<?php 
		//$opt_sales=GetOptAll('master_sales','-Nama-',array('nama_lengkap'=>'order/asc'),'nama_lengkap');

            $anaknya=anaknya();
            
             if(diaadmin()){
                
        //$wherez['status']='where/Aktif';$qbz='';
            if($this->session->userdata('divisi') && $this->session->userdata('groups')){                
                    $qbz=" WHERE (divisi='".$this->session->userdata('divisi')."' AND groups='".$this->session->userdata('groups')."' )";
                }
                else{
                    if($this->session->userdata('divisi')){
                    $qbz=" WHERE divisi='".$this->session->userdata('divisi')."'";
                    }
                    elseif($this->session->userdata('groups')){
                        $qbz=" WHERE groups='".$this->session->userdata('groups')."'";
                    }
                }
                
            $anak=implode(',',$anaknya);
            $q=" SELECT * FROM (`sv_master_sales`) $qbz ORDER BY `nama_lengkap` asc";
            if($this->session->userdata('divisi')) $and.=" AND `divisi`='".$this->session->userdata('divisi')."'";
                $opt_sales=GetOptQuery($q,'-Name-',array(),'nama_lengkap');
            }
            else{
                $qbz='';
            if($this->session->userdata('divisi') && $this->session->userdata('groups')){                
                    $qbz=" AND (divisi='".$this->session->userdata('divisi')."' AND groups='".$this->session->userdata('groups')."' )";
                }
                else{
                    if($this->session->userdata('divisi')){
                    $qbz=" AND divisi='".$this->session->userdata('divisi')."'";
                    }
                    elseif($this->session->userdata('groups')){
                        $qbz=" AND groups='".$this->session->userdata('groups')."'";
                    }
            }
            $anak=implode(',',$anaknya);
            $q=" SELECT * FROM (`sv_master_sales`) WHERE (`id` =  '".$this->session->userdata('webmaster_marketing')."' OR `leader` IN ($anak)) $qbz ORDER BY `nama_lengkap` asc";
       if($this->session->userdata('divisi')) $and.=" AND `divisi`='".$this->session->userdata('divisi')."'";
                $opt_sales=GetOptQuery($q,'-Name-',array(),'nama_lengkap');
            }
                $opt_year=array(''=>'-Year-');
               for($a=2016;$a<=date('Y');$a++){
                   $opt_year[$a]=$a;
               }
                ?>
<script>
    $(document).ready(function(e){
        $('#datacustomerpo').load('<?php echo base_url()?>dashboard/chart_customer_po_target');
    });
    function cari_sales_planz(){
        var marketingz=$('#salesnya2').val();
        var yearz=$('#year2').val();
        //alert(marketingz);
        ///if(marketing && year){
        $('#datacustomerpo').load('<?php echo base_url()?>dashboard/chart_customer_po_target',{marketingz:marketingz,yearz:yearz});
    }
    //};
    </script>
<style>
    .centerz{
        float:none!important;
        margin:0 auto;
    }
    input[type="text"]{
        padding:0!important;
    }
</style>
<div class="col-md-12">
    <div class="col-md-12 centerz"><center>
            <label></label>&nbsp;&nbsp;&nbsp;<?php echo form_dropdown('marketingz',$opt_sales,$_POST['marketingz'],'class="select2" id="salesnya2"')?>&nbsp;-&nbsp;<?php echo form_dropdown('limit',array(''=>'-Number-','10'=>'10','20'=>'20','50'=>'50',),$_POST['marketing'],'class="select2" id="limit"')?>&nbsp;&nbsp;&nbsp;<input type="text" name="start_bidang" id="start_bidang" class="datepicker" data-provide="datepicker" data-date-format="yyyy-mm-dd" style="border-radius: 5px!important;height:26px;text-indent:37px;" placeholder="Periode : Start">&nbsp;-&nbsp;<input type="text" name="end_bidang" id="end_bidang" class="datepicker" data-provide="datepicker" data-date-format="yyyy-mm-dd" style="border-radius: 5px!important;height:26px;text-indent:37px;" placeholder="Periode : End">
        <button type="button" id="search" onclick="cari_sales_planz()">Search</button></center>
    </div>
</div>
<div id="datacustomerpo"></div>