/** * public function getData(){ * global $database; * $depts = Department::find_all(); * $role = Roles::find_all(); * $country = Country::find_all(); * $vendors = Vendor::find_all(); * $zone = Zone::find_by_sql("SELECT * FROM zone"); * $clietproducts = Cproduct::find_all(); * $startups = array("departs"=>$depts,"country"=>$country,"zone"=>$zone,"vendors"=>$vendors,"role"=>$role,'products'=>$clietproducts); * return $startups; * } */ public function creatworksheet() { if (!empty($_POST["prod_id"]) && !empty($_POST["w_date"])) { $newWorkSheet = new Worksheet(); if (isset($_FILES['fupload']) && $_FILES['fupload']['error'] == 0) { //if file upload is set move_uploaded_file($_FILES['fupload']['tmp_name'], "public/uploads/" . basename($_FILES['fupload']['name'])); $image = new Imageresize(); // an instance of image resize object $image->load("public/uploads/" . basename($_FILES['fupload']['name'])); //$image->image =; $image->resize(400, 400); $image->save("public/uploads/" . basename($_FILES['fupload']['name'])); //this section is needed to get the extension for image type in renaming the image if ($_FILES['fupload']['type'] == "image/gif") { $ext = ".gif"; } if ($_FILES['fupload']['type'] == "image/png") { $ext = ".png"; } if ($_FILES['fupload']['type'] == "image/jpeg") { $ext = ".jpeg"; } if ($_FILES['fupload']['type'] == "image/pjpeg") { $ext = ".jpeg"; } if ($_FILES['fupload']['type'] == "image/gif") { $ext = ".gif"; } if ($_FILES['fupload']['type'] == "image/jpg") { $ext = ".jpg"; } $new_name = uniqid() . "_" . time() . $ext; //new name for the image rename("public/uploads/" . basename($_FILES['fupload']['name']), "public/uploads/" . $new_name); $photo = $new_name; $newWorkSheet->scan_url = $photo; } else { //$applicant->img_url = $_POST['imgvalue']; } $mySchedule = Schedule::find_by_id($_POST['wsid']); $newWorkSheet->prod_id = $_POST["prod_id"]; $newWorkSheet->formid = $_POST['wsid']; $newWorkSheet->prod_name = $mySchedule->prod_name; $newWorkSheet->sheet_date = $_POST["w_date"]; $newWorkSheet->time_in = $_POST["time_in"]; $newWorkSheet->time_out = $_POST["time_out"]; $newWorkSheet->contact_person = $_POST["contact_person"]; $newWorkSheet->cse_emp_id = empty($_POST["emp_id"]) ? $mySchedule->emp_id : $_POST['emp_id']; $newWorkSheet->problem = empty($_POST["problem"]) ? $mySchedule->issue : $_POST['problem']; $newWorkSheet->cause = $_POST["cause"]; $newWorkSheet->corrective_action = $_POST["corrective_action"]; $newWorkSheet->part_changed = $_POST["part_changed"]; $newWorkSheet->cse_remark = $_POST["cse_remark"]; $newWorkSheet->client_remark = $_POST["client_remark"]; $newWorkSheet->datecreated = date("Y-m-d H:i:s"); global $session; if ($newWorkSheet->create()) { // $schedulee = Schedule::find_by_id($_POST["wsid"]); $mySchedule->status = "Closed"; $mySchedule->datemodified = date("Y:m:d H:i:s"); $mySchedule->update(); $_SESSION["message"] = "<div data-alert class='alert-box success'>Record Saved <a href='#' class='close'>×</a></div>"; return 1; //returns 1 on success } else { $_SESSION["message"] = "<div data-alert class='alert-box alert'>Unexpected Error! Record not Saved <a href='#' class='close'>×</a></div>"; return 2; // returns 2 on insert error } } else { $_SESSION["message"] = "<div data-alert class='alert-box alert'>Unexpected Error! Record not Saved <a href='#' class='close'>×</a></div>"; return 3; //returns 3 if requiered input field is not supplied } }
public function acceptTask() { global $session; $newWorkSheet = new Worksheet(); $ticket = Schedule::find_by_id($_POST['taskid']); if (isset($_POST['taskid'])) { $newWorkSheet->cse_emp_id = $_SESSION['emp_ident']; $newWorkSheet->formid = $_POST['taskid']; $newWorkSheet->prod_id = $ticket->prod_id; $newWorkSheet->client_id = $ticket->client_id; //$newWorkSheet->contact_person = $ticket->contact_name; $newWorkSheet->problem = $ticket->issue; $newWorkSheet->sheet_date = date("Y:m:d H:i:s"); $newWorkSheet->datecreated = date("Y:m:d H:i:s"); $newWorkSheet->status = "Open"; $ticket->status = "In Progress"; $ticket->datemodified = date("Y:m:d H:i:s"); if ($newWorkSheet->create()) { $ticket->update(); return 1; } else { return 2; } } else { return 3; } }