

<?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);
						alert('Sukses!');
					   }
					});
				}
			} else {
				return false;
			} 
      }           
}
function changesendby(val,id){
$.ajax({
					   type: "POST",
					   url: "<?php echo site_url("alert_activity/sendby");?>",
					   data: {v:val,i:id},
					   success: function(data){
					   	$('#flex1').flexReload();
						//alert(data);
						alert('Jenis Pengiriman Berhasil Dirubah');
					   }
					});
}
setInterval("$('#flex1').flexReload()",50000 );
$(document).ready(function(e){
$('#time_sent').timepicker({
    
                defaultTime: '<?php echo GetValue('time','sv_alert_setting',array('id'=>'where/1'))?>',
                showMeridian:false
});
});
</script>
<div class="col-md-12">
    <form method="post" action="<?php echo base_url()?>alert_activity/change_time">
       <div class="col-md-12" style="margin-bottom: 10px;"> 
           <div class="col-md-2">Send Time : </div><div class="col-md-2"><input id="time_sent" type="text" name="time" style="height:50%;" value="<?php echo GetValue('time','sv_alert_setting',array('id'=>'where/1'))?>" class="form-control"></div>
       </div>
       <div class="col-md-12" style="margin-bottom: 10px;"> 
        <div class="col-md-2">Message : </div><div class="col-md-8"> <textarea name="content" style="height:80%" class="form-control editor"><?php echo GetValue('content','sv_alert_setting',array('id'=>'where/1'))?></textarea></div> 
        <div class="col-md-1"><button style="height:100%;width:100%;">SAVE</button></div>     </div>
    </form>
</div><br/>
<div class="col-md-12">
    <fieldset>
        <legend>Test Email</legend>
    <form method="post" action="<?php echo base_url()?>alert_activity/tes_sent">
       <div class="col-md-12" style="margin-bottom: 10px;"> 
           <div class="col-md-2">Email Address : </div><div class="col-md-2"><input id="email_test" type="text" name="email_test" style="height:50%;" value="" placeholder="example@google.com" class="form-control"></div><div class="col-md-1"><button style="height:100%;width:100%;">Test Email</button></div>
       </div>
    </form>
    </fieldset>
</div><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">&nbsp;<?php echo $this->session->flashdata('message');?></div></div><?php  }?>

<div class="col-md-12">
    <fieldset>
        <legend>Send Alert To..</legend>
<div class="layout-grid">
	<table id="flex1" style="display:none; "></table>
</div>
    </fieldset>
</div>
<script language="JavaScript" src="<?php echo base_url();?>assets/mz_ckeditor/ckeditor.js" type="text/javascript"></script>
<script>
CKEDITOR.replace( 'content',
{
toolbar :
[
['Source','-','Copy','Paste','Bold','Italic','Underline','Strike','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','Subscript','Superscript','PasteFromWord']
]
});
</script>