 <?php 
 if($_POST)
 {
	$customer_name 			        =		set_value('customer_name',$_POST['customer_name']);
	$customer_addr1 			        =		set_value('customer_addr1',$_POST['customer_addr1']);
	$customer_addr2 			        =		set_value('customer_addr2',$_POST['customer_addr2']);
	$customer_addr3 			        =		set_value('customer_addr3',$_POST['customer_addr3']);
	$customer_addr4 			        =		set_value('customer_addr4',$_POST['customer_addr4']);
	// $customer_country_id 			    =		set_value('customer_country_id',$_POST['customer_country_id']);
	// $customer_state_id 			    =		set_value('customer_state_id',$_POST['customer_state_id']);
	// $customer_pin 			            =		set_value('customer_pin',$_POST['customer_pin']);
	$customer_con_person 			    =		set_value('customer_con_person',$_POST['customer_con_person']);
	$customer_con_no 			        =		set_value('customer_con_no',$_POST['customer_con_no']);
	$customer_alt_no 			        =		set_value('customer_alt_no',$_POST['customer_alt_no']);
	$customer_fax 			            =		set_value('customer_fax',$_POST['customer_fax']);
	 
}
else
{
	$customer_name 			        =		$edit_customer->customer_name;
	$customer_addr1			        =		$edit_customer->customer_addr1;
	$customer_addr2 			        =		$edit_customer->customer_addr2;
	$customer_addr3			        =		$edit_customer->customer_addr3;
	$customer_addr4 			        =		$edit_customer->customer_addr4;
	// $customer_country_id			    =		$edit_customer->customer_country_id;
	// $customer_state_id 			    =		$edit_customer->customer_state_id;
	// $customer_pin			            =		$edit_customer->customer_pin;
	$customer_con_person 			    =		$edit_customer->customer_con_person;
	$customer_con_no			        =		$edit_customer->customer_con_no;
	$customer_alt_no 			        =		$edit_customer->customer_alt_no;
	$customer_fax			        	=		$edit_customer->customer_fax;
$pan			        	=		$edit_customer->pan_no;
$gst			        	=		$edit_customer->gst;
$iec			        	=		$edit_customer->iec;
$state			        	=		$edit_customer->state;
	 	 
	 
}
 ?>
 <div class="box-body">
 	<div style="color:red;" class="error"><strong><?php if($this->session->flashdata('error')){ echo $this->session->flashdata('error');} ?></strong></div>
   <form role="form" id="edit_customer" name="edit_customer" action="<?php echo base_url();?>General_masters/edit_customer/<?php echo $customer_id;?>" method="post">
    	<input type="hidden" id="customer_id" name="customer_id" value="<?php echo $customer_id;?>">

    	<div class="col-md-4">

	        <div class="form-group">
	            <label>customer Name</label>
	            <input type="text" class="form-control" placeholder="Enter Ledger customer Name..." id="customer_name" name="customer_name" value="<?php echo $customer_name;?>">
	        </div>
	        <div class="form-group">
	            <label>Address Line 1</label>
	            <textarea class="form-control" rows="5" placeholder="Enter Address Line 1..." id="customer_addr1" name="customer_addr1"><?php echo $customer_addr1;?></textarea>
	        </div>
	        <div class="form-group">
	            <label>Address Line 2</label>
	            <textarea class="form-control" rows="5" placeholder="Enter Address Line 2..." id="customer_addr2" name="customer_addr2"><?php echo $customer_addr2;?></textarea>
	        </div>
	        <div class="form-group">
	            <label>Address Line 3</label>
	            <textarea class="form-control" rows="5" placeholder="Enter Address Line 3..." id="customer_addr3" name="customer_addr3"><?php echo $customer_addr3;?></textarea>
	        </div>
	        <div class="form-group">
	            <label>Address Line 4</label>
	            <textarea class="form-control" rows="5" placeholder="Enter Address Line 4..." id="customer_addr4" name="customer_addr4"><?php echo $customer_addr4;?></textarea>
	        </div>

	    </div>
    	<div class="col-md-4">
	        <div class="form-group">
	            <label>Contact Person</label>
	            <input type="text" class="form-control" placeholder="Enter Ledger Contact Person..." id="customer_con_person" name="customer_con_person" value="<?php echo $customer_con_person;?>">
	        </div>
	        <div class="form-group">
	            <label>Contact Number</label>
	            <input type="text" class="form-control" placeholder="Enter Ledger Contact Number..." id="customer_con_no" name="customer_con_no" value="<?php echo $customer_con_no;?>">
	        </div>
	        <div class="form-group">
	            <label>Alternate Number</label>
	            <input type="text" class="form-control" placeholder="Enter Ledger Alternate Number..." id="customer_alt_no" name="customer_alt_no" value="<?php echo $customer_alt_no;?>">
	        </div>
	        <div class="form-group">
	            <label>Fax</label>
	            <input type="text" class="form-control" placeholder="Enter Ledger Fax..." id="customer_fax" name="customer_fax" value="<?php echo $customer_fax;?>">
	        </div>
			
			<div class="form-group">
	            <label>Pan</label>
	            <input type="text" class="form-control" placeholder="Enter Pan Card..." id="pan" name="pan" value="<?php echo $pan;?>">
	        </div>
			<div class="form-group">
	            <label>GSTIN</label>
	            <input type="text" class="form-control" placeholder="Enter GST..." id="gst" name="gst" value="<?php echo $gst;?>">
	        </div>
			<div class="form-group">
	            <label>IEC CODE</label>
	            <input type="text" class="form-control" placeholder="Enter IEC CODE..." id="iec" name="iec" value="<?php echo $iec;?>">
	        </div>
			<div class="form-group">
	            <label>State</label>
	            <input type="text" class="form-control" placeholder="Enter State..." id="state" name="state" value="<?php echo $state;?>">
	        </div>
			
			
	        <div class="form-group">
            	<div class="col-md-6"></div>
            	<div class="col-md-6"><input type="submit" id="submit" name="submit" class="btn btn-info" value="Save">
            	<a href="<?php echo base_url()?>General_masters/customer"><button type="button" class="btn btn-warning">Cancel</button></a></div>
            </div> 
	        
	        
	        
	        
            
	    </div>
    	<div class="col-md-4 form-group has-warning">
    		<h4><label>Recently customer</label></h4>
    		<div class="box box-warning">
			     <table class="table table-bordered table-hover">
			        <thead>
			            <tr>
			                <th>Name</th>
			                <th>Contact Person</th>
			                <th>Contact Number</th>
			                
			            </tr>
			        </thead>
			        <tbody>
	        			<?php if(count($recent_list)!=0)
	        			{
	        				foreach($recent_list as $row)
	        				{?>
		    					<tr>
		    						<td><a href="<?php echo base_url();?>General_masters/edit_customer/<?php echo $row['customer_id'];?>"><strong><?php echo $row['customer_name'];?></strong></a></td>
		    						<td><?php echo $row['customer_con_person'];?></td>
		    						<td><?php echo $row['customer_con_no'];?></td>
		    					 
		    					</tr>
	        				<?php }
	        			}
	        			else
	        			{?>
	        				<tr><td colspan="3">Data Not Found</td></tr>
	        			<?php }?>
			        </tbody>
			    </table>
			   <a class="text-red" href="<?php echo base_url();?>General_masters/customer"><strong>View All Ledger Group Lists</strong></a>
		    </div>
	    </div> 
	</form>
    <!-- /.box-body -->
</div>

<script type="text/javascript">
	$(function()
	{
		setTimeout(country_select);
        setTimeout(state_select);
	});

	function country_select()
	{
		$("#customer_country_id").select2({
			ajax: { 
				dataType: 'json', 
				url: '<?php echo base_url();?>General_masters/get_countries',
				cache: true,
				data: function (params) 
					{
						return {
							q: params.term
						}
					}
			}
		});
	}
	function state_select()
	{
		$("#customer_state_id").select2({
			ajax: { 
				dataType: 'json', 
				url: '<?php echo base_url();?>General_masters/get_state_by_country',
				cache: true,
				data: function (params) 
					{
						return {
							q: params.term,
							country_id:$('#customer_country_id').val()
						}
					}
			}
		});
	}
</script>