public function view_labelingList() { $navlist = array(array('url' => '', 'title' => '入库'), array('url' => 'index.php?mod=pasteLabel&act=pasteLabel', 'title' => '贴标录入'), array('url' => '', 'title' => '贴标列表')); $toplevel = 1; $secondlevel = 17; $checkUser = isset($_GET['checkUser']) ? $_GET['checkUser'] : ""; $sku = isset($_GET['sku']) ? $_GET['sku'] : ""; $status = isset($_GET['status']) ? $_GET['status'] : 0; $start = isset($_GET['startdate']) ? $_GET['startdate'] : ""; $end = isset($_GET['enddate']) ? $_GET['enddate'] : ""; $this->smarty->assign('navlist', $navlist); $this->smarty->assign('toplevel', $toplevel); $this->smarty->assign('secondlevel', $secondlevel); $this->smarty->assign("status", $status); if (empty($checkUser) && empty($sku) && empty($start) && empty($end) && empty($status)) { $where = "where a.is_delete=0 and a.status=1 order by a.id desc"; } else { if (!empty($checkUser)) { $where[] = "a.labelUserId='{$checkUser}'"; $this->smarty->assign("labelingUserId", $checkUser); } if (!empty($status)) { if ($status == 1) { $where[] = "a.labelUserId is NULL"; } if ($status == 2) { $where[] = "a.labelUserId is not NULL"; } } if (!empty($sku)) { $where[] = "b.sku = '{$sku}'"; $this->smarty->assign("sku", $sku); } if (!empty($start) && !empty($end)) { $starttime = strtotime($start); $endtime = strtotime($end); $where[] = "(a.labelTime between {$starttime} and {$endtime})"; $this->smarty->assign("start", $start); $this->smarty->assign("end", $end); } elseif (!empty($start) && empty($end)) { $starttime = strtotime($start); $where[] = "a.labelTime >{$starttime}"; $this->smarty->assign("start", $start); } elseif (empty($start) && !empty($end)) { $endtime = strtotime($end); $where[] = "a.labelTime < {$endtime}"; $this->smarty->assign("end", $end); } $where = implode(" AND ", $where); $where = " where a.is_delete=0 and a.status=1 and " . $where . " order by a.id desc"; } $lists = PasteLabelModel::selectList($where); $pagesize = 20; $nums = count($lists); $pager = new Page($nums, $pagesize); $lists = PasteLabelModel::selectList($where . " " . $pager->limit); if ($nums > $pagesize) { //分页 $pagestr = $pager->fpage(array(0, 2, 3, 4, 5, 6, 7, 8, 9)); } else { $pagestr = $pager->fpage(array(0, 2, 3)); } $usermodel = UserModel::getInstance(); //贴标员 $tallyUser = $usermodel->getGlobalUserLists('global_user_id,global_user_name', "where a.global_user_job=130", '', ''); $this->smarty->assign('tallyUser', $tallyUser); $toptitle = '贴标列表'; //顶部链接 $this->smarty->assign('toptitle', $toptitle); $this->smarty->assign('pagestr', $pagestr); $this->smarty->assign("lists", $lists); $this->smarty->display('labelingList.htm'); }
public function act_export() { $checkUser = $_GET['checkUser']; $status = $_GET['status']; $sku = $_GET['sku']; $startdate = $_GET['startdate']; $enddate = $_GET['enddate']; if (empty($checkUser) && empty($status) && empty($sku) && empty($startdate) && empty($enddate)) { echo "请选择导出条件"; exit; } if (!empty($checkUser)) { $where[] = "a.labelUserId='{$checkUser}'"; } if (!empty($status)) { if ($status == 1) { $where[] = "a.labelUserId is NULL"; } if ($status == 2) { $where[] = "a.labelUserId is not NULL"; } } if (!empty($sku)) { $where[] = "b.sku = '{$sku}'"; } if (!empty($startdate)) { $start = strtotime($startdate); $where[] = "a.labelTime >={$start}"; } if (!empty($enddate)) { $end = strtotime($enddate); $where[] = "a.labelTime <={$end}"; } $where = implode(" AND ", $where); $where = " where a.is_delete=0 and a.status=1 and " . $where . " order by a.id desc"; $lists = PasteLabelModel::selectList($where); $excel = new ExportDataExcel('browser', "labelKpiExport" . date('Y-m-d') . ".xls"); $excel->initialize(); $tharr = array("贴标人", "贴标时间", "SKU", "数量", "分组号", "批次号"); $excel->addRow($tharr); foreach ($lists as $list) { if (!empty($list['labelUserId'])) { $user = getUserNameById($list['labelUserId']); $time = date('Y-m-d H:i:s', $list['labelTime']); } else { $user = ''; $time = ''; } $sku = $list['sku']; $num = $list['labelNum']; $id = $list['id']; $batchNum = $list['batchNum']; $tdarr = array($user, $time, $sku, $num, $id, $batchNum); $excel->addRow($tdarr); } $excel->finalize(); exit; }
public function initDB() { global $dbConn; self::$dbConn = $dbConn; mysql_query('SET NAMES UTF8'); }