

         <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		$(document).on("click", "#editbtn", function()
        {
          var mycategoryid = $(this).data('id');
		  $("#mycategoryid").val(mycategoryid); 
		   
		   		   
   var maincategory = $(this).data('maincategory');
		   $("#maincategory").val(maincategory);
 
		    var name = $(this).data('name');
		   $("#name").val(name); 
		   
		     var enddate = $(this).data('enddate');
		   $("#enddate").val(enddate); 
		 
		     var startdate = $(this).data('startdate');
		   $("#startdate").val(startdate); 
		 
		    var status = $(this).data('status');
		   $("#status").val(status); 
		  var opening = $(this).data('opening');
		   $("#opening").val(opening); 
		 
		 
		  var closing = $(this).data('closing');
		   $("#closing").val(closing); 
		 
		   
		  var number = $(this).data('number');
		   $("#number").val(number); 
		 
		   
        });
		
		
		
		
    </script>   
 
 <div class="row">
  
   	

   	<div class="col-md-10">
	
  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
						 <span class="pull-right"><br> View Closing/ Opening Balances </span>					                     <a data-toggle='modal' data-target='#addModal' class="btn btn-primary">Close/Open Account Balances </a>


						 		 <a href="<?php echo base_url();?>user/startsales" class="btn btn-success"> Go back to Report </a>	 

				
            	</div>
            </div>
			<div class="panel-body">

				<div class="widget-content nopadding table_holder table-responsive" >				
	<?PHP

 $session_data = $this->session->userdata('logged_in');

   
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];

 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	  echo $this->session->flashdata('deletemsg'); 
							  $startdate=date("Y-m-d 00:00:00");
  $enddate=date("Y-m-d 23:59:59");
				echo $this->session->flashdata('msg'); 
								?>	
										
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
									
									
  <table cellpadding="0" cellspacing="0" border="0" class="table  table-striped" id="example" style="border-color:#CCCCCC; width:100%;"  >

             <thead>
         <tr>
     <th>Gl </th>
     <th>Name</th>
	     <th>Start date</th>
		 <th>Close  date</th>
		 		<th>Status</th>		 

		 		 <th>Opening</th>

				 		 <th>Closing</th>

		
	<th>More</th>	

                 </tr>
             </thead><tbody>
<?php

 if(!is_array($glfiscalyear)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='6'>";
    
       echo '<div class="alert alert-warning text-center">There no records found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
  
  	foreach ($glfiscalyear as $c): 

		 

             ?>



             <tr>
                
            <?php 
$id=$c->id;


?>

    
  <td><?php 
  
  
  $myglaccounts = $this->usermodel->populateallarray('glaccounts','number',$c->number);

			 echo$names=$myglaccounts[0]['accountname'];
  
  
  
  ?></td>          
  <td><?php echo $c->name ; ?></td>  
  <td><?php echo $c->startdate ; ?></td>
    
  
  
  
  	  <td><?php echo $c->enddate ; ?></td>

  
  
	  <td><?php echo $c->status ; ?></td>
	  
  	  <td><?php echo $c->opening ; ?></td>

  
  
	  <td><?php echo $c->closing ; ?></td>
	  
	  
	  
	  
	 <td> 

 
 
					<div class="btn-group">
                                    <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									<?php
										if($usertype=="admin"){
											
											?>
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
										
											  <li> 
										 <a class="btn btn-danger managebtn" id="managebtndelete"		 data-id='<?php echo  $c->id;?>'    data-toggle='modal' data-target='#myModal<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
									
									
                                        <li class="divider"></li>
                                        
                                     	  <li> 

	 <a class="btn btn-primary editbtn" id="editbtn"  data-number='<?php echo  $c->number;?>' data-closing='<?php echo  $c->closing;?>' data-opening='<?php echo  $c->opening;?>'  data-enddate='<?php echo  $c->enddate;?>'  data-startdate='<?php echo  $c->startdate;?>'   data-name='<?php echo  $c->name;?>'   data-status='<?php echo  $c->status;?>'  data-id='<?php echo  $c->id;?>' data-toggle='modal' data-target='#editProductModel'> 	 

                                                <i class="glyphicon glyphicon-pencil"></i>
																Update
                                                </a>
                                                        </li>
                                        
                                    </ul>
											<?php
										}
										?>
                                </div>
</td>
		 
		 
		 
             </tr>

	<?php endforeach;} ?>

             
