totalizadores de servicios realizado

This commit is contained in:
Jaime Jiménez
2023-12-14 15:34:45 +01:00
parent 3a43f90ef9
commit 7a27bf56a7
11 changed files with 190 additions and 78 deletions

View File

@ -58,6 +58,34 @@ class Presupuestopreimpresiones extends \App\Controllers\GoBaseResourceControlle
return $this->respond($data);
}
public function update($requestedId = null)
{
if ($requestedId == null) :
return;
endif;
$postData = $this->request->getJSON();
$tarifas = array_column($postData->datos, 'tarifa_id');
$result = [];
if(count($tarifas)>0){
foreach ($tarifas as $tarifa){
$values = $this->model->getPrecioTarifa($tarifa);
array_push($result, $values);
}
}
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'lines' => $result,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
public function datatable()
{
if ($this->request->isAJAX()) {

View File

@ -11,6 +11,7 @@ class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity
"tarifa_acabado_id" => null,
"precio_unidad" => null,
"precio_total" => null,
"margen" => null,
"created_at" => null,
"updated_at" => null,
];
@ -19,5 +20,6 @@ class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity
"tarifa_acabado_id" => "int",
"precio_unidad" => "float",
"precio_total" => "float",
"margen" => "float",
];
}

View File

@ -11,6 +11,7 @@ class PresupuestoManipuladosEntity extends \CodeIgniter\Entity\Entity
"tarifa_manipulado_id" => null,
"precio_unidad" => null,
"precio_total" => null,
"margen" => null,
"created_at" => null,
"updated_at" => null,
];
@ -19,5 +20,6 @@ class PresupuestoManipuladosEntity extends \CodeIgniter\Entity\Entity
"tarifa_manipulado_id" => "int",
"precio_unidad" => "float",
"precio_total" => "float",
"margen" => "float",
];
}

View File

@ -9,15 +9,15 @@ class PresupuestoPreimpresionesEntity extends \CodeIgniter\Entity\Entity
"id" => null,
"presupuesto_id" => null,
"tarifa_preimpresion_id" => null,
"precio_unidad" => null,
"precio_total" => null,
"margen" => null,
"created_at" => null,
"updated_at" => null,
];
protected $casts = [
"presupuesto_id" => "int",
"tarifa_preimpresion_id" => "int",
"precio_unidad" => "float",
"precio_total" => "float",
"margen" => "float",
];
}

View File

@ -19,7 +19,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel
2 => "t1.precio_total"
];
protected $allowedFields = ["presupuesto_id", "tarifa_acabado_id", "nombre", "precio_total", "precio_unidad"];
protected $allowedFields = ["presupuesto_id", "tarifa_acabado_id", "nombre", "precio_total", "precio_unidad", "margen"];
protected $returnType = "App\Entities\Presupuestos\PresupuestoAcabadosEntity";
protected $useTimestamps = true;
@ -56,6 +56,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel
'tarifa_nombre'=> $tarifa_value[0]->tarifa_acabado_nombre,
'precio_unidad'=> $result_data[0],
'total'=> $result_data[1],
'margen'=> $result_data[2],
];
return $ret_array;
}
@ -64,6 +65,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel
'tarifa_id'=> $tarifa_acabado_id,
'tarifa_nombre'=> $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre,
'precio_unidad' => 0,
'margen' => 0,
'total'=> 0,
];
return $ret_array;
@ -79,12 +81,13 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel
$precio_unidad = $precio_unidad* (1+ floatval($tarifa->margen)/100.0);
$total = $precio_unidad * $tirada;
$margen = floatval($tarifa->margen);
if (!$is_POD){
$total += floatval($tarifa->tarifa_importe_fijo);
}
return [$precio_unidad, $total];
return [$precio_unidad, $total, $margen];
}
public function deleteAllServicios($presupuesto_id){
@ -123,6 +126,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel
->where('tarifa_acabado_id', $tarifa->tarifa_id)
->set('precio_unidad', $tarifa->precio_unidad)
->set('precio_total', $tarifa->precio_total)
->set('margen', $tarifa->margen)
->update();
@ -134,6 +138,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel
->set('tarifa_acabado_id', $tarifa->tarifa_id)
->set('precio_unidad', $tarifa->precio_unidad)
->set('precio_total', $tarifa->precio_total)
->set('margen', $tarifa->margen)
->insert();
}
}
@ -152,7 +157,7 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel
->table($this->table . " t1")
->select(
"t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.precio_unidad AS precio_unidad,
t1.precio_total AS precio_total, t2.nombre AS nombre"
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre"
);
$builder->where('t1.presupuesto_id', $presupuesto_id);

