public function postSavestation() { $station = new Station(); $station->district_id = Input::get('district_id'); $station->name = Input::get('name'); $station->code = Input::get('code'); $station->save(); return Response::json($station); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Station(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Station'])) { $model->attributes = $_POST['Station']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Create a station within a country * * @access public * @param int $id (country id) * @return void */ public function create() { $station = new Station(); if ($this->input->post("device_id")) { $station->populate($this->input->post()); if ($station->save()) { Notification::set(Stations::SUCCESS, "The station has been added"); redirect("/stations/"); } } $this->data["regions"] = (new Region())->load(); $this->data["station"] = $station; $this->load->view("stations/create", $this->data); }
public function actionStationSave() { $form = Station::model()->findByPk(isset($_REQUEST['station_id']) ? intval($_REQUEST['station_id']) : null); if (is_null($form)) { $form = new Station(); $form->communication_type = 'direct'; $form->station_gravity = array_shift(array_keys(\yii::app()->params['station_gravity'])); } $form->wmo_block_number = $form->wmo_block_number > 0 ? $form->wmo_block_number : ''; $form->wmo_member_state_id = $form->wmo_member_state_id > 0 ? $form->wmo_member_state_id : ''; $form->national_aws_number = $form->national_aws_number > 0 ? $form->national_aws_number : ''; if (Yii::app()->request->isPostRequest && isset($_POST['Station'])) { $form->attributes = $_POST['Station']; if ($form->save()) { It::memStatus($form->isNewRecord ? 'station_added' : 'station_updated'); $this->redirect($this->createUrl('admin/StationSave', array('station_id' => $form->station_id))); } } $this->render('station_save', array('form' => $form, 'comports_list' => SysFunc::getAvailableComPortsList())); }
/** * @param $stationParamsArray array */ protected function stationAdd($stationParamArray) { $station = new Station(); unset($stationParamArray['station_id']); unset($stationParamArray['created']); unset($stationParamArray['updated']); $station->attributes = $stationParamArray; $station->save(); $station_id = $station->getPrimaryKey(); $this->stations[] = $station; return $station_id; }
/** * put your comment there... * * @param mixed $stationInformationArray */ private function _addStation($stationInformationArray) { $fiedsList = array('f_station_code', 'f_date', 'f_dev_id', 'f_name', 'f_descr', 'f_info', 'f_uid', 'f_status', 'f_create_time', 'f_master_name', 'f_date_min', 'f_date_max', 'f_date_last_down', 'f_date_sens', 'f_date_data', 'f_date_conf', 'f_measure_int', 'f_data_int', 'f_timezone', 'f_latitude', 'f_longitude', 'f_altitude', 'f_hw_ver_major', 'f_hw_ver_minor', 'f_sw_ver_major', 'f_sw_ver_minor', 'f_sms_warn_numbers', 'f_sms_warn_values', 'f_gsm_mcc', 'f_gsm_mnc', 'f_gprs_apn', 'f_gprs_user_id', 'f_gprs_passw', 'f_sernum', 'f_date_comm', 'f_user_station_name', 'f_user_name', 'custom_name', 'custom_desc', 'custom_image', 'enable_station', 'show_in_home', 'priority', 'last_editor'); foreach ($fiedsList as $key) { if (!isset($stationInformationArray->{$key})) { $stationInformationArray->{$key} = NULL; } else { switch ($key) { case 'f_latitude': case 'f_longitude': if (!empty($stationInformationArray->{$key})) { $stationInformationArray->{$key} = recoverLatLongData($stationInformationArray->{$key}, str_replace("f_", "", $key)); } break; default: break; } } } $newStation = new Station(null, $stationInformationArray->f_station_code, $stationInformationArray->f_date, $stationInformationArray->f_dev_id, $stationInformationArray->f_name, $stationInformationArray->f_descr, $stationInformationArray->f_info, $stationInformationArray->f_uid, $stationInformationArray->f_status, $stationInformationArray->f_create_time, $stationInformationArray->f_master_name, $stationInformationArray->f_date_min, $stationInformationArray->f_date_max, $stationInformationArray->f_date_last_down, $stationInformationArray->f_date_sens, $stationInformationArray->f_date_data, $stationInformationArray->f_date_conf, $stationInformationArray->f_measure_int, $stationInformationArray->f_data_int, $stationInformationArray->f_timezone, $stationInformationArray->f_latitude, $stationInformationArray->f_longitude, $stationInformationArray->f_altitude, $stationInformationArray->f_hw_ver_major, $stationInformationArray->f_hw_ver_minor, $stationInformationArray->f_sw_ver_major, $stationInformationArray->f_sw_ver_minor, $stationInformationArray->f_sms_warn_numbers, $stationInformationArray->f_sms_warn_values, $stationInformationArray->f_gsm_mcc, $stationInformationArray->f_gsm_mnc, $stationInformationArray->f_gprs_apn, $stationInformationArray->f_gprs_user_id, $stationInformationArray->f_gprs_passw, $stationInformationArray->f_sernum, $stationInformationArray->f_date_comm, $stationInformationArray->f_user_station_name, $stationInformationArray->f_user_name, $custom_name = null, $custom_desc = null, $custom_image = null, 1, $stationInformationArray->f_latitude && $stationInformationArray->f_longitude ? 1 : 0, $priority = null, $last_update_date = null, $last_edition_time = null, $last_editor = null); if ($newStation->save()) { return $stationInformationArray->f_name . " added"; } else { return $stationInformationArray->f_name . " ERROR SAVING DATA"; } }