Added minor things to Order; fixed saving patcher in Patching

This commit is contained in:
Frank Schubert
2021-11-09 21:04:29 +01:00
parent 33c9f7b2be
commit 8dd3831c0a
11 changed files with 159 additions and 32 deletions

View File

@@ -58,7 +58,7 @@
<?php endif; ?> <?php endif; ?>
</div> </div>
<form method="post" id="submit-form" action="<?=self::getUrl("Cpeshipping", "ship")?>"> <form method="post" id="submit-form" action="<?=self::getUrl("Cpeshipping", "save")?>">
<table class="table table-striped table-hover"> <table class="table table-striped table-hover">
<tr> <tr>
<th class="text-center">Versand<br /><input type="checkbox" id="checkAll" class="form-control" /></th> <th class="text-center">Versand<br /><input type="checkbox" id="checkAll" class="form-control" /></th>
@@ -73,8 +73,14 @@
<td class="versand-checkbox text-center"><input type="checkbox" class="form-control" id="ship-<?=$c->id?>" name="ships[]" value="<?=$c->id?>" /></td> <td class="versand-checkbox text-center"><input type="checkbox" class="form-control" id="ship-<?=$c->id?>" name="ships[]" value="<?=$c->id?>" /></td>
<td class="text-center"> <td class="text-center">
<?php if(array_key_exists("hostnetwork_order", $c->orderproduct->product->attributes) && $c->orderproduct->product->attributes['hostnetwork_order']->value): ?> <?php if(array_key_exists("hostnetwork_order", $c->orderproduct->product->attributes) && $c->orderproduct->product->attributes['hostnetwork_order']->value): ?>
<input type="checkbox" class="form-control" id="external_finish-<?=$c->id?>" name="external_finish-<?=$c->id?>" value="1" /> <input type="hidden" name="prov[]" value="<?=$c->id?>" />
<input type="checkbox" class="form-control" id="external_finish-<?=$c->id?>" name="external_finish[<?=$c->id?>]" value="1" <?=($c->external_finished) ? "checked='checked'" : ""?> />
<span id="ship-error-<?=$c->id?>" class="text-danger hidden">Vorleistungsdienst muss bestellt sein vor Versand!</span> <span id="ship-error-<?=$c->id?>" class="text-danger hidden">Vorleistungsdienst muss bestellt sein vor Versand!</span>
<span class="text-info" <?=($c->external_finished_by) ? "title='Vorleistungsdienst bestellt von ".$c->external_finisher->name." (".$c->external_finisher->address->getCompanyOrName(true).")'" : ""?>>
<?php if($c->external_finished_by): ?>
<?=($c->external_finished_by) ? $c->external_finisher->getAbbrName() : ""?>
<?php endif; ?>
</span>
<?php else: ?> <?php else: ?>
<i>nicht erforderlich</i> <i>nicht erforderlich</i>
<?php endif; ?> <?php endif; ?>
@@ -89,7 +95,8 @@
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<input type="submit" class="btn btn-primary" value="Versand-CSV generieren" /> <button type="submit" name="type" class="btn btn-outline-primary" value="save" />Speichern</button>
<button type="submit" name="type" class="btn btn-primary ml-2" value="ship" >Versand-CSV generieren</button>
</div> </div>
</div> </div>
@@ -143,11 +150,11 @@
var error = false; var error = false;
$('input[name^=external_finish-]').each(function() { $('input[id^=external_finish-]').each(function() {
var id_match = $(this).attr("name").match(/external_finish-(\d+)$/); var id_match = $(this).attr("id").match(/external_finish-(\d+)$/);
var id = id_match[1]; var id = id_match[1];
if(!$("input[name^=external_finish-").is(":checked")) { if(!$("input[id^=external_finish-").is(":checked")) {
if($("#ship-" + id).is(":checked")) { if($("#ship-" + id).is(":checked")) {
error = true; error = true;
$("#ship-error-" + id).show(); $("#ship-error-" + id).show();

View File

@@ -1,4 +1,6 @@
<?php //var_dump($order);exit; ?> <?php
$includes_external_product = false;
?>
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?> <?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
<!-- start page title --> <!-- start page title -->
@@ -260,6 +262,12 @@
<input type="text" class="form-control" name="order_date" id="order_date" value="<?=($order->order_date) ? date("d.m.Y", $order->order_date) : date("d.m.Y")?>" /> <input type="text" class="form-control" name="order_date" id="order_date" value="<?=($order->order_date) ? date("d.m.Y", $order->order_date) : date("d.m.Y")?>" />
</div> </div>
</div> </div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="partner_number">Partnernummer</label>
<div class="col-lg-4">
<input type="text" class="form-control" name="partner_number" id="partner_number" value="<?=$order->partner_number?>" />
</div>
</div>
<h5 class="mt-3">Verzögerte Herstellung:</h5> <h5 class="mt-3">Verzögerte Herstellung:</h5>
@@ -353,6 +361,11 @@
<?php if(is_array($order->products) && count($order->products)): ?> <?php if(is_array($order->products) && count($order->products)): ?>
<?php foreach($order->products as $product): ?> <?php foreach($order->products as $product): ?>
<?php
if($product->product->external == 1) {
$includes_external_product = true;
}
?>
<div class="row product-container"> <div class="row product-container">
<div class="col-md-1 product-<?=$product->id?>"> <div class="col-md-1 product-<?=$product->id?>">
<!-- pos number --> <!-- pos number -->
@@ -607,7 +620,7 @@
<div class="card-body"> <div class="card-body">
<?php if($me->is("Admin", "netoperator")): ?> <?php if($me->is("Admin", "netoperator")): ?>
<?php if($order->id): ?> <?php if($order->id && !$includes_external_product): ?>
<div class="form-group row"> <div class="form-group row">
<label class="col-lg-2"></label> <label class="col-lg-2"></label>
<div class="col-lg-10 mb-2"> <div class="col-lg-10 mb-2">

View File

@@ -76,6 +76,11 @@
<input type="text" class="form-control" name="filter[building_street]" id="filter_building_street" value="<?=$filter['building_street']?>" /> <input type="text" class="form-control" name="filter[building_street]" id="filter_building_street" value="<?=$filter['building_street']?>" />
</div> </div>
<div class="col-1">
<label class="form-label" for="filter_partner_number">Partnernummer</label>
<input type="text" class="form-control" name="filter[partner_number]" id="filter_partner_number" value="<?=$filter['partner_number']?>" />
</div>
<div class="col-2"> <div class="col-2">
<label class="form-label" for="filter_finish_date">Bestellstatus</label> <label class="form-label" for="filter_finish_date">Bestellstatus</label>
<select name="filter[finish_date]" id="filter_finish_date" class="form-control"> <select name="filter[finish_date]" id="filter_finish_date" class="form-control">
@@ -224,7 +229,7 @@
<form method="post" action="<?=self::getUrl("OrderJournal", "save")?>"> <form method="post" action="<?=self::getUrl("OrderJournal", "save")?>">
<input type="hidden" name="order_id" value="<?=$order->id?>" /> <input type="hidden" name="order_id" value="<?=$order->id?>" />
<input type="hidden" name="s" value="<?=$pagination['start']?>" /> <input type="hidden" name="s" value="<?=$pagination['start']?>" />
<?php foreach($filter as $n => $v): ?> <?php if(is_array($filter) && count($filter)) foreach($filter as $n => $v): ?>
<input type="hidden" name="filter[<?=$n?>]" value="<?=$v?>" /> <input type="hidden" name="filter[<?=$n?>]" value="<?=$v?>" />
<?php endforeach; ?> <?php endforeach; ?>
<textarea name="text" class="form-control mb-2" style="height:120px;"></textarea> <textarea name="text" class="form-control mb-2" style="height:120px;"></textarea>
@@ -279,7 +284,9 @@
<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="--.--.----" /> <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"> <div class="input-group-append">
<button class="btn btn-outline-primary" id="vororttermin-button-<?=$order->id?>" type="button" title="Vororttermin speichern" onclick="saveVororttermin(<?=$order->id?>)"><i class="fas fa-save"></i></button> <button class="btn btn-outline-primary" id="vororttermin-button-<?=$order->id?>" type="button" title="Vororttermin speichern" onclick="saveVororttermin(<?=$order->id?>)"><i class="fas fa-save"></i></button>
<button class="btn btn-outline-danger ml-1" id="vororttermin-delete-<?=$order->id?>" type="button" title="Vororttermin speichern" onclick="saveVororttermin(<?=$order->id?>, true)"><i class="fas fa-trash"></i></button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@@ -555,9 +562,9 @@
<form method="post" action="<?=self::getUrl("OrderJournal", "save")?>"> <form method="post" action="<?=self::getUrl("OrderJournal", "save")?>">
<input type="hidden" name="order_id" value="<?=$order->id?>" /> <input type="hidden" name="order_id" value="<?=$order->id?>" />
<input type="hidden" name="s" value="<?=$pagination['start']?>" /> <input type="hidden" name="s" value="<?=$pagination['start']?>" />
<?php foreach($filter as $n => $v): ?> <?php if(is_array($filter) && count($filter)): foreach($filter as $n => $v): ?>
<input type="hidden" name="filter[<?=$n?>]" value="<?=$v?>" /> <input type="hidden" name="filter[<?=$n?>]" value="<?=$v?>" />
<?php endforeach; ?> <?php endforeach; endif; ?>
<textarea name="text" class="form-control mb-2" style="height:120px;"></textarea> <textarea name="text" class="form-control mb-2" style="height:120px;"></textarea>
<button class="btn btn-sm btn-primary" type="submit"><i class="fas fa-save"></i> Speichern</button> <button class="btn btn-sm btn-primary" type="submit"><i class="fas fa-save"></i> Speichern</button>
</form> </form>
@@ -610,6 +617,7 @@
<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="--.--.----" /> <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"> <div class="input-group-append">
<button class="btn btn-outline-primary" id="vororttermin-button-<?=$order->id?>" type="button" title="Vororttermin speichern" onclick="saveVororttermin(<?=$order->id?>)"><i class="fas fa-save"></i></button> <button class="btn btn-outline-primary" id="vororttermin-button-<?=$order->id?>" type="button" title="Vororttermin speichern" onclick="saveVororttermin(<?=$order->id?>)"><i class="fas fa-save"></i></button>
<button class="btn btn-outline-danger ml-1" id="vororttermin-delete-<?=$order->id?>" type="button" title="Vororttermin speichern" onclick="saveVororttermin(<?=$order->id?>, true)"><i class="fas fa-trash"></i></button>
</div> </div>
</div> </div>
</div> </div>
@@ -790,15 +798,18 @@
<?php endif; ?> <?php endif; ?>
function saveVororttermin(id) { function saveVororttermin(id, removeDate = false) {
date = $('#vororttermin-' + id).val(); date = $('#vororttermin-' + id).val();
if(!date) { if(removeDate) {
date = "";
}
/*if(!date) {
$('#vororttermin-button-' + id).addClass("btn-danger"); $('#vororttermin-button-' + id).addClass("btn-danger");
$('#vororttermin-button-' + id).removeClass("btn-outline-success"); $('#vororttermin-button-' + id).removeClass("btn-outline-success");
$('#vororttermin-button-' + id).removeClass("btn-outline-primary"); $('#vororttermin-button-' + id).removeClass("btn-outline-primary");
$('#vororttermin-' + id).addClass("is-invalid"); $('#vororttermin-' + id).addClass("is-invalid");
return false; return false;
} }*/
$.post('<?=self::getUrl("Order", "saveVororttermin")?>', $.post('<?=self::getUrl("Order", "saveVororttermin")?>',
{ {
@@ -815,8 +826,15 @@
$('#vororttermin-' + id).addClass("is-valid"); $('#vororttermin-' + id).addClass("is-valid");
$('#vororttermin-' + id).removeClass("is-invalid"); $('#vororttermin-' + id).removeClass("is-invalid");
if(data.order.date) {
$('#date-pill-' + id + '-install_date').html('Vorortinstallation: <span class="text-monospace"><span class="text-success">' + data.order.date + '</span></span>'); $('#date-pill-' + id + '-install_date').html('Vorortinstallation: <span class="text-monospace"><span class="text-success">' + data.order.date + '</span></span>');
$('#date-pill-' + id + '-install_date').addClass("active"); $('#date-pill-' + id + '-install_date').addClass("active");
} else {
$('#date-pill-' + id + '-install_date').removeClass("active");
$('#date-pill-' + id + '-install_date').html('Vorortinstallation: <span class="text-monospace"><span class="text-success">--.--.----</span></span>');
$('#vororttermin-' + id).val("");
}
setTimeout(function() { setTimeout(function() {
$('#vororttermin-' + id).removeClass("is-valid"); $('#vororttermin-' + id).removeClass("is-valid");

View File

@@ -16,7 +16,7 @@
</li> </li>
<li class="dropdown notification-list"> <li class="dropdown notification-list">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="false" aria-expanded="false"> <a class="nav-link dropdown-toggle" data-toggle="adropdown" href="#" role="button" aria-haspopup="false" aria-expanded="false">
<i class="fe-bell noti-icon"></i> <i class="fe-bell noti-icon"></i>
<!--<span class="badge badge-danger rounded-circle noti-icon-badge">2</span>--> <!--<span class="badge badge-danger rounded-circle noti-icon-badge">2</span>-->
</a> </a>
@@ -33,7 +33,7 @@
</h5> </h5>
</div> </div>
<div class="slimscroll noti-scroll"> <div class="aslimscroll noti-scroll">
<!-- item--> <!-- item-->
<a href="javascript:void(0);" class="dropdown-item notify-item"> <a href="javascript:void(0);" class="dropdown-item notify-item">

View File

@@ -6,6 +6,7 @@ class Cpeprovisioning extends mfBaseModel {
private $order; private $order;
private $orderproduct; private $orderproduct;
private $termination; private $termination;
private $external_finisher;
private $creator; private $creator;
private $editor; private $editor;
@@ -21,6 +22,11 @@ class Cpeprovisioning extends mfBaseModel {
return $this->orderproduct; return $this->orderproduct;
} }
if($name == "external_finisher") {
$this->external_finisher = new User($this->external_finished_by);
return $this->external_finisher;
}
if($name == "creator") { if($name == "creator") {
$this->creator = new User($this->create_by); $this->creator = new User($this->create_by);
return $this->creator; return $this->creator;

View File

@@ -5,8 +5,14 @@ class CpeprovisioningModel {
public $order_id; public $order_id;
public $orderproduct_id; public $orderproduct_id;
public $routerconfig_finished; public $routerconfig_finished;
public $order_journal_id;
public $routertype; public $routertype;
public $shipping; public $shipping;
public $shipping_date;
public $external_finished;
public $external_finished_by;
public $shipped;
public $shipped_by;
public $wifi_ssid; public $wifi_ssid;
public $wifi_pass; public $wifi_pass;
public $mac; public $mac;

View File

@@ -60,15 +60,67 @@ class CpeshippingController extends mfBaseController {
$this->layout()->set("pagination", $pagination); $this->layout()->set("pagination", $pagination);
} }
protected function saveAction() {
$r = $this->request;
if($r->type == "ship") {
return $this->shipAction();
}
//var_dump($r);exit;
if(is_array($r->external_finish) && count($r->external_finish)) {
$ext_finish = $r->external_finish;
}
if(is_array($r->prov) && count($r->prov)) {
$provs = $r->prov;
}
if(!count($provs)) {
$this->layout()->setFlash("Nichts zu speichern", "warning");
$this->redirect("Cpeshipping");
}
$shippings = [];
foreach($provs as $prov_id) {
if(!is_numeric($prov_id) || $prov_id <= 0) {
continue;
}
$prov = new Cpeprovisioning($prov_id);
if(!$prov->id) {
continue;
}
if(!$prov->shipping) {
// is not supposed to be selectable in UI
continue;
}
if(array_key_exists($prov_id, $ext_finish) && $ext_finish[$prov_id] == 1) {
$prov->external_finished = date('U');
$prov->external_finished_by = $this->me->id;
} else {
$prov->external_finished = null;
$prov->external_finished_by = $this->me->id;
}
$prov->save();
}
$this->layout()->setFlash("Erfolgreich gespeichert.", "success");
$this->redirect("Cpeshipping");
}
protected function shipAction() { protected function shipAction() {
//$this->redirect("Cpeshipping");
$r = $this->request; $r = $this->request;
//var_dump($r);exit; //var_dump($r);exit;
$ships = [];
if(is_array($r->ships) && count($r->ships)) { if(is_array($r->ships) && count($r->ships)) {
$ships = $r->ships; $ships = $r->ships;
} }
$ext_finish = [];
if(is_array($r->external_finish) && count($r->external_finish)) {
$ext_finish = $r->external_finish;
}
if(!count($ships)) { if(!count($ships)) {
$this->layout()->setFlash("Keine CPEs ausgewählt", "warning"); $this->layout()->setFlash("Keine CPEs ausgewählt", "warning");
@@ -90,8 +142,16 @@ class CpeshippingController extends mfBaseController {
// is not supposed to be selectable in UI // is not supposed to be selectable in UI
continue; continue;
} }
$shippings[] = $prov;
if(array_key_exists($prov_id, $ext_finish) && $ext_finish[$prov_id] == 1) {
$prov->external_finished = date('U');
$prov->external_finished_by = $this->me->id;
} else {
$prov->external_finished = null;
$prov->external_finished_by = $this->me->id;
}
$prov->save();
$shippings[] = $prov;
} }
$tpl = new Layout(); $tpl = new Layout();

View File

@@ -409,6 +409,7 @@ class OrderController extends mfBaseController {
} else { } else {
$order_data['billing_type'] = "invoice"; $order_data['billing_type'] = "invoice";
} }
$order_data['partner_number'] = $r->partner_number;
$order_data['bank_account_bank'] = $r->bank_account_bank; $order_data['bank_account_bank'] = $r->bank_account_bank;
$order_data['bank_account_owner'] = $r->bank_account_owner; $order_data['bank_account_owner'] = $r->bank_account_owner;
$order_data['bank_account_iban'] = $r->bank_account_iban; $order_data['bank_account_iban'] = $r->bank_account_iban;
@@ -688,19 +689,24 @@ class OrderController extends mfBaseController {
} }
$date = $r->install_date; $date = $r->install_date;
if(!$date) { if($date === null) {
$this->returnJson(["status" => "error", "order" => ['id' => $order_id]]); $this->returnJson(["status" => "error", "order" => ['id' => $order_id]]);
} }
if($date) {
$date = Layout::dateToInt($date); $date = Layout::dateToInt($date);
if(!$date) { if(!$date) {
$this->returnJson(["status" => "error", "order" => ['id' => $order_id]]); $this->returnJson(["status" => "error", "order" => ['id' => $order_id]]);
} }
} elseif($date === "") {
$date = null;
}
$order->install_date = $date; $order->install_date = $date;
$order->save(); $order->save();
$this->returnJson(["status" => "OK", "order" => ['id' => $order_id, 'date' => date('d.m.Y', $date)]]); $this->returnJson(["status" => "OK", "order" => ['id' => $order_id, 'date' => ($date) ? date('d.m.Y', $date) : ""]]);
} }
protected function deleteAction() { protected function deleteAction() {

View File

@@ -3,6 +3,7 @@
class OrderModel { class OrderModel {
public $owner_id; public $owner_id;
public $billingaddress_id; public $billingaddress_id;
public $partner_number;
public $order_date; public $order_date;
public $finish_date; public $finish_date;
public $finish_after; public $finish_after;
@@ -246,6 +247,13 @@ class OrderModel {
} }
} }
if(array_key_exists("partner_number", $filter)) {
$partner_number = FronkDB::singleton()->escape($filter['partner_number']);
if($partner_number) {
$where .= " AND Order.partner_number like '%$partner_number%'";
}
}
if(array_key_exists("create_by", $filter)) { if(array_key_exists("create_by", $filter)) {
$create_by = $filter['create_by']; $create_by = $filter['create_by'];
if(is_numeric($create_by)) { if(is_numeric($create_by)) {

View File

@@ -177,14 +177,15 @@ class PatchingController extends mfBaseController {
$mode = "add"; $mode = "add";
$patch_data["termination_id"] = $term_id; $patch_data["termination_id"] = $term_id;
} }
//var_dump($mode, $r);exit;
if($mode == "add") { if($mode == "add") {
$patch_data['create_by'] = 1;
$patching = PatchingModel::create($patch_data);
if($patch_data["patched"]) { if($patch_data["patched"]) {
$patch_data["patched_by"] = $this->me->id; $patch_data["patched_by"] = $this->me->id;
$patch_data["patched_date"] = date("U"); $patch_data["patched_date"] = date("U");
} }
$patch_data['create_by'] = $this->me_id;
$patching = PatchingModel::create($patch_data);
} else { } else {
if($patch_data["patched"] && !$patching->patched) { if($patch_data["patched"] && !$patching->patched) {
$patch_data["patched_by"] = $this->me->id; $patch_data["patched_by"] = $this->me->id;
@@ -192,7 +193,7 @@ class PatchingController extends mfBaseController {
} }
$patching->update($patch_data); $patching->update($patch_data);
} }
//var_dump($patching);exit;
$id = $patching->save(); $id = $patching->save();
if(!$id) { if(!$id) {
$this->layout()->setFlash("Fehler beim Speichern", "error"); $this->layout()->setFlash("Fehler beim Speichern", "error");

View File

@@ -7,6 +7,8 @@ class PatchingModel {
public $device_name = null; public $device_name = null;
public $device_port = null; public $device_port = null;
public $patched = null; public $patched = null;
public $patched_by = null;
public $patched_date = null;
public $create_by = null; public $create_by = null;
public $edit_by = null; public $edit_by = null;