JezK
Edit File: ajax.php
<?php // ini_set('display_errors',1); if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { // print_r($_SERVER);exit; $ajaxResult=[]; include_once("app/adminObj.php"); $requestFrom=explode("/",$_SERVER['HTTP_REFERER']); if($requestFrom['5']=='master_admin') { // echo "one";exit; if(isset($_REQUEST['process']) && $_REQUEST['process']=='checkExistsOrNot') { $resultJson=json_decode($_POST['data'],true); if($resultJson['type']==1) { $replaceString=str_replace("***"," ",$resultJson['requestedValue']); $rs=$adminObj->checkEmailExistsOrNot($replaceString); $ajaxResult['state']='success'; $ajaxResult['result']=$rs; } else if($resultJson['type']==2) { $replaceString=str_replace("***"," ",$resultJson['requestedValue']); $rs=$adminObj->checkPhoneExistsOrNot($replaceString); $ajaxResult['state']='success'; $ajaxResult['result']=$rs; } echo json_encode($ajaxResult); } if(isset($_REQUEST['process']) && $_REQUEST['process']=='checkUpdatedEmailExistsOrNot') { $emailOrPhone = $_REQUEST['emailOrPhone']; $id = $_REQUEST['id']; $res = $adminObj->checkUpdatedExistsOrNot($emailOrPhone,$id,$_REQUEST['type']); $ajaxResult['state']='success'; $ajaxResult['result']=$res; echo json_encode($ajaxResult); } } } else { //~ echo "Not AJAX"; } if(isset($_REQUEST["action"])&&$_REQUEST["action"]=="getquotationdetails"){ // echo $_REQUEST['quotationid']; $Quotationdata=$adminObj->getwareHouseData($_REQUEST['quotationid']); $ajaxResult['result']=$Quotationdata; // } echo json_encode($ajaxResult); } else { //~ echo "Not AJAX"; } if(isset($_REQUEST["action"]) && $_REQUEST["action"]=="get_warehouses"){ $totalRecords =0; // exit; if($_SESSION['admin_languageStatus'] ==2) { $_SESSION['admin_languageStatus'] = 2; include('lang.ar.php'); // $chcked = "checked"; } else{ $_SESSION['admin_languageStatus'] = 1; include('lang.es.php'); // $chcked = ""; } // print_r($_REQUEST['feature_ids']); // print_r($_REQUEST['storage_ids']); $warehouses=$adminObj->get_warehouse($_REQUEST['feature_ids'],$_REQUEST['storage_ids'],$_REQUEST['services_ids'],$_REQUEST['deals_ids'],$_REQUEST['searchKey'],$_REQUEST['searchData'],$_REQUEST['palletData'],$_REQUEST['spaceData'],$_REQUEST['minValue'],$_REQUEST['maxValue'],$_REQUEST['filterInput']); $warehoseData=''; // print_r($warehouses); // exit; $totalCount= isset($warehouses[0]) ? $warehouses[0] :0 ; if($warehouses==1){ $warehoseData = "<h4 class='text-center py-3'>No warehouses Found</h4>"; }else{ $totalRecords=count($warehouses[1]); // $warehoseData.='<input type="hidden" value="'.$totalRecords.'" />'; if($totalRecords>0){ foreach($warehouses[1] as $wrow) { // print_r($wrow); $wHTML = ""; if ($wrow['warehouse_status'] == 0){ $status = $lang['PENDING']; $color = "text-warning"; $hrefHTML ='<a class="p-2 actionCls green" title="Active" href="warehouseActive.php?type=2&id='.$wrow["warehouse_id"].'"><i title="Active" class="fa fa-check-circle text-primary" aria-hidden="true"></i>'.$lang['ACTIVE'].'</a> <a class="p-2 actionCls red" title="Reject" href="warehouseReject.php?type=2&id='.$wrow["warehouse_id"].'"><i title="Reject" class="fa fa-times-circle-o text-danger" aria-hidden="true"></i>'.$lang['REJECT'].'</a>'; }else if($wrow['warehouse_status'] == 1){ $status = $lang['ACTIVE']; $color = "text-success"; $hrefHTML ='href="warehouseActive.php?id='.$wrow["warehouse_id"].'"'; $hrefHTML ='<a class="p-2 actionCls red" title="Block" href="warehouseInactive.php?type=2&id='.$wrow["warehouse_id"].'"><i title="Block" class="fa fa-ban text-warning" aria-hidden="true"></i>'.$lang['BLOCK'].'</a>'; }else if($wrow['warehouse_status'] == 2){ $status = $lang['REJECTED']; $color = "text-danger"; $hrefHTML =''; }else if($wrow['warehouse_status'] == 3){ $status = $lang['BLOCK']; $color = "text-danger"; $hrefHTML ='<a class="p-2 actionCls green" title="Pending" href="warehouseActive.php?type=2&id='.$wrow["warehouse_id"].'"><i title="Pending" class="fa fa-check-circle text-warning" aria-hidden="true"></i>'.$lang['ACTIVE'].'</a>'; } $imgTag=""; if(isset($wrow['warehouse_logo']) && isset($wrow['warehouse_logo'])!='') { $imgPath = "../uploads/warehouse_imgs/".$wrow['warehouse_logo']; // echo $imgPath;exit; if(file_exists($imgPath)) { $imgTag='<img src="./../uploads/warehouse_imgs/'.$wrow['warehouse_logo'].'" alt="image1" height="200px" width="200%">'; } else { $imgTag='<img src="../pictures/img1.png" alt="image1" height="200px" width="200%">'; } } else { $imgTag='<img src="../pictures/img1.png" alt="image1" height="200px" width="200%">'; } $warehoseData.='<div class="card" onclick="location.href=\'warehouseDetails.php?id='.$wrow['warehouse_id'].'\'"> <div class="card-horizontal book"> <div class="img-square-wrapper pt-4 pb-3 pl-3 align-self-right col-sm-5"> <a href="warehouseDetails.php?id='.$wrow["warehouse_id"].'">'.$imgTag.'</a> </div> <div class="card-body"> <div class="row"> <div class="col-sm-6 "> <p class="text-dark m-0 font-weight-bold">'.$lang['STATUS'].': <span class="'.$color.'">'.$status.'</span></p> </div> <div class="col-sm-6 text-right ipadWareRes"> '.$hrefHTML.' </div> <div class="col-md-6"> <h6 class = "warehouse pt-3"><b>'.$lang['WAREHOUSE_NAME'].'</b></h6> <p class = "pt-2 20px text-dark" style="color: black;">'.$wrow['warehouse_name'].'</p> </div> <div class="col-md-6"> <h6 class = "location pt-3"><b>'.$lang['LOCATION'].'</b></h6> <img src="pictures/location.png" alt="" height="15px"> <label> <p class ="pt-2 20px text-dark">'.$lang[$wrow['city_lang_variable']].', '.$lang[$wrow['lang_variables']].'</p> </label> </i> </div> <div class="col-md-6"> <h6 class = "type pt-4 "><b>'.$lang['WAREHOUSE_ID'].'</b></h6> <p class = "pt-2 20px text-dark">'.$wrow['warehouse_id'].'</p> </div> <div class="col-md-6"> <h6 class = "type pt-4"><b>'.$lang['WAREHOUSE_TYPE'].'</b></h6> <p class = "pt-2 20px text-dark">'.$lang[$wrow['lang_variable']].'</p> </div> </div> </div> </div> </div>' ; // echo $warehoseData; } }else{ $warehoseData = "<h4 class='text-center'>No warehouses Found</h4>"; } } print_r(json_encode(array("warehoseData"=>$warehoseData,"count"=>$totalRecords,"totalCount"=>$totalCount))); } if(isset($_REQUEST["action"]) && $_REQUEST["action"] == "get_currency"){ $currencies=$adminObj->get_currency($_REQUEST['country_id']); ?> <div class="jordan" > <?php foreach($currencies as $currency){ ?> <input type="text" name="currency" class="form-control" placeholder> <span class="currencyType"><?php echo $currency['currency'] ?></span> <?php } ?> </div> <?php } // Get all notifications developed by gowtham if(isset($_REQUEST['action']) && $_REQUEST['action']=="getNotifications"){ $userId=$_REQUEST['userid']; // print_r($_REQUEST); $minVal=$_REQUEST['min']; $notifications=$adminObj->getMasterAdminNotifications($userId,$minVal); // print_r($notifications);exit; $count=isset($notifications[0])? $notifications[0]:0; $notificationdata=isset($notifications[1])? $notifications[1]:0; $notificationDataCount=$notificationdata ? count($notificationdata):0; // print_r($notificationDataCount);exit; $notificationHTML=''; if($notificationDataCount>0){ $status=''; // echo "hii"; $className=''; foreach($notificationdata as $data){ // print_r($data);exit; $notifyMessage=""; if($data['read_status']==0){ $status='<span class="unReadNotifications"></span>'; $className='unRead'; }else{ $status=''; $className=''; $notifyMessage=""; } $sendDatetime=$data['created_date']; $then =new DateTime($data['created_date']); $nowTime=gmdate("Y-m-d H:i:s"); $now = new DateTime($nowTime); $delta = $now->diff($then); // print_r($delta);exit; $str = ''; if(($delta->y !=0) || ($delta->m !=0) || ($delta->d >4)) { $str=date('m/d/Y',strtotime($sendDatetime)); }else { if($delta->d !=0) { if($delta->d != 1) { $str = $delta->d.' days ago'; }else { $str = $delta->d.' day ago'; } }else if($delta->h !=0) { if($delta->h != 1) { $str = $delta->h.' hours ago'; }else { $str = $delta->h.' hour ago'; } }else if($delta->i!=0) { if($delta->i != 1) { $str = $delta->i.' minutes ago'; }else { $str = $delta->i.' minute ago'; } }else if($delta->s!=0) { if($delta->s != 1) { $str = $delta->s.' secs ago'; }else { $str = $delta->s.' sec ago'; } } } if($_SESSION['admin_languageStatus'] ==2) { $notifyMessage=$data['arabicmessage']; } else{ $notifyMessage=$data['message']; } $notificationHTML.=' <div class=" card cardLength ml-2 mr-1 notificationCard '.$className.'"> <a class="dropdown-item " href="'.$data['master_admin_path'].'" onclick="return myfunction('.$data['notification_id'].')"> '.$status.' <p class="text-dark ">'.$notifyMessage.'</p> <div> <font class="text-primary dateLink">'.$str.' </font> </div> </a> </div>' ; } }else{ $notificationHTML=' '; } $notificationArray=array(); // array_push($notificationArray, $count,$notificationHTML) print_r(json_encode(array("notificationData"=>$notificationHTML,"count"=>$count))); } /*updating notification status by gowtham*/ if(isset($_REQUEST['action']) && $_REQUEST['action']=="notificationStatusUpdate"){ $id=isset($_REQUEST['data'])? $_REQUEST['data']:0; $notifications=$adminObj->updateNotificationStatus($id); } if(isset($_REQUEST['action']) && $_REQUEST['action']=="getLangArray"){ // echo "haii"; exit; if($_SESSION['admin_languageStatus'] ==2) { $_SESSION['admin_languageStatus'] = 2; include('lang.ar.php'); // $chcked = "checked"; } else{ $_SESSION['admin_languageStatus'] = 1; include('lang.es.php'); // $chcked = ""; } echo json_encode($lang); } if(isset($_REQUEST["action"]) && $_REQUEST["action"] == "get_cities_list"){ if($_SESSION['admin_languageStatus'] ==2) { $_SESSION['admin_languageStatus'] = 2; include('lang.ar.php'); // $chcked = "checked"; } else{ $_SESSION['admin_languageStatus'] = 1; include('lang.es.php'); // $chcked = ""; } $cities=$adminObj->getcities_function($_REQUEST['country_id']); // print_r($cities); $citiesHTML = '<option value="" class="ml-3">'.$lang['SELECT_CITY'].'</option>'; foreach($cities as $city) { $selected = ""; if(isset($_REQUEST['city']) && $city['city_name']==$_REQUEST['city']){ $selected ="selected"; } $citiesHTML .= '<option value="'.$city['city_name'].'" '.$selected.'>'.$lang[$city['lang_variables']].'</option>'; } echo $citiesHTML; } if(isset($_REQUEST["action"]) && $_REQUEST["action"] == "get_cities"){ if($_SESSION['admin_languageStatus'] ==2) { $_SESSION['admin_languageStatus'] = 2; include('lang.ar.php'); // $chcked = "checked"; } else{ $_SESSION['admin_languageStatus'] = 1; include('lang.es.php'); // $chcked = ""; } $cities=$adminObj->getcities_function($_REQUEST['country_id']); ?> <select name="city" id="city" class="form-control frm-input" > <option value="" selected="selected">Select City</option> <?php foreach($cities as $city){ ?> <option value="<?php echo $city['city_name']; ?>"><?php echo $lang[$city['lang_variables']]; ?></option> <?php } ?> </select> <?php } if(isset($_REQUEST["action"]) && $_REQUEST["action"]=="update_percentage") { $updatePercent=$adminObj->uflexitPercentage($_REQUEST['warehouseId'],$_REQUEST['percentage']); echo $updatePercent; } ?>