public function add() { $config = ['upload_path' => 'upload', 'allowed_types' => 'gif|jpg|png', 'max_size' => 250, 'max_width' => 1920, 'max_heigh' => 1080]; $this->load->library('upload', $config); $this->load->model('Publication'); $publications = $this->Publication->get(); $publication_form_options = []; foreach ($publications as $id => $publication) { $publication_form_options[$id] = $publication->publication_name; } $this->load->library('form_validation'); $this->form_validation->set_rules([['field' => 'publication_id', 'label' => 'Publication', 'rules' => 'required'], ['field' => 'issue_number', 'label' => 'Issue number', 'rules' => 'required|is_numeric'], ['field' => 'issue_date_publication', 'label' => 'Publication date', 'rules' => 'required|callback_date_validation']]); $this->form_validation->set_error_delimiters('<div class="alert alert-error">', '</div>'); $check_file_upload = FALSE; if (isset($_FILES['issue_cover']['error']) && $_FILES['issue_cover']['error'] != 4) { $check_file_upload = TRUE; } if (!$this->form_validation->run() || $check_file_upload && !$this->upload->do_upload('issue_cover')) { $this->load->view('bootstrap/main', ['main' => 'magazines/magazine_form', 'publication_form_options' => $publication_form_options]); } else { $this->load->model('Issue'); $issue = new Issue(); $issue->publication_id = $this->input->post('publication_id'); $issue->issue_number = $this->input->post('issue_number'); $issue->issue_date_publication = $this->input->post('issue_date_publication'); $upload_data = $this->upload->data(); if (isset($upload_data['file_name'])) { $issue->issue_cover = $upload_data['file_name']; } $issue->save(); $this->load->view('bootstrap/main', ['main' => 'magazines/magazine_form_success', 'issue' => $issue]); } }
public function store() { $validator = Validator::make(Input::all(), Issue::$rules, Issue::$messages); //if($validator->passes()){ $issue = new Issue(); $issue->summary = Input::get('summary'); $issue->detail = Input::get('detail'); $issue->budget = 0.0; $issue->currentState = "TO-DO"; $issue->points = Input::get('points'); $issue->labels = Input::get('labels'); $issue->iterationid = Input::get('iterationid'); $categoryId = Input::get('categoryid'); if ($categoryId == 0) { //crear categoria $category = new Category(); $category->name = Input::get('category_name'); $category->save(); $issue->categoryid = $category->id; } else { $issue->categoryid = $categoryId; } $issue->save(); return Redirect::to('/iterations/' . $issue->iterationid)->with('message', 'Historia creada con exito'); /*}else{ return Redirect::to('iterations/'. Input::get('iterationid')) ->with('error', 'Ocurrieron los siguientes errores') ->withErrors($validator) ->withInput(); }*/ }
public function add() { $this->load->helper('url'); $this->load->library('session'); $this->load->model('My_User'); $this->load->library('table'); $this->load->model(array('Issue', 'Publication')); $this->load->view('bootstrap/header'); $upload_config = array('upload_path' => 'upload', 'allowed_types' => 'gif|png|jpg', 'max_size' => 600, 'max_width' => 1920, 'max_height' => 1080); $this->load->library('upload', $upload_config); $this->load->helper('form'); $this->load->model("Publication"); $publications = $this->Publication->get(); $publication_form_options = array(); foreach ($publications as $id => $publication) { $publication_form_options[$id] = $publication->publication_name; } $this->load->library('form_validation'); $this->form_validation->set_rules(array(array('field' => 'publication_id', 'label' => 'Publication Name', 'rules' => 'required'), array('field' => 'issue_number', 'label' => 'Issue Number', 'rules' => 'required|is_numeric|callback_check_duplicate'), array('field' => 'issue_date_publication', 'label' => 'Publication Date', 'rules' => 'required|callback_date_validation'))); $this->form_validation->set_error_delimiters('<div class="alert alert-danger">', '</div>'); // checking selected file for cover $check_file_upload = false; if (isset($_FILES['issue_cover']['error']) && $_FILES['issue_cover']['error'] != 4) { $check_file_upload = true; } if (!$this->form_validation->run() || $check_file_upload && !$this->upload->do_upload('issue_cover')) { $this->load->view("magazine_add_form", array("publication_form_options" => $publication_form_options)); } else { $this->load->model('Issue'); $issue = new Issue(); $issue->publication_id = $this->input->post('publication_id'); $issue->issue_number = $this->input->post('issue_number'); $issue->issue_date_publication = $this->input->post('issue_date_publication'); $upload_data = $this->upload->data(); if (isset($upload_data['file_name'])) { $issue->issue_cover = $upload_data['file_name']; } $issue->save(); // making thumbnail of uploaded image for future use $config['image_library'] = 'gd2'; $config['source_image'] = 'upload/' . $issue->issue_cover; $config['create_thumb'] = true; $config['maintain_ration'] = true; $config['width'] = 75; $config['height'] = 50; $this->load->library('image_lib', $config); $this->image_lib->resize(); // the resulting thumbnail name is same as the cover name appended with '_thumb' // success message after saving the new issue $this->load->view('magazine_form_success', array('issue' => $issue)); } $this->load->view('bootstrap/footer'); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Issue(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Issue'])) { $model->attributes = $_POST['Issue']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id_trans)); } } $this->render('create', array('model' => $model)); }
/** * Index page for Magazine controller. */ public function index() { $this->load->database(); $this->load->model('Publication'); $this->Publication->publication_name = 'Sandy Shore'; $this->Publication->save(); echo '<tt><pre>' . var_export($this->Publication, TRUE) . '</pre></tt>'; $this->load->model('Issue'); $issue = new Issue(); $issue->publication_id = $this->Publication->publication_id; $issue->issue_number = 2; $issue->issue_date_publication = date('2013-02-01'); $issue->issue_cover = 'This is first issue'; $issue->save(); echo '<tt><pre>' . var_export($issue, TRUE) . '</pre></tt>'; $this->load->view('magazines'); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($id) { $equipment = $this->loadEquipment($id); $model = new Issue(); $model->equipmentId = $id; $model->status = 1; $model->createTime = new CDbExpression('GETDATE()'); $model->userId = Yii::app()->user->id; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Issue'])) { $model->attributes = $_POST['Issue']; if ($model->save()) { $this->redirect(array('result/create', 'id' => $model->id)); } } $this->render('create', array('model' => $model, 'equipment' => $equipment)); }
public function actionAdd() { // Init $data = $this->getJsonData(); // Store new element $issue = new Issue(); $issue->setAttributes($data); if (!$issue->save()) { $errors = array(); foreach ($issue->getErrors() as $err) { $errors[] = implode("\n", $err); } $this->sendError(implode("\n", $errors)); } $issue = Issue::model()->with(array('status'))->findByPk($issue->id); $item = array_merge($issue->attributes, array('status' => $issue->status->attributes)); // Success $this->send($item); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Issue(); $model->project_id = $this->_project->id; //if _project property is not null, use it to set project for new issue // if(!$this->_project===null) // { // $model->project_id = $this->_project->id; // } // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Issue'])) { $model->attributes = $_POST['Issue']; 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($fk_componentDetail) { $model = new Issue(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Issue'])) { $model->attributes = $_POST['Issue']; $model->fk_componentDetail = $fk_componentDetail; $passinfo = $fk_componentDetail; if ($model->save()) { //update component status //call componentDetail model $component = componentDetail::model()->findByPk($fk_componentDetail); $component->deviceStatus = "In Use"; $component->save(); $this->redirect(array('componentDetail/admin')); } } $this->render('create', array('model' => $model)); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // $rules = array('receivers_name' => 'required', 'quantity_issued' => 'required|integer', 'batch_no' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::route('issue.index')->withErrors($validator); } else { // store $issue = new Issue(); $issue->receipt_id = Input::get('batch_no'); $issue->topup_request_id = Input::get('topup_request_id'); $issue->quantity_issued = Input::get('quantity_issued'); $issue->issued_to = Input::get('receivers_name'); $issue->user_id = Auth::user()->id; $issue->remarks = Input::get('remarks'); try { $issue->save(); return Redirect::route('issue.index')->with('message', trans('messages.commodity-succesfully-added')); } catch (QueryException $e) { Log::error($e); } } }
public function store() { // Get StudentID // From student_id or Create New // Create Registration // Create Issue // Create Education // Create Placement // Create Receivables // Reductions // Create Installment try { //DB::beginTransaction(); if (Input::get('student_id') == 0) { // Create New Student $student = new Student(); $student->name = Input::get('name'); $student->sex = Input::get('sex'); $student->birthplace = Input::get('birthplace'); $student->birthdate = date('Y-m-d', strtotime(Input::get('birthdate'))); $student->religion = Input::get('religion'); $student->address = Input::get('address'); $student->contact = Input::get('contact'); $student->email = Input::get('email'); if (Input::get('sex') == 'L') { $student->photo = 'boy.png'; } else { $student->photo = 'girl.png'; } $student->father_name = Input::get('father_name'); $student->father_occupation = Input::get('father_occupation'); $student->father_address = Input::get('father_address'); $student->father_contact = Input::get('father_contact'); $student->father_email = Input::get('father_email'); $student->mother_name = Input::get('mother_name'); $student->mother_occupation = Input::get('mother_occupation'); $student->mother_address = Input::get('mother_address'); $student->mother_contact = Input::get('mother_contact'); $student->mother_email = Input::get('mother_email'); $student->save(); $id = $student->id; } else { $student = Student::find(Input::get('student_id')); $student->name = Input::get('name'); $student->sex = Input::get('sex'); $student->birthplace = Input::get('birthplace'); $student->birthdate = date('Y-m-d', strtotime(Input::get('birthdate'))); $student->religion = Input::get('religion'); $student->address = Input::get('address'); $student->contact = Input::get('contact'); $student->email = Input::get('email'); if (Input::get('sex') == 'L') { $student->photo = 'boy.png'; } else { $student->photo = 'girl.png'; } $student->father_name = Input::get('father_name'); $student->father_occupation = Input::get('father_occupation'); $student->father_address = Input::get('father_address'); $student->father_contact = Input::get('father_contact'); $student->father_email = Input::get('father_email'); $student->mother_name = Input::get('mother_name'); $student->mother_occupation = Input::get('mother_occupation'); $student->mother_address = Input::get('mother_address'); $student->mother_contact = Input::get('mother_contact'); $student->mother_email = Input::get('mother_email'); $student->save(); $id = $student->id; } // Create Registration Data $registration = new Registration(); $registration->project_id = Auth::user()->curr_project_id; $registration->location_id = Auth::user()->location_id; $registration->student_id = $id; $registration->classification_id = Input::get('classification'); $registration->base_id = Input::get('location'); $registration->registration_date = date('Y-m-d', strtotime(Input::get('registration_date'))); $registration->registration_cost = Input::get('fee'); $registration->recommender_type = Input::get('recommender_type'); $registration->recommender_id = Input::get('recommender_id'); $registration->employee_id = Input::get('employee'); $registration->save(); // Create Issue $issue = new Issue(); $issue->project_id = Auth::user()->curr_project_id; $issue->location_id = Auth::user()->location_id; $issue->registration_id = $registration->id; $issue->generation_id = Input::get('generation'); $issue->student_id = $id; $issue->issue = Input::get('issue'); $issue->save(); //Create Education Data if (Input::get('school') != '0') { $education = new Education(); $education->project_id = Auth::user()->curr_project_id; $education->issue_id = $issue->id; $education->school_id = Input::get('school'); $education->generation_id = Input::get('generation'); $education->save(); } // Receivables - Registration Costs $receivable = new Receivable(); $receivable->project_id = Auth::user()->curr_project_id; $receivable->location_id = Auth::user()->location_id; $receivable->issue_id = $issue->id; $receivable->registration_id = $registration->id; $receivable->total = Input::get('total'); $receivable->billable = Input::get('billable'); $receivable->receivable = Input::get('receivables'); $receivable->balance = Input::get('billable'); if (Input::get('payment') == 0) { $receivable->payment = 'Cash'; } else { $receivable->payment = 'Installment'; } $receivable->save(); $billable = Input::get('billable'); $payment = Input::get('payment'); if ((int) $payment > 0) { // First Installment $installment = new Installment(); $installment->project_id = Auth::user()->curr_project_id; $installment->location_id = Auth::user()->location_id; $installment->receivable_id = $receivable->id; $installment->schedule = Input::get('registration_date'); $installment->total = $billable / $payment; $installment->balance = $billable / $payment; $installment->paid = 0; $installment->save(); // Extracting Date $dd = (int) substr(Input::get('registration_date'), 8, 2); $mm = (int) substr(Input::get('registration_date'), 5, 2); $yy = (int) substr(Input::get('registration_date'), 0, 4); if ($dd > 25) { $mm += 2; if ($mm > 12) { $new_mm = $mm - 12; $yy += 1; } else { $new_mm = $mm; } } else { $mm += 1; if ($mm > 12) { $new_mm = $mm - 12; $yy += 1; } else { $new_mm = $mm; } } for ($i = 2; $i <= $payment; $i++) { $installment_date = $yy . '-' . str_pad($new_mm, 2, "0", STR_PAD_LEFT) . '-' . '05'; $installment = new Installment(); $installment->project_id = Auth::user()->curr_project_id; $installment->location_id = Auth::user()->location_id; $installment->receivable_id = $receivable->id; $installment->schedule = date('Y-m-d', strtotime($installment_date)); $installment->total = $billable / $payment; $installment->balance = $billable / $payment; $installment->paid = 0; $installment->save(); $new_mm += 1; if ($new_mm > 12) { $new_mm = $new_mm - 12; $yy += 1; } } } // Placements $courses = Input::get('course'); foreach ($courses as $key => $value) { $course = explode("#", $value); $placement = new Placement(); $placement->project_id = Auth::user()->curr_project_id; $placement->location_id = Auth::user()->location_id; $placement->registration_id = $registration->id; $placement->issue_id = $issue->id; $placement->course_id = $course[0]; $placement->save(); } // Reductions - Discounts $discounts = Input::get('discounts'); if ($discounts) { foreach ($discounts as $key => $value) { $discount = explode("#", $value); $reduction = new Reduction(); $reduction->project_id = Auth::user()->curr_project_id; $reduction->location_id = Auth::user()->location_id; $reduction->registration_id = $registration->id; $reduction->receivable_id = $receivable->id; $reduction->reductable_type = 'Discount'; $reduction->reductable_id = $discount[0]; $reduction->save(); } } // Reductions - Promotions $promotions = Input::get('promotions'); if ($promotions) { foreach ($promotions as $key => $value) { $promotion = explode("#", $value); $reduction = new Reduction(); $reduction->project_id = Auth::user()->curr_project_id; $reduction->location_id = Auth::user()->location_id; $reduction->registration_id = $registration->id; $reduction->receivable_id = $receivable->id; $reduction->reductable_type = 'Promotion'; $reduction->reductable_id = $promotion[0]; $reduction->save(); } } // Reductions - Vouchers $vouchers = Input::get('vouchers'); if ($vouchers) { foreach ($vouchers as $key => $value) { $voucher = explode("#", $value); $reduction = new Reduction(); $reduction->project_id = Auth::user()->curr_project_id; $reduction->location_id = Auth::user()->location_id; $reduction->registration_id = $registration->id; $reduction->receivable_id = $receivable->id; $reduction->reductable_type = 'Voucher'; $reduction->reductable_id = $voucher[0]; $reduction->save(); } } // Reductions - Charges $charges = Input::get('charges'); if ($charges) { foreach ($charges as $key => $value) { $charger = explode("#", $value); $reduction = new Reduction(); $reduction->project_id = Auth::user()->curr_project_id; $reduction->location_id = Auth::user()->location_id; $reduction->registration_id = $registration->id; $reduction->receivable_id = $receivable->id; $reduction->reductable_type = 'Charge'; $reduction->reductable_id = $charger[0]; $reduction->save(); } } // Updating Student Timelines $content = 'Bergabung menjadi Siswa One School ' . Auth::user()->location->name . 'untuk periode ' . Auth::user()->curr_project->name; $timeline = new Timeline(); $timeline->project_id = Auth::user()->curr_project_id; $timeline->location_id = Auth::user()->location_id; $timeline->informable_type = 'Issue'; $timeline->informable_id = $issue->id; $timeline->content = $content; $timeline->save(); // Updating Employee Timeline $content = 'Menerima Pendaftaran Siswa untuk periode ' . Auth::user()->curr_project->name; $timeline = new Timeline(); $timeline->project_id = Auth::user()->curr_project_id; $timeline->location_id = Auth::user()->location_id; $timeline->informable_type = 'Employee'; $timeline->informable_id = Input::get('employee'); $timeline->content = $content; $timeline->save(); //DB::commit(); return Response::json(array('status' => 'Succeed', 'registration_id' => $registration->id, 'issue_id' => $issue->id)); } catch (Exception $e) { DB::rollback(); return Response::json(array('status' => 'Failed', 'error' => $e)); } }
<?php if (!empty($_POST['issueID'])) { $issueID = $_POST['issueID']; $issue = new Issue(new NamedArguments(array('primaryKey' => $issueID))); $issue->resolutionText = $_POST['resolutionText']; $issue->dateClosed = date("Y-m-d H:i:s"); try { $issue->save(); } catch (Exception $e) { echo $e->getMessage(); } }
if (!empty($_POST["ccEmails"])) { $issueEmails = explode(',', $_POST["ccEmails"]); } $newIssue = new Issue(); $newIssue->creatorID = $user->loginID; $newIssue->dateCreated = date('Y-m-d H:i:s'); if ($_POST["ccCreator"]) { $issueEmails[] = $user->emailAddress; } if (!is_numeric($formDataArray["reminderInterval"])) { $formDataArray["reminderInterval"] = 0; } foreach ($formDataArray as $key => $value) { $newIssue->{$key} = $value; } $newIssue->save(); //start building the email body $emailMessage = "Subject: {$newIssue->subjectText}\r\n\r\n\r\n\t\t\t\t\tBody: {$newIssue->bodyText}\r\n\r\n\r\n\t\t\t\t\tApplies To: "; if ($organizationID) { $newIssueRelationship = new IssueRelationship(); $newIssueRelationship->issueID = $newIssue->primaryKey; $newIssueRelationship->entityID = $organizationID; $newIssueRelationship->entityTypeID = 1; $newIssueRelationship->save(); $emailMessage .= "{$organization->name}\r\n"; } else { $orgResourcesArray = $sourceOrganization->getResources(5); $orgResourcesIndexed = array(); foreach ($orgResources as $resource) { $orgResourcesIndexed[$resource['resourceID']] = $resource; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Issue(); $model->project_id = $this->_project->id; if (!is_null($this->_issue)) { $model->issue_id = $this->_issue->id; } // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Issue'])) { $model->attributes = $_POST['Issue']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model, 'project' => $this->_project, 'issue' => $this->_issue)); }
private function save_issue() { $this->load->model('Issue'); $issue = new Issue(); $id = $this->input->post('issue_id'); if (!empty($id)) { $issue->load($id); } $issue->issue_number = intval($this->input->post('issue_number')); $issue->issue_date_publication = $this->input->post('issue_date_publication'); $issue->save(); return $issue; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { if (!Yii::app()->user->checkAccess('createIssue', array('project' => $this->_project))) { throw new CHttpException(403, 'You are not authorized to perform this action.'); } $model = new Issue(); $model->project_id = $this->_project->id; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Issue'])) { $model->attributes = $_POST['Issue']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
function save($check_notify = false) { $this->fixDatetimes(); $return_id = parent::save($check_notify); return $return_id; }
/** * Add an issue to this event. * * @param $text * * @return bool */ public function addIssue($text) { if (!($issue = Issue::model()->find('name=?', array($text)))) { $issue = new Issue(); $issue->name = $text; if (!$issue->save()) { return false; } } if (!EventIssue::model()->find('event_id=? and issue_id=?', array($this->id, $issue->id))) { $ei = new EventIssue(); $ei->event_id = $this->id; $ei->issue_id = $issue->id; if (!$ei->save()) { return false; } } return true; }
/** * Duplicate a complete issue tree, starting from a duplicated issue created by duplicate() * @param int $id * @param int $new_id * @return Issue $this */ protected function _duplicateTree($id, $new_id) { // Find all child issues $children = $this->find(array("parent_id = ?", $id)); if (count($children)) { $f3 = \Base::instance(); foreach ($children as $child) { if (!$child->deleted_date) { // Duplicate issue $child->copyto("duplicating_issue"); $f3->clear("duplicating_issue.id"); $f3->clear("duplicating_issue.due_date"); $new_child = new Issue(); $new_child->copyfrom("duplicating_issue"); $new_child->clear("id"); $new_child->clear("due_date"); $new_child->author_id = $f3->get("user.id"); $new_child->set("parent_id", $new_id); $new_child->save(false); // Duplicate issue's children $this->_duplicateTree($child->id, $new_child->id); } } } return $this; }