<?php $this->load->view("partial/header"); ?>

<div class="row">
	<div class="col-md-12">
		<div class="panel panel-piluku">
			<div class="panel-heading">
				<h3 class="panel-title"><?php echo lang('module_cierre'); ?></h3>
			</div>
			<div class="panel-body">
								<div class="clearfix" style="margin-bottom:15px;">
					<div class="btn-toolbar" role="toolbar">
						<?php if ($this->Employee->has_module_action_permission('cierre','add_update',$this->Employee->get_logged_in_employee_info()->person_id)) { ?>
							<?php echo anchor('cierre/create', '<span class="ion-plus"></span> '.lang('cierre_new'), array('class'=>'btn btn-primary')); ?>
						<?php } ?>
						<?php if ($this->Employee->has_module_action_permission('cierre','config',$this->Employee->get_logged_in_employee_info()->person_id)) { ?>
							<?php echo anchor('cierre/config', '<span class="ion-gear-a"></span> '.lang('cierre_config'), array('class'=>'btn btn-default')); ?>
						<?php } ?>
					</div>
				</div>

				<?php if ($this->session->flashdata('manage_success_message')) { ?>
					<div class="alert alert-success"><?php echo H($this->session->flashdata('manage_success_message')); ?></div>
				<?php } ?>
				<?php if ($this->session->flashdata('error')) { ?>
					<div class="alert alert-danger"><?php echo H($this->session->flashdata('error')); ?></div>
				<?php } ?>

				<div class="table-responsive">
					<table class="table table-bordered table-striped">
						<thead>
							<tr>
								<th><?php echo lang('cierre_fecha'); ?></th>
								<th><?php echo lang('cierre_caja'); ?></th>
								<th><?php echo lang('cierre_bolsa'); ?></th>
								<th><?php echo lang('cierre_estado'); ?></th>
								<th><?php echo lang('cierre_total_sistema'); ?></th>
								<th><?php echo lang('cierre_total_contado'); ?></th>
								<th><?php echo lang('cierre_diferencia'); ?></th>
								<th><?php echo lang('common_actions'); ?></th>
							</tr>
						</thead>
						<tbody>
							<?php if (!empty($cierres)) { foreach ($cierres as $c) { ?>
								<tr>
									<td><?php echo H($c->fecha); ?></td>
									<td><?php echo H($c->caja_nombre); ?></td>
									<td><?php echo H($c->bolsa_manual); ?></td>
									<td><?php echo H($c->estado); ?></td>
									<td><?php echo to_currency($c->total_sistema_usd); ?></td>
									<td><?php echo to_currency($c->total_contado_usd); ?></td>
									<td><?php echo to_currency($c->diferencia_total_usd); ?></td>
									<td>
										<?php echo anchor('cierre/view/'.$c->id, lang('common_view'), array('class'=>'btn btn-xs btn-default')); ?>
										<?php if ($this->Employee->has_module_action_permission('cierre','add_update',$this->Employee->get_logged_in_employee_info()->person_id)) { ?>
											<?php echo anchor('cierre/edit/'.$c->id, lang('common_edit'), array('class'=>'btn btn-xs btn-primary')); ?>
										<?php } ?>
									</td>
								</tr>
							<?php }} else { ?>
								<tr><td colspan="8" class="text-center"><?php echo lang('cierre_no_records'); ?></td></tr>
							<?php } ?>
						</tbody>
					</table>
				</div>

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

<?php $this->load->view("partial/footer"); ?>
