diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 8a97a21c..e204ca63 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -70,7 +70,6 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion'] /* Series Factura */ $routes->group('series-facturas', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) { - $routes->get('', 'SeriesFacturas::index', ['as' => 'seriesFacturasList']); $routes->match(['get', 'post'], 'add', 'SeriesFacturas::add', ['as' => 'seriesFacturasAdd']); $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']); }); + /* 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('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('addExcedentes/(:any)', 'Facturas::addExcedentes/$1', ['as' => 'addLineaExcedentes']); $routes->get('deleteLinea/(:any)', 'FacturasLineas::deleteLinea/$1', ['as' => 'deleteLineaFactura']); $routes->get('delete/(:any)', 'Facturas::delete/$1', ['as' => 'borrarFactura']); $routes->post('deleteFacturaLineaPedido', 'Facturas::deleteLineaPedidoImpresion', ['as' => 'deleteLineaPedidoImpresion']); diff --git a/ci4/app/Controllers/Clientes/Cliente.php b/ci4/app/Controllers/Clientes/Cliente.php index 2f7faefa..678532c9 100755 --- a/ci4/app/Controllers/Clientes/Cliente.php +++ b/ci4/app/Controllers/Clientes/Cliente.php @@ -395,7 +395,7 @@ class Cliente extends \App\Controllers\BaseResourceController 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)) : $formaPagoModel = model('App\Models\Configuracion\FormaPagoModel'); diff --git a/ci4/app/Controllers/Configuracion/Formaspagos.php b/ci4/app/Controllers/Configuracion/FormasPago.php old mode 100755 new mode 100644 similarity index 87% rename from ci4/app/Controllers/Configuracion/Formaspagos.php rename to ci4/app/Controllers/Configuracion/FormasPago.php index ef027110..a2867c59 --- a/ci4/app/Controllers/Configuracion/Formaspagos.php +++ b/ci4/app/Controllers/Configuracion/FormasPago.php @@ -9,7 +9,7 @@ use App\Entities\Configuracion\FormaPagoEntity; use App\Models\Configuracion\FormaPagoModel; -class Formaspagos extends \App\Controllers\BaseResourceController +class FormasPago extends \App\Controllers\BaseResourceController { protected $modelName = FormaPagoModel::class; @@ -22,15 +22,22 @@ class Formaspagos extends \App\Controllers\BaseResourceController 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'; 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; + + // 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); } @@ -40,7 +47,7 @@ class Formaspagos extends \App\Controllers\BaseResourceController $viewData = [ 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('FormasPagoes.formaDePago')]), + 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('FormasPago.formaDePago')]), 'formaPagoEntity' => new FormaPagoEntity(), 'usingServerSideDataTable' => true, @@ -55,22 +62,15 @@ class Formaspagos extends \App\Controllers\BaseResourceController public function add() { - - - if ($this->request->getPost()) : - $nullIfEmpty = true; // !(phpversion() >= '8.1'); - $postData = $this->request->getPost(); - $sanitizedData = $this->sanitized($postData, $nullIfEmpty); - + $sanitizedData = $this->sanitized($postData, true); $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : try { $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); @@ -93,7 +93,8 @@ class Formaspagos extends \App\Controllers\BaseResourceController if ($thenRedirect) : 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: return $this->redirect2listView('sweet-success', $message); endif; @@ -106,11 +107,8 @@ class Formaspagos extends \App\Controllers\BaseResourceController endif; // ($requestMethod === 'post') $this->viewData['formaPagoEntity'] = isset($sanitizedData) ? new FormaPagoEntity($sanitizedData) : new FormaPagoEntity(); - - $this->viewData['formAction'] = route_to('createFormaDePago'); - - $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('FormasPagoes.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); - + $this->viewData['formAction'] = route_to('formasPagoAdd'); + $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('FormasPago.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); return $this->displayForm(__METHOD__); } // end function add() @@ -125,25 +123,18 @@ class Formaspagos extends \App\Controllers\BaseResourceController $formaPagoEntity = $this->model->find($id); 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); endif; - - if ($this->request->getPost()) : - $nullIfEmpty = true; // !(phpversion() >= '8.1'); - $postData = $this->request->getPost(); - - $sanitizedData = $this->sanitized($postData, $nullIfEmpty); - + $sanitizedData = $this->sanitized($postData, true); $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : - if ($this->canValidate()) : try { $successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData); @@ -152,13 +143,12 @@ class Formaspagos extends \App\Controllers\BaseResourceController $this->dealWithException($e); } 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()); endif; $formaPagoEntity->fill($sanitizedData); - $thenRedirect = false; endif; if ($noException && $successfulResult) : @@ -179,11 +169,8 @@ class Formaspagos extends \App\Controllers\BaseResourceController endif; // ($requestMethod === 'post') $this->viewData['formaPagoEntity'] = $formaPagoEntity; - - $this->viewData['formAction'] = route_to('updateFormaDePago', $id); - - $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('FormasPagoes.moduleTitle') . ' ' . lang('Basic.global.edit3'); - + $this->viewData['formAction'] = route_to('formasPagoEdit', $id); + $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('FormasPago.moduleTitle') . ' ' . lang('Basic.global.edit3'); return $this->displayForm(__METHOD__, $id); } // end function edit(...) diff --git a/ci4/app/Controllers/Configuracion/SeriesFacturas.php b/ci4/app/Controllers/Configuracion/SeriesFacturas.php index 6dd1a0dc..f7618629 100644 --- a/ci4/app/Controllers/Configuracion/SeriesFacturas.php +++ b/ci4/app/Controllers/Configuracion/SeriesFacturas.php @@ -66,7 +66,6 @@ class SeriesFacturas extends BaseResourceController $noException = true; if ($successfulResult = $this->canValidate()) : - if ($this->canValidate()) : try { $successfulResult = $this->model->skipValidation(true)->save($sanitizedData); @@ -105,7 +104,6 @@ class SeriesFacturas extends BaseResourceController $this->viewData['formAction'] = route_to('seriesFacturasAdd'); $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('SeriesFacturas.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); - return $this->displayForm(__METHOD__); } // end function add() @@ -126,7 +124,6 @@ class SeriesFacturas extends BaseResourceController if ($this->request->getPost()) : $postData = $this->request->getPost(); - $sanitizedData = $this->sanitized($postData, true); if ($this->request->getPost('show_erp') == null) { $sanitizedData['show_erp'] = false; diff --git a/ci4/app/Controllers/Facturacion/Facturas.php b/ci4/app/Controllers/Facturacion/Facturas.php index abf1db51..d21c2bf2 100755 --- a/ci4/app/Controllers/Facturacion/Facturas.php +++ b/ci4/app/Controllers/Facturacion/Facturas.php @@ -392,13 +392,16 @@ class Facturas extends \App\Controllers\BaseResourceController $postData = $this->request->getPost(); + $pendiente = $postData['pendiente'] ?? 0; + $total = $postData['total'] ?? 0; + $data = [ 'base' => $postData['base'] ?? 0, - 'total' => $postData['total'] ?? 0, - 'pendiente' => $postData['pendiente'] ?? 0, + 'total' => $total, + 'pendiente' => $pendiente, 'total_pagos' => $postData['total_pagos'] ?? 0, '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(); @@ -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){ @@ -433,48 +484,55 @@ class Facturas extends \App\Controllers\BaseResourceController try{ $pedido_linea_id = $this->request->getPost('lineaPedido') ?? 0; $linea = $model_pedido_linea->find($pedido_linea_id); + + $factura = $this->model->find($factura_id); - if($linea){ - $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; + if($factura){ - $data = (object)[ - '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, - ]; + if($linea){ + $presupuesto = $model_presupuesto->find($linea->presupuesto_id); - $model_factura_linea->insert($data); + 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; - $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 + $data = (object)[ + '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, ]; - 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); + } } } } diff --git a/ci4/app/Controllers/Pedidos/Pedido.php b/ci4/app/Controllers/Pedidos/Pedido.php index bc8254dd..647ff134 100755 --- a/ci4/app/Controllers/Pedidos/Pedido.php +++ b/ci4/app/Controllers/Pedidos/Pedido.php @@ -245,13 +245,31 @@ class Pedido extends \App\Controllers\BaseResourceController $estado = $reqData['estado'] ?? 'todos'; if($estado == 'todos') $estado = ''; - $model_linea = model('\App\Models\Pedidos\PedidoLineaModel'); - $resourceData = $model_linea->getResource($search, $estado)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject(); + $showTotal = $reqData['showTotal'] ?? false; + $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( $resourceData, $model_linea->getResource("", $estado)->countAllResults(), - $model_linea->getResource($search, $estado)->countAllResults() + $model_linea->getResource($searchValues, $estado)->countAllResults(), + "", + [ + 'total_tirada' => $totalTirada, + 'total' => $total + ] )); } else { return $this->failUnauthorized('Invalid request', 403); diff --git a/ci4/app/Controllers/Presupuestos/Buscador.php b/ci4/app/Controllers/Presupuestos/Buscador.php index 30b7b53e..edfe067d 100644 --- a/ci4/app/Controllers/Presupuestos/Buscador.php +++ b/ci4/app/Controllers/Presupuestos/Buscador.php @@ -111,7 +111,7 @@ class Buscador extends \App\Controllers\BaseResourceController return $this->respond(Collection::datatable( $resourceData, $this->model->getResource("")->countAllResults(), - $this->model->getResource($search)->countAllResults() + $this->model->getResource($searchValues)->countAllResults() )); } else { return $this->failUnauthorized('Invalid request', 403); diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php index aa2cdbdf..03ff9410 100755 --- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php +++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php @@ -1073,14 +1073,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController try { $return_data = []; - if ($extra_info) { - $info = [ - 'merma' => 0, - 'lomo_cubierta' => 0.0, - 'lomo_sobrecubierta' => 0.0, - 'user_id' => auth()->user()->id, - ]; - } + $info = [ + 'merma' => 0, + 'lomo_cubierta' => 0.0, + 'lomo_sobrecubierta' => 0.0, + 'user_id' => auth()->user()->id, + ]; $tirada = $datos_entrada['tirada']; $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) { - $info['lomo_cubierta'] = $lomo; - $info['lomo_sobrecubierta'] = $lomo_sobrecubierta; - $return_data['info'] = $info; $return_data['info']['interior'] = $interior; $return_data['info']['cubierta'] = $cubierta; $return_data['info']['sobrecubierta'] = $linea_sobrecubierta; diff --git a/ci4/app/Language/en/App.php b/ci4/app/Language/en/App.php index 8a54743e..be8505b2 100755 --- a/ci4/app/Language/en/App.php +++ b/ci4/app/Language/en/App.php @@ -679,7 +679,7 @@ return [ "menu_calendario" => "Calendar", "menu_paises" => "Countries", "menu_correo" => "Mail", - "menu_formaspago" => "Payment methods", + "menu_formas_pago" => "Payment methods", "menu_imposiciones" => "Impositions", "menu_maquina" => "Machines", "menu_papelgenerico" => "Generic paper", diff --git a/ci4/app/Language/en/FormasPagoes.php b/ci4/app/Language/en/FormasPago.php old mode 100755 new mode 100644 similarity index 95% rename from ci4/app/Language/en/FormasPagoes.php rename to ci4/app/Language/en/FormasPago.php index 7e7e55cf..a2d39cc3 --- a/ci4/app/Language/en/FormasPagoes.php +++ b/ci4/app/Language/en/FormasPago.php @@ -11,7 +11,6 @@ return [ 'formasDePagos' => 'Formas de Pagos', 'formasPago' => 'Formas Pago', 'formasPagoList' => 'Formas Pago List', - 'formasPagoes' => 'Formas Pagoes', 'id' => 'ID', 'moduleTitle' => 'Formas Pagoes', 'nombre' => 'Nombre', diff --git a/ci4/app/Language/en/Pedidos.php b/ci4/app/Language/en/Pedidos.php index 69a30669..553a35c8 100644 --- a/ci4/app/Language/en/Pedidos.php +++ b/ci4/app/Language/en/Pedidos.php @@ -78,6 +78,8 @@ return [ 'facturas' => 'Invoices', + 'showTotal' => 'Show totals', + 'validation' => [ ], diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index e03fa10d..fbfc1cd4 100755 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -682,7 +682,7 @@ return [ "menu_calendario" => "Calendario", "menu_paises" => "Paises", "menu_correo" => "Correo", - "menu_formaspago" => "Metodos de pago", + "menu_formas_pago" => "Formas de pago", "menu_imposiciones" => "Imposiciones", "menu_maquina" => "Maquinas", "menu_maquina_defecto" => "Maquinas por defecto", diff --git a/ci4/app/Language/es/Pedidos.php b/ci4/app/Language/es/Pedidos.php index f8556058..25de0a9c 100644 --- a/ci4/app/Language/es/Pedidos.php +++ b/ci4/app/Language/es/Pedidos.php @@ -78,6 +78,8 @@ return [ 'facturas' => 'Facturas', + 'showTotal' => 'Mostrar totales', + 'validation' => [ ], diff --git a/ci4/app/Language/es/RolesPermisos.php b/ci4/app/Language/es/RolesPermisos.php index d09ccf35..6c631c16 100644 --- a/ci4/app/Language/es/RolesPermisos.php +++ b/ci4/app/Language/es/RolesPermisos.php @@ -37,6 +37,7 @@ return [ 'tarifaExtraSection' => 'Tarifas extra', 'proveedoresSection' => 'Proveedores', 'paisesSection' => 'Países', + 'formasPagoSection' => 'Formas de Pago', 'maquinasSection' => 'Máquinas', 'maquinasDefectoSection' => 'Máquinas por defecto', 'papelGenericoSection' => 'Papel genérico', diff --git a/ci4/app/Models/Clientes/ClienteModel.php b/ci4/app/Models/Clientes/ClienteModel.php index 741a736a..85df9782 100755 --- a/ci4/app/Models/Clientes/ClienteModel.php +++ b/ci4/app/Models/Clientes/ClienteModel.php @@ -257,7 +257,7 @@ class ClienteModel extends \App\Models\BaseModel LEFT JOIN lg_paises t4 ON t1.pais_id = t4.id LEFT JOIN users t5 ON t1.comercial_id = t5.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) { $sql .= " LIMIT " . intval($limit); } @@ -287,7 +287,7 @@ class ClienteModel extends \App\Models\BaseModel ) ->where("is_deleted", 0);; $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) diff --git a/ci4/app/Models/Collection.php b/ci4/app/Models/Collection.php index 773ae680..af469083 100755 --- a/ci4/app/Models/Collection.php +++ b/ci4/app/Models/Collection.php @@ -15,7 +15,7 @@ class Collection * * @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; $req = service('request'); @@ -38,6 +38,10 @@ class Collection $response['error'] = $error; } + if (count($extra_data)>0) { + $response['extra'] = $extra_data; + } + return $response; } } \ No newline at end of file diff --git a/ci4/app/Models/Configuracion/FormaPagoModel.php b/ci4/app/Models/Configuracion/FormaPagoModel.php index d22a1bd5..2a7374bb 100755 --- a/ci4/app/Models/Configuracion/FormaPagoModel.php +++ b/ci4/app/Models/Configuracion/FormaPagoModel.php @@ -15,8 +15,6 @@ class FormaPagoModel extends \App\Models\BaseModel const SORTABLE = [ 1 => "t1.id", 2 => "t1.nombre", - 3 => "t1.created_at", - 4 => "t1.updated_at", ]; protected $allowedFields = ["nombre"]; @@ -26,15 +24,15 @@ class FormaPagoModel extends \App\Models\BaseModel protected $validationRules = [ "nombre" => [ - "label" => "FormasPagoes.nombre", + "label" => "FormasPago.nombre", "rules" => "trim|required|max_length[255]", ], ]; protected $validationMessages = [ "nombre" => [ - "max_length" => "FormasPagoes.validation.nombre.max_length", - "required" => "FormasPagoes.validation.nombre.required", + "max_length" => "FormasPago.validation.nombre.max_length", + "required" => "FormasPago.validation.nombre.required", ], ]; @@ -61,7 +59,7 @@ class FormaPagoModel extends \App\Models\BaseModel { $builder = $this->db ->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) ? $builder @@ -69,12 +67,6 @@ class FormaPagoModel extends \App\Models\BaseModel ->groupStart() ->like("t1.id", $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(); } } diff --git a/ci4/app/Models/Facturas/FacturaLineaModel.php b/ci4/app/Models/Facturas/FacturaLineaModel.php index 757f4bad..b808ac8c 100644 --- a/ci4/app/Models/Facturas/FacturaLineaModel.php +++ b/ci4/app/Models/Facturas/FacturaLineaModel.php @@ -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.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, - 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("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.deleted_at", null); diff --git a/ci4/app/Models/Pedidos/PedidoLineaModel.php b/ci4/app/Models/Pedidos/PedidoLineaModel.php index d7eb4699..52284cb4 100644 --- a/ci4/app/Models/Pedidos/PedidoLineaModel.php +++ b/ci4/app/Models/Pedidos/PedidoLineaModel.php @@ -14,12 +14,20 @@ class PedidoLineaModel extends \App\Models\BaseModel protected $useAutoIncrement = true; const SORTABLE = [ - 0 => "t1.id", - 1 => "t1.estado", - 2 => "t1.total_precio", - 3 => "t1.total_tirada", + 0 => "t2.id", + 1 => "t2.updated_at", + 2 => "t2.fecha_entrega_real", + 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 = [ "pedido_id", "presupuesto_id", @@ -40,7 +48,7 @@ class PedidoLineaModel extends \App\Models\BaseModel public static $labelField = "id"; - public function getResource(string $search = "", $estado="") + public function getResource($search = [], $estado="") { $builder = $this->db ->table($this->table . " t1") @@ -67,16 +75,112 @@ class PedidoLineaModel extends \App\Models\BaseModel } } - // Falta implementar la busqueda por grupos - return empty($search) - ? $builder - : $builder - ->groupStart() - ->like("t1.id", $search) - ->orLike("t1.id", $search) - ->groupEnd(); + if (empty($search)) + return $builder; + else { + $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(); + 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) { $resultaArray = []; diff --git a/ci4/app/Models/Presupuestos/PresupuestoModel.php b/ci4/app/Models/Presupuestos/PresupuestoModel.php index dc8c3ad3..424ba107 100755 --- a/ci4/app/Models/Presupuestos/PresupuestoModel.php +++ b/ci4/app/Models/Presupuestos/PresupuestoModel.php @@ -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 " . $this->table . " 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 t4 ON t1.tipo_impresion_id = t4.id LEFT JOIN lg_tipologias_libros t5 ON t1.tipologia_id = t5.id LEFT JOIN lg_paises diff --git a/ci4/app/Views/themes/vuexy/form/clientes/cliente/viewClienteList.php b/ci4/app/Views/themes/vuexy/form/clientes/cliente/viewClienteList.php index ecb9a1e5..f2448cbc 100644 --- a/ci4/app/Views/themes/vuexy/form/clientes/cliente/viewClienteList.php +++ b/ci4/app/Views/themes/vuexy/form/clientes/cliente/viewClienteList.php @@ -21,7 +21,7 @@ - + diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/formas-pago/_formaDePagoFormItems.php b/ci4/app/Views/themes/vuexy/form/configuracion/formas-pago/_formaDePagoFormItems.php index 27eed497..9d218e2d 100644 --- a/ci4/app/Views/themes/vuexy/form/configuracion/formas-pago/_formaDePagoFormItems.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/formas-pago/_formaDePagoFormItems.php @@ -1,12 +1,11 @@ -
-
-
- - -
- -
- -
\ No newline at end of file +
+
+
+ + +
+
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/formas-pago/viewFormaDePagoForm.php b/ci4/app/Views/themes/vuexy/form/configuracion/formas-pago/viewFormaDePagoForm.php index c91e868e..965dd75f 100644 --- a/ci4/app/Views/themes/vuexy/form/configuracion/formas-pago/viewFormaDePagoForm.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/formas-pago/viewFormaDePagoForm.php @@ -1,26 +1,45 @@ -include("themes_commonPartialsBs/select2bs5") ?> -include("themes_commonPartialsBs/sweetalert") ?> +include("themes/_commonPartialsBs/sweetalert") ?> extend('themes/vuexy/main/defaultlayout') ?> section("content") ?>
-
-
-

-
-
- -
- - getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> - -
- -
-
+
+
+

+
+
+ +
+ + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+
+ " + /> + "btn btn-secondary float-start",] + ) ?> +
+
+
endSection() ?> + + +section('additionalExternalJs') ?> + + + + + + + +endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/formas-pago/viewFormaDePagoList.php b/ci4/app/Views/themes/vuexy/form/configuracion/formas-pago/viewFormaDePagoList.php index c2124231..912b0085 100644 --- a/ci4/app/Views/themes/vuexy/form/configuracion/formas-pago/viewFormaDePagoList.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/formas-pago/viewFormaDePagoList.php @@ -1,25 +1,23 @@ -include('themes_commonPartialsBs/datatables') ?> -include('themes_commonPartialsBs/sweetalert') ?> -extend('themes'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/sweetalert') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/vuexy/main/defaultlayout') ?> section('content'); ?>
-

+

+ 'btn btn-primary float-end']); ?>
- + - - - - - + @@ -29,7 +27,7 @@
@@ -40,125 +38,83 @@ section('additionalInlineJs') ?> - const lastColNr = $('#tableOfFormasdepagos').find("tr:first th").length - 1; - const actionBtns = function(data) { - return ` -
- - -
- `; - }; - 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: '', - 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 } - ] - }); + const lastColNr = $('#tableOfFormasdepagos').find("tr:first th").length - 1; + const actionBtns = function(data) { + return ` +
+ + +
+ `; + }; - - theTable.on( 'draw.dt', function () { - - const dateCols = [3, 4]; - const shortDateFormat = ''; - const dateTimeFormat = ''; - - for (let coln of dateCols) { - theTable.column(coln, { page: 'current' }).nodes().each( function (cell, 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); - const md = moment(d); - const usingThisFormat = dateStrLen > 11 ? dateTimeFormat : shortDateFormat; - const formattedDateStr = md.format(usingThisFormat); - cell.innerHTML = formattedDateStr; - } - }); + 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": 'lfBrtip', + "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: '', + method: 'POST', + headers: {'X-Requested-With': 'XMLHttpRequest'}, + async: true, + }), + columnDefs: [ + { + orderable: false, + searchable: false, + targets: [0,lastColNr] + } + ], + columns : [ + { 'data': 'nombre' }, + { 'data': actionBtns } + ] }); -$(document).on('click', '.btn-edit', function(e) { - window.location.href = `/${$(this).attr('data-id')}/edit`; + $(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) { - Swal.fire({ - title: '', - text: '', - icon: 'warning', - showCancelButton: true, - confirmButtonColor: '#3085d6', - confirmButtonText: '', - cancelButtonText: '', - cancelButtonColor: '#d33' - }) - .then((result) => { - const dataId = $(this).data('id'); - const row = $(this).closest('tr'); - if (result.value) { - $.ajax({ - url: `/${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, - }); - }) - } - }); + + + $(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) + }) + } }); - diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/series-facturas/viewSeriesFacturasForm.php b/ci4/app/Views/themes/vuexy/form/configuracion/series-facturas/viewSeriesFacturasForm.php index cd4eaf81..fe46f704 100644 --- a/ci4/app/Views/themes/vuexy/form/configuracion/series-facturas/viewSeriesFacturasForm.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/series-facturas/viewSeriesFacturasForm.php @@ -6,26 +6,29 @@ section("content") ?>
-
-
-

-
-
- - - getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> - -
- " - /> - "btn btn-secondary float-start",]) ?> - -
-
-
+
+
+

+
+
+ + + getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> + +
+ " + /> + "btn btn-secondary float-start",] + ) ?> +
+
+
@@ -33,20 +36,22 @@ -section('css') ?> - - "> -endSection() ?> +section('css') ?> + +"> +endSection() ?> section('additionalExternalJs') ?> - - - - - - - - -endSection() ?> + + + + + + + + +endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/series-facturas/viewSeriesFacturasList.php b/ci4/app/Views/themes/vuexy/form/configuracion/series-facturas/viewSeriesFacturasList.php index 85ca4f23..1ffca01a 100644 --- a/ci4/app/Views/themes/vuexy/form/configuracion/series-facturas/viewSeriesFacturasList.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/series-facturas/viewSeriesFacturasList.php @@ -112,7 +112,7 @@ const row = $(this).closest('tr'); if ($.isNumeric(dataId)) { $.ajax({ - url: `/configuracion/series-facturas//delete/${dataId}`, + url: `/configuracion/series-facturas/delete/${dataId}`, method: 'GET', }).done((data, textStatus, jqXHR) => { $('#confirm2delete').modal('toggle'); diff --git a/ci4/app/Views/themes/vuexy/form/facturas/_addPedidosItems.php b/ci4/app/Views/themes/vuexy/form/facturas/_addPedidosItems.php index 1b616980..453074b7 100644 --- a/ci4/app/Views/themes/vuexy/form/facturas/_addPedidosItems.php +++ b/ci4/app/Views/themes/vuexy/form/facturas/_addPedidosItems.php @@ -118,11 +118,10 @@ $('#addNewPedidoImpresion').on('click', function(){ yeniden(response.); // se ajustan el ancho de las columnas - $('#tableOfLineasFactura').DataTable().columns.adjust().draw(); $('#pedidoImpresion').val(null).trigger('change'); // Se actualiza la tabla de lineas de factura tableLineas.clearPipeline(); - tableLineas.draw(); + $('#tableOfLineasFactura').DataTable().columns.adjust().draw(); } }); }); diff --git a/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php b/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php index 2a4142f8..1c8dcbaf 100644 --- a/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php +++ b/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php @@ -255,7 +255,7 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({ error_text = 'El total del pedido ('+ total_aceptado + '€) no coincide con la línea ('+ subtotal + '€)'; } - return ` + var returned_data = `
${data}
@@ -265,11 +265,55 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({ ${error_text}
-
- - -
+
+
+ + +
`; + + if (row.tirada_flexible === "1"){ + returned_data += ` +
+ + +
+
+ + +
+ `; + if(row.cantidad + +
+ + `; + } + else{ + returned_data += ` + + `; + } + } + else{ + returned_data += ` + + `; + } + + return returned_data; } else{ return ` @@ -372,7 +416,8 @@ function updateFooterLineas(table){ base: totalSubtotal, total: totalTotal, total_pagos: total_pagos, - pendiente: pendientePago + pendiente: pendientePago, + : v } }).done((data, textStatus, jqXHR) => { if(data.estado_pago == 'pagada'){ @@ -397,12 +442,12 @@ $(document).on('click', '.btn-delete', function(e) { asyncConfirmDialogWithParams( "Borrar Linea de Factura", "¿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 row = params[1]; const row_data = tableLineas.row($(row)).data(); @@ -415,7 +460,8 @@ function deleteConfirmed(params){ data: { factura_id: id ?>, pedido_linea_impresion_id: row_data.pedido_linea_impresion_id, - cantidad: row_data.cantidad + cantidad: row_data.cantidad, + : v } }).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 = id ?>; + + var url = ''; + 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), + : v + } + }).done((data, textStatus, jqXHR) => { + $('#tableOfLineasFactura').DataTable().clearPipeline(); + $('#tableOfLineasFactura').DataTable().draw(); + }).fail((jqXHR, textStatus, errorThrown) => { + popErrorAlert(jqXHR.responseJSON.messages.error) + }) +}); + endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php index 1a169428..6a395ff5 100644 --- a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php +++ b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidosList.php @@ -11,6 +11,14 @@
+
+
+ + +
+
@@ -23,11 +31,11 @@ - - - + + + - + @@ -57,24 +65,130 @@ `; }; - 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('