Merge branch 'fronkdev' into 'master'
New Dobl-Zwaring Order Import See merge request fronk/thetool!359
This commit is contained in:
@@ -78,7 +78,12 @@ class Address extends mfBaseModel {
|
||||
$name_search = [];
|
||||
if($this->company) $name_search[] = $this->company;
|
||||
if($this->lastname) $name_search[] = $this->lastname;
|
||||
|
||||
|
||||
$country = new Country($this->country_id);
|
||||
if(!$country) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$fibumerge = XinonFibuMergeModel::getFirst(["old_custnum" => $old_custnum, "name" => $name_search]);
|
||||
if(!$fibumerge) {
|
||||
// create fibu merge
|
||||
@@ -91,6 +96,7 @@ class Address extends mfBaseModel {
|
||||
"strasse" => $this->street,
|
||||
"plz" => $this->zip,
|
||||
"ort" => $this->city,
|
||||
"land" => $country->isocode,
|
||||
"create_by" => 1,
|
||||
"edit_by" => 1
|
||||
]);
|
||||
|
||||
@@ -52,6 +52,11 @@ class AddressModel {
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if($model->phone == null) $model->phone = "";
|
||||
if($model->fax == null) $model->fax = "";
|
||||
if($model->mobile == null) $model->mobile = "";
|
||||
if($model->email == null) $model->email = "";
|
||||
|
||||
if (!is_numeric($model->create_by) && !$model->create_by) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ class AdminController extends mfBaseController {
|
||||
$products = [];
|
||||
|
||||
foreach($ivtproducts as $product) {
|
||||
$active_count = IvtCustomerProductModel::count(['pid' => $product->id]);
|
||||
$active_count = IvtCustomerTelephoneNrModel::count(['pid' => $product->id]);
|
||||
if(!$active_count) continue;
|
||||
|
||||
$new_product = [];
|
||||
@@ -136,7 +136,7 @@ class AdminController extends mfBaseController {
|
||||
$new_product["customer"] = false;
|
||||
|
||||
if($active_count == 1) {
|
||||
$cp = IvtCustomerProductModel::getFirst(["pid" => $product->id]);
|
||||
$cp = IvtCustomerTelephoneNrModel::getFirst(["pid" => $product->id]);
|
||||
//var_dump($cp);exit;
|
||||
$customer = $cp->customer;
|
||||
//var_dump($customer);exit;
|
||||
@@ -151,7 +151,7 @@ class AdminController extends mfBaseController {
|
||||
}
|
||||
|
||||
protected function ivtContractImportAction() {
|
||||
exit;
|
||||
//exit;
|
||||
$doit = false;
|
||||
if($this->request->doit == 1) {
|
||||
$doit = true;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -144,11 +144,19 @@ class Contract extends mfBaseModel {
|
||||
$termination_address = $termination->building->street.", ".$termination->building->zip." ".$termination->building->city;
|
||||
return $termination_address;
|
||||
}
|
||||
|
||||
if(stripos($this->getProperty("product")->name, "dsl") != false) {
|
||||
return $owner_address;
|
||||
}
|
||||
|
||||
|
||||
$product = $this->getProperty("product");
|
||||
/*
|
||||
* exceptions for certain products
|
||||
*/
|
||||
foreach(["dsl", "standortgeber", "funkinternet", "glasfaser", "brettljausn"] as $qname) {
|
||||
$qname = strtolower($qname);
|
||||
$product_name = strtolower($product->name);
|
||||
if(stripos($product_name, $qname) !== false) {
|
||||
return $owner_address;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -231,8 +239,34 @@ class Contract extends mfBaseModel {
|
||||
}
|
||||
return $this->orderproduct;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*if($name == "contractConfigGroups") {
|
||||
$product = $this->getProperty("product");
|
||||
$this->contractConfigGroups = ContractconfigGroupModel::search(['producttech_id' => $product->producttech_id]);
|
||||
return $this->contractConfigGroups;
|
||||
}*/
|
||||
|
||||
if($name == "configgroups") {
|
||||
$product = $this->getProperty("product");
|
||||
$this->configgroups = [];
|
||||
foreach(ContractconfiggroupProductgroupModel::search(['productgroup_id' => $product->productgroup_id]) as $ccpg) {
|
||||
$ccpg->contractconfiggroup->setContractId($this->id);
|
||||
$this->configgroups[] = $ccpg->contractconfiggroup;
|
||||
}
|
||||
|
||||
return $this->configgroups;
|
||||
}
|
||||
|
||||
if($name == "configvalues") {
|
||||
foreach($this->getProperty("configgroups") as $group) {
|
||||
foreach($group->items as $item) {
|
||||
$this->configvalues[$item->name] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->configvalues;
|
||||
}
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
@@ -240,32 +274,11 @@ class Contract extends mfBaseModel {
|
||||
|
||||
|
||||
|
||||
/*if($name == "contractConfigGroups") {
|
||||
$product = $this->getProperty("product");
|
||||
$this->contractConfigGroups = ContractconfigGroupModel::search(['producttech_id' => $product->producttech_id]);
|
||||
return $this->contractConfigGroups;
|
||||
}*/
|
||||
|
||||
|
||||
if($name == "configgroups") {
|
||||
$product = $this->getProperty("product");
|
||||
$this->configgroups = [];
|
||||
foreach(ContractconfiggroupProductgroupModel::search(['productgroup_id' => $product->productgroup_id]) as $ccpg) {
|
||||
$ccpg->contractconfiggroup->setContractId($this->id);
|
||||
$this->configgroups[] = $ccpg->contractconfiggroup;
|
||||
}
|
||||
|
||||
return $this->configgroups;
|
||||
}
|
||||
|
||||
|
||||
if($name == "configvalues") {
|
||||
foreach($this->getProperty("configgroups") as $group) {
|
||||
foreach($group->items as $item) {
|
||||
$this->configvalues[$item->name] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->configvalues;
|
||||
}
|
||||
|
||||
|
||||
/*if($name == "contractConfigItems") {
|
||||
$product = $this->getProperty("product");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
class ContractconfigItem extends mfBaseModel {
|
||||
private $value;
|
||||
private $contract_id;
|
||||
public $contract_id;
|
||||
|
||||
public function setContractId($contract_id) {
|
||||
if(!is_numeric($contract_id)) {
|
||||
|
||||
@@ -3,15 +3,19 @@
|
||||
class IvtCustomerProductModel {
|
||||
|
||||
|
||||
public static function getAll() {
|
||||
public static function getAll($order = false) {
|
||||
$items = [];
|
||||
|
||||
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$res = $db->select("customer_product", "*", "1=1 ORDER BY id");
|
||||
|
||||
if(!$order) {
|
||||
$order = "id";
|
||||
}
|
||||
|
||||
$res = $db->select("customer_product", "*", "1=1 ORDER BY $order");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new IvtCustomerProduct($data);
|
||||
$items[] = new IvtCustomerTelephoneNr($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
@@ -24,7 +28,7 @@ class IvtCustomerProductModel {
|
||||
$res = $db->select("customer_product", "*", "$where ORDER BY id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new IvtCustomerProduct($data);
|
||||
$item = new IvtCustomerTelephoneNr($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
@@ -67,7 +71,7 @@ class IvtCustomerProductModel {
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new IvtCustomerProduct($data);
|
||||
$items[] = new IvtCustomerTelephoneNr($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
@@ -113,6 +117,13 @@ class IvtCustomerProductModel {
|
||||
$where .= " AND sid=$sid";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("last_date>", $filter)) {
|
||||
$last_date = $filter['last_date>'];
|
||||
if(is_numeric($last_date)) {
|
||||
$where .= " AND last_date >=$last_date";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
class IvtCustomerTelephoneNr extends mfBaseModel {
|
||||
protected $forcestr = [];
|
||||
private $customer;
|
||||
|
||||
/**
|
||||
* Takes ID or DB row as arguments
|
||||
* @param id or table row $_
|
||||
*/
|
||||
public function __construct($_ = NULL) {
|
||||
$this->log = mfLoghandler::singleton();
|
||||
$this->data = new stdClass();
|
||||
$this->table = "products";
|
||||
|
||||
$this->db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
if(is_numeric($_)) {
|
||||
$this->fetch($_);
|
||||
} elseif(is_object($_)) {
|
||||
$this->load($_);
|
||||
}
|
||||
}
|
||||
|
||||
public function save() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "customer") {
|
||||
$ivtcustomer = new IvtCustomer($this->cid);
|
||||
if($ivtcustomer->id) {
|
||||
$this->ivtcustomer = $ivtcustomer;
|
||||
}
|
||||
return $this->ivtcustomer;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
public function __debugInfo() {
|
||||
$vars = get_object_vars($this);
|
||||
if(is_object($vars['db'])) $vars['db'] = "object(FronkDB)";
|
||||
if(is_object($vars['log'])) $vars['log'] = 'object(mfLoghandler)';
|
||||
return $vars;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
class IvtCustomerTelephoneNrModel {
|
||||
|
||||
|
||||
public static function getAll($order = false) {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
if(!$order) {
|
||||
$order = "id";
|
||||
}
|
||||
|
||||
$res = $db->select("customer_telephone_nr", "*", "1=1 ORDER BY $order");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new IvtCustomerTelephoneNr($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function getFirst($filter = []) {
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("customer_telephone_nr", "*", "$where ORDER BY id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new IvtCustomerTelephoneNr($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) cnt FROM customer_telephone_nr WHERE $where ORDER by id";
|
||||
|
||||
$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(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM customer_telephone_nr WHERE $where ORDER by cid,pid,sid,id";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new IvtCustomerTelephoneNr($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
if(array_key_exists("cid", $filter)) {
|
||||
$cid = $filter['cid'];
|
||||
if(is_numeric($cid)) {
|
||||
$where .= " AND cid=$cid";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("pid", $filter)) {
|
||||
$pid = $filter['pid'];
|
||||
if(is_numeric($pid)) {
|
||||
$where .= " AND pid=$pid";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("number", $filter)) {
|
||||
$number = (string)FronkDB::singleton()->escape($filter['number']);
|
||||
if($number) {
|
||||
$where .= " AND number='$number'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("number%", $filter)) {
|
||||
$number = (string)FronkDB::singleton()->escape($filter['number']);
|
||||
if($number) {
|
||||
$where .= " AND number LIKE '%$number%'";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -288,7 +288,7 @@ class Order extends mfBaseModel {
|
||||
$to = $values['to'];
|
||||
|
||||
if(!$subject || !$from || !$from_name || !$to) {
|
||||
$this->log->warn("Order Fileupload Email not sent. (subject: '$subject', from: '$from', from_email: '$from_email', to: '$to')");
|
||||
$this->log->warn("Order Fileupload Email not sent. (subject: '$subject', from: '$from_name', from_email: '$from', to: '$to')");
|
||||
} else {
|
||||
$filepath = MFUPLOAD_FILE_SAVE_PATH;
|
||||
if($file->file->subfolder) {
|
||||
|
||||
@@ -1236,7 +1236,6 @@ class OrderController extends mfBaseController {
|
||||
$order->deletePositions();
|
||||
|
||||
|
||||
// TODO: check if Product is unused
|
||||
$order->delete();
|
||||
$this->layout()->setFlash("Bestellung gelöscht", "success");
|
||||
$this->redirect("Order");
|
||||
|
||||
@@ -34,7 +34,23 @@ class Voicenumberblock extends mfBaseModel {
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
|
||||
public function getVoicenumber($number) {
|
||||
if(!$this->isNumberInBlock($number)) return false;
|
||||
|
||||
$vn = VoicenumberModel::getFirst(["number" => $number]);
|
||||
if(!$vn) {
|
||||
$vn = VoicenumberModel::create([
|
||||
"voicenumberblock_id" => $this->id,
|
||||
"active" => 1,
|
||||
"activated_date" => date("U"),
|
||||
"number" => $number
|
||||
]);
|
||||
}
|
||||
|
||||
return $vn;
|
||||
}
|
||||
|
||||
public function getFreeNumbers() {
|
||||
if(!$this->id) return false;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ class XinonFibuMergeModel {
|
||||
public $strasse;
|
||||
public $plz;
|
||||
public $ort;
|
||||
public $land;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
@@ -41,11 +42,14 @@ class XinonFibuMergeModel {
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getFirst($filter = []) {
|
||||
public static function getFirst($filter = [], $order = false) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
if(!$order) {
|
||||
$order = "old_custnum";
|
||||
}
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("XinonFibuMerge", "*", "$where ORDER BY old_custnum LIMIT 1");
|
||||
$res = $db->select("XinonFibuMerge", "*", "$where ORDER BY $order LIMIT 1");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new XinonFibuMerge($data);
|
||||
@@ -58,12 +62,16 @@ class XinonFibuMergeModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
public static function getAll($order = false) {
|
||||
$items = [];
|
||||
|
||||
if(!$order) {
|
||||
$order = "old_custnum";
|
||||
}
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("XinonFibuMerge", "*", "1=1 ORDER BY old_custnum");
|
||||
$res = $db->select("XinonFibuMerge", "*", "1=1 ORDER BY $order");
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new XinonFibuMerge($data);
|
||||
@@ -88,20 +96,25 @@ class XinonFibuMergeModel {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter = [], $limit = false) {
|
||||
public static function search($filter = [], $limit = false, $order = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
if(!$order) {
|
||||
$order = "old_custnum";
|
||||
}
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM XinonFibuMerge
|
||||
WHERE $where
|
||||
ORDER BY old_custnum";
|
||||
ORDER BY $order";
|
||||
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
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)) {
|
||||
} elseif (is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT " . $limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user