Contract WIP
This commit is contained in:
@@ -135,7 +135,7 @@ class ContractModel {
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Contract($data);
|
||||
$items[$data->id] = new Contract($data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,17 +148,25 @@ class ContractModel {
|
||||
$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 owner_id=$owner_id";
|
||||
$where .= " AND Contract.owner_id=$owner_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("product_id", $filter)) {
|
||||
$product_id = $filter['product_id'];
|
||||
if(is_numeric($product_id)) {
|
||||
$where .= " AND product_id=$product_id";
|
||||
$where .= " AND Contract.product_id=$product_id";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,10 +180,26 @@ class ContractModel {
|
||||
if(array_key_exists("product_name", $filter)) {
|
||||
$product_name = $db->escape($filter['product_name']);
|
||||
if($product_name) {
|
||||
$where .= " AND `product_name` like '$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("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%' ))";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user