Added cpe provisioning enabled in order

This commit is contained in:
Frank Schubert
2021-11-18 22:05:33 +01:00
parent 8a91ce062e
commit 48620673ff
2 changed files with 92 additions and 4 deletions

View File

@@ -374,7 +374,7 @@
<td><?=($order->finish_after) ? date("d.m.Y",$order->finish_after) : "--.--.----" ?></td>
<th class="bg-light">Rechnungsart:</th>
<td><?=($order->billing_type == "sepa") ? "order-date-pillSEPA" : "Rechnung"?></td>
<td><?=($order->billing_type == "sepa") ? "SEPA" : "Rechnung"?></td>
<th class="bg-light">Einwilligungen:</th>
<td><?=($order->allow_contact) ? "<span class='order-date-pill active'><i class='fas fa-check text-success'></i> Info</span>" : ""?> <?=($order->allow_spin) ? "<span class='order-date-pill active ml-1'><i class='fas fa-check text-success'></i> SPIN</span>" : ""?></td>
@@ -810,7 +810,7 @@
<td><?=($order->finish_after) ? date("d.m.Y",$order->finish_after) : "--.--.----"?></td>
<th class="bg-light">Rechnungsart:</th>
<td><?=($order->billing_type == "sepa") ? "order-date-pillSEPA" : "Rechnung"?></td>
<td><?=($order->billing_type == "sepa") ? "SEPA" : "Rechnung"?></td>
<th class="bg-light">Einwilligungen:</th>
<td><?=($order->allow_contact) ? "<span class='order-date-pill active'><i class='fas fa-check text-success'></i> Info</span>" : ""?> <?=($order->allow_spin) ? "<span class='order-date-pill active ml-1'><i class='fas fa-check text-success'></i> SPIN</span>" : ""?></td>
@@ -819,8 +819,8 @@
<div class="row">
<div class="form-group col-lg-4 col-md-6 col-sm-8">
<label>Vorortinstallation:</label>
<div class="form-group col-lg-4 col-md-6">
<label for="vororttermin-<?=$order->id?>">Vorortinstallation:</label>
<div class="input-group">
<input type="text" class="form-control datepicker" id="vororttermin-<?=$order->id?>" name="vororttermin" value="<?=($order->install_date) ? date("d.m.Y",$order->install_date) : ""?>" placeholder="--.--.----" />
<div class="input-group-append">
@@ -829,6 +829,16 @@
</div>
</div>
</div>
<div class="form-group col-lg-4 col-md-6 text-center">
<label for="cpeprovisioning_enabled-<?=$order->id?>">CPE Konfig freigegeben:</label>
<div class="input-group">
<input type="checkbox" class="form-control" id="cpeprovisioning_enabled-<?=$order->id?>" name="cpeprovisioning_enabled" value="1" onchange="saveCpeprovisioning(<?=$order->id?>)" />
</div>
<small id="cpeprovisioning_enabled-<?=$order->id?>-success" class="text-success hidden">Gespeichert!</small>
<small id="cpeprovisioning_enabled-<?=$order->id?>-error" class="text-danger hidden">Fehler beim Speichern!</small>
</div>
</div>
<?php if(is_array($order->products) && count($order->products)): ?>
@@ -1060,6 +1070,50 @@
"json"
);
}
function saveCpeprovisioning(id) {
var enabled = 0;
$('#cpeprovisioning_enabled-' + id + '-error').hide();
$('#cpeprovisioning_enabled-' + id + '-success').hide();
if($('#cpeprovisioning_enabled-' + id).is(":checked")) {
enabled = 1;
}
$.post('<?=self::getUrl("Order", "saveCpeprovisioning")?>',
{
'id': id,
'enabled': enabled
},
function(data) {
console.log(data);
var id = data.order.id;
var enabled = data.order.enabled;
if(data.status == "OK") {
$('#cpeprovisioning_enabled-' + id + '-error').hide();
$('#cpeprovisioning_enabled-' + id + '-success').show();
setTimeout(function() {
$('#cpeprovisioning_enabled-' + id + '-success').hide(1000);
}, 3000, id);
} else {
$('#cpeprovisioning_enabled-' + id + '-success').hide();
$('#cpeprovisioning_enabled-' + id + '-error').text(data.msg);
$('#cpeprovisioning_enabled-' + id + '-error').show();
if(enabled) {
$('#cpeprovisioning_enabled-' + id).prop("checked",true);
} else {
$('#cpeprovisioning_enabled-' + id).prop("checked",false);
}
}
},
"json"
);
}
</script>
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>

View File

@@ -757,6 +757,40 @@ class OrderController extends mfBaseController {
$this->returnJson(["status" => "OK", "order" => ['id' => $order_id, 'date' => ($date) ? date('d.m.Y', $date) : ""]]);
}
protected function saveCpeprovisioningAction() {
if(!$this->me->is(["Admin","salespartner"])) {
$this->layout()->setFlash("Keine Berechtigung", "error");
$this->redirect("Order");
}
$r = $this->request;
$order_id = $r->id;
if(!is_numeric($order_id) || $order_id < 1) {
$this->returnJson(["status" => "error", "msg" => "Fehler beim Speichern!", "order" => ['id' => $order_id]]);
}
$order = new Order($order_id);
if(!$order->id) {
$this->returnJson(["status" => "error", "msg" => "Fehler beim Speichern!", "order" => ['id' => $order_id]]);
}
$enabled = $r->enabled;
if($enabled === null || !is_numeric($enabled)) {
$this->returnJson(["status" => "error", "msg" => "Fehler beim Speichern!", "order" => ['id' => $order_id]]);
}
$term = $order->terminations[0];
if($enabled && !$term->getWorkflowvalue("pop_id")) {
$this->returnJson(["status" => "error", "msg" => "Kein POP im Leitungsbau!", "order" => ['id' => $order_id, "enabled" => 0]]);
}
$order->cpeprovisioning_enabled = ($enabled) ? 1 : 0;
$order->save();
$this->returnJson(["status" => "OK", "order" => ['id' => $order_id]]);
}
protected function deleteAction() {
if(!$this->me->is(["Admin","salespartner"])) {
$this->layout()->setFlash("Keine Berechtigung", "error");