1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.XtupleCreditMemos = new Roo.XComponent({
6 part : ["Xtuple","CreditMemos"],
7 order : '200-Pman.Tab.XtupleCreditMemos',
9 parent : 'Pman.Tab.XtupleSales',
10 name : "Pman.Tab.XtupleCreditMemos",
21 activate : function() {
24 _this.grid.footer.onClick('first');
33 title : "Credit Memos",
41 //_this.dialog = Pman.Dialog.FILL_IN
42 if (_this.panel.active) {
43 this.footer.onClick('first');
46 rowdblclick : function (_self, rowIndex, e)
48 var s = this.dataSource.getAt(rowIndex);
49 Pman.Dialog.XtupleCreditMemo.show({
50 cmhead_id : s.data.cmhead_id
52 _this.grid.footer.onClick('first');
55 /* if (!_this.dialog) return;
56 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
57 _this.grid.footer.onClick('first');
61 autoExpandColumn : 'cmhead_cust_id_cust_name',
67 beforeload : function (_self, o)
69 if ( _this.customer && _this.customer.getValue() ) {
70 o.params.cmhead_cust_id = _this.customer.getValue();
72 if (_this.cmnumber && _this.cmnumber.getValue() ) {
73 o.params.cmhead_id = _this.cmnumber.getValue();
76 o.params['query[status]'] = _this.status.getValue();
79 o.params._with_aropen = 1;
83 sortInfo : { field : 'cmhead_id', direction: 'DESC' },
88 url : baseURL + '/Roo/cmhead.php'
93 totalProperty : 'total',
102 'name': 'cmhead_number',
106 'name': 'cmhead_posted',
110 'name': 'cmhead_invcnumber',
114 'name': 'cmhead_custponumber',
118 'name': 'cmhead_cust_id',
122 'name': 'cmhead_docdate',
124 'dateFormat': 'Y-m-d'
127 'name': 'cmhead_shipto_id',
131 'name': 'cmhead_shipto_name',
135 'name': 'cmhead_shipto_address1',
139 'name': 'cmhead_shipto_address2',
143 'name': 'cmhead_shipto_address3',
147 'name': 'cmhead_shipto_city',
151 'name': 'cmhead_shipto_state',
155 'name': 'cmhead_shipto_zipcode',
159 'name': 'cmhead_salesrep_id',
163 'name': 'cmhead_freight',
167 'name': 'cmhead_misc',
171 'name': 'cmhead_comments',
175 'name': 'cmhead_printed',
179 'name': 'cmhead_billtoname',
183 'name': 'cmhead_billtoaddress1',
187 'name': 'cmhead_billtoaddress2',
191 'name': 'cmhead_billtoaddress3',
195 'name': 'cmhead_billtocity',
199 'name': 'cmhead_billtostate',
203 'name': 'cmhead_billtozip',
207 'name': 'cmhead_hold',
211 'name': 'cmhead_commission',
215 'name': 'cmhead_misc_accnt_id',
219 'name': 'cmhead_misc_descrip',
223 'name': 'cmhead_rsncode_id',
227 'name': 'cmhead_curr_id',
231 'name': 'cmhead_freighttaxtype_id',
235 'name': 'cmhead_gldistdate',
237 'dateFormat': 'Y-m-d'
240 'name': 'cmhead_billtocountry',
244 'name': 'cmhead_shipto_country',
248 'name': 'cmhead_rahead_id',
252 'name': 'cmhead_taxzone_id',
256 'name': 'cmhead_prj_id',
263 xtype: 'PagingToolbar',
267 displayMsg : "Displaying cmhead{0} - {1} of {2}",
268 emptyMsg : "No cmhead found",
274 click : function (_self, e)
279 Roo.MessageBox.alert("Notice", "Report is downloading");
294 render : function (_self)
296 _this.cmnumber = _self;
298 select : function (combo, record, index)
301 _this.grid.footer.onClick('first');
305 displayField : 'cmhead_number',
308 fieldLabel : 'ordernumber',
309 forceSelection : true,
310 hiddenName : 'cmhead_id',
312 loadingText : "Searching...",
314 name : 'cmhead_number',
316 qtip : "Select invchead",
317 queryParam : 'query[cmhead_number]',
318 selectOnFocus : true,
319 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cmhead_number}</b> </div>',
320 triggerAction : 'all',
322 valueField : 'cmhead_id',
328 beforeload : function (_self, o){
329 o.params = o.params || {};
334 sortInfo : { direction : 'ASC', field: 'cmhead_number' },
339 url : baseURL + '/Roo/cmhead.php'
346 totalProperty : 'total',
347 fields : [{"name":"cmhead_id","type":"int"},"cmhead_number"]
355 render : function (_self)
357 _this.customer = _self;
359 select : function (combo, record, index)
361 _this.grid.footer.onClick('first');
365 displayField : 'cust_name',
367 emptyText : "Select Customer",
368 fieldLabel : 'cust_name',
369 forceSelection : true,
370 hiddenName : 'cust_id',
372 loadingText : "Searching...",
376 qtip : "Select custinfo",
377 queryParam : 'query[cust_name]',
378 selectOnFocus : true,
379 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> </div>',
380 triggerAction : 'all',
382 valueField : 'cust_id',
387 sortInfo : { direction : 'ASC', field: 'cust_name' },
390 beforeload : function (_self, o){
391 o.params = o.params || {};
399 url : baseURL + '/Roo/custinfo.php'
406 totalProperty : 'total',
407 fields : [{"name":"cust_id","type":"int"},"cust_name"]
415 render : function (_self)
417 _this.status = _self;
419 select : function (combo, record, index)
422 _this.grid.footer.onClick('first');
426 displayField : 'fname',
428 fieldLabel : 'Status',
429 hiddenName : 'cm_status',
432 name : 'cm_status_name',
433 triggerAction : 'all',
435 valueField : 'ftype',
438 xtype: 'SimpleStore',
441 [ 'NOTCLOSED', "Not Closed"],
442 [ 'CLOSED' , "Closed"],
443 [ 'UNPOSTED', "Unposted only"] ,
444 [ 'UNUSED', "Posted and not used"] ,
445 [ 'VOIDED', "Voided"],
446 [ 'NOTVOIDED', "Not Voided"]
448 fields : [ 'ftype', 'fname']
458 cls : 'x-btn-text-icon',
460 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
469 click : function (_self, e)
471 Pman.Dialog.XtupleCreditMemoNew.show( {} , function() {
472 _this.grid.footer.onClick('first');
477 cls : 'x-btn-text-icon',
478 text : "New Credit Memo",
479 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
489 click : function (_self, e)
491 var s = _this.grid.getSelectionModel().getSelections();
493 if (!s.length || (s.length > 1)) {
494 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
497 if(s[0].data.checkhead_total == 0){
498 Roo.MessageBox.alert("Error", "you cannot create the miscellaneous check for the credit memo coz the total amount remaining is 0! ");
501 if(!s[0].data.cmhead_posted){
502 Roo.MessageBox.alert("Error", "This credit memo has not been posted!");
506 'checkhead_recip_id' : s[0].data.cmhead_cust_id,
507 'checkhead_recip_type' : 'C',
508 'checkhead_checkdate' : new Date(),
509 'checkhead_amount' : s[0].data.checkhead_total,
510 'remaining_total' : s[0].data.checkhead_total,
511 'checkhead_curr_id' : s[0].data.cmhead_curr_id,
512 'checkhead_curr_id_curr_name' : s[0].data.cmhead_curr_id_curr_name,
513 'checkhead_misc' : true,
514 'aropen_id' : s[0].data.cmhead_aropen_id_aropen_id,
515 'cmhead_number' : s[0].data.cmhead_number,
516 'cust_name' : s[0].data.cmhead_cust_id_cust_name,
517 '_create_and_post' : 1
522 Pman.Dialog.XtupleMiscellaneousCheck.show( data , function() {
523 _this.grid.footer.onClick('first');
528 cls : 'x-btn-text-icon',
529 text : "New Miscellaneous Check",
530 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
545 var s = _this.grid.getSelectionModel().getSelections();
547 if (!s.length || (s.length > 1)) {
548 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
552 var postit = function()
556 url : baseURL + '/Roo/Cmhead',
560 cmhead_id : s[0].data.cmhead_id,
565 _this.grid.footer.onClick('refresh');
572 Roo.MessageBox.confirm(
574 "Are you sure to void this credit memo?",
585 cls : 'x-btn-text-icon',
586 text : "Void Credit Memo",
587 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
599 var s = _this.grid.getSelectionModel().getSelections();
601 if (!s.length || (s.length > 1)) {
602 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
605 if (s[0].data.cmhead_posted ) {
606 Roo.MessageBox.alert("Error",
607 "You can not delete posted credit memo's - you have to create an invoice to reverse them");
613 var postit = function()
617 url : baseURL + '/Roo/Cmhead',
621 _delete : s[0].data.cmhead_id
625 _this.grid.footer.onClick('refresh');
632 Roo.MessageBox.confirm(
634 "You will have to make sure this credit memo has no line items associated before deleting it. ",
645 cls : 'x-btn-text-icon',
646 text : "Delete Credit Memo",
647 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
659 var s = _this.grid.getSelectionModel().getSelections();
661 if (!s.length || (s.length > 1)) {
662 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
666 var postit = function()
670 url : baseURL + '/Roo/Cmhead',
674 cmhead_id : s[0].data.cmhead_id,
679 _this.grid.footer.onClick('refresh');
686 Roo.MessageBox.confirm(
688 "Are you sure that is complete, <B>Voiding a Credit memo invoices creating a sales order and invoice</B>, so make sure this is correct before posting",
699 cls : 'x-btn-text-icon',
701 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
713 var s = _this.grid.getSelectionModel().getSelected();
714 if (!s || !s.data.cmhead_id) {
715 Roo.MessageBox.alert("Error", "Select a credit memo");
719 var ext = baseURL.split('/').pop().replace(/\.php/, '');
721 url : baseURL + '/Xtuple/Print',
723 template: 'creditmemo-' + ext,
724 filename : 'creditmemo-' + s.data.cmhead_id,
725 'param[0]': "cmhead_id:string='" + s.data.cmhead_id + "'"
730 Roo.MessageBox.alert("Notice", "Report will download shortly");
736 cls : 'x-btn-text-icon',
738 icon : rootURL + '/Pman/templates/images/pdf.gif'
747 cls : 'x-btn-text-icon',
749 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
762 click : function (_self, e)
764 Roo.MessageBox.confirm(
766 "It is going to fill in all the blank return stock. Are you sure?",
773 url : baseURL + '/Roo/Cmhead',
781 Roo.MessageBox.alert('Notice','Fixed');
782 _this.grid.footer.onClick('refresh');
789 cls : 'x-btn-text-icon',
790 text : "Fix Blank Return Stock",
791 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
800 xtype: 'ColumnModel',
802 dataIndex : 'cmhead_number',
806 renderer : function(v) { return String.format('{0}', v); }
809 xtype: 'ColumnModel',
811 dataIndex : 'cmhead_docdate',
815 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
818 xtype: 'ColumnModel',
820 dataIndex : 'cmhead_salesrep_id_salesrep_name',
821 header : 'Sales Rep',
824 renderer : function(v) { return String.format('{0}', v ); }
827 xtype: 'ColumnModel',
829 dataIndex : 'cmhead_salesrep_id_salesrep_name',
830 header : 'Cust. Sales Rep',
833 renderer : function(v) { return String.format('{0}', v ); }
836 xtype: 'ColumnModel',
838 dataIndex : 'cmhead_cust_id_cust_name',
841 renderer : function(v) { return String.format('{0}', v); }
844 xtype: 'ColumnModel',
847 dataIndex : 'cmhead_curr_id_curr_symbol',
850 renderer : function(v)
852 return String.format('{0}', v ? v : '??');
856 xtype: 'ColumnModel',
859 dataIndex : 'cmhead_value',
862 renderer : function(v)
864 return Roo.util.Format.usMoney(v);
868 xtype: 'ColumnModel',
871 dataIndex : 'cmhead_unpaid',
872 header : 'Open Value',
874 renderer : function(v,x,r)
876 if (!r.data.cmhead_posted) {
879 return Roo.util.Format.usMoney(v);
883 xtype: 'ColumnModel',
885 dataIndex : 'cmhead_posted',
888 renderer : function(v) { return String.format('{0}', v ? 'Yes':''); }