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