col_prefix .'to_branch_bn']) { $purchaseLib = kernel::single('purchase_purchase_order'); $branchInfo = $purchaseLib->getWarehouse($row[$this->col_prefix .'to_branch_bn']); $row[$this->col_prefix .'to_branch_bn'] = $branchInfo['branch_name']; } return $row[$this->col_prefix .'to_branch_bn']; } var $column_status = '审核状态'; var $column_status_width = '100'; var $column_status_order = 14; function column_status($row) { if ($row[$this->col_prefix .'status'] == '3') { return '已取消'; } return ($row[$this->col_prefix .'status'] == 2 ? '已审核' : '未审核'); } var $column_delivery_status = '发贷状态'; var $column_delivery_status_width = '100'; var $column_delivery_status_order = 14; function column_delivery_status($row) { return ($row[$this->col_prefix .'delivery_status'] == 2 ? '已发货' : '未发货'); } var $column_edit = '操作'; var $column_edit_order = 2; var $column_edit_width = '150'; function column_edit($row) { $bill_id = $row['bill_id']; $finder_id = $_GET['_finder']['finder_id']; $pick_no = $row[$this->col_prefix.'pick_no']; $button = <<补发 EOF; if($row[$this->col_prefix .'status'] == '2') { if($row[$this->col_prefix .'delivery_status']==2 && ($row['pick_num'] > $row['branch_send_num'])) { //检查是否存在未完成的出库单 $stockoutObj = app::get('purchase')->model('pick_stockout_bills'); $sql = "SELECT a.stockout_id FROM sdb_purchase_pick_stockout AS a LEFT JOIN sdb_purchase_pick_stockout_bills AS b ON a.stockout_id=b.stockout_id WHERE a.bill_id=". $bill_id ." AND (b.status=1 OR b.o_status=1)"; $stockRow = $stockoutObj->db->selectrow($sql); if(empty($stockRow)) { return ''. $button .''; } } return ''; } $button = []; if ($row[$this->col_prefix .'status'] == '1'){ $button[] = <<审核 EOF; // 取消按钮 $button[] = <<取消 EOF; } return ''. implode('  ', $button) .''; } var $detail_base = '拣货单详情'; /** * detail_base * @param mixed $bill_id ID * @return mixed 返回值 */ public function detail_base($bill_id) { $render = app::get('console')->render(); //详情 $pickObj = app::get('purchase')->model('pick_bills'); $row = $pickObj->dump(array('bill_id'=>$bill_id), '*'); $row['status'] = $row['status'] == '2' ? '已审核' : '未审核'; $row['delivery_status'] = $row['delivery_status'] == '2' ? '已发货' : '未发货'; $row['create_time'] = date('Y-m-d H:i:s', $row['create_time']); if($row['to_branch_bn']) { $purchaseLib = kernel::single('purchase_purchase_order'); $branchInfo = $purchaseLib->getWarehouse($row['to_branch_bn']); $row['branch_name'] = $branchInfo['branch_name']; } $render->pagedata['data'] = $row; return $render->fetch('admin/vop/vopick_detail.html'); } var $detail_items = '拣货单明细'; /** * detail_items * @param mixed $bill_id ID * @return mixed 返回值 */ public function detail_items($bill_id) { $render = app::get('console')->render(); //详情 $pickObj = app::get('purchase')->model('pick_bills'); $pickItemObj = app::get('purchase')->model('pick_bill_items'); if($bill_id){ //拣货单信息 $row = $pickObj->dump(array('bill_id'=>$bill_id), 'po_id, bill_id, status, delivery_status'); //拣货单明细 $dataList = $pickItemObj->getList('*', array('bill_id'=>$bill_id)); $billItemIdArr = array_column($dataList, 'bill_item_id'); $labelList = kernel::single('ome_bill_label')->getLabelFromOrder($billItemIdArr, 'pick_bill_item'); foreach ($dataList as $k => $v){ if ($labelList[$v['bill_item_id']]) { $dataList[$k]['order_label'] = ''; foreach ($labelList[$v['bill_item_id']] as $lk => $lv) { $dataList[$k]['order_label'] .= sprintf("%s", $lv['label_name'], $lv['label_color'], $lv['label_name']); } } } //计算已出库数量 if($row['status'] == 2){ $sql = "SELECT a.stockout_id FROM sdb_purchase_pick_stockout AS a LEFT JOIN sdb_purchase_pick_stockout_bills AS b ON a.stockout_id=b.stockout_id WHERE a.bill_id=". $bill_id ." AND b.confirm_status=2 AND b.o_status in(2,3)"; $stockoutInfo = $pickObj->db->select($sql); if($stockoutInfo){ $stockout_ids = array(); foreach ($stockoutInfo as $key => $val) { $stockout_ids[] = $val['stockout_id']; } foreach ($dataList as $key => $val) { $sql = "SELECT stockout_item_id FROM sdb_purchase_pick_stockout_bill_items WHERE stockout_id in(". implode(',', $stockout_ids) .") AND po_id=". $row['po_id'] ." AND bill_id=". $row['bill_id'] . " AND barcode='". $val['barcode'] ."'"; $item_ids = array(); $stockItem = $pickObj->db->select($sql); foreach ($stockItem as $key_i => $val) { $item_ids[] = $val['stockout_item_id']; } if($item_ids){ $sql = "SELECT sum(num) AS send_num FROM sdb_purchase_pick_stockout_bill_item_boxs WHERE stockout_item_id in(". implode(',', $item_ids) .")"; $boxItem = $pickObj->db->selectrow($sql); $dataList[$key]['send_num'] = $boxItem['send_num']; } } } } $render->pagedata['dataList'] = $dataList; $pickItemObj = app::get('purchase')->model('pick_bill_check_items'); $checkDataList = $pickItemObj->getList('*', array('bill_id'=>$bill_id)); foreach ($checkDataList as $k => $v) { if ($pickItemObj->order_label[$v['order_label']]) { $checkDataList[$k]['order_label'] = $pickItemObj->order_label[$v['order_label']]; } } $render->pagedata['checkDataList'] = $checkDataList; } $render->pagedata['is_stockout'] = ($row['status'] == 2 ? true : false); $render->pagedata['pick_info'] = $row; return $render->fetch('admin/vop/vopick_item.html'); } var $detail_logs = '操作日志'; /** * detail_logs * @param mixed $bill_id ID * @return mixed 返回值 */ public function detail_logs($bill_id) { $render = app::get('console')->render(); $logObj = app::get('ome')->model('operation_log'); $logs = $logObj->read_log(array('obj_id'=>$bill_id, 'obj_type'=>'pick_bills@purchase'), 0, -1); foreach($logs as $k=>$v) { $logs[$k]['operate_time'] = date('Y-m-d H:i:s', $v['operate_time']); } $render->pagedata['logs'] = $logs; return $render->fetch('admin/vop/logs.html'); } /** * 订单标记 */ public $column_order_label = '标记'; public $column_order_label_width = 110; public $column_order_label_order = 30; /** * column_order_label * @param mixed $row row * @param mixed $list list * @return mixed 返回值 */ public function column_order_label($row, $list) { $bill_id = $row['bill_id']; //获取订单标记列表 $labelList = $this->__getOrderLabel($list); $dataList = $labelList[$bill_id]; if(empty($dataList)){ return ''; } //默认只显示三条记录 $str = []; $color_i = 0; foreach ($dataList as $key => $val) { $color_i++; // if($color_i > 3){ // continue; // } $str[] = sprintf("%s", $val['label_name'], $val['label_color'], $val['label_name']); } $str = implode("
", $str); return $str; } /** * 订单标记列表 * * @param array $list * @return null */ private function __getOrderLabel($list) { static $arrOrderLabel; if(isset($arrOrderLabel)){ return $arrOrderLabel; } $billIds = array(); foreach($list as $val) { $billIds[] = $val['bill_id']; } //获取订单标记列表 $orderLabelObj = app::get('ome')->model('bill_label'); $labelData = $orderLabelObj->getBIllLabelList($billIds, 'pick_bill'); foreach($labelData as $val) { $bill_id = $val['bill_id']; $arrOrderLabel[$bill_id][] = array( 'label_id' => $val['label_id'], 'label_name' => $val['label_name'], 'label_color' => $val['label_color'], ); } unset($billIds, $labelData); return $arrOrderLabel; } }