View File

@ -73,7 +73,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
$result_data[0] = floatval($precio_total / $tirada); // Precio/unidad
$result_data[1] = $precio_total;
$result_data[2] = $precio_total * ($tarifa_value[0]->margen/100.0) ; // margen
$result_data[2] = $tarifa_value[0]->margen ; // margen
array_push($tarifas,
(object)[
@ -206,7 +206,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
$result_data[0] = floatval($precio_total / $tirada); // Precio/unidad
$result_data[1] = $precio_total;
$result_data[2] = $precio_total * ($tarifa_value[0]->margen/100.0) ; // margen
$result_data[2] = $tarifa_value[0]->margen; // margen
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_encuadernacion_id,
@ -242,7 +242,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
$precio_unidad = $precio_unidad* (1+ floatval($tarifa->margen)/100.0);
$total = $precio_unidad * $paginas;
$margen = $total * (floatval($tarifa->margen)/100.0);
$margen = floatval($tarifa->margen);
if (!$is_POD){
$total += floatval($tarifa->tarifa_importe_fijo);

View File

@ -19,7 +19,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel
2 => "t1.precio_total"
];
protected $allowedFields = ["presupuesto_id", "tarifa_manipulado_id", "nombre", "precio_total", "precio_unidad"];
protected $allowedFields = ["presupuesto_id", "tarifa_manipulado_id", "nombre", "precio_total", "precio_unidad", "margen"];
protected $returnType = "App\Entities\Presupuestos\PresupuestoManipuladosEntity";
protected $useTimestamps = true;
@ -57,6 +57,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel
'tarifa_nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre,
'precio_unidad'=> $result_data[0],
'total'=> $result_data[1],
'margen' => $result_data[2],
];
return $ret_array;
}
@ -66,6 +67,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel
'tarifa_nombre'=> $modelTarifa->getNombreTarifaManipulado($tarifa_manipulado_id)[0]->nombre,
'precio_unidad' => 0,
'total'=> 0,
'margen' => 0,
];
return $ret_array;
}
@ -80,12 +82,13 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel
$precio_unidad = $precio_unidad* (1+ floatval($tarifa->margen)/100.0);
$total = $precio_unidad * $tirada;
$margen = floatval($tarifa->margen);
if (!$is_POD){
$total += floatval($tarifa->tarifa_importe_fijo);
}
return [$precio_unidad, $total];
return [$precio_unidad, $total, $margen];
}
public function deleteAllServicios($presupuesto_id){
@ -124,6 +127,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel
->where('tarifa_manipulado_id', $tarifa->tarifa_id)
->set('precio_unidad', $tarifa->precio_unidad)
->set('precio_total', $tarifa->precio_total)
->set('margen', $tarifa->margen)
->update();
@ -135,6 +139,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel
->set('tarifa_manipulado_id', $tarifa->tarifa_id)
->set('precio_unidad', $tarifa->precio_unidad)
->set('precio_total', $tarifa->precio_total)
->set('margen', $tarifa->margen)
->insert();
}
}
@ -160,6 +165,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel
'tarifa_nombre'=> $tarifa_value[0]->tarifa_manipulado_nombre,
'precio_unidad'=> $result_data[0],
'total'=> $result_data[1],
'margen'=> $result_data[2],
]);
}
else{
@ -169,6 +175,7 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel
'tarifa_nombre'=> $tarifa['tarifa_nombre'],
'precio_unidad' => 0,
'total'=> 0,
'margen' => 0,
]);
}
@ -189,7 +196,8 @@ class PresupuestoManipuladosModel extends \App\Models\GoBaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.tarifa_manipulado_id AS tarifa_manipulado_id, t1.precio_unidad AS precio_unidad, t1.precio_total AS precio_total, t2.nombre AS nombre"
"t1.id AS id, t1.tarifa_manipulado_id AS tarifa_manipulado_id, t1.precio_unidad AS precio_unidad,
t1.precio_total AS precio_total, t1.margen AS margen, t2.nombre AS nombre"
);
$builder->where('t1.presupuesto_id', $presupuesto_id);

View File

