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:
@ -410,16 +410,9 @@ $routes->resource('tarifasenvios', ['namespace' => 'App\Controllers\Tarifas', '
|
|||||||
|
|
||||||
|
|
||||||
$routes->group('tarifasenviosprecios', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
|
$routes->group('tarifasenviosprecios', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
|
||||||
/* $routes->get('', 'Tarifasenvioserecios::index', ['as' => 'tarifaEnvioPrecioList']);
|
$routes->post('datatable', 'Tarifasenvioserecios::datatable', ['as' => 'dataTableOfTarifasEnvioPrecios']);
|
||||||
$routes->get('add', 'Tarifasenvioserecios::add', ['as' => 'newTarifaEnvioPrecio']);
|
$routes->post('datatable_editor', 'Tarifasenvioserecios::datatable_editor', ['as' => 'editorOfTarifasEnvioPrecios']);
|
||||||
$routes->post('add', 'Tarifasenvioserecios::add', ['as' => 'createTarifaEnvioPrecio']);
|
});
|
||||||
$routes->post('create', 'Tarifasenvioserecios::create', ['as' => 'ajaxCreateTarifaEnvioPrecio']);
|
|
||||||
$routes->put('(:num)/update', 'Tarifasenvioserecios::update/$1', ['as' => 'ajaxUpdateTarifaEnvioPrecio']);
|
|
||||||
$routes->post('(:num)/edit', 'Tarifasenvioserecios::edit/$1', ['as' => 'updateTarifaEnvioPrecio']);
|
|
||||||
$routes->post('datatable', 'Tarifasenvioserecios::datatable', ['as' => 'dataTableOfTarifaEnvioPrecio']);
|
|
||||||
$routes->post('allmenuitems', 'Tarifasenvioserecios::allItemsSelect', ['as' => 'select2ItemsOfTarifaEnvioPrecio']);
|
|
||||||
$routes->post('menuitems', 'Tarifasenvioserecios::menuItems', ['as' => 'menuItemsOfTarifaEnvioPrecio']);
|
|
||||||
*/});
|
|
||||||
$routes->resource('tarifasenviosprecios', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasenvioserecios', 'except' => 'show,new,create,update']);
|
$routes->resource('tarifasenviosprecios', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasenvioserecios', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,8 @@ use App\Models\Collection;
|
|||||||
use App\Entities\Tarifas\TarifaEnvioEntity;
|
use App\Entities\Tarifas\TarifaEnvioEntity;
|
||||||
|
|
||||||
use App\Models\Configuracion\PaisModel;
|
use App\Models\Configuracion\PaisModel;
|
||||||
|
use App\Models\Compras\ProveedorModel;
|
||||||
|
use App\Models\Compras\ProveedorTipoModel;
|
||||||
|
|
||||||
use App\Models\Tarifas\TarifaEnvioModel;
|
use App\Models\Tarifas\TarifaEnvioModel;
|
||||||
|
|
||||||
@ -43,7 +45,7 @@ class Tarifasenvios extends \App\Controllers\GoBaseResourceController {
|
|||||||
// Breadcrumbs
|
// Breadcrumbs
|
||||||
$this->viewData['breadcrumb'] = [
|
$this->viewData['breadcrumb'] = [
|
||||||
['title' => lang("App.menu_tarifas"), 'route' => "javascript:void(0);", 'active' => false],
|
['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);
|
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');
|
$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);
|
return $this->displayForm(__METHOD__, $id);
|
||||||
} // end function edit(...)
|
} // end function edit(...)
|
||||||
@ -307,4 +311,12 @@ class Tarifasenvios extends \App\Controllers\GoBaseResourceController {
|
|||||||
return $data;
|
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 App\Models\Tarifas\TarifaEnvioPrecioModel;
|
||||||
|
|
||||||
|
use
|
||||||
|
DataTables\Editor,
|
||||||
|
DataTables\Editor\Field;
|
||||||
|
|
||||||
class Tarifasenvioserecios extends \App\Controllers\GoBaseResourceController {
|
class Tarifasenvioserecios extends \App\Controllers\GoBaseResourceController {
|
||||||
|
|
||||||
protected $modelName = TarifaEnvioPrecioModel::class;
|
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) {
|
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||||
$this->viewData['pageTitle'] = lang('TarifasEnviosPrecios.moduleTitle');
|
$this->viewData['pageTitle'] = lang('TarifasEnviosPrecios.moduleTitle');
|
||||||
$this->viewData['usingSweetAlert'] = true;
|
$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);
|
parent::initController($request, $response, $logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,6 +212,103 @@ class Tarifasenvioserecios extends \App\Controllers\GoBaseResourceController {
|
|||||||
} // end function edit(...)
|
} // 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() {
|
public function datatable() {
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
|
|||||||
@ -13,6 +13,8 @@ use App\Models\Tarifas\TarifaEnvioZonaModel;
|
|||||||
|
|
||||||
use
|
use
|
||||||
DataTables\Editor,
|
DataTables\Editor,
|
||||||
|
|
||||||
|
DataTables\Editor\Validate,
|
||||||
DataTables\Editor\Field;
|
DataTables\Editor\Field;
|
||||||
|
|
||||||
class Tarifasenvioszonas extends \App\Controllers\GoBaseResourceController {
|
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) {
|
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||||
$this->viewData['pageTitle'] = lang('TarifasEnviosZonas.moduleTitle');
|
$this->viewData['pageTitle'] = lang('TarifasEnviosZonas.moduleTitle');
|
||||||
$this->viewData['usingSweetAlert'] = true;
|
$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);
|
parent::initController($request, $response, $logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +199,7 @@ class Tarifasenvioszonas extends \App\Controllers\GoBaseResourceController {
|
|||||||
$this->viewData['tarifaEnvioZonaEntity'] = $tarifaEnvioZonaEntity;
|
$this->viewData['tarifaEnvioZonaEntity'] = $tarifaEnvioZonaEntity;
|
||||||
$this->viewData['tarifaEnvioList'] = $this->getTarifaEnvioListItems($tarifaEnvioZonaEntity->tarifa_envio_id ?? null);
|
$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');
|
$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(
|
->validator('Validate::required', array(
|
||||||
'message' => lang('TarifasEnviosZonas.validation.cp_inicial.required'))
|
'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'))
|
'message' => lang('TarifasEnviosZonas.validation.cp_inicial.max_length'))
|
||||||
),
|
),
|
||||||
Field::inst('cp_final')
|
Field::inst('cp_final')
|
||||||
->validator('Validate::required', array(
|
->validator('Validate::required', array(
|
||||||
'message' => lang('TarifasEnviosZonas.validation.cp_final.required'))
|
'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'))
|
'message' => lang('TarifasEnviosZonas.validation.cp_final.max_length'))
|
||||||
),
|
),
|
||||||
Field::inst('importe_fijo')
|
Field::inst('importe_fijo')
|
||||||
@ -296,8 +304,8 @@ class Tarifasenvioszonas extends \App\Controllers\GoBaseResourceController {
|
|||||||
$start = $reqData['start'] ?? 0;
|
$start = $reqData['start'] ?? 0;
|
||||||
$length = $reqData['length'] ?? 5;
|
$length = $reqData['length'] ?? 5;
|
||||||
$search = $reqData['search']['value'];
|
$search = $reqData['search']['value'];
|
||||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
||||||
$order = TarifaEnvioZonaModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
|
$order = TarifaEnvioZonaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||||
|
|
||||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||||
|
|||||||
@ -25,6 +25,7 @@ return [
|
|||||||
'userCreatedId' => 'User Created ID',
|
'userCreatedId' => 'User Created ID',
|
||||||
'userUpdatedId' => 'User Updated ID',
|
'userUpdatedId' => 'User Updated ID',
|
||||||
'validation' => [
|
'validation' => [
|
||||||
|
'error_seleccion_zonas' => 'A line from the zones table must be selected before creating a new record.',
|
||||||
'peso_max' => [
|
'peso_max' => [
|
||||||
'decimal' => 'The field must contain a decimal number.',
|
'decimal' => 'The field must contain a decimal number.',
|
||||||
'required' => 'The field is required.',
|
'required' => 'The field is required.',
|
||||||
|
|||||||
@ -13,8 +13,8 @@ return [
|
|||||||
'palets' => 'Palets',
|
'palets' => 'Palets',
|
||||||
'pesoMax' => 'Peso Max',
|
'pesoMax' => 'Peso Max',
|
||||||
'pesoMin' => 'Peso Min',
|
'pesoMin' => 'Peso Min',
|
||||||
'precio' => 'Precio',
|
'precio' => 'Precio peso mín.',
|
||||||
'precioAdicional' => 'Precio Adicional',
|
'precioAdicional' => 'Precio Kg Adicional',
|
||||||
'proveedorId' => 'Proveedor',
|
'proveedorId' => 'Proveedor',
|
||||||
'tarifaEnvioId' => 'Tarifa Envío',
|
'tarifaEnvioId' => 'Tarifa Envío',
|
||||||
'tarifaEnvioPrecio' => 'Peso y Precio',
|
'tarifaEnvioPrecio' => 'Peso y Precio',
|
||||||
@ -25,6 +25,7 @@ return [
|
|||||||
'userCreatedId' => 'User Created ID',
|
'userCreatedId' => 'User Created ID',
|
||||||
'userUpdatedId' => 'User Updated ID',
|
'userUpdatedId' => 'User Updated ID',
|
||||||
'validation' => [
|
'validation' => [
|
||||||
|
'error_seleccion_zonas' => 'Debe seleccionar una línea de la tabla zonas antes de crear un registro nuevo.',
|
||||||
'peso_max' => [
|
'peso_max' => [
|
||||||
'decimal' => 'El campo debe contener un número decimal.',
|
'decimal' => 'El campo debe contener un número decimal.',
|
||||||
'required' => 'El campo es obligatorio.',
|
'required' => 'El campo es obligatorio.',
|
||||||
|
|||||||
@ -13,16 +13,12 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
|
|||||||
protected $useAutoIncrement = true;
|
protected $useAutoIncrement = true;
|
||||||
|
|
||||||
const SORTABLE = [
|
const SORTABLE = [
|
||||||
1 => "t1.id",
|
0 => "t1.proveedor",
|
||||||
2 => "t1.tarifa_envio_id",
|
1 => "t1.tipo_envio",
|
||||||
3 => "t1.proveedor_id",
|
2 => "t1.peso_min",
|
||||||
4 => "t1.tipo_envio",
|
3 => "t1.peso_max",
|
||||||
5 => "t1.peso_min",
|
4 => "t1.precio",
|
||||||
6 => "t1.peso_max",
|
5 => "t1.precio_adicional"
|
||||||
7 => "t1.precio",
|
|
||||||
8 => "t1.precio_adicional",
|
|
||||||
9 => "t2.id",
|
|
||||||
10 => "t3.id",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $allowedFields = [
|
protected $allowedFields = [
|
||||||
@ -33,6 +29,8 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
|
|||||||
"peso_max",
|
"peso_max",
|
||||||
"precio",
|
"precio",
|
||||||
"precio_adicional",
|
"precio_adicional",
|
||||||
|
"deleted_at",
|
||||||
|
"is_deleted",
|
||||||
];
|
];
|
||||||
protected $returnType = "App\Entities\Tarifas\TarifaEnvioPrecioEntity";
|
protected $returnType = "App\Entities\Tarifas\TarifaEnvioPrecioEntity";
|
||||||
|
|
||||||
@ -123,9 +121,10 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
|
|||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS id, t1.tipo_envio AS tipo_envio, t1.peso_min AS peso_min, t1.peso_max AS peso_max, t1.precio AS precio, t1.precio_adicional AS precio_adicional, t2.id AS tarifa_envio, t3.id AS proveedor"
|
"t1.id AS id, t1.tipo_envio AS tipo_envio, t1.peso_min AS peso_min, t1.peso_max AS peso_max, t1.precio AS precio,
|
||||||
|
t1.precio_adicional AS precio_adicional, t2.id AS tarifa_envio, t3.id AS proveedor_id, t3.nombre AS proveedor"
|
||||||
);
|
);
|
||||||
$builder->join("lg_tarifas_envios t2", "t1.tarifa_envio_id = t2.id", "left");
|
$builder->join("tarifas_envios_zonas t2", "t1.zona_envio_id = t2.id", "left");
|
||||||
$builder->join("lg_proveedores t3", "t1.proveedor_id = t3.id", "left");
|
$builder->join("lg_proveedores t3", "t1.proveedor_id = t3.id", "left");
|
||||||
|
|
||||||
//JJO
|
//JJO
|
||||||
@ -135,24 +134,18 @@ class TarifaEnvioPrecioModel extends \App\Models\GoBaseModel
|
|||||||
? $builder
|
? $builder
|
||||||
: $builder
|
: $builder
|
||||||
->groupStart()
|
->groupStart()
|
||||||
->like("t1.id", $search)
|
->like("t1.tipo_envio", $search)
|
||||||
|
->orLike("t1.peso_min", $search)
|
||||||
|
->orLike("t1.peso_max", $search)
|
||||||
|
->orLike("t1.precio", $search)
|
||||||
|
->orLike("t1.precio_adicional", $search)
|
||||||
|
->orLike("t3.nombre", $search)
|
||||||
->orLike("t1.tipo_envio", $search)
|
->orLike("t1.tipo_envio", $search)
|
||||||
->orLike("t1.peso_min", $search)
|
->orLike("t1.peso_min", $search)
|
||||||
->orLike("t1.peso_max", $search)
|
->orLike("t1.peso_max", $search)
|
||||||
->orLike("t1.precio", $search)
|
->orLike("t1.precio", $search)
|
||||||
->orLike("t1.precio_adicional", $search)
|
->orLike("t1.precio_adicional", $search)
|
||||||
->orLike("t2.id", $search)
|
->orLike("t3.nombre", $search)
|
||||||
->orLike("t3.id", $search)
|
|
||||||
->orLike("t1.id", $search)
|
|
||||||
->orLike("t1.tarifa_envio_id", $search)
|
|
||||||
->orLike("t1.proveedor_id", $search)
|
|
||||||
->orLike("t1.tipo_envio", $search)
|
|
||||||
->orLike("t1.peso_min", $search)
|
|
||||||
->orLike("t1.peso_max", $search)
|
|
||||||
->orLike("t1.precio", $search)
|
|
||||||
->orLike("t1.precio_adicional", $search)
|
|
||||||
->orLike("t2.id", $search)
|
|
||||||
->orLike("t3.id", $search)
|
|
||||||
->groupEnd();
|
->groupEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,11 +13,9 @@ class TarifaEnvioZonaModel extends \App\Models\GoBaseModel
|
|||||||
protected $useAutoIncrement = true;
|
protected $useAutoIncrement = true;
|
||||||
|
|
||||||
const SORTABLE = [
|
const SORTABLE = [
|
||||||
1 => "t1.tarifa_envio_id",
|
0 => "t1.cp_inicial",
|
||||||
2 => "t1.cp_inicial",
|
1 => "t1.cp_final",
|
||||||
3 => "t1.cp_final",
|
2 => "t1.importe_fijo",
|
||||||
4 => "t1.importe_fijo",
|
|
||||||
5 => "t2.id",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $allowedFields = ["tarifa_envio_id", "cp_inicial", "cp_final", "importe_fijo"];
|
protected $allowedFields = ["tarifa_envio_id", "cp_inicial", "cp_final", "importe_fijo"];
|
||||||
@ -109,12 +107,9 @@ class TarifaEnvioZonaModel extends \App\Models\GoBaseModel
|
|||||||
->like("t1.cp_inicial", $search)
|
->like("t1.cp_inicial", $search)
|
||||||
->orLike("t1.cp_final", $search)
|
->orLike("t1.cp_final", $search)
|
||||||
->orLike("t1.importe_fijo", $search)
|
->orLike("t1.importe_fijo", $search)
|
||||||
->orLike("t2.id", $search)
|
|
||||||
->orLike("t1.tarifa_envio_id", $search)
|
|
||||||
->orLike("t1.cp_inicial", $search)
|
->orLike("t1.cp_inicial", $search)
|
||||||
->orLike("t1.cp_final", $search)
|
->orLike("t1.cp_final", $search)
|
||||||
->orLike("t1.importe_fijo", $search)
|
->orLike("t1.importe_fijo", $search)
|
||||||
->orLike("t2.id", $search)
|
|
||||||
->groupEnd();
|
->groupEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,10 +16,15 @@
|
|||||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||||
<?= view("themes/backend/vuexy/form/tarifas/envios/_tarifaEnvioFormItems") ?>
|
<?= view("themes/backend/vuexy/form/tarifas/envios/_tarifaEnvioFormItems") ?>
|
||||||
</div><!-- /.card-body -->
|
</div><!-- /.card-body -->
|
||||||
<div class="card-footer">
|
<div class="pt-4">
|
||||||
<?= anchor(route_to("tarifaEnvioList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
|
<input type="submit"
|
||||||
<input type="submit" class="btn btn-primary float-end" name="save" value="<?= lang("Basic.global.Save") ?>">
|
class="btn btn-primary float-start me-sm-3 me-1"
|
||||||
|
name="save"
|
||||||
|
value="<?= lang("Basic.global.Save") ?>"
|
||||||
|
/>
|
||||||
|
<?= anchor(route_to("tarifaEnvioList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start",]) ?>
|
||||||
</div><!-- /.card-footer -->
|
</div><!-- /.card-footer -->
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div><!-- //.card -->
|
</div><!-- //.card -->
|
||||||
</div><!--//.col -->
|
</div><!--//.col -->
|
||||||
@ -54,6 +59,38 @@
|
|||||||
</div>
|
</div>
|
||||||
</div> <!-- //.accordion -->
|
</div> <!-- //.accordion -->
|
||||||
|
|
||||||
|
|
||||||
|
<div class="accordion mt-3" id="accordionPrecios" style="visibility:visible" >
|
||||||
|
<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="#accordionTip2" aria-expanded="false" aria-controls="accordionTip2">
|
||||||
|
<h3><?= lang("TarifasEnviosPrecios.moduleTitle") ?></h3>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div id="accordionTip2" class="accordion-collapse collapse show" data-bs-parent="#accordionPrecios">
|
||||||
|
<div class="accordion-body">
|
||||||
|
|
||||||
|
<table id="tableOfPrecios" class="table table-striped table-hover" style="width: 100%;">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?= lang('TarifasEnviosPrecios.proveedorId') ?></th>
|
||||||
|
<th><?= lang('TarifasEnviosPrecios.tipoEnvio') ?></th>
|
||||||
|
<th><?= lang('TarifasEnviosPrecios.pesoMin') ?></th>
|
||||||
|
<th><?= lang('TarifasEnviosPrecios.pesoMax') ?></th>
|
||||||
|
<th><?= lang('TarifasEnviosPrecios.precio') ?></th>
|
||||||
|
<th><?= lang('TarifasEnviosPrecios.precioAdicional') ?></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div> <!-- //.accordion -->
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
</div><!--//.row -->
|
</div><!--//.row -->
|
||||||
@ -109,11 +146,11 @@
|
|||||||
const row = $(this).closest('tr');
|
const row = $(this).closest('tr');
|
||||||
if ($.isNumeric(dataId)) {
|
if ($.isNumeric(dataId)) {
|
||||||
|
|
||||||
if($(this).attr('table').includes('tiradas')){
|
if($(this).attr('table').includes('zonas')){
|
||||||
remove_tiradas(dataId, row);
|
remove_zonas(dataId, row);
|
||||||
}
|
}
|
||||||
else if ($(this).attr('table').includes('lineas')){
|
else if ($(this).attr('table').includes('precios')){
|
||||||
remove_lineas(dataId, row);
|
remove_precios(dataId, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -253,7 +290,7 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
// Delete row
|
// Delete row
|
||||||
function remove_lineas(dataId, row){
|
function remove_zonas(dataId, row){
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/tarifas/tarifasenvioszonas/delete/${dataId}`,
|
url: `/tarifas/tarifasenvioszonas/delete/${dataId}`,
|
||||||
@ -287,10 +324,190 @@
|
|||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
|
||||||
|
<!------------------------------------------->
|
||||||
|
<!-- Código JS para tableOfPrecios -->
|
||||||
|
<!------------------------------------------->
|
||||||
|
<?= $this->section("additionalInlineJs") ?>
|
||||||
|
const lastColNr2 = $('#tableOfPrecios').find("tr:first th").length - 1;
|
||||||
|
|
||||||
|
var editor2 = new $.fn.dataTable.Editor( {
|
||||||
|
ajax: {
|
||||||
|
url: "<?= route_to('editorOfTarifasEnvioPrecios') ?>",
|
||||||
|
headers: {
|
||||||
|
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
table : "#tableOfPrecios",
|
||||||
|
idSrc: 'id',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
"name": "proveedor_id",
|
||||||
|
"type": "select"
|
||||||
|
}, {
|
||||||
|
name: "tipo_envio"
|
||||||
|
}, {
|
||||||
|
name: "peso_min"
|
||||||
|
}, {
|
||||||
|
name: "peso_max"
|
||||||
|
}, {
|
||||||
|
name: "precio"
|
||||||
|
}, {
|
||||||
|
name: "precio_adicional"
|
||||||
|
}, {
|
||||||
|
"name": "zona_envio_id",
|
||||||
|
"type": "hidden"
|
||||||
|
}, {
|
||||||
|
"name": "proveedor_id",
|
||||||
|
"type": "hidden"
|
||||||
|
}, {
|
||||||
|
"name": "deleted_at",
|
||||||
|
"type": "hidden"
|
||||||
|
},{
|
||||||
|
"name": "is_deleted",
|
||||||
|
"type": "hidden"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
} );
|
||||||
|
|
||||||
|
// Generación de la lista de proveedores (id, nombre) para encuadernación
|
||||||
|
const suppliersList = <?php echo json_encode($proveedores); ?>;
|
||||||
|
editor2.field( 'proveedor_id' ).update( suppliersList );
|
||||||
|
|
||||||
|
editor2.on( 'preSubmit', function ( e, d, type ) {
|
||||||
|
if ( type === 'create'){
|
||||||
|
d.data[0]['zona_envio_id'] = selected_zona_id;
|
||||||
|
}
|
||||||
|
else if(type === 'edit' ) {
|
||||||
|
for (v in d.data){
|
||||||
|
d.data[v]['zona_envio_id'] = selected_zona_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
editor2.on( 'postSubmit', function ( e, json, data, action ) {
|
||||||
|
|
||||||
|
yeniden(json.<?= csrf_token() ?>);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
editor2.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||||
|
|
||||||
|
theTable2.clearPipeline();
|
||||||
|
theTable2.draw();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var theTable2 = $('#tableOfPrecios').DataTable( {
|
||||||
|
serverSide: true,
|
||||||
|
processing: true,
|
||||||
|
autoWidth: true,
|
||||||
|
responsive: true,
|
||||||
|
lengthMenu: [ 5, 10, 25, 50, 100],
|
||||||
|
order: [[ 0, "asc" ], [ 1, "asc" ]],
|
||||||
|
pageLength: 25,
|
||||||
|
lengthChange: true,
|
||||||
|
searching: false,
|
||||||
|
paging: true,
|
||||||
|
info: false,
|
||||||
|
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
|
||||||
|
ajax : $.fn.dataTable.pipeline( {
|
||||||
|
url: '<?= route_to('dataTableOfTarifasEnvioPrecios') ?>',
|
||||||
|
data: function ( d ) {
|
||||||
|
d.zona_envio_id = selected_zona_id;
|
||||||
|
},
|
||||||
|
method: 'POST',
|
||||||
|
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||||
|
async: true,
|
||||||
|
}),
|
||||||
|
columns: [
|
||||||
|
{ 'data': 'proveedor' },
|
||||||
|
{ 'data': 'tipo_envio' },
|
||||||
|
{ 'data': 'peso_min' },
|
||||||
|
{ 'data': 'peso_max' },
|
||||||
|
{ 'data': 'precio' },
|
||||||
|
{ 'data': 'precio_adicional' },
|
||||||
|
{
|
||||||
|
data: actionBtns,
|
||||||
|
className: 'row-edit dt-center'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
columnDefs: [
|
||||||
|
{
|
||||||
|
orderable: false,
|
||||||
|
searchable: false,
|
||||||
|
targets: [lastColNr2]
|
||||||
|
},
|
||||||
|
{"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: editor2,
|
||||||
|
formOptions: {
|
||||||
|
submitTrigger: -1,
|
||||||
|
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
|
||||||
|
|
||||||
|
},
|
||||||
|
action: function ( e, dt, node, config ) {
|
||||||
|
if(selected_zona_id == -1){
|
||||||
|
popErrorAlert("<?= lang('TarifasEnviosPrecios.validation.error_seleccion_zonas') ?>");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
formOptions= {
|
||||||
|
submitTrigger: -1,
|
||||||
|
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
|
||||||
|
|
||||||
|
};
|
||||||
|
editor2.inlineCreate(config.position, formOptions);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
} ],
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
// Activate an inline edit on click of a table cell
|
||||||
|
$('#tableOfPrecios').on( 'click', 'tbody span.edit', function (e) {
|
||||||
|
editor.inline(
|
||||||
|
theTable2.cells(this.parentNode.parentNode, '*').nodes(),
|
||||||
|
{
|
||||||
|
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
|
||||||
|
cancelTrigger: 'span.cancel',
|
||||||
|
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||||
|
submitTrigger: 'span.edit',
|
||||||
|
submit: 'allIfChanged'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} );
|
||||||
|
|
||||||
|
// Delete row
|
||||||
|
function remove_precios(dataId, row){
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: `/tarifas/tarifasenviosprecios/delete/${dataId}`,
|
||||||
|
method: 'GET',
|
||||||
|
}).done((data, textStatus, jqXHR) => {
|
||||||
|
$('#confirm2delete').modal('toggle');
|
||||||
|
theTable2.clearPipeline();
|
||||||
|
theTable2.row($(row)).invalidate().draw();
|
||||||
|
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||||
|
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||||
|
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
<?=$this->section('css') ?>
|
<?=$this->section('css') ?>
|
||||||
|
|
||||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
|
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
|
||||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap5.min.css">
|
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap5.min.css">
|
||||||
|
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/sk-datatables.css') ?>">
|
||||||
|
|
||||||
<?=$this->endSection() ?>
|
<?=$this->endSection() ?>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user