 <?php 
 if($_POST)
 {
	$consignor_name 			        =		set_value('consignor_name',$_POST['consignor_name']);
	$consignor_addr1 			        =		set_value('consignor_addr1',$_POST['consignor_addr1']);
	$consignor_addr2 			        =		set_value('consignor_addr2',$_POST['consignor_addr2']);
	$consignor_addr3 			        =		set_value('consignor_addr3',$_POST['consignor_addr3']);
	$consignor_addr4 			        =		set_value('consignor_addr4',$_POST['consignor_addr4']);
	// $consignor_country_id 			    =		set_value('consignor_country_id',$_POST['consignor_country_id']);
	// $consignor_state_id 			    =		set_value('consignor_state_id',$_POST['consignor_state_id']);
	// $consignor_pin 			            =		set_value('consignor_pin',$_POST['consignor_pin']);
	$consignor_con_person 			    =		set_value('consignor_con_person',$_POST['consignor_con_person']);
	// $consignor_con_no 			        =		set_value('consignor_con_no',$_POST['consignor_con_no']);
	// $consignor_alt_no 			        =		set_value('consignor_alt_no',$_POST['consignor_alt_no']);
	// $consignor_fax 			            =		set_value('consignor_fax',$_POST['consignor_fax']);
	 
}
else
{
	$consignor_name 			        =		$edit_consignor->consignor_name;
	$consignor_addr1			        =		$edit_consignor->consignor_addr1;
	$consignor_addr2 			        =		$edit_consignor->consignor_addr2;
	$consignor_addr3			        =		$edit_consignor->consignor_addr3;
	$consignor_addr4 			        =		$edit_consignor->consignor_addr4;
	// $consignor_country_id			    =		$edit_consignor->consignor_country_id;
	// $consignor_state_id 			    =		$edit_consignor->consignor_state_id;
	// $consignor_pin			            =		$edit_consignor->consignor_pin;
	$consignor_con_person 			    =		$edit_consignor->consignor_con_person;
	// $consignor_con_no			        =		$edit_consignor->consignor_con_no;
	// $consignor_alt_no 			        =		$edit_consignor->consignor_alt_no;
	// $consignor_fax			        	=		$edit_consignor->consignor_fax;

	 
}
 ?>
 <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_consignor" name="edit_consignor" action="<?php echo base_url();?>General_masters/edit_consignor/<?php echo $consignor_id;?>" method="post">
    	<input type="hidden" id="consignor_id" name="consignor_id" value="<?php echo $consignor_id;?>">

    	<div class="col-md-4">
            <!-- <div class="form-group">
                <label>Parent Ledger Group Name</label><?php echo form_error('parent_id');?>
                <select class="form-control select2" id="parent_id" name="parent_id">
                	<option value="">Select Parent Ledger Group Name</option>
                  	<?php foreach($ledger_drpdwn as $row)
                  	{?>
                  		<option value="<?php echo $row['ledger_group_id'];?>" <?php if($parent_id==$row['ledger_group_id'])echo "selected";?>><?php echo $row['ledger_group_name'];?></option>
                  	<?php }?>                	
                </select>             
            </div> -->
	        <div class="form-group">
	            <label>Shipper/Exporter Name</label><?php //cho form_error('consignor_name');?>
	            <input type="text" class="form-control" pattern="^[-_a-zA-Z0-9]+(\s+[-_a-zA-Z0-9]+)*$" placeholder="Enter Shipper/Exporter Name..." id="consignor_name" name="consignor_name" value="<?php echo $consignor_name;?>">
	        </div>
	        <div class="form-group">
	            <label>Address Line 1</label><?php //echo form_error('consignor_addr1');?>
	            <textarea class="form-control" rows="5" placeholder="Enter Address Line 1..." id="consignor_addr1" name="consignor_addr1"><?php echo $consignor_addr1;?></textarea>
	        </div>
	        <div class="form-group">
	            <label>Address Line 2</label><?php //echo form_error('consignor_addr2');?>
	            <textarea class="form-control" rows="5" placeholder="Enter Address Line 2..." id="consignor_addr2" name="consignor_addr2"><?php echo $consignor_addr2;?></textarea>
	        </div>
	         <div class="form-group">
	            <label>Address Line 3</label><?php //echo form_error('consignee_addr1');?>
	            <textarea class="form-control" rows="5" placeholder="Enter Address Line 3..." id="consignor_addr3" name="consignor_addr3"><?php echo $consignor_addr3;?></textarea>
	        </div>
	        <div class="form-group">
	            <label>Address Line 4</label><?php //echo form_error('consignee_addr2');?>
	            <textarea class="form-control" rows="5" placeholder="Enter Address Line 4..." id="consignor_addr4" name="consignor_addr4"><?php echo $consignor_addr4;?></textarea>
	        </div>
	       <!--  <div class="form-group">
                <label>Country</label><?php echo form_error('consignor_country_id');?>
                <select class="form-control select2" id="consignor_country_id" name="consignor_country_id">
                    <option value="">Select Country</option>
                    <?php foreach($country_drpdwn as $row)
                    {?>
                        <option value="<?php echo $row['country_id'];?>" <?php if($consignor_country_id==$row['country_id'])echo "selected";?>><?php echo $row['name'];?></option>
                    <?php }?>                   
                </select>                
            </div>
            <div class="form-group">
                <label>State</label><?php echo form_error('consignor_state_id');?>
                <select class="form-control select2" id="consignor_state_id" name="consignor_state_id">
                    <option value="">Select State</option>
                    <?php foreach($state_drpdwn as $row)
                    {?>
                        <option value="<?php echo $row['state_id'];?>" <?php if($consignor_state_id==$row['state_id'])echo "selected";?>><?php echo $row['state'];?></option>
                    <?php }?>
                </select>
            </div> 
            <div class="form-group">
	            <label>Pincode</label><?php echo form_error('consignor_pin');?>
	            <input type="text" class="form-control" placeholder="Enter Ledger Consignor PIN..." id="consignor_pin" name="consignor_pin" value="<?php echo $consignor_pin;?>">
	        </div> -->
	        
	       
	        
	    </div>
    	<div class="col-md-4">
	        <div class="form-group">
	            <label>Contact Person</label><?php //echo form_error('consignor_con_person');?>
	            <input type="text" class="form-control" placeholder="Enter Contact Person..." id="consignor_con_person" name="consignor_con_person" value="<?php echo $consignor_con_person;?>">
	        </div>
	        <!-- <div class="form-group">
	            <label>Contact Number</label><?php //echo form_error('consignor_con_no');?>
	            <input type="text" class="form-control" placeholder="Enter Contact Number..." id="consignor_con_no" name="consignor_con_no" value="<?php echo $consignor_con_no;?>">
	        </div>
	        <div class="form-group">
	            <label>Alternate Number</label><?php //echo form_error('consignor_alt_no');?>
	            <input type="text" class="form-control" placeholder="Enter Alternate Number..." id="consignor_alt_no" name="consignor_alt_no" value="<?php echo $consignor_alt_no;?>">
	        </div>
	        <div class="form-group">
	            <label>Fax</label><?php //echo form_error('consignor_fax');?>
	            <input type="text" class="form-control" placeholder="Enter Fax..." id="consignor_fax" name="consignor_fax" value="<?php echo $consignor_fax;?>">
	        </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/consignor"><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 Shipper/Exporter</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_consignor/<?php echo $row['consignor_id'];?>"><strong><?php echo $row['consignor_name'];?></strong></a></td>
		    						<td><?php echo $row['consignor_con_person'];?></td>
		    						<td><?php echo $row['consignor_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/consignor"><strong>View All Shipper/Exporter</strong></a>
		    </div>
	    </div> 
	</form>
    <!-- /.box-body -->
</div>

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

	function country_select()
	{
		$("#consignor_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()
	{
		$("#consignor_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:$('#consignor_country_id').val()
						}
					}
			}
		});
	}
</script>