Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.92 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <meta charset="UTF-8">
  4. <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  5. <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
  6. <script src="js/grid.js" type="text/javascript"></script>
  7. <link href="css/grid.css" rel="stylesheet" type="text/css">
  8. <script src="js/dialog.js" type="text/javascript"></script>
  9. <link href="css/dialog.css" rel="stylesheet" type="text/css">
  10. <script src="js/draggable.js" type="text/javascript"></script>
  11. <script type="text/javascript" src="js/valida.js"></script>
  12. <link href="css/jquery-ui.css" rel="stylesheet" type="text/css"/>
  13. <link rel="stylesheet" type="text/css" href="css/estilo.css" media="screen" />
  14.  
  15. <table border="0" class="tablePopup">
  16. <tr>
  17. <td width="80">Cantidad</td>
  18. <td width="160">Unidad de Medida</td>
  19. <td>Condición</td>
  20. <td>Activo Fijo</td>
  21. </tr>
  22. <tr>
  23.  
  24. <td>
  25. <input type="text" id ="Cantidad" name="Cantidad" class="solo-numero" maxlength="2" required>
  26. </td>
  27. <td>
  28. <select id ="unidadMedida" required><option value="" >Seleccione...</option>
  29. <option value="litros">Litros</option>
  30. <option value="kilos">Kilos</option>
  31. <option value="bulto">Bulto</option>
  32. <option value="lote">Lote</option>
  33. <option value="equipo">Equipo</option>
  34. <option value="piezas">Piezas</option>
  35. <option value="unidad">Unidad</option>
  36. </td>
  37.  
  38. <td>
  39. <select id ="condicion" required><option value="">Seleccione...</option>
  40. <option value="Bueno">Bueno</option>
  41. <option value="Malo">Malo</option>
  42. <option value="Regular">Regular</option>
  43. </td>
  44. <td>
  45. <input type="radio" name="activoFijo" value="Si" >Si
  46. <input type="radio" name="activoFijo" value="No" >No
  47. </td>
  48. </tr>
  49. <tr>
  50. <td>Descripción</td>
  51. </tr>
  52. <tr>
  53. <td scope="colgroup" colspan="4"><textarea cols="65" maxlength="1500" id="descripcion">ewdd</textarea></td>
  54. </tr>
  55. </table>
  56. <table border="0" class="tablaButton">
  57. <tr>
  58. <td></td>
  59. <td></td>
  60. <td><button type="button" id="btnSave" class="btn btn-default">Save</button></td>
  61. <td width="80"><button type="button" id="btnCancel" class="btn btn-default">Cancel</button></td>
  62. </tr>
  63. </table>
  64. </form>
  65. </div>
  66.  
  67. </td>
  68. </tr>
  69.  
  70. $(document).ready(function () {
  71. var data, grid, dialog;
  72. data = [];
  73.  
  74. dialog = $('#dialog').dialog({
  75. title: 'Agregar/Editar',
  76. autoOpen: false,
  77. resizable: false,
  78. height:250,
  79. width:600,
  80. modal: true
  81. });
  82. function Edit(e) {
  83. $('#Item').val(e.data.id);
  84. $('#Cantidad').val(e.data.record.Cantidad);
  85. $('#unidadMedida').val(e.data.record.unidadMedida);
  86. $('#descripcion').val(e.data.record.descripcion);
  87. $('#condicion').val(e.data.record.condicion);
  88. $('#activoFijo').val(e.data.record.activoFijo);
  89. $('#dialog').dialog('open');
  90. $('#button').show();
  91. }
  92. function Delete(e) {
  93. if (confirm('¿esta seguro que desea eliminar este registro?')) {
  94. grid.removeRow(e.data.id);
  95. if(grid.count()!=0){
  96. $('#button').show();
  97. }else{
  98. $('#button').hide();
  99. }
  100. }
  101. }
  102. function Save() {
  103.  
  104. if ($('#Item').val()) {
  105. var id = parseInt($('#Item').val());
  106. grid.updateRow(id, { 'Item': id, 'Cantidad': $('#Cantidad').val(), 'unidadMedida': $('#unidadMedida').val(), 'descripcion' : $('#descripcion').val(), 'condicion' : $('#condicion').val(), 'activoFijo' : $('#activoFijo').val() });
  107. } else {
  108. grid.addRow({ 'Item': grid.count() + 1, 'Cantidad': $('#Cantidad').val(), 'unidadMedida': $('#unidadMedida').val(), 'descripcion' : $('#descripcion').val(), 'condicion' : $('#condicion').val(), 'activoFijo' : $('#activoFijo').val() });
  109. console.log($('#Cantidad').val());
  110. console.log($('#activoFijo').val());
  111. }
  112. dialog.close();
  113. $('#button').show();
  114. }
  115.  
  116. grid = $('#grid').grid({
  117. dataSource: data,
  118. columns: [
  119. { field: 'Item', width: 32 },
  120. { field: 'Cantidad' },
  121. { field: 'unidadMedida', title: 'Unidad de Medida' },
  122. { field: 'descripcion', title: 'Descripcion' },
  123. { field: 'condicion', title: 'Condicion'},
  124. { field: 'activoFijo', title: 'Activo Fijo (si-no)'},
  125. { width: 50, tmpl: '<a href="#"><img src="img/editar.png"></a>', align: 'center', events: { 'click': Edit } },
  126. { width: 50, tmpl: '<a href="#"><img src="img/eliminar.png"></a>', align: 'center', events: { 'click': Delete } }
  127. ]
  128.  
  129. });
  130. $('#btnAdd').on('click', function () {
  131. $('#Item').val('');
  132. $('#Cantidad').val('');
  133. $('#unidadMedida').val('');
  134. $('#descripcion').val('');
  135. $('#condicion').val('');
  136. $('#activoFijo').val('');
  137. $('#dialog').dialog('open');
  138. });
  139.  
  140.  
  141. $('#btnSave').on('click', function(){
  142. if(comprobarCamposRequired()){
  143. Save();
  144. }else{
  145. alert("llene todos los campos");
  146. }
  147.  
  148. } );
  149.  
  150. dialog.dialog("close");
  151. });
  152.  
  153. $('.solo-numero').keyup(function (){
  154. this.value = (this.value + '').replace(/[^0-9]/g, '');
  155. });
  156.  
  157. $(function($){
  158. $.datepicker.regional['es'] = {
  159. closeText:'Cerrar',
  160. currentText:'Hoy',
  161. monthNames:['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
  162. monthNamesShort:['Ene','Feb','Mar','Abr', 'May','Jun','Jul','Ago','Sep', 'Oct','Nov','Dic'],
  163. dayNames:['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
  164. dayNamesShort:['Dom','Lun','Mar','Mié','Juv','Vie','Sáb'],
  165. dayNamesMin:['Do','Lu','Ma','Mi','Ju','Vi','Sá'],
  166. weekHeader:'Sm',
  167. dateFormat:'dd/mm/yy',
  168. firstDay:1,
  169. isRTL:false,
  170. showMonthAfterYear:false,
  171. yearSuffix:''
  172. };
  173. $.datepicker.setDefaults($.datepicker.regional['es']);
  174.  
  175. });
  176.  
  177. $("#fchFecha").datepicker({
  178. changeMonth: true,
  179. changeYear: true,
  180. showOn: "button",
  181. buttonImage: "img/calendar.gif",
  182. buttonImageOnly: true,
  183. showAnim: "drop",
  184. buttonText: "Selecione una Fecha"
  185. });
  186. $('#button').hide();
  187.  
  188. function comprobarCamposRequired(){
  189. var correcto=true;
  190. var campos=$('input[type="text"]:required');
  191. var select=$('select:required');
  192.  
  193. $(campos).each(function() {
  194. if($(this).val()==''){
  195. correcto=false;
  196. $(this).addClass('error');
  197. }
  198. });
  199.  
  200. $(select).each(function() {
  201. if($(this).val()==''){
  202. correcto=false;
  203. $(this).addClass('error');
  204. }
  205. });
  206. return correcto;
  207.  
  208. }
  209.  
  210. $('input[type="text"]:required').click(function(){
  211. $(this).removeClass('error');
  212. });
  213.  
  214.  
  215.  
  216. var hoy = new Date();
  217. dia = hoy.getDate();
  218. mes = ((hoy.getMonth() + 1) < 10 ? '0' : '') + (hoy.getMonth() + 1);
  219. anio = hoy.getFullYear();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement