public function actionAdd() { global $arr_response; $model = new Subject(); $model->scenario = 'add'; $_REQUEST['content_type_id'] = ContentType::model()->find('name=:name', array(':name' => $_REQUEST['content_type']))->id; $_REQUEST['country_id'] = Country::model()->find('code=:code', array(':code' => $_REQUEST['country_code']))->id; $_REQUEST['priority_id'] = Priority::model()->find('name=:name', array(':name' => $_REQUEST['priority']))->id; if ($_REQUEST['time']) { if (date("l", $_REQUEST['time'])) { //if its a valid timestamp $_REQUEST['user_position_ymd'] = date("Y", $_REQUEST['time']) . "/" . date("m", $_REQUEST['time']) . "/" . date("d", $_REQUEST['time']); $_REQUEST['user_position_hour'] = date("H", $_REQUEST['time']); $_REQUEST['user_position_minute'] = date("i", $_REQUEST['time']); } } else { $_REQUEST['user_position_anydatetime'] = 1; } $model->attributes = $_REQUEST; //NOTICE that we are creating a new record, so model its not loaded, ($model->content_type its juest the received $_REQUEST parameter) //print_r($model); //$model->content_type_id = $content_type->id; if ($model->save()) { $arr_response['response_message'] = Yii::t('subject', 'Subject successfully saved.'); } else { $arr_response['response_code'] = 409; $arr_response['response_message'] = Yii::t('subject', 'Subject could not be saved.'); $arr_response['response_details'] = $model->getErrors(); } }
public function store() { $subject = new Subject(); $subject->name = Input::get('name'); $subject->save(); Session::flash('message', 'Sukses menambahkan bidang studi baru!'); }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { $rules = ['name' => 'required', 'code' => 'required', 'type' => 'required', 'subgroup' => 'required', 'stdgroup' => 'required', 'class' => 'required', 'totalfull' => 'required', 'wfull' => 'required', 'mfull' => 'required', 'sfull' => 'required', 'pfull' => 'required']; $validator = \Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('/subject/create')->withErrors($validator); } else { $exsubject = Subject::select('*')->where('class', Input::get('class'))->where('code', Input::get('code'))->get(); if (count($exsubject) > 0) { $errorMessages = new Illuminate\Support\MessageBag(); $errorMessages->add('deplicate', 'subject all ready exists for this class!!'); return Redirect::to('/subject/create')->withErrors($errorMessages); } else { $subject = new Subject(); $subject->name = Input::get('name'); $subject->code = Input::get('code'); $subject->class = Input::get('class'); $subject->type = Input::get('type'); $subject->subgroup = Input::get('subgroup'); $subject->stdgroup = Input::get('stdgroup'); $subject->totalfull = Input::get('totalfull'); $subject->totalpass = Input::get('totalpass'); $subject->wfull = Input::get('wfull'); $subject->wpass = Input::get('wpass'); $subject->mfull = Input::get('mfull'); $subject->mpass = Input::get('mpass'); $subject->sfull = Input::get('sfull'); $subject->spass = Input::get('spass'); $subject->pfull = Input::get('pfull'); $subject->ppass = Input::get('ppass'); $subject->save(); return Redirect::to('/subject/create')->with("success", "Subject Created Succesfully."); } } }
/** * 录入 * */ public function actionCreate() { parent::_acl('subject_create'); $model = new Subject(); $imageList = $this->_gets->getPost('imageList'); $layoutList = $this->_gets->getPost('layoutList'); $imageListSerialize = XUtils::imageListSerialize($imageList); $layoutListSerialize = XUtils::imageListSerialize($layoutList); if (isset($_POST['Subject'])) { $file = XUpload::upload($_FILES['attach']); $model->attributes = $_POST['Subject']; $model->date = strtotime($_POST['Subject']['date']); if (is_array($file)) { $model->room_type_image = $file['pathname']; } $model->image_list = $imageListSerialize['dataSerialize']; $model->layout_list = $layoutListSerialize['dataSerialize']; if ($model->save()) { AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入项目,ID:' . $model->id)); $this->redirect(array('index')); } } $this->city_list = parent::_groupList('city'); $this->render('create', array('model' => $model, 'imageList' => $imageListSerialize['data'], 'layoutList' => $layoutListSerialize['data'])); }
/** * Run the database seeds. * * @return void */ public function run() { Eloquent::unguard(); DB::table('propel_fellow_wingman')->delete(); DB::table('propel_student_wingman')->delete(); Subject::truncate(); DB::table('propel_city_subject')->delete(); CalendarEvent::truncate(); CancelledCalendarEvent::truncate(); WingmanModule::truncate(); WingmanTime::truncate(); VolunteerTime::truncate(); WingmanJournal::truncate(); $fellow = Fellow::find(1); $wingman1 = Wingman::find(2); $wingman2 = Wingman::find(3); $fellow->wingman()->attach($wingman1); $fellow->wingman()->attach($wingman2); $student1 = Student::find(3); $student2 = Student::find(4); $wingman1->student()->attach($student1); $wingman1->student()->attach($student2); $cEvent1 = new CalendarEvent(); $cEvent1->type = 'volunteer_time'; $cEvent1->student()->associate($student1); $cEvent1->status = 'created'; $cEvent1->save(); $vTime1 = new VolunteerTime(); $vTime1->calendarEvent()->associate($cEvent1); $volunteer1 = Volunteer::find(4); $vTime1->volunteer()->associate($volunteer1); $subject1 = new Subject(); $subject1->name = "English"; $subject1->save(); $vTime1->subject()->associate($subject1); $vTime1->save(); $cEvent2 = new CalendarEvent(); $cEvent2->type = 'wingman_time'; $cEvent2->student()->associate($student1); $cEvent2->status = 'created'; $cEvent2->save(); $wTime1 = new WingmanTime(); $wTime1->calendarEvent()->associate($cEvent2); $wTime1->wingman()->associate($wingman1); $wModule1 = new WingmanModule(); $wModule1->name = "Programming"; $wModule1->save(); $wTime1->wingmanModule()->associate($wModule1); $wTime1->save(); $city1 = City::find(1); $subject1->city()->attach($city1); $wJournal1 = new WingmanJournal(); $wJournal1->type = 'formal'; $wJournal1->title = "Day at Navy Camp"; $wJournal1->mom = "It was awesome"; $wJournal1->student()->associate($student1); $wJournal1->wingman()->associate($wingman1); $wJournal1->save(); }
private function create() { $subject = new Subject(); $subject->subjectname = Input::get('name'); $subject->subjectcode = Input::get('code'); $subject->grade = Input::get('grade'); $subject->save(); }
/** * Создает новую модель Предмета. * Если создание прошло успешно - перенаправляет на просмотр. * * @return void */ public function actionCreate() { $model = new Subject(); if (Yii::app()->getRequest()->getPost('Subject') !== null) { $model->setAttributes(Yii::app()->getRequest()->getPost('Subject')); if ($model->save()) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('SubjectModule.subject', 'Запись добавлена!')); $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id])); } } $this->render('create', ['model' => $model]); }
public function save() { $subjectId = $this->getValue('subjectId'); if (!empty($subjectId)) { $subject = $this->getSubjectService()->getSubjectById($subjectId); } else { $subject = new Subject(); } $subject->setCode($this->getValue('code')); $subject->setName($this->getValue('name')); $subject->save(); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Subject(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Subject'])) { $model->attributes = $_POST['Subject']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Создает новую модель Предмета. * Если создание прошло успешно - перенаправляет на просмотр. * * @return void */ public function actionCreate() { $roles = ['1', '5', '4']; $role = \Yii::app()->user->role; if (array_intersect($role, $roles)) { $model = new Subject(); if (Yii::app()->getRequest()->getPost('Subject') !== null) { $model->setAttributes(Yii::app()->getRequest()->getPost('Subject')); if ($model->save()) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('SubjectModule.subject', 'Запись добавлена!')); $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id])); } } $this->render('create', ['model' => $model]); } else { throw new CHttpException(403, 'Ошибка прав доступа.'); } }
/** * Store a subject in the Subject collection * * @return View */ public function addSubject() { $subject = new Subject(); $subject->name = strtoupper(trim(Input::get('subject_name'))); $subject->university_id = Auth::id(); $subject->school = strtoupper(trim(Input::get('school'))); $sections = explode(',', Input::get('section')); foreach ($sections as $section) { $sect = new Section(); $sect->code = strtoupper(trim($section)); $sect->is_free = true; $subject->sections()->associate($sect); } try { $subject->save(); } catch (MongoDuplicateKeyException $e) { return Redirect::back()->withErrors(array('error' => Lang::get('add_subject.subject_duplicated'))); } return Redirect::to(Lang::get('routes.add_subject'))->with('message', Lang::get('add_subject.success')); }
public function executeUpdate() { $i18n = new sfI18N(); $i18n->initialize($this->getContext()); $i18n->setCulture($this->getUser()->getCulture()); $action_i18n = $i18n->globalMessageFormat->format('save as new'); $action_type = $this->getRequestParameter('action_type'); if ($action_type == $action_i18n || !$this->getRequestParameter('id')) { $subject = new Subject(); $subject->setCode($this->getRequestParameter('code')); $subject->setName($this->getRequestParameter('name')); $subject->setCredit($this->getRequestParameter('credit')); $subject->setSubjectGroupId($this->getRequestParameter('subject_group_id')); $subject->setDepartmentId($this->getRequestParameter('department_id')); $subject->save(); #$subject_curr = new SubjectCurr(); #$subject_curr->setSubject($subject); #$subject_curr->setCurriculumId($this->getRequestParameter('curriculum_id')); #$subject_curr->save(); #$c = new Criteria(); #$c->add(AcademicCalendarPeer::CURRICULUM_ID, $this->getRequestParameter('curriculum_id')); #$currs = AcademicCalendarPeer::doSelect($c); #foreach ($currs as $curr) { # $subject_accal = new SubjectAccal(); # $subject_accal->setSubject($subject); # $subject_accal->setAcademicCalendarId($curr->getId()); # $subject_accal->setEmployeeId($this->getRequestParameter('employee_id')); # $subject_accal->save(); # $subject_accal_lector = new SubjectAccalLector(); # $subject_accal_lector->setSubjectAccal($subject_accal); # $subject_accal_lector->setEmployeeId($this->getRequestParameter('employee_id')); # $subject_accal_lector->save(); #} $subject_accal = new SubjectAccal(); $subject_accal->setSubject($subject); $subject_accal->setAcademicCalendarId($this->getRequestParameter('academic_calendar_id')); $subject_accal->setEmployeeId($this->getRequestParameter('employee_id')); $subject_accal->save(); #$subject_accal_lector = new SubjectAccalLector(); #$subject_accal_lector->setSubjectAccal($subject_accal); #$subject_accal_lector->setEmployeeId($this->getRequestParameter('employee_id')); #$subject_accal_lector->save(); } else { $subject = SubjectPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($subject); $subject->setId($this->getRequestParameter('id')); $subject->setCode($this->getRequestParameter('code')); $subject->setName($this->getRequestParameter('name')); $subject->setCredit($this->getRequestParameter('credit')); $subject->setSubjectGroupId($this->getRequestParameter('subject_group_id')); $subject->setDepartmentId($this->getRequestParameter('department_id')); $subject->save(); $c = new Criteria(); $c->add(SubjectAccalPeer::ID, $this->getRequestParameter('subject_accal_id')); $subject_accal = SubjectAccalPeer::doSelectOne($c); #$subject_accal = SubjectAccalPeer::retrieveByPk($this->getRequestParameter('subject_accal_id')); #$this->forward404Unless($subject_accal); $subject_accal->setId('subject_accal_id'); $subject_accal->setSubject($subject); $subject_accal->setAcademicCalendarId($this->getRequestParameter('academic_calendar_id')); $subject_accal->setEmployeeId($this->getRequestParameter('employee_id')); $subject_accal->save(); } return $this->redirect('subject/list'); }
</select> </div> </fieldset> <fieldset class="buttons"> <button type="reset">reset</button> <button type="submit" name="stage" value="2">submit</button> </fieldset> </form> </div>'; break; case "2": $subject = new Subject("00000", $_POST["code"], $_POST["name"], $_POST["description"], $_POST["startYear"], $_POST["stopYear"]); if ($subject->validate()) { if ($subject->save()) { $pageBody .= ' <table> <tbody> <tr> <th>code</th> <td>' . $subject->getCode() . '</td> </tr> <tr> <th>name</th> <td>' . $subject->getName() . '</td> </tr> <tr> <th>description</th> <td>' . $subject->getDescription() . '</td> </tr>
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionAjaxCreate() { $model = new Subject(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Subject'])) { $model->attributes = $_POST['Subject']; if ($model->save()) { $this->redirect(array('index', 'id' => $model->ID)); } } $this->renderPartial('_form', array('model' => $model), false, true); }
<?php require_once '../../includes/initialize.php'; ?> <?php selected_page(); if (isset($_POST['submit'])) { $new_subject = new Subject(); $new_subject->menu_name = trim($_POST['menu_name']); $new_subject->visible = (int) trim($_POST['visible']); $new_subject->position = (int) trim($_POST['position']); if ($new_subject->save()) { $message = "New Subject Added"; } else { $message = "Failed to Add New Subject"; } } include_layout_template("admin_header"); ?> <nav> <br> <a href="index.php">« Back</a> <br> <?php echo navigation($current_subject, $current_page); ?> </nav> <div class="page">
$sql = "SELECT id FROM subjects WHERE id=?"; $data = array($id); $query = $db->prepare($sql); if ($query->execute($data)) { while ($row = $query->fetch()) { $current_subject = new Subject(); $current_subject->load($row['id']); echo $current_subject->display_subject(); } } break; case "new_subject": $new_subject = new Subject(); $new_subject->subject_type_id = $_POST['subject_type_id']; $new_subject->name = $_POST['name']; $new_subject->save(); echo "Saved."; break; case "edit_subject": $current_subject = new Subject(); $current_subject->load($_POST['subject_id']); $current_subject->name = $_POST['name']; $current_subject->subject_type_id = $_POST['subject_type_id']; $current_subject->update(); echo "saved."; break; case "delete_subject": $current_subject = new Subject(); $current_subject->load($_POST['subject_id']); $current_subject->delete(); echo "deleted";
public function add() { $tabla = Input::get('tabla'); switch ($tabla) { case '0': $clave = Input::get('clave'); $appat = Input::get('ap_pat'); $apmat = Input::get('ap_mat'); $nombre = Input::get('nombre'); $segnombre = Input::get('seg_nombre'); $tipo = Input::get('tipo'); $grado = Input::get('grado'); $tutorias = Input::get('tutorias'); $gestion = Input::get('gestion'); $invest = Input::get('invest'); $depend = Input::get('depend'); $add = new Professor(); $add->clave = $clave; $add->ap_pat = $appat; $add->ap_mat = $apmat; $add->nombre = $nombre; $add->seg_nombre = $segnombre; $add->tipo = $tipo; $add->id_grado = $grado; $add->tutorias = $tutorias; $add->gestion = $gestion; $add->investigacion = $invest; $add->dependencias = $depend; $add->save(); return View::make('crud.crudMaestros')->with('professors', Professor::all()); break; case '1': $nombre = Input::get('nombre'); $semestre = Input::get('semestre'); $plan = Input::get('idPlan'); $add = new Subject(); $add->nombre = $nombre; $add->semestre = $semestre; $add->id_plan = $plan; $add->save(); return View::make('crud.crudMaterias')->with('subjects', Subject::all()); break; case '2': $nombre = Input::get('nombre'); $add = new Aula(); $add->nombre = $nombre; $add->save(); return View::make('crud.crudAulas')->with('aulas', Aula::all()); break; case '3': $nombre = Input::get('nombre'); $add = new Plan(); $add->nombre = $nombre; $add->save(); return View::make('crud.crudPlanes')->with('plans', Plan::all()); break; default: //aqui me redirecciona a una pagina vacia solo con un mensaje 404 return View::make('landing'); break; } }
/** * Update the specified resource in storage. * PUT /backend\puskice\subject/{id} * * @param int $id * @return Response */ public function postUpdate($id) { if (Session::get('user_level') < Config::get('cms.createPage')) { return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning'); } $rules = array('title' => 'Required', 'shortContent' => 'Required', 'createdAt' => 'Required', 'publishedBy' => 'Required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to(_l(URL::action('SubjectController@getEdit') . "/" . $id))->withErrors($validator)->withInput(); } else { try { $news = News::findOrFail($id); $news->title = Input::get('title'); if (!Input::get('permalink')) { $news->permalink = slugify(Input::get('title')); } else { $news->permalink = slugify(Input::get('permalink')); } if (Input::get('createdAt')) { $news->created_at = date("Y-m-d H:i:s", strtotime(Input::get('createdAt'))); } else { $news->created_at = date("Y-m-d H:i:s", strtotime('now')); } $news->short_content = Input::get('shortContent'); if (!Input::get('longContent')) { $news->long_content = Input::get('shortContent'); } else { $news->long_content = Input::get('longContent'); } $news->featured = 0; $news->last_modified_by = Session::get('id'); $news->published_by = Input::get('publishedBy'); $news->featured_image = Input::get('featuredImage'); $news->image_caption = Input::get('imageCaption'); $news->post_type = 3; $news->published = Input::get('published'); $news->save(); $news->subjects()->forceDelete(); $subject1 = new Subject(); $subject1->news_id = $news->id; $subject1->semester = Input::get('semester1'); $subject1->espb = Input::get('espb1'); $subject1->department = Input::get('department1'); $subject1->save(); if (Input::get('semester2') != 0) { $subject2 = new Subject(); $subject2->news_id = $news->id; $subject2->semester = Input::get('semester2'); $subject2->espb = Input::get('espb2'); $subject2->department = Input::get('department2'); $subject2->save(); } if (Input::get('semester3') != 0) { $subject2 = new Subject(); $subject2->news_id = $news->id; $subject2->semester = Input::get('semester3'); $subject2->espb = Input::get('espb3'); $subject2->department = Input::get('department3'); $subject2->save(); } return Redirect::to(_l(URL::action('SubjectController@getEdit') . "/" . $news->id))->with('message', Lang::get('admin.subjectUpdated'))->with('notif', 'success'); } catch (Exception $e) { return Redirect::to(_l(URL::action('SubjectController@getIndex')))->with('message', Lang::get('admin.error'))->with('notif', 'danger'); } } }
public function add_new_people() { $raw_array = unserialize($this->aspect_data); $entry_array = $raw_array['feed']['entry']; foreach ($entry_array as $entry) { // first, check to see if the entry already exists by looking for a google Contact Id. if (!find_aspect_from_data($entry['id']['$t']) && !empty($entry['title']['$t'])) { // no entry exists, create a new subject and populate. $person = new Subject(); $person->subject_type_id = '14'; // hardcoded for the subject type at the moment. This should be replaced with a factory. $person->name = $entry['title']['$t']; $person->save(); // make sure we save it. // now let's add aspects. if (isset($entry['id']['$t'])) { $person->quick_add('Google Contact ID', $entry['id']['$t']); } // //////// if (isset($entry['gd$etag'])) { $person->quick_add('Google Contact Etag', $entry['gd$etag']); } // /////// if (isset($entry['gd$name']['gd$givenName']['$t'])) { $person->quick_add('First Name', $entry['gd$name']['gd$givenName']['$t']); } // /////// if (isset($entry['gd$name']['gd$familyName']['$t'])) { $person->quick_add('Last Name', $entry['gd$name']['gd$familyName']['$t']); } // /////// if (isset($entry['gContact$gender']['value'])) { $person->quick_add('Gender', $entry['gContact$gender']['value']); } // /////// if (isset($entry['gd$organization'])) { // loop through. foreach ($entry['gd$organization'] as $organizatiom) { // this requires more thought. // $person->quick_add('Gender', $entry['gContact$gender']['value']); } } // /////// if (isset($entry['gd$email'])) { foreach ($entry['gd$email'] as $email) { $person->quick_add('Email Address', $email['address']); } } // /////// if (isset($entry['gd$phoneNumber'])) { foreach ($entry['gd$phoneNumber'] as $phone) { $person->quick_add('Telephone Number', $phone['uri']); } } if (isset($entry['gd$structuredPostalAddress'])) { if (isset($entry['gd$structuredPostalAddress'][0]['gd$street']['$t'])) { $person->quick_add('Street Address', $entry['gd$structuredPostalAddress'][0]['gd$street']['$t']); } if (isset($entry['gd$structuredPostalAddress'][0]['gd$city']['$t'])) { $person->quick_add('City', $entry['gd$structuredPostalAddress'][0]['gd$city']['$t']); } if (isset($entry['gd$structuredPostalAddress'][0]['gd$region']['$t'])) { $person->quick_add('State', $entry['gd$structuredPostalAddress'][0]['gd$region']['$t']); } if (isset($entry['gd$structuredPostalAddress'][0]['gd$postcode']['$t'])) { $person->quick_add('Zip Code', $entry['gd$structuredPostalAddress'][0]['gd$postcode']['$t']); } if (isset($entry['gd$structuredPostalAddress'][0]['gd$formattedAddress']['$t'])) { $person->quick_add('Formatted Address', $entry['gd$structuredPostalAddress'][0]['gd$formattedAddress']['$t']); } } if (isset($entry['gContact$website'])) { foreach ($entry['gContact$website'] as $link) { $link_html = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>'; $person->quick_add('Hyperlink', $link_html); } } $person->update(); } // end duplicate check. } // end foreach }