Мне не удалось отфильтровать статус (ожидает рассмотрения, одобрил, отклонил, отменил).

pullout_request_tbl.php

<div>
    <label>Status</label>
    <select id='stat_filter' onchange='SYS_setlist(); settblCol()'>
        <option value="0">Pending</option>
        <option value="1">Approved</option>
        <option value="2">Disapproved</option>
        <option value="3">Cancelled</option>
    </select>
</div>

<div style='margin-top:0.5%; padding:1.5%;' class='table-responsive'>

    <table id='t_maintable0' class='table table-bordered table-striped table-condensed table-hover' >
        <thead>
            <tr>
             <th style='width:5px;'></th>
             <th style='width:50px;'>Pull out No.</th>
             <th style='width:50px;'>Supplier/Business Partner</th>
             <th style='width:55px;'>Date requested</th>
             <th style='width:50px;'>Requested By</th>
             <th style='width:50px;' id='ap_col1'>Date Approved</th>
             <th style='width:50px;' id='ap_col2'>Approved By</th>
             <th style='width:50px;'>Status</th>
             <th style='width:50px;'>View</th>
             <th style='width:50px;'>Edit</th>
             <th style='width:50px;'>Delete</th>

         </tr>
     </thead>
     <tbody>

     </tbody>
 </table>

Функция SYS_setlist (); чтобы получить свадьбу. containerid и статус. Это будет перенаправить на setlist php. Функция resolblCol (); изменит текст с идентификаторами ap_col1 и ap_col2. a_js.js

 function SYS_setlist(){

    var brid=$('#filter_branchid').val();
    var containerid=$('#filter_container').val();

    var status=$("#stat_filter").val();

    var link=URL+"index.php/pullout_request/loadPullOutRequestPendingSetlist?name=Xssd23SqQ&brid="+brid+"&containerid="+containerid+"&status="+status+"";
    SYS_TableServerside2(link,'#t_maintable0'); 
    // $('#t_maintable').css({'visibility':'visible'});

}

function settblCol(){
    var status=$('#stat_filter').val();
    if(status==0){
        $('#ap_col1').text("Approved Date");
        $('#ap_col2').text("Approved By");
    }
    else if(status==1){
        $('#ap_col1').text("Approved Date");
        $('#ap_col2').text("Approved By");
    }
    else if(status==2){
        $('#ap_col1').text("Disapprove Date");
        $('#ap_col2').text("Disapproved By");
    }
    else if(status==3){
        $('#ap_col1').text("Cancelled Date");
        $('#ap_col2').text("Cancelled By");
    }

}

setlist.php . Я думаю, что в этом php-коде ни mysql где-то проблема. К сожалению, я не мог увидеть это и решить.

<?php

$columns = array(
  0 =>'', 
  1 => 'po_num',
  2=> 'bpname',
  3=>'', // Date Requested,   DATE_FORMAT(date_created,'%Y-%m-%d')
  4=>'',  // Requested By
  5=>'',  //approved_date, disapproved_date, cancelled_date
  6=>'',   //approved_by, disapproved_by, cancelled_by
  7=>'status', //status
  8=>'',
  9=>'',
  10=>''

  );
$status=(isset($_GET['a.status']))?$_GET['a.status']:"";

$brid=(isset($_GET['brid']))?$_GET['brid']:"";

$containerid=(isset($_GET['containerid']))?$_GET['containerid']:"";

