Пример #1
0
 public function create()
 {
     if (!empty($_POST['area'])) {
         $thisArea = new Subarea();
         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;
             $thisArea->img_url = $photo;
         } else {
             //$applicant->img_url = $_POST['imgvalue'];
         }
         $areaid = explode(",", $_POST['area']);
         $areaid = $areaid[0];
         $thisArea->name = $_POST['subregion'];
         $thisArea->des = $_POST['description'];
         $thisArea->area_id = $areaid;
         //print_r($areaid);
         $thisArea->datecreated = date("Y:m:s H:i:s");
         if ($thisArea->create()) {
             return 1;
             //returns 1 on success
         } else {
             return 2;
             // returns 2 on insert error
         }
     } else {
         return 3;
         //returns 3 if requiered input field is not supplied
     }
 }
Пример #2
0
 public function create()
 {
     if (!empty($_POST['vendid']) && !empty($_POST['compname']) && !empty($_POST['phone']) && !empty($_POST['email'])) {
         if (Vendor::find_by_vendid($_POST['vendid'])) {
             return 4;
             //Cannot enter Duplicated vendor ID
             exit;
         }
         $newVendor = new Vendor();
         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;
             $newVendor->img_url = $photo;
         } else {
             //$applicant->img_url = $_POST['imgvalue'];
         }
         $newVendor->vend_id = $_POST['vendid'];
         $newVendor->vend_name = $_POST['compname'];
         $newVendor->vend_contact = $_POST['contact'];
         $newVendor->vend_address = $_POST['address'];
         $newVendor->vend_city = $_POST['city'];
         $newVendor->vend_state = $_POST['state'];
         $newVendor->vend_country = $_POST['country'];
         $newVendor->vend_phone = $_POST['phone'];
         $newVendor->vend_email = $_POST['email'];
         $newVendor->vend_website = $_POST['website'];
         $newVendor->vend_accno = $_POST['accno'];
         $newVendor->vend_datecreated = date("Y-m-d H:i:s");
         if ($newVendor->create()) {
             return 1;
             //returns 1 on success
         } else {
             return 2;
             // returns 2 on insert error
         }
     } else {
         return 3;
         //returns 3 if requiered input field is not supplied
     }
 }
 public function update()
 {
     if (!empty($_POST['clientid']) && !empty($_POST["pgid"]) && !empty($_POST['prodname']) && !empty($_POST['serial']) && !empty($_POST["address"])) {
         /*if(Client::find_by_id($_POST['clientid'])){
                         return 4; //Ensures that user creates the clients before proceeding
                         exit;
                     }
         
                      if(Client::find_by_id($_POST['prodid'])){
                         return 5; //Cannot enter ensures that users enter an existing product in the category
                         exit;
                     }*/
         $thisclientproduct = Cproduct::find_by_id((int) preg_replace('#[^0-9]#i', '', $_POST['pgid']));
         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;
             $thisclientproduct->img_url = $photo;
         } else {
             //$applicant->img_url = $_POST['imgvalue'];
         }
         $cid = explode(",", $_POST["country"]);
         $thisclientproduct->client_id = $_POST["clientid"];
         $thisclientproduct->client_name = $_POST["clientname"];
         $thisclientproduct->prod_id = $_POST["prodid"];
         $thisclientproduct->prod_name = $_POST["prodname"];
         $thisclientproduct->prod_serial = $_POST["serial"];
         $thisclientproduct->install_address = $_POST["address"];
         $thisclientproduct->install_country = $cid[1];
         $thisclientproduct->install_state = $_POST["state"];
         $thisclientproduct->install_city = $_POST["city"];
         $thisclientproduct->install_status = 0;
         $thisclientproduct->status = 0;
         $thisclientproduct->branch = $_POST['site'];
         $thisclientproduct->atm_type = $_POST["mmode"];
         $thisclientproduct->os = $_POST["os"];
         $thisclientproduct->selling_price = $_POST["amount"];
         $thisclientproduct->datemodified = date("Y-m-d H:i:s");
         global $session;
         if ($thisclientproduct->update()) {
             $_SESSION["message"] = "<div data-alert class='alert-box success'>Record Saved <a href='#' class='close'>&times;</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'>&times;</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'>&times;</a></div>";
         return 3;
         //returns 3 if requiered input field is not supplied
     }
 }
