/** * 箱子颜色表插入一条记录 * @param array $data * @return number $insertId * @author czq */ public static function insertWaveBoxColorRow($data) { self::initDB(); $sql = "INSERT INTO " . self::$tablename . " SET " . array2sql($data); $query = self::$dbConn->query($sql); if ($query) { $insertId = self::$dbConn->insert_id(); return $insertId; } else { self::$errCode = "003"; self::$errMsg = "error"; return false; } }
/** * 箱子颜色处理逻辑 * @return boolean * @author czq */ public function act_waveColorEdit() { $sameZoneColor = isset($_POST['sameZoneColor']) ? $_POST['sameZoneColor'] : ''; $crossZoneColor = isset($_POST['crossZoneColor']) ? $_POST['crossZoneColor'] : ''; $crossStoreyColor = isset($_POST['crossStoreyColor']) ? $_POST['crossStoreyColor'] : ''; TransactionBaseModel::begin(); $waveColors = WhWaveColorModel::getWaveBoxColor(); //已经存在数据,直接更新 if (!empty($waveColors)) { foreach ($waveColors as $wave) { if ($wave['waveZone'] == 1) { $color = $sameZoneColor; } else { if ($wave['waveZone'] == 2) { $color = $crossZoneColor; } else { if ($wave['waveZone'] == 3) { $color = $crossStoreyColor; } } } $updateData = array('color' => $color); if (!WhWaveColorModel::updateWaveBoxColor($updateData, 'AND id = ' . $wave['id'])) { self::$errCode = 102; self::$errMsg = "更新数据失败"; TransactionBaseModel::rollback(); return false; } } } else { $insertData = array(array('waveZone' => 1, 'color' => $sameZoneColor), array('waveZone' => 2, 'color' => $crossZoneColor), array('waveZone' => 3, 'color' => $crossStorey)); foreach ($insertData as $data) { $insertId = WhWaveColorModel::insertWaveBoxColorRow($data); if (!$insertId) { self::$errCode = 101; self::$errMsg = "数据插入失败"; TransactionBaseModel::rollback(); return false; } } } TransactionBaseModel::commit(); self::$errCode = 200; self::$errMsg = "数据更新成功"; return true; }
public function view_edit() { $toplevel = 4; $secondlevel = 47; $messagetype = 0; //前端提示信息显示类型 $type = isset($_POST['editType']) ? $_POST['editType'] : ''; if (!empty($type)) { $waveEdit = A("whWaveEdit"); if ($type == 'waveBoxColor') { $waveEdit->act_waveColorEdit(); $boxmessage = $waveEdit::$errMsg; $messagetype = $waveEdit::$errCode; $this->smarty->assign('boxmessage', $boxmessage); } else { if ($type == 'waveAllocation') { $waveEdit->act_waveAllocation(); } } } $boxColors = array('蓝', '黄', '红', '绿', '紫'); $this->smarty->assign('messagetype', $messagetype); $this->smarty->assign('boxColors', $boxColors); //获取箱子颜色 $waveColors = WhWaveColorModel::getWaveBoxColor(); foreach ($waveColors as $wave) { if ($wave['waveZone'] == 1) { $this->smarty->assign('sameZoneColor', $wave['color']); } else { if ($wave['waveZone'] == 2) { $this->smarty->assign('crossZoneColor', $wave['color']); } else { if ($wave['waveZone'] == 3) { $this->smarty->assign('crossStoreyColor', $wave['color']); } } } } // 获取波次配置信息 $waveConfigs = WhWaveConfigModel::getWaveConfig(); foreach ($waveConfigs as $waveConfig) { if ($waveConfig['waveType'] == 1) { if ($waveConfig['limitType'] == 1) { //单个发货单 $this->smarty->assign('singleInvoice', $waveConfig); } else { if ($waveConfig['limitType'] == 2) { //单个发货单每个波次拆分 $this->smarty->assign('singleInvoiceSplit', $waveConfig); } else { if ($waveConfig['limitType'] == 3) { //单个发货单拆分起点 $this->smarty->assign('singleInvoiceSplitEach', $waveConfig); } } } } else { if ($waveConfig['waveType'] == 2) { //单SKU $this->smarty->assign('singleSku', $waveConfig); } else { if ($waveConfig['waveType'] == 3) { //多SKU $this->smarty->assign('skus', $waveConfig); } } } } $toptitle = '波次设置'; $this->smarty->assign('toptitle', $toptitle); $this->smarty->assign('toplevel', $toplevel); $this->smarty->assign('secondlevel', $secondlevel); $this->smarty->display('whWaveEdit.htm'); }
/** * WaveInfoManageView::get_color_config() * 获取箱子颜色配置 * @return void */ public function get_color_config() { $color_info = WhWaveColorModel::getWaveBoxColor(); $return = array(); if (!empty($color_info)) { foreach ($color_info as $color) { $return[$color['waveZone']] = $color['color']; } } unset($color_info); return $return; }