Started Contract Index
This commit is contained in:
@@ -60,11 +60,21 @@ class ContractModel {
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Contract", "*", "$where ORDER BY owner_id,product_id,`create` LIMIT 1");
|
||||
$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.owner_id,Contract.product_id,Contract.`create`
|
||||
LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Contract($data);
|
||||
@@ -81,11 +91,13 @@ class ContractModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) FROM Contract
|
||||
LEFT JOIN Address ON (Contract.address_id = Address.id)
|
||||
$sql = "SELECT COUNT(*) as cnt 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 owner_id,product_id,`create`";
|
||||
GROUP BY Contract.id";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
@@ -102,10 +114,13 @@ class ContractModel {
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT Contract.* FROM Contract
|
||||
LEFT JOIN Address ON (Contract.address_id = Address.id)
|
||||
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 owner_id,product_id,`create`";
|
||||
ORDER BY Contract.owner_id,Contract.product_id,Contract.`create`";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
@@ -147,6 +162,13 @@ class ContractModel {
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user