 <?php 
 if($_POST)
 {
	$cmp_name 				=		set_value('cmp_name',$_POST['cmp_name']);
	$cmp_pol 				=		set_value('cmp_pol',$_POST['cmp_pol']);
	$cmp_shrt_code 			=		set_value('cmp_shrt_code',$_POST['cmp_shrt_code']);
	
}
else
{
	$cmp_name 				=		$edit_company->cmp_name;
	$cmp_pol 				=		$edit_company->cmp_pol;
	$cmp_shrt_code 			=		$edit_company->cmp_shrt_code;

	
}
 ?>
 <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_company" name="edit_company" action="<?php echo base_url();?>General_masters/edit_company/<?php echo $cmp_id;?>" method="post" enctype="multipart/form-data">
    	<input type="hidden" id="cmp_id" name="cmp_id" value="<?php echo $cmp_id;?>">
    	<div class="col-md-4">
	        <div class="form-group">
	            <label>Company Name</label><?php echo form_error('cmp_name');?>
	            <input type="text" class="form-control" placeholder="Enter Company Name..." id="cmp_name" name="cmp_name" value="<?php echo $cmp_name;?>">
	        </div>
	       	
	       	<div class="form-group">
	            <label>Place Of Loading</label><?php echo form_error('cmp_pol');?>
	            <input type="text" class="form-control" placeholder="Enter Place Of Loading..." id="cmp_pol" name="cmp_pol" value="<?php echo $cmp_pol;?>">
	        </div>

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

            	<div class="form-group">
		            <label>Short Code</label><?php echo form_error('cmp_shrt_code');?>
		            <input type="text" class="form-control" placeholder="Enter Short Code..." id="cmp_shrt_code" name="cmp_shrt_code" value="<?php echo $cmp_shrt_code;?>">
		        </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/company"><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 Listed Company</label></h4>
    		<div class="box box-warning">
			    <table class="table table-bordered table-hover">
			        <thead>
			            <tr>
			                <th>Name</th>
			                <th>Phone No</th>
			                <th>Email</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_company/<?php echo $row['cmp_id'];?>"><strong><?php echo $row['cmp_name'];?></strong></a></td>
		    						<td><?php echo $row['cmp_phone'];?></td>
		    						<td><?php echo $row['cmp_email'];?></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/company"><strong>View All Company Lists</strong></a>
		    </div>
	    </div>-->
	</form>
    <!-- /.box-body -->
</div>
<script type="text/javascript">	
	$(function()
	{
		setTimeout(country_select);
		setTimeout(state_select);
		setTimeout(currency_select);
	});
	function country_select()
	{
		$("#cmp_country").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()
	{
		$("#cmp_state").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:$('#cmp_country').val()
						}
					}
			}
		});
	}
    function currency_select()
    {
        $("#cmp_currency").select2({
            ajax: { 
                dataType: 'json', 
                url: '<?php echo base_url();?>General_masters/get_currency/',
                cache: true,
                data: function (params) 
                    {
                        return {
                            q: params.term
                        }
                    }
            }
        });
    }
</script>