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"));
776 xtype: 'DisplayField',
778 fieldLabel : 'Email',
779 name : 'billto_email'
791 style : 'margin-left:10px',
796 legend : "Price Details",
797 style : 'width:420px',
803 labelAlign : 'right',
811 labelSeparator : ' ',
818 beforequery : function (combo, query, forceAll, cancel, e)
820 Roo.log('beforequery');
822 if (_this.form.findField('cohead_number').getValue().length) {
823 Roo.MessageBox.alert("Error", "You can not change the currency of this order");
832 displayField : 'curr_name',
834 emptyText : "Select curr_name",
835 fieldLabel : 'Currency',
836 forceSelection : true,
837 hiddenName : 'cohead_curr_id',
839 loadingText : "Searching...",
841 name : 'cohead_curr_id_curr_name',
843 qtip : "Select Currency",
844 queryParam : 'query[curr_name]',
845 selectOnFocus : true,
846 tpl : '<div class="x-grid-cell-text x-btn button"><b>{curr_name}</b> </div>',
847 triggerAction : 'all',
849 valueField : 'curr_id',
855 beforeload : function (_self, o){
856 o.params = o.params || {};
862 sortInfo : { direction : 'ASC', field: 'curr_symbol' },
867 url : baseURL + '/Roo/curr_symbol.php'
874 totalProperty : 'total',
875 fields : [{"name":"curr_id","type":"int"},"curr_symbol"]
880 xtype: 'NumberField',
882 allowDecimals : true,
883 cls : 'roo-align-right',
884 decimalPrecision : 3,
885 fieldLabel : 'Products',
886 name : 'cohead_subtotal',
896 labelSeparator : ' ',
903 select : function (combo, record, index)
905 _this.form.findField('cohead_tax').setValue(
906 parseFloat(record.data.taxzone_rate) *
907 parseFloat(_this.form.findField('cohead_subtotal').getValue())
909 _this.form.findField('cohead_total').recalc();
913 displayField : 'taxzone_descrip',
915 emptyText : "Select taxtype",
916 fieldLabel : 'Tax Zone',
917 forceSelection : true,
918 hiddenName : 'cohead_taxzone_id',
920 loadingText : "Searching...",
922 name : 'cohead_taxzone_id_taxzone_descrip',
924 qtip : "Select taxtype",
925 queryParam : 'query[taxzone_descrip]',
926 selectOnFocus : true,
927 tpl : '<div class="x-grid-cell-text x-btn button"><b>{taxzone_descrip}</b> </div>',
928 triggerAction : 'all',
930 valueField : 'taxzone_id',
936 beforeload : function (_self, o){
937 o.params = o.params || {};
940 o.params.with_date = _this.form.findField('cohead_orderdate').getValue().format('Y-m-d');
941 Roo.log("with date?" + o.params.with_date);
947 sortInfo : { direction : 'ASC', field: 'taxzone_descrip' },
952 url : baseURL + '/Roo/taxzone.php'
959 totalProperty : 'total',
960 fields : [{"name":"taxzone_id","type":"int"},"taxzone_descrip"]
965 xtype: 'NumberField',
967 allowDecimals : true,
968 cls : 'roo-align-right',
969 decimalPrecision : 3,
978 xtype: 'NumberField',
980 allowDecimals : true,
981 cls : 'roo-align-right',
982 decimalPrecision : 3,
983 fieldLabel : 'Pre Tax discount',
984 name : 'cohead_pretax_discount',
992 labelSeparator : ' ',
998 fieldLabel : 'Discount after Tax Description',
999 name : 'cohead_misc_descrip',
1003 xtype: 'NumberField',
1006 keyup : function (_self, e)
1008 var pv = parseFloat(_this.form.findField('cohead_subtotal').getValue());
1009 var tax = parseFloat(_this.form.findField('cohead_tax').getValue());
1010 var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());
1012 var n = this.getValue();
1013 var discount = parseFloat(n * (pv + tax + pd) * 0.01);
1015 _this.form.findField('cohead_posttax_discount').setValue(discount);
1017 _this.form.findField('cohead_total').recalc();
1018 _this.form.findField('cohead_misc').recalc();
1019 var val = discount * -1.0;
1021 _this.form.findField('cohead_misc_descrip').setValue("Discount of " + val.toFixed(1)+'%');
1027 allowDecimals : true,
1028 cls : 'roo-align-right',
1029 decimalPrecision : 1,
1031 name : 'cohead_misc_per',
1033 update : function() {
1034 var m = _this.form.findField('cohead_misc_per');
1035 var pv = parseFloat(_this.form.findField('cohead_subtotal').getValue());
1036 var tax = parseFloat(_this.form.findField('cohead_tax').getValue());
1037 var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());
1039 var discount = parseFloat(_this.form.findField('cohead_posttax_discount').getValue());
1041 if (discount > 0.0) {
1049 var val = ((discount) / (pv + tax + pd)) * -100;
1051 //Roo.log("update discount?" + val);
1052 this.setValue(val.toFixed(1));
1055 _this.form.findField('cohead_misc_descrip').setValue("Discount of " + val.toFixed(1)+'%');
1063 xtype: 'NumberField',
1066 keyup : function (_self, e)
1068 _this.form.findField('cohead_misc_per').update();
1069 _this.form.findField('cohead_total').recalc();
1070 _this.form.findField('cohead_misc').recalc();
1073 allowDecimals : true,
1074 cls : 'roo-align-right',
1075 decimalPrecision : 3,
1076 fieldLabel : ' ',
1077 name : 'cohead_posttax_discount',
1083 xtype: 'NumberField',
1085 allowDecimals : true,
1086 cls : 'roo-align-right',
1087 decimalPrecision : 3,
1088 fieldLabel : 'Total',
1089 name : 'cohead_total',
1092 recalc : function() {
1093 var d = _this.form.getValues();
1095 parseFloat(d.cohead_subtotal) +
1096 parseFloat(d.cohead_pretax_discount) +
1097 parseFloat(d.cohead_posttax_discount) +
1098 parseFloat(d.cohead_tax) +
1099 parseFloat(d.cohead_freight));
1103 xtype: 'NumberField',
1106 keyup : function (_self, e)
1108 _this.form.findField('cohead_total').recalc();
1111 allowDecimals : true,
1112 cls : 'roo-align-right',
1113 decimalPrecision : 3,
1114 fieldLabel : 'Shipping',
1115 name : 'cohead_freight',
1119 xtype: 'NumberField',
1121 allowDecimals : true,
1122 cls : 'roo-align-right',
1123 decimalPrecision : 3,
1124 fieldLabel : 'Unshipped Total',
1125 name : 'cohead_unshipped',
1130 xtype: 'NumberField',
1132 allowDecimals : true,
1133 cls : 'roo-align-right',
1134 decimalPrecision : 3,
1135 fieldLabel : 'Uninvoiced Total',
1136 name : 'cohead_uninvoiced',
1147 style : 'width:420px',
1148 legend : "Shipping",
1159 labelSeparator : ' ',
1165 check : function (_self, checked)
1171 if (_this.dataloading) {
1179 // copy the cohead_billto_cntct_id
1180 for (var i in _this.data) {
1181 if (!i.match(/^cohead_billto_cntct_id/)) {
1184 var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');
1185 _this.data[ni] = _this.data[i];
1187 _this.form.findField('shipto_address').update();
1188 _this.form.setValues( {
1189 cohead_shipto_cntct_id : _this.data.cohead_shipto_cntct_id,
1190 cohead_shipto_cntct_id_cntct_name : _this.data.cohead_shipto_cntct_id_cntct_first_name + ' ' +
1191 _this.data.cohead_shipto_cntct_id_cntct_last_name
1198 for (var i in _this.data) {
1199 if (!i.match(/^cohead_billto_cntct_id/)) {
1202 var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');
1204 _this.data[ni] = '';
1206 _this.form.findField('shipto_address').update();
1208 _this.form.setValues( {
1209 cohead_shipto_cntct_id : '',
1210 cohead_shipto_cntct_id_cntct_name : ''
1218 boxLabel : 'Same as Billing',
1219 name : '_shipto_same'
1227 add : function (combo)
1229 Pman.Dialog.XtupleQuickContact.show(
1232 customer_id : _this.form.findField('cohead_cust_id').getValue()
1237 for(var i in data) {
1239 _this.data['cohead_shipto_cntct_id_' + i] = data[i];
1242 _this.form.findField('shipto_address').update();
1243 // fill in the select box..
1244 _this.form.setValues( {
1245 cohead_shipto_cntct_id : data.cntct_id,
1246 cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1247 data.cntct_last_name
1253 beforeselect : function (combo, record, index)
1256 // just add everything...
1257 for(var i in record.data) {
1258 //Roo.log('cohead_shipto_cntct_id_' + i +' =' + record.data[i]);
1259 _this.data['cohead_shipto_cntct_id_' + i] = record.data[i];
1262 _this.form.findField('shipto_address').update();
1269 displayField : 'cntct_name',
1271 emptyText : "Select ship to",
1272 fieldLabel : 'Ship to',
1273 forceSelection : true,
1274 hiddenName : 'cohead_shipto_cntct_id',
1276 loadingText : "Searching...",
1278 name : 'cohead_shipto_cntct_id_cntct_name',
1280 qtip : "Select shiptoinfo",
1281 queryParam : 'query[cntct_name]',
1282 selectOnFocus : true,
1283 tpl : '<div class="x-grid-cell-text x-btn button">{cntct_name} - <b>{cntct_addr_id_addr_line1}</b> </div>',
1284 triggerAction : 'all',
1286 valueField : 'cntct_id',
1292 beforeload : function (_self, o){
1293 o.params = o.params || {};
1295 o.params._customer_id = _this.data.cohead_cust_id;
1299 sortInfo : { direction : 'ASC', field: 'cntct_name' },
1304 url : baseURL + '/Roo/cntct.php'
1307 xtype: 'JsonReader',
1311 totalProperty : 'total',
1312 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
1320 render : function (_self)
1326 this.el.on('click', function() {
1327 var id = _this.form.findField('cohead_shipto_cntct_id').getValue();
1328 Pman.Dialog.XtupleQuickContact.show(
1331 customer_id : _this.form.findField('cohead_cust_id').getValue()
1336 for(var i in data) {
1338 _this.data['cohead_shipto_cntct_id_' + i] = data[i];
1341 _this.form.findField('shipto_address').update();
1342 // fill in the select box..
1343 _this.form.setValues( {
1344 cohead_shipto_cntct_id : data.cntct_id,
1345 cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1346 data.cntct_last_name
1355 // Roo.log("Click text");
1361 fieldLabel : 'Address',
1362 name : 'shipto_address',
1365 update : function() {
1367 var c = ['first_name', 'last_name' ] ;
1368 var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];
1370 Roo.each(c, function(e) {
1371 if (_this.data['cohead_shipto_cntct_id_cntct_' +e] &&
1372 _this.data['cohead_shipto_cntct_id_cntct_' +e].length) {
1373 v.push(_this.data['cohead_shipto_cntct_id_cntct_' +e]);
1376 Roo.each(a, function(e) {
1377 if (_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e] &&
1378 _this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e].length) {
1379 v.push(_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e]);
1383 this.setValue(v.join("\n"));
1389 fieldLabel : 'Shipment Comments',
1390 name : 'cohead_shipcomments',
1407 name : 'cohead_shipto_id'
1412 name : 'cohead_shipto_id_shipto_name'
1417 name : 'cohead_max_linenumber'
1422 name : 'cohead_cust_id'
1427 name : 'cohead_misc',
1428 recalc : function() {
1429 var d = _this.form.getValues();
1431 parseFloat(d.cohead_pretax_discount) +
1432 parseFloat(d.cohead_posttax_discount) );
1438 name : 'taxzone_rate'
1448 activate : function() {
1451 try { if (MODULE.isBuilder) {
1455 var id = _this.form.findField('cohead_id').getValue() * 1;
1457 Roo.MessageBox.alert("Save First", "Save the order first, before adding items");
1458 _this.dialog.layout.getRegion('center').showPanel(0);
1463 _this.grid.footer.onClick('first');
1465 //if (_this.form.findField('cohead_cust_id_cust_name').getValue() == 'Bloom and Grow HK') {
1466 // _this.xferAll.show();
1469 // _this.xferAll.hide();
1474 deactivate : function (_self)
1477 _this.grid.stopEditing();
1482 fitContainer : true,
1485 tableName : 'coitem',
1486 title : "Order Items",
1488 xtype: 'EditorGrid',
1494 //_this.dialog = Pman.Dialog.FILL_IN
1496 if (_this.panel.active) {
1497 this.footer.onClick('first');
1500 afteredit : function (e)
1502 Roo.log('afteredit:' + e.record.data.coitem_linenumber);
1505 // if ( e.record && e.record.data.coitem_id) {
1506 // as we disable update to the display on the ajax callback to
1507 // allow editing flow to continue, and not refresh - we can only update
1508 // these values after something has actually been edited.
1509 // e.record.set('coitem_id', e.record.data.coitem_id);
1510 // e.record.set('coitem_status', e.record.data.coitem_status);
1513 if (e.field == 'item_number' || e.originalValue == e.value) {
1514 // afterselect handles this...
1517 if (e.field == 'item_descrip1') {
1518 e.record.set('coitem_memo', e.value);
1520 var rate = _this.form.findField('taxzone_rate').getValue();
1522 case 'coitem_linedisc':
1524 var cp = parseFloat(e.record.data.coitem_custprice);
1526 if (isNaN(cp) || cp == 0.0) {
1530 var dis = parseFloat(e.value);
1538 Math.max(0,cp * ((100.0 - parseInt(e.value))/ 100.0) )
1541 // donot need to set the subtotal here, coz we will render it automatically
1543 // 'coitem_subtotal',
1544 // e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord
1548 case 'coitem_price': // SELL@ price
1550 var cp = parseFloat(e.record.data.coitem_custprice);
1551 // list price is < price -- update it..
1552 if (isNaN(cp) || cp == 0.0 || cp < e.value) {
1553 e.record.set('coitem_custprice', e.value);
1556 // update the discount calc.
1558 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( e.value / cp) * 100.0)));
1560 // donot need to set the subtotal here, coz we will render it automatically
1562 // 'coitem_subtotal',
1563 // e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord
1567 case 'coitem_custprice':
1568 // modified customer price...
1569 // just modify the discount.. -- leave the entered price the same..
1570 var sp = parseFloat(e.record.data.coitem_price);
1571 var cp = parseFloat(e.value);
1572 if (isNaN(cp) || cp == 0.0 || cp < e.value) {
1576 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1580 case 'coitem_custprice_tax':
1581 var cp = parseFloat(e.value / ( 1 + rate * 1 ));
1582 var sp = parseFloat(e.record.data.coitem_price);
1584 if (isNaN(cp) || cp == 0.0) {
1587 e.record.set('coitem_custprice', cp);
1588 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1592 case 'coitem_price_tax':
1594 var cp = parseFloat(e.record.data.coitem_custprice);
1595 var sp = parseFloat(e.value / ( 1 + rate * 1 ));
1596 if (isNaN(cp) || cp == 0.0 || cp < sp) {
1597 e.record.set('coitem_custprice', sp);
1600 e.record.set('coitem_price', sp);
1601 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1610 var doupdate = function() {
1611 if (!e.record.updatePending) {
1612 Roo.log('doupdate...' + e.record.data.coitem_linenumber);
1617 Roo.log('doupdate pending...' + e.record.data.coitem_linenumber);
1618 // wait until it's not peding an update..
1619 doupdate.defer(500);
1622 if(e.record.data.coitem_id * 1 < 1 && !e.record.isInserting){ // insert
1623 e.record.isInserting = 1;
1624 e.record.isUpdating = 0;
1630 if(!e.record.isInserting && !e.record.isUpdating){
1631 e.record.isUpdating = 1;
1636 if(!e.record.updatePending){
1637 e.record.updatePending = 1;
1641 Roo.log("got to end without doing an update?" + e.record.data.coitem_linenumber);
1644 beforeedit : function (e)
1646 // we can only edit if nothing is assigned to shipping or invoices..
1650 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0 || (rec.data.shipitem_shipped - rec.data.coitem_qtyshipped) > 0 ) {
1651 Roo.MessageBox.alert("Error", "That item has been shipped, has a draft shipment or invoices - void the shipments/invoices first");
1656 if (rec.data.coitem_subnumber * 1 > 0) {
1657 Roo.log("Edit container event");
1658 Roo.log(e); // if it's a tab..
1662 // allow editing of source / destination..
1663 case 'coitem_shipto_id':
1664 case 'coitem_location_src':
1669 Roo.MessageBox.alert("Error", "That is a kit item, edit the container.");
1673 // zero off values..
1674 //if (e.field == 'coitem_qtyord' && rec.data.coitem_qtyord == 0) {
1677 // if (e.field == 'coitem_custprice' && rec.data.coitem_qtyord == 0.0) {
1681 if (rec.data.item_type == 'K' && e.field == 'item_number') {
1682 // you can not change the product type on kits' as it messing things up..
1683 Roo.MessageBox.alert("Error", "That is a kit item,if you need to change it, delete it first.");
1689 celldblclick : function (_self, rowIndex, columnIndex, e)
1691 var rec = this.ds.getAt(rowIndex);
1692 var di = this.cm.getDataIndex(columnIndex);
1693 if (di != 'avail_qty') {
1697 Pman.Dialog.XtupleInvHistory.show({
1698 itemsite_item_id_item_number : rec.data.item_number,
1699 // itemsite_item_id_item_descript1 : rec.data.item_descrip1,
1700 location_name : rec.data.coitem_location_src_location_name,
1701 location_descrip : rec.data.coitem_location_src_location_descrip,
1703 invhist_transdate : _this.form.findField('cohead_targetdate').getValue()
1707 rowclass : function (gridview, rowcfg)
1709 if (rowcfg.record.data.coitem_status == 'C' &&
1710 rowcfg.record.data.shipitem_shipped * 1 < 1) {
1712 rowcfg.rowClass = 'strikethrough';
1714 if (rowcfg.record.data.coitem_status == 'X' ) {
1716 rowcfg.rowClass = 'strikethrough';
1719 if (!rowcfg.record.data.coitem_id) {
1720 rowcfg.rowClass = 'dragon-not-saved';
1728 autoExpandColumn : 'item_descrip1',
1731 loadAvail : function() {
1734 this.ds.each(function(r) {
1736 if(!r.data.item_number.length){
1740 if(typeof(_this.stockcache[r.data.item_number]) != 'undefined'){
1742 r.set('avail_qty', _this.stockcache[r.data.item_number].qty);
1743 if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {
1744 r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);
1752 item : r.data.item_number,
1753 loc: r.data.coitem_location_src_location_name,
1754 id: r.data.coitem_linenumber + (r.data.coitem_subnumber ? ('.' + r.data.coitem_subnumber) : '')
1758 url : baseURL + '/Roo/itemloc',
1761 _availqty : Roo.encode(q),
1762 curr_name : _this.form.findField('cohead_curr_id').el.dom.value
1764 success : function(res)
1766 for (var i in res.data) {
1767 _this.stockcache[res.data[i].item] = res.data[i];
1769 r.set('avail_qty', _this.stockcache[r.data.item_number].qty);
1770 if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {
1771 r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);
1773 //_this.grid.ds.fireEvent("update", _this.grid.ds, r, Roo.data.Record.EDIT);
1782 xtype: 'CellSelectionModel',
1785 tabend : function (_self)
1787 _this.addItemBtn.fireEvent('click', _this.addItemBtn);
1789 beforeeditnext : function (eventdata)
1793 // this does not work, as the reload effect cancels editng.
1794 var rec = _this.grid.ds.getAt(eventdata.cell[0]);
1795 if (rec.data.coitem_subnumber *1 < 0 ) {
1798 var r = eventdata.cell[0] + 1;
1801 if (r > _this.grid.ds.getCount()-1 ) {
1802 eventdata.cell = false;
1805 rec = _this.grid.ds.getAt(r);
1806 if (rec.data.coitem_subnumber *1 < 0 ) {
1807 eventdata.cell = [ r, eventdata.cell[1] ];
1821 xtype: 'PagingToolbar',
1824 emptyMsg : "No Items",
1826 updateSummary : function() {
1829 url : baseURL + '/Roo/Coitem',
1833 coitem_cohead_id : _this.form.findField('cohead_id').getValue()
1835 success : function(d) {
1837 f.displayEl.update(String.format(
1838 "{0} items | Subtotal: {2} | Tax: {3} | List Discount {4} | Total : {1}{5}",
1840 _this.form.findField('cohead_curr_id').el.dom.value,
1843 d.data.total_list_discount,
1855 click : function (_self, e)
1858 url : baseURL + '/Roo/Cohead',
1861 _fill_shipto : _this.form.findField('cohead_id').getValue()
1863 success : function() {
1864 _this.grid.footer.onClick('first');
1869 text : "Fill empty Ship To"
1875 click : function (_self, e)
1877 Roo.MessageBox.confirm("Confirm", "Are you sure?<BR>"+
1878 "This will set all the locations to match the Sales Order - and remove all old locations.",
1885 url : baseURL + '/Roo/Cohead',
1888 _fill_location : _this.form.findField('cohead_id').getValue(),
1889 _location_id : _this.form.findField('cohead_location_src').getValue()
1891 success : function() {
1892 _this.grid.footer.onClick('first');
1899 text : "Update Location to match S/O"
1905 toggle : function (_self, pressed)
1907 this.setText(pressed ? "Prices exc GST" : "Prices with GST");
1908 var cm = _this.grid.getColumnModel();
1910 cm.setHidden(cm.getIndexByDataIndex('coitem_price_tax'), pressed ? false : true);
1911 cm.setHidden(cm.getIndexByDataIndex('coitem_custprice_tax'), pressed ? false : true);
1912 cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal_tax'), pressed ? false : true);
1914 cm.setHidden(cm.getIndexByDataIndex('coitem_price'), pressed ? true : false);
1915 cm.setHidden(cm.getIndexByDataIndex('coitem_custprice'), pressed ? true : false);
1916 cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal'), pressed ? true : false);
1919 render : function (_self)
1921 _this.showgstBtn = _self;
1924 enableToggle : true,
1926 text : "Prices with GST"
1934 beforeload : function (_self,o) {
1941 if (!_this.data || !_this.data.cohead_id) {
1944 o.params = o.params || {};
1946 o.params.coitem_cohead_id = _this.data.cohead_id;
1947 o.params._without_list_discount =1;
1948 //o.params.limit = 999;
1952 update : function (_self, rec, operation)
1955 if (operation != Roo.data.Record.COMMIT) {
1959 // row has been updated..
1960 // if the qty + item has been filled in, we should try and save it..
1963 var setRecord = function(){
1965 Roo.log("Clearing update?" + rec.data.coitem_linenumber);
1966 rec.updatePending = 0;
1967 if(rec.isInserting){
1968 rec.isInserting = 0;
1974 if (!(rec.data.coitem_itemsite_id * 1) || !(rec.data.coitem_qtyord*1)) {
1978 var doCommit = function() {
1979 Roo.log("Sending data?" + rec.data.coitem_linenumber);
1982 url : baseURL+'/Roo/coitem',
1985 success: function(res)
1988 var row = _this.grid.ds.indexOf(rec);
1989 Roo.get(_this.grid.view.getRow(row)).removeClass('dragon-not-saved');
1995 Roo.log("GOT success: " + rec.data.coitem_linenumber);
1996 //Roo.log("GOT success");
1997 // update the data...
1999 if (rec.data.item_type == 'K') {
2001 _this.grid.ds.load({});
2006 // why is this here.??
2008 if (_this.grid.activeEditor) {
2014 rec.set('coitem_id', res.data.coitem_id);
2015 rec.set('coitem_status', res.data.coitem_status);
2019 delete rec.modified;
2021 _this.grid.footer.updateSummary();
2022 _this.grid.loadAvail();
2028 failure : function(res)
2031 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error updating");
2044 load : function (_self, records, options)
2046 // need to fetch availablity from master data..
2047 // build a list of what to ask..
2049 // query: ITEM CODE - LOCATION
2050 _this.grid.footer.updateSummary();
2051 _this.grid.loadAvail.defer(100, _this.grid);
2059 sortInfo : { field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' },
2064 url : baseURL + '/Roo/coitem.php'
2067 xtype: 'JsonReader',
2071 totalProperty : 'total',
2074 'name': 'coitem_linenumber',
2078 'name': 'coitem_itemsite_id',
2082 'name': 'coitem_qtyord'
2085 'name': 'coitem_unitcost'
2088 'name': 'coitem_price'
2091 'name': 'coitem_custprice'
2094 'name': 'coitem_qtyreturned'
2097 'name': 'coitem_prcost'
2100 'name': 'coitem_price_uom_id',
2104 'name': 'coitem_qtyreserved'
2120 Roo.log("add presed");
2123 var grid = _this.grid;
2125 grid.ds.each(function(r) {
2126 if (r.data.coitem_qtyord < 1) {
2127 Roo.MessageBox.alert("Error", "you must fill in a quantity for " + r.data.item_number);
2139 var last = _this.form.findField('cohead_max_linenumber').getValue();
2146 _this.form.findField('cohead_max_linenumber').setValue(last);
2148 // this should be getting the previous row..??
2149 var ct = _this.grid.ds.getCount();
2150 var lastrow = ct ? _this.grid.ds.getAt(ct-1) : false;
2152 function lastor(k,d,kk) {
2153 var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();
2154 return lastrow ? lastrow.data[kk] : def;
2157 // uses form defaults or last row value.
2158 var nr = _this.grid.ds.reader.newRow({
2159 coitem_linenumber : last,
2163 coitem_cohead_id : _this.form.findField('cohead_id').getValue(),
2164 coitem_qtyshipped : 0,
2165 coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),
2166 coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),
2167 coitem_shipto_id : lastor('cohead_shipto_id',false, 'coitem_shipto_id'),
2168 coitem_shipto_id_shipto_name : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name'),
2169 coitem_unitcost_in_order_cur : 0,
2170 coitem_taxtype_id : _this.data.default_taxtype_id,
2171 coitem_taxtype_id_taxtype_name : 'Taxable',
2177 grid.ds.insert(grid.ds.getCount(), nr);
2178 grid.startEditing(grid.ds.getCount()-1, 1); // type..
2179 nr.updatePending = 0;
2184 render : function (_self)
2186 _this.addItemBtn = _self;
2189 cls : 'x-btn-text-icon',
2191 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
2197 click : function (_self, e)
2199 var last = _this.form.findField('cohead_max_linenumber').getValue();
\r
2201 _this.form.findField('cohead_max_linenumber').setValue(last);
2203 var ct = _this.grid.ds.getCount();
\r
2204 var lastrow = ct ? _this.grid.ds.getAt(ct-1) : false;
\r
2206 function lastor(k,d,kk) {
\r
2207 var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();
\r
2208 return lastrow ? lastrow.data[kk] : def;
\r
2211 var cohead_cust_id = _this.form.findField('cohead_cust_id').getValue();
2212 var cohead_id = _this.form.findField('cohead_id').getValue();
2214 Pman.Dialog.XtupleSalesProductList.show( {cohead_cust_id : cohead_cust_id, cohead_id : cohead_id} , function(res) {
2216 _this.grid.stopEditing();
2218 if (_this.grid.ds.getCount() > 0) {
2219 var lr = _this.grid.ds.getAt(_this.grid.ds.getCount()-1);
2220 if (!lr.data.coitem_itemsite_id) {
2221 lr.set('coitem_itemsite_id', res.item_itemsite_id_itemsite_id);
2222 lr.set('item_number', res.item_number);
2223 lr.set('item_descrip1', res.item_descrip1);
2224 lr.set('coitem_listprice', res.item_price);
2225 lr.set('coitem_price', res.item_price);
2226 lr.set('coitem_custprice', res.item_price);
2233 var nr = _this.grid.ds.reader.newRow({
2234 coitem_linenumber : last,
2235 coitem_itemsite_id : res.item_itemsite_id_itemsite_id,
2236 item_number : res.item_number,
2237 item_descrip1 : res.item_descrip1,
2239 coitem_cohead_id : _this.form.findField('cohead_id').getValue(),
2240 coitem_qtyshipped : 0,
2241 coitem_listprice : res.item_price,
2242 coitem_price : res.item_price,
2243 coitem_custprice : res.item_price,
2245 coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),
2246 coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),
2247 coitem_shipto_id : lastor('cohead_shipto_id',false, 'coitem_shipto_id'),
2248 coitem_shipto_id_shipto_name : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name')
2251 _this.grid.ds.insert(_this.grid.ds.getCount(), nr);
2256 cls : 'x-btn-text-icon',
2257 text : "Find Products",
2258 icon : rootURL + '/Pman/templates/images/search.gif'
2268 url : baseURL + '/Roo/coitem',
2269 mask : 'Loading Data',
2273 _hk_xfer :_this.form.findField('cohead_id').getValue()
2275 success : function() {
2276 _this.grid.ds.load({});
2281 render : function (_self)
2283 _this.xferAll = _self;
2286 cls : 'x-btn-text-icon',
2288 text : "Xfer all stock to HK",
2289 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
2295 click : function (_self, e)
2297 var c = _this.grid.getSelectionModel().getSelectedCell();
2299 Roo.MessageBox.alert("Error", "Select item to show history (you can also double click on the #avail number) ");
2303 var rec = _this.grid.ds.getAt(c[0]);
2305 Pman.Dialog.XtupleInvHistory.show({
2306 itemsite_item_id_item_number : rec.data.item_number,
2307 // itemsite_item_id_item_descript1 : rec.data.item_descrip1,
2308 location_name : rec.data.coitem_location_src_location_name,
2309 location_descrip : rec.data.coitem_location_src_location_descrip,
2312 invhist_transdate : _this.form.findField('cohead_targetdate').getValue()
2318 text : "Show Inventory History"
2327 text : "Apply % Discount of : "
2333 render : function (_self)
2335 _this._applyDiscount = _self;
2344 click : function (_self, e)
2346 var val = parseFloat(_this._applyDiscount.getValue());
2348 var factor = (100.0 - val)/100.0;
2350 _this.grid.ds.each(function(rec) {
2351 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2355 rec.set('coitem_price', rec.data.coitem_custprice * factor);
2356 rec.set('coitem_linedisc', val);
2357 rec.set('coitem_subtotal', rec.data.coitem_price & rec.data.ordqty);
2365 text : "Apply To All"
2371 click : function (_self, e)
2374 if (!(1* _this.form.findField('cohead_id').getValue())) {
2375 Roo.MessageBox.alert("Error", "save the order first");
2379 Pman.Dialog.Image.show(
2382 _url : baseURL+'/Xtuple/Import/SalesOrder',
2383 onid : _this.form.findField('cohead_id').getValue()
2388 Roo.MessageBox.alert("Notice", "Uploaded");
2389 _this.grid.footer.onClick('first');
2407 _this.grid.stopEditing();
2408 // check that no shipments or invoices are done..
2409 var rc = _this.grid.getSelectionModel().getSelectedCell();
2411 var rec = _this.grid.ds.getAt(rc[0]);
2413 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2414 Roo.MessageBox.alert("Error", "That item has been shipped or invoices - void the shipments/invoices first");
2417 if (rec.data.coitem_subnumber*1 > 0) {
2418 Roo.MessageBox.alert("Error", "Delete the kit item that that belongs to.");
2421 if (!rec.data.coitem_id) {
2422 _this.grid.ds.remove(rec);
2429 url : baseURL + '/Roo/coitem',
2432 _delete : rec.data.coitem_id
2435 success : function() {
2436 if (rec.data.item_type == 'K') {
2437 _this.grid.ds.load({});
2440 _this.grid.ds.remove(rec);
2445 if (rec.data_qtyord * 1 < 1) {
2449 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that line?", function(r)
2462 cls : 'x-btn-text-icon',
2464 icon : rootURL + '/Pman/templates/images/trash.gif'
2472 _this.grid.stopEditing();
2473 // check that no shipments or invoices are done..
2475 _this.grid.ds.each(function(rec) {
2479 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2480 //Roo.MessageBox.alert("Error", "That item has been shipped or invoices - void the shipments/invoices first");
2483 if (rec.data.item_type == 'K') {
2487 if (rec.data.coitem_subnumber*1 > 0) {
2488 //Roo.MessageBox.alert("Error", "Delete the kit item that that belongs to.");
2491 if (!rec.data.coitem_id) {
2492 _this.grid.ds.remove(rec);
2495 ids.push(rec.data.coitem_id);
2501 url : baseURL + '/Roo/coitem',
2504 _delete : ids.join(',')
2507 success : function() {
2509 _this.grid.footer.onClick('first');
2514 // if (rec.data_qtyord * 1 < 1) {
2518 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete everything?", function(r)
2531 cls : 'x-btn-text-icon',
2532 text : "Delete All",
2533 icon : rootURL + '/Pman/templates/images/trash.gif'
2539 xtype: 'ColumnModel',
2541 dataIndex : 'coitem_linenumber',
2544 renderer : function(v,x,r) {
2546 if (r.data.coitem_subnumber * 1 > 0) {
2547 return String.format('{0}.{1}', v,r.data.coitem_subnumber);
2549 return String.format('{0}', v);
2553 xtype: 'ColumnModel',
2555 dataIndex : 'item_number',
2556 header : 'Item Code',
2558 renderer : function(v) { return String.format('{0}', v); },
2560 xtype: 'GridEditor',
2566 beforeselect : function (combo, record, index)
2568 // set _this.data values ..
2569 var ar = _this.grid.activeEditor.record;
2570 // Roo.log('beforeselect');
2574 // Roo.log('beforeselect-cb');
2575 ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
2576 ar.set('coitem_listprice', record.data.item_listprice);
2577 ar.set('coitem_price', record.data.item_price);
2578 ar.set('coitem_custprice', record.data.item_price);
2579 ar.set('coitem_itemsite_id', record.data.itemsite_id);
2580 ar.set('item_number', record.data.itemsite_item_id_item_number);
2581 ar.set('item_type', record.data.itemsite_item_id_item_type);
2582 ar.set('avail_qty', 0);
2589 displayField : 'itemsite_item_id_item_number',
2591 emptyText : "Select item",
2592 forceSelection : true,
2593 hiddenName : 'itemsite_item_id_item_number',
2595 loadingText : "Searching...",
2597 name : 'item_number',
2599 qtip : "Select item",
2600 queryParam : 'query[number]',
2601 selectOnFocus : true,
2602 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>',
2603 triggerAction : 'all',
2605 valueField : 'item_number',
2610 beforeload : function (_self, o){
2611 o.params = o.params || {};
2612 o.params.customer_id = _this.form.findField('cohead_cust_id').getValue();
2613 o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue();
2614 //o.params.shipto_cust_id = _this.data.cohead_cust_id;
2619 sortInfo : { direction : 'ASC', field: 'item_number' },
2624 url : baseURL + '/Roo/itemsite.php'
2627 xtype: 'JsonReader',
2631 totalProperty : 'total',
2632 fields : [{"name":"item_id","type":"int"},"item_number"]
2639 xtype: 'ColumnModel',
2641 dataIndex : 'coitem_location_src',
2644 renderer : function(v,x,r) {
2645 return String.format('{0}', r.data.coitem_location_src_location_name);
2648 xtype: 'GridEditor',
2654 beforeselect : function (combo, record, index)
2656 // set _this.data values ..
2657 var ar = _this.grid.activeEditor.record;
2661 //Roo.log('beforeselect');
2665 // Roo.log('beforeselect-cb');
2666 ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
2667 ar.set('coitem_price', record.data.item_listprice);
2668 ar.set('coitem_custprice', record.data.item_price);
2669 ar.set('coitem_itemsite_id', record.data.itemsite_id);
2670 ar.set('item_number', record.data.itemsite_item_id_item_number);
2679 displayField : 'location_name',
2681 emptyText : "Select location",
2682 forceSelection : true,
2683 hiddenName : 'coitem_location_src',
2685 loadingText : "Searching...",
2687 name : 'coitem_location_src_location_name',
2689 qtip : "Select item",
2690 queryParam : 'query[location_name]',
2691 selectOnFocus : true,
2692 tpl : '<div class="x-grid-cell-text x-btn button"><b> {location_name}</b> {location_descrip}</div>',
2693 triggerAction : 'all',
2695 valueField : 'location_id',
2700 beforeload : function (_self, o){
2701 o.params = o.params || {};
2703 var row = _this.grid.activeEditor.record;
2705 o.params['query[item_itemsite_id]'] = row.data.coitem_itemsite_id;
2706 // need to know the date to calc the est. delivery time..
2707 //o.params['query[avail_when]'] = _this.form.findField('cohead_targetdate').getValue().format('Y-m-d');
2708 //o.params.location_netable = 1;
2709 o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue();
2711 o.params.location_restrict = 0;
2712 o.params._notinternalcompany = 1;
2716 // o.params.itemsite_id = _this.form.findField('cohead_cust_id').getValue();
2717 //o.params.shipto_cust_id = _this.data.cohead_cust_id;
2722 sortInfo : { direction : 'ASC', field: 'location_name' },
2727 url : baseURL + '/Roo/location.php'
2730 xtype: 'JsonReader',
2734 totalProperty : 'total',
2735 fields : [{"name":"location_id","type":"int"},"location_name"]
2742 xtype: 'ColumnModel',
2744 dataIndex : 'coitem_shipto_id',
2747 renderer : function(v,x,r) {
2748 return String.format('{0}:{1}', v, r.data.coitem_shipto_id_shipto_name);
2751 xtype: 'GridEditor',
2757 add : function (combo)
2760 Pman.Dialog.XtupleCustomer.show({ cust_id : _this.form.findField('cohead_cust_id').getValue() }, function(data) {
2761 // refresh the data in the pulldown..
2764 beforeselect : function (combo, record, index)
2768 for(var i = 1; i <4; i++) {
2769 _this.data['cohead_shiptoaddress'+ i] = record.data['cntct_addr_id_addr_line'+i];
2771 _this.form.findField('shipto_address').update();
2778 displayField : 'shipto_name',
2780 emptyText : "Select cntct",
2781 forceSelection : true,
2782 hiddenName : 'cohead_shipto_id',
2784 loadingText : "Searching...",
2786 name : 'coitem_shipto_id_shipto_name',
2788 qtip : "Select shipto",
2789 queryParam : 'query[shipto_name]',
2790 selectOnFocus : true,
2791 tpl : '<div class="x-grid-cell-text x-btn button"><b>{shipto_id}:{shipto_addr_id_addr_name}</b> </div>',
2792 triggerAction : 'all',
2794 valueField : 'shipto_id',
2800 beforeload : function (_self, o){
2801 o.params = o.params || {};
2802 o.params.shipto_cust_id = _this.data.cohead_cust_id;
2803 //o.params['query[with_shipinfo]'] = 1;
2808 sortInfo : { direction : 'ASC', field: 'shipto_name' },
2813 url : baseURL + '/Roo/shiptoinfo.php'
2816 xtype: 'JsonReader',
2820 totalProperty : 'total',
2821 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
2828 xtype: 'ColumnModel',
2830 dataIndex : 'item_descrip1',
2831 header : 'Item Description',
2833 renderer : function(v,x,r) {
2835 if (r.data.coitem_memo && r.data.coitem_memo.length) {
2836 return String.format('{0}', r.data.coitem_memo);
2837 if (r.data.coitem_memo != v) {
2838 r.set('item_descrip1', r.data.coitem_memo);
2842 if (v && v.length > 49) {
2843 return String.format('<span style="color:orange" qtip="line may be too long to print">{0}</span>', v);
2846 return String.format('{0}', v);
2850 xtype: 'GridEditor',
2860 xtype: 'ColumnModel',
2863 dataIndex : 'coitem_status',
2866 renderer : function(v) { return String.format('{0}', v); }
2869 xtype: 'ColumnModel',
2872 dataIndex : 'coitem_qtyord',
2875 renderer : function(v,x,r) {
2876 var v = parseInt(v);
2877 //var aq = parseInt(r.data.avail_qty);
2878 //aq = isNaN(aq) ? 0 : aq;
2880 var rate = _this.form.findField('taxzone_rate').getValue();
2881 r.data.coitem_subtotal = v * r.data.coitem_price;
2882 r.data.coitem_subtotal_tax = v * r.data.coitem_price * ( 1 + rate * 1);
2883 return String.format('{0}', v);
2887 xtype: 'GridEditor',
2890 xtype: 'NumberField',
2893 focus : function (_self)
2895 if (this.value == 0) {
2896 this.el.dom.value = '';
2900 allowDecimals : false,
2901 decimalPrecision : 0,
2903 style : 'text-align:right'
2908 xtype: 'ColumnModel',
2911 dataIndex : 'coitem_price',
2914 renderer : function(v,x,r) {
2916 var rate = _this.form.findField('taxzone_rate').getValue();
2917 r.data.coitem_subtotal = v * r.data.coitem_qtyord;
2918 r.data.coitem_subtotal_tax = v * ( 1 + rate * 1 ) * r.data.coitem_qtyord;
2919 r.data.coitem_price_tax = v * ( 1 + rate * 1 );
2920 if (parseInt(v) < 1) {
2921 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,3));
2925 //r.set('coitem_subtotal', v * r.data.coitem_qtyord);
2927 return String.format('{0}', Roo.util.Format.number(v,3));
2930 xtype: 'GridEditor',
2933 xtype: 'NumberField',
2936 focus : function (_self)
2938 if (this.value == 0.0) {
2939 this.el.dom.value = '';
2943 decimalPrecision : 3,
2945 style : 'text-align:right'
2950 xtype: 'ColumnModel',
2953 dataIndex : 'coitem_price_tax',
2954 header : 'Sell @w/GST',
2957 renderer : function(v,x,r) {
2959 if (parseInt(v) < 1) {
2960 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,3));
2963 return String.format('{0}', Roo.util.Format.number(v,3));
2966 xtype: 'GridEditor',
2969 xtype: 'NumberField',
2972 focus : function (_self)
2974 if (this.value == 0.0) {
2975 this.el.dom.value = '';
2979 decimalPrecision : 3,
2981 style : 'text-align:right'
2986 xtype: 'ColumnModel',
2989 dataIndex : 'coitem_linedisc',
2992 renderer : function(v,x,r) {
2994 // coitem_custprice = coitem_price * ((100 - coitem_disc)/ 100)
2996 // 12 * (( 100 - 0) / 100)
2997 // coitem_custprice / coitem_price = ((100 - coitem_disc)/ 100)
2998 // 100 - ((coitem_custprice / coitem_price) * 100) = coitem_disc
2999 // 100 - 97 = 100 -3
3001 // r.data.coitem_linedisc = 100 - (
3002 // (parseFloat(r.data.coitem_custprice) /
3003 // parseFloat(r.data.coitem_price)
3005 var fl = parseFloat(r.data.coitem_linedisc);
3006 if ( isNaN(fl) || fl == 0.0 || r.data.coitem_price > r.data.coitem_custprice) {
3009 return String.format('<span style="color:green">{0}%</span>', Roo.util.Format.number( r.data.coitem_linedisc,2));
3012 xtype: 'GridEditor',
3015 xtype: 'NumberField',
3018 focus : function (_self)
3020 if (this.value == 0.0) {
3021 this.el.dom.value = '';
3025 decimalPrecision : 2,
3028 style : 'text-align:right'
3033 xtype: 'ColumnModel',
3036 dataIndex : 'coitem_custprice',
3037 header : 'List Price',
3039 renderer : function(v,x,r) {
3041 var rate = _this.form.findField('taxzone_rate').getValue();
3042 r.data.coitem_custprice_tax = v * ( 1 + rate * 1 );
3044 var tip = 'No WRP available';
3045 if ((r.data.coitem_wrpprice * 1) > 0) {
3046 tip = "WRP : " + Roo.util.Format.number(r.data.coitem_wrpprice,3);
3048 // less than zero, show as red..
3049 if (parseFloat(v) < 1) {
3050 return String.format('<b qtip="{1}" style="color:red;">{0}</b>',
3051 Roo.util.Format.number(v,3), tip);
3053 if (r.data.customer_price_each != v) {
3054 return String.format('<b qtip="{1}" style="color:pink;">{0}</b>',
3055 Roo.util.Format.number(v,3),
3056 "List Price = " + Roo.util.Format.number(r.data.customer_price_each,3)
3062 //r.data.coitem_subtotal = v * r.data.coitem_qtyord;
3064 //r.set('coitem_subtotal', v * r.data.coitem_qtyord);
3066 return String.format('<span qtip="{1}">{0}</span>', Roo.util.Format.number(v,3), tip);
3069 xtype: 'GridEditor',
3072 xtype: 'NumberField',
3075 focus : function (_self)
3077 if (this.value == 0.0) {
3078 this.el.dom.value = '';
3082 decimalPrecision : 3,
3084 style : 'text-align:right'
3089 xtype: 'ColumnModel',
3092 dataIndex : 'coitem_custprice_tax',
3093 header : 'List Price w/GST',
3096 renderer : function(v,x,r) {
3097 var rate = _this.form.findField('taxzone_rate').getValue();
3098 var tip = 'No WRP available';
3099 if ((r.data.coitem_wrpprice * 1) > 0) {
3100 tip = "WRP : " + Roo.util.Format.number(r.data.coitem_wrpprice,3);
3103 if (parseFloat(v) < 1) {
3104 return String.format('<b qtip="{1}" style="color:red;">{0}</b>',
3105 Roo.util.Format.number(v,3), tip);
3107 if (r.data.customer_price_each != v) {
3108 return String.format('<b qtip="{1}" style="color:pink;">{0}</b>',
3109 Roo.util.Format.number(v,3),
3110 "List Price = " + Roo.util.Format.number(r.data.customer_price_each * ( 1 + rate * 1 ),3)
3114 return String.format('<span qtip="{1}">{0}</span>', Roo.util.Format.number(v,3), tip);
3117 xtype: 'GridEditor',
3120 xtype: 'NumberField',
3123 focus : function (_self)
3125 if (this.value == 0.0) {
3126 this.el.dom.value = '';
3130 decimalPrecision : 3,
3132 style : 'text-align:right'
3137 xtype: 'ColumnModel',
3140 dataIndex : 'coitem_subtotal',
3141 header : 'SubTotal',
3143 renderer : function(v) {
3145 if (parseInt(v) < 1) {
3146 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,2));
3151 return Roo.util.Format.number( v, 2);
3155 xtype: 'ColumnModel',
3158 dataIndex : 'coitem_subtotal_tax',
3159 header : 'SubTotal w/GST',
3162 renderer : function(v,x,r) {
3164 if (parseInt(v) < 1) {
3165 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,2));
3168 return String.format('{0}', Roo.util.Format.number(v,2));
3172 xtype: 'ColumnModel',
3175 dataIndex : 'coitem_unitcost_in_order_cur',
3176 header : 'Unit Cost',
3178 renderer : function(v) { return Roo.util.Format.number( v, 2); }
3181 xtype: 'ColumnModel',
3184 dataIndex : 'coitem_taxtype_id',
3187 renderer : function(v,x,r) { return String.format('{0}', r.data.coitem_taxtype_id_taxtype_name); },
3189 xtype: 'GridEditor',
3195 displayField : 'taxtype_name',
3197 emptyText : "Select Tax Type",
3198 forceSelection : true,
3199 hiddenName : 'coitem_taxtype_id',
3201 loadingText : "Searching...",
3203 name : 'coitem_taxtype_id_taxtype_name',
3205 qtip : "Select taxtype",
3206 queryParam : 'query[taxtype_id]',
3207 selectOnFocus : true,
3208 tpl : '<div class="x-grid-cell-text x-btn button"><b>{taxtype_name}</b> </div>',
3209 triggerAction : 'all',
3211 valueField : 'taxtype_id',
3217 beforeload : function (_self, o){
3218 o.params = o.params || {};
3225 sortInfo : { direction : 'ASC', field: 'taxtype_name' },
3230 url : baseURL + '/Roo/taxtype.php'
3233 xtype: 'JsonReader',
3237 totalProperty : 'total',
3238 fields : [{"name":"taxtype_id","type":"int"},"taxtype_name"]
3245 xtype: 'ColumnModel',
3248 dataIndex : 'avail_qty',
3251 renderer : function(v,x,r) {
3253 var oq = parseInt(r.data.coitem_qtyord);
3254 var aq = parseInt(r.data.avail_qty);
3255 var sq = parseInt(r.data.coitem_qtyshipped);
3256 aq = isNaN(aq) ? 0 : aq;
3257 oq = isNaN(oq) ? 0 : oq;
3258 sq = isNaN(sq) ? 0 : sq;
3260 var unshipped = oq - sq;
3262 if ( aq < 0 || (unshipped > 0 && aq < unshipped)) {
3263 return String.format('<b style="color:red;">{0}</b>', parseInt(aq));
3266 return String.format('{0}', aq);
3271 xtype: 'ColumnModel',
3274 dataIndex : 'shipitem_shipped',
3275 header : '#reserved',
3277 renderer : function(v,x,r) {
3280 var vv = parseInt(v);
3281 vv = isNaN(vv) ? 0 : vv;
3283 var ov = parseInt(r.data.coitem_qtyord);
3284 ov = isNaN(ov) ? 0 : ov;
3286 var qs = parseInt(r.data.coitem_qtyshipped);
3287 qs = isNaN(qs) ? 0 : qs;
3292 // not enough reserved yet.
3293 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv - qs);
3296 return String.format('{0}', vv - qs);
3301 xtype: 'ColumnModel',
3304 dataIndex : 'coitem_qtyshipped',
3305 header : '#shipped',
3307 renderer : function(v,x,r) {
3309 var vv = parseInt(v);
3310 vv = isNaN(vv) ? 0 : vv;
3312 var ov = parseInt(r.data.coitem_qtyord);
3313 ov = isNaN(ov) ? 0 : ov;
3317 // not enought shipped.
3318 // or too many shipped.
3319 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv);
3324 return String.format('{0}', vv);
3329 xtype: 'ColumnModel',
3332 dataIndex : 'cobill_billed',
3333 header : '#invoiced',
3335 renderer : function(v,x,r) {
3337 var vv = parseInt(v);
3338 vv = isNaN(vv) ? 0 : vv;
3340 var ov = parseInt(r.data.coitem_qtyord);
3341 ov = isNaN(ov) ? 0 : ov;
3345 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv);
3347 return String.format('{0}', vv);
3355 xtype: 'NestedLayoutPanel',
3358 activate : function (_self)
3360 _this.shipinvtab = _self;
3364 title : "Shipments / Invoices",
3366 xtype: 'BorderLayout',
3373 activate : function() {
3374 _this.shippanel = this;
3375 if (_this.shipgrid) {
3376 _this.shipgrid.ds.load({});
3381 fitContainer : true,
3384 tableName : 'shiphead',
3392 _this.shipgrid = this;
3393 //_this.dialog = Pman.Dialog.FILL_IN
3394 if (_this.shippanel.active) {
3398 rowdblclick : function (_self, rowIndex, e)
3400 var rec = this.ds.getAt(rowIndex);
3401 if (!rec.json.shiphead_shipdate.length) {
3402 Roo.MessageBox.alert("Error", "You can not edit voided shipments, create a new one, and use the restore feature");
3406 Pman.Dialog.XtupleShipment.show({
3407 shiphead_id : rec.data.shiphead_id
3416 autoExpandColumn : 'shiphead_shipvia',
3422 beforeload : function (_self, options)
3424 options.params = options.params || {};
3425 options.params.shiphead_order_id = _this.form.findField('cohead_id').getValue() * 1;
3426 if (options.params.shiphead_order_id < 1) {
3432 sortInfo : { field : 'shiphead_shipvia', direction: 'ASC' },
3437 url : baseURL + '/Roo/shiphead.php'
3440 xtype: 'JsonReader',
3442 totalProperty : 'total',
3447 'name': 'shiphead_number',
3451 'name': 'shiphead_shipvia',
3455 'name': 'shiphead_shipdate',
3459 'name': 'shiphead_sfstatus'
3462 'name': 'shiphead_tracknum',
3478 var sel = _this.shipgrid.getSelectionModel().getSelected();
3480 Roo.MessageBox.alert("Error", "Select a shipment");
3483 if (sel.data.shiphead_shipped) {
3484 Roo.MessageBox.alert("Error", "Shipment is already confirmed");
3489 // check current status of shipment..
3494 url : baseURL + '/Roo/shiphead',
3498 shiphead_id : sel.data.shiphead_id,
3501 success : function() {
3502 _this.shipgrid.ds.load({});
3509 cls : 'x-btn-text-icon',
3510 text : "Confirm Shipment",
3511 icon : rootURL + '/Pman/templates/images/lock.gif'
3519 var sel = _this.shipgrid.getSelectionModel().getSelected();
3521 Roo.MessageBox.alert("Error", "Select a shipment");
3526 // check current status of shipment..
3530 url : baseURL + '/Roo/shiphead',
3533 _download :sel.data.shiphead_id
3541 cls : 'x-btn-text-icon',
3542 text : "Download (as xls)",
3543 icon : rootURL + '/Pman/templates/images/save.gif'
3551 var sel = _this.shipgrid.getSelectionModel().getSelected();
\r
3553 Roo.MessageBox.alert("Error", "Select a shipment");
\r
3556 // check current status of shipment..
3559 url : baseURL + '/Xtuple/Print',
3562 template : 'picking-slip',
3563 param : "shiphead_id:integer='" + sel.data.shiphead_id + "'",
3564 filename : 'picking-slip-' + sel.data.shiphead_number
3566 success : function() {
3575 cls : 'x-btn-text-icon',
3576 text : "Print Picking Slip",
3577 icon : rootURL + '/Pman/templates/images/pdf.gif'
3585 var sel = _this.shipgrid.getSelectionModel().getSelected();
\r
3587 Roo.MessageBox.alert("Error", "Select a shipment");
\r
3590 // check current status of shipment..
3593 url : baseURL + '/Xtuple/Print',
3596 template : 'delivery-note-',
3597 param : "shiphead_id:integer='" + sel.data.shiphead_id + "'",
3598 filename : 'delivery-note-' + sel.data.shiphead_number
3600 success : function() {
3609 cls : 'x-btn-text-icon',
3610 text : "Print Delivery Note",
3611 icon : rootURL + '/Pman/templates/images/pdf.gif'
3623 if (!_this.form.findField('cohead_id').getValue()) {
3624 Roo.MessageBox.alert("Error", "Save Order first");
3627 var rv = _this.form.getFieldValues();
3629 Pman.Dialog.XtupleShipmentNew.show({
3630 shiphead_order_id : rv.cohead_id,
3631 shiphead_shipdate : _this.form.findField('cohead_targetdate').getValue().format('Y-m-d')
3634 _this.shipgrid.ds.load({});
3638 render : function (_self)
3640 _this.addShipmentBtn = _self;
3643 cls : 'x-btn-text-icon',
3645 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
3653 var sel = _this.shipgrid.getSelectionModel().getSelected();
3655 Roo.MessageBox.alert("Error", "Select a shipment");
3658 // check current status of shipment..
3660 var msg = sel.data.shiphead_shipped ?
3661 "Are you sure you want to un-confirm that shipment? - It will remove items from unposted invoices" :
3662 "Are you sure you want to void that shipment?";
3664 Roo.MessageBox.confirm("Are you sure", msg,
3672 url : baseURL + '/Roo/shiphead',
3676 shiphead_id : sel.data.shiphead_id,
3679 success : function() {
3680 _this.shipgrid.ds.load({});
3693 cls : 'x-btn-text-icon',
3694 text : "Void / Unconfirm",
3695 icon : rootURL + '/Pman/templates/images/trash.gif'
3701 xtype: 'ColumnModel',
3703 dataIndex : 'shiphead_number',
3706 renderer : function(v,x,r) {
3707 if (r.json.shiphead_shipdate.length) {
3708 return String.format('{0}', v);
3710 return String.format('<s>{0}</s>', v);
3714 xtype: 'ColumnModel',
3716 dataIndex : 'shiphead_location_id_location_name',
3717 header : 'From Location',
3719 renderer : function(v) { return String.format('{0}', v); }
3722 xtype: 'ColumnModel',
3724 dataIndex : 'shiphead_shipto_id_shipto_name',
3727 renderer : function(v) { return String.format('{0}', v); }
3730 xtype: 'ColumnModel',
3732 header : 'shipdate',
3734 dataIndex : 'shiphead_shipdate',
3735 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
3738 xtype: 'ColumnModel',
3740 dataIndex : 'shiphead_sfstatus',
3743 renderer : function(v,x,r) {
3748 if (r.json.shiphead_shipdate.length) {
3750 if (r.json.shiphead_shipped) {
3754 return '<span style="color:red">Draft</span>';
3763 xtype: 'ColumnModel',
3767 dataIndex : 'shiphead_shipvia',
3768 renderer : function(v) { return String.format('{0}', v); }
3771 xtype: 'ColumnModel',
3773 header : 'tracknum',
3775 dataIndex : 'shiphead_tracknum',
3776 renderer : function(v) { return String.format('{0}', v); }
3785 activate : function() {
3786 _this.invpanel = this;
3787 if (_this.invgrid) {
3788 _this.invgrid.ds.load({});
3793 fitContainer : true,
3796 tableName : 'cobmisc',
3804 _this.invgrid = this;
3805 //_this.dialog = Pman.Dialog.FILL_IN
3806 if (_this.invpanel.active) {
3810 rowdblclick : function (_self, rowIndex, e)
3813 var ri = this.ds.getAt(rowIndex);
3814 if ( ri.data.cobmisc_id < 0) { // skip summary row..
3817 var rv = _this.form.getFieldValues();
3818 Pman.Dialog.XtupleInvoice.show({
3819 cobmisc_id : ri.data.cobmisc_id,
3820 // below parms for add credit memo
3822 cm_cust_id : rv.cohead_cust_id,
3823 cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,
3824 cm_curr_id : rv.cohead_curr_id,
3825 cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,
3826 cm_terms_id : rv.cohead_terms_id,
3827 cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,
3828 cm_salesrep_id : rv.cohead_salesrep_id,
3829 cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,
3830 cm_docdate : new Date(),
3831 cm_taxzone_id : rv.cohead_taxzone_id,
3832 cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,
3833 cm_billto_cntct_id : rv.cohead_billto_cntct_id,
3834 cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,
3835 cm_location_src : rv.cohead_location_src,
3836 cm_location_src_location_name : rv.cohead_location_src_location_name,
3837 cm_billto_address : rv.billto_address
3841 _this.invgrid.ds.load({});
3846 autoExpandColumn : 'invchead_invcnumber',
3852 beforeload : function (_self, options)
3855 options.params = options.params || {};
3856 options.params.cobmisc_cohead_id = _this.form.findField('cohead_id').getValue() * 1;
3857 if (options.params.cobmisc_cohead_id < 1) {
3861 options.params._with_other_payment = 1;
3862 //options.params['query[invchead_ordernumber]'] = _this.form.findField('cohead_number').getValue()
3865 load : function (_self, records, options)
3870 var totalfreight = 0.0;
3871 var totalmisc = 0.0;
3874 Roo.each(records, function(r)
3876 if(r.data.cobmisc_id > 1){
3877 done += parseInt(r.data.cobmisc_qty);
3878 totalic += parseFloat(r.data.cobmisc_itemcost).toFixed(2)*1;
3879 totalmisc += parseFloat(r.data.cobmisc_misc).toFixed(2)*1;
3880 totalfreight += parseFloat(r.data.cobmisc_freight).toFixed(2)*1;
3881 totaltax += parseFloat(r.data.cobmisc_tax).toFixed(2)*1;
3882 total = parseInt(r.data.cobmisc_total_qty);
3887 _this.shipinvtab.layout.getRegion('center').getPanel(0).setTitle(
3889 "Invoices (Complete)" :
3890 ("Invoices prepared for " + done + '/' + total)
3894 var frtotal = (parseFloat(_this.form.findField('cohead_freight').getValue()) - totalfreight).toFixed(2);
3895 var misctotal = (parseFloat(_this.form.findField('cohead_misc').getValue()) - totalmisc).toFixed(2);
3896 var ictotal = (parseFloat(_this.form.findField('cohead_subtotal').getValue()) - totalic).toFixed(2);
3897 var taxtotal = (parseFloat(_this.form.findField('cohead_tax').getValue()) - totaltax).toFixed(2);
3898 var remtotal = frtotal*1 + misctotal*1 + ictotal*1 + taxtotal*1;
3900 var nr = this.reader.newRow({
3902 cobmisc_invchead_id_invchead_invcnumber : "Total Remaining",
3903 cobmisc_qty : total - done,
3904 cobmisc_freight :frtotal,
3905 cobmisc_misc : misctotal,
3906 cobmisc_itemcost : ictotal,
3907 cobmisc_tax : taxtotal,
3908 cobmisc_total : remtotal
3912 // do we need to add it somehow??
3913 _this.invgrid.ds.add(nr);
3917 sortInfo : { field : 'invchead_invcnumber', direction: 'ASC' },
3922 url : baseURL + '/Roo/cobmisc.php'
3925 xtype: 'JsonReader',
3929 totalProperty : 'total',
3932 'name': 'invchead_invcnumber',
3936 'name': 'invchead_invcdate',
3953 var sel = _this.invgrid.getSelectionModel().getSelected();
3955 Roo.MessageBox.alert("Error", "Select a invoice");
3958 // check current status of shipment..
3960 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to Post that invoice?",
3967 url : baseURL + '/Roo/cobmisc',
3970 cobmisc_id : sel.data.cobmisc_id,
3973 success : function() {
3974 _this.invgrid.ds.load({});
3985 cls : 'x-btn-text-icon',
3986 text : "Post Invoice",
3987 icon : rootURL + '/Pman/templates/images/lock.gif'
3992 cls : 'x-btn-text-icon',
3994 icon : rootURL + '/Pman/templates/images/pdf.gif',
4006 var sel = _this.invgrid.getSelectionModel().getSelected();
4008 Roo.MessageBox.alert("Error", "Select a invoice");
4011 if (!sel.data.cobmisc_invchead_id) {
4012 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4015 // check current status of shipment..
4018 url : baseURL + '/Roo/invchead',
4021 invchead_id : sel.data.cobmisc_invchead_id,
4024 success : function() {
4033 text : "Print Standard Invoice"
4039 click : function (_self, e)
4042 var sel = _this.invgrid.getSelectionModel().getSelected();
4044 Roo.MessageBox.alert("Error", "Select a invoice");
4047 if (!sel.data.cobmisc_invchead_id) {
4048 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4051 // check current status of shipment..
4054 url : baseURL + '/Roo/invchead',
4057 invchead_id : sel.data.cobmisc_invchead_id,
4061 success : function() {
4069 text : "Print Chinese Invoice With GST in line item",
4070 hidden : !(baseURL.match(/(hk\.php|cn\.php)$/))
4076 click : function (_self, e)
4079 var sel = _this.invgrid.getSelectionModel().getSelected();
4081 Roo.MessageBox.alert("Error", "Select a invoice");
4084 if (!sel.data.cobmisc_invchead_id) {
4085 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4088 // check current status of shipment..
4091 url : baseURL + '/Roo/invchead',
4094 invchead_id : sel.data.cobmisc_invchead_id,
4098 success : function() {
4106 text : "Print Chinese Invoice",
4107 hidden : !(baseURL.match(/(hk\.php|cn\.php)$/))
4113 click : function (_self, e)
4116 var sel = _this.invgrid.getSelectionModel().getSelected();
4118 Roo.MessageBox.alert("Error", "Select a invoice");
4121 if (!sel.data.cobmisc_invchead_id) {
4122 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4125 // check current status of shipment..
4128 url : baseURL + '/Roo/invchead',
4131 invchead_id : sel.data.cobmisc_invchead_id,
4135 success : function() {
4143 text : "Print Aus - GST included Invoice",
4144 hidden : !(baseURL.match(/au\.php$/))
4150 click : function (_self, e)
4152 var sel = _this.invgrid.getSelectionModel().getSelected();
4154 Roo.MessageBox.alert("Error", "Select a invoice");
4157 if (!sel.data.cobmisc_invchead_id) {
4158 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4161 // check current status of shipment..
4164 url : baseURL + '/Roo/invchead',
4167 invchead_id : sel.data.cobmisc_invchead_id,
4177 text : "Print Bambini Pronto Invoice",
4178 hidden : !(baseURL.match(/au\.php$/))
4184 click : function (_self, e)
4187 var sel = _this.invgrid.getSelectionModel().getSelected();
4189 Roo.MessageBox.alert("Error", "Select a invoice");
4192 if (!sel.data.cobmisc_invchead_id) {
4193 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4196 // check current status of shipment..
4199 url : baseURL + '/Roo/invchead',
4202 invchead_id : sel.data.cobmisc_invchead_id,
4203 _print : 'au-proforma'
4206 success : function() {
4214 text : "Print Bambini Pro Forma Invoice",
4215 hidden : !(baseURL.match(/au\.php$/))
4221 click : function (_self, e)
4223 var sel = _this.invgrid.getSelectionModel().getSelected();
4225 Roo.MessageBox.alert("Error", "Select a invoice");
4229 Pman.Dialog.XtupleDiscountOfInvoice.show({invchead_id : sel.data.cobmisc_invchead_id}, function(){
4234 text : "Print Shipping / Commercial Invoice",
4235 hidden : !( baseURL.match(/au\.php$/))
4243 cls : 'x-btn-text-icon',
4244 text : "Payments / Refunds / Credit Memos",
4245 icon : Roo.rootURL + 'images/default/tree/leaf.gif',
4254 click : function(_self,e)
4257 var sel = _this.invgrid.getSelectionModel().getSelected();
4258 if (!sel || sel.data.cobmisc_id < 1) {
4259 Roo.MessageBox.alert("Error", "Select a invoice");
4262 if(!sel.data.cobmisc_posted){
4263 Roo.MessageBox.alert("Error", "This invoice has not been posted!");
4266 if(sel.data.cobmisc_outstanding == 0){
4267 Roo.MessageBox.alert("Error", "There is no any outstanding of this invoice!");
4271 var cust_id = _this.form.findField('cohead_cust_id').getValue();
4276 cashrcpt_amount : sel.data.cobmisc_outstanding,
4277 cashrcpt_cust_id : cust_id,
4278 cashrcpt_aropen_id : sel.data.cobmisc_aropen_id_aropen_id,
4279 cashrcpt_distdate : new Date(),
4280 cashrcpt_fundstype : 'C',
4281 cashrcpt_curr_id : sel.data.cobmisc_curr_id_curr_id,
4282 cashrcpt_curr_id_curr_name : sel.data.cobmisc_curr_id_curr_name,
4283 cashrcpt_usecustdeposit : true,
4284 cashrcpt_docdate : new Date(),
4285 cashrcpt_salescat_id : -1,
4286 cashrcpt_applydate : new Date(),
4287 cashrcpt_discount : 0
4289 Pman.Dialog.XtupleReceivePayment.show( data , function() {
4290 _this.invgrid.ds.load({});
4294 cls : 'x-btn-text-icon',
4295 text : "Receive Payment",
4296 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4302 click : function(_self,e)
4304 var sel = _this.invgrid.getSelectionModel().getSelected();
4305 if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {
4306 Roo.MessageBox.alert("Error", "Select a credit memo");
4309 if(!sel.data.cobmisc_posted){
4310 Roo.MessageBox.alert("Error", "The invoice that credit memo has been applied to has been not posted");
4313 var cust_id = _this.form.findField('cohead_cust_id').getValue();
4318 if(!sel.data.cobmisc_outstanding || sel.data.cobmisc_outstanding == 0){
4319 Roo.MessageBox.alert("Error", "The amount of this credit memo is 0!");
4323 var d = _this.form.getFieldValues();
4326 'checkhead_recip_id' : cust_id,
4327 'checkhead_recip_type' : 'C',
4328 'checkhead_checkdate' : new Date(),
4329 'checkhead_amount' : sel.data.cobmisc_outstanding,
4330 'remaining_total' : sel.data.cobmisc_outstanding,
4331 'checkhead_curr_id' : d.cohead_curr_id,
4332 'checkhead_curr_id_curr_name' : d.cohead_curr_id_curr_name,
4333 'checkhead_misc' : true,
4334 'aropen_id' : sel.data.cobmisc_cobapply_aropen_id,
4335 'cmhead_number' : sel.data.cobmisc_invchead_id_invchead_invcnumber,
4336 'cust_name' : d.cohead_cust_id_cust_name,
4337 '_create_and_post' : 1
4342 Pman.Dialog.XtupleMiscellaneousCheck.show( data , function() {
4343 _this.invgrid.ds.load({});
4347 cls : 'x-btn-text-icon',
4348 text : "Issue Refund",
4349 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4359 click : function(_self,e)
4361 var sel = _this.invgrid.getSelectionModel().getSelected();
4362 if (!sel || sel.data.cobmisc_cashrcpt_id * 1 < 1) {
4363 Roo.MessageBox.alert("Error", "Select a Receive Payment");
4367 Roo.MessageBox.confirm("Confirm", "Voiding receipt will mean you will have to re-enter the receipt refund - " +
4368 "please take note of the details so you can enter it again correctly later.", function(r) {
4374 url : baseURL + '/Roo/cashrcpt',
4377 cashrcpt_id : sel.data.cobmisc_cashrcpt_id,
4380 success : function()
4382 _this.invgrid.ds.load({});
4392 cls : 'x-btn-text-icon',
4393 text : "Void Payment",
4394 icon : rootURL + '/Pman/templates/images/trash.gif'
4400 click : function(_self,e)
4402 var sel = _this.invgrid.getSelectionModel().getSelected();
4403 if (!sel || sel.data.cobmisc_checkhead_id * 1 < 1) {
4404 Roo.MessageBox.alert("Error", "Select a Miscellaneours Check");
4408 Roo.MessageBox.confirm("Confirm", "Voiding refund will mean you will have to re-enter the receipt refund - " +
4409 "please take note of the details so you can enter it again correctly later.", function(r) {
4415 url : baseURL + '/Roo/checkhead',
4418 checkhead_id : sel.data.cobmisc_checkhead_id,
4421 success : function()
4423 _this.invgrid.ds.load({});
4433 cls : 'x-btn-text-icon',
4434 text : "Void Refund",
4435 icon : rootURL + '/Pman/templates/images/trash.gif'
4441 click : function(_self,e)
4443 var sel = _this.invgrid.getSelectionModel().getSelected();
4444 if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {
4445 Roo.MessageBox.alert("Error", "Select a credit memo");
4449 if(sel.data.cobmisc_posted){
4450 Roo.MessageBox.alert("Error", "You cann't void this credit memo, since the invoice that credit memo has been applied to has been posted");
4454 if (sel.data.cobmisc_cobapply_id < 1) {
4455 Roo.MessageBox.alert("Error", "invaild credit memo");
4458 Roo.MessageBox.confirm("Confirm", "Are you sure want to void this applied credit memo, " +
4459 "it will also void all the check that belongs to this credit memo ", function(r) {
4465 url : baseURL + '/Roo/cobapply',
4468 _delete : sel.data.cobmisc_cobapply_id,
4471 success : function()
4473 _this.invgrid.ds.load({});
4482 cls : 'x-btn-text-icon',
4483 text : "Void Credit Memo",
4484 icon : rootURL + '/Pman/templates/images/trash.gif'
4500 if (!_this.form.findField('cohead_id').getValue()) {
4501 Roo.MessageBox.alert("Error", "Save Order first");
4505 var rv = _this.form.getFieldValues();
4508 Pman.Dialog.XtupleInvoice.show({
4509 cobmisc_cohead_id : rv.cohead_id,
4510 cobmisc_shipdate : _this.form.findField('cohead_targetdate').getValue(),
4511 cobmisc_invcdate : _this.form.findField('cohead_targetdate').getValue(),
4512 cobmisc_curr_id : rv.cohead_curr_id,
4513 cobmisc_curr_id_curr_name : rv.cohead_curr_id_curr_name,
4514 // below parms for add credit memo
4516 cm_cust_id : rv.cohead_cust_id,
4517 cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,
4518 cm_curr_id : rv.cohead_curr_id,
4519 cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,
4520 cm_terms_id : rv.cohead_terms_id,
4521 cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,
4522 cm_salesrep_id : rv.cohead_salesrep_id,
4523 cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,
4524 cm_docdate : new Date(),
4525 cm_taxzone_id : rv.cohead_taxzone_id,
4526 cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,
4527 cm_billto_cntct_id : rv.cohead_billto_cntct_id,
4528 cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,
4529 cm_location_src : rv.cohead_location_src,
4530 cm_location_src_location_name : rv.cohead_location_src_location_name,
4531 cm_billto_address : rv.billto_address
4536 _this.invgrid.ds.load({});
4540 render : function (_self)
4542 _this.addInvoiceBtn = _self;
4545 cls : 'x-btn-text-icon',
4547 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4556 var sel = _this.invgrid.getSelectionModel().getSelected();
4558 Roo.MessageBox.alert("Error", "Select a invoice");
4561 // check current status of shipment..
4564 // cobmisc_id : sel.data.cobmisc_id,
4567 if (sel.data.cobmisc_id * 1) {
4568 params.cobmisc_id = sel.data.cobmisc_id * 1 ;
4570 if (sel.data.cobmisc_invchead_id_invchead_id * 1) {
4571 params.invchead_id = sel.data.cobmisc_invchead_id_invchead_id * 1;
4574 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to VOID that invoice?",
4581 url : baseURL + '/Roo/cobmisc',
4584 success : function() {
4585 _this.invgrid.ds.load({});
4596 cls : 'x-btn-text-icon',
4597 text : "Void / Unpost",
4598 icon : rootURL + '/Pman/templates/images/trash.gif'
4604 xtype: 'ColumnModel',
4606 dataIndex : 'cobmisc_invchead_id_invchead_invcnumber',
4607 header : 'Invoice #',
4609 renderer : function(v,x,r) {
4611 r.data.cobmisc_invchead_id_invchead_id * 1 &&
4612 !r.data.cobmisc_invchead_id_invchead_posted) {
4613 return '<span style="color:red">' +
4614 "NEEDS Voiding then re-posted: " +
4615 String.format('{0}', v) +
4619 if(v && r.data.cobmisc_id == -2){
4620 return String.format('<span style="margin-left: 10px;"> - {0} (Credit Memo)</span>', v);
4622 if(v && r.data.cobmisc_id == -3){
4623 return String.format('<span style="margin-left: 20px;"> - {0} (Miscellaneous Check)</span>', v);
4625 if(v && r.data.cobmisc_id == -4){
4626 return String.format('<span style="margin-left: 10px;"> - {0} (Receive Payment) [ {1} ]</span>', v, r.data.cobmisc_cashrcpt_amount);
4629 return v ? String.format('{0}', v) :
4630 '<span style="color:red">' + "Not Posted" + '</span>';
4634 xtype: 'ColumnModel',
4636 dataIndex : 'cobmisc_invcdate',
4637 header : 'invcdate',
4639 renderer : function(v,x,r) {
4641 return String.format('{0}', v && r.data.cobmisc_id > 0 ? v.format('d/M/Y') : '');
4645 xtype: 'ColumnModel',
4648 dataIndex : 'cobmisc_qty',
4651 renderer : function(v) { return String.format('{0}', v ? parseInt(v) : 0); }
4654 xtype: 'ColumnModel',
4657 dataIndex : 'cobmisc_itemcost',
4658 header : 'Item Cost',
4660 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }
4663 xtype: 'ColumnModel',
4666 dataIndex : 'cobmisc_freight',
4667 header : 'Shipping',
4669 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : ''); }
4672 xtype: 'ColumnModel',
4675 dataIndex : 'cobmisc_tax',
4678 renderer : function(v,x,r) {
4680 // tax is based on the % itemcost..
4681 // var ic = r.data.cobmisc_itemcost;
4683 var ic =r.data.cobmisc_itemcost - (1* r.data.cobmisc_itemcost_taxfree);
4685 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
4686 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
4690 var taxp = tax / totic;
4693 return String.format('{0}', (1.0*v).toFixed(2) );
4699 xtype: 'ColumnModel',
4702 dataIndex : 'cobmisc_cohead_id_cohead_pretax_discount',
4703 header : 'Discount (Pretax)',
4705 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }
4708 xtype: 'ColumnModel',
4711 dataIndex : 'cobmisc_misc',
4712 header : 'Discount (Posttax)',
4714 renderer : function(v,x,r)
4716 var vv = v - r.data.cobmisc_cohead_id_cohead_pretax_discount;
4718 return String.format('{0}', vv ? (1.0*vv).toFixed(2) : 0);
4722 xtype: 'ColumnModel',
4725 dataIndex : 'cobmisc_total',
4728 renderer : function(v,x,r) {
4731 var ic = r.data.cobmisc_itemcost;
4732 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
4733 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
4736 var taxp = tax / totic;
4744 return String.format('{0}',(v * 1.0).toFixed(2) );
4748 return String.format('{0}',
4749 ((d.cobmisc_itemcost * 1.0) +
4750 (d.cobmisc_freight * 1.0) +
4751 (d.cobmisc_tax * 1.0) +
4752 (d.cobmisc_misc * 1.0)
4758 xtype: 'ColumnModel',
4761 dataIndex : 'cobmisc_outstanding',
4762 header : 'Outstanding',
4764 renderer : function(v,x,r)
4767 return String.format('{0}', v ? (v * 1.0).toFixed(2) : 0 );
4775 xtype: 'LayoutRegion',
4780 xtype: 'LayoutRegion',
4783 title : "Reserve Stock / Shipments"
4791 activate : function() {
4792 _this.hpanel = this;
4794 _this.hgrid.footer.onClick('first');
4799 fitContainer : true,
4802 tableName : 'events',
4811 //_this.dialog = Pman.Dialog.FILL_IN
4812 if (_this.hpanel.active) {
4813 this.footer.onClick('first');
4816 rowdblclick : function (_self, rowIndex, e)
4818 if (!_this.dialog) return;
4819 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
4820 _this.grid.footer.onClick('first');
4824 autoExpandColumn : 'remarks',
4830 beforeload : function (_self, options)
4832 options.params._related_on_table = 'cohead';
4833 options.params._related_on_id = _this.form.findField('cohead_id').getValue();
4837 sortInfo : { field : 'event_when', direction: 'DESC' },
4842 url : baseURL + '/Roo/events.php'
4845 xtype: 'JsonReader',
4849 totalProperty : 'total',
4852 'name': 'event_when',
4864 'name': 'person_id_name',
4875 xtype: 'PagingToolbar',
4879 displayMsg : "Displaying events{0} - {1} of {2}",
4880 emptyMsg : "No events found"
4884 xtype: 'ColumnModel',
4886 dataIndex : 'event_when',
4889 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); }
4892 xtype: 'ColumnModel',
4894 dataIndex : 'action',
4897 renderer : function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); }
4900 xtype: 'ColumnModel',
4902 dataIndex : 'ipaddr',
4903 header : 'IP address',
4905 renderer : function(v) { return String.format('{0}', v); }
4908 xtype: 'ColumnModel',
4910 dataIndex : 'person_id_name',
4913 renderer : function(v) { return String.format('{0}', v); }
4916 xtype: 'ColumnModel',
4918 dataIndex : 'remarks',
4921 renderer : function(v) { return String.format('{0}', v); }
4927 xtype: 'NestedLayoutPanel',
4932 xtype: 'BorderLayout',
4939 activate : function() {
4940 _this.txpanel = this;
4942 _this.txgrid.footer.onClick('first');
4947 fitContainer : true,
4950 tableName : 'invdetail',
4951 title : "invdetail",
4958 _this.txgrid = this;
4959 //_this.dialog = Pman.Dialog.FILL_IN
4960 if (_this.txpanel.active) {
4961 this.footer.onClick('first');
4965 autoExpandColumn : 'item_number',
4975 click : function (_self, e)
4979 url : baseURL + '/Roo/Cohead',
4982 _apply_fifo : _this.form.findField('cohead_id').getValue()
4984 success : function () {
4985 Roo.MessageBox.alert("Applied", "Succesfully Applied");
4990 text : "Run Apply Fifo on order"
4996 click : function (_self, e)
5000 url : baseURL + '/Roo/Cohead',
5003 _run_void_fix : _this.form.findField('cohead_id').getValue()
5005 success : function () {
5006 Roo.MessageBox.alert("Applied", "Succesfully Run");
5011 text : "Run Void flagger"
5017 click : function (_self, e)
5022 url : baseURL + '/Roo/Invdetail',
5027 _reverse_all_bad : _this.form.findField('cohead_id').getValue()
5029 success : function () {
5030 Roo.MessageBox.alert("Applied", "Succesfully Run");
5035 text : "Auto Reverse"
5040 xtype: 'RowSelectionModel',
5043 selectionchange : function (_self)
5045 _this.txdgrid.footer.onClick('first');;
5054 beforeload : function (_self, o)
5056 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5057 if (! o.params.cohead_id ) {
5064 sortInfo : { field : 'item_number', direction: 'ASC' },
5069 url : baseURL + '/Roo/invdetail.php'
5072 xtype: 'JsonReader',
5074 totalProperty : 'total',
5079 'name': 'invdetail_id',
5083 'name': 'invdetail_transtype',
5087 'name': 'invdetail_invhist_id',
5091 'name': 'invdetail_location_id',
5095 'name': 'invdetail_qty',
5099 'name': 'invdetail_comments',
5103 'name': 'invdetail_qty_before',
5107 'name': 'invdetail_qty_after',
5111 'name': 'invdetail_invcitem_id',
5115 'name': 'invdetail_expiration',
5117 'dateFormat': 'Y-m-d'
5120 'name': 'invdetail_warrpurc',
5122 'dateFormat': 'Y-m-d'
5125 'name': 'invdetail_ls_id',
5132 xtype: 'PagingToolbar',
5135 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5136 emptyMsg : "No invdetail found",
5141 xtype: 'ColumnModel',
5143 dataIndex : 'item_number',
5146 renderer : function(v) { return String.format('{0}', v); }
5149 xtype: 'ColumnModel',
5152 dataIndex : 'rec_shipped',
5155 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5158 xtype: 'ColumnModel',
5161 dataIndex : 'rec_returned',
5164 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5167 xtype: 'ColumnModel',
5170 dataIndex : 'tx_shipped',
5171 header : '#TX ship',
5173 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5176 xtype: 'ColumnModel',
5179 dataIndex : 'tx_returned',
5182 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5185 xtype: 'ColumnModel',
5188 dataIndex : 'tx_total',
5191 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5194 xtype: 'ColumnModel',
5197 dataIndex : 'total_value',
5200 renderer : function(v,x,r) {
5202 return (v*1).toFixed(3);
5206 xtype: 'ColumnModel',
5209 dataIndex : 'tx_total',
5212 renderer : function(v,x,r) {
5214 var cototal = (r.data.rec_returned*1) - (r.data.rec_shipped*1);
5215 // Roo.log(cototal);
5216 var diff = (v*1) - cototal;
5221 return String.format('<span style="color:red">{0}</span>', diff );
5231 activate : function() {
5232 _this.txdpanel = this;
5233 if (_this.txdgrid) {
5234 _this.txdgrid.footer.onClick('first');
5239 fitContainer : true,
5242 tableName : 'invdetail',
5243 title : "invdetail",
5250 _this.txdgrid = this;
5251 //_this.dialog = Pman.Dialog.FILL_IN
5252 if (_this.txdpanel.active) {
5253 this.footer.onClick('first');
5256 rowclick : function (_self, rowIndex, e)
5258 var s = _this.txdgrid.ds.getAt(rowIndex);
5259 var dt = s.data.invhist_transdate.split(' ');
5261 _this.dateSel.setValue(new Date(dt[0]));
5264 autoExpandColumn : 'invhist_comments',
5274 click : function (_self, e)
5276 var s = _this.txdgrid.selModel.getSelected();
5279 Roo.MessageBox.alert("Error", "Select a transaction");
5283 var reverseSel = function() {
5287 url : baseURL + '/Roo/invdetail',
5290 _duplicate : s.data.invdetail_id
5292 success : function() {
5293 _this.txdgrid.footer.onClick('first');
5301 Roo.MessageBox.confirm(
5303 "This should only be used by System Administrators - are you sure you know what you are doing!",
5317 text : "Duplicate Selected"
5332 render : function (_self)
5334 _this.dateSel = _self;
5338 fieldLabel : 'Issue Date',
5340 name : 'issue_date',
5347 click : function (_self, e)
5349 var s = _this.txdgrid.selModel.getSelected();
5350 var dt = _this.dateSel.getValue();
5352 Roo.MessageBox.alert("Error", "Select a transaction");
5356 var reverseSel = function(force) {
5360 url : baseURL + '/Roo/invdetail',
5363 _reverse : s.data.invdetail_id,
5364 _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
5367 success : function() {
5368 _this.txdgrid.footer.onClick('first');
5370 failure : function(res) {
5373 if (res.errors.confirm) {
5375 Roo.MessageBox.confirm(
5377 "are you really sure the totals will get messed up.",
5388 Roo.MessageBox.alert("Error", res.errorMsg);
5398 Roo.MessageBox.confirm(
5400 "This should only be used by System Administrators - are you sure you know what you are doing!",
5414 text : "Reverse Selected"
5422 beforeload : function (_self, o)
5424 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5425 var s = _this.txgrid.selModel.getSelected();
5430 o.params.itemsite_id = s.data.invhist_itemsite_id;
5435 sortInfo : { field : 'invdetail_id', direction: 'ASC' },
5440 url : baseURL + '/Roo/invdetail.php'
5443 xtype: 'JsonReader',
5445 totalProperty : 'total',
5450 'name': 'invdetail_id',
5454 'name': 'invdetail_transtype',
5458 'name': 'invdetail_invhist_id',
5462 'name': 'invdetail_location_id',
5466 'name': 'invdetail_qty',
5470 'name': 'invdetail_comments',
5474 'name': 'invdetail_qty_before',
5478 'name': 'invdetail_qty_after',
5482 'name': 'invdetail_invcitem_id',
5486 'name': 'invdetail_expiration',
5488 'dateFormat': 'Y-m-d'
5491 'name': 'invdetail_warrpurc',
5493 'dateFormat': 'Y-m-d'
5496 'name': 'invdetail_ls_id',
5503 xtype: 'PagingToolbar',
5506 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5507 emptyMsg : "No invdetail found",
5512 xtype: 'ColumnModel',
5514 dataIndex : 'invdetail_id',
5517 renderer : function(v) { return String.format('{0}', v); }
5520 xtype: 'ColumnModel',
5522 dataIndex : 'invhist_transdate',
5525 renderer : function(v) { return String.format('{0}', v); }
5528 xtype: 'ColumnModel',
5530 dataIndex : 'invhist_ordnumber',
5533 renderer : function(v,x,r) {
5534 if (r.data.invfifo_void *1 != 0) {
5535 return String.format('<s>{0}</s>', v);
5538 return String.format('{0}', v);
5542 xtype: 'ColumnModel',
5544 dataIndex : 'invhist_comments',
5547 renderer : function(v) { return String.format('{0}', v); }
5550 xtype: 'ColumnModel',
5553 dataIndex : 'invdetail_qty',
5554 header : 'Qty Changed',
5556 renderer : function(v,x,r) {
5557 if ( r.data.coitem_shipped != v) {
5558 return String.format('{0} <span style="color:red">({1})</span>',
5559 Roo.util.Format.number(v,0),
5560 r.data.coitem_shipped
5564 return String.format('{0}', Roo.util.Format.number(v,0));
5568 xtype: 'ColumnModel',
5571 dataIndex : 'invhist_value_before',
5572 header : 'Qty Changed',
5574 renderer : function(v,x,r) {
5575 var tot = r.data.invhist_value_after*1 - v*1;
5577 if (r.data.invdetail_qty >0 && tot < 0) {
5578 f = '<span style="color:red">{0}</span>';
5580 if (r.data.invdetail_qty < 0 && tot > 0) {
5581 f = '<span style="color:red">{0}</span>';
5583 return String.format(f, Roo.util.Format.number(tot));
5587 xtype: 'ColumnModel',
5589 dataIndex : 'invhist_posted',
5592 renderer : function(v,x,r) {
5594 var state = v ? '-checked' : '';
5596 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
5604 xtype: 'LayoutRegion',
5608 xtype: 'LayoutRegion',
5616 xtype: 'NestedLayoutPanel',
5621 xtype: 'BorderLayout',
5628 activate : function() {
5629 _this.gltxpanel = this;
5630 if (_this.gltxgrid) {
5631 _this.gltxgrid.footer.onClick('first');
5636 fitContainer : true,
5639 tableName : 'invdetail',
5640 title : "invdetail",
5647 _this.gltxgrid = this;
5648 //_this.dialog = Pman.Dialog.FILL_IN
5649 if (_this.gltxpanel.active) {
5650 this.footer.onClick('first');
5653 cellclick : function (_self, rowIndex, columnIndex, e)
5655 if (columnIndex > 0) {
5658 var rec = this.ds.getAt(rowIndex);
5659 rec.set('gltrans_as_summary', rec.data.gltrans_as_summary *1 ? 0 : 1);
5660 _this.gltxdgrid.footer.onClick('first');
5663 autoExpandColumn : 'gltrans_accnt_id_accnt_descrip',
5666 xtype: 'RowSelectionModel',
5669 selectionchange : function (_self)
5671 _this.gltxdgrid.footer.onClick('first');;
5680 beforeload : function (_self, o)
5682 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5683 if (! o.params.cohead_id ) {
5687 o.params._split_sales = _this.glsalesbtn.pressed ? 1 : 0;
5691 sortInfo : { field : 'item_number', direction: 'ASC' },
5696 url : baseURL + '/Roo/gltrans.php'
5699 xtype: 'JsonReader',
5701 totalProperty : 'total',
5706 'name': 'invdetail_id',
5710 'name': 'invdetail_transtype',
5714 'name': 'invdetail_invhist_id',
5718 'name': 'invdetail_location_id',
5722 'name': 'invdetail_qty',
5726 'name': 'invdetail_comments',
5730 'name': 'invdetail_qty_before',
5734 'name': 'invdetail_qty_after',
5738 'name': 'invdetail_invcitem_id',
5742 'name': 'invdetail_expiration',
5744 'dateFormat': 'Y-m-d'
5747 'name': 'invdetail_warrpurc',
5749 'dateFormat': 'Y-m-d'
5752 'name': 'invdetail_ls_id',
5759 xtype: 'PagingToolbar',
5762 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5763 emptyMsg : "No invdetail found",
5770 render : function (_self)
5772 _this.glsalesbtn = _self;
5774 click : function (_self, e)
5776 (function() { _this.gltxgrid.footer.onClick('first'); }).defer(100);
5779 enableToggle : true,
5781 text : "Split sales"
5787 xtype: 'ColumnModel',
5789 dataIndex : 'gltrans_as_summary',
5792 renderer : function(v,x,r) {
5794 var state = v*1 ? '-checked' : '';
5796 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
5800 xtype: 'ColumnModel',
5802 dataIndex : 'gltrans_accnt_id_accnt_descrip',
5805 renderer : function(v) { return String.format('{0}', v); }
5808 xtype: 'ColumnModel',
5811 dataIndex : 'gltrans_amount_credit',
5814 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
5817 xtype: 'ColumnModel',
5820 dataIndex : 'gltrans_amount_debit',
5823 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
5826 xtype: 'ColumnModel',
5829 dataIndex : 'gltrans_amount_total',
5832 renderer : function(v) { return String.format('<b>{0}</b>', Roo.util.Format.number(v,3)); }
5835 xtype: 'ColumnModel',
5838 dataIndex : 'gltrans_amount_total_unposted',
5839 header : 'Unposted',
5841 renderer : function(v) { return String.format('<span style="color:red">{0}</span>', Roo.util.Format.number(v,3)); }
5850 activate : function() {
5851 _this.gltxdpanel = this;
5852 if (_this.gltxdgrid) {
5853 _this.gltxdgrid.footer.onClick('first');
5858 fitContainer : true,
5861 tableName : 'invdetail',
5862 title : "invdetail",
5869 _this.gltxdgrid = this;
5870 //_this.dialog = Pman.Dialog.FILL_IN
5871 if (_this.gltxdpanel.active) {
5872 this.footer.onClick('first');
5875 cellclick : function (_self, ri, ci, e)
5878 var deleteSel = function() {
5882 url : baseURL + '/Roo/gltrans',
5886 gltrans_id : rec.data.gltrans_id
5889 success : function() {
5890 rec.set('gltrans_posted', false);
5891 rec.set('gltrans_deleted', true);
5892 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
5893 _this.gltxgrid.footer.onClick('first');
5898 var undeleteSel = function() {
5902 url : baseURL + '/Roo/gltrans',
5906 gltrans_id : rec.data.gltrans_id
5909 success : function() {
5910 rec.set('gltrans_posted', true);
5911 rec.set('gltrans_deleted', false);
5912 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
5913 _this.gltxgrid.footer.onClick('first');
5919 var di = this.colModel.config[ci].dataIndex;
5920 if (di != 'gltrans_posted') {
5926 var rec = this.ds.getAt(ri);
5927 if (rec.data.gltrans_deleted) {
5929 Roo.MessageBox.confirm(
5931 "This should only be used by System Administrators - are you sure you know what you are doing!",
5945 if (!rec.data.gltrans_posted) {
5951 url : baseURL + '/Roo/gltrans',
5955 gltrans_id : rec.data.gltrans_id
5957 success : function (res)
5959 rec.set('gltrans_posted', true);
5960 _this.gltxgrid.footer.onClick('first');
5969 // we have a posted transaction.
5970 // only allow recalled to be deleted..
5971 if (!rec.data.gltrans_notes.match(/(Recall|Ship Order)/)) {
5980 Roo.MessageBox.confirm(
5982 "This should only be used by System Administrators - are you sure you know what you are doing!",
5995 autoExpandColumn : 'gltrans_notes',
6001 beforeload : function (_self, o)
6003 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
6004 var s = _this.gltxgrid.selModel.getSelected();
6009 o.params.gltrans_accnt_id = s.data.gltrans_accnt_id;
6010 o.params.gltrans_is_ship = s.data.gltrans_is_ship;
6011 o.params.gltrans_as_summary = s.data.gltrans_as_summary;
6017 sortInfo : { field : 'gltrans_docnumber', direction: 'ASC' },
6022 url : baseURL + '/Roo/gltrans.php'
6025 xtype: 'JsonReader',
6027 totalProperty : 'total',
6032 'name': 'invdetail_id',
6036 'name': 'invdetail_transtype',
6040 'name': 'invdetail_invhist_id',
6044 'name': 'invdetail_location_id',
6048 'name': 'invdetail_qty',
6052 'name': 'invdetail_comments',
6056 'name': 'invdetail_qty_before',
6060 'name': 'invdetail_qty_after',
6064 'name': 'invdetail_invcitem_id',
6068 'name': 'invdetail_expiration',
6070 'dateFormat': 'Y-m-d'
6073 'name': 'invdetail_warrpurc',
6075 'dateFormat': 'Y-m-d'
6078 'name': 'invdetail_ls_id',
6085 xtype: 'PagingToolbar',
6088 displayMsg : "Displaying invdetail{0} - {1} of {2}",
6089 emptyMsg : "No invdetail found",
6096 click : function (_self, e)
6098 new Pman.Download( {
6099 grid : _this.gltxdgrid
6110 xtype: 'ColumnModel',
6112 dataIndex : 'gltrans_id',
6116 renderer : function(v) { return String.format('{0}', v ); }
6119 xtype: 'ColumnModel',
6121 dataIndex : 'gltrans_date',
6124 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
6127 xtype: 'ColumnModel',
6129 dataIndex : 'gltrans_docnumber',
6132 renderer : function(v,x,r) {
6133 if (r.data.gltrans_deleted) {
6134 return String.format('<s>{0}</s>', v);
6136 return String.format('{0}', v);
6140 xtype: 'ColumnModel',
6142 dataIndex : 'gltrans_source',
6145 renderer : function(v) { return String.format('{0}', v); }
6148 xtype: 'ColumnModel',
6150 dataIndex : 'gltrans_notes',
6153 renderer : function(v) { return String.format('{0}', v); }
6156 xtype: 'ColumnModel',
6159 dataIndex : 'gltrans_amount',
6162 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
6165 xtype: 'ColumnModel',
6167 dataIndex : 'gltrans_posted',
6170 renderer : function(v,x,r) {
6172 var state = v ? '-checked' : '';
6174 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
6182 xtype: 'LayoutRegion',
6186 xtype: 'LayoutRegion',
6197 activate : function() {
6198 _this.profitpanel = this;
6200 try { if (MODULE.isBuilder) {
6204 var id = _this.form.findField('cohead_id').getValue() * 1;
6206 Roo.MessageBox.alert("Save First", "Save the order first, before adding items");
6207 _this.dialog.layout.getRegion('center').showPanel(0);
6211 if (_this.profitgrid) {
6212 _this.profitgrid.footer.onClick('first');
6218 fitContainer : true,
6221 tableName : 'coitem',
6229 _this.profitgrid = this;
6230 //_this.dialog = Pman.Dialog.FILL_IN
6231 if (_this.profitpanel.active) {
6232 this.footer.onClick('first');
6236 autoExpandColumn : 'item_number',
6242 beforeload : function (_self,o) {
6249 if (!_this.data || !_this.data.cohead_id) {
6252 o.params = o.params || {};
6254 o.params.coitem_cohead_id = _this.data.cohead_id;
6255 o.params._without_list_discount =1;
6256 o.params._with_profit = 1;
6261 sortInfo : { field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' },
6266 url : baseURL + '/Roo/coitem.php'
6269 xtype: 'JsonReader',
6271 totalProperty : 'total',
6292 'name': 'leader_id',
6296 'name': 'leader_office_id',
6300 'name': 'leader_name',
6304 'name': 'leader_phone',
6308 'name': 'leader_fax',
6312 'name': 'leader_email',
6316 'name': 'leader_company_id',
6320 'name': 'leader_role',
6324 'name': 'leader_active',
6328 'name': 'leader_remarks',
6332 'name': 'leader_passwd',
6336 'name': 'leader_owner_id',
6340 'name': 'leader_lang',
6344 'name': 'leader_no_reset_sent',
6348 'name': 'leader_action_type',
6352 'name': 'leader_project_id',
6356 'name': 'leader_deleted_by',
6360 'name': 'leader_deleted_dt',
6364 'name': 'leader_firstname',
6368 'name': 'leader_lastname',
6372 'name': 'leader_name_facebook',
6376 'name': 'leader_url_blog',
6380 'name': 'leader_url_twitter',
6384 'name': 'leader_url_linkedin',
6388 'name': 'leader_crm_lead_percentage',
6392 'name': 'leader_crm_industry_id',
6396 'name': 'leader_crm_updated_action_id',
6400 'name': 'leader_crm_created_action_id',
6404 'name': 'leader_crm_type_id',
6411 xtype: 'PagingToolbar',
6414 displayMsg : "Displaying coitem{0} - {1} of {2}",
6415 emptyMsg : "No coitem found",
6420 xtype: 'ColumnModel',
6422 dataIndex : 'item_number',
6423 header : 'Item Code',
6425 renderer : function(v) { return String.format('{0}', v); }
6428 xtype: 'ColumnModel',
6430 dataIndex : 'calc_subtotal',
6431 header : 'SubTotal',
6433 renderer : function(v) {
6436 return Roo.util.Format.number( v, 2);
6440 xtype: 'ColumnModel',
6442 dataIndex : 'calc_cost_total',
6443 header : 'Cost of goods',
6445 renderer : function(v) {
6447 return Roo.util.Format.number( v, 2);
6451 xtype: 'ColumnModel',
6453 dataIndex : 'profit',
6456 renderer : function(v,x,r) {
6458 var profit = r.data.calc_subtotal - r.data.calc_cost_total;
6460 if(parseInt(profit) < 1){
6461 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(profit,2));
6465 return Roo.util.Format.number( profit, 2);
6473 xtype: 'LayoutRegion',
6475 alwaysShowTabs : true,
6476 tabPosition : 'top',
6491 var id = 1* _this.form.findField('cohead_id').getValue();
6493 Roo.MessageBox.alert("Error", "Save Sales order first");
6497 // check current status of shipment..
6500 url : baseURL + '/Roo/cohead',
6506 success : function() {
6515 cls : 'x-btn-text-icon',
6516 text : "Download Excel",
6517 icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
6525 var id = 1* _this.form.findField('cohead_id').getValue();
6527 Roo.MessageBox.alert("Error", "Save Sales order first");
6531 // check current status of shipment..
6534 url : baseURL + '/Roo/cohead',
6540 success : function() {
6549 cls : 'x-btn-text-icon',
6551 icon : rootURL + '/Pman/templates/images/pdf.gif'
6557 click : function (_self, e)
6560 _this.addShipmentBtn.fireEvent('click');
6564 cls : 'x-btn-text-icon',
6566 text : "Add Shipment",
6567 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6573 click : function (_self, e)
6576 Pman.Dialog.XtupleCustomer.show({
6577 cust_id : _this.form.findField('cohead_cust_id').getValue()
6581 cls : 'x-btn-text-icon',
6582 text : "Edit Customer",
6583 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6589 click : function (_self, e)
6592 _this.addInvoiceBtn.fireEvent('click');
6596 cls : 'x-btn-text-icon',
6598 text : "Add Invoice",
6599 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6605 render : function (_self, e)
6607 _this.voidBtn = _self;
6609 click : function (_self, e)
6612 cohead_id : _this.form.findField('cohead_id').getValue()
6619 url: baseURL + '/Roo/cohead',
6622 success : function()
6625 if ( _this.data.cohead_status == 'X') {
6626 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
6632 _this.dialog.hide();
6638 if (_this.data.cohead_status == 'X') {
6644 Roo.MessageBox.confirm("Confirm", "Are you sure you want to void this?", function(r) {
6663 click : function (_self, e)
6665 var p = { cohead_id : _this.form.findField('cohead_id').getValue() };
6668 if (_this.data.cohead_status == 'C') {
6676 url: baseURL + '/Roo/cohead',
6680 success : function()
6684 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
6689 _this.dialog.hide();
6694 render : function (_self)
6696 _this.closeBtn = _self;
6709 click : function (_self, e)
6711 if (_this.grid) _this.grid.stopEditing();
6712 _this.dialog.hide();
6721 click : function (_self, e)
6725 if (_this.grid) _this.grid.stopEditing();
6727 _this.form.doAction("submit");
6730 render : function (_self)
6732 _this.saveBtn = _self;