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') { // echo "coming"; $ajaxResult=[]; include_once("app/adminObj.php"); include_once("app/checkSession.php"); $requestFrom=explode("/",$_SERVER['HTTP_REFERER']); $sk=WEBSITENAME; $compareVariable=''; if($requestFrom['2']== 'localhost') //local { $compareVariable=$requestFrom['4']."/"; } else if($requestFrom['2']=='bu1dev.krify.com') { $compareVariable=$requestFrom['3']."/"; } // if($compareVariable==$sk) // { if(isset($_REQUEST['process']) && $_REQUEST['process']=='checkExistsOrNot') { //~ echo 1; $resultJson=json_decode($_POST['data'],true); if($resultJson['type']==1) { $replaceString=str_replace("***"," ",$resultJson['requestedValue']); $rs=$wareHouseAdminObj->checkEmailExistsOrNot($replaceString); $ajaxResult['state']='success'; $ajaxResult['result']=$rs; } else if($resultJson['type']==2) { $replaceString=str_replace("***"," ",$resultJson['requestedValue']); $rs=$wareHouseAdminObj->checkPhoneExistsOrNot($replaceString); $ajaxResult['state']='success'; $ajaxResult['result']=$rs; } else if($resultJson['type']==3) { $replaceString=str_replace("***"," ",$resultJson['requestedValue']); $rs=$wareHouseAdminObj->checkupdatedPhoneExistsOrNot($replaceString); $ajaxResult['state']='success'; $ajaxResult['result']=$rs; // $ajaxResult['row']=$ } else if($resultJson['type']==4) { $replaceString=str_replace("***"," ",$resultJson['requestedValue']); $rs=$wareHouseAdminObj->checkWarehouseNameExistsOrNot($replaceString); $ajaxResult['state']='success'; $ajaxResult['result']=$rs; // $ajaxResult['row']=$ } } else if(isset($_REQUEST['process']) && $_REQUEST['process']=='BringWhNum') { $rs=$wareHouseAdminObj->generateAutoWareHouseNumber(); $ajaxResult['state']='success'; $ajaxResult['result']=$rs; } // } if(isset($_REQUEST["action"]) && $_REQUEST["action"] == "get_quotations"){ // echo "coming4"; $quote_list = $wareHouseAdminObj->get_quotations($_REQUEST["quotationId"]); $ajaxResult['result']=$quote_list; // print_r($quote_list);exit; // echo $quote_list; } if(isset($_REQUEST['action']) && $_REQUEST['action']=="getquotationdetails"){ $Quotationdata=$wareHouseAdminObj->getwareHouseData($_REQUEST['quotationid']); $ajaxResult['result']=$Quotationdata; } if(isset($_REQUEST['action']) && $_REQUEST['action']=="getNotifications"){ $minVal=$_REQUEST['min']; $notifications=$wareHouseAdminObj->getOwnerNotifications($minVal); //~ print_r($notifications);exit; // $notifications=$customerObj->getCustomerNotifications($userId); $count=$notifications[0]? $notifications[0]:0; $notificationdata=$notifications[1]? $notifications[1]:0; $notificationDataCount=$notificationdata ? count($notificationdata):0; // print_r($notificationdata); $notificationHTML=''; if($notificationDataCount>0){ $status=''; $className=''; $notifyMessage=""; foreach($notificationdata as $data){ // print_r($data['message']); if($data['read_status']==0){ $status='<span class="unReadNotifications"></span>'; $className='unRead'; }else{ $status=''; $className=''; } $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['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['warehouse_owner_path'].'" onclick="return myfunction('.$data['notification_id'].')"> '.$status.' <p class="text-dark ">'.$notifyMessage.'</p> <div> <font class="text-primary">'.$str.' </font> </div> </a> </div>' ; } }else{ $notificationHTML=' '; } $notificationArray=array(); // array_push($notificationArray, $count,$notificationHTML) // print_r(json_encode(array("notificationData"=>$notificationHTML,"count"=>$count))); $ajaxResult['result']=array("notificationData"=>$notificationHTML,"count"=>$count); } if(isset($_REQUEST['action']) && $_REQUEST['action']=="notificationStatusUpdate"){ $id=isset($_REQUEST['data'])? $_REQUEST['data']:0; $notifications=$wareHouseAdminObj->updateNotificationStatus($id); } if(isset($_REQUEST["action"]) && $_REQUEST["action"] == "updateShipmentStatus"){ $date=$_REQUEST['dateVal']; $quotationId=$_REQUEST['quotationid']; $res=$wareHouseAdminObj->updateShipmentStatus($quotationId,$date); // echo $res; $ajaxResult['result']=$res; } if(isset($_REQUEST["action"]) && $_REQUEST["action"] == "get_quotationItemDetails"){ $quotationId=$_REQUEST['qid']; $res=$wareHouseAdminObj->getQuotationIteamDetails($quotationId); if($res){ $tableData=''; $i=0; foreach($res as $data){ $id="qty_".$i; $tableData.='<tr> <td><input type="text" id="itemcode" name="itemcode[]" value="'.$data['itemcode'].'" readonly></td> <td><textarea type="text" id="item_desc" name="item_desc[]" value="" class="form-control bgcolor" readonly>'.$data['item_desc'].'</textarea></td> <td><input type="text" id="'.$id.'" name="qty[]" value="'.$data['available_quantity'].'" onkeyup="quantityValidation('.$data['available_quantity'].','.$id.')" onkeypress="return checkPhone(event)"> </td> <td><input type="text" id="ref_number" name="ref_number[]" value="'.$data['ref_number'].'" readonly></td> <td><input type="text" id="cost" name="cost[]" value="'.$data['cost'].'" onkeypress="return checkPhone(event)"></td> <td><input type="text" id="pallet_no" name="pallet_no[]" value="'.$data['pallet_no'].'" readonly></td> <td><input type="text" id="row_val" name="row_val[]" value="'.$data['row_val'].'" readonly></td> <td><input type="text" id="rack" name="rack[]" value="'.$data['rack'].'" readonly></td> <td><input type="text" id="pin" name="pin[]" value="'.$data['pin'].'" readonly></td> <td style="padding:10px !important"><input type="checkbox" class="customWeigth" id="customCheck'.$i.'" name="action'.$i.'" onhange="setValues()" ></td> </tr>'; $i++; } } else{ $tableData=' <tr class="text-center"> <td colspan="10" ><p class="p-2">No data avilable</p></td> </tr> '; } $ajaxResult['result']=$tableData; } if(isset($_REQUEST["action"]) && $_REQUEST["action"] == "get_cities_list"){ if($_SESSION['languageStatus'] ==2) { $_SESSION['languageStatus'] = 2; include('lang.ar.php'); // $chcked = "checked"; } else{ $_SESSION['languageStatus'] = 1; include('lang.es.php'); // $chcked = ""; } $cities=$wareHouseAdminObj->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['languageStatus'] ==2) { $_SESSION['languageStatus'] = 2; include('lang.ar.php'); // $chcked = "checked"; } else{ $_SESSION['languageStatus'] = 1; include('lang.es.php'); // $chcked = ""; } $cities=$wareHouseAdminObj->getcities_function($_REQUEST['country_id']); ?> <select name="city" id="city" class="form-control frm-input" > <option value="" selected="selected"><?php echo $lang['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"] == "get_arqquotations"){ $wid=$_REQUEST['wid']; $year=$_REQUEST['year']; $pendingQuotations = $wareHouseAdminObj->getPendingQuotations($wid,$year); $waitingQuotations=$wareHouseAdminObj->getWaitingQuotations($wid,$year); $closedQuotations=$wareHouseAdminObj->getClosedQuotations($wid,$year); $lostQuotations=$wareHouseAdminObj->getLostQuotations($wid,$year); $wonQuotations=$wareHouseAdminObj->getWonQuotations($wid,$year); // $res=$wareHouseAdminObj->updateShipmentStatus($quotationId,$date); // echo $res; $ajaxResult['result']=$pendingQuotations; $ajaxResult['result1']=$waitingQuotations; $ajaxResult['result2']=$closedQuotations; $ajaxResult['result4']=$lostQuotations; $ajaxResult['result3']=$wonQuotations; } echo json_encode($ajaxResult); } else { echo "Not AJAX"; } ?>