Merge branch 'main' into 'dev/chat'

Main

See merge request jjimenez/safekat!305
This commit is contained in:
Ignacio Martinez Navajas
2024-08-16 08:51:39 +00:00
30 changed files with 770 additions and 367 deletions

View File

@ -70,7 +70,6 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion']
/* Series Factura */ /* Series Factura */
$routes->group('series-facturas', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { $routes->group('series-facturas', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->get('', 'SeriesFacturas::index', ['as' => 'seriesFacturasList']); $routes->get('', 'SeriesFacturas::index', ['as' => 'seriesFacturasList']);
$routes->match(['get', 'post'], 'add', 'SeriesFacturas::add', ['as' => 'seriesFacturasAdd']); $routes->match(['get', 'post'], 'add', 'SeriesFacturas::add', ['as' => 'seriesFacturasAdd']);
$routes->match(['get', 'post'], 'edit/(:num)', 'SeriesFacturas::edit/$1', ['as' => 'seriesFacturasEdit']); $routes->match(['get', 'post'], 'edit/(:num)', 'SeriesFacturas::edit/$1', ['as' => 'seriesFacturasEdit']);
@ -79,6 +78,15 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion']
$routes->post('menuitemsFacturas', 'SeriesFacturas::menuItemsFacturas', ['as' => 'menuItemsOfSeriesFacturas']); $routes->post('menuitemsFacturas', 'SeriesFacturas::menuItemsFacturas', ['as' => 'menuItemsOfSeriesFacturas']);
}); });
/* Formas de Pago */
$routes->group('formas-pago', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->get('', 'FormasPago::index', ['as' => 'formasPagoList']);
$routes->match(['get', 'post'], 'add', 'FormasPago::add', ['as' => 'formasPagoAdd']);
$routes->match(['get', 'post'], 'edit/(:num)', 'FormasPago::edit/$1', ['as' => 'formasPagoEdit']);
$routes->get('delete/(:num)', 'FormasPago::delete/$1', ['as' => 'formasPagoDelete']);
$routes->post('datatable', 'FormasPago::datatable', ['as' => 'formasPagoDT']);
});
}); });
@ -661,7 +669,7 @@ $routes->group('facturas', ['namespace' => 'App\Controllers\Facturacion'], funct
$routes->post('datatable/(:any)', 'FacturasLineas::datatable/$1', ['as' => 'dataTableOfLineasFacturas']); $routes->post('datatable/(:any)', 'FacturasLineas::datatable/$1', ['as' => 'dataTableOfLineasFacturas']);
$routes->post('menuPedidosPendientes/(:num)', 'Facturas::menuPedidosPendientes/$1', ['as' => 'menuPedidosPendientesImpresion']); $routes->post('menuPedidosPendientes/(:num)', 'Facturas::menuPedidosPendientes/$1', ['as' => 'menuPedidosPendientesImpresion']);
$routes->post('addLineaPedidoImpresion/(:num)', 'Facturas::addLineaPedidoImpresion/$1', ['as' => 'addLineaPedidoImpresion2Factura']); $routes->post('addLineaPedidoImpresion/(:num)', 'Facturas::addLineaPedidoImpresion/$1', ['as' => 'addLineaPedidoImpresion2Factura']);
$routes->post('addLineaPedidoImpresion/(:num)', 'Facturas::addLineaPedidoImpresion/$1', ['as' => 'addLineaPedidoImpresion2Factura']); $routes->post('addExcedentes/(:any)', 'Facturas::addExcedentes/$1', ['as' => 'addLineaExcedentes']);
$routes->get('deleteLinea/(:any)', 'FacturasLineas::deleteLinea/$1', ['as' => 'deleteLineaFactura']); $routes->get('deleteLinea/(:any)', 'FacturasLineas::deleteLinea/$1', ['as' => 'deleteLineaFactura']);
$routes->get('delete/(:any)', 'Facturas::delete/$1', ['as' => 'borrarFactura']); $routes->get('delete/(:any)', 'Facturas::delete/$1', ['as' => 'borrarFactura']);
$routes->post('deleteFacturaLineaPedido', 'Facturas::deleteLineaPedidoImpresion', ['as' => 'deleteLineaPedidoImpresion']); $routes->post('deleteFacturaLineaPedido', 'Facturas::deleteLineaPedidoImpresion', ['as' => 'deleteLineaPedidoImpresion']);

View File

@ -395,7 +395,7 @@ class Cliente extends \App\Controllers\BaseResourceController
protected function getFormaDePagoListItems($selId = null) protected function getFormaDePagoListItems($selId = null)
{ {
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('FormasPagoes.formaDePago'))])]; $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('FormasPago.formaDePago'))])];
if (!empty($selId)) : if (!empty($selId)) :
$formaPagoModel = model('App\Models\Configuracion\FormaPagoModel'); $formaPagoModel = model('App\Models\Configuracion\FormaPagoModel');

View File

@ -9,7 +9,7 @@ use App\Entities\Configuracion\FormaPagoEntity;
use App\Models\Configuracion\FormaPagoModel; use App\Models\Configuracion\FormaPagoModel;
class Formaspagos extends \App\Controllers\BaseResourceController class FormasPago extends \App\Controllers\BaseResourceController
{ {
protected $modelName = FormaPagoModel::class; protected $modelName = FormaPagoModel::class;
@ -22,15 +22,22 @@ class Formaspagos extends \App\Controllers\BaseResourceController
protected static $controllerSlug = 'formas-pagos'; protected static $controllerSlug = 'formas-pagos';
protected static $viewPath = 'themes/vuexy/form/configuracion/formasPagoViews/'; protected static $viewPath = 'themes/vuexy/form/configuracion/formas-pago/';
protected $indexRoute = 'formaDePagoList'; protected $indexRoute = 'formaDePagoList';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{ {
$this->viewData['pageTitle'] = lang('FormasPagoes.moduleTitle'); $this->viewData['pageTitle'] = lang('FormasPago.moduleTitle');
$this->viewData['usingSweetAlert'] = true; $this->viewData['usingSweetAlert'] = true;
// Breadcrumbs (IMN)
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
['title' => lang("App.menu_formas_pago"), 'route' => route_to('formasPagoList'), 'active' => true]
];
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
} }
@ -40,7 +47,7 @@ class Formaspagos extends \App\Controllers\BaseResourceController
$viewData = [ $viewData = [
'currentModule' => static::$controllerSlug, 'currentModule' => static::$controllerSlug,
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('FormasPagoes.formaDePago')]), 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('FormasPago.formaDePago')]),
'formaPagoEntity' => new FormaPagoEntity(), 'formaPagoEntity' => new FormaPagoEntity(),
'usingServerSideDataTable' => true, 'usingServerSideDataTable' => true,
@ -55,22 +62,15 @@ class Formaspagos extends \App\Controllers\BaseResourceController
public function add() public function add()
{ {
if ($this->request->getPost()) : if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost(); $postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty); $sanitizedData = $this->sanitized($postData, true);
$noException = true; $noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) : if ($this->canValidate()) :
try { try {
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData); $successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
@ -93,7 +93,8 @@ class Formaspagos extends \App\Controllers\BaseResourceController
if ($thenRedirect) : if ($thenRedirect) :
if (!empty($this->indexRoute)) : if (!empty($this->indexRoute)) :
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message); return redirect()->to(site_url('/configuracion/formas-pago/edit/' . $id))->with('sweet-success', $message);
//return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else: else:
return $this->redirect2listView('sweet-success', $message); return $this->redirect2listView('sweet-success', $message);
endif; endif;
@ -106,11 +107,8 @@ class Formaspagos extends \App\Controllers\BaseResourceController
endif; // ($requestMethod === 'post') endif; // ($requestMethod === 'post')
$this->viewData['formaPagoEntity'] = isset($sanitizedData) ? new FormaPagoEntity($sanitizedData) : new FormaPagoEntity(); $this->viewData['formaPagoEntity'] = isset($sanitizedData) ? new FormaPagoEntity($sanitizedData) : new FormaPagoEntity();
$this->viewData['formAction'] = route_to('formasPagoAdd');
$this->viewData['formAction'] = route_to('createFormaDePago'); $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('FormasPago.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('FormasPagoes.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__); return $this->displayForm(__METHOD__);
} // end function add() } // end function add()
@ -125,25 +123,18 @@ class Formaspagos extends \App\Controllers\BaseResourceController
$formaPagoEntity = $this->model->find($id); $formaPagoEntity = $this->model->find($id);
if ($formaPagoEntity == false) : if ($formaPagoEntity == false) :
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('FormasPagoes.formaDePago')), $id]); $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('FormasPago.formaDePago')), $id]);
return $this->redirect2listView('sweet-error', $message); return $this->redirect2listView('sweet-error', $message);
endif; endif;
if ($this->request->getPost()) : if ($this->request->getPost()) :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost(); $postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, true);
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
$noException = true; $noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) : if ($this->canValidate()) :
try { try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
@ -152,13 +143,12 @@ class Formaspagos extends \App\Controllers\BaseResourceController
$this->dealWithException($e); $this->dealWithException($e);
} }
else: else:
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('FormasPagoes.formaDePago'))]); $this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('FormasPago.formaDePago'))]);
$this->session->setFlashdata('formErrors', $this->model->errors()); $this->session->setFlashdata('formErrors', $this->model->errors());
endif; endif;
$formaPagoEntity->fill($sanitizedData); $formaPagoEntity->fill($sanitizedData);
$thenRedirect = false; $thenRedirect = false;
endif; endif;
if ($noException && $successfulResult) : if ($noException && $successfulResult) :
@ -179,11 +169,8 @@ class Formaspagos extends \App\Controllers\BaseResourceController
endif; // ($requestMethod === 'post') endif; // ($requestMethod === 'post')
$this->viewData['formaPagoEntity'] = $formaPagoEntity; $this->viewData['formaPagoEntity'] = $formaPagoEntity;
$this->viewData['formAction'] = route_to('formasPagoEdit', $id);
$this->viewData['formAction'] = route_to('updateFormaDePago', $id); $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('FormasPago.moduleTitle') . ' ' . lang('Basic.global.edit3');
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('FormasPagoes.moduleTitle') . ' ' . lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id); return $this->displayForm(__METHOD__, $id);
} // end function edit(...) } // end function edit(...)

