	      <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		
		$(document).on("click", "#editbtn", function()
        {
  var mydiscountcategoryid = $(this).data('id');
	   $("#mydiscountcategoryid").val(mydiscountcategoryid);	
		   
		   		      var type = $(this).data('type');
		   $("#discounttype").val(type);
  
 
		    var name = $(this).data('name');
		   $("#discountname").val(name); 
		   
		     var discount = $(this).data('discount');
		   $("#discountamount").val(discount); 
		   var dateposted = $(this).data('dateposted');
		   $("#dateposted").val(dateposted); 
		  
		  var default2 = $(this).data('default');
		   $("#default2").val(default2); 
		  
		   
        });
		
		
    </script> 

<ul class="nav nav-tabs bordered">
			<li class="active">
            	<a href="#list" data-toggle="tab"><i class="entypo-menu"></i> 
					All Discount Charges
                    	</a></li>
			<li>
            	<a href="#add" data-toggle="tab"><i class="entypo-plus-circled"></i>
					Add Discount Charges
                    	</a></li>
				                	</a></li>
			<li>
            	
								 <a href="<?php echo base_url(); ?>admin/viewpallmyplots">Back</a>

				</li>		
						
						
		</ul>
    	<!------CONTROL TABS END------>
        
		<div class="tab-content">
            <!----TABLE LISTING STARTS-->
            <div class="tab-pane box active" id="list">
				<?php
 echo $this->session->flashdata('imagemsg1'); 
		      $mydate=date("Y-m-d H:i:s");
    echo $this->session->flashdata('deletemsg'); 

		    
$session_data = $this->session->userdata('logged_in');
 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	
$data['surname'] = $session_data['surname'];
$data['id'] = $session_data['id'];
 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
$surname=$data['surname'];
   $userid=$data['id'];

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

?>
 <div class="panel panel-primary" data-collapsed="0">
 
<table id="example"  cellspacing="1" class="table  table" width="100%">
             <thead>
		
         <tr>
        <th>ID </th>           	<th>Type</th> 

    <th>Discount Name </th>

           	<th>Amount/Value</th> 

	<th>Date created</th> 
	<th>Dafault</th> 

<th>More</th> 


                 </tr>
             </thead>