@ -19,7 +19,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel
2 => "t1.precio_total"
];
protected $allowedFields = ["presupuesto_id", "tarifa_preimpresion_id", "nombre", "precio_total", "precio_unidad"];
protected $allowedFields = ["presupuesto_id", "tarifa_preimpresion_id", "nombre", "precio_total", "precio_unidad", "margen"];
protected $returnType = "App\Entities\Presupuestos\PresupuestoPreimpresionesEntity";
protected $useTimestamps = true;
@ -55,7 +55,8 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_value[0]->tarifa_preimpresion_id,
'tarifa_nombre'=> $tarifa_value[0]->tarifa_preimpresion_nombre,
'precio'=> $result_data,
'precio'=> $result_data[0],
'margen'=> $result_data[1],
];
return $ret_array;
}
@ -64,6 +65,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel
'tarifa_id'=> $tarifa_preimpresion_id,
'tarifa_nombre'=> $modelTarifa->getNombreTarifaPreimpresion($tarifa_preimpresion_id)[0]->nombre,
'precio' => 0,
'margen' => 0,
];
return $ret_array;
}
@ -74,8 +76,9 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel
$precio = floatval($tarifa->precio);
$precio = $precio * (1+ floatval($tarifa->margen)/100.0);
return $precio;
$margen = $tarifa->margen;
return [$precio, $margen];
}
public function deleteAllServicios($presupuesto_id){
@ -114,6 +117,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel
->where('presupuesto_id', $presupuesto_id)
->where('tarifa_preimpresion_id', $tarifa->tarifa_id)
->set('precio', $tarifa->precio)
->set('margen', $tarifa->margen)
->update();
@ -124,6 +128,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel
->set('presupuesto_id', $presupuesto_id)
->set('tarifa_preimpresion_id', $tarifa->tarifa_id)
->set('precio', $tarifa->precio)
->set('margen', $tarifa->margen)
->insert();
}
}
@ -142,7 +147,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.precio AS precio, t2.nombre AS nombre"
"t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.precio AS precio, t1.margen AS margen, t2.nombre AS nombre"
);
$builder->where('t1.presupuesto_id', $presupuesto_id);

View File

