more query fixes
This commit is contained in:
parent
40a6262da5
commit
a4fa1b40ce
@ -68,15 +68,15 @@ class Cockpit_Admin extends Crunchbutton_Admin {
|
||||
|
||||
public function deliveries() {
|
||||
if (!isset($this->_deliveries)) {
|
||||
$o = Order::q('
|
||||
$o = Order::q("
|
||||
select o.*, oa.type as status, oa.timestamp as status_time from `order` o
|
||||
left join order_action oa using (id_order)
|
||||
where
|
||||
id_admin="'.$this->id_admin.'"
|
||||
and (oa.type="delivery-pickedup" or oa.type="delivery-accepted" or oa.type="delivery-delivered" or oa.type="delivery-rejected" or oa.type="delivery-transfered")
|
||||
id_admin=?
|
||||
and (oa.type='delivery-pickedup' or oa.type='delivery-accepted' or oa.type='delivery-delivered' or oa.type='delivery-rejected' or oa.type='delivery-transfered')
|
||||
and o.date >= (curdate() - interval 50 day)
|
||||
order by oa.timestamp asc
|
||||
');
|
||||
", [$this->id_admin]);
|
||||
$orders = [];
|
||||
foreach ($o as $order) {
|
||||
if (!$orders[$order->id_order]) {
|
||||
|
||||
@ -805,12 +805,12 @@ class Crunchbutton_Order extends Crunchbutton_Order_Trackchange {
|
||||
}
|
||||
|
||||
public function accepted() {
|
||||
$nl = Notification_Log::q('select * from notification_log where id_order=? and status="accepted"', [$this->id_order]);
|
||||
$nl = Notification_Log::q("select * from notification_log where id_order=? and status='accepted'", [$this->id_order]);
|
||||
return $nl->count() ? true : false;
|
||||
}
|
||||
|
||||
public function fax_succeeds() {
|
||||
$nl = Notification_Log::q('select * from notification_log where id_order=? and type="phaxio" and status="success"', [$this->id_order]);
|
||||
$nl = Notification_Log::q("select * from notification_log where id_order=? and type='phaxio' and status='success'", [$this->id_order]);
|
||||
return $nl->count() ? true : false;
|
||||
}
|
||||
|
||||
|
||||
@ -422,25 +422,25 @@ class Crunchbutton_Promo extends Cana_Table
|
||||
$query = 'SELECT `promo`.*, user.name FROM `promo` LEFT JOIN restaurant USING(id_restaurant) LEFT OUTER JOIN user USING(id_user) WHERE id_promo IS NOT NULL ';
|
||||
|
||||
if ($search['type']) {
|
||||
$query .= ' and type="'.$search['type'].'" ';
|
||||
$query .= " and type='".$search['type']."' ";
|
||||
}
|
||||
|
||||
if ($search['start']) {
|
||||
$s = new DateTime($search['start']);
|
||||
$query .= ' and DATE(`date`)>="'.$s->format('Y-m-d').'" ';
|
||||
$query .= " and DATE(`date`)>='".$s->format('Y-m-d')."' ";
|
||||
}
|
||||
|
||||
if ($search['end']) {
|
||||
$s = new DateTime($search['end']);
|
||||
$query .= ' and DATE(`date`)<="'.$s->format('Y-m-d').'" ';
|
||||
$query .= " and DATE(`date`)<='".$s->format('Y-m-d')."' ";
|
||||
}
|
||||
|
||||
if ($search['restaurant']) {
|
||||
$query .= ' and `promo`.id_restaurant="'.$search['restaurant'].'" ';
|
||||
$query .= " and `promo`.id_restaurant=".$search['restaurant']." ";
|
||||
}
|
||||
|
||||
if ($search['id_user']) {
|
||||
$query .= ' and `promo`.id_user="'.$search['id_user'].'" ';
|
||||
$query .= " and `promo`.id_user='".$search['id_user']."' ";
|
||||
}
|
||||
|
||||
$query .= 'ORDER BY `id_promo` DESC';
|
||||
|
||||
@ -39,29 +39,29 @@ class Crunchbutton_Suggestion extends Cana_Table {
|
||||
$query = 'SELECT `suggestion`.* FROM `suggestion` LEFT JOIN restaurant USING(id_restaurant) WHERE id_suggestion IS NOT NULL ';
|
||||
|
||||
if ($search['type']) {
|
||||
$query .= ' and type="'.$search['type'].'" ';
|
||||
$query .= " and type='".$search['type']."' ";
|
||||
}
|
||||
|
||||
if ($search['status']) {
|
||||
$query .= ' and status="'.$search['status'].'" ';
|
||||
$query .= " and status='".$search['status']."' ";
|
||||
}
|
||||
|
||||
if ($search['start']) {
|
||||
$s = new DateTime($search['start']);
|
||||
$query .= ' and DATE(`date`)>="'.$s->format('Y-m-d').'" ';
|
||||
$query .= " and DATE(`date`)>='".$s->format('Y-m-d')."' ";
|
||||
}
|
||||
|
||||
if ($search['end']) {
|
||||
$s = new DateTime($search['end']);
|
||||
$query .= ' and DATE(`date`)<="'.$s->format('Y-m-d').'" ';
|
||||
$query .= " and DATE(`date`)<='".$s->format('Y-m-d')."' ";
|
||||
}
|
||||
|
||||
if ($search['restaurant']) {
|
||||
$query .= ' and `suggestion`.id_restaurant="'.$search['restaurant'].'" ';
|
||||
$query .= ' and `suggestion`.id_restaurant='.$search['restaurant'].' ';
|
||||
}
|
||||
|
||||
if ($search['community']) {
|
||||
$query .= ' and `suggestion`.id_community="'.$search['community'].'" ';
|
||||
$query .= ' and `suggestion`.id_community='.$search['community'].' ';
|
||||
}
|
||||
|
||||
if ($search['search']) {
|
||||
|
||||
@ -533,21 +533,21 @@ class Crunchbutton_Support extends Cana_Table_Trackchange {
|
||||
$query = 'SELECT `support`.* FROM `support` WHERE id_support IS NOT NULL ';
|
||||
|
||||
if ($search['type']) {
|
||||
$query .= ' and type="'.$search['type'].'" ';
|
||||
$query .= " and type='".$search['type']."' ";
|
||||
}
|
||||
|
||||
if ($search['status']) {
|
||||
$query .= ' and status="'.$search['status'].'" ';
|
||||
$query .= " and status='".$search['status']."' ";
|
||||
}
|
||||
|
||||
if ($search['start']) {
|
||||
$s = new DateTime($search['start']);
|
||||
$query .= ' and DATE(`date`)>="'.$s->format('Y-m-d').'" ';
|
||||
$query .= " and DATE(`date`)>='".$s->format('Y-m-d')."' ";
|
||||
}
|
||||
|
||||
if ($search['end']) {
|
||||
$s = new DateTime($search['end']);
|
||||
$query .= ' and DATE(`date`)<="'.$s->format('Y-m-d').'" ';
|
||||
$query .= " and DATE(`date`)<='".$s->format('Y-m-d')."' ";
|
||||
}
|
||||
|
||||
if ($search['search']) {
|
||||
|
||||
@ -26,25 +26,25 @@ class Crunchbutton_User_Auth extends Cana_Table {
|
||||
SELECT *
|
||||
FROM user_auth
|
||||
WHERE
|
||||
type="'.$type.'"
|
||||
AND auth="'.$id.'"
|
||||
type=?
|
||||
AND auth=?
|
||||
LIMIT 1
|
||||
');
|
||||
', [$type, $id]);
|
||||
return new Crunchbutton_User_Auth($row);
|
||||
}
|
||||
|
||||
public static function localLogin( $email, $password ) {
|
||||
$password = static::passwordEncrypt( $password );
|
||||
$query = '
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM user_auth
|
||||
WHERE
|
||||
type="local"
|
||||
type='local'
|
||||
AND email=:email
|
||||
AND auth=:password
|
||||
AND active=true
|
||||
LIMIT 1
|
||||
';
|
||||
";
|
||||
|
||||
$row = Cana::db()->get($query, ['email' => $email, 'password' => $password]);
|
||||
if( $row->_items && $row->_items[0] ){
|
||||
@ -207,15 +207,15 @@ class Crunchbutton_User_Auth extends Cana_Table {
|
||||
}
|
||||
|
||||
public function validateResetCode( $code ){
|
||||
$query = '
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM user_auth
|
||||
WHERE
|
||||
type="local"
|
||||
type='local'
|
||||
AND reset_code=:code
|
||||
AND active=true
|
||||
LIMIT 1
|
||||
';
|
||||
";
|
||||
$row = Cana::db()->get( $query, ['code' => $code]);
|
||||
if( $row->_items && $row->_items[0] ){
|
||||
$row = $row->_items[0];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user