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',
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'
4346 click : function(_self,e)
4348 var sel = _this.invgrid.getSelectionModel().getSelected();
4349 if (!sel || sel.data.cobmisc_cashrcpt_id * 1 < 1) {
4350 Roo.MessageBox.alert("Error", "Select a Receive Payment");
4354 Roo.MessageBox.confirm("Confirm", "Voiding receipt will mean you will have to re-enter the receipt refund - " +
4355 "please take note of the details so you can enter it again correctly later.", function(r) {
4361 url : baseURL + '/Roo/cashrcpt',
4364 cashrcpt_id : sel.data.cobmisc_cashrcpt_id,
4367 success : function()
4369 _this.invgrid.ds.load({});
4379 cls : 'x-btn-text-icon',
4380 text : "Void Payment",
4381 icon : rootURL + '/Pman/templates/images/trash.gif'
4387 click : function(_self,e)
4389 var sel = _this.invgrid.getSelectionModel().getSelected();
4390 if (!sel || sel.data.cobmisc_checkhead_id * 1 < 1) {
4391 Roo.MessageBox.alert("Error", "Select a Miscellaneours Check");
4395 Roo.MessageBox.confirm("Confirm", "Voiding refund will mean you will have to re-enter the receipt refund - " +
4396 "please take note of the details so you can enter it again correctly later.", function(r) {
4402 url : baseURL + '/Roo/checkhead',
4405 checkhead_id : sel.data.cobmisc_checkhead_id,
4408 success : function()
4410 _this.invgrid.ds.load({});
4420 cls : 'x-btn-text-icon',
4421 text : "Void Refund",
4422 icon : rootURL + '/Pman/templates/images/trash.gif'
4428 click : function(_self,e)
4430 var sel = _this.invgrid.getSelectionModel().getSelected();
4431 if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {
4432 Roo.MessageBox.alert("Error", "Select a credit memo");
4436 if(sel.data.cobmisc_posted){
4437 Roo.MessageBox.alert("Error", "You cann't void this credit memo, since the invoice that credit memo has been applied to has been posted");
4441 if (sel.data.cobmisc_cobapply_id < 1) {
4442 Roo.MessageBox.alert("Error", "invaild credit memo");
4445 Roo.MessageBox.confirm("Confirm", "Are you sure want to void this applied credit memo, " +
4446 "it will also void all the check that belongs to this credit memo ", function(r) {
4452 url : baseURL + '/Roo/cobapply',
4455 _delete : sel.data.cobmisc_cobapply_id,
4458 success : function()
4460 _this.invgrid.ds.load({});
4469 cls : 'x-btn-text-icon',
4470 text : "Void Credit Memo",
4471 icon : rootURL + '/Pman/templates/images/trash.gif'
4487 if (!_this.form.findField('cohead_id').getValue()) {
4488 Roo.MessageBox.alert("Error", "Save Order first");
4492 var rv = _this.form.getFieldValues();
4495 Pman.Dialog.XtupleInvoice.show({
4496 cobmisc_cohead_id : rv.cohead_id,
4497 cobmisc_shipdate : _this.form.findField('cohead_targetdate').getValue(),
4498 cobmisc_invcdate : _this.form.findField('cohead_targetdate').getValue(),
4499 cobmisc_curr_id : rv.cohead_curr_id,
4500 cobmisc_curr_id_curr_name : rv.cohead_curr_id_curr_name,
4501 // below parms for add credit memo
4503 cm_cust_id : rv.cohead_cust_id,
4504 cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,
4505 cm_curr_id : rv.cohead_curr_id,
4506 cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,
4507 cm_terms_id : rv.cohead_terms_id,
4508 cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,
4509 cm_salesrep_id : rv.cohead_salesrep_id,
4510 cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,
4511 cm_docdate : new Date(),
4512 cm_taxzone_id : rv.cohead_taxzone_id,
4513 cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,
4514 cm_billto_cntct_id : rv.cohead_billto_cntct_id,
4515 cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,
4516 cm_location_src : rv.cohead_location_src,
4517 cm_location_src_location_name : rv.cohead_location_src_location_name,
4518 cm_billto_address : rv.billto_address
4523 _this.invgrid.ds.load({});
4527 render : function (_self)
4529 _this.addInvoiceBtn = _self;
4532 cls : 'x-btn-text-icon',
4534 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4543 var sel = _this.invgrid.getSelectionModel().getSelected();
4545 Roo.MessageBox.alert("Error", "Select a invoice");
4548 // check current status of shipment..
4551 // cobmisc_id : sel.data.cobmisc_id,
4554 if (sel.data.cobmisc_id * 1) {
4555 params.cobmisc_id = sel.data.cobmisc_id * 1 ;
4557 if (sel.data.cobmisc_invchead_id_invchead_id * 1) {
4558 params.invchead_id = sel.data.cobmisc_invchead_id_invchead_id * 1;
4561 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to VOID that invoice?",
4568 url : baseURL + '/Roo/cobmisc',
4571 success : function() {
4572 _this.invgrid.ds.load({});
4583 cls : 'x-btn-text-icon',
4584 text : "Void / Unpost",
4585 icon : rootURL + '/Pman/templates/images/trash.gif'
4591 xtype: 'ColumnModel',
4593 dataIndex : 'cobmisc_invchead_id_invchead_invcnumber',
4594 header : 'Invoice #',
4596 renderer : function(v,x,r) {
4598 r.data.cobmisc_invchead_id_invchead_id * 1 &&
4599 !r.data.cobmisc_invchead_id_invchead_posted) {
4600 return '<span style="color:red">' +
4601 "NEEDS Voiding then re-posted: " +
4602 String.format('{0}', v) +
4606 if(v && r.data.cobmisc_id == -2){
4607 return String.format('<span style="margin-left: 10px;"> - {0} (Credit Memo)</span>', v);
4609 if(v && r.data.cobmisc_id == -3){
4610 return String.format('<span style="margin-left: 20px;"> - {0} (Miscellaneous Check)</span>', v);
4612 if(v && r.data.cobmisc_id == -4){
4613 return String.format('<span style="margin-left: 10px;"> - {0} (Receive Payment) [ {1} ]</span>', v, r.data.cobmisc_cashrcpt_amount);
4616 return v ? String.format('{0}', v) :
4617 '<span style="color:red">' + "Not Posted" + '</span>';
4621 xtype: 'ColumnModel',
4623 dataIndex : 'cobmisc_invcdate',
4624 header : 'invcdate',
4626 renderer : function(v,x,r) {
4628 return String.format('{0}', v && r.data.cobmisc_id > 0 ? v.format('d/M/Y') : '');
4632 xtype: 'ColumnModel',
4635 dataIndex : 'cobmisc_qty',
4638 renderer : function(v) { return String.format('{0}', v ? parseInt(v) : 0); }
4641 xtype: 'ColumnModel',
4644 dataIndex : 'cobmisc_itemcost',
4645 header : 'Item Cost',
4647 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }
4650 xtype: 'ColumnModel',
4653 dataIndex : 'cobmisc_freight',
4654 header : 'Shipping',
4656 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : ''); }
4659 xtype: 'ColumnModel',
4662 dataIndex : 'cobmisc_tax',
4665 renderer : function(v,x,r) {
4667 // tax is based on the % itemcost..
4668 // var ic = r.data.cobmisc_itemcost;
4670 var ic =r.data.cobmisc_itemcost - (1* r.data.cobmisc_itemcost_taxfree);
4672 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
4673 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
4677 var taxp = tax / totic;
4680 return String.format('{0}', (1.0*v).toFixed(2) );
4686 xtype: 'ColumnModel',
4689 dataIndex : 'cobmisc_cohead_id_cohead_pretax_discount',
4690 header : 'Discount (Pretax)',
4692 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }
4695 xtype: 'ColumnModel',
4698 dataIndex : 'cobmisc_misc',
4699 header : 'Discount (Posttax)',
4701 renderer : function(v,x,r)
4703 var vv = v - r.data.cobmisc_cohead_id_cohead_pretax_discount;
4705 return String.format('{0}', vv ? (1.0*vv).toFixed(2) : 0);
4709 xtype: 'ColumnModel',
4712 dataIndex : 'cobmisc_total',
4715 renderer : function(v,x,r) {
4718 var ic = r.data.cobmisc_itemcost;
4719 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
4720 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
4723 var taxp = tax / totic;
4731 return String.format('{0}',(v * 1.0).toFixed(2) );
4735 return String.format('{0}',
4736 ((d.cobmisc_itemcost * 1.0) +
4737 (d.cobmisc_freight * 1.0) +
4738 (d.cobmisc_tax * 1.0) +
4739 (d.cobmisc_misc * 1.0)
4745 xtype: 'ColumnModel',
4748 dataIndex : 'cobmisc_outstanding',
4749 header : 'Outstanding',
4751 renderer : function(v,x,r)
4754 return String.format('{0}', v ? (v * 1.0).toFixed(2) : 0 );
4762 xtype: 'LayoutRegion',
4767 xtype: 'LayoutRegion',
4770 title : "Reserve Stock / Shipments"
4778 activate : function() {
4779 _this.hpanel = this;
4781 _this.hgrid.footer.onClick('first');
4786 fitContainer : true,
4789 tableName : 'events',
4798 //_this.dialog = Pman.Dialog.FILL_IN
4799 if (_this.hpanel.active) {
4800 this.footer.onClick('first');
4803 rowdblclick : function (_self, rowIndex, e)
4805 if (!_this.dialog) return;
4806 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
4807 _this.grid.footer.onClick('first');
4811 autoExpandColumn : 'remarks',
4817 beforeload : function (_self, options)
4819 options.params._related_on_table = 'cohead';
4820 options.params._related_on_id = _this.form.findField('cohead_id').getValue();
4824 sortInfo : { field : 'event_when', direction: 'DESC' },
4829 url : baseURL + '/Roo/events.php'
4832 xtype: 'JsonReader',
4836 totalProperty : 'total',
4839 'name': 'event_when',
4851 'name': 'person_id_name',
4862 xtype: 'PagingToolbar',
4866 displayMsg : "Displaying events{0} - {1} of {2}",
4867 emptyMsg : "No events found"
4871 xtype: 'ColumnModel',
4873 dataIndex : 'event_when',
4876 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); }
4879 xtype: 'ColumnModel',
4881 dataIndex : 'action',
4884 renderer : function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); }
4887 xtype: 'ColumnModel',
4889 dataIndex : 'ipaddr',
4890 header : 'IP address',
4892 renderer : function(v) { return String.format('{0}', v); }
4895 xtype: 'ColumnModel',
4897 dataIndex : 'person_id_name',
4900 renderer : function(v) { return String.format('{0}', v); }
4903 xtype: 'ColumnModel',
4905 dataIndex : 'remarks',
4908 renderer : function(v) { return String.format('{0}', v); }
4914 xtype: 'NestedLayoutPanel',
4919 xtype: 'BorderLayout',
4926 activate : function() {
4927 _this.txpanel = this;
4929 _this.txgrid.footer.onClick('first');
4934 fitContainer : true,
4937 tableName : 'invdetail',
4938 title : "invdetail",
4945 _this.txgrid = this;
4946 //_this.dialog = Pman.Dialog.FILL_IN
4947 if (_this.txpanel.active) {
4948 this.footer.onClick('first');
4952 autoExpandColumn : 'item_number',
4962 click : function (_self, e)
4966 url : baseURL + '/Roo/Cohead',
4969 _apply_fifo : _this.form.findField('cohead_id').getValue()
4971 success : function () {
4972 Roo.MessageBox.alert("Applied", "Succesfully Applied");
4977 text : "Run Apply Fifo on order"
4983 click : function (_self, e)
4987 url : baseURL + '/Roo/Cohead',
4990 _run_void_fix : _this.form.findField('cohead_id').getValue()
4992 success : function () {
4993 Roo.MessageBox.alert("Applied", "Succesfully Run");
4998 text : "Run Void flagger"
5004 click : function (_self, e)
5009 url : baseURL + '/Roo/Invdetail',
5014 _reverse_all_bad : _this.form.findField('cohead_id').getValue()
5016 success : function () {
5017 Roo.MessageBox.alert("Applied", "Succesfully Run");
5022 text : "Auto Reverse"
5027 xtype: 'RowSelectionModel',
5030 selectionchange : function (_self)
5032 _this.txdgrid.footer.onClick('first');;
5041 beforeload : function (_self, o)
5043 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5044 if (! o.params.cohead_id ) {
5051 sortInfo : { field : 'item_number', direction: 'ASC' },
5056 url : baseURL + '/Roo/invdetail.php'
5059 xtype: 'JsonReader',
5061 totalProperty : 'total',
5066 'name': 'invdetail_id',
5070 'name': 'invdetail_transtype',
5074 'name': 'invdetail_invhist_id',
5078 'name': 'invdetail_location_id',
5082 'name': 'invdetail_qty',
5086 'name': 'invdetail_comments',
5090 'name': 'invdetail_qty_before',
5094 'name': 'invdetail_qty_after',
5098 'name': 'invdetail_invcitem_id',
5102 'name': 'invdetail_expiration',
5104 'dateFormat': 'Y-m-d'
5107 'name': 'invdetail_warrpurc',
5109 'dateFormat': 'Y-m-d'
5112 'name': 'invdetail_ls_id',
5119 xtype: 'PagingToolbar',
5122 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5123 emptyMsg : "No invdetail found",
5128 xtype: 'ColumnModel',
5130 dataIndex : 'item_number',
5133 renderer : function(v) { return String.format('{0}', v); }
5136 xtype: 'ColumnModel',
5139 dataIndex : 'rec_shipped',
5142 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5145 xtype: 'ColumnModel',
5148 dataIndex : 'rec_returned',
5151 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5154 xtype: 'ColumnModel',
5157 dataIndex : 'tx_shipped',
5158 header : '#TX ship',
5160 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5163 xtype: 'ColumnModel',
5166 dataIndex : 'tx_returned',
5169 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5172 xtype: 'ColumnModel',
5175 dataIndex : 'tx_total',
5178 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5181 xtype: 'ColumnModel',
5184 dataIndex : 'total_value',
5187 renderer : function(v,x,r) {
5189 return (v*1).toFixed(3);
5193 xtype: 'ColumnModel',
5196 dataIndex : 'tx_total',
5199 renderer : function(v,x,r) {
5201 var cototal = (r.data.rec_returned*1) - (r.data.rec_shipped*1);
5202 // Roo.log(cototal);
5203 var diff = (v*1) - cototal;
5208 return String.format('<span style="color:red">{0}</span>', diff );
5218 activate : function() {
5219 _this.txdpanel = this;
5220 if (_this.txdgrid) {
5221 _this.txdgrid.footer.onClick('first');
5226 fitContainer : true,
5229 tableName : 'invdetail',
5230 title : "invdetail",
5237 _this.txdgrid = this;
5238 //_this.dialog = Pman.Dialog.FILL_IN
5239 if (_this.txdpanel.active) {
5240 this.footer.onClick('first');
5243 rowclick : function (_self, rowIndex, e)
5245 var s = _this.txdgrid.ds.getAt(rowIndex);
5246 var dt = s.data.invhist_transdate.split(' ');
5248 _this.dateSel.setValue(new Date(dt[0]));
5251 autoExpandColumn : 'invhist_comments',
5261 click : function (_self, e)
5263 var s = _this.txdgrid.selModel.getSelected();
5266 Roo.MessageBox.alert("Error", "Select a transaction");
5270 var reverseSel = function() {
5274 url : baseURL + '/Roo/invdetail',
5277 _duplicate : s.data.invdetail_id
5279 success : function() {
5280 _this.txdgrid.footer.onClick('first');
5288 Roo.MessageBox.confirm(
5290 "This should only be used by System Administrators - are you sure you know what you are doing!",
5304 text : "Duplicate Selected"
5319 render : function (_self)
5321 _this.dateSel = _self;
5325 fieldLabel : 'Issue Date',
5327 name : 'issue_date',
5334 click : function (_self, e)
5336 var s = _this.txdgrid.selModel.getSelected();
5337 var dt = _this.dateSel.getValue();
5339 Roo.MessageBox.alert("Error", "Select a transaction");
5343 var reverseSel = function(force) {
5347 url : baseURL + '/Roo/invdetail',
5350 _reverse : s.data.invdetail_id,
5351 _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
5354 success : function() {
5355 _this.txdgrid.footer.onClick('first');
5357 failure : function(res) {
5360 if (res.errors.confirm) {
5362 Roo.MessageBox.confirm(
5364 "are you really sure the totals will get messed up.",
5375 Roo.MessageBox.alert("Error", res.errorMsg);
5385 Roo.MessageBox.confirm(
5387 "This should only be used by System Administrators - are you sure you know what you are doing!",
5401 text : "Reverse Selected"
5409 beforeload : function (_self, o)
5411 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5412 var s = _this.txgrid.selModel.getSelected();
5417 o.params.itemsite_id = s.data.invhist_itemsite_id;
5422 sortInfo : { field : 'invdetail_id', direction: 'ASC' },
5427 url : baseURL + '/Roo/invdetail.php'
5430 xtype: 'JsonReader',
5432 totalProperty : 'total',
5437 'name': 'invdetail_id',
5441 'name': 'invdetail_transtype',
5445 'name': 'invdetail_invhist_id',
5449 'name': 'invdetail_location_id',
5453 'name': 'invdetail_qty',
5457 'name': 'invdetail_comments',
5461 'name': 'invdetail_qty_before',
5465 'name': 'invdetail_qty_after',
5469 'name': 'invdetail_invcitem_id',
5473 'name': 'invdetail_expiration',
5475 'dateFormat': 'Y-m-d'
5478 'name': 'invdetail_warrpurc',
5480 'dateFormat': 'Y-m-d'
5483 'name': 'invdetail_ls_id',
5490 xtype: 'PagingToolbar',
5493 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5494 emptyMsg : "No invdetail found",
5499 xtype: 'ColumnModel',
5501 dataIndex : 'invdetail_id',
5504 renderer : function(v) { return String.format('{0}', v); }
5507 xtype: 'ColumnModel',
5509 dataIndex : 'invhist_transdate',
5512 renderer : function(v) { return String.format('{0}', v); }
5515 xtype: 'ColumnModel',
5517 dataIndex : 'invhist_ordnumber',
5520 renderer : function(v,x,r) {
5521 if (r.data.invfifo_void *1 != 0) {
5522 return String.format('<s>{0}</s>', v);
5525 return String.format('{0}', v);
5529 xtype: 'ColumnModel',
5531 dataIndex : 'invhist_comments',
5534 renderer : function(v) { return String.format('{0}', v); }
5537 xtype: 'ColumnModel',
5540 dataIndex : 'invdetail_qty',
5541 header : 'Qty Changed',
5543 renderer : function(v,x,r) {
5544 if ( r.data.coitem_shipped != v) {
5545 return String.format('{0} <span style="color:red">({1})</span>',
5546 Roo.util.Format.number(v,0),
5547 r.data.coitem_shipped
5551 return String.format('{0}', Roo.util.Format.number(v,0));
5555 xtype: 'ColumnModel',
5558 dataIndex : 'invhist_value_before',
5559 header : 'Qty Changed',
5561 renderer : function(v,x,r) {
5562 var tot = r.data.invhist_value_after*1 - v*1;
5564 if (r.data.invdetail_qty >0 && tot < 0) {
5565 f = '<span style="color:red">{0}</span>';
5567 if (r.data.invdetail_qty < 0 && tot > 0) {
5568 f = '<span style="color:red">{0}</span>';
5570 return String.format(f, Roo.util.Format.number(tot));
5574 xtype: 'ColumnModel',
5576 dataIndex : 'invhist_posted',
5579 renderer : function(v,x,r) {
5581 var state = v ? '-checked' : '';
5583 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
5591 xtype: 'LayoutRegion',
5595 xtype: 'LayoutRegion',
5603 xtype: 'NestedLayoutPanel',
5608 xtype: 'BorderLayout',
5615 activate : function() {
5616 _this.gltxpanel = this;
5617 if (_this.gltxgrid) {
5618 _this.gltxgrid.footer.onClick('first');
5623 fitContainer : true,
5626 tableName : 'invdetail',
5627 title : "invdetail",
5634 _this.gltxgrid = this;
5635 //_this.dialog = Pman.Dialog.FILL_IN
5636 if (_this.gltxpanel.active) {
5637 this.footer.onClick('first');
5640 cellclick : function (_self, rowIndex, columnIndex, e)
5642 if (columnIndex > 0) {
5645 var rec = this.ds.getAt(rowIndex);
5646 rec.set('gltrans_as_summary', rec.data.gltrans_as_summary *1 ? 0 : 1);
5647 _this.gltxdgrid.footer.onClick('first');
5650 autoExpandColumn : 'gltrans_accnt_id_accnt_descrip',
5653 xtype: 'RowSelectionModel',
5656 selectionchange : function (_self)
5658 _this.gltxdgrid.footer.onClick('first');;
5667 beforeload : function (_self, o)
5669 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5670 if (! o.params.cohead_id ) {
5674 o.params._split_sales = _this.glsalesbtn.pressed ? 1 : 0;
5678 sortInfo : { field : 'item_number', direction: 'ASC' },
5683 url : baseURL + '/Roo/gltrans.php'
5686 xtype: 'JsonReader',
5688 totalProperty : 'total',
5693 'name': 'invdetail_id',
5697 'name': 'invdetail_transtype',
5701 'name': 'invdetail_invhist_id',
5705 'name': 'invdetail_location_id',
5709 'name': 'invdetail_qty',
5713 'name': 'invdetail_comments',
5717 'name': 'invdetail_qty_before',
5721 'name': 'invdetail_qty_after',
5725 'name': 'invdetail_invcitem_id',
5729 'name': 'invdetail_expiration',
5731 'dateFormat': 'Y-m-d'
5734 'name': 'invdetail_warrpurc',
5736 'dateFormat': 'Y-m-d'
5739 'name': 'invdetail_ls_id',
5746 xtype: 'PagingToolbar',
5749 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5750 emptyMsg : "No invdetail found",
5757 render : function (_self)
5759 _this.glsalesbtn = _self;
5761 click : function (_self, e)
5763 (function() { _this.gltxgrid.footer.onClick('first'); }).defer(100);
5766 enableToggle : true,
5768 text : "Split sales"
5774 xtype: 'ColumnModel',
5776 dataIndex : 'gltrans_as_summary',
5779 renderer : function(v,x,r) {
5781 var state = v*1 ? '-checked' : '';
5783 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
5787 xtype: 'ColumnModel',
5789 dataIndex : 'gltrans_accnt_id_accnt_descrip',
5792 renderer : function(v) { return String.format('{0}', v); }
5795 xtype: 'ColumnModel',
5798 dataIndex : 'gltrans_amount_credit',
5801 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
5804 xtype: 'ColumnModel',
5807 dataIndex : 'gltrans_amount_debit',
5810 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
5813 xtype: 'ColumnModel',
5816 dataIndex : 'gltrans_amount_total',
5819 renderer : function(v) { return String.format('<b>{0}</b>', Roo.util.Format.number(v,3)); }
5822 xtype: 'ColumnModel',
5825 dataIndex : 'gltrans_amount_total_unposted',
5826 header : 'Unposted',
5828 renderer : function(v) { return String.format('<span style="color:red">{0}</span>', Roo.util.Format.number(v,3)); }
5837 activate : function() {
5838 _this.gltxdpanel = this;
5839 if (_this.gltxdgrid) {
5840 _this.gltxdgrid.footer.onClick('first');
5845 fitContainer : true,
5848 tableName : 'invdetail',
5849 title : "invdetail",
5856 _this.gltxdgrid = this;
5857 //_this.dialog = Pman.Dialog.FILL_IN
5858 if (_this.gltxdpanel.active) {
5859 this.footer.onClick('first');
5862 cellclick : function (_self, ri, ci, e)
5865 var deleteSel = function() {
5869 url : baseURL + '/Roo/gltrans',
5873 gltrans_id : rec.data.gltrans_id
5876 success : function() {
5877 rec.set('gltrans_posted', false);
5878 rec.set('gltrans_deleted', true);
5879 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
5880 _this.gltxgrid.footer.onClick('first');
5885 var undeleteSel = function() {
5889 url : baseURL + '/Roo/gltrans',
5893 gltrans_id : rec.data.gltrans_id
5896 success : function() {
5897 rec.set('gltrans_posted', true);
5898 rec.set('gltrans_deleted', false);
5899 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
5900 _this.gltxgrid.footer.onClick('first');
5906 var di = this.colModel.config[ci].dataIndex;
5907 if (di != 'gltrans_posted') {
5913 var rec = this.ds.getAt(ri);
5914 if (rec.data.gltrans_deleted) {
5916 Roo.MessageBox.confirm(
5918 "This should only be used by System Administrators - are you sure you know what you are doing!",
5932 if (!rec.data.gltrans_posted) {
5938 url : baseURL + '/Roo/gltrans',
5942 gltrans_id : rec.data.gltrans_id
5944 success : function (res)
5946 rec.set('gltrans_posted', true);
5947 _this.gltxgrid.footer.onClick('first');
5956 // we have a posted transaction.
5957 // only allow recalled to be deleted..
5958 if (!rec.data.gltrans_notes.match(/(Recall|Ship Order)/)) {
5967 Roo.MessageBox.confirm(
5969 "This should only be used by System Administrators - are you sure you know what you are doing!",
5982 autoExpandColumn : 'gltrans_notes',
5988 beforeload : function (_self, o)
5990 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5991 var s = _this.gltxgrid.selModel.getSelected();
5996 o.params.gltrans_accnt_id = s.data.gltrans_accnt_id;
5997 o.params.gltrans_is_ship = s.data.gltrans_is_ship;
5998 o.params.gltrans_as_summary = s.data.gltrans_as_summary;
6004 sortInfo : { field : 'gltrans_docnumber', direction: 'ASC' },
6009 url : baseURL + '/Roo/gltrans.php'
6012 xtype: 'JsonReader',
6014 totalProperty : 'total',
6019 'name': 'invdetail_id',
6023 'name': 'invdetail_transtype',
6027 'name': 'invdetail_invhist_id',
6031 'name': 'invdetail_location_id',
6035 'name': 'invdetail_qty',
6039 'name': 'invdetail_comments',
6043 'name': 'invdetail_qty_before',
6047 'name': 'invdetail_qty_after',
6051 'name': 'invdetail_invcitem_id',
6055 'name': 'invdetail_expiration',
6057 'dateFormat': 'Y-m-d'
6060 'name': 'invdetail_warrpurc',
6062 'dateFormat': 'Y-m-d'
6065 'name': 'invdetail_ls_id',
6072 xtype: 'PagingToolbar',
6075 displayMsg : "Displaying invdetail{0} - {1} of {2}",
6076 emptyMsg : "No invdetail found",
6083 click : function (_self, e)
6085 new Pman.Download( {
6086 grid : _this.gltxdgrid
6097 xtype: 'ColumnModel',
6099 dataIndex : 'gltrans_id',
6103 renderer : function(v) { return String.format('{0}', v ); }
6106 xtype: 'ColumnModel',
6108 dataIndex : 'gltrans_date',
6111 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
6114 xtype: 'ColumnModel',
6116 dataIndex : 'gltrans_docnumber',
6119 renderer : function(v,x,r) {
6120 if (r.data.gltrans_deleted) {
6121 return String.format('<s>{0}</s>', v);
6123 return String.format('{0}', v);
6127 xtype: 'ColumnModel',
6129 dataIndex : 'gltrans_source',
6132 renderer : function(v) { return String.format('{0}', v); }
6135 xtype: 'ColumnModel',
6137 dataIndex : 'gltrans_notes',
6140 renderer : function(v) { return String.format('{0}', v); }
6143 xtype: 'ColumnModel',
6146 dataIndex : 'gltrans_amount',
6149 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
6152 xtype: 'ColumnModel',
6154 dataIndex : 'gltrans_posted',
6157 renderer : function(v,x,r) {
6159 var state = v ? '-checked' : '';
6161 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
6169 xtype: 'LayoutRegion',
6173 xtype: 'LayoutRegion',
6184 activate : function() {
6185 _this.profitpanel = this;
6187 try { if (MODULE.isBuilder) {
6191 var id = _this.form.findField('cohead_id').getValue() * 1;
6193 Roo.MessageBox.alert("Save First", "Save the order first, before adding items");
6194 _this.dialog.layout.getRegion('center').showPanel(0);
6198 if (_this.profitgrid) {
6199 _this.profitgrid.footer.onClick('first');
6205 fitContainer : true,
6208 tableName : 'coitem',
6216 _this.profitgrid = this;
6217 //_this.dialog = Pman.Dialog.FILL_IN
6218 if (_this.profitpanel.active) {
6219 this.footer.onClick('first');
6223 autoExpandColumn : 'item_number',
6229 beforeload : function (_self,o) {
6236 if (!_this.data || !_this.data.cohead_id) {
6239 o.params = o.params || {};
6241 o.params.coitem_cohead_id = _this.data.cohead_id;
6242 o.params._without_list_discount =1;
6243 o.params._with_profit = 1;
6248 sortInfo : { field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' },
6253 url : baseURL + '/Roo/coitem.php'
6256 xtype: 'JsonReader',
6258 totalProperty : 'total',
6279 'name': 'leader_id',
6283 'name': 'leader_office_id',
6287 'name': 'leader_name',
6291 'name': 'leader_phone',
6295 'name': 'leader_fax',
6299 'name': 'leader_email',
6303 'name': 'leader_company_id',
6307 'name': 'leader_role',
6311 'name': 'leader_active',
6315 'name': 'leader_remarks',
6319 'name': 'leader_passwd',
6323 'name': 'leader_owner_id',
6327 'name': 'leader_lang',
6331 'name': 'leader_no_reset_sent',
6335 'name': 'leader_action_type',
6339 'name': 'leader_project_id',
6343 'name': 'leader_deleted_by',
6347 'name': 'leader_deleted_dt',
6351 'name': 'leader_firstname',
6355 'name': 'leader_lastname',
6359 'name': 'leader_name_facebook',
6363 'name': 'leader_url_blog',
6367 'name': 'leader_url_twitter',
6371 'name': 'leader_url_linkedin',
6375 'name': 'leader_crm_lead_percentage',
6379 'name': 'leader_crm_industry_id',
6383 'name': 'leader_crm_updated_action_id',
6387 'name': 'leader_crm_created_action_id',
6391 'name': 'leader_crm_type_id',
6398 xtype: 'PagingToolbar',
6401 displayMsg : "Displaying coitem{0} - {1} of {2}",
6402 emptyMsg : "No coitem found",
6407 xtype: 'ColumnModel',
6409 dataIndex : 'item_number',
6410 header : 'Item Code',
6412 renderer : function(v) { return String.format('{0}', v); }
6415 xtype: 'ColumnModel',
6417 dataIndex : 'calc_subtotal',
6418 header : 'SubTotal',
6420 renderer : function(v) {
6423 return Roo.util.Format.number( v, 2);
6427 xtype: 'ColumnModel',
6429 dataIndex : 'calc_cost_total',
6430 header : 'Cost of goods',
6432 renderer : function(v) {
6434 return Roo.util.Format.number( v, 2);
6438 xtype: 'ColumnModel',
6440 dataIndex : 'profit',
6443 renderer : function(v,x,r) {
6445 var profit = r.data.calc_subtotal - r.data.calc_cost_total;
6447 if(parseInt(profit) < 1){
6448 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(profit,2));
6452 return Roo.util.Format.number( profit, 2);
6460 xtype: 'LayoutRegion',
6462 alwaysShowTabs : true,
6463 tabPosition : 'top',
6478 var id = 1* _this.form.findField('cohead_id').getValue();
6480 Roo.MessageBox.alert("Error", "Save Sales order first");
6484 // check current status of shipment..
6487 url : baseURL + '/Roo/cohead',
6493 success : function() {
6502 cls : 'x-btn-text-icon',
6503 text : "Download Excel",
6504 icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
6512 var id = 1* _this.form.findField('cohead_id').getValue();
6514 Roo.MessageBox.alert("Error", "Save Sales order first");
6518 // check current status of shipment..
6521 url : baseURL + '/Roo/cohead',
6527 success : function() {
6536 cls : 'x-btn-text-icon',
6538 icon : rootURL + '/Pman/templates/images/pdf.gif'
6544 click : function (_self, e)
6547 _this.addShipmentBtn.fireEvent('click');
6551 cls : 'x-btn-text-icon',
6553 text : "Add Shipment",
6554 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6560 click : function (_self, e)
6563 Pman.Dialog.XtupleCustomer.show({
6564 cust_id : _this.form.findField('cohead_cust_id').getValue()
6568 cls : 'x-btn-text-icon',
6569 text : "Edit Customer",
6570 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6576 click : function (_self, e)
6579 _this.addInvoiceBtn.fireEvent('click');
6583 cls : 'x-btn-text-icon',
6585 text : "Add Invoice",
6586 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6592 render : function (_self, e)
6594 _this.voidBtn = _self;
6596 click : function (_self, e)
6599 cohead_id : _this.form.findField('cohead_id').getValue()
6606 url: baseURL + '/Roo/cohead',
6609 success : function()
6612 if ( _this.data.cohead_status == 'X') {
6613 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
6619 _this.dialog.hide();
6625 if (_this.data.cohead_status == 'X') {
6631 Roo.MessageBox.confirm("Confirm", "Are you sure you want to void this?", function(r) {
6650 click : function (_self, e)
6652 var p = { cohead_id : _this.form.findField('cohead_id').getValue() };
6655 if (_this.data.cohead_status == 'C') {
6663 url: baseURL + '/Roo/cohead',
6667 success : function()
6671 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
6676 _this.dialog.hide();
6681 render : function (_self)
6683 _this.closeBtn = _self;
6696 click : function (_self, e)
6698 if (_this.grid) _this.grid.stopEditing();
6699 _this.dialog.hide();
6708 click : function (_self, e)
6712 if (_this.grid) _this.grid.stopEditing();
6714 _this.form.doAction("submit");
6717 render : function (_self)
6719 _this.saveBtn = _self;