public function actionUpdateBulkStatus() { $new_event = new ShipmentEvent('bulkinsert'); $failed = array(); $success = array(); if (isset($_POST['ShipmentEvent'])) { $new_event->setAttributes($_POST['ShipmentEvent']); if ($new_event->validate()) { $rawsAwb = nl2br($new_event->shipment_list); $arrAwb = explode('<br />', $rawsAwb); foreach ($arrAwb as $awb) { $awb = trim($awb); $shipment = Shipment::model()->findByAttributes(array('awb' => $awb)); if ($shipment instanceof Shipment) { array_push($success, $awb); // CVarDumper::dump($success,10,true); $event = new ShipmentEvent(); $event->setAttributes($_POST['ShipmentEvent']); $event->setAttribute('shipment_id', $shipment->id); $shipment->shipping_status = $event->status; $shipment->shipping_remark = $event->remark; $shipment->recipient_name = $event->recipient_name; $shipment->recipient_title = $event->recipient_title; $shipment->event_time = strtotime($event->event_time); if (isset($event->recipient_date)) { $shipment->recipient_date = strtotime($event->recipient_date); } $shipment->setScenario('event'); $event->save(); $shipment->save(); } else { array_push($failed, $awb); } if (count($success) != 0) { $list_success = implode(', ', $success); Yii::app()->user->setFlash('success', 'Success : ' . $list_success); } if (count($failed) != 0) { $list_failed = implode(', ', $failed); Yii::app()->user->setFlash('error', 'Failed : ' . $list_failed); } } } } $this->render('updateBulk', array('new_event' => $new_event)); }