mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en el editar
This commit is contained in:
@ -534,11 +534,11 @@ $routes->group('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos
|
|||||||
$routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Cosidotapablanda', 'except' => 'show,new,create,update']);
|
$routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Cosidotapablanda', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
$routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
$routes->group('presupuestocliente', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||||
$routes->get('list/(:num)', 'Presupuestocliente::list/$1', ['as' => 'listarPresupuestoCliente']); // HOMOGENIZAR CON ARGS DINAMICOS!!!
|
$routes->get('list', 'Presupuestocliente::list', ['as' => 'listaPresupuestos']);
|
||||||
|
$routes->post('datatable', 'Presupuestocliente::datatable', ['as' => 'datatableOfPresupuestos']);
|
||||||
$routes->get('add', 'Presupuestocliente::add', ['as' => 'nuevoPresupuestoCliente']);
|
$routes->get('add', 'Presupuestocliente::add', ['as' => 'nuevoPresupuestoCliente']);
|
||||||
$routes->post('add', 'Presupuestocliente::add', ['as' => 'crearPresupuestoCliente']);
|
$routes->post('add', 'Presupuestocliente::add', ['as' => 'crearPresupuestoCliente']);
|
||||||
$routes->post('edit/(:num)', 'Presupuestocliente::edit/$1', ['as' => 'editarPresupuestoCliente']);
|
$routes->post('edit/(:num)', 'Presupuestocliente::edit/$1', ['as' => 'editarPresupuestoCliente']);
|
||||||
$routes->post('datatable', 'Cosidotapablanda::datatable', ['as' => 'tablaPresupuestosCliente']);
|
|
||||||
$routes->post('getgramaje', 'Presupuestocliente::getGramaje', ['as' => 'obtenerGramaje']);
|
$routes->post('getgramaje', 'Presupuestocliente::getGramaje', ['as' => 'obtenerGramaje']);
|
||||||
$routes->post('presupuesto', 'Presupuestocliente::presupuesto', ['as' => 'presupuestoCliente']);
|
$routes->post('presupuesto', 'Presupuestocliente::presupuesto', ['as' => 'presupuestoCliente']);
|
||||||
$routes->post('getDireccionesCliente', 'Presupuestocliente::getDireccionesCliente', ['as' => 'getDirecciones']);
|
$routes->post('getDireccionesCliente', 'Presupuestocliente::getDireccionesCliente', ['as' => 'getDirecciones']);
|
||||||
|
|||||||
@ -97,11 +97,11 @@ class Buscador extends \App\Controllers\BaseResourceController
|
|||||||
$order1 = PresupuestoModel::SORTABLE[$requestedOrder1 >= 0 ? $requestedOrder1 : 0];
|
$order1 = PresupuestoModel::SORTABLE[$requestedOrder1 >= 0 ? $requestedOrder1 : 0];
|
||||||
$dir1 = $reqData['order']['0']['dir'] ?? 'asc';
|
$dir1 = $reqData['order']['0']['dir'] ?? 'asc';
|
||||||
$requestedOrder2 = $reqData['order']['1']['column'] ?? 0;
|
$requestedOrder2 = $reqData['order']['1']['column'] ?? 0;
|
||||||
$order2 = PresupuestoModel::SORTABLE[$requestedOrder2 >= 0 ? $requestedOrder1 : 0];
|
$order2 = PresupuestoModel::SORTABLE[$requestedOrder2 >= 0 ? $requestedOrder2 : 0];
|
||||||
$dir2 = $reqData['order']['0']['dir'] ?? 'asc';
|
$dir2 = $reqData['order']['1']['dir'] ?? 'asc';
|
||||||
$requestedOrder3 = $reqData['order']['2']['column'] ?? 0;
|
$requestedOrder3 = $reqData['order']['2']['column'] ?? 0;
|
||||||
$order3 = PresupuestoModel::SORTABLE[$requestedOrder3 >= 0 ? $requestedOrder1 : 0];
|
$order3 = PresupuestoModel::SORTABLE[$requestedOrder3 >= 0 ? $requestedOrder3 : 0];
|
||||||
$dir3 = $reqData['order']['0']['dir'] ?? 'asc';
|
$dir3 = $reqData['order']['2']['dir'] ?? 'asc';
|
||||||
|
|
||||||
$searchValues = get_filter_datatables_columns($reqData);
|
$searchValues = get_filter_datatables_columns($reqData);
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,7 @@ use App\Models\Presupuestos\PresupuestoModel;
|
|||||||
use App\Models\Presupuestos\PresupuestoPreimpresionesModel;
|
use App\Models\Presupuestos\PresupuestoPreimpresionesModel;
|
||||||
use App\Models\Presupuestos\PresupuestoServiciosExtraModel;
|
use App\Models\Presupuestos\PresupuestoServiciosExtraModel;
|
||||||
use App\Services\PresupuestoClienteService;
|
use App\Services\PresupuestoClienteService;
|
||||||
|
use App\Services\PresupuestoService;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
use function PHPUnit\Framework\containsOnly;
|
use function PHPUnit\Framework\containsOnly;
|
||||||
@ -33,7 +34,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
protected static $viewPath = 'themes/vuexy/form/presupuestos/cliente/';
|
protected static $viewPath = 'themes/vuexy/form/presupuestos/cliente/';
|
||||||
|
|
||||||
protected $indexRoute = 'cosidotapablandaList';
|
protected $indexRoute = 'listaPresupuestos';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -54,90 +55,30 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function list($tipo_impresion_id = 4)
|
public function list()
|
||||||
{
|
{
|
||||||
$viewData = [
|
$viewData = [
|
||||||
'currentModule' => static::$controllerSlug,
|
'currentModule' => static::$controllerSlug,
|
||||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Presupuestos.presupuesto')]),
|
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Presupuestos.presupuesto')]),
|
||||||
'presupuestoEntity' => new PresupuestoEntity(),
|
'presupuestoEntity' => new PresupuestoEntity(),
|
||||||
'usingServerSideDataTable' => true,
|
'usingServerSideDataTable' => true,
|
||||||
'tipo_impresion_id' => $tipo_impresion_id
|
'pageTitle' => lang('Presupuestos.presupuestos'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$viewData = array_merge($viewData, $this->getStringsFromTipoImpresion($tipo_impresion_id));
|
|
||||||
|
|
||||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
if (auth()->user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor')) {
|
||||||
|
$clienteId = 999; // Fijo hasta desarollar clientes usuarios
|
||||||
|
} else {
|
||||||
|
$clienteId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$viewData['clienteId'] = $clienteId;
|
||||||
return view(static::$viewPath . 'viewCosidotapablandaList', $viewData);
|
return view(static::$viewPath . 'viewPresupuestoList', $viewData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
|
|
||||||
// JJO
|
|
||||||
$session = session();
|
|
||||||
|
|
||||||
$requestMethod = $this->request->getMethod();
|
|
||||||
|
|
||||||
if ($requestMethod === 'post') :
|
|
||||||
|
|
||||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
|
||||||
|
|
||||||
$postData = $this->request->getPost();
|
|
||||||
|
|
||||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
|
||||||
|
|
||||||
// JJO
|
|
||||||
$sanitizedData['user_created_id'] = $session->id_user;
|
|
||||||
|
|
||||||
if (!isset($sanitizedData['papel_formato_id']) || $sanitizedData['papel_formato_id'] == null) {
|
|
||||||
$sanitizedData['papel_formato_id'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($sanitizedData['is_duplicado']) || $sanitizedData['is_duplicado'] == null) {
|
|
||||||
$sanitizedData['is_duplicado'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$noException = true;
|
|
||||||
if ($successfulResult = $this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
|
||||||
|
|
||||||
if ($this->canValidate($this->model->validationRulesAdd, $this->model->validationMessagesAdd)) :
|
|
||||||
try {
|
|
||||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$noException = false;
|
|
||||||
$this->dealWithException($e);
|
|
||||||
}
|
|
||||||
else :
|
|
||||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Presupuestos.presupuesto'))]);
|
|
||||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
|
||||||
endif;
|
|
||||||
|
|
||||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
|
||||||
endif;
|
|
||||||
if ($noException && $successfulResult) :
|
|
||||||
|
|
||||||
$id = $this->model->db->insertID();
|
|
||||||
|
|
||||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
|
||||||
|
|
||||||
if ($thenRedirect) :
|
|
||||||
if (!empty($this->indexRoute)) :
|
|
||||||
//return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
|
|
||||||
return redirect()->to(site_url('presupuestos/cliente/edit/' . $id))->with('sweet-success', $message);
|
|
||||||
else :
|
|
||||||
return $this->redirect2listView('sweet-success', $message);
|
|
||||||
endif;
|
|
||||||
else :
|
|
||||||
$this->session->setFlashData('sweet-success', $message);
|
|
||||||
endif;
|
|
||||||
|
|
||||||
endif; // $noException && $successfulResult
|
|
||||||
|
|
||||||
endif; // ($requestMethod === 'post')
|
|
||||||
|
|
||||||
// Se obtiene el cliente ID a partir del usuario de la sesion
|
// Se obtiene el cliente ID a partir del usuario de la sesion
|
||||||
$clienteId = 999; // Fijo hasta desarollar clientes usuarios
|
$clienteId = 999; // Fijo hasta desarollar clientes usuarios
|
||||||
|
|
||||||
@ -194,218 +135,52 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$requestMethod = $this->request->getMethod();
|
$requestMethod = $this->request->getMethod();
|
||||||
|
|
||||||
if ($requestMethod === 'post') :
|
$datosPresupuesto = (object)array();
|
||||||
|
$datosPresupuesto->POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
|
||||||
|
$datosPresupuesto->paisList = model('App\Models\Configuracion\PaisModel')->getAllForMenu('id, nombre', 'nombre', true);
|
||||||
|
$datosPresupuesto->papelFormatoList = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null);
|
||||||
|
|
||||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
$datosPresupuesto->papelInteriorNegro = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('negro', false, false, false, false, true);
|
||||||
|
$datosPresupuesto->papelInteriorNegroHq = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('negrohq', false, false, false, false, true);
|
||||||
|
$datosPresupuesto->papelInteriorColor = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('color', false, false, false, false, true);
|
||||||
|
$datosPresupuesto->papelInteriorColorHq = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', false, false, false, false, true);
|
||||||
|
|
||||||
$postData = $this->request->getPost();
|
$datosPresupuesto->papelCubierta = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', true, false, false, false, true);
|
||||||
|
$datosPresupuesto->papelSobrecubierta = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', false, true, false, false, true);
|
||||||
|
$datosPresupuesto->papelGuardas = model('App\Models\Configuracion\PapelGenericoModel')->getPapelForComparador('colorhq', false, false, false, true, false);
|
||||||
|
|
||||||
$postData['updated_at'] = gmdate('Y-m-d H:m:s', time());
|
$datosPresupuesto->acabadosCubierta = $this->getAcabadosCubierta();
|
||||||
|
$datosPresupuesto->acabadosSobrecubierta = $this->getAcabadosSobrecubierta();
|
||||||
|
|
||||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
$datosPresupuesto->clienteList = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
|
||||||
|
|
||||||
// JJO
|
|
||||||
$sanitizedData['user_updated_id'] = $session->id_user;
|
|
||||||
|
|
||||||
if ($this->request->getPost('is_duplicado') == null) {
|
|
||||||
$sanitizedData['is_duplicado'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->request->getPost('retractilado') == null) {
|
|
||||||
$sanitizedData['retractilado'] = false;
|
|
||||||
}
|
|
||||||
if ($this->request->getPost('retractilado5') == null) {
|
|
||||||
$sanitizedData['retractilado5'] = false;
|
|
||||||
}
|
|
||||||
if ($this->request->getPost('ferro') == null) {
|
|
||||||
$sanitizedData['ferro'] = false;
|
|
||||||
}
|
|
||||||
if ($this->request->getPost('ferro_digital') == null) {
|
|
||||||
$sanitizedData['ferro_digital'] = false;
|
|
||||||
}
|
|
||||||
if ($this->request->getPost('prototipo') == null) {
|
|
||||||
$sanitizedData['prototipo'] = false;
|
|
||||||
}
|
|
||||||
if ($this->request->getPost('marcapaginas') == null) {
|
|
||||||
$sanitizedData['marcapaginas'] = false;
|
|
||||||
}
|
|
||||||
if ($this->request->getPost('faja_color') == null) {
|
|
||||||
$sanitizedData['faja_color'] = false;
|
|
||||||
}
|
|
||||||
if ($this->request->getPost('papel_formato_personalizado') == null) {
|
|
||||||
$sanitizedData['papel_formato_personalizado'] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->request->getPost('papel_formato_id') == null) {
|
|
||||||
$sanitizedData['papel_formato_id'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->request->getPost('solapas') == null) {
|
|
||||||
$sanitizedData['solapas'] = 0;
|
|
||||||
}
|
|
||||||
if ($this->request->getPost('solapas_sobrecubierta') == null) {
|
|
||||||
$sanitizedData['solapas_sobrecubierta'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$noException = true;
|
|
||||||
if (
|
|
||||||
$sanitizedData['papel_formato_id'] == null && $sanitizedData['papel_formato_ancho'] == null
|
|
||||||
&& $sanitizedData['papel_formato_alto'] == null
|
|
||||||
) {
|
|
||||||
if ($this->request->isAJAX()) {
|
|
||||||
$newTokenHash = csrf_hash();
|
|
||||||
$csrfTokenName = csrf_token();
|
|
||||||
$data = [
|
|
||||||
'errorMensaje' => lang('Presupuestos.errores.formato_papel'),
|
|
||||||
$csrfTokenName => $newTokenHash
|
|
||||||
];
|
|
||||||
return $this->respond($data);
|
|
||||||
} else {
|
|
||||||
$this->session->setFlashData('errorMessage', lang('Presupuestos.errores.formato_papel'));
|
|
||||||
}
|
|
||||||
$successfulResult = false;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) )
|
|
||||||
|
|
||||||
if ($this->canValidate()) :
|
|
||||||
try {
|
|
||||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$noException = false;
|
|
||||||
$this->dealWithException($e);
|
|
||||||
}
|
|
||||||
else :
|
|
||||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Presupuestos.presupuesto'))]);
|
|
||||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
$presupuestoEntity->fill($sanitizedData);
|
|
||||||
|
|
||||||
$thenRedirect = false;
|
|
||||||
endif;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($noException && $successfulResult) :
|
|
||||||
$id = $presupuestoEntity->id ?? $id;
|
|
||||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Presupuestos.presupuesto'))]) . '.';
|
|
||||||
|
|
||||||
if ($thenRedirect) :
|
|
||||||
if (!empty($this->indexRoute)) :
|
|
||||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
|
||||||
else :
|
|
||||||
if ($this->request->isAJAX()) {
|
|
||||||
$newTokenHash = csrf_hash();
|
|
||||||
$csrfTokenName = csrf_token();
|
|
||||||
$data = [
|
|
||||||
'mensaje' => $message,
|
|
||||||
$csrfTokenName => $newTokenHash
|
|
||||||
];
|
|
||||||
return $this->respond($data);
|
|
||||||
} else {
|
|
||||||
return $this->redirect2listView('sweet-success', $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
endif;
|
|
||||||
else :
|
|
||||||
if ($this->request->isAJAX()) {
|
|
||||||
$newTokenHash = csrf_hash();
|
|
||||||
$csrfTokenName = csrf_token();
|
|
||||||
$data = [
|
|
||||||
'mensaje' => $message,
|
|
||||||
$csrfTokenName => $newTokenHash
|
|
||||||
];
|
|
||||||
return $this->respond($data);
|
|
||||||
} else {
|
|
||||||
$this->session->setFlashData('sweet-success', $message);
|
|
||||||
}
|
|
||||||
endif;
|
|
||||||
|
|
||||||
endif; // $noException && $successfulResult
|
|
||||||
endif; // ($requestMethod === 'post')
|
|
||||||
|
|
||||||
/*
|
|
||||||
$this->viewData['presupuestoId'] = $id;
|
|
||||||
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
|
|
||||||
$this->viewData['isCosido'] = (new TipoPresupuestoModel())->get_isCosido($presupuestoEntity->tipo_impresion_id);
|
|
||||||
$this->viewData['isTapaDura'] = (new TipoPresupuestoModel())->get_isTapaDura($presupuestoEntity->tipo_impresion_id);
|
|
||||||
|
|
||||||
if (!is_null($presupuestoEntity->comparador_json_data))
|
|
||||||
$this->viewData['comp_data'] = json_decode($presupuestoEntity->comparador_json_data);
|
|
||||||
else
|
|
||||||
$this->viewData['comp_data'] = "";
|
|
||||||
|
|
||||||
$this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
|
|
||||||
$this->viewData['paisList'] = $this->getPaisListItems();
|
|
||||||
$this->viewData['ccaaList'] = $this->getCcaaListItems();
|
|
||||||
|
|
||||||
$this->viewData['clienteList'] = $this->getClienteListItems($presupuestoEntity->cliente_id ?? null);
|
|
||||||
$this->viewData['incReiList'] = array('incidencia' => lang('Presupuestos.incidencia'), 'reimpresion' => lang('Presupuestos.reimpresion'), 'sin_cargo' => lang('Presupuestos.sinCargo'));
|
|
||||||
$this->viewData['papelFormatoList'] = $this->getPapelFormatoListItems($presupuestoEntity->papel_formato_id ?? null);
|
|
||||||
$this->viewData['papelGenericoNegroList'] = $this->getPapelGenericoNegro();
|
|
||||||
$this->viewData['papelGenericoNegroHQList'] = $this->getPapelGenericoNegroHQ();
|
|
||||||
$this->viewData['papelGenericoColorList'] = $this->getPapelGenericoColor();
|
|
||||||
$this->viewData['papelGenericoColorHQList'] = $this->getPapelGenericoColorHQ();
|
|
||||||
$this->viewData['papelGenericoCubiertaList'] = $this->getPapelGenericoCubierta();
|
|
||||||
$this->viewData['papelGenericoGuardasList'] = $this->getPapelGenericoGuardas();
|
|
||||||
$this->viewData['papelGenericoSobrecubiertaList'] = $this->getPapelGenericoSobreCubierta();
|
|
||||||
$this->viewData['papelGenericoRotativaNegroList'] = $this->getPapelGenericoRotativaNegro();
|
|
||||||
$this->viewData['papelGenericoRotativaColorList'] = $this->getPapelGenericoRotativaColor();
|
|
||||||
|
|
||||||
// Acabados exteriores
|
|
||||||
$this->viewData['acabadosCubierta'] = $this->getAcabadosCubierta();
|
|
||||||
$this->viewData['acabadosSobrecubierta'] = $this->getAcabadosSobrecubierta();
|
|
||||||
|
|
||||||
// Lineas Presupuesto
|
|
||||||
[$cambios_lineas, $this->viewData['lineasPresupuesto']] = $this->getLineasPresupuesto($presupuestoEntity);
|
|
||||||
$this->viewData['presupuestoEntity']->cambios_lineas=$cambios_lineas;
|
|
||||||
|
|
||||||
// Servicios
|
|
||||||
$this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion();
|
|
||||||
$this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion();
|
|
||||||
$this->viewData['serviciosManipulado'] = $this->getServiciosManipulado();
|
|
||||||
$this->viewData['serviciosAcabado'] = $this->getServiciosAcabado();
|
|
||||||
$this->viewData['serviciosExtra'] = $this->getServiciosExtra();
|
|
||||||
|
|
||||||
[$cambios_en_servicios, $servicios] = $this->getLineasServicios($presupuestoEntity);
|
|
||||||
$this->viewData['presupuestoEntity']->cambios_servicios=$cambios_en_servicios;
|
|
||||||
|
|
||||||
$this->viewData['serviciosEncuadernacionList'] = $servicios->serviciosEncuadernacion;
|
|
||||||
$this->viewData['serviciosAcabadosList'] = $servicios->serviciosAcabado;
|
|
||||||
$this->viewData['serviciosManipuladoList'] = $servicios->serviciosManipulado;
|
|
||||||
$this->viewData['serviciosPreimpresionList'] = $servicios->serviciosPreimpresion;
|
|
||||||
$this->viewData['serviciosExtraList'] = $servicios->serviciosExtra;
|
|
||||||
|
|
||||||
// Direciones presupuesto
|
|
||||||
[$cambios_en_direcciones, $this->viewData['direccionesList']] = $this->getLineasDirecciones($presupuestoEntity);
|
|
||||||
$this->viewData['presupuestoEntity']->cambios_direcciones=$cambios_en_direcciones;
|
|
||||||
|
|
||||||
$this->viewData['POD'] = $this->getPOD();
|
|
||||||
|
|
||||||
$this->viewData['serviciosAutomaticos'] = [
|
|
||||||
'retractilado' => 3,
|
|
||||||
'retractilado5' => 5,
|
|
||||||
'ferro' => 24,
|
|
||||||
'prototipo' => 9,
|
|
||||||
'fajaColor' => 16,
|
|
||||||
'plegadoGuardas' => 62,
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->viewData['tipo_impresion_id'] = $presupuestoEntity->tipo_impresion_id; // Cosido tapa blanda JJO
|
|
||||||
|
|
||||||
$this->viewData = array_merge($this->viewData, $this->getStringsFromTipoImpresion($presupuestoEntity->tipo_impresion_id));
|
|
||||||
|
|
||||||
$this->viewData['formAction'] = route_to('updateCosidotapablanda', $id);
|
$this->viewData['formAction'] = route_to('updateCosidotapablanda', $id);
|
||||||
|
|
||||||
|
$this->viewData['paisList'] = $this->getPaisListItems();
|
||||||
|
|
||||||
|
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
|
||||||
|
$this->viewData['datosPresupuesto'] = $datosPresupuesto;
|
||||||
|
|
||||||
|
|
||||||
|
$cambios_lineas = $this->getLineasPresupuesto($presupuestoEntity)[0];
|
||||||
|
$this->viewData['updated']->cambios_lineas=$cambios_lineas;
|
||||||
|
|
||||||
|
$cambios_en_servicios = $this->getLineasServicios($presupuestoEntity)[0];
|
||||||
|
$this->viewData['updated']->cambios_servicios=$cambios_en_servicios;
|
||||||
|
|
||||||
|
$cambios_en_direcciones = $this->getLineasDirecciones($presupuestoEntity)[0];
|
||||||
|
$this->viewData['updated']->cambios_direcciones=$cambios_en_direcciones;
|
||||||
|
|
||||||
|
|
||||||
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
|
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
|
||||||
// se actualiza la bbdd para que sólo ejecute algunas funciones una vez
|
// se actualiza la bbdd para que sólo ejecute algunas funciones una vez
|
||||||
if($presupuestoEntity->is_duplicado){
|
if($presupuestoEntity->is_duplicado){
|
||||||
$this->model->removeIsDuplicado($presupuestoEntity->id);
|
$this->model->removeIsDuplicado($presupuestoEntity->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);
|
||||||
} // end function edit(...)
|
} // end function edit(...)
|
||||||
|
|
||||||
@ -517,83 +292,37 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
$reqData = $this->request->getPost();
|
$reqData = $this->request->getPost();
|
||||||
|
|
||||||
$type = $reqData['type'] ?? null;
|
$clienteId = $reqData['clienteId'] ?? 0;
|
||||||
|
|
||||||
if (is_null($type)) {
|
|
||||||
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);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
$search = $reqData['search']['value'];
|
$search = $reqData['search']['value'];
|
||||||
}
|
|
||||||
$start = $reqData['start'] ?? 0;
|
$start = $reqData['start'] ?? 0;
|
||||||
$length = $reqData['length'] ?? 5;
|
$length = $reqData['length'] ?? 5;
|
||||||
|
|
||||||
$requestedOrder1 = $reqData['order']['0']['column'] ?? 0;
|
$requestedOrder1 = $reqData['order']['0']['column'] ?? 0;
|
||||||
$order1 = PresupuestoModel::SORTABLE[$requestedOrder1 >= 0 ? $requestedOrder1 : 0];
|
$order1 = PresupuestoModel::SORTABLE_CLIENTE[$requestedOrder1 >= 0 ? $requestedOrder1 : 0];
|
||||||
$dir1 = $reqData['order']['0']['dir'] ?? 'asc';
|
$dir1 = $reqData['order']['0']['dir'] ?? 'asc';
|
||||||
$requestedOrder2 = $reqData['order']['1']['column'] ?? 0;
|
$requestedOrder2 = $reqData['order']['1']['column'] ?? $requestedOrder1;
|
||||||
$order2 = PresupuestoModel::SORTABLE[$requestedOrder2 >= 0 ? $requestedOrder1 : 0];
|
$order2 = PresupuestoModel::SORTABLE_CLIENTE[$requestedOrder2 >= 0 ? $requestedOrder2 : 0];
|
||||||
$dir2 = $reqData['order']['0']['dir'] ?? 'asc';
|
$dir2 = $reqData['order']['1']['dir'] ?? 'asc';
|
||||||
$requestedOrder3 = $reqData['order']['2']['column'] ?? 0;
|
$requestedOrder3 = $reqData['order']['2']['column'] ?? $requestedOrder1;
|
||||||
$order3 = PresupuestoModel::SORTABLE[$requestedOrder3 >= 0 ? $requestedOrder1 : 0];
|
$order3 = PresupuestoModel::SORTABLE_CLIENTE[$requestedOrder3 >= 0 ? $requestedOrder3 : 0];
|
||||||
$dir3 = $reqData['order']['0']['dir'] ?? 'asc';
|
$dir3 = $reqData['order']['2']['dir'] ?? 'asc';
|
||||||
|
|
||||||
// por defecto, se deja cosido tapa blanda por ahora JJO
|
|
||||||
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$searchValues = get_filter_datatables_columns($reqData);
|
$searchValues = get_filter_datatables_columns($reqData);
|
||||||
|
|
||||||
$resourceData = $this->model->getResource($searchValues, $tipo_impresion_id)->orderBy($order1, $dir1)->orderBy($order2, $dir2)
|
$resourceData = $this->model->getListaPresupuestosCliente($searchValues, $clienteId)->orderBy($order1, $dir1)->orderBy($order2, $dir2)
|
||||||
->orderBy($order3, $dir3)->limit($length, $start)->get()->getResultObject();
|
->orderBy($order3, $dir3)->limit($length, $start)->get()->getResultObject();
|
||||||
foreach ($resourceData as $item) :
|
|
||||||
if (isset($item->comentarios_pdf) && strlen($item->comentarios_pdf) > 100) :
|
|
||||||
$item->comentarios_pdf = character_limiter($item->comentarios_pdf, 100);
|
|
||||||
endif;
|
|
||||||
if (isset($item->causa_cancelacion) && strlen($item->causa_cancelacion) > 100) :
|
|
||||||
$item->causa_cancelacion = character_limiter($item->causa_cancelacion, 100);
|
|
||||||
endif;
|
|
||||||
if (isset($item->comentarios_cliente) && strlen($item->comentarios_cliente) > 100) :
|
|
||||||
$item->comentarios_cliente = character_limiter($item->comentarios_cliente, 100);
|
|
||||||
endif;
|
|
||||||
if (isset($item->comentarios_safekat) && strlen($item->comentarios_safekat) > 100) :
|
|
||||||
$item->comentarios_safekat = character_limiter($item->comentarios_safekat, 100);
|
|
||||||
endif;
|
|
||||||
if (isset($item->comentarios_tarifa) && strlen($item->comentarios_tarifa) > 100) :
|
|
||||||
$item->comentarios_tarifa = character_limiter($item->comentarios_tarifa, 100);
|
|
||||||
endif;
|
|
||||||
if (isset($item->comentarios_produccion) && strlen($item->comentarios_produccion) > 100) :
|
|
||||||
$item->comentarios_produccion = character_limiter($item->comentarios_produccion, 100);
|
|
||||||
endif;
|
|
||||||
if (isset($item->tirada_alternativa_json_data) && strlen($item->tirada_alternativa_json_data) > 100) :
|
|
||||||
$item->tirada_alternativa_json_data = character_limiter($item->tirada_alternativa_json_data, 100);
|
|
||||||
endif;
|
|
||||||
if (isset($item->titulo) && strlen($item->titulo) > 100) :
|
|
||||||
$item->titulo = character_limiter($item->titulo, 100);
|
|
||||||
endif;
|
|
||||||
if (isset($item->paginas_color_posicion) && strlen($item->paginas_color_posicion) > 100) :
|
|
||||||
$item->paginas_color_posicion = character_limiter($item->paginas_color_posicion, 100);
|
|
||||||
endif;
|
|
||||||
if (isset($item->aprobado_json_data) && strlen($item->aprobado_json_data) > 100) :
|
|
||||||
$item->aprobado_json_data = character_limiter($item->aprobado_json_data, 100);
|
|
||||||
endif;
|
|
||||||
if (isset($item->comparador_json_data) && strlen($item->comparador_json_data) > 100) :
|
|
||||||
$item->comparador_json_data = character_limiter($item->comparador_json_data, 100);
|
|
||||||
endif;
|
|
||||||
if (isset($item->ws_externo_json_data) && strlen($item->ws_externo_json_data) > 100) :
|
|
||||||
$item->ws_externo_json_data = character_limiter($item->ws_externo_json_data, 100);
|
|
||||||
endif;
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $this->respond(Collection::datatable(
|
return $this->respond(Collection::datatable(
|
||||||
$resourceData,
|
$resourceData,
|
||||||
$this->model->getResource("", $tipo_impresion_id)->countAllResults(),
|
$this->model->getListaPresupuestosCliente("", $clienteId)->countAllResults(),
|
||||||
$this->model->getResource($search, $tipo_impresion_id)->countAllResults()
|
$this->model->getListaPresupuestosCliente($search, $clienteId)->countAllResults()
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
@ -601,6 +330,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function presupuesto()
|
public function presupuesto()
|
||||||
{
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
@ -773,6 +503,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$newTokenHash = csrf_hash();
|
$newTokenHash = csrf_hash();
|
||||||
$csrfTokenName = csrf_token();
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
|
$confirmar = $reqData['confirmar'] ?? 0;
|
||||||
|
|
||||||
$datosCabecera = $reqData['datos_cabecera'] ?? [];
|
$datosCabecera = $reqData['datos_cabecera'] ?? [];
|
||||||
|
|
||||||
$tirada = $reqData['datos_libro']['tirada'] ?? 0;
|
$tirada = $reqData['datos_libro']['tirada'] ?? 0;
|
||||||
@ -852,8 +584,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (isset($resultado_presupuesto['exception'])) {
|
||||||
else if(isset($resultado_presupuesto['exception'])){
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'error' => $resultado_presupuesto['exception'],
|
'error' => $resultado_presupuesto['exception'],
|
||||||
$csrfTokenName => $newTokenHash
|
$csrfTokenName => $newTokenHash
|
||||||
@ -871,7 +602,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$proporcion = intval($direccion['unidades']) / $selected_tirada * 100.0;
|
$proporcion = intval($direccion['unidades']) / $selected_tirada * 100.0;
|
||||||
$unidades_calculo = floor($tirada[$i] * $proporcion / 100.0);
|
$unidades_calculo = floor($tirada[$i] * $proporcion / 100.0);
|
||||||
$coste_envio = $this->calcular_coste_envio(
|
$coste_envio = $this->calcular_coste_envio(
|
||||||
$direccion['id'], $peso_libro, $unidades_calculo, $direccion['tipo']=='cajas'?0:1);
|
$direccion['id'],
|
||||||
|
$peso_libro,
|
||||||
|
$unidades_calculo,
|
||||||
|
$direccion['tipo'] == 'cajas' ? 0 : 1
|
||||||
|
);
|
||||||
if (count($coste_envio) > 0) {
|
if (count($coste_envio) > 0) {
|
||||||
$coste = floatval($coste_envio[0]->coste);
|
$coste = floatval($coste_envio[0]->coste);
|
||||||
$margen = ($coste * floatval($coste_envio[0]->margen)) / 100.0;
|
$margen = ($coste * floatval($coste_envio[0]->margen)) / 100.0;
|
||||||
@ -905,15 +640,20 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
'total_pedido' => $total_pedido,
|
'total_pedido' => $total_pedido,
|
||||||
'precio_unidad' => $precio_u,
|
'precio_unidad' => $precio_u,
|
||||||
));
|
));
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$resumen_totales = $resultado_presupuesto['info']['totales'][$i];
|
$resumen_totales = $resultado_presupuesto['info']['totales'][$i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $model_presupuesto->insertarPresupuestoCliente(
|
$id = $model_presupuesto->insertarPresupuestoCliente(
|
||||||
$selected_tirada, $datos_presupuesto, $datosCabecera, $resultado_presupuesto['info'],
|
$selected_tirada,
|
||||||
$resumen_totales, $iva_reducido, $tiradas_alternativas);
|
$datos_presupuesto,
|
||||||
|
$datosCabecera,
|
||||||
|
$resultado_presupuesto['info'],
|
||||||
|
$resumen_totales,
|
||||||
|
$iva_reducido,
|
||||||
|
$tiradas_alternativas
|
||||||
|
);
|
||||||
|
|
||||||
// Lineas Presupuesto
|
// Lineas Presupuesto
|
||||||
foreach ($resultado_presupuesto['info']['interior'] as $linea) {
|
foreach ($resultado_presupuesto['info']['interior'] as $linea) {
|
||||||
@ -936,11 +676,9 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
if ($servicio->tarifa_id == 3 || $servicio->tarifa_id == 5 || $servicio->tarifa_id == 16) {
|
if ($servicio->tarifa_id == 3 || $servicio->tarifa_id == 5 || $servicio->tarifa_id == 16) {
|
||||||
// Servicios acabado
|
// Servicios acabado
|
||||||
$this->guardarServicio($id, $servicio, 'acabado');
|
$this->guardarServicio($id, $servicio, 'acabado');
|
||||||
|
|
||||||
} else if ($servicio->tarifa_id == 24 || $servicio->tarifa_id == 9) {
|
} else if ($servicio->tarifa_id == 24 || $servicio->tarifa_id == 9) {
|
||||||
// Servicios extra
|
// Servicios extra
|
||||||
$this->guardarServicio($id, $servicio, 'extra');
|
$this->guardarServicio($id, $servicio, 'extra');
|
||||||
|
|
||||||
} else if ($servicio->tarifa_id == 62) {
|
} else if ($servicio->tarifa_id == 62) {
|
||||||
// Servicios manipulado
|
// Servicios manipulado
|
||||||
$this->guardarServicio($id, $servicio, 'manipulado');
|
$this->guardarServicio($id, $servicio, 'manipulado');
|
||||||
@ -951,11 +689,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$this->guardarLineaEnvio($id, $direccion, $peso_libro);
|
$this->guardarLineaEnvio($id, $direccion, $peso_libro);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($confirmar == 1){
|
||||||
|
$model_presupuesto->confirmarPresupuesto($id);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'value' => $id,
|
'status' => $id,
|
||||||
|
'url' => site_url('presupuestocliente/list'),
|
||||||
|
'message' => lang('Basic.global.saveSuccess', [lang('Basic.global.record')]),
|
||||||
$csrfTokenName => $newTokenHash
|
$csrfTokenName => $newTokenHash
|
||||||
]);
|
]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
}
|
}
|
||||||
@ -967,14 +710,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
* Funciones auxiliares
|
* Funciones auxiliares
|
||||||
*
|
*
|
||||||
**********************/
|
**********************/
|
||||||
protected function guardarLineaPresupuesto($presupuestoId, $linea){
|
protected function guardarLineaPresupuesto($presupuestoId, $linea)
|
||||||
|
{
|
||||||
|
|
||||||
$model = new PresupuestoLineaModel();
|
$model = new PresupuestoLineaModel();
|
||||||
$model->insertLPFromBackend($presupuestoId, $linea);
|
$model->insertLPFromBackend($presupuestoId, $linea);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function guardarLineaEnvio($presupuestoId, $direccion, $peso_libro){
|
protected function guardarLineaEnvio($presupuestoId, $direccion, $peso_libro)
|
||||||
|
{
|
||||||
|
|
||||||
$unidades = intval($direccion['unidades']);
|
$unidades = intval($direccion['unidades']);
|
||||||
$peso_envio = $peso_libro * $unidades / 1000.0;
|
$peso_envio = $peso_libro * $unidades / 1000.0;
|
||||||
@ -998,7 +743,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function guardarServicio($presupuestoId, $servicio, $tipo){
|
protected function guardarServicio($presupuestoId, $servicio, $tipo)
|
||||||
|
{
|
||||||
|
|
||||||
if ($tipo == 'encuadernacion') {
|
if ($tipo == 'encuadernacion') {
|
||||||
$model = new PresupuestoEncuadernacionesModel();
|
$model = new PresupuestoEncuadernacionesModel();
|
||||||
@ -1013,8 +759,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
'margen' => $servicio->margen,
|
'margen' => $servicio->margen,
|
||||||
];
|
];
|
||||||
$model->insert($data);
|
$model->insert($data);
|
||||||
}
|
} else if ($tipo == 'extra') {
|
||||||
else if($tipo == 'extra'){
|
|
||||||
$model = new PresupuestoServiciosExtraModel();
|
$model = new PresupuestoServiciosExtraModel();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
@ -1025,8 +770,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
'margen' => $servicio->margen,
|
'margen' => $servicio->margen,
|
||||||
];
|
];
|
||||||
$model->insert($data);
|
$model->insert($data);
|
||||||
}
|
} else if ($tipo == 'acabado') {
|
||||||
else if($tipo == 'acabado'){
|
|
||||||
$model = new PresupuestoAcabadosModel();
|
$model = new PresupuestoAcabadosModel();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
@ -1037,8 +781,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
'margen' => $servicio->margen,
|
'margen' => $servicio->margen,
|
||||||
];
|
];
|
||||||
$model->insert($data);
|
$model->insert($data);
|
||||||
}
|
} else if ($tipo == 'manipulado') {
|
||||||
else if($tipo == 'manipulado'){
|
|
||||||
$model = new PresupuestoManipuladosModel();
|
$model = new PresupuestoManipuladosModel();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
@ -1053,7 +796,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function calcular_coste_envio($direccionId, $peso, $unidades, $entregaPieCalle){
|
protected function calcular_coste_envio($direccionId, $peso, $unidades, $entregaPieCalle)
|
||||||
|
{
|
||||||
|
|
||||||
$model = model('App\Models\Clientes\ClienteDireccionesModel');
|
$model = model('App\Models\Clientes\ClienteDireccionesModel');
|
||||||
$data = $model->getDireccion($direccionId);
|
$data = $model->getDireccion($direccionId);
|
||||||
@ -1214,8 +958,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$peso_interior += floatval($linea['peso']);
|
$peso_interior += floatval($linea['peso']);
|
||||||
$lomo += floatval($linea['mano']);
|
$lomo += floatval($linea['mano']);
|
||||||
if ($extra_info) {
|
if ($extra_info) {
|
||||||
$this->calcular_coste_linea($linea,
|
$this->calcular_coste_linea(
|
||||||
$totalPapel, $margenPapel, $sumForFactor, $totalImpresion, $margenImpresion);
|
$linea,
|
||||||
|
$totalPapel,
|
||||||
|
$margenPapel,
|
||||||
|
$sumForFactor,
|
||||||
|
$totalImpresion,
|
||||||
|
$margenImpresion
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1256,8 +1006,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$lomo += floatval($linea['mano']);
|
$lomo += floatval($linea['mano']);
|
||||||
if ($extra_info) {
|
if ($extra_info) {
|
||||||
|
|
||||||
$this->calcular_coste_linea($linea,
|
$this->calcular_coste_linea(
|
||||||
$totalPapel, $margenPapel, $sumForFactor, $totalImpresion, $margenImpresion);
|
$linea,
|
||||||
|
$totalPapel,
|
||||||
|
$margenPapel,
|
||||||
|
$sumForFactor,
|
||||||
|
$totalImpresion,
|
||||||
|
$margenImpresion
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1290,8 +1046,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$lomo += floatval($cubierta['mano']);
|
$lomo += floatval($cubierta['mano']);
|
||||||
if ($extra_info) {
|
if ($extra_info) {
|
||||||
|
|
||||||
$this->calcular_coste_linea($linea,
|
$this->calcular_coste_linea(
|
||||||
$totalPapel, $margenPapel, $sumForFactor, $totalImpresion, $margenImpresion);
|
$linea,
|
||||||
|
$totalPapel,
|
||||||
|
$margenPapel,
|
||||||
|
$sumForFactor,
|
||||||
|
$totalImpresion,
|
||||||
|
$margenImpresion
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($coste_cubierta <= 0)
|
if ($coste_cubierta <= 0)
|
||||||
@ -1341,8 +1103,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$peso_sobrecubierta += floatval($linea_sobrecubierta['peso']);
|
$peso_sobrecubierta += floatval($linea_sobrecubierta['peso']);
|
||||||
if ($extra_info) {
|
if ($extra_info) {
|
||||||
|
|
||||||
$this->calcular_coste_linea($linea,
|
$this->calcular_coste_linea(
|
||||||
$totalPapel, $margenPapel, $sumForFactor, $totalImpresion, $margenImpresion);
|
$linea,
|
||||||
|
$totalPapel,
|
||||||
|
$margenPapel,
|
||||||
|
$sumForFactor,
|
||||||
|
$totalImpresion,
|
||||||
|
$margenImpresion
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($coste_sobrecubierta <= 0)
|
if ($coste_sobrecubierta <= 0)
|
||||||
@ -1404,8 +1172,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$peso_guardas += floatval($guardas['peso']);
|
$peso_guardas += floatval($guardas['peso']);
|
||||||
if ($extra_info) {
|
if ($extra_info) {
|
||||||
|
|
||||||
$this->calcular_coste_linea($linea,
|
$this->calcular_coste_linea(
|
||||||
$totalPapel, $margenPapel, $sumForFactor, $totalImpresion, $margenImpresion);
|
$linea,
|
||||||
|
$totalPapel,
|
||||||
|
$margenPapel,
|
||||||
|
$sumForFactor,
|
||||||
|
$totalImpresion,
|
||||||
|
$margenImpresion
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($coste_guardas <= 0)
|
if ($coste_guardas <= 0)
|
||||||
@ -1540,7 +1314,8 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
'porcentajeMargenPapel' => $porcentajeMargenPapel,
|
'porcentajeMargenPapel' => $porcentajeMargenPapel,
|
||||||
'porcentajeMargenImpresion' => $porcentajeMargenImpresion,
|
'porcentajeMargenImpresion' => $porcentajeMargenImpresion,
|
||||||
'porcentajeMargenServicios' => $porcentajeMargenServicios));
|
'porcentajeMargenServicios' => $porcentajeMargenServicios
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($extra_info && $tirada[$t] == $selected_tirada) {
|
if ($extra_info && $tirada[$t] == $selected_tirada) {
|
||||||
@ -1574,14 +1349,14 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $return_data;
|
return $return_data;
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return ['exception' => $e->getMessage()];
|
return ['exception' => $e->getMessage()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function calcular_coste_linea($linea, &$totalPapel, &$margenPapel, &$sumForFactor, &$totalImpresion, &$margenImpresion){
|
protected function calcular_coste_linea($linea, &$totalPapel, &$margenPapel, &$sumForFactor, &$totalImpresion, &$margenImpresion)
|
||||||
|
{
|
||||||
if (count($linea) == 0)
|
if (count($linea) == 0)
|
||||||
return;
|
return;
|
||||||
$totalPapel += $linea['precio_pedido'];
|
$totalPapel += $linea['precio_pedido'];
|
||||||
@ -1601,7 +1376,6 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
$margenImpresion += $linea['margen_impresion_horas'];
|
$margenImpresion += $linea['margen_impresion_horas'];
|
||||||
$margenImpresion += $linea['margen_click_pedido'];
|
$margenImpresion += $linea['margen_click_pedido'];
|
||||||
$sumForFactor -= $linea['margen_click_pedido'];
|
$sumForFactor -= $linea['margen_click_pedido'];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function calcular_lomo($lineas, $lomo_inicial)
|
protected function calcular_lomo($lineas, $lomo_inicial)
|
||||||
@ -1722,4 +1496,60 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getLineasPresupuesto($presupuestoEntity){
|
||||||
|
$lineas = (new PresupuestoLineaModel())->getLineasPresupuesto($presupuestoEntity->id);
|
||||||
|
|
||||||
|
$input_data = [];
|
||||||
|
$input_data['presupuesto'] = $presupuestoEntity;
|
||||||
|
|
||||||
|
return PresupuestoService::checkLineasPresupuesto($input_data, $lineas);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getLineasServicios($presupuestoEntity){
|
||||||
|
|
||||||
|
$serviciosPresupuesto = (object)array();
|
||||||
|
|
||||||
|
$serviciosPresupuesto->serviciosAcabado = (new PresupuestoAcabadosModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||||
|
$serviciosPresupuesto->serviciosPreimpresion = (new PresupuestoPreimpresionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||||
|
$serviciosPresupuesto->serviciosEncuadernacion = (new PresupuestoEncuadernacionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||||
|
$serviciosPresupuesto->serviciosManipulado = (new PresupuestoManipuladosModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||||
|
$serviciosPresupuesto->serviciosExtra = (new PresupuestoServiciosExtraModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
|
||||||
|
|
||||||
|
$input_data = [];
|
||||||
|
$input_data['presupuesto_id'] = $presupuestoEntity->id;
|
||||||
|
$input_data['tipo_impresion_id'] = $presupuestoEntity->tipo_impresion_id;
|
||||||
|
$input_data['tirada'] = $presupuestoEntity->tirada;
|
||||||
|
$input_data['POD'] = $this->getPOD();
|
||||||
|
$input_data['paginas'] = $presupuestoEntity->paginas;
|
||||||
|
$input_data['is_duplicado'] = $presupuestoEntity->is_duplicado;
|
||||||
|
|
||||||
|
if($presupuestoEntity->papel_formato_personalizado){
|
||||||
|
$input_data['ancho'] = $presupuestoEntity->ancho;
|
||||||
|
$input_data['alto'] = $presupuestoEntity->alto;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$model = model("App\Models\Configuracion\PapelFormatoModel");
|
||||||
|
$papel = $model->find($presupuestoEntity->papel_formato_id);
|
||||||
|
if($papel){
|
||||||
|
$input_data['ancho'] = $papel->ancho;
|
||||||
|
$input_data['alto'] = $papel->alto;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$input_data['ancho'] = 0;
|
||||||
|
$input_data['alto'] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PresupuestoService::checkLineasServicios($input_data, $serviciosPresupuesto);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getLineasDirecciones($presupuestoEntity){
|
||||||
|
|
||||||
|
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||||
|
$direccionesEnvio = $model->where('presupuesto_id', $presupuestoEntity->id)->findAll();
|
||||||
|
|
||||||
|
return PresupuestoService::checkLineasEnvios($direccionesEnvio);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ return [
|
|||||||
'presupuestoCosidotapaduraList' => 'Lista presupuestos Libros Cosido Tapa Dura',
|
'presupuestoCosidotapaduraList' => 'Lista presupuestos Libros Cosido Tapa Dura',
|
||||||
'presupuestoCosidotapablandaList' => 'Lista presupuestos Libros Cosido Tapa Blanda',
|
'presupuestoCosidotapablandaList' => 'Lista presupuestos Libros Cosido Tapa Blanda',
|
||||||
'presupuesto' => 'Presupuesto',
|
'presupuesto' => 'Presupuesto',
|
||||||
|
'presupuestos' => 'Presupuestos',
|
||||||
|
|
||||||
'libroCosidoTapaBlanda' => "Cosido Tapa Blanda",
|
'libroCosidoTapaBlanda' => "Cosido Tapa Blanda",
|
||||||
'libroCosidoTapaDura' => "Cosido Tapa Dura",
|
'libroCosidoTapaDura' => "Cosido Tapa Dura",
|
||||||
|
|||||||
@ -30,6 +30,20 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
10 => "t6.estado",
|
10 => "t6.estado",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const SORTABLE_CLIENTE = [
|
||||||
|
0 => "t1.id",
|
||||||
|
1 => "t1.created_at",
|
||||||
|
2 => "t7.codigo",
|
||||||
|
3 => "t2.nombre",
|
||||||
|
4 => "t3.first_name",
|
||||||
|
5 => "t1.titulo",
|
||||||
|
6 => "t5.nombre",
|
||||||
|
8 => "t1.paginas",
|
||||||
|
9 => "t1.tirada",
|
||||||
|
10 => "t1.total_presupuesto",
|
||||||
|
11 => "t6.estado",
|
||||||
|
];
|
||||||
|
|
||||||
protected $allowedFields = [
|
protected $allowedFields = [
|
||||||
"cliente_id",
|
"cliente_id",
|
||||||
"user_created_id",
|
"user_created_id",
|
||||||
@ -313,6 +327,55 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
return $builder;
|
return $builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getListaPresupuestosCliente($search = [] , $clienteId){
|
||||||
|
|
||||||
|
$builder = $this->db
|
||||||
|
->table($this->table . " t1")
|
||||||
|
->select(
|
||||||
|
"t1.id AS id, t1.created_at AS fecha, t7.codigo as codigo, t2.nombre AS cliente,
|
||||||
|
CONCAT(t3.first_name, ' ', t3.last_name) AS comercial, t1.titulo AS titulo,
|
||||||
|
t5.nombre AS pais, t1.inc_rei AS inc_rei, t1.paginas AS paginas, t1.tirada AS tirada,
|
||||||
|
t1.total_presupuesto AS total_presupuesto, t1.total_presupuesto AS total_presupuesto,
|
||||||
|
t6.estado AS estado"
|
||||||
|
);
|
||||||
|
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
|
||||||
|
$builder->join("users t3", "t1.user_update_id = t3.id", "left");
|
||||||
|
$builder->join("lg_paises t5", "t1.pais_id = t5.id", "left");
|
||||||
|
$builder->join("presupuesto_estados t6", "t1.estado_id = t6.id", "left");
|
||||||
|
$builder->join("tipos_presupuestos t7", "t1.tipo_impresion_id = t7.id", "left");
|
||||||
|
|
||||||
|
if($clienteId != 0)
|
||||||
|
$builder->where("t1.cliente_id", $clienteId);
|
||||||
|
|
||||||
|
$builder->where("t1.is_deleted", 0);
|
||||||
|
|
||||||
|
if (empty($search))
|
||||||
|
return $builder;
|
||||||
|
else {
|
||||||
|
$builder->groupStart();
|
||||||
|
foreach ($search as $col_search) {
|
||||||
|
if ($col_search[0] != 1)
|
||||||
|
$builder->like(self::SORTABLE_CLIENTE[$col_search[0]], $col_search[2]);
|
||||||
|
else {
|
||||||
|
$dates = explode(" ", $col_search[2]);
|
||||||
|
$builder->where(self::SORTABLE_CLIENTE[$col_search[0]] . ">=", $dates[0]);
|
||||||
|
$builder->where(self::SORTABLE_CLIENTE[$col_search[0]] . "<=", $dates[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$builder->groupEnd();
|
||||||
|
return $builder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmarPresupuesto($presupuesto_id)
|
||||||
|
{
|
||||||
|
$this->db
|
||||||
|
->table($this->table . " t1")
|
||||||
|
->where('t1.id', $presupuesto_id)
|
||||||
|
->set('t1.estado', 2)
|
||||||
|
->update();
|
||||||
|
}
|
||||||
|
|
||||||
function insertarPresupuestoCliente($tirada, $data, $data_cabecera, $extra_info, $resumen_totales, $iva_reducido, $tiradas_alternativas)
|
function insertarPresupuestoCliente($tirada, $data, $data_cabecera, $extra_info, $resumen_totales, $iva_reducido, $tiradas_alternativas)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -390,6 +453,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
|
|
||||||
'total_precio_unidad' => round(($totalCostes + $totalMargenes)/$tirada, 4),
|
'total_precio_unidad' => round(($totalCostes + $totalMargenes)/$tirada, 4),
|
||||||
'total_presupuesto' => round($totalCostes + $totalMargenes, 2),
|
'total_presupuesto' => round($totalCostes + $totalMargenes, 2),
|
||||||
|
'total_aceptado' => round($totalCostes + $totalMargenes, 2),
|
||||||
|
|
||||||
'total_factor' => round(($totalCostes + $totalMargenes-$resumen_totales['coste_envio']-$resumen_totales['margen_envio'])/$resumen_totales['sumForFactor'], 2),
|
'total_factor' => round(($totalCostes + $totalMargenes-$resumen_totales['coste_envio']-$resumen_totales['margen_envio'])/$resumen_totales['sumForFactor'], 2),
|
||||||
'total_factor_ponderado' => round(($totalCostes + $totalMargenes-$resumen_totales['coste_envio']-$resumen_totales['margen_envio'])/$resumen_totales['sumForFactorPonderado'], 2),
|
'total_factor_ponderado' => round(($totalCostes + $totalMargenes-$resumen_totales['coste_envio']-$resumen_totales['margen_envio'])/$resumen_totales['sumForFactorPonderado'], 2),
|
||||||
@ -463,4 +527,6 @@ class PresupuestoModel extends \App\Models\BaseModel
|
|||||||
$json = json_encode($values);
|
$json = json_encode($values);
|
||||||
return $json;
|
return $json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -123,6 +123,18 @@ function getTotalEnvio(){
|
|||||||
|
|
||||||
$('#btnSave').on('click', function() {
|
$('#btnSave').on('click', function() {
|
||||||
|
|
||||||
|
finalizarPresupuesto(false);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#btnConfirm').on('click', function() {
|
||||||
|
|
||||||
|
finalizarPresupuesto(true);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function finalizarPresupuesto(confirmar){
|
||||||
let servicios = [];
|
let servicios = [];
|
||||||
$('.servicio-extra:checked').each(function () {
|
$('.servicio-extra:checked').each(function () {
|
||||||
servicios.push($(this).attr('serv_id'));
|
servicios.push($(this).attr('serv_id'));
|
||||||
@ -205,7 +217,9 @@ $('#btnSave').on('click', function() {
|
|||||||
tirada: tirada,
|
tirada: tirada,
|
||||||
peso: peso_libro,
|
peso: peso_libro,
|
||||||
iva_reducido: $('#ivaReducido').val()==1?1:0,
|
iva_reducido: $('#ivaReducido').val()==1?1:0,
|
||||||
|
confirmar: confirmar,
|
||||||
},
|
},
|
||||||
|
|
||||||
datos = Object.assign(datos, window.token_ajax)
|
datos = Object.assign(datos, window.token_ajax)
|
||||||
|
|
||||||
$('#loader').show();
|
$('#loader').show();
|
||||||
@ -215,15 +229,18 @@ $('#btnSave').on('click', function() {
|
|||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: datos,
|
data: datos,
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if(response.length > 0) {
|
|
||||||
|
|
||||||
|
if(Object.keys(response).length > 0) {
|
||||||
|
if(response.status > 0){
|
||||||
|
window.location.href = response.url;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$('#loader').hide();
|
$('#loader').hide();
|
||||||
|
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
$('#loader').hide();
|
$('#loader').hide();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
|
||||||
@ -0,0 +1,342 @@
|
|||||||
|
<?=$this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||||
|
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
|
||||||
|
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||||
|
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||||
|
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||||
|
<?=$this->section('content'); ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
|
||||||
|
<div class="card card-info">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3 class="card-title"><?= $pageTitle ?></h3>
|
||||||
|
</div><!--//.card-header -->
|
||||||
|
<div class="card-body">
|
||||||
|
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||||
|
|
||||||
|
<table id="tableOfPresupuestos" class="table table-striped table-hover" style="width: 100%;">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Número</th>
|
||||||
|
<th><?= lang('Presupuestos.created_at') ?></th>
|
||||||
|
<th><?= lang('Presupuestos.tipoPresupuesto') ?></th>
|
||||||
|
<?php if ($clienteId == 0): ?>
|
||||||
|
<th><?= lang('Clientes.cliente') ?></th>
|
||||||
|
<?php endif; ?>
|
||||||
|
<th><?= lang('Presupuestos.titulo') ?></th>
|
||||||
|
<th class='noFilter'><?= lang('Presupuestos.paginas') ?></th>
|
||||||
|
<th class='noFilter'><?= lang('Presupuestos.tirada') ?></th>
|
||||||
|
<th class='noFilter'><?= lang('Presupuestos.totalPresupuesto') ?></th>
|
||||||
|
<th><?= lang('Presupuestos.presupuestoEstado') ?></th>
|
||||||
|
<th class="noFilter text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div><!--//.card-body -->
|
||||||
|
<div class="card-footer">
|
||||||
|
|
||||||
|
</div><!--//.card-footer -->
|
||||||
|
</div><!--//.card -->
|
||||||
|
</div><!--//.col -->
|
||||||
|
</div><!--//.row -->
|
||||||
|
|
||||||
|
<?=$this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
|
<?=$this->section('additionalInlineJs') ?>
|
||||||
|
|
||||||
|
const lastColNr = $('#tableOfPresupuestos').find("tr:first th").length - 1;
|
||||||
|
const actionBtns = function(data) {
|
||||||
|
return `
|
||||||
|
<td class="text-right py-0 align-middle">
|
||||||
|
<div class="btn-group btn-group-sm">
|
||||||
|
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a>
|
||||||
|
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||||
|
</div>
|
||||||
|
</td>`;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Setup - add a text input to each footer cell
|
||||||
|
$('#tableOfPresupuestos thead tr').clone(true).appendTo('#tableOfPresupuestos thead');
|
||||||
|
$('#tableOfPresupuestos thead tr:eq(1) th').each(function (i) {
|
||||||
|
if (!$(this).hasClass("noFilter")) {
|
||||||
|
var title = $(this).text();
|
||||||
|
if(i==1){
|
||||||
|
|
||||||
|
$(this).html('<input id="bs-rangepicker-range" type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
|
||||||
|
var bsRangePickerRange = $('#bs-rangepicker-range')
|
||||||
|
bsRangePickerRange.daterangepicker({
|
||||||
|
ranges: {
|
||||||
|
'<?= lang('datePicker.hoy') ?>': [moment(), moment()],
|
||||||
|
'<?= lang('datePicker.ayer') ?>': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||||
|
'<?= lang('datePicker.ultimos7') ?>': [moment().subtract(6, 'days'), moment()],
|
||||||
|
'<?= lang('datePicker.ultimos30') ?>': [moment().subtract(29, 'days'), moment()],
|
||||||
|
'<?= lang('datePicker.esteMes') ?>': [moment().startOf('month'), moment().endOf('month')],
|
||||||
|
'<?= lang('datePicker.ultimoMes') ?>': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||||
|
},
|
||||||
|
opens: 'right',
|
||||||
|
language: '<?= config('Basics')->i18n ?>',
|
||||||
|
"locale": {
|
||||||
|
"customRangeLabel": "<?= lang('datePicker.personalizar') ?>",
|
||||||
|
"format": "YYYY-MM-DD",
|
||||||
|
"separator": " ",
|
||||||
|
"applyLabel": "<?= lang('datePicker.aplicar') ?>",
|
||||||
|
"cancelLabel": "<?= lang('datePicker.limpiar') ?>",
|
||||||
|
|
||||||
|
},
|
||||||
|
"alwaysShowCalendars": true,
|
||||||
|
autoUpdateInput: false,
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
bsRangePickerRange.on('apply.daterangepicker', function(ev, picker) {
|
||||||
|
$(this).val(picker.startDate.format('YYYY-MM-DD') + ' ' + picker.endDate.format('YYYY-MM-DD'));
|
||||||
|
theTable
|
||||||
|
.column(i)
|
||||||
|
.search(this.value)
|
||||||
|
.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
bsRangePickerRange.on('cancel.daterangepicker', function(ev, picker) {
|
||||||
|
$(this).val('');
|
||||||
|
theTable
|
||||||
|
.column(i)
|
||||||
|
.search(this.value)
|
||||||
|
.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (i == 2) {
|
||||||
|
// Agregar un selector en la tercera columna
|
||||||
|
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
|
||||||
|
|
||||||
|
// Agregar opciones al selector
|
||||||
|
var selector = $('select', this);
|
||||||
|
selector.append('<option value="">Todos</option>'); // Opción vacía
|
||||||
|
selector.append('<option value="libroCosidoTapaBlanda"><?= lang('Presupuestos.libroCosidoTapaBlanda') ?></option>');
|
||||||
|
selector.append('<option value="libroCosidoTapaDura"><?= lang('Presupuestos.libroCosidoTapaDura') ?></option>');
|
||||||
|
selector.append('<option value="libroFresadoTapaBlanda"><?= lang('Presupuestos.libroFresadoTapaBlanda') ?></option>');
|
||||||
|
selector.append('<option value="libroFresadoTapaDura"><?= lang('Presupuestos.libroFresadoTapaDura') ?></option>');
|
||||||
|
selector.append('<option value="libroEspiralTapaDura"><?= lang('Presupuestos.libroEspiralTapaDura') ?></option>');
|
||||||
|
selector.append('<option value="libroEspiralTapaBlanda"><?= lang('Presupuestos.libroEspiralTapaBlanda') ?></option>');
|
||||||
|
selector.append('<option value="libroWireoTapaDura"><?= lang('Presupuestos.libroWireoTapaDura') ?></option>');
|
||||||
|
selector.append('<option value="libroWireoTapaBlanda"><?= lang('Presupuestos.libroWireoTapaBlanda') ?></option>');
|
||||||
|
selector.append('<option value="libroGrapado"><?= lang('Presupuestos.libroGrapado') ?></option>');
|
||||||
|
|
||||||
|
selector.on('change', function () {
|
||||||
|
var val = $.fn.dataTable.util.escapeRegex(
|
||||||
|
$(this).val()
|
||||||
|
);
|
||||||
|
theTable.column(i).search(val).draw();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$(this).html('<input type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
|
||||||
|
|
||||||
|
$('input', this).on('change clear', function () {
|
||||||
|
if (theTable.column(i).search() !== this.value) {
|
||||||
|
theTable
|
||||||
|
.column(i)
|
||||||
|
.search(this.value)
|
||||||
|
.draw();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$(this).html('<span></span>');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
theTable = $('#tableOfPresupuestos').DataTable({
|
||||||
|
orderCellsTop: true,
|
||||||
|
fixedHeader: true,
|
||||||
|
processing: true,
|
||||||
|
serverSide: true,
|
||||||
|
autoWidth: true,
|
||||||
|
responsive: true,
|
||||||
|
scrollX: true,
|
||||||
|
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
|
||||||
|
pageLength: 50,
|
||||||
|
lengthChange: true,
|
||||||
|
"dom": '<"mb-3"l>Brtip',
|
||||||
|
"buttons": [
|
||||||
|
'colvis', 'copy', 'csv', 'excel', 'print', {
|
||||||
|
extend: 'pdfHtml5',
|
||||||
|
orientation: 'landscape',
|
||||||
|
pageSize: 'A4'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
stateSave: false,
|
||||||
|
order: [[1, 'asc']],
|
||||||
|
language: {
|
||||||
|
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||||
|
},
|
||||||
|
ajax : $.fn.dataTable.pipeline( {
|
||||||
|
url: '<?= route_to('datatableOfPresupuestos') ?>',
|
||||||
|
method: 'POST',
|
||||||
|
data: function(q) {
|
||||||
|
q.cliente = <? echo $clienteId; ?>;
|
||||||
|
},
|
||||||
|
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||||
|
async: true,
|
||||||
|
}),
|
||||||
|
columnDefs: [
|
||||||
|
{
|
||||||
|
orderable: false,
|
||||||
|
searchable: false,
|
||||||
|
targets: [lastColNr]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
columns : [
|
||||||
|
{ 'data': 'id' },
|
||||||
|
{ 'data': 'fecha' },
|
||||||
|
{ 'data': 'codigo',
|
||||||
|
render: function(data, type, row, meta) {
|
||||||
|
switch(data){
|
||||||
|
case "libroCosidoTapaBlanda":
|
||||||
|
return '<?= lang('Presupuestos.libroCosidoTapaBlanda') ?>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "libroCosidoTapaDura":
|
||||||
|
return '<?= lang('Presupuestos.libroCosidoTapaDura') ?>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "libroFresadoTapaBlanda":
|
||||||
|
return '<?= lang('Presupuestos.libroFresadoTapaBlanda') ?>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "libroFresadoTapaDura":
|
||||||
|
return '<?= lang('Presupuestos.libroFresadoTapaDura') ?>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case "libroEspiralTapaDura":
|
||||||
|
return '<?= lang('Presupuestos.libroEspiralTapaDura') ?>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "libroEspiralTapaBlanda":
|
||||||
|
return '<?= lang('Presupuestos.libroEspiralTapaBlanda') ?>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "libroWireoTapaDura":
|
||||||
|
return '<?= lang('Presupuestos.libroWireoTapaDura') ?>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "libroWireoTapaBlanda":
|
||||||
|
return '<?= lang('Presupuestos.libroWireoTapaBlanda') ?>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "libroGrapado":
|
||||||
|
return '<?= lang('Presupuestos.libroGrapado') ?>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return data; // Debug
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
<?php if ($clienteId == 0): ?>
|
||||||
|
{ 'data': 'cliente' },
|
||||||
|
<?php endif; ?>
|
||||||
|
{ 'data': 'titulo' },
|
||||||
|
{ 'data': 'paginas' },
|
||||||
|
{ 'data': 'tirada' },
|
||||||
|
{ 'data': 'total_presupuesto' },
|
||||||
|
{ 'data': 'estado' ,
|
||||||
|
'render': function ( data, type, row, meta ) {
|
||||||
|
if(data=='borrador')
|
||||||
|
return '<?= lang('Presupuestos.presupuestoEstadoBorrador') ?>';
|
||||||
|
else if(data=='aceptado')
|
||||||
|
return '<?= lang('Presupuestos.presupuestoEstadoAceptado') ?>';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ 'data': actionBtns }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
theTable.on( 'draw.dt', function () {
|
||||||
|
|
||||||
|
const dateCols = [1];
|
||||||
|
const priceCols = [7];
|
||||||
|
|
||||||
|
for (let coln of dateCols) {
|
||||||
|
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
|
||||||
|
const datestr = cell.innerHTML;
|
||||||
|
const dateStrLen = datestr.toString().trim().length;
|
||||||
|
if (dateStrLen > 0) {
|
||||||
|
let dateTimeParts= datestr.split(/[- :]/); // regular expression split that creates array with: year, month, day, hour, minutes, seconds values
|
||||||
|
dateTimeParts[1]--; // monthIndex begins with 0 for January and ends with 11 for December so we need to decrement by one
|
||||||
|
const d = new Date(...dateTimeParts); // new Date(datestr);
|
||||||
|
cell.innerHTML = d.toLocaleDateString();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let coln of priceCols) {
|
||||||
|
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
|
||||||
|
cell.innerHTML = parseFloat(cell.innerHTML).toFixed(2);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$(document).on('click', '.btn-edit', function(e) {
|
||||||
|
window.location.href = `/presupuestos/presupuestocliente/edit/${$(this).attr('data-id')}/`;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$(document).on('click', '.btn-delete', function(e) {
|
||||||
|
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$(document).on('click', '.btn-remove', function(e) {
|
||||||
|
const dataId = $(this).attr('data-id');
|
||||||
|
const row = $(this).closest('tr');
|
||||||
|
if ($.isNumeric(dataId)) {
|
||||||
|
$.ajax({
|
||||||
|
url: `/presupuestos/presupuestocliente/delete/${dataId}`,
|
||||||
|
method: 'GET',
|
||||||
|
}).done((data, textStatus, jqXHR) => {
|
||||||
|
$('#confirm2delete').modal('toggle');
|
||||||
|
theTable.clearPipeline();
|
||||||
|
theTable.row($(row)).invalidate().draw();
|
||||||
|
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||||
|
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||||
|
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
<?=$this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
|
<?=$this->section('css') ?>
|
||||||
|
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
|
||||||
|
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/fixedheader/fixedHeader.dataTables.min.css") ?>">
|
||||||
|
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/bootstrap-daterangepicker/bootstrap-daterangepicker.css') ?>" />
|
||||||
|
<?=$this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
|
<?= $this->section('additionalExternalJs') ?>
|
||||||
|
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
|
||||||
|
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
|
||||||
|
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
|
||||||
|
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
|
||||||
|
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.colVis.min.js") ?>"></script>
|
||||||
|
<script src="<?= site_url('themes/vuexy/vendor/libs/moment/moment.js') ?>"></script>
|
||||||
|
<script src="<?= site_url('themes/vuexy/vendor/libs/bootstrap-daterangepicker/bootstrap-daterangepicker.js') ?>"></script>
|
||||||
|
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
|
||||||
|
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
|
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></script>
|
||||||
|
<?=$this->endSection() ?>
|
||||||
|
|
||||||
@ -151,11 +151,20 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6 d-flex flex-row-reverse">
|
<div class="col-6 d-flex flex-row-reverse">
|
||||||
|
<?php if ($presupuestoEntity->estado_id == 1) : ?>
|
||||||
<button id="btnSave" class="btn btn-primary btn-submit waves-effect waves-light ml-2">
|
<button id="btnSave" class="btn btn-primary btn-submit waves-effect waves-light ml-2">
|
||||||
<span class="align-middle d-sm-inline-block d-none me-sm-1">Guardar</span>
|
<span class="align-middle d-sm-inline-block d-none me-sm-1">Guardar</span>
|
||||||
<i class="ti ti-arrow-right ti-xs"></i>
|
<i class="ti ti-arrow-right ti-xs"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
|
<?php endif; ?>
|
||||||
|
<button id="btnConfirm" class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
|
||||||
|
<span class="align-middle d-sm-inline-block d-none me-sm-1">Confirmar</span><i class="ti ti-check ti-xs"></i>
|
||||||
|
</button>
|
||||||
|
<button id="btnSave" class="btn btn-primary btn-submit waves-effect waves-light ml-2">
|
||||||
|
<span class="align-middle d-sm-inline-block d-none me-sm-1">Guardar</span>
|
||||||
|
<i class="ti ti-arrow-right ti-xs"></i>
|
||||||
|
</button>
|
||||||
|
<button id="btnConfirm" class="btn btn-success btn-submit btn-next mx-2 waves-effect waves-light">
|
||||||
<span class="align-middle d-sm-inline-block d-none me-sm-1">Confirmar</span><i class="ti ti-check ti-xs"></i>
|
<span class="align-middle d-sm-inline-block d-none me-sm-1">Confirmar</span><i class="ti ti-check ti-xs"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -62,7 +62,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<ul class="menu-sub">
|
<ul class="menu-sub">
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="<?= site_url("presupuestos/buscador") ?>" class="menu-link">
|
<a href="<?= route_to("listaPresupuestos") ?>" class="menu-link">
|
||||||
Mis presupuestos
|
Mis presupuestos
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
15804
xdebug.log
15804
xdebug.log
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user