mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
copiada la rama presu_cliente_v2 en esta para poder hacer el merge al main
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Controllers\Clientes;
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Clientes;
|
||||
|
||||
|
||||
|
||||
@ -152,7 +154,7 @@ class Cliente extends \App\Controllers\BaseResourceController
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
@ -310,10 +312,9 @@ class Cliente extends \App\Controllers\BaseResourceController
|
||||
$onlyActiveOnes = false;
|
||||
$columns2select = [$reqId ?? 'id', $reqText ?? 'nombre'];
|
||||
$onlyActiveOnes = false;
|
||||
try{
|
||||
try {
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
}
|
||||
catch(Exception $e){
|
||||
} catch (Exception $e) {
|
||||
$menu = [];
|
||||
}
|
||||
|
||||
@ -330,6 +331,28 @@ class Cliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
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("clientes.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getPaisListItems($selId = null)
|
||||
{
|
||||
$paisModel = model('App\Models\Configuracion\PaisModel');
|
||||
@ -423,24 +446,23 @@ class Cliente extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
protected function getPrecioTemplate($cliente_id){
|
||||
protected function getPrecioTemplate($cliente_id)
|
||||
{
|
||||
|
||||
$modelPreciosCliente = model('App\Models\Clientes\ClientePreciosModel');
|
||||
$plantilla_id = $modelPreciosCliente->get_plantilla_precios($cliente_id);
|
||||
if (is_null($plantilla_id)){
|
||||
if (is_null($plantilla_id)) {
|
||||
return null;
|
||||
}
|
||||
$modelPlantillaPreciosCliente = model('App\Models\Clientes\ClientePlantillaPreciosModel');
|
||||
$plantilla = $modelPlantillaPreciosCliente->where("id", $plantilla_id)->where("is_deleted", 0)->first();
|
||||
if ($plantilla == false){
|
||||
if ($plantilla == false) {
|
||||
return null;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return (object)array(
|
||||
"value" => $plantilla_id,
|
||||
"label" => $plantilla->nombre
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Controllers\Clientes;
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Clientes;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
@ -38,7 +40,7 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
|
||||
// Breadcrumbs (IMN)
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("Clientes.direccionesEnvio"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
|
||||
|
||||
];
|
||||
|
||||
$this->viewData['comunidadAutonomaList'] = $this->getComunidadAutonomaListItems($clienteEntity->comunidad_autonoma_id ?? null);
|
||||
@ -71,21 +73,22 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
|
||||
return view(static::$viewPath . 'viewClienteDireccionesList', $viewData);
|
||||
}
|
||||
|
||||
public function add(){
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
$cliente_id = $reqData['cliente_id'] ?? -1;
|
||||
$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'] ?? "";
|
||||
$telefono = $reqData['telefono'] ?? "";
|
||||
$alias = $reqData['alias'] ?? "";
|
||||
|
||||
|
||||
$data = [
|
||||
"cliente_id" => $cliente_id,
|
||||
"att" => $att,
|
||||
@ -99,15 +102,11 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
|
||||
"alias" => $alias,
|
||||
];
|
||||
$response = $this->model->insert($data);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$data_ret = [
|
||||
'data' => $response,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data_ret);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
@ -117,14 +116,14 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
|
||||
public function menuItems()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
$cliente_id = $reqData['cliente_id'] ?? -1;
|
||||
|
||||
|
||||
$clienteDireccionesModel = model('App\Models\Clientes\ClienteDireccionesModel');
|
||||
$menu = $clienteDireccionesModel->getMenuDirecciones($cliente_id);
|
||||
//$menu = $this->model->getMenuItems($cliente_id);
|
||||
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
@ -138,6 +137,34 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
public function getSelect2()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$cliente_id = $this->request->getGet('cliente_id');
|
||||
|
||||
|
||||
$query = $this->model->builder()->select(
|
||||
[
|
||||
"id",
|
||||
"alias as name"
|
||||
]
|
||||
)
|
||||
->where("cliente_id", $cliente_id)
|
||||
->orderBy("alias", "asc");
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("clientes.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
@ -145,7 +172,7 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
|
||||
|
||||
$tipo = $reqData['tipo'] ?? null;
|
||||
|
||||
if(is_null($tipo)){
|
||||
if (is_null($tipo)) {
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
|
||||
@ -160,22 +187,21 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
|
||||
|
||||
$id_C = $reqData['cliente_id'] ?? -1;
|
||||
|
||||
|
||||
|
||||
$resourceData = $this->model->getResource($search, $id_C)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource("", $id_C)->countAllResults()
|
||||
));
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
|
||||
$id = $reqData['id'] ?? -1;
|
||||
|
||||
$resourceData = $this->model->getDireccion($id);
|
||||
|
||||
|
||||
|
||||
return $this->respond($resourceData);
|
||||
}
|
||||
@ -184,6 +210,44 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function get($id)
|
||||
{
|
||||
try {
|
||||
$resourceData = $this->model->getDireccion($id);
|
||||
$response = (object)[
|
||||
'error' => false,
|
||||
'data' => $resourceData
|
||||
];
|
||||
return $this->respond($response);
|
||||
} catch (\Exception $e) {
|
||||
$response = (object)[
|
||||
'error' => true,
|
||||
'message' => $e->getMessage()
|
||||
];
|
||||
return $this->fail($response);
|
||||
}
|
||||
}
|
||||
|
||||
public function getDireccionPresupuesto($id)
|
||||
{
|
||||
try {
|
||||
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
$resourceData = $model->getDireccion($id);
|
||||
$response = (object)[
|
||||
'error' => false,
|
||||
'data' => $resourceData
|
||||
];
|
||||
return $this->respond($response);
|
||||
} catch (\Exception $e) {
|
||||
$response = (object)[
|
||||
'error' => true,
|
||||
'message' => $e->getMessage()
|
||||
];
|
||||
return $this->fail($response);
|
||||
}
|
||||
}
|
||||
|
||||
public function datatable_editor()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
@ -194,72 +258,116 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
|
||||
$response = Editor::inst($db, 'cliente_direcciones')
|
||||
->fields(
|
||||
Field::inst('att')
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('ClienteDirecciones.validation.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.required')
|
||||
)
|
||||
)
|
||||
->validator( Validate::maxLen( 100 ) , array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length'))
|
||||
),
|
||||
->validator(
|
||||
Validate::maxLen(100),
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length')
|
||||
)
|
||||
),
|
||||
Field::inst('alias')
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('ClienteDirecciones.validation.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.required')
|
||||
)
|
||||
)
|
||||
->validator( Validate::maxLen( 100 ) , array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length'))
|
||||
),
|
||||
->validator(
|
||||
Validate::maxLen(100),
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length')
|
||||
)
|
||||
),
|
||||
Field::inst('email')
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('ClienteDirecciones.validation.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.required')
|
||||
)
|
||||
)
|
||||
->validator( Validate::maxLen( 100 ) , array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length'))
|
||||
),
|
||||
->validator(
|
||||
Validate::maxLen(100),
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length')
|
||||
)
|
||||
),
|
||||
Field::inst('direccion')
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('ClienteDirecciones.validation.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.required')
|
||||
)
|
||||
)
|
||||
->validator( Validate::maxLen( 255 ) , array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length'))
|
||||
),
|
||||
->validator(
|
||||
Validate::maxLen(255),
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length')
|
||||
)
|
||||
),
|
||||
Field::inst('municipio')
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('ClienteDirecciones.validation.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.required')
|
||||
)
|
||||
)
|
||||
->validator( Validate::maxLen( 100 ) , array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length'))
|
||||
),
|
||||
->validator(
|
||||
Validate::maxLen(100),
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length')
|
||||
)
|
||||
),
|
||||
Field::inst('cp')
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('ClienteDirecciones.validation.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.required')
|
||||
)
|
||||
)
|
||||
->validator( Validate::maxLen( 20 ) , array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length'))
|
||||
),
|
||||
->validator(
|
||||
Validate::maxLen(20),
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length')
|
||||
)
|
||||
),
|
||||
Field::inst('telefono')
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('ClienteDirecciones.validation.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.required')
|
||||
)
|
||||
)
|
||||
->validator( Validate::maxLen( 40 ) , array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length'))
|
||||
),
|
||||
->validator(
|
||||
Validate::maxLen(40),
|
||||
array(
|
||||
'message' => lang('ClienteDirecciones.validation.max_length')
|
||||
)
|
||||
),
|
||||
Field::inst('provincia')
|
||||
->validator( function ( $val, $data, $field, $host ) {
|
||||
if ($data['pais_id'] == 1) { // Si es españa provincia y CCAA es obligatorio
|
||||
if (strlen( $val ) > 100)
|
||||
return lang('ClienteDirecciones.validation.max_length');
|
||||
else if (strlen( $val ) == 0)
|
||||
lang('ClienteDirecciones.validation.required');
|
||||
else
|
||||
return true;
|
||||
->validator(
|
||||
function ($val, $data, $field, $host) {
|
||||
if ($data['pais_id'] == 1) { // Si es españa provincia y CCAA es obligatorio
|
||||
if (strlen($val) > 100)
|
||||
return lang('ClienteDirecciones.validation.max_length');
|
||||
else if (strlen($val) == 0)
|
||||
lang('ClienteDirecciones.validation.required');
|
||||
else
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
),
|
||||
),
|
||||
Field::inst('pais_id')->validator('Validate::notEmpty', array(
|
||||
'message' => lang('ClienteDirecciones.validation.required'))),
|
||||
'message' => lang('ClienteDirecciones.validation.required')
|
||||
)),
|
||||
Field::inst('cliente_id'),
|
||||
)
|
||||
|
||||
|
||||
->debug(true)
|
||||
->process($_POST)
|
||||
->data();
|
||||
@ -270,7 +378,6 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
|
||||
$response[$csrfTokenName] = $newTokenHash;
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
|
||||
@ -33,7 +33,6 @@ class ConfigVariables extends BaseResourceController
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->configVariableModel = model(ConfigVariableModel::class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -48,45 +47,46 @@ class ConfigVariables extends BaseResourceController
|
||||
|
||||
return view(static::$viewPath . $this->indexRoute, $viewData);
|
||||
}
|
||||
public function store(){
|
||||
public function store()
|
||||
{
|
||||
$data = [];
|
||||
$variableCreated = $this->configVariableModel->store($data);
|
||||
return $this->response->setJSON($variableCreated);
|
||||
}
|
||||
public function get(int $config_variable_id){
|
||||
public function get(int $config_variable_id)
|
||||
{
|
||||
$data = $this->configVariableModel->find($config_variable_id);
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
public function updateVariable(int $config_variable_id){
|
||||
public function updateVariable(int $config_variable_id)
|
||||
{
|
||||
$reqData = [];
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
$status = $this->configVariableModel->update($config_variable_id,$reqData);
|
||||
$status = $this->configVariableModel->update($config_variable_id, $reqData);
|
||||
return $this->response->setJSON([
|
||||
"message" => "Variable actualizada correctamente",
|
||||
"status" => $status
|
||||
]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
public function deleteVariable(int $config_variable_id): Response
|
||||
{
|
||||
return $this->response->setJSON([]);
|
||||
|
||||
}
|
||||
public function datatable(){
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$query = $this->configVariableModel->builder()->select([
|
||||
"id",
|
||||
"name",
|
||||
"value",
|
||||
"description"])->orderBy("name","asc");
|
||||
"description"
|
||||
])->orderBy("name", "asc");
|
||||
return DataTable::of($query)
|
||||
->add("action",fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
->add("action", fn($q) => $q->id)
|
||||
->toJson(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
<?php
|
||||
namespace App\Controllers\Configuracion;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
@ -12,8 +13,8 @@ use App\Models\Configuracion\MaquinasTarifasImpresionModel;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
|
||||
use
|
||||
DataTables\Editor,
|
||||
DataTables\Editor\Field;
|
||||
DataTables\Editor,
|
||||
DataTables\Editor\Field;
|
||||
|
||||
class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
@ -69,9 +70,9 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -81,10 +82,10 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -98,14 +99,14 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -129,25 +130,25 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
|
||||
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
if ($requestedId == null):
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$maquinasTarifasImpresion = $this->model->find($id);
|
||||
|
||||
if ($maquinasTarifasImpresion == false) :
|
||||
if ($maquinasTarifasImpresion == false):
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('MaquinasTarifasImpresions.maquinasTarifaImpresion')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -160,10 +161,10 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -180,12 +181,12 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
$id = $maquinasTarifasImpresion->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -220,30 +221,48 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
$response = Editor::inst($db, 'lg_maquinas_tarifas_impresion')
|
||||
->fields(
|
||||
Field::inst('uso')
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.uso.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.uso.required')
|
||||
)
|
||||
),
|
||||
Field::inst('tipo')
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
|
||||
)
|
||||
),
|
||||
Field::inst('precio')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal'))
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
|
||||
)
|
||||
),
|
||||
Field::inst('margen')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal'))
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.precio.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required')
|
||||
)
|
||||
),
|
||||
Field::inst('maquina_id'),
|
||||
Field::inst('user_created_id'),
|
||||
@ -269,16 +288,21 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
'maquina_id' => $values['maquina_id'],
|
||||
'tipo' => $values['tipo'],
|
||||
'uso' => $values['uso'],
|
||||
'is_deleted' => 0));
|
||||
'is_deleted' => 0
|
||||
));
|
||||
|
||||
$id = $builder->get()->getFirstRow()->id;
|
||||
$id = $builder->get()->getFirstRow();
|
||||
if ($id) {
|
||||
$id = $id->id;
|
||||
// No se pueden duplicar valores al crear o al editar
|
||||
if ($builder->countAllResults() >= 1) {
|
||||
if (
|
||||
($action === Editor::ACTION_EDIT && $id != $pkey)
|
||||
|| $action === Editor::ACTION_CREATE
|
||||
) {
|
||||
|
||||
// No se pueden duplicar valores al crear o al editar
|
||||
if ($builder->countAllResults() >= 1) {
|
||||
if (($action === Editor::ACTION_EDIT && $id != $pkey)
|
||||
|| $action === Editor::ACTION_CREATE) {
|
||||
|
||||
return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
|
||||
return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -413,11 +437,11 @@ class Maquinastarifasimpresion extends \App\Controllers\BaseResourceController
|
||||
protected function getMaquinaListItems($selId = null)
|
||||
{
|
||||
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])];
|
||||
if (!empty($selId)) :
|
||||
if (!empty($selId)):
|
||||
$maquinaModel = model('App\Models\Configuracion\MaquinaModel');
|
||||
|
||||
$selOption = $maquinaModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
if (!empty($selOption)):
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
|
||||
@ -244,23 +244,15 @@ class Papelformato extends \App\Controllers\BaseResourceController {
|
||||
|
||||
public function menuItems() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
$reqId = goSanitize($this->request->getPost('id'))[0];
|
||||
$reqText = goSanitize($this->request->getPost('text'))[0];
|
||||
$onlyActiveOnes = false;
|
||||
$columns2select = [$reqId ?? 'id', $reqText ?? 'ancho'];
|
||||
$onlyActiveOnes = false;
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$papelFormatoModel = model('App\Models\Configuracion\PapelFormatoModel');
|
||||
$searchStr = goSanitize($this->request->getPfgost('searchTerm'))[0];
|
||||
$menu = $papelFormatoModel->getElementsForMenu2($searchStr);
|
||||
if(empty(($searchStr)))
|
||||
array_shift($menu);
|
||||
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
@ -268,4 +260,15 @@ class Papelformato extends \App\Controllers\BaseResourceController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getSelect2()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$data = $this->model->getElementsForMenu2($this->request->getGet("q"));
|
||||
|
||||
return $this->response->setJSON($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,4 +15,15 @@ class Language extends BaseController
|
||||
$url = previous_url();
|
||||
return redirect()->to($url);
|
||||
}
|
||||
|
||||
|
||||
// Function to get the translation of the language file from a AJAX request
|
||||
public function getTranslation()
|
||||
{
|
||||
$translationFile = $this->request->getPost('translationFile');
|
||||
$locale = $this->request->getPost('locale');
|
||||
$path = "Language/{$locale}/$translationFile.php";
|
||||
$lang = require APPPATH.$path;
|
||||
return json_encode($lang);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1278,8 +1278,8 @@ class Cosidotapablanda extends \App\Controllers\BaseResourceController
|
||||
$input_data['is_duplicado'] = $presupuestoEntity->is_duplicado;
|
||||
|
||||
if($presupuestoEntity->papel_formato_personalizado){
|
||||
$input_data['ancho'] = $presupuestoEntity->ancho;
|
||||
$input_data['alto'] = $presupuestoEntity->alto;
|
||||
$input_data['ancho'] = $presupuestoEntity->papel_formato_ancho ;
|
||||
$input_data['alto'] = $presupuestoEntity->papel_formato_alto ;
|
||||
}
|
||||
else{
|
||||
$model = model("App\Models\Configuracion\PapelFormatoModel");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -39,10 +39,10 @@ class TarifaAcabados extends BaseResourceController
|
||||
|
||||
$this->viewData = ['usingServerSideDataTable' => true];
|
||||
|
||||
// Breadcrumbs
|
||||
// Breadcrumbs
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_tarifas"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_tarifaacabado"), 'route' => site_url('tarifas/tarifaacabado'), 'active' => true]
|
||||
['title' => lang("App.menu_tarifaacabado"), 'route' => site_url('tarifas/acabados'), 'active' => true]
|
||||
];
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
@ -133,6 +133,8 @@ class TarifaAcabados extends BaseResourceController
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['proveedores'] = $this->getProveedores();
|
||||
|
||||
$this->viewData['tarifaacabadoEntity'] = isset($sanitizedData) ? new TarifaAcabadoEntity($sanitizedData) : new TarifaAcabadoEntity();
|
||||
$this->viewData['formAction'] = route_to('tarifaAcabadoAdd');
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifaacabado.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php namespace App\Controllers\Tarifas;
|
||||
<?php
|
||||
namespace App\Controllers\Tarifas;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
@ -10,15 +11,15 @@ use App\Entities\Tarifas\TarifaEncuadernacionLinea;
|
||||
use App\Models\Tarifas\TarifaEncuadernacionLineaModel;
|
||||
|
||||
use
|
||||
DataTables\Editor,
|
||||
DataTables\Database,
|
||||
DataTables\Editor\Field,
|
||||
DataTables\Editor\Format,
|
||||
DataTables\Editor\Mjoin,
|
||||
DataTables\Editor\Options,
|
||||
DataTables\Editor\Upload,
|
||||
DataTables\Editor\Validate,
|
||||
DataTables\Editor\ValidateOptions;
|
||||
DataTables\Editor,
|
||||
DataTables\Database,
|
||||
DataTables\Editor\Field,
|
||||
DataTables\Editor\Format,
|
||||
DataTables\Editor\Mjoin,
|
||||
DataTables\Editor\Options,
|
||||
DataTables\Editor\Upload,
|
||||
DataTables\Editor\Validate,
|
||||
DataTables\Editor\ValidateOptions;
|
||||
|
||||
|
||||
class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
@ -73,9 +74,9 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -84,10 +85,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -101,14 +102,14 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -134,20 +135,20 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
if ($requestedId == null):
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$tarifaEncuadernacionLinea = $this->model->find($id);
|
||||
|
||||
if ($tarifaEncuadernacionLinea == false) :
|
||||
if ($tarifaEncuadernacionLinea == false):
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -156,10 +157,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -176,12 +177,12 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
$id = $tarifaEncuadernacionLinea->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -214,45 +215,90 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
$response = Editor::inst($db, 'tarifa_encuadernacion_lineas')
|
||||
->fields(
|
||||
Field::inst('paginas_libro_min')
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal'))
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')
|
||||
)
|
||||
),
|
||||
Field::inst('paginas_libro_max')
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal'))
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')
|
||||
)
|
||||
),
|
||||
Field::inst('precio_min')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')
|
||||
)
|
||||
),
|
||||
Field::inst('precio_max')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required')
|
||||
)
|
||||
),
|
||||
Field::inst('total_min')
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal')
|
||||
)
|
||||
)
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')
|
||||
)
|
||||
),
|
||||
Field::inst('margen')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.required')
|
||||
)
|
||||
),
|
||||
Field::inst('tirada_encuadernacion_id'),
|
||||
Field::inst('user_created_id'),
|
||||
@ -322,10 +368,10 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
|
||||
$cleandatatable = $reqData['cleandatatable'] ?? 0;
|
||||
|
||||
if($cleandatatable){
|
||||
|
||||
if ($cleandatatable) {
|
||||
|
||||
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1;
|
||||
|
||||
@ -338,11 +384,9 @@ class Tarifaencuadernacionlineas extends \App\Controllers\BaseResourceController
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
|
||||
}
|
||||
|
||||
else{
|
||||
|
||||
} else {
|
||||
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php namespace App\Controllers\Tarifas;
|
||||
<?php
|
||||
namespace App\Controllers\Tarifas;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
@ -10,15 +11,15 @@ use App\Entities\Tarifas\TarifaEncuadernacionLinea;
|
||||
use App\Models\Tarifas\TarifaEncuadernacionLineaHorasModel;
|
||||
|
||||
use
|
||||
DataTables\Editor,
|
||||
DataTables\Database,
|
||||
DataTables\Editor\Field,
|
||||
DataTables\Editor\Format,
|
||||
DataTables\Editor\Mjoin,
|
||||
DataTables\Editor\Options,
|
||||
DataTables\Editor\Upload,
|
||||
DataTables\Editor\Validate,
|
||||
DataTables\Editor\ValidateOptions;
|
||||
DataTables\Editor,
|
||||
DataTables\Database,
|
||||
DataTables\Editor\Field,
|
||||
DataTables\Editor\Format,
|
||||
DataTables\Editor\Mjoin,
|
||||
DataTables\Editor\Options,
|
||||
DataTables\Editor\Upload,
|
||||
DataTables\Editor\Validate,
|
||||
DataTables\Editor\ValidateOptions;
|
||||
|
||||
|
||||
class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceController
|
||||
@ -71,9 +72,9 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -82,10 +83,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -99,14 +100,14 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -134,20 +135,20 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
if ($requestedId == null):
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$tarifaEncuadernacionLinea = $this->model->find($id);
|
||||
|
||||
if ($tarifaEncuadernacionLinea == false) :
|
||||
if ($tarifaEncuadernacionLinea == false):
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaEncuadernacionLineas.tarifaencuadernacionLinea')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
@ -156,10 +157,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -176,12 +177,12 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
$id = $tarifaEncuadernacionLinea->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -214,40 +215,79 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
$response = Editor::inst($db, 'tarifa_encuadernacion_lineas_horas')
|
||||
->fields(
|
||||
Field::inst('tiempo_min')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_min.required')
|
||||
)
|
||||
),
|
||||
Field::inst('tiempo_max')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.paginas_libro_max.required')
|
||||
)
|
||||
),
|
||||
Field::inst('precio_hora')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required')
|
||||
)
|
||||
),
|
||||
Field::inst('total_min')
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal')
|
||||
)
|
||||
)
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required')
|
||||
)
|
||||
),
|
||||
Field::inst('margen')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal'))
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.decimal')
|
||||
)
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.required'))
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.margen.required')
|
||||
)
|
||||
),
|
||||
Field::inst('tirada_encuadernacion_id'),
|
||||
Field::inst('user_created_id'),
|
||||
@ -314,10 +354,10 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
|
||||
$cleandatatable = $reqData['cleandatatable'] ?? 0;
|
||||
|
||||
if($cleandatatable){
|
||||
|
||||
if ($cleandatatable) {
|
||||
|
||||
$tarifa_encuadernacion_id = $reqData['tarifa_encuadernacion_id'] ?? -1;
|
||||
|
||||
@ -330,9 +370,8 @@ class Tarifaencuadernacionlineashoras extends \App\Controllers\BaseResourceContr
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
} else {
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
|
||||
|
||||
@ -126,15 +126,6 @@ class Tarifaencuadernaciontiradas extends \App\Controllers\BaseResourceControlle
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required'))
|
||||
),
|
||||
Field::inst('precio_min')
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator('Validate::numeric', array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.decimal'))
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_min.required'))
|
||||
),
|
||||
Field::inst('proveedor_id')
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('TarifaEncuadernacionTiradas.validation.tirada_max.required'))
|
||||
|
||||
Reference in New Issue
Block a user