mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Inicio servicios para presupuestos
This commit is contained in:
4
.idea/php.xml
generated
4
.idea/php.xml
generated
@ -10,7 +10,9 @@
|
||||
<option name="highlightLevel" value="WARNING" />
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="7.3" />
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.0">
|
||||
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||
</component>
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
|
||||
4
ci4/.env
4
ci4/.env
@ -22,8 +22,8 @@ CI_ENVIRONMENT = development
|
||||
# APP
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
app.baseURL = 'https://sk-jjo.imnavajas.es'
|
||||
#app.baseURL = 'https://sk-imn.imnavajas.es'
|
||||
#app.baseURL = 'https://sk-jjo.imnavajas.es'
|
||||
app.baseURL = 'https://sk-imn.imnavajas.es'
|
||||
# app.baseURL = "http://safekat.test/"
|
||||
# app.forceGlobalSecureRequests = false
|
||||
|
||||
|
||||
@ -148,6 +148,12 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$this->viewData['papelGenericoCubiertaList'] = $this->getPapelGenericoCubierta();
|
||||
$this->viewData['papelGenericoSobrecubiertaList'] = $this->getPapelGenericoSobreCubierta();
|
||||
|
||||
// Tarifas
|
||||
$this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion();
|
||||
$this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion();
|
||||
$this->viewData['serviciosAcabado'] = $this->getServiciosAcabado();
|
||||
$this->viewData['serviciosManipulado'] = $this->getServiciosManipulado();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@ -376,7 +382,6 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$this->viewData['papelGenericoCubiertaList'] = $this->getPapelGenericoCubierta();
|
||||
$this->viewData['papelGenericoSobrecubiertaList'] = $this->getPapelGenericoSobreCubierta();
|
||||
|
||||
|
||||
$this->viewData['formAction'] = route_to('updatePresupuesto', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Presupuestos.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
@ -701,6 +706,53 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getServiciosPreimpresion()
|
||||
{
|
||||
$model = model('App\Models\Tarifas\TarifapreimpresionModel');
|
||||
$data = $model->getServiciosPreimpresionSelector();
|
||||
array_unshift($data, (object)array(
|
||||
"id" => 0,
|
||||
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioPreimpresion'))])
|
||||
));
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getServiciosEncuadernacion()
|
||||
{
|
||||
$model = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||
$data = $model->getServiciosEncuadernacionSelector();
|
||||
array_unshift($data, (object)array(
|
||||
"id" => 0,
|
||||
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioEncuadernacion'))])
|
||||
));
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getServiciosAcabado()
|
||||
{
|
||||
$model = model('App\Models\Tarifas\TarifaacabadoModel');
|
||||
$data = $model->getServiciosAcabadoSelector();
|
||||
array_unshift($data, (object)array(
|
||||
"id" => 0,
|
||||
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioAcabado'))])
|
||||
));
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getServiciosManipulado()
|
||||
{
|
||||
$model = model('App\Models\Tarifas\TarifaManipuladoModel');
|
||||
$data = $model->getServiciosManipuladoSelector();
|
||||
array_unshift($data, (object)array(
|
||||
"id" => 0,
|
||||
"nombre" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioManipulado'))])
|
||||
));
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@ -1087,4 +1139,5 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
return $paginasPortadaOptions;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
367
ci4/app/Controllers/Presupuestos/PresupuestoAcabados.php
Normal file
367
ci4/app/Controllers/Presupuestos/PresupuestoAcabados.php
Normal file
@ -0,0 +1,367 @@
|
||||
<?php namespace App\Controllers\Presupuestos;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\Clientes\ClienteContactoEntity;
|
||||
|
||||
use App\Models\Clientes\ClienteModel;
|
||||
|
||||
use App\Models\Presupuestos\PresupuestoAcabadoModel;
|
||||
use DataTables\Editor;
|
||||
use DataTables\Editor\Field;
|
||||
use DataTables\Editor\Validate;
|
||||
use function App\Controllers\Clientes\csrf_hash;
|
||||
use function App\Controllers\Clientes\csrf_token;
|
||||
use function App\Controllers\Clientes\lang;
|
||||
use function App\Controllers\Clientes\model;
|
||||
use function App\Controllers\Clientes\redirect;
|
||||
use function App\Controllers\Clientes\route_to;
|
||||
use function App\Controllers\Clientes\view;
|
||||
use const App\Controllers\Clientes\APPPATH;
|
||||
|
||||
class PresupuestoAcabados extends \App\Controllers\GoBaseResourceController
|
||||
{
|
||||
|
||||
protected $modelName = PresupuestoAcabadoModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Contacto de cliente';
|
||||
protected static $singularObjectNameCc = 'contactoDeCliente';
|
||||
protected static $pluralObjectName = 'Contactos de cliente';
|
||||
protected static $pluralObjectNameCc = 'contactosDeCliente';
|
||||
|
||||
protected static $controllerSlug = 'presupuesto-acabados';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/clientes/contactos/';
|
||||
|
||||
protected $indexRoute = 'contactoDeClienteList';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('ClienteContactos.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ClienteContactos.contactoDeCliente')]),
|
||||
'clienteContactoEntity' => new ClienteContactoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath . 'viewContactoDeClienteList', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [lang('Basic.global.record')]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['clienteContactoEntity'] = isset($sanitizedData) ? new ClienteContactoEntity($sanitizedData) : new ClienteContactoEntity();
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems($clienteContactoEntity->cliente_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('createContactoDeCliente');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('ClienteContactos.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$clienteContactoEntity = $this->model->find($id);
|
||||
|
||||
if ($clienteContactoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('ClienteContactos.contactoDeCliente')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('ClienteContactos.contactoDeCliente'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$clienteContactoEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $clienteContactoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['clienteContactoEntity'] = $clienteContactoEntity;
|
||||
$this->viewData['clienteList'] = $this->getClienteListItems($clienteContactoEntity->cliente_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateContactoDeCliente', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('ClienteContactos.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
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);
|
||||
return $response;
|
||||
}
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$order = ClienteContactoModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$id_C = $reqData['id_cliente'] ?? -1;
|
||||
|
||||
$resourceData = $this->model->getResource("", $id_C)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
/*$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
foreach ($resourceData as $item) :
|
||||
if (isset($item->apellidos) && strlen($item->apellidos) > 100) :
|
||||
$item->apellidos = character_limiter($item->apellidos, 100);
|
||||
endif;
|
||||
endforeach;*/
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource("", $id_C)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function datatable_editor() {
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
|
||||
|
||||
// Build our Editor instance and process the data coming from _POST
|
||||
$response = Editor::inst( $db, 'cliente_contactos' )
|
||||
->fields(
|
||||
Field::inst( 'nombre' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta nombre' )
|
||||
),
|
||||
Field::inst( 'apellidos' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta apellidos' )
|
||||
),
|
||||
Field::inst( 'cargo' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta cargp' )
|
||||
),
|
||||
Field::inst( 'telefono' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta telefono' )
|
||||
),
|
||||
Field::inst( 'email' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta email' )
|
||||
),
|
||||
|
||||
Field::inst( 'cliente_id' ),
|
||||
|
||||
)
|
||||
->validator( function($editor, $action, $data){
|
||||
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){
|
||||
/*foreach ($data['data'] as $pkey => $values ){
|
||||
// No se pueden duplicar valores al crear o al editar
|
||||
if (!empty($response)){
|
||||
return $response;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
})
|
||||
->debug(true)
|
||||
->process( $_POST )
|
||||
->data();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$response[$csrfTokenName] = $newTokenHash;
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function allItemsSelect()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$onlyActiveOnes = true;
|
||||
$reqVal = $this->request->getPost('val') ?? 'id';
|
||||
$menu = $this->model->getAllForMenu($reqVal . ', nombre', 'nombre', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->nombre = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
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 ?? 'nombre'];
|
||||
$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();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getClienteListItems($selId = null)
|
||||
{
|
||||
$data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Clientes.cliente'))])];
|
||||
if (!empty($selId)) :
|
||||
$clienteModel = model('App\Models\Clientes\ClienteModel');
|
||||
|
||||
$selOption = $clienteModel->where('id', $selId)->findColumn('nombre');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
26
ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php
Normal file
26
ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace App\Entities\Presupuestos;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class PresupuestoAcabadosEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"presupuesto_id" => null,
|
||||
"tarifa_acabado_id" => null,
|
||||
"nombre" => null,
|
||||
"precio" => null,
|
||||
"precio_unidad" => null,
|
||||
"tirada" => null,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"presupuesto_id" => "int",
|
||||
"tarifa_acabado_id" => "int",
|
||||
"precio" => "float",
|
||||
"precio_unidad" => "float",
|
||||
"tirada" => "int",
|
||||
];
|
||||
}
|
||||
@ -10,6 +10,7 @@ return [
|
||||
|
||||
'datosPresupuesto' => 'Budget information',
|
||||
'datosLibro' => 'Book information',
|
||||
'datosServicios' => 'Other Services',
|
||||
'datosPresupuestoCliente' => 'Client budget data (comparator)',
|
||||
|
||||
'id' => 'Budget Number',
|
||||
|
||||
@ -10,6 +10,7 @@ return [
|
||||
|
||||
'datosPresupuesto' => 'Datos generales del presupuesto',
|
||||
'datosLibro' => 'Datos del libro',
|
||||
'datosServicios' => 'Otros Servicios',
|
||||
'datosPresupuestoCliente' => 'Datos presupuesto cliente (comparador)',
|
||||
|
||||
'id' => 'Número Presupuesto',
|
||||
@ -85,6 +86,10 @@ return [
|
||||
'solapasAnchoCubierta' => 'Ancho solapas cubierta',
|
||||
'1cara' => '1 cara',
|
||||
'2caras' => '2 caras',
|
||||
'servicioAcabado' => 'Servicio de acabado',
|
||||
'servicioPreimpresion' => 'Servicio de preimpresión',
|
||||
'servicioEncuadernado' => 'Servicio de encuadernado',
|
||||
'servicioManipulado' => 'Servicio de manipulado',
|
||||
|
||||
/* '4x0' => '4x0',
|
||||
'4x4' => '4x4',
|
||||
|
||||
127
ci4/app/Models/Presupuestos/PresupuestoAcabadoModel.php
Normal file
127
ci4/app/Models/Presupuestos/PresupuestoAcabadoModel.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Presupuestos;
|
||||
|
||||
class PresupuestoAcabadoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "presupuesto_acabados";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.nombre",
|
||||
1 => "t1.apellidos",
|
||||
2 => "t1.cargo",
|
||||
3 => "t1.telefono",
|
||||
4 => "t1.email",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["cliente_id", "cargo", "nombre", "apellidos", "telefono", "email"];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoAcabadosEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"apellidos" => [
|
||||
"label" => "ClienteContactos.apellidos",
|
||||
"rules" => "trim|max_length[500]",
|
||||
],
|
||||
"cargo" => [
|
||||
"label" => "ClienteContactos.cargo",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"email" => [
|
||||
"label" => "ClienteContactos.email",
|
||||
"rules" => "trim|max_length[150]|valid_email|permit_empty",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "ClienteContactos.nombre",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"telefono" => [
|
||||
"label" => "ClienteContactos.telefono",
|
||||
"rules" => "trim|max_length[20]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"apellidos" => [
|
||||
"max_length" => "ClienteContactos.validation.apellidos.max_length",
|
||||
],
|
||||
"cargo" => [
|
||||
"max_length" => "ClienteContactos.validation.cargo.max_length",
|
||||
],
|
||||
"email" => [
|
||||
"max_length" => "ClienteContactos.validation.email.max_length",
|
||||
"valid_email" => "ClienteContactos.validation.email.valid_email",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "ClienteContactos.validation.nombre.max_length",
|
||||
],
|
||||
"telefono" => [
|
||||
"max_length" => "ClienteContactos.validation.telefono.max_length",
|
||||
],
|
||||
];
|
||||
|
||||
public function findAllWithClientes(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.nombre AS cliente_id FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN clientes t2 ON t1.cliente_id = t2.id";
|
||||
if (!is_null($limit) && intval($limit) > 0) {
|
||||
$sql .= " LIMIT " . $limit;
|
||||
}
|
||||
|
||||
if (!is_null($offset) && intval($offset) > 0) {
|
||||
$sql .= " OFFSET " . $offset;
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$result = $query->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "", $presupuesto_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.cargo AS cargo, t1.nombre AS nombre, t1.apellidos AS apellidos, t1.telefono AS telefono, t1.email AS email, t1.cliente_id AS cliente_id"
|
||||
);
|
||||
|
||||
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
||||
$builder->join("presupuestos t2", "t1.presupuesto_id = t2.id", "left");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.cargo", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.apellidos", $search)
|
||||
->orLike("t1.telefono", $search)
|
||||
->orLike("t1.email", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
@ -94,4 +94,22 @@ class TarifaEncuadernacionModel extends \App\Models\GoBaseModel
|
||||
->like("t1.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function getServiciosEncuadernacionSelector()
|
||||
{
|
||||
/*
|
||||
Todos los servicios de encuadernacion activas que se pueden usar en presupuestos
|
||||
*/
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id as id, t1.nombre AS nombre"
|
||||
)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.mostrar_en_presupuesto", 1);
|
||||
|
||||
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -93,4 +93,20 @@ class TarifaManipuladoModel extends \App\Models\GoBaseModel
|
||||
->like("t1.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function getServiciosManipuladoSelector()
|
||||
{
|
||||
/*
|
||||
Todos los servicios de manipulado activas que se pueden usar en presupuestos
|
||||
*/
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id as id, t1.nombre AS nombre"
|
||||
)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.mostrar_en_presupuesto", 1);
|
||||
|
||||
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,4 +94,22 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel
|
||||
->like("t1.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function getServiciosAcabadoSelector()
|
||||
{
|
||||
/*
|
||||
Todos los servicios de acabado activos que se pueden usar en presupuestos
|
||||
*/
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id as id, t1.nombre AS nombre"
|
||||
)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.mostrar_en_presupuesto", 1);
|
||||
|
||||
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -79,4 +79,22 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel
|
||||
"decimal" => "Tarifapreimpresion.validation.margen.decimal",
|
||||
],
|
||||
];
|
||||
|
||||
public function getServiciosPreimpresionSelector()
|
||||
{
|
||||
/*
|
||||
Todos los servicios de preimpresion activas que se pueden usar en presupuestos
|
||||
*/
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id as id, t1.nombre AS nombre"
|
||||
)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.mostrar_en_presupuesto", 1);
|
||||
|
||||
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default"
|
||||
data-bs-dismiss="modal"><?= lang('Basic.global.deleteConfirmationCancel') ?></button>
|
||||
<a href="javascript:void(0);" class="btn btn-danger btn-confirm btn-remove"><?= lang('Basic.global.deleteConfirmationButton') ?></a>
|
||||
<a id="confirmDelete" href="javascript:void(0);" class="btn btn-danger btn-confirm btn-remove"><?= lang('Basic.global.deleteConfirmationButton') ?></a>
|
||||
</div><!--//.modal-footer -->
|
||||
</div><!--//.modal-content -->
|
||||
</div><!--//.modal-dialog -->
|
||||
|
||||
@ -175,6 +175,12 @@
|
||||
$(this).find('.btn-confirm').attr('href', $(e.relatedTarget).data('href'));
|
||||
});
|
||||
|
||||
$('#confirm2delete').keypress(function(e) { // Attach the form handler to the keypress event
|
||||
if (e.keyCode == 13) { // If the the enter key was pressed.
|
||||
$('#confirmDelete').click(); // Trigger the button(elementId) click event.
|
||||
}
|
||||
});
|
||||
|
||||
function toggleAllCheckboxes($cssClass, $io=null) {
|
||||
$('.'+$cssClass).prop('checked', $io);
|
||||
}
|
||||
|
||||
@ -0,0 +1,88 @@
|
||||
<div class="accordion mt-3" id="accordionDatosServicios">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingOne">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse"
|
||||
data-bs-target="#accordionDatosServiciosTip" aria-expanded="false"
|
||||
aria-controls="accordionDatosServiciosTip">
|
||||
<h4><?= lang("Presupuestos.datosServicios") ?></h4>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
<div id="accordionDatosServiciosTip" class="accordion-collapse collapse show"
|
||||
data-bs-parent="#accordionDatosServicios">
|
||||
<div class="accordion-body">
|
||||
<div class="nav-align-top mb-4">
|
||||
<ul class="nav nav-pills mb-3" role="tablist">
|
||||
<li class="nav-item">
|
||||
<button
|
||||
type="button"
|
||||
class="nav-link active"
|
||||
role="tab"
|
||||
data-bs-toggle="tab"
|
||||
data-bs-target="#servicios-acabado"
|
||||
aria-controls="servicios-acabado"
|
||||
aria-selected="true">
|
||||
<?= lang("Presupuestos.servicioAcabado") ?>
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button
|
||||
type="button"
|
||||
class="nav-link"
|
||||
role="tab"
|
||||
data-bs-toggle="tab"
|
||||
data-bs-target="#servicios-preimpresion"
|
||||
aria-controls="servicios-preimpresion"
|
||||
aria-selected="false">
|
||||
<?= lang("Presupuestos.servicioPreimpresion") ?>
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button
|
||||
type="button"
|
||||
class="nav-link"
|
||||
role="tab"
|
||||
data-bs-toggle="tab"
|
||||
data-bs-target="#servicios-encuadernacion"
|
||||
aria-controls="servicios-encuadernacion"
|
||||
aria-selected="false">
|
||||
<?= lang("Presupuestos.servicioEncuadernado") ?>
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button
|
||||
type="button"
|
||||
class="nav-link"
|
||||
role="tab"
|
||||
data-bs-toggle="tab"
|
||||
data-bs-target="#servicios-manipulado"
|
||||
aria-controls="servicios-manipulado"
|
||||
aria-selected="false">
|
||||
<?= lang("Presupuestos.servicioManipulado") ?>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade show active" id="servicios-acabado" role="tabpanel">
|
||||
<h3>Proximanente</h3>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="servicios-preimpresion" role="tabpanel">
|
||||
<h3>Proximanente</h3>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="servicios-encuadernacion" role="tabpanel">
|
||||
<h3>Proximanente</h3>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="servicios-manipulado" role="tabpanel">
|
||||
<h3>Proximanente</h3>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- //.accordion-body -->
|
||||
</div> <!-- //.accordion-collapse -->
|
||||
</div> <!-- //.accordion-item -->
|
||||
</div> <!-- //.accordion -->
|
||||
@ -17,6 +17,7 @@
|
||||
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoItems") ?>
|
||||
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems") ?>
|
||||
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosPresupuestoClienteItems") ?>
|
||||
<?= view("themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems") ?>
|
||||
<div class="pt-4">
|
||||
<input type="submit"
|
||||
class="btn btn-primary float-start me-sm-3 me-1"
|
||||
|
||||
Reference in New Issue
Block a user