<tbody>
        </table>

									
									
									
					</div>	

					
					
					
					
					
<div id="editProductModel" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Update Gl Fiscal Year</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addglfiscalyear' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
	<input type="hidden" name="mycategoryid" value=""id="mycategoryid" class="form-control" required placeholder="Enter mycategoryid">
			  			<input type="hidden" name="action" value="update"id="mycategoryid" class="form-control" required placeholder="Enter mycategoryid">

	<div class="form-group">
    <label for="inputname" class="col-sm-2 control-label">Year	Name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="name" value="<?php echo set_value('name'); ?>" id="name" class="form-control" required placeholder="Enter name">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>
  
  
  <div class="form-group">
    <label for="inputstatus" class="col-sm-2 control-label">Select Acount </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="number" id="number"  required>
	<option value=""  selected="selected" ></option>

		<option value=""  >-Select gl account-</option>

		
	


	<?php 
					 
			//$glacounts= $this->usermodel->populateviewcustomers('glaccounts','accountname','ASC','companyid', $companyid);
	      $glacounts=$this->usermodel->populateall('glaccounts','companyid',$companyid);


if(is_array($glacounts)) {

   foreach($glacounts as $glacountsrow){

   ?>
					<option value="<?=  $glacountsrow->number;   ?>"><?=  $glacountsrow->accountname ." (". $glacountsrow->number.")"; ?></option>




	<?php

}} else {
    echo 'No Customer account.';
}
	
