JezK
Edit File: myquotation-ajax.php
<?php include_once("adminObj.php"); // include('../../app/checkSession.php'); $data =array(); $limit = ""; $quoteCondition=""; // print_r($_SESSION); if(isset($_GET['wid']) && $_GET['wid']!=''){ $quoteCondition = "urq.warehouse_id=".$_GET['wid']; } else { $quoteCondition = "umw.company_id=".(int)$_SESSION['company_id']; } $tableColumns = array('umw.warehouse_name','us.first_name','us.last_name','uws.closed_status','ur.role_name','urq.quotation_id::TEXT'); if (isset($_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) { $limit = "order by modify_dt desc OFFSET ".$wareHouseAdminObj->db->escape($_GET['iDisplayStart'] )." LIMIT ". $wareHouseAdminObj->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 '%".$wareHouseAdminObj->db->escape($_GET['sSearch'] )."%' OR "; } $whereCondition = substr_replace( $whereCondition, "", -3 ); $whereCondition .= ') '; } $sql= "SELECT urq.quotation_id,uws.closed_status,ur.role_name,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 us.role_id=ur.role_id join uflexit_warehouse_status as uws on uws.status_type=urq.closed_status WHERE $quoteCondition $whereCondition $limit "; $rows = $wareHouseAdminObj->db->get_results($sql); $totalRecord = count($rows); $query="SELECT urq.quotation_id,uws.closed_status,ur.role_name,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 us.role_id=ur.role_id join uflexit_warehouse_status as uws on uws.status_type=urq.closed_status where ".$quoteCondition.$whereCondition; $count_result = $wareHouseAdminObj->db->get_results($query); $count=count($count_result); $totalRecords = 0; if($count>0) { $totalRecords = count($count_result); } // 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_id']==3?'Individual':'Business'; //~ $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="createnewasn.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']='<small class="d-inline-flex tableData smallFont"> <a href="myquotations_edit.php?id='.$fetch['quotation_id'].'"> <img src="images/edit.png" class="mt-1 mr-2"></a> '.$fetch_view.' </small>'; if(isset($_REQUEST['type']) && $_REQUEST['type'] ==2) { $fetch['action']='<small class="d-inline-flex tableData smallFont"> <a href="myquotations_edit.php?type=2&id='.$fetch['quotation_id'].'"> <img src="images/view.png" class="mt-1 mr-2"></a> </small>'; } $data[]=$fetch; } } $data = ["sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $totalRecord, "iTotalDisplayRecords" => $totalRecords, "aaData" => $data ]; echo json_encode($data); exit; ?>