Ejemplo n.º 1
0
 public function view_insert()
 {
     $errMsg = "";
     $res = 0;
     $cn_name = isset($_POST["cn_name"]) ? post_check($_POST["cn_name"]) : "";
     $en_name = isset($_POST["en_name"]) ? post_check($_POST["en_name"]) : "";
     $ship_ali = isset($_POST["ship_ali"]) ? post_check($_POST["ship_ali"]) : "";
     $ship_abb = isset($_POST["ship_abb"]) ? post_check($_POST["ship_abb"]) : "";
     $ship_logo = isset($_POST["ship_logo"]) ? post_check($_POST["ship_logo"]) : "";
     $ship_index = isset($_POST["ship_index"]) ? post_check($_POST["ship_index"]) : "";
     $plat_arr = isset($_POST["plat_name"]) ? $_POST["plat_name"] : "";
     $ship_add = isset($_POST["ship_add"]) ? post_check($_POST["ship_add"]) : 0;
     $ship_type = isset($_POST["ship_type"]) ? post_check($_POST["ship_type"]) : "";
     $min_weight = isset($_POST["min_weight"]) ? post_check($_POST["min_weight"]) : 0;
     $max_weight = isset($_POST["max_weight"]) ? post_check($_POST["max_weight"]) : 0;
     $ship_day = isset($_POST["ship_day"]) ? post_check($_POST["ship_day"]) : 0;
     $ship_note = isset($_POST["ship_note"]) ? post_check($_POST["ship_note"]) : "";
     $is_track = isset($_POST["is_track"]) ? post_check($_POST["is_track"]) : 1;
     if (empty($cn_name)) {
         $errMsg .= "运输方式中文名称有误!<br/>";
     }
     if (empty($en_name)) {
         $errMsg .= "运输方式英文名称有误!<br/>";
     }
     if (empty($ship_ali)) {
         $errMsg .= "运输方式简称有误!<br/>";
     }
     if (empty($ship_abb) || !preg_match("/^[A-Z]{5,5}\$/", $ship_abb)) {
         $errMsg .= "运输方式简码有误!<br/>";
     }
     if (empty($ship_index) || !preg_match("/^[A-Z]{1,1}\$/", $ship_index)) {
         $errMsg .= "运输方式字母索引有误!<br/>";
     }
     if (!count($plat_arr)) {
         $errMsg .= "所属平台有误!<br/>";
     }
     if (empty($ship_add)) {
         $errMsg .= "发货地址有误!<br/>";
     }
     if (!in_array($ship_type, array("0", "1"))) {
         $errMsg .= "物流类型有误!<br/>";
     }
     $where = "(carrierNameEn = '{$en_name}' OR carrierNameCn = '{$cn_name}' OR carrierAbb = '{$ship_abb}')";
     $res = CarrierManageModel::modListCount($where);
     if ($res > 0) {
         $errMsg .= "添加失败:运输方式已存在,中文名或英文名或简码都不能重复!";
     }
     if (!$errMsg) {
         $data = array("carrierNameCn" => $cn_name, "carrierNameEn" => $en_name, "carrierAli" => $ship_ali, "carrierAbb" => $ship_abb, "carrierLogo" => $ship_logo, "carrierIndex" => $ship_index, "plat_arr" => $plat_arr, "type" => $ship_type, "ship_add" => $ship_add, "weightMin" => $min_weight, "weightMax" => $max_weight, "timecount" => $ship_day, "note" => $ship_note, "createdTime" => time(), "is_track" => $is_track);
         $carrierObj = new CarrierManageAct();
         $res = $carrierObj->actAddCarrierManage($data);
         if ($res) {
             $errMsg = "添加成功!";
         }
     }
     $this->smarty->assign('title', '添加运输方式结果');
     $this->smarty->assign('errMsg', $errMsg);
     $this->smarty->display('carrierManageAdd.htm');
 }