<?PHP

 if(!is_array($discount)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='3'>";
    
       echo '<div class="alert alert-warning text-center">There is no payment charges found by now from system..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
  
  	foreach ($discount as $c): 

		 

             ?>



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


?>
             <td><?php echo $c->id ; ?></td> 
			 						              <td><?php echo $c->type ; ?></td> 

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

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



				
                     <td><?php echo $c->createdate; ?></td>   
					                      <td><?php echo $c->updatedate; ?></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>
								
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
											<?php
										if($usertype=="admin"){
											
											?>
											  <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-default2='<?php echo  $c->updatedate;?>'  data-name='<?php echo  $c->name;?>' data-discount='<?php echo  $c->discount;?>'   data-type='<?php echo  $c->type;?>'    data-id='<?php echo  $c->id;?>' data-toggle='modal' data-target='#editProductModel'> 	 

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

             <?php endforeach; ?>

              <?php }?>

        </table>

</div>

</div>
<div class="tab-pane box" id="add" style="padding: 5px">




		
<div class="row">
	<div class="col-md-12">
		<div class="panel panel-primary" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" >
            		<i class="entypo-plus-circled"></i>
				Add new Discount offer
            	</div>
            </div>
			<div class="panel-body">





				<?PHP
				echo $this->session->flashdata('msg'); 
		
                 echo form_open('admin/adddiscount' , 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="default" value="No" class="form-control" required placeholder="Enter action">

		<input type="hidden" name="action" value="insert" class="form-control" required placeholder="Enter action">
	<input type="hidden" name="categoryid" value=""  class="form-control" required placeholder="Enter mycategoryid">
				
  <div class="form-group">

    <label for="inputname" class="col-sm-2 control-label">Discount Name</label>
    <div class="col-sm-7">
<input type="text" name="name" value="<?php echo set_value('name'); ?>"id="type" class="form-control" required placeholder="Enter discount name / amount">
     <span class="text-danger"><?php echo form_error('name'); ?></span>
   </div>
  </div>
   			

        <div class="form-group">
    <label for="inputtype" class="col-sm-2 control-label">Discount Type?</label>
    <div class="col-sm-10">
	<select class="form-control" name="type"  id="type" required>
		<option value=""  selected="selected"> -Select discount type -</option>

	<option value="Percentage" >Percentage % </option>
	<option value="Amount"  >Amount</option>



</select>
		
						<span class="text-danger"><?php echo form_error('type'); ?>

	</div>
  </div>
  
  
  
    <div class="form-group">

    <label for="inputdiscount" class="col-sm-2 control-label"> Value</label>
    <div class="col-sm-7">
<input type="text" name="discount" value="<?php echo set_value('discount'); ?>"id="type" class="form-control" required placeholder="Enter discount amount">
     <span class="text-danger"><?php echo form_error('discount'); ?></span>
   </div>
  </div>
  
  
  
  
  
  
  
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-7">
     
	       <button type="submit" name="btn_adddiscount"value="discountcharge" class="btn btn-primary">Add Discount Offer</button>

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



</div>


    </div>
</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 Discount</h4>
      </div>
      <div class="modal-body">
      
	  	

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



		
                 echo form_open('admin/adddiscount' , 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="categoryid" value="" id="mydiscountcategoryid" class="form-control" required placeholder="Enter mycategoryid">

  		<input type="hidden" name="action" value="<?php echo set_value('action','update'); ?>"id="action" class="form-control" required placeholder="Enter action">


 <div class="form-group">

    <label for="inputdiscount" class="col-sm-2 control-label"> Amount</label>
    <div class="col-sm-10">
<input type="text" name="discount" value="<?php echo set_value('discount'); ?>"id="discountamount" class="form-control" required placeholder="Enter discount amount">
     <span class="text-danger"><?php echo form_error('discount'); ?></span>
   </div>
  </div>
  
  

  <div class="form-group">

    <label for="inputname" class="col-sm-2 control-label">Discount Name</label>
    <div class="col-sm-10">
<input type="text" name="name" value="<?php echo set_value('name'); ?>"id="discountname" class="form-control" required placeholder="Enter discount name / amount">
     <span class="text-danger"><?php echo form_error('name'); ?></span>
   </div>
  </div>
   			






        <div class="form-group">
    <label for="inputtype" class="col-sm-2 control-label">Discount Type?</label>
    <div class="col-sm-10">
	<select class="form-control" name="type"  id="discounttype" required>
		<option value=""  selected="selected"> -Select discount type -</option>

	<option value="Percentage" >Percentage % </option>
	<option value="Amount"  >Amount</option>



</select>
		
						<span class="text-danger"><?php echo form_error('type'); ?>

	</div>
  </div>
  
  
  
   
  
  
     <div class="form-group">
    <label for="inputdefault" class="col-sm-2 control-label">Default?</label>
    <div class="col-sm-10">
	<select class="form-control" name="default"  id="default2" required>
			<option value="" selected="selected"  ></option>

	<option value=""  > -Select discount type -</option>

	<option value="Yes" >Yes </option>
	<option value="No" >No</option>



</select>
		
						<span class="text-danger"><?php echo form_error('type'); ?>

	</div>
  </div>
  
  

	 
	


		<div class="form-group">
    <label for="inputdateposted" class="col-sm-2 control-label">Date Updated:</label>
    <div class="col-sm-10">
	
		  		<input type="text" required readonly name="dateposted" value="<?php echo set_value('dateposted', $mydate); ?>" class="form-control" required placeholder="Enter dateposted ">
		 
				
		<span class="text-danger"> <?php echo form_error('dateposted'); ?>
		
		</span>
	</div>
  </div>
  
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-7">
     
	       <button type="submit" name="btn_adddiscount"value="discountcharge" class="btn btn-primary">Add Discount Offer</button>

    </div>
  </div>

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

    

				</div>

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






	<div id="updateProductModel" 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 Charges </h4>
      </div>
      <div class="modal-body">
      
	  	

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



		
                 echo form_open('user/assignbank' , 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="view" class="form-control" required placeholder="Enter action">
	<input type="hidden" name="categoryid" value=""id="mycategoryid" class="form-control" required placeholder="Enter mycategoryid">

	 <div class="form-group">
    <label for="inputbranchname" class="col-sm-2 control-label">Branch</label>
    <div class="col-sm-10">
	<select class="form-control" name="branchid"  id="branchid" required >
		<option value="" >---Select Branch/Counter Name--</option>



						
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>

</select>
		

		
	</div>
  </div>
     
	 	<div class="form-group">
    <label for="inputname" class="col-sm-2 control-label">	Charge name  :  </label>
    <div class="col-sm-10">
	
		  		<input type="text" required id="name" name="name" value="<?php echo set_value('name'); ?>" class="form-control"  placeholder="Enter payment method name">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>

	 

  
	<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">	Description </label>
    <div class="col-sm-10">

				<textarea id="description" name="description" value="<?php echo set_value('description'); ?>"  class="form-control"  placeholder="Enter remarks"></textarea>
			
		<span class="text-danger"> <?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
	
	 
	 
	
 	<div class="form-group">
    <label for="inputpriority" class="col-sm-2 control-label">	Priority  </label>
    <div class="col-sm-10">
	
		  		<input type="text"  name="priority" value="<?php echo set_value('priority'); ?>" class="form-control"  placeholder="Enter priority">
		 
				
		<span class="text-danger"> Priority<?php echo form_error('priority'); ?>
		
		</span>
	</div>
  </div>
 <div class="form-group">
    <label for="inputreading" class="col-sm-2 control-label">Has Meter Reading</label>
    <div class="col-sm-10">
	<select class="form-control" name="reading"  id="reading" required >
		<option value="" >--Enable meeting reading?--</option>
		<option value="No" >No</option>
		<option value="Yes" >Yes</option>



</select>
		

		
	</div>
  </div>
	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="bank" name="btn_assignbank" class="btn btn-primary"> Update    </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('adminlogged_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="discount">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="admin/viewalldiscounts">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
          <input type="hidden" id="plotno1"name="plotno" class="form-control" placeholder="plotno"  value="">
 <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>