Пример #4
0
 public function updatesignoff()
 {
     if (isset($_POST['prod_id']) && !empty($_POST['prod_id']) && !empty($_POST['pgid'])) {
         $error = array();
         $obj = Sign_off::find_by_id($_POST['pgid']);
         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_stripe = isset($_POST['mag_stripe']) ? 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 = $_POST['withdraw'];
         $obj->withdraw_comment = $_POST['withdraw_area'];
         $obj->balance = $_POST['balance'];
         $obj->balance_comment = $_POST['balance_area'];
         $obj->statement = $_POST['statement'];
         $obj->statement_comment = $_POST['statement_area'];
         $obj->transfer = $_POST['transfer'];
         $obj->transfer_comment = $_POST['transfer_area'];
         $obj->pin_change = $_POST['pin_change'];
         $obj->pin_change_comment = $_POST['pin_change_area'];
         $obj->mobile_recharge = $_POST['mobile_recharge'];
         $obj->mobile_recharge_comment = $_POST['mobile_recharge_area'];
         $obj->camera_instal = $_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"];
         $obj->datemodified = date("Y-m-d H:i:s");
         $obj->status = "Closed";
         global $session;
         if ($obj->update()) {
             $_SESSION["message"] = "<div data-alert class='alert-box success'>Record Saved <a href='#' class='close'>&times;</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'>&times;</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'>&times;</a></div>";
         return 3;
         //returns 3 if requiered input field is not supplied
     }
 }
Пример #5
0
 function upload_pix($filepath = "")
 {
     $ext = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION);
     if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png' || $ext == 'jpeg') {
         $image = new Imageresize();
         $image->load($_FILES["image"]["tmp_name"]);
         $image->resize(1300, 400);
         $custom_name = rand(3, 500) . "_" . time();
         $filepath = $custom_name . "." . $ext;
         $path = "../public/images/" . $filepath;
         $image->save($path);
         $image->create($filepath);
         return $filepath;
     } else {
         return 3;
     }
 }
Пример #6
0
 public function update()
 {
     if (!empty($_POST['pname']) && !empty($_POST['pgid'])) {
         $Produc = Product::find_by_id((int) preg_replace('#[^0-9]#i', '', $_POST['pgid']));
         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;
             $Produc->prod_image = $photo;
         } else {
             $Produc->prod_image = $_POST['imgvalue'];
         }
         $Produc->prod_name = $_POST['pname'];
         $Produc->prod_desc = $_POST['description'];
         $Produc->prod_modified = date("Y:m:s H:i:s");
         if ($Produc->update()) {
             $_SESSION['message'] = "<div data-alert class='alert-box success'>Record Saved <a href='#' class='close'>&times;</a></div>";
             return 1;
         } else {
             $_SESSION['message'] = "<div data-alert class='alert-box alert'>Record not Saved <a href='#' class='close'>&times;</a></div>";
             return 2;
         }
     } else {
         $_SESSION['message'] = "<div data-alert class='alert-box alert'>Record not Saved <a href='#' class='close'>&times;</a></div>";
         return 3;
     }
 }
 public function create()
 {
     if (!empty($_POST['itemid']) && !empty($_POST['itemname']) && !empty($_POST['qty'])) {
         $newItem = new Items();
         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;
             $applicant->img_url = $photo;
         } else {
             //$applicant->img_url = $_POST['imgvalue'];
         }
         $newItem->item_id = $_POST['itemid'];
         $newItem->item_name = $_POST['itemname'];
         $newItem->item_description = $_POST['descript'];
         $newItem->item_type = $_POST['ttype'];
         $newItem->item_cost = $_POST['cprice'];
         $newItem->item_quantity = $_POST['qty'];
         $newItem->item_isbn = $_POST['isbn'];
         $newItem->item_serial = $_POST['serial'];
         $newItem->item_dateadded = date("Y-m-d H:i:s");
         if ($newItem->create()) {
             return 1;
             //returns 1 on success
         } else {
             return 2;
             // returns 2 on insert error
         }
     } else {
         return 3;
         //returns 3 if requiered input field is not supplied
     }
 }
