/** * 非系统下单导入方法 */ public function view_importOrderData() { require_once WEB_PATH . 'lib/PHPExcel.php'; $uploadfile = date("Y") . date("m") . date("d") . rand(1, 100) . ".xlsx"; $path = WEB_PATH . 'html/upload/'; if (move_uploaded_file($_FILES['upfile']['tmp_name'], $path . $uploadfile)) { $importResult = "<font color=green>上传成功</font><br>"; $ismark = 'yes'; } else { $importResult = "<font color=red>上传失败</font><br>"; $ismark = 'no'; } $fileName = $path . $uploadfile; $filePath = $fileName; $PHPExcel = new PHPExcel(); $PHPReader = new PHPExcel_Reader_Excel2007(); if (!$PHPReader->canRead($filePath)) { $PHPReader = new PHPExcel_Reader_Excel5(); if (!$PHPReader->canRead($filePath)) { echo 'no Excel'; return; } } $PHPExcel = $PHPReader->load($filePath); $sheet = $PHPExcel->getActiveSheet(); /**取得一共有多少列*/ $c = 2; $importShow = ''; $purModel = new PurToWhModel(); while (true) { $aa = 'A' . $c; $bb = 'B' . $c; $cc = 'C' . $c; $dd = 'D' . $c; $ff = 'F' . $c; $gg = 'G' . $c; $ii = 'I' . $c; $jj = 'J' . $c; $purTime = trim($sheet->getCell($aa)->getValue()); $purTime = strtotime($purTime); $orderSn = trim($sheet->getCell($bb)->getValue()); $parnter = trim($sheet->getCell($cc)->getValue()); $sku = trim($sheet->getCell($dd)->getValue()); $purCount = trim($sheet->getCell($ff)->getValue()); $purPrice = trim($sheet->getCell($gg)->getValue()); $cguser = trim($sheet->getCell($ii)->getValue()); $purNote = trim($sheet->getCell($jj)->getValue()); if (empty($orderSn)) { break; } $rtnCode = $purModel->importOrderData($orderSn, $sku, $parnter, $purCount, $purPrice, $cguser, $purNote, $purTime); if ($rtnCode == '200') { $importShow .= "<font color=green>订单号[" . $orderSn . "]料号[" . $sku . "]添加成功</font><br/>"; } else { if ($rtnCode == '202') { $importShow .= "<font color=red>订单号[" . $orderSn . "]料号[" . $sku . "]已存在</font><br/>"; } else { if ($rtnCode == '201') { $importShow .= "<font color=red>订单号[" . $orderSn . "]料号[" . $sku . "]添加失败</font><br/>"; } } } $c++; } $this->smarty->assign('importShow', $importShow); $this->smarty->assign('importResult', $importResult); $this->smarty->display('importReceiptOrderResult.htm'); }