mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Compare commits
26 Commits
41ac08fcd8
...
dev/presu_
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e80fddfb6 | |||
| 1e2d550301 | |||
| 0a3618cd00 | |||
| 33fbfc1a5d | |||
| a8612f64a4 | |||
| 0b614d4d58 | |||
| 55b225ab49 | |||
| 315d2a3acd | |||
| 83c8628645 | |||
| d0ee0b27bc | |||
| 8556887567 | |||
| f50987dc2b | |||
| 4180cea16a | |||
| 0b3bf0ed85 | |||
| 14fe3b1461 | |||
| 58ab81d8e8 | |||
| cdb9afc290 | |||
| adcf2fbec3 | |||
| eb806621c6 | |||
| 0963fae240 | |||
| daa10420c7 | |||
| 716019bf81 | |||
| 2ac99d14c0 | |||
| 0f00649f99 | |||
| 3dd9f8f7e3 | |||
| c79bc4343f |
@ -58,9 +58,9 @@ class ConfigErrores extends BaseResourceController
|
|||||||
public function get_error_presupuesto(int $error_presupuesto_id)
|
public function get_error_presupuesto(int $error_presupuesto_id)
|
||||||
{
|
{
|
||||||
$data = $this->errorPresupuestoModel->getErrorPresupuestoForm($error_presupuesto_id);
|
$data = $this->errorPresupuestoModel->getErrorPresupuestoForm($error_presupuesto_id);
|
||||||
if(isset($data[0])){
|
if (isset($data[0])) {
|
||||||
return $this->response->setJSON(["data" => $data[0]]);
|
return $this->response->setJSON(["data" => $data[0]]);
|
||||||
}else{
|
} else {
|
||||||
return $this->response->setJSON(["data" => []]);
|
return $this->response->setJSON(["data" => []]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ class ConfigErrores extends BaseResourceController
|
|||||||
|
|
||||||
public function datatable()
|
public function datatable()
|
||||||
{
|
{
|
||||||
$query = $this->errorPresupuestoModel->getQueryDatatable();
|
$query = $this->errorPresupuestoModel->getQueryDatatable()->orderBy("created_at", "DESC");
|
||||||
return DataTable::of($query)
|
return DataTable::of($query)
|
||||||
->add("action", fn($q) => $q->id)
|
->add("action", fn($q) => $q->id)
|
||||||
->toJson(true);
|
->toJson(true);
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<?php namespace App\Controllers\Configuracion;
|
<?php
|
||||||
|
namespace App\Controllers\Configuracion;
|
||||||
|
|
||||||
|
|
||||||
use App\Controllers\BaseResourceController;
|
use App\Controllers\BaseResourceController;
|
||||||
@ -12,8 +13,8 @@ use App\Models\Configuracion\MaquinasTarifasImpresionModel;
|
|||||||
use App\Models\Configuracion\MaquinaModel;
|
use App\Models\Configuracion\MaquinaModel;
|
||||||
|
|
||||||
use
|
use
|
||||||
DataTables\Editor,
|
DataTables\Editor,
|
||||||
DataTables\Editor\Field;
|
DataTables\Editor\Field;
|
||||||
|
|
||||||
class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||||
{
|
{
|
||||||
@ -71,7 +72,7 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->request->getPost()) :
|
if ($this->request->getPost()):
|
||||||
|
|
||||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||||
|
|
||||||
@ -81,10 +82,10 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
|
|
||||||
$noException = true;
|
$noException = true;
|
||||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||||
|
|
||||||
|
|
||||||
if ($this->canValidate()) :
|
if ($this->canValidate()):
|
||||||
try {
|
try {
|
||||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -98,14 +99,14 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||||
endif;
|
endif;
|
||||||
if ($noException && $successfulResult) :
|
if ($noException && $successfulResult):
|
||||||
|
|
||||||
$id = $this->model->db->insertID();
|
$id = $this->model->db->insertID();
|
||||||
|
|
||||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||||
|
|
||||||
if ($thenRedirect) :
|
if ($thenRedirect):
|
||||||
if (!empty($this->indexRoute)) :
|
if (!empty($this->indexRoute)):
|
||||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||||
else:
|
else:
|
||||||
return $this->redirect2listView('sweet-success', $message);
|
return $this->redirect2listView('sweet-success', $message);
|
||||||
@ -134,20 +135,20 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
|||||||
public function edit($requestedId = null)
|
public function edit($requestedId = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($requestedId == null) :
|
if ($requestedId == null):
|
||||||
return $this->redirect2listView();
|
return $this->redirect2listView();
|
||||||
endif;
|
endif;
|
||||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||||
$maquinasTarifasImpresion = $this->model->find($id);
|
$maquinasTarifasImpresion = $this->model->find($id);
|
||||||
|
|
||||||
if ($maquinasTarifasImpresion == false) :
|
if ($maquinasTarifasImpresion == false):
|
||||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion')), $id]);
|
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion')), $id]);
|
||||||
return $this->redirect2listView('sweet-error', $message);
|
return $this->redirect2listView('sweet-error', $message);
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->request->getPost()) :
|
if ($this->request->getPost()):
|
||||||
|
|
||||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||||
|
|
||||||
@ -160,10 +161,10 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
|
|
||||||
$noException = true;
|
$noException = true;
|
||||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||||
|
|
||||||
|
|
||||||
if ($this->canValidate()) :
|
if ($this->canValidate()):
|
||||||
try {
|
try {
|
||||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -180,12 +181,12 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$thenRedirect = false;
|
$thenRedirect = false;
|
||||||
endif;
|
endif;
|
||||||
if ($noException && $successfulResult) :
|
if ($noException && $successfulResult):
|
||||||
$id = $maquinasTarifasImpresion->id ?? $id;
|
$id = $maquinasTarifasImpresion->id ?? $id;
|
||||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||||
|
|
||||||
if ($thenRedirect) :
|
if ($thenRedirect):
|
||||||
if (!empty($this->indexRoute)) :
|
if (!empty($this->indexRoute)):
|
||||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||||
else:
|
else:
|
||||||
return $this->redirect2listView('sweet-success', $message);
|
return $this->redirect2listView('sweet-success', $message);
|
||||||
@ -220,30 +221,48 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
|||||||
$response = Editor::inst($db, 'lg_maquinas_tarifas_impresion')
|
$response = Editor::inst($db, 'lg_maquinas_tarifas_impresion')
|
||||||
->fields(
|
->fields(
|
||||||
Field::inst('uso')
|
Field::inst('uso')
|
||||||
->validator('Validate::notEmpty', array(
|
->validator(
|
||||||
'message' => lang('MaquinasTarifasImpresions.validation.uso.required'))
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('MaquinasTarifasImpresions.validation.uso.required')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Field::inst('tipo')
|
Field::inst('tipo')
|
||||||
->validator('Validate::notEmpty', array(
|
->validator(
|
||||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required'))
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Field::inst('precio')
|
Field::inst('precio')
|
||||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||||
->validator('Validate::numeric', array(
|
->validator(
|
||||||
|
'Validate::numeric',
|
||||||
|
array(
|
||||||
"decimal" => ',',
|
"decimal" => ',',
|
||||||
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal'))
|
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
->validator('Validate::notEmpty', array(
|
->validator(
|
||||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required'))
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Field::inst('margen')
|
Field::inst('margen')
|
||||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||||
->validator('Validate::numeric', array(
|
->validator(
|
||||||
|
'Validate::numeric',
|
||||||
|
array(
|
||||||
"decimal" => ',',
|
"decimal" => ',',
|
||||||
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal'))
|
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
->validator('Validate::notEmpty', array(
|
->validator(
|
||||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required'))
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Field::inst('maquina_id'),
|
Field::inst('maquina_id'),
|
||||||
Field::inst('user_created_id'),
|
Field::inst('user_created_id'),
|
||||||
@ -269,16 +288,21 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
|||||||
'maquina_id' => $values['maquina_id'],
|
'maquina_id' => $values['maquina_id'],
|
||||||
'tipo' => $values['tipo'],
|
'tipo' => $values['tipo'],
|
||||||
'uso' => $values['uso'],
|
'uso' => $values['uso'],
|
||||||
'is_deleted' => 0));
|
'is_deleted' => 0
|
||||||
|
));
|
||||||
|
|
||||||
$id = $builder->get()->getFirstRow()->id;
|
$id = $builder->get()->getFirstRow();
|
||||||
|
if ($id) {
|
||||||
|
$id = $id->id;
|
||||||
|
// No se pueden duplicar valores al crear o al editar
|
||||||
|
if ($builder->countAllResults() >= 1) {
|
||||||
|
if (
|
||||||
|
($action === Editor::ACTION_EDIT && $id != $pkey)
|
||||||
|
|| $action === Editor::ACTION_CREATE
|
||||||
|
) {
|
||||||
|
|
||||||
// No se pueden duplicar valores al crear o al editar
|
return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
|
||||||
if ($builder->countAllResults() >= 1) {
|
}
|
||||||
if (($action === Editor::ACTION_EDIT && $id != $pkey)
|
|
||||||
|| $action === Editor::ACTION_CREATE) {
|
|
||||||
|
|
||||||
return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,11 +437,11 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
|||||||
protected function getMaquinaListItems($selId = null)
|
protected function getMaquinaListItems($selId = null)
|
||||||
{
|
{
|
||||||
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
|
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
|
||||||
if (!empty($selId)) :
|
if (!empty($selId)):
|
||||||
$maquinaModel = model('App\Models\Configuracion\MaquinaModel');
|
$maquinaModel = model('App\Models\Configuracion\MaquinaModel');
|
||||||
|
|
||||||
$selOption = $maquinaModel->where('id', $selId)->findColumn('nombre');
|
$selOption = $maquinaModel->where('id', $selId)->findColumn('nombre');
|
||||||
if (!empty($selOption)) :
|
if (!empty($selOption)):
|
||||||
$data[$selId] = $selOption[0];
|
$data[$selId] = $selOption[0];
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
@ -1278,8 +1278,8 @@ class Cosidotapablanda extends \App\Controllers\BaseResourceController
|
|||||||
$input_data['is_duplicado'] = $presupuestoEntity->is_duplicado;
|
$input_data['is_duplicado'] = $presupuestoEntity->is_duplicado;
|
||||||
|
|
||||||
if($presupuestoEntity->papel_formato_personalizado){
|
if($presupuestoEntity->papel_formato_personalizado){
|
||||||
$input_data['ancho'] = $presupuestoEntity->ancho;
|
$input_data['ancho'] = $presupuestoEntity->papel_formato_ancho ;
|
||||||
$input_data['alto'] = $presupuestoEntity->alto;
|
$input_data['alto'] = $presupuestoEntity->papel_formato_alto ;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$model = model("App\Models\Configuracion\PapelFormatoModel");
|
$model = model("App\Models\Configuracion\PapelFormatoModel");
|
||||||
|
|||||||
@ -99,9 +99,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
// Se obtiene el cliente ID a partir del usuario de la sesion
|
// Se obtiene el cliente ID a partir del usuario de la sesion
|
||||||
$model_user = model('App\Models\Usuarios\UserModel');
|
$model_user = model('App\Models\Usuarios\UserModel');
|
||||||
|
|
||||||
$user = $model_user->find(auth()->user()->id);
|
$user = $model_user->find(auth()->user()->id);
|
||||||
$clienteId = $user->cliente_id;
|
$clienteId = $user->cliente_id;
|
||||||
|
|
||||||
|
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
|
||||||
|
if ($clienteId === false || $clienteId === null) {
|
||||||
|
return $this->failNotFound('Su usuario no tiene asociado un cliente de Safekat. Póngase en contacto con el administrador.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
|
$POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
|
||||||
|
|
||||||
$this->viewData['breadcrumb'] = [
|
$this->viewData['breadcrumb'] = [
|
||||||
@ -137,10 +144,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
// Se obtiene el cliente ID a partir del usuario de la sesion
|
// Se obtiene el cliente ID a partir del usuario de la sesion
|
||||||
$model_user = model('App\Models\Usuarios\UserModel');
|
$model_user = model('App\Models\Usuarios\UserModel');
|
||||||
$user = $model_user->find(auth()->user()->id);
|
$user = $model_user->find(auth()->user()->id);
|
||||||
if(auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')){
|
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
|
||||||
$clienteId = $user->cliente_id;
|
$clienteId = $user->cliente_id;
|
||||||
}
|
if ($clienteId === false || $clienteId === null) {
|
||||||
else{
|
return $this->failNotFound('Su usuario no tiene asociado un cliente de Safekat. Póngase en contacto con el administrador.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$clienteId = $presupuestoEntity->cliente_id;
|
$clienteId = $presupuestoEntity->cliente_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,6 +166,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->viewData['presupuestoId'] = $presupuestoEntity->id;
|
$this->viewData['presupuestoId'] = $presupuestoEntity->id;
|
||||||
|
$this->viewData['state'] = intval($presupuestoEntity->estado_id);
|
||||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.edit3');
|
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.edit3');
|
||||||
|
|
||||||
return $this->displayForm(__METHOD__, $id);
|
return $this->displayForm(__METHOD__, $id);
|
||||||
@ -361,8 +371,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
);
|
);
|
||||||
|
|
||||||
$return_data = $this->calcular_presupuesto($datos_presupuesto, 0, false); //TRUE FOR DEBUG
|
$return_data = $this->calcular_presupuesto($datos_presupuesto, 0, false); //TRUE FOR DEBUG
|
||||||
if(array_key_exists('errors', $return_data)){
|
if (array_key_exists('errors', $return_data)) {
|
||||||
if($return_data['errors']->status == 1){
|
if ($return_data['errors']->status == 1) {
|
||||||
$return_data = [
|
$return_data = [
|
||||||
'errors' => (object) ([
|
'errors' => (object) ([
|
||||||
'status' => 1
|
'status' => 1
|
||||||
@ -370,7 +380,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
];
|
];
|
||||||
return $return_data;
|
return $return_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('exception', $return_data)) {
|
if (array_key_exists('exception', $return_data)) {
|
||||||
@ -412,7 +421,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
return $return_data;
|
return $return_data;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$coste_envio += $coste_direccion->coste;
|
$coste_envio += $coste_direccion->coste;
|
||||||
}
|
}
|
||||||
@ -449,8 +457,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$return_data['precio_u'][$i] = round(floatval($return_data['precio_u'][$i]) + $coste_envio / $tirada[$i], 4);
|
$return_data['precio_u'][$i] = round(floatval($return_data['precio_u'][$i]) + $coste_envio / $tirada[$i], 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond($return_data);
|
return $this->respond($return_data);
|
||||||
@ -621,6 +627,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$datosCabecera = $reqData['datosCabecera'] ?? [];
|
$datosCabecera = $reqData['datosCabecera'] ?? [];
|
||||||
|
|
||||||
$confirmar = $reqData['confirmar'] ?? 0;
|
$confirmar = $reqData['confirmar'] ?? 0;
|
||||||
|
$confirmar = intval($confirmar);
|
||||||
|
|
||||||
$cliente_id = $reqData['clienteId'] ?? -1;
|
$cliente_id = $reqData['clienteId'] ?? -1;
|
||||||
|
|
||||||
@ -728,6 +735,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
'servicios' => $reqData['servicios'] ?? [],
|
'servicios' => $reqData['servicios'] ?? [],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$datos_presupuesto['id'] = $id;
|
||||||
|
|
||||||
$resultado_presupuesto = $this->calcular_presupuesto($datos_presupuesto, $selected_tirada, true);
|
$resultado_presupuesto = $this->calcular_presupuesto($datos_presupuesto, $selected_tirada, true);
|
||||||
|
|
||||||
if (isset($resultado_presupuesto['errors'])) {
|
if (isset($resultado_presupuesto['errors'])) {
|
||||||
@ -785,8 +794,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$resultado_presupuesto['info']['totales'][$i]['coste_envio'] = $coste_envio - $margen_envio;
|
$resultado_presupuesto['info']['totales'][$i]['coste_envio'] = $coste_envio - $margen_envio;
|
||||||
$resultado_presupuesto['info']['totales'][$i]['margen_envio'] = $margen_envio;
|
$resultado_presupuesto['info']['totales'][$i]['margen_envio'] = $margen_envio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$model_presupuesto = new PresupuestoModel();
|
$model_presupuesto = new PresupuestoModel();
|
||||||
@ -832,9 +839,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
$acabado_id = $this->obtenerTarifasAcabado($datos_presupuesto['cubierta']['acabadosCubierta']);
|
$acabado_id = $this->obtenerTarifasAcabado($datos_presupuesto['cubierta']['acabadosCubierta']);
|
||||||
if (count($acabado_id) > 0) {
|
if (count($acabado_id) > 0) {
|
||||||
$datos_presupuesto['cubierta']['acabadosCubierta']['plastificado'] = $acabado_id[0];
|
if (array_key_exists('plastificado', $acabado_id)) {
|
||||||
$datos_presupuesto['cubierta']['acabadosCubierta']['barniz'] = $acabado_id[1];
|
$datos_presupuesto['cubierta']['acabadosCubierta']['plastificado'] = $acabado_id['plastificado'];
|
||||||
$datos_presupuesto['cubierta']['acabadosCubierta']['estampado'] = $acabado_id[2];
|
}
|
||||||
|
if (array_key_exists('barniz', $acabado_id)) {
|
||||||
|
$datos_presupuesto['cubierta']['acabadosCubierta']['barniz'] = $acabado_id['barniz'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('estampado', $acabado_id)) {
|
||||||
|
$datos_presupuesto['cubierta']['acabadosCubierta']['estampado'] = $acabado_id['estampado'];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$datos_presupuesto['cubierta']['acabadosCubierta']['id'] = 0;
|
$datos_presupuesto['cubierta']['acabadosCubierta']['id'] = 0;
|
||||||
}
|
}
|
||||||
@ -890,8 +903,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($reqData['direcciones'] as $direccion) {
|
if (array_key_exists('direcciones', $reqData)) {
|
||||||
$this->guardarLineaEnvio($id, $direccion, $peso_libro);
|
|
||||||
|
foreach ($reqData['direcciones'] as $direccion) {
|
||||||
|
$this->guardarLineaEnvio($id, $direccion, $peso_libro);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($confirmar) {
|
if ($confirmar) {
|
||||||
@ -914,17 +930,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
{
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
$modelPapelGenerico = new PapelGenericoModel();
|
|
||||||
$modelPapelFormato = new PapelFormatoModel();
|
$modelPapelFormato = new PapelFormatoModel();
|
||||||
$modelCliente = new ClienteModel();
|
$modelCliente = new ClienteModel();
|
||||||
|
|
||||||
$reqData = $this->request->getPost();
|
|
||||||
|
|
||||||
$presupuesto = $this->model->find($id);
|
$presupuesto = $this->model->find($id);
|
||||||
$data = [];
|
$data = [];
|
||||||
if ($presupuesto) {
|
if ($presupuesto) {
|
||||||
$data['lc'] = $presupuesto->lomo_cubierta;
|
$data['lc'] = $presupuesto->lomo_cubierta;
|
||||||
$data['lsc'] = $presupuesto->lomo_sobrecubierta;
|
$data['lsc'] = $presupuesto->lomo_sobrecubierta;
|
||||||
|
$data['state'] = intval($presupuesto->estado_id);
|
||||||
$data['datosGenerales']['titulo'] = $presupuesto->titulo;
|
$data['datosGenerales']['titulo'] = $presupuesto->titulo;
|
||||||
$data['datosGenerales']['autor'] = $presupuesto->autor;
|
$data['datosGenerales']['autor'] = $presupuesto->autor;
|
||||||
$data['datosGenerales']['isbn'] = $presupuesto->isbn;
|
$data['datosGenerales']['isbn'] = $presupuesto->isbn;
|
||||||
@ -963,8 +978,17 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$data['cubierta']['cabezada'] = $presupuesto->cabezada;
|
$data['cubierta']['cabezada'] = $presupuesto->cabezada;
|
||||||
$modelAcabado = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel");
|
$modelAcabado = model("App\Models\Tarifas\Acabados\TarifaAcabadoModel");
|
||||||
$data['cubierta']['plastificado'] = $modelAcabado->getCodeFromId($presupuesto->acabado_cubierta_id);
|
$data['cubierta']['plastificado'] = $modelAcabado->getCodeFromId($presupuesto->acabado_cubierta_id);
|
||||||
|
if ($data['cubierta']['plastificado'] == '') {
|
||||||
|
$data['cubierta']['plastificado'] = 'NONE';
|
||||||
|
}
|
||||||
$data['cubierta']['barniz'] = $modelAcabado->getCodeFromId($presupuesto->barniz_cubierta_id);
|
$data['cubierta']['barniz'] = $modelAcabado->getCodeFromId($presupuesto->barniz_cubierta_id);
|
||||||
|
if ($data['cubierta']['barniz'] == '') {
|
||||||
|
$data['cubierta']['barniz'] = 'NONE';
|
||||||
|
}
|
||||||
$data['cubierta']['estampado'] = $modelAcabado->getCodeFromId($presupuesto->estampado_cubierta_id);
|
$data['cubierta']['estampado'] = $modelAcabado->getCodeFromId($presupuesto->estampado_cubierta_id);
|
||||||
|
if ($data['cubierta']['estampado'] == '') {
|
||||||
|
$data['cubierta']['estampado'] = 'NONE';
|
||||||
|
}
|
||||||
$data['cubierta']['retractilado'] = $presupuesto->retractilado ? 1 : 0;
|
$data['cubierta']['retractilado'] = $presupuesto->retractilado ? 1 : 0;
|
||||||
|
|
||||||
$data['sobrecubierta'] = array_key_exists('sobrecubierta', $datos_papel) ? $datos_papel['sobrecubierta'] : [];
|
$data['sobrecubierta'] = array_key_exists('sobrecubierta', $datos_papel) ? $datos_papel['sobrecubierta'] : [];
|
||||||
@ -982,11 +1006,15 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id);
|
$data['direcciones'] = $this->obtenerDireccionesEnvio($id, $presupuesto->cliente_id);
|
||||||
|
|
||||||
|
if(intval($presupuesto->estado_id) == 2){
|
||||||
|
$data['resumen']['base'] = $presupuesto->total_aceptado;
|
||||||
|
$data['resumen']['precio_unidad'] = $presupuesto->total_precio_unidad;
|
||||||
|
}
|
||||||
|
|
||||||
$tiradas_alternativas = json_decode($presupuesto->tirada_alternativa_json_data);
|
$tiradas_alternativas = json_decode($presupuesto->tirada_alternativa_json_data);
|
||||||
for ($i = 0; $i < count($tiradas_alternativas); $i++) {
|
for ($i = 0; $i < count($tiradas_alternativas); $i++) {
|
||||||
$tirada = $tiradas_alternativas[$i];
|
$tirada = $tiradas_alternativas[$i];
|
||||||
$data['datosGenerales']['tirada' . ($i + 2)] = $tirada->tirada;
|
$data['datosGenerales']['tirada' . ($i + 2)] = $tirada->tirada;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
@ -994,8 +1022,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
'data' => $data
|
'data' => $data
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
}
|
}
|
||||||
@ -1387,7 +1413,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
if ($interior == -1) {
|
if ($interior == -1) {
|
||||||
$errorModel = new ErrorPresupuesto();
|
$errorModel = new ErrorPresupuesto();
|
||||||
$errorModel->insertError(
|
$errorModel->insertError(
|
||||||
$datos_entrada['id'],
|
$datos_entrada['id'] == 0 ? null : $datos_entrada['id'],
|
||||||
auth()->user()->id,
|
auth()->user()->id,
|
||||||
'
|
'
|
||||||
No se puede obtener el interior',
|
No se puede obtener el interior',
|
||||||
@ -1932,7 +1958,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $return_data;
|
return $return_data;
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return [
|
return [
|
||||||
'exception' => $e->getMessage(),
|
'exception' => $e->getMessage(),
|
||||||
@ -2389,7 +2414,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
if ($value != 'NONE') {
|
if ($value != 'NONE') {
|
||||||
$data = $model->where('code', $value)->first();
|
$data = $model->where('code', $value)->first();
|
||||||
$data = $data->id;
|
$data = $data->id;
|
||||||
array_push($tarifas, $data);
|
array_push($tarifas, [$acabado => $data]);
|
||||||
} else {
|
} else {
|
||||||
array_push($tarifas, 0);
|
array_push($tarifas, 0);
|
||||||
}
|
}
|
||||||
@ -2426,5 +2451,4 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
return [$paginasNegro, $paginasColor];
|
return [$paginasNegro, $paginasColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<?php namespace App\Controllers\Tarifas;
|
<?php
|
||||||
|
namespace App\Controllers\Tarifas;
|
||||||
|
|
||||||
|
|
||||||
use App\Controllers\BaseResourceController;
|
use App\Controllers\BaseResourceController;
|
||||||
@ -10,15 +11,15 @@ use App\Entities\Tarifas\TarifaEncuadernacionLinea;
|
|||||||
use App\Models\Tarifas\TarifaEncuadernacionLineaModel;
|
use App\Models\Tarifas\TarifaEncuadernacionLineaModel;
|
||||||
|
|
||||||
use
|
use
|
||||||
DataTables\Editor,
|
DataTables\Editor,
|
||||||
DataTables\Database,
|
DataTables\Database,
|
||||||
DataTables\Editor\Field,
|
DataTables\Editor\Field,
|
||||||
DataTables\Editor\Format,
|
DataTables\Editor\Format,
|
||||||
DataTables\Editor\Mjoin,
|
DataTables\Editor\Mjoin,
|
||||||
DataTables\Editor\Options,
|
DataTables\Editor\Options,
|
||||||
DataTables\Editor\Upload,
|
DataTables\Editor\Upload,
|
||||||
DataTables\Editor\Validate,
|
DataTables\Editor\Validate,
|
||||||
DataTables\Editor\ValidateOptions;
|
DataTables\Editor\ValidateOptions;
|
||||||
|
|
||||||
|
|
||||||
class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||||
@ -75,7 +76,7 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->request->getPost()) :
|
if ($this->request->getPost()):
|
||||||
|
|
||||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||||
|
|
||||||
@ -84,10 +85,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
|||||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||||
|
|
||||||
$noException = true;
|
$noException = true;
|
||||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||||
|
|
||||||
|
|
||||||
if ($this->canValidate()) :
|
if ($this->canValidate()):
|
||||||
try {
|
try {
|
||||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -101,14 +102,14 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||||
endif;
|
endif;
|
||||||
if ($noException && $successfulResult) :
|
if ($noException && $successfulResult):
|
||||||
|
|
||||||
$id = $this->model->db->insertID();
|
$id = $this->model->db->insertID();
|
||||||
|
|
||||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||||
|
|
||||||
if ($thenRedirect) :
|
if ($thenRedirect):
|
||||||
if (!empty($this->indexRoute)) :
|
if (!empty($this->indexRoute)):
|
||||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||||
else:
|
else:
|
||||||
return $this->redirect2listView('sweet-success', $message);
|
return $this->redirect2listView('sweet-success', $message);
|
||||||
@ -134,20 +135,20 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
|||||||
public function edit($requestedId = null)
|
public function edit($requestedId = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($requestedId == null) :
|
if ($requestedId == null):
|
||||||
return $this->redirect2listView();
|
return $this->redirect2listView();
|
||||||
endif;
|
endif;
|
||||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||||
$tarifaEncuadernacionLinea = $this->model->find($id);
|
$tarifaEncuadernacionLinea = $this->model->find($id);
|
||||||
|
|
||||||
if ($tarifaEncuadernacionLinea == false) :
|
if ($tarifaEncuadernacionLinea == false):
|
||||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]);
|
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]);
|
||||||
return $this->redirect2listView('sweet-error', $message);
|
return $this->redirect2listView('sweet-error', $message);
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->request->getPost()) :
|
if ($this->request->getPost()):
|
||||||
|
|
||||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||||
|
|
||||||
@ -156,10 +157,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
|||||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||||
|
|
||||||
$noException = true;
|
$noException = true;
|
||||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||||
|
|
||||||
|
|
||||||
if ($this->canValidate()) :
|
if ($this->canValidate()):
|
||||||
try {
|
try {
|
||||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -176,12 +177,12 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$thenRedirect = false;
|
$thenRedirect = false;
|
||||||
endif;
|
endif;
|
||||||
if ($noException && $successfulResult) :
|
if ($noException && $successfulResult):
|
||||||
$id = $tarifaEncuadernacionLinea->id ?? $id;
|
$id = $tarifaEncuadernacionLinea->id ?? $id;
|
||||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||||
|
|
||||||
if ($thenRedirect) :
|
if ($thenRedirect):
|
||||||
if (!empty($this->indexRoute)) :
|
if (!empty($this->indexRoute)):
|
||||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||||
else:
|
else:
|
||||||
return $this->redirect2listView('sweet-success', $message);
|
return $this->redirect2listView('sweet-success', $message);
|
||||||
@ -214,45 +215,90 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
|||||||
$response = Editor::inst($db, 'tarifa_encuadernacion_lineas')
|
$response = Editor::inst($db, 'tarifa_encuadernacion_lineas')
|
||||||
->fields(
|
->fields(
|
||||||
Field::inst('paginas_libro_min')
|
Field::inst('paginas_libro_min')
|
||||||
->validator('Validate::numeric', array(
|
->validator(
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal'))
|
'Validate::numeric',
|
||||||
|
array(
|
||||||
|
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
->validator('Validate::notEmpty', array(
|
->validator(
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required'))
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Field::inst('paginas_libro_max')
|
Field::inst('paginas_libro_max')
|
||||||
->validator('Validate::numeric', array(
|
->validator(
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal'))
|
'Validate::numeric',
|
||||||
|
array(
|
||||||
|
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
->validator('Validate::notEmpty', array(
|
->validator(
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required'))
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Field::inst('precio_min')
|
Field::inst('precio_min')
|
||||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||||
->validator('Validate::numeric', array(
|
->validator(
|
||||||
|
'Validate::numeric',
|
||||||
|
array(
|
||||||
"decimal" => ',',
|
"decimal" => ',',
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal'))
|
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
->validator('Validate::notEmpty', array(
|
->validator(
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required'))
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Field::inst('precio_max')
|
Field::inst('precio_max')
|
||||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||||
->validator('Validate::numeric', array(
|
->validator(
|
||||||
|
'Validate::numeric',
|
||||||
|
array(
|
||||||
"decimal" => ',',
|
"decimal" => ',',
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal'))
|
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
->validator('Validate::notEmpty', array(
|
->validator(
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required'))
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Field::inst('total_min')
|
||||||
|
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||||
|
->validator(
|
||||||
|
'Validate::numeric',
|
||||||
|
array(
|
||||||
|
"decimal" => ',',
|
||||||
|
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->validator(
|
||||||
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Field::inst('margen')
|
Field::inst('margen')
|
||||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||||
->validator('Validate::numeric', array(
|
->validator(
|
||||||
|
'Validate::numeric',
|
||||||
|
array(
|
||||||
"decimal" => ',',
|
"decimal" => ',',
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal'))
|
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
->validator('Validate::notEmpty', array(
|
->validator(
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.margen.required'))
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('TarifaAcabadoLineas.validation.margen.required')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Field::inst('tirada_encuadernacion_id'),
|
Field::inst('tirada_encuadernacion_id'),
|
||||||
Field::inst('user_created_id'),
|
Field::inst('user_created_id'),
|
||||||
@ -325,7 +371,7 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$cleandatatable = $reqData['cleandatatable'] ?? 0;
|
$cleandatatable = $reqData['cleandatatable'] ?? 0;
|
||||||
|
|
||||||
if($cleandatatable){
|
if ($cleandatatable) {
|
||||||
|
|
||||||
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1;
|
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1;
|
||||||
|
|
||||||
@ -339,9 +385,7 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
|||||||
];
|
];
|
||||||
return $this->respond($data);
|
return $this->respond($data);
|
||||||
|
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else{
|
|
||||||
|
|
||||||
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
|
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
|
||||||
$errstr = 'No data available in response to this specific request.';
|
$errstr = 'No data available in response to this specific request.';
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<?php namespace App\Controllers\Tarifas;
|
<?php
|
||||||
|
namespace App\Controllers\Tarifas;
|
||||||
|
|
||||||
|
|
||||||
use App\Controllers\BaseResourceController;
|
use App\Controllers\BaseResourceController;
|
||||||
@ -10,15 +11,15 @@ use App\Entities\Tarifas\TarifaEncuadernacionLinea;
|
|||||||
use App\Models\Tarifas\TarifaEncuadernacionLineaHorasModel;
|
use App\Models\Tarifas\TarifaEncuadernacionLineaHorasModel;
|
||||||
|
|
||||||
use
|
use
|
||||||
DataTables\Editor,
|
DataTables\Editor,
|
||||||
DataTables\Database,
|
DataTables\Database,
|
||||||
DataTables\Editor\Field,
|
DataTables\Editor\Field,
|
||||||
DataTables\Editor\Format,
|
DataTables\Editor\Format,
|
||||||
DataTables\Editor\Mjoin,
|
DataTables\Editor\Mjoin,
|
||||||
DataTables\Editor\Options,
|
DataTables\Editor\Options,
|
||||||
DataTables\Editor\Upload,
|
DataTables\Editor\Upload,
|
||||||
DataTables\Editor\Validate,
|
DataTables\Editor\Validate,
|
||||||
DataTables\Editor\ValidateOptions;
|
DataTables\Editor\ValidateOptions;
|
||||||
|
|
||||||
|
|
||||||
class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceController
|
class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceController
|
||||||
@ -73,7 +74,7 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if ($this->request->getPost()) :
|
if ($this->request->getPost()):
|
||||||
|
|
||||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||||
|
|
||||||
@ -82,10 +83,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
|||||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||||
|
|
||||||
$noException = true;
|
$noException = true;
|
||||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||||
|
|
||||||
|
|
||||||
if ($this->canValidate()) :
|
if ($this->canValidate()):
|
||||||
try {
|
try {
|
||||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -99,14 +100,14 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
|||||||
|
|
||||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||||
endif;
|
endif;
|
||||||
if ($noException && $successfulResult) :
|
if ($noException && $successfulResult):
|
||||||
|
|
||||||
$id = $this->model->db->insertID();
|
$id = $this->model->db->insertID();
|
||||||
|
|
||||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||||
|
|
||||||
if ($thenRedirect) :
|
if ($thenRedirect):
|
||||||
if (!empty($this->indexRoute)) :
|
if (!empty($this->indexRoute)):
|
||||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||||
else:
|
else:
|
||||||
return $this->redirect2listView('sweet-success', $message);
|
return $this->redirect2listView('sweet-success', $message);
|
||||||
@ -134,20 +135,20 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
|||||||
public function edit($requestedId = null)
|
public function edit($requestedId = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($requestedId == null) :
|
if ($requestedId == null):
|
||||||
return $this->redirect2listView();
|
return $this->redirect2listView();
|
||||||
endif;
|
endif;
|
||||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||||
$tarifaEncuadernacionLinea = $this->model->find($id);
|
$tarifaEncuadernacionLinea = $this->model->find($id);
|
||||||
|
|
||||||
if ($tarifaEncuadernacionLinea == false) :
|
if ($tarifaEncuadernacionLinea == false):
|
||||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]);
|
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]);
|
||||||
return $this->redirect2listView('sweet-error', $message);
|
return $this->redirect2listView('sweet-error', $message);
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->request->getPost()) :
|
if ($this->request->getPost()):
|
||||||
|
|
||||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||||
|
|
||||||
@ -156,10 +157,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
|||||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||||
|
|
||||||
$noException = true;
|
$noException = true;
|
||||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||||
|
|
||||||
|
|
||||||
if ($this->canValidate()) :
|
if ($this->canValidate()):
|
||||||
try {
|
try {
|
||||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -176,12 +177,12 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
|||||||
|
|
||||||
$thenRedirect = false;
|
$thenRedirect = false;
|
||||||
endif;
|
endif;
|
||||||
if ($noException && $successfulResult) :
|
if ($noException && $successfulResult):
|
||||||
$id = $tarifaEncuadernacionLinea->id ?? $id;
|
$id = $tarifaEncuadernacionLinea->id ?? $id;
|
||||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||||
|
|
||||||
if ($thenRedirect) :
|
if ($thenRedirect):
|
||||||
if (!empty($this->indexRoute)) :
|
if (!empty($this->indexRoute)):
|
||||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||||
else:
|
else:
|
||||||
return $this->redirect2listView('sweet-success', $message);
|
return $this->redirect2listView('sweet-success', $message);
|
||||||
@ -214,40 +215,79 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
|||||||
$response = Editor::inst($db, 'tarifa_encuadernacion_lineas_horas')
|
$response = Editor::inst($db, 'tarifa_encuadernacion_lineas_horas')
|
||||||
->fields(
|
->fields(
|
||||||
Field::inst('tiempo_min')
|
Field::inst('tiempo_min')
|
||||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||||
->validator('Validate::numeric', array(
|
->validator(
|
||||||
|
'Validate::numeric',
|
||||||
|
array(
|
||||||
"decimal" => ',',
|
"decimal" => ',',
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal'))
|
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
->validator('Validate::notEmpty', array(
|
->validator(
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required'))
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Field::inst('tiempo_max')
|
Field::inst('tiempo_max')
|
||||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||||
->validator('Validate::numeric', array(
|
->validator(
|
||||||
|
'Validate::numeric',
|
||||||
|
array(
|
||||||
"decimal" => ',',
|
"decimal" => ',',
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal'))
|
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
->validator('Validate::notEmpty', array(
|
->validator(
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required'))
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Field::inst('precio_hora')
|
Field::inst('precio_hora')
|
||||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||||
->validator('Validate::numeric', array(
|
->validator(
|
||||||
|
'Validate::numeric',
|
||||||
|
array(
|
||||||
"decimal" => ',',
|
"decimal" => ',',
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal'))
|
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
->validator('Validate::notEmpty', array(
|
->validator(
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required'))
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Field::inst('total_min')
|
||||||
|
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||||
|
->validator(
|
||||||
|
'Validate::numeric',
|
||||||
|
array(
|
||||||
|
"decimal" => ',',
|
||||||
|
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->validator(
|
||||||
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Field::inst('margen')
|
Field::inst('margen')
|
||||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||||
->validator('Validate::numeric', array(
|
->validator(
|
||||||
|
'Validate::numeric',
|
||||||
|
array(
|
||||||
"decimal" => ',',
|
"decimal" => ',',
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal'))
|
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
->validator('Validate::notEmpty', array(
|
->validator(
|
||||||
'message' => lang('TarifaAcabadoLineas.validation.margen.required'))
|
'Validate::notEmpty',
|
||||||
|
array(
|
||||||
|
'message' => lang('TarifaAcabadoLineas.validation.margen.required')
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Field::inst('tirada_encuadernacion_id'),
|
Field::inst('tirada_encuadernacion_id'),
|
||||||
Field::inst('user_created_id'),
|
Field::inst('user_created_id'),
|
||||||
@ -317,7 +357,7 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
|||||||
|
|
||||||
$cleandatatable = $reqData['cleandatatable'] ?? 0;
|
$cleandatatable = $reqData['cleandatatable'] ?? 0;
|
||||||
|
|
||||||
if($cleandatatable){
|
if ($cleandatatable) {
|
||||||
|
|
||||||
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1;
|
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1;
|
||||||
|
|
||||||
@ -331,8 +371,7 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
|||||||
];
|
];
|
||||||
return $this->respond($data);
|
return $this->respond($data);
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
|
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
|
||||||
$errstr = 'No data available in response to this specific request.';
|
$errstr = 'No data available in response to this specific request.';
|
||||||
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
|
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
|
||||||
|
|||||||
@ -126,15 +126,6 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\BaseResourceControlle
|
|||||||
->validator('Validate::notEmpty', array(
|
->validator('Validate::notEmpty', array(
|
||||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required'))
|
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required'))
|
||||||
),
|
),
|
||||||
Field::inst('precio_min')
|
|
||||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
|
||||||
->validator('Validate::numeric', array(
|
|
||||||
"decimal" => ',',
|
|
||||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal'))
|
|
||||||
)
|
|
||||||
->validator('Validate::notEmpty', array(
|
|
||||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required'))
|
|
||||||
),
|
|
||||||
Field::inst('proveedor_id')
|
Field::inst('proveedor_id')
|
||||||
->validator('Validate::notEmpty', array(
|
->validator('Validate::notEmpty', array(
|
||||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_max.required'))
|
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_max.required'))
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Controllers\Tarifas;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controllers\Tarifas;
|
||||||
|
|
||||||
|
|
||||||
use App\Controllers\BaseResourceController;
|
use App\Controllers\BaseResourceController;
|
||||||
@ -146,7 +148,7 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$this->viewData['tarifaEncuadernacionEntity'] = isset($sanitizedData) ? new TarifaEncuadernacionEntity($sanitizedData) : new TarifaEncuadernacionEntity();
|
$this->viewData['tarifaEncuadernacionEntity'] = isset($sanitizedData) ? new TarifaEncuadernacionEntity($sanitizedData) : new TarifaEncuadernacionEntity();
|
||||||
|
|
||||||
$this->viewData['formAction'] = site_url('tarifas/tarifasencuadernacion/add');//route_to('createTarifaEncuadernacion');
|
$this->viewData['formAction'] = site_url('tarifas/tarifasencuadernacion/add'); //route_to('createTarifaEncuadernacion');
|
||||||
|
|
||||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifaencuadernacion.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifaencuadernacion.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||||
|
|
||||||
@ -335,7 +337,8 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getProveedores(){
|
private function getProveedores()
|
||||||
|
{
|
||||||
$provTipoModel = new ProveedorTipoModel();
|
$provTipoModel = new ProveedorTipoModel();
|
||||||
$provModel = new ProveedorModel();
|
$provModel = new ProveedorModel();
|
||||||
|
|
||||||
@ -343,12 +346,13 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
|||||||
return $provModel->getProvList($tipoId);
|
return $provModel->getProvList($tipoId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDimensiones(){
|
private function getDimensiones()
|
||||||
|
{
|
||||||
$dimensionModel = new TarifaEncuadernacionDimensionesModel();
|
$dimensionModel = new TarifaEncuadernacionDimensionesModel();
|
||||||
|
|
||||||
$dimensiones = $dimensionModel->getDimensiones();
|
$dimensiones = $dimensionModel->getDimensiones();
|
||||||
foreach($dimensiones as $dim){
|
foreach ($dimensiones as $dim) {
|
||||||
$dim->label= lang("TarifaEncuadernacionLineas." . $dim->label);
|
$dim->label = lang("TarifaEncuadernacionLineas." . $dim->label);
|
||||||
}
|
}
|
||||||
return $dimensiones;
|
return $dimensiones;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ class TarifaEncuadernacionLinea extends \CodeIgniter\Entity\Entity
|
|||||||
"precio_max" => 0,
|
"precio_max" => 0,
|
||||||
"tirada_min" => 0,
|
"tirada_min" => 0,
|
||||||
"tirada_max" => 0,
|
"tirada_max" => 0,
|
||||||
|
"total_min" => 0,
|
||||||
"margen" => 0,
|
"margen" => 0,
|
||||||
"user_created_id" => 0,
|
"user_created_id" => 0,
|
||||||
"user_updated_id" => 0,
|
"user_updated_id" => 0,
|
||||||
@ -31,6 +32,7 @@ class TarifaEncuadernacionLinea extends \CodeIgniter\Entity\Entity
|
|||||||
"precio_max" => "float",
|
"precio_max" => "float",
|
||||||
"tirada_min" => "float",
|
"tirada_min" => "float",
|
||||||
"tirada_max" => "float",
|
"tirada_max" => "float",
|
||||||
|
"total_min" => "float",
|
||||||
"margen" => "float",
|
"margen" => "float",
|
||||||
"user_created_id" => "int",
|
"user_created_id" => "int",
|
||||||
"user_updated_id" => "int",
|
"user_updated_id" => "int",
|
||||||
|
|||||||
@ -11,6 +11,7 @@ class TarifaEncuadernacionLineaHoras extends \CodeIgniter\Entity\Entity
|
|||||||
"tiempo_min" => 0,
|
"tiempo_min" => 0,
|
||||||
"tiempo_max" => 0,
|
"tiempo_max" => 0,
|
||||||
"precio_hora" => 0,
|
"precio_hora" => 0,
|
||||||
|
"total_min" => 0,
|
||||||
"margen" => 0,
|
"margen" => 0,
|
||||||
"user_created_id" => 0,
|
"user_created_id" => 0,
|
||||||
"user_updated_id" => 0,
|
"user_updated_id" => 0,
|
||||||
@ -22,6 +23,7 @@ class TarifaEncuadernacionLineaHoras extends \CodeIgniter\Entity\Entity
|
|||||||
"tirada_encuadernacion_id" => "int",
|
"tirada_encuadernacion_id" => "int",
|
||||||
"tiempo_min" => "float",
|
"tiempo_min" => "float",
|
||||||
"tiempo_max" => "float",
|
"tiempo_max" => "float",
|
||||||
|
"total_min" => "float",
|
||||||
"precio_hora" => "float",
|
"precio_hora" => "float",
|
||||||
"margen" => "float",
|
"margen" => "float",
|
||||||
"user_created_id" => "int",
|
"user_created_id" => "int",
|
||||||
|
|||||||
@ -11,7 +11,6 @@ class TarifaEncuadernacionTirada extends \CodeIgniter\Entity\Entity
|
|||||||
"tirada_min" => 0,
|
"tirada_min" => 0,
|
||||||
"tirada_max" => 0,
|
"tirada_max" => 0,
|
||||||
"proveedor_id" => 0,
|
"proveedor_id" => 0,
|
||||||
"precio_min" => 0,
|
|
||||||
"importe_fijo" => 0,
|
"importe_fijo" => 0,
|
||||||
"user_created_id" => 0,
|
"user_created_id" => 0,
|
||||||
"user_updated_id" => 0,
|
"user_updated_id" => 0,
|
||||||
@ -24,7 +23,6 @@ class TarifaEncuadernacionTirada extends \CodeIgniter\Entity\Entity
|
|||||||
"tirada_min" => "float",
|
"tirada_min" => "float",
|
||||||
"tirada_max" => "float",
|
"tirada_max" => "float",
|
||||||
"proveedor_id" => "int",
|
"proveedor_id" => "int",
|
||||||
"precio_min" => "float",
|
|
||||||
"importe_fijo" => "float",
|
"importe_fijo" => "float",
|
||||||
"user_created_id" => "int",
|
"user_created_id" => "int",
|
||||||
"user_updated_id" => "int",
|
"user_updated_id" => "int",
|
||||||
|
|||||||
@ -20,6 +20,10 @@ return [
|
|||||||
'menor_a5' =>'Hasta A5',
|
'menor_a5' =>'Hasta A5',
|
||||||
'entre_a5_a4' =>'Entre A5 y A4',
|
'entre_a5_a4' =>'Entre A5 y A4',
|
||||||
'mayor_a4' =>'Desde A4',
|
'mayor_a4' =>'Desde A4',
|
||||||
|
'menor_a5_apaisado' =>'Hasta A5 apaisado',
|
||||||
|
'entre_a5_a4_apaisado' =>'Entre A5 y A4 apaisado',
|
||||||
|
'mayor_a4_apaisado' =>'Desde A4 apaisado',
|
||||||
|
'210x210' =>'210x210',
|
||||||
'por_defecto' =>'Genérico',
|
'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',
|
||||||
|
|||||||
@ -199,7 +199,7 @@ class ChatModel extends Model
|
|||||||
}
|
}
|
||||||
public function getClienteChatPedidos(array $pedidos) : array
|
public function getClienteChatPedidos(array $pedidos) : array
|
||||||
{
|
{
|
||||||
$results = $this->db->table("chats")
|
$q = $this->db->table("chats")
|
||||||
->select([
|
->select([
|
||||||
"chats.id as chatId",
|
"chats.id as chatId",
|
||||||
"chats.pedido_id as pedidoId",
|
"chats.pedido_id as pedidoId",
|
||||||
@ -209,9 +209,13 @@ class ChatModel extends Model
|
|||||||
])
|
])
|
||||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||||
->join("pedidos","pedidos.id = chats.pedido_id","left")
|
->join("pedidos","pedidos.id = chats.pedido_id","left")
|
||||||
->whereIn("pedidos.id",$pedidos)
|
->where('chats.chat_department_id is NOT NULL', NULL, FALSE);
|
||||||
->where("chats.chat_department_id is NOT NULL",NULL,FALSE)
|
if(count($pedidos)>0){
|
||||||
->get()->getResultObject();
|
$q->whereIn("pedidos.id",$pedidos);
|
||||||
|
}else{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$results = $q->get()->getResultObject();
|
||||||
$chatMessageModel = model(ChatMessageModel::class);
|
$chatMessageModel = model(ChatMessageModel::class);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($results as $row) {
|
foreach ($results as $row) {
|
||||||
@ -221,13 +225,14 @@ class ChatModel extends Model
|
|||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$row->uri = "/pedidos/edit/".$row->pedidoId;
|
||||||
$row->unreadMessages=$count;
|
$row->unreadMessages=$count;
|
||||||
}
|
}
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
public function getClienteChatFacturas(array $facturas) : array
|
public function getClienteChatFacturas(array $facturas) : array
|
||||||
{
|
{
|
||||||
$results = $this->db->table("chats")
|
$q = $this->db->table("chats")
|
||||||
->select([
|
->select([
|
||||||
"chats.id as chatId",
|
"chats.id as chatId",
|
||||||
"chats.factura_id as facturaId",
|
"chats.factura_id as facturaId",
|
||||||
@ -237,9 +242,14 @@ class ChatModel extends Model
|
|||||||
])
|
])
|
||||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||||
->join("facturas","facturas.id = chats.factura_id","left")
|
->join("facturas","facturas.id = chats.factura_id","left")
|
||||||
->whereIn("facturas.id",$facturas)
|
->where('chats.chat_department_id is NOT NULL', NULL, FALSE);
|
||||||
->where("chats.chat_department_id is NOT NULL",NULL,FALSE)
|
|
||||||
->get()->getResultObject();
|
if(count($facturas)>0){
|
||||||
|
$q->whereIn("facturas.id",$facturas);
|
||||||
|
}else{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$results = $q->get()->getResultObject();
|
||||||
$chatMessageModel = model(ChatMessageModel::class);
|
$chatMessageModel = model(ChatMessageModel::class);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($results as $row) {
|
foreach ($results as $row) {
|
||||||
@ -249,13 +259,14 @@ class ChatModel extends Model
|
|||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$row->uri = "/facturas/edit/".$row->facturaId;
|
||||||
$row->unreadMessages=$count;
|
$row->unreadMessages=$count;
|
||||||
}
|
}
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
public function getClienteChatPresupuestos(array $presupuestos) : array
|
public function getClienteChatPresupuestos(array $presupuestos) : array
|
||||||
{
|
{
|
||||||
$results = $this->db->table("chats")
|
$q = $this->db->table("chats")
|
||||||
->select([
|
->select([
|
||||||
"chats.id as chatId",
|
"chats.id as chatId",
|
||||||
"chats.presupuesto_id as presupuestoId",
|
"chats.presupuesto_id as presupuestoId",
|
||||||
@ -265,9 +276,14 @@ class ChatModel extends Model
|
|||||||
])
|
])
|
||||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||||
->join("presupuestos","presupuestos.id = chats.presupuesto_id","left")
|
->join("presupuestos","presupuestos.id = chats.presupuesto_id","left")
|
||||||
->whereIn("presupuestos.id",$presupuestos)
|
->where('chats.chat_department_id is NOT NULL', NULL, FALSE);
|
||||||
->where("chats.chat_department_id is NOT NULL",NULL,FALSE)
|
|
||||||
->get()->getResultObject();
|
if(count($presupuestos)>0){
|
||||||
|
$q->whereIn("presupuestos.id",$presupuestos);
|
||||||
|
}else{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$results = $q->get()->getResultObject();
|
||||||
$chatMessageModel = model(ChatMessageModel::class);
|
$chatMessageModel = model(ChatMessageModel::class);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($results as $row) {
|
foreach ($results as $row) {
|
||||||
@ -277,6 +293,7 @@ class ChatModel extends Model
|
|||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$row->uri = "/presupuestos/presupuestocliente/edit/".$row->presupuestoId;
|
||||||
$row->unreadMessages=$count;
|
$row->unreadMessages=$count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,8 +33,8 @@ class ErrorPresupuesto extends Model
|
|||||||
protected array $castHandlers = [];
|
protected array $castHandlers = [];
|
||||||
|
|
||||||
// Dates
|
// Dates
|
||||||
protected $useTimestamps = false;
|
protected $useTimestamps = true;
|
||||||
protected $dateFormat = 'datetime';
|
//protected $dateFormat = 'datetime';
|
||||||
protected $createdField = 'created_at';
|
protected $createdField = 'created_at';
|
||||||
protected $updatedField = 'updated_at';
|
protected $updatedField = 'updated_at';
|
||||||
protected $deletedField = 'deleted_at';
|
protected $deletedField = 'deleted_at';
|
||||||
|
|||||||
@ -269,6 +269,14 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
|||||||
$precio_total += floatval($tarifa_proveedor->tarifa_importe_fijo);
|
$precio_total += floatval($tarifa_proveedor->tarifa_importe_fijo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tarifa_precio_min = floatval($tarifa_proveedor->tarifa_precio_min);
|
||||||
|
|
||||||
|
if($tarifa_precio_min > $precio_total){
|
||||||
|
$total = $total-($total * $margen/100.0);
|
||||||
|
$margen = round(100.0 * (floatval($$tarifa_precio_min) - $total) / floatval($$tarifa_precio_min), 0);
|
||||||
|
$total = floatval($$tarifa_precio_min);
|
||||||
|
}
|
||||||
|
|
||||||
$result_data[0] = floatval($precio_total / $tirada); // Precio/unidad
|
$result_data[0] = floatval($precio_total / $tirada); // Precio/unidad
|
||||||
$result_data[1] = $precio_total;
|
$result_data[1] = $precio_total;
|
||||||
$result_data[2] = $tarifa_proveedor->margen ; // margen
|
$result_data[2] = $tarifa_proveedor->margen ; // margen
|
||||||
@ -323,11 +331,12 @@ class PresupuestoEncuadernacionesModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
$total = $precio_unidad * $ejemplares;
|
$total = $precio_unidad * $ejemplares;
|
||||||
$margen = floatval($tarifa->margen);
|
$margen = floatval($tarifa->margen);
|
||||||
|
$tarifa_precio_min = floatval($tarifa->tarifa_precio_min);
|
||||||
|
|
||||||
if($tarifa->tarifa_precio_min > $total){
|
if($tarifa_precio_min > $total){
|
||||||
$total = $total-($total * $margen/100.0);
|
$total = $total-($total * $margen/100.0);
|
||||||
$margen = round(100.0 * (floatval($tarifa->tarifa_precio_min) - $total) / floatval($tarifa->tarifa_precio_min), 0);
|
$margen = round(100.0 * (floatval($tarifa_precio_min) - $total) / floatval($tarifa_precio_min), 0);
|
||||||
$total = floatval($tarifa->tarifa_precio_min);
|
$total = floatval($tarifa_precio_min);
|
||||||
$precio_unidad = round(floatval($total / $ejemplares), 2);
|
$precio_unidad = round(floatval($total / $ejemplares), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Models\Tarifas;
|
namespace App\Models\Tarifas;
|
||||||
|
|
||||||
class TarifaEncuadernacionDimensionesModel extends \App\Models\BaseModel
|
class TarifaEncuadernacionDimensionesModel extends \App\Models\BaseModel
|
||||||
@ -12,20 +13,14 @@ class TarifaEncuadernacionDimensionesModel extends \App\Models\BaseModel
|
|||||||
*/
|
*/
|
||||||
protected $useAutoIncrement = true;
|
protected $useAutoIncrement = true;
|
||||||
|
|
||||||
protected $allowedFields = [
|
protected $allowedFields = [];
|
||||||
|
|
||||||
];
|
|
||||||
protected $returnType = "App\Entities\Tarifas\TarifaEncuadernacionDimensionesEntity";
|
protected $returnType = "App\Entities\Tarifas\TarifaEncuadernacionDimensionesEntity";
|
||||||
|
|
||||||
public static $labelField = "descripcion";
|
public static $labelField = "descripcion";
|
||||||
|
|
||||||
protected $validationRules = [
|
protected $validationRules = [];
|
||||||
|
|
||||||
];
|
protected $validationMessages = [];
|
||||||
|
|
||||||
protected $validationMessages = [
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get resource data.
|
* Get resource data.
|
||||||
@ -34,13 +29,32 @@ class TarifaEncuadernacionDimensionesModel extends \App\Models\BaseModel
|
|||||||
*
|
*
|
||||||
* @return \CodeIgniter\Database\BaseBuilder
|
* @return \CodeIgniter\Database\BaseBuilder
|
||||||
*/
|
*/
|
||||||
public function getDimensiones(){
|
public function getDimensiones()
|
||||||
|
{
|
||||||
|
|
||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select("t1.id AS value, t1.keyword AS label")
|
->select("t1.id AS value, t1.keyword AS label")
|
||||||
->orderBy('t1.id', 'asc');
|
->orderBy('t1.id', 'asc');
|
||||||
|
|
||||||
return $builder->get()->getResultObject();
|
$result = $builder->get()->getResultObject();
|
||||||
|
|
||||||
|
// Convertir el resultado en un array
|
||||||
|
$resultArray = json_decode(json_encode($result), true);
|
||||||
|
|
||||||
|
// Buscar y mover el objeto con value == 3 al principio
|
||||||
|
foreach ($resultArray as $key => $item) {
|
||||||
|
if ($item['value'] == 4) {
|
||||||
|
$generico = $item;
|
||||||
|
unset($resultArray[$key]);
|
||||||
|
array_unshift($resultArray, $generico);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convertir de nuevo a objetos
|
||||||
|
$result = json_decode(json_encode($resultArray));
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,8 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel
|
|||||||
1 => "t1.tiempo_min",
|
1 => "t1.tiempo_min",
|
||||||
2 => "t1.tiempo_max",
|
2 => "t1.tiempo_max",
|
||||||
3 => "t1.precio_hora",
|
3 => "t1.precio_hora",
|
||||||
4 => "t1.margen",
|
4 => "t1.total_min",
|
||||||
|
5 => "t1.margen",
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $allowedFields = [
|
protected $allowedFields = [
|
||||||
@ -25,6 +26,7 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel
|
|||||||
"tiempo_min",
|
"tiempo_min",
|
||||||
"tiempo_max",
|
"tiempo_max",
|
||||||
"precio_hora",
|
"precio_hora",
|
||||||
|
"total_min",
|
||||||
"margen",
|
"margen",
|
||||||
"user_created_id",
|
"user_created_id",
|
||||||
"is_deleted",
|
"is_deleted",
|
||||||
@ -54,6 +56,10 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel
|
|||||||
"label" => "TarifaEncuadernacionLineas.precioHora",
|
"label" => "TarifaEncuadernacionLineas.precioHora",
|
||||||
"rules" => "required|decimal",
|
"rules" => "required|decimal",
|
||||||
],
|
],
|
||||||
|
"total_min" => [
|
||||||
|
"label" => "TarifaEncuadernacionLineas.precioHora",
|
||||||
|
"rules" => "required|decimal",
|
||||||
|
],
|
||||||
"margen" => [
|
"margen" => [
|
||||||
"label" => "TarifaEncuadernacionLineas.margen",
|
"label" => "TarifaEncuadernacionLineas.margen",
|
||||||
"rules" => "required|decimal",
|
"rules" => "required|decimal",
|
||||||
@ -73,6 +79,10 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel
|
|||||||
"decimal" => "TarifaEncuadernacionLineas.validation.tirada_max.decimal",
|
"decimal" => "TarifaEncuadernacionLineas.validation.tirada_max.decimal",
|
||||||
"required" => "TarifaEncuadernacionLineas.validation.tirada_max.required",
|
"required" => "TarifaEncuadernacionLineas.validation.tirada_max.required",
|
||||||
],
|
],
|
||||||
|
"total_min" => [
|
||||||
|
"decimal" => "TarifaEncuadernacionLineas.validation.tirada_max.decimal",
|
||||||
|
"required" => "TarifaEncuadernacionLineas.validation.tirada_max.required",
|
||||||
|
],
|
||||||
"margen" => [
|
"margen" => [
|
||||||
"decimal" => "TarifaEncuadernacionLineas.validation.margen.decimal",
|
"decimal" => "TarifaEncuadernacionLineas.validation.margen.decimal",
|
||||||
"required" => "TarifaEncuadernacionLineas.validation.margen.required",
|
"required" => "TarifaEncuadernacionLineas.validation.margen.required",
|
||||||
@ -92,7 +102,7 @@ class TarifaEncuadernacionLineaHorasModel extends \App\Models\BaseModel
|
|||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS id, t1.tirada_encuadernacion_id AS tirada_encuadernacion_id, t1.tiempo_min AS tiempo_min,
|
"t1.id AS id, t1.tirada_encuadernacion_id AS tirada_encuadernacion_id, t1.tiempo_min AS tiempo_min,
|
||||||
t1.tiempo_max AS tiempo_max, t1.precio_hora AS precio_hora, t1.margen AS margen,
|
t1.tiempo_max AS tiempo_max, t1.precio_hora AS precio_hora, t1.total_min AS total_min, t1.margen AS margen,
|
||||||
t2.id AS tarifa_encuadernacion"
|
t2.id AS tarifa_encuadernacion"
|
||||||
);
|
);
|
||||||
//JJO
|
//JJO
|
||||||
|
|||||||
@ -19,6 +19,8 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel
|
|||||||
3 => "t1.paginas_libro_max",
|
3 => "t1.paginas_libro_max",
|
||||||
4 => "t1.precio_min",
|
4 => "t1.precio_min",
|
||||||
5 => "t1.precio_max",
|
5 => "t1.precio_max",
|
||||||
|
6 => "t1.total_min",
|
||||||
|
7 => "t1.margen",
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $allowedFields = [
|
protected $allowedFields = [
|
||||||
@ -30,6 +32,8 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel
|
|||||||
"precio_max",
|
"precio_max",
|
||||||
"tirada_min",
|
"tirada_min",
|
||||||
"tirada_max",
|
"tirada_max",
|
||||||
|
"margen",
|
||||||
|
"total_min",
|
||||||
"user_created_id",
|
"user_created_id",
|
||||||
"is_deleted",
|
"is_deleted",
|
||||||
|
|
||||||
@ -62,6 +66,10 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel
|
|||||||
"label" => "TarifaEncuadernacionLineas.tiradaMin",
|
"label" => "TarifaEncuadernacionLineas.tiradaMin",
|
||||||
"rules" => "required|decimal",
|
"rules" => "required|decimal",
|
||||||
],
|
],
|
||||||
|
"total_min" => [
|
||||||
|
"label" => "TarifaEncuadernacionLineas.precioMin",
|
||||||
|
"rules" => "required|decimal",
|
||||||
|
],
|
||||||
"paginas_libro_max" => [
|
"paginas_libro_max" => [
|
||||||
"label" => "TarifaEncuadernacionLineas.paginasMax",
|
"label" => "TarifaEncuadernacionLineas.paginasMax",
|
||||||
"rules" => "required|decimal",
|
"rules" => "required|decimal",
|
||||||
@ -93,6 +101,10 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel
|
|||||||
"decimal" => "TarifaEncuadernacionLineas.validation.tirada_min.decimal",
|
"decimal" => "TarifaEncuadernacionLineas.validation.tirada_min.decimal",
|
||||||
"required" => "TarifaEncuadernacionLineas.validation.tirada_min.required",
|
"required" => "TarifaEncuadernacionLineas.validation.tirada_min.required",
|
||||||
],
|
],
|
||||||
|
"total_min" => [
|
||||||
|
"decimal" => "TarifaEncuadernacionLineas.validation.precio_min.decimal",
|
||||||
|
"required" => "TarifaEncuadernacionLineas.validation.precio_min.required",
|
||||||
|
],
|
||||||
"paginas_libro_max" => [
|
"paginas_libro_max" => [
|
||||||
"decimal" => "TarifaEncuadernacionLineas.validation.paginas_libro_max.decimal",
|
"decimal" => "TarifaEncuadernacionLineas.validation.paginas_libro_max.decimal",
|
||||||
"required" => "TarifaEncuadernacionLineas.validation.paginas_libro_max.required",
|
"required" => "TarifaEncuadernacionLineas.validation.paginas_libro_max.required",
|
||||||
@ -120,7 +132,7 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel
|
|||||||
->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.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, t3.descripcion as descripcion"
|
t1.tirada_max AS tirada_max, t1.total_min as total_min, 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, t3.descripcion as descripcion"
|
||||||
);
|
);
|
||||||
//JJO
|
//JJO
|
||||||
$builder->where('tirada_encuadernacion_id', $tirada_encuadernacion_id);
|
$builder->where('tirada_encuadernacion_id', $tirada_encuadernacion_id);
|
||||||
@ -191,6 +203,7 @@ class TarifaEncuadernacionLineaModel extends \App\Models\BaseModel
|
|||||||
return $builder;
|
return $builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function removeAllEncuadernacionLineasForTarifa($tarifaId = -1, $datetime = null, $delete_flag=1){
|
public function removeAllEncuadernacionLineasForTarifa($tarifaId = -1, $datetime = null, $delete_flag=1){
|
||||||
|
|
||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
|
|||||||
@ -125,7 +125,7 @@ class TarifaEncuadernacionModel extends \App\Models\BaseModel
|
|||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t2.precio_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo,
|
"t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t3.total_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo,
|
||||||
t2.id AS tarifa_tirada_id, t2.proveedor_id AS proveedor_id, t5.nombre AS proveedor_nombre, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max,
|
t2.id AS tarifa_tirada_id, t2.proveedor_id AS proveedor_id, t5.nombre AS proveedor_nombre, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max,
|
||||||
t3.id AS tarifa_linea_id, t3.paginas_libro_min AS paginas_min, t3.paginas_libro_max AS paginas_max, t3.precio_min AS precio_min, t3.precio_max AS precio_max, t3.margen AS margen,
|
t3.id AS tarifa_linea_id, t3.paginas_libro_min AS paginas_min, t3.paginas_libro_max AS paginas_max, t3.precio_min AS precio_min, t3.precio_max AS precio_max, t3.margen AS margen,
|
||||||
t4.ancho_min AS ancho_min, t4.ancho_max AS ancho_max, t4.alto_min AS alto_min, t4.alto_max AS alto_max"
|
t4.ancho_min AS ancho_min, t4.ancho_max AS ancho_max, t4.alto_min AS alto_min, t4.alto_max AS alto_max"
|
||||||
@ -161,7 +161,7 @@ class TarifaEncuadernacionModel extends \App\Models\BaseModel
|
|||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t2.precio_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo,
|
"t1.id AS tarifa_enc_id, t1.nombre AS tarifa_enc_nombre, t3.total_min AS tarifa_precio_min, t2.importe_fijo AS tarifa_importe_fijo,
|
||||||
t2.id AS tarifa_tirada_id, t2.proveedor_id AS proveedor_id, t5.nombre AS proveedor_nombre, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max,
|
t2.id AS tarifa_tirada_id, t2.proveedor_id AS proveedor_id, t5.nombre AS proveedor_nombre, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max,
|
||||||
t3.id AS tarifa_linea_id, t3.tiempo_min AS tiempo_min, t3.tiempo_max AS tiempo_max, t3.precio_hora AS precio_hora, t3.margen AS margen"
|
t3.id AS tarifa_linea_id, t3.tiempo_min AS tiempo_min, t3.tiempo_max AS tiempo_max, t3.precio_hora AS precio_hora, t3.margen AS margen"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -16,7 +16,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel
|
|||||||
0 => "t3.nombre",
|
0 => "t3.nombre",
|
||||||
1 => "t1.tirada_min",
|
1 => "t1.tirada_min",
|
||||||
2 => "t1.tirada_max",
|
2 => "t1.tirada_max",
|
||||||
3 => "t1.precio_min",
|
|
||||||
4 => "t1.importe_fijo",
|
4 => "t1.importe_fijo",
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -25,7 +24,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel
|
|||||||
"tirada_min",
|
"tirada_min",
|
||||||
"tirada_max",
|
"tirada_max",
|
||||||
"proveedor_id",
|
"proveedor_id",
|
||||||
"precio_min",
|
|
||||||
"importe_fijo",
|
"importe_fijo",
|
||||||
"user_created_id",
|
"user_created_id",
|
||||||
"user_updated_id",
|
"user_updated_id",
|
||||||
@ -53,10 +51,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel
|
|||||||
"label" => "TarifaEncuadernacionTiradas.tiradaMin",
|
"label" => "TarifaEncuadernacionTiradas.tiradaMin",
|
||||||
"rules" => "required|integer",
|
"rules" => "required|integer",
|
||||||
],
|
],
|
||||||
"precio_min" => [
|
|
||||||
"label" => "Tarifaencuadernacion.precioMin",
|
|
||||||
"rules" => "required|decimal",
|
|
||||||
],
|
|
||||||
"importe_fijo" => [
|
"importe_fijo" => [
|
||||||
"label" => "Tarifaencuadernacion.importeFijo",
|
"label" => "Tarifaencuadernacion.importeFijo",
|
||||||
"rules" => "required|decimal",
|
"rules" => "required|decimal",
|
||||||
@ -72,10 +66,6 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel
|
|||||||
"integer" => "TarifaEncuadernacionTiradas.validation.tirada_min.integer",
|
"integer" => "TarifaEncuadernacionTiradas.validation.tirada_min.integer",
|
||||||
"required" => "TarifaEncuadernacionTiradas.validation.tirada_min.required",
|
"required" => "TarifaEncuadernacionTiradas.validation.tirada_min.required",
|
||||||
],
|
],
|
||||||
"precio_min" => [
|
|
||||||
"required" => "Tarifaencuadernacion.validation.precio_min.required",
|
|
||||||
"decimal" => "Tarifaencuadernacion.validation.precio_min.decimal",
|
|
||||||
],
|
|
||||||
"importe_fijo" => [
|
"importe_fijo" => [
|
||||||
"required" => "Tarifaencuadernacion.validation.importe_fijo.required",
|
"required" => "Tarifaencuadernacion.validation.importe_fijo.required",
|
||||||
"decimal" => "Tarifaencuadernacion.validation.importe_fijo.decimal",
|
"decimal" => "Tarifaencuadernacion.validation.importe_fijo.decimal",
|
||||||
@ -95,7 +85,7 @@ class TarifaEncuadernacionTiradaModel extends \App\Models\BaseModel
|
|||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS id, t1.tarifa_encuadernacion_id AS tarifa_encuadernacion_id,
|
"t1.id AS id, t1.tarifa_encuadernacion_id AS tarifa_encuadernacion_id,
|
||||||
t1.precio_min AS precio_min, t1.importe_fijo AS importe_fijo,
|
t1.importe_fijo AS importe_fijo,
|
||||||
t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max,
|
t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max,
|
||||||
t3.nombre AS proveedor, t3.id AS proveedor_id, t2.id AS tarifa_encuadernacion"
|
t3.nombre AS proveedor, t3.id AS proveedor_id, t2.id AS tarifa_encuadernacion"
|
||||||
);
|
);
|
||||||
|
|||||||
@ -52,10 +52,10 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
|
|
||||||
if ($maquina->is_inkjet) {
|
if ($maquina->is_inkjet) {
|
||||||
$parametrosInkjet = (object)array(
|
$parametrosInkjet = (object) array(
|
||||||
'a_favor_fibra' => $a_favor_fibra, // este parametro se cambia para comprobar
|
'a_favor_fibra' => $a_favor_fibra, // este parametro se cambia para comprobar
|
||||||
// en las dos direcciones (menos en rustica fresada que es siempre 1)
|
// en las dos direcciones (menos en rustica fresada que es siempre 1)
|
||||||
'bnPages' => $isColor ? 0 : $datosPedido->paginas,
|
'bnPages' => $isColor ? 0 : $datosPedido->paginas,
|
||||||
'colorPages' => ($uso == 'guardas') ? $datosPedido->paginas_impresion : ($isColor ? $datosPedido->paginas : 0),
|
'colorPages' => ($uso == 'guardas') ? $datosPedido->paginas_impresion : ($isColor ? $datosPedido->paginas : 0),
|
||||||
'rotativa_gota_negro' => 0,
|
'rotativa_gota_negro' => 0,
|
||||||
'rotativa_gota_color' => 0,
|
'rotativa_gota_color' => 0,
|
||||||
@ -74,13 +74,13 @@ class PresupuestoService extends BaseService
|
|||||||
} else {
|
} else {
|
||||||
$datosTipologias = $datosTipolog;
|
$datosTipologias = $datosTipolog;
|
||||||
}
|
}
|
||||||
$parametrosInkjet->rotativa_gota_negro = $datosTipologias[0]->gota_negro;
|
$parametrosInkjet->rotativa_gota_negro = $datosTipologias[0]->gota_negro;
|
||||||
$parametrosInkjet->rotativa_gota_color = $datosTipologias[0]->gota_color;
|
$parametrosInkjet->rotativa_gota_color = $datosTipologias[0]->gota_color;
|
||||||
$parametrosInkjet->rotativa_negro = $datosTipologias[0]->negro;
|
$parametrosInkjet->rotativa_negro = $datosTipologias[0]->negro;
|
||||||
$parametrosInkjet->rotativa_cyan = $datosTipologias[0]->cyan;
|
$parametrosInkjet->rotativa_cyan = $datosTipologias[0]->cyan;
|
||||||
$parametrosInkjet->rotativa_magenta = $datosTipologias[0]->magenta;
|
$parametrosInkjet->rotativa_magenta = $datosTipologias[0]->magenta;
|
||||||
$parametrosInkjet->rotativa_amarillo = $datosTipologias[0]->amarillo;
|
$parametrosInkjet->rotativa_amarillo = $datosTipologias[0]->amarillo;
|
||||||
$parametrosInkjet->rotativa_cg = $datosTipologias[0]->cg;
|
$parametrosInkjet->rotativa_cg = $datosTipologias[0]->cg;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tarifamodel = new \App\Models\Configuracion\MaquinasTarifasImpresionModel();
|
$tarifamodel = new \App\Models\Configuracion\MaquinasTarifasImpresionModel();
|
||||||
@ -127,7 +127,7 @@ class PresupuestoService extends BaseService
|
|||||||
);
|
);
|
||||||
|
|
||||||
$clientePreciosModel = new \App\Models\Clientes\ClientePreciosModel();
|
$clientePreciosModel = new \App\Models\Clientes\ClientePreciosModel();
|
||||||
$config = (object)[
|
$config = (object) [
|
||||||
"tipo" => ($uso == 'guardas') ? 'interior' : $uso,
|
"tipo" => ($uso == 'guardas') ? 'interior' : $uso,
|
||||||
"tipo_maquina" => $maquina->is_inkjet ? 'inkjet' : 'toner',
|
"tipo_maquina" => $maquina->is_inkjet ? 'inkjet' : 'toner',
|
||||||
"tipo_impresion" => $tipo
|
"tipo_impresion" => $tipo
|
||||||
@ -137,7 +137,7 @@ class PresupuestoService extends BaseService
|
|||||||
$linea['fields']['precio_click'],
|
$linea['fields']['precio_click'],
|
||||||
$maquina->velocidad
|
$maquina->velocidad
|
||||||
);
|
);
|
||||||
[$precio_hora, $margen_precio_hora] = $clientePreciosModel->get_precio_hora($cliente_id, $config, $tiempo);
|
[$precio_hora, $margen_precio_hora] = $clientePreciosModel->get_precio_hora($cliente_id, $config, $tiempo);
|
||||||
|
|
||||||
|
|
||||||
if (is_null($precio_hora)) {
|
if (is_null($precio_hora)) {
|
||||||
@ -209,7 +209,7 @@ class PresupuestoService extends BaseService
|
|||||||
$tarifamodel = new MaquinasTarifasImpresionModel();
|
$tarifamodel = new MaquinasTarifasImpresionModel();
|
||||||
|
|
||||||
$resultado_tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo) ? 'color' : $tipo);
|
$resultado_tarifa = $tarifamodel->getTarifa($maquina->maquina_id, $uso, is_array($tipo) ? 'color' : $tipo);
|
||||||
if($resultado_tarifa == null){
|
if ($resultado_tarifa == null) {
|
||||||
/*
|
/*
|
||||||
$info = [
|
$info = [
|
||||||
'maquina_id' => $maquina->maquina_id,
|
'maquina_id' => $maquina->maquina_id,
|
||||||
@ -219,8 +219,7 @@ class PresupuestoService extends BaseService
|
|||||||
log_message("error","No se ha encontrado tarifa para la maquina {maquina_id} y el uso {uso} y el tipo {tipo}", $info);
|
log_message("error","No se ha encontrado tarifa para la maquina {maquina_id} y el uso {uso} y el tipo {tipo}", $info);
|
||||||
*/
|
*/
|
||||||
return [];
|
return [];
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$tarifaId = $resultado_tarifa[0];
|
$tarifaId = $resultado_tarifa[0];
|
||||||
$tarifa = $resultado_tarifa[1];
|
$tarifa = $resultado_tarifa[1];
|
||||||
$tarifa_margen = $resultado_tarifa[2];
|
$tarifa_margen = $resultado_tarifa[2];
|
||||||
@ -231,8 +230,8 @@ class PresupuestoService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// precio del pliego de impresion
|
// precio del pliego de impresion
|
||||||
$linea['fields'] = PresupuestoService::getCostesLineaRotativa($maquina, $papel, $datosPedido, $parametrosRotativa);
|
$linea['fields'] = PresupuestoService::getCostesLineaRotativa($maquina, $papel, $datosPedido, $parametrosRotativa);
|
||||||
if(count($linea['fields']) == 0){
|
if (count($linea['fields']) == 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +244,8 @@ class PresupuestoService extends BaseService
|
|||||||
$linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $linea['fields']['precios_pliegos'];
|
$linea['fields']['precio_libro'] = $linea['fields']['pliegos_libro'] * $linea['fields']['precios_pliegos'];
|
||||||
// Precio papel pedido
|
// Precio papel pedido
|
||||||
$linea['fields']['precio_pedido'] = $linea['fields']['precio_libro'] * ($datosPedido->tirada + $datosPedido->merma);
|
$linea['fields']['precio_pedido'] = $linea['fields']['precio_libro'] * ($datosPedido->tirada + $datosPedido->merma);
|
||||||
$linea['fields']['margen_papel_pedido'] = $linea['fields']['pliegos_libro'] * $margen_pliego_impresion * ($datosPedido->tirada + $datosPedido->merma);;
|
$linea['fields']['margen_papel_pedido'] = $linea['fields']['pliegos_libro'] * $margen_pliego_impresion * ($datosPedido->tirada + $datosPedido->merma);
|
||||||
|
;
|
||||||
|
|
||||||
$linea['fields']['a_favor_fibra'] = $parametrosRotativa->a_favor_fibra;
|
$linea['fields']['a_favor_fibra'] = $parametrosRotativa->a_favor_fibra;
|
||||||
$linea['fields']['maquina'] = $maquina->maquina;
|
$linea['fields']['maquina'] = $maquina->maquina;
|
||||||
@ -267,7 +267,7 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
|
|
||||||
$linea['fields']['datosTipologias'] = //$datosTipologias[0];
|
$linea['fields']['datosTipologias'] = //$datosTipologias[0];
|
||||||
(Object)array(
|
(Object) array(
|
||||||
'gota_negro' => $parametrosRotativa->rotativa_gota_negro,
|
'gota_negro' => $parametrosRotativa->rotativa_gota_negro,
|
||||||
'gota_color' => $parametrosRotativa->rotativa_gota_color,
|
'gota_color' => $parametrosRotativa->rotativa_gota_color,
|
||||||
'negro' => $parametrosRotativa->rotativa_negro,
|
'negro' => $parametrosRotativa->rotativa_negro,
|
||||||
@ -290,7 +290,7 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
|
|
||||||
$clientePreciosModel = new ClientePreciosModel();
|
$clientePreciosModel = new ClientePreciosModel();
|
||||||
$config = (object)[
|
$config = (object) [
|
||||||
"tipo" => $uso,
|
"tipo" => $uso,
|
||||||
"tipo_maquina" => 'inkjet',
|
"tipo_maquina" => 'inkjet',
|
||||||
"tipo_impresion" => $tipo
|
"tipo_impresion" => $tipo
|
||||||
@ -300,7 +300,7 @@ class PresupuestoService extends BaseService
|
|||||||
$linea['fields']['precio_click'],
|
$linea['fields']['precio_click'],
|
||||||
$maquina->velocidad
|
$maquina->velocidad
|
||||||
);
|
);
|
||||||
[$precio_hora, $margen_precio_hora] = $clientePreciosModel->get_precio_hora($cliente_id, $config, $tiempo);
|
[$precio_hora, $margen_precio_hora] = $clientePreciosModel->get_precio_hora($cliente_id, $config, $tiempo);
|
||||||
|
|
||||||
if (is_null($precio_hora)) {
|
if (is_null($precio_hora)) {
|
||||||
return [];
|
return [];
|
||||||
@ -335,7 +335,7 @@ class PresupuestoService extends BaseService
|
|||||||
$ancho_calculo = ($uso == 'cubierta' || $uso == 'sobrecubierta') ? $datosPedido->anchoExteriores : $datosPedido->ancho;
|
$ancho_calculo = ($uso == 'cubierta' || $uso == 'sobrecubierta') ? $datosPedido->anchoExteriores : $datosPedido->ancho;
|
||||||
$alto_calculo = ($uso == 'cubierta' || $uso == 'sobrecubierta') ? $datosPedido->altoExteriores : $datosPedido->alto;
|
$alto_calculo = ($uso == 'cubierta' || $uso == 'sobrecubierta') ? $datosPedido->altoExteriores : $datosPedido->alto;
|
||||||
$formas = PresupuestoService::getNumFormasPlana($uso, $maquina, $ancho_calculo, $alto_calculo, $datosPedido->isCosido, $forzar_a_favor_fibra);
|
$formas = PresupuestoService::getNumFormasPlana($uso, $maquina, $ancho_calculo, $alto_calculo, $datosPedido->isCosido, $forzar_a_favor_fibra);
|
||||||
$response['fields'] = $formas;
|
$response['fields'] = $formas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -358,8 +358,8 @@ class PresupuestoService extends BaseService
|
|||||||
$rotativa = array_key_exists('rotativa', $opciones_papel) ? $opciones_papel['rotativa'] : 0;
|
$rotativa = array_key_exists('rotativa', $opciones_papel) ? $opciones_papel['rotativa'] : 0;
|
||||||
|
|
||||||
|
|
||||||
$precio_click = $tarifa * (1 + $tarifa_margen / 100.0);
|
$precio_click = $tarifa * (1 + $tarifa_margen / 100.0);
|
||||||
$margen_click = $tarifa * ($tarifa_margen / 100.0);
|
$margen_click = $tarifa * ($tarifa_margen / 100.0);
|
||||||
|
|
||||||
//interior (bn o color)
|
//interior (bn o color)
|
||||||
if ($cubierta == 0 && $sobrecubierta == 0 && $rotativa == 0) {
|
if ($cubierta == 0 && $sobrecubierta == 0 && $rotativa == 0) {
|
||||||
@ -466,7 +466,7 @@ class PresupuestoService extends BaseService
|
|||||||
$factor_altura = round($maquina->alto_impresion / ($data['alto'] + self::MARGEN_PAGINAS_ROTATIVA), 2);
|
$factor_altura = round($maquina->alto_impresion / ($data['alto'] + self::MARGEN_PAGINAS_ROTATIVA), 2);
|
||||||
$factor_altura_click = round($maquina->alto_click / ($data['alto'] + self::MARGEN_PAGINAS_ROTATIVA), 2);
|
$factor_altura_click = round($maquina->alto_click / ($data['alto'] + self::MARGEN_PAGINAS_ROTATIVA), 2);
|
||||||
|
|
||||||
if(floor($factor_anchura) == 0){
|
if (floor($factor_anchura) == 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,7 +566,7 @@ class PresupuestoService extends BaseService
|
|||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
$data['pulgada'] = 1 / 1000000000000.0;
|
$data['pulgada'] = 1 / 1000000000000.0;
|
||||||
if($maquina->maquina_id == 91 || $maquina->maquina_id == 99 || $maquina->maquina_id == 114 || $maquina->maquina_id == 98)
|
if ($maquina->maquina_id == 91 || $maquina->maquina_id == 99 || $maquina->maquina_id == 114 || $maquina->maquina_id == 98)
|
||||||
$data['resolucion'] = 1200;
|
$data['resolucion'] = 1200;
|
||||||
else
|
else
|
||||||
$data['resolucion'] = 600;
|
$data['resolucion'] = 600;
|
||||||
@ -599,9 +599,9 @@ class PresupuestoService extends BaseService
|
|||||||
// precio tinta
|
// precio tinta
|
||||||
$data['precio_tinta'] = round(
|
$data['precio_tinta'] = round(
|
||||||
round(($data['peso_gotas_negro_pedido'] / 1000.0) * $maquina->precio_tinta_negro, 2) +
|
round(($data['peso_gotas_negro_pedido'] / 1000.0) * $maquina->precio_tinta_negro, 2) +
|
||||||
round(($data['peso_gotas_cyan_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2) +
|
round(($data['peso_gotas_cyan_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2) +
|
||||||
round(($data['peso_gotas_magenta_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2) +
|
round(($data['peso_gotas_magenta_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2) +
|
||||||
round(($data['peso_gotas_amarillo_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2),
|
round(($data['peso_gotas_amarillo_pedido'] / 1000.0) * $maquina->precio_tinta_color, 2),
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -842,7 +842,7 @@ class PresupuestoService extends BaseService
|
|||||||
{
|
{
|
||||||
$ancho_total = 0;
|
$ancho_total = 0;
|
||||||
$sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA;
|
$sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA;
|
||||||
if($datosPedido->ancho > 210 || $datosPedido->alto > 297){
|
if ($datosPedido->ancho >= 210) {
|
||||||
$sangre_cubierta = 15;
|
$sangre_cubierta = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -865,9 +865,9 @@ class PresupuestoService extends BaseService
|
|||||||
// si es cubierta
|
// si es cubierta
|
||||||
// se añade 7mm del ancho del cartón (2*3.5mm) por cada lado del lomo
|
// se añade 7mm del ancho del cartón (2*3.5mm) por cada lado del lomo
|
||||||
// más 7mm de vuelo+cajo por cada lado. Por último, 20mm de sangre por cada lado
|
// más 7mm de vuelo+cajo por cada lado. Por último, 20mm de sangre por cada lado
|
||||||
if ($uso == "cubierta"){
|
if ($uso == "cubierta") {
|
||||||
$ancho_total += (2 * 7 + 2 * $sangre_cubierta + 6);
|
$ancho_total += (2 * 7 + 2 * $sangre_cubierta + 6);
|
||||||
if($lomoRedondo){
|
if ($lomoRedondo) {
|
||||||
$ancho_total += 6;
|
$ancho_total += 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -878,8 +878,10 @@ class PresupuestoService extends BaseService
|
|||||||
$ancho_total += (2 * 7 + 2 * self::SANGRE_FORMAS) + 7;
|
$ancho_total += (2 * 7 + 2 * self::SANGRE_FORMAS) + 7;
|
||||||
}
|
}
|
||||||
// Wire-o y espiral (tapa blanda y tapa dura)
|
// Wire-o y espiral (tapa blanda y tapa dura)
|
||||||
else if ($tipo_impresion_id == 5 || $tipo_impresion_id == 6 ||
|
else if (
|
||||||
$tipo_impresion_id == 7 || $tipo_impresion_id == 8) {
|
$tipo_impresion_id == 5 || $tipo_impresion_id == 6 ||
|
||||||
|
$tipo_impresion_id == 7 || $tipo_impresion_id == 8
|
||||||
|
) {
|
||||||
// En este caso, la cubierta se imprime como dos formas separadas, pero hay que dejar un
|
// En este caso, la cubierta se imprime como dos formas separadas, pero hay que dejar un
|
||||||
// espacio entre ellas para poder cortarlas
|
// espacio entre ellas para poder cortarlas
|
||||||
$calles = (new \App\Models\Configuracion\MaquinasCallesModel())->getCallesForMaquina($maquina_id, 2);
|
$calles = (new \App\Models\Configuracion\MaquinasCallesModel())->getCallesForMaquina($maquina_id, 2);
|
||||||
@ -889,7 +891,7 @@ class PresupuestoService extends BaseService
|
|||||||
$ancho_total += $calles[0]->internas;
|
$ancho_total += $calles[0]->internas;
|
||||||
|
|
||||||
// Tapa blanda
|
// Tapa blanda
|
||||||
if($tipo_impresion_id == 7 || $tipo_impresion_id == 8){
|
if ($tipo_impresion_id == 7 || $tipo_impresion_id == 8) {
|
||||||
// añadimos ancho de las solapas
|
// añadimos ancho de las solapas
|
||||||
// si se añaden solapas hay que sumar 3mm de los dobleces
|
// si se añaden solapas hay que sumar 3mm de los dobleces
|
||||||
if ($datosPedido->solapas) {
|
if ($datosPedido->solapas) {
|
||||||
@ -900,12 +902,11 @@ class PresupuestoService extends BaseService
|
|||||||
$ancho_total += (4 * self::SANGRE_FORMAS);
|
$ancho_total += (4 * self::SANGRE_FORMAS);
|
||||||
}
|
}
|
||||||
// Tapa dura
|
// Tapa dura
|
||||||
else{
|
else {
|
||||||
// Se le suma 20mm de sangre por cada lado. Como son 2 hojas independientes, se multiplica por 4
|
// Se le suma 20mm de sangre por cada lado. Como son 2 hojas independientes, se multiplica por 4
|
||||||
$ancho_total += (4 * $sangre_cubierta);
|
$ancho_total += (4 * $sangre_cubierta);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// En cualquier otro caso se le suma 5mm de sangre por cada lado
|
// En cualquier otro caso se le suma 5mm de sangre por cada lado
|
||||||
$ancho_total += (2 * self::SANGRE_FORMAS);
|
$ancho_total += (2 * self::SANGRE_FORMAS);
|
||||||
}
|
}
|
||||||
@ -922,11 +923,15 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
if ($datosPedido) {
|
if ($datosPedido) {
|
||||||
$alto_total = floatval($datosPedido->alto);
|
$alto_total = floatval($datosPedido->alto);
|
||||||
|
$sangre_cubierta = self::SANGRE_FORMAS_CUBIERTA;
|
||||||
|
if ($datosPedido->alto >= 297) {
|
||||||
|
$sangre_cubierta = 15;
|
||||||
|
}
|
||||||
// Tapa dura (cosido y fresado)
|
// Tapa dura (cosido y fresado)
|
||||||
if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) {
|
if ($tipo_impresion_id == 1 || $tipo_impresion_id == 3) {
|
||||||
// Se añaden 20mm de sangre por cada lado + 3.5mm extra por cada lado de vuelo
|
// Se añaden 20mm de sangre por cada lado + 3.5mm extra por cada lado de vuelo
|
||||||
if ($uso == "cubierta")
|
if ($uso == "cubierta")
|
||||||
$alto_total += (2*3.5 + 2 * self::SANGRE_FORMAS_CUBIERTA);
|
$alto_total += (2 * 3.5 + 2 * $sangre_cubierta);
|
||||||
// si es sobrecubierta
|
// si es sobrecubierta
|
||||||
// Se añaden 5mm de sangre por cada lado + 7mm de vuelo
|
// Se añaden 5mm de sangre por cada lado + 7mm de vuelo
|
||||||
else
|
else
|
||||||
@ -1019,13 +1024,11 @@ class PresupuestoService extends BaseService
|
|||||||
// Si el papel o la máquina no existen, se utiliza la más barata del comparador
|
// Si el papel o la máquina no existen, se utiliza la más barata del comparador
|
||||||
if (!PresupuestoService::checkMaquina($linea->maquina_id) || !PresupuestoService::checkPapelImpresion($linea->papel_impresion_id)) {
|
if (!PresupuestoService::checkMaquina($linea->maquina_id) || !PresupuestoService::checkPapelImpresion($linea->papel_impresion_id)) {
|
||||||
|
|
||||||
if(($input_data['presupuesto'])->papel_formato_personalizado == 0){
|
if (($input_data['presupuesto'])->papel_formato_personalizado == 0) {
|
||||||
$papel_formato = (new PapelFormatoModel())->find(($input_data['presupuesto'])->papel_formato_id);
|
$papel_formato = (new PapelFormatoModel())->find(($input_data['presupuesto'])->papel_formato_id);
|
||||||
$ancho = $papel_formato->ancho;
|
$ancho = $papel_formato->ancho;
|
||||||
$alto = $papel_formato->alto;
|
$alto = $papel_formato->alto;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$ancho = ($input_data['presupuesto'])->papel_formato_ancho;
|
$ancho = ($input_data['presupuesto'])->papel_formato_ancho;
|
||||||
$alto = ($input_data['presupuesto'])->papel_formato_alto;
|
$alto = ($input_data['presupuesto'])->papel_formato_alto;
|
||||||
}
|
}
|
||||||
@ -1038,10 +1041,10 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
// Hay que ver si es rotativa o plana
|
// Hay que ver si es rotativa o plana
|
||||||
// Si es rotativa
|
// Si es rotativa
|
||||||
if(str_contains($linea->tipo, '_rot_')){
|
if (str_contains($linea->tipo, '_rot_')) {
|
||||||
|
|
||||||
$datos = [
|
$datos = [
|
||||||
'datosPedido' => (object)array(
|
'datosPedido' => (object) array(
|
||||||
'paginas' => ($input_data['presupuesto'])->paginas,
|
'paginas' => ($input_data['presupuesto'])->paginas,
|
||||||
'tirada' => ($input_data['presupuesto'])->tirada,
|
'tirada' => ($input_data['presupuesto'])->tirada,
|
||||||
'merma' => ($input_data['presupuesto'])->merma,
|
'merma' => ($input_data['presupuesto'])->merma,
|
||||||
@ -1052,30 +1055,32 @@ class PresupuestoService extends BaseService
|
|||||||
),
|
),
|
||||||
'papel_generico' => $papel_generico,
|
'papel_generico' => $papel_generico,
|
||||||
'gramaje' => $linea->gramaje,
|
'gramaje' => $linea->gramaje,
|
||||||
'paginas' => (object)array(
|
'paginas' => (object) array(
|
||||||
'negro' => ($input_data['presupuesto'])->paginas - $linea->rotativa_pag_color,
|
'negro' => ($input_data['presupuesto'])->paginas - $linea->rotativa_pag_color,
|
||||||
'color' => $linea->rotativa_pag_color,
|
'color' => $linea->rotativa_pag_color,
|
||||||
),
|
),
|
||||||
'cliente_id' => ($input_data['presupuesto'])->cliente_id,
|
'cliente_id' => ($input_data['presupuesto'])->cliente_id,
|
||||||
'datosTipolog' => [(object)array(
|
'datosTipolog' => [
|
||||||
'negro' => $linea->rotativa_negro,
|
(object) array(
|
||||||
'cyan' => $linea->rotativa_cyan,
|
'negro' => $linea->rotativa_negro,
|
||||||
'magenta' => $linea->rotativa_magenta,
|
'cyan' => $linea->rotativa_cyan,
|
||||||
'amarillo' => $linea->rotativa_amarillo,
|
'magenta' => $linea->rotativa_magenta,
|
||||||
'cg' => $linea->rotativa_cg,
|
'amarillo' => $linea->rotativa_amarillo,
|
||||||
'gota_negro' => $linea->rotativa_gota_negro,
|
'cg' => $linea->rotativa_cg,
|
||||||
'gota_color' => $linea->rotativa_gota_color,
|
'gota_negro' => $linea->rotativa_gota_negro,
|
||||||
)]
|
'gota_color' => $linea->rotativa_gota_color,
|
||||||
|
)
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$comp_data = PresupuestoService::obtenerComparadorRotativa($datos);
|
$comp_data = PresupuestoService::obtenerComparadorRotativa($datos);
|
||||||
}
|
}
|
||||||
// Si es plana
|
// Si es plana
|
||||||
else{
|
else {
|
||||||
|
|
||||||
$datos = [
|
$datos = [
|
||||||
'tipo_impresion_id' => $data['tipo_impresion_id'],
|
'tipo_impresion_id' => $data['tipo_impresion_id'],
|
||||||
'datosPedido' => (object)array(
|
'datosPedido' => (object) array(
|
||||||
'paginas' => ($input_data['presupuesto'])->paginas,
|
'paginas' => ($input_data['presupuesto'])->paginas,
|
||||||
'tirada' => ($input_data['presupuesto'])->tirada,
|
'tirada' => ($input_data['presupuesto'])->tirada,
|
||||||
'merma' => ($input_data['presupuesto'])->merma,
|
'merma' => ($input_data['presupuesto'])->merma,
|
||||||
@ -1088,43 +1093,43 @@ class PresupuestoService extends BaseService
|
|||||||
'papel_generico' => $papel_generico,
|
'papel_generico' => $papel_generico,
|
||||||
'gramaje' => $linea->gramaje,
|
'gramaje' => $linea->gramaje,
|
||||||
'cliente_id' => ($input_data['presupuesto'])->cliente_id,
|
'cliente_id' => ($input_data['presupuesto'])->cliente_id,
|
||||||
'datosTipolog' => [(object)array(
|
'datosTipolog' => [
|
||||||
'negro' => $linea->rotativa_negro,
|
(object) array(
|
||||||
'cyan' => $linea->rotativa_cyan,
|
'negro' => $linea->rotativa_negro,
|
||||||
'magenta' => $linea->rotativa_magenta,
|
'cyan' => $linea->rotativa_cyan,
|
||||||
'amarillo' => $linea->rotativa_amarillo,
|
'magenta' => $linea->rotativa_magenta,
|
||||||
'cg' => $linea->rotativa_cg,
|
'amarillo' => $linea->rotativa_amarillo,
|
||||||
'gota_negro' => $linea->rotativa_gota_negro,
|
'cg' => $linea->rotativa_cg,
|
||||||
'gota_color' => $linea->rotativa_gota_color,
|
'gota_negro' => $linea->rotativa_gota_negro,
|
||||||
)]
|
'gota_color' => $linea->rotativa_gota_color,
|
||||||
|
)
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
// si la línea es cubierta o sobrecubierta, es HQ y color
|
// si la línea es cubierta o sobrecubierta, es HQ y color
|
||||||
if( str_contains($linea->tipo, 'cubierta') ){
|
if (str_contains($linea->tipo, 'cubierta')) {
|
||||||
$datos['isColor'] = true;
|
$datos['isColor'] = true;
|
||||||
$datos['isHq'] = true;
|
$datos['isHq'] = true;
|
||||||
|
|
||||||
// además se añade los campos de lomo y solapas y el uso
|
// además se añade los campos de lomo y solapas y el uso
|
||||||
if( str_contains($linea->tipo, 'sobrecubierta') ){
|
if (str_contains($linea->tipo, 'sobrecubierta')) {
|
||||||
$datos['datosPedido']->solapas = ($input_data['presupuesto'])->solapas_sobrecubierta;
|
$datos['datosPedido']->solapas = ($input_data['presupuesto'])->solapas_sobrecubierta;
|
||||||
$datos['datosPedido']->solapas_ancho = ($input_data['presupuesto'])->solapas_ancho_sobrecubierta;
|
$datos['datosPedido']->solapas_ancho = ($input_data['presupuesto'])->solapas_ancho_sobrecubierta;
|
||||||
$datos['datosPedido']->lomo = ($input_data['presupuesto'])->lomo_sobrecubierta;
|
$datos['datosPedido']->lomo = ($input_data['presupuesto'])->lomo_sobrecubierta;
|
||||||
$datos['uso'] = 'sobrecubierta';
|
$datos['uso'] = 'sobrecubierta';
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$datos['datosPedido']->solapas = ($input_data['presupuesto'])->solapas;
|
$datos['datosPedido']->solapas = ($input_data['presupuesto'])->solapas;
|
||||||
$datos['datosPedido']->solapas_ancho = ($input_data['presupuesto'])->solapas_ancho;
|
$datos['datosPedido']->solapas_ancho = ($input_data['presupuesto'])->solapas_ancho;
|
||||||
$datos['datosPedido']->lomo = ($input_data['presupuesto'])->lomo_cubierta;
|
$datos['datosPedido']->lomo = ($input_data['presupuesto'])->lomo_cubierta;
|
||||||
$datos['uso'] = 'cubierta';
|
$datos['uso'] = 'cubierta';
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$datos['isColor'] = str_contains($linea->tipo, '_color') ? true : false;
|
$datos['isColor'] = str_contains($linea->tipo, '_color') ? true : false;
|
||||||
$datos['isHq'] = str_contains($linea->tipo, 'hq') ? true : false;
|
$datos['isHq'] = str_contains($linea->tipo, 'hq') ? true : false;
|
||||||
$datos['uso'] = 'interior';
|
$datos['uso'] = 'interior';
|
||||||
}
|
}
|
||||||
|
|
||||||
if( str_contains($linea->tipo, 'guardas') ){
|
if (str_contains($linea->tipo, 'guardas')) {
|
||||||
$datos['uso'] = 'guardas';
|
$datos['uso'] = 'guardas';
|
||||||
$datos['datosPedido']->paginas_impresion = $linea->paginas_impresion;
|
$datos['datosPedido']->paginas_impresion = $linea->paginas_impresion;
|
||||||
}
|
}
|
||||||
@ -1133,8 +1138,8 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// se ordena $comp_data usando el campo ['fields]['total_impresion']
|
// se ordena $comp_data usando el campo ['fields]['total_impresion']
|
||||||
usort($comp_data, function($a, $b) {
|
usort($comp_data, function ($a, $b) {
|
||||||
return $a['fields']['total_impresion'] <=> $b['fields']['total_impresion'];
|
return $a['fields']['total_impresion'] <=> $b['fields']['total_impresion'];
|
||||||
});
|
});
|
||||||
(new PresupuestoLineaModel())->updatePreciosLineasPresupuesto($linea->id, $comp_data[0]);
|
(new PresupuestoLineaModel())->updatePreciosLineasPresupuesto($linea->id, $comp_data[0]);
|
||||||
@ -1144,16 +1149,15 @@ class PresupuestoService extends BaseService
|
|||||||
}
|
}
|
||||||
// Si existe el papel y la máquina, se recalcula el precio con los mismos
|
// Si existe el papel y la máquina, se recalcula el precio con los mismos
|
||||||
// parámetros y se comprueba
|
// parámetros y se comprueba
|
||||||
else{
|
else {
|
||||||
$nueva_linea = PresupuestoService::obtenerValorLineaPresupuesto($data, $linea);
|
$nueva_linea = PresupuestoService::obtenerValorLineaPresupuesto($data, $linea);
|
||||||
if(count($nueva_linea) >0){
|
if (count($nueva_linea) > 0) {
|
||||||
if(round($nueva_linea['fields']['total_impresion'],2) != round($linea->total_linea, 2)){
|
if (round($nueva_linea['fields']['total_impresion'], 2) != round($linea->total_linea, 2)) {
|
||||||
(new PresupuestoLineaModel())->updatePreciosLineasPresupuesto($linea->id, $nueva_linea);
|
(new PresupuestoLineaModel())->updatePreciosLineasPresupuesto($linea->id, $nueva_linea);
|
||||||
$linea_to_save = (new PresupuestoLineaModel())->find($linea->id);
|
$linea_to_save = (new PresupuestoLineaModel())->find($linea->id);
|
||||||
$cambios = true;
|
$cambios = true;
|
||||||
array_push($lineas, $linea_to_save);
|
array_push($lineas, $linea_to_save);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
array_push($lineas, $linea);
|
array_push($lineas, $linea);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1166,7 +1170,8 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static function obtenerValorLineaPresupuesto($input_data, $linea){
|
private static function obtenerValorLineaPresupuesto($input_data, $linea)
|
||||||
|
{
|
||||||
|
|
||||||
$tipo_impresion_id = $input_data['tipo_impresion_id'];
|
$tipo_impresion_id = $input_data['tipo_impresion_id'];
|
||||||
$tirada = $input_data['tirada'];
|
$tirada = $input_data['tirada'];
|
||||||
@ -1183,7 +1188,7 @@ class PresupuestoService extends BaseService
|
|||||||
$lomo_cubierta = $input_data['lomo_cubierta'];
|
$lomo_cubierta = $input_data['lomo_cubierta'];
|
||||||
$lomo_sobrecubierta = $input_data['lomo_sobrecubierta'];
|
$lomo_sobrecubierta = $input_data['lomo_sobrecubierta'];
|
||||||
|
|
||||||
if($papel_formato_personalizado == 0){
|
if ($papel_formato_personalizado == 0) {
|
||||||
$papel_formato = (new PapelFormatoModel())->find($papel_formato_id);
|
$papel_formato = (new PapelFormatoModel())->find($papel_formato_id);
|
||||||
$ancho = $papel_formato->ancho;
|
$ancho = $papel_formato->ancho;
|
||||||
$alto = $papel_formato->alto;
|
$alto = $papel_formato->alto;
|
||||||
@ -1202,7 +1207,7 @@ class PresupuestoService extends BaseService
|
|||||||
'nombre' => $papel_generico->nombre,
|
'nombre' => $papel_generico->nombre,
|
||||||
);
|
);
|
||||||
|
|
||||||
$data['datosPedido'] = (object)array(
|
$data['datosPedido'] = (object) array(
|
||||||
'paginas' => $linea->paginas,
|
'paginas' => $linea->paginas,
|
||||||
'tirada' => $tirada,
|
'tirada' => $tirada,
|
||||||
'merma' => $merma,
|
'merma' => $merma,
|
||||||
@ -1216,18 +1221,20 @@ class PresupuestoService extends BaseService
|
|||||||
$data['maquina'] = $maquina;
|
$data['maquina'] = $maquina;
|
||||||
$data['papel_generico'] = $papel_generico;
|
$data['papel_generico'] = $papel_generico;
|
||||||
$data['a_favor_fibra'] = $linea->rotativa_a_favor_fibra;
|
$data['a_favor_fibra'] = $linea->rotativa_a_favor_fibra;
|
||||||
$data['datosTipolog'] = [(object)array(
|
$data['datosTipolog'] = [
|
||||||
'negro' => $linea->rotativa_negro,
|
(object) array(
|
||||||
'cyan' => $linea->rotativa_cyan,
|
'negro' => $linea->rotativa_negro,
|
||||||
'magenta' => $linea->rotativa_magenta,
|
'cyan' => $linea->rotativa_cyan,
|
||||||
'amarillo' => $linea->rotativa_amarillo,
|
'magenta' => $linea->rotativa_magenta,
|
||||||
'cg' => $linea->rotativa_cg,
|
'amarillo' => $linea->rotativa_amarillo,
|
||||||
'gota_negro' => $linea->rotativa_gota_negro,
|
'cg' => $linea->rotativa_cg,
|
||||||
'gota_color' => $linea->rotativa_gota_color,
|
'gota_negro' => $linea->rotativa_gota_negro,
|
||||||
)];
|
'gota_color' => $linea->rotativa_gota_color,
|
||||||
|
)
|
||||||
|
];
|
||||||
$data['gramaje'] = $linea->gramaje;
|
$data['gramaje'] = $linea->gramaje;
|
||||||
|
|
||||||
switch($linea->tipo){
|
switch ($linea->tipo) {
|
||||||
|
|
||||||
case 'lp_bn':
|
case 'lp_bn':
|
||||||
case 'lp_bnhq':
|
case 'lp_bnhq':
|
||||||
@ -1240,7 +1247,7 @@ class PresupuestoService extends BaseService
|
|||||||
$tipo = $isColor ? ($isHq ? 'colorhq' : 'color') : ($isHq ? 'negrohq' : 'negro');
|
$tipo = $isColor ? ($isHq ? 'colorhq' : 'color') : ($isHq ? 'negrohq' : 'negro');
|
||||||
$opciones_papel = PresupuestoService::get_opciones_papel('interior', $isColor);
|
$opciones_papel = PresupuestoService::get_opciones_papel('interior', $isColor);
|
||||||
|
|
||||||
if($linea->tipo == 'lp_guardas'){
|
if ($linea->tipo == 'lp_guardas') {
|
||||||
$data['uso'] = 'guardas';
|
$data['uso'] = 'guardas';
|
||||||
$tipo = 'colorhq';
|
$tipo = 'colorhq';
|
||||||
$data['datosPedido']->paginas_impresion = $linea->paginas_impresion;
|
$data['datosPedido']->paginas_impresion = $linea->paginas_impresion;
|
||||||
@ -1265,17 +1272,17 @@ class PresupuestoService extends BaseService
|
|||||||
case 'lp_rot_color':
|
case 'lp_rot_color':
|
||||||
case 'lp_rot_bn':
|
case 'lp_rot_bn':
|
||||||
$data['uso'] = 'interior';
|
$data['uso'] = 'interior';
|
||||||
$tipo = $linea->rotativa_pag_color>0 ? 'color' : 'negro';
|
$tipo = $linea->rotativa_pag_color > 0 ? 'color' : 'negro';
|
||||||
$data['paginas'] = (object)array(
|
$data['paginas'] = (object) array(
|
||||||
'negro' => $linea->paginas-$linea->rotativa_pag_color,
|
'negro' => $linea->paginas - $linea->rotativa_pag_color,
|
||||||
'color' => $linea->rotativa_pag_color,
|
'color' => $linea->rotativa_pag_color,
|
||||||
);
|
);
|
||||||
|
|
||||||
$data['tipo'] = $tipo;
|
$data['tipo'] = $tipo;
|
||||||
$data['parametrosRotativa'] = (object)array(
|
$data['parametrosRotativa'] = (object) array(
|
||||||
'a_favor_fibra' => $linea->rotativa_a_favor_fibra,
|
'a_favor_fibra' => $linea->rotativa_a_favor_fibra,
|
||||||
'bnPages' => $data['paginas']->negro,
|
'bnPages' => $data['paginas']->negro,
|
||||||
'colorPages' => $data['paginas']->color,
|
'colorPages' => $data['paginas']->color,
|
||||||
'rotativa_negro' => $linea->rotativa_negro,
|
'rotativa_negro' => $linea->rotativa_negro,
|
||||||
'rotativa_cyan' => $linea->rotativa_cyan,
|
'rotativa_cyan' => $linea->rotativa_cyan,
|
||||||
'rotativa_magenta' => $linea->rotativa_magenta,
|
'rotativa_magenta' => $linea->rotativa_magenta,
|
||||||
@ -1290,12 +1297,12 @@ class PresupuestoService extends BaseService
|
|||||||
case 'lp_cubierta':
|
case 'lp_cubierta':
|
||||||
case 'lp_sobrecubierta':
|
case 'lp_sobrecubierta':
|
||||||
|
|
||||||
$data['uso'] = ($linea->tipo == 'lp_cubierta')? 'cubierta':'sobrecubierta';
|
$data['uso'] = ($linea->tipo == 'lp_cubierta') ? 'cubierta' : 'sobrecubierta';
|
||||||
$data['tipo'] = 'colorhq';
|
$data['tipo'] = 'colorhq';
|
||||||
$data['isColor'] = true;
|
$data['isColor'] = true;
|
||||||
$data['datosPedido']->solapas = ($linea->tipo == 'lp cubierta')? $solapas : $solapas_sobrecubierta;
|
$data['datosPedido']->solapas = ($linea->tipo == 'lp cubierta') ? $solapas : $solapas_sobrecubierta;
|
||||||
$data['datosPedido']->solapas_ancho = ($linea->tipo == 'lp cubierta')? $solapas_ancho_cubierta : $solapas_ancho_sobrecubierta;
|
$data['datosPedido']->solapas_ancho = ($linea->tipo == 'lp cubierta') ? $solapas_ancho_cubierta : $solapas_ancho_sobrecubierta;
|
||||||
$data['datosPedido']->lomo = ($linea->tipo == 'lp cubierta')? $lomo_cubierta : $lomo_sobrecubierta;
|
$data['datosPedido']->lomo = ($linea->tipo == 'lp cubierta') ? $lomo_cubierta : $lomo_sobrecubierta;
|
||||||
|
|
||||||
$opciones_papel = PresupuestoService::get_opciones_papel($data['uso'], true);
|
$opciones_papel = PresupuestoService::get_opciones_papel($data['uso'], true);
|
||||||
$data['opciones_papel'] = $opciones_papel;
|
$data['opciones_papel'] = $opciones_papel;
|
||||||
@ -1305,8 +1312,10 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
$output_data = PresupuestoService::getLineaPresupuestoPlana($data);
|
$output_data = PresupuestoService::getLineaPresupuestoPlana($data);
|
||||||
|
|
||||||
if ($tipo_impresion_id == 5 || $tipo_impresion_id == 6 ||
|
if (
|
||||||
$tipo_impresion_id == 7 || $tipo_impresion_id == 8) {
|
$tipo_impresion_id == 5 || $tipo_impresion_id == 6 ||
|
||||||
|
$tipo_impresion_id == 7 || $tipo_impresion_id == 8
|
||||||
|
) {
|
||||||
|
|
||||||
$output_data['fields']['num_formas']['num_formas_horizontales'] *= 2;
|
$output_data['fields']['num_formas']['num_formas_horizontales'] *= 2;
|
||||||
$output_data['fields']['num_formas']['value'] *= 2;
|
$output_data['fields']['num_formas']['value'] *= 2;
|
||||||
@ -1317,33 +1326,34 @@ class PresupuestoService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Funcion que procesa los servicios y actualiza los precios en caso de cambio
|
// Funcion que procesa los servicios y actualiza los precios en caso de cambio
|
||||||
public static function checkLineasServicios($input_data, $servicios){
|
public static function checkLineasServicios($input_data, $servicios)
|
||||||
|
{
|
||||||
|
|
||||||
$cambio_en_servicios = false;
|
$cambio_en_servicios = false;
|
||||||
$cambio = false;
|
$cambio = false;
|
||||||
|
|
||||||
if(count($servicios->serviciosAcabado)>0){
|
if (count($servicios->serviciosAcabado) > 0) {
|
||||||
|
|
||||||
[$cambio, $servicios->serviciosAcabado] =
|
[$cambio, $servicios->serviciosAcabado] =
|
||||||
PresupuestoService::procesarServiciosAcabado($input_data, $servicios->serviciosAcabado);
|
PresupuestoService::procesarServiciosAcabado($input_data, $servicios->serviciosAcabado);
|
||||||
|
|
||||||
$cambio_en_servicios = $cambio_en_servicios? $cambio_en_servicios: $cambio;
|
$cambio_en_servicios = $cambio_en_servicios ? $cambio_en_servicios : $cambio;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($servicios->serviciosManipulado)>0){
|
if (count($servicios->serviciosManipulado) > 0) {
|
||||||
|
|
||||||
[$cambio, $servicios->serviciosManipulado] =
|
[$cambio, $servicios->serviciosManipulado] =
|
||||||
PresupuestoService::procesarServiciosManipulado($input_data, $servicios->serviciosManipulado);
|
PresupuestoService::procesarServiciosManipulado($input_data, $servicios->serviciosManipulado);
|
||||||
|
|
||||||
$cambio_en_servicios = $cambio_en_servicios? $cambio_en_servicios: $cambio;
|
$cambio_en_servicios = $cambio_en_servicios ? $cambio_en_servicios : $cambio;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($servicios->serviciosEncuadernacion)>0){
|
if (count($servicios->serviciosEncuadernacion) > 0) {
|
||||||
|
|
||||||
[$cambio, $servicios->serviciosEncuadernacion] =
|
[$cambio, $servicios->serviciosEncuadernacion] =
|
||||||
PresupuestoService::procesarServiciosEncuadernacion($input_data, $servicios->serviciosEncuadernacion);
|
PresupuestoService::procesarServiciosEncuadernacion($input_data, $servicios->serviciosEncuadernacion);
|
||||||
|
|
||||||
$cambio_en_servicios = $cambio_en_servicios? $cambio_en_servicios: $cambio;
|
$cambio_en_servicios = $cambio_en_servicios ? $cambio_en_servicios : $cambio;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Los servicios de preimpresion y los extra se dejan tal y como esten
|
// Los servicios de preimpresion y los extra se dejan tal y como esten
|
||||||
@ -1354,7 +1364,8 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
// Funcion que procesa los servicios de acabado del presupuesto
|
// Funcion que procesa los servicios de acabado del presupuesto
|
||||||
// y actualiza los precios en caso de cambio de valor en precio_unidad
|
// y actualiza los precios en caso de cambio de valor en precio_unidad
|
||||||
private static function procesarServiciosAcabado($input_data, $servicios){
|
private static function procesarServiciosAcabado($input_data, $servicios)
|
||||||
|
{
|
||||||
|
|
||||||
$serviciosUpdated = [];
|
$serviciosUpdated = [];
|
||||||
$cambio = false;
|
$cambio = false;
|
||||||
@ -1363,16 +1374,17 @@ class PresupuestoService extends BaseService
|
|||||||
foreach ($servicios as $servicio) {
|
foreach ($servicios as $servicio) {
|
||||||
|
|
||||||
// Si es un presupuesto duplicado hay que buscar el proveedor más barato
|
// Si es un presupuesto duplicado hay que buscar el proveedor más barato
|
||||||
if($input_data['is_duplicado']){
|
if ($input_data['is_duplicado']) {
|
||||||
$nueva_tarifa = $model->getPrecioTarifa($servicio->tarifa_acabado_id, $input_data['tirada'], -1, $input_data['POD']);
|
$nueva_tarifa = $model->getPrecioTarifa($servicio->tarifa_acabado_id, $input_data['tirada'], -1, $input_data['POD']);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$nueva_tarifa = $model->getPrecioTarifa($servicio->tarifa_acabado_id, $input_data['tirada'], $servicio->proveedor_id, $input_data['POD']);
|
$nueva_tarifa = $model->getPrecioTarifa($servicio->tarifa_acabado_id, $input_data['tirada'], $servicio->proveedor_id, $input_data['POD']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($nueva_tarifa && count($nueva_tarifa)>0){
|
if ($nueva_tarifa && count($nueva_tarifa) > 0) {
|
||||||
if(round($nueva_tarifa[0]->precio_unidad, 2) != round($servicio->precio_unidad,2) ||
|
if (
|
||||||
$nueva_tarifa[0]->margen != $servicio->margen){
|
round($nueva_tarifa[0]->precio_unidad, 2) != round($servicio->precio_unidad, 2) ||
|
||||||
|
$nueva_tarifa[0]->margen != $servicio->margen
|
||||||
|
) {
|
||||||
|
|
||||||
$servicio->precio_unidad = round($nueva_tarifa[0]->precio_unidad, 2);
|
$servicio->precio_unidad = round($nueva_tarifa[0]->precio_unidad, 2);
|
||||||
$servicio->precio_total = round($nueva_tarifa[0]->total, 2);
|
$servicio->precio_total = round($nueva_tarifa[0]->total, 2);
|
||||||
@ -1392,7 +1404,8 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
// Funcion que procesa los servicios de manipulado del presupuesto
|
// Funcion que procesa los servicios de manipulado del presupuesto
|
||||||
// y actualiza los precios en caso de cambio de valor en precio_unidad
|
// y actualiza los precios en caso de cambio de valor en precio_unidad
|
||||||
private static function procesarServiciosManipulado($input_data, $servicios){
|
private static function procesarServiciosManipulado($input_data, $servicios)
|
||||||
|
{
|
||||||
|
|
||||||
$serviciosUpdated = [];
|
$serviciosUpdated = [];
|
||||||
$cambio = false;
|
$cambio = false;
|
||||||
@ -1401,9 +1414,11 @@ class PresupuestoService extends BaseService
|
|||||||
foreach ($servicios as $servicio) {
|
foreach ($servicios as $servicio) {
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$nueva_tarifa = $model->getPrecioTarifa($servicio->tarifa_manipulado_id, $input_data['tirada'], $input_data['POD']);
|
$nueva_tarifa = $model->getPrecioTarifa($servicio->tarifa_manipulado_id, $input_data['tirada'], $input_data['POD']);
|
||||||
if($nueva_tarifa && count($nueva_tarifa)>0){
|
if ($nueva_tarifa && count($nueva_tarifa) > 0) {
|
||||||
if(round($nueva_tarifa[0]->precio_unidad, 2) != round($servicio->precio_unidad,2) ||
|
if (
|
||||||
$nueva_tarifa[0]->margen != $servicio->margen){
|
round($nueva_tarifa[0]->precio_unidad, 2) != round($servicio->precio_unidad, 2) ||
|
||||||
|
$nueva_tarifa[0]->margen != $servicio->margen
|
||||||
|
) {
|
||||||
|
|
||||||
$servicio->precio_unidad = round($nueva_tarifa[0]->precio_unidad, 2);
|
$servicio->precio_unidad = round($nueva_tarifa[0]->precio_unidad, 2);
|
||||||
$servicio->precio_total = round($nueva_tarifa[0]->total, 2);
|
$servicio->precio_total = round($nueva_tarifa[0]->total, 2);
|
||||||
@ -1424,7 +1439,8 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
// Funcion que procesa los servicios de encuadernacion del presupuesto
|
// Funcion que procesa los servicios de encuadernacion del presupuesto
|
||||||
// y actualiza los precios en caso de cambio de valor en precio_unidad
|
// y actualiza los precios en caso de cambio de valor en precio_unidad
|
||||||
private static function procesarServiciosEncuadernacion($input_data, $servicios){
|
private static function procesarServiciosEncuadernacion($input_data, $servicios)
|
||||||
|
{
|
||||||
|
|
||||||
$serviciosUpdated = [];
|
$serviciosUpdated = [];
|
||||||
$cambio = false;
|
$cambio = false;
|
||||||
@ -1435,17 +1451,18 @@ class PresupuestoService extends BaseService
|
|||||||
foreach ($servicios as $servicio) {
|
foreach ($servicios as $servicio) {
|
||||||
|
|
||||||
// Si es un presupuesto duplicado hay que buscar el proveedor más barato
|
// Si es un presupuesto duplicado hay que buscar el proveedor más barato
|
||||||
if($input_data['is_duplicado']){
|
if ($input_data['is_duplicado']) {
|
||||||
if($tarifaModel->isTarifaPorHoras($servicio->tarifa_encuadernado_id)){
|
if ($tarifaModel->isTarifaPorHoras($servicio->tarifa_encuadernado_id)) {
|
||||||
$paginas_cuadernillo = $servicio->paginas_por_cuadernillo??null;
|
$paginas_cuadernillo = $servicio->paginas_por_cuadernillo ?? null;
|
||||||
$nueva_tarifa = $model->getPrecioTarifaHoras(
|
$nueva_tarifa = $model->getPrecioTarifaHoras(
|
||||||
$servicio->tarifa_encuadernado_id,
|
$servicio->tarifa_encuadernado_id,
|
||||||
$input_data['paginas'],
|
$input_data['paginas'],
|
||||||
$input_data['tirada'],
|
$input_data['tirada'],
|
||||||
-1,
|
-1,
|
||||||
$input_data['POD'],
|
$input_data['POD'],
|
||||||
$paginas_cuadernillo);
|
$paginas_cuadernillo
|
||||||
}else{
|
);
|
||||||
|
} else {
|
||||||
$nueva_tarifa = $model->getPrecioTarifa(
|
$nueva_tarifa = $model->getPrecioTarifa(
|
||||||
$servicio->tarifa_encuadernado_id,
|
$servicio->tarifa_encuadernado_id,
|
||||||
$input_data['paginas'],
|
$input_data['paginas'],
|
||||||
@ -1453,23 +1470,25 @@ class PresupuestoService extends BaseService
|
|||||||
$input_data['ancho'],
|
$input_data['ancho'],
|
||||||
$input_data['alto'],
|
$input_data['alto'],
|
||||||
-1,
|
-1,
|
||||||
$input_data['POD']);
|
$input_data['POD']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// En caso de que el presupuesto no sea duplicado, recalcular la tarifa
|
// En caso de que el presupuesto no sea duplicado, recalcular la tarifa
|
||||||
// con el mismo proveedor
|
// con el mismo proveedor
|
||||||
else{
|
else {
|
||||||
if($tarifaModel->isTarifaPorHoras($servicio->tarifa_encuadernado_id)){
|
if ($tarifaModel->isTarifaPorHoras($servicio->tarifa_encuadernado_id)) {
|
||||||
$paginas_cuadernillo = $servicio->paginas_por_cuadernillo??null;
|
$paginas_cuadernillo = $servicio->paginas_por_cuadernillo ?? null;
|
||||||
$nueva_tarifa = $model->getPrecioTarifaHoras(
|
$nueva_tarifa = $model->getPrecioTarifaHoras(
|
||||||
$servicio->tarifa_encuadernado_id,
|
$servicio->tarifa_encuadernado_id,
|
||||||
$input_data['paginas'],
|
$input_data['paginas'],
|
||||||
$input_data['tirada'],
|
$input_data['tirada'],
|
||||||
$servicio->proveedor_id,
|
$servicio->proveedor_id,
|
||||||
$input_data['POD'],
|
$input_data['POD'],
|
||||||
$paginas_cuadernillo);
|
$paginas_cuadernillo
|
||||||
}else{
|
);
|
||||||
|
} else {
|
||||||
$nueva_tarifa = $model->getPrecioTarifa(
|
$nueva_tarifa = $model->getPrecioTarifa(
|
||||||
$servicio->tarifa_encuadernado_id,
|
$servicio->tarifa_encuadernado_id,
|
||||||
$input_data['paginas'],
|
$input_data['paginas'],
|
||||||
@ -1477,34 +1496,36 @@ class PresupuestoService extends BaseService
|
|||||||
$input_data['ancho'],
|
$input_data['ancho'],
|
||||||
$input_data['alto'],
|
$input_data['alto'],
|
||||||
$servicio->proveedor_id,
|
$servicio->proveedor_id,
|
||||||
$input_data['POD']);
|
$input_data['POD']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($nueva_tarifa && count($nueva_tarifa)>0){
|
if ($nueva_tarifa && count($nueva_tarifa) > 0) {
|
||||||
if(!isset($nueva_tarifa[0]->proveedor_id)){
|
if (!isset($nueva_tarifa[0]->proveedor_id)) {
|
||||||
$nueva_tarifa[0]->proveedor_id = null;
|
$nueva_tarifa[0]->proveedor_id = null;
|
||||||
}
|
}
|
||||||
// Si el presupuesto no es duplicado, se comprueba que
|
// Si el presupuesto no es duplicado, se comprueba que
|
||||||
// no ha cambiado el precio unidad
|
// no ha cambiado el precio unidad
|
||||||
if($nueva_tarifa[0]->tiempo==null)
|
if ($nueva_tarifa[0]->tiempo == null)
|
||||||
$nueva_tarifa[0]->tiempo = 0;
|
$nueva_tarifa[0]->tiempo = 0;
|
||||||
if($servicio->tiempo == null)
|
if ($servicio->tiempo == null)
|
||||||
$servicio->tiempo = 0;
|
$servicio->tiempo = 0;
|
||||||
if(round($nueva_tarifa[0]->precio_unidad, 2) != round(floatval($servicio->precio_unidad),2) ||
|
if (
|
||||||
|
round($nueva_tarifa[0]->precio_unidad, 2) != round(floatval($servicio->precio_unidad), 2) ||
|
||||||
$nueva_tarifa[0]->margen != floatval($servicio->margen) ||
|
$nueva_tarifa[0]->margen != floatval($servicio->margen) ||
|
||||||
$nueva_tarifa[0]->tiempo != floatval($servicio->tiempo)){
|
$nueva_tarifa[0]->tiempo != floatval($servicio->tiempo)
|
||||||
|
) {
|
||||||
|
|
||||||
$servicio->precio_unidad = round($nueva_tarifa[0]->precio_unidad, 2);
|
$servicio->precio_unidad = round($nueva_tarifa[0]->precio_unidad, 2);
|
||||||
$servicio->tiempo = $nueva_tarifa[0]->tiempo==null?0: round($nueva_tarifa[0]->tiempo, 2);
|
$servicio->tiempo = $nueva_tarifa[0]->tiempo == null ? 0 : round($nueva_tarifa[0]->tiempo, 2);
|
||||||
$servicio->precio_total = round($nueva_tarifa[0]->total, 2);
|
$servicio->precio_total = round($nueva_tarifa[0]->total, 2);
|
||||||
$servicio->margen = round($nueva_tarifa[0]->margen);
|
$servicio->margen = round($nueva_tarifa[0]->margen);
|
||||||
$cambio = true;
|
$cambio = true;
|
||||||
}
|
} else if ($input_data['is_duplicado'] && $nueva_tarifa[0]->proveedor_id != $servicio->proveedor_id) {
|
||||||
else if($input_data['is_duplicado'] && $nueva_tarifa[0]->proveedor_id != $servicio->proveedor_id){
|
|
||||||
$servicio->precio_unidad = round($nueva_tarifa[0]->precio_unidad, 2);
|
$servicio->precio_unidad = round($nueva_tarifa[0]->precio_unidad, 2);
|
||||||
$servicio->tiempo = $nueva_tarifa[0]->tiempo==null?"": round($nueva_tarifa[0]->tiempo, 2);
|
$servicio->tiempo = $nueva_tarifa[0]->tiempo == null ? "" : round($nueva_tarifa[0]->tiempo, 2);
|
||||||
$servicio->precio_total = round($nueva_tarifa[0]->total, 2);
|
$servicio->precio_total = round($nueva_tarifa[0]->total, 2);
|
||||||
$servicio->margen = round($nueva_tarifa[0]->margen);
|
$servicio->margen = round($nueva_tarifa[0]->margen);
|
||||||
$servicio->proveedor = $nueva_tarifa[0]->proveedor;
|
$servicio->proveedor = $nueva_tarifa[0]->proveedor;
|
||||||
@ -1522,37 +1543,40 @@ class PresupuestoService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function checkLineasEnvios($envios){
|
public static function checkLineasEnvios($envios)
|
||||||
|
{
|
||||||
|
|
||||||
$cambio = false;
|
$cambio = false;
|
||||||
|
|
||||||
if(count($envios)>0){
|
if (count($envios) > 0) {
|
||||||
$model = new TarifaEnvioModel();
|
$model = new TarifaEnvioModel();
|
||||||
|
|
||||||
foreach ($envios as $envio) {
|
foreach ($envios as $envio) {
|
||||||
$paisId = $envio->pais_id;
|
$paisId = $envio->pais_id;
|
||||||
$cp= $envio->cp;
|
$cp = $envio->cp;
|
||||||
$peso= $envio->peso;
|
$peso = $envio->peso;
|
||||||
$tipo_envio= $envio->entregaPieCalle==1?'palets':'cajas';
|
$tipo_envio = $envio->entregaPieCalle == 1 ? 'palets' : 'cajas';
|
||||||
|
|
||||||
$nueva_tarifa = $model->getTarifaEnvio($paisId, $cp, $peso, $tipo_envio);
|
$nueva_tarifa = $model->getTarifaEnvio($paisId, $cp, $peso, $tipo_envio);
|
||||||
|
|
||||||
if($nueva_tarifa && count($nueva_tarifa)>0){
|
if ($nueva_tarifa && count($nueva_tarifa) > 0) {
|
||||||
$coste = 0;
|
$coste = 0;
|
||||||
$margen = 0;
|
$margen = 0;
|
||||||
if($peso>$nueva_tarifa[0]->peso_max){
|
if ($peso > $nueva_tarifa[0]->peso_max) {
|
||||||
$coste += floatval($nueva_tarifa[0]->peso_min) + ($peso-floatval($nueva_tarifa[0]->peso_min))*floatval($nueva_tarifa[0]->precio_adicional);
|
$coste += floatval($nueva_tarifa[0]->peso_min) + ($peso - floatval($nueva_tarifa[0]->peso_min)) * floatval($nueva_tarifa[0]->precio_adicional);
|
||||||
}
|
}
|
||||||
// si no se calcula linealmente
|
// si no se calcula linealmente
|
||||||
else{
|
else {
|
||||||
$m=(floatval($nueva_tarifa[0]->precio_max)-floatval($nueva_tarifa[0]->precio_min)) / ((floatval($nueva_tarifa[0]->peso_max)-floatval($nueva_tarifa[0]->peso_min)));
|
$m = (floatval($nueva_tarifa[0]->precio_max) - floatval($nueva_tarifa[0]->precio_min)) / ((floatval($nueva_tarifa[0]->peso_max) - floatval($nueva_tarifa[0]->peso_min)));
|
||||||
$b=floatval($nueva_tarifa[0]->precio_max)-$m*floatval($nueva_tarifa[0]->peso_max);
|
$b = floatval($nueva_tarifa[0]->precio_max) - $m * floatval($nueva_tarifa[0]->peso_max);
|
||||||
$coste += floatval($m*$peso+$b);
|
$coste += floatval($m * $peso + $b);
|
||||||
}
|
}
|
||||||
$margen += $coste*floatval($nueva_tarifa[0]->margen)/100.0;
|
$margen += $coste * floatval($nueva_tarifa[0]->margen) / 100.0;
|
||||||
|
|
||||||
if(round($coste, 2) != $envio->precio ||
|
if (
|
||||||
$margen != $envio->margen || $nueva_tarifa[0]->id != $envio->tarifa_id){
|
round($coste, 2) != $envio->precio ||
|
||||||
|
$margen != $envio->margen || $nueva_tarifa[0]->id != $envio->tarifa_id
|
||||||
|
) {
|
||||||
|
|
||||||
$envio->precio = round($coste, 2);
|
$envio->precio = round($coste, 2);
|
||||||
$envio->margen = $margen;
|
$envio->margen = $margen;
|
||||||
@ -1588,7 +1612,8 @@ class PresupuestoService extends BaseService
|
|||||||
// - gramaje: gramaje del papel seleccionado
|
// - gramaje: gramaje del papel seleccionado
|
||||||
// - cliente_id: id del cliente al que va destinado el presupuesto
|
// - cliente_id: id del cliente al que va destinado el presupuesto
|
||||||
// - datosTipolog: datos referentes a las tintas
|
// - datosTipolog: datos referentes a las tintas
|
||||||
public static function obtenerComparadorRotativa($input_data){
|
public static function obtenerComparadorRotativa($input_data)
|
||||||
|
{
|
||||||
|
|
||||||
$paginas = $input_data['paginas'];
|
$paginas = $input_data['paginas'];
|
||||||
$datosPedido = $input_data['datosPedido'];
|
$datosPedido = $input_data['datosPedido'];
|
||||||
@ -1600,10 +1625,10 @@ class PresupuestoService extends BaseService
|
|||||||
$tipo = $paginas->color > 0 ? 'color' : 'negro';
|
$tipo = $paginas->color > 0 ? 'color' : 'negro';
|
||||||
$uso = 'interior';
|
$uso = 'interior';
|
||||||
|
|
||||||
$parametrosRotativa = (object)array(
|
$parametrosRotativa = (object) array(
|
||||||
'a_favor_fibra' => $datosPedido->a_favor_fibra,
|
'a_favor_fibra' => $datosPedido->a_favor_fibra,
|
||||||
'bnPages' => $paginas->negro,
|
'bnPages' => $paginas->negro,
|
||||||
'colorPages' => $paginas->color,
|
'colorPages' => $paginas->color,
|
||||||
'rotativa_gota_negro' => 0,
|
'rotativa_gota_negro' => 0,
|
||||||
'rotativa_gota_color' => 0,
|
'rotativa_gota_color' => 0,
|
||||||
);
|
);
|
||||||
@ -1616,8 +1641,7 @@ class PresupuestoService extends BaseService
|
|||||||
if ($paginas->color > 0) {
|
if ($paginas->color > 0) {
|
||||||
$tipo = 'color';
|
$tipo = 'color';
|
||||||
$opciones_papel['color'] = 1;
|
$opciones_papel['color'] = 1;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$opciones_papel['bn'] = 1;
|
$opciones_papel['bn'] = 1;
|
||||||
$tipo = 'negro';
|
$tipo = 'negro';
|
||||||
}
|
}
|
||||||
@ -1648,12 +1672,12 @@ class PresupuestoService extends BaseService
|
|||||||
$datosTipologias = $datosTipolog;
|
$datosTipologias = $datosTipolog;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parametrosRotativa->rotativa_gota_negro = $datosTipologias[0]->gota_negro;
|
$parametrosRotativa->rotativa_gota_negro = $datosTipologias[0]->gota_negro;
|
||||||
$parametrosRotativa->rotativa_gota_color = $datosTipologias[0]->gota_color;
|
$parametrosRotativa->rotativa_gota_color = $datosTipologias[0]->gota_color;
|
||||||
$parametrosRotativa->rotativa_negro = $datosTipologias[0]->negro;
|
$parametrosRotativa->rotativa_negro = $datosTipologias[0]->negro;
|
||||||
$parametrosRotativa->rotativa_cyan = $datosTipologias[0]->cyan;
|
$parametrosRotativa->rotativa_cyan = $datosTipologias[0]->cyan;
|
||||||
$parametrosRotativa->rotativa_magenta = $datosTipologias[0]->magenta;
|
$parametrosRotativa->rotativa_magenta = $datosTipologias[0]->magenta;
|
||||||
$parametrosRotativa->rotativa_amarillo = $datosTipologias[0]->amarillo;
|
$parametrosRotativa->rotativa_amarillo = $datosTipologias[0]->amarillo;
|
||||||
|
|
||||||
$maquinamodel = new MaquinaModel();
|
$maquinamodel = new MaquinaModel();
|
||||||
|
|
||||||
@ -1682,7 +1706,7 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
$linea = PresupuestoService::getLineaPresupuestoRotativa($data);
|
$linea = PresupuestoService::getLineaPresupuestoRotativa($data);
|
||||||
|
|
||||||
if(empty($linea))
|
if (empty($linea))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
array_push($lineas, $linea);
|
array_push($lineas, $linea);
|
||||||
@ -1713,7 +1737,8 @@ class PresupuestoService extends BaseService
|
|||||||
// - cliente_id: id del cliente al que va destinado el presupuesto
|
// - cliente_id: id del cliente al que va destinado el presupuesto
|
||||||
// - datosTipolog: datos referentes a las tintas (opcional)
|
// - datosTipolog: datos referentes a las tintas (opcional)
|
||||||
// - a_favor_fibra: dirección de la impresión
|
// - a_favor_fibra: dirección de la impresión
|
||||||
public static function obtenerComparadorPlana($input_data){
|
public static function obtenerComparadorPlana($input_data)
|
||||||
|
{
|
||||||
|
|
||||||
$uso = $input_data['uso'];
|
$uso = $input_data['uso'];
|
||||||
$tipo_impresion_id = $input_data['tipo_impresion_id'];
|
$tipo_impresion_id = $input_data['tipo_impresion_id'];
|
||||||
@ -1776,27 +1801,28 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
$linea = PresupuestoService::getLineaPresupuestoPlana($data);
|
$linea = PresupuestoService::getLineaPresupuestoPlana($data);
|
||||||
|
|
||||||
if ($tipo_impresion_id == 5 || $tipo_impresion_id == 6 ||
|
if (empty($linea))
|
||||||
$tipo_impresion_id == 7 || $tipo_impresion_id == 8) {
|
continue;
|
||||||
|
|
||||||
if ($uso == 'cubierta'){
|
if (
|
||||||
|
$tipo_impresion_id == 5 || $tipo_impresion_id == 6 ||
|
||||||
|
$tipo_impresion_id == 7 || $tipo_impresion_id == 8
|
||||||
|
) {
|
||||||
|
|
||||||
|
if ($uso == 'cubierta') {
|
||||||
$linea['fields']['num_formas']['num_formas_horizontales'] *= 2;
|
$linea['fields']['num_formas']['num_formas_horizontales'] *= 2;
|
||||||
$linea['fields']['num_formas']['value'] *= 2;
|
$linea['fields']['num_formas']['value'] *= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($linea))
|
if (!array_key_exists('tipo_linea', $linea['fields'])) {
|
||||||
continue;
|
if ($isColor) {
|
||||||
|
if ($isHq)
|
||||||
if(!array_key_exists('tipo_linea', $linea['fields'])){
|
|
||||||
if($isColor){
|
|
||||||
if($isHq)
|
|
||||||
$linea['fields']['tipo_linea'] = 'lp_colorhq';
|
$linea['fields']['tipo_linea'] = 'lp_colorhq';
|
||||||
else
|
else
|
||||||
$linea['fields']['tipo_linea'] = 'lp_color';
|
$linea['fields']['tipo_linea'] = 'lp_color';
|
||||||
}
|
} else {
|
||||||
else{
|
if ($isHq)
|
||||||
if($isHq)
|
|
||||||
$linea['fields']['tipo_linea'] = 'lp_bnhq';
|
$linea['fields']['tipo_linea'] = 'lp_bnhq';
|
||||||
else
|
else
|
||||||
$linea['fields']['tipo_linea'] = 'lp_bn';
|
$linea['fields']['tipo_linea'] = 'lp_bn';
|
||||||
@ -1830,7 +1856,7 @@ class PresupuestoService extends BaseService
|
|||||||
];
|
];
|
||||||
|
|
||||||
$pedido_id = $model_pedido->insert($data_pedido);
|
$pedido_id = $model_pedido->insert($data_pedido);
|
||||||
if($pedido_id){
|
if ($pedido_id) {
|
||||||
$data_pedido_linea = [
|
$data_pedido_linea = [
|
||||||
"pedido_id" => $pedido_id,
|
"pedido_id" => $pedido_id,
|
||||||
"presupuesto_id" => $presupuesto_id,
|
"presupuesto_id" => $presupuesto_id,
|
||||||
@ -1842,7 +1868,7 @@ class PresupuestoService extends BaseService
|
|||||||
PedidoXMLService::generate_xml($pedido_id);
|
PedidoXMLService::generate_xml($pedido_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($id_linea != 0 && $pedido_id != 0){
|
if ($id_linea != 0 && $pedido_id != 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1853,7 +1879,8 @@ class PresupuestoService extends BaseService
|
|||||||
*******************************/
|
*******************************/
|
||||||
|
|
||||||
// Funcion que comprueba si existe una maquina
|
// Funcion que comprueba si existe una maquina
|
||||||
private static function checkMaquina($maquina_id){
|
private static function checkMaquina($maquina_id)
|
||||||
|
{
|
||||||
|
|
||||||
$maquina = (new MaquinaModel())->find($maquina_id);
|
$maquina = (new MaquinaModel())->find($maquina_id);
|
||||||
if (!$maquina) {
|
if (!$maquina) {
|
||||||
@ -1864,7 +1891,8 @@ class PresupuestoService extends BaseService
|
|||||||
|
|
||||||
|
|
||||||
// Funcion que comprueba si existe un papel de impresion
|
// Funcion que comprueba si existe un papel de impresion
|
||||||
private static function checkPapelImpresion($papel_impresion_id){
|
private static function checkPapelImpresion($papel_impresion_id)
|
||||||
|
{
|
||||||
|
|
||||||
$papel = (new PapelImpresionModel())->find($papel_impresion_id);
|
$papel = (new PapelImpresionModel())->find($papel_impresion_id);
|
||||||
if (!$papel) {
|
if (!$papel) {
|
||||||
|
|||||||
@ -1,30 +1,36 @@
|
|||||||
<div class="col-12" style="min-height: 50px;">
|
<div class="col-12" style="min-height: 50px;">
|
||||||
<div id="btnsDiv" class="d-flex w-100 position-relative" style="margin-top: 40px;">
|
<div id="btnsDiv" class="d-flex w-100 position-relative" style="margin-top: 40px;">
|
||||||
|
|
||||||
<div class="me-auto">
|
<div class="me-auto">
|
||||||
<div id="btnPrint" class="btn mt-3 btn-secondary waves-effect waves-light ml-2 d-none">
|
<div id="btnPrint" class="btn mt-3 btn-secondary waves-effect waves-light ml-2 d-none">
|
||||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_print2') ?></span>
|
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_print2') ?></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="position-absolute start-50 translate-middle-x">
|
||||||
|
<?php if ($state != 2): ?>
|
||||||
|
<div id="btnPrev" class="btn mt-3 btn-primary waves-effect waves-light ml-2 d-none">
|
||||||
|
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_prev') ?></span>
|
||||||
|
</div>
|
||||||
|
<div id="btnNext" class="btn mt-3 btn-primary waves-effect waves-light ml-2">
|
||||||
|
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_next') ?></span>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ms-auto">
|
||||||
|
|
||||||
|
<?php if ($state != 2): ?>
|
||||||
|
|
||||||
|
<div id="btnConfirm" class="btn mt-3 btn-success waves-effect waves-light ml-2 d-none">
|
||||||
|
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_confirm') ?></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="btnSave" class="btn mt-3 btn-primary waves-effect waves-light ml-2 d-none">
|
||||||
|
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_save') ?></span>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="position-absolute start-50 translate-middle-x">
|
|
||||||
<div id="btnPrev" class="btn mt-3 btn-primary waves-effect waves-light ml-2 d-none">
|
|
||||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_prev') ?></span>
|
|
||||||
</div>
|
|
||||||
<div id="btnNext" class="btn mt-3 btn-primary waves-effect waves-light ml-2">
|
|
||||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_next') ?></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ms-auto">
|
|
||||||
<div id="btnConfirm" class="btn mt-3 btn-success waves-effect waves-light ml-2 d-none">
|
|
||||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_confirm') ?></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="btnSave" class="btn mt-3 btn-primary waves-effect waves-light ml-2 d-none">
|
|
||||||
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_save') ?></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
@ -16,14 +16,15 @@
|
|||||||
<label for="autor" class="form-label">
|
<label for="autor" class="form-label">
|
||||||
<?= lang('Presupuestos.autor') ?>
|
<?= lang('Presupuestos.autor') ?>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="autor" placeholder="Autor" name="autor" maxLength="150" class="form-control text-center" value="">
|
<input type="text" id="autor" placeholder="Autor" name="autor" maxLength="150" class="form-control text-center"
|
||||||
|
value="">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
|
|
||||||
<div class="col-sm-4 mb-3">
|
<div class="col-sm-4 mb-3">
|
||||||
<label for="isbn" class="form-label">
|
<label for="isbn" class="form-label">
|
||||||
<?=lang('Presupuestos.isbn') ?>
|
<?= lang('Presupuestos.isbn') ?>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="isbn" name="isbn" placeholder="ISBN" maxLength="50" class="form-control" value="">
|
<input type="text" id="isbn" name="isbn" placeholder="ISBN" maxLength="50" class="form-control" value="">
|
||||||
</div>
|
</div>
|
||||||
@ -32,14 +33,16 @@
|
|||||||
<label for="coleccion" class="form-label">
|
<label for="coleccion" class="form-label">
|
||||||
<?= lang('Presupuestos.coleccion') ?>
|
<?= lang('Presupuestos.coleccion') ?>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="coleccion" name="coleccion" placeholder="Coleccion" maxLength="255" class="form-control" value="">
|
<input type="text" id="coleccion" name="coleccion" placeholder="Coleccion" maxLength="255"
|
||||||
|
class="form-control" value="">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-4 mb-3">
|
<div class="col-sm-4 mb-3">
|
||||||
<label for="referenciaCliente" class="form-label">
|
<label for="referenciaCliente" class="form-label">
|
||||||
<?=lang('Presupuestos.referenciaCliente') ?>
|
<?= lang('Presupuestos.referenciaCliente') ?>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="referenciaCliente" name="referencia_cliente" placeholder="Referencia cliente" maxLength="100" class="form-control" value="">
|
<input type="text" id="referenciaCliente" name="referencia_cliente" placeholder="Referencia cliente"
|
||||||
|
maxLength="100" class="form-control" value="">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -47,20 +50,27 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="col-sm-5 mb-3 d-flex flex-column align-items-center">
|
<div class="col-sm-5 mb-3 d-flex flex-column align-items-center">
|
||||||
<label id="label_clienteId" for="clienteId" class="form-label">
|
<label <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
|
||||||
|
id="label_clienteId" for="clienteId" class="form-label">
|
||||||
Cliente*
|
Cliente*
|
||||||
</label>
|
</label>
|
||||||
<select id="clienteId" name="cliente_id" class="form-control select2bs2 calcular-presupuesto"
|
<select <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
|
||||||
|
id="clienteId" name="cliente_id" class="form-control select2bs2 calcular-presupuesto"
|
||||||
style="width: 100%;">
|
style="width: 100%;">
|
||||||
|
<?php if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')): ?>
|
||||||
|
<option value="<?= $clienteId ?>" selected>cliente</option>
|
||||||
|
<?php endif; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="row col-sm-5 mb-3 d-flex flex-column align-items-center">
|
<div class="row col-sm-5 mb-3 d-flex flex-column align-items-center">
|
||||||
<div class="form-check form-switch mb-2">
|
<div class="form-check form-switch mb-2">
|
||||||
<input class="calcular-presupuesto form-check-input" type="checkbox" id="excluirRotativa"
|
<input <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
|
||||||
|
class="calcular-presupuesto form-check-input" type="checkbox" id="excluirRotativa"
|
||||||
name="excluir_rotativa" value="1">
|
name="excluir_rotativa" value="1">
|
||||||
<label class="form-check-label" for="excluirRotativa">Excluir rotativa</label>
|
<label <?= (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))? " hidden" : "" ?>
|
||||||
|
class="form-check-label" for="excluirRotativa">Excluir rotativa</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -182,4 +182,25 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<?php if ($state == 2): ?>
|
||||||
|
<div class="col-12 mb-3">
|
||||||
|
<h3>Ficheros</h3>
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="dropzone needsclick" id="dropzone-multi">
|
||||||
|
<div class="dz-message needsclick">
|
||||||
|
Arrastre aquí los ficheros o haga click
|
||||||
|
</div>
|
||||||
|
<div class="fallback">
|
||||||
|
<input name="file" type="file" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button id="submit-all-files" class="btn mt-3 btn-primary btn-submit waves-effect waves-light ml-2">
|
||||||
|
<span class="align-middle d-sm-inline-block d-none me-sm-1">Actualizar ficheros</span>
|
||||||
|
<i class="ti ti-upload ti-xs"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
<div class="bs-stepper-header">
|
<div class="bs-stepper-header">
|
||||||
|
|
||||||
<div class="step active" data-target="#datos-generales">
|
<div <?= ($state == 2)? 'hidden': '' ?> class="step active titulos-menu" data-target="#datos-generales">
|
||||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||||
<span class="bs-stepper-circle"><i class="ti ti-info-circle ti-sm"></i></span>
|
<span class="bs-stepper-circle"><i class="ti ti-info-circle ti-sm"></i></span>
|
||||||
<span class="bs-stepper-label">
|
<span class="bs-stepper-label">
|
||||||
@ -38,7 +38,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="step" data-target="#interior-libro">
|
<div <?= ($state == 2)? 'hidden': '' ?> class="step titulos-menu" data-target="#interior-libro">
|
||||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||||
<span class="bs-stepper-circle"><i class="ti ti-book ti-sm"></i></span>
|
<span class="bs-stepper-circle"><i class="ti ti-book ti-sm"></i></span>
|
||||||
<span class="bs-stepper-label">
|
<span class="bs-stepper-label">
|
||||||
@ -47,7 +47,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="step" data-target="#cubierta-libro">
|
<div <?= ($state == 2)? 'hidden': '' ?> class="step titulos-menu" data-target="#cubierta-libro">
|
||||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||||
<span class="bs-stepper-circle"><i class="ti ti-books ti-sm"></i></span>
|
<span class="bs-stepper-circle"><i class="ti ti-books ti-sm"></i></span>
|
||||||
<span class="bs-stepper-label">
|
<span class="bs-stepper-label">
|
||||||
@ -56,7 +56,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="step" data-target="#direcciones-libro">
|
<div <?= ($state == 2)? 'hidden': '' ?> class="step titulos-menu" data-target="#direcciones-libro">
|
||||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||||
<span class="bs-stepper-circle"><i class="ti ti-map-pins ti-sm"></i></span>
|
<span class="bs-stepper-circle"><i class="ti ti-map-pins ti-sm"></i></span>
|
||||||
<span class="bs-stepper-label">
|
<span class="bs-stepper-label">
|
||||||
@ -65,7 +65,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="step" data-target="#resumen-libro">
|
<div id="menu_resumen_button" class="step titulos-menu" data-target="#resumen-libro">
|
||||||
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
|
||||||
<span class="bs-stepper-circle"><i class="ti ti-checkbox ti-sm"></i></span>
|
<span class="bs-stepper-circle"><i class="ti ti-checkbox ti-sm"></i></span>
|
||||||
<span class="bs-stepper-label">
|
<span class="bs-stepper-label">
|
||||||
@ -87,26 +87,30 @@
|
|||||||
|
|
||||||
<form id="presupuesto-cliente-form" onsubmit="return false">
|
<form id="presupuesto-cliente-form" onsubmit="return false">
|
||||||
|
|
||||||
<div id="datos-generales" class="content active dstepper-block fv-plugins-bootstrap5 fv-plugins-framework">
|
<div <?= ($state == 2) ? 'hidden' : '' ?> id="datos-generales"
|
||||||
|
class="content active dstepper-block fv-plugins-bootstrap5 fv-plugins-framework">
|
||||||
|
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<?= view("themes/vuexy/form/presupuestos/cliente/items/_datosGenerales") ?>
|
<?= view("themes/vuexy/form/presupuestos/cliente/items/_datosGenerales") ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="interior-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
<div <?= ($state == 2) ? 'hidden' : '' ?> id="interior-libro"
|
||||||
|
class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioInterior") ?>
|
<?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioInterior") ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="cubierta-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
<div <?= ($state == 2) ? 'hidden' : '' ?> id="cubierta-libro"
|
||||||
|
class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta") ?>
|
<?= view("themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta") ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="direcciones-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
<div <?= ($state == 2) ? 'hidden' : '' ?> id="direcciones-libro"
|
||||||
|
class="content fv-plugins-bootstrap5 fv-plugins-framework">
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<?= view("themes/vuexy/form/presupuestos/cliente/items/_direcciones") ?>
|
<?= view("themes/vuexy/form/presupuestos/cliente/items/_direcciones") ?>
|
||||||
</div>
|
</div>
|
||||||
@ -132,7 +136,9 @@
|
|||||||
<div id="form_buttons" class="row col-sm-12 justify-content-center" style="display: none;">
|
<div id="form_buttons" class="row col-sm-12 justify-content-center" style="display: none;">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<?= view("themes/vuexy/components/chat_internal_presupuesto",data:["modelId" => $presupuestoId,"type" => "presupuesto"]) ?>
|
<?php if ($formAction == 'edit'): ?>
|
||||||
|
<?= view("themes/vuexy/components/chat_internal_presupuesto", data: ["modelId" => $presupuestoId, "type" => "presupuesto"]) ?>
|
||||||
|
<?php endif; ?>
|
||||||
</div><!--//.row -->
|
</div><!--//.row -->
|
||||||
<?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?>
|
<?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?>
|
||||||
<?= view("themes/_commonPartialsBs/_modalMessageDialog") ?>
|
<?= view("themes/_commonPartialsBs/_modalMessageDialog") ?>
|
||||||
|
|||||||
@ -121,11 +121,11 @@ function calcular_mermas(){
|
|||||||
|
|
||||||
|
|
||||||
$('#papelFormatoPersonalizado').on("click",function(){
|
$('#papelFormatoPersonalizado').on("click",function(){
|
||||||
var checkbox = document.getElementById('papelFormatoPersonalizado');
|
|
||||||
if(checkbox.checked == true){
|
if($('#papelFormatoPersonalizado').is(':checked')){
|
||||||
document.getElementById("papelFormatoAncho").style.display = "block";
|
document.getElementById("papelFormatoAncho").style.display = "block";
|
||||||
document.getElementById("papelFormatoAlto").style.display = "block";
|
document.getElementById("papelFormatoAlto").style.display = "block";
|
||||||
$('#papelFormatoId').next(".select2-container").hide();
|
$('#papelFormatoId').hide();
|
||||||
$('#papelFormatoId').val(0).change();
|
$('#papelFormatoId').val(0).change();
|
||||||
document.getElementById("label_papelFormatoId").innerHTML =
|
document.getElementById("label_papelFormatoId").innerHTML =
|
||||||
window.Presupuestos.papelFormatoId + " (" +
|
window.Presupuestos.papelFormatoId + " (" +
|
||||||
@ -136,7 +136,7 @@ $('#papelFormatoPersonalizado').on("click",function(){
|
|||||||
document.getElementById("papelFormatoAlto").value= "";
|
document.getElementById("papelFormatoAlto").value= "";
|
||||||
document.getElementById("papelFormatoAncho").style.display = "none";
|
document.getElementById("papelFormatoAncho").style.display = "none";
|
||||||
document.getElementById("papelFormatoAlto").style.display = "none";
|
document.getElementById("papelFormatoAlto").style.display = "none";
|
||||||
$('#papelFormatoId').next(".select2-container").show();
|
$('#papelFormatoId').show();
|
||||||
document.getElementById("label_papelFormatoId").innerHTML =
|
document.getElementById("label_papelFormatoId").innerHTML =
|
||||||
window.Presupuestos.papelFormatoId + '*';
|
window.Presupuestos.papelFormatoId + '*';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
<?= lang('Presupuestos.papelFormatoId') ?>*
|
<?= lang('Presupuestos.papelFormatoId') ?>*
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<select id="papelFormatoId" name="papel_formato_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
|
<select id="papelFormatoId" <?= $presupuestoEntity->papel_formato_personalizado == false ? '' : 'style="display: none"'; ?> name="papel_formato_id" tabindex="3" class="form-control select2bs2" style="width: 100%;">
|
||||||
|
|
||||||
<?php if (isset($papelFormatoList) && is_array($papelFormatoList) && !empty($papelFormatoList)) :
|
<?php if (isset($papelFormatoList) && is_array($papelFormatoList) && !empty($papelFormatoList)) :
|
||||||
foreach ($papelFormatoList as $formato) : ?>
|
foreach ($papelFormatoList as $formato) : ?>
|
||||||
|
|||||||
@ -49,7 +49,6 @@
|
|||||||
<th><?= lang('TarifaEncuadernacionTiradas.proveedor') ?></th>
|
<th><?= lang('TarifaEncuadernacionTiradas.proveedor') ?></th>
|
||||||
<th><?= lang('TarifaEncuadernacionTiradas.tiradaMin') ?></th>
|
<th><?= lang('TarifaEncuadernacionTiradas.tiradaMin') ?></th>
|
||||||
<th><?= lang('TarifaEncuadernacionTiradas.tiradaMax') ?></th>
|
<th><?= lang('TarifaEncuadernacionTiradas.tiradaMax') ?></th>
|
||||||
<th><?= lang('Tarifaencuadernacion.importeMin') ?></th>
|
|
||||||
<th><?= lang('Tarifaencuadernacion.importeFijo') ?></th>
|
<th><?= lang('Tarifaencuadernacion.importeFijo') ?></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -83,6 +82,7 @@
|
|||||||
<th><?= lang('TarifaEncuadernacionLineas.precioMin') ?></th>
|
<th><?= lang('TarifaEncuadernacionLineas.precioMin') ?></th>
|
||||||
<th><?= lang('TarifaEncuadernacionLineas.paginasMax') ?></th>
|
<th><?= lang('TarifaEncuadernacionLineas.paginasMax') ?></th>
|
||||||
<th><?= lang('TarifaEncuadernacionLineas.precioMax') ?></th>
|
<th><?= lang('TarifaEncuadernacionLineas.precioMax') ?></th>
|
||||||
|
<th><?= lang('Tarifaencuadernacion.importeMin') ?></th>
|
||||||
<th><?= lang('TarifaEncuadernacionLineas.margen') ?></th>
|
<th><?= lang('TarifaEncuadernacionLineas.margen') ?></th>
|
||||||
<th style="min-width:100px"></th>
|
<th style="min-width:100px"></th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -112,6 +112,7 @@
|
|||||||
<th><?= lang('TarifaEncuadernacionLineas.tiempoMin') ?></th>
|
<th><?= lang('TarifaEncuadernacionLineas.tiempoMin') ?></th>
|
||||||
<th><?= lang('TarifaEncuadernacionLineas.tiempoMax') ?></th>
|
<th><?= lang('TarifaEncuadernacionLineas.tiempoMax') ?></th>
|
||||||
<th><?= lang('TarifaEncuadernacionLineas.precioHora') ?></th>
|
<th><?= lang('TarifaEncuadernacionLineas.precioHora') ?></th>
|
||||||
|
<th><?= lang('Tarifaencuadernacion.importeMin') ?></th>
|
||||||
<th><?= lang('TarifaEncuadernacionLineas.margen') ?></th>
|
<th><?= lang('TarifaEncuadernacionLineas.margen') ?></th>
|
||||||
<th style="min-width:100px"></th>
|
<th style="min-width:100px"></th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -298,6 +299,8 @@
|
|||||||
name: "tiempo_max"
|
name: "tiempo_max"
|
||||||
}, {
|
}, {
|
||||||
name: "precio_hora"
|
name: "precio_hora"
|
||||||
|
}, {
|
||||||
|
name: "total_min"
|
||||||
}, {
|
}, {
|
||||||
name: "margen"
|
name: "margen"
|
||||||
}, {
|
}, {
|
||||||
@ -366,6 +369,7 @@
|
|||||||
{ 'data': 'tiempo_min' },
|
{ 'data': 'tiempo_min' },
|
||||||
{ 'data': 'tiempo_max' },
|
{ 'data': 'tiempo_max' },
|
||||||
{ 'data': 'precio_hora' },
|
{ 'data': 'precio_hora' },
|
||||||
|
{ 'data': 'total_min' },
|
||||||
{ 'data': 'margen' },
|
{ 'data': 'margen' },
|
||||||
{
|
{
|
||||||
data: actionBtns,
|
data: actionBtns,
|
||||||
@ -477,6 +481,8 @@
|
|||||||
name: "paginas_libro_max"
|
name: "paginas_libro_max"
|
||||||
}, {
|
}, {
|
||||||
name: "precio_max"
|
name: "precio_max"
|
||||||
|
}, {
|
||||||
|
name: "total_min"
|
||||||
}, {
|
}, {
|
||||||
name: "margen"
|
name: "margen"
|
||||||
}, {
|
}, {
|
||||||
@ -556,6 +562,7 @@
|
|||||||
{ 'data': 'precio_max' },
|
{ 'data': 'precio_max' },
|
||||||
{ 'data': 'paginas_libro_max' },
|
{ 'data': 'paginas_libro_max' },
|
||||||
{ 'data': 'precio_min' },
|
{ 'data': 'precio_min' },
|
||||||
|
{ 'data': 'total_min' },
|
||||||
{ 'data': 'margen' },
|
{ 'data': 'margen' },
|
||||||
{
|
{
|
||||||
data: actionBtns,
|
data: actionBtns,
|
||||||
@ -661,8 +668,6 @@
|
|||||||
name: "tirada_min"
|
name: "tirada_min"
|
||||||
}, {
|
}, {
|
||||||
name: "tirada_max"
|
name: "tirada_max"
|
||||||
}, {
|
|
||||||
name: "precio_min"
|
|
||||||
}, {
|
}, {
|
||||||
name: "importe_fijo"
|
name: "importe_fijo"
|
||||||
}, {
|
}, {
|
||||||
@ -746,7 +751,6 @@
|
|||||||
},
|
},
|
||||||
{ 'data': 'tirada_min' },
|
{ 'data': 'tirada_min' },
|
||||||
{ 'data': 'tirada_max' },
|
{ 'data': 'tirada_max' },
|
||||||
{ 'data': 'precio_min' },
|
|
||||||
{ 'data': 'importe_fijo' },
|
{ 'data': 'importe_fijo' },
|
||||||
{
|
{
|
||||||
data: actionBtns,
|
data: actionBtns,
|
||||||
|
|||||||
@ -98,7 +98,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
theTable.on( 'draw.dt', function () {
|
theTable.on( 'draw.dt', function () {
|
||||||
const boolCols = [1,2,3];
|
const boolCols = [1,2,3, 4];
|
||||||
for (let coln of boolCols) {
|
for (let coln of boolCols) {
|
||||||
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
|
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
|
||||||
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
|
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
|
||||||
|
|||||||
@ -482,6 +482,9 @@ export const showNotificationMessages = (dom) => {
|
|||||||
if(data.totalMessages > 0){
|
if(data.totalMessages > 0){
|
||||||
$("#chat-notification-number").removeClass("d-none")
|
$("#chat-notification-number").removeClass("d-none")
|
||||||
$("#chat-notification-number").text(data.totalMessages ?? 0)
|
$("#chat-notification-number").text(data.totalMessages ?? 0)
|
||||||
|
}else{
|
||||||
|
$("#chat-notification-number").addClass("d-none")
|
||||||
|
$("#chat-notification-number").text(0)
|
||||||
}
|
}
|
||||||
data?.internals?.map((e) => {
|
data?.internals?.map((e) => {
|
||||||
let numberOfMessages = e.unreadMessages
|
let numberOfMessages = e.unreadMessages
|
||||||
@ -509,7 +512,7 @@ export const showNotificationMessages = (dom) => {
|
|||||||
dom.append(
|
dom.append(
|
||||||
`
|
`
|
||||||
<li class="">
|
<li class="">
|
||||||
<a href="/presupuestos/cosidotapablanda/edit/${e.presupuestoId}" class="d-flex align-items-center flex-grow">
|
<a href="${e.uri}" class="d-flex align-items-center flex-grow">
|
||||||
<div class="avatar d-block flex-shrink-0">
|
<div class="avatar d-block flex-shrink-0">
|
||||||
<span class="avatar-initial rounded-circle bg-label-primary">${e.presupuestoId}</span>
|
<span class="avatar-initial rounded-circle bg-label-primary">${e.presupuestoId}</span>
|
||||||
</div>
|
</div>
|
||||||
@ -529,7 +532,7 @@ export const showNotificationMessages = (dom) => {
|
|||||||
dom.append(
|
dom.append(
|
||||||
`
|
`
|
||||||
<li class="">
|
<li class="">
|
||||||
<a href="/facturas/edit/${e.facturaId}" class="d-flex align-items-center flex-grow">
|
<a href="${e.uri}" class="d-flex align-items-center flex-grow">
|
||||||
<div class="avatar d-block flex-shrink-0">
|
<div class="avatar d-block flex-shrink-0">
|
||||||
<span class="avatar-initial rounded-circle bg-label-primary">${e.facturaId}</span>
|
<span class="avatar-initial rounded-circle bg-label-primary">${e.facturaId}</span>
|
||||||
</div>
|
</div>
|
||||||
@ -549,7 +552,7 @@ export const showNotificationMessages = (dom) => {
|
|||||||
dom.append(
|
dom.append(
|
||||||
`
|
`
|
||||||
<li class="">
|
<li class="">
|
||||||
<a href="/pedidos/edit/${e.pedidoId}" class="d-flex align-items-center flex-grow">
|
<a href="${e.uri}" class="d-flex align-items-center flex-grow">
|
||||||
<div class="avatar d-block flex-shrink-0">
|
<div class="avatar d-block flex-shrink-0">
|
||||||
<span class="avatar-initial rounded-circle bg-label-primary">${e.pedidoId}</span>
|
<span class="avatar-initial rounded-circle bg-label-primary">${e.pedidoId}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -29,9 +29,14 @@ class ErrorPresupuestoView {
|
|||||||
init() {
|
init() {
|
||||||
this.datatable = this.datatableItem.DataTable({
|
this.datatable = this.datatableItem.DataTable({
|
||||||
processing: true,
|
processing: true,
|
||||||
dom: 'Brtip',
|
layout :{
|
||||||
|
topStart: 'pageLength',
|
||||||
|
topEnd: 'search',
|
||||||
|
bottomStart: 'info',
|
||||||
|
bottomEnd: 'paging'
|
||||||
|
},
|
||||||
serverSide: true,
|
serverSide: true,
|
||||||
|
pageLength : 50,
|
||||||
language: {
|
language: {
|
||||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,7 +5,9 @@ import tarjetaTiradasPrecio from './tarjetaTiradasPrecio.js';
|
|||||||
class DatosGenerales {
|
class DatosGenerales {
|
||||||
|
|
||||||
constructor(domItem, wizardForm, validatorStepper) {
|
constructor(domItem, wizardForm, validatorStepper) {
|
||||||
|
|
||||||
this.domItem = domItem;
|
this.domItem = domItem;
|
||||||
|
this.allowNext = true;
|
||||||
|
|
||||||
this.wizardStep = wizardForm.querySelector('#datos-generales');
|
this.wizardStep = wizardForm.querySelector('#datos-generales');
|
||||||
this.validatorStepper = validatorStepper;
|
this.validatorStepper = validatorStepper;
|
||||||
@ -64,6 +66,7 @@ class DatosGenerales {
|
|||||||
this.formatoLibro.init();
|
this.formatoLibro.init();
|
||||||
this.cliente.init();
|
this.cliente.init();
|
||||||
|
|
||||||
|
|
||||||
// Inicializa el tipo de impresion
|
// Inicializa el tipo de impresion
|
||||||
this.#handlePaginas();
|
this.#handlePaginas();
|
||||||
|
|
||||||
@ -98,6 +101,8 @@ class DatosGenerales {
|
|||||||
message: window.translations["validation"].cliente,
|
message: window.translations["validation"].cliente,
|
||||||
callback: function (input) {
|
callback: function (input) {
|
||||||
// Get the selected options
|
// Get the selected options
|
||||||
|
if (!$(this.excluirRotativa).prop('hidden'))
|
||||||
|
return true;
|
||||||
const options = $("#clienteId").select2('data');
|
const options = $("#clienteId").select2('data');
|
||||||
const hasValidOption = options.some(option => parseInt(option.id) > 0);
|
const hasValidOption = options.some(option => parseInt(option.id) > 0);
|
||||||
return options !== null && options.length > 0 && hasValidOption;
|
return options !== null && options.length > 0 && hasValidOption;
|
||||||
@ -116,25 +121,25 @@ class DatosGenerales {
|
|||||||
const value4 = $("#tirada4").val();
|
const value4 = $("#tirada4").val();
|
||||||
let tiradas = [value];
|
let tiradas = [value];
|
||||||
|
|
||||||
if(!(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0)){
|
if (!(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0)) {
|
||||||
return {
|
return {
|
||||||
valid: false,
|
valid: false,
|
||||||
message: window.translations["validation"].integer_greatherThan_0,
|
message: window.translations["validation"].integer_greatherThan_0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if(value2.length > 0 && Number.isInteger(parseInt(value2)) && parseInt(value2) > 0){
|
if (value2.length > 0 && Number.isInteger(parseInt(value2)) && parseInt(value2) > 0) {
|
||||||
tiradas.push(value2);
|
tiradas.push(value2);
|
||||||
}
|
}
|
||||||
if(value3.length > 0 && Number.isInteger(parseInt(value3)) && parseInt(value3) > 0){
|
if (value3.length > 0 && Number.isInteger(parseInt(value3)) && parseInt(value3) > 0) {
|
||||||
tiradas.push(value3);
|
tiradas.push(value3);
|
||||||
}
|
}
|
||||||
if(value4.length > 0 && Number.isInteger(parseInt(value4)) && parseInt(value4) > 0){
|
if (value4.length > 0 && Number.isInteger(parseInt(value4)) && parseInt(value4) > 0) {
|
||||||
tiradas.push(value4);
|
tiradas.push(value4);
|
||||||
}
|
}
|
||||||
// comprobar si hay valores > 30
|
// comprobar si hay valores > 30
|
||||||
const noPOD = (tiradas.some(tirada => parseInt(tirada) > 30));
|
const noPOD = (tiradas.some(tirada => parseInt(tirada) > 30));
|
||||||
const siPOD = (tiradas.some(tirada => parseInt(tirada) <= 30));
|
const siPOD = (tiradas.some(tirada => parseInt(tirada) <= 30));
|
||||||
if(noPOD && siPOD){
|
if (noPOD && siPOD) {
|
||||||
return {
|
return {
|
||||||
valid: false,
|
valid: false,
|
||||||
message: "No se pueden mezclar tiradas <30 con >30",
|
message: "No se pueden mezclar tiradas <30 con >30",
|
||||||
@ -367,7 +372,8 @@ class DatosGenerales {
|
|||||||
submitButton: new FormValidation.plugins.SubmitButton()
|
submitButton: new FormValidation.plugins.SubmitButton()
|
||||||
}
|
}
|
||||||
}).on('core.form.valid', () => {
|
}).on('core.form.valid', () => {
|
||||||
stepper.next();
|
if (this.allowNext)
|
||||||
|
stepper.next();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,6 +437,12 @@ class DatosGenerales {
|
|||||||
this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change');
|
this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCliente() {
|
||||||
|
if ($(this.excluirRotativa).prop('hidden'))
|
||||||
|
return $('#clienteId').val();
|
||||||
|
return this.cliente.getVal();
|
||||||
|
}
|
||||||
|
|
||||||
getDimensionLibro() {
|
getDimensionLibro() {
|
||||||
|
|
||||||
let ancho = 0;
|
let ancho = 0;
|
||||||
@ -511,7 +523,7 @@ class DatosGenerales {
|
|||||||
if (this.fresado.hasClass('selected') || this.cosido.hasClass('selected')) {
|
if (this.fresado.hasClass('selected') || this.cosido.hasClass('selected')) {
|
||||||
$('#tapaDuraLomoRedondo').removeClass('d-none');
|
$('#tapaDuraLomoRedondo').removeClass('d-none');
|
||||||
if (this.cosido.hasClass('selected')) {
|
if (this.cosido.hasClass('selected')) {
|
||||||
$('#tapaDuraLomoRedondo').addClass('selected');
|
//$('#tapaDuraLomoRedondo').addClass('selected');
|
||||||
this.divPaginasCuaderillo.removeClass('d-none');
|
this.divPaginasCuaderillo.removeClass('d-none');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -528,8 +540,8 @@ class DatosGenerales {
|
|||||||
$('#addSobrecubierta').prop('checked', false).trigger('change');
|
$('#addSobrecubierta').prop('checked', false).trigger('change');
|
||||||
$(".sobrecubierta-items").addClass('d-none');
|
$(".sobrecubierta-items").addClass('d-none');
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
if($('#addSobrecubierta').hasClass('d-none')){
|
if ($('#addSobrecubierta').hasClass('d-none')) {
|
||||||
$('#addSobrecubierta').removeClass('d-none');
|
$('#addSobrecubierta').removeClass('d-none');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ class Direcciones {
|
|||||||
this.domItem = domItem;
|
this.domItem = domItem;
|
||||||
this.wizardStep = wizardForm.querySelector('#direcciones-libro');
|
this.wizardStep = wizardForm.querySelector('#direcciones-libro');
|
||||||
this.validatorStepper = validatorStepper;
|
this.validatorStepper = validatorStepper;
|
||||||
|
this.allowNext = true;
|
||||||
|
|
||||||
this.unidadesAdd = this.domItem.find('#unidadesEnvio');
|
this.unidadesAdd = this.domItem.find('#unidadesEnvio');
|
||||||
this.btnAdd = this.domItem.find('#insertarDireccion');
|
this.btnAdd = this.domItem.find('#insertarDireccion');
|
||||||
@ -94,13 +95,13 @@ class Direcciones {
|
|||||||
|
|
||||||
let peticion = new Ajax('/misdirecciones/getDireccionPresupuesto/' + id, {}, {},
|
let peticion = new Ajax('/misdirecciones/getDireccionPresupuesto/' + id, {}, {},
|
||||||
(response) => {
|
(response) => {
|
||||||
let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]);
|
let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]);
|
||||||
tarjeta.setUnidades(unidades);
|
tarjeta.setUnidades(unidades);
|
||||||
tarjeta.setEntregaPalets(entregaPalets);
|
tarjeta.setEntregaPalets(entregaPalets);
|
||||||
tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self));
|
tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self));
|
||||||
tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self));
|
tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self));
|
||||||
this.divDirecciones.append(tarjeta.card);
|
this.divDirecciones.append(tarjeta.card);
|
||||||
this.direcciones.push(tarjeta);
|
this.direcciones.push(tarjeta);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
console.error('Error getting address');
|
console.error('Error getting address');
|
||||||
@ -124,7 +125,7 @@ class Direcciones {
|
|||||||
validators: {
|
validators: {
|
||||||
callback: {
|
callback: {
|
||||||
callback: () => {
|
callback: () => {
|
||||||
const div = $('#divErrorEnvios'); // Selecciona el div
|
/* const div = $('#divErrorEnvios'); // Selecciona el div
|
||||||
|
|
||||||
div.find('.fv-plugins-message-container').remove();
|
div.find('.fv-plugins-message-container').remove();
|
||||||
|
|
||||||
@ -148,6 +149,8 @@ class Direcciones {
|
|||||||
</div>
|
</div>
|
||||||
`);
|
`);
|
||||||
return false;
|
return false;
|
||||||
|
*/
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +178,8 @@ class Direcciones {
|
|||||||
submitButton: new FormValidation.plugins.SubmitButton()
|
submitButton: new FormValidation.plugins.SubmitButton()
|
||||||
}
|
}
|
||||||
}).on('core.form.valid', () => {
|
}).on('core.form.valid', () => {
|
||||||
stepper.next();
|
if (this.allowNext)
|
||||||
|
stepper.next();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
class DisenioCubierta {
|
class DisenioCubierta {
|
||||||
|
|
||||||
constructor(domItem, wizardForm, validatorStepper) {
|
constructor(domItem, wizardForm, validatorStepper) {
|
||||||
|
|
||||||
this.domItem = domItem;
|
this.domItem = domItem;
|
||||||
|
this.allowNext = true;
|
||||||
|
|
||||||
this.wizardStep = wizardForm.querySelector('#cubierta-libro');
|
this.wizardStep = wizardForm.querySelector('#cubierta-libro');
|
||||||
this.validatorStepper = validatorStepper;
|
this.validatorStepper = validatorStepper;
|
||||||
@ -174,7 +176,7 @@ class DisenioCubierta {
|
|||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(datosSobrecubierta && datosSobrecubierta.papel) {
|
if (datosSobrecubierta && datosSobrecubierta.papel) {
|
||||||
this.sobrecubierta.trigger('click');
|
this.sobrecubierta.trigger('click');
|
||||||
this.papelSobrecubierta.val(datosSobrecubierta.papel.code + "_" + datosSobrecubierta.gramaje).trigger('change');
|
this.papelSobrecubierta.val(datosSobrecubierta.papel.code + "_" + datosSobrecubierta.gramaje).trigger('change');
|
||||||
this.solapasSobrecubierta.val(datosSobrecubierta.solapas_ancho);
|
this.solapasSobrecubierta.val(datosSobrecubierta.solapas_ancho);
|
||||||
@ -313,7 +315,8 @@ class DisenioCubierta {
|
|||||||
submitButton: new FormValidation.plugins.SubmitButton()
|
submitButton: new FormValidation.plugins.SubmitButton()
|
||||||
}
|
}
|
||||||
}).on('core.form.valid', () => {
|
}).on('core.form.valid', () => {
|
||||||
stepper.next();
|
if (this.allowNext)
|
||||||
|
stepper.next();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ class DisenioInterior {
|
|||||||
|
|
||||||
this.wizardStep = wizardForm.querySelector('#interior-libro');
|
this.wizardStep = wizardForm.querySelector('#interior-libro');
|
||||||
this.validatorStepper = validatorStepper;
|
this.validatorStepper = validatorStepper;
|
||||||
|
this.allowNext = true;
|
||||||
|
|
||||||
this.disenioInterior = this.domItem.find(".disenio-interior");
|
this.disenioInterior = this.domItem.find(".disenio-interior");
|
||||||
this.divPapelInterior = this.domItem.find("#divPapelInterior");
|
this.divPapelInterior = this.domItem.find("#divPapelInterior");
|
||||||
@ -364,7 +365,8 @@ class DisenioInterior {
|
|||||||
submitButton: new FormValidation.plugins.SubmitButton()
|
submitButton: new FormValidation.plugins.SubmitButton()
|
||||||
}
|
}
|
||||||
}).on('core.form.valid', () => {
|
}).on('core.form.valid', () => {
|
||||||
stepper.next();
|
if (this.allowNext)
|
||||||
|
stepper.next();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,8 @@ class PresupuestoCliente {
|
|||||||
|
|
||||||
this.divTiradasPrecios = $("#divTiradasPrecio");
|
this.divTiradasPrecios = $("#divTiradasPrecio");
|
||||||
|
|
||||||
|
this.titulosMenu = $(".titulos-menu");
|
||||||
|
|
||||||
this.datos = {};
|
this.datos = {};
|
||||||
this.ajax_calcular = new Ajax('/presupuestocliente/calcular',
|
this.ajax_calcular = new Ajax('/presupuestocliente/calcular',
|
||||||
{}, this.datos,
|
{}, this.datos,
|
||||||
@ -59,11 +61,26 @@ class PresupuestoCliente {
|
|||||||
this.disenioInterior.init();
|
this.disenioInterior.init();
|
||||||
this.disenioCubierta.init();
|
this.disenioCubierta.init();
|
||||||
this.direcciones.init();
|
this.direcciones.init();
|
||||||
|
if (window.location.href.includes("edit")) {
|
||||||
|
this.resumen.init(window.location.href.split("/").pop());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.resumen.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (this.datosGenerales.excluirRotativa.length == 0) {
|
||||||
|
|
||||||
|
this.direcciones.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").val() })
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.btnNext.on('click', this.#nextStep.bind(this));
|
this.btnNext.on('click', this.#nextStep.bind(this));
|
||||||
this.btnPrev.on('click', this.#prevtStep.bind(this));
|
this.btnPrev.on('click', this.#prevtStep.bind(this));
|
||||||
this.btnSave.on('click', this.#savePresupuesto.bind(this));
|
this.btnSave.on('click', this.#savePresupuesto.bind(this));
|
||||||
|
this.btnConfirm.on('click', this.#confirmPresupuesto.bind(this));
|
||||||
|
|
||||||
|
this.titulosMenu.on('click', this.#handleTitulosMenu.bind(this));
|
||||||
|
|
||||||
if (window.location.href.includes("edit")) {
|
if (window.location.href.includes("edit")) {
|
||||||
|
|
||||||
@ -145,9 +162,21 @@ class PresupuestoCliente {
|
|||||||
if (datos_to_check.direcciones) {
|
if (datos_to_check.direcciones) {
|
||||||
delete datos_to_check.direcciones;
|
delete datos_to_check.direcciones;
|
||||||
}
|
}
|
||||||
if (datos_to_check.posPaginasColor) {
|
if (datos_to_check.posPaginasColor == "" || datos_to_check.posPaginasColor == null) {
|
||||||
delete datos_to_check.posPaginasColor;
|
delete datos_to_check.posPaginasColor;
|
||||||
}
|
}
|
||||||
|
if (datos_to_check.cubierta.acabados.barniz == undefined) {
|
||||||
|
delete datos_to_check.cubierta.acabados.barniz;
|
||||||
|
}
|
||||||
|
if (datos_to_check.cubierta.acabados.plastificado == undefined) {
|
||||||
|
delete datos_to_check.cubierta.acabados.plastificado;
|
||||||
|
}
|
||||||
|
if (datos_to_check.cubierta.acabados.estampado == undefined) {
|
||||||
|
delete datos_to_check.cubierta.acabados.estampado;
|
||||||
|
}
|
||||||
|
if (datos_to_check.sobrecubierta.plastificado == undefined) {
|
||||||
|
delete datos_to_check.sobrecubierta.plastificado;
|
||||||
|
}
|
||||||
|
|
||||||
if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
|
if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
|
||||||
try {
|
try {
|
||||||
@ -172,61 +201,134 @@ class PresupuestoCliente {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#handleTitulosMenu(event) {
|
||||||
|
|
||||||
/*RELLENAR_PRESUPUESTO(finalizar) {
|
$('.titulos-menu').removeClass('crossed');
|
||||||
|
|
||||||
if (finalizar) {
|
const nextElement = $(event.target).attr('data-target')
|
||||||
|
const currentElement = $('.dstepper-block.active').attr('id');
|
||||||
|
|
||||||
$("#titulo").val("Titulo del libro");
|
if (currentElement === nextElement) {
|
||||||
$("#titulo").trigger('change');
|
return;
|
||||||
|
}
|
||||||
const clienteId = $("#clienteId");
|
|
||||||
const newOption = new Option("Cliente Potencial", "1817", true, true);
|
|
||||||
clienteId.append(newOption).trigger('change');
|
|
||||||
|
|
||||||
const papelFormatoId = $("#papelFormatoId");
|
|
||||||
const newOption2 = new Option("148 x 210", "1", true, true);
|
|
||||||
papelFormatoId.append(newOption2).trigger('change');
|
|
||||||
|
|
||||||
|
|
||||||
$("#paginasColor").val("6");
|
|
||||||
$("#paginasColor").trigger('change');
|
|
||||||
|
|
||||||
$("#fresado").trigger("click");
|
|
||||||
|
|
||||||
|
|
||||||
$("#colorPremium").trigger("click");
|
|
||||||
$("#offsetBlanco").trigger("click");
|
|
||||||
|
|
||||||
setTimeout(function () {
|
|
||||||
$("#gramaje90").trigger("click");
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
setTimeout(function () {
|
|
||||||
$("#tapaDura").trigger("click");
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
|
|
||||||
setTimeout(function () {
|
|
||||||
$("#btnNext").trigger("click");
|
|
||||||
}, 0);
|
|
||||||
setTimeout(function () {
|
|
||||||
$("#btnNext").trigger("click");
|
|
||||||
}, 0);
|
|
||||||
setTimeout(function () {
|
|
||||||
$("#btnNext").trigger("click");
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
|
|
||||||
setTimeout(function () {
|
|
||||||
$("#unidadesEnvio").val("50");
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
|
if (currentElement !== 'resumen-libro') {
|
||||||
|
this.#validateCurrentForm(currentElement, nextElement);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$("#titulo").trigger('change');
|
this.#goToForm(nextElement);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
#goToForm(form) {
|
||||||
|
|
||||||
|
switch (form) {
|
||||||
|
case '#datos-generales':
|
||||||
|
this.validationStepper.to(1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '#interior-libro':
|
||||||
|
this.validationStepper.to(2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '#cubierta-libro':
|
||||||
|
this.validationStepper.to(3);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '#direcciones-libro':
|
||||||
|
this.validationStepper.to(4);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '#resumen-libro':
|
||||||
|
this.validationStepper.to(5);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#validateCurrentForm(form, nextForm) {
|
||||||
|
|
||||||
|
switch (form) {
|
||||||
|
case 'datos-generales':
|
||||||
|
this.datosGenerales.allowNext = false;
|
||||||
|
validateForm(this.datosGenerales.formValidation).then((status) => {
|
||||||
|
if (status !== 'Valid') {
|
||||||
|
this.datosGenerales.allowNext = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.#goToForm(nextForm);
|
||||||
|
this.datosGenerales.allowNext = true;
|
||||||
|
return true;
|
||||||
|
}).catch(error => {
|
||||||
|
this.datosGenerales.allowNext = true;
|
||||||
|
console.error('Error al validar:', error);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'interior-libro':
|
||||||
|
this.disenioInterior.allowNext = false;
|
||||||
|
validateForm(this.disenioInterior.formValidation).then((status) => {
|
||||||
|
if (status !== 'Valid') {
|
||||||
|
this.disenioInterior.allowNext = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.#goToForm(nextForm);
|
||||||
|
this.disenioInterior.allowNext = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
).catch(error => {
|
||||||
|
this.disenioInterior.allowNext = true;
|
||||||
|
console.error('Error al validar:', error);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'cubierta-libro':
|
||||||
|
this.disenioCubierta.allowNext = false;
|
||||||
|
validateForm(this.disenioCubierta.formValidation).then((status) => {
|
||||||
|
if (status !== 'Valid') {
|
||||||
|
this.disenioCubierta.allowNext = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.#goToForm(nextForm);
|
||||||
|
this.disenioCubierta.allowNext = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
).catch(error => {
|
||||||
|
this.disenioCubierta.allowNext = true;
|
||||||
|
console.error('Error al validar:', error);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'direcciones-libro':
|
||||||
|
this.direcciones.allowNext = false;
|
||||||
|
validateForm(this.direcciones.formValidation).then((status) => {
|
||||||
|
if (status !== 'Valid') {
|
||||||
|
this.direcciones.allowNext = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.#goToForm(nextForm);
|
||||||
|
this.direcciones.allowNext = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
).catch(error => {
|
||||||
|
this.direcciones.allowNext = true;
|
||||||
|
console.error('Error al validar:', error);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
stepperHandler() {
|
stepperHandler() {
|
||||||
@ -267,10 +369,27 @@ class PresupuestoCliente {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#confirmPresupuesto() {
|
||||||
|
|
||||||
|
this.#solicitudGuardarPresupuesto(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#savePresupuesto() {
|
#savePresupuesto() {
|
||||||
|
|
||||||
|
this.#solicitudGuardarPresupuesto(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#solicitudGuardarPresupuesto(confirmar = false) {
|
||||||
|
|
||||||
this.#getDatos(true);
|
this.#getDatos(true);
|
||||||
|
|
||||||
|
if (confirmar) {
|
||||||
|
this.datos["confirmar"] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$('#loader').modal('show');
|
$('#loader').modal('show');
|
||||||
|
|
||||||
@ -292,7 +411,11 @@ class PresupuestoCliente {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
popSuccessAlert(response.message);
|
if (response.error) {
|
||||||
|
popErrorAlert("No se ha podido guardar el presupuesto. Por favor, póngase en contacto con el departamento comercial.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
popSuccessAlert(response.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
() => { $('#loader').modal('hide'); }
|
() => { $('#loader').modal('hide'); }
|
||||||
@ -352,7 +475,7 @@ class PresupuestoCliente {
|
|||||||
$(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click');
|
$(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click');
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
$('#loader').modal('hide');
|
||||||
// DEBUG
|
// DEBUG
|
||||||
//console.log(response);
|
//console.log(response);
|
||||||
}
|
}
|
||||||
@ -395,7 +518,7 @@ class PresupuestoCliente {
|
|||||||
|
|
||||||
this.datos = {
|
this.datos = {
|
||||||
|
|
||||||
clienteId: this.datosGenerales.cliente.getVal(),
|
clienteId: this.datosGenerales.getCliente(),
|
||||||
|
|
||||||
tamanio: this.datosGenerales.getDimensionLibro(),
|
tamanio: this.datosGenerales.getDimensionLibro(),
|
||||||
tirada: this.datosGenerales.getTiradas(),
|
tirada: this.datosGenerales.getTiradas(),
|
||||||
@ -420,7 +543,6 @@ class PresupuestoCliente {
|
|||||||
|
|
||||||
cubierta: {
|
cubierta: {
|
||||||
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
|
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
|
||||||
lomoRedondo: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id').includes('Redondo') ? 1 : 0,
|
|
||||||
papelCubierta: this.disenioCubierta.getPapel(),
|
papelCubierta: this.disenioCubierta.getPapel(),
|
||||||
gramajeCubierta: this.disenioCubierta.getGramaje(),
|
gramajeCubierta: this.disenioCubierta.getGramaje(),
|
||||||
cabezada: this.disenioCubierta.getCabezada(),
|
cabezada: this.disenioCubierta.getCabezada(),
|
||||||
@ -438,6 +560,10 @@ class PresupuestoCliente {
|
|||||||
'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
|
'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
let lomoRedondo = 0;
|
||||||
|
if (this.disenioCubierta.disenioCubierta.filter('.selected').length > 0)
|
||||||
|
lomoRedondo = this.disenioCubierta.disenioCubierta.filter('.selected').attr('id').includes('Redondo') ? 1 : 0;
|
||||||
|
this.datos.cubierta.lomoRedondo = lomoRedondo;
|
||||||
|
|
||||||
if (this.datos.tipo == "cosido") {
|
if (this.datos.tipo == "cosido") {
|
||||||
this.datos.paginasCuadernillo = this.datosGenerales.paginasCuadernillo.val();
|
this.datos.paginasCuadernillo = this.datosGenerales.paginasCuadernillo.val();
|
||||||
@ -498,14 +624,27 @@ class PresupuestoCliente {
|
|||||||
|
|
||||||
this.datosGenerales.cargarDatos(response.data.datosGenerales);
|
this.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||||
this.direcciones.handleChangeCliente();
|
this.direcciones.handleChangeCliente();
|
||||||
|
|
||||||
this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
|
this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
|
||||||
this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
|
this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
|
||||||
this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
||||||
$('#loader').modal('hide');
|
$('#loader').modal('hide');
|
||||||
this.calcularPresupuesto = true;
|
|
||||||
this.checkForm({ target: { id: 'tirada' } });
|
if (response.data.state != 2) {
|
||||||
|
|
||||||
|
this.calcularPresupuesto = true;
|
||||||
|
this.checkForm({ target: { id: 'tirada' } });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#menu_resumen_button').trigger('click');
|
||||||
|
setTimeout(() => {
|
||||||
|
this.resumen.init_dropzone();
|
||||||
|
this.resumen.generate_total(response.data.resumen.base, response.data.resumen.precio_unidad);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -530,6 +669,16 @@ class PresupuestoCliente {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function validateForm(formValidation) {
|
||||||
|
try {
|
||||||
|
const validationResult = await formValidation.validate();
|
||||||
|
return validationResult;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error durante la validación:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function isValid(value) {
|
function isValid(value) {
|
||||||
if (value === null || value === undefined || value === '') {
|
if (value === null || value === undefined || value === '') {
|
||||||
|
|||||||
@ -53,13 +53,134 @@ class Resumen {
|
|||||||
this.divPreview = $(this.domItem.find("#pv_ec_shape"));
|
this.divPreview = $(this.domItem.find("#pv_ec_shape"));
|
||||||
this.btnPreviewCubierta = $(this.domItem.find("#btnPreviewCubierta"));
|
this.btnPreviewCubierta = $(this.domItem.find("#btnPreviewCubierta"));
|
||||||
|
|
||||||
this.init();
|
this.submitFiles = $(this.domItem.find("#submit-all-files"));
|
||||||
|
|
||||||
|
this.dropzone = null;
|
||||||
|
this.presupuesto_id = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
init() {
|
init(presupuesto_id = -1) {
|
||||||
|
|
||||||
this.btnPreviewCubierta.on('click', this.#btnPreview.bind(this));
|
this.btnPreviewCubierta.on('click', this.#btnPreview.bind(this));
|
||||||
|
|
||||||
|
this.submitFiles.on('click', this.#btnUploadFiles.bind(this));
|
||||||
|
|
||||||
|
if (presupuesto_id != -1) {
|
||||||
|
this.presupuesto_id = presupuesto_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init_dropzone() {
|
||||||
|
|
||||||
|
let id = this.presupuesto_id;
|
||||||
|
Dropzone.autoDiscover = false;
|
||||||
|
|
||||||
|
const previewTemplate = `<div class="dz-preview dz-file-preview">
|
||||||
|
<div class="dz-details">
|
||||||
|
<div class="dz-thumbnail">
|
||||||
|
<!---<img data-dz-thumbnail>
|
||||||
|
<span class="dz-nopreview">No preview</span> --->
|
||||||
|
<div class="dz-success-mark"></div>
|
||||||
|
<div class="dz-error-mark"></div>
|
||||||
|
<div class="dz-error-message"><span data-dz-errormessage></span></div>
|
||||||
|
<div class="progress">
|
||||||
|
<div class="progress-bar progress-bar-primary" role="progressbar" aria-valuemin="0" aria-valuemax="100" data-dz-uploadprogress></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="dz-filename" data-dz-name></div>
|
||||||
|
<div class="dz-size" data-dz-size></div>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
this.dropzone = new Dropzone('#dropzone-multi', {
|
||||||
|
url: "/presupuestos/presupuestocliente/upload_files",
|
||||||
|
addRemoveLinks: true,
|
||||||
|
previewTemplate: previewTemplate,
|
||||||
|
paramName: "file",
|
||||||
|
uploadMultiple: true,
|
||||||
|
parallelUploads: 4, // Ajusta este número al máximo número de archivos que esperas subir a la vez
|
||||||
|
maxFiles: 5, // Ajusta este número al máximo número de archivos que esperas subir a la vez
|
||||||
|
autoProcessQueue: true,
|
||||||
|
dictRemoveFile: "Eliminar",
|
||||||
|
acceptedFiles: 'image/*, application/pdf',
|
||||||
|
maxFilesize: 5e+7, // Bytes
|
||||||
|
init: function () {
|
||||||
|
let thisDropzone = this;
|
||||||
|
$('#loader').show();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/presupuestos/presupuestocliente/get_files",
|
||||||
|
type: 'POST',
|
||||||
|
data: { presupuesto_id: id }
|
||||||
|
|
||||||
|
}).done(function (response) {
|
||||||
|
if (response == null || response == "") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let values = JSON.parse(response);
|
||||||
|
for (var i = 0; i < values.length; i++) {
|
||||||
|
var mockFile = { name: values[i].name, size: values[i].size, hash: values[i].hash };
|
||||||
|
|
||||||
|
thisDropzone.files.push(mockFile); // add to files array
|
||||||
|
thisDropzone.emit("addedfile", mockFile);
|
||||||
|
thisDropzone.emit("thumbnail", mockFile, window.location.host + "/sistema/intranet/presupuestos/" + values[i].hash);
|
||||||
|
thisDropzone.emit("complete", mockFile);
|
||||||
|
thisDropzone.options.success.call(thisDropzone, mockFile);
|
||||||
|
};
|
||||||
|
}).always(function () {
|
||||||
|
$('#loader').hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.on("addedfile", function (file) {
|
||||||
|
if (file.hash) {
|
||||||
|
var viewButton = Dropzone.createElement("<span class='dz-remove'>Ver</span>");
|
||||||
|
file.previewElement.appendChild(viewButton);
|
||||||
|
// Listen to the view button click event
|
||||||
|
viewButton.addEventListener("click", function (e) {
|
||||||
|
|
||||||
|
window.open(window.location.protocol + "//" + window.location.host + "/sistema/intranet/presupuestos/" + file.hash, '_blank');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#btnUploadFiles() {
|
||||||
|
|
||||||
|
var files = this.dropzone.files;
|
||||||
|
$('#loader').show();
|
||||||
|
|
||||||
|
var formData = new FormData();
|
||||||
|
var oldFiles = [];
|
||||||
|
var counter = 0;
|
||||||
|
for (var i = 0; i < files.length; i++) {
|
||||||
|
|
||||||
|
if (files[i].upload) {
|
||||||
|
var file = files[i];
|
||||||
|
formData.append('file[' + counter + ']', file);
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
oldFiles.push(files[i].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
formData.append('oldFiles', JSON.stringify(oldFiles));
|
||||||
|
|
||||||
|
formData.append('presupuesto_id', this.presupuesto_id);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/presupuestos/presupuestocliente/upload_files",
|
||||||
|
type: 'POST',
|
||||||
|
data: formData,
|
||||||
|
processData: false, // Indicar a jQuery que no procese los datos
|
||||||
|
contentType: false // Indicar a jQuery que no establezca el tipo de contenido
|
||||||
|
}).done(function (response) {
|
||||||
|
popSuccessAlert("Archivos actualizados correctamente");
|
||||||
|
}).always(function () {
|
||||||
|
$('#loader').hide();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -180,7 +301,7 @@ class Resumen {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let precio_u_text = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio-unidad').text();
|
let precio_u_text = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio-unidad').text();
|
||||||
precio_u_text = precio_u_text.replace('€/u', '');
|
precio_u_text = precio_u_text.replace('€/u', '');
|
||||||
precio_u_text = this.#changeDecimalFormat(precio_u_text);
|
precio_u_text = this.#changeDecimalFormat(precio_u_text);
|
||||||
|
|
||||||
@ -202,6 +323,28 @@ class Resumen {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generate_total(base, precio_u) {
|
||||||
|
|
||||||
|
let precio_u_text = String(precio_u);
|
||||||
|
precio_u_text = precio_u_text.replace('€/u', '');
|
||||||
|
precio_u_text = this.#changeDecimalFormat(precio_u_text);
|
||||||
|
|
||||||
|
let base_text = this.#changeDecimalFormat(String(base));
|
||||||
|
|
||||||
|
const iva_porcentaje = this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? 0.21 : 0.04;
|
||||||
|
const iva = (parseFloat(base) * iva_porcentaje).toFixed(2);
|
||||||
|
let iva_text = this.#changeDecimalFormat(iva);
|
||||||
|
|
||||||
|
const total = (parseFloat(base) + parseFloat(iva)).toFixed(2);
|
||||||
|
let total_text = this.#changeDecimalFormat(total);
|
||||||
|
|
||||||
|
this.precio_unidad.text(precio_u_text);
|
||||||
|
this.total_base.text(base_text);
|
||||||
|
this.iva_porcentaje.text(this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? '21' : '4');
|
||||||
|
this.iva.text(iva_text);
|
||||||
|
this.total.text(total_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#capitalizeFirstLetter(string) {
|
#capitalizeFirstLetter(string) {
|
||||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||||
|
|||||||
@ -10,7 +10,15 @@ class previewFormas {
|
|||||||
this.ancho = datos.ancho;
|
this.ancho = datos.ancho;
|
||||||
this.alto = datos.alto;
|
this.alto = datos.alto;
|
||||||
this.lomo = datos.lomo;
|
this.lomo = datos.lomo;
|
||||||
this.solapa = datos.solapa;
|
|
||||||
|
if (datos.solapas == undefined || datos.solapas == null || datos.solapas == false) {
|
||||||
|
this.solapa = 0;
|
||||||
|
this.offsetSolapa = 0.0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.solapa = datos.solapas;
|
||||||
|
this.offsetSolapa = 3.0;
|
||||||
|
}
|
||||||
this.lomoRedondo = datos.lomoRedondo;
|
this.lomoRedondo = datos.lomoRedondo;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -25,7 +33,7 @@ class previewFormas {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (this.tipoLibro.includes("espiral") || this.tipoLibro.includes("wire-o")) {
|
else if (this.tipoLibro.includes("espiral") || this.tipoLibro.includes("wire-o")) {
|
||||||
if (this.tipoTapa.includes("dura"))
|
if (this.tipoTapa.toLowerCase().includes("dura"))
|
||||||
this.#portadaEspiral(true);
|
this.#portadaEspiral(true);
|
||||||
else
|
else
|
||||||
this.#portadaEspiral(false);
|
this.#portadaEspiral(false);
|
||||||
@ -233,14 +241,14 @@ class previewFormas {
|
|||||||
let styleCotas = { size: 12, family: 'Public Sans' };
|
let styleCotas = { size: 12, family: 'Public Sans' };
|
||||||
let sangradoTexto = "Sangrado 20 mm";
|
let sangradoTexto = "Sangrado 20 mm";
|
||||||
let sangradoValor = parseFloat(20); // mm
|
let sangradoValor = parseFloat(20); // mm
|
||||||
if(this.ancho > 210 || this.alto > 297){
|
if (this.ancho >= 210 || this.alto >= 297) {
|
||||||
sangradoValor = parseFloat(15); // mm
|
sangradoValor = parseFloat(15); // mm
|
||||||
sangradoTexto = "Sangrado 15 mm";
|
sangradoTexto = "Sangrado 15 mm";
|
||||||
}
|
}
|
||||||
let anchoPliegue = parseFloat(7); // mm cajo
|
let anchoPliegue = parseFloat(7); // mm cajo
|
||||||
let altoPliegue = parseFloat(7); // mm
|
let altoPliegue = parseFloat(7); // mm
|
||||||
let anchoCarton = parseFloat(6); // mm
|
let anchoCarton = parseFloat(6); // mm
|
||||||
if(this.lomoRedondo)
|
if (this.lomoRedondo)
|
||||||
anchoCarton += parseFloat(6); // mm
|
anchoCarton += parseFloat(6); // mm
|
||||||
// Definicion de los parametros del Esquema de Cubierta (EC)
|
// Definicion de los parametros del Esquema de Cubierta (EC)
|
||||||
if (this.size == "thumbnail") {
|
if (this.size == "thumbnail") {
|
||||||
@ -354,7 +362,7 @@ class previewFormas {
|
|||||||
previewEC.makeText((this.lomo + anchoCarton).toFixed(1) + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
|
previewEC.makeText((this.lomo + anchoCarton).toFixed(1) + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
|
||||||
previewEC.makeText((this.ancho + anchoPliegue).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
previewEC.makeText((this.ancho + anchoPliegue).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||||
previewEC.makeText((this.ancho + anchoPliegue).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
previewEC.makeText((this.ancho + anchoPliegue).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||||
previewEC.makeText((this.alto + altoPliegue).toFixed(1)+ " mm", origenEC.x + (lomoLibro / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
previewEC.makeText((this.alto + altoPliegue).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
||||||
previewEC.makeText((this.alto + (2 * sangradoValor) + altoPliegue).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro) + 55, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
previewEC.makeText((this.alto + (2 * sangradoValor) + altoPliegue).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro) + 55, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
||||||
previewEC.makeText((2 * this.ancho) + this.lomo + (2 * sangradoValor) + +(2 * anchoPliegue) + anchoCarton + " mm",
|
previewEC.makeText((2 * this.ancho) + this.lomo + (2 * sangradoValor) + +(2 * anchoPliegue) + anchoCarton + " mm",
|
||||||
origenEC.x,
|
origenEC.x,
|
||||||
@ -369,14 +377,14 @@ class previewFormas {
|
|||||||
#portadaEspiral(isTapaDura = false) {
|
#portadaEspiral(isTapaDura = false) {
|
||||||
|
|
||||||
// Variables locales
|
// Variables locales
|
||||||
let altoLibro, anchoLibro, anchoCalle, altoSangrado, anchoSangrado, anchoSolapa, offsetCubierta, anchoCubierta;
|
let altoLibro, anchoLibro, anchoSolapa, anchoCalle, altoSangrado, anchoSangrado, offsetCubierta, anchoCubierta;
|
||||||
let styleCotas = { size: 12, family: 'Public Sans' };
|
let styleCotas = { size: 12, family: 'Public Sans' };
|
||||||
let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm";
|
let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm";
|
||||||
let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm
|
let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm
|
||||||
|
|
||||||
|
|
||||||
// Definicion de los parametros del Esquema de Cubierta (EC)
|
// Definicion de los parametros del Esquema de Cubierta (EC)
|
||||||
if ((anchoSolapa !== 0) && (!isTapaDura)) {
|
if ((this.solapa !== 0) && (!isTapaDura)) {
|
||||||
if (this.size == "thumbnail") {
|
if (this.size == "thumbnail") {
|
||||||
anchoSangrado = 350; // px
|
anchoSangrado = 350; // px
|
||||||
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
|
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
|
||||||
@ -399,8 +407,8 @@ class previewFormas {
|
|||||||
anchoSangrado = 750; // px
|
anchoSangrado = 750; // px
|
||||||
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
|
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
|
||||||
}
|
}
|
||||||
altoLibro = (isTapaDura) ? altoSangrado * 0.88 : altoSangrado * 0.97;
|
altoLibro = (isTapaDura) ? altoSangrado * 0.88 : altoSangrado * 0.9;
|
||||||
anchoLibro = (isTapaDura) ? anchoSangrado * 0.39 : anchoSangrado * 0.419;
|
anchoLibro = (isTapaDura) ? anchoSangrado * 0.39 : anchoSangrado * 0.44;
|
||||||
anchoCalle = anchoSangrado * 0.02;
|
anchoCalle = anchoSangrado * 0.02;
|
||||||
anchoSolapa = 0;
|
anchoSolapa = 0;
|
||||||
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + anchoCalle;
|
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + anchoCalle;
|
||||||
@ -422,7 +430,7 @@ class previewFormas {
|
|||||||
sangrado.fill = '#FCEAF1';
|
sangrado.fill = '#FCEAF1';
|
||||||
sangrado.linewidth = 1;
|
sangrado.linewidth = 1;
|
||||||
|
|
||||||
if ((anchoSolapa != 0) && (!isTapaDura)) {
|
if ((this.solapa != 0) && (!isTapaDura)) {
|
||||||
var solapa1 = previewEC.makeRectangle(
|
var solapa1 = previewEC.makeRectangle(
|
||||||
origenEC.x + (anchoLibro + anchoCalle / 2 + anchoSolapa / 2 + sangradoValor),
|
origenEC.x + (anchoLibro + anchoCalle / 2 + anchoSolapa / 2 + sangradoValor),
|
||||||
origenEC.y,
|
origenEC.y,
|
||||||
@ -462,8 +470,8 @@ class previewFormas {
|
|||||||
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
||||||
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
||||||
// Textos Cotas Solapas
|
// Textos Cotas Solapas
|
||||||
previewEC.makeText((anchoSolapa).toFixed(1) + " mm", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
previewEC.makeText((this.solapa).toFixed(1) + " mm", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||||
previewEC.makeText(anchoSolapa.toFixed(1) + " mm", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
previewEC.makeText(this.solapa.toFixed(1) + " mm", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -556,15 +564,15 @@ class previewFormas {
|
|||||||
previewEC.makeText(sangradoTexto, origenEC.x + (anchoSangrado / 2) - 20, origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
previewEC.makeText(sangradoTexto, origenEC.x + (anchoSangrado / 2) - 20, origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
||||||
previewEC.makeText(sangradoTexto, origenEC.x - (anchoSangrado / 2) + 20, origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
previewEC.makeText(sangradoTexto, origenEC.x - (anchoSangrado / 2) + 20, origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
||||||
// Cotas
|
// Cotas
|
||||||
previewEC.makeText(anchoLibro.toFixed(1) + " mm", origenEC.x - (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
previewEC.makeText(this.ancho.toFixed(1) + " mm", origenEC.x - (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||||
previewEC.makeText(anchoLibro.toFixed(1) + " mm", origenEC.x + (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
previewEC.makeText(this.ancho.toFixed(1) + " mm", origenEC.x + (offsetCubierta - anchoSolapa / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||||
previewEC.makeText(altoLibro.toFixed(1) + " mm", origenEC.x + (anchoCalle / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
previewEC.makeText(this.alto.toFixed(1) + " mm", origenEC.x + (anchoCalle / 2) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
||||||
previewEC.makeText((altoLibro + (2 * sangradoValor)).toFixed(1) + " mm",
|
previewEC.makeText((this.alto + (2 * sangradoValor)).toFixed(1) + " mm",
|
||||||
origenEC.x + (anchoSangrado / 2) + 30,
|
origenEC.x + (anchoSangrado / 2) + 30,
|
||||||
origenEC.y,
|
origenEC.y,
|
||||||
styleCotas
|
styleCotas
|
||||||
).rotation = -Math.PI / 2;
|
).rotation = -Math.PI / 2;
|
||||||
previewEC.makeText(((2 * anchoLibro) + this.lomo + (2 * sangradoValor)).toFixed(1) + " mm",
|
previewEC.makeText(((2 * this.ancho) + this.lomo + (2 * sangradoValor)).toFixed(1) + " mm",
|
||||||
origenEC.x,
|
origenEC.x,
|
||||||
origenEC.y + (altoLibro / 2) + 50,
|
origenEC.y + (altoLibro / 2) + 50,
|
||||||
styleCotas);
|
styleCotas);
|
||||||
@ -582,10 +590,9 @@ class previewFormas {
|
|||||||
let styleCotas = { size: 12, family: 'Public Sans' };
|
let styleCotas = { size: 12, family: 'Public Sans' };
|
||||||
let sangradoTexto = "Sangrado 5 mm";
|
let sangradoTexto = "Sangrado 5 mm";
|
||||||
let sangradoValor = parseFloat(5); // mm
|
let sangradoValor = parseFloat(5); // mm
|
||||||
let offsetSolapaValor = parseFloat(0); // mm
|
|
||||||
|
|
||||||
// Definicion de los parametros del Esquema de Cubierta (EC)
|
// Definicion de los parametros del Esquema de Cubierta (EC)
|
||||||
if (anchoSolapa == 0) {
|
if (this.solapa == 0) {
|
||||||
if (this.size == "thumbnail") {
|
if (this.size == "thumbnail") {
|
||||||
anchoSangrado = 350; // px
|
anchoSangrado = 350; // px
|
||||||
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
|
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
|
||||||
@ -629,7 +636,7 @@ class previewFormas {
|
|||||||
sangrado.fill = '#FCEAF1';
|
sangrado.fill = '#FCEAF1';
|
||||||
sangrado.linewidth = 1;
|
sangrado.linewidth = 1;
|
||||||
|
|
||||||
if (anchoSolapa != 0) {
|
if (this.solapa != 0) {
|
||||||
var solapas = previewEC.makeRectangle(
|
var solapas = previewEC.makeRectangle(
|
||||||
origenEC.x,
|
origenEC.x,
|
||||||
origenEC.y,
|
origenEC.y,
|
||||||
@ -661,8 +668,8 @@ class previewFormas {
|
|||||||
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
||||||
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
||||||
// Textos Cotas Solapas
|
// Textos Cotas Solapas
|
||||||
previewEC.makeText(anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
previewEC.makeText(this.solapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||||
previewEC.makeText(anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
previewEC.makeText(this.solapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -735,11 +742,11 @@ class previewFormas {
|
|||||||
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
||||||
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
||||||
// Cotas
|
// Cotas
|
||||||
previewEC.makeText((anchoLibro + offsetSolapaValor).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||||
previewEC.makeText((anchoLibro + offsetSolapaValor).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||||
previewEC.makeText(altoLibro.toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
previewEC.makeText(this.alto.toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
||||||
previewEC.makeText(altoLibro.toFixed(1) + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
previewEC.makeText(this.alto.toFixed(1) + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
||||||
previewEC.makeText(((2 * anchoLibro) + (2 * (anchoSolapa + offsetSolapaValor)) + lomoLibro + (2 * sangradoValor)).toFixed(1) + " mm",
|
previewEC.makeText(((2 * anchoLibro) + (2 * (this.solapa + this.offsetSolapa)) + this.lomo + (2 * sangradoValor)).toFixed(1) + " mm",
|
||||||
origenEC.x,
|
origenEC.x,
|
||||||
origenEC.y + (altoLibro / 2) + 50,
|
origenEC.y + (altoLibro / 2) + 50,
|
||||||
styleCotas);
|
styleCotas);
|
||||||
@ -750,445 +757,3 @@ class previewFormas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default previewFormas;
|
export default previewFormas;
|
||||||
/*
|
|
||||||
// Global parameters
|
|
||||||
var pvObj;
|
|
||||||
|
|
||||||
$('#toReview').on("click", function () {
|
|
||||||
previewEsquemaCubierta(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on('shown.bs.modal', function (e) {
|
|
||||||
previewEsquemaCubierta(false);
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
function previewEsquemaCubierta(isThumbnail = false) {
|
|
||||||
|
|
||||||
if ($('#cosidoDiv').length) {
|
|
||||||
|
|
||||||
if ($('#cosidoDiv').hasClass('checked') || $("#fresadoDiv").hasClass('checked')) {
|
|
||||||
//console.log("Cosido/Fresado");
|
|
||||||
if ($("#tapaBlanda").is(":checked")) {
|
|
||||||
portadaTapaBlanda(isThumbnail);
|
|
||||||
} else if ($("#tapaDura").is(":checked")) {
|
|
||||||
portadaTapaDura(isThumbnail);
|
|
||||||
}
|
|
||||||
} else if ($('#espiralDiv').hasClass('checked') || $('#wireoDiv').hasClass('checked')) {
|
|
||||||
//console.log("Espiral/Wireo");
|
|
||||||
if ($("#tapaBlanda").is(":checked")) {
|
|
||||||
portadaEspiral(isThumbnail, false);
|
|
||||||
} else if ($("#tapaDura").is(":checked")) {
|
|
||||||
portadaEspiral(isThumbnail, true);
|
|
||||||
}
|
|
||||||
} else if ($('#grapadoDiv').hasClass('checked')) {
|
|
||||||
portadaGrapado(isThumbnail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let titulo = $('#tipoLibro').text().toLowerCase();
|
|
||||||
if (titulo.includes("cosido") || titulo.includes("fresado")) {
|
|
||||||
if (titulo.includes("dura"))
|
|
||||||
portadaTapaDura(isThumbnail);
|
|
||||||
else {
|
|
||||||
portadaTapaBlanda(isThumbnail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (titulo.includes("espiral") || titulo.includes("wire-o")) {
|
|
||||||
if (titulo.includes("dura"))
|
|
||||||
portadaEspiral(isThumbnail, true);
|
|
||||||
else
|
|
||||||
portadaEspiral(isThumbnail, false);
|
|
||||||
}
|
|
||||||
else if (titulo.includes("grapado")) {
|
|
||||||
portadaGrapado(isThumbnail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function portadaTapaBlanda(isThumbnail = false) {
|
|
||||||
|
|
||||||
// Variables locales
|
|
||||||
let altoLibro, anchoLibro, lomoLibro, anchoSolapa, anchoCubierta, altoSangrado, anchoSangrado;
|
|
||||||
let styleCotas = { size: 12, family: 'Public Sans' };
|
|
||||||
let sangradoTexto = "Sangrado 5 mm";
|
|
||||||
let sangradoValor = parseFloat(5); // mm
|
|
||||||
let offsetSolapaValor = parseFloat(0); // mm
|
|
||||||
|
|
||||||
let divIdName = (isThumbnail) ? 'thumbnail_ec_shape' : 'pv_ec_shape';
|
|
||||||
|
|
||||||
// Get the preview Object parameters
|
|
||||||
getObjetoToPreview();
|
|
||||||
|
|
||||||
|
|
||||||
// Definicion de los parametros del Esquema de Cubierta (EC)
|
|
||||||
if (anchoSolapa == 0) {
|
|
||||||
if (isThumbnail) {
|
|
||||||
anchoSangrado = 350; // px
|
|
||||||
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
|
|
||||||
} else {
|
|
||||||
anchoSangrado = 800; // px
|
|
||||||
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
|
|
||||||
}
|
|
||||||
|
|
||||||
altoLibro = altoSangrado * 0.97;
|
|
||||||
anchoLibro = anchoSangrado * 0.419;
|
|
||||||
anchoSolapa = 0;
|
|
||||||
lomoLibro = anchoSangrado * 0.133;
|
|
||||||
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (isThumbnail) {
|
|
||||||
anchoSangrado = 350; // px
|
|
||||||
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
|
|
||||||
} else {
|
|
||||||
anchoSangrado = 750; // px
|
|
||||||
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
|
|
||||||
}
|
|
||||||
altoLibro = altoSangrado * 0.95;
|
|
||||||
anchoLibro = anchoSangrado * 0.28;
|
|
||||||
anchoSolapa = anchoSangrado * 0.163;
|
|
||||||
lomoLibro = anchoSangrado * 0.09;
|
|
||||||
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear the canvas element
|
|
||||||
$(`#${divIdName}`).empty();
|
|
||||||
// Get the element for placing the graphical elements
|
|
||||||
var divEC = document.getElementById(divIdName);
|
|
||||||
var previewEC = new Two({ fitted: true }).appendTo(divEC);
|
|
||||||
// Calculate the center of the canvas element
|
|
||||||
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
|
|
||||||
|
|
||||||
var sangrado = previewEC.makeRectangle(
|
|
||||||
origenEC.x,
|
|
||||||
origenEC.y,
|
|
||||||
anchoSangrado,
|
|
||||||
altoSangrado
|
|
||||||
);
|
|
||||||
sangrado.stroke = 'black';
|
|
||||||
sangrado.dashes = [5, 5];
|
|
||||||
sangrado.fill = '#FCEAF1';
|
|
||||||
sangrado.linewidth = 1;
|
|
||||||
|
|
||||||
if (anchoSolapa != 0) {
|
|
||||||
var solapas = previewEC.makeRectangle(
|
|
||||||
origenEC.x,
|
|
||||||
origenEC.y,
|
|
||||||
anchoCubierta,
|
|
||||||
altoLibro);
|
|
||||||
solapas.stroke = 'black';
|
|
||||||
solapas.linewidth = 1;
|
|
||||||
|
|
||||||
// Cotas Solapas
|
|
||||||
if (!isThumbnail) {
|
|
||||||
var cotaSolapa2 = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x - anchoCubierta / 2,
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
origenEC.x - anchoLibro - lomoLibro / 2,
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
10);
|
|
||||||
cotaSolapa2.linewidth = 2;
|
|
||||||
var cotaSolapa1 = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x + anchoCubierta / 2,
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
origenEC.x + anchoLibro + lomoLibro / 2,
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
10);
|
|
||||||
cotaSolapa1.linewidth = 2;
|
|
||||||
|
|
||||||
// Textos Solapas
|
|
||||||
let stylesSolapa = { size: 18, family: 'Public Sans' };
|
|
||||||
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
|
||||||
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
|
||||||
// Textos Cotas Solapas
|
|
||||||
previewEC.makeText(anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
|
||||||
previewEC.makeText(anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var libro = previewEC.makeRectangle(
|
|
||||||
origenEC.x,
|
|
||||||
origenEC.y,
|
|
||||||
((2 * anchoLibro) + lomoLibro),
|
|
||||||
altoLibro);
|
|
||||||
libro.stroke = 'black';
|
|
||||||
libro.linewidth = 1;
|
|
||||||
|
|
||||||
var lomo = previewEC.makeRectangle(
|
|
||||||
origenEC.x,
|
|
||||||
origenEC.y,
|
|
||||||
lomoLibro,
|
|
||||||
altoLibro);
|
|
||||||
lomo.stroke = 'black';
|
|
||||||
lomo.fill = '#F4F8F2';
|
|
||||||
lomo.linewidth = 1;
|
|
||||||
|
|
||||||
// Cotas y textos
|
|
||||||
if (!isThumbnail) {
|
|
||||||
// Cotas:
|
|
||||||
var cotaAnchoCubierta = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x - (anchoSangrado / 2),
|
|
||||||
origenEC.y + (altoLibro / 2) + 35,
|
|
||||||
origenEC.x + (anchoSangrado / 2),
|
|
||||||
origenEC.y + (altoLibro / 2) + 35,
|
|
||||||
10);
|
|
||||||
cotaAnchoCubierta.linewidth = 2;
|
|
||||||
var cotaAltoCubierta = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x + (anchoCubierta / 2) + 35,
|
|
||||||
origenEC.y + (altoSangrado / 2),
|
|
||||||
origenEC.x + (anchoCubierta / 2) + 35,
|
|
||||||
origenEC.y - (altoSangrado / 2),
|
|
||||||
10);
|
|
||||||
cotaAltoCubierta.linewidth = 2;
|
|
||||||
var cotaAltoLibro = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x + (lomoLibro / 2) + 35,
|
|
||||||
origenEC.y + (altoLibro / 2),
|
|
||||||
origenEC.x + (lomoLibro / 2) + 35,
|
|
||||||
origenEC.y - (altoLibro / 2),
|
|
||||||
10);
|
|
||||||
cotaAltoLibro.linewidth = 2;
|
|
||||||
var cotaLomo = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x - (lomoLibro / 2),
|
|
||||||
origenEC.y + (altoLibro / 3),
|
|
||||||
origenEC.x + (lomoLibro / 2),
|
|
||||||
origenEC.y + (altoLibro / 3),
|
|
||||||
10);
|
|
||||||
cotaLomo.linewidth = 2;
|
|
||||||
var cotaContraportada = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x - (lomoLibro / 2 + anchoLibro),
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
origenEC.x - (lomoLibro / 2),
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
10);
|
|
||||||
cotaContraportada.linewidth = 2;
|
|
||||||
var cotaPortada = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x + (lomoLibro / 2),
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
origenEC.x + (lomoLibro / 2 + anchoLibro),
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
10);
|
|
||||||
cotaPortada.linewidth = 2;
|
|
||||||
|
|
||||||
|
|
||||||
// Textos:
|
|
||||||
// Titulos generales
|
|
||||||
let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' };
|
|
||||||
previewEC.makeText("Portada", origenEC.x + (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
|
|
||||||
previewEC.makeText("Contraportada", origenEC.x - (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
|
|
||||||
let a = previewEC.makeText("Lomo", origenEC.x, origenEC.y, stylesEC).rotation = -Math.PI / 2;
|
|
||||||
// Sangrados
|
|
||||||
let styleSangrado = { size: 10, family: 'Public Sans', style: 'italic', fill: 'red' };
|
|
||||||
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y + (altoLibro / 2 + 20), styleSangrado);
|
|
||||||
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y - (altoLibro / 2 + 20), styleSangrado);
|
|
||||||
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
|
||||||
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
|
||||||
// Cotas
|
|
||||||
previewEC.makeText(lomoLibro + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
|
|
||||||
previewEC.makeText(anchoLibro + offsetSolapaValor + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
|
||||||
previewEC.makeText(anchoLibro + offsetSolapaValor + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
|
||||||
previewEC.makeText(altoLibro + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
|
||||||
previewEC.makeText(altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
|
||||||
previewEC.makeText((2 * anchoLibro) + (2 * (anchoSolapa + offsetSolapaValor)) + lomoLibro + (2 * sangradoValor) + " mm",
|
|
||||||
origenEC.x,
|
|
||||||
origenEC.y + (altoLibro / 2) + 50,
|
|
||||||
styleCotas);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
previewEC.update();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function portadaGrapado(isThumbnail = false) {
|
|
||||||
|
|
||||||
// Variables locales
|
|
||||||
let altoLibro, anchoLibro, lomoLibro, anchoSolapa, anchoCubierta, altoSangrado, anchoSangrado;
|
|
||||||
let styleCotas = { size: 12, family: 'Public Sans' };
|
|
||||||
let sangradoTexto = "Sangrado 5 mm";
|
|
||||||
let sangradoValor = parseFloat(5); // mm
|
|
||||||
let offsetSolapaValor = parseFloat(0); // mm
|
|
||||||
|
|
||||||
let divIdName = (isThumbnail) ? 'thumbnail_ec_shape' : 'pv_ec_shape';
|
|
||||||
|
|
||||||
// Get the preview Object parameters
|
|
||||||
getObjetoToPreview();
|
|
||||||
|
|
||||||
// Definicion de los parametros del Esquema de Cubierta (EC)
|
|
||||||
if (anchoSolapa == 0) {
|
|
||||||
if (isThumbnail) {
|
|
||||||
anchoSangrado = 350; // px
|
|
||||||
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
|
|
||||||
} else {
|
|
||||||
anchoSangrado = 750; // px
|
|
||||||
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
|
|
||||||
}
|
|
||||||
altoLibro = altoSangrado * 0.97;
|
|
||||||
anchoLibro = anchoSangrado * 0.48;
|
|
||||||
anchoSolapa = 0;
|
|
||||||
lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO
|
|
||||||
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (isThumbnail) {
|
|
||||||
anchoSangrado = 350; // px
|
|
||||||
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
|
|
||||||
} else {
|
|
||||||
anchoSangrado = 750; // px
|
|
||||||
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
|
|
||||||
}
|
|
||||||
altoLibro = altoSangrado * 0.95;
|
|
||||||
anchoLibro = anchoSangrado * 0.3;
|
|
||||||
anchoSolapa = anchoSangrado * 0.18;
|
|
||||||
lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO
|
|
||||||
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear the canvas element
|
|
||||||
$(`#${divIdName}`).empty();
|
|
||||||
// Get the element for placing the graphical elements
|
|
||||||
var divEC = document.getElementById(divIdName);
|
|
||||||
var previewEC = new Two({ fitted: true }).appendTo(divEC);
|
|
||||||
// Calculate the center of the canvas element
|
|
||||||
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
|
|
||||||
|
|
||||||
var sangrado = previewEC.makeRectangle(
|
|
||||||
origenEC.x,
|
|
||||||
origenEC.y,
|
|
||||||
anchoSangrado,
|
|
||||||
altoSangrado
|
|
||||||
);
|
|
||||||
sangrado.stroke = 'black';
|
|
||||||
sangrado.dashes = [5, 5];
|
|
||||||
sangrado.fill = '#FCEAF1';
|
|
||||||
sangrado.linewidth = 1;
|
|
||||||
|
|
||||||
if (anchoSolapa != 0) {
|
|
||||||
var solapas = previewEC.makeRectangle(
|
|
||||||
origenEC.x,
|
|
||||||
origenEC.y,
|
|
||||||
anchoCubierta,
|
|
||||||
altoLibro);
|
|
||||||
solapas.stroke = 'black';
|
|
||||||
solapas.linewidth = 1;
|
|
||||||
|
|
||||||
// Cotas y textos
|
|
||||||
if (!isThumbnail) {
|
|
||||||
// Cotas
|
|
||||||
var cotaSolapa2 = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x - anchoCubierta / 2,
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
origenEC.x - anchoLibro - lomoLibro / 2,
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
10);
|
|
||||||
cotaSolapa2.linewidth = 2;
|
|
||||||
var cotaSolapa1 = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x + anchoCubierta / 2,
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
origenEC.x + anchoLibro + lomoLibro / 2,
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
10);
|
|
||||||
cotaSolapa1.linewidth = 2;
|
|
||||||
|
|
||||||
// Textos Solapas
|
|
||||||
let stylesSolapa = { size: 18, family: 'Public Sans' };
|
|
||||||
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
|
||||||
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
|
||||||
// Textos Cotas Solapas
|
|
||||||
previewEC.makeText(anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
|
||||||
previewEC.makeText(anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var libro = previewEC.makeRectangle(
|
|
||||||
origenEC.x,
|
|
||||||
origenEC.y,
|
|
||||||
((2 * anchoLibro) + lomoLibro),
|
|
||||||
altoLibro);
|
|
||||||
libro.stroke = 'black';
|
|
||||||
libro.linewidth = 1;
|
|
||||||
|
|
||||||
var lomo = previewEC.makeRectangle(
|
|
||||||
origenEC.x,
|
|
||||||
origenEC.y,
|
|
||||||
lomoLibro,
|
|
||||||
altoLibro);
|
|
||||||
lomo.stroke = 'black';
|
|
||||||
lomo.fill = '#F4F8F2';
|
|
||||||
lomo.linewidth = 1;
|
|
||||||
|
|
||||||
// Cotas y textos
|
|
||||||
if (!isThumbnail) {
|
|
||||||
// Cotas:
|
|
||||||
var cotaAnchoCubierta = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x - (anchoSangrado / 2),
|
|
||||||
origenEC.y + (altoLibro / 2) + 35,
|
|
||||||
origenEC.x + (anchoSangrado / 2),
|
|
||||||
origenEC.y + (altoLibro / 2) + 35,
|
|
||||||
10);
|
|
||||||
cotaAnchoCubierta.linewidth = 2;
|
|
||||||
var cotaAltoCubierta = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x + (anchoCubierta / 2) + 35,
|
|
||||||
origenEC.y + (altoSangrado / 2),
|
|
||||||
origenEC.x + (anchoCubierta / 2) + 35,
|
|
||||||
origenEC.y - (altoSangrado / 2),
|
|
||||||
10);
|
|
||||||
cotaAltoCubierta.linewidth = 2;
|
|
||||||
var cotaAltoLibro = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x + (lomoLibro / 2) + 35,
|
|
||||||
origenEC.y + (altoLibro / 2),
|
|
||||||
origenEC.x + (lomoLibro / 2) + 35,
|
|
||||||
origenEC.y - (altoLibro / 2),
|
|
||||||
10);
|
|
||||||
cotaAltoLibro.linewidth = 2;
|
|
||||||
var cotaContraportada = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x - (lomoLibro / 2 + anchoLibro),
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
origenEC.x - (lomoLibro / 2),
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
10);
|
|
||||||
cotaContraportada.linewidth = 2;
|
|
||||||
var cotaPortada = previewEC.makeDobleArrow(
|
|
||||||
origenEC.x + (lomoLibro / 2),
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
origenEC.x + (lomoLibro / 2 + anchoLibro),
|
|
||||||
origenEC.y - (altoLibro / 3),
|
|
||||||
10);
|
|
||||||
cotaPortada.linewidth = 2;
|
|
||||||
|
|
||||||
// Textos:
|
|
||||||
// Titulos generales
|
|
||||||
let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' };
|
|
||||||
previewEC.makeText("Portada", origenEC.x + (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
|
|
||||||
previewEC.makeText("Contraportada", origenEC.x - (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
|
|
||||||
// Sangrados
|
|
||||||
let styleSangrado = { size: 10, family: 'Public Sans', style: 'italic', fill: 'red' };
|
|
||||||
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y + (altoLibro / 2 + 20), styleSangrado);
|
|
||||||
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y - (altoLibro / 2 + 20), styleSangrado);
|
|
||||||
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
|
||||||
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
|
||||||
// Cotas
|
|
||||||
previewEC.makeText(anchoLibro + offsetSolapaValor + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
|
||||||
previewEC.makeText(anchoLibro + offsetSolapaValor + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
|
||||||
previewEC.makeText(altoLibro + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
|
||||||
previewEC.makeText(altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
|
||||||
previewEC.makeText((2 * anchoLibro) + (2 * (anchoSolapa + offsetSolapaValor)) + lomoLibro + (2 * sangradoValor) + " mm",
|
|
||||||
origenEC.x,
|
|
||||||
origenEC.y + (altoLibro / 2) + 50,
|
|
||||||
styleCotas);
|
|
||||||
}
|
|
||||||
|
|
||||||
previewEC.update();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
Reference in New Issue
Block a user