mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminados servicios acabados
This commit is contained in:
@ -493,16 +493,16 @@ $routes->group('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos
|
|||||||
$routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Cosidotapablanda', 'except' => 'show,new,create,update']);
|
$routes->resource('cosidotapablanda', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Cosidotapablanda', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
$routes->group('serviciosacabados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
$routes->group('serviciosacabados', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||||
$routes->post('datatable', 'PresupuestoAcabados::datatable', ['as' => 'dataTableOfPresupuestoAcabados']);
|
$routes->post('datatable', 'Presupuestoacabados::datatable', ['as' => 'dataTableOfPresupuestoAcabados']);
|
||||||
$routes->post('datatable_editor', 'PresupuestoAcabados::datatable_editor', ['as' => 'editorOfPresupuestoAcabados']);
|
$routes->get('delete/(:num)', 'Presupuestoacabados::delete/$1', ['as' => 'deletePresupuestoAcabado']);
|
||||||
$routes->get('delete/(:num)', 'PresupuestoAcabados::delete/$1', ['as' => 'deletePresupuestoAcabado']);
|
$routes->post('edit/(:num)', 'Presupuestoacabados::edit/$1', ['as' => 'updatePresupuestoacabados']);
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group('serviciosencuadernaciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
$routes->group('serviciosencuadernaciones', ['namespace' => 'App\Controllers\Presupuestos'], function ($routes) {
|
||||||
$routes->post('datatable', 'Presupuestoencuadernaciones::datatable', ['as' => 'dataTableOfPresupuestoEncuadernaciones']);
|
$routes->post('datatable', 'Presupuestoencuadernaciones::datatable', ['as' => 'dataTableOfPresupuestoEncuadernaciones']);
|
||||||
$routes->post('menuitems', 'Presupuestoencuadernaciones::menuItems', ['as' => 'menuItemsOfPresupuestoEncuadernaciones']);
|
$routes->post('menuitems', 'Presupuestoencuadernaciones::menuItems', ['as' => 'menuItemsOfPresupuestoEncuadernaciones']);
|
||||||
$routes->get('delete/(:num)', 'Presupuestoencuadernaciones::delete/$1', ['as' => 'deletePresupuestoencuadernaciones']);
|
$routes->get('delete/(:num)', 'Presupuestoencuadernaciones::delete/$1', ['as' => 'deletePresupuestoencuadernaciones']);
|
||||||
$routes->post('edit/(:num)', 'Presupuestoencuadernaciones::edit/$1', ['as' => 'updateCosidotapablanda']);
|
$routes->post('edit/(:num)', 'Presupuestoencuadernaciones::edit/$1', ['as' => 'updatePresupuestoencuadernaciones']);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ use App\Models\Configuracion\PapelGenericoModel;
|
|||||||
use App\Models\Presupuestos\PresupuestoModel;
|
use App\Models\Presupuestos\PresupuestoModel;
|
||||||
|
|
||||||
use App\Models\Presupuestos\PresupuestoEncuadernacionesModel;
|
use App\Models\Presupuestos\PresupuestoEncuadernacionesModel;
|
||||||
|
use App\Models\Presupuestos\PresupuestoAcabadosModel;
|
||||||
|
|
||||||
use App\Services\PresupuestoService;
|
use App\Services\PresupuestoService;
|
||||||
use App\Models\Configuracion\PapelImpresionModel;
|
use App\Models\Configuracion\PapelImpresionModel;
|
||||||
@ -277,11 +278,12 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
|||||||
$this->viewData['lineasPresupuesto'] = $this->getLineasPresupuestoActivas($id);
|
$this->viewData['lineasPresupuesto'] = $this->getLineasPresupuestoActivas($id);
|
||||||
|
|
||||||
// Tarifas
|
// Tarifas
|
||||||
|
$this->viewData['serviciosAcabado'] = $this->getServiciosAcabado();
|
||||||
$this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion();
|
$this->viewData['serviciosPreimpresion'] = $this->getServiciosPreimpresion();
|
||||||
$this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion();
|
$this->viewData['serviciosEncuadernacion'] = $this->getServiciosEncuadernacion();
|
||||||
$this->viewData['serviciosAcabado'] = $this->getServiciosAcabado();
|
|
||||||
$this->viewData['serviciosManipulado'] = $this->getServiciosManipulado();
|
$this->viewData['serviciosManipulado'] = $this->getServiciosManipulado();
|
||||||
$this->viewData['serviciosEncuadernacionList'] = (new PresupuestoEncuadernacionesModel())->getResource($id)->get()->getResultObject();
|
$this->viewData['serviciosEncuadernacionList'] = (new PresupuestoEncuadernacionesModel())->getResource($id)->get()->getResultObject();
|
||||||
|
$this->viewData['serviciosAcabadosList'] = (new PresupuestoAcabadosModel())->getResource($id)->get()->getResultObject();
|
||||||
|
|
||||||
$this->viewData['POD'] = $this->getPOD();
|
$this->viewData['POD'] = $this->getPOD();
|
||||||
|
|
||||||
@ -999,10 +1001,10 @@ class Cosidotapablanda extends \App\Controllers\GoBaseResourceController
|
|||||||
{
|
{
|
||||||
$model = model('App\Models\Tarifas\TarifaacabadoModel');
|
$model = model('App\Models\Tarifas\TarifaacabadoModel');
|
||||||
$data = $model->getServiciosAcabadoSelector();
|
$data = $model->getServiciosAcabadoSelector();
|
||||||
array_unshift($data, (object)array(
|
/*array_unshift($data, (object)array(
|
||||||
"value" => 0,
|
"value" => 0,
|
||||||
"label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioAcabado'))])
|
"label" => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Presupuestos.servicioAcabado'))])
|
||||||
));
|
));*/
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,121 +0,0 @@
|
|||||||
<?php namespace App\Controllers\Presupuestos;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Controllers\GoBaseResourceController;
|
|
||||||
|
|
||||||
use App\Models\Collection;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Presupuestos\PresupuestoAcabadosModel;
|
|
||||||
use DataTables\Editor;
|
|
||||||
use DataTables\Editor\Field;
|
|
||||||
use DataTables\Editor\Validate;
|
|
||||||
|
|
||||||
|
|
||||||
class PresupuestoAcabados extends \App\Controllers\GoBaseResourceController
|
|
||||||
{
|
|
||||||
|
|
||||||
protected $modelName = PresupuestoAcabadosModel::class;
|
|
||||||
protected $format = 'json';
|
|
||||||
|
|
||||||
protected static $singularObjectName = 'Presupuesto acabado';
|
|
||||||
protected static $singularObjectNameCc = 'presupuestoAcabado';
|
|
||||||
protected static $pluralObjectName = 'Presupuestos acabado';
|
|
||||||
protected static $pluralObjectNameCc = 'presupuestosAcabado';
|
|
||||||
|
|
||||||
protected static $controllerSlug = 'presupuesto-acabados';
|
|
||||||
|
|
||||||
protected static $viewPath = 'themes/backend/vuexy/form/presupuestos/';
|
|
||||||
|
|
||||||
protected $indexRoute = 'contactoDeClienteList';
|
|
||||||
|
|
||||||
|
|
||||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
|
||||||
{
|
|
||||||
parent::initController($request, $response, $logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function datatable()
|
|
||||||
{
|
|
||||||
if ($this->request->isAJAX()) {
|
|
||||||
$reqData = $this->request->getPost();
|
|
||||||
if (!isset($reqData['draw']) || !isset($reqData['columns'])) {
|
|
||||||
$errstr = 'No data available in response to this specific request.';
|
|
||||||
$response = $this->respond(Collection::datatable([], 0, 0, $errstr), 400, $errstr);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
$start = $reqData['start'] ?? 0;
|
|
||||||
$length = $reqData['length'] ?? 5;
|
|
||||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
|
||||||
$order = PresupuestoAcabadosModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1];
|
|
||||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
|
||||||
|
|
||||||
$id_P = $reqData['id_presupuesto'] ?? -1;
|
|
||||||
|
|
||||||
$resourceData = $this->model->getResource($id_P)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
|
||||||
|
|
||||||
return $this->respond(Collection::datatable(
|
|
||||||
$resourceData,
|
|
||||||
$this->model->getResource()->countAllResults(),
|
|
||||||
$this->model->getResource($id_P)->countAllResults()
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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, 'presupuesto_acabados' )
|
|
||||||
->fields(
|
|
||||||
Field::inst( 'tarifa_acabado_id' )
|
|
||||||
->validator( 'Validate::notEmpty',array(
|
|
||||||
'message' => 'Selecciones servicios de acabado' )
|
|
||||||
),
|
|
||||||
Field::inst( 'precio_unidad' )
|
|
||||||
->validator( 'Validate::notEmpty',array(
|
|
||||||
'message' => 'Falta precio unitario' )
|
|
||||||
),
|
|
||||||
Field::inst( 'precio_total' )
|
|
||||||
->validator( 'Validate::notEmpty',array(
|
|
||||||
'message' => 'Falta precio total' )
|
|
||||||
),
|
|
||||||
|
|
||||||
Field::inst( 'presupuesto_id' ),
|
|
||||||
|
|
||||||
)
|
|
||||||
->validator( function($editor, $action, $data){
|
|
||||||
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT){
|
|
||||||
//return $response;
|
|
||||||
/*foreach ($data['data'] as $pkey => $values ){
|
|
||||||
// No se pueden duplicar valores al crear o al editar
|
|
||||||
if (!empty($response)){
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
93
ci4/app/Controllers/Presupuestos/Presupuestoacabados.php
Executable file
93
ci4/app/Controllers/Presupuestos/Presupuestoacabados.php
Executable file
@ -0,0 +1,93 @@
|
|||||||
|
<?php namespace App\Controllers\Presupuestos;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Controllers\GoBaseResourceController;
|
||||||
|
|
||||||
|
use App\Models\Collection;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Models\Presupuestos\PresupuestoAcabadosModel;
|
||||||
|
use DataTables\Editor;
|
||||||
|
use DataTables\Editor\Field;
|
||||||
|
use DataTables\Editor\Validate;
|
||||||
|
|
||||||
|
|
||||||
|
class Presupuestoacabados extends \App\Controllers\GoBaseResourceController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $modelName = PresupuestoAcabadosModel::class;
|
||||||
|
protected $format = 'json';
|
||||||
|
|
||||||
|
protected static $singularObjectName = 'Presupuesto acabado';
|
||||||
|
protected static $singularObjectNameCc = 'presupuestoAcabado';
|
||||||
|
protected static $pluralObjectName = 'Presupuestos acabado';
|
||||||
|
protected static $pluralObjectNameCc = 'presupuestosAcabado';
|
||||||
|
|
||||||
|
protected static $controllerSlug = 'presupuesto-acabados';
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->model->updateTarifas($requestedId, $postData->datos);
|
||||||
|
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
$data = [
|
||||||
|
$csrfTokenName => $newTokenHash
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->respond($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function datatable()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
$reqData = $this->request->getPost();
|
||||||
|
|
||||||
|
$tarifa_acabado_id = $reqData['tarifa_acabado_id'] ?? 0;
|
||||||
|
$tirada = $reqData['tirada'] ?? 0;
|
||||||
|
$POD = $reqData['POD'] ?? 0;
|
||||||
|
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
|
$values = $this->model->getPrecioTarifa($tarifa_acabado_id, $tirada, $POD);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'values' => $values,
|
||||||
|
$csrfTokenName => $newTokenHash
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->respond($data);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -18,12 +18,7 @@ class Test extends BaseController
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
echo '<pre>';
|
echo '<pre>';
|
||||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
var_dump($this->get_precio_tarifa_acabado(1, 200, 30));
|
||||||
|
|
||||||
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionLineaHorasModel');
|
|
||||||
$test = $modelTarifa->removeAllEncuadernacionLineasHorasForTarifa(2, $datetime, 1);
|
|
||||||
var_dump($test);
|
|
||||||
//var_dump($this->get_precio_tarifa_horas(2, 200, 100, -1, false));
|
|
||||||
echo '</pre>';
|
echo '</pre>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,6 +33,11 @@ class Test extends BaseController
|
|||||||
return $model->getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD);
|
return $model->getPrecioTarifa($tarifa_encuadernacion_id, $paginas, $tirada, $ancho, $alto, $proveedor_id, $POD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_precio_tarifa_acabado($tarifa_id, $tirada, $POD){
|
||||||
|
$model = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||||
|
return $model->getPrecioTarifa($tarifa_id, $tirada, $POD);
|
||||||
|
}
|
||||||
|
|
||||||
public function get_precio_tarifa_horas($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD){
|
public function get_precio_tarifa_horas($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD){
|
||||||
$model = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
|
$model = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
|
||||||
return $model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD);
|
return $model->getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD);
|
||||||
|
|||||||
@ -152,6 +152,7 @@ return [
|
|||||||
'servicioPreimpresion' => 'Servicio de preimpresión',
|
'servicioPreimpresion' => 'Servicio de preimpresión',
|
||||||
'servicioEncuadernado' => 'Servicio de encuadernación',
|
'servicioEncuadernado' => 'Servicio de encuadernación',
|
||||||
'servicioEncuadernadoList' => 'Servicios de encuadernación',
|
'servicioEncuadernadoList' => 'Servicios de encuadernación',
|
||||||
|
'servicioAcabadoList' => 'Servicios de acabado',
|
||||||
|
|
||||||
'servicioManipulado' => 'Servicio de manipulado',
|
'servicioManipulado' => 'Servicio de manipulado',
|
||||||
'comentarios' => 'Comentarios',
|
'comentarios' => 'Comentarios',
|
||||||
|
|||||||
@ -44,6 +44,100 @@ class PresupuestoAcabadosModel extends \App\Models\GoBaseModel
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getPrecioTarifa($tarifa_acabado_id, $tirada, $POD){
|
||||||
|
|
||||||
|
$modelTarifa = model('App\Models\Tarifas\TarifaacabadoModel');
|
||||||
|
$tarifa_value = $modelTarifa->getTarifaPresupuestoAcabado($tarifa_acabado_id, $tirada);
|
||||||
|
if (count($tarifa_value)>0) {
|
||||||
|
|
||||||
|
$result_data = $this->calcularTarifa($tarifa_value[0], $tirada, $POD<$tirada?false:true);
|
||||||
|
$ret_array[] = (object)[
|
||||||
|
'tarifa_id'=> $tarifa_value[0]->tarifa_acabado_id,
|
||||||
|
'tarifa_nombre'=> $tarifa_value[0]->tarifa_acabado_nombre,
|
||||||
|
'precio_unidad'=> $result_data[0],
|
||||||
|
'total'=> $result_data[1],
|
||||||
|
];
|
||||||
|
return $ret_array;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$ret_array[] = (object)[
|
||||||
|
'tarifa_id'=> $tarifa_acabado_id,
|
||||||
|
'tarifa_nombre'=> $modelTarifa->getNombreTarifaAcabado($tarifa_acabado_id)[0]->nombre,
|
||||||
|
'precio_unidad' => 0,
|
||||||
|
'total'=> 0,
|
||||||
|
];
|
||||||
|
return $ret_array;
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function calcularTarifa($tarifa, $tirada, $is_POD=false){
|
||||||
|
|
||||||
|
$precio_unidad = floatval($tarifa->precio_min) - (floatval($tarifa->precio_min) - floatval($tarifa->precio_max))/($tarifa->tirada_max - $tarifa->tirada_min) * ($tirada - $tarifa->tirada_min);
|
||||||
|
if ($tirada > $tarifa->tirada_max)
|
||||||
|
$precio_unidad = $tarifa->precio_max;
|
||||||
|
$precio_unidad = $precio_unidad* (1+ floatval($tarifa->margen)/100.0);
|
||||||
|
|
||||||
|
$total = $precio_unidad * $tirada;
|
||||||
|
|
||||||
|
if (!$is_POD){
|
||||||
|
$total += floatval($tarifa->tarifa_importe_fijo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$precio_unidad, $total];
|
||||||
|
}
|
||||||
|
|
||||||
|
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_acabado_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_acabado_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_acabado_id', $tarifa->tarifa_id)
|
||||||
|
->set('precio_unidad', $tarifa->precio_unidad)
|
||||||
|
->set('precio_total', $tarifa->precio_total)
|
||||||
|
->update();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$this->db
|
||||||
|
->table($this->table . " t1")
|
||||||
|
->set('presupuesto_id', $presupuesto_id)
|
||||||
|
->set('tarifa_acabado_id', $tarifa->tarifa_id)
|
||||||
|
->set('precio_unidad', $tarifa->precio_unidad)
|
||||||
|
->set('precio_total', $tarifa->precio_total)
|
||||||
|
->insert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get resource data.
|
* Get resource data.
|
||||||
@ -57,7 +151,8 @@ class PresupuestoAcabadosModel 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.tarifa_acabado_id AS tarifa_acabado_id, t1.precio_unidad AS precio_unidad, t1.precio_total AS precio_total, t2.nombre AS nombre"
|
"t1.id AS id, t1.tarifa_acabado_id AS tarifa_acabado_id, t1.precio_unidad AS precio_unidad,
|
||||||
|
t1.precio_total AS precio_total, t2.nombre AS nombre"
|
||||||
);
|
);
|
||||||
|
|
||||||
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
||||||
|
|||||||
@ -14,11 +14,11 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
|||||||
protected $useAutoIncrement = true;
|
protected $useAutoIncrement = true;
|
||||||
|
|
||||||
const SORTABLE = [
|
const SORTABLE = [
|
||||||
1 => "t1.tarifa_encuadernado_id",
|
0 => "t1.tarifa_encuadernado_id",
|
||||||
2 => "t2.nombre",
|
1 => "t2.nombre",
|
||||||
4 => "t3.nombre",
|
2 => "t3.nombre",
|
||||||
5 => "t1.precio_unidad",
|
3 => "t1.precio_unidad",
|
||||||
6 => "t1.precio_total"
|
4 => "t1.precio_total"
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $allowedFields = ["presupuesto_id", "tarifa_encuadernado_id", "nombre", "precio_total", "precio_unidad"];
|
protected $allowedFields = ["presupuesto_id", "tarifa_encuadernado_id", "nombre", "precio_total", "precio_unidad"];
|
||||||
@ -61,11 +61,8 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
|||||||
|
|
||||||
if($modelTarifa->isTarifaPorHoras($tarifa['tarifa_encuadernacion_id'])){
|
if($modelTarifa->isTarifaPorHoras($tarifa['tarifa_encuadernacion_id'])){
|
||||||
|
|
||||||
$maquinaModel = model("App\Models\Configuracion\MaquinaModel");
|
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||||
$pliegos_libro = $paginas/4;
|
|
||||||
$pliegos_pedido = $pliegos_libro*$tirada;
|
|
||||||
$velocidad = $maquinaModel->getVelocidad(16); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
|
||||||
$tiempo = round($pliegos_pedido/($velocidad*60.0), 2);
|
|
||||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa['tarifa_encuadernacion_id'], $tiempo, $tirada);
|
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa['tarifa_encuadernacion_id'], $tiempo, $tirada);
|
||||||
if (count($tarifa_value)>0) {
|
if (count($tarifa_value)>0) {
|
||||||
|
|
||||||
@ -130,12 +127,8 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
|||||||
|
|
||||||
$proveedores = [];
|
$proveedores = [];
|
||||||
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||||
$maquinaModel = model("App\Models\Configuracion\MaquinaModel");
|
|
||||||
|
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||||
$pliegos_libro = $paginas/4;
|
|
||||||
$pliegos_pedido = $pliegos_libro*$tirada;
|
|
||||||
$velocidad = $maquinaModel->getVelocidad(16); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
|
||||||
$tiempo = round($pliegos_pedido/($velocidad*60.0), 2);
|
|
||||||
|
|
||||||
if($modelTarifa->isTarifaPorHoras($tarifa_encuadernacion_id)){
|
if($modelTarifa->isTarifaPorHoras($tarifa_encuadernacion_id)){
|
||||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa_encuadernacion_id, $tiempo, $tirada);
|
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa_encuadernacion_id, $tiempo, $tirada);
|
||||||
@ -190,11 +183,8 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
|||||||
public function getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD){
|
public function getPrecioTarifaHoras($tarifa_encuadernacion_id, $paginas, $tirada, $proveedor_id, $POD){
|
||||||
|
|
||||||
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
$modelTarifa = model('App\Models\Tarifas\TarifaEncuadernacionModel');
|
||||||
$maquinaModel = model("App\Models\Configuracion\MaquinaModel");
|
|
||||||
$pliegos_libro = $paginas/4;
|
$tiempo = $this->calcularTiempo(16, $paginas, $tirada); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
||||||
$pliegos_pedido = $pliegos_libro*$tirada;
|
|
||||||
$velocidad = $maquinaModel->getVelocidad(16); // ID fija. Cambiar cuando se metan maquinas de corte. Velocidad en minutos
|
|
||||||
$tiempo = round($pliegos_pedido/($velocidad*60.0), 2);
|
|
||||||
|
|
||||||
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa_encuadernacion_id, $tiempo, $tirada, $proveedor_id);
|
$tarifa_value = $modelTarifa->getTarifaPresupuestoEncuadernacionHoras($tarifa_encuadernacion_id, $tiempo, $tirada, $proveedor_id);
|
||||||
if (count($tarifa_value)>0) {
|
if (count($tarifa_value)>0) {
|
||||||
@ -228,7 +218,7 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function calcularTarifa($tarifa, $paginas, $is_POD=false){
|
private function calcularTarifa($tarifa, $paginas, $is_POD=false){
|
||||||
|
|
||||||
$precio_unidad = floatval($tarifa->precio_min) - (floatval($tarifa->precio_min) - floatval($tarifa->precio_max))/($tarifa->paginas_max - $tarifa->paginas_min) * ($paginas - $tarifa->paginas_min);
|
$precio_unidad = floatval($tarifa->precio_min) - (floatval($tarifa->precio_min) - floatval($tarifa->precio_max))/($tarifa->paginas_max - $tarifa->paginas_min) * ($paginas - $tarifa->paginas_min);
|
||||||
if ($paginas > $tarifa->paginas_max)
|
if ($paginas > $tarifa->paginas_max)
|
||||||
@ -334,4 +324,13 @@ class PresupuestoEncuadernacionesModel extends \App\Models\GoBaseModel
|
|||||||
|
|
||||||
return $builder;
|
return $builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function calcularTiempo($maquina_id, $paginas, $tirada){
|
||||||
|
|
||||||
|
$maquinaModel = model("App\Models\Configuracion\MaquinaModel");
|
||||||
|
$pliegos_libro = $paginas/4;
|
||||||
|
$pliegos_pedido = $pliegos_libro*$tirada;
|
||||||
|
$velocidad = $maquinaModel->getVelocidad($maquina_id);
|
||||||
|
return round($pliegos_pedido/($velocidad*60.0), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,5 +111,41 @@ class TarifaacabadoModel extends \App\Models\GoBaseModel
|
|||||||
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTarifaPresupuestoAcabado($tarifa_id, $tirada){
|
||||||
|
|
||||||
|
$builder = $this->db
|
||||||
|
->table($this->table . " t1")
|
||||||
|
->select(
|
||||||
|
"t1.id AS tarifa_acabado_id, t1.nombre AS tarifa_acabado_nombre, t1.precio_min AS tarifa_precio_min, t1.importe_fijo AS tarifa_importe_fijo,
|
||||||
|
t2.id AS tarifa_linea_id, t2.tirada_min AS tirada_min, t2.tirada_max AS tirada_max,
|
||||||
|
t2.precio_min AS precio_min, t2.precio_max AS precio_max, t2.margen AS margen"
|
||||||
|
)
|
||||||
|
->join("tarifa_acabado_lineas t2", "t1.id = t2.tarifa_acabado_id", "left")
|
||||||
|
->where("t1.is_deleted", 0)
|
||||||
|
//->where("t1.mostrar_en_presupuesto", 1)
|
||||||
|
->where("t2.is_deleted", 0);
|
||||||
|
|
||||||
|
$builder->where('t1.id =', $tarifa_id);
|
||||||
|
$builder->where('t2.tirada_min <=', $tirada);
|
||||||
|
$builder->where('t2.tirada_max >', $tirada);
|
||||||
|
|
||||||
|
return $builder->get()->getResultObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNombreTarifaAcabado($id=-1)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Todos los servicios de encuadernacion activas que se pueden usar en presupuestos
|
||||||
|
*/
|
||||||
|
$builder = $this->db
|
||||||
|
->table($this->table . " t1")
|
||||||
|
->select(
|
||||||
|
"t1.nombre AS nombre"
|
||||||
|
)
|
||||||
|
->where("t1.id", $id)
|
||||||
|
->where("t1.is_deleted", 0);
|
||||||
|
|
||||||
|
return $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,9 +64,14 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane fade show active" id="servicios-acabado" role="tabpanel">
|
<div class="tab-pane fade show active" id="servicios-acabado" role="tabpanel">
|
||||||
|
<div id="serv-acabado-alert">
|
||||||
|
</div>
|
||||||
|
<div id="serv-acabado-error">
|
||||||
|
</div>
|
||||||
<table id="tableOfServiciosAcabado" class="table table-striped table-hover" style="width: 100%;">
|
<table id="tableOfServiciosAcabado" class="table table-striped table-hover" style="width: 100%;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th><?= lang('Presupuestos.id') ?></th>
|
||||||
<th><?= lang('Tarifaacabado.tarifaacabado') ?></th>
|
<th><?= lang('Tarifaacabado.tarifaacabado') ?></th>
|
||||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||||
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
||||||
@ -76,8 +81,25 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<div class="row mb-3 px-4">
|
||||||
|
<div class="col-md-12 col-lg-4 py-4">
|
||||||
|
<select id="add_servicio_acabado_list" class="proveedor_enc select2bs2" style="width: 100%;">
|
||||||
|
<option></option>
|
||||||
|
<?php foreach ($serviciosAcabado 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_acabado" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="tab-pane fade" id="servicios-preimpresion" role="tabpanel">
|
<div class="tab-pane fade" id="servicios-preimpresion" role="tabpanel">
|
||||||
<table id="tableOfServiciosPreimpresion" class="table table-striped table-hover" style="width: 100%;">
|
<table id="tableOfServiciosPreimpresion" class="table table-striped table-hover" style="width: 100%;">
|
||||||
<thead>
|
<thead>
|
||||||
@ -164,6 +186,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
<?= $this->section("additionalInlineJs") ?>
|
||||||
|
|
||||||
const url = window.location.href;
|
const url = window.location.href;
|
||||||
const url_parts = url.split('/');
|
const url_parts = url.split('/');
|
||||||
if(url_parts[url_parts.length-2] == 'edit'){
|
if(url_parts[url_parts.length-2] == 'edit'){
|
||||||
@ -178,6 +201,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const POD = <?php echo $POD; ?>;
|
||||||
|
|
||||||
// Delete row
|
// Delete row
|
||||||
$(document).on('click', '.btn-delete-serv', function(e) {
|
$(document).on('click', '.btn-delete-serv', function(e) {
|
||||||
@ -188,156 +212,221 @@
|
|||||||
if($(this).closest('table').attr('id').includes('tableOfServiciosEncuadernacion')){
|
if($(this).closest('table').attr('id').includes('tableOfServiciosEncuadernacion')){
|
||||||
table = "tableOfServiciosEncuadernacion";
|
table = "tableOfServiciosEncuadernacion";
|
||||||
}
|
}
|
||||||
|
else if($(this).closest('table').attr('id').includes('tableOfServiciosAcabado')){
|
||||||
|
table = "tableOfServiciosAcabado";
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
table = "";
|
table = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#' + table).DataTable().rows( function ( idx, data, node ) {
|
if(table != ""){
|
||||||
return data[0] === dataId;
|
$('#' + table).DataTable().rows( function ( idx, data, node ) {
|
||||||
} )
|
return data[0] === dataId;
|
||||||
.remove()
|
} )
|
||||||
.draw();
|
.remove()
|
||||||
|
.draw();
|
||||||
|
}
|
||||||
|
|
||||||
check_serv_enc_error()
|
check_serv_enc_error()
|
||||||
|
check_serv_acabado_error()
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function save_servicios(){
|
||||||
|
|
||||||
|
var datosAcabado = get_datos_acabado()
|
||||||
|
|
||||||
|
var datosEnc = get_datos_encuadernacion()
|
||||||
|
const domain = window.location.origin
|
||||||
|
|
||||||
|
fetch(domain + "/presupuestos/presupuestoencuadernaciones/edit/" + id , {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({
|
||||||
|
datos: datosEnc,
|
||||||
|
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||||
|
}),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
yeniden(data.<?= csrf_token() ?>);
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
fetch(domain + "/presupuestos/presupuestoacabados/edit/" + id , {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({
|
||||||
|
datos: datosAcabado,
|
||||||
|
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||||
|
}),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
yeniden(data.<?= csrf_token() ?>);
|
||||||
|
})
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
<!------------------------------------------------------->
|
<!------------------------------------------------------->
|
||||||
<!-- Código JS comportamiento tabla servicios acabado. -->
|
<!-- Código JS comportamiento tabla servicios acabado. -->
|
||||||
<!------------------------------------------------------->
|
<!------------------------------------------------------->
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
<?= $this->section("additionalInlineJs") ?>
|
||||||
/*
|
|
||||||
const lastColNr = $('#tableOfServiciosAcabado').find("tr:first th").length - 1;
|
|
||||||
|
|
||||||
|
|
||||||
editor = new $.fn.dataTable.Editor( {
|
|
||||||
ajax: {
|
|
||||||
url: "<?= route_to('editorOfPresupuestoAcabados') ?>",
|
|
||||||
headers: {
|
|
||||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
table : "#tableOfServiciosAcabado",
|
|
||||||
idSrc: 'id',
|
|
||||||
fields: [ {
|
|
||||||
"name": "tarifa_acabado_id",
|
|
||||||
"type": "select"
|
|
||||||
}, {
|
|
||||||
"name": "precio_unidad"
|
|
||||||
}, {
|
|
||||||
"name": "precio_total"
|
|
||||||
}, {
|
|
||||||
"name": "presupuesto_id",
|
|
||||||
"type": "hidden"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
} );
|
|
||||||
|
|
||||||
// Generación de la lista de servicios de acabado (id, nombre)
|
// Generación de la lista de servicios de acabado (id, nombre)
|
||||||
const acabadosList = <?php echo json_encode($serviciosAcabado); ?>;
|
const acabadosList = <?php echo json_encode($serviciosAcabado); ?>;
|
||||||
editor.field( 'tarifa_acabado_id' ).update( acabadosList );
|
|
||||||
|
|
||||||
editor.on( 'preSubmit', function ( e, d, type ) {
|
|
||||||
if ( type === 'create'){
|
|
||||||
d.data[0]['presupuesto_id'] = id;
|
|
||||||
}
|
|
||||||
else if(type === 'edit' ) {
|
|
||||||
for (v in d.data){
|
|
||||||
d.data[v]['presupuesto_id'] = id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
editor.on( 'postSubmit', function ( e, json, data, action ) {
|
|
||||||
yeniden(json.<?= csrf_token() ?>);
|
|
||||||
});
|
|
||||||
|
|
||||||
editor.on( 'submitSuccess', function ( e, json, data, action ) {
|
|
||||||
theTable.clearPipeline();
|
|
||||||
theTable.draw();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Activate an inline edit on click of a table cell
|
|
||||||
$('#tableOfServiciosAcabado').on( 'click', 'tbody span.edit', function (e) {
|
|
||||||
editor.inline(
|
|
||||||
theTable.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'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} );
|
|
||||||
|
|
||||||
|
|
||||||
var theTable = $('#tableOfServiciosAcabado').DataTable( {
|
var tableServiciosAcabado = new DataTable('#tableOfServiciosAcabado',{
|
||||||
draw: 1,
|
scrollX: true,
|
||||||
serverSide: true,
|
|
||||||
processing: true,
|
|
||||||
autoWidth: true,
|
|
||||||
responsive: true,
|
|
||||||
lengthMenu: [ 5, 10, 25],
|
|
||||||
order: [[ 0, "asc" ], [ 1, "asc" ]],
|
|
||||||
pageLength: 10,
|
|
||||||
lengthChange: true,
|
|
||||||
searching: false,
|
searching: false,
|
||||||
paging: true,
|
paging: false,
|
||||||
info: false,
|
info: false,
|
||||||
dom: '<"mt-4"><"float-start"l><t><"mt-4 mb-3"p>',
|
ordering: false,
|
||||||
ajax : $.fn.dataTable.pipeline( {
|
responsive: true,
|
||||||
url: '<?= route_to('dataTableOfPresupuestoAcabados') ?>',
|
select: false,
|
||||||
data: {
|
|
||||||
id_presupuesto: id,
|
|
||||||
},
|
|
||||||
method: 'POST',
|
|
||||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
|
||||||
async: false,
|
|
||||||
}),
|
|
||||||
columns: [
|
|
||||||
{ 'data': 'id'},
|
|
||||||
{ 'data': 'tarifa_acabado_id'},
|
|
||||||
{ 'data': 'precio_unidad' },
|
|
||||||
{ 'data': 'precio_total' },
|
|
||||||
{
|
|
||||||
data: actionBtns,
|
|
||||||
className: 'row-edit dt-center'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
columnDefs: [
|
|
||||||
{'visible':false, 'targets' : 2},
|
|
||||||
{
|
|
||||||
orderable: false,
|
|
||||||
searchable: false,
|
|
||||||
targets: [lastColNr]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"orderData": [ 0, 1 ],
|
|
||||||
"targets": 1
|
|
||||||
},
|
|
||||||
|
|
||||||
],
|
|
||||||
language: {
|
language: {
|
||||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||||
},
|
},
|
||||||
buttons: [ {
|
|
||||||
className: 'btn btn-primary float-end me-sm-3 me-1',
|
});
|
||||||
extend: "createInline",
|
|
||||||
editor: editor,
|
|
||||||
formOptions: {
|
|
||||||
submitTrigger: -1,
|
|
||||||
submitHtml: '<i class="ti ti-device-floppy"/>'
|
|
||||||
}
|
|
||||||
} ]
|
|
||||||
} );
|
|
||||||
|
|
||||||
function init_servicio_acabado(){
|
function init_servicio_acabado(){
|
||||||
|
const serviciosacabadosList = <?php echo json_encode($serviciosAcabadosList); ?>;
|
||||||
|
|
||||||
|
$('#add_servicio_acabado_list').select2({
|
||||||
|
allowClear: false,
|
||||||
|
minimumResultsForSearch: -1,
|
||||||
|
placeholder: '<?= lang("Presupuestos.servicioAcabadoList") ?>'
|
||||||
|
})
|
||||||
|
|
||||||
|
serviciosacabadosList.forEach((element) =>{
|
||||||
|
|
||||||
|
tableServiciosAcabado.row.add([
|
||||||
|
element.tarifa_acabado_id,
|
||||||
|
element.nombre,
|
||||||
|
'<span id="precio_unidad_' + element.tarifa_acabado_id + '">' + parseFloat(element.precio_unidad).toFixed(2) + '</span>',
|
||||||
|
'<input id="precio_total_' + element.tarifa_acabado_id +'" value="' + parseFloat(element.precio_total).toFixed(2) + '"></input>',
|
||||||
|
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + element.tarifa_acabado_id +'"></i></a>'
|
||||||
|
]).draw(false)
|
||||||
|
|
||||||
|
})
|
||||||
|
check_serv_acabado_error()
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
function check_serv_acabado_error(){
|
||||||
|
|
||||||
|
var htmlString = '';
|
||||||
|
|
||||||
|
$('#tableOfServiciosAcabado tr').each(function(){
|
||||||
|
if($(this).find('td').eq(2).text() == '0.00'){
|
||||||
|
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"><?= lang("Presupuestos.errores.error_servicios_anadidos") ?></h5>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$('#serv-acabado-error').html(htmlString)
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_tarifas_acabado(tarifa_id = -1){
|
||||||
|
const dimension = getDimensionLibro();
|
||||||
|
|
||||||
|
if(parseInt($('#tirada').val())>0){
|
||||||
|
var tirada = parseInt($('#tirada').val())
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
var tirada = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
var datos = {
|
||||||
|
tarifa_acabado_id : tarifa_id,
|
||||||
|
tirada: tirada,
|
||||||
|
POD: POD,
|
||||||
|
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: '<?=route_to('dataTableOfPresupuestoAcabados') ?>',
|
||||||
|
data: datos,
|
||||||
|
success: function (data) {
|
||||||
|
|
||||||
|
data.values.forEach((row) => {
|
||||||
|
|
||||||
|
tableServiciosAcabado.row.add([
|
||||||
|
row.tarifa_id,
|
||||||
|
row.tarifa_nombre,
|
||||||
|
'<span id="precio_unidad_' + row.tarifa_id + '">' + parseFloat(row.precio_unidad).toFixed(2) + '</span>',
|
||||||
|
'<input id="precio_total_' + row.tarifa_id +'" value="' + parseFloat(row.total).toFixed(2) + '"></input>',
|
||||||
|
'<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)
|
||||||
|
});
|
||||||
|
|
||||||
|
check_serv_acabado_error()
|
||||||
|
yeniden(data.<?= csrf_token() ?>);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
error: function(e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#insertar_serv_acabado').on('click', function(){
|
||||||
|
const tarifa_text = $('#add_servicio_acabado_list').select2('data')[0].text.trim()
|
||||||
|
|
||||||
|
if( $('#add_servicio_acabado_list').select2('data')[0].text.trim().length > 0){
|
||||||
|
if($('#tableOfServiciosAcabado tr > td:contains(' + tarifa_text + ')').length == 0)
|
||||||
|
get_tarifas_acabado($('#add_servicio_acabado_list').select2('data')[0].id);
|
||||||
|
else{
|
||||||
|
popErrorAlert("Ese servicio ya existe", 'serv-acabado-alert')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
check_serv_enc_error()
|
||||||
|
})
|
||||||
|
|
||||||
|
function get_datos_acabado(){
|
||||||
|
|
||||||
|
var datosAcabado = []
|
||||||
|
$("#tableOfServiciosAcabado 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_unidad'] = $(this).text()
|
||||||
|
break
|
||||||
|
case 3:
|
||||||
|
values['precio_total'] = $(this).children(":first").val()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(Object.keys(values).length>0)
|
||||||
|
datosAcabado.push(values)
|
||||||
|
})
|
||||||
|
|
||||||
|
return datosAcabado
|
||||||
|
}
|
||||||
|
|
||||||
|
init_servicio_acabado()
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
<!-------------------------------------------------------------->
|
<!-------------------------------------------------------------->
|
||||||
@ -345,8 +434,6 @@
|
|||||||
<!-------------------------------------------------------------->
|
<!-------------------------------------------------------------->
|
||||||
<?= $this->section("additionalInlineJs") ?>
|
<?= $this->section("additionalInlineJs") ?>
|
||||||
|
|
||||||
const POD = <?php echo $POD; ?>;
|
|
||||||
|
|
||||||
// Generación de la lista de servicios de acabado (id, nombre)
|
// Generación de la lista de servicios de acabado (id, nombre)
|
||||||
const encuadernadosList = <?php echo json_encode($serviciosEncuadernacion); ?>;
|
const encuadernadosList = <?php echo json_encode($serviciosEncuadernacion); ?>;
|
||||||
|
|
||||||
@ -610,9 +697,9 @@
|
|||||||
check_serv_enc_error()
|
check_serv_enc_error()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function get_datos_encuadernacion(){
|
||||||
function save_servicios(){
|
|
||||||
var datos = []
|
var datosEnc = []
|
||||||
$("#tableOfServiciosEncuadernacion tr").each(function (index,tr) {
|
$("#tableOfServiciosEncuadernacion tr").each(function (index,tr) {
|
||||||
var values = {}
|
var values = {}
|
||||||
$(this).find("td").each(function (index2) {
|
$(this).find("td").each(function (index2) {
|
||||||
@ -633,28 +720,13 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
if(Object.keys(values).length>0)
|
if(Object.keys(values).length>0)
|
||||||
datos.push(values)
|
datosEnc.push(values)
|
||||||
})
|
})
|
||||||
|
|
||||||
const domain = window.location.origin
|
return datosEnc
|
||||||
|
|
||||||
fetch(domain + "/presupuestos/presupuestoencuadernaciones/edit/" + id , {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({
|
|
||||||
datos: datos,
|
|
||||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
"Content-type": "application/json; charset=UTF-8"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
yeniden(data.<?= csrf_token() ?>);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
init_servicio_encuadernado()
|
init_servicio_encuadernado()
|
||||||
|
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user