JezK
Edit File: functions-old.php
<?php class uflexitCustomer { public $db; function __construct() { include_once dirname(__FILE__) . '/uflexitConfig.php'; require_once dirname(__FILE__) . '/class.db.php'; $this->db = new DB(); } /** * function name: generateApiKey * decription: for generating random md5 hash token * developed by: lathif */ function generateApiKey() { return md5(uniqid(rand(), true)); } /** * function name: generateSecuredPassword * decription: hash password for users registration * developed by: lathif */ function generateSecuredPassword($password) { $passwordHash=''; $options = [ 'cost' => 12, ]; $passwordHash=password_hash($password, PASSWORD_BCRYPT, $options); return $passwordHash; } /** * function name: checkPasswordMatch * decription: check hash password in db match with given password or not * developed by: yamuna */ function checkPasswordMatch($password,$passwordHash) { $passIsValid = password_verify($password,$passwordHash); return $passIsValid; } /** * function name: checkEmailExistsOrNot * decription: This is for check email exists or not * developed by: lathif */ function checkEmailExistsOrNot($email) { $returnVal=0; $trimEmail=strip_tags($this->db->escape($email)); $query="select * from uflexit_users where email='".$trimEmail."'"; $count=$this->db->num_rows($query); if(isset($count) && $count>0) { $returnVal=1; } return $returnVal; } /** * function name: checkCompanyExists * decription: This is for check company exists or not * developed by: lathif */ function checkCompanyExists($companyName,$type) { $returnVal=0; $trimcompanyName=strip_tags($this->db->escape($companyName)); if($type==1) $query="select * from uflexit_company where company_name='".strtolower($trimcompanyName)."' and company_name!=''"; else $query="select * from uflexit_company where company_number='".strtolower($trimcompanyName)."' and company_number!=''"; $count=$this->db->num_rows($query); if(isset($count) && $count>0) { $returnVal=1; } return $returnVal; } /** * function name: checkPhoneExistsOrNot * decription: This is for check company exists or not * developed by: lathif */ function checkPhoneExistsOrNot($phone) { $returnVal=0; $trimPhone=strip_tags($this->db->escape($phone)); $query="select * from uflexit_users where mobile_number='".$trimPhone."'"; $count=$this->db->num_rows($query); if(isset($count) && $count>0) { $returnVal=1; } return $returnVal; } /** * function name: userSignup * decription: This is for signup customer and uflexit Admin * developed by: lathif,yamuna */ function userSignup($post,$role) { $returnVal=0; $company_name=$company_alter_name=$company_number=$first_name=$last_name=$designation=$location=$zip=$checkCompany=''; $country=0; //sql injections preventing if($role == 1 || $role == 4) { if(isset($post['company_name'])) $company_name=strip_tags($this->db->escape($post['company_name'])); $designation=strip_tags($this->db->escape($post['designation'])); $country=strip_tags($this->db->escape($post['country'])); if(isset($post['postalcode1'])) { $zip=strip_tags($this->db->escape($post['postalcode1'])); } if(isset($post['first_name'])) $first_name=strip_tags($this->db->escape(trim($post['first_name']))); if(isset($post['last_name'])) $last_name=strip_tags($this->db->escape(trim($post['last_name']))); $email=strip_tags($this->db->escape(trim($post['email']))); $password=strip_tags($this->db->escape(trim($post['password']))); $mobile_number=strip_tags($this->db->escape(trim($post['mobile_number']))); $mobile_country_code = strip_tags($this->db->escape(trim($post['mobile_country_code']))); $city=strip_tags($this->db->escape(trim($post['city']))); $address=strip_tags($this->db->escape(trim($post['address']))); } if($role == 3) { if(isset($post['postalcode'])) { $zip=strip_tags($this->db->escape($post['postalcode'])); } if(isset($post['customer_first_name'])) $first_name=strip_tags($this->db->escape(trim($post['customer_first_name']))); if(isset($post['customer_last_name'])) $last_name=strip_tags($this->db->escape(trim($post['customer_last_name']))); $email=strip_tags($this->db->escape(trim($post['email']))); $password=strip_tags($this->db->escape(trim($post['customerPassword']))); $mobile_number=strip_tags($this->db->escape(trim($post['customer_mobile_number']))); $mobile_country_code = strip_tags($this->db->escape(trim($post['mobile_country_code1']))); $city=strip_tags($this->db->escape(trim($post['customer_city']))); $address=strip_tags($this->db->escape(trim($post['customer_address']))); $location=strip_tags($this->db->escape($post['customer_location'])); } // if(isset($post['company_alter_name'])) // $company_alter_name=strip_tags(mysqli_real_escape_string($this->con,trim($post['company_alter_name']))); // if(isset($post['warehouse_number'])) // $company_number=strip_tags(mysqli_real_escape_string($this->con,trim($post['warehouse_number']))); //sql injections preventing $convertedPassword=$this->generateSecuredPassword($password); if($role==1) $checkCompany=$this->checkCompanyExists($company_name,1); //$checkCompanyNumber=$this->checkCompanyExists($company_number,2); $checkEmail=$this->checkEmailExistsOrNot($email); $checkPhone=$this->checkPhoneExistsOrNot($mobile_number); if($checkCompany==1) { $returnVal=1; } else if($checkEmail==1) { $returnVal=2; } else if($checkPhone==1) { $returnVal=3; } // else if($company_number==1) // { // $returnVal=5; // } else { $createdDate=gmdate("Y-m-d H:m:i"); $emailactiveToken=$this->generateApiKey(); $query="insert into uflexit_users (email, mobile_number, role_id, designation, password, first_name, last_name, city_name, address, country_id, postal_code, location, email_active_token, created_date,mobile_country_code) VALUES('".$email."','".$mobile_number."','".$role."','".$designation."','".$convertedPassword."','".$first_name."','".$last_name."','".$city."','".$address."','".$country."','".$zip."','".$location."','".$emailactiveToken."','".$createdDate."','".$mobile_country_code."') RETURNING user_id"; $row=$this->db->query($query); $lastId=pg_fetch_row($row); $lastInsertId=$lastId[0]; if($row) { if($role ==1 || $role==4) { $createCompany=$this->createCompany($company_name,$city,$address,$role,$lastInsertId); //exit; } $this->sendEmailUserAndSuperAdmin($post,$emailactiveToken,$role);//customer Email //$this->sendEmailUserAndSuperAdmin($post,$emailactiveToken,3); //SuperAdmin Email $returnVal=4; } } return $returnVal; } /** * function name: createCompany * decription: This is for creating new company * developed by: lathif */ function createCompany($company_name,$city,$address,$role,$userId) { $returnVal=0; $createdDate=gmdate("Y-m-d H:m:i"); // company_alter_name='".strtolower($company_alter_name)."', // company_number='".strtolower($company_number)."', $query="insert into uflexit_company (company_name, role_id, user_id, city_name, address, created_date) VALUES ('".strtolower($company_name)."', '".$role."', '".$userId."', '".$city."', '".$address."', '".$createdDate."')"; //echo $query;exit; $row=$this->db->query($query); if($row) { $returnVal=1; } return $returnVal; } /** * function name: emailActivation * decription: This is for activating email for customer or admin * developed by: lathif */ function emailActivation($token) { $data=array(); $trimToken=strip_tags($this->db->escape(trim($token))); $query="select * from uflexit_users where email_active_token='".$trimToken."' and email_active=0"; $fetch = $this->db->get_row($query); if($fetch) { $query1="update uflexit_users set email_active=1 where user_id='".$fetch['user_id']."'"; //email_active_token='' $row1=$this->db->query($query1); if($row1) { $data['status']=1; $data['role_id']=$fetch['role_id']; } } else { $data['status']=2; } return $data; } /** * function name: sendEmailUserAndSuperAdmin * decription: This is for sending email to customer either amdin or user * developed by: lathif */ function sendEmailUserAndSuperAdmin($post,$emailToken=null,$role) { $baseUrl=HOSTPATH;//from config file $fromName = 'Uflexit'; $from='karimunnisa@krify.net'; $to=$post['email']; // if($role==1 || $role==2 || $role==3 || $role==4) // { $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= 'From: ' . $fromName . '<' . $from . '>' . "\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $headers .= 'Cc: ' .$from. "\r\n"; $headers .= 'Bcc: ' .$from. "\r\n"; $subject='Email Activation from Uflexit'; $customerContent=''; if($role!=2 && $role!=3) { $customerContent=' <tr style="padding:10px !important;display:flex;width:100%;color: #000;word-break: break-word;justify-content: space-evenly;"> <td style="width:45%;font-weight:bold;text-align:center" >Company</td> <td style="width: 5%;">:</td> <td style="width: 50%;">' . $post['company_name'] . '</td> </tr>'; } $customerContent.='<tr style="padding:10px !important;display:flex;width:100%;color: #000;word-break: break-word; justify-content: space-evenly;"> <td style="width:45%;font-weight:bold;text-align:center" >Email</td> <td style="width: 5%;">:</td> <td style="width: 50%;">' . $post['email'] . '</td> </tr> <tr style="padding:10px !important;display:flex;width:100%;color: #000;word-break: break-word;justify-content: space-evenly;"> <td style="width:45%;font-weight:bold;text-align:center">Password</td> <td style="width: 5%;">:</td> <td style="width: 50%;">' . $post['password'] . '</td> </tr> <tr style="padding:10px !important;display:flex;width:100%;color: #000;word-break: break-word;justify-content: space-evenly;"> <td style="width:45%;font-weight:bold;text-align:center">Phone number</td> <td style="width: 5%;">:</td> <td style="width: 50%;">' .$post['mobile_number'] . '</td> </tr> <tr style="padding:10px !important;display:flex;width:100%;color: #000;word-break: break-word;justify-content: space-evenly;"> <td style="width:45%;font-weight:bold;text-align:center">Activate Your account</td> <td style="width: 5%;">:</td> <td style="width: 50%;"><a href="'.$baseUrl.COMMONPATH.'emailverification.php?etoken='.$emailToken.'" target="_blank">Activate</a></td> </tr> '; //} // else // { // $headers = "MIME-Version: 1.0" . "\r\n"; // $headers .= 'From: New Registration'.'<' . $to . '>' . "\r\n"; // $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; // $headers .= 'Cc: ' .$to. "\r\n"; // $headers .= 'Bcc: ' .$to. "\r\n"; // $subject='New user Registered in Uflexit'; // $customerContent=''; // if(isset($post['company_name'])) // { // $customerContent=' // <tr style="padding:10px !important;display:flex;width:100%;color: #000;word-break: break-word;justify-content: space-evenly;"> // <td style="width:45%;font-weight:bold;text-align:center" >Company</td> // <td style="width: 5%;">:</td> // <td style="width: 50%;">' . $post['company_name'] . '</td> // </tr>'; // } // $customerContent.=' // <tr style="padding:10px !important;display:flex;width:100%;color: #000;word-break: break-word;justify-content: space-evenly;"> // <td style="width:45%;font-weight:bold;text-align:center">Phone number</td> // <td style="width: 5%;">:</td> // <td style="width: 50%;">' .$post['mobile_number'] . '</td> // </tr> // <tr style="padding:10px !important;display:flex;width:100%;color: #000;word-break: break-word;justify-content: space-evenly;"> // <td style="width:45%;font-weight:bold;text-align:center" >Email</td> // <td style="width: 5%;">:</td> // <td style="width: 50%;">' . $post['email'] . '</td> // </tr> // '; // } $htmlContent = ' <html> <head> <title>Uflexit WareHouse Service</title> </head> <body> <div> <div style="text-align:center;width: 550px;margin: 40px auto;border: 2px solid #2157c9;border-radius: 28px;"> <div style="padding:10px"> <img src="'.$baseUrl.MAILSLOGOPATH.'" alt="Website Change Request" alt="Website Change Request"/> </div> <div style="color: #2157c9;font-size: 24px;text-align:center !important;font-weight: 600;">Registration Details</div> <div style="margin:15px;padding:20px !important;"> <hr style="border: 1px solid #2157c9;"/> <table style="width: 100%;"> <tbody style="overflow:auto;font-size: 16px;"> '.$customerContent.' </tbody> </table> <hr style="border: 1px solid #2157c9;"/> <footer> <h3 style="color: #2157c9;font-size: 18px;"><br/>Thanks & Regards<br/> Uflexit Team</h3> </footer> </div> </div> </div> </body> </html>'; // echo "<br/>"; // echo $htmlContent;exit; $sent_mail_customer = mail($to, $subject, $htmlContent, $headers,"-f".$from); //mail to customer // echo $sent_mail_customer; $sent_mail_admin = mail($from, $subject, $htmlContent, $headers); //mail to Admin // echo $sent_mail_admin;exit; return true; } /** * function name: userLogin * decription: This is for login both admin,subadmin and user * developed by: yamuna */ function userLogin($post,$type=NULL) { /** * type * 1-WareHouse Admin * 2-WareHouse Sub Admin * 3-WareHouse individual customer * 4-WareHouse business customer */ $returnVal = array(); $subQuery = ""; if($type!=NULL) { $subQuery=" AND role_id='".$type."'"; } $email=strip_tags($this->db->escape(trim($post['email']))); $password=strip_tags($this->db->escape(trim($post['password']))); $query="SELECT * FROM uflexit_users WHERE email='".$email. "' ".$subQuery; $loginDetails = $this->db->get_row($query); if ($loginDetails) { if($this->checkPasswordMatch($password,$loginDetails['password'])) { if ($loginDetails['email_active'] == 1) { $token = $this->generateApiKey(); $query = "update uflexit_users set token = '".$token."' where user_id = ".$loginDetails['user_id']; $cmd = $this->db->get_row($query); $loginDetails['token']=$token; $returnVal['details'] = $loginDetails; $returnVal['status'] = 1; //success } else if ($loginDetails['email_active'] == 0) { $returnVal['status'] = 3; //email verfication pending } } else{ $returnVal['status'] = 2; //password wrong } } return $returnVal; } /** * function name: getCountryList * decription: This is for getting all countries in uflexit_countries table * developed by: yamuna */ function getCountryList() { $data=array(); $query="SELECT * FROM uflexit_countries"; return $this->db->get_results($query); } /** * function name: forgotPassword * decription: forgotPassword functionality * developed by: yamuna */ function forgotPassword($post) { $returnValue = 0; $emailactiveToken=$this->generateApiKey(); $email=strip_tags($this->db->escape(trim($post['email']))); $query="SELECT * FROM uflexit_users WHERE email='" .$email. "'"; $result = $this->db->get_row($query); if($result) { $this->sendForgetPasswordMail($post['email'],$result['email_active_token']); $returnValue = 1; } return $returnValue; } function sendForgetPasswordMail($email,$emailToken=null) { $baseUrl=HOSTPATH; //config file $fromName = 'Uflexit'; $from='support@uflexit.com'; $to=$email; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= 'From: ' . $fromName . '<' . $from . '>' . "\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $headers .= 'Cc: ' .$from. "\r\n"; $headers .= 'Bcc: ' .$from. "\r\n"; $subject='Forget Password from Uflexit'; $customerContent=' <tr style="padding:10px !important;display:flex;width:100%;color: #000;word-break: break-word;justify-content: space-evenly;"> <td style="width:45%;font-weight:bold;text-align:center">change Your password</td> <td style="width: 5%;">:</td> <td style="width: 50%;"><a href="' . $baseUrl .COMMONPATH.'/resetPassword.php?etoken='.$emailToken.'"" target="_blank">Reset Password</a></td> </tr> '; $htmlContent = ' <html> <head> <title>Uflexit WareHouse Service</title> </head> <body> <div><img src="' . $baseUrl . '/uflexit_web_new/images/loginlogo.png"</div> <div style="text-align:center;width: 550px;margin: 40px auto;border: 2px solid #2157c9;border-radius: 28px;"> <div style="color: #2157c9;font-size: 24px;text-align:center !important;font-weight: 600;padding-top:10px;">Reset your password by Clicking below link</div> <div style="margin:15px;padding:20px !important;"> <hr style="border: 1px solid #2157c9;"/> <table style="width: 100%;"> <tbody style="overflow:auto;font-size: 16px;"> '.$customerContent.' </tbody> </table> <hr style="border: 1px solid #2157c9;"/> <footer> <h3 style="color: #2157c9;font-size: 18px;"><br/>Thanks & Regards<br/> Uflexit Team</h3> </footer> </div> </div> </body> </html>'; //exit; //echo "<br/>"; $sent_mail_customer = mail($to, $subject,$htmlContent,$headers,"-f".$from); //mail to forget password user return true; } /** * function name: changePassword * decription: This is for forgetPassword for user and admin * developed by: yamuna */ function changePassword($post) { //$returnVal=0; $returnVal = array(); $password=strip_tags($this->db->escape(trim($post['password']))); $cnfrmPassword=strip_tags($this->db->escape(trim($post['cnfrmPassword']))); $token=strip_tags($this->db->escape(trim($post['token']))); $query="SELECT * FROM uflexit_users WHERE email_active_token='" .$token. "'"; $result = $this->db->get_row($query); if($result) { if($password == $cnfrmPassword) { $convertedPassword=$this->generateSecuredPassword($password); $query1="UPDATE uflexit_users SET password='$convertedPassword' WHERE email_active_token='$token'"; $row1=$this->db->query($query1); if($row1) { $returnVal['status'] = 1; //success $returnVal['role'] = $result['role_id']; } } else { $returnVal['status'] = 0; //password not match $returnVal['role'] = $result['role_id']; } } return $returnVal; } function updatePassword($post) { //$returnVal=0; // echo "kiran";exit; $returnVal = array(); $password=strip_tags($this->db->escape(trim($post['password']))); $cnfrmPassword=strip_tags($this->db->escape(trim($post['cnfrmPassword']))); $token=strip_tags($this->db->escape(trim($post['token']))); $query="SELECT * FROM uflexit_users WHERE token='" .$token. "'"; $result = $this->db->get_row($query); if($result) { // echo "kiran";exit; if($password == $cnfrmPassword) { $convertedPassword=$this->generateSecuredPassword($password); $query1="UPDATE uflexit_users SET password='$convertedPassword' WHERE token='$token'"; $row1=$this->db->query($query1); if($row1) { $returnVal['status'] = 1; //success } } else { $returnVal['status'] = 0; //password not match } } return $returnVal; } /** * function name: usermng * decription: usermng functionality * developed by: Ramyakrishna */ function userCustomerEdit($post){ $returnVal=0; $first_name = strip_tags($this->db->escape(trim($post['first_name']))); $last_name = strip_tags($this->db->escape(trim($post['last_name']))); $email = strip_tags($this->db->escape(trim($post['email']))); $address = strip_tags($this->db->escape(trim($post['address']))); $city_name = strip_tags($this->db->escape(trim($post['city_name']))); $mobile_number = strip_tags($this->db->escape(trim($post['mobile_number']))); if(isset($post['password']) && !empty($post['password'])){ $customer_password = strip_tags($this->db->escape(trim($post['password']))); $convertedPassword=$this->generateSecuredPassword($customer_password);} $checkEmail=$this->checkEmailExistsOrNot($email); $checkPhone=$this->checkPhoneExistsOrNot($mobile_number); $fileName = $_FILES["formUpload"]['name']; $createdDate = gmdate("Y-m-d H:m:i"); $emailactiveToken=$this->generateApiKey(); //echo "hiii"; if(!empty($post['password'])){ $query="update uflexit_users set mobile_number='".$mobile_number."', password='".$convertedPassword."', first_name='".$first_name."', last_name='".$last_name."', city='".$city."', address='".$address."' where email='".$email."'"; }else if($fileName){ $fileName = explode(".",$fileName); // print_r( $fileName); $fileName = $fileName[0].time().".".$fileName[1]; $target_dir = "../uploads/subadmin_photos/".$fileName; // exit; if (move_uploaded_file($_FILES["formUpload"]["tmp_name"], $target_dir)) { echo "file uploaded succesfully"; } else{ echo "there was an error"; } $query="update uflexit_users set mobile_number='".$mobile_number."', first_name='".$first_name."', last_name='".$last_name."', city_name='".$city_name."', address='".$address."', upload_pic='".$fileName."' where email='".$email."'"; }else{ $query="update uflexit_users set mobile_number='".$mobile_number."', first_name='".$first_name."', last_name='".$last_name."', city_name='".$city_name."', address='".$address."', upload_pic='".$fileName."' where email='".$email."'"; } $row=$this->db->query($query); $lastInsertId=$this->db->lastid($row); if($row) { $returnVal=3; }else{ $returnVal=4; } return $returnVal; } /** * function name: usermng * decription: usermng getting details functionality * developed by: Ramyakrishna */ function getCustomerDetails($email) { $data=array(); $extraQuery=''; if($email!=''){ $trimEmail=@strip_tags($this->db->escape(trim($email))); $extraQuery="email='".$trimEmail."'"; $query="SELECT * FROM uflexit_users where 1=1 and $extraQuery"; return $this->db->get_results($query); } return $data; } function getcities_function($country_id){ $query="SELECT * FROM uflexit_cities WHERE country_id=".$country_id; $cities = $this->db->get_results($query); return $cities; } function checkPhoneExistsOrNotForAjax($phone) { $returnVal= 0; $trimPhone=strip_tags($this->db->escape(trim($phone))); $query="select * from uflexit_users where mobile_number='".$trimPhone."'"; $returnVal = $this->db->get_row($query); return $returnVal; } function get_currency($country_id){ $query="SELECT * FROM uflexit_countries where country_id=".$country_id; $currencies=$this->db->get_results($query); return $currencies; } /** * decription: This is for Email checking for newsletter subcription * developed by: Surendra */ function checkNewsLetterEmailExistorNot($email) { $returnVal=0; $trimEmail=strip_tags($this->db->escape(trim($email))); $query="select * from uflexit_newsletter where email='".$trimEmail."'"; $returnVal = $this->db->get_row($query); return $returnVal; } /** * function name: Newsletter Email insertion * decription: This is for inserting Email for newsletter subcription * developed by: Surendra */ function insertNewsLetterEmail($email) { $returnVal=0; $createdDate = gmdate("Y-m-d H:m:i"); $trimEmail=strip_tags($this->db->escape(trim($email))); $query="select * from uflexit_newsletter where email='".$trimEmail."'"; $row = $this->db->get_row($query); if($row) { $returnVal=1; } else { $trimEmail=strip_tags($this->db->escape(trim($email))); $query1="INSERT INTO uflexit_newsletter (email,created_date) VALUES('".$trimEmail."','".$createdDate."')"; $row1 = $this->db->query( $query1); if($row1) { $returnVal=2; } } return $returnVal; } /** * function name: TESTIMONALS * decription: Customer testimonals display * developed by: Veeranna Chowdary */ function testimonial(){ $testimonial_data=array(); $query= "select * from uflexit_users where role_id='3' or role_id='4'"; // echo $query;exit; $row1=$this->db->get_row($query); // print_r(count($row1));exit; if($row1>0) { foreach($row1 as $rowdata) { $data['user_id']=$row1['user_id']; $data['first_name']=$row1['first_name']; $data['last_name']=$row1['last_name']; $data['created_date']=$row1['created_date']; $testimonial_data[]=$data; } } // if($row1){ // $data['user_id']=$row1['user_id']; // $data['first_name']=$row1['first_name']; // $data['last_name']=$row1['last_name']; // $data['created_date']=$row1['created_date']; // $testimonial_data[]=$data; // } return $testimonial_data; } function usersData(){ $testimonial_data=$this->testimonial(); $data1 = []; $dataa = []; foreach($testimonial_data as $value){ $data1['first_name'] = $value['first_name']; $data1['last_name'] = $value['last_name']; $data1['user_id'] = $value['user_id']; $data1['created_date']=$value['created_date']; $query1= "select * from uflexit_testimonial where user_id='".$value['user_id']."'"; $row1=$this->db->get_row($query1); if($row1){ $data1['message'] = $row1['message']; } else{ $query= "insert into uflexit_testimonial (user_id,created_date) values('".$value['user_id']."','".$value['created_date']."')"; $row=$this->db->query($query); } $dataa[] = $data1; } return $dataa; } /** * function name: getWarehouseDealList * decription: fetching WarehouseDealList * developed by: gowtham */ function getWarehouseDealList($id,$productwareHouseDeals){ $warehouseid=strip_tags($this->db->escape(trim($id))); $query="select choosen_meta_value from uflexit_warehouse_meta where warehouse_id=$id and meta_key='productwareHouseDeals'"; $data = $this->db->get_results($query); $productsarray=[]; $productsarray=$data[0]['choosen_meta_value']; $query1="select deal_name,deal_id from uflexit_warehouse_deals where deal_id in ($productsarray)"; $productsdata = $this->db->get_results($query1); return $productsdata; } /** * function name: getWarehouseType * decription: fetching warehouse type like space or pallet * developed by: gowtham */ function getWarehouseType($id,$wareHousePriceType){ $warehouseid=strip_tags($this->db->escape(trim($id))); $query="select choosen_meta_value from uflexit_warehouse_meta where warehouse_id=$id and meta_key='$wareHousePriceType'"; $data = $this->db->get_results($query); $productsarray=[]; $productsarray=$data[0]['choosen_meta_value']; $query1="select pricetype_id,pricetype_name from uflexit_warehouse_type where pricetype_id in ($productsarray)"; $warehousetypedata = $this->db->get_results($query1); return $warehousetypedata; } /** * function name: getWarehouseData * decription: fetching warehouse details * developed by: gowtham */ function getWarehouseData($id){ $warehouseid=strip_tags($this->db->escape(trim($id))); $query="select umw.warehouse_name,umw.warehouse_city,umw.warehouse_address ,uc.country_name from uflexit_countries as uc JOIN uflexit_master_warehouse as umw ON uc.country_id=warehouse_country_id where umw.warehouse_id=$warehouseid"; $data = $this->db->get_row($query); return $data; } function warehouseRating($postdata){ $warehouseRating=strip_tags($this->db->escape(trim($postdata['rating']))); $query="update uflexit_request_quote set warehouse_rating=$warehouseRating ,rating_status=1 where warehouse_id=71 AND quotation_status=3 returning *"; $warehouseratingdata = $this->db->get_row($query); $ratingStatus=$warehouseratingdata['rating_status']; return $ratingStatus; } /** * function name: requestQoute * decription: Updating subadmin details by admin * developed by: Surendra */ function productDealList($id=null){ $data=array(); $extraQuery=''; if((int)$id) { $extraQuery='where deal_id='.$id; } $query="select deal_id,deal_name from uflexit_warehouse_deals $extraQuery order by deal_name asc"; $data = $this->db->get_results($query); return $data; } function requestQuote($post,$session_id){ $productwareHouseDeals = implode(',', $post['productwareHouseDeals']); // echo $session_id; $response=''; $userid=$session_id; $warehouseid=$post['warehouse_id']; echo $warehouseid; $rand=time(); $select_type=strip_tags($this->db->escape(trim($post['pallet_or_space_type']))); if(isset($_POST['pallet']) && $_POST['pallet']!='' ){ $num_of_pallets_or_space=strip_tags($this->db->escape(trim($post['pallet']))); }else{ $num_of_pallets_or_space=strip_tags($this->db->escape(trim($post['space']))); } $from_date= date('Y-m-d',strtotime(strip_tags($this->db->escape(trim($post['from_date']))))); $to_date= date('Y-m-d',strtotime(strip_tags($this->db->escape(trim($post['to_date']))))); $total_days=strip_tags($this->db->escape(trim($post['total_days']))); $product_deals=strip_tags($this->db->escape(trim($productwareHouseDeals))); $description=strip_tags($this->db->escape(trim($post['description']))); $currency_type=strip_tags($this->db->escape(trim($post['currency_type']))); $expected_rate=strip_tags($this->db->escape(trim($post['currency']))); // if(isset($_POST['jordn']) && $_POST['jordn']!='' ){ // $currency=strip_tags($this->db->escape(trim($post['jordn']))); // } // else if(isset($_POST['uae']) && $_POST['uae']!=''){ // $currency=strip_tags($this->db->escape(trim($post['uae']))); // }else if(isset($_POST['saudi']) && $_POST['saudi']!=''){ // $currency=strip_tags($this->db->escape(trim($post['saudi']))); // } // echo $product_deals; $wrow = $this->db->get_row("SELECT * FROM uflexit_master_warehouse WHERE warehouse_id=".(int)$warehouseid); $whadminid=$wrow["created_by"]; $query="insert into uflexit_request_quote (storage_type,user_id,warehouse_id,choosen_pallets_space,from_date,to_date,num_of_days,choosen_deals,quotation_rand_num,whadmin_id,customer_description,currency_type,expected_rate) values('$select_type','$userid','$warehouseid','$num_of_pallets_or_space','$from_date','$to_date','$total_days','$product_deals','$rand','$whadminid','$description',$currency_type,$expected_rate) "; echo $query; $row=$this->db->query($query); if($row){ $response=1; } else{ $response= 0; } return $response; } function QuoteList(){ $data=array(); $query="SELECT * FROM uflexit_request_quote WHERE user_id=".(int)$_SESSION['user_id']; $data=$this->db->get_results($query); return $data; } function setFlashMessage($msg,$flag='success'){ $_SESSION['msg'] = $msg; $_SESSION['msg_flag'] = $flag; } function flashMessage(){ if (isset($_SESSION['msg']) && strlen(trim($_SESSION['msg']))) { echo '<div class="alert alert-'.$_SESSION['msg_flag'].'">'.$_SESSION['msg'].'</div>'; unset($_SESSION['msg']); unset($_SESSION['msg_flag']); } } function redirect($path){ die("<script>window.location.href='".$path."'</script>"); } function get_price($price){ echo '₹'.number_format((float)$price,2); } function asnsubmit($post){ //print_r($post);exit; //Array ( [quote_id] => 4 [request_type] => test type [user_id] => 32 [customertype] => business [warehouse_name] => kakinad [warehouse_type] => Gold [date] => 28-12-2020 [time] => 22:25 [itemcode] => Array ( [0] => 001 [1] => 002 ) [item_desc] => Array ( [0] => test desc [1] => test desc2 ) [qty] => Array ( [0] => 10 [1] => 20 ) [ref_number] => Array ( [0] => ref 001 [1] => ref 002 ) [cost] => Array ( [0] => 1000 [1] => 500 ) [pallet_no] => Array ( [0] => 001pallet no [1] => 002 pallet no ) [asnsubmit] => Create ASN ) $createdDate=gmdate("Y-m-d H:m:i"); $que = "insert into uflexit_asn_request (warehouse_id,request_type,quotation_id,user_id,customer_type,price,date,time,created_date,created_by) VALUES (".$this->db->escape(trim($post['warehouse_id'])).",'".$this->db->escape(trim($post['request_type']))."',".$this->db->escape(trim($post['quote_id'])).",".$this->db->escape(trim($post['user_id'])).",'".$this->db->escape(trim($post['customertype']))."','".$this->db->escape(trim($post['quote_value']))."','".$this->db->escape(trim($post['date']))."','".$this->db->escape(trim($post['time']))."','".$createdDate."','".$_SESSION['user_id']."')"; $res = $this->db->query($que); // print_r($res); if($res){ $sel = "select * from uflexit_asn_request order by asn_id desc"; $result = $this->db->get_row($sel); // print_r($result);echo '<br/>'; $lastId=$result['asn_id']; for($i=0;$i<count($_POST['itemcode']);$i++) { $query = "insert into uflexit_mini_goods_track (item_code,item_description,item_quantity,price,warehouse_id,warehouse_type,pallet_space_num,user_id,quotation_id,created_date,ref_number,asn_no) VALUES ('".$this->db->escape(trim($post['itemcode'][$i]))."','".$this->db->escape(trim($post['item_desc'][$i]))."','".$this->db->escape(trim($post['qty'][$i]))."','".$this->db->escape(trim($post['cost'][$i]))."','".$this->db->escape(trim($post['warehouse_id']))."','".$this->db->escape(trim($post['warehouse_type']))."','".$this->db->escape(trim($post['pallet_no'][$i]))."','".$this->db->escape(trim($post['user_id']))."','".$this->db->escape(trim($post['quote_id']))."','".$createdDate."','".$this->db->escape(trim($post['ref_number'][$i]))."','".$this->db->escape(trim($lastId))."')"; //echo '<br/>'; $res = $this->db->query($query); } return '1'; } //exit; // echo '<br/>'; } function savequationrate($post) { $wrow = $this->db->get_row("SELECT * FROM uflexit_request_quote WHERE quotation_id=".(int)$post['quotation_id']); //echo "SELECT * FROM uflexit_master_warehouse WHERE warehouse_id=".(int)$wrow['warehouse_id']; $wrow2 = $this->db->get_row("SELECT * FROM uflexit_master_warehouse WHERE warehouse_id=".(int)$wrow['warehouse_id']); $whadminid=$wrow2["created_by"]; //insert into uflexit_request_quote_track (quotation_id,admin_id,change_datetime,expected_rate,quotation_status,closed_status,"whAdmin_description",customer_description,whadmin_id) VALUES(7,8,'2020-12-25 16:16:16','500',0,0,'','Test PPPP',0) $query="insert into uflexit_request_quote_track (quotation_id,admin_id,change_datetime,expected_rate,quotation_status,closed_status,".'"'."whAdmin_description".'"'.",customer_description,whadmin_id) VALUES(".$post['quotation_id'].",".$post['uid'].",'".date('Y-m-d H:i:s')."','".$post['expected_rate']."',".$post['quotation_status'].",0,'','".$post['whadmin_description']."',$whadminid)"; $row=$this->db->query($query); $query2="update uflexit_request_quote set expected_rate='".$post['expected_rate']."', quotation_status='".$post['quotation_status']."' where quotation_id=".$post['quotation_id'].""; $row=$this->db->query($query2); if($query2) { $returnVal=1; } return $returnVal; } /** * function name: isValidApiKey * decription: Updating subadmin details by admin * developed by: Surendra */ function isValidApiKey($token) { $query = "select * from uflexit_users where token = '".$token."'"; $data=$this->db->get_results($query); return $data; } } ?>