public function filterBySubUrbs($auth, $type = 'admin') { $data = '('; switch (true) { case $type == 'admin': $role = array(Auth_Constant_Server::SUPER_ADMIN, Auth_Constant_Server::INTERNATIONAL_STAFF, Auth_Constant_Server::INTERNATIONAL_ADMIN); if (!in_array($auth->detail->role, $role)) { $ids = "" . $auth->detail->area_ids; $subUrbs = Configuration_Model_DbTable_Suburb::getInstance()->getSuburbById($ids); if ($subUrbs) { $customerIds = Customer_Model_DbTable_Customer::getInstance()->getCustomerBySuburb($subUrbs); $courierIds = Courier_Model_DbTable_Courier::getInstance()->getCourierBySuburb($subUrbs); $data .= !empty($courierIds) ? "`pickup`.`courier_id` IN (" . implode(',', $courierIds) . ")" : ''; if (!empty($customerIds) && !empty($courierIds)) { $data .= " OR `pickup`.`customer_id` IN (" . implode(',', $customerIds) . ")"; } else { if (!empty($customerIds)) { $data .= " `pickup`.`customer_id` IN (" . implode(',', $customerIds) . ")"; } } } } break; case $type == 'courier': $preferred = Courier_Model_DbTable_Courier::getInstance()->getDetail($auth->detail->auth_id); $preferred_ids = array_unique(array_merge(explode(",", $preferred[0]['preferred_pickup_suburb_ids']), explode(",", $preferred[0]['preferred_delivery_suburb_ids']))); $subUrbs = Configuration_Model_DbTable_Suburb::getInstance()->getSuburbById(implode(",", $preferred_ids)); $customerIds = Customer_Model_DbTable_Customer::getInstance()->getCustomerBySuburb($subUrbs); $data .= !empty($customerIds) ? " `pickup`.`customer_id` IN (" . implode(',', $customerIds) . ")" : ' `pickup`.`customer_id` = 0'; break; default: break; } if ($data != '(') { $data .= ')'; $this->_wheres[] = $data; } }
public function compare() { switch (true) { case 'email' == $this->name && 'login' == $this->option: break; case 'email' == $this->name && 0 <= strpos($this->user, 'courier'): $this->preMatch('email'); $table = Courier_Model_DbTable_Courier::getInstance(); $this->checkMailFromDB($table, 'email'); break; case 'email' == $this->name && 0 <= strpos($this->user, 'customer'): if ($this->preMatch('email')) { $table = Customer_Model_DbTable_Customer::getInstance(); $this->checkMailFromDB($table, 'email'); } break; case 'app_email' == $this->name: $this->preMatch('email'); $table = Auth_Model_DbTable_Auth::getInstance(); if ($this->preMatch('email')) { $this->checkMailFromDB($table, 'app_email'); } break; case 'email' == $this->name: $this->preMatch('email'); break; case 'alternative_email' == $this->name: $this->preMatch('email'); break; case 'postcode' == $this->name: $this->preMatch('postcode'); break; case 'company_name' == $this->name: $this->preMatch('company_name'); break; case 'general_number' == $this->name: $this->preMatch('tel'); break; case 'contact_number' == $this->name: $this->preMatch('tel'); break; case 'mobile' == $this->name: $this->preMatch('tel'); break; case 'address' == $this->name: $this->preMatch('address'); break; case 'suburb' == $this->name: $this->preMatch('address'); break; case 'fax' == $this->name: $this->preMatch('tel'); break; case 'lastname' == $this->name || 'firstname' == $this->name || 'contact_lastname' == $this->name || 'contact_firstname' == $this->name: $this->preMatch('name'); break; case 'app_password' == $this->name: $this->preMatch('password'); break; case 'ccv' == $this->name: $this->preMatch('ccv'); break; case 'card_number' == $this->name: $this->preMatch('number'); break; default: break; } }