0byt3m1n1
Path:
/
home
/
k74ns2xygros
/
www
/
globetech
/
cms
/
assets
/
[
Home
]
File: login.php
<?php date_default_timezone_set('Asia/Kolkata'); include "connection.php"; class User { var $conn; // For Connection Construct function __construct() { $con = new connection(); $this->conn = $con->connect(); } // For Data Encryption function encrypt($data, $key) { $iv = mcrypt_create_iv( mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_DEV_URANDOM ); $encrypted = base64_encode( $iv . mcrypt_encrypt( MCRYPT_RIJNDAEL_128, hash('sha256', $key, true), $data, MCRYPT_MODE_CBC, $iv ) ); return $encrypted; } // For Data Decryption function decrypt($encrypted, $key) { $data = base64_decode($encrypted); $iv = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)); $decrypted = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_128, hash('sha256', $key, true), substr($data, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)), MCRYPT_MODE_CBC, $iv ), "\0" ); return $decrypted; } // Reseller Or Provider Login public function login() { $name = $_POST['name']; $password = $_POST['password']; $sq = "select * from admin_company inner join admin_user on admin_company.company_id= admin_user.company_id where admin_user='$name'and admin_pass='$password'"; $qu = mysqli_query($this->conn, $sq); if (mysqli_num_rows($qu)) { $row = mysqli_fetch_array($qu); $_SESSION['admin_cid'] = $row['cid']; $_SESSION['login'] = 'yes'; $_SESSION['name'] = $name; if (!empty($_POST["remember"])) { setcookie("name1", $name, time() + (10 * 365 * 24 * 60 * 60)); setcookie("password1", $password, time() + (10 * 365 * 24 * 60 * 60)); } else { if (isset($_COOKIE["name1"])) { setcookie("name1", ""); } if (isset($_COOKIE["password1"])) { setcookie("password1", ""); } } // echo "<script>location.href='admin/dashboard.php';</script>"; echo '<script type="text/javascript"> window.location = "admin/dashboard.php" </script>'; // header("Location:admin/dashboard.php"); } else { $_SESSION['err_login'] = "Username or Password is Wrong!"; } } // Reseller Or Provider Login public function employee_login() { $phone = $_POST['phone']; // $password = $_POST['password']; $sq = "select * from employee where phone='$phone'"; $qu = mysqli_query($this->conn, $sq); if (mysqli_num_rows($qu)) { $row = mysqli_fetch_array($qu); $_SESSION['cid'] = $row['cid']; $_SESSION['emp_login'] = 'yes'; $_SESSION['emp_no'] = $row['emp_no']; if (!empty($_POST["remember"])) { setcookie("name1", $name, time() + (10 * 365 * 24 * 60 * 60)); setcookie("password1", $password, time() + (10 * 365 * 24 * 60 * 60)); } else { if (isset($_COOKIE["name1"])) { setcookie("name1", ""); } if (isset($_COOKIE["password1"])) { setcookie("password1", ""); } } if ($row['form_status'] == 1) { echo '<script type="text/javascript"> window.location = "employee_address.php" </script>'; } elseif ($row['form_status'] == 2) { echo '<script type="text/javascript"> window.location = "accounr_details.php" </script>'; } elseif ($row['form_status'] == 3) { echo '<script type="text/javascript"> window.location = "insurance_details.php" </script>'; } elseif ($row['form_status'] == 'complete') { echo '<script type="text/javascript"> window.location = "employee_dashboard.php" </script>'; } } else { $_SESSION['err_login'] = "Your Phone No. or OTP is Wrong!"; } } // Get Reseller Data public function get_data($id) { $sq1 = "select * from admin_user where user_id='$id'"; $qu1 = mysqli_query($this->conn, $sq1); $res = mysqli_fetch_assoc($qu1); return $res; } // get general data in settings public function get_gendata($cid) { $sq1 = "select * from admin_company where company_id='$cid'"; $qu1 = mysqli_query($this->conn, $sq1); $res = mysqli_fetch_assoc($qu1); return $res; } // update general data in settings public function update_gendata($id, $name, $email, $phone, $address, $country, $state, $city, $zcode, $tname, $tno, $trate) { $company_type = $_SESSION['type']; $sq2 = "UPDATE admin_company SET name = '$name', company_email = '$email', address = '$address', city = '$city',state='$state', country='$country', zcode = '$zcode', phone = '$phone', taxname='$tname', tax_no='$tno', tax='$trate' WHERE company_id= '$id'"; $qu2 = mysqli_query($this->conn, $sq2); $_SESSION['msg_iteration'] = 0; if ($qu2) { $_SESSION['msg'] = 'Company Details Updated Successfully.'; $message = 'General Settings Updated Successfully by <a href="../profile/company_profile.php?q=' . $id . '"> ' . $company_type . ' #' . $id . ' </a>'; $log_status = 'activity'; } else { $_SESSION['err_msg'] = 'Something Went Wrong!'; $message = 'Updation in General Settings Failed! by <a href="../profile/company_profile.php?q=' . $id . '"> ' . $company_type . ' #' . $id . ' </a>'; $log_status = 'error'; } $sqlog = "INSERT INTO log (`log_id`, `message`,`log_status`) VALUES('NULL', '$message','$log_status')"; $qulog = mysqli_query($this->conn, $sqlog); header("location:general_settings.php"); } // update profile of loggedin user public function update_data($id, $name, $email, $phone, $add, $city, $zcode, $cpass) { $company_type = $_SESSION['type']; $sq2 = "UPDATE admin_user SET user_name = '$name', admin_pass = '$cpass', user_email = '$email', user_phone = '$phone', user_address = '$add', user_city = '$city', user_zcode = '$zcode' WHERE user_id= '$id'"; $qu2 = mysqli_query($this->conn, $sq2); $_SESSION['msg_iteration'] = 0; if ($qu2) { $_SESSION['msg'] = 'User Profile Updated Successfully!'; $message = 'Profile Updated Successfully by <a href="../profile/company_profile.php?q=' . $id . '"> ' . $company_type . ' #' . $id . ' </a>'; $log_status = 'activity'; } else { $_SESSION['err_msg'] = 'Something Went Wrong!'; $message = 'Updation in Profile Failed! by <a href="../profile/company_profile.php?q=' . $id . '"> ' . $company_type . ' #' . $id . ' </a>'; $log_status = 'error'; } $sqlog = "INSERT INTO log (`log_id`, `message`,`log_status`) VALUES('NULL', '$message','$log_status')"; $qulog = mysqli_query($this->conn, $sqlog); header("location:profile.php"); } public function add_employee() { $fname = $_POST['fullname']; $father_name = $_POST['father_name']; $mother_name = $_POST['mother_name']; $phone = $_POST['phone']; $email = $_POST['email']; $dob = $_POST['dob']; $gender = $_POST['gender']; $nationality = $_POST['nationality']; $mstatus = $_POST['mstatus']; $wife_name = $_POST['wife_name']; $street = $_POST['street']; $village = $_POST['village']; $post = $_POST['post']; $state = $_POST['state']; $city = $_POST['city']; $pincode = $_POST['pincode']; $thana = $_POST['thana']; // $country = $_POST['country']; $skilled = $_POST['skilled']; $emp_no = $_POST['emp_no']; $ipno = $_POST['ipno']; $ic = $_POST['ic']; $samprice = $_POST['samprice']; $nominee = $_POST['nominee']; $nominee_rel = $_POST['nominee_rel']; $childs = $_POST['childs']; $epf = $_POST['epf']; $accname = $_POST['accname']; $accnumber = $_POST['accnumber']; $ifsc = $_POST['ifsc']; $bank_name = $_POST['bank_name']; $bank_branch = $_POST['bank_branch']; $bank_address = $_POST['bank_address']; $pan = $_POST['pan']; $target_dir = "../include/uploads/"; $t_dir = "include/uploads/"; // only for url image use in db $target_file = $target_dir . basename($_FILES["clogo"]["name"]); $target_file1 = $t_dir . $emp_no . '.jpg'; $target_file1 = str_replace(' ', '+', $target_file1); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); // Check if image images is a actual image or fake image global $errtext; $check = getimagesize($_FILES["clogo"]["tmp_name"]); if ($check !== false) { "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { $errtext = "File is not an image."; $uploadOk = 0; } // Check images size if ($_FILES["clogo"]["size"] > 300000) { echo $errtext = "Sorry, your images is too large."; $uploadOk = 0; } // Allow certain images formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG" && $imageFileType != "GIF") { echo $errtext = "Sorry, only JPG, JPEG, PNG & GIF imagess are allowed."; $uploadOk = 0; } if (file_exists($target_file)) { chmod($target_file, 0755); //Change the file permissions if allowed unlink($target_file); //remove the file } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { "Sorry, your images was not uploaded."; // if everything is ok, try to upload images } else { if (move_uploaded_file($_FILES["clogo"]["tmp_name"], $target_dir . $emp_no . ".jpg")) { $clogo = $target_file . $_FILES["clogo"]["tmp_name"]; $errtext = "The images " . basename($_FILES["clogo"]["name"]) . " has been uploaded."; $x = 'ok'; } else { echo $errtext = "Sorry, there was an error uploading your images."; } } if ($x == 'ok') { $sq = "INSERT INTO `employee`(`cid`, `customer_name`, `father_name`, `mother_name`, `phone`, `emailid`, `dob`, `gender`, `mstatus`, `wife_name`, `street`, `village`, `post`, `state`, `district`, `pincode`, `thana`, `skilled`, `emp_no`, `insurance_policy_no`, `insurance_company`, `s_price`, `nominee`, `nominee_relation`, `epf_reg`, `acc_holder_name`, `acc_no`, `ifsc`, `bank_name`, `bank_branch`, `pan_no`, `clogo`, `nationality`, `bank_address`,`childs`) VALUES (NULL,'$fname','$father_name','$mother_name','$phone','$email','$dob','$gender','$mstatus','$wife_name','$street','$village','$post','$state','$city','$pincode','$thana','$skilled','$emp_no','$ipno','$ic','$samprice','$nominee','$nominee_rel','$epf','$accname','$accnumber','$ifsc','$bank_name','$bank_branch','$pan','$target_file1','$nationality','$bank_address','$childs')"; $qu = mysqli_query($this->conn, $sq); $cid = mysqli_insert_id($this->conn); if ($qu) { $_SESSION['msg'] = 'Company Added Successfully.'; // echo "<script type='text/javascript'> // window.location = 'lists/view_employee.php?q=$cid'; // </script>"; echo "<script>location.href='lists/view_employee.php?q=$cid';</script>"; // header("Location:lists/view_employee.php?q=$cid"); } else { $_SESSION['err_msg'] = 'Something Went Wrong1!'; echo '<meta http-equiv="refresh" content="0">'; } } else { $_SESSION['err_msg'] = 'Something Went Wrong2!'; echo '<meta http-equiv="refresh" content="0">'; } // echo '<meta http-equiv="refresh" content="0">'; } public function add_employee_itself() { $fname = $_POST['fullname']; $father_name = $_POST['father_name']; $mother_name = $_POST['mother_name']; $phone = $_POST['phone']; $email = $_POST['email']; $dob = $_POST['dob']; $gender = $_POST['gender']; $nationality = $_POST['nationality']; $mstatus = $_POST['mstatus']; $wife_name = $_POST['wife_name']; $street = $_POST['street']; $village = $_POST['village']; $post = $_POST['post']; $state = $_POST['state']; $city = $_POST['city']; $pincode = $_POST['pincode']; $thana = $_POST['thana']; // $country = $_POST['country']; $skilled = $_POST['skilled']; $emp_no = $_POST['emp_no']; $ipno = $_POST['ipno']; $ic = $_POST['ic']; $samprice = $_POST['samprice']; $nominee = $_POST['nominee']; $nominee_rel = $_POST['nominee_rel']; $childs = $_POST['childs']; $epf = $_POST['epf']; $accname = $_POST['accname']; $accnumber = $_POST['accnumber']; $ifsc = $_POST['ifsc']; $bank_name = $_POST['bank_name']; $bank_branch = $_POST['bank_branch']; $bank_address = $_POST['bank_address']; $pan = $_POST['pan']; $target_dir = "include/uploads/"; $target_file = $target_dir . basename($_FILES["clogo"]["name"]); $target_file1 = $target_dir . $emp_no . '.jpg'; $target_file1 = str_replace(' ', '+', $target_file1); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); // Check if image images is a actual image or fake image global $errtext; $check = getimagesize($_FILES["clogo"]["tmp_name"]); if ($check !== false) { "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { $errtext = "File is not an image."; $uploadOk = 0; } // Check images size if ($_FILES["clogo"]["size"] > 300000) { echo $errtext = "Sorry, your images is too large."; $uploadOk = 0; } // Allow certain images formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG" && $imageFileType != "GIF") { echo $errtext = "Sorry, only JPG, JPEG, PNG & GIF imagess are allowed."; $uploadOk = 0; } if (file_exists($target_file)) { chmod($target_file, 0755); //Change the file permissions if allowed unlink($target_file); //remove the file } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { "Sorry, your images was not uploaded."; // if everything is ok, try to upload images } else { if (move_uploaded_file($_FILES["clogo"]["tmp_name"], $target_dir . $emp_no . ".jpg")) { $clogo = $target_file . $_FILES["clogo"]["tmp_name"]; $errtext = "The images " . basename($_FILES["clogo"]["name"]) . " has been uploaded."; $x = 'ok'; } else { echo $errtext = "Sorry, there was an error uploading your images."; } } if ($x == 'ok') { $sq = "INSERT INTO `employee`(`cid`, `customer_name`, `father_name`, `mother_name`, `phone`, `emailid`, `dob`, `gender`, `mstatus`, `wife_name`, `street`, `village`, `post`, `state`, `district`, `pincode`, `thana`, `skilled`, `emp_no`, `insurance_policy_no`, `insurance_company`, `s_price`, `nominee`, `nominee_relation`, `epf_reg`, `acc_holder_name`, `acc_no`, `ifsc`, `bank_name`, `bank_branch`, `pan_no`, `clogo`, `nationality`, `bank_address`,`childs`) VALUES (NULL,'$fname','$father_name','$mother_name','$phone','$email','$dob','$gender','$mstatus','$wife_name','$street','$village','$post','$state','$city','$pincode','$thana','$skilled','$emp_no','$ipno','$ic','$samprice','$nominee','$nominee_rel','$epf','$accname','$accnumber','$ifsc','$bank_name','$bank_branch','$pan','$target_file1','$nationality','$bank_address','$childs')"; $qu = mysqli_query($this->conn, $sq); $cid = mysqli_insert_id($this->conn); if ($qu) { $_SESSION['msg'] = 'Company Added Successfully.'; echo "<script>location.href='print_details.php?q=$cid';</script>"; } else { $_SESSION['err_msg'] = 'Something Went Wrong!'; echo '<meta http-equiv="refresh" content="0">'; } } else { $_SESSION['err_msg'] = 'Something Went Wrong!'; echo '<meta http-equiv="refresh" content="0">'; } // echo '<meta http-equiv="refresh" content="0">'; } public function initial_registration() { $fname = $_POST['f_name']; $lname = $_POST['l_name']; $mname = $_POST['m_name']; $fullname = $fname . ' ' . $mname . ' ' . $lname; $father_name = $_POST['father_name']; $phone = $_POST['phone']; // $email = $_POST['email']; $fulladdress = $_POST['fulladdress']; // $nationality = $_POST['nationality']; $identity_type = $_POST['identity_type']; $zone = $_POST['zone']; $s_engineer = $_POST['s_engineer']; $ex_engineer = $_POST['ex_engineer']; $electry_city = $_POST['electry_city']; $reg_date = date('Y-m-d'); // $emp_no = date('dmY') . rand(100, 1000); //for file name only $sq = "INSERT INTO `employee`(`cid`, `customer_name`, `father_name`, `phone`, `identity_type`, `full_address`, `zone`, `s_engineer`, `ex_engineer`, `electrycity_zone`, `reg_date`) VALUES (NULL,'$fullname','$father_name','$phone','$identity_type','$fulladdress','$zone','$s_engineer','$ex_engineer','$electry_city','$reg_date')"; $qu = mysqli_query($this->conn, $sq); $cid = mysqli_insert_id($this->conn); if ($qu) { $_SESSION['msg'] = 'You have registered yourself successfully.'; $_SESSION['cid'] = $cid; $_SESSION['phone'] = $phone; // echo "<script>location.href='print_after_registration.php?q=$cid';</script>"; echo "<script>location.href='send_success_message.php';</script>"; } else { $_SESSION['err_msg'] = 'Oops! Registration Failed.'; echo '<meta http-equiv="refresh" content="0">'; } // echo '<meta http-equiv="refresh" content="0">'; } public function initial_employee_registration() { $fname = $_POST['f_name']; $lname = $_POST['l_name']; $mname = $_POST['m_name']; $fullname = $fname . ' ' . $mname . ' ' . $lname; $father_name = $_POST['father_name']; $mother_name = $_POST['mother_name']; $phone = $_POST['phone']; $phone2 = $_POST['phone2']; $email = $_POST['email']; $dob = $_POST['dob']; $gender = $_POST['gender']; // $fulladdress = $_POST['fulladdress']; $nationality = $_POST['nationality']; $mstatus = $_POST['mstatus']; $wife_name = $_POST['wife_name']; $childs = $_POST['childs']; // $identity_type = $_POST['identity_type']; $zone = $_POST['zone']; $s_engineer = $_POST['s_engineer']; $ex_engineer = $_POST['ex_engineer']; $electry_city = $_POST['electry_city']; $reg_date = date('Y-m-d'); $emp_no = 'GII' . date('Ymd') . rand(100, 1000); //for file name only $target_dir = "include/uploads/"; $target_file = $target_dir . basename($_FILES["clogo"]["name"]); $target_file1 = $target_dir . $emp_no . '.jpg'; $target_file1 = str_replace(' ', '+', $target_file1); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); // Check if image images is a actual image or fake image global $errtext; $check = getimagesize($_FILES["clogo"]["tmp_name"]); if ($check !== false) { "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { $errtext = "File is not an image."; $uploadOk = 0; } // Check images size if ($_FILES["clogo"]["size"] > 300000) { echo $errtext = "Sorry, your images is too large."; $uploadOk = 0; } // Allow certain images formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG" && $imageFileType != "GIF") { echo $errtext = "Sorry, only JPG, JPEG, PNG & GIF imagess are allowed."; $uploadOk = 0; } if (file_exists($target_file)) { chmod($target_file, 0755); //Change the file permissions if allowed unlink($target_file); //remove the file } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { "Sorry, your images was not uploaded."; // if everything is ok, try to upload images } else { if (move_uploaded_file($_FILES["clogo"]["tmp_name"], $target_dir . $emp_no . ".jpg")) { $clogo = $target_file . $_FILES["clogo"]["tmp_name"]; $errtext = "The images " . basename($_FILES["clogo"]["name"]) . " has been uploaded."; $x = 'ok'; } else { echo $errtext = "Sorry, there was an error uploading your images."; } } if ($x == 'ok') { $sq = "INSERT INTO `employee`(`cid`, `customer_name`,`first_name` ,`middle_name` ,`last_name` ,`father_name`, `mother_name`, `phone`, `phone2`, `emailid`, `dob`, `gender`, `mstatus`, `wife_name`, `clogo`, `nationality`,`childs`, `zone`, `s_engineer`, `ex_engineer`, `electrycity_zone`, `emp_no`, `reg_date`,`form_status`) VALUES (NULL,'$fullname','$fname','$mname','$lname','$father_name','$mother_name','$phone','$phone2','$email','$dob','$gender','$mstatus','$wife_name','$target_file1','$nationality','$childs','$zone','$s_engineer','$ex_engineer','$electry_city','$emp_no','$reg_date','1')"; // $sq = "INSERT INTO `employee`(`cid`, `customer_name`, `father_name`, `mother_name`, `phone`, `phone2`, `emailid`, `dob`, `gender`, `mstatus`, `wife_name`, `clogo`, `nationality`,`childs`, `identity_type`, `full_address`, `zone`, `s_engineer`, `ex_engineer`, `electrycity_zone`, `emp_no`, `reg_date`) VALUES (NULL,'$fullname','$father_name','$mother_name','$phone','$phone2','$email','$dob','$gender','$mstatus','$wife_name','$target_file1','$nationality','$childs','$identity_type','$fulladdress','$zone','$s_engineer','$ex_engineer','$electry_city','$emp_no','$reg_date')"; $qu = mysqli_query($this->conn, $sq); $cid = mysqli_insert_id($this->conn); if ($qu) { $_SESSION['msg'] = 'You Personal Details Added Successfully.'; $_SESSION['emp_no'] = $emp_no; $_SESSION['cid'] = $cid; echo "<script>location.href='employee_address.php';</script>"; // echo "<script>location.href='print_after_registration.php?q=$cid';</script>"; } else { $_SESSION['err_msg'] = 'Oops! Your Registration Failed.'; echo '<meta http-equiv="refresh" content="0">'; } } else { $_SESSION['err_msg'] = 'Error in Photo Upload due to ' . $errtext; echo '<meta http-equiv="refresh" content="0">'; } // echo '<meta http-equiv="refresh" content="0">'; } public function add_employee_address($emp_no, $cid) { $identity_type = $_POST['identity_type']; $identity_no = $_POST['identity_no']; $mohalla = $_POST['mohalla']; $village = $_POST['village']; $block = $_POST['block']; $tahsil = $_POST['tahsil']; $thana = $_POST['thana']; $pincode = $_POST['pincode']; $post = $_POST['post']; $city = $_POST['city']; $state = $_POST['state']; // $country = $_POST['country']; $target_dir = "include/identity/"; $target_file = $target_dir . basename($_FILES["identity_proof"]["name"]); $target_file1 = $target_dir . $emp_no . '.jpg'; $target_file1 = str_replace(' ', '+', $target_file1); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); // Check if image images is a actual image or fake image global $errtext; $check = getimagesize($_FILES["identity_proof"]["tmp_name"]); if ($check !== false) { "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { $errtext = "File is not an image."; $uploadOk = 0; } // Check images size if ($_FILES["identity_proof"]["size"] > 300000) { echo $errtext = "Sorry, your image size is larger than 1 MB."; $uploadOk = 0; } // Allow certain images formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG" && $imageFileType != "GIF") { echo $errtext = "Sorry, only JPG, JPEG, PNG & GIF imagess are allowed."; $uploadOk = 0; } if (file_exists($target_file)) { chmod($target_file, 0755); //Change the file permissions if allowed unlink($target_file); //remove the file } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { "Sorry, your images was not uploaded."; // if everything is ok, try to upload images } else { if (move_uploaded_file($_FILES["identity_proof"]["tmp_name"], $target_dir . $emp_no . ".jpg")) { $identity_proof = $target_file . $_FILES["identity_proof"]["tmp_name"]; $errtext = "The images " . basename($_FILES["identity_proof"]["name"]) . " has been uploaded."; $x = 'ok'; } else { echo $errtext = "Sorry, there was an error uploading your images."; } } if ($x == 'ok') { $sq = "UPDATE `employee` SET `mohalla`='$mohalla',`village`='$village',`post`='$post',`state`='$state',`district`='$city',`pincode`='$pincode',`thana`='$thana',`block`='$block',`tahsil`='$tahsil',`identity_type`='$identity_type',`identity_no`='$identity_no',`identity_upload`='$target_file1',`form_status`='2' WHERE `cid`='$cid'"; $qu = mysqli_query($this->conn, $sq); if ($qu) { $_SESSION['msg'] = 'Employee Address Added Successfully.'; echo "<script>location.href='account_details.php';</script>"; } else { $_SESSION['err_msg'] = 'Something Went Wrong!'; echo '<meta http-equiv="refresh" content="0">'; } } else { $_SESSION['err_msg'] = 'Error in Photo Upload due to ' . $errtext; echo '<meta http-equiv="refresh" content="0">'; } // echo '<meta http-equiv="refresh" content="0">'; } public function add_employee_bank_details($emp_no, $cid) { $skilled = $_POST['skilled']; $skilled_type = $_POST['skilled_type']; // $skilled_upload = $_POST['skilled_upload']; $work_type = $_POST['work_type']; $ifsc = $_POST['ifsc']; $bank_name = $_POST['bank_name']; $bank_branch = $_POST['bank_branch']; $bank_address = $_POST['bank_address']; $accname = $_POST['accname']; $accnumber = $_POST['accnumber']; // $pan = $_POST['pan']; /* image upload for passbook start */ $target_dir = "include/passbook/"; $target_file = $target_dir . basename($_FILES["passbook"]["name"]); $target_file1 = $target_dir . $emp_no . 'passbook.jpg'; $target_file1 = str_replace(' ', '+', $target_file1); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); // Check if image images is a actual image or fake image global $errtext; $check = getimagesize($_FILES["passbook"]["tmp_name"]); if ($check !== false) { "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { $errtext = "File is not an image."; $uploadOk = 0; } // Check images size if ($_FILES["passbook"]["size"] > 300000) { echo $errtext = "Sorry, your images is too large."; $uploadOk = 0; } // Allow certain images formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG" && $imageFileType != "GIF") { echo $errtext = "Sorry, only JPG, JPEG, PNG & GIF imagess are allowed."; $uploadOk = 0; } if (file_exists($target_file)) { chmod($target_file, 0755); //Change the file permissions if allowed unlink($target_file); //remove the file } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { "Sorry, your images was not uploaded."; // if everything is ok, try to upload images } else { if (move_uploaded_file($_FILES["passbook"]["tmp_name"], $target_dir . $emp_no . "passbook.jpg")) { $passbook = $target_file . $_FILES["passbook"]["tmp_name"]; $errtext = "The images " . basename($_FILES["passbook"]["name"]) . " has been uploaded."; $x = 'ok'; } else { echo $errtext = "Sorry, there was an error uploading your images."; } } /* image upload for passbook end */ /* image upload for skill start */ if ($skilled_type == 'Skilled') { $target_dir_skill = "include/skill_upload/"; $target_file_skill = $target_dir_skill . basename($_FILES["skilled_upload"]["name"]); $target_file_skill1 = $target_dir . $emp_no . 'skill.jpg'; $target_file_skill1 = str_replace(' ', '+', $target_file_skill1); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file_skill, PATHINFO_EXTENSION)); // Check if image images is a actual image or fake image global $errtexty; $check = getimagesize($_FILES["skilled_upload"]["tmp_name"]); if ($check !== false) { "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { $errtexty = "File is not an image."; $uploadOk = 0; } // Check images size if ($_FILES["skilled_upload"]["size"] > 300000) { echo $errtexty = "Sorry, your images is too large."; $uploadOk = 0; } // Allow certain images formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG" && $imageFileType != "GIF") { echo $errtexty = "Sorry, only JPG, JPEG, PNG & GIF imagess are allowed."; $uploadOk = 0; } if (file_exists($target_file_skill)) { chmod($target_file_skill, 0755); //Change the file permissions if allowed unlink($target_file_skill); //remove the file } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { "Sorry, your images was not uploaded."; // if everything is ok, try to upload images } else { if (move_uploaded_file($_FILES["skilled_upload"]["tmp_name"], $target_dir_skill . $emp_no . "skill.jpg")) { $skilled_upload = $target_file_skill . $_FILES["skilled_upload"]["tmp_name"]; $errtexty = "The images " . basename($_FILES["skilled_upload"]["name"]) . " has been uploaded."; $y = 'ok'; } else { echo $errtexty = "Sorry, there was an error uploading your images."; } } } else { $y = 'ok'; } /* image upload for skill end */ if ($x == 'ok' && $y == 'ok') { $sq = "UPDATE `employee` SET `skilled`='$skilled',`skilled_type`='$skilled_type',`skilled_upload`='$target_file_skill1',`acc_holder_name`='$accname',`acc_no`='$accnumber',`ifsc`='$ifsc',`bank_name`='$bank_name',`bank_branch`='$bank_branch',`bank_address`='$bank_address',`work_type`='$work_type',`passbook_upload`='$target_file1',`form_status`='3' WHERE `cid`='$cid'"; $qu = mysqli_query($this->conn, $sq); if ($qu) { $_SESSION['msg'] = 'Bank Detail Added Successfully.'; echo "<script>location.href='insurance_details.php';</script>"; } else { $_SESSION['err_msg'] = 'Something Went Wrong!'; echo '<meta http-equiv="refresh" content="0">'; } } else { $_SESSION['err_msg'] = 'Error in Photo Upload due to ' . $errtext . $errtexty; echo '<meta http-equiv="refresh" content="0">'; } } public function add_employee_insurance_details($emp_no, $cid) { $ipno = $_POST['ipno']; $ic = $_POST['ic']; $ip_expiry = $_POST['ip_expiry']; $samprice = $_POST['samprice']; $nominee = $_POST['nominee']; $nominee_rel = $_POST['nominee_rel']; $nominee_other = $_POST['nominee_other']; $epf_detail = $_POST['epf_detail']; $epf = $_POST['epf']; $epf_expiry = $_POST['epf_expiry']; $pan_detail = $_POST['pan_detail']; $pan_no = $_POST['pan_no']; // $pan_upload = $_POST['pan_upload']; if ($pan_detail == 'yes') { $target_dir = "include/pan_upload/"; $target_file = $target_dir . basename($_FILES["pan_upload"]["name"]); $target_file1 = $emp_no . 'pan.jpg'; $target_file1 = str_replace(' ', '+', $target_file1); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); // Check if image images is a actual image or fake image global $errtext; $check = getimagesize($_FILES["pan_upload"]["tmp_name"]); if ($check !== false) { "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { $errtext = "File is not an image."; $uploadOk = 0; } // Check images size if ($_FILES["pan_upload"]["size"] > 300000) { echo $errtext = "Sorry, your images is too large."; $uploadOk = 0; } // Allow certain images formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG" && $imageFileType != "GIF") { echo $errtext = "Sorry, only JPG, JPEG, PNG & GIF imagess are allowed."; $uploadOk = 0; } if (file_exists($target_file)) { chmod($target_file, 0755); //Change the file permissions if allowed unlink($target_file); //remove the file } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { "Sorry, your images was not uploaded."; // if everything is ok, try to upload images } else { if (move_uploaded_file($_FILES["pan_upload"]["tmp_name"], $target_dir . $emp_no . "pan.jpg")) { $pan_upload = $target_file . $_FILES["pan_upload"]["tmp_name"]; $errtext = "The images " . basename($_FILES["pan_upload"]["name"]) . " has been uploaded."; $x = 'ok'; } else { echo $errtext = "Sorry, there was an error uploading your images."; } } } else { $x = 'ok'; } if ($x == 'ok') { $sq = "UPDATE `employee` SET `insurance_policy_no`='$ipno',`insurance_company`='$ic',`s_price`='$samprice',`nominee`='$nominee',`nominee_relation`='$nominee_rel',`nominee_other`='$nominee_other',`epf_detail`='$epf_detail',`epf_reg`='$epf',`ip_expiry`='$ip_expiry',`pan_no`='$pan_no',`pan_detail`='$pan_detail',`pan_upload`='$target_file1',`form_status`='complete' where `cid`='$cid'"; $qu = mysqli_query($this->conn, $sq); if ($qu) { $_SESSION['cid'] = $cid; $_SESSION['msg'] = 'Insurance Detail Added Successfully.'; // echo "<script>location.href='send_success_message.php';</script>"; echo "<script>location.href='print_after_registration.php';</script>"; } else { $_SESSION['err_msg'] = 'Something Went Wrong!'; echo '<meta http-equiv="refresh" content="0">'; } } else { $_SESSION['err_msg'] = 'Something Went Wrong!'; echo '<meta http-equiv="refresh" content="0">'; } } // Get Countries public function getcountries() { $sq = "select * from countries"; $result = mysqli_query($this->conn, $sq); while ($row = mysqli_fetch_assoc($result)) { $row1[] = $row; } return $row1; } // Get Country public function getzone() { $sq = "select * from zone"; $result = mysqli_query($this->conn, $sq); while ($row = mysqli_fetch_assoc($result)) { $row1[] = $row; } return $row1; } //Get State public function get_s_engineer($country_id) { $sq = "SELECT * FROM `super_engineer` WHERE `zone_id` in (select zone_id from zone where zone_name='$country_id')"; $result = mysqli_query($this->conn, $sq); return $result; } //Get City public function get_ex_engineer($state_id) { $sq = "SELECT * FROM `executive_engineer` WHERE `super_id` in (select super_id from super_engineer where super_name='$state_id')"; $result = mysqli_query($this->conn, $sq); return $result; } //Get ElectriCity Zone public function electry_city($city_id) { $sq = "SELECT * FROM `electrycity_zone` WHERE `ex_id` in (select ex_id from executive_engineer where ex_name='$city_id')"; $result = mysqli_query($this->conn, $sq); return $result; } //Get States public function getstates() { $sq = "SELECT * FROM `states` WHERE `country_id` in (select id from countries where name='$cname')"; $result = mysqli_query($this->conn, $sq); return $result; } //Get Cities public function getcities() { $sname = $_REQUEST['sname']; $sq = "SELECT * FROM `cities` WHERE `state_id` in(select id from states where name='$sname')"; $result = mysqli_query($this->conn, $sq); return $result; } //Check Unique Company Reseller User Name public function getuser() { $name = $_REQUEST['name']; $sq = "select admin_user from admin_user where admin_user ='$name'"; $qu = mysqli_query($this->conn, $sq); $n = mysqli_num_rows($qu); return $n; } //List all active provider public function list_activeprovider() { $sq3 = "select * from admin_company where company_type='provider' and comp_status='active'"; $qu3 = mysqli_query($this->conn, $sq3); return $qu3; } //List all suspendedprovider public function list_suspprovider() { $sq3 = "select * from admin_company where company_type='provider' and comp_status='suspended'"; $qu3 = mysqli_query($this->conn, $sq3); return $qu3; } //List all client public function list_client() { $sq3 = "SELECT * FROM `employee` order by cid desc"; $qu3 = mysqli_query($this->conn, $sq3); return $qu3; } public function list_accepted_client($app_status) { $sq3 = "SELECT * FROM `employee` where application_status='$app_status' order by cid desc"; $qu3 = mysqli_query($this->conn, $sq3); return $qu3; } //List all client view_specific_employee($cid) public function view_specific_employee($cid) { $sq3 = "SELECT * FROM `employee` where cid='$cid'"; $qu3 = mysqli_query($this->conn, $sq3); return $qu3; } //Update Client Profile public function update_clientdata($val) { $sq3 = "update register set pname= '$val[0]', email= '$val[1]', phone= '$val[2]', address= '$val[3]', city= '$val[4]', state= '$val[5]', country= '$val[6]', c_cur= '$val[7]' where customer_id ='$val[8]'"; // $sq3 = "update register set pname= '$val[0]', email= '$val[1]', phone= '$val[2]', address= '$val[3].$val[4]', city= '$val[5]', state= '$val[6]', country= '$val[7]' where customer_id ='$val[8]'"; $qu3 = mysqli_query($this->conn, $sq3); $customer_id = $val[8]; if ($qu3) { $message = '<a href="../profile/company_profile.php?q=' . $_SESSION['cid'] . '"> ' . $_SESSION['type'] . ' #' . $_SESSION['cid'] . ' </a> updated data of <a href="../profile/profile.php?q=' . $customer_id . '"> Client #' . $customer_id . ' </a>'; $log_status = 'activity'; } else { $message = 'Updation in Client Data Failed by <a href="../profile/company_profile.php?q=' . $_SESSION['cid'] . '"> ' . $_SESSION['type'] . ' #' . $_SESSION['cid'] . ' </a>'; $log_status = 'error'; } $sqlog = "INSERT INTO log (`log_id`, `message`,`log_status`) VALUES('NULL', '$message','$log_status')"; $qulog = mysqli_query($this->conn, $sqlog); return $qu3; } //Reset Password and Send Email public function reset_sent($id, $cid, $x) { $sq1 = "SELECT * from admin_company where company_id = '$cid'"; $qu1 = mysqli_query($this->conn, $sq1); $row1 = mysqli_fetch_assoc($qu1); $gen_by_email = $row1['company_email']; $gen_by_name = $row1['name']; $gen_by_phone = $row1['phone']; $gen_by_logo = $row1['clogo']; $curl = $row1['company_domain']; $gen_by = $cid; $chars = "0123456789qwertyuiopasdfhjllzmnbxvc"; $password = substr(str_shuffle($chars), 0, 10); $passwd = $password; if ($x == 'company') { $sq = "SELECT * from admin_company where company_id = '$id'"; $qu = mysqli_query($this->conn, $sq); $row = mysqli_fetch_assoc($qu); $gen_to_email = $row['company_email']; $gen_to_name = $row['name']; $url = 'https://manage.' . $curl; // $gen_by = $id; $sq2 = "update admin_user set admin_pass= '$passwd' where company_id='$id'"; } else if ($x == 'client') { $sq = "SELECT * from register where customer_id = '$id'"; $qu = mysqli_query($this->conn, $sq); $row = mysqli_fetch_assoc($qu); $gen_to_email = $row['email']; $gen_to_name = $row['pname']; // $gen_by = $id; $sq2 = "update register set password= '$passwd' where customer_id='$id'"; $url = 'https://' . $curl; } $qu2 = mysqli_query($this->conn, $sq2); if ($qu2) { $email_send_url = '/assets/send_email.php?genby=' . $gen_by . '&temp_cat=7&genbyemail=' . $gen_by_email . '&genbyname=' . $gen_by_name . '&logo=' . $gen_by_logo . '&gentoname=' . $gen_to_name . '&gentoemail=' . $gen_to_email . '&genbyphone=' . $gen_by_phone . '&passwd=' . $passwd . '&url=' . $url . '&x=' . $x . '&id=' . $id; exec('/usr/bin/wget -O - -q -t 1 "https://' . $_SERVER['HTTP_HOST'] . '/' . addslashes($email_send_url) . '" > /dev/null &' ); if ($x == 'company') { $message = 'Password reset of <a href="../profile/company_profile.php?q=' . $id . '"> Company id #' . $id . ' </a> done successfully.'; } else if ($x == 'client') { $message = 'Password reset of <a href="../profile/profile.php?q=' . $id . '"> Client id #' . $id . ' </a> done successfully.'; } $log_status = 'activity'; $sqlog = "INSERT INTO log (`log_id`, `message`,`log_status`) VALUES('NULL', '$message','$log_status')"; $qulog = mysqli_query($this->conn, $sqlog); return 1; } } //Get Company Details public function profile_info($id) { $sq3 = "SELECT * from admin_company where company_id='$id'"; $qu3 = mysqli_query($this->conn, $sq3); return $qu3; } //Get 5 Recent Customers public function list_cust($id) { $sql3 = "SELECT * from register where company_id =$id order by customer_id desc LIMIT 5"; $qul3 = mysqli_query($this->conn, $sql3); return $qul3; } //Delete Company User public function user_delete($id) { $sq = "delete from admin_user where user_id='$id'"; $qu = mysqli_query($this->conn, $sq); $_SESSION['msg_iteration'] = 0; if ($qu) { $_SESSION['msg'] = 'User Deleted Successfully.'; $message = '<a href="../profile/company_profile.php?q=' . $_SESSION['cid'] . '"> ' . $_SESSION['type'] . ' #' . $_SESSION['cid'] . ' </a> has Deleted User #' . $id . ' Sucessfully.'; $log_status = 'activity'; } else { $_SESSION['err_msg'] = 'Something Went Wrong!'; $message = 'User Deletion Failed by <a href="../profile/company_profile.php?q=' . $_SESSION['cid'] . '"> ' . $_SESSION['type'] . ' #' . $_SESSION['cid'] . ' </a>'; $log_status = 'error'; } $sqlog = "INSERT INTO log (`log_id`, `message`,`log_status`) VALUES('NULL', '$message','$log_status')"; $qulog = mysqli_query($this->conn, $sqlog); header('location:staff_mgmt.php'); } //Get New Customers as per Company Id public function get_new_customers() { $sq = "SELECT * FROM `employee` order by cid desc LIMIT 5"; $qu1 = mysqli_query($this->conn, $sq); return $qu1; } // Get Company Profile as per domain name function company_profile($url) { $sq = "select * from admin_company inner join plan_table on admin_company.company_id= plan_table.company_id where company_domain ='$url'"; $qu = mysqli_query($this->conn, $sq); $row = mysqli_fetch_array($qu); return $row; } //Save Email Template Changes public function save_template($cid, $temp_id, $category_id) { $temp_code = $_POST['sourceCode']; $temp_code1 = preg_replace('!\s+!', ' ', $temp_code); $temp_code1 = str_replace("'", "\'", $temp_code1); $sq = "SELECT * FROM `email_template` WHERE `company_id`='$cid' and `category_id`='$category_id'"; $qu = mysqli_query($this->conn, $sq); if (mysqli_num_rows($qu) > 0) { $sq3 = "UPDATE `email_template` SET `template_code`= '$temp_code1' WHERE `template_id`= '$temp_id' and `company_id`='$cid'"; $qu3 = mysqli_query($this->conn, $sq3); } else { $sq3 = "INSERT INTO `email_template`(`template_id`, `template_code`, `category_id`, `company_id`) VALUES ('NULL','$temp_code1','$category_id','$cid')"; $qu3 = mysqli_query($this->conn, $sq3); $temp_id = mysqli_insert_id($this->conn); } header('location:viewemail.php?q=' . $temp_id); } //Get template Code as per Argument public function get_template_code($cid, $category_id) { $sq3 = "SELECT * FROM `email_template` WHERE company_id in( 1,$cid) and category_id = '$category_id' order by `company_id` desc"; $qu3 = mysqli_query($this->conn, $sq3); $qu = mysqli_fetch_assoc($qu3); return $qu; } //Send Due Invoice Reminder from cron function reminder_email($duration) { $customer_info = $this->select_due_invioces($duration, 'false'); foreach ($customer_info as $customer_val) { $customer_id = $customer_val['customer_id']; $pid = $customer_val['planid']; $domain = $customer_val['domain']; $product_id = $customer_val['product_id']; $company_id = $customer_val['company_id']; $invoice_no = $customer_val['invoice_no']; $gen_date = $customer_val['gen_date']; $due_date = $customer_val['due_date']; $pname = $customer_val['pname']; $email = $customer_val['email']; $total = $customer_val['total_due']; $company_info = $this->company_details($company_id); $cemail = $company_info['company_email']; $logo = $company_info['clogo']; $cphone = $company_info['phone']; $cname = $company_info['name']; $cdname = $company_info['company_domain']; $rcur = $company_info['cur']; $url = 'https://' . $cdname . '/account/viewinvoice.php?q=' . $invoice_no; $email_send_url = '/assets/send_email.php?cuid=' . $company_id . '&temp_cat=12&email=' . $email . '&pname=' . $pname . '&logo=' . $logo . '&cname=' . $cname . '&cemail=' . $cemail . '&cphone=' . $cphone . '&url=' . $url . '&iid=' . $customer_id . '&invoice_no=' . $invoice_no . '&gen_date=' . $gen_date . '&due_date=' . $due_date . '&cur=' . $rcur . '&total=' . $total; exec('/usr/bin/wget -O - -q -t 1 "https://' . $_SERVER['HTTP_HOST'] . '/' . addslashes($email_send_url) . '" > /dev/null &' ); $upq = "UPDATE `cron_activity` SET `overdue_reminder`=`overdue_reminder`+1 "; $upqu = mysqli_query($this->conn, $upq); } } // day count within dates public function dayCount($from, $to) { $first_date = strtotime($from); $second_date = strtotime($to); $offset = $second_date - $first_date; return floor($offset / 60 / 60 / 24); } // Send Support Email from Cron function reminder_support_email($duration) { $customer_info = $this->select_customers_for_supportemail($duration); foreach ($customer_info as $customer_val) { $customer_id = $customer_val['customer_id']; $company_id = $customer_val['company_id']; $pname = $customer_val['pname']; $email = $customer_val['email']; $company_info = $this->company_details($company_id); $cemail = $company_info['company_email']; $logo = $company_info['clogo']; $cphone = $company_info['phone']; $cname = $company_info['name']; $cdname = $company_info['company_domain']; $url = 'https://' . $cdname . '/account'; $email_send_url = 'assets/send_email.php?cuid=' . $company_id . '&temp_cat=14&email=' . $email . '&pname=' . $pname . '&logo=' . $logo . '&cname=' . $cname . '&cemail=' . $cemail . '&cphone=' . $cphone . '&url=' . $url . '&iid=' . $customer_id; exec('/usr/bin/wget -O - -q -t 1 "https://' . $_SERVER['HTTP_HOST'] . '/' . addslashes($email_send_url) . '" > /dev/null &' ); } } /* * Returns rows from the database based on the conditions * @param string name of the table * @param array select, where, order_by, limit and return_type conditions */ public function checkRow($conditions = array()) { $sql = 'SELECT * FROM mobile_numbers'; if (!empty($conditions) && is_array($conditions)) { $sql .= ' WHERE '; $i = 0; foreach ($conditions as $key => $value) { $pre = ($i > 0) ? ' AND ' : ''; $sql .= $pre . $key . " = '" . $value . "'"; $i++; } } $result = mysqli_query($this->conn, $sql); // $result = $this->db->query($sql); // return !empty($result->num_rows > 0)?true:false; return !empty(mysqli_num_rows($result) > 0) ? true : false; } /* * Insert data into the database * @param string name of the table * @param array the data for inserting into the table */ public function insert($data) { if (!empty($data) && is_array($data)) { $columns = ''; $values = ''; $i = 0; foreach ($data as $key => $val) { $pre = ($i > 0) ? ', ' : ''; $columns .= $pre . $key; $values .= $pre . "'" . $val . "'"; $i++; } $query = "INSERT INTO mobile_numbers (" . $columns . ") VALUES (" . $values . ")"; $insert = mysqli_query($this->conn, $query); return $insert ? mysqli_insert_id($this->conn) : false; // $query = "INSERT INTO ".$this->tblName." (".$columns.") VALUES (".$values.")"; // $insert = $this->db->query($query); // return $insert?$this->db->insert_id:false; } else { return false; } } /* * Update data into the database * @param string name of the table * @param array the data for updating into the table * @param array where condition on updating data */ public function update($data, $conditions) { if (!empty($data) && is_array($data)) { $colvalSet = ''; $whereSql = ''; $i = 0; foreach ($data as $key => $val) { $pre = ($i > 0) ? ', ' : ''; $colvalSet .= $pre . $key . "='" . $val . "'"; $i++; } if (!empty($conditions) && is_array($conditions)) { $whereSql .= ' WHERE '; $i = 0; foreach ($conditions as $key => $value) { $pre = ($i > 0) ? ' AND ' : ''; $whereSql .= $pre . $key . " = '" . $value . "'"; $i++; } } $query = "UPDATE mobile_numbers SET " . $colvalSet . $whereSql; $update = mysqli_query($this->conn, $query); return $update ? $this->db->affected_rows : false; } else { return false; } } public function redirect_add_employee() { if (isset($_POST['fill_form'])) { $_SESSION['zone'] = $_POST['zone']; $_SESSION['s_engineer'] = $_POST['s_engineer']; $_SESSION['ex_engineer'] = $_POST['ex_engineer']; $_SESSION['electry_city'] = $_POST['electry_city']; echo "<script>location.href='forms/add_customer.php';</script>"; } } public function add_electricity_house() { // $zone = $_POST['zone']; // $s_engineer = $_POST['s_engineer']; $ex_engineer = $_POST['ex_engineer']; $electrycity_house = $_POST['electrycity_house']; $h_electrycity_house = $_POST['h_electrycity_house']; $sq = "SELECT * FROM `executive_engineer` WHERE `ex_id` in (select ex_id from executive_engineer where ex_name='$ex_engineer')"; $ex_res = mysqli_query($this->conn, $sq); $result = mysqli_fetch_assoc($ex_res); if ($result) { $ex_id = $result['ex_id']; $sq = "INSERT INTO `electrycity_zone`(`ez_id`, `ex_id`, `electrycity_zone_name`, `h_electrycity_zone_name`) VALUES (NULL,'$ex_id','$electrycity_house','$h_electrycity_house')"; $qu = mysqli_query($this->conn, $sq); if ($qu) { $_SESSION['msg'] = 'Electricity House added Successfully.'; } else { $_SESSION['err_msg'] = 'Something Went Wrong!'; } } else { $_SESSION['err_msg'] = 'Something Went Wrong2!'; } echo '<meta http-equiv="refresh" content="0">'; } // public function resend_otp($phone) { // echo $phone; // // } public function resend_otp($numbers) { $error = 'no'; // Authorisation details. $username = "infosky@blogworm.in"; $hash = "49006f7b416e515543c5a5458df8e5e3ebf15a75f338804c6feb4dfdc6a19104"; // Config variables. Consult http://api.textlocal.in/docs for more info. //$test = "0"; $rndno = rand(10000, 99999); //// Data for text message. This is the text message data. //$sender = "TXTLCL"; // This is who the message appears to be from. // ////$numbers = $_POST["phone"];//"919120102338"; // A single number or a comma-seperated list of numbers //$message = "Your otp number for Globe India Infrastructure is : ".$rndno; //// 612 chars or less //// A single number or a comma-seperated list of numbers //$message = urlencode($message); //$data = "username=" . $username . "&hash=" . $hash . "&message=" . $message . "&sender=" . $sender . "&numbers=" . $numbers ; //$ch = curl_init('http://api.textlocal.in/send/?'); //curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //$result = curl_exec($ch); // This is the result from the API // ////Print error if any //if(curl_errno($ch)) //{ //echo 'error:' . curl_error($ch); //$error='yes'; //}else{ // $error='no'; //} //curl_close($ch); if ($error == 'yes') { $_SESSION['msg_err'] = 'Failed to send OTP!'; header("Location: otp.php"); } else { $_SESSION['msg_success'] = 'OTP sent successfully.'; //$_SESSION['name']=$_POST['name']; //$_SESSION['email']=$_POST['email']; $_SESSION['phone'] = $numbers; $_SESSION['otp'] = $rndno; header("Location: otp.php"); } } public function verify_otp() { $rno = $_SESSION['otp']; $phone = $_SESSION['phone']; $urno = $_POST['otpvalue']; if (!strcmp($rno, $urno)) { unset($_SESSION['otp']); session_unset(); $_SESSION['msg'] = "OTP Verified Successfully. Plase fill the form carefully."; $_SESSION['phone'] = $phone; header("Location: select_zone.php"); } else { $_SESSION['msg_err'] = "OTP does not not Match! Plase enter correct otp."; header("Location: otp.php"); } } public function change_application_status($status, $customer_id) { $approval_date = date('Y-m-d'); $approved_emp_no = 'GII' . date('Ymd') . rand(100, 1000); $sq3 = "UPDATE `employee` SET `application_status`='$status',`approval_date`='$approval_date',`approved_emp_no`='$approved_emp_no' WHERE `cid`='$customer_id'"; $qu3 = mysqli_query($this->conn, $sq3); return $qu3; } public function employee_phone($phone) { $sq = "SELECT * FROM `employee` where phone='$phone'"; $qu1 = mysqli_query($this->conn, $sq); // $res= mysqli_fetch_assoc($qu1); return $qu1; } public function update_employee($emp_id) { $fname = $_POST['f_name']; $mname = $_POST['m_name']; $lname = $_POST['l_name']; $fullname = $fname . ' ' . $mname . ' ' . $lname; $father_name = $_POST['father_name']; $mother_name = $_POST['mother_name']; // $phone = $_POST['phone']; // $phone2 = $_POST['phone2']; // $email = $_POST['email']; $dob = $_POST['dob']; // echo $emp_no ='GII' . date('Ymd') . rand(100, 1000); //for file name only $_POST['emp_no']; $emp_no = $_POST['emp_no']; // 'GII' . date('Ymd') . rand(100, 1000); //for file name only if ($_FILES["emp_img"]["name"] != '') { $target_dir = "../include/uploads/"; $t_dir = "include/uploads/"; // only for url image use in db $target_file = $target_dir . basename($_FILES["emp_img"]["name"]); $target_file1 = $t_dir . $emp_no . '.jpg'; $target_file1 = str_replace(' ', '+', $target_file1); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); // Check if image images is a actual image or fake image global $errtext; $check = getimagesize($_FILES["emp_img"]["tmp_name"]); if ($check !== false) { "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { $errtext = "File is not an image."; $uploadOk = 0; } // Check images size if ($_FILES["emp_img"]["size"] > 300000) { echo $errtext = "Sorry, your images is too large."; $uploadOk = 0; } // Allow certain images formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG" && $imageFileType != "GIF") { echo $errtext = "Sorry, only JPG, JPEG, PNG & GIF imagess are allowed."; $uploadOk = 0; } if (file_exists($target_file)) { chmod($target_file, 0755); //Change the file permissions if allowed unlink($target_file); //remove the file } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { "Sorry, your images was not uploaded."; // if everything is ok, try to upload images } else { if (move_uploaded_file($_FILES["emp_img"]["tmp_name"], $target_dir . $emp_no . ".jpg")) { $emp_img = $target_file . $_FILES["emp_img"]["tmp_name"]; $errtext = "The images " . basename($_FILES["emp_img"]["name"]) . " has been uploaded."; $x = 'ok'; } else { echo $errtext = "Sorry, there was an error uploading your images."; } // } if ($x == 'ok') { $sq = "UPDATE `employee` SET `customer_name`='$fullname',`first_name`='$fname',`middle_name`='$mname',`last_name`='$lname',`father_name`='$father_name',`mother_name`='$mother_name',`clogo`='$target_file1',`dob`='$dob' WHERE `cid`='$emp_id'"; } } } else { $x = 'ok'; if ($x == 'ok') { $sq = "UPDATE `employee` SET `customer_name`='$fullname',`first_name`='$fname',`middle_name`='$mname',`last_name`='$lname',`father_name`='$father_name',`mother_name`='$mother_name',`dob`='$dob' WHERE `cid`='$emp_id'"; } } if ($x == 'ok') { // echo $sq = "UPDATE `employee` SET `customer_name`='$fullname',`first_name`='$fname',`middle_name`='$mname',`last_name`='$lname',`father_name`='$father_name',`mother_name`='$mother_name',`clogo`='$target_file1',`dob`='$dob' WHERE `cid`='$emp_id'"; $qu = mysqli_query($this->conn, $sq); if ($qu) { $_SESSION['msg'] = 'Employee Personal Details Updated Successfully.'; // $_SESSION['emp_no'] = $emp_no; echo "<script>location.href='view_employee.php?q=$emp_id';</script>"; } else { $_SESSION['err_msg'] = 'Oops! Employee Detail Updation Failed.'; echo '<meta http-equiv="refresh" content="0">'; } } else { $_SESSION['err_msg'] = 'Error in Photo Upload due to ' . $errtext; echo '<meta http-equiv="refresh" content="0">'; } // echo '<meta http-equiv="refresh" content="0">'; } public function update_employee_upload($emp_id) { $image_type = $_POST['image_type']; // echo $emp_no ='GII' . date('Ymd') . rand(100, 1000); //for file name only $_POST['emp_no']; $emp_no = $_POST['emp_no']; // 'GII' . date('Ymd') . rand(100, 1000); //for file name only // if ($image_type == 'passbook') { // } $target_dir = "../include/temp_img_upload/"; $t_dir = "include/uploads/"; // only for url image use in db $target_file = $target_dir . basename($_FILES["emp_img"]["name"]); $target_file1 = $t_dir . $emp_no . $image_type . '.jpg'; $image_url = $target_file1 = str_replace(' ', '+', $target_file1); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); // Check if image images is a actual image or fake image global $errtext; $check = getimagesize($_FILES["emp_img"]["tmp_name"]); if ($check !== false) { "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { $errtext = "File is not an image."; $uploadOk = 0; } // Check images size if ($_FILES["emp_img"]["size"] > 300000) { echo $errtext = "Sorry, your images is too large."; $uploadOk = 0; } // Allow certain images formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG" && $imageFileType != "GIF") { echo $errtext = "Sorry, only JPG, JPEG, PNG & GIF imagess are allowed."; $uploadOk = 0; } if (file_exists($target_file)) { chmod($target_file, 0755); //Change the file permissions if allowed unlink($target_file); //remove the file } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { "Sorry, your images was not uploaded."; // if everything is ok, try to upload images } else { if (move_uploaded_file($_FILES["emp_img"]["tmp_name"], $target_dir . $emp_no . $image_type . ".jpg")) { $emp_img = $target_file . $_FILES["emp_img"]["tmp_name"]; $errtext = "The images " . basename($_FILES["emp_img"]["name"]) . " has been uploaded."; $x = 'ok'; } else { echo $errtext = "Sorry, there was an error uploading your images."; } } if ($x == 'ok') { $sq = "INSERT INTO `update_image`(`image_url`, `image_type`, `cid`) VALUES ('$image_url','$image_type','$emp_id')"; $qu = mysqli_query($this->conn, $sq); if ($qu) { $_SESSION['msg'] = 'Employee Image Updated Successfully.'; // $_SESSION['emp_no'] = $emp_no; // echo "<script>location.href='view_employee.php?q=$emp_id';</script>"; } else { $_SESSION['err_msg'] = 'Oops! Employee Detail Updation Failed.'; // echo '<meta http-equiv="refresh" content="0">'; } } else { $_SESSION['err_msg'] = 'Error in Photo Upload due to ' . $errtext; // echo '<meta http-equiv="refresh" content="0">'; } echo '<meta http-equiv="refresh" content="0">'; } public function change_image_status($status, $emp_id, $image_type) { $DATE = date("Y-m-d H:i:s"); $sq = "UPDATE `update_image` SET `img_status`='$status',`accepted_date`='$DATE' WHERE `cid`='$emp_id'"; $qu = mysqli_query($this->conn, $sq); if ($qu) { // $sq1 = "update employee e inner join update_image ui on e.cid=ui.cid //set e.clogo=ui.image_url, // e.col2=ui.col2, // e.col3=ui.col3;"; if ($image_type == 'updatephoto') { $column='clogo'; } else if ($image_type == 'voterid') { $column='identity_upload'; } else if ($image_type == 'drivinglicence') { $column='identity_upload'; } else if ($image_type == 'passport') { $column='identity_upload'; } else if ($image_type == 'pancard') { $column='pan_upload'; } else if ($image_type == 'passbook') { $column='passbook_upload'; } else if ($image_type == 'Skilled') { $column='skilled_upload'; } $sq1 = "update employee e inner join update_image ui on e.cid=ui.cid set e.$column=ui.image_url;"; $qu1 = mysqli_query($this->conn, $sq1); } return $qu1; } public function select_updated_upload() { $sq = "SELECT ui.*,customer_name,emp_no from `update_image` ui inner join employee e on e.cid=ui.cid where img_status='unaccepted'"; $result = mysqli_query($this->conn, $sq); while ($row = mysqli_fetch_assoc($result)) { $row1[] = $row; } return $row1; } } ?>