Пример #8
0
 public function create()
 {
     global $database;
     if (isset($_POST['Submit']) && !empty($_POST['uname']) && !empty($_POST['password']) && !empty($_POST['email'])) {
         $newuser = new User();
         $limit = $_POST['limit'];
         $x = 0;
         $urole = "";
         while ($x <= $limit) {
             if (isset($_POST["utype{$x}"])) {
                 $urole .= $_POST["utype{$x}"];
                 $urole .= ",";
                 goto Data;
             }
             Data:
             $x++;
         }
         $urole = substr_replace($urole, "", -1);
         $newuser->fname = $_POST['fname'];
         $newuser->username = $_POST['uname'];
         $newuser->lname = $_POST['lname'];
         $newuser->password = $_POST['password'];
         $newuser->phone = $_POST['phone'];
         $newuser->email = $_POST['email'];
         $newuser->user_role = $urole;
         $newuser->date_added = date("Y-m-d H:i:s");
         if (isset($_FILES['fupload'])) {
             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(276, 390);
             $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;
             $newuser->img_url = $photo;
         }
         if ($database->db_query("SELECT * FROM users WHERE username='******' OR phone='" . $theuser->phone . "' OR email='" . $theuser->email . "'")) {
             if ($newuser->create()) {
                 return 1;
             } else {
                 return 2;
             }
         } else {
             return 5;
         }
     } else {
         return 4;
     }
 }
Пример #9
0
 public function create()
 {
     if (!empty($_POST['lname']) && !empty($_POST['fname']) && !empty($_POST['gender']) && !empty($_POST['mstatus']) && !empty($_POST['religion']) && !empty($_POST['dob']) && !empty($_POST['nationality']) && !empty($_POST['soo']) && !empty($_POST['address'])) {
         $applicant = new Employee();
         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;
             $applicant->img_url = $photo;
         } else {
             //$applicant->img_url = $_POST['imgvalue'];
         }
         $applicant->emp_lname = $_POST['lname'];
         $applicant->emp_fname = $_POST['fname'];
         $applicant->emp_mname = $_POST['mname'];
         $applicant->emp_sex = $_POST['gender'];
         $applicant->emp_mstatus = $_POST['mstatus'];
         $applicant->emp_religion = $_POST['religion'];
         $applicant->emp_dob = $_POST['dob'];
         $applicant->emp_nationality = $_POST['nationality'];
         $applicant->emp_soo = $_POST['soo'];
         $applicant->emp_lga = $_POST['lga'];
         $applicant->emp_address = $_POST['address'];
         $applicant->emp_email = $_POST['email'];
         $applicant->emp_phone = $_POST['phone'];
         $applicant->emp_uname = $_POST['email'];
         $applicant->emp_pword = crypt(Employee::generatePassword(8, 2), '$2a$07$usesomesillystringforsalt$');
         $applicant->emp_id = Employee::getID2("RJH/S/", "tblemp", $applicant->emp_fname . " " . $applicant->emp_lname);
         $applicant->datecreated = date("Y-m-d H:i:s");
         if ($applicant->create()) {
             $this->sendMail($applicant->fname, $applicant->lname, $applicant->emp_mname, $applicant->emp_pword, $applicant->emp_uname, $applicant->emp_email);
             return 1;
             //returns 1 on success
         } else {
             return 2;
             // returns 2 on insert error
         }
     } else {
         return 3;
         //returns 3 if requiered input field is not supplied
     }
 }
