Exemplo n.º 1
0
 /**
  * 查询出入库记录
  *
  * @param string $sdate	开始日期
  * @param string $edate	结束日期
  * @param string $goodsName	品名
  * @param string $code		条码
  * @param string $billNo	单据号
  * @param string $inoutType	出/入库
  * @param string $place		仓库
  * @param string $billType	单据类型
  * @return array
  */
 public function query($sdate = '', $edate = '', $goodsName = '', $code = '*', $billNo = '', $inoutType = '', $place = '', $billType = '', $client = '')
 {
     try {
         $dao = new StocksDao();
         $querycondition = '';
         //如果开始日期和结束日期都有则用between,否则用=
         if ($sdate != '' && $edate != '') {
             if ($querycondition != '') {
                 $querycondition .= " and ";
             }
             $querycondition .= " ( `billDate` between date('{$sdate}') and date('{$edate}') ) ";
         } else {
             if ($sdate != '') {
                 if ($querycondition != '') {
                     $querycondition .= " and ";
                 }
                 $querycondition .= " ( `billDate` = date('{$sdate}') ) ";
             } else {
                 if ($edate != '') {
                     if ($querycondition != '') {
                         $querycondition .= " and ";
                     }
                     $querycondition .= " ( `billDate` = date('{$edate}') ) ";
                 }
             }
         }
         //品名
         if ($goodsName != '') {
             if ($querycondition != '') {
                 $querycondition .= " and ";
             }
             $querycondition .= " ( `goodsName` = '{$goodsName}' ) ";
         }
         //条码
         if ($code != '*') {
             if ($querycondition != '') {
                 $querycondition .= " and ";
             }
             $querycondition .= " ( '{$code}' = `code` ) ";
         }
         //单据号
         if ($billNo != '') {
             if ($querycondition != '') {
                 $querycondition .= " and ";
             }
             $querycondition .= "( `billNo` = '{$billNo}') ";
         }
         //单据类型
         if ($inoutType != '') {
             if ($querycondition != '') {
                 $querycondition .= " and ";
             }
             $querycondition .= "( `inoutType` = '{$inoutType}') ";
         }
         //仓库
         if ($place != '') {
             if ($querycondition != '') {
                 $querycondition .= " and ";
             }
             $querycondition .= "( `place` = '{$place}') ";
         }
         //单据类型
         if ($billType != '') {
             if ($querycondition != '') {
                 $querycondition .= " and ";
             }
             $querycondition .= "( `billType` = '{$billType}') ";
         }
         //客户
         if ($client != '') {
             if ($querycondition != '') {
                 $querycondition .= " and ";
             }
             $querycondition .= "( `client` = '{$client}') ";
         }
         $table = StocksIndexAction::getTableNameByDate($sdate, $edate);
         if (!$table) {
             //system_out("StocksManagerAction.query error:获取表名出错,errcode:$table,
             //			sdate:$sdate,edate:$edate");
             //$this->setError("获取存储表名出错!");
             return false;
         }
         if (is_string($table)) {
             $table = array(array("tablename" => $table));
         }
         $volist = new VoList();
         //开始查询
         for ($i = 0; $i < sizeof($table); $i++) {
             $tablename = $table[$i]["tablename"];
             $result = $dao->findAll($querycondition, $tablename);
             $volist->addAll($result);
         }
         return $volist ? $volist->toResultSet() : false;
     } catch (Executive $e) {
         $this->setError("StocksManagerAction.query error:{$e},tablecondition:{$tablename}\n\t\t\t\t\t\t\tquerycondtion:{$querycondition}");
         throw new Exception($e);
     }
 }
Exemplo n.º 2
0
 public function queryLocationDetail($code = '')
 {
     $table = StocksIndexAction::getTableNameByCode($code);
     $volist = new VoList();
     $dao = new StocksDao();
     //开始查询
     for ($i = 0; $i < sizeof($table); $i++) {
         $tablename = $table[$i];
         $result = $dao->findAll("code='{$code}'", $tablename, '*', 'id');
         $volist->addAll($result);
     }
     $field = "billType,billNo,billDate,goodsName,madeIn,code,factoryNo,spec,client,inqty,outqty,voltage1,current1," . "direct,constant,grade,madeDate,memo,place,station";
     $action = new StocksManagerAction();
     $struct = $action->getStruct();
     //如果字段不是全部的,则把必须的字段替换
     if ($field != '*') {
         $field = explode(',', $field);
         $visible = array("_type_" => "INCLUDE", "data" => $field);
         $struct["visible"] = $visible;
         $struct["item"] = $field;
     }
     //返回值
     $rtn["struct"] = $struct;
     $rtn["data"] = $volist->toResultSet();
     return $rtn;
 }