Exemplo n.º 1
0
 public function view_tmpReturnPros()
 {
     $tmpReturnProsAct = new TmpReturnProsAct();
     $productsAct = new ProductsAct();
     //ProductsAct
     //添加sku
     $type = isset($_GET['type']) ? $_GET['type'] : '';
     $sku = isset($_GET['sku']) ? post_check(trim($_GET['sku'])) : '';
     if ($type == 'add') {
         if (!empty($sku)) {
             $skuList = getSkuBygoodsCode($sku);
             if (empty($skuList)) {
                 $status = "{$_GET['sku']} 找不到对应料号";
                 header('Location:index.php?mod=products&act=tmpReturnPros&status=' . $status);
                 exit;
             }
             $sku = $skuList[0]['sku'];
             $whereProducts = "where sku='{$sku}' and productsStatus=3";
             $isExsit = $productsAct->act_getProductsCount($whereProducts);
             //查看添加的sku是否是pc_products中状态为3的(归还)
             $status = '';
             if ($isExsit > 0) {
                 //如果存在
                 $where = "where sku='{$sku}'";
                 $now = time();
                 $skuExistCount = $tmpReturnProsAct->act_getTmpReturnProsCount($where);
                 //查看添加的sku是否在退料临时表中存在
                 $flag = 0;
                 //标识是添加成功还是由于数量导致添加失败
                 if ($skuExistCount > 0) {
                     //如果存在
                     $productsCountArr = $productsAct->act_getProducts('productsCount', $whereProducts);
                     $productsCount = $productsCountArr[0]['productsCount'];
                     //该sku在products表中的数量
                     $skuCountArr = $tmpReturnProsAct->act_getTmpReturnPros("count", $where);
                     //该sku在退料临时表中的数量
                     $skuCount = $skuCountArr[0]['count'] + 1;
                     if ($skuCount > $productsCount) {
                         $flag = 1;
                         //改变标识变量,输出提示
                         $status = "添加失败,{$sku} 已经扫描过且数量达到上限";
                     } else {
                         $set = "set count='{$skuCount}',createdTime='{$now}'";
                         $tmpReturnProsAct->act_updateTmpReturnPros($set, "where sku='{$sku}'");
                     }
                 } else {
                     $userId = intval($_SESSION['userId']);
                     if ($userId <= 0) {
                         $status = "登陆超时,请重试";
                         header('Location:index.php?mod=products&act=tmpReturnPros&status=' . $status);
                         exit;
                     }
                     $tmpReturnProsAct->act_addTmpReturnPros("set sku='{$sku}',addUserId={$userId},createdTime='{$now}'");
                 }
                 if ($flag == 0) {
                     $status = $sku . ' 添加成功';
                 }
             } else {
                 $status = "添加失败,制作完成列表中找不到 {$sku}";
             }
         }
         header('Location:index.php?mod=products&act=tmpReturnPros&status=' . $status);
     }
     //展示tmp表中的记录
     $select = "*";
     $where = "WHERE returnType=1 order by createdTime desc";
     $tmpReturnProsList = $tmpReturnProsAct->act_getTmpReturnPros($select, $where);
     $navlist = array(array('url' => 'index.php?mod=products&act=getProductsComfirmList', 'title' => '产品制作'), array('url' => 'index.php?mod=products&act=tmpReturnPros', 'title' => '新品归还'));
     $this->smarty->assign('navlist', $navlist);
     $this->smarty->assign('onevar', 5);
     $this->smarty->assign('twovar', 56);
     $this->smarty->assign('show_page', $show_page);
     $this->smarty->assign('title', '新品归还');
     $this->smarty->assign('status', $status);
     if (!empty($tmpReturnProsList)) {
         $whInfoList = getWhInfo();
         //根据接口取得对应仓库信息
         $whArr = array();
         foreach ($whInfoList as $value) {
             if (intval($value['id']) > 0) {
                 $whArr[$value['id']] = $value['whName'];
             }
         }
         $countProsList = count($tmpReturnProsList);
         for ($i = 0; $i < $countProsList; $i++) {
             $sku = $tmpReturnProsList[$i]['sku'];
             $tName = 'pc_goods';
             $select = 'goodsName';
             $where = "WHERE sku='{$sku}'";
             $skuInfoList = OmAvailableModel::getTNameList($tName, $select, $where);
             $tmpReturnProsList[$i]['goodsName'] = $skuInfoList[0]['goodsName'];
             $tName = 'pc_goods_whId_location_raletion';
             $select = 'location,whId';
             $where = "WHERE sku='{$sku}'";
             $skuLocWhInfoList = OmAvailableModel::getTNameList($tName, $select, $where);
             $tmpReturnProsList[$i]['location'] = $skuLocWhInfoList[0]['location'];
             $tmpReturnProsList[$i]['whName'] = $whArr[$skuLocWhInfoList[0]['whId']];
         }
     }
     $this->smarty->assign('tmpReturnProsList', empty($tmpReturnProsList) ? array() : $tmpReturnProsList);
     $this->smarty->display("tmpReturnPros.htm");
 }
