mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en el envio de datos
This commit is contained in:
@ -681,6 +681,7 @@ $routes->group('importador', ['namespace' => 'App\Controllers\Presupuestos'], fu
|
|||||||
$routes->get('presupuestoslist', 'Importadorpresupuestos::getPresupuestosList', ['as' => 'presupuestosList']);
|
$routes->get('presupuestoslist', 'Importadorpresupuestos::getPresupuestosList', ['as' => 'presupuestosList']);
|
||||||
$routes->get('getencuadernacion', 'Importadorpresupuestos::getEncuadernacionList');
|
$routes->get('getencuadernacion', 'Importadorpresupuestos::getEncuadernacionList');
|
||||||
$routes->get('getpresupuestodata', 'Importadorpresupuestos::getPresupuesto', ['as' => 'getPresupuesto']);
|
$routes->get('getpresupuestodata', 'Importadorpresupuestos::getPresupuesto', ['as' => 'getPresupuesto']);
|
||||||
|
$routes->post('importar', 'Importadorpresupuestos::importarPresupuesto');
|
||||||
});
|
});
|
||||||
$routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']);
|
$routes->resource('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestocliente', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
|
|||||||
@ -183,7 +183,7 @@ class Importadorpresupuestos extends \App\Controllers\BaseResourceController
|
|||||||
'ferro' => $data['datosGenerales']->ferro,
|
'ferro' => $data['datosGenerales']->ferro,
|
||||||
'ferroDigital' => $data['datosGenerales']->ferro_digital,
|
'ferroDigital' => $data['datosGenerales']->ferro_digital,
|
||||||
'marcapaginas' => $data['datosGenerales']->marcapaginas,
|
'marcapaginas' => $data['datosGenerales']->marcapaginas,
|
||||||
'prototipo' => $data['datosGenerales']->prototipo
|
//'prototipo' => $data['datosGenerales']->prototipo
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -422,4 +422,141 @@ class Importadorpresupuestos extends \App\Controllers\BaseResourceController
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function importarPresupuesto(){
|
||||||
|
|
||||||
|
if($this->request->isAJAX()){
|
||||||
|
|
||||||
|
$presupuesto_id = $this->request->getPost('id');
|
||||||
|
|
||||||
|
$tipo_presupuesto_id = intval($this->request->getPost('encuadernacion') ?? 0);
|
||||||
|
|
||||||
|
$papel_formato_id = $this->request->getPost('papel_formato_id');
|
||||||
|
$papel_formato_personalizado = intval($this->request->getPost('papel_formato_personalizado') ?? 0);
|
||||||
|
$papel_formato_ancho = intval($this->request->getPost('papel_formato_ancho') ?? 0);
|
||||||
|
$papel_formato_alto = intval($this->request->getPost('papel_formato_alto') ?? 0);
|
||||||
|
|
||||||
|
if($papel_formato_personalizado){
|
||||||
|
$tamanio = array(
|
||||||
|
"ancho" => $papel_formato_ancho,
|
||||||
|
"alto" => $papel_formato_alto
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$medidas = model('App\Models\Configuracion\PapelFormatoModel')->select('ancho, alto')->where('id', $papel_formato_id)->first();
|
||||||
|
$tamanio = array(
|
||||||
|
"ancho" => $medidas->ancho,
|
||||||
|
"alto" => $medidas->alto
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$isHq = intval($this->request->getPost('isHq') ?? 0);
|
||||||
|
$paginas_bn = intval($this->request->getPost('paginas_bn') ?? 0);
|
||||||
|
$paginas_color = intval($this->request->getPost('paginas_color') ?? 0);
|
||||||
|
$gramaje_bn = intval($this->request->getPost('gramaje_bn') ?? 0);
|
||||||
|
$gramaje_color = intval($this->request->getPost('gramaje_color') ?? 0);
|
||||||
|
$papel_bn = intval($this->request->getPost('papel_bn') ?? 0);
|
||||||
|
$papel_color = intval($this->request->getPost('papel_color') ?? 0);
|
||||||
|
|
||||||
|
$papel_interior_diferente = false;
|
||||||
|
if($papel_bn != $papel_color && $papel_bn != 0 && $papel_color != 0){
|
||||||
|
$papel_interior_diferente = true;
|
||||||
|
$papel_interior = array(
|
||||||
|
"negro" => $papel_bn,
|
||||||
|
"color" => $papel_color
|
||||||
|
);
|
||||||
|
$gramaje_interior = array(
|
||||||
|
"negro" => $gramaje_bn,
|
||||||
|
"color" => $gramaje_color
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$papel_interior = $papel_bn == 0 ? $papel_color : $papel_bn;
|
||||||
|
$gramaje_interior = $gramaje_bn == 0 ? $gramaje_color : $gramaje_bn;
|
||||||
|
}
|
||||||
|
|
||||||
|
$interior = array(
|
||||||
|
"papelInterior" => $papel_interior,
|
||||||
|
"gramajeInterior" => $gramaje_interior
|
||||||
|
);
|
||||||
|
|
||||||
|
$isColor = false;
|
||||||
|
if(intval($paginas_color)>0){
|
||||||
|
$isColor = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tapaCubierta = model('App\Models\Configuracion\TipoPresupuestoModel')->
|
||||||
|
select("is_tapa_dura")->where('id', $tipo_presupuesto_id)->first();
|
||||||
|
$tapaCubierta = $tapaCubierta->is_tapa_dura == 0 ? "tapaBlanda" : "tapaDura";
|
||||||
|
$cubierta = array(
|
||||||
|
"carasImpresion" => intval($this->request->getPost('paginas_cubierta') ?? 0),
|
||||||
|
"tipoCubierta" => $tapaCubierta,
|
||||||
|
"papelCubierta" => intval($this->request->getPost('papel_cubierta') ?? 0),
|
||||||
|
"gramajeCubierta" => intval($this->request->getPost('gramaje_cubierta') ?? 0),
|
||||||
|
"acabado" => intval($this->request->getPost('acabado_cubierta') ?? 0),
|
||||||
|
);
|
||||||
|
|
||||||
|
$solapas_cubierta = intval($this->request->getPost('solapas_cubierta') ?? 0);
|
||||||
|
if($solapas_cubierta>0){
|
||||||
|
$cubierta["solapas"] = 1;
|
||||||
|
$cubierta["tamanioSolapas"] = $solapas_cubierta;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$cubierta["solapas"] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sobrecubierta = intval($this->request->getPost('sobrecubierta') ?? 0);
|
||||||
|
if($sobrecubierta>0){
|
||||||
|
$sobrecubierta = array(
|
||||||
|
"papel" => intval($this->request->getPost('papel_sobrecubierta') ?? 0),
|
||||||
|
"gramaje" => intval($this->request->getPost('gramaje_sobrecubierta') ?? 0),
|
||||||
|
"solapas" => intval($this->request->getPost('solapas_sobrecubierta') ?? 0),
|
||||||
|
"acabado" => intval($this->request->getPost('acabado_sobrecubierta') ?? 0),
|
||||||
|
);
|
||||||
|
|
||||||
|
// para corregir el fallo de un presupuesto sin solapas en sobrecubierta
|
||||||
|
if($sobrecubierta["solapas"] == 0){
|
||||||
|
$sobrecubierta["solapas"] = 80;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sobrecubierta = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$datos = array(
|
||||||
|
"tirada" => array(intval($this->request->getPost('tirada') ?? 0)),
|
||||||
|
"paginas" => intval($this->request->getPost('paginas') ?? 0),
|
||||||
|
"tamanio" => $tamanio,
|
||||||
|
"tipo_presupuesto_id" => $tipo_presupuesto_id,
|
||||||
|
"clienteId" => intval($this->request->getPost('cliente_id') ?? 0),
|
||||||
|
"isColor" => $isColor,
|
||||||
|
"isHq" => $isHq,
|
||||||
|
"papelDiferente" => $papel_interior_diferente,
|
||||||
|
"paginasColor" => $paginas_color,
|
||||||
|
"paginasCuadernillo" => 32,
|
||||||
|
|
||||||
|
"interior" => $interior,
|
||||||
|
|
||||||
|
"cubierta" => $cubierta,
|
||||||
|
|
||||||
|
"sobrecubierta" => $sobrecubierta,
|
||||||
|
"guardas" => false,
|
||||||
|
);
|
||||||
|
|
||||||
|
$value = (new Presupuestocliente())->calcular($datos);
|
||||||
|
|
||||||
|
$returnData = [
|
||||||
|
'success' => true,
|
||||||
|
'data' => $value
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->response->setJSON($returnData);
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -460,7 +460,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$tamanio = $reqData['tamanio'];
|
$tamanio = $reqData['tamanio'];
|
||||||
$paginas = $reqData['paginas'] ?? 0;
|
$paginas = $reqData['paginas'] ?? 0;
|
||||||
$paginas_color = $reqData['paginasColor'] ?? 0;
|
$paginas_color = $reqData['paginasColor'] ?? 0;
|
||||||
$tipo = $reqData['tipo'];
|
$tipo = $reqData['tipo'] ?? 'cosido';
|
||||||
|
|
||||||
$paginasCuadernillo = $reqData['paginasCuadernillo'] ?? null;
|
$paginasCuadernillo = $reqData['paginasCuadernillo'] ?? null;
|
||||||
$papelInteriorDiferente = intval($reqData['papelInteriorDiferente'] ?? null);
|
$papelInteriorDiferente = intval($reqData['papelInteriorDiferente'] ?? null);
|
||||||
@ -478,7 +478,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$direcciones = $reqData['direcciones'] ?? [];
|
$direcciones = $reqData['direcciones'] ?? [];
|
||||||
|
|
||||||
$tipo_impresion_id = $this->getTipoImpresion($tipo, $cubierta['tipoCubierta']);
|
$tipo_impresion_id = intval($reqData['tipo_presupuesto_id'] ?? 0) == 0?
|
||||||
|
$this->getTipoImpresion($tipo, $cubierta['tipoCubierta']) : intval($reqData['tipo_presupuesto_id']);
|
||||||
$lomoRedondo = $cubierta['lomoRedondo'] ?? 0;
|
$lomoRedondo = $cubierta['lomoRedondo'] ?? 0;
|
||||||
|
|
||||||
if ($papelInteriorDiferente) {
|
if ($papelInteriorDiferente) {
|
||||||
|
|||||||
@ -368,27 +368,35 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div><!--//.card -->
|
<div class="row">
|
||||||
|
<div class="col-md-3 mb-3">
|
||||||
|
<button id="makeImport" class="btn btn-primary waves-effect waves-light mt-auto w-100">
|
||||||
|
Importar presupuesto
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div><!--//.card-body -->
|
</div><!--//.card -->
|
||||||
|
|
||||||
<div class="card-footer">
|
</div><!--//.card-body -->
|
||||||
</div><!--//.card-footer -->
|
|
||||||
|
|
||||||
</div><!--//.card -->
|
<div class="card-footer">
|
||||||
</div><!--//.col -->
|
</div><!--//.card-footer -->
|
||||||
</div><!--//.row -->
|
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
</div><!--//.card -->
|
||||||
|
</div><!--//.col -->
|
||||||
|
</div><!--//.row -->
|
||||||
|
|
||||||
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?= $this->section('css') ?>
|
<?= $this->section('css') ?>
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
<?= $this->section('additionalExternalJs') ?>
|
<?= $this->section('additionalExternalJs') ?>
|
||||||
<script type="module"
|
<script type="module"
|
||||||
src="<?= site_url('assets/js/safekat/pages/importadorPresupuestos/importador.js') ?>"></script>
|
src="<?= site_url('assets/js/safekat/pages/importadorPresupuestos/importador.js') ?>"></script>
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
@ -73,6 +73,8 @@ class Importador {
|
|||||||
|
|
||||||
this.openBtn = $('#openOld');
|
this.openBtn = $('#openOld');
|
||||||
this.initImport = $('#initImport');
|
this.initImport = $('#initImport');
|
||||||
|
this.makeImport = $('#makeImport');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@ -120,8 +122,74 @@ class Importador {
|
|||||||
this.getPresupuestoData.bind(this)();
|
this.getPresupuestoData.bind(this)();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.makeImport.on('click', this.importPresupuesto.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
importPresupuesto(){
|
||||||
|
|
||||||
|
if ($("#clienteId").val() != '' && $("#presupuesto").val() != '') {
|
||||||
|
let data = this.collectData();
|
||||||
|
new Ajax(
|
||||||
|
'/importador/importar',
|
||||||
|
data,
|
||||||
|
{},
|
||||||
|
(response) => {
|
||||||
|
if (response.success) {
|
||||||
|
alert('Presupuesto importado correctamente');
|
||||||
|
console.log(response);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
).post();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
collectData() {
|
||||||
|
|
||||||
|
let data = {};
|
||||||
|
|
||||||
|
data.id = $("#presupuesto").val();
|
||||||
|
data.cliente_id = $("#clienteId").val();
|
||||||
|
|
||||||
|
data.paginas = $('#paginas').val();
|
||||||
|
data.tirada = $('#tirada').val();
|
||||||
|
data.papel_formato_id = $('#tamanio').val();
|
||||||
|
data.papel_formato_personalizado = $('#papelFormatoPersonalizado').prop('checked')?1:0;
|
||||||
|
data.papel_formato_ancho = $('#papelFormatoAncho').val();
|
||||||
|
data.papel_formato_alto = $('#papelFormatoAlto').val();
|
||||||
|
|
||||||
|
data.encuadernacion = this.encuadernacion.getVal();
|
||||||
|
data.isHq = $('#hq').val();
|
||||||
|
|
||||||
|
data.paginas_bn = $('#compPaginasNegro').val();
|
||||||
|
data.papel_bn = this.compPapelNegroSelected.getVal();
|
||||||
|
data.gramaje_bn = $('#compGramajeNegro').val();
|
||||||
|
|
||||||
|
data.paginas_color = $('#compPaginasColor').val();
|
||||||
|
data.papel_color = this.compPapelColorSelected.getVal();
|
||||||
|
data.gramaje_color = $('#compGramajeColor').val();
|
||||||
|
|
||||||
|
data.paginas_cubierta = $('#compCarasCubierta').val();
|
||||||
|
data.papel_cubierta = this.compPapelCubiertaSelected.getVal();
|
||||||
|
data.gramaje_cubierta = $('#compGramajeCubierta').val();
|
||||||
|
data.solapas_cubierta = $('#compSolapasCubierta').val();
|
||||||
|
data.acabado_cubierta = this.acabadoCubierta.getVal();
|
||||||
|
|
||||||
|
data.sobrecubierta = $('#compSobrecubierta').val();
|
||||||
|
data.papel_sobrecubierta = this.compSobrecubiertaSelected.getVal();
|
||||||
|
data.gramaje_sobrecubierta = $('#compGramajeSobrecubierta').val();
|
||||||
|
data.solapas_sobrecubierta = $('#compSolapasSobrecubierta').val();
|
||||||
|
data.acabado_sobrecubierta = this.acabadosSobrecubierta.getVal();
|
||||||
|
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
getPresupuestoData() {
|
getPresupuestoData() {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user