PageRenderTime 44ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/magehelp/application/views/products/product_stock_details_1.php

https://bitbucket.org/jit_bec/shopifine
PHP | 319 lines | 236 code | 73 blank | 10 comment | 14 complexity | c9ce54183fc2f39897c0480b10fa71b7 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <html><head>
  2. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  3. <title> Add product details and generate barcode</title>
  4. <?php $this->load->view("common/header"); ?>
  5. <!-- <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/ui-lightness/jquery-ui.css">-->
  6. <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url();?>css/ui.jqgrid.css" />
  7. <!-- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>-->
  8. <script src="<?php echo base_url();?>js/i18n/grid.locale-en.js" type="text/javascript"></script>
  9. <script src="<?php echo base_url();?>js/jquery.jqGrid.min.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
  10. <style type="text/css">
  11. body { font-size: 62.5%; }
  12. label, input { display:inline; }
  13. input.text { margin-bottom:12px; width:95%; padding: .4em; }
  14. fieldset { padding:0; border:0; margin-top:25px; }
  15. h1 { font-size: 1.2em; margin: .6em 0; }
  16. div#users-contain { width: 350px; margin: 20px 0; }
  17. div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
  18. div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
  19. .ui-dialog .ui-state-error { padding: .3em; }
  20. .validateTips { border: 1px solid transparent; padding: 0.3em; }
  21. .reqBarcodeAC { position:absolute;left:230px;}
  22. * { font-family: Verdana; font-size: 98%; }
  23. em {color:red;}
  24. label { width: 10em; float: left; }
  25. label.error { float: right; color: red; padding-left: .5em; vertical-align: top; position: relative;width:130px;}
  26. p , .column{ clear: both; padding: 1em; }
  27. .submit { margin-left: 12em; }
  28. em { font-weight: bold; padding-right: 1em; vertical-align: top; }
  29. .ui-combobox {
  30. position: relative;
  31. display: inline-block;
  32. }
  33. .ui-combobox-toggle {
  34. position: absolute;
  35. top: 0;
  36. bottom: 0;
  37. margin-left: -1px;
  38. padding: 0;
  39. }
  40. .ui-combobox-input {
  41. margin: 0;
  42. padding: 0.3em;
  43. }
  44. </style>
  45. <script type="text/javascript">
  46. //<![CDATA[
  47. $(function() {
  48. $.validator.addMethod("greaterThanZero", function(value, element) {
  49. return this.optional(element) || (parseInt(value) > 0);
  50. }, "* Number of Items must be greater than zero");
  51. $.validator.addMethod("barcodeRequired", function(value, element) {
  52. var value = $("#stockbarcode-hidden").val();
  53. if (value == null || value == ""){
  54. return false;
  55. }
  56. return true;
  57. }, "Please scan an item");
  58. $( "#dialog:ui-dialog" ).dialog( "destroy" );
  59. $( "#productForm" ).validate({
  60. errorPlacement: function(error, element) {
  61. error.appendTo( element.parent());
  62. },
  63. rules: {
  64. noOfItems: {
  65. greaterThanZero: true
  66. },
  67. stockbarcode : {
  68. barcodeRequired:true
  69. }
  70. }
  71. }
  72. );
  73. $( "#dialog-form" ).dialog({
  74. autoOpen: false,
  75. height: 'auto',
  76. width: 450,
  77. position:[400,25],
  78. modal: true,
  79. buttons: {
  80. "Scan and update stock": function() {
  81. var bValid = $("#productForm").valid();
  82. if (bValid ){
  83. $.ajax({
  84. url:"index.php/products/updateStocksByBarcode",
  85. data: {
  86. stock_add: $("#noOfItems").val(),
  87. barcode: $("#stockbarcode-hidden").val() },
  88. type:"POST",
  89. success:function(response)
  90. {
  91. myGrid.trigger("reloadGrid");
  92. }
  93. });
  94. }
  95. },
  96. Cancel: function() {
  97. $( this ).dialog( "close" );
  98. }
  99. },
  100. close: function() {
  101. //allFields.val( "" ).removeClass( "ui-state-error" );
  102. $("#productForm").data('validator').resetForm();
  103. $('#productForm')[0].reset();
  104. }
  105. });
  106. $( "#create-product" )
  107. .button()
  108. .click(function() {
  109. //if (!$("#newModelCtnr").parent().is(':hidden')){
  110. $("#newModelCtnr").parent().css("display","none");
  111. //}
  112. //if (!$("#modelCtnr").parent().is(':hidden')){
  113. $("#modelCtnr").parent().css("display","none");
  114. //}
  115. $( "#dialog-form" ).dialog( "open" );
  116. });
  117. function negativeValCheck(value,colname) {
  118. if (value < 0)
  119. return [false,"Please enter a positive value"];
  120. else
  121. return [true,""];
  122. }
  123. //jQGrid
  124. var myGrid = $("#products"),lastsel2;
  125. var editparameters = {
  126. "keys" : true,
  127. "oneditfunc" : null,
  128. "successfunc" : function(){
  129. myGrid.trigger("reloadGrid");
  130. return true;
  131. },
  132. "aftersavefunc" : null,
  133. "errorfunc": null,
  134. "afterrestorefunc" : null,
  135. "restoreAfterError" : true,
  136. "mtype" : "POST"
  137. };
  138. myGrid.jqGrid({
  139. url:'index.php/products/populateProductStocksInGrid',
  140. datatype: 'json',
  141. mtype: 'GET',
  142. colNames:['Product Id','Barcode','Product Name','Stock','Quick Stock Add','Is Active'],
  143. colModel :[
  144. // {name:'id', index:'id', width:55},
  145. {name:'product_id', index:'product_id',hidden:true},
  146. {name:'barcode', index:'barcode', width:80, align:'right'},
  147. {name:'system_name', index:'system_name', width:140, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
  148. {name:'stock', index:'stock', width:80, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
  149. {name:'stock_add', index:'stock_add', width:80, align:'right',editrules:{custom:true,custom_func:negativeValCheck},editable:true,editoptions:{size:"20",maxlength:"30"}},
  150. {name:'isactive', index:'isactive', width:80, align:'right',editable:false,edittype:"select", formatter:'select', editoptions:{value:"1:Yes;0:No"}},
  151. ],
  152. pager: '#pager',
  153. rowNum:10,
  154. rowList:[5,10,20],
  155. sortname: 'id',
  156. sortorder: 'desc',
  157. viewrecords: true,
  158. gridview: true,
  159. ignoreCase:true,
  160. rownumbers:true,
  161. height:'50%',
  162. caption: 'Product Stocks',
  163. jsonReader : {
  164. root:"productdata",
  165. page: "page",
  166. total: "total",
  167. records: "records",
  168. cell: "dprow",
  169. id: "id"
  170. },
  171. onSelectRow: function(id){if(id && id!==lastsel2){
  172. myGrid.restoreRow(lastsel2);
  173. myGrid.editRow(id,editparameters);
  174. lastsel2=id;
  175. }
  176. }
  177. ,editurl:'index.php/products/updateStocks'
  178. });
  179. //myGrid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: false, defaultSearch : "cn"});
  180. var availableBarcodes = <?php echo $barcodes ?>;
  181. $("#stockbarcode").autocomplete({
  182. source: availableBarcodes,
  183. focus: function( event, ui ) {
  184. $( "#stockbarcode" ).val( ui.item.label );
  185. return false;
  186. },
  187. select: function( event, ui ) {
  188. $( "#stockbarcode" ).val( ui.item.label );
  189. var hiddenVal = $( "#stockbarcode-hidden" ).val();
  190. if (hiddenVal!= null){
  191. if (hiddenVal != ui.item.label){
  192. console.log ("hiddenval = " + hiddenVal);
  193. console.log ("ui.item.label = " + ui.item.label);
  194. $("#noOfItems").val(0);
  195. }
  196. }
  197. $( "#stockbarcode-hidden" ).val( ui.item.value );
  198. return false;
  199. }
  200. });
  201. });
  202. //]]>
  203. </script>
  204. </head>
  205. <body>
  206. <?php $this->load->view("common/menubar"); ?>
  207. <div id ="dialog-form">
  208. <h1 id="formHeader">Add New Product Entity</h1>
  209. <form id="productForm">
  210. <fieldset>
  211. <div class="row">
  212. <div class="column">
  213. <div class="ui-widget field">
  214. <label for="stockbarcode">Scan/Input Barcode:</label><em>*</em>
  215. <input id="stockbarcode" name ="stockbarcode" type="text"/>
  216. </div>
  217. <input id="stockbarcode-hidden" name ="stockbarcode-hidden" type="hidden"/>
  218. </div>
  219. <div class="column">
  220. <div class=" ui-widget field">
  221. <label for="noOfItems">Items Scanned:</label><em>*</em>
  222. <input id="noOfItems" name ="noOfItems" type="text" value="0" class="required"/>
  223. </div>
  224. </div>
  225. </div>
  226. </fieldset>
  227. </form>
  228. </div>
  229. <table id="products"><tr><td/></tr></table>
  230. <div id="pager"></div>
  231. <!-- </div>-->
  232. <button id="create-product">Update Stocks</button>
  233. </body>
  234. </html>
  235. <script type="text/javascript">
  236. function addItem (e){
  237. console.log(e.which);
  238. if (e.which == 13){
  239. var value = parseInt($("#noOfItems").val());
  240. value = value + 1;
  241. $("#noOfItems").val(value);
  242. $("#stockbarcode").val("");
  243. }
  244. }
  245. $("#stockbarcode").on("keypress",addItem)
  246. </script>