Exemplo n.º 2
0
 public function view_tmpReturnPros()
 {
     if (!isset($_SESSION['userId'])) {
         header('Location:index.php?mod=login&act=index');
     }
     $tmpReturnProsAct = new TmpReturnProsAct();
     $productsAct = new ProductsAct();
     //ProductsAct
     //添加sku
     $type = isset($_GET['type']) ? $_GET['type'] : '';
     $sku = isset($_GET['sku']) ? post_check($_GET['sku']) : '';
     if ($type == 'add') {
         if (!empty($sku)) {
             $whereProducts = "where sku='{$sku}' and productsStatus=3";
             $isExsit = $productsAct->act_getProductsCount($whereProducts);
             //查看添加的sku是否是pc_products中状态为5的(状态为文员确认归还)
             $status = '';
             if ($isExsit > 0) {
                 //如果存在
                 $where = "where sku='{$sku}'";
                 $now = time();
                 $skuExistCount = $tmpReturnProsAct->act_getTmpReturnProsCount($where);
                 //查看添加的sku是否在退料临时表中存在
                 $flag = 0;
                 //标识是添加成功还是由于数量导致添加失败
                 if ($skuExistCount > 0) {
                     //如果存在
                     $productsCountArr = $productsAct->act_getProducts('productsCount', $whereProducts);
                     $productsCount = $productsCountArr[0]['productsCount'];
                     //该sku在products表中的数量
                     $skuCountArr = $tmpReturnProsAct->act_getTmpReturnPros("count", $where);
                     //该sku在退料临时表中的数量
                     $skuCount = $skuCountArr[0]['count'] + 1;
                     if ($skuCount > $productsCount) {
                         $flag = 1;
                         //改变标识变量,输出提示
                         $status = '添加失败,该sku已经扫描过且数量达到上限';
                     } else {
                         $set = "set count='{$skuCount}',createdTime='{$now}'";
                         $tmpReturnProsAct->act_updateTmpReturnPros($set, "where sku='{$sku}'");
                     }
                 } else {
                     $tmpReturnProsAct->act_addTmpReturnPros("set sku='{$sku}',count=1,createdTime='{$now}'");
                 }
                 if ($flag == 0) {
                     $status = '添加成功';
                 }
             } else {
                 $status = '添加失败,文员确认收到列表中找不到该料号';
             }
         }
         header('Location:index.php?mod=TmpReturnPros&act=tmpReturnPros&status=' . $status);
     }
     //展示tmp表中的记录
     $select = "*";
     $where = "order by createdTime desc";
     $productsList = $tmpReturnProsAct->act_getTmpReturnPros($select, $where);
     //删除tmp中的记录
     $this->tp->set_file("productsList", "tmpReturnPros.html");
     $this->tp->set_file("header", "header.html");
     $this->tp->set_file("link", "productsLink.html");
     $this->tp->set_file("footer", "footer.html");
     $this->tp->parse("header", "header");
     $this->tp->parse("link", "link");
     $this->tp->parse("footer", "footer");
     $this->tp->set_var("title", "退还料号临时表");
     $this->tp->set_block("productsList", "list", "lists");
     $this->tp->set_var("username", $_SESSION['username']);
     $this->tp->set_var("status", $_GET['status']);
     if (!empty($productsList)) {
         foreach ($productsList as $products) {
             $this->tp->set_var("t_id", $products['id']);
             $this->tp->set_var("t_sku", $products['sku']);
             $this->tp->set_var("t_count", $products['count']);
             $this->tp->set_var("t_createdTime", date("Y-m-d H:m:s", $products['createdTime']));
             $this->tp->parse("lists", "list", true);
         }
     }
     $this->tp->parse("buff", "productsList");
     $this->tp->p("buff");
 }