HEad fixed

This commit is contained in:
imnavajas
2025-02-02 10:55:03 +01:00
131 changed files with 15486 additions and 16195 deletions

View File

@ -13,6 +13,7 @@ class PedidoXML extends BaseConfig
public string $password;
public string $base_dir; # FTP server directory
public bool $xml_enabled;
public int $id_offset;
public function __construct() {
parent::__construct();
@ -22,6 +23,7 @@ class PedidoXML extends BaseConfig
$this->password = env("HIDRIVE_PASS","A77h3b0X4OA2rOYAf4w2");
$this->base_dir = env("HIDRIVE_PATH_ROOT","/home/admin/safekat"); # FTP server directory
$this->xml_enabled = env("FTP_XML_ENABLED",false);
$this->id_offset = env("XML_OFFSET_CUSTOMER_ID",1000000);
}
}

View File

@ -9,10 +9,10 @@ const SK_PERMISSION_MATRIX = [
"plantilla-tarifa.edit",
"plantilla-tarifa.delete",
"plantilla-tarifa.menu",
"perfil.create",
"perfil.edit",
"perfil.delete",
"perfil.menu",
"direcciones.create",
"direcciones.edit",
"direcciones.delete",
"direcciones.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.delete",
@ -21,6 +21,14 @@ const SK_PERMISSION_MATRIX = [
"presupuesto-cliente.edit",
"presupuesto-cliente.delete",
"presupuesto-cliente.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
"tarifa-preimpresion.create",
"tarifa-preimpresion.edit",
"tarifa-preimpresion.delete",
@ -37,14 +45,14 @@ const SK_PERMISSION_MATRIX = [
"tarifa-encuadernacion.edit",
"tarifa-encuadernacion.delete",
"tarifa-encuadernacion.menu",
"tarifa-envio.create",
"tarifa-envio.edit",
"tarifa-envio.delete",
"tarifa-envio.menu",
"tarifa-extra.create",
"tarifa-extra.edit",
"tarifa-extra.delete",
"tarifa-extra.menu",
"tarifa-envio.create",
"tarifa-envio.edit",
"tarifa-envio.delete",
"tarifa-envio.menu",
"proveedores.create",
"proveedores.edit",
"proveedores.delete",
@ -61,10 +69,6 @@ const SK_PERMISSION_MATRIX = [
"paises.edit",
"paises.delete",
"paises.menu",
"formas-pago.create",
"formas-pago.edit",
"formas-pago.delete",
"formas-pago.menu",
"maquinas.create",
"maquinas.edit",
"maquinas.delete",
@ -89,48 +93,48 @@ const SK_PERMISSION_MATRIX = [
"roles-permisos.edit",
"roles-permisos.delete",
"roles-permisos.menu",
"ubicaciones.create",
"ubicaciones.edit",
"ubicaciones.delete",
"ubicaciones.menu",
"series-facturas.create",
"series-facturas.edit",
"series-facturas.delete",
"series-facturas.menu",
],
"cliente-admin" => [
"perfil.edit",
"perfil.menu",
"direcciones.create",
"direcciones.edit",
"direcciones.delete",
"direcciones.menu",
"presupuesto-cliente.create",
"presupuesto-cliente.edit",
"presupuesto-cliente.delete",
"presupuesto-cliente.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
],
"cliente-editor" => [
"perfil.create",
"perfil.edit",
"perfil.delete",
"perfil.menu",
"direcciones.create",
"direcciones.edit",
"direcciones.delete",
"direcciones.menu",
"presupuesto-cliente.create",
"presupuesto-cliente.edit",
"presupuesto-cliente.delete",
"presupuesto-cliente.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
],
"comercial" => [
"token.token",
"token.menu",
],
"produccion" => [
"token.token",
"token.menu",
"clientes.create",
"clientes.edit",
"clientes.menu",
"direcciones.create",
"direcciones.edit",
"direcciones.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.menu",
],
"maquina" => [
"token.token",
@ -163,10 +167,10 @@ const SK_PERMISSION_MATRIX = [
"plantilla-tarifa.edit",
"plantilla-tarifa.delete",
"plantilla-tarifa.menu",
"perfil.create",
"perfil.edit",
"perfil.delete",
"perfil.menu",
"direcciones.create",
"direcciones.edit",
"direcciones.delete",
"direcciones.menu",
"presupuesto.create",
"presupuesto.edit",
"presupuesto.delete",
@ -175,6 +179,14 @@ const SK_PERMISSION_MATRIX = [
"presupuesto-cliente.edit",
"presupuesto-cliente.delete",
"presupuesto-cliente.menu",
"pedidos-activos.view",
"pedidos-activos.menu",
"pedidos-finalizados.view",
"pedidos-finalizados.menu",
"pedidos-cancelados.view",
"pedidos-cancelados.menu",
"pedidos-todos.view",
"pedidos-todos.menu",
"tarifa-preimpresion.create",
"tarifa-preimpresion.edit",
"tarifa-preimpresion.delete",
@ -195,10 +207,6 @@ const SK_PERMISSION_MATRIX = [
"tarifa-envio.edit",
"tarifa-envio.delete",
"tarifa-envio.menu",
"tarifa-extra.create",
"tarifa-extra.edit",
"tarifa-extra.delete",
"tarifa-extra.menu",
"proveedores.create",
"proveedores.edit",
"proveedores.delete",
@ -239,13 +247,5 @@ const SK_PERMISSION_MATRIX = [
"roles-permisos.edit",
"roles-permisos.delete",
"roles-permisos.menu",
"ubicaciones.create",
"ubicaciones.edit",
"ubicaciones.delete",
"ubicaciones.menu",
"series-facturas.create",
"series-facturas.edit",
"series-facturas.delete",
"series-facturas.menu",
],
];

View File

@ -45,6 +45,10 @@ const SK_PERMISSIONS = [
'tarifa-encuadernacion.edit' => 'Can edit',
'tarifa-encuadernacion.delete' => 'Can delete',
'tarifa-encuadernacion.menu' => 'Menu shall be visualize',
'tarifa-extra.create' => 'Can create',
'tarifa-extra.edit' => 'Can edit',
'tarifa-extra.delete' => 'Can delete',
'tarifa-extra.menu' => 'Menu shall be visualize',
'tarifa-envio.create' => 'Can create',
'tarifa-envio.edit' => 'Can edit',
'tarifa-envio.delete' => 'Can delete',

View File

@ -77,8 +77,6 @@ $routes->group('tarifas', ['namespace' => 'App\Controllers\Tarifas'], function (
$routes->get('delete/(:num)', 'TarifaAcabados::delete/$1', ['as' => 'tarifaAcabadoDelete']);
$routes->post('datatable', 'TarifaAcabados::datatable', ['as' => 'tarifaAcabadoDT']);
$routes->get('select', 'TarifaAcabados::show_select', ["as" => "showSelectTarifaAcabado"]);
$routes->get('gettarifas', 'TarifaAcabados::getSelect2');
$routes->group('lineas', ['namespace' => 'App\Controllers\Tarifas\Acabados'], function ($routes) {
$routes->post('datatable', 'TarifaAcabadosLineas::datatable', ['as' => 'tarifaAcabadoLineasDT']);
$routes->post('datatable_editor', 'TarifaAcabadosLineas::datatable_editor', ['as' => 'tarifaAcabadoLineasDTE']);

View File

@ -3,6 +3,8 @@
namespace Config;
use App\Services\FTPService;
use App\Services\MaquinaService;
use App\Services\PapelImpresionService;
use CodeIgniter\Config\BaseService;
use App\Services\ProductionService;
use App\Services\TarifaMaquinaService;
@ -38,4 +40,12 @@ class Services extends BaseService
public static function tarifa_maquina(){
return new TarifaMaquinaService();
}
public static function papel_impresion()
{
return new PapelImpresionService();
}
public static function maquina()
{
return new MaquinaService();
}
}

View File

@ -42,7 +42,22 @@ class Validation extends BaseConfig
// --------------------------------------------------------------------
// Rules
// --------------------------------------------------------------------
/**
* Maquina duplicate validation
*
* @var array
*/
public array $maquina_duplicate = [
"name" => "required|string"
];
/**
* PapelImpresion duplicate validation
*
* @var array
*/
public array $papel_impresion_duplicate = [
"name" => "required|string"
];
/**========================================================================
* TARIFA MAQUINA ACABADO
*========================================================================**/

View File

@ -0,0 +1,86 @@
<?php
namespace App\Controllers\Configuracion;
use App\Controllers\BaseController;
use App\Models\Configuracion\MaquinaTareaModel;
use CodeIgniter\HTTP\Response;
use Hermawan\DataTables\DataTable;
use CodeIgniter\I18n\Time;
class MaquinaTarea extends BaseController
{
protected MaquinaTareaModel $maquinaTareaModel;
protected $format = 'json';
protected array $viewData = [];
protected static $viewPath = 'themes/vuexy/form/configuracion/maquina_tareas/';
protected static $controllerSlug = "maquina-tareas";
protected $indexRoute = 'viewMaquinaTarea';
protected $editRoute = 'editMaquinaTarea';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->maquinaTareaModel = model(MaquinaTareaModel::class);
}
public function index()
{
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
['title' => lang("App.menu_maquina_tareas"), 'route' => site_url('configuracion/maquina-tareas'), 'active' => true]
];
return view(static::$viewPath . $this->indexRoute, $this->viewData);
}
public function viewForm(int $maquina_tarea_id)
{
$maquinaTarea = $this->maquinaTareaModel->find($maquina_tarea_id);
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
['title' => lang("App.menu_maquina_tareas"), 'route' => site_url('configuracion/maquina-tareas'), 'active' => false],
['title' => $maquinaTarea->name, 'route' => site_url('configuracion/maquina-tareas/edit/' . $maquina_tarea_id), 'active' => true]
];
$this->viewData["model"] = $maquinaTarea;
return view(static::$viewPath . $this->editRoute, $this->viewData);
}
public function show(int $id)
{
$data = $this->maquinaTareaModel->find($id);
return $this->response->setJSON($data);
}
public function update_servicio_cliente(int $id)
{
$data = $this->request->getPost();
$status = $this->maquinaTareaModel->update($id, [
"name" => $data["name"],
"description" => $data["description"]
]);
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status]);
}
public function store()
{
$bodyData = $this->request->getPost();
$r = $this->maquinaTareaModel->insert($bodyData);
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r,"data" => $bodyData]);
}
public function delete(int $maquina_tarea_id){
$r = $this->maquinaTareaModel->delete($maquina_tarea_id);
return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => $r]);
}
public function datatable()
{
$query = $this->maquinaTareaModel->getQueryDatatable()->orderBy("created_at", "DESC");
return DataTable::of($query)
->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "")
->add("action", fn($q) => $q->id)
->toJson(true);
}
}

View File

@ -9,6 +9,8 @@ use App\Models\Collection;
use App\Entities\Configuracion\Maquina;
use App\Models\Configuracion\MaquinaModel;
use App\Services\MaquinaService;
use CodeIgniter\Validation\Validation;
class Maquinas extends \App\Controllers\BaseResourceController
{
@ -26,18 +28,19 @@ class Maquinas extends \App\Controllers\BaseResourceController
protected static $viewPath = 'themes/vuexy/form/configuracion/maquinas/';
protected $indexRoute = 'maquinaList';
protected MaquinaService $maquinaService;
protected Validation $validation;
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
$this->viewData['pageTitle'] = lang('Maquinas.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
$this->maquinaService = service('maquina');
$this->validation = service('validation');
// Se indica que este controlador trabaja con soft_delete
$this->soft_delete = true;
// Se indica el flag para los ficheros borrados
$this->delete_flag = 1;
$this->viewData = ['usingServerSideDataTable' => true]; // JJO
// Breadcrumbs (IMN)
@ -385,6 +388,19 @@ class Maquinas extends \App\Controllers\BaseResourceController
];
return $tipoOptions;
}
public function duplicate(int $maquina_id)
{
$bodyData = $this->request->getPost();
$validated = $this->validation->run($bodyData,'maquina_duplicate');
if($validated){
$this->maquinaService->setMaquina($maquina_id);
$duplicated = $this->maquinaService->duplicate($bodyData['name']);
return $this->response->setJSON(["data" => $duplicated]);
}else{
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
}
}
}

View File

@ -225,7 +225,9 @@ class Maquinaspapelesimpresion extends \App\Controllers\BaseResourceController {
];
// Se checkea que no haya otro papel con ese gramaje seleccionado y que la accion sea activar ese papel
if($this->model->getPapelActivo($maquina_id, $gramaje)->countAllResults() != 0 && intval($active)==1){
// Esta funcionalidad esta mal: habría que comprobar también que tienen el mismo papel genérico. Se opta por
// quitar la condición el 22012025
/*if($this->model->getPapelActivo($maquina_id, $gramaje)->countAllResults() != 0 && intval($active)==1){
$response['error']= lang('MaquinasPapelImpresion.gramaje_duplicado');;
$ret_vals = [
'DT_RowId' => 'row_'. $papel_id,
@ -235,9 +237,9 @@ class Maquinaspapelesimpresion extends \App\Controllers\BaseResourceController {
];
$response['data'] = $ret_vals;
}
else{
else{*/
$this->model->updateRows([$data]);
}
//}
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();

View File

@ -314,8 +314,15 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
$tapa_dura = goSanitize($this->request->getGet('tapa_dura'))[0] ?? null;
$menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, false, $POD);
$menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, true, $POD);
$ancho = floatval($this->request->getGet('ancho') ?? 0);
$alto = floatval($this->request->getGet('alto') ?? 0);
$solapas = floatval($this->request->getGet('solapas') ?? 0);
$lomo = floatval($this->request->getGet('lomo') ?? 0);
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
$menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada);
$menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -349,8 +356,17 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
}
$tipo = goSanitize($this->request->getGet('tipo'))[0];
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
$ancho = floatval($this->request->getGet('ancho') ?? 0);
$alto = floatval($this->request->getGet('alto') ?? 0);
$solapas = floatval($this->request->getGet('solapas') ?? 0);
$lomo = floatval($this->request->getGet('lomo') ?? 0);
$items = $this->model->getPapelCliente($tipo, $cubierta, null, true, $POD);
$tapa_dura = $this->request->getGet('tapa_dura') ?? 0;
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
$items = $this->model->getPapelCliente($tipo, $cubierta, null, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
$items = array_map(function ($item) {
return [
'id' => $item->id,

View File

@ -22,6 +22,7 @@ use
use App\Models\Collection;
use CodeIgniter\Validation\Validation;
@ -35,7 +36,6 @@ use App\Models\Configuracion\PapelImpresionTipologiaModel;
use App\Models\Configuracion\MaquinasPapelesImpresionModel;
use App\Models\Configuracion\MaquinaModel;
class Papelesimpresion extends \App\Controllers\BaseResourceController
{
@ -52,6 +52,7 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController
protected static $viewPath = 'themes/vuexy/form/configuracion/papel/';
protected $indexRoute = 'papelImpresionList';
protected Validation $validation;
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
@ -66,6 +67,7 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController
$this->delete_flag = 1;
$this->tpModel = new PapelImpresionTipologiaModel();
$this->validation = service("validation");
// Breadcrumbs
$this->viewData['breadcrumb'] = [
@ -443,4 +445,27 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController
$ma_pa_model->updateRows($active_values);
}
}
/**
* Duplica el papel impresion y sus relaciones
*
* @param int $papel_impresion_id
* @return Response
*/
public function duplicate( int $papel_impresion_id)
{
$bodyData = $this->request->getPost();
$validated = $this->validation->run($bodyData, "papel_impresion_duplicate");
if($validated){
$papelImpresionEntity = $this->model->find($papel_impresion_id);
$papelImpresionService = service('papel_impresion');
$duplicated = $papelImpresionService
->setPapelImpresionEntity($papelImpresionEntity)
->duplicate($bodyData["name"]);
return $this->response->setJSON(["data" => $duplicated]);
}else{
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
}
}
}

View File

@ -1,89 +0,0 @@
<?php
namespace App\Controllers\Configuracion;
use App\Controllers\BaseController;
use App\Models\Configuracion\ServicioClienteModel;
use CodeIgniter\HTTP\Response;
use Hermawan\DataTables\DataTable;
use CodeIgniter\I18n\Time;
class ServicioCliente extends BaseController
{
protected ServicioClienteModel $servicioClienteModel;
protected $format = 'json';
protected array $viewData = [];
protected static $viewPath = 'themes/vuexy/form/configuracion/servicios_cliente/';
protected static $controllerSlug = "servicios";
protected $indexRoute = 'viewServicioCliente';
protected $editRoute = 'ServicioClienteEdit';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->servicioClienteModel = model(ServicioClienteModel::class);
}
public function index()
{
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
['title' => lang("App.menu_servicios_cliente"), 'route' => site_url('configuracion/servicios'), 'active' => true]
];
return view(static::$viewPath . $this->indexRoute, $this->viewData);
}
public function viewForm(int $servicio_cliente_id)
{
$servicioCliente = $this->servicioClienteModel->find($servicio_cliente_id);
$this->viewData['breadcrumb'] = [
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
['title' => lang("App.menu_servicios_cliente"), 'route' => site_url('configuracion/servicios'), 'active' => false],
['title' => $servicioCliente->nombre, 'route' => site_url('configuracion/servicios/edit/' . $servicio_cliente_id), 'active' => true]
];
$this->viewData["model"] = $servicioCliente;
return view(static::$viewPath . 'ServicioClienteEdit', $this->viewData);
}
public function show(int $id)
{
$data = $this->servicioClienteModel->find($id)->withAllTarifas();
return $this->response->setJSON($data);
}
public function update_servicio_cliente(int $id)
{
$data = $this->request->getPost();
$status = $this->servicioClienteModel->update($id, [
"nombre" => $data["nombre"],
"code" => $data["code"]
]);
if (isset($data["tarifa_manipulado_id"])) {
$this->servicioClienteModel->upsertTarifaManipulado($id, $data["tarifa_manipulado_id"]);
}else if(isset($data["tarifa_acabado_id"])) {
$this->servicioClienteModel->upsertTarifaAcabado($id, $data["tarifa_acabado_id"]);
}else{
$this->servicioClienteModel->detachTarifas($id);
}
return $this->response->setJSON(["message" => lang("App.global_success"), "status" => $status]);
}
public function store()
{
// $this->servicioClienteModel->update($id,[$this->request->getPost()]);
return $this->response->setJSON([]);
}
public function datatable()
{
$query = $this->servicioClienteModel->getQueryDatatable()->orderBy("created_at", "DESC");
return DataTable::of($query)
->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "")
->add("action", fn($q) => $q->id)
->toJson(true);
}
}

View File

