PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/opensourcepos/application/views/products/product_stock_details.php

https://bitbucket.org/jit_bec/shopifine
PHP | 371 lines | 287 code | 75 blank | 9 comment | 17 complexity | 44974b8a2b27194d227b8d59fc5f826b 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" rev="stylesheet" href="<?php echo base_url();?>css/shopifine.css" />
  6. <!-- <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/ui-lightness/jquery-ui.css">-->
  7. <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url(); ?>css/ui.jqgrid.css" />
  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. html {height:100%;}
  12. body { font-size: 62.5%; height:100%;}
  13. label, input { display:inline; }
  14. input.text { margin-bottom:12px; width:95%; padding: .4em; }
  15. fieldset { padding:0; border:0; margin-top:25px; }
  16. h1 { font-size: 1.2em; margin: 1em 0; padding-left:2em;}
  17. div#users-contain { width: 350px; margin: 20px 0; }
  18. div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
  19. div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
  20. .ui-dialog .ui-state-error { padding: .3em; }
  21. .shopifine-ui-dialog
  22. {overflow: hidden;
  23. padding: 4em;
  24. left: 65px;
  25. position: relative;
  26. width: 680px;}
  27. .validateTips { border: 1px solid transparent; padding: 0.3em; }
  28. .reqBarcodeAC { position:absolute;left:230px;}
  29. * { font-family: Verdana; font-size: 98%; }
  30. em {color:red;}
  31. .shopifine-ui-button{width:150px;float:right}
  32. .shopifine-ui-widget-content{background: url("images/ui-bg_inset-hard_100_fcfdfd_1x100.png") repeat-x scroll 50% bottom #FCFDFD;
  33. border-bottom: 1px solid #A6C9E2;
  34. color: #222222;
  35. }
  36. .form-container {
  37. border: 1px solid #A6C9E2;
  38. color: #222222;
  39. }
  40. .shopifine-ui-dialog-buttonset {
  41. margin: 1em;
  42. padding-bottom: 3em;
  43. }
  44. label { width: 6em; float: left; }
  45. label.error { float: right; color: red; padding-left: .5em; vertical-align: top; position: relative;width:100px;}
  46. p , .column{ float:left; padding:1em 1em 3em;width:310px}
  47. .submit { margin-left: 12em; }
  48. em { font-weight: bold; padding-right: 1em; vertical-align: top; }
  49. .ui-combobox {
  50. position: relative;
  51. display: inline-block;
  52. }
  53. .ui-combobox-toggle {
  54. position: absolute;
  55. top: 0;
  56. bottom: 0;
  57. margin-left: -1px;
  58. padding: 0;
  59. }
  60. .ui-combobox-input {
  61. margin: 0;
  62. padding: 0.3em;
  63. }
  64. .table-grid {
  65. height: 60%;
  66. clear:both;
  67. }
  68. #status-message{height: 35px;
  69. margin: 20px;
  70. padding: 0 0.7em;
  71. position: relative;
  72. width: auto;}
  73. </style>-->
  74. <script type="text/javascript">
  75. //<![CDATA[
  76. //validators
  77. $(function() {
  78. $.validator.addMethod("greaterThanZero", function(value, element) {
  79. return this.optional(element) || (parseInt(value) > 0);
  80. }, "* Number of Items must be greater than zero");
  81. $.validator.addMethod("barcodeRequired", function(value, element) {
  82. var value = $("#stockbarcode-hidden").val();
  83. if (value == null || value == ""){
  84. return false;
  85. }
  86. return true;
  87. }, "Please scan an item");
  88. $( "#dialog:ui-dialog" ).dialog( "destroy" );
  89. $( "#productForm" ).validate({
  90. errorPlacement: function(error, element) {
  91. error.appendTo( element.parent());
  92. },
  93. rules: {
  94. noOfItems: {
  95. greaterThanZero: true
  96. },
  97. stockbarcode : {
  98. barcodeRequired:true
  99. }
  100. }
  101. }
  102. );
  103. function negativeValCheck(value,colname) {
  104. if (value < 0)
  105. return [false,"Please enter a positive value"];
  106. else
  107. return [true,""];
  108. }
  109. //jQGrid
  110. var myGrid = $("#products"),lastsel2;
  111. var editparameters = {
  112. "keys" : true,
  113. "oneditfunc" : null,
  114. "successfunc" : function(){
  115. var successStatus = " The product update is successful ";
  116. $("#status-message").addClass("ui-state-highlight");
  117. $("#status-message > p > span").addClass("ui-icon");
  118. $("#status-message > p > span").addClass("ui-icon-info");
  119. $("#status-message > p").append(successStatus);
  120. myGrid.trigger("reloadGrid");
  121. return true;
  122. },
  123. "aftersavefunc" : null,
  124. "errorfunc": function(response)
  125. {
  126. var errorStatus = "Update error!! Please contact Administrator";
  127. $("#status-message").addClass("ui-state-error");
  128. $("#status-message > p > span").addClass("ui-icon");
  129. $("#status-message > p > span").addClass("ui-icon-alert");
  130. $("#status-message > p").append(errorStatus);
  131. },
  132. "afterrestorefunc" : null,
  133. "restoreAfterError" : true,
  134. "mtype" : "POST"
  135. };
  136. myGrid.jqGrid({
  137. url:'index.php/products/populateProductStocksInGrid',
  138. datatype: 'json',
  139. mtype: 'GET',
  140. colNames:['Product Id','Barcode','Product Name','Stock','Quick Stock Add','Is Active'],
  141. colModel :[
  142. // {name:'id', index:'id', width:55},
  143. {name:'product_id', index:'product_id',hidden:true},
  144. {name:'barcode', index:'barcode', width:80, align:'right'},
  145. {name:'system_name', index:'system_name', width:140, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
  146. {name:'stock',search:false, index:'stock', width:80, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
  147. {name:'stock_add', search:false,index:'stock_add', width:80, align:'right',editrules:{custom:true,custom_func:negativeValCheck},editable:true,editoptions:{size:"20",maxlength:"30"}},
  148. {name:'isactive',search:false, index:'isactive', width:80, align:'right',editable:false,edittype:"select", formatter:'select', editoptions:{value:"1:Yes;0:No"}},
  149. ],
  150. pager: '#pager',
  151. rowNum:10,
  152. rowList:[5,10,20],
  153. sortname: 'id',
  154. sortorder: 'desc',
  155. viewrecords: true,
  156. gridview: true,
  157. ignoreCase:true,
  158. rownumbers:true,
  159. height:'50%',
  160. width:680,
  161. caption: 'Product Stocks',
  162. jsonReader : {
  163. root:"productdata",
  164. page: "page",
  165. total: "total",
  166. records: "records",
  167. cell: "dprow",
  168. id: "id"
  169. },
  170. onSelectRow: function(id){if(id && id!==lastsel2){
  171. myGrid.restoreRow(lastsel2);
  172. myGrid.editRow(id,editparameters);
  173. lastsel2=id;
  174. }
  175. }
  176. ,editurl:'index.php/products/updateStocks'
  177. });
  178. myGrid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: false, defaultSearch : "cn"});
  179. //end grid
  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 && hiddenVal!= ""){
  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. $("#scanBtn").click(function() {
  202. var bValid = $("#productForm").valid();
  203. var stock = $("#noOfItems").val();
  204. var sku = $("#stockbarcode-hidden").val();
  205. if (bValid ){
  206. $.ajax({
  207. url:"index.php/products/updateStocksByBarcode",
  208. data: {
  209. stock_add: $("#noOfItems").val(),
  210. barcode: $("#stockbarcode-hidden").val() },
  211. type:"POST",
  212. success:function(response)
  213. {
  214. var successStatus = stock + " items has been added in inventory for " + sku;
  215. $("#status-message").addClass("ui-state-highlight");
  216. $("#status-message > p > span").addClass("ui-icon");
  217. $("#status-message > p > span").addClass("ui-icon-info");
  218. $("#status-message > p").append(successStatus);
  219. myGrid.trigger("reloadGrid");
  220. },
  221. error:function(response)
  222. {
  223. var errorStatus = stock + " items could not be added in inventory for " + sku + " due to error in backend";
  224. $("#status-message").addClass("ui-state-error");
  225. $("#status-message > p > span").addClass("ui-icon");
  226. $("#status-message > p > span").addClass("ui-icon-alert");
  227. $("#status-message > p").append(errorStatus);
  228. }
  229. });
  230. }
  231. })
  232. });
  233. //]]>
  234. </script>
  235. </head>
  236. <body>
  237. <?php $this->load->view("common/menubar"); ?>
  238. <div style="display: block;height: auto;" class="shopifine-ui-dialog ui-widget ui-widget-content ui-corner-all" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog-form">
  239. <div class="form-container">
  240. <div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">
  241. <span class="ui-dialog-title" id="ui-dialog-title-dialog-form">&nbsp;</span>
  242. <a href="#" class="ui-dialog-titlebar-close ui-corner-all" role="button">
  243. </a>
  244. </div>
  245. <div class="ui-dialog-content" style="width: auto; min-height: 65.1333px; height: auto;" scrolltop="0" scrollleft="0">
  246. <h1 id="formHeader">Scan Items</h1>
  247. <form id="productForm">
  248. <fieldset>
  249. <div class="row">
  250. <div class="column">
  251. <div class="field">
  252. <label for="stockbarcode">Scan/Input Barcode:</label><em>*</em>
  253. <input type="text" name="stockbarcode" id="stockbarcode" class="ui-autocomplete-input" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
  254. </div>
  255. <input type="hidden" name="stockbarcode-hidden" id="stockbarcode-hidden">
  256. </div>
  257. <div class="column">
  258. <div class="field">
  259. <label for="noOfItems">Items Scanned:</label><em>*</em>
  260. <input type="text" class="required" value="0" name="noOfItems" id="noOfItems">
  261. </div>
  262. </div>
  263. </div>
  264. </fieldset>
  265. </form>
  266. </div>
  267. <div class="ui-dialog-buttonpane shopifine-ui-widget-content ui-helper-clearfix">
  268. <div class="shopifine-ui-dialog-buttonset">
  269. <button id="scanBtn" type="button" class="shopifine-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false">
  270. <span class="ui-button-text">Scan and update stock</span>
  271. <!-- </button><button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Cancel</span></button></div></div></div>-->
  272. </div>
  273. </div>
  274. </div>
  275. <?php $this->load->view("common/message"); ?>
  276. <div class="table-grid">
  277. <h1 id="table header">Product Stock Table</h1>
  278. <table id="products"><tr><td/></tr></table>
  279. <div id="pager"></div>
  280. </div>
  281. </div>
  282. <?php $this->load->view("partial/footer"); ?>
  283. </body>
  284. </html>
  285. <script type="text/javascript">
  286. function addItem (e){
  287. console.log(e.which);
  288. if (e.which == 13){
  289. var value = parseInt($("#noOfItems").val());
  290. value = value + 1;
  291. $("#noOfItems").val(value);
  292. $("#stockbarcode").val("");
  293. }
  294. }
  295. $("#stockbarcode").on("keypress",addItem);
  296. </script>