<?php error_reporting(E_ALL ^ E_NOTICE);
if(isset($list)){	
	$val=$list->row_array();
}
?>

    
<div class="row">
	<ul class="breadcrumb">
        <li>
            <a href="#">Home</a>
        </li>
        <li>
            <a href="<?php echo base_url($this->utama)?>"><?php echo ucwords(str_replace('_',' ',$this->utama))?></a>
        </li>
        <li>
            <a href="#"><?php echo $type?></a>
        </li>
    </ul>
    <div class="box col-md-12">
    <div class="box-inner">
    <div class="box-header well" data-original-title="">
        <h2><!--i class="<?php echo GetValue('icon','sv_menu',array('filez'=>'where/'.$this->utama))?>"></i--> <?php echo $this->title;?></h2>

        
    </div>
    	<div class="box-content">
       <form id="form" method="post" enctype="multipart/form-data" action="<?php echo base_url($this->utama)?>/submit" class="form-horizontal formular" role="form">
		   
		   <?php echo form_hidden('id',isset($val['id']) ? $val['id'] : '')?>
				
				<?php echo form_hidden('redirect',isset($_GET['redirect']) ? $_GET['redirect'] : '')?>
				<?php echo form_hidden('formid',isset($_GET['formid']) ? $_GET['formid'] : '')?>
			
		   
		   <div class="form-group">
			   
			   <?php $nm_f="nama_lengkap";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_input($nm_f,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='col-sm-4 ' id='$nm_f'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="nama_panggilan";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_input($nm_f,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='col-sm-4 ' id='$nm_f'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="tempat_lahir";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_input($nm_f,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='col-sm-4 ' id='$nm_f'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="tanggal_lahir";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_input($nm_f,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='col-sm-4  date-picker' id='$nm_f' data-date-format='yyyy-mm-dd'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="jenis_kelamin";?> 
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_radio($nm_f,'Laki-laki',(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='' id='$nm_f'")?>&nbsp;&nbsp;<label>Laki-laki</label>&nbsp;
                                           <?php echo form_radio($nm_f,'Perempuan',(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='' id='$nm_f'")?>&nbsp;&nbsp;<label>Perempuan</label>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="alamat";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_textarea($nm_f,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='col-sm-4 ' id='$nm_f'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="telp1";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_input($nm_f,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='col-sm-4 ' id='$nm_f'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="telp2";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_input($nm_f,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='col-sm-4 ' id='$nm_f'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="wa";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo strtoupper(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_input($nm_f,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='col-sm-4 ' id='$nm_f'")?>
				  
			   </div>
		   </div>
		   <!--div class="form-group">
			   
			   <?php $nm_f="pin_bb";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_input($nm_f,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='col-sm-4 ' id='$nm_f'")?>
				  
			   </div>
		   </div-->
		   <div class="form-group">
			   
			   <?php $nm_f="email";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_input($nm_f,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='col-sm-4 ' id='$nm_f'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="divisi";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>">Divisi</label>
				   </div><div class="col-sm-9">
                                       <?php echo form_dropdown($nm_f,GetOptAll('sv_ref_divisi','-Divisi-',array()),(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='select2' id='$nm_f' onchange='gantiindivisi()'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="groups";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>">Group</label>
				   </div><div class="col-sm-9" id="grup">
                                       <?php echo form_dropdown($nm_f,array(),(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='select2' id='$nm_f'")?>
				  
			   </div>
		   </div>
		   <div class="form-group" style="display:none">
			   
			   <?php $nm_f="roles";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_dropdown($nm_f,array('3'=>'Marketing','11'=>'Divisi Leader'),(isset($val[$nm_f]) ? $val[$nm_f] : 3),"class='select2' id='$nm_f'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="leader";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_dropdown($nm_f,$opt_leader,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='select2' id='$nm_f'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="tanggal_masuk";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_input($nm_f,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='col-sm-4  date-picker' id='$nm_f' data-date-format='yyyy-mm-dd'")?>
				  
			   </div>
		   </div>
		   <!--div class="form-group">
			   
			   <?php $nm_f="tanggal_keluar";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_input($nm_f,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='col-sm-4  date-picker' id='$nm_f' data-date-format='yyyy-mm-dd'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="klasifikasi";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?></label>
				   </div><div class="col-sm-9">
                                       <?php echo form_dropdown($nm_f,GetOptAll('sv_ref_sales','-klasifikasi-'),(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class=' select2' id='$nm_f'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="sort";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?> Grafik</label>
				   </div><div class="col-sm-9">
                                       <?php echo form_input($nm_f,(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class=' select2' id='$nm_f'")?>
				  
			   </div>
		   </div--><div class="form-group">
            
            <?php $nm_f="username";?>
			   <div class="col-sm-3">
                               <label for="<?php echo $nm_f?>"><?php echo ucfirst($nm_f)?></label></div>
                       <div class="col-sm-9">
				<input type="text" name="<?php echo $nm_f?>"  id="<?php echo $nm_f?>" value="<?php echo $a= (isset($val['id']) ? GetValue('username','sv_admin',array('marketing'=>'where/'.$val['id'])) : '') ?>">
                       </div>
                   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="password";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?> Login</label>
				   </div><div class="col-sm-9">
                                       <?php echo form_password($nm_f,''," select2' id='$nm_f'")?>
				  
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="konfirmasi_password";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?> Login</label>
				   </div><div class="col-sm-9">
                                       <?php echo form_password($nm_f,'','',"class='validate[equals[password]]' id='$nm_f' ")?>
                                      
			   </div>
		   </div>
		   <div class="form-group">
			   
			   <?php $nm_f="status";?>
			   <div class="col-sm-3">
				   <label for="<?php echo $nm_f?>"><?php echo ucwords(str_replace('_',' ',$nm_f))?> </label>
				   </div><div class="col-sm-9"> <?php echo form_dropdown($nm_f,array('Aktif'=>'Aktif','Non Aktif'=>'Non Aktif'),(isset($val[$nm_f]) ? $val[$nm_f] : ''),"class='select2' id='$nm_f' ")?>
				  
				  
			   </div>
		   </div>
		  
    		<div class="form-group">
            <button type="submit" class="btn pull-right">Submit</button>
            
             </div>
			 </form>
    	</div>
    </div>
    </div>
</div>
<script>
    $(document).ready(function(e){
        gantiindivisi();
        $("#form").validate({
            submitHandler: function(form) {
    form.submit();
  },
           ignore: [],        
            rules: {
                'nama_lengkap': {required:true},
                'nama_panggilan': {required:true},
                'tempat_lahir': {required:true},
                'tanggal_lahir': {required:true},
                'jenis_kelamin': {required:true},
                'alamat': {required:true},
                'telp1': {required:true},
                'wa': {required:true},
                'email': {required:true},
                'divisi': {required:true},
                'roles': {required:true},
                'leader': {required:true},
                'tanggal_masuk': {required:true},
                'username': {required:true},
                <?php if(!isset($val['id'])){?>
                'password': {required:true},<?php }?>
            }
            , 
            messages: {
                'nama_lengkap':  'Wajib diisi',
                'nama_panggilan': 'Wajib diisi',
                'tempat_lahir': 'Wajib diisi',
                'tanggal_lahir':  'Wajib diisi',
                'jenis_kelamin': 'Wajib diisi',
                'alamat':  'Wajib diisi',
                'telp1':  'Wajib diisi',
                'wa':  'Wajib diisi',
                'email':  'Wajib diisi',
                'divisi':  'Wajib diisi',
                'roles':  'Wajib diisi',
                'leader':  'Wajib diisi',
                'tanggal_masuk':  'Wajib diisi',
                'username':  'Wajib diisi',
                <?php if(!isset($val['id'])){?>
                'password':  'Wajib diisi',<?php }?>
            }
            });    
    });
function gantiindivisi(){
    
    var dz=$('#divisi').val();
    var v='<?php echo isset($val['groups']) ? $val['groups'] : '' ?>';
    $('#grup').load('<?php echo base_url()?>load/grupz/',{dz:dz,v:v});
    
    }
</script>