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 _this.reversalBtn.hide();
91 if (_this.data.cohead_id) {
92 this.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
96 _this.dialog.setTitle("Edit New Sales Order");
98 _this.closeBtn.hide();
100 _this.saveBtn.show();
102 if(_this.data.cohead_billto_cntct_id_cntct_id){
103 _this.form.findField('billto_address').update();
105 _this.form.setValues({
\r
106 cohead_billto_cntct_id: _this.data.cohead_billto_cntct_id_cntct_id,
\r
107 cohead_billto_cntct_id_cntct_name : _this.data.cohead_billto_cntct_id_cntct_name,
\r
116 if (action.type == 'load') {
119 _this.data = action.result.data;
121 if (!_this.data.cohead_shipto_id && _this.data.shipto_id*1 > 0) {
122 _this.form.findField('cohead_shipto_id').setValue(_this.data.shipto_id);
123 _this.form.findField('cohead_shipto_id_shipto_name').setValue(_this.data.cohead_shipto_cntct_id_cntct_name);
128 _this.dataloading = true;
129 if (_this.data.cohead_shipto_cntct_id == _this.data.cohead_billto_cntct_id) {
130 this.findField('_shipto_same').setValue(1);
131 Roo.log("set shipto 1");
133 this.findField('_shipto_same').setValue(0);
134 Roo.log("set shipto 0");
136 _this.dataloading = false;
139 this.findField('billto_address').update();
140 this.findField('shipto_address').update();
141 _this.dialog.setTitle("Edit Sales Order - " + this.findField('cohead_number').getValue());
144 if (_this.data.cohead_status == 'C') {
145 _this.closeBtn.show();
146 _this.closeBtn.setText('Re-open');
147 _this.voidBtn.hide();
148 _this.saveBtn.hide();
149 _this.reversalBtn.show();
150 } else if (_this.data.cohead_status == 'X') {
151 _this.closeBtn.hide();
152 _this.voidBtn.show();
153 _this.voidBtn.setText("Un-void / Re-open");
154 _this.saveBtn.hide();
157 _this.closeBtn.show();
158 _this.closeBtn.setText('Complete and Close');
159 _this.voidBtn.setText("Void");
160 _this.voidBtn.show();
161 _this.saveBtn.show();
164 _this.form.findField('cohead_misc_per').update();
166 // finally override the value for discount...
167 if ((''+ _this.data.cohead_misc_descrip).length) {
168 _this.form.findField('cohead_misc_descrip').setValue(_this.data.cohead_misc_descrip);
171 // update the stockcache...
174 url : baseURL + '/Roo/cohead',
177 _stockLevel : _this.data.cohead_id
179 success : function(res)
181 for (var i in res.data) {
183 if(typeof(_this.stockcache[res.data[i].item]) == 'undefined'){
184 _this.stockcache[res.data[i].item] = res.data[i];
192 if (action.type =='submit') {
195 var id = _this.form.findField('cohead_id').getValue() * 1;
198 _this.data.cohead_id = action.result.data.cohead_id;
199 this.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
205 if (_this.callback) {
206 _this.callback.call(_this, _this.form.getValues());
212 rendered : function (form)
216 actionfailed : function (_self, action)
218 if (action.failureType == 'client') {
219 Roo.MessageBox.alert("Error", "Fill in all the required fields");
221 if (action.failureType == 'server') {
223 Roo.MessageBox.alert("Error", action.result.errorMsg);
225 _this.dialog.layout.getRegion('center').showPanel(0);
229 style : 'margin:10px;',
230 url : baseURL + '/Roo/cohead.php',
242 style : 'width:420px',
260 emptyText : "Automatic",
261 fieldLabel : 'Order#',
262 name : 'cohead_number',
270 style : 'float:left',
277 fieldLabel : 'Cust#',
278 name : 'cohead_cust_id_cust_number',
290 fieldLabel : 'Customer',
291 forceSelection : true,
292 hiddenName : 'cohead_cust_id',
294 loadingText : "Searching...",
296 name : 'cohead_cust_id_cust_name',
298 qtip : "Select custinfo",
299 queryParam : 'query[cust_name]',
301 selectOnFocus : true,
302 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> </div>',
303 triggerAction : 'all',
305 valueField : 'cust_id',
311 fieldLabel : 'Customer PO#',
312 name : 'cohead_custponumber',
319 fieldLabel : 'Ordered',
321 name : 'cohead_orderdate',
334 fieldLabel : 'Target Delivery',
336 name : 'cohead_targetdate',
348 check : function (_self, checked)
351 _this.form.findField('cohead_targetdate').setValue(_this.form.findField('cohead_orderdate').getValue());
355 boxLabel : 'same as order',
357 name : '_same_as_order'
367 displayField : 'location_name',
369 emptyText : "Supply From",
370 fieldLabel : 'Supply From',
371 forceSelection : true,
372 hiddenName : 'cohead_location_src',
374 loadingText : "Searching...",
376 name : 'cohead_location_src_location_name',
378 qtip : "Select terms",
379 queryParam : 'query[location_name]',
380 selectOnFocus : true,
381 tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> {location_descrip} </div>',
382 triggerAction : 'all',
384 valueField : 'location_id',
390 beforeload : function (_self, o){
391 o.params = o.params || {};
393 o.params.location_netable = 1;
394 o.params.location_restrict = 0;
395 o.params._notinternalcompany = 1;
399 sortInfo : { direction : 'ASC', field: 'location_name' },
404 url : baseURL + '/Roo/location.php'
411 totalProperty : 'total',
412 fields : [{"name":"location_id","type":"int"},"location_name"]
425 style : 'width:420px',
438 emptyText : "Select terms",
439 forceSelection : true,
441 loadingText : "Searching...",
444 qtip : "Select terms",
445 selectOnFocus : true,
446 triggerAction : 'all',
449 tpl : '<div class="x-grid-cell-text x-btn button"><b>{terms_descrip}</b> </div>',
450 queryParam : 'query[terms_descrip]',
451 fieldLabel : 'Terms',
452 valueField : 'terms_id',
453 displayField : 'terms_descrip',
454 hiddenName : 'cohead_terms_id',
455 name : 'cohead_terms_id_terms_descrip',
460 beforeload : function (_self, o){
461 o.params = o.params || {};
466 sortInfo : { direction : 'ASC', field: 'terms_descrip' },
471 url : baseURL + '/Roo/terms.php'
478 totalProperty : 'total',
479 fields : [{"name":"terms_id","type":"int"},"terms_descrip"]
488 displayField : 'salesrep_name',
490 emptyText : "Select salesrep",
491 fieldLabel : 'Sales Rep',
492 forceSelection : true,
493 hiddenName : 'cohead_display_salesrep_id',
495 loadingText : "Searching...",
497 name : 'cohead_display_salesrep_id_salesrep_name',
499 qtip : "Select salesrep",
500 queryParam : 'query[salesrep_name]',
501 selectOnFocus : true,
502 tpl : '<div class="x-grid-cell-text x-btn button"><b>{salesrep_name}</b> </div>',
503 triggerAction : 'all',
505 valueField : 'salesrep_id',
511 beforeload : function (_self, o){
512 o.params = o.params || {};
517 sortInfo : { direction : 'ASC', field: 'salesrep_name' },
522 url : baseURL + '/Roo/salesrep.php'
529 totalProperty : 'total',
530 fields : [{"name":"salesrep_id","type":"int"},"salesrep_name"]
539 displayField : 'salesrep_name',
541 emptyText : "Select Staff",
542 fieldLabel : 'Staff I.C.',
543 forceSelection : true,
544 hiddenName : 'cohead_salesrep_id',
546 loadingText : "Searching...",
548 name : 'cohead_salesrep_id_salesrep_name',
550 qtip : "Select salesrep",
551 queryParam : 'query[salesrep_name]',
552 selectOnFocus : true,
553 tpl : '<div class="x-grid-cell-text x-btn button"><b>{salesrep_name}</b> </div>',
554 triggerAction : 'all',
556 valueField : 'salesrep_id',
562 beforeload : function (_self, o){
563 o.params = o.params || {};
568 sortInfo : { direction : 'ASC', field: 'salesrep_name' },
573 url : baseURL + '/Roo/salesrep.php'
580 totalProperty : 'total',
581 fields : [{"name":"salesrep_id","type":"int"},"salesrep_name"]
588 fieldLabel : 'Order Comments',
590 name : 'cohead_ordercomments',
600 style : 'width:420px',
613 beforeselect : function (combo, record, index)
615 // set _this.data values ..
617 // just add everything...
618 for(var i in record.data) {
619 _this.data['cohead_billto_cntct_id_' + i] = record.data[i];
622 _this.form.findField('billto_address').update();
627 add : function (combo)
630 Pman.Dialog.XtupleQuickContact.show(
633 customer_id : _this.form.findField('cohead_cust_id').getValue()
640 _this.data['cohead_billto_cntct_id_' + i] = data[i];
643 _this.form.findField('billto_address').update();
644 // fill in the select box..
645 _this.form.setValues( {
646 cohead_billto_cntct_id : data.cntct_id,
647 cohead_billto_cntct_id_cntct_name : data.cntct_first_name + ' '+
653 // Pman.Dialog.XtupleCustomer.show(
654 //{ cust_id : _this.form.findField('cohead_cust_id').getValue() },
656 // refresh the data in the pulldown..
663 displayField : 'cntct_name',
665 emptyText : "Select cntct",
666 fieldLabel : 'Bill To (select)',
667 forceSelection : true,
668 hiddenName : 'cohead_billto_cntct_id',
670 loadingText : "Searching...",
672 name : 'cohead_billto_cntct_id_cntct_name',
674 qtip : "Select cntct",
675 queryParam : 'query[cntct_name]',
676 selectOnFocus : true,
677 tpl : '<div class="x-grid-cell-text x-btn button"><b>{cntct_name}</b> {cntct_addr_id_addr_line1}</div>',
678 triggerAction : 'all',
680 valueField : 'cntct_id',
686 beforeload : function (_self, o){
687 o.params = o.params || {};
689 o.params._customer_id = _this.data.cohead_cust_id;
693 sortInfo : { direction : 'ASC', field: 'cntct_name' },
698 url : baseURL + '/Roo/cntct.php'
705 totalProperty : 'total',
706 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
714 render : function (_self)
720 this.el.on('click', function() {
721 var id = _this.form.findField('cohead_billto_cntct_id').getValue();
722 Pman.Dialog.XtupleQuickContact.show(
725 customer_id : _this.form.findField('cohead_cust_id').getValue()
732 _this.data['cohead_billto_cntct_id_' + i] = data[i];
735 _this.form.findField('billto_address').update();
736 // fill in the select box..
737 _this.form.setValues( {
738 cohead_billto_cntct_id : data.cntct_id,
739 cohead_billto_cntct_id_cntct_name : data.cntct_first_name + ' '+
749 Roo.log("Click text");
755 fieldLabel : 'or enter Address',
756 name : 'billto_address',
758 update : function() {
760 var c = ['first_name', 'last_name' ] ;
761 var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];
763 Roo.each(c, function(e) {
764 if (_this.data['cohead_billto_cntct_id_cntct_' +e].length) {
765 v.push(_this.data['cohead_billto_cntct_id_cntct_' +e]);
768 Roo.each(a, function(e) {
769 if (_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e].length) {
770 v.push(_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e]);
774 this.setValue(v.join("\n"));
776 if(_this.data.cohead_billto_cntct_id_cntct_email.length){
777 _this.form.findField('billto_email').setValue(_this.data.cohead_billto_cntct_id_cntct_email);
782 xtype: 'DisplayField',
784 fieldLabel : 'Email',
785 name : 'billto_email',
786 valueRenderer : function(v)
789 return v ? String.format('<a href="mailto:{0}" target="_blank">{0}</a>',v) : '';
802 style : 'margin-left:10px',
807 legend : "Price Details",
808 style : 'width:420px',
814 labelAlign : 'right',
822 labelSeparator : ' ',
829 beforequery : function (combo, query, forceAll, cancel, e)
831 Roo.log('beforequery');
833 if (_this.form.findField('cohead_number').getValue().length) {
834 Roo.MessageBox.alert("Error", "You can not change the currency of this order");
843 displayField : 'curr_name',
845 emptyText : "Select curr_name",
846 fieldLabel : 'Currency',
847 forceSelection : true,
848 hiddenName : 'cohead_curr_id',
850 loadingText : "Searching...",
852 name : 'cohead_curr_id_curr_name',
854 qtip : "Select Currency",
855 queryParam : 'query[curr_name]',
856 selectOnFocus : true,
857 tpl : '<div class="x-grid-cell-text x-btn button"><b>{curr_name}</b> </div>',
858 triggerAction : 'all',
860 valueField : 'curr_id',
866 beforeload : function (_self, o){
867 o.params = o.params || {};
873 sortInfo : { direction : 'ASC', field: 'curr_symbol' },
878 url : baseURL + '/Roo/curr_symbol.php'
885 totalProperty : 'total',
886 fields : [{"name":"curr_id","type":"int"},"curr_symbol"]
891 xtype: 'NumberField',
893 allowDecimals : true,
894 cls : 'roo-align-right',
895 decimalPrecision : 3,
896 fieldLabel : 'Products',
897 name : 'cohead_subtotal',
907 labelSeparator : ' ',
914 select : function (combo, record, index)
916 _this.form.findField('cohead_tax').setValue(
917 parseFloat(record.data.taxzone_rate) *
918 parseFloat(_this.form.findField('cohead_subtotal').getValue())
920 _this.form.findField('cohead_total').recalc();
924 displayField : 'taxzone_descrip',
926 emptyText : "Select taxtype",
927 fieldLabel : 'Tax Zone',
928 forceSelection : true,
929 hiddenName : 'cohead_taxzone_id',
931 loadingText : "Searching...",
933 name : 'cohead_taxzone_id_taxzone_descrip',
935 qtip : "Select taxtype",
936 queryParam : 'query[taxzone_descrip]',
937 selectOnFocus : true,
938 tpl : '<div class="x-grid-cell-text x-btn button"><b>{taxzone_descrip}</b> </div>',
939 triggerAction : 'all',
941 valueField : 'taxzone_id',
947 beforeload : function (_self, o){
948 o.params = o.params || {};
951 o.params.with_date = _this.form.findField('cohead_orderdate').getValue().format('Y-m-d');
952 Roo.log("with date?" + o.params.with_date);
958 sortInfo : { direction : 'ASC', field: 'taxzone_descrip' },
963 url : baseURL + '/Roo/taxzone.php'
970 totalProperty : 'total',
971 fields : [{"name":"taxzone_id","type":"int"},"taxzone_descrip"]
976 xtype: 'NumberField',
978 allowDecimals : true,
979 cls : 'roo-align-right',
980 decimalPrecision : 3,
989 xtype: 'NumberField',
991 allowDecimals : true,
992 cls : 'roo-align-right',
993 decimalPrecision : 3,
994 fieldLabel : 'Pre Tax discount',
995 name : 'cohead_pretax_discount',
1003 labelSeparator : ' ',
1009 fieldLabel : 'Discount after Tax Description',
1010 name : 'cohead_misc_descrip',
1014 xtype: 'NumberField',
1017 keyup : function (_self, e)
1019 var pv = parseFloat(_this.form.findField('cohead_subtotal').getValue());
1020 var tax = parseFloat(_this.form.findField('cohead_tax').getValue());
1021 var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());
1023 var n = this.getValue();
1024 var discount = parseFloat(n * (pv + tax + pd) * 0.01);
1026 _this.form.findField('cohead_posttax_discount').setValue(discount);
1028 _this.form.findField('cohead_total').recalc();
1029 _this.form.findField('cohead_misc').recalc();
1030 var val = discount * -1.0;
1032 _this.form.findField('cohead_misc_descrip').setValue("Discount of " + val.toFixed(1)+'%');
1038 allowDecimals : true,
1039 cls : 'roo-align-right',
1040 decimalPrecision : 1,
1042 name : 'cohead_misc_per',
1044 update : function() {
1045 var m = _this.form.findField('cohead_misc_per');
1046 var pv = parseFloat(_this.form.findField('cohead_subtotal').getValue());
1047 var tax = parseFloat(_this.form.findField('cohead_tax').getValue());
1048 var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());
1050 var discount = parseFloat(_this.form.findField('cohead_posttax_discount').getValue());
1052 if (discount > 0.0) {
1060 var val = ((discount) / (pv + tax + pd)) * -100;
1062 //Roo.log("update discount?" + val);
1063 this.setValue(val.toFixed(1));
1066 _this.form.findField('cohead_misc_descrip').setValue("Discount of " + val.toFixed(1)+'%');
1074 xtype: 'NumberField',
1077 keyup : function (_self, e)
1079 _this.form.findField('cohead_misc_per').update();
1080 _this.form.findField('cohead_total').recalc();
1081 _this.form.findField('cohead_misc').recalc();
1084 allowDecimals : true,
1085 cls : 'roo-align-right',
1086 decimalPrecision : 3,
1087 fieldLabel : ' ',
1088 name : 'cohead_posttax_discount',
1094 xtype: 'NumberField',
1096 allowDecimals : true,
1097 cls : 'roo-align-right',
1098 decimalPrecision : 3,
1099 fieldLabel : 'Total',
1100 name : 'cohead_total',
1103 recalc : function() {
1104 var d = _this.form.getValues();
1106 parseFloat(d.cohead_subtotal) +
1107 parseFloat(d.cohead_pretax_discount) +
1108 parseFloat(d.cohead_posttax_discount) +
1109 parseFloat(d.cohead_tax) +
1110 parseFloat(d.cohead_freight));
1114 xtype: 'NumberField',
1117 keyup : function (_self, e)
1119 _this.form.findField('cohead_total').recalc();
1122 allowDecimals : true,
1123 cls : 'roo-align-right',
1124 decimalPrecision : 3,
1125 fieldLabel : 'Shipping',
1126 name : 'cohead_freight',
1130 xtype: 'NumberField',
1132 allowDecimals : true,
1133 cls : 'roo-align-right',
1134 decimalPrecision : 3,
1135 fieldLabel : 'Unshipped Total',
1136 name : 'cohead_unshipped',
1141 xtype: 'NumberField',
1143 allowDecimals : true,
1144 cls : 'roo-align-right',
1145 decimalPrecision : 3,
1146 fieldLabel : 'Uninvoiced Total',
1147 name : 'cohead_uninvoiced',
1158 style : 'width:420px',
1159 legend : "Shipping",
1170 labelSeparator : ' ',
1176 check : function (_self, checked)
1182 if (_this.dataloading) {
1190 // copy the cohead_billto_cntct_id
1191 for (var i in _this.data) {
1192 if (!i.match(/^cohead_billto_cntct_id/)) {
1195 var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');
1196 _this.data[ni] = _this.data[i];
1198 _this.form.findField('shipto_address').update();
1199 _this.form.setValues( {
1200 cohead_shipto_cntct_id : _this.data.cohead_shipto_cntct_id,
1201 cohead_shipto_cntct_id_cntct_name : _this.data.cohead_shipto_cntct_id_cntct_first_name + ' ' +
1202 _this.data.cohead_shipto_cntct_id_cntct_last_name
1209 for (var i in _this.data) {
1210 if (!i.match(/^cohead_billto_cntct_id/)) {
1213 var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');
1215 _this.data[ni] = '';
1217 _this.form.findField('shipto_address').update();
1219 _this.form.setValues( {
1220 cohead_shipto_cntct_id : '',
1221 cohead_shipto_cntct_id_cntct_name : ''
1229 boxLabel : 'Same as Billing',
1230 name : '_shipto_same'
1238 add : function (combo)
1240 Pman.Dialog.XtupleQuickContact.show(
1243 customer_id : _this.form.findField('cohead_cust_id').getValue()
1248 for(var i in data) {
1250 _this.data['cohead_shipto_cntct_id_' + i] = data[i];
1253 _this.form.findField('shipto_address').update();
1254 // fill in the select box..
1255 _this.form.setValues( {
1256 cohead_shipto_cntct_id : data.cntct_id,
1257 cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1258 data.cntct_last_name
1264 beforeselect : function (combo, record, index)
1267 // just add everything...
1268 for(var i in record.data) {
1269 //Roo.log('cohead_shipto_cntct_id_' + i +' =' + record.data[i]);
1270 _this.data['cohead_shipto_cntct_id_' + i] = record.data[i];
1273 _this.form.findField('shipto_address').update();
1280 displayField : 'cntct_name',
1282 emptyText : "Select ship to",
1283 fieldLabel : 'Ship to',
1284 forceSelection : true,
1285 hiddenName : 'cohead_shipto_cntct_id',
1287 loadingText : "Searching...",
1289 name : 'cohead_shipto_cntct_id_cntct_name',
1291 qtip : "Select shiptoinfo",
1292 queryParam : 'query[cntct_name]',
1293 selectOnFocus : true,
1294 tpl : '<div class="x-grid-cell-text x-btn button">{cntct_name} - <b>{cntct_addr_id_addr_line1}</b> </div>',
1295 triggerAction : 'all',
1297 valueField : 'cntct_id',
1303 beforeload : function (_self, o){
1304 o.params = o.params || {};
1306 o.params._customer_id = _this.data.cohead_cust_id;
1310 sortInfo : { direction : 'ASC', field: 'cntct_name' },
1315 url : baseURL + '/Roo/cntct.php'
1318 xtype: 'JsonReader',
1322 totalProperty : 'total',
1323 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
1331 render : function (_self)
1337 this.el.on('click', function() {
1338 var id = _this.form.findField('cohead_shipto_cntct_id').getValue();
1339 Pman.Dialog.XtupleQuickContact.show(
1342 customer_id : _this.form.findField('cohead_cust_id').getValue()
1347 for(var i in data) {
1349 _this.data['cohead_shipto_cntct_id_' + i] = data[i];
1352 _this.form.findField('shipto_address').update();
1353 // fill in the select box..
1354 _this.form.setValues( {
1355 cohead_shipto_cntct_id : data.cntct_id,
1356 cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1357 data.cntct_last_name
1366 // Roo.log("Click text");
1372 fieldLabel : 'Address',
1373 name : 'shipto_address',
1376 update : function() {
1378 var c = ['first_name', 'last_name' ] ;
1379 var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];
1382 if (_this.data['cohead_shipto_vend_name'] && _this.data['cohead_shipto_vend_name'].length) {
1383 v.push(_this.data['cohead_shipto_vend_name']);
1385 if (_this.data['cohead_shipto_vendaddr_code'] && _this.data['cohead_shipto_vendaddr_code'].length) {
1386 v.push(_this.data['cohead_shipto_vendaddr_code']);
1388 Roo.each(c, function(e) {
1389 if (_this.data['cohead_shipto_cntct_id_cntct_' +e] &&
1390 _this.data['cohead_shipto_cntct_id_cntct_' +e].length) {
1391 v.push(_this.data['cohead_shipto_cntct_id_cntct_' +e]);
1394 Roo.each(a, function(e) {
1395 if (_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e] &&
1396 _this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e].length) {
1397 v.push(_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e]);
1401 this.setValue(v.join("\n"));
1407 fieldLabel : 'Shipment Comments',
1408 name : 'cohead_shipcomments',
1425 name : 'cohead_shipto_id'
1430 name : 'cohead_shipto_id_shipto_name'
1435 name : 'cohead_max_linenumber'
1440 name : 'cohead_cust_id'
1445 name : 'cohead_misc',
1446 recalc : function() {
1447 var d = _this.form.getValues();
1449 parseFloat(d.cohead_pretax_discount) +
1450 parseFloat(d.cohead_posttax_discount) );
1456 name : 'taxzone_rate'
1466 activate : function() {
1469 try { if (MODULE.isBuilder) {
1473 var id = _this.form.findField('cohead_id').getValue() * 1;
1475 Roo.MessageBox.alert("Save First", "Save the order first, before adding items");
1476 _this.dialog.layout.getRegion('center').showPanel(0);
1481 _this.grid.footer.onClick('first');
1483 //if (_this.form.findField('cohead_cust_id_cust_name').getValue() == 'Bloom and Grow HK') {
1484 // _this.xferAll.show();
1487 // _this.xferAll.hide();
1492 deactivate : function (_self)
1495 _this.grid.stopEditing();
1500 fitContainer : true,
1503 tableName : 'coitem',
1504 title : "Order Items",
1506 xtype: 'EditorGrid',
1512 //_this.dialog = Pman.Dialog.FILL_IN
1514 if (_this.panel.active) {
1515 this.footer.onClick('first');
1518 afteredit : function (e)
1520 Roo.log('afteredit:' + e.record.data.coitem_linenumber);
1523 // if ( e.record && e.record.data.coitem_id) {
1524 // as we disable update to the display on the ajax callback to
1525 // allow editing flow to continue, and not refresh - we can only update
1526 // these values after something has actually been edited.
1527 // e.record.set('coitem_id', e.record.data.coitem_id);
1528 // e.record.set('coitem_status', e.record.data.coitem_status);
1531 if (e.field == 'item_number' || e.originalValue == e.value) {
1532 // afterselect handles this...
1535 if (e.field == 'item_descrip1') {
1536 e.record.set('coitem_memo', e.value);
1538 var rate = _this.form.findField('taxzone_rate').getValue();
1540 case 'coitem_linedisc':
1542 var cp = parseFloat(e.record.data.coitem_custprice);
1544 if (isNaN(cp) || cp == 0.0) {
1548 var dis = parseFloat(e.value);
1556 Math.max(0,cp * ((100.0 - parseInt(e.value))/ 100.0) )
1559 // donot need to set the subtotal here, coz we will render it automatically
1561 // 'coitem_subtotal',
1562 // e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord
1566 case 'coitem_price': // SELL@ price
1568 var cp = parseFloat(e.record.data.coitem_custprice);
1569 // list price is < price -- update it..
1570 if (isNaN(cp) || cp == 0.0 || cp < e.value) {
1571 e.record.set('coitem_custprice', e.value);
1574 // update the discount calc.
1576 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( e.value / cp) * 100.0)));
1578 // donot need to set the subtotal here, coz we will render it automatically
1580 // 'coitem_subtotal',
1581 // e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord
1585 case 'coitem_custprice':
1586 // modified customer price...
1587 // just modify the discount.. -- leave the entered price the same..
1588 var sp = parseFloat(e.record.data.coitem_price);
1589 var cp = parseFloat(e.value);
1590 if (isNaN(cp) || cp == 0.0 || cp < e.value) {
1594 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1598 case 'coitem_custprice_tax':
1599 var cp = parseFloat(e.value / ( 1 + rate * 1 ));
1600 var sp = parseFloat(e.record.data.coitem_price);
1602 if (isNaN(cp) || cp == 0.0) {
1605 e.record.set('coitem_custprice', cp);
1606 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1610 case 'coitem_price_tax':
1612 var cp = parseFloat(e.record.data.coitem_custprice);
1613 var sp = parseFloat(e.value / ( 1 + rate * 1 ));
1614 if (isNaN(cp) || cp == 0.0 || cp < sp) {
1615 e.record.set('coitem_custprice', sp);
1618 e.record.set('coitem_price', sp);
1619 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
1628 var doupdate = function() {
1629 if (!e.record.updatePending) {
1630 Roo.log('doupdate...' + e.record.data.coitem_linenumber);
1635 Roo.log('doupdate pending...' + e.record.data.coitem_linenumber);
1636 // wait until it's not peding an update..
1637 doupdate.defer(500);
1640 if(e.record.data.coitem_id * 1 < 1 && !e.record.isInserting){ // insert
1641 e.record.isInserting = 1;
1642 e.record.isUpdating = 0;
1648 if(!e.record.isInserting && !e.record.isUpdating){
1649 e.record.isUpdating = 1;
1654 if(!e.record.updatePending){
1655 e.record.updatePending = 1;
1659 Roo.log("got to end without doing an update?" + e.record.data.coitem_linenumber);
1662 beforeedit : function (e)
1664 // we can only edit if nothing is assigned to shipping or invoices..
1668 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0 || (rec.data.shipitem_shipped - rec.data.coitem_qtyshipped) > 0 ) {
1669 Roo.MessageBox.alert("Error", "That item has been shipped, has a draft shipment or invoices - void the shipments/invoices first");
1674 if (rec.data.coitem_subnumber * 1 > 0) {
1675 Roo.log("Edit container event");
1676 Roo.log(e); // if it's a tab..
1680 // allow editing of source / destination..
1681 case 'coitem_shipto_id':
1682 case 'coitem_location_src':
1687 Roo.MessageBox.alert("Error", "That is a kit item, edit the container.");
1691 // zero off values..
1692 //if (e.field == 'coitem_qtyord' && rec.data.coitem_qtyord == 0) {
1695 // if (e.field == 'coitem_custprice' && rec.data.coitem_qtyord == 0.0) {
1699 if (rec.data.item_type == 'K' && e.field == 'item_number') {
1700 // you can not change the product type on kits' as it messing things up..
1701 Roo.MessageBox.alert("Error", "That is a kit item,if you need to change it, delete it first.");
1707 celldblclick : function (_self, rowIndex, columnIndex, e)
1709 var rec = this.ds.getAt(rowIndex);
1710 var di = this.cm.getDataIndex(columnIndex);
1711 if (di != 'avail_qty') {
1715 Pman.Dialog.XtupleInvHistory.show({
1716 itemsite_item_id_item_number : rec.data.item_number,
1717 // itemsite_item_id_item_descript1 : rec.data.item_descrip1,
1718 location_name : rec.data.coitem_location_src_location_name,
1719 location_descrip : rec.data.coitem_location_src_location_descrip,
1721 invhist_transdate : _this.form.findField('cohead_targetdate').getValue()
1725 rowclass : function (gridview, rowcfg)
1727 if (rowcfg.record.data.coitem_status == 'C' &&
1728 rowcfg.record.data.shipitem_shipped * 1 < 1) {
1730 rowcfg.rowClass = 'strikethrough';
1732 if (rowcfg.record.data.coitem_status == 'X' ) {
1734 rowcfg.rowClass = 'strikethrough';
1737 if (!rowcfg.record.data.coitem_id) {
1738 rowcfg.rowClass = 'dragon-not-saved';
1746 autoExpandColumn : 'item_descrip1',
1749 loadAvail : function() {
1752 this.ds.each(function(r) {
1754 if(!r.data.item_number.length){
1758 if(typeof(_this.stockcache[r.data.item_number]) != 'undefined'){
1760 r.set('avail_qty', _this.stockcache[r.data.item_number].qty);
1761 if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {
1762 r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);
1770 item : r.data.item_number,
1771 loc: r.data.coitem_location_src_location_name,
1772 id: r.data.coitem_linenumber + (r.data.coitem_subnumber ? ('.' + r.data.coitem_subnumber) : '')
1776 url : baseURL + '/Roo/itemloc',
1779 _availqty : Roo.encode(q),
1780 curr_name : _this.form.findField('cohead_curr_id').el.dom.value
1782 success : function(res)
1784 for (var i in res.data) {
1785 _this.stockcache[res.data[i].item] = res.data[i];
1787 r.set('avail_qty', _this.stockcache[r.data.item_number].qty);
1788 if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {
1789 r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);
1791 //_this.grid.ds.fireEvent("update", _this.grid.ds, r, Roo.data.Record.EDIT);
1800 xtype: 'CellSelectionModel',
1803 tabend : function (_self)
1805 _this.addItemBtn.fireEvent('click', _this.addItemBtn);
1807 beforeeditnext : function (eventdata)
1811 // this does not work, as the reload effect cancels editng.
1812 var rec = _this.grid.ds.getAt(eventdata.cell[0]);
1813 if (rec.data.coitem_subnumber *1 < 0 ) {
1816 var r = eventdata.cell[0] + 1;
1819 if (r > _this.grid.ds.getCount()-1 ) {
1820 eventdata.cell = false;
1823 rec = _this.grid.ds.getAt(r);
1824 if (rec.data.coitem_subnumber *1 < 0 ) {
1825 eventdata.cell = [ r, eventdata.cell[1] ];
1839 xtype: 'PagingToolbar',
1842 emptyMsg : "No Items",
1844 updateSummary : function() {
1847 url : baseURL + '/Roo/Coitem',
1851 coitem_cohead_id : _this.form.findField('cohead_id').getValue()
1853 success : function(d) {
1855 f.displayEl.update(String.format(
1856 "{0} items | Subtotal: {2} | Tax: {3} | List Discount {4} | Total : {1}{5}",
1858 _this.form.findField('cohead_curr_id').el.dom.value,
1861 d.data.total_list_discount,
1873 click : function (_self, e)
1876 url : baseURL + '/Roo/Cohead',
1879 _fill_shipto : _this.form.findField('cohead_id').getValue()
1881 success : function() {
1882 _this.grid.footer.onClick('first');
1887 text : "Fill empty Ship To"
1893 click : function (_self, e)
1895 Roo.MessageBox.confirm("Confirm", "Are you sure?<BR>"+
1896 "This will set all the locations to match the Sales Order - and remove all old locations.",
1903 url : baseURL + '/Roo/Cohead',
1906 _fill_location : _this.form.findField('cohead_id').getValue(),
1907 _location_id : _this.form.findField('cohead_location_src').getValue()
1909 success : function() {
1910 _this.grid.footer.onClick('first');
1917 text : "Update Location to match S/O"
1923 toggle : function (_self, pressed)
1925 this.setText(pressed ? "Prices exc GST" : "Prices with GST");
1926 var cm = _this.grid.getColumnModel();
1928 cm.setHidden(cm.getIndexByDataIndex('coitem_price_tax'), pressed ? false : true);
1929 cm.setHidden(cm.getIndexByDataIndex('coitem_custprice_tax'), pressed ? false : true);
1930 cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal_tax'), pressed ? false : true);
1932 cm.setHidden(cm.getIndexByDataIndex('coitem_price'), pressed ? true : false);
1933 cm.setHidden(cm.getIndexByDataIndex('coitem_custprice'), pressed ? true : false);
1934 cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal'), pressed ? true : false);
1937 render : function (_self)
1939 _this.showgstBtn = _self;
1942 enableToggle : true,
1944 text : "Prices with GST"
1952 beforeload : function (_self,o) {
1959 if (!_this.data || !_this.data.cohead_id) {
1962 o.params = o.params || {};
1964 o.params.coitem_cohead_id = _this.data.cohead_id;
1965 o.params._without_list_discount =1;
1966 //o.params.limit = 999;
1970 update : function (_self, rec, operation)
1973 if (operation != Roo.data.Record.COMMIT) {
1977 // row has been updated..
1978 // if the qty + item has been filled in, we should try and save it..
1981 var setRecord = function(){
1983 Roo.log("Clearing update?" + rec.data.coitem_linenumber);
1984 rec.updatePending = 0;
1985 if(rec.isInserting){
1986 rec.isInserting = 0;
1992 if (!(rec.data.coitem_itemsite_id * 1) || !(rec.data.coitem_qtyord*1)) {
1996 var doCommit = function() {
1997 Roo.log("Sending data?" + rec.data.coitem_linenumber);
2000 url : baseURL+'/Roo/coitem',
2003 success: function(res)
2006 var row = _this.grid.ds.indexOf(rec);
2007 Roo.get(_this.grid.view.getRow(row)).removeClass('dragon-not-saved');
2013 Roo.log("GOT success: " + rec.data.coitem_linenumber);
2014 //Roo.log("GOT success");
2015 // update the data...
2017 if (rec.data.item_type == 'K') {
2019 _this.grid.ds.load({});
2024 // why is this here.??
2026 if (_this.grid.activeEditor) {
2032 rec.set('coitem_id', res.data.coitem_id);
2033 rec.set('coitem_status', res.data.coitem_status);
2037 delete rec.modified;
2039 _this.grid.footer.updateSummary();
2040 _this.grid.loadAvail();
2046 failure : function(res)
2049 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error updating");
2062 load : function (_self, records, options)
2064 // need to fetch availablity from master data..
2065 // build a list of what to ask..
2067 // query: ITEM CODE - LOCATION
2068 _this.grid.footer.updateSummary();
2069 _this.grid.loadAvail.defer(100, _this.grid);
2077 sortInfo : { field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' },
2082 url : baseURL + '/Roo/coitem.php'
2085 xtype: 'JsonReader',
2089 totalProperty : 'total',
2092 'name': 'coitem_linenumber',
2096 'name': 'coitem_itemsite_id',
2100 'name': 'coitem_qtyord'
2103 'name': 'coitem_unitcost'
2106 'name': 'coitem_price'
2109 'name': 'coitem_custprice'
2112 'name': 'coitem_qtyreturned'
2115 'name': 'coitem_prcost'
2118 'name': 'coitem_price_uom_id',
2122 'name': 'coitem_qtyreserved'
2138 Roo.log("add presed");
2141 var grid = _this.grid;
2143 grid.ds.each(function(r) {
2144 if (r.data.coitem_qtyord < 1) {
2145 Roo.MessageBox.alert("Error", "you must fill in a quantity for " + r.data.item_number);
2157 var last = _this.form.findField('cohead_max_linenumber').getValue();
2164 _this.form.findField('cohead_max_linenumber').setValue(last);
2166 // this should be getting the previous row..??
2167 var ct = _this.grid.ds.getCount();
2168 var lastrow = ct ? _this.grid.ds.getAt(ct-1) : false;
2170 function lastor(k,d,kk) {
2171 var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();
2172 return lastrow ? lastrow.data[kk] : def;
2175 // uses form defaults or last row value.
2176 var nr = _this.grid.ds.reader.newRow({
2177 coitem_linenumber : last,
2181 coitem_cohead_id : _this.form.findField('cohead_id').getValue(),
2182 coitem_qtyshipped : 0,
2183 coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),
2184 coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),
2185 coitem_shipto_id : lastor('cohead_shipto_id',false, 'coitem_shipto_id'),
2186 coitem_shipto_id_shipto_name : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name'),
2187 coitem_unitcost_in_order_cur : 0,
2188 coitem_taxtype_id : _this.data.default_taxtype_id,
2189 coitem_taxtype_id_taxtype_name : 'Taxable',
2195 grid.ds.insert(grid.ds.getCount(), nr);
2196 grid.startEditing(grid.ds.getCount()-1, 1); // type..
2197 nr.updatePending = 0;
2202 render : function (_self)
2204 _this.addItemBtn = _self;
2207 cls : 'x-btn-text-icon',
2209 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
2215 click : function (_self, e)
2217 var last = _this.form.findField('cohead_max_linenumber').getValue();
\r
2219 _this.form.findField('cohead_max_linenumber').setValue(last);
2221 var ct = _this.grid.ds.getCount();
\r
2222 var lastrow = ct ? _this.grid.ds.getAt(ct-1) : false;
\r
2224 function lastor(k,d,kk) {
\r
2225 var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();
\r
2226 return lastrow ? lastrow.data[kk] : def;
\r
2229 var cohead_cust_id = _this.form.findField('cohead_cust_id').getValue();
2230 var cohead_id = _this.form.findField('cohead_id').getValue();
2232 Pman.Dialog.XtupleSalesProductList.show( {cohead_cust_id : cohead_cust_id, cohead_id : cohead_id} , function(res) {
2234 _this.grid.stopEditing();
2236 if (_this.grid.ds.getCount() > 0) {
2237 var lr = _this.grid.ds.getAt(_this.grid.ds.getCount()-1);
2238 if (!lr.data.coitem_itemsite_id) {
2239 lr.set('coitem_itemsite_id', res.item_itemsite_id_itemsite_id);
2240 lr.set('item_number', res.item_number);
2241 lr.set('item_descrip1', res.item_descrip1);
2242 lr.set('coitem_listprice', res.item_price);
2243 lr.set('coitem_price', res.item_price);
2244 lr.set('coitem_custprice', res.item_price);
2251 var nr = _this.grid.ds.reader.newRow({
2252 coitem_linenumber : last,
2253 coitem_itemsite_id : res.item_itemsite_id_itemsite_id,
2254 item_number : res.item_number,
2255 item_descrip1 : res.item_descrip1,
2257 coitem_cohead_id : _this.form.findField('cohead_id').getValue(),
2258 coitem_qtyshipped : 0,
2259 coitem_listprice : res.item_price,
2260 coitem_price : res.item_price,
2261 coitem_custprice : res.item_price,
2263 coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),
2264 coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),
2265 coitem_shipto_id : lastor('cohead_shipto_id',false, 'coitem_shipto_id'),
2266 coitem_shipto_id_shipto_name : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name')
2269 _this.grid.ds.insert(_this.grid.ds.getCount(), nr);
2274 cls : 'x-btn-text-icon',
2275 text : "Find Products",
2276 icon : rootURL + '/Pman/templates/images/search.gif'
2286 url : baseURL + '/Roo/coitem',
2287 mask : 'Loading Data',
2291 _hk_xfer :_this.form.findField('cohead_id').getValue()
2293 success : function() {
2294 _this.grid.ds.load({});
2299 render : function (_self)
2301 _this.xferAll = _self;
2304 cls : 'x-btn-text-icon',
2306 text : "Xfer all stock to HK",
2307 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
2313 click : function (_self, e)
2315 var c = _this.grid.getSelectionModel().getSelectedCell();
2317 Roo.MessageBox.alert("Error", "Select item to show history (you can also double click on the #avail number) ");
2321 var rec = _this.grid.ds.getAt(c[0]);
2323 Pman.Dialog.XtupleInvHistory.show({
2324 itemsite_item_id_item_number : rec.data.item_number,
2325 // itemsite_item_id_item_descript1 : rec.data.item_descrip1,
2326 location_name : rec.data.coitem_location_src_location_name,
2327 location_descrip : rec.data.coitem_location_src_location_descrip,
2330 invhist_transdate : _this.form.findField('cohead_targetdate').getValue()
2336 text : "Show Inventory History"
2345 text : "Apply % Discount of : "
2351 render : function (_self)
2353 _this._applyDiscount = _self;
2362 click : function (_self, e)
2364 var val = parseFloat(_this._applyDiscount.getValue());
2366 var factor = (100.0 - val)/100.0;
2368 _this.grid.ds.each(function(rec) {
2369 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2373 rec.set('coitem_price', rec.data.coitem_custprice * factor);
2374 rec.set('coitem_linedisc', val);
2375 rec.set('coitem_subtotal', rec.data.coitem_price & rec.data.ordqty);
2383 text : "Apply To All"
2389 click : function (_self, e)
2392 if (!(1* _this.form.findField('cohead_id').getValue())) {
2393 Roo.MessageBox.alert("Error", "save the order first");
2397 Pman.Dialog.Image.show(
2400 _url : baseURL+'/Xtuple/Import/SalesOrder',
2401 onid : _this.form.findField('cohead_id').getValue()
2406 Roo.MessageBox.alert("Notice", "Uploaded");
2407 _this.grid.footer.onClick('first');
2425 _this.grid.stopEditing();
2426 // check that no shipments or invoices are done..
2427 var rc = _this.grid.getSelectionModel().getSelectedCell();
2429 var rec = _this.grid.ds.getAt(rc[0]);
2431 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2432 Roo.MessageBox.alert("Error", "That item has been shipped or invoices - void the shipments/invoices first");
2435 if (rec.data.coitem_subnumber*1 > 0) {
2436 Roo.MessageBox.alert("Error", "Delete the kit item that that belongs to.");
2439 if (!rec.data.coitem_id) {
2440 _this.grid.ds.remove(rec);
2447 url : baseURL + '/Roo/coitem',
2450 _delete : rec.data.coitem_id
2453 success : function() {
2454 if (rec.data.item_type == 'K') {
2455 _this.grid.ds.load({});
2458 _this.grid.ds.remove(rec);
2463 if (rec.data_qtyord * 1 < 1) {
2467 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that line?", function(r)
2480 cls : 'x-btn-text-icon',
2482 icon : rootURL + '/Pman/templates/images/trash.gif'
2490 _this.grid.stopEditing();
2491 // check that no shipments or invoices are done..
2493 _this.grid.ds.each(function(rec) {
2497 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2498 //Roo.MessageBox.alert("Error", "That item has been shipped or invoices - void the shipments/invoices first");
2501 if (rec.data.item_type == 'K') {
2505 if (rec.data.coitem_subnumber*1 > 0) {
2506 //Roo.MessageBox.alert("Error", "Delete the kit item that that belongs to.");
2509 if (!rec.data.coitem_id) {
2510 _this.grid.ds.remove(rec);
2513 ids.push(rec.data.coitem_id);
2519 url : baseURL + '/Roo/coitem',
2522 _delete : ids.join(',')
2525 success : function() {
2527 _this.grid.footer.onClick('first');
2532 // if (rec.data_qtyord * 1 < 1) {
2536 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete everything?", function(r)
2549 cls : 'x-btn-text-icon',
2550 text : "Delete All",
2551 icon : rootURL + '/Pman/templates/images/trash.gif'
2557 xtype: 'ColumnModel',
2559 dataIndex : 'coitem_linenumber',
2562 renderer : function(v,x,r) {
2564 if (r.data.coitem_subnumber * 1 > 0) {
2565 return String.format('{0}.{1}', v,r.data.coitem_subnumber);
2567 return String.format('{0}', v);
2571 xtype: 'ColumnModel',
2573 dataIndex : 'item_number',
2574 header : 'Item Code',
2576 renderer : function(v) { return String.format('{0}', v); },
2578 xtype: 'GridEditor',
2584 beforeselect : function (combo, record, index)
2586 // set _this.data values ..
2587 var ar = _this.grid.activeEditor.record;
2588 // Roo.log('beforeselect');
2592 // Roo.log('beforeselect-cb');
2593 ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
2594 ar.set('coitem_listprice', record.data.item_listprice);
2595 ar.set('coitem_price', record.data.item_price);
2596 ar.set('coitem_custprice', record.data.item_price);
2597 ar.set('coitem_itemsite_id', record.data.itemsite_id);
2598 ar.set('item_number', record.data.itemsite_item_id_item_number);
2599 ar.set('item_type', record.data.itemsite_item_id_item_type);
2600 ar.set('avail_qty', 0);
2607 displayField : 'itemsite_item_id_item_number',
2609 emptyText : "Select item",
2610 forceSelection : true,
2611 hiddenName : 'itemsite_item_id_item_number',
2613 loadingText : "Searching...",
2615 name : 'item_number',
2617 qtip : "Select item",
2618 queryParam : 'query[number]',
2619 selectOnFocus : true,
2620 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>',
2621 triggerAction : 'all',
2623 valueField : 'item_number',
2628 beforeload : function (_self, o){
2629 o.params = o.params || {};
2630 o.params.customer_id = _this.form.findField('cohead_cust_id').getValue();
2631 o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue();
2632 //o.params.shipto_cust_id = _this.data.cohead_cust_id;
2637 sortInfo : { direction : 'ASC', field: 'item_number' },
2642 url : baseURL + '/Roo/itemsite.php'
2645 xtype: 'JsonReader',
2649 totalProperty : 'total',
2650 fields : [{"name":"item_id","type":"int"},"item_number"]
2657 xtype: 'ColumnModel',
2659 dataIndex : 'coitem_location_src',
2662 renderer : function(v,x,r) {
2663 return String.format('{0}', r.data.coitem_location_src_location_name);
2666 xtype: 'GridEditor',
2672 beforeselect : function (combo, record, index)
2674 // set _this.data values ..
2675 var ar = _this.grid.activeEditor.record;
2679 //Roo.log('beforeselect');
2683 // Roo.log('beforeselect-cb');
2684 ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
2685 ar.set('coitem_price', record.data.item_listprice);
2686 ar.set('coitem_custprice', record.data.item_price);
2687 ar.set('coitem_itemsite_id', record.data.itemsite_id);
2688 ar.set('item_number', record.data.itemsite_item_id_item_number);
2697 displayField : 'location_name',
2699 emptyText : "Select location",
2700 forceSelection : true,
2701 hiddenName : 'coitem_location_src',
2703 loadingText : "Searching...",
2705 name : 'coitem_location_src_location_name',
2707 qtip : "Select item",
2708 queryParam : 'query[location_name]',
2709 selectOnFocus : true,
2710 tpl : '<div class="x-grid-cell-text x-btn button"><b> {location_name}</b> {location_descrip}</div>',
2711 triggerAction : 'all',
2713 valueField : 'location_id',
2718 beforeload : function (_self, o){
2719 o.params = o.params || {};
2721 var row = _this.grid.activeEditor.record;
2723 o.params['query[item_itemsite_id]'] = row.data.coitem_itemsite_id;
2724 // need to know the date to calc the est. delivery time..
2725 //o.params['query[avail_when]'] = _this.form.findField('cohead_targetdate').getValue().format('Y-m-d');
2726 //o.params.location_netable = 1;
2727 o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue();
2729 o.params.location_restrict = 0;
2730 o.params._notinternalcompany = 1;
2734 // o.params.itemsite_id = _this.form.findField('cohead_cust_id').getValue();
2735 //o.params.shipto_cust_id = _this.data.cohead_cust_id;
2740 sortInfo : { direction : 'ASC', field: 'location_name' },
2745 url : baseURL + '/Roo/location.php'
2748 xtype: 'JsonReader',
2752 totalProperty : 'total',
2753 fields : [{"name":"location_id","type":"int"},"location_name"]
2760 xtype: 'ColumnModel',
2762 dataIndex : 'coitem_shipto_id',
2765 renderer : function(v,x,r) {
2766 return String.format('{0}:{1}', v, r.data.coitem_shipto_id_shipto_name);
2769 xtype: 'GridEditor',
2775 add : function (combo)
2778 Pman.Dialog.XtupleCustomer.show({ cust_id : _this.form.findField('cohead_cust_id').getValue() }, function(data) {
2779 // refresh the data in the pulldown..
2782 beforeselect : function (combo, record, index)
2786 for(var i = 1; i <4; i++) {
2787 _this.data['cohead_shiptoaddress'+ i] = record.data['cntct_addr_id_addr_line'+i];
2789 _this.form.findField('shipto_address').update();
2796 displayField : 'shipto_name',
2798 emptyText : "Select cntct",
2799 forceSelection : true,
2800 hiddenName : 'cohead_shipto_id',
2802 loadingText : "Searching...",
2804 name : 'coitem_shipto_id_shipto_name',
2806 qtip : "Select shipto",
2807 queryParam : 'query[shipto_name]',
2808 selectOnFocus : true,
2809 tpl : '<div class="x-grid-cell-text x-btn button"><b>{shipto_id}:{shipto_addr_id_addr_name}</b> </div>',
2810 triggerAction : 'all',
2812 valueField : 'shipto_id',
2818 beforeload : function (_self, o){
2819 o.params = o.params || {};
2820 o.params.shipto_cust_id = _this.data.cohead_cust_id;
2821 //o.params['query[with_shipinfo]'] = 1;
2826 sortInfo : { direction : 'ASC', field: 'shipto_name' },
2831 url : baseURL + '/Roo/shiptoinfo.php'
2834 xtype: 'JsonReader',
2838 totalProperty : 'total',
2839 fields : [{"name":"cntct_id","type":"int"},"cntct_name"]
2846 xtype: 'ColumnModel',
2848 dataIndex : 'item_descrip1',
2849 header : 'Item Description',
2851 renderer : function(v,x,r) {
2853 if (r.data.coitem_memo && r.data.coitem_memo.length) {
2854 return String.format('{0}', r.data.coitem_memo);
2855 if (r.data.coitem_memo != v) {
2856 r.set('item_descrip1', r.data.coitem_memo);
2860 if (v && v.length > 49) {
2861 return String.format('<span style="color:orange" qtip="line may be too long to print">{0}</span>', v);
2864 return String.format('{0}', v);
2868 xtype: 'GridEditor',
2878 xtype: 'ColumnModel',
2881 dataIndex : 'coitem_status',
2884 renderer : function(v) { return String.format('{0}', v); }
2887 xtype: 'ColumnModel',
2890 dataIndex : 'coitem_qtyord',
2893 renderer : function(v,x,r) {
2894 var v = parseInt(v);
2895 //var aq = parseInt(r.data.avail_qty);
2896 //aq = isNaN(aq) ? 0 : aq;
2898 var rate = _this.form.findField('taxzone_rate').getValue();
2899 r.data.coitem_subtotal = v * r.data.coitem_price;
2900 r.data.coitem_subtotal_tax = v * r.data.coitem_price * ( 1 + rate * 1);
2901 return String.format('{0}', v);
2905 xtype: 'GridEditor',
2908 xtype: 'NumberField',
2911 focus : function (_self)
2913 if (this.value == 0) {
2914 this.el.dom.value = '';
2918 allowDecimals : false,
2919 decimalPrecision : 0,
2921 style : 'text-align:right'
2926 xtype: 'ColumnModel',
2929 dataIndex : 'coitem_price',
2932 renderer : function(v,x,r) {
2934 var rate = _this.form.findField('taxzone_rate').getValue();
2935 r.data.coitem_subtotal = v * r.data.coitem_qtyord;
2936 r.data.coitem_subtotal_tax = v * ( 1 + rate * 1 ) * r.data.coitem_qtyord;
2937 r.data.coitem_price_tax = v * ( 1 + rate * 1 );
2938 if (parseInt(v) < 1) {
2939 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,3));
2943 //r.set('coitem_subtotal', v * r.data.coitem_qtyord);
2945 return String.format('{0}', Roo.util.Format.number(v,3));
2948 xtype: 'GridEditor',
2951 xtype: 'NumberField',
2954 focus : function (_self)
2956 if (this.value == 0.0) {
2957 this.el.dom.value = '';
2961 decimalPrecision : 3,
2963 style : 'text-align:right'
2968 xtype: 'ColumnModel',
2971 dataIndex : 'coitem_price_tax',
2972 header : 'Sell @w/GST',
2975 renderer : function(v,x,r) {
2977 if (parseInt(v) < 1) {
2978 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,3));
2981 return String.format('{0}', Roo.util.Format.number(v,3));
2984 xtype: 'GridEditor',
2987 xtype: 'NumberField',
2990 focus : function (_self)
2992 if (this.value == 0.0) {
2993 this.el.dom.value = '';
2997 decimalPrecision : 3,
2999 style : 'text-align:right'
3004 xtype: 'ColumnModel',
3007 dataIndex : 'coitem_linedisc',
3010 renderer : function(v,x,r) {
3012 // coitem_custprice = coitem_price * ((100 - coitem_disc)/ 100)
3014 // 12 * (( 100 - 0) / 100)
3015 // coitem_custprice / coitem_price = ((100 - coitem_disc)/ 100)
3016 // 100 - ((coitem_custprice / coitem_price) * 100) = coitem_disc
3017 // 100 - 97 = 100 -3
3019 // r.data.coitem_linedisc = 100 - (
3020 // (parseFloat(r.data.coitem_custprice) /
3021 // parseFloat(r.data.coitem_price)
3023 var fl = parseFloat(r.data.coitem_linedisc);
3024 if ( isNaN(fl) || fl == 0.0 || r.data.coitem_price > r.data.coitem_custprice) {
3027 return String.format('<span style="color:green">{0}%</span>', Roo.util.Format.number( r.data.coitem_linedisc,2));
3030 xtype: 'GridEditor',
3033 xtype: 'NumberField',
3036 focus : function (_self)
3038 if (this.value == 0.0) {
3039 this.el.dom.value = '';
3043 decimalPrecision : 2,
3046 style : 'text-align:right'
3051 xtype: 'ColumnModel',
3054 dataIndex : 'coitem_custprice',
3055 header : 'List Price',
3057 renderer : function(v,x,r) {
3059 var rate = _this.form.findField('taxzone_rate').getValue();
3060 r.data.coitem_custprice_tax = v * ( 1 + rate * 1 );
3062 var tip = 'No WRP available';
3063 if ((r.data.coitem_wrpprice * 1) > 0) {
3064 tip = "WRP : " + Roo.util.Format.number(r.data.coitem_wrpprice,3);
3066 // less than zero, show as red..
3067 if (parseFloat(v) < 1) {
3068 return String.format('<b qtip="{1}" style="color:red;">{0}</b>',
3069 Roo.util.Format.number(v,3), tip);
3071 if (r.data.customer_price_each != v) {
3072 return String.format('<b qtip="{1}" style="color:pink;">{0}</b>',
3073 Roo.util.Format.number(v,3),
3074 "List Price = " + Roo.util.Format.number(r.data.customer_price_each,3)
3080 //r.data.coitem_subtotal = v * r.data.coitem_qtyord;
3082 //r.set('coitem_subtotal', v * r.data.coitem_qtyord);
3084 return String.format('<span qtip="{1}">{0}</span>', Roo.util.Format.number(v,3), tip);
3087 xtype: 'GridEditor',
3090 xtype: 'NumberField',
3093 focus : function (_self)
3095 if (this.value == 0.0) {
3096 this.el.dom.value = '';
3100 decimalPrecision : 3,
3102 style : 'text-align:right'
3107 xtype: 'ColumnModel',
3110 dataIndex : 'coitem_custprice_tax',
3111 header : 'List Price w/GST',
3114 renderer : function(v,x,r) {
3115 var rate = _this.form.findField('taxzone_rate').getValue();
3116 var tip = 'No WRP available';
3117 if ((r.data.coitem_wrpprice * 1) > 0) {
3118 tip = "WRP : " + Roo.util.Format.number(r.data.coitem_wrpprice,3);
3121 if (parseFloat(v) < 1) {
3122 return String.format('<b qtip="{1}" style="color:red;">{0}</b>',
3123 Roo.util.Format.number(v,3), tip);
3125 if (r.data.customer_price_each != v) {
3126 return String.format('<b qtip="{1}" style="color:pink;">{0}</b>',
3127 Roo.util.Format.number(v,3),
3128 "List Price = " + Roo.util.Format.number(r.data.customer_price_each * ( 1 + rate * 1 ),3)
3132 return String.format('<span qtip="{1}">{0}</span>', Roo.util.Format.number(v,3), tip);
3135 xtype: 'GridEditor',
3138 xtype: 'NumberField',
3141 focus : function (_self)
3143 if (this.value == 0.0) {
3144 this.el.dom.value = '';
3148 decimalPrecision : 3,
3150 style : 'text-align:right'
3155 xtype: 'ColumnModel',
3158 dataIndex : 'coitem_subtotal',
3159 header : 'SubTotal',
3161 renderer : function(v) {
3163 if (parseInt(v) < 1) {
3164 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,2));
3169 return Roo.util.Format.number( v, 2);
3173 xtype: 'ColumnModel',
3176 dataIndex : 'coitem_subtotal_tax',
3177 header : 'SubTotal w/GST',
3180 renderer : function(v,x,r) {
3182 if (parseInt(v) < 1) {
3183 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,2));
3186 return String.format('{0}', Roo.util.Format.number(v,2));
3190 xtype: 'ColumnModel',
3193 dataIndex : 'coitem_unitcost_in_order_cur',
3194 header : 'Unit Cost',
3196 renderer : function(v) { return Roo.util.Format.number( v, 2); }
3199 xtype: 'ColumnModel',
3202 dataIndex : 'coitem_taxtype_id',
3205 renderer : function(v,x,r) { return String.format('{0}', r.data.coitem_taxtype_id_taxtype_name); },
3207 xtype: 'GridEditor',
3213 displayField : 'taxtype_name',
3215 emptyText : "Select Tax Type",
3216 forceSelection : true,
3217 hiddenName : 'coitem_taxtype_id',
3219 loadingText : "Searching...",
3221 name : 'coitem_taxtype_id_taxtype_name',
3223 qtip : "Select taxtype",
3224 queryParam : 'query[taxtype_id]',
3225 selectOnFocus : true,
3226 tpl : '<div class="x-grid-cell-text x-btn button"><b>{taxtype_name}</b> </div>',
3227 triggerAction : 'all',
3229 valueField : 'taxtype_id',
3235 beforeload : function (_self, o){
3236 o.params = o.params || {};
3243 sortInfo : { direction : 'ASC', field: 'taxtype_name' },
3248 url : baseURL + '/Roo/taxtype.php'
3251 xtype: 'JsonReader',
3255 totalProperty : 'total',
3256 fields : [{"name":"taxtype_id","type":"int"},"taxtype_name"]
3263 xtype: 'ColumnModel',
3266 dataIndex : 'avail_qty',
3269 renderer : function(v,x,r) {
3271 var oq = parseInt(r.data.coitem_qtyord);
3272 var aq = parseInt(r.data.avail_qty);
3273 var sq = parseInt(r.data.coitem_qtyshipped);
3274 aq = isNaN(aq) ? 0 : aq;
3275 oq = isNaN(oq) ? 0 : oq;
3276 sq = isNaN(sq) ? 0 : sq;
3278 var unshipped = oq - sq;
3280 if ( aq < 0 || (unshipped > 0 && aq < unshipped)) {
3281 return String.format('<b style="color:red;">{0}</b>', parseInt(aq));
3284 return String.format('{0}', aq);
3289 xtype: 'ColumnModel',
3292 dataIndex : 'shipitem_shipped',
3293 header : '#reserved',
3295 renderer : function(v,x,r) {
3298 var vv = parseInt(v);
3299 vv = isNaN(vv) ? 0 : vv;
3301 var ov = parseInt(r.data.coitem_qtyord);
3302 ov = isNaN(ov) ? 0 : ov;
3304 var qs = parseInt(r.data.coitem_qtyshipped);
3305 qs = isNaN(qs) ? 0 : qs;
3310 // not enough reserved yet.
3311 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv - qs);
3314 return String.format('{0}', vv - qs);
3319 xtype: 'ColumnModel',
3322 dataIndex : 'coitem_qtyshipped',
3323 header : '#shipped',
3325 renderer : function(v,x,r) {
3327 var vv = parseInt(v);
3328 vv = isNaN(vv) ? 0 : vv;
3330 var ov = parseInt(r.data.coitem_qtyord);
3331 ov = isNaN(ov) ? 0 : ov;
3335 // not enought shipped.
3336 // or too many shipped.
3337 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv);
3342 return String.format('{0}', vv);
3347 xtype: 'ColumnModel',
3350 dataIndex : 'cobill_billed',
3351 header : '#invoiced',
3353 renderer : function(v,x,r) {
3355 var vv = parseInt(v);
3356 vv = isNaN(vv) ? 0 : vv;
3358 var ov = parseInt(r.data.coitem_qtyord);
3359 ov = isNaN(ov) ? 0 : ov;
3363 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv);
3365 return String.format('{0}', vv);
3373 xtype: 'NestedLayoutPanel',
3376 activate : function (_self)
3378 _this.shipinvtab = _self;
3382 title : "Shipments / Invoices",
3384 xtype: 'BorderLayout',
3391 activate : function() {
3392 _this.shippanel = this;
3393 if (_this.shipgrid) {
3394 _this.shipgrid.ds.load({});
3399 fitContainer : true,
3402 tableName : 'shiphead',
3410 _this.shipgrid = this;
3411 //_this.dialog = Pman.Dialog.FILL_IN
3412 if (_this.shippanel.active) {
3416 rowdblclick : function (_self, rowIndex, e)
3418 var rec = this.ds.getAt(rowIndex);
3419 if (!rec.json.shiphead_shipdate.length) {
3420 Roo.MessageBox.alert("Error", "You can not edit voided shipments, create a new one, and use the restore feature");
3424 Pman.Dialog.XtupleShipment.show({
3425 shiphead_id : rec.data.shiphead_id
3434 autoExpandColumn : 'shiphead_shipvia',
3437 xtype: 'RowSelectionModel',
3445 beforeload : function (_self, options)
3447 options.params = options.params || {};
3448 options.params.shiphead_order_id = _this.form.findField('cohead_id').getValue() * 1;
3449 if (options.params.shiphead_order_id < 1) {
3455 sortInfo : { field : 'shiphead_shipvia', direction: 'ASC' },
3460 url : baseURL + '/Roo/shiphead.php'
3463 xtype: 'JsonReader',
3465 totalProperty : 'total',
3470 'name': 'shiphead_number',
3474 'name': 'shiphead_shipvia',
3478 'name': 'shiphead_shipdate',
3482 'name': 'shiphead_sfstatus'
3485 'name': 'shiphead_tracknum',
3501 var sel = _this.shipgrid.getSelectionModel().getSelected();
3503 Roo.MessageBox.alert("Error", "Select a shipment");
3506 if (sel.data.shiphead_shipped) {
3507 Roo.MessageBox.alert("Error", "Shipment is already confirmed");
3512 // check current status of shipment..
3517 url : baseURL + '/Roo/shiphead',
3521 shiphead_id : sel.data.shiphead_id,
3524 success : function() {
3525 _this.shipgrid.ds.load({});
3532 cls : 'x-btn-text-icon',
3533 text : "Confirm Shipment",
3534 icon : rootURL + '/Pman/templates/images/lock.gif'
3542 var sel = _this.shipgrid.getSelectionModel().getSelected();
3544 Roo.MessageBox.alert("Error", "Select a shipment");
3549 // check current status of shipment..
3553 url : baseURL + '/Roo/shiphead',
3556 _download :sel.data.shiphead_id
3564 cls : 'x-btn-text-icon',
3565 text : "Download (as xls)",
3566 icon : rootURL + '/Pman/templates/images/save.gif'
3574 var sel = _this.shipgrid.getSelectionModel().getSelected();
\r
3576 Roo.MessageBox.alert("Error", "Select a shipment");
\r
3579 // check current status of shipment..
3582 url : baseURL + '/Xtuple/Print',
3585 template : 'picking-slip',
3586 param : "shiphead_id:integer='" + sel.data.shiphead_id + "'",
3587 filename : 'picking-slip-' + sel.data.shiphead_number
3589 success : function() {
3598 cls : 'x-btn-text-icon',
3599 text : "Print Picking Slip",
3600 icon : rootURL + '/Pman/templates/images/pdf.gif'
3608 var sel = _this.shipgrid.getSelectionModel().getSelected();
\r
3610 Roo.MessageBox.alert("Error", "Select a shipment");
\r
3613 // check current status of shipment..
3616 url : baseURL + '/Xtuple/Print',
3619 template : 'delivery-note-',
3620 param : "shiphead_id:integer='" + sel.data.shiphead_id + "'",
3621 filename : 'delivery-note-' + sel.data.shiphead_number
3623 success : function() {
3632 cls : 'x-btn-text-icon',
3633 text : "Print Delivery Note",
3634 icon : rootURL + '/Pman/templates/images/pdf.gif'
3642 var s = _this.shipgrid.getSelectionModel().getSelected();
3644 if(!s || s.data.shiphead_id * 1 < 1){
3645 Roo.MessageBox.alert('Error', 'Please select a shipment');
3651 url: baseURL+ '/Roo/shiphead',
3653 shiphead_id : s.data.shiphead_id,
3656 success : function() {
3657 Roo.MessageBox.alert('Notice', 'SENT');
3663 cls : 'x-btn-text-icon',
3664 text : "Send Delivery Email",
3665 icon : Roo.rootURL + 'images/default/dd/email.gif'
3677 if (!_this.form.findField('cohead_id').getValue()) {
3678 Roo.MessageBox.alert("Error", "Save Order first");
3681 var rv = _this.form.getFieldValues();
3683 Pman.Dialog.XtupleShipmentNew.show({
3684 shiphead_order_id : rv.cohead_id,
3685 shiphead_shipdate : _this.form.findField('cohead_targetdate').getValue().format('Y-m-d')
3688 _this.shipgrid.ds.load({});
3692 render : function (_self)
3694 _this.addShipmentBtn = _self;
3697 cls : 'x-btn-text-icon',
3699 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
3707 var sel = _this.shipgrid.getSelectionModel().getSelected();
3709 Roo.MessageBox.alert("Error", "Select a shipment");
3712 // check current status of shipment..
3714 var msg = sel.data.shiphead_shipped ?
3715 "Are you sure you want to un-confirm that shipment? - It will remove items from unposted invoices" :
3716 "Are you sure you want to void that shipment?";
3718 Roo.MessageBox.confirm("Are you sure", msg,
3726 url : baseURL + '/Roo/shiphead',
3730 shiphead_id : sel.data.shiphead_id,
3733 success : function() {
3734 _this.shipgrid.ds.load({});
3747 cls : 'x-btn-text-icon',
3748 text : "Void / Unconfirm",
3749 icon : rootURL + '/Pman/templates/images/trash.gif'
3755 xtype: 'ColumnModel',
3757 dataIndex : 'shiphead_number',
3760 renderer : function(v,x,r) {
3761 if (r.json.shiphead_shipdate.length) {
3762 return String.format('{0}', v);
3764 return String.format('<s>{0}</s>', v);
3768 xtype: 'ColumnModel',
3770 dataIndex : 'shiphead_location_id_location_name',
3771 header : 'From Location',
3773 renderer : function(v) { return String.format('{0}', v); }
3776 xtype: 'ColumnModel',
3778 dataIndex : 'shiphead_shipto_id_shipto_name',
3781 renderer : function(v) { return String.format('{0}', v); }
3784 xtype: 'ColumnModel',
3786 header : 'shipdate',
3788 dataIndex : 'shiphead_shipdate',
3789 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
3792 xtype: 'ColumnModel',
3794 dataIndex : 'shiphead_sfstatus',
3797 renderer : function(v,x,r) {
3802 if (r.json.shiphead_shipdate.length) {
3804 if (r.json.shiphead_shipped) {
3808 return '<span style="color:red">Draft</span>';
3817 xtype: 'ColumnModel',
3821 dataIndex : 'shiphead_shipvia',
3822 renderer : function(v) { return String.format('{0}', v); }
3825 xtype: 'ColumnModel',
3827 header : 'tracknum',
3829 dataIndex : 'shiphead_tracknum',
3830 renderer : function(v) { return String.format('{0}', v); }
3839 activate : function() {
3840 _this.invpanel = this;
3841 if (_this.invgrid) {
3842 _this.invgrid.ds.load({});
3847 fitContainer : true,
3850 tableName : 'cobmisc',
3858 _this.invgrid = this;
3859 //_this.dialog = Pman.Dialog.FILL_IN
3860 if (_this.invpanel.active) {
3864 rowdblclick : function (_self, rowIndex, e)
3867 var ri = this.ds.getAt(rowIndex);
3868 if ( ri.data.cobmisc_id < 0) { // skip summary row..
3871 var rv = _this.form.getFieldValues();
3872 Pman.Dialog.XtupleInvoice.show({
3873 cobmisc_id : ri.data.cobmisc_id,
3874 // below parms for add credit memo
3876 cm_cust_id : rv.cohead_cust_id,
3877 cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,
3878 cm_curr_id : rv.cohead_curr_id,
3879 cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,
3880 cm_terms_id : rv.cohead_terms_id,
3881 cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,
3882 cm_salesrep_id : rv.cohead_salesrep_id,
3883 cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,
3884 cm_docdate : new Date(),
3885 cm_taxzone_id : rv.cohead_taxzone_id,
3886 cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,
3887 cm_billto_cntct_id : rv.cohead_billto_cntct_id,
3888 cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,
3889 cm_location_src : rv.cohead_location_src,
3890 cm_location_src_location_name : rv.cohead_location_src_location_name,
3891 cm_billto_address : rv.billto_address
3895 _this.invgrid.ds.load({});
3900 autoExpandColumn : 'invchead_invcnumber',
3906 beforeload : function (_self, options)
3909 options.params = options.params || {};
3910 options.params.cobmisc_cohead_id = _this.form.findField('cohead_id').getValue() * 1;
3911 if (options.params.cobmisc_cohead_id < 1) {
3915 options.params._with_other_payment = 1;
3916 //options.params['query[invchead_ordernumber]'] = _this.form.findField('cohead_number').getValue()
3919 load : function (_self, records, options)
3924 var totalfreight = 0.0;
3925 var totalmisc = 0.0;
3928 Roo.each(records, function(r)
3930 if(r.data.cobmisc_id > 1){
3931 done += parseInt(r.data.cobmisc_qty);
3932 totalic += parseFloat(r.data.cobmisc_itemcost).toFixed(2)*1;
3933 totalmisc += parseFloat(r.data.cobmisc_misc).toFixed(2)*1;
3934 totalfreight += parseFloat(r.data.cobmisc_freight).toFixed(2)*1;
3935 totaltax += parseFloat(r.data.cobmisc_tax).toFixed(2)*1;
3936 total = parseInt(r.data.cobmisc_total_qty);
3941 _this.shipinvtab.layout.getRegion('center').getPanel(0).setTitle(
3943 "Invoices (Complete)" :
3944 ("Invoices prepared for " + done + '/' + total)
3948 var frtotal = (parseFloat(_this.form.findField('cohead_freight').getValue()) - totalfreight).toFixed(2);
3949 var misctotal = (parseFloat(_this.form.findField('cohead_misc').getValue()) - totalmisc).toFixed(2);
3950 var ictotal = (parseFloat(_this.form.findField('cohead_subtotal').getValue()) - totalic).toFixed(2);
3951 var taxtotal = (parseFloat(_this.form.findField('cohead_tax').getValue()) - totaltax).toFixed(2);
3952 var remtotal = frtotal*1 + misctotal*1 + ictotal*1 + taxtotal*1;
3954 var nr = this.reader.newRow({
3956 cobmisc_invchead_id_invchead_invcnumber : "Total Remaining",
3957 cobmisc_qty : total - done,
3958 cobmisc_freight :frtotal,
3959 cobmisc_misc : misctotal,
3960 cobmisc_itemcost : ictotal,
3961 cobmisc_tax : taxtotal,
3962 cobmisc_total : remtotal
3966 // do we need to add it somehow??
3967 _this.invgrid.ds.add(nr);
3971 sortInfo : { field : 'invchead_invcnumber', direction: 'ASC' },
3976 url : baseURL + '/Roo/cobmisc.php'
3979 xtype: 'JsonReader',
3983 totalProperty : 'total',
3986 'name': 'invchead_invcnumber',
3990 'name': 'invchead_invcdate',
4007 var sel = _this.invgrid.getSelectionModel().getSelected();
4009 Roo.MessageBox.alert("Error", "Select a invoice");
4012 // check current status of shipment..
4014 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to Post that invoice?",
4021 url : baseURL + '/Roo/cobmisc',
4024 cobmisc_id : sel.data.cobmisc_id,
4027 success : function() {
4028 _this.invgrid.ds.load({});
4039 cls : 'x-btn-text-icon',
4040 text : "Post Invoice",
4041 icon : rootURL + '/Pman/templates/images/lock.gif'
4046 cls : 'x-btn-text-icon',
4048 icon : rootURL + '/Pman/templates/images/pdf.gif',
4060 var sel = _this.invgrid.getSelectionModel().getSelected();
4062 Roo.MessageBox.alert("Error", "Select a invoice");
4065 if (!sel.data.cobmisc_invchead_id) {
4066 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4069 // check current status of shipment..
4072 url : baseURL + '/Roo/invchead',
4075 invchead_id : sel.data.cobmisc_invchead_id,
4078 success : function() {
4087 text : "Print Standard Invoice"
4093 click : function (_self, e)
4096 var sel = _this.invgrid.getSelectionModel().getSelected();
4098 Roo.MessageBox.alert("Error", "Select a invoice");
4101 if (!sel.data.cobmisc_invchead_id) {
4102 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4105 // check current status of shipment..
4108 url : baseURL + '/Roo/invchead',
4111 invchead_id : sel.data.cobmisc_invchead_id,
4115 success : function() {
4123 text : "Print Chinese Invoice With GST in line item",
4124 hidden : !(baseURL.match(/(hk\.php|cn\.php)$/))
4130 click : function (_self, e)
4133 var sel = _this.invgrid.getSelectionModel().getSelected();
4135 Roo.MessageBox.alert("Error", "Select a invoice");
4138 if (!sel.data.cobmisc_invchead_id) {
4139 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4142 // check current status of shipment..
4145 url : baseURL + '/Roo/invchead',
4148 invchead_id : sel.data.cobmisc_invchead_id,
4152 success : function() {
4160 text : "Print Chinese Invoice",
4161 hidden : !(baseURL.match(/(hk\.php|cn\.php)$/))
4167 click : function (_self, e)
4170 var sel = _this.invgrid.getSelectionModel().getSelected();
4172 Roo.MessageBox.alert("Error", "Select a invoice");
4175 if (!sel.data.cobmisc_invchead_id) {
4176 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4179 // check current status of shipment..
4182 url : baseURL + '/Roo/invchead',
4185 invchead_id : sel.data.cobmisc_invchead_id,
4189 success : function() {
4197 text : "Print Aus - GST included Invoice",
4198 hidden : !(baseURL.match(/au\.php$/))
4204 click : function (_self, e)
4206 var sel = _this.invgrid.getSelectionModel().getSelected();
4208 Roo.MessageBox.alert("Error", "Select a invoice");
4211 if (!sel.data.cobmisc_invchead_id) {
4212 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4215 // check current status of shipment..
4218 url : baseURL + '/Roo/invchead',
4221 invchead_id : sel.data.cobmisc_invchead_id,
4231 text : "Print Bambini Pronto Invoice",
4232 hidden : !(baseURL.match(/au\.php$/))
4238 click : function (_self, e)
4241 var sel = _this.invgrid.getSelectionModel().getSelected();
4243 Roo.MessageBox.alert("Error", "Select a invoice");
4246 if (!sel.data.cobmisc_invchead_id) {
4247 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4250 // check current status of shipment..
4253 url : baseURL + '/Roo/invchead',
4256 invchead_id : sel.data.cobmisc_invchead_id,
4257 _print : 'au-proforma'
4260 success : function() {
4268 text : "Print Bambini Pro Forma Invoice",
4269 hidden : !(baseURL.match(/au\.php$/))
4275 click : function (_self, e)
4277 var sel = _this.invgrid.getSelectionModel().getSelected();
4279 Roo.MessageBox.alert("Error", "Select a invoice");
4283 Pman.Dialog.XtupleDiscountOfInvoice.show({invchead_id : sel.data.cobmisc_invchead_id}, function(){
4288 text : "Print Shipping / Commercial Invoice",
4289 hidden : !( baseURL.match(/au\.php$/))
4297 cls : 'x-btn-text-icon',
4298 text : "Payments / Refunds / Credit Memos",
4299 icon : Roo.rootURL + 'images/default/tree/leaf.gif',
4308 click : function(_self,e)
4311 var sel = _this.invgrid.getSelectionModel().getSelected();
4312 if (!sel || sel.data.cobmisc_id < 1) {
4313 Roo.MessageBox.alert("Error", "Select a invoice");
4316 if(!sel.data.cobmisc_posted){
4317 Roo.MessageBox.alert("Error", "This invoice has not been posted!");
4320 if(sel.data.cobmisc_outstanding == 0){
4321 Roo.MessageBox.alert("Error", "There is no any outstanding of this invoice!");
4325 var cust_id = _this.form.findField('cohead_cust_id').getValue();
4330 cashrcpt_amount : sel.data.cobmisc_outstanding,
4331 cashrcpt_cust_id : cust_id,
4332 cashrcpt_aropen_id : sel.data.cobmisc_aropen_id_aropen_id,
4333 cashrcpt_distdate : new Date(),
4334 cashrcpt_fundstype : 'C',
4335 cashrcpt_curr_id : sel.data.cobmisc_curr_id_curr_id,
4336 cashrcpt_curr_id_curr_name : sel.data.cobmisc_curr_id_curr_name,
4337 cashrcpt_usecustdeposit : true,
4338 cashrcpt_docdate : new Date(),
4339 cashrcpt_salescat_id : -1,
4340 cashrcpt_applydate : new Date(),
4341 cashrcpt_discount : 0
4343 Pman.Dialog.XtupleReceivePayment.show( data , function() {
4344 _this.invgrid.ds.load({});
4348 cls : 'x-btn-text-icon',
4349 text : "Receive Payment",
4350 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4356 click : function(_self,e)
4358 var sel = _this.invgrid.getSelectionModel().getSelected();
4359 if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {
4360 Roo.MessageBox.alert("Error", "Select a credit memo");
4363 if(!sel.data.cobmisc_posted){
4364 Roo.MessageBox.alert("Error", "The invoice that credit memo has been applied to has been not posted");
4367 var cust_id = _this.form.findField('cohead_cust_id').getValue();
4372 if(!sel.data.cobmisc_outstanding || sel.data.cobmisc_outstanding == 0){
4373 Roo.MessageBox.alert("Error", "The amount of this credit memo is 0!");
4377 var d = _this.form.getFieldValues();
4380 'checkhead_recip_id' : cust_id,
4381 'checkhead_recip_type' : 'C',
4382 'checkhead_checkdate' : new Date(),
4383 'checkhead_amount' : sel.data.cobmisc_outstanding,
4384 'remaining_total' : sel.data.cobmisc_outstanding,
4385 'checkhead_curr_id' : d.cohead_curr_id,
4386 'checkhead_curr_id_curr_name' : d.cohead_curr_id_curr_name,
4387 'checkhead_misc' : true,
4388 'aropen_id' : sel.data.cobmisc_cobapply_aropen_id,
4389 'cmhead_number' : sel.data.cobmisc_invchead_id_invchead_invcnumber,
4390 'cust_name' : d.cohead_cust_id_cust_name,
4391 '_create_and_post' : 1
4396 Pman.Dialog.XtupleMiscellaneousCheck.show( data , function() {
4397 _this.invgrid.ds.load({});
4401 cls : 'x-btn-text-icon',
4402 text : "Issue Refund",
4403 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4413 click : function(_self,e)
4415 var sel = _this.invgrid.getSelectionModel().getSelected();
4416 if (!sel || sel.data.cobmisc_cashrcpt_id * 1 < 1) {
4417 Roo.MessageBox.alert("Error", "Select a Receive Payment");
4421 Roo.MessageBox.confirm("Confirm", "Voiding receipt will mean you will have to re-enter the receipt refund - " +
4422 "please take note of the details so you can enter it again correctly later.", function(r) {
4428 url : baseURL + '/Roo/cashrcpt',
4431 cashrcpt_id : sel.data.cobmisc_cashrcpt_id,
4434 success : function()
4436 _this.invgrid.ds.load({});
4446 cls : 'x-btn-text-icon',
4447 text : "Void Payment",
4448 icon : rootURL + '/Pman/templates/images/trash.gif'
4454 click : function(_self,e)
4456 var sel = _this.invgrid.getSelectionModel().getSelected();
4457 if (!sel || sel.data.cobmisc_checkhead_id * 1 < 1) {
4458 Roo.MessageBox.alert("Error", "Select a Miscellaneours Check");
4462 Roo.MessageBox.confirm("Confirm", "Voiding refund will mean you will have to re-enter the receipt refund - " +
4463 "please take note of the details so you can enter it again correctly later.", function(r) {
4469 url : baseURL + '/Roo/checkhead',
4472 checkhead_id : sel.data.cobmisc_checkhead_id,
4475 success : function()
4477 _this.invgrid.ds.load({});
4487 cls : 'x-btn-text-icon',
4488 text : "Void Refund",
4489 icon : rootURL + '/Pman/templates/images/trash.gif'
4495 click : function(_self,e)
4497 var sel = _this.invgrid.getSelectionModel().getSelected();
4498 if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {
4499 Roo.MessageBox.alert("Error", "Select a credit memo");
4503 if(sel.data.cobmisc_posted){
4504 Roo.MessageBox.alert("Error", "You cann't void this credit memo, since the invoice that credit memo has been applied to has been posted");
4508 if (sel.data.cobmisc_cobapply_id < 1) {
4509 Roo.MessageBox.alert("Error", "invaild credit memo");
4512 Roo.MessageBox.confirm("Confirm", "Are you sure want to void this applied credit memo, " +
4513 "it will also void all the check that belongs to this credit memo ", function(r) {
4519 url : baseURL + '/Roo/cobapply',
4522 _delete : sel.data.cobmisc_cobapply_id,
4525 success : function()
4527 _this.invgrid.ds.load({});
4536 cls : 'x-btn-text-icon',
4537 text : "Void Credit Memo",
4538 icon : rootURL + '/Pman/templates/images/trash.gif'
4554 if (!_this.form.findField('cohead_id').getValue()) {
4555 Roo.MessageBox.alert("Error", "Save Order first");
4559 var rv = _this.form.getFieldValues();
4562 Pman.Dialog.XtupleInvoice.show({
4563 cobmisc_cohead_id : rv.cohead_id,
4564 cobmisc_shipdate : _this.form.findField('cohead_targetdate').getValue(),
4565 cobmisc_invcdate : _this.form.findField('cohead_targetdate').getValue(),
4566 cobmisc_curr_id : rv.cohead_curr_id,
4567 cobmisc_curr_id_curr_name : rv.cohead_curr_id_curr_name,
4568 // below parms for add credit memo
4570 cm_cust_id : rv.cohead_cust_id,
4571 cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,
4572 cm_curr_id : rv.cohead_curr_id,
4573 cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,
4574 cm_terms_id : rv.cohead_terms_id,
4575 cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,
4576 cm_salesrep_id : rv.cohead_salesrep_id,
4577 cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,
4578 cm_docdate : new Date(),
4579 cm_taxzone_id : rv.cohead_taxzone_id,
4580 cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,
4581 cm_billto_cntct_id : rv.cohead_billto_cntct_id,
4582 cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,
4583 cm_location_src : rv.cohead_location_src,
4584 cm_location_src_location_name : rv.cohead_location_src_location_name,
4585 cm_billto_address : rv.billto_address
4590 _this.invgrid.ds.load({});
4594 render : function (_self)
4596 _this.addInvoiceBtn = _self;
4599 cls : 'x-btn-text-icon',
4601 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
4610 var sel = _this.invgrid.getSelectionModel().getSelected();
4612 Roo.MessageBox.alert("Error", "Select a invoice");
4615 // check current status of shipment..
4618 // cobmisc_id : sel.data.cobmisc_id,
4621 if (sel.data.cobmisc_id * 1) {
4622 params.cobmisc_id = sel.data.cobmisc_id * 1 ;
4624 if (sel.data.cobmisc_invchead_id_invchead_id * 1) {
4625 params.invchead_id = sel.data.cobmisc_invchead_id_invchead_id * 1;
4628 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to VOID that invoice?",
4635 url : baseURL + '/Roo/cobmisc',
4638 success : function() {
4639 _this.invgrid.ds.load({});
4650 cls : 'x-btn-text-icon',
4651 text : "Void / Unpost",
4652 icon : rootURL + '/Pman/templates/images/trash.gif'
4658 xtype: 'ColumnModel',
4660 dataIndex : 'cobmisc_invchead_id_invchead_invcnumber',
4661 header : 'Invoice #',
4663 renderer : function(v,x,r) {
4665 r.data.cobmisc_invchead_id_invchead_id * 1 &&
4666 !r.data.cobmisc_invchead_id_invchead_posted) {
4667 return '<span style="color:red">' +
4668 "NEEDS Voiding then re-posted: " +
4669 String.format('{0}', v) +
4673 if(v && r.data.cobmisc_id == -2){
4674 return String.format('<span style="margin-left: 10px;"> - {0} (Credit Memo)</span>', v);
4676 if(v && r.data.cobmisc_id == -3){
4677 return String.format('<span style="margin-left: 20px;"> - {0} (Miscellaneous Check)</span>', v);
4679 if(v && r.data.cobmisc_id == -4){
4680 return String.format('<span style="margin-left: 10px;"> - {0} (Receive Payment to {2}) [ {1} ]</span>',
4681 v, r.data.cobmisc_cashrcpt_amount, r.json.cashrcpt_bankaccnt_id_bankaccnt_bankname);
4684 return v ? String.format('{0}', v) :
4685 '<span style="color:red">' + "Not Posted" + '</span>';
4689 xtype: 'ColumnModel',
4691 dataIndex : 'cobmisc_invcdate',
4692 header : 'invcdate',
4694 renderer : function(v,x,r) {
4696 return String.format('{0}', v && v.format ? v.format('d/M/Y') : '');
4700 xtype: 'ColumnModel',
4703 dataIndex : 'cobmisc_qty',
4706 renderer : function(v) { return String.format('{0}', v ? parseInt(v) : 0); }
4709 xtype: 'ColumnModel',
4712 dataIndex : 'cobmisc_itemcost',
4713 header : 'Item Cost',
4715 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }
4718 xtype: 'ColumnModel',
4721 dataIndex : 'cobmisc_freight',
4722 header : 'Shipping',
4724 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : ''); }
4727 xtype: 'ColumnModel',
4730 dataIndex : 'cobmisc_tax',
4733 renderer : function(v,x,r) {
4735 // tax is based on the % itemcost..
4736 // var ic = r.data.cobmisc_itemcost;
4738 var ic =r.data.cobmisc_itemcost - (1* r.data.cobmisc_itemcost_taxfree);
4740 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
4741 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
4745 var taxp = tax / totic;
4748 return String.format('{0}', (1.0*v).toFixed(2) );
4754 xtype: 'ColumnModel',
4757 dataIndex : 'cobmisc_cohead_id_cohead_pretax_discount',
4758 header : 'Discount (Pretax)',
4760 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }
4763 xtype: 'ColumnModel',
4766 dataIndex : 'cobmisc_misc',
4767 header : 'Discount (Posttax)',
4769 renderer : function(v,x,r)
4771 var vv = v - r.data.cobmisc_cohead_id_cohead_pretax_discount;
4773 return String.format('{0}', vv ? (1.0*vv).toFixed(2) : 0);
4777 xtype: 'ColumnModel',
4780 dataIndex : 'cobmisc_total',
4783 renderer : function(v,x,r) {
4786 var ic = r.data.cobmisc_itemcost;
4787 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
4788 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
4791 var taxp = tax / totic;
4799 return String.format('{0}',(v * 1.0).toFixed(2) );
4803 return String.format('{0}',
4804 ((d.cobmisc_itemcost * 1.0) +
4805 (d.cobmisc_freight * 1.0) +
4806 (d.cobmisc_tax * 1.0) +
4807 (d.cobmisc_misc * 1.0)
4813 xtype: 'ColumnModel',
4816 dataIndex : 'cobmisc_outstanding',
4817 header : 'Outstanding',
4819 renderer : function(v,x,r)
4822 return String.format('{0}', v ? (v * 1.0).toFixed(2) : 0 );
4830 xtype: 'LayoutRegion',
4835 xtype: 'LayoutRegion',
4838 title : "Reserve Stock / Shipments"
4846 activate : function() {
4847 _this.hpanel = this;
4849 _this.hgrid.footer.onClick('first');
4854 fitContainer : true,
4857 tableName : 'events',
4866 //_this.dialog = Pman.Dialog.FILL_IN
4867 if (_this.hpanel.active) {
4868 this.footer.onClick('first');
4871 rowdblclick : function (_self, rowIndex, e)
4873 if (!_this.dialog) return;
4874 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
4875 _this.grid.footer.onClick('first');
4879 autoExpandColumn : 'remarks',
4885 beforeload : function (_self, options)
4887 options.params._related_on_table = 'cohead';
4888 options.params._related_on_id = _this.form.findField('cohead_id').getValue();
4892 sortInfo : { field : 'event_when', direction: 'DESC' },
4897 url : baseURL + '/Roo/events.php'
4900 xtype: 'JsonReader',
4904 totalProperty : 'total',
4907 'name': 'event_when',
4919 'name': 'person_id_name',
4930 xtype: 'PagingToolbar',
4934 displayMsg : "Displaying events{0} - {1} of {2}",
4935 emptyMsg : "No events found"
4939 xtype: 'ColumnModel',
4941 dataIndex : 'event_when',
4944 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); }
4947 xtype: 'ColumnModel',
4949 dataIndex : 'action',
4952 renderer : function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); }
4955 xtype: 'ColumnModel',
4957 dataIndex : 'ipaddr',
4958 header : 'IP address',
4960 renderer : function(v) { return String.format('{0}', v); }
4963 xtype: 'ColumnModel',
4965 dataIndex : 'person_id_name',
4968 renderer : function(v) { return String.format('{0}', v); }
4971 xtype: 'ColumnModel',
4973 dataIndex : 'remarks',
4976 renderer : function(v) { return String.format('{0}', v); }
4982 xtype: 'NestedLayoutPanel',
4987 xtype: 'BorderLayout',
4994 activate : function() {
4995 _this.txpanel = this;
4997 _this.txgrid.footer.onClick('first');
5002 fitContainer : true,
5005 tableName : 'invdetail',
5006 title : "invdetail",
5013 _this.txgrid = this;
5014 //_this.dialog = Pman.Dialog.FILL_IN
5015 if (_this.txpanel.active) {
5016 this.footer.onClick('first');
5020 autoExpandColumn : 'item_number',
5030 click : function (_self, e)
5034 url : baseURL + '/Roo/Cohead',
5037 _apply_fifo : _this.form.findField('cohead_id').getValue()
5039 success : function () {
5040 Roo.MessageBox.alert("Applied", "Succesfully Applied");
5045 text : "Run Apply Fifo on order"
5051 click : function (_self, e)
5055 url : baseURL + '/Roo/Cohead',
5058 _run_void_fix : _this.form.findField('cohead_id').getValue()
5060 success : function () {
5061 Roo.MessageBox.alert("Applied", "Succesfully Run");
5066 text : "Run Void flagger"
5072 click : function (_self, e)
5077 url : baseURL + '/Roo/Invdetail',
5082 _reverse_all_bad : _this.form.findField('cohead_id').getValue()
5084 success : function () {
5085 Roo.MessageBox.alert("Applied", "Succesfully Run");
5090 text : "Auto Reverse"
5095 xtype: 'RowSelectionModel',
5098 selectionchange : function (_self)
5100 _this.txdgrid.footer.onClick('first');;
5109 beforeload : function (_self, o)
5111 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5112 if (! o.params.cohead_id ) {
5119 sortInfo : { field : 'item_number', direction: 'ASC' },
5124 url : baseURL + '/Roo/invdetail.php'
5127 xtype: 'JsonReader',
5129 totalProperty : 'total',
5134 'name': 'invdetail_id',
5138 'name': 'invdetail_transtype',
5142 'name': 'invdetail_invhist_id',
5146 'name': 'invdetail_location_id',
5150 'name': 'invdetail_qty',
5154 'name': 'invdetail_comments',
5158 'name': 'invdetail_qty_before',
5162 'name': 'invdetail_qty_after',
5166 'name': 'invdetail_invcitem_id',
5170 'name': 'invdetail_expiration',
5172 'dateFormat': 'Y-m-d'
5175 'name': 'invdetail_warrpurc',
5177 'dateFormat': 'Y-m-d'
5180 'name': 'invdetail_ls_id',
5187 xtype: 'PagingToolbar',
5190 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5191 emptyMsg : "No invdetail found",
5196 xtype: 'ColumnModel',
5198 dataIndex : 'item_number',
5201 renderer : function(v) { return String.format('{0}', v); }
5204 xtype: 'ColumnModel',
5207 dataIndex : 'rec_shipped',
5210 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5213 xtype: 'ColumnModel',
5216 dataIndex : 'rec_returned',
5219 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5222 xtype: 'ColumnModel',
5225 dataIndex : 'tx_shipped',
5226 header : '#TX ship',
5228 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5231 xtype: 'ColumnModel',
5234 dataIndex : 'tx_returned',
5237 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5240 xtype: 'ColumnModel',
5243 dataIndex : 'tx_total',
5246 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }
5249 xtype: 'ColumnModel',
5252 dataIndex : 'total_value',
5255 renderer : function(v,x,r) {
5257 return (v*1).toFixed(3);
5261 xtype: 'ColumnModel',
5264 dataIndex : 'tx_total',
5267 renderer : function(v,x,r) {
5269 var cototal = (r.data.rec_returned*1) - (r.data.rec_shipped*1);
5270 // Roo.log(cototal);
5271 var diff = (v*1) - cototal;
5276 return String.format('<span style="color:red">{0}</span>', diff );
5286 activate : function() {
5287 _this.txdpanel = this;
5288 if (_this.txdgrid) {
5289 _this.txdgrid.footer.onClick('first');
5294 fitContainer : true,
5297 tableName : 'invdetail',
5298 title : "invdetail",
5305 _this.txdgrid = this;
5306 //_this.dialog = Pman.Dialog.FILL_IN
5307 if (_this.txdpanel.active) {
5308 this.footer.onClick('first');
5311 rowclick : function (_self, rowIndex, e)
5313 var s = _this.txdgrid.ds.getAt(rowIndex);
5314 var dt = s.data.invhist_transdate.split(' ');
5316 _this.dateSel.setValue(new Date(dt[0]));
5319 autoExpandColumn : 'invhist_comments',
5329 click : function (_self, e)
5331 var s = _this.txdgrid.selModel.getSelected();
5334 Roo.MessageBox.alert("Error", "Select a transaction");
5338 var reverseSel = function() {
5342 url : baseURL + '/Roo/invdetail',
5345 _duplicate : s.data.invdetail_id
5347 success : function() {
5348 _this.txdgrid.footer.onClick('first');
5356 Roo.MessageBox.confirm(
5358 "This should only be used by System Administrators - are you sure you know what you are doing!",
5372 text : "Duplicate Selected"
5387 render : function (_self)
5389 _this.dateSel = _self;
5393 fieldLabel : 'Issue Date',
5395 name : 'issue_date',
5402 click : function (_self, e)
5404 var s = _this.txdgrid.selModel.getSelected();
5405 var dt = _this.dateSel.getValue();
5407 Roo.MessageBox.alert("Error", "Select a transaction");
5411 var reverseSel = function(force) {
5415 url : baseURL + '/Roo/invdetail',
5418 _reverse : s.data.invdetail_id,
5419 _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
5422 success : function() {
5423 _this.txdgrid.footer.onClick('first');
5425 failure : function(res) {
5428 if (res.errors.confirm) {
5430 Roo.MessageBox.confirm(
5432 "are you really sure the totals will get messed up.",
5443 Roo.MessageBox.alert("Error", res.errorMsg);
5453 Roo.MessageBox.confirm(
5455 "This should only be used by System Administrators - are you sure you know what you are doing!",
5469 text : "Reverse Selected"
5477 beforeload : function (_self, o)
5479 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5480 var s = _this.txgrid.selModel.getSelected();
5485 o.params.itemsite_id = s.data.invhist_itemsite_id;
5490 sortInfo : { field : 'invdetail_id', direction: 'ASC' },
5495 url : baseURL + '/Roo/invdetail.php'
5498 xtype: 'JsonReader',
5500 totalProperty : 'total',
5505 'name': 'invdetail_id',
5509 'name': 'invdetail_transtype',
5513 'name': 'invdetail_invhist_id',
5517 'name': 'invdetail_location_id',
5521 'name': 'invdetail_qty',
5525 'name': 'invdetail_comments',
5529 'name': 'invdetail_qty_before',
5533 'name': 'invdetail_qty_after',
5537 'name': 'invdetail_invcitem_id',
5541 'name': 'invdetail_expiration',
5543 'dateFormat': 'Y-m-d'
5546 'name': 'invdetail_warrpurc',
5548 'dateFormat': 'Y-m-d'
5551 'name': 'invdetail_ls_id',
5558 xtype: 'PagingToolbar',
5561 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5562 emptyMsg : "No invdetail found",
5567 xtype: 'ColumnModel',
5569 dataIndex : 'invdetail_id',
5572 renderer : function(v) { return String.format('{0}', v); }
5575 xtype: 'ColumnModel',
5577 dataIndex : 'invhist_transdate',
5580 renderer : function(v) { return String.format('{0}', v); }
5583 xtype: 'ColumnModel',
5585 dataIndex : 'invhist_ordnumber',
5588 renderer : function(v,x,r) {
5589 if (r.data.invfifo_void *1 != 0) {
5590 return String.format('<s>{0}</s>', v);
5593 return String.format('{0}', v);
5597 xtype: 'ColumnModel',
5599 dataIndex : 'location_name',
5602 renderer : function(v) { return String.format('{0}', v); }
5605 xtype: 'ColumnModel',
5607 dataIndex : 'invhist_comments',
5610 renderer : function(v) { return String.format('{0}', v); }
5613 xtype: 'ColumnModel',
5616 dataIndex : 'invdetail_qty',
5617 header : 'Qty Changed',
5619 renderer : function(v,x,r) {
5620 if ( r.data.coitem_shipped != v) {
5621 return String.format('{0} <span style="color:red">({1})</span>',
5622 Roo.util.Format.number(v,0),
5623 r.data.coitem_shipped
5627 return String.format('{0}', Roo.util.Format.number(v,0));
5631 xtype: 'ColumnModel',
5634 dataIndex : 'invhist_value_before',
5635 header : 'Qty Changed',
5637 renderer : function(v,x,r) {
5638 var tot = r.data.invhist_value_after*1 - v*1;
5640 if (r.data.invdetail_qty >0 && tot < 0) {
5641 f = '<span style="color:red">{0}</span>';
5643 if (r.data.invdetail_qty < 0 && tot > 0) {
5644 f = '<span style="color:red">{0}</span>';
5646 return String.format(f, Roo.util.Format.number(tot));
5650 xtype: 'ColumnModel',
5652 dataIndex : 'invhist_posted',
5655 renderer : function(v,x,r) {
5657 var state = v ? '-checked' : '';
5659 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
5667 xtype: 'LayoutRegion',
5671 xtype: 'LayoutRegion',
5679 xtype: 'NestedLayoutPanel',
5684 xtype: 'BorderLayout',
5691 activate : function() {
5692 _this.gltxpanel = this;
5693 if (_this.gltxgrid) {
5694 _this.gltxgrid.footer.onClick('first');
5699 fitContainer : true,
5702 tableName : 'invdetail',
5703 title : "invdetail",
5710 _this.gltxgrid = this;
5711 //_this.dialog = Pman.Dialog.FILL_IN
5712 if (_this.gltxpanel.active) {
5713 this.footer.onClick('first');
5716 cellclick : function (_self, rowIndex, columnIndex, e)
5718 if (columnIndex > 0) {
5721 var rec = this.ds.getAt(rowIndex);
5722 rec.set('gltrans_as_summary', rec.data.gltrans_as_summary *1 ? 0 : 1);
5723 _this.gltxdgrid.footer.onClick('first');
5726 autoExpandColumn : 'gltrans_accnt_id_accnt_descrip',
5729 xtype: 'RowSelectionModel',
5732 selectionchange : function (_self)
5734 _this.gltxdgrid.footer.onClick('first');;
5743 beforeload : function (_self, o)
5745 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
5746 if (! o.params.cohead_id ) {
5750 o.params._split_sales = _this.glsalesbtn.pressed ? 1 : 0;
5754 sortInfo : { field : 'item_number', direction: 'ASC' },
5759 url : baseURL + '/Roo/gltrans.php'
5762 xtype: 'JsonReader',
5764 totalProperty : 'total',
5769 'name': 'invdetail_id',
5773 'name': 'invdetail_transtype',
5777 'name': 'invdetail_invhist_id',
5781 'name': 'invdetail_location_id',
5785 'name': 'invdetail_qty',
5789 'name': 'invdetail_comments',
5793 'name': 'invdetail_qty_before',
5797 'name': 'invdetail_qty_after',
5801 'name': 'invdetail_invcitem_id',
5805 'name': 'invdetail_expiration',
5807 'dateFormat': 'Y-m-d'
5810 'name': 'invdetail_warrpurc',
5812 'dateFormat': 'Y-m-d'
5815 'name': 'invdetail_ls_id',
5822 xtype: 'PagingToolbar',
5825 displayMsg : "Displaying invdetail{0} - {1} of {2}",
5826 emptyMsg : "No invdetail found",
5833 render : function (_self)
5835 _this.glsalesbtn = _self;
5837 click : function (_self, e)
5839 (function() { _this.gltxgrid.footer.onClick('first'); }).defer(100);
5842 enableToggle : true,
5844 text : "Split sales"
5850 xtype: 'ColumnModel',
5852 dataIndex : 'gltrans_as_summary',
5855 renderer : function(v,x,r) {
5857 var state = v*1 ? '-checked' : '';
5859 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
5863 xtype: 'ColumnModel',
5865 dataIndex : 'gltrans_accnt_id_accnt_descrip',
5868 renderer : function(v) { return String.format('{0}', v); }
5871 xtype: 'ColumnModel',
5874 dataIndex : 'gltrans_amount_credit',
5877 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
5880 xtype: 'ColumnModel',
5883 dataIndex : 'gltrans_amount_debit',
5886 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
5889 xtype: 'ColumnModel',
5892 dataIndex : 'gltrans_amount_total',
5895 renderer : function(v) { return String.format('<b>{0}</b>', Roo.util.Format.number(v,3)); }
5898 xtype: 'ColumnModel',
5901 dataIndex : 'gltrans_amount_total_unposted',
5902 header : 'Unposted',
5904 renderer : function(v) { return String.format('<span style="color:red">{0}</span>', Roo.util.Format.number(v,3)); }
5913 activate : function() {
5914 _this.gltxdpanel = this;
5915 if (_this.gltxdgrid) {
5916 _this.gltxdgrid.footer.onClick('first');
5921 fitContainer : true,
5924 tableName : 'invdetail',
5925 title : "invdetail",
5932 _this.gltxdgrid = this;
5933 //_this.dialog = Pman.Dialog.FILL_IN
5934 if (_this.gltxdpanel.active) {
5935 this.footer.onClick('first');
5938 cellclick : function (_self, ri, ci, e)
5941 var deleteSel = function() {
5945 url : baseURL + '/Roo/gltrans',
5949 gltrans_id : rec.data.gltrans_id
5952 success : function() {
5953 rec.set('gltrans_posted', false);
5954 rec.set('gltrans_deleted', true);
5955 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
5956 _this.gltxgrid.footer.onClick('first');
5961 var undeleteSel = function() {
5965 url : baseURL + '/Roo/gltrans',
5969 gltrans_id : rec.data.gltrans_id
5972 success : function() {
5973 rec.set('gltrans_posted', true);
5974 rec.set('gltrans_deleted', false);
5975 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
5976 _this.gltxgrid.footer.onClick('first');
5982 var di = this.colModel.config[ci].dataIndex;
5983 if (di != 'gltrans_posted') {
5989 var rec = this.ds.getAt(ri);
5990 if (rec.data.gltrans_deleted) {
5992 Roo.MessageBox.confirm(
5994 "This should only be used by System Administrators - are you sure you know what you are doing!",
6008 if (!rec.data.gltrans_posted) {
6014 url : baseURL + '/Roo/gltrans',
6018 gltrans_id : rec.data.gltrans_id
6020 success : function (res)
6022 rec.set('gltrans_posted', true);
6023 _this.gltxgrid.footer.onClick('first');
6032 // we have a posted transaction.
6033 // only allow recalled to be deleted..
6034 if (!rec.data.gltrans_notes.match(/(Recall|Ship Order)/)) {
6043 Roo.MessageBox.confirm(
6045 "This should only be used by System Administrators - are you sure you know what you are doing!",
6058 autoExpandColumn : 'gltrans_notes',
6064 beforeload : function (_self, o)
6066 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
6067 var s = _this.gltxgrid.selModel.getSelected();
6072 o.params.gltrans_accnt_id = s.data.gltrans_accnt_id;
6073 o.params.gltrans_is_ship = s.data.gltrans_is_ship;
6074 o.params.gltrans_as_summary = s.data.gltrans_as_summary;
6080 sortInfo : { field : 'gltrans_docnumber', direction: 'ASC' },
6085 url : baseURL + '/Roo/gltrans.php'
6088 xtype: 'JsonReader',
6090 totalProperty : 'total',
6095 'name': 'invdetail_id',
6099 'name': 'invdetail_transtype',
6103 'name': 'invdetail_invhist_id',
6107 'name': 'invdetail_location_id',
6111 'name': 'invdetail_qty',
6115 'name': 'invdetail_comments',
6119 'name': 'invdetail_qty_before',
6123 'name': 'invdetail_qty_after',
6127 'name': 'invdetail_invcitem_id',
6131 'name': 'invdetail_expiration',
6133 'dateFormat': 'Y-m-d'
6136 'name': 'invdetail_warrpurc',
6138 'dateFormat': 'Y-m-d'
6141 'name': 'invdetail_ls_id',
6148 xtype: 'PagingToolbar',
6151 displayMsg : "Displaying invdetail{0} - {1} of {2}",
6152 emptyMsg : "No invdetail found",
6159 click : function (_self, e)
6161 new Pman.Download( {
6162 grid : _this.gltxdgrid
6173 xtype: 'ColumnModel',
6175 dataIndex : 'gltrans_id',
6179 renderer : function(v) { return String.format('{0}', v ); }
6182 xtype: 'ColumnModel',
6184 dataIndex : 'gltrans_date',
6187 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
6190 xtype: 'ColumnModel',
6192 dataIndex : 'gltrans_docnumber',
6195 renderer : function(v,x,r) {
6196 if (r.data.gltrans_deleted) {
6197 return String.format('<s>{0}</s>', v);
6199 return String.format('{0}', v);
6203 xtype: 'ColumnModel',
6205 dataIndex : 'gltrans_source',
6208 renderer : function(v) { return String.format('{0}', v); }
6211 xtype: 'ColumnModel',
6213 dataIndex : 'gltrans_notes',
6216 renderer : function(v) { return String.format('{0}', v); }
6219 xtype: 'ColumnModel',
6222 dataIndex : 'gltrans_amount',
6225 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
6228 xtype: 'ColumnModel',
6230 dataIndex : 'gltrans_posted',
6233 renderer : function(v,x,r) {
6235 var state = v ? '-checked' : '';
6237 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
6245 xtype: 'LayoutRegion',
6249 xtype: 'LayoutRegion',
6260 activate : function() {
6261 _this.profitpanel = this;
6263 try { if (MODULE.isBuilder) {
6267 var id = _this.form.findField('cohead_id').getValue() * 1;
6269 Roo.MessageBox.alert("Save First", "Save the order first, before adding items");
6270 _this.dialog.layout.getRegion('center').showPanel(0);
6274 if (_this.profitgrid) {
6275 _this.profitgrid.footer.onClick('first');
6281 fitContainer : true,
6284 tableName : 'coitem',
6292 _this.profitgrid = this;
6293 //_this.dialog = Pman.Dialog.FILL_IN
6294 if (_this.profitpanel.active) {
6295 this.footer.onClick('first');
6299 autoExpandColumn : 'item_number',
6305 beforeload : function (_self,o) {
6312 if (!_this.data || !_this.data.cohead_id) {
6315 o.params = o.params || {};
6317 o.params.coitem_cohead_id = _this.data.cohead_id;
6318 o.params._without_list_discount =1;
6319 o.params._with_profit = 1;
6324 sortInfo : { field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' },
6329 url : baseURL + '/Roo/coitem.php'
6332 xtype: 'JsonReader',
6334 totalProperty : 'total',
6355 'name': 'leader_id',
6359 'name': 'leader_office_id',
6363 'name': 'leader_name',
6367 'name': 'leader_phone',
6371 'name': 'leader_fax',
6375 'name': 'leader_email',
6379 'name': 'leader_company_id',
6383 'name': 'leader_role',
6387 'name': 'leader_active',
6391 'name': 'leader_remarks',
6395 'name': 'leader_passwd',
6399 'name': 'leader_owner_id',
6403 'name': 'leader_lang',
6407 'name': 'leader_no_reset_sent',
6411 'name': 'leader_action_type',
6415 'name': 'leader_project_id',
6419 'name': 'leader_deleted_by',
6423 'name': 'leader_deleted_dt',
6427 'name': 'leader_firstname',
6431 'name': 'leader_lastname',
6435 'name': 'leader_name_facebook',
6439 'name': 'leader_url_blog',
6443 'name': 'leader_url_twitter',
6447 'name': 'leader_url_linkedin',
6451 'name': 'leader_crm_lead_percentage',
6455 'name': 'leader_crm_industry_id',
6459 'name': 'leader_crm_updated_action_id',
6463 'name': 'leader_crm_created_action_id',
6467 'name': 'leader_crm_type_id',
6474 xtype: 'PagingToolbar',
6477 displayMsg : "Displaying coitem{0} - {1} of {2}",
6478 emptyMsg : "No coitem found",
6483 xtype: 'ColumnModel',
6485 dataIndex : 'item_number',
6486 header : 'Item Code',
6488 renderer : function(v) { return String.format('{0}', v); }
6491 xtype: 'ColumnModel',
6493 dataIndex : 'calc_subtotal',
6494 header : 'SubTotal',
6496 renderer : function(v) {
6499 return Roo.util.Format.number( v, 2);
6503 xtype: 'ColumnModel',
6505 dataIndex : 'calc_cost_total',
6506 header : 'Cost of goods',
6508 renderer : function(v) {
6510 return Roo.util.Format.number( v, 2);
6514 xtype: 'ColumnModel',
6516 dataIndex : 'profit',
6519 renderer : function(v,x,r) {
6521 var profit = r.data.calc_subtotal - r.data.calc_cost_total;
6523 if(parseInt(profit) < 1){
6524 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(profit,2));
6528 return Roo.util.Format.number( profit, 2);
6536 xtype: 'LayoutRegion',
6538 alwaysShowTabs : true,
6539 tabPosition : 'top',
6554 var id = 1* _this.form.findField('cohead_id').getValue();
6556 Roo.MessageBox.alert("Error", "Save Sales order first");
6560 // check current status of shipment..
6563 url : baseURL + '/Roo/cohead',
6569 success : function() {
6578 cls : 'x-btn-text-icon',
6579 text : "Download Excel",
6580 icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
6588 var id = 1* _this.form.findField('cohead_id').getValue();
6590 Roo.MessageBox.alert("Error", "Save Sales order first");
6594 // check current status of shipment..
6597 url : baseURL + '/Roo/cohead',
6603 success : function() {
6612 cls : 'x-btn-text-icon',
6614 icon : rootURL + '/Pman/templates/images/pdf.gif'
6620 click : function (_self, e)
6623 _this.addShipmentBtn.fireEvent('click');
6627 cls : 'x-btn-text-icon',
6629 text : "Add Shipment",
6630 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6636 click : function (_self, e)
6639 Pman.Dialog.XtupleCustomer.show({
6640 cust_id : _this.form.findField('cohead_cust_id').getValue()
6644 cls : 'x-btn-text-icon',
6645 text : "Edit Customer",
6646 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6652 click : function (_self, e)
6655 _this.addInvoiceBtn.fireEvent('click');
6659 cls : 'x-btn-text-icon',
6661 text : "Add Invoice",
6662 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
6668 render : function (_self, e)
6670 _this.voidBtn = _self;
6672 click : function (_self, e)
6675 cohead_id : _this.form.findField('cohead_id').getValue()
6682 url: baseURL + '/Roo/cohead',
6685 success : function()
6688 if ( _this.data.cohead_status == 'X') {
6689 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
6695 _this.dialog.hide();
6701 if (_this.data.cohead_status == 'X') {
6707 Roo.MessageBox.confirm("Confirm", "Are you sure you want to void this?", function(r) {
6726 click : function (_self, e)
6728 var p = { cohead_id : _this.form.findField('cohead_id').getValue() };
6731 if (_this.data.cohead_status == 'C') {
6739 url: baseURL + '/Roo/cohead',
6743 success : function()
6747 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
6752 _this.dialog.hide();
6757 render : function (_self)
6759 _this.closeBtn = _self;
6772 click : function (_self, e)
6774 var id = _this.form.findField('cohead_id').getValue() * 1;
6777 Roo.MessageBox.alert('Error', 'Error occour on getting the sales order id');
6781 Roo.MessageBox.confirm("Confirm", "Are you sure to create a credit memo reversal?",
6789 url: baseURL+ '/Roo/cohead',
6794 success : function() {
6795 _this.form.load({ method: 'GET', params: { '_id' : id }});
6801 render : function (_self)
6803 _this.reversalBtn = _self;
6806 text : "Create CM reversal"
6812 click : function (_self, e)
6814 if (_this.grid) _this.grid.stopEditing();
6815 _this.dialog.hide();
6824 click : function (_self, e)
6828 if (_this.grid) _this.grid.stopEditing();
6830 _this.form.doAction("submit");
6833 render : function (_self)
6835 _this.saveBtn = _self;