PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/jit_bec/shopifine
PHP | 435 lines | 348 code | 63 blank | 24 comment | 13 complexity | 5227e82108c8797fe8ccef3a0d89e68f 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. .shopifine-ui-dialog {
  53. padding: 1em 1em;
  54. }
  55. .ui-tabs {
  56. height: 80%;
  57. margin: 0 auto;
  58. width: 100%;
  59. left:0;
  60. }
  61. #notetab {
  62. height:20em;
  63. }
  64. .ui-tabs-nav{
  65. height:22px;
  66. }
  67. #status-message{
  68. margin:5px;
  69. }
  70. p {
  71. padding: 0;
  72. width: 70%;
  73. word-wrap: break-word;
  74. }
  75. </style>
  76. <script type="text/javascript">
  77. $(function() {
  78. //form validation
  79. $("#quoteForm").validate();
  80. $( "#dialog-form" ).dialog({
  81. autoOpen: false,
  82. height: 'auto',
  83. width: '52%',
  84. position:[350,25],
  85. modal: true,
  86. buttons: {
  87. "DoneButton": {
  88. id:"doneBtn",
  89. text:"Approve",
  90. click:function() {
  91. var isValid = $("#quoteForm").valid();
  92. if (isValid){
  93. $.ajax({url:"index.php/procurement/approveOrReject",
  94. type:"POST",
  95. data:{
  96. action:'approve',
  97. quoteId:myGrid.getGridParam('selrow'),
  98. quote_approval_notes:$("#approveNotes").val(),
  99. entity:'rfq'
  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. entity:'rfq'
  123. },
  124. success:function(response)
  125. {
  126. emptyMessages();
  127. showSuccessMessage("Quoation Has Been Rejected.Please Modify And Resubmit");
  128. myGrid.trigger("reloadGrid");
  129. }
  130. }) //end ajax
  131. $( this ).dialog( "close" );
  132. } //end ifvalid
  133. }}
  134. },//end buttons
  135. open: function(){
  136. $( "#tabs" ).tabs({
  137. //cache
  138. beforeLoad: function( event, ui ) {
  139. var tabcache = $("#tabcache").val();
  140. if (tabcache==1){
  141. if ( ui.tab.data( "loaded" ) ) {
  142. event.preventDefault();
  143. return;
  144. }
  145. ui.jqXHR.success(function() {
  146. ui.tab.data( "loaded", true );
  147. });
  148. }
  149. },
  150. beforeActivate: function (event,ui){
  151. if (ui.oldTab[0].id=="notesLink"){
  152. $("#tabcache").val("1");
  153. }
  154. },
  155. //load contents after the tab loading is complete
  156. load: function(event,ui){
  157. $.ajax({
  158. method:"POST",
  159. url:'index.php/procurement/getRFQDetails',
  160. data:{quoteId: myGrid.getGridParam('selrow')},
  161. success:function(response){
  162. //console.log(response);
  163. var resJson = JSON.parse(response);
  164. //console.log(resJson);
  165. $("#quoteRef").text(resJson.reference);
  166. $("#supplierOP").text(resJson.supplier_name);
  167. $("#warehouseOP").text(resJson.warehouse);
  168. $("#quoteOP").text(resJson.reference);
  169. $("#raisedByOP").text(resJson.raised_by_name);
  170. $("#approvedByOP").text(resJson.approved_by_name);
  171. $("#estValueOP").text(resJson.estimated_value);
  172. }
  173. })
  174. $("#lineItems").jqGrid({
  175. url:'index.php/procurement/populateRFQItems?q=2&quoteId='+myGrid.getGridParam('selrow'),
  176. datatype: 'json',
  177. colNames:['Product','Quantity','Need By Date','Unit Price','Estimated Value','Notes'],
  178. colModel :[
  179. {name:'name', index:'name',editable:false, width:120, align:'right'},
  180. {name:'quoted_quantity', index:'quoted_quantity', editable:true,width:50, align:'right'},
  181. {name:'needed_by_date',index:'needed_by_date',editable:true, width:80, align:'right'},
  182. {name:'expected_price',index:'expected_price',editable:true, width:50, align:'right'},
  183. {name:'estimated_value', index:'estimated_value',editable:false, width:60, align:'right'},
  184. {name:'comments', index:'comments',editable:true, width:180, align:'right'}
  185. ],
  186. rowNum:20,
  187. pager: '#pagerPk',
  188. sortname: 'id',
  189. sortorder: "asc",
  190. height: '100%',
  191. jsonReader : {
  192. root:"quoteitemdata",
  193. page: "page",
  194. total: "total",
  195. records: "records",
  196. cell: "dprow",
  197. id: "id"
  198. }
  199. }).navGrid("#pagerPk",{edit:false,add:false,del:false,search:false},{},{},{},{},{});
  200. }
  201. });
  202. },
  203. close: function() {
  204. //allFields.val( "" ).removeClass( "ui-state-error" );
  205. $("#quoteForm").data('validator').resetForm();
  206. $("#quoteForm")[0].reset();
  207. $("#tabcache").val("0");
  208. $("#lineItems").jqGrid("GridUnload");
  209. $( "#tabs" ).tabs("destroy");
  210. }
  211. });
  212. // Main Request For Quotation Grid
  213. var myGrid = $("#quotes");
  214. myGrid.jqGrid({
  215. url:'index.php/procurement/populateRFQ?status='+'waitingforapproval',
  216. datatype: 'json',
  217. mtype: 'GET',
  218. colNames:['Reference','Supplier','Estimated Value',/*'Owner',*/'Status','Raised By','Owner','Needed By Date'],
  219. colModel :[
  220. {name:'reference', index:'reference', width:80, align:'right',editable:false},
  221. {name:'supplier_name', index:'supplier_name', width:140, align:'right',editable:false},
  222. {name:'estimated_value', index:'estimated_value', width:100, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
  223. // {name:'owner', index:'owner', width:140, align:'right',editable:true,editoptions:{size:"20",maxlength:"30"}},
  224. {name:'status', index:'status', width:60, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
  225. {name:'raised_by_name', index:'raised_by_name',editable:false, width:80, align:'right'},
  226. {name:'owner_name', index:'owner_name',editable:false, width:80, align:'right'},
  227. {name:'needed_by_date', index:'needed_by_date',editable:false, width:120, sorttype:'date'}
  228. ],
  229. pager: '#pager',
  230. rowNum:10,
  231. rowList:[5,10,20],
  232. sortname: 'id',
  233. sortorder: 'desc',
  234. viewrecords: true,
  235. gridview: true,
  236. multiselect:true,
  237. ignoreCase:true,
  238. rownumbers:true,
  239. height:'auto',
  240. width:680,
  241. caption: 'Request For Quotations',
  242. jsonReader : {
  243. root:"quotedata",
  244. page: "page",
  245. total: "total",
  246. records: "records",
  247. cell: "dprow",
  248. id: "id"
  249. },
  250. subGrid:true,
  251. subGridRowExpanded: function(subgrid_id, row_id) {
  252. var subgrid_table_id, pager_id;
  253. subgrid_table_id = subgrid_id+"_t";
  254. pager_id = "p_"+subgrid_table_id;
  255. $("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
  256. jQuery("#"+subgrid_table_id).jqGrid({
  257. url:'index.php/procurement/populateRFQItems?q=2&quoteId='+row_id,
  258. datatype: 'json',
  259. colNames:['Product','Quantity','Need By Date','Unit Price','Estimated Value','Notes'],
  260. colModel :[
  261. {name:'name', index:'name',editable:false, width:120, align:'right'},
  262. {name:'quoted_quantity', index:'quoted_quantity', editable:false,width:50, align:'right'},
  263. {name:'needed_by_date',index:'needed_by_date',editable:false, width:80, align:'right'},
  264. {name:'expected_price',index:'expected_price',editable:false, width:50, align:'right'},
  265. {name:'estimated_value', index:'estimated_value',editable:false, width:60, align:'right'},
  266. {name:'comments', index:'comments',editable:false, width:180, align:'right'}
  267. ],
  268. rowNum:20,
  269. pager: pager_id,
  270. sortname: 'id',
  271. sortorder: "asc",
  272. height: '100%',
  273. jsonReader : {
  274. root:"quoteitemdata",
  275. page: "page",
  276. total: "total",
  277. records: "records",
  278. cell: "dprow",
  279. id: "id"
  280. }
  281. });
  282. jQuery("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit:false,add:false,del:false,search:false});
  283. }}).navGrid("#pager",{edit:false,add:false,del:false,search:false},{height:280,reloadAfterSubmit:false,closeAfterEdit:true,recreateForm:true,checkOnSubmit:true},{},{},{},{});
  284. myGrid.jqGrid('navButtonAdd','#pager',{
  285. caption:"",
  286. title:"Approve RFQ",
  287. buttonicon:"ui-icon-check",
  288. id:"add_quotes",
  289. onClickButton : function () {
  290. var selectedRows = myGrid.jqGrid('getGridParam', 'selarrrow');
  291. var noOfRows = selectedRows.length;
  292. if (noOfRows == 0){
  293. $( "#modal-warning" ).dialog("open");
  294. }
  295. else if (noOfRows == 1){
  296. $( "#dialog-form" ).dialog( "open" );
  297. }
  298. else {
  299. $( "#modal-warning-morethanone" ).dialog("open") ;
  300. }
  301. }
  302. });
  303. myGrid.jqGrid('navButtonAdd','#pager',{
  304. caption:"",
  305. title:"Approve RFQ In Bulk",
  306. buttonicon:"ui-icon-circle-check",
  307. id:"po_quotes",
  308. onClickButton : function () {
  309. var rowid = myGrid.jqGrid('getGridParam', 'selarrrow');
  310. var selectedRows = myGrid.jqGrid('getGridParam', 'selarrrow');
  311. var noOfRows = selectedRows.length;
  312. if (noOfRows == 0){
  313. $( "#modal-warning" ).dialog("open");
  314. }
  315. else{
  316. $.ajax({
  317. method:"POST",
  318. url:"index.php/procurement/approveQuotesInBulk",
  319. data: {ids : rowid},
  320. success: function(){
  321. myGrid.trigger("reloadGrid");
  322. showSuccessMessage("success");
  323. }
  324. })
  325. }
  326. }
  327. });
  328. myGrid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch : "cn"});
  329. $("#del_quotes").insertAfter("#add_quotes");
  330. });
  331. // $(window).load(function(){
  332. // $( "#modal-warning-morethanone" ).dialog({
  333. // autoOpen:false,
  334. // height: 80,
  335. // modal: true
  336. // });
  337. // $( "#modal-warning" ).dialog({
  338. // autoOpen:false,
  339. // height: 80,
  340. // modal: true
  341. // });
  342. // });
  343. </script>
  344. </head>
  345. <body>
  346. <?php $this->load->view("common/menubar"); ?>
  347. <?php $this->load->view("common/dialogs"); ?>
  348. <div id ="dialog-form">
  349. <h1 id="formHeader">RFQ # <span id="quoteRef"></span> Details</h1>
  350. <form id="quoteForm">
  351. <fieldset>
  352. <div id="tabs">
  353. <ul>
  354. <li id="baseLink"><a href="<?php echo site_url('procurement/loadWaitingForApprovalRFQFormFragment') ?>">Basic Details</a></li>
  355. <li id="notesLink"><a href="<?php echo site_url('procurement/loadWaitingForApprovalRFQNotesFragment') ?>">Notes</a></li>
  356. </ul>
  357. </div>
  358. </fieldset>
  359. </form>
  360. </div>
  361. <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">
  362. <?php $this->load->view("common/message"); ?>
  363. <div class="table-grid">
  364. <h1 id="quote_header">Request For Quotations</h1>
  365. <table id="quotes"><tr><td/></tr></table>
  366. <div id="pager"></div>
  367. </div>
  368. </div>
  369. <input id="tabcache" name="tabcache" value="0" type="hidden"/>
  370. <?php $this->load->view("partial/footer"); ?>
  371. </body>
  372. </html>