<?php 
	use Backend\Models\User;
	use NetSTI\System\Models\CompanySettings; 
	use NetSTI\System\Models\PaymentsSettings; 
?>
<div class="scoreboard">
	<div data-control="toolbar">
		<div class="scoreboard-item title-value">
			<h4><?= $model->taxdocument->doc_type ?></h4>
			<p><?= $model->label_nid ?></p>
			<p class="description"><?= $model->taxdocument->doc_name." : ".$model->taxdocument->doc_nid ?></p>
		</div>

		<div class="scoreboard-item title-value">
			<h4><?= trans('netsti.system::lang.estimates.total') ?></h4>
			<p><?= PaymentsSettings::getCurrencyData()['symbol_native'] ?> <span class="<?= ($model->status < 1)? 'total-widget':'' ?>"><?= number_format($model->total, 2, '.', ',') ?></span></p>
			<?php if($model->status == 0){ ?>
				<span style="font-size: 12px;margin-top:-2px;margin-right:6px;color:#FFF;padding: 2px 4px;display:inline-block; background-color: #e67e22; border-radius: 3px;"><?= trans('netsti.system::lang.invoices.pending_status') ?></span>
			<?php }else if($model->status == 1){ ?>
				<span style="font-size: 12px;margin-top:-2px;margin-right:6px;color:#FFF;padding: 2px 4px;display:inline-block; background-color: #3498db; border-radius: 3px;"><?= trans('netsti.system::lang.invoices.approved_status') ?></span>
			<?php }else if($model->status == 2){ ?>
				<span style="font-size: 12px;margin-top:-2px;margin-right:6px;color:#FFF;padding: 2px 4px;display:inline-block; background-color: #95b753; border-radius: 3px;"><?= trans('netsti.system::lang.invoices.paid_status') ?></span>
			<?php }else if($model->status == 3){ ?>
				<span style="font-size: 12px;margin-top:-2px;margin-right:6px;color:#FFF;padding: 2px 4px;display:inline-block; background-color: #e74c3c; border-radius: 3px;"><?= trans('netsti.system::lang.invoices.void_status') ?></span>
			<?php } ?>

			<?php if($model->checkOverdue() && $value < 2): ?>
				<span style="font-size: 12px;margin-top:-2px;margin-right:6px;color:#FFF;padding: 2px 4px;display:inline-block; background-color: #9b59b6; border-radius: 3px;"><?= trans('netsti.system::lang.invoices.overdue_status') ?></span>
			<?php endif ?>
		</div>

		<div class="scoreboard-item title-value">
			<h4><?= trans('netsti.system::lang.estimates.created_by') ?></h4>
			<p class="oc-icon-user"><?= $model->owner->first_name.' '.$model->owner->last_name ?></p>
			<p class="description"><?= date_format($model->created_at, 'D d, M Y - h:i a') ?></p>
		</div>

		<?php if($model->estimate != null): ?>
		<div class="scoreboard-item title-value">
			<h4><?= trans('netsti.system::lang.estimates.from_estimate') ?></h4>
			<p><a href="<?= Backend::url('netsti/system/estimates/preview/'.$model->estimate->id) ?>"><?= $model->estimate->label_nid ?></a></p>
			<p class="description"><?= date_format($model->estimate->created_at, 'D d, M Y - h:i a') ?></p>
		</div>
		<?php endif ?>
	</div>
</div>
<div data-control="toolbar">
	<a href="<?= Backend::url('netsti/system/invoices') ?>" class="btn btn-primary oc-icon-chevron-left">
		<?= trans('netsti.system::lang.back_close') ?>
	</a>

	<?php if($model->status < 1): ?>
	<a href="<?= Backend::url('netsti/system/invoices/update/'.$model->id) ?>" class="btn btn-primary oc-icon-edit">
		<?= trans('netsti.system::lang.edit') ?>
	</a>

	<button
			class="btn btn-success oc-icon-check"
			data-request="onApprove"
			data-request-confirm="<?= trans('netsti.system::lang.invoices.approve_confirm') ?>"
			data-request-success="location.reload()"
			data-stripe-load-indicator>
			<?= trans('netsti.system::lang.invoices.approve') ?>
	</button>
	<?php endif ?>

	<div class="btn-group">
		<button
			class="btn btn-default oc-icon-send"
			data-request="onMail"
			data-request-confirm="<?= trans('netsti.system::lang.send_cofirm') ?>"
			data-stripe-load-indicator>
			<?= trans('netsti.system::lang.send') ?>
		</button>
		<a href="<?= Backend::url('netsti/system/invoices/pdf/'.$model->id) ?>" target="_blank" class="btn btn-default oc-icon-print">
			<?= trans('netsti.system::lang.print') ?>
		</a>
	</div>

	<?php if($model->status < 2): ?>
	<button
			class="btn btn-danger oc-icon-exclamation-circle"
			data-request="onVoid"
			data-request-confirm="<?= trans('netsti.system::lang.invoices.void_confirm') ?>"
			data-request-success="location.reload()"
			data-stripe-load-indicator>
			<?= trans('netsti.system::lang.invoices.void') ?>
	</button>
	<?php endif ?>
</div>