mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
tarifas acabado a falta de check duplicados y guardar tarifa acabado
This commit is contained in:
@ -192,6 +192,20 @@ $routes->group('papelimpresiontipologias', ['namespace' => 'App\Controllers\Conf
|
||||
$routes->get('delete/(:num)', 'Papelimpresiontipologias::delete/$1', ['as' => 'deletePapelImpresionTipologia']);
|
||||
});
|
||||
|
||||
$routes->group('tarifaacabadolineas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
|
||||
$routes->get('', 'Tarifaacabadolineas::index', ['as' => 'tarifaAcabadoLineaList']);
|
||||
$routes->get('add', 'Tarifaacabadolineas::add', ['as' => 'newTarifaAcabadoLinea']);
|
||||
$routes->post('add', 'Tarifaacabadolineas::add', ['as' => 'createTarifaAcabadoLinea']);
|
||||
$routes->post('create', 'Tarifaacabadolineas::create', ['as' => 'ajaxCreateTarifaAcabadoLinea']);
|
||||
$routes->put('(:num)/update', 'Tarifaacabadolineas::update/$1', ['as' => 'ajaxUpdateTarifaAcabadoLinea']);
|
||||
$routes->post('(:num)/edit', 'Tarifaacabadolineas::edit/$1', ['as' => 'updateTarifaAcabadoLinea']);
|
||||
$routes->post('datatable', 'Tarifaacabadolineas::datatable', ['as' => 'dataTableOfTarifaAcabadoLineas']);
|
||||
$routes->post('datatable_editor', 'Tarifaacabadolineas::datatable_editor', ['as' => 'editorOfTarifaAcabadoLineas']);
|
||||
$routes->post('allmenuitems', 'Tarifaacabadolineas::allItemsSelect', ['as' => 'select2ItemsOfTarifaAcabadoLineas']);
|
||||
$routes->post('menuitems', 'Tarifaacabadolineas::menuItems', ['as' => 'menuItemsOfTarifaAcabadoLineas']);
|
||||
$routes->get('delete/(:num)', 'Tarifaacabadolineas::delete/$1', ['as' => 'deleteTarifaAcabadoLinea']);
|
||||
});
|
||||
$routes->resource('tarifaacabadolineas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifaacabadolineas', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
$routes->group('profile', ['namespace' => 'App\Controllers'], function ($routes) {
|
||||
|
||||
@ -286,12 +286,12 @@ class Papelimpresiontipologias extends \App\Controllers\GoBaseResourceController
|
||||
array_unshift($menu , $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName = csrf_token();
|
||||
$output = array(
|
||||
'success' => 'yes',
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
);
|
||||
return json_encode($output);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
|
||||
@ -30,6 +30,13 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController {
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('Tarifaacabado.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
// Se indica que este controlador trabaja con soft_delete
|
||||
$this->soft_delete = true;
|
||||
// Se indica el flag para los ficheros borrados
|
||||
$this->delete_flag = 1;
|
||||
|
||||
$this->viewData = ['usingServerSideDataTable' => true];
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
@ -52,7 +59,8 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
public function add() {
|
||||
|
||||
|
||||
// JJO
|
||||
$session = session();
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
@ -64,6 +72,10 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
if(isset($this->model->user_update_id)){
|
||||
$sanitizedData['user_created_id'] = $session->id_user;
|
||||
}
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
@ -116,6 +128,9 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController {
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
// JJO
|
||||
$session = session();
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
@ -136,15 +151,18 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
if(isset($this->model->user_update_id)){
|
||||
$sanitizedData['user_update_id'] = $session->id_user;
|
||||
}
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
|
||||
@ -11,6 +11,17 @@ use App\Models\tarifas\TarifaacabadoModel;
|
||||
|
||||
use App\Models\Tarifas\TarifaAcabadoLineaModel;
|
||||
|
||||
use
|
||||
DataTables\Editor,
|
||||
DataTables\Database,
|
||||
DataTables\Editor\Field,
|
||||
DataTables\Editor\Format,
|
||||
DataTables\Editor\Mjoin,
|
||||
DataTables\Editor\Options,
|
||||
DataTables\Editor\Upload,
|
||||
DataTables\Editor\Validate,
|
||||
DataTables\Editor\ValidateOptions;
|
||||
|
||||
class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected $modelName = TarifaAcabadoLineaModel::class;
|
||||
@ -205,25 +216,124 @@ class Tarifaacabadolineas extends \App\Controllers\GoBaseResourceController {
|
||||
$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 = TarifaAcabadoLineaModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
||||
$order = TarifaAcabadoLineaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
$id_TA = $reqData['id_tarifaacabado'] ?? -1;
|
||||
|
||||
|
||||
$resourceData = $this->model->getResource("", $id_TA)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
$this->model->getResource($search, $id_TA)->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, 'tarifa_acabado_lineas' )
|
||||
->fields(
|
||||
Field::inst( 'tirada_min' )
|
||||
->validator( 'Validate::numeric', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.tirada_min.decimal') )
|
||||
)
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.tirada_min.required') )
|
||||
),
|
||||
Field::inst( 'tirada_max' )
|
||||
->validator( 'Validate::numeric', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.tirada_max.decimal') )
|
||||
)
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.tirada_max.required') )
|
||||
),
|
||||
Field::inst( 'precio_min' )
|
||||
->validator( 'Validate::numeric', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.decimal') )
|
||||
)
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_min.required') )
|
||||
),
|
||||
Field::inst( 'precio_max' )
|
||||
->validator( 'Validate::numeric', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_max.decimal') )
|
||||
)
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_max.required') )
|
||||
),
|
||||
Field::inst( 'precio_unidad' )
|
||||
->validator( 'Validate::numeric', array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_unidad.decimal') )
|
||||
)
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('TarifaAcabadoLineas.validation.precio_unidad.required') )
|
||||
),
|
||||
Field::inst( 'tarifa_acabado_id' ),
|
||||
Field::inst( 'user_created_id' ),
|
||||
Field::inst( 'created_at' ),
|
||||
Field::inst( 'user_updated_id' ),
|
||||
Field::inst( 'updated_at' ),
|
||||
Field::inst( 'is_deleted' ),
|
||||
Field::inst( 'deleted_at' ),
|
||||
|
||||
)
|
||||
->on( 'preCreate', function ( $editor, &$values ) {
|
||||
$session = session();
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
$editor
|
||||
->field( 'user_created_id' )
|
||||
->setValue( $session->id_user );
|
||||
$editor
|
||||
->field( 'created_at' )
|
||||
->setValue( $datetime->format('Y-m-d H:i:s') );
|
||||
} )
|
||||
->on( 'preEdit', function ( $editor, &$values ) {
|
||||
$session = session();
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
$editor
|
||||
->field( 'user_updated_id' )
|
||||
->setValue( $session->id_user );
|
||||
$editor
|
||||
->field( 'updated_at' )
|
||||
->setValue( $datetime->format('Y-m-d H:i:s') );
|
||||
} )
|
||||
->debug(true)
|
||||
->process( $_POST )
|
||||
->data();
|
||||
|
||||
if(isset($response['error'])){
|
||||
if(str_contains($response['error'], "tirada_min_tirada_max") &&
|
||||
str_contains($response['error'], "Duplicate entry ")){
|
||||
$response['error'] = lang('TarifaAcabadoLineas.validation.duplicated_tirada');
|
||||
}
|
||||
}
|
||||
$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;
|
||||
|
||||
@ -41,7 +41,8 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
|
||||
|
||||
public function add() {
|
||||
|
||||
|
||||
// JJO
|
||||
$session = session();
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
@ -52,6 +53,10 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
|
||||
$postData = $this->request->getPost();
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
if(isset($this->model->user_update_id)){
|
||||
$sanitizedData['user_created_id'] = $session->id_user;
|
||||
}
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
@ -8,8 +8,8 @@ class TarifaacabadoEntity extends \CodeIgniter\Entity\Entity
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"nombre" => null,
|
||||
"user_created_id" => 1,
|
||||
"user_update_id" => 1,
|
||||
"user_created_id" => 0,
|
||||
"user_update_id" => 0,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
|
||||
@ -79,7 +79,8 @@ return [
|
||||
'sureToDeleteTitle' => 'Are you sure you want to delete this {0}?',
|
||||
'text' => 'This action cannot be undone.',
|
||||
'title' => 'Are you sure?',
|
||||
'maxRowsReached' => 'No more lines can be added.'
|
||||
'maxRowsReached' => 'No more lines can be added.',
|
||||
'line' => 'the line'
|
||||
],
|
||||
'ok' => 'Ok',
|
||||
'wait' => 'Wait',
|
||||
|
||||
51
ci4/app/Language/en/TarifaAcabadoLineas.php
Normal file
51
ci4/app/Language/en/TarifaAcabadoLineas.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Finish rates Lines',
|
||||
'deleteLine' => 'the selected register',
|
||||
'precioMax' => 'Max Price',
|
||||
'precioMin' => 'Min Price',
|
||||
'precioUnidad' => 'Price Unit',
|
||||
'tiradaMax' => 'Print Max',
|
||||
'tiradaMin' => 'Print Min',
|
||||
'validation' => [
|
||||
'duplicated_tirada' => "Duplicated line (the couple 'Print Min' and 'Print Max' must be unique)",
|
||||
'precio_max' => [
|
||||
'decimal' => 'The field must contain a decimal number.',
|
||||
'required' => 'The field is required.',
|
||||
|
||||
],
|
||||
|
||||
'precio_min' => [
|
||||
'decimal' => 'The field must contain a decimal number.',
|
||||
'required' => 'The field is required.',
|
||||
|
||||
],
|
||||
|
||||
'precio_unidad' => [
|
||||
'decimal' => 'The field must contain a decimal number.',
|
||||
'required' => 'The field is required.',
|
||||
|
||||
],
|
||||
|
||||
'tirada_max' => [
|
||||
'integer' => 'The field must contain an integer.',
|
||||
'required' => 'The field is required.',
|
||||
|
||||
],
|
||||
|
||||
'tirada_min' => [
|
||||
'integer' => 'The field must contain an integer.',
|
||||
'required' => 'The field is required.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
@ -79,7 +79,8 @@ return [
|
||||
'sureToDeleteTitle' => 'Está seguro de borrar {0}?',
|
||||
'text' => 'Esta acción no se puede deshacer.',
|
||||
'title' => 'Está seguro?',
|
||||
'maxRowsReached' => 'No se pueden añadir más líneas.'
|
||||
'maxRowsReached' => 'No se pueden añadir más líneas.',
|
||||
'line' => 'la línea'
|
||||
|
||||
],
|
||||
'ok' => 'Ok',
|
||||
|
||||
50
ci4/app/Language/es/TarifaAcabadoLineas.php
Normal file
50
ci4/app/Language/es/TarifaAcabadoLineas.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Tarifa Acabado Lineas',
|
||||
'deleteLine' => 'el registro seleccionado',
|
||||
'precioMax' => 'Precio Max',
|
||||
'precioMin' => 'Precio Min',
|
||||
'precioUnidad' => 'Precio Unidad',
|
||||
'tiradaMax' => 'Tirada Max',
|
||||
'tiradaMin' => 'Tirada Min',
|
||||
'validation' => [
|
||||
'duplicated_tirada' => "Línea duplicada (la pareja 'Tirada Min' y 'Tirada Max' debe de ser única)",
|
||||
'precio_max' => [
|
||||
'decimal' => 'El campo debe contener un número decimal.',
|
||||
'required' => 'El campo es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
'precio_min' => [
|
||||
'decimal' => 'El campo debe contener un número decimal.',
|
||||
'required' => 'El campo es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
'precio_unidad' => [
|
||||
'decimal' => 'El campo debe contener un número decimal.',
|
||||
'required' => 'El campo es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
'tirada_max' => [
|
||||
'integer' => 'El campo debe contener un número entero.',
|
||||
'required' => 'El campo es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
'tirada_min' => [
|
||||
'integer' => 'El campo debe contener un número entero.',
|
||||
'required' => 'El campo es obligatorio.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
@ -13,17 +13,11 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.tirada_min",
|
||||
2 => "t1.tirada_max",
|
||||
3 => "t1.precio_min",
|
||||
4 => "t1.precio_max",
|
||||
5 => "t1.precio_unidad",
|
||||
6 => "t1.user_created_id",
|
||||
7 => "t1.user_updated_id",
|
||||
8 => "t1.is_deleted",
|
||||
9 => "t1.created_at",
|
||||
10 => "t1.updated_at",
|
||||
11 => "t2.id",
|
||||
0 => "t1.tirada_min",
|
||||
1 => "t1.tirada_max",
|
||||
2 => "t1.precio_min",
|
||||
3 => "t1.precio_max",
|
||||
4 => "t1.precio_unidad",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
@ -136,15 +130,24 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
public function getResource(string $search = "", $tarifa_acabado_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.precio_unidad AS precio_unidad, t1.user_created_id AS user_created_id, t1.user_updated_id AS user_updated_id, t1.is_deleted AS is_deleted, t1.created_at AS created_at, t1.updated_at AS updated_at, t2.id AS tarifa_acabado"
|
||||
"t1.id AS id, t1.tirada_min AS tirada_min, t1.tirada_max AS tirada_max, t1.precio_min AS precio_min, t1.precio_max AS precio_max, t1.precio_unidad AS precio_unidad, t1.user_created_id AS user_created_id, t1.user_updated_id AS user_updated_id, t1.is_deleted AS is_deleted, t1.created_at AS created_at, t1.updated_at AS updated_at, t2.id AS tarifa_acabado"
|
||||
);
|
||||
|
||||
if($tarifa_acabado_id>=0)
|
||||
{
|
||||
$builder->where('tarifa_acabado_id', $tarifa_acabado_id);
|
||||
}
|
||||
|
||||
$builder->join("lg_tarifa_acabado t2", "t1.tarifa_acabado_id = t2.id", "left");
|
||||
|
||||
//JJO
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
@ -173,4 +176,16 @@ class TarifaAcabadoLineaModel extends \App\Models\GoBaseModel
|
||||
->orLike("t2.id", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function findLineasForTarifaAcabado(int $tarifaacabado_id){
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table )
|
||||
->select("*")
|
||||
->where("tarifa_acabado_id", $tarifaacabado_id);
|
||||
|
||||
|
||||
return $builder;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,13 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel
|
||||
0 => "t1.nombre",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre"];
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
"user_created_id",
|
||||
"user_update_id",
|
||||
];
|
||||
protected $returnType = 'App\Entities\Tarifas\TarifaacabadoEntity';
|
||||
|
||||
protected $useTimestamps = true;
|
||||
@ -53,6 +59,9 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
$builder = $this->db->table($this->table . " t1")->select("t1.id AS id, t1.nombre AS nombre");
|
||||
|
||||
//JJO
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
|
||||
@ -10,11 +10,11 @@ ini_set('display_errors', '1');
|
||||
*/
|
||||
$sql_details = array(
|
||||
"type" => "Mysql", // Database type: "Mysql", "Postgres", "Sqlserver", "Sqlite" or "Oracle"
|
||||
"user" => "sk-misc", // Database user name
|
||||
"pass" => "Itd27y^86", // Database password
|
||||
"user" => "sk_jjo", // Database user name
|
||||
"pass" => "61tv&G1Zf^XY", // Database password
|
||||
"host" => "localhost", // Database host
|
||||
"port" => "", // Database connection port (can be left empty for default)
|
||||
"db" => "sk-misc", // Database name
|
||||
"db" => "sk_jjo", // Database name
|
||||
"dsn" => "", // PHP DSN extra information. Set as `charset=utf8mb4` if you are using MySQL
|
||||
"pdoAttr" => array() // PHP PDO attributes array. See the PHP documentation for all options
|
||||
);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
|
||||
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
@ -10,22 +11,262 @@
|
||||
</div><!--//.card-header -->
|
||||
<form id="tarifaAcabadoForm" method="post" action="<?= $formAction ?>">
|
||||
<?= csrf_field() ?>
|
||||
<div class="card-body">
|
||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||
<?= view("themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="card-footer">
|
||||
<input type="submit"
|
||||
class="btn btn-primary float-start me-sm-3 me-1"
|
||||
name="save"
|
||||
value="<?= lang("Basic.global.Save") ?>"
|
||||
/>
|
||||
<?= anchor(route_to("tarifaAcabadoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
|
||||
|
||||
</div><!-- /.card-footer -->
|
||||
<div class="card-body">
|
||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||
<?= view("themes/backend/vuexy/form/tarifas/acabado/_tarifaAcabadoFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="card-footer">
|
||||
<input type="submit"
|
||||
class="btn btn-primary float-start me-sm-3 me-1"
|
||||
name="save"
|
||||
value="<?= lang("Basic.global.Save") ?>"
|
||||
/>
|
||||
<?= anchor(route_to("tarifaAcabadoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
|
||||
</div><!-- /.card-footer -->
|
||||
</form>
|
||||
</div><!-- //.card -->
|
||||
</div><!-- //.card -->
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
<div class="accordion mt-3" id="accordionAcabadoLineas">
|
||||
<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="#accordionTip1" aria-expanded="false" aria-controls="accordionTip1">
|
||||
<p><?= lang("TarifaAcabadoLineas.moduleTitle") ?></p>
|
||||
</button>
|
||||
|
||||
</h2>
|
||||
|
||||
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionAcabadoLineas">
|
||||
<div class="accordion-body">
|
||||
|
||||
<table id="tableOfTarifaacabadolineas" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('TarifaAcabadoLineas.tiradaMin') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.tiradaMax') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.precioMin') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.precioMax') ?></th>
|
||||
<th><?= lang('TarifaAcabadoLineas.precioUnidad') ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- //.accordion -->
|
||||
|
||||
</div><!--//.row -->
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
const lastColNr = $('#tableOfTarifasacabado').find("tr:first th").length - 1;
|
||||
const url = window.location.href;
|
||||
const url_parts = url.split('/');
|
||||
if(url_parts[url_parts.length-2] == 'edit'){
|
||||
id = url_parts[url_parts.length-1];
|
||||
}
|
||||
else{
|
||||
id = -1;
|
||||
}
|
||||
|
||||
const actionBtns = function(data) {
|
||||
return `
|
||||
<span class="edit"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></span>
|
||||
<span class="cancel"></span>
|
||||
<span class="remove"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i></span>
|
||||
`;
|
||||
};
|
||||
|
||||
|
||||
editor = new $.fn.dataTable.Editor( {
|
||||
ajax: {
|
||||
url: "<?= route_to('editorOfTarifaAcabadoLineas') ?>",
|
||||
headers: {
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
||||
},
|
||||
},
|
||||
table : "#tableOfTarifaacabadolineas",
|
||||
idSrc: 'id',
|
||||
fields: [ {
|
||||
name: "tirada_min"
|
||||
}, {
|
||||
name: "tirada_max"
|
||||
}, {
|
||||
name: "precio_min"
|
||||
}, {
|
||||
name: "precio_max"
|
||||
}, {
|
||||
name: "precio_unidad"
|
||||
},{
|
||||
"name": "tarifa_acabado_id",
|
||||
"type": "hidden"
|
||||
},{
|
||||
"name": "deleted_at",
|
||||
"type": "hidden"
|
||||
},{
|
||||
"name": "is_deleted",
|
||||
"type": "hidden"
|
||||
},
|
||||
]
|
||||
} );
|
||||
|
||||
editor.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['tarifa_acabado_id'] = id;
|
||||
}
|
||||
else if(type === 'edit' ) {
|
||||
for (v in d.data){
|
||||
d.data[v]['tarifa_acabado_id'] = id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
editor.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
|
||||
yeniden(json.<?= csrf_token() ?>);
|
||||
});
|
||||
|
||||
editor.on( 'submitComplete', function ( e, json, data, action ) {
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.draw();
|
||||
});
|
||||
|
||||
|
||||
var theTable = $('#tableOfTarifaacabadolineas').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: "Bltp",
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('dataTableOfTarifaAcabadoLineas') ?>',
|
||||
data: {
|
||||
id_tarifaacabado: id,
|
||||
},
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columns: [
|
||||
{ 'data': 'tirada_min' },
|
||||
{ 'data': 'tirada_max' },
|
||||
{ 'data': 'precio_min' },
|
||||
{ 'data': 'precio_max' },
|
||||
{ 'data': 'precio_unidad' },
|
||||
{
|
||||
data: actionBtns,
|
||||
className: 'row-edit dt-center'
|
||||
}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr]
|
||||
}
|
||||
],
|
||||
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: editor,
|
||||
formOptions: {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<i class="ti ti-device-floppy"/>'
|
||||
}
|
||||
} ]
|
||||
} );
|
||||
|
||||
|
||||
|
||||
// Activate an inline edit on click of a table cell
|
||||
$('#tableOfTarifaacabadolineas').on( 'click', 'tbody span.edit', function (e) {
|
||||
editor.inline(
|
||||
theTable.cells(this.parentNode, '*').nodes(),
|
||||
{
|
||||
cancelHtml: '<i class="ti ti-x"></i>',
|
||||
cancelTrigger: 'span.cancel',
|
||||
submitHtml: '<i class="ti ti-device-floppy"></i>',
|
||||
submitTrigger: 'span.edit',
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
|
||||
// Delete row
|
||||
$('#tableOfTarifaacabadolineas').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();
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?=$this->section('css') ?>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.<?=config('Basics')->theme['name'] == 'Bootstrap5' ? 'bootstrap5' : 'bootstrap4' ?>.min.css">
|
||||
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
<script src="https://cdn.datatables.net/buttons/2.2.3/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.<?=config('Basics')->theme['name'] == 'Bootstrap5' ? 'bootstrap5' : 'bootstrap4' ?>.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.print.min.js"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.0/jszip.min.js" integrity="sha512-xcHCGC5tQ0SHlRX8Anbz6oy/OullASJkEhb4gjkneVpGE3/QGYejf14CUO5n5q5paiHfRFTa9HKgByxzidw2Bw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.5/pdfmake.min.js" integrity="sha512-rDbVu5s98lzXZsmJoMa0DjHNE+RwPJACogUCLyq3Xxm2kJO6qsQwjbE5NDk2DqmlKcxDirCnU1wAzVLe12IM3w==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.5/vfs_fonts.js" integrity="sha512-cktKDgjEiIkPVHYbn8bh/FEyYxmt4JDJJjOCu5/FQAkW4bc911XtKYValiyzBiJigjVEvrIAyQFEbRJZyDA1wQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
|
||||
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user