JezK
Edit File: functions-old.php
<?php // include_once("../app/checkSession.php"); @session_start(); class uflexitAdmin { public $db; function __construct() { // session_start(); 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: getBaseURL * decription: for get rul purpose * developed by: lathif */ function getBaseURL() { $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $url = ($protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); $url1 = explode('uflexit_web_new', $url); // print_r($url1);exit; return $url1[0]; } /** * 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: generateAutoWareHouseNumber * decription: It will generate auto generate number as per client given input like WH-1000 onwards * developed by: lathif */ function generateAutoWareHouseNumber() { $wareHouseNumber=''; $query="select warehouse_number from uflexit_master_wareHouse where warehouse_number!='' order by warehouse_id desc limit 1"; $fetch = $this->db->get_row($query); if($fetch) { $expNum=$fetch['warehouse_number']; $expData=explode("-",$expNum); $numberNow=$expData[1]+1; $wareHouseNumber="WH-".$numberNow; } else { $wareHouseNumber="WH-1000"; } return $wareHouseNumber; } /** * function name: checkWHNOExistsOrNot * decription: This is checking wareHouse number exists or not before inserting into database * developed by: lathif */ function checkWHNOExistsOrNot($wareHouseNumber) { $returnVal=''; $clWHNo=strip_tags($this->db->escape(trim($wareHouseNumber))); $query="select * from uflexit_master_wareHouse where warehouse_number!='' and warehouse_number='".$clWHNo."'"; $row = $this->db->get_row($query); if($row) { $returnVal=$this->generateAutoWareHouseNumber(); } else { $returnVal=$clWHNo; } return $returnVal; } /** * function name: getWareHouseDeals * decription: This is used for bring all the getWareHouse deals * developed by: lathif */ function getWareHouseDeals($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"; $query="select deal_id,deal_name from uflexit_warehouse_deals $extraQuery"; $data = $this->db->get_results($query); return $data; } /** * function name: getWorkWithList * decription: This is for get workWith list data purpose * developed by: lathif */ function getWorkWithList($id=null) { $data=array(); $extraQuery=''; if((int)$id) { $extraQuery='where work_id='.$id; } $query="select work_id,work_name from uflexit_warehouse_workwith $extraQuery order by work_id asc"; $data = $this->db->get_results($query); return $data; } /** * function name: getWareHouseServices * decription: This is used for bring all the getWareHouseServices * developed by: lathif */ function getWareHouseServices($id=null) { $data=array(); $extraQuery=''; if((int)$id) { $extraQuery='where service_id='.$id; } $query="select service_id,service_name from uflexit_warehouse_services $extraQuery order by service_name asc"; $data = $this->db->get_results($query); return $data; } /** * function name: getWareHouseFeatures * decription: This is used for bring all the getWareHouseFeatures * developed by: lathif */ function getWareHouseFeatures($id=null) { $data=array(); $extraQuery=''; if((int)$id) { $extraQuery='where feature_id='.$id; } $query="select feature_id,feature_name from uflexit_warehouse_features $extraQuery order by feature_id asc"; $data = $this->db->get_results($query); return $data; } /** * function name: getWareHouseSpace * decription: This is used for bring all the getWareHouseFeatures * developed by: lathif */ function getWareHouseSpace($id=null) { $data=array(); $extraQuery=''; if((int)$id) { $extraQuery='where space_id='.$id; } $query="select space_id,space_name from uflexit_warehouse_space $extraQuery order by space_name asc"; $data = $this->db->get_results($query); return $data; } /** * function name: addWareHouseDetails * decription: This is used for edit wareHouse * developed by: Kiran kukmar */ function editWareHouseDetails($post,$userId) { $data=array(); $createdDate=gmdate("Y-m-d H:m:i"); $wareHouseName=strip_tags($this->db->escape(trim($post['wareHouseName']))); $alternateWarehouseName=strip_tags($this->db->escape(trim($post['alternateWarehouseName']))); $warehouse_number=strip_tags($this->db->escape(trim($post['wareHouseNumber']))); $description=$this->db->escape(trim($post['description'])); $city=strip_tags($this->db->escape(trim($post['city']))); $address=strip_tags($this->db->escape(trim($post['address']))); $phoneNumber=strip_tags($this->db->escape(trim($post['phoneNumber']))); $email=strip_tags($this->db->escape(trim($post['email']))); $location=strip_tags($this->db->escape(trim($post['location']))); $latitude=strip_tags($this->db->escape(trim($post['latitude']))); $longitude=strip_tags($this->db->escape(trim($post['longitude']))); $countryId=strip_tags($this->db->escape(trim($post['country']))); $mobile_country_code=strip_tags($this->db->escape(trim($post['mobile_country_code']))); //checkwarehouse number $warehouse_number=$this->checkWHNOExistsOrNot($warehouse_number); $query="select * from uflexit_master_wareHouse where warehouse_name='".strtolower($wareHouseName)."' and warehouse_id !='".$post['ewarehouse_id']."'"; $row = $this->db->get_row($query); if($row) { $data['status']=1; } else { $query="update uflexit_master_wareHouse SET warehouse_name='".strtolower($wareHouseName)."', warehouse_alter_name='".strtolower($alternateWarehouseName)."', warehouse_number='".$warehouse_number."', warehouse_description='".urldecode($description)."', warehouse_status=0, warehouse_city='".$city."', warehouse_address='".$address."', warehouse_phone_number='".$phoneNumber."', warehouse_email='".$email."', warehouse_location='".$location."', warehouse_country_id='".(int)$countryId."', created_by='".$userId."', latitude='".$latitude."', longitude='".$longitude."', mobile_country_code= '".$mobile_country_code."', created_date='".$createdDate."' where warehouse_id='".$post['ewarehouse_id']."'"; $row = $this->db->query($query); $lastId=$post['ewarehouse_id']; if($row) { $this->editWareHouseMetaData('productwareHouseDeals',$post['productwareHouseDeals'],$lastId); $this->editWareHouseMetaData('wareHouseService',$post['wareHouseService'],$lastId); $this->editWareHouseMetaData('wareHousefeature',$post['wareHousefeature'],$lastId); $this->editWareHouseMetaData('wareHouseSpace',$post['wareHouseSpace'],$lastId); $this->editWareHouseMetaData('workwith',$post['workwith'],$lastId); $this->editWareHouseTimes($lastId,$post['start_time'],$post['end_time']); $data['lastId']=$lastId; $data['status']=2; } } // print_r($data);exit; return $data; } /** * function name: editWareHouseMetaData * decription: This is used for update extra data related to wareHouse * developed by: lathif */ function query_execute_mine($query){ echo $query; echo '<br/><br/>'; //exit; $row = $this->db->query($query); print_r($row); //echo 'valli the great'; exit; return true; } function editWareHouseMetaData($meta,$recData,$warehouseId) { $createdDate=gmdate("Y-m-d H:m:i"); $data=implode(",",$recData); $row = $this->db->get_row("SELECT * FROM uflexit_wareHouse_meta where warehouse_id='".$warehouseId."' and meta_key='".$meta."'"); if ($row) { $query="update uflexit_wareHouse_meta set choosen_meta_value='".$data."', modify_date='".$createdDate."' where warehouse_id='".$warehouseId."' and meta_key='".$meta."'"; } else{ $query="INSERT INTO uflexit_wareHouse_meta (warehouse_id,meta_key,choosen_meta_value,created_date) VALUES('".$warehouseId."', '".$meta."', '".$data."', '".$createdDate."')"; } //echo $query; $row = $this->db->query($query); //echo '<Br/><br/>'; //print_r($row); //exit; return true; } //Add addIssueTran function addIssueTran($post) { $rand=rand(20,98746); for($i=0;$i<sizeof($post['itemcode']);$i++) { $result_new= $this->db->get_row( "SELECT * from uflexit_issues_transactions order by id desc" ); $id=$result_new[id]+1+$i; //INSERT INTO "public"."uflexit_issues_transactions" ("id","quotation_id","asn_id","customer_name","country","email","city","itemcode","item_desc","qty","ref_number","cost","pallet_no","row_val","rack","pin","created_date","status")VALUES (1,1,1,'test','test country','test@gmail.com','test city','001','item descrion','100','ref 001','1000','001','1','1','1','2021-01-20 11:12:49',1) //$query="insert into uflexit_issues_transactions (quotation_id,warehouse_alter_name,warehouse_number,warehouse_description,warehouse_status,warehouse_city,warehouse_address,warehouse_phone_number,warehouse_email,warehouse_location,warehouse_country_id,created_by,latitude,longitude,created_date,mobile_country_code) VALUES('".strtolower($wareHouseName)."','".strtolower($alternateWarehouseName)."','".$warehouse_number."','".urldecode($description)."',0,'".$city."','".$address."','".$phoneNumber."','".$email."','".$location."','".(int)$countryId."','".$userId."','".$latitude."','".$longitude."','".$createdDate."','".$mobile_country_code."')"; $quotation_id=$post['quotation_id']; $asn_id=$post['asn_id']; $customer_name=$post['customer_name']; $country=$post['country']; $email=$post['email'];$city=$post['city'];$itemcode=$post['itemcode'][$i];$item_desc=$post['item_desc'][$i]; $qty=$post['qty'][$i];$ref_number=$post['ref_number'][$i];$cost=$post['cost'][$i];$pallet_no=$post['pallet_no'][$i]; $row_val=$post['row_val'][$i];$rack=$post['rack'][$i];$pin=$post['pin'][$i];$created_date=date('Y-m-d'); $query="INSERT INTO uflexit_issues_transactions(id,quotation_id,asn_id,customer_name,country,email,city,itemcode,item_desc,qty,ref_number,cost,pallet_no,row_val,rack,pin,created_date,status,randval)VALUES ('".(int)$id."',$quotation_id,$asn_id,'".$customer_name."','".$country."','".$email."','".$city."','".$itemcode."','".$item_desc."','".$qty."','".$ref_number."','".$cost."','".$pallet_no."','".$row_val."','".$rack."','".$pin."','".$created_date."',1,'".$rand."')"; $row = $this->db->query($query); } $data['status']=2;return $data; } function addReceivedTran($post) { $rand=rand(20,98746); for($i=0;$i<sizeof($post['itemcode']);$i++) { $result_new= $this->db->get_row( "SELECT * from uflexit_received_transactions order by id desc" ); $id=$result_new[id]+1+$i; $quotation_id=$post['quotation_id']; $asn_id=$post['asn_id']; $customer_name=$post['customer_name']; $country=$post['country']; $email=$post['email'];$city=$post['city'];$itemcode=$post['itemcode'][$i];$item_desc=$post['item_desc'][$i]; $qty=$post['qty'][$i];$ref_number=$post['ref_number'][$i];$cost=$post['cost'][$i];$pallet_no=$post['pallet_no'][$i]; $row_val=$post['row_val'][$i];$rack=$post['rack'][$i];$pin=$post['pin'][$i];$created_date=date('Y-m-d'); $query="INSERT INTO uflexit_received_transactions(id,quotation_id,asn_id,customer_name,country,email,city,itemcode,item_desc,qty,ref_number,cost,pallet_no,row_val,rack,pin,created_date,status,randval)VALUES ('".(int)$id."',$quotation_id,$asn_id,'".$customer_name."','".$country."','".$email."','".$city."','".$itemcode."','".$item_desc."','".$qty."','".$ref_number."','".$cost."','".$pallet_no."','".$row_val."','".$rack."','".$pin."','".$created_date."',1,'".$rand."')"; $row = $this->db->query($query); } $data['status']=2;return $data; } /** * function name: addWareHouseDetails * decription: This is used for add wareHouse * developed by: lathif */ function addWareHouseDetails($post,$userId) { //print_r($_POST); //exit; $data=array(); $createdDate=gmdate("Y-m-d H:m:i"); $wareHouseName=strip_tags($this->db->escape(trim($post['wareHouseName']))); $alternateWarehouseName=strip_tags($this->db->escape(trim($post['alternateWarehouseName']))); $warehouse_number=strip_tags($this->db->escape(trim($post['wareHouseNumber']))); $description=$this->db->escape(trim($post['description'])); $city=strip_tags($this->db->escape(trim($post['city']))); $address=strip_tags($this->db->escape(trim($post['address']))); $phoneNumber=strip_tags($this->db->escape(trim($post['phoneNumber']))); $email=strip_tags($this->db->escape(trim($post['email']))); $location=strip_tags($this->db->escape(trim($post['location']))); $latitude=strip_tags($this->db->escape(trim($post['latitude']))); $longitude=strip_tags($this->db->escape(trim($post['longitude']))); $countryId=strip_tags($this->db->escape(trim($post['country']))); $mobile_country_code=strip_tags($this->db->escape(trim($post['mobile_country_code']))); //checkwarehouse number $warehouse_number=$this->checkWHNOExistsOrNot($warehouse_number); //echo dirname(__FILE__) . '/class.db.php';exit; $query="select * from uflexit_master_wareHouse where warehouse_name='".strtolower($wareHouseName)."'"; $row = $this->db->get_row($query); if($row) { $data['status']=1; } else { $query="insert into uflexit_master_wareHouse (warehouse_name,warehouse_alter_name,warehouse_number,warehouse_description,warehouse_status,warehouse_city,warehouse_address,warehouse_phone_number,warehouse_email,warehouse_location,warehouse_country_id,created_by,latitude,longitude,created_date,mobile_country_code) VALUES('".strtolower($wareHouseName)."','".strtolower($alternateWarehouseName)."','".$warehouse_number."','".urldecode($description)."',0,'".$city."','".$address."','".$phoneNumber."','".$email."','".$location."','".(int)$countryId."','".$userId."','".$latitude."','".$longitude."','".$createdDate."','".$mobile_country_code."')"; $row = $this->db->query($query); $result_new = $this->db->get_row( "SELECT warehouse_id from uflexit_master_wareHouse order by warehouse_id desc" ); // $lastId=$this->db->lastid($row); $lastId= $result_new['warehouse_id']; // nwly added code on 6th dec 2020 //exit; if($row) { $this->addWareHouseMetaData('productwareHouseDeals',$post['productwareHouseDeals'],$lastId); $this->addWareHouseMetaData('wareHouseService',$post['wareHouseService'],$lastId); $this->addWareHouseMetaData('wareHousefeature',$post['wareHousefeature'],$lastId); $this->addWareHouseMetaData('wareHouseSpace',$post['wareHouseSpace'],$lastId); $this->addWareHouseMetaData('workwith',$post['workwith'],$lastId); $this->addWareHouseTimes($lastId,$post['start_time'],$post['end_time']); $data['lastId']=$lastId; $data['status']=2; } } // print_r($data);exit; return $data; } /** * function name: addWareHouseMetaData * decription: This is used for add extra data related to wareHouse * developed by: lathif */ function addWareHouseMetaData($meta,$recData,$warehouseId) { $createdDate=gmdate("Y-m-d H:m:i"); $data=implode(",",$recData); $query="insert into uflexit_wareHouse_meta (warehouse_id,meta_key,choosen_meta_value,created_date) VALUES('".$warehouseId."', '".$meta."', '".$data."', '".$createdDate."')"; $row = $this->db->query($query); return true; } /** * function name: addWareHousePriceData * decription: This is addwarehouse price data storing purpose * developed by: Lathif */ function addWareHousePriceData($post) { // print_r($post);exit; $data=array(); $this->addWareHouseMetaData('wareHousePriceType',$post['wareHousePriceType'],$post['ewarehouse_id']);//price types // echo count($post['wareHousePriceType']);exit; //echo $post['wareHousePriceType'][0];exit; if($post['wareHousePriceType'][0] == 1 || $post['wareHousePriceType'][0] == 2){ // echo 'd'; exit; $this->addPriceListData($post['minPallet'],$post['minPalletPeriod'],$post['maxPallet'],$post['maxPalletPeriod'],$post['palletDateFrom'],$post['palletDateTo'],$post['palletPricePday'],1,$post['ewarehouse_id']);//pallet } if($post['wareHousePriceType'][0] == 1 || $post['wareHousePriceType'][0] == 3){ //echo 'd1'; exit; $this->addPriceListData($post['minSpace'],$post['minPeriodSpace'],$post['maxSpace'],$post['maxPeriodSpace'],$post['spaceFrom'],$post['spaceTo'],$post['spacePerDay'],2,$post['ewarehouse_id']);//space } $this->addWareHouseMetaData('paymentTypes',$post['payment_types'],$post['ewarehouse_id']);//payment types /*$query="update uflexit_master_wareHouse set warehouse_min_weight='".$post['maxstorageWeight']."', warehouse_max_height='".$post['maxstorageHeight']."', warehouse_packageid='".$post['warehousePackageType']."', max_pallet_online_booking='".$post['max_pallet_online_booking']."', enable_online_booking='".$post['enable_online_booking']."' where warehouse_id=".$post['ewarehouse_id']; */ if($post['warehousePackageType'] != ''){ $post['warehousePackageType'] = $post['warehousePackageType']; } else { $post['warehousePackageType'] = 0; } if($post['max_pallet_online_booking'] != ''){ $post['max_pallet_online_booking'] = $post['max_pallet_online_booking']; } else { $post['max_pallet_online_booking'] = 0; } if($post['enable_online_booking'] != ''){ $post['enable_online_booking'] = $post['enable_online_booking']; } else { $post['enable_online_booking'] = 0; } $query="update uflexit_master_warehouse set warehouse_min_weight='".$post['maxstorageWeight']."', warehouse_max_height='".$post['maxstorageHeight']."', ".'"'."warehouse_packageId".'"'."=".$post['warehousePackageType'].", max_pallet_online_booking=".$post['max_pallet_online_booking'].", enable_online_booking=".$post['enable_online_booking']." where warehouse_id=".$post['ewarehouse_id']; //exit; $row = $this->db->query($query); //print_r($row);exit; if($row) { $data['wareHouseId']=$post['ewarehouse_id']; $data['status']=1; } else { $data['wareHouseId']=$post['ewarehouse_id']; $data['status']=0; } return $data; } /** * function name: editWareHousePriceData * decription: This is updated warehouse price data storing purpose * developed by: Kiran kumar */ function editWareHousePriceData($post) { // print_r($post);exit; // $removedPallets = explode(',',$post['removedPallets']); // print_r($removedPallets);exit; $data=array(); $this->editWareHouseMetaData('wareHousePriceType',$post['wareHousePriceType'],$post['ewarehouse_id']);//price types $this->editWareHouseMetaData('paymentTypes',$post['payment_types'],$post['ewarehouse_id']);//payment types $this->editPriceListData($post['minPallet'],$post['minPalletPeriod'],$post['maxPallet'],$post['maxPalletPeriod'],$post['palletDateFrom'],$post['palletDateTo'],$post['palletPricePday'],1,$post['ewarehouse_id'],$post['pricelist_id']);//pallet // exit; $this->editPriceListData($post['minSpace'],$post['minPeriodSpace'],$post['maxSpace'],$post['maxPeriodSpace'],$post['spaceFrom'],$post['spaceTo'],$post['spacePerDay'],2,$post['ewarehouse_id'],$post['space_id']);//space // exit; $this->deletePriceListData($post['removedPallets']); // delete pallets $this->deletePriceListData($post['removedSpaces']); // delete spaces /*$query="update uflexit_master_warehouse set warehouse_min_weight='".$post['maxstorageWeight']."', warehouse_max_height='".$post['maxstorageHeight']."', 'warehouse_packageId'=".$post['warehousePackageType'].", max_pallet_online_booking='".$post['max_pallet_online_booking']."', enable_online_booking='".$post['enable_online_booking']."' where warehouse_id=".$post['ewarehouse_id'];*/ if($post['warehousePackageType'] != ''){ $post['warehousePackageType'] = $post['warehousePackageType']; } else { $post['warehousePackageType'] = 0; } if($post['max_pallet_online_booking'] != ''){ $post['max_pallet_online_booking'] = $post['max_pallet_online_booking']; } else { $post['max_pallet_online_booking'] = 0; } if($post['enable_online_booking'] != ''){ $post['enable_online_booking'] = $post['enable_online_booking']; } else { $post['enable_online_booking'] = 0; } $query="update uflexit_master_warehouse set warehouse_min_weight='".$post['maxstorageWeight']."', warehouse_max_height='".$post['maxstorageHeight']."', ".'"'."warehouse_packageId".'"'."=".$post['warehousePackageType'].", max_pallet_online_booking='".$post['max_pallet_online_booking']."', enable_online_booking='".$post['enable_online_booking']."' where warehouse_id=".$post['ewarehouse_id']; /*$query = 'update uflexit_master_warehouse set warehouse_min_weight='"1000"', warehouse_max_height='"10000"', "warehouse_packageId"=0, max_pallet_online_booking='"4333"', enable_online_booking='"1"' where warehouse_id=34'; */ //$row = $this->db->query($query); //$this->query_execute_mine($query);//payment types //exit; $row = $this->db->query($query); //print_r($row); exit; if($row) { $data['wareHouseId']=$post['ewarehouse_id']; $data['status']=1; } else { $data['wareHouseId']=$post['ewarehouse_id']; $data['status']=0; } return $data; } /** * function name: deletePriceListData * description : This is addwarehouse delte pallet record purpose * developed by :kiran kumar */ function deletePriceListData($ids) { $returnVal =''; $query = "delete from uflexit_warehouse_priceList where pricelist_id in(".$ids.")"; $result = $this->db->query($query); if($result) { $returnVal = 1; } return $returnVal; } function uploadMedia($name,$oldFileName='') { $photo = ""; $file = $_FILES[$name]['name']; $file = time()."_".rand()."_".str_replace(' ','_',$file); $path = '../../uploads/warehouse_docs/'; if($name == 'warehouse_logo') { $path = '../../uploads/warehouse_imgs/'; } if(move_uploaded_file($_FILES[$name]['tmp_name'], $path.$file)) { if($oldFileName!='' && file_exists($path.$oldFileName)){ unlink($path.$oldFileName); } $photo = $file; } else { $photo = ""; } return $photo; } /** * function name: editWareHouseAddinfo * decription: This is addwarehouse updating additional information data storing purpose * developed by: Kiran Kumar */ function editWareHouseAddinfo($post,$files) { $data=array(); $updatedDate=gmdate("Y-m-d H:m:i"); $insurenceAttch =$insurance_attach = $warehouseLogo = $warehouse_logo = $warehouseLicenseAttachement= $Licensefile = ''; if(isset($files['insurance_attach']['name']) && $files['insurance_attach']['name']!='') { $insurance_attach = $this->uploadMedia('insurance_attach',$post['insurance_old_attach']); $insurenceAttch = ",warehouse_lnsurance_attachement = '".$insurance_attach."'"; } if(isset($files['warehouse_logo']['name']) && $files['warehouse_logo']['name']!='') { $warehouse_logo = $this->uploadMedia('warehouse_logo',$post['warehouse_logo_old']); $warehouseLogo = ",warehouse_logo = '".$warehouse_logo."'"; } if(isset($files['Licensefile']['name']) && $files['Licensefile']['name']!='') { $Licensefile = $this->uploadMedia('Licensefile',$post['license_old_attachment']); $warehouseLicenseAttachement = ",warehouse_license_attachement = '".$Licensefile."'"; } $contact_details_status = 0; if(isset($post['warehouseOwnerDetails']) && $post['warehouseOwnerDetails'] !='') { $contact_details_status = 1; } /*$query = "update uflexit_master_wareHouse set contact_details_status= '".$contact_details_status."' , warehouse_Insurance ='".$post['Insurance_Description']."' , warehouse_license='".$post['licenseNumber']."', warehouse_license_expdate='".date('Y-m-d', strtotime($post['licenseExpiry']))."' $insurenceAttch $warehouseLogo $warehouseLicenseAttachement , modify_date='".$updatedDate."' where warehouse_id='".$post['ewarehouse_id']."'"; */ $query = "update uflexit_master_warehouse set contact_details_status = ".$contact_details_status." , ".'"'."warehouse_Insurance".'"'." ='".$post['Insurance_Description']."' , warehouse_license='".$post['licenseNumber']."', warehouse_license_expdate='".date('Y-m-d', strtotime($post['licenseExpiry']))."' $insurenceAttch $warehouseLogo $warehouseLicenseAttachement , modify_date='".$updatedDate."' where warehouse_id='".$post['ewarehouse_id']."'"; $result = $this->db->query($query); if($result) { if(isset($files['support_attach1']['name']) && $files['support_attach1']['name']!='') { $support_attach1 = $this->uploadMedia('support_attach1',$post['support_old_attach1']); $this->updateSupportAttachment($support_attach1,$post['ewarehouse_id'],$post['supportdocIdone']); } if(isset($files['support_attach2']['name']) && $files['support_attach2']['name']!=''){ $support_attach2 = $this->uploadMedia('support_attach2',$post['support_old_attach2']); $this->updateSupportAttachment($support_attach2,$post['ewarehouse_id'],$post['supportdocIdtwo']); } $data['wareHouseId']=$post['ewarehouse_id']; $data['status'] =1;// update success } else{ $data['wareHouseId']=$post['ewarehouse_id']; $data['status'] =0; // update failed } return $data; } /** * function name: addWareHouseAddinfo * decription: This is addwarehouse updating additional information data storing purpose * developed by: Kiran Kumar */ function addWareHouseAddinfo($post,$files) { $data=array(); $insurenceAttch = $warehouseLogo= $warehouseLicenseAttachement=''; $updatedDate=gmdate("Y-m-d H:m:i"); if(isset($files['insurance_attach']['name']) && $files['insurance_attach']['name']!=''){ $insurance_attach=time()."_".rand()."_".str_replace(' ', '_', $files['insurance_attach']['name']); if(move_uploaded_file($files['insurance_attach']['tmp_name'], "../../uploads/warehouse_docs/".$insurance_attach)) { $insurenceAttch = ",warehouse_lnsurance_attachement = '".$insurance_attach."'"; } } if(isset($files['warehouse_logo']['name']) && $files['warehouse_logo']['name']!=''){ $warehouse_logo=time()."_".rand()."_".str_replace(' ', '_', $files['warehouse_logo']['name']); if(move_uploaded_file($files['warehouse_logo']['tmp_name'], "../../uploads/warehouse_imgs/".$warehouse_logo)) { $warehouseLogo = ",warehouse_logo = '".$warehouse_logo."'"; } } if(isset($files['Licensefile']['name']) && $files['Licensefile']['name']!=''){ $Licensefile=time()."_".rand()."_".str_replace(' ', '_', $files['Licensefile']['name']); if(move_uploaded_file($files['Licensefile']['tmp_name'], "../../uploads/warehouse_docs/".$Licensefile)) { $warehouseLicenseAttachement = ",warehouse_license_attachement = '".$Licensefile."'"; } } $contact_details_status = 0; if(isset($post['warehouseOwnerDetails']) && $post['warehouseOwnerDetails'] !='') { $contact_details_status = 1; } $query = "update uflexit_master_warehouse set contact_details_status = ".$contact_details_status." , ".'"'."warehouse_Insurance".'"'." ='".$post['Insurance_Description']."' , warehouse_license='".$post['licenseNumber']."', warehouse_license_expdate='".date('Y-m-d', strtotime($post['licenseExpiry']))."' $insurenceAttch $warehouseLogo $warehouseLicenseAttachement , modify_date='".$updatedDate."' where warehouse_id='".$post['ewarehouse_id']."'"; /*$query="update uflexit_master_warehouse set warehouse_min_weight='".$post['maxstorageWeight']."', warehouse_max_height='".$post['maxstorageHeight']."', ".'"'."warehouse_packageId".'"'."=".$post['warehousePackageType'].", max_pallet_online_booking=".$post['max_pallet_online_booking'].", enable_online_booking=".$post['enable_online_booking']." where warehouse_id=".$post['ewarehouse_id'];*/ $result = $this->db->query($query); if($result) { if(isset($files['support_attach1']['name']) && $files['support_attach1']['name']!=''){ $support_attach1=time()."_".rand()."_".str_replace(' ', '_', $files['support_attach1']['name']); if(move_uploaded_file($files['support_attach1']['tmp_name'], "../../uploads/warehouse_docs/".$support_attach1)) { $this->supportAttachment($support_attach1,$post['ewarehouse_id']); } } if(isset($files['support_attach2']['name']) && $files['support_attach2']['name']!=''){ $support_attach2=time()."_".rand()."_".str_replace(' ', '_', $files['support_attach2']['name']); if(move_uploaded_file($files['support_attach2']['tmp_name'], "../../uploads/warehouse_docs/".$support_attach2)) { $this->supportAttachment($support_attach2,$post['ewarehouse_id']); } } $data['wareHouseId']=$post['ewarehouse_id']; $data['status'] =1;// update success } else{ $data['wareHouseId']=$post['ewarehouse_id']; $data['status'] =0; // update failed } return $data; } function supportAttachment($attachment,$warehouse_id) { $returnVal =0; $createdDate=gmdate("Y-m-d H:m:i"); $query ="insert into uflexit_supporting_attachments (support_attachment,warehouse_id,created_at) VALUES('".$attachment."','".$warehouse_id."','".$createdDate."')"; $res= $this->db->query($query); if($res) { $returnVal= 1; } return $returnVal; } function updateSupportAttachment($attachment,$warehouse_id,$supportDocId) { $returnVal =0; $updatedDate=gmdate("Y-m-d H:m:i"); $query ="update uflexit_supporting_attachments set support_attachment='".$attachment."', updated_at ='".$updatedDate."' where attachment_id='".$supportDocId."'"; $res= $this->db->query($query); if($res) { $returnVal= 1; } return $returnVal; } /** * function name: addPriceListData * decription: This is addprice list data storing purpose * developed by: Lathif */ function addPriceListData($arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7,$type,$warehouseId) { $createdDate=gmdate("Y-m-d H:m:i"); $count=0; if($type==1) $count=count($arg1); else if($type==2) $count=count($arg1); for($i=0;$i<$count;$i++) { if($type==1) { $p_from=date("Y-m-d",strtotime($arg5[$i])); $p_to=date("Y-m-d",strtotime($arg6[$i])); /* $query="insert into uflexit_warehouse_priceList set minimum='".$arg1[$i]."', minimum_period='".$arg2[$i]."', maximum='".$arg3[$i]."', maximum_period='".$arg4[$i]."', period_from='".$p_from."', period_to='".$p_to."', price_per_day='".$arg7[$i]."', warehouse_id='".$warehouseId."', price_type='".$type."', created_date='".$createdDate."'";*/ $query="insert into uflexit_warehouse_priceList (minimum,minimum_period,maximum,maximum_period,period_from,period_to,price_per_day,warehouse_id,price_type,created_date) VALUES('".$arg1[$i]."','".$arg2[$i]."','".$arg3[$i]."','".$arg4[$i]."','".$p_from."','".$p_to."','".$arg7[$i]."','".$warehouseId."','".$type."','".$createdDate."')"; } else { $p_from=date("Y-m-d",strtotime($arg5[$i])); $p_to=date("Y-m-d",strtotime($arg6[$i])); /* $query="insert into uflexit_warehouse_priceList set minimum='".$arg1[$i]."', minimum_period='".$arg2[$i]."', maximum='".$arg3[$i]."', maximum_period='".$arg4[$i]."', period_from='".$p_from."', period_to='".$p_to."', price_per_day='".$arg7[$i]."', warehouse_id='".$warehouseId."', price_type='".$type."', created_date='".$createdDate."'";*/ $query="insert into uflexit_warehouse_priceList (minimum,minimum_period,maximum,maximum_period,period_from,period_to,price_per_day,warehouse_id,price_type,created_date) VALUES('".$arg1[$i]."','".$arg2[$i]."','".$arg3[$i]."','".$arg4[$i]."','".$p_from."','".$p_to."','".$arg7[$i]."','".$warehouseId."','".$type."','".$createdDate."')"; } $row = $this->db->query($query); } return true; } /** * function name: editPriceListData * decription: This is updating price list data storing purpose * developed by: Kiran kumar */ function editPriceListData($arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7,$type,$warehouseId,$priceList_id) { $createdDate=gmdate("Y-m-d H:m:i"); $count1 = $count2 = 0; if($type==1) $count1=count($arg1); else if($type==2) $count2=count($arg1); if($type==1) { for($i=0;$i<$count1;$i++) { // if($type==1) // { $p_from=date("Y-m-d",strtotime($arg5[$i])); $p_to=date("Y-m-d",strtotime($arg6[$i])); if($priceList_id[$i]){ $query="update uflexit_warehouse_priceList set minimum='".$arg1[$i]."', minimum_period='".$arg2[$i]."', maximum='".$arg3[$i]."', maximum_period='".$arg4[$i]."', period_from='".$p_from."', period_to='".$p_to."', price_per_day='".$arg7[$i]."', warehouse_id='".$warehouseId."', price_type='".$type."', modify_date='".$createdDate."' where pricelist_id='".$priceList_id[$i]."'"; } else{ $query="insert into uflexit_warehouse_priceList (minimum,minimum_period,maximum,maximum_period,period_from,period_to,price_per_day,warehouse_id,price_type,created_date) VALUES('".$arg1[$i]."','".$arg2[$i]."','".$arg3[$i]."','".$arg4[$i]."','".$p_from."','".$p_to."','".$arg7[$i]."','".$warehouseId."','".$type."','".$createdDate."')"; } $row = $this->db->query($query); } } else { for($i=0;$i<$count2;$i++) { $p_from=date("Y-m-d",strtotime($arg5[$i])); $p_to=date("Y-m-d",strtotime($arg6[$i])); if($priceList_id[$i]){ $query="update uflexit_warehouse_priceList set minimum='".$arg1[$i]."', minimum_period='".$arg2[$i]."', maximum='".$arg3[$i]."', maximum_period='".$arg4[$i]."', period_from='".$p_from."', period_to='".$p_to."', price_per_day='".$arg7[$i]."', price_type='".$type."', modify_date='".$createdDate."' where pricelist_id='".$priceList_id[$i]."'"; } else{ $query="insert into uflexit_warehouse_priceList (minimum,minimum_period,maximum,maximum_period,period_from,period_to,price_per_day,warehouse_id,price_type,created_date) VALUES('".$arg1[$i]."','".$arg2[$i]."','".$arg3[$i]."','".$arg4[$i]."','".$p_from."','".$p_to."','".$arg7[$i]."','".$warehouseId."','".$type."','".$createdDate."')"; } $row = $this->db->query($query); } } return true; } /** * function name: checkEmailExistsOrNot * decription: This is for check email exists or not * developed by: surendra */ function checkEmailExistsOrNot($email) { $returnVal=0; $trimEmail=strip_tags($this->db->escape(trim($email))); $query="select * from uflexit_users where email='".$trimEmail."'"; $row = $this->db->get_row($query); if($row) { $returnVal=1; } return $returnVal; } /** * function name: checkPhoneExistsOrNot * decription: This is for check phone exists or not * developed by: surendra */ function checkPhoneExistsOrNot($mobile) { $returnVal=0; $trimPhone=strip_tags($this->db->escape(trim($mobile))); $query="select * from uflexit_users where mobile_number='".$trimPhone."'"; $row = $this->db->get_row($query); if($row) { $returnVal=1; } return $returnVal; } /** * function name: subadminupdatingcheckPhoneExistsOrNot * decription: This is for updating subadmin phone * developed by: surendra */ function checkupdatedPhoneExistsOrNot($mobile) { $returnVal=''; $result=''; $trimPhone=strip_tags($this->db->escape(trim($mobile))); $query="select email from uflexit_users where mobile_number='".$trimPhone."' "; $result = $this->db->get_row($query); if($result) { $result1= $result['email']; $returnVal=1; return $result1; } return $returnVal; } /** * function name: changePassword * decription: This is for password change both admin,subadmin and user * developed by: Surendra */ function changePassword($post,$email) { $returnVal=0; // $email=strip_tags($this->db->escape(trim($post['email']))); $password=strip_tags($this->db->escape(trim($post['password']))); $cnfrmPassword=strip_tags($this->db->escape(trim($post['cnfrmPassword']))); $checkEmail=$this->checkEmailExistsOrNot($email); if($checkEmail==1) { if($password == $cnfrmPassword) { $convertedPassword=$this->generateSecuredPassword($password); $query_c="SELECT * FROM uflexit_users WHERE email='$email'"; //echo '<Br/>'; $data_c = $this->db->get_results($query_c); $hash = $data_c[0]['password']; if (password_verify($password, $hash)) { $returnVal='same'; // exit; } else { $query1="UPDATE uflexit_users SET password='$convertedPassword' WHERE email='$email'"; // exit; $row1=$this->db->query($query1); //echo '<br/>'; if($row1) { $returnVal=1; } } } else { $returnVal=2; } } else { $returnVal=3; } return $returnVal; } /** * function name: getCountryList * decription: This is for getting all countries in uflexit_countries table * developed by: surendra */ function getCountryList($countryId ='') { $data=array(); $where =''; if($countryId!='') { $where = "where country_id ='".$countryId."'"; } $query="SELECT * FROM uflexit_countries $where order by country_name asc"; $data = $this->db->get_results($query); return $data; } function getCityList($country_id){ $query="SELECT * FROM uflexit_cities WHERE country_id=".$country_id; $cities = $this->db->get_results($query); return $cities; } /** * function name: subAdmin Creation * decription: This is for creating sub admin by admin * developed by: surendra */ function addSubAdmin($post,$role,$email_active) { $returnVal=0; //sql injections preventing //print_r($_POST);exit; $first_name=$last_name=$mobile=$email=$country=$city=''; 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']))); if(isset($post['mobile'])) $mobile=strip_tags($this->db->escape(trim($post['mobile']))); if(isset($post['email'])) $email=strip_tags($this->db->escape(trim($post['email']))); if(isset($post['country'])) $country=strip_tags($this->db->escape(trim($post['country']))); if(isset($post['city'])) $city=strip_tags($this->db->escape(trim($post['city']))); $checkEmail=$this->checkEmailExistsOrNot($email); $checkPhone=$this->checkPhoneExistsOrNot($mobile); $password = '123456'; $convertedPassword=$this->generateSecuredPassword($password); $mobile_country_code=strip_tags($this->db->escape(trim($post['mobile_country_code']))); if($checkEmail==1) { $returnVal=1; } else if($checkPhone==1) { $returnVal=2; } else { //echo 'came'; //print_r($_SESSION);echo '<br/><br/>'; $createdDate=gmdate("Y-m-d H:m:i"); $emailactiveToken=$this->generateApiKey(); $query="INSERT into uflexit_users (email,mobile_number,role_id,first_name,last_name,city_name,country_id,email_active_token,email_active,created_date,password,designation,address,postal_code,created_by,mobile_country_code) VALUES ('".$email."','".$mobile."','".$role."','".$first_name."','".$last_name."','".$city."','".$country."','".$emailactiveToken."','".$email_active."','".$createdDate."','".$convertedPassword."','','','',".$_SESSION['user_id'].",'".$mobile_country_code."')"; //exit; //exit; $row=$this->db->query($query); // echo "<script>alert('$row');</script>"; if($row) { $this->sendEmailSubAdmin($post,$emailactiveToken,$role);//subadmin Email $returnVal = 3; } } return $returnVal; } /** * function name: sendEmailUserAndSuperAdmin * decription: This is for sending email to customer either amdin or user * developed by: lathif */ function sendEmailSubAdmin($post,$emailactiveToken,$role) { $baseUrl=HOSTPATH;//from config file $fromName = 'Uflexit'; $from='support@uflexit.com'; $to=$post['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='Reset Password From Uflexit'; $customerContent=''; $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">Phone number</td> <td style="width: 5%;">:</td> <td style="width: 50%;">' .$post['mobile'] . '</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">Setup Your Password</td> <td style="width: 5%;">:</td> <td style="width: 50%;"><a href="' . $baseUrl.COMMONPATH.'/warehouse_admin/passwordGeneration.php?etoken='.$emailactiveToken.'" target="_blank">Password Genration</a></td> </tr> '; $htmlContent = ' <html> <head> <title>Uflexit WareHouse Service</title> </head> <body> <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="Set Your Password in Uflexit" /> </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="font-size: 18px;color: #308DFD"><br/>Thanks & Regards<br/> Uflexit Team</h3> </footer> </div> </div> </body> </html>'; // echo "<br/>"; // echo $htmlContent; // exit; $sent_mail_subadmin = mail($to,$from, $subject, $htmlContent, $headers); //mail to subAdmin return true; } /** * function name: checkToken exists or not * decription: This is for check emailtoken exists or not * developed by: surendra */ function checkEmailTokenExists($etoken) { $returnVal=0; $trimEtoken=strip_tags($this->db->escape(trim($etoken))); $query="select * from uflexit_users where email_active_token='".$trimEtoken."'"; $row = $this->db->get_row($query); if($row) { $returnVal=1; } return $returnVal; } /** * function name: PasswordGeneration * decription: This is for password creation for subadmin * developed by: Surendra */ function passwordGenerationSubAdmin($post,$etoken) { $returnVal=0; $password=strip_tags($this->db->escape(trim($post['password']))); $cnfrmPassword=strip_tags($this->db->escape(trim($post['cnfrmPassword']))); $etoken=strip_tags($this->db->escape(trim($etoken))); $checketoken=$this->checkEmailTokenExists($etoken); if($checketoken==1) { if($password == $cnfrmPassword) { $convertedPassword=$this->generateSecuredPassword($password); $query1="UPDATE uflexit_users SET password='$convertedPassword' WHERE email_active_token='$etoken'"; $row1=$this->db->escape($query1); if($row1) { $returnVal=1; } } else { $returnVal=2; } } else { $returnVal=3; } return $returnVal; } /** * function name: addWareHouseTimes * decription: This is used for add week times to wareHouse * developed by: lathif */ function addWareHouseTimes($warehouseId,$startTime,$endTime) { for($i=0;$i<count($startTime);$i++) { $createdDate=gmdate("Y-m-d H:m:i"); $utcStartTime=gmdate($startTime[$i]); $utcEndTime=gmdate($endTime[$i]); $query="insert into uflexit_warehouse_workingHours (warehouse_id,working_day,start_time,end_time,utc_start_time,utc_end_time,created_date) VALUES('".$warehouseId."','".$i."','".$startTime[$i]."','".$endTime[$i]."','".$utcStartTime."','".$utcEndTime."','".$createdDate."')"; //$row = $this->db->escape($query); $row = $this->db->query($query); //return true; } return true; } /** * function name: editWareHouseTimes * decription: This is used for update week times to wareHouse * developed by: Kiran kumar */ function editWareHouseTimes($warehouseId,$startTime,$endTime) { for($i=0;$i<count($startTime);$i++) { $createdDate=gmdate("Y-m-d H:i:s"); $utcStartTime=gmdate($startTime[$i]); $utcEndTime=gmdate($endTime[$i]); if (empty($utcStartTime)) continue; $row = $this->db->get_row("SELECT * FROM uflexit_warehouse_workingHours where warehouse_id='".$warehouseId."' and working_day='".$i."'"); if ($row) { $query="update uflexit_warehouse_workingHours set start_time='".$startTime[$i]."', end_time='".$endTime[$i]."', utc_start_time='".$utcStartTime."', utc_end_time='".$utcEndTime."', modify_date='".$createdDate."' where warehouse_id='".$warehouseId."' and working_day='".$i."'"; } else{ $query="insert into uflexit_warehouse_workingHours (warehouse_id,working_day,start_time,end_time,utc_start_time,utc_end_time,created_date) VALUES('".$warehouseId."','".$i."','".$startTime[$i]."','".$endTime[$i]."','".$utcStartTime."','".$utcEndTime."','".$createdDate."')"; } $row = $this->db->query($query); } return true; } /** * function name: getWarehouseType * decription: This is used for uflexit Warehouse Type * developed by: lathif */ function getWarehouseType($id=null) { $data=array(); $extraQuery=''; if((int)$id) { $extraQuery='where pricetype_id='.$id; } $query="select pricetype_id,pricetype_name from uflexit_warehouse_type $extraQuery order by pricetype_name asc"; $data = $this->db->get_results($query); return $data; } /** * function name: fetching all subadmin data * decription: This is for getting sub admin contact details * developed by: surendra */ function getsubadmindetails() { $data=array(); $query="SELECT * FROM uflexit_users where role_id='2' AND created_by = ".$_SESSION['user_id']." ORDER BY user_id DESC"; $data = $this->db->get_results($query); return $data; } /** * function name: fetching subadmin data using id * decription: This is for getting sub admin contact details using id * developed by: surendra */ function fetchSubadmin($editdata) { //$result=''; $query= "SELECT * FROM uflexit_users WHERE user_id='".$editdata."'";; $result = $this->db->get_row($query); return $result; } /** * function name: updating subadmin details * decription: This is for updating subadmin details * developed by: surendra */ function editsubadmindetails($post,$files) { $returnVal=0; //sql injections preventing $first_name=$last_name=$mobile=$email=$country=$city=$company_name=$address=$postal=$inactiveDate=''; 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']))); if(isset($post['mobile'])) $mobile=strip_tags($this->db->escape(trim($post['mobile']))); if(isset($post['email'])) $email=strip_tags($this->db->escape(trim($post['email']))); if(isset($post['country'])) $country=strip_tags($this->db->escape(trim($post['country']))); if(isset($post['city'])) $city=strip_tags($this->db->escape(trim($post['city']))); if(isset($post['company_name'])) $company_name=strip_tags($this->db->escape(trim($post['company_name']))); if(isset($post['address'])) $address=strip_tags($this->db->escape(trim($post['address']))); if(isset($post['postal'])) $postal=strip_tags($this->db->escape(trim($post['postal']))); $checkEmail=$this->checkEmailExistsOrNot($email); $mobile_country_code=strip_tags($this->db->escape(trim($post['mobile_country_code']))); //print_r($_FILES);exit; // Image upload $recordFile=''; $t = $_FILES["image"]["tmp_name"]; $n = $_FILES["image"]["name"]; $p=strtotime(date('d-m-Y H:i:s')); $k=substr(str_shuffle($p),0,5); $tfname=$k.$n; if(move_uploaded_file($t, "../../uploads/subadmin_photos/".$tfname)) { $recordFile=strip_tags($this->db->escape(trim($tfname))); } // else if($recordFile) // { // // echo "Uploaded successfully"; // } if($checkEmail==1) { $returnVal=1; //$inactiveDate=gmdate("Y-m-d H:m:i"); $inactiveDate = strip_tags($this->db->escape(trim(date('Y-m-d' ,strtotime($post['inactiveDate']))))); if($recordFile !='') { $query="UPDATE uflexit_users set mobile_number='".$mobile."', first_name='".$first_name."', last_name='".$last_name."', city_name='".$city."', country_id='".$country."', inactive_date='".$inactiveDate."', address='".$address."', postal_code='".$postal."', upload_pic='".$recordFile."', mobile_country_code='".$mobile_country_code."' WHERE email='".$email."'"; // exit; $row=$this->db->query($query); if($row) { $returnVal = 2; } } else { //print_r($_POST);echo '<br/><br/>'; $query="UPDATE uflexit_users set mobile_number='".$mobile."', first_name='".$first_name."', last_name='".$last_name."', city_name='".$city."', country_id='".$country."', inactive_date='".$inactiveDate."', address='".$address."', postal_code='".$postal."', mobile_country_code='".$mobile_country_code."' WHERE email='".$email."'"; // exit; $row=$this->db->query($query); if($row) { $returnVal = 2; } } } return $returnVal; } function addCompany($post,$files) { $sel = "select * from uflexit_company where company_name ='".$this->db->escape(trim($post['company_name']))."'"; $result = $this->db->get_row($sel); if(!$result) { $sel = "select * from uflexit_company where cr_number ='".$this->db->escape(trim($post['cr_number']))."'"; $result = $this->db->get_row($sel); if(!$result) { $sel = "select * from uflexit_company where tax_reg_number ='".$this->db->escape(trim($post['tax_reg_number']))."'"; $result = $this->db->get_row($sel); if(!$result) { $createdDate=gmdate("Y-m-d H:m:i"); $query="insert into uflexit_company (company_name,user_id,role_id,cr_number,cr_exp_date,tax_reg_number,tax_exp_date,country_id,city_name,created_date) VALUES('".$this->db->escape(trim($post['company_name']))."','".$_SESSION['user_id']."','".$_SESSION['role']."','".$this->db->escape(trim($post['cr_number']))."','".date('Y-m-d', strtotime($post['cr_exp_date']))."','".$this->db->escape(trim($post['tax_reg_number']))."','".date('Y-m-d', strtotime($post['tax_registration_expire']))."','".$this->db->escape(trim($post['country_id']))."','".$this->db->escape(trim($post['city_name']))."','".$createdDate."')"; $res = $this->db->query($query); $lastId=$this->db->lastid($res); if($res) { $attach=''; if(isset($files['attachment']['name']) && $files['attachment']['name']!=''){ $fname=time()."_".rand()."_".str_replace(' ', '_', $files['attachment']['name']); if(move_uploaded_file($files['attachment']['tmp_name'], "../../uploads/warehouse_docs/".$fname)) { $que = "insert into uflexit_company_attachements (uploaded_attachement,company_id,created_dt) VALUES('".$fname."','".$lastId."','".$createdDate."')"; $res = $this->db->query($que); } } return 1; } }else{ return -1; //tax_reg_number already exists } } else{ return -2; //cr_number already exists } } else{ return -3; //company name already exists } } 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 editCompany($post,$files) { $sel = "select * from uflexit_company where company_name ='".$this->db->escape(trim($post['company_name']))."' and company_id!='".$post['companyId']."'"; $result = $this->db->get_row($sel); if(sizeof($result)!=0) { $sel = "select * from uflexit_company where cr_number ='".$this->db->escape(trim($post['cr_number']))."' and company_id!='".$post['companyId']."'"; $result = $this->db->get_row($sel); if(!$result) { $sel = "select * from uflexit_company where tax_reg_number ='".$this->db->escape(trim($post['tax_reg_number']))."' and company_id!='".$post['companyId']."'"; $result = $this->db->get_row($sel); if(!$result) { $createdDate=gmdate("Y-m-d H:m:i"); $query="update uflexit_company SET company_name='".$this->db->escape(trim($post['company_name']))."', user_id ='".$_SESSION['user_id']."', role_id = '".$_SESSION['role']."', cr_number='".$this->db->escape(trim($post['cr_number']))."', cr_exp_date='".date('Y-m-d', strtotime($post['cr_exp_date']))."', tax_reg_number='".$this->db->escape(trim($post['tax_reg_number']))."', tax_exp_date='".date('Y-m-d', strtotime($post['tax_registration_expire']))."', updated_date='".$createdDate."' where company_id ='".$post['companyId']."'"; $res = $this->db->query($query); if($res) { $attach=''; if(isset($files['attachment']['name']) && $files['attachment']['name']!=''){ $fname=time()."_".rand()."_".str_replace(' ', '_', $files['attachment']['name']); if(move_uploaded_file($files['attachment']['tmp_name'], "../../uploads/warehouse_docs/".$fname)) { // $attach="profile_pic='".$fname."',"; if($post['olddoc'] !='') { unlink('../../uploads/warehouse_docs/'.$post['olddoc']); } $selQue ="select * from uflexit_company_attachements where company_id ='".$post['companyId']."'"; $reslt = $this->db->get_row($selQue); if($reslt) { $que = "update uflexit_company_attachements SET uploaded_attachement ='".$fname."',created_dt='".$createdDate."' where company_id ='".$post['companyId']."'"; $res = $this->db->query($que); } else{ $que = "insert into uflexit_company_attachements (uploaded_attachement,created_dt, company_id) VALUES ('".$fname."','".$createdDate."','".$post['companyId']."')"; $res = $this->db->query($que); } } } return 1; } }else{ return -1; //tax_reg_number already exists } } else{ return -2; //cr_number already exists } } else{ if($post['companyId']=='') { $createdDate=gmdate("Y-m-d H:m:i"); $query="insert into uflexit_company (company_name,user_id,role_id,cr_number,cr_exp_date,tax_reg_number,tax_exp_date,country_id,city_name,created_date) VALUES('".$this->db->escape(trim($post['company_name']))."','".$_SESSION['user_id']."','".$_SESSION['role']."','".$this->db->escape(trim($post['cr_number']))."','".date('Y-m-d', strtotime($post['cr_exp_date']))."','".$this->db->escape(trim($post['tax_reg_number']))."','".date('Y-m-d', strtotime($post['tax_registration_expire']))."','0','0','".$createdDate."')"; $res = $this->db->query($query); $lastId=$this->db->lastid($res); return 1; }else { return -3; //company name already exists } } } function companyAttachment($company_id) { $query = "select * from uflexit_company_attachements where company_id='".$company_id."'"; return $this->db->get_row($query); } function getCompany($company_id) { $attach=''; $row =array(); $sql= "select * from uflexit_company where company_id='".$company_id."'"; $row = $this->db->get_row($sql); if($row) { $attach = $this->companyAttachment($row['company_id']); $row['attachment'] = $attach['uploaded_attachement']; return $row; } } /** * function name: getUflexitPaymentsTypes * decription: This is used for bring type of payments in uflexit * developed by: Lathif */ function getUflexitPaymentsTypes($id=Null) { $data=array(); $extraQuery=''; if((int)$id) { $extraQuery='where payment_type='.$id; } $query="select payment_type,payment_name from uflexit_payment_method $extraQuery order by payment_name asc"; $data = $this->db->get_results($query); return $data; } /** * function name: Validating passwords * decription: Validating hash password in db with given password * developed by: Surendra */ function checkPasswordMatch($password,$passwordHash) { if(password_verify($password,$passwordHash)) { return 1; } else{ return 0; } } /** * function name: Login functionalities * decription: Login functionaliteis for uflexit owner * developed by: Surendra */ function loginUser($post) { $returnVal = array(); $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'"; $loginDetails = $this->db->get_row($query); //print_r($loginDetails);exit; if ($loginDetails) { $db_password=strip_tags($this->db->escape(trim($loginDetails['password']))); $password_result=$this->checkPasswordMatch($password,$db_password); if($password_result) { $returnVal['details'] = $loginDetails; $returnVal['status'] = 1; //success } else { $returnVal['status']=2; } } return $returnVal; } /** * Function name: getWareHouseMainDetails * Decription: This is for get wareHouse master data from this table. * Developed by: Lathif */ function getWareHouseMainDetails($wareHouseId) { $data=array(); $query="select * from uflexit_master_wareHouse where warehouse_id=".$wareHouseId; $data = $this->db->get_row($query); return $data; } /** * Function name: getWareHouseMetaDetails * Decription:This is for bring meta data from wareHouse * Developed by: Lathif */ function getWareHouseMetaDetails($wareHouseId) { $data=array(); $query="select meta_id,warehouse_id,meta_key,choosen_meta_value from uflexit_wareHouse_meta where warehouse_id=".$wareHouseId; $data = $this->db->get_results($query); return $data; } /** * Function name: getWHPriceList * Decription:This is for bring wareHouse price List data * Developed by: Lathif */ function getWHPriceList($wareHouseId,$type='') { $data=array(); $typeCondition = ''; if($type !='') { $typeCondition = "price_type ='".$type."' and "; } //$query="select * from uflexit_warehouse_priceList where $typeCondition warehouse_id=".$wareHouseId; $query="select * from uflexit_warehouse_priceList where $typeCondition warehouse_id=".$wareHouseId; //echo '<br/>'; $data = $this->db->get_results($query); //print_r($data);echo '<br/><br/>'; return $data; } /** * Function name: getWorkingHours * Decription:This is for bring wareHouse price List data * Developed by: Lathif */ function getWorkingHours($wareHouseId) { $data=array(); $query="select * from uflexit_warehouse_workingHours where warehouse_id=".$wareHouseId; $data = $this->db->get_results($query); $newData = []; foreach ($data as $dat) { $newData[$dat['working_day']] = $dat; } return $newData; } /** * Function name: getSupportDcouments * Decription:This is for bring wareHouse Support/Legal Dcouments * Developed by: Kiran kumar */ function getSupportDcouments($wareHouseId) { $data=array(); $query="select * from uflexit_supporting_attachments where warehouse_id=".$wareHouseId; $data = $this->db->get_results($query); return $data; } function fetchLoginAdminwarehousesActive($user_id) { $data=array(); if($_SESSION['created_by'] > 0){ $query= "SELECT * FROM uflexit_master_wareHouse WHERE created_by IN ('".$user_id."','".$_SESSION['created_by']."') and warehouse_status=1"; } else { $query= "SELECT * FROM uflexit_master_wareHouse WHERE created_by='".$user_id."' and warehouse_status=1"; } $data = $this->db->get_results($query); return $data; } function fetchLoginAdminwarehousesPending($user_id) { $data=array(); $query= "SELECT * FROM uflexit_master_wareHouse WHERE created_by='".$user_id."' and warehouse_status=0"; $data = $this->db->get_results($query); return $data; } function fetchLoginAdminwarehousesRejected($user_id) { $data=array(); $query= "SELECT * FROM uflexit_master_wareHouse WHERE created_by='".$user_id."' and warehouse_status=2"; $data = $this->db->get_results($query); return $data; } /** * function name: FetchingLoginUserData * decription: Fetching data of login user with the help ofsession_id * developed by: Surendra */ function fetchLoginAdminwarehouses($user_id) { $data=array(); if($_SESSION['created_by'] > 0){ $query= "SELECT * FROM uflexit_master_wareHouse WHERE created_by IN ('".$user_id."','".$_SESSION['created_by']."')"; } else { $query= "SELECT * FROM uflexit_master_wareHouse WHERE created_by='".$user_id."'"; } $data = $this->db->get_results($query); return $data; } /** * function name: FetchingLoginUserData * decription: Fetching data of login user with the help of session_id * developed by: Surendra */ function fetchLoginAdminDetails($id) { $data=''; $query="select * from uflexit_users where user_id=".$id; $data = $this->db->get_row($query); return $data; } /** * function name: Updating subadmin details * decription: Updating subadmin details by admin * developed by: Surendra */ function updateSubadmindataUsingAjax($data) { $returnVal=''; //sql injections preventing $first_name=$last_name=$mobile=$email=$country=$city=$company_name=$address=$postal=$inactiveDate=''; if(isset($data['first_name'])) $first_name=strip_tags($this->db->escape(trim($data['first_name']))); if(isset($data['last_name'])) $last_name=strip_tags($this->db->escape(trim($data['last_name']))); if(isset($data['mobile'])) $mobile=strip_tags($this->db->escape(trim($data['mobile']))); if(isset($data['email'])) $email=strip_tags($this->db->escape(trim($data['email']))); if(isset($data['country'])) $country=strip_tags($this->db->escape(trim($data['country']))); if(isset($data['city'])) $city=strip_tags($this->db->escape(trim($data['city']))); if(isset($data['company_name'])) $company_name=strip_tags($this->db->escape(trim($data['company_name']))); if(isset($data['address'])) $address=strip_tags($this->db->escape(trim($data['address']))); if(isset($data['postal'])) $postal=strip_tags($this->db->escape(trim($data['postal']))); $checkEmail=$this->checkEmailExistsOrNot($data['email']); // Image upload // $recordFile=''; // $t = $_FILES["image"]["tmp_name"]; // $n = $_FILES["image"]["name"]; // echo $n; // exit; // $p=strtotime(date('d-m-Y H:i:s')); // $k=substr(str_shuffle($p),0,5); // $tfname=$k.$n; // if(move_uploaded_file($t, "../../uploads/subadmin_photos/".$tfname)) // { // $recordFile=strip_tags($this->db->escape(trim($tfname))); // } // else if($recordFile) // { // // echo "Uploaded successfully"; // } //$file= $data['file']; $upload = ''; if(!empty($_FILES['image'])){ // File upload configuration $targetDir = "./../uploads/subadmin_photos/"; $allowTypes = array('pdf', 'doc', 'docx', 'jpg', 'png', 'jpeg'); $fileName = basename($_FILES['image']['name']); $targetFilePath = $targetDir.$fileName; $recordFile=strip_tags($this->db->escape(trim($fileName))); // Check whether file type is valid $fileType = pathinfo($targetFilePath, PATHINFO_EXTENSION); if(in_array($fileType, $allowTypes)){ // Upload file to the server if(move_uploaded_file($_FILES['image']['tmp_name'], $targetFilePath)){ $upload = 'ok'; }else{ echo $_FILES["image"]["error"]; } } } if($checkEmail==1) { $inactiveDate=gmdate("Y-m-d H:m:i"); if($recordFile !='') { $query="UPDATE uflexit_users set mobile_number='".$mobile."', first_name='".$first_name."', last_name='".$last_name."', city_name='".$city."', country_id='".$country."', inactive_date='".$inactiveDate."', address='".$address."', postal_code='".$postal."', upload_pic='".$recordFile."' WHERE email='".$email."'"; $row=$this->db->query($query); if($row) { $returnVal = 11; } } else { $query="UPDATE uflexit_users set mobile_number='".$mobile."', first_name='".$first_name."', last_name='".$last_name."', city_name='".$city."', country_id='".$country."', inactive_date='".$inactiveDate."', address='".$address."', postal_code='".$postal."' WHERE email='".$email."'"; $row=$this->db->query($query); if($row) { $returnVal = 12; } } } return $returnVal; } function setFlashMessage($msg,$flag='success'){ $_SESSION['msg'] = $msg; $_SESSION['msg_flag'] = $flag; } function flashMessage(){ if (isset($_SESSION['msg']) && strlen(trim($_SESSION['msg']))) { if($_SESSION['msg_flag']=='error') $_SESSION['msg_flag']='danger'; 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 getCustomerDetails(){ return $this->db->get_row("SELECT u.*,c.company_name FROM uflexit_users u LEFT JOIN uflexit_company c ON c.user_id=u.user_id WHERE u.user_id=".(int)$_SESSION['user_id']); } function get_price($price){ echo '₹'.number_format((float)$price,2); } 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'].",".$post['quotation_status'].",'".$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']."', closed_status='".$post['quotation_status']."' where quotation_id=".$post['quotation_id'].""; $row=$this->db->query($query2); if($query2) { $returnVal=1; } return $returnVal; } /* function savequationrate($post) { $query2="update uflexit_request_quote_track set closed_status='1' where track_id=".$post['quid'].""; $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 token from uflexit_users where token = '".$token."'"; $data=$this->db->get_results($query); return $data[0]['token']; } } ?>