@ -80,6 +80,7 @@
<th><?= lang('Tarifaacabado.tarifaacabado') ?></th>
<th><?= lang('Presupuestos.precioUnidad') ?></th>
<th><?= lang('Presupuestos.precioTotal') ?></th>
<th></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
@ -116,6 +117,7 @@
<th><?= lang('Presupuestos.id') ?></th>
<th><?= lang('Tarifapreimpresion.tarifapreimpresion') ?></th>
<th><?= lang('Presupuestos.precio') ?></th>
<th></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
@ -193,6 +195,7 @@
<th><?= lang('Tarifamanipulado.tarifamanipulado') ?></th>
<th><?= lang('Presupuestos.precioUnidad') ?></th>
<th><?= lang('Presupuestos.precioTotal') ?></th>
<th></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
@ -398,6 +401,7 @@
data.lines.forEach((line) => {
$('#precio_unidad_acabado_' + line[0].tarifa_id).text(parseFloat(line[0].precio_unidad).toFixed(2))
$('#precio_total_acabado_' + line[0].tarifa_id).val(parseFloat(line[0].total).toFixed(2))
$('#acabado_margen_' + line[0].tarifa_id).text(parseFloat(line[0].margen).toFixed(2))
});
yeniden(data.<?= csrf_token() ?>);
}).then(
@ -423,6 +427,7 @@
$('#proveedor_enc_' + line[0].tarifa_id).val(line[0].proveedor_id)
$('#precio_unidad_encuadernado_' + line[0].tarifa_id).text(parseFloat(line[0].precio_unidad).toFixed(2))
$('#precio_total_encuadernado_' + line[0].tarifa_id).val(parseFloat(line[0].total).toFixed(2))
$('#enc_margen_' + line[0].tarifa_id).val(parseFloat(line[0].margen).toFixed(2))
$('#proveedor_enc_' + line[0].tarifa_id).on('change', proveedor_enc_event)
});
yeniden(data.<?= csrf_token() ?>);
@ -444,10 +449,30 @@
data.lines.forEach((line) => {
$('#precio_unidad_manipulado_' + line[0].tarifa_id).text(parseFloat(line[0].precio_unidad).toFixed(2))
$('#precio_total_manipulado_' + line[0].tarifa_id).val(parseFloat(line[0].total).toFixed(2))
$('#manipulado_margen_' + line[0].tarifa_id).val(parseFloat(line[0].margen).toFixed(2))
});
yeniden(data.<?= csrf_token() ?>);
})
)
}).then(
fetch(domain + "/presupuestos/presupuestopreimpresiones/update/" + id , {
method: "POST",
body: JSON.stringify({
datos: datosPreimpresion,
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
.then(response => response.json())
.then(data => {
data.lines.forEach((line) => {
$('#precio_preimpresion_' + line[0].tarifa_id).val(parseFloat(line[0].total).toFixed(2))
$('#preimpresion_margen_' + line[0].tarifa_id).val(parseFloat(line[0].margen).toFixed(2))
});
yeniden(data.<?= csrf_token() ?>);
})
)
)
)
}
@ -473,7 +498,9 @@
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
"drawCallback": function(settings ) {
updateTotales()
}
});
function init_servicio_acabado(){
@ -491,7 +518,8 @@
element.tarifa_acabado_id,
element.nombre,
'<span id="precio_unidad_acabado_' + element.tarifa_acabado_id + '">' + parseFloat(element.precio_unidad).toFixed(2) + '</span>',
'<input id="precio_total_acabado_' + element.tarifa_acabado_id +'" value="' + parseFloat(element.precio_total).toFixed(2) + '"></input>',
'<input class="update-totales" id="precio_total_acabado_' + element.tarifa_acabado_id +'" value="' + parseFloat(element.precio_total).toFixed(2) + '"></input>',
'<span style="display: none;" class="update-totales" id="acabado_margen_' + element.tarifa_acabado_id + '">' + parseFloat(element.margen).toFixed(2) + '</span>',
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + element.tarifa_acabado_id +'"></i></a>'
]).draw(false)
@ -548,7 +576,8 @@
row.tarifa_id,
row.tarifa_nombre,
'<span id="precio_unidad_acabado_' + row.tarifa_id + '">' + parseFloat(row.precio_unidad).toFixed(2) + '</span>',
'<input id="precio_total_acabado_' + row.tarifa_id +'" value="' + parseFloat(row.total).toFixed(2) + '"></input>',
'<input class="update-totales" id="precio_total_acabado_' + row.tarifa_id +'" value="' + parseFloat(row.total).toFixed(2) + '"></input>',
'<span style="display: none;" class="update-totales" id="acabado_margen_' + row.tarifa_id + '">' + parseFloat(row.margen).toFixed(2) + '</span>',
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + row.tarifa_id +'"></i></a>'
]).draw(false)
});
@ -595,6 +624,9 @@
case 3:
values['precio_total'] = $(this).children(":first").val()
break
case 4:
values['margen'] = $(this).text()
break
}
})
if(Object.keys(values).length>0)
@ -624,12 +656,10 @@
select: false,
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
columnDefs: [{
target: 5,
visible: false
}]
},
"drawCallback": function(settings ) {
updateTotales()
}
});
@ -657,7 +687,7 @@
'</select>',
'<span id="precio_unidad_encuadernado_' + element.tarifa_encuadernado_id + '">' + parseFloat(element.precio_unidad).toFixed(2) + '</span>',
'<input class="update-totales" id="precio_total_encuadernado_' + element.tarifa_encuadernado_id +'" value="' + parseFloat(element.precio_total).toFixed(2) + '"></input>',
'<span class="update-totales" id="margen_' + element.tarifa_encuadernado_id + '">' + parseFloat(element.margen).toFixed(2) + '</span>',
'<span style="display: none;" class="update-totales" id="enc_margen_' + element.tarifa_encuadernado_id + '">' + parseFloat(element.margen).toFixed(2) + '</span>',
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + element.tarifa_encuadernado_id +'"></i></a>'
]).draw(false)
@ -731,7 +761,7 @@
$('#precio_unidad_encuadernado_' + datos.tarifa_encuadernacion_id).text(parseFloat(data.values[0].precio_unidad).toFixed(2))
$('#precio_total_encuadernado_' + datos.tarifa_encuadernacion_id).val(parseFloat(data.values[0].total).toFixed(2))
$('#margen_' + datos.tarifa_encuadernacion_id).val(parseFloat(data.values[0].margen).toFixed(2))
$('#enc_margen_' + datos.tarifa_encuadernacion_id).val(parseFloat(data.values[0].margen).toFixed(2))
yeniden(data.<?= csrf_token() ?>);
return true;
},
@ -796,6 +826,7 @@
tableServiciosEnc.clear().draw()
data.values.forEach((row) => {
tableServiciosEnc.row.add([
row.tarifa_id,
row.tarifa_nombre,
@ -806,7 +837,7 @@
'</select>',
'<span id="precio_unidad_encuadernado_' + row.tarifa_id + '">' + parseFloat(row.precio_unidad).toFixed(2) + '</span>',
'<input class="update-totales" id="precio_total_encuadernado_' + row.tarifa_id +'" value="' + parseFloat(row.total).toFixed(2) + '"></input>',
'<span class="update-totales" id="margen_' + row.tarifa_id + '">' + parseFloat(row.margen).toFixed(2) + '</span>',
'<span style="display: none;" class="update-totales" id="enc_margen_' + row.tarifa_id + '">' + parseFloat(row.margen).toFixed(2) + '</span>',
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + row.tarifa_id +'"></i></a>'
]).draw(false)
@ -932,7 +963,9 @@
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
"drawCallback": function(settings ) {
updateTotales()
}
});
function init_servicio_manipulado(){
@ -951,6 +984,7 @@
element.nombre,
'<span id="precio_unidad_manipulado_' + element.tarifa_manipulado_id + '">' + parseFloat(element.precio_unidad).toFixed(2) + '</span>',
'<input class="update-totales" id="precio_total_manipulado_' + element.tarifa_manipulado_id +'" value="' + parseFloat(element.precio_total).toFixed(2) + '"></input>',
'<span style="display: none;" class="update-totales" id="manipulado_margen_' + element.tarifa_manipulado_id + '">' + parseFloat(element.margen).toFixed(2) + '</span>',
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + element.tarifa_manipulado_id +'"></i></a>'
]).draw(false)
@ -1016,7 +1050,8 @@
row.tarifa_id,
row.tarifa_nombre,
'<span id="precio_unidad_manipulado_' + row.tarifa_id + '">' + parseFloat(row.precio_unidad).toFixed(2) + '</span>',
'<input id="precio_total_manipulado_' + row.tarifa_id +'" value="' + parseFloat(row.total).toFixed(2) + '"></input>',
'<input class="update-totales" id="precio_total_manipulado_' + row.tarifa_id +'" value="' + parseFloat(row.total).toFixed(2) + '"></input>',
'<span style="display: none;" class="update-totales" id="manipulado_margen_' + row.tarifa_id + '">' + parseFloat(row.margen).toFixed(2) + '</span>',
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + row.tarifa_id +'"></i></a>'
]).draw(false)
});
@ -1036,8 +1071,9 @@
const tarifa_text = $('#add_servicio_manipulado_list').select2('data')[0].text.trim()
if( $('#add_servicio_manipulado_list').select2('data')[0].text.trim().length > 0){
if($('#tableOfServiciosManipulado tr > td:contains(' + tarifa_text + ')').length == 0)
get_tarifas_manipulado($('#add_servicio_manipulado_list').select2('data')[0].id);
if($('#tableOfServiciosManipulado tr > td:contains(' + tarifa_text + ')').length == 0){
get_tarifas_manipulado(null, $('#add_servicio_manipulado_list').select2('data')[0].id);
}
else{
popErrorAlert("<?= lang("Presupuestos.errores.error_servicios_duplicados") ?>", 'serv-manipulado-alert')
}
@ -1064,6 +1100,9 @@
case 3:
values['precio_total'] = $(this).children(":first").val()
break
case 4:
values['margen'] = $(this).text()
break
}
})
if(Object.keys(values).length>0)
@ -1095,9 +1134,12 @@
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
"drawCallback": function(settings ) {
updateTotales()
}
});
function init_servicio_preimpresion(){
const serviciospreimpresionList = <?php echo json_encode($serviciosPreimpresionList); ?>;
@ -1112,7 +1154,8 @@
tableServiciosPreimpresion.row.add([
element.tarifa_preimpresion_id,
element.nombre,
'<input id="precio_preimpresion' + element.tarifa_preimpresion_id +'" value="' + parseFloat(element.precio).toFixed(2) + '"></input>',
'<input class="update-totales" id="precio_preimpresion_' + element.tarifa_preimpresion_id +'" value="' + parseFloat(element.precio).toFixed(2) + '"></input>',
'<span style="display: none;" class="update-totales" id="preimpresion_margen_' + element.tarifa_preimpresion_id + '">' + parseFloat(element.margen).toFixed(2) + '</span>',
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + element.tarifa_preimpresion_id +'"></i></a>'
]).draw(false)
@ -1156,11 +1199,12 @@
success: function (data) {
data.values.forEach((row) => {
tableServiciosPreimpresion.row.add([
row.tarifa_id,
row.tarifa_nombre,
'<input id="precio_preimpresion' + row.tarifa_id +'" value="' + parseFloat(row.precio).toFixed(2) + '"></input>',
'<input class="update-totales" id="precio_preimpresion_' + row.tarifa_id +'" value="' + parseFloat(row.precio).toFixed(2) + '"></input>',
'<span style="display: none;" class="update-totales" id="preimpresion_margen_' + row.tarifa_id + '">' + parseFloat(row.margen).toFixed(2) + '</span>',
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + row.tarifa_id +'"></i></a>'
]).draw(false)
});
@ -1205,6 +1249,9 @@
case 2:
values['precio'] = $(this).children(":first").val()
break
case 3:
values['margen'] = $(this).text()
break
}
})
if(Object.keys(values).length>0)

