diff --git a/Layout/default/AddressDB/Form.php b/Layout/default/AddressDB/Form.php
index 4e5776ade..17e4a108e 100644
--- a/Layout/default/AddressDB/Form.php
+++ b/Layout/default/AddressDB/Form.php
@@ -314,13 +314,17 @@
id): ?>
-
['preordercampaign_id' => $campaign->id], "resetFilter" => 1])?>">Filter zurücksetzen
+
['preordercampaign_id' => $campaign->id], "resetFilter" => 1])?>">Filter zurücksetzen
-
">Filter zurücksetzen
+
1])?>">Filter zurücksetzen
is("Preorderfront")): ?>
diff --git a/application/AddressDB/AddressDB.php b/application/AddressDB/AddressDB.php
index 355580862..89a105911 100644
--- a/application/AddressDB/AddressDB.php
+++ b/application/AddressDB/AddressDB.php
@@ -277,12 +277,27 @@ class AddressDB {
$hausnummer_data['rollout'] = (trim($data['rollout'])) ? trim($data['rollout']) : null;
$hausnummer_data['rollout_info'] = (trim($data['rollout_info'])) ? trim($data['rollout_info']) : null;
$hausnummer_data['freigabe'] = json_encode($data['freigabe']);
- $hausnummer_data['manual_add'] = date('U');
- $hausnummer_data['manual_add_by'] = $me->id;
- $hausnummer_data['manual_add_info'] = "thetool user ".$me->username." via AddressDB";
+
+ if(!$hausnummer) {
+ $hausnummer_data['manual_add'] = date('U');
+ $hausnummer_data['manual_add_by'] = $me->id;
+ $hausnummer_data['manual_add_info'] = "thetool user ".$me->username." via AddressDB";
+ }
$hausnummer_data['manual_update'] = date('U');
$hausnummer_data['manual_update_by'] = $me->id;
$hausnummer_data['manual_update_info'] = "thetool user ".$me->username." via AddressDB";
+ //var_dump($data);exit;
+ if(!$data["visibility"]) {
+ $hausnummer_data['visibility'] = "public";
+ } else {
+ switch($data['visibility']) {
+ case "private":
+ $hausnummer_data['visibility'] = "private";
+ break;
+ default:
+ $hausnummer_data['visibility'] = "public";
+ }
+ }
//var_dump($hausnummer_data, $hausnummer);exit;
diff --git a/application/AddressDB/AddressDBController.php b/application/AddressDB/AddressDBController.php
index ba5ae40f3..8a015bf8b 100644
--- a/application/AddressDB/AddressDBController.php
+++ b/application/AddressDB/AddressDBController.php
@@ -270,7 +270,7 @@ class AddressDBController extends mfBaseController {
if(!$this->me->is("Admin")) {
$required[] = "netzgebiet_id";
}
- foreach(['adrcd','extref','rimo_id','netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde','grund_nr','gdaeigenschaft','meridian','rw','hw','gps_lat','gps_long','unit_count'] as $field) {
+ foreach(['adrcd','extref','rimo_id','netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde','grund_nr','gdaeigenschaft','meridian','rw','hw','gps_lat','gps_long','unit_count','visibility'] as $field) {
if(in_array($field, $required)) {
if(!trim($r->$field)) {
$this->layout()->setFlash("'".ucfirst($field)."' darf nicht leer sein!", "error");
diff --git a/application/Contractqueue/Contractqueue.php b/application/Contractqueue/Contractqueue.php
index 3ac00faa6..a802df0f0 100644
--- a/application/Contractqueue/Contractqueue.php
+++ b/application/Contractqueue/Contractqueue.php
@@ -1,8 +1,164 @@
getProperty("owner")->street.", ".$this->getProperty("owner")->zip." ".$this->getProperty("owner")->city;
+
+ // phone
+ if($this->getProperty("product")->productgroup->mathcodeorigin == "voicenumber") {
+
+ }
+ // domain
+ if($this->getProperty("product")->productgroup->mathcodeorigin == "domain") {
+
+ }
+
+ if($this->termination_id) {
+ $termination = new Termination($this->termination_id);
+ $termination_address = $termination->building->street.", ".$termination->building->zip." ".$termination->building->city;
+ return $termination_address;
+ } else {
+
+
+
+ // everything else
+
+ return $owner_address;
+ }
+
+ return false;
+ }
+
+ public function getCredit() {
+ $crediting = [];
+
+ if(!$this->crediting_partner_id) {
+ return false;
+ }
+
+ $crediting["partner"] = $this->getProperty("crediting_partner");
+
+ if($this->crediting_partner_rate) {
+ // use rate
+ $crediting["rate_source"] = "rate";
+ $crediting["rate"] = round($this->price / 100 * $this->crediting_partner_rate, 4);
+ } else {
+ $crediting["rate_source"] = "nne";
+ }
+
+ return $crediting;
+ }
+
+ public function getProperty($name) {
+ if($this->$name == null) {
+
+ if($name == "billingaddress" && $this->billingaddress_id) {
+ $this->billingaddress = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->billingaddress_id);
+ if($this->billingaddress === null) {
+ $this->billingaddress = new Address($this->billingaddress_id);
+ if($this->billingaddress->id) {
+ mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->billingaddress_id, $this->billingaddress);
+ }
+ }
+ return $this->billingaddress;
+ }
+
+ if($name == "owner" && $this->owner_id) {
+ $this->owner = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->owner_id);
+ if($this->owner === null) {
+ $this->owner = new Address($this->owner_id);
+ if($this->owner->id) {
+ mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->owner_id, $this->owner);
+ }
+ }
+ return $this->owner;
+ }
+
+ if($name == "crediting_partner" && $this->crediting_partner_id) {
+ $this->crediting_partner = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->crediting_partner_id);
+ if($this->crediting_partner === null) {
+ $this->crediting_partner = new Address($this->crediting_partner_id);
+ if($this->crediting_partner->id) {
+ mfValuecache::singleton()->set("mfObjectmodel-Address-".$this->crediting_partner_id, $this->crediting_partner);
+ }
+ }
+ return $this->crediting_partner;
+ }
+
+ if($name == "product") {
+ $this->product = mfValuecache::singleton()->get("mfObjectmodel-Product-".$this->product_id);
+ if($this->product === null) {
+ $this->product = new Product($this->product_id);
+ if($this->product->id) {
+ mfValuecache::singleton()->set("mfObjectmodel-Product-".$this->product_id, $this->product);
+ }
+ }
+ return $this->product;
+ }
+
+ if($name == "orderproduct") {
+ $this->orderproduct = mfValuecache::singleton()->get("mfObjectmodel-OrderProduct-".$this->orderproduct_id);
+ if($this->orderproduct === null) {
+ $this->orderproduct = new OrderProduct($this->orderproduct_id);
+ if($this->orderproduct->id) {
+ mfValuecache::singleton()->set("mfObjectmodel-OrderProduct-".$this->orderproduct_id, $this->orderproduct);
+ }
+ }
+ return $this->orderproduct;
+ }
+
+
+ if($name == "creator" && $this->id) {
+ $this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
+ if($this->creator === null) {
+ $this->creator = new User($this->create_by);
+ if($this->creator->id) {
+ mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
+ }
+ }
+ return $this->creator;
+ }
+
+ if($name == "editor" && $this->id) {
+ $this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
+ if($this->editor === null) {
+ $this->editor = new User($this->edit_by);
+ if($this->editor->id) {
+ mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
+ }
+ }
+ return $this->editor;
+ }
+
+ $classname = ucfirst($name);
+ $idfield = $name."_id";
+ $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
+ if(!$this->$name) {
+ $this->$name = new $classname($this->$idfield);
+ }
+
+ if($this->$name->id) {
+ mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
+ return $this->$name;
+ } else {
+ return null;
+ }
+
+ }
+
+ return $this->$name;
+ }
+}
\ No newline at end of file
diff --git a/application/Contractqueue/ContractqueueController.php b/application/Contractqueue/ContractqueueController.php
new file mode 100644
index 000000000..d087c805a
--- /dev/null
+++ b/application/Contractqueue/ContractqueueController.php
@@ -0,0 +1,171 @@
+needlogin=true;
+ $me = new User();
+ $me->loadMe();
+ $this->me = $me;
+ $this->layout()->set("me",$me);
+
+ if(!$me->is(["Admin"])) {
+ $this->redirect("Dashboard");
+ }
+ }
+
+ protected function indexAction() {
+ if($this->request->resetFilter) {
+ unset($_SESSION[MFAPPNAME.'-Contractqueue-filter']);
+ }
+
+ $filter = [];
+ if(is_array($this->request->filter)) {
+ $filter = $this->request->filter;
+ $_SESSION[MFAPPNAME.'-Contractqueue-filter'] = $filter;
+ } else {
+ if(array_key_exists(MFAPPNAME.'-Contractqueue-filter', $_SESSION) && count($_SESSION[MFAPPNAME.'-Contractqueue-filter'])) {
+ $filter = $_SESSION[MFAPPNAME.'-Contractqueue-filter'];
+ }
+ }
+
+ $this->layout->set("filter", $filter);
+ $filter = $this->getPreparedFilter($filter);
+
+ // pagination defaults
+ $pagination = [];
+ $pagination['start'] = 0;
+ $pagination['count'] = 50;
+ $pagination['maxItems'] = 0;
+
+ if(is_numeric($this->request->s)) {
+ $pagination['start'] = intval($this->request->s);
+ }
+
+ $filter["contract_id"] = null;
+ $pagination['maxItems'] = ContractqueueModel::count($filter);
+
+ $last_order_id = false;
+ $orders = [];
+ foreach(ContractqueueModel::search($filter, $pagination) as $contractq) {
+ $last_order_id = $contractq->order_id;
+ $orders[$contractq->order_id][] = $contractq;
+ }
+
+ if($last_order_id) {
+ $filter["order_id"] = $last_order_id;
+ $orders[$contractq->order_id] = [];
+ foreach(ContractqueueModel::search($filter, $pagination) as $contractq) {
+ $orders[$contractq->order_id][] = $contractq;
+ }
+ }
+
+ $this->layout()->set("orders", $orders);
+ $this->layout()->set("pagination", $pagination);
+
+
+ }
+
+ protected function getPreparedFilter($filter) {
+
+ return $filter;
+ }
+
+ protected function importFinishedOrdersAction() {
+ $o = 0;
+ $max_orders = 1500;
+ foreach(OrderModel::search(["finish_date<" => date("U")]) as $order) {
+ if(!is_array($order->products) || !count($order->products)) {
+ //echo "keine Produkte in Order ".$order->id."\n";
+ continue;
+ }
+
+ if(ContractqueueModel::getFirst(["order_id" => $order->id])) {
+ continue;
+ }
+
+ $contracts = [];
+ $primary_matchcode = false;
+
+
+ foreach($order->products as $op) {
+ $contract = ContractModel::getFirst(["orderproduct_id" => $op->id]);
+ if(!$contract) {
+ $contract = ContractqueueModel::getFirst(["orderproduct_id" => $op->id]);
+ }
+ if($contract && $contract->matchcode) {
+ $primary_matchcode = $contract->matchcode;
+ continue;
+ }
+
+ // if contract does not exist yet, create Contractqueue
+ $contract = ContractqueueModel::createFromOrderproduct($op);
+
+ // find reseller / receiver of credit
+ // from product
+ $product_attribs = $contract->product->attributes;
+ /*if($op->id == "8666") {
+ var_dump($product_attribs);exit;
+ }*/
+ if(is_array($product_attribs) && array_key_exists("crediting_partner", $product_attribs) && $product_attribs["crediting_partner"] && is_object($product_attribs["crediting_partner"])) {
+
+ if($product_attribs["crediting_partner"]->value) {
+ $contract->crediting_partner_id = $product_attribs["crediting_partner"]->value;
+ }
+ if($product_attribs["crediting_rate"]->value) {
+ $contract->crediting_partner_rate = str_replace(",", ".",$product_attribs["crediting_rate"]->value);
+ }
+ }
+ // or from netowner if anschluss product
+ if(!$contract->crediting_partner_id && $contract->termination_id) {
+ $contract->crediting_partner_id = $contract->termination->building->network->owner_id;
+ }
+
+ if($contract->matchcode) {
+ $primary_matchcode = $contract->matchcode;
+ }
+ $contracts[] = $contract;
+ }
+
+
+ if(!$primary_matchcode) {
+ $primary_matchcode = $order->owner->street.", ".$order->owner->zip." ".$order->owner->city;
+ }
+
+ $links = [];
+ // set matchcode and save
+ foreach($contracts as $contract) {
+ if(!$contract->matchcode) {
+ $contract->matchcode = $primary_matchcode;
+
+ }
+ //var_dump($contract);exit;
+ $contract->save();
+
+ /*if(!count($links)) {
+ $links[$contract->id] = $contract;
+ } elseif(!array_key_exists($contract->id, $links)) {
+ $first_link = reset($links);
+
+ $new_link = ContractLinkModel::create([
+ "contract_id" => $first_link->id,
+ "origin_contract_id" => $contract->id,
+ "type" => "link"
+ ]);
+ $new_link->save();
+ $links[$contract->id] = $contract;
+ }*/
+
+ }
+
+ $o++;
+
+ if($o >= $max_orders) {
+ $this->layout()->setFlash("$o Bestellungen importiert, es gibt noch mehr Bestellungen zum importieren.", "info");
+ $this->redirect("Contractqueue");
+ }
+ }
+ $this->layout()->setFlash("Alle Bestellungen importiert", "success");
+ $this->redirect("Contractqueue");
+ }
+}
\ No newline at end of file
diff --git a/application/Contractqueue/ContractqueueModel.php b/application/Contractqueue/ContractqueueModel.php
new file mode 100644
index 000000000..d17e4cf9a
--- /dev/null
+++ b/application/Contractqueue/ContractqueueModel.php
@@ -0,0 +1,374 @@
+ $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 createFromOrderproduct($op) {
+ $log = mfLoghandler::singleton();
+
+ if(!$op->id) {
+ $log->warning(__METHOD__."(): Invalid OrderProduct object");
+ return false;
+ }
+
+ $order = $op->order;
+ $product = $op->product;
+
+ if(!$order->id || !$product->id) {
+ $log->warning(__METHOD__."(): Invalid Order or Product");
+ return false;
+ }
+
+ if(!$order->finish_date || $order->finish_date > date("U")) {
+ $log->warning(__METHOD__."(): Order not finished yet");
+ return false;
+ }
+
+ $data = [];
+ $data["order_id"] = $order->id;
+ $data["orderproduct_id"] = $op->id;
+ $data["owner_id"] = $order->owner_id;
+ $data["billingaddress_id"] = $order->billingaddress_id;
+ $data["termination_id"] = ($op->termination_id) ? $op->termination_id : null;
+ $data["product_id"] = $op->product_id;
+ $data["product_name"] = $product->name;
+ $data["product_info"] = $product->description;
+ $data["amount"] = $op->amount;
+ $data["sla_id"] = $product->sla_id;
+ $data["product_external"] = ($product->external) ? $product->external : 0;
+ $data["product_external_id"] = ($product->external) ? $product->external_id : null;
+ $data["price"] = $op->price;
+ $data["price_setup"] = $op->price_setup;
+ $data["price_nne"] = $op->price_nne;
+ $data["price_nbe"] = $op->price_nbe;
+ $data["billing_delay"] = $op->billing_delay;
+ $data["billing_period"] = $op->billing_period;
+ $data["order_date"] = $order->order_date;
+
+ $data["finish_date"] = $order->finish_date;
+ $data["finish_date_by"] = 1;
+ $data["note"] = $order->note;
+
+ $contractq = ContractqueueModel::create($data);
+ $contractq->matchcode = $contractq->generateMatchcode();
+ //var_dump($contract);exit;
+
+ return $contractq;
+ }
+
+ public static function getAll() {
+ $items = [];
+
+ $db = FronkDB::singleton();
+
+ $res = $db->select("Contractqueue", "*", "1 = 1 ORDER BY owner_id,`create`");
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[] = new Contractqueue($data);
+ }
+ }
+ return $items;
+
+ }
+
+ public static function getFirst($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT Contractqueue.* FROM Contractqueue
+ LEFT JOIN Address ON (Contractqueue.owner_id = Address.id)
+ LEFT JOIN OrderProduct ON (Contractqueue.orderproduct_id = OrderProduct.id)
+ LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
+ LEFT JOIN Product ON (Contractqueue.product_id = Product.id)
+ WHERE $where
+ GROUP BY Contractqueue.id
+ ORDER BY Contractqueue.owner_id,Contractqueue.product_id,Contractqueue.`create`
+ LIMIT 1";
+ //var_dump($sql);exit;
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new Contractqueue($data);
+ if($item->id) {
+ return $item;
+ } else {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static function count($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT COUNT(*) as cnt FROM (
+ SELECT Contractqueue.* FROM Contractqueue
+ LEFT JOIN Address ON (Contractqueue.owner_id = Address.id)
+ LEFT JOIN OrderProduct ON (Contractqueue.orderproduct_id = OrderProduct.id)
+ LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
+ LEFT JOIN Product ON (Contractqueue.product_id = Product.id)
+ WHERE $where
+ AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())
+ GROUP BY Contractqueue.id
+ ) contract";
+
+ mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ return $data->cnt;
+ }
+ return 0;
+ }
+
+ public static function searchActive($filter, $limit = false) {
+ //var_dump($filter);exit;
+ $items = [];
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT Contractqueue.* FROM Contractqueue
+ LEFT JOIN Address ON (Contractqueue.owner_id = Address.id)
+ LEFT JOIN OrderProduct ON (Contractqueue.orderproduct_id = OrderProduct.id)
+ LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
+ LEFT JOIN Product ON (Contractqueue.product_id = Product.id)
+ WHERE $where
+ AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())
+ GROUP BY Contractqueue.id
+ ORDER BY Contractqueue.owner_id,Contractqueue.`create`";
+
+ 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'];
+ }
+ }
+
+ mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[$data->id] = new Contractqueue($data);
+ }
+ }
+
+ return $items;
+ }
+
+ public static function search($filter, $limit = false) {
+ //var_dump($filter);exit;
+ $items = [];
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT Contractqueue.* FROM Contractqueue
+ LEFT JOIN Address ON (Contractqueue.owner_id = Address.id)
+ LEFT JOIN OrderProduct ON (Contractqueue.orderproduct_id = OrderProduct.id)
+ LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
+ LEFT JOIN Product ON (Contractqueue.product_id = Product.id)
+ WHERE $where
+ GROUP BY Contractqueue.id
+ ORDER BY Contractqueue.owner_id,Contractqueue.`create`";
+
+ 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'];
+ }
+ }
+
+ mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[$data->id] = new Contractqueue($data);
+ }
+ }
+
+ return $items;
+ }
+
+ private static function getSqlFilter($filter) {
+ $where = "1=1 ";
+
+ $db = FronkDB::singleton();
+
+ //var_dump($filter);exit;
+
+ if(array_key_exists("id", $filter)) {
+ $id = $filter['id'];
+ if(is_numeric($id)) {
+ $where .= " AND Contractqueue.id like '%$id%'";
+ }
+ }
+
+ if(array_key_exists("contract_id", $filter)) {
+ $contract_id = $filter['contract_id'];
+ if(is_numeric($contract_id)) {
+ $where .= " AND Contractqueue.contract_id=$contract_id";
+ } elseif($contract_id === null || $contract_id === false) {
+ $where .= " AND (Contractqueue.contract_id IS NULL OR Contractqueue.contract_id = 0)";
+ } elseif($contract_id === true) {
+ $where .= " AND (Contractqueue.contract_id IS NOT NULL AND Contractqueue.contract_id > 0)";
+ }
+ }
+
+ if(array_key_exists("owner_id", $filter)) {
+ $owner_id = $filter['owner_id'];
+ if(is_numeric($owner_id)) {
+ $where .= " AND Contractqueue.owner_id=$owner_id";
+ }
+ }
+
+ if(array_key_exists("billingaddress_id", $filter)) {
+ $billingaddress_id = $filter['billingaddress_id'];
+ if(is_numeric($billingaddress_id)) {
+ $where .= " AND Contractqueue.billingaddress_id=$billingaddress_id";
+ }
+ }
+
+ if(array_key_exists("product_id", $filter)) {
+ $product_id = $filter['product_id'];
+ if(is_numeric($product_id)) {
+ $where .= " AND Contractqueue.product_id=$product_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 Contractqueue.orderproduct_id=$orderproduct_id";
+ }
+ }
+
+ if(array_key_exists("product_name", $filter)) {
+ $product_name = $db->escape($filter['product_name']);
+ if($product_name) {
+ $where .= " AND (Contractqueue.`product_name` like '%$product_name%' OR Product.name like '%$product_name%')";
+ }
+ }
+
+
+ if(array_key_exists("matchcode", $filter)) {
+ $matchcode = $db->escape($filter['matchcode']);
+ if($matchcode) {
+ $where .= " AND Contractqueue.`matchcode` like '%$matchcode%'";
+ }
+ }
+
+ if(array_key_exists("rtr_code", $filter)) {
+ $rtr_code = $filter['rtr_code'];
+ if(is_numeric($rtr_code)) {
+ $where .= " AND Contractqueue.rtr_code=$rtr_code";
+ }
+ }
+
+ if(array_key_exists("customer_number", $filter)) {
+ $customer_number = $filter['customer_number'];
+ if(is_numeric($customer_number)) {
+ $where .= " AND Address.customer_number=$customer_number";
+ }
+ }
+
+ if(array_key_exists("owner", $filter)) {
+ $owner = FronkDB::singleton()->escape($filter["owner"]);
+ if($owner) {
+ $where .= " AND (Address.company like '%$owner%' OR (CONCAT(Address.firstname, ' ', Address.lastname) like '%$owner%' OR CONCAT(Address.lastname, ' ', Address.firstname) like '%$owner%' ))";
+ }
+ }
+
+ if(array_key_exists("imported_from", $filter)) {
+ $imported_from = FronkDB::singleton()->escape($filter["imported_from"]);
+ if($imported_from) {
+ $where .= " AND Contractqueue.imported_from like '$imported_from'";
+ }
+ }
+
+ if(array_key_exists("imported_data", $filter)) {
+ $imported_data = FronkDB::singleton()->escape($filter["imported_data"]);
+ if($imported_data) {
+ $where .= " AND Contractqueue.imported_data like '$imported_data'";
+ }
+ }
+
+ if(array_key_exists("add-where", $filter)) {
+ $where .= " ".$filter['add-where'];
+ }
+
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+
+}
diff --git a/composer.json b/composer.json
index 3c82036fe..e80227924 100644
--- a/composer.json
+++ b/composer.json
@@ -1,9 +1,9 @@
{
- "require": {
- "phpoffice/phpspreadsheet": "^1.23",
- "robmorgan/phinx": "^0.13.4",
- "textalk/websocket": "^1.6",
- "chillerlan/php-qrcode": "dev-main",
- "phpseclib/phpseclib": "^3.0"
- }
+ "require": {
+ "phpoffice/phpspreadsheet": "^1.23",
+ "robmorgan/phinx": "^0.13.4",
+ "textalk/websocket": "^1.6",
+ "chillerlan/php-qrcode": "^4",
+ "phpseclib/phpseclib": "^3.0"
+ }
}