PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/magehelp/application/views/impex/update_stock.php

https://bitbucket.org/jit_bec/shopifine
PHP | 310 lines | 266 code | 41 blank | 3 comment | 17 complexity | 4e1a6988651c87a4bdee62dfc0fcd03b MD5 | raw file
Possible License(s): LGPL-3.0
  1. <!--
  2. To change this template, choose Tools | Templates
  3. and open the template in the editor.
  4. -->
  5. <!DOCTYPE html>
  6. <html>
  7. <html>
  8. <head>
  9. <?php $this->load->view("common/header"); ?>
  10. <!--<link rel="stylesheet" rev="stylesheet" href="<?php echo base_url(); ?>js/jqplot/jquery.jqplot.css" />-->
  11. <!-- <script type="text/javascript" src="<?php echo base_url(); ?>js/jqplot/jquery.jqplot.min.js"></script>
  12. <script type="text/javascript" src="<?php echo base_url(); ?>js/jqplot/plugins/jquery.jqplot.min.js"></script>
  13. <script type="text/javascript" src="<?php echo base_url(); ?>js/jqplot/plugins/jqplot.barRenderer.min.js"></script>
  14. <script type="text/javascript" src="<?php echo base_url(); ?>js/jqplot/plugins/jqplot.categoryAxisRenderer.min.js"></script>
  15. <script type="text/javascript" src="<?php echo base_url(); ?>js/jqplot/plugins/jqplot.pointLabels.min.js"></script>-->
  16. <!--<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/shopifine/message.css" />-->
  17. <style type="text/css">
  18. .menu_item {
  19. display: inline;
  20. }
  21. </style>
  22. <style type="text/css">
  23. #menubar_admin_navigation {
  24. top:49px;
  25. }
  26. #content_area {width:100%;height:auto;}
  27. .logoauth {color:green;}
  28. .shopifine-ui-dialog-buttonset {
  29. float: left;
  30. margin: 1em;
  31. padding-left: 2em;
  32. }
  33. .shopifine-ui-widget-content {
  34. border:none;
  35. }
  36. </style>
  37. <script>
  38. function checkStatus(){
  39. var error= '<?php echo $error ?>';
  40. if (error=="true"){
  41. $("#mainCntnr").hide();
  42. $("#forceMessageCntnr").show();
  43. }
  44. }
  45. $(function() {
  46. var idsOfSelectedRows =[];
  47. var updateIdsOfSelectedRows = function (id, isSelected) {
  48. var contains = $.inArray(id, idsOfSelectedRows)
  49. //idsOfSelectedRows.contains(id);
  50. if (!isSelected && contains>-1) {
  51. for(var i=0; i<idsOfSelectedRows.length; i++) {
  52. if(idsOfSelectedRows[i] == id) {
  53. idsOfSelectedRows.splice(i, 1);
  54. break;
  55. }
  56. }
  57. }
  58. else if (contains==-1) {
  59. idsOfSelectedRows.push(id);
  60. }
  61. console.log(idsOfSelectedRows);
  62. };
  63. var myGrid = $("#product_stock");
  64. myGrid.jqGrid({
  65. url:'index.php/impex/populateProductsStocksToExport',
  66. datatype: 'json',
  67. mtype: 'GET',
  68. colNames:['Barcode','Product ID','Stocks To Add'],
  69. colModel :[
  70. {name:'barcode', index:'barcode', width:200, align:'right',editable:false},
  71. {name:'product_id', index:'product_id', align:'right',hidden:true},
  72. {name:'balance_to_update', index:'balance_to_update', width:100, align:'right'},
  73. ],
  74. pager: '#pager',
  75. rowNum:5,
  76. rowList:[5,10,50],
  77. sortname: 'id',
  78. sortorder: 'desc',
  79. viewrecords: true,
  80. gridview: true,
  81. ignoreCase:true,
  82. rownumbers:true,
  83. height:'auto',
  84. width:250,
  85. multiselect:true,
  86. caption: 'Inventory To Be Updated',
  87. jsonReader : {
  88. root:"productstockdata",
  89. page: "page",
  90. total: "total",
  91. records: "records",
  92. cell: "dprow",
  93. id: "id"
  94. },
  95. onSelectRow: function(rowid, status){
  96. updateIdsOfSelectedRows(rowid, status);
  97. },
  98. onSelectAll: function (aRowids, status) {
  99. var i, count, id;
  100. for (i = 0, count = aRowids.length; i < count; i++) {
  101. id = aRowids[i];
  102. updateIdsOfSelectedRows(id, status);
  103. }
  104. }
  105. }).navGrid("#pager",{edit:false,add:false,del:false,search:false},
  106. /* edit Option*/ {},
  107. /* Add Option*/ {},
  108. {},{},{});
  109. myGrid.jqGrid('navButtonAdd','#pager',{
  110. caption:"",
  111. title:"Create CSV To Begin Export Process",
  112. buttonicon:"ui-icon-newwin",
  113. onClickButton : function () {
  114. var rowid = myGrid.jqGrid('getGridParam', 'selarrrow');
  115. var noOfRows = rowid.length;
  116. console.log(rowid);
  117. if (noOfRows == 0){
  118. $( "#modal-warning-none" ).dialog("open");
  119. }
  120. else{
  121. $(".inithide").hide();
  122. $.ajax({
  123. url:'index.php/impex/createExportStockFile',
  124. method:'post',
  125. data:{selected:idsOfSelectedRows},
  126. success:function(response){
  127. var responseObj = JSON.parse(response);
  128. $(".inithide").hide();
  129. if (responseObj.status == "success"){
  130. $("#successCntnr").slideDown("slow");
  131. $("#success-text").text(responseObj.message);
  132. $("#selected_ids_hidden").val(idsOfSelectedRows);
  133. }
  134. else if (responseObj.status == "error"){
  135. $("#failureCntnr").slideDown("slow");
  136. $("#failure-text").text(responseObj.message);
  137. $("#selected_ids_hidden").val("");
  138. }
  139. },
  140. error:function(response){
  141. var responseObj = JSON.parse(response);
  142. $(".inithide").hide();
  143. $("#failureCntnr").show();
  144. $("#failure-text").text("File Could Not Ve Exported Due To Internal Error");
  145. $("#selected_ids_hidden").val("");
  146. }
  147. })
  148. }
  149. }
  150. });
  151. $("#magmiBtn").click(function(){
  152. $("#syncBtn").show()
  153. $.ajax({
  154. url:'index.php/impex/syncNeeeded',
  155. method:'post',
  156. data:{selected:$("#selected_ids_hidden").val()}
  157. });
  158. })
  159. $("#syncBtn").click(function(){
  160. $( "#dialog-confirm" ).dialog("open");
  161. });
  162. $("#forceSyncBtn").click(function(){
  163. $.ajax({
  164. url:'index.php/impex/doSync',
  165. method:'get',
  166. success:function (response){
  167. var responseObj = JSON.parse(response);
  168. if (responseObj.status=="success"){
  169. $("#mainCntnr").show();
  170. $("#forceMessageCntnr").hide();
  171. $("#success-text").text("Sync Successful");
  172. }
  173. else{
  174. $("#force-text").text("Force Sync Failed");
  175. }
  176. },
  177. error:function (response){
  178. $("#force-text").text("Force Sync Failed");
  179. }
  180. });
  181. })
  182. $( "#dialog-confirm" ).dialog({
  183. resizable: false,
  184. height:200,
  185. width:500,
  186. modal: true,
  187. autoOpen:false,
  188. buttons: {
  189. "Confirm": function() {
  190. $.ajax({
  191. url:'index.php/impex/doSync',
  192. method:'get',
  193. success:function (response){
  194. $("#success-text").text("Sync Completed");
  195. },
  196. error:function (response){
  197. $("#success-text").text("Sync Failed");
  198. }
  199. });
  200. $( this ).dialog( "close" );
  201. },
  202. Cancel: function() {
  203. $( this ).dialog( "close" );
  204. }
  205. }
  206. });
  207. });
  208. </script>
  209. </head>
  210. <body onload="return checkStatus();">
  211. <?php $this->load->view("common/menubar"); ?>
  212. <div id="dialog-confirm" title="Warning" class="inithide">
  213. <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
  214. Please See The Console To See If Processing Complete.Sync Only When The Processing Is Over;Else System Will Be Inconsistent and Sync May Not Work. Is Processing Over?</p>
  215. </div>
  216. <?php //if (!$error): ?>
  217. <div id="mainCntnr" style="display: block;height: auto;" class="shopifine-ui-dialog ui-dialog-medium ui-widget ui-widget-content ui-corner-all" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog-form">
  218. <div class="table-grid">
  219. <h1 id="table header">Product Stock</h1>
  220. <table id="product_stock"><tr><td/></tr></table>
  221. <div id="pager"></div>
  222. </div>
  223. <div id="successCntnr" class="inithide">
  224. <h1>Export To CSV For New Product Creation Completed</h1>
  225. <h3 id="success-text"></h3>
  226. <div class="ui-dialog-content" style="width: auto; min-height: 65.1333px; height: auto;" scrolltop="0" scrollleft="0">
  227. <!-- <h1 id="formHeader">Add Delivery Point</h1> -->
  228. <form id="deliverypointform" target="iframeMagmi" method="post" action="<?php echo $server_url ?>/magmi/web/magmi.php">
  229. <input type="hidden" name="logfile" value="progress.txt"/>
  230. <input type="hidden" name="mode" value="<?php echo $mode ?>"/>
  231. <input type="hidden" name="profile" value="<?php echo $profile ?>"/>
  232. <input type="hidden" name="run" value="import"/>
  233. <input id ="selected_ids_hidden" type="hidden" name="selected_ids_hidden" value="import"/>
  234. <div class="ui-dialog-buttonpane shopifine-ui-widget-content ui-helper-clearfix">
  235. <div class="shopifine-ui-dialog-buttonset">
  236. <input id="magmiBtn" type="submit" class="shopifine-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false" value="Process For Magento">
  237. <input id="syncBtn" class="inithide shopifine-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false" value="Sync After Process Completes!!">
  238. </div>
  239. </div>
  240. </form>
  241. </div>
  242. <iframe id="iframeMagmi" name="iframeMagmi" style="height:900px;width:100%" frameborder="no">
  243. </iframe>
  244. </div>
  245. <?php //else: ?>
  246. <div id="faliureCntnr" class="inithide">
  247. <h1 id ="failure-text"></h1>
  248. </div>
  249. <?php //endif; ?>
  250. </div>
  251. <?php //else: ?>
  252. <div id="forceMessageCntnr" style=" height: auto;" class="inithide shopifine-ui-dialog ui-dialog-medium ui-widget ui-widget-content ui-corner-all" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog-form">
  253. <h3 id ="force-text">Sync Was Not Properly Done. You Can Not Update Stock Before The Previous Sync Is Done Properly. Please Do Force Sync And System Will Try To Resolve The Issue Else ConTact Admin </h3>
  254. <div class="shopifine-ui-dialog-buttonset">
  255. <input id="forceSyncBtn" class="shopifine-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false" value="Force Sync!!">
  256. </div>
  257. </div>
  258. <?php //endif; ?>
  259. <!-- <div style="display: block;height: 100%;left:0em; overflow: hidden;" class="shopifine-ui-dialog ui-widget ui-widget-content ui-corner-all" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog-form">
  260. <?php //$this->load->view("common/message"); ?>
  261. </div>-->
  262. <?php $this->load->view("partial/footer"); ?>
  263. </body>
  264. </html>
  265. <script>
  266. function setOption(){
  267. $("#mode").val("xcreate");
  268. }
  269. </script>