mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'dev/views'
# Conflicts: # ci4/.env # ci4/app/Controllers/Test.php
This commit is contained in:
22
ci4/.env
22
ci4/.env
@ -41,22 +41,22 @@ app.baseURL = 'https://sk-imn.imnavajas.es'
|
||||
# DATABASE
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
# database.default.hostname = localhost
|
||||
# database.default.database = sk_jjo
|
||||
# database.default.username = sk_jjo
|
||||
# database.default.password = 61tv&G1Zf^XY
|
||||
# database.default.DBDriver = MySQLi
|
||||
# database.default.DBPrefix =
|
||||
# database.default.dump =
|
||||
|
||||
database.default.hostname = localhost
|
||||
database.default.database = sk_imn
|
||||
database.default.username = sk_imn
|
||||
database.default.password = Uyia19_87
|
||||
database.default.database = sk_jjo
|
||||
database.default.username = sk_jjo
|
||||
database.default.password = 61tv&G1Zf^XY
|
||||
database.default.DBDriver = MySQLi
|
||||
database.default.DBPrefix =
|
||||
database.default.dump =
|
||||
|
||||
# database.default.hostname = localhost
|
||||
# database.default.database = sk_imn
|
||||
# database.default.username = sk_imn
|
||||
# database.default.password = Uyia19_87
|
||||
# database.default.DBDriver = MySQLi
|
||||
# database.default.DBPrefix =
|
||||
# database.default.dump =
|
||||
|
||||
# database.tests.hostname = localhost
|
||||
# database.tests.database = ci4
|
||||
# database.tests.username = root
|
||||
|
||||
@ -115,18 +115,34 @@ $routes->group('tarifapreimpresion', ['namespace' => 'App\Controllers\Tarifas'],
|
||||
});
|
||||
|
||||
|
||||
$routes->group('tarifamanipulado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
|
||||
$routes->get('', 'Tarifamanipulado::index', ['as' => 'tarifamanipuladoList']);
|
||||
$routes->get('index', 'Tarifamanipulado::index', ['as' => 'tarifamanipuladoIndex']);
|
||||
$routes->get('list', 'Tarifamanipulado::index', ['as' => 'tarifamanipuladoList2']);
|
||||
$routes->get('add', 'Tarifamanipulado::add', ['as' => 'newTarifamanipulado']);
|
||||
$routes->post('add', 'Tarifamanipulado::add', ['as' => 'createTarifamanipulado']);
|
||||
$routes->get('edit/(:num)', 'Tarifamanipulado::edit/$1', ['as' => 'editTarifamanipulado']);
|
||||
$routes->post('edit/(:num)', 'Tarifamanipulado::edit/$1', ['as' => 'updateTarifamanipulado']);
|
||||
$routes->get('delete/(:num)', 'Tarifamanipulado::delete/$1', ['as' => 'deleteTarifamanipulado']);
|
||||
$routes->post('allmenuitems', 'Tarifamanipulado::allItemsSelect', ['as' => 'select2ItemsOfTarifasmanipulado']);
|
||||
$routes->post('menuitems', 'Tarifamanipulado::menuItems', ['as' => 'menuItemsOfTarifasmanipulado']);
|
||||
$routes->group('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
|
||||
$routes->get('', 'Tarifasmanipulado::index', ['as' => 'tarifaManipuladoList']);
|
||||
$routes->get('add', 'Tarifasmanipulado::add', ['as' => 'newTarifaManipulado']);
|
||||
$routes->post('add', 'Tarifasmanipulado::add', ['as' => 'createTarifaManipulado']);
|
||||
$routes->post('create', 'Tarifasmanipulado::create', ['as' => 'ajaxCreateTarifaManipulado']);
|
||||
$routes->put('(:num)/update', 'Tarifasmanipulado::update/$1', ['as' => 'ajaxUpdateTarifaManipulado']);
|
||||
$routes->post('edit/(:num)', 'Tarifasmanipulado::edit/$1', ['as' => 'updateTarifaManipulado']);
|
||||
$routes->get('delete/(:num)', 'Tarifasmanipulado::delete/$1', ['as' => 'deleteTarifaManipulado']);
|
||||
$routes->post('datatable', 'Tarifasmanipulado::datatable', ['as' => 'dataTableOfTarifasManipulado']);
|
||||
$routes->post('allmenuitems', 'Tarifasmanipulado::allItemsSelect', ['as' => 'select2ItemsOfTarifasManipulado']);
|
||||
$routes->post('menuitems', 'Tarifasmanipulado::menuItems', ['as' => 'menuItemsOfTarifasManipulado']);
|
||||
});
|
||||
$routes->resource('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasmanipulado', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
$routes->group('tarifamanipuladolineas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
|
||||
$routes->get('', 'Tarifamanipuladolineas::index', ['as' => 'tarifaManipuladoLineaList']);
|
||||
$routes->get('add', 'Tarifamanipuladolineas::add', ['as' => 'newTarifaManipuladoLinea']);
|
||||
$routes->post('add', 'Tarifamanipuladolineas::add', ['as' => 'createTarifaManipuladoLinea']);
|
||||
$routes->post('create', 'Tarifamanipuladolineas::create', ['as' => 'ajaxCreateTarifaManipuladoLinea']);
|
||||
$routes->put('(:num)/update', 'Tarifamanipuladolineas::update/$1', ['as' => 'ajaxUpdateTarifaManipuladoLinea']);
|
||||
$routes->post('(:num)/edit', 'Tarifamanipuladolineas::edit/$1', ['as' => 'updateTarifaManipuladoLinea']);
|
||||
$routes->post('datatable', 'Tarifamanipuladolineas::datatable', ['as' => 'dataTableOfTarifaManipuladoLineas']);
|
||||
$routes->post('datatable_editor', 'Tarifamanipuladolineas::datatable_editor', ['as' => 'editorOfTarifaManipuladoLineas']);
|
||||
$routes->post('allmenuitems', 'Tarifamanipuladolineas::allItemsSelect', ['as' => 'select2ItemsOfTarifaManipuladoLineas']);
|
||||
$routes->post('menuitems', 'Tarifamanipuladolineas::menuItems', ['as' => 'menuItemsOfTarifaManipuladoLineas']);
|
||||
});
|
||||
$routes->resource('tarifamanipuladolineas', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifamanipuladolineas', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
$routes->group('tipologiaslibros', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
|
||||
401
ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php
Normal file
401
ci4/app/Controllers/Tarifas/Tarifamanipuladolineas.php
Normal file
@ -0,0 +1,401 @@
|
||||
<?php namespace App\Controllers\Tarifas;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\Tarifas\TarifaManipuladoLinea;
|
||||
|
||||
use App\Models\Tarifas\TarifaManipuladoLineaModel;
|
||||
|
||||
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 Tarifamanipuladolineas extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected $modelName = TarifaManipuladoLineaModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Tarifa Manipulado Linea';
|
||||
protected static $singularObjectNameCc = 'tarifaManipuladoLinea';
|
||||
protected static $pluralObjectName = 'Tarifa Manipulado Lineas';
|
||||
protected static $pluralObjectNameCc = 'tarifaManipuladoLineas';
|
||||
|
||||
protected static $controllerSlug = 'tarifamanipuladolineas';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/tarifas/manipulado/';
|
||||
|
||||
protected $indexRoute = 'tarifaManipuladoLineaList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('TarifaManipuladoLineas.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('TarifaManipuladoLineas.tarifamanipuladoLinea')]),
|
||||
'tarifaManipuladoLinea' => new TarifaManipuladoLinea(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath.'viewTarifaManipuladoLineaList', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function add() {
|
||||
|
||||
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('TarifaManipuladoLineas.tarifamanipuladoLinea'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('TarifaManipuladoLineas.tarifamanipuladoLinea'))]).'.';
|
||||
$message .= anchor( "tarifamanipuladolineas/{$id}/edit" , lang('Basic.global.continueEditing').'?');
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['tarifaManipuladoLinea'] = isset($sanitizedData) ? new TarifaManipuladoLinea($sanitizedData) : new TarifaManipuladoLinea();
|
||||
|
||||
$this->viewData['formAction'] = route_to('createTarifaManipuladoLinea');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('TarifaManipuladoLineas.moduleTitle').' '.lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$tarifaManipuladoLinea = $this->model->find($id);
|
||||
|
||||
if ($tarifaManipuladoLinea == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('TarifaManipuladoLineas.tarifamanipuladoLinea')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
|
||||
if ($requestMethod === 'post') :
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('TarifaManipuladoLineas.tarifamanipuladoLinea'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$tarifaManipuladoLinea->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $tarifaManipuladoLinea->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('TarifaManipuladoLineas.tarifamanipuladoLinea'))]).'.';
|
||||
$message .= anchor( "tarifamanipuladolineas/{$id}/edit" , lang('Basic.global.continueEditing').'?');
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['tarifaManipuladoLinea'] = $tarifaManipuladoLinea;
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateTarifaManipuladoLinea', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TarifaManipuladoLineas.moduleTitle').' '.lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
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_manipulado_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_manipulado_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' ),
|
||||
|
||||
)
|
||||
->validator( function($editor, $action, $data){
|
||||
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){
|
||||
foreach ($data['data'] as $pkey => $values ){
|
||||
// Si no se quiere borrar...
|
||||
if($data['data'][$pkey]['is_deleted'] != 1)
|
||||
{
|
||||
|
||||
$count = $this->model->select('*')
|
||||
->where(array(
|
||||
'tarifa_manipulado_id'=> $values['tarifa_manipulado_id'],
|
||||
'tirada_min'=> $values['tirada_min'],
|
||||
'tirada_max'=> $values['tirada_max'],
|
||||
'is_deleted'=> 0))
|
||||
->countAllResults();
|
||||
if ($count >= 1){
|
||||
return lang('TarifaAcabadoLineas.validation.duplicated_tirada');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
->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 unique key is set in DB
|
||||
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 datatable() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
|
||||
return $response;
|
||||
}
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
||||
$order = TarifaManipuladoLineaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$id_TM = $reqData['id_tarifamanipulado'] ?? -1;
|
||||
|
||||
$resourceData = $this->model->getResource("", $id_TM)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function allItemsSelect() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$onlyActiveOnes = true;
|
||||
$reqVal = $this->request->getPost('val') ?? 'id';
|
||||
$menu = $this->model->getAllForMenu($reqVal.', tarifa_manipulado_id', 'tarifa_manipulado_id', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->tarifa_manipulado_id = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function menuItems() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
$reqId = goSanitize($this->request->getPost('id'))[0];
|
||||
$reqText = goSanitize($this->request->getPost('text'))[0];
|
||||
$onlyActiveOnes = false;
|
||||
$columns2select = [$reqId ?? 'id', $reqText ?? 'tarifa_manipulado_id'];
|
||||
$onlyActiveOnes = false;
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- '.lang('Basic.global.None').' -';
|
||||
array_unshift($menu , $nonItem);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,44 +1,62 @@
|
||||
<?php namespace App\Controllers\Tarifas;
|
||||
|
||||
|
||||
use App\Entities\Tarifas\TarifamanipuladoEntity;
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
class Tarifamanipulado extends \App\Controllers\GoBaseController {
|
||||
use App\Models\Collection;
|
||||
|
||||
use \CodeIgniter\API\ResponseTrait;
|
||||
use App\Entities\Tarifas\TarifaManipuladoEntity;
|
||||
|
||||
protected static $primaryModelName = 'App\Models\Tarifas\TarifamanipuladoModel';
|
||||
use App\Models\Tarifas\TarifaManipuladoModel;
|
||||
|
||||
class Tarifasmanipulado extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected $modelName = TarifaManipuladoModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Tarifa Manipulado';
|
||||
protected static $singularObjectNameCc = 'tarifaManipulado';
|
||||
protected static $pluralObjectName = 'Tarifas Manipulado';
|
||||
protected static $pluralObjectNameCc = 'tarifasManipulado';
|
||||
|
||||
protected static $singularObjectNameCc = 'tarifamanipulado';
|
||||
protected static $singularObjectName = 'Tarifamanipulado';
|
||||
protected static $pluralObjectName = 'Tarifasmanipulado';
|
||||
protected static $controllerSlug = 'tarifamanipulado';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/tarifas/manipulado/';
|
||||
|
||||
protected $indexRoute = 'tarifamanipuladoList';
|
||||
protected $indexRoute = 'tarifaManipuladoList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('Tarifamanipulado.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]; // JJO
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
$this->viewData['usingClientSideDataTable'] = true;
|
||||
|
||||
$this->viewData['pageSubTitle'] = lang('Basic.global.ManageAllRecords', [lang('Tarifamanipulado.tarifamanipulado')]);
|
||||
parent::index();
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tarifamanipulado.tarifamanipulado')]),
|
||||
'tarifaManipuladoEntity' => new TarifaManipuladoEntity(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath.'viewTarifaManipuladoList', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function add() {
|
||||
|
||||
// JJO
|
||||
@ -51,6 +69,7 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
@ -60,7 +79,7 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
@ -79,49 +98,50 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]).'.';
|
||||
$message .= anchor(route_to('editTarifamanipulado', $id), lang('Basic.global.continueEditing').'?');
|
||||
$message .= anchor( "tarifamanipulado/{$id}/edit" , lang('Basic.global.continueEditing').'?');
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('successMessage', $message);
|
||||
return redirect()->to(site_url('tarifas/tarifasmanipulado/edit/'.$id))->with('sweet-success', $message);
|
||||
//return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('successMessage', $message);
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->viewData['successMessage'] = $message;
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['tarifamanipuladoEntity'] = isset($sanitizedData) ? new TarifamanipuladoEntity($sanitizedData) : new TarifamanipuladoEntity();
|
||||
$this->viewData['tarifaManipuladoEntity'] = isset($sanitizedData) ? new TarifaManipuladoEntity($sanitizedData) : new TarifaManipuladoEntity();
|
||||
|
||||
$this->viewData['formAction'] = route_to('createTarifamanipulado');
|
||||
$this->viewData['formAction'] = route_to('createTarifaManipulado');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifamanipulado.tarifamanipulado').' '.lang('Basic.global.addNewSuffix');
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('Tarifamanipulado.moduleTitle').' '.lang('Basic.global.addNewSuffix');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
public function edit($requestedId = null) {
|
||||
|
||||
|
||||
// JJO
|
||||
$session = session();
|
||||
|
||||
|
||||
if ($requestedId == null) :
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$tarifamanipuladoEntity = $this->model->find($id);
|
||||
$tarifaManipuladoEntity = $this->model->find($id);
|
||||
|
||||
if ($tarifamanipuladoEntity == false) :
|
||||
if ($tarifaManipuladoEntity == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado')), $id]);
|
||||
return $this->redirect2listView('errorMessage', $message);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
$requestMethod = $this->request->getMethod();
|
||||
@ -131,6 +151,7 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
@ -140,56 +161,80 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$tarifaManipuladoEntity->fill($sanitizedData);
|
||||
|
||||
if ($this->canValidate()) :
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
$noException = false;
|
||||
$this->dealWithException($e);
|
||||
}
|
||||
else:
|
||||
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$tarifamanipuladoEntity->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $tarifamanipuladoEntity->id ?? $id;
|
||||
$id = $tarifaManipuladoEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado'))]).'.';
|
||||
$message .= anchor(route_to('editTarifamanipulado', $id), lang('Basic.global.continueEditing').'?');
|
||||
$message .= anchor( "tarifamanipulado/{$id}/edit" , lang('Basic.global.continueEditing').'?');
|
||||
$message = ucfirst(str_replace("'", "\'", $message));
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('successMessage', $message);
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('successMessage', $message);
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
endif;
|
||||
else:
|
||||
$this->viewData['successMessage'] = $message;
|
||||
$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['tarifamanipuladoEntity'] = $tarifamanipuladoEntity;
|
||||
$this->viewData['tarifaManipuladoEntity'] = $tarifaManipuladoEntity;
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateTarifamanipulado', $id);
|
||||
$this->viewData['formAction'] = route_to('updateTarifaManipulado', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifamanipulado.tarifamanipulado').' '.lang('Basic.global.edit3');
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('Tarifamanipulado.moduleTitle').' '.lang('Basic.global.edit3');
|
||||
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
|
||||
|
||||
|
||||
|
||||
public function datatable() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
|
||||
$errstr = 'No data available in response to this specific request.';
|
||||
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
|
||||
return $response;
|
||||
}
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$order = TarifaManipuladoModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function allItemsSelect() {
|
||||
if ($this->request->isAJAX()) {
|
||||
@ -212,7 +257,7 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function menuItems() {
|
||||
if ($this->request->isAJAX()) {
|
||||
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
|
||||
@ -238,5 +283,5 @@ class Tarifamanipulado extends \App\Controllers\GoBaseController {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -15,14 +15,11 @@ class Test extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
$t_model = new TarifaAcabadoLineaModel();
|
||||
$count = $t_model->select('*')
|
||||
->where(array( 'tarifa_acabado_id'=> 13,
|
||||
'tirada_min'=> 1,
|
||||
'tirada_max'=> 1,
|
||||
'is_deleted'=> 0))
|
||||
->countAllResults();
|
||||
var_dump($count);
|
||||
/*
|
||||
$papel = new Papelesimpresion();
|
||||
var_dump($papel->datatablePG());*/
|
||||
return redirect()->to(site_url('tarifas/tarifaacabado/edit/'. 30))->with('sweet-success', 'OK');
|
||||
//return redirect()->to('https://sk-jjo.imnavajas.es/tarifas/tarifaacabado/edit/30');
|
||||
}
|
||||
}
|
||||
|
||||
33
ci4/app/Entities/Tarifas/TarifaManipuladoLinea.php
Normal file
33
ci4/app/Entities/Tarifas/TarifaManipuladoLinea.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace App\Entities\Tarifas;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class TarifaManipuladoLinea extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"tarifa_manipulado_id" => 0,
|
||||
"tirada_min" => 0,
|
||||
"tirada_max" => 0,
|
||||
"precio_min" => 0,
|
||||
"precio_max" => 0,
|
||||
"precio_unidad" => 0,
|
||||
"user_created_id" => 0,
|
||||
"user_updated_id" => 0,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"tarifa_manipulado_id" => "int",
|
||||
"tirada_min" => "float",
|
||||
"tirada_max" => "float",
|
||||
"precio_min" => "float",
|
||||
"precio_max" => "float",
|
||||
"precio_unidad" => "float",
|
||||
"user_created_id" => "int",
|
||||
"user_updated_id" => "int",
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
@ -3,33 +3,20 @@ namespace App\Entities\Tarifas;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class TarifamanipuladoEntity extends \CodeIgniter\Entity\Entity
|
||||
class TarifaManipuladoEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"nombre" => null,
|
||||
"tirada_min" => 0,
|
||||
"precio_min" => 0,
|
||||
"tirada_max" => 0,
|
||||
"precio_max" => null,
|
||||
"ajuste" => 0,
|
||||
"ajuste_total_pedido" => 0,
|
||||
"formula_price" => null,
|
||||
"user_created_id" => 1,
|
||||
"user_update_id" => 1,
|
||||
"deleted_at" => null,
|
||||
"user_created_id" => 0,
|
||||
"user_update_id" => 0,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"tirada_min" => "int",
|
||||
"precio_min" => "float",
|
||||
"tirada_max" => "int",
|
||||
"precio_max" => "float",
|
||||
"ajuste" => "float",
|
||||
"ajuste_total_pedido" => "float",
|
||||
"user_created_id" => "int",
|
||||
"user_update_id" => "int",
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
|
||||
@ -182,7 +182,6 @@ class LoginAuthFilter implements FilterInterface
|
||||
'datatable',
|
||||
'datatable_editor',
|
||||
'fetch_single_data',
|
||||
'datatableTintas',
|
||||
'collect',
|
||||
'cast',
|
||||
];
|
||||
|
||||
49
ci4/app/Language/en/TarifaManipuladoLineas.php
Normal file
49
ci4/app/Language/en/TarifaManipuladoLineas.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Handling rates Lines',
|
||||
'deleteLine' => 'the selected register',
|
||||
'precioMax' => 'Max Price',
|
||||
'precioMin' => 'Min Price',
|
||||
'precioUnidad' => 'Price Unit',
|
||||
'tiradaMax' => 'Print Max',
|
||||
'tiradaMin' => 'Print Min',
|
||||
'validation' => [
|
||||
'precio_max' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'precio_min' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'precio_unidad' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'tirada_max' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'tirada_min' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
49
ci4/app/Language/es/TarifaManipuladoLineas.php
Normal file
49
ci4/app/Language/es/TarifaManipuladoLineas.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Tarifa Manipulado Lineas',
|
||||
'deleteLine' => 'el registro seleccionado',
|
||||
'precioMax' => 'Precio Max',
|
||||
'precioMin' => 'Precio Min',
|
||||
'precioUnidad' => 'Precio Unidad',
|
||||
'tiradaMax' => 'Tirada Max',
|
||||
'tiradaMin' => 'Tirada Min',
|
||||
'validation' => [
|
||||
'precio_max' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'precio_min' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'precio_unidad' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'tirada_max' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
'tirada_min' => [
|
||||
'decimal' => 'The {field} field must contain a decimal number.',
|
||||
'required' => 'The {field} field is required.',
|
||||
|
||||
],
|
||||
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
@ -13,7 +13,7 @@ return [
|
||||
'nombre' => 'Nombre',
|
||||
'precioMax' => 'Precio Max',
|
||||
'precioMin' => 'Precio Min',
|
||||
'tarifamanipulado' => 'Tarifas manipulado',
|
||||
'tarifamanipulado' => 'Tarifa manipulado',
|
||||
'tarifamanipuladoList' => 'Lista Tarifas manipulado',
|
||||
'tarifasmanipulado' => 'Tarifas manipulado',
|
||||
'tiradaMax' => 'Tirada Max',
|
||||
|
||||
132
ci4/app/Models/Tarifas/TarifaManipuladoLineaModel.php
Normal file
132
ci4/app/Models/Tarifas/TarifaManipuladoLineaModel.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
namespace App\Models\Tarifas;
|
||||
|
||||
class TarifaManipuladoLineaModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "tarifa_manipulado_lineas";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.tirada_min",
|
||||
1 => "t1.tirada_max",
|
||||
2 => "t1.precio_min",
|
||||
3 => "t1.precio_max",
|
||||
4 => "t1.precio_unidad",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"tarifa_manipulado_id",
|
||||
"tirada_min",
|
||||
"tirada_max",
|
||||
"precio_min",
|
||||
"precio_max",
|
||||
"precio_unidad",
|
||||
"user_created_id",
|
||||
"is_deleted",
|
||||
|
||||
];
|
||||
protected $returnType = "App\Entities\Tarifas\TarifaManipuladoLinea";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "tarifa_manipulado_id";
|
||||
|
||||
protected $validationRules = [
|
||||
"precio_max" => [
|
||||
"label" => "TarifaManipuladoLineas.precioMax",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"precio_min" => [
|
||||
"label" => "TarifaManipuladoLineas.precioMin",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"precio_unidad" => [
|
||||
"label" => "TarifaManipuladoLineas.precioUnidad",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"tirada_max" => [
|
||||
"label" => "TarifaManipuladoLineas.tiradaMax",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"tirada_min" => [
|
||||
"label" => "TarifaManipuladoLineas.tiradaMin",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"precio_max" => [
|
||||
"decimal" => "TarifaManipuladoLineas.validation.precio_max.decimal",
|
||||
"required" => "TarifaManipuladoLineas.validation.precio_max.required",
|
||||
],
|
||||
"precio_min" => [
|
||||
"decimal" => "TarifaManipuladoLineas.validation.precio_min.decimal",
|
||||
"required" => "TarifaManipuladoLineas.validation.precio_min.required",
|
||||
],
|
||||
"precio_unidad" => [
|
||||
"decimal" => "TarifaManipuladoLineas.validation.precio_unidad.decimal",
|
||||
"required" => "TarifaManipuladoLineas.validation.precio_unidad.required",
|
||||
],
|
||||
"tirada_max" => [
|
||||
"decimal" => "TarifaManipuladoLineas.validation.tirada_max.decimal",
|
||||
"required" => "TarifaManipuladoLineas.validation.tirada_max.required",
|
||||
],
|
||||
"tirada_min" => [
|
||||
"decimal" => "TarifaManipuladoLineas.validation.tirada_min.decimal",
|
||||
"required" => "TarifaManipuladoLineas.validation.tirada_min.required",
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "", $tarifa_manipulado_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.tarifa_manipulado_id AS tarifa_manipulado_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, t2.id AS tarifa_manipulado"
|
||||
);
|
||||
//JJO
|
||||
$builder->where('tarifa_manipulado_id', $tarifa_manipulado_id);
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
|
||||
$builder->join("lg_tarifa_manipulado t2", "t1.tarifa_manipulado_id = t2.id", "left");
|
||||
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.tarifa_manipulado_id", $search)
|
||||
->orLike("t1.tirada_min", $search)
|
||||
->orLike("t1.tirada_max", $search)
|
||||
->orLike("t1.precio_min", $search)
|
||||
->orLike("t1.precio_max", $search)
|
||||
->orLike("t1.precio_unidad", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.tarifa_manipulado_id", $search)
|
||||
->orLike("t1.tirada_min", $search)
|
||||
->orLike("t1.tirada_max", $search)
|
||||
->orLike("t1.precio_min", $search)
|
||||
->orLike("t1.precio_max", $search)
|
||||
->orLike("t1.precio_unidad", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace App\Models\Tarifas;
|
||||
|
||||
class TarifamanipuladoModel extends \App\Models\GoBaseModel
|
||||
class TarifaManipuladoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_tarifa_manipulado";
|
||||
|
||||
@ -12,97 +12,62 @@ class TarifamanipuladoModel extends \App\Models\GoBaseModel
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.nombre",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"tirada_min",
|
||||
"precio_min",
|
||||
"tirada_max",
|
||||
"precio_max",
|
||||
"ajuste",
|
||||
"ajuste_total_pedido",
|
||||
"formula_price",
|
||||
"deleted_at",
|
||||
"is_deleted",
|
||||
"user_created_id",
|
||||
"user_update_id",
|
||||
"user_update_id"
|
||||
];
|
||||
protected $returnType = "App\Entities\Tarifas\TarifamanipuladoEntity";
|
||||
protected $returnType = "App\Entities\Tarifas\TarifaManipuladoEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"ajuste" => [
|
||||
"label" => "Manipuladoes.ajuste",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"ajuste_total_pedido" => [
|
||||
"label" => "Manipuladoes.ajusteTotalPedido",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"formula_price" => [
|
||||
"label" => "Manipuladoes.formulaPrice",
|
||||
"rules" => "trim|required|max_length[1073241]",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "Manipuladoes.nombre",
|
||||
"label" => "Tarifamanipulado.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"precio_max" => [
|
||||
"label" => "Manipuladoes.precioMax",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"precio_min" => [
|
||||
"label" => "Manipuladoes.precioMin",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"tirada_max" => [
|
||||
"label" => "Manipuladoes.tiradaMax",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"tirada_min" => [
|
||||
"label" => "Manipuladoes.tiradaMin",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"ajuste" => [
|
||||
"decimal" => "Manipuladoes.validation.ajuste.decimal",
|
||||
"required" => "Manipuladoes.validation.ajuste.required",
|
||||
],
|
||||
"ajuste_total_pedido" => [
|
||||
"decimal" => "Manipuladoes.validation.ajuste_total_pedido.decimal",
|
||||
"required" => "Manipuladoes.validation.ajuste_total_pedido.required",
|
||||
],
|
||||
"formula_price" => [
|
||||
"max_length" => "Manipuladoes.validation.formula_price.max_length",
|
||||
"required" => "Manipuladoes.validation.formula_price.required",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "Manipuladoes.validation.nombre.max_length",
|
||||
"required" => "Manipuladoes.validation.nombre.required",
|
||||
"max_length" => "Tarifamanipulado.validation.nombre.max_length",
|
||||
"required" => "Tarifamanipulado.validation.nombre.required",
|
||||
],
|
||||
"precio_max" => [
|
||||
"decimal" => "Manipuladoes.validation.precio_max.decimal",
|
||||
"required" => "Manipuladoes.validation.precio_max.required",
|
||||
],
|
||||
"precio_min" => [
|
||||
"decimal" => "Manipuladoes.validation.precio_min.decimal",
|
||||
"required" => "Manipuladoes.validation.precio_min.required",
|
||||
],
|
||||
"tirada_max" => [
|
||||
"integer" => "Manipuladoes.validation.tirada_max.integer",
|
||||
"required" => "Manipuladoes.validation.tirada_max.required",
|
||||
],
|
||||
"tirada_min" => [
|
||||
"integer" => "Manipuladoes.validation.tirada_min.integer",
|
||||
"required" => "Manipuladoes.validation.tirada_min.required",
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$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
|
||||
->groupStart()
|
||||
->like("t1.nombre", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,77 +1,12 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="col-md-12 col-lg-12 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="nombre" class="form-label">
|
||||
<?=lang('Tarifamanipulado.nombre') ?>*
|
||||
</label>
|
||||
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $tarifamanipuladoEntity->nombre) ?>">
|
||||
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $tarifaManipuladoEntity->nombre) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="tiradaMin" class="form-label">
|
||||
<?=lang('Tarifamanipulado.tiradaMin') ?>*
|
||||
</label>
|
||||
<input type="number" id="tiradaMin" name="tirada_min" required placeholder="0" maxLength="11" class="form-control" value="<?=old('tirada_min', $tarifamanipuladoEntity->tirada_min) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="tiradaMax" class="form-label">
|
||||
<?=lang('Tarifamanipulado.tiradaMax') ?>*
|
||||
</label>
|
||||
<input type="number" id="tiradaMax" name="tirada_max" required placeholder="0" maxLength="11" class="form-control" value="<?=old('tirada_max', $tarifamanipuladoEntity->tirada_max) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="precioMin" class="form-label">
|
||||
<?=lang('Tarifamanipulado.precioMin') ?>*
|
||||
</label>
|
||||
<input type="number" id="precioMin" name="precio_min" required placeholder="0" maxLength="31" step="0.01" class="form-control" value="<?=old('precio_min', $tarifamanipuladoEntity->precio_min) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="precioMax" class="form-label">
|
||||
<?=lang('Tarifamanipulado.precioMax') ?>*
|
||||
</label>
|
||||
<input type="number" id="precioMax" name="precio_max" required maxLength="31" step="0.01" class="form-control" value="<?=old('precio_max', $tarifamanipuladoEntity->precio_max) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="ajuste" class="form-label">
|
||||
<?=lang('Tarifamanipulado.ajuste') ?>*
|
||||
</label>
|
||||
<input type="number" id="ajuste" name="ajuste" required placeholder="0" maxLength="31" step="0.01" class="form-control" value="<?=old('ajuste', $tarifamanipuladoEntity->ajuste) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="ajusteTotalPedido" class="form-label">
|
||||
<?=lang('Tarifamanipulado.ajusteTotalPedido') ?>*
|
||||
</label>
|
||||
<input type="number" id="ajusteTotalPedido" name="ajuste_total_pedido" required placeholder="0" maxLength="31" step="0.01" class="form-control" value="<?=old('ajuste_total_pedido', $tarifamanipuladoEntity->ajuste_total_pedido) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="formulaPrice" class="form-label">
|
||||
<?=lang('Tarifamanipulado.formulaPrice') ?>*
|
||||
</label>
|
||||
<textarea rows="3" id="formulaPrice" name="formula_price" required style="height: 10em;" class="form-control"><?=old('formula_price', $tarifamanipuladoEntity->formula_price) ?></textarea>
|
||||
</div><!--//.mb-3 -->
|
||||
<?php /*
|
||||
<div class="mb-3">
|
||||
<label for="userCreatedId" class="form-label">
|
||||
<?=lang('Tarifamanipulado.userCreatedId') ?>*
|
||||
</label>
|
||||
<input type="number" id="userCreatedId" name="user_created_id" required placeholder="1" maxLength="10" class="form-control" value="<?=old('user_created_id', $tarifamanipuladoEntity->user_created_id) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="userUpdateId" class="form-label">
|
||||
<?=lang('Tarifamanipulado.userUpdateId') ?>*
|
||||
</label>
|
||||
<input type="number" id="userUpdateId" name="user_update_id" required placeholder="1" maxLength="10" class="form-control" value="<?=old('user_update_id', $tarifamanipuladoEntity->user_update_id) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
*/ ?>
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -1,5 +1,7 @@
|
||||
<?= $this->include("themes/_commonPartialsBs/datatables") ?>
|
||||
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
|
||||
<?= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
<?= $this->section("content") ?>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@ -7,21 +9,272 @@
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
|
||||
</div><!--//.card-header -->
|
||||
<form id="tarifamanipuladoForm" method="post" action="<?= $formAction ?>">
|
||||
<form id="tarifaManipuladoForm" 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/manipulado/_tarifamanipuladoFormItems") ?>
|
||||
<?= view("themes/backend/vuexy/form/tarifas/manipulado/_tarifaManipuladoFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="card-footer">
|
||||
<?= anchor(route_to("tarifamanipuladoIndex"), lang("Basic.global.Cancel"), [
|
||||
"class" => "btn btn-secondary float-start",
|
||||
]) ?>
|
||||
<input type="submit" class="btn btn-primary float-end" name="save" value="<?= lang("Basic.global.Save") ?>">
|
||||
<input type="submit"
|
||||
class="btn btn-primary float-start me-sm-3 me-1"
|
||||
name="save"
|
||||
value="<?= lang("Basic.global.Save") ?>"
|
||||
/>
|
||||
<?= anchor(route_to("tarifaManipuladoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start",]) ?>
|
||||
|
||||
</div><!-- /.card-footer -->
|
||||
</form>
|
||||
</div><!-- //.card -->
|
||||
</div><!--//.col -->
|
||||
|
||||
<?php if($formAction == route_to('createTarifaManipulado')): ?>
|
||||
<div class="accordion mt-3" id="accordionManipuladoLineas" style="visibility:hidden" >
|
||||
<?php else: ?>
|
||||
<div class="accordion mt-3" id="accordionManipuladoLineas" style="visibility:visible" >
|
||||
<?php endif; ?>
|
||||
<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("TarifaManipuladoLineas.moduleTitle") ?></p>
|
||||
</button>
|
||||
|
||||
</h2>
|
||||
|
||||
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionManipuladoLineas">
|
||||
<div class="accordion-body">
|
||||
|
||||
<table id="tableOfTarifamanipuladolineas" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('TarifaManipuladoLineas.tiradaMin') ?></th>
|
||||
<th><?= lang('TarifaManipuladoLineas.tiradaMax') ?></th>
|
||||
<th><?= lang('TarifaManipuladoLineas.precioMin') ?></th>
|
||||
<th><?= lang('TarifaManipuladoLineas.precioMax') ?></th>
|
||||
<th><?= lang('TarifaManipuladoLineas.precioUnidad') ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- //.accordion -->
|
||||
|
||||
|
||||
</div><!--//.row -->
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
const lastColNr = $('#tableOfTarifamanipuladolineas').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('editorOfTarifaManipuladoLineas') ?>",
|
||||
headers: {
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
||||
},
|
||||
},
|
||||
table : "#tableOfTarifamanipuladolineas",
|
||||
idSrc: 'id',
|
||||
fields: [ {
|
||||
name: "tirada_min"
|
||||
}, {
|
||||
name: "tirada_max"
|
||||
}, {
|
||||
name: "precio_min"
|
||||
}, {
|
||||
name: "precio_max"
|
||||
}, {
|
||||
name: "precio_unidad"
|
||||
},{
|
||||
"name": "tarifa_manipulado_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_manipulado_id'] = id;
|
||||
}
|
||||
else if(type === 'edit' ) {
|
||||
for (v in d.data){
|
||||
d.data[v]['tarifa_manipulado_id'] = id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
editor.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
|
||||
yeniden(json.<?= csrf_token() ?>);
|
||||
});
|
||||
|
||||
editor.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.draw();
|
||||
});
|
||||
|
||||
|
||||
var theTable = $('#tableOfTarifamanipuladolineas').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('dataTableOfTarifaManipuladoLineas') ?>',
|
||||
data: {
|
||||
id_tarifamanipulado: 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]
|
||||
},
|
||||
{"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: editor,
|
||||
formOptions: {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<i class="ti ti-device-floppy"/>'
|
||||
}
|
||||
} ]
|
||||
} );
|
||||
|
||||
|
||||
|
||||
// Activate an inline edit on click of a table cell
|
||||
$('#tableOfTarifamanipuladolineas').on( 'click', 'tbody span.edit', function (e) {
|
||||
editor.inline(
|
||||
theTable.cells(this.parentNode.parentNode, '*').nodes(),
|
||||
{
|
||||
cancelHtml: '<i class="ti ti-x"></i>',
|
||||
cancelTrigger: 'span.cancel',
|
||||
submitHtml: '<i class="ti ti-device-floppy"></i>',
|
||||
submitTrigger: 'span.edit',
|
||||
submit: 'allIfChanged'
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
|
||||
// Delete row
|
||||
$('#tableOfTarifamanipuladolineas').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() ?>
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
|
||||
<?=$this->section('content'); ?>
|
||||
<div class="row">
|
||||
@ -7,87 +8,20 @@
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?=lang('Tarifamanipulado.tarifamanipuladoList') ?></h3>
|
||||
<?=anchor(route_to('newTarifamanipulado'), lang('Basic.global.addNew').' '.lang('Tarifamanipulado.tarifamanipulado'), ['class'=>'btn btn-primary float-end']); ?>
|
||||
<?=anchor(route_to('newTarifaManipulado'), lang('Basic.global.addNew').' '.lang('Tarifamanipulado.tarifamanipulado'), ['class'=>'btn btn-primary float-end']); ?>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<table id="tableOfTarifasmanipulado" class="table table-striped table-hover using-exportable-data-table" style="width: 100%;">
|
||||
<table id="tableOfTarifasmanipulado" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php /*
|
||||
<th><?= lang('Tarifamanipulado.id') ?></th>
|
||||
*/ ?>
|
||||
<th><?= lang('Tarifamanipulado.nombre') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.tiradaMin') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.tiradaMax') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.precioMin') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.precioMax') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.ajuste') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.ajusteTotalPedido') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.formulaPrice') ?></th>
|
||||
<?php /*
|
||||
<th><?= lang('Tarifamanipulado.userCreatedId') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.userUpdateId') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.createdAt') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.updatedAt') ?></th>
|
||||
*/ ?>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($tarifamanipuladoList as $item ) : ?>
|
||||
<tr>
|
||||
<?php /*
|
||||
<td class="align-middle text-center">
|
||||
<?=$item->id ?>
|
||||
</td>
|
||||
*/ ?>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->nombre) || strlen($item->nombre) < 51 ? esc($item->nombre) : character_limiter(esc($item->nombre), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->tirada_min) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->tirada_max) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->precio_min) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->precio_max) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->ajuste) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->ajuste_total_pedido) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= empty($item->formula_price) || strlen($item->formula_price) < 51 ? esc($item->formula_price) : character_limiter(esc($item->formula_price), 50) ?>
|
||||
</td>
|
||||
<?php /*
|
||||
<td class="align-middle">
|
||||
<?= esc($item->user_created_id) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->user_update_id) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->created_at) ? '' : date('d/m/Y H:m:s', strtotime($item->created_at)) ?>
|
||||
</td>
|
||||
<td class="align-middle text-nowrap">
|
||||
<?= empty($item->updated_at) ? '' : date('d/m/Y H:m:s', strtotime($item->updated_at)) ?>
|
||||
</td>
|
||||
*/ ?>
|
||||
<td class="align-middle text-center text-nowrap">
|
||||
<?=anchor(route_to('editTarifamanipulado', $item->id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?>
|
||||
<?=anchor('#confirm2delete', lang('Basic.global.Delete'), ['class'=>'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteTarifamanipulado', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div><!--//.card-body -->
|
||||
@ -98,6 +32,110 @@
|
||||
</div><!--//.col -->
|
||||
</div><!--//.row -->
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
<?=$this->section('additionalInlineJs') ?>
|
||||
|
||||
const lastColNr = $('#tableOfTarifasmanipulado').find("tr:first th").length - 1;
|
||||
const actionBtns = function(data) {
|
||||
return `<td class="text-right py-0 align-middle">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i>
|
||||
<i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i>
|
||||
</div>
|
||||
</td>`;
|
||||
};
|
||||
theTable = $('#tableOfTarifasmanipulado').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
scrollX: true,
|
||||
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
|
||||
pageLength: 10,
|
||||
lengthChange: true,
|
||||
"dom": 'lfBrtip',
|
||||
"buttons": [
|
||||
'copy', 'csv', 'excel', 'print', {
|
||||
extend: 'pdfHtml5',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'A4'
|
||||
}
|
||||
],
|
||||
stateSave: true,
|
||||
order: [[0, 'asc']],
|
||||
language: {
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('dataTableOfTarifasManipulado') ?>',
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr]
|
||||
}
|
||||
],
|
||||
columns : [
|
||||
{ 'data': 'nombre' },
|
||||
{ 'data': actionBtns }
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
//window.location.href = `<?= route_to('tarifaManipuladoList') ?>/${$(this).attr('data-id')}/edit`;
|
||||
window.location.href = `/tarifas/tarifasmanipulado/edit/${$(this).attr('data-id')}`;
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Tarifamanipulado.tarifa manipulado'))]) ?>',
|
||||
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) {
|
||||
$.ajax({
|
||||
//url: `<?= route_to('tarifaManipuladoList') ?>/${dataId}`,
|
||||
//method: 'DELETE',
|
||||
url: `/tarifas/tarifasmanipulado/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
Toast.fire({
|
||||
icon: 'success',
|
||||
title: data.msg ?? jqXHR.statusText,
|
||||
});
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.row($(row)).invalidate().draw();
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
Toast.fire({
|
||||
icon: 'error',
|
||||
title: jqXHR.responseJSON.messages.error,
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
@ -116,39 +154,3 @@
|
||||
<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>
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
<?=$this->section('additionalInlineJs') ?>
|
||||
|
||||
const lastColNr2 = $(".using-exportable-data-table").find("tr:first th").length - 1;
|
||||
theTable = $('.using-exportable-data-table').DataTable({
|
||||
"responsive": true,
|
||||
"paging": true,
|
||||
"lengthMenu": [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
|
||||
"pageLength": 10,
|
||||
"lengthChange": true,
|
||||
"searching": true,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"dom": 'lfBrtip', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other
|
||||
// "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above
|
||||
"buttons": [
|
||||
'copy', 'csv', 'excel', 'print', {
|
||||
extend: 'pdfHtml5',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'A4'
|
||||
}
|
||||
],
|
||||
"autoWidth": true,
|
||||
"scrollX": true,
|
||||
"stateSave": true,
|
||||
"language": {
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
"columnDefs": [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [0,lastColNr2]
|
||||
}
|
||||
]
|
||||
});
|
||||
<?=$this->endSection() ?>
|
||||
@ -361,10 +361,10 @@
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if (count($temp = getArrayItem($menus, 'name', 'Tarifamanipulado')) > 0): ?>
|
||||
<?php if (count($temp = getArrayItem($menus, 'name', 'Tarifasmanipulado')) > 0): ?>
|
||||
<?php if (count(getArrayItem($temp, 'methods', 'index', true)) > 0): ?>
|
||||
<li class="menu-item">
|
||||
<a href="<?= site_url("tarifas/tarifamanipulado") ?>" class="menu-link">
|
||||
<a href="<?= site_url("tarifas/tarifasmanipulado") ?>" class="menu-link">
|
||||
<div data-i18n="<?= lang("App.menu_tarifamanipulado") ?>"><?= lang("App.menu_tarifamanipulado") ?></div>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user