mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
creando lista proveedores editor precios
This commit is contained in:
@ -8,6 +8,8 @@ use App\Models\Collection;
|
||||
use App\Entities\Tarifas\TarifaEnvioEntity;
|
||||
|
||||
use App\Models\Configuracion\PaisModel;
|
||||
use App\Models\Compras\ProveedorModel;
|
||||
use App\Models\Compras\ProveedorTipoModel;
|
||||
|
||||
use App\Models\Tarifas\TarifaEnvioModel;
|
||||
|
||||
@ -43,7 +45,7 @@ class Tarifasenvios extends \App\Controllers\GoBaseResourceController {
|
||||
// Breadcrumbs
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_tarifas"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_tarifasenvios"), 'route' => site_url('tarifas/tarifasenvios'), 'active' => true]
|
||||
['title' => lang("App.menu_tarifaenvio"), 'route' => site_url('tarifas/tarifasenvios'), 'active' => true]
|
||||
];
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
@ -217,6 +219,8 @@ class Tarifasenvios extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TarifasEnvios.moduleTitle').' '.lang('Basic.global.edit3');
|
||||
|
||||
//JJO
|
||||
$this->viewData['proveedores'] = $this->getProveedores();
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
@ -307,4 +311,12 @@ class Tarifasenvios extends \App\Controllers\GoBaseResourceController {
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getProveedores(){
|
||||
$provTipoModel = new ProveedorTipoModel();
|
||||
$provModel = new ProveedorModel();
|
||||
|
||||
$tipoId = $provTipoModel->getTipoId("Transporte");
|
||||
return $provModel->getProvList($tipoId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -13,6 +13,10 @@ use App\Models\Tarifas\TarifaEnvioModel;
|
||||
|
||||
use App\Models\Tarifas\TarifaEnvioPrecioModel;
|
||||
|
||||
use
|
||||
DataTables\Editor,
|
||||
DataTables\Editor\Field;
|
||||
|
||||
class Tarifasenvioserecios extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected $modelName = TarifaEnvioPrecioModel::class;
|
||||
@ -34,6 +38,12 @@ class Tarifasenvioserecios extends \App\Controllers\GoBaseResourceController {
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('TarifasEnviosPrecios.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;
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
@ -202,6 +212,103 @@ class Tarifasenvioserecios extends \App\Controllers\GoBaseResourceController {
|
||||
} // 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, 'tarifas_envios_precios')
|
||||
->fields(
|
||||
Field::inst('tipo_envio')
|
||||
->validator('Validate::required', array(
|
||||
'message' => lang('TarifasEnviosPrecios.validation.tipo_envio.required'))
|
||||
),
|
||||
Field::inst('peso_min')
|
||||
->validator('Validate::required', array(
|
||||
'message' => lang('TarifasEnviosPrecios.validation.peso_min.required'))
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('TarifasEnviosPrecios.validation.peso_min.decimal'))
|
||||
),
|
||||
Field::inst('peso_max')
|
||||
->validator('Validate::required', array(
|
||||
'message' => lang('TarifasEnviosPrecios.validation.peso_max.required'))
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('TarifasEnviosPrecios.validation.peso_max.decimal'))
|
||||
),
|
||||
Field::inst('precio')
|
||||
->validator('Validate::required', array(
|
||||
'message' => lang('TarifasEnviosPrecios.validation.precio.required'))
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('TarifasEnviosPrecios.validation.precio.decimal'))
|
||||
),
|
||||
Field::inst('precio_adicional')
|
||||
->validator('Validate::required', array(
|
||||
'message' => lang('TarifasEnviosPrecios.validation.precio_adicional.required'))
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('TarifasEnviosPrecios.validation.precio_adicional.decimal'))
|
||||
),
|
||||
Field::inst('zona_envio_id'),
|
||||
Field::inst('proveedor_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) {
|
||||
/*Los CP son string... consultar si checkear*/
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
->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();
|
||||
|
||||
$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()) {
|
||||
|
||||
@ -13,6 +13,8 @@ use App\Models\Tarifas\TarifaEnvioZonaModel;
|
||||
|
||||
use
|
||||
DataTables\Editor,
|
||||
|
||||
DataTables\Editor\Validate,
|
||||
DataTables\Editor\Field;
|
||||
|
||||
class Tarifasenvioszonas extends \App\Controllers\GoBaseResourceController {
|
||||
@ -36,6 +38,12 @@ class Tarifasenvioszonas extends \App\Controllers\GoBaseResourceController {
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('TarifasEnviosZonas.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;
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
@ -191,7 +199,7 @@ class Tarifasenvioszonas extends \App\Controllers\GoBaseResourceController {
|
||||
$this->viewData['tarifaEnvioZonaEntity'] = $tarifaEnvioZonaEntity;
|
||||
$this->viewData['tarifaEnvioList'] = $this->getTarifaEnvioListItems($tarifaEnvioZonaEntity->tarifa_envio_id ?? null);
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateTarifaEnvioZona', $id);
|
||||
$this->viewData['formAction'] = route_to('updateTarifaEnvioZona', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('TarifasEnviosZonas.moduleTitle').' '.lang('Basic.global.edit3');
|
||||
|
||||
@ -213,14 +221,14 @@ class Tarifasenvioszonas extends \App\Controllers\GoBaseResourceController {
|
||||
->validator('Validate::required', array(
|
||||
'message' => lang('TarifasEnviosZonas.validation.cp_inicial.required'))
|
||||
)
|
||||
->validator('Validate::maxLen(10)', array(
|
||||
->validator(Validate::maxLen(10), array(
|
||||
'message' => lang('TarifasEnviosZonas.validation.cp_inicial.max_length'))
|
||||
),
|
||||
Field::inst('cp_final')
|
||||
->validator('Validate::required', array(
|
||||
'message' => lang('TarifasEnviosZonas.validation.cp_final.required'))
|
||||
)
|
||||
->validator('Validate::maxLen(10)', array(
|
||||
->validator(Validate::maxLen(10), array(
|
||||
'message' => lang('TarifasEnviosZonas.validation.cp_final.max_length'))
|
||||
),
|
||||
Field::inst('importe_fijo')
|
||||
@ -296,8 +304,8 @@ class Tarifasenvioszonas extends \App\Controllers\GoBaseResourceController {
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$order = TarifaEnvioZonaModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
||||
$order = TarifaEnvioZonaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
Reference in New Issue
Block a user