Contract WIP
This commit is contained in:
@@ -116,6 +116,42 @@ class ContractModel {
|
||||
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.owner_id,Contract.`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 Contract($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false) {
|
||||
//var_dump($filter);exit;
|
||||
$items = [];
|
||||
|
||||
Reference in New Issue
Block a user