コード例 #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Courses();
     $model_1 = new Batches();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Courses'])) {
         $model_1->attributes = $_POST['Batches'];
         $model->attributes = $_POST['Courses'];
         $model->validate();
         if ($model_1->validate()) {
             if ($model->save()) {
                 $list = $_POST['Batches'];
                 if (!$list['start_date']) {
                     $s_d = "";
                 } else {
                     $s_d = date('Y-m-d', strtotime($list['start_date']));
                 }
                 if (!$list['end_date']) {
                     $e_d = "";
                 } else {
                     $e_d = date('Y-m-d', strtotime($list['end_date']));
                 }
                 $model_1->course_id = Yii::app()->db->getLastInsertId();
                 $model_1->start_date = $s_d;
                 $model_1->end_date = $e_d;
                 $model_1->save();
                 $this->redirect(array('/courses'));
             }
         }
     }
     $this->render('create', array('model' => $model, 'model_1' => $model_1));
 }
コード例 #2
0
ファイル: Courses.php プロジェクト: Headrun-php/TLG
 static function addCourse($inputs)
 {
     $Course = new Courses();
     $Course->course_name = $inputs['courseName'];
     $Course->slug = $inputs['slug'];
     $Course->master_course_id = $inputs['masterCourse'];
     $Course->franchisee_id = Session::get('franchiseId');
     $Course->created_by = Session::get('userId');
     $Course->created_at = date("Y-m-d H:i:s");
     $Course->save();
     return $Course;
 }
コード例 #3
0
ファイル: BaseUserQuestionTag.php プロジェクト: rayku/rayku
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->aCategory !== null) {
             if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
                 $affectedRows += $this->aCategory->save($con);
             }
             $this->setCategory($this->aCategory);
         }
         if ($this->aCourses !== null) {
             if ($this->aCourses->isModified() || $this->aCourses->isNew()) {
                 $affectedRows += $this->aCourses->save($con);
             }
             $this->setCourses($this->aCourses);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = UserQuestionTagPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = UserQuestionTagPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += UserQuestionTagPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
コード例 #4
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Courses();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Courses'])) {
         $model->attributes = $_POST['Courses'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->idCourse));
         }
     }
     $this->render('create', array('model' => $model));
 }
コード例 #5
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Courses();
     $model_1 = new Batches();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Courses'])) {
         $model_1->attributes = $_POST['Batches'];
         $model->attributes = $_POST['Courses'];
         if ($model->save()) {
             $model_1->course_id = Yii::app()->db->getLastInsertId();
             $model_1->save();
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model, 'model_1' => $model_1));
 }
コード例 #6
0
 public function actionSave()
 {
     $data_array = $_POST;
     if (!empty($data_array)) {
         $course = new Courses();
         foreach ($data_array as $key => $value) {
             $course->{$key} = $value;
         }
         if (!empty($_FILES)) {
             $course->img = Files::upload($_FILES, 'courses');
         }
         $course->save();
     } else {
         header('Location: ' . ADMIN_PATH);
     }
     header('Location: ' . ADMIN_PATH . '?ctrl=courses&act=edit&id=' . $course->id);
 }
コード例 #7
0
ファイル: FbController.php プロジェクト: bafio89/qea-u
 public function actionAddDegreeGroup()
 {
     //INSERIRE INFO DI UNIVERSITà E CDL
     if ($_POST['ExamGroup']['courses_id'] != '') {
         $group = ExamGroup::model()->findByPk($_POST['DegreeGroup']['cid']);
     } else {
         $group = DegreeGroup::model()->findByPk($_POST['DegreeGroup']['cid']);
     }
     if (!isset($group)) {
         $course = new Courses();
         if ($_POST['ExamGroup']['courses_id'] != '' && !is_numeric($_POST['ExamGroup']['courses_id'])) {
             $max_id = Courses::model()->find(array('order' => 'cid DESC'));
             $course->name = $_POST['ExamGroup']['courses_id'];
             $course->degree_id = $_SESSION['did'];
             $course->cid = $max_id->cid + 1;
             $course->validate();
             $course->save();
         } else {
             $course->cid = $_POST['ExamGroup']['courses_id'];
         }
         if ($_POST['ExamGroup']['courses_id'] != '') {
             $group = new ExamGroup();
             $group->eid = $_POST['DegreeGroup']['cid'];
             $group->courses_id = $course->cid;
             $group->degree_id = $_SESSION['did'];
         } else {
             $group = new DegreeGroup();
             $group->cid = $_POST['DegreeGroup']['cid'];
             $group->degree_id = $_SESSION['did'];
         }
         $group->validate();
         $group->save();
     }
 }
