PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/opensourcepos/application/views/procurement/quote/approval/quote_approval_grid.php

https://bitbucket.org/jit_bec/shopifine
PHP | 413 lines | 337 code | 59 blank | 17 comment | 10 complexity | 92c6c5611739721a2eb6ed2655b60a29 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <html>
  2. <head>
  3. <?php $this->load->view("common/header"); ?>
  4. <!-- <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>-->
  5. <style>
  6. .column {
  7. float: left;
  8. padding: 1em;
  9. width:45%;
  10. }
  11. .extra-wide{
  12. width:95%;
  13. }
  14. .field{
  15. width:100%;
  16. }
  17. .ui-widget-header {height:12px;}
  18. .quote-column {
  19. float: left;
  20. padding-bottom: 0.5em;
  21. width: 45em;
  22. }
  23. .ui-combobox-input{
  24. width:23em;
  25. }
  26. #supplierOp-input{
  27. width:10em;
  28. }
  29. #warehouseOp-input{
  30. width:10em;
  31. }
  32. .calculated {
  33. color: green;
  34. font-size: 90%;
  35. }
  36. .row{
  37. width:95%;
  38. }
  39. .shopifine-ro-label {
  40. float: left;
  41. padding-right: 0.5em;
  42. width: 50%;
  43. word-wrap: break-word;
  44. color:#2E6E9E;
  45. }
  46. .shopifine-output {
  47. float: right;
  48. width: 45%;
  49. word-wrap: break-word;
  50. font-weight:bold;
  51. }
  52. .ui-tabs {
  53. height: 80%;
  54. margin: 0 auto;
  55. width: 100%;
  56. left:0;
  57. }
  58. #notetab {
  59. height:20em;
  60. }
  61. .ui-tabs-nav{
  62. height:22px;
  63. }
  64. p {
  65. padding: 0;
  66. width: 70%;
  67. word-wrap: break-word;
  68. }
  69. </style>
  70. <script type="text/javascript">
  71. $(function() {
  72. //form validation
  73. $("#quoteForm").validate();
  74. $( "#dialog-form" ).dialog({
  75. autoOpen: false,
  76. height: 'auto',
  77. width: '52%',
  78. position:[350,25],
  79. modal: true,
  80. buttons: {
  81. "DoneButton": {
  82. id:"doneBtn",
  83. text:"Approve And Generate PO",
  84. click:function() {
  85. var isValid = $("#quoteForm").valid();
  86. if (isValid){
  87. $.ajax({url:"index.php/procurement/approveOrReject",
  88. type:"POST",
  89. data:{
  90. action:'approve',
  91. quoteId:myGrid.getGridParam('selrow'),
  92. quote_approval_notes:$("#approveNotes").val()
  93. },
  94. success:function(response)
  95. {
  96. emptyMessages();
  97. showSuccessMessage("Quoation Has Been Approved And Purchase Order Generated");
  98. myGrid.trigger("reloadGrid");
  99. }
  100. }) //end ajax
  101. $( this ).dialog( "close" );
  102. } //end ifvalid
  103. }}, //end of Create button
  104. "RejectButton": {id:"rejectBtn",
  105. text:"Reject",
  106. click:function() {
  107. var isValid = $("#quoteForm").valid();
  108. if (isValid){
  109. $.ajax({url:"index.php/procurement/approveOrReject",
  110. type:"POST",
  111. data:{
  112. action:'reject',
  113. quoteId:myGrid.getGridParam('selrow'),
  114. quote_approval_notes:$("#approveNotes").val()
  115. },
  116. success:function(response)
  117. {
  118. emptyMessages();
  119. showSuccessMessage("Quoation Has Been Rejected.Please Modify And Resubmit");
  120. myGrid.trigger("reloadGrid");
  121. }
  122. }) //end ajax
  123. $( this ).dialog( "close" );
  124. } //end ifvalid
  125. }}
  126. },//end buttons
  127. open: function(){
  128. $( "#tabs" ).tabs({
  129. //load contents after the tab loading is complete
  130. load: function(event,ui){
  131. $.ajax({
  132. method:"POST",
  133. url:'index.php/procurement/getQuoteDetails',
  134. data:{quoteId: myGrid.getGridParam('selrow')},
  135. success:function(response){
  136. //console.log(response);
  137. var resJson = JSON.parse(response);
  138. //console.log(resJson);
  139. $("#quoteRef").text(resJson.reference);
  140. $("#supplierOP").text(resJson.supplier_name);
  141. $("#warehouseOP").text(resJson.warehouse);
  142. $("#quoteOP").text(resJson.reference);
  143. $("#raisedByOP").text(resJson.raised_by_name);
  144. $("#approvedByOP").text(resJson.approved_by_name);
  145. $("#estValueOP").text(resJson.estimated_value);
  146. }
  147. })
  148. $("#lineItems").jqGrid({
  149. url:'index.php/procurement/populateQuoteItems?q=2&quoteId='+myGrid.getGridParam('selrow'),
  150. datatype: 'json',
  151. colNames:['Product','Quantity','Need By Date','Unit Price','Estimated Value','Notes'],
  152. colModel :[
  153. {name:'name', index:'name',editable:false, width:120, align:'right'},
  154. {name:'quoted_quantity', index:'quoted_quantity', editable:true,width:50, align:'right'},
  155. {name:'needed_by_date',index:'needed_by_date',editable:true, width:80, align:'right'},
  156. {name:'expected_price',index:'expected_price',editable:true, width:50, align:'right'},
  157. {name:'estimated_value', index:'estimated_value',editable:false, width:60, align:'right'},
  158. {name:'comments', index:'comments',editable:true, width:180, align:'right'}
  159. ],
  160. rowNum:20,
  161. pager: '#pagerPk',
  162. sortname: 'id',
  163. sortorder: "asc",
  164. height: '100%',
  165. jsonReader : {
  166. root:"quoteitemdata",
  167. page: "page",
  168. total: "total",
  169. records: "records",
  170. cell: "dprow",
  171. id: "id"
  172. }
  173. }).navGrid("#pagerPk",{edit:false,add:false,del:true,search:false},{},{},{},{},{});
  174. }
  175. });
  176. },
  177. close: function() {
  178. //allFields.val( "" ).removeClass( "ui-state-error" );
  179. $("#quoteForm").data('validator').resetForm();
  180. $("#quoteForm")[0].reset();
  181. $("#lineItems").jqGrid("GridUnload");
  182. $( "#tabs" ).tabs("destroy");
  183. }
  184. });
  185. // Main Request For Quotation Grid
  186. var myGrid = $("#quotes");
  187. myGrid.jqGrid({
  188. url:'index.php/procurement/populateRFQ?status='+'waitingforapproval',
  189. datatype: 'json',
  190. mtype: 'GET',
  191. colNames:['Reference','Supplier','Estimated Value',/*'Owner',*/'Status','Raised By','Owner','Needed By Date'],
  192. colModel :[
  193. {name:'reference', index:'reference', width:80, align:'right',editable:false},
  194. {name:'supplier_name', index:'supplier_name', width:140, align:'right',editable:false},
  195. {name:'estimated_value', index:'estimated_value', width:100, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
  196. // {name:'owner', index:'owner', width:140, align:'right',editable:true,editoptions:{size:"20",maxlength:"30"}},
  197. {name:'status', index:'status', width:60, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
  198. {name:'raised_by_name', index:'raised_by_name',editable:false, width:80, align:'right'},
  199. {name:'owner_name', index:'owner_name',editable:false, width:80, align:'right'},
  200. {name:'needed_by_date', index:'needed_by_date',editable:false, width:120, sorttype:'date'}
  201. ],
  202. pager: '#pager',
  203. rowNum:10,
  204. rowList:[5,10,20],
  205. sortname: 'id',
  206. sortorder: 'desc',
  207. viewrecords: true,
  208. gridview: true,
  209. multiselect:true,
  210. ignoreCase:true,
  211. rownumbers:true,
  212. height:'auto',
  213. width:680,
  214. caption: 'Request For Quote',
  215. jsonReader : {
  216. root:"quotedata",
  217. page: "page",
  218. total: "total",
  219. records: "records",
  220. cell: "dprow",
  221. id: "id"
  222. },
  223. subGrid:true,
  224. subGridRowExpanded: function(subgrid_id, row_id) {
  225. // we pass two parameters
  226. // subgrid_id is a id of the div tag created whitin a table data
  227. // the id of this elemenet is a combination of the "sg_" + id of the row
  228. // the row_id is the id of the row
  229. // If we wan to pass additinal parameters to the url we can use
  230. // a method getRowData(row_id) - which returns associative array in type name-value
  231. // here we can easy construct the flowing
  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" ).dialog("open");
  274. }
  275. else if (noOfRows == 1){
  276. $( "#dialog-form" ).dialog( "open" );
  277. }
  278. else {
  279. $( "#modal-warning-morethanone" ).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/generatePOFromRFQ",
  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. $( "#modal-warning-morethanone" ).dialog({
  311. autoOpen:false,
  312. height: 80,
  313. modal: true
  314. });
  315. $( "#modal-warning" ).dialog({
  316. autoOpen:false,
  317. height: 80,
  318. modal: true
  319. });
  320. });
  321. </script>
  322. </head>
  323. <body>
  324. <?php $this->load->view("common/menubar"); ?>
  325. <div id="modal-warning-morethanone" title="Warning">
  326. <p>More Than One Row Selected.Please Select Exactly Row</p>
  327. </div>
  328. <div id="modal-warning" title="Warning">
  329. <p>Please Select At Least One Row</p>
  330. </div>
  331. <div id ="dialog-form">
  332. <h1 id="formHeader">Quote # <span id="quoteRef"></span> Details</h1>
  333. <form id="quoteForm">
  334. <fieldset>
  335. <div id="tabs">
  336. <ul>
  337. <li><a href="<?php echo site_url('procurement/loadQuoteFormFragment') ?>">Basic Details</a></li>
  338. <li><a href="<?php echo site_url('procurement/loadQuoteNotesFragment') ?>">Notes</a></li>
  339. </ul>
  340. </div>
  341. </fieldset>
  342. </form>
  343. </div>
  344. <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">
  345. <?php $this->load->view("common/message"); ?>
  346. <div class="table-grid">
  347. <h1 id="table header">Request For Quotations</h1>
  348. <table id="quotes"><tr><td/></tr></table>
  349. <div id="pager"></div>
  350. </div>
  351. </div>
  352. <?php $this->load->view("partial/footer"); ?>
  353. </body>
  354. </html>