mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en los envios
This commit is contained in:
@ -552,6 +552,7 @@ $routes->group('serviciospreimpresiones', ['namespace' => 'App\Controllers\Presu
|
|||||||
|
|
||||||
$routes->group('presupuestodirecciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
$routes->group('presupuestodirecciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||||
$routes->post('datatable', 'Presupuestodirecciones::datatable', ['as' => 'dataTableOfPresupuestoDirecciones']);
|
$routes->post('datatable', 'Presupuestodirecciones::datatable', ['as' => 'dataTableOfPresupuestoDirecciones']);
|
||||||
|
$routes->post('datatable_2', 'Presupuestodirecciones::datatable_2', ['as' => 'processDataDirecciones']);
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('presupuestotiradasalternativas', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
$routes->group('presupuestotiradasalternativas', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||||
|
|||||||
@ -33,5 +33,17 @@ class Js_loader extends BaseController
|
|||||||
return view('themes/backend/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js');
|
return view('themes/backend/vuexy/form/presupuestos/cosidotapablanda/_tiradasAlternativasItems.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function datosServicios_js()
|
||||||
|
{
|
||||||
|
$this->response->setHeader('Content-Type', 'text/javascript');
|
||||||
|
return view('themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.js');
|
||||||
|
}
|
||||||
|
|
||||||
|
function datosEnvios_js()
|
||||||
|
{
|
||||||
|
$this->response->setHeader('Content-Type', 'text/javascript');
|
||||||
|
return view('themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.js');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,5 +140,32 @@ class Presupuestodirecciones extends \App\Controllers\GoBaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function datatable_2(){
|
||||||
|
|
||||||
|
$reqData = $this->request->getJSON();
|
||||||
|
|
||||||
|
if($reqData->tipo=='get_tarifa'){
|
||||||
|
$peso = $reqData->peso ?? 0;
|
||||||
|
$paisId = $reqData->paisId ?? 0;
|
||||||
|
$cp = $reqData->cp ?? 0;
|
||||||
|
$tipo_envio = $reqData->tipo_envio ?? 'cajas';
|
||||||
|
|
||||||
|
$model = model('App\Models\Tarifas\TarifaEnvioModel');
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
$values = $model->getTarifaEnvio($paisId, $cp, $peso, $tipo_envio);
|
||||||
|
$data = [
|
||||||
|
'data' => count($values)>0?$values[0]:[],
|
||||||
|
$csrfTokenName => $newTokenHash
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->respond($data);
|
||||||
|
}
|
||||||
|
else if($reqData->tipo=='clear_lineas'){
|
||||||
|
|
||||||
|
$presupuesto_id = $reqData->presupuesto_id ?? 0;
|
||||||
|
return $this->respond($this->model->where('presupuesto_id', $presupuesto_id)->delete());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,8 +77,6 @@ class Presupuestotiradasalternativas extends \App\Controllers\GoBaseResourceCont
|
|||||||
public function datatable_2()
|
public function datatable_2()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->request->isAJAX()) {
|
|
||||||
|
|
||||||
$reqData = $this->request->getPost();
|
$reqData = $this->request->getPost();
|
||||||
|
|
||||||
$newTokenHash = csrf_hash();
|
$newTokenHash = csrf_hash();
|
||||||
@ -230,6 +228,12 @@ class Presupuestotiradasalternativas extends \App\Controllers\GoBaseResourceCont
|
|||||||
$linea_coste['fields']['precio_tinta'] +
|
$linea_coste['fields']['precio_tinta'] +
|
||||||
$linea_coste['fields']['totalCorte'];
|
$linea_coste['fields']['totalCorte'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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);
|
array_push($values, $linea_coste);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -243,8 +247,6 @@ class Presupuestotiradasalternativas extends \App\Controllers\GoBaseResourceCont
|
|||||||
$response['lineas'] = $values;
|
$response['lineas'] = $values;
|
||||||
|
|
||||||
return $this->respond($response);
|
return $this->respond($response);
|
||||||
} else {
|
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -224,7 +224,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
|||||||
'proveedor' => lang('Presupuestos.no_disponible'),
|
'proveedor' => lang('Presupuestos.no_disponible'),
|
||||||
'precio_unidad'=> 0,
|
'precio_unidad'=> 0,
|
||||||
'total'=> 0,
|
'total'=> 0,
|
||||||
'marge'=> 0,
|
'margen'=> 0,
|
||||||
];
|
];
|
||||||
return $ret_array;
|
return $ret_array;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,56 @@
|
|||||||
|
// 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]);
|
||||||
|
console.log(values.data);
|
||||||
|
return values.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function get_coste_envio_tiradasAlternativas(tirada){
|
||||||
|
|
||||||
|
var peso_libro = get_peso_libro();
|
||||||
|
var tirada_inicial = parseInt($('#tirada').val());
|
||||||
|
var precio_envio = 0.0;
|
||||||
|
var margen_envio = 0.0;
|
||||||
|
|
||||||
|
$('#tableOfDireccionesEnvio').DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||||
|
const rowData = this.data();
|
||||||
|
const porcentaje = parseInt(rowData.cantidad)/tirada_inicial*100.0;
|
||||||
|
const cantidad = Math.floor(tirada*porcentaje/100.0);
|
||||||
|
const precio_linea = get_precio_envio(cantidad*peso_libro/1000.0, rowData.paisId, rowData.cp, parseInt(rowData.entregaPieCalle)==1?'palets':'cajas');
|
||||||
|
console.log(precio_linea);
|
||||||
|
precio_envio += parseFloat(precio_linea.precio);
|
||||||
|
margen_envio += parseFloat(precio_linea.precio*precio_linea.margen/100.0);
|
||||||
|
})
|
||||||
|
return {precio_envio, margen_envio};
|
||||||
|
|
||||||
|
}
|
||||||
@ -90,30 +90,17 @@ const actionBtns_direcciones = function(data) {
|
|||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
|
||||||
function updateTablaEnvios(){
|
async function updateTablaEnvios(){
|
||||||
|
|
||||||
var peso_total_libro = 0
|
var peso_total_libro = get_peso_libro();
|
||||||
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
|
||||||
var rowData = this.data();
|
|
||||||
peso_total_libro += parseFloat(rowData.peso)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||||
|
|
||||||
var rowData = this.data();
|
var rowData = this.data();
|
||||||
const peso_envio = peso_total_libro*parseInt(rowData.cantidad)/1000.0
|
const peso_envio = peso_total_libro*parseInt(rowData.cantidad)/1000.0;
|
||||||
|
|
||||||
|
const data = get_precio_envio(peso_envio, rowData.paisId, rowData.cp, parseInt(rowData.entregaPieCalle)==1?'palets':'cajas');
|
||||||
|
|
||||||
$.post( '<?= route_to('dataTableOfPresupuestoDirecciones') ?>',
|
|
||||||
{
|
|
||||||
tipo: "get_tarifa",
|
|
||||||
peso: peso_envio,
|
|
||||||
paisId: rowData.paisId,
|
|
||||||
cp: rowData.cp,
|
|
||||||
tipo_envio: parseInt(rowData.entregaPieCalle)==1?'palets':'cajas',
|
|
||||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
|
||||||
})
|
|
||||||
.done(function( data ) {
|
|
||||||
if(data.length >0){
|
if(data.length >0){
|
||||||
|
|
||||||
var precios = []
|
var precios = []
|
||||||
@ -167,12 +154,10 @@ function updateTablaEnvios(){
|
|||||||
else{
|
else{
|
||||||
popErrorAlert('<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>', 'error-tarifa')
|
popErrorAlert('<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>', 'error-tarifa')
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
});
|
* @var mixed })
|
||||||
|
*/
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('click', '.delete-add-row', function(e) {
|
$(document).on('click', '.delete-add-row', function(e) {
|
||||||
@ -411,5 +396,6 @@ function load_datos_envios(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
window.url_get_precio_envio = '<?= route_to('processDataDirecciones') ?>';
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
@ -0,0 +1,266 @@
|
|||||||
|
/****************************************************************************************
|
||||||
|
* Seccion para los servicios de acabado
|
||||||
|
***************************************************************************************/
|
||||||
|
function get_datos_acabado(){
|
||||||
|
|
||||||
|
var datosAcabado = []
|
||||||
|
if($('#tableOfServiciosAcabado').DataTable().rows().count()>0){
|
||||||
|
$("#tableOfServiciosAcabado tr").each(function (index,tr) {
|
||||||
|
var values = {}
|
||||||
|
$(this).find("td").each(function (index2) {
|
||||||
|
|
||||||
|
switch (index2) {
|
||||||
|
case 0:
|
||||||
|
values['tarifa_id'] = $(this).text()
|
||||||
|
break
|
||||||
|
case 1:
|
||||||
|
if($(this).text().includes(' '+ lang_text_cubierta))
|
||||||
|
values['cubierta'] = 1
|
||||||
|
else
|
||||||
|
values['cubierta'] = 0
|
||||||
|
if($(this).text().includes(' '+ lang_text_sobrecubierta))
|
||||||
|
values['sobrecubierta'] = 1
|
||||||
|
else
|
||||||
|
values['sobrecubierta'] = 0
|
||||||
|
break
|
||||||
|
case 2:
|
||||||
|
values['precio_unidad'] = $(this).text()
|
||||||
|
break
|
||||||
|
case 3:
|
||||||
|
values['precio_total'] = $(this).children(":first").val()
|
||||||
|
break
|
||||||
|
case 4:
|
||||||
|
values['margen'] = $(this).text()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(Object.keys(values).length>0)
|
||||||
|
datosAcabado.push(values)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return datosAcabado
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function get_servAcabados_tiradasAlternativas(tirada){
|
||||||
|
serviciosAcabados ={
|
||||||
|
coste: 0.0,
|
||||||
|
margen: 0.0,
|
||||||
|
}
|
||||||
|
json_data = {
|
||||||
|
datos: get_datos_acabado(),
|
||||||
|
tirada: parseInt(tirada),
|
||||||
|
POD: $('#POD').val()
|
||||||
|
}
|
||||||
|
json_data = Object.assign(json_data, window.token_ajax);
|
||||||
|
|
||||||
|
const response = await fetch(window.location.origin + "/presupuestos/presupuestoacabados/update/" + id , {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(json_data),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const values = await response.json();
|
||||||
|
yeniden(values[window.csrf_token]);
|
||||||
|
values.lines.forEach((line) => {
|
||||||
|
|
||||||
|
serviciosAcabados.coste += parseFloat(line[0].total);
|
||||||
|
serviciosAcabados.margen += parseFloat(line[0].total)*parseFloat(line[0].margen)/100.0;
|
||||||
|
});
|
||||||
|
return serviciosAcabados;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
* Seccion para los servicios de encuadernación
|
||||||
|
***************************************************************************************/
|
||||||
|
function get_datos_encuadernacion(){
|
||||||
|
|
||||||
|
var datosEnc = []
|
||||||
|
if($("#tableOfServiciosEncuadernacion").DataTable().rows().count()>0){
|
||||||
|
$("#tableOfServiciosEncuadernacion tr").each(function (index,tr) {
|
||||||
|
var values = {}
|
||||||
|
$(this).find("td").each(function (index2) {
|
||||||
|
|
||||||
|
switch (index2) {
|
||||||
|
case 0:
|
||||||
|
values['tarifa_id'] = $(this).text()
|
||||||
|
break
|
||||||
|
case 2:
|
||||||
|
values['proveedor_id'] = $(this).children(":first").select2('data')[0].id
|
||||||
|
break
|
||||||
|
case 3:
|
||||||
|
values['precio_unidad'] = $(this).text()
|
||||||
|
break
|
||||||
|
case 4:
|
||||||
|
values['precio_total'] = $(this).children(":first").val()
|
||||||
|
break
|
||||||
|
case 5:
|
||||||
|
values['margen'] = $(this).text()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(Object.keys(values).length>0)
|
||||||
|
datosEnc.push(values)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return datosEnc
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function get_servEncuadernacion_tiradasAlternativas(tirada, paginas, ancho, alto){
|
||||||
|
serviciosEncuadernacion ={
|
||||||
|
coste: 0.0,
|
||||||
|
margen: 0.0,
|
||||||
|
}
|
||||||
|
json_data = {
|
||||||
|
datos: get_datos_encuadernacion(),
|
||||||
|
tirada: parseInt(tirada),
|
||||||
|
paginas: parseInt(paginas),
|
||||||
|
ancho: ancho,
|
||||||
|
alto: alto,
|
||||||
|
POD: $('#POD').val()
|
||||||
|
}
|
||||||
|
json_data = Object.assign(json_data, window.token_ajax);
|
||||||
|
|
||||||
|
const response = await fetch(window.location.origin + "/presupuestos/presupuestoencuadernaciones/update/" + id , {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(json_data),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const values = await response.json();
|
||||||
|
yeniden(values[window.csrf_token]);
|
||||||
|
values.lines.forEach((line) => {
|
||||||
|
serviciosEncuadernacion.coste += parseFloat(line[0].total);
|
||||||
|
serviciosEncuadernacion.margen += parseFloat(line[0].total)*parseFloat(line[0].margen)/100.0;
|
||||||
|
});
|
||||||
|
return serviciosEncuadernacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
* Seccion para los servicios de manipulado
|
||||||
|
***************************************************************************************/
|
||||||
|
function get_datos_manipulado(){
|
||||||
|
|
||||||
|
var datosManipulado = []
|
||||||
|
if($("#tableOfServiciosManipulado").DataTable().rows().count()>0){
|
||||||
|
|
||||||
|
$("#tableOfServiciosManipulado tr").each(function (index,tr) {
|
||||||
|
var values = {}
|
||||||
|
$(this).find("td").each(function (index2) {
|
||||||
|
|
||||||
|
switch (index2) {
|
||||||
|
case 0:
|
||||||
|
values['tarifa_id'] = $(this).text()
|
||||||
|
break
|
||||||
|
case 2:
|
||||||
|
values['precio_unidad'] = $(this).text()
|
||||||
|
break
|
||||||
|
case 3:
|
||||||
|
values['precio_total'] = $(this).children(":first").val()
|
||||||
|
break
|
||||||
|
case 4:
|
||||||
|
values['margen'] = $(this).text()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(Object.keys(values).length>0)
|
||||||
|
datosManipulado.push(values)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return datosManipulado
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function get_servManipulado_tiradasAlternativas(tirada){
|
||||||
|
serviciosManipulado ={
|
||||||
|
coste: 0.0,
|
||||||
|
margen: 0.0,
|
||||||
|
}
|
||||||
|
json_data = {
|
||||||
|
datos: get_datos_manipulado(),
|
||||||
|
tirada: parseInt(tirada),
|
||||||
|
POD: $('#POD').val()
|
||||||
|
}
|
||||||
|
json_data = Object.assign(json_data, window.token_ajax);
|
||||||
|
|
||||||
|
const response = await fetch(window.location.origin + "/presupuestos/presupuestomanipulados/update/" + id , {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(json_data),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const values = await response.json();
|
||||||
|
yeniden(values[window.csrf_token]);
|
||||||
|
values.lines.forEach((line) => {
|
||||||
|
serviciosManipulado.coste += parseFloat(line[0].total);
|
||||||
|
serviciosManipulado.margen += parseFloat(line[0].total)*parseFloat(line[0].margen)/100.0;
|
||||||
|
});
|
||||||
|
return serviciosManipulado;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
* Seccion para los servicios de preimpresión
|
||||||
|
***************************************************************************************/
|
||||||
|
function get_datos_preimpresion(){
|
||||||
|
|
||||||
|
var datosPreimpresion = []
|
||||||
|
if($("#tableOfServiciosPreimpresion").DataTable().rows().count()>0){
|
||||||
|
|
||||||
|
$("#tableOfServiciosPreimpresion tr").each(function (index,tr) {
|
||||||
|
var values = {}
|
||||||
|
$(this).find("td").each(function (index2) {
|
||||||
|
|
||||||
|
switch (index2) {
|
||||||
|
case 0:
|
||||||
|
values['tarifa_id'] = $(this).text()
|
||||||
|
break
|
||||||
|
case 2:
|
||||||
|
values['precio'] = $(this).children(":first").val()
|
||||||
|
break
|
||||||
|
case 3:
|
||||||
|
values['margen'] = $(this).text()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(Object.keys(values).length>0)
|
||||||
|
datosPreimpresion.push(values)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return datosPreimpresion
|
||||||
|
}
|
||||||
|
|
||||||
|
async function get_servPreimpresion_tiradasAlternativas(){
|
||||||
|
serviciosPreimpresion ={
|
||||||
|
coste: 0.0,
|
||||||
|
margen: 0.0,
|
||||||
|
}
|
||||||
|
json_data = {
|
||||||
|
datos: get_datos_preimpresion(),
|
||||||
|
POD: $('#POD').val()
|
||||||
|
}
|
||||||
|
json_data = Object.assign(json_data, window.token_ajax);
|
||||||
|
|
||||||
|
const response = await fetch(window.location.origin + "/presupuestos/presupuestopreimpresiones/update/" + id , {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(json_data),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const values = await response.json();
|
||||||
|
yeniden(values[window.csrf_token]);
|
||||||
|
values.lines.forEach((line) => {
|
||||||
|
serviciosPreimpresion.coste += parseFloat(line[0].total);
|
||||||
|
serviciosPreimpresion.margen += parseFloat(line[0].total)*parseFloat(line[0].margen)/100.0;
|
||||||
|
});
|
||||||
|
return serviciosPreimpresion;
|
||||||
|
}
|
||||||
@ -710,46 +710,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_datos_acabado(){
|
|
||||||
|
|
||||||
var datosAcabado = []
|
|
||||||
if(tableServiciosAcabado.rows().count()>0){
|
|
||||||
$("#tableOfServiciosAcabado tr").each(function (index,tr) {
|
|
||||||
var values = {}
|
|
||||||
$(this).find("td").each(function (index2) {
|
|
||||||
|
|
||||||
switch (index2) {
|
|
||||||
case 0:
|
|
||||||
values['tarifa_id'] = $(this).text()
|
|
||||||
break
|
|
||||||
case 1:
|
|
||||||
if($(this).text().includes(' (<?= lang("Presupuestos.cubierta") ?>)'))
|
|
||||||
values['cubierta'] = 1
|
|
||||||
else
|
|
||||||
values['cubierta'] = 0
|
|
||||||
if($(this).text().includes(' (<?= lang("Presupuestos.sobrecubierta") ?>)'))
|
|
||||||
values['sobrecubierta'] = 1
|
|
||||||
else
|
|
||||||
values['sobrecubierta'] = 0
|
|
||||||
break
|
|
||||||
case 2:
|
|
||||||
values['precio_unidad'] = $(this).text()
|
|
||||||
break
|
|
||||||
case 3:
|
|
||||||
values['precio_total'] = $(this).children(":first").val()
|
|
||||||
break
|
|
||||||
case 4:
|
|
||||||
values['margen'] = $(this).text()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if(Object.keys(values).length>0)
|
|
||||||
datosAcabado.push(values)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return datosAcabado
|
|
||||||
}
|
|
||||||
|
|
||||||
init_servicio_acabado()
|
init_servicio_acabado()
|
||||||
|
|
||||||
@ -1026,41 +986,6 @@
|
|||||||
check_serv_enc_error()
|
check_serv_enc_error()
|
||||||
})
|
})
|
||||||
|
|
||||||
function get_datos_encuadernacion(){
|
|
||||||
|
|
||||||
var datosEnc = []
|
|
||||||
if(tableServiciosEnc.rows().count()>0){
|
|
||||||
$("#tableOfServiciosEncuadernacion tr").each(function (index,tr) {
|
|
||||||
var values = {}
|
|
||||||
$(this).find("td").each(function (index2) {
|
|
||||||
|
|
||||||
switch (index2) {
|
|
||||||
case 0:
|
|
||||||
values['tarifa_id'] = $(this).text()
|
|
||||||
break
|
|
||||||
case 2:
|
|
||||||
values['proveedor_id'] = $(this).children(":first").select2('data')[0].id
|
|
||||||
break
|
|
||||||
case 3:
|
|
||||||
values['precio_unidad'] = $(this).text()
|
|
||||||
break
|
|
||||||
case 4:
|
|
||||||
values['precio_total'] = $(this).children(":first").val()
|
|
||||||
break
|
|
||||||
case 5:
|
|
||||||
values['margen'] = $(this).text()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if(Object.keys(values).length>0)
|
|
||||||
datosEnc.push(values)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return datosEnc
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
init_servicio_encuadernado()
|
init_servicio_encuadernado()
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
@ -1200,37 +1125,6 @@
|
|||||||
check_serv_manipulado_error()
|
check_serv_manipulado_error()
|
||||||
})
|
})
|
||||||
|
|
||||||
function get_datos_manipulado(){
|
|
||||||
|
|
||||||
var datosManipulado = []
|
|
||||||
if(tableServiciosManipulado.rows().count()>0){
|
|
||||||
|
|
||||||
$("#tableOfServiciosManipulado tr").each(function (index,tr) {
|
|
||||||
var values = {}
|
|
||||||
$(this).find("td").each(function (index2) {
|
|
||||||
|
|
||||||
switch (index2) {
|
|
||||||
case 0:
|
|
||||||
values['tarifa_id'] = $(this).text()
|
|
||||||
break
|
|
||||||
case 2:
|
|
||||||
values['precio_unidad'] = $(this).text()
|
|
||||||
break
|
|
||||||
case 3:
|
|
||||||
values['precio_total'] = $(this).children(":first").val()
|
|
||||||
break
|
|
||||||
case 4:
|
|
||||||
values['margen'] = $(this).text()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if(Object.keys(values).length>0)
|
|
||||||
datosManipulado.push(values)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return datosManipulado
|
|
||||||
}
|
|
||||||
|
|
||||||
function servicioGuardas(add_service = false){
|
function servicioGuardas(add_service = false){
|
||||||
if(add_service){
|
if(add_service){
|
||||||
@ -1403,35 +1297,12 @@
|
|||||||
check_serv_preimpresion_error()
|
check_serv_preimpresion_error()
|
||||||
})
|
})
|
||||||
|
|
||||||
function get_datos_preimpresion(){
|
|
||||||
|
|
||||||
var datosPreimpresion = []
|
|
||||||
if(tableServiciosPreimpresion.rows().count()>0){
|
|
||||||
|
|
||||||
$("#tableOfServiciosPreimpresion tr").each(function (index,tr) {
|
|
||||||
var values = {}
|
|
||||||
$(this).find("td").each(function (index2) {
|
|
||||||
|
|
||||||
switch (index2) {
|
|
||||||
case 0:
|
|
||||||
values['tarifa_id'] = $(this).text()
|
|
||||||
break
|
|
||||||
case 2:
|
|
||||||
values['precio'] = $(this).children(":first").val()
|
|
||||||
break
|
|
||||||
case 3:
|
|
||||||
values['margen'] = $(this).text()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if(Object.keys(values).length>0)
|
|
||||||
datosPreimpresion.push(values)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return datosPreimpresion
|
|
||||||
}
|
|
||||||
|
|
||||||
init_servicio_preimpresion()
|
init_servicio_preimpresion()
|
||||||
|
|
||||||
|
|
||||||
|
// Definición de varibles para el js (actualizar el lang)
|
||||||
|
lang_text_cubierta = '<?= lang("Presupuestos.cubierta") ?>';
|
||||||
|
lang_text_sobrecubierta = '<?= lang("Presupuestos.sobrecubierta") ?>';
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|||||||
@ -14,6 +14,7 @@ const actionBtns_tiradasAlt = function (data) {
|
|||||||
var tableTiradas;
|
var tableTiradas;
|
||||||
|
|
||||||
|
|
||||||
|
// Espera a que todas las variables necesarias estén definidas
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
||||||
while (!window.hasOwnProperty("datatable_lang_url") && !window.hasOwnProperty("datatable_TA_url"))
|
while (!window.hasOwnProperty("datatable_lang_url") && !window.hasOwnProperty("datatable_TA_url"))
|
||||||
@ -29,16 +30,18 @@ var tableTiradas;
|
|||||||
total_pedido: 0,
|
total_pedido: 0,
|
||||||
precio_unidad: 0
|
precio_unidad: 0
|
||||||
}).draw(false);
|
}).draw(false);
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
// Evento de añadir una tirada alternativa
|
||||||
$('#add_tirada_alt').on('click', function () {
|
$('#add_tirada_alt').on('click', function () {
|
||||||
|
|
||||||
const dimension = getDimensionLibro();
|
const dimension = getDimensionLibro();
|
||||||
|
|
||||||
let datos = {
|
let datos = {
|
||||||
tirada: $('#tirada_alt').val(),
|
tirada: $('#tirada_alt').val(),
|
||||||
merma: 20, ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>calcular merma
|
merma: get_merma_tirada_alternativa($('#tirada_alt').val()),
|
||||||
tipo_impresion_id: $('#tipo_impresion_id').val(),
|
tipo_impresion_id: $('#tipo_impresion_id').val(),
|
||||||
json_tiradas: generate_json_tiradas(),
|
json_tiradas: generate_json_tiradas(),
|
||||||
ancho: dimension.ancho,
|
ancho: dimension.ancho,
|
||||||
@ -53,32 +56,66 @@ $('#add_tirada_alt').on('click', function () {
|
|||||||
|
|
||||||
datos = Object.assign(datos, window.token_ajax);
|
datos = Object.assign(datos, window.token_ajax);
|
||||||
|
|
||||||
|
// Se realiza la petición AJAX
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: window.get_tirada_url,
|
url: window.get_tirada_url,
|
||||||
data: datos,
|
data: datos,
|
||||||
success: function (data) {
|
success: async function (data) {
|
||||||
|
|
||||||
|
var coste_total = 0.0;
|
||||||
|
var margen_total = 0.0;
|
||||||
|
|
||||||
|
var costes_servicios = 0.0;
|
||||||
|
var margen_servicios = 0.0;
|
||||||
|
|
||||||
if(data.lineas.length >0){
|
if(data.lineas.length >0){
|
||||||
// Se cogen los valores de la linea con los datos correspondientes
|
// Se cogen los valores de la linea con los datos correspondientes
|
||||||
$.each(data.lineas, function(key, value) {
|
$.each(data.lineas, function(key, value) {
|
||||||
|
|
||||||
console.log(value);
|
coste_total += value.total_coste;
|
||||||
|
margen_total += value.total_margen;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
// Se obtiene el precio de los servicios
|
||||||
else{
|
const valueAcabados = await get_servAcabados_tiradasAlternativas(parseInt(datos.tirada));
|
||||||
|
costes_servicios += valueAcabados.coste;
|
||||||
|
margen_servicios += valueAcabados.margen;
|
||||||
|
|
||||||
|
const valueEncuadernacion = await get_servEncuadernacion_tiradasAlternativas(
|
||||||
|
parseInt(datos.tirada), parseInt( $('#paginas').val()), parseInt(dimension.ancho), parseInt(dimension.alto));
|
||||||
|
costes_servicios += valueEncuadernacion.coste;
|
||||||
|
margen_servicios += valueEncuadernacion.margen;
|
||||||
|
|
||||||
|
const valueManipulado = await get_servManipulado_tiradasAlternativas(parseInt(datos.tirada));
|
||||||
|
costes_servicios += valueManipulado.coste;
|
||||||
|
margen_servicios += valueManipulado.margen;
|
||||||
|
|
||||||
|
const valuePreimpresion = await get_servPreimpresion_tiradasAlternativas(parseInt(datos.tirada));
|
||||||
|
costes_servicios += valuePreimpresion.coste;
|
||||||
|
margen_servicios += valuePreimpresion.margen;
|
||||||
|
|
||||||
|
const valueTransporte = await get_coste_envio_tiradasAlternativas(parseInt(datos.tirada));
|
||||||
|
|
||||||
|
console.log(coste_total);
|
||||||
|
console.log(margen_total);
|
||||||
|
console.log(costes_servicios);
|
||||||
|
console.log(margen_servicios);
|
||||||
|
console.log(valueTransporte);
|
||||||
}
|
}
|
||||||
|
|
||||||
yeniden(data[window.csrf_token]);
|
yeniden(data[window.csrf_token]);
|
||||||
|
|
||||||
},
|
},
|
||||||
error: function(e){
|
error: function(e){}
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Función para obtener el lomo exterior
|
||||||
function getLomoExterior(){
|
function getLomoExterior(){
|
||||||
let lomoTotal = 0
|
let lomoTotal = 0
|
||||||
try{
|
try{
|
||||||
@ -94,6 +131,7 @@ function getLomoExterior(){
|
|||||||
return lomoTotal
|
return lomoTotal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Inicialización de la tabla de tiradas
|
// Inicialización de la tabla de tiradas
|
||||||
function initTableTiradas() {
|
function initTableTiradas() {
|
||||||
tableTiradas = $('#tableTiradas').DataTable({
|
tableTiradas = $('#tableTiradas').DataTable({
|
||||||
@ -186,3 +224,34 @@ function filterData(data, keys) {
|
|||||||
return newObj;
|
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;
|
||||||
|
}
|
||||||
@ -55,10 +55,6 @@
|
|||||||
window.datatable_TA_url = "<?= route_to('dataTableOfPresupuestoTiradasAlternativas') ?>";
|
window.datatable_TA_url = "<?= route_to('dataTableOfPresupuestoTiradasAlternativas') ?>";
|
||||||
window.get_tirada_url = "<?= route_to('getTiradaData') ?>";
|
window.get_tirada_url = "<?= route_to('getTiradaData') ?>";
|
||||||
|
|
||||||
window.token_ajax= {<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v};
|
|
||||||
|
|
||||||
window.csrf_token = '<?= csrf_token() ?>';
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,10 @@
|
|||||||
<?= !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"
|
<input type="hidden" name="tipo_impresion_id" id="tipo_impresion_id" class="form-control"
|
||||||
value="<?= $tipo_impresion_id ?>"></input>
|
value="<?= $tipo_impresion_id ?>"></input>
|
||||||
|
<input type="hidden" name="isCosido" id="isCosido" class="form-control"
|
||||||
|
value="<?= $isCosido ?>"></input>
|
||||||
|
<input type="hidden" name="POD" id="POD" class="form-control"
|
||||||
|
value="<?= $POD ?>"></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") ?>
|
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems") ?>
|
||||||
<?php if (str_contains($formAction, 'edit')): ?>
|
<?php if (str_contains($formAction, 'edit')): ?>
|
||||||
@ -227,12 +231,25 @@ const url_parts = url.split('/');
|
|||||||
return false; //stop the actual form post !important!
|
return false; //stop the actual form post !important!
|
||||||
});
|
});
|
||||||
|
|
||||||
|
<?= $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() ?>
|
<?= $this->endSection() ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?= $this->section('css') ?>
|
<?= $this->section('css') ?>
|
||||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
|
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
|
||||||
<link rel="stylesheet" href="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
|
<link rel="stylesheet" href="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
|
||||||
@ -251,6 +268,8 @@ const url_parts = url.split('/');
|
|||||||
<script src="<?= site_url('js_loader/comparadorCosidoTapaBlanda_js') ?>"></script>
|
<script src="<?= site_url('js_loader/comparadorCosidoTapaBlanda_js') ?>"></script>
|
||||||
<script src="<?= site_url('js_loader/previsualizador_js') ?>"></script>
|
<script src="<?= site_url('js_loader/previsualizador_js') ?>"></script>
|
||||||
<script src="<?= site_url('js_loader/tiradasAlternativas_js') ?>"></script>
|
<script src="<?= site_url('js_loader/tiradasAlternativas_js') ?>"></script>
|
||||||
|
<script src="<?= site_url('js_loader/datosServicios_js') ?>"></script>
|
||||||
|
<script src="<?= site_url('js_loader/datosEnvios_js') ?>"></script>
|
||||||
<script src="<?= site_url('themes/vuexy/vendor/libs/two/two.js') ?>"></script>
|
<script src="<?= site_url('themes/vuexy/vendor/libs/two/two.js') ?>"></script>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user