Пример #1
0
 /**
  * Searching PO
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  *
  */
 public function searchPO($sender, $param)
 {
     $results = $errors = array();
     try {
         $items = array();
         $searchTxt = isset($param->CallbackParameter->searchTxt) ? trim($param->CallbackParameter->searchTxt) : '';
         if ($searchTxt === '') {
             $results['items'] = '';
         } else {
             PurchaseOrder::getQuery()->eagerLoad('PurchaseOrder.supplier');
             $pos = PurchaseOrder::getAllByCriteria('(po.purchaseOrderNo like :searchTxt OR po.supplierRefNo like :searchTxt OR po_sup.name like :suplierName) AND (status = :statusReceiving OR status = :statusOrdered)', array('searchTxt' => $searchTxt . '%', 'suplierName' => '%' . $searchTxt . '%', 'statusReceiving' => PurchaseOrder::STATUS_RECEIVING, 'statusOrdered' => PurchaseOrder::STATUS_ORDERED), true, null, DaoQuery::DEFAUTL_PAGE_SIZE, array('id' => 'desc'));
             foreach ($pos as $po) {
                 if (!$po instanceof PurchaseOrder) {
                     throw new Exception('Invalid PurchaseOrder passed in!');
                 }
                 $items[] = $this->_getPOJson($po);
             }
             $results['items'] = $items;
         }
     } catch (Exception $ex) {
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }