public function actionCreate() { $model = new Program(); if (isset($_POST['Program'])) { $model->setAttributes($_POST['Program']); if ($model->save()) { if (Yii::app()->getRequest()->getIsAjaxRequest()) { Yii::app()->end(); } else { $this->redirect(array('view', 'id' => $model->id)); } } } $this->render('create', array('model' => $model)); }
public function store() { $daterange = explode('-', Input::get('range')); $start_date = trim($daterange[0]); $end_date = trim($daterange[1]); $program = new Program(); $program->project_id = Auth::user()->curr_project_id; $program->location_id = Auth::user()->location_id; $program->name = Input::get('name'); $program->description = Input::get('description'); $program->start_date = date('Y-m-d', strtotime($start_date)); $program->end_date = date('Y-m-d', strtotime($end_date)); $program->save(); Session::flash('message', 'Sukses membuka program baru!'); }
public function postProgram() { $validator = Validator::make(Input::all(), Program::$rules); if ($validator->passes()) { $program = new Program(); $program->name = Input::get('name'); $program->category_id = Input::get('category_id'); $program->classification = Input::get('classification'); $program->audience_id = Input::get('audience_id'); $program->language_id = Input::get('language_id'); $program->save(); return Response::json($program); } else { return 0; } }
/** * Store a newly created resource in storage. * POST /program * * @return Response */ public function store() { //get current club $user = Auth::user(); $club = $user->Clubs()->FirstOrFail(); $uuid = Uuid::generate(); $validator = Validator::make(Input::all(), Program::$rules); if ($validator->passes()) { $program = new Program(); $program->id = $uuid; $program->name = Input::get('name'); $program->club_id = $club->id; $program->user_id = $user->id; $program->description = Input::get('description'); $status = $program->save(); if ($status) { return Redirect::action('ProgramController@index')->with('messages', 'Program created successfully'); } } $error = $validator->errors()->all(':message'); return Redirect::action('ProgramController@create')->withErrors($validator)->withInput(); }
public function actionInsertProgram() { Yii::app()->user->returnUrl = Yii::app()->request->urlReferrer; if ($_POST) { // $cek = DatabaseUmum::cekExist("program","nama_program",$_POST['namaTP']); // cek menggunakan component DatabaseUmum $cek = DatabaseUmum::cekExist2('program', 'nama_program', 'tahun_anggaran', $_POST['namaTP'], $_POST['tahunTP']); if ($cek <= 0) { $program = new Program(); $program->nama_program = $_POST['namaTP']; $program->kode_program = $_POST['kodeTP']; $program->target = $_POST['targetTP']; $program->tahun_anggaran = $_POST['tahunTP']; $program->id_rekaman = 0; if ($program->validate()) { $program->save(); // echo $program->nama_program; $this->redirect(array('index')); } else { Yii::app()->user->setFlash('error', 'Maaf, simpan Program gagal. Mohon periksa kembali data yang anda inputkan'); $this->redirect(array('/errPage/errDB')); } } else { Yii::app()->user->setFlash('error', 'Maaf, simpan Program gagal. Data sudah ada'); $this->redirect(array('/errPage/errDB')); } } else { $this->actionIndex(); } }