mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
HEad fixed
This commit is contained in:
86
ci4/app/Controllers/Configuracion/MaquinaTarea.php
Normal file
86
ci4/app/Controllers/Configuracion/MaquinaTarea.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Configuracion;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\Configuracion\MaquinaTareaModel;
|
||||
use CodeIgniter\HTTP\Response;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
class MaquinaTarea extends BaseController
|
||||
{
|
||||
|
||||
protected MaquinaTareaModel $maquinaTareaModel;
|
||||
protected $format = 'json';
|
||||
protected array $viewData = [];
|
||||
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/configuracion/maquina_tareas/';
|
||||
protected static $controllerSlug = "maquina-tareas";
|
||||
protected $indexRoute = 'viewMaquinaTarea';
|
||||
protected $editRoute = 'editMaquinaTarea';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->maquinaTareaModel = model(MaquinaTareaModel::class);
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_maquina_tareas"), 'route' => site_url('configuracion/maquina-tareas'), 'active' => true]
|
||||
];
|
||||
return view(static::$viewPath . $this->indexRoute, $this->viewData);
|
||||
}
|
||||
public function viewForm(int $maquina_tarea_id)
|
||||
{
|
||||
$maquinaTarea = $this->maquinaTareaModel->find($maquina_tarea_id);
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_maquina_tareas"), 'route' => site_url('configuracion/maquina-tareas'), 'active' => false],
|
||||
['title' => $maquinaTarea->name, 'route' => site_url('configuracion/maquina-tareas/edit/' . $maquina_tarea_id), 'active' => true]
|
||||
];
|
||||
$this->viewData["model"] = $maquinaTarea;
|
||||
|
||||
return view(static::$viewPath . $this->editRoute, $this->viewData);
|
||||
}
|
||||
public function show(int $id)
|
||||
{
|
||||
$data = $this->maquinaTareaModel->find($id);
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function update_servicio_cliente(int $id)
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
$status = $this->maquinaTareaModel->update($id, [
|
||||
"name" => $data["name"],
|
||||
"description" => $data["description"]
|
||||
]);
|
||||
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $status]);
|
||||
}
|
||||
public function store()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$r = $this->maquinaTareaModel->insert($bodyData);
|
||||
return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r,"data" => $bodyData]);
|
||||
}
|
||||
public function delete(int $maquina_tarea_id){
|
||||
$r = $this->maquinaTareaModel->delete($maquina_tarea_id);
|
||||
return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => $r]);
|
||||
}
|
||||
public function datatable()
|
||||
{
|
||||
$query = $this->maquinaTareaModel->getQueryDatatable()->orderBy("created_at", "DESC");
|
||||
return DataTable::of($query)
|
||||
->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "")
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
}
|
||||
@ -9,6 +9,8 @@ use App\Models\Collection;
|
||||
use App\Entities\Configuracion\Maquina;
|
||||
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
use App\Services\MaquinaService;
|
||||
use CodeIgniter\Validation\Validation;
|
||||
|
||||
class Maquinas extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
@ -26,18 +28,19 @@ class Maquinas extends \App\Controllers\BaseResourceController
|
||||
protected static $viewPath = 'themes/vuexy/form/configuracion/maquinas/';
|
||||
|
||||
protected $indexRoute = 'maquinaList';
|
||||
|
||||
protected MaquinaService $maquinaService;
|
||||
protected Validation $validation;
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('Maquinas.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
$this->maquinaService = service('maquina');
|
||||
$this->validation = service('validation');
|
||||
// Se indica que este controlador trabaja con soft_delete
|
||||
$this->soft_delete = true;
|
||||
// Se indica el flag para los ficheros borrados
|
||||
$this->delete_flag = 1;
|
||||
|
||||
$this->viewData = ['usingServerSideDataTable' => true]; // JJO
|
||||
|
||||
// Breadcrumbs (IMN)
|
||||
@ -385,6 +388,19 @@ class Maquinas extends \App\Controllers\BaseResourceController
|
||||
];
|
||||
return $tipoOptions;
|
||||
}
|
||||
public function duplicate(int $maquina_id)
|
||||
{
|
||||
|
||||
$bodyData = $this->request->getPost();
|
||||
$validated = $this->validation->run($bodyData,'maquina_duplicate');
|
||||
if($validated){
|
||||
$this->maquinaService->setMaquina($maquina_id);
|
||||
$duplicated = $this->maquinaService->duplicate($bodyData['name']);
|
||||
return $this->response->setJSON(["data" => $duplicated]);
|
||||
}else{
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -225,7 +225,9 @@ class Maquinaspapelesimpresion extends \App\Controllers\BaseResourceController {
|
||||
];
|
||||
|
||||
// Se checkea que no haya otro papel con ese gramaje seleccionado y que la accion sea activar ese papel
|
||||
if($this->model->getPapelActivo($maquina_id, $gramaje)->countAllResults() != 0 && intval($active)==1){
|
||||
// Esta funcionalidad esta mal: habría que comprobar también que tienen el mismo papel genérico. Se opta por
|
||||
// quitar la condición el 22012025
|
||||
/*if($this->model->getPapelActivo($maquina_id, $gramaje)->countAllResults() != 0 && intval($active)==1){
|
||||
$response['error']= lang('MaquinasPapelImpresion.gramaje_duplicado');;
|
||||
$ret_vals = [
|
||||
'DT_RowId' => 'row_'. $papel_id,
|
||||
@ -235,9 +237,9 @@ class Maquinaspapelesimpresion extends \App\Controllers\BaseResourceController {
|
||||
];
|
||||
$response['data'] = $ret_vals;
|
||||
}
|
||||
else{
|
||||
else{*/
|
||||
$this->model->updateRows([$data]);
|
||||
}
|
||||
//}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
@ -314,8 +314,15 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
|
||||
$tapa_dura = goSanitize($this->request->getGet('tapa_dura'))[0] ?? null;
|
||||
|
||||
$menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, false, $POD);
|
||||
$menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, true, $POD);
|
||||
$ancho = floatval($this->request->getGet('ancho') ?? 0);
|
||||
$alto = floatval($this->request->getGet('alto') ?? 0);
|
||||
$solapas = floatval($this->request->getGet('solapas') ?? 0);
|
||||
$lomo = floatval($this->request->getGet('lomo') ?? 0);
|
||||
|
||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||
|
||||
$menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada);
|
||||
$menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
@ -349,8 +356,17 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
$tipo = goSanitize($this->request->getGet('tipo'))[0];
|
||||
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
|
||||
|
||||
$ancho = floatval($this->request->getGet('ancho') ?? 0);
|
||||
$alto = floatval($this->request->getGet('alto') ?? 0);
|
||||
$solapas = floatval($this->request->getGet('solapas') ?? 0);
|
||||
$lomo = floatval($this->request->getGet('lomo') ?? 0);
|
||||
|
||||
$items = $this->model->getPapelCliente($tipo, $cubierta, null, true, $POD);
|
||||
$tapa_dura = $this->request->getGet('tapa_dura') ?? 0;
|
||||
|
||||
$anchoLibro = 2* $ancho + 2 * $solapas + $lomo;
|
||||
|
||||
$items = $this->model->getPapelCliente($tipo, $cubierta, null, $tapa_dura, true, $POD, $anchoLibro, $alto, $tirada);
|
||||
$items = array_map(function ($item) {
|
||||
return [
|
||||
'id' => $item->id,
|
||||
|
||||
@ -22,6 +22,7 @@ use
|
||||
|
||||
|
||||
use App\Models\Collection;
|
||||
use CodeIgniter\Validation\Validation;
|
||||
|
||||
|
||||
|
||||
@ -35,7 +36,6 @@ use App\Models\Configuracion\PapelImpresionTipologiaModel;
|
||||
use App\Models\Configuracion\MaquinasPapelesImpresionModel;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
|
||||
|
||||
class Papelesimpresion extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
|
||||
@ -52,6 +52,7 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController
|
||||
protected static $viewPath = 'themes/vuexy/form/configuracion/papel/';
|
||||
|
||||
protected $indexRoute = 'papelImpresionList';
|
||||
protected Validation $validation;
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
@ -66,6 +67,7 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController
|
||||
$this->delete_flag = 1;
|
||||
|
||||
$this->tpModel = new PapelImpresionTipologiaModel();
|
||||
$this->validation = service("validation");
|
||||
|
||||
// Breadcrumbs
|
||||
$this->viewData['breadcrumb'] = [
|
||||
@ -443,4 +445,27 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController
|
||||
$ma_pa_model->updateRows($active_values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Duplica el papel impresion y sus relaciones
|
||||
*
|
||||
* @param int $papel_impresion_id
|
||||
* @return Response
|
||||
*/
|
||||
public function duplicate( int $papel_impresion_id)
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$validated = $this->validation->run($bodyData, "papel_impresion_duplicate");
|
||||
if($validated){
|
||||
$papelImpresionEntity = $this->model->find($papel_impresion_id);
|
||||
$papelImpresionService = service('papel_impresion');
|
||||
$duplicated = $papelImpresionService
|
||||
->setPapelImpresionEntity($papelImpresionEntity)
|
||||
->duplicate($bodyData["name"]);
|
||||
return $this->response->setJSON(["data" => $duplicated]);
|
||||
|
||||
}else{
|
||||
return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Configuracion;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\Configuracion\ServicioClienteModel;
|
||||
use CodeIgniter\HTTP\Response;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
class ServicioCliente extends BaseController
|
||||
{
|
||||
|
||||
protected ServicioClienteModel $servicioClienteModel;
|
||||
protected $format = 'json';
|
||||
protected array $viewData = [];
|
||||
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/configuracion/servicios_cliente/';
|
||||
protected static $controllerSlug = "servicios";
|
||||
protected $indexRoute = 'viewServicioCliente';
|
||||
protected $editRoute = 'ServicioClienteEdit';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->servicioClienteModel = model(ServicioClienteModel::class);
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_servicios_cliente"), 'route' => site_url('configuracion/servicios'), 'active' => true]
|
||||
];
|
||||
return view(static::$viewPath . $this->indexRoute, $this->viewData);
|
||||
}
|
||||
public function viewForm(int $servicio_cliente_id)
|
||||
{
|
||||
$servicioCliente = $this->servicioClienteModel->find($servicio_cliente_id);
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_servicios_cliente"), 'route' => site_url('configuracion/servicios'), 'active' => false],
|
||||
['title' => $servicioCliente->nombre, 'route' => site_url('configuracion/servicios/edit/' . $servicio_cliente_id), 'active' => true]
|
||||
];
|
||||
$this->viewData["model"] = $servicioCliente;
|
||||
|
||||
return view(static::$viewPath . 'ServicioClienteEdit', $this->viewData);
|
||||
}
|
||||
public function show(int $id)
|
||||
{
|
||||
$data = $this->servicioClienteModel->find($id)->withAllTarifas();
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function update_servicio_cliente(int $id)
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
$status = $this->servicioClienteModel->update($id, [
|
||||
"nombre" => $data["nombre"],
|
||||
"code" => $data["code"]
|
||||
]);
|
||||
if (isset($data["tarifa_manipulado_id"])) {
|
||||
$this->servicioClienteModel->upsertTarifaManipulado($id, $data["tarifa_manipulado_id"]);
|
||||
}else if(isset($data["tarifa_acabado_id"])) {
|
||||
|
||||
$this->servicioClienteModel->upsertTarifaAcabado($id, $data["tarifa_acabado_id"]);
|
||||
}else{
|
||||
$this->servicioClienteModel->detachTarifas($id);
|
||||
}
|
||||
|
||||
return $this->response->setJSON(["message" => lang("App.global_success"), "status" => $status]);
|
||||
}
|
||||
public function store()
|
||||
{
|
||||
// $this->servicioClienteModel->update($id,[$this->request->getPost()]);
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
public function datatable()
|
||||
{
|
||||
$query = $this->servicioClienteModel->getQueryDatatable()->orderBy("created_at", "DESC");
|
||||
return DataTable::of($query)
|
||||
->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "")
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
}
|
||||
@ -89,6 +89,8 @@ class Users extends \App\Controllers\GoBaseController
|
||||
|
||||
// Marcar el username como NULL
|
||||
$sanitizedData = $this->sanitized($postData, true);
|
||||
$email = $sanitizedData['email'];
|
||||
unset($sanitizedData['email']);
|
||||
|
||||
$noException = true;
|
||||
|
||||
@ -100,7 +102,7 @@ class Users extends \App\Controllers\GoBaseController
|
||||
try {
|
||||
|
||||
// The Email is unique
|
||||
if ($this->user_model->isEmailUnique($sanitizedData['email'])) {
|
||||
if ($this->user_model->isEmailUnique($email)) {
|
||||
|
||||
// Crear el usuario si pasa la validación
|
||||
$user = new \CodeIgniter\Shield\Entities\User([
|
||||
@ -109,8 +111,6 @@ class Users extends \App\Controllers\GoBaseController
|
||||
'last_name' => $sanitizedData['last_name'],
|
||||
'cliente_id' => $sanitizedData['cliente_id'],
|
||||
'comments' => $sanitizedData['comments'],
|
||||
'email' => $sanitizedData['email'],
|
||||
'password' => $sanitizedData['password'],
|
||||
'status' => $sanitizedData['status'] ?? 0,
|
||||
'active' => $sanitizedData['active'] ?? 0,
|
||||
]);
|
||||
|
||||
@ -33,13 +33,6 @@ class Js_loader extends BaseController
|
||||
|
||||
}
|
||||
|
||||
|
||||
function datosLibro_js()
|
||||
{
|
||||
$this->response->setHeader('Content-Type', 'text/javascript');
|
||||
return view('themes/vuexy/form/presupuestos/admin/_datosLibroItems.js');
|
||||
}
|
||||
|
||||
function previsualizador_js()
|
||||
{
|
||||
$this->response->setHeader('Content-Type', 'text/javascript');
|
||||
|
||||
@ -69,30 +69,61 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
|
||||
return;
|
||||
endif;
|
||||
|
||||
$postData = $this->request->getJSON();
|
||||
$tarifas = array_column($postData->datos, 'tarifa_id');
|
||||
$tirada = $postData->tirada ?? 0;
|
||||
$POD = $postData->POD ?? 0;
|
||||
$result = [];
|
||||
|
||||
if (count($tarifas) > 0) {
|
||||
foreach ($tarifas as $tarifa) {
|
||||
$values = $this->model->getPrecioTarifa($tarifa, $tirada, $POD);
|
||||
array_push($result, $values);
|
||||
}
|
||||
}
|
||||
$postData = $this->request->getPost();
|
||||
$datos_tarifas = $postData['datos'] ?? [];
|
||||
$tirada = $postData['tirada'] ?? 0;
|
||||
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
|
||||
$result = $this->getServiciosAcabados($datos_tarifas, $tirada, $POD);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'lines' => $result,
|
||||
'lineas' => $result,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
public function getServiciosAcabados($datos_tarifas, $tirada, $POD){
|
||||
|
||||
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
$result = [];
|
||||
if (count($datos_tarifas) > 0) {
|
||||
foreach ($datos_tarifas as $tarifa) {
|
||||
$proveedor = $tarifa['proveedor_id'] == '' ? -1 : $tarifa['proveedor_id'];
|
||||
|
||||
$values = $model->getPrecioTarifa($tarifa['tarifa_id'], $tirada, $proveedor, $POD);
|
||||
$values[0]->cubierta = $tarifa['cubierta'] ?? 0;
|
||||
$values[0]->sobrecubierta = $tarifa['sobrecubierta'] ?? 0;
|
||||
array_push($result, $values[0]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function cargar()
|
||||
{
|
||||
if($this->request->isAJAX()) {
|
||||
$presupuesto_id = $this->request->getGet('presupuesto_id') ?? null;
|
||||
|
||||
$rows = $this->model->getResource($presupuesto_id)->get()->getResultObject();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'rows' => $rows,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function getRowValues()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
@ -100,7 +131,7 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
|
||||
$tarifa_acabado_id = $reqData['tarifa_acabado_id'] ?? 0;
|
||||
$tirada = $reqData['tirada'] ?? 0;
|
||||
$proveedor_id = $reqData['proveedor_id'] ?? -1;
|
||||
$POD = $reqData['POD'] ?? 0;
|
||||
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
@ -195,4 +226,6 @@ class Presupuestoacabados extends \App\Controllers\BaseResourceController
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1586,7 +1586,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
if (!is_null($new_name)) {
|
||||
$path = WRITEPATH . 'uploads/presupuestos/' . $new_name;
|
||||
move_uploaded_file($tmp_name, $path);
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
|
||||
>>>>>>> main
|
||||
}
|
||||
}
|
||||
$ftp->uploadFilePresupuesto($presupuesto_id);
|
||||
@ -2384,7 +2388,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'id' => model('App\Models\Configuracion\ConfigVariableModel')->getVariable('id_servicio_plegado_exceso_solapas_faja')->value
|
||||
];
|
||||
|
||||
<<<<<<< HEAD
|
||||
// se comprueba si $datos guardas es un array
|
||||
=======
|
||||
// se comprueba si $datos guardas es un array
|
||||
>>>>>>> main
|
||||
if (is_array($datos_guardas)) {
|
||||
if (count($datos_guardas) > 0) {
|
||||
array_push($servicios, $servicio_plegado_guardas); // Plegado de guardas
|
||||
@ -2407,7 +2415,11 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
array_push($servicios, $servicio_solapas_cubierta);
|
||||
if (!is_null($sobreCubierta) && $sobreCubierta) // Si hay sobrecubierta, siempre con solapas
|
||||
array_push($servicios, $servicio_solapas_sobrecubierta);
|
||||
<<<<<<< HEAD
|
||||
/* TO-DO
|
||||
=======
|
||||
/* TO-DO
|
||||
>>>>>>> main
|
||||
if (!is_null($faja) && $faja) // Si hay faja, siempre con solapas
|
||||
array_push($servicios, $servicio_solapas_faja);
|
||||
*/
|
||||
|
||||
@ -44,7 +44,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
|
||||
$att = $reqData['att'] ?? "";
|
||||
$email = $reqData['email'] ?? "";
|
||||
$direccion = $reqData['direccion'] ?? "";
|
||||
$pais_id = $reqData['paisId'] ?? -1;
|
||||
$pais_id = $reqData['pais_id'] ?? -1;
|
||||
$provincia = $reqData['provincia'] ?? "";
|
||||
$municipio = $reqData['municipio'] ?? "";
|
||||
$cp = $reqData['cp'] ?? "";
|
||||
@ -145,6 +145,7 @@ class Presupuestodirecciones extends \App\Controllers\BaseResourceController
|
||||
$reqData = $this->request->getJSON();
|
||||
|
||||
if($reqData->tipo=='get_tarifa'){
|
||||
|
||||
$peso = $reqData->peso ?? 0;
|
||||
$paisId = $reqData->paisId ?? 0;
|
||||
$cp = $reqData->cp ?? 0;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php namespace App\Controllers\Presupuestos;
|
||||
<?php
|
||||
namespace App\Controllers\Presupuestos;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
@ -9,7 +10,7 @@ use App\Models\Presupuestos\PresupuestoEncuadernacionesModel;
|
||||
use DataTables\Editor;
|
||||
use DataTables\Editor\Field;
|
||||
use DataTables\Editor\Validate;
|
||||
|
||||
|
||||
class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
|
||||
@ -25,7 +26,7 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/presupuestos/';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
@ -35,20 +36,19 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
if ($requestedId == null):
|
||||
return;
|
||||
endif;
|
||||
|
||||
$postData = $this->request->getJSON();
|
||||
$tarifas = array_column($postData->datos, 'tarifa_id');
|
||||
if(count($tarifas)>0){
|
||||
if (count($tarifas) > 0) {
|
||||
$this->model->deleteServiciosNotInArray($requestedId, $tarifas);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$this->model->deleteAllServicios($requestedId);
|
||||
}
|
||||
|
||||
if(count($tarifas)>0){
|
||||
if (count($tarifas) > 0) {
|
||||
$this->model->updateTarifas($requestedId, $postData->datos);
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
||||
$data = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
@ -65,136 +65,177 @@ class Presupuestoencuadernaciones extends \App\Controllers\BaseResourceControlle
|
||||
{
|
||||
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
|
||||
if ($requestedId == null) :
|
||||
if ($requestedId == null):
|
||||
return;
|
||||
endif;
|
||||
|
||||
$postData = $this->request->getJSON();
|
||||
$tarifas = array_column($postData->datos, 'tarifa_id');
|
||||
$tirada = $postData->tirada ?? 0;
|
||||
$paginas = $postData->paginas ?? 0;
|
||||
$POD = $postData->POD ?? 0;
|
||||
$ancho = $postData->ancho ?? 0;
|
||||
$alto = $postData->alto ?? 0;
|
||||
$result = [];
|
||||
|
||||
if(count($tarifas)>0){
|
||||
foreach ($tarifas as $tarifa){
|
||||
if($tarifaModel->isTarifaPorHoras($tarifa)){
|
||||
$values = $this->model->getPrecioTarifaHoras($tarifa, $paginas, $tirada, -1, $POD);
|
||||
}else{
|
||||
$values = $this->model->getPrecioTarifa($tarifa, $paginas, $tirada, $ancho, $alto, -1, $POD);
|
||||
}
|
||||
array_push($result, $values);
|
||||
}
|
||||
}
|
||||
$postData = $this->request->getPost();
|
||||
$datos_tarifas = $postData['datos'] ?? [];
|
||||
$tirada = $postData['tirada'] ?? 0;
|
||||
$paginas = $postData['paginas'] ?? 0;
|
||||
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
$ancho = $postData['ancho'] ?? 0;
|
||||
$alto = $postData['alto'] ?? 0;
|
||||
|
||||
$result = $this->getServiciosEncuadernacion($datos_tarifas, $tirada, $paginas, $ancho, $alto, $POD);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'lines' => $result,
|
||||
'lineas' => $result,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
public function getServiciosEncuadernacion($datos_tarifas, $tirada, $paginas, $ancho, $alto, $POD)
|
||||
{
|
||||
$result = [];
|
||||
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
$model = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
|
||||
|
||||
|
||||
if (count($datos_tarifas) > 0) {
|
||||
foreach ($datos_tarifas as $tarifa) {
|
||||
if ($tarifaModel->isTarifaPorHoras($tarifa['tarifa_id'])) {
|
||||
$values = $model->getPrecioTarifaHoras($tarifa['tarifa_id'], $paginas, $tirada, -1, $POD);
|
||||
} else {
|
||||
$values = $model->getPrecioTarifa($tarifa['tarifa_id'], $paginas, $tirada, $ancho, $alto, -1, $POD);
|
||||
}
|
||||
array_push($result, $values[0]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
$tipo = $reqData['tipo'] ?? null;
|
||||
if(is_null($tipo) || $tipo=='tarifa'){
|
||||
if (is_null($tipo) || $tipo == 'tarifa') {
|
||||
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? 0;
|
||||
$proveedor_id = $reqData['proveedor_id'] ?? 0;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$solapas = $reqData['solapas'] ?? 0;
|
||||
}
|
||||
$paginas = $reqData['paginas'] ?? 0;
|
||||
$tirada = $reqData['tirada'] ?? 0;
|
||||
$ancho = $reqData['ancho'] ?? 0;
|
||||
$alto = $reqData['alto'] ?? 0;
|
||||
|
||||
|
||||
$POD = $reqData['POD'] ?? 0;
|
||||
$paginas_cuadernillo = $reqData['paginas_por_cuadernillo'] ?? null;
|
||||
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
|
||||
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
if(is_null($tipo)){
|
||||
if($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)){
|
||||
if (is_null($tipo)) {
|
||||
if ($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)) {
|
||||
$values = $this->model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo);
|
||||
}else{
|
||||
} else {
|
||||
$values = $this->model->getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD);
|
||||
}
|
||||
}
|
||||
|
||||
else if($tipo=='tarifa'){
|
||||
if($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)){
|
||||
} else if ($tipo == 'tarifa') {
|
||||
if ($tarifaModel->isTarifaPorHoras($tarifa_encuadernacion_id)) {
|
||||
$values = $this->model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, -1, $POD);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$values = $this->model->getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, -1, $POD);
|
||||
}
|
||||
}
|
||||
|
||||
else{
|
||||
} else {
|
||||
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
|
||||
$values = $this->model->initPresupuesto($tipo_impresion_id, $solapas, $tirada, $paginas, $ancho, $alto, $POD);
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'values' => $values,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
|
||||
return $this->respond($data);
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getRowValues()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$tarifaModel = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
$tarifa_enc_id = $reqData['tarifa_enc_id'] ?? 0;
|
||||
$tirada = $reqData['tirada'] ?? 0;
|
||||
$paginas = $reqData['paginas'] ?? 0;
|
||||
$ancho = $reqData['ancho'] ?? 0;
|
||||
$alto = $reqData['alto'] ?? 0;
|
||||
$proveedor_id = $reqData['proveedor_id'] ?? -1;
|
||||
$paginas_cuadernillo = $reqData['paginas_por_cuadernillo'] ?? 32;
|
||||
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
if ($tarifaModel->isTarifaPorHoras($tarifa_enc_id)) {
|
||||
$values = $this->model->getPrecioTarifaHoras($tarifa_enc_id, $paginas, $tirada, $proveedor_id, $POD, $paginas_cuadernillo);
|
||||
} else {
|
||||
$values = $this->model->getPrecioTarifa($tarifa_enc_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'values' => $values,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function menuItems()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
try{
|
||||
try {
|
||||
|
||||
$tarifa_id = $reqData['tarifa_id'] ?? -1;
|
||||
$paginas = $reqData['paginas'] ?? 0;
|
||||
$tirada = $reqData['tirada'] ?? 0;
|
||||
$ancho = $reqData['ancho'] ?? 0;
|
||||
$alto = $reqData['alto'] ?? 0;
|
||||
//$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
$paginas_cuadernillo = $reqData['paginas_por_cuadernillo'] ?? 32;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$menu = $this->model->getProveedoresForSelector($tarifa_id, $paginas, $tirada, $ancho, $alto);
|
||||
$menu = $this->model->getProveedoresForSelector($tarifa_id, $paginas, $tirada, $ancho, $alto, $paginas_cuadernillo);
|
||||
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
}
|
||||
catch(Exception $e){
|
||||
} catch (Exception $e) {
|
||||
$data = [
|
||||
'error' => $e,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
}
|
||||
finally{
|
||||
} finally {
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
|
||||
@ -63,6 +63,27 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
public function getServicioSolapas(){
|
||||
|
||||
if($this->request->isAJAX()){
|
||||
|
||||
$servicio = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('servicio_solapas')->value;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$data = [
|
||||
'service' => $servicio,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
}
|
||||
else{
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($requestedId = null)
|
||||
{
|
||||
|
||||
@ -70,28 +91,38 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
|
||||
return;
|
||||
endif;
|
||||
|
||||
$postData = $this->request->getJSON();
|
||||
$tarifas = array_column($postData->datos, 'tarifa_id');
|
||||
$tirada = $postData->tirada ?? 0;
|
||||
$POD = $postData->POD ?? 0;
|
||||
$result = [];
|
||||
|
||||
if(count($tarifas)>0){
|
||||
foreach ($tarifas as $tarifa){
|
||||
$values = $this->model->getPrecioTarifa($tarifa, $tirada, $POD);
|
||||
array_push($result, $values);
|
||||
}
|
||||
}
|
||||
$postData = $this->request->getPost();
|
||||
$tarifas = $postData['datos'] ?? [];
|
||||
$tirada = $postData['tirada'] ?? 0;
|
||||
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
|
||||
$result = $this->getServiciosManipulado($tarifas, $tirada, $POD);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'lines' => $result,
|
||||
'lineas' => $result,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
public function getServiciosManipulado($datos_tarifas, $tirada, $POD)
|
||||
{
|
||||
$result = [];
|
||||
$model = model('App\Models\Presupuestos\PresupuestoManipuladosModel');
|
||||
|
||||
if (count($datos_tarifas) > 0) {
|
||||
foreach ($datos_tarifas as $tarifa) {
|
||||
$values = $model->getPrecioTarifa($tarifa, $tirada, $POD);
|
||||
$values[0]->cubierta = $tarifa['cubierta'] ?? 0;
|
||||
$values[0]->sobrecubierta = $tarifa['sobrecubierta'] ?? 0;
|
||||
array_push($result, $values[0]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function datatable()
|
||||
@ -101,7 +132,7 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
|
||||
|
||||
$tarifa_manipulado_id = $reqData['tarifa_manipulado_id'] ?? 0;
|
||||
$tirada = $reqData['tirada'] ?? 0;
|
||||
$POD = $reqData['POD'] ?? 0;
|
||||
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
$tipo = $reqData['tipo'] ?? null;
|
||||
|
||||
|
||||
@ -129,4 +160,29 @@ class Presupuestomanipulados extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function getRowValues()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
$tarifa_manipulado_id = $reqData['tarifa_manipulado_id'] ?? 0;
|
||||
$tirada = $reqData['tirada'] ?? 0;
|
||||
$POD = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$values = $this->model->getPrecioTarifa($tarifa_manipulado_id, $tirada, $POD);
|
||||
|
||||
$data = [
|
||||
'values' => $values,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,4 +110,47 @@ class Presupuestopreimpresiones extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function getRowValues()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
$tarifa_preimpresion_id = $reqData['tarifa_preimpresion_id'] ?? 0;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$values = $this->model->getPrecioTarifa($tarifa_preimpresion_id);
|
||||
|
||||
$data = [
|
||||
'values' => $values,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function cargar()
|
||||
{
|
||||
if($this->request->isAJAX()) {
|
||||
$presupuesto_id = $this->request->getGet('presupuesto_id') ?? null;
|
||||
|
||||
$rows = $this->model->getResource($presupuesto_id)->get()->getResultObject();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'rows' => $rows,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,4 +110,28 @@ class Presupuestoserviciosextra extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function getRowValues()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
$tarifa_extra_id = $reqData['tarifa_extra_id'] ?? 0;
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$values = $this->model->getPrecioTarifa($tarifa_extra_id);
|
||||
|
||||
$data = [
|
||||
'values' => $values,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -82,7 +82,12 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$id = $reqData['id'] ?? 0;
|
||||
|
||||
$json_data = $reqData['json_tiradas'] ?? null;
|
||||
$json_data_acabados = $reqData['json_acabados'] ?? null;
|
||||
$json_data_encuadernacion = $reqData['json_encuadernaciones'] ?? null;
|
||||
$json_data_manipulado = $reqData['json_manipulado'] ?? null;
|
||||
$cliente_id = $reqData['cliente_id'] ?? 0;
|
||||
|
||||
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
|
||||
@ -95,7 +100,7 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
|
||||
foreach ($data as $linea) {
|
||||
// Se obtienen los valores de cada linea para el calculo del precio
|
||||
$datosPedido = (object)array(
|
||||
$datosPedido = (object) array(
|
||||
'paginas' => intval($linea['paginas']) ?? 0,
|
||||
'tirada' => intval($reqData['tirada']) ?? 0,
|
||||
'merma' => intval($reqData['merma']) ?? 0,
|
||||
@ -144,24 +149,24 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$uso = 'interior';
|
||||
$tipo = strpos($linea['row_id'], "_bn") !== false ? 'negro' : 'color';
|
||||
$paginas_negro = isset($linea['numPagColor']) ? intval($datosPedido->paginas) - intval($linea['numPagColor']) : 0;
|
||||
$paginas_color = $linea['numPagColor'] ?? 0;
|
||||
$paginas = (object)array(
|
||||
$paginas_color = $linea['numPagColor'] ?? 0;
|
||||
$paginas = (object) array(
|
||||
'negro' => $paginas_negro,
|
||||
'color' => $paginas_color,
|
||||
);
|
||||
$parametrosRotativa = (object)array(
|
||||
$parametrosRotativa = (object) array(
|
||||
'a_favor_fibra' => $datosPedido->a_favor_fibra,
|
||||
'bnPages' => $paginas->negro,
|
||||
'colorPages' => $paginas->color,
|
||||
'bnPages' => $paginas->negro,
|
||||
'colorPages' => $paginas->color,
|
||||
'rotativa_gota_negro' => 0,
|
||||
'rotativa_gota_color' => 0,
|
||||
);
|
||||
$parametrosRotativa->rotativa_gota_negro = floatval($linea['gotaNegro']?? 0);
|
||||
$parametrosRotativa->rotativa_gota_color = floatval($linea['gotaColor']?? 0);
|
||||
$parametrosRotativa->rotativa_negro = floatval($linea['cobNegro'] ?? 0);
|
||||
$parametrosRotativa->rotativa_cyan = floatval($linea['cobCyan'] ?? 0);
|
||||
$parametrosRotativa->rotativa_magenta = floatval($linea['cobMagenta']?? 0);
|
||||
$parametrosRotativa->rotativa_amarillo = floatval($linea['cobAmarillo']?? 0);
|
||||
$parametrosRotativa->rotativa_gota_negro = floatval($linea['gotaNegro'] ?? 0);
|
||||
$parametrosRotativa->rotativa_gota_color = floatval($linea['gotaColor'] ?? 0);
|
||||
$parametrosRotativa->rotativa_negro = floatval($linea['cobNegro'] ?? 0);
|
||||
$parametrosRotativa->rotativa_cyan = floatval($linea['cobCyan'] ?? 0);
|
||||
$parametrosRotativa->rotativa_magenta = floatval($linea['cobMagenta'] ?? 0);
|
||||
$parametrosRotativa->rotativa_amarillo = floatval($linea['cobAmarillo'] ?? 0);
|
||||
break;
|
||||
case 'lp_cubierta':
|
||||
$uso = 'cubierta';
|
||||
@ -194,14 +199,14 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$datosTipolog = $linea['gotaNegro'] ?? null;
|
||||
if (!is_null($datosTipolog)) {
|
||||
$datosTipolog = [];
|
||||
$data_temp = (object)array(
|
||||
$data_temp = (object) array(
|
||||
'negro' => floatval($linea['cobNegro'] ?? 0),
|
||||
'cyan' => floatval($linea['cobCyan'] ?? 0),
|
||||
'magenta' => floatval($linea['cobMagenta']?? 0),
|
||||
'amarillo' => floatval($linea['cobAmarillo']?? 0),
|
||||
'magenta' => floatval($linea['cobMagenta'] ?? 0),
|
||||
'amarillo' => floatval($linea['cobAmarillo'] ?? 0),
|
||||
'cg' => floatval($linea['cobCG'] ?? 0),
|
||||
'gota_negro' => floatval($linea['gotaNegro']?? 0),
|
||||
'gota_color' => floatval($linea['gotaColor']?? 0),
|
||||
'gota_negro' => floatval($linea['gotaNegro'] ?? 0),
|
||||
'gota_color' => floatval($linea['gotaColor'] ?? 0),
|
||||
);
|
||||
array_push($datosTipolog, $data_temp);
|
||||
}
|
||||
@ -213,13 +218,13 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$datosLinea['datosPedido'] = $datosPedido;
|
||||
$datosLinea['cliente_id'] = $cliente_id;
|
||||
$datosLinea['papel'] = $papel;
|
||||
if(isset($isColor))
|
||||
$datosLinea['isColor'] = $isColor;
|
||||
if(isset($opciones_papel))
|
||||
if (isset($isColor))
|
||||
$datosLinea['isColor'] = $isColor;
|
||||
if (isset($opciones_papel))
|
||||
$datosLinea['opciones_papel'] = $opciones_papel;
|
||||
if(isset($parametrosRotativa))
|
||||
if (isset($parametrosRotativa))
|
||||
$datosLinea['parametrosRotativa'] = $parametrosRotativa;
|
||||
if(isset($paginas))
|
||||
if (isset($paginas))
|
||||
$datosLinea['paginas'] = $paginas;
|
||||
$datosLinea['maquina'] = $maquina;
|
||||
$datosLinea['papel_generico'] = $papel_generico;
|
||||
@ -257,19 +262,113 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
$linea_coste['total_coste'] +=
|
||||
$linea_coste['fields']['precio_tinta'];
|
||||
if (strpos($linea['row_id'], 'lp_rot') === 0) {
|
||||
$linea_coste['total_coste'] +=
|
||||
$linea_coste['fields']['total_corte'];
|
||||
}
|
||||
$linea_coste['total_coste'] +=
|
||||
$linea_coste['fields']['total_corte'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$linea_coste['total_margen'] = $linea_coste['fields']['margen_papel_pedido'] +
|
||||
$linea_coste['fields']['margen_impresion_horas'] +
|
||||
$linea_coste['fields']['margen_click_pedido'];
|
||||
|
||||
|
||||
unset($linea_coste['fields']);
|
||||
array_push($values, $linea_coste);
|
||||
}
|
||||
|
||||
// Calculo de los servicios (presimpresion y extra no dependen de nada)
|
||||
$servicios = (object) (['coste' => 0.0, 'margen' => 0.0]);
|
||||
|
||||
if ($json_data_acabados) {
|
||||
$json_data_acabados = json_decode($json_data_acabados, true);
|
||||
if (count($json_data_acabados) > 0) {
|
||||
|
||||
$acabados = new Presupuestoacabados();
|
||||
$POD = (new \App\Models\Configuracion\ConfigVariableModel())->getVariable('POD')->value;
|
||||
$result = $acabados->getServiciosAcabados($json_data_acabados, $reqData['tirada'], $POD);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $servicio) {
|
||||
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
|
||||
$margen = round($servicio->total - $coste, 2);
|
||||
$servicios->coste += $coste;
|
||||
$servicios->margen += $margen;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($json_data_encuadernacion) {
|
||||
$json_data_encuadernacion = json_decode($json_data_encuadernacion, true);
|
||||
if (count($json_data_encuadernacion) > 0) {
|
||||
|
||||
$encuadernacion = new Presupuestoencuadernaciones();
|
||||
$POD = (new \App\Models\Configuracion\ConfigVariableModel())->getVariable('POD')->value;
|
||||
$result = $encuadernacion->getServiciosEncuadernacion($json_data_encuadernacion, $reqData['tirada'], $reqData['paginas'], $reqData['ancho'], $reqData['alto'], $POD);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $servicio) {
|
||||
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
|
||||
$margen = round($servicio->total - $coste, 2);
|
||||
$servicios->coste += $coste;
|
||||
$servicios->margen += $margen;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($json_data_manipulado) {
|
||||
$json_data_manipulado = json_decode($json_data_manipulado, true);
|
||||
if (count($json_data_manipulado) > 0) {
|
||||
$manipulados = new Presupuestomanipulados();
|
||||
$POD = (new \App\Models\Configuracion\ConfigVariableModel())->getVariable('POD')->value;
|
||||
$result = $manipulados->getServiciosManipulado($json_data_manipulado, $reqData['tirada'], $POD);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $servicio) {
|
||||
$coste = round($servicio->total / (1 + $servicio->margen / 100), 2);
|
||||
$margen = round($servicio->total - $coste, 2);
|
||||
$servicios->coste += $coste;
|
||||
$servicios->margen += $margen;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$json_envios = $reqData['json_envios'] ?? null;
|
||||
$coste_envio = 0.0;
|
||||
$margen_envio = 0.0;
|
||||
$tirada_base = floatval($reqData['tirada_base']);
|
||||
$peso_libro = floatval($reqData['peso_libro']);
|
||||
// el primer envio con la tirada base
|
||||
$model = model('App\Models\Tarifas\TarifaEnvioModel');
|
||||
$envios = $model->getTarifaEnvio(1, 18000, $tirada_base * $peso_libro/1000.0, "cajas");
|
||||
$resultado = $this->calcular_envio($envios, $tirada_base * $peso_libro/1000.0);
|
||||
$coste_envio += $resultado->coste;
|
||||
$margen_envio += $resultado->margen;
|
||||
|
||||
if ($json_envios) {
|
||||
$json_envios = json_decode($json_envios, true);
|
||||
if (count($json_envios) > 0) {
|
||||
//la primera linea es el envio base
|
||||
for($i = 1; $i < count($json_envios); $i++) {
|
||||
|
||||
$porcentaje = ($json_envios[$i]['cantidad']) / $tirada_base * 100.0;
|
||||
$cantidad = floor($reqData['tirada'] * $porcentaje / 100.0);
|
||||
$peso_envio = $cantidad * $peso_libro / 1000.0;
|
||||
|
||||
$paisId = $json_envios[$i]['pais_id'];
|
||||
$cp = $json_envios[$i]['cp'];
|
||||
$tipo_envio = $json_envios[$i]['entregaPieCalle'] == 1 ? 'palets' : 'cajas';
|
||||
|
||||
$model = model('App\Models\Tarifas\TarifaEnvioModel');
|
||||
$envios = $model->getTarifaEnvio($paisId, $cp, $peso_envio, $tipo_envio);
|
||||
|
||||
$resultado = $this->calcular_envio($envios, $peso_envio);
|
||||
$coste_envio += $resultado->coste;
|
||||
$margen_envio += $resultado->margen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$values = [];
|
||||
}
|
||||
@ -279,8 +378,36 @@ class Presupuestotiradasalternativas extends \App\Controllers\BaseResourceContro
|
||||
|
||||
$response[$csrfTokenName] = $newTokenHash;
|
||||
$response['lineas'] = $values;
|
||||
$response['servicios'] = $servicios;
|
||||
$response['envios'] = (object) (['coste' => $coste_envio, 'margen' => $margen_envio]);
|
||||
|
||||
return $this->respond($response);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function calcular_envio($envio, $peso_envio)
|
||||
{
|
||||
$coste_envio = 0.0;
|
||||
$margen_envio = 0.0;
|
||||
if (count(value: $envio) > 0) {
|
||||
$envio = $envio[0];
|
||||
if ($envio->id != null) {
|
||||
|
||||
if ($peso_envio > $envio->peso_max || floatval($envio->precio_max) == 0) {
|
||||
$coste_envio += number_format(floatval($envio->precio_min) + ($peso_envio - floatval($envio->peso_min)) * floatval($envio->precio_adicional), 2);
|
||||
}
|
||||
// si no se calcula linealmente
|
||||
else {
|
||||
$m = (($envio->precio_max - $envio->precio_min) / ($envio->peso_max - $envio->peso_min));
|
||||
$b = $envio->precio_max - $m * $envio->peso_max;
|
||||
$coste_envio = number_format($m * $peso_envio + $b, 2);
|
||||
|
||||
}
|
||||
|
||||
$margen_envio += $coste_envio * $envio->margen / 100.0;
|
||||
}
|
||||
}
|
||||
|
||||
return (object) (['coste' => $coste_envio, 'margen' => $margen_envio]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,4 +336,25 @@ class TarifaAcabados extends BaseResourceController
|
||||
}
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
}
|
||||
|
||||
public function getSelect2()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$query = $this->model->builder()->select(
|
||||
[
|
||||
"id",
|
||||
"nombre as name"
|
||||
]
|
||||
)->where("deleted_at", null);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("lg_tarifas_acabado.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,4 +239,25 @@ class Tarifaextra extends \App\Controllers\GoBaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function getSelect2()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$query = $this->model->builder()->select(
|
||||
[
|
||||
"id",
|
||||
"nombre as name"
|
||||
]
|
||||
)->where("deleted_at", null)
|
||||
->where("mostrar_en_presupuesto", 1);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("tarifa_extra.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,4 +242,25 @@ class Tarifapreimpresion extends \App\Controllers\GoBaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function getSelect2()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$query = $this->model->builder()->select(
|
||||
[
|
||||
"id",
|
||||
"nombre as name"
|
||||
]
|
||||
)->where("deleted_at", null)
|
||||
->where("mostrar_en_presupuesto", 1);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("lg_tarifa_preimpresion.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,4 +356,26 @@ class Tarifasencuadernacion extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
return $dimensiones;
|
||||
}
|
||||
|
||||
public function getSelect2()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$query = $this->model->builder()->select(
|
||||
[
|
||||
"id",
|
||||
"nombre as name"
|
||||
]
|
||||
)->where("deleted_at", null)
|
||||
->where("mostrar_en_presupuesto", 1);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("tarifa_encuadernacion.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,4 +310,26 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
}
|
||||
|
||||
public function getSelect2()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$query = $this->model->builder()->select(
|
||||
[
|
||||
"id",
|
||||
"nombre as name"
|
||||
]
|
||||
)->where("deleted_at", null)
|
||||
->where("mostrar_en_presupuesto", 1);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("lg_tarifa_manipulado.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user