@ -89,6 +89,8 @@ class Users extends \App\Controllers\GoBaseController
// Marcar el username como NULL
$sanitizedData = $this->sanitized($postData, true);
$email = $sanitizedData['email'];
unset($sanitizedData['email']);
$noException = true;
@ -100,7 +102,7 @@ class Users extends \App\Controllers\GoBaseController
try {
// The Email is unique
if ($this->user_model->isEmailUnique($sanitizedData['email'])) {
if ($this->user_model->isEmailUnique($email)) {
// Crear el usuario si pasa la validación
$user = new \CodeIgniter\Shield\Entities\User([
@ -109,8 +111,6 @@ class Users extends \App\Controllers\GoBaseController
'last_name' => $sanitizedData['last_name'],
'cliente_id' => $sanitizedData['cliente_id'],
'comments' => $sanitizedData['comments'],
'email' => $sanitizedData['email'],
'password' => $sanitizedData['password'],
'status' => $sanitizedData['status'] ?? 0,
'active' => $sanitizedData['active'] ?? 0,
]);

View File

@ -33,13 +33,6 @@ class Js_loader extends BaseController
}
function datosLibro_js()
{
$this->response->setHeader('Content-Type', 'text/javascript');
return view('themes/vuexy/form/presupuestos/admin/_datosLibroItems.js');
}
function previsualizador_js()
{
$this->response->setHeader('Content-Type', 'text/javascript');

View File

@ -69,30 +69,61 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
return;
endif;
$postData = $this->request->getJSON();
$tarifas = array_column($postData->datos, 'tarifa_id');
$tirada = $postData->tirada ?? 0;
$POD = $postData->POD ?? 0;
$result = [];
if (count($tarifas) > 0) {
foreach ($tarifas as $tarifa) {
$values = $this->model->getPrecioTarifa($tarifa, $tirada, $POD);
array_push($result, $values);
}
}
$postData = $this->request->getPost();
$datos_tarifas = $postData['datos'] ?? [];
$tirada = $postData['tirada'] ?? 0;
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
$result = $this->getServiciosAcabados($datos_tarifas, $tirada, $POD);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'lines' => $result,
'lineas' => $result,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
public function datatable()
public function getServiciosAcabados($datos_tarifas, $tirada, $POD){
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
$result = [];
if (count($datos_tarifas) > 0) {
foreach ($datos_tarifas as $tarifa) {
$proveedor = $tarifa['proveedor_id'] == '' ? -1 : $tarifa['proveedor_id'];
$values = $model->getPrecioTarifa($tarifa['tarifa_id'], $tirada, $proveedor, $POD);
$values[0]->cubierta = $tarifa['cubierta'] ?? 0;
$values[0]->sobrecubierta = $tarifa['sobrecubierta'] ?? 0;
array_push($result, $values[0]);
}
}
return $result;
}
public function cargar()
{
if($this->request->isAJAX()) {
$presupuesto_id = $this->request->getGet('presupuesto_id') ?? null;
$rows = $this->model->getResource($presupuesto_id)->get()->getResultObject();
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'rows' => $rows,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function getRowValues()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
@ -100,7 +131,7 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
$tarifa_acabado_id = $reqData['tarifa_acabado_id'] ?? 0;
$tirada = $reqData['tirada'] ?? 0;
$proveedor_id = $reqData['proveedor_id'] ?? -1;
$POD = $reqData['POD'] ?? 0;
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
@ -195,4 +226,6 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
return $this->failUnauthorized('Invalid request', 403);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1586,7 +1586,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if (!is_null($new_name)) {
$path = WRITEPATH . 'uploads/presupuestos/' . $new_name;
move_uploaded_file($tmp_name, $path);
<<<<<<< HEAD
=======
>>>>>>> main
}
}
$ftp->uploadFilePresupuesto($presupuesto_id);
@ -2384,7 +2388,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value
];
<<<<<<< HEAD
// se comprueba si $datos guardas es un array
=======
// se comprueba si $datos guardas es un array
>>>>>>> main
if (is_array($datos_guardas)) {
if (count($datos_guardas) > 0) {
array_push($servicios, $servicio_plegado_guardas); // Plegado de guardas
@ -2407,7 +2415,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
array_push($servicios, $servicio_solapas_cubierta);
if (!is_null($sobreCubierta) && $sobreCubierta) // Si hay sobrecubierta, siempre con solapas
array_push($servicios, $servicio_solapas_sobrecubierta);
<<<<<<< HEAD
/* TO-DO
=======
/* TO-DO
>>>>>>> main
if (!is_null($faja) && $faja) // Si hay faja, siempre con solapas
array_push($servicios, $servicio_solapas_faja);
*/

View File

@ -44,7 +44,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
$att = $reqData['att'] ?? "";
$email = $reqData['email'] ?? "";
$direccion = $reqData['direccion'] ?? "";
$pais_id = $reqData['paisId'] ?? -1;
$pais_id = $reqData['pais_id'] ?? -1;
$provincia = $reqData['provincia'] ?? "";
$municipio = $reqData['municipio'] ?? "";
$cp = $reqData['cp'] ?? "";
@ -145,6 +145,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
$reqData = $this->request->getJSON();
if($reqData->tipo=='get_tarifa'){
$peso = $reqData->peso ?? 0;
$paisId = $reqData->paisId ?? 0;
$cp = $reqData->cp ?? 0;

View File

@ -1,4 +1,5 @@
<?php namespace App\Controllers\Presupuestos;
<?php
namespace App\Controllers\Presupuestos;
use App\Controllers\BaseResourceController;
@ -9,7 +10,7 @@ use App\Models\Presupuestos\PresupuestoEncuadernacionesModel;
use DataTables\Editor;
use DataTables\Editor\Field;
use DataTables\Editor\Validate;
class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceController
{
@ -25,7 +26,7 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
protected static $viewPath = 'themes/vuexy/form/presupuestos/';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
@ -35,20 +36,19 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
public function edit($requestedId = null)
{
if ($requestedId == null) :
if ($requestedId == null):
return;
endif;
$postData = $this->request->getJSON();
$tarifas = array_column($postData->datos, 'tarifa_id');
if(count($tarifas)>0){
if (count($tarifas) > 0) {
$this->model->deleteServiciosNotInArray($requestedId, $tarifas);
}
else{
} else {
$this->model->deleteAllServicios($requestedId);
}
if(count($tarifas)>0){
if (count($tarifas) > 0) {
$this->model->updateTarifas($requestedId, $postData->datos);
}
@ -57,7 +57,7 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
$data = [
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
@ -65,136 +65,177 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
{
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
if ($requestedId == null) :
if ($requestedId == null):
return;
endif;
$postData = $this->request->getJSON();
$tarifas = array_column($postData->datos, 'tarifa_id');
$tirada = $postData->tirada ?? 0;
$paginas = $postData->paginas ?? 0;
$POD = $postData->POD ?? 0;
$ancho = $postData->ancho ?? 0;
$alto = $postData->alto ?? 0;
$result = [];
if(count($tarifas)>0){
foreach ($tarifas as $tarifa){
if($tarifaModel->isTarifaPorHoras($tarifa)){
$values = $this->model->getPrecioTarifaHoras($tarifa, $paginas, $tirada, -1, $POD);
}else{
$values = $this->model->getPrecioTarifa($tarifa, $paginas, $tirada, $ancho, $alto, -1, $POD);
}
array_push($result, $values);
}
}
$postData = $this->request->getPost();
$datos_tarifas = $postData['datos'] ?? [];
$tirada = $postData['tirada'] ?? 0;
$paginas = $postData['paginas'] ?? 0;
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
$ancho = $postData['ancho'] ?? 0;
$alto = $postData['alto'] ?? 0;
$result = $this->getServiciosEncuadernacion($datos_tarifas, $tirada, $paginas, $ancho, $alto, $POD);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'lines' => $result,
'lineas' => $result,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
public function getServiciosEncuadernacion($datos_tarifas, $tirada, $paginas, $ancho, $alto, $POD)
{
$result = [];
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
$model = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
if (count($datos_tarifas) > 0) {
foreach ($datos_tarifas as $tarifa) {
if ($tarifaModel->isTarifaPorHoras($tarifa['tarifa_id'])) {
$values = $model->getPrecioTarifaHoras($tarifa['tarifa_id'], $paginas, $tirada, -1, $POD);
} else {
$values = $model->getPrecioTarifa($tarifa['tarifa_id'], $paginas, $tirada, $ancho, $alto, -1, $POD);
}
array_push($result, $values[0]);
}
}
return $result;
}
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
$tipo = $reqData['tipo'] ?? null;
if(is_null($tipo) || $tipo=='tarifa'){
if (is_null($tipo) || $tipo == 'tarifa') {
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? 0;
$proveedor_id = $reqData['proveedor_id'] ?? 0;
}
else{
} else {
$solapas = $reqData['solapas'] ?? 0;
}
$paginas = $reqData['paginas'] ?? 0;
$tirada = $reqData['tirada'] ?? 0;
$ancho = $reqData['ancho'] ?? 0;
$alto = $reqData['alto'] ?? 0;
$POD = $reqData['POD'] ?? 0;
$paginas_cuadernillo = $reqData['paginas_por_cuadernillo'] ?? null;
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
if(is_null($tipo)){
if($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)){
if (is_null($tipo)) {
if ($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)) {
$values = $this->model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo);
}else{
} else {
$values = $this->model->getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD);
}
}
else if($tipo=='tarifa'){
if($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)){
} else if ($tipo == 'tarifa') {
if ($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)) {
$values = $this->model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, -1, $POD);
}
else{
} else {
$values = $this->model->getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, -1, $POD);
}
}
else{
} else {
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
$values = $this->model->initPresupuesto($tipo_impresion_id, $solapas, $tirada, $paginas, $ancho, $alto, $POD);
}
$data = [
'values' => $values,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function getRowValues()
{
if ($this->request->isAJAX()) {
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
$reqData = $this->request->getPost();
$tarifa_enc_id = $reqData['tarifa_enc_id'] ?? 0;
$tirada = $reqData['tirada'] ?? 0;
$paginas = $reqData['paginas'] ?? 0;
$ancho = $reqData['ancho'] ?? 0;
$alto = $reqData['alto'] ?? 0;
$proveedor_id = $reqData['proveedor_id'] ?? -1;
$paginas_cuadernillo = $reqData['paginas_por_cuadernillo'] ?? 32;
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
if ($tarifaModel->isTarifaPorHoras($tarifa_enc_id)) {
$values = $this->model->getPrecioTarifaHoras($tarifa_enc_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo);
} else {
$values = $this->model->getPrecioTarifa($tarifa_enc_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD);
}
$data = [
'values' => $values,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function menuItems()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
try{
try {
$tarifa_id = $reqData['tarifa_id'] ?? -1;
$paginas = $reqData['paginas'] ?? 0;
$tirada = $reqData['tirada'] ?? 0;
$ancho = $reqData['ancho'] ?? 0;
$alto = $reqData['alto'] ?? 0;
//$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$paginas_cuadernillo = $reqData['paginas_por_cuadernillo'] ?? 32;
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$menu = $this->model->getProveedoresForSelector($tarifa_id, $paginas, $tirada, $ancho, $alto);
$menu = $this->model->getProveedoresForSelector($tarifa_id, $paginas, $tirada, $ancho, $alto, $paginas_cuadernillo);
$data = [
'menu' => $menu,
$csrfTokenName => $newTokenHash
];
}
catch(Exception $e){
} catch (Exception $e) {
$data = [
'error' => $e,
$csrfTokenName => $newTokenHash
];
}
finally{
} finally {
return $this->respond($data);
}
} else {
return $this->failUnauthorized('Invalid request', 403);
}

View File

@ -63,6 +63,27 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
return $this->respond($data);
}
public function getServicioSolapas(){
if($this->request->isAJAX()){
$servicio = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas')->value;
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'service' => $servicio,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
else{
return $this->failUnauthorized('Invalid request', 403);
}
}
public function update($requestedId = null)
{
@ -70,28 +91,38 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
return;
endif;
$postData = $this->request->getJSON();
$tarifas = array_column($postData->datos, 'tarifa_id');
$tirada = $postData->tirada ?? 0;
$POD = $postData->POD ?? 0;
$result = [];
if(count($tarifas)>0){
foreach ($tarifas as $tarifa){
$values = $this->model->getPrecioTarifa($tarifa, $tirada, $POD);
array_push($result, $values);
}
}
$postData = $this->request->getPost();
$tarifas = $postData['datos'] ?? [];
$tirada = $postData['tirada'] ?? 0;
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
$result = $this->getServiciosManipulado($tarifas, $tirada, $POD);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'lines' => $result,
'lineas' => $result,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
public function getServiciosManipulado($datos_tarifas, $tirada, $POD)
{
$result = [];
$model = model('App\Models\Presupuestos\PresupuestoManipuladosModel');
if (count($datos_tarifas) > 0) {
foreach ($datos_tarifas as $tarifa) {
$values = $model->getPrecioTarifa($tarifa, $tirada, $POD);
$values[0]->cubierta = $tarifa['cubierta'] ?? 0;
$values[0]->sobrecubierta = $tarifa['sobrecubierta'] ?? 0;
array_push($result, $values[0]);
}
}
return $result;
}
public function datatable()
@ -101,7 +132,7 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
$tarifa_manipulado_id = $reqData['tarifa_manipulado_id'] ?? 0;
$tirada = $reqData['tirada'] ?? 0;
$POD = $reqData['POD'] ?? 0;
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
$tipo = $reqData['tipo'] ?? null;
@ -129,4 +160,29 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
}
}
public function getRowValues()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
$tarifa_manipulado_id = $reqData['tarifa_manipulado_id'] ?? 0;
$tirada = $reqData['tirada'] ?? 0;
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$values = $this->model->getPrecioTarifa($tarifa_manipulado_id, $tirada, $POD);
$data = [
'values' => $values,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

View File

@ -110,4 +110,47 @@ class Presupuestopreimpresiones extends \App\Controllers\BaseResourceController
}
}
public function getRowValues()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
$tarifa_preimpresion_id = $reqData['tarifa_preimpresion_id'] ?? 0;
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$values = $this->model->getPrecioTarifa($tarifa_preimpresion_id);
$data = [
'values' => $values,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function cargar()
{
if($this->request->isAJAX()) {
$presupuesto_id = $this->request->getGet('presupuesto_id') ?? null;
$rows = $this->model->getResource($presupuesto_id)->get()->getResultObject();
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'rows' => $rows,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

View File

@ -110,4 +110,28 @@ class Presupuestoserviciosextra extends \App\Controllers\BaseResourceController
}
}
public function getRowValues()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
$tarifa_extra_id = $reqData['tarifa_extra_id'] ?? 0;
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$values = $this->model->getPrecioTarifa($tarifa_extra_id);
$data = [
'values' => $values,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

View File

@ -82,7 +82,12 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$id = $reqData['id'] ?? 0;
$json_data = $reqData['json_tiradas'] ?? null;
$json_data_acabados = $reqData['json_acabados'] ?? null;
$json_data_encuadernacion = $reqData['json_encuadernaciones'] ?? null;
$json_data_manipulado = $reqData['json_manipulado'] ?? null;
$cliente_id = $reqData['cliente_id'] ?? 0;
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
@ -95,7 +100,7 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
foreach ($data as $linea) {
// Se obtienen los valores de cada linea para el calculo del precio
$datosPedido = (object)array(
$datosPedido = (object) array(
'paginas' => intval($linea['paginas']) ?? 0,
'tirada' => intval($reqData['tirada']) ?? 0,
'merma' => intval($reqData['merma']) ?? 0,
@ -144,24 +149,24 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
$uso = 'interior';
$tipo = strpos($linea['row_id'], "_bn") !== false ? 'negro' : 'color';
$paginas_negro = isset($linea['numPagColor']) ? intval($datosPedido->paginas) - intval($linea['numPagColor']) : 0;
$paginas_color = $linea['numPagColor'] ?? 0;
$paginas = (object)array(
$paginas_color = $linea['numPagColor'] ?? 0;
$paginas = (object) array(
'negro' => $paginas_negro,
'color' => $paginas_color,
);
$parametrosRotativa = (object)array(
$parametrosRotativa = (object) array(
'a_favor_fibra' => $datosPedido->a_favor_fibra,
'bnPages' => $paginas->negro,
'colorPages' => $paginas->color,
'bnPages' => $paginas->negro,
'colorPages' => $paginas->color,
'rotativa_gota_negro' => 0,
'rotativa_gota_color' => 0,
);
$parametrosRotativa->rotativa_gota_negro = floatval($linea['gotaNegro']?? 0);
$parametrosRotativa->rotativa_gota_color = floatval($linea['gotaColor']?? 0);
$parametrosRotativa->rotativa_negro = floatval($linea['cobNegro'] ?? 0);
$parametrosRotativa->rotativa_cyan = floatval($linea['cobCyan'] ?? 0);
$parametrosRotativa->rotativa_magenta = floatval($linea['cobMagenta']?? 0);
$parametrosRotativa->rotativa_amarillo = floatval($linea['cobAmarillo']?? 0);
$parametrosRotativa->rotativa_gota_negro = floatval($linea['gotaNegro'] ?? 0);
$parametrosRotativa->rotativa_gota_color = floatval($linea['gotaColor'] ?? 0);
$parametrosRotativa->rotativa_negro = floatval($linea['cobNegro'] ?? 0);
$parametrosRotativa->rotativa_cyan = floatval($linea['cobCyan'] ?? 0);
$parametrosRotativa->rotativa_magenta = floatval($linea['cobMagenta'] ?? 0);
$parametrosRotativa->rotativa_amarillo = floatval($linea['cobAmarillo'] ?? 0);
break;
case 'lp_cubierta':
$uso = 'cubierta';
@ -194,14 +199,14 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
$datosTipolog = $linea['gotaNegro'] ?? null;
if (!is_null($datosTipolog)) {
$datosTipolog = [];
$data_temp = (object)array(
$data_temp = (object) array(
'negro' => floatval($linea['cobNegro'] ?? 0),
'cyan' => floatval($linea['cobCyan'] ?? 0),
'magenta' => floatval($linea['cobMagenta']?? 0),
'amarillo' => floatval($linea['cobAmarillo']?? 0),
'magenta' => floatval($linea['cobMagenta'] ?? 0),
'amarillo' => floatval($linea['cobAmarillo'] ?? 0),
'cg' => floatval($linea['cobCG'] ?? 0),
'gota_negro' => floatval($linea['gotaNegro']?? 0),
'gota_color' => floatval($linea['gotaColor']?? 0),
'gota_negro' => floatval($linea['gotaNegro'] ?? 0),
'gota_color' => floatval($linea['gotaColor'] ?? 0),
);
array_push($datosTipolog, $data_temp);
}
@ -213,13 +218,13 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
$datosLinea['datosPedido'] = $datosPedido;
$datosLinea['cliente_id'] = $cliente_id;
$datosLinea['papel'] = $papel;
if(isset($isColor))
$datosLinea['isColor'] = $isColor;
if(isset($opciones_papel))
if (isset($isColor))
$datosLinea['isColor'] = $isColor;
if (isset($opciones_papel))
$datosLinea['opciones_papel'] = $opciones_papel;
if(isset($parametrosRotativa))
if (isset($parametrosRotativa))
$datosLinea['parametrosRotativa'] = $parametrosRotativa;
if(isset($paginas))
if (isset($paginas))
$datosLinea['paginas'] = $paginas;
$datosLinea['maquina'] = $maquina;
$datosLinea['papel_generico'] = $papel_generico;
@ -257,19 +262,113 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
$linea_coste['total_coste'] +=
$linea_coste['fields']['precio_tinta'];
if (strpos($linea['row_id'], 'lp_rot') === 0) {
$linea_coste['total_coste'] +=
$linea_coste['fields']['total_corte'];
}
$linea_coste['total_coste'] +=
$linea_coste['fields']['total_corte'];
}
}
$linea_coste['total_margen'] = $linea_coste['fields']['margen_papel_pedido'] +
$linea_coste['fields']['margen_impresion_horas'] +
$linea_coste['fields']['margen_click_pedido'];
unset($linea_coste['fields']);
array_push($values, $linea_coste);
}
// Calculo de los servicios (presimpresion y extra no dependen de nada)
$servicios = (object) (['coste' => 0.0, 'margen' => 0.0]);
if ($json_data_acabados) {
$json_data_acabados = json_decode($json_data_acabados, true);
if (count($json_data_acabados) > 0) {
$acabados = new Presupuestoacabados();
$POD = (new \App\Models\Configuracion\ConfigVariableModel())->getVariable('POD')->value;
$result = $acabados->getServiciosAcabados($json_data_acabados, $reqData['tirada'], $POD);
if (count($result) > 0) {
foreach ($result as $servicio) {
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
$margen = round($servicio->total - $coste, 2);
$servicios->coste += $coste;
$servicios->margen += $margen;
}
}
}
}
if ($json_data_encuadernacion) {
$json_data_encuadernacion = json_decode($json_data_encuadernacion, true);
if (count($json_data_encuadernacion) > 0) {
$encuadernacion = new Presupuestoencuadernaciones();
$POD = (new \App\Models\Configuracion\ConfigVariableModel())->getVariable('POD')->value;
$result = $encuadernacion->getServiciosEncuadernacion($json_data_encuadernacion, $reqData['tirada'], $reqData['paginas'], $reqData['ancho'], $reqData['alto'], $POD);
if (count($result) > 0) {
foreach ($result as $servicio) {
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
$margen = round($servicio->total - $coste, 2);
$servicios->coste += $coste;
$servicios->margen += $margen;
}
}
}
}
if ($json_data_manipulado) {
$json_data_manipulado = json_decode($json_data_manipulado, true);
if (count($json_data_manipulado) > 0) {
$manipulados = new Presupuestomanipulados();
$POD = (new \App\Models\Configuracion\ConfigVariableModel())->getVariable('POD')->value;
$result = $manipulados->getServiciosManipulado($json_data_manipulado, $reqData['tirada'], $POD);
if (count($result) > 0) {
foreach ($result as $servicio) {
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
$margen = round($servicio->total - $coste, 2);
$servicios->coste += $coste;
$servicios->margen += $margen;
}
}
}
}
$json_envios = $reqData['json_envios'] ?? null;
$coste_envio = 0.0;
$margen_envio = 0.0;
$tirada_base = floatval($reqData['tirada_base']);
$peso_libro = floatval($reqData['peso_libro']);
// el primer envio con la tirada base
$model = model('App\Models\Tarifas\TarifaEnvioModel');
$envios = $model->getTarifaEnvio(1, 18000, $tirada_base * $peso_libro/1000.0, "cajas");
$resultado = $this->calcular_envio($envios, $tirada_base * $peso_libro/1000.0);
$coste_envio += $resultado->coste;
$margen_envio += $resultado->margen;
if ($json_envios) {
$json_envios = json_decode($json_envios, true);
if (count($json_envios) > 0) {
//la primera linea es el envio base
for($i = 1; $i < count($json_envios); $i++) {
$porcentaje = ($json_envios[$i]['cantidad']) / $tirada_base * 100.0;
$cantidad = floor($reqData['tirada'] * $porcentaje / 100.0);
$peso_envio = $cantidad * $peso_libro / 1000.0;
$paisId = $json_envios[$i]['pais_id'];
$cp = $json_envios[$i]['cp'];
$tipo_envio = $json_envios[$i]['entregaPieCalle'] == 1 ? 'palets' : 'cajas';
$model = model('App\Models\Tarifas\TarifaEnvioModel');
$envios = $model->getTarifaEnvio($paisId, $cp, $peso_envio, $tipo_envio);
$resultado = $this->calcular_envio($envios, $peso_envio);
$coste_envio += $resultado->coste;
$margen_envio += $resultado->margen;
}
}
}
} else {
$values = [];
}
@ -279,8 +378,36 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
$response[$csrfTokenName] = $newTokenHash;
$response['lineas'] = $values;
$response['servicios'] = $servicios;
$response['envios'] = (object) (['coste' => $coste_envio, 'margen' => $margen_envio]);
return $this->respond($response);
}
private function calcular_envio($envio, $peso_envio)
{
$coste_envio = 0.0;
$margen_envio = 0.0;
if (count(value: $envio) > 0) {
$envio = $envio[0];
if ($envio->id != null) {
if ($peso_envio > $envio->peso_max || floatval($envio->precio_max) == 0) {
$coste_envio += number_format(floatval($envio->precio_min) + ($peso_envio - floatval($envio->peso_min)) * floatval($envio->precio_adicional), 2);
}
// si no se calcula linealmente
else {
$m = (($envio->precio_max - $envio->precio_min) / ($envio->peso_max - $envio->peso_min));
$b = $envio->precio_max - $m * $envio->peso_max;
$coste_envio = number_format($m * $peso_envio + $b, 2);
}
$margen_envio += $coste_envio * $envio->margen / 100.0;
}
}
return (object) (['coste' => $coste_envio, 'margen' => $margen_envio]);
}
}

View File

@ -336,4 +336,25 @@ class TarifaAcabados extends BaseResourceController
}
return $this->response->setJSON($query->get()->getResultObject());
}
public function getSelect2()
{
if ($this->request->isAJAX()) {
$query = $this->model->builder()->select(
[
"id",
"nombre as name"
]
)->where("deleted_at", null);
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("lg_tarifas_acabado.nombre", $this->request->getGet("q"))
->groupEnd();
}
return $this->response->setJSON($query->get()->getResultObject());
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

View File

@ -239,4 +239,25 @@ class Tarifaextra extends \App\Controllers\GoBaseController
}
}
public function getSelect2()
{
if ($this->request->isAJAX()) {
$query = $this->model->builder()->select(
[
"id",
"nombre as name"
]
)->where("deleted_at", null)
->where("mostrar_en_presupuesto", 1);
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("tarifa_extra.nombre", $this->request->getGet("q"))
->groupEnd();
}
return $this->response->setJSON($query->get()->getResultObject());
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

View File

@ -242,4 +242,25 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
}
}
public function getSelect2()
{
if ($this->request->isAJAX()) {
$query = $this->model->builder()->select(
[
"id",
"nombre as name"
]
)->where("deleted_at", null)
->where("mostrar_en_presupuesto", 1);
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("lg_tarifa_preimpresion.nombre", $this->request->getGet("q"))
->groupEnd();
}
return $this->response->setJSON($query->get()->getResultObject());
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

View File

@ -356,4 +356,26 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
}
return $dimensiones;
}
public function getSelect2()
{
if ($this->request->isAJAX()) {
$query = $this->model->builder()->select(
[
"id",
"nombre as name"
]
)->where("deleted_at", null)
->where("mostrar_en_presupuesto", 1);
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("tarifa_encuadernacion.nombre", $this->request->getGet("q"))
->groupEnd();
}
return $this->response->setJSON($query->get()->getResultObject());
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

View File

@ -310,4 +310,26 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
}
return $this->response->setJSON($query->get()->getResultObject());
}
public function getSelect2()
{
if ($this->request->isAJAX()) {
$query = $this->model->builder()->select(
[
"id",
"nombre as name"
]
)->where("deleted_at", null)
->where("mostrar_en_presupuesto", 1);
if ($this->request->getGet("q")) {
$query->groupStart()
->orLike("lg_tarifa_manipulado.nombre", $this->request->getGet("q"))
->groupEnd();
}
return $this->response->setJSON($query->get()->getResultObject());
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

View File

@ -1,7 +1,12 @@
<?php
namespace App\Entities\Configuracion;
use App\Models\Configuracion\MaquinasCallesModel;
use App\Models\Configuracion\MaquinasDefectoModel;
use App\Models\Configuracion\MaquinasPapelesImpresionModel;
use App\Models\Configuracion\MaquinasTarifasImpresionModel;
use CodeIgniter\Entity;
use PhpParser\Node\Expr\Cast\Array_;
class Maquina extends \CodeIgniter\Entity\Entity
{
@ -64,4 +69,34 @@ class Maquina extends \CodeIgniter\Entity\Entity
"user_created_id" => "int",
"user_updated_id" => "int",
];
public function papeles_impresion() : ?array
{
$m = model(MaquinasPapelesImpresionModel::class);
return $m->asArray()->where('maquina_id',$this->attributes['id'])->findAll();
}
public function maquina_defecto(): ?array
{
$m = model(MaquinasDefectoModel::class);
return $m->asArray()->where('maquina_id',$this->attributes['id'])->findAll();
}
public function maquina_calles() : ?array
{
$m = model(MaquinasCallesModel::class);
return $m->asArray()->where('maquina_id',$this->attributes['id'])->findAll();
}
public function tarifas_impresion() : ?array
{
$m = model(MaquinasTarifasImpresionModel::class);
return $m->asArray()->where('maquina_id',$this->attributes['id'])->findAll();
}
public function withAll() : self
{
$this->attributes['papeles_impresion'] = $this->papeles_impresion();
$this->attributes['maquina_calles'] = $this->maquina_calles();
$this->attributes['maquina_defecto'] = $this->maquina_defecto();
$this->attributes['tarifas_impresion'] = $this->tarifas_impresion();
return $this;
}
}

View File

@ -1,6 +1,9 @@
<?php
namespace App\Entities\Configuracion;
use App\Models\Configuracion\MaquinasPapelesImpresionModel;
use App\Models\Configuracion\PapelImpresionMargenModel;
use App\Models\Configuracion\PapelImpresionTipologiaModel;
use CodeIgniter\Entity;
class PapelImpresion extends \CodeIgniter\Entity\Entity
@ -49,4 +52,20 @@ class PapelImpresion extends \CodeIgniter\Entity\Entity
"use_for_tapa_dura" => "boolean",
"is_deleted" => "int",
];
public function tipologia() : ?array
{
$m = model(PapelImpresionTipologiaModel::class);
return $m->asArray()->where('papel_impresion_id',$this->attributes["id"])->findAll();
}
public function maquinas_impresion() : ?array
{
$m = model(MaquinasPapelesImpresionModel::class);
return $m->asArray()->where('papel_impresion_id',$this->attributes["id"])->findAll();
}
public function margen() : ?array
{
$m = model(PapelImpresionMargenModel::class);
return $m->asArray()->where('papel_impresion_id',$this->attributes["id"])->findAll();
}
}

View File

@ -31,7 +31,6 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
"retractilado" => false,
"retractilado5" => false,
"guardas" => false,
"faja_color" => false,
"recoger_en_taller" => false,
"ferro" => false,
"ferro_digital" => false,
@ -53,6 +52,9 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
"solapas_ancho" => 0.0,
"solapas_sobrecubierta" => false,
"solapas_ancho_sobrecubierta" => 0.0,
"faja_color" => false,
"solapas_ancho_faja_color" => 0.0,
"alto_faja_color" => 0.0,
"cosido" => false,
"sobrecubiertas" => false,
"sobrecubiertas_ancho" => 0.0,
@ -63,6 +65,7 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
"comentarios_pdf" => null,
"comentarios_tarifa" => null,
"comentarios_produccion" => null,
"comentarios_presupuesto" => null,
"lomo_cubierta" => null,
"lomo_sobrecubierta" => null,
"total_presupuesto" => null,
@ -107,6 +110,7 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
'paginasCuadernillo' => null,
'lomo_redondo' => null,
'cabezada' => null,
'envio_base' => null,
];
protected $casts = [
"cliente_id" => "int",
@ -116,11 +120,9 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
"tipologia_id" => "?int",
"pais_id" => "int",
"estado_id" => "int",
"inc_rei" => "?int",
"retractilado" => "boolean",
"retractilado5" => "boolean",
"guardas" => "boolean",
"faja_color" => "boolean",
"recoger_en_taller" => "boolean",
"ferro" => "boolean",
"ferro_digital" => "boolean",
@ -136,6 +138,9 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
"solapas_ancho" => "float",
"solapas_sobrecubierta" => "boolean",
"solapas_ancho_sobrecubierta" => "float",
"faja_color" => "boolean",
"solapas_ancho_faja_color" => "float",
"alto_faja_color" => "float",
"cosido" => "boolean",
"sobrecubiertas" => "boolean",
"sobrecubiertas_ancho" => "float",

View File

@ -13,6 +13,7 @@ class UserEntity extends \CodeIgniter\Entity\Entity
"status" => null,
"status_message" => null,
'active' => null,
"comments" => null,
"last_active" => null,
"created_at" => null,
"updated_at" => null,

View File

@ -32,7 +32,8 @@ return [
"global_pdf" => "PDF",
"global_prev" => "Anterior",
"global_next" => "Siguiente",
"global_save_file" => "Guardar ficheros",
"global_upload_files" => "Subir ficheros",
// LOGIN - Index
"login_title" => "Iniciar sesión en su cuenta",
"login_email" => "Correo Electrónico",
@ -695,7 +696,7 @@ return [
"menu_papelgenerico" => "Papel generico",
"menu_papelimpresion" => "Papel impresión",
"menu_series_facturas" => "Series facturas",
"menu_servicios_cliente" => "Servicios cliente",
"menu_maquina_tareas" => "Tareas máquinas",
"menu_ubicaciones" => "Ubicaciones",
"menu_serviciocliente" => "Servicio cliente",
"menu_tamanioformatos" => "Tamaño formatos",

View File

@ -28,6 +28,8 @@ return [
'Profile' => 'Perfil',
'Roles' => 'Roles',
'Save' => 'Guardar',
'Copy' => 'Copiar',
'Duplicate' => 'Duplicar',
'Sections' => 'Secciones',
'SignOut' => 'Desconectar',
'Success' => 'Éxito',

View File

@ -2,13 +2,14 @@
return [
"cardTitle" => "Servicios cliente",
"cardTitle" => "Máquina tareas",
"tarea_new" => "Crear tarea",
"infoTarifaManipulado" => "La tarifa seleccionada estará asociada al servicio.",
"infoTarifaAcabado" => "La tarifa seleccionada estará asociada al servicio.",
"datatable" => [
"nombre" => "Nombre",
"code" => "Código",
"description" => "Descripción",
"created_at" => "Fecha creación",
]
];

View File

@ -43,6 +43,7 @@ return [
'velocidad' => 'Velocidad',
'velocidadCorte' => 'Velocidad Corte',
'maquina_tarea' => 'Máquina tarea',
'namePlaceholderDuplicated' => "Inserte el nombre de la máquina a duplicar ...",
'validation' => [
'alto_menor_alto_impresion' => 'El campo \'Alto impresión\' debe ser menor que \'Alto\'',
'ancho_menor_ancho_impresion' => '\'Ancho Impresión\' debe ser menor que \'Ancho\'',

View File

@ -39,6 +39,7 @@ return [
'activo' => 'Activo?',
'useInClient' => 'Usar en presup. cliente',
'userUpdateId' => 'ID usuario actualización',
'namePlaceholderDuplicated' => 'Inserte el nombre del papel que se va a duplicar',
'consumo_tintas_rotativas' => 'Consumo tintas',
'maquinas_papel' => 'Máquinas seleccionadas',

View File

@ -130,6 +130,8 @@ return [
'estucadoMate170gr' => 'Estucado mate 170 gr',
'estucadoMate200gr' => 'Estucado mate 200 gr',
'acabadoNinguno' => 'Ninguno',
'fajaColor' => 'Imprimir faja a color',
'compInteriorPlana' => 'Interior en plana',
'compInteriorRotativa' => 'Interior en rotativa',
@ -143,6 +145,7 @@ return [
'libro' => 'Libro',
'totalPapelPedido' => 'Papel pedido',
'lomo' => 'Lomo',
'lomoRedondo' => 'Lomo redondo',
'peso' => 'Peso',
'click' => 'Click',
'totalClicks' => 'Total clicks',
@ -163,6 +166,7 @@ return [
'solapasSobrecubierta' => 'Solapas sobrecub.',
'solapasAnchoCubierta' => 'Ancho solapas cub.',
'solapasAnchoSobrecubierta' => 'Ancho solapas sobrecub.',
'sinImpresion' => 'Sin impresion',
'unaCara' => '1 cara',
'dosCaras' => '2 caras',
@ -195,6 +199,7 @@ return [
'totalLinea' => 'TOTAL LÍNEA',
'verCalculos' => 'Cálculos',
'metrosMinuto' => 'Metros x min.',
'clicksMinuto' => 'Clicks x min.',
'resolucion' => 'Resolución (dpi)',
'areaPaginas' => 'Área páginas (in)',
'gotasNegro' => 'Nº gotas negro',
@ -272,12 +277,14 @@ return [
'previewConfiguracionGuardas' => 'Configuración de guardas',
'previewConfiguracionCubierta' => 'Configuración de cubierta',
'previewConfiguracionSobrecubierta' => 'Configuración de sobrecubierta',
'previewConfiguracionFaja' => 'Configuración de faja',
'previewEsquemaCubierta' => 'Esquema de cubierta',
'previewConfiguracionEsquemaCubierta' => 'Configuración esquema de cubierta',
'previewMaquinaPlana' => 'Configuración del papel: Plana',
'previewMaquinaRotativa' => 'Configuración del papel: Rotativa',
'previewCubierta' => 'Configuración del papel: Cubierta',
'previewSobrecubierta' => 'Configuración del papel: Sobrecubierta',
'previewFaja' => 'Configuración del papel: Faja',
'previewPapelGenerico' => 'Papel Genérico',
'previewPapelCompra' => 'Papel de Compra',
'previewAreaImpresion' => 'Área de Impresión',
@ -313,7 +320,7 @@ return [
'tiradasAlternativas' => 'Tiradas alternativas',
'tiradasInfoIVA' => 'Los precios mostrados no incluyen IVA',
'tiradaMargen' => 'Margen',
'tiradaEnvio' => 'Coste Envío',
'tiradaEnvio' => 'Precio Envío',
'tiradaImpresion' => 'Coste Impresión',
'duplicado' => 'DUPLICADO',
@ -328,7 +335,7 @@ return [
'actualizacionSolapasCubierta' => 'El tamaño de las solapas de la cubierta se ha actualizado debido a que supera el máximo permitido (este valor depende del ancho del libro y del número de páginas).',
'actualizacionSolapasSobrecubierta' => 'El tamaño de las solapas de la sobrecubierta se ha actualizado debido a que supera el máximo permitido (este valor depende del ancho del libro y del número de páginas).',
'files' => 'Ficheros',
'titulos' => [
'libroFresadoTapaDura' => 'Rústica Fresado tapa dura',
'libroFresadoTapaBlanda' => 'Rústica Fresado tapa blanda',
@ -369,6 +376,9 @@ return [
'paginas' => 'El campo páginas tiene que ser mayor que cero',
'paginasLP' => 'El número de páginas no coincide con el total',
'tiradas' => 'El campo tiradas tiene que ser mayor que cero',
'seleccionePapel' => 'Seleccione un papel',
'seleccioneGramaje' => 'Seleccione un gramaje',
'seleccioneCliente' => 'Seleccione un cliente',
'dimension' => 'La dimensión del libro tiene que ser mayor que 60mm',
'lineaDuplicada' => 'Ya existe ese tipo de linea en el presupuesto',
'errorRotColor' => 'Papeles y gramajes deben ser iguales en color y BN',
@ -380,6 +390,8 @@ return [
'noInterior' => 'No se hay resultados para el interior',
'noCubiertaSobrecubierta' => 'No se hay resultados para cubierta/sobrecubierta',
'errorPresupuesto' => 'Se ha producido un error al calcular el presupuesto. Póngase en contacto con el administrador',
'error_sobrecubierta_sin_solapas' => 'Debe seleccionar "sobrecubierta" en los datos del libro para introducir el ancho de solapa',
'error_faja_sin_solapas' => 'Debe seleccionar "faja" en los datos del libro para introducir el ancho de solapa'
],
];

View File

@ -9,6 +9,7 @@ return [
'id' => 'ID',
'moduleTitle' => 'Tarifas Acabado',
'nombre' => 'Nombre',
'margen' => 'Margen',
'precioMin' => 'Precio Mínimo',
'importeFijo' => 'Importe Fijo',
'mostrar_en_presupuesto' => 'Mostrar en presupuesto',

View File

@ -58,12 +58,14 @@ class SafekatFtpClient
public function uploadFilePresupuesto(int $presupuesto_id)
{
try {
if ($this->xml_enabled == false) return false;
$model = model(PresupuestoFicheroModel::class);
$modelPedidoLinea = model(PedidoLineaModel::class);
$pedidoLinea = $modelPedidoLinea->findByPresupuesto($presupuesto_id);
$rootIdExtern = 1e6 + $pedidoLinea->pedido_id;
$rootIdExtern = $this->pedido_xml_config->id_offset + $pedidoLinea->pedido_id;
$presupuestoFiles = $model->getFiles($presupuesto_id);
$this->ftp->login(username: $this->username, password: $this->password);
foreach ($presupuestoFiles as $key => $value) {
$filename = array_reverse(explode("/", $value->file_path))[0];
$remoteDir = implode("/", [$this->base_dir,"pedidos_files",$rootIdExtern]);
@ -73,6 +75,29 @@ class SafekatFtpClient
}
$this->ftp->put($remoteFile,$value->file_path,mode:$this->ftp::SOURCE_LOCAL_FILE);
}
$this->ftp->disconnect();
} catch (Exception $e) {
log_message('error', $e->getMessage());
throw $e;
}
}
public function removeFiles(int $presupuesto_id)
{
try {
// if ($this->xml_enabled == false) return false;
$model = model(PresupuestoFicheroModel::class);
$modelPedidoLinea = model(PedidoLineaModel::class);
$pedidoLinea = $modelPedidoLinea->findByPresupuesto($presupuesto_id);
$rootIdExtern = $this->pedido_xml_config->id_offset + $pedidoLinea->pedido_id;
$presupuestoFiles = $model->getFiles($presupuesto_id);
$this->ftp->login(username: $this->username, password: $this->password);
foreach ($presupuestoFiles as $key => $value) {
$filename = array_reverse(explode("/", $value->file_path))[0];
$remoteFile = implode("/", [$this->base_dir,"pedidos_files",$rootIdExtern,$filename]);
$this->ftp->delete($remoteFile);
}
$this->ftp->disconnect();
} catch (Exception $e) {
log_message('error', $e->getMessage());
throw $e;

View File

@ -99,7 +99,7 @@ class ClienteDireccionesModel extends \App\Models\BaseModel
->table($this->table . " t1")
->select(
"t1.id AS id, t1.cliente_id AS cliente_id, t2.nombre as cliente_nombre, t1.att AS att, t1.alias AS alias,
t1.email AS email, t1.direccion AS direccion, t1.pais_id AS pais_id, t3.nombre AS pais,
t1.email AS email, t1.direccion AS direccion, t1.pais_id AS pais_id, t3.nombre AS pais, t3.nombre AS pais,
t1.municipio AS municipio, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono"
);

View File

@ -330,7 +330,7 @@ class MaquinaModel extends \App\Models\BaseModel
->table($this->table . " t1")
->distinct('t1.id')
->select(
"t1.id AS maquina_id, t1.nombre AS maquina, t1.ancho_impresion AS ancho_impresion,
"t1.id AS id, t1.id AS maquina_id, t1.nombre AS maquina, t1.nombre AS nombre, t1.ancho_impresion AS ancho_impresion,
t1.alto_impresion AS alto_impresion, t1.ancho AS ancho, t1.alto AS alto,
t1.is_rotativa AS is_rotativa, t1.is_inkjet AS is_inkjet, t1.alto_click AS alto_click, t1.velocidad AS velocidad,
t1.precio_tinta_negro AS precio_tinta_negro, t1.precio_tinta_color AS precio_tinta_color, t1.precio_tinta_cg AS precio_tinta_cg,
@ -361,7 +361,7 @@ class MaquinaModel extends \App\Models\BaseModel
$builder->where("t2.uso", $uso_tarifa);
}
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
return $builder;
}

View File

@ -3,6 +3,9 @@
namespace App\Models\Configuracion;
use App\Entities\Tarifas\Maquinas\TareaMaquinaEntity;
use CodeIgniter\Database\BaseBuilder;
use CodeIgniter\Database\MySQLi\Builder;
use CodeIgniter\Database\Query;
use CodeIgniter\Model;
class MaquinaTareaModel extends Model
@ -55,14 +58,19 @@ class MaquinaTareaModel extends Model
* @return array
*
*/
public function getSelectQuery(?string $q = null) : array
public function getSelectQuery(?string $q = null): array
{
$query = $this->builder()->select(["id","name","description"])
->where("deleted_at",null);
if($q){
$query->like("nombre",$q);
$query = $this->builder()->select(["id", "name", "description"])
->where("deleted_at", null);
if ($q) {
$query->like("nombre", $q);
}
return $query->get()->getResultArray();
}
public function getQueryDatatable(): BaseBuilder
{
return $this->builder()->select(["id","name","description","created_at"])
->where("deleted_at", null);
}
}

View File

@ -42,7 +42,7 @@ class MaquinasCallesModel extends \App\Models\BaseModel
protected $validationRules = [
"formas" => [
"rules" => "required|int",
"rules" => "required|integer",
],
"internas" => [
"rules" => "required|decimal",

View File

@ -129,141 +129,225 @@ class PapelGenericoModel extends \App\Models\BaseModel
return empty($search)
? $builder
: $builder
->groupStart()
->like("t1.id", $search)
->orLike("t1.nombre", $search)
->orLike("t1.code", $search)
->orLike("t1.code_ot", $search)
->orLike("t1.id", $search)
->orLike("t1.nombre", $search)
->orLike("t1.code", $search)
->orLike("t1.code_ot", $search)
->groupEnd();
->groupStart()
->like("t1.id", $search)
->orLike("t1.nombre", $search)
->orLike("t1.code", $search)
->orLike("t1.code_ot", $search)
->orLike("t1.id", $search)
->orLike("t1.nombre", $search)
->orLike("t1.code", $search)
->orLike("t1.code_ot", $search)
->groupEnd();
}
public function getPapelForComparador($tipo, $is_cubierta = false, $is_sobrecubierta = false, $rotativa = false, $is_guardas = false, $mostrar_cliente = null)
{
public function getPapelForComparador(
$tipo,
$is_cubierta = false,
$is_sobrecubierta = false,
$rotativa = false,
$is_guardas = false,
$tapa_dura = false,
$POD = false,
$ancho = 0,
$alto = 0,
$tirada = 0
) {
/*
1.-> Tipo impresion
2.-> Maquina
3.-> Papeles impresion asociados a esa maquina
4.-> papeles genericos que aparecen en esos papeles impresion
*/
if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) {
if ($tipo == 'color')
$tipo = 'colorhq';
else if ($tipo == 'negro')
$tipo = 'negrohq';
}
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id as id, t1.nombre AS nombre"
"t1.id as id, t1.nombre AS nombre",
// for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo"
)
->distinct('t1.id')
->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "left")
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left")
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left")
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left")
->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner")
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner")
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner")
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner")
->where("t1.is_deleted", 0)
->where("t1.show_in_client", 1)
->where("t2.is_deleted", 0)
->where("t2.isActivo", 1)
->where("t3.active", 1)
->where("t4.is_deleted", 0)
->where("t4.tipo", "impresion")
->where("t4.min <= ", $tirada)
->where("t4.max >= ", $tirada)
->where("t5.is_deleted", 0)
->where("t5.tipo", $tipo);
->where("t5.tipo", $tipo)
->distinct('t1.id');
// Validación adicional para asegurar que t1.id esté presente en las combinaciones con t3.active = 1
$builder->whereIn("t1.id", function ($subQuery) {
$subQuery->select("t1_inner.id")
->from("lg_papel_generico t1_inner")
->join("lg_papel_impresion t2_inner", "t2_inner.papel_generico_id = t1_inner.id", "inner")
->join("lg_maquina_papel_impresion t3_inner", "t3_inner.papel_impresion_id = t2_inner.id", "inner")
->where("t3_inner.active", 1);
});
$builder->groupStart()
->groupStart()
->where("t4.ancho_impresion >", $ancho)
->where("t4.alto_impresion >", $alto)
->groupEnd()
->orGroupStart()
->where("t4.ancho_impresion >", $alto)
->where("t4.alto_impresion >", $ancho)
->groupEnd()
->orGroupStart()
->where("t4.ancho_impresion >", $alto)
->where("t4.is_rotativa", 1)
->groupEnd()
->groupEnd();
if ($is_cubierta == true) {
$builder->where("t2.cubierta", 1);
$builder->where("t5.uso", 'cubierta');
}
if ($is_sobrecubierta == true) {
if ($tapa_dura == true) {
$builder->where("t2.use_for_tapa_dura", 1);
}
} else if ($is_sobrecubierta == true) {
$builder->where("t2.sobrecubierta", 1);
$builder->where("t5.uso", 'sobrecubierta');
}
if ($is_cubierta == false && $is_sobrecubierta == false) {
$builder->where("t5.uso", 'interior');
}
if ($is_guardas == true) {
} else if ($is_guardas == true) {
$builder->where("t2.guardas", 1);
} else {
$builder->where("t2.interior", 1);
$builder->where("t5.uso", 'interior');
if ($tipo == 'negro' || $tipo == 'negrohq')
$builder->where("t2.bn", 1);
else if ($tipo == 'color' || $tipo == 'colorhq')
$builder->where("t2.color", 1);
}
if ($rotativa == true) {
if ($tipo == 'colorhq' || $tipo == 'negrohq') {
$builder->where("t2.rotativa", 0);
} else if ($rotativa && $POD == false) {
$builder->where("t2.rotativa", 1);
} else if ($POD) {
$builder->where("t2.rotativa", 0);
}
if ($mostrar_cliente != null) {
$builder->where("t1.show_in_client", $mostrar_cliente);
}
$data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
//var_dump($this->db->getLastQuery());
return $data;
//$query = $this->db->getLastQuery();
return $builder;
}
public function getGramajeComparador(string $papel_generico_nombre = "", $uso = "", $ejemplares = 0)
{
if ($uso == 'cubierta' || $uso == 'sobrecubierta')
$tipo = 'colorhq';
else
$tipo = $uso; // color y colorhq valen para los dos
if ($uso == 'bn')
$tipo = "negro";
if ($uso == 'bnhq')
$tipo = "negrohq";
public function getGramajeForComparador(
$tipo,
$selected_papel_id,
$is_cubierta = false,
$is_sobrecubierta = false,
$rotativa = false,
$is_guardas = false,
$tapa_dura = false,
$POD = false,
$ancho = 0,
$alto = 0,
$tirada = 0
) {
if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) {
if ($tipo == 'color')
$tipo = 'colorhq';
else if ($tipo == 'negro')
$tipo = 'negrohq';
}
$builder = $this->db
->table($this->table . " t1")
->select(
"t2.gramaje AS text"
"t2.gramaje as id, t2.gramaje as nombre",
// for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo"
)
->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "left")
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left")
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left")
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left")
->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner")
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner")
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner")
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner")
->where("t1.id", $selected_papel_id)
->where("t1.is_deleted", 0)
->where("t1.show_in_client", 1)
->where("t2.is_deleted", 0)
->where("t2.isActivo", 1)
->where("t3.active", 1)
->where("t4.is_deleted", 0)
->where("t4.min <= ", $tirada)
->where("t4.max >= ", $tirada)
->where("t4.tipo", "impresion")
->where("t5.is_deleted", 0)
->where("t5.tipo", $tipo)
->where("t1.nombre", $papel_generico_nombre);
->distinct('t2.gramaje');
$uso_tarifa = 'interior';
// Validación adicional para asegurar que t1.id esté presente en las combinaciones con t3.active = 1
$builder->whereIn("t1.id", function ($subQuery) {
$subQuery->select("t1_inner.id")
->from("lg_papel_generico t1_inner")
->join("lg_papel_impresion t2_inner", "t2_inner.papel_generico_id = t1_inner.id", "inner")
->join("lg_maquina_papel_impresion t3_inner", "t3_inner.papel_impresion_id = t2_inner.id", "inner")
->where("t3_inner.active", 1);
});
if ($uso == 'bn' || $uso == 'bnhq')
$builder->where("t2.bn", 1);
else if ($uso == 'color' || $uso == 'colorhq')
$builder->where("t2.color", 1);
else if ($uso == 'cubierta') {
$uso_tarifa = 'cubierta';
$builder->groupStart()
->groupStart()
->where("t4.ancho_impresion >", $ancho)
->where("t4.alto_impresion >", $alto)
->groupEnd()
->orGroupStart()
->where("t4.ancho_impresion >", $alto)
->where("t4.alto_impresion >", $ancho)
->groupEnd()
->orGroupStart()
->where("t4.ancho_impresion >", $alto)
->where("t4.is_rotativa", 1)
->groupEnd()
->groupEnd();
if ($is_cubierta == true) {
$builder->where("t2.cubierta", 1);
} else if ($uso == 'sobrecubierta') {
$uso_tarifa = 'sobrecubierta';
$builder->where("t5.uso", 'cubierta');
if ($tapa_dura == true) {
$builder->where("t2.use_for_tapa_dura", 1);
}
} else if ($is_sobrecubierta == true) {
$builder->where("t2.sobrecubierta", 1);
$builder->where("t5.uso", 'sobrecubierta');
} else if ($is_guardas == true) {
$builder->where("t2.guardas", 1);
} else {
$builder->where("t2.interior", 1);
$builder->where("t5.uso", 'interior');
if ($tipo == 'negro' || $tipo == 'negrohq')
$builder->where("t2.bn", 1);
else if ($tipo == 'color' || $tipo == 'colorhq')
$builder->where("t2.color", 1);
}
$builder->where("t5.uso", $uso_tarifa);
$builder->where("t4.min <=", $ejemplares);
$builder->where("t4.max >=", $ejemplares);
$values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
$id = 1;
foreach ($values as $value) {
$value->id = $id;
$id++;
if ($tipo == 'colorhq' || $tipo == 'negrohq') {
$builder->where("t2.rotativa", 0);
} else if ($rotativa && $POD == false) {
$builder->where("t2.rotativa", 1);
} else if ($POD) {
$builder->where("t2.rotativa", 0);
}
$values_array = array_map(function ($value) {
return $value->text;
}, $values);
$unique_values = array_unique($values_array);
return array_values(array_intersect_key($values, $unique_values));
//$query = $this->db->getLastQuery();
return $builder;
}
//tipo: negro, negrohq, color, colorhq
@ -323,12 +407,20 @@ class PapelGenericoModel extends \App\Models\BaseModel
}, $values);
$unique_values = array_unique($values_array);
return array_values(array_intersect_key($values, $unique_values));
}
public function getPapelCliente($tipo, $is_cubierta = false, $selected_papel_id = null, $tapa_dura = null, $papel_especial = false, $POD = null)
{
public function getPapelCliente(
$tipo,
$is_cubierta = false,
$selected_papel_id = null,
$tapa_dura = null,
$papel_especial = false,
$POD = null,
$ancho = 0,
$alto = 0,
$tirada = 0
) {
/*
1.-> Tipo impresion
2.-> Maquina
@ -337,9 +429,9 @@ class PapelGenericoModel extends \App\Models\BaseModel
*/
if ($POD == true && ($tipo == 'color' || $tipo == 'negro')) {
if($tipo == 'color')
if ($tipo == 'color')
$tipo = 'colorhq';
else if($tipo == 'negro')
else if ($tipo == 'negro')
$tipo = 'negrohq';
}
@ -363,6 +455,8 @@ class PapelGenericoModel extends \App\Models\BaseModel
->where("t2.use_in_client", 1)
->where("t3.active", 1)
->where("t4.is_deleted", 0)
->where("t4.min <= ", $tirada)
->where("t4.max >= ", $tirada)
->where("t4.tipo", "impresion")
->where("t5.is_deleted", 0)
->where("t5.tipo", $tipo)
@ -386,6 +480,8 @@ class PapelGenericoModel extends \App\Models\BaseModel
->where("t2.use_in_client", 1)
->where("t3.active", 1)
->where("t4.is_deleted", 0)
->where("t4.min <= ", $tirada)
->where("t4.max >= ", $tirada)
->where("t4.tipo", "impresion")
->where("t5.is_deleted", 0)
->where("t5.tipo", $tipo)
@ -400,10 +496,25 @@ class PapelGenericoModel extends \App\Models\BaseModel
->where("t3_inner.active", 1);
});
$builder->groupStart()
->groupStart()
->where("t4.ancho_impresion >", $ancho)
->where("t4.alto_impresion >", $alto)
->groupEnd()
->orGroupStart()
->where("t4.ancho_impresion >", $alto)
->where("t4.alto_impresion >", $ancho)
->groupEnd()
->orGroupStart()
->where("t4.ancho_impresion >", $alto)
->where("t4.is_rotativa", 1)
->groupEnd()
->groupEnd();
if ($is_cubierta == true) {
$builder->where("t2.cubierta", 1);
$builder->where("t5.uso", 'cubierta');
if($tapa_dura == true){
if ($tapa_dura == true) {
$builder->where("t2.use_for_tapa_dura", 1);
}
} else {
@ -417,19 +528,16 @@ class PapelGenericoModel extends \App\Models\BaseModel
if ($papel_especial == true) {
$builder->where("t1.show_in_client_special", 1);
}
else{
} else {
$builder->where("t1.show_in_client_special", 0);
}
if ($tipo == 'colorhq' || $tipo == 'negrohq') {
$builder->where("t2.rotativa", 0);
}
else{
if($POD == false){
} else {
if ($POD == false) {
$builder->where("t2.rotativa", 1);
}
else if ($POD == true){
} else if ($POD == true) {
$builder->where("t2.rotativa", 0);
}
}

View File

@ -279,8 +279,15 @@ class PapelImpresionModel extends \App\Models\BaseModel
//tipo: negro, negrohq, color, colorhq
//uso: interior, rotativa, cubierta, sobrecubierta
public function getPapelesImpresionForMenu($papel_generico = null, $gramaje = null, $tipo = null, $uso = "")
{
public function getPapelesImpresionForMenu(
$papel_generico = null,
$gramaje = null,
$tipo = null,
$uso = "",
$tapaDura = false,
$forInkjet = false
) {
$builder = $this->db
->table($this->table . " t1")
->distinct("t1.id")
@ -289,7 +296,7 @@ class PapelImpresionModel extends \App\Models\BaseModel
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left")
->join("lg_maquinas_tarifas_impresion t5", "t4.id = t5.maquina_id", "left")
->select(
"t1.id AS id, t1.nombre AS text"
"t1.id AS id, t1.nombre AS nombre"
);
$builder->where("t1.is_deleted", 0);
@ -304,24 +311,31 @@ class PapelImpresionModel extends \App\Models\BaseModel
$builder->where("t2.id", $papel_generico);
$builder->where("t1.gramaje", $gramaje);
if ($uso == 'cubierta')
if ($uso == 'cubierta') {
if ($tapaDura)
$builder->where("t1.use_for_tapa_dura", 1);
$builder->where("t1.cubierta", 1);
else if ($uso == 'sobrecubierta')
} else if ($uso == 'sobrecubierta')
$builder->where("t1.sobrecubierta", 1);
else if ($uso == 'guardas')
$builder->where("t1.guardas", 1);
else {
$builder->where("t1.interior", 1);
if ($tipo == 'negro' || $tipo == 'negrohq')
$builder->where("t1.bn", 1);
else if ($tipo == 'color' || $tipo == 'colorhq')
$builder->where("t1.color", 1);
}
if ($uso == 'rotativa')
if ($uso == 'rotativa') {
$builder->where("t1.rotativa", 1);
else
$builder->where("t4.is_rotativa", 1);
} else
$builder->where("t1.rotativa", 0);
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
if ($forInkjet)
$builder->where("t1.inkjet", 1);
return $builder;
}
public function getNombre($id)
@ -355,5 +369,5 @@ class PapelImpresionModel extends \App\Models\BaseModel
return "";
}
}

View File

@ -72,25 +72,37 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
$tarifa_value = $modelTarifa->getTarifaPresupuestoAcabado($tarifa_acabado_id, $tirada, $proveedor_id);
if (count($tarifa_value)>0) {
$result_data = $this->calcularTarifa($tarifa_value[0], $tirada, $POD<$tirada?false:true);
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_value[0]->tarifa_acabado_id,
'tarifa_nombre'=> $tarifa_value[0]->tarifa_acabado_nombre,
'precio_unidad'=> $result_data[0],
'total'=> $result_data[1],
'margen'=> $result_data[2],
'proveedor' => $tarifa_value[0]->proveedor_nombre,
'proveedor_id' => $tarifa_value[0]->proveedor_id,
];
$ret_array = [];
foreach ($tarifa_value as $tarifa) {
$result_data = $this->calcularTarifa($tarifa, $tirada, $POD<$tirada?false:true);
array_push($ret_array, (object)[
'tarifa_id'=> $tarifa->tarifa_acabado_id,
'tarifa_nombre'=> $tarifa->tarifa_acabado_nombre,
'nombre'=> $tarifa->tarifa_acabado_nombre,
'precio_unidad'=> round($result_data[0], 2),
'total'=> round($result_data[1], 2),
'precio_total'=> round($result_data[1], 2),
'margen'=> $result_data[2],
'proveedor' => $tarifa->proveedor_nombre,
'proveedor_id' => $tarifa->proveedor_id,
]);
}
usort($ret_array, function($a, $b) {
return $a->precio_total <=> $b->precio_total;
});
return $ret_array;
}
else{
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_acabado_id,
'tarifa_nombre'=> $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre,
'nombre'=> $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre,
'precio_unidad' => 0,
'total' => 0,
'precio_total' => 0,
'margen' => 0,
'total'=> 0,
'proveedor' => '',
'proveedor_id' => 0,
];
return $ret_array;
}
@ -194,7 +206,7 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.precio_unidad AS precio_unidad,
"t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.tarifa_acabado_id AS tarifa_id, t1.precio_unidad AS precio_unidad,
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre, t1.cubierta AS cubierta, t1.sobrecubierta AS sobrecubierta,
t1.proveedor_id AS proveedor_id, t3.nombre AS proveedor,"
);

View File

@ -84,9 +84,11 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
$datos = [
'tarifa_id'=> $tarifa['tarifa_id'],
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
'nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
'precio_unidad'=> $result_data[0],
'tiempo' => $tiempo,
'total'=> $result_data[1],
'precio_total'=> $result_data[1],
'margen' => $result_data[2],
'proveedor' => $tarifa_proveedor->proveedor_nombre,
'proveedor_id' => $tarifa_proveedor->proveedor_id,
@ -117,10 +119,12 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
(object)[
'tarifa_id'=> $tarifa['tarifa_id'],
'tarifa_nombre'=> $tarifa['tarifa_nombre'],
'nombre'=> $tarifa['tarifa_nombre'],
'proveedor' => lang('Presupuestos.no_disponible'),
'precio_unidad'=> 0,
'tiempo' => null,
'total'=> 0,
'precio_total'=> 0,
'margen' => 0,
]);
}
@ -135,9 +139,11 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
array_push($result_array, (object)[
'tarifa_id'=> $tarifa_proveedor->tarifa_enc_id,
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
'nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
'precio_unidad'=> $result_data[0],
'tiempo' => null,
'total'=> $result_data[1],
'precio_total'=> $result_data[1],
'margen'=> $result_data[2],
'proveedor' => $tarifa_proveedor->proveedor_nombre,
'proveedor_id' => $tarifa_proveedor->proveedor_id,
@ -159,10 +165,12 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
(object)[
'tarifa_id'=> $tarifa['tarifa_id'] ,
'tarifa_nombre'=> $tarifa['tarifa_nombre'],
'nombre'=> $tarifa['tarifa_nombre'],
'proveedor' => lang('Presupuestos.no_disponible'),
'precio_unidad'=> 0,
'tiempo' => null,
'total'=> 0,
'precio_total'=> 0,
'margen' => 0,
]);
}
@ -173,17 +181,17 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
}
public function getProveedoresForSelector($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto){
public function getProveedoresForSelector($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $paginasCuadernillo = 32){
$proveedores = [];
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
if($modelTarifa->isTarifaPorHoras($tarifa_encuadernacion_id)){
$tiempo = $this->calcularTiempoCosido(16, $paginas, $tirada, $paginasCuadernillo); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa_encuadernacion_id, $tiempo, $tirada);
}
else{
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacion($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto);
}
if (count($tarifa_value)>0) {
@ -215,9 +223,11 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
array_push($ret_array, (object)[
'tarifa_id'=> $tarifa->tarifa_enc_id,
'tarifa_nombre'=> $tarifa->tarifa_enc_nombre,
'nombre'=> $tarifa->tarifa_enc_nombre,
'precio_unidad'=> $result_data[0],
'tiempo' => null,
'total'=> $result_data[1],
'precio_total'=> $result_data[1],
'margen'=> $result_data[2],
'proveedor' => $tarifa->proveedor_nombre,
'proveedor_id' => $tarifa->proveedor_id,
@ -237,10 +247,12 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_encuadernacion_id,
'tarifa_nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
'nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
'proveedor' => lang('Presupuestos.no_disponible'),
'precio_unidad'=> 0,
'tiempo' => null,
'total'=> 0,
'precio_total'=> 0,
'margen'=> 0,
];
return $ret_array;
@ -286,9 +298,11 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
(object)[
'tarifa_id'=> $tarifa_proveedor->tarifa_enc_id,
'tarifa_nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
'nombre'=> $tarifa_proveedor->tarifa_enc_nombre,
'precio_unidad'=> $result_data[0],
'tiempo' => $tiempo,
'paginas_por_cuadernillo' => $paginas_cuadernillo,
'precio_total'=> $result_data[1],
'total'=> $result_data[1],
'margen' => $result_data[2],
'proveedor' => $tarifa_proveedor->proveedor_nombre,
@ -310,11 +324,13 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_encuadernacion_id,
'tarifa_nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
'nombre'=> $modelTarifa->getNombreTarifaEncuadernacion($tarifa_encuadernacion_id)[0]->nombre,
'proveedor' => lang('Presupuestos.no_disponible'),
'precio_unidad'=> 0,
'tiempo' => null,
'paginas_por_cuadernillo' => null,
'total'=> 0,
'precio_total'=> 0,
'margen' => 0,
];
return $ret_array;

View File

@ -50,28 +50,37 @@ class PresupuestoManipuladosModel extends \App\Models\BaseModel
$modelTarifa = model('App\Models\Tarifas\TarifaManipuladoModel');
$tarifa_value = $modelTarifa->getTarifaPresupuestoManipulado($tarifa_manipulado_id, $tirada);
if (count($tarifa_value)>0) {
$ret_array = [];
foreach($tarifa_value as $tarifa){
$result_data = $this->calcularTarifa($tarifa, $tirada, $POD<$tirada?false:true);
array_push($ret_array, (object)[
'tarifa_id'=> $tarifa->tarifa_manipulado_id,
'tarifa_nombre'=> $tarifa->tarifa_manipulado_nombre,
'nombre'=> $tarifa->tarifa_manipulado_nombre,
'precio_unidad'=> $result_data[0],
'total'=> $result_data[1],
'precio_total'=> $result_data[1],
'margen' => $result_data[2],
]);
}
usort($ret_array, function($a, $b) {
return $a->precio_total <=> $b->precio_total;
});
$result_data = $this->calcularTarifa($tarifa_value[0], $tirada, $POD<$tirada?false:true);
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_value[0]->tarifa_manipulado_id,
'tarifa_nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre,
'precio_unidad'=> $result_data[0],
'total'=> $result_data[1],
'margen' => $result_data[2],
];
return $ret_array;
}
else{
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_manipulado_id,
'tarifa_nombre'=> $modelTarifa->getNombreTarifaManipulado($tarifa_manipulado_id)[0]->nombre,
'nombre'=> $modelTarifa->getNombreTarifaManipulado($tarifa_manipulado_id)[0]->nombre,
'precio_unidad' => 0,
'total'=> 0,
'margen' => 0,
];
return $ret_array;
}
return [];
}
private function calcularTarifa($tarifa, $tirada, $is_POD=false){
@ -170,8 +179,10 @@ class PresupuestoManipuladosModel extends \App\Models\BaseModel
array_push($tarifas, (object)[
'tarifa_id'=> $tarifa_value[0]->tarifa_manipulado_id,
'tarifa_nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre,
'nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre,
'precio_unidad'=> $result_data[0],
'total'=> $result_data[1],
'precio_total'=> $result_data[1],
'margen'=> $result_data[2],
]);
}
@ -180,8 +191,10 @@ class PresupuestoManipuladosModel extends \App\Models\BaseModel
(object)[
'tarifa_id'=> $tarifa['tarifa_id'] ,
'tarifa_nombre'=> $tarifa['tarifa_nombre'],
'nombre'=> $tarifa['tarifa_nombre'],
'precio_unidad' => 0,
'total'=> 0,
'precio_total'=> 0,
'margen' => 0,
]);
}

View File

@ -54,7 +54,6 @@ class PresupuestoModel extends \App\Models\BaseModel
"retractilado",
"retractilado5",
"guardas",
"faja_color",
"recoger_en_taller",
"ferro",
"ferro_digital",
@ -76,6 +75,9 @@ class PresupuestoModel extends \App\Models\BaseModel
"solapas_ancho",
"solapas_sobrecubierta",
"solapas_ancho_sobrecubierta",
"solapas_ancho_faja_color",
"faja_color",
"alto_faja_color",
"cosido",
"sobrecubiertas",
"sobrecubiertas_ancho",
@ -85,6 +87,7 @@ class PresupuestoModel extends \App\Models\BaseModel
"comentarios_safekat",
"comentarios_pdf",
"comentarios_tarifa",
"comentarios_presupuesto",
"comentarios_produccion",
"lomo_cubierta",
"lomo_sobrecubierta",
@ -132,6 +135,7 @@ class PresupuestoModel extends \App\Models\BaseModel
'paginasCuadernillo',
'lomo_redondo',
'cabezada',
'envio_base',
];
protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity";
@ -412,6 +416,7 @@ class PresupuestoModel extends \App\Models\BaseModel
'ferro_digital' => $data['ferro_digital'] ? 1 : 0,
'marcapaginas' => $data['marcapaginas'] ? 1 : 0,
'prototipo' => $data['prototipo'] ? 1 : 0,
'envio_base' => $data['envio_base'],
'papel_formato_id' => is_null($papel_formato_id) ? 0 : $papel_formato_id->id,
'papel_formato_personalizado' => !$papel_formato_id ? 1 : 0,
'papel_formato_ancho' => !$papel_formato_id ? $data['tamanio']['ancho'] : null,
@ -557,7 +562,7 @@ class PresupuestoModel extends \App\Models\BaseModel
// -- SOBRECUBIERTA --
if ($data['sobrecubierta']) {
$values['sobrecubierta'] = array(
'papel_id' => intval($data['sobrecubierta']['papel']),
'papel_id' => intval($data['sobrecubierta']['papel']['id']),
'gramaje' => intval($data['sobrecubierta']['gramaje']),
'imprimir' => 1,
);

View File

@ -51,19 +51,30 @@ class PresupuestoPreimpresionesModel extends \App\Models\BaseModel
$tarifa_value = $modelTarifa->getTarifaPresupuestoPreimpresion($tarifa_preimpresion_id);
if (count($tarifa_value)>0) {
$result_data = $this->calcularTarifa($tarifa_value[0]);
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_value[0]->tarifa_preimpresion_id,
'tarifa_nombre'=> $tarifa_value[0]->tarifa_preimpresion_nombre,
'precio'=> $result_data[0],
'margen'=> $result_data[1],
];
$ret_array = [];
foreach ($tarifa_value as $tarifa) {
$result_data = $this->calcularTarifa($tarifa);
array_push($ret_array, (object)[
'tarifa_id'=> $tarifa->tarifa_preimpresion_id,
'tarifa_nombre'=> $tarifa->tarifa_preimpresion_nombre,
'nombre'=> $tarifa->tarifa_preimpresion_nombre,
'precio'=> $result_data[0],
'margen'=> $result_data[1],
]);
}
usort($ret_array, function($a, $b) {
return $a->precio <=> $b->precio;
});
return $ret_array;
}
else{
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_preimpresion_id,
'tarifa_nombre'=> $modelTarifa->getNombreTarifaPreimpresion($tarifa_preimpresion_id)[0]->nombre,
'nombre'=> $modelTarifa->getNombreTarifaPreimpresion($tarifa_preimpresion_id)[0]->nombre,
'precio' => 0,
'margen' => 0,
];
@ -146,7 +157,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\BaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.precio AS precio, t1.margen AS margen, t2.nombre AS nombre"
"t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.tarifa_preimpresion_id AS tarifa_id, t1.precio AS precio, t1.margen AS margen, t2.nombre AS nombre"
);
$builder->where('t1.presupuesto_id', $presupuesto_id);

View File

@ -50,19 +50,27 @@ class PresupuestoServiciosExtraModel extends \App\Models\BaseModel
$tarifa_value = $modelTarifa->getTarifaPresupuestoExtra($tarifa_extra_id);
if (count($tarifa_value)>0) {
$result_data = $this->calcularTarifa($tarifa_value[0]);
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_value[0]->tarifa_extra_id,
'tarifa_nombre'=> $tarifa_value[0]->tarifa_extra_nombre,
'precio'=> $result_data[0],
'margen'=> $result_data[1],
];
$ret_array = [];
foreach($tarifa_value as $tarifa){
$result_data = $this->calcularTarifa($tarifa);
array_push($ret_array, (object)[
'tarifa_id'=> $tarifa->tarifa_extra_id,
'tarifa_nombre'=> $tarifa->tarifa_extra_nombre,
'nombre'=> $tarifa->tarifa_extra_nombre,
'precio'=> $result_data[0],
'margen'=> $result_data[1],
]);
}
usort($ret_array, function($a, $b) {
return $a->precio <=> $b->precio;
});
return $ret_array;
}
else{
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_extra_id,
'tarifa_nombre'=> $modelTarifa->getNombreTarifaExtra($tarifa_extra_id)[0]->nombre,
'tarifa'=> $modelTarifa->getNombreTarifaExtra($tarifa_extra_id)[0]->nombre,
'precio' => 0,
'margen' => 0,
];

View File

@ -98,11 +98,13 @@ class TarifaEnvioModel extends \App\Models\BaseModel
// Si el pais es españa se tienen que tener en cuenta los postales
// Se busca primero la tarifa a la que corresponde
$builder = $this->db->table($this->table . " t1")
->select("t1.id AS tarifa_envio_id, t2.importe_fijo as importe_fijo")
->select("t1.id AS tarifa_envio_id, t2.importe_fijo as importe_fijo, t3.nombre as pais")
->join("tarifas_envios_zonas t2", "t1.id = t2.tarifa_envio_id")
->join("lg_paises t3", "t1.pais_id = t3.id")
->where("t1.pais_id", $paisId)
->where("t1.is_deleted", 0)
->where("t2.is_deleted", 0);
if ($paisId == 1) { // España
$builder->where("CAST(t2.cp_inicial AS UNSIGNED)<=", intval($cp))
@ -117,10 +119,12 @@ class TarifaEnvioModel extends \App\Models\BaseModel
$precio_tarifas = $model->getEnvioPrecio($tarifa->tarifa_envio_id, $peso, $tipo_envio);
foreach ($precio_tarifas as $precio_tarifa) {
$precio_tarifa->importe_fijo = $tarifa->importe_fijo;
$precio_tarifa->pais = $tarifa->pais;
array_push($resultado, $precio_tarifa);
}
}
return $resultado;
}
}

View File

@ -20,14 +20,13 @@ class UserModel extends \App\Models\BaseModel
protected $allowedFields = [
"username",
"email",
"first_name",
"last_name",
"client_id",
"status",
"status_message",
"active",
"country",
"comments",
"last_active",
"created_at",
"updated_at",
@ -39,143 +38,25 @@ class UserModel extends \App\Models\BaseModel
protected $validationRules = [
"address" => [
"label" => "Users.address",
"rules" => "trim|max_length[255]",
],
"blocked" => [
"label" => "Users.blocked",
"rules" => "required|permit_empty",
],
"city" => [
"label" => "Users.city",
"rules" => "trim|max_length[255]",
],
"country" => [
"label" => "Users.country",
"rules" => "trim|max_length[2]",
],
"date_birth" => [
"label" => "Users.dateBirth",
"rules" => "valid_date|permit_empty",
],
"email" => [
"label" => "Users.email",
"rules" => "trim|required|max_length[150]|valid_email",
],
"email_confirmed" => [
"label" => "Users.emailConfirmed",
"rules" => "required|integer",
],
"first_name" => [
"label" => "Users.firstName",
"rules" => "trim|max_length[150]",
],
"language" => [
"label" => "Users.language",
"rules" => "trim|max_length[10]",
],/*
"last_access" => [
"label" => "Users.lastAccess",
"rules" => "valid_date",
],*/
"last_ip" => [
"label" => "Users.lastIp",
"rules" => "max_length[50]",
],
"last_name" => [
"label" => "Users.lastName",
"rules" => "trim|max_length[150]",
],
"mobile" => [
"label" => "Users.mobile",
"rules" => "trim|max_length[50]",
],
"password" => [
"label" => "Users.password",
"rules" => "required|max_length[35]",
],
"picture" => [
"label" => "Users.picture",
"rules" => "trim|max_length[150]",
],
"state" => [
"label" => "Users.state",
"rules" => "trim|max_length[255]",
],
"zip_code" => [
"label" => "Users.zipCode",
"rules" => "trim|max_length[50]",
],
];
protected $validationMessages = [
"address" => [
"max_length" => "Users.validation.address.max_length",
],
"blocked" => [
"required" => "Users.validation.email_confirmed.required",
],
"city" => [
"max_length" => "Users.validation.city.max_length",
],
"country" => [
"max_length" => "Users.validation.country.max_length",
"required" => "Users.validation.country.required",
],
"date_birth" => [
"valid_date" => "Users.validation.date_birth.valid_date",
],
"email" => [
"max_length" => "Users.validation.email.max_length",
"required" => "Users.validation.email.required",
"valid_email" => "Users.validation.email.valid_email",
],
"email_confirmed" => [
"integer" => "Users.validation.email_confirmed.integer",
"required" => "Users.validation.email_confirmed.required",
],
"first_name" => [
"max_length" => "Users.validation.first_name.max_length",
"required" => "Users.validation.first_name.required",
],
"language" => [
"max_length" => "Users.validation.language.max_length",
"required" => "Users.validation.language.required",
],
"last_access" => [
"required" => "Users.validation.last_access.required",
"valid_date" => "Users.validation.last_access.valid_date",
],
"last_ip" => [
"max_length" => "Users.validation.last_ip.max_length",
"required" => "Users.validation.last_ip.required",
],
"last_name" => [
"max_length" => "Users.validation.last_name.max_length",
"required" => "Users.validation.last_name.required",
],
"mobile" => [
"max_length" => "Users.validation.mobile.max_length",
"required" => "Users.validation.mobile.required",
],
"password" => [
"max_length" => "Users.validation.password.max_length",
"required" => "Users.validation.password.required",
],
"picture" => [
"max_length" => "Users.validation.picture.max_length",
"required" => "Users.validation.picture.required",
],
"state" => [
"max_length" => "Users.validation.state.max_length",
"required" => "Users.validation.state.required",
],
"zip_code" => [
"max_length" => "Users.validation.zip_code.max_length",
],
],
];
public function getGroupsTitles($user_token){

View File

@ -0,0 +1,84 @@
<?php
namespace App\Services;
use App\Entities\Configuracion\Maquina;
use App\Models\Configuracion\MaquinaModel;
use App\Models\Configuracion\MaquinasCallesModel;
use App\Models\Configuracion\MaquinasDefectoModel;
use App\Models\Configuracion\MaquinasPapelesImpresionModel;
use App\Models\Configuracion\MaquinasTarifasImpresionModel;
use CodeIgniter\Config\BaseService;
class MaquinaService extends BaseService
{
protected Maquina $maquina;
protected MaquinaModel $maquinaModel;
protected MaquinasDefectoModel $maquinaDefectoModel;
protected MaquinasCallesModel $maquinaCalleModel;
protected MaquinasPapelesImpresionModel $maquinaPapelesImpresionModel;
protected MaquinasTarifasImpresionModel $maquinaTarifaImpresionModel;
public function __construct()
{
$this->maquinaModel = model(MaquinaModel::class);
$this->maquinaDefectoModel = model(MaquinasDefectoModel::class);
$this->maquinaCalleModel = model(MaquinasCallesModel::class);
$this->maquinaPapelesImpresionModel = model(MaquinasPapelesImpresionModel::class);
$this->maquinaTarifaImpresionModel = model(MaquinasTarifasImpresionModel::class);
}
public function setMaquina(int $maquina_id): self
{
$this->maquina = $this->maquinaModel->find($maquina_id);
return $this;
}
public function duplicate(string $newName): ?Maquina
{
$maquina_array = $this->maquina->toArray();
$maquina_array['nombre'] = $newName;
$maquinaDuplicatedId = $this->maquinaModel->insert($maquina_array);
$maquinaWithAllRelations = $this->maquina->withAll()->toArray();
$maquina_defecto = $maquinaWithAllRelations['maquina_defecto'];
$maquina_papeles_impresion = $maquinaWithAllRelations['papeles_impresion'];
$maquina_calles = $maquinaWithAllRelations['maquina_calles'];
$maquina_tarifas_impresion = $maquinaWithAllRelations['tarifas_impresion'];
foreach ($maquina_defecto as $md)
{
unset($md['id']);
$md['maquina_id'] = $maquinaDuplicatedId;
$this->maquinaDefectoModel->insert($md);
}
foreach ($maquina_papeles_impresion as $mpi)
{
unset($mpi['id']);
$mpi['maquina_id'] = $maquinaDuplicatedId;
$this->maquinaPapelesImpresionModel->insert($mpi);
}
foreach ($maquina_calles as $mc)
{
unset($mc['id']);
$mc['maquina_id'] = $maquinaDuplicatedId;
$this->maquinaCalleModel->insert($mc);
}
foreach ($maquina_tarifas_impresion as $mti)
{
unset($mti['id']);
$mti['maquina_id'] = $maquinaDuplicatedId;
$this->maquinaTarifaImpresionModel->insert($mti);
}
return $this->maquinaModel->find($maquinaDuplicatedId)->withAll();
}
}

View File

@ -0,0 +1,76 @@
<?php
namespace App\Services;
use App\Entities\Configuracion\PapelImpresion;
use App\Models\Configuracion\MaquinasPapelesImpresionModel;
use App\Models\Configuracion\PapelImpresionMargenModel;
use App\Models\Configuracion\PapelImpresionModel;
use App\Models\Configuracion\PapelImpresionTipologiaModel;
use CodeIgniter\Config\BaseService;
class PapelImpresionService extends BaseService
{
protected PapelImpresionModel $papelImpresionModel;
protected PapelImpresionTipologiaModel $papelImpresionTipologiaModel;
protected MaquinasPapelesImpresionModel $maquinaPapelImpresionModel;
protected PapelImpresionMargenModel $papelImpresionMargenModel;
protected MaquinasPapelesImpresionModel $papelImpresionMaquinaModel;
protected PapelImpresion $papelImpresion;
public function __construct()
{
$this->papelImpresionModel = model(PapelImpresionModel::class);
$this->papelImpresionModel = model(PapelImpresionModel::class);
$this->papelImpresionMargenModel = model(PapelImpresionMargenModel::class);
$this->papelImpresionTipologiaModel = model(PapelImpresionTipologiaModel::class);
$this->papelImpresionMaquinaModel = model(MaquinasPapelesImpresionModel::class);
}
public function setPapelImpresionEntity(PapelImpresion $papelImpresionEntity): self
{
$this->papelImpresion = $papelImpresionEntity;
return $this;
}
public function duplicate(string $newName): ?PapelImpresion
{
$papelImpresionRow = $this->papelImpresion?->toArray();
$papelImpresionMargenes = $this->papelImpresion->margen();
$papelImpresionTipologias = $this->papelImpresion->tipologia();
$papelImpresionMaquinas = $this->papelImpresion->maquinas_impresion();
$papelImpresionRow['nombre'] = $newName;
if ($this->papelImpresion) {
unset($papelImpresionRow["id"]);
$papelImpresionDuplicatedId = $this->papelImpresionModel->insert($papelImpresionRow);
}
if ($papelImpresionMargenes) {
foreach ($papelImpresionMargenes as $papelImpresionMargen) {
unset($papelImpresionMargen["id"]);
$papelImpresionMargen['papel_impresion_id'] = $papelImpresionDuplicatedId;
$this->papelImpresionMargenModel->insert($papelImpresionMargen);
}
}
if ($papelImpresionTipologias) {
foreach ($papelImpresionTipologias as $papelImpresionTipologia) {
unset($papelImpresionTipologia["id"]);
$papelImpresionTipologia['papel_impresion_id'] = $papelImpresionDuplicatedId;
$this->papelImpresionTipologiaModel->insert($papelImpresionTipologia);
}
}
if ($papelImpresionMaquinas) {
foreach ($papelImpresionMaquinas as $papelImpresionMaquina) {
unset($papelImpresionMaquina["id"]);
$papelImpresionMaquina['papel_impresion_id'] = $papelImpresionDuplicatedId;
$this->papelImpresionMaquinaModel->insert($papelImpresionMaquina);
}
}
$papelImpresionDuplicated = $this->papelImpresionModel->find($papelImpresionDuplicatedId);
return $papelImpresionDuplicated;
}
}

View File

@ -65,7 +65,7 @@ class PresupuestoClienteService extends BaseService
}
}
public static function obtenerCubierta($data)
public static function obtenerCubierta($data, $return_raw=false)
{
$uso = $data['uso'];
@ -76,7 +76,6 @@ class PresupuestoClienteService extends BaseService
$isColor = $data['isColor'];
$isHq = $data['isHq'];
$cliente_id = $data['cliente_id'];
$paginas_color = $data['paginas_color'];
$lomoRedondo = $data['lomoRedondo'];
$lineas_cubierta = [];
@ -102,6 +101,14 @@ class PresupuestoClienteService extends BaseService
}
if (count($lineas_cubierta) > 0) {
if($return_raw){
$lineas_cubierta = array_values(array_unique($lineas_cubierta, SORT_REGULAR));
return[
'cubierta' => $lineas_cubierta
];
}
usort(
$lineas_cubierta,
function ($a, $b) {
@ -119,7 +126,7 @@ class PresupuestoClienteService extends BaseService
return $lineas_cubierta;
}
public static function obtenerSobrecubierta($data)
public static function obtenerSobrecubierta($data, $return_raw=false)
{
$uso = $data['uso'];
@ -154,6 +161,14 @@ class PresupuestoClienteService extends BaseService
}
if (count($lineas_sobrecubierta) > 0) {
if($return_raw){
$lineas_sobrecubierta = array_values(array_unique($lineas_sobrecubierta, SORT_REGULAR));
return[
'sobrecubierta' => $lineas_sobrecubierta
];
}
usort(
$lineas_sobrecubierta,
function ($a, $b) {
@ -171,7 +186,7 @@ class PresupuestoClienteService extends BaseService
return $lineas_sobrecubierta;
}
public static function obtenerGuardas($data)
public static function obtenerGuardas($data, $return_raw=false)
{
$uso = $data['uso'];
@ -205,6 +220,14 @@ class PresupuestoClienteService extends BaseService
}
if (count($lineas_guardas) > 0) {
if($return_raw){
$lineas_guardas = array_values(array_unique($lineas_guardas, SORT_REGULAR));
return[
'guardas' => $lineas_guardas
];
}
usort(
$lineas_guardas,
function ($a, $b) {
@ -241,28 +264,31 @@ class PresupuestoClienteService extends BaseService
* - isHq: si es alta calidad
* - paginas_color: número de páginas a color
*/
private static function obtenerPresupuestoClienteInterior($data)
public static function obtenerPresupuestoClienteInterior($data, $return_raw = false)
{
$uso = $data['uso'];
$tipo_impresion_id = $data['tipo_impresion_id'];
$datosPedido = $data['datosPedido'];
$paginas_color = $data['paginas_color'];
if ($data['papelInteriorDiferente'] == false)
$papel_generico = $data['papel_generico'];
else {
$papel_generico = $data['papel_generico']['negro'];
$papel_generico_color = $data['papel_generico']['color'];
if($paginas_color>0)
$papel_generico_color = $data['papel_generico']['color'];
}
if ($data['papelInteriorDiferente'] == false)
$gramaje = $data['gramaje'];
else {
$gramaje = $data['gramaje']['negro'];
$gramaje_color = $data['gramaje']['color'];
if($paginas_color>0)
$gramaje_color = $data['gramaje']['color'];
}
$isColor = $data['isColor'];
$isHq = $data['isHq'];
$cliente_id = $data['cliente_id'];
$paginas_color = $data['paginas_color'];
$paginas_negro = $datosPedido->paginas - $paginas_color;
@ -293,6 +319,14 @@ class PresupuestoClienteService extends BaseService
}
if (count($linea_negro_plana) > 0) {
/*if($return_raw){
$linea_negro_plana = array_values(array_unique($linea_color_plana, SORT_REGULAR));
return[
'negro' => $linea_negro_plana
];
}*/
usort(
$linea_negro_plana,
function ($a, $b) {
@ -335,6 +369,14 @@ class PresupuestoClienteService extends BaseService
}
if (count($linea_color_plana) > 0) {
/*if($return_raw){
$linea_color_plana = array_values(array_unique($linea_color_plana, SORT_REGULAR));
return[
'color' => $linea_color_plana
];
}*/
usort(
$linea_color_plana,
function ($a, $b) {
@ -349,6 +391,16 @@ class PresupuestoClienteService extends BaseService
}
}
if($return_raw){
$linea_negro_plana = array_values(array_unique($linea_negro_plana, SORT_REGULAR));
$linea_color_plana = array_values(array_unique($linea_color_plana, SORT_REGULAR));
return[
'negro' => $linea_negro_plana,
'color' => $linea_color_plana
];
}
// Si hay negro y color, y se hace con el mismo papel, hay que buscar la combinación
// más económica con la misma máquna
if (
@ -493,7 +545,7 @@ class PresupuestoClienteService extends BaseService
* - isHq: si es alta calidad
* - paginas_color: número de páginas a color
*/
private static function obtenerPresupuestoClienteInteriorRotativa($data)
public static function obtenerPresupuestoClienteInteriorRotativa($data, $return_raw = false)
{
$datosPedido = $data['datosPedido'];
$papel_generico = $data['papel_generico'];
@ -532,6 +584,14 @@ class PresupuestoClienteService extends BaseService
if (count($linea_rotativa) > 0) {
if($return_raw){
$linea_rotativa = array_values(array_unique($linea_rotativa, SORT_REGULAR));
return[
'rotativa' => $linea_rotativa,
];
}
usort(
$linea_rotativa,
function ($a, $b) {

View File

@ -83,8 +83,13 @@ class PresupuestoService extends BaseService
$parametrosInkjet->rotativa_cg = $datosTipologias[0]->cg;
}
$uso_tarifa = $uso;
if($uso == 'guardas')
$uso_tarifa = 'interior';
else if ($uso == 'faja')
$uso_tarifa = 'sobrecubierta';
$tarifamodel = new \App\Models\Configuracion\MaquinasTarifasImpresionModel();
$datos_tarifa = $tarifamodel->getTarifa($maquina->maquina_id, ($uso == 'guardas') ? 'interior' : $uso, $tipo);
$datos_tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso_tarifa, $tipo);
if (count($datos_tarifa) > 0) {
$tarifaId = $datos_tarifa[0];
$tarifa = $datos_tarifa[1];
@ -128,7 +133,7 @@ class PresupuestoService extends BaseService
$clientePreciosModel = new \App\Models\Clientes\ClientePreciosModel();
$config = (object) [
"tipo" => ($uso == 'guardas') ? 'interior' : $uso,
"tipo" => $uso_tarifa,
"tipo_maquina" => $maquina->is_inkjet ? 'inkjet' : 'toner',
"tipo_impresion" => $tipo
];
@ -235,7 +240,9 @@ class PresupuestoService extends BaseService
return [];
}
[$precio_pliego_impresion, $margen_pliego_impresion] = PresupuestoService::getPrecioPliego($maquina, $papel, $datosPedido->paginas);
$paginas_pedido = (intval($datosPedido->tirada) + intval($datosPedido->merma))*intval($datosPedido->paginas);
[$precio_pliego_impresion, $margen_pliego_impresion] = PresupuestoService::getPrecioPliego($maquina, $papel, $paginas_pedido);
$linea['fields']['tarifa_impresion_id'] = $tarifaId;
@ -332,8 +339,8 @@ class PresupuestoService extends BaseService
if ($uso != 'rotativa') {
$ancho_calculo = ($uso == 'cubierta' || $uso == 'sobrecubierta') ? $datosPedido->anchoExteriores : $datosPedido->ancho;
$alto_calculo = ($uso == 'cubierta' || $uso == 'sobrecubierta') ? $datosPedido->altoExteriores : $datosPedido->alto;
$ancho_calculo = ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'faja') ? $datosPedido->anchoExteriores : $datosPedido->ancho;
$alto_calculo = ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'faja') ? $datosPedido->altoExteriores : $datosPedido->alto;
$formas = PresupuestoService::getNumFormasPlana($uso, $maquina, $ancho_calculo, $alto_calculo, $datosPedido->isCosido, $forzar_a_favor_fibra);
$response['fields'] = $formas;
}
@ -345,8 +352,10 @@ class PresupuestoService extends BaseService
return $response;
}
$paginas_pedido = (intval($datosPedido->tirada) + intval($datosPedido->merma)) * intval($datosPedido->paginas);
// precio del pliego de impresion
[$precio_pliego_impresion, $margen_pliego_impresion] = PresupuestoService::getPrecioPliego($maquina, $papel_impresion, $datosPedido->paginas);
[$precio_pliego_impresion, $margen_pliego_impresion] = PresupuestoService::getPrecioPliego($maquina, $papel_impresion, $paginas_pedido);
$precio_click = 0;
$precio_click_pedido = 0;
@ -362,10 +371,12 @@ class PresupuestoService extends BaseService
$margen_click = $tarifa * ($tarifa_margen / 100.0);
//interior (bn o color)
if ($cubierta == 0 && $sobrecubierta == 0 && $rotativa == 0) {
if ($cubierta == 0 && $sobrecubierta == 0 && $rotativa == 0 || $uso == 'faja') {
// precio papel
$pliegos_libro = ceil(($datosPedido->paginas / 2.0) / $response['fields']['num_formas']['value']);
if ($pliegos_libro < 1)
$pliegos_libro = ($datosPedido->paginas / 2.0) / $response['fields']['num_formas']['value'];
if($uso != 'faja')
$pliegos_libro = ceil($pliegos_libro);
if ($uso != 'faja' && $pliegos_libro < 1) // faja pueden entrar más de una forma
$pliegos_libro = 1;
$pliegos_pedido = $pliegos_libro * ($datosPedido->tirada + $datosPedido->merma);
$precio_libro = $pliegos_libro * ($precio_pliego_impresion + $margen_pliego_impresion);
@ -462,7 +473,7 @@ class PresupuestoService extends BaseService
[$data['ancho'], $data['alto']] = PresupuestoService::calculoDimForma($datosPedido, $parametrosRotativa);
// calculo de papel y clicks
$factor_anchura = round($maquina->ancho_impresion / $data['ancho'], 2);
$factor_anchura = floor($maquina->ancho_impresion / $data['ancho']);
$factor_altura = round($maquina->alto_impresion / ($data['alto'] + self::MARGEN_PAGINAS_ROTATIVA), 2);
$factor_altura_click = round($maquina->alto_click / ($data['alto'] + self::MARGEN_PAGINAS_ROTATIVA), 2);
@ -471,12 +482,12 @@ class PresupuestoService extends BaseService
}
$multiplicador_pliego = $datosPedido->isCosido ? 4 : 2;
$paginas_por_pliego = round(floor($factor_anchura) * $factor_altura * $multiplicador_pliego, 2);
$paginas_por_pliego = round($factor_anchura * $factor_altura * $multiplicador_pliego, 2);
$pliegos_libro = round($paginas_por_pliego ? $datosPedido->paginas / $paginas_por_pliego : 0, 2);
$metros_papel_libro = round($pliegos_libro * ($maquina->alto_impresion / 1000.0), 2);
$metros_papel_total = round($metros_papel_libro * ($datosPedido->tirada + $datosPedido->merma), 2);
$paginas_por_pliego_click = round(floor($factor_anchura) * $factor_altura_click * $multiplicador_pliego, 2);
$paginas_por_pliego_click = round($factor_anchura * $factor_altura_click * $multiplicador_pliego, 2);
$pliegos_libro_click = round($paginas_por_pliego_click ? $datosPedido->paginas / $paginas_por_pliego_click : 0, 2);
$clicks_libro = round(ceil($pliegos_libro_click) * 2, 2);
$clicks_pedido = round($clicks_libro * ($datosPedido->tirada + $datosPedido->merma), 2);
@ -518,12 +529,15 @@ class PresupuestoService extends BaseService
$data['alto_click'] = $maquina->alto_click;
$direccion_fibra = ($parametrosRotativa->a_favor_fibra === "false" || $parametrosRotativa->a_favor_fibra === 0 ||
$parametrosRotativa->a_favor_fibra === "0" || $parametrosRotativa->a_favor_fibra === false)? 0 : 1;
$formas = PresupuestoService::getNumFormasRot(
$maquina,
$datosPedido->ancho,
$datosPedido->alto,
$datosPedido->isCosido,
$parametrosRotativa->a_favor_fibra
$direccion_fibra
);
$data['num_formas'] = $formas;
@ -537,7 +551,7 @@ class PresupuestoService extends BaseService
public static function calculoDimForma($datosPedido, $parametros)
{
// posicionamos paginas en función de a favor de fibra o no
if (!$parametros->a_favor_fibra) {
if ($parametros->a_favor_fibra === "false" || $parametros->a_favor_fibra === 0 || $parametros->a_favor_fibra === "0" || $parametros->a_favor_fibra === false) {
$anchoLibro = $datosPedido->alto;
$altoLibro = $datosPedido->ancho;
} else {
@ -547,7 +561,7 @@ class PresupuestoService extends BaseService
// si es cosido ancho x 2
if ($datosPedido->isCosido) {
if (!$parametros->a_favor_fibra) {
if ($parametros->a_favor_fibra === "false" || $parametros->a_favor_fibra === 0 || $parametros->a_favor_fibra === "0" || $parametros->a_favor_fibra === false) {
$altoLibro = $altoLibro * 2;
} else {
$anchoLibro = $anchoLibro * 2;
@ -686,7 +700,7 @@ class PresupuestoService extends BaseService
$h2_temp = 0;
// El ancho si es cosido es el doble
if ($uso != 'cubierta' && $uso != 'sobrecubierta') {
if ($uso != 'cubierta' && $uso != 'sobrecubierta' && $uso != 'faja') {
$anchoForCalculo = $isCosido ? $ancho * 2 : $ancho;
} else {
$anchoForCalculo = $ancho;
@ -843,7 +857,7 @@ class PresupuestoService extends BaseService
$ancho_total = 0;
$sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA;
if ($datosPedido->ancho >= 210) {
$sangre_cubierta = 15;
$sangre_cubierta = 10;
}
if ($datosPedido) {
@ -924,8 +938,8 @@ class PresupuestoService extends BaseService
if ($datosPedido) {
$alto_total = floatval($datosPedido->alto);
$sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA;
if ($datosPedido->alto >= 297) {
$sangre_cubierta = 15;
if ($datosPedido->alto >= 267) {
$sangre_cubierta = 10;
}
// Tapa dura (cosido y fresado)
if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) {
@ -938,7 +952,7 @@ class PresupuestoService extends BaseService
$alto_total += (7 + 2 * self::SANGRE_FORMAS);
}
// Tapa dura (espiral y wire-0)
if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) {
else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 7) {
// Sólo se le añade los 20mm de sangre por cada lado
$alto_total += (2 * self::SANGRE_FORMAS_CUBIERTA);
}
@ -1687,7 +1701,7 @@ class PresupuestoService extends BaseService
uso_tarifa: $uso,
tirada: $datosPedido->tirada + $datosPedido->merma,
papel_impresion_id: $papel->id,
);
)->orderBy("t1.id", "asc")->get()->getResultObject();
$data['uso'] = $uso;
$data['tipo'] = $tipo;
@ -1754,7 +1768,8 @@ class PresupuestoService extends BaseService
$tipo = $isColor ? ($isHq ? 'colorhq' : 'color') : ($isHq ? 'negrohq' : 'negro');
$opciones_papel = PresupuestoService::get_opciones_papel($uso, $isColor);
$uso_papel = $uso == 'faja' ? 'sobrecubierta': $uso;
$opciones_papel = PresupuestoService::get_opciones_papel($uso_papel, $isColor);
// Se obtienen los papeles disponibles
$papelimpresionmodel = new PapelImpresionModel();
@ -1772,18 +1787,18 @@ class PresupuestoService extends BaseService
$maquinas = $maquinamodel->getMaquinaImpresionForPresupuesto(
is_rotativa: 0,
tarifa_tipo: $tipo,
uso_tarifa: ($uso == 'guardas') ? 'interior' : $uso,
uso_tarifa: ($uso == 'guardas') ? 'interior' : $uso_papel,
tirada: $datosPedido->tirada + $datosPedido->merma,
papel_impresion_id: $papel->id,
);
)->orderBy("t1.id", "asc")->get()->getResultObject();
// Se recorren las máquinas y se calcula el coste de linea por cada una
foreach ($maquinas as $maquina) {
if ($uso == 'cubierta' || $uso == 'sobrecubierta') {
if ($uso == 'cubierta' || $uso == 'sobrecubierta' || $uso == 'faja') {
$datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($uso, $tipo_impresion_id, $datosPedido, $maquina->maquina_id, $lomoRedondo);
$datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($uso, $tipo_impresion_id, $datosPedido);
$datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($uso_papel, $tipo_impresion_id, $datosPedido, $maquina->maquina_id, $lomoRedondo);
$datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($uso_papel, $tipo_impresion_id, $datosPedido);
}
$data['uso'] = $uso;

View File

@ -0,0 +1,43 @@
<div class="accordion accordion-bordered mt-3" id="accordionPresupuestoFiles">
<div class="card accordion-item">
<h2 class="accordion-header" id="headingPresupuestoFiles">
<button type="button" class="accordion-button collapsed" data-bs-toggle="collapse"
data-bs-target="#accordionPresupuestoFilesTip" aria-expanded="false"
aria-controls="accordionPresupuestoFilesTip">
<h3><?= lang("Presupuestos.files") ?></h3>
</button>
</h2>
<div id="accordionPresupuestoFilesTip" class="accordion-collapse collapse"
data-bs-parent="#accordionPresupuestoFiles">
<div class="accordion-body">
<div class="col-12">
<div class="dropzone needsclick" id="<?= $id ?>" data-id="<?= $modelId ?>">
<div class="dz-message needsclick">
Arrastre aquí los ficheros o haga click
</div>
<div class="fallback">
<input name="file" type="file" />
</div>
</div>
</div>
<div class="col-md-12 gap-2">
<button id="<?= $id ?>_btnUploadFiles" class="btn mt-3 btn-primary btn-submit waves-effect waves-light ml-2 ">
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('App.global_upload_files') ?></span>
<i class="ti ti-upload ti-xs"></i>
</button>
<button id="<?= $id ?>_btnSubmitFiles" class="btn mt-3 btn-success btn-submit waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('App.global_save_file') ?></span>
<i class="ti ti-device-floppy ti-xs"></i>
</button>
</div>
</div>
</div>
</div>
</div>
<?= $this->section('css') ?>
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/dropzone/dropzone.css') ?>" />
<?= $this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("themes/vuexy/vendor/libs/dropzone/dropzone.js") ?>"></script>
<?= $this->endSection() ?>

View File

@ -0,0 +1,23 @@
<form class="form-control" id="<?= $id ?>" data-id="<?= $model?->id ?>">
<div class="row mb-2">
<!-- Servicio cliente nombre-->
<div class="col-xs-12 col-md-12 col-lg-12 mb-2">
<label for="servicio-cliente-nombre" class="form-label"><?= @lang("MaquinaTarea.datatable.nombre") ?></label>
<input type="text" class="form-control" name="name" id="maquina-tarea-nombre">
</div>
<!-- Servicio cliente code-->
<div class="col-xs-12 col-md-12 col-lg-12 mb-2">
<label for="servicio-cliente-code" class="form-label"><?= @lang("MaquinaTarea.datatable.description") ?></label>
<textarea type="text" rows="5" cols="5" class="form-control" name="description" id="maquina-tarea-description"></textarea>
</div>
</div>
<div class="row mb-2">
<div class="col-md-12 d-flex justify-content-start gap-4">
<button type="button" class="btn btn-primary btn-md d-none" id="btn-new-maquina-tarea"><?= lang("App.global_save") ?></button>
<button type="button" class="btn btn-primary btn-md d-none" id="btn-update-maquina-tarea"><?= lang("App.global_save") ?></button>
<a href="<?= route_to("maquinaTareaList")?>" type="button" class="btn btn-secondary btn-md d-none" id="btn-come-back"><?= lang("App.global_come_back") ?></button>
</div>
</div>
</form>

View File

@ -1,61 +0,0 @@
<form class="form-control" id="<?= $id ?>" data-id="<?= $model->id ?>">
<div class="row mb-2">
<!-- Servicio cliente nombre-->
<div class="col-xs-12 col-md-6 col-lg-6 mb-2">
<label for="servicio-cliente-nombre" class="form-label"><?= @lang("ServicioCliente.datatable.nombre") ?></label>
<input type="text" class="form-control" name="nombre" id="servicio-cliente-nombre">
</div>
<!-- Servicio cliente code-->
<div class="col-xs-12 col-md-6 col-lg-6 mb-2">
<label for="servicio-cliente-code" class="form-label"><?= @lang("ServicioCliente.datatable.code") ?></label>
<input type="text" class="form-control" name="code" id="servicio-cliente-code">
</div>
<!-- Tarifa acabado asociada a servicio -->
<div class="col-xs-12 col-md-8 col-lg-6 mb-2" id="container-tarifa-acabado-select">
<label for="servicio-cliente-tarifa-acabado" class="form-label"><?= @lang("Tarifaacabado.tarifaacabado") ?></label>
<select class="select2 form-select" name="tarifa_acabado_id" id="servicio-cliente-tarifa-acabado" placeholder="<?= @lang("Tarifaacabado.tarifasacabado") ?>">
</select>
<div class="form-text"><?= @lang("ServicioCliente.infoTarifaAcabado") ?></div>
</div>
<!-- Tarifa manipulado asociada a servicio-->
<div class="col-xs-12 col-md-8 col-lg-6 mb-2 d-none" id="container-tarifa-manipulado-select">
<label for="servicio-cliente-tarifa-manipulado" class="form-label"><?= @lang("Tarifamanipulado.tarifamanipulado") ?></label>
<select class="select2 form-select" name="tarifa_manipulado_id" id="servicio-cliente-tarifa-manipulado" placeholder="<?= @lang("Tarifamanipulado.tarifasmanipulado") ?>">
</select>
<div class="form-text"><?= @lang("ServicioCliente.infoTarifaManipulado") ?></div>
</div>
<!-- Check tarifa acabado o manipulado -->
<div class="col-xs-12 col-md-4 col-lg-6 mb-2">
<div class="text-light small fw-medium mb-2">Seleccione tipo de tarifa</div>
<div class="switches-stacked">
<label class="switch">
<input type="radio" class="switch-input" id="check-tarifa-acabado" name="switches-stacked-radio" checked />
<span class="switch-toggle-slider">
<span class="switch-on"></span>
<span class="switch-off"></span>
</span>
<span class="switch-label"><?= @lang("Tarifaacabado.tarifasacabado") ?></span>
</label>
<label class="switch">
<input type="radio" class="switch-input" id="check-tarifa-manipulado" name="switches-stacked-radio" />
<span class="switch-toggle-slider">
<span class="switch-on"></span>
<span class="switch-off"></span>
</span>
<span class="switch-label"><?= @lang("Tarifamanipulado.tarifasmanipulado") ?></span>
</label>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col-md-12 d-flex justify-content-start gap-4">
<button type="button" class="btn btn-primary btn-md d-none" id="btn-new-servicio-cliente"><?= lang("App.global_save") ?></button>
<button type="button" class="btn btn-primary btn-md d-none" id="btn-update-servicio-cliente"><?= lang("App.global_save") ?></button>
<button type="button" class="btn btn-secondary btn-md"><?= lang("App.global_come_back") ?></button>
</div>
</div>
</form>

View File

@ -2,9 +2,9 @@
<table id="<?= $id ?>" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('ServicioCliente.datatable.nombre') ?></th>
<th><?= lang('ServicioCliente.datatable.code') ?></th>
<th><?= lang('ServicioCliente.datatable.created_at') ?></th>
<th><?= lang('MaquinaTarea.datatable.nombre') ?></th>
<th><?= lang('MaquinaTarea.datatable.description') ?></th>
<th><?= lang('MaquinaTarea.datatable.created_at') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>

View File

@ -9,14 +9,14 @@
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= lang('ServicioCliente.cardTitle') ?></h3>
<h3 class="card-title"><?= $model->name ?></h3>
</div>
<!--//.card-header -->
<div class="card-body" id="serviciosClienteCard">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<?= view('themes/vuexy/components/forms/servicio_cliente', ["id" => "formServicioCliente"]); ?>
<?= view('themes/vuexy/components/forms/maquina_tarea', ["id" => "maquina-tarea-form", "model" => $model]); ?>
</div>
<!--//.card-body -->
@ -31,7 +31,15 @@
</div>
<!--//.row -->
<?= $this->endSection() ?>
<?= $this->section('css') ?>
<link rel="stylesheet" href="<?= site_url("themes/vuexy/vendor/libs/dropzone/dropzone.css") ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/spinkit/spinkit.css') ?>" />
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
<?= $this->endSection() ?>
<?= $this->section("additionalExternalJs") ?>
<script type="module" src="<?= site_url("assets/js/safekat/pages/configuracion/servicio_cliente/edit.js") ?>">
</script>
<script type="module" src="<?= site_url("assets/js/safekat/pages/configuracion/maquina_tarea/edit.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -0,0 +1,56 @@
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?= $this->section('content'); ?>
<div class="row">
<div class="col-md-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= lang('MaquinaTarea.cardTitle') ?></h3>
</div>
<!--//.card-header -->
<div class="card-body" id="maquinaTareaCard">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<div class="col-md-12 d-flex justify-content-end">
<button type="button" class="btn-primary btn btn-md" id="btn-maquina-tarea-new">
<i class="ti ti-plus ti-xs"></i> &nbsp; <?= lang("MaquinaTarea.tarea_new") ?>
</button>
</div>
<?= view('themes/vuexy/components/tables/maquina_tarea_table', ["id" => "maquina-tarea-datatable"]); ?>
<div class="modal fade" id="modalNewMaquinaTarea" tabindex="-1" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3><?= lang("MaquinaTarea.tarea_new") ?></h3>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<?= view('themes/vuexy/components/forms/maquina_tarea', ["id" => "maquina-tarea-form", "model" => null]); ?>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</div>
<!--//.card-footer -->
</div>
<!--//.card -->
</div>
<!--//.col -->
</div>
<!--//.row -->
<?= $this->endSection() ?>
<?= $this->section('css') ?>
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
<?= $this->endSection() ?>
<?= $this->section("additionalExternalJs") ?>
<script type="module" src="<?= site_url("assets/js/safekat/pages/configuracion/maquina_tarea/index.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -10,7 +10,7 @@
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="maquinaForm" class="card-body" method="post" action="<?= $formAction ?>">
<form id="maquinaForm" class="card-body" method="post" action="<?= $formAction ?>" data-id="<?= $maquina->id ?>">
<?= csrf_field() ?>
<div class="card-body">
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
@ -19,12 +19,39 @@
</div><!-- /.card-body -->
<div class="py-4">
<input type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>"
class="btn btn-primary me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>"
/>
<?= anchor(route_to("maquinaList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
<button type="button" id="btn-maquina-duplicate" class="btn btn-danger me-sm-3 me-1"><i class="ti ti-xs ti-copy"></i><?= lang("Basic.global.Duplicate") ?></button>
<?= anchor(route_to("maquinaList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary"]) ?>
</div><!-- /.card-footer -->
<div class="modal fade" id="modalMaquinaDuplicate" tabindex="-1" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3><?= lang('Basic.global.Duplicate') ?></h3>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="col-md-12">
<label for="duplicated_name"><?= lang("Maquinas.nombre") ?></label>
<input type="text" id="duplicated_name" name="name" class="form-control" placeholder="<?=lang("Maquinas.namePlaceholderDuplicated")?>">
<div class="invalid-feedback d-none">
</div>
</div>
</div>
<div class="modal-footer">
<div class="d-flex align-items-center justify-content-end gap-2">
<button type="button" id="btn-new-maquina-duplicate" class="btn-primary btn btn-md"><?= lang('Basic.global.Save') ?></button>
<button type="button" class="btn-secondary btn btn-md" data-bs-dismiss="modal"><?= lang('Basic.global.Cancel') ?></button>
</div>
</div>
</div>
</div>
</div>
</form>
</div><!-- //.card -->
</div><!--//.col -->
@ -253,7 +280,7 @@
url: '<?= route_to('updateMaquinaPapelOnTarifasChange') ?>',
data: {
maquina_id: id,
isRotativa: isRotativa.watch,
isRotativa: ()=>{ return $('#isRotativa').prop('checked')?1:0},
isInkjet: $('#isTinta').prop('checked'),
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
},
@ -435,11 +462,7 @@
yeniden(json.<?= csrf_token() ?>);
if(json.error){
document.getElementById("check_" + json.data.papel_impresion_id).checked = false;
Swal.fire({
icon: 'error',
title: '<?= lang('Basic.global.sweet.error_tittle') ?>',
text: json.error,
});
popErrorAlert(json.error, 'sk-alert-2');
}
});
@ -543,7 +566,7 @@
url: '<?= route_to('dataTableOfMaquinasPapelesImpresion') ?>',
data: function (d) {
d.maquina_id = id;
d.isRotativa = isRotativa.watch;
d.isRotativa = $('#isRotativa').prop('checked')?1:0;
d.webguard_token = '<?= csrf_hash() ?>';
},
method: 'POST',
@ -821,6 +844,7 @@
<?= $this->section('additionalExternalJs') ?>
<script type="module" src="<?= site_url('assets/js/safekat/pages/maquinas/duplicate.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.html5.min.js") ?>"></script>

View File

@ -1,37 +0,0 @@
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?= $this->section('content'); ?>
<div class="row">
<div class="col-md-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= lang('ServicioCliente.cardTitle') ?></h3>
</div>
<!--//.card-header -->
<div class="card-body" id="serviciosClienteCard">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<?= view('themes/vuexy/components/tables/servicios_cliente_table', ["id" => "tableServiciosCliente"]); ?>
</div>
<!--//.card-body -->
<div class="card-footer">
</div>
<!--//.card-footer -->
</div>
<!--//.card -->
</div>
<!--//.col -->
</div>
<!--//.row -->
<?= $this->endSection() ?>
<?= $this->section("additionalExternalJs") ?>
<script type="module" src="<?= site_url("assets/js/safekat/pages/configuracion/servicio_cliente/index.js") ?>">
</script>
<?= $this->endSection() ?>

View File

@ -158,7 +158,7 @@
<!-- Código JS comportamiento ?????. -->
<!------------------------------------------------------->
<?= $this->section("additionalInlineJs") ?>
/*
$("textarea[name*='comentarios_']").each(function(){
if (!$.trim($(this).val())) {
// textarea is empty or contains only white-space
@ -167,7 +167,7 @@ $("textarea[name*='comentarios_']").each(function(){
$("#mostrar_" + $(this).attr('name')).show();
}
});
*/
<?= $this->endSection() ?>

View File

@ -1,423 +0,0 @@
const actionBtns_direcciones = function(data) {
return `
<span class="edit-add"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit-add mx-2" data-id="${data.id}"></i></a></span>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm tiradas-alternativas delete-add-row mx-2"></i></a>
`;
};
// Funcion para obtener el peso total del libro
function get_peso_libro(){
var peso_total_libro = 0.0
$('#tableLineasPresupuesto').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var rowData = this.data();
peso_total_libro += parseFloat(rowData.peso)
})
return peso_total_libro;
}
async function get_precio_envio(peso, paisId, cp, tipo_envio){
data = {
tipo: 'get_tarifa',
peso: peso,
paisId: paisId,
cp: cp,
tipo_envio: tipo_envio,
}
data = Object.assign(data, window.token_ajax);
const response = await fetch(window.location.origin + window.url_get_precio_envio , {
method: "POST",
body: JSON.stringify(data),
headers: {
"Content-type": "application/json; charset=UTF-8",
}
});
const values = await response.json();
yeniden(values[window.csrf_token]);
return values.data;
}
async function get_coste_envio_tiradasAlternativas(tirada){
var peso_libro = get_peso_libro();
var tirada_inicial = parseInt($('#tirada').val());
var coste = 0.0;
var margen = 0.0;
const table = $('#tableOfDireccionesEnvio').DataTable();
const rows = table.rows().nodes();
for (let i = 0; i < rows.length; i++) {
const rowData = table.row(rows[i]).data();
const porcentaje = parseInt(rowData.cantidad)/tirada_inicial*100.0;
const cantidad = Math.floor(tirada*porcentaje/100.0);
const peso_envio = cantidad*peso_libro/1000.0;
const datos_tarifa = await get_precio_envio(peso_envio, rowData.paisId, rowData.cp, parseInt(rowData.entregaPieCalle)==1?'palets':'cajas');
if(datos_tarifa.id!=null){
if(peso_envio>parseFloat(datos_tarifa.peso_max)){
coste += (parseFloat(datos_tarifa.precio_min) + (peso_envio-parseFloat(datos_tarifa.peso_min)) * parseFloat(datos_tarifa.precio_adicional)).toFixed(2);
}
// si no se calcula linealmente
else{
m=((parseFloat(datos_tarifa.precio_max)-parseFloat(datos_tarifa.precio_min))/(parseFloat(datos_tarifa.peso_max)-parseFloat(datos_tarifa.peso_min)));
b=parseFloat(datos_tarifa.precio_max)-m*parseFloat(datos_tarifa.peso_max);
coste += parseFloat(m*peso_envio+b);
}
}
margen += coste*datos_tarifa.margen/100.0;
}
return {coste, margen};
}
function checkInsertar(){
var cantidad_total = 0
$('#tableOfDireccionesEnvio').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var data = this.data();
cantidad_total += parseInt(data.cantidad )
} );
var htmlString = ''
if(cantidad_total < parseInt($('#tirada').val())){
$('#rowInsertar').css('display', 'flex')
}
else{
$('#rowInsertar').css('display', 'none')
}
if(cantidad_total != parseInt($('#tirada').val())){
htmlString = `
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
<span class="alert-icon alert-icon-lg text-primary me-2">
<i class="ti ti-bell ti-sm"></i>
</span>
<div class="d-flex flex-column ps-1">
<h5 class="alert-heading mb-2">` +
window.Presupuestos.validation.ejemplares_envio +
`</h5>
</div>
</div>`;
}
$('#alert-envios').html(htmlString)
}
async function updateTablaEnvios(tirada_inicial = null, tirada = null){
var peso_total_libro = get_peso_libro();
$('#tableOfDireccionesEnvio').DataTable().rows().every(async function ( rowIdx, tableLoop, rowLoop ) {
var rowData = this.data();
if(tirada_inicial!=null && tirada!=null){
const porcentaje = parseInt(rowData.cantidad)/tirada_inicial*100.0;
const cantidad = Math.floor(tirada*porcentaje/100.0);
rowData.cantidad = cantidad
}
const peso_envio = peso_total_libro*parseInt(rowData.cantidad)/1000.0;
var datos_tarifa = await get_precio_envio(peso_envio, rowData.paisId, rowData.cp, parseInt(rowData.entregaPieCalle)==1?'palets':'cajas');
if(datos_tarifa.id!=null){
if(peso_envio>parseFloat(datos_tarifa.peso_max) || parseFloat(datos_tarifa.peso_max) == 0){
datos_tarifa.precio = parseFloat(datos_tarifa.peso_min) + (peso_envio-parseFloat(datos_tarifa.peso_min))*parseFloat(datos_tarifa.precio_adicional);
}
// si no se calcula linealmente
else{
m=((parseFloat(datos_tarifa.precio_max)-parseFloat(datos_tarifa.precio_min))/(parseFloat(datos_tarifa.peso_max)-parseFloat(datos_tarifa.peso_min)));
b=parseFloat(datos_tarifa.precio_max)-m*parseFloat(datos_tarifa.peso_max);
datos_tarifa.precio = parseFloat(m*peso_envio+b);
}
datos_tarifa.cantidad = parseInt($('#add_cantidad').val());
datos_tarifa.peso = peso_envio;
$('#tableOfDireccionesEnvio').DataTable().row(rowIdx)
.data({
'tarifa_id': datos_tarifa.id,
'cantidad': rowData.cantidad,
'peso': datos_tarifa.peso.toFixed(3),
'att': rowData.att,
'email': rowData.email,
'direccion': rowData.direccion,
'cp': rowData.cp,
'municipio': rowData.municipio,
'provincia': rowData.provincia,
'paisId': rowData.paisId,
'telefono': rowData.telefono,
'proveedor': datos_tarifa.proveedor,
'proveedor_id': datos_tarifa.proveedor_id,
'precio': datos_tarifa.precio.toFixed(2),
'margen': datos_tarifa.margen,
'entregaPieCalle': rowData.entregaPieCalle,
'actionBtns_direcciones': actionBtns_direcciones,
})
.draw();
checkInsertar()
//updateTotales(false, false, true)
updatePresupuesto({
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true
})
}
else{
popErrorAlert(window.error_no_tarifa_envio, 'error-tarifa')
}
})
}
$('#insertar_direccion').on('click', function(){
$("#addressForm").attr('action','create')
var $newAddDialog = $("#addressForm")
var maximaCantidad = parseInt($('#tirada').val())
$("#add_cantidad").attr("max" , maximaCantidad);
$("#add_cantidad").val( maximaCantidad);
$("#add_cantidad").on('change', function(){
$("#add_cantidad").val(parseInt($("#add_cantidad").val())>maximaCantidad ? maximaCantidad : $("#add_cantidad").val())
})
cantidad_total = 0
tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var data = this.data();
cantidad_total += parseInt(data.cantidad)
} );
$('#add_cantidad').attr('max-value', parseInt($('#tirada').val())-cantidad_total)
$('#add_cantidad').val(parseInt($('#tirada').val())-cantidad_total)
$newAddDialog.modal('show')
})
const lastColNr_direcciones = $('#tableOfDireccionesEnvio').find("tr:first th").length - 1;
$(document).on('click', '.delete-add-row', function(e) {
const row = $(this).closest('tr');
tableEnvios.row( row )
.remove()
.draw();
checkInsertar()
//updateTotales(false, false, true)
updatePresupuesto({
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true
})
showBreadCrumbSaveButton(true);
})
$(document).on('click', '.btn-edit-add', function(e) {
const row = $(this).closest('tr');
var data = tableEnvios.row( row ).data()
$("#addressForm").attr('action','edit')
$("#addressForm").attr('row', row[0]._DT_RowIndex)
$("#addressForm").attr('presupuestodireccion_id', $(this).attr('data-id'))
var $newAddDialog = $("#addressForm")
var maximaCantidad = parseInt($('#tirada').val())
$("#add_cantidad").attr("max" , maximaCantidad);
$("#add_cantidad").val( maximaCantidad);
$("#add_cantidad").on('change', function(){
$("#add_cantidad").val(parseInt($("#add_cantidad").val())>maximaCantidad ? maximaCantidad : $("#add_cantidad").val())
})
cantidad_total = 0
tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var data2 = this.data();
cantidad_total += parseInt(data2.cantidad)
} );
cantidad_total -= parseInt(data.cantidad) // Si es editar tienes que restar los de la linea actual
$('#add_cantidad').attr('max-value', parseInt($('#tirada').val())-cantidad_total)
$('#add_cantidad').val(parseInt($('#tirada').val())-cantidad_total)
$('#add_att').val(data.att)
$('#add_direccion').val(data.direccion)
$('#add_email').val(data.email)
$('#add_cp').val(data.cp)
$('#add_municipio').val(data.municipio)
$('#add_provincia').val(data.provincia)
$('#add_pais_id').val(data.paisId)
$('#add_telefono').val(data.telefono)
$('#add_cantidad').val(data.cantidad)
$('#add_entregaPieCalle').prop('checked', data.entregaPieCalle==1?true:false)
$newAddDialog.modal('show')
})
$('#recoger_en_taller').change(function(){
if(this.checked) {
$('#rowTable').css('display', 'none')
$('#rowInsertar').css('display', 'none')
tableEnvios.clear().draw()
}
else{
$('#rowTable').css('display', 'flex')
$('#rowInsertar').css('display', 'flex')
tableEnvios.columns.adjust();
}
})
let tableEnvios = $('#tableOfDireccionesEnvio').DataTable( {
draw:5,
serverSide: false,
processing: true,
autoWidth: true,
responsive: true,
order: [[ 0, "asc" ]],
pageLength: 20,
lengthChange: false,
searching: false,
paging: false,
info: false,
scrollX: true,
columns: [
{ 'data': 'tarifa_id' },
{ 'data': 'cantidad' },
{ 'data': 'peso' },
{ 'data': 'att' },
{ 'data': 'email' },
{ 'data': 'direccion' },
{ 'data': 'cp' },
{ 'data': 'municipio' },
{ 'data': 'paisId' ,
render: function(data, type, row, meta) {
var pais = window.paisList.find(element => element.id == data);
return pais['nombre'];
},
},
{ 'data': 'telefono' },
{ 'data': 'proveedor'},
{ 'data': 'proveedor_id'},
{ 'data': 'precio' },
{ 'data': 'margen' },
{ 'data': 'entregaPieCalle' },
{
data: actionBtns_direcciones,
className: 'row-edit dt-center'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr_direcciones]
},
{"orderData": [ 0], "targets": 0 },
],
columnDefs: [
{
target: [0,11,13,14],
visible: false,
searchable: false
},
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
} );
function save_datos_envios(){
var id = $('#presupuesto_id').val()
$.post( window.routes_envios.dataTableOfPresupuestoDirecciones,
Object.assign({tipo: "clear_lineas", presupuesto_id: id}, window.token_ajax))
.done(function( data ) {
$('#tableOfDireccionesEnvio').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var data = this.data();
$.post( '/presupuestos/presupuestodirecciones/add',
Object.assign({
presupuesto_id : id,
tarifa_id : data.tarifa_id,
cantidad : data.cantidad,
peso : data.peso,
att : data.att,
email : data.email,
direccion : data.direccion,
paisId : data.paisId,
provincia : data.provincia,
municipio : data.municipio,
cp : data.cp,
telefono : data.telefono,
precio : data.precio,
margen : data.margen,
proveedor : data.proveedor,
proveedor_id : data.proveedor_id,
entregaPieCalle : data.entregaPieCalle}, window.token_ajax))
});
})
}
function load_datos_envios(){
window.direccionesList.forEach((linea) => {
tableEnvios.row
.add({
'tarifa_id': linea.tarifa_id,
'cantidad': linea.cantidad,
'peso': linea.peso,
'att': linea.att,
'email': linea.email,
'direccion': linea.direccion,
'cp': linea.cp,
'municipio': linea.municipio,
'provincia': linea.provincia,
'paisId': linea.pais_id,
'telefono': linea.telefono,
'proveedor': linea.proveedor,
'proveedor_id': linea.proveedor_id,
'precio': linea.precio,
'margen': linea.margen,
'entregaPieCalle': linea.entregaPieCalle,
'actionBtns_direcciones': actionBtns_direcciones,
})
.draw();
checkInsertar()
});
updatePresupuesto({
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: false
})
}

View File

@ -10,11 +10,20 @@
<div class="accordion-body">
<div id='alert-envios'></div>
<?= view("themes/vuexy/form/presupuestos/admin/_presupuestoDireccionesForm") ?>
<div class='row'>
<div class='col-md-12 col-lg-4 px-4 py-2'>
<label for='envio_base' class='form-label'>
Envio base
</label>
<input readonly type='text' class='form-control' id='envio_base' name='envio_base' value='<?= $presupuestoEntity->envio_base ?>' />
</div>
</div>
<div id='rowTable' class='row'>
<table id="tableOfDireccionesEnvio" class="table dt-responsive dataTable px-2 update-resumen-presupuesto" style="width: 95%;">
<table id="tableOfDireccionesEnvio" class="table comparator-table dt-responsive dataTable px-2 update-resumen-presupuesto" style="width: 95%;">
<thead>
<tr>
<th class="lp-header">Tarifa_id</th>
<th class="lp-header">TARIFA ID</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.cantidad') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.peso') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.att') ?></th>
@ -23,12 +32,13 @@
<th class="lp-header"><?= lang('PresupuestosDirecciones.cp') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.municipio') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.pais') ?></th>
<th class="lp-header">pais_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.telefono') ?></th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.proveedor') ?></th>
<th>Proveedor_id</th>
<th class="lp-header">Proveedor_id</th>
<th class="lp-header"><?= lang('PresupuestosDirecciones.precio') ?></th>
<th>Margen</th>
<th>Entrega a pie</th>
<th class="lp-header"><?= lang('Tarifaacabado.margen') ?></th>
<th class="lp-header">Pallets?</th>
<th style="min-width:120px !important;" class="lp-header"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
@ -55,24 +65,3 @@
</div> <!-- //.accordion-item -->
</div> <!-- //.accordion -->
<!------------------------------------------->
<!-- Código JS comportamiento general pag. -->
<!------------------------------------------->
<?= $this->section("additionalInlineJs") ?>
window.paisList = <?php echo json_encode($paisList); ?>;
window.direccionesList = <?php echo json_encode($direccionesList); ?>;
window.routes_envios = {
dataTableOfPresupuestoDirecciones: '<?= route_to('dataTableOfPresupuestoDirecciones') ?>'
}
window.url_get_precio_envio = '<?= route_to('processDataDirecciones') ?>';
window.error_no_tarifa_envio = '<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>'
window.token_ajax= {<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v};
$( document ).ready(function() {
load_datos_envios();
});
<?= $this->endSection() ?>

View File

@ -1,144 +0,0 @@
$('#paginas').on("change", function () {
const url2 = window.location.href;
const url_parts2 = url2.split('/');
if($('#tipo_impresion_id').val() == 21){
if(parseInt($('#paginas').val()) > 80){
$('#paginas').val(80)
}
}
if(url_parts2[url_parts2.length-2] == 'edit'){
checkPaginasPresupuesto()
// Si es negro o color
if ($('#tipoImpresion').select2('data')[0].id == 'negro' ||
$('#tipoImpresion').select2('data')[0].id == 'color') {
$('#compPaginasNegro').val(parseInt($('#paginas').val())-parseInt($('#compPaginasColor').val()));
$('#compPaginasNegro').trigger('change')
}
// Si es negrohq o colorhq
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' ||
$('#tipoImpresion').select2('data')[0].id == 'colorhq') {
$('#compPaginasNegrohq').val(parseInt($('#paginas').val())-parseInt($('#compPaginasColorhq').val()));
$('#compPaginasNegrohq').trigger('change');
}
//update_servicios(false)
//updateLineasPresupuesto()
updatePresupuesto({
update_lineas: true,
update_servicios: true,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
})
}
});
$('#tirada').on("change", function (update_tiradas_alternativas = true) {
calcular_mermas()
const url2 = window.location.href;
const url_parts2 = url2.split('/');
if(url_parts2[url_parts2.length-2] == 'edit'){
//update_servicios(false)
//updateLineasPresupuesto()
if(update_tiradas_alternativas)
updatePresupuesto({
update_lineas: true,
update_servicios: false,
update_envios: false,
update_resumen: false,
update_tiradas_alternativas: false
})
else
updatePresupuesto({
update_lineas: true,
update_servicios: false,
update_envios: false,
update_resumen: false,
update_tiradas_alternativas: false
})
checkInsertar()
}
})
function calcular_mermas(){
const tirada = parseInt($('#tirada').val())
var merma = 0
htmlString = ''
if(tirada> parseInt($('#POD').val())){
merma = tirada*0.1<=30 ? tirada*0.1 : 30
}
else{
merma_lineas = []
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var rowData = this.data();
if(rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta'){
const formas_linea = parseInt($('#isCosido').val())==0?parseInt(rowData.formas):parseInt(rowData.formas)/2
if(formas_linea > tirada)
merma_lineas.push(formas_linea-tirada)
else
merma_lineas.push(tirada%formas_linea)
}
})
if(merma_lineas.length>0)
merma = Math.max(...merma_lineas)
else{
htmlString = `
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
<span class="alert-icon alert-icon-lg text-primary me-2">
<i class="ti ti-bell ti-sm"></i>
</span>
<div class="d-flex flex-column ps-1">
<h5 class="alert-heading mb-2">` +
window.Presupuestos.validation.no_lp_for_merma +
`</h5>
</div>
</div>`;
merma = 0
}
}
$('#mermacubierta').val(parseInt(merma))
$('#merma').val(parseInt(merma))
$('#alert-datosLibro').html(htmlString)
}
$('#papelFormatoPersonalizado').on("click",function(){
if($('#papelFormatoPersonalizado').is(':checked')){
document.getElementById("papelFormatoAncho").style.display = "block";
document.getElementById("papelFormatoAlto").style.display = "block";
$('#papelFormatoId').hide();
$('#papelFormatoId').val(0).change();
document.getElementById("label_papelFormatoId").innerHTML =
window.Presupuestos.papelFormatoId + " (" +
window.Presupuestos.papelFormatoAncho + " x " + window.Presupuestos.papelFormatoAncho + ")*";
}
else{
document.getElementById("papelFormatoAncho").value= "";
document.getElementById("papelFormatoAlto").value= "";
document.getElementById("papelFormatoAncho").style.display = "none";
document.getElementById("papelFormatoAlto").style.display = "none";
$('#papelFormatoId').show();
document.getElementById("label_papelFormatoId").innerHTML =
window.Presupuestos.papelFormatoId + '*';
}
});

View File

@ -1,7 +1,8 @@
<div class="accordion accordion-bordered mt-3" id="accordionDatosLibro">
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingOne">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionDatosLibroTip" aria-expanded="false" aria-controls="accordionDatosLibroTip">
<button type="button" class="accordion-button" data-bs-toggle="collapse"
data-bs-target="#accordionDatosLibroTip" aria-expanded="false" aria-controls="accordionDatosLibroTip">
<h4><?= lang("Presupuestos.datosLibro") ?></h4>
</button>
</h2>
@ -19,18 +20,20 @@
<label for="paginas" class="form-label">
<?= lang('Presupuestos.paginas') ?>*
</label>
<input type="number" id="paginas" name="paginas" tabindex="1" maxLength="11" class="form-control" value="<?= old('paginas', $presupuestoEntity->paginas) ?>" <?php echo ($tipo_impresion_id == 21)?' max=80':'' ?>>
<input type="number" id="paginas" name="paginas" tabindex="1" maxLength="11"
class="form-control" value="" <?php echo ($tipo_impresion_id == 21) ? ' max=80' : '' ?>>
</div><!--//.mb-3 -->
</div>
</div><!--//.col -->
<div class="col-md-12 col-lg-2 px-4">
<div class="mb-1">
<label for="tirada" class="form-label">
<?= lang('Presupuestos.tirada') ?>*
</label>
<input type="number" id="tirada" name="tirada" tabindex="2" maxLength="11" class="form-control" value="<?= old('tirada', $presupuestoEntity->tirada) ?>">
<input type="number" id="tirada" name="tirada" tabindex="2" maxLength="11"
class="form-control" value="">
</div><!--//.mb-3 -->
</div><!--//.col -->
@ -41,28 +44,25 @@
<label id="label_papelFormatoId" for="papelFormatoId" class="form-label">
<?= lang('Presupuestos.papelFormatoId') ?>*
</label>
<div class="row tamanio-estandar">
<select id="papelFormatoId" name="papel_formato_id" tabindex="3"
class="form-control select2bs2" style="width: 100%;">
</select>
</div>
<select id="papelFormatoId" <?= $presupuestoEntity->papel_formato_personalizado == false ? '' : 'style="display: none"'; ?> name="papel_formato_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
<?php if (isset($papelFormatoList) && is_array($papelFormatoList) && !empty($papelFormatoList)) :
foreach ($papelFormatoList as $formato) : ?>
<option value="<?= $formato->id ?>" <?= $formato->id == $presupuestoEntity->papel_formato_id ? ' selected' : '' ?>>
<?= $formato->tamanio ?>
</option>
<?php endforeach;
endif; ?>
</select>
<div class="row">
<div class="col-md-12 col-lg-6">
<div class="col-md-12 col-lg-6 tamanio-personalizado d-none">
<div class="mb-1">
<input <?= $presupuestoEntity->papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAncho" name="papel_formato_ancho" maxLength="8" step="0.01" class="form-control formato_libro" value="<?= old('papel_formato_ancho', $presupuestoEntity->papel_formato_ancho) ?>">
<input type="number" id="papelFormatoAncho" name="papel_formato_ancho"
maxLength="8" step="0.01" class="form-control formato_libro" value="">
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-6">
<div class="mb-1">
<input <?= $presupuestoEntity->papel_formato_personalizado == true ? '' : 'style="display: none"'; ?> type="number" id="papelFormatoAlto" name="papel_formato_alto" maxLength="8" step="0.01" class="form-control formato_libro" value="<?= old('papel_formato_alto', $presupuestoEntity->papel_formato_alto) ?>">
<div class="col-md-12 col-lg-6 tamanio-personalizado d-none">
<div class="mb-1">
<input type="number" id="papelFormatoAlto" name="papel_formato_alto"
maxLength="8" step="0.01" class="form-control formato_libro" value="">
</div><!--//.mb-3 -->
</div><!--//.col -->
</div>
@ -76,7 +76,8 @@
<label for="merma" class="form-label">
<?= lang('Presupuestos.merma') ?>*
</label>
<input readonly style="background: #E8E8E8;" id="merma" name="merma" maxLength="8" tabindex="4" step="1" placeholder="10" class="form-control" value="<?= old('merma', $presupuestoEntity->merma) ?>">
<input readonly style="background: #E8E8E8;" id="merma" name="merma" maxLength="8"
tabindex="4" step="1" placeholder="10" class="form-control" value="">
</div><!--//.mb-3 -->
</div><!--//.col -->
@ -85,7 +86,8 @@
<label for="mermacubierta" class="form-label">
<?= lang('Presupuestos.mermacubierta') ?>*
</label>
<input readonly style="background: #E8E8E8;" id="mermacubierta" name="merma_cubierta" tabindex="5" placeholder="10" maxLength="8" step="1" class="form-control" value="<?= old('merma_cubierta', $presupuestoEntity->merma_cubierta) ?>">
<input readonly style="background: #E8E8E8;" id="mermacubierta" name="merma_cubierta"
tabindex="5" placeholder="10" maxLength="8" step="1" class="form-control" value="">
</div><!--//.mb-3 -->
</div><!--//.col -->
@ -96,38 +98,64 @@
<!-- Fila 2 -->
<div class="row">
<div class="col-md-12 col-lg-2 px-4">
<?php if($tipo_impresion_id != 1 && $tipo_impresion_id != 3 && $tipo_impresion_id != 5 && $tipo_impresion_id != 7): ?>
<div class="row">
<div class="mb-1">
<div class="form-check form-switch mb-2">
<input class="form-check-input solapas_cubierta" type="checkbox" id="solapas" name="solapas" tabindex="6" value="1" <?= $presupuestoEntity->solapas == true ? 'checked' : ''; ?>>
<label class="form-check-label" for="solapas"><?= lang('Presupuestos.solapasCubierta') ?></label>
</div>
</div><!--//.mb-3 -->
<div class="row solapas-cubierta-div">
<div class="mb-1">
<div class="form-check form-switch mb-2">
<input class="form-check-input solapas_cubierta" type="checkbox" id="solapas"
name="solapas" tabindex="6" value="1">
<label class="form-check-label"
for="solapas"><?= lang('Presupuestos.solapasCubierta') ?></label>
</div>
</div><!--//.mb-3 -->
</div>
<div class="row">
<div class="mb-1 solapas-cubierta-div d-none" id="div_solapas_ancho">
<label for="solapas_ancho" class="form-label">
<?= lang('Presupuestos.solapasAnchoCubierta') ?>*
</label>
<input type="number" id="solapas_ancho" name="solapas_ancho" placeholder="0"
maxLength="8" step="1" class="form-control solapas_cubierta" value="">
<div class="form-text">
Entre 60 y 120 mm
</div>
</div><!--//.mb-1 -->
</div>
</div>
</div>
<?php endif; ?>
</div>
<div class="col-md-12 col-lg-2 px-4">
<?php if ($tipo_impresion_id != 5 && $tipo_impresion_id != 6 && $tipo_impresion_id != 7 && $tipo_impresion_id != 8 && $tipo_impresion_id != 21) : ?>
<div class="row">
<div class="mb-1">
<div class="form-check form-switch mb-2">
<input class="form-check-input solapas_sobrecubierta" type="checkbox" id="solapas_sobrecubierta" name="solapas_sobrecubierta" tabindex="6" value="1" <?= $presupuestoEntity->solapas_sobrecubierta == true ? 'checked' : ''; ?>>
<label class="form-check-label" for="solapas_sobrecubierta"><?= lang('Presupuestos.solapasSobrecubierta') ?></label>
</div>
</div><!--//.mb-3 -->
</div>
<?php endif; ?>
<div class="row solapas-sobrecubierta-div">
<div class="mb-1">
<div class="form-check form-switch mb-2">
<input class="form-check-input solapas_sobrecubierta" type="checkbox"
id="solapas_sobrecubierta" name="solapas_sobrecubierta" tabindex="6" value="1">
<label class="form-check-label"
for="solapas_sobrecubierta"><?= lang('Presupuestos.sobrecubierta') ?></label>
</div>
</div><!--//.mb-3 -->
</div>
<div class="row">
<div class="mb-1 solapas-sobrecubierta-div d-none" id="div_solapas_ancho_sobrecubierta">
<label for="solapas_ancho_sobrecubierta" class="form-label">
<?= lang('Presupuestos.solapasAnchoSobrecubierta') ?>*
</label>
<input type="number" id="solapas_ancho_sobrecubierta" name="solapas_ancho_sobrecubierta"
placeholder="60" min="60" maxLength="8" step="1"
class="form-control solapas_sobrecubierta" value="">
<div class="form-text">
Entre 60 y 120 mm
</div>
</div><!--//.mb-1 -->
</div>
</div>
<div class="col-md-12 col-lg-6 px-4">
<div class="row">
<div class="mb-1">
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" id="papelFormatoPersonalizado" name="papel_formato_personalizado" value="1" <?= $presupuestoEntity->papel_formato_personalizado == true ? 'checked' : ''; ?>>
<label class="form-check-label" for="papelFormatoPersonalizado"><?= lang('Presupuestos.papelFormatoPersonalizado') ?></label>
<input class="form-check-input" type="checkbox" id="papelFormatoPersonalizado"
name="papel_formato_personalizado" value="1">
<label class="form-check-label"
for="papelFormatoPersonalizado"><?= lang('Presupuestos.papelFormatoPersonalizado') ?></label>
</div>
</div>
</div>
@ -135,47 +163,56 @@
</div>
<!-- Fila 3 -->
<div class="row">
<div class="col-md-12 col-lg-2 px-4">
<?php if($tipo_impresion_id != 1 && $tipo_impresion_id != 3 && $tipo_impresion_id != 5 && $tipo_impresion_id != 7): ?>
<?php if($presupuestoEntity->solapas == true): ?>
<div class="mb-1" id="div_solapas_ancho">
<?php else: ?>
<div class="mb-1" id="div_solapas_ancho" style="display:none;">
<?php endif; ?>
<label for="solapas_ancho" class="form-label">
<?= lang('Presupuestos.solapasAnchoCubierta') ?>*
</label>
<input type="number" id="solapas_ancho" name="solapas_ancho" placeholder="0" maxLength="8" step="1" class="form-control solapas_cubierta" value="<?= old('solapas_ancho', $presupuestoEntity->solapas_ancho) ?>">
</div><!--//.mb-1 -->
<div class="row mt-2 container-faja">
<?php endif; ?>
</div>
<div class="col-md-12 col-lg-2 px-4">
<?php if ($tipo_impresion_id != 5 && $tipo_impresion_id != 6 && $tipo_impresion_id != 7 && $tipo_impresion_id != 8 && $tipo_impresion_id != 21) : ?>
<?php if($presupuestoEntity->solapas_sobrecubierta == true): ?>
<div class="mb-1" id="div_solapas_ancho_sobrecubierta">
<?php else: ?>
<div class="mb-1" id="div_solapas_ancho_sobrecubierta" style="display:none;">
<?php endif; ?>
<label for="solapas_ancho_sobrecubierta" class="form-label">
<?= lang('Presupuestos.solapasAnchoSobrecubierta') ?>*
<div class="row align-items-center">
<div class="col-md-12 col-lg-2 px-4">
<div class="mb-1">
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" id="faja" name="faja" tabindex="6"
value="1">
<label class="form-check-label" for="faja"><?= lang('Presupuestos.faja') ?></label>
</div>
</div><!--//.mb-3 -->
</div>
<div class="col-md-12 col-lg-2 px-4">
<div class="mb-1 faja-div d-none" id="div_faja_alto">
<label for="faja_alto" class="form-label">
<?= lang('Presupuestos.altoFaja') ?>*
</label>
<input type="number" id="solapas_ancho_sobrecubierta" name="solapas_ancho_sobrecubierta" placeholder="0" maxLength="8" step="1" class="form-control solapas_sobrecubierta" value="<?= old('solapas_ancho', $presupuestoEntity->solapas_ancho_sobrecubierta) ?>">
<input type="number" id="faja_alto" name="faja_alto" placeholder="0" maxLength="8"
step="1" class="form-control" min="50" value="50">
<div class="form-text">
Entre 50 y 120 mm
</div>
</div><!--//.mb-1 -->
<?php endif; ?>
</div>
</div>
<div class="col-md-12 col-lg-2 px-4">
<div class="mb-1 faja-div d-none" id="div_faja_solapas_ancho">
<label for="faja_solapas_ancho" class="form-label">
<?= lang('Presupuestos.tamanioSolapasFaja') ?>*
</label>
<input type="number" id="faja_solapas_ancho" name="faja_solapas_ancho" placeholder="0"
maxLength="8" step="1" min="60" class="form-control" value="60">
<div class="form-text">
Entre 60 y 120 mm
</div>
</div><!--//.mb-1 -->
</div>
</div>
</div>
<!----------------------------------------------------------------------------->
<?php if(str_contains($formAction,'edit')): ?>
<?php if (str_contains($formAction, 'edit')): ?>
<div class="divider divider-dark text-start mb-1">
<div class="divider-text">
<h5><?= lang("Presupuestos.acabadosExteriores") ?></h5>
<h5>
<?= lang("Presupuestos.acabadosExteriores") ?>
</h5>
</div>
</div>
@ -186,49 +223,33 @@
<label id="label_acabado_cubierta_id" for="acabado_cubierta_id" class="form-label">
<?= lang('Presupuestos.acabadoCubierta') ?>*
</label>
<select id="acabado_cubierta_id" name="acabado_cubierta_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
<?php if (isset($acabadosCubierta) && is_array($acabadosCubierta) && !empty($acabadosCubierta)) :
foreach ($acabadosCubierta as $acabado) : ?>
<option value="<?= $acabado->id ?>" <?= $acabado->id == $presupuestoEntity->acabado_cubierta_id ? ' selected' : '' ?>>
<?= $acabado->label ?>
</option>
<?php endforeach;
endif; ?>
<select id="acabado_cubierta_id" name="acabado_cubierta_id" tabindex="3"
class="form-control select2bs2" style="width: 100%;">
</select>
</div>
</div>
</div>
</div>
<div class="col-md-12 col-lg-6 px-4">
<?php if ($tipo_impresion_id != 5 && $tipo_impresion_id != 6 && $tipo_impresion_id != 7 && $tipo_impresion_id != 8 && $tipo_impresion_id != 21) : ?>
<div class="row">
<div class="mb-1">
<label id="label_acabado_cubierta_id" for="acabado_sobrecubierta_id" class="form-label">
<?= lang('Presupuestos.acabadoSobrecubierta') ?>*
</label>
<select id="acabado_sobrecubierta_id" name="acabado_sobrecubierta_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
<?php if (isset($acabadosSobrecubierta) && is_array($acabadosSobrecubierta) && !empty($acabadosSobrecubierta)) :
foreach ($acabadosSobrecubierta as $acabado) : ?>
<option value="<?= $acabado->id ?>" <?= $acabado->id == $presupuestoEntity->acabado_sobrecubierta_id ? ' selected' : '' ?>>
<?= $acabado->label ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div>
<div class="row impresion-con-sobrecubierta">
<div class="mb-1">
<label id="label_acabado_cubierta_id" for="acabado_sobrecubierta_id" class="form-label">
<?= lang('Presupuestos.acabadoSobrecubierta') ?>*
</label>
<select id="acabado_sobrecubierta_id" name="acabado_sobrecubierta_id" tabindex="3"
class="form-control select2bs2" style="width: 100%;">
</select>
</div>
<?php endif; ?>
</div>
</div>
</div>
<!----------------------------------------------------------------------------->
<div class="divider divider-dark text-start mb-1">
<div class="divider-text">
<h5><?= lang("Presupuestos.opcionesPresupuesto") ?></h5>
<h5>
<?= lang("Presupuestos.opcionesPresupuesto") ?>
</h5>
</div>
</div>
@ -237,207 +258,114 @@
<div class="mb-3">
<div class="form-check">
<label for="retractilado" class="form-check-label">
<input type="checkbox" id="retractilado" name="retractilado" value="1" class="form-check-input" <?= $presupuestoEntity->retractilado == true ? 'checked' : ''; ?>>
<input type="checkbox" id="retractilado" name="retractilado" value="1"
class="form-check-input" service="acabado"
service-id=<?= $serviciosAutomaticos['retractilado'] ?>>
<?= lang('Presupuestos.retractilado') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="retractilado5" class="form-check-label">
<input type="checkbox" id="retractilado5" name="retractilado_5" value="1" class="form-check-input" <?= $presupuestoEntity->retractilado5 == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.retractilado5') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="retractilado5" class="form-check-label">
<input type="checkbox" id="retractilado5" name="retractilado_5" value="1"
class="form-check-input" service="acabado"
service-id=<?= $serviciosAutomaticos['retractilado5'] ?>>
<?= lang('Presupuestos.retractilado5') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="prototipo" class="form-check-label">
<input type="checkbox" id="prototipo" name="prototipo" value="1"
class="form-check-input" service="extra"
service-id=<?= $serviciosAutomaticos['prototipo'] ?>>
<?= lang('Presupuestos.prototipo') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
<div class="mb-3">
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="fajaColor" class="form-check-label">
<input type="checkbox" id="fajaColor" name="faja_color" value="1" class="form-check-input" <?= $presupuestoEntity->faja_color == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.fajaColor') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="prototipo" class="form-check-label">
<input type="checkbox" id="prototipo" name="prototipo" value="1" class="form-check-input" <?= $presupuestoEntity->prototipo == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.prototipo') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
<div class="mb-3">
</div><!--//.mb-3 -->
</div><!--//.col -->
</div>
</div>
<div class="row">
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="ferro" class="form-check-label">
<input type="checkbox" id="ferro" name="ferro" value="1" class="form-check-input"
service="extra" service-id=<?= $serviciosAutomaticos['ferro'] ?>>
<?= lang('Presupuestos.ferro') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="row">
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="ferroDigital" class="form-check-label">
<input type="checkbox" id="ferroDigital" name="ferro_digital" value="1"
class="form-check-input">
<?= lang('Presupuestos.ferroDigital') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="ferro" class="form-check-label">
<input type="checkbox" id="ferro" name="ferro" value="1" class="form-check-input" <?= $presupuestoEntity->ferro == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.ferro') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="marcapaginas" class="form-check-label">
<input type="checkbox" id="marcapaginas" name="marcapaginas" value="1"
class="form-check-input">
<?= lang('Presupuestos.marcapaginas') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<input type="checkbox" id="serv_solapas_cubierta" name="serv_solapas_cubierta" value="1"
class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['solapas_cubierta'] ?>>
<input type="checkbox" id="serv_solapas_sobrecubierta" name="serv_solapas_sobrecubierta" value="1"
class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['solapas_sobrecubierta'] ?>>
<input type="checkbox" id="solapas_faja" name="solapas_faja" value="1"
class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['solapas_faja'] ?>>
<input type="checkbox" id="plegado_guardas" name="plegado_guardas" value="1"
class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['plegado_guardas'] ?>>
<input type="checkbox" id="solapas_grandes_cubierta" name="solapas_grandes_cubierta" value="1"
class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['solapas_grandes_cubierta'] ?>>
<input type="checkbox" id="solapas_grandes_sobrecubierta" name="solapas_grandes_sobrecubierta"
value="1" class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['solapas_grandes_sobrecubierta'] ?>>
<input type="checkbox" id="solapas_grandes_faja" name="solapas_grandes_faja" value="1"
class="form-check-input d-none" service="manipulado"
service-id=<?= $serviciosAutomaticos['solapas_grandes_faja'] ?>>
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="ferroDigital" class="form-check-label">
<input type="checkbox" id="ferroDigital" name="ferro_digital" value="1" class="form-check-input" <?= $presupuestoEntity->ferro_digital == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.ferroDigital') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<div class="form-check">
<label for="marcapaginas" class="form-check-label">
<input type="checkbox" id="marcapaginas" name="marcapaginas" value="1" class="form-check-input" <?= $presupuestoEntity->marcapaginas == true ? 'checked' : ''; ?>>
<?= lang('Presupuestos.marcapaginas') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
</div>
</div>
<?php endif; ?>
</div> <!-- //.accordion-body -->
</div> <!-- //.accordion-collapse -->
</div> <!-- //.accordion-item -->
</div> <!-- //.accordion -->
<!------------------------------------------->
<!-- Código JS comportamiento general pag. -->
<!------------------------------------------->
<?= $this->section("additionalInlineJs") ?>
$('#papelFormatoId').select2({
allowClear: false,
});
<?php if(str_contains($formAction,'edit')): ?>
var ancho_libro = getDimensionLibro().ancho;
var alto_libro = getDimensionLibro().alto;
$('#retractilado').on("change", function () {
checkRetractiladoComparador(this);
servicioRetractilado()
});
$('#retractilado5').on("change", function () {
checkRetractiladoComparador(this);
servicioRetractilado5()
});
$('#fajaColor').on("change", function () {
servicioFajaColor()
});
$('#ferro').on("change", function () {
servicioFerro()
});
$('#prototipo').on("change", function () {
servicioPrototipo()
servicioFerro()
});
$('#papelFormatoId').on('select2:select', event_change_formato)
$('.formato_libro').on('change', event_change_formato)
function event_change_formato(){
ancho_libro = getDimensionLibro().ancho;
alto_libro = getDimensionLibro().alto;
// Si es negro o color
if ($('#tipoImpresion').select2('data')[0].id == 'negro' ||
$('#tipoImpresion').select2('data')[0].id == 'color') {
$('#compPaginasNegro').trigger('change')
}
// Si es negrohq o colorhq
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' ||
$('#tipoImpresion').select2('data')[0].id == 'colorhq') {
$('#compPaginasNegrohq').trigger('change');
}
$('.solapas_cubierta').trigger('change')
$('.solapas_sobrecubierta').trigger('change')
checkPaginasPresupuesto()
updatePresupuesto({
update_lineas: true,
update_servicios: true,
update_envios: true,
update_resumen: true,
update_tiradas_alternativas: true
})
//updateLineasPresupuesto()
//update_servicios(false)
}
<?php endif; ?>
<?php if($tipo_impresion_id != 1 && $tipo_impresion_id != 3 && $tipo_impresion_id != 5 && $tipo_impresion_id != 7): ?>
$("#solapas").on("click", function () {
var e = document.getElementById('div_solapas_ancho');
if (document.getElementById('solapas').checked) {
e.style.display = "block";
}
else {
e.style.display = "none";
$('#solapas_ancho').val(0)
}
$('#serv_default').click()
});
<?php endif; ?>
$("#solapas_sobrecubierta").on("click", function () {
var e = document.getElementById('div_solapas_ancho_sobrecubierta');
if (document.getElementById('solapas_sobrecubierta').checked) {
e.style.display = "block";
}
else {
e.style.display = "none";
$('#solapas_ancho_sobrecubierta').val(0)
}
$('#serv_default').click()
});
let initTamanioPersonalizado = <?php echo ($presupuestoEntity->papel_formato_personalizado==true?1:0); ?>;
if(initTamanioPersonalizado != null){
if ( initTamanioPersonalizado){
$('#papelFormatoId').next(".select2-container").hide();
}
}
<?= $this->endSection() ?>
</div> <!-- //.accordion -->

View File

@ -16,7 +16,7 @@
<label for="id" class="form-label">
<?= lang('Presupuestos.id') ?>
</label>
<input readonly style="background: #E8E8E8;" id="id" name="id" maxLength="12" class="form-control" value="<?= old('id', $presupuestoEntity->id) ?>">
<input readonly style="background: #E8E8E8;" id="id" name="id" maxLength="12" class="form-control" value="">
</div><!--//.mb-3 -->
</div><!--//.col -->
@ -26,9 +26,9 @@
<?= lang('Presupuestos.created_at') ?>
</label>
<?php if(str_contains($formAction,'edit')): ?>
<input readonly style="background: #E8E8E8;" id="updated_at" name="updated_at" maxLength="12" class="form-control" value="<?= old('created_at', (isset($presupuestoEntity->updated_at)) ? date ('d/m/Y', strtotime($presupuestoEntity->updated_at)) : "") ?>">
<input readonly style="background: #E8E8E8;" id="updated_at" name="updated_at" maxLength="12" class="form-control" value="">
<?php else: ?>
<input readonly style="background: #E8E8E8;" id="created_at" name="created_at" maxLength="12" class="form-control" value="<?= old('created_at', (isset($presupuestoEntity->created_at)) ? date ('d/m/Y', strtotime($presupuestoEntity->created_at)) : "") ?>">
<input readonly style="background: #E8E8E8;" id="created_at" name="created_at" maxLength="12" class="form-control" value="">
<?php endif; ?>
</div><!--//.mb-3 -->
</div><!--//.col -->
@ -38,11 +38,11 @@
<label for="estado_id" class="form-label">
<?= lang('Presupuestos.presupuestoEstado') ?>
</label>
<select disabled id="estado_id" name="estado_id" maxLength="11" style="background-color: #E8E8E8;" class="form-control" value="<?= old(1, $presupuestoEntity->estado_id) ?>">
<option value=1 <?= $presupuestoEntity->estado_id==1? ' selected':''?>>
<select disabled id="estado_id" name="estado_id" maxLength="11" style="background-color: #E8E8E8;" class="form-control select2bs" value="">
<option value=1 >
<?=lang('Presupuestos.presupuestoEstadoBorrador') ?>
</option>
<option value=2 <?= $presupuestoEntity->estado_id==2? ' selected':''?>>
<option value=2 >
<?=lang('Presupuestos.presupuestoEstadoAceptado') ?>
</option>
</select>
@ -54,15 +54,11 @@
<label for="incRei" class="form-label">
<?= lang('Presupuestos.incRei') ?>
</label>
<select id="incRei" name="inc_rei" maxLength="11" class="form-control" value="<?= old('inc_rei', $presupuestoEntity->inc_rei) ?>">
<?php if (isset($incReiList) && is_array($incReiList) && !empty($incReiList)) : ?>
<option> </option>
<?php foreach ($incReiList as $k => $v) : ?>
<option value="<?= $k ?>" <?= $k == $presupuestoEntity->inc_rei ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
<select id="incRei" name="inc_rei" maxLength="11" class="form-control select2bs" value="">
<option value="0">No</option>
<option value="incidencia">Incidencia</option>
<option value="reimpresion">Reimpresion</option>
<option value="sin_cargo">Sin cargo</option>
</select>
</div><!--//.mb-3 -->
@ -77,7 +73,7 @@
<label for="titulo" class="form-label">
<?=lang('Presupuestos.titulo') ?>*
</label>
<input type="text" id="titulo" name="titulo" maxLength="300" class="form-control" value="<?=old('titulo', $presupuestoEntity->titulo) ?>">
<input type="text" id="titulo" name="titulo" maxLength="300" class="form-control" value="">
</div><!--//.mb-3 -->
</div><!--//.col -->
@ -87,7 +83,7 @@
<label for="autor" class="form-label">
<?=lang('Presupuestos.autor') ?>
</label>
<input type="text" id="autor" name="autor" maxLength="150" class="form-control" value="<?=old('autor', $presupuestoEntity->autor) ?>">
<input type="text" id="autor" name="autor" maxLength="150" class="form-control" value="">
</div><!--//.mb-3 -->
</div><!--//.col -->
@ -101,7 +97,7 @@
<label for="coleccion" class="form-label">
<?=lang('Presupuestos.coleccion') ?>
</label>
<input type="text" id="coleccion" name="coleccion" maxLength="255" class="form-control" value="<?=old('coleccion', $presupuestoEntity->coleccion) ?>">
<input type="text" id="coleccion" name="coleccion" maxLength="255" class="form-control" value="">
</div><!--//.mb-3 -->
</div>
@ -110,7 +106,7 @@
<label for="numeroEdicion" class="form-label">
<?=lang('Presupuestos.numeroEdicion') ?>
</label>
<input type="text" id="numeroEdicion" name="numero_edicion" maxLength="50" class="form-control" value="<?=old('numero_edicion', $presupuestoEntity->numero_edicion) ?>">
<input type="text" id="numeroEdicion" name="numero_edicion" maxLength="50" class="form-control" value="">
</div><!--//.mb-3 -->
</div>
@ -119,7 +115,7 @@
<label for="isbn" class="form-label">
<?=lang('Presupuestos.isbn') ?>
</label>
<input type="text" id="isbn" name="isbn" maxLength="50" class="form-control" value="<?=old('isbn', $presupuestoEntity->isbn) ?>">
<input type="text" id="isbn" name="isbn" maxLength="50" class="form-control" value="">
</div><!--//.mb-3 -->
</div>
@ -129,12 +125,11 @@
<?=lang('Presupuestos.paisId') ?>
</label>
<select id="paisId" name="pais_id" class="form-control select2bs" style="width: 100%;" >
<option value=""><?=lang('Basic.global.pleaseSelectA', [lang('Presupuestos.paisId')]) ?></option>
<?php foreach ($paisList as $item) : ?>
<option value="<?=$item->id ?>"<?=$item->id==$presupuestoEntity->pais_id ? ' selected':'' ?>>
<?=$item->nombre ?>
<?php if(isset($pais_default)): ?>
<option value="<?= $pais_default_id ?>" selected>
<?= $pais_default ?>
</option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div><!--//.mb-3 -->
</div>
@ -150,14 +145,6 @@
<?= lang('Presupuestos.clienteId') ?>*
</label>
<select id="clienteId" name="cliente_id" class="form-control select2bs2" style="width: 100%;">
<?php if (isset($clienteList) && is_array($clienteList) && !empty($clienteList)) :
foreach ($clienteList as $k => $v) : ?>
<option value="<?= $k ?>" <?= $k == $presupuestoEntity->cliente_id ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div><!--//.mb-3 -->
</div><!--//.col -->
@ -167,7 +154,7 @@
<label for="referenciaCliente" class="form-label">
<?=lang('Presupuestos.referenciaCliente') ?>
</label>
<input type="text" id="referenciaCliente" name="referencia_cliente" maxLength="100" class="form-control" value="<?=old('referencia_cliente', $presupuestoEntity->referencia_cliente) ?>">
<input type="text" id="referenciaCliente" name="referencia_cliente" maxLength="100" class="form-control" value="">
</div><!--//.mb-3 -->
</div><!--//.col -->

View File

@ -93,6 +93,8 @@
<th><?= lang('Proveedores.proveedor') ?></th>
<th><?= lang('Presupuestos.precioUnidad') ?></th>
<th><?= lang('Presupuestos.precioTotal') ?></th>
<th><?= lang('Tarifaacabado.margen') ?></th>
<th></th>
<th></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
@ -103,12 +105,6 @@
<div class="row mb-3 px-4">
<div class="col-md-12 col-lg-4 py-4">
<select id="add_servicio_acabado_list" class="select2bs2" style="width: 100%;">
<option></option>
<?php foreach ($serviciosAcabado as $item) : ?>
<option value="<?= $item->value ?>" >
<?= $item->label ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-12 col-lg-4 px-2 py-4">
@ -131,7 +127,7 @@
<th><?= lang('Tarifapreimpresion.tarifapreimpresion') ?></th>
<th><?= lang('Tarifapreimpresion.coste') ?></th>
<th><?= lang('Presupuestos.precio') ?></th>
<th></th>
<th><?= lang('Tarifaacabado.margen') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
@ -141,12 +137,6 @@
<div class="row mb-3 px-4">
<div class="col-md-12 col-lg-4 py-4">
<select id="add_servicio_preimpresion_list" class="select2bs2" style="width: 100%;">
<option></option>
<?php foreach ($serviciosPreimpresion as $item) : ?>
<option value="<?= $item->value ?>" >
<?= $item->label ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-12 col-lg-4 px-2 py-4">
@ -168,11 +158,11 @@
<th><?= lang('Presupuestos.id') ?></th>
<th><?= lang('Presupuestos.tarifa') ?></th>
<th><?= lang('Proveedores.proveedor') ?></th>
<th><?= lang('Presupuestos.precioUnidad') ?></th>
<th><?= lang('Presupuestos.paginasCuadernillo') ?></th>
<th><?= lang('Presupuestos.tiempo') ?></th>
<th><?= lang('Presupuestos.precioUnidad') ?></th>
<th><?= lang('Presupuestos.precioTotal') ?></th>
<th></th>
<th><?= lang('Tarifaacabado.margen') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
@ -183,12 +173,6 @@
<div class="row mb-3 px-4">
<div class="col-md-12 col-lg-4 py-4">
<select id="add_servicio_enc_list" class="select2bs2" style="width: 100%;">
<option></option>
<?php foreach ($serviciosEncuadernacion as $item) : ?>
<option value="<?= $item->value ?>" >
<?= $item->label ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-12 col-lg-4 px-2 py-4">
@ -211,7 +195,7 @@
<th><?= lang('Tarifamanipulado.tarifamanipulado') ?></th>
<th><?= lang('Presupuestos.precioUnidad') ?></th>
<th><?= lang('Presupuestos.precioTotal') ?></th>
<th></th>
<th><?= lang('Tarifaacabado.margen') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
@ -221,12 +205,6 @@
<div class="row mb-3 px-4">
<div class="col-md-12 col-lg-4 py-4">
<select id="add_servicio_manipulado_list" class="select2bs2" style="width: 100%;">
<option></option>
<?php foreach ($serviciosManipulado as $item) : ?>
<option value="<?= $item->value ?>" >
<?= $item->label ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-12 col-lg-4 px-2 py-4">
@ -249,7 +227,7 @@
<th><?= lang('Tarifaextra.tarifaextra') ?></th>
<th><?= lang('Tarifaextra.coste') ?></th>
<th><?= lang('Presupuestos.precio') ?></th>
<th></th>
<th><?= lang('Tarifaacabado.margen') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
@ -259,12 +237,6 @@
<div class="row mb-3 px-4">
<div class="col-md-12 col-lg-4 py-4">
<select id="add_servicio_extra_list" class="select2bs2" style="width: 100%;">
<option></option>
<?php foreach ($serviciosExtra as $item) : ?>
<option value="<?= $item->value ?>" >
<?= $item->label ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-12 col-lg-4 px-2 py-4">
@ -280,90 +252,3 @@
</div> <!-- //.accordion-collapse -->
</div> <!-- //.accordion-item -->
</div> <!-- //.accordion -->
<?= $this->section("additionalInlineJs") ?>
// Generación de la lista de servicios de acabado (id, nombre)
window.acabadosList = <?php echo json_encode($serviciosAcabado); ?>;
window.serviciosacabadosList = <?php echo json_encode($serviciosAcabadosList); ?>;
window.serviciosAutomaticos = <?php echo json_encode($serviciosAutomaticos); ?>;
window.serviciosencuadernadosList = <?php echo json_encode($serviciosEncuadernacionList); ?>;
window.serviciosmanipuladoList = <?php echo json_encode($serviciosManipuladoList); ?>;
window.serviciospreimpresionList = <?php echo json_encode($serviciosPreimpresionList); ?>;
window.serviciosextraList = <?php echo json_encode($serviciosExtraList); ?>;
window.routes_servicios = {
dataTableOfPresupuestoAcabados: "<?=route_to('dataTableOfPresupuestoAcabados') ?>",
menuItemsOfPresupuestoAcabados: '<?= route_to("menuItemsOfPresupuestoAcabados") ?>',
dataTableOfPresupuestoPreimpresion: "<?=route_to('dataTableOfPresupuestoPreimpresiones') ?>",
dataTableOfPresupuestoEncuadernaciones: "<?=route_to('dataTableOfPresupuestoEncuadernaciones') ?>",
dataTableOfPresupuestoManipulados: "<?=route_to('dataTableOfPresupuestoManipulados') ?>",
menuItemsOfPresupuestoEncuadernaciones: '<?= route_to("menuItemsOfPresupuestoEncuadernaciones") ?>',
dataTableOfPresupuestoServiciosExtra: "<?=route_to('dataTableOfPresupuestoServiciosExtra') ?>",
}
init_servicio_acabado()
init_servicio_encuadernado()
init_servicio_manipulado()
init_servicio_preimpresion()
init_servicio_extra()
/* ELIMINADO PARA COMPROBAR EL MAXIMO DE SOLAPAS DESDE EL BACKEND
PENDIENTE
$('.solapas_cubierta').on('change', function(){
const ancho_libro = getDimensionLibro().ancho;
// ancho_libro*2 + lomo + solapas*2 <= 630
const limite_1 = ((630 - ancho_libro*2 - getLomoLineasPresupuesto()) / 2.0).toFixed(1);
// solapas <= ancho_libro - 10
const limite_2 = ancho_libro - 10;
const limite = Math.min(limite_1, limite_2);
if(parseInt($('#solapas_ancho').val()) > limite){
$('#solapas_ancho').val(limite)
asyncMessageDialog(
window.Presupuestos.advertencia,
window.Presupuestos.actualizacionSolapasCubierta,
function(){});
}
$('#compGramajeCubierta').trigger('change')
})
$('.solapas_sobrecubierta').on('change', function(){
const ancho_libro = getDimensionLibro().ancho;
// ancho_libro*2 + lomo + solapas*2 <= 630
const limite_1 = ((630 - ancho_libro*2 - getLomoLineasPresupuesto()) / 2.0).toFixed(1);
// solapas <= ancho_libro - 10
const limite_2 = ancho_libro - 10;
const limite = Math.min(limite_1, limite_2);
if(parseInt($('#solapas_ancho_sobrecubierta').val()) > limite){
$('#solapas_ancho_sobrecubierta').val(limite)
asyncMessageDialog(
window.Presupuestos.advertencia,
window.Presupuestos.actualizacionSolapasSobrecubierta,
function(){});
}
$('#compGramajeSobrecubierta').trigger('change')
})
*/
<?= $this->endSection() ?>

View File

@ -60,6 +60,7 @@
<option value="lp_cubierta"><?= lang('Presupuestos.cubierta') ?></option>
<option value="lp_sobrecubierta"><?= lang('Presupuestos.sobrecubierta') ?></option>
<option value="lp_guardas"><?= lang('Presupuestos.Guardas') ?></option>
<option value="lp_faja"><?= lang('Presupuestos.faja') ?></option>
</select>
</div>
</div>
@ -70,33 +71,3 @@
</div>
</div>
<!------------------------------------------->
<!-- Código JS de las lineas de presupuesto. -->
<!------------------------------------------->
<?= $this->section("additionalInlineJs") ?>
window.papelGenericoNegroList = <?php echo json_encode($papelGenericoNegroList); ?>;
window.papelGenericoNegroHQList = <?php echo json_encode($papelGenericoNegroHQList); ?>;
window.papelGenericoColorList = <?php echo json_encode($papelGenericoColorList); ?>;
window.papelGenericoColorHQList = <?php echo json_encode($papelGenericoColorHQList); ?>;
window.papelGenericoCubiertaList = <?php echo json_encode($papelGenericoCubiertaList); ?>;
window.papelGenericoSobrecubiertaList = <?php echo json_encode($papelGenericoSobrecubiertaList); ?>;
window.papelGenericoRotativaNegroList = <?php echo json_encode($papelGenericoRotativaNegroList); ?>;
window.papelGenericoRotativaColorList = <?php echo json_encode($papelGenericoRotativaColorList); ?>;
<?php if($tipo_impresion_id == 1 || $tipo_impresion_id == 3 || $tipo_impresion_id == 5 || $tipo_impresion_id == 7): ?>
window.papelGenericoGuardasList = <?php echo json_encode($papelGenericoGuardasList); ?>;
<?php endif; ?>
window.lineasPresupuestoList = <?php echo json_encode($lineasPresupuesto); ?>;
window.routes_lp = {
menuItemsOfPresupuestoAdmin: '<?= route_to("menuItemsOfPresupuestoAdmin") ?>',
updateDataOfPresupuestoAdmin: '<?= route_to("updateDataOfPresupuestoAdmin") ?>',
}
fill_lp_from_bbdd()
checkPaginasPresupuesto()
<?= $this->endSection() ?>

View File

@ -2,20 +2,21 @@
<div class="modal-dialog modal-lg modal-simple">
<div class="modal-content">
<div class="modal-header">
<h4 id="labelTitleConfirmDialog" class="modal-title"><?= lang('PresupuestosDirecciones.direccionTitle') ?></h4>
<h4 id="labelTitleConfirmDialog" class="modal-title">
<?= lang('PresupuestosDirecciones.direccionTitle') ?></h4>
</div>
<div class="modal-body">
<div id='error-tarifa'></div>
<div class="mb-3">
<label for="add_clientedAdd" class="form-label">
<?=lang('PresupuestosDirecciones.clientedAdd') ?>*
</label>
<select id="add_clientedAdd" class="form-control select2bs" style="width: 100%;" >
</select>
</div><!--//.mb-3 -->
<div id='error-tarifa'></div>
<div class="mb-3">
<label for="add_clientedAdd" class="form-label">
<?= lang('PresupuestosDirecciones.clientedAdd') ?>*
</label>
<select id="add_clientedAdd" class="form-control select2bs" style="width: 100%;">
</select>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="add_cantidad" class="form-label">
<?= lang('PresupuestosDirecciones.cantidad') ?>*
@ -41,38 +42,32 @@
<input type="text" id="add_direccion" maxLength="255" class="form-control new-address">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="add_pais_id" class="form-label">
<?=lang('PresupuestosDirecciones.pais') ?>*
<?= lang('PresupuestosDirecciones.pais') ?>*
</label>
<select id="add_pais_id" class="form-control select2bs new-address" style="width: 100%;" >
<option value="" disabled selected><?=lang('PresupuestosDirecciones.selectPais') ?></option>
<?php foreach ($paisList as $item) : ?>
<option value="<?=$item->id ?>"<?=$item->id==1 ? ' selected':'' ?>>
<?=$item->nombre ?>
</option>
<?php endforeach; ?>
<select id="add_pais_id" class="form-control select2bs new-address" style="width: 100%;">
</select>
</div><!--//.mb-3 -->
<div class='row'>
<div id='divMunicipio' class="col-md-12 col-lg-12 pl-4">
<div id='divMunicipio' class="col-md-12 col-lg-12 pl-4">
<div class="mb-3">
<label for="add_municipio" class="form-label">
<?=lang('PresupuestosDirecciones.municipio') ?>*
<?= lang('PresupuestosDirecciones.municipio') ?>*
</label>
<input type="text" id="add_municipio" maxLength="100" class="form-control new-address">
</div><!--//.mb-3 -->
</div>
<div class="col-md-12 col-lg-6 pl-4 spain-data" style="display: none;">
<div class="col-md-12 col-lg-6 pl-4 spain-data" style="display: none;">
<div class="mb-3">
<label for="add_provincia" class="form-label">
<?=lang('PresupuestosDirecciones.provincia') ?>*
<?= lang('PresupuestosDirecciones.provincia') ?>*
</label>
<input type="text" id="add_provincia" maxLength="100" class="form-control new-address">
</div><!--//.mb-3 -->
@ -82,37 +77,42 @@
<div class='row'>
<div class="col-md-12 col-lg-6 pl-4">
<div class="col-md-12 col-lg-6 pl-4">
<div class="mb-3">
<label for="add_cp" class="form-label">
<?=lang('PresupuestosDirecciones.cp') ?>*
<?= lang('PresupuestosDirecciones.cp') ?>*
</label>
<input type="text" id="add_cp" maxLength="100" class="form-control new-address">
</div><!--//.mb-3 -->
</div>
<div class="col-md-12 col-lg-6 pl-4">
<div class="col-md-12 col-lg-6 pl-4">
<div class="mb-3">
<label for="add_telefono" class="form-label">
<?=lang('PresupuestosDirecciones.telefono') ?>*
<?= lang('PresupuestosDirecciones.telefono') ?>*
</label>
<input type="text" id="add_telefono" maxLength="100" class="form-control new-address"></input>
<input type="text" id="add_telefono" maxLength="100"
class="form-control new-address"></input>
</div><!--//.mb-3 -->
</div>
</div> <!-- //.row -->
<div class="col-md-12 col-lg-6 pl-4">
<div class="col-md-12 col-lg-6 pl-4">
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" id="add_entregaPieCalle" name="add_entregaPieCalle" value="1" >
<label class="form-check-label" for="add_entregaPieCalle"><?= lang('PresupuestosDirecciones.entregaPieCalle') ?></label>
<input class="form-check-input" type="checkbox" id="add_entregaPieCalle"
name="add_entregaPieCalle" value="1">
<label class="form-check-label"
for="add_entregaPieCalle"><?= lang('PresupuestosDirecciones.entregaPieCalle') ?></label>
</div>
</div>
<div class="col-md-12 col-lg-6 pl-4">
<div class="col-md-12 col-lg-6 pl-4">
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" id="add_saveDirection" name="add_saveDirection" value="1" >
<label class="form-check-label" for="add_saveDirection"><?= lang('PresupuestosDirecciones.saveDirection') ?></label>
<input class="form-check-input" type="checkbox" id="add_saveDirection" name="add_saveDirection"
value="1">
<label class="form-check-label"
for="add_saveDirection"><?= lang('PresupuestosDirecciones.saveDirection') ?></label>
</div>
</div>
@ -120,279 +120,15 @@
<label style="display:none" for="add_alias" class="form-label save-alias">
<?= lang('PresupuestosDirecciones.alias') ?>*
</label>
<input type="text" id="add_alias" maxLength="100" class="form-control new-address save-alias" style='display: none;'>
<input type="text" id="add_alias" maxLength="100" class="form-control new-address save-alias"
style='display: none;'>
</div><!--//.mb-3 -->
</div>
<div class="modal-footer">
<button id="saveDireccionEnvio"
type="button"
class="btn btn-primary"
>Guardar</button>
<button id="cancelAdd"
type="button"
class="btn btn-default"
>Cancelar</button>
<button id="saveDireccionEnvio" type="button" class="btn btn-primary">Guardar</button>
<button id="cancelAdd" type="button" class="btn btn-default">Cancelar</button>
</div>
</div>
</div>
</div>
<?= $this->section("additionalInlineJs") ?>
$('#cancelAdd').on('click', function(){
$('#addressForm').modal("hide");
})
$('#add_cantidad').on('change', function(){
if(parseInt($('#add_cantidad').val()) > $('#add_cantidad').attr('max-value'))
$('#add_cantidad').val($('#add_cantidad').attr('max-value'))
})
$('#saveDireccionEnvio').on('click', function(){
if(validate_fields()){
if($('#addressForm').attr('action')=='edit'){
tableEnvios.row( $("#addressForm").attr('row') )
.remove()
.draw();
}
var peso_total_libro = 0
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var rowData = this.data();
peso_total_libro += parseFloat(rowData.peso)
})
const peso_envio = peso_total_libro*parseInt($('#add_cantidad').val())/1000.0
$.post( '<?= route_to('dataTableOfPresupuestoDirecciones') ?>',
{
tipo: "get_tarifa",
peso: peso_envio,
paisId: $("#add_pais_id").val(),
cp: $('#add_cp').val(),
tipo_envio: $('#add_entregaPieCalle').is(":checked")?'palets':'cajas',
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
})
.done(function( data ) {
if(data.length >0){
var precios = []
for (var i = 0; i < data.length; i++) {
if(peso_envio>data[i].peso_max || data[i].precio_max == 0){
data[i].precio = (parseFloat(data[i].precio_min) + (peso_envio-parseFloat(data[i].peso_min))*parseFloat(data[i].precio_adicional)).toFixed(2);
}
// si no se calcula linealmente
else{
m=((data[i].precio_max-data[i].precio_min)/(data[i].peso_max-data[i].peso_min))
b=data[i].precio_max-m*data[i].peso_max
data[i].precio = parseFloat(m*peso_envio+b).toFixed(2);
}
data[i].margen = data[i].margen
}
const tarifa_final = data.reduce((previous, current) => {
return current.precio < previous.precio ? current : previous;
});
tarifa_final.cantidad=parseInt($('#add_cantidad').val())
tarifa_final.peso=peso_envio
tableEnvios.row
.add({
'tarifa_id': tarifa_final.id,
'cantidad': tarifa_final.cantidad,
'peso': tarifa_final.peso.toFixed(3),
'att': $('#add_att').val(),
'email': $('#add_email').val(),
'direccion': $('#add_direccion').val(),
'cp': $('#add_cp').val(),
'municipio': $('#add_municipio').val(),
'provincia': $('#add_provincia').val(),
'paisId': $('#add_pais_id').val(),
'telefono': $('#add_telefono').val(),
'proveedor': tarifa_final.proveedor,
'proveedor_id': tarifa_final.proveedor_id,
'precio': tarifa_final.precio,
'margen': tarifa_final.margen,
'entregaPieCalle': $('#add_entregaPieCalle').is(":checked")?1:0,
'actionBtns_direcciones': actionBtns_direcciones,
})
.draw();
// Se guarda la dirección
if($('#add_saveDirection').is(":checked") &&
$('#add_alias').val().length>0){
$.post( '/clientes/clientedirecciones/add',
{
cliente_id: $('#clienteId').val(),
'att': $('#add_att').val(),
'email': $('#add_email').val(),
'direccion': $('#add_direccion').val(),
'cp': $('#add_cp').val(),
'municipio': $('#add_municipio').val(),
'provincia': $('#add_provincia').val(),
'paisId': $('#add_pais_id').val(),
'telefono': $('#add_telefono').val(),
'alias': $('#add_alias').val(),
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
})
.done(function( data ) {
})
}
checkInsertar()
//updateTotales(false, false, true)
updatePresupuesto({
update_lineas: false,
update_servicios: true,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true
})
$('#addressForm').modal("hide");
}
else{
popErrorAlert('<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>', 'error-tarifa')
}
});
}
})
function validate_fields(){
$( ".error-text-form" ).remove();
var returnValue = false
$("input.new-address").each( function() {
if($('#' + this.id).val().length == 0 && $('#' + this.id).css('display') != 'none'){
$('#' + this.id).after(
"<p style='font-size: 11px !important;" +
"padding: 0 !important; " +
"color: #b11f1f !important;' " +
"class='error-text-form'>" +'<?= lang('PresupuestosDirecciones.validation.required'); ?>' + '</p>')
}
returnValue = true
})
return returnValue
}
$('#add_saveDirection').change(function() {
if(this.checked) {
$('.save-alias').css('display', 'inline')
}
else{
$('.save-alias').css('display', 'none')
}
$('#add_saveDirection').val(this.checked);
});
$('#add_clientedAdd').select2({
allowClear: false,
minimumResultsForSearch: Infinity,
dropdownParent: $('#addressForm'),
ajax: {
url: '<?= route_to("menuItemsOfClienteDirecciones") ?>',
type: 'post',
dataType: 'json',
data: function (params) {
return {
cliente_id: $('#clienteId').val(),
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
},
delay: 60,
processResults: function (response) {
yeniden(response.<?= csrf_token() ?>);
return {
results: response.menu
};
},
cache: true
}
})
$('#add_clientedAdd').on('select2:select', function (e) {
$('.save-alias').css('display', 'none')
$('#add_alias').val('')
$('#add_saveDirection').attr("disabled", true)
var data = e.params.data;
$.ajax({
type: "POST",
url: '<?=route_to('dataTableOfClienteDirecciones') ?>',
dataType: 'json',
data: {
tipo: 'direccion',
id: data.id,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
},
success: function (data) {
if(data.length>0){
$('#add_att').val(data[0].att)
$('#add_direccion').val(data[0].direccion)
$('#add_cp').val(data[0].cp)
$('#add_municipio').val(data[0].municipio)
$('#add_provincia').val(data[0].provincia)
$('#add_telefono').val(data[0].telefono)
$('#add_email').val(data[0].email)
$('#add_pais_id').val(data[0].pais_id).change();
}
yeniden(data.<?= csrf_token() ?>);
return true;
},
error: function(e){
return false;
}
})
return false;
});
$('.new-address').on('change', function(e){
if (e.originalEvent) {
// user-triggered event
$('#add_clientedAdd').val(null).trigger('change');
$('#add_saveDirection').removeAttr("disabled");
}
})
// clear modal items when close
$('#addressForm').on('hidden.bs.modal', function () {
$('#add_alias').val("")
$('#add_att').val("")
$('#add_email').val("")
$('#add_direccion').val("")
$("#add_pais_id").val(1).change()
$("#add_clientedAdd").val("").change()
$('#add_municipio').val("")
$('#add_provincia').val("")
$('#add_cp').val("")
$('#add_telefono').val("")
$('#add_saveDirection').prop('checked', false)
$('#add_entregaPieCalle').prop('checked', false)
})
<?=$this->endSection() ?>
</div>

View File

@ -1,91 +0,0 @@
async function updatePresupuesto(
{
update_lineas = false,
update_servicios = false,
update_envios = false,
update_resumen = false,
update_tiradas_alternativas = false
}) {
new Promise(
async function(resolve, reject){
if(update_lineas){
await updateLineasPresupuesto()
}
else
resolve()
}
).then(function(){
new Promise(
async function(resolve, reject){
if(update_servicios){
await actualizar_servicios()
}
else
resolve()
}
)
}).then(function(){
new Promise(
function(resolve, reject){
if(update_envios){
updateTablaEnvios()
}
else
resolve()
}
)
}).then(function(){
new Promise(
function(resolve, reject){
if(update_resumen){
updateTotales()
}
else
resolve()
}
)
}).then(function(){
new Promise(
async function(resolve, reject){
if(update_tiradas_alternativas){
await actualizar_tiradas_alternativas()
}
else
resolve()
}
)
})
}
async function updateLineasPresupuesto(){
$('#tableLineasPresupuesto tbody tr:visible ').each(async function(){
if(this.id.endsWith('lp_bn')){
await calcularPresupuesto_bn({}, true);
}
else if(this.id.endsWith('lp_bnhq')){
await calcularPresupuesto_bnhq({}, true);
}
else if(this.id.endsWith('lp_color')){
await calcularPresupuesto_color({}, true);
}
else if(this.id.endsWith('lp_colorhq')){
await calcularPresupuesto_colorhq({}, true);
}
else if(this.id.endsWith('lp_rot_bn')){
await calcularPresupuesto_rot_bn(false, true, {})
}
else if(this.id.endsWith('lp_rot_color')){
await calcularPresupuesto_rot_color(false, true, {})
}
else if(this.id.endsWith('_cubierta')){
await calcularPresupuesto_cubierta(false, {})
}
else if(this.id.endsWith('_guardas')){
await calcularPresupuesto_guardas(false, {})
}
})
}

View File

@ -2,137 +2,149 @@
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingOne">
<button type="button" class="accordion-button" data-bs-toggle="collapse"
data-bs-target="#accordionPreviewTip" aria-expanded="false"
aria-controls="accordionPreviewTip">
data-bs-target="#accordionPreviewTip" aria-expanded="false"
aria-controls="accordionPreviewTip">
<h4><?= lang("Presupuestos.preview") ?></h4>
</button>
</h2>
<div id="accordionPreviewTip" class="accordion-collapse collapse show"
data-bs-parent="#accordionPreview">
data-bs-parent="#accordionPreview">
<div class="accordion-body">
<div class="nav-align-top mb-4">
<ul class="nav nav-pills mb-3" role="tablist">
<li id="tab-pv-bn" class="nav-item" style="display: none">
<button
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_bn"
aria-controls="pv_bn"
aria-selected="true">
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_bn"
aria-controls="pv_bn"
aria-selected="true">
<?= lang("Presupuestos.preview-conf-bn") ?>
</button>
</li>
<li id="tab-pv-bnhq" class="nav-item" style="display: none">
<button
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_bnhq"
aria-controls="pv_bnhq"
aria-selected="true">
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_bnhq"
aria-controls="pv_bnhq"
aria-selected="true">
<?= lang("Presupuestos.preview-conf-bn-hq") ?>
</button>
</li>
<li id="tab-pv-color" class="nav-item" style="display: none">
<button
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_color"
aria-controls="pv_color"
aria-selected="true">
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_color"
aria-controls="pv_color"
aria-selected="true">
<?= lang("Presupuestos.preview-conf-color") ?>
</button>
</li>
<li id="tab-pv-colorhq" class="nav-item" style="display: none">
<button
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_colorhq"
aria-controls="pv_colorhq"
aria-selected="true">
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_colorhq"
aria-controls="pv_colorhq"
aria-selected="true">
<?= lang("Presupuestos.preview-conf-color-hq") ?>
</button>
</li>
<li id="tab-pv-rot-bn" class="nav-item" style="display: none">
<button
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_rot_bn"
aria-controls="pv_rot_bn"
aria-selected="true">
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_rot_bn"
aria-controls="pv_rot_bn"
aria-selected="true">
<?= lang("Presupuestos.preview-conf-rot-bn") ?>
</button>
</li>
<li id="tab-pv-rot-color" class="nav-item" style="display: none">
<button
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_rot_color"
aria-controls="pv_rot_color"
aria-selected="true">
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_rot_color"
aria-controls="pv_rot_color"
aria-selected="true">
<?= lang("Presupuestos.preview-conf-rot-color") ?>
</button>
</li>
<li id="tab-pv-guardas" class="nav-item" style="display: none">
<button
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_guardas"
aria-controls="pv_guardas"
aria-selected="false">
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_guardas"
aria-controls="pv_guardas"
aria-selected="false">
<?= lang("Presupuestos.previewConfiguracionGuardas") ?>
</button>
</li>
<li id="tab-pv-cubierta" class="nav-item" style="display: none">
<button
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_cubierta"
aria-controls="pv_cubierta"
aria-selected="false">
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_cubierta"
aria-controls="pv_cubierta"
aria-selected="false">
<?= lang("Presupuestos.previewConfiguracionCubierta") ?>
</button>
</li>
<li id="tab-pv-esquema-cubierta" class="nav-item" style="display: none">
<button
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_esquema_cubierta"
aria-controls="pv_esquema_cubierta"
aria-selected="false">
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_esquema_cubierta"
aria-controls="pv_esquema_cubierta"
aria-selected="false">
<?= lang("Presupuestos.previewEsquemaCubierta") ?>
</button>
</li>
<li id="tab-pv-sobrecubierta" class="nav-item" style="display: none">
<button
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_sobrecubierta"
aria-controls="pv_sobrecubierta"
aria-selected="false">
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_sobrecubierta"
aria-controls="pv_sobrecubierta"
aria-selected="false">
<?= lang("Presupuestos.previewConfiguracionSobrecubierta") ?>
</button>
</li>
<li id="tab-pv-faja" class="nav-item" style="display: none">
<button
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#pv_faja"
aria-controls="pv_faja"
aria-selected="false">
<?= lang("Presupuestos.previewConfiguracionFaja") ?>
</button>
</li>
</ul>
<div class="tab-content border border-container">
@ -171,7 +183,7 @@
</div>
</div>
<hr class="mx-n4"/>
<hr class="mx-n4" />
<!-- Detalles del presupuesto -->
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
@ -206,6 +218,9 @@
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
<div id="shape-container">
<div class="d-flex align-items-stretch justify-content-end">
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
</div>
<div id="pv_bn_shape" class="draw-shapes"></div>
</div>
@ -249,7 +264,7 @@
</div>
</div>
<hr class="mx-n4"/>
<hr class="mx-n4" />
<!-- Detalles del presupuesto -->
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
@ -284,6 +299,9 @@
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
<div id="shape-container">
<div class="d-flex align-items-stretch justify-content-end">
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
</div>
<div id="pv_bnhq_shape" class="draw-shapes"></div>
</div>
@ -327,7 +345,7 @@
</div>
</div>
<hr class="mx-n4"/>
<hr class="mx-n4" />
<!-- Detalles del presupuesto -->
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
@ -362,6 +380,9 @@
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
<div id="shape-container">
<div class="d-flex align-items-stretch justify-content-end">
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
</div>
<div id="pv_color_shape" class="draw-shapes"></div>
</div>
@ -375,7 +396,7 @@
<div class="col-3">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<div class="row g-3 mb-3">
<div class="row g-3 mb-3">
<div class="col-12">
<a id="pv_colorhq_pg" href="#" sk-url="<?= site_url('configuracion/papelesgenericos/edit/'); ?>" target="_blank">
<div class="d-grid">
@ -405,7 +426,7 @@
</div>
</div>
<hr class="mx-n4"/>
<hr class="mx-n4" />
<!-- Detalles del presupuesto -->
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
@ -440,6 +461,10 @@
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
<div id="shape-container">
<div class="d-flex align-items-stretch justify-content-end">
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
</div>
<div id="pv_colorhq_shape" class="draw-shapes"></div>
</div>
@ -483,7 +508,7 @@
</div>
</div>
<hr class="mx-n4"/>
<hr class="mx-n4" />
<!-- Detalles del presupuesto -->
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
@ -516,6 +541,9 @@
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
<div id="shape-container">
<div class="d-flex align-items-stretch justify-content-end">
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
</div>
<div id="pv_rot_bn_shape" class="draw-rot-shapes"></div>
</div>
@ -552,7 +580,7 @@
<a id="pv_rot_color_mi" href="#" sk-url="<?= site_url('configuracion/maquinas/edit/'); ?>" target="_blank">
<div class="d-grid">
<button type="button"
class="btn btn-label-primary">
class="btn btn-label-primary">
<?= lang("Presupuestos.previewAreaImpresion") ?>
</button>
</div>
@ -560,7 +588,7 @@
</div>
</div>
<hr class="mx-n4"/>
<hr class="mx-n4" />
<!-- Detalles del presupuesto -->
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
@ -593,6 +621,9 @@
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
<div id="shape-container">
<div class="d-flex align-items-stretch justify-content-end">
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
</div>
<div id="pv_rot_color_shape" class="draw-rot-shapes"></div>
</div>
@ -636,7 +667,7 @@
</div>
</div>
<hr class="mx-n4"/>
<hr class="mx-n4" />
<!-- Detalles del presupuesto -->
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
@ -671,6 +702,9 @@
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
<div id="shape-container">
<div class="d-flex align-items-stretch justify-content-end">
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
</div>
<div id="pv_guardas_shape" class="draw-shapes"></div>
</div>
@ -714,7 +748,7 @@
</div>
</div>
<hr class="mx-n4"/>
<hr class="mx-n4" />
<!-- Detalles del presupuesto -->
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
@ -752,6 +786,9 @@
<h6><?= lang("Presupuestos.previewCubierta") ?></h6>
<div id="pv-cubierta-container">
<div class="d-flex align-items-stretch justify-content-end">
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
</div>
<div id="pv_cubierta_shape" class="draw-shapes"></div>
</div>
@ -795,7 +832,7 @@
</div>
</div>
<hr class="mx-n4"/>
<hr class="mx-n4" />
<!-- Detalles del presupuesto -->
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
@ -817,6 +854,9 @@
<h6><?= lang("Presupuestos.previewConfiguracionEsquemaCubierta") ?></h6>
<div id="shape-container">
<div class="d-flex align-items-stretch justify-content-end">
<button type="button" class="btn btn-xs btn-primary h-100 download-shape"><i class="ti ti-xs ti-download"></i></button>
</div>
<div id="pv_ec_shape" class="draw-shapes"></div>
</div>
@ -860,7 +900,7 @@
</div>
</div>
<hr class="mx-n4"/>
<hr class="mx-n4" />
<!-- Detalles del presupuesto -->
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
@ -906,6 +946,87 @@
</div>
</div>
<div class="tab-pane fade" id="pv_faja" role="tabpanel">
<div class="row">
<div class="col-3">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<div class="row g-3 mb-3">
<div class="col-12">
<a id="pv_faja_pg" href="#" sk-url="<?= site_url('configuracion/papelesgenericos/edit/'); ?>" target="_blank">
<div class="d-grid">
<button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelGenerico") ?>
</button>
</div>
</a>
</div>
<div class="col-12">
<a id="pv_faja_pi" href="#" sk-url="<?= site_url('configuracion/papelesimpresion/edit/'); ?>" target="_blank">
<div class="d-grid">
<button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewPapelCompra") ?>
</button>
</div>
</a>
</div>
<div class="col-12">
<a id="pv_faja_mi" href="#" sk-url="<?= site_url('configuracion/maquinas/edit/'); ?>" target="_blank">
<div class="d-grid">
<button type="button" class="btn btn-label-primary">
<?= lang("Presupuestos.previewAreaImpresion") ?>
</button>
</div>
</a>
</div>
</div>
<hr class="mx-n4" />
<!-- Detalles del presupuesto -->
<h6><?= lang("Presupuestos.previewDetalles") ?></h6>
<dl class="row mb-0">
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewGramaje") ?></dt>
<dd id="pv_faja_gramaje" class="col-6 text-left">TBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewMano") ?></dt>
<dd id="pv_faja_mano" class="col-sm-6 text-left">TBD</dd>
<dt class="col-6 fw-semibold pv-solapas"><?= lang("Presupuestos.previewSolapas") ?></dt>
<dd id="pv_faja_solapas" class="col-sm-6 text-left pv-solapas">TBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewMaquina") ?></dt>
<dd id="pv_faja_maquina" class="col-6 text-left">TBDxTBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewAreaImpresion") ?></dt>
<dd id="pv_faja_maquina_impresion" class="col-6 text-left">TBDxTBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewLibro") ?></dt>
<dd id="pv_faja_libro" class="col-6 text-left">TBDxTBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewForma") ?></dt>
<dd id="pv_faja_forma" class="col-6 text-left">TBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewFormas") ?></dt>
<dd id="pv_faja_nFormas" class="col-6 text-left">TBD</dd>
</dl>
</div>
</div>
<div class="col-9">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<h6><?= lang("Presupuestos.previewFaja") ?></h6>
<div id="pv-cubierta-container">
<div id="pv_faja_shape" class="draw-shapes"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@ -914,73 +1035,3 @@
</div> <!-- //.accordion-collapse -->
</div> <!-- //.accordion-item -->
</div> <!-- //.accordion -->
<!------------------------------------------------------->
<!-- Código JS comportamiento ?????. -->
<!------------------------------------------------------->
<?= $this->section("additionalInlineJs") ?>
$('#tab-pv-bn').on( "click", function() {
previewInteriorPlana('bn', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
} );
$('#tab-pv-bnhq').on( "click", function() {
previewInteriorPlana('bnhq', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
} );
$('#tab-pv-color').on( "click", function() {
previewInteriorPlana('color', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
} );
$('#tab-pv-colorhq').on( "click", function() {
previewInteriorPlana('colorhq', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
} );
$('#tab-pv-rot-bn').on( "click", function() {
previewRotativa('rot_bn', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
} );
$('#tab-pv-rot-color').on( "click", function() {
previewRotativa('rot_color', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
} );
$('#tab-pv-guardas').on( "click", function() {
previewInteriorPlana('guardas', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
} );
$('#tab-pv-cubierta').on( "click", function() {
previewInteriorPlana('cubierta', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
} );
$('#tab-pv-esquema-cubierta').on( "click", function() {
previewEsquemaCubierta('ec', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
} );
$('#tab-pv-sobrecubierta').on( "click", function() {
previewInteriorPlana('sobrecubierta', <?php echo $isCosido; ?>, <?php echo $isTapaDura; ?>);
} );
<?= $this->endSection() ?>

View File

@ -18,55 +18,57 @@
<!-- Price Details -->
<dl class="row mb-0">
<dt class="col-5 py-1 fw-normal text-end">Coste papel</dt>
<dd id="totalCostePapel" class="py-1 col-6 text-end"><?= old('0', $presupuestoEntity->total_coste_papel) ?>€</dd>
<dd id="totalCostePapel" class="py-1 col-6 text-end"></dd>
<dt class="col-5 py-1 fw-normal text-end">Margen papel</dt>
<dd id="porcentajeMargenPapel" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenPercent_papel) ?>%</dd>
<dd id="margenPapel" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margen_papel) ?>€</dd>
<dd id="porcentajeMargenPapel" class="col-3 text-end py-1"></dd>
<dd id="margenPapel" class="col-3 text-end py-1"></dd>
<dt class="col-5 fw-normal text-end">Coste impresión</dt>
<dd id="totalCosteImpresion" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_coste_impresion) ?>€</dd>
<dd id="totalCosteImpresion" class="col-6 text-end"></dd>
<dt class="col-5 py-1 fw-normal text-end">Margen impresión</dt>
<dd id="porcentajeMargenImpresion" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenPercent_impresion) ?>%</dd>
<dd id="margenImpresion" class="col-3 py-1 text-end"><?= old('0', $presupuestoEntity->total_margen_impresion) ?>€</dd>
<dd id="porcentajeMargenImpresion" class="col-3 text-end py-1"></dd>
<dd id="margenImpresion" class="col-3 py-1 text-end"></dd>
<dt class="col-5 fw-normal text-end">Coste servicios</dt>
<dd id="totalServicios" class="col-6 text-end py-1"><?= old('0', $presupuestoEntity->total_coste_servicios) ?>€</dd>
<dd id="totalServicios" class="col-6 text-end py-1"></dd>
<dt class="col-5 fw-normal text-end">Margen servicios</dt>
<dd id="porcentajeMargenServicios" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenPercent_servicios) ?>%</dd>
<dd id="margenServicios" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margen_servicios) ?>€</dd>
<dd id="porcentajeMargenServicios" class="col-3 text-end py-1"></dd>
<dd id="margenServicios" class="col-3 text-end py-1"></dd>
<dt class="col-5 fw-normal text-end">Coste de envío</dt>
<dd id="totalEnvios"class="col-6 text-end py-1"><?= old('0', $presupuestoEntity->total_coste_envios) ?>€</dd>
<dd id="costeEnvios"class="col-6 text-end py-1"></dd>
<dt class="col-5 fw-normal text-end">Precio de envío</dt>
<dd id="totalEnvios"class="col-6 text-end py-1"></dd>
<dt class="col-5 fw-normal text-end">Margen envío</dt>
<dd id="margenEnvios" class="col-6 text-end py-1"><?= old('0', $presupuestoEntity->total_margen_envios) ?>€</dd>
<dd id="margenEnvios" class="col-6 text-end py-1"></dd>
</dl>
<hr class="mx-n4">
<dl class="row mb-0">
<dt class="col-5 fw-normal text-end">Total Costes</dt>
<dd id="totalCostes" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_costes) ?>€</dd>
<dd id="totalCostes" class="col-6 text-end"></dd>
<dt class="col-5 fw-normal text-end">Total Margen</dt>
<dd id="porcentajeMargen" class="col-3 text-end py-1"><?= old('0', round(($presupuestoEntity->total_costes+$presupuestoEntity->total_margenes)>0? 100*$presupuestoEntity->total_margenes/($presupuestoEntity->total_costes+$presupuestoEntity->total_margenes) : 0,0)) ?>%</dd>
<dd id="totalMargenes" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenes) ?>€</dd>
<dd id="porcentajeMargen" class="col-3 text-end py-1"></dd>
<dd id="totalMargenes" class="col-3 text-end py-1"></dd>
</dl>
<hr class="mx-n4">
<dl class="row mb-0">
<dt class="col-5 fw-normal text-end">Total</dt>
<dd id="totalAntesDescuento" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_antes_descuento) ?>€</dd>
<dt class="col-5 py-1 fw-normal text-end">Descuento</dt>
<dd id="dd" class="col-3 text-end py-1"><input id="total_descuentoPercent" type="number" value="<?= old('0', $presupuestoEntity->total_descuentoPercent) ?>" class="update-totales form-control" style="width:100% !important;"></dd>
<dd id="descuentoTotal" class="col-3 py-1 text-end"><?= old('0', $presupuestoEntity->total_descuento) ?>€</dd>
<dd id="totalAntesDescuento" class="col-6 text-end"></dd>
<dt class="col-5 py-1 fw-normal text-end">Descuento (%)</dt>
<dd id="dd" class="col-3 text-end py-1"><input id="total_descuentoPercent" type="number" value="" class="update-totales form-control" style="width:100% !important;"></dd>
<dd id="descuentoTotal" class="col-3 py-1 text-end"></dd>
<dt class="col-5 text-end">Total presupuesto</dt>
<dd id="totalDespuesDecuento" class="col-6 fw-semibold text-end"><?= old('0', $presupuestoEntity->total_presupuesto) ?>€</dd>
<dd id="totalDespuesDecuento" class="col-6 fw-semibold text-end"></dd>
<dt class="col-5 fw-normal text-end">Precio unidad</dt>
<dd id="precioUnidadPresupuesto" class="col-6 text-end mb-2"><?= old('0', $presupuestoEntity->total_precio_unidad) ?>€</dd>
<dd id="precioUnidadPresupuesto" class="col-6 text-end mb-2"></dd>
<dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor</dt>
<dd id="factor" class="col-6 text-end mb-2" style="font-size: smaller !important;"><?= old('0', is_numeric($presupuestoEntity->total_factor) ? $presupuestoEntity->total_factor : 0) ?></dd>
<dd id="factor" class="col-6 text-end mb-2" style="font-size: smaller !important;"></dd>
<dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor Ponderado</dt>
<dd id="factor_ponderado" class="col-6 text-end mb-0" style="font-size: smaller !important;"><?= old('0', is_numeric($presupuestoEntity->total_factor_ponderado) ? $presupuestoEntity->total_factor_ponderado : 0) ?></dd>
<dd id="factor_ponderado" class="col-6 text-end mb-0" style="font-size: smaller !important;"></dd>
</dl>
</div>
<div class="d-grid float-end mb-4">
@ -80,10 +82,10 @@
<?php if ($presupuestoEntity->estado_id == 2): ?>
<div class="row mt-5">
<div class="mb-1">
<label for="paginas" class="form-label">
<label for="totalAceptado" class="form-label">
<?= lang('Presupuestos.totalAceptado') ?>
</label>
<input disabled type="text" id="totalAceptado" name="totalAceptado" class="form-control" value="<?= old('paginas', $presupuestoEntity->total_aceptado) ?>" <?php echo ($tipo_impresion_id == 21)?' max=80':'' ?>>
<input disabled type="text" id="totalAceptado" name="totalAceptado" class="form-control" value="" <?php echo ($tipo_impresion_id == 21)?' max=80':'' ?>>
</div><!--//.mb-3 -->
</div>
<?php endif; ?>

View File

@ -1,299 +0,0 @@
function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
var totalPapel = 0
var margenPapel = 0
var totalImpresion = 0
var totalImpresionforMargen = 0
var margenImpresion = 0
var totalServicios = 0
var margenServicios = 0
var totalEnvios = 0
var margenEnvios = 0
var sumForFactor = 0.0
var sumForFactorPonderado = 0.0
var margenPorHoras = 0.0;
if(updateLP){
if(typeof $("#tableLineasPresupuesto").DataTable() !== 'undefined'){
$("#tableLineasPresupuesto").DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var rowData = this.data();
if(rowData.check_papel_total){
totalPapel += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val())
margenPapel += parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val())
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val())
sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val())
}
if(rowData.check_impresion_total){
//totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
margenPorHoras += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
totalImpresion += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
if(rowData.maquinaTipo=='inkjet'){
totalImpresion += parseFloat(rowData.totalTinta)
totalImpresion += parseFloat(rowData.totalCorte)
sumForFactor += (parseFloat(rowData.totalTinta) + parseFloat(rowData.totalCorte))
}
//margenImpresion += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
//margenPorHoras += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
margenImpresion += parseFloat($('#' + rowData.row_id + '_margenClicks').val())
sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenClicks').val())
if(!isNaN(parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val()))){
totalImpresion += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
sumForFactor += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
}
}
})
}
totalImpresion -= margenImpresion
totalPapel -= margenPapel
margenImpresion += margenPorHoras
var porcentajeMargenPapel = isNaN(margenPapel/(totalPapel)*100.0)?0:margenPapel/(totalPapel)*100.0
$('#porcentajeMargenPapel').text(porcentajeMargenPapel.toFixed(0) + '%')
$('#totalCostePapel').text((addSeparatorsNF(totalPapel.toFixed(2), ".", ",", ".")) + "€")
$('#margenPapel').text((addSeparatorsNF(margenPapel.toFixed(2), ".", ",", ".")) + "€")
$('#totalCostePapel').attr('val',totalPapel.toFixed(2))
$('#margenPapel').attr('val',margenPapel.toFixed(2))
var porcentajeMargenImpresion = isNaN(margenImpresion/(totalImpresion)*100.0)?0:margenImpresion/(totalImpresion)*100.0
$('#porcentajeMargenImpresion').text(porcentajeMargenImpresion.toFixed(0) + '%')
$('#totalCosteImpresion').text((addSeparatorsNF(totalImpresion.toFixed(2), ".", ",", ".")) + "€")
$('#margenImpresion').text((addSeparatorsNF(margenImpresion.toFixed(2), ".", ",", ".")) + "€")
$('#totalCosteImpresion').attr('val',totalImpresion.toFixed(2))
$('#margenImpresion').attr('val',margenImpresion.toFixed(2))
}
else{
totalPapel = parseFloat($('#totalCostePapel').attr('val'))
margenPapel = parseFloat($('#margenPapel').attr('val'))
totalImpresion = parseFloat($('#totalCosteImpresion').attr('val'))
margenImpresion = parseFloat($('#margenImpresion').attr('val'))
}
sumForFactorPonderado = sumForFactor;
if(updateServicios){
if ( typeof $("#tableOfServiciosEncuadernacion").DataTable() !== 'undefined' && $("#tableOfServiciosEncuadernacion").DataTable().rows().count() > 0){
$('#tableOfServiciosEncuadernacion tbody tr').each(function(){
var currentRow = $(this).closest("tr");
var subId = $('#tableOfServiciosEncuadernacion').DataTable().cell(currentRow,0).node().innerHTML;
var total = parseFloat($('#precio_total_encuadernado_' + subId)[0].value)
totalServicios += total
var base = parseFloat($('#precio_total_encuadernado_' + subId)[0].value)/(1+parseFloat($('#enc_margen_' + subId)[0].innerHTML)/100.0);
var margen = total - base;
margenServicios += margen;
})
}
if ( typeof $("#tableOfServiciosAcabado").DataTable() !== 'undefined' && $("#tableOfServiciosAcabado").DataTable().rows().count() > 0){
$('#tableOfServiciosAcabado tbody tr').each(function(){
var currentRow = $(this).closest("tr");
var subId = $('#tableOfServiciosAcabado').DataTable().cell(currentRow,0).node().innerHTML;
var total = parseFloat($('#precio_total_acabado_' + subId)[0].value)
totalServicios += total
var base = parseFloat($('#precio_total_acabado_' + subId)[0].value)/(1+parseFloat($('#acabado_margen_' + subId)[0].innerHTML)/100.0);
var margen = total - base;
margenServicios += margen;
})
}
if ( typeof $("#tableOfServiciosPreimpresion").DataTable() !== 'undefined' && $("#tableOfServiciosPreimpresion").DataTable().rows().count() > 0){
$('#tableOfServiciosPreimpresion tbody tr').each(function(){
var currentRow = $(this).closest("tr");
var subId = $('#tableOfServiciosPreimpresion').DataTable().cell(currentRow,0).node().innerHTML;
var total = parseFloat($('#precio_preimpresion_' + subId)[0].value)
totalServicios += total
var base = parseFloat($('#precio_preimpresion_' + subId)[0].value)/(1+parseFloat($('#preimpresion_margen_' + subId)[0].innerHTML)/100.0);
var margen = total - base;
margenServicios += margen;
})
}
if ( typeof $("#tableOfServiciosExtra").DataTable() !== 'undefined' && $("#tableOfServiciosExtra").DataTable().rows().count() > 0){
$('#tableOfServiciosExtra tbody tr').each(function(){
var currentRow = $(this).closest("tr");
var subId = $('#tableOfServiciosExtra').DataTable().cell(currentRow,0).node().innerHTML;
var total = parseFloat($('#precio_servicioextra_' + subId)[0].value)
totalServicios += total
var base = parseFloat($('#precio_servicioextra_' + subId)[0].value)/(1+parseFloat($('#servicioextra_margen_' + subId)[0].innerHTML)/100.0);
var margen = total - base;
margenServicios += margen;
})
}
if ( typeof $("#tableOfServiciosManipulado").DataTable() !== 'undefined' && $("#tableOfServiciosManipulado").DataTable().rows().count() > 0){
$('#tableOfServiciosManipulado tbody tr').each(function(){
var currentRow = $(this).closest("tr");
var subId = $('#tableOfServiciosManipulado').DataTable().cell(currentRow,0).node().innerHTML;
var total = parseFloat($('#precio_total_manipulado_' + subId)[0].value)
totalServicios += total
var base = parseFloat($('#precio_total_manipulado_' + subId)[0].value)/(1+parseFloat($('#manipulado_margen_' + subId)[0].innerHTML)/100.0);
var margen = total - base;
margenServicios += margen;
})
}
totalServicios -= margenServicios;
sumForFactorPonderado += totalServicios;
var porcentajeMargenServicios = margenServicios/(totalServicios)*100
$('#porcentajeMargenServicios').text(isNaN(porcentajeMargenServicios.toFixed(0))?0:porcentajeMargenServicios.toFixed(0) + '%')
$('#totalServicios').text((addSeparatorsNF(totalServicios.toFixed(2), ".", ",", ".")) + "€")
$('#margenServicios').text((addSeparatorsNF(margenServicios.toFixed(2), ".", ",", ".")) + "€")
$('#totalServicios').attr('val',totalServicios.toFixed(2) + '€')
$('#margenServicios').attr('val',margenServicios.toFixed(2) + '€')
}
else{
totalServicios = parseFloat($('#totalServicios').attr('val'))
margenServicios = parseFloat($('#margenServicios').attr('val'))
sumForFactorPonderado += totalServicios;
}
if(updateEnvio){
if ( typeof $('#tableOfDireccionesEnvio').DataTable() !== 'undefined' && $('#tableOfDireccionesEnvio').DataTable().rows().count() > 0){
$('#tableOfDireccionesEnvio').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var data = this.data()
totalEnvios += parseFloat(data.precio)
margenEnvios += parseFloat((data.precio)*data.margen/100)
} );
}
totalEnvios -= margenEnvios
$('#totalEnvios').text((addSeparatorsNF(totalEnvios.toFixed(2), ".", ",", ".")) + "€")
$('#margenEnvios').text((addSeparatorsNF(margenEnvios.toFixed(2), ".", ",", ".")) + "€")
$('#totalEnvios').attr('val',totalEnvios.toFixed(2) + '€')
$('#margenEnvios').attr('val',margenEnvios.toFixed(2) + '€')
}
else{
totalEnvios = parseFloat($('#totalEnvios').attr('val'))
margenEnvios = parseFloat($('#margenEnvios').attr('val'))
}
var totalCostes = parseFloat(totalPapel.toFixed(2)) + parseFloat(totalImpresion.toFixed(2)) + parseFloat(totalServicios.toFixed(2)) + parseFloat(totalEnvios.toFixed(2))
var totalMargenes = parseFloat(margenPapel.toFixed(2)) + parseFloat(margenImpresion.toFixed(2)) + parseFloat(margenServicios.toFixed(2)) + parseFloat(margenEnvios.toFixed(2))
var porcentajeMargen = totalCostes+totalMargenes>0? (100*totalMargenes/(totalCostes+totalMargenes)).toFixed(0) : 0
$('#totalCostes').text((addSeparatorsNF(totalCostes.toFixed(2), ".", ",", ".")) + "€")
$('#totalMargenes').text((addSeparatorsNF(totalMargenes.toFixed(2), ".", ",", ".")) + "€")
$('#totalCostes').attr('val',(totalCostes).toFixed(2) + '€')
$('#totalMargenes').attr('val',(totalMargenes).toFixed(2) + '€')
$('#porcentajeMargen').text(porcentajeMargen + '%')
$('#porcentajeMargen').attr('val',porcentajeMargen)
if($('#total_descuentoPercent').val()<0){
$('#total_descuentoPercent').val(0)
}
var totalAntesDescuento = totalCostes + totalMargenes
var totalDescuento = totalAntesDescuento * parseInt($('#total_descuentoPercent').val())/100
var totalPresupuesto = totalAntesDescuento - totalDescuento
var precioUnidad = totalPresupuesto/parseInt($('#tirada').val())
$('#totalAntesDescuento').text((addSeparatorsNF(totalAntesDescuento.toFixed(2), ".", ",", ".")) + "€")
$('#descuentoTotal').text((addSeparatorsNF(totalDescuento.toFixed(2), ".", ",", ".")) + "€")
$('#totalDespuesDecuento').text((addSeparatorsNF(totalPresupuesto.toFixed(2), ".", ",", ".")) + "€")
$('#precioUnidadPresupuesto').text((addSeparatorsNF(precioUnidad.toFixed(4), ".", ",", ".")) + "€")
$('#totalAntesDescuento').attr('val',(totalAntesDescuento).toFixed(2))
$('#descuentoTotal').attr('val',(totalDescuento).toFixed(2))
$('#totalDespuesDecuento').attr('val',(totalPresupuesto).toFixed(2))
$('#precioUnidadPresupuesto').attr('val',(precioUnidad).toFixed(4))
$('#factor').text(addSeparatorsNF(((totalPresupuesto-totalEnvios-margenEnvios)/sumForFactor).toFixed(2), ".", ",", "."))
$('#factor').attr('val', ((totalPresupuesto-totalEnvios-margenEnvios)/sumForFactor).toFixed(2))
$('#factor_ponderado').text(addSeparatorsNF(((totalPresupuesto-totalEnvios-margenEnvios)/sumForFactorPonderado).toFixed(2), ".", ",", "."))
$('#factor_ponderado').attr('val',((totalPresupuesto-totalEnvios-margenEnvios)/sumForFactorPonderado).toFixed(2))
}
function addSeparatorsNF(nStr, inD, outD, sep)
{
nStr += '';
var dpos = nStr.indexOf(inD);
var nStrEnd = '';
if (dpos != -1) {
nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
nStr = nStr.substring(0, dpos);
}
var rgx = /(\d+)(\d{3})/;
while (rgx.test(nStr)) {
nStr = nStr.replace(rgx, '$1' + sep + '$2');
}
return nStr + nStrEnd;
}
function getValuesResumenForm(){
var formResumen = "";
formResumen += '&total_coste_papel=' + $('#totalCostePapel').attr('val');
formResumen += '&total_margen_papel=' + $('#margenPapel').attr('val');
formResumen += '&total_margenPercent_papel=' + $('#porcentajeMargenPapel').text().replace('%', '');
formResumen += '&total_coste_impresion=' + $('#totalCosteImpresion').attr('val');
formResumen += '&total_margen_impresion=' + $('#margenImpresion').attr('val');
formResumen += '&total_margenPercent_impresion=' + $('#porcentajeMargenImpresion').text().replace('%', '');
formResumen += '&total_coste_servicios=' + $('#totalServicios').attr('val');
formResumen += '&total_margen_servicios=' + $('#margenServicios').attr('val');
formResumen += '&total_margenPercent_servicios=' + $('#porcentajeMargenServicios').text().replace('%', '');
formResumen += '&total_coste_envios=' + $('#totalEnvios').attr('val');
formResumen += '&total_margen_envios=' + $('#margenEnvios').attr('val');
formResumen += '&total_costes=' + $('#totalCostes').attr('val');
formResumen += '&total_margenes=' + $('#totalMargenes').attr('val');
formResumen += '&total_antes_descuento=' + $('#totalAntesDescuento').attr('val');
formResumen += '&total_descuento=' + $('#descuentoTotal').attr('val');
formResumen += '&total_descuentoPercent=' + $('#total_descuentoPercent').val();
formResumen += '&total_presupuesto=' + $('#totalDespuesDecuento').attr('val');
formResumen += '&total_precio_unidad=' + $('#precioUnidadPresupuesto').attr('val');
// replace , for . in the values
formResumen += '&total_factor=' + $('#factor').text().replace(/,/g, '.');
formResumen += '&total_factor_ponderado=' + $('#factor_ponderado').text().replace(/,/g, '.');
if($('#confirmar_presupuesto').prop('checked')){
formResumen += '&confirmar=1';
formResumen += '&total_aceptado=' + $('#totalDespuesDecuento').attr('val');
}
return formResumen
}
$(".update-totales").on("change", function(){
updatePresupuesto({
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: false
})
})

