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 if (_this.data.cohead_id) {
88 this.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
92 _this.dialog.setTitle("Edit New Sales Order");
94 _this.closeBtn.hide();
98 if(_this.data.cohead_billto_cntct_id_cntct_id){
99 _this.form.findField('billto_address').update();
101 _this.form.setValues({
\r
102 cohead_billto_cntct_id: _this.data.cohead_billto_cntct_id_cntct_id,
\r
103 cohead_billto_cntct_id_cntct_name : _this.data.cohead_billto_cntct_id_cntct_name,
\r
112 if (action.type == 'load') {
115 _this.data = action.result.data;
117 if (!_this.data.cohead_shipto_id && _this.data.shipto_id*1 > 0) {
118 _this.form.findField('cohead_shipto_id').setValue(_this.data.shipto_id);
119 _this.form.findField('cohead_shipto_id_shipto_name').setValue(_this.data.cohead_shipto_cntct_id_cntct_name);
124 _this.dataloading = true;
125 if (_this.data.cohead_shipto_cntct_id == _this.data.cohead_billto_cntct_id) {
126 this.findField('_shipto_same').setValue(1);
127 Roo.log("set shipto 1");
129 this.findField('_shipto_same').setValue(0);
130 Roo.log("set shipto 0");
132 _this.dataloading = false;
135 this.findField('billto_address').update();
136 this.findField('shipto_address').update();
137 _this.dialog.setTitle("Edit Sales Order - " + this.findField('cohead_number').getValue());
140 if (_this.data.cohead_status == 'C') {
141 _this.closeBtn.show();
142 _this.closeBtn.setText('Re-open');
143 _this.voidBtn.hide();
144 _this.saveBtn.hide();
145 } else if (_this.data.cohead_status == 'X') {
146 _this.closeBtn.hide();
147 _this.voidBtn.show();
148 _this.voidBtn.setText("Un-void / Re-open");
149 _this.saveBtn.hide();
152 _this.closeBtn.show();
153 _this.closeBtn.setText('Complete and Close');
154 _this.voidBtn.setText("Void");
155 _this.voidBtn.show();
156 _this.saveBtn.show();
159 _this.form.findField('cohead_misc_per').update();
161 // finally override the value for discount...
162 if ((''+ _this.data.cohead_misc_descrip).length) {
163 _this.form.findField('cohead_misc_descrip').setValue(_this.data.cohead_misc_descrip);
166 // update the stockcache...
169 url : baseURL + '/Roo/cohead',
172 _stockLevel : _this.data.cohead_id
174 success : function(res)
176 for (var i in res.data) {
178 if(typeof(_this.stockcache[res.data[i].item]) == 'undefined'){
179 _this.stockcache[res.data[i].item] = res.data[i];
187 if (action.type =='submit') {
190 var id = _this.form.findField('cohead_id').getValue() * 1;
193 _this.data.cohead_id = action.result.data.cohead_id;
194 this.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
200 if (_this.callback) {
201 _this.callback.call(_this, _this.form.getValues());
207 rendered : function (form)
211 actionfailed : function (_self, action)
213 if (action.failureType == 'client') {
214 Roo.MessageBox.alert("Error", "Fill in all the required fields");
216 if (action.failureType == 'server') {
218 Roo.MessageBox.alert("Error", action.result.errorMsg);
220 _this.dialog.layout.getRegion('center').showPanel(0);
224 style : 'margin:10px;',
225 url : baseURL + '/Roo/cohead.php',
237 style : 'width:420px',
255 emptyText : "Automatic",
256 fieldLabel : 'Order#',
257 name : 'cohead_number',
265 style : 'float:left',
272 fieldLabel : 'Cust#',
273 name : 'cohead_cust_id_cust_number',
285 fieldLabel : 'Customer',
286 forceSelection : true,
287 hiddenName : 'cohead_cust_id',
289 loadingText : "Searching...",
291 name : 'cohead_cust_id_cust_name',
293 qtip : "Select custinfo",
294 queryParam : 'query[cust_name]',
296 selectOnFocus : true,
297 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> </div>',
298 triggerAction : 'all',
300 valueField : 'cust_id',
306 fieldLabel : 'Customer PO#',
307 name : 'cohead_custponumber',
314 fieldLabel : 'Ordered',
316 name : 'cohead_orderdate',
329 fieldLabel : 'Target Delivery',
331 name : 'cohead_targetdate',
343 check : function (_self, checked)
346 _this.form.findField('cohead_targetdate').setValue(_this.form.findField('cohead_orderdate').getValue());
350 boxLabel : 'same as order',
352 name : '_same_as_order'
362 displayField : 'location_name',
364 emptyText : "Supply From",
365 fieldLabel : 'Supply From',
366 forceSelection : true,
367 hiddenName : 'cohead_location_src',
369 loadingText : "Searching...",
371 name : 'cohead_location_src_location_name',
373 qtip : "Select terms",
374 queryParam : 'query[location_name]',
375 selectOnFocus : true,
376 tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> {location_descrip} </div>',
377 triggerAction : 'all',
379 valueField : 'location_id',
385 beforeload : function (_self, o){
386 o.params = o.params || {};
388 o.params.location_netable = 1;
389 o.params.location_restrict = 0;
390 o.params._notinternalcompany = 1;
394 sortInfo : { direction : 'ASC', field: 'location_name' },
399 url : baseURL + '/Roo/location.php'
406 totalProperty : 'total',
407 fields : [{"name":"location_id","type":"int"},"location_name"]
420 style : 'width:420px',
433 emptyText : "Select terms",
434 forceSelection : true,
436 loadingText : "Searching...",
439 qtip : "Select terms",
440 selectOnFocus : true,
441 triggerAction : 'all',
444 tpl : '<div class="x-grid-cell-text x-btn button"><b>{terms_descrip}</b> </div>',
445 queryParam : 'query[terms_descrip]',
446 fieldLabel : 'Terms',
447 valueField : 'terms_id',
448 displayField : 'terms_descrip',
449 hiddenName : 'cohead_terms_id',
450 name : 'cohead_terms_id_terms_descrip',
455 beforeload : function (_self, o){
456 o.params = o.params || {};
461 sortInfo : { direction : 'ASC', field: 'terms_descrip' },
466 url : baseURL + '/Roo/terms.php'
473 totalProperty : 'total',
474 fields : [{"name":"terms_id","type":"int"},"terms_descrip"]
483 displayField : 'salesrep_name',
485 emptyText : "Select salesrep",
486 fieldLabel : 'Sales Rep',
487 forceSelection : true,
488 hiddenName : 'cohead_display_salesrep_id',
490 loadingText : "Searching...",
492 name : 'cohead_display_salesrep_id_salesrep_name',
494 qtip : "Select salesrep",
495 queryParam : 'query[salesrep_name]',
496 selectOnFocus : true,
497 tpl : '<div class="x-grid-cell-text x-btn button"><b>{salesrep_name}</b> </div>',
498 triggerAction : 'all',
500 valueField : 'salesrep_id',
506 beforeload : function (_self, o){
507 o.params = o.params || {};
512 sortInfo : { direction : 'ASC', field: 'salesrep_name' },
517 url : baseURL + '/Roo/salesrep.php'
524 totalProperty : 'total',
525 fields : [{"name":"salesrep_id","type":"int"},"salesrep_name"]
534 displayField : 'salesrep_name',
536 emptyText : "Select Staff",
537 fieldLabel : 'Staff I.C.',
538 forceSelection : true,
539 hiddenName : 'cohead_salesrep_id',
541 loadingText : "Searching...",
543 name : 'cohead_salesrep_id_salesrep_name',
545 qtip : "Select salesrep",
546 queryParam : 'query[salesrep_name]',
547 selectOnFocus : true,
548 tpl : '<div class="x-grid-cell-text x-btn button"><b>{salesrep_name}</b> </div>',
549 triggerAction : 'all',
551 valueField : 'salesrep_id',
557 beforeload : function (_self, o){
558 o.params = o.params || {};
563 sortInfo : { direction : 'ASC', field: 'salesrep_name' },
568 url : baseURL + '/Roo/salesrep.php'
575 totalProperty : 'total',
576 fields : [{"name":"salesrep_id","type":"int"},"salesrep_name"]
583 fieldLabel : 'Order Comments',
585 name : 'cohead_ordercomments',
595 style : 'width:420px',
608 beforeselect : function (combo, record, index)
610 // set _this.data values ..
612 // just add everything...
613 for(var i in record.data) {
614 Roo.log('cohead_billto_cntct_id_' + i +' =' + record.data[i]);
615 _this.data['cohead_billto_cntct_id_' + i] = record.data[i];
618 _this.form.findField('billto_address').update();
622 add : function (combo)
625 Pman.Dialog.XtupleQuickContact.show(
628 customer_id : _this.form.findField('cohead_cust_id').getValue()
635 _this.data['cohead_billto_cntct_id_' + i] = data[i];
638 _this.form.findField('billto_address').update();
639 // fill in the select box..
640 _this.form.setValues( {
641 cohead_billto_cntct_id : data.cntct_id,
642 cohead_billto_cntct_id_cntct_name : data.cntct_first_name + ' '+
648 // Pman.Dialog.XtupleCustomer.show(
649 //{ cust_id : _this.form.findField('cohead_cust_id').getValue() },
651 // refresh the data in the pulldown..
658 displayField : 'cntct_name',
660 emptyText : "Select cntct",
661 fieldLabel : 'Bill To (select)',
662 forceSelection : true,
663 hiddenName : 'cohead_billto_cntct_id',
665 loadingText : "Searching...",
667 name : 'cohead_billto_cntct_id_cntct_name',
669 qtip : "Select cntct",
670 queryParam : 'query[cntct_name]',
671 selectOnFocus : true,
672 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cntct_name}</b> {cntct_addr_id_addr_line1}</div>',
673 triggerAction : 'all',
675 valueField : 'cntct_id',
681 beforeload : function (_self, o){
682 o.params = o.params || {};
684 o.params._customer_id = _this.data.cohead_cust_id;
688 sortInfo : { direction : 'ASC', field: 'cntct_name' },
693 url : baseURL + '/Roo/cntct.php'
700 totalProperty : 'total',
701 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
709 render : function (_self)
715 this.el.on('click', function() {
716 var id = _this.form.findField('cohead_billto_cntct_id').getValue();
717 Pman.Dialog.XtupleQuickContact.show(
720 customer_id : _this.form.findField('cohead_cust_id').getValue()
727 _this.data['cohead_billto_cntct_id_' + i] = data[i];
730 _this.form.findField('billto_address').update();
731 // fill in the select box..
732 _this.form.setValues( {
733 cohead_billto_cntct_id : data.cntct_id,
734 cohead_billto_cntct_id_cntct_name : data.cntct_first_name + ' '+
744 Roo.log("Click text");
750 fieldLabel : 'or enter Address',
751 name : 'billto_address',
753 update : function() {
755 var c = ['first_name', 'last_name' ] ;
756 var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];
758 Roo.each(c, function(e) {
759 if (_this.data['cohead_billto_cntct_id_cntct_' +e].length) {
760 v.push(_this.data['cohead_billto_cntct_id_cntct_' +e]);
763 Roo.each(a, function(e) {
764 if (_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e].length) {
765 v.push(_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e]);
769 this.setValue(v.join("\n"));
782 style : 'margin-left:10px',
787 legend : "Price Details",
788 style : 'width:420px',
794 labelAlign : 'right',
802 labelSeparator : ' ',
809 beforequery : function (combo, query, forceAll, cancel, e)
811 Roo.log('beforequery');
813 if (_this.form.findField('cohead_number').getValue().length) {
814 Roo.MessageBox.alert("Error", "You can not change the currency of this order");
823 displayField : 'curr_name',
825 emptyText : "Select curr_name",
826 fieldLabel : 'Currency',
827 forceSelection : true,
828 hiddenName : 'cohead_curr_id',
830 loadingText : "Searching...",
832 name : 'cohead_curr_id_curr_name',
834 qtip : "Select Currency",
835 queryParam : 'query[curr_name]',
836 selectOnFocus : true,
837 tpl : '<div class="x-grid-cell-text x-btn button"><b>{curr_name}</b> </div>',
838 triggerAction : 'all',
840 valueField : 'curr_id',
846 beforeload : function (_self, o){
847 o.params = o.params || {};
853 sortInfo : { direction : 'ASC', field: 'curr_symbol' },
858 url : baseURL + '/Roo/curr_symbol.php'
865 totalProperty : 'total',
866 fields : [{"name":"curr_id","type":"int"},"curr_symbol"]
871 xtype: 'NumberField',
873 allowDecimals : true,
874 cls : 'roo-align-right',
875 decimalPrecision : 3,
876 fieldLabel : 'Products',
877 name : 'cohead_subtotal',
887 labelSeparator : ' ',
894 select : function (combo, record, index)
896 _this.form.findField('cohead_tax').setValue(
897 parseFloat(record.data.taxzone_rate) *
898 parseFloat(_this.form.findField('cohead_subtotal').getValue())
900 _this.form.findField('cohead_total').recalc();
904 displayField : 'taxzone_descrip',
906 emptyText : "Select taxtype",
907 fieldLabel : 'Tax Zone',
908 forceSelection : true,
909 hiddenName : 'cohead_taxzone_id',
911 loadingText : "Searching...",
913 name : 'cohead_taxzone_id_taxzone_descrip',
915 qtip : "Select taxtype",
916 queryParam : 'query[taxzone_descrip]',
917 selectOnFocus : true,
918 tpl : '<div class="x-grid-cell-text x-btn button"><b>{taxzone_descrip}</b> </div>',
919 triggerAction : 'all',
921 valueField : 'taxzone_id',
927 beforeload : function (_self, o){
928 o.params = o.params || {};
931 o.params.with_date = _this.form.findField('cohead_orderdate').getValue().format('Y-m-d');
932 Roo.log("with date?" + o.params.with_date);
938 sortInfo : { direction : 'ASC', field: 'taxzone_descrip' },
943 url : baseURL + '/Roo/taxzone.php'
950 totalProperty : 'total',
951 fields : [{"name":"taxzone_id","type":"int"},"taxzone_descrip"]
956 xtype: 'NumberField',
958 allowDecimals : true,
959 cls : 'roo-align-right',
960 decimalPrecision : 3,
969 xtype: 'NumberField',
971 allowDecimals : true,
972 cls : 'roo-align-right',
973 decimalPrecision : 3,
974 fieldLabel : 'Pre Tax discount',
975 name : 'cohead_pretax_discount',
983 labelSeparator : ' ',
989 fieldLabel : 'Discount after Tax Description',
990 name : 'cohead_misc_descrip',
994 xtype: 'NumberField',
997 keyup : function (_self, e)
999 var pv = parseFloat(_this.form.findField('cohead_subtotal').getValue());
1000 var tax = parseFloat(_this.form.findField('cohead_tax').getValue());
1001 var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());
1003 var n = this.getValue();
1004 var discount = parseFloat(n * (pv + tax + pd) * 0.01);
1006 _this.form.findField('cohead_posttax_discount').setValue(discount);
1008 _this.form.findField('cohead_total').recalc();
1009 _this.form.findField('cohead_misc').recalc();
1010 var val = discount * -1.0;
1012 _this.form.findField('cohead_misc_descrip').setValue("Discount of " + val.toFixed(1)+'%');
1018 allowDecimals : true,
1019 cls : 'roo-align-right',
1020 decimalPrecision : 1,
1022 name : 'cohead_misc_per',
1024 update : function() {
1025 var m = _this.form.findField('cohead_misc_per');
1026 var pv = parseFloat(_this.form.findField('cohead_subtotal').getValue());
1027 var tax = parseFloat(_this.form.findField('cohead_tax').getValue());
1028 var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());
1030 var discount = parseFloat(_this.form.findField('cohead_posttax_discount').getValue());
1032 if (discount > 0.0) {
1040 var val = ((discount) / (pv + tax + pd)) * -100;
1042 //Roo.log("update discount?" + val);
1043 this.setValue(val.toFixed(1));
1046 _this.form.findField('cohead_misc_descrip').setValue("Discount of " + val.toFixed(1)+'%');
1054 xtype: 'NumberField',
1057 keyup : function (_self, e)
1059 _this.form.findField('cohead_misc_per').update();
1060 _this.form.findField('cohead_total').recalc();
1061 _this.form.findField('cohead_misc').recalc();
1064 allowDecimals : true,
1065 cls : 'roo-align-right',
1066 decimalPrecision : 3,
1067 fieldLabel : ' ',
1068 name : 'cohead_posttax_discount',
1074 xtype: 'NumberField',
1076 allowDecimals : true,
1077 cls : 'roo-align-right',
1078 decimalPrecision : 3,
1079 fieldLabel : 'Total',
1080 name : 'cohead_total',
1083 recalc : function() {
1084 var d = _this.form.getValues();
1086 parseFloat(d.cohead_subtotal) +
1087 parseFloat(d.cohead_pretax_discount) +
1088 parseFloat(d.cohead_posttax_discount) +
1089 parseFloat(d.cohead_tax) +
1090 parseFloat(d.cohead_freight));
1094 xtype: 'NumberField',
1097 keyup : function (_self, e)
1099 _this.form.findField('cohead_total').recalc();
1102 allowDecimals : true,
1103 cls : 'roo-align-right',
1104 decimalPrecision : 3,
1105 fieldLabel : 'Shipping',
1106 name : 'cohead_freight',
1110 xtype: 'NumberField',
1112 allowDecimals : true,
1113 cls : 'roo-align-right',
1114 decimalPrecision : 3,
1115 fieldLabel : 'Unshipped Total',
1116 name : 'cohead_unshipped',
1121 xtype: 'NumberField',
1123 allowDecimals : true,
1124 cls : 'roo-align-right',
1125 decimalPrecision : 3,
1126 fieldLabel : 'Uninvoiced Total',
1127 name : 'cohead_uninvoiced',
1138 style : 'width:420px',
1139 legend : "Shipping",
1150 labelSeparator : ' ',
1156 check : function (_self, checked)
1162 if (_this.dataloading) {
1170 // copy the cohead_billto_cntct_id
1171 for (var i in _this.data) {
1172 if (!i.match(/^cohead_billto_cntct_id/)) {
1175 var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');
1176 _this.data[ni] = _this.data[i];
1178 _this.form.findField('shipto_address').update();
1179 _this.form.setValues( {
1180 cohead_shipto_cntct_id : _this.data.cohead_shipto_cntct_id,
1181 cohead_shipto_cntct_id_cntct_name : _this.data.cohead_shipto_cntct_id_cntct_first_name + ' ' +
1182 _this.data.cohead_shipto_cntct_id_cntct_last_name
1189 for (var i in _this.data) {
1190 if (!i.match(/^cohead_billto_cntct_id/)) {
1193 var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');
1195 _this.data[ni] = '';
1197 _this.form.findField('shipto_address').update();
1199 _this.form.setValues( {
1200 cohead_shipto_cntct_id : '',
1201 cohead_shipto_cntct_id_cntct_name : ''
1209 boxLabel : 'Same as Billing',
1210 name : '_shipto_same'
1218 add : function (combo)
1220 Pman.Dialog.XtupleQuickContact.show(
1223 customer_id : _this.form.findField('cohead_cust_id').getValue()
1228 for(var i in data) {
1230 _this.data['cohead_shipto_cntct_id_' + i] = data[i];
1233 _this.form.findField('shipto_address').update();
1234 // fill in the select box..
1235 _this.form.setValues( {
1236 cohead_shipto_cntct_id : data.cntct_id,
1237 cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1238 data.cntct_last_name
1244 beforeselect : function (combo, record, index)
1247 // just add everything...
1248 for(var i in record.data) {
1249 //Roo.log('cohead_shipto_cntct_id_' + i +' =' + record.data[i]);
1250 _this.data['cohead_shipto_cntct_id_' + i] = record.data[i];
1253 _this.form.findField('shipto_address').update();
1260 displayField : 'cntct_name',
1262 emptyText : "Select ship to",
1263 fieldLabel : 'Ship to',
1264 forceSelection : true,
1265 hiddenName : 'cohead_shipto_cntct_id',
1267 loadingText : "Searching...",
1269 name : 'cohead_shipto_cntct_id_cntct_name',
1271 qtip : "Select shiptoinfo",
1272 queryParam : 'query[cntct_name]',
1273 selectOnFocus : true,
1274 tpl : '<div class="x-grid-cell-text x-btn button">{cntct_name} - <b>{cntct_addr_id_addr_line1}</b> </div>',
1275 triggerAction : 'all',
1277 valueField : 'cntct_id',
1283 beforeload : function (_self, o){
1284 o.params = o.params || {};
1286 o.params._customer_id = _this.data.cohead_cust_id;
1290 sortInfo : { direction : 'ASC', field: 'cntct_name' },
1295 url : baseURL + '/Roo/cntct.php'
1298 xtype: 'JsonReader',
1302 totalProperty : 'total',
1303 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
1311 render : function (_self)
1317 this.el.on('click', function() {
1318 var id = _this.form.findField('cohead_shipto_cntct_id').getValue();
1319 Pman.Dialog.XtupleQuickContact.show(
1322 customer_id : _this.form.findField('cohead_cust_id').getValue()
1327 for(var i in data) {
1329 _this.data['cohead_shipto_cntct_id_' + i] = data[i];
1332 _this.form.findField('shipto_address').update();
1333 // fill in the select box..
1334 _this.form.setValues( {
1335 cohead_shipto_cntct_id : data.cntct_id,
1336 cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1337 data.cntct_last_name
1346 // Roo.log("Click text");
1352 fieldLabel : 'Address',
1353 name : 'shipto_address',
1356 update : function() {
1358 var c = ['first_name', 'last_name' ] ;
1359 var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];
1361 Roo.each(c, function(e) {
1362 if (_this.data['cohead_shipto_cntct_id_cntct_' +e] &&
1363 _this.data['cohead_shipto_cntct_id_cntct_' +e].length) {
1364 v.push(_this.data['cohead_shipto_cntct_id_cntct_' +e]);
1367 Roo.each(a, function(e) {
1368 if (_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e] &&
1369 _this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e].length) {
1370 v.push(_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e]);
1374 this.setValue(v.join("\n"));
1380 fieldLabel : 'Shipment Comments',
1381 name : 'cohead_shipcomments',
1398 name : 'cohead_shipto_id'
1403 name : 'cohead_shipto_id_shipto_name'
1408 name : 'cohead_max_linenumber'
1413 name : 'cohead_cust_id'
1418 name : 'cohead_misc',
1419 recalc : function() {
1420 var d = _this.form.getValues();
1422 parseFloat(d.cohead_pretax_discount) +
1423 parseFloat(d.cohead_posttax_discount) );
1429 name : 'taxzone_rate'
1439 activate : function() {
1442 try { if (MODULE.isBuilder) {
1446 var id = _this.form.findField('cohead_id').getValue() * 1;
1448 Roo.MessageBox.alert("Save First", "Save the order first, before adding items");
1449 _this.dialog.layout.getRegion('center').showPanel(0);
1454 _this.grid.footer.onClick('first');
1456 //if (_this.form.findField('cohead_cust_id_cust_name').getValue() == 'Bloom and Grow HK') {
1457 // _this.xferAll.show();
1460 // _this.xferAll.hide();
1465 deactivate : function (_self)
1468 _this.grid.stopEditing();
1473 fitContainer : true,
1476 tableName : 'coitem',
1477 title : "Order Items",
1479 xtype: 'EditorGrid',
1485 //_this.dialog = Pman.Dialog.FILL_IN
1487 if (_this.panel.active) {
1488 this.footer.onClick('first');
1491 afteredit : function (e)
1493 Roo.log('afteredit:' + e.record.data.coitem_linenumber);
1496 // if ( e.record && e.record.data.coitem_id) {
1497 // as we disable update to the display on the ajax callback to
1498 // allow editing flow to continue, and not refresh - we can only update
1499 // these values after something has actually been edited.
1500 // e.record.set('coitem_id', e.record.data.coitem_id);
1501 // e.record.set('coitem_status', e.record.data.coitem_status);
1504 if (e.field == 'item_number' || e.originalValue == e.value) {
1505 // afterselect handles this...
1508 if (e.field == 'item_descrip1') {
1509 e.record.set('coitem_memo', e.value);
1511 var rate = _this.form.findField('taxzone_rate').getValue();
1513 case 'coitem_linedisc':
1515 var cp = parseFloat(e.record.data.coitem_custprice);
1517 if (isNaN(cp) || cp == 0.0) {
1521 var dis = parseFloat(e.value);
1529 Math.max(0,cp * ((100.0 - parseInt(e.value))/ 100.0) )
1532 // donot need to set the subtotal here, coz we will render it automatically
1534 // 'coitem_subtotal',
1535 // e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord
1539 case 'coitem_price': // SELL@ price
1541 var cp = parseFloat(e.record.data.coitem_custprice);
1542 // list price is < price -- update it..
1543 if (isNaN(cp) || cp == 0.0 || cp < e.value) {
1544 e.record.set('coitem_custprice', e.value);
1547 // update the discount calc.
1549 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( e.value / cp) * 100.0)));
1551 // donot need to set the subtotal here, coz we will render it automatically
1553 // 'coitem_subtotal',
1554 // e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord
1558 case 'coitem_custprice':
1559 // modified customer price...
1560 // just modify the discount.. -- leave the entered price the same..
1561 var sp = parseFloat(e.record.data.coitem_price);
1562 var cp = parseFloat(e.value);
1563 if (isNaN(cp) || cp == 0.0 || cp < e.value) {
1567 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1571 case 'coitem_custprice_tax':
1572 var cp = parseFloat(e.value / ( 1 + rate * 1 ));
1573 var sp = parseFloat(e.record.data.coitem_price);
1575 if (isNaN(cp) || cp == 0.0) {
1578 e.record.set('coitem_custprice', cp);
1579 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1583 case 'coitem_price_tax':
1585 var cp = parseFloat(e.record.data.coitem_custprice);
1586 var sp = parseFloat(e.value / ( 1 + rate * 1 ));
1587 if (isNaN(cp) || cp == 0.0 || cp < sp) {
1588 e.record.set('coitem_custprice', sp);
1591 e.record.set('coitem_price', sp);
1592 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1601 var doupdate = function() {
1602 if (!e.record.updatePending) {
1603 Roo.log('doupdate...' + e.record.data.coitem_linenumber);
1608 Roo.log('doupdate pending...' + e.record.data.coitem_linenumber);
1609 // wait until it's not peding an update..
1610 doupdate.defer(500);
1613 if(e.record.data.coitem_id * 1 < 1 && !e.record.isInserting){ // insert
1614 e.record.isInserting = 1;
1615 e.record.isUpdating = 0;
1621 if(!e.record.isInserting && !e.record.isUpdating){
1622 e.record.isUpdating = 1;
1627 if(!e.record.updatePending){
1628 e.record.updatePending = 1;
1632 Roo.log("got to end without doing an update?" + e.record.data.coitem_linenumber);
1635 beforeedit : function (e)
1637 // we can only edit if nothing is assigned to shipping or invoices..
1641 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0 || (rec.data.shipitem_shipped - rec.data.coitem_qtyshipped) > 0 ) {
1642 Roo.MessageBox.alert("Error", "That item has been shipped, has a draft shipment or invoices - void the shipments/invoices first");
1647 if (rec.data.coitem_subnumber * 1 > 0) {
1648 Roo.log("Edit container event");
1649 Roo.log(e); // if it's a tab..
1653 // allow editing of source / destination..
1654 case 'coitem_shipto_id':
1655 case 'coitem_location_src':
1660 Roo.MessageBox.alert("Error", "That is a kit item, edit the container.");
1664 // zero off values..
1665 //if (e.field == 'coitem_qtyord' && rec.data.coitem_qtyord == 0) {
1668 // if (e.field == 'coitem_custprice' && rec.data.coitem_qtyord == 0.0) {
1672 if (rec.data.item_type == 'K' && e.field == 'item_number') {
1673 // you can not change the product type on kits' as it messing things up..
1674 Roo.MessageBox.alert("Error", "That is a kit item,if you need to change it, delete it first.");
1680 celldblclick : function (_self, rowIndex, columnIndex, e)
1682 var rec = this.ds.getAt(rowIndex);
1683 var di = this.cm.getDataIndex(columnIndex);
1684 if (di != 'avail_qty') {
1688 Pman.Dialog.XtupleInvHistory.show({
1689 itemsite_item_id_item_number : rec.data.item_number,
1690 // itemsite_item_id_item_descript1 : rec.data.item_descrip1,
1691 location_name : rec.data.coitem_location_src_location_name,
1692 location_descrip : rec.data.coitem_location_src_location_descrip,
1694 invhist_transdate : _this.form.findField('cohead_targetdate').getValue()
1698 rowclass : function (gridview, rowcfg)
1700 if (rowcfg.record.data.coitem_status == 'C' &&
1701 rowcfg.record.data.shipitem_shipped * 1 < 1) {
1703 rowcfg.rowClass = 'strikethrough';
1705 if (rowcfg.record.data.coitem_status == 'X' ) {
1707 rowcfg.rowClass = 'strikethrough';
1710 if (!rowcfg.record.data.coitem_id) {
1711 rowcfg.rowClass = 'dragon-not-saved';
1719 autoExpandColumn : 'item_descrip1',
1722 loadAvail : function() {
1725 this.ds.each(function(r) {
1727 if(!r.data.item_number.length){
1731 if(typeof(_this.stockcache[r.data.item_number]) != 'undefined'){
1733 r.set('avail_qty', _this.stockcache[r.data.item_number].qty);
1734 if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {
1735 r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);
1743 item : r.data.item_number,
1744 loc: r.data.coitem_location_src_location_name,
1745 id: r.data.coitem_linenumber + (r.data.coitem_subnumber ? ('.' + r.data.coitem_subnumber) : '')
1749 url : baseURL + '/Roo/itemloc',
1752 _availqty : Roo.encode(q),
1753 curr_name : _this.form.findField('cohead_curr_id').el.dom.value
1755 success : function(res)
1757 for (var i in res.data) {
1758 _this.stockcache[res.data[i].item] = res.data[i];
1760 r.set('avail_qty', _this.stockcache[r.data.item_number].qty);
1761 if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {
1762 r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);
1764 //_this.grid.ds.fireEvent("update", _this.grid.ds, r, Roo.data.Record.EDIT);
1773 xtype: 'CellSelectionModel',
1776 tabend : function (_self)
1778 _this.addItemBtn.fireEvent('click', _this.addItemBtn);
1780 beforeeditnext : function (eventdata)
1784 // this does not work, as the reload effect cancels editng.
1785 var rec = _this.grid.ds.getAt(eventdata.cell[0]);
1786 if (rec.data.coitem_subnumber *1 < 0 ) {
1789 var r = eventdata.cell[0] + 1;
1792 if (r > _this.grid.ds.getCount()-1 ) {
1793 eventdata.cell = false;
1796 rec = _this.grid.ds.getAt(r);
1797 if (rec.data.coitem_subnumber *1 < 0 ) {
1798 eventdata.cell = [ r, eventdata.cell[1] ];
1812 xtype: 'PagingToolbar',
1815 emptyMsg : "No Items",
1817 updateSummary : function() {
1820 url : baseURL + '/Roo/Coitem',
1824 coitem_cohead_id : _this.form.findField('cohead_id').getValue()
1826 success : function(d) {
1828 f.displayEl.update(String.format(
1829 "{0} items | Subtotal: {2} | Tax: {3} | List Discount {4} | Total : {1}{5}",
1831 _this.form.findField('cohead_curr_id').el.dom.value,
1834 d.data.total_list_discount,
1846 click : function (_self, e)
1849 url : baseURL + '/Roo/Cohead',
1852 _fill_shipto : _this.form.findField('cohead_id').getValue()
1854 success : function() {
1855 _this.grid.footer.onClick('first');
1860 text : "Fill empty Ship To"
1866 click : function (_self, e)
1868 Roo.MessageBox.confirm("Confirm", "Are you sure?<BR>"+
1869 "This will set all the locations to match the Sales Order - and remove all old locations.",
1876 url : baseURL + '/Roo/Cohead',
1879 _fill_location : _this.form.findField('cohead_id').getValue(),
1880 _location_id : _this.form.findField('cohead_location_src').getValue()
1882 success : function() {
1883 _this.grid.footer.onClick('first');
1890 text : "Update Location to match S/O"
1896 toggle : function (_self, pressed)
1898 this.setText(pressed ? "Prices exc GST" : "Prices with GST");
1899 var cm = _this.grid.getColumnModel();
1901 cm.setHidden(cm.getIndexByDataIndex('coitem_price_tax'), pressed ? false : true);
1902 cm.setHidden(cm.getIndexByDataIndex('coitem_custprice_tax'), pressed ? false : true);
1903 cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal_tax'), pressed ? false : true);
1905 cm.setHidden(cm.getIndexByDataIndex('coitem_price'), pressed ? true : false);
1906 cm.setHidden(cm.getIndexByDataIndex('coitem_custprice'), pressed ? true : false);
1907 cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal'), pressed ? true : false);
1910 render : function (_self)
1912 _this.showgstBtn = _self;
1915 enableToggle : true,
1917 text : "Prices with GST"
1925 beforeload : function (_self,o) {
1932 if (!_this.data || !_this.data.cohead_id) {
1935 o.params = o.params || {};
1937 o.params.coitem_cohead_id = _this.data.cohead_id;
1938 o.params._without_list_discount =1;
1939 //o.params.limit = 999;
1943 update : function (_self, rec, operation)
1946 if (operation != Roo.data.Record.COMMIT) {
1950 // row has been updated..
1951 // if the qty + item has been filled in, we should try and save it..
1954 var setRecord = function(){
1956 Roo.log("Clearing update?" + rec.data.coitem_linenumber);
1957 rec.updatePending = 0;
1958 if(rec.isInserting){
1959 rec.isInserting = 0;
1965 if (!(rec.data.coitem_itemsite_id * 1) || !(rec.data.coitem_qtyord*1)) {
1969 var doCommit = function() {
1970 Roo.log("Sending data?" + rec.data.coitem_linenumber);
1973 url : baseURL+'/Roo/coitem',
1976 success: function(res)
1979 var row = _this.grid.ds.indexOf(rec);
1980 Roo.get(_this.grid.view.getRow(row)).removeClass('dragon-not-saved');
1986 Roo.log("GOT success: " + rec.data.coitem_linenumber);
1987 //Roo.log("GOT success");
1988 // update the data...
1990 if (rec.data.item_type == 'K') {
1992 _this.grid.ds.load({});
1997 // why is this here.??
1999 if (_this.grid.activeEditor) {
2005 rec.set('coitem_id', res.data.coitem_id);
2006 rec.set('coitem_status', res.data.coitem_status);
2010 delete rec.modified;
2012 _this.grid.footer.updateSummary();
2013 _this.grid.loadAvail();
2019 failure : function(res)
2022 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error updating");
2035 load : function (_self, records, options)
2037 // need to fetch availablity from master data..
2038 // build a list of what to ask..
2040 // query: ITEM CODE - LOCATION
2041 _this.grid.footer.updateSummary();
2042 _this.grid.loadAvail.defer(100, _this.grid);
2050 sortInfo : { field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' },
2055 url : baseURL + '/Roo/coitem.php'
2058 xtype: 'JsonReader',
2062 totalProperty : 'total',
2065 'name': 'coitem_linenumber',
2069 'name': 'coitem_itemsite_id',
2073 'name': 'coitem_qtyord'
2076 'name': 'coitem_unitcost'
2079 'name': 'coitem_price'
2082 'name': 'coitem_custprice'
2085 'name': 'coitem_qtyreturned'
2088 'name': 'coitem_prcost'
2091 'name': 'coitem_price_uom_id',
2095 'name': 'coitem_qtyreserved'
2111 Roo.log("add presed");
2114 var grid = _this.grid;
2116 grid.ds.each(function(r) {
2117 if (r.data.coitem_qtyord < 1) {
2118 Roo.MessageBox.alert("Error", "you must fill in a quantity for " + r.data.item_number);
2130 var last = _this.form.findField('cohead_max_linenumber').getValue();
2137 _this.form.findField('cohead_max_linenumber').setValue(last);
2139 // this should be getting the previous row..??
2140 var ct = _this.grid.ds.getCount();
2141 var lastrow = ct ? _this.grid.ds.getAt(ct-1) : false;
2143 function lastor(k,d,kk) {
2144 var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();
2145 return lastrow ? lastrow.data[kk] : def;
2148 // uses form defaults or last row value.
2149 var nr = _this.grid.ds.reader.newRow({
2150 coitem_linenumber : last,
2154 coitem_cohead_id : _this.form.findField('cohead_id').getValue(),
2155 coitem_qtyshipped : 0,
2156 coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),
2157 coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),
2158 coitem_shipto_id : lastor('cohead_shipto_id',false, 'coitem_shipto_id'),
2159 coitem_shipto_id_shipto_name : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name'),
2160 coitem_unitcost_in_order_cur : 0,
2161 coitem_taxtype_id : _this.data.default_taxtype_id,
2162 coitem_taxtype_id_taxtype_name : 'Taxable',
2168 grid.ds.insert(grid.ds.getCount(), nr);
2169 grid.startEditing(grid.ds.getCount()-1, 1); // type..
2170 nr.updatePending = 0;
2175 render : function (_self)
2177 _this.addItemBtn = _self;
2180 cls : 'x-btn-text-icon',
2182 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
2188 click : function (_self, e)
2190 var last = _this.form.findField('cohead_max_linenumber').getValue();
\r
2192 _this.form.findField('cohead_max_linenumber').setValue(last);
2194 var ct = _this.grid.ds.getCount();
\r
2195 var lastrow = ct ? _this.grid.ds.getAt(ct-1) : false;
\r
2197 function lastor(k,d,kk) {
\r
2198 var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();
\r
2199 return lastrow ? lastrow.data[kk] : def;
\r
2202 var cohead_cust_id = _this.form.findField('cohead_cust_id').getValue();
2203 var cohead_id = _this.form.findField('cohead_id').getValue();
2205 Pman.Dialog.XtupleSalesProductList.show( {cohead_cust_id : cohead_cust_id, cohead_id : cohead_id} , function(res) {
2207 _this.grid.stopEditing();
2209 if (_this.grid.ds.getCount() > 0) {
2210 var lr = _this.grid.ds.getAt(_this.grid.ds.getCount()-1);
2211 if (!lr.data.coitem_itemsite_id) {
2212 lr.set('coitem_itemsite_id', res.item_itemsite_id_itemsite_id);
2213 lr.set('item_number', res.item_number);
2214 lr.set('item_descrip1', res.item_descrip1);
2215 lr.set('coitem_listprice', res.item_price);
2216 lr.set('coitem_price', res.item_price);
2217 lr.set('coitem_custprice', res.item_price);
2224 var nr = _this.grid.ds.reader.newRow({
2225 coitem_linenumber : last,
2226 coitem_itemsite_id : res.item_itemsite_id_itemsite_id,
2227 item_number : res.item_number,
2228 item_descrip1 : res.item_descrip1,
2230 coitem_cohead_id : _this.form.findField('cohead_id').getValue(),
2231 coitem_qtyshipped : 0,
2232 coitem_listprice : res.item_price,
2233 coitem_price : res.item_price,
2234 coitem_custprice : res.item_price,
2236 coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),
2237 coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),
2238 coitem_shipto_id : lastor('cohead_shipto_id',false, 'coitem_shipto_id'),
2239 coitem_shipto_id_shipto_name : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name')
2242 _this.grid.ds.insert(_this.grid.ds.getCount(), nr);
2247 cls : 'x-btn-text-icon',
2248 text : "Find Products",
2249 icon : rootURL + '/Pman/templates/images/search.gif'
2259 url : baseURL + '/Roo/coitem',
2260 mask : 'Loading Data',
2264 _hk_xfer :_this.form.findField('cohead_id').getValue()
2266 success : function() {
2267 _this.grid.ds.load({});
2272 render : function (_self)
2274 _this.xferAll = _self;
2277 cls : 'x-btn-text-icon',
2279 text : "Xfer all stock to HK",
2280 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
2286 click : function (_self, e)
2288 var c = _this.grid.getSelectionModel().getSelectedCell();
2290 Roo.MessageBox.alert("Error", "Select item to show history (you can also double click on the #avail number) ");
2294 var rec = _this.grid.ds.getAt(c[0]);
2296 Pman.Dialog.XtupleInvHistory.show({
2297 itemsite_item_id_item_number : rec.data.item_number,
2298 // itemsite_item_id_item_descript1 : rec.data.item_descrip1,
2299 location_name : rec.data.coitem_location_src_location_name,
2300 location_descrip : rec.data.coitem_location_src_location_descrip,
2303 invhist_transdate : _this.form.findField('cohead_targetdate').getValue()
2309 text : "Show Inventory History"
2318 text : "Apply % Discount of : "
2324 render : function (_self)
2326 _this._applyDiscount = _self;
2335 click : function (_self, e)
2337 var val = parseFloat(_this._applyDiscount.getValue());
2339 var factor = (100.0 - val)/100.0;
2341 _this.grid.ds.each(function(rec) {
2342 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2346 rec.set('coitem_price', rec.data.coitem_custprice * factor);
2347 rec.set('coitem_linedisc', val);
2348 rec.set('coitem_subtotal', rec.data.coitem_price & rec.data.ordqty);
2356 text : "Apply To All"
2362 click : function (_self, e)
2365 if (!(1* _this.form.findField('cohead_id').getValue())) {
2366 Roo.MessageBox.alert("Error", "save the order first");
2370 Pman.Dialog.Image.show(
2373 _url : baseURL+'/Xtuple/Import/SalesOrder',
2374 onid : _this.form.findField('cohead_id').getValue()
2379 Roo.MessageBox.alert("Notice", "Uploaded");
2380 _this.grid.footer.onClick('first');
2398 _this.grid.stopEditing();
2399 // check that no shipments or invoices are done..
2400 var rc = _this.grid.getSelectionModel().getSelectedCell();
2402 var rec = _this.grid.ds.getAt(rc[0]);
2404 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2405 Roo.MessageBox.alert("Error", "That item has been shipped or invoices - void the shipments/invoices first");
2408 if (rec.data.coitem_subnumber*1 > 0) {
2409 Roo.MessageBox.alert("Error", "Delete the kit item that that belongs to.");
2412 if (!rec.data.coitem_id) {
2413 _this.grid.ds.remove(rec);
2420 url : baseURL + '/Roo/coitem',
2423 _delete : rec.data.coitem_id
2426 success : function() {
2427 if (rec.data.item_type == 'K') {
2428 _this.grid.ds.load({});
2431 _this.grid.ds.remove(rec);
2436 if (rec.data_qtyord * 1 < 1) {
2440 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that line?", function(r)
2453 cls : 'x-btn-text-icon',
2455 icon : rootURL + '/Pman/templates/images/trash.gif'
2463 _this.grid.stopEditing();
2464 // check that no shipments or invoices are done..
2466 _this.grid.ds.each(function(rec) {
2470 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2471 //Roo.MessageBox.alert("Error", "That item has been shipped or invoices - void the shipments/invoices first");
2474 if (rec.data.item_type == 'K') {
2478 if (rec.data.coitem_subnumber*1 > 0) {
2479 //Roo.MessageBox.alert("Error", "Delete the kit item that that belongs to.");
2482 if (!rec.data.coitem_id) {
2483 _this.grid.ds.remove(rec);
2486 ids.push(rec.data.coitem_id);
2492 url : baseURL + '/Roo/coitem',
2495 _delete : ids.join(',')
2498 success : function() {
2500 _this.grid.footer.onClick('first');
2505 // if (rec.data_qtyord * 1 < 1) {
2509 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete everything?", function(r)
2522 cls : 'x-btn-text-icon',
2523 text : "Delete All",
2524 icon : rootURL + '/Pman/templates/images/trash.gif'
2530 xtype: 'ColumnModel',
2532 dataIndex : 'coitem_linenumber',
2535 renderer : function(v,x,r) {
2537 if (r.data.coitem_subnumber * 1 > 0) {
2538 return String.format('{0}.{1}', v,r.data.coitem_subnumber);
2540 return String.format('{0}', v);
2544 xtype: 'ColumnModel',
2546 dataIndex : 'item_number',
2547 header : 'Item Code',
2549 renderer : function(v) { return String.format('{0}', v); },
2551 xtype: 'GridEditor',
2557 beforeselect : function (combo, record, index)
2559 // set _this.data values ..
2560 var ar = _this.grid.activeEditor.record;
2561 // Roo.log('beforeselect');
2565 // Roo.log('beforeselect-cb');
2566 ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
2567 ar.set('coitem_listprice', record.data.item_listprice);
2568 ar.set('coitem_price', record.data.item_price);
2569 ar.set('coitem_custprice', record.data.item_price);
2570 ar.set('coitem_itemsite_id', record.data.itemsite_id);
2571 ar.set('item_number', record.data.itemsite_item_id_item_number);
2572 ar.set('item_type', record.data.itemsite_item_id_item_type);
2573 ar.set('avail_qty', 0);
2580 displayField : 'itemsite_item_id_item_number',
2582 emptyText : "Select item",
2583 forceSelection : true,
2584 hiddenName : 'itemsite_item_id_item_number',
2586 loadingText : "Searching...",
2588 name : 'item_number',
2590 qtip : "Select item",
2591 queryParam : 'query[number]',
2592 selectOnFocus : true,
2593 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>',
2594 triggerAction : 'all',
2596 valueField : 'item_number',
2601 beforeload : function (_self, o){
2602 o.params = o.params || {};
2603 o.params.customer_id = _this.form.findField('cohead_cust_id').getValue();
2604 o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue();
2605 //o.params.shipto_cust_id = _this.data.cohead_cust_id;
2610 sortInfo : { direction : 'ASC', field: 'item_number' },
2615 url : baseURL + '/Roo/itemsite.php'
2618 xtype: 'JsonReader',
2622 totalProperty : 'total',
2623 fields : [{"name":"item_id","type":"int"},"item_number"]
2630 xtype: 'ColumnModel',
2632 dataIndex : 'coitem_location_src',
2635 renderer : function(v,x,r) {
2636 return String.format('{0}', r.data.coitem_location_src_location_name);
2639 xtype: 'GridEditor',
2645 beforeselect : function (combo, record, index)
2647 // set _this.data values ..
2648 var ar = _this.grid.activeEditor.record;
2652 //Roo.log('beforeselect');
2656 // Roo.log('beforeselect-cb');
2657 ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
2658 ar.set('coitem_price', record.data.item_listprice);
2659 ar.set('coitem_custprice', record.data.item_price);
2660 ar.set('coitem_itemsite_id', record.data.itemsite_id);
2661 ar.set('item_number', record.data.itemsite_item_id_item_number);
2670 displayField : 'location_name',
2672 emptyText : "Select location",
2673 forceSelection : true,
2674 hiddenName : 'coitem_location_src',
2676 loadingText : "Searching...",
2678 name : 'coitem_location_src_location_name',
2680 qtip : "Select item",
2681 queryParam : 'query[location_name]',
2682 selectOnFocus : true,
2683 tpl : '<div class="x-grid-cell-text x-btn button"><b> {location_name}</b> {location_descrip}</div>',
2684 triggerAction : 'all',
2686 valueField : 'location_id',
2691 beforeload : function (_self, o){
2692 o.params = o.params || {};
2694 var row = _this.grid.activeEditor.record;
2696 o.params['query[item_itemsite_id]'] = row.data.coitem_itemsite_id;
2697 // need to know the date to calc the est. delivery time..
2698 //o.params['query[avail_when]'] = _this.form.findField('cohead_targetdate').getValue().format('Y-m-d');
2699 //o.params.location_netable = 1;
2700 o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue();
2702 o.params.location_restrict = 0;
2703 o.params._notinternalcompany = 1;
2707 // o.params.itemsite_id = _this.form.findField('cohead_cust_id').getValue();
2708 //o.params.shipto_cust_id = _this.data.cohead_cust_id;
2713 sortInfo : { direction : 'ASC', field: 'location_name' },
2718 url : baseURL + '/Roo/location.php'
2721 xtype: 'JsonReader',
2725 totalProperty : 'total',
2726 fields : [{"name":"location_id","type":"int"},"location_name"]
2733 xtype: 'ColumnModel',
2735 dataIndex : 'coitem_shipto_id',
2738 renderer : function(v,x,r) {
2739 return String.format('{0}:{1}', v, r.data.coitem_shipto_id_shipto_name);
2742 xtype: 'GridEditor',
2748 add : function (combo)
2751 Pman.Dialog.XtupleCustomer.show({ cust_id : _this.form.findField('cohead_cust_id').getValue() }, function(data) {
2752 // refresh the data in the pulldown..
2755 beforeselect : function (combo, record, index)
2759 for(var i = 1; i <4; i++) {
2760 _this.data['cohead_shiptoaddress'+ i] = record.data['cntct_addr_id_addr_line'+i];
2762 _this.form.findField('shipto_address').update();
2769 displayField : 'shipto_name',
2771 emptyText : "Select cntct",
2772 forceSelection : true,
2773 hiddenName : 'cohead_shipto_id',
2775 loadingText : "Searching...",
2777 name : 'coitem_shipto_id_shipto_name',
2779 qtip : "Select shipto",
2780 queryParam : 'query[shipto_name]',
2781 selectOnFocus : true,
2782 tpl : '<div class="x-grid-cell-text x-btn button"><b>{shipto_id}:{shipto_addr_id_addr_name}</b> </div>',
2783 triggerAction : 'all',
2785 valueField : 'shipto_id',
2791 beforeload : function (_self, o){
2792 o.params = o.params || {};
2793 o.params.shipto_cust_id = _this.data.cohead_cust_id;
2794 //o.params['query[with_shipinfo]'] = 1;
2799 sortInfo : { direction : 'ASC', field: 'shipto_name' },
2804 url : baseURL + '/Roo/shiptoinfo.php'
2807 xtype: 'JsonReader',
2811 totalProperty : 'total',
2812 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
2819 xtype: 'ColumnModel',
2821 dataIndex : 'item_descrip1',
2822 header : 'Item Description',
2824 renderer : function(v,x,r) {
2826 if (r.data.coitem_memo && r.data.coitem_memo.length) {
2827 return String.format('{0}', r.data.coitem_memo);
2828 if (r.data.coitem_memo != v) {
2829 r.set('item_descrip1', r.data.coitem_memo);
2833 if (v && v.length > 49) {
2834 return String.format('<span style="color:orange" qtip="line may be too long to print">{0}</span>', v);
2837 return String.format('{0}', v);
2841 xtype: 'GridEditor',
2851 xtype: 'ColumnModel',
2854 dataIndex : 'coitem_status',
2857 renderer : function(v) { return String.format('{0}', v); }
2860 xtype: 'ColumnModel',
2863 dataIndex : 'coitem_qtyord',
2866 renderer : function(v,x,r) {
2867 var v = parseInt(v);
2868 //var aq = parseInt(r.data.avail_qty);
2869 //aq = isNaN(aq) ? 0 : aq;
2871 var rate = _this.form.findField('taxzone_rate').getValue();
2872 r.data.coitem_subtotal = v * r.data.coitem_price;
2873 r.data.coitem_subtotal_tax = v * r.data.coitem_price * ( 1 + rate * 1);
2874 return String.format('{0}', v);
2878 xtype: 'GridEditor',
2881 xtype: 'NumberField',
2884 focus : function (_self)
2886 if (this.value == 0) {
2887 this.el.dom.value = '';
2891 allowDecimals : false,
2892 decimalPrecision : 0,
2894 style : 'text-align:right'
2899 xtype: 'ColumnModel',
2902 dataIndex : 'coitem_price',
2905 renderer : function(v,x,r) {
2907 var rate = _this.form.findField('taxzone_rate').getValue();
2908 r.data.coitem_subtotal = v * r.data.coitem_qtyord;
2909 r.data.coitem_subtotal_tax = v * ( 1 + rate * 1 ) * r.data.coitem_qtyord;
2910 r.data.coitem_price_tax = v * ( 1 + rate * 1 );
2911 if (parseInt(v) < 1) {
2912 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,3));
2916 //r.set('coitem_subtotal', v * r.data.coitem_qtyord);
2918 return String.format('{0}', Roo.util.Format.number(v,3));
2921 xtype: 'GridEditor',
2924 xtype: 'NumberField',
2927 focus : function (_self)
2929 if (this.value == 0.0) {
2930 this.el.dom.value = '';
2934 decimalPrecision : 3,
2936 style : 'text-align:right'
2941 xtype: 'ColumnModel',
2944 dataIndex : 'coitem_price_tax',
2945 header : 'Sell @w/GST',
2948 renderer : function(v,x,r) {
2950 if (parseInt(v) < 1) {
2951 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,3));
2954 return String.format('{0}', Roo.util.Format.number(v,3));
2957 xtype: 'GridEditor',
2960 xtype: 'NumberField',
2963 focus : function (_self)
2965 if (this.value == 0.0) {
2966 this.el.dom.value = '';
2970 decimalPrecision : 3,
2972 style : 'text-align:right'
2977 xtype: 'ColumnModel',
2980 dataIndex : 'coitem_linedisc',
2983 renderer : function(v,x,r) {
2985 // coitem_custprice = coitem_price * ((100 - coitem_disc)/ 100)
2987 // 12 * (( 100 - 0) / 100)
2988 // coitem_custprice / coitem_price = ((100 - coitem_disc)/ 100)
2989 // 100 - ((coitem_custprice / coitem_price) * 100) = coitem_disc
2990 // 100 - 97 = 100 -3
2992 // r.data.coitem_linedisc = 100 - (
2993 // (parseFloat(r.data.coitem_custprice) /
2994 // parseFloat(r.data.coitem_price)
2996 var fl = parseFloat(r.data.coitem_linedisc);
2997 if ( isNaN(fl) || fl == 0.0 || r.data.coitem_price > r.data.coitem_custprice) {
3000 return String.format('<span style="color:green">{0}%</span>', Roo.util.Format.number( r.data.coitem_linedisc,2));
3003 xtype: 'GridEditor',
3006 xtype: 'NumberField',
3009 focus : function (_self)
3011 if (this.value == 0.0) {
3012 this.el.dom.value = '';
3016 decimalPrecision : 2,
3019 style : 'text-align:right'
3024 xtype: 'ColumnModel',
3027 dataIndex : 'coitem_custprice',
3028 header : 'List Price',
3030 renderer : function(v,x,r) {
3032 var rate = _this.form.findField('taxzone_rate').getValue();
3033 r.data.coitem_custprice_tax = v * ( 1 + rate * 1 );
3035 var tip = 'No WRP available';
3036 if ((r.data.coitem_wrpprice * 1) > 0) {
3037 tip = "WRP : " + Roo.util.Format.number(r.data.coitem_wrpprice,3);
3039 // less than zero, show as red..
3040 if (parseFloat(v) < 1) {
3041 return String.format('<b qtip="{1}" style="color:red;">{0}</b>',
3042 Roo.util.Format.number(v,3), tip);
3044 if (r.data.customer_price_each != v) {
3045 return String.format('<b qtip="{1}" style="color:pink;">{0}</b>',
3046 Roo.util.Format.number(v,3),
3047 "List Price = " + Roo.util.Format.number(r.data.customer_price_each,3)
3053 //r.data.coitem_subtotal = v * r.data.coitem_qtyord;
3055 //r.set('coitem_subtotal', v * r.data.coitem_qtyord);
3057 return String.format('<span qtip="{1}">{0}</span>', Roo.util.Format.number(v,3), tip);
3060 xtype: 'GridEditor',
3063 xtype: 'NumberField',
3066 focus : function (_self)
3068 if (this.value == 0.0) {
3069 this.el.dom.value = '';
3073 decimalPrecision : 3,
3075 style : 'text-align:right'
3080 xtype: 'ColumnModel',
3083 dataIndex : 'coitem_custprice_tax',
3084 header : 'List Price w/GST',
3087 renderer : function(v,x,r) {
3088 var rate = _this.form.findField('taxzone_rate').getValue();
3089 var tip = 'No WRP available';
3090 if ((r.data.coitem_wrpprice * 1) > 0) {
3091 tip = "WRP : " + Roo.util.Format.number(r.data.coitem_wrpprice,3);
3094 if (parseFloat(v) < 1) {
3095 return String.format('<b qtip="{1}" style="color:red;">{0}</b>',
3096 Roo.util.Format.number(v,3), tip);
3098 if (r.data.customer_price_each != v) {
3099 return String.format('<b qtip="{1}" style="color:pink;">{0}</b>',
3100 Roo.util.Format.number(v,3),
3101 "List Price = " + Roo.util.Format.number(r.data.customer_price_each * ( 1 + rate * 1 ),3)
3105 return String.format('<span qtip="{1}">{0}</span>', Roo.util.Format.number(v,3), tip);
3108 xtype: 'GridEditor',
3111 xtype: 'NumberField',
3114 focus : function (_self)
3116 if (this.value == 0.0) {
3117 this.el.dom.value = '';
3121 decimalPrecision : 3,
3123 style : 'text-align:right'
3128 xtype: 'ColumnModel',
3131 dataIndex : 'coitem_subtotal',
3132 header : 'SubTotal',
3134 renderer : function(v) {
3136 if (parseInt(v) < 1) {
3137 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,2));
3142 return Roo.util.Format.number( v, 2);
3146 xtype: 'ColumnModel',
3149 dataIndex : 'coitem_subtotal_tax',
3150 header : 'SubTotal w/GST',
3153 renderer : function(v,x,r) {
3155 if (parseInt(v) < 1) {
3156 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,2));
3159 return String.format('{0}', Roo.util.Format.number(v,2));
3163 xtype: 'ColumnModel',
3166 dataIndex : 'coitem_unitcost_in_order_cur',
3167 header : 'Unit Cost',
3169 renderer : function(v) { return Roo.util.Format.number( v, 2); }
3172 xtype: 'ColumnModel',
3175 dataIndex : 'coitem_taxtype_id',
3178 renderer : function(v,x,r) { return String.format('{0}', r.data.coitem_taxtype_id_taxtype_name); },
3180 xtype: 'GridEditor',
3186 displayField : 'taxtype_name',
3188 emptyText : "Select Tax Type",
3189 forceSelection : true,
3190 hiddenName : 'coitem_taxtype_id',
3192 loadingText : "Searching...",
3194 name : 'coitem_taxtype_id_taxtype_name',
3196 qtip : "Select taxtype",
3197 queryParam : 'query[taxtype_id]',
3198 selectOnFocus : true,
3199 tpl : '<div class="x-grid-cell-text x-btn button"><b>{taxtype_name}</b> </div>',
3200 triggerAction : 'all',
3202 valueField : 'taxtype_id',
3208 beforeload : function (_self, o){
3209 o.params = o.params || {};
3216 sortInfo : { direction : 'ASC', field: 'taxtype_name' },
3221 url : baseURL + '/Roo/taxtype.php'
3224 xtype: 'JsonReader',
3228 totalProperty : 'total',
3229 fields : [{"name":"taxtype_id","type":"int"},"taxtype_name"]
3236 xtype: 'ColumnModel',
3239 dataIndex : 'avail_qty',
3242 renderer : function(v,x,r) {
3244 var oq = parseInt(r.data.coitem_qtyord);
3245 var aq = parseInt(r.data.avail_qty);
3246 var sq = parseInt(r.data.coitem_qtyshipped);
3247 aq = isNaN(aq) ? 0 : aq;
3248 oq = isNaN(oq) ? 0 : oq;
3249 sq = isNaN(sq) ? 0 : sq;
3251 var unshipped = oq - sq;
3253 if ( aq < 0 || (unshipped > 0 && aq < unshipped)) {
3254 return String.format('<b style="color:red;">{0}</b>', parseInt(aq));
3257 return String.format('{0}', aq);
3262 xtype: 'ColumnModel',
3265 dataIndex : 'shipitem_shipped',
3266 header : '#reserved',
3268 renderer : function(v,x,r) {
3271 var vv = parseInt(v);
3272 vv = isNaN(vv) ? 0 : vv;
3274 var ov = parseInt(r.data.coitem_qtyord);
3275 ov = isNaN(ov) ? 0 : ov;
3277 var qs = parseInt(r.data.coitem_qtyshipped);
3278 qs = isNaN(qs) ? 0 : qs;
3283 // not enough reserved yet.
3284 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv - qs);
3287 return String.format('{0}', vv - qs);
3292 xtype: 'ColumnModel',
3295 dataIndex : 'coitem_qtyshipped',
3296 header : '#shipped',
3298 renderer : function(v,x,r) {
3300 var vv = parseInt(v);
3301 vv = isNaN(vv) ? 0 : vv;
3303 var ov = parseInt(r.data.coitem_qtyord);
3304 ov = isNaN(ov) ? 0 : ov;
3308 // not enought shipped.
3309 // or too many shipped.
3310 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv);
3315 return String.format('{0}', vv);
3320 xtype: 'ColumnModel',
3323 dataIndex : 'cobill_billed',
3324 header : '#invoiced',
3326 renderer : function(v,x,r) {
3328 var vv = parseInt(v);
3329 vv = isNaN(vv) ? 0 : vv;
3331 var ov = parseInt(r.data.coitem_qtyord);
3332 ov = isNaN(ov) ? 0 : ov;
3336 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv);
3338 return String.format('{0}', vv);
3346 xtype: 'NestedLayoutPanel',
3349 activate : function (_self)
3351 _this.shipinvtab = _self;
3355 title : "Shipments / Invoices",
3357 xtype: 'BorderLayout',
3364 activate : function() {
3365 _this.shippanel = this;
3366 if (_this.shipgrid) {
3367 _this.shipgrid.ds.load({});
3372 fitContainer : true,
3375 tableName : 'shiphead',
3383 _this.shipgrid = this;
3384 //_this.dialog = Pman.Dialog.FILL_IN
3385 if (_this.shippanel.active) {
3389 rowdblclick : function (_self, rowIndex, e)
3391 var rec = this.ds.getAt(rowIndex);
3392 if (!rec.json.shiphead_shipdate.length) {
3393 Roo.MessageBox.alert("Error", "You can not edit voided shipments, create a new one, and use the restore feature");
3397 Pman.Dialog.XtupleShipment.show({
3398 shiphead_id : rec.data.shiphead_id
3407 autoExpandColumn : 'shiphead_shipvia',
3413 beforeload : function (_self, options)
3415 options.params = options.params || {};
3416 options.params.shiphead_order_id = _this.form.findField('cohead_id').getValue() * 1;
3417 if (options.params.shiphead_order_id < 1) {
3423 sortInfo : { field : 'shiphead_shipvia', direction: 'ASC' },
3428 url : baseURL + '/Roo/shiphead.php'
3431 xtype: 'JsonReader',
3433 totalProperty : 'total',
3438 'name': 'shiphead_number',
3442 'name': 'shiphead_shipvia',
3446 'name': 'shiphead_shipdate',
3450 'name': 'shiphead_sfstatus'
3453 'name': 'shiphead_tracknum',
3469 var sel = _this.shipgrid.getSelectionModel().getSelected();
3471 Roo.MessageBox.alert("Error", "Select a shipment");
3474 if (sel.data.shiphead_shipped) {
3475 Roo.MessageBox.alert("Error", "Shipment is already confirmed");
3480 // check current status of shipment..
3485 url : baseURL + '/Roo/shiphead',
3489 shiphead_id : sel.data.shiphead_id,
3492 success : function() {
3493 _this.shipgrid.ds.load({});
3500 cls : 'x-btn-text-icon',
3501 text : "Confirm Shipment",
3502 icon : rootURL + '/Pman/templates/images/lock.gif'
3510 var sel = _this.shipgrid.getSelectionModel().getSelected();
3512 Roo.MessageBox.alert("Error", "Select a shipment");
3517 // check current status of shipment..
3521 url : baseURL + '/Roo/shiphead',
3524 _download :sel.data.shiphead_id
3532 cls : 'x-btn-text-icon',
3533 text : "Download (as xls)",
3534 icon : rootURL + '/Pman/templates/images/save.gif'
3542 var sel = _this.shipgrid.getSelectionModel().getSelected();
\r
3544 Roo.MessageBox.alert("Error", "Select a shipment");
\r
3547 // check current status of shipment..
3550 url : baseURL + '/Xtuple/Print',
3553 template : 'picking-slip',
3554 param : "shiphead_id:integer='" + sel.data.shiphead_id + "'",
3555 filename : 'picking-slip-' + sel.data.shiphead_number
3557 success : function() {
3566 cls : 'x-btn-text-icon',
3567 text : "Print Picking Slip",
3568 icon : rootURL + '/Pman/templates/images/pdf.gif'
3576 var sel = _this.shipgrid.getSelectionModel().getSelected();
\r
3578 Roo.MessageBox.alert("Error", "Select a shipment");
\r
3581 // check current status of shipment..
3584 url : baseURL + '/Xtuple/Print',
3587 template : 'delivery-note-',
3588 param : "shiphead_id:integer='" + sel.data.shiphead_id + "'",
3589 filename : 'delivery-note-' + sel.data.shiphead_number
3591 success : function() {
3600 cls : 'x-btn-text-icon',
3601 text : "Print Delivery Note",
3602 icon : rootURL + '/Pman/templates/images/pdf.gif'
3614 if (!_this.form.findField('cohead_id').getValue()) {
3615 Roo.MessageBox.alert("Error", "Save Order first");
3618 var rv = _this.form.getFieldValues();
3620 Pman.Dialog.XtupleShipmentNew.show({
3621 shiphead_order_id : rv.cohead_id,
3622 shiphead_shipdate : _this.form.findField('cohead_targetdate').getValue().format('Y-m-d')
3625 _this.shipgrid.ds.load({});
3629 render : function (_self)
3631 _this.addShipmentBtn = _self;
3634 cls : 'x-btn-text-icon',
3636 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
3644 var sel = _this.shipgrid.getSelectionModel().getSelected();
3646 Roo.MessageBox.alert("Error", "Select a shipment");
3649 // check current status of shipment..
3651 var msg = sel.data.shiphead_shipped ?
3652 "Are you sure you want to un-confirm that shipment? - It will remove items from unposted invoices" :
3653 "Are you sure you want to void that shipment?";
3655 Roo.MessageBox.confirm("Are you sure", msg,
3663 url : baseURL + '/Roo/shiphead',
3667 shiphead_id : sel.data.shiphead_id,
3670 success : function() {
3671 _this.shipgrid.ds.load({});
3684 cls : 'x-btn-text-icon',
3685 text : "Void / Unconfirm",
3686 icon : rootURL + '/Pman/templates/images/trash.gif'
3692 xtype: 'ColumnModel',
3694 dataIndex : 'shiphead_number',
3697 renderer : function(v,x,r) {
3698 if (r.json.shiphead_shipdate.length) {
3699 return String.format('{0}', v);
3701 return String.format('<s>{0}</s>', v);
3705 xtype: 'ColumnModel',
3707 dataIndex : 'shiphead_location_id_location_name',
3708 header : 'From Location',
3710 renderer : function(v) { return String.format('{0}', v); }
3713 xtype: 'ColumnModel',
3715 dataIndex : 'shiphead_shipto_id_shipto_name',
3718 renderer : function(v) { return String.format('{0}', v); }
3721 xtype: 'ColumnModel',
3723 header : 'shipdate',
3725 dataIndex : 'shiphead_shipdate',
3726 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
3729 xtype: 'ColumnModel',
3731 dataIndex : 'shiphead_sfstatus',
3734 renderer : function(v,x,r) {
3739 if (r.json.shiphead_shipdate.length) {
3741 if (r.json.shiphead_shipped) {
3745 return '<span style="color:red">Draft</span>';
3754 xtype: 'ColumnModel',
3758 dataIndex : 'shiphead_shipvia',
3759 renderer : function(v) { return String.format('{0}', v); }
3762 xtype: 'ColumnModel',
3764 header : 'tracknum',
3766 dataIndex : 'shiphead_tracknum',
3767 renderer : function(v) { return String.format('{0}', v); }
3776 activate : function() {
3777 _this.invpanel = this;
3778 if (_this.invgrid) {
3779 _this.invgrid.ds.load({});
3784 fitContainer : true,
3787 tableName : 'cobmisc',
3795 _this.invgrid = this;
3796 //_this.dialog = Pman.Dialog.FILL_IN
3797 if (_this.invpanel.active) {
3801 rowdblclick : function (_self, rowIndex, e)
3804 var ri = this.ds.getAt(rowIndex);
3805 if ( ri.data.cobmisc_id < 0) { // skip summary row..
3808 var rv = _this.form.getFieldValues();
3809 Pman.Dialog.XtupleInvoice.show({
3810 cobmisc_id : ri.data.cobmisc_id,
3811 // below parms for add credit memo
3813 cm_cust_id : rv.cohead_cust_id,
3814 cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,
3815 cm_curr_id : rv.cohead_curr_id,
3816 cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,
3817 cm_terms_id : rv.cohead_terms_id,
3818 cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,
3819 cm_salesrep_id : rv.cohead_salesrep_id,
3820 cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,
3821 cm_docdate : new Date(),
3822 cm_taxzone_id : rv.cohead_taxzone_id,
3823 cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,
3824 cm_billto_cntct_id : rv.cohead_billto_cntct_id,
3825 cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,
3826 cm_location_src : rv.cohead_location_src,
3827 cm_location_src_location_name : rv.cohead_location_src_location_name,
3828 cm_billto_address : rv.billto_address
3832 _this.invgrid.ds.load({});
3837 autoExpandColumn : 'invchead_invcnumber',
3843 beforeload : function (_self, options)
3846 options.params = options.params || {};
3847 options.params.cobmisc_cohead_id = _this.form.findField('cohead_id').getValue() * 1;
3848 if (options.params.cobmisc_cohead_id < 1) {
3852 options.params._with_other_payment = 1;
3853 //options.params['query[invchead_ordernumber]'] = _this.form.findField('cohead_number').getValue()
3856 load : function (_self, records, options)
3861 var totalfreight = 0.0;
3862 var totalmisc = 0.0;
3865 Roo.each(records, function(r)
3867 if(r.data.cobmisc_id > 1){
3868 done += parseInt(r.data.cobmisc_qty);
3869 totalic += parseFloat(r.data.cobmisc_itemcost).toFixed(2)*1;
3870 totalmisc += parseFloat(r.data.cobmisc_misc).toFixed(2)*1;
3871 totalfreight += parseFloat(r.data.cobmisc_freight).toFixed(2)*1;
3872 totaltax += parseFloat(r.data.cobmisc_tax).toFixed(2)*1;
3873 total = parseInt(r.data.cobmisc_total_qty);
3878 _this.shipinvtab.layout.getRegion('center').getPanel(0).setTitle(
3880 "Invoices (Complete)" :
3881 ("Invoices prepared for " + done + '/' + total)
3885 var frtotal = (parseFloat(_this.form.findField('cohead_freight').getValue()) - totalfreight).toFixed(2);
3886 var misctotal = (parseFloat(_this.form.findField('cohead_misc').getValue()) - totalmisc).toFixed(2);
3887 var ictotal = (parseFloat(_this.form.findField('cohead_subtotal').getValue()) - totalic).toFixed(2);
3888 var taxtotal = (parseFloat(_this.form.findField('cohead_tax').getValue()) - totaltax).toFixed(2);
3889 var remtotal = frtotal*1 + misctotal*1 + ictotal*1 + taxtotal*1;
3891 var nr = this.reader.newRow({
3893 cobmisc_invchead_id_invchead_invcnumber : "Total Remaining",
3894 cobmisc_qty : total - done,
3895 cobmisc_freight :frtotal,
3896 cobmisc_misc : misctotal,
3897 cobmisc_itemcost : ictotal,
3898 cobmisc_tax : taxtotal,
3899 cobmisc_total : remtotal
3903 // do we need to add it somehow??
3904 _this.invgrid.ds.add(nr);
3908 sortInfo : { field : 'invchead_invcnumber', direction: 'ASC' },
3913 url : baseURL + '/Roo/cobmisc.php'
3916 xtype: 'JsonReader',
3920 totalProperty : 'total',
3923 'name': 'invchead_invcnumber',
3927 'name': 'invchead_invcdate',
3944 var sel = _this.invgrid.getSelectionModel().getSelected();
3946 Roo.MessageBox.alert("Error", "Select a invoice");
3949 // check current status of shipment..
3951 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to Post that invoice?",
3958 url : baseURL + '/Roo/cobmisc',
3961 cobmisc_id : sel.data.cobmisc_id,
3964 success : function() {
3965 _this.invgrid.ds.load({});
3976 cls : 'x-btn-text-icon',
3977 text : "Post Invoice",
3978 icon : rootURL + '/Pman/templates/images/lock.gif'
3983 cls : 'x-btn-text-icon',
3985 icon : rootURL + '/Pman/templates/images/pdf.gif',
3997 var sel = _this.invgrid.getSelectionModel().getSelected();
3999 Roo.MessageBox.alert("Error", "Select a invoice");
4002 if (!sel.data.cobmisc_invchead_id) {
4003 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4006 // check current status of shipment..
4009 url : baseURL + '/Roo/invchead',
4012 invchead_id : sel.data.cobmisc_invchead_id,
4015 success : function() {
4024 text : "Print Standard Invoice"
4030 click : function (_self, e)
4033 var sel = _this.invgrid.getSelectionModel().getSelected();
4035 Roo.MessageBox.alert("Error", "Select a invoice");
4038 if (!sel.data.cobmisc_invchead_id) {
4039 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4042 // check current status of shipment..
4045 url : baseURL + '/Roo/invchead',
4048 invchead_id : sel.data.cobmisc_invchead_id,
4052 success : function() {
4060 text : "Print Chinese Invoice With GST in line item",
4061 hidden : !(baseURL.match(/(hk\.php|cn\.php)$/))
4067 click : function (_self, e)
4070 var sel = _this.invgrid.getSelectionModel().getSelected();
4072 Roo.MessageBox.alert("Error", "Select a invoice");
4075 if (!sel.data.cobmisc_invchead_id) {
4076 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4079 // check current status of shipment..
4082 url : baseURL + '/Roo/invchead',
4085 invchead_id : sel.data.cobmisc_invchead_id,
4089 success : function() {
4097 text : "Print Chinese Invoice",
4098 hidden : !(baseURL.match(/(hk\.php|cn\.php)$/))
4104 click : function (_self, e)
4107 var sel = _this.invgrid.getSelectionModel().getSelected();
4109 Roo.MessageBox.alert("Error", "Select a invoice");
4112 if (!sel.data.cobmisc_invchead_id) {
4113 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4116 // check current status of shipment..
4119 url : baseURL + '/Roo/invchead',
4122 invchead_id : sel.data.cobmisc_invchead_id,
4126 success : function() {
4134 text : "Print Aus - GST included Invoice",
4135 hidden : !(baseURL.match(/au\.php$/))
4141 click : function (_self, e)
4143 var sel = _this.invgrid.getSelectionModel().getSelected();
4145 Roo.MessageBox.alert("Error", "Select a invoice");
4148 if (!sel.data.cobmisc_invchead_id) {
4149 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4152 // check current status of shipment..
4155 url : baseURL + '/Roo/invchead',
4158 invchead_id : sel.data.cobmisc_invchead_id,
4168 text : "Print Bambini Pronto Invoice",
4169 hidden : !(baseURL.match(/au\.php$/))
4175 click : function (_self, e)
4178 var sel = _this.invgrid.getSelectionModel().getSelected();
4180 Roo.MessageBox.alert("Error", "Select a invoice");
4183 if (!sel.data.cobmisc_invchead_id) {
4184 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4187 // check current status of shipment..
4190 url : baseURL + '/Roo/invchead',
4193 invchead_id : sel.data.cobmisc_invchead_id,
4194 _print : 'au-proforma'
4197 success : function() {
4205 text : "Print Bambini Pro Forma Invoice",
4206 hidden : !(baseURL.match(/au\.php$/))
4212 click : function (_self, e)
4214 var sel = _this.invgrid.getSelectionModel().getSelected();
4216 Roo.MessageBox.alert("Error", "Select a invoice");
4220 Pman.Dialog.XtupleDiscountOfInvoice.show({invchead_id : sel.data.cobmisc_invchead_id}, function(){
4225 text : "Print Shipping / Commercial Invoice",
4226 hidden : !( baseURL.match(/au\.php$/))
4234 cls : 'x-btn-text-icon',
4235 text : "Payments / Refunds / Credit Memos",
4236 icon : Roo.rootURL + 'images/default/tree/leaf.gif',
4245 click : function(_self,e)
4248 var sel = _this.invgrid.getSelectionModel().getSelected();
4249 if (!sel || sel.data.cobmisc_id < 1) {
4250 Roo.MessageBox.alert("Error", "Select a invoice");
4253 if(!sel.data.cobmisc_posted){
4254 Roo.MessageBox.alert("Error", "This invoice has not been posted!");
4257 if(sel.data.cobmisc_outstanding == 0){
4258 Roo.MessageBox.alert("Error", "There is no any outstanding of this invoice!");
4262 var cust_id = _this.form.findField('cohead_cust_id').getValue();
4267 cashrcpt_amount : sel.data.cobmisc_outstanding,
4268 cashrcpt_cust_id : cust_id,
4269 cashrcpt_aropen_id : sel.data.cobmisc_aropen_id_aropen_id,
4270 cashrcpt_distdate : new Date(),
4271 cashrcpt_fundstype : 'C',
4272 cashrcpt_curr_id : sel.data.cobmisc_curr_id_curr_id,
4273 cashrcpt_curr_id_curr_name : sel.data.cobmisc_curr_id_curr_name,
4274 cashrcpt_usecustdeposit : true,
4275 cashrcpt_docdate : new Date(),
4276 cashrcpt_salescat_id : -1,
4277 cashrcpt_applydate : new Date(),
4278 cashrcpt_discount : 0
4280 Pman.Dialog.XtupleReceivePayment.show( data , function() {
4281 _this.invgrid.ds.load({});
4285 cls : 'x-btn-text-icon',
4286 text : "Receive Payment",
4287 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4293 click : function(_self,e)
4295 var sel = _this.invgrid.getSelectionModel().getSelected();
4296 if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {
4297 Roo.MessageBox.alert("Error", "Select a credit memo");
4300 if(!sel.data.cobmisc_posted){
4301 Roo.MessageBox.alert("Error", "The invoice that credit memo has been applied to has been not posted");
4304 var cust_id = _this.form.findField('cohead_cust_id').getValue();
4309 if(!sel.data.cobmisc_outstanding || sel.data.cobmisc_outstanding == 0){
4310 Roo.MessageBox.alert("Error", "The amount of this credit memo is 0!");
4314 var d = _this.form.getFieldValues();
4317 'checkhead_recip_id' : cust_id,
4318 'checkhead_recip_type' : 'C',
4319 'checkhead_checkdate' : new Date(),
4320 'checkhead_amount' : sel.data.cobmisc_outstanding,
4321 'remaining_total' : sel.data.cobmisc_outstanding,
4322 'checkhead_curr_id' : d.cohead_curr_id,
4323 'checkhead_curr_id_curr_name' : d.cohead_curr_id_curr_name,
4324 'checkhead_misc' : true,
4325 'aropen_id' : sel.data.cobmisc_cobapply_aropen_id,
4326 'cmhead_number' : sel.data.cobmisc_invchead_id_invchead_invcnumber,
4327 'cust_name' : d.cohead_cust_id_cust_name,
4328 '_create_and_post' : 1
4333 Pman.Dialog.XtupleMiscellaneousCheck.show( data , function() {
4334 _this.invgrid.ds.load({});
4338 cls : 'x-btn-text-icon',
4339 text : "Issue Refund",
4340 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4350 click : function(_self,e)
4352 var sel = _this.invgrid.getSelectionModel().getSelected();
4353 if (!sel || sel.data.cobmisc_cashrcpt_id * 1 < 1) {
4354 Roo.MessageBox.alert("Error", "Select a Receive Payment");
4358 Roo.MessageBox.confirm("Confirm", "Voiding receipt will mean you will have to re-enter the receipt refund - " +
4359 "please take note of the details so you can enter it again correctly later.", function(r) {
4365 url : baseURL + '/Roo/cashrcpt',
4368 cashrcpt_id : sel.data.cobmisc_cashrcpt_id,
4371 success : function()
4373 _this.invgrid.ds.load({});
4383 cls : 'x-btn-text-icon',
4384 text : "Void Payment",
4385 icon : rootURL + '/Pman/templates/images/trash.gif'
4391 click : function(_self,e)
4393 var sel = _this.invgrid.getSelectionModel().getSelected();
4394 if (!sel || sel.data.cobmisc_checkhead_id * 1 < 1) {
4395 Roo.MessageBox.alert("Error", "Select a Miscellaneours Check");
4399 Roo.MessageBox.confirm("Confirm", "Voiding refund will mean you will have to re-enter the receipt refund - " +
4400 "please take note of the details so you can enter it again correctly later.", function(r) {
4406 url : baseURL + '/Roo/checkhead',
4409 checkhead_id : sel.data.cobmisc_checkhead_id,
4412 success : function()
4414 _this.invgrid.ds.load({});
4424 cls : 'x-btn-text-icon',
4425 text : "Void Refund",
4426 icon : rootURL + '/Pman/templates/images/trash.gif'
4432 click : function(_self,e)
4434 var sel = _this.invgrid.getSelectionModel().getSelected();
4435 if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {
4436 Roo.MessageBox.alert("Error", "Select a credit memo");
4440 if(sel.data.cobmisc_posted){
4441 Roo.MessageBox.alert("Error", "You cann't void this credit memo, since the invoice that credit memo has been applied to has been posted");
4445 if (sel.data.cobmisc_cobapply_id < 1) {
4446 Roo.MessageBox.alert("Error", "invaild credit memo");
4449 Roo.MessageBox.confirm("Confirm", "Are you sure want to void this applied credit memo, " +
4450 "it will also void all the check that belongs to this credit memo ", function(r) {
4456 url : baseURL + '/Roo/cobapply',
4459 _delete : sel.data.cobmisc_cobapply_id,
4462 success : function()
4464 _this.invgrid.ds.load({});
4473 cls : 'x-btn-text-icon',
4474 text : "Void Credit Memo",
4475 icon : rootURL + '/Pman/templates/images/trash.gif'
4491 if (!_this.form.findField('cohead_id').getValue()) {
4492 Roo.MessageBox.alert("Error", "Save Order first");
4496 var rv = _this.form.getFieldValues();
4499 Pman.Dialog.XtupleInvoice.show({
4500 cobmisc_cohead_id : rv.cohead_id,
4501 cobmisc_shipdate : _this.form.findField('cohead_targetdate').getValue(),
4502 cobmisc_invcdate : _this.form.findField('cohead_targetdate').getValue(),
4503 cobmisc_curr_id : rv.cohead_curr_id,
4504 cobmisc_curr_id_curr_name : rv.cohead_curr_id_curr_name,
4505 // below parms for add credit memo
4507 cm_cust_id : rv.cohead_cust_id,
4508 cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,
4509 cm_curr_id : rv.cohead_curr_id,
4510 cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,
4511 cm_terms_id : rv.cohead_terms_id,
4512 cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,
4513 cm_salesrep_id : rv.cohead_salesrep_id,
4514 cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,
4515 cm_docdate : new Date(),
4516 cm_taxzone_id : rv.cohead_taxzone_id,
4517 cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,
4518 cm_billto_cntct_id : rv.cohead_billto_cntct_id,
4519 cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,
4520 cm_location_src : rv.cohead_location_src,
4521 cm_location_src_location_name : rv.cohead_location_src_location_name,
4522 cm_billto_address : rv.billto_address
4527 _this.invgrid.ds.load({});
4531 render : function (_self)
4533 _this.addInvoiceBtn = _self;
4536 cls : 'x-btn-text-icon',
4538 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4547 var sel = _this.invgrid.getSelectionModel().getSelected();
4549 Roo.MessageBox.alert("Error", "Select a invoice");
4552 // check current status of shipment..
4555 // cobmisc_id : sel.data.cobmisc_id,
4558 if (sel.data.cobmisc_id * 1) {
4559 params.cobmisc_id = sel.data.cobmisc_id * 1 ;
4561 if (sel.data.cobmisc_invchead_id_invchead_id * 1) {
4562 params.invchead_id = sel.data.cobmisc_invchead_id_invchead_id * 1;
4565 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to VOID that invoice?",
4572 url : baseURL + '/Roo/cobmisc',
4575 success : function() {
4576 _this.invgrid.ds.load({});
4587 cls : 'x-btn-text-icon',
4588 text : "Void / Unpost",
4589 icon : rootURL + '/Pman/templates/images/trash.gif'
4595 xtype: 'ColumnModel',
4597 dataIndex : 'cobmisc_invchead_id_invchead_invcnumber',
4598 header : 'Invoice #',
4600 renderer : function(v,x,r) {
4602 r.data.cobmisc_invchead_id_invchead_id * 1 &&
4603 !r.data.cobmisc_invchead_id_invchead_posted) {
4604 return '<span style="color:red">' +
4605 "NEEDS Voiding then re-posted: " +
4606 String.format('{0}', v) +
4610 if(v && r.data.cobmisc_id == -2){
4611 return String.format('<span style="margin-left: 10px;"> - {0} (Credit Memo)</span>', v);
4613 if(v && r.data.cobmisc_id == -3){
4614 return String.format('<span style="margin-left: 20px;"> - {0} (Miscellaneous Check)</span>', v);
4616 if(v && r.data.cobmisc_id == -4){
4617 return String.format('<span style="margin-left: 10px;"> - {0} (Receive Payment) [ {1} ]</span>', v, r.data.cobmisc_cashrcpt_amount);
4620 return v ? String.format('{0}', v) :
4621 '<span style="color:red">' + "Not Posted" + '</span>';
4625 xtype: 'ColumnModel',
4627 dataIndex : 'cobmisc_invcdate',
4628 header : 'invcdate',
4630 renderer : function(v,x,r) {
4632 return String.format('{0}', v && r.data.cobmisc_id > 0 ? v.format('d/M/Y') : '');
4636 xtype: 'ColumnModel',
4639 dataIndex : 'cobmisc_qty',
4642 renderer : function(v) { return String.format('{0}', v ? parseInt(v) : 0); }
4645 xtype: 'ColumnModel',
4648 dataIndex : 'cobmisc_itemcost',
4649 header : 'Item Cost',
4651 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }
4654 xtype: 'ColumnModel',
4657 dataIndex : 'cobmisc_freight',
4658 header : 'Shipping',
4660 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : ''); }
4663 xtype: 'ColumnModel',
4666 dataIndex : 'cobmisc_tax',
4669 renderer : function(v,x,r) {
4671 // tax is based on the % itemcost..
4672 // var ic = r.data.cobmisc_itemcost;
4674 var ic =r.data.cobmisc_itemcost - (1* r.data.cobmisc_itemcost_taxfree);
4676 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
4677 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
4681 var taxp = tax / totic;
4684 return String.format('{0}', (1.0*v).toFixed(2) );
4690 xtype: 'ColumnModel',
4693 dataIndex : 'cobmisc_cohead_id_cohead_pretax_discount',
4694 header : 'Discount (Pretax)',
4696 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }
4699 xtype: 'ColumnModel',
4702 dataIndex : 'cobmisc_misc',
4703 header : 'Discount (Posttax)',
4705 renderer : function(v,x,r)
4707 var vv = v - r.data.cobmisc_cohead_id_cohead_pretax_discount;
4709 return String.format('{0}', vv ? (1.0*vv).toFixed(2) : 0);
4713 xtype: 'ColumnModel',
4716 dataIndex : 'cobmisc_total',
4719 renderer : function(v,x,r) {
4722 var ic = r.data.cobmisc_itemcost;
4723 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
4724 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
4727 var taxp = tax / totic;
4735 return String.format('{0}',(v * 1.0).toFixed(2) );
4739 return String.format('{0}',
4740 ((d.cobmisc_itemcost * 1.0) +
4741 (d.cobmisc_freight * 1.0) +
4742 (d.cobmisc_tax * 1.0) +
4743 (d.cobmisc_misc * 1.0)
4749 xtype: 'ColumnModel',
4752 dataIndex : 'cobmisc_outstanding',
4753 header : 'Outstanding',
4755 renderer : function(v,x,r)
4758 return String.format('{0}', v ? (v * 1.0).toFixed(2) : 0 );
4766 xtype: 'LayoutRegion',
4771 xtype: 'LayoutRegion',
4774 title : "Reserve Stock / Shipments"
4782 activate : function() {
4783 _this.hpanel = this;
4785 _this.hgrid.footer.onClick('first');
4790 fitContainer : true,
4793 tableName : 'events',
4802 //_this.dialog = Pman.Dialog.FILL_IN
4803 if (_this.hpanel.active) {
4804 this.footer.onClick('first');
4807 rowdblclick : function (_self, rowIndex, e)
4809 if (!_this.dialog) return;
4810 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
4811 _this.grid.footer.onClick('first');
4815 autoExpandColumn : 'remarks',
4821 beforeload : function (_self, options)
4823 options.params._related_on_table = 'cohead';
4824 options.params._related_on_id = _this.form.findField('cohead_id').getValue();
4828 sortInfo : { field : 'event_when', direction: 'DESC' },
4833 url : baseURL + '/Roo/events.php'
4836 xtype: 'JsonReader',
4840 totalProperty : 'total',
4843 'name': 'event_when',
4855 'name': 'person_id_name',
4866 xtype: 'PagingToolbar',
4870 displayMsg : "Displaying events{0} - {1} of {2}",
4871 emptyMsg : "No events found"
4875 xtype: 'ColumnModel',
4877 dataIndex : 'event_when',
4880 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); }
4883 xtype: 'ColumnModel',
4885 dataIndex : 'action',
4888 renderer : function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); }
4891 xtype: 'ColumnModel',
4893 dataIndex : 'ipaddr',
4894 header : 'IP address',
4896 renderer : function(v) { return String.format('{0}', v); }
4899 xtype: 'ColumnModel',
4901 dataIndex : 'person_id_name',
4904 renderer : function(v) { return String.format('{0}', v); }
4907 xtype: 'ColumnModel',
4909 dataIndex : 'remarks',
4912 renderer : function(v) { return String.format('{0}', v); }
4918 xtype: 'NestedLayoutPanel',
4923 xtype: 'BorderLayout',
4930 activate : function() {
4931 _this.txpanel = this;
4933 _this.txgrid.footer.onClick('first');
4938 fitContainer : true,
4941 tableName : 'invdetail',
4942 title : "invdetail",
4949 _this.txgrid = this;
4950 //_this.dialog = Pman.Dialog.FILL_IN
4951 if (_this.txpanel.active) {
4952 this.footer.onClick('first');
4956 autoExpandColumn : 'item_number',
4966 click : function (_self, e)
4970 url : baseURL + '/Roo/Cohead',
4973 _apply_fifo : _this.form.findField('cohead_id').getValue()
4975 success : function () {
4976 Roo.MessageBox.alert("Applied", "Succesfully Applied");
4981 text : "Run Apply Fifo on order"
4987 click : function (_self, e)
4991 url : baseURL + '/Roo/Cohead',
4994 _run_void_fix : _this.form.findField('cohead_id').getValue()
4996 success : function () {
4997 Roo.MessageBox.alert("Applied", "Succesfully Run");
5002 text : "Run Void flagger"
5008 click : function (_self, e)
5013 url : baseURL + '/Roo/Invdetail',
5018 _reverse_all_bad : _this.form.findField('cohead_id').getValue()
5020 success : function () {
5021 Roo.MessageBox.alert("Applied", "Succesfully Run");
5026 text : "Auto Reverse"
5031 xtype: 'RowSelectionModel',
5034 selectionchange : function (_self)
5036 _this.txdgrid.footer.onClick('first');;
5045 beforeload : function (_self, o)
5047 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5048 if (! o.params.cohead_id ) {
5055 sortInfo : { field : 'item_number', direction: 'ASC' },
5060 url : baseURL + '/Roo/invdetail.php'
5063 xtype: 'JsonReader',
5065 totalProperty : 'total',
5070 'name': 'invdetail_id',
5074 'name': 'invdetail_transtype',
5078 'name': 'invdetail_invhist_id',
5082 'name': 'invdetail_location_id',
5086 'name': 'invdetail_qty',
5090 'name': 'invdetail_comments',
5094 'name': 'invdetail_qty_before',
5098 'name': 'invdetail_qty_after',
5102 'name': 'invdetail_invcitem_id',
5106 'name': 'invdetail_expiration',
5108 'dateFormat': 'Y-m-d'
5111 'name': 'invdetail_warrpurc',
5113 'dateFormat': 'Y-m-d'
5116 'name': 'invdetail_ls_id',
5123 xtype: 'PagingToolbar',
5126 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5127 emptyMsg : "No invdetail found",
5132 xtype: 'ColumnModel',
5134 dataIndex : 'item_number',
5137 renderer : function(v) { return String.format('{0}', v); }
5140 xtype: 'ColumnModel',
5143 dataIndex : 'rec_shipped',
5146 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5149 xtype: 'ColumnModel',
5152 dataIndex : 'rec_returned',
5155 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5158 xtype: 'ColumnModel',
5161 dataIndex : 'tx_shipped',
5162 header : '#TX ship',
5164 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5167 xtype: 'ColumnModel',
5170 dataIndex : 'tx_returned',
5173 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5176 xtype: 'ColumnModel',
5179 dataIndex : 'tx_total',
5182 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5185 xtype: 'ColumnModel',
5188 dataIndex : 'total_value',
5191 renderer : function(v,x,r) {
5193 return (v*1).toFixed(3);
5197 xtype: 'ColumnModel',
5200 dataIndex : 'tx_total',
5203 renderer : function(v,x,r) {
5205 var cototal = (r.data.rec_returned*1) - (r.data.rec_shipped*1);
5206 // Roo.log(cototal);
5207 var diff = (v*1) - cototal;
5212 return String.format('<span style="color:red">{0}</span>', diff );
5222 activate : function() {
5223 _this.txdpanel = this;
5224 if (_this.txdgrid) {
5225 _this.txdgrid.footer.onClick('first');
5230 fitContainer : true,
5233 tableName : 'invdetail',
5234 title : "invdetail",
5241 _this.txdgrid = this;
5242 //_this.dialog = Pman.Dialog.FILL_IN
5243 if (_this.txdpanel.active) {
5244 this.footer.onClick('first');
5247 rowclick : function (_self, rowIndex, e)
5249 var s = _this.txdgrid.ds.getAt(rowIndex);
5250 var dt = s.data.invhist_transdate.split(' ');
5252 _this.dateSel.setValue(new Date(dt[0]));
5255 autoExpandColumn : 'invhist_comments',
5265 click : function (_self, e)
5267 var s = _this.txdgrid.selModel.getSelected();
5270 Roo.MessageBox.alert("Error", "Select a transaction");
5274 var reverseSel = function() {
5278 url : baseURL + '/Roo/invdetail',
5281 _duplicate : s.data.invdetail_id
5283 success : function() {
5284 _this.txdgrid.footer.onClick('first');
5292 Roo.MessageBox.confirm(
5294 "This should only be used by System Administrators - are you sure you know what you are doing!",
5308 text : "Duplicate Selected"
5323 render : function (_self)
5325 _this.dateSel = _self;
5329 fieldLabel : 'Issue Date',
5331 name : 'issue_date',
5338 click : function (_self, e)
5340 var s = _this.txdgrid.selModel.getSelected();
5341 var dt = _this.dateSel.getValue();
5343 Roo.MessageBox.alert("Error", "Select a transaction");
5347 var reverseSel = function(force) {
5351 url : baseURL + '/Roo/invdetail',
5354 _reverse : s.data.invdetail_id,
5355 _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
5358 success : function() {
5359 _this.txdgrid.footer.onClick('first');
5361 failure : function(res) {
5364 if (res.errors.confirm) {
5366 Roo.MessageBox.confirm(
5368 "are you really sure the totals will get messed up.",
5379 Roo.MessageBox.alert("Error", res.errorMsg);
5389 Roo.MessageBox.confirm(
5391 "This should only be used by System Administrators - are you sure you know what you are doing!",
5405 text : "Reverse Selected"
5413 beforeload : function (_self, o)
5415 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5416 var s = _this.txgrid.selModel.getSelected();
5421 o.params.itemsite_id = s.data.invhist_itemsite_id;
5426 sortInfo : { field : 'invdetail_id', direction: 'ASC' },
5431 url : baseURL + '/Roo/invdetail.php'
5434 xtype: 'JsonReader',
5436 totalProperty : 'total',
5441 'name': 'invdetail_id',
5445 'name': 'invdetail_transtype',
5449 'name': 'invdetail_invhist_id',
5453 'name': 'invdetail_location_id',
5457 'name': 'invdetail_qty',
5461 'name': 'invdetail_comments',
5465 'name': 'invdetail_qty_before',
5469 'name': 'invdetail_qty_after',
5473 'name': 'invdetail_invcitem_id',
5477 'name': 'invdetail_expiration',
5479 'dateFormat': 'Y-m-d'
5482 'name': 'invdetail_warrpurc',
5484 'dateFormat': 'Y-m-d'
5487 'name': 'invdetail_ls_id',
5494 xtype: 'PagingToolbar',
5497 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5498 emptyMsg : "No invdetail found",
5503 xtype: 'ColumnModel',
5505 dataIndex : 'invdetail_id',
5508 renderer : function(v) { return String.format('{0}', v); }
5511 xtype: 'ColumnModel',
5513 dataIndex : 'invhist_transdate',
5516 renderer : function(v) { return String.format('{0}', v); }
5519 xtype: 'ColumnModel',
5521 dataIndex : 'invhist_ordnumber',
5524 renderer : function(v,x,r) {
5525 if (r.data.invfifo_void *1 != 0) {
5526 return String.format('<s>{0}</s>', v);
5529 return String.format('{0}', v);
5533 xtype: 'ColumnModel',
5535 dataIndex : 'invhist_comments',
5538 renderer : function(v) { return String.format('{0}', v); }
5541 xtype: 'ColumnModel',
5544 dataIndex : 'invdetail_qty',
5545 header : 'Qty Changed',
5547 renderer : function(v,x,r) {
5548 if ( r.data.coitem_shipped != v) {
5549 return String.format('{0} <span style="color:red">({1})</span>',
5550 Roo.util.Format.number(v,0),
5551 r.data.coitem_shipped
5555 return String.format('{0}', Roo.util.Format.number(v,0));
5559 xtype: 'ColumnModel',
5562 dataIndex : 'invhist_value_before',
5563 header : 'Qty Changed',
5565 renderer : function(v,x,r) {
5566 var tot = r.data.invhist_value_after*1 - v*1;
5568 if (r.data.invdetail_qty >0 && tot < 0) {
5569 f = '<span style="color:red">{0}</span>';
5571 if (r.data.invdetail_qty < 0 && tot > 0) {
5572 f = '<span style="color:red">{0}</span>';
5574 return String.format(f, Roo.util.Format.number(tot));
5578 xtype: 'ColumnModel',
5580 dataIndex : 'invhist_posted',
5583 renderer : function(v,x,r) {
5585 var state = v ? '-checked' : '';
5587 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
5595 xtype: 'LayoutRegion',
5599 xtype: 'LayoutRegion',
5607 xtype: 'NestedLayoutPanel',
5612 xtype: 'BorderLayout',
5619 activate : function() {
5620 _this.gltxpanel = this;
5621 if (_this.gltxgrid) {
5622 _this.gltxgrid.footer.onClick('first');
5627 fitContainer : true,
5630 tableName : 'invdetail',
5631 title : "invdetail",
5638 _this.gltxgrid = this;
5639 //_this.dialog = Pman.Dialog.FILL_IN
5640 if (_this.gltxpanel.active) {
5641 this.footer.onClick('first');
5644 cellclick : function (_self, rowIndex, columnIndex, e)
5646 if (columnIndex > 0) {
5649 var rec = this.ds.getAt(rowIndex);
5650 rec.set('gltrans_as_summary', rec.data.gltrans_as_summary *1 ? 0 : 1);
5651 _this.gltxdgrid.footer.onClick('first');
5654 autoExpandColumn : 'gltrans_accnt_id_accnt_descrip',
5657 xtype: 'RowSelectionModel',
5660 selectionchange : function (_self)
5662 _this.gltxdgrid.footer.onClick('first');;
5671 beforeload : function (_self, o)
5673 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5674 if (! o.params.cohead_id ) {
5678 o.params._split_sales = _this.glsalesbtn.pressed ? 1 : 0;
5682 sortInfo : { field : 'item_number', direction: 'ASC' },
5687 url : baseURL + '/Roo/gltrans.php'
5690 xtype: 'JsonReader',
5692 totalProperty : 'total',
5697 'name': 'invdetail_id',
5701 'name': 'invdetail_transtype',
5705 'name': 'invdetail_invhist_id',
5709 'name': 'invdetail_location_id',
5713 'name': 'invdetail_qty',
5717 'name': 'invdetail_comments',
5721 'name': 'invdetail_qty_before',
5725 'name': 'invdetail_qty_after',
5729 'name': 'invdetail_invcitem_id',
5733 'name': 'invdetail_expiration',
5735 'dateFormat': 'Y-m-d'
5738 'name': 'invdetail_warrpurc',
5740 'dateFormat': 'Y-m-d'
5743 'name': 'invdetail_ls_id',
5750 xtype: 'PagingToolbar',
5753 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5754 emptyMsg : "No invdetail found",
5761 render : function (_self)
5763 _this.glsalesbtn = _self;
5765 click : function (_self, e)
5767 (function() { _this.gltxgrid.footer.onClick('first'); }).defer(100);
5770 enableToggle : true,
5772 text : "Split sales"
5778 xtype: 'ColumnModel',
5780 dataIndex : 'gltrans_as_summary',
5783 renderer : function(v,x,r) {
5785 var state = v*1 ? '-checked' : '';
5787 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
5791 xtype: 'ColumnModel',
5793 dataIndex : 'gltrans_accnt_id_accnt_descrip',
5796 renderer : function(v) { return String.format('{0}', v); }
5799 xtype: 'ColumnModel',
5802 dataIndex : 'gltrans_amount_credit',
5805 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
5808 xtype: 'ColumnModel',
5811 dataIndex : 'gltrans_amount_debit',
5814 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
5817 xtype: 'ColumnModel',
5820 dataIndex : 'gltrans_amount_total',
5823 renderer : function(v) { return String.format('<b>{0}</b>', Roo.util.Format.number(v,3)); }
5826 xtype: 'ColumnModel',
5829 dataIndex : 'gltrans_amount_total_unposted',
5830 header : 'Unposted',
5832 renderer : function(v) { return String.format('<span style="color:red">{0}</span>', Roo.util.Format.number(v,3)); }
5841 activate : function() {
5842 _this.gltxdpanel = this;
5843 if (_this.gltxdgrid) {
5844 _this.gltxdgrid.footer.onClick('first');
5849 fitContainer : true,
5852 tableName : 'invdetail',
5853 title : "invdetail",
5860 _this.gltxdgrid = this;
5861 //_this.dialog = Pman.Dialog.FILL_IN
5862 if (_this.gltxdpanel.active) {
5863 this.footer.onClick('first');
5866 cellclick : function (_self, ri, ci, e)
5869 var deleteSel = function() {
5873 url : baseURL + '/Roo/gltrans',
5877 gltrans_id : rec.data.gltrans_id
5880 success : function() {
5881 rec.set('gltrans_posted', false);
5882 rec.set('gltrans_deleted', true);
5883 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
5884 _this.gltxgrid.footer.onClick('first');
5889 var undeleteSel = function() {
5893 url : baseURL + '/Roo/gltrans',
5897 gltrans_id : rec.data.gltrans_id
5900 success : function() {
5901 rec.set('gltrans_posted', true);
5902 rec.set('gltrans_deleted', false);
5903 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
5904 _this.gltxgrid.footer.onClick('first');
5910 var di = this.colModel.config[ci].dataIndex;
5911 if (di != 'gltrans_posted') {
5917 var rec = this.ds.getAt(ri);
5918 if (rec.data.gltrans_deleted) {
5920 Roo.MessageBox.confirm(
5922 "This should only be used by System Administrators - are you sure you know what you are doing!",
5936 if (!rec.data.gltrans_posted) {
5942 url : baseURL + '/Roo/gltrans',
5946 gltrans_id : rec.data.gltrans_id
5948 success : function (res)
5950 rec.set('gltrans_posted', true);
5951 _this.gltxgrid.footer.onClick('first');
5960 // we have a posted transaction.
5961 // only allow recalled to be deleted..
5962 if (!rec.data.gltrans_notes.match(/(Recall|Ship Order)/)) {
5971 Roo.MessageBox.confirm(
5973 "This should only be used by System Administrators - are you sure you know what you are doing!",
5986 autoExpandColumn : 'gltrans_notes',
5992 beforeload : function (_self, o)
5994 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5995 var s = _this.gltxgrid.selModel.getSelected();
6000 o.params.gltrans_accnt_id = s.data.gltrans_accnt_id;
6001 o.params.gltrans_is_ship = s.data.gltrans_is_ship;
6002 o.params.gltrans_as_summary = s.data.gltrans_as_summary;
6008 sortInfo : { field : 'gltrans_docnumber', direction: 'ASC' },
6013 url : baseURL + '/Roo/gltrans.php'
6016 xtype: 'JsonReader',
6018 totalProperty : 'total',
6023 'name': 'invdetail_id',
6027 'name': 'invdetail_transtype',
6031 'name': 'invdetail_invhist_id',
6035 'name': 'invdetail_location_id',
6039 'name': 'invdetail_qty',
6043 'name': 'invdetail_comments',
6047 'name': 'invdetail_qty_before',
6051 'name': 'invdetail_qty_after',
6055 'name': 'invdetail_invcitem_id',
6059 'name': 'invdetail_expiration',
6061 'dateFormat': 'Y-m-d'
6064 'name': 'invdetail_warrpurc',
6066 'dateFormat': 'Y-m-d'
6069 'name': 'invdetail_ls_id',
6076 xtype: 'PagingToolbar',
6079 displayMsg : "Displaying invdetail{0} - {1} of {2}",
6080 emptyMsg : "No invdetail found",
6087 click : function (_self, e)
6089 new Pman.Download( {
6090 grid : _this.gltxdgrid
6101 xtype: 'ColumnModel',
6103 dataIndex : 'gltrans_id',
6107 renderer : function(v) { return String.format('{0}', v ); }
6110 xtype: 'ColumnModel',
6112 dataIndex : 'gltrans_date',
6115 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
6118 xtype: 'ColumnModel',
6120 dataIndex : 'gltrans_docnumber',
6123 renderer : function(v,x,r) {
6124 if (r.data.gltrans_deleted) {
6125 return String.format('<s>{0}</s>', v);
6127 return String.format('{0}', v);
6131 xtype: 'ColumnModel',
6133 dataIndex : 'gltrans_source',
6136 renderer : function(v) { return String.format('{0}', v); }
6139 xtype: 'ColumnModel',
6141 dataIndex : 'gltrans_notes',
6144 renderer : function(v) { return String.format('{0}', v); }
6147 xtype: 'ColumnModel',
6150 dataIndex : 'gltrans_amount',
6153 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
6156 xtype: 'ColumnModel',
6158 dataIndex : 'gltrans_posted',
6161 renderer : function(v,x,r) {
6163 var state = v ? '-checked' : '';
6165 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
6173 xtype: 'LayoutRegion',
6177 xtype: 'LayoutRegion',
6188 activate : function() {
6189 _this.profitpanel = this;
6191 try { if (MODULE.isBuilder) {
6195 var id = _this.form.findField('cohead_id').getValue() * 1;
6197 Roo.MessageBox.alert("Save First", "Save the order first, before adding items");
6198 _this.dialog.layout.getRegion('center').showPanel(0);
6202 if (_this.profitgrid) {
6203 _this.profitgrid.footer.onClick('first');
6209 fitContainer : true,
6212 tableName : 'coitem',
6220 _this.profitgrid = this;
6221 //_this.dialog = Pman.Dialog.FILL_IN
6222 if (_this.profitpanel.active) {
6223 this.footer.onClick('first');
6227 autoExpandColumn : 'item_number',
6233 beforeload : function (_self,o) {
6240 if (!_this.data || !_this.data.cohead_id) {
6243 o.params = o.params || {};
6245 o.params.coitem_cohead_id = _this.data.cohead_id;
6246 o.params._without_list_discount =1;
6247 o.params._with_profit = 1;
6252 sortInfo : { field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' },
6257 url : baseURL + '/Roo/coitem.php'
6260 xtype: 'JsonReader',
6262 totalProperty : 'total',
6283 'name': 'leader_id',
6287 'name': 'leader_office_id',
6291 'name': 'leader_name',
6295 'name': 'leader_phone',
6299 'name': 'leader_fax',
6303 'name': 'leader_email',
6307 'name': 'leader_company_id',
6311 'name': 'leader_role',
6315 'name': 'leader_active',
6319 'name': 'leader_remarks',
6323 'name': 'leader_passwd',
6327 'name': 'leader_owner_id',
6331 'name': 'leader_lang',
6335 'name': 'leader_no_reset_sent',
6339 'name': 'leader_action_type',
6343 'name': 'leader_project_id',
6347 'name': 'leader_deleted_by',
6351 'name': 'leader_deleted_dt',
6355 'name': 'leader_firstname',
6359 'name': 'leader_lastname',
6363 'name': 'leader_name_facebook',
6367 'name': 'leader_url_blog',
6371 'name': 'leader_url_twitter',
6375 'name': 'leader_url_linkedin',
6379 'name': 'leader_crm_lead_percentage',
6383 'name': 'leader_crm_industry_id',
6387 'name': 'leader_crm_updated_action_id',
6391 'name': 'leader_crm_created_action_id',
6395 'name': 'leader_crm_type_id',
6402 xtype: 'PagingToolbar',
6405 displayMsg : "Displaying coitem{0} - {1} of {2}",
6406 emptyMsg : "No coitem found",
6411 xtype: 'ColumnModel',
6413 dataIndex : 'item_number',
6414 header : 'Item Code',
6416 renderer : function(v) { return String.format('{0}', v); }
6419 xtype: 'ColumnModel',
6421 dataIndex : 'calc_subtotal',
6422 header : 'SubTotal',
6424 renderer : function(v) {
6427 return Roo.util.Format.number( v, 2);
6431 xtype: 'ColumnModel',
6433 dataIndex : 'calc_cost_total',
6434 header : 'Cost of goods',
6436 renderer : function(v) {
6438 return Roo.util.Format.number( v, 2);
6442 xtype: 'ColumnModel',
6444 dataIndex : 'profit',
6447 renderer : function(v,x,r) {
6449 var profit = r.data.calc_subtotal - r.data.calc_cost_total;
6451 if(parseInt(profit) < 1){
6452 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(profit,2));
6456 return Roo.util.Format.number( profit, 2);
6464 xtype: 'LayoutRegion',
6466 alwaysShowTabs : true,
6467 tabPosition : 'top',
6482 var id = 1* _this.form.findField('cohead_id').getValue();
6484 Roo.MessageBox.alert("Error", "Save Sales order first");
6488 // check current status of shipment..
6491 url : baseURL + '/Roo/cohead',
6497 success : function() {
6506 cls : 'x-btn-text-icon',
6507 text : "Download Excel",
6508 icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
6516 var id = 1* _this.form.findField('cohead_id').getValue();
6518 Roo.MessageBox.alert("Error", "Save Sales order first");
6522 // check current status of shipment..
6525 url : baseURL + '/Roo/cohead',
6531 success : function() {
6540 cls : 'x-btn-text-icon',
6542 icon : rootURL + '/Pman/templates/images/pdf.gif'
6548 click : function (_self, e)
6551 _this.addShipmentBtn.fireEvent('click');
6555 cls : 'x-btn-text-icon',
6557 text : "Add Shipment",
6558 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6564 click : function (_self, e)
6567 Pman.Dialog.XtupleCustomer.show({
6568 cust_id : _this.form.findField('cohead_cust_id').getValue()
6572 cls : 'x-btn-text-icon',
6573 text : "Edit Customer",
6574 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6580 click : function (_self, e)
6583 _this.addInvoiceBtn.fireEvent('click');
6587 cls : 'x-btn-text-icon',
6589 text : "Add Invoice",
6590 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6596 render : function (_self, e)
6598 _this.voidBtn = _self;
6600 click : function (_self, e)
6603 cohead_id : _this.form.findField('cohead_id').getValue()
6610 url: baseURL + '/Roo/cohead',
6613 success : function()
6616 if ( _this.data.cohead_status == 'X') {
6617 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
6623 _this.dialog.hide();
6629 if (_this.data.cohead_status == 'X') {
6635 Roo.MessageBox.confirm("Confirm", "Are you sure you want to void this?", function(r) {
6654 click : function (_self, e)
6656 var p = { cohead_id : _this.form.findField('cohead_id').getValue() };
6659 if (_this.data.cohead_status == 'C') {
6667 url: baseURL + '/Roo/cohead',
6671 success : function()
6675 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
6680 _this.dialog.hide();
6685 render : function (_self)
6687 _this.closeBtn = _self;
6700 click : function (_self, e)
6702 if (_this.grid) _this.grid.stopEditing();
6703 _this.dialog.hide();
6712 click : function (_self, e)
6716 if (_this.grid) _this.grid.stopEditing();
6718 _this.form.doAction("submit");
6721 render : function (_self)
6723 _this.saveBtn = _self;