mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Añadidos servicios preimpresion y manipulado
This commit is contained in:
@ -479,7 +479,7 @@ $routes->group('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos
|
||||
});
|
||||
$routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Cosidotapablanda', 'except' => 'show,new,create,update']);
|
||||
|
||||
$routes->group('serviciospresupuesto', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||
$routes->group('serviciosacabados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||
$routes->post('datatable', 'PresupuestoAcabados::datatable', ['as' => 'dataTableOfPresupuestoAcabados']);
|
||||
$routes->post('datatable_editor', 'PresupuestoAcabados::datatable_editor', ['as' => 'editorOfPresupuestoAcabados']);
|
||||
});
|
||||
@ -489,6 +489,16 @@ $routes->group('serviciosencuadernaciones', ['namespace' => 'App\Controllers\Pre
|
||||
$routes->post('datatable_editor', 'PresupuestoEncuadernaciones::datatable_editor', ['as' => 'editorOfPresupuestoEncuadernaciones']);
|
||||
});
|
||||
|
||||
$routes->group('serviciosmanipulados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||
$routes->post('datatable', 'PresupuestoManipulados::datatable', ['as' => 'dataTableOfPresupuestoManipulados']);
|
||||
$routes->post('datatable_editor', 'PresupuestoManipulados::datatable_editor', ['as' => 'editorOfPresupuestoManipulados']);
|
||||
});
|
||||
|
||||
$routes->group('serviciospreimpresiones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||
$routes->post('datatable', 'PresupuestoPreimpresiones::datatable', ['as' => 'dataTableOfPresupuestoPreimpresiones']);
|
||||
$routes->post('datatable_editor', 'PresupuestoPreimpresiones::datatable_editor', ['as' => 'editorOfPresupuestoPreimpresiones']);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
|
||||
@ -711,8 +711,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$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'))])
|
||||
"value" => 0,
|
||||
"label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioPreimpresion'))])
|
||||
));
|
||||
return $data;
|
||||
}
|
||||
@ -722,8 +722,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$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'))])
|
||||
"value" => 0,
|
||||
"label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioEncuadernado'))])
|
||||
));
|
||||
return $data;
|
||||
}
|
||||
@ -744,8 +744,8 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
||||
$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'))])
|
||||
"value" => 0,
|
||||
"label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioManipulado'))])
|
||||
));
|
||||
return $data;
|
||||
}
|
||||
|
||||
131
ci4/app/Controllers/Presupuestos/PresupuestoManipulados.php
Normal file
131
ci4/app/Controllers/Presupuestos/PresupuestoManipulados.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?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\PresupuestoManipuladosModel;
|
||||
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 PresupuestoManipulados extends \App\Controllers\GoBaseResourceController
|
||||
{
|
||||
|
||||
protected $modelName = PresupuestoManipuladosModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Presupuesto manipulado';
|
||||
protected static $singularObjectNameCc = 'presupuestoManipulado';
|
||||
protected static $pluralObjectName = 'Presupuestos manipulado';
|
||||
protected static $pluralObjectNameCc = 'presupuestosManipulado';
|
||||
|
||||
protected static $controllerSlug = 'presupuesto-manipulado';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/presupuestos/';
|
||||
|
||||
protected $indexRoute = 'contactoDeClienteList';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$order = PresupuestoManipuladosModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$id_P = $reqData['id_presupuesto'] ?? -1;
|
||||
|
||||
$resourceData = $this->model->getResource($id_P)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($id_P)->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, 'presupuesto_manipulados' )
|
||||
->fields(
|
||||
Field::inst( 'tarifa_manipulado_id' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Selecciones servicios de acabado' )
|
||||
),
|
||||
Field::inst( 'precio_unidad' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta precio unitario' )
|
||||
),
|
||||
Field::inst( 'precio_total' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta precio total' )
|
||||
),
|
||||
|
||||
Field::inst( 'presupuesto_id' ),
|
||||
|
||||
)
|
||||
->validator( function($editor, $action, $data){
|
||||
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){
|
||||
//return $response;
|
||||
/*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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
125
ci4/app/Controllers/Presupuestos/PresupuestoPreimpresiones.php
Normal file
125
ci4/app/Controllers/Presupuestos/PresupuestoPreimpresiones.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php namespace App\Controllers\Presupuestos;
|
||||
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Models\Presupuestos\PresupuestoPreimpresionesModel;
|
||||
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 PresupuestoPreimpresiones extends \App\Controllers\GoBaseResourceController
|
||||
{
|
||||
|
||||
protected $modelName = PresupuestoPreimpresionesModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Presupuesto preimpresion';
|
||||
protected static $singularObjectNameCc = 'presupuestoPreimpresion';
|
||||
protected static $pluralObjectName = 'Presupuestos preimpresion';
|
||||
protected static $pluralObjectNameCc = 'presupuestosPreimpresion';
|
||||
|
||||
protected static $controllerSlug = 'presupuesto-preimpresiones';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/presupuestos/';
|
||||
|
||||
protected $indexRoute = 'contactoDeClienteList';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$order = PresupuestoPreimpresionesModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$id_P = $reqData['id_presupuesto'] ?? -1;
|
||||
|
||||
$resourceData = $this->model->getResource($id_P)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($id_P)->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, 'presupuesto_preimpresiones' )
|
||||
->fields(
|
||||
Field::inst( 'tarifa_preimpresion_id' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Selecciones servicios de acabado' )
|
||||
),
|
||||
Field::inst( 'precio_unidad' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta precio unitario' )
|
||||
),
|
||||
Field::inst( 'precio_total' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => 'Falta precio total' )
|
||||
),
|
||||
|
||||
Field::inst( 'presupuesto_id' ),
|
||||
|
||||
)
|
||||
->validator( function($editor, $action, $data){
|
||||
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){
|
||||
//return $response;
|
||||
/*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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
68
ci4/app/Models/Presupuestos/PresupuestoManipuladosModel.php
Normal file
68
ci4/app/Models/Presupuestos/PresupuestoManipuladosModel.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Presupuestos;
|
||||
|
||||
class PresupuestoManipuladosModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "presupuesto_manipulados";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t2.nombre",
|
||||
1 => "t1.precio_unidad",
|
||||
2 => "t1.precio_total"
|
||||
];
|
||||
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_manipulado_id", "nombre", "precio_total", "precio_unidad"];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoManipuladosEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"precio_total" => [
|
||||
"label" => "Presupuestos.precioTotal",
|
||||
"rules" => "decimal|required",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"precio_total" => [
|
||||
"decimal" => "Presupuestos.validation.decimal",
|
||||
"requerido" => "Presupuestos.validation.decimal",
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource($presupuesto_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.tarifa_manipulado_id AS tarifa_manipulado_id, t1.precio_unidad AS precio_unidad, t1.precio_total AS precio_total, t2.nombre AS nombre"
|
||||
);
|
||||
|
||||
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
||||
$builder->join("lg_tarifa_manipulado t2", "t1.tarifa_manipulado_id = t2.id", "left");
|
||||
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Presupuestos;
|
||||
|
||||
class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "presupuesto_preimpresiones";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t2.nombre",
|
||||
1 => "t1.precio_unidad",
|
||||
2 => "t1.precio_total"
|
||||
];
|
||||
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_preimpresion_id", "nombre", "precio_total", "precio_unidad"];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoPreimpresionesEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"precio_total" => [
|
||||
"label" => "Presupuestos.precioTotal",
|
||||
"rules" => "decimal|required",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"precio_total" => [
|
||||
"decimal" => "Presupuestos.validation.decimal",
|
||||
"requerido" => "Presupuestos.validation.decimal",
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource($presupuesto_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.precio_unidad AS precio_unidad, t1.precio_total AS precio_total, t2.nombre AS nombre"
|
||||
);
|
||||
|
||||
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
||||
$builder->join("lg_tarifa_preimpresion t2", "t1.tarifa_preimpresion_id = t2.id", "left");
|
||||
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
@ -103,7 +103,7 @@ class TarifaEncuadernacionModel extends \App\Models\GoBaseModel
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id as id, t1.nombre AS nombre"
|
||||
"t1.id as value, t1.nombre AS label"
|
||||
)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.mostrar_en_presupuesto", 1);
|
||||
|
||||
@ -102,7 +102,7 @@ class TarifaManipuladoModel extends \App\Models\GoBaseModel
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id as id, t1.nombre AS nombre"
|
||||
"t1.id as value, t1.nombre AS label"
|
||||
)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.mostrar_en_presupuesto", 1);
|
||||
|
||||
@ -88,7 +88,7 @@ class TarifapreimpresionModel extends \App\Models\GoBaseModel
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id as id, t1.nombre AS nombre"
|
||||
"t1.id as value, t1.nombre AS label"
|
||||
)
|
||||
->where("t1.is_deleted", 0)
|
||||
->where("t1.mostrar_en_presupuesto", 1);
|
||||
|
||||
@ -79,14 +79,25 @@
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="servicios-preimpresion" role="tabpanel">
|
||||
<h3>Proximanente</h3>
|
||||
<table id="tableOfServiciosPreimpresion" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Tarifapreimpresion.tarifapreimpresion') ?></th>
|
||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="servicios-encuadernacion" role="tabpanel">
|
||||
<table id="tableOfServiciosEncuadernacion" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Tarifaencuadernacion.tarifaaencuadernacion') ?></th>
|
||||
<th><?= lang('Tarifaencuadernacion.tarifaencuadernacion') ?></th>
|
||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
@ -98,7 +109,18 @@
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="servicios-manipulado" role="tabpanel">
|
||||
<h3>Proximanente</h3>
|
||||
<table id="tableOfServiciosManipulado" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Tarifamanipulado.tarifamanipulado') ?></th>
|
||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
@ -196,33 +218,27 @@
|
||||
);
|
||||
} );
|
||||
|
||||
|
||||
// Delete row
|
||||
$('#tableOfServiciosAcabado').on( 'click', 'tbody span.remove', function (e) {
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||
});
|
||||
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Basic.global.sweet.line'))]) ?>',
|
||||
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||
cancelButtonColor: '#d33'
|
||||
})
|
||||
.then((result) => {
|
||||
const dataId = $(this).data('id');
|
||||
const row = $(this).closest('tr');
|
||||
if (result.value) {
|
||||
editor
|
||||
.create( false )
|
||||
.edit( this.parentNode, false)
|
||||
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
|
||||
.set( 'is_deleted', 1 )
|
||||
.submit();
|
||||
|
||||
}
|
||||
});
|
||||
$(document).on('click', '.btn-remove', function(e) {
|
||||
const dataId = $(this).attr('data-id');
|
||||
const row = $(this).closest('tr');
|
||||
if ($.isNumeric(dataId)) {
|
||||
$.ajax({
|
||||
url: `/presupuestos/presupuestoacabados/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
$('#confirm2delete').modal('toggle');
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
var theTable = $('#tableOfServiciosAcabado').DataTable( {
|
||||
@ -289,14 +305,14 @@
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<!------------------------------------------------------->
|
||||
<!-- Código JS comportamiento tabla servicios acabado. -->
|
||||
<!------------------------------------------------------->
|
||||
<!-------------------------------------------------------------->
|
||||
<!-- Código JS comportamiento tabla servicios encuadernacion. -->
|
||||
<!-------------------------------------------------------------->
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
const lastColNr2 = $('#tableOfServiciosEncuadernacion').find("tr:first th").length - 1;
|
||||
|
||||
editor = new $.fn.dataTable.Editor( {
|
||||
editor2 = new $.fn.dataTable.Editor( {
|
||||
ajax: {
|
||||
url: "<?= route_to('editorOfPresupuestoEncuadernaciones') ?>",
|
||||
headers: {
|
||||
@ -321,9 +337,9 @@
|
||||
|
||||
// Generación de la lista de servicios de acabado (id, nombre)
|
||||
const encuadernadosList = <?php echo json_encode($serviciosEncuadernacion); ?>;
|
||||
editor.field( 'tarifa_encuadernado_id' ).update( encuadernadosList );
|
||||
editor2.field( 'tarifa_encuadernado_id' ).update( encuadernadosList );
|
||||
|
||||
editor.on( 'preSubmit', function ( e, d, type ) {
|
||||
editor2.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['presupuesto_id'] = id;
|
||||
}
|
||||
@ -334,19 +350,19 @@
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
editor2.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
yeniden(json.<?= csrf_token() ?>);
|
||||
});
|
||||
|
||||
editor.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
theTable.clearPipeline();
|
||||
theTable.draw();
|
||||
editor2.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
theTable2.clearPipeline();
|
||||
theTable2.draw();
|
||||
});
|
||||
|
||||
// Activate an inline edit on click of a table cell
|
||||
$('#tableOfServiciosEncuadernacion').on( 'click', 'tbody span.edit', function (e) {
|
||||
editor.inline(
|
||||
theTable.cells(this.parentNode.parentNode, '*').nodes(),
|
||||
editor2.inline(
|
||||
theTable2.cells(this.parentNode.parentNode, '*').nodes(),
|
||||
{
|
||||
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
|
||||
cancelTrigger: 'span.cancel',
|
||||
@ -358,35 +374,7 @@
|
||||
} );
|
||||
|
||||
|
||||
// Delete row
|
||||
$('#tableOfServiciosEncuadernacion').on( 'click', 'tbody span.remove', function (e) {
|
||||
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Basic.global.sweet.line'))]) ?>',
|
||||
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
|
||||
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||
cancelButtonColor: '#d33'
|
||||
})
|
||||
.then((result) => {
|
||||
const dataId = $(this).data('id');
|
||||
const row = $(this).closest('tr');
|
||||
if (result.value) {
|
||||
editor
|
||||
.create( false )
|
||||
.edit( this.parentNode, false)
|
||||
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
|
||||
.set( 'is_deleted', 1 )
|
||||
.submit();
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var theTable = $('#tableOfServiciosEncuadernacion').DataTable( {
|
||||
var theTable2 = $('#tableOfServiciosEncuadernacion').DataTable( {
|
||||
serverSide: true,
|
||||
processing: true,
|
||||
autoWidth: true,
|
||||
@ -440,7 +428,280 @@
|
||||
buttons: [ {
|
||||
className: 'btn btn-primary float-end me-sm-3 me-1',
|
||||
extend: "createInline",
|
||||
editor: editor,
|
||||
editor: editor2,
|
||||
formOptions: {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<i class="ti ti-device-floppy"/>'
|
||||
}
|
||||
} ]
|
||||
} );
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<!-------------------------------------------------------------->
|
||||
<!-- Código JS comportamiento tabla servicios manipulados. -->
|
||||
<!-------------------------------------------------------------->
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
const lastColNr3 = $('#tableOfServiciosManipulado').find("tr:first th").length - 1;
|
||||
|
||||
editor3 = new $.fn.dataTable.Editor( {
|
||||
ajax: {
|
||||
url: "<?= route_to('editorOfPresupuestoManipulados') ?>",
|
||||
headers: {
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
||||
},
|
||||
},
|
||||
table : "#tableOfServiciosManipulado",
|
||||
idSrc: 'id',
|
||||
fields: [ {
|
||||
"name": "tarifa_manipulado_id",
|
||||
"type": "select"
|
||||
}, {
|
||||
"name": "precio_unidad"
|
||||
}, {
|
||||
"name": "precio_total"
|
||||
}, {
|
||||
"name": "presupuesto_id",
|
||||
"type": "hidden"
|
||||
},
|
||||
]
|
||||
} );
|
||||
|
||||
// Generación de la lista de servicios de acabado (id, nombre)
|
||||
const manipuladosList = <?php echo json_encode($serviciosManipulado); ?>;
|
||||
editor3.field( 'tarifa_manipulado_id' ).update( manipuladosList );
|
||||
|
||||
editor3.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['presupuesto_id'] = id;
|
||||
}
|
||||
else if(type === 'edit' ) {
|
||||
for (v in d.data){
|
||||
d.data[v]['presupuesto_id'] = id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor3.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
yeniden(json.<?= csrf_token() ?>);
|
||||
});
|
||||
|
||||
editor3.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
theTable3.clearPipeline();
|
||||
theTable3.draw();
|
||||
});
|
||||
|
||||
// Activate an inline edit on click of a table cell
|
||||
$('#tableOfServiciosManipulado').on( 'click', 'tbody span.edit', function (e) {
|
||||
editor3.inline(
|
||||
theTable3.cells(this.parentNode.parentNode, '*').nodes(),
|
||||
{
|
||||
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
|
||||
cancelTrigger: 'span.cancel',
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||
submitTrigger: 'span.edit',
|
||||
submit: 'allIfChanged'
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
|
||||
// Delete row
|
||||
|
||||
|
||||
var theTable3 = $('#tableOfServiciosManipulado').DataTable( {
|
||||
serverSide: true,
|
||||
processing: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
lengthMenu: [ 5, 10, 25],
|
||||
order: [[ 0, "asc" ], [ 1, "asc" ]],
|
||||
pageLength: 10,
|
||||
lengthChange: true,
|
||||
searching: false,
|
||||
paging: true,
|
||||
info: false,
|
||||
dom: '<"mt-4"><"float-start"l><t><"mt-4 mb-3"p>',
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('dataTableOfPresupuestoManipulados') ?>',
|
||||
data: {
|
||||
id_presupuesto: id,
|
||||
},
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columns: [
|
||||
{'data': 'tarifa_manipulado_id',
|
||||
render: function(data, type, row, meta) {
|
||||
var value = manipuladosList.find(element => element.value === data);
|
||||
return value['label'];
|
||||
},
|
||||
},
|
||||
{ 'data': 'precio_unidad' },
|
||||
{ 'data': 'precio_total' },
|
||||
{
|
||||
data: actionBtns,
|
||||
className: 'row-edit dt-center'
|
||||
}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr3]
|
||||
},
|
||||
{
|
||||
"orderData": [ 0, 1 ],
|
||||
"targets": 0
|
||||
},
|
||||
|
||||
],
|
||||
language: {
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
buttons: [ {
|
||||
className: 'btn btn-primary float-end me-sm-3 me-1',
|
||||
extend: "createInline",
|
||||
editor: editor3,
|
||||
formOptions: {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<i class="ti ti-device-floppy"/>'
|
||||
}
|
||||
} ]
|
||||
} );
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<!-------------------------------------------------------------->
|
||||
<!-- Código JS comportamiento tabla servicios preimpresion. -->
|
||||
<!-------------------------------------------------------------->
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
const lastColNr4 = $('#tableOfServiciosPreimpresion').find("tr:first th").length - 1;
|
||||
|
||||
editor4 = new $.fn.dataTable.Editor( {
|
||||
ajax: {
|
||||
url: "<?= route_to('editorOfPresupuestoPreimpresiones') ?>",
|
||||
headers: {
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
||||
},
|
||||
},
|
||||
table : "#tableOfServiciosPreimpresion",
|
||||
idSrc: 'id',
|
||||
fields: [ {
|
||||
"name": "tarifa_preimpresion_id",
|
||||
"type": "select"
|
||||
}, {
|
||||
"name": "precio_unidad"
|
||||
}, {
|
||||
"name": "precio_total"
|
||||
}, {
|
||||
"name": "presupuesto_id",
|
||||
"type": "hidden"
|
||||
},
|
||||
]
|
||||
} );
|
||||
|
||||
// Generación de la lista de servicios de acabado (id, nombre)
|
||||
const preimpresionesList = <?php echo json_encode($serviciosPreimpresion); ?>;
|
||||
editor4.field( 'tarifa_preimpresion_id' ).update( preimpresionesList );
|
||||
|
||||
editor4.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['presupuesto_id'] = id;
|
||||
}
|
||||
else if(type === 'edit' ) {
|
||||
for (v in d.data){
|
||||
d.data[v]['presupuesto_id'] = id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor4.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
yeniden(json.<?= csrf_token() ?>);
|
||||
});
|
||||
|
||||
editor4.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
theTable4.clearPipeline();
|
||||
theTable4.draw();
|
||||
});
|
||||
|
||||
// Activate an inline edit on click of a table cell
|
||||
$('#tableOfServiciosPreimpresion').on( 'click', 'tbody span.edit', function (e) {
|
||||
editor4.inline(
|
||||
theTable4.cells(this.parentNode.parentNode, '*').nodes(),
|
||||
{
|
||||
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
|
||||
cancelTrigger: 'span.cancel',
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||
submitTrigger: 'span.edit',
|
||||
submit: 'allIfChanged'
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
|
||||
// Delete row
|
||||
|
||||
|
||||
var theTable4 = $('#tableOfServiciosPreimpresion').DataTable( {
|
||||
serverSide: true,
|
||||
processing: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
lengthMenu: [ 5, 10, 25],
|
||||
order: [[ 0, "asc" ], [ 1, "asc" ]],
|
||||
pageLength: 10,
|
||||
lengthChange: true,
|
||||
searching: false,
|
||||
paging: true,
|
||||
info: false,
|
||||
dom: '<"mt-4"><"float-start"l><t><"mt-4 mb-3"p>',
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('dataTableOfPresupuestoPreimpresiones') ?>',
|
||||
data: {
|
||||
id_presupuesto: id,
|
||||
},
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columns: [
|
||||
{'data': 'tarifa_preimpresion_id',
|
||||
render: function(data, type, row, meta) {
|
||||
var value = preimpresionesList.find(element => element.value === data);
|
||||
return value['label'];
|
||||
},
|
||||
},
|
||||
{ 'data': 'precio_unidad' },
|
||||
{ 'data': 'precio_total' },
|
||||
{
|
||||
data: actionBtns,
|
||||
className: 'row-edit dt-center'
|
||||
}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr4]
|
||||
},
|
||||
{
|
||||
"orderData": [ 0, 1 ],
|
||||
"targets": 0
|
||||
},
|
||||
|
||||
],
|
||||
language: {
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
buttons: [ {
|
||||
className: 'btn btn-primary float-end me-sm-3 me-1',
|
||||
extend: "createInline",
|
||||
editor: editor4,
|
||||
formOptions: {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<i class="ti ti-device-floppy"/>'
|
||||
|
||||
Reference in New Issue
Block a user