mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
finalizado el controlador máquinas
This commit is contained in:
@ -255,7 +255,7 @@ $routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\
|
|||||||
$routes->group('maquinaspapelesimpresion', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
$routes->group('maquinaspapelesimpresion', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||||
$routes->post('datatable', 'Maquinaspapelesimpresion::datatable', ['as' => 'dataTableOfMaquinasPapelesImpresion']);
|
$routes->post('datatable', 'Maquinaspapelesimpresion::datatable', ['as' => 'dataTableOfMaquinasPapelesImpresion']);
|
||||||
$routes->post('datatable_editor', 'Maquinaspapelesimpresion::datatable_editor', ['as' => 'editorOfMaquinasPapelImpresion']);
|
$routes->post('datatable_editor', 'Maquinaspapelesimpresion::datatable_editor', ['as' => 'editorOfMaquinasPapelImpresion']);
|
||||||
$routes->post('updateOnTarifasChange', 'Maquinaspapelesimpresion::updateOnTarifasChange', ['as' => 'updateMaquinaPapelOnTarifasChange']);
|
$routes->post('updateTableOnChange', 'Maquinaspapelesimpresion::updateTableOnChange', ['as' => 'updateMaquinaPapelOnTarifasChange']);
|
||||||
});
|
});
|
||||||
$routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinastarifasimpresion', 'except' => 'show,new,create,update']);
|
$routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinastarifasimpresion', 'except' => 'show,new,create,update']);
|
||||||
|
|
||||||
|
|||||||
@ -100,7 +100,7 @@ class Maquinaspapelesimpresion extends \App\Controllers\GoBaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateOnTarifasChange(){
|
public function updateTableOnChange(){
|
||||||
|
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
@ -119,88 +119,24 @@ class Maquinaspapelesimpresion extends \App\Controllers\GoBaseResourceController
|
|||||||
// 1- Se obtienen los papeles que hay seleccionados (de la tabla lg_maquina_papel_impresion y que coincidan con las tarifas actuales)
|
// 1- Se obtienen los papeles que hay seleccionados (de la tabla lg_maquina_papel_impresion y que coincidan con las tarifas actuales)
|
||||||
$initData = $this->model->getInitData($isRotativa, $tarifas, $maquina_id);
|
$initData = $this->model->getInitData($isRotativa, $tarifas, $maquina_id);
|
||||||
// 2- Se cuentan los resultados. Si no hay coincidencias, hay que crear la tabla pivote con todos los papeles que cumplan la
|
// 2- Se cuentan los resultados. Si no hay coincidencias, hay que crear la tabla pivote con todos los papeles que cumplan la
|
||||||
// condición de las tarifas y con la columna active a 0. Si hay coincidencias, se guardan los activos en un array
|
// condición de las tarifas y con la columna active a 0. Si hay coincidencias, se guardan los activos en un array
|
||||||
|
$selected_papers = $initData->countAllResults();
|
||||||
$active_values = [];
|
$active_values = [];
|
||||||
if($initData->countAllResults() != 0){
|
if($selected_papers > 0){
|
||||||
$active_values = $this->model->getInitData($isRotativa, $tarifas, $maquina_id)->get()->getResult('array');
|
$active_values = $this->model->getInitData($isRotativa, $tarifas, $maquina_id)->get()->getResult('array');
|
||||||
}
|
}
|
||||||
// Primero se borran las filas con la maquina_id de la tabla pivote
|
// Primero se borran las filas con la maquina_id de la tabla pivote
|
||||||
$this->model->deleteRows($maquina_id);
|
$this->model->deleteRows($maquina_id);
|
||||||
|
|
||||||
// Se insertan en la tabla pivote los resultados de los papeles que cumplan con las tarifas con el campo active = 0
|
// Se insertan en la tabla pivote los resultados de los papeles que cumplan con las tarifas con el campo active = 0
|
||||||
$papeles_ids = $papelimpresion_model->getIdPapelesActivos($tarifas)->get()->getResult('array');
|
$data = $papelimpresion_model->getIdPapelesImpresion($maquina_id, $tarifas)->get()->getResult('array');
|
||||||
$data = [];
|
|
||||||
foreach($papeles_ids as $papel_id){
|
|
||||||
$value = [
|
|
||||||
'active' => 0,
|
|
||||||
'maquina_id' => $maquina_id,
|
|
||||||
'papel_impresion_id' => $papel_id['id']
|
|
||||||
];
|
|
||||||
array_push($data, $value);
|
|
||||||
}
|
|
||||||
$this->model->insertRows($data);
|
$this->model->insertRows($data);
|
||||||
|
|
||||||
// Se actualizan los activos que había en caso de que los hubiera
|
// Se actualizan los activos que había en caso de que los hubiera
|
||||||
if(!empty($active_values)){
|
if(count($active_values)>0){
|
||||||
$this->model->updateRows($active_values);
|
$this->model->updateRows($active_values);
|
||||||
}
|
}
|
||||||
} 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, 'lg_maquinas_tarifas_impresion' )
|
|
||||||
->fields(
|
|
||||||
Field::inst( 'maquina_id' ),
|
|
||||||
Field::inst( 'papel_impresion_id' ),
|
|
||||||
Field::inst( 'active' )
|
|
||||||
|
|
||||||
)
|
|
||||||
->validator( function($editor, $action, $data){
|
|
||||||
if ($action === Editor::ACTION_EDIT){
|
|
||||||
foreach ($data['data'] as $pkey => $values ){
|
|
||||||
/*// Si no se quiere borrar...
|
|
||||||
if($data['data'][$pkey]['is_deleted'] != 1)
|
|
||||||
{
|
|
||||||
// Cubierta y sobrecubierta sólo pueden ser en color
|
|
||||||
if($values['uso'] != 'interior' && $values['tipo'] != 'color'){
|
|
||||||
return lang('MaquinasTarifasImpresions.validation.cubierta_sobrecubierta_color');
|
|
||||||
}
|
|
||||||
|
|
||||||
$builder = $this->model->select('*')
|
|
||||||
->where(array(
|
|
||||||
'maquina_id'=> $values['maquina_id'],
|
|
||||||
'tipo'=> $values['tipo'],
|
|
||||||
'uso'=> $values['uso'],
|
|
||||||
'is_deleted'=> 0));
|
|
||||||
|
|
||||||
if ($builder->countAllResults() >= 1){
|
|
||||||
if(($action === Editor::ACTION_EDIT && $builder->get()->getFirstRow()->id != $pkey)
|
|
||||||
|| $action === Editor::ACTION_CREATE)
|
|
||||||
return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
|
|
||||||
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->debug(true)
|
|
||||||
->process( $_POST )
|
|
||||||
->data();
|
|
||||||
|
|
||||||
|
|
||||||
/*// if unique key is set in DB
|
|
||||||
if(isset($response['error'])){
|
|
||||||
if(str_contains($response['error'], "tirada_min_tirada_max") &&
|
|
||||||
str_contains($response['error'], "Duplicate entry ")){
|
|
||||||
$response['error'] = lang('TarifaAcabadoLineas.validation.duplicated_tirada');
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
$newTokenHash = csrf_hash();
|
$newTokenHash = csrf_hash();
|
||||||
$csrfTokenName = csrf_token();
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
@ -213,5 +149,55 @@ class Maquinaspapelesimpresion extends \App\Controllers\GoBaseResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function datatable_editor() {
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
|
$reqData = $this->request->getPost();
|
||||||
|
if($reqData['action'] =='edit'){
|
||||||
|
|
||||||
|
$rec_data = $reqData['data'];
|
||||||
|
$key = array_key_first($rec_data);
|
||||||
|
$maquina_id = $rec_data[$key]['maquina_id'] ?? -1;
|
||||||
|
$papel_id = $rec_data[$key]['papel_impresion_id'] ?? -1;
|
||||||
|
$active = $rec_data[$key]['active'] ?? -1;
|
||||||
|
$gramaje = $rec_data[$key]['gramaje'] ?? -1;
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'maquina_id' => $maquina_id,
|
||||||
|
'papel_impresion_id' => $papel_id,
|
||||||
|
'active' => $active,
|
||||||
|
];
|
||||||
|
|
||||||
|
// Se checkea que no haya otro papel con ese gramaje seleccionado y que la accion sea activar ese papel
|
||||||
|
if($this->model->getPapelActivo($maquina_id, $gramaje)->countAllResults() != 0 && intval($active)==1){
|
||||||
|
$response['error']= lang('MaquinasPapelImpresion.gramaje_duplicado');;
|
||||||
|
$ret_vals = [
|
||||||
|
'DT_RowId' => 'row_'. $papel_id,
|
||||||
|
'maquina_id' => $maquina_id,
|
||||||
|
'papel_impresion_id' => $papel_id,
|
||||||
|
'active' => '0',
|
||||||
|
];
|
||||||
|
$response['data'] = $ret_vals;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$this->model->updateRows([$data]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$newTokenHash = csrf_hash();
|
||||||
|
$csrfTokenName = csrf_token();
|
||||||
|
|
||||||
|
$response[$csrfTokenName] = $newTokenHash;
|
||||||
|
|
||||||
|
echo json_encode($response);
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -255,18 +255,21 @@ if ($this->request->getPost('predeterminado') == null ) {
|
|||||||
return lang('MaquinasTarifasImpresions.validation.cubierta_sobrecubierta_color');
|
return lang('MaquinasTarifasImpresions.validation.cubierta_sobrecubierta_color');
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder = $this->model->select('*')
|
// No se pueden duplicar valores al crear
|
||||||
->where(array(
|
if($action === Editor::ACTION_CREATE){
|
||||||
'maquina_id'=> $values['maquina_id'],
|
$builder = $this->model->select('*')
|
||||||
'tipo'=> $values['tipo'],
|
->where(array(
|
||||||
'uso'=> $values['uso'],
|
'maquina_id'=> $values['maquina_id'],
|
||||||
'is_deleted'=> 0));
|
'tipo'=> $values['tipo'],
|
||||||
|
'uso'=> $values['uso'],
|
||||||
|
'is_deleted'=> 0));
|
||||||
|
|
||||||
if ($builder->countAllResults() >= 1){
|
if ($builder->countAllResults() >= 1){
|
||||||
if(($action === Editor::ACTION_EDIT && $builder->get()->getFirstRow()->id != $pkey)
|
if(($action === Editor::ACTION_EDIT && $builder->get()->getFirstRow()->id != $pkey)
|
||||||
|| $action === Editor::ACTION_CREATE)
|
|| $action === Editor::ACTION_CREATE)
|
||||||
return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
|
return lang('MaquinasTarifasImpresions.validation.duplicated_uso_tipo');
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -144,6 +144,8 @@ class LoginAuthFilter implements FilterInterface
|
|||||||
'Viewmode',
|
'Viewmode',
|
||||||
'GoBaseController',
|
'GoBaseController',
|
||||||
'GoBaseResourceController',
|
'GoBaseResourceController',
|
||||||
|
'Maquinaspapelesimpresion',
|
||||||
|
'Maquinastarifasimpresion',
|
||||||
'My', 'Usuarios', 'Notification' // PARA LA DEMO
|
'My', 'Usuarios', 'Notification' // PARA LA DEMO
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@ -80,10 +80,12 @@ return [
|
|||||||
'text' => 'This action cannot be undone.',
|
'text' => 'This action cannot be undone.',
|
||||||
'title' => 'Are you sure?',
|
'title' => 'Are you sure?',
|
||||||
'maxRowsReached' => 'No more lines can be added.',
|
'maxRowsReached' => 'No more lines can be added.',
|
||||||
'line' => 'the line'
|
'line' => 'the line',
|
||||||
|
'error_tittle' => 'Error',
|
||||||
],
|
],
|
||||||
'ok' => 'Ok',
|
'ok' => 'Ok',
|
||||||
'wait' => 'Wait',
|
'wait' => 'Wait',
|
||||||
|
'yes' => 'Yes',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,5 +4,7 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'activo' => 'Active',
|
'activo' => 'Active',
|
||||||
|
'gramaje_duplicado' => 'It can not be selected two pieces of paper with the same grammage',
|
||||||
|
'sureToChangeRotativaTitle' => 'Are you sure to change this option?',
|
||||||
|
'sureToChangeRotativaText' => 'This operation can\'t undone and the paper list will change.',
|
||||||
];
|
];
|
||||||
@ -80,11 +80,12 @@ return [
|
|||||||
'text' => 'Esta acción no se puede deshacer.',
|
'text' => 'Esta acción no se puede deshacer.',
|
||||||
'title' => 'Está seguro?',
|
'title' => 'Está seguro?',
|
||||||
'maxRowsReached' => 'No se pueden añadir más líneas.',
|
'maxRowsReached' => 'No se pueden añadir más líneas.',
|
||||||
'line' => 'la línea'
|
'line' => 'la línea',
|
||||||
|
'error_tittle' => 'Error',
|
||||||
],
|
],
|
||||||
'ok' => 'Ok',
|
'ok' => 'Ok',
|
||||||
'wait' => 'Espere',
|
'wait' => 'Espere',
|
||||||
|
'yes' => 'Si',
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@ -4,5 +4,7 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'activo' => 'Activo',
|
'activo' => 'Activo',
|
||||||
|
'gramaje_duplicado' => 'No se pueden seleccionar dos papeles con el mismo gramaje',
|
||||||
|
'sureToChangeRotativaTitle' => 'Está seguro de cambiar esta opción?',
|
||||||
|
'sureToChangeRotativaText' => 'Está operación no se puede deshacer y cambiará la lista de papeles.',
|
||||||
];
|
];
|
||||||
@ -55,12 +55,9 @@ class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
|
|||||||
$builder->where("t3.is_deleted", 0);
|
$builder->where("t3.is_deleted", 0);
|
||||||
$builder->where("t4.is_deleted", 0);
|
$builder->where("t4.is_deleted", 0);
|
||||||
$builder->where("t3.isActivo", 1);
|
$builder->where("t3.isActivo", 1);
|
||||||
|
|
||||||
|
|
||||||
$builder->where("t3.rotativa", $isRotativa);
|
$builder->where("t3.rotativa", $isRotativa);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$isFirst = true;
|
$isFirst = true;
|
||||||
$where_str = "(";
|
$where_str = "(";
|
||||||
//Si hay tarifas...
|
//Si hay tarifas...
|
||||||
@ -92,7 +89,7 @@ class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
|
|||||||
$builder->where("t3.bn", 2);
|
$builder->where("t3.bn", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return empty($search)
|
return empty($search)
|
||||||
? $builder
|
? $builder
|
||||||
: $builder
|
: $builder
|
||||||
@ -110,7 +107,6 @@ class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
|
|||||||
"t1.*"
|
"t1.*"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$builder->join("lg_papel_impresion t2", "t1.papel_impresion_id = t2.id", "left");
|
$builder->join("lg_papel_impresion t2", "t1.papel_impresion_id = t2.id", "left");
|
||||||
|
|
||||||
$builder->where("t1.maquina_id", $maquina_id);
|
$builder->where("t1.maquina_id", $maquina_id);
|
||||||
@ -118,11 +114,9 @@ class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
|
|||||||
$builder->where("t2.isActivo", 1);
|
$builder->where("t2.isActivo", 1);
|
||||||
$builder->where("t2.rotativa", $isRotativa);
|
$builder->where("t2.rotativa", $isRotativa);
|
||||||
$builder->where("t1.active", 1);
|
$builder->where("t1.active", 1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$isFirst = true;
|
$isFirst = true;
|
||||||
$where_str = "";
|
$where_str = "(";
|
||||||
//Si hay tarifas...
|
//Si hay tarifas...
|
||||||
if (!empty($tarifas)){
|
if (!empty($tarifas)){
|
||||||
foreach ($tarifas as $tarifa){
|
foreach ($tarifas as $tarifa){
|
||||||
@ -142,18 +136,37 @@ class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
|
|||||||
$where_str .= "`t2`.`color`=1 ";
|
$where_str .= "`t2`.`color`=1 ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$where_str .= ")";
|
||||||
$builder->where($where_str);
|
$builder->where($where_str);
|
||||||
}
|
}
|
||||||
// si no hay tarifas no hay que devolver nada
|
// si no hay tarifas no hay que devolver nada
|
||||||
else{
|
else{
|
||||||
// Se pone una condicion que no se puede dar
|
// Se pone una condicion que no se puede dar
|
||||||
$builder->where("t3.bn", 2);
|
$builder->where("t2.bn", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $builder;
|
return $builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Funcion para consultar los papeles activos con un gramaje
|
||||||
|
// determinado seleccionados para una máquina
|
||||||
|
public function getPapelActivo($maquina_id=-1, $gramaje=-1){
|
||||||
|
$builder = $this->db
|
||||||
|
->table($this->table . " t1")
|
||||||
|
->select(
|
||||||
|
"t1.*"
|
||||||
|
);
|
||||||
|
$builder->join("lg_papel_impresion t2", "t1.papel_impresion_id = t2.id", "left");
|
||||||
|
|
||||||
|
$builder->where('t1.active', 1);
|
||||||
|
$builder->where('t1.maquina_id', $maquina_id);
|
||||||
|
$builder->where('t2.gramaje', $gramaje);
|
||||||
|
|
||||||
|
return $builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Funcion que borra todos los registros de una máquina determinada
|
||||||
public function deleteRows($maquina_id = -1){
|
public function deleteRows($maquina_id = -1){
|
||||||
$this->db
|
$this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
@ -161,12 +174,15 @@ class MaquinasPapelesImpresionModel extends \App\Models\GoBaseModel
|
|||||||
->delete();
|
->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Funcion que inserta valores en la tabla
|
||||||
public function insertRows($values = []){
|
public function insertRows($values = []){
|
||||||
if (!empty($values)){
|
if (!empty($values)){
|
||||||
$this->db->table($this->table)->insertBatch($values);
|
$this->db->table($this->table)->insertBatch($values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Funcion que actualiza valores en la tabla
|
||||||
public function updateRows($values = []){
|
public function updateRows($values = []){
|
||||||
if (!empty($values)){
|
if (!empty($values)){
|
||||||
foreach($values as $value){
|
foreach($values as $value){
|
||||||
|
|||||||
@ -13,15 +13,12 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel
|
|||||||
protected $useAutoIncrement = true;
|
protected $useAutoIncrement = true;
|
||||||
|
|
||||||
const SORTABLE = [
|
const SORTABLE = [
|
||||||
1 => "t1.id",
|
1 => "t1.tipo",
|
||||||
2 => "t1.maquina_id",
|
2 => "t1.uso",
|
||||||
3 => "t1.tipo",
|
3 => "t1.precio",
|
||||||
4 => "t1.precio",
|
|
||||||
5 => "t1.uso",
|
|
||||||
6 => "t2.nombre",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $allowedFields = ["maquina_id", "tipo", "precio", "uso"];
|
protected $allowedFields = ["maquina_id", "tipo", "precio", "uso", "user_created_id", "user_updated_id", "is_deleted", "deleted_at", "created_at", "updated_at"];
|
||||||
protected $returnType = "App\Entities\Configuracion\MaquinasTarifasImpresionEntity";
|
protected $returnType = "App\Entities\Configuracion\MaquinasTarifasImpresionEntity";
|
||||||
|
|
||||||
protected $useTimestamps = true;
|
protected $useTimestamps = true;
|
||||||
@ -95,7 +92,7 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel
|
|||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS id, t1.tipo AS tipo, t1.precio AS precio, t1.uso AS uso, t2.nombre AS maquina"
|
"t1.id AS id, t1.tipo AS tipo, t1.precio AS precio, t1.uso AS uso"
|
||||||
);
|
);
|
||||||
|
|
||||||
//JJO
|
//JJO
|
||||||
@ -112,13 +109,11 @@ class MaquinasTarifasImpresionModel extends \App\Models\GoBaseModel
|
|||||||
->orLike("t1.tipo", $search)
|
->orLike("t1.tipo", $search)
|
||||||
->orLike("t1.precio", $search)
|
->orLike("t1.precio", $search)
|
||||||
->orLike("t1.uso", $search)
|
->orLike("t1.uso", $search)
|
||||||
->orLike("t2.id", $search)
|
|
||||||
->orLike("t1.id", $search)
|
->orLike("t1.id", $search)
|
||||||
->orLike("t1.maquina_id", $search)
|
->orLike("t1.maquina_id", $search)
|
||||||
->orLike("t1.tipo", $search)
|
->orLike("t1.tipo", $search)
|
||||||
->orLike("t1.precio", $search)
|
->orLike("t1.precio", $search)
|
||||||
->orLike("t1.uso", $search)
|
->orLike("t1.uso", $search)
|
||||||
->orLike("t2.nombre", $search)
|
|
||||||
->groupEnd();
|
->groupEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -231,12 +231,12 @@ class PapelImpresionModel extends \App\Models\GoBaseModel
|
|||||||
->groupEnd();
|
->groupEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIdPapelesActivos($tarifas = [])
|
public function getIdPapelesImpresion($maquina_id = -1, $tarifas = [])
|
||||||
{
|
{
|
||||||
$builder = $this->db
|
$builder = $this->db
|
||||||
->table($this->table . " t1")
|
->table($this->table . " t1")
|
||||||
->select(
|
->select(
|
||||||
"t1.id AS id"
|
"'".$maquina_id."'". " as maquina_id, t1.id AS papel_impresion_id, '0' as active"
|
||||||
);
|
);
|
||||||
|
|
||||||
$builder->where("t1.is_deleted", 0);
|
$builder->where("t1.is_deleted", 0);
|
||||||
|
|||||||
@ -128,20 +128,38 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#isRotativa').on("click",function(el){
|
$('#isRotativa').on("click",function(el){
|
||||||
if($(this).is(':checked')){
|
|
||||||
|
Swal.fire({
|
||||||
$("#datosRotativa").show();
|
title: '<?= lang('MaquinasPapelImpresion.sureToChangeRotativaTitle') ?>',
|
||||||
isRotativa.watch = 1;
|
text: '<?= lang('MaquinasPapelImpresion.sureToChangeRotativaText') ?>',
|
||||||
|
icon: 'warning',
|
||||||
}else{
|
showCancelButton: true,
|
||||||
document.getElementById("precioTintaNegro").value = null;
|
confirmButtonColor: '#3085d6',
|
||||||
document.getElementById("precioTintaColor").value = null;
|
confirmButtonText: '<?= lang('Basic.global.yes') ?>',
|
||||||
document.getElementById("velocidadCorte").value = null;
|
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
|
||||||
document.getElementById("precioHoraCorte").value = null;
|
cancelButtonColor: '#d33'
|
||||||
document.getElementById("metrosxminuto").value = null;
|
})
|
||||||
$("#datosRotativa").hide();
|
.then((result) => {
|
||||||
isRotativa.watch = 0;
|
if (result.value) {
|
||||||
}
|
|
||||||
|
if($(this).is(':checked')){
|
||||||
|
isRotativa.watch = 1;
|
||||||
|
$("#datosRotativa").show();
|
||||||
|
}else{
|
||||||
|
document.getElementById("precioTintaNegro").value = null;
|
||||||
|
document.getElementById("precioTintaColor").value = null;
|
||||||
|
document.getElementById("velocidadCorte").value = null;
|
||||||
|
document.getElementById("precioHoraCorte").value = null;
|
||||||
|
document.getElementById("metrosxminuto").value = null;
|
||||||
|
$("#datosRotativa").hide();
|
||||||
|
isRotativa.watch = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
theTable2.clearPipeline();
|
||||||
|
theTable2.draw();
|
||||||
|
yeniden(response.<?= csrf_token() ?>);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#isPadre').on("click",function(el){
|
$('#isPadre').on("click",function(el){
|
||||||
@ -268,24 +286,27 @@
|
|||||||
editor.on( 'postSubmit', function ( e, json, data, action ) {
|
editor.on( 'postSubmit', function ( e, json, data, action ) {
|
||||||
|
|
||||||
yeniden(json.<?= csrf_token() ?>);
|
yeniden(json.<?= csrf_token() ?>);
|
||||||
});
|
|
||||||
|
|
||||||
editor.on( 'submitSuccess', function ( e, json, data, action ) {
|
setTimeout(() => {
|
||||||
|
console.log("1 Segundo esperado")
|
||||||
theTable.clearPipeline();
|
}, 1000);
|
||||||
theTable.draw();
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '<?= route_to('updateMaquinaPapelOnTarifasChange') ?>',
|
url: '<?= route_to('updateMaquinaPapelOnTarifasChange') ?>',
|
||||||
data: function (d) {
|
data: {
|
||||||
d.id_maquina= id;
|
maquina_id: id,
|
||||||
d.isRotativa = isRotativa.watch;
|
isRotativa: isRotativa.watch,
|
||||||
d.<?= csrf_token() ?? "token" ?> = <?= csrf_token() ?>v;
|
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
|
||||||
},
|
},
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||||
success:function(response){
|
success:function(response){
|
||||||
yeniden(response.<?= csrf_token() ?>);
|
|
||||||
|
token=JSON.parse(response).<?= csrf_token() ?>;
|
||||||
|
yeniden(token);
|
||||||
|
|
||||||
|
theTable.clearPipeline();
|
||||||
|
theTable.draw();
|
||||||
|
|
||||||
theTable2.clearPipeline();
|
theTable2.clearPipeline();
|
||||||
theTable2.draw();
|
theTable2.draw();
|
||||||
}
|
}
|
||||||
@ -301,6 +322,7 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
table : "#tableOfPapelesImpresion",
|
table : "#tableOfPapelesImpresion",
|
||||||
|
idSrc: 'papel_impresion_id',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "active",
|
name: "active",
|
||||||
@ -310,21 +332,11 @@
|
|||||||
{ label: '', value: 1 }
|
{ label: '', value: 1 }
|
||||||
]
|
]
|
||||||
},{
|
},{
|
||||||
"name": "papel_generico"
|
"name": "papel_impresion_id",
|
||||||
|
"type": "hidden"
|
||||||
},{
|
},{
|
||||||
"name": "papel_impresion",
|
"name": "gramaje",
|
||||||
},{
|
"type": "hidden"
|
||||||
"name": "gramaje"
|
|
||||||
},{
|
|
||||||
"name": "bn"
|
|
||||||
},{
|
|
||||||
"name": "color"
|
|
||||||
},{
|
|
||||||
"name": "cubierta"
|
|
||||||
},{
|
|
||||||
"name": "sobrecubierta"
|
|
||||||
},{
|
|
||||||
"name": "rotativa"
|
|
||||||
},{
|
},{
|
||||||
"name": "maquina_id",
|
"name": "maquina_id",
|
||||||
"type": "hidden"
|
"type": "hidden"
|
||||||
@ -332,36 +344,31 @@
|
|||||||
]
|
]
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
/*editor2.on( 'preSubmit', function ( e, d, type ) {
|
|
||||||
if(type === 'edit' ) {
|
|
||||||
for (v in d.data){
|
|
||||||
d.data[v]['maquina_id'] = id;
|
|
||||||
//d.data[v]['papel_impresion_id'] = papel_impresion_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
|
|
||||||
|
|
||||||
editor2.on( 'postSubmit', function ( e, json, data, action ) {
|
editor2.on( 'postSubmit', function ( e, json, data, action ) {
|
||||||
|
|
||||||
yeniden(json.<?= csrf_token() ?>);
|
yeniden(json.<?= csrf_token() ?>);
|
||||||
|
if(json.error){
|
||||||
|
document.getElementById("check_" + json.data.papel_impresion_id).checked = false;
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: '<?= lang('Basic.global.sweet.error_tittle') ?>',
|
||||||
|
text: json.error,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var theTable = $('#tableOfMaquinastarifasimpresion').DataTable( {
|
var theTable = $('#tableOfMaquinastarifasimpresion').DataTable( {
|
||||||
serverSide: true,
|
serverSide: true,
|
||||||
processing: true,
|
processing: true,
|
||||||
autoWidth: true,
|
autoWidth: true,
|
||||||
responsive: true,
|
responsive: true,
|
||||||
lengthMenu: [ 5, 10, 25, 50],
|
|
||||||
order: [[ 1, "asc" ]],
|
order: [[ 1, "asc" ]],
|
||||||
pageLength: 10,
|
pageLength: 5,
|
||||||
lengthChange: true,
|
lengthChange: false,
|
||||||
searching: true,
|
searching: false,
|
||||||
paging: true,
|
paging: true,
|
||||||
info: false,
|
info: false,
|
||||||
dom: "Bltp",
|
dom: "Blt",
|
||||||
ajax : $.fn.dataTable.pipeline( {
|
ajax : $.fn.dataTable.pipeline( {
|
||||||
url: '<?= route_to('dataTableOfMaquinasTarifasImpresion') ?>',
|
url: '<?= route_to('dataTableOfMaquinasTarifasImpresion') ?>',
|
||||||
data: {
|
data: {
|
||||||
@ -441,6 +448,7 @@
|
|||||||
data: function (d) {
|
data: function (d) {
|
||||||
d.maquina_id = id;
|
d.maquina_id = id;
|
||||||
d.isRotativa = isRotativa.watch;
|
d.isRotativa = isRotativa.watch;
|
||||||
|
d.webguard_token = '<?= csrf_hash() ?>';
|
||||||
},
|
},
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||||
@ -450,7 +458,7 @@
|
|||||||
{ 'data': 'active',
|
{ 'data': 'active',
|
||||||
render: function (data, type, row) {
|
render: function (data, type, row) {
|
||||||
if (type === 'display') {
|
if (type === 'display') {
|
||||||
return '<input type="checkbox" class="editor-active">';
|
return '<input type="checkbox" class="editor-active" id="check_' + row.papel_impresion_id + '">';
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
@ -480,9 +488,9 @@
|
|||||||
],
|
],
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
// Cuando se clica en un checkbox hacer submit en el editor
|
// Cuando se clica en un checkbox hacer submit en el editor
|
||||||
theTable2.on( 'change', 'input.editor-active', function () {
|
theTable2.on( 'change', 'input.editor-active', function () {
|
||||||
console.log($(this).closest('tr')[0]));
|
|
||||||
editor2
|
editor2
|
||||||
.edit( $(this).closest('tr'), false )
|
.edit( $(this).closest('tr'), false )
|
||||||
.set( 'active', $(this).prop( 'checked' ) ? 1 : 0 )
|
.set( 'active', $(this).prop( 'checked' ) ? 1 : 0 )
|
||||||
|
|||||||
Reference in New Issue
Block a user