public function getSignOffByID($id) { return Sign_off::find_by_id($id); }
public function createsignoff() { if (isset($_POST['prod_id']) && !empty($_POST['prod_id'])) { $error = array(); $obj = new Sign_off(); 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; $obj->scan_url = $photo; } else { //$applicant->img_url = $_POST['imgvalue']; } $obj->prod_id = $_POST['prod_id']; //$obj->mag_strip = isset($_POST['mag_strip']) ? 1:0; $obj->verve_card = isset($_POST['verve']) ? 1 : 0; $obj->master_card = isset($_POST['master_card']) ? 1 : 0; $obj->visa_card = isset($_POST['visa_card']) ? 1 : 0; $obj->withdraw = isset($_POST['withdraw']) ? $_POST['withdraw'] : ""; $obj->witdraw_comment = isset($_POST['withdraw_area']) ? $_POST['withdraw_area'] : ""; $obj->balance = isset($_POST['balance']) ? $_POST['balance'] : ""; $obj->balance_comment = isset($_POST['balance_area']) ? $_POST['balance_area'] : ""; $obj->statement = isset($_POST['statement']) ? $_POST['statement'] : ""; $obj->statement_comment = isset($_POST['statement_area']) ? $_POST['statement_area'] : ""; $obj->transfer = isset($_POST['transfer']) ? $_POST['transfer'] : ""; $obj->transfer_comment = isset($_POST['transfer_area']) ? $_POST['transfer_area'] : ""; $obj->pin_change = isset($_POST['pin_change']) ? $_POST['pin_change'] : ""; $obj->pin_change_comment = isset($_POST['pin_change_area']) ? $_POST['pin_change_area'] : ""; $obj->mobile_recharge = isset($_POST['mobile_recharge']) ? $_POST['mobile_recharge'] : ""; $obj->mobile_recharge_comment = isset($_POST['mobile_recharge_area']) ? $_POST['mobile_recharge_area'] : ""; $obj->camera_instal = isset($_POST['camera']) ? $_POST['camera'] : ""; $obj->inverter_status = $_POST["inverter"]; $obj->AC_status = $_POST["air_cond"]; $obj->ATM_room_cond = $_POST['atm_room']; $obj->cse_remark = $_POST['cse_remark']; $obj->client_remark = $_POST['client_remark']; $obj->employee_id = $_SESSION["emp_ident"]; global $session; if ($obj->create()) { $_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 } }