View File

@ -66,7 +66,6 @@ class SeriesFacturas extends BaseResourceController
$noException = true; $noException = true;
if ($successfulResult = $this->canValidate()) : if ($successfulResult = $this->canValidate()) :
if ($this->canValidate()) : if ($this->canValidate()) :
try { try {
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData); $successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
@ -105,7 +104,6 @@ class SeriesFacturas extends BaseResourceController
$this->viewData['formAction'] = route_to('seriesFacturasAdd'); $this->viewData['formAction'] = route_to('seriesFacturasAdd');
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('SeriesFacturas.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('SeriesFacturas.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__); return $this->displayForm(__METHOD__);
} // end function add() } // end function add()
@ -126,7 +124,6 @@ class SeriesFacturas extends BaseResourceController
if ($this->request->getPost()) : if ($this->request->getPost()) :
$postData = $this->request->getPost(); $postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, true); $sanitizedData = $this->sanitized($postData, true);
if ($this->request->getPost('show_erp') == null) { if ($this->request->getPost('show_erp') == null) {
$sanitizedData['show_erp'] = false; $sanitizedData['show_erp'] = false;

View File

@ -392,13 +392,16 @@ class Facturas extends \App\Controllers\BaseResourceController
$postData = $this->request->getPost(); $postData = $this->request->getPost();
$pendiente = $postData['pendiente'] ?? 0;
$total = $postData['total'] ?? 0;
$data = [ $data = [
'base' => $postData['base'] ?? 0, 'base' => $postData['base'] ?? 0,
'total' => $postData['total'] ?? 0, 'total' => $total,
'pendiente' => $postData['pendiente'] ?? 0, 'pendiente' => $pendiente,
'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', 'estado_pago' => (intval($pendiente)==0 && intval($total)!=0) ? 'pagada' : 'pendiente',
]; ];
$newTokenHash = csrf_hash(); $newTokenHash = csrf_hash();
@ -422,6 +425,54 @@ class Facturas extends \App\Controllers\BaseResourceController
} }
} }
public function addExcedentes($factura_id){
if ($this->request->isAJAX()) {
$model_factura_linea = model('\App\Models\Facturas\FacturaLineaModel');
$postData = $this->request->getPost();
$cantidad = $postData['cantidad'] ?? 0;
$precio_unidad = $postData['precio_unidad'] ?? 0;
$iva = $postData['iva'] ?? 0;
$descripcion = $postData['descripcion'] ?? '';
$descuento = $postData['descuento'] ?? 0;
$pedido_linea_impresion_id = $postData['pedido_linea_impresion_id'] ?? null;
$pedido_linea_maquetacion_id = $postData['pedido_linea_maquetacion_id'] ?? null;
$pedido_id = $postData['pedido_id'] ?? 0;
$nuevo_precio_unidad = round($precio_unidad*(100-floatval($descuento))/100, 4);
$base = round($cantidad * $nuevo_precio_unidad, 2);
$total_iva = round($base * $iva / 100, 2);
$data = (object)[
'factura_id'=>$factura_id,
'pedido_linea_impresion_id'=>$pedido_linea_impresion_id,
'pedido_linea_maquetacion_id'=>$pedido_linea_maquetacion_id,
'descripcion'=>$newString = preg_replace_callback('/Impresión de (\d+) ejemplares/', function ($matches) use ($cantidad) {
return 'Impresión de ' . $cantidad . ' ejemplares';
}, $descripcion),
'cantidad'=>$cantidad,
'precio_unidad'=> $nuevo_precio_unidad,
'iva' => $iva,
'base' => $base,
'total_iva' => $total_iva,
'total' => round($base + $total_iva, 2),
'user_updated_id' => auth()->user()->id,
];
$model_factura_linea->insert($data);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data_ret = [
$csrfTokenName => $newTokenHash
];
return $this->respond($data_ret);
}
else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function addLineaPedidoImpresion($factura_id){ public function addLineaPedidoImpresion($factura_id){
@ -434,47 +485,54 @@ class Facturas extends \App\Controllers\BaseResourceController
$pedido_linea_id = $this->request->getPost('lineaPedido') ?? 0; $pedido_linea_id = $this->request->getPost('lineaPedido') ?? 0;
$linea = $model_pedido_linea->find($pedido_linea_id); $linea = $model_pedido_linea->find($pedido_linea_id);
if($linea){ $factura = $this->model->find($factura_id);
$presupuesto = $model_presupuesto->find($linea->presupuesto_id);
if($presupuesto){
// Se añade la linea de factura
$descripcion = $model_presupuesto->generarLineaPedido($presupuesto->id, true, $linea->pedido_id);
$cantidad = intval($presupuesto->tirada) - intval($this->model->getCantidadLineaPedidoFacturada($linea->id));
$base = $cantidad * floatval($presupuesto->total_precio_unidad);
$total_iva = $base * ($presupuesto->iva_reducido==1 ? 0.04 : 0.21);
// se redondea a dos decimales
$total_iva = round($total_iva, 2);
$total = $base + $total_iva;
$data = (object)[ if($factura){
'factura_id'=>$factura_id,
'pedido_linea_impresion_id'=>$linea->pedido_id,
'descripcion'=>$descripcion[0]->concepto,
'cantidad'=>$cantidad,
'precio_unidad'=>$presupuesto->total_precio_unidad,
'iva' => $presupuesto->iva_reducido==1 ? 4 : 21,
'base' => $base,
'total_iva' => $total_iva,
'total' => $total,
'user_updated_id' => auth()->user()->id,
];
$model_factura_linea->insert($data); if($linea){
$presupuesto = $model_presupuesto->find($linea->presupuesto_id);
$id = $model_factura_linea->getInsertID(); if($presupuesto){
// Se añade la linea de factura
$descripcion = $model_presupuesto->generarLineaPedido($presupuesto->id, true, $linea->pedido_id);
$cantidad = intval($presupuesto->tirada) - intval($this->model->getCantidadLineaPedidoFacturada($linea->id));
$base = $cantidad * floatval($presupuesto->total_precio_unidad);
$base = round($base, 2);
$total_iva = $base * ($presupuesto->iva_reducido==1 ? 0.04 : 0.21);
// se redondea a dos decimales
$total_iva = round($total_iva, 2);
$total = $base + $total_iva;
if($id){ $data = (object)[
'factura_id'=>$factura_id,
$model_factura_linea->addFacturaPedidoLinea($factura_id, $linea->id, $cantidad); 'pedido_linea_impresion_id'=>$linea->pedido_id,
'descripcion'=>$descripcion[0]->concepto,
$newTokenHash = csrf_hash(); 'cantidad'=>$cantidad,
$csrfTokenName = csrf_token(); 'precio_unidad'=>$presupuesto->total_precio_unidad,
$data = [ 'iva' => $presupuesto->iva_reducido==1 ? 4 : 21,
'error' => 0, 'base' => $base,
'id' => $id, 'total_iva' => $total_iva,
$csrfTokenName => $newTokenHash 'total' => $total,
'user_updated_id' => auth()->user()->id,
]; ];
return $this->respond($data);
$model_factura_linea->insert($data);
$id = $model_factura_linea->getInsertID();
if($id){
$model_factura_linea->addFacturaPedidoLinea($factura_id, $linea->id, $cantidad);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'error' => 0,
'id' => $id,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
} }
} }
} }

View File

@ -245,13 +245,31 @@ class Pedido extends \App\Controllers\BaseResourceController
$estado = $reqData['estado'] ?? 'todos'; $estado = $reqData['estado'] ?? 'todos';
if($estado == 'todos') $estado = ''; if($estado == 'todos') $estado = '';
$model_linea = model('\App\Models\Pedidos\PedidoLineaModel'); $showTotal = $reqData['showTotal'] ?? false;
$resourceData = $model_linea->getResource($search, $estado)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
$searchValues = get_filter_datatables_columns($reqData);
$model_linea = model('\App\Models\Pedidos\PedidoLineaModel');
$resourceData = $model_linea->getResource($searchValues, $estado)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
$totalTirada = $model_linea->getSumOfTirada($searchValues, $estado, $start, $length);
$total = $model_linea->getSumOfTotalAceptado($searchValues, $estado, $start, $length);
$total2 = 0;
if($showTotal){
$total2 = $model_linea->getTotalOfTotalAceptado();
}
if($total2 != 0){
$total = "" . $total . " \n(" . $total2 . ")";
}
return $this->respond(Collection::datatable( return $this->respond(Collection::datatable(
$resourceData, $resourceData,
$model_linea->getResource("", $estado)->countAllResults(), $model_linea->getResource("", $estado)->countAllResults(),
$model_linea->getResource($search, $estado)->countAllResults() $model_linea->getResource($searchValues, $estado)->countAllResults(),
"",
[
'total_tirada' => $totalTirada,
'total' => $total
]
)); ));
} else { } else {
return $this->failUnauthorized('Invalid request', 403); return $this->failUnauthorized('Invalid request', 403);

View File

@ -111,7 +111,7 @@ class Buscador extends \App\Controllers\BaseResourceController
return $this->respond(Collection::datatable( return $this->respond(Collection::datatable(
$resourceData, $resourceData,
$this->model->getResource("")->countAllResults(), $this->model->getResource("")->countAllResults(),
$this->model->getResource($search)->countAllResults() $this->model->getResource($searchValues)->countAllResults()
)); ));
} else { } else {
return $this->failUnauthorized('Invalid request', 403); return $this->failUnauthorized('Invalid request', 403);

View File

@ -1073,14 +1073,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
try { try {
$return_data = []; $return_data = [];
if ($extra_info) { $info = [
$info = [ 'merma' => 0,
'merma' => 0, 'lomo_cubierta' => 0.0,
'lomo_cubierta' => 0.0, 'lomo_sobrecubierta' => 0.0,
'lomo_sobrecubierta' => 0.0, 'user_id' => auth()->user()->id,
'user_id' => auth()->user()->id, ];
];
}
$tirada = $datos_entrada['tirada']; $tirada = $datos_entrada['tirada'];
$tamanio = $datos_entrada['tamanio']; $tamanio = $datos_entrada['tamanio'];
@ -1568,11 +1566,13 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
)); ));
} }
$info['lomo_cubierta'] = $lomo;
$info['lomo_sobrecubierta'] = $lomo_sobrecubierta;
$return_data['info'] = $info;
if ($extra_info) { // && $tirada[$t] == $selected_tirada) { if ($extra_info) { // && $tirada[$t] == $selected_tirada) {
$info['lomo_cubierta'] = $lomo;
$info['lomo_sobrecubierta'] = $lomo_sobrecubierta;
$return_data['info'] = $info;
$return_data['info']['interior'] = $interior; $return_data['info']['interior'] = $interior;
$return_data['info']['cubierta'] = $cubierta; $return_data['info']['cubierta'] = $cubierta;
$return_data['info']['sobrecubierta'] = $linea_sobrecubierta; $return_data['info']['sobrecubierta'] = $linea_sobrecubierta;

View File

@ -679,7 +679,7 @@ return [
"menu_calendario" => "Calendar", "menu_calendario" => "Calendar",
"menu_paises" => "Countries", "menu_paises" => "Countries",
"menu_correo" => "Mail", "menu_correo" => "Mail",
"menu_formaspago" => "Payment methods", "menu_formas_pago" => "Payment methods",
"menu_imposiciones" => "Impositions", "menu_imposiciones" => "Impositions",
"menu_maquina" => "Machines", "menu_maquina" => "Machines",
"menu_papelgenerico" => "Generic paper", "menu_papelgenerico" => "Generic paper",

View File

@ -11,7 +11,6 @@ return [
'formasDePagos' => 'Formas de Pagos', 'formasDePagos' => 'Formas de Pagos',
'formasPago' => 'Formas Pago', 'formasPago' => 'Formas Pago',
'formasPagoList' => 'Formas Pago List', 'formasPagoList' => 'Formas Pago List',
'formasPagoes' => 'Formas Pagoes',
'id' => 'ID', 'id' => 'ID',
'moduleTitle' => 'Formas Pagoes', 'moduleTitle' => 'Formas Pagoes',
'nombre' => 'Nombre', 'nombre' => 'Nombre',

View File

@ -78,6 +78,8 @@ return [
'facturas' => 'Invoices', 'facturas' => 'Invoices',
'showTotal' => 'Show totals',
'validation' => [ 'validation' => [
], ],

View File

@ -682,7 +682,7 @@ return [
"menu_calendario" => "Calendario", "menu_calendario" => "Calendario",
"menu_paises" => "Paises", "menu_paises" => "Paises",
"menu_correo" => "Correo", "menu_correo" => "Correo",
"menu_formaspago" => "Metodos de pago", "menu_formas_pago" => "Formas de pago",
"menu_imposiciones" => "Imposiciones", "menu_imposiciones" => "Imposiciones",
"menu_maquina" => "Maquinas", "menu_maquina" => "Maquinas",
"menu_maquina_defecto" => "Maquinas por defecto", "menu_maquina_defecto" => "Maquinas por defecto",

View File

@ -78,6 +78,8 @@ return [
'facturas' => 'Facturas', 'facturas' => 'Facturas',
'showTotal' => 'Mostrar totales',
'validation' => [ 'validation' => [
], ],

View File

@ -37,6 +37,7 @@ return [
'tarifaExtraSection' => 'Tarifas extra', 'tarifaExtraSection' => 'Tarifas extra',
'proveedoresSection' => 'Proveedores', 'proveedoresSection' => 'Proveedores',
'paisesSection' => 'Países', 'paisesSection' => 'Países',
'formasPagoSection' => 'Formas de Pago',
'maquinasSection' => 'Máquinas', 'maquinasSection' => 'Máquinas',
'maquinasDefectoSection' => 'Máquinas por defecto', 'maquinasDefectoSection' => 'Máquinas por defecto',
'papelGenericoSection' => 'Papel genérico', 'papelGenericoSection' => 'Papel genérico',

View File

@ -257,7 +257,7 @@ class ClienteModel extends \App\Models\BaseModel
LEFT JOIN lg_paises t4 ON t1.pais_id = t4.id LEFT JOIN lg_paises t4 ON t1.pais_id = t4.id
LEFT JOIN users t5 ON t1.comercial_id = t5.id LEFT JOIN users t5 ON t1.comercial_id = t5.id
LEFT JOIN users t6 ON t1.soporte_id = t6.id LEFT JOIN users t6 ON t1.soporte_id = t6.id
LEFT JOIN lg_formas_pago t7 ON t1.forma_pago_id = t7.id"; LEFT JOIN formas_pago t7 ON t1.forma_pago_id = t7.id";
if (!is_null($limit) && intval($limit) > 0) { if (!is_null($limit) && intval($limit) > 0) {
$sql .= " LIMIT " . intval($limit); $sql .= " LIMIT " . intval($limit);
} }
@ -287,7 +287,7 @@ class ClienteModel extends \App\Models\BaseModel
) )
->where("is_deleted", 0);; ->where("is_deleted", 0);;
$builder->join("users t5", "t1.comercial_id = t5.id", "left"); $builder->join("users t5", "t1.comercial_id = t5.id", "left");
$builder->join("lg_formas_pago t7", "t1.forma_pago_id = t7.id", "left"); $builder->join("formas_pago t7", "t1.forma_pago_id = t7.id", "left");
return empty($search) return empty($search)

View File

@ -15,7 +15,7 @@ class Collection
* *
* @return array * @return array
*/ */
public static function datatable(array $data, int $recordsTotal, int $recordsFiltered, string $error = null) public static function datatable(array $data, int $recordsTotal, int $recordsFiltered, string $error = null, $extra_data = [])
{ {
$draw = 1; $draw = 1;
$req = service('request'); $req = service('request');
@ -38,6 +38,10 @@ class Collection
$response['error'] = $error; $response['error'] = $error;
} }
if (count($extra_data)>0) {
$response['extra'] = $extra_data;
}
return $response; return $response;
} }
} }

View File

@ -15,8 +15,6 @@ class FormaPagoModel extends \App\Models\BaseModel
const SORTABLE = [ const SORTABLE = [
1 => "t1.id", 1 => "t1.id",
2 => "t1.nombre", 2 => "t1.nombre",
3 => "t1.created_at",
4 => "t1.updated_at",
]; ];
protected $allowedFields = ["nombre"]; protected $allowedFields = ["nombre"];
@ -26,15 +24,15 @@ class FormaPagoModel extends \App\Models\BaseModel
protected $validationRules = [ protected $validationRules = [
"nombre" => [ "nombre" => [
"label" => "FormasPagoes.nombre", "label" => "FormasPago.nombre",
"rules" => "trim|required|max_length[255]", "rules" => "trim|required|max_length[255]",
], ],
]; ];
protected $validationMessages = [ protected $validationMessages = [
"nombre" => [ "nombre" => [
"max_length" => "FormasPagoes.validation.nombre.max_length", "max_length" => "FormasPago.validation.nombre.max_length",
"required" => "FormasPagoes.validation.nombre.required", "required" => "FormasPago.validation.nombre.required",
], ],
]; ];
@ -61,7 +59,7 @@ class FormaPagoModel extends \App\Models\BaseModel
{ {
$builder = $this->db $builder = $this->db
->table($this->table . " t1") ->table($this->table . " t1")
->select("t1.id AS id, t1.nombre AS nombre, t1.created_at AS created_at, t1.updated_at AS updated_at"); ->select("t1.id AS id, t1.nombre AS nombre");
return empty($search) return empty($search)
? $builder ? $builder
@ -69,12 +67,6 @@ class FormaPagoModel extends \App\Models\BaseModel
->groupStart() ->groupStart()
->like("t1.id", $search) ->like("t1.id", $search)
->orLike("t1.nombre", $search) ->orLike("t1.nombre", $search)
->orLike("t1.created_at", $search)
->orLike("t1.updated_at", $search)
->orLike("t1.id", $search)
->orLike("t1.nombre", $search)
->orLike("t1.created_at", $search)
->orLike("t1.updated_at", $search)
->groupEnd(); ->groupEnd();
} }
} }

