Ejemplo n.º 1
0
 public function view_createModReturnBill()
 {
     $whId = $_GET['whId'] ? post_check(trim($_GET['whId'])) : '';
     $whInfoList = getWhInfo();
     //根据接口取得对应仓库信息
     $whInfoIdArr = array();
     foreach ($whInfoList as $value) {
         $whInfoIdArr[] = $value['id'];
         //取得仓库id
     }
     if (!in_array($whId, $whInfoIdArr)) {
         $status = '仓库信息有误';
         header("Location:index.php?mod=products&act=tmpReturnPros&status={$status}");
         exit;
     }
     $whId = intval($whId);
     $tName = 'pc_tmp_products_return';
     $select = '*';
     $where = "WHERE returnType=3 ";
     //选出产品修改归还的产品
     $returnSkuList = OmAvailableModel::getTNameList($tName, $select, $where);
     if (empty($returnSkuList)) {
         $status = '修改产品归还列表中没有sku,请先添加';
         header("Location:index.php?mod=products&act=tmpModReturnPros&status={$status}");
         exit;
     }
     try {
         BaseModel::begin();
         //先插入表头数据
         $tName = 'pc_products_iostore';
         $dataIostore = array();
         $dataIostore['ordersn'] = "XGGH" . date('Y') . date('m') . date('d') . date("H") . date('i') . date('s') . str_pad(rand(1, 9999), 4, '0', STR_PAD_LEFT);
         //默认领料单单号为前缀“PRODUCTOR”+年月日时分秒生成
         $where = "WHERE ordersn='{$dataIostore['ordersn']}'";
         $countIoStore = OmAvailableModel::getTNameCount($tName, $where);
         if ($countIoStore) {
             $status = '异常,请重试';
             header("Location:index.php?mod=products&act=tmpModReturnPros&status={$status}");
             exit;
         }
         $dataIostore['iostoreTypeId'] = 2;
         //单据类型为2,退料单
         $dataIostore['addUserId'] = $_SESSION['userId'];
         //添加人
         if (intval($dataIostore['addUserId']) <= 0) {
             $status = '登陆超时,请重试';
             header("Location:index.php?mod=products&act=tmpModReturnPros&status={$status}");
             exit;
         }
         $dataIostore['createdTime'] = time();
         //生成时间
         $dataIostore['whId'] = $whId;
         $insertIostoreId = OmAvailableModel::addTNameRow2arr($tName, $dataIostore);
         //下面插入表体
         $tName = 'pc_products_iostore_detail';
         foreach ($returnSkuList as $value) {
             $dataIostoreDetail = array();
             $dataIostoreDetail['iostoreId'] = $insertIostoreId;
             $dataIostoreDetail['iostoreTypeId'] = 2;
             //退料单
             $dataIostoreDetail['sku'] = $value['sku'];
             //$dataIostoreDetail['amount'] = $value['amount'];
             $dataIostoreDetail['addUserId'] = $value['addUserId'];
             $dataIostoreDetail['addTime'] = $value['createdTime'];
             $dataIostoreDetail['whId'] = $whId;
             OmAvailableModel::addTNameRow2arr($tName, $dataIostoreDetail);
         }
         //下面删除掉returnType=3的料号
         $tName = 'pc_tmp_products_return';
         $where = "WHERE returnType=3 ";
         OmAvailableModel::deleteTNameRow($tName, $where);
         BaseModel::commit();
         BaseModel::autoCommit();
         $status = "退料单 {$dataIostore['ordersn']} 生成成功";
         header("Location:index.php?mod=products&act=getInStoreList&status={$status}");
         exit;
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         $status = "系统错误,生成失败";
         header("Location:index.php?mod=products&act=getInStoreList&status={$status}");
         exit;
     }
 }
Ejemplo n.º 2
0
 function act_getInStoreDetailList()
 {
     $iostoreId = $_GET['iostoreId'] ? post_check(trim($_GET['iostoreId'])) : 0;
     //退料单状态,草稿或者已经发送至仓库
     $iostoreId = intval($iostoreId);
     if ($iostoreId <= 0) {
         $status = '退料单非法';
         header("Location:index.php?mod=products&act=getInStoreList&status={$status}");
         exit;
     }
     $tName = 'pc_products_iostore';
     $select = '*';
     $where = "WHERE iostoreTypeId=2 AND is_delete=0 AND id={$iostoreId} ";
     $inStoreList = OmAvailableModel::getTNameList($tName, $select, $where);
     $inStore = $inStoreList[0];
     if (empty($inStore)) {
         $status = '系统不存在该退料单';
         header("Location:index.php?mod=products&act=getInStoreList&status={$status}");
         exit;
     }
     $tName = 'pc_products_iostore_detail';
     $select = '*';
     $where = "WHERE is_delete=0 AND iostoreId={$iostoreId} ";
     $total = OmAvailableModel::getTNameCount($tName, $where);
     $num = 1000;
     //每页显示的个数
     $page = new Page($total, $num, '', 'CN');
     $where .= "order by id desc " . $page->limit;
     $inStoreDetailList = OmAvailableModel::getTNameList($tName, $select, $where);
     if (!empty($inStoreDetailList)) {
         $whInfoList = getWhInfo();
         //根据接口取得对应仓库信息
         $whArr = array();
         foreach ($whInfoList as $value) {
             if (intval($value['id']) > 0) {
                 $whArr[$value['id']] = $value['whName'];
             }
         }
         $countStoreDetailList = count($inStoreDetailList);
         for ($i = 0; $i < $countStoreDetailList; $i++) {
             $sku = $inStoreDetailList[$i]['sku'];
             $tName = 'pc_goods';
             $select = 'goodsName';
             $where = "WHERE sku='{$sku}'";
             $skuInfoList = OmAvailableModel::getTNameList($tName, $select, $where);
             $inStoreDetailList[$i]['goodsName'] = $skuInfoList[0]['goodsName'];
             $tName = 'pc_goods_whId_location_raletion';
             $select = 'location,whId';
             $where = "WHERE sku='{$sku}'";
             $skuLocWhInfoList = OmAvailableModel::getTNameList($tName, $select, $where);
             $inStoreDetailList[$i]['location'] = $skuLocWhInfoList[0]['location'];
             $inStoreDetailList[$i]['whName'] = $whArr[$skuLocWhInfoList[0]['whId']];
         }
     }
     if (!empty($_GET['page'])) {
         if (intval($_GET['page']) <= 1 || intval($_GET['page']) > ceil($total / $num)) {
             $n = 1;
         } else {
             $n = (intval($_GET['page']) - 1) * $num + 1;
         }
     } else {
         $n = 1;
     }
     if ($total > $num) {
         //输出分页显示
         $show_page = $page->fpage(array(0, 2, 3, 4, 5, 6, 7, 8, 9));
     } else {
         $show_page = $page->fpage(array(0, 2, 3));
     }
     return array('inStore' => $inStore, 'inStoreDetailList' => $inStoreDetailList, 'show_page' => $show_page);
 }