View File

@ -75,7 +75,7 @@
<td class="lp-td"><input id="lp_bn_precioPliego" name="lp_bn_precioPliego" class="lp-input lp-cell lp-cell-disabled lp-bn-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_bn_libro" name="lp_bn_libro" readonly class="lp-input lp-cell lp-cell-disabled lp-bn-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_bn_totalPapelPedido" name="lp_bn_totalPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-bn-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_bn_margenPapelPedido" name="lp_bn_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-bn-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_bn_margenPapelPedido" name="lp_bn_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-bn-input" type="text" value="0" style="display: none;"></td>
<td class="lp-td"><input id="lp_bn_checkPapel" name="lp_bn_checkPapel_bn" class="update-totales" style="width: 15px; padding: 0; margin:0;" type="checkbox" checked></td>
<td class="lp-td"><input id="lp_bn_lomo" name="lp_bn_lomo" readonly class="lp-input lp-cell lp-cell-disabled lp-bn-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_bn_peso" name="lp_bn_peso" readonly class="lp-input lp-cell lp-cell-disabled lp-bn-input" type="text" value="0"></td>
@ -120,7 +120,7 @@
<td class="lp-td"><input id="lp_bnhq_precioPliego" name="lp_bnhq_precioPliego" class="lp-input lp-cell lp-cell-disabled lp-bnhq-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_bnhq_libro" name="lp_bnhq_libro" readonly class="lp-input lp-cell lp-cell-disabled lp-bnhq-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_bnhq_totalPapelPedido" name="lp_bnhq_totalPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-bnhq-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_bnhq_margenPapelPedido" name="lp_bnhq_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-bnhq-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_bnhq_margenPapelPedido" name="lp_bnhq_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-bnhq-input" type="text" value="0" style="display: none;"></td>
<td class="lp-td"><input id="lp_bnhq_checkPapel" name="lp_bnhq_checkPapel_bn"class="update-totales" style="width: 15px; padding: 0; margin:0;" type="checkbox" checked></td>
<td class="lp-td"><input id="lp_bnhq_lomo" name="lp_bnhq_lomo" readonly class="lp-input lp-cell lp-cell-disabled lp-bnhq-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_bnhq_peso" name="lp_bnhq_peso" readonly class="lp-input lp-cell lp-cell-disabled lp-bnhq-input" type="text" value="0"></td>
@ -165,7 +165,7 @@
<td class="lp-td"><input id="lp_color_precioPliego" name="lp_color_precioPliego" class="lp-input lp-cell lp-cell-disabled lp-color-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_color_libro" name="lp_color_libro" readonly class="lp-input lp-cell lp-cell-disabled lp-color-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_color_totalPapelPedido" name="lp_color_totalPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-color-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_color_margenPapelPedido" name="lp_color_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-color-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_color_margenPapelPedido" name="lp_color_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-color-input" type="text" value="0" style="display: none;"></td>
<td class="lp-td"><input id="lp_color_checkPapel" name="lp_color_checkPapel_bn"class="update-totales" style="width: 15px; padding: 0; margin:0;" type="checkbox" checked></td>
<td class="lp-td"><input id="lp_color_lomo" name="lp_color_lomo" readonly class="lp-input lp-cell lp-cell-disabled lp-color-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_color_peso" name="lp_color_peso" readonly class="lp-input lp-cell lp-cell-disabled lp-color-input" type="text" value="0"></td>
@ -211,7 +211,7 @@
<td class="lp-td"><input id="lp_colorhq_precioPliego" name="lp_colorhq_precioPliego" class="lp-input lp-cell lp-cell-disabled lp-colorhq-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_colorhq_libro" name="lp_colorhq_libro" readonly class="lp-input lp-cell lp-cell-disabled lp-colorhq-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_colorhq_totalPapelPedido" name="lp_colorhq_totalPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-colorhq-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_colorhq_margenPapelPedido" name="lp_colorhq_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-colorhq-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_colorhq_margenPapelPedido" name="lp_colorhq_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-colorhq-input" type="text" value="0" style="display: none;"></td>
<td class="lp-td"><input id="lp_colorhq_checkPapel" name="lp_colorhq_checkPapel_bn"class="update-totales" style="width: 15px; padding: 0; margin:0;" type="checkbox" checked></td>
<td class="lp-td"><input id="lp_colorhq_lomo" name="lp_colorhq_lomo" readonly class="lp-input lp-cell lp-cell-disabled lp-colorhq-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_colorhq_peso" name="lp_colorhq_peso" readonly class="lp-input lp-cell lp-cell-disabled lp-colorhq-input" type="text" value="0"></td>
@ -256,7 +256,7 @@
<td class="lp-td"><input id="lp_rot_bn_precioPliego" name="lp_rot_bn_precioPliego" class="lp-input lp-cell lp-cell-disabled lp-rotbn-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_rot_bn_libro" name="lp_rot_bn_libro" readonly class="lp-input lp-cell lp-cell-disabled lp-rotbn-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_rot_bn_totalPapelPedido" name="lp_rot_bn_totalPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-rotbn-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_rot_bn_margenPapelPedido" name="lp_rot_bn_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-rotbn-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_rot_bn_margenPapelPedido" name="lp_rot_bn_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-rotbn-input" type="text" value="0" style="display: none;"></td>
<td class="lp-td"><input id="lp_rot_bn_checkPapel" name="lp_rot_bn_checkPapel_bn"class="update-totales" style="width: 15px; padding: 0; margin:0;" type="checkbox" checked></td>
<td class="lp-td"><input id="lp_rot_bn_lomo" name="lp_rot_bn_lomo" readonly class="lp-input lp-cell lp-cell-disabled lp-rotbn-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_rot_bn_peso" name="lp_rot_bn_peso" readonly class="lp-input lp-cell lp-cell-disabled lp-rotbn-input" type="text" value="0"></td>
@ -508,7 +508,7 @@
<td class="lp-td"><input id="lp_rot_color_precioPliego" name="lp_rot_color_precioPliego" class="lp-input lp-cell lp-cell-disabled lp-rotcolor-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_rot_color_libro" name="lp_rot_color_libro" readonly class="lp-input lp-cell lp-cell-disabled lp-rotcolor-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_rot_color_totalPapelPedido" name="lp_rot_color_totalPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-rotcolor-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_rot_color_margenPapelPedido" name="lp_rot_color_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-rotcolor-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_rot_color_margenPapelPedido" name="lp_rot_color_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-rotcolor-input" type="text" value="0" style="display: none;"></td>
<td class="lp-td"><input id="lp_rot_color_checkPapel" name="lp_rot_color_checkPapel_bn"class="update-totales" style="width: 15px; padding: 0; margin:0;" type="checkbox" checked></td>
<td class="lp-td"><input id="lp_rot_color_lomo" name="lp_rot_color_lomo" readonly class="lp-input lp-cell lp-cell-disabled lp-rotcolor-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_rot_color_peso" name="lp_rot_color_peso" readonly class="lp-input lp-cell lp-cell-disabled lp-rotcolor-input" type="text" value="0"></td>
@ -768,7 +768,7 @@
<td class="lp-td"><input id="lp_cubierta_precioPliego" name="lp_cubierta_precioPliego" class="lp-input lp-cell lp-cell-disabled lp-cubierta-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_cubierta_libro" name="lp_cubierta_libro" readonly class="lp-input lp-cell lp-cell-disabled lp-cubierta-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_cubierta_totalPapelPedido" name="lp_cubierta_totalPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-cubierta-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_cubierta_margenPapelPedido" name="lp_cubierta_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-cubierta-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_cubierta_margenPapelPedido" name="lp_cubierta_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled lp-cubierta-input" type="text" value="0" style="display: none;"></td>
<td class="lp-td"><input id="lp_cubierta_checkPapel" name="lp_cubierta_checkPapel_bn"class="update-totales" style="width: 15px; padding: 0; margin:0;" type="checkbox" checked></td>
<td class="lp-td"><input id="lp_cubierta_lomo" name="lp_cubierta_lomo" readonly class="lp-input lp-cell lp-cell-disabled lp-cubierta-input" type="text" value="0"></td>
<td class="lp-td"><input id="lp_cubierta_peso" name="lp_cubierta_peso" readonly class="lp-input lp-cell lp-cell-disabled lp-cubierta-input" type="text" value="0"></td>
@ -813,7 +813,7 @@
<td class="lp-td"><input id="lp_sobrecubierta_precioPliego" name="lp_sobrecubierta_precioPliego" class="lp-input lp-cell lp-cell-disabled" type="text" value="0"></td>
<td class="lp-td"><input id="lp_sobrecubierta_libro" name="lp_sobrecubierta_libro" readonly class="lp-input lp-cell lp-cell-disabled" type="text" value="0"></td>
<td class="lp-td"><input id="lp_sobrecubierta_totalPapelPedido" name="lp_sobrecubierta_totalPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled" type="text" value="0"></td>
<td class="lp-td"><input id="lp_sobrecubierta_margenPapelPedido" name="lp_sobrecubierta_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled" type="text" value="0"></td>
<td class="lp-td"><input id="lp_sobrecubierta_margenPapelPedido" name="lp_sobrecubierta_margenPapelPedido" readonly class="lp-input lp-cell lp-cell-disabled" type="text" value="0" style="display: none;"></td>
<td class="lp-td"><input id="lp_sobrecubierta_checkPapel" name="lp_sobrecubierta_checkPapel_bn"class="update-totales" style="width: 15px; padding: 0; margin:0;" type="checkbox" checked></td>
<td class="lp-td"><input id="lp_sobrecubierta_lomo" name="lp_sobrecubierta_lomo" readonly class="lp-input lp-cell lp-cell-disabled" type="text" value="0"></td>
<td class="lp-td"><input id="lp_sobrecubierta_peso" name="lp_sobrecubierta_peso" readonly class="lp-input lp-cell lp-cell-disabled" type="text" value="0"></td>
@ -2698,13 +2698,6 @@ var tableLineasPresupuesto = new DataTable('#tableLineasPresupuesto',{
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
columnDefs: [
{
target: 12,
visible: false
}
]
});
async function set_lp_cubierta_gramaje(){

View File

@ -78,8 +78,6 @@
updateTotales()
$(".update-totales").on("change", updateTotales)
function updateTotales(){
totalPapel = 0
margenPapel = 0
@ -89,14 +87,7 @@ function updateTotales(){
totalServicios = 0
margenServicios = 0
tableLineasPresupuesto.rows({filter: 'applied'}).every( function ( rowIdx, tableLoop, rowLoop ) {
/*totalServicios += parseFloat(tableServiciosEnc.cell(rowIdx, 4).node().lastChild.value)
margenServicios += parseFloat(tableServiciosEnc.cell(rowIdx, 5).node().lastChild.innerText)
*/
});
/*$('#tableLineasPresupuesto tbody tr:visible ').each(function(){
$('#tableLineasPresupuesto tbody tr:visible ').each(function(){
if($('#' + this.id + '_checkPapel').prop('checked')){
totalPapel += parseFloat($('#' + this.id + '_totalPapelPedido').val())
margenPapel += parseFloat($('#' + this.id + '_margenPapelPedido').val())
@ -104,36 +95,67 @@ function updateTotales(){
if($('#' + this.id + '_checkClicks').prop('checked')){
totalImpresion += parseFloat($('#' + this.id + '_totalClicks').val())
}
})*/
})
$('#totalCostePapel').text(totalPapel.toFixed(2) + '€')
$('#margenPapel').text(margenPapel.toFixed(2) + '€')
$('#totalCosteImpresion').text(totalImpresion.toFixed(2) + '€')
$('#margenImpresion').text((totalImpresion*$('#margenImpresionValue').val()/100.0).toFixed(2) + '€')
tableServiciosEnc.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
if ( typeof tableServiciosEnc !== 'undefined' && tableServiciosEnc.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
margenServicios += (total*parseFloat($('#enc_margen_' + subId)[0].innerHTML)/100.0)
})
}
if ( typeof tableServiciosAcabado !== 'undefined' && tableServiciosAcabado.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
margenServicios += (total*parseFloat($('#acabado_margen_' + subId)[0].innerHTML)/100.0)
})
}
totalServicios += parseFloat(tableServiciosEnc.cell(rowIdx, 4).node().lastChild.value)
margenServicios += parseFloat(tableServiciosEnc.cell(rowIdx, 5).node().lastChild.innerText)
if ( typeof tableServiciosPreimpresion !== 'undefined' && tableServiciosPreimpresion.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
margenServicios += (total*parseFloat($('#preimpresion_margen_' + subId)[0].innerHTML)/100.0)
})
}
});
if ( typeof tableServiciosManipulado !== 'undefined' && tableServiciosManipulado.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
margenServicios += (total*parseFloat($('#manipulado_margen_' + subId)[0].innerHTML)/100.0)
})
}
/*$('#tableOfServiciosEncuadernacion tbody tr').each(function(){
console.log(this)
var currentRow = $(this).closest("tr");
var data = $('#myTable').DataTable().row(currentRow).data();
console.log(data)
//margenServicios += parseFloat(this.text())
})*/
/*$('#tableOfServiciosEncuadernacion tbody tr td:nth-child(4)').each(function(){
totalServicios += parseFloat(this.text())
})*/
totalServicios -= margenServicios;
$('#totalServicios').text(totalServicios.toFixed(2) + '€')
$('#margenServicios').text(margenServicios.toFixed(2) + '€')
}
$(".update-totales").on("change", function(){
updateTotales()
})
<?= $this->endSection() ?>