<?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('cierre_view'); ?> #<?php echo (int)$cierre->id; ?></h3>
			</div>
			<div class="panel-body">
				<?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="row" style="margin-bottom:15px;">
					<div class="col-md-8">
						<strong><?php echo lang('cierre_fecha'); ?>:</strong> <?php echo H($cierre->fecha); ?> &nbsp; 
						<strong><?php echo lang('cierre_caja'); ?>:</strong> <?php echo H($cierre->caja_nombre); ?> &nbsp;
						<strong><?php echo lang('cierre_bolsa'); ?>:</strong> <?php echo H($cierre->bolsa_manual); ?>
						<br>
						<strong><?php echo lang('cierre_estado'); ?>:</strong> <?php echo H($cierre->estado); ?>
					</div>
					<div class="col-md-4 text-right">
						<?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/'.$cierre->id, lang('common_edit'), array('class'=>'btn btn-primary')); ?>
						<?php } ?>
						<?php if ($cierre->completo == 0 && $this->Employee->has_module_action_permission('cierre','complete',$this->Employee->get_logged_in_employee_info()->person_id)) { ?>
							<?php echo anchor('cierre/complete/'.$cierre->id, lang('cierre_mark_complete'), array('class'=>'btn btn-success')); ?>
						<?php } ?>
						<?php echo anchor('cierre', lang('common_back'), array('class'=>'btn btn-default')); ?>
					</div>
				</div>

				<div class="table-responsive">
					<table class="table table-bordered">
						<thead>
							<tr>
								<th><?php echo lang('cierre_tipo_pago'); ?></th>
								<th class="text-right"><?php echo lang('cierre_sistema_usd'); ?></th>
								<th class="text-right"><?php echo lang('cierre_contado_usd'); ?></th>
								<th class="text-right"><?php echo lang('cierre_diferencia'); ?></th>
							</tr>
						</thead>
						<tbody>
							<?php foreach($detalle as $d) { ?>
								<tr>
									<td><?php echo H($d->tipo_pago); ?></td>
									<td class="text-right"><?php echo number_format((float)$d->monto_sistema_usd,2); ?></td>
									<td class="text-right"><?php echo number_format((float)$d->monto_contado_usd,2); ?></td>
									<td class="text-right"><?php echo number_format((float)$d->diferencia_usd,2); ?></td>
								</tr>
							<?php } ?>
						</tbody>
						<tfoot>
							<tr>
								<th class="text-right"><?php echo lang('cierre_totales'); ?></th>
								<th class="text-right"><?php echo number_format((float)$cierre->total_sistema_usd,2); ?></th>
								<th class="text-right"><?php echo number_format((float)$cierre->total_contado_usd,2); ?></th>
								<th class="text-right"><?php echo number_format((float)$cierre->diferencia_total_usd,2); ?></th>
							</tr>
						</tfoot>
					</table>
				</div>

				<?php if ($cierre->notas) { ?>
					<div class="well"><strong><?php echo lang('cierre_notas'); ?>:</strong><br><?php echo nl2br(H($cierre->notas)); ?></div>
				<?php } ?>

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

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