View File

@ -40,10 +40,14 @@ class FacturaLineaModel extends \App\Models\BaseModel {
t1.pedido_linea_impresion_id AS pedido_linea_impresion_id, t1.pedido_maquetacion_id AS pedido_maquetacion_id, t1.pedido_linea_impresion_id AS pedido_linea_impresion_id, t1.pedido_maquetacion_id AS pedido_maquetacion_id,
t1.descripcion AS descripcion, t1.cantidad as cantidad, t1.precio_unidad AS precio_unidad, t1.iva AS iva, t1.descripcion AS descripcion, t1.cantidad as cantidad, t1.precio_unidad AS precio_unidad, t1.iva AS iva,
t1.base AS base, t1.total_iva AS total_iva, t1.total AS total, t1.data AS data, t2.pedido_id AS pedido_id, t1.base AS base, t1.total_iva AS total_iva, t1.total AS total, t1.data AS data, t2.pedido_id AS pedido_id,
t3.total_aceptado AS total_aceptado" t3.total_aceptado AS total_aceptado, t4.tirada_flexible AS tirada_flexible, t4.descuento_tirada_flexible AS descuento_tirada_flexible,
t6.cantidad AS cantidad_albaran"
) )
->join("pedidos_linea t2", "t2.id = t1.pedido_linea_impresion_id", "left") ->join("pedidos_linea t2", "t2.id = t1.pedido_linea_impresion_id", "left")
->join("presupuestos t3", "t3.id = t2.presupuesto_id", "left") ->join("presupuestos t3", "t3.id = t2.presupuesto_id", "left")
->join("clientes t4", "t4.id = t3.cliente_id", "left")
->join("albaranes t5", "t5.pedido_id = t2.pedido_id", "left")
->join("albaranes_lineas t6", "t6.albaran_id = t5.id", "left")
->where("t1.factura_id", $factura_id) ->where("t1.factura_id", $factura_id)
->where("t1.deleted_at", null); ->where("t1.deleted_at", null);

