public function actionSaveCall() { $user = User::model()->find('id=:id', array(':id' => Yii::app()->user->id)); $user_name = $user['first_name'] . ' ' . $user['last_name']; $id = $_POST['id']; $comment = $_POST['comment']; $post = Carrier::model()->findByPk($id); $post->Comment = $comment . '( ' . $user_name . ')'; $post->Last_Activity_Date = date('Y-m-d'); $post->save(); $reports = new UserReports(); $reports->client_id = (int) $id; $reports->user_id = (int) Yii::app()->user->id; $reports->action = 1; $reports->comment = $comment; $reports->date = date('Y-m-d'); $reports->save(); $model = new Carrier('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['Carrier'])) { $model->attributes = $_GET['Carrier']; } $this->render('admin', array('model' => $model)); }
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)); } }