public function actionChngShiping() { $id = $_GET['id']; $carrier_id = $_GET['carrier_name']; $carrier_name = $_GET['carrier_id']; $Shipping = new Shipping(); $item = $Shipping->GetShipping($id); if (!empty($item['carriers_id'])) { $carriers_id_arr = explode(', ', $item['carriers_id']); array_push($carriers_id_arr, $carrier_id); $res = array_unique($carriers_id_arr); $final_carriers_id = implode(', ', $res); } else { $final_carriers_id = $carrier_id; } if (!empty($item['carrier_name'])) { $carriers_name_arr = explode('|', $item['carrier_name']); array_push($carriers_name_arr, $carrier_id); $res = array_unique($carriers_name_arr); $final_carriers_name = implode('|', $res); } else { $final_carriers_name = $carrier_name; } $post = Shipping::model()->findByPk($id); $post->carriers_id = $final_carriers_id; $post->carrier_name = $final_carriers_name; // $Shipping->route = $item['route']; // $Shipping->comment = $item['comment']; $r = $post->save(); // var_dump($post->errors);die; }
public function actionChngShiping() { $id = $_GET['id']; $carrier_name = $_GET['carrier_name']; $carrier_id = $_GET['carrier_id']; $route = $_GET['route']; $Shipping = new Shipping(); $items = $Shipping->GetShipping($id); $item = $items[0]; if (!empty($item['carriers_id'])) { $carriers_id_arr = explode(', ', $item['carriers_id']); array_push($carriers_id_arr, $carrier_id); $result = array_unique($carriers_id_arr); $final_carriers_id = implode(', ', $result); } else { $final_carriers_id = $carrier_id; } if (!empty($item['carrier_name'])) { $carriers_name_arr = explode('|', $item['carrier_name']); array_push($carriers_name_arr, $carrier_name); $res = array_unique($carriers_name_arr); $final_carriers_name = implode('|', $res); } else { $final_carriers_name = $carrier_name; } $post = Shipping::model()->findByPk($id); $post->carriers_id = $final_carriers_id; $post->carrier_name = $final_carriers_name; $post->save(); if ($post->save()) { $car = $Shipping->getCarrier($carrier_id); $carrier = $car[0]; if (!empty($carrier['Direction'])) { $carriers_Direction_arr = explode(' | ', $carrier['Direction']); array_push($carriers_Direction_arr, $route); $carr = array_unique($carriers_Direction_arr); $final_route = implode(' | ', $carr); } else { $final_route = $route; } if (!empty($carrier['Direction_id'])) { $carriers_Direction_id_arr = explode(', ', $carrier['Direction_id']); array_push($carriers_Direction_id_arr, $id); $carrid = array_unique($carriers_Direction_id_arr); $final_id = implode(', ', $carrid); } else { $final_id = $id; } $Carrier = Carrier::model()->findByPk($carrier_id); $Carrier->Direction = $final_route; $Carrier->Direction_id = $final_id; $Carrier->save(); // var_dump($Carrier->errors);die; $this->redirect(array('view', 'id' => $post->id)); } }