mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
servicio cliente tareas
This commit is contained in:
@ -45,7 +45,7 @@ $routes->group('tarifas', ['namespace' => 'App\Controllers\Tarifas'], function (
|
||||
$routes->match(['get', 'post'], 'edit/(:num)', 'TarifaAcabados::edit/$1', ['as' => 'tarifaAcabadoEdit']);
|
||||
$routes->get('delete/(:num)', 'TarifaAcabados::delete/$1', ['as' => 'tarifaAcabadoDelete']);
|
||||
$routes->post('datatable', 'TarifaAcabados::datatable', ['as' => 'tarifaAcabadoDT']);
|
||||
|
||||
$routes->get('select','TarifaAcabados::show_select',["as" => "showSelectTarifaAcabado"]);
|
||||
$routes->group('lineas', ['namespace' => 'App\Controllers\Tarifas\Acabados'], function ($routes) {
|
||||
$routes->post('datatable', 'TarifaAcabadosLineas::datatable', ['as' => 'tarifaAcabadoLineasDT']);
|
||||
$routes->post('datatable_editor', 'TarifaAcabadosLineas::datatable_editor', ['as' => 'tarifaAcabadoLineasDTE']);
|
||||
@ -92,6 +92,14 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion']
|
||||
$routes->get('datatable', 'ConfigErrores::datatable', ['as' => 'erroresPresupuestoDatatable']);
|
||||
$routes->post('edit/(:num)', 'ConfigErrores::update_error_presupuesto/$1', ['as' => 'erroresPresupuestoUpdate']);
|
||||
});
|
||||
$routes->group("servicios", ["namespace" => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
$routes->get('', 'ServicioCliente::index', ['as' => 'servicioClienteList']);
|
||||
$routes->get('(:num)', 'ServicioCliente::show/$1', ['as' => 'servicioClienteShow']);
|
||||
$routes->post('(:num)', 'ServicioCliente::store/$1', ['as' => 'servicioClienteStore']);
|
||||
$routes->post('update/(:num)', 'ServicioCliente::update_servicio_cliente/$1', ['as' => 'updateServicioCliente']);
|
||||
$routes->get('edit/(:num)', 'ServicioCliente::viewForm/$1', ['as' => 'servicioClienteViewForm']);
|
||||
$routes->get('datatable', 'ServicioCliente::datatable', ['as' => 'servicioClienteDatatable']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -159,6 +167,8 @@ $routes->group('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas'],
|
||||
$routes->post('datatable', 'Tarifasmanipulado::datatable', ['as' => 'dataTableOfTarifasManipulado']);
|
||||
$routes->post('allmenuitems', 'Tarifasmanipulado::allItemsSelect', ['as' => 'select2ItemsOfTarifasManipulado']);
|
||||
$routes->post('menuitems', 'Tarifasmanipulado::menuItems', ['as' => 'menuItemsOfTarifasManipulado']);
|
||||
$routes->get('select','Tarifasmanipulado::show_select',["as" => "showSelectTarifaManipulado"]);
|
||||
|
||||
});
|
||||
$routes->resource('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasmanipulado', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
89
ci4/app/Controllers/Configuracion/ServicioCliente.php
Normal file
89
ci4/app/Controllers/Configuracion/ServicioCliente.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Controllers\Tarifas\Acabados;
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas\Acabados;
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
use App\Entities\Tarifas\Acabados\TarifaAcabadoEntity;
|
||||
@ -207,7 +209,7 @@ class TarifaAcabados extends BaseResourceController
|
||||
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $tarifaacabadoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) .'.';
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
@ -312,12 +314,26 @@ class TarifaAcabados extends BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
private function getProveedores(){
|
||||
private function getProveedores()
|
||||
{
|
||||
$provTipoModel = new ProveedorTipoModel();
|
||||
$provModel = new ProveedorModel();
|
||||
|
||||
$tipoId = $provTipoModel->getTipoId("Acabados");
|
||||
return $provModel->getProvList($tipoId);
|
||||
}
|
||||
|
||||
public function show_select()
|
||||
{
|
||||
$query = $this->model->builder()
|
||||
->select(
|
||||
["id", "nombre as name", "code as description"]
|
||||
)
|
||||
->where("deleted_at",null);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Controllers\Tarifas;
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Tarifas;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
@ -130,7 +132,7 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
|
||||
$this->viewData['tarifaManipuladoEntity'] = isset($sanitizedData) ? new TarifaManipuladoEntity($sanitizedData) : new TarifaManipuladoEntity();
|
||||
|
||||
$this->viewData['formAction'] = site_url('tarifas/tarifasmanipulado/add');//route_to('createTarifaManipulado');
|
||||
$this->viewData['formAction'] = site_url('tarifas/tarifasmanipulado/add'); //route_to('createTarifaManipulado');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifamanipulado.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix');
|
||||
|
||||
@ -293,5 +295,19 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
public function show_select()
|
||||
{
|
||||
$query = $this->model->builder()
|
||||
->select(
|
||||
["id", "nombre as name", "code as description"]
|
||||
)
|
||||
->where("deleted_at", null);
|
||||
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ class ServicioClienteTareas extends Migration
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"autoincrement" => true
|
||||
"auto_increment" => true
|
||||
],
|
||||
"servicio_cliente_id" => [
|
||||
"type" => "INT",
|
||||
@ -21,12 +21,14 @@ class ServicioClienteTareas extends Migration
|
||||
"tarifa_acabado_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"null" => true,
|
||||
"comment" => "Tarifa de acabado asociada a servicio"
|
||||
],
|
||||
"tarifa_manipulado_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"comment" => "Tarifa de manipulado asociada a servicio"
|
||||
"null" => true,
|
||||
"comment" => "Tarifa de manipulado asociada a servicio",
|
||||
|
||||
]
|
||||
];
|
||||
@ -51,6 +53,8 @@ class ServicioClienteTareas extends Migration
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey("id");
|
||||
$this->forge->addForeignKey('servicio_cliente_id','servicios_cliente','id');
|
||||
$this->forge->addForeignKey('tarifa_acabado_id','lg_tarifa_acabado','id');
|
||||
$this->forge->addForeignKey('tarifa_manipulado_id','lg_tarifa_manipulado','id');
|
||||
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AlterColumnServiciosCliente extends Migration
|
||||
{
|
||||
protected array $ALTER_COLUMNS = [
|
||||
"deleted_at" => [
|
||||
"name" => "deleted_at",
|
||||
"type" => "datetime",
|
||||
"default" => null,
|
||||
"null" => true,
|
||||
],
|
||||
"updated_at" => [
|
||||
"name" => "updated_at",
|
||||
"type" => "datetime",
|
||||
"default" => null,
|
||||
"null" => true,
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->modifyColumn("servicios_cliente", $this->ALTER_COLUMNS);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->addField([
|
||||
"is_deleted" => [
|
||||
"type" => "boolean",
|
||||
"default" => false,
|
||||
"null" => false,
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
59
ci4/app/Entities/Configuracion/ServicioClienteEntity.php
Normal file
59
ci4/app/Entities/Configuracion/ServicioClienteEntity.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Configuracion;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
use App\Entities\Tarifas\Acabados\TarifaAcabadoEntity;
|
||||
use App\Entities\Tarifas\TarifaManipuladoEntity;
|
||||
use App\Models\Configuracion\ServicioClienteModel;
|
||||
use CodeIgniter\Database\MySQLi\Result;
|
||||
|
||||
class ServicioClienteEntity extends Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"nombre" => null,
|
||||
"code" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"nombre" => "string",
|
||||
"code" => "string",
|
||||
];
|
||||
|
||||
public function withManipuladoTarifas()
|
||||
{
|
||||
$this->attributes["tarifas_manipulado"] = $this->getManipuladoTarifas();
|
||||
return $this;
|
||||
}
|
||||
public function withAcabadoTarifas()
|
||||
{
|
||||
$this->attributes["tarifas_acabado"] = $this->getAcabadoTarifas();
|
||||
return $this;
|
||||
}
|
||||
public function withAllTarifas(){
|
||||
$this->withManipuladoTarifas();
|
||||
$this->withAcabadoTarifas();
|
||||
return $this;
|
||||
}
|
||||
public function getManipuladoTarifas(): ?object
|
||||
{
|
||||
$model = model(ServicioClienteModel::class);
|
||||
return $model->builder()->select("lg_tarifa_manipulado.*")
|
||||
->join("servicio_cliente_tareas","servicio_cliente_tareas.servicio_cliente_id = servicios_cliente.id",'left')
|
||||
->join("lg_tarifa_manipulado","lg_tarifa_manipulado.id = servicio_cliente_tareas.tarifa_manipulado_id",'left')
|
||||
->where("servicio_cliente_tareas.servicio_cliente_id",$this->attributes["id"])
|
||||
->where("lg_tarifa_manipulado.id IS NOT NULL",NULL,FALSE)
|
||||
->where("servicio_cliente_tareas.deleted_at", NULL) // Exclude soft-deleted rows
|
||||
->get()->getFirstRow();
|
||||
}
|
||||
public function getAcabadoTarifas(): ?object
|
||||
{
|
||||
$model = model(ServicioClienteModel::class);
|
||||
return $model->builder()->select("lg_tarifa_acabado.*")
|
||||
->join("servicio_cliente_tareas","servicio_cliente_tareas.servicio_cliente_id = servicios_cliente.id",'left')
|
||||
->join("lg_tarifa_acabado","lg_tarifa_acabado.id = servicio_cliente_tareas.tarifa_acabado_id",'left')
|
||||
->where("servicio_cliente_tareas.servicio_cliente_id",$this->attributes["id"])
|
||||
->where("servicio_cliente_tareas.deleted_at", NULL) // Exclude soft-deleted rows
|
||||
->where("lg_tarifa_acabado.id IS NOT NULL",NULL,FALSE)
|
||||
->get()->getFirstRow();
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace App\Entities\Presupuestos;
|
||||
namespace App\Entities\Produccion;
|
||||
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
|
||||
@ -695,6 +695,7 @@ return [
|
||||
"menu_papelgenerico" => "Papel generico",
|
||||
"menu_papelimpresion" => "Papel impresión",
|
||||
"menu_series_facturas" => "Series facturas",
|
||||
"menu_servicios_cliente" => "Servicios cliente",
|
||||
"menu_ubicaciones" => "Ubicaciones",
|
||||
"menu_serviciocliente" => "Servicio cliente",
|
||||
"menu_tamanioformatos" => "Tamaño formatos",
|
||||
|
||||
14
ci4/app/Language/es/ServicioCliente.php
Normal file
14
ci4/app/Language/es/ServicioCliente.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
return [
|
||||
"cardTitle" => "Servicios cliente",
|
||||
"infoTarifaManipulado" => "La tarifa seleccionada estará asociada al servicio.",
|
||||
"infoTarifaAcabado" => "La tarifa seleccionada estará asociada al servicio.",
|
||||
|
||||
"datatable" => [
|
||||
"nombre" => "Nombre",
|
||||
"code" => "Código",
|
||||
"created_at" => "Fecha creación",
|
||||
]
|
||||
];
|
||||
143
ci4/app/Models/Configuracion/ServicioClienteModel.php
Normal file
143
ci4/app/Models/Configuracion/ServicioClienteModel.php
Normal file
@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
use App\Entities\Configuracion\ServicioClienteEntity;
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ServicioClienteModel extends Model
|
||||
{
|
||||
|
||||
protected $table = 'servicios_cliente';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = ServicioClienteEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"code",
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
/**
|
||||
* Query para datatable
|
||||
*
|
||||
* @return BaseBuilder
|
||||
*/
|
||||
public function getQueryDatatable(): BaseBuilder
|
||||
{
|
||||
$q = $this->builder()->select(["id", "nombre", "code", "created_at"])->where("deleted_at", null);
|
||||
return $q;
|
||||
}
|
||||
/**
|
||||
* Actualiza la tarifa de acabado `lg_tarifas_acabado` si ya existe una asociada o inserta si ya no existe.
|
||||
*
|
||||
* @param integer $servicio_cliente_id
|
||||
* @param integer $tarifa_acabado_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function upsertTarifaAcabado(int $servicio_cliente_id, int $tarifa_acabado_id): bool
|
||||
{
|
||||
$servicioClienteTareaModel = model(ServicioClienteTareaModel::class);
|
||||
$q = $servicioClienteTareaModel
|
||||
->where("servicio_cliente_id", $servicio_cliente_id);
|
||||
if ($q->countAllResults() > 0) {
|
||||
$this->detachTarifas($servicio_cliente_id);
|
||||
}
|
||||
$r = $this->attachTarifaAcabado($servicio_cliente_id, $tarifa_acabado_id);
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Actualiza la tarifa de manipulado `lg_tarifas_manipulado` si ya existe una asociada o inserta si ya no existe.
|
||||
*
|
||||
* @param integer $servicio_cliente_id
|
||||
* @param integer $tarifa_manipulado_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function upsertTarifaManipulado(int $servicio_cliente_id, int $tarifa_manipulado_id): bool
|
||||
{
|
||||
$servicioClienteTareaModel = model(ServicioClienteTareaModel::class);
|
||||
$q = $servicioClienteTareaModel
|
||||
->where("servicio_cliente_id", $servicio_cliente_id);
|
||||
if ($q->countAllResults() > 0) {
|
||||
$this->detachTarifas($servicio_cliente_id);
|
||||
}
|
||||
$r = $this->attachTarifaManipulado($servicio_cliente_id, $tarifa_manipulado_id);
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Asocia tarifa de acabado a servicio cliente
|
||||
*
|
||||
* @param integer $servicio_cliente_id
|
||||
* @param integer $tarifa_acabado_id
|
||||
* @return integer
|
||||
*/
|
||||
public function attachTarifaAcabado(int $servicio_cliente_id, int $tarifa_acabado_id): int
|
||||
{
|
||||
$servicioClienteTareaModel = model(ServicioClienteTareaModel::class);
|
||||
$id = $servicioClienteTareaModel->insert([
|
||||
"servicio_cliente_id" => $servicio_cliente_id,
|
||||
"tarifa_acabado_id" => $tarifa_acabado_id
|
||||
]);
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* Asocia tarifa de manipulado a servicio cliente
|
||||
*
|
||||
* @param integer $servicio_cliente_id
|
||||
* @param integer $tarifa_manipulado_id
|
||||
* @return integer
|
||||
*/
|
||||
public function attachTarifaManipulado(int $servicio_cliente_id, int $tarifa_manipulado_id): int
|
||||
{
|
||||
$servicioClienteTareaModel = model(ServicioClienteTareaModel::class);
|
||||
$id = $servicioClienteTareaModel->insert([
|
||||
"servicio_cliente_id" => $servicio_cliente_id,
|
||||
"tarifa_manipulado_id" => $tarifa_manipulado_id
|
||||
]);
|
||||
return $id;
|
||||
}
|
||||
/**
|
||||
* Elimina todas las tarifas asociadas a un servicio cliente
|
||||
*
|
||||
* @param integer $servicio_cliente_id
|
||||
* @return bool
|
||||
*/
|
||||
public function detachTarifas(int $servicio_cliente_id): bool
|
||||
{
|
||||
$servicioClienteTareaModel = model(ServicioClienteTareaModel::class);
|
||||
$s = $servicioClienteTareaModel->where("servicio_cliente_id", $servicio_cliente_id)->delete();
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
53
ci4/app/Models/Configuracion/ServicioClienteTareaModel.php
Normal file
53
ci4/app/Models/Configuracion/ServicioClienteTareaModel.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ServicioClienteTareaModel extends Model
|
||||
{
|
||||
protected $table = 'servicio_cliente_tareas';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"servicio_cliente_id",
|
||||
"tarifa_acabado_id",
|
||||
"tarifa_manipulado_id",
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
<form class="form-control" id="<?= $id ?>" data-id="<?= $model->id ?>">
|
||||
<div class="row mb-2">
|
||||
<!-- Servicio cliente nombre-->
|
||||
<div class="col-xs-12 col-md-6 col-lg-6 mb-2">
|
||||
<label for="servicio-cliente-nombre" class="form-label"><?= @lang("ServicioCliente.datatable.nombre") ?></label>
|
||||
<input type="text" class="form-control" name="nombre" id="servicio-cliente-nombre">
|
||||
</div>
|
||||
<!-- Servicio cliente code-->
|
||||
<div class="col-xs-12 col-md-6 col-lg-6 mb-2">
|
||||
<label for="servicio-cliente-code" class="form-label"><?= @lang("ServicioCliente.datatable.code") ?></label>
|
||||
<input type="text" class="form-control" name="code" id="servicio-cliente-code">
|
||||
|
||||
</div>
|
||||
<!-- Tarifa acabado asociada a servicio -->
|
||||
<div class="col-xs-12 col-md-8 col-lg-6 mb-2" id="container-tarifa-acabado-select">
|
||||
<label for="servicio-cliente-tarifa-acabado" class="form-label"><?= @lang("Tarifaacabado.tarifaacabado") ?></label>
|
||||
<select class="select2 form-select" name="tarifa_acabado_id" id="servicio-cliente-tarifa-acabado" placeholder="<?= @lang("Tarifaacabado.tarifasacabado") ?>">
|
||||
</select>
|
||||
<div class="form-text"><?= @lang("ServicioCliente.infoTarifaAcabado") ?></div>
|
||||
|
||||
</div>
|
||||
<!-- Tarifa manipulado asociada a servicio-->
|
||||
<div class="col-xs-12 col-md-8 col-lg-6 mb-2 d-none" id="container-tarifa-manipulado-select">
|
||||
<label for="servicio-cliente-tarifa-manipulado" class="form-label"><?= @lang("Tarifamanipulado.tarifamanipulado") ?></label>
|
||||
<select class="select2 form-select" name="tarifa_manipulado_id" id="servicio-cliente-tarifa-manipulado" placeholder="<?= @lang("Tarifamanipulado.tarifasmanipulado") ?>">
|
||||
</select>
|
||||
<div class="form-text"><?= @lang("ServicioCliente.infoTarifaManipulado") ?></div>
|
||||
</div>
|
||||
<!-- Check tarifa acabado o manipulado -->
|
||||
<div class="col-xs-12 col-md-4 col-lg-6 mb-2">
|
||||
<div class="text-light small fw-medium mb-2">Seleccione tipo de tarifa</div>
|
||||
<div class="switches-stacked">
|
||||
<label class="switch">
|
||||
<input type="radio" class="switch-input" id="check-tarifa-acabado" name="switches-stacked-radio" checked />
|
||||
<span class="switch-toggle-slider">
|
||||
<span class="switch-on"></span>
|
||||
<span class="switch-off"></span>
|
||||
</span>
|
||||
<span class="switch-label"><?= @lang("Tarifaacabado.tarifasacabado") ?></span>
|
||||
</label>
|
||||
<label class="switch">
|
||||
<input type="radio" class="switch-input" id="check-tarifa-manipulado" name="switches-stacked-radio" />
|
||||
<span class="switch-toggle-slider">
|
||||
<span class="switch-on"></span>
|
||||
<span class="switch-off"></span>
|
||||
</span>
|
||||
<span class="switch-label"><?= @lang("Tarifamanipulado.tarifasmanipulado") ?></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-12 d-flex justify-content-start gap-4">
|
||||
<button type="button" class="btn btn-primary btn-md d-none" id="btn-new-servicio-cliente"><?= lang("App.global_save") ?></button>
|
||||
<button type="button" class="btn btn-primary btn-md d-none" id="btn-update-servicio-cliente"><?= lang("App.global_save") ?></button>
|
||||
<button type="button" class="btn btn-secondary btn-md"><?= lang("App.global_come_back") ?></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
@ -0,0 +1,14 @@
|
||||
|
||||
<table id="<?= $id ?>" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('ServicioCliente.datatable.nombre') ?></th>
|
||||
<th><?= lang('ServicioCliente.datatable.code') ?></th>
|
||||
<th><?= lang('ServicioCliente.datatable.created_at') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@ -0,0 +1,37 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= lang('ServicioCliente.cardTitle') ?></h3>
|
||||
</div>
|
||||
<!--//.card-header -->
|
||||
<div class="card-body" id="serviciosClienteCard">
|
||||
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<?= view('themes/vuexy/components/forms/servicio_cliente', ["id" => "formServicioCliente"]); ?>
|
||||
|
||||
</div>
|
||||
<!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
|
||||
</div>
|
||||
<!--//.card-footer -->
|
||||
</div>
|
||||
<!--//.card -->
|
||||
</div>
|
||||
<!--//.col -->
|
||||
</div>
|
||||
<!--//.row -->
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section("additionalExternalJs") ?>
|
||||
<script type="module" src="<?= site_url("assets/js/safekat/pages/configuracion/servicio_cliente/edit.js") ?>">
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -0,0 +1,37 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= lang('ServicioCliente.cardTitle') ?></h3>
|
||||
</div>
|
||||
<!--//.card-header -->
|
||||
<div class="card-body" id="serviciosClienteCard">
|
||||
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<?= view('themes/vuexy/components/tables/servicios_cliente_table', ["id" => "tableServiciosCliente"]); ?>
|
||||
|
||||
</div>
|
||||
<!--//.card-body -->
|
||||
<div class="card-footer">
|
||||
|
||||
</div>
|
||||
<!--//.card-footer -->
|
||||
</div>
|
||||
<!--//.card -->
|
||||
</div>
|
||||
<!--//.col -->
|
||||
</div>
|
||||
<!--//.row -->
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section("additionalExternalJs") ?>
|
||||
<script type="module" src="<?= site_url("assets/js/safekat/pages/configuracion/servicio_cliente/index.js") ?>">
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -99,6 +99,13 @@ if (
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php if (auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
|
||||
<li class="menu-item">
|
||||
<a href="<?= route_to("servicioClienteList") ?>" class="menu-link">
|
||||
<?= lang("App.menu_servicios_cliente") ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php if (auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
|
||||
<li class="menu-item">
|
||||
<a href="<?= route_to('erroresPresupuestoIndex') ?>" class="menu-link">
|
||||
<?= lang("App.menu_error_presupuesto") ?>
|
||||
|
||||
Reference in New Issue
Block a user