Esempio n. 1
0
 /**
  * Getting the selling item
  *
  * @param OrderItem $orderItem
  * @param string    $serialNo
  * @param string    $description
  * @param Order     $order
  * @param Product   $product
  * @param string    $activeOnly
  * @param string    $pageNo
  * @param unknown   $pageSize
  * @param unknown   $orderBy
  * @param unknown   $stats
  * @return Ambigous <Ambigous, multitype:, multitype:BaseEntityAbstract >
  */
 public static function getSellingItems(OrderItem $orderItem = null, $serialNo = '', $description = '', Order $order = null, Product $product = null, $activeOnly = true, $pageNo = null, $pageSize = DaoQuery::DEFAUTL_PAGE_SIZE, $orderBy = array(), &$stats = array())
 {
     $where = $params = array();
     if (trim($serialNo) !== '') {
         $where[] = 'serialNo like ?';
         $params[] = $serialNo;
     }
     if (trim($description) !== '') {
         $where[] = 'description like ?';
         $params[] = '%' . $description . '%';
     }
     if ($orderItem instanceof OrderItem) {
         $where[] = 'orderItemId = ?';
         $params[] = $orderItem->getId();
     }
     if ($order instanceof Order) {
         $where[] = 'orderId = ?';
         $params[] = $order->getId();
     }
     if ($product instanceof Product) {
         $where[] = 'productId = ?';
         $params[] = $product->getId();
     }
     if (count($where) === 0) {
         return SellingItem::getAll($activeOnly, $pageNo, $pageSize, $orderBy, $stats);
     }
     $results = SellingItem::getAllByCriteria(implode(' AND ', $where), $params, $activeOnly, $pageNo, $pageSize, $orderBy, $stats);
     return $results;
 }