<?php 
            $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){
        <?php
        $marketing_major=(!diaadmin()? $this->session->userdata('webmaster_marketing') : '');
        if(!diaadmin()){ ?> <?php }?>
                
        var marketingz=<?php echo $marketing_major?>;
        //var yearz=$('#yearzz').val();
        
        var start=$('#start_major').val();
        var end=$('#end_major').val();
        $('#datamajor').load('<?php echo base_url()?>dashboard/chart_customer_major',{marketing_major:marketingz,s:start,e:end});
    });
    function cari_sales_plan(){
        var marketingz=$('#salesnyaz').val();
        //var yearz=$('#yearzz').val();
        
        var start=$('#start_major').val();
        var end=$('#end_major').val();
        
        $('#datamajor').load('<?php echo base_url()?>dashboard/chart_customer_major',{marketing_major:marketingz,s:start,e:end});
    }
    </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_major',$opt_sales,$_POST['marketingz'],'class="select2" id="salesnyaz"')?>&nbsp;-&nbsp;<input type="text" name="start" id="start_major" 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" id="end_major" 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_plan()">Search</button></center>
    </div>
</div>
<div id="datamajor"></div>