/** * 料号海外负责人导入 */ public function view_importOverSeaSku() { 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; $sku = trim($sheet->getCell($aa)->getValue()); $cguser = trim($sheet->getCell($bb)->getValue()); if (empty($sku)) { break; } $rtnCode = $purModel->addOldSkuToOverSku($sku, $cguser); if ($rtnCode == 200) { $importShow .= "<font color=green>料号[" . $sku . "]关联成功</font><br/>"; } else { if ($rtnCode == 201) { $importShow .= "<font color=red>料号[" . $sku . "]已存在海外仓预警</font><br/>"; } else { if ($rtnCode == 404) { $importShow .= "<font color=red>料号[" . $sku . "]不存在</font><br/>"; } else { if ($rtnCode == 202) { $importShow .= "<font color=red>料号[" . $sku . "]关联失败</font><br/>"; } } } } $c++; } $this->smarty->assign('importShow', $importShow); $this->smarty->assign('importResult', $importResult); $this->smarty->display('importOverSeaSkuResult.htm'); }