<script type="text/javascript">
$(document).ready(function() {
  $('#companyList').DataTable();
});

// SHOW MODAL
function fnShowItemModal(id) {
	id = id || null;
	console.log(id);
	if(id > 0) {
		$('#companyID').val(id);		
		$('#chooseCompanyModal').modal('show');
	} else {
		$('#companyID').val('');	
		$('#chooseCompanyModal').modal('hide');
	}
}
</script>
<div class="content-wrapper">
	<!-- Content Header (Page header) -->
	<section class="content-header">
		<h1>Home</h1>
		<ol class="breadcrumb">
			<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
			<li class="active">Dashboard</li>
		</ol>
	</section>

	<!-- Main content -->
	<section class="content">
		<div class="row">
			<div class="col-xs-12">	
        <div class="box-body">
          <div class="row">
            <div class="col-md-12">
            <table id="companyList" class="table table-bordered table-striped pull-right">
              <thead>
                <th><?php echo $this->lang->line('no');?></th>
                <th><?php echo $this->lang->line('companyName');?></th>
                <th><?php echo $this->lang->line('companyNo');?></th>
              </thead>
              <tbody>
								<!-- SAMPLE 1 -->
								<tr>
								<td id="comp_1">1</td>
								<td><a href="javascript:fnShowItemModal(1);"><b>Kedai Kereta Terpakai Ahmad Albab</b></a></td>
								<td>VW123-456H</td>
								</tr>
								
								<!-- SAMPLE 2 -->
								<tr>
								<td id="comp_2">2</td>
								<td><a href="javascript:fnShowItemModal(2);"><b>Maju Jaya Trading</b></a></td>
								<td>AX00-200</td>
								</tr>									
              </tbody>
            </table>
          </div>
          </div>
        </div>
			</div>
		</div>
	</section>
</div>





<!-- MODAL SECTION -->
<div class="modal fade" id="chooseCompanyModal" role="dialog">
	<div class="modal-dialog modal-lg">
		<form id="selectCompForm" action="<?php echo base_url(); ?>home/selectCompany" method="POST" role="form">
		<div class="modal-content">
			<div class="modal-header" >
				<button type="button" class="close" data-dismiss="modal">&times;</button>
				<h3 class="modal-title"><?php echo $this->lang->line('choosePrompt'); ?></h3>
			</div>
			
			<div class="modal-body">
				<div class="row">
					<div class="col-md-12">
						<div class="form-group">
							<strong>Adakah anda pasti untuk memilih Syarikat ini?</strong>
							<input type="hidden" name="companyID" id="companyID" value="" />
						</div>
					</div>
				</div>
			</div>
					
			<div class="modal-footer">
				<a type="button" class="btn btn-danger btn-sm pull-left" data-dismiss="modal"><?php echo $this->lang->line('Cancel'); ?></a>
				<button type="submit" class="btn bg-olive btn-sm pull-right">
					<span class="glyphicon glyphicon-plus"></span> <?php echo $this->lang->line('Choose'); ?>
				</button>
			</div>
			
		</div>
		</form>
	</div>
</div>
