public function getStorageQuotationsToJson($code)
 {
     $cotations = $this->dao->getValuesFromAnAtive($code);
     return $this->buildJsonArray($cotations);
 }
Exemplo n.º 2
0
 /**
  * 删除库房
  * @param $id
  * @return boolean
  */
 public function deleted($data)
 {
     try {
         $storeage = new StorageDao();
         //检查仓库是否已经使用
         $storageName = $data["storageName"];
         $stocks = new CurrentStocksDao();
         $count = $stocks->getCount("place='{$storageName}' or station = '{$storageName}'");
         if ($count > 0) {
             $this->setError("该" . $data['stype'] . "含有库存,不能删除!");
             return false;
         }
         $id = $data["id"];
         $result = $storeage->deleteById($id);
     } catch (Exception $e) {
         system_out("StorageAction delete exception:" . $e);
         throw new Exception($e);
     }
     return $result;
 }
Exemplo n.º 3
0
 /**
  * 清理数据
  *
  * @param array $cleardata 要清理的类型
  */
 public function clear($cleardata)
 {
     if (!is_array($cleardata)) {
         return "数据清理失败";
     }
     try {
         for ($i = 0; $i < sizeof($cleardata); $i++) {
             $datatype = $cleardata[$i];
             switch ($datatype) {
                 case '采购申请':
                     $dao = new PurchaseOrderHeadDao();
                     $dao->deleteAll('');
                     $dao = new PurchaseOrderDetailDao();
                     $dao->deleteAll('');
                     break;
                 case '客户资料':
                     $dao = new ClientsDao();
                     $dao->deleteAll('');
                     break;
                 case '故障登记':
                     $dao = new FaultLogsDao();
                     $dao->deleteAll('');
                     break;
                 case '定期检查':
                     $dao = new CheckLogsDao();
                     $dao->deleteAll('');
                     break;
                 case '投诉登记':
                     $dao = new ComplaintLogsDao();
                     $dao->deleteAll('');
                     break;
                 case '产品资料':
                     $dao = new GoodsDao();
                     $dao->deleteAll('');
                     break;
                 case '厂商资料':
                     $dao = new SupplyDao();
                     $dao->deleteAll('');
                     break;
                 case '库房资料':
                     $dao = new StorageDao();
                     $dao->deleteAll('');
                     break;
                 case '库存资料':
                     $dao = new StocksIndexDao();
                     $result = $dao->findAll()->toResultSet();
                     for ($j = 0; $j < sizeof($result); $j++) {
                         $tablename = $result[$j]['tablename'];
                         $dao->deleteAll('', $tablename);
                     }
                     $dao->deleteAll('', 'stc_currentstocks');
                     $dao->deleteAll('', 'stc_codeIndex');
                     break;
                 case '条码规则':
                     $dao = new CodeDictDao();
                     $dao->deleteAll('');
                     break;
                 case '开灯记录':
                     $dao = new UnconfirmstationDao();
                     $dao->deleteAll('');
                     break;
             }
         }
     } catch (Exception $e) {
         throw new Exception($e);
     }
     return true;
 }
Exemplo n.º 4
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once '../../../DataBase/Connection.php';
require_once '../../../../util/Maps/HashMap.php';
require_once '../../../Link/LinkController.php';
require_once '../HtmlLib.php';
require_once 'StorageDao.php';
$allCots = HtmlLib::cotacoes();
$types = array("BMF", "NY", "London", 'Arabica', 'Dolar', 'Euro', 'IBovespa');
$storage = new StorageDao(Connection::connect());
foreach ($types as $val) {
    if ($allCots->containsKey($val)) {
        $cots = $allCots->get($val);
        foreach ($cots as $cot) {
            $cotation = turnItToObj($cot);
            try {
                if ($cotation->hasValidValues()) {
                    echo $storage->saveFuturas($cotation);
                } else {
                    echo 'Não foi possível salvar os valores de ' . $cotation->getCode();
                }
            } catch (PDOException $err) {
                echo $err->getMessage() . '<br />';
            } catch (Exception $err) {
                echo $err->getMessage() . '<br />';
            }
        }
    }
}
Exemplo n.º 5
0
 /**
  * 库存一览表
  *
  * @param string $condition
  */
 public function queryCurrentStocksGeneral($condition)
 {
     try {
         $storage = new StorageDao();
         $sql = "select storageNo,storageName from " . (DB_PREFIX ? DB_PREFIX . "_" : "") . "storage where stype = '库房' or stype='库区' order by storageNo";
         $storageList = $storage->query($sql)->toArray();
         $stocks = new CurrentStocksDao();
         $sql = "select goodsName,spec from " . (DB_PREFIX ? DB_PREFIX . "_" : "") . "currentstocks ";
         if ($condition != '') {
             $sql = $sql . " where " . $condition;
         }
         $sql .= "group by goodsName,spec";
         //echo $sql ;
         $goodsList = $stocks->query($sql)->toArray();
         //数据
         $data = array();
         for ($i = 0; $i < sizeof($goodsList); $i++) {
             $item = array();
             $item["goodsName"] = $goodsList[$i]["goodsName"];
             $item["spec"] = $goodsList[$i]["spec"];
             //计算每个仓库的值
             foreach ($storageList as $place) {
                 $sql = "goodsName = '" . $goodsList[$i]["goodsName"] . "' and spec ='" . $goodsList[$i]["spec"] . "' and placeno like'" . $place['storageNo'] . "%'";
                 if ($condition != '') {
                     $sql = $sql . " and " . $condition;
                 }
                 //echo $sql ."<br>";
                 $sum = $stocks->getSum('qty', $sql);
                 $item[$place['storageNo']] = $sum;
             }
             array_push($data, $item);
         }
         //计算合计
         $sumrecord['goodsName'] = '合计:';
         foreach ($storageList as $place) {
             $sumrecord[$place['storageNo']] = ExFunction::ex_array_sum($data, $place['storageNo']);
         }
         array_push($data, $sumrecord);
         //表的结构
         $item = array("goodsName", "spec");
         $label = array("goodsName" => "品名", "spec" => "型号");
         foreach ($storageList as $place) {
             array_push($item, $place['storageNo']);
             $label[$place['storageNo']] = $place['storageName'];
         }
         $columnitem = $item;
         $enabled = array("_type_" => "*");
         $visible = array("_type_" => "*");
         $align = array();
         $width = array("qty" => 50);
         $inputtype = array();
         $struct["item"] = $item;
         $struct["label"] = $label;
         $struct["columnitem"] = $columnitem;
         $struct["enabled"] = $enabled;
         $struct["visible"] = $visible;
         $struct["align"] = $align;
         $struct["width"] = $width;
         $struct["inputtype"] = $inputtype;
         //返回值
         $rtn["struct"] = $struct;
         $rtn["data"] = $data;
         return $rtn;
     } catch (Exception $e) {
         throw new Exception($e);
     }
 }