PageRenderTime 54ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/magehelp/application/views/procurement/quote/approval/quote_approval_grid_1.php

https://bitbucket.org/jit_bec/shopifine
PHP | 403 lines | 332 code | 60 blank | 11 comment | 10 complexity | 0f53af8c9fd6f4e50961fa566ddbb0b6 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <html>
  2. <head>
  3. <?php $this->load->view("common/header"); ?>
  4. <script src="<?php echo base_url();?>js/dialogs.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
  5. <!-- <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>-->
  6. <style>
  7. .column {
  8. float: left;
  9. padding: 1em;
  10. width:45%;
  11. }
  12. .extra-wide{
  13. width:95%;
  14. }
  15. .field{
  16. width:100%;
  17. }
  18. .ui-widget-header {height:12px;}
  19. .quote-column {
  20. float: left;
  21. padding-bottom: 0.5em;
  22. width: 45em;
  23. }
  24. .ui-combobox-input{
  25. width:23em;
  26. }
  27. #supplierOp-input{
  28. width:10em;
  29. }
  30. #warehouseOp-input{
  31. width:10em;
  32. }
  33. .calculated {
  34. color: green;
  35. font-size: 90%;
  36. }
  37. .row{
  38. width:95%;
  39. }
  40. .shopifine-ro-label {
  41. float: left;
  42. padding-right: 0.5em;
  43. width: 50%;
  44. word-wrap: break-word;
  45. color:#2E6E9E;
  46. }
  47. .shopifine-output {
  48. float: right;
  49. width: 45%;
  50. word-wrap: break-word;
  51. font-weight:bold;
  52. }
  53. .shopifine-ui-dialog {
  54. padding: 1em 1em;
  55. }
  56. .ui-tabs {
  57. height: 80%;
  58. margin: 0 auto;
  59. width: 100%;
  60. left:0;
  61. }
  62. #notetab {
  63. height:20em;
  64. }
  65. .ui-tabs-nav{
  66. height:22px;
  67. }
  68. #status-message{
  69. margin:5px;
  70. }
  71. p {
  72. padding: 0;
  73. width: 70%;
  74. word-wrap: break-word;
  75. }
  76. </style>
  77. <script type="text/javascript">
  78. $(function() {
  79. //form validation
  80. $("#quoteForm").validate();
  81. $( "#dialog-form" ).dialog({
  82. autoOpen: false,
  83. height: 'auto',
  84. width: '52%',
  85. position:[350,25],
  86. modal: true,
  87. buttons: {
  88. "DoneButton": {
  89. id:"doneBtn",
  90. text:"Approve And Generate PO",
  91. click:function() {
  92. var isValid = $("#quoteForm").valid();
  93. if (isValid){
  94. $.ajax({url:"index.php/procurement/approveOrReject",
  95. type:"POST",
  96. data:{
  97. action:'approve',
  98. quoteId:myGrid.getGridParam('selrow'),
  99. quote_approval_notes:$("#approveNotes").val()
  100. },
  101. success:function(response)
  102. {
  103. emptyMessages();
  104. showSuccessMessage("Quoation Has Been Approved And Purchase Order Generated");
  105. myGrid.trigger("reloadGrid");
  106. }
  107. }) //end ajax
  108. $( this ).dialog( "close" );
  109. } //end ifvalid
  110. }}, //end of Create button
  111. "RejectButton": {id:"rejectBtn",
  112. text:"Reject",
  113. click:function() {
  114. var isValid = $("#quoteForm").valid();
  115. if (isValid){
  116. $.ajax({url:"index.php/procurement/approveOrReject",
  117. type:"POST",
  118. data:{
  119. action:'reject',
  120. quoteId:myGrid.getGridParam('selrow'),
  121. quote_approval_notes:$("#approveNotes").val()
  122. },
  123. success:function(response)
  124. {
  125. emptyMessages();
  126. showSuccessMessage("Quoation Has Been Rejected.Please Modify And Resubmit");
  127. myGrid.trigger("reloadGrid");
  128. }
  129. }) //end ajax
  130. $( this ).dialog( "close" );
  131. } //end ifvalid
  132. }}
  133. },//end buttons
  134. open: function(){
  135. $( "#tabs" ).tabs({
  136. //load contents after the tab loading is complete
  137. load: function(event,ui){
  138. $.ajax({
  139. method:"POST",
  140. url:'index.php/procurement/getQuoteDetails',
  141. data:{quoteId: myGrid.getGridParam('selrow')},
  142. success:function(response){
  143. //console.log(response);
  144. var resJson = JSON.parse(response);
  145. //console.log(resJson);
  146. $("#quoteRef").text(resJson.reference);
  147. $("#supplierOP").text(resJson.supplier_name);
  148. $("#warehouseOP").text(resJson.warehouse);
  149. $("#quoteOP").text(resJson.reference);
  150. $("#raisedByOP").text(resJson.raised_by_name);
  151. $("#approvedByOP").text(resJson.approved_by_name);
  152. $("#estValueOP").text(resJson.estimated_value);
  153. }
  154. })
  155. $("#lineItems").jqGrid({
  156. url:'index.php/procurement/populateQuoteItems?q=2&quoteId='+myGrid.getGridParam('selrow'),
  157. datatype: 'json',
  158. colNames:['Product','Quantity','Need By Date','Unit Price','Estimated Value','Notes'],
  159. colModel :[
  160. {name:'name', index:'name',editable:false, width:120, align:'right'},
  161. {name:'quoted_quantity', index:'quoted_quantity', editable:true,width:50, align:'right'},
  162. {name:'needed_by_date',index:'needed_by_date',editable:true, width:80, align:'right'},
  163. {name:'expected_price',index:'expected_price',editable:true, width:50, align:'right'},
  164. {name:'estimated_value', index:'estimated_value',editable:false, width:60, align:'right'},
  165. {name:'comments', index:'comments',editable:true, width:180, align:'right'}
  166. ],
  167. rowNum:20,
  168. pager: '#pagerPk',
  169. sortname: 'id',
  170. sortorder: "asc",
  171. height: '100%',
  172. jsonReader : {
  173. root:"quoteitemdata",
  174. page: "page",
  175. total: "total",
  176. records: "records",
  177. cell: "dprow",
  178. id: "id"
  179. }
  180. }).navGrid("#pagerPk",{edit:false,add:false,del:true,search:false},{},{},{},{},{});
  181. }
  182. });
  183. },
  184. close: function() {
  185. //allFields.val( "" ).removeClass( "ui-state-error" );
  186. $("#quoteForm").data('validator').resetForm();
  187. $("#quoteForm")[0].reset();
  188. $("#lineItems").jqGrid("GridUnload");
  189. $( "#tabs" ).tabs("destroy");
  190. }
  191. });
  192. // Main Request For Quotation Grid
  193. var myGrid = $("#quotes");
  194. myGrid.jqGrid({
  195. url:'index.php/procurement/populateQuotes?_status='+'waitingforapproval',
  196. datatype: 'json',
  197. mtype: 'GET',
  198. colNames:['Reference','Supplier','Estimated Value',/*'Owner',*/'Status','Raised By','Owner','Needed By Date'],
  199. colModel :[
  200. {name:'reference', index:'reference', width:80, align:'right',editable:false},
  201. {name:'supplier_name', index:'supplier_name', width:140, align:'right',editable:false},
  202. {name:'estimated_value', index:'estimated_value', width:100, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
  203. // {name:'owner', index:'owner', width:140, align:'right',editable:true,editoptions:{size:"20",maxlength:"30"}},
  204. {name:'status', index:'status', width:60, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
  205. {name:'raised_by_name', index:'raised_by_name',editable:false, width:80, align:'right'},
  206. {name:'owner_name', index:'owner_name',editable:false, width:80, align:'right'},
  207. {name:'needed_by_date', index:'needed_by_date',editable:false, width:120, sorttype:'date'}
  208. ],
  209. pager: '#pager',
  210. rowNum:10,
  211. rowList:[5,10,20],
  212. sortname: 'id',
  213. sortorder: 'desc',
  214. viewrecords: true,
  215. gridview: true,
  216. multiselect:true,
  217. ignoreCase:true,
  218. rownumbers:true,
  219. height:'auto',
  220. width:680,
  221. caption: 'Quotes',
  222. jsonReader : {
  223. root:"quotedata",
  224. page: "page",
  225. total: "total",
  226. records: "records",
  227. cell: "dprow",
  228. id: "id"
  229. },
  230. subGrid:true,
  231. subGridRowExpanded: function(subgrid_id, row_id) {
  232. var subgrid_table_id, pager_id;
  233. subgrid_table_id = subgrid_id+"_t";
  234. pager_id = "p_"+subgrid_table_id;
  235. $("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
  236. jQuery("#"+subgrid_table_id).jqGrid({
  237. url:'index.php/procurement/populateQuoteItems?q=2&quoteId='+row_id,
  238. datatype: 'json',
  239. colNames:['Product','Quantity','Need By Date','Unit Price','Estimated Value','Notes'],
  240. colModel :[
  241. {name:'name', index:'name',editable:false, width:120, align:'right'},
  242. {name:'quoted_quantity', index:'quoted_quantity', editable:false,width:50, align:'right'},
  243. {name:'needed_by_date',index:'needed_by_date',editable:false, width:80, align:'right'},
  244. {name:'expected_price',index:'expected_price',editable:false, width:50, align:'right'},
  245. {name:'estimated_value', index:'estimated_value',editable:false, width:60, align:'right'},
  246. {name:'comments', index:'comments',editable:false, width:180, align:'right'}
  247. ],
  248. rowNum:20,
  249. pager: pager_id,
  250. sortname: 'id',
  251. sortorder: "asc",
  252. height: '100%',
  253. jsonReader : {
  254. root:"quoteitemdata",
  255. page: "page",
  256. total: "total",
  257. records: "records",
  258. cell: "dprow",
  259. id: "id"
  260. }
  261. });
  262. jQuery("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit:false,add:false,del:true,search:false});
  263. }}).navGrid("#pager",{edit:false,add:false,del:true,search:false},{height:280,reloadAfterSubmit:false,closeAfterEdit:true,recreateForm:true,checkOnSubmit:true},{},{},{},{});
  264. myGrid.jqGrid('navButtonAdd','#pager',{
  265. caption:"",
  266. title:"Approve And Generate Purchase Order",
  267. buttonicon:"ui-icon-check",
  268. id:"add_quotes",
  269. onClickButton : function () {
  270. var selectedRows = myGrid.jqGrid('getGridParam', 'selarrrow');
  271. var noOfRows = selectedRows.length;
  272. if (noOfRows == 0){
  273. $( "#modal-warning-none" ).dialog("open");
  274. }
  275. else if (noOfRows == 1){
  276. $( "#dialog-form" ).dialog( "open" );
  277. }
  278. else {
  279. $( "#modal-warning-one" ).dialog("open") ;
  280. }
  281. }
  282. });
  283. myGrid.jqGrid('navButtonAdd','#pager',{
  284. caption:"",
  285. title:"Approve And Generate Purchase Order In Bulk",
  286. buttonicon:"ui-icon-cart",
  287. id:"po_quotes",
  288. onClickButton : function () {
  289. var rowid = myGrid.jqGrid('getGridParam', 'selarrrow');
  290. var selectedRows = myGrid.jqGrid('getGridParam', 'selarrrow');
  291. var noOfRows = selectedRows.length;
  292. if (noOfRows == 0){
  293. $( "#modal-warning" ).dialog("open");
  294. }
  295. else{
  296. $.ajax({
  297. method:"POST",
  298. url:"index.php/procurement/generatePOFromQuote",
  299. data: {ids : rowid},
  300. success: function(){
  301. myGrid.trigger("reloadGrid");
  302. showSuccessMessage("success");
  303. }
  304. })
  305. }
  306. }
  307. });
  308. myGrid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch : "cn"});
  309. $("#del_quotes").insertAfter("#add_quotes");
  310. });
  311. $(window).load(function(){
  312. var dialogs={one:true,none:true,status:true};
  313. initDialogs(dialogs);
  314. });
  315. </script>
  316. </head>
  317. <body>
  318. <?php $this->load->view("common/menubar"); ?>
  319. <?php $this->load->view("common/dialogs"); ?>
  320. <div id ="dialog-form">
  321. <h1 id="formHeader">Quote # <span id="quoteRef"></span> Details</h1>
  322. <form id="quoteForm">
  323. <fieldset>
  324. <div id="tabs">
  325. <ul>
  326. <li id="baseLink"><a href="<?php echo site_url('procurement/loadQuoteFormFragment') ?>">Basic Details</a></li>
  327. <li id="notesLink"><a href="<?php echo site_url('procurement/loadQuoteNotesFragment') ?>">Notes</a></li>
  328. </ul>
  329. </div>
  330. </fieldset>
  331. </form>
  332. </div>
  333. <div style="display: block;height: 100%;" class="shopifine-ui-dialog ui-widget ui-widget-content ui-corner-all" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog-form">
  334. <?php $this->load->view("common/message"); ?>
  335. <div class="table-grid">
  336. <h1 id="quote_header">Quotes</h1>
  337. <table id="quotes"><tr><td/></tr></table>
  338. <div id="pager"></div>
  339. </div>
  340. </div>
  341. <?php $this->load->view("partial/footer"); ?>
  342. </body>
  343. </html>