View File

@ -1,397 +0,0 @@
// Selección de la última columna de la tabla de tiradas
const lastColNr_tiradasAlt = $('#tableTiradas').find("tr:first th").length - 1;
// Función para generar los botones de acción de la tabla de tiradas
const actionBtns_tiradasAlt = function (data) {
return `
<a href="javascript:void(0);"><i class="ti ti-check ti-sm comfirm-tirada-alt mx-2" data-id="${data.row_id}"></i></a>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-tirada mx-2" data-id="${data.row_id}"></i></a>
`;
};
// Inicializaciones de la tabla de tiradas
var tableTiradas;
// Espera a que todas las variables necesarias estén definidas
(async () => {
while (!window.hasOwnProperty("datatable_lang_url") && !window.hasOwnProperty("datatable_TA_url"))
await new Promise(resolve => setTimeout(resolve, 200));
initTableTiradas();
fill_tiradas_alternativas();
/*$('.tiradas-alternativas').each(function() {
if ($(this).is('input')) {
$(this).bind('change', update_tiradas_alternativas);
} else if ($(this).is('button')) {
$(this).bind('click', update_tiradas_alternativas);
} else if ($(this).is('table')) {
$(this).bind('draw.dt', update_tiradas_alternativas);
}
else{
// para los botones de borrar
$(this).bind('click', update_tiradas_alternativas);
}
});*/
})();
async function actualizar_tiradas_alternativas(){
if(tableTiradas !== undefined && tableTiradas.rows().count() > 0){
// se obtiene la primera columna de la tabla de tiradas
const data = tableTiradas.rows().data().toArray();
// se borra la tabla de tiradas
tableTiradas.clear().draw();
const tiradas = data.map(row => row.tirada);
// por cada tirada, se añade una fila a la tabla de tiradas
await tiradas.forEach(async function(tirada){
await add_tirada_alternativa(tirada);
});
}
}
// Evento de añadir una tirada alternativa
$('#add_tirada_alt').on('click', function () {
const tirada_alt = parseInt($('#tirada_alt').val());
add_tirada_alternativa(tirada_alt);
showBreadCrumbSaveButton(true);
});
// Funcion para añadir una tirada alternativa
async function add_tirada_alternativa(tirada_alt) {
// se comprueba que la tirada no existe ya en la tabla
const exists = tableTiradas.rows().data().toArray().some(row => row.tirada == tirada_alt);
const isPOD = parseInt($('#tirada').val())<= parseInt($('#POD').val());
const typeIsOk = tirada_alt <= parseInt($('#POD').val()) && isPOD || tirada_alt > parseInt($('#POD').val()) && !isPOD;
if (!exists && typeIsOk) {
const dimension = getDimensionLibro();
let datos = {
tirada: tirada_alt,
merma: get_merma_tirada_alternativa(tirada_alt),
tipo_impresion_id: $('#tipo_impresion_id').val(),
json_tiradas: generate_json_tiradas(),
ancho: dimension.ancho,
alto: dimension.alto,
cliente_id: $('#clienteId').find(":selected").val(),
solapas_cubierta: $('#solapas').is(':checked')?1:0,
solapas_cubierta_ancho: $('#solapas').is(':checked')?parseInt($('#solapas_ancho').val()):0,
solapas_sobrecubierta: $('#solapas_sobrecubierta').is(':checked')?1:0,
solapas_sobrecubierta_ancho: $('#solapas_sobrecubierta').is(':checked')?parseInt($('#solapas_ancho_sobrecubierta').val()):0,
lomo: getLomoExterior(),
};
datos = Object.assign(datos, window.token_ajax);
// Se realiza la petición AJAX
await $.ajax({
type: "POST",
url: window.get_tirada_url,
data: datos,
success: async function (data) {
var coste_total = 0.0;
var margen_total = 0.0;
var costes_servicios = 0.0;
var margen_servicios = 0.0;
var coste_envio = 0.0;
var margen_envio = 0.0;
if(data.lineas.length >0){
// Se cogen los valores de la linea con los datos correspondientes
data.lineas.forEach(function(value) {
coste_total += value.total_coste;
margen_total += value.total_margen;
});
//console.log(datos.tirada);
// Se obtiene el precio de los servicios
const valueAcabados = await get_servAcabados_tiradasAlternativas(parseInt(datos.tirada));
costes_servicios += parseFloat(valueAcabados.coste);
margen_servicios += parseFloat(valueAcabados.margen);
//console.log('coste acabados ('+ datos.tirada +'): ' + valueAcabados.coste);
const valueEncuadernacion = await get_servEncuadernacion_tiradasAlternativas(
parseInt(datos.tirada), parseInt( $('#paginas').val()), parseInt(dimension.ancho), parseInt(dimension.alto));
costes_servicios += parseFloat(valueEncuadernacion.coste);
margen_servicios += parseFloat(valueEncuadernacion.margen);
//console.log('coste encuadernacion ('+ datos.tirada +'): ' + valueEncuadernacion.coste);
const valueManipulado = await get_servManipulado_tiradasAlternativas(parseInt(datos.tirada));
costes_servicios += parseFloat(valueManipulado.coste);
margen_servicios += parseFloat(valueManipulado.margen);
//console.log('coste manipulado ('+ datos.tirada +'): ' + valueManipulado.coste);
const valuePreimpresion = await get_servPreimpresion_tiradasAlternativas(parseInt(datos.tirada));
costes_servicios += parseFloat(valuePreimpresion.coste);
margen_servicios += parseFloat(valuePreimpresion.margen);
const valueServiciosExtra = await get_servExtra_tiradasAlternativas(parseInt(datos.tirada));
costes_servicios += parseFloat(valueServiciosExtra.coste);
margen_servicios += parseFloat(valueServiciosExtra.margen);
//console.log('coste preimpresion ('+ datos.tirada +'): ' + valuePreimpresion.coste);
const valueTransporte = await get_coste_envio_tiradasAlternativas(parseInt(datos.tirada));
coste_envio = valueTransporte.coste;
margen_envio = valueTransporte.margen;
// Se añade la fila a la tabla de tiradas
tableTiradas.row.add({
tirada: datos.tirada,
coste_impresion: coste_total.toFixed(2),
coste_envio: coste_envio.toFixed(2),
margen: ((margen_total + margen_servicios + margen_envio)/(coste_total+coste_envio)*100.0).toFixed(2),
total_pedido: (coste_total + costes_servicios + coste_envio).toFixed(2),
precio_unidad: ((coste_total + costes_servicios + coste_envio) / datos.tirada).toFixed(4),
}).draw(false);
}
yeniden(data[window.csrf_token]);
},
error: function(e){}
});
}
else {
var htmlString = '';
if(typeIsOk){
htmlString = `
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
<span class="alert-icon alert-icon-lg text-primary me-2">
<i class="ti ti-bell ti-sm"></i>
</span>
<div class="d-flex flex-column ps-1">
<h5 class="alert-heading mb-2">` +
window.Presupuestos.errores.tirada_alt_duplicada +
`</h5>
</div>
</div>`;
}
else{
htmlString = `
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
<span class="alert-icon alert-icon-lg text-primary me-2">
<i class="ti ti-bell ti-sm"></i>
</span>
<div class="d-flex flex-column ps-1">
<h5 class="alert-heading mb-2">` +
window.Presupuestos.errores.tirada_alt_tipo +
`</h5>
</div>
</div>`;
}
$('#alert-tiradas_alt').hide().empty().html(htmlString).fadeIn("slow", function(){
setTimeout(function(){
$('#alert-tiradas_alt').fadeOut("slow");
}, 5000);
});
}
}
// Función para obtener el lomo exterior
function getLomoExterior(){
let lomoTotal = 0
try{
$('#tableLineasPresupuesto').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var rowData = this.data();
if(rowData.row_id != 'lp_cubierta' && rowData.tipo != 'lp_sobrecubierta')
lomoTotal += parseFloat(rowData.lomo)
})
}
catch(error){
lomoTotal = 0
}
return lomoTotal
}
// Inicialización de la tabla de tiradas
function initTableTiradas() {
tableTiradas = $('#tableTiradas').DataTable({
"language": {
"url": window.datatable_lang_url
},
"paging": false,
"info": false,
"searching": false,
"ordering": true,
"autoWidth": false,
"responsive": true,
"columnDefs": [
{
orderable: false,
searchable: false,
targets: [lastColNr_tiradasAlt]
},
],
"columns": [
{ data: "tirada" },
{ data: 'coste_impresion' },
{ data: 'coste_envio' },
{ data: 'margen' ,
render: function ( data, type, row ) {
return data + '%';
}
},
{ data: 'total_pedido' },
{ data: 'precio_unidad' },
{
data: actionBtns_tiradasAlt,
className: 'row-edit dt-center'
}
],
order: [[0, 'asc']]
});
}
// Evento de borrado de una fila de la tabla de tiradas
$(document).on('click', '.btn-delete-tirada', function (e) {
const row = $(this).closest('tr');
tableTiradas.row(row)
.remove()
.draw();
showBreadCrumbSaveButton(true);
})
// Función para usar la tirada alternativa como tirada principal
$(document).on('click', '.comfirm-tirada-alt', function (e) {
const row = $(this).closest('tr');
const data = tableTiradas.row(row).data();
updateTablaEnvios($('#tirada').val(), data.tirada).then(function(){
$('#tirada').val(data.tirada);
$('#tirada').trigger('change', [false]);
})
})
// Función para generar el JSON de las lineas de presupuesto para calcular las tiradas
function generate_json_tiradas() {
const data = $('#tableLineasPresupuesto').DataTable().data().toArray();
//return data; // For debugging purposes
json = filterData(data,
['paginas',
'numPagColor',
'paginas_impresion',
'papel', // papel generico
'papel_impresion_id',
'gramaje',
'maquina_id',
'aFavorFibra',
'row_id',
'check_papel_total',
'check_impresion_total',
'cobAmarillo', // tipologia de papel
'cobCyan',
'cobMagenta',
'cobNegro',
'cobCG',
'gotaColor',
'gotaNegro']);
json.forEach(element => {
element['check_papel_total'] = $('#' + element['row_id'] + '_checkPapel').is(':checked') ? 1 : 0;
element['check_impresion_total'] = $('#' + element['row_id'] + '_checkClicks').is(':checked') ? 1 : 0;
});
return JSON.stringify(json);
}
// Función para filtrar las columnas de la tabla de tiradas
function filterData(data, keys) {
return data.map(obj => {
const newObj = {};
keys.forEach(key => {
if (obj.hasOwnProperty(key)) {
newObj[key] = obj[key];
}
});
return newObj;
});
}
// Función para obtener la merma de la tirada alternativa
function get_merma_tirada_alternativa(tirada){
var merma = 0
if(tirada>parseInt($('#POD').val())){
merma = tirada*0.1<=30 ? tirada*0.1 : 30
}
else{
merma_lineas = []
$('#tableLineasPresupuesto').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var rowData = this.data();
if(rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta'){
const formas_linea = $('#isCosido').val()==0?parseInt(rowData.formas):parseInt(rowData.formas)/2
if(formas_linea > tirada)
merma_lineas.push(formas_linea-tirada)
else
merma_lineas.push(tirada%formas_linea)
}
})
if(merma_lineas.length>0)
merma = Math.max(...merma_lineas)
else
merma = 0
}
return merma;
}
function fill_tiradas_alternativas(){
tableTiradas.clear().draw();
const text = $('#tirada_alternativa_json_data').val()
if(text.length>0){
const data = JSON.parse(text);
if(data.length>0){
$.each(data, function(key, value) {
tableTiradas.row.add({
tirada: value.tirada,
coste_impresion: value.coste_impresion,
coste_envio: value.coste_envio,
margen: value.margen,
total_pedido: value.total_pedido,
precio_unidad: value.precio_unidad,
}).draw(false);
});
}
}
}

