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"],
447 [ 'ALL', "Show All"],
449 fields : [ 'ftype', 'fname']
459 cls : 'x-btn-text-icon',
461 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
470 click : function (_self, e)
472 Pman.Dialog.XtupleCreditMemoNew.show( {} , function() {
473 _this.grid.footer.onClick('first');
478 cls : 'x-btn-text-icon',
479 text : "New Credit Memo",
480 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
490 click : function (_self, e)
492 var s = _this.grid.getSelectionModel().getSelections();
494 if (!s.length || (s.length > 1)) {
495 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
498 if(s[0].data.checkhead_total == 0){
499 Roo.MessageBox.alert("Error", "you cannot create the miscellaneous check for the credit memo coz the total amount remaining is 0! ");
502 if(!s[0].data.cmhead_posted){
503 Roo.MessageBox.alert("Error", "This credit memo has not been posted!");
507 'checkhead_recip_id' : s[0].data.cmhead_cust_id,
508 'checkhead_recip_type' : 'C',
509 'checkhead_checkdate' : new Date(),
510 'checkhead_amount' : s[0].data.checkhead_total,
511 'remaining_total' : s[0].data.checkhead_total,
512 'checkhead_curr_id' : s[0].data.cmhead_curr_id,
513 'checkhead_curr_id_curr_name' : s[0].data.cmhead_curr_id_curr_name,
514 'checkhead_misc' : true,
515 'aropen_id' : s[0].data.cmhead_aropen_id_aropen_id,
516 'cmhead_number' : s[0].data.cmhead_number,
517 'cust_name' : s[0].data.cmhead_cust_id_cust_name,
518 '_create_and_post' : 1
523 Pman.Dialog.XtupleMiscellaneousCheck.show( data , function() {
524 _this.grid.footer.onClick('first');
529 cls : 'x-btn-text-icon',
530 text : "New Miscellaneous Check",
531 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
546 var s = _this.grid.getSelectionModel().getSelections();
548 if (!s.length || (s.length > 1)) {
549 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
553 var postit = function()
557 url : baseURL + '/Roo/Cmhead',
561 cmhead_id : s[0].data.cmhead_id,
566 _this.grid.footer.onClick('refresh');
573 Roo.MessageBox.confirm(
575 "Are you sure to void this credit memo?",
586 cls : 'x-btn-text-icon',
587 text : "Void Credit Memo",
588 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
600 var s = _this.grid.getSelectionModel().getSelections();
602 if (!s.length || (s.length > 1)) {
603 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
606 if (s[0].data.cmhead_posted ) {
607 Roo.MessageBox.alert("Error",
608 "You can not delete posted credit memo's - you have to create an invoice to reverse them");
614 var postit = function()
618 url : baseURL + '/Roo/Cmhead',
622 _delete : s[0].data.cmhead_id
626 _this.grid.footer.onClick('refresh');
633 Roo.MessageBox.confirm(
635 "You will have to make sure this credit memo has no line items associated before deleting it. ",
646 cls : 'x-btn-text-icon',
647 text : "Delete Credit Memo",
648 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
660 var s = _this.grid.getSelectionModel().getSelections();
662 if (!s.length || (s.length > 1)) {
663 Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
667 var postit = function()
671 url : baseURL + '/Roo/Cmhead',
675 cmhead_id : s[0].data.cmhead_id,
680 _this.grid.footer.onClick('refresh');
687 Roo.MessageBox.confirm(
689 "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",
700 cls : 'x-btn-text-icon',
702 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
714 var s = _this.grid.getSelectionModel().getSelected();
715 if (!s || !s.data.cmhead_id) {
716 Roo.MessageBox.alert("Error", "Select a credit memo");
720 var ext = baseURL.split('/').pop().replace(/\.php/, '');
722 url : baseURL + '/Xtuple/Print',
724 template: 'creditmemo-' + ext,
725 filename : 'creditmemo-' + s.data.cmhead_id,
726 'param[0]': "cmhead_id:string='" + s.data.cmhead_id + "'"
731 Roo.MessageBox.alert("Notice", "Report will download shortly");
737 cls : 'x-btn-text-icon',
739 icon : rootURL + '/Pman/templates/images/pdf.gif'
748 cls : 'x-btn-text-icon',
750 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
763 click : function (_self, e)
765 Roo.MessageBox.confirm(
767 "It is going to fill in all the blank return stock. Are you sure?",
774 url : baseURL + '/Roo/Cmhead',
782 Roo.MessageBox.alert('Notice','Fixed');
783 _this.grid.footer.onClick('refresh');
790 cls : 'x-btn-text-icon',
791 text : "Fix Blank Return Stock",
792 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
801 xtype: 'ColumnModel',
803 dataIndex : 'cmhead_number',
807 renderer : function(v) { return String.format('{0}', v); }
810 xtype: 'ColumnModel',
812 dataIndex : 'cmhead_docdate',
816 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
819 xtype: 'ColumnModel',
821 dataIndex : 'cmhead_salesrep_id_salesrep_name',
822 header : 'Sales Rep',
825 renderer : function(v) { return String.format('{0}', v ); }
828 xtype: 'ColumnModel',
830 dataIndex : 'cust_salesrep_salesrep_name',
831 header : 'Cust. Sales Rep',
834 renderer : function(v) { return String.format('{0}', v ); }
837 xtype: 'ColumnModel',
839 dataIndex : 'cmhead_cust_id_cust_name',
842 renderer : function(v) { return String.format('{0}', v); }
845 xtype: 'ColumnModel',
848 dataIndex : 'cmhead_curr_id_curr_symbol',
851 renderer : function(v)
853 return String.format('{0}', v ? v : '??');
857 xtype: 'ColumnModel',
860 dataIndex : 'cmhead_value',
863 renderer : function(v)
865 return Roo.util.Format.usMoney(v);
869 xtype: 'ColumnModel',
872 dataIndex : 'cmhead_unpaid',
873 header : 'Open Value',
875 renderer : function(v,x,r)
877 if (!r.data.cmhead_posted) {
880 return Roo.util.Format.usMoney(v);
884 xtype: 'ColumnModel',
886 dataIndex : 'cmhead_posted',
889 renderer : function(v) { return String.format('{0}', v ? 'Yes':''); }