<section class="container" style="padding-bottom: 2rem;">
	<div class="card bg-light-transparent">
		<div class="card-body">
			<div class="card no-shadow"  style="padding-top: 3rem; padding-bottom: 3rem;">
				<div class="card-body">
					<div class="row">
						<div class="col-md-4 text-center align-self-center">
							<img class="image-responsive" src="<?php echo base_url($company['file_location'].$company['file_name']); ?>" style="max-height: 15rem; max-width: 15rem;">
						</div>
						<div class="col-md-8">
							<img class="image-responsive" src="<?php echo base_url($company['file_location'].'salihin-logo.png'); ?>" style="max-height: 15rem; max-width: 15rem;">
							<p class="lead" id="cardProfile"><?php echo $company['profile']; ?></p>
							<hr class="my-4">
							<p id="cardPhone"><?php echo $company['phone']; ?></p>
							<p><a id="cardWebsite" target="_blank" href="<?php echo 'http://'.$company['website']; ?>"><?php echo $company['website']; ?></a></p>
						</div> 
					</div>
				</div>
			</div>
		</div>
	</div>
</section>

<section class="container" style="padding-bottom: 2rem;">
	<div class="card bg-light-transparent">
		<div class="card-body">
			<div class="row">
				<div class="col-12 col-sm-6 mb-3 mb-sm-0">
					<button onclick="addStaff();" type="button" class="btn btn-dark btn-round btn-block" style="height:100px" <?php if($role == 'user'){ ?> disabled<?php } ?>>
						<h5 class="card-title"><i class="fa fa-plus"></i> Add new</h5>
						<p class="card-text">Add new staff.</p>
					</button>
				</div>				
				<div class="col-12 col-sm-6 mb-0 mb-sm-0">
					<button onclick="printStaffList();" type="button" class="btn btn-dark btn-round btn-block" style="height:100px">
						<h5 class="card-title"><i class="fa fa-print"></i> Print</h5>
						<p class="card-text">Print staff list.</p>
					</button>
				</div>
			</div>
		</div>
	</div>
</section>

<section class="container" style="padding-bottom: 2rem;">
	<div class="card bg-light-transparent">
		<div class="card-body">
			<div class="card no-shadow" >

				<div class="card-body d-none d-sm-block">
					<h4 class="card-title">Staff List</h4>
					<hr><br>
					<div class="table-responsive">
						<table id="table_companies" class="table table-hover table-bordered">
							<thead>
								<tr>
									<th>#</th>
									<th>Staff ID</th>
									<th>Staff Name</th>							
									<th>Department</th>
									<th>Status</th>
									<th>Action</th>
								</tr>
							</thead>
							<tbody>
								<?php 
									$i = 1;
									if($staff) foreach($staff as $row) {  ?>
										<?php if (($_SESSION['user']['id'] == $row['id']) || $role == 'admin'): ?>
											<tr class="link-row">
												<td scope="row"><?php echo $i; ?></td>
												<td><?php echo $row['staff_id']; ?></td>
												<td><?php echo $row['name']; ?></td>
												<td><?php echo $row['department_name']; ?></td>
												<td class="text-center"><?php if($row['is_delete'] == 0){ ?>
													<span class="badge badge-success">Current Staff</span>
												<?php } else{ ?>
													<span class="badge badge-danger">Deleted</span>
												<?php } ?>
												</td>
												<td class="text-center btn-group">
													<a href="<?php echo base_url('hr/StaffProfile/new_action_type/'.$row['id']); ?>" class="btn btn-primary" data-trigger="hover" data-tooltip="tooltip" title="" data-original-title="Create Action Type"><i class="fas fa-plus-square"></i></a>
													<a href="<?php echo base_url().'hr/StaffProfile/staffDetail/'.$row['id']; ?>" class="btn btn-success btn-sm"  data-trigger="hover" data-tooltip="tooltip" title="" data-original-title="View staff Details"><i class="fas fa-eye"></i></a>
												</td>
											</tr>
										<?php endif ?>
									    <?php
	                                    $i++;
	                                } ?>
							</tbody>
						</table>
					</div>
				</div>

				<div class="card-body d-block d-sm-none">
					<h4 class="card-title">Staff List</h4>
					<hr><br>
					<?php if(!empty($staff)) foreach($staff as $key => $row): ?>
						<?php if (($_SESSION['user']['id'] == $row['id']) || $role == 'admin'): ?>
							
							<div class="row">
								<div class="col-12">
									<strong class="text-uppercase">Staff Id : </strong><br/>
									<?php echo $row['staff_id']; ?>
								</div>
							</div>

							<div class="row">
								<div class="col-12">
									<strong class="text-uppercase">Staff Name : </strong><br/>
									<?php echo $row['name']; ?>
								</div>
							</div>

							<div class="row">
								<div class="col-12">
									<strong class="text-uppercase">Status : </strong><br/>
									<?php if($row['is_delete'] == 0){ ?>
										<span class="badge badge-success">Current Staff</span>
									<?php } else{ ?>
										<span class="badge badge-danger">Deleted</span>
									<?php } ?>
								</div>
							</div>
						
							<div class="row">
								<div class="col-12">
									<strong class="text-uppercase">Action :</strong><br>
									
									<a href="<?php echo base_url('hr/StaffProfile/new_action_type/'.$row['id']); ?>" class="btn btn-primary" data-trigger="hover" data-tooltip="tooltip" title="" data-original-title="Create Action Type"><i class="fas fa-plus-square"></i></a>
									<a href="<?php echo base_url().'hr/StaffProfile/staffDetail/'.$row['id']; ?>" class="btn btn-success"  data-trigger="hover" data-tooltip="tooltip" title="" data-original-title="View staff Details"><i class="fas fa-eye"></i></a>
								</div>
							</div>
							<hr>

						<?php endif; ?>
					<?php endforeach; ?>
				</div>



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

<script type="text/javascript">
	function addStaff()
	{
		window.open("<?php echo base_url().'admin/user/setting/'?>", "_blank");
	}

	function deleteUser()
	{
		
	}

	function clearForm(e)
	{
		$(e).find('form').find("input[type=text], input[type=password], textarea").val("");
	}

	function saveCustomer()
	{
		var postData = {
			'name': $('#company_name').val(),
			'roc_no': $('#company_no').val(),
		};

		$.ajax({
            type: 'POST',
            dataType: 'json',
            url: '<?php echo base_url(); ?>CRM/saveNewCustomer',
            data: postData,
            success: function(data) {
                location.reload();
            }
        });
	}

	function printStaffList()
	{
		window.open("<?php echo base_url().'hr/staffprofile/staff_list_report/'?>", "_blank");
	}


</script>