JezK
Edit File: rating_ajax.php
<?php // ini_set('display_errors',1); include_once("adminObj.php"); include('checkSession.php'); if($_SESSION['customer_languageStatus'] ==2) { $_SESSION['customer_languageStatus'] = 2; include('../lang.ar.php'); } else{ $_SESSION['customer_languageStatus'] = 1; include('../lang.es.php'); } $data =array(); $limit = ""; $quoteCondition=""; $quoteCondition = "user_id=".(int)$_SESSION['customer_user_id']; $tableColumns = array('urq.quotation_id::Text','umw.warehouse_name::Text','uws.request_status'); if (isset($_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) { $limit = "OFFSET ".$customerObj->db->escape($_GET['iDisplayStart'] )." LIMIT ". $customerObj->db->escape($_GET['iDisplayLength'] ); } // $order="Order by warehouse_id desc"; $whereCondition = ""; if ( $_GET['sSearch'] != "" ) { $whereCondition = "and ("; for ( $i=0 ; $i<count($tableColumns) ; $i++ ) { $whereCondition .= $tableColumns[$i]." ILIKE '%".$customerObj->db->escape($_GET['sSearch'] )."%' OR "; } $whereCondition = substr_replace( $whereCondition, "", -3 ); $whereCondition .= ') '; } $sql= "SELECT urq.quotation_id,uws.request_status,uws.request_status_variables,urq.rating_status,urq.warehouse_rating,umw.warehouse_name FROM uflexit_request_quote as urq JOIN uflexit_master_warehouse as umw ON umw.warehouse_id=urq.warehouse_id join uflexit_warehouse_status as uws on uws.status_type=urq.warehouse_request_type WHERE $quoteCondition $whereCondition and urq.quotation_status=3 $limit "; // echo $sql; $rows = $customerObj->db->get_results($sql); // print_r($rows); $totalRecord = $rows ? count($rows) :0; $sql1="SELECT urq.quotation_id,urq.rating_status,uws.request_status_variables,urq.warehouse_rating,umw.warehouse_name FROM uflexit_request_quote as urq JOIN uflexit_master_warehouse as umw ON umw.warehouse_id=urq.warehouse_id join uflexit_warehouse_status as uws on uws.status_type=urq.warehouse_request_type WHERE $quoteCondition $whereCondition and urq.quotation_status=3"; $count = $customerObj->db->get_results($sql1); $totalRecords = $count ? count($count) :0; // print_r($totalRecords);exit; if($totalRecord>0) { $j=1; foreach($rows as $fetch) { // print_r($fetch); // if(isset($fetch['warehouse_request_type']) && $fetch['warehouse_request_type']==1){ // $fetch['warehouse_request_type']='Online'; // }else if(isset($fetch['warehouse_request_type']) && $fetch['warehouse_request_type']==0){ // $fetch['warehouse_request_type']='Request Quote'; // } // $fetch['req_status']=$lang[$fetch['request_status_variables']]; $ratedStars=''; $normalStars=''; if( $fetch['rating_status']=='1'){ $button='<button class="btn ratingButton px-3 rated-button" name="rating" disabled>'.$lang['SUBMIT'].'</button>'; }else{ $button='<button type="submit" class="btn ratingButton px-3" name="rating">'.$lang['SUBMIT'].'</button> '; } if(isset($fetch['rating_status']) && $fetch['rating_status']==null || $fetch['rating_status']!=1){ // if($fetch['rating_status']==null){ $fetch['rating']=' <form method="post" action="app/rating_app.php"><div class="star-rating"> '. $button.'<input type="radio" id="5-stars'.$fetch['quotation_id'].'" name="rating'.$fetch['quotation_id'].'" value="5" /> <label for="5-stars'.$fetch['quotation_id'].'" class="star">★</label> <input type="radio" id="4-stars'.$fetch['quotation_id'].'" name="rating'.$fetch['quotation_id'].'" value="4" /> <label for="4-stars'.$fetch['quotation_id'].'" class="star">★</label> <input type="radio" id="3-stars'.$fetch['quotation_id'].'" name="rating'.$fetch['quotation_id'].'" value="3" /> <label for="3-stars'.$fetch['quotation_id'].'" class="star">★</label> <input type="radio" id="2-stars'.$fetch['quotation_id'].'" name="rating'.$fetch['quotation_id'].'" value="2" /> <label for="2-stars'.$fetch['quotation_id'].'" class="star">★</label> <input type="radio" id="1-star'.$fetch['quotation_id'].'" name="rating'.$fetch['quotation_id'].'" value="1" /> <label for="1-star'.$fetch['quotation_id'].'" class="star">★</label> <input type="hidden" name="quoid" value="'.$fetch['quotation_id'].'" </div> </form>'; }else{ if(isset($fetch['warehouse_rating']) && $fetch['warehouse_rating']>0){ for($i=5;$i>0;$i--){ $checked=""; if($fetch['warehouse_rating'] == $i) { $checked="checked"; } $ratedStars.='<input type="radio" id="'.$i.'-stars'.$fetch['quotation_id'].'" name="rating_'.$fetch['quotation_id'].'" value="'.$i.'" '.$checked.'/><label for="'.$i.'-stars'.$fetch['quotation_id'].'" class="star">★</label>' ; } } // $ratedStars = '<div class="star-rating"> // <input type="radio" id="5-stars" name="rating" value="5" checked/> // <label for="5-stars" class="star">★</label> // <input type="radio" id="4-stars" name="rating" value="4" checked/> // <label for="4-stars" class="star">★</label> // <input type="radio" id="3-stars" name="rating" value="3" checked/> // <label for="3-stars" class="star">★</label> // <input type="radio" id="2-stars" name="rating" value="2" checked /> // <label for="2-stars" class="star">★</label> // <input type="radio" id="1-star" name="rating" value="1" /> // <label for="1-star" class="star">★</label> // </div>'; // print_r($ratedStars); // exit; $fetch['rating']='<div class="star-rating" style="pointer-events:none !important; ">'.$button.''.$ratedStars.'</div>'; // echo $lang[$fetch['request_status_variables']]; // exit; // echo $fetch['req_status']; } $data[]=$fetch; } } $data = ["sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $totalRecord, "iTotalDisplayRecords" => $totalRecords, "aaData" => $data ]; echo json_encode($data); exit; ?>