View File

@ -30,7 +30,7 @@
<th><?= lang('Presupuestos.tiradaMargen') ?></th>
<th><?= lang('Presupuestos.totalPedido') ?></th>
<th><?= lang('Presupuestos.precioUnidad') ?></th>
<th></th>
<th style="min-width: 80px;"></th>
</tr>
</thead>
@ -48,21 +48,6 @@
</div> <!-- //.accordion-item -->
</div> <!-- //.accordion -->
<!------------------------------------------------------->
<!-- Código JS comportamiento ?????. -->
<!------------------------------------------------------->
<?= $this->section("additionalInlineJs") ?>
window.datatable_lang_url = "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json";
window.datatable_TA_url = "<?= route_to('dataTableOfPresupuestoTiradasAlternativas') ?>";
window.get_tirada_url = "<?= route_to('getTiradaData') ?>";
window.error_lang_tirada_alt_duplicada = "<?= lang('Presupuestos.errores.tirada_alt_duplicada') ?>";
window.error_lang_tirada_alt_tipo = "<?= lang('Presupuestos.errores.tirada_alt_tipo') ?>";
<?= $this->endSection() ?>

View File

@ -1,747 +0,0 @@
/*******************************
* Eventos asociados a elementos HTML
*******************************/
$('#compPaginasNegro').on("change", function () {
var negro = parseInt(document.getElementById('compPaginasNegro').value);
const paginas = parseInt(document.getElementById('paginas').value);
if (paginas < negro) {
document.getElementById('compPaginasNegro').value = paginas;
negro = paginas;
}
var color = parseInt(document.getElementById('compPaginasColor').value);
if ($('#tipoImpresion').select2('data')[0].id == 'color') {
var newValue = paginas - negro;
if (newValue != color) {
document.getElementById('compPaginasColor').value = newValue >= 0 ? newValue : 0;
$('#compPaginasColor').change();
}
}
});
$('#compPaginasColor').on("change", function () {
const paginas = parseInt(document.getElementById('paginas').value);
var color = parseInt(document.getElementById('compPaginasColor').value);
var negro = parseInt(document.getElementById('compPaginasNegro').value);
if (paginas < color) {
document.getElementById('compPaginasColor').value = paginas;
color = paginas
}
var newValue = paginas - color;
if (newValue != negro) {
document.getElementById('compPaginasNegro').value = newValue >= 0 ? newValue : 0;
$('#compPaginasNegro').change();
}
});
$('#compPaginasNegrohq').on("change", function () {
var negro = parseInt(document.getElementById('compPaginasNegrohq').value);
const paginas = parseInt(document.getElementById('paginas').value);
if (paginas < negro) {
document.getElementById('compPaginasNegrogq').value = paginas;
negro = paginas;
}
var color = parseInt(document.getElementById('compPaginasColorhq').value);
if ($('#tipoImpresion').select2('data')[0].id == 'colorhq') {
var newValue = paginas - negro;
if (newValue != color) {
document.getElementById('compPaginasColorhq').value = newValue >= 0 ? newValue : 0;
$('#compPaginasColorhq').change();
}
}
});
$('#compPaginasColorhq').on("change", function () {
const paginas = parseInt(document.getElementById('paginas').value);
var color = parseInt(document.getElementById('compPaginasColorhq').value);
var negro = parseInt(document.getElementById('compPaginasNegrohq').value);
if (paginas < color) {
document.getElementById('compPaginasColorhq').value = paginas;
color = paginas
}
var newValue = paginas - color;
if (newValue != negro) {
document.getElementById('compPaginasNegrohq').value = newValue >= 0 ? newValue : 0;
$('#compPaginasNegrohq').change();
}
});
$('#prototipo').on("change", function () {
$('#ferro').prop('checked', true)
});
$('#compPosPaginasColor').on("keyup", function () {
computarPaginasColor(this.value);
});
// Este evento recoloca los headers de las tablas cuando se pulsa el
// boton del acordeon
$('.accordion-button').on('click', function (e) {
if (e.target.id.includes("plana")) {
$("#tableCompIntPlana").DataTable().columns.adjust();
}
else if (e.target.id.includes("rotativa")) {
$("#tableCompIntRotativa").DataTable().columns.adjust();
}
else if (e.target.id.includes("cubierta")) {
$("#tableCompCubierta").DataTable().columns.adjust();
}
else if (e.target.id.includes("guardas")) {
$("#tableCompGuardas").DataTable().columns.adjust();
}
else if (e.target.id.includes("LineasPresupuesto")) {
$("#tableLineasPresupuesto").DataTable().columns.adjust();
}
});
/*******************************
* Metodos
*******************************/
function getRowFromLineaInt(tipo, linea) {
$precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido)) ? "" :
parseFloat(linea.fields.precio_impresion_horas + linea.fields.margen_impresion_horas + linea.fields.precio_click_pedido).toFixed(2);
data = {
'tipo': tipo,
'paginas': linea.fields.paginas,
'papel': linea.fields.papel_generico,
'gramaje': linea.fields.gramaje,
'marca': linea.fields.papel_impresion,
'maquina': linea.fields.maquina,
'numeroPliegos': isNaN(parseFloat(linea.fields.pliegos_libro)) ? "" : parseFloat(linea.fields.pliegos_libro).toFixed(2),
'pliegosPedido': isNaN(parseFloat(linea.fields.pliegos_pedido)) ? "" : parseFloat(linea.fields.pliegos_pedido).toFixed(2),
'precioPliego': isNaN(parseFloat(linea.fields.precios_pliegos)) ? "" : parseFloat(linea.fields.precios_pliegos).toFixed(6),
'libro': isNaN(parseFloat(linea.fields.precio_libro)) ? "" : parseFloat(linea.fields.precio_libro).toFixed(2),
'totalPapelPedido': isNaN(parseFloat(linea.fields.precio_pedido)) ? "" : parseFloat(linea.fields.precio_pedido).toFixed(2),
'lomo': isNaN(parseFloat(linea.fields.mano)) ? "" : parseFloat(linea.fields.mano).toFixed(2),
'peso': isNaN(parseFloat(linea.fields.peso)) ? "" : parseFloat(linea.fields.peso).toFixed(2),
'horasMaquina': isNaN(parseFloat(linea.fields.horas_maquina)) ? "" : parseFloat(linea.fields.horas_maquina).toFixed(2),
'precioImpresion': $precio_impresion,
'total': isNaN(parseFloat(linea.fields.total_impresion).toFixed(2)) ? "" : parseFloat(linea.fields.total_impresion).toFixed(2),
'maquinaId': linea.fields.maquina_id,
'maquinaVelocidad': linea.fields.maquina_velocidad,
'tiempoMaquina': linea.fields.tiempo_maquina,
'papelGenericoId': linea.fields.papel_generico_id,
'papelImpresionId': linea.fields.papel_impresion_id,
'tarifa_impresion_id': linea.fields.tarifa_impresion_id,
}
if(data['tipo']=='guardas')
data['paginas_impresion'] = linea.fields.paginas_impresion;
return data;
}
function getRowFromLineaRot(linea) {
$precio_impresion = isNaN(parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido)) ? "" :
parseFloat(linea.fields.precio_impresion_horas + linea.fields.precio_click_pedido).toFixed(2);
return {
'tipo': 'rotativa',
'paginas': linea.fields.paginas,
'papel': linea.fields.papel_generico,
'gramaje': linea.fields.gramaje,
'marca': linea.fields.papel_impresion,
'aFavorFibra': linea.fields.a_favor_fibra == 1 ? 'si' : 'no',
'maquina': linea.fields.maquina,
'numeroPliegos': isNaN(parseFloat(linea.fields.pliegos_libro)) ? "" : parseFloat(linea.fields.pliegos_libro).toFixed(2),
'pliegosPedido': isNaN(parseFloat(linea.fields.pliegos_pedido)) ? "" : parseFloat(linea.fields.pliegos_pedido).toFixed(2),
'precioPliego': isNaN(parseFloat(linea.fields.precios_pliegos)) ? "" : parseFloat(linea.fields.precios_pliegos).toFixed(6),
'libro': isNaN(parseFloat(linea.fields.precio_libro)) ? "" : parseFloat(linea.fields.precio_libro).toFixed(2),
'totalPapelPedido': isNaN(parseFloat(linea.fields.precio_pedido)) ? "" : parseFloat(linea.fields.precio_pedido).toFixed(2),
'lomo': isNaN(parseFloat(linea.fields.mano)) ? "" : parseFloat(linea.fields.mano).toFixed(2),
'peso': isNaN(parseFloat(linea.fields.peso)) ? "" : parseFloat(linea.fields.peso).toFixed(2),
'horasMaquina': isNaN(parseFloat(linea.fields.horas_maquina)) ? "" : parseFloat(linea.fields.horas_maquina).toFixed(2),
'precioImpresion': $precio_impresion,
'precioPagNegro': isNaN(parseFloat(linea.fields.precio_pagina_negro)) ? "" : parseFloat(linea.fields.precio_pagina_negro).toFixed(6),
'precioPagColor': isNaN(parseFloat(linea.fields.precio_pagina_color)) ? "" : parseFloat(linea.fields.precio_pagina_color).toFixed(6),
'totalTinta': isNaN(parseFloat(linea.fields.precio_tinta)) ? "" : parseFloat(linea.fields.precio_tinta).toFixed(2),
'totalCorte': isNaN(parseFloat(linea.fields.total_corte)) ? "" : parseFloat(linea.fields.total_corte).toFixed(2),
'total': isNaN(parseFloat(linea.fields.total_impresion)) ? "" : (parseFloat(linea.fields.total_impresion)).toFixed(2),
'maquinaId': linea.fields.maquina_id,
'maquinaVelocidad': linea.fields.maquina_velocidad,
'tiempoMaquina': linea.fields.tiempo_maquina,
'papelGenericoId': linea.fields.papel_generico_id,
'papelImpresionId': linea.fields.papel_impresion_id,
'paginasColor': linea.fields.paginas_color,
'tarifa_impresion_id': linea.fields.tarifa_impresion_id,
}
}
function computarPaginasColor(string) {
var numbers = [];
for (const [, beginStr, endStr] of string.matchAll(/(\d+)(?:-(\d+))?/g)) {
const [begin, end] = [beginStr, endStr].map(Number);
numbers.push(begin);
if (endStr !== undefined) {
for (let num = begin + 1; num <= end; num++) {
numbers.push(num);
}
}
}
var numbers2 = [];
numbers.forEach(function (value, i) {
// Si es impar y no está el siguiente par hay que añadirlo
if (value % 2 != 0 && numbers[i + 1] != value + 1) {
numbers2.push(value + 1);
}
});
numbers = numbers.concat(numbers2);
numbers.sort(function (a, b) {
return a - b;
});
calPagesTextarea = document.getElementById('compCalPaginasColor');
calPagesTextarea.value = numbers;
autosize.update(calPagesTextarea);
}
function checkRetractiladoComparador(element) {
switch (element.id) {
case 'retractilado':
if ($('#' + element.id).prop('checked')) {
$('#retractilado5').prop('checked', false);
}
break;
case 'retractilado5':
if ($('#' + element.id).prop('checked')) {
$('#retractilado').prop('checked', false);
}
break;
default:
break;
}
}
function updatePapelesComparador() {
var e = document.getElementById("tipoImpresion");
elements_negro = document.getElementsByClassName('comp-negro-selected');
elements_negrohq = document.getElementsByClassName('comp-negrohq-selected');
elements_color = document.getElementsByClassName('comp-color-selected');
elements_colorhq = document.getElementsByClassName('comp-colorhq-selected');
switch (e.value) {
case "negro":
Array.from(elements_color).forEach(element => {
element.style.display = "none";
});
Array.from(elements_negro).forEach(element => {
element.style.display = "flex";
});
Array.from(elements_negrohq).forEach(element => {
element.style.display = "none";
});
Array.from(elements_colorhq).forEach(element => {
element.style.display = "none";
});
break;
case "negrohq":
Array.from(elements_color).forEach(element => {
element.style.display = "none";
});
Array.from(elements_negro).forEach(element => {
element.style.display = "none";
});
Array.from(elements_negrohq).forEach(element => {
element.style.display = "flex";
});
Array.from(elements_colorhq).forEach(element => {
element.style.display = "none";
});
break;
case "color":
Array.from(elements_negro).forEach(element => {
element.style.display = "flex";
});
Array.from(elements_negrohq).forEach(element => {
element.style.display = "none";
});
Array.from(elements_color).forEach(element => {
element.style.display = "flex";
});
Array.from(elements_colorhq).forEach(element => {
element.style.display = "none";
});
break;
case "colorhq":
Array.from(elements_negro).forEach(element => {
element.style.display = "none";
});
Array.from(elements_negrohq).forEach(element => {
element.style.display = "flex";
});
Array.from(elements_color).forEach(element => {
element.style.display = "none";
});
Array.from(elements_colorhq).forEach(element => {
element.style.display = "flex";
});
break;
default:
break;
}
}
function clearIntLineas(is_color) {
//$("#tableCompIntPlana").DataTable().rows( '.selected' ).deselect();
var tabla = $('#tableCompIntPlana').DataTable();
tabla
.rows(function (idx, data, node) {
return data['tipo'].includes(is_color ? 'color' : 'bn');
})
.remove()
.draw();
//$('#tableCompIntPlana').DataTable().clear().draw();
$('#insertarPlanaBtn').css('display', 'none');
}
function clearCubierta() {
var tabla = $('#tableCompCubierta').DataTable();
tabla
.rows(function (idx, data, node) {
return data['tipo'] === 'cubierta';
})
.remove()
.draw();
if(tabla.rows().count()==0)
$('#insertarCubiertaBtn').css('display', 'none');
}
function clearSobrecubierta() {
var tabla = $('#tableCompCubierta').DataTable();
tabla
.rows(function (idx, data, node) {
return data['tipo'] === 'sobrecubierta';
})
.remove()
.draw();
if(tabla.rows().count()==0)
$('#insertarCubiertaBtn').css('display', 'none');
}
function clearGuardas() {
$('#tableCompGuardas').DataTable().clear().draw();
$('#insertarGuardasBtn').css('display', 'none');
}
function clearIntRot() {
$('#errorComRot').html('');
$('#tableCompIntRotativa').DataTable().clear().draw();
$('#insertarRotativaBtn').css('display', 'none');
}
function selectIntLineas() {
var negro_selected = false;
var color_selected = false;
$("#tableCompIntPlana").DataTable().rows('.selected').deselect();
$("#tableCompIntPlana").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
if (!negro_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('bn')) {
$("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
negro_selected = true;
}
if (!color_selected && $('#tableCompIntPlana').DataTable().cell(rowIdx, 0).data().includes('color')) {
$("#tableCompIntPlana").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
color_selected = true;
}
});
var table = $("#tableCompIntPlana").DataTable();
var rows = table.rows('.selected').indexes();
var data = table.rows(rows).data();
var value_total = 0.00;
for (let i = 0; i < data.length; i++) {
value_total += parseFloat(data[i]['total'])
}
$('#total_comp_plana').html(value_total.toFixed(2));
}
function selectIntRotLineas() {
$("#tableCompIntRotativa").DataTable().rows('.selected').deselect();
let value_total = 0.00;
if ($("#tableCompIntRotativa").DataTable().rows().count() > 0) {
$("#tableCompIntRotativa").DataTable().row(0).nodes().to$().toggleClass('selected');
value_total = parseFloat($("#tableCompIntRotativa").DataTable().rows(0).data()[0]['total'])
};
$('#total_comp_rot').html(value_total.toFixed(2));
}
function selectCubiertaLineas() {
$("#tableCompCubierta").DataTable().rows('.selected').deselect();
cubierta_selected = false;
sobrecubierta_selected = false;
if ($("#tableCompCubierta").DataTable().rows().count() > 0) {
$("#tableCompCubierta").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
if (!cubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'cubierta') {
$("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
cubierta_selected = true;
}
if (!sobrecubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'sobrecubierta') {
$("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
sobrecubierta_selected = true;
}
});
}
var table = $("#tableCompCubierta").DataTable();
var rows = table.rows('.selected').indexes();
var data = table.rows(rows).data();
var value_total = 0.00;
for (let i = 0; i < data.length; i++) {
value_total += parseFloat(data[i]['total'])
}
$('#total_comp_cubierta').html(value_total.toFixed(2));
}
function selectGuardasLineas() {
$("#tableCompGuardas").DataTable().rows('.selected').deselect();
let value_total = 0.00;
if ($("#tableCompGuardas").DataTable().rows().count() > 0) {
$("#tableCompGuardas").DataTable().row(0).nodes().to$().toggleClass('selected');
value_total = parseFloat($("#tableCompGuardas").DataTable().rows(0).data()[0]['total'])
};
$('#total_comp_guardas').html(value_total.toFixed(2));
}
function getIDsComparador(is_color, is_hq) {
if (!is_color) {
if (is_hq) {
var papel = '#compPapelNegrohq';
var gramaje = '#compGramajeNegrohq';
var paginas = '#compPaginasNegrohq';
}
else {
var papel = '#compPapelNegro';
var gramaje = '#compGramajeNegro';
var paginas = '#compPaginasNegro';
}
}
else {
if (is_hq) {
var papel = '#compPapelColorhq';
var gramaje = '#compGramajeColorhq';
var paginas = '#compPaginasColorhq';
}
else {
var papel = '#compPapelColor';
var gramaje = '#compGramajeColor';
var paginas = '#compPaginasColor';
}
}
return {
papel: papel,
gramaje: gramaje,
paginas: paginas,
}
}
function getDimensionLibro() {
var ancho = 0;
var alto = 0;
if ($('#papelFormatoId').select2('data').length > 0) {
if ($('#papelFormatoId').select2('data')[0].id.length > 0) {
ancho = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[0]);
alto = parseFloat($('#papelFormatoId').select2('data')[0].text.trim().split(" x ")[1]);
}
else if (document.getElementById('papelFormatoPersonalizado').checked) {
ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
alto = parseFloat(document.getElementById('papelFormatoAlto').value);
}
}
else if (document.getElementById('papelFormatoPersonalizado').checked) {
ancho = parseFloat(document.getElementById('papelFormatoAncho').value);
alto = parseFloat(document.getElementById('papelFormatoAlto').value);
}
return {
ancho: ancho,
alto: alto
}
}
function checkInputsForRotativa() {
// Si es color, el gramaje y el papel tiene que ser el mismo
try {
if ($('#tipoImpresion').select2('data')[0].id == 'color') {
if ($('#compPapelNegro').select2('data')[0].id == $('#compPapelColor').select2('data')[0].id &&
$('#compGramajeNegro').select2('data')[0].text.trim() == $('#compGramajeColor').select2('data')[0].text.trim()) {
return true;
}
}
else if ($('#tipoImpresion').select2('data')[0].id == 'negro') {
if ($('#compPapelNegro').select2('data')[0].id.length > 0 &&
$('#compGramajeNegro').select2('data')[0].text.length > 0) {
return true;
}
}
}
catch (error) {
return false;
}
return false;
}
function fillIntPlana(data, is_color, is_hq) {
let sorted = data.lineas.sort(
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
sorted.forEach(function (linea) {
if (typeof linea.error == "undefined")
$('#tableCompIntPlana').DataTable().row
.add(getRowFromLineaInt(is_color ? (is_hq ? 'colorhq' : 'color') : (is_hq ? 'bnhq' : 'bn'), linea))
.draw()
})
}
function fillIntRot(data) {
let sorted = data.lineas.sort(
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
sorted.forEach(function (linea) {
if (typeof linea.error == "undefined") {
$('#tableCompIntRotativa').DataTable().row
.add(getRowFromLineaRot(linea))
.draw()
}
})
}
function fillCubierta(data) {
let sorted = data.lineas.sort(
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
sorted.forEach(function (linea) {
if (typeof linea.error == "undefined")
$('#tableCompCubierta').DataTable().row
.add(getRowFromLineaInt('cubierta', linea))
.draw()
})
}
function fillSobrecubierta(data) {
let sorted = data.lineas.sort(
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
sorted.forEach(function (linea) {
if (typeof linea.error == "undefined")
$('#tableCompCubierta').DataTable().row
.add(getRowFromLineaInt('sobrecubierta', linea))
.draw()
})
}
function fillGuardas(data) {
let sorted = data.lineas.sort(
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
sorted.forEach(function (linea) {
if (typeof linea.error == "undefined")
$('#tableCompGuardas').DataTable().row
.add(getRowFromLineaInt('guardas', linea))
.draw()
})
}
function clearCompTable() {
$('#insertarPlanaBtn').addClass('d-none')
$('#insertarRotativaBtn').addClass('d-none')
$('#total_comp_plana').html('0.00')
$('#total_comp_rot').html('0.00')
}
function generateCompJSON() {
data = {}
if ($('#tipoImpresion').select2('data')[0].id == 'negro' || $('#tipoImpresion').select2('data')[0].id == 'color') {
try {
bn_obj = {
"bn": {
'paginas': $('#compPaginasNegro').val(),
'papel_id': $('#compPapelNegro').select2('data')[0].id,
'gramaje': $('#compGramajeNegro').select2('data')[0].text.trim(),
}
}
}
catch (e) {
bn_obj = {}
}
$.extend(data, bn_obj);
}
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' || $('#tipoImpresion').select2('data')[0].id == 'colorhq') {
try {
bnhq_obj = {
"bnhq": {
'paginas': $('#compPaginasNegrohq').val(),
'papel_id': $('#compPapelNegrohq').select2('data')[0].id,
'gramaje': $('#compGramajeNegrohq').select2('data')[0].text.trim(),
}
}
}
catch (e) {
bnhq_obj = {}
}
$.extend(data, bnhq_obj);
}
if ($('#tipoImpresion').select2('data')[0].id == 'color') {
try {
color_obj = {
"color": {
'paginas': $('#compPaginasColor').val(),
'papel_id': $('#compPapelColor').select2('data')[0].id,
'gramaje': $('#compGramajeColor').select2('data')[0].text.trim(),
},
}
}
catch (e) {
color_obj = {}
}
$.extend(data, color_obj);
}
if ($('#tipoImpresion').select2('data')[0].id == 'colorhq') {
try {
colorhq_obj = {
"colorhq": {
'paginas': $('#compPaginasColorhq').val(),
'papel_id': $('#compPapelColorhq').select2('data')[0].id,
'gramaje': $('#compGramajeColorhq').select2('data')[0].text.trim(),
},
}
}
catch (e) {
colorhq_obj = {}
}
$.extend(data, colorhq_obj);
}
try {
cubierta_obj = {
"cubierta": {
'paginas': $('#compCarasCubierta option:selected').val(),
'papel_id': $('#compPapelCubierta').select2('data')[0].id,
'gramaje': $('#compGramajeCubierta').select2('data')[0].text.trim(),
},
}
}
catch (e) {
cubierta_obj = {}
}
$.extend(data, cubierta_obj);
try {
sobrecubierta_obj = {
"sobrecubierta": {
'imprimir': $('#compSobrecubierta option:selected').val(),
'papel_id': $('#compPapelSobrecubierta').select2('data')[0].id,
'gramaje': $('#compGramajeSobrecubierta').select2('data')[0].text.trim(),
},
}
}
catch (e) {
sobrecubierta_obj = {}
}
$.extend(data, sobrecubierta_obj);
if($('#compCarasGuardas').length>0){
try {
guardas_obj = {
"guardas": {
'paginas_impresion': $('#compCarasGuardas option:selected').val(),
'papel_id': $('#compPapelGuardas').select2('data')[0].id,
},
}
}
catch (e) {
guardas_obj = {}
}
$.extend(data, guardas_obj);
}
data_str = JSON.stringify(data)
$('#comparador_json_data').val(data_str)
}

File diff suppressed because it is too large Load Diff

View File

@ -6,25 +6,31 @@
<?= $this->section("content") ?>
<div class="row">
<div id="mainContainer" class="row">
<div class="col-12">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
<form id="presupuestoForm" class="card-body" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= view("themes/vuexy/form/presupuestos/cliente/loader") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<input type="hidden" name="presupuesto_id" id="presupuesto_id" class="form-control"
value="<?= $presupuestoEntity->id ?>"></input>
<input type="hidden" name="tipo_impresion_id" id="tipo_impresion_id" class="form-control"
value="<?= $tipo_impresion_id ?>"></input>
<input type="hidden" name="lomo_cubierta" id="lomo_cubierta" class="form-control"
value="<?= is_null($presupuestoEntity->lomo_cubierta)?0:$presupuestoEntity->lomo_cubierta ?>"></input>
<input type="hidden" name="lomo_sobrecubierta" id="lomo_sobrecubierta" class="form-control"
value="<?= is_null($presupuestoEntity->lomo_sobrecubierta)?0:$presupuestoEntity->lomo_sobrecubierta ?>"></input>
<input type="hidden" name="lomo" id="lomo" class="form-control" value=""></input>
<input type="hidden" name="lomo_cubierta" id="lomo_cubierta" class="form-control" value=""></input>
<input type="hidden" name="lomo_sobrecubierta" id="lomo_sobrecubierta" class="form-control" value=""></input>
<input type="hidden" name="isCosido" id="isCosido" class="form-control"
value="<?= $isCosido ?>"></input>
<input type="hidden" name="presupuesto_id" id="presupuesto_id" class="form-control"
value="<?= $presupuestoEntity->id ?>"></input>
<input type="hidden" name="POD" id="POD" class="form-control"
value="<?= $POD ?>"></input>
<?= view("themes/vuexy/form/presupuestos/admin/_datosPresupuestoItems") ?>
<?= view("themes/vuexy/form/presupuestos/admin/_datosLibroItems") ?>
<?php if (str_contains($formAction, 'edit')): ?>
@ -35,8 +41,12 @@
<?= view("themes/vuexy/form/presupuestos/admin/_datosEnvios") ?>
<?= view("themes/vuexy/form/presupuestos/admin/_comentariosItems") ?>
<?= view("themes/vuexy/components/chat_internal_presupuesto",data:["modelId" => $presupuestoId,"type" => "presupuesto"]) ?>
<?php if ($presupuestoEntity->estado_id == 2) : ?>
<?= view("themes/vuexy/components/dropzone",data: ['id' => 'dropzone-presupuesto-admin-files','modelId' => $presupuestoId]) ?>
<?php endif ?>
<?= view("themes/vuexy/form/presupuestos/admin/_resumenPresupuestoItems") ?>
<?= view("themes/vuexy/form/presupuestos/admin/_tiradasAlternativasItems") ?>
<?php else: ?>
<input type="hidden" name="total_presupuesto" id="total_presupuesto" class="form-control"
value="0.0"></input>
@ -168,155 +178,14 @@
}
}
});
$('#clienteId').select2({
allowClear: false,
ajax: {
url: '<?= route_to("menuItemsOfClientes") ?>',
type: 'post',
dataType: 'json',
data: function(params) {
return {
id: 'id',
text: 'nombre',
searchTerm: params.term,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
},
delay: 60,
processResults: function(response) {
yeniden(response.<?= csrf_token() ?>);
return {
results: response.menu
};
},
cache: true
}
});
/*******************************
* Inicialización de los Select2
*******************************/
$('#incRei').select2({
allowClear: false,
});
$('#paisId').select2({
allowClear: false,
});
<?= $this->endSection() ?>
<!------------------------------------------------------->
<!-- Código JS para detectar cambios en el presupuesto -->
<!------------------------------------------------------->
<?= $this->section("additionalInlineJs") ?>
$(window).on('load', function() {
// Detectar cambios en inputs de texto
$('input[type="text"]').on('input', function() {
showBreadCrumbSaveButton(true);
});
// Detectar cambios en inputs de texto
$('input[type="number"]').on('input', function() {
showBreadCrumbSaveButton(true);
});
// Detectar cambios en select
$('select').change(function() {
showBreadCrumbSaveButton(true);
});
// Detectar cambios en checkboxes
$('input[type="checkbox"]').change(function() {
showBreadCrumbSaveButton(true);
});
// Detectar cambios en textareas
$('textarea').on('input', function() {
showBreadCrumbSaveButton(true);
});
// Detectar cambios en otros tipos de input
$('input[type="radio"]').change(function() {
showBreadCrumbSaveButton(true);
});
// Detectar cambios en otros tipos de input
$('input:not([type])').on('input', function() {
showBreadCrumbSaveButton(true);
});
});
$('#bc-save').on( "click", function() {
showBreadCrumbSaveButton(false);
$('#saveForm').click()
} );
<?= $this->endSection() ?>
<!------------------------------------------->
<!-- Acciones antes de submit... -->
<!------------------------------------------->
<?php if (str_contains($formAction, 'edit')): ?>
<?= $this->section("additionalInlineJs") ?>
var submitButtonClicked; // Variable para almacenar el botón que fue clickeado
// funcion que genera un JSON con la tabla de tiradas alternativas
function generate_json_tiradas() {
const data = tableTiradas.rows().data().toArray();
$('#tirada_alternativa_json_data').val(JSON.stringify(data));
}
$('#saveForm').on("click", function(event) {
event.preventDefault();
save_servicios();
save_datos_envios();
var presupuesto_id = $('#presupuesto_id').val()
$.when(fill_bbdd_from_lp(presupuesto_id).then(function(data, textStatus, jqXHR) {
generateCompJSON()
generate_json_tiradas()
form = $('#presupuestoForm').serialize()
form += getValuesResumenForm()
$.ajax({
type: "POST",
url: "<?php echo $formAction; ?>",
data: form,
success: function (data) {
yeniden(data.<?= csrf_token() ?>)
if('errorMensaje' in data)
popErrorAlert(data.errorMensaje)
else{
showBreadCrumbSaveButton(false)
popSuccessAlert(data.mensaje)
if($('#confirmar_presupuesto').prop('checked')) {
$('#estado_id').val(2)
}
}
}
}).fail(function (jqXHR, textStatus, error) {
// Handle error here
console.log(jqXHR)
});;
}))
return false; //stop the actual form post !important!
});
<?= $this->endSection() ?>
<?php endif; ?>
<?php if (str_contains($formAction, 'edit')): ?>
@ -350,17 +219,6 @@ $('#bc-save').on( "click", function() {
<?= $this->endSection() ?>
<?php endif; ?>
<!------------------------------------------->
<!-- Variables generales usadas en los ficheros js -->
<!------------------------------------------->
<?php if (str_contains($formAction, 'edit')): ?>
<?= $this->section("additionalInlineJs") ?>
window.token_ajax= {<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v};
window.csrf_token = '<?= csrf_token() ?>';
<?= $this->endSection() ?>
<?php endif; ?>
@ -370,6 +228,9 @@ $('#bc-save').on( "click", function() {
<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/css/pages/app-chat.css') ?>">
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/sk-datatables.css') ?>">
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/presupuestoCliente.css') ?>">
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
<?= $this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
@ -379,19 +240,16 @@ $('#bc-save').on( "click", function() {
<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/select/dataTables.select.min.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/autosize/autosize.js') ?>"></script>
<script src="<?= site_url('js_loader/translate_js/Presupuestos') ?>"></script>
<script src="<?= site_url('js_loader/datosLibro_js') ?>"></script>
<?php if (str_contains($formAction, 'edit')): ?>
<script src="<?= site_url('js_loader/datosEnvios_js') ?>"></script>
<script src="<?= site_url('js_loader/resumenPresupuestos_js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestos_js') ?>"></script>
<script src="<?= site_url('js_loader/comparadorPresupuestoAdmin_js') ?>"></script>
<script src="<?= site_url('js_loader/previsualizador_js') ?>"></script>
<script src="<?= site_url('js_loader/lineasPresupuesto_js') ?>"></script>
<script src="<?= site_url('js_loader/tiradasAlternativas_js') ?>"></script>
<script src="<?= site_url('js_loader/datosServicios_js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/two/two.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/perfect-scrollbar/perfect-scrollbar.js') ?>"></script>
<script type="module" src="<?= site_url('assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js') ?>"></script>
<?php else: ?>
<script type="module" src="<?= site_url('assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminAdd.js') ?>"></script>
<?php endif; ?>
<?= $this->endSection() ?>

View File

@ -173,19 +173,10 @@
<div class="col-sm-6">
<select class="form-select select2bs2 calcular-presupuesto" id="acabadoCubierta" name="acabado_cubierta">
<option value="0"> <?=lang('Presupuestos.acabadoNinguno') ?> </option>
</select>
</div>
<div id="retractilado"
class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center solapas-cubierta imagen-selector image-container">
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/retractilado.png") ?>"
alt="Retractilado">
<label class="form-label">
Retractilado
</label>
</div>
</div>
</div>
@ -238,6 +229,7 @@
</label>
<select class="form-select select2bs2 calcular-presupuesto" id="acabadoSobrecubierta"
name="acabado_sobrecubierta">
<option value="0"> <?=lang('Presupuestos.acabadoNinguno') ?> </option>
</select>
</div>
</div>

View File

@ -196,11 +196,15 @@
</div>
</div>
</div>
<button id="submit-all-files" class="btn mt-3 btn-primary btn-submit waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Actualizar ficheros</span>
<button id="btnUploadFile" class="btn mt-3 btn-primary btn-submit waves-effect waves-light ml-2 ">
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('App.global_upload_files') ?></span>
<i class="ti ti-upload ti-xs"></i>
</button>
<button id="submit-all-files" class="btn mt-3 btn-success btn-submit waves-effect waves-light ml-2">
<span class="align-middle d-sm-inline-block d-none me-sm-1"><?= lang('App.global_save_file') ?></span>
<i class="ti ti-device-floppy ti-xs"></i>
</button>
</div>
<?php endif; ?>
</div>

View File

@ -29,6 +29,7 @@
<input readonly hidden id="lomo_minimo_fresado_cosido" value="<?= $lomo_minimo_fresado_cosido ?>"></input>
<input readonly hidden id="pod" value="<?= $POD ?>"></input>
<input readonly hidden id="c" value="<?= $clienteId ?>"></input>
<input readonly hidden id="eb" value="<?= $eb ?>"></input>
<!-- Create Deal Wizard -->
<div id="wizard-presupuesto-cliente" class="bs-stepper vertical mt-2 linear">

View File

@ -2,37 +2,36 @@
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
<?=$this->extend('themes/vuexy/main/defaultlayout') ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
<div class="row">
<div class="col-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="tarifaAcabadoForm" class="card-body" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="tarifaAcabadoForm" class="card-body" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems") ?>
<div class="pt-4">
<input type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>"
/>
<?= anchor(route_to("tarifaAcabadoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
<div class="pt-4">
<input type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>" />
<?= anchor(route_to("tarifaAcabadoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
</div><!--//.col -->
<?php if($formAction == route_to('tarifaAcabadoAdd')): ?>
<div class="accordion mt-3" id="accordionAcabadoLineas" style="visibility:hidden" >
<?php else: ?>
<div class="accordion mt-3" id="accordionAcabadoLineas" style="visibility:visible" >
<?php endif; ?>
<?php if ($formAction == route_to('tarifaAcabadoAdd')): ?>
<div class="accordion mt-3" id="accordionAcabadoLineas" style="visibility:hidden">
<?php else: ?>
<div class="accordion mt-3" id="accordionAcabadoLineas" style="visibility:visible">
<?php endif; ?>
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingOne">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip1" aria-expanded="false" aria-controls="accordionTip1">
@ -51,320 +50,321 @@
<th><?= lang('TarifaAcabadoLineas.tiradaMax') ?></th>
<th><?= lang('TarifaAcabadoLineas.precioMin') ?></th>
<th><?= lang('TarifaAcabadoLineas.margen') ?></th>
<th class="noFilter" ></th>
<th class="noFilter"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</table>
</div>
</div>
</div>
</div> <!-- //.accordion -->
<div class="accordion mt-3" id="accordionTarifaMaquinas" style="visibility:visible">
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingTwo">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTipTarifaMaquina" aria-expanded="false" aria-controls="accordionTipTarifaMaquina">
<h3>Tarifaquinas</h3>
</button>
</h2>
<div id="accordionTipTarifaMaquina" class="accordion-collapse collapse show" data-bs-parent="#accordionTarifaMaquinas">
<div class="accordion-body">
<?= view("themes/vuexy/components/forms/tarifa_maquinas",["id" => "tarifa_maquina_component","tarifaId" => $tarifaacabadoEntity->id ]) ?>
</div> <!-- //.accordion -->
<?php if (str_contains($formAction, 'edit')): ?>
<div class="accordion mt-3" id="accordionTarifaMaquinas" style="visibility:visible">
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingTwo">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTipTarifaMaquina" aria-expanded="false" aria-controls="accordionTipTarifaMaquina">
<h3>Tarifa máquinas</h3>
</button>
</h2>
<div id="accordionTipTarifaMaquina" class="accordion-collapse collapse show" data-bs-parent="#accordionTarifaMaquinas">
<div class="accordion-body">
<?= view("themes/vuexy/components/forms/tarifa_maquinas", ["id" => "tarifa_maquina_component", "tarifaId" => $tarifaacabadoEntity->id]) ?>
</div>
</div>
</div>
</div>
</div> <!-- //.accordion -->
</div><!--//.row -->
</div> <!-- //.accordion -->
<?php endif ?>
</div><!--//.row -->
<?= $this->endSection() ?>
<?= $this->endSection() ?>
<?= $this->section("additionalExternalJs") ?>
<script type="module" src="<?= site_url('assets/js/safekat/pages/tarifas/maquinas/acabado/index.js') ?>"></script>
<?= $this->endSection() ?>
<?= $this->section("additionalExternalJs") ?>
<script type="module" src="<?= site_url('assets/js/safekat/pages/tarifas/maquinas/acabado/index.js') ?>"></script>
<?= $this->endSection() ?>
<?= $this->section("additionalInlineJs") ?>
const lastColNr = $('#tableOfTarifasacabado').find("tr:first th").length - 1;
const url = window.location.href;
const url_parts = url.split('/');
let id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
<?= $this->section("additionalInlineJs") ?>
const lastColNr = $('#tableOfTarifasacabado').find("tr:first th").length - 1;
const url = window.location.href;
const url_parts = url.split('/');
let id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
id = url_parts[url_parts.length-1];
}
}
const actionBtns = function(data) {
const actionBtns = function(data) {
return `
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
<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>
<span class="cancel"></span>
`;
};
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
<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>
<span class="cancel"></span>
`;
};
var editor = new $.fn.dataTable.Editor( {
var editor = new $.fn.dataTable.Editor( {
ajax: {
url: "<?= route_to('tarifaAcabadoLineasDTE') ?>",
headers: {
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
},
url: "<?= route_to('tarifaAcabadoLineasDTE') ?>",
headers: {
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
},
},
table : "#tableOfTarifaacabadolineas",
idSrc: 'id',
fields: [
{
name: "proveedor_id",
type: "select",
}, {
name: "tirada_min"
}, {
name: "precio_max"
}, {
name: "tirada_max"
}, {
name: "precio_min"
},{
name: "margen"
}, {
"name": "tarifa_acabado_id",
"type": "hidden"
},{
name: "proveedor_nombre",
"type": "hidden"
},{
"name": "deleted_at",
"type": "hidden"
},{
"name": "is_deleted",
"type": "hidden"
},
table : "#tableOfTarifaacabadolineas",
idSrc: 'id',
fields: [
{
name: "proveedor_id",
type: "select",
}, {
name: "tirada_min"
}, {
name: "precio_max"
}, {
name: "tirada_max"
}, {
name: "precio_min"
},{
name: "margen"
}, {
"name": "tarifa_acabado_id",
"type": "hidden"
},{
name: "proveedor_nombre",
"type": "hidden"
},{
"name": "deleted_at",
"type": "hidden"
},{
"name": "is_deleted",
"type": "hidden"
},
]
} );
} );
// Generación de la lista de proveedores (id, nombre) para encuadernación
const suppliersList = <?php echo json_encode($proveedores); ?>;
editor.field( 'proveedor_id' ).update( suppliersList );
// Generación de la lista de proveedores (id, nombre) para encuadernación
const suppliersList = <?php echo json_encode($proveedores); ?>;
editor.field( 'proveedor_id' ).update( suppliersList );
editor.on( 'preSubmit', function ( e, d, type ) {
editor.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['tarifa_acabado_id'] = id;
d.data[0]['tarifa_acabado_id'] = id;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['tarifa_acabado_id'] = id;
}
for (v in d.data){
d.data[v]['tarifa_acabado_id'] = id;
}
});
editor.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
});
}
});
editor.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
});
editor.on( 'submitSuccess', function ( e, json, data, action ) {
editor.on( 'submitSuccess', function ( e, json, data, action ) {
theTable.clearPipeline();
theTable.draw();
});
});
function searchProviders(){
function searchProviders(){
var values = [];
$('#select_Proveedor').find(':selected').each(function () {
values.push($(this).val());
values.push($(this).val());
});
theTable.column(0).search(values).draw();
}
}
// Setup - add a text input to each footer cell
$('#tableOfTarifaacabadolineas thead tr').clone(true).appendTo('#tableOfTarifaacabadolineas thead');
$('#tableOfTarifaacabadolineas thead tr:eq(1) th').each(function (i) {
// Setup - add a text input to each footer cell
$('#tableOfTarifaacabadolineas thead tr').clone(true).appendTo('#tableOfTarifaacabadolineas thead');
$('#tableOfTarifaacabadolineas thead tr:eq(1) th').each(function (i) {
if (!$(this).hasClass("noFilter")) {
var title = $(this).text();
title = title.replace(/ /g, "_").replace(/\./g, "_");
var title = $(this).text();
title = title.replace(/ /g, "_").replace(/\./g, "_");
if(i==0){
if(i==0){
// Agregar un selector en la primera columna
$(this).html(`<select id=select_${title} class="form-control select2" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>`);
// Agregar un selector en la primera columna
$(this).html(`<select id=select_${title} class="form-control select2" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>`);
// Agregar opciones al selector
var selector = $('select', this);
const suppliersList = <?php echo json_encode($proveedores); ?>;
//selector.append('<option value="">Todos</option>'); // Opción vacía
for (j = 0; j < suppliersList.length; j++) {
selector.append('<option value="' + suppliersList[j].value + '">' + suppliersList[j].label + '</option>');
};
$('#select_' + title).select2({
multiple: true,
placeholder: ""
});
// Agregar opciones al selector
var selector = $('select', this);
const suppliersList = <?php echo json_encode($proveedores); ?>;
//selector.append('<option value="">Todos</option>'); // Opción vacía
for (j = 0; j < suppliersList.length; j++) {
selector.append('<option value="' + suppliersList[j].value + '">' + suppliersList[j].label + '</option>');
};
$('#select_' + title).select2({
multiple: true,
placeholder: ""
});
selector.bind('select2:select', searchProviders);
selector.bind('select2:unselect', searchProviders);
selector.bind('select2:select', searchProviders);
selector.bind('select2:unselect', searchProviders);
$('#select_' + title).val("").trigger('change');
$('#select_' + title).val("").trigger('change');
}
else{
$(this).html(`
<div class='d-flex'>
<input name=min_${title} id=min_${title} class="form-control" type='text' min='0' placeholder='Min' style='width: 80px;'/>
<input name=max_${title} id=max_${title} class="form-control ml-1" type='text' min='0' placeholder='Max' style='width: 80px;'/>
</div>
`);
$('input', this).on('change clear', function () {
var minInputValue = parseFloat($(`#min_${title}`).val().replace(',','.')) || "";
var maxInputValue = parseFloat($(`#max_${title}`).val().replace(',','.')) || "";
$(this).html(`
<div class='d-flex'>
<input name=min_${title} id=min_${title} class="form-control" type='text' min='0' placeholder='Min' style='width: 80px;' />
<input name=max_${title} id=max_${title} class="form-control ml-1" type='text' min='0' placeholder='Max' style='width: 80px;' />
</div>
`);
if (theTable.column(i).search() !== [minInputValue,maxInputValue]) {
theTable
.column(i)
.search([minInputValue,maxInputValue])
.draw();
}
});
$('input', this).on('change clear', function () {
var minInputValue = parseFloat($(`#min_${title}`).val().replace(',','.')) || "";
var maxInputValue = parseFloat($(`#max_${title}`).val().replace(',','.')) || "";
if (theTable.column(i).search() !== [minInputValue,maxInputValue]) {
theTable
.column(i)
.search([minInputValue,maxInputValue])
.draw();
}
}
else {
});
}
}
else {
$(this).html('<span></span>');
}
});
var theTable = $('#tableOfTarifaacabadolineas').DataTable( {
orderCellsTop: true,
serverSide: true,
processing: true,
autoWidth: true,
responsive: true,
fixedHeader: true,
lengthMenu: [ 5, 10, 25],
order: [[ 0, "asc" ], [ 1, "asc" ]],
pageLength: 10,
lengthChange: true,
paging: true,
info: false,
stateSave: false,
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('tarifaAcabadoLineasDT') ?>',
data: {
id_tarifaacabado: id,
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columns: [
{ 'data': 'proveedor_id',
render: function(data, type, row, meta) {
var value = suppliersList.find(element => element.value === data);
return value['label'];
},
},
{ 'data': 'tirada_min' },
{ 'data': 'precio_max' },
{ 'data': 'tirada_max' },
{ 'data': 'precio_min' },
{ 'data': 'margen' },
{
data: actionBtns,
className: 'row-edit dt-center'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr]
},
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
buttons: [ {
className: 'btn btn-primary me-sm-3 me-1',
extend: "createInline",
editor: editor,
formOptions: {
submitTrigger: -1,
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
}
} ]
} );
// Activate an inline edit on click of a table cell
$('#tableOfTarifaacabadolineas').on( 'click', 'tbody span.edit', function (e) {
editor.inline(
theTable.cells(this.parentNode.parentNode, '*').nodes(),
{
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
cancelTrigger: 'span.cancel',
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
submitTrigger: 'span.edit',
submit: 'allIfChanged'
}
);
} );
// Delete row
$(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: `/tarifas/acabados/lineas/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)
})
}
});
<?= $this->endSection() ?>
<?=$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/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") ?>">
<?=$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>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<?=$this->endSection() ?>
var theTable = $('#tableOfTarifaacabadolineas').DataTable( {
orderCellsTop: true,
serverSide: true,
processing: true,
autoWidth: true,
responsive: true,
fixedHeader: true,
lengthMenu: [ 5, 10, 25],
order: [[ 0, "asc" ], [ 1, "asc" ]],
pageLength: 10,
lengthChange: true,
paging: true,
info: false,
stateSave: false,
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('tarifaAcabadoLineasDT') ?>',
data: {
id_tarifaacabado: id,
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columns: [
{ 'data': 'proveedor_id',
render: function(data, type, row, meta) {
var value = suppliersList.find(element => element.value === data);
return value['label'];
},
},
{ 'data': 'tirada_min' },
{ 'data': 'precio_max' },
{ 'data': 'tirada_max' },
{ 'data': 'precio_min' },
{ 'data': 'margen' },
{
data: actionBtns,
className: 'row-edit dt-center'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr]
},
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
buttons: [ {
className: 'btn btn-primary me-sm-3 me-1',
extend: "createInline",
editor: editor,
formOptions: {
submitTrigger: -1,
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
}
} ]
} );
// Activate an inline edit on click of a table cell
$('#tableOfTarifaacabadolineas').on( 'click', 'tbody span.edit', function (e) {
editor.inline(
theTable.cells(this.parentNode.parentNode, '*').nodes(),
{
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
cancelTrigger: 'span.cancel',
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
submitTrigger: 'span.edit',
submit: 'allIfChanged'
}
);
} );
// Delete row
$(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: `/tarifas/acabados/lineas/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)
})
}
});
<?= $this->endSection() ?>
<?= $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/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") ?>">
<?= $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>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -6,160 +6,163 @@
<?= $this->section("content") ?>
<div class="row">
<div class="col-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="tarifaManipuladoForm" class="card-body" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/vuexy/form/tarifas/manipulado/_tarifaManipuladoFormItems") ?>
<div class="pt-4">
<input type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>"
/>
<?= anchor(route_to("tarifaManipuladoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start",]) ?>
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="tarifaManipuladoForm" class="card-body" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/vuexy/form/tarifas/manipulado/_tarifaManipuladoFormItems") ?>
<div class="pt-4">
<input type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>" />
<?= anchor(route_to("tarifaManipuladoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start",]) ?>
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
</div><!--//.col -->
<?php if($formAction == site_url('tarifas/tarifasmanipulado/add')): ?>
<div class="accordion mt-3" id="accordionManipuladoLineas" style="visibility:hidden" >
<?php else: ?>
<div class="accordion mt-3" id="accordionManipuladoLineas" style="visibility:visible" >
<?php endif; ?>
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingOne">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip1" aria-expanded="false" aria-controls="accordionTip1">
<h3><?= lang("TarifaManipuladoLineas.moduleTitle") ?></h3>
</button>
</h2>
<?php if ($formAction == site_url('tarifas/tarifasmanipulado/add')): ?>
<div class="accordion mt-3" id="accordionManipuladoLineas" style="visibility:hidden">
<?php else: ?>
<div class="accordion mt-3" id="accordionManipuladoLineas" style="visibility:visible">
<?php endif; ?>
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingOne">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip1" aria-expanded="false" aria-controls="accordionTip1">
<h3><?= lang("TarifaManipuladoLineas.moduleTitle") ?></h3>
</button>
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionManipuladoLineas">
<div class="accordion-body">
<table id="tableOfTarifamanipuladolineas" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('TarifaManipuladoLineas.tiradaMin') ?></th>
<th><?= lang('TarifaManipuladoLineas.precioMax') ?></th>
<th><?= lang('TarifaManipuladoLineas.tiradaMax') ?></th>
<th><?= lang('TarifaManipuladoLineas.precioMin') ?></th>
<th><?= lang('TarifaManipuladoLineas.margen') ?></th>
<th style="min-width:100px"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div> <!-- //.accordion -->
<div class="accordion mt-3" id="accordionTarifaMaquinas" style="visibility:visible">
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingTwo">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTipTarifaMaquina" aria-expanded="false" aria-controls="accordionTipTarifaMaquina">
<h3>Tarifa máquinas</h3>
</button>
</h2>
<div id="accordionTipTarifaMaquina" class="accordion-collapse collapse show" data-bs-parent="#accordionTarifaMaquinas">
<div class="accordion-body">
<?= view("themes/vuexy/components/forms/tarifa_maquinas",["id" => "tarifa_maquina_component","tarifaId" => $tarifaManipuladoEntity->id ]) ?>
</div>
</h2>
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionManipuladoLineas">
<div class="accordion-body">
<table id="tableOfTarifamanipuladolineas" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('TarifaManipuladoLineas.tiradaMin') ?></th>
<th><?= lang('TarifaManipuladoLineas.precioMax') ?></th>
<th><?= lang('TarifaManipuladoLineas.tiradaMax') ?></th>
<th><?= lang('TarifaManipuladoLineas.precioMin') ?></th>
<th><?= lang('TarifaManipuladoLineas.margen') ?></th>
<th style="min-width:100px"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div> <!-- //.accordion -->
</div><!--//.row -->
<?= $this->endSection() ?>
<?= $this->section("additionalExternalJs") ?>
<script type="module" src="<?= site_url('assets/js/safekat/pages/tarifas/maquinas/manipulado/index.js') ?>"></script>
<?= $this->endSection() ?>
<?php if ($formAction != site_url('tarifas/tarifasmanipulado/add')): ?>
<div class="accordion mt-3" id="accordionTarifaMaquinas" style="visibility:visible">
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingTwo">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTipTarifaMaquina" aria-expanded="false" aria-controls="accordionTipTarifaMaquina">
<h3>Tarifa máquinas</h3>
</button>
</h2>
<div id="accordionTipTarifaMaquina" class="accordion-collapse collapse show" data-bs-parent="#accordionTarifaMaquinas">
<div class="accordion-body">
<?= view("themes/vuexy/components/forms/tarifa_maquinas", ["id" => "tarifa_maquina_component", "tarifaId" => $tarifaManipuladoEntity?->id]) ?>
</div>
</div>
</div>
</div> <!-- //.accordion -->
<?php endif; ?>
</div><!--//.row -->
<?= $this->endSection() ?>
<?= $this->section("additionalExternalJs") ?>
<script type="module" src="<?= site_url('assets/js/safekat/pages/tarifas/maquinas/manipulado/index.js') ?>"></script>
<?= $this->endSection() ?>
<?= $this->section("additionalInlineJs") ?>
<?= $this->section("additionalInlineJs") ?>
const lastColNr = $('#tableOfTarifamanipuladolineas').find("tr:first th").length - 1;
const url = window.location.href;
const url_parts = url.split('/');
let id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
const lastColNr = $('#tableOfTarifamanipuladolineas').find("tr:first th").length - 1;
const url = window.location.href;
const url_parts = url.split('/');
let id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
id = url_parts[url_parts.length-1];
}
}
const actionBtns = function(data) {
const actionBtns = function(data) {
return `
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
<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>
<span class="cancel"></span>
`;
};
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
<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>
<span class="cancel"></span>
`;
};
editor = new $.fn.dataTable.Editor( {
editor = new $.fn.dataTable.Editor( {
ajax: {
url: "<?= route_to('editorOfTarifaManipuladoLineas') ?>",
headers: {
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
},
url: "<?= route_to('editorOfTarifaManipuladoLineas') ?>",
headers: {
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
},
table : "#tableOfTarifamanipuladolineas",
idSrc: 'id',
},
table : "#tableOfTarifamanipuladolineas",
idSrc: 'id',
fields: [ {
name: "tirada_min"
}, {
name: "precio_max"
}, {
name: "tirada_max"
}, {
name: "precio_min"
}, {
name: "margen"
}, {
"name": "tarifa_manipulado_id",
"type": "hidden"
},{
"name": "deleted_at",
"type": "hidden"
},{
"name": "is_deleted",
"type": "hidden"
},
name: "tirada_min"
}, {
name: "precio_max"
}, {
name: "tirada_max"
}, {
name: "precio_min"
}, {
name: "margen"
}, {
"name": "tarifa_manipulado_id",
"type": "hidden"
},{
"name": "deleted_at",
"type": "hidden"
},{
"name": "is_deleted",
"type": "hidden"
},
]
} );
} );
editor.on( 'preSubmit', function ( e, d, type ) {
editor.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['tarifa_manipulado_id'] = id;
d.data[0]['tarifa_manipulado_id'] = id;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['tarifa_manipulado_id'] = id;
}
for (v in d.data){
d.data[v]['tarifa_manipulado_id'] = id;
}
});
editor.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
});
}
});
editor.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
});
editor.on( 'submitSuccess', function ( e, json, data, action ) {
editor.on( 'submitSuccess', function ( e, json, data, action ) {
theTable.clearPipeline();
theTable.draw();
});
});
var theTable = $('#tableOfTarifamanipuladolineas').DataTable( {
serverSide: true,
var theTable = $('#tableOfTarifamanipuladolineas').DataTable( {
serverSide: true,
processing: true,
autoWidth: true,
responsive: true,
@ -167,149 +170,148 @@
order: [[ 0, "asc" ], [ 1, "asc" ]],
pageLength: 10,
lengthChange: true,
searching: false,
paging: true,
searching: false,
paging: true,
info: false,
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfTarifaManipuladoLineas') ?>',
data: {
id_tarifamanipulado: id,
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columns: [
{ 'data': 'tirada_min' },
{ 'data': 'precio_max' },
{ 'data': 'tirada_max' },
{ 'data': 'precio_min' },
{ 'data': 'margen' },
{
data: actionBtns,
className: 'row-edit dt-center'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr]
},
{"orderData": [ 0, 1 ], "targets": 0 },
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfTarifaManipuladoLineas') ?>',
data: {
id_tarifamanipulado: id,
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columns: [
{ 'data': 'tirada_min' },
{ 'data': 'precio_max' },
{ 'data': 'tirada_max' },
{ 'data': 'precio_min' },
{ 'data': 'margen' },
{
data: actionBtns,
className: 'row-edit dt-center'
}
],
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr]
},
{"orderData": [ 0, 1 ], "targets": 0 },
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
buttons: [
{
extend: 'collection',
text: 'Exportar',
buttons:[
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
]
},
{
className: 'btn btn-primary float-end me-sm-3 me-1',
extend: "createInline",
editor: editor,
formOptions: {
submitTrigger: -1,
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
}
} ]
} );
// Activate an inline edit on click of a table cell
$('#tableOfTarifamanipuladolineas').on( 'click', 'tbody span.edit', function (e) {
editor.inline(
theTable.cells(this.parentNode.parentNode, '*').nodes(),
{
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
cancelTrigger: 'span.cancel',
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
submitTrigger: 'span.edit',
submit: 'allIfChanged'
}
);
} );
// Delete row
$('#tableOfTarifamanipuladolineas').on( 'click', 'tbody span.remove', function (e) {
Swal.fire({
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Basic.global.sweet.line'))]) ?>',
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
cancelButtonColor: '#d33'
})
.then((result) => {
const dataId = $(this).data('id');
const row = $(this).closest('tr');
if (result.value) {
editor
.create( false )
.edit( this.parentNode, false)
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
.set( 'is_deleted', 1 )
.submit();
}
});
});
],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
buttons: [
{
extend: 'collection',
text: 'Exportar',
buttons:[
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
]
},
{
className: 'btn btn-primary float-end me-sm-3 me-1',
extend: "createInline",
editor: editor,
formOptions: {
submitTrigger: -1,
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
}
} ]
} );
// Delete row
$(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: `/tarifas/tarifamanipuladolineas/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)
})
}
});
<?= $this->endSection() ?>
<?=$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/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
<?=$this->endSection() ?>
// Activate an inline edit on click of a table cell
$('#tableOfTarifamanipuladolineas').on( 'click', 'tbody span.edit', function (e) {
editor.inline(
theTable.cells(this.parentNode.parentNode, '*').nodes(),
{
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
cancelTrigger: 'span.cancel',
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
submitTrigger: 'span.edit',
submit: 'allIfChanged'
}
);
} );
<?= $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>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<?=$this->endSection() ?>
// Delete row
$('#tableOfTarifamanipuladolineas').on( 'click', 'tbody span.remove', function (e) {
Swal.fire({
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Basic.global.sweet.line'))]) ?>',
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
cancelButtonColor: '#d33'
})
.then((result) => {
const dataId = $(this).data('id');
const row = $(this).closest('tr');
if (result.value) {
editor
.create( false )
.edit( this.parentNode, false)
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
.set( 'is_deleted', 1 )
.submit();
}
});
});
// Delete row
$(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: `/tarifas/tarifamanipuladolineas/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)
})
}
});
<?= $this->endSection() ?>
<?= $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/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
<?= $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>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -1,4 +1,5 @@
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/datatables") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
@ -26,21 +27,6 @@
</div><!-- //.card -->
</div><!--//.col -->
</div><!--//.row -->
<div class="accordion mt-3" id="accordionTarifaMaquinas" style="visibility:visible">
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingTwo">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTipTarifaMaquina" aria-expanded="false" aria-controls="accordionTipTarifaMaquina">
<h3>Tarifa máquinas</h3>
</button>
</h2>
<div id="accordionTipTarifaMaquina" class="accordion-collapse collapse show" data-bs-parent="#accordionTarifaMaquinas">
<div class="accordion-body">
<?= view("themes/vuexy/components/forms/tarifa_maquinas", ["id" => "tarifa_maquina_component", "tarifaId" => $tarifapreimpresionEntity->id]) ?>
</div>
</div>
</div>
</div> <!-- //.accordion -->
<?= $this->endSection() ?>
<?= $this->section("additionalExternalJs") ?>
<script type="module" src="<?= site_url('assets/js/safekat/pages/tarifas/maquinas/preimpresion/index.js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -63,6 +63,13 @@ if (
</a>
</li>
<?php } ?>
<?php if (auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
<li class="menu-item">
<a href="<?= route_to("maquinaTareaList") ?>" class="menu-link">
<?= lang("App.menu_maquina_tareas") ?>
</a>
</li>
<?php } ?>
<?php if (auth()->user()->can('usuarios.menu')) { ?>
<li class="menu-item">
<a href="<?= site_url("configuracion/users") ?>" class="menu-link">
@ -98,13 +105,7 @@ if (
</a>
</li>
<?php } ?>
<?php if (auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
<li class="menu-item">
<a href="<?= route_to("servicioClienteList") ?>" class="menu-link">
<?= lang("App.menu_servicios_cliente") ?>
</a>
</li>
<?php } ?>
<?php if (auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
<li class="menu-item">
<a href="<?= route_to('erroresPresupuestoIndex') ?>" class="menu-link">

View File

@ -18,3 +18,14 @@ export const alertConfirmationDelete = (title,type="primary") => {
buttonsStyling: false
})
}
export const alertSuccessMessage = (title,type="primary") => {
return Swal.fire({
showCancelButton: false,
showConfirmButton : false,
title: title,
text: title,
icon: "success",
timer : 2000
})
}

View File

@ -0,0 +1,72 @@
import Ajax from "../ajax.js";
import { alertConfirmationDelete, alertSuccessMessage } from "../alerts/sweetAlert.js";
class MaquinaTareaDatatable {
constructor(domItem) {
this.datatableItem = domItem
this.datatableColumns = [
{ data: 'name', searchable: true, sortable: true },
{ data: 'description', searchable: true, sortable: true },
{ data: 'created_at', searchable: true, sortable: true },
{
data: 'action', searchable: false, sortable: false,
render: (d, t) => {
return `<div class="btn-group btn-group-sm">
<a href="/configuracion/maquina-tareas/edit/${d}" class="maquina-tarea-edit"><i class="ti ti-eye ti-sm mx-2"></i></a>
<a type="button" data-id="${d}" class="maquina-tarea-delete"><i class="ti ti-trash ti-sm mx-2"></i></a>
</div>`
}
}
]
}
init() {
this.datatableItem.on('click','.maquina-tarea-delete',this.onDelete.bind(this))
this.datatable = this.datatableItem.DataTable({
processing: true,
layout: {
topStart: 'pageLength',
topEnd: 'search',
bottomStart: 'info',
bottomEnd: 'paging'
},
serverSide: true,
pageLength: 25,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/configuracion/maquina-tareas/datatable'
});
}
onDelete(event){
const modelId = $(event.currentTarget).data("id");
alertConfirmationDelete("¿Estás seguro de realizar esta acción?").then(result => {
if(result.isConfirmed){
this.handleDeleteMaquinaTarea(modelId)
}
}
)
}
handleDeleteMaquinaTarea(modelId){
const ajax = new Ajax('/configuracion/maquina-tareas/' + modelId,
null,
null,
(response) => {
alertSuccessMessage(response.message)
this.datatable.ajax.reload()
},
null
)
ajax.delete()
}
}
export default MaquinaTareaDatatable;

View File

@ -1,44 +0,0 @@
class ServicioClienteDatatable {
constructor(domItem) {
this.datatableItem = domItem
this.datatableColumns = [
{ data: 'nombre', searchable: true, sortable: true },
{ data: 'code', searchable: true, sortable: true },
{ data: 'created_at', searchable: true, sortable: true },
{
data: 'action', searchable: false, sortable: false,
render: (d, t) => {
return `<div class="btn-group btn-group-sm">
<a href="/configuracion/servicios/edit/${d}" class="servicio-cliente-edit"><i class="ti ti-eye ti-sm mx-2"></i></a>
</div>`
}
}
]
}
init() {
this.datatable = this.datatableItem.DataTable({
processing: true,
layout: {
topStart: 'pageLength',
topEnd: 'search',
bottomStart: 'info',
bottomEnd: 'paging'
},
serverSide: true,
pageLength: 25,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/configuracion/servicios/datatable'
});
}
}
export default ServicioClienteDatatable;

Some files were not shown because too many files have changed in this diff Show More