public function actionIndex() { $this->htmlOption = array('class' => 'icon-head head-products', 'header' => "货运设置", 'button' => array(array('class' => 'scalable save', 'id' => 'form-save', 'header' => '保存'))); $carrier = $this->loadModel(); if ($_POST['SHIPPING']) { configuration::updateItems($_POST['SHIPPING']); } if ($_POST['feeAdd']) { foreach ($_POST['feeAdd'] as $key => $row) { if ($row != 0) { $arr = explode('-', $key); $delivery = new delivery(); $delivery->carrier_ID = $_POST['carrier_ID']; $delivery->zone_ID = $arr[0]; $delivery->weight_range_ID = $arr[1]; $delivery->price = $row; $delivery->save(); } } } if ($_POST['feeUpdate']) { foreach ($_POST['feeUpdate'] as $key => $row) { $delivery = delivery::model()->findByPk($key); if ($row != 0 && $row != $delivery->price) { $delivery->price = $row; $delivery->save(); } else { if ($row == 0) { $delivery->delete(); } } } } $config = configuration::item('SHIPPING', 'SHIPPING_FREE_PRICE'); $this->constructScript('index'); $this->render('index', array('config' => $config, 'carrier' => $carrier)); }