public function actionAdd() { $model = new Destination; if(isset($_POST['Destination'])){ $model->attributes = $_POST['Destination']; $model->createtime = time(); if($model->save()){ $this->redirect(array('list')); } } $this->render('add',array( 'model'=>$model, )); }
foreach ($focus->column_fields as $field) { if (isset($_POST[$field])) { $value = $_POST[$field]; $focus->{$field} = $value; } } foreach ($focus->additional_column_fields as $field) { if (isset($_POST[$field])) { $value = $_POST[$field]; $focus->{$field} = $value; } } if (!empty($this->uploadfile)) { $this->picture = $this->uploadfile; } $focus->save($check_notify); $return_id = $focus->id; if (!empty($_POST['uploadfile'])) { $file_name = $_FILES['uploadfile']['name']; $ext = explode('.', $file_name); $img_ext = $ext[count($ext) - 1]; $image_extension = 'jpg_jpeg_gif_bmp_png'; $image_extension_arr = explode('_', $image_extension); for ($i = 0; $i < count($image_extension_arr); $i++) { if ($img_ext != $image_extension_arr[$i]) { echo "<script language='javascript'> alert('file ảnh không hợp lệ'); </script>"; } } move_uploaded_file($_FILES['uploadfile']['tmp_name'], 'modules/images/' . $_FILES['uploadfile']['tmp_name']); } handleRedirect($return_id, 'Destinations');
public function actionNewdestination() { if (isset($_POST['Destination'])) { $obj = new Destination(); $obj->attributes = $_POST['Destination']; if ($obj->validate()) { if ($obj->country == "0") { $obj->country = null; } if ($obj->country == "") { $obj->country = null; } if ($obj->state == "0") { $obj->state = null; } if ($obj->state == "") { $obj->state = null; } if ($obj->save()) { echo "success"; } else { echo print_r($obj->getErrors, true); } } else { echo print_r($obj->getErrors, true); } } }
public static function VerifyAnyDestination() { $objAnyDest = Destination::model()->findByAttributes(array('country' => null, 'state' => null)); if (!$objAnyDest instanceof Destination) { $objTax = TaxCode::GetNoTaxCode(); if ($objTax) { $objNewAny = new Destination(); $objNewAny->country = null; $objNewAny->state = null; $objNewAny->zipcode1 = ''; $objNewAny->zipcode2 = ''; $objNewAny->taxcode = $objTax->lsid; $objNewAny->save(); } } }