static function addBatches($input) { $batch = new Batches(); $batch->batch_name = $input['batchName']; $batch->franchisee_id = Session::get('franchiseId'); $batch->season_id = $input['season_id']; $batch->class_id = $input['classId']; $batch->course_id = $input['courseId']; $batch->start_date = $input['startDate']; $batch->end_date = $input['endDate']; // if(isset($input['classAmount'])){ // $batch->class_amount=$input['classAmount']; // } $batch->preferred_time = $input['preferredTime']; $batch->preferred_end_time = $input['preferredEndTime']; if (isset($input['location_id'])) { $batch->location_id = $input['location_id']; } if ($input['leadInstructor'] != "") { $batch->lead_instructor = $input['leadInstructor']; } else { $batch->lead_instructor = null; } if ($input['alternateInstructor'] != "") { $batch->alternate_instructor = $input['alternateInstructor']; } else { $batch->alternate_instructor = null; } $batch->created_by = Session::get('userId'); $batch->created_at = date("Y-m-d H:i:s"); $batch->save(); return $batch; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Batches(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Batches'])) { $model->attributes = $_POST['Batches']; $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->start_date = $s_d; $model->end_date = $e_d; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * 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)); }
public function save_batch($edit_id = false) { if ($this->input->post("submit")) { if ($this->_submit_validate() === FALSE) { $data['title'] = "Stock Management::Add New Stock (Error)"; $data['content_view'] = "add_batch_view"; $this->base_params($data); } else { if ($edit_id != false) { $batch = Batches::getBatch($edit_id); $batch = $batch[0]; $disbursement = Disbursements::getBatchEntry($edit_id); $disbursement = $disbursement[0]; } else { if ($edit_id == false) { $batch = new Batches(); $disbursement = new Disbursements(); } } $batch->Vaccine_Id = $this->input->post("vaccine_id"); $batch->Batch_Number = $this->input->post("batch_number"); $batch->Expiry_Date = $this->input->post("expiry_date"); $batch->Manufacturing_Date = $this->input->post("manufacturing_date"); $batch->Manufacturer = $this->input->post("manufacturer"); $batch->Lot_Number = $this->input->post("lot_number"); $batch->Origin_Country = $this->input->post("origin_country"); $batch->Arrival_Date = $this->input->post("arrival_date"); $batch->Quantity = str_replace(",", "", $this->input->post("quantity")); $batch->Timestamp = date("U"); $batch->Added_By = $this->session->userdata('user_id'); $batch->Year = date('Y'); $batch->save(); $disbursement->Batch_Id = $batch->id; $disbursement->Date_Issued = $this->input->post("arrival_date"); $disbursement->Quantity = str_replace(",", "", $this->input->post("quantity")); $disbursement->Batch_Number = $this->input->post("batch_number"); $disbursement->Vaccine_Id = $this->input->post("vaccine_id"); $disbursement->Issued_To_National = "0"; $disbursement->Timestamp = date("U"); $disbursement->Added_By = $this->session->userdata('user_id'); $disbursement->Stock_At_Hand = Disbursements::getNationalPeriodBalance($this->input->post("vaccine_id"), date("U")); $disbursement->Date_Issued_Timestamp = strtotime($this->input->post('arrival_date')); $disbursement->save(); redirect("batch_management"); } } }
/** * 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)); }