1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Dialog.XtupleSalesOrder = {
10 show : function(data, cb)
18 this.dialog.show(this.data._el);
21 this.form.setValues(data);
22 this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });
30 this.dialog = Roo.factory({
31 xtype: 'LayoutDialog',
35 this.layout.getRegion('center').showPanel(0);
43 title : "Edit / Create Sales Order",
47 xtype: 'ContentPanel',
50 activate : function (_self)
52 // we need to reload to find out the subtotal.
53 if (!_this.data || !_this.data.cohead_id) {
58 url : baseURL + '/Roo/cohead',
60 _id : _this.data.cohead_id
62 success : function(res) {
63 _this.form.findField('cohead_subtotal').setValue(res.data.cohead_subtotal);
64 _this.form.findField('cohead_tax').setValue(res.data.cohead_tax);
65 _this.form.findField('cohead_uninvoiced').setValue(res.data.cohead_uninvoiced);
66 _this.form.findField('cohead_unshipped').setValue(res.data.cohead_unshipped);
67 _this.form.findField('cohead_pretax_discount').setValue(res.data.cohead_pretax_discount);
68 _this.form.findField('cohead_total').recalc();
69 _this.form.findField('cohead_misc').recalc();
75 title : "Order Details",
81 actioncomplete : function(_self,action)
83 if (action.type == 'setdata') {
84 // clear the stock level cache...
85 _this.stockcache = [];
87 _this.form.findField('billto_email').setValue('');
89 if (_this.data.cohead_id) {
90 this.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
94 _this.dialog.setTitle("Edit New Sales Order");
96 _this.closeBtn.hide();
100 if(_this.data.cohead_billto_cntct_id_cntct_id){
101 _this.form.findField('billto_address').update();
103 _this.form.setValues({
\r
104 cohead_billto_cntct_id: _this.data.cohead_billto_cntct_id_cntct_id,
\r
105 cohead_billto_cntct_id_cntct_name : _this.data.cohead_billto_cntct_id_cntct_name,
\r
114 if (action.type == 'load') {
117 _this.data = action.result.data;
119 if (!_this.data.cohead_shipto_id && _this.data.shipto_id*1 > 0) {
120 _this.form.findField('cohead_shipto_id').setValue(_this.data.shipto_id);
121 _this.form.findField('cohead_shipto_id_shipto_name').setValue(_this.data.cohead_shipto_cntct_id_cntct_name);
126 _this.dataloading = true;
127 if (_this.data.cohead_shipto_cntct_id == _this.data.cohead_billto_cntct_id) {
128 this.findField('_shipto_same').setValue(1);
129 Roo.log("set shipto 1");
131 this.findField('_shipto_same').setValue(0);
132 Roo.log("set shipto 0");
134 _this.dataloading = false;
137 this.findField('billto_address').update();
138 this.findField('shipto_address').update();
139 _this.dialog.setTitle("Edit Sales Order - " + this.findField('cohead_number').getValue());
142 if (_this.data.cohead_status == 'C') {
143 _this.closeBtn.show();
144 _this.closeBtn.setText('Re-open');
145 _this.voidBtn.hide();
146 _this.saveBtn.hide();
147 } else if (_this.data.cohead_status == 'X') {
148 _this.closeBtn.hide();
149 _this.voidBtn.show();
150 _this.voidBtn.setText("Un-void / Re-open");
151 _this.saveBtn.hide();
154 _this.closeBtn.show();
155 _this.closeBtn.setText('Complete and Close');
156 _this.voidBtn.setText("Void");
157 _this.voidBtn.show();
158 _this.saveBtn.show();
161 _this.form.findField('cohead_misc_per').update();
163 // finally override the value for discount...
164 if ((''+ _this.data.cohead_misc_descrip).length) {
165 _this.form.findField('cohead_misc_descrip').setValue(_this.data.cohead_misc_descrip);
168 // update the stockcache...
171 url : baseURL + '/Roo/cohead',
174 _stockLevel : _this.data.cohead_id
176 success : function(res)
178 for (var i in res.data) {
180 if(typeof(_this.stockcache[res.data[i].item]) == 'undefined'){
181 _this.stockcache[res.data[i].item] = res.data[i];
189 if (action.type =='submit') {
192 var id = _this.form.findField('cohead_id').getValue() * 1;
195 _this.data.cohead_id = action.result.data.cohead_id;
196 this.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
202 if (_this.callback) {
203 _this.callback.call(_this, _this.form.getValues());
209 rendered : function (form)
213 actionfailed : function (_self, action)
215 if (action.failureType == 'client') {
216 Roo.MessageBox.alert("Error", "Fill in all the required fields");
218 if (action.failureType == 'server') {
220 Roo.MessageBox.alert("Error", action.result.errorMsg);
222 _this.dialog.layout.getRegion('center').showPanel(0);
226 style : 'margin:10px;',
227 url : baseURL + '/Roo/cohead.php',
239 style : 'width:420px',
257 emptyText : "Automatic",
258 fieldLabel : 'Order#',
259 name : 'cohead_number',
267 style : 'float:left',
274 fieldLabel : 'Cust#',
275 name : 'cohead_cust_id_cust_number',
287 fieldLabel : 'Customer',
288 forceSelection : true,
289 hiddenName : 'cohead_cust_id',
291 loadingText : "Searching...",
293 name : 'cohead_cust_id_cust_name',
295 qtip : "Select custinfo",
296 queryParam : 'query[cust_name]',
298 selectOnFocus : true,
299 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> </div>',
300 triggerAction : 'all',
302 valueField : 'cust_id',
308 fieldLabel : 'Customer PO#',
309 name : 'cohead_custponumber',
316 fieldLabel : 'Ordered',
318 name : 'cohead_orderdate',
331 fieldLabel : 'Target Delivery',
333 name : 'cohead_targetdate',
345 check : function (_self, checked)
348 _this.form.findField('cohead_targetdate').setValue(_this.form.findField('cohead_orderdate').getValue());
352 boxLabel : 'same as order',
354 name : '_same_as_order'
364 displayField : 'location_name',
366 emptyText : "Supply From",
367 fieldLabel : 'Supply From',
368 forceSelection : true,
369 hiddenName : 'cohead_location_src',
371 loadingText : "Searching...",
373 name : 'cohead_location_src_location_name',
375 qtip : "Select terms",
376 queryParam : 'query[location_name]',
377 selectOnFocus : true,
378 tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> {location_descrip} </div>',
379 triggerAction : 'all',
381 valueField : 'location_id',
387 beforeload : function (_self, o){
388 o.params = o.params || {};
390 o.params.location_netable = 1;
391 o.params.location_restrict = 0;
392 o.params._notinternalcompany = 1;
396 sortInfo : { direction : 'ASC', field: 'location_name' },
401 url : baseURL + '/Roo/location.php'
408 totalProperty : 'total',
409 fields : [{"name":"location_id","type":"int"},"location_name"]
422 style : 'width:420px',
435 emptyText : "Select terms",
436 forceSelection : true,
438 loadingText : "Searching...",
441 qtip : "Select terms",
442 selectOnFocus : true,
443 triggerAction : 'all',
446 tpl : '<div class="x-grid-cell-text x-btn button"><b>{terms_descrip}</b> </div>',
447 queryParam : 'query[terms_descrip]',
448 fieldLabel : 'Terms',
449 valueField : 'terms_id',
450 displayField : 'terms_descrip',
451 hiddenName : 'cohead_terms_id',
452 name : 'cohead_terms_id_terms_descrip',
457 beforeload : function (_self, o){
458 o.params = o.params || {};
463 sortInfo : { direction : 'ASC', field: 'terms_descrip' },
468 url : baseURL + '/Roo/terms.php'
475 totalProperty : 'total',
476 fields : [{"name":"terms_id","type":"int"},"terms_descrip"]
485 displayField : 'salesrep_name',
487 emptyText : "Select salesrep",
488 fieldLabel : 'Sales Rep',
489 forceSelection : true,
490 hiddenName : 'cohead_display_salesrep_id',
492 loadingText : "Searching...",
494 name : 'cohead_display_salesrep_id_salesrep_name',
496 qtip : "Select salesrep",
497 queryParam : 'query[salesrep_name]',
498 selectOnFocus : true,
499 tpl : '<div class="x-grid-cell-text x-btn button"><b>{salesrep_name}</b> </div>',
500 triggerAction : 'all',
502 valueField : 'salesrep_id',
508 beforeload : function (_self, o){
509 o.params = o.params || {};
514 sortInfo : { direction : 'ASC', field: 'salesrep_name' },
519 url : baseURL + '/Roo/salesrep.php'
526 totalProperty : 'total',
527 fields : [{"name":"salesrep_id","type":"int"},"salesrep_name"]
536 displayField : 'salesrep_name',
538 emptyText : "Select Staff",
539 fieldLabel : 'Staff I.C.',
540 forceSelection : true,
541 hiddenName : 'cohead_salesrep_id',
543 loadingText : "Searching...",
545 name : 'cohead_salesrep_id_salesrep_name',
547 qtip : "Select salesrep",
548 queryParam : 'query[salesrep_name]',
549 selectOnFocus : true,
550 tpl : '<div class="x-grid-cell-text x-btn button"><b>{salesrep_name}</b> </div>',
551 triggerAction : 'all',
553 valueField : 'salesrep_id',
559 beforeload : function (_self, o){
560 o.params = o.params || {};
565 sortInfo : { direction : 'ASC', field: 'salesrep_name' },
570 url : baseURL + '/Roo/salesrep.php'
577 totalProperty : 'total',
578 fields : [{"name":"salesrep_id","type":"int"},"salesrep_name"]
585 fieldLabel : 'Order Comments',
587 name : 'cohead_ordercomments',
597 style : 'width:420px',
610 beforeselect : function (combo, record, index)
612 // set _this.data values ..
614 // just add everything...
615 for(var i in record.data) {
616 _this.data['cohead_billto_cntct_id_' + i] = record.data[i];
619 _this.form.findField('billto_address').update();
624 add : function (combo)
627 Pman.Dialog.XtupleQuickContact.show(
630 customer_id : _this.form.findField('cohead_cust_id').getValue()
637 _this.data['cohead_billto_cntct_id_' + i] = data[i];
640 _this.form.findField('billto_address').update();
641 // fill in the select box..
642 _this.form.setValues( {
643 cohead_billto_cntct_id : data.cntct_id,
644 cohead_billto_cntct_id_cntct_name : data.cntct_first_name + ' '+
650 // Pman.Dialog.XtupleCustomer.show(
651 //{ cust_id : _this.form.findField('cohead_cust_id').getValue() },
653 // refresh the data in the pulldown..
660 displayField : 'cntct_name',
662 emptyText : "Select cntct",
663 fieldLabel : 'Bill To (select)',
664 forceSelection : true,
665 hiddenName : 'cohead_billto_cntct_id',
667 loadingText : "Searching...",
669 name : 'cohead_billto_cntct_id_cntct_name',
671 qtip : "Select cntct",
672 queryParam : 'query[cntct_name]',
673 selectOnFocus : true,
674 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cntct_name}</b> {cntct_addr_id_addr_line1}</div>',
675 triggerAction : 'all',
677 valueField : 'cntct_id',
683 beforeload : function (_self, o){
684 o.params = o.params || {};
686 o.params._customer_id = _this.data.cohead_cust_id;
690 sortInfo : { direction : 'ASC', field: 'cntct_name' },
695 url : baseURL + '/Roo/cntct.php'
702 totalProperty : 'total',
703 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
711 render : function (_self)
717 this.el.on('click', function() {
718 var id = _this.form.findField('cohead_billto_cntct_id').getValue();
719 Pman.Dialog.XtupleQuickContact.show(
722 customer_id : _this.form.findField('cohead_cust_id').getValue()
729 _this.data['cohead_billto_cntct_id_' + i] = data[i];
732 _this.form.findField('billto_address').update();
733 // fill in the select box..
734 _this.form.setValues( {
735 cohead_billto_cntct_id : data.cntct_id,
736 cohead_billto_cntct_id_cntct_name : data.cntct_first_name + ' '+
746 Roo.log("Click text");
752 fieldLabel : 'or enter Address',
753 name : 'billto_address',
755 update : function() {
757 var c = ['first_name', 'last_name' ] ;
758 var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];
760 Roo.each(c, function(e) {
761 if (_this.data['cohead_billto_cntct_id_cntct_' +e].length) {
762 v.push(_this.data['cohead_billto_cntct_id_cntct_' +e]);
765 Roo.each(a, function(e) {
766 if (_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e].length) {
767 v.push(_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e]);
771 this.setValue(v.join("\n"));
773 if(_this.data.cohead_billto_cntct_id_cntct_email.length){
774 _this.form.findField('billto_email').setValue(_this.data.cohead_billto_cntct_id_cntct_email);
779 xtype: 'DisplayField',
781 fieldLabel : 'Email',
782 name : 'billto_email',
783 valueRenderer : function(v)
798 style : 'margin-left:10px',
803 legend : "Price Details",
804 style : 'width:420px',
810 labelAlign : 'right',
818 labelSeparator : ' ',
825 beforequery : function (combo, query, forceAll, cancel, e)
827 Roo.log('beforequery');
829 if (_this.form.findField('cohead_number').getValue().length) {
830 Roo.MessageBox.alert("Error", "You can not change the currency of this order");
839 displayField : 'curr_name',
841 emptyText : "Select curr_name",
842 fieldLabel : 'Currency',
843 forceSelection : true,
844 hiddenName : 'cohead_curr_id',
846 loadingText : "Searching...",
848 name : 'cohead_curr_id_curr_name',
850 qtip : "Select Currency",
851 queryParam : 'query[curr_name]',
852 selectOnFocus : true,
853 tpl : '<div class="x-grid-cell-text x-btn button"><b>{curr_name}</b> </div>',
854 triggerAction : 'all',
856 valueField : 'curr_id',
862 beforeload : function (_self, o){
863 o.params = o.params || {};
869 sortInfo : { direction : 'ASC', field: 'curr_symbol' },
874 url : baseURL + '/Roo/curr_symbol.php'
881 totalProperty : 'total',
882 fields : [{"name":"curr_id","type":"int"},"curr_symbol"]
887 xtype: 'NumberField',
889 allowDecimals : true,
890 cls : 'roo-align-right',
891 decimalPrecision : 3,
892 fieldLabel : 'Products',
893 name : 'cohead_subtotal',
903 labelSeparator : ' ',
910 select : function (combo, record, index)
912 _this.form.findField('cohead_tax').setValue(
913 parseFloat(record.data.taxzone_rate) *
914 parseFloat(_this.form.findField('cohead_subtotal').getValue())
916 _this.form.findField('cohead_total').recalc();
920 displayField : 'taxzone_descrip',
922 emptyText : "Select taxtype",
923 fieldLabel : 'Tax Zone',
924 forceSelection : true,
925 hiddenName : 'cohead_taxzone_id',
927 loadingText : "Searching...",
929 name : 'cohead_taxzone_id_taxzone_descrip',
931 qtip : "Select taxtype",
932 queryParam : 'query[taxzone_descrip]',
933 selectOnFocus : true,
934 tpl : '<div class="x-grid-cell-text x-btn button"><b>{taxzone_descrip}</b> </div>',
935 triggerAction : 'all',
937 valueField : 'taxzone_id',
943 beforeload : function (_self, o){
944 o.params = o.params || {};
947 o.params.with_date = _this.form.findField('cohead_orderdate').getValue().format('Y-m-d');
948 Roo.log("with date?" + o.params.with_date);
954 sortInfo : { direction : 'ASC', field: 'taxzone_descrip' },
959 url : baseURL + '/Roo/taxzone.php'
966 totalProperty : 'total',
967 fields : [{"name":"taxzone_id","type":"int"},"taxzone_descrip"]
972 xtype: 'NumberField',
974 allowDecimals : true,
975 cls : 'roo-align-right',
976 decimalPrecision : 3,
985 xtype: 'NumberField',
987 allowDecimals : true,
988 cls : 'roo-align-right',
989 decimalPrecision : 3,
990 fieldLabel : 'Pre Tax discount',
991 name : 'cohead_pretax_discount',
999 labelSeparator : ' ',
1005 fieldLabel : 'Discount after Tax Description',
1006 name : 'cohead_misc_descrip',
1010 xtype: 'NumberField',
1013 keyup : function (_self, e)
1015 var pv = parseFloat(_this.form.findField('cohead_subtotal').getValue());
1016 var tax = parseFloat(_this.form.findField('cohead_tax').getValue());
1017 var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());
1019 var n = this.getValue();
1020 var discount = parseFloat(n * (pv + tax + pd) * 0.01);
1022 _this.form.findField('cohead_posttax_discount').setValue(discount);
1024 _this.form.findField('cohead_total').recalc();
1025 _this.form.findField('cohead_misc').recalc();
1026 var val = discount * -1.0;
1028 _this.form.findField('cohead_misc_descrip').setValue("Discount of " + val.toFixed(1)+'%');
1034 allowDecimals : true,
1035 cls : 'roo-align-right',
1036 decimalPrecision : 1,
1038 name : 'cohead_misc_per',
1040 update : function() {
1041 var m = _this.form.findField('cohead_misc_per');
1042 var pv = parseFloat(_this.form.findField('cohead_subtotal').getValue());
1043 var tax = parseFloat(_this.form.findField('cohead_tax').getValue());
1044 var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());
1046 var discount = parseFloat(_this.form.findField('cohead_posttax_discount').getValue());
1048 if (discount > 0.0) {
1056 var val = ((discount) / (pv + tax + pd)) * -100;
1058 //Roo.log("update discount?" + val);
1059 this.setValue(val.toFixed(1));
1062 _this.form.findField('cohead_misc_descrip').setValue("Discount of " + val.toFixed(1)+'%');
1070 xtype: 'NumberField',
1073 keyup : function (_self, e)
1075 _this.form.findField('cohead_misc_per').update();
1076 _this.form.findField('cohead_total').recalc();
1077 _this.form.findField('cohead_misc').recalc();
1080 allowDecimals : true,
1081 cls : 'roo-align-right',
1082 decimalPrecision : 3,
1083 fieldLabel : ' ',
1084 name : 'cohead_posttax_discount',
1090 xtype: 'NumberField',
1092 allowDecimals : true,
1093 cls : 'roo-align-right',
1094 decimalPrecision : 3,
1095 fieldLabel : 'Total',
1096 name : 'cohead_total',
1099 recalc : function() {
1100 var d = _this.form.getValues();
1102 parseFloat(d.cohead_subtotal) +
1103 parseFloat(d.cohead_pretax_discount) +
1104 parseFloat(d.cohead_posttax_discount) +
1105 parseFloat(d.cohead_tax) +
1106 parseFloat(d.cohead_freight));
1110 xtype: 'NumberField',
1113 keyup : function (_self, e)
1115 _this.form.findField('cohead_total').recalc();
1118 allowDecimals : true,
1119 cls : 'roo-align-right',
1120 decimalPrecision : 3,
1121 fieldLabel : 'Shipping',
1122 name : 'cohead_freight',
1126 xtype: 'NumberField',
1128 allowDecimals : true,
1129 cls : 'roo-align-right',
1130 decimalPrecision : 3,
1131 fieldLabel : 'Unshipped Total',
1132 name : 'cohead_unshipped',
1137 xtype: 'NumberField',
1139 allowDecimals : true,
1140 cls : 'roo-align-right',
1141 decimalPrecision : 3,
1142 fieldLabel : 'Uninvoiced Total',
1143 name : 'cohead_uninvoiced',
1154 style : 'width:420px',
1155 legend : "Shipping",
1166 labelSeparator : ' ',
1172 check : function (_self, checked)
1178 if (_this.dataloading) {
1186 // copy the cohead_billto_cntct_id
1187 for (var i in _this.data) {
1188 if (!i.match(/^cohead_billto_cntct_id/)) {
1191 var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');
1192 _this.data[ni] = _this.data[i];
1194 _this.form.findField('shipto_address').update();
1195 _this.form.setValues( {
1196 cohead_shipto_cntct_id : _this.data.cohead_shipto_cntct_id,
1197 cohead_shipto_cntct_id_cntct_name : _this.data.cohead_shipto_cntct_id_cntct_first_name + ' ' +
1198 _this.data.cohead_shipto_cntct_id_cntct_last_name
1205 for (var i in _this.data) {
1206 if (!i.match(/^cohead_billto_cntct_id/)) {
1209 var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');
1211 _this.data[ni] = '';
1213 _this.form.findField('shipto_address').update();
1215 _this.form.setValues( {
1216 cohead_shipto_cntct_id : '',
1217 cohead_shipto_cntct_id_cntct_name : ''
1225 boxLabel : 'Same as Billing',
1226 name : '_shipto_same'
1234 add : function (combo)
1236 Pman.Dialog.XtupleQuickContact.show(
1239 customer_id : _this.form.findField('cohead_cust_id').getValue()
1244 for(var i in data) {
1246 _this.data['cohead_shipto_cntct_id_' + i] = data[i];
1249 _this.form.findField('shipto_address').update();
1250 // fill in the select box..
1251 _this.form.setValues( {
1252 cohead_shipto_cntct_id : data.cntct_id,
1253 cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1254 data.cntct_last_name
1260 beforeselect : function (combo, record, index)
1263 // just add everything...
1264 for(var i in record.data) {
1265 //Roo.log('cohead_shipto_cntct_id_' + i +' =' + record.data[i]);
1266 _this.data['cohead_shipto_cntct_id_' + i] = record.data[i];
1269 _this.form.findField('shipto_address').update();
1276 displayField : 'cntct_name',
1278 emptyText : "Select ship to",
1279 fieldLabel : 'Ship to',
1280 forceSelection : true,
1281 hiddenName : 'cohead_shipto_cntct_id',
1283 loadingText : "Searching...",
1285 name : 'cohead_shipto_cntct_id_cntct_name',
1287 qtip : "Select shiptoinfo",
1288 queryParam : 'query[cntct_name]',
1289 selectOnFocus : true,
1290 tpl : '<div class="x-grid-cell-text x-btn button">{cntct_name} - <b>{cntct_addr_id_addr_line1}</b> </div>',
1291 triggerAction : 'all',
1293 valueField : 'cntct_id',
1299 beforeload : function (_self, o){
1300 o.params = o.params || {};
1302 o.params._customer_id = _this.data.cohead_cust_id;
1306 sortInfo : { direction : 'ASC', field: 'cntct_name' },
1311 url : baseURL + '/Roo/cntct.php'
1314 xtype: 'JsonReader',
1318 totalProperty : 'total',
1319 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
1327 render : function (_self)
1333 this.el.on('click', function() {
1334 var id = _this.form.findField('cohead_shipto_cntct_id').getValue();
1335 Pman.Dialog.XtupleQuickContact.show(
1338 customer_id : _this.form.findField('cohead_cust_id').getValue()
1343 for(var i in data) {
1345 _this.data['cohead_shipto_cntct_id_' + i] = data[i];
1348 _this.form.findField('shipto_address').update();
1349 // fill in the select box..
1350 _this.form.setValues( {
1351 cohead_shipto_cntct_id : data.cntct_id,
1352 cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1353 data.cntct_last_name
1362 // Roo.log("Click text");
1368 fieldLabel : 'Address',
1369 name : 'shipto_address',
1372 update : function() {
1374 var c = ['first_name', 'last_name' ] ;
1375 var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];
1377 Roo.each(c, function(e) {
1378 if (_this.data['cohead_shipto_cntct_id_cntct_' +e] &&
1379 _this.data['cohead_shipto_cntct_id_cntct_' +e].length) {
1380 v.push(_this.data['cohead_shipto_cntct_id_cntct_' +e]);
1383 Roo.each(a, function(e) {
1384 if (_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e] &&
1385 _this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e].length) {
1386 v.push(_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e]);
1390 this.setValue(v.join("\n"));
1396 fieldLabel : 'Shipment Comments',
1397 name : 'cohead_shipcomments',
1414 name : 'cohead_shipto_id'
1419 name : 'cohead_shipto_id_shipto_name'
1424 name : 'cohead_max_linenumber'
1429 name : 'cohead_cust_id'
1434 name : 'cohead_misc',
1435 recalc : function() {
1436 var d = _this.form.getValues();
1438 parseFloat(d.cohead_pretax_discount) +
1439 parseFloat(d.cohead_posttax_discount) );
1445 name : 'taxzone_rate'
1455 activate : function() {
1458 try { if (MODULE.isBuilder) {
1462 var id = _this.form.findField('cohead_id').getValue() * 1;
1464 Roo.MessageBox.alert("Save First", "Save the order first, before adding items");
1465 _this.dialog.layout.getRegion('center').showPanel(0);
1470 _this.grid.footer.onClick('first');
1472 //if (_this.form.findField('cohead_cust_id_cust_name').getValue() == 'Bloom and Grow HK') {
1473 // _this.xferAll.show();
1476 // _this.xferAll.hide();
1481 deactivate : function (_self)
1484 _this.grid.stopEditing();
1489 fitContainer : true,
1492 tableName : 'coitem',
1493 title : "Order Items",
1495 xtype: 'EditorGrid',
1501 //_this.dialog = Pman.Dialog.FILL_IN
1503 if (_this.panel.active) {
1504 this.footer.onClick('first');
1507 afteredit : function (e)
1509 Roo.log('afteredit:' + e.record.data.coitem_linenumber);
1512 // if ( e.record && e.record.data.coitem_id) {
1513 // as we disable update to the display on the ajax callback to
1514 // allow editing flow to continue, and not refresh - we can only update
1515 // these values after something has actually been edited.
1516 // e.record.set('coitem_id', e.record.data.coitem_id);
1517 // e.record.set('coitem_status', e.record.data.coitem_status);
1520 if (e.field == 'item_number' || e.originalValue == e.value) {
1521 // afterselect handles this...
1524 if (e.field == 'item_descrip1') {
1525 e.record.set('coitem_memo', e.value);
1527 var rate = _this.form.findField('taxzone_rate').getValue();
1529 case 'coitem_linedisc':
1531 var cp = parseFloat(e.record.data.coitem_custprice);
1533 if (isNaN(cp) || cp == 0.0) {
1537 var dis = parseFloat(e.value);
1545 Math.max(0,cp * ((100.0 - parseInt(e.value))/ 100.0) )
1548 // donot need to set the subtotal here, coz we will render it automatically
1550 // 'coitem_subtotal',
1551 // e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord
1555 case 'coitem_price': // SELL@ price
1557 var cp = parseFloat(e.record.data.coitem_custprice);
1558 // list price is < price -- update it..
1559 if (isNaN(cp) || cp == 0.0 || cp < e.value) {
1560 e.record.set('coitem_custprice', e.value);
1563 // update the discount calc.
1565 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( e.value / cp) * 100.0)));
1567 // donot need to set the subtotal here, coz we will render it automatically
1569 // 'coitem_subtotal',
1570 // e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord
1574 case 'coitem_custprice':
1575 // modified customer price...
1576 // just modify the discount.. -- leave the entered price the same..
1577 var sp = parseFloat(e.record.data.coitem_price);
1578 var cp = parseFloat(e.value);
1579 if (isNaN(cp) || cp == 0.0 || cp < e.value) {
1583 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1587 case 'coitem_custprice_tax':
1588 var cp = parseFloat(e.value / ( 1 + rate * 1 ));
1589 var sp = parseFloat(e.record.data.coitem_price);
1591 if (isNaN(cp) || cp == 0.0) {
1594 e.record.set('coitem_custprice', cp);
1595 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1599 case 'coitem_price_tax':
1601 var cp = parseFloat(e.record.data.coitem_custprice);
1602 var sp = parseFloat(e.value / ( 1 + rate * 1 ));
1603 if (isNaN(cp) || cp == 0.0 || cp < sp) {
1604 e.record.set('coitem_custprice', sp);
1607 e.record.set('coitem_price', sp);
1608 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1617 var doupdate = function() {
1618 if (!e.record.updatePending) {
1619 Roo.log('doupdate...' + e.record.data.coitem_linenumber);
1624 Roo.log('doupdate pending...' + e.record.data.coitem_linenumber);
1625 // wait until it's not peding an update..
1626 doupdate.defer(500);
1629 if(e.record.data.coitem_id * 1 < 1 && !e.record.isInserting){ // insert
1630 e.record.isInserting = 1;
1631 e.record.isUpdating = 0;
1637 if(!e.record.isInserting && !e.record.isUpdating){
1638 e.record.isUpdating = 1;
1643 if(!e.record.updatePending){
1644 e.record.updatePending = 1;
1648 Roo.log("got to end without doing an update?" + e.record.data.coitem_linenumber);
1651 beforeedit : function (e)
1653 // we can only edit if nothing is assigned to shipping or invoices..
1657 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0 || (rec.data.shipitem_shipped - rec.data.coitem_qtyshipped) > 0 ) {
1658 Roo.MessageBox.alert("Error", "That item has been shipped, has a draft shipment or invoices - void the shipments/invoices first");
1663 if (rec.data.coitem_subnumber * 1 > 0) {
1664 Roo.log("Edit container event");
1665 Roo.log(e); // if it's a tab..
1669 // allow editing of source / destination..
1670 case 'coitem_shipto_id':
1671 case 'coitem_location_src':
1676 Roo.MessageBox.alert("Error", "That is a kit item, edit the container.");
1680 // zero off values..
1681 //if (e.field == 'coitem_qtyord' && rec.data.coitem_qtyord == 0) {
1684 // if (e.field == 'coitem_custprice' && rec.data.coitem_qtyord == 0.0) {
1688 if (rec.data.item_type == 'K' && e.field == 'item_number') {
1689 // you can not change the product type on kits' as it messing things up..
1690 Roo.MessageBox.alert("Error", "That is a kit item,if you need to change it, delete it first.");
1696 celldblclick : function (_self, rowIndex, columnIndex, e)
1698 var rec = this.ds.getAt(rowIndex);
1699 var di = this.cm.getDataIndex(columnIndex);
1700 if (di != 'avail_qty') {
1704 Pman.Dialog.XtupleInvHistory.show({
1705 itemsite_item_id_item_number : rec.data.item_number,
1706 // itemsite_item_id_item_descript1 : rec.data.item_descrip1,
1707 location_name : rec.data.coitem_location_src_location_name,
1708 location_descrip : rec.data.coitem_location_src_location_descrip,
1710 invhist_transdate : _this.form.findField('cohead_targetdate').getValue()
1714 rowclass : function (gridview, rowcfg)
1716 if (rowcfg.record.data.coitem_status == 'C' &&
1717 rowcfg.record.data.shipitem_shipped * 1 < 1) {
1719 rowcfg.rowClass = 'strikethrough';
1721 if (rowcfg.record.data.coitem_status == 'X' ) {
1723 rowcfg.rowClass = 'strikethrough';
1726 if (!rowcfg.record.data.coitem_id) {
1727 rowcfg.rowClass = 'dragon-not-saved';
1735 autoExpandColumn : 'item_descrip1',
1738 loadAvail : function() {
1741 this.ds.each(function(r) {
1743 if(!r.data.item_number.length){
1747 if(typeof(_this.stockcache[r.data.item_number]) != 'undefined'){
1749 r.set('avail_qty', _this.stockcache[r.data.item_number].qty);
1750 if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {
1751 r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);
1759 item : r.data.item_number,
1760 loc: r.data.coitem_location_src_location_name,
1761 id: r.data.coitem_linenumber + (r.data.coitem_subnumber ? ('.' + r.data.coitem_subnumber) : '')
1765 url : baseURL + '/Roo/itemloc',
1768 _availqty : Roo.encode(q),
1769 curr_name : _this.form.findField('cohead_curr_id').el.dom.value
1771 success : function(res)
1773 for (var i in res.data) {
1774 _this.stockcache[res.data[i].item] = res.data[i];
1776 r.set('avail_qty', _this.stockcache[r.data.item_number].qty);
1777 if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {
1778 r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);
1780 //_this.grid.ds.fireEvent("update", _this.grid.ds, r, Roo.data.Record.EDIT);
1789 xtype: 'CellSelectionModel',
1792 tabend : function (_self)
1794 _this.addItemBtn.fireEvent('click', _this.addItemBtn);
1796 beforeeditnext : function (eventdata)
1800 // this does not work, as the reload effect cancels editng.
1801 var rec = _this.grid.ds.getAt(eventdata.cell[0]);
1802 if (rec.data.coitem_subnumber *1 < 0 ) {
1805 var r = eventdata.cell[0] + 1;
1808 if (r > _this.grid.ds.getCount()-1 ) {
1809 eventdata.cell = false;
1812 rec = _this.grid.ds.getAt(r);
1813 if (rec.data.coitem_subnumber *1 < 0 ) {
1814 eventdata.cell = [ r, eventdata.cell[1] ];
1828 xtype: 'PagingToolbar',
1831 emptyMsg : "No Items",
1833 updateSummary : function() {
1836 url : baseURL + '/Roo/Coitem',
1840 coitem_cohead_id : _this.form.findField('cohead_id').getValue()
1842 success : function(d) {
1844 f.displayEl.update(String.format(
1845 "{0} items | Subtotal: {2} | Tax: {3} | List Discount {4} | Total : {1}{5}",
1847 _this.form.findField('cohead_curr_id').el.dom.value,
1850 d.data.total_list_discount,
1862 click : function (_self, e)
1865 url : baseURL + '/Roo/Cohead',
1868 _fill_shipto : _this.form.findField('cohead_id').getValue()
1870 success : function() {
1871 _this.grid.footer.onClick('first');
1876 text : "Fill empty Ship To"
1882 click : function (_self, e)
1884 Roo.MessageBox.confirm("Confirm", "Are you sure?<BR>"+
1885 "This will set all the locations to match the Sales Order - and remove all old locations.",
1892 url : baseURL + '/Roo/Cohead',
1895 _fill_location : _this.form.findField('cohead_id').getValue(),
1896 _location_id : _this.form.findField('cohead_location_src').getValue()
1898 success : function() {
1899 _this.grid.footer.onClick('first');
1906 text : "Update Location to match S/O"
1912 toggle : function (_self, pressed)
1914 this.setText(pressed ? "Prices exc GST" : "Prices with GST");
1915 var cm = _this.grid.getColumnModel();
1917 cm.setHidden(cm.getIndexByDataIndex('coitem_price_tax'), pressed ? false : true);
1918 cm.setHidden(cm.getIndexByDataIndex('coitem_custprice_tax'), pressed ? false : true);
1919 cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal_tax'), pressed ? false : true);
1921 cm.setHidden(cm.getIndexByDataIndex('coitem_price'), pressed ? true : false);
1922 cm.setHidden(cm.getIndexByDataIndex('coitem_custprice'), pressed ? true : false);
1923 cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal'), pressed ? true : false);
1926 render : function (_self)
1928 _this.showgstBtn = _self;
1931 enableToggle : true,
1933 text : "Prices with GST"
1941 beforeload : function (_self,o) {
1948 if (!_this.data || !_this.data.cohead_id) {
1951 o.params = o.params || {};
1953 o.params.coitem_cohead_id = _this.data.cohead_id;
1954 o.params._without_list_discount =1;
1955 //o.params.limit = 999;
1959 update : function (_self, rec, operation)
1962 if (operation != Roo.data.Record.COMMIT) {
1966 // row has been updated..
1967 // if the qty + item has been filled in, we should try and save it..
1970 var setRecord = function(){
1972 Roo.log("Clearing update?" + rec.data.coitem_linenumber);
1973 rec.updatePending = 0;
1974 if(rec.isInserting){
1975 rec.isInserting = 0;
1981 if (!(rec.data.coitem_itemsite_id * 1) || !(rec.data.coitem_qtyord*1)) {
1985 var doCommit = function() {
1986 Roo.log("Sending data?" + rec.data.coitem_linenumber);
1989 url : baseURL+'/Roo/coitem',
1992 success: function(res)
1995 var row = _this.grid.ds.indexOf(rec);
1996 Roo.get(_this.grid.view.getRow(row)).removeClass('dragon-not-saved');
2002 Roo.log("GOT success: " + rec.data.coitem_linenumber);
2003 //Roo.log("GOT success");
2004 // update the data...
2006 if (rec.data.item_type == 'K') {
2008 _this.grid.ds.load({});
2013 // why is this here.??
2015 if (_this.grid.activeEditor) {
2021 rec.set('coitem_id', res.data.coitem_id);
2022 rec.set('coitem_status', res.data.coitem_status);
2026 delete rec.modified;
2028 _this.grid.footer.updateSummary();
2029 _this.grid.loadAvail();
2035 failure : function(res)
2038 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error updating");
2051 load : function (_self, records, options)
2053 // need to fetch availablity from master data..
2054 // build a list of what to ask..
2056 // query: ITEM CODE - LOCATION
2057 _this.grid.footer.updateSummary();
2058 _this.grid.loadAvail.defer(100, _this.grid);
2066 sortInfo : { field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' },
2071 url : baseURL + '/Roo/coitem.php'
2074 xtype: 'JsonReader',
2078 totalProperty : 'total',
2081 'name': 'coitem_linenumber',
2085 'name': 'coitem_itemsite_id',
2089 'name': 'coitem_qtyord'
2092 'name': 'coitem_unitcost'
2095 'name': 'coitem_price'
2098 'name': 'coitem_custprice'
2101 'name': 'coitem_qtyreturned'
2104 'name': 'coitem_prcost'
2107 'name': 'coitem_price_uom_id',
2111 'name': 'coitem_qtyreserved'
2127 Roo.log("add presed");
2130 var grid = _this.grid;
2132 grid.ds.each(function(r) {
2133 if (r.data.coitem_qtyord < 1) {
2134 Roo.MessageBox.alert("Error", "you must fill in a quantity for " + r.data.item_number);
2146 var last = _this.form.findField('cohead_max_linenumber').getValue();
2153 _this.form.findField('cohead_max_linenumber').setValue(last);
2155 // this should be getting the previous row..??
2156 var ct = _this.grid.ds.getCount();
2157 var lastrow = ct ? _this.grid.ds.getAt(ct-1) : false;
2159 function lastor(k,d,kk) {
2160 var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();
2161 return lastrow ? lastrow.data[kk] : def;
2164 // uses form defaults or last row value.
2165 var nr = _this.grid.ds.reader.newRow({
2166 coitem_linenumber : last,
2170 coitem_cohead_id : _this.form.findField('cohead_id').getValue(),
2171 coitem_qtyshipped : 0,
2172 coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),
2173 coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),
2174 coitem_shipto_id : lastor('cohead_shipto_id',false, 'coitem_shipto_id'),
2175 coitem_shipto_id_shipto_name : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name'),
2176 coitem_unitcost_in_order_cur : 0,
2177 coitem_taxtype_id : _this.data.default_taxtype_id,
2178 coitem_taxtype_id_taxtype_name : 'Taxable',
2184 grid.ds.insert(grid.ds.getCount(), nr);
2185 grid.startEditing(grid.ds.getCount()-1, 1); // type..
2186 nr.updatePending = 0;
2191 render : function (_self)
2193 _this.addItemBtn = _self;
2196 cls : 'x-btn-text-icon',
2198 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
2204 click : function (_self, e)
2206 var last = _this.form.findField('cohead_max_linenumber').getValue();
\r
2208 _this.form.findField('cohead_max_linenumber').setValue(last);
2210 var ct = _this.grid.ds.getCount();
\r
2211 var lastrow = ct ? _this.grid.ds.getAt(ct-1) : false;
\r
2213 function lastor(k,d,kk) {
\r
2214 var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();
\r
2215 return lastrow ? lastrow.data[kk] : def;
\r
2218 var cohead_cust_id = _this.form.findField('cohead_cust_id').getValue();
2219 var cohead_id = _this.form.findField('cohead_id').getValue();
2221 Pman.Dialog.XtupleSalesProductList.show( {cohead_cust_id : cohead_cust_id, cohead_id : cohead_id} , function(res) {
2223 _this.grid.stopEditing();
2225 if (_this.grid.ds.getCount() > 0) {
2226 var lr = _this.grid.ds.getAt(_this.grid.ds.getCount()-1);
2227 if (!lr.data.coitem_itemsite_id) {
2228 lr.set('coitem_itemsite_id', res.item_itemsite_id_itemsite_id);
2229 lr.set('item_number', res.item_number);
2230 lr.set('item_descrip1', res.item_descrip1);
2231 lr.set('coitem_listprice', res.item_price);
2232 lr.set('coitem_price', res.item_price);
2233 lr.set('coitem_custprice', res.item_price);
2240 var nr = _this.grid.ds.reader.newRow({
2241 coitem_linenumber : last,
2242 coitem_itemsite_id : res.item_itemsite_id_itemsite_id,
2243 item_number : res.item_number,
2244 item_descrip1 : res.item_descrip1,
2246 coitem_cohead_id : _this.form.findField('cohead_id').getValue(),
2247 coitem_qtyshipped : 0,
2248 coitem_listprice : res.item_price,
2249 coitem_price : res.item_price,
2250 coitem_custprice : res.item_price,
2252 coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),
2253 coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),
2254 coitem_shipto_id : lastor('cohead_shipto_id',false, 'coitem_shipto_id'),
2255 coitem_shipto_id_shipto_name : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name')
2258 _this.grid.ds.insert(_this.grid.ds.getCount(), nr);
2263 cls : 'x-btn-text-icon',
2264 text : "Find Products",
2265 icon : rootURL + '/Pman/templates/images/search.gif'
2275 url : baseURL + '/Roo/coitem',
2276 mask : 'Loading Data',
2280 _hk_xfer :_this.form.findField('cohead_id').getValue()
2282 success : function() {
2283 _this.grid.ds.load({});
2288 render : function (_self)
2290 _this.xferAll = _self;
2293 cls : 'x-btn-text-icon',
2295 text : "Xfer all stock to HK",
2296 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
2302 click : function (_self, e)
2304 var c = _this.grid.getSelectionModel().getSelectedCell();
2306 Roo.MessageBox.alert("Error", "Select item to show history (you can also double click on the #avail number) ");
2310 var rec = _this.grid.ds.getAt(c[0]);
2312 Pman.Dialog.XtupleInvHistory.show({
2313 itemsite_item_id_item_number : rec.data.item_number,
2314 // itemsite_item_id_item_descript1 : rec.data.item_descrip1,
2315 location_name : rec.data.coitem_location_src_location_name,
2316 location_descrip : rec.data.coitem_location_src_location_descrip,
2319 invhist_transdate : _this.form.findField('cohead_targetdate').getValue()
2325 text : "Show Inventory History"
2334 text : "Apply % Discount of : "
2340 render : function (_self)
2342 _this._applyDiscount = _self;
2351 click : function (_self, e)
2353 var val = parseFloat(_this._applyDiscount.getValue());
2355 var factor = (100.0 - val)/100.0;
2357 _this.grid.ds.each(function(rec) {
2358 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2362 rec.set('coitem_price', rec.data.coitem_custprice * factor);
2363 rec.set('coitem_linedisc', val);
2364 rec.set('coitem_subtotal', rec.data.coitem_price & rec.data.ordqty);
2372 text : "Apply To All"
2378 click : function (_self, e)
2381 if (!(1* _this.form.findField('cohead_id').getValue())) {
2382 Roo.MessageBox.alert("Error", "save the order first");
2386 Pman.Dialog.Image.show(
2389 _url : baseURL+'/Xtuple/Import/SalesOrder',
2390 onid : _this.form.findField('cohead_id').getValue()
2395 Roo.MessageBox.alert("Notice", "Uploaded");
2396 _this.grid.footer.onClick('first');
2414 _this.grid.stopEditing();
2415 // check that no shipments or invoices are done..
2416 var rc = _this.grid.getSelectionModel().getSelectedCell();
2418 var rec = _this.grid.ds.getAt(rc[0]);
2420 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2421 Roo.MessageBox.alert("Error", "That item has been shipped or invoices - void the shipments/invoices first");
2424 if (rec.data.coitem_subnumber*1 > 0) {
2425 Roo.MessageBox.alert("Error", "Delete the kit item that that belongs to.");
2428 if (!rec.data.coitem_id) {
2429 _this.grid.ds.remove(rec);
2436 url : baseURL + '/Roo/coitem',
2439 _delete : rec.data.coitem_id
2442 success : function() {
2443 if (rec.data.item_type == 'K') {
2444 _this.grid.ds.load({});
2447 _this.grid.ds.remove(rec);
2452 if (rec.data_qtyord * 1 < 1) {
2456 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that line?", function(r)
2469 cls : 'x-btn-text-icon',
2471 icon : rootURL + '/Pman/templates/images/trash.gif'
2479 _this.grid.stopEditing();
2480 // check that no shipments or invoices are done..
2482 _this.grid.ds.each(function(rec) {
2486 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2487 //Roo.MessageBox.alert("Error", "That item has been shipped or invoices - void the shipments/invoices first");
2490 if (rec.data.item_type == 'K') {
2494 if (rec.data.coitem_subnumber*1 > 0) {
2495 //Roo.MessageBox.alert("Error", "Delete the kit item that that belongs to.");
2498 if (!rec.data.coitem_id) {
2499 _this.grid.ds.remove(rec);
2502 ids.push(rec.data.coitem_id);
2508 url : baseURL + '/Roo/coitem',
2511 _delete : ids.join(',')
2514 success : function() {
2516 _this.grid.footer.onClick('first');
2521 // if (rec.data_qtyord * 1 < 1) {
2525 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete everything?", function(r)
2538 cls : 'x-btn-text-icon',
2539 text : "Delete All",
2540 icon : rootURL + '/Pman/templates/images/trash.gif'
2546 xtype: 'ColumnModel',
2548 dataIndex : 'coitem_linenumber',
2551 renderer : function(v,x,r) {
2553 if (r.data.coitem_subnumber * 1 > 0) {
2554 return String.format('{0}.{1}', v,r.data.coitem_subnumber);
2556 return String.format('{0}', v);
2560 xtype: 'ColumnModel',
2562 dataIndex : 'item_number',
2563 header : 'Item Code',
2565 renderer : function(v) { return String.format('{0}', v); },
2567 xtype: 'GridEditor',
2573 beforeselect : function (combo, record, index)
2575 // set _this.data values ..
2576 var ar = _this.grid.activeEditor.record;
2577 // Roo.log('beforeselect');
2581 // Roo.log('beforeselect-cb');
2582 ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
2583 ar.set('coitem_listprice', record.data.item_listprice);
2584 ar.set('coitem_price', record.data.item_price);
2585 ar.set('coitem_custprice', record.data.item_price);
2586 ar.set('coitem_itemsite_id', record.data.itemsite_id);
2587 ar.set('item_number', record.data.itemsite_item_id_item_number);
2588 ar.set('item_type', record.data.itemsite_item_id_item_type);
2589 ar.set('avail_qty', 0);
2596 displayField : 'itemsite_item_id_item_number',
2598 emptyText : "Select item",
2599 forceSelection : true,
2600 hiddenName : 'itemsite_item_id_item_number',
2602 loadingText : "Searching...",
2604 name : 'item_number',
2606 qtip : "Select item",
2607 queryParam : 'query[number]',
2608 selectOnFocus : true,
2609 tpl : '<div class="x-grid-cell-text x-btn button"><b>{itemsite_item_id_item_number}</b> ${item_price:toFixed(2)}- {itemsite_item_id_item_descrip1} </div>',
2610 triggerAction : 'all',
2612 valueField : 'item_number',
2617 beforeload : function (_self, o){
2618 o.params = o.params || {};
2619 o.params.customer_id = _this.form.findField('cohead_cust_id').getValue();
2620 o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue();
2621 //o.params.shipto_cust_id = _this.data.cohead_cust_id;
2626 sortInfo : { direction : 'ASC', field: 'item_number' },
2631 url : baseURL + '/Roo/itemsite.php'
2634 xtype: 'JsonReader',
2638 totalProperty : 'total',
2639 fields : [{"name":"item_id","type":"int"},"item_number"]
2646 xtype: 'ColumnModel',
2648 dataIndex : 'coitem_location_src',
2651 renderer : function(v,x,r) {
2652 return String.format('{0}', r.data.coitem_location_src_location_name);
2655 xtype: 'GridEditor',
2661 beforeselect : function (combo, record, index)
2663 // set _this.data values ..
2664 var ar = _this.grid.activeEditor.record;
2668 //Roo.log('beforeselect');
2672 // Roo.log('beforeselect-cb');
2673 ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
2674 ar.set('coitem_price', record.data.item_listprice);
2675 ar.set('coitem_custprice', record.data.item_price);
2676 ar.set('coitem_itemsite_id', record.data.itemsite_id);
2677 ar.set('item_number', record.data.itemsite_item_id_item_number);
2686 displayField : 'location_name',
2688 emptyText : "Select location",
2689 forceSelection : true,
2690 hiddenName : 'coitem_location_src',
2692 loadingText : "Searching...",
2694 name : 'coitem_location_src_location_name',
2696 qtip : "Select item",
2697 queryParam : 'query[location_name]',
2698 selectOnFocus : true,
2699 tpl : '<div class="x-grid-cell-text x-btn button"><b> {location_name}</b> {location_descrip}</div>',
2700 triggerAction : 'all',
2702 valueField : 'location_id',
2707 beforeload : function (_self, o){
2708 o.params = o.params || {};
2710 var row = _this.grid.activeEditor.record;
2712 o.params['query[item_itemsite_id]'] = row.data.coitem_itemsite_id;
2713 // need to know the date to calc the est. delivery time..
2714 //o.params['query[avail_when]'] = _this.form.findField('cohead_targetdate').getValue().format('Y-m-d');
2715 //o.params.location_netable = 1;
2716 o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue();
2718 o.params.location_restrict = 0;
2719 o.params._notinternalcompany = 1;
2723 // o.params.itemsite_id = _this.form.findField('cohead_cust_id').getValue();
2724 //o.params.shipto_cust_id = _this.data.cohead_cust_id;
2729 sortInfo : { direction : 'ASC', field: 'location_name' },
2734 url : baseURL + '/Roo/location.php'
2737 xtype: 'JsonReader',
2741 totalProperty : 'total',
2742 fields : [{"name":"location_id","type":"int"},"location_name"]
2749 xtype: 'ColumnModel',
2751 dataIndex : 'coitem_shipto_id',
2754 renderer : function(v,x,r) {
2755 return String.format('{0}:{1}', v, r.data.coitem_shipto_id_shipto_name);
2758 xtype: 'GridEditor',
2764 add : function (combo)
2767 Pman.Dialog.XtupleCustomer.show({ cust_id : _this.form.findField('cohead_cust_id').getValue() }, function(data) {
2768 // refresh the data in the pulldown..
2771 beforeselect : function (combo, record, index)
2775 for(var i = 1; i <4; i++) {
2776 _this.data['cohead_shiptoaddress'+ i] = record.data['cntct_addr_id_addr_line'+i];
2778 _this.form.findField('shipto_address').update();
2785 displayField : 'shipto_name',
2787 emptyText : "Select cntct",
2788 forceSelection : true,
2789 hiddenName : 'cohead_shipto_id',
2791 loadingText : "Searching...",
2793 name : 'coitem_shipto_id_shipto_name',
2795 qtip : "Select shipto",
2796 queryParam : 'query[shipto_name]',
2797 selectOnFocus : true,
2798 tpl : '<div class="x-grid-cell-text x-btn button"><b>{shipto_id}:{shipto_addr_id_addr_name}</b> </div>',
2799 triggerAction : 'all',
2801 valueField : 'shipto_id',
2807 beforeload : function (_self, o){
2808 o.params = o.params || {};
2809 o.params.shipto_cust_id = _this.data.cohead_cust_id;
2810 //o.params['query[with_shipinfo]'] = 1;
2815 sortInfo : { direction : 'ASC', field: 'shipto_name' },
2820 url : baseURL + '/Roo/shiptoinfo.php'
2823 xtype: 'JsonReader',
2827 totalProperty : 'total',
2828 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
2835 xtype: 'ColumnModel',
2837 dataIndex : 'item_descrip1',
2838 header : 'Item Description',
2840 renderer : function(v,x,r) {
2842 if (r.data.coitem_memo && r.data.coitem_memo.length) {
2843 return String.format('{0}', r.data.coitem_memo);
2844 if (r.data.coitem_memo != v) {
2845 r.set('item_descrip1', r.data.coitem_memo);
2849 if (v && v.length > 49) {
2850 return String.format('<span style="color:orange" qtip="line may be too long to print">{0}</span>', v);
2853 return String.format('{0}', v);
2857 xtype: 'GridEditor',
2867 xtype: 'ColumnModel',
2870 dataIndex : 'coitem_status',
2873 renderer : function(v) { return String.format('{0}', v); }
2876 xtype: 'ColumnModel',
2879 dataIndex : 'coitem_qtyord',
2882 renderer : function(v,x,r) {
2883 var v = parseInt(v);
2884 //var aq = parseInt(r.data.avail_qty);
2885 //aq = isNaN(aq) ? 0 : aq;
2887 var rate = _this.form.findField('taxzone_rate').getValue();
2888 r.data.coitem_subtotal = v * r.data.coitem_price;
2889 r.data.coitem_subtotal_tax = v * r.data.coitem_price * ( 1 + rate * 1);
2890 return String.format('{0}', v);
2894 xtype: 'GridEditor',
2897 xtype: 'NumberField',
2900 focus : function (_self)
2902 if (this.value == 0) {
2903 this.el.dom.value = '';
2907 allowDecimals : false,
2908 decimalPrecision : 0,
2910 style : 'text-align:right'
2915 xtype: 'ColumnModel',
2918 dataIndex : 'coitem_price',
2921 renderer : function(v,x,r) {
2923 var rate = _this.form.findField('taxzone_rate').getValue();
2924 r.data.coitem_subtotal = v * r.data.coitem_qtyord;
2925 r.data.coitem_subtotal_tax = v * ( 1 + rate * 1 ) * r.data.coitem_qtyord;
2926 r.data.coitem_price_tax = v * ( 1 + rate * 1 );
2927 if (parseInt(v) < 1) {
2928 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,3));
2932 //r.set('coitem_subtotal', v * r.data.coitem_qtyord);
2934 return String.format('{0}', Roo.util.Format.number(v,3));
2937 xtype: 'GridEditor',
2940 xtype: 'NumberField',
2943 focus : function (_self)
2945 if (this.value == 0.0) {
2946 this.el.dom.value = '';
2950 decimalPrecision : 3,
2952 style : 'text-align:right'
2957 xtype: 'ColumnModel',
2960 dataIndex : 'coitem_price_tax',
2961 header : 'Sell @w/GST',
2964 renderer : function(v,x,r) {
2966 if (parseInt(v) < 1) {
2967 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,3));
2970 return String.format('{0}', Roo.util.Format.number(v,3));
2973 xtype: 'GridEditor',
2976 xtype: 'NumberField',
2979 focus : function (_self)
2981 if (this.value == 0.0) {
2982 this.el.dom.value = '';
2986 decimalPrecision : 3,
2988 style : 'text-align:right'
2993 xtype: 'ColumnModel',
2996 dataIndex : 'coitem_linedisc',
2999 renderer : function(v,x,r) {
3001 // coitem_custprice = coitem_price * ((100 - coitem_disc)/ 100)
3003 // 12 * (( 100 - 0) / 100)
3004 // coitem_custprice / coitem_price = ((100 - coitem_disc)/ 100)
3005 // 100 - ((coitem_custprice / coitem_price) * 100) = coitem_disc
3006 // 100 - 97 = 100 -3
3008 // r.data.coitem_linedisc = 100 - (
3009 // (parseFloat(r.data.coitem_custprice) /
3010 // parseFloat(r.data.coitem_price)
3012 var fl = parseFloat(r.data.coitem_linedisc);
3013 if ( isNaN(fl) || fl == 0.0 || r.data.coitem_price > r.data.coitem_custprice) {
3016 return String.format('<span style="color:green">{0}%</span>', Roo.util.Format.number( r.data.coitem_linedisc,2));
3019 xtype: 'GridEditor',
3022 xtype: 'NumberField',
3025 focus : function (_self)
3027 if (this.value == 0.0) {
3028 this.el.dom.value = '';
3032 decimalPrecision : 2,
3035 style : 'text-align:right'
3040 xtype: 'ColumnModel',
3043 dataIndex : 'coitem_custprice',
3044 header : 'List Price',
3046 renderer : function(v,x,r) {
3048 var rate = _this.form.findField('taxzone_rate').getValue();
3049 r.data.coitem_custprice_tax = v * ( 1 + rate * 1 );
3051 var tip = 'No WRP available';
3052 if ((r.data.coitem_wrpprice * 1) > 0) {
3053 tip = "WRP : " + Roo.util.Format.number(r.data.coitem_wrpprice,3);
3055 // less than zero, show as red..
3056 if (parseFloat(v) < 1) {
3057 return String.format('<b qtip="{1}" style="color:red;">{0}</b>',
3058 Roo.util.Format.number(v,3), tip);
3060 if (r.data.customer_price_each != v) {
3061 return String.format('<b qtip="{1}" style="color:pink;">{0}</b>',
3062 Roo.util.Format.number(v,3),
3063 "List Price = " + Roo.util.Format.number(r.data.customer_price_each,3)
3069 //r.data.coitem_subtotal = v * r.data.coitem_qtyord;
3071 //r.set('coitem_subtotal', v * r.data.coitem_qtyord);
3073 return String.format('<span qtip="{1}">{0}</span>', Roo.util.Format.number(v,3), tip);
3076 xtype: 'GridEditor',
3079 xtype: 'NumberField',
3082 focus : function (_self)
3084 if (this.value == 0.0) {
3085 this.el.dom.value = '';
3089 decimalPrecision : 3,
3091 style : 'text-align:right'
3096 xtype: 'ColumnModel',
3099 dataIndex : 'coitem_custprice_tax',
3100 header : 'List Price w/GST',
3103 renderer : function(v,x,r) {
3104 var rate = _this.form.findField('taxzone_rate').getValue();
3105 var tip = 'No WRP available';
3106 if ((r.data.coitem_wrpprice * 1) > 0) {
3107 tip = "WRP : " + Roo.util.Format.number(r.data.coitem_wrpprice,3);
3110 if (parseFloat(v) < 1) {
3111 return String.format('<b qtip="{1}" style="color:red;">{0}</b>',
3112 Roo.util.Format.number(v,3), tip);
3114 if (r.data.customer_price_each != v) {
3115 return String.format('<b qtip="{1}" style="color:pink;">{0}</b>',
3116 Roo.util.Format.number(v,3),
3117 "List Price = " + Roo.util.Format.number(r.data.customer_price_each * ( 1 + rate * 1 ),3)
3121 return String.format('<span qtip="{1}">{0}</span>', Roo.util.Format.number(v,3), tip);
3124 xtype: 'GridEditor',
3127 xtype: 'NumberField',
3130 focus : function (_self)
3132 if (this.value == 0.0) {
3133 this.el.dom.value = '';
3137 decimalPrecision : 3,
3139 style : 'text-align:right'
3144 xtype: 'ColumnModel',
3147 dataIndex : 'coitem_subtotal',
3148 header : 'SubTotal',
3150 renderer : function(v) {
3152 if (parseInt(v) < 1) {
3153 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,2));
3158 return Roo.util.Format.number( v, 2);
3162 xtype: 'ColumnModel',
3165 dataIndex : 'coitem_subtotal_tax',
3166 header : 'SubTotal w/GST',
3169 renderer : function(v,x,r) {
3171 if (parseInt(v) < 1) {
3172 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,2));
3175 return String.format('{0}', Roo.util.Format.number(v,2));
3179 xtype: 'ColumnModel',
3182 dataIndex : 'coitem_unitcost_in_order_cur',
3183 header : 'Unit Cost',
3185 renderer : function(v) { return Roo.util.Format.number( v, 2); }
3188 xtype: 'ColumnModel',
3191 dataIndex : 'coitem_taxtype_id',
3194 renderer : function(v,x,r) { return String.format('{0}', r.data.coitem_taxtype_id_taxtype_name); },
3196 xtype: 'GridEditor',
3202 displayField : 'taxtype_name',
3204 emptyText : "Select Tax Type",
3205 forceSelection : true,
3206 hiddenName : 'coitem_taxtype_id',
3208 loadingText : "Searching...",
3210 name : 'coitem_taxtype_id_taxtype_name',
3212 qtip : "Select taxtype",
3213 queryParam : 'query[taxtype_id]',
3214 selectOnFocus : true,
3215 tpl : '<div class="x-grid-cell-text x-btn button"><b>{taxtype_name}</b> </div>',
3216 triggerAction : 'all',
3218 valueField : 'taxtype_id',
3224 beforeload : function (_self, o){
3225 o.params = o.params || {};
3232 sortInfo : { direction : 'ASC', field: 'taxtype_name' },
3237 url : baseURL + '/Roo/taxtype.php'
3240 xtype: 'JsonReader',
3244 totalProperty : 'total',
3245 fields : [{"name":"taxtype_id","type":"int"},"taxtype_name"]
3252 xtype: 'ColumnModel',
3255 dataIndex : 'avail_qty',
3258 renderer : function(v,x,r) {
3260 var oq = parseInt(r.data.coitem_qtyord);
3261 var aq = parseInt(r.data.avail_qty);
3262 var sq = parseInt(r.data.coitem_qtyshipped);
3263 aq = isNaN(aq) ? 0 : aq;
3264 oq = isNaN(oq) ? 0 : oq;
3265 sq = isNaN(sq) ? 0 : sq;
3267 var unshipped = oq - sq;
3269 if ( aq < 0 || (unshipped > 0 && aq < unshipped)) {
3270 return String.format('<b style="color:red;">{0}</b>', parseInt(aq));
3273 return String.format('{0}', aq);
3278 xtype: 'ColumnModel',
3281 dataIndex : 'shipitem_shipped',
3282 header : '#reserved',
3284 renderer : function(v,x,r) {
3287 var vv = parseInt(v);
3288 vv = isNaN(vv) ? 0 : vv;
3290 var ov = parseInt(r.data.coitem_qtyord);
3291 ov = isNaN(ov) ? 0 : ov;
3293 var qs = parseInt(r.data.coitem_qtyshipped);
3294 qs = isNaN(qs) ? 0 : qs;
3299 // not enough reserved yet.
3300 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv - qs);
3303 return String.format('{0}', vv - qs);
3308 xtype: 'ColumnModel',
3311 dataIndex : 'coitem_qtyshipped',
3312 header : '#shipped',
3314 renderer : function(v,x,r) {
3316 var vv = parseInt(v);
3317 vv = isNaN(vv) ? 0 : vv;
3319 var ov = parseInt(r.data.coitem_qtyord);
3320 ov = isNaN(ov) ? 0 : ov;
3324 // not enought shipped.
3325 // or too many shipped.
3326 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv);
3331 return String.format('{0}', vv);
3336 xtype: 'ColumnModel',
3339 dataIndex : 'cobill_billed',
3340 header : '#invoiced',
3342 renderer : function(v,x,r) {
3344 var vv = parseInt(v);
3345 vv = isNaN(vv) ? 0 : vv;
3347 var ov = parseInt(r.data.coitem_qtyord);
3348 ov = isNaN(ov) ? 0 : ov;
3352 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv);
3354 return String.format('{0}', vv);
3362 xtype: 'NestedLayoutPanel',
3365 activate : function (_self)
3367 _this.shipinvtab = _self;
3371 title : "Shipments / Invoices",
3373 xtype: 'BorderLayout',
3380 activate : function() {
3381 _this.shippanel = this;
3382 if (_this.shipgrid) {
3383 _this.shipgrid.ds.load({});
3388 fitContainer : true,
3391 tableName : 'shiphead',
3399 _this.shipgrid = this;
3400 //_this.dialog = Pman.Dialog.FILL_IN
3401 if (_this.shippanel.active) {
3405 rowdblclick : function (_self, rowIndex, e)
3407 var rec = this.ds.getAt(rowIndex);
3408 if (!rec.json.shiphead_shipdate.length) {
3409 Roo.MessageBox.alert("Error", "You can not edit voided shipments, create a new one, and use the restore feature");
3413 Pman.Dialog.XtupleShipment.show({
3414 shiphead_id : rec.data.shiphead_id
3423 autoExpandColumn : 'shiphead_shipvia',
3429 beforeload : function (_self, options)
3431 options.params = options.params || {};
3432 options.params.shiphead_order_id = _this.form.findField('cohead_id').getValue() * 1;
3433 if (options.params.shiphead_order_id < 1) {
3439 sortInfo : { field : 'shiphead_shipvia', direction: 'ASC' },
3444 url : baseURL + '/Roo/shiphead.php'
3447 xtype: 'JsonReader',
3449 totalProperty : 'total',
3454 'name': 'shiphead_number',
3458 'name': 'shiphead_shipvia',
3462 'name': 'shiphead_shipdate',
3466 'name': 'shiphead_sfstatus'
3469 'name': 'shiphead_tracknum',
3485 var sel = _this.shipgrid.getSelectionModel().getSelected();
3487 Roo.MessageBox.alert("Error", "Select a shipment");
3490 if (sel.data.shiphead_shipped) {
3491 Roo.MessageBox.alert("Error", "Shipment is already confirmed");
3496 // check current status of shipment..
3501 url : baseURL + '/Roo/shiphead',
3505 shiphead_id : sel.data.shiphead_id,
3508 success : function() {
3509 _this.shipgrid.ds.load({});
3516 cls : 'x-btn-text-icon',
3517 text : "Confirm Shipment",
3518 icon : rootURL + '/Pman/templates/images/lock.gif'
3526 var sel = _this.shipgrid.getSelectionModel().getSelected();
3528 Roo.MessageBox.alert("Error", "Select a shipment");
3533 // check current status of shipment..
3537 url : baseURL + '/Roo/shiphead',
3540 _download :sel.data.shiphead_id
3548 cls : 'x-btn-text-icon',
3549 text : "Download (as xls)",
3550 icon : rootURL + '/Pman/templates/images/save.gif'
3558 var sel = _this.shipgrid.getSelectionModel().getSelected();
\r
3560 Roo.MessageBox.alert("Error", "Select a shipment");
\r
3563 // check current status of shipment..
3566 url : baseURL + '/Xtuple/Print',
3569 template : 'picking-slip',
3570 param : "shiphead_id:integer='" + sel.data.shiphead_id + "'",
3571 filename : 'picking-slip-' + sel.data.shiphead_number
3573 success : function() {
3582 cls : 'x-btn-text-icon',
3583 text : "Print Picking Slip",
3584 icon : rootURL + '/Pman/templates/images/pdf.gif'
3592 var sel = _this.shipgrid.getSelectionModel().getSelected();
\r
3594 Roo.MessageBox.alert("Error", "Select a shipment");
\r
3597 // check current status of shipment..
3600 url : baseURL + '/Xtuple/Print',
3603 template : 'delivery-note-',
3604 param : "shiphead_id:integer='" + sel.data.shiphead_id + "'",
3605 filename : 'delivery-note-' + sel.data.shiphead_number
3607 success : function() {
3616 cls : 'x-btn-text-icon',
3617 text : "Print Delivery Note",
3618 icon : rootURL + '/Pman/templates/images/pdf.gif'
3630 if (!_this.form.findField('cohead_id').getValue()) {
3631 Roo.MessageBox.alert("Error", "Save Order first");
3634 var rv = _this.form.getFieldValues();
3636 Pman.Dialog.XtupleShipmentNew.show({
3637 shiphead_order_id : rv.cohead_id,
3638 shiphead_shipdate : _this.form.findField('cohead_targetdate').getValue().format('Y-m-d')
3641 _this.shipgrid.ds.load({});
3645 render : function (_self)
3647 _this.addShipmentBtn = _self;
3650 cls : 'x-btn-text-icon',
3652 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
3660 var sel = _this.shipgrid.getSelectionModel().getSelected();
3662 Roo.MessageBox.alert("Error", "Select a shipment");
3665 // check current status of shipment..
3667 var msg = sel.data.shiphead_shipped ?
3668 "Are you sure you want to un-confirm that shipment? - It will remove items from unposted invoices" :
3669 "Are you sure you want to void that shipment?";
3671 Roo.MessageBox.confirm("Are you sure", msg,
3679 url : baseURL + '/Roo/shiphead',
3683 shiphead_id : sel.data.shiphead_id,
3686 success : function() {
3687 _this.shipgrid.ds.load({});
3700 cls : 'x-btn-text-icon',
3701 text : "Void / Unconfirm",
3702 icon : rootURL + '/Pman/templates/images/trash.gif'
3708 xtype: 'ColumnModel',
3710 dataIndex : 'shiphead_number',
3713 renderer : function(v,x,r) {
3714 if (r.json.shiphead_shipdate.length) {
3715 return String.format('{0}', v);
3717 return String.format('<s>{0}</s>', v);
3721 xtype: 'ColumnModel',
3723 dataIndex : 'shiphead_location_id_location_name',
3724 header : 'From Location',
3726 renderer : function(v) { return String.format('{0}', v); }
3729 xtype: 'ColumnModel',
3731 dataIndex : 'shiphead_shipto_id_shipto_name',
3734 renderer : function(v) { return String.format('{0}', v); }
3737 xtype: 'ColumnModel',
3739 header : 'shipdate',
3741 dataIndex : 'shiphead_shipdate',
3742 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
3745 xtype: 'ColumnModel',
3747 dataIndex : 'shiphead_sfstatus',
3750 renderer : function(v,x,r) {
3755 if (r.json.shiphead_shipdate.length) {
3757 if (r.json.shiphead_shipped) {
3761 return '<span style="color:red">Draft</span>';
3770 xtype: 'ColumnModel',
3774 dataIndex : 'shiphead_shipvia',
3775 renderer : function(v) { return String.format('{0}', v); }
3778 xtype: 'ColumnModel',
3780 header : 'tracknum',
3782 dataIndex : 'shiphead_tracknum',
3783 renderer : function(v) { return String.format('{0}', v); }
3792 activate : function() {
3793 _this.invpanel = this;
3794 if (_this.invgrid) {
3795 _this.invgrid.ds.load({});
3800 fitContainer : true,
3803 tableName : 'cobmisc',
3811 _this.invgrid = this;
3812 //_this.dialog = Pman.Dialog.FILL_IN
3813 if (_this.invpanel.active) {
3817 rowdblclick : function (_self, rowIndex, e)
3820 var ri = this.ds.getAt(rowIndex);
3821 if ( ri.data.cobmisc_id < 0) { // skip summary row..
3824 var rv = _this.form.getFieldValues();
3825 Pman.Dialog.XtupleInvoice.show({
3826 cobmisc_id : ri.data.cobmisc_id,
3827 // below parms for add credit memo
3829 cm_cust_id : rv.cohead_cust_id,
3830 cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,
3831 cm_curr_id : rv.cohead_curr_id,
3832 cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,
3833 cm_terms_id : rv.cohead_terms_id,
3834 cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,
3835 cm_salesrep_id : rv.cohead_salesrep_id,
3836 cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,
3837 cm_docdate : new Date(),
3838 cm_taxzone_id : rv.cohead_taxzone_id,
3839 cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,
3840 cm_billto_cntct_id : rv.cohead_billto_cntct_id,
3841 cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,
3842 cm_location_src : rv.cohead_location_src,
3843 cm_location_src_location_name : rv.cohead_location_src_location_name,
3844 cm_billto_address : rv.billto_address
3848 _this.invgrid.ds.load({});
3853 autoExpandColumn : 'invchead_invcnumber',
3859 beforeload : function (_self, options)
3862 options.params = options.params || {};
3863 options.params.cobmisc_cohead_id = _this.form.findField('cohead_id').getValue() * 1;
3864 if (options.params.cobmisc_cohead_id < 1) {
3868 options.params._with_other_payment = 1;
3869 //options.params['query[invchead_ordernumber]'] = _this.form.findField('cohead_number').getValue()
3872 load : function (_self, records, options)
3877 var totalfreight = 0.0;
3878 var totalmisc = 0.0;
3881 Roo.each(records, function(r)
3883 if(r.data.cobmisc_id > 1){
3884 done += parseInt(r.data.cobmisc_qty);
3885 totalic += parseFloat(r.data.cobmisc_itemcost).toFixed(2)*1;
3886 totalmisc += parseFloat(r.data.cobmisc_misc).toFixed(2)*1;
3887 totalfreight += parseFloat(r.data.cobmisc_freight).toFixed(2)*1;
3888 totaltax += parseFloat(r.data.cobmisc_tax).toFixed(2)*1;
3889 total = parseInt(r.data.cobmisc_total_qty);
3894 _this.shipinvtab.layout.getRegion('center').getPanel(0).setTitle(
3896 "Invoices (Complete)" :
3897 ("Invoices prepared for " + done + '/' + total)
3901 var frtotal = (parseFloat(_this.form.findField('cohead_freight').getValue()) - totalfreight).toFixed(2);
3902 var misctotal = (parseFloat(_this.form.findField('cohead_misc').getValue()) - totalmisc).toFixed(2);
3903 var ictotal = (parseFloat(_this.form.findField('cohead_subtotal').getValue()) - totalic).toFixed(2);
3904 var taxtotal = (parseFloat(_this.form.findField('cohead_tax').getValue()) - totaltax).toFixed(2);
3905 var remtotal = frtotal*1 + misctotal*1 + ictotal*1 + taxtotal*1;
3907 var nr = this.reader.newRow({
3909 cobmisc_invchead_id_invchead_invcnumber : "Total Remaining",
3910 cobmisc_qty : total - done,
3911 cobmisc_freight :frtotal,
3912 cobmisc_misc : misctotal,
3913 cobmisc_itemcost : ictotal,
3914 cobmisc_tax : taxtotal,
3915 cobmisc_total : remtotal
3919 // do we need to add it somehow??
3920 _this.invgrid.ds.add(nr);
3924 sortInfo : { field : 'invchead_invcnumber', direction: 'ASC' },
3929 url : baseURL + '/Roo/cobmisc.php'
3932 xtype: 'JsonReader',
3936 totalProperty : 'total',
3939 'name': 'invchead_invcnumber',
3943 'name': 'invchead_invcdate',
3960 var sel = _this.invgrid.getSelectionModel().getSelected();
3962 Roo.MessageBox.alert("Error", "Select a invoice");
3965 // check current status of shipment..
3967 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to Post that invoice?",
3974 url : baseURL + '/Roo/cobmisc',
3977 cobmisc_id : sel.data.cobmisc_id,
3980 success : function() {
3981 _this.invgrid.ds.load({});
3992 cls : 'x-btn-text-icon',
3993 text : "Post Invoice",
3994 icon : rootURL + '/Pman/templates/images/lock.gif'
3999 cls : 'x-btn-text-icon',
4001 icon : rootURL + '/Pman/templates/images/pdf.gif',
4013 var sel = _this.invgrid.getSelectionModel().getSelected();
4015 Roo.MessageBox.alert("Error", "Select a invoice");
4018 if (!sel.data.cobmisc_invchead_id) {
4019 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4022 // check current status of shipment..
4025 url : baseURL + '/Roo/invchead',
4028 invchead_id : sel.data.cobmisc_invchead_id,
4031 success : function() {
4040 text : "Print Standard Invoice"
4046 click : function (_self, e)
4049 var sel = _this.invgrid.getSelectionModel().getSelected();
4051 Roo.MessageBox.alert("Error", "Select a invoice");
4054 if (!sel.data.cobmisc_invchead_id) {
4055 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4058 // check current status of shipment..
4061 url : baseURL + '/Roo/invchead',
4064 invchead_id : sel.data.cobmisc_invchead_id,
4068 success : function() {
4076 text : "Print Chinese Invoice With GST in line item",
4077 hidden : !(baseURL.match(/(hk\.php|cn\.php)$/))
4083 click : function (_self, e)
4086 var sel = _this.invgrid.getSelectionModel().getSelected();
4088 Roo.MessageBox.alert("Error", "Select a invoice");
4091 if (!sel.data.cobmisc_invchead_id) {
4092 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4095 // check current status of shipment..
4098 url : baseURL + '/Roo/invchead',
4101 invchead_id : sel.data.cobmisc_invchead_id,
4105 success : function() {
4113 text : "Print Chinese Invoice",
4114 hidden : !(baseURL.match(/(hk\.php|cn\.php)$/))
4120 click : function (_self, e)
4123 var sel = _this.invgrid.getSelectionModel().getSelected();
4125 Roo.MessageBox.alert("Error", "Select a invoice");
4128 if (!sel.data.cobmisc_invchead_id) {
4129 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4132 // check current status of shipment..
4135 url : baseURL + '/Roo/invchead',
4138 invchead_id : sel.data.cobmisc_invchead_id,
4142 success : function() {
4150 text : "Print Aus - GST included Invoice",
4151 hidden : !(baseURL.match(/au\.php$/))
4157 click : function (_self, e)
4159 var sel = _this.invgrid.getSelectionModel().getSelected();
4161 Roo.MessageBox.alert("Error", "Select a invoice");
4164 if (!sel.data.cobmisc_invchead_id) {
4165 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4168 // check current status of shipment..
4171 url : baseURL + '/Roo/invchead',
4174 invchead_id : sel.data.cobmisc_invchead_id,
4184 text : "Print Bambini Pronto Invoice",
4185 hidden : !(baseURL.match(/au\.php$/))
4191 click : function (_self, e)
4194 var sel = _this.invgrid.getSelectionModel().getSelected();
4196 Roo.MessageBox.alert("Error", "Select a invoice");
4199 if (!sel.data.cobmisc_invchead_id) {
4200 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4203 // check current status of shipment..
4206 url : baseURL + '/Roo/invchead',
4209 invchead_id : sel.data.cobmisc_invchead_id,
4210 _print : 'au-proforma'
4213 success : function() {
4221 text : "Print Bambini Pro Forma Invoice",
4222 hidden : !(baseURL.match(/au\.php$/))
4228 click : function (_self, e)
4230 var sel = _this.invgrid.getSelectionModel().getSelected();
4232 Roo.MessageBox.alert("Error", "Select a invoice");
4236 Pman.Dialog.XtupleDiscountOfInvoice.show({invchead_id : sel.data.cobmisc_invchead_id}, function(){
4241 text : "Print Shipping / Commercial Invoice",
4242 hidden : !( baseURL.match(/au\.php$/))
4250 cls : 'x-btn-text-icon',
4251 text : "Payments / Refunds / Credit Memos",
4252 icon : Roo.rootURL + 'images/default/tree/leaf.gif',
4261 click : function(_self,e)
4264 var sel = _this.invgrid.getSelectionModel().getSelected();
4265 if (!sel || sel.data.cobmisc_id < 1) {
4266 Roo.MessageBox.alert("Error", "Select a invoice");
4269 if(!sel.data.cobmisc_posted){
4270 Roo.MessageBox.alert("Error", "This invoice has not been posted!");
4273 if(sel.data.cobmisc_outstanding == 0){
4274 Roo.MessageBox.alert("Error", "There is no any outstanding of this invoice!");
4278 var cust_id = _this.form.findField('cohead_cust_id').getValue();
4283 cashrcpt_amount : sel.data.cobmisc_outstanding,
4284 cashrcpt_cust_id : cust_id,
4285 cashrcpt_aropen_id : sel.data.cobmisc_aropen_id_aropen_id,
4286 cashrcpt_distdate : new Date(),
4287 cashrcpt_fundstype : 'C',
4288 cashrcpt_curr_id : sel.data.cobmisc_curr_id_curr_id,
4289 cashrcpt_curr_id_curr_name : sel.data.cobmisc_curr_id_curr_name,
4290 cashrcpt_usecustdeposit : true,
4291 cashrcpt_docdate : new Date(),
4292 cashrcpt_salescat_id : -1,
4293 cashrcpt_applydate : new Date(),
4294 cashrcpt_discount : 0
4296 Pman.Dialog.XtupleReceivePayment.show( data , function() {
4297 _this.invgrid.ds.load({});
4301 cls : 'x-btn-text-icon',
4302 text : "Receive Payment",
4303 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4309 click : function(_self,e)
4311 var sel = _this.invgrid.getSelectionModel().getSelected();
4312 if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {
4313 Roo.MessageBox.alert("Error", "Select a credit memo");
4316 if(!sel.data.cobmisc_posted){
4317 Roo.MessageBox.alert("Error", "The invoice that credit memo has been applied to has been not posted");
4320 var cust_id = _this.form.findField('cohead_cust_id').getValue();
4325 if(!sel.data.cobmisc_outstanding || sel.data.cobmisc_outstanding == 0){
4326 Roo.MessageBox.alert("Error", "The amount of this credit memo is 0!");
4330 var d = _this.form.getFieldValues();
4333 'checkhead_recip_id' : cust_id,
4334 'checkhead_recip_type' : 'C',
4335 'checkhead_checkdate' : new Date(),
4336 'checkhead_amount' : sel.data.cobmisc_outstanding,
4337 'remaining_total' : sel.data.cobmisc_outstanding,
4338 'checkhead_curr_id' : d.cohead_curr_id,
4339 'checkhead_curr_id_curr_name' : d.cohead_curr_id_curr_name,
4340 'checkhead_misc' : true,
4341 'aropen_id' : sel.data.cobmisc_cobapply_aropen_id,
4342 'cmhead_number' : sel.data.cobmisc_invchead_id_invchead_invcnumber,
4343 'cust_name' : d.cohead_cust_id_cust_name,
4344 '_create_and_post' : 1
4349 Pman.Dialog.XtupleMiscellaneousCheck.show( data , function() {
4350 _this.invgrid.ds.load({});
4354 cls : 'x-btn-text-icon',
4355 text : "Issue Refund",
4356 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4366 click : function(_self,e)
4368 var sel = _this.invgrid.getSelectionModel().getSelected();
4369 if (!sel || sel.data.cobmisc_cashrcpt_id * 1 < 1) {
4370 Roo.MessageBox.alert("Error", "Select a Receive Payment");
4374 Roo.MessageBox.confirm("Confirm", "Voiding receipt will mean you will have to re-enter the receipt refund - " +
4375 "please take note of the details so you can enter it again correctly later.", function(r) {
4381 url : baseURL + '/Roo/cashrcpt',
4384 cashrcpt_id : sel.data.cobmisc_cashrcpt_id,
4387 success : function()
4389 _this.invgrid.ds.load({});
4399 cls : 'x-btn-text-icon',
4400 text : "Void Payment",
4401 icon : rootURL + '/Pman/templates/images/trash.gif'
4407 click : function(_self,e)
4409 var sel = _this.invgrid.getSelectionModel().getSelected();
4410 if (!sel || sel.data.cobmisc_checkhead_id * 1 < 1) {
4411 Roo.MessageBox.alert("Error", "Select a Miscellaneours Check");
4415 Roo.MessageBox.confirm("Confirm", "Voiding refund will mean you will have to re-enter the receipt refund - " +
4416 "please take note of the details so you can enter it again correctly later.", function(r) {
4422 url : baseURL + '/Roo/checkhead',
4425 checkhead_id : sel.data.cobmisc_checkhead_id,
4428 success : function()
4430 _this.invgrid.ds.load({});
4440 cls : 'x-btn-text-icon',
4441 text : "Void Refund",
4442 icon : rootURL + '/Pman/templates/images/trash.gif'
4448 click : function(_self,e)
4450 var sel = _this.invgrid.getSelectionModel().getSelected();
4451 if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {
4452 Roo.MessageBox.alert("Error", "Select a credit memo");
4456 if(sel.data.cobmisc_posted){
4457 Roo.MessageBox.alert("Error", "You cann't void this credit memo, since the invoice that credit memo has been applied to has been posted");
4461 if (sel.data.cobmisc_cobapply_id < 1) {
4462 Roo.MessageBox.alert("Error", "invaild credit memo");
4465 Roo.MessageBox.confirm("Confirm", "Are you sure want to void this applied credit memo, " +
4466 "it will also void all the check that belongs to this credit memo ", function(r) {
4472 url : baseURL + '/Roo/cobapply',
4475 _delete : sel.data.cobmisc_cobapply_id,
4478 success : function()
4480 _this.invgrid.ds.load({});
4489 cls : 'x-btn-text-icon',
4490 text : "Void Credit Memo",
4491 icon : rootURL + '/Pman/templates/images/trash.gif'
4507 if (!_this.form.findField('cohead_id').getValue()) {
4508 Roo.MessageBox.alert("Error", "Save Order first");
4512 var rv = _this.form.getFieldValues();
4515 Pman.Dialog.XtupleInvoice.show({
4516 cobmisc_cohead_id : rv.cohead_id,
4517 cobmisc_shipdate : _this.form.findField('cohead_targetdate').getValue(),
4518 cobmisc_invcdate : _this.form.findField('cohead_targetdate').getValue(),
4519 cobmisc_curr_id : rv.cohead_curr_id,
4520 cobmisc_curr_id_curr_name : rv.cohead_curr_id_curr_name,
4521 // below parms for add credit memo
4523 cm_cust_id : rv.cohead_cust_id,
4524 cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,
4525 cm_curr_id : rv.cohead_curr_id,
4526 cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,
4527 cm_terms_id : rv.cohead_terms_id,
4528 cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,
4529 cm_salesrep_id : rv.cohead_salesrep_id,
4530 cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,
4531 cm_docdate : new Date(),
4532 cm_taxzone_id : rv.cohead_taxzone_id,
4533 cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,
4534 cm_billto_cntct_id : rv.cohead_billto_cntct_id,
4535 cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,
4536 cm_location_src : rv.cohead_location_src,
4537 cm_location_src_location_name : rv.cohead_location_src_location_name,
4538 cm_billto_address : rv.billto_address
4543 _this.invgrid.ds.load({});
4547 render : function (_self)
4549 _this.addInvoiceBtn = _self;
4552 cls : 'x-btn-text-icon',
4554 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4563 var sel = _this.invgrid.getSelectionModel().getSelected();
4565 Roo.MessageBox.alert("Error", "Select a invoice");
4568 // check current status of shipment..
4571 // cobmisc_id : sel.data.cobmisc_id,
4574 if (sel.data.cobmisc_id * 1) {
4575 params.cobmisc_id = sel.data.cobmisc_id * 1 ;
4577 if (sel.data.cobmisc_invchead_id_invchead_id * 1) {
4578 params.invchead_id = sel.data.cobmisc_invchead_id_invchead_id * 1;
4581 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to VOID that invoice?",
4588 url : baseURL + '/Roo/cobmisc',
4591 success : function() {
4592 _this.invgrid.ds.load({});
4603 cls : 'x-btn-text-icon',
4604 text : "Void / Unpost",
4605 icon : rootURL + '/Pman/templates/images/trash.gif'
4611 xtype: 'ColumnModel',
4613 dataIndex : 'cobmisc_invchead_id_invchead_invcnumber',
4614 header : 'Invoice #',
4616 renderer : function(v,x,r) {
4618 r.data.cobmisc_invchead_id_invchead_id * 1 &&
4619 !r.data.cobmisc_invchead_id_invchead_posted) {
4620 return '<span style="color:red">' +
4621 "NEEDS Voiding then re-posted: " +
4622 String.format('{0}', v) +
4626 if(v && r.data.cobmisc_id == -2){
4627 return String.format('<span style="margin-left: 10px;"> - {0} (Credit Memo)</span>', v);
4629 if(v && r.data.cobmisc_id == -3){
4630 return String.format('<span style="margin-left: 20px;"> - {0} (Miscellaneous Check)</span>', v);
4632 if(v && r.data.cobmisc_id == -4){
4633 return String.format('<span style="margin-left: 10px;"> - {0} (Receive Payment) [ {1} ]</span>', v, r.data.cobmisc_cashrcpt_amount);
4636 return v ? String.format('{0}', v) :
4637 '<span style="color:red">' + "Not Posted" + '</span>';
4641 xtype: 'ColumnModel',
4643 dataIndex : 'cobmisc_invcdate',
4644 header : 'invcdate',
4646 renderer : function(v,x,r) {
4648 return String.format('{0}', v && r.data.cobmisc_id > 0 ? v.format('d/M/Y') : '');
4652 xtype: 'ColumnModel',
4655 dataIndex : 'cobmisc_qty',
4658 renderer : function(v) { return String.format('{0}', v ? parseInt(v) : 0); }
4661 xtype: 'ColumnModel',
4664 dataIndex : 'cobmisc_itemcost',
4665 header : 'Item Cost',
4667 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }
4670 xtype: 'ColumnModel',
4673 dataIndex : 'cobmisc_freight',
4674 header : 'Shipping',
4676 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : ''); }
4679 xtype: 'ColumnModel',
4682 dataIndex : 'cobmisc_tax',
4685 renderer : function(v,x,r) {
4687 // tax is based on the % itemcost..
4688 // var ic = r.data.cobmisc_itemcost;
4690 var ic =r.data.cobmisc_itemcost - (1* r.data.cobmisc_itemcost_taxfree);
4692 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
4693 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
4697 var taxp = tax / totic;
4700 return String.format('{0}', (1.0*v).toFixed(2) );
4706 xtype: 'ColumnModel',
4709 dataIndex : 'cobmisc_cohead_id_cohead_pretax_discount',
4710 header : 'Discount (Pretax)',
4712 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }
4715 xtype: 'ColumnModel',
4718 dataIndex : 'cobmisc_misc',
4719 header : 'Discount (Posttax)',
4721 renderer : function(v,x,r)
4723 var vv = v - r.data.cobmisc_cohead_id_cohead_pretax_discount;
4725 return String.format('{0}', vv ? (1.0*vv).toFixed(2) : 0);
4729 xtype: 'ColumnModel',
4732 dataIndex : 'cobmisc_total',
4735 renderer : function(v,x,r) {
4738 var ic = r.data.cobmisc_itemcost;
4739 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
4740 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
4743 var taxp = tax / totic;
4751 return String.format('{0}',(v * 1.0).toFixed(2) );
4755 return String.format('{0}',
4756 ((d.cobmisc_itemcost * 1.0) +
4757 (d.cobmisc_freight * 1.0) +
4758 (d.cobmisc_tax * 1.0) +
4759 (d.cobmisc_misc * 1.0)
4765 xtype: 'ColumnModel',
4768 dataIndex : 'cobmisc_outstanding',
4769 header : 'Outstanding',
4771 renderer : function(v,x,r)
4774 return String.format('{0}', v ? (v * 1.0).toFixed(2) : 0 );
4782 xtype: 'LayoutRegion',
4787 xtype: 'LayoutRegion',
4790 title : "Reserve Stock / Shipments"
4798 activate : function() {
4799 _this.hpanel = this;
4801 _this.hgrid.footer.onClick('first');
4806 fitContainer : true,
4809 tableName : 'events',
4818 //_this.dialog = Pman.Dialog.FILL_IN
4819 if (_this.hpanel.active) {
4820 this.footer.onClick('first');
4823 rowdblclick : function (_self, rowIndex, e)
4825 if (!_this.dialog) return;
4826 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
4827 _this.grid.footer.onClick('first');
4831 autoExpandColumn : 'remarks',
4837 beforeload : function (_self, options)
4839 options.params._related_on_table = 'cohead';
4840 options.params._related_on_id = _this.form.findField('cohead_id').getValue();
4844 sortInfo : { field : 'event_when', direction: 'DESC' },
4849 url : baseURL + '/Roo/events.php'
4852 xtype: 'JsonReader',
4856 totalProperty : 'total',
4859 'name': 'event_when',
4871 'name': 'person_id_name',
4882 xtype: 'PagingToolbar',
4886 displayMsg : "Displaying events{0} - {1} of {2}",
4887 emptyMsg : "No events found"
4891 xtype: 'ColumnModel',
4893 dataIndex : 'event_when',
4896 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); }
4899 xtype: 'ColumnModel',
4901 dataIndex : 'action',
4904 renderer : function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); }
4907 xtype: 'ColumnModel',
4909 dataIndex : 'ipaddr',
4910 header : 'IP address',
4912 renderer : function(v) { return String.format('{0}', v); }
4915 xtype: 'ColumnModel',
4917 dataIndex : 'person_id_name',
4920 renderer : function(v) { return String.format('{0}', v); }
4923 xtype: 'ColumnModel',
4925 dataIndex : 'remarks',
4928 renderer : function(v) { return String.format('{0}', v); }
4934 xtype: 'NestedLayoutPanel',
4939 xtype: 'BorderLayout',
4946 activate : function() {
4947 _this.txpanel = this;
4949 _this.txgrid.footer.onClick('first');
4954 fitContainer : true,
4957 tableName : 'invdetail',
4958 title : "invdetail",
4965 _this.txgrid = this;
4966 //_this.dialog = Pman.Dialog.FILL_IN
4967 if (_this.txpanel.active) {
4968 this.footer.onClick('first');
4972 autoExpandColumn : 'item_number',
4982 click : function (_self, e)
4986 url : baseURL + '/Roo/Cohead',
4989 _apply_fifo : _this.form.findField('cohead_id').getValue()
4991 success : function () {
4992 Roo.MessageBox.alert("Applied", "Succesfully Applied");
4997 text : "Run Apply Fifo on order"
5003 click : function (_self, e)
5007 url : baseURL + '/Roo/Cohead',
5010 _run_void_fix : _this.form.findField('cohead_id').getValue()
5012 success : function () {
5013 Roo.MessageBox.alert("Applied", "Succesfully Run");
5018 text : "Run Void flagger"
5024 click : function (_self, e)
5029 url : baseURL + '/Roo/Invdetail',
5034 _reverse_all_bad : _this.form.findField('cohead_id').getValue()
5036 success : function () {
5037 Roo.MessageBox.alert("Applied", "Succesfully Run");
5042 text : "Auto Reverse"
5047 xtype: 'RowSelectionModel',
5050 selectionchange : function (_self)
5052 _this.txdgrid.footer.onClick('first');;
5061 beforeload : function (_self, o)
5063 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5064 if (! o.params.cohead_id ) {
5071 sortInfo : { field : 'item_number', direction: 'ASC' },
5076 url : baseURL + '/Roo/invdetail.php'
5079 xtype: 'JsonReader',
5081 totalProperty : 'total',
5086 'name': 'invdetail_id',
5090 'name': 'invdetail_transtype',
5094 'name': 'invdetail_invhist_id',
5098 'name': 'invdetail_location_id',
5102 'name': 'invdetail_qty',
5106 'name': 'invdetail_comments',
5110 'name': 'invdetail_qty_before',
5114 'name': 'invdetail_qty_after',
5118 'name': 'invdetail_invcitem_id',
5122 'name': 'invdetail_expiration',
5124 'dateFormat': 'Y-m-d'
5127 'name': 'invdetail_warrpurc',
5129 'dateFormat': 'Y-m-d'
5132 'name': 'invdetail_ls_id',
5139 xtype: 'PagingToolbar',
5142 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5143 emptyMsg : "No invdetail found",
5148 xtype: 'ColumnModel',
5150 dataIndex : 'item_number',
5153 renderer : function(v) { return String.format('{0}', v); }
5156 xtype: 'ColumnModel',
5159 dataIndex : 'rec_shipped',
5162 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5165 xtype: 'ColumnModel',
5168 dataIndex : 'rec_returned',
5171 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5174 xtype: 'ColumnModel',
5177 dataIndex : 'tx_shipped',
5178 header : '#TX ship',
5180 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5183 xtype: 'ColumnModel',
5186 dataIndex : 'tx_returned',
5189 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5192 xtype: 'ColumnModel',
5195 dataIndex : 'tx_total',
5198 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5201 xtype: 'ColumnModel',
5204 dataIndex : 'total_value',
5207 renderer : function(v,x,r) {
5209 return (v*1).toFixed(3);
5213 xtype: 'ColumnModel',
5216 dataIndex : 'tx_total',
5219 renderer : function(v,x,r) {
5221 var cototal = (r.data.rec_returned*1) - (r.data.rec_shipped*1);
5222 // Roo.log(cototal);
5223 var diff = (v*1) - cototal;
5228 return String.format('<span style="color:red">{0}</span>', diff );
5238 activate : function() {
5239 _this.txdpanel = this;
5240 if (_this.txdgrid) {
5241 _this.txdgrid.footer.onClick('first');
5246 fitContainer : true,
5249 tableName : 'invdetail',
5250 title : "invdetail",
5257 _this.txdgrid = this;
5258 //_this.dialog = Pman.Dialog.FILL_IN
5259 if (_this.txdpanel.active) {
5260 this.footer.onClick('first');
5263 rowclick : function (_self, rowIndex, e)
5265 var s = _this.txdgrid.ds.getAt(rowIndex);
5266 var dt = s.data.invhist_transdate.split(' ');
5268 _this.dateSel.setValue(new Date(dt[0]));
5271 autoExpandColumn : 'invhist_comments',
5281 click : function (_self, e)
5283 var s = _this.txdgrid.selModel.getSelected();
5286 Roo.MessageBox.alert("Error", "Select a transaction");
5290 var reverseSel = function() {
5294 url : baseURL + '/Roo/invdetail',
5297 _duplicate : s.data.invdetail_id
5299 success : function() {
5300 _this.txdgrid.footer.onClick('first');
5308 Roo.MessageBox.confirm(
5310 "This should only be used by System Administrators - are you sure you know what you are doing!",
5324 text : "Duplicate Selected"
5339 render : function (_self)
5341 _this.dateSel = _self;
5345 fieldLabel : 'Issue Date',
5347 name : 'issue_date',
5354 click : function (_self, e)
5356 var s = _this.txdgrid.selModel.getSelected();
5357 var dt = _this.dateSel.getValue();
5359 Roo.MessageBox.alert("Error", "Select a transaction");
5363 var reverseSel = function(force) {
5367 url : baseURL + '/Roo/invdetail',
5370 _reverse : s.data.invdetail_id,
5371 _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
5374 success : function() {
5375 _this.txdgrid.footer.onClick('first');
5377 failure : function(res) {
5380 if (res.errors.confirm) {
5382 Roo.MessageBox.confirm(
5384 "are you really sure the totals will get messed up.",
5395 Roo.MessageBox.alert("Error", res.errorMsg);
5405 Roo.MessageBox.confirm(
5407 "This should only be used by System Administrators - are you sure you know what you are doing!",
5421 text : "Reverse Selected"
5429 beforeload : function (_self, o)
5431 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5432 var s = _this.txgrid.selModel.getSelected();
5437 o.params.itemsite_id = s.data.invhist_itemsite_id;
5442 sortInfo : { field : 'invdetail_id', direction: 'ASC' },
5447 url : baseURL + '/Roo/invdetail.php'
5450 xtype: 'JsonReader',
5452 totalProperty : 'total',
5457 'name': 'invdetail_id',
5461 'name': 'invdetail_transtype',
5465 'name': 'invdetail_invhist_id',
5469 'name': 'invdetail_location_id',
5473 'name': 'invdetail_qty',
5477 'name': 'invdetail_comments',
5481 'name': 'invdetail_qty_before',
5485 'name': 'invdetail_qty_after',
5489 'name': 'invdetail_invcitem_id',
5493 'name': 'invdetail_expiration',
5495 'dateFormat': 'Y-m-d'
5498 'name': 'invdetail_warrpurc',
5500 'dateFormat': 'Y-m-d'
5503 'name': 'invdetail_ls_id',
5510 xtype: 'PagingToolbar',
5513 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5514 emptyMsg : "No invdetail found",
5519 xtype: 'ColumnModel',
5521 dataIndex : 'invdetail_id',
5524 renderer : function(v) { return String.format('{0}', v); }
5527 xtype: 'ColumnModel',
5529 dataIndex : 'invhist_transdate',
5532 renderer : function(v) { return String.format('{0}', v); }
5535 xtype: 'ColumnModel',
5537 dataIndex : 'invhist_ordnumber',
5540 renderer : function(v,x,r) {
5541 if (r.data.invfifo_void *1 != 0) {
5542 return String.format('<s>{0}</s>', v);
5545 return String.format('{0}', v);
5549 xtype: 'ColumnModel',
5551 dataIndex : 'invhist_comments',
5554 renderer : function(v) { return String.format('{0}', v); }
5557 xtype: 'ColumnModel',
5560 dataIndex : 'invdetail_qty',
5561 header : 'Qty Changed',
5563 renderer : function(v,x,r) {
5564 if ( r.data.coitem_shipped != v) {
5565 return String.format('{0} <span style="color:red">({1})</span>',
5566 Roo.util.Format.number(v,0),
5567 r.data.coitem_shipped
5571 return String.format('{0}', Roo.util.Format.number(v,0));
5575 xtype: 'ColumnModel',
5578 dataIndex : 'invhist_value_before',
5579 header : 'Qty Changed',
5581 renderer : function(v,x,r) {
5582 var tot = r.data.invhist_value_after*1 - v*1;
5584 if (r.data.invdetail_qty >0 && tot < 0) {
5585 f = '<span style="color:red">{0}</span>';
5587 if (r.data.invdetail_qty < 0 && tot > 0) {
5588 f = '<span style="color:red">{0}</span>';
5590 return String.format(f, Roo.util.Format.number(tot));
5594 xtype: 'ColumnModel',
5596 dataIndex : 'invhist_posted',
5599 renderer : function(v,x,r) {
5601 var state = v ? '-checked' : '';
5603 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
5611 xtype: 'LayoutRegion',
5615 xtype: 'LayoutRegion',
5623 xtype: 'NestedLayoutPanel',
5628 xtype: 'BorderLayout',
5635 activate : function() {
5636 _this.gltxpanel = this;
5637 if (_this.gltxgrid) {
5638 _this.gltxgrid.footer.onClick('first');
5643 fitContainer : true,
5646 tableName : 'invdetail',
5647 title : "invdetail",
5654 _this.gltxgrid = this;
5655 //_this.dialog = Pman.Dialog.FILL_IN
5656 if (_this.gltxpanel.active) {
5657 this.footer.onClick('first');
5660 cellclick : function (_self, rowIndex, columnIndex, e)
5662 if (columnIndex > 0) {
5665 var rec = this.ds.getAt(rowIndex);
5666 rec.set('gltrans_as_summary', rec.data.gltrans_as_summary *1 ? 0 : 1);
5667 _this.gltxdgrid.footer.onClick('first');
5670 autoExpandColumn : 'gltrans_accnt_id_accnt_descrip',
5673 xtype: 'RowSelectionModel',
5676 selectionchange : function (_self)
5678 _this.gltxdgrid.footer.onClick('first');;
5687 beforeload : function (_self, o)
5689 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5690 if (! o.params.cohead_id ) {
5694 o.params._split_sales = _this.glsalesbtn.pressed ? 1 : 0;
5698 sortInfo : { field : 'item_number', direction: 'ASC' },
5703 url : baseURL + '/Roo/gltrans.php'
5706 xtype: 'JsonReader',
5708 totalProperty : 'total',
5713 'name': 'invdetail_id',
5717 'name': 'invdetail_transtype',
5721 'name': 'invdetail_invhist_id',
5725 'name': 'invdetail_location_id',
5729 'name': 'invdetail_qty',
5733 'name': 'invdetail_comments',
5737 'name': 'invdetail_qty_before',
5741 'name': 'invdetail_qty_after',
5745 'name': 'invdetail_invcitem_id',
5749 'name': 'invdetail_expiration',
5751 'dateFormat': 'Y-m-d'
5754 'name': 'invdetail_warrpurc',
5756 'dateFormat': 'Y-m-d'
5759 'name': 'invdetail_ls_id',
5766 xtype: 'PagingToolbar',
5769 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5770 emptyMsg : "No invdetail found",
5777 render : function (_self)
5779 _this.glsalesbtn = _self;
5781 click : function (_self, e)
5783 (function() { _this.gltxgrid.footer.onClick('first'); }).defer(100);
5786 enableToggle : true,
5788 text : "Split sales"
5794 xtype: 'ColumnModel',
5796 dataIndex : 'gltrans_as_summary',
5799 renderer : function(v,x,r) {
5801 var state = v*1 ? '-checked' : '';
5803 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
5807 xtype: 'ColumnModel',
5809 dataIndex : 'gltrans_accnt_id_accnt_descrip',
5812 renderer : function(v) { return String.format('{0}', v); }
5815 xtype: 'ColumnModel',
5818 dataIndex : 'gltrans_amount_credit',
5821 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
5824 xtype: 'ColumnModel',
5827 dataIndex : 'gltrans_amount_debit',
5830 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
5833 xtype: 'ColumnModel',
5836 dataIndex : 'gltrans_amount_total',
5839 renderer : function(v) { return String.format('<b>{0}</b>', Roo.util.Format.number(v,3)); }
5842 xtype: 'ColumnModel',
5845 dataIndex : 'gltrans_amount_total_unposted',
5846 header : 'Unposted',
5848 renderer : function(v) { return String.format('<span style="color:red">{0}</span>', Roo.util.Format.number(v,3)); }
5857 activate : function() {
5858 _this.gltxdpanel = this;
5859 if (_this.gltxdgrid) {
5860 _this.gltxdgrid.footer.onClick('first');
5865 fitContainer : true,
5868 tableName : 'invdetail',
5869 title : "invdetail",
5876 _this.gltxdgrid = this;
5877 //_this.dialog = Pman.Dialog.FILL_IN
5878 if (_this.gltxdpanel.active) {
5879 this.footer.onClick('first');
5882 cellclick : function (_self, ri, ci, e)
5885 var deleteSel = function() {
5889 url : baseURL + '/Roo/gltrans',
5893 gltrans_id : rec.data.gltrans_id
5896 success : function() {
5897 rec.set('gltrans_posted', false);
5898 rec.set('gltrans_deleted', true);
5899 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
5900 _this.gltxgrid.footer.onClick('first');
5905 var undeleteSel = function() {
5909 url : baseURL + '/Roo/gltrans',
5913 gltrans_id : rec.data.gltrans_id
5916 success : function() {
5917 rec.set('gltrans_posted', true);
5918 rec.set('gltrans_deleted', false);
5919 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
5920 _this.gltxgrid.footer.onClick('first');
5926 var di = this.colModel.config[ci].dataIndex;
5927 if (di != 'gltrans_posted') {
5933 var rec = this.ds.getAt(ri);
5934 if (rec.data.gltrans_deleted) {
5936 Roo.MessageBox.confirm(
5938 "This should only be used by System Administrators - are you sure you know what you are doing!",
5952 if (!rec.data.gltrans_posted) {
5958 url : baseURL + '/Roo/gltrans',
5962 gltrans_id : rec.data.gltrans_id
5964 success : function (res)
5966 rec.set('gltrans_posted', true);
5967 _this.gltxgrid.footer.onClick('first');
5976 // we have a posted transaction.
5977 // only allow recalled to be deleted..
5978 if (!rec.data.gltrans_notes.match(/(Recall|Ship Order)/)) {
5987 Roo.MessageBox.confirm(
5989 "This should only be used by System Administrators - are you sure you know what you are doing!",
6002 autoExpandColumn : 'gltrans_notes',
6008 beforeload : function (_self, o)
6010 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
6011 var s = _this.gltxgrid.selModel.getSelected();
6016 o.params.gltrans_accnt_id = s.data.gltrans_accnt_id;
6017 o.params.gltrans_is_ship = s.data.gltrans_is_ship;
6018 o.params.gltrans_as_summary = s.data.gltrans_as_summary;
6024 sortInfo : { field : 'gltrans_docnumber', direction: 'ASC' },
6029 url : baseURL + '/Roo/gltrans.php'
6032 xtype: 'JsonReader',
6034 totalProperty : 'total',
6039 'name': 'invdetail_id',
6043 'name': 'invdetail_transtype',
6047 'name': 'invdetail_invhist_id',
6051 'name': 'invdetail_location_id',
6055 'name': 'invdetail_qty',
6059 'name': 'invdetail_comments',
6063 'name': 'invdetail_qty_before',
6067 'name': 'invdetail_qty_after',
6071 'name': 'invdetail_invcitem_id',
6075 'name': 'invdetail_expiration',
6077 'dateFormat': 'Y-m-d'
6080 'name': 'invdetail_warrpurc',
6082 'dateFormat': 'Y-m-d'
6085 'name': 'invdetail_ls_id',
6092 xtype: 'PagingToolbar',
6095 displayMsg : "Displaying invdetail{0} - {1} of {2}",
6096 emptyMsg : "No invdetail found",
6103 click : function (_self, e)
6105 new Pman.Download( {
6106 grid : _this.gltxdgrid
6117 xtype: 'ColumnModel',
6119 dataIndex : 'gltrans_id',
6123 renderer : function(v) { return String.format('{0}', v ); }
6126 xtype: 'ColumnModel',
6128 dataIndex : 'gltrans_date',
6131 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
6134 xtype: 'ColumnModel',
6136 dataIndex : 'gltrans_docnumber',
6139 renderer : function(v,x,r) {
6140 if (r.data.gltrans_deleted) {
6141 return String.format('<s>{0}</s>', v);
6143 return String.format('{0}', v);
6147 xtype: 'ColumnModel',
6149 dataIndex : 'gltrans_source',
6152 renderer : function(v) { return String.format('{0}', v); }
6155 xtype: 'ColumnModel',
6157 dataIndex : 'gltrans_notes',
6160 renderer : function(v) { return String.format('{0}', v); }
6163 xtype: 'ColumnModel',
6166 dataIndex : 'gltrans_amount',
6169 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
6172 xtype: 'ColumnModel',
6174 dataIndex : 'gltrans_posted',
6177 renderer : function(v,x,r) {
6179 var state = v ? '-checked' : '';
6181 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
6189 xtype: 'LayoutRegion',
6193 xtype: 'LayoutRegion',
6204 activate : function() {
6205 _this.profitpanel = this;
6207 try { if (MODULE.isBuilder) {
6211 var id = _this.form.findField('cohead_id').getValue() * 1;
6213 Roo.MessageBox.alert("Save First", "Save the order first, before adding items");
6214 _this.dialog.layout.getRegion('center').showPanel(0);
6218 if (_this.profitgrid) {
6219 _this.profitgrid.footer.onClick('first');
6225 fitContainer : true,
6228 tableName : 'coitem',
6236 _this.profitgrid = this;
6237 //_this.dialog = Pman.Dialog.FILL_IN
6238 if (_this.profitpanel.active) {
6239 this.footer.onClick('first');
6243 autoExpandColumn : 'item_number',
6249 beforeload : function (_self,o) {
6256 if (!_this.data || !_this.data.cohead_id) {
6259 o.params = o.params || {};
6261 o.params.coitem_cohead_id = _this.data.cohead_id;
6262 o.params._without_list_discount =1;
6263 o.params._with_profit = 1;
6268 sortInfo : { field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' },
6273 url : baseURL + '/Roo/coitem.php'
6276 xtype: 'JsonReader',
6278 totalProperty : 'total',
6299 'name': 'leader_id',
6303 'name': 'leader_office_id',
6307 'name': 'leader_name',
6311 'name': 'leader_phone',
6315 'name': 'leader_fax',
6319 'name': 'leader_email',
6323 'name': 'leader_company_id',
6327 'name': 'leader_role',
6331 'name': 'leader_active',
6335 'name': 'leader_remarks',
6339 'name': 'leader_passwd',
6343 'name': 'leader_owner_id',
6347 'name': 'leader_lang',
6351 'name': 'leader_no_reset_sent',
6355 'name': 'leader_action_type',
6359 'name': 'leader_project_id',
6363 'name': 'leader_deleted_by',
6367 'name': 'leader_deleted_dt',
6371 'name': 'leader_firstname',
6375 'name': 'leader_lastname',
6379 'name': 'leader_name_facebook',
6383 'name': 'leader_url_blog',
6387 'name': 'leader_url_twitter',
6391 'name': 'leader_url_linkedin',
6395 'name': 'leader_crm_lead_percentage',
6399 'name': 'leader_crm_industry_id',
6403 'name': 'leader_crm_updated_action_id',
6407 'name': 'leader_crm_created_action_id',
6411 'name': 'leader_crm_type_id',
6418 xtype: 'PagingToolbar',
6421 displayMsg : "Displaying coitem{0} - {1} of {2}",
6422 emptyMsg : "No coitem found",
6427 xtype: 'ColumnModel',
6429 dataIndex : 'item_number',
6430 header : 'Item Code',
6432 renderer : function(v) { return String.format('{0}', v); }
6435 xtype: 'ColumnModel',
6437 dataIndex : 'calc_subtotal',
6438 header : 'SubTotal',
6440 renderer : function(v) {
6443 return Roo.util.Format.number( v, 2);
6447 xtype: 'ColumnModel',
6449 dataIndex : 'calc_cost_total',
6450 header : 'Cost of goods',
6452 renderer : function(v) {
6454 return Roo.util.Format.number( v, 2);
6458 xtype: 'ColumnModel',
6460 dataIndex : 'profit',
6463 renderer : function(v,x,r) {
6465 var profit = r.data.calc_subtotal - r.data.calc_cost_total;
6467 if(parseInt(profit) < 1){
6468 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(profit,2));
6472 return Roo.util.Format.number( profit, 2);
6480 xtype: 'LayoutRegion',
6482 alwaysShowTabs : true,
6483 tabPosition : 'top',
6498 var id = 1* _this.form.findField('cohead_id').getValue();
6500 Roo.MessageBox.alert("Error", "Save Sales order first");
6504 // check current status of shipment..
6507 url : baseURL + '/Roo/cohead',
6513 success : function() {
6522 cls : 'x-btn-text-icon',
6523 text : "Download Excel",
6524 icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
6532 var id = 1* _this.form.findField('cohead_id').getValue();
6534 Roo.MessageBox.alert("Error", "Save Sales order first");
6538 // check current status of shipment..
6541 url : baseURL + '/Roo/cohead',
6547 success : function() {
6556 cls : 'x-btn-text-icon',
6558 icon : rootURL + '/Pman/templates/images/pdf.gif'
6564 click : function (_self, e)
6567 _this.addShipmentBtn.fireEvent('click');
6571 cls : 'x-btn-text-icon',
6573 text : "Add Shipment",
6574 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6580 click : function (_self, e)
6583 Pman.Dialog.XtupleCustomer.show({
6584 cust_id : _this.form.findField('cohead_cust_id').getValue()
6588 cls : 'x-btn-text-icon',
6589 text : "Edit Customer",
6590 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6596 click : function (_self, e)
6599 _this.addInvoiceBtn.fireEvent('click');
6603 cls : 'x-btn-text-icon',
6605 text : "Add Invoice",
6606 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6612 render : function (_self, e)
6614 _this.voidBtn = _self;
6616 click : function (_self, e)
6619 cohead_id : _this.form.findField('cohead_id').getValue()
6626 url: baseURL + '/Roo/cohead',
6629 success : function()
6632 if ( _this.data.cohead_status == 'X') {
6633 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
6639 _this.dialog.hide();
6645 if (_this.data.cohead_status == 'X') {
6651 Roo.MessageBox.confirm("Confirm", "Are you sure you want to void this?", function(r) {
6670 click : function (_self, e)
6672 var p = { cohead_id : _this.form.findField('cohead_id').getValue() };
6675 if (_this.data.cohead_status == 'C') {
6683 url: baseURL + '/Roo/cohead',
6687 success : function()
6691 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
6696 _this.dialog.hide();
6701 render : function (_self)
6703 _this.closeBtn = _self;
6716 click : function (_self, e)
6718 if (_this.grid) _this.grid.stopEditing();
6719 _this.dialog.hide();
6728 click : function (_self, e)
6732 if (_this.grid) _this.grid.stopEditing();
6734 _this.form.doAction("submit");
6737 render : function (_self)
6739 _this.saveBtn = _self;