Пример #10
0
 public function create()
 {
     global $database;
     if (isset($_POST['Submit']) && !empty($_POST['password']) && !empty($_POST['email'])) {
         $newuser = new Clientuser();
         $company = Client::find_by_id($_SESSION['client_ident']);
         $newuser->fname = $_POST['fname'];
         $newuser->username = $_POST['email'];
         $newuser->lname = $_POST['sname'];
         $newuser->password = $_POST['password'];
         $newuser->phone = $_POST['phone'];
         $newuser->email = $_POST['email'];
         $newuser->company_id = $company->id;
         $newuser->company = $company->name;
         $newuser->client_id = $company->id;
         $newuser->user_role = "standard";
         $newuser->date_added = date("Y-m-d H:i:s");
         if (isset($_FILES['fupload']) && $_FILES['fupload']['error'] == 0) {
             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(280, 280);
             $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;
             $newuser->img_url = $photo;
         }
         if ($database->db_query("SELECT * FROM users_client WHERE username='******' OR phone='" . $newuser->phone . "' OR email='" . $newuser->email . "'")) {
             if ($newuser->create()) {
                 $to = $newuser->email;
                 $subject = 'RJ Support ATM Services Portal ';
                 $headers = "From: " . $company->name . "<" . $company->email . ">\r\n";
                 $headers .= "Reply-To: " . $company->contact_email . "\r\n";
                 $headers .= "MIME-Version: 1.0\r\n";
                 $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
                 $message = "<p>Your username and password on the Robert Johnson ATM Support Portal is as below </p> ";
                 $message .= "<p><b>Username: </b>" . $newuser->email . "<br>";
                 $message .= "<b>Password: </b>" . $_POST['password'] . "<br></p>";
                 $message .= "<br><br> Thank You";
                 mail($to, $subject, $message, $headers);
                 return 1;
             } else {
                 return 2;
             }
         } else {
             return 5;
         }
     } else {
         return 4;
     }
 }
Пример #11
0
 public function create()
 {
     if (isset($_POST['name']) && !empty($_POST['name'])) {
         $obj = new Client();
         $error = array();
         $obj->name = strip_tags($_POST['name']);
         $obj->addy = strip_tags($_POST['addy']);
         $obj->visible = $_POST['visible'];
         $obj->phone = $_POST['phone'];
         $obj->email = $_POST['email'];
         $obj->descr = $_POST['desc'];
         $obj->username = $_POST['username'];
         $phpFileUploadErrors = array(0 => 'There is no error, the file uploaded with success', 1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini', 2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', 3 => 'The uploaded file was only partially uploaded', 4 => 'No file was uploaded', 6 => 'Missing a temporary folder', 7 => 'Failed to write file to disk.', 8 => 'A PHP extension stopped the file upload.');
         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->image = $photo;
         } else {
             //$applicant->img_url = $_REQUEST['imgvalue'];
             echo $phpFileUploadErrors[$_FILES['fupload']['error']];
             exit;
         }
         if ($_POST['password'] == $_POST['r_password']) {
             $obj->password = $_POST['password'];
         } else {
             array_push($error, "Password do not match");
         }
         if (empty($error)) {
             if ($obj->create()) {
                 $obj->main_id = Client::getID("CLT", $obj->id);
                 $obj->update();
                 return 1;
             } else {
                 return 2;
             }
         }
     }
 }
 /**
  * this worksheet is to be used
  * with employee account after employee
  * have accepted the task
  * this is because you can't get worksheet id from 
  * the employee account so you need to get worksheet by
  * form id which is also the schedule id'
  */
 public function updateWorkSheetEmpAccount($id)
 {
     if (!empty($_POST["prod_id"]) && !empty($_POST["w_date"])) {
         $newWorkSheet = Worksheet::find_by_formid((int) preg_replace('#[^0-9]#i', '', $id));
         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->client_id = $mySchedule->client_id;
         $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");
         $newWorkSheet->status = "Closed";
         global $session;
         if ($newWorkSheet->Update()) {
             // $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'>&times;</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'>&times;</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'>&times;</a></div>";
         return 3;
         //returns 3 if requiered input field is not supplied
     }
 }