trabajando en servicios encuadernacion (init)

This commit is contained in:
2023-11-21 20:36:12 +01:00
parent 58af5bf90f
commit 1d0681847a
17 changed files with 174 additions and 18 deletions

View File

@ -140,6 +140,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
$this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null); $this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
$this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo')); $this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo'));
$this->viewData['paisList'] = $this->getPaisListItems(); $this->viewData['paisList'] = $this->getPaisListItems();
$this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null);
$this->viewData['tipo_impresion_id'] = 4; // Cosido tapa blanda JJO $this->viewData['tipo_impresion_id'] = 4; // Cosido tapa blanda JJO

View File

@ -257,6 +257,7 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
Field::inst('updated_at'), Field::inst('updated_at'),
Field::inst('is_deleted'), Field::inst('is_deleted'),
Field::inst('deleted_at'), Field::inst('deleted_at'),
Field::inst('dimensiones_id'),
) )
->validator(function ($editor, $action, $data) { ->validator(function ($editor, $action, $data) {
@ -266,6 +267,7 @@ class Tarifaencuadernacionlineas extends \App\Controllers\GoBaseResourceControll
if ($data['data'][$pkey]['is_deleted'] != 1) { if ($data['data'][$pkey]['is_deleted'] != 1) {
$process_data['paginas_libro_min'] = $data['data'][$pkey]['paginas_libro_min']; $process_data['paginas_libro_min'] = $data['data'][$pkey]['paginas_libro_min'];
$process_data['paginas_libro_max'] = $data['data'][$pkey]['paginas_libro_max']; $process_data['paginas_libro_max'] = $data['data'][$pkey]['paginas_libro_max'];
$process_data['dimensiones_id'] = $data['data'][$pkey]['dimensiones_id'];
$response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tirada_encuadernacion_id']); $response = $this->model->checkIntervals($process_data, $pkey, $data['data'][$pkey]['tirada_encuadernacion_id']);
// No se pueden duplicar valores al crear o al editar // No se pueden duplicar valores al crear o al editar
if (!empty($response)) { if (!empty($response)) {

View File

@ -10,6 +10,7 @@ use App\Entities\Tarifas\TarifaEncuadernacionEntity;
use App\Models\Tarifas\TarifaEncuadernacionModel; use App\Models\Tarifas\TarifaEncuadernacionModel;
use App\Models\Compras\ProveedorModel; use App\Models\Compras\ProveedorModel;
use App\Models\Compras\ProveedorTipoModel; use App\Models\Compras\ProveedorTipoModel;
use App\Models\Tarifas\TarifaEncuadernacionDimensionesModel;
class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController
@ -221,6 +222,7 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController
//JJO //JJO
$this->viewData['proveedores'] = $this->getProveedores(); $this->viewData['proveedores'] = $this->getProveedores();
$this->viewData['dimensiones'] = $this->getDimensiones();
return $this->displayForm(__METHOD__, $id); return $this->displayForm(__METHOD__, $id);
} // end function edit(...) } // end function edit(...)
@ -311,4 +313,14 @@ class Tarifasencuadernacion extends \App\Controllers\GoBaseResourceController
$tipoId = $provTipoModel->getTipoId("Encuadernacion"); $tipoId = $provTipoModel->getTipoId("Encuadernacion");
return $provModel->getProvList($tipoId); return $provModel->getProvList($tipoId);
} }
private function getDimensiones(){
$dimensionModel = new TarifaEncuadernacionDimensionesModel();
$dimensiones = $dimensionModel->getDimensiones();
foreach($dimensiones as $dim){
$dim->label= lang("TarifaEncuadernacionLineas." . $dim->label);
}
return $dimensiones;
}
} }

View File

@ -17,7 +17,20 @@ class Test extends BaseController
public function index() public function index()
{ {
var_dump($this->get_tarifas_encuadernacion(4, true)); echo '<pre>';
$this->get_dimensiones_enc();
echo '</pre>';
}
public function get_dimensiones_enc(){
$dimensionModel = model('App\Models\Tarifas\TarifaEncuadernacionDimensionesModel');
$dimensiones = $dimensionModel->getDimensiones();
var_dump($dimensiones);
foreach($dimensiones as $dim){
$dim->label= lang("TarifaEncuadernacionLineas." . $dim->label);
}
var_dump($dimensiones);
} }

View File

@ -0,0 +1,24 @@
<?php
namespace App\Entities\Tarifas;
use CodeIgniter\Entity;
class TarifaEncuadernacionDimensionesEntity extends \CodeIgniter\Entity\Entity
{
protected $attributes = [
"id" => null,
"keyword" => "",
"descripcion" => "",
"ancho_min" => 0,
"ancho_max" => 0,
"alto_min" => 0,
"alto_max" => 0,
];
protected $casts = [
"id" => "int",
"ancho_min" => "float",
"ancho_max" => "float",
"alto_min" => "float",
"alto_max" => "float",
];
}

View File

@ -142,6 +142,8 @@ return [
'addLineaPresupuesto' => 'Add line...', 'addLineaPresupuesto' => 'Add line...',
'serviciosEncDefault' => 'Default binding services',
'validation' => [ 'validation' => [
'decimal' => 'The {field} field must contain a decimal number.', 'decimal' => 'The {field} field must contain a decimal number.',
'integer' => 'The {field} field must contain an integer.', 'integer' => 'The {field} field must contain an integer.',

View File

@ -11,6 +11,11 @@ return [
'precioUnidad' => 'Price Unit', 'precioUnidad' => 'Price Unit',
'paginasMax' => 'Max Pages', 'paginasMax' => 'Max Pages',
'paginasMin' => 'Min Pages', 'paginasMin' => 'Min Pages',
'dimensiones' => 'Dimensions',
'menor_a5' =>'Less than A5',
'entre_a5_a4' =>'Between A5 and A4',
'mayor_a4' =>'Greater than A4',
'por_defecto' =>'Generic',
'moduleExplanation' => 'The number of pages indicated in this section refers per copy, not to the total of the order.', 'moduleExplanation' => 'The number of pages indicated in this section refers per copy, not to the total of the order.',
'margen' => 'Margin', 'margen' => 'Margin',
'validation' => [ 'validation' => [

View File

@ -167,6 +167,7 @@ return [
// Servicios // Servicios
'precioUnidad' => 'Precio unitario', 'precioUnidad' => 'Precio unitario',
'precioTotal' => 'Precio total', 'precioTotal' => 'Precio total',
'serviciosEncDefault' => 'Servicios Enc. por defecto',
'validation' => [ 'validation' => [

View File

@ -13,6 +13,11 @@ return [
'precioUnidad' => 'Precio Unidad', 'precioUnidad' => 'Precio Unidad',
'paginasMax' => 'Páginas Max', 'paginasMax' => 'Páginas Max',
'paginasMin' => 'Páginas Min', 'paginasMin' => 'Páginas Min',
'dimensiones' => 'Dimensiones',
'menor_a5' =>'Menor A5',
'entre_a5_a4' =>'Entre A5 y A4',
'mayor_a4' =>'Mayor A4',
'por_defecto' =>'Genérico',
'moduleExplanation' => 'El número de páginas reflejado en este apartado se refiere por ejemplar, no al total del pedido', 'moduleExplanation' => 'El número de páginas reflejado en este apartado se refiere por ejemplar, no al total del pedido',
'margen' => 'Margen', 'margen' => 'Margen',
'validation' => [ 'validation' => [

View File

@ -46,10 +46,23 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
public function initPresupuesto($tipoPresupuesto, $solapas){ public function initPresupuesto($id_presupuesto,$tipoPresupuesto, $solapas){
$model = model('App\Models\Presupuestos\TipoPresupuestoTarifaEncuadernacionModel'); $model = model('App\Models\Presupuestos\TipoPresupuestoTarifaEncuadernacionModel');
$tarifas_ids = $model->get_tarifas($tipo_presupuesto,$solapas); $tarifas_ids = $model->get_tarifas($tipo_presupuesto,$solapas);
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
foreach($tarifas_ids as $tarifa){
/* $data = [
'id' => new RawSql('DEFAULT'),
'title' => 'My title',
'name' => 'My Name',
'date' => '2022-01-01',
'last_update' => new RawSql('CURRENT_TIMESTAMP()'),
];
$modelTarifa->getMejorPrecio($tirada, $paginas)*/
}
} }
public function delete($presupuesto_id){ public function delete($presupuesto_id){

View File

@ -0,0 +1,46 @@
<?php
namespace App\Models\Tarifas;
class TarifaEncuadernacionDimensionesModel extends \App\Models\GoBaseModel
{
protected $table = "tarifa_encuadernacion_dimensiones";
/**
* Whether primary key uses auto increment.
*
* @var bool
*/
protected $useAutoIncrement = true;
protected $allowedFields = [
];
protected $returnType = "App\Entities\Tarifas\TarifaEncuadernacionDimensionesEntity";
public static $labelField = "descripcion";
protected $validationRules = [
];
protected $validationMessages = [
];
/**
* Get resource data.
*
* @param string $search
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getDimensiones(){
$builder = $this->db
->table($this->table . " t1")
->select("t1.id AS value, t1.keyword AS label")
->orderBy('t1.id', 'asc');
return $builder->get()->getResultObject();
}
}

View File

@ -13,10 +13,11 @@ class TarifaEncuadernacionLineaModel extends \App\Models\GoBaseModel
protected $useAutoIncrement = true; protected $useAutoIncrement = true;
const SORTABLE = [ const SORTABLE = [
0 => "t1.paginas_libro_min", 0 => "t1.dimensiones_id",
1 => "t1.paginas_libro_max", 1 => "t1.paginas_libro_min",
2 => "t1.precio_min", 2 => "t1.paginas_libro_max",
3 => "t1.precio_max", 3 => "t1.precio_min",
4 => "t1.precio_max",
]; ];
protected $allowedFields = [ protected $allowedFields = [
@ -117,13 +118,16 @@ class TarifaEncuadernacionLineaModel extends \App\Models\GoBaseModel
$builder = $this->db $builder = $this->db
->table($this->table . " t1") ->table($this->table . " t1")
->select( ->select(
"t1.id AS id, t1.tirada_encuadernacion_id AS tirada_encuadernacion_id, t1.paginas_libro_min AS paginas_libro_min, t1.paginas_libro_max AS paginas_libro_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t1.margen AS margen, t2.id AS tarifa_encuadernacion" "t1.id AS id, t1.tirada_encuadernacion_id AS tirada_encuadernacion_id, t1.paginas_libro_min AS paginas_libro_min, t1.paginas_libro_max AS paginas_libro_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.tirada_min AS tirada_min,
t1.tirada_max AS tirada_max, t1.margen AS margen, t2.id AS tarifa_encuadernacion, t3.id AS dimensiones_id, t3.ancho_min, t3.ancho_max, , t3.alto_min, t3.alto_max"
); );
//JJO //JJO
$builder->where('tirada_encuadernacion_id', $tirada_encuadernacion_id); $builder->where('tirada_encuadernacion_id', $tirada_encuadernacion_id);
$builder->where("t1.is_deleted", 0); $builder->where("t1.is_deleted", 0);
$builder->join("tarifa_encuadernacion_tiradas t2", "t1.tirada_encuadernacion_id = t2.id", "left"); $builder->join("tarifa_encuadernacion_tiradas t2", "t1.tirada_encuadernacion_id = t2.id", "left");
$builder->join("tarifa_encuadernacion_dimensiones t3", "t1.dimensiones_id = t3.id", "left");
return empty($search) return empty($search)
@ -151,7 +155,7 @@ class TarifaEncuadernacionLineaModel extends \App\Models\GoBaseModel
$rows = $this->db $rows = $this->db
->table($this->table) ->table($this->table)
->select("id, paginas_libro_min, paginas_libro_max") ->select("id, paginas_libro_min, paginas_libro_max, dimensiones_id")
->where("is_deleted", 0) ->where("is_deleted", 0)
->where("tirada_encuadernacion_id", $tirada_encuadernacion_id) ->where("tirada_encuadernacion_id", $tirada_encuadernacion_id)
->get()->getResultObject(); ->get()->getResultObject();
@ -163,9 +167,11 @@ class TarifaEncuadernacionLineaModel extends \App\Models\GoBaseModel
continue; continue;
} }
} }
if(check_overlap(floatval($data["paginas_libro_min"]), floatval($data["paginas_libro_max"]), if($data['dimensiones_id'] == $row->dimensiones_id){
$row->paginas_libro_min, $row->paginas_libro_max)){ if(check_overlap(floatval($data["paginas_libro_min"]), floatval($data["paginas_libro_max"]),
return lang('TarifaEncuadernacionLineas.validation.error_paginas_overlap'); $row->paginas_libro_min, $row->paginas_libro_max)){
return lang('TarifaEncuadernacionLineas.validation.error_paginas_overlap');
}
} }
} }

View File

@ -95,7 +95,7 @@
<label for="merma" class="form-label"> <label for="merma" class="form-label">
<?= lang('Presupuestos.merma') ?>* <?= lang('Presupuestos.merma') ?>*
</label> </label>
<input type="number" id="merma" name="merma" maxLength="8" tabindex="4" step="1" class="form-control" value="<?= old('merma', $presupuestoEntity->merma) ?>"> <input type="number" id="merma" name="merma" maxLength="8" tabindex="4" step="1" placeholder="10" class="form-control" value="<?= old('merma', $presupuestoEntity->merma) ?>">
</div><!--//.mb-3 --> </div><!--//.mb-3 -->
</div><!--//.col --> </div><!--//.col -->
@ -136,6 +136,7 @@
<!-----------------------------------------------------------------------------> <!----------------------------------------------------------------------------->
<?php if(str_contains($formAction,'edit')): ?>
<div class="divider divider-dark text-start mb-1"> <div class="divider divider-dark text-start mb-1">
<div class="divider-text"> <div class="divider-text">
@ -259,6 +260,7 @@
</div><!--//.col --> </div><!--//.col -->
</div> <!--//.row --> </div> <!--//.row -->
<?php endif; ?>
</div> <!-- //.accordion-body --> </div> <!-- //.accordion-body -->
</div> <!-- //.accordion-collapse --> </div> <!-- //.accordion-collapse -->
@ -269,6 +271,10 @@
<!-- Código JS comportamiento general pag. --> <!-- Código JS comportamiento general pag. -->
<!-------------------------------------------> <!------------------------------------------->
<?= $this->section("additionalInlineJs") ?> <?= $this->section("additionalInlineJs") ?>
$('#papelFormatoId').select2({
allowClear: false,
});
$('#papelFormatoPersonalizado').on("click",function(){ $('#papelFormatoPersonalizado').on("click",function(){
var checkbox = document.getElementById('papelFormatoPersonalizado'); var checkbox = document.getElementById('papelFormatoPersonalizado');
if(checkbox.checked == true){ if(checkbox.checked == true){

View File

@ -491,10 +491,6 @@
minimumResultsForSearch: Infinity, minimumResultsForSearch: Infinity,
}); });
$('#papelFormatoId').select2({
allowClear: false,
});
updatePapelesComparador(); updatePapelesComparador();
const paginasColor = document.getElementById('compCalPaginasColor'); const paginasColor = document.getElementById('compCalPaginasColor');
if (paginasColor.value.length > 0) { if (paginasColor.value.length > 0) {

View File

@ -94,6 +94,11 @@
</div> </div>
<div class="tab-pane fade" id="servicios-encuadernacion" role="tabpanel"> <div class="tab-pane fade" id="servicios-encuadernacion" role="tabpanel">
<div class="row">
<div class="col-md-12 col-lg-4 px-4">
<?= anchor(route_to(""), lang("Presupuestos.serviciosEncDefault"), ["class" => "btn btn-dark float-start me-sm-3 me-1",]) ?>
</div>
</div>
<table id="tableOfServiciosEncuadernacion" class="table table-striped table-hover" style="width: 100%;"> <table id="tableOfServiciosEncuadernacion" class="table table-striped table-hover" style="width: 100%;">
<thead> <thead>
<tr> <tr>

View File

@ -18,8 +18,8 @@
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?> <?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<input type="hidden" name="tipo_impresion_id" id="tipo_impresion_id" class="form-control" value="<?= $tipo_impresion_id ?>"></input> <input type="hidden" name="tipo_impresion_id" id="tipo_impresion_id" class="form-control" value="<?= $tipo_impresion_id ?>"></input>
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems") ?> <?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems") ?>
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems") ?>
<?php if(str_contains($formAction,'edit')): ?> <?php if(str_contains($formAction,'edit')): ?>
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems") ?>
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems") ?> <?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems") ?>
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems") ?> <?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems") ?>
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems") ?> <?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_previewItems") ?>

View File

@ -75,6 +75,8 @@
<table id="tableOfTarifaencuadernacionlineas" class="table table-striped table-hover" style="width: 100%;"> <table id="tableOfTarifaencuadernacionlineas" class="table table-striped table-hover" style="width: 100%;">
<thead> <thead>
<tr> <tr>
<th>ID</th>
<th><?= lang('TarifaEncuadernacionLineas.dimensiones') ?></th>
<th><?= lang('TarifaEncuadernacionLineas.paginasMin') ?></th> <th><?= lang('TarifaEncuadernacionLineas.paginasMin') ?></th>
<th><?= lang('TarifaEncuadernacionLineas.precioMax') ?></th> <th><?= lang('TarifaEncuadernacionLineas.precioMax') ?></th>
<th><?= lang('TarifaEncuadernacionLineas.paginasMax') ?></th> <th><?= lang('TarifaEncuadernacionLineas.paginasMax') ?></th>
@ -171,7 +173,13 @@
}, },
table : "#tableOfTarifaencuadernacionlineas", table : "#tableOfTarifaencuadernacionlineas",
idSrc: 'id', idSrc: 'id',
fields: [ { fields: [
{name: "id"},
{
name: "dimensiones_id",
"type": "select"
},
{
name: "paginas_libro_min" name: "paginas_libro_min"
}, { }, {
name: "precio_max" name: "precio_max"
@ -194,6 +202,9 @@
] ]
} ); } );
// Generación de la lista de proveedores (id, nombre) para encuadernación
const dimensionesList = <?php echo json_encode($dimensiones); ?>;
editor.field( 'dimensiones_id' ).update( dimensionesList );
editor.on( 'preSubmit', function ( e, d, type ) { editor.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){ if ( type === 'create'){
@ -243,6 +254,13 @@
async: true, async: true,
}), }),
columns: [ columns: [
{ 'data': 'id' },
{ 'data': 'dimensiones_id',
render: function(data, type, row, meta) {
var value = dimensionesList.find(element => element.value === data);
return value['label'];
},
},
{ 'data': 'paginas_libro_min' }, { 'data': 'paginas_libro_min' },
{ 'data': 'precio_max' }, { 'data': 'precio_max' },
{ 'data': 'paginas_libro_max' }, { 'data': 'paginas_libro_max' },
@ -401,6 +419,7 @@
// Tabla de tiradas // Tabla de tiradas
var theTable2 = $('#tableOfTarifaencuadernaciontiradas').DataTable( { var theTable2 = $('#tableOfTarifaencuadernaciontiradas').DataTable( {
draw:1,
serverSide: true, serverSide: true,
processing: true, processing: true,
autoWidth: true, autoWidth: true,