trabajando en presupuestos servicios extra

This commit is contained in:
jaimejimenezortega
2024-04-07 21:32:38 +02:00
parent 8eb322aaae
commit 987da56f2a
14 changed files with 5777 additions and 5 deletions

View File

@ -104,6 +104,20 @@ $routes->group('tarifapreimpresion', ['namespace' => 'App\Controllers\Tarifas'],
});
$routes->group('tarifaextra', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
$routes->get('', 'Tarifaextra::index', ['as' => 'tarifaextraList']);
$routes->get('index', 'Tarifaextra::index', ['as' => 'tarifaextraIndex']);
$routes->get('list', 'Tarifaextra::index', ['as' => 'tarifaextraList2']);
$routes->get('add', 'Tarifaextra::add', ['as' => 'newTarifaextra']);
$routes->post('add', 'Tarifaextra::add', ['as' => 'createTarifaextra']);
$routes->get('edit/(:num)', 'Tarifaextra::edit/$1', ['as' => 'editTarifaextra']);
$routes->post('edit/(:num)', 'Tarifaextra::edit/$1', ['as' => 'updateTarifaextra']);
$routes->get('delete/(:num)', 'Tarifaextra::delete/$1', ['as' => 'deleteTarifaextra']);
$routes->post('allmenuitems', 'Tarifaextra::allItemsSelect', ['as' => 'select2ItemsOfTarifasextra']);
$routes->post('menuitems', 'Tarifaextra::menuItems', ['as' => 'menuItemsOfTarifasextra']);
});
$routes->group('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
$routes->get('', 'Tarifasmanipulado::index', ['as' => 'tarifaManipuladoList']);
$routes->get('add', 'Tarifasmanipulado::add', ['as' => 'newTarifaManipulado']);
@ -550,6 +564,11 @@ $routes->group('serviciospreimpresiones', ['namespace' => 'App\Controllers\Presu
$routes->post('edit/(:num)', 'Presupuestopreimpresiones::edit/$1', ['as' => 'updatePresupuestopreimpresiones']);
});
$routes->group('serviciosextra', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
$routes->post('datatable', 'Presupuestoserviciosextra::datatable', ['as' => 'dataTableOfPresupuestoServiciosExtra']);
$routes->post('edit/(:num)', 'Presupuestoserviciosextra::edit/$1', ['as' => 'updatePresupuestoServiciosExtra']);
});
$routes->group('presupuestodirecciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
$routes->post('datatable', 'Presupuestodirecciones::datatable', ['as' => 'dataTableOfPresupuestoDirecciones']);
$routes->post('datatable_2', 'Presupuestodirecciones::datatable_2', ['as' => 'processDataDirecciones']);

View File

@ -17,6 +17,7 @@ use App\Models\Presupuestos\PresupuestoEncuadernacionesModel;
use App\Models\Presupuestos\PresupuestoAcabadosModel;
use App\Models\Presupuestos\PresupuestoManipuladosModel;
use App\Models\Presupuestos\PresupuestoPreimpresionesModel;
use App\Models\Presupuestos\PresupuestoServiciosExtraModel;
use App\Services\PresupuestoService;
use App\Models\Configuracion\PapelImpresionModel;
@ -356,10 +357,10 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
// Servicios
$this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion();
$this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion();
$this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion();
$this->viewData['serviciosManipulado'] = $this->getServiciosManipulado();
$this->viewData['serviciosAcabado'] = $this->getServiciosAcabado();
$this->viewData['serviciosExtra'] = $this->getServiciosExtra();
[$cambios_en_servicios, $servicios] = $this->getLineasServicios($presupuestoEntity);
$this->viewData['presupuestoEntity']->cambios_servicios=$cambios_en_servicios;
@ -368,6 +369,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
$this->viewData['serviciosAcabadosList'] = $servicios->serviciosAcabado;
$this->viewData['serviciosManipuladoList'] = $servicios->serviciosManipulado;
$this->viewData['serviciosPreimpresionList'] = $servicios->serviciosPreimpresion;
$this->viewData['serviciosExtraList'] = $servicios->serviciosExtra;
// Direciones presupuesto
[$cambios_en_direcciones, $this->viewData['direccionesList']] = $this->getLineasDirecciones($presupuestoEntity);
@ -459,6 +461,10 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
$model = new PresupuestoManipuladosModel();
$model->where("presupuesto_id", $id)->delete();
// Se borran los servicios extra
$model = new PresupuestoServiciosExtraModel();
$model->where("presupuesto_id", $id)->delete();
// $message = lang('Basic.global.deleteSuccess', [$objName]); IMN commented
$message = lang('Basic.global.deleteSuccess', [lang('Basic.global.record')]);
$response = $this->respondDeleted(['id' => $id, 'msg' => $message]);
@ -889,6 +895,12 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
$preimpresion->presupuesto_id = $new_id;
$presupuestoPreimpresionesModel->insert($preimpresion);
}
$presupuestoServiciosExtraModel = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel');
foreach ($presupuestoServiciosExtraModel->where('presupuesto_id', $presupuesto->id)->findAll() as $servicioExtra) {
$servicioExtra->presupuesto_id = $new_id;
$presupuestoServiciosExtraModel->insert($preimpresion);
}
$presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
foreach ($presupuestoDireccionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $direccion) {
@ -1189,6 +1201,17 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
return $data;
}
protected function getServiciosExtra()
{
$model = model('App\Models\Tarifas\TarifaextraModel');
$data = $model->getServiciosExtraSelector();
array_unshift($data, (object)array(
"value" => 0,
"label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioExtra'))])
));
return $data;
}
protected function getServiciosEncuadernacion()
{
$model = model('App\Models\Tarifas\TarifaEncuadernacionModel');
@ -1246,6 +1269,7 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
$serviciosPresupuesto->serviciosPreimpresion = (new PresupuestoPreimpresionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
$serviciosPresupuesto->serviciosEncuadernacion = (new PresupuestoEncuadernacionesModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
$serviciosPresupuesto->serviciosManipulado = (new PresupuestoManipuladosModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
$serviciosPresupuesto->serviciosExtra = (new PresupuestoServiciosExtraModel())->getResource($presupuestoEntity->id)->get()->getResultObject();
$input_data = [];
$input_data['presupuesto_id'] = $presupuestoEntity->id;

View File

@ -0,0 +1,113 @@
<?php namespace App\Controllers\Presupuestos;
use App\Models\Collection;
use App\Models\Presupuestos\PresupuestoServiciosExtraModel;
class Presupuestoserviciosextra extends \App\Controllers\GoBaseResourceController
{
protected $modelName = PresupuestoServiciosExtraModel::class;
protected $format = 'json';
protected static $singularObjectName = 'Presupuesto extra';
protected static $singularObjectNameCc = 'presupuestoPreimpresion';
protected static $pluralObjectName = 'Presupuestos extra';
protected static $pluralObjectNameCc = 'presupuestosPreimpresion';
protected static $controllerSlug = 'presupuesto-servicios-extra';
protected static $viewPath = 'themes/backend/vuexy/form/presupuestos/';
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
}
public function edit($requestedId = null)
{
if ($requestedId == null) :
return;
endif;
$postData = $this->request->getJSON();
$tarifas = array_column($postData->datos, 'tarifa_id');
if(count($tarifas)>0){
$this->model->deleteServiciosNotInArray($requestedId, $tarifas);
}
else{
$this->model->deleteAllServicios($requestedId);
}
if(count($tarifas)>0){
$this->model->updateTarifas($requestedId, $postData->datos);
}
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
public function update($requestedId = null)
{
if ($requestedId == null) :
return;
endif;
$postData = $this->request->getJSON();
$tarifas = array_column($postData->datos, 'tarifa_id');
$result = [];
if(count($tarifas)>0){
foreach ($tarifas as $tarifa){
$values = $this->model->getPrecioTarifa($tarifa);
array_push($result, $values);
}
}
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'lines' => $result,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
}
public function datatable()
{
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
$tarifa_extra_id = $reqData['tarifa_extra_id'] ?? 0;
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$values = $this->model->getPrecioTarifa($tarifa_extra_id);
$data = [
'values' => $values,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Entities\Presupuestos;
use CodeIgniter\Entity;
class PresupuestoServiciosExtraEntity extends \CodeIgniter\Entity\Entity
{
protected $attributes = [
"id" => null,
"presupuesto_id" => null,
"tarifa_extra_id" => null,
"precio_total" => null,
"margen" => null,
"created_at" => null,
"updated_at" => null,
];
protected $casts = [
"presupuesto_id" => "int",
"tarifa_extra_id" => "int",
"precio_total" => "float",
"margen" => "float",
];
}

View File

@ -182,11 +182,13 @@ return [
'servicioAcabado' => 'Servicio de acabado',
'servicioPreimpresion' => 'Servicio de preimpresión',
'servicioExtra' => 'Servicio extra',
'servicioEncuadernado' => 'Servicio de encuadernación',
'servicioEncuadernadoList' => 'Servicios de encuadernación',
'servicioAcabadoList' => 'Servicios de acabado',
'servicioManipuladoList' => 'Servicios de manipulado',
'servicioPreimpresionList' => 'Servicios de preimpresion',
'servicioExtraList' => 'Servicios extra',
'servicioManipulado' => 'Servicio de manipulado',
'comentarios' => 'Comentarios',

View File

@ -0,0 +1,50 @@
<?php
return [
'createdAt' => 'Creado en',
'deletedAt' => 'Borrado en',
'id' => 'ID',
'moduleTitle' => 'Tarifas Servicios Extra',
'nombre' => 'Nombre',
'precio' => 'Precio',
'precioMin' => 'Precio Mínimo',
'importeFijo' => 'Importe Fijo',
'mostrar_en_presupuesto' => 'Mostrar en presupuesto',
'margen' => 'Margen',
'tarifaextra' => 'Tarifa Servicios Extra',
'tarifaextraList' => 'Lista Tarifas Servicios Extra',
'tarifasextra' => 'Tarifas Servicios Extra',
'updatedAt' => 'Actualizado en',
'userCreatedId' => 'ID Usuario \"Creado en\"',
'userUpdateId' => 'ID Usuario \"Actualizado en\"',
'validation' => [
'nombre' => [
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
'required' => 'El campo {field} es obligatorio.',
],
'precio' => [
'decimal' => 'El campo {field} debe contener un número decimal.',
'required' => 'El campo {field} es obligatorio.',
],
'user_created_id' => [
'integer' => 'El campo {field} debe contener un número entero.',
'required' => 'El campo {field} es obligatorio.',
],
'user_update_id' => [
'integer' => 'El campo {field} debe contener un número entero.',
'required' => 'El campo {field} es obligatorio.',
],
],
];

View File

@ -0,0 +1,158 @@
<?php
namespace App\Models\Presupuestos;
class PresupuestoServiciosExtraModel extends \App\Models\GoBaseModel
{
protected $table = "presupuesto_serviciosExtra";
/**
* Whether primary key uses auto increment.
*
* @var bool
*/
protected $useAutoIncrement = true;
const SORTABLE = [
0 => "t2.nombre",
1 => "t1.precio_unidad",
2 => "t1.precio_total"
];
protected $allowedFields = ["presupuesto_id", "tarifa_extra_id", "nombre", "precio_total", "precio_unidad", "margen"];
protected $returnType = "App\Entities\Presupuestos\PresupuestoPreimpresionesEntity";
protected $useTimestamps = true;
protected $useSoftDeletes = false;
protected $createdField = "created_at";
protected $updatedField = "updated_at";
public static $labelField = "nombre";
protected $validationRules = [
"precio_total" => [
"label" => "Presupuestos.precioTotal",
"rules" => "decimal|required",
],
];
protected $validationMessages = [
"precio_total" => [
"decimal" => "Presupuestos.validation.decimal",
"requerido" => "Presupuestos.validation.decimal",
],
];
public function getPrecioTarifa($tarifa_extra_id){
$modelTarifa = model('App\Models\Tarifas\TarifaextraModel');
$tarifa_value = $modelTarifa->getTarifaPresupuestoPreimpresion($tarifa_extra_id);
if (count($tarifa_value)>0) {
$result_data = $this->calcularTarifa($tarifa_value[0]);
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_value[0]->tarifa_extra_id,
'tarifa_nombre'=> $tarifa_value[0]->tarifa_extra_nombre,
'precio'=> $result_data[0],
'margen'=> $result_data[1],
];
return $ret_array;
}
else{
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_extra_id,
'tarifa_nombre'=> $modelTarifa->getNombreTarifaPreimpresion($tarifa_extra_id)[0]->nombre,
'precio' => 0,
'margen' => 0,
];
return $ret_array;
}
return [];
}
private function calcularTarifa($tarifa){
$precio = floatval($tarifa->precio);
$precio = $precio * (1+ floatval($tarifa->margen)/100.0);
$margen = $tarifa->margen;
return [$precio, $margen];
}
public function deleteAllServicios($presupuesto_id){
$this->db
->table($this->table . " t1")
->where('presupuesto_id', $presupuesto_id)
->delete();
}
public function deleteServiciosNotInArray($presupuesto_id, $tarifas_id){
$builder = $this->db
->table($this->table . " t1");
$builder->where('presupuesto_id', $presupuesto_id);
foreach($tarifas_id as $id){
$builder->where('tarifa_extra_id !=', $id);
}
$builder->delete();
}
public function updateTarifas($presupuesto_id, $tarifas){
foreach($tarifas as $tarifa){
$builder = $this->db
->table($this->table . " t1");
$builder->select("id");
$builder->where('presupuesto_id', $presupuesto_id);
$builder->where('tarifa_extra_id', $tarifa->tarifa_id);
$result = $builder->get()->getResultObject();
if(count($result)>0){
$this->db
->table($this->table . " t1")
->where('presupuesto_id', $presupuesto_id)
->where('tarifa_extra_id', $tarifa->tarifa_id)
->set('precio', $tarifa->precio)
->set('margen', $tarifa->margen)
->update();
}
else{
$this->db
->table($this->table . " t1")
->set('presupuesto_id', $presupuesto_id)
->set('tarifa_extra_id', $tarifa->tarifa_id)
->set('precio', $tarifa->precio)
->set('margen', $tarifa->margen)
->insert();
}
}
}
/**
* Get resource data.
*
* @param string $search
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResource($presupuesto_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.tarifa_extra_id AS tarifa_extra_id, t1.precio AS precio, t1.margen AS margen, t2.nombre AS nombre"
);
$builder->where('t1.presupuesto_id', $presupuesto_id);
$builder->join("tarifa_extra t2", "t1.tarifa_extra_id = t2.id", "left");
return $builder;
}
}

View File

@ -80,7 +80,7 @@ class TarifaextraModel extends \App\Models\GoBaseModel
],
];
public function getServiciosPreimpresionSelector()
public function getServiciosExtraSelector()
{
/*
Todos los servicios de extra activas que se pueden usar en presupuestos
@ -96,7 +96,7 @@ class TarifaextraModel extends \App\Models\GoBaseModel
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
}
public function getTarifaPresupuestoPreimpresion($tarifa_id){
public function getTarifaPresupuestoExtra($tarifa_id){
$builder = $this->db
->table($this->table . " t1")
@ -111,7 +111,7 @@ class TarifaextraModel extends \App\Models\GoBaseModel
return $builder->get()->getResultObject();
}
public function getNombreTarifaPreimpresion($id=-1)
public function getNombreTarifaExtra($id=-1)
{
/*
Todos los servicios de encuadernacion activas que se pueden usar en presupuestos

View File

@ -1375,6 +1375,236 @@ async function get_servPreimpresion_tiradasAlternativas(){
}
/****************************************************************************************
* Seccion para los servicios extra
***************************************************************************************/
var tableServiciosExtra = new DataTable('#tableOfServiciosExtra',{
scrollX: true,
searching: false,
paging: false,
info: false,
ordering: false,
responsive: true,
select: false,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
}
});
function init_servicio_extra(){
$('#add_servicio_extra_list').select2({
allowClear: false,
minimumResultsForSearch: -1,
placeholder: window.Presupuestos.servicioextraList
})
window.serviciosextraList.forEach((element) =>{
tableServiciosPreimpresion.row.add([
element.tarifa_extra_id,
element.nombre,
'<input class="update-totales-servicios" id="precio_servicioextra_' + element.tarifa_extra_id +'" value="' + parseFloat(element.precio).toFixed(2) + '"></input>',
'<span style="display: none;" class="update-totales" id="servicioextra_margen_' + element.tarifa_extra_id + '">' + parseFloat(element.margen).toFixed(2) + '</span>',
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + element.tarifa_extra_id +'"></i></a>'
]).draw(false)
$('#precio_servicioextra_' + element.tarifa_extra_id).on('change', function(){
updatePresupuesto({
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true})
})
})
updatePresupuesto({
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true
})
check_serv_extra_error()
}
function check_serv_extra_error(){
var htmlString = '';
$('#tableOfServiciosExtra tr').each(function(){
if(parseFloat($(this).find('td:eq(2) input').val()) == '0'){
htmlString = `
<div class="alert alert-danger d-flex align-items-baseline" role="alert">
<span class="alert-icon alert-icon-lg text-primary me-2">
<i class="ti ti-ban ti-sm"></i>
</span>
<div class="d-flex flex-column ps-1">
<h5 class="alert-heading mb-2">` +
window.Presupuestos.errores.error_servicios_anadidos +
`</h5>
</div>
</div>`;
}
})
$('#serv-preimpresion-error').html(htmlString)
}
function get_tarifas_extra(tarifa_id = -1){
var datos = {
tarifa_extra_id : tarifa_id,
};
datos = Object.assign(datos, window.token_ajax)
$.ajax({
type: "POST",
url: window.routes_servicios.dataTableOfPresupuestoServiciosExtra,
data: datos,
success: function (data) {
data.values.forEach((row) => {
tableServiciosExtra.row.add([
row.tarifa_id,
row.tarifa_nombre,
'<input class="update-totales-servicios" id="precio_servicioextra_' + row.tarifa_id +'" value="' + parseFloat(row.precio).toFixed(2) + '"></input>',
'<span style="display: none;" class="update-totales" id="servicioextra_margen_' + row.tarifa_id + '">' + parseFloat(row.margen).toFixed(2) + '</span>',
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + row.tarifa_id +'"></i></a>'
]).draw(false)
$('#precio_servicioextra_' + row.tarifa_id).on('change', function(){
updatePresupuesto({
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true})
})
});
if(data.values.lenght > 0){
updatePresupuesto({
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true
})
}
check_serv_extra_error()
yeniden(data[window.csrf_token]);
return true;
},
error: function(e){
return false;
}
})
return false;
}
$('#insertar_serv_extra').on('click', function(){
const tarifa_text = $('#add_servicio_extra_list').select2('data')[0].text.trim()
if( $('#add_servicio_extra_list').select2('data')[0].text.trim().length > 0){
if($('#tableOfServiciosExtra tr > td:contains(' + tarifa_text + ')').length == 0)
get_tarifas_extra($('#add_servicio_extra_list').select2('data')[0].id);
else{
popErrorAlert(window.Presupuestos.errores.error_servicios_duplicados, 'serv-extra-alert')
}
}
check_serv_extra_error()
})
function get_datos_serviciosextra(){
var datosServiciosExtra = []
if($("#tableOfServiciosExtra").DataTable().rows().count()>0){
$("#tableOfServiciosExtra tr").each(function (index,tr) {
var values = {}
$(this).find("td").each(function (index2) {
switch (index2) {
case 0:
values['tarifa_id'] = $(this).text()
break
case 2:
values['precio'] = $(this).children(":first").val()
break
case 3:
values['margen'] = $(this).text()
break
}
})
if(Object.keys(values).length>0)
datosServiciosExtra.push(values)
})
}
return datosServiciosExtra;
}
async function get_servExtra_tiradasAlternativas(){
const url = window.location.href;
const url_parts = url.split('/');
var id = -1;
if(url_parts[url_parts.length-2] == 'edit'){
id = url_parts[url_parts.length-1];
}
var serviciosExtra ={
coste: 0.0,
margen: 0.0,
}
var json_data = {
datos: get_datos_serviciosextra(),
POD: $('#POD').val()
}
if(json_data.datos.length>0){
json_data = Object.assign(json_data, window.token_ajax);
await fetch(window.location.origin + "/presupuestos/presupuestoserviciosextra/update/" + id , {
method: "POST",
body: JSON.stringify(json_data),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
.then(response => response.json())
.then(data => {
//const values = await response.json();
yeniden(data[window.csrf_token]);
data.lines.forEach((line) => {
serviciosExtra.coste += parseFloat(line[0].precio);
serviciosExtra.margen += parseFloat(line[0].precio)*parseFloat(line[0].margen)/100.0;
});
});
}
return serviciosExtra;
}
/****************************************************************************************
* Seccion para "otros"
***************************************************************************************/
async function actualizar_servicios(update_preimpresion=false){
const domain = window.location.origin
@ -1425,6 +1655,11 @@ async function actualizar_servicios(update_preimpresion=false){
datos_json_preimpresion = Object.assign(datos_json_preimpresion, window.token_ajax);
var datos_json_serviciosextra = {
datos: get_datos_serviciosextra(),
}
datos_json_preimpresion = Object.assign(datos_json_preimpresion, window.token_ajax);
fetch(domain + "/presupuestos/presupuestoacabados/update/" + id , {
method: "POST",
body: JSON.stringify(datos_json_acabados),
@ -1507,6 +1742,26 @@ async function actualizar_servicios(update_preimpresion=false){
yeniden(data[window.csrf_token]);
})
}
}).then(function(){
if(update_preimpresion){
fetch(domain + "/presupuestos/presupuestoserviciosextra/update/" + id , {
method: "POST",
body: JSON.stringify(datos_json_serviciosextra),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
.then(response => response.json())
.then(data => {
data.lines.forEach((line) => {
$('#precio_serviciosextra_' + line[0].tarifa_id).val(parseFloat(line[0].total).toFixed(2))
$('#serviciosextra_margen_' + line[0].tarifa_id).val(parseFloat(line[0].margen).toFixed(2))
});
check_serv_preimpresion_error();
yeniden(data[window.csrf_token]);
})
}
})
)
)
@ -1531,4 +1786,4 @@ function popAlert(message, alertClass, alertIcon, containerId = 'sk-alert'){
$('#' + containerId).fadeOut("slow");
}, 5000);
});
}
}

View File

@ -66,6 +66,18 @@
<?= lang("Presupuestos.servicioManipulado") ?>
</button>
</li>
<li class="nav-item">
<button
type="button"
class="nav-link"
role="tab"
data-bs-toggle="tab"
data-bs-target="#servicios-extra"
aria-controls="servicios-extra"
aria-selected="false">
<?= lang("Presupuestos.servicioExtra") ?>
</button>
</li>
</ul>
<div class="tab-content border border-container">
<div class="tab-pane fade show active" id="servicios-acabado" role="tabpanel">
@ -221,6 +233,42 @@
</div>
<div class="tab-pane fade" id="servicios-extra" role="tabpanel">
<div id="serv-extra-alert">
</div>
<div id="serv-extra-error">
</div>
<table id="tableOfServiciosExtra" class="table table-striped table-hover tiradas-alternativas update-resumen-presupuesto" style="width: 100%;">
<thead>
<tr>
<th><?= lang('Presupuestos.id') ?></th>
<th><?= lang('Tarifaextra.tarifaextra') ?></th>
<th><?= lang('Presupuestos.precio') ?></th>
<th></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="row mb-3 px-4">
<div class="col-md-12 col-lg-4 py-4">
<select id="add_servicio_extra_list" class="select2bs2" style="width: 100%;">
<option></option>
<?php foreach ($serviciosExtra as $item) : ?>
<option value="<?= $item->value ?>" >
<?= $item->label ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-12 col-lg-4 px-2 py-4">
<button id="insertar_serv_extra" type="button" class="btn btn-secondary waves-effect waves-light float-start tiradas-alternativas"><?= lang("Presupuestos.insertar")?></button>
</div>
</div>
</div>
</div>
</div>
</div> <!-- //.accordion-body -->
@ -243,12 +291,15 @@
window.serviciospreimpresionList = <?php echo json_encode($serviciosPreimpresionList); ?>;
window.serviciosextraList = <?php echo json_encode($serviciosExtraList); ?>;
window.routes_servicios = {
dataTableOfPresupuestoAcabados: "<?=route_to('dataTableOfPresupuestoAcabados') ?>",
dataTableOfPresupuestoPreimpresion: "<?=route_to('dataTableOfPresupuestoPreimpresiones') ?>",
dataTableOfPresupuestoEncuadernaciones: "<?=route_to('dataTableOfPresupuestoEncuadernaciones') ?>",
dataTableOfPresupuestoManipulados: "<?=route_to('dataTableOfPresupuestoManipulados') ?>",
menuItemsOfPresupuestoEncuadernaciones: '<?= route_to("menuItemsOfPresupuestoEncuadernaciones") ?>',
dataTableOfPresupuestoServiciosExtra: "<?=route_to('dataTableOfPresupuestoServiciosExtra') ?>",
}
init_servicio_acabado()
@ -258,5 +309,7 @@
init_servicio_manipulado()
init_servicio_preimpresion()
init_servicio_extra()
<?= $this->endSection() ?>

View File

@ -0,0 +1,93 @@
<div class="row">
<div class="col-md-12 col-lg-12 px-4">
<div class="mb-3">
<label for="nombre" class="form-label">
<?= lang('Tarifaextra.nombre') ?>*
</label>
<input
type="text"
id="nombre"
name="nombre"
required
maxLength="255"
class="form-control"
value="<?= old('nombre', $tarifaextraEntity->nombre) ?>"
>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="precio" class="form-label">
<?= lang('Tarifaextra.precio') ?>*
</label>
<input
type="number"
id="precio"
name="precio"
required
maxLength="31"
step="0.01"
class="form-control"
value="<?= old('precio', $tarifaextraEntity->precio) ?>"
>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="precio_min" class="form-label">
<?= lang('Tarifaextra.precioMin') ?>*
</label>
<input
type="text"
id="precio_min"
name="precio_min"
required
class="form-control"
value="<?= old('precio_min', $tarifaextraEntity->precio_min) ?>"
>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="importe_fijo" class="form-label">
<?= lang('Tarifaextra.importeFijo') ?>*
</label>
<input
type="text"
id="importe_fijo"
name="importe_fijo"
required
class="form-control"
value="<?= old('importe_fijo', $tarifaextraEntity->importe_fijo) ?>"
>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="margen" class="form-label">
<?= lang('Tarifaextra.margen') ?>*
</label>
<input
type="text"
id="margen"
name="margen"
required
class="form-control"
value="<?= old('margen', $tarifaextraEntity->margen) ?>"
>
</div><!--//.mb-3 -->
<div class="mb-3">
<div class="form-check form-check-inline">
<input type="checkbox"
id="mostrar_en_presupuesto"
name="mostrar_en_presupuesto"
value="1"
class="form-check-input"<?= $tarifaextraEntity->mostrar_en_presupuesto == true ? 'checked' : ''; ?>
>
<label for="mostrar_en_presupuesto" class="form-check-label">
<?= lang('Tarifaextra.mostrar_en_presupuesto') ?>
</label>
</div>
</div>
</div><!--//.col -->
</div><!-- //.row -->

View File

@ -0,0 +1,30 @@
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
<div class="row">
<div class="col-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="tarifaextraForm" method="post" class="card-body" action="<?= $formAction ?>">
<?= csrf_field() ?>
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/backend/vuexy/form/tarifas/extra/_tarifaextraFormItems") ?>
<div class="pt-4">
<input
type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
value="<?= lang("Basic.global.Save") ?>"
/>
<?= anchor(route_to("tarifaextraList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary"]) ?>
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
</div><!--//.col -->
</div><!--//.row -->
<?= $this->endSection() ?>

View File

@ -0,0 +1,120 @@
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
<?=$this->section('content'); ?>
<div class="row">
<div class="col-md-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?=lang('Tarifaextra.tarifaextraList') ?></h3>
<?=anchor(route_to('newTarifaextra'), lang('Basic.global.addNew').' '.lang('Tarifaextra.tarifaextra'), ['class'=>'btn btn-primary float-end']); ?>
</div><!--//.card-header -->
<div class="card-body">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<table id="tableOfTarifasextra" class="table table-striped table-hover using-exportable-data-table" style="width: 100%;">
<thead>
<tr>
<th><?= lang('Tarifaextra.nombre') ?></th>
<th><?= lang('Tarifaextra.precio') ?></th>
<th><?= lang('Tarifaextra.precioMin') ?></th>
<th><?= lang('Tarifaextra.importeFijo') ?></th>
<th><?= lang('Tarifaextra.margen') ?></th>
<th><?= lang('Tarifaextra.mostrar_en_presupuesto') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($tarifaextraList as $item ) : ?>
<tr>
<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->precio) ?>
</td>
<td class="align-middle">
<?= esc($item->precio_min) ?>
</td>
<td class="align-middle">
<?= esc($item->importe_fijo) ?>
</td>
<td class="align-middle">
<?= esc($item->margen) ?>
</td>
<td class="align-middle">
<?= esc($item->mostrar_en_presupuesto)==1?'<i class="ti ti-check"></i>':"" ?>
</td>
<td class="align-middle text-center text-nowrap">
<?=anchor(route_to('editTarifaextra', $item->id), "<i class='ti ti-pencil ti-sm mx-2'></i>", ['class'=>'text-body', 'data-id'=>$item->id,]); ?>
<?=anchor('#confirm2delete', "<i class='ti ti-trash ti-sm mx-2'></i>", ['class'=>'text-body', 'data-href'=>route_to('deleteTarifaextra', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div><!--//.card-body -->
<div class="card-footer">
</div><!--//.card-footer -->
</div><!--//.card -->
</div><!--//.col -->
</div><!--//.row -->
<?=$this->endSection() ?>
<?=$this->section('css') ?>
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
<?=$this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/jszip/jszip.min.js") ?>"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/pdfmake.min.js") ?>" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="<?= site_url("/themes/vuexy/vendor/libs/datatables-sk/plugins/pdfmake/vfs_fonts.js") ?>"></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": 50,
"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: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
"columnDefs": [
{
orderable: false,
searchable: false,
targets: [lastColNr2]
}
]
});
<?=$this->endSection() ?>

4832
xdebug.log

File diff suppressed because it is too large Load Diff