1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Dialog.XtupleSalesOrder = {
10 show : function(data, cb)
18 this.dialog.show(this.data._el);
21 this.form.setValues(data);
22 this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });
30 this.dialog = Roo.factory({
31 xtype: 'LayoutDialog',
35 this.layout.getRegion('center').showPanel(0);
43 title : "Edit / Create Sales Order",
47 xtype: 'ContentPanel',
50 activate : function (_self)
52 // we need to reload to find out the subtotal.
53 if (!_this.data || !_this.data.cohead_id) {
58 url : baseURL + '/Roo/cohead',
60 _id : _this.data.cohead_id
62 success : function(res) {
63 _this.form.findField('cohead_subtotal').setValue(res.data.cohead_subtotal);
64 _this.form.findField('cohead_tax').setValue(res.data.cohead_tax);
65 _this.form.findField('cohead_uninvoiced').setValue(res.data.cohead_uninvoiced);
66 _this.form.findField('cohead_unshipped').setValue(res.data.cohead_unshipped);
67 _this.form.findField('cohead_pretax_discount').setValue(res.data.cohead_pretax_discount);
68 _this.form.findField('cohead_total').recalc();
69 _this.form.findField('cohead_misc').recalc();
75 title : "Order Details",
81 actioncomplete : function(_self,action)
83 if (action.type == 'setdata') {
84 // clear the stock level cache...
85 _this.stockcache = [];
87 _this.form.findField('billto_email').setValue('');
89 if (_this.data.cohead_id) {
90 this.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
94 _this.dialog.setTitle("Edit New Sales Order");
96 _this.closeBtn.hide();
100 if(_this.data.cohead_billto_cntct_id_cntct_id){
101 _this.form.findField('billto_address').update();
103 _this.form.setValues({
\r
104 cohead_billto_cntct_id: _this.data.cohead_billto_cntct_id_cntct_id,
\r
105 cohead_billto_cntct_id_cntct_name : _this.data.cohead_billto_cntct_id_cntct_name,
\r
114 if (action.type == 'load') {
117 _this.data = action.result.data;
119 if (!_this.data.cohead_shipto_id && _this.data.shipto_id*1 > 0) {
120 _this.form.findField('cohead_shipto_id').setValue(_this.data.shipto_id);
121 _this.form.findField('cohead_shipto_id_shipto_name').setValue(_this.data.cohead_shipto_cntct_id_cntct_name);
126 _this.dataloading = true;
127 if (_this.data.cohead_shipto_cntct_id == _this.data.cohead_billto_cntct_id) {
128 this.findField('_shipto_same').setValue(1);
129 Roo.log("set shipto 1");
131 this.findField('_shipto_same').setValue(0);
132 Roo.log("set shipto 0");
134 _this.dataloading = false;
137 this.findField('billto_address').update();
138 this.findField('shipto_address').update();
139 _this.dialog.setTitle("Edit Sales Order - " + this.findField('cohead_number').getValue());
142 if (_this.data.cohead_status == 'C') {
143 _this.closeBtn.show();
144 _this.closeBtn.setText('Re-open');
145 _this.voidBtn.hide();
146 _this.saveBtn.hide();
147 } else if (_this.data.cohead_status == 'X') {
148 _this.closeBtn.hide();
149 _this.voidBtn.show();
150 _this.voidBtn.setText("Un-void / Re-open");
151 _this.saveBtn.hide();
154 _this.closeBtn.show();
155 _this.closeBtn.setText('Complete and Close');
156 _this.voidBtn.setText("Void");
157 _this.voidBtn.show();
158 _this.saveBtn.show();
161 _this.form.findField('cohead_misc_per').update();
163 // finally override the value for discount...
164 if ((''+ _this.data.cohead_misc_descrip).length) {
165 _this.form.findField('cohead_misc_descrip').setValue(_this.data.cohead_misc_descrip);
168 // update the stockcache...
171 url : baseURL + '/Roo/cohead',
174 _stockLevel : _this.data.cohead_id
176 success : function(res)
178 for (var i in res.data) {
180 if(typeof(_this.stockcache[res.data[i].item]) == 'undefined'){
181 _this.stockcache[res.data[i].item] = res.data[i];
189 if (action.type =='submit') {
192 var id = _this.form.findField('cohead_id').getValue() * 1;
195 _this.data.cohead_id = action.result.data.cohead_id;
196 this.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
202 if (_this.callback) {
203 _this.callback.call(_this, _this.form.getValues());
209 rendered : function (form)
213 actionfailed : function (_self, action)
215 if (action.failureType == 'client') {
216 Roo.MessageBox.alert("Error", "Fill in all the required fields");
218 if (action.failureType == 'server') {
220 Roo.MessageBox.alert("Error", action.result.errorMsg);
222 _this.dialog.layout.getRegion('center').showPanel(0);
226 style : 'margin:10px;',
227 url : baseURL + '/Roo/cohead.php',
239 style : 'width:420px',
257 emptyText : "Automatic",
258 fieldLabel : 'Order#',
259 name : 'cohead_number',
267 style : 'float:left',
274 fieldLabel : 'Cust#',
275 name : 'cohead_cust_id_cust_number',
287 fieldLabel : 'Customer',
288 forceSelection : true,
289 hiddenName : 'cohead_cust_id',
291 loadingText : "Searching...",
293 name : 'cohead_cust_id_cust_name',
295 qtip : "Select custinfo",
296 queryParam : 'query[cust_name]',
298 selectOnFocus : true,
299 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> </div>',
300 triggerAction : 'all',
302 valueField : 'cust_id',
308 fieldLabel : 'Customer PO#',
309 name : 'cohead_custponumber',
316 fieldLabel : 'Ordered',
318 name : 'cohead_orderdate',
331 fieldLabel : 'Target Delivery',
333 name : 'cohead_targetdate',
345 check : function (_self, checked)
348 _this.form.findField('cohead_targetdate').setValue(_this.form.findField('cohead_orderdate').getValue());
352 boxLabel : 'same as order',
354 name : '_same_as_order'
364 displayField : 'location_name',
366 emptyText : "Supply From",
367 fieldLabel : 'Supply From',
368 forceSelection : true,
369 hiddenName : 'cohead_location_src',
371 loadingText : "Searching...",
373 name : 'cohead_location_src_location_name',
375 qtip : "Select terms",
376 queryParam : 'query[location_name]',
377 selectOnFocus : true,
378 tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> {location_descrip} </div>',
379 triggerAction : 'all',
381 valueField : 'location_id',
387 beforeload : function (_self, o){
388 o.params = o.params || {};
390 o.params.location_netable = 1;
391 o.params.location_restrict = 0;
392 o.params._notinternalcompany = 1;
396 sortInfo : { direction : 'ASC', field: 'location_name' },
401 url : baseURL + '/Roo/location.php'
408 totalProperty : 'total',
409 fields : [{"name":"location_id","type":"int"},"location_name"]
422 style : 'width:420px',
435 emptyText : "Select terms",
436 forceSelection : true,
438 loadingText : "Searching...",
441 qtip : "Select terms",
442 selectOnFocus : true,
443 triggerAction : 'all',
446 tpl : '<div class="x-grid-cell-text x-btn button"><b>{terms_descrip}</b> </div>',
447 queryParam : 'query[terms_descrip]',
448 fieldLabel : 'Terms',
449 valueField : 'terms_id',
450 displayField : 'terms_descrip',
451 hiddenName : 'cohead_terms_id',
452 name : 'cohead_terms_id_terms_descrip',
457 beforeload : function (_self, o){
458 o.params = o.params || {};
463 sortInfo : { direction : 'ASC', field: 'terms_descrip' },
468 url : baseURL + '/Roo/terms.php'
475 totalProperty : 'total',
476 fields : [{"name":"terms_id","type":"int"},"terms_descrip"]
485 displayField : 'salesrep_name',
487 emptyText : "Select salesrep",
488 fieldLabel : 'Sales Rep',
489 forceSelection : true,
490 hiddenName : 'cohead_display_salesrep_id',
492 loadingText : "Searching...",
494 name : 'cohead_display_salesrep_id_salesrep_name',
496 qtip : "Select salesrep",
497 queryParam : 'query[salesrep_name]',
498 selectOnFocus : true,
499 tpl : '<div class="x-grid-cell-text x-btn button"><b>{salesrep_name}</b> </div>',
500 triggerAction : 'all',
502 valueField : 'salesrep_id',
508 beforeload : function (_self, o){
509 o.params = o.params || {};
514 sortInfo : { direction : 'ASC', field: 'salesrep_name' },
519 url : baseURL + '/Roo/salesrep.php'
526 totalProperty : 'total',
527 fields : [{"name":"salesrep_id","type":"int"},"salesrep_name"]
536 displayField : 'salesrep_name',
538 emptyText : "Select Staff",
539 fieldLabel : 'Staff I.C.',
540 forceSelection : true,
541 hiddenName : 'cohead_salesrep_id',
543 loadingText : "Searching...",
545 name : 'cohead_salesrep_id_salesrep_name',
547 qtip : "Select salesrep",
548 queryParam : 'query[salesrep_name]',
549 selectOnFocus : true,
550 tpl : '<div class="x-grid-cell-text x-btn button"><b>{salesrep_name}</b> </div>',
551 triggerAction : 'all',
553 valueField : 'salesrep_id',
559 beforeload : function (_self, o){
560 o.params = o.params || {};
565 sortInfo : { direction : 'ASC', field: 'salesrep_name' },
570 url : baseURL + '/Roo/salesrep.php'
577 totalProperty : 'total',
578 fields : [{"name":"salesrep_id","type":"int"},"salesrep_name"]
585 fieldLabel : 'Order Comments',
587 name : 'cohead_ordercomments',
597 style : 'width:420px',
610 beforeselect : function (combo, record, index)
612 // set _this.data values ..
614 // just add everything...
615 for(var i in record.data) {
616 _this.data['cohead_billto_cntct_id_' + i] = record.data[i];
619 _this.form.findField('billto_address').update();
621 _this.form.findField('billto_email').setValue(record.data.cntct_email);
625 add : function (combo)
628 Pman.Dialog.XtupleQuickContact.show(
631 customer_id : _this.form.findField('cohead_cust_id').getValue()
638 _this.data['cohead_billto_cntct_id_' + i] = data[i];
641 _this.form.findField('billto_address').update();
642 // fill in the select box..
643 _this.form.setValues( {
644 cohead_billto_cntct_id : data.cntct_id,
645 cohead_billto_cntct_id_cntct_name : data.cntct_first_name + ' '+
651 // Pman.Dialog.XtupleCustomer.show(
652 //{ cust_id : _this.form.findField('cohead_cust_id').getValue() },
654 // refresh the data in the pulldown..
661 displayField : 'cntct_name',
663 emptyText : "Select cntct",
664 fieldLabel : 'Bill To (select)',
665 forceSelection : true,
666 hiddenName : 'cohead_billto_cntct_id',
668 loadingText : "Searching...",
670 name : 'cohead_billto_cntct_id_cntct_name',
672 qtip : "Select cntct",
673 queryParam : 'query[cntct_name]',
674 selectOnFocus : true,
675 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cntct_name}</b> {cntct_addr_id_addr_line1}</div>',
676 triggerAction : 'all',
678 valueField : 'cntct_id',
684 beforeload : function (_self, o){
685 o.params = o.params || {};
687 o.params._customer_id = _this.data.cohead_cust_id;
691 sortInfo : { direction : 'ASC', field: 'cntct_name' },
696 url : baseURL + '/Roo/cntct.php'
703 totalProperty : 'total',
704 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
712 render : function (_self)
718 this.el.on('click', function() {
719 var id = _this.form.findField('cohead_billto_cntct_id').getValue();
720 Pman.Dialog.XtupleQuickContact.show(
723 customer_id : _this.form.findField('cohead_cust_id').getValue()
730 _this.data['cohead_billto_cntct_id_' + i] = data[i];
733 _this.form.findField('billto_address').update();
734 // fill in the select box..
735 _this.form.setValues( {
736 cohead_billto_cntct_id : data.cntct_id,
737 cohead_billto_cntct_id_cntct_name : data.cntct_first_name + ' '+
747 Roo.log("Click text");
753 fieldLabel : 'or enter Address',
754 name : 'billto_address',
756 update : function() {
758 var c = ['first_name', 'last_name' ] ;
759 var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];
761 Roo.each(c, function(e) {
762 if (_this.data['cohead_billto_cntct_id_cntct_' +e].length) {
763 v.push(_this.data['cohead_billto_cntct_id_cntct_' +e]);
766 Roo.each(a, function(e) {
767 if (_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e].length) {
768 v.push(_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e]);
772 this.setValue(v.join("\n"));
774 _this.form.findField('billto_email').setValue(_this.data.cohead_billto_cntct_id_cntct_email);
778 xtype: 'DisplayField',
780 fieldLabel : 'Email',
781 name : 'billto_email'
793 style : 'margin-left:10px',
798 legend : "Price Details",
799 style : 'width:420px',
805 labelAlign : 'right',
813 labelSeparator : ' ',
820 beforequery : function (combo, query, forceAll, cancel, e)
822 Roo.log('beforequery');
824 if (_this.form.findField('cohead_number').getValue().length) {
825 Roo.MessageBox.alert("Error", "You can not change the currency of this order");
834 displayField : 'curr_name',
836 emptyText : "Select curr_name",
837 fieldLabel : 'Currency',
838 forceSelection : true,
839 hiddenName : 'cohead_curr_id',
841 loadingText : "Searching...",
843 name : 'cohead_curr_id_curr_name',
845 qtip : "Select Currency",
846 queryParam : 'query[curr_name]',
847 selectOnFocus : true,
848 tpl : '<div class="x-grid-cell-text x-btn button"><b>{curr_name}</b> </div>',
849 triggerAction : 'all',
851 valueField : 'curr_id',
857 beforeload : function (_self, o){
858 o.params = o.params || {};
864 sortInfo : { direction : 'ASC', field: 'curr_symbol' },
869 url : baseURL + '/Roo/curr_symbol.php'
876 totalProperty : 'total',
877 fields : [{"name":"curr_id","type":"int"},"curr_symbol"]
882 xtype: 'NumberField',
884 allowDecimals : true,
885 cls : 'roo-align-right',
886 decimalPrecision : 3,
887 fieldLabel : 'Products',
888 name : 'cohead_subtotal',
898 labelSeparator : ' ',
905 select : function (combo, record, index)
907 _this.form.findField('cohead_tax').setValue(
908 parseFloat(record.data.taxzone_rate) *
909 parseFloat(_this.form.findField('cohead_subtotal').getValue())
911 _this.form.findField('cohead_total').recalc();
915 displayField : 'taxzone_descrip',
917 emptyText : "Select taxtype",
918 fieldLabel : 'Tax Zone',
919 forceSelection : true,
920 hiddenName : 'cohead_taxzone_id',
922 loadingText : "Searching...",
924 name : 'cohead_taxzone_id_taxzone_descrip',
926 qtip : "Select taxtype",
927 queryParam : 'query[taxzone_descrip]',
928 selectOnFocus : true,
929 tpl : '<div class="x-grid-cell-text x-btn button"><b>{taxzone_descrip}</b> </div>',
930 triggerAction : 'all',
932 valueField : 'taxzone_id',
938 beforeload : function (_self, o){
939 o.params = o.params || {};
942 o.params.with_date = _this.form.findField('cohead_orderdate').getValue().format('Y-m-d');
943 Roo.log("with date?" + o.params.with_date);
949 sortInfo : { direction : 'ASC', field: 'taxzone_descrip' },
954 url : baseURL + '/Roo/taxzone.php'
961 totalProperty : 'total',
962 fields : [{"name":"taxzone_id","type":"int"},"taxzone_descrip"]
967 xtype: 'NumberField',
969 allowDecimals : true,
970 cls : 'roo-align-right',
971 decimalPrecision : 3,
980 xtype: 'NumberField',
982 allowDecimals : true,
983 cls : 'roo-align-right',
984 decimalPrecision : 3,
985 fieldLabel : 'Pre Tax discount',
986 name : 'cohead_pretax_discount',
994 labelSeparator : ' ',
1000 fieldLabel : 'Discount after Tax Description',
1001 name : 'cohead_misc_descrip',
1005 xtype: 'NumberField',
1008 keyup : function (_self, e)
1010 var pv = parseFloat(_this.form.findField('cohead_subtotal').getValue());
1011 var tax = parseFloat(_this.form.findField('cohead_tax').getValue());
1012 var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());
1014 var n = this.getValue();
1015 var discount = parseFloat(n * (pv + tax + pd) * 0.01);
1017 _this.form.findField('cohead_posttax_discount').setValue(discount);
1019 _this.form.findField('cohead_total').recalc();
1020 _this.form.findField('cohead_misc').recalc();
1021 var val = discount * -1.0;
1023 _this.form.findField('cohead_misc_descrip').setValue("Discount of " + val.toFixed(1)+'%');
1029 allowDecimals : true,
1030 cls : 'roo-align-right',
1031 decimalPrecision : 1,
1033 name : 'cohead_misc_per',
1035 update : function() {
1036 var m = _this.form.findField('cohead_misc_per');
1037 var pv = parseFloat(_this.form.findField('cohead_subtotal').getValue());
1038 var tax = parseFloat(_this.form.findField('cohead_tax').getValue());
1039 var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());
1041 var discount = parseFloat(_this.form.findField('cohead_posttax_discount').getValue());
1043 if (discount > 0.0) {
1051 var val = ((discount) / (pv + tax + pd)) * -100;
1053 //Roo.log("update discount?" + val);
1054 this.setValue(val.toFixed(1));
1057 _this.form.findField('cohead_misc_descrip').setValue("Discount of " + val.toFixed(1)+'%');
1065 xtype: 'NumberField',
1068 keyup : function (_self, e)
1070 _this.form.findField('cohead_misc_per').update();
1071 _this.form.findField('cohead_total').recalc();
1072 _this.form.findField('cohead_misc').recalc();
1075 allowDecimals : true,
1076 cls : 'roo-align-right',
1077 decimalPrecision : 3,
1078 fieldLabel : ' ',
1079 name : 'cohead_posttax_discount',
1085 xtype: 'NumberField',
1087 allowDecimals : true,
1088 cls : 'roo-align-right',
1089 decimalPrecision : 3,
1090 fieldLabel : 'Total',
1091 name : 'cohead_total',
1094 recalc : function() {
1095 var d = _this.form.getValues();
1097 parseFloat(d.cohead_subtotal) +
1098 parseFloat(d.cohead_pretax_discount) +
1099 parseFloat(d.cohead_posttax_discount) +
1100 parseFloat(d.cohead_tax) +
1101 parseFloat(d.cohead_freight));
1105 xtype: 'NumberField',
1108 keyup : function (_self, e)
1110 _this.form.findField('cohead_total').recalc();
1113 allowDecimals : true,
1114 cls : 'roo-align-right',
1115 decimalPrecision : 3,
1116 fieldLabel : 'Shipping',
1117 name : 'cohead_freight',
1121 xtype: 'NumberField',
1123 allowDecimals : true,
1124 cls : 'roo-align-right',
1125 decimalPrecision : 3,
1126 fieldLabel : 'Unshipped Total',
1127 name : 'cohead_unshipped',
1132 xtype: 'NumberField',
1134 allowDecimals : true,
1135 cls : 'roo-align-right',
1136 decimalPrecision : 3,
1137 fieldLabel : 'Uninvoiced Total',
1138 name : 'cohead_uninvoiced',
1149 style : 'width:420px',
1150 legend : "Shipping",
1161 labelSeparator : ' ',
1167 check : function (_self, checked)
1173 if (_this.dataloading) {
1181 // copy the cohead_billto_cntct_id
1182 for (var i in _this.data) {
1183 if (!i.match(/^cohead_billto_cntct_id/)) {
1186 var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');
1187 _this.data[ni] = _this.data[i];
1189 _this.form.findField('shipto_address').update();
1190 _this.form.setValues( {
1191 cohead_shipto_cntct_id : _this.data.cohead_shipto_cntct_id,
1192 cohead_shipto_cntct_id_cntct_name : _this.data.cohead_shipto_cntct_id_cntct_first_name + ' ' +
1193 _this.data.cohead_shipto_cntct_id_cntct_last_name
1200 for (var i in _this.data) {
1201 if (!i.match(/^cohead_billto_cntct_id/)) {
1204 var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');
1206 _this.data[ni] = '';
1208 _this.form.findField('shipto_address').update();
1210 _this.form.setValues( {
1211 cohead_shipto_cntct_id : '',
1212 cohead_shipto_cntct_id_cntct_name : ''
1220 boxLabel : 'Same as Billing',
1221 name : '_shipto_same'
1229 add : function (combo)
1231 Pman.Dialog.XtupleQuickContact.show(
1234 customer_id : _this.form.findField('cohead_cust_id').getValue()
1239 for(var i in data) {
1241 _this.data['cohead_shipto_cntct_id_' + i] = data[i];
1244 _this.form.findField('shipto_address').update();
1245 // fill in the select box..
1246 _this.form.setValues( {
1247 cohead_shipto_cntct_id : data.cntct_id,
1248 cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1249 data.cntct_last_name
1255 beforeselect : function (combo, record, index)
1258 // just add everything...
1259 for(var i in record.data) {
1260 //Roo.log('cohead_shipto_cntct_id_' + i +' =' + record.data[i]);
1261 _this.data['cohead_shipto_cntct_id_' + i] = record.data[i];
1264 _this.form.findField('shipto_address').update();
1271 displayField : 'cntct_name',
1273 emptyText : "Select ship to",
1274 fieldLabel : 'Ship to',
1275 forceSelection : true,
1276 hiddenName : 'cohead_shipto_cntct_id',
1278 loadingText : "Searching...",
1280 name : 'cohead_shipto_cntct_id_cntct_name',
1282 qtip : "Select shiptoinfo",
1283 queryParam : 'query[cntct_name]',
1284 selectOnFocus : true,
1285 tpl : '<div class="x-grid-cell-text x-btn button">{cntct_name} - <b>{cntct_addr_id_addr_line1}</b> </div>',
1286 triggerAction : 'all',
1288 valueField : 'cntct_id',
1294 beforeload : function (_self, o){
1295 o.params = o.params || {};
1297 o.params._customer_id = _this.data.cohead_cust_id;
1301 sortInfo : { direction : 'ASC', field: 'cntct_name' },
1306 url : baseURL + '/Roo/cntct.php'
1309 xtype: 'JsonReader',
1313 totalProperty : 'total',
1314 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
1322 render : function (_self)
1328 this.el.on('click', function() {
1329 var id = _this.form.findField('cohead_shipto_cntct_id').getValue();
1330 Pman.Dialog.XtupleQuickContact.show(
1333 customer_id : _this.form.findField('cohead_cust_id').getValue()
1338 for(var i in data) {
1340 _this.data['cohead_shipto_cntct_id_' + i] = data[i];
1343 _this.form.findField('shipto_address').update();
1344 // fill in the select box..
1345 _this.form.setValues( {
1346 cohead_shipto_cntct_id : data.cntct_id,
1347 cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1348 data.cntct_last_name
1357 // Roo.log("Click text");
1363 fieldLabel : 'Address',
1364 name : 'shipto_address',
1367 update : function() {
1369 var c = ['first_name', 'last_name' ] ;
1370 var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];
1372 Roo.each(c, function(e) {
1373 if (_this.data['cohead_shipto_cntct_id_cntct_' +e] &&
1374 _this.data['cohead_shipto_cntct_id_cntct_' +e].length) {
1375 v.push(_this.data['cohead_shipto_cntct_id_cntct_' +e]);
1378 Roo.each(a, function(e) {
1379 if (_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e] &&
1380 _this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e].length) {
1381 v.push(_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e]);
1385 this.setValue(v.join("\n"));
1391 fieldLabel : 'Shipment Comments',
1392 name : 'cohead_shipcomments',
1409 name : 'cohead_shipto_id'
1414 name : 'cohead_shipto_id_shipto_name'
1419 name : 'cohead_max_linenumber'
1424 name : 'cohead_cust_id'
1429 name : 'cohead_misc',
1430 recalc : function() {
1431 var d = _this.form.getValues();
1433 parseFloat(d.cohead_pretax_discount) +
1434 parseFloat(d.cohead_posttax_discount) );
1440 name : 'taxzone_rate'
1450 activate : function() {
1453 try { if (MODULE.isBuilder) {
1457 var id = _this.form.findField('cohead_id').getValue() * 1;
1459 Roo.MessageBox.alert("Save First", "Save the order first, before adding items");
1460 _this.dialog.layout.getRegion('center').showPanel(0);
1465 _this.grid.footer.onClick('first');
1467 //if (_this.form.findField('cohead_cust_id_cust_name').getValue() == 'Bloom and Grow HK') {
1468 // _this.xferAll.show();
1471 // _this.xferAll.hide();
1476 deactivate : function (_self)
1479 _this.grid.stopEditing();
1484 fitContainer : true,
1487 tableName : 'coitem',
1488 title : "Order Items",
1490 xtype: 'EditorGrid',
1496 //_this.dialog = Pman.Dialog.FILL_IN
1498 if (_this.panel.active) {
1499 this.footer.onClick('first');
1502 afteredit : function (e)
1504 Roo.log('afteredit:' + e.record.data.coitem_linenumber);
1507 // if ( e.record && e.record.data.coitem_id) {
1508 // as we disable update to the display on the ajax callback to
1509 // allow editing flow to continue, and not refresh - we can only update
1510 // these values after something has actually been edited.
1511 // e.record.set('coitem_id', e.record.data.coitem_id);
1512 // e.record.set('coitem_status', e.record.data.coitem_status);
1515 if (e.field == 'item_number' || e.originalValue == e.value) {
1516 // afterselect handles this...
1519 if (e.field == 'item_descrip1') {
1520 e.record.set('coitem_memo', e.value);
1522 var rate = _this.form.findField('taxzone_rate').getValue();
1524 case 'coitem_linedisc':
1526 var cp = parseFloat(e.record.data.coitem_custprice);
1528 if (isNaN(cp) || cp == 0.0) {
1532 var dis = parseFloat(e.value);
1540 Math.max(0,cp * ((100.0 - parseInt(e.value))/ 100.0) )
1543 // donot need to set the subtotal here, coz we will render it automatically
1545 // 'coitem_subtotal',
1546 // e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord
1550 case 'coitem_price': // SELL@ price
1552 var cp = parseFloat(e.record.data.coitem_custprice);
1553 // list price is < price -- update it..
1554 if (isNaN(cp) || cp == 0.0 || cp < e.value) {
1555 e.record.set('coitem_custprice', e.value);
1558 // update the discount calc.
1560 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( e.value / cp) * 100.0)));
1562 // donot need to set the subtotal here, coz we will render it automatically
1564 // 'coitem_subtotal',
1565 // e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord
1569 case 'coitem_custprice':
1570 // modified customer price...
1571 // just modify the discount.. -- leave the entered price the same..
1572 var sp = parseFloat(e.record.data.coitem_price);
1573 var cp = parseFloat(e.value);
1574 if (isNaN(cp) || cp == 0.0 || cp < e.value) {
1578 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1582 case 'coitem_custprice_tax':
1583 var cp = parseFloat(e.value / ( 1 + rate * 1 ));
1584 var sp = parseFloat(e.record.data.coitem_price);
1586 if (isNaN(cp) || cp == 0.0) {
1589 e.record.set('coitem_custprice', cp);
1590 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1594 case 'coitem_price_tax':
1596 var cp = parseFloat(e.record.data.coitem_custprice);
1597 var sp = parseFloat(e.value / ( 1 + rate * 1 ));
1598 if (isNaN(cp) || cp == 0.0 || cp < sp) {
1599 e.record.set('coitem_custprice', sp);
1602 e.record.set('coitem_price', sp);
1603 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1612 var doupdate = function() {
1613 if (!e.record.updatePending) {
1614 Roo.log('doupdate...' + e.record.data.coitem_linenumber);
1619 Roo.log('doupdate pending...' + e.record.data.coitem_linenumber);
1620 // wait until it's not peding an update..
1621 doupdate.defer(500);
1624 if(e.record.data.coitem_id * 1 < 1 && !e.record.isInserting){ // insert
1625 e.record.isInserting = 1;
1626 e.record.isUpdating = 0;
1632 if(!e.record.isInserting && !e.record.isUpdating){
1633 e.record.isUpdating = 1;
1638 if(!e.record.updatePending){
1639 e.record.updatePending = 1;
1643 Roo.log("got to end without doing an update?" + e.record.data.coitem_linenumber);
1646 beforeedit : function (e)
1648 // we can only edit if nothing is assigned to shipping or invoices..
1652 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0 || (rec.data.shipitem_shipped - rec.data.coitem_qtyshipped) > 0 ) {
1653 Roo.MessageBox.alert("Error", "That item has been shipped, has a draft shipment or invoices - void the shipments/invoices first");
1658 if (rec.data.coitem_subnumber * 1 > 0) {
1659 Roo.log("Edit container event");
1660 Roo.log(e); // if it's a tab..
1664 // allow editing of source / destination..
1665 case 'coitem_shipto_id':
1666 case 'coitem_location_src':
1671 Roo.MessageBox.alert("Error", "That is a kit item, edit the container.");
1675 // zero off values..
1676 //if (e.field == 'coitem_qtyord' && rec.data.coitem_qtyord == 0) {
1679 // if (e.field == 'coitem_custprice' && rec.data.coitem_qtyord == 0.0) {
1683 if (rec.data.item_type == 'K' && e.field == 'item_number') {
1684 // you can not change the product type on kits' as it messing things up..
1685 Roo.MessageBox.alert("Error", "That is a kit item,if you need to change it, delete it first.");
1691 celldblclick : function (_self, rowIndex, columnIndex, e)
1693 var rec = this.ds.getAt(rowIndex);
1694 var di = this.cm.getDataIndex(columnIndex);
1695 if (di != 'avail_qty') {
1699 Pman.Dialog.XtupleInvHistory.show({
1700 itemsite_item_id_item_number : rec.data.item_number,
1701 // itemsite_item_id_item_descript1 : rec.data.item_descrip1,
1702 location_name : rec.data.coitem_location_src_location_name,
1703 location_descrip : rec.data.coitem_location_src_location_descrip,
1705 invhist_transdate : _this.form.findField('cohead_targetdate').getValue()
1709 rowclass : function (gridview, rowcfg)
1711 if (rowcfg.record.data.coitem_status == 'C' &&
1712 rowcfg.record.data.shipitem_shipped * 1 < 1) {
1714 rowcfg.rowClass = 'strikethrough';
1716 if (rowcfg.record.data.coitem_status == 'X' ) {
1718 rowcfg.rowClass = 'strikethrough';
1721 if (!rowcfg.record.data.coitem_id) {
1722 rowcfg.rowClass = 'dragon-not-saved';
1730 autoExpandColumn : 'item_descrip1',
1733 loadAvail : function() {
1736 this.ds.each(function(r) {
1738 if(!r.data.item_number.length){
1742 if(typeof(_this.stockcache[r.data.item_number]) != 'undefined'){
1744 r.set('avail_qty', _this.stockcache[r.data.item_number].qty);
1745 if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {
1746 r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);
1754 item : r.data.item_number,
1755 loc: r.data.coitem_location_src_location_name,
1756 id: r.data.coitem_linenumber + (r.data.coitem_subnumber ? ('.' + r.data.coitem_subnumber) : '')
1760 url : baseURL + '/Roo/itemloc',
1763 _availqty : Roo.encode(q),
1764 curr_name : _this.form.findField('cohead_curr_id').el.dom.value
1766 success : function(res)
1768 for (var i in res.data) {
1769 _this.stockcache[res.data[i].item] = res.data[i];
1771 r.set('avail_qty', _this.stockcache[r.data.item_number].qty);
1772 if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {
1773 r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);
1775 //_this.grid.ds.fireEvent("update", _this.grid.ds, r, Roo.data.Record.EDIT);
1784 xtype: 'CellSelectionModel',
1787 tabend : function (_self)
1789 _this.addItemBtn.fireEvent('click', _this.addItemBtn);
1791 beforeeditnext : function (eventdata)
1795 // this does not work, as the reload effect cancels editng.
1796 var rec = _this.grid.ds.getAt(eventdata.cell[0]);
1797 if (rec.data.coitem_subnumber *1 < 0 ) {
1800 var r = eventdata.cell[0] + 1;
1803 if (r > _this.grid.ds.getCount()-1 ) {
1804 eventdata.cell = false;
1807 rec = _this.grid.ds.getAt(r);
1808 if (rec.data.coitem_subnumber *1 < 0 ) {
1809 eventdata.cell = [ r, eventdata.cell[1] ];
1823 xtype: 'PagingToolbar',
1826 emptyMsg : "No Items",
1828 updateSummary : function() {
1831 url : baseURL + '/Roo/Coitem',
1835 coitem_cohead_id : _this.form.findField('cohead_id').getValue()
1837 success : function(d) {
1839 f.displayEl.update(String.format(
1840 "{0} items | Subtotal: {2} | Tax: {3} | List Discount {4} | Total : {1}{5}",
1842 _this.form.findField('cohead_curr_id').el.dom.value,
1845 d.data.total_list_discount,
1857 click : function (_self, e)
1860 url : baseURL + '/Roo/Cohead',
1863 _fill_shipto : _this.form.findField('cohead_id').getValue()
1865 success : function() {
1866 _this.grid.footer.onClick('first');
1871 text : "Fill empty Ship To"
1877 click : function (_self, e)
1879 Roo.MessageBox.confirm("Confirm", "Are you sure?<BR>"+
1880 "This will set all the locations to match the Sales Order - and remove all old locations.",
1887 url : baseURL + '/Roo/Cohead',
1890 _fill_location : _this.form.findField('cohead_id').getValue(),
1891 _location_id : _this.form.findField('cohead_location_src').getValue()
1893 success : function() {
1894 _this.grid.footer.onClick('first');
1901 text : "Update Location to match S/O"
1907 toggle : function (_self, pressed)
1909 this.setText(pressed ? "Prices exc GST" : "Prices with GST");
1910 var cm = _this.grid.getColumnModel();
1912 cm.setHidden(cm.getIndexByDataIndex('coitem_price_tax'), pressed ? false : true);
1913 cm.setHidden(cm.getIndexByDataIndex('coitem_custprice_tax'), pressed ? false : true);
1914 cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal_tax'), pressed ? false : true);
1916 cm.setHidden(cm.getIndexByDataIndex('coitem_price'), pressed ? true : false);
1917 cm.setHidden(cm.getIndexByDataIndex('coitem_custprice'), pressed ? true : false);
1918 cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal'), pressed ? true : false);
1921 render : function (_self)
1923 _this.showgstBtn = _self;
1926 enableToggle : true,
1928 text : "Prices with GST"
1936 beforeload : function (_self,o) {
1943 if (!_this.data || !_this.data.cohead_id) {
1946 o.params = o.params || {};
1948 o.params.coitem_cohead_id = _this.data.cohead_id;
1949 o.params._without_list_discount =1;
1950 //o.params.limit = 999;
1954 update : function (_self, rec, operation)
1957 if (operation != Roo.data.Record.COMMIT) {
1961 // row has been updated..
1962 // if the qty + item has been filled in, we should try and save it..
1965 var setRecord = function(){
1967 Roo.log("Clearing update?" + rec.data.coitem_linenumber);
1968 rec.updatePending = 0;
1969 if(rec.isInserting){
1970 rec.isInserting = 0;
1976 if (!(rec.data.coitem_itemsite_id * 1) || !(rec.data.coitem_qtyord*1)) {
1980 var doCommit = function() {
1981 Roo.log("Sending data?" + rec.data.coitem_linenumber);
1984 url : baseURL+'/Roo/coitem',
1987 success: function(res)
1990 var row = _this.grid.ds.indexOf(rec);
1991 Roo.get(_this.grid.view.getRow(row)).removeClass('dragon-not-saved');
1997 Roo.log("GOT success: " + rec.data.coitem_linenumber);
1998 //Roo.log("GOT success");
1999 // update the data...
2001 if (rec.data.item_type == 'K') {
2003 _this.grid.ds.load({});
2008 // why is this here.??
2010 if (_this.grid.activeEditor) {
2016 rec.set('coitem_id', res.data.coitem_id);
2017 rec.set('coitem_status', res.data.coitem_status);
2021 delete rec.modified;
2023 _this.grid.footer.updateSummary();
2024 _this.grid.loadAvail();
2030 failure : function(res)
2033 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error updating");
2046 load : function (_self, records, options)
2048 // need to fetch availablity from master data..
2049 // build a list of what to ask..
2051 // query: ITEM CODE - LOCATION
2052 _this.grid.footer.updateSummary();
2053 _this.grid.loadAvail.defer(100, _this.grid);
2061 sortInfo : { field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' },
2066 url : baseURL + '/Roo/coitem.php'
2069 xtype: 'JsonReader',
2073 totalProperty : 'total',
2076 'name': 'coitem_linenumber',
2080 'name': 'coitem_itemsite_id',
2084 'name': 'coitem_qtyord'
2087 'name': 'coitem_unitcost'
2090 'name': 'coitem_price'
2093 'name': 'coitem_custprice'
2096 'name': 'coitem_qtyreturned'
2099 'name': 'coitem_prcost'
2102 'name': 'coitem_price_uom_id',
2106 'name': 'coitem_qtyreserved'
2122 Roo.log("add presed");
2125 var grid = _this.grid;
2127 grid.ds.each(function(r) {
2128 if (r.data.coitem_qtyord < 1) {
2129 Roo.MessageBox.alert("Error", "you must fill in a quantity for " + r.data.item_number);
2141 var last = _this.form.findField('cohead_max_linenumber').getValue();
2148 _this.form.findField('cohead_max_linenumber').setValue(last);
2150 // this should be getting the previous row..??
2151 var ct = _this.grid.ds.getCount();
2152 var lastrow = ct ? _this.grid.ds.getAt(ct-1) : false;
2154 function lastor(k,d,kk) {
2155 var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();
2156 return lastrow ? lastrow.data[kk] : def;
2159 // uses form defaults or last row value.
2160 var nr = _this.grid.ds.reader.newRow({
2161 coitem_linenumber : last,
2165 coitem_cohead_id : _this.form.findField('cohead_id').getValue(),
2166 coitem_qtyshipped : 0,
2167 coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),
2168 coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),
2169 coitem_shipto_id : lastor('cohead_shipto_id',false, 'coitem_shipto_id'),
2170 coitem_shipto_id_shipto_name : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name'),
2171 coitem_unitcost_in_order_cur : 0,
2172 coitem_taxtype_id : _this.data.default_taxtype_id,
2173 coitem_taxtype_id_taxtype_name : 'Taxable',
2179 grid.ds.insert(grid.ds.getCount(), nr);
2180 grid.startEditing(grid.ds.getCount()-1, 1); // type..
2181 nr.updatePending = 0;
2186 render : function (_self)
2188 _this.addItemBtn = _self;
2191 cls : 'x-btn-text-icon',
2193 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
2199 click : function (_self, e)
2201 var last = _this.form.findField('cohead_max_linenumber').getValue();
\r
2203 _this.form.findField('cohead_max_linenumber').setValue(last);
2205 var ct = _this.grid.ds.getCount();
\r
2206 var lastrow = ct ? _this.grid.ds.getAt(ct-1) : false;
\r
2208 function lastor(k,d,kk) {
\r
2209 var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();
\r
2210 return lastrow ? lastrow.data[kk] : def;
\r
2213 var cohead_cust_id = _this.form.findField('cohead_cust_id').getValue();
2214 var cohead_id = _this.form.findField('cohead_id').getValue();
2216 Pman.Dialog.XtupleSalesProductList.show( {cohead_cust_id : cohead_cust_id, cohead_id : cohead_id} , function(res) {
2218 _this.grid.stopEditing();
2220 if (_this.grid.ds.getCount() > 0) {
2221 var lr = _this.grid.ds.getAt(_this.grid.ds.getCount()-1);
2222 if (!lr.data.coitem_itemsite_id) {
2223 lr.set('coitem_itemsite_id', res.item_itemsite_id_itemsite_id);
2224 lr.set('item_number', res.item_number);
2225 lr.set('item_descrip1', res.item_descrip1);
2226 lr.set('coitem_listprice', res.item_price);
2227 lr.set('coitem_price', res.item_price);
2228 lr.set('coitem_custprice', res.item_price);
2235 var nr = _this.grid.ds.reader.newRow({
2236 coitem_linenumber : last,
2237 coitem_itemsite_id : res.item_itemsite_id_itemsite_id,
2238 item_number : res.item_number,
2239 item_descrip1 : res.item_descrip1,
2241 coitem_cohead_id : _this.form.findField('cohead_id').getValue(),
2242 coitem_qtyshipped : 0,
2243 coitem_listprice : res.item_price,
2244 coitem_price : res.item_price,
2245 coitem_custprice : res.item_price,
2247 coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),
2248 coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),
2249 coitem_shipto_id : lastor('cohead_shipto_id',false, 'coitem_shipto_id'),
2250 coitem_shipto_id_shipto_name : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name')
2253 _this.grid.ds.insert(_this.grid.ds.getCount(), nr);
2258 cls : 'x-btn-text-icon',
2259 text : "Find Products",
2260 icon : rootURL + '/Pman/templates/images/search.gif'
2270 url : baseURL + '/Roo/coitem',
2271 mask : 'Loading Data',
2275 _hk_xfer :_this.form.findField('cohead_id').getValue()
2277 success : function() {
2278 _this.grid.ds.load({});
2283 render : function (_self)
2285 _this.xferAll = _self;
2288 cls : 'x-btn-text-icon',
2290 text : "Xfer all stock to HK",
2291 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
2297 click : function (_self, e)
2299 var c = _this.grid.getSelectionModel().getSelectedCell();
2301 Roo.MessageBox.alert("Error", "Select item to show history (you can also double click on the #avail number) ");
2305 var rec = _this.grid.ds.getAt(c[0]);
2307 Pman.Dialog.XtupleInvHistory.show({
2308 itemsite_item_id_item_number : rec.data.item_number,
2309 // itemsite_item_id_item_descript1 : rec.data.item_descrip1,
2310 location_name : rec.data.coitem_location_src_location_name,
2311 location_descrip : rec.data.coitem_location_src_location_descrip,
2314 invhist_transdate : _this.form.findField('cohead_targetdate').getValue()
2320 text : "Show Inventory History"
2329 text : "Apply % Discount of : "
2335 render : function (_self)
2337 _this._applyDiscount = _self;
2346 click : function (_self, e)
2348 var val = parseFloat(_this._applyDiscount.getValue());
2350 var factor = (100.0 - val)/100.0;
2352 _this.grid.ds.each(function(rec) {
2353 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2357 rec.set('coitem_price', rec.data.coitem_custprice * factor);
2358 rec.set('coitem_linedisc', val);
2359 rec.set('coitem_subtotal', rec.data.coitem_price & rec.data.ordqty);
2367 text : "Apply To All"
2373 click : function (_self, e)
2376 if (!(1* _this.form.findField('cohead_id').getValue())) {
2377 Roo.MessageBox.alert("Error", "save the order first");
2381 Pman.Dialog.Image.show(
2384 _url : baseURL+'/Xtuple/Import/SalesOrder',
2385 onid : _this.form.findField('cohead_id').getValue()
2390 Roo.MessageBox.alert("Notice", "Uploaded");
2391 _this.grid.footer.onClick('first');
2409 _this.grid.stopEditing();
2410 // check that no shipments or invoices are done..
2411 var rc = _this.grid.getSelectionModel().getSelectedCell();
2413 var rec = _this.grid.ds.getAt(rc[0]);
2415 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2416 Roo.MessageBox.alert("Error", "That item has been shipped or invoices - void the shipments/invoices first");
2419 if (rec.data.coitem_subnumber*1 > 0) {
2420 Roo.MessageBox.alert("Error", "Delete the kit item that that belongs to.");
2423 if (!rec.data.coitem_id) {
2424 _this.grid.ds.remove(rec);
2431 url : baseURL + '/Roo/coitem',
2434 _delete : rec.data.coitem_id
2437 success : function() {
2438 if (rec.data.item_type == 'K') {
2439 _this.grid.ds.load({});
2442 _this.grid.ds.remove(rec);
2447 if (rec.data_qtyord * 1 < 1) {
2451 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that line?", function(r)
2464 cls : 'x-btn-text-icon',
2466 icon : rootURL + '/Pman/templates/images/trash.gif'
2474 _this.grid.stopEditing();
2475 // check that no shipments or invoices are done..
2477 _this.grid.ds.each(function(rec) {
2481 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2482 //Roo.MessageBox.alert("Error", "That item has been shipped or invoices - void the shipments/invoices first");
2485 if (rec.data.item_type == 'K') {
2489 if (rec.data.coitem_subnumber*1 > 0) {
2490 //Roo.MessageBox.alert("Error", "Delete the kit item that that belongs to.");
2493 if (!rec.data.coitem_id) {
2494 _this.grid.ds.remove(rec);
2497 ids.push(rec.data.coitem_id);
2503 url : baseURL + '/Roo/coitem',
2506 _delete : ids.join(',')
2509 success : function() {
2511 _this.grid.footer.onClick('first');
2516 // if (rec.data_qtyord * 1 < 1) {
2520 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete everything?", function(r)
2533 cls : 'x-btn-text-icon',
2534 text : "Delete All",
2535 icon : rootURL + '/Pman/templates/images/trash.gif'
2541 xtype: 'ColumnModel',
2543 dataIndex : 'coitem_linenumber',
2546 renderer : function(v,x,r) {
2548 if (r.data.coitem_subnumber * 1 > 0) {
2549 return String.format('{0}.{1}', v,r.data.coitem_subnumber);
2551 return String.format('{0}', v);
2555 xtype: 'ColumnModel',
2557 dataIndex : 'item_number',
2558 header : 'Item Code',
2560 renderer : function(v) { return String.format('{0}', v); },
2562 xtype: 'GridEditor',
2568 beforeselect : function (combo, record, index)
2570 // set _this.data values ..
2571 var ar = _this.grid.activeEditor.record;
2572 // Roo.log('beforeselect');
2576 // Roo.log('beforeselect-cb');
2577 ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
2578 ar.set('coitem_listprice', record.data.item_listprice);
2579 ar.set('coitem_price', record.data.item_price);
2580 ar.set('coitem_custprice', record.data.item_price);
2581 ar.set('coitem_itemsite_id', record.data.itemsite_id);
2582 ar.set('item_number', record.data.itemsite_item_id_item_number);
2583 ar.set('item_type', record.data.itemsite_item_id_item_type);
2584 ar.set('avail_qty', 0);
2591 displayField : 'itemsite_item_id_item_number',
2593 emptyText : "Select item",
2594 forceSelection : true,
2595 hiddenName : 'itemsite_item_id_item_number',
2597 loadingText : "Searching...",
2599 name : 'item_number',
2601 qtip : "Select item",
2602 queryParam : 'query[number]',
2603 selectOnFocus : true,
2604 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>',
2605 triggerAction : 'all',
2607 valueField : 'item_number',
2612 beforeload : function (_self, o){
2613 o.params = o.params || {};
2614 o.params.customer_id = _this.form.findField('cohead_cust_id').getValue();
2615 o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue();
2616 //o.params.shipto_cust_id = _this.data.cohead_cust_id;
2621 sortInfo : { direction : 'ASC', field: 'item_number' },
2626 url : baseURL + '/Roo/itemsite.php'
2629 xtype: 'JsonReader',
2633 totalProperty : 'total',
2634 fields : [{"name":"item_id","type":"int"},"item_number"]
2641 xtype: 'ColumnModel',
2643 dataIndex : 'coitem_location_src',
2646 renderer : function(v,x,r) {
2647 return String.format('{0}', r.data.coitem_location_src_location_name);
2650 xtype: 'GridEditor',
2656 beforeselect : function (combo, record, index)
2658 // set _this.data values ..
2659 var ar = _this.grid.activeEditor.record;
2663 //Roo.log('beforeselect');
2667 // Roo.log('beforeselect-cb');
2668 ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
2669 ar.set('coitem_price', record.data.item_listprice);
2670 ar.set('coitem_custprice', record.data.item_price);
2671 ar.set('coitem_itemsite_id', record.data.itemsite_id);
2672 ar.set('item_number', record.data.itemsite_item_id_item_number);
2681 displayField : 'location_name',
2683 emptyText : "Select location",
2684 forceSelection : true,
2685 hiddenName : 'coitem_location_src',
2687 loadingText : "Searching...",
2689 name : 'coitem_location_src_location_name',
2691 qtip : "Select item",
2692 queryParam : 'query[location_name]',
2693 selectOnFocus : true,
2694 tpl : '<div class="x-grid-cell-text x-btn button"><b> {location_name}</b> {location_descrip}</div>',
2695 triggerAction : 'all',
2697 valueField : 'location_id',
2702 beforeload : function (_self, o){
2703 o.params = o.params || {};
2705 var row = _this.grid.activeEditor.record;
2707 o.params['query[item_itemsite_id]'] = row.data.coitem_itemsite_id;
2708 // need to know the date to calc the est. delivery time..
2709 //o.params['query[avail_when]'] = _this.form.findField('cohead_targetdate').getValue().format('Y-m-d');
2710 //o.params.location_netable = 1;
2711 o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue();
2713 o.params.location_restrict = 0;
2714 o.params._notinternalcompany = 1;
2718 // o.params.itemsite_id = _this.form.findField('cohead_cust_id').getValue();
2719 //o.params.shipto_cust_id = _this.data.cohead_cust_id;
2724 sortInfo : { direction : 'ASC', field: 'location_name' },
2729 url : baseURL + '/Roo/location.php'
2732 xtype: 'JsonReader',
2736 totalProperty : 'total',
2737 fields : [{"name":"location_id","type":"int"},"location_name"]
2744 xtype: 'ColumnModel',
2746 dataIndex : 'coitem_shipto_id',
2749 renderer : function(v,x,r) {
2750 return String.format('{0}:{1}', v, r.data.coitem_shipto_id_shipto_name);
2753 xtype: 'GridEditor',
2759 add : function (combo)
2762 Pman.Dialog.XtupleCustomer.show({ cust_id : _this.form.findField('cohead_cust_id').getValue() }, function(data) {
2763 // refresh the data in the pulldown..
2766 beforeselect : function (combo, record, index)
2770 for(var i = 1; i <4; i++) {
2771 _this.data['cohead_shiptoaddress'+ i] = record.data['cntct_addr_id_addr_line'+i];
2773 _this.form.findField('shipto_address').update();
2780 displayField : 'shipto_name',
2782 emptyText : "Select cntct",
2783 forceSelection : true,
2784 hiddenName : 'cohead_shipto_id',
2786 loadingText : "Searching...",
2788 name : 'coitem_shipto_id_shipto_name',
2790 qtip : "Select shipto",
2791 queryParam : 'query[shipto_name]',
2792 selectOnFocus : true,
2793 tpl : '<div class="x-grid-cell-text x-btn button"><b>{shipto_id}:{shipto_addr_id_addr_name}</b> </div>',
2794 triggerAction : 'all',
2796 valueField : 'shipto_id',
2802 beforeload : function (_self, o){
2803 o.params = o.params || {};
2804 o.params.shipto_cust_id = _this.data.cohead_cust_id;
2805 //o.params['query[with_shipinfo]'] = 1;
2810 sortInfo : { direction : 'ASC', field: 'shipto_name' },
2815 url : baseURL + '/Roo/shiptoinfo.php'
2818 xtype: 'JsonReader',
2822 totalProperty : 'total',
2823 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
2830 xtype: 'ColumnModel',
2832 dataIndex : 'item_descrip1',
2833 header : 'Item Description',
2835 renderer : function(v,x,r) {
2837 if (r.data.coitem_memo && r.data.coitem_memo.length) {
2838 return String.format('{0}', r.data.coitem_memo);
2839 if (r.data.coitem_memo != v) {
2840 r.set('item_descrip1', r.data.coitem_memo);
2844 if (v && v.length > 49) {
2845 return String.format('<span style="color:orange" qtip="line may be too long to print">{0}</span>', v);
2848 return String.format('{0}', v);
2852 xtype: 'GridEditor',
2862 xtype: 'ColumnModel',
2865 dataIndex : 'coitem_status',
2868 renderer : function(v) { return String.format('{0}', v); }
2871 xtype: 'ColumnModel',
2874 dataIndex : 'coitem_qtyord',
2877 renderer : function(v,x,r) {
2878 var v = parseInt(v);
2879 //var aq = parseInt(r.data.avail_qty);
2880 //aq = isNaN(aq) ? 0 : aq;
2882 var rate = _this.form.findField('taxzone_rate').getValue();
2883 r.data.coitem_subtotal = v * r.data.coitem_price;
2884 r.data.coitem_subtotal_tax = v * r.data.coitem_price * ( 1 + rate * 1);
2885 return String.format('{0}', v);
2889 xtype: 'GridEditor',
2892 xtype: 'NumberField',
2895 focus : function (_self)
2897 if (this.value == 0) {
2898 this.el.dom.value = '';
2902 allowDecimals : false,
2903 decimalPrecision : 0,
2905 style : 'text-align:right'
2910 xtype: 'ColumnModel',
2913 dataIndex : 'coitem_price',
2916 renderer : function(v,x,r) {
2918 var rate = _this.form.findField('taxzone_rate').getValue();
2919 r.data.coitem_subtotal = v * r.data.coitem_qtyord;
2920 r.data.coitem_subtotal_tax = v * ( 1 + rate * 1 ) * r.data.coitem_qtyord;
2921 r.data.coitem_price_tax = v * ( 1 + rate * 1 );
2922 if (parseInt(v) < 1) {
2923 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,3));
2927 //r.set('coitem_subtotal', v * r.data.coitem_qtyord);
2929 return String.format('{0}', Roo.util.Format.number(v,3));
2932 xtype: 'GridEditor',
2935 xtype: 'NumberField',
2938 focus : function (_self)
2940 if (this.value == 0.0) {
2941 this.el.dom.value = '';
2945 decimalPrecision : 3,
2947 style : 'text-align:right'
2952 xtype: 'ColumnModel',
2955 dataIndex : 'coitem_price_tax',
2956 header : 'Sell @w/GST',
2959 renderer : function(v,x,r) {
2961 if (parseInt(v) < 1) {
2962 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,3));
2965 return String.format('{0}', Roo.util.Format.number(v,3));
2968 xtype: 'GridEditor',
2971 xtype: 'NumberField',
2974 focus : function (_self)
2976 if (this.value == 0.0) {
2977 this.el.dom.value = '';
2981 decimalPrecision : 3,
2983 style : 'text-align:right'
2988 xtype: 'ColumnModel',
2991 dataIndex : 'coitem_linedisc',
2994 renderer : function(v,x,r) {
2996 // coitem_custprice = coitem_price * ((100 - coitem_disc)/ 100)
2998 // 12 * (( 100 - 0) / 100)
2999 // coitem_custprice / coitem_price = ((100 - coitem_disc)/ 100)
3000 // 100 - ((coitem_custprice / coitem_price) * 100) = coitem_disc
3001 // 100 - 97 = 100 -3
3003 // r.data.coitem_linedisc = 100 - (
3004 // (parseFloat(r.data.coitem_custprice) /
3005 // parseFloat(r.data.coitem_price)
3007 var fl = parseFloat(r.data.coitem_linedisc);
3008 if ( isNaN(fl) || fl == 0.0 || r.data.coitem_price > r.data.coitem_custprice) {
3011 return String.format('<span style="color:green">{0}%</span>', Roo.util.Format.number( r.data.coitem_linedisc,2));
3014 xtype: 'GridEditor',
3017 xtype: 'NumberField',
3020 focus : function (_self)
3022 if (this.value == 0.0) {
3023 this.el.dom.value = '';
3027 decimalPrecision : 2,
3030 style : 'text-align:right'
3035 xtype: 'ColumnModel',
3038 dataIndex : 'coitem_custprice',
3039 header : 'List Price',
3041 renderer : function(v,x,r) {
3043 var rate = _this.form.findField('taxzone_rate').getValue();
3044 r.data.coitem_custprice_tax = v * ( 1 + rate * 1 );
3046 var tip = 'No WRP available';
3047 if ((r.data.coitem_wrpprice * 1) > 0) {
3048 tip = "WRP : " + Roo.util.Format.number(r.data.coitem_wrpprice,3);
3050 // less than zero, show as red..
3051 if (parseFloat(v) < 1) {
3052 return String.format('<b qtip="{1}" style="color:red;">{0}</b>',
3053 Roo.util.Format.number(v,3), tip);
3055 if (r.data.customer_price_each != v) {
3056 return String.format('<b qtip="{1}" style="color:pink;">{0}</b>',
3057 Roo.util.Format.number(v,3),
3058 "List Price = " + Roo.util.Format.number(r.data.customer_price_each,3)
3064 //r.data.coitem_subtotal = v * r.data.coitem_qtyord;
3066 //r.set('coitem_subtotal', v * r.data.coitem_qtyord);
3068 return String.format('<span qtip="{1}">{0}</span>', Roo.util.Format.number(v,3), tip);
3071 xtype: 'GridEditor',
3074 xtype: 'NumberField',
3077 focus : function (_self)
3079 if (this.value == 0.0) {
3080 this.el.dom.value = '';
3084 decimalPrecision : 3,
3086 style : 'text-align:right'
3091 xtype: 'ColumnModel',
3094 dataIndex : 'coitem_custprice_tax',
3095 header : 'List Price w/GST',
3098 renderer : function(v,x,r) {
3099 var rate = _this.form.findField('taxzone_rate').getValue();
3100 var tip = 'No WRP available';
3101 if ((r.data.coitem_wrpprice * 1) > 0) {
3102 tip = "WRP : " + Roo.util.Format.number(r.data.coitem_wrpprice,3);
3105 if (parseFloat(v) < 1) {
3106 return String.format('<b qtip="{1}" style="color:red;">{0}</b>',
3107 Roo.util.Format.number(v,3), tip);
3109 if (r.data.customer_price_each != v) {
3110 return String.format('<b qtip="{1}" style="color:pink;">{0}</b>',
3111 Roo.util.Format.number(v,3),
3112 "List Price = " + Roo.util.Format.number(r.data.customer_price_each * ( 1 + rate * 1 ),3)
3116 return String.format('<span qtip="{1}">{0}</span>', Roo.util.Format.number(v,3), tip);
3119 xtype: 'GridEditor',
3122 xtype: 'NumberField',
3125 focus : function (_self)
3127 if (this.value == 0.0) {
3128 this.el.dom.value = '';
3132 decimalPrecision : 3,
3134 style : 'text-align:right'
3139 xtype: 'ColumnModel',
3142 dataIndex : 'coitem_subtotal',
3143 header : 'SubTotal',
3145 renderer : function(v) {
3147 if (parseInt(v) < 1) {
3148 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,2));
3153 return Roo.util.Format.number( v, 2);
3157 xtype: 'ColumnModel',
3160 dataIndex : 'coitem_subtotal_tax',
3161 header : 'SubTotal w/GST',
3164 renderer : function(v,x,r) {
3166 if (parseInt(v) < 1) {
3167 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,2));
3170 return String.format('{0}', Roo.util.Format.number(v,2));
3174 xtype: 'ColumnModel',
3177 dataIndex : 'coitem_unitcost_in_order_cur',
3178 header : 'Unit Cost',
3180 renderer : function(v) { return Roo.util.Format.number( v, 2); }
3183 xtype: 'ColumnModel',
3186 dataIndex : 'coitem_taxtype_id',
3189 renderer : function(v,x,r) { return String.format('{0}', r.data.coitem_taxtype_id_taxtype_name); },
3191 xtype: 'GridEditor',
3197 displayField : 'taxtype_name',
3199 emptyText : "Select Tax Type",
3200 forceSelection : true,
3201 hiddenName : 'coitem_taxtype_id',
3203 loadingText : "Searching...",
3205 name : 'coitem_taxtype_id_taxtype_name',
3207 qtip : "Select taxtype",
3208 queryParam : 'query[taxtype_id]',
3209 selectOnFocus : true,
3210 tpl : '<div class="x-grid-cell-text x-btn button"><b>{taxtype_name}</b> </div>',
3211 triggerAction : 'all',
3213 valueField : 'taxtype_id',
3219 beforeload : function (_self, o){
3220 o.params = o.params || {};
3227 sortInfo : { direction : 'ASC', field: 'taxtype_name' },
3232 url : baseURL + '/Roo/taxtype.php'
3235 xtype: 'JsonReader',
3239 totalProperty : 'total',
3240 fields : [{"name":"taxtype_id","type":"int"},"taxtype_name"]
3247 xtype: 'ColumnModel',
3250 dataIndex : 'avail_qty',
3253 renderer : function(v,x,r) {
3255 var oq = parseInt(r.data.coitem_qtyord);
3256 var aq = parseInt(r.data.avail_qty);
3257 var sq = parseInt(r.data.coitem_qtyshipped);
3258 aq = isNaN(aq) ? 0 : aq;
3259 oq = isNaN(oq) ? 0 : oq;
3260 sq = isNaN(sq) ? 0 : sq;
3262 var unshipped = oq - sq;
3264 if ( aq < 0 || (unshipped > 0 && aq < unshipped)) {
3265 return String.format('<b style="color:red;">{0}</b>', parseInt(aq));
3268 return String.format('{0}', aq);
3273 xtype: 'ColumnModel',
3276 dataIndex : 'shipitem_shipped',
3277 header : '#reserved',
3279 renderer : function(v,x,r) {
3282 var vv = parseInt(v);
3283 vv = isNaN(vv) ? 0 : vv;
3285 var ov = parseInt(r.data.coitem_qtyord);
3286 ov = isNaN(ov) ? 0 : ov;
3288 var qs = parseInt(r.data.coitem_qtyshipped);
3289 qs = isNaN(qs) ? 0 : qs;
3294 // not enough reserved yet.
3295 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv - qs);
3298 return String.format('{0}', vv - qs);
3303 xtype: 'ColumnModel',
3306 dataIndex : 'coitem_qtyshipped',
3307 header : '#shipped',
3309 renderer : function(v,x,r) {
3311 var vv = parseInt(v);
3312 vv = isNaN(vv) ? 0 : vv;
3314 var ov = parseInt(r.data.coitem_qtyord);
3315 ov = isNaN(ov) ? 0 : ov;
3319 // not enought shipped.
3320 // or too many shipped.
3321 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv);
3326 return String.format('{0}', vv);
3331 xtype: 'ColumnModel',
3334 dataIndex : 'cobill_billed',
3335 header : '#invoiced',
3337 renderer : function(v,x,r) {
3339 var vv = parseInt(v);
3340 vv = isNaN(vv) ? 0 : vv;
3342 var ov = parseInt(r.data.coitem_qtyord);
3343 ov = isNaN(ov) ? 0 : ov;
3347 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv);
3349 return String.format('{0}', vv);
3357 xtype: 'NestedLayoutPanel',
3360 activate : function (_self)
3362 _this.shipinvtab = _self;
3366 title : "Shipments / Invoices",
3368 xtype: 'BorderLayout',
3375 activate : function() {
3376 _this.shippanel = this;
3377 if (_this.shipgrid) {
3378 _this.shipgrid.ds.load({});
3383 fitContainer : true,
3386 tableName : 'shiphead',
3394 _this.shipgrid = this;
3395 //_this.dialog = Pman.Dialog.FILL_IN
3396 if (_this.shippanel.active) {
3400 rowdblclick : function (_self, rowIndex, e)
3402 var rec = this.ds.getAt(rowIndex);
3403 if (!rec.json.shiphead_shipdate.length) {
3404 Roo.MessageBox.alert("Error", "You can not edit voided shipments, create a new one, and use the restore feature");
3408 Pman.Dialog.XtupleShipment.show({
3409 shiphead_id : rec.data.shiphead_id
3418 autoExpandColumn : 'shiphead_shipvia',
3424 beforeload : function (_self, options)
3426 options.params = options.params || {};
3427 options.params.shiphead_order_id = _this.form.findField('cohead_id').getValue() * 1;
3428 if (options.params.shiphead_order_id < 1) {
3434 sortInfo : { field : 'shiphead_shipvia', direction: 'ASC' },
3439 url : baseURL + '/Roo/shiphead.php'
3442 xtype: 'JsonReader',
3444 totalProperty : 'total',
3449 'name': 'shiphead_number',
3453 'name': 'shiphead_shipvia',
3457 'name': 'shiphead_shipdate',
3461 'name': 'shiphead_sfstatus'
3464 'name': 'shiphead_tracknum',
3480 var sel = _this.shipgrid.getSelectionModel().getSelected();
3482 Roo.MessageBox.alert("Error", "Select a shipment");
3485 if (sel.data.shiphead_shipped) {
3486 Roo.MessageBox.alert("Error", "Shipment is already confirmed");
3491 // check current status of shipment..
3496 url : baseURL + '/Roo/shiphead',
3500 shiphead_id : sel.data.shiphead_id,
3503 success : function() {
3504 _this.shipgrid.ds.load({});
3511 cls : 'x-btn-text-icon',
3512 text : "Confirm Shipment",
3513 icon : rootURL + '/Pman/templates/images/lock.gif'
3521 var sel = _this.shipgrid.getSelectionModel().getSelected();
3523 Roo.MessageBox.alert("Error", "Select a shipment");
3528 // check current status of shipment..
3532 url : baseURL + '/Roo/shiphead',
3535 _download :sel.data.shiphead_id
3543 cls : 'x-btn-text-icon',
3544 text : "Download (as xls)",
3545 icon : rootURL + '/Pman/templates/images/save.gif'
3553 var sel = _this.shipgrid.getSelectionModel().getSelected();
\r
3555 Roo.MessageBox.alert("Error", "Select a shipment");
\r
3558 // check current status of shipment..
3561 url : baseURL + '/Xtuple/Print',
3564 template : 'picking-slip',
3565 param : "shiphead_id:integer='" + sel.data.shiphead_id + "'",
3566 filename : 'picking-slip-' + sel.data.shiphead_number
3568 success : function() {
3577 cls : 'x-btn-text-icon',
3578 text : "Print Picking Slip",
3579 icon : rootURL + '/Pman/templates/images/pdf.gif'
3587 var sel = _this.shipgrid.getSelectionModel().getSelected();
\r
3589 Roo.MessageBox.alert("Error", "Select a shipment");
\r
3592 // check current status of shipment..
3595 url : baseURL + '/Xtuple/Print',
3598 template : 'delivery-note-',
3599 param : "shiphead_id:integer='" + sel.data.shiphead_id + "'",
3600 filename : 'delivery-note-' + sel.data.shiphead_number
3602 success : function() {
3611 cls : 'x-btn-text-icon',
3612 text : "Print Delivery Note",
3613 icon : rootURL + '/Pman/templates/images/pdf.gif'
3625 if (!_this.form.findField('cohead_id').getValue()) {
3626 Roo.MessageBox.alert("Error", "Save Order first");
3629 var rv = _this.form.getFieldValues();
3631 Pman.Dialog.XtupleShipmentNew.show({
3632 shiphead_order_id : rv.cohead_id,
3633 shiphead_shipdate : _this.form.findField('cohead_targetdate').getValue().format('Y-m-d')
3636 _this.shipgrid.ds.load({});
3640 render : function (_self)
3642 _this.addShipmentBtn = _self;
3645 cls : 'x-btn-text-icon',
3647 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
3655 var sel = _this.shipgrid.getSelectionModel().getSelected();
3657 Roo.MessageBox.alert("Error", "Select a shipment");
3660 // check current status of shipment..
3662 var msg = sel.data.shiphead_shipped ?
3663 "Are you sure you want to un-confirm that shipment? - It will remove items from unposted invoices" :
3664 "Are you sure you want to void that shipment?";
3666 Roo.MessageBox.confirm("Are you sure", msg,
3674 url : baseURL + '/Roo/shiphead',
3678 shiphead_id : sel.data.shiphead_id,
3681 success : function() {
3682 _this.shipgrid.ds.load({});
3695 cls : 'x-btn-text-icon',
3696 text : "Void / Unconfirm",
3697 icon : rootURL + '/Pman/templates/images/trash.gif'
3703 xtype: 'ColumnModel',
3705 dataIndex : 'shiphead_number',
3708 renderer : function(v,x,r) {
3709 if (r.json.shiphead_shipdate.length) {
3710 return String.format('{0}', v);
3712 return String.format('<s>{0}</s>', v);
3716 xtype: 'ColumnModel',
3718 dataIndex : 'shiphead_location_id_location_name',
3719 header : 'From Location',
3721 renderer : function(v) { return String.format('{0}', v); }
3724 xtype: 'ColumnModel',
3726 dataIndex : 'shiphead_shipto_id_shipto_name',
3729 renderer : function(v) { return String.format('{0}', v); }
3732 xtype: 'ColumnModel',
3734 header : 'shipdate',
3736 dataIndex : 'shiphead_shipdate',
3737 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
3740 xtype: 'ColumnModel',
3742 dataIndex : 'shiphead_sfstatus',
3745 renderer : function(v,x,r) {
3750 if (r.json.shiphead_shipdate.length) {
3752 if (r.json.shiphead_shipped) {
3756 return '<span style="color:red">Draft</span>';
3765 xtype: 'ColumnModel',
3769 dataIndex : 'shiphead_shipvia',
3770 renderer : function(v) { return String.format('{0}', v); }
3773 xtype: 'ColumnModel',
3775 header : 'tracknum',
3777 dataIndex : 'shiphead_tracknum',
3778 renderer : function(v) { return String.format('{0}', v); }
3787 activate : function() {
3788 _this.invpanel = this;
3789 if (_this.invgrid) {
3790 _this.invgrid.ds.load({});
3795 fitContainer : true,
3798 tableName : 'cobmisc',
3806 _this.invgrid = this;
3807 //_this.dialog = Pman.Dialog.FILL_IN
3808 if (_this.invpanel.active) {
3812 rowdblclick : function (_self, rowIndex, e)
3815 var ri = this.ds.getAt(rowIndex);
3816 if ( ri.data.cobmisc_id < 0) { // skip summary row..
3819 var rv = _this.form.getFieldValues();
3820 Pman.Dialog.XtupleInvoice.show({
3821 cobmisc_id : ri.data.cobmisc_id,
3822 // below parms for add credit memo
3824 cm_cust_id : rv.cohead_cust_id,
3825 cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,
3826 cm_curr_id : rv.cohead_curr_id,
3827 cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,
3828 cm_terms_id : rv.cohead_terms_id,
3829 cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,
3830 cm_salesrep_id : rv.cohead_salesrep_id,
3831 cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,
3832 cm_docdate : new Date(),
3833 cm_taxzone_id : rv.cohead_taxzone_id,
3834 cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,
3835 cm_billto_cntct_id : rv.cohead_billto_cntct_id,
3836 cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,
3837 cm_location_src : rv.cohead_location_src,
3838 cm_location_src_location_name : rv.cohead_location_src_location_name,
3839 cm_billto_address : rv.billto_address
3843 _this.invgrid.ds.load({});
3848 autoExpandColumn : 'invchead_invcnumber',
3854 beforeload : function (_self, options)
3857 options.params = options.params || {};
3858 options.params.cobmisc_cohead_id = _this.form.findField('cohead_id').getValue() * 1;
3859 if (options.params.cobmisc_cohead_id < 1) {
3863 options.params._with_other_payment = 1;
3864 //options.params['query[invchead_ordernumber]'] = _this.form.findField('cohead_number').getValue()
3867 load : function (_self, records, options)
3872 var totalfreight = 0.0;
3873 var totalmisc = 0.0;
3876 Roo.each(records, function(r)
3878 if(r.data.cobmisc_id > 1){
3879 done += parseInt(r.data.cobmisc_qty);
3880 totalic += parseFloat(r.data.cobmisc_itemcost).toFixed(2)*1;
3881 totalmisc += parseFloat(r.data.cobmisc_misc).toFixed(2)*1;
3882 totalfreight += parseFloat(r.data.cobmisc_freight).toFixed(2)*1;
3883 totaltax += parseFloat(r.data.cobmisc_tax).toFixed(2)*1;
3884 total = parseInt(r.data.cobmisc_total_qty);
3889 _this.shipinvtab.layout.getRegion('center').getPanel(0).setTitle(
3891 "Invoices (Complete)" :
3892 ("Invoices prepared for " + done + '/' + total)
3896 var frtotal = (parseFloat(_this.form.findField('cohead_freight').getValue()) - totalfreight).toFixed(2);
3897 var misctotal = (parseFloat(_this.form.findField('cohead_misc').getValue()) - totalmisc).toFixed(2);
3898 var ictotal = (parseFloat(_this.form.findField('cohead_subtotal').getValue()) - totalic).toFixed(2);
3899 var taxtotal = (parseFloat(_this.form.findField('cohead_tax').getValue()) - totaltax).toFixed(2);
3900 var remtotal = frtotal*1 + misctotal*1 + ictotal*1 + taxtotal*1;
3902 var nr = this.reader.newRow({
3904 cobmisc_invchead_id_invchead_invcnumber : "Total Remaining",
3905 cobmisc_qty : total - done,
3906 cobmisc_freight :frtotal,
3907 cobmisc_misc : misctotal,
3908 cobmisc_itemcost : ictotal,
3909 cobmisc_tax : taxtotal,
3910 cobmisc_total : remtotal
3914 // do we need to add it somehow??
3915 _this.invgrid.ds.add(nr);
3919 sortInfo : { field : 'invchead_invcnumber', direction: 'ASC' },
3924 url : baseURL + '/Roo/cobmisc.php'
3927 xtype: 'JsonReader',
3931 totalProperty : 'total',
3934 'name': 'invchead_invcnumber',
3938 'name': 'invchead_invcdate',
3955 var sel = _this.invgrid.getSelectionModel().getSelected();
3957 Roo.MessageBox.alert("Error", "Select a invoice");
3960 // check current status of shipment..
3962 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to Post that invoice?",
3969 url : baseURL + '/Roo/cobmisc',
3972 cobmisc_id : sel.data.cobmisc_id,
3975 success : function() {
3976 _this.invgrid.ds.load({});
3987 cls : 'x-btn-text-icon',
3988 text : "Post Invoice",
3989 icon : rootURL + '/Pman/templates/images/lock.gif'
3994 cls : 'x-btn-text-icon',
3996 icon : rootURL + '/Pman/templates/images/pdf.gif',
4008 var sel = _this.invgrid.getSelectionModel().getSelected();
4010 Roo.MessageBox.alert("Error", "Select a invoice");
4013 if (!sel.data.cobmisc_invchead_id) {
4014 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4017 // check current status of shipment..
4020 url : baseURL + '/Roo/invchead',
4023 invchead_id : sel.data.cobmisc_invchead_id,
4026 success : function() {
4035 text : "Print Standard Invoice"
4041 click : function (_self, e)
4044 var sel = _this.invgrid.getSelectionModel().getSelected();
4046 Roo.MessageBox.alert("Error", "Select a invoice");
4049 if (!sel.data.cobmisc_invchead_id) {
4050 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4053 // check current status of shipment..
4056 url : baseURL + '/Roo/invchead',
4059 invchead_id : sel.data.cobmisc_invchead_id,
4063 success : function() {
4071 text : "Print Chinese Invoice With GST in line item",
4072 hidden : !(baseURL.match(/(hk\.php|cn\.php)$/))
4078 click : function (_self, e)
4081 var sel = _this.invgrid.getSelectionModel().getSelected();
4083 Roo.MessageBox.alert("Error", "Select a invoice");
4086 if (!sel.data.cobmisc_invchead_id) {
4087 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4090 // check current status of shipment..
4093 url : baseURL + '/Roo/invchead',
4096 invchead_id : sel.data.cobmisc_invchead_id,
4100 success : function() {
4108 text : "Print Chinese Invoice",
4109 hidden : !(baseURL.match(/(hk\.php|cn\.php)$/))
4115 click : function (_self, e)
4118 var sel = _this.invgrid.getSelectionModel().getSelected();
4120 Roo.MessageBox.alert("Error", "Select a invoice");
4123 if (!sel.data.cobmisc_invchead_id) {
4124 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4127 // check current status of shipment..
4130 url : baseURL + '/Roo/invchead',
4133 invchead_id : sel.data.cobmisc_invchead_id,
4137 success : function() {
4145 text : "Print Aus - GST included Invoice",
4146 hidden : !(baseURL.match(/au\.php$/))
4152 click : function (_self, e)
4154 var sel = _this.invgrid.getSelectionModel().getSelected();
4156 Roo.MessageBox.alert("Error", "Select a invoice");
4159 if (!sel.data.cobmisc_invchead_id) {
4160 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4163 // check current status of shipment..
4166 url : baseURL + '/Roo/invchead',
4169 invchead_id : sel.data.cobmisc_invchead_id,
4179 text : "Print Bambini Pronto Invoice",
4180 hidden : !(baseURL.match(/au\.php$/))
4186 click : function (_self, e)
4189 var sel = _this.invgrid.getSelectionModel().getSelected();
4191 Roo.MessageBox.alert("Error", "Select a invoice");
4194 if (!sel.data.cobmisc_invchead_id) {
4195 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4198 // check current status of shipment..
4201 url : baseURL + '/Roo/invchead',
4204 invchead_id : sel.data.cobmisc_invchead_id,
4205 _print : 'au-proforma'
4208 success : function() {
4216 text : "Print Bambini Pro Forma Invoice",
4217 hidden : !(baseURL.match(/au\.php$/))
4223 click : function (_self, e)
4225 var sel = _this.invgrid.getSelectionModel().getSelected();
4227 Roo.MessageBox.alert("Error", "Select a invoice");
4231 Pman.Dialog.XtupleDiscountOfInvoice.show({invchead_id : sel.data.cobmisc_invchead_id}, function(){
4236 text : "Print Shipping / Commercial Invoice",
4237 hidden : !( baseURL.match(/au\.php$/))
4245 cls : 'x-btn-text-icon',
4246 text : "Payments / Refunds / Credit Memos",
4247 icon : Roo.rootURL + 'images/default/tree/leaf.gif',
4256 click : function(_self,e)
4259 var sel = _this.invgrid.getSelectionModel().getSelected();
4260 if (!sel || sel.data.cobmisc_id < 1) {
4261 Roo.MessageBox.alert("Error", "Select a invoice");
4264 if(!sel.data.cobmisc_posted){
4265 Roo.MessageBox.alert("Error", "This invoice has not been posted!");
4268 if(sel.data.cobmisc_outstanding == 0){
4269 Roo.MessageBox.alert("Error", "There is no any outstanding of this invoice!");
4273 var cust_id = _this.form.findField('cohead_cust_id').getValue();
4278 cashrcpt_amount : sel.data.cobmisc_outstanding,
4279 cashrcpt_cust_id : cust_id,
4280 cashrcpt_aropen_id : sel.data.cobmisc_aropen_id_aropen_id,
4281 cashrcpt_distdate : new Date(),
4282 cashrcpt_fundstype : 'C',
4283 cashrcpt_curr_id : sel.data.cobmisc_curr_id_curr_id,
4284 cashrcpt_curr_id_curr_name : sel.data.cobmisc_curr_id_curr_name,
4285 cashrcpt_usecustdeposit : true,
4286 cashrcpt_docdate : new Date(),
4287 cashrcpt_salescat_id : -1,
4288 cashrcpt_applydate : new Date(),
4289 cashrcpt_discount : 0
4291 Pman.Dialog.XtupleReceivePayment.show( data , function() {
4292 _this.invgrid.ds.load({});
4296 cls : 'x-btn-text-icon',
4297 text : "Receive Payment",
4298 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4304 click : function(_self,e)
4306 var sel = _this.invgrid.getSelectionModel().getSelected();
4307 if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {
4308 Roo.MessageBox.alert("Error", "Select a credit memo");
4311 if(!sel.data.cobmisc_posted){
4312 Roo.MessageBox.alert("Error", "The invoice that credit memo has been applied to has been not posted");
4315 var cust_id = _this.form.findField('cohead_cust_id').getValue();
4320 if(!sel.data.cobmisc_outstanding || sel.data.cobmisc_outstanding == 0){
4321 Roo.MessageBox.alert("Error", "The amount of this credit memo is 0!");
4325 var d = _this.form.getFieldValues();
4328 'checkhead_recip_id' : cust_id,
4329 'checkhead_recip_type' : 'C',
4330 'checkhead_checkdate' : new Date(),
4331 'checkhead_amount' : sel.data.cobmisc_outstanding,
4332 'remaining_total' : sel.data.cobmisc_outstanding,
4333 'checkhead_curr_id' : d.cohead_curr_id,
4334 'checkhead_curr_id_curr_name' : d.cohead_curr_id_curr_name,
4335 'checkhead_misc' : true,
4336 'aropen_id' : sel.data.cobmisc_cobapply_aropen_id,
4337 'cmhead_number' : sel.data.cobmisc_invchead_id_invchead_invcnumber,
4338 'cust_name' : d.cohead_cust_id_cust_name,
4339 '_create_and_post' : 1
4344 Pman.Dialog.XtupleMiscellaneousCheck.show( data , function() {
4345 _this.invgrid.ds.load({});
4349 cls : 'x-btn-text-icon',
4350 text : "Issue Refund",
4351 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4361 click : function(_self,e)
4363 var sel = _this.invgrid.getSelectionModel().getSelected();
4364 if (!sel || sel.data.cobmisc_cashrcpt_id * 1 < 1) {
4365 Roo.MessageBox.alert("Error", "Select a Receive Payment");
4369 Roo.MessageBox.confirm("Confirm", "Voiding receipt will mean you will have to re-enter the receipt refund - " +
4370 "please take note of the details so you can enter it again correctly later.", function(r) {
4376 url : baseURL + '/Roo/cashrcpt',
4379 cashrcpt_id : sel.data.cobmisc_cashrcpt_id,
4382 success : function()
4384 _this.invgrid.ds.load({});
4394 cls : 'x-btn-text-icon',
4395 text : "Void Payment",
4396 icon : rootURL + '/Pman/templates/images/trash.gif'
4402 click : function(_self,e)
4404 var sel = _this.invgrid.getSelectionModel().getSelected();
4405 if (!sel || sel.data.cobmisc_checkhead_id * 1 < 1) {
4406 Roo.MessageBox.alert("Error", "Select a Miscellaneours Check");
4410 Roo.MessageBox.confirm("Confirm", "Voiding refund will mean you will have to re-enter the receipt refund - " +
4411 "please take note of the details so you can enter it again correctly later.", function(r) {
4417 url : baseURL + '/Roo/checkhead',
4420 checkhead_id : sel.data.cobmisc_checkhead_id,
4423 success : function()
4425 _this.invgrid.ds.load({});
4435 cls : 'x-btn-text-icon',
4436 text : "Void Refund",
4437 icon : rootURL + '/Pman/templates/images/trash.gif'
4443 click : function(_self,e)
4445 var sel = _this.invgrid.getSelectionModel().getSelected();
4446 if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {
4447 Roo.MessageBox.alert("Error", "Select a credit memo");
4451 if(sel.data.cobmisc_posted){
4452 Roo.MessageBox.alert("Error", "You cann't void this credit memo, since the invoice that credit memo has been applied to has been posted");
4456 if (sel.data.cobmisc_cobapply_id < 1) {
4457 Roo.MessageBox.alert("Error", "invaild credit memo");
4460 Roo.MessageBox.confirm("Confirm", "Are you sure want to void this applied credit memo, " +
4461 "it will also void all the check that belongs to this credit memo ", function(r) {
4467 url : baseURL + '/Roo/cobapply',
4470 _delete : sel.data.cobmisc_cobapply_id,
4473 success : function()
4475 _this.invgrid.ds.load({});
4484 cls : 'x-btn-text-icon',
4485 text : "Void Credit Memo",
4486 icon : rootURL + '/Pman/templates/images/trash.gif'
4502 if (!_this.form.findField('cohead_id').getValue()) {
4503 Roo.MessageBox.alert("Error", "Save Order first");
4507 var rv = _this.form.getFieldValues();
4510 Pman.Dialog.XtupleInvoice.show({
4511 cobmisc_cohead_id : rv.cohead_id,
4512 cobmisc_shipdate : _this.form.findField('cohead_targetdate').getValue(),
4513 cobmisc_invcdate : _this.form.findField('cohead_targetdate').getValue(),
4514 cobmisc_curr_id : rv.cohead_curr_id,
4515 cobmisc_curr_id_curr_name : rv.cohead_curr_id_curr_name,
4516 // below parms for add credit memo
4518 cm_cust_id : rv.cohead_cust_id,
4519 cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,
4520 cm_curr_id : rv.cohead_curr_id,
4521 cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,
4522 cm_terms_id : rv.cohead_terms_id,
4523 cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,
4524 cm_salesrep_id : rv.cohead_salesrep_id,
4525 cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,
4526 cm_docdate : new Date(),
4527 cm_taxzone_id : rv.cohead_taxzone_id,
4528 cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,
4529 cm_billto_cntct_id : rv.cohead_billto_cntct_id,
4530 cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,
4531 cm_location_src : rv.cohead_location_src,
4532 cm_location_src_location_name : rv.cohead_location_src_location_name,
4533 cm_billto_address : rv.billto_address
4538 _this.invgrid.ds.load({});
4542 render : function (_self)
4544 _this.addInvoiceBtn = _self;
4547 cls : 'x-btn-text-icon',
4549 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4558 var sel = _this.invgrid.getSelectionModel().getSelected();
4560 Roo.MessageBox.alert("Error", "Select a invoice");
4563 // check current status of shipment..
4566 // cobmisc_id : sel.data.cobmisc_id,
4569 if (sel.data.cobmisc_id * 1) {
4570 params.cobmisc_id = sel.data.cobmisc_id * 1 ;
4572 if (sel.data.cobmisc_invchead_id_invchead_id * 1) {
4573 params.invchead_id = sel.data.cobmisc_invchead_id_invchead_id * 1;
4576 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to VOID that invoice?",
4583 url : baseURL + '/Roo/cobmisc',
4586 success : function() {
4587 _this.invgrid.ds.load({});
4598 cls : 'x-btn-text-icon',
4599 text : "Void / Unpost",
4600 icon : rootURL + '/Pman/templates/images/trash.gif'
4606 xtype: 'ColumnModel',
4608 dataIndex : 'cobmisc_invchead_id_invchead_invcnumber',
4609 header : 'Invoice #',
4611 renderer : function(v,x,r) {
4613 r.data.cobmisc_invchead_id_invchead_id * 1 &&
4614 !r.data.cobmisc_invchead_id_invchead_posted) {
4615 return '<span style="color:red">' +
4616 "NEEDS Voiding then re-posted: " +
4617 String.format('{0}', v) +
4621 if(v && r.data.cobmisc_id == -2){
4622 return String.format('<span style="margin-left: 10px;"> - {0} (Credit Memo)</span>', v);
4624 if(v && r.data.cobmisc_id == -3){
4625 return String.format('<span style="margin-left: 20px;"> - {0} (Miscellaneous Check)</span>', v);
4627 if(v && r.data.cobmisc_id == -4){
4628 return String.format('<span style="margin-left: 10px;"> - {0} (Receive Payment) [ {1} ]</span>', v, r.data.cobmisc_cashrcpt_amount);
4631 return v ? String.format('{0}', v) :
4632 '<span style="color:red">' + "Not Posted" + '</span>';
4636 xtype: 'ColumnModel',
4638 dataIndex : 'cobmisc_invcdate',
4639 header : 'invcdate',
4641 renderer : function(v,x,r) {
4643 return String.format('{0}', v && r.data.cobmisc_id > 0 ? v.format('d/M/Y') : '');
4647 xtype: 'ColumnModel',
4650 dataIndex : 'cobmisc_qty',
4653 renderer : function(v) { return String.format('{0}', v ? parseInt(v) : 0); }
4656 xtype: 'ColumnModel',
4659 dataIndex : 'cobmisc_itemcost',
4660 header : 'Item Cost',
4662 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }
4665 xtype: 'ColumnModel',
4668 dataIndex : 'cobmisc_freight',
4669 header : 'Shipping',
4671 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : ''); }
4674 xtype: 'ColumnModel',
4677 dataIndex : 'cobmisc_tax',
4680 renderer : function(v,x,r) {
4682 // tax is based on the % itemcost..
4683 // var ic = r.data.cobmisc_itemcost;
4685 var ic =r.data.cobmisc_itemcost - (1* r.data.cobmisc_itemcost_taxfree);
4687 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
4688 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
4692 var taxp = tax / totic;
4695 return String.format('{0}', (1.0*v).toFixed(2) );
4701 xtype: 'ColumnModel',
4704 dataIndex : 'cobmisc_cohead_id_cohead_pretax_discount',
4705 header : 'Discount (Pretax)',
4707 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }
4710 xtype: 'ColumnModel',
4713 dataIndex : 'cobmisc_misc',
4714 header : 'Discount (Posttax)',
4716 renderer : function(v,x,r)
4718 var vv = v - r.data.cobmisc_cohead_id_cohead_pretax_discount;
4720 return String.format('{0}', vv ? (1.0*vv).toFixed(2) : 0);
4724 xtype: 'ColumnModel',
4727 dataIndex : 'cobmisc_total',
4730 renderer : function(v,x,r) {
4733 var ic = r.data.cobmisc_itemcost;
4734 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
4735 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
4738 var taxp = tax / totic;
4746 return String.format('{0}',(v * 1.0).toFixed(2) );
4750 return String.format('{0}',
4751 ((d.cobmisc_itemcost * 1.0) +
4752 (d.cobmisc_freight * 1.0) +
4753 (d.cobmisc_tax * 1.0) +
4754 (d.cobmisc_misc * 1.0)
4760 xtype: 'ColumnModel',
4763 dataIndex : 'cobmisc_outstanding',
4764 header : 'Outstanding',
4766 renderer : function(v,x,r)
4769 return String.format('{0}', v ? (v * 1.0).toFixed(2) : 0 );
4777 xtype: 'LayoutRegion',
4782 xtype: 'LayoutRegion',
4785 title : "Reserve Stock / Shipments"
4793 activate : function() {
4794 _this.hpanel = this;
4796 _this.hgrid.footer.onClick('first');
4801 fitContainer : true,
4804 tableName : 'events',
4813 //_this.dialog = Pman.Dialog.FILL_IN
4814 if (_this.hpanel.active) {
4815 this.footer.onClick('first');
4818 rowdblclick : function (_self, rowIndex, e)
4820 if (!_this.dialog) return;
4821 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
4822 _this.grid.footer.onClick('first');
4826 autoExpandColumn : 'remarks',
4832 beforeload : function (_self, options)
4834 options.params._related_on_table = 'cohead';
4835 options.params._related_on_id = _this.form.findField('cohead_id').getValue();
4839 sortInfo : { field : 'event_when', direction: 'DESC' },
4844 url : baseURL + '/Roo/events.php'
4847 xtype: 'JsonReader',
4851 totalProperty : 'total',
4854 'name': 'event_when',
4866 'name': 'person_id_name',
4877 xtype: 'PagingToolbar',
4881 displayMsg : "Displaying events{0} - {1} of {2}",
4882 emptyMsg : "No events found"
4886 xtype: 'ColumnModel',
4888 dataIndex : 'event_when',
4891 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); }
4894 xtype: 'ColumnModel',
4896 dataIndex : 'action',
4899 renderer : function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); }
4902 xtype: 'ColumnModel',
4904 dataIndex : 'ipaddr',
4905 header : 'IP address',
4907 renderer : function(v) { return String.format('{0}', v); }
4910 xtype: 'ColumnModel',
4912 dataIndex : 'person_id_name',
4915 renderer : function(v) { return String.format('{0}', v); }
4918 xtype: 'ColumnModel',
4920 dataIndex : 'remarks',
4923 renderer : function(v) { return String.format('{0}', v); }
4929 xtype: 'NestedLayoutPanel',
4934 xtype: 'BorderLayout',
4941 activate : function() {
4942 _this.txpanel = this;
4944 _this.txgrid.footer.onClick('first');
4949 fitContainer : true,
4952 tableName : 'invdetail',
4953 title : "invdetail",
4960 _this.txgrid = this;
4961 //_this.dialog = Pman.Dialog.FILL_IN
4962 if (_this.txpanel.active) {
4963 this.footer.onClick('first');
4967 autoExpandColumn : 'item_number',
4977 click : function (_self, e)
4981 url : baseURL + '/Roo/Cohead',
4984 _apply_fifo : _this.form.findField('cohead_id').getValue()
4986 success : function () {
4987 Roo.MessageBox.alert("Applied", "Succesfully Applied");
4992 text : "Run Apply Fifo on order"
4998 click : function (_self, e)
5002 url : baseURL + '/Roo/Cohead',
5005 _run_void_fix : _this.form.findField('cohead_id').getValue()
5007 success : function () {
5008 Roo.MessageBox.alert("Applied", "Succesfully Run");
5013 text : "Run Void flagger"
5019 click : function (_self, e)
5024 url : baseURL + '/Roo/Invdetail',
5029 _reverse_all_bad : _this.form.findField('cohead_id').getValue()
5031 success : function () {
5032 Roo.MessageBox.alert("Applied", "Succesfully Run");
5037 text : "Auto Reverse"
5042 xtype: 'RowSelectionModel',
5045 selectionchange : function (_self)
5047 _this.txdgrid.footer.onClick('first');;
5056 beforeload : function (_self, o)
5058 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5059 if (! o.params.cohead_id ) {
5066 sortInfo : { field : 'item_number', direction: 'ASC' },
5071 url : baseURL + '/Roo/invdetail.php'
5074 xtype: 'JsonReader',
5076 totalProperty : 'total',
5081 'name': 'invdetail_id',
5085 'name': 'invdetail_transtype',
5089 'name': 'invdetail_invhist_id',
5093 'name': 'invdetail_location_id',
5097 'name': 'invdetail_qty',
5101 'name': 'invdetail_comments',
5105 'name': 'invdetail_qty_before',
5109 'name': 'invdetail_qty_after',
5113 'name': 'invdetail_invcitem_id',
5117 'name': 'invdetail_expiration',
5119 'dateFormat': 'Y-m-d'
5122 'name': 'invdetail_warrpurc',
5124 'dateFormat': 'Y-m-d'
5127 'name': 'invdetail_ls_id',
5134 xtype: 'PagingToolbar',
5137 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5138 emptyMsg : "No invdetail found",
5143 xtype: 'ColumnModel',
5145 dataIndex : 'item_number',
5148 renderer : function(v) { return String.format('{0}', v); }
5151 xtype: 'ColumnModel',
5154 dataIndex : 'rec_shipped',
5157 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5160 xtype: 'ColumnModel',
5163 dataIndex : 'rec_returned',
5166 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5169 xtype: 'ColumnModel',
5172 dataIndex : 'tx_shipped',
5173 header : '#TX ship',
5175 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5178 xtype: 'ColumnModel',
5181 dataIndex : 'tx_returned',
5184 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5187 xtype: 'ColumnModel',
5190 dataIndex : 'tx_total',
5193 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5196 xtype: 'ColumnModel',
5199 dataIndex : 'total_value',
5202 renderer : function(v,x,r) {
5204 return (v*1).toFixed(3);
5208 xtype: 'ColumnModel',
5211 dataIndex : 'tx_total',
5214 renderer : function(v,x,r) {
5216 var cototal = (r.data.rec_returned*1) - (r.data.rec_shipped*1);
5217 // Roo.log(cototal);
5218 var diff = (v*1) - cototal;
5223 return String.format('<span style="color:red">{0}</span>', diff );
5233 activate : function() {
5234 _this.txdpanel = this;
5235 if (_this.txdgrid) {
5236 _this.txdgrid.footer.onClick('first');
5241 fitContainer : true,
5244 tableName : 'invdetail',
5245 title : "invdetail",
5252 _this.txdgrid = this;
5253 //_this.dialog = Pman.Dialog.FILL_IN
5254 if (_this.txdpanel.active) {
5255 this.footer.onClick('first');
5258 rowclick : function (_self, rowIndex, e)
5260 var s = _this.txdgrid.ds.getAt(rowIndex);
5261 var dt = s.data.invhist_transdate.split(' ');
5263 _this.dateSel.setValue(new Date(dt[0]));
5266 autoExpandColumn : 'invhist_comments',
5276 click : function (_self, e)
5278 var s = _this.txdgrid.selModel.getSelected();
5281 Roo.MessageBox.alert("Error", "Select a transaction");
5285 var reverseSel = function() {
5289 url : baseURL + '/Roo/invdetail',
5292 _duplicate : s.data.invdetail_id
5294 success : function() {
5295 _this.txdgrid.footer.onClick('first');
5303 Roo.MessageBox.confirm(
5305 "This should only be used by System Administrators - are you sure you know what you are doing!",
5319 text : "Duplicate Selected"
5334 render : function (_self)
5336 _this.dateSel = _self;
5340 fieldLabel : 'Issue Date',
5342 name : 'issue_date',
5349 click : function (_self, e)
5351 var s = _this.txdgrid.selModel.getSelected();
5352 var dt = _this.dateSel.getValue();
5354 Roo.MessageBox.alert("Error", "Select a transaction");
5358 var reverseSel = function(force) {
5362 url : baseURL + '/Roo/invdetail',
5365 _reverse : s.data.invdetail_id,
5366 _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
5369 success : function() {
5370 _this.txdgrid.footer.onClick('first');
5372 failure : function(res) {
5375 if (res.errors.confirm) {
5377 Roo.MessageBox.confirm(
5379 "are you really sure the totals will get messed up.",
5390 Roo.MessageBox.alert("Error", res.errorMsg);
5400 Roo.MessageBox.confirm(
5402 "This should only be used by System Administrators - are you sure you know what you are doing!",
5416 text : "Reverse Selected"
5424 beforeload : function (_self, o)
5426 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5427 var s = _this.txgrid.selModel.getSelected();
5432 o.params.itemsite_id = s.data.invhist_itemsite_id;
5437 sortInfo : { field : 'invdetail_id', direction: 'ASC' },
5442 url : baseURL + '/Roo/invdetail.php'
5445 xtype: 'JsonReader',
5447 totalProperty : 'total',
5452 'name': 'invdetail_id',
5456 'name': 'invdetail_transtype',
5460 'name': 'invdetail_invhist_id',
5464 'name': 'invdetail_location_id',
5468 'name': 'invdetail_qty',
5472 'name': 'invdetail_comments',
5476 'name': 'invdetail_qty_before',
5480 'name': 'invdetail_qty_after',
5484 'name': 'invdetail_invcitem_id',
5488 'name': 'invdetail_expiration',
5490 'dateFormat': 'Y-m-d'
5493 'name': 'invdetail_warrpurc',
5495 'dateFormat': 'Y-m-d'
5498 'name': 'invdetail_ls_id',
5505 xtype: 'PagingToolbar',
5508 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5509 emptyMsg : "No invdetail found",
5514 xtype: 'ColumnModel',
5516 dataIndex : 'invdetail_id',
5519 renderer : function(v) { return String.format('{0}', v); }
5522 xtype: 'ColumnModel',
5524 dataIndex : 'invhist_transdate',
5527 renderer : function(v) { return String.format('{0}', v); }
5530 xtype: 'ColumnModel',
5532 dataIndex : 'invhist_ordnumber',
5535 renderer : function(v,x,r) {
5536 if (r.data.invfifo_void *1 != 0) {
5537 return String.format('<s>{0}</s>', v);
5540 return String.format('{0}', v);
5544 xtype: 'ColumnModel',
5546 dataIndex : 'invhist_comments',
5549 renderer : function(v) { return String.format('{0}', v); }
5552 xtype: 'ColumnModel',
5555 dataIndex : 'invdetail_qty',
5556 header : 'Qty Changed',
5558 renderer : function(v,x,r) {
5559 if ( r.data.coitem_shipped != v) {
5560 return String.format('{0} <span style="color:red">({1})</span>',
5561 Roo.util.Format.number(v,0),
5562 r.data.coitem_shipped
5566 return String.format('{0}', Roo.util.Format.number(v,0));
5570 xtype: 'ColumnModel',
5573 dataIndex : 'invhist_value_before',
5574 header : 'Qty Changed',
5576 renderer : function(v,x,r) {
5577 var tot = r.data.invhist_value_after*1 - v*1;
5579 if (r.data.invdetail_qty >0 && tot < 0) {
5580 f = '<span style="color:red">{0}</span>';
5582 if (r.data.invdetail_qty < 0 && tot > 0) {
5583 f = '<span style="color:red">{0}</span>';
5585 return String.format(f, Roo.util.Format.number(tot));
5589 xtype: 'ColumnModel',
5591 dataIndex : 'invhist_posted',
5594 renderer : function(v,x,r) {
5596 var state = v ? '-checked' : '';
5598 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
5606 xtype: 'LayoutRegion',
5610 xtype: 'LayoutRegion',
5618 xtype: 'NestedLayoutPanel',
5623 xtype: 'BorderLayout',
5630 activate : function() {
5631 _this.gltxpanel = this;
5632 if (_this.gltxgrid) {
5633 _this.gltxgrid.footer.onClick('first');
5638 fitContainer : true,
5641 tableName : 'invdetail',
5642 title : "invdetail",
5649 _this.gltxgrid = this;
5650 //_this.dialog = Pman.Dialog.FILL_IN
5651 if (_this.gltxpanel.active) {
5652 this.footer.onClick('first');
5655 cellclick : function (_self, rowIndex, columnIndex, e)
5657 if (columnIndex > 0) {
5660 var rec = this.ds.getAt(rowIndex);
5661 rec.set('gltrans_as_summary', rec.data.gltrans_as_summary *1 ? 0 : 1);
5662 _this.gltxdgrid.footer.onClick('first');
5665 autoExpandColumn : 'gltrans_accnt_id_accnt_descrip',
5668 xtype: 'RowSelectionModel',
5671 selectionchange : function (_self)
5673 _this.gltxdgrid.footer.onClick('first');;
5682 beforeload : function (_self, o)
5684 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5685 if (! o.params.cohead_id ) {
5689 o.params._split_sales = _this.glsalesbtn.pressed ? 1 : 0;
5693 sortInfo : { field : 'item_number', direction: 'ASC' },
5698 url : baseURL + '/Roo/gltrans.php'
5701 xtype: 'JsonReader',
5703 totalProperty : 'total',
5708 'name': 'invdetail_id',
5712 'name': 'invdetail_transtype',
5716 'name': 'invdetail_invhist_id',
5720 'name': 'invdetail_location_id',
5724 'name': 'invdetail_qty',
5728 'name': 'invdetail_comments',
5732 'name': 'invdetail_qty_before',
5736 'name': 'invdetail_qty_after',
5740 'name': 'invdetail_invcitem_id',
5744 'name': 'invdetail_expiration',
5746 'dateFormat': 'Y-m-d'
5749 'name': 'invdetail_warrpurc',
5751 'dateFormat': 'Y-m-d'
5754 'name': 'invdetail_ls_id',
5761 xtype: 'PagingToolbar',
5764 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5765 emptyMsg : "No invdetail found",
5772 render : function (_self)
5774 _this.glsalesbtn = _self;
5776 click : function (_self, e)
5778 (function() { _this.gltxgrid.footer.onClick('first'); }).defer(100);
5781 enableToggle : true,
5783 text : "Split sales"
5789 xtype: 'ColumnModel',
5791 dataIndex : 'gltrans_as_summary',
5794 renderer : function(v,x,r) {
5796 var state = v*1 ? '-checked' : '';
5798 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
5802 xtype: 'ColumnModel',
5804 dataIndex : 'gltrans_accnt_id_accnt_descrip',
5807 renderer : function(v) { return String.format('{0}', v); }
5810 xtype: 'ColumnModel',
5813 dataIndex : 'gltrans_amount_credit',
5816 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
5819 xtype: 'ColumnModel',
5822 dataIndex : 'gltrans_amount_debit',
5825 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
5828 xtype: 'ColumnModel',
5831 dataIndex : 'gltrans_amount_total',
5834 renderer : function(v) { return String.format('<b>{0}</b>', Roo.util.Format.number(v,3)); }
5837 xtype: 'ColumnModel',
5840 dataIndex : 'gltrans_amount_total_unposted',
5841 header : 'Unposted',
5843 renderer : function(v) { return String.format('<span style="color:red">{0}</span>', Roo.util.Format.number(v,3)); }
5852 activate : function() {
5853 _this.gltxdpanel = this;
5854 if (_this.gltxdgrid) {
5855 _this.gltxdgrid.footer.onClick('first');
5860 fitContainer : true,
5863 tableName : 'invdetail',
5864 title : "invdetail",
5871 _this.gltxdgrid = this;
5872 //_this.dialog = Pman.Dialog.FILL_IN
5873 if (_this.gltxdpanel.active) {
5874 this.footer.onClick('first');
5877 cellclick : function (_self, ri, ci, e)
5880 var deleteSel = function() {
5884 url : baseURL + '/Roo/gltrans',
5888 gltrans_id : rec.data.gltrans_id
5891 success : function() {
5892 rec.set('gltrans_posted', false);
5893 rec.set('gltrans_deleted', true);
5894 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
5895 _this.gltxgrid.footer.onClick('first');
5900 var undeleteSel = function() {
5904 url : baseURL + '/Roo/gltrans',
5908 gltrans_id : rec.data.gltrans_id
5911 success : function() {
5912 rec.set('gltrans_posted', true);
5913 rec.set('gltrans_deleted', false);
5914 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
5915 _this.gltxgrid.footer.onClick('first');
5921 var di = this.colModel.config[ci].dataIndex;
5922 if (di != 'gltrans_posted') {
5928 var rec = this.ds.getAt(ri);
5929 if (rec.data.gltrans_deleted) {
5931 Roo.MessageBox.confirm(
5933 "This should only be used by System Administrators - are you sure you know what you are doing!",
5947 if (!rec.data.gltrans_posted) {
5953 url : baseURL + '/Roo/gltrans',
5957 gltrans_id : rec.data.gltrans_id
5959 success : function (res)
5961 rec.set('gltrans_posted', true);
5962 _this.gltxgrid.footer.onClick('first');
5971 // we have a posted transaction.
5972 // only allow recalled to be deleted..
5973 if (!rec.data.gltrans_notes.match(/(Recall|Ship Order)/)) {
5982 Roo.MessageBox.confirm(
5984 "This should only be used by System Administrators - are you sure you know what you are doing!",
5997 autoExpandColumn : 'gltrans_notes',
6003 beforeload : function (_self, o)
6005 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
6006 var s = _this.gltxgrid.selModel.getSelected();
6011 o.params.gltrans_accnt_id = s.data.gltrans_accnt_id;
6012 o.params.gltrans_is_ship = s.data.gltrans_is_ship;
6013 o.params.gltrans_as_summary = s.data.gltrans_as_summary;
6019 sortInfo : { field : 'gltrans_docnumber', direction: 'ASC' },
6024 url : baseURL + '/Roo/gltrans.php'
6027 xtype: 'JsonReader',
6029 totalProperty : 'total',
6034 'name': 'invdetail_id',
6038 'name': 'invdetail_transtype',
6042 'name': 'invdetail_invhist_id',
6046 'name': 'invdetail_location_id',
6050 'name': 'invdetail_qty',
6054 'name': 'invdetail_comments',
6058 'name': 'invdetail_qty_before',
6062 'name': 'invdetail_qty_after',
6066 'name': 'invdetail_invcitem_id',
6070 'name': 'invdetail_expiration',
6072 'dateFormat': 'Y-m-d'
6075 'name': 'invdetail_warrpurc',
6077 'dateFormat': 'Y-m-d'
6080 'name': 'invdetail_ls_id',
6087 xtype: 'PagingToolbar',
6090 displayMsg : "Displaying invdetail{0} - {1} of {2}",
6091 emptyMsg : "No invdetail found",
6098 click : function (_self, e)
6100 new Pman.Download( {
6101 grid : _this.gltxdgrid
6112 xtype: 'ColumnModel',
6114 dataIndex : 'gltrans_id',
6118 renderer : function(v) { return String.format('{0}', v ); }
6121 xtype: 'ColumnModel',
6123 dataIndex : 'gltrans_date',
6126 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
6129 xtype: 'ColumnModel',
6131 dataIndex : 'gltrans_docnumber',
6134 renderer : function(v,x,r) {
6135 if (r.data.gltrans_deleted) {
6136 return String.format('<s>{0}</s>', v);
6138 return String.format('{0}', v);
6142 xtype: 'ColumnModel',
6144 dataIndex : 'gltrans_source',
6147 renderer : function(v) { return String.format('{0}', v); }
6150 xtype: 'ColumnModel',
6152 dataIndex : 'gltrans_notes',
6155 renderer : function(v) { return String.format('{0}', v); }
6158 xtype: 'ColumnModel',
6161 dataIndex : 'gltrans_amount',
6164 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
6167 xtype: 'ColumnModel',
6169 dataIndex : 'gltrans_posted',
6172 renderer : function(v,x,r) {
6174 var state = v ? '-checked' : '';
6176 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
6184 xtype: 'LayoutRegion',
6188 xtype: 'LayoutRegion',
6199 activate : function() {
6200 _this.profitpanel = this;
6202 try { if (MODULE.isBuilder) {
6206 var id = _this.form.findField('cohead_id').getValue() * 1;
6208 Roo.MessageBox.alert("Save First", "Save the order first, before adding items");
6209 _this.dialog.layout.getRegion('center').showPanel(0);
6213 if (_this.profitgrid) {
6214 _this.profitgrid.footer.onClick('first');
6220 fitContainer : true,
6223 tableName : 'coitem',
6231 _this.profitgrid = this;
6232 //_this.dialog = Pman.Dialog.FILL_IN
6233 if (_this.profitpanel.active) {
6234 this.footer.onClick('first');
6238 autoExpandColumn : 'item_number',
6244 beforeload : function (_self,o) {
6251 if (!_this.data || !_this.data.cohead_id) {
6254 o.params = o.params || {};
6256 o.params.coitem_cohead_id = _this.data.cohead_id;
6257 o.params._without_list_discount =1;
6258 o.params._with_profit = 1;
6263 sortInfo : { field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' },
6268 url : baseURL + '/Roo/coitem.php'
6271 xtype: 'JsonReader',
6273 totalProperty : 'total',
6294 'name': 'leader_id',
6298 'name': 'leader_office_id',
6302 'name': 'leader_name',
6306 'name': 'leader_phone',
6310 'name': 'leader_fax',
6314 'name': 'leader_email',
6318 'name': 'leader_company_id',
6322 'name': 'leader_role',
6326 'name': 'leader_active',
6330 'name': 'leader_remarks',
6334 'name': 'leader_passwd',
6338 'name': 'leader_owner_id',
6342 'name': 'leader_lang',
6346 'name': 'leader_no_reset_sent',
6350 'name': 'leader_action_type',
6354 'name': 'leader_project_id',
6358 'name': 'leader_deleted_by',
6362 'name': 'leader_deleted_dt',
6366 'name': 'leader_firstname',
6370 'name': 'leader_lastname',
6374 'name': 'leader_name_facebook',
6378 'name': 'leader_url_blog',
6382 'name': 'leader_url_twitter',
6386 'name': 'leader_url_linkedin',
6390 'name': 'leader_crm_lead_percentage',
6394 'name': 'leader_crm_industry_id',
6398 'name': 'leader_crm_updated_action_id',
6402 'name': 'leader_crm_created_action_id',
6406 'name': 'leader_crm_type_id',
6413 xtype: 'PagingToolbar',
6416 displayMsg : "Displaying coitem{0} - {1} of {2}",
6417 emptyMsg : "No coitem found",
6422 xtype: 'ColumnModel',
6424 dataIndex : 'item_number',
6425 header : 'Item Code',
6427 renderer : function(v) { return String.format('{0}', v); }
6430 xtype: 'ColumnModel',
6432 dataIndex : 'calc_subtotal',
6433 header : 'SubTotal',
6435 renderer : function(v) {
6438 return Roo.util.Format.number( v, 2);
6442 xtype: 'ColumnModel',
6444 dataIndex : 'calc_cost_total',
6445 header : 'Cost of goods',
6447 renderer : function(v) {
6449 return Roo.util.Format.number( v, 2);
6453 xtype: 'ColumnModel',
6455 dataIndex : 'profit',
6458 renderer : function(v,x,r) {
6460 var profit = r.data.calc_subtotal - r.data.calc_cost_total;
6462 if(parseInt(profit) < 1){
6463 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(profit,2));
6467 return Roo.util.Format.number( profit, 2);
6475 xtype: 'LayoutRegion',
6477 alwaysShowTabs : true,
6478 tabPosition : 'top',
6493 var id = 1* _this.form.findField('cohead_id').getValue();
6495 Roo.MessageBox.alert("Error", "Save Sales order first");
6499 // check current status of shipment..
6502 url : baseURL + '/Roo/cohead',
6508 success : function() {
6517 cls : 'x-btn-text-icon',
6518 text : "Download Excel",
6519 icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
6527 var id = 1* _this.form.findField('cohead_id').getValue();
6529 Roo.MessageBox.alert("Error", "Save Sales order first");
6533 // check current status of shipment..
6536 url : baseURL + '/Roo/cohead',
6542 success : function() {
6551 cls : 'x-btn-text-icon',
6553 icon : rootURL + '/Pman/templates/images/pdf.gif'
6559 click : function (_self, e)
6562 _this.addShipmentBtn.fireEvent('click');
6566 cls : 'x-btn-text-icon',
6568 text : "Add Shipment",
6569 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6575 click : function (_self, e)
6578 Pman.Dialog.XtupleCustomer.show({
6579 cust_id : _this.form.findField('cohead_cust_id').getValue()
6583 cls : 'x-btn-text-icon',
6584 text : "Edit Customer",
6585 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6591 click : function (_self, e)
6594 _this.addInvoiceBtn.fireEvent('click');
6598 cls : 'x-btn-text-icon',
6600 text : "Add Invoice",
6601 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6607 render : function (_self, e)
6609 _this.voidBtn = _self;
6611 click : function (_self, e)
6614 cohead_id : _this.form.findField('cohead_id').getValue()
6621 url: baseURL + '/Roo/cohead',
6624 success : function()
6627 if ( _this.data.cohead_status == 'X') {
6628 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
6634 _this.dialog.hide();
6640 if (_this.data.cohead_status == 'X') {
6646 Roo.MessageBox.confirm("Confirm", "Are you sure you want to void this?", function(r) {
6665 click : function (_self, e)
6667 var p = { cohead_id : _this.form.findField('cohead_id').getValue() };
6670 if (_this.data.cohead_status == 'C') {
6678 url: baseURL + '/Roo/cohead',
6682 success : function()
6686 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
6691 _this.dialog.hide();
6696 render : function (_self)
6698 _this.closeBtn = _self;
6711 click : function (_self, e)
6713 if (_this.grid) _this.grid.stopEditing();
6714 _this.dialog.hide();
6723 click : function (_self, e)
6727 if (_this.grid) _this.grid.stopEditing();
6729 _this.form.doAction("submit");
6732 render : function (_self)
6734 _this.saveBtn = _self;