View File

@ -14,10 +14,18 @@ class PedidoLineaModel extends \App\Models\BaseModel
protected $useAutoIncrement = true; protected $useAutoIncrement = true;
const SORTABLE = [ const SORTABLE = [
0 => "t1.id", 0 => "t2.id",
1 => "t1.estado", 1 => "t2.updated_at",
2 => "t1.total_precio", 2 => "t2.fecha_entrega_real",
3 => "t1.total_tirada", 3 => "t4.nombre",
4 => "CONCAT(t5.first_name, ' ', t5.last_name)",
5 => "t3.titulo",
6 => "t6.nombre",
7 => "t3.inc_rei",
8 => "t3.paginas",
9 => "t3.tirada",
10 => "t3.total_aceptado",
11 => "t2.estado"
]; ];
protected $allowedFields = [ protected $allowedFields = [
@ -40,7 +48,7 @@ class PedidoLineaModel extends \App\Models\BaseModel
public static $labelField = "id"; public static $labelField = "id";
public function getResource(string $search = "", $estado="") public function getResource($search = [], $estado="")
{ {
$builder = $this->db $builder = $this->db
->table($this->table . " t1") ->table($this->table . " t1")
@ -67,16 +75,112 @@ class PedidoLineaModel extends \App\Models\BaseModel
} }
} }
// Falta implementar la busqueda por grupos if (empty($search))
return empty($search) return $builder;
? $builder else {
: $builder $builder->groupStart();
->groupStart() foreach ($search as $col_search) {
->like("t1.id", $search) if ($col_search[0] != 1 && $col_search[0] != 2)
->orLike("t1.id", $search) $builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
->groupEnd(); else {
$dates = explode(" ", $col_search[2]);
$builder->where(self::SORTABLE[$col_search[0]] . ">=", $dates[0]);
$builder->where(self::SORTABLE[$col_search[0]] . "<=", $dates[1]);
}
}
$builder->groupEnd();
return $builder;
}
} }
public function getSumOfTirada(array $search, $estado = '', $start = 0, $length = 5)
{
$builder = $this->db
->table($this->table . " t1")
->selectSum('t3.tirada', 'total_tirada');
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
// Aplica los filtros de búsqueda y estado
if (!empty($search)) {
$builder->groupStart();
foreach ($search as $col_search) {
if ($col_search[0] != 1 && $col_search[0] != 2)
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
else {
$dates = explode(" ", $col_search[2]);
$builder->where(self::SORTABLE[$col_search[0]] . ">=", $dates[0]);
$builder->where(self::SORTABLE[$col_search[0]] . "<=", $dates[1]);
}
}
$builder->groupEnd();
}
if ($estado !== '') {
$builder->where('estado', $estado);
}
// Aplicar el orden y el límite
$builder->limit($length, $start);
return $builder->get()->getRow()->total_tirada;
}
public function getSumOfTotalAceptado(array $search, $estado = '', $start = 0, $length = 5)
{
$builder = $this->db
->table($this->table . " t1")
->selectSum('t3.total_aceptado', 'total');
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
// Aplica los filtros de búsqueda y estado
if (!empty($search)) {
$builder->groupStart();
foreach ($search as $col_search) {
if ($col_search[0] != 1 && $col_search[0] != 2)
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
else {
$dates = explode(" ", $col_search[2]);
$builder->where(self::SORTABLE[$col_search[0]] . ">=", $dates[0]);
$builder->where(self::SORTABLE[$col_search[0]] . "<=", $dates[1]);
}
}
$builder->groupEnd();
}
if ($estado !== '') {
$builder->where('estado', $estado);
}
// Aplicar el orden y el límite
$builder
->limit($length, $start);
return $builder->get()->getRow()->total;
}
public function getTotalOfTotalAceptado()
{
$builder = $this->db
->table($this->table . " t1")
->selectSum('t3.total_aceptado', 'total');
$builder->join("pedidos t2", "t2.id = t1.pedido_id", "left");
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
return $builder->get()->getRow()->total;
}
public function obtenerLineasPedidoSinFacturar($cliente_id) { public function obtenerLineasPedidoSinFacturar($cliente_id) {
$resultaArray = []; $resultaArray = [];

View File

@ -215,7 +215,7 @@ class PresupuestoModel extends \App\Models\BaseModel
", t2.nombre AS cliente, t3.nombre AS forma_pago, t4.nombre AS tipo_impresion, t5.nombre AS tipologia, t6.nombre AS pais, t7.estado AS estado, t8.id AS papel_formato, t9.first_name AS total_confirmado_user, t10.first_name AS aprobado_user FROM " . ", t2.nombre AS cliente, t3.nombre AS forma_pago, t4.nombre AS tipo_impresion, t5.nombre AS tipologia, t6.nombre AS pais, t7.estado AS estado, t8.id AS papel_formato, t9.first_name AS total_confirmado_user, t10.first_name AS aprobado_user FROM " .
$this->table . $this->table .
" t1 LEFT JOIN clientes " t1 LEFT JOIN clientes
t2 ON t1.cliente_id = t2.id LEFT JOIN lg_formas_pago t2 ON t1.cliente_id = t2.id LEFT JOIN formas_pago
t3 ON t1.forma_pago_id = t3.id LEFT JOIN lg_tipos_impresion t3 ON t1.forma_pago_id = t3.id LEFT JOIN lg_tipos_impresion
t4 ON t1.tipo_impresion_id = t4.id LEFT JOIN lg_tipologias_libros t4 ON t1.tipo_impresion_id = t4.id LEFT JOIN lg_tipologias_libros
t5 ON t1.tipologia_id = t5.id LEFT JOIN lg_paises t5 ON t1.tipologia_id = t5.id LEFT JOIN lg_paises

View File

@ -21,7 +21,7 @@
<th><?= lang('Clientes.cif') ?></th> <th><?= lang('Clientes.cif') ?></th>
<th><?= lang('Clientes.email') ?></th> <th><?= lang('Clientes.email') ?></th>
<th><?= lang('Users.comercial') ?></th> <th><?= lang('Users.comercial') ?></th>
<th><?= lang('FormasPagoes.formaDePago') ?></th> <th><?= lang('FormasPago.formaDePago') ?></th>
<th><?= lang('Clientes.vencimiento') ?></th> <th><?= lang('Clientes.vencimiento') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th> <th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr> </tr>

View File

@ -1,12 +1,11 @@
<div class="row"> <div class="row">
<div class="col-md-12 col-lg-12 px-4"> <div class="col-md-12 col-lg-12 px-4">
<div class="mb-3"> <div class="mb-3">
<label for="nombre" class="form-label"> <label for="nombre" class="form-label">
<?=lang('FormasPagoes.nombre') ?>* <?= lang('FormasPago.nombre') ?>*
</label> </label>
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $formaPagoEntity->nombre) ?>"> <input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control"
</div><!--//.mb-3 --> value="<?= old('nombre', $formaPagoEntity->nombre) ?>">
</div><!--//.mb-3 -->
</div><!--//.col --> </div><!--//.col -->
</div><!-- //.row -->
</div><!-- //.row -->

View File

@ -1,26 +1,45 @@
<?= $this->include("themes_commonPartialsBs/select2bs5") ?> <?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->include("themes_commonPartialsBs/sweetalert") ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?> <?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?> <?= $this->section("content") ?>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card card-info"> <div class="card card-info">
<div class="card-header"> <div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3> <h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header --> </div><!--//.card-header -->
<form id="formaDePagoForm" method="post" action="<?= $formAction ?>"> <form id="formaDePagoForm" class="card-body" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?> <?= csrf_field() ?>
<div class="card-body"> <div class="card-body">
<?= view("themes_commonPartialsBs/_alertBoxes") ?> <?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> <?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/vuexy/form/configuracion/formasPagoViews/_formaDePagoFormItems") ?> <?= view("themes/vuexy/form/configuracion/formas-pago/_formaDePagoFormItems") ?>
</div><!-- /.card-body --> </div><!-- /.card-body -->
<div class="card-footer"> <div class="pt-4">
<?= anchor(route_to("formaDePagoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?> <input type="submit"
<input type="submit" class="btn btn-primary float-end" name="save" value="<?= lang("Basic.global.Save") ?>"> class="btn btn-primary float-start me-sm-3 me-1"
</div><!-- /.card-footer --> name="save"
</form> value="<?= lang("Basic.global.Save") ?>"
</div><!-- //.card --> />
<?= anchor(
route_to("formasPagoList"),
lang("Basic.global.Cancel"),
["class" => "btn btn-secondary float-start",]
) ?>
</div>
</form>
</div><!-- //.card -->
</div><!--//.col --> </div><!--//.col -->
</div><!--//.row --> </div><!--//.row -->
<?= $this->endSection() ?> <?= $this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>"
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
<?= $this->endSection() ?>

View File

@ -1,25 +1,23 @@
<?=$this->include('themes_commonPartialsBs/datatables') ?> <?=$this->include('themes/_commonPartialsBs/datatables') ?>
<?=$this->include('themes_commonPartialsBs/sweetalert') ?> <?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
<?=$this->extend('themes'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?> <?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?=$this->section('content'); ?> <?=$this->section('content'); ?>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="card card-info"> <div class="card card-info">
<div class="card-header"> <div class="card-header">
<h3 class="card-title"><?=lang('FormasPagoes.formaDePagoList') ?></h3> <h3 class="card-title"><?=lang('FormasPago.formaPagoList') ?></h3>
<?=anchor(route_to('formasPagoAdd'), lang('Basic.global.addNew').' '.lang('FormasPago.formaPago'), ['class'=>'btn btn-primary float-end']); ?>
</div><!--//.card-header --> </div><!--//.card-header -->
<div class="card-body"> <div class="card-body">
<?= view('themes_commonPartialsBs/_alertBoxes'); ?> <?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<table id="tableOfFormasdepagos" class="table table-striped table-hover" style="width: 100%;"> <table id="tableOfFormasdepagos" class="table table-striped table-hover" style="width: 100%;">
<thead> <thead>
<tr> <tr>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th> <th><?= lang('FormasPago.nombre') ?></th>
<th><?=lang('FormasPagoes.id')?></th>
<th><?= lang('FormasPagoes.nombre') ?></th>
<th><?= lang('FormasPagoes.createdAt') ?></th>
<th><?= lang('FormasPagoes.updatedAt') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th> <th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr> </tr>
</thead> </thead>
@ -29,7 +27,7 @@
</table> </table>
</div><!--//.card-body --> </div><!--//.card-body -->
<div class="card-footer"> <div class="card-footer">
<?=anchor(route_to('newFormaDePago'), lang('Basic.global.addNew').' '.lang('FormasPagoes.formaDePago'), ['class'=>'btn btn-primary float-end']); ?>
</div><!--//.card-footer --> </div><!--//.card-footer -->
</div><!--//.card --> </div><!--//.card -->
</div><!--//.col --> </div><!--//.col -->
@ -40,125 +38,83 @@
<?=$this->section('additionalInlineJs') ?> <?=$this->section('additionalInlineJs') ?>
const lastColNr = $('#tableOfFormasdepagos').find("tr:first th").length - 1; const lastColNr = $('#tableOfFormasdepagos').find("tr:first th").length - 1;
const actionBtns = function(data) { const actionBtns = function(data) {
return `<td class="text-right py-0 align-middle"> return `<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm"> <div class="btn-group btn-group-sm">
<button class="btn btn-sm btn-warning btn-edit me-1" data-id="${data.id}"><?= lang('Basic.global.edit') ?></button> <a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
<button class="btn btn-sm btn-danger btn-delete ms-1" data-id="${data.id}"><?= lang('Basic.global.Delete') ?></button> <a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
</div> </div>
</td>`; </td>`;
}; };
theTable = $('#tableOfFormasdepagos').DataTable({
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
pageLength: 10,
lengthChange: true,
"dom": 'lfrtipB', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other
// "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above
"buttons": [
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
stateSave: true,
order: [[1, 'asc']],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfFormasDePagos') ?>',
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columnDefs: [
{
orderable: false,
searchable: false,
targets: [0,lastColNr]
}
],
columns : [
{ 'data': actionBtns },
{ 'data': 'id' },
{ 'data': 'nombre' },
{ 'data': 'created_at' },
{ 'data': 'updated_at' },
{ 'data': actionBtns }
]
});
theTable = $('#tableOfFormasdepagos').DataTable({
theTable.on( 'draw.dt', function () { processing: true,
serverSide: true,
const dateCols = [3, 4]; autoWidth: true,
const shortDateFormat = '<?= convertPhpDateToMomentFormat('mm/dd/YYYY')?>'; responsive: true,
const dateTimeFormat = '<?= convertPhpDateToMomentFormat('mm/dd/YYYY h:i a')?>'; scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
for (let coln of dateCols) { pageLength: 10,
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { lengthChange: true,
const datestr = cell.innerHTML; "dom": 'lfBrtip',
const dateStrLen = datestr.toString().trim().length; "buttons": [
if (dateStrLen > 0) { 'copy', 'csv', 'excel', 'print', {
let dateTimeParts= datestr.split(/[- :]/); // regular expression split that creates array with: year, month, day, hour, minutes, seconds values extend: 'pdfHtml5',
dateTimeParts[1]--; // monthIndex begins with 0 for January and ends with 11 for December so we need to decrement by one orientation: 'landscape',
const d = new Date(...dateTimeParts); // new Date(datestr); pageSize: 'A4'
const md = moment(d);
const usingThisFormat = dateStrLen > 11 ? dateTimeFormat : shortDateFormat;
const formattedDateStr = md.format(usingThisFormat);
cell.innerHTML = formattedDateStr;
}
});
} }
}); ],
stateSave: true,
$(document).on('click', '.btn-edit', function(e) { order: [[1, 'asc']],
window.location.href = `<?= route_to('formaDePagoList') ?>/${$(this).attr('data-id')}/edit`; language: {
}); url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
$(document).on('click', '.btn-delete', function(e) { ajax : $.fn.dataTable.pipeline( {
Swal.fire({ url: '<?= route_to('formasPagoDT') ?>',
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('FormasPagoes.forma de pago'))]) ?>', method: 'POST',
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>', headers: {'X-Requested-With': 'XMLHttpRequest'},
icon: 'warning', async: true,
showCancelButton: true, }),
confirmButtonColor: '#3085d6', columnDefs: [
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>', {
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>', orderable: false,
cancelButtonColor: '#d33' searchable: false,
}) targets: [0,lastColNr]
.then((result) => {
const dataId = $(this).data('id');
const row = $(this).closest('tr');
if (result.value) {
$.ajax({
url: `<?= route_to('formaDePagoList') ?>/${dataId}`,
method: 'DELETE',
}).done((data, textStatus, jqXHR) => {
Toast.fire({
icon: 'success',
title: data.msg ?? jqXHR.statusText,
});
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
}).fail((jqXHR, textStatus, errorThrown) => {
Toast.fire({
icon: 'error',
title: jqXHR.responseJSON.messages.error,
});
})
} }
}); ],
columns : [
{ 'data': 'nombre' },
{ 'data': actionBtns }
]
}); });
$(document).on('click', '.btn-edit', function(e) {
window.location.href = `/configuracion/formas-pago/edit/${$(this).attr('data-id')}`;
});
$(document).on('click', '.btn-delete', function(e) {
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
});
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
if ($.isNumeric(dataId)) {
$.ajax({
url: `/configuracion/formas-pago/delete/${dataId}`,
method: 'GET',
}).done((data, textStatus, jqXHR) => {
$('#confirm2delete').modal('toggle');
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
popSuccessAlert(data.msg ?? jqXHR.statusText);
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
})
}
});

