mantoPreventivo.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <?php
  2. $strModulo = 'refacciones';
  3. $arrCT = array();
  4. //$url = 'https://www.solerpalau.mx/plantasyp/datosPlanta.php';
  5. $url = 'https://www.solerpalau.mx/plantasyp/datosPlanta.php';
  6. $opciones = array('http' =>
  7. array(
  8. 'method' => 'GET',
  9. 'max_redirects' => '0',
  10. 'ignore_errors' => '1'
  11. )
  12. );
  13. $contexto = stream_context_create($opciones);
  14. $flujo = fopen($url, 'r', false, $contexto);
  15. $arrResultadoPeticion = json_decode(stream_get_contents($flujo), true);
  16. $arrCT[0]['idCT'] = 'todos';
  17. $arrCT[0]['name'] = 'Todos';
  18. $contadorCT = 1;
  19. foreach ($arrResultadoPeticion['datosRespuesta'] as $clave => $valor){
  20. $arrCT[$contadorCT]['idCT'] = $clave;
  21. $arrCT[$contadorCT]['name'] = $clave;
  22. $contadorCT++;
  23. }
  24. $jsonCentrosT = json_encode($arrCT);
  25. ?>
  26. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  27. <html xmlns="http://www.w3.org/1999/xhtml">
  28. <head>
  29. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  30. <meta http-equiv="imagetoolbar" content="no" />
  31. <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Poppins:400,500,700,300,600">
  32. <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans">
  33. <link media="screen" rel="stylesheet" type="text/css" href="css/principal.css" />
  34. <!--<link media="screen" rel="stylesheet" type="text/css" href="css/pagination.css" />--> <!--Paginador-->
  35. <link rel="shortcut icon" type="image/x-icon" href="css/layout/global/sp.ico" />
  36. <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/dojo/1.14.1/dijit/themes/claro/claro.css">
  37. <script src="//ajax.googleapis.com/ajax/libs/dojo/1.14.1/dojo/dojo.js" data-dojo-config="async: true, parseOnLoad:true"></script>
  38. <style type="text/css">
  39. /* Estilos para el DataGrid */
  40. @import "//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojox/grid/resources/claroGrid.css";
  41. @import "//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/resources/dojo.css";
  42. @import "//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/claro/claro.css";
  43. @import "//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/claro/document.css";
  44. @import "//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojox/grid/enhanced/resources/claro/EnhancedGrid.css";
  45. @import "//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojox/grid/enhanced/resources/EnhancedGrid_rtl.css";
  46. #Grid_Refacciones {
  47. height: 600px;
  48. }
  49. </style>
  50. <script type="application/javascript">
  51. // Cargamos los complementos de dojo
  52. require(["dojo/dom", "dojo/_base/fx", "dojo/_base/array", "dojo/query", "dojo/dom-construct", "dijit/registry", "dojo/dom-style", "dojo/ready", "dojo/on", "dojo/window",
  53. "dojo/store/Memory", "dijit/form/FilteringSelect", "dijit/form/Button", "dojo/dom-class", "dijit/Dialog",
  54. "dojo/_base/lang", "dojox/grid/DataGrid", "dojo/data/ItemFileWriteStore", "dojox/grid/enhanced/plugins/DnD", "dojox/grid/EnhancedGrid", "dojox/grid/enhanced/plugins/Selector", "dojox/grid/enhanced/plugins/IndirectSelection", "dojox/grid/enhanced/plugins/NestedSorting",
  55. "dijit/ProgressBar", "dijit/ConfirmDialog", "dojo/dom-style", "dijit/form/ComboButton", "dijit/Menu", "dijit/MenuItem", "dijit/MenuSeparator", "dijit/Tooltip", "dijit/form/Form", "dijit/form/TextBox",
  56. "dojox/grid/enhanced/plugins/Filter", "dijit/form/ValidationTextBox", "dijit/form/NumberSpinner", "dojo/request", "dojo/parser"],
  57. function(dom, fx, array, query, domConstruct, dijit, style, ready, on, win,
  58. Memory, FilteringSelect, Button, domClass, Dialog,
  59. lang, DataGrid, ItemFileWriteStore, DnDConfig, EnhancedGrid, Selector, indirectSelection, nestedSorting,
  60. ProgressBar, ConfirmDialog, style, ComboButton, Menu, MenuItem, MenuSeparator, Tooltip, Form, TextBox, filter, ValidationTextBox, NumberSpinner, request) {
  61. const idModulo = "<?php echo($strModulo);?>";
  62. const arrCentrosT = <?php echo($jsonCentrosT); ?>;
  63. // Para Mostrar de Mensajes de "error o éxito"
  64. var dgEjecuta = new Dialog({title: 'Procesando...', style: 'width:300px'});
  65. var pbMarcar = new ProgressBar({value: Number.POSITIVE_INFINITY, layoutAlign: 'left'});
  66. dgEjecuta.setContent(pbMarcar);
  67. dgResultadoError = new ConfirmDialog({ title:"<b>Error</b>", style: "min-width:300px; heigth; auto" });
  68. style.set(dgResultadoError.cancelButton.domNode, 'display', 'none');
  69. dgResultadoExito = new ConfirmDialog({ title:"<b>Éxito</b>", style: "min-width:300px; heigth; auto" });
  70. style.set(dgResultadoExito.cancelButton.domNode, 'display', 'none');
  71. /****************************************************************** Inputs ******************************************************************/
  72. new FilteringSelect({
  73. id: "select_CentroTrabajo",
  74. store: new Memory({ idProperty: "idCT", data: arrCentrosT }),
  75. autoComplete: true,
  76. maxHeight: 300,
  77. style: "width: 100%;",
  78. placeHolder: "Seleccione una opción",
  79. onChange: function(idCt){
  80. }
  81. }, "select_CentroTrabajo");
  82. /****************************************************************** Botones ******************************************************************/
  83. new Button({
  84. id: "btn_Buscar",
  85. label: "Buscar",
  86. iconClass: "dijitIconSearch",
  87. showLabel: false,
  88. onClick: function(){
  89. let centroT = dijit.byId('select_CentroTrabajo').value;
  90. if(centroT != ""){
  91. cargarGrid("id_Grid_Refacciones", centroT, "");
  92. }
  93. }
  94. }, "btn_Buscar").startup();
  95. /****************************************************************** Acciones ******************************************************************/
  96. cargarGrid = function (idGrid, ct, maq){
  97. dgEjecuta.set("title", "Consultando...");
  98. dgEjecuta.show();
  99. var accion = "";
  100. var resdatosRecibidos = "datosRespuesta";
  101. var posicionDom = "";
  102. if(idGrid == "id_Grid_Refacciones"){
  103. accion = "buscarMantoPreventivo";
  104. posicionDom = "Grid_Refacciones";
  105. }
  106. request.post("datosPlanta.php", {
  107. data: {
  108. accion: accion,
  109. idModulo: idModulo,
  110. ct: ct,
  111. maq: maq
  112. }
  113. }).then(
  114. function (response) {
  115. var objResponse = JSON.parse(response);
  116. if (objResponse['estatus'] == "ERROR") {
  117. dgEjecuta.hide();
  118. dgResultadoError.setContent(objResponse['errorDescripcion']);
  119. dgResultadoError.show();
  120. } else {
  121. let datosRecibidos = objResponse[resdatosRecibidos];
  122. // Configuramos el data store
  123. var data = {
  124. identifier: "id",
  125. items: []
  126. };
  127. // Creamos la lista de objetos
  128. var data_list = JSON.parse(datosRecibidos);
  129. for(var i = 0, l = data_list.length; i < data_list.length; i++){
  130. data.items.push(lang.mixin({ id: i+1 }, data_list[i%l]));
  131. }
  132. var store = new ItemFileWriteStore({data: data});
  133. // Destruimos el dataGrid si ya existe
  134. if (dijit.byId(idGrid)){
  135. dijit.byId(idGrid).destroy();
  136. }
  137. if(idGrid == "id_Grid_Refacciones"){
  138. var estructuralayout = [[
  139. {'name': 'No.', 'field': 'id', 'width': '30px', 'datatype':'number'},
  140. {'name': 'Centro de Trabajo', 'field': 'ct', 'width': '120px', 'datatype':'string'},
  141. {'name': 'Parte', 'field': 'parte', 'width': '250px', 'datatype':'string'},
  142. {'name': 'Actividad', 'field': 'actividad', 'width': '270px', 'datatype':'string'},
  143. {'name': 'Duración', 'field': 'duracion', 'width': '150px', 'datatype':'string'},
  144. {'name': 'Prioridad', 'field': 'prioridad', 'width': '150px', 'datatype':'string'},
  145. {'name': 'Tipo', 'field': 'tipo', 'width': '150px', 'datatype':'string'},
  146. {'name': 'Clasificación 1', 'field': 'clasificacion', 'width': '260px', 'datatype':'string'}
  147. ]];
  148. }
  149. var grid = new EnhancedGrid({
  150. id: idGrid,
  151. store: store,
  152. structure: estructuralayout,
  153. autoHeight: false,
  154. autoWidth: false,
  155. rowSelector: '20px',
  156. noDataMessage: 'No se encontraron datos',
  157. canSort: function () {
  158. return true;
  159. }, // Filtra
  160. plugins: {
  161. nestedSorting: true,
  162. filter: {
  163. // Show the closeFilterbarButton at the filter bar
  164. closeFilterbarButton: false,
  165. // Set the maximum rule count to 5
  166. ruleCount: 5,
  167. // Set the name of the items
  168. itemsName: "registros"
  169. }
  170. }
  171. });
  172. // Cargamos el dataGrid en el div
  173. grid.placeAt(posicionDom);
  174. // Inicializamos el dataGrid
  175. grid.startup();
  176. dgEjecuta.hide();
  177. }
  178. }
  179. );
  180. };
  181. ready(function() {
  182. // Actualizar el tamaño del TabContainer en función del tamaño de página
  183. var ventana = win.getBox();
  184. var strVentana = (ventana.h-130)+"px";
  185. style.set(dijit.byId("djTab").id, { height:strVentana });
  186. dijit.byId("djTab").resize();
  187. // Actualizar el tamaño del TabContainer en función del tamaño de página
  188. on(window, "resize", function() {
  189. var ventana = win.getBox();
  190. var strVentana = (ventana.h-130)+"px";
  191. style.set(dijit.byId("djTab").id, { height:strVentana });
  192. dijit.byId("djTab").resize();
  193. });
  194. // Eliminar la cortina de entrada
  195. fx.fadeOut({node: dom.byId("loadingOverlay"), duration: 1}).play();
  196. setTimeout(function () {
  197. domConstruct.destroy("loadingOverlay");
  198. }, 1);
  199. cargarGrid("id_Grid_Refacciones", "todos", "");
  200. });
  201. });
  202. </script>
  203. </head>
  204. <body class="claro">
  205. <div id="loadingOverlay" class="loadingOverlay pageOverlay">
  206. <div class="loadingMessage">Espere...</div>
  207. </div>
  208. <div id="wrapper_container_module">
  209. <div id="wrapper_table" style="position:relative;">
  210. <div data-dojo-type="dijit/form/Form" id="frm" data-dojo-id="frm" encType="multipart/form-data"
  211. action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post" style="position:relative;">
  212. <script type="dojo/on" data-dojo-event="submit">return true;</script>
  213. <div id="wrapper_table_head">Mantenimiento Preventivo</div>
  214. <div id="wrapper_table_body_mod_app">
  215. <table width="100%" height="auto" border="0" style="border-spacing: 5px;">
  216. <tr>
  217. <td width="10%" colspan="2" class="etiquetaFormulario">
  218. <label class="noTopPadding">Centro de Trabajo:</label>
  219. </td>
  220. <td width="20%" colspan="4">
  221. <input id="select_CentroTrabajo"/>
  222. </td>
  223. <td width="70%" colspan="14">
  224. <button id="btn_Buscar" type="button"></button>
  225. </td>
  226. </tr>
  227. </table>
  228. <div id="djTab" data-dojo-type="dijit/layout/LayoutContainer" style="overflow-y: auto;">
  229. <div style="margin-top: 15px">
  230. <div id="Grid_Refacciones"></div>
  231. </div>
  232. </div>
  233. </div>
  234. </div>
  235. </div>
  236. </div>
  237. </body>