PageRenderTime 47ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/magehelp/application/views/procurement/invoice/purchase_invoice_grid_1.php

https://bitbucket.org/jit_bec/shopifine
PHP | 501 lines | 404 code | 77 blank | 20 comment | 4 complexity | 8909c9d8936e3ecda2103782df1a818e 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:30%;
  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: 95%;
  22. }
  23. .ui-combobox {
  24. width:14em;
  25. }
  26. .ui-combobox-input{
  27. width:12em;
  28. }
  29. #supplierOp-input{
  30. width:10em;
  31. }
  32. #warehouseOp-input{
  33. width:10em;
  34. }
  35. .calculated {
  36. color: green;
  37. font-size: 90%;
  38. }
  39. .row{
  40. width:95%;
  41. }
  42. .shopifine-ro-label {
  43. float: left;
  44. padding-right: 0.5em;
  45. width: 50%;
  46. word-wrap: break-word;
  47. color:#2E6E9E;
  48. }
  49. .shopifine-output {
  50. float: right;
  51. width: 45%;
  52. word-wrap: break-word;
  53. font-weight:bold;
  54. }
  55. .ui-tabs {
  56. height: 80%;
  57. margin: 0 auto;
  58. width: 70%;
  59. left:0;
  60. }
  61. #notetab {
  62. height:30em;
  63. }
  64. #details {
  65. height:12em;
  66. }
  67. .ui-tabs-nav{
  68. height:22px;
  69. }
  70. .labeldiv {
  71. color: #2E6E9E;
  72. float: left;
  73. font-size: 110%;
  74. font-weight: bold;
  75. margin-right: .5em;
  76. width: 35%;
  77. word-wrap: break-word;
  78. }
  79. .valuediv {
  80. float: left;
  81. font-weight: bold;
  82. width: 45%;
  83. word-wrap: break-word;
  84. }
  85. label.error {
  86. margin-right: .5em;
  87. }
  88. #status-message-li{
  89. color: red;
  90. font-size: 110%;
  91. font-style: italic;
  92. margin: 0 auto;
  93. width: 80%;
  94. }
  95. .table-grid {
  96. padding-top: 2em;
  97. }
  98. .help-message {
  99. color: green;
  100. float: right;
  101. font-size: 90%;
  102. font-style: italic;
  103. width: 65%;
  104. }
  105. </style>
  106. <script type="text/javascript">
  107. $(function() {
  108. $.validator.addMethod('tallyamount', function (value, el) {
  109. var already_paid = parseFloat($("#amount_paid_form").text());
  110. var pay_amount = parseFloat($("#amount").val());
  111. var total_invoiced_value = parseFloat($("#total_value_form").text());
  112. var prev_amount = $("#prev_amount").val();
  113. var total_paid= already_paid + pay_amount-prev_amount;
  114. if (total_paid>total_invoiced_value){
  115. return false;
  116. }
  117. else {
  118. return true;
  119. }
  120. },"Total Payment Exceeds Invoiced ");
  121. $.validator.addMethod('tallyadvance', function (value, el) {
  122. var advance_value = parseFloat($("#advance_value").text());
  123. var pay_amount = parseFloat($("#amount").val());
  124. var adjusted_advance = parseFloat($("#adjusted_advance").text());
  125. var prev_amount = $("#prev_amount").val();
  126. var total_paid= adjusted_advance + pay_amount - prev_amount;
  127. if (total_paid>advance_value){
  128. return false;
  129. }
  130. else {
  131. return true;
  132. }
  133. },"Total Adjusted Payment Exceeds Advance Payment ");
  134. $("#paymentForm").validate({rules:{
  135. amount:{
  136. required:true,
  137. number:true,
  138. minStrict:0,
  139. tallyamount:true,
  140. tallyadvance:true
  141. }
  142. }}
  143. );
  144. // Main Request For Quotation Grid
  145. function invFormatter ( cellvalue, options, rowObject )
  146. {
  147. // format the cellvalue to new format
  148. return 'PINV-' + cellvalue;
  149. }
  150. function poFormatter ( cellvalue, options, rowObject )
  151. {
  152. // format the cellvalue to new format
  153. return 'PO-' + cellvalue;
  154. }
  155. var myGrid = $("#orders");
  156. myGrid.jqGrid({
  157. url:'index.php/procurement/populateInvoicesToPay',
  158. datatype: 'json',
  159. mtype: 'GET',
  160. colNames:['Invoice Reference','Payment Process','Total Value','Amount Paid','Status','Payee Id','Payee','Owner Id','Owner Name','Order Id','Order Ref'],
  161. colModel :[
  162. {name:'reference', index:'reference', width:120, align:'right',editable:false,formatter:invFormatter},
  163. {name:'payment_process_type', index:'payment_process_type', width:120, align:'right'},
  164. {name:'total_value', index:'total_value',editable:false,align:'right',width:100},
  165. {name:'amount_paid', index:'amount_paid',editable:false,align:'right',width:120},
  166. {name:'status', index:'status',editable:false,align:'right'},
  167. {name:'payee', index:'payee',hidden:true},
  168. {name:'payee_name', index:'payee_name', width:70, align:'right',editable:false},
  169. {name:'owner_id', index:'owner_id',hidden:true},
  170. {name:'owner_name', index:'owner_name', width:70, align:'right',editable:false},
  171. {name:'order_id', index:'order_id',hidden:true},
  172. {name:'order_reference', index:'order_reference',editable:false, width:100, align:'right',formatter:poFormatter}
  173. ],
  174. pager: '#pager',
  175. rowNum:10,
  176. rowList:[5,10,20],
  177. sortname: 'id',
  178. sortorder: 'desc',
  179. viewrecords: true,
  180. gridview: true,
  181. ignoreCase:true,
  182. rownumbers:true,
  183. height:'auto',
  184. width:680,
  185. caption: 'Invoices',
  186. onSelectRow: function (){
  187. $( "#dialog-form" ).dialog("open");
  188. },
  189. jsonReader : {
  190. root:"quotedata",
  191. page: "page",
  192. total: "total",
  193. records: "records",
  194. cell: "dprow",
  195. id: "id"
  196. },
  197. subGrid:true,
  198. subGridRowExpanded: function(subgrid_id, row_id) {
  199. // we pass two parameters
  200. // subgrid_id is a id of the div tag created whitin a table data
  201. // the id of this elemenet is a combination of the "sg_" + id of the row
  202. // the row_id is the id of the row
  203. // If we wan to pass additinal parameters to the url we can use
  204. // a method getRowData(row_id) - which returns associative array in type name-value
  205. // here we can easy construct the flowing
  206. var subgrid_table_id, pager_id;
  207. subgrid_table_id = subgrid_id+"_t";
  208. pager_id = "p_"+subgrid_table_id;
  209. $("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
  210. jQuery("#"+subgrid_table_id).jqGrid({
  211. url:'index.php/procurement/populateInvoiceItems?invoiceId='+row_id,
  212. datatype: 'json',
  213. colNames:['Product Id','Product','Invoiced Quantity','Invoiced Value'/*,'Owner','Status','Order Id','Order Ref','Quote Ref','Owner','Needed By Date'*/],
  214. colModel :[
  215. // {name:'reference', index:'reference', width:80, align:'right',editable:false},
  216. {name:'product_id', index:'product_id',editable:false,align:'right',hidden:true},
  217. {name:'name', index:'name', width:140, align:'right',editable:false},
  218. // {name:'estimated_value', index:'estimated_value', width:100, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
  219. // {name:'owner', index:'owner', width:140, align:'right',editable:true,editoptions:{size:"20",maxlength:"30"}},
  220. {name:'invoiced_quantiy', index:'invoiced_quantiy', width:100, align:'right',editable:false,editoptions:{size:"20",maxlength:"30"}},
  221. {name:'total_invoiced_value', index:'total_invoiced_value',editable:false,align:'right'}
  222. ],
  223. rowNum:20,
  224. pager: pager_id,
  225. sortname: 'id',
  226. sortorder: "asc",
  227. height: '100%',
  228. jsonReader : {
  229. root:"invoiceitemdata",
  230. page: "page",
  231. total: "total",
  232. records: "records",
  233. cell: "dprow",
  234. id: "id"
  235. }
  236. });
  237. jQuery("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit:false,add:false,del:false,search:false,view:true});
  238. }
  239. }).navGrid("#pager",{edit:false,add:false,view:false,del:false,search:false},{height:280,reloadAfterSubmit:false,closeAfterEdit:true,recreateForm:true,checkOnSubmit:true},{},{},{},{});
  240. myGrid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch : "cn"});
  241. //$("#del_orders").insertAfter("#add_orders");
  242. $( "#dialog-form" ).dialog({
  243. autoOpen: false,
  244. height: 'auto',
  245. width: '55%',
  246. position:[300,25],
  247. modal: true,
  248. buttons: {
  249. Cancel: function() {
  250. $( this ).dialog( "close" );
  251. }
  252. },
  253. open: function(event,ui){
  254. var invoice_id = myGrid.getGridParam('selrow');
  255. var settingsObj ={grid_id:'payments',pager:'pagerPayments',multiselect:true};
  256. var postData={invoiceId: myGrid.getGridParam('selrow')};
  257. preparePaymentsGrid(settingsObj,postData);
  258. $("#payments").navGrid("#pagerPayments",{edit:false,add:false,del:false,search:false,view:true},{},{},{},{},{});
  259. var btns = {add:true,edit:true,adjust:true,data:{type:'general',invoice_id:invoice_id,order_id:myGrid.getCell(invoice_id,'order_id')}};
  260. addCustomButtonsInPaymentsGrid('payments','pagerPayments',null,btns);
  261. $("#payments").jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch : "cn"});
  262. console.log(invoice_id);
  263. $("#invoice").text(myGrid.getCell(invoice_id,'reference'));
  264. $("#total_value").text(myGrid.getCell(invoice_id,'total_value'));
  265. $("#order_ref").text(myGrid.getCell(invoice_id,'order_reference'));
  266. $("#amount_paid").text(myGrid.getCell(invoice_id,'amount_paid'));
  267. },
  268. close: function(event,ui) {
  269. $("#estValue").text("");
  270. $("#curPrice").text("");
  271. $("#status-message-li").empty();
  272. $("#payments").jqGrid("GridUnload");
  273. myGrid.trigger("reloadGrid");
  274. }
  275. });
  276. });
  277. $(window).load(function(){
  278. var warningDialogs={one:true,none:true,status:true};
  279. initDialogs(warningDialogs);
  280. initPaymentDialog();
  281. initErrorDialogs({total:true,advance:true});
  282. $("#advance_ref").change(function(){
  283. $.ajax({
  284. url:"index.php/procurement/getPaymentDetails",
  285. type:"POST",
  286. data:{pay_id:$(this).val()
  287. },
  288. success:function (response){
  289. var resObj = JSON.parse(response);
  290. $(".paymentCntnr,#advancePaymentAmountCntnr").show();
  291. $("#oper_payment").val("assign");
  292. $("#payment_id").val(resObj.id);
  293. $("#payment_ref").val(resObj.payment_reference);
  294. $("#payment_mode").val(resObj.payment_mode);
  295. $("#bankcomments").val(resObj.comments);
  296. //$("#amount").val($("#payments").getCell(pay_id,'amount'));
  297. $("#payment_ref").attr('readonly','readonly');
  298. $("#payment_mode").attr('readonly','readonly');
  299. $("#advance_value").text(resObj.amount);
  300. $("#adjusted_advance").text(resObj.invoiced_amount);
  301. },
  302. error:function (response){
  303. }
  304. });
  305. });
  306. });
  307. </script>
  308. </head>
  309. <body>
  310. <?php $this->load->view("common/menubar"); ?>
  311. <?php $this->load->view("common/dialogs"); ?>
  312. <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">
  313. <?php $this->load->view("common/message"); ?>
  314. <div class="table-grid">
  315. <h1 id="table header">Invoices To Pay</h1>
  316. <table id="orders"><tr><td/></tr></table>
  317. <div id="pager"></div>
  318. </div>
  319. </div>
  320. <div id ="dialog-form">
  321. <h1 id="formHeader">Add Payments For Invoice #: <span id="invoice" name ="invoice" ></span> </h1>
  322. <div id ="status-message-li" class="ui-corner-all">
  323. </div>
  324. <div class="row ">
  325. <div class="column ">
  326. <div class="field">
  327. <div class="labeldiv">Total Value:</div>
  328. <div class="valuediv" id="total_value" name ="total_value" ></div>
  329. </div>
  330. </div>
  331. <div class="column ">
  332. <div class="field">
  333. <div class="labeldiv">Amount Paid :</div>
  334. <div class="valuediv" name="amount_paid" id="amount_paid" ></div>
  335. </div>
  336. </div>
  337. <div class="column ">
  338. <div class="field">
  339. <div class="labeldiv">Order Reference:</div>
  340. <div class="valuediv" name="order_ref" id="order_ref" ></div>
  341. </div>
  342. </div>
  343. </div>
  344. <div id ="status-message-li" class="ui-corner-all">
  345. </div>
  346. <div class="table-grid">
  347. <h1 id="table_header_payment">Payment Details</h1>
  348. <table id="payments"><tr><td/></tr></table>
  349. <div id="pagerPayments"></div>
  350. </div>
  351. </div>
  352. <!-- <div id ="dialog-form-item">
  353. <h1 id="formHeader">Payment Details</h1>
  354. <form id="paymentForm">
  355. <fieldset>
  356. <div class="row single-column-row">
  357. <div class="column quote-column single-column">
  358. <div class="field">
  359. <div class="labeldiv">Total Value:</div>
  360. <div class="valuediv" id="total_value_form" name="total_value_form" ></div>
  361. </div>
  362. </div>
  363. </div>
  364. <div class="row single-column-row">
  365. <div class="column quote-column single-column">
  366. <div class="field">
  367. <div class="labeldiv">Amount Paid:</div>
  368. <div class="valuediv" id="amount_paid_form" name="amount_paid_form" ></div>
  369. </div>
  370. </div>
  371. </div>
  372. <div class="row single-column-row">
  373. <div class="column quote-column single-column">
  374. <div class="field">
  375. <label for="payment_mode" class="labeldiv">Payment Type:</label>
  376. <select id="payment_mode" name ="payment_mode" class="required">
  377. <option value="">Choose..</option>
  378. <option value="cash">Cash</option>
  379. <option value="cheque">Cheque</option>
  380. <option value="draft">Draft</option>
  381. <option value="online">Online</option>
  382. </select>
  383. </div>
  384. </div>
  385. </div>
  386. <div class="row single-column-row">
  387. <div class="column quote-column single-column">
  388. <div class="field">
  389. <label for="payment_ref" class="labeldiv">Payment Reference:</label>
  390. <input id="payment_ref" name="payment_ref" class="required"/>
  391. <div id ="receipt-help" class="ui-corner-all help-message">
  392. (Provide Cheque Number/Draft Number/Online Transaction Id)
  393. </div>
  394. </div>
  395. </div>
  396. </div>
  397. <div class="row single-column-row">
  398. <div class="column quote-column single-column">
  399. <div class="field">
  400. <label for="amount" class="labeldiv">Amount:</label>
  401. <input id="amount" name="amount" />
  402. </div>
  403. </div>
  404. </div>
  405. <div class="row single-column-row">
  406. <div class="column quote-column single-column">
  407. <div class="field">
  408. <label for="comments" class="labeldiv">Bank Details:</label>
  409. <textarea id="bankcomments" name="bankcomments" row="5" col="40"></textarea>
  410. <div id ="receipt-help" class="ui-corner-all help-message">
  411. (Provide Account # , Branch Etc:)
  412. </div>
  413. </div>
  414. </div>
  415. </div>
  416. <input id="oper" name="oper" type="hidden" value=""/>
  417. <input id="type" name="type" type="hidden" value=""/>
  418. <input id="payment_id" name="payment_id" type="hidden" value=""/>
  419. </fieldset>
  420. </form>
  421. </div>-->
  422. <?php $this->load->view("partial/footer"); ?>
  423. </body>
  424. </html>