Added Cpeprovisioning/Save
This commit is contained in:
@@ -74,16 +74,46 @@
|
||||
<td class="text-pink"><?=$product->order->owner->spin?></td>
|
||||
<td><?=$product->order->owner->getCompanyOrName()?></td>
|
||||
<td><?=$product->product->name?></td>
|
||||
<td><?=$product->product->attributes['bras_type']->value?></td>
|
||||
<td><?=$product->product->attributes['bras_type']->value?> - Down: <?=$product->product->attributes["bw_down"]?> / Up: <?=$product->product->attributes["bw_up"]?></td>
|
||||
<td class="text-monospace">
|
||||
<?php if($product->termination_id): ?>
|
||||
<label class="order-date-pill active pointer">Public: <strong><?=$product->termination->building->pop->vlan_public?></strong> <input type="checkbox" name="router_vlan_public" /></label>
|
||||
<label class="order-date-pill active pointer">NAT: <strong><?=$product->termination->building->pop->vlan_nat?></strong> <input type="checkbox" name="router_vlan_nat" /></label>
|
||||
<label class="order-date-pill active pointer">IPv6: <strong><?=$product->termination->building->pop->vlan_ipv6?></strong> <input type="checkbox" name="router_vlan_ipv6" /></label>
|
||||
<?php if($product->termination->building->pop->vlan_public): ?>
|
||||
<label class="order-date-pill active pointer">
|
||||
Public: <strong><?=$product->termination->building->pop->vlan_public?></strong>
|
||||
<input type="checkbox" name="vlan_inet" form="cpeprovform-<?=$product->id?>" value="<?=$product->termination->building->pop->vlan_public?>" />
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php if($product->termination->building->pop->vlan_nat): ?>
|
||||
<label class="order-date-pill active pointer">
|
||||
NAT: <strong><?=$product->termination->building->pop->vlan_nat?></strong>
|
||||
<input type="checkbox" name="vlan_nat" form="cpeprovform-<?=$product->id?>" value="<?=$product->termination->building->pop->vlan_nat?>" />
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php if($product->termination->building->pop->vlan_ipv6): ?>
|
||||
<label class="order-date-pill active pointer">
|
||||
IPv6: <strong><?=$product->termination->building->pop->vlan_ipv6?></strong>
|
||||
<input type="checkbox" name="vlan_ipv6" form="cpeprovform-<?=$product->id?>" value="<?=$product->termination->building->pop->vlan_ipv6?>" />
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<label class="order-date-pill active pointer">Public: <strong><?=$product->product->attributes['vlan_default_public']->value?></strong> <input type="checkbox" name="router_vlan_public" /></label>
|
||||
<label class="order-date-pill active pointer">NAT: <strong><?=$product->product->attributes['vlan_default_nat']->value?></strong> <input type="checkbox" name="router_vlan_nat" /></label>
|
||||
<label class="order-date-pill active pointer">IPv6: <strong><?=$product->product->attributes['vlan_default_ipv6']->value?></strong> <input type="checkbox" name="router_vlan_ipv6" /></label>
|
||||
<?php if($product->product->attributes['vlan_default_public']->value): ?>
|
||||
<label class="order-date-pill active pointer">
|
||||
Public: <strong><?=$product->product->attributes['vlan_default_public']->value?></strong>
|
||||
<input type="checkbox" name="vlan_inet" form="cpeprovform-<?=$product->id?>" value="<?=$product->product->attributes['vlan_default_public']->value?>" />
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php if($product->product->attributes['vlan_default_nat']->value): ?>
|
||||
<label class="order-date-pill active pointer">
|
||||
NAT: <strong><?=$product->product->attributes['vlan_default_nat']->value?></strong>
|
||||
<input type="checkbox" name="vlan_nat" form="cpeprovform-<?=$product->id?>" value="<?=$product->product->attributes['vlan_default_nat']->value?>" />
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php if($product->product->attributes['vlan_default_ipv6']->value): ?>
|
||||
<label class="order-date-pill active pointer">
|
||||
IPv6: <strong><?=$product->product->attributes['vlan_default_ipv6']->value?></strong>
|
||||
<input type="checkbox" name="vlan_ipv6" form="cpeprovform-<?=$product->id?>" value="<?=$product->product->attributes['vlan_default_ipv6']->value?>" />
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td style="font-size: 18px; cursor:pointer; min-width: 180px;">
|
||||
@@ -92,6 +122,7 @@
|
||||
$vot = false;
|
||||
$hw = false;
|
||||
$voip = false;
|
||||
|
||||
foreach($product->order->products as $prod) {
|
||||
if(is_array($prod->product->attributes) && count($prod->product->attributes)) {
|
||||
if(array_key_exists("hw_only", $prod->product->attributes)) {
|
||||
@@ -124,94 +155,105 @@
|
||||
<tr class="<?=($prov_count % 2 == 0) ? "table-bg-even" : "table-bg-odd"?> ">
|
||||
<td colspan="6">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="router_type-<?=$product->id?>">Router</label>
|
||||
<select class="form-control" name="router_type" id="router_type-<?=$product->id?>">
|
||||
<option></option>
|
||||
<option value="eigener Router">Eigener Router</option>
|
||||
<option value="anderes CPE">Anderes CPE</option>
|
||||
<?php if(preg_match('/^(pppoe|dhcp)$/', $product->product->attributes['bras_type']->value)): ?>
|
||||
<option value="TP-Link Archer C80">TP-Link Archer C80 (Inet, IPTV)</option>
|
||||
<option value="FritzBox 4040">FritzBox 4040 (Inet, IPTV)</option>
|
||||
<option value="FritzBox 7530">FritzBox 7530 (Inet, Phone, IPTV)</option>
|
||||
<option value="FritzBox 7590">FritzBox 7590 (Inet, Phone, IPTV)</option>
|
||||
<?php elseif($product->product->attributes['bras_type']->value = "static"): ?>
|
||||
<option value="Mikrotik HAP AC">Mikrotik HAP AC (Inet, IPTV)</option>
|
||||
<option value="Mikrotik HEX S">Mikrotik HEX S (Inet, IPTV)</option>
|
||||
<option value="Mikrotik RB3011">Mikrotik RB3011 (Inet, IPTV)</option>
|
||||
<?php elseif($product->product->attributes['bras_type']->value == "cmts"): ?>
|
||||
<option value="FritzBox 6490 Cable">FritzBox 6490 Cable (Inet, Phone, IPTV)</option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-1">
|
||||
<div class="form-group text-center">
|
||||
<label class="form-label" for="router_wifi_ssid-<?=$product->id?>">WLAN SSID</label>
|
||||
<input class="form-control" type="text" name="router_wifi_ssid" id="router_wifi_ssid-<?=$product->id?>" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<form method="post" id="cpeprovform-<?=$product->id?>" action="<?=self::getUrl("Cpeprovisioning", "Save")?>">
|
||||
<input type="hidden" name="order_id" value="<?=$product->order_id?>" />
|
||||
<input type="hidden" name="orderproduct_id" value="<?=$product->id?>" />
|
||||
<input type="hidden" name="termination_id" value="<?=$product->termination_id?>" />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="routertype-<?=$product->id?>">Router</label>
|
||||
<select class="form-control" name="routertype" id="routertype-<?=$product->id?>">
|
||||
<option></option>
|
||||
<option value="eigener Router" <?=($product->cpeprovisioning->routertype == "eigener Router") ? "selected='selected'" : ""?>>Eigener Router</option>
|
||||
<option value="anderes CPE" <?=($product->cpeprovisioning->routertype == "anderes CPE") ? "selected='selected'" : ""?>>Anderes CPE</option>
|
||||
<?php if(preg_match('/^(pppoe|dhcp)$/', $product->product->attributes['bras_type']->value)): ?>
|
||||
<option value="TP-Link Archer C80" <?=($product->cpeprovisioning->routertype == "TP-Link Archer C80") ? "selected='selected'" : ""?>>TP-Link Archer C80 (Inet, IPTV)</option>
|
||||
<option value="FritzBox 4040" <?=($product->cpeprovisioning->routertype == "FritzBox 4040") ? "selected='selected'" : ""?>>FritzBox 4040 (Inet, IPTV)</option>
|
||||
<option value="FritzBox 7530" <?=($product->cpeprovisioning->routertype == "FritzBox 7530") ? "selected='selected'" : ""?>>FritzBox 7530 (Inet, Phone, IPTV)</option>
|
||||
<option value="FritzBox 7590" <?=($product->cpeprovisioning->routertype == "FritzBox 7590") ? "selected='selected'" : ""?>>FritzBox 7590 (Inet, Phone, IPTV)</option>
|
||||
<?php elseif($product->product->attributes['bras_type']->value = "static"): ?>
|
||||
<option value="Mikrotik HAP AC" <?=($product->cpeprovisioning->routertype == "Mikrotik HAP AC") ? "selected='selected'" : ""?>>Mikrotik HAP AC (Inet, IPTV)</option>
|
||||
<option value="Mikrotik HEX S" <?=($product->cpeprovisioning->routertype == "Mikrotik HEX S") ? "selected='selected'" : ""?>>Mikrotik HEX S (Inet, IPTV)</option>
|
||||
<option value="Mikrotik RB3011" <?=($product->cpeprovisioning->routertype == "Mikrotik RB3011") ? "selected='selected'" : ""?>>Mikrotik RB3011 (Inet, IPTV)</option>
|
||||
<?php elseif($product->product->attributes['bras_type']->value == "cmts"): ?>
|
||||
<option value="FritzBox 6490 Cable" <?=($product->cpeprovisioning->routertype == "FritzBox 6490 Cable") ? "selected='selected'" : ""?>>FritzBox 6490 Cable (Inet, Phone, IPTV)</option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="router_wifi_pass-<?=$product->id?>">WLAN Passwort</label>
|
||||
<input class="form-control" type="text" name="router_wifi_pass" id="router_wifi_pass-<?=$product->id?>" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-1">
|
||||
<div class="form-group text-center">
|
||||
<label class="form-label" for="create_shipment_task-<?=$product->id?>">Versandauftrag</label>
|
||||
<input class="form-control" type="checkbox" value="1" name="create_shipment_task" id="create_shipment_task-<?=$product->id?>" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> />
|
||||
|
||||
<div class="col-md-1">
|
||||
<div class="form-group text-center">
|
||||
<label class="form-label" for="wifi_ssid-<?=$product->id?>">WLAN SSID</label>
|
||||
<input class="form-control" type="text" name="wifi_ssid" id="router_wifi_ssid-<?=$product->id?>" value="<?=$product->cpeprovisioning->wifi_ssid?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="ship_weight-<?=$product->id?>">Gewicht</label>
|
||||
<input class="form-control" type="text" name="ship_weight" id="ship_weight-<?=$product->id?>" value="" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> />
|
||||
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="wifi_pass-<?=$product->id?>">WLAN Passwort</label>
|
||||
<input class="form-control" type="text" name="wifi_pass" id="router_wifi_pass-<?=$product->id?>" value="<?=$product->cpeprovisioning->wifi_pass?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="ship_length-<?=$product->id?>">Länge</label>
|
||||
<input class="form-control" type="text" name="ship_length" id="ship_length-<?=$product->id?>" value="" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> />
|
||||
|
||||
<?php if($vot): ?>
|
||||
<div class="col-md-5"></div>
|
||||
<?php else: ?>
|
||||
<div class="col-md-1">
|
||||
<div class="form-group text-center">
|
||||
<label class="form-label" for="shipping-<?=$product->id?>">Versandauftrag</label>
|
||||
<input class="form-control" type="checkbox" value="1" name="shipping" id="shipping-<?=$product->id?>" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> <?=($product->cpeprovisioning->shipping) ? "checked='checked'" : ""?> />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="ship_width-<?=$product->id?>">Breite</label>
|
||||
<input class="form-control" type="text" name="ship_width" id="ship_width-<?=$product->id?>" value="" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> />
|
||||
|
||||
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="ship_weight-<?=$product->id?>">Gewicht</label>
|
||||
<input class="form-control" type="text" name="ship_weight" id="ship_weight-<?=$product->id?>" value="<?=$product->cpeprovisioning->ship_weight?>" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="ship_height-<?=$product->id?>">Höhe</label>
|
||||
<input class="form-control" type="text" name="ship_height" id="ship_height-<?=$product->id?>" value="" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> />
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="ship_length-<?=$product->id?>">Länge</label>
|
||||
<input class="form-control" type="text" name="ship_length" id="ship_length-<?=$product->id?>" value="<?=$product->cpeprovisioning->ship_length?>" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-1">
|
||||
<div class="form-group text-center">
|
||||
<label class="form-label text-success" for="routerconfig_finished-<?=$product->id?>">Routerkonfig <i class="fas fa-check"></i></label>
|
||||
<input class="form-control" type="checkbox" value="1" name="routerconfig_finished" id="routerconfig_finished-<?=$product->id?>" />
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="ship_width-<?=$product->id?>">Breite</label>
|
||||
<input class="form-control" type="text" name="ship_width" id="ship_width-<?=$product->id?>" value="<?=$product->cpeprovisioning->ship_width?>" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label class="form-label"> </label>
|
||||
<button class="form-control btn btn-primary" type="submit"><i class="fas fa-save"></i> Speichern</button>
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="ship_height-<?=$product->id?>">Höhe</label>
|
||||
<input class="form-control" type="text" name="ship_height" id="ship_height-<?=$product->id?>" value="<?=$product->cpeprovisioning->ship_height?>" <?=($vot) ? "disabled='disabled' title='Vorortinstallation bestellt'" : ""?> />
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<div class="col-md-1">
|
||||
<div class="form-group text-center">
|
||||
<label class="form-label text-success" for="routerconfig_finished-<?=$product->id?>">Routerkonfig <i class="fas fa-check"></i></label>
|
||||
<input class="form-control" type="checkbox" value="1" name="routerconfig_finished" id="routerconfig_finished-<?=$product->id?>" <?=($product->cpeprovisioning->routerconfig_finished) ? "checked='checked'" : ""?> />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label class="form-label"> </label>
|
||||
<button class="form-control btn btn-primary" type="submit"><i class="fas fa-save"></i> Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
|
||||
6
application/Cpeprovisioning/Cpeprovisioning.php
Normal file
6
application/Cpeprovisioning/Cpeprovisioning.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Cpeprovisioning extends mfBaseModel {
|
||||
protected $forcestr = ["wifi_ssid", "wifi_pass"];
|
||||
|
||||
}
|
||||
@@ -40,6 +40,9 @@ class CpeprovisioningController extends mfBaseController {
|
||||
}
|
||||
|
||||
foreach($order->products as $orderproduct) {
|
||||
if($orderproduct->cpeprovisioning->routerconfig_finished == 1) {
|
||||
continue;
|
||||
}
|
||||
$product = $orderproduct->product;
|
||||
|
||||
if(is_array($product->attributes) && count($product->attributes)) {
|
||||
@@ -59,9 +62,65 @@ class CpeprovisioningController extends mfBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($cpeproducts);exit;
|
||||
|
||||
$this->layout()->set("products", $cpeproducts);
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
var_dump($r);
|
||||
if(is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$cpeprovisioning = new Cpeprovisioning($id);
|
||||
if(!$building->id) {
|
||||
$this->layout()->setFlash("Eintrag nicht gefunden", "error");
|
||||
$this->redirect("Cpeprovisioning");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$termination_id = $r->termination_id;
|
||||
if(!(is_numeric($termination_id) && $termination_id > 0) && !(is_numeric($order_id) && $order_id > 0)) {
|
||||
$this->layout()->setFlash("Anschluss oder Bestellung nicht gefunden", "error");
|
||||
$this->redirect("Cpeprovisioning");
|
||||
}
|
||||
|
||||
$prov_data = [];
|
||||
$prov_data["termination_id"] = $r->termination_id;
|
||||
$prov_data["order_id"] = $r->order_id;
|
||||
$prov_data["orderproduct_id"] = $r->orderproduct_id;
|
||||
$prov_data["routerconfig_finished"] = ($r->routerconfig_finished) ? 1 : 0;
|
||||
$prov_data["routertype"] = $r->routertype;
|
||||
$prov_data["shipping"] = ($r->shipping) ? 1 : 0;
|
||||
$prov_data["wifi_ssid"] = $r->wifi_ssid;
|
||||
$prov_data["wifi_pass"] = $r->wifi_pass;
|
||||
$prov_data["vlan_inet"] = (strlen($r->vlan_inet)) ? $r->vlan_inet : null;
|
||||
$prov_data["vlan_nat"] = (strlen($r->vlan_nat)) ? $r->vlan_nat : null;
|
||||
$prov_data["vlan_ipv6"] = (strlen($r->vlan_ipv6)) ? $r->vlan_ipv6 : null;
|
||||
$prov_data["ship_weight"] = $r->ship_weight;
|
||||
$prov_data["ship_length"] = $r->ship_length;
|
||||
$prov_data["ship_width"] = $r->ship_width;
|
||||
$prov_data["ship_height"] = $r->ship_height;
|
||||
|
||||
$prov_data["edit_by"] = $this->me->id;
|
||||
|
||||
if($mode == "add") {
|
||||
$prov_data["create_by"] = $this->me->id;
|
||||
$cpeprovisioning = CpeprovisioningModel::create($prov_data);
|
||||
} else {
|
||||
$cpeprovisioning->update($prov_data);
|
||||
}
|
||||
|
||||
//var_dump($prov_data);exit;
|
||||
$new_id = $cpeprovisioning->save();
|
||||
if(!$new_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->redirect("Cpeprovisioning");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Eintrag erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Cpeprovisioning");
|
||||
|
||||
}
|
||||
|
||||
|
||||
162
application/Cpeprovisioning/CpeprovisioningModel.php
Normal file
162
application/Cpeprovisioning/CpeprovisioningModel.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
class CpeprovisioningModel {
|
||||
public $termination_id;
|
||||
public $order_id;
|
||||
public $orderproduct_id;
|
||||
public $routerconfig_finished;
|
||||
public $routertype;
|
||||
public $shipping;
|
||||
public $wifi_ssid;
|
||||
public $wifi_pass;
|
||||
public $vlan_inet;
|
||||
public $vlan_nat;
|
||||
public $vlan_ipv6;
|
||||
public $ship_weight;
|
||||
public $ship_length;
|
||||
public $ship_width;
|
||||
public $ship_height;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new Cpeprovisioning();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
$model ->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getOne($id) {
|
||||
if(!is_numeric($id) || !$id) {
|
||||
throw new Exception("Invalid number", 400);
|
||||
}
|
||||
$item = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("Cpeprovisioning", "*", "id=$id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Cpeprovisioning($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Cpeprovisioning", "*", "$where ORDER BY order_id,orderproduct_id,termination_id");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Cpeprovisioning($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("Cpeprovisioning", "*", "1=1 ORDER BY order_id,orderproduct_id,termination_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Cpeprovisioning($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM Cpeprovisioning WHERE $where";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
|
||||
$sql = "SELECT * FROM Cpeprovisioning WHERE $where ORDER BY order_id,orderproduct_id,termination_id";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($count)) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Cpeprovisioning($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
if(array_key_exists("termination_id", $filter)) {
|
||||
$termination_id = $filter['termination_id'];
|
||||
if(is_numeric($termination_id)) {
|
||||
$where .= " AND termination_id=$termination_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("order_id", $filter)) {
|
||||
$order_id = $filter['order_id'];
|
||||
if(is_numeric($order_id)) {
|
||||
$where .= " AND order_id=$order_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("orderproduct_id", $filter)) {
|
||||
$orderproduct_id = $filter['orderproduct_id'];
|
||||
if(is_numeric($orderproduct_id)) {
|
||||
$where .= " AND orderproduct_id=$orderproduct_id";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -237,7 +237,13 @@ class OrderModel {
|
||||
if($owner) {
|
||||
$where .= " AND (Address.company like '%$owner%' OR Address.firstname like '%$owner%' OR Address.lastname like '%$owner%')";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(array_key_exists("owner", $filter)) {
|
||||
$owner = FronkDB::singleton()->escape($filter['owner']);
|
||||
if($owner) {
|
||||
$where .= " AND (Address.company like '%$owner%' OR Address.firstname like '%$owner%' OR Address.lastname like '%$owner%')";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("create_by", $filter)) {
|
||||
|
||||
@@ -4,6 +4,7 @@ class OrderProduct extends mfBaseModel {
|
||||
private $order;
|
||||
private $product;
|
||||
private $termination;
|
||||
private $cpeprovisioning;
|
||||
private $editor;
|
||||
private $creator;
|
||||
|
||||
@@ -34,6 +35,12 @@ class OrderProduct extends mfBaseModel {
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "cpeprovisioning") {
|
||||
$this->cpeprovisioning = CpeprovisioningModel::getFirst(["orderproduct_id" => $this->id]);
|
||||
return $this->cpeprovisioning;
|
||||
}
|
||||
|
||||
|
||||
if($name == "creator") {
|
||||
if($this->id) {
|
||||
$this->creator = new User($this->create_by);
|
||||
|
||||
@@ -7,6 +7,7 @@ class Termination extends mfBaseModel {
|
||||
private $status;
|
||||
private $lineworker;
|
||||
private $workflowitems;
|
||||
private $cpeprovisioning;
|
||||
private $files;
|
||||
private $patching;
|
||||
private $creator;
|
||||
@@ -163,6 +164,11 @@ class Termination extends mfBaseModel {
|
||||
return $this->patching;
|
||||
}
|
||||
|
||||
if($name == "Cpeprovisioning") {
|
||||
$this->cpeprovisioning = CpeprovisioningModel::getFirst(["termination_id" => $this->id]);
|
||||
return $this->cpeprovisioning;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
Reference in New Issue
Block a user