View File

@ -6,26 +6,29 @@
<?= $this->section("content") ?> <?= $this->section("content") ?>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card card-info"> <div class="card card-info">
<div class="card-header"> <div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3> <h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header --> </div><!--//.card-header -->
<form id="seriesFacturasForm" class="card-body" method="post" action="<?= $formAction ?>"> <form id="seriesFacturasForm" class="card-body" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?> <?= csrf_field() ?>
<?= view("themes/_commonPartialsBs/_alertBoxes") ?> <?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> <?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/vuexy/form/configuracion/series-facturas/_seriesFacturasFormItems") ?> <?= view("themes/vuexy/form/configuracion/series-facturas/_seriesFacturasFormItems") ?>
<div class="pt-4"> <div class="pt-4">
<input type="submit" <input type="submit"
class="btn btn-primary float-start me-sm-3 me-1" class="btn btn-primary float-start me-sm-3 me-1"
name="save" name="save"
value="<?= lang("Basic.global.Save") ?>" value="<?= lang("Basic.global.Save") ?>"
/> />
<?= anchor(route_to("seriesFacturasList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start",]) ?> <?= anchor(
route_to("seriesFacturasList"),
</div><!-- /.card-footer --> lang("Basic.global.Cancel"),
</form> ["class" => "btn btn-secondary float-start",]
</div><!-- //.card --> ) ?>
</div>
</form>
</div><!-- //.card -->
</div><!--//.col --> </div><!--//.col -->
</div><!--//.row --> </div><!--//.row -->
@ -33,20 +36,22 @@
<?=$this->section('css') ?> <?= $this->section('css') ?>
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>"> <link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>"> <link rel="stylesheet"
<?=$this->endSection() ?> href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
<?= $this->endSection() ?>
<?= $this->section('additionalExternalJs') ?> <?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>"
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script> crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
<?=$this->endSection() ?> <script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -112,7 +112,7 @@
const row = $(this).closest('tr'); const row = $(this).closest('tr');
if ($.isNumeric(dataId)) { if ($.isNumeric(dataId)) {
$.ajax({ $.ajax({
url: `/configuracion/series-facturas//delete/${dataId}`, url: `/configuracion/series-facturas/delete/${dataId}`,
method: 'GET', method: 'GET',
}).done((data, textStatus, jqXHR) => { }).done((data, textStatus, jqXHR) => {
$('#confirm2delete').modal('toggle'); $('#confirm2delete').modal('toggle');

View File

@ -118,11 +118,10 @@ $('#addNewPedidoImpresion').on('click', function(){
yeniden(response.<?= csrf_token() ?>); yeniden(response.<?= csrf_token() ?>);
// se ajustan el ancho de las columnas // se ajustan el ancho de las columnas
$('#tableOfLineasFactura').DataTable().columns.adjust().draw();
$('#pedidoImpresion').val(null).trigger('change'); $('#pedidoImpresion').val(null).trigger('change');
// Se actualiza la tabla de lineas de factura // Se actualiza la tabla de lineas de factura
tableLineas.clearPipeline(); tableLineas.clearPipeline();
tableLineas.draw(); $('#tableOfLineasFactura').DataTable().columns.adjust().draw();
} }
}); });
}); });