?>
		
	</select>		 
				
		<span class="text-danger"> <?php echo form_error('number'); ?>
		
		</span>
	</div>
  </div>
	
  
  

  	<div class="form-group">
    <label for="inputstartdate" class="col-sm-2 control-label">	Start Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="startdate" id="startdate" value="<?php echo set_value('startdate'); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> YYY-M-D <?php echo form_error('startdate'); ?>
		
		</span>
	</div>
  </div>
 	<div class="form-group">
    <label for="inputstenddate" class="col-sm-2 control-label">	End Date </label>
    <div class="col-sm-10">
	 
		  		<input type="text" name="enddate" id="enddate" value="<?php echo set_value('enddate'); ?>" class="form-control" required placeholder="Enter end date">
		 
				
		<span class="text-danger"> YYY-M-D<?php echo form_error('enddate'); ?>
		
		</span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputopening" class="col-sm-2 control-label">	Opening Balance </label>
    <div class="col-sm-10">
	 
		  		<input type="text" name="opening" id="opening" value="<?php echo set_value('opening'); ?>" class="form-control" required placeholder="Enter  opening balance">
		 
				
		<span class="text-danger"> <?php echo form_error('opening'); ?>
		
		</span>
	</div>
  </div>
		 <div class="form-group">
    <label for="inputclosing" class="col-sm-2 control-label">	Closing Balance </label>
    <div class="col-sm-10">
	 
		  		<input type="text" name="closing" id="closing" value="<?php echo set_value('closing'); ?>" class="form-control" required placeholder="Enter  closing balance">
		 
				
		<span class="text-danger"> <?php echo form_error('closing'); ?>
		
		</span>
	</div>
  </div>
		
		
	<div class="form-group">
    <label for="inputstatus" class="col-sm-2 control-label">Status </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="status" id="status"  required>
	<option value=""  selected="selected" ></option>

	<option value="active"  >active</option>
		<option value="closed"  >closed</option>
	</select>		 
				
		<span class="text-danger"> <?php echo form_error('status'); ?>
		
		</span>
	</div>
  </div>
	
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit" class="btn btn-primary"  value="year" name="addfiscalyear"> Update Fiscal Year   </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>
					
					
					
					
					
					
					
					
					
					
					
					
						<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Delete</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to delete this item? </h3>
      </div>
      <div class="modal-footer">
	  	

     
		<?PHP
				$session_data = $this->session->userdata('logged_in');
 echo $this->session->flashdata('deletemsg'); 

		
                 echo form_open('user/deletebyid' , array('class' => 'form-horizontal ', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
 <input type="hidden" id="table"name="table" class="table" placeholder="view" value="glfiscalyear">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/glfiscalyear">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
 <button type="button" class="btn btn-success" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="btn_delete" value="deletebyid" class="btn btn-danger"> Delete  </button>

	<?php echo form_close();?>
      </div>
    </div>

  </div>

  </div>					
<div id="addModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Open/Close Account </h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');

				echo $this->session->flashdata('deletemsg'); 


				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addglfiscalyear' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
					  			<input type="hidden" name="action" value="insert"id="mycategoryid" class="form-control" required placeholder="Enter mycategoryid">
		  			<input type="hidden" name="mycategoryid" value=""id="mycategoryid" class="form-control" required placeholder="Enter mycategoryid">

	<div class="form-group">
    <label for="inputname" class="col-sm-2 control-label">Year	Name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="name" value="<?php echo set_value('name'); ?>" class="form-control" required placeholder="Enter name e.g 2018 Fiscal Year">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>

  <div class="form-group">
    <label for="inputstatus" class="col-sm-2 control-label">Select Acount </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="number"  required>
		<option value=""  >-Select gl account-</option>



	<?php 
					 
			//$glacounts= $this->usermodel->populateviewcustomers('glaccounts','accountname','ASC','companyid', $companyid);
	      $glacounts=$this->usermodel->populatealldatawhere('glaccounts','accounttype','ASC','companyid',$companyid);


if(is_array($glacounts)) {

   foreach($glacounts as $glacountsrow){

   ?>
					<option value="<?=  $glacountsrow->number;   ?>"><?=  $glacountsrow->accountname ." (". $glacountsrow->number.")"; ?></option>




	<?php

}} else {
    echo 'No Customer account.';
}
	
?>
		
	</select>		 
				
		<span class="text-danger"> <?php echo form_error('number'); ?>
		
		</span>
	</div>
  </div>
	
  
  
  	<div class="form-group">
    <label for="inputstartdate" class="col-sm-2 control-label">	Star Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="startdate" value="<?php echo set_value('startdate',$startdate); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger">YYY-M-D <?php echo form_error('startdate'); ?>
		
		</span>
	</div>
  </div>
 	<div class="form-group">
    <label for="inputstenddate" class="col-sm-2 control-label">	End Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="enddate" value="<?php echo set_value('enddate',$enddate); ?>" class="form-control" required placeholder="Enter end date">
		 
				
		<span class="text-danger"> YYY-M-D<?php echo form_error('enddate'); ?>
		
		</span>
	</div>
  </div>
		 <div class="form-group">
    <label for="inputopening" class="col-sm-2 control-label">	Opening Balance </label>
    <div class="col-sm-10">
	 
		  		<input type="text" name="opening" id="opening" value="<?php echo set_value('opening'); ?>" class="form-control" required placeholder="Enter  opening balance">
		 
				
		<span class="text-danger"> <?php echo form_error('opening'); ?>
		
		</span>
	</div>
  </div>
		 <div class="form-group">
    <label for="inputclosing" class="col-sm-2 control-label">	Closing Balance </label>
    <div class="col-sm-10">
	 
		  		<input type="text" name="closing" id="closing" value="<?php echo set_value('closing'); ?>" class="form-control" required placeholder="Enter  closing balance">
		 
				
		<span class="text-danger"> <?php echo form_error('closing'); ?>
		
		</span>
	</div>
  </div>
		
	<div class="form-group">
    <label for="inputstatus" class="col-sm-2 control-label">Status </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="status" required >
	<option value=""  selected="selected" >Select status</option>

	<option value="active"  >active</option>
		<option value="closed"  >closed</option>
	</select>		 
				
		<span class="text-danger"> <?php echo form_error('status'); ?>
		
		</span>
	</div>
  </div>
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit" class="btn btn-primary"  value="year" name="addfiscalyear"> Close/Open Account  </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>





					
									
									
							</div>		
									
							</div>
						</div>
				

			
			</div>
		</div>
  
  </div>
			
		<div class="col-md-2">
			  <div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
				<p>Help/More Explanation </p>

				
            	</div>
            </div>
      
			<p>Create various  gl fiscal years.</p>
			
			
		</div>			
	</div>			
		
		
  

 
</div>


















