637 lines
20 KiB
PHP
637 lines
20 KiB
PHP
<?php
|
|
|
|
class ContractModel {
|
|
public $orderproduct_id;
|
|
public $owner_id;
|
|
public $billingaddress_id;
|
|
public $termination_id;
|
|
public $product_id;
|
|
public $product_name;
|
|
public $product_info;
|
|
public $matchcode;
|
|
public $amount;
|
|
public $sla_id = null;
|
|
public $product_external;
|
|
public $product_external_id;
|
|
public $price = null;
|
|
public $price_setup = null;
|
|
public $vatgroup_id = null;
|
|
public $price_nne = null;
|
|
public $price_nbe = null;
|
|
public $billing_delay = null;
|
|
public $billing_period = null;
|
|
public $order_date;
|
|
public $finish_date;
|
|
public $finish_date_by;
|
|
public $cancel_date;
|
|
public $cancel_date_by;
|
|
public $imported_from;
|
|
public $imported_data;
|
|
|
|
public $note = null;
|
|
public $create_by = null;
|
|
public $edit_by = null;
|
|
public $create = null;
|
|
public $edit = null;
|
|
|
|
|
|
public static function create(Array $data) {
|
|
$model = new Contract();
|
|
|
|
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 createFromOrderproduct(OrderProduct $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["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["vatgroup_id"] = $op->product->vatgroup_id;
|
|
$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;
|
|
|
|
$contract = ContractModel::create($data);
|
|
$contract->matchcode = $contract->generateMatchcode();
|
|
//var_dump($contract);exit;
|
|
|
|
return $contract;
|
|
}
|
|
|
|
public static function createFromContractQueue(Contractqueue $cq, $contracttype = "contract") {
|
|
$log = mfLoghandler::singleton();
|
|
$me = new User();
|
|
$me->loadMe();
|
|
|
|
if(!$cq->id) {
|
|
$log->warning(__METHOD__."(): Invalid Contractqueue object");
|
|
return false;
|
|
}
|
|
|
|
$order_id = $cq->order_id;
|
|
$product_id = $cq->product_id;
|
|
|
|
$order = new Order($order_id);
|
|
$product = new Product($product_id);
|
|
|
|
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["orderproduct_id"] = $cq->orderproduct_id;
|
|
$data["matchcode"] = $cq->matchcode;
|
|
$data["owner_id"] = $cq->owner_id;
|
|
$data["billingaddress_id"] = ($cq->billingaddress_id) ? $cq->billingaddress_id : $cq->owner_id;
|
|
$data["termination_id"] = ($cq->termination_id) ? $cq->termination_id : null;
|
|
$data["product_id"] = $cq->product_id;
|
|
$data["product_name"] = $cq->product_name;
|
|
$data["product_info"] = $cq->product_info;
|
|
$data["amount"] = $cq->amount;
|
|
$data["sla_id"] = $cq->sla_id;
|
|
$data["product_external"] = $cq->product_external;
|
|
$data["product_external_id"] = $cq->product_external_id;
|
|
$data["price"] = $cq->price;
|
|
$data["price_setup"] = $cq->price_setup;
|
|
$data["price_nne"] = $cq->price_nne;
|
|
$data["price_nbe"] = $cq->price_nbe;
|
|
$data["vatgroup_id"] = $cq->vatgroup_id;
|
|
$data["billing_delay"] = $cq->billing_delay;
|
|
$data["billing_period"] = $cq->billing_period;
|
|
$data["contract_term"] = $cq->contract_term;
|
|
$data["order_date"] = $order->order_date;
|
|
|
|
|
|
$data["finish_date"] = $order->finish_date;
|
|
$data["finish_date_by"] = $me->id;
|
|
$data["note"] = $order->note;
|
|
|
|
if($contracttype == "credit") {
|
|
$crediting_price = $cq->price_nne;
|
|
if($cq->crediting_partner_rate) {
|
|
$crediting_price = round($cq->price / 100 * $cq->crediting_partner_rate, 4);
|
|
}
|
|
$crediting_price *= -1;
|
|
|
|
$data["matchcode"] = $cq->crediting_matchcode;
|
|
$data["owner_id"] = $cq->crediting_partner_id;
|
|
$data["billingaddress_id"] = $cq->crediting_partner_id;
|
|
$data["termination_id"] = null;
|
|
$data["price"] = $crediting_price;
|
|
$data["price_setup"] = 0;
|
|
$data["price_nne"] = 0;
|
|
$data["price_nbe"] = 0;
|
|
}
|
|
|
|
$contract = ContractModel::create($data);
|
|
//var_dump($contract);exit;
|
|
|
|
return $contract;
|
|
}
|
|
|
|
public static function createCreditForContract($contract) {
|
|
$log = mfLoghandler::singleton();
|
|
$me = new User();
|
|
$me->loadMe();
|
|
|
|
if(!$contract->id) {
|
|
$log->warning(__METHOD__."(): Invalid Contractqueue object");
|
|
return false;
|
|
}
|
|
|
|
$product = $contract->product;
|
|
$owner = $contract->owner;
|
|
|
|
if(!$product->id) {
|
|
$log->warning(__METHOD__."(): Invalid Product");
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
* Get credit price from NNE or percentage of sales price
|
|
*/
|
|
$crediting_partner_id = false;
|
|
$crediting_partner_rate = false;
|
|
|
|
$product_attribs = $product->attributes;
|
|
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) {
|
|
$crediting_partner_id = $product_attribs["crediting_partner"]->value;
|
|
}
|
|
if($product_attribs["crediting_rate"]->value) {
|
|
$crediting_partner_rate = str_replace(",", ".",$product_attribs["crediting_rate"]->value);
|
|
}
|
|
}
|
|
|
|
// or from netowner if anschluss product
|
|
if(!$crediting_partner_id && $contract->termination_id) {
|
|
$crediting_partner_id = $contract->termination->building->network->owner_id;
|
|
}
|
|
|
|
$crediting_partner = new Address($crediting_partner_id);
|
|
if(!$crediting_partner->id) {
|
|
$log->error(__METHOD__.": Kein Crediting Partner gefunden für Credit für Contract ID ".$contract->id);
|
|
return false;
|
|
}
|
|
|
|
// determine price:
|
|
// either NNE or percentage based, depends on product
|
|
$crediting_price = $product->price_nne;
|
|
if($crediting_partner_rate) {
|
|
$crediting_price = round($contract->price / 100 * $crediting_partner_rate, 4);
|
|
}
|
|
|
|
if(!$crediting_price) return true;
|
|
$crediting_price *= -1;
|
|
|
|
$data = [];
|
|
$data["orderproduct_id"] = null;
|
|
$data["owner_id"] = $crediting_partner_id;
|
|
$data["billingaddress_id"] = null;
|
|
$data["termination_id"] = null;
|
|
$data["product_id"] = $contract->product_id;
|
|
$data["product_name"] = $contract->product_name;
|
|
$data["product_info"] = $contract->product_info;
|
|
$data["amount"] = $contract->amount;
|
|
$data["sla_id"] = $contract->sla_id;
|
|
$data["product_external"] = $contract->product_external;
|
|
$data["product_external_id"] = $contract->product_external_id;
|
|
$data["billing_delay"] = $contract->billing_delay;
|
|
$data["billing_period"] = $contract->billing_period;
|
|
$data["contract_term"] = $contract->contract_term;
|
|
$data["order_date"] = $contract->order_date;
|
|
|
|
$data["finish_date"] = $contract->finish_date;
|
|
$data["finish_date_by"] = $me->id;
|
|
$data["note"] = null;
|
|
|
|
|
|
// matchcode
|
|
$owner_address = $owner->street.", ".$owner->zip." ".$owner->city;
|
|
if($contract->termination_id) {
|
|
$termination = new Termination($contract->termination_id);
|
|
$termination_address = $termination->building->street.", ".$termination->building->zip." ".$termination->building->city;
|
|
$matchcode = $termination_address;
|
|
} else {
|
|
$matchcode = $owner_address;
|
|
}
|
|
|
|
$matchcode = $contract->owner->getCompanyOrName()."; $matchcode";
|
|
|
|
$data["matchcode"] = $matchcode;
|
|
$data["price"] = $crediting_price;
|
|
$data["price_setup"] = 0;
|
|
$data["price_nne"] = 0;
|
|
$data["price_nbe"] = 0;
|
|
$data["vatgroup_id"] = $contract->vatgroup_id;
|
|
|
|
|
|
$credit = ContractModel::create($data);
|
|
|
|
return $credit;
|
|
}
|
|
|
|
public static function getAll() {
|
|
$items = [];
|
|
|
|
$db = FronkDB::singleton();
|
|
|
|
$res = $db->select("Contract", "*", "1 = 1 ORDER BY owner_id,`create`");
|
|
if($db->num_rows($res)) {
|
|
while($data = $db->fetch_object($res)) {
|
|
$items[] = new Contract($data);
|
|
}
|
|
}
|
|
return $items;
|
|
|
|
}
|
|
|
|
public static function getFirst($filter) {
|
|
$db = FronkDB::singleton();
|
|
|
|
$where = self::getSqlFilter($filter);
|
|
$sql = "SELECT Contract.* FROM Contract
|
|
LEFT JOIN Address ON (Contract.owner_id = Address.id)
|
|
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
|
|
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
|
|
LEFT JOIN Product ON (Contract.product_id = Product.id)
|
|
WHERE $where
|
|
GROUP BY Contract.id
|
|
ORDER BY Contract.`create`,Contract.id
|
|
LIMIT 1";
|
|
//var_dump($sql);exit;
|
|
$res = $db->query($sql);
|
|
if($db->num_rows($res)) {
|
|
$data = $db->fetch_object($res);
|
|
$item = new Contract($data);
|
|
if($item->id) {
|
|
return $item;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static function countActive($filter) {
|
|
$db = FronkDB::singleton();
|
|
|
|
$where = self::getSqlFilter($filter);
|
|
$sql = "SELECT COUNT(*) as cnt FROM (
|
|
SELECT Contract.* FROM Contract
|
|
LEFT JOIN Address ON (Contract.owner_id = Address.id)
|
|
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
|
|
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
|
|
LEFT JOIN Product ON (Contract.product_id = Product.id)
|
|
WHERE $where
|
|
AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())
|
|
GROUP BY Contract.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 Contract.* FROM Contract
|
|
LEFT JOIN Address ON (Contract.owner_id = Address.id)
|
|
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
|
|
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
|
|
LEFT JOIN Product ON (Contract.product_id = Product.id)
|
|
WHERE $where
|
|
AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())
|
|
GROUP BY Contract.id
|
|
ORDER BY Contract.`create`,Contract.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($limit['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 Contract($data);
|
|
}
|
|
}
|
|
|
|
return $items;
|
|
}
|
|
|
|
public static function count($filter) {
|
|
$db = FronkDB::singleton();
|
|
|
|
$where = self::getSqlFilter($filter);
|
|
$sql = "SELECT COUNT(*) as cnt FROM (
|
|
SELECT Contract.* FROM Contract
|
|
LEFT JOIN Address ON (Contract.owner_id = Address.id)
|
|
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
|
|
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
|
|
LEFT JOIN Product ON (Contract.product_id = Product.id)
|
|
WHERE $where
|
|
GROUP BY Contract.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 search($filter = [], $limit = false) {
|
|
//var_dump($filter);exit;
|
|
$items = [];
|
|
$db = FronkDB::singleton();
|
|
|
|
$where = self::getSqlFilter($filter);
|
|
$sql = "SELECT Contract.* FROM Contract
|
|
LEFT JOIN Address ON (Contract.owner_id = Address.id)
|
|
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
|
|
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
|
|
LEFT JOIN Product ON (Contract.product_id = Product.id)
|
|
WHERE $where
|
|
GROUP BY Contract.id
|
|
ORDER BY Contract.`create`,Contract.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($limit['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 Contract($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 Contract.id like '%$id%'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("owner_id", $filter)) {
|
|
$owner_id = $filter['owner_id'];
|
|
if(is_numeric($owner_id)) {
|
|
$where .= " AND Contract.owner_id=$owner_id";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("billingaddress_id", $filter)) {
|
|
$billingaddress_id = $filter['billingaddress_id'];
|
|
if(is_numeric($billingaddress_id)) {
|
|
$where .= " AND Contract.billingaddress_id=$billingaddress_id";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("product_id", $filter)) {
|
|
$product_id = $filter['product_id'];
|
|
if(is_numeric($product_id)) {
|
|
$where .= " AND Contract.product_id=$product_id";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("orderproduct_id", $filter)) {
|
|
$orderproduct_id = $filter['orderproduct_id'];
|
|
if(is_numeric($orderproduct_id)) {
|
|
$where .= " AND Contract.orderproduct_id=$orderproduct_id";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("product_name", $filter)) {
|
|
$product_name = $db->escape($filter['product_name']);
|
|
if($product_name) {
|
|
$where .= " AND (Contract.`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 Contract.`matchcode` like '%$matchcode%'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("rtr_code", $filter)) {
|
|
$rtr_code = $filter['rtr_code'];
|
|
if(is_numeric($rtr_code)) {
|
|
$where .= " AND Contract.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 Contract.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 Contract.imported_data like '$imported_data'";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("price<", $filter)) {
|
|
$price = $filter['price<'];
|
|
if(is_numeric($price)) {
|
|
$where .= " AND Contract.price < $price";
|
|
}
|
|
}
|
|
if(array_key_exists("price<=", $filter)) {
|
|
$price = $filter['price<='];
|
|
if(is_numeric($price)) {
|
|
$where .= " AND Contract.price <= $price";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("price>", $filter)) {
|
|
$price = $filter['price>'];
|
|
if(is_numeric($price)) {
|
|
$where .= " AND Contract.price > $price";
|
|
}
|
|
}
|
|
if(array_key_exists("price>=", $filter)) {
|
|
$price = $filter['price>='];
|
|
if(is_numeric($price)) {
|
|
$where .= " AND Contract.price >= $price";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("billing_period", $filter)) {
|
|
$billing_period = $filter['billing_period'];
|
|
if(is_numeric($billing_period)) {
|
|
$where .= " AND Contract.billing_period=$billing_period";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("finish_date", $filter)) {
|
|
$finish_date = $filter['finish_date'];
|
|
if(is_numeric($finish_date)) {
|
|
$where .= " AND Contract.finish_date = $finish_date";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("finish_date>", $filter)) {
|
|
$finish_date = $filter['finish_date>'];
|
|
if(is_numeric($finish_date)) {
|
|
$where .= " AND Contract.finish_date >= $finish_date";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("finish_date<", $filter)) {
|
|
$finish_date = $filter['finish_date<'];
|
|
if(is_numeric($finish_date)) {
|
|
$where .= " AND Contract.finish_date <= $finish_date";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("cancel_date>", $filter)) {
|
|
$cancel_date = $filter['cancel_date>'];
|
|
if(is_numeric($cancel_date)) {
|
|
$where .= " AND Contract.cancel_date >= $cancel_date";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("cancel_date_null_or_gte", $filter)) {
|
|
$cancel_date = $filter['cancel_date_null_or_gte'];
|
|
if(is_numeric($cancel_date)) {
|
|
$where .= " AND (Contract.cancel_date IS NULL OR Contract.cancel_date >= $cancel_date)";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("cancel_date<", $filter)) {
|
|
$cancel_date = $filter['cancel_date<'];
|
|
if(is_numeric($cancel_date)) {
|
|
$where .= " AND Contract.cancel_date <= $cancel_date";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("cancel_date_null_or_lte", $filter)) {
|
|
$cancel_date = $filter['cancel_date_null_or_lte'];
|
|
if(is_numeric($cancel_date)) {
|
|
$where .= " AND (Contract.cancel_date IS NULL OR Contract.cancel_date <= $cancel_date)";
|
|
}
|
|
}
|
|
|
|
if(array_key_exists("add-where", $filter)) {
|
|
$where .= " ".$filter['add-where'];
|
|
}
|
|
|
|
|
|
//var_dump($filter, $where);exit;
|
|
return $where;
|
|
}
|
|
|
|
} |