<?php $custz=$this->db->query("SELECT * FROM sv_activity_sales a LEFT JOIN sv_master_sales b ON a.sales=b.id  WHERE a.pelanggan='".$_POST['m']."' $qz AND YEAR(a.created_on)='".date('Y')."' ORDER BY a.nilai_po DESC")->num_rows();?>

<table width="100%" border="1" cellspacing="0" cellpadding="1">
  <tbody>
    <tr style="background-color: #E2574C!important; color:white!important;">
      <td style="padding-left:5px;padding-right:7px">No</td>
      <td style="padding-left:5px;padding-right:7px">Tanggal</td>
      <td style="padding-left:5px;padding-right:7px">Customer</td>
      <td style="padding-left:5px;padding-right:7px">Sales</td>
      <td style="padding-left:5px;padding-right:7px">Produk</td>
      <td style="padding-left:5px;padding-right:7px">Catatan</td>
      <!--td style="padding-left:5px;padding-right:7px">Jumlah Activity</td-->
      <td style="padding-left:5px;padding-right:7px">Nilai PO</td>
    </tr>
    <?php
    $no=1;
    $total=0;
    foreach($cust as $pelanggan){
        $produk=GetAll('activity_sales_detail',array('activity'=>'where/'.$pelanggan['id']))->result_array();
        $div=array();
                foreach($produk as $pr){
                 $div[]=GetValue('title','master_brand',array('id'=>'where/'.$pr['brand'])).' - '.GetValue('title','master_jenis_produk',array('id'=>'where/'.$pr['jenis_produk'])).' - '.GetValue('title','master_produk',array('id'=>'where/'.$pr['produk']));
                }
        $divisinya=implode('<br/>',$div);
        ?>
    <tr style="background-color: #A9FF96!important;cursor:pointer;">
      <td style="padding-left:5px;padding-right:7px;vertical-align:top"><?php echo $no?></td>
      <td style="padding-left:5px;padding-right:7px;vertical-align:top"><?php echo $pelanggan['created_on']?></td>
      <td style="padding-left:5px;padding-right:7px;vertical-align:top"><?php echo GetValue('title','master_pelanggan',array('id'=>'where/'.$pelanggan['pelanggan']))?></td>
      <td style="padding-left:5px;padding-right:7px;vertical-align:top"><?php echo GetValue('nama_lengkap','master_sales',array('id'=>'where/'.$pelanggan['sales']))?></td>
      <td style="padding-left:5px;padding-right:7px;vertical-align:top"><?php echo $divisinya?></td>
      <td style="padding-left:5px;padding-right:7px;vertical-align:top"><?php echo $pelanggan['catatan']?></td>
      <td style="padding-left:5px;padding-right:7px;vertical-align:top"><?php echo uang($pelanggan['nilai_po'])?></td>
    </tr><?php $no++;
    $total+=$pelanggan['nilai_po']; }?>
    <tr style="background-color: #A9FF96!important;cursor:pointer;">
      
        <td colspan="6" style="padding-left:5px;padding-right:7px;vertical-align:top"><strong>TOTAL</strong></td>
      <td style="padding-left:5px;padding-right:7px;vertical-align:top"><strong><?php echo uang($total)?></strong></td>
    </tr>
    <tr style="background-color: #A9FF96!important;cursor:pointer;">
      
        <td colspan="5" style="padding-left:5px;padding-right:7px;vertical-align:top"><strong>TOTAL Activity</strong></td>
      <td colspan="2" style="padding-left:5px;padding-right:7px;vertical-align:top"><strong><?php echo $custz?> Activity</strong></td>
    </tr>
  </tbody>
</table> 


