JezK
Edit File: functions.php
<?php // include_once("../app/checkSession.php"); // ini_set('display_errors',1); use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\OAuth; use League\OAuth2\Client\Provider\Google; require_once dirname(__FILE__) .'/../../composer_test/vendor/autoload.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,lang_variables 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,lang_variables 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,lang_variables 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,lang_variables 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,lang_variables 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) { // 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); $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_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) { $subject=$post['wareHouseName']." Warehouse Owner has updated the Warehouse registartion details "; $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']); $this->sendEditMailToMasterAdmin($subject); $data['lastId']=$lastId; $data['status']=2; } } // print_r($data);exit; return $data; } function sendAddMailToMasterAdmin($content){ $baseUrl=HOSTPATH; $subject="Warehouse Registration Details"; $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="'.MAILSLOGOPATH.'" alt="Image" /> </div>` <div style="color: #2157c9;font-size: 24px;text-align:center !important;font-weight: 600;">Warehouse Updated Information</div> <div style="margin:15px;padding:20px !important;"> <p style="font-weight:bold;">'.$content.'</p> <footer> <h3 style="font-size: 18px;color: #308DFD"><br/>Thanks & Regards<br/> Uflexit Team</h3> </footer> </div> </div> </body> </html>'; $query="select email from uflexit_super_administrator"; $result=$this->db->get_results($query); $count=count($result); $arr=[]; for($i=0;$i<$count;$i++){ $to=$result[$i]['email']; array_push($arr, $to); } $mailSend=$this->smtpMail($baseUrl,$htmlContent,$subject,$arr); } function sendEditMailToMasterAdmin($content){ $baseUrl=HOSTPATH; $subject="Warehouse Updated Details"; $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="'.MAILSLOGOPATH.'" alt="Image" /> </div>` <div style="color: #2157c9;font-size: 24px;text-align:center !important;font-weight: 600;">Warehouse Updated Information</div> <div style="margin:15px;padding:20px !important;"> <p style="font-weight:bold;">'.$content.'</p> <footer> <h3 style="font-size: 18px;color: #308DFD"><br/>Thanks & Regards<br/> Uflexit Team</h3> </footer> </div> </div> </body> </html>'; $query="select email from uflexit_super_administrator"; $result=$this->db->get_results($query); $count=count($result); // print_r($result);exit; // echo $count; // exit; // foreach($result as $res){ // $to=$res['email']; // $mailSend=$this->smtpMail($baseUrl,$htmlContent,$subject,$to); // $arr=[]; for($i=0;$i<$count;$i++){ $to=$result[$i]['email']; array_push($arr, $to); } $mailSend=$this->smtpMail($baseUrl,$htmlContent,$subject,$arr); } /** * 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(",",(array) $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_material_transactions order by id desc" ); $id=$result_new['id']+1; $warehouseId=$post['warehouse_id']; //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."')"; $type=1; $quotation_id=$post['quotation_id']; $asn_id=$post['asn_id']; $customer_name=$post['customer_name']; $country=$post['country']; $user_data=$this->db->get_row("select user_id from uflexit_request_quote where quotation_id=$quotation_id"); $user_id=$user_data['user_id']; $email=$post['email'];$city=$post['city'];$itemcode=$post['itemcode'][$i];$item_desc=$this->db->escape($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'); $checkedParam="action".$i; $checked=''; if(isset($post[$checkedParam]) && $post[$checkedParam] !='' ){ $checked=$post[$checkedParam]; $checkedParam="action".$i; } if($itemcode!='' && $checked=='on'){ $query="INSERT INTO uflexit_material_transactions(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,warehouse_id,type,user_id)VALUES ($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."','".$warehouseId."','".$type."',$user_id)"; // echo $query;exit; $row = $this->db->query($query); $query1="select available_quantity,cost from uflexit_onhand_stock where quotation_id=$quotation_id and itemcode='".$itemcode."' "; $res=$this->db->get_row($query1); if($res){ $itemCost=$res['cost']; $itemQty=$res['available_quantity']; $updatedQty=$itemQty-$qty; // echo $updatedQty; $updatedCost=$itemCost-$cost; // echo $updatedCost; $query2="update uflexit_onhand_stock set available_quantity=$updatedQty, cost=$updatedCost where quotation_id=$quotation_id and itemcode='".$itemcode."'"; $result = $this->db->query($query2); } } } $data['status']=2;return $data; } function addReceivedTran($post) { $warehouseId=$post['warehouse_id']; $rand=rand(20,98746); for($i=0;$i<sizeof($post['itemcode']);$i++) { $result_new= $this->db->get_row( "SELECT * from uflexit_material_transactions order by id desc" ); $id=$result_new['id']+1; $type=2; $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=$this->db->escape($post['item_desc'][$i]); $qty=$post['qty'][$i];$ref_number=$post['ref_number'][$i];$cost=$post['cost'][$i];$pallet_no=$post['pallet_no'][$i]; $user_data=$this->db->get_row("select user_id from uflexit_request_quote where quotation_id=$quotation_id"); $user_id=$user_data['user_id']; $row_val=$post['row_val'][$i];$rack=$post['rack'][$i];$pin=$post['pin'][$i];$created_date=date('Y-m-d'); if($itemcode!=''){ $query="INSERT INTO uflexit_material_transactions(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,warehouse_id,type,user_id)VALUES ($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."','".$warehouseId."','".$type."',$user_id)"; $row = $this->db->query($query); $query2="select itemcode,available_quantity,cost from uflexit_onhand_stock where quotation_id=$quotation_id and itemcode='".$itemcode."' "; $res=$this->db->get_row($query2); if($res){ $availableData=$res['available_quantity']; $availableCost=$res['cost']; $updatedQuantity=$availableData+$qty; $updatedCost=$availableCost+$cost; $query1="update uflexit_onhand_stock set available_quantity=$updatedQuantity, cost=$updatedCost where quotation_id=$quotation_id and itemcode='".$itemcode."'"; }else{ $query1="INSERT INTO uflexit_onhand_stock(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,warehouse_id,user_id,initial_quantity,available_quantity)VALUES ($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."','".$warehouseId."',$user_id,$qty,$qty)"; } $row1 = $this->db->query($query1); } } $data['status']=2;return $data; } /** * function name: addWareHouseDetails * decription: This is used for add wareHouse * developed by: lathif */ function addWareHouseDetails($post,$userId) { $data=array(); $createdDate=gmdate("Y-m-d H:m:i"); $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']))); $companyId=strip_tags($this->db->escape(trim($post['companyId']))); $mobile_country_code=strip_tags($this->db->escape(trim($post['mobile_country_code']))); $wareHouseName=strip_tags($this->db->escape(trim($post['wareHouseName']))); //checkwarehouse number $warehouse_number=$this->checkWHNOExistsOrNot($warehouse_number); //echo dirname(__FILE__) . '/class.db.php';exit; $query4="select company_name from uflexit_company where company_id= $companyId"; $result=$this->db->get_row($query4); $company_name=$result['company_name']; $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,company_id) VALUES('".strtolower($wareHouseName)."','".strtolower($alternateWarehouseName)."','".$warehouse_number."','".urldecode($description)."',0,'".$city."','".$address."','".$phoneNumber."','".$email."','".$location."','".(int)$countryId."','".$userId."','".$latitude."','".$longitude."','".$createdDate."','".$mobile_country_code."',$companyId)"; $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 $warehouse_number="WH-".$lastId; $this->updateWarehouseNumber($warehouse_number,$lastId); //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; // $warehose_id=$result1['warehouse_id']; $userId=$_SESSION['user_id']; $notifyType=2; $title='Add Warehouse'; $warehose_id=$lastId; $message= $company_name .' has added ' .$wareHouseName.' warehouse Successfully'; $arabicmessage= $company_name.' اضافت ' .$wareHouseName. ' المستودع بنجاح '; $readStatus=0; $dt = new DateTime(); $dt->setTimezone(new DateTimeZone('UTC')); $date=$dt->format('Y-m-d H:i:s'); $query="select admin_id from uflexit_super_administrator"; $result=$this->db->get_results($query); $count=$result ? count($result):0; for($i=0;$i<$count;$i++){ $receiverId=$result[$i]['admin_id']; $this->addNotification($notifyType,$title,$message,$arabicmessage,$warehose_id,$userId,$receiverId,$date,$readStatus); } $this->sendAddMailToMasterAdmin($message); } } // print_r($data);exit; return $data; } 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) { $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'],2,$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'],3,$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'] = isset($post['warehousePackageType']) ? $post['warehousePackageType'] :2; } else { $post['warehousePackageType'] = 2; } 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(); $post['minPeriodSpace'] = isset($post['minPeriodSpace']) ? $post['minPeriodSpace'] : ""; $post['payment_types'] = isset($post['payment_types']) ? $post['payment_types'] : ""; $post['spaceFrom'] = isset($post['spaceFrom']) ? $post['spaceFrom'] : ""; $post['spaceTo'] = isset($post['spaceTo']) ? $post['spaceTo'] : ""; $post['palletDateFrom'] = isset($post['palletDateFrom']) ? $post['palletDateFrom'] : ""; $post['palletDateTo'] = isset($post['palletDateTo']) ? $post['palletDateTo'] : ""; if(isset($post['wareHousePriceType'])) { $this->editWareHouseMetaData('wareHousePriceType',$post['wareHousePriceType'],$post['ewarehouse_id']);//price types }else{ $this->deleteWareHouseMetaData('wareHousePriceType',$post['ewarehouse_id']); } $this->editWareHouseMetaData('paymentTypes',$post['payment_types'],$post['ewarehouse_id']);//payment types // wareHousePriceType //~ echo $post['removedPallets']; if(isset($post['removedPallets']) && $post['removedPallets'] !="") { $this->deletePriceListData($post['removedPallets']); // delete pallets } if(isset($post['wareHousePriceType']) && !in_array("2", $post['wareHousePriceType']) && (!isset($post['removedPallets']) || (isset($post['removedPallets']) && $post['removedPallets']==''))){ $this->deletePriceListDataByWarehouseId($post['ewarehouse_id'],2); // delete pallets } if(isset($post['removedSpaces']) && $post['removedSpaces']) { $this->deletePriceListData($post['removedSpaces']); // delete spaces } if(isset($post['wareHousePriceType']) && !in_array("3", $post['wareHousePriceType']) && (!isset($post['removedSpaces']) || (isset($post['removedSpaces']) && $post['removedSpaces']==''))){ $this->deletePriceListDataByWarehouseId($post['ewarehouse_id'],3); // delete spaces of warehouse id } // exit; if(isset($post['wareHousePriceType']) && in_array("2", $post['wareHousePriceType'])) { $post['pricelist_id'] = isset($post['pricelist_id']) ? $post['pricelist_id'] : array(); $this->editPriceListData($post['minPallet'],$post['minPalletPeriod'],$post['maxPallet'],$post['maxPalletPeriod'],$post['palletDateFrom'],$post['palletDateTo'],$post['palletPricePday'],2,$post['ewarehouse_id'],$post['pricelist_id']);//pallet } //~ exit; // exit; if(isset($post['wareHousePriceType']) && in_array("3", $post['wareHousePriceType'])) { $post['space_id'] = isset($post['space_id']) ? $post['space_id'] : array(); $this->editPriceListData($post['minSpace'],$post['minPeriodSpace'],$post['maxSpace'],$post['maxPeriodSpace'],$post['spaceFrom'],$post['spaceTo'],$post['spacePerDay'],3,$post['ewarehouse_id'],$post['space_id']);//space //~ exit; } // wareHousePriceType if(isset($post['removedPallets']) && $post['removedPallets'] !="") { $this->deletePriceListData($post['removedPallets']); // delete pallets } if(isset($post['removedSpaces']) && $post['removedSpaces'] !="") { $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'] = 2; } if($post['max_pallet_online_booking'] != ''){ $post['max_pallet_online_booking'] = $post['max_pallet_online_booking']; } else { $post['max_pallet_online_booking'] = 0; } if(isset($post['enable_online_booking']) && $post['enable_online_booking'] != ''){ $post['enable_online_booking'] = $post['enable_online_booking']; } else { $post['enable_online_booking'] = 0; } $post['maxstorageWeight'] = isset($post['maxstorageWeight']) ? $post['maxstorageWeight'] : ""; $post['maxstorageHeight'] = isset($post['maxstorageHeight']) ? $post['maxstorageHeight'] : ""; $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) { $subject=$post['wareHouseName']." Warehouse Owner has updated the Warehouse Pricing details "; // echo $subject;exit; $this->sendEditMailToMasterAdmin($subject); $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) { // print_r($post); $data=array(); $updatedDate=gmdate("Y-m-d H:m:i"); $removedWareHouseImages = (isset($post["removedwareHouseImages"]) && $post["removedwareHouseImages"]!='')?$post["removedwareHouseImages"]:''; if($removedWareHouseImages) { $res=$this->deleteImages("uflexit_warehouse_imgs",$removedWareHouseImages); } $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']!=''){ $count = count($_FILES["warehouse_logo"]["name"]); for($i=0;$i<$count;$i++) { $warehouse_logo=time()."_".rand()."_".str_replace(' ', '_', $files['warehouse_logo']['name'][$i]); // exit; if(move_uploaded_file($files['warehouse_logo']['tmp_name'][$i], "../../uploads/warehouse_imgs/".$warehouse_logo)) { $warehouseLogo = ",warehouse_logo = '".$warehouse_logo."'"; $query = "insert into uflexit_warehouse_imgs(warehouse_logo,created_date,warehouse_id) values('".$warehouse_logo."','".Date("Y-m-d H:i:s")."','".$post['ewarehouse_id']."')"; $result = $this->db->query($query); } } } 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".'"'." ='".$this->db->escape($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']); } $subject=$post['wareHouseName']." Warehouse Owner has updated the Warehouse Additional Information details "; $this->sendEditMailToMasterAdmin($subject); $data['wareHouseId']=$post['ewarehouse_id']; $data['status'] =1;// update success } else{ $data['wareHouseId']=$post['ewarehouse_id']; $data['status'] =0; // update failed } return $data; } function deleteImages($table,$ids){ if($table =='uflexit_warehouse_imgs') { $data=array(); $selQue = "select warehouse_logo from uflexit_warehouse_imgs where id in (".$ids.")"; $result = $this->db->get_results($selQue); $targetDirectory = './../../uploads/warehouse_imgs/'; foreach($result as $k) { if(file_exists($targetDirectory.$k['warehouse_logo'])){ unlink($targetDirectory.$k['warehouse_logo']); } } } $query = "delete from ".$table." where id in (".$ids.")"; $res=$this->db->query($query); } /** * 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']!=''){ $count = count($_FILES["warehouse_logo"]["name"]); for($i=0;$i<$count;$i++) { $warehouse_logo=time()."_".rand()."_".str_replace(' ', '_', $files['warehouse_logo']['name'][$i]); // exit; if(move_uploaded_file($files['warehouse_logo']['tmp_name'][$i], "../../uploads/warehouse_imgs/".$warehouse_logo)) { $warehouseLogo = ",warehouse_logo = '".$warehouse_logo."'"; $query = "insert into uflexit_warehouse_imgs(warehouse_logo,created_date,warehouse_id) values('".$warehouse_logo."','".Date("Y-m-d H:i:s")."','".$post['ewarehouse_id']."')"; $result = $this->db->query($query); } } } 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".'"'." ='".$this->db->escape($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==2) $count=count($arg1); else if($type==3) $count=count($arg1); for($i=0;$i<$count;$i++) { if($type==2) { $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==2) $count1=count($arg1); else if($type==3) $count2=count($arg1); if($type==2) { for($i=0;$i<$count1;$i++) { // if($type==1) // { $p_from= isset($arg5[$i]) ? date("Y-m-d",strtotime($arg5[$i])) : null; $p_to=isset($arg6[$i]) ? date("Y-m-d",strtotime($arg6[$i])) : null; if(isset($priceList_id[$i]) && $priceList_id[$i]){ $query="update uflexit_warehouse_priceList set minimum='".$arg1[$i]."', minimum_period='".$arg2[$i]."', maximum='".$arg3[$i]."', maximum_period='".$arg4[$i]."', 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,price_per_day,warehouse_id,price_type,created_date) VALUES('".$arg1[$i]."','".$arg2[$i]."','".$arg3[$i]."','".$arg4[$i]."','".$arg7[$i]."','".$warehouseId."','".$type."','".$createdDate."')"; } $row = $this->db->query($query); } } else { $arg2 = is_array($arg2) ? $arg2 : array(); for($i=0;$i<$count2;$i++) { //~ $p_from=date("Y-m-d",strtotime($arg5[$i])); //~ $p_to=date("Y-m-d",strtotime($arg6[$i])); $p_from= isset($arg5[$i]) ? date("Y-m-d",strtotime($arg5[$i])) : null; $p_to=isset($arg6[$i]) ? date("Y-m-d",strtotime($arg6[$i])) : null; $arg2[$i] = isset($arg2[$i]) ? $arg2[$i] : ""; $arg7[$i] = $arg7[$i] ? $arg7[$i] : 0; $arg1[$i] = isset($arg1[$i]) ? $arg1[$i] : ""; $arg3[$i] = isset($arg3[$i]) ? $arg3[$i] : ""; $arg4[$i] = isset($arg4[$i]) ? $arg4[$i] : ""; $p_from= isset($arg5[$i]) ? date("Y-m-d",strtotime($arg5[$i])) : null; $p_to=isset($arg6[$i]) ? date("Y-m-d",strtotime($arg6[$i])) : null; if(isset($priceList_id[$i]) && $priceList_id[$i]){ $query="update uflexit_warehouse_priceList set minimum='".$arg1[$i]."', minimum_period='".$arg2[$i]."', maximum='".$arg3[$i]."', maximum_period='".$arg4[$i]."', 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,price_per_day,warehouse_id,price_type,created_date) VALUES('".$arg1[$i]."','".$arg2[$i]."','".$arg3[$i]."','".$arg4[$i]."','".$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']))); $old_password=strip_tags($this->db->escape(trim($post['old_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($old_password,$hash)){ 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=4; } } 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 country_id,INITCAP(country_name) as country_name,display_name,currency,lang_variables 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']))); if(isset($post['companyId'])) $companyId=strip_tags($this->db->escape(trim($post['companyId']))); $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(); if(isset($post['inactiveDate']) && $post['inactiveDate']!='') { $inactiveDate=strip_tags($this->db->escape(trim($post['inactiveDate']))); $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,company_id,inactive_date) VALUES ('".$email."','".$mobile."','".$role."','".$first_name."','".$last_name."','".$city."','".$country."','".$emailactiveToken."','".$email_active."','".$createdDate."','','','','',".$_SESSION['user_id'].",'".$mobile_country_code."',$companyId,'".$inactiveDate."')"; } else{ $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,company_id) VALUES ('".$email."','".$mobile."','".$role."','".$first_name."','".$last_name."','".$city."','".$country."','".$emailactiveToken."','".$email_active."','".$createdDate."','','','','',".$_SESSION['user_id'].",'".$mobile_country_code."',$companyId)";; } //exit; $row=$this->db->query($query); // echo "<script>alert('$row');</script>";exit; if($row) { $this->sendEmailSubAdmin($post,$emailactiveToken,$role);//subadmin Email $returnVal = 3; } } return $returnVal; } function checkEtoken($token){ $query="SELECT * FROM uflexit_users WHERE email_active_token='" .$token. "'"; $result = $this->db->get_row($query); if($result){ return 1; } else{ return 0; } } /** * 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 //$baseUrl="http://localhost/bitbucketworkspace/uflexit/uflexit_web_new"; // $fromName = 'Uflexit'; // // $from='support@uflexit.com'; $to=$post['email']; // $to='vijayakodandapani@krify.net'; $subject='Password Generation for Warehouse Sub-Admin'; $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="'.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; $res=$this->smtpMail($baseUrl,$htmlContent,$subject,$to); 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); $emailactiveToken=$this->generateApiKey(); if($checketoken==1) { if($password == $cnfrmPassword) { $convertedPassword=$this->generateSecuredPassword($password); $query1="UPDATE uflexit_users SET password='$convertedPassword',email_active_token='$emailactiveToken' WHERE email_active_token='$etoken'"; $row1=$this->db->query($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) { //~ print_r($startTime); for($i=0;$i<count($startTime);$i++) { if($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='and pricetype_id='.$id; } $query="select pricetype_id,pricetype_name,lang_variables from uflexit_warehouse_type where pricetype_id!=1 $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($company_id) { $data=array(); $query="SELECT * FROM uflexit_users where role_id='2' AND company_id = ".$company_id." ORDER BY created_date 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"; // } // print_r($_POST); if($checkEmail==1) { $returnVal=1; //$inactiveDate=gmdate("Y-m-d H:m:i"); $subQuery=''; if(isset($post['inactiveDate']) && $post['inactiveDate'] !=''){ $inactiveDate = strip_tags($this->db->escape(trim(date('Y-m-d' ,strtotime($post['inactiveDate']))))); $subQuery="inactive_date='".$inactiveDate."'".","; } $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."', $subQuery 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."', $subQuery address='".$address."', postal_code='".$postal."', mobile_country_code='".$mobile_country_code."' WHERE email='".$email."'"; // exit; // print_r($query);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) { // print_r($post);exit; $company_name=$post['company_name']; $sel = "select * from uflexit_company where company_id='".$post['companyId']."'"; $result = $this->db->get_row($sel); // print_r($result);exit; 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']!=''){ // print_r($files); // exit; $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); } } } $notifyType=3; $title='Update company information'; $userId=$_SESSION['user_id']; $name=$_SESSION['name']; $message=$company_name.' has updated the Company details successfully'; $arabicmessage=$company_name.' الشركة بنجاح قام بتحديث تفاصيل'; $dt = new DateTime(); $dt->setTimezone(new DateTimeZone('UTC')); $date=$dt->format('Y-m-d H:i:s'); $readStatus=0; $warehouseId=0; $query="select admin_id from uflexit_super_administrator"; $result=$this->db->get_results($query); $count=$result ? count($result):0; for($i=0;$i<$count;$i++){ $receiverId=$result[$i]['admin_id']; $this->addNotification($notifyType,$title,$message,$arabicmessage,$warehouseId,$userId,$receiverId,$date,$readStatus); } 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); 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 getwarehouseImages($warehouseId){ $data=array(); $query="select * from uflexit_warehouse_imgs where warehouse_id ='".$warehouseId."'"; $data=$this->db->get_results($query); return $data; } function getWareHouseMainDetails($wareHouseId) { $data=array(); $query="select umw.*,uc.currency from uflexit_master_wareHouse as umw join uflexit_countries as uc on uc.country_id=umw.warehouse_country_id 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 $query; //echo '<br/>'; $data = $this->db->get_results($query); // echo "check"; // print_r($data);exit; //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 company_id =$user_id"; } else { $query= "SELECT * FROM uflexit_master_wareHouse WHERE company_id =$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.company_id=u.company_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); // print_r($data);exit; if($data){ return $data[0]['token']; } } /** * function name: updateWarehouseNumber * decription: Updating subadmin details by admin * developed by: Ramya */ function updateWarehouseNumber($number,$id) { $query="update uflexit_master_wareHouse SET warehouse_number='".$number."' where warehouse_id='".$id."'"; $row = $this->db->query($query); return $row; } /** * function name: Get Quotat * decription: Updating subadmin details by admin * developed by: Ramya */ function getQuotationsInfo($id) { $query = "select urq.*,uc.currency from uflexit_request_quote as urq join uflexit_countries as uc on urq.currency_type=uc.country_id where quotation_id = '".$id."'"; $data=$this->db->get_row($query); return $data; } /** * function name: warehouseDetails * decription: fetching warehouse features type Details * developed by: gowtham */ // function getQuationList($id){ // $query="select quotation_id from uflexit_request_quote where whadmin_id=$id and quotation_status =3 and closed_status != 4 and asn_status=0"; // $quotationData=$this->db->get_results($query); // return $quotationData; // } function getQuationList($id){ $query1="select user_id from uflexit_users where company_id=$id and (role_id=1 or role_id=2)"; // echo $query1; $res=$this->db->get_results($query1); $userArray=array(); foreach($res as $data ){ $userArray[]=$data['user_id']; } $imploded_arr = implode(',', $userArray); $query="select quotation_id from uflexit_request_quote where whadmin_id IN ($imploded_arr) and quotation_status =3 and closed_status != 4 and asn_status=0"; $quotationData=$this->db->get_results($query); return $quotationData; } /** * function name: Get Quotat * decription: Updating subadmin details by admin * developed by: Surendra */ function getCustomerDetailsById($id) { $query = "select user_id,first_name,last_name,email,role_id from uflexit_users where user_id = '".$id."'"; $data=$this->db->get_row($query); return $data; } /** * function name: updateQuotationStatus * decription: Updating subadmin details by admin * developed by: Ramya */ function updateQuotationStatus($post) { $createdDate=gmdate("Y-m-d H:m:i"); $post['expected_rate'] = $post['expected_rate'] ? $post['expected_rate'] : 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['user_id'].",'".date('Y-m-d H:i:s')."','".$post['expected_rate']."',".$post['quotation_status'].",".$post['closed_status'].",'".$post['adminDescription']."','".$post['customer_description']."','".$post['whadmin_id']."')"; $row=$this->db->query($query); $query2="update uflexit_request_quote set admin_expected_rate='".$post['adminExpectedRate']."', quotation_status='".$post['quotation_status']."', closed_status='".$post['closed_status']."', modify_dt='".date('Y-m-d')."', whadmin_description='".$post['adminDescription']."' where quotation_id=".$post['quotation_id'].""; $row=$this->db->query($query2); if($row) { $returnVal=1; } return $returnVal; } /** * function name: deletePriceListDataByWarehouseId * description : This is delete price list info based on warehouse id and type * developed by :Ramya */ function deletePriceListDataByWarehouseId($warehouseId,$type) { $returnVal =''; $query = "delete from uflexit_warehouse_priceList where warehouse_id='".$warehouseId."' and price_type='".$type."'"; $result = $this->db->query($query); if($result) { $returnVal = 1; } return $returnVal; } /** * function name: deleteWareHouseMetaData * description : This is delete meta data based on warehouse id and type * developed by :Ramya */ function deleteWareHouseMetaData($type,$warehouseId) { $returnVal =''; $query = "delete from uflexit_warehouse_meta where warehouse_id='".$warehouseId."' and meta_key='".$type."'"; $result = $this->db->query($query); if($result) { $returnVal = 1; } return $returnVal; } function get_wareHouseData($id){ $query="select uc.currency,urq.quotation_id from uflexit_request_quote as urq join uflexit_master_warehouse as umw ON umw.warehouse_id=urq.warehouse_id join uflexit_countries as uc on uc.country_id=urq.currency_type where urq.quotation_status =3 and urq.closed_status != 4 and umw.company_id=$id"; // $query="select quotation_id from uflexit_request_quote where whadmin_id=$id and closed_status=3"; $quotationData=$this->db->get_results($query); return $quotationData; } function get_quotations($id){ $query="select urq.quotation_id, urq.expected_rate,urq.admin_expected_rate,urq.user_id,umw.warehouse_id,umw.warehouse_id,umw.warehouse_name,umw.warehouse_number,us.first_name,uc.currency from uflexit_request_quote as urq JOIN uflexit_master_warehouse as umw ON urq.warehouse_id=umw.warehouse_id JOIN uflexit_users as us ON urq.user_id=us.user_id join uflexit_countries as uc on urq.currency_type=uc.country_id where urq.quotation_id=$id"; $quotationData=$this->db->get_row($query); return $quotationData; } function addInvocies($postData){ if(isset($postData['quotationid'])) $quotation_id=strip_tags($this->db->escape(trim($postData['quotationid']))); if(isset($postData['invoices'])) $invocies=strip_tags($this->db->escape(trim($postData['invoices']))); if(isset($postData['whname'])) $warehouseName=strip_tags($this->db->escape(trim($postData['whname']))); if(isset($postData['whnumber'])) $warehouseNumber=strip_tags($this->db->escape(trim($postData['whnumber']))); if(isset($postData['customer'])) $customer=strip_tags($this->db->escape(trim($postData['customer']))); if(isset($postData['date'])) $date=strip_tags($this->db->escape(trim($postData['date']))); if(isset($postData['warehouse_id'])) $warehouseId=strip_tags($this->db->escape(trim($postData['warehouse_id']))); if(isset($postData['DescriptionMsg'])) $description=strip_tags($this->db->escape(trim($postData['DescriptionMsg']))); if(isset($postData["totalvalue"])) $totalval=strip_tags($this->db->escape(trim($postData['totalvalue']))); $postData['user_id'] = isset($postData['user_id']) ? $postData['user_id'] : ""; $company_id=$_SESSION['company_id']; $query="insert into uflexit_invoice (user_id,quotation_id,invoice_value,created_by,created_date,warehouse_id,invoice_number,company_id ,grandtotal,description) VALUES(".$postData['user_id'].",'".$quotation_id."','".$postData['invoices']."',".$_SESSION['user_id'].",'".date('Y-m-d', strtotime($postData['date']))."',".$warehouseId.",'0',$company_id,$totalval,'$description') RETURNING invoice_id"; //~ echo $query;exit; //~ $row=$this->db->query($query); $lastRow = $this->db->get_row($query); $invoiceId = $lastRow['invoice_id']; //~ print_r($row); //~ echo $invoiceId= $row; $invoice_number ="INV".$invoiceId; $query2 ="update uflexit_invoice set invoice_number='".$invoice_number."',modify_date='".date('Y-m-d H:i:s')."' where invoice_id='".$invoiceId."'"; //~ echo $query2;exit; $res= $this->db->query($query2); for($i=0;$i<count($postData['Item_No']);$i++){ $itemNo=strip_tags($this->db->escape(trim($postData['Item_No'][$i]))); if($itemNo !="") { $query3="insert into uflexit_invoice_track (invoice_id,invoice_number,user_id,description,quotation_id,invoice_value,numberof_pallets,quantity,price,total,created_by,created_date,item_number) VALUES(".$invoiceId.",'".$invoice_number."',".$postData['user_id'][$i].",'".$postData['Description'][$i]."','".$quotation_id."','".$postData['invoices']."','".$postData['Number_of_Pallets'][$i]."','".$postData['Quantity'][$i]."','".$postData['Price'][$i]."','".$postData['Total'][$i]."',".$_SESSION['user_id'].",'".date('Y-m-d H:i:s')."','".$postData['Item_No'][$i]."')"; //~ echo $query3;exit; $row=$this->db->query($query3); // print_r($row); } } $notifyType=7; $title='Invoice request'; $userId=$_SESSION['user_id']; $name=$_SESSION['name']; $dt = new DateTime(); $dt->setTimezone(new DateTimeZone('UTC')); $date=$dt->format('Y-m-d H:i:s'); $readStatus=0; $query="select urq.user_id,uc.company_name from uflexit_request_quote as urq join uflexit_users as uu on uu.user_id=urq.whadmin_id join uflexit_company as uc on uc.company_id=uu.company_id where quotation_id=$quotation_id"; $res=$this->db->get_row($query); $receiverId=$res['user_id']; $company_name=$res['company_name']; $message=$company_name.' has raised an Invoice to QID: ' .$quotation_id.' for the ' .$warehouseName .' warehouse'; $arabicmessage=$company_name.' تم رفع الفاتورة لعرض الاسعار :' .$quotation_id.' ل ' .$warehouseName .' مستودع'; // echo $message;exit; $this->addNotification($notifyType,$title,$message,$arabicmessage,$warehouseId,$userId,$receiverId,$date,$readStatus); $query1="select admin_id from uflexit_super_administrator"; $result=$this->db->get_results($query1); $count=$result ? count($result):0; for($i=0;$i<$count;$i++){ $receiverId=$result[$i]['admin_id']; $this->addNotification($notifyType,$title,$message,$arabicmessage,$warehouseId,$userId,$receiverId,$date,$readStatus); } return 1; } function getInvoiceInfo($id){ $query="SELECT urq.currency_type,uc.currency, ui.*,umw.warehouse_name,umw.warehouse_number,us.first_name,us.last_name FROM uflexit_invoice as ui JOIN uflexit_master_warehouse as umw on ui.warehouse_id=umw.warehouse_id JOIN uflexit_users as us ON ui.user_id=us.user_id join uflexit_request_quote as urq on urq.quotation_id=ui.quotation_id join uflexit_countries as uc on uc.country_id=urq.currency_type WHERE ui.invoice_id=$id"; $row = $this->db->get_row($query); if($row) { return $row; } return 0; } function getCompanyLogo($company_id){ $query="select uploaded_attachement from uflexit_company_attachements where company_id=$company_id"; $row=$this->db->get_row($query); if($row){ return $row; } return 0; } function getCompanyInfo($company_id){ $query="select cr_number,tax_reg_number,company_name,city_name,address from uflexit_company where company_id=$company_id"; $row=$this->db->get_row($query); if($row){ return $row; } return 0; } function getInvoicesItemsInfo($id){ $query="SELECT * FROM uflexit_invoice_track WHERE invoice_id='$id'"; $data = $this->db->get_results($query); if($data) { return $data; } return 0; } function getQutationslist($id){ $query = "select urq.quotation_id,urq.currency_type,uc.currency from uflexit_request_quote as urq join uflexit_countries as uc on uc.country_id=urq.currency_type where warehouse_id = '".$id."'"; $data=$this->db->get_results($query); return $data; // print_r($data); } function getwareHouseData($id){ $query="select uar.asn_status,uar.quotation_id,uar.warehouse_id,uar.request_type,uar.customer_type,uar.date,uar.price,uar.time,umw.warehouse_name,us.first_name from uflexit_asn_request as uar JOIN uflexit_master_warehouse as umw ON umw.warehouse_id=uar.warehouse_id JOIN uflexit_users as us ON us.user_id=uar.created_by where quotation_id='".$id."'"; $data=$this->db->get_results($query); if($data){ $date=date_create($data[0]['date']); $data[0]['date']=date_format($date,"d-m-Y"); } // print_r($data); return $data; } /** * function name: newAsn * decription: inserting new asn data by owner * developed by: gowtham */ function newAsn($postData){ // print_r($_POST); $createdDate=$this->db->escape(trim(gmdate("Y-m-d H:m:i"))); $userId=$this->db->escape(trim($postData['userId'])); $warehouseId=$this->db->escape(trim($postData['warehouseId'])); $warehouseAdminId=$this->db->escape(trim($postData['warehouseAdminId'])); $quotationid=$this->db->escape(trim($postData['quotationId'])); $customer=$this->db->escape(trim($postData['customer'])); $customerId=$this->db->escape(trim($postData['customerTypeId'])); $customerType=$this->db->escape(trim($postData['customerTypeText'])); $warehouseName=$this->db->escape(trim($postData['warehouseName'])); $warehouseType=$this->db->escape(trim($postData['warehouseType'])); $date=$this->db->escape(trim($postData['date'])); $time=$this->db->escape(trim($postData['time'])); $quoteValue=$this->db->escape(trim($postData['quoteValue'])); $request_type=$this->db->escape(trim($postData['requestType'])); $query="select from_date from uflexit_request_quote where quotation_id=$quotationid "; $result1 = $this->db->get_row($query); $fromDate=$result1['from_date'] ; $dateTimestamp1 = strtotime($fromDate); $dateTimestamp2 = strtotime($date); $status=''; if($dateTimestamp1>$dateTimestamp2){ $status="early"; }else if($dateTimestamp1<$dateTimestamp2){ $status="late"; }else{ $status="on date"; } $query="insert into uflexit_asn_request (warehouse_id,request_type,quotation_id,user_id,customer_type,price,date,time,created_date,created_by,wh_admin_id,asn_status) VALUES ($warehouseId,'".$request_type."',$quotationid,$userId,$customerId,$quoteValue,'$date','".$time."','".$createdDate."',$userId,$warehouseAdminId,'$status')"; $res = $this->db->query($query); 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++) { $itemCode=$this->db->escape(trim($postData['itemcode'][$i])); $itemDescripition=$this->db->escape(trim($postData['item_desc'][$i])); $itemQuantity=$this->db->escape(trim($postData['qty'][$i])); $itemReferenceNum=$this->db->escape(trim($postData['ref_number'][$i])); $cost=$this->db->escape(trim($postData['cost'][$i])); $palletNumber=$this->db->escape(trim($postData['pallet_no'][$i])); if($itemCode!=''){ $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 ('".$itemCode."','".$itemDescripition."',$itemQuantity, $cost,$warehouseId,'".$warehouseType."', '".$palletNumber."',$userId,$quotationid,'".$createdDate."', '".$itemReferenceNum."',$lastId) "; $res = $this->db->query($query); } } if( $res){ $query1="update uflexit_request_quote set asn_status=1 where quotation_id =$quotationid"; $result=$this->db->query($query1); $company_id=$_SESSION['company_id']; $query2="select company_name from uflexit_company where company_id=".$company_id; $res=$this->db->get_row($query2); $companyName=$res['company_name']; // print_r($res); if($result){ $notifyType=15; $title='Add ASN Request'; $name=$_SESSION['name']; $message=$companyName.' has sent you ASN to QID:'.$quotationid." for the ".$warehouseName ." warehouse"; $arabicmessage=$companyName.' عرض الأسعار تم إرسال إشعار الشحن المسبق الى ' .$quotationid." ل ".$warehouseName ." مستودع"; $dt = new DateTime(); $dt->setTimezone(new DateTimeZone('UTC')); $date=$dt->format('Y-m-d H:i:s'); $readStatus=0; $this->addNotification($notifyType,$title,$message,$arabicmessage,$warehouseId,$warehouseAdminId,$userId,$date,$readStatus); return 1; } } } } /** * function name: checkWarehouseNameExistsOrNot * decription: This is for warehouse name exists are not * developed by: Ramya */ function checkWarehouseNameExistsOrNot($name) { $name=strip_tags($this->db->escape(trim($name))); $query="select warehouse_name from uflexit_master_warehouse where warehouse_name='".$name."' "; $result = $this->db->get_row($query); if(is_array($result) && count($result) > 0) { return 0; //already exist } return 1; // not exist } /** * function name: getOwnerNotifications * decription: to display owner notifications * developed by: gowtham */ function getOwnerNotifications($minVal){ $user_id=$_SESSION['user_id']; $newdate = date("Y-m-d", strtotime("-30 days")); $query=" select title,message,arabicmessage,notification_id,created_date from uflexit_notifications where read_status=0 and receiver_id=$user_id and created_date>='$newdate' order by created_date desc "; $result=$this->db->get_results($query); $notificationCount=$result? count($result):0; $query1=" select un.title,un.message,un.arabicmessage,un.notification_id,un.created_date,unt.warehouse_owner_path,un.read_status from uflexit_notifications as un join uflexit_notifications_type as unt on unt.type=un.notification_type where receiver_id=$user_id and un.created_date>='$newdate' order by created_date desc LIMIT 5 OFFSET $minVal "; $notificationData=$this->db->get_results($query1); $notificationArray=array(); array_push($notificationArray,$notificationCount,$notificationData); if($notificationData){ return $notificationArray; }else { return 0; } } function smtpMail($baseUrl,$htmlContent,$subject,$to=null){ // print_r($to);exit;s date_default_timezone_set('Etc/UTC'); // testing // $google_email = 'soniya@krify.net'; // $oauth2_clientId = '187052798677-ns6933vkdc3tbcpnn5qbmt8r0s2vkcvc.apps.googleusercontent.com'; // $oauth2_clientSecret = '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'; // $oauth2_refreshToken = '1//04v4EsHl8DL2TCgYIARAAGAQSNwF-L9IrBh3iOKXjdODvB_d3csxZo9hTenUjP1lBTD9fLU9W60LOK57MF7OmKstsAtSLako2teI'; // $google_email = 'saigowtham@krify.net'; // $oauth2_clientId = '825026943448-mocc3aksa690aj4oloe34ttqh7jr394r.apps.googleusercontent.com'; // $oauth2_clientSecret = 'IQh24zvlySlx1wu0U9Haqdm9'; // $oauth2_refreshToken = '1//04lQL5xQs7qOTCgYIARAAGAQSNwF-L9IryWBHoNmgnXe2V_1KGuUxTPuzCjKr7jHYgGex7xTSI_XPISLGzylJyTiRgkKYBerVmLo'; // $mail = new PHPMailer(TRUE); // try { // $mail->setFrom($google_email, 'Uflexit'); // if(is_array($to)){ // if($to!="") // { // foreach($to as $to1){ // $mail->addAddress($to1); // } // } // } // else{ // $mail->addAddress($to); // } // $mail->Subject = $subject; // $mail->Body =$htmlContent; // $mail->isSMTP(); // $mail->Port = 587; // $mail->SMTPAuth = TRUE; // $mail->SMTPSecure = 'tls'; // $mail->IsHTML(true); // /* Google's SMTP */ // $mail->Host = 'smtp.gmail.com'; // /* Set AuthType to XOAUTH2. */ // $mail->AuthType = 'XOAUTH2'; // /* Create a new OAuth2 provider instance. */ // $provider = new Google( // [ // 'clientId' => $oauth2_clientId, // 'clientSecret' => $oauth2_clientSecret, // ] // ); // /* Pass the OAuth provider instance to PHPMailer. */ // $mail->setOAuth( // new OAuth( // [ // 'provider' => $provider, // 'clientId' => $oauth2_clientId, // 'clientSecret' => $oauth2_clientSecret, // 'refreshToken' => $oauth2_refreshToken, // 'userName' => $google_email, // ] // ) // ); // /* Finally send the mail. */ // if ($mail->send()) { // // echo "Mail sent successfully"; // } else { // // echo "Mail not sent"; // } // } // catch (Exception $e) // { // // echo $e->errorMessage(); // } // catch (\Exception $e) // { // // echo $e->getMessage(); // } $query="Select * from uflexit_smtp_mailandpass"; $result=$result=$this->db->get_row($query); if($result){ $adminemail = $result['mail']; $to =$to; $mail = new PHPMailer; $mail->isSMTP(); /*Outlook host is smtp.office365.com*/ $mail->Host = "smtp.office365.com"; $mail->Port = "587"; /*tls true*/ $mail->SMTPKeepAlive = true; $mail->Mailer = "smtp"; $mail->SMTPSecure = 'tls'; $mail->SMTPAuth = true; $mail->Username = 'info@uflexit.com'; $mail->Password = 'Uflexit@123$'; /* setfrom and username should be always same */ $mail->setFrom('info@uflexit.com'); $mail->addAddress($to); $mail->Subject = $subject; $mail->msgHTML($htmlContent); if (!$mail->send()) { echo 'Mailer Error: ' . $mail->ErrorInfo; // echo "<pre>"; // print_r($mail); die('fail'); }else{ // echo "success"; // die('done'); } } else{ echo "Credential expired"; } } /** * function name: addNotifications * decription: to display owner notifications * developed by: gowtham */ function addNotification($notifyType,$title,$message,$arabicmessage,$warehouseid,$userid,$whadminid,$date,$readStatus){ $arabic=utf8_encode($arabicmessage); $query="insert into uflexit_notifications (notification_type,title,message,warehouse_id,sender_id,receiver_id,created_date,read_status,arabicmessage) VALUES ($notifyType,'$title','$message',$warehouseid,$userid,$whadminid,'$date',$readStatus,N'$arabicmessage')"; $result=$this->db->query($query); // print_r($result); return $result; } /** * * function Name:get warehouseName * description:to display warehouse name * developed by: vijay */ function getNameWarehouse($id){ $query="select warehouse_name from uflexit_master_warehouse where warehouse_id='".$id."'"; $result=$this->db->get_row($query); return $result; } /** * * function Name:updateNotificationStatus * description:to update Notification read status * developed by: gowtham */ function updateNotificationStatus($id){ $query="update uflexit_notifications set read_status=1 where notification_id=$id"; $result=$this->db->query($query); } /** * * function Name:updateShipmentStatus * description:to update date for shipment status * developed by: gowtham */ function updateShipmentStatus($id,$date){ $query="select from_date from uflexit_request_quote where quotation_id=$id "; $result1 = $this->db->get_row($query); $fromDate=$result1['from_date'] ; $dateTimestamp1 = strtotime($fromDate); $dateTimestamp2 = strtotime($date); $status=''; if($dateTimestamp1>$dateTimestamp2){ $status="early"; }else if($dateTimestamp1<$dateTimestamp2){ $status="late"; }else{ $status="on date"; } $query="update uflexit_asn_request set date='$date',asn_status = '$status' where quotation_id=$id RETURNING quotation_id"; $result=$this->db->get_row($query); return $result; } /** * * function Name:responseOrClosedNotification * description:to get notification for customer when owner send response or closed quotation * developed by: gowtham */ function responseOrClosedNotification($post,$id){ $quotation_id=$post['quotation_id']; $senderId=$post['user_id']; $name=$_SESSION['name']; $dt = new DateTime(); $dt->setTimezone(new DateTimeZone('UTC')); $date=$dt->format('Y-m-d H:i:s'); $readStatus=0; $query="select urq.user_id,urq.warehouse_id,umw.company_id,umw.warehouse_name,uc.company_name from uflexit_request_quote as urq join uflexit_master_warehouse as umw on urq.warehouse_id=umw.warehouse_id join uflexit_company as uc on uc.company_id=umw.company_id where quotation_id=$quotation_id"; $result=$this->db->get_row($query); $receiverId=$result['user_id']; $warehouseId=$result['warehouse_id']; $company_name=$result['company_name']; $warehouseName=$result['warehouse_name']; if($id==3){ $notifyType=16; $title='Quotation response '; $message=$company_name.' has Responded to your QID: '.$quotation_id.' for '.$warehouseName.' warehouse'; $arabicmessage=$company_name.' للمستودع تم الرد على عرض الاسعار رقم: '.$quotation_id.' ل '.$warehouseName.' مستودع'; }else if($id==4){ $notifyType=17; $title='Quotation closed'; $message=$company_name.' has closed your QID: '.$quotation_id.' for '.$warehouseName.' warehouse'; $arabicmessage=$company_name.' تم اغلاق عرض الأسعار: '.$quotation_id.' ل '.$warehouseName.' مستودع'; } $this->addNotification($notifyType,$title,$message,$arabicmessage,$warehouseId,$senderId,$receiverId,$date, $readStatus); } /** * * function Name:notificationForEditWareHouse * description:to get notification for master admin when owner change warehouse Details * developed by: gowtham */ function notificationForEditWareHouse($post,$type,$id){ $userId=$_SESSION['user_id']; $warehose_id=$id; $query="select uc.company_name, umw.warehouse_name from uflexit_master_warehouse as umw join uflexit_company as uc on uc.company_id=umw.company_id where umw.warehouse_id=$id "; $res=$this->db->get_row($query); $CompanyName=$res['company_name']; $warehouseName=$res['warehouse_name']; $readStatus=0; $dt = new DateTime(); $dt->setTimezone(new DateTimeZone('UTC')); $date=$dt->format('Y-m-d H:i:s'); if($type==18){ $notifyType=$type; $title='edit Warehouse Details'; $message= $CompanyName .' has updated the ' .$warehouseName.' warehouse Details Successfully'; $arabicmessage= $CompanyName .' قام بتحديث ' .$warehouseName.' تفاصيل المستودع بنجاح'; }else if($type==19){ $notifyType=$type; $title='edit price Details'; $message= $CompanyName .' has updated the ' .$warehouseName.' warehouse Pricing Successfully'; $arabicmessage= $CompanyName .' قام بتحديث ' .$warehouseName.' تسعير للمستودع بنجاح'; }else { $notifyType=$type; $title='edit additional Details'; $message= $CompanyName .' has updated the ' .$warehouseName.' warehouse Additional Information Successfully'; $arabicmessage= $CompanyName .' قام بتحديث ' .$warehouseName.' إضافية بنجاح المستودع معلومات'; } $query1="select admin_id from uflexit_super_administrator"; $result=$this->db->get_results($query1); $count=$result ? count($result):0; for($i=0;$i<$count;$i++){ $receiverId=$result[$i]['admin_id']; $this->addNotification($notifyType,$title,$message,$arabicmessage,$warehose_id,$userId,$receiverId,$date,$readStatus); } } function getQuotationIteamDetails($id){ $query="select itemcode,cost,available_quantity,item_desc,ref_number,pallet_no,row_val,rack,pin from uflexit_onhand_stock where quotation_id=$id and available_quantity !=0"; $result=$this->db->get_results($query); return $result; } function getcities_function($country_id){ // echo "Hello"; $query="SELECT * FROM uflexit_cities WHERE country_id=".$country_id; $cities = $this->db->get_results($query); return $cities; } /** * Function name: quotationlistchart * Decription:This is for bring wareHouse price List data * Developed by: vijay */ // function getClosedQuotations($id,$year){ // function getStartAndEndDate($week, $year) { // $dto = new DateTime(); // $dto->setISODate($year, $week); // // print_r($dto); // $ret['week_start'] = $dto->format('Y-m-d'); // $dto->modify('+6 days'); // $ret['week_end'] = $dto->format('Y-m-d'); // return $ret; // } // $week_array = getStartAndEndDate(date('W'),date('Y')); // // print_r($week_array); // $query="select * from uflexit_request_quote WHERE date_part('year', modify_dt) = '$year' and closed_status=4 and warehouse_id='".$id."'"; // $data=$this->db->get_results($query); // // print_r($data); // return $data; // } // function getAcceptedQuotations($id,$year){ // function getStartAndEndDate1($week, $year) { // $dto = new DateTime(); // $dto->setISODate($year, $week); // // print_r($dto); // $ret['week_start'] = $dto->format('Y-m-d'); // $dto->modify('+6 days'); // $ret['week_end'] = $dto->format('Y-m-d'); // return $ret; // } // $week_array = getStartAndEndDate1(date('W'),date('Y')); // // print_r($week_array); // $query="select * from uflexit_request_quote WHERE date_part('year', modify_dt) = '$year' and quotation_status=3 and closed_status!=4 and warehouse_id='".$id."'"; // $data=$this->db->get_results($query); // // print_r($data); // return $data; // } // function getAllQuotations($id,$year){ // function getStartAndEndDate2($week, $year) { // $dto = new DateTime(); // $dto->setISODate($year, $week); // // print_r($dto); // $ret['week_start'] = $dto->format('Y-m-d'); // $dto->modify('+6 days'); // $ret['week_end'] = $dto->format('Y-m-d'); // return $ret; // } // $week_array = getStartAndEndDate2(date('W'),date('Y')); // // print_r($week_array); // $query="select * from uflexit_request_quote WHERE date_part('year', modify_dt) = '$year' and whadmin_id='".$_SESSION['user_id']."'and warehouse_id='".$id."'"; // $data=$this->db->get_results($query); // // print_r($data); // return $data; // } function getPendingQuotations($id,$year){ function getStartAndEndDate($week, $year) { $dto = new DateTime(); $dto->setISODate($year, $week); // print_r($dto); $ret['week_start'] = $dto->format('Y-m-d'); $dto->modify('+6 days'); $ret['week_end'] = $dto->format('Y-m-d'); return $ret; } $week_array = getStartAndEndDate(date('W'),date('Y')); // print_r($week_array); $query="select * from uflexit_request_quote WHERE date_part('year', modify_dt) ='$year' and closed_status=0 and warehouse_id='".$id."'"; $data=$this->db->get_results($query); // print_r($data); return $data; } function getWaitingQuotations($id,$year){ function getStartAndEndDate1($week, $year) { $dto = new DateTime(); $dto->setISODate($year, $week); // print_r($dto); $ret['week_start'] = $dto->format('Y-m-d'); $dto->modify('+6 days'); $ret['week_end'] = $dto->format('Y-m-d'); return $ret; } $week_array = getStartAndEndDate1(date('W'),date('Y')); // print_r($week_array); $query="select * from uflexit_request_quote WHERE date_part('year', modify_dt) = '$year' and closed_status=1 and warehouse_id='".$id."'"; $data=$this->db->get_results($query); // print_r($data); return $data; } function getClosedQuotations($id,$year){ function getStartAndEndDate2($week, $year) { $dto = new DateTime(); $dto->setISODate($year, $week); // print_r($dto); $ret['week_start'] = $dto->format('Y-m-d'); $dto->modify('+6 days'); $ret['week_end'] = $dto->format('Y-m-d'); return $ret; } $week_array = getStartAndEndDate2(date('W'),date('Y')); // print_r($week_array); $query="select * from uflexit_request_quote WHERE date_part('year', modify_dt) = '$year' and closed_status=4 and warehouse_id='".$id."'"; $data=$this->db->get_results($query); // print_r($data); return $data; } function getLostQuotations($id,$year){ // function getStartAndEndDate2($week, $year) { // $dto = new DateTime(); // $dto->setISODate($year, $week); // // print_r($dto); // $ret['week_start'] = $dto->format('Y-m-d'); // $dto->modify('+6 days'); // $ret['week_end'] = $dto->format('Y-m-d'); // return $ret; // } $week_array = getStartAndEndDate2(date('W'),date('Y')); // print_r($week_array); $query="select * from uflexit_request_quote WHERE date_part('year', modify_dt) = '$year' and closed_status=2 and warehouse_id='".$id."'"; $data=$this->db->get_results($query); // print_r($data); return $data; } function getWonQuotations($id,$year){ // function getStartAndEndDate2($week, $year) { // $dto = new DateTime(); // $dto->setISODate($year, $week); // // print_r($dto); // $ret['week_start'] = $dto->format('Y-m-d'); // $dto->modify('+6 days'); // $ret['week_end'] = $dto->format('Y-m-d'); // return $ret; // } $week_array = getStartAndEndDate2(date('W'),date('Y')); // print_r($week_array); $query="select * from uflexit_request_quote WHERE date_part('year', modify_dt) = '$year' and closed_status=3 and warehouse_id='".$id."'"; $data=$this->db->get_results($query); // print_r($data); return $data; } /** * function name:Quotation details * Description:To Get all Quotation lists * Developed by:soniya */ function getStartAndEndDateforGraph($week, $year) { $dto = new DateTime(); $dto->setISODate($year, $week); // print_r($dto); $ret['week_start'] = $dto->format('Y-m-d'); $dto->modify('+6 days'); $ret['week_end'] = $dto->format('Y-m-d'); return $ret; } function get_year($id) { $query="SELECT DATE_PART('year', from_date::date) AS year FROM uflexit_request_quote WHERE warehouse_id='".$id."' and from_date is not NULL GROUP BY year order by year desc"; $data=$this->db->get_results($query); return $data; } } ?>