View File

@ -255,7 +255,7 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
error_text = 'El total del pedido ('+ total_aceptado + '€) no coincide con la línea ('+ subtotal + '€)'; error_text = 'El total del pedido ('+ total_aceptado + '€) no coincide con la línea ('+ subtotal + '€)';
} }
return ` var returned_data = `
<div> <div>
${data} ${data}
</div> </div>
@ -265,11 +265,55 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
<span style="color: red;" id="error-${meta.row}">${error_text}</span> <span style="color: red;" id="error-${meta.row}">${error_text}</span>
</div> </div>
<div class="mt-2"> <div class="row mt-2">
<label for="input-${meta.row}">Total aceptado</label> <div style="margin-top: auto;" class="col-md-12 col-lg-2 px-4">
<input readonly type="text" id="input-${meta.row}" value="${row.total_aceptado}"> <label for="total-aceptado_-${meta.row}">Total aceptado</label>
</div> <input readonly style="max-width: 110px;" type="text" id="total-aceptado_${meta.row}" value="${row.total_aceptado}">
</div>
`; `;
if (row.tirada_flexible === "1"){
returned_data += `
<div style="margin-top: auto;" class="col-md-12 col-lg-2 px-4">
<label for="descuento-tf_${meta.row}">Descuento tirada flexible</label>
<input readonly style="max-width: 110px;" type="text" id="descuento-tf_${meta.row}" value="${row.descuento_tirada_flexible}">
</div>
<div style="margin-top: auto;" class="col-md-12 col-lg-2 px-4">
<label for="tirada-albaran_${meta.row}">Tirada albarán</label>
<input readonly style="max-width: 110px;" type="text" id="tirada-albaran_${meta.row}" value="${row.cantidad_albaran}">
</div>
`;
if(row.cantidad<row.cantidad_albaran){
returned_data += `
<div style="margin-top: auto;" class="col-md-12 col-lg-2 px-4">
<button
type="button"
class="btn btn-label-primary float-start me-sm-3 me-1 btn-excedentes"
name="btn-excedentes_${meta.row}"
id="btn-excedentes_${meta.row}"
data-row="${meta.row}"
>
<span class="ti-xs ti ti-circle-plus me-1"></span>
Excedentes
</button>
</div>
</div>
`;
}
else{
returned_data += `
</div>
`;
}
}
else{
returned_data += `
</div>
`;
}
return returned_data;
} }
else{ else{
return ` return `
@ -372,7 +416,8 @@ function updateFooterLineas(table){
base: totalSubtotal, base: totalSubtotal,
total: totalTotal, total: totalTotal,
total_pagos: total_pagos, total_pagos: total_pagos,
pendiente: pendientePago pendiente: pendientePago,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
} }
}).done((data, textStatus, jqXHR) => { }).done((data, textStatus, jqXHR) => {
if(data.estado_pago == 'pagada'){ if(data.estado_pago == 'pagada'){
@ -397,12 +442,12 @@ $(document).on('click', '.btn-delete', function(e) {
asyncConfirmDialogWithParams( asyncConfirmDialogWithParams(
"Borrar Linea de Factura", "Borrar Linea de Factura",
"¿Está seguro de borrar la línea? Esta acción no se puede deshacer.", "¿Está seguro de borrar la línea? Esta acción no se puede deshacer.",
deleteConfirmed, function(){}, [dataId, row]) deleteConfirmedLinea, function(){}, [dataId, row])
} }
}); });
function deleteConfirmed(params){ function deleteConfirmedLinea(params){
var factura_linea_id = params[0]; var factura_linea_id = params[0];
var row = params[1]; var row = params[1];
const row_data = tableLineas.row($(row)).data(); const row_data = tableLineas.row($(row)).data();
@ -415,7 +460,8 @@ function deleteConfirmed(params){
data: { data: {
factura_id: <?= $facturaEntity->id ?>, factura_id: <?= $facturaEntity->id ?>,
pedido_linea_impresion_id: row_data.pedido_linea_impresion_id, pedido_linea_impresion_id: row_data.pedido_linea_impresion_id,
cantidad: row_data.cantidad cantidad: row_data.cantidad,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
} }
}).done((data, textStatus, jqXHR) => { }).done((data, textStatus, jqXHR) => {
@ -457,4 +503,47 @@ $('#addLineaFactura').on('click', function() {
}); });
$(document).on('click', '.btn-excedentes', function(e) {
const row = $(this).data('row');
const row_data = tableLineas.row(row).data();
const pedido_id = row_data.pedido_id;
var pedido_linea_impresion_id = null;
var pedido_linea_maquetacion_id = null;
if(row_data.pedido_linea_impresion_id != null){
pedido_linea_impresion_id = row_data.pedido_linea_impresion_id
}
else{
pedido_linea_maquetacion_id = row_data.pedido_maquetacion_id
}
var factura_id = <?= $facturaEntity->id ?>;
var url = '<?= route_to('addLineaExcedentes', ':factura_id') ?>';
url = url.replace(':factura_id', factura_id );
$.ajax({
url: url,
method: 'POST',
data: {
pedido_id: pedido_id,
pedido_linea_impresion_id: pedido_linea_impresion_id,
pedido_linea_maquetacion_id: pedido_linea_maquetacion_id,
precio_unidad: row_data.precio_unidad,
descripcion: row_data.descripcion,
iva: row_data.iva,
descuento: row_data.descuento_tirada_flexible,
cantidad: parseInt(row_data.cantidad_albaran)-parseInt(row_data.cantidad),
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
}
}).done((data, textStatus, jqXHR) => {
$('#tableOfLineasFactura').DataTable().clearPipeline();
$('#tableOfLineasFactura').DataTable().draw();
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
})
});
<?=$this->endSection() ?> <?=$this->endSection() ?>

View File

@ -11,6 +11,14 @@
</div><!--//.card-header --> </div><!--//.card-header -->
<div class="card-body"> <div class="card-body">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?> <?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<div class="row">
<div class="form-check form-check-inline">
<input type="checkbox" class="form-check-input" id="showTotal" name="showTotal">
<label for="showTotal" class="form-check-label">
<?= lang('Pedidos.showTotal') ?>
</label>
</div>
</div>
<table id="tableOfPedidos" class="table table-striped table-hover" style="width: 100%;"> <table id="tableOfPedidos" class="table table-striped table-hover" style="width: 100%;">
<thead> <thead>
@ -23,11 +31,11 @@
<th><?= lang('Pedidos.titulo') ?></th> <th><?= lang('Pedidos.titulo') ?></th>
<th><?= lang('Pedidos.ubicacion') ?></th> <th><?= lang('Pedidos.ubicacion') ?></th>
<th><?= lang('Pedidos.inc_rei') ?></th> <th><?= lang('Pedidos.inc_rei') ?></th>
<th><?= lang('Pedidos.num_paginas') ?></th> <th class='noFilter'><?= lang('Pedidos.num_paginas') ?></th>
<th><?= lang('Pedidos.tiradas') ?></th> <th class='totalizador'><?= lang('Pedidos.tiradas') ?></th>
<th><?= lang('Pedidos.total_presupuesto') ?></th> <th class='totalizador'><?= lang('Pedidos.total_presupuesto') ?></th>
<th><?= lang('Pedidos.estado') ?></th> <th><?= lang('Pedidos.estado') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th> <th class="noFilter text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -57,24 +65,130 @@
</td>`; </td>`;
}; };
theTable = $('#tableOfPedidos').DataTable({ // Setup - add a text input to each footer cell
$('#tableOfPedidos thead tr').clone(true).appendTo('#tableOfPedidos thead');
$('#tableOfPedidos thead tr:eq(1) th').each(function (i) {
if (!$(this).hasClass("noFilter")) {
var title = $(this).text();
if($(this).hasClass("totalizador")){
if(i==9){
$(this).html('<label id="total_tirada" />');
}
else if(i==10){
$(this).html('<label id="total_aceptado" />');
}
}
else{
if(i==1 || i==2){
name = 'bs-rangepicker-range_' + i;
$(this).html('<input id="'+name+'" type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
var bsRangePickerRange = $('#' + name);
bsRangePickerRange.daterangepicker({
ranges: {
'<?= lang('datePicker.hoy') ?>': [moment(), moment()],
'<?= lang('datePicker.ayer') ?>': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'<?= lang('datePicker.ultimos7') ?>': [moment().subtract(6, 'days'), moment()],
'<?= lang('datePicker.ultimos30') ?>': [moment().subtract(29, 'days'), moment()],
'<?= lang('datePicker.esteMes') ?>': [moment().startOf('month'), moment().endOf('month')],
'<?= lang('datePicker.ultimoMes') ?>': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
opens: 'right',
language: '<?= config('Basics')->i18n ?>',
"locale": {
"customRangeLabel": "<?= lang('datePicker.personalizar') ?>",
"format": "YYYY-MM-DD",
"separator": " ",
"applyLabel": "<?= lang('datePicker.aplicar') ?>",
"cancelLabel": "<?= lang('datePicker.limpiar') ?>",
},
"alwaysShowCalendars": true,
autoUpdateInput: false,
});
bsRangePickerRange.on('apply.daterangepicker', function(ev, picker) {
$(this).val(picker.startDate.format('YYYY-MM-DD') + ' ' + picker.endDate.format('YYYY-MM-DD'));
theTable
.column(i)
.search(this.value)
.draw();
});
bsRangePickerRange.on('cancel.daterangepicker', function(ev, picker) {
$(this).val('');
theTable
.column(i)
.search(this.value)
.draw();
});
}
else if (i == 11) {
// Agregar un selector en la tercera columna
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
// Agregar opciones al selector
var selector = $('select', this);
selector.append('<option value="">Todos</option>'); // Opción vacía
selector.append('<option value="validacion"><?= lang('Pedidos.validacion') ?></option>');
selector.append('<option value="produccion"><?= lang('Pedidos.produccion') ?></option>');
selector.append('<option value="finalizado"><?= lang('Pedidos.finalizado') ?></option>');
selector.append('<option value="enviado"><?= lang('Pedidos.enviado') ?></option>');
selector.append('<option value="cancelado"><?= lang('Pedidos.cancelado') ?></option>');
selector.on('change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
theTable.column(i).search(val).draw();
});
}
else{
$(this).html('<input type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
$('input', this).on('change clear', function () {
if (theTable.column(i).search() !== this.value) {
theTable
.column(i)
.search(this.value)
.draw();
}
});
}
}
}
else {
$(this).html('<span></span>');
}
});
var theTable = $('#tableOfPedidos').DataTable({
select: {
style: 'multi',
info: false
},
orderCellsTop: true,
fixedHeader: true,
processing: true, processing: true,
serverSide: true, serverSide: true,
autoWidth: true, autoWidth: true,
responsive: true, responsive: true,
searching: true,
scrollX: true, scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ], lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
pageLength: 50, pageLength: 100,
lengthChange: true, lengthChange: true,
"dom": 'lfBrtip', "dom": '<"mb-3"l>Brtip',
"buttons": [ "buttons": [
'copy', 'csv', 'excel', 'print', { 'colvis', 'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5', extend: 'pdfHtml5',
orientation: 'landscape', orientation: 'landscape',
pageSize: 'A4' pageSize: 'A4'
} }
], ],
stateSave: true, stateSave: false,
order: [[0, 'asc']], order: [[0, 'asc']],
language: { language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
@ -82,8 +196,9 @@
ajax : $.fn.dataTable.pipeline( { ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfPedidos') ?>', url: '<?= route_to('dataTableOfPedidos') ?>',
method: 'POST', method: 'POST',
data: { data: function(d, settings){
estado: "<?= $estadoPedidos ?>", d.estado= "<?= $estadoPedidos ?>";
d.showTotal= $('#showTotal').is(':checked')? "1":"0";
}, },
headers: {'X-Requested-With': 'XMLHttpRequest'}, headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true, async: true,
@ -91,7 +206,7 @@
columnDefs: [ columnDefs: [
{ {
orderable: false, orderable: false,
searchable: false, searchable: true,
targets: [lastColNr] targets: [lastColNr]
} }
], ],
@ -138,39 +253,76 @@
} }
}, },
{ 'data': actionBtns } { 'data': actionBtns }
] ],
drawCallback: function (settings) {
$('#total_tirada').text(settings.json.extra.total_tirada);
$('#total_aceptado').text(settings.json.extra.total);
}
}); });
theTable.on( 'draw.dt', function () { theTable.on( 'draw.dt', function () {
const boolCols = []; const dateCols = [1,2];
for (let coln of boolCols) { const priceCols = [10];
for (let coln of dateCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) { theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : ''; const datestr = cell.innerHTML;
const dateStrLen = datestr.toString().trim().length;
if (dateStrLen > 0) {
let dateTimeParts= datestr.split(/[- :]/); // regular expression split that creates array with: year, month, day, hour, minutes, seconds values
dateTimeParts[1]--; // monthIndex begins with 0 for January and ends with 11 for December so we need to decrement by one
const d = new Date(...dateTimeParts); // new Date(datestr);
cell.innerHTML = d.toLocaleDateString();
}
});
}
for (let coln of priceCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
cell.innerHTML = parseFloat(cell.innerHTML).toFixed(2);
}); });
} }
}); });
$(document).on('click', '.btn-edit', function(e) { $(document).on('click', '.btn-edit', function(e) {
var url = '<?= route_to('editarPedido', ':id') ?>'; var url = '<?= route_to('editarPedido', ':id') ?>';
url = url.replace(':id', `${$(this).attr('data-id')}` ); url = url.replace(':id', `${$(this).attr('data-id')}` );
window.location.href = url; window.location.href = url;
}); });
theTable.on('click', 'tbody tr', function (e) {
e.currentTarget.classList.toggle('selected');
});
$('#showTotal').on('change', function() {
theTable.clearPipeline();
theTable.ajax.reload(null, false);
//theTable.draw();
});
<?=$this->endSection() ?> <?=$this->endSection() ?>
<?=$this->section('css') ?> <?=$this->section('css') ?>
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>"> <link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/fixedheader/fixedHeader.dataTables.min.css") ?>">
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/bootstrap-daterangepicker/bootstrap-daterangepicker.css') ?>" />
<?=$this->endSection() ?> <?=$this->endSection() ?>
<?= $this->section('additionalExternalJs') ?> <?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/select/dataTables.select.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.colVis.min.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/moment/moment.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/bootstrap-daterangepicker/bootstrap-daterangepicker.js') ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script> <script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>

