Example #1
0
 public function view_internalUseIostoreList()
 {
     //基础代码准备
     $InternalIoSellManagement = new InternalIoSellManagementAct();
     //搜索操作
     $condition = array();
     $ordersn = "";
     $choose_status = 0;
     $ioStatus = 0;
     $startTime = date("Y-m-d 00:00:00", time());
     $endTime = date("Y-m-d 23:59:59", time());
     if (isset($_POST) && !empty($_POST)) {
         $ordersn = trim($_POST['ordersnInput']);
         //单据号
         $ioTypeinvoiceChoose = $_POST['ioTypeinvoiceChoose'];
         //出入库单类型
         $ioStatus = $_POST['ioStatus'];
         //审核状态
         if (!empty($_POST['startTime']) && !empty($_POST['endTime'])) {
             $startTime = strtotime(trim($_POST['startTime']));
             //开始时间
             $endTime = strtotime(trim($_POST['endTime']));
             //结束时间
             $condition[] = "createdTime BETWEEN {$startTime} AND {$endTime}";
             $startTime = trim($_POST['startTime']);
             //开始时间
             $endTime = trim($_POST['endTime']);
             //结束时间
         } else {
             $condition[] = "createdTime BETWEEN " . strtotime($startTime) . " and " . strtotime($endTime);
         }
         if (!empty($ordersn)) {
             $condition[] = "ordersn = '{$ordersn}'";
         }
         if (!empty($ioTypeinvoiceChoose)) {
             $condition[] = "invoiceTypeId = '{$ioTypeinvoiceChoose}'";
             $choose_status = $ioTypeinvoiceChoose;
         } else {
             $condition[] = "invoiceTypeId in (1,2,3,4,5)";
         }
         if (!empty($ioStatus)) {
             $condition[] = "ioStatus = '{$ioStatus}'";
         }
         $this->where = "WHERE " . implode(" and ", $condition) . " and is_delete = 0 ";
     } else {
         //默认显示列表条件 invoiceTypeId in (1,2,3,4,5) 内部使用5种类型
         $this->where = "WHERE invoiceTypeId in (1,2,3,4,5) and createdTime BETWEEN " . strtotime($startTime) . " and " . strtotime($endTime) . " and is_delete = 0 ";
     }
     /*/分页
     		$total = $InternalIoSellManagement->act_getPageNum($this->where);
     		$num      = 5;//每页显示的个数
     		$page     = new Page($total,$num,'','CN');
     		$this->where    .= " order by id desc ".$page->limit;
     		*/
     //单据表
     $iostoreArr = $InternalIoSellManagement->act_iostoreList($this->where);
     /*
     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));
     }
     $this->smarty->assign('show_page',$show_page);
     */
     //单据类型
     $this->where = " where groupId = 1";
     //内部使用分组单据类型
     $invoiceTypeArr = $InternalIoSellManagement->act_invoiceTypeList($this->where);
     $invoiceNameArr = array();
     //出入库单据类型
     foreach ($invoiceTypeArr as $invoiceName) {
         $invoiceNameArr[$invoiceName['id']] = $invoiceName['invoiceName'];
     }
     //付款方式
     $payMethods = array();
     $paymentMethodsArr = $InternalIoSellManagement->act_changeCategoriesSkip();
     foreach ($paymentMethodsArr as $payValue) {
         $payMethods[$payValue['id']] = $payValue['method'];
     }
     //单据明细
     $iostoreDetails = array();
     $iostoreDetailNum = array();
     //合计件数
     $iostoreDetailDue = array();
     //应付款总金额
     if (!empty($iostoreArr)) {
         foreach ($iostoreArr as $ioId) {
             $this->where = " where iostoreId = " . $ioId['id'];
             $iostoredetailArr = $InternalIoSellManagement->act_iostoredetailList($this->where);
             if (empty($iostoredetailArr)) {
                 continue;
             }
             $sumNum = 0;
             $due = 0;
             foreach ($iostoredetailArr as $keyId => $ioNumInfo) {
                 $sumNum += $ioNumInfo['amount'];
                 $due += $ioNumInfo['cost'] * $ioNumInfo['amount'];
                 //仓位ID转换
                 $whereStr = " WHERE is_enable = 1 and type = 1 and id = {$ioNumInfo['positionId']}";
                 $iostoredetailArr[$keyId]['positionId'] = $InternalIoSellManagement->act_positionIdToName($whereStr);
                 //采购ID转换
                 $usermodel = UserModel::getInstance();
                 $whereStr = "where a.global_user_id=" . $ioNumInfo['purchaseId'];
                 $cgUser = $usermodel->getGlobalUserLists('global_user_name', $whereStr, '', '');
                 //$cgUser[0]['global_user_name'];
                 $iostoredetailArr[$keyId]['purchaseId'] = $cgUser[0]['global_user_name'];
             }
             $iostoreDetailNum[$ioId['id']] = $sumNum;
             $iostoreDetailDue[$ioId['id']] = $due;
             $iostoreDetails[$ioId['id']] = $iostoredetailArr;
         }
     }
     if (!empty($iostoreArr)) {
         $usermodel = UserModel::getInstance();
         //申请人
         $count = count($iostoreArr);
         for ($i = 0; $i < $count; $i++) {
             $user_info = $usermodel->getGlobalUserLists('global_user_name', "where a.global_user_id='{$iostoreArr[$i]['userId']}'", '', 'limit 1');
             $iostoreArr[$i]['userName'] = $user_info[0]['global_user_name'];
             $user_info = $usermodel->getGlobalUserLists('global_user_name', "where a.global_user_id='{$iostoreArr[$i]['operatorId']}'", '', 'limit 1');
             $iostoreArr[$i]['operatorName'] = $user_info[0]['global_user_name'];
         }
     }
     $this->smarty->assign('toplevel', 3);
     $this->smarty->assign('secondlevel', 31);
     $this->smarty->assign('ordersn', $ordersn);
     $this->smarty->assign('choose_status', $choose_status);
     $this->smarty->assign('ioStatus', $ioStatus);
     $this->smarty->assign('startTime', $startTime);
     $this->smarty->assign('endTime', $endTime);
     $this->smarty->assign('iostoreDetailNum', $iostoreDetailNum);
     $this->smarty->assign('iostoreDetailDue', $iostoreDetailDue);
     $this->smarty->assign('iostoreDetails', $iostoreDetails);
     $this->smarty->assign('payMethods', $payMethods);
     $this->smarty->assign('invoiceNameArr', $invoiceNameArr);
     if (empty($iostoreArr)) {
         $this->smarty->assign('iostoreArr', null);
     } else {
         $this->smarty->assign('iostoreArr', $iostoreArr);
     }
     $navlist = array(array('url' => 'index.php?mod=internalIoSell&act=internalUseIostoreList', 'title' => '单据业务'), array('url' => 'index.php?mod=internalIoSell&act=internalUseIostoreList', 'title' => '内部使用'));
     $this->smarty->assign('navlist', $navlist);
     $this->smarty->assign('curusername', $_SESSION['userName']);
     $this->smarty->display('internalUseIostoreList.htm');
 }