<?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){
        $('#datayearly').load('<?php echo base_url()?>dashboard/chart_yearly');
    });
    function cari_yearly(){
        var marketing=$('#marketing').val();
        var year=$('#year').val();
        if(start && end){
        $('#datayearly').load('<?php echo base_url()?>dashboard/chart_yearly',{marketing:marketing,year:year});}
    };
    </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-6 centerz"><center>
            <label></label>&nbsp;&nbsp;&nbsp;<?php echo form_dropdown('marketing',$opt_sales,$_POST['marketing'],'class="select2" id="marketing"')?>&nbsp;-&nbsp;<?php echo form_dropdown('year',$opt_year,$_POST['year'],'class="select2" id="year"')?>
        <button type="button" id="search" onclick="cari_yearly()">Search</button></center>
    </div>
</div>
<div id="datayearly"></div>