mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
aaa
This commit is contained in:
@ -143,6 +143,11 @@ class Facturas extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
|
|
||||||
helper('form');
|
helper('form');
|
||||||
|
|
||||||
|
$this->viewData['breadcrumb'] = [
|
||||||
|
['title' => lang("App.menu_facturas"), 'route' => "javascript:void(0);", 'active' => false],
|
||||||
|
['title' => lang("Facturas.facturaList"), 'route' => route_to('facturasList'), 'active' => true]
|
||||||
|
];
|
||||||
|
|
||||||
$this->viewData['usingSelect2'] = true;
|
$this->viewData['usingSelect2'] = true;
|
||||||
|
|
||||||
@ -168,9 +173,15 @@ class Facturas extends \App\Controllers\BaseResourceController
|
|||||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Facturas.factura')), $id]);
|
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Facturas.factura')), $id]);
|
||||||
return $this->redirect2listView('sweet-error', $message);
|
return $this->redirect2listView('sweet-error', $message);
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|
||||||
$this->obtenerDatosFormulario($factura);
|
$this->obtenerDatosFormulario($factura);
|
||||||
|
|
||||||
|
$this->viewData['breadcrumb'] = [
|
||||||
|
['title' => lang("App.menu_facturas"), 'route' => "javascript:void(0);", 'active' => false],
|
||||||
|
['title' => lang("Facturas.facturaList"), 'route' => route_to('facturasList'), 'active' => true]
|
||||||
|
];
|
||||||
|
|
||||||
$this->viewData['facturaEntity'] = $factura;
|
$this->viewData['facturaEntity'] = $factura;
|
||||||
|
|
||||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Facturas.factura') . ' ' . lang('Basic.global.edit3');
|
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Facturas.factura') . ' ' . lang('Basic.global.edit3');
|
||||||
@ -355,14 +366,24 @@ class Facturas extends \App\Controllers\BaseResourceController
|
|||||||
'pendiente' => $postData['pendiente'] ?? 0,
|
'pendiente' => $postData['pendiente'] ?? 0,
|
||||||
'total_pagos' => $postData['total_pagos'] ?? 0,
|
'total_pagos' => $postData['total_pagos'] ?? 0,
|
||||||
'user_updated_id' => auth()->user()->id,
|
'user_updated_id' => auth()->user()->id,
|
||||||
|
'estado_pago' => (intval($postData['pendiente'] ?? 0)==0) ? 'pagada' : 'pendiente',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
$data_ret = [
|
||||||
|
$csrfTokenName => $newTokenHash
|
||||||
|
];
|
||||||
|
|
||||||
if($factura_id == 0){
|
if($factura_id == 0){
|
||||||
return;
|
return $this->respond($data_ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data_ret['estado_pago'] = $data['estado_pago'];
|
||||||
$model = model('\App\Models\Facturas\FacturaModel');
|
$model = model('\App\Models\Facturas\FacturaModel');
|
||||||
$model->update($factura_id, $data);
|
$model->update($factura_id, $data);
|
||||||
|
|
||||||
|
return $this->respond($data_ret);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
@ -483,6 +504,10 @@ class Facturas extends \App\Controllers\BaseResourceController
|
|||||||
'user_updated_id' => auth()->user()->id,
|
'user_updated_id' => auth()->user()->id,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if((strpos($numero, "REC ") === 0)){
|
||||||
|
$data['estado_pago'] = 'pagada';
|
||||||
|
}
|
||||||
|
|
||||||
$this->model->update($factura_id, $data);
|
$this->model->update($factura_id, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,7 @@ return [
|
|||||||
'serieFacturacion' => 'Billing Series',
|
'serieFacturacion' => 'Billing Series',
|
||||||
'creditoAsegurado' => 'Secured Credit',
|
'creditoAsegurado' => 'Secured Credit',
|
||||||
'facturaRectificada' => 'Rectified Invoice',
|
'facturaRectificada' => 'Rectified Invoice',
|
||||||
|
'facturaRectificativa' => 'Rectifying Invoice',
|
||||||
'razonSocial' => 'Business Name',
|
'razonSocial' => 'Business Name',
|
||||||
'cif' => 'Tax ID',
|
'cif' => 'Tax ID',
|
||||||
'direccion' => 'Address',
|
'direccion' => 'Address',
|
||||||
@ -70,6 +71,7 @@ return [
|
|||||||
"fechaCobro" => "Collection Date",
|
"fechaCobro" => "Collection Date",
|
||||||
"cantidad" => "Quantity",
|
"cantidad" => "Quantity",
|
||||||
"addPago" => "Add Payment",
|
"addPago" => "Add Payment",
|
||||||
|
"facturaPagada" => "Rectifying Invoice already paid",
|
||||||
|
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'requiredFields' => 'Fields marked with * are required',
|
'requiredFields' => 'Fields marked with * are required',
|
||||||
|
|||||||
@ -22,6 +22,7 @@ return [
|
|||||||
'serieFacturacion' => 'Serie facturación',
|
'serieFacturacion' => 'Serie facturación',
|
||||||
'creditoAsegurado' => 'Crédito asegurado',
|
'creditoAsegurado' => 'Crédito asegurado',
|
||||||
'facturaRectificada' => 'Factura rectificada',
|
'facturaRectificada' => 'Factura rectificada',
|
||||||
|
'facturaRectificativa' => 'Factura rectificativa',
|
||||||
'razonSocial' => 'Razón Social',
|
'razonSocial' => 'Razón Social',
|
||||||
'cif' => 'CIF',
|
'cif' => 'CIF',
|
||||||
'direccion' => 'Dirección',
|
'direccion' => 'Dirección',
|
||||||
@ -70,6 +71,7 @@ return [
|
|||||||
"fechaCobro" => "Fecha Cobro",
|
"fechaCobro" => "Fecha Cobro",
|
||||||
"cantidad" => "Cantidad",
|
"cantidad" => "Cantidad",
|
||||||
"addPago" => "Añadir Pago",
|
"addPago" => "Añadir Pago",
|
||||||
|
"facturaPagada" => "Factura rectificativa ya pagada",
|
||||||
|
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'requiredFields' => 'Los campos marcados con * son obligatorios',
|
'requiredFields' => 'Los campos marcados con * son obligatorios',
|
||||||
|
|||||||
@ -11,7 +11,11 @@
|
|||||||
<div class="accordion-body">
|
<div class="accordion-body">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h4><?= lang('Facturas.factura') . ': '?> <span style="color:<?=($facturaEntity->estado === 'borrador')?"red":"green"?>;"> <?= lang('Facturas.' . $facturaEntity->estado)?> </span></h4>
|
<h4><?= lang('Facturas.factura') . ': '?>
|
||||||
|
<span style="color:<?=($facturaEntity->estado === 'borrador')?"red":"green"?>;"> <?= lang('Facturas.' . $facturaEntity->estado)?></span>
|
||||||
|
<span class="factura-validada"> <?= ($facturaEntity->estado != 'borrador')? " / ":""?></span>
|
||||||
|
<span id="estado_pago_text" class="factura-validada" style="color:<?=($facturaEntity->estado_pago === 'pendiente')?"red":"green"?>;<?= ($facturaEntity->estado == 'borrador')? "display:none;":""?>"> <?= lang('Facturas.' . $facturaEntity->estado_pago)?></span>
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
|
|
||||||
@ -86,7 +90,26 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
<div class="col-md-12 col-lg-6 px-4">
|
<?php if($facturaEntity->serie_id == 7 || $facturaEntity->serie_id == 9): ?>
|
||||||
|
<div class="col-md-12 col-lg-2 px-4">
|
||||||
|
<div class="mb-1">
|
||||||
|
<label for="id" class="form-label">
|
||||||
|
<?= ($facturaEntity->factura_retificada_id != null) ? lang('Facturas.facturaRectificada') : lang('Facturas.facturaRectificativa') ?>:
|
||||||
|
</label>
|
||||||
|
<input <?= ($facturaEntity->estado!='borrador')? "disabled":"" ?> id="facturaR" name="facturaR" tabindex="" maxLength="11" class="form-control"
|
||||||
|
value=
|
||||||
|
<?php if($facturaEntity->factura_retificada_id != null && $facturaEntity->factura_retificada_id != null): ?>
|
||||||
|
""
|
||||||
|
<?
|
||||||
|
<?= old('factura_retificada_id', $facturaEntity->factura_retificada_id) ?>
|
||||||
|
?>
|
||||||
|
"
|
||||||
|
value="<?= ($facturaEntity->factura_retificada_id != null) ? old('factura_retificada_id', $facturaEntity->factura_retificada_id): old('numero', $facturaEntity->factura_retificativa_id)?>"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<div class="col-md-12 col-lg-<?= ($facturaEntity->factura_retificada_id != null || $facturaEntity->factura_retificativa_id != null)?"4":"6" ?> px-4">
|
||||||
<div class="mb-1">
|
<div class="mb-1">
|
||||||
<label for="cliente_nombre" class="form-label">
|
<label for="cliente_nombre" class="form-label">
|
||||||
<?= lang('Facturas.razonSocial') ?>
|
<?= lang('Facturas.razonSocial') ?>
|
||||||
|
|||||||
@ -90,7 +90,11 @@ const actionBtns = function(data) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ``;
|
||||||
|
}
|
||||||
|
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
if (data.pedido_id === null) {
|
if (data.pedido_id === null) {
|
||||||
@ -349,7 +353,7 @@ function updateFooterLineas(table){
|
|||||||
$('#total-sum').html(totalTotal.toFixed(2));
|
$('#total-sum').html(totalTotal.toFixed(2));
|
||||||
|
|
||||||
// Assuming pendiente de pago is totalTotal - totalIVA for this example
|
// Assuming pendiente de pago is totalTotal - totalIVA for this example
|
||||||
<?php if($facturaEntity->estado != 'borrador') :?>
|
<?php if($facturaEntity->estado == 'borrador') :?>
|
||||||
var pendientePago = totalTotal ;
|
var pendientePago = totalTotal ;
|
||||||
var total_pagos = 0;
|
var total_pagos = 0;
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
@ -368,7 +372,14 @@ function updateFooterLineas(table){
|
|||||||
pendiente: pendientePago
|
pendiente: pendientePago
|
||||||
}
|
}
|
||||||
}).done((data, textStatus, jqXHR) => {
|
}).done((data, textStatus, jqXHR) => {
|
||||||
//console.log(data);
|
if(data.estado_pago == 'pagada'){
|
||||||
|
$('#estado_pago_text').text('<?= lang('Facturas.pagada') ?>');
|
||||||
|
$('#estado_pago_text').css('color', 'green');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$('#estado_pago_text').text('<?= lang('Facturas.pendiente') ?>');
|
||||||
|
$('#estado_pago_text').css('color', 'red');
|
||||||
|
}
|
||||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -169,13 +169,18 @@ var tablePagos = $('#tableOfLineasPagos').DataTable({
|
|||||||
{
|
{
|
||||||
data: "fecha_vencimiento_at",
|
data: "fecha_vencimiento_at",
|
||||||
render: function(data, type, row) {
|
render: function(data, type, row) {
|
||||||
|
if(data == null){
|
||||||
|
return '';
|
||||||
|
}
|
||||||
return data!='0000-00-00 00:00:00' ? moment(data).format('DD/MM/YYYY') : '';
|
return data!='0000-00-00 00:00:00' ? moment(data).format('DD/MM/YYYY') : '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: "fecha_pago_at",
|
data: "fecha_pago_at",
|
||||||
render: function(data, type, row) {
|
render: function(data, type, row) {
|
||||||
|
if(data == null){
|
||||||
|
return '';
|
||||||
|
}
|
||||||
return data!='0000-00-00 00:00:00' ? moment(data).format('DD/MM/YYYY') : '';
|
return data!='0000-00-00 00:00:00' ? moment(data).format('DD/MM/YYYY') : '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -300,6 +305,14 @@ function updateFooterLineas(table){
|
|||||||
} else {
|
} else {
|
||||||
$('#validarFactura').show();
|
$('#validarFactura').show();
|
||||||
}
|
}
|
||||||
|
if(data.estado_pago == 'pagada'){
|
||||||
|
$('#estado_pago_text').text('<?= lang('Facturas.pagada') ?>');
|
||||||
|
$('#estado_pago_text').css('color', 'green');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$('#estado_pago_text').text('<?= lang('Facturas.pendiente') ?>');
|
||||||
|
$('#estado_pago_text').css('color', 'red');
|
||||||
|
}
|
||||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?= view("themes/vuexy/form/facturas/_facturaLineasItems") ?>
|
<?= view("themes/vuexy/form/facturas/_facturaLineasItems") ?>
|
||||||
<?php if($facturaEntity->estado !='borrador') : ?>
|
<?php if($facturaEntity->estado !='borrador' && (strpos($facturaEntity->numero, "REC ") === 0) ) : ?>
|
||||||
<?= view("themes/vuexy/form/facturas/_pagosFacturasItems") ?>
|
<?= view("themes/vuexy/form/facturas/_pagosFacturasItems") ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
@ -39,14 +39,14 @@
|
|||||||
id="borrarFactura"
|
id="borrarFactura"
|
||||||
name="borrarFactura"
|
name="borrarFactura"
|
||||||
value="<?= lang("Facturas.borrarFactura") ?>"
|
value="<?= lang("Facturas.borrarFactura") ?>"
|
||||||
/>
|
/>
|
||||||
<input type="button"
|
|
||||||
class="btn btn-info float-start me-sm-3 me-1"
|
|
||||||
id="imprimirFactura"
|
|
||||||
name="imprimirFactura"
|
|
||||||
value="<?= lang("Facturas.imprimirFactura") ?>"
|
|
||||||
/>
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<input type="button"
|
||||||
|
class="btn btn-info float-start me-sm-3 me-1"
|
||||||
|
id="imprimirFactura"
|
||||||
|
name="imprimirFactura"
|
||||||
|
value="<?= lang("Facturas.imprimirFactura") ?>"
|
||||||
|
/>
|
||||||
<?= anchor(route_to("facturasList"), lang("Basic.global.back"), ["class" => "btn btn-secondary float-start"]) ?>
|
<?= anchor(route_to("facturasList"), lang("Basic.global.back"), ["class" => "btn btn-secondary float-start"]) ?>
|
||||||
</div><!-- /.card-footer -->
|
</div><!-- /.card-footer -->
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user