protected function getSelectFilter()
 {
     if (!$this->selectFilter) {
         $this->selectFilter = select(eq('CustomerOrder.isFinalized', true), isnotnull('CustomerOrder.invoiceNumber'));
         $this->selectFilter->setOrder(f('CustomerOrder.dateCompleted'), 'DESC');
         $this->selectFilter->setLimit(1);
     }
     return $this->selectFilter;
 }
示例#2
0
 public static function getUserToolbarItems($types = null, $filter = null, $order = 'ASC')
 {
     if ($filter == null) {
         $filter = new ARSelectFilter();
     }
     $filter->mergeCondition(eq(f(__CLASS__ . '.ownerID'), SessionUser::getUser()->getID()));
     $filter->setOrder(f(__CLASS__ . '.position'), $order);
     $m = array(BackendToolbarItem::TYPE_MENU => 'menuID', BackendToolbarItem::TYPE_PRODUCT => 'productID', BackendToolbarItem::TYPE_USER => 'userID', BackendToolbarItem::TYPE_ORDER => 'orderID');
     if (is_array($types) == false) {
         $types = array($types);
     }
     $conditions = array();
     foreach ($types as $type) {
         if (array_key_exists($type, $m)) {
             $conditions[] = isnotnull(f(__CLASS__ . '.' . $m[$type]));
         }
     }
     if (count($conditions)) {
         $filter->mergeCondition(new OrChainCondition($conditions));
     }
     return self::getRecordSetArray(__CLASS__, $filter, true);
 }
示例#3
0
 public static function getUserToolbarItems($types = null, $filter = null, $order = 'ASC')
 {
     if ($filter == null) {
         $filter = new ARSelectFilter();
     }
     $filter->mergeCondition(eq(f(__CLASS__ . '.ownerID'), SessionUser::getUser()->getID()));
     $filter->setOrder(f(__CLASS__ . '.position'), $order);
     $m = array(BackendToolbarItem::TYPE_MENU => '', BackendToolbarItem::TYPE_PRODUCT => '', BackendToolbarItem::TYPE_USER => '', BackendToolbarItem::TYPE_ORDER => '');
     if (is_array($types) == false) {
         $types = array($types);
     }
     $conditions = array();
     foreach ($types as $type) {
         switch ($type) {
             case BackendToolbarItem::TYPE_MENU:
                 $conditions[] = isnotnull(f(__CLASS__ . '.menuID'));
                 break;
             case BackendToolbarItem::TYPE_PRODUCT:
                 $conditions[] = new AndChainCondition(array(isnotnull(f(__CLASS__ . '.productID')), isnotnull(f('Product.ID'))));
                 // fake inner join
                 break;
             case BackendToolbarItem::TYPE_USER:
                 $conditions[] = new AndChainCondition(array(isnotnull(f(__CLASS__ . '.userID')), isnotnull(f('User.ID'))));
                 break;
             case BackendToolbarItem::TYPE_ORDER:
                 $conditions[] = new AndChainCondition(array(isnotnull(f(__CLASS__ . '.orderID')), isnotnull(f('CustomerOrder.ID'))));
                 break;
         }
     }
     if (count($conditions)) {
         $filter->mergeCondition(new OrChainCondition($conditions));
     }
     return self::getRecordSetArray(__CLASS__, $filter, true);
 }