JezK
Edit File: myquotation-ajax.php
<?php include_once("adminObj.php"); include('./checkSession.php'); $data =array(); $limit = ""; $quoteCondition=""; // print_r($_SESSION); $quoteCondition = "us.user_id=".(int)$_SESSION['customer_user_id']; $tableColumns = array('warehouse_name','first_name','last_name','urq.quotation_id::TEXT','uws.closed_status','ur.role_name'); if (isset($_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) { $limit = "order by modify_dt desc 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 ur.role_name,uws.closed_status,urq.quotation_id,urq.asn_status,us.first_name,us.last_name,us.role_id,umw.warehouse_name FROM uflexit_request_quote as urq JOIN uflexit_master_warehouse as umw on umw.warehouse_id=urq.warehouse_id JOIN uflexit_users as us ON us.user_id=urq.user_id join uflexit_roles as ur on ur.role_id=us.role_id join uflexit_warehouse_status as uws on uws.status_type=urq.closed_status WHERE $quoteCondition $whereCondition $limit "; $rows = $customerObj->db->get_results($sql); $totalRecord = $rows?count($rows):0; $query="SELECT urq.*,us.first_name,us.last_name,us.role_id,umw.warehouse_name FROM uflexit_request_quote as urq JOIN uflexit_master_warehouse as umw on umw.warehouse_id=urq.warehouse_id JOIN uflexit_users as us ON us.user_id=urq.user_id join uflexit_roles as ur on ur.role_id=us.role_id join uflexit_warehouse_status as uws on uws.status_type=urq.closed_status where ".$quoteCondition.$whereCondition; $count_result = $customerObj->db->get_results($query); $count=$count_result?count($count_result):0; $totalRecords = $count; // print_r($totalRecords);exit; if($totalRecord>0) { $j=1; foreach($rows as $fetch) { // $fetch['warehouse_name']='<a href="viewhistory.php?uid='.$fetch['quotation_id'].'">'.$fetch['warehouse_name'].'</a>'; // echo $fetch['warehouse_name']; $fetch['customer_name']=$fetch['first_name'].' '. $fetch['last_name']; $fetch['customer_type']=$fetch['role_name']; //~ $fetch['status']=$fetch['quotation_status']?'Approved':'Pending'; // switch ($fetch['closed_status']) { // case "0": // $closedStatus = "Pending"; // break; // case "1": // $closedStatus = "Awaiting"; // break; // case "2": // $closedStatus = "Lost"; // break; // case "3": // $closedStatus = "Won"; // break; // case "4": // $closedStatus = "Finally Closed"; // break; // default: // $closedStatus = "Pending"; // } // $fetch['status'] = $closedStatus ; $fetch_view=''; // if($fetch['closed_status']=='3') // { // $fetch_view='<a href="#" ><img src="images/view.png" alt="view">dfds</a>'; // } if($fetch['closed_status']=='Won' && $fetch['asn_status']=='0') { $fetch_view='<a href="newasn.php?q_id='.$fetch['quotation_id'].'" title="ASN" class="btn">ASN</a>'; } // $fetch['view']=$fetch['closed_status']=='0'?'<a href="#" onclick='jQuery("#quotation_id").val($qlist["quotation_id"])" data-toggle='modal' data-target='#myModal'><img src='images/view.png' alt='view'>dfds</a>' : ' <a href='asnlist.php?q_id=<?php echo $qlist['quotation_id']; ' title="ASN">ASN</a>'; $fetch['id'] = $j++; $fetch['action']='<div class="d-inline-flex tableData smallFont"> <a href="update_quotation_status.php?id='.$fetch['quotation_id'].'"> <img src="warehouse_admin/images/edit.png" class="mt-1 mr-2"></a> '.$fetch_view.' </div>'; $data[]=$fetch; } } $data = ["sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $totalRecord, "iTotalDisplayRecords" => $totalRecords, "aaData" => $data ]; echo json_encode($data); exit; ?>