コード例 #8
0
ファイル: HomeController.php プロジェクト: Konaeu/ubicom
 public function edit($cat_id = 0, $item_id = 0)
 {
     if ($cat_id == 0) {
         //默认为新闻编辑
         $item = News::find($item_id);
         if ($item) {
             //要是编辑文件存在,这时进行修改
             return View::make('home.edit')->with('cat_title', '新闻编辑')->with('cat_id', $cat_id)->with('item_id', $item->id)->with('item_title', $item->title)->with('item_abstract', $item->abstract)->with('item_content', $item->content);
         } else {
             return View::make('home.edit')->with('cat_title', '新闻编辑')->with('cat_id', $cat_id)->with('item_id', 0)->with('item_title', '')->with('item_abstract', '')->with('item_content', '');
         }
     } else {
         if ($cat_id == 1) {
             //项目编辑
             $item = Researches::find($item_id);
             if ($item) {
                 return View::make('home.edit')->with('cat_title', '项目编辑')->with('cat_id', $cat_id)->with('item_id', $item->id)->with('item_begin_time', $item->begin_time)->with('item_end_time', $item->end_time)->with('item_title', $item->title)->with('item_abstract', $item->abstract)->with('item_content', $item->content);
             } else {
                 return View::make('home.edit')->with('cat_title', '项目编辑')->with('cat_id', $cat_id)->with('item_id', 0)->with('item_begin_time', '')->with('item_end_time', '')->with('item_title', '')->with('item_abstract', '')->with('item_content', '');
             }
         } else {
             if ($cat_id == 2) {
                 //通知编辑
                 $item = Notices::find($item_id);
                 if ($item) {
                     //要是编辑文件存在,这时进行修改
                     return View::make('home.edit')->with('cat_title', '通知编辑')->with('cat_id', $cat_id)->with('item_id', $item->id)->with('item_title', $item->title)->with('item_content', $item->content);
                 } else {
                     return View::make('home.edit')->with('cat_title', '通知编辑')->with('cat_id', $cat_id)->with('item_id', 0)->with('item_title', '')->with('item_content', '');
                 }
             } else {
                 if ($cat_id == 3) {
                     //课程编辑
                     $item = Courses::find($item_id);
                     if ($item) {
                         //要是编辑文件存在,这时进行修改
                         //$homeworks=Courses::find($item_id)->homework;
                         //$coursewares=Courses::find($item_id)->courseware;
                     } else {
                         //创建新课程:同时创建homework,coursewares
                         $item = new Courses();
                         $item->course_name = '';
                         $item->save();
                         $item_id = $item->id;
                     }
                     $homeworks = Courses::find($item_id)->homework;
                     $coursewares = Courses::find($item_id)->courseware;
                     $course_notices = Courses::find($item_id)->comments;
                     return View::make('home.edit')->with('cat_title', '课程编辑')->with('cat_id', $cat_id)->with('item_id', $item->id)->with('course_name', $item->course_name)->with('teacher_address', $item->teacher_address)->with('teacher_mail', $item->teacher_mail)->with('TA_name', $item->TA_name)->with('TA_address', $item->TA_address)->with('TA_mail', $item->TA_mail)->with('course_info', $item->course_info)->with('homeworks', $homeworks)->with('coursewares', $coursewares)->with('course_notices', $course_notices);
                 }
             }
         }
     }
 }
