mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminadas tarifas cliente
This commit is contained in:
@ -394,6 +394,8 @@ $routes->group('clientes', ['namespace' => 'App\Controllers\Clientes'], function
|
||||
$routes->group('clienteprecios', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
||||
$routes->post('datatable', 'ClientePrecios::datatable', ['as' => 'dataTableOfClienteprecios']);
|
||||
$routes->post('datatable_editor', 'ClientePrecios::datatable_editor', ['as' => 'editorOfClienteprecios']);
|
||||
$routes->post('changeplantilla', 'ClientePrecios::updatePlantilla', ['as' => 'changePlantillaOfClienteprecios']);
|
||||
$routes->get('getplantilla', 'ClientePrecios::getCurrentPlantilla', ['as' => 'getPlantillaOfClienteprecios']);
|
||||
});
|
||||
$routes->resource('clienteprecios', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'ClientePrecios', 'except' => 'show,new,create,update']);
|
||||
|
||||
@ -405,7 +407,7 @@ $routes->group('clienteplantillaprecios', ['namespace' => 'App\Controllers\Clien
|
||||
$routes->post('edit/(:num)', 'Clienteplantillaprecios::edit/$1', ['as' => 'updateClienteplantillaprecios']);
|
||||
$routes->get('delete/(:num)', 'Clienteplantillaprecios::delete/$1', ['as' => 'deleteClienteplantillaprecios']);
|
||||
$routes->post('datatable', 'Clienteplantillaprecios::datatable', ['as' => 'dataTableOfClientesplantillaprecios']);
|
||||
$routes->post('menuitems', 'Clienteplantillaprecios::menuItems', ['as' => 'menuItemsOfClienteplantillaprecios']);
|
||||
$routes->get('menuitems', 'Clienteplantillaprecios::menuItems', ['as' => 'menuItemsOfClienteplantillaprecios']);
|
||||
});
|
||||
$routes->resource('clienteplantillaprecios', ['namespace' => 'App\Controllers\Clientes', 'controller' => 'Clienteplantillaprecios', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php namespace App\Controllers\Clientes;
|
||||
<?php
|
||||
namespace App\Controllers\Clientes;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
@ -45,40 +46,36 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
public function update($requestedId = null)
|
||||
public function updatePlantilla()
|
||||
{
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($requestedId == null) :
|
||||
return;
|
||||
endif;
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$postData = $this->request->getJSON();
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$cliente_id = $postData['cliente_id'] ?? -1;
|
||||
$plantilla_id = $postData['plantilla_id'] ?? -1;
|
||||
|
||||
$plantilla_id = $postData->plantilla_id ?? -1;
|
||||
|
||||
// Se ha actualizado un registro por lo que no es una plantilla
|
||||
if($plantilla_id == -1){
|
||||
$this->model->clean_plantilla_id($requestedId);
|
||||
}
|
||||
else if($requestedId== -1){ // actualizar todos los clientes que usan una plantilla
|
||||
if ($plantilla_id == -1) {
|
||||
$this->model->clean_plantilla_id($cliente_id);
|
||||
} else if ($cliente_id == -1) { // actualizar todos los clientes que usan una plantilla
|
||||
$this->model->update_from_plantilla($plantilla_id);
|
||||
} else {
|
||||
$this->model->copy_from_plantilla($cliente_id, $plantilla_id);
|
||||
}
|
||||
else{
|
||||
$this->model->copy_from_plantilla($requestedId, $plantilla_id);
|
||||
}
|
||||
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
|
||||
return $this->respond($data);
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -106,11 +103,11 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
$dir2 = $reqData['order']['1']['dir'] ?? $dir;
|
||||
$dir3 = $reqData['order']['2']['dir'] ?? $dir;
|
||||
$dir4= $reqData['order']['3']['dir'] ?? $dir;
|
||||
$dir5= $reqData['order']['4']['dir'] ?? $dir;
|
||||
$dir4 = $reqData['order']['3']['dir'] ?? $dir;
|
||||
$dir5 = $reqData['order']['4']['dir'] ?? $dir;
|
||||
|
||||
$searchValues = get_filter_datatables_columns($reqData);
|
||||
|
||||
|
||||
$cliente_id = $reqData['cliente_id'] ?? 0;
|
||||
|
||||
$resourceData = $this->model->getResource($searchValues, $cliente_id)
|
||||
@ -126,61 +123,86 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function datatable_editor() {
|
||||
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, 'cliente_precios' )
|
||||
$response = Editor::inst($db, 'cliente_precios')
|
||||
->fields(
|
||||
Field::inst( 'plantilla_id' ),
|
||||
Field::inst( 'cliente_id' ),
|
||||
Field::inst( 'tipo' ),
|
||||
Field::inst( 'tipo_maquina' ),
|
||||
Field::inst( 'tipo_impresion' ),
|
||||
Field::inst( 'user_updated_id' ),
|
||||
Field::inst( 'updated_at' ),
|
||||
Field::inst( 'is_deleted' ),
|
||||
Field::inst( 'tiempo_min' )
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('ClientePrecios.validation.required'))
|
||||
Field::inst('plantilla_id'),
|
||||
Field::inst('cliente_id'),
|
||||
Field::inst('tipo'),
|
||||
Field::inst('tipo_maquina'),
|
||||
Field::inst('tipo_impresion'),
|
||||
Field::inst('user_updated_id'),
|
||||
Field::inst('updated_at'),
|
||||
Field::inst('is_deleted'),
|
||||
Field::inst('tiempo_min')
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClientePrecios.validation.required')
|
||||
)
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal'))
|
||||
'message' => lang('ClientePrecios.validation.decimal')
|
||||
)
|
||||
),
|
||||
|
||||
Field::inst( 'tiempo_max' )
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('ClientePrecios.validation.required'))
|
||||
|
||||
Field::inst('tiempo_max')
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClientePrecios.validation.required')
|
||||
)
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal'))
|
||||
),
|
||||
|
||||
Field::inst( 'precio_hora' )
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('ClientePrecios.validation.required'))
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal'))
|
||||
),
|
||||
|
||||
Field::inst( 'margen' )
|
||||
->getFormatter( 'Format::toDecimalChar')->setFormatter( 'Format::fromDecimalChar')
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('ClientePrecios.validation.required'))
|
||||
)
|
||||
->validator('Validate::numeric', array(
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal'))
|
||||
'message' => lang('ClientePrecios.validation.decimal')
|
||||
)
|
||||
),
|
||||
|
||||
Field::inst('precio_hora')
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClientePrecios.validation.required')
|
||||
)
|
||||
)
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal')
|
||||
)
|
||||
),
|
||||
|
||||
Field::inst('margen')
|
||||
->getFormatter('Format::toDecimalChar')->setFormatter('Format::fromDecimalChar')
|
||||
->validator(
|
||||
'Validate::notEmpty',
|
||||
array(
|
||||
'message' => lang('ClientePrecios.validation.required')
|
||||
)
|
||||
)
|
||||
->validator(
|
||||
'Validate::numeric',
|
||||
array(
|
||||
"decimal" => ',',
|
||||
'message' => lang('ClientePrecios.validation.decimal')
|
||||
)
|
||||
),
|
||||
|
||||
)
|
||||
@ -238,4 +260,16 @@ class ClientePrecios extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function getCurrentPlantilla()
|
||||
{
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$cliente_id = $this->request->getGet('cliente_id');
|
||||
$plantilla = $this->model->getPlantilla($cliente_id);
|
||||
return $this->respond($plantilla);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php namespace App\Controllers\Clientes;
|
||||
<?php
|
||||
namespace App\Controllers\Clientes;
|
||||
|
||||
|
||||
use App\Controllers\BaseResourceController;
|
||||
@ -70,22 +71,22 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
|
||||
// plantilla desde la lista
|
||||
public function update($requestedId = null)
|
||||
{
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($requestedId == null) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
if ($requestedId == null):
|
||||
return;
|
||||
endif;
|
||||
$model = model('App\Models\Clientes\ClientePlantillaPreciosLineasModel');
|
||||
$model->delete_values($requestedId);
|
||||
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
|
||||
|
||||
return $this->respond($data);
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
@ -95,26 +96,27 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
|
||||
public function add()
|
||||
{
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$cliente_id = $postData['cliente_id'] ?? -1;
|
||||
|
||||
$from_client_data = $postData['from_client_data'] ?? 0;
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_created_id'] = auth()->user()->id;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -126,24 +128,27 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
|
||||
$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
|
||||
if ($from_client_data == 1) {
|
||||
$thenRedirect = false;
|
||||
} else {
|
||||
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
|
||||
}
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if($cliente_id != -1){
|
||||
if ($cliente_id != -1) {
|
||||
$modelLineas = model('App\Models\Clientes\ClientePlantillaPreciosLineasModel');
|
||||
$modelLineas->copy_from_cliente($cliente_id, $id);
|
||||
$modelClientePrecios = model('App\Models\Clientes\ClientePreciosModel');
|
||||
$modelClientePrecios->set_plantilla_id($cliente_id, $id);
|
||||
return ;
|
||||
}
|
||||
else{
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return $this->respond(['status' => 'success', 'id' => $id]);
|
||||
} else {
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
//return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
return redirect()->to(site_url('/clientes/clienteplantillaprecios/edit/' . $id))->with('message', $message);
|
||||
else:
|
||||
@ -171,35 +176,35 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
|
||||
{
|
||||
|
||||
|
||||
if ($requestedId == null) :
|
||||
if ($requestedId == null):
|
||||
return $this->redirect2listView();
|
||||
endif;
|
||||
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
|
||||
$clientePlantillaPreciosEntity = $this->model->find($id);
|
||||
|
||||
if ($clientePlantillaPreciosEntity == false) :
|
||||
if ($clientePlantillaPreciosEntity == false):
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Clientes.cliente')), $id]);
|
||||
return $this->redirect2listView('sweet-error', $message);
|
||||
endif;
|
||||
|
||||
|
||||
|
||||
if ($this->request->getPost()) :
|
||||
|
||||
if ($this->request->getPost()):
|
||||
|
||||
$nullIfEmpty = true; // !(phpversion() >= '8.1');
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
|
||||
|
||||
|
||||
// JJO
|
||||
$sanitizedData['user_updated_id'] = auth()->user()->id;
|
||||
|
||||
$noException = true;
|
||||
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
if ($successfulResult = $this->canValidate()): // if ($successfulResult = $this->validate($this->formValidationRules) ) :
|
||||
|
||||
|
||||
if ($this->canValidate()) :
|
||||
if ($this->canValidate()):
|
||||
try {
|
||||
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
|
||||
} catch (\Exception $e) {
|
||||
@ -216,12 +221,12 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
|
||||
|
||||
$thenRedirect = false;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
if ($noException && $successfulResult):
|
||||
$id = $clientePlantillaPreciosEntity->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
if ($thenRedirect):
|
||||
if (!empty($this->indexRoute)):
|
||||
return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
|
||||
else:
|
||||
return $this->redirect2listView('sweet-success', $message);
|
||||
@ -236,7 +241,7 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
|
||||
//var_dump($clientePlantillaPreciosEntity); dd();
|
||||
|
||||
$this->viewData['clienteplantillapreciosEntity'] = $clientePlantillaPreciosEntity;
|
||||
|
||||
|
||||
$this->viewData['formAction'] = route_to('updateClienteplantillaprecios', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Clientes.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
@ -275,34 +280,32 @@ class Clienteplantillaprecios extends \App\Controllers\BaseResourceController
|
||||
|
||||
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 ?? 'nombre'];
|
||||
$onlyActiveOnes = false;
|
||||
try{
|
||||
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr, true);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->text = '- ' . lang('Basic.global.None') . ' -';
|
||||
array_unshift($menu, $nonItem);
|
||||
}
|
||||
catch(Exception $e){
|
||||
$menu = [];
|
||||
$query = $this->model->builder()->select(
|
||||
[
|
||||
"id",
|
||||
"nombre as name"
|
||||
]
|
||||
)->where("deleted_at", null);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("cliente_plantilla_precios.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'menu' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
$items = $query->get()->getResultObject();
|
||||
// add a custom item at the beginning
|
||||
$customItem = new \stdClass;
|
||||
$customItem->id = 0;
|
||||
$customItem->name = "Personalizado";
|
||||
array_unshift($items, $customItem);
|
||||
|
||||
return $this->response->setJSON($items);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -183,14 +183,13 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
|
||||
|
||||
function copy_from_cliente($cliente_id = 0, $plantilla_id = 0){
|
||||
|
||||
$session = session();
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
$date_value = $datetime->format('Y-m-d H:i:s');
|
||||
|
||||
|
||||
// Se cargan los valores en la plantilla
|
||||
$clientePreciosModel = model('App\Models\Clientes\ClientePreciosModel');
|
||||
$values = $clientePreciosModel->getResource($cliente_id)->get()->getResultObject();
|
||||
$values = $clientePreciosModel->getResource([], $cliente_id)->get()->getResultObject();
|
||||
foreach ($values as $value) {
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
@ -201,7 +200,7 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
|
||||
->set('tiempo_min', $value->tiempo_min)
|
||||
->set('tiempo_max', $value->tiempo_max)
|
||||
->set('margen', $value->margen)
|
||||
->set('user_updated_id', $session->id_user)
|
||||
->set('user_updated_id', auth()->user()->id)
|
||||
->set('updated_at', $date_value)
|
||||
->insert();
|
||||
}
|
||||
|
||||
@ -287,6 +287,27 @@ class ClientePreciosModel extends \App\Models\BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
public function getPlantilla($cliente_id = -1){
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.plantilla_id AS id, t2.nombre AS nombre"
|
||||
);
|
||||
|
||||
$builder->where('t1.is_deleted', 0);
|
||||
$builder->where('t1.cliente_id', $cliente_id);
|
||||
$builder->join("cliente_plantilla_precios t2", "t1.plantilla_id = t2.id", "left");
|
||||
$builder->limit(1);
|
||||
|
||||
$values = $builder->get()->getResultArray();
|
||||
if(count($values)>0){
|
||||
return $values[0];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function checkIntervals($data = [], $id_linea = null, $cliente_id = null){
|
||||
|
||||
|
||||
@ -561,7 +561,6 @@
|
||||
|
||||
<?php if ($formAction !== route_to('clienteAdd')){ ?>
|
||||
<div class="tab-pane fade" id="tarifascliente" role="tabpanel">
|
||||
<?= view("themes/vuexy/form/clientes/cliente/convert2templateModal") ?>
|
||||
<div class='row'>
|
||||
<div class="col-md-12 col-lg-4 px-4">
|
||||
<div class="mb-3">
|
||||
@ -885,7 +884,7 @@ $(document).on('click', '.btn-remove', function(e) {
|
||||
/**************************************
|
||||
Tarifas cliente
|
||||
***************************************/
|
||||
|
||||
/*
|
||||
$('#plantillas').select2({
|
||||
allowClear: false,
|
||||
ajax: {
|
||||
@ -915,280 +914,7 @@ $(document).on('click', '.btn-remove', function(e) {
|
||||
}
|
||||
});
|
||||
|
||||
const lastColNr_lineas = $('#tableOfPrecios').find("tr:first th").length - 1;
|
||||
|
||||
const actionBtns_lineas = function(data) {
|
||||
return `
|
||||
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
<span class="cancel"></span>
|
||||
`;
|
||||
};
|
||||
|
||||
/*
|
||||
const tipo_linea = [
|
||||
{label:'<?= lang('ClientePrecios.interior') ?>', value:'interior'},
|
||||
{label:'<?= lang('ClientePrecios.cubierta') ?>', value: 'cubierta'},
|
||||
{label:'<?= lang('ClientePrecios.sobrecubierta') ?>', value: 'sobrecubierta'}
|
||||
];
|
||||
|
||||
const tipo_maquina = [
|
||||
{label: '<?= lang('ClientePrecios.toner') ?>', value:'toner'},
|
||||
{label: '<?= lang('ClientePrecios.inkjet') ?>', value:'inkjet'},
|
||||
];
|
||||
|
||||
const tipo_impresion = [
|
||||
{label: '<?= lang('ClientePrecios.negro') ?>', value:'negro'},
|
||||
{label: '<?= lang('ClientePrecios.negrohq') ?>', value:'negrohq'},
|
||||
{label: '<?= lang('ClientePrecios.color') ?>', value:'color'},
|
||||
{label: '<?= lang('ClientePrecios.colorhq') ?>', value:'colorhq'},
|
||||
];
|
||||
|
||||
var editorPrecios = new $.fn.dataTable.Editor( {
|
||||
ajax: {
|
||||
url: "<?= route_to('editorOfClienteprecios') ?>",
|
||||
headers: {
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
||||
},
|
||||
},
|
||||
table : "#tableOfPrecios",
|
||||
idSrc: 'id',
|
||||
fields: [ {
|
||||
name: "tipo",
|
||||
type: "select",
|
||||
options: tipo_linea
|
||||
}, {
|
||||
name: "tipo_maquina",
|
||||
type: "select",
|
||||
options: tipo_maquina
|
||||
}, {
|
||||
name: "tipo_impresion",
|
||||
type: "select",
|
||||
options: tipo_impresion
|
||||
}, {
|
||||
name: "tiempo_min"
|
||||
}, {
|
||||
name: "tiempo_max"
|
||||
}, {
|
||||
name: "precio_hora"
|
||||
}, {
|
||||
name: "margen"
|
||||
}, {
|
||||
name: "user_updated_id",
|
||||
type:'hidden',
|
||||
|
||||
}, {
|
||||
name: "updated_at",
|
||||
type:'hidden',
|
||||
|
||||
}, {
|
||||
"name": "plantilla_id",
|
||||
"type": "hidden"
|
||||
},{
|
||||
"name": "cliente_id",
|
||||
"type": "hidden"
|
||||
},{
|
||||
"name": "deleted_at",
|
||||
"type": "hidden"
|
||||
},{
|
||||
"name": "is_deleted",
|
||||
"type": "hidden"
|
||||
},
|
||||
]
|
||||
} );
|
||||
|
||||
editorPrecios.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['cliente_id'] = id;
|
||||
}
|
||||
else if(type === 'edit' ) {
|
||||
for (v in d.data){
|
||||
d.data[v]['cliente_id'] = id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
editorPrecios.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
|
||||
yeniden(json.<?= csrf_token() ?>);
|
||||
|
||||
});
|
||||
|
||||
editorPrecios.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
|
||||
theTablePrecios.clearPipeline();
|
||||
theTablePrecios.draw();
|
||||
});
|
||||
|
||||
editorPrecios.on ('postEdit', function ( e, json, data, action ) {
|
||||
const domain = window.location.origin
|
||||
fetch(domain + "/clientes/clienteprecios/update/" + id , {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
}),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
editorPrecios.on ('postCreate', function ( e, json, data, action ) {
|
||||
const domain = window.location.origin
|
||||
fetch(domain + "/clientes/clienteprecios/update/" + id , {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
}),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
})
|
||||
})
|
||||
*/
|
||||
/*
|
||||
|
||||
var theTablePrecios = $('#tableOfPrecios').DataTable( {
|
||||
serverSide: true,
|
||||
processing: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
lengthMenu: [ 10, 25, 50, 100],
|
||||
order: [[ 0, "asc" ], [ 1, "asc" ], [ 2, "asc" ], [ 3, "asc" ]],
|
||||
pageLength: 50,
|
||||
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('dataTableOfClienteprecios') ?>',
|
||||
data: {
|
||||
cliente_id: id,
|
||||
},
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columns: [
|
||||
{ 'data': 'tipo' ,
|
||||
'render': function ( data, type, row, meta ) {
|
||||
if(data=='interior')
|
||||
return '<?= lang('ClientePrecios.interior') ?>';
|
||||
else if(data=='cubierta')
|
||||
return '<?= lang('ClientePrecios.cubierta') ?>';
|
||||
else if(data=='sobrecubierta')
|
||||
return '<?= lang('ClientePrecios.sobrecubierta') ?>';
|
||||
}
|
||||
},
|
||||
{ 'data': 'tipo_maquina',
|
||||
'render': function ( data, type, row, meta ) {
|
||||
if(data=='toner')
|
||||
return '<?= lang('ClientePrecios.toner') ?>';
|
||||
else if(data=='inkjet')
|
||||
return '<?= lang('ClientePrecios.inkjet') ?>';
|
||||
}
|
||||
},
|
||||
{ 'data': 'tipo_impresion',
|
||||
'render': function ( data, type, row, meta ) {
|
||||
if(data=='negro')
|
||||
return '<?= lang('ClientePrecios.negro') ?>';
|
||||
else if(data=='negrohq')
|
||||
return '<?= lang('ClientePrecios.negrohq') ?>';
|
||||
else if(data=='color')
|
||||
return '<?= lang('ClientePrecios.color') ?>';
|
||||
else if(data=='colorhq')
|
||||
return '<?= lang('ClientePrecios.colorhq') ?>';
|
||||
}
|
||||
},
|
||||
{ 'data': 'tiempo_min' },
|
||||
{ 'data': 'tiempo_max' },
|
||||
{ 'data': 'precio_hora' },
|
||||
{ 'data': 'margen' },
|
||||
{ 'data': 'user_updated_id',
|
||||
'render': function ( data, type, row, meta ) {
|
||||
return row.user_updated
|
||||
}
|
||||
},
|
||||
{ 'data': 'updated_at' },
|
||||
{ 'data': 'plantilla_id' },
|
||||
{
|
||||
data: actionBtns_lineas,
|
||||
className: 'row-edit dt-center'
|
||||
}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
target: 9,
|
||||
orderable: false,
|
||||
visible: false,
|
||||
searchable: false
|
||||
},
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr_lineas]
|
||||
},
|
||||
{"orderData": [ 0, 1 ], "targets": 0 },
|
||||
|
||||
],
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
buttons: [ {
|
||||
className: 'btn btn-primary me-sm-3 me-1',
|
||||
extend: "createInline",
|
||||
editor: editorPrecios,
|
||||
formOptions: {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
|
||||
}
|
||||
} ]
|
||||
} );
|
||||
*/
|
||||
|
||||
const initPrecioTemplate = <?php echo json_encode($precioTemplate);?>;
|
||||
if(initPrecioTemplate != null){
|
||||
var newOption = new Option(initPrecioTemplate.label, initPrecioTemplate.value, false, false);
|
||||
$('#plantillas').append(newOption);
|
||||
}
|
||||
|
||||
/*
|
||||
// Activate an inline edit on click of a table cell
|
||||
$('#tableOfPrecios').on( 'click', 'tbody span.edit', function (e) {
|
||||
editorPrecios.inline(
|
||||
theTablePrecios.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
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||
$(".btn-remove").attr('table-id', '#tableOfPrecios');
|
||||
$(".btn-remove").attr('row', $(this).closest('tr')[0]._DT_RowIndex);
|
||||
});
|
||||
|
||||
function delete_precio(dataId, row){
|
||||
if ($.isNumeric(dataId)) {
|
||||
editorPrecios
|
||||
.create( false )
|
||||
.edit( theTablePrecios.rows(row), false)
|
||||
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
|
||||
.set( 'is_deleted', 1 )
|
||||
.submit();
|
||||
$('#confirm2delete').modal('toggle');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$('#plantillas').on('change.select2', function(){
|
||||
const data = $('#plantillas').select2('data');
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
<div id="convert2Template" class="modal fade addModal">
|
||||
<div class="modal-dialog modal-lg modal-simple">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 id="labelTitleConfirmDialog" class="modal-title"><?= lang('ClientePrecios.convertir2plantilla') ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id='error-nombre'></div>
|
||||
|
||||
<div class="mb-3">
|
||||
<p><?= lang('ClientePrecios.convertir2plantillaText') ?></p>
|
||||
<p><?= lang('ClientePrecios.convertir2plantillaText2') ?></p>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="nombre_plantilla" class="form-label">
|
||||
<?= lang('ClientePrecios.nombrePlantilla') ?>
|
||||
</label>
|
||||
<input type="text" id="nombre_plantilla" maxLength="100" class="form-control new-address">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="saveTemplate"
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
><?= lang('App.global_save') ?></button>
|
||||
<button id="cancelTemplate"
|
||||
type="button"
|
||||
class="btn btn-default"
|
||||
><?= lang('App.user_delete_btn_cancel') ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
$('#saveTemplate').on('click', function(){
|
||||
if($('#nombre_plantilla').val().length == 0){
|
||||
popErrorAlert('<?= lang('ClientePrecios.errors.error_nombre_template') ?>', 'error-nombre')
|
||||
}
|
||||
else{
|
||||
data = new FormData();
|
||||
data.append('cliente_id', id)
|
||||
data.append('nombre', $('#nombre_plantilla').val())
|
||||
data.append('<?= csrf_token() ?? "token" ?>', <?= csrf_token() ?>v)
|
||||
fetch('<?= route_to("createClienteplantillaprecios");?>' , {
|
||||
method: "POST",
|
||||
body: data,
|
||||
})
|
||||
.then(data => {
|
||||
$('#convert2Template').modal("hide");
|
||||
var newOption = new Option($('#nombre_plantilla').val(), "", false, false);
|
||||
$('#plantillas').append(newOption);
|
||||
$('#nombre_plantilla').val("");
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
$('#cancelTemplate').on('click', function(){
|
||||
$('#convert2Template').modal("hide");
|
||||
})
|
||||
<?=$this->endSection() ?>
|
||||
@ -84,6 +84,10 @@ let ClassSelect = function (domItem, url, placeholder, allowClear = false, param
|
||||
this.onChange = function(callback) {
|
||||
this.item.on('change', callback);
|
||||
};
|
||||
this.offChange = function() {
|
||||
this.item.off('change');
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
export default ClassSelect;
|
||||
|
||||
@ -0,0 +1,83 @@
|
||||
class ModalConvert2Template {
|
||||
|
||||
constructor() {
|
||||
|
||||
this.modalId = 'modalConvert2Template';
|
||||
this.modalHtml = `
|
||||
<div class="modal fade" id="${this.modalId}" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="${this.modalId}Label" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 id="labelTitleConfirmDialog" class="modal-title">${window.language.ClientePrecios.convertir2plantilla}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id='error-nombre'></div>
|
||||
<div class="mb-3">
|
||||
<p>${window.language.ClientePrecios.convertir2plantillaText}</p>
|
||||
<p>${window.language.ClientePrecios.convertir2plantillaText2}</p>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="nombre_plantilla" class="form-label">
|
||||
${window.language.ClientePrecios.nombrePlantilla}
|
||||
</label>
|
||||
<input type="text" id="nombre_plantilla" maxLength="100" class="form-control new-address">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="saveTemplate" type="button" class="btn btn-primary">
|
||||
Guardar
|
||||
</button>
|
||||
<button id="cancelTemplate" type="button" class="btn btn-default">
|
||||
Cancelar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
this.modalInstance = null;
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
const self = this;
|
||||
|
||||
// Insertar el modal en el body del documento si no existe
|
||||
if (!document.getElementById(this.modalId)) {
|
||||
document.body.insertAdjacentHTML('beforeend', this.modalHtml);
|
||||
}
|
||||
|
||||
this.modalInstance = new bootstrap.Modal(document.getElementById(this.modalId));
|
||||
|
||||
// Configurar el evento del botón de cancelar
|
||||
document.getElementById('cancelTemplate').addEventListener('click', () => {
|
||||
this.modalInstance.hide();
|
||||
});
|
||||
}
|
||||
|
||||
// Método para mostrar el modal
|
||||
show(callback) {
|
||||
|
||||
// Mostrar el modal usando Bootstrap
|
||||
this.modalInstance.show();
|
||||
|
||||
// Configurar el evento de confirmación de eliminación
|
||||
document.getElementById('saveTemplate').addEventListener('click', () => {
|
||||
callback(); // Llamar al callback que el usuario haya proporcionado
|
||||
this.modalInstance.hide();
|
||||
});
|
||||
}
|
||||
|
||||
hide() {
|
||||
document.getElementById('nombre_plantilla').value = "";
|
||||
const modal = new bootstrap.Modal(document.getElementById(this.modalId));
|
||||
modal.hide();
|
||||
}
|
||||
|
||||
getNombrePlantilla() {
|
||||
return document.getElementById('nombre_plantilla').value;
|
||||
}
|
||||
}
|
||||
|
||||
export default ModalConvert2Template;
|
||||
@ -1,6 +1,9 @@
|
||||
import Table from '../../components/table.js';
|
||||
import TableEditor from '../../components/tableEditor.js';
|
||||
import ConfirmDeleteModal from '../../components/ConfirmDeleteModal.js';
|
||||
import ConvertToTemplate from './modalConvert2Template.js';
|
||||
import ClassSelect from '../../components/select2.js';
|
||||
import Ajax from '../../components/ajax.js';
|
||||
import { getToken } from '../../common/common.js';
|
||||
|
||||
|
||||
@ -21,7 +24,14 @@ class tarifasClienteView {
|
||||
this.tableTarifas = null;
|
||||
this.editorTarifas = null;
|
||||
this.confirmDeleteModal = null;
|
||||
|
||||
this.deleteModal = null;
|
||||
this.convertToTemplate = null;
|
||||
|
||||
this.plantillas = $(this.domItem.find('#plantillas'));
|
||||
this.selectorPlantilla = new ClassSelect(this.plantillas, '/clienteplantillaprecios/menuitems', '');
|
||||
|
||||
this.convertToTemplateBtn = $('#convert2template');
|
||||
}
|
||||
|
||||
init() {
|
||||
@ -31,24 +41,35 @@ class tarifasClienteView {
|
||||
this.deleteModal = new ConfirmDeleteModal('tarifascliente');
|
||||
this.deleteModal.init();
|
||||
|
||||
this.convertToTemplate = new ConvertToTemplate();
|
||||
this.convertToTemplate.init();
|
||||
|
||||
this.#initEditor();
|
||||
|
||||
this.#initTable();
|
||||
|
||||
this.selectorPlantilla.init();
|
||||
|
||||
this.#getPlantillaPrecios();
|
||||
|
||||
this.convertToTemplateBtn.on('click', function () {
|
||||
self.convertToTemplate.show(self.#convertir2plantilla.bind(self));
|
||||
})
|
||||
|
||||
|
||||
// Editar en linea la fila
|
||||
this.tableTarifas.table.on('click', 'tbody span.edit', function (e) {
|
||||
|
||||
const row = $(this).closest('tr');
|
||||
|
||||
|
||||
// Iniciar la edición en línea para todas las celdas de la fila
|
||||
self.editorTarifas.editor.inline(
|
||||
self.tableTarifas.table.cells(row, '*').nodes(),
|
||||
{
|
||||
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||
cancelTrigger: row.find('span.cancel')[0],
|
||||
submitTrigger: row.find('span.edit')[0],
|
||||
cancelTrigger: row.find('span.cancel')[0],
|
||||
submitTrigger: row.find('span.edit')[0],
|
||||
submit: 'allIfChanged'
|
||||
}
|
||||
);
|
||||
@ -58,19 +79,19 @@ class tarifasClienteView {
|
||||
this.tableTarifas.table.on('click', '.btn-delete-' + this.tableTarifas.getAlias(), function (e) {
|
||||
const row = $(this).closest('tr')[0]._DT_RowIndex;
|
||||
self.deleteModal.setData($(this).attr('data-id'));
|
||||
self.deleteModal.show(() =>{
|
||||
self.deleteModal.show(() => {
|
||||
if ($.isNumeric(self.deleteModal.getData())) {
|
||||
self.editorTarifas.editor
|
||||
.create( false )
|
||||
.edit( self.tableTarifas.table.rows(row), false)
|
||||
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
|
||||
.set( 'is_deleted', 1 )
|
||||
.create(false)
|
||||
.edit(self.tableTarifas.table.rows(row), false)
|
||||
.set('deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' '))
|
||||
.set('is_deleted', 1)
|
||||
.submit();
|
||||
self.deleteModal.hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -166,10 +187,16 @@ class tarifasClienteView {
|
||||
|
||||
this.editorTarifas.editor.on('postEdit', function (e, json, data, action) {
|
||||
self.#borrarPlantillaTarifa(self.clienteId);
|
||||
self.selectorPlantilla.offChange();
|
||||
self.selectorPlantilla.setOption(0, 'Personalizado');
|
||||
self.selectorPlantilla.onChange(self.#changePlantilla.bind(this));
|
||||
})
|
||||
|
||||
this.editorTarifas.editor.on('postCreate', function (e, json, data, action) {
|
||||
self.#borrarPlantillaTarifa(self.clienteId);
|
||||
self.selectorPlantilla.offChange();
|
||||
self.selectorPlantilla.setOption(0, 'Personalizado');
|
||||
self.selectorPlantilla.onChange(self.#changePlantilla.bind(this));
|
||||
})
|
||||
|
||||
this.editorTarifas.editor.on('postCancel', function (e, json, data) {
|
||||
@ -181,18 +208,82 @@ class tarifasClienteView {
|
||||
});
|
||||
}
|
||||
|
||||
#convertir2plantilla() {
|
||||
if (this.convertToTemplate.getNombrePlantilla().length == 0) {
|
||||
popErrorAlert(window.language.ClientePrecios.errors.error_nombre_template, 'error-nombre')
|
||||
}
|
||||
else {
|
||||
new Ajax('/clientes/clienteplantillaprecios/add',
|
||||
{
|
||||
'from_client_data': 1,
|
||||
'cliente_id': this.clienteId,
|
||||
'nombre': this.convertToTemplate.getNombrePlantilla(),
|
||||
[this.csrf_token]: this.csrf_hash
|
||||
},
|
||||
{},
|
||||
(response) => {
|
||||
if (response.id) {
|
||||
|
||||
this.selectorPlantilla.offChange();
|
||||
this.selectorPlantilla.setOption(response.id, this.convertToTemplate.getNombrePlantilla());
|
||||
this.selectorPlantilla.onChange(this.#changePlantilla.bind(this));
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
}
|
||||
).post();
|
||||
}
|
||||
}
|
||||
|
||||
#getPlantillaPrecios() {
|
||||
|
||||
new Ajax(
|
||||
'/clienteprecios/getplantilla',
|
||||
{
|
||||
'cliente_id': this.clienteId,
|
||||
[this.csrf_token]: this.csrf_hash
|
||||
},
|
||||
{},
|
||||
(data) => {
|
||||
if (data !== null && typeof data === 'object') {
|
||||
if (data.hasOwnProperty('id') && data.id != null)
|
||||
this.selectorPlantilla.setOption(data.id, data.nombre);
|
||||
else {
|
||||
this.selectorPlantilla.setOption(0, 'Personalizado');
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.selectorPlantilla.setOption(0, 'Personalizado');
|
||||
}
|
||||
this.selectorPlantilla.onChange(this.#changePlantilla.bind(this));
|
||||
},
|
||||
(data) => {
|
||||
this.selectorPlantilla.onChange(this.#changePlantilla.bind(this));
|
||||
console.log(data);
|
||||
}
|
||||
).get();
|
||||
}
|
||||
|
||||
#changePlantilla() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
#borrarPlantillaTarifa(id) {
|
||||
|
||||
const domain = window.location.origin
|
||||
fetch(domain + "/clientes/clienteprecios/update/" + id, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
[self.csrf_token]: self.csrf_hash
|
||||
}),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
new Ajax(
|
||||
'/clienteprecios/changeplantilla',
|
||||
{
|
||||
'cliente_id': id,
|
||||
[this.csrf_token]: this.csrf_hash
|
||||
},
|
||||
{},
|
||||
() => { },
|
||||
(data) => {
|
||||
console.log(data);
|
||||
}
|
||||
})
|
||||
).post();
|
||||
}
|
||||
|
||||
#initTable() {
|
||||
@ -280,7 +371,7 @@ class tarifasClienteView {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
headerSearcher() {
|
||||
|
||||
|
||||
@ -44,7 +44,8 @@ class PresupuestoCliente {
|
||||
|
||||
this.datos = {};
|
||||
this.ajax_calcular = new Ajax('/presupuestocliente/calcular',
|
||||
{}, this.datos,
|
||||
this.datos,
|
||||
{},
|
||||
this.#procesarPresupuesto.bind(this),
|
||||
() => { $('#loader').modal('hide'); });
|
||||
|
||||
@ -78,7 +79,7 @@ class PresupuestoCliente {
|
||||
}
|
||||
|
||||
|
||||
if ($('#divExcluirRotativa').hasClass('d-none')) {
|
||||
if (this.datosGenerales.excluirRotativa.length == 0) {
|
||||
|
||||
this.direcciones.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").val() })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user