

<?php //if(dialeader() || diaadmin()){?>
<div class="col-sm-12 col-md-12">
    <button data-toggle="collapse" data-target="#demo" class="btn-danger btn">Search</button>
<fieldset style="border:1px solid #D4011B; padding-bottom:10px; border-radius:5px;" class="col-md-12 collapse <?php if(isset($_POST['search'])) echo "in"?>" id="demo">
	
	<form enctype="multipart/form-data" method="post" action="<?php echo base_url() ?>master_pelanggan">
            <div class="col-sm-12 col-md-12" style="margin-top:10px">
                           <div class="col-sm-6 col-md-6"  style="float:none!important;margin:0 auto;"><?php echo form_dropdown('pelanggan',$opt_search,$_POST['pelanggan'],'class="select2"')?> &nbsp; &nbsp; &nbsp;
                           <?php echo form_dropdown('bidang',$opt_activity,$_POST['bidang'],'class="select2"')?> </div>
            </div>
            <!--div class="col-sm-12 col-md-12" style="margin-top:12px;"> 
			   <div class="col-sm-6 col-md-6" style="float:none!important;margin:0 auto;"><label>Periode</label>
                           &nbsp; 
                               <?php $nm_f='from';?><input type="text" name="from" id="from" class="datepicker" data-provide="datepicker" data-date-format="yyyy-mm-dd" value="<?php echo (isset($_POST['from']) ? $_POST['from'] : '')?>">
                           <?php $nm_f='to'?>
                            - &nbsp;<input type="text" name="to" id="to" class="datepicker" data-provide="datepicker" data-date-format="yyyy-mm-dd" value="<?php echo (isset($_POST['to']) ? $_POST['to'] : '')?>"></div>
            </div-->
			<?php echo form_hidden('lastq',$lastq);?>
            <div class="col-sm-12 col-md-12"><div class="col-sm-12 col-md-12"><input type="submit" value="Search" name="search">&nbsp;<input type="submit" value="Export" name="export"></div></div>
	<div class="col-sm-12" style="margin-top:10px"></div>
	
	</form>

</fieldset></div><?php // }?><br/><?php if($this->session->flashdata('message')){?>
<div class="col-sm-12" style="padding-left:0px!important; margin-top: 20px;">  <div class="alert alert-info"><?php echo $this->session->flashdata('message');?></div></div><?php  }?>
<?php
error_reporting(0);
 echo $js_grid; ?>
<!--input type="button" value="Tambah" onclick="window.location = '<?//= base_url() ?>index.php/ms_con/add'"/-->
<script type="text/javascript">
var _base_url = '<?php echo  base_url() ?>';
var controller = '<?php echo $this->utama?>/';
function del(id) { 
  i = confirm('Hapus : ' + id + ' ?');
  if (i) {
    window.location = _base_url + controller + 'delete/' + id;
  }
}
//$('.flex1').flexigrid({height:'auto',width:'auto',striped:false});

function edit(id) {
  window.location = _base_url + controller + 'input/' + id;
}

function detail(id) {
  window.location = _base_url + controller + 'form/' + id;
}
function btn(com,grid)
{
    if (com == 'add' ) {
		window.location = _base_url + controller + 'form/';
    }
	
    if (com == 'select' )
    {
		$('.bDiv tbody tr',grid).addClass('trSelected');
    }

    if (com == 'deselect')
    {
		$('.bDiv tbody tr',grid).removeClass('trSelected');
    }
	if(com=='edit'){
		if($('.trSelected',grid).length==1){ 
    			var abbr = [];
    				$('.hDiv th', flex).each( function(index){
       			 abbr[index] = $(this).attr('abbr');
  				  });
		//var items = $('.trSelected',grid);
 		 window.location = _base_url + controller + 'form/' + $('td:nth-child('+ (1+$.inArray('idnya',abbr)) +')>div', '.trSelected',grid).text();
			} else {
				return false;
			} 
	}
	if (com=='delete')
    {
           if($('.trSelected',grid).length>0){
			   if(confirm('Delete ' + $('.trSelected',grid).length + ' items?')){
		        var flex = $(grid).closest('.flexigrid');
    			var abbr = [];
    				$('.hDiv th', flex).each( function(index){
       			 abbr[index] = $(this).attr('abbr');
  				  });
    	
   				 $('.res').html('');//div.res - area for display result
		            var items = $('.trSelected',grid);
		            var itemlist ='';
		        	for(i=0;i<items.length;i++){
					//itemlist+=items[i].id+",";
					//var iteming=$('td:"no_reg" >div', items[i]).text();
					itemlist+=$('td:nth-child('+ (1+$.inArray('idnya',abbr)) +')>div', items[i]).text()+",";
					}
					  	
					$.ajax({
					   type: "POST",
					   url: "<?php echo site_url($this->utama."/deletec");?>",
					   data: "items="+itemlist,
					   success: function(data){
					   	$('#flex1').flexReload();
						//alert(data);
						if(data=='ok'){
						alert('Sukses!');}
						else{
							alert('Failed to Delete Data');
						}
					   }
					});
				}
			} else {
				return false;
			} 
      }           
}
setInterval("$('#flex1').flexReload()",50000 );
</script>
<div class="col-sm-12" style="padding-left:0px!important; margin-top: 20px;">
<div class="layout-grid">
	<table id="flex1" style="display:none; "></table>
</div>
</div>