Esempio n. 1
0
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c = parent::prepareQueryBeforeCount($c);
     //$c->leftJoin('modUser', 'ModifiedBy');
     //$c->leftJoin('modUserProfile', 'ModifiedByProfile', 'ModifiedBy.id=ModifiedByProfile.internalKey');
     $c->leftJoin('modUser', 'Contractor');
     $c->leftJoin('modUserProfile', 'ContractorProfile', 'Contractor.id=ContractorProfile.internalKey');
     $c->leftJoin('modUser', 'Manager');
     $c->leftJoin('modUserProfile', 'ManagerProfile', 'Manager.id=ManagerProfile.internalKey');
     $c->select(array("ContractorProfile.fullname  as contractor_fullname", "ContractorProfile.email as contractor_email", "ContractorProfile.address as contractor_address", "if(ContractorProfile.mobilephone != '', ContractorProfile.mobilephone, ContractorProfile.phone) as contractor_phone", "ManagerProfile.fullname as manager_fullname"));
     $className = 'OrderStatus';
     $tableAlias = 'Status';
     # $c->leftJoin($className, $tableAlias);
     if ($columns = $this->modx->getSelectColumns($className, $tableAlias, 'status_')) {
         $columns = explode(',', $columns);
         $c->select($columns);
     }
     # exit;
     // Проверяем право видеть все заявки
     if (!$this->modx->hasPermission('view_all_orders')) {
         $c->andCondition(array(array('status_id:in' => array(1, 2, 8), 'manager' => null), 'OR:manager:=' => $this->modx->user->id));
     }
     if ($id = $this->getProperty('order_id')) {
         $c->where(array("`{$this->classKey}`.id" => $id));
     }
     return $c;
 }
Esempio n. 2
0
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c = parent::prepareQueryBeforeCount($c);
     if ($order_id = (int) $this->getProperty('order_id')) {
         $this->setProperty('limit', 1);
         $c->where(array("id" => $order_id));
     }
     return $c;
 }