$q=$this->db->query("
select *, DATE_FORMAT(a.date,'%Y-%m-%d') as date_requested, DATE_FORMAT(approved_date,'%Y-%m-%d') as approved_date,
a.status as astatus,
DATE_FORMAT(disapprove_date,'%Y-%m-%d') as disapprove_date,
DATE_FORMAT(cancelled_date,'%Y-%m-%d') as cancelled_date,
(select wrr from across_draft_addstockdetails where batch_num=a.batch_num  and remark='1' limit 1) as po_num,
(select (select bpname from across_business_partner where bpid=aaa.bpid limit 1) from across_draft_addstockdetails as aaa where batch_num=a.batch_num limit 1) as bpname
  from 
   across_add_stock as a 
   LEFT JOIN  across_add_stock_disapprove as b ON b.batch_num=a.batch_num and b.pid=a.pid
   where
   a.remark='1' and a.status='$status'
");

$r=$q->result_array();    // recordsTotal
$tcnt=count($r);
$data=array();
for($x=0;$x<$tcnt;$x++){ 

  $po_num=($r[$x]['po_num']==0)?"N/A" : $r[$x]['po_num'];
  $bpname=$r[$x]['bpname'];

$date_requested=$r[$x]['date_requested']; // Date Requested

$stat="";
if($r[$x]['astatus']==0){
  $stat="Pending";
}
else if($r[$x]['astatus']==1){
  $stat="Approved";
}
else if($r[$x]['astatus']==2){
  $stat="Disapproved";
}
else if($r[$x]['astatus']==3){
  $stat="Cancelled";
}

$disapprove_date=$r[$x]['disapprove_date'];
$disapproved_by=$r[$x]['disapproved_by'];  

$saved_by=$r[$x]['saved_by']; // Requested By

$q2=$this->db->query("
  select * from across_p_user_account as a
  LEFT JOIN across_p_person as b ON a.eid=b.eid
  where  a.accountid='$saved_by'
  ");


$r2=$q2->result_array();
$saved_by_name=(count($r2)==0)?"N/A":$r2[0]['lname']." ".$r2[0]['ename'].", ".$r2[0]['fname']." ".$r2[0]['mname'];


$approved_by=$r[$x]['approved_by']; 

$q21=$this->db->query("
  select * from across_p_user_account as a
  LEFT JOIN across_p_person as b ON a.eid=b.eid
  where  a.accountid='$approved_by'
  ");


$r21=$q21->result_array();
$approved_by_name=(count($r21)==0)?"N/A":$r21[0]['lname']." ".$r21[0]['ename'].", ".$r21[0]['fname']." ".$r21[0]['mname'];

$approved_date=($r[$x]['approved_date']=="0000-00-00")?"N/A":$r[$x]['approved_date'];



$q211=$this->db->query("
  select * from across_p_user_account as a
  LEFT JOIN across_p_person as b ON a.eid=b.eid
  where  a.accountid='$disapproved_by'
  ");


$r211=$q211->result_array();
$disapproved_by_name=(count($r211)==0)?"":$r211[0]['lname']." ".$r211[0]['ename'].", ".$r211[0]['fname']." ".$r211[0]['mname'];

// Getting the cancelled_date and cancelled_by
$q2111=$this->db->query("
  select * from across_p_user_account as a
  LEFT JOIN across_p_person as b ON a.eid=b.eid
  where  a.accountid='$cancelled_by'
  ");


$r2111=$q2111->result_array();
$cancelled_by_name=(count($r2111)==0)?"":$r2111[0]['lname']." ".$r2111[0]['ename'].", ".$r2111[0]['fname']." ".$r2111[0]['mname'];

$cancelled_date=($r[$x]['cancelled_date']=="0000-00-00")?"N/A":$r[$x]['cancelled_date'];


$appdate="";
$appby="";

if($r[$x]['astatus']==1){
  $appdate=$approved_date;
  $appby=$approved_by_name;
}
else if($r[$x]['astatus']==0){
  $appdate=$approved_date;
  $appby=$approved_by_name;

}
else if($r[$x]['astatus']==2){
  $appdate=$disapprove_date;
  $appby=$disapproved_by_name;

}else if($r[$x]['astatus']==3){
  $appdate=$cancelled_date;
  $appby=$cancelled_by_name;

}

$data[$x] = array(
  0=>"
  <input type='hidden' id='tbl_approved_date$x' value='$approved_date' />
  <input type='hidden' id='tbl_approved_by$x' value='$approved_by_name' />

  <input type='hidden' id='tbl_requested_by$x' value='$save_by_name' />

  <input type='hidden' id='tbl_requested_date$x' value='$date_requested' />

  <input type='hidden' id='tbl_po_num$x' value='$po_num' />
  <input type='hidden' id='tbl_bpname$x' value='$bpname' />
  <input type='hidden' id='tbl_description$x' value='$description' />

  <input type='hidden' id='tbl_disapproved_by$x' value='$disapproved_by_name' />
  <input type='hidden' id='tbl_disapproved_date$x' value='$disapprove_date' />
  <input type='hidden' id='tbl_cancelled_by$x' value='$cancelled_by_name' />
  <input type='hidden' id='tbl_cancelled_date$x' value='$cancelled_date' />

  <input type='hidden' id='tbl_pid$x' value='$pid' />

  <input type='hidden' id='tbl_items$x' value='$r11' />
  <div id='tbl_items_$x' style='display:none;'>$r11</div>
  <input type='hidden' id='tbl_draft_details$x' value='$rditems' />

  ",
  1=>"$po_num",
  2=>"$bpname",
  3=>"$date_requested",
  4=>"$saved_by_name",
  5=>"$appdate",
  6=>"$appby",
  7=> "$stat",
  8=>"<button class='btn' style='width:100%; background:rgba(0,0,0,0);' onclick='view_pullout($x)'><span class='glyphicon glyphicon-search'></span></button>",
  9=>"<button class='btn' style='background:rgba(0,0,0,0); width:100%; font-size:15px;' title='Edit' onclick='pullout_edit($x)'><span class='glyphicon glyphicon-edit'></span></button>",
  10=>"<button class='btn' style='background:rgba(0,0,0,0); width:100%; font-size:15px;' title='Delete' onclick='pullout_delete($x)'><span class='glyphicon glyphicon-remove'></span></button>");


} // end for loop


$json_data = array(
  "draw"            => intval( $_REQUEST['draw'] ),
  "recordsTotal"    => intval(count($r)),
  "recordsFiltered" => intval(count($r1)),
  "data"            => $data
);

echo json_encode($json_data);

?>
0
John Mark

1 ответ

Когда я пытаюсь отфильтровать статус (например, я выбираю утвержденный), данные в таблице не изменяются, так же как отклоняются и отменяются. Я хочу, чтобы при выборе каждого статуса данные отображались по-разному в зависимости от их статуса. Надеюсь, кто-нибудь поможет мне. Благодарность