コード例 #9
0
ファイル: CourseController.php プロジェクト: nagyist/abge
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function postCreate()
 {
     /*
     		Validator::make(
     array(
     	'title' => Input::get('title'),
     	'description' => Input::get('description'),
     	'content' => Input::get('content'),
     	'program' => Input::get('program'),
     	'address' => Input::get('address'),
     	'company_id' => Input::get('company_id'),
     	'event_id' => Input::get('event_id'),
     	'category_id' => Input::get('category_id'),
     	'start' => date("Y-m-d", Input::get('start')),
     	'end' => date("Y-m-d", Input::get('end'))
     	),
     array(
     	'title' => 'required',
     	'description' => 'required',
     	'content' => 'required',
     	'program' => 'required',
     	'address' => 'required',
     	'company_id' => 'required|integer',
     	'event_id' => 'required|integer',
     	'category_id' => 'required|integer',
     	'start' => 'required|date',
     	'end' => 'required|date',
     	)
     );
     */
     $header = Input::file('header');
     $image = Input::file('image');
     $validator = Validator::make(array('header' => $header, 'image' => $image), array('header' => 'mimes:png,jpeg,gif', 'image' => 'mimes:png,jpeg,gif'), array('mimes' => 'Tipo de imagen inválido, solo se admite los formatos PNG, JPEG, y GIF'));
     if ($validator->fails()) {
         return Redirect::to($this->route . '/create')->with('msg_succes', Lang::get('messages.companies_create_img_err'));
     } else {
         if ($header != "") {
             $headerfilename = $this->uploadHeader($header);
         } else {
             $headerfilename = "";
         }
         if ($image != "") {
             $imagefilename = $this->uploadCourseImage($image);
         } else {
             $imagefilename = "";
         }
         $course = new Courses();
         $course->title = Input::get('title');
         $course->description = Input::get('description');
         $course->header = $headerfilename;
         $course->image = $imagefilename;
         /*
         $course->description = Input::get('description');
         $course->inscription = Input::get('inscription');
         $course->associates_payment = Input::get('associates_payment');
         $course->participants_payment = Input::get('participants_payment');
         $course->associates_message = Input::get('associates_message');
         $course->program = Input::get('program');
         $course->participants_message = Input::get('participants_message');
         */
         $course->category_id = Input::get('category_id');
         $course->company_id = Input::get('company_id');
         $course->event_id = Input::get('event_id');
         $course->type = Input::get('type');
         $course->route = Input::get('route');
         $course->min = Input::get('min');
         $course->max = Input::get('max');
         $course->min_message = Input::get('min_message');
         $course->max_message = Input::get('max_message');
         $course->address = Input::get('address');
         $course->start = date("Y-m-d", strtotime(Input::get('start')));
         $course->end = date("Y-m-d", strtotime(Input::get('end')));
         if ($course->save()) {
             /*$teachers = Input::get('teachers');
             		$course->teachers()->sync($teachers);
             		$promotioners = Input::get('promotioners');
             		$course->promotioners()->sync($promotioners);
             		$supporters = Input::get('supporters');
             		$course->supporters()->sync($supporters);*/
             $sections = Input::get('section');
             $course->sections()->sync($sections);
             return Redirect::to($this->route)->with('msg_success', Lang::get('messages.companies_create', array('title' => $course->title)));
         } else {
             return Redirect::to($this->route)->with('msg_error', Lang::get('messages.companies_create_err', array('title' => $course->title)));
         }
     }
 }
 public function teacherAddAction()
 {
     try {
         $name = Input::get('name');
         $description = Input::get('description');
         $publish = Input::get('publish');
         $user_id = Input::get('userID');
         $classes = explode(',', Input::get('hiddenClasses'));
         $course = new Courses();
         $course->name = $name;
         $course->description = $description;
         $course->published = $publish;
         $course->created_by = $user_id;
         $course->save();
         $id = DB::getPdo()->lastInsertId();
         for ($i = 0; $i < count($classes); $i++) {
             if ($classes[$i] != "") {
                 $classcourse = new Classcourse();
                 $classcourse->class = $classes[$i];
                 $classcourse->course = $id;
                 $classcourse->save();
             }
         }
         return Redirect::route('teacher/sprints');
     } catch (Exception $ex) {
         echo $ex;
         Session::flash('status_error', '');
     }
 }