View File

@ -4,6 +4,7 @@
*/ */
if ( if (
auth()->user()->can('paises.menu') || auth()->user()->can('paises.menu') ||
auth()->user()->can('formas-pago.menu') ||
auth()->user()->can('papel-genericosk .menu') || auth()->user()->can('papel-genericosk .menu') ||
auth()->user()->can('papel-impresion.menu') || auth()->user()->can('papel-impresion.menu') ||
auth()->user()->can('maquinas.menu') || auth()->user()->can('maquinas.menu') ||
@ -11,7 +12,7 @@ if (
auth()->user()->can('usuarios.menu') || auth()->user()->can('usuarios.menu') ||
auth()->user()->can('roles-permisos.menu') auth()->user()->can('roles-permisos.menu')
) { ) {
?> ?>
<li class="menu-item"> <li class="menu-item">
<a href="javascript:void(0);" class="menu-link menu-toggle"> <a href="javascript:void(0);" class="menu-link menu-toggle">
<i class="menu-icon tf-icons ti ti-adjustments-horizontal"></i> <i class="menu-icon tf-icons ti ti-adjustments-horizontal"></i>
@ -25,6 +26,13 @@ if (
</a> </a>
</li> </li>
<?php } ?> <?php } ?>
<?php if (auth()->user()->can('formas-pago.menu')) { ?>
<li class="menu-item">
<a href="<?= route_to('formasPagoList') ?>" class="menu-link">
<?= lang("App.menu_formas_pago") ?>
</a>
</li>
<?php } ?>
<?php if (auth()->user()->can('papel-generico.menu')) { ?> <?php if (auth()->user()->can('papel-generico.menu')) { ?>
<li class="menu-item"> <li class="menu-item">
<a href="<?= site_url("configuracion/papelesgenericos") ?>" class="menu-link"> <a href="<?= site_url("configuracion/papelesgenericos") ?>" class="menu-link">
@ -40,32 +48,32 @@ if (
</li> </li>
<?php } ?> <?php } ?>
<?php if (auth()->user()->can('maquinas.menu')) { ?> <?php if (auth()->user()->can('maquinas.menu')) { ?>
<li class="menu-item"> <li class="menu-item">
<a href="<?= site_url("configuracion/maquinas") ?>" class="menu-link"> <a href="<?= site_url("configuracion/maquinas") ?>" class="menu-link">
<?= lang("App.menu_maquina") ?> <?= lang("App.menu_maquina") ?>
</a> </a>
</li> </li>
<?php } ?> <?php } ?>
<?php if (auth()->user()->can('maquinas-defecto.menu')) { ?> <?php if (auth()->user()->can('maquinas-defecto.menu')) { ?>
<li class="menu-item"> <li class="menu-item">
<a href="<?= site_url("configuracion/maquinasdefecto") ?>" class="menu-link"> <a href="<?= site_url("configuracion/maquinasdefecto") ?>" class="menu-link">
<?= lang("App.menu_maquina_defecto") ?> <?= lang("App.menu_maquina_defecto") ?>
</a> </a>
</li> </li>
<?php } ?> <?php } ?>
<?php if (auth()->user()->can('usuarios.menu')) { ?> <?php if (auth()->user()->can('usuarios.menu')) { ?>
<li class="menu-item"> <li class="menu-item">
<a href="<?= site_url("configuracion/users") ?>" class="menu-link"> <a href="<?= site_url("configuracion/users") ?>" class="menu-link">
<?= lang("App.menu_users") ?> <?= lang("App.menu_users") ?>
</a> </a>
</li> </li>
<?php } ?> <?php } ?>
<?php if (auth()->user()->can('roles-permisos.menu')) { ?> <?php if (auth()->user()->can('roles-permisos.menu')) { ?>
<li class="menu-item"> <li class="menu-item">
<a href="<?= site_url("configuracion/group") ?>" class="menu-link"> <a href="<?= site_url("configuracion/group") ?>" class="menu-link">
<?= lang("App.menu_permission_group") ?> <?= lang("App.menu_permission_group") ?>
</a> </a>
</li> </li>
<?php } ?> <?php } ?>
<?php if (auth()->user()->can('ubicaciones.menu')) { ?> <?php if (auth()->user()->can('ubicaciones.menu')) { ?>
<li class="menu-item"> <li class="menu-item">