1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Roo.namespace('Pman.Dialog');
7 Pman.Dialog.XtupleSalesOrder = {
12 show : function(data, cb)
20 this.dialog.show(this.data._el);
23 this.form.setValues(data);
24 this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });
32 this.dialog = Roo.factory({
40 '|xns' : 'Roo.Toolbar',
45 '|xns' : 'Roo.Toolbar',
46 text : "Download Excel",
48 cls : 'x-btn-text-icon',
49 icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
54 var id = 1* _this.form.findField('cohead_id').getValue();
56 Roo.MessageBox.alert("Error", "Save Sales order first");
60 // check current status of shipment..
63 url : baseURL + '/Roo/cohead',
69 success : function() {
80 '|xns' : 'Roo.Toolbar',
83 cls : 'x-btn-text-icon',
84 icon : rootURL + '/Pman/templates/images/pdf.gif',
89 var id = 1* _this.form.findField('cohead_id').getValue();
91 Roo.MessageBox.alert("Error", "Save Sales order first");
95 // check current status of shipment..
98 url : baseURL + '/Roo/cohead',
104 success : function() {
115 '|xns' : 'Roo.Toolbar',
116 text : "Add Shipment",
119 cls : 'x-btn-text-icon',
120 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
123 click : function (_self, e)
126 _this.addShipmentBtn.fireEvent('click');
132 '|xns' : 'Roo.Toolbar',
133 text : "Edit Customer",
135 cls : 'x-btn-text-icon',
136 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
139 click : function (_self, e)
142 Pman.Dialog.XtupleCustomer.show({
143 cust_id : _this.form.findField('cohead_cust_id').getValue()
149 '|xns' : 'Roo.Toolbar',
150 text : "Add Invoice",
153 cls : 'x-btn-text-icon',
154 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
157 click : function (_self, e)
160 _this.addInvoiceBtn.fireEvent('click');
166 '|xns' : 'Roo.Toolbar',
171 render : function (_self, e)
173 _this.voidBtn = _self;
175 click : function (_self, e)
178 cohead_id : _this.form.findField('cohead_id').getValue()
185 url: baseURL + '/Roo/cohead',
191 if ( _this.data.cohead_status == 'X') {
192 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
204 if (_this.data.cohead_status == 'X') {
210 Roo.MessageBox.confirm("Confirm", "Are you sure you want to void this?", function(r) {
225 '|xns' : 'Roo.Toolbar',
230 render : function (_self)
232 _this.closeBtn = _self;
234 click : function (_self, e)
236 var p = { cohead_id : _this.form.findField('cohead_id').getValue() };
239 if (_this.data.cohead_status == 'C') {
247 url: baseURL + '/Roo/cohead',
255 _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
271 alwaysShowTabs : true,
272 xtype : 'LayoutRegion',
283 title : "Edit / Create Sales Order",
284 xtype : 'LayoutDialog',
293 text : "Create CM reversal",
297 render : function (_self)
299 _this.reversalBtn = _self;
301 click : function (_self, e)
303 var id = _this.form.findField('cohead_id').getValue() * 1;
306 Roo.MessageBox.alert('Error', 'Error occour on getting the sales order id');
310 Roo.MessageBox.confirm("Confirm", "Are you sure to create a credit memo reversal?",
318 url: baseURL+ '/Roo/cohead',
323 success : function() {
324 _this.form.load({ method: 'GET', params: { '_id' : id }});
338 click : function (_self, e)
340 if (_this.grid) _this.grid.stopEditing();
351 render : function (_self)
353 _this.saveBtn = _self;
355 click : function (_self, e)
359 if (_this.grid) _this.grid.stopEditing();
361 _this.form.doAction("submit");
369 this.layout.getRegion('center').showPanel(0);
376 xtype : 'ContentPanel',
377 title : "Order Details",
380 activate : function (_self)
382 // we need to reload to find out the subtotal.
383 if (!_this.data || !_this.data.cohead_id) {
388 url : baseURL + '/Roo/cohead',
390 _id : _this.data.cohead_id
392 success : function(res) {
393 _this.form.findField('cohead_subtotal').setValue(res.data.cohead_subtotal);
394 _this.form.findField('cohead_tax').setValue(res.data.cohead_tax);
395 _this.form.findField('cohead_uninvoiced').setValue(res.data.cohead_uninvoiced);
396 _this.form.findField('cohead_unshipped').setValue(res.data.cohead_unshipped);
397 _this.form.findField('cohead_pretax_discount').setValue(res.data.cohead_pretax_discount);
398 _this.form.findField('cohead_total').recalc();
399 _this.form.findField('cohead_misc').recalc();
407 url : baseURL + '/Roo/cohead.php',
410 style : 'margin:10px;',
413 actionfailed : function (_self, action)
415 if (action.failureType == 'client') {
416 Roo.MessageBox.alert("Error", "Fill in all the required fields");
418 if (action.failureType == 'server') {
420 Roo.MessageBox.alert("Error", action.result.errorMsg);
422 _this.dialog.layout.getRegion('center').showPanel(0);
424 actioncomplete : function(_self,action)
426 if (action.type == 'setdata') {
427 // clear the stock level cache...
428 _this.stockcache = [];
430 _this.form.findField('billto_email').setValue('');
432 _this.reversalBtn.hide();
434 if (_this.data.cohead_id) {
435 this.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
439 _this.dialog.setTitle("Edit New Sales Order");
441 _this.closeBtn.hide();
442 _this.voidBtn.hide();
443 _this.saveBtn.show();
445 if(_this.data.cohead_billto_cntct_id_cntct_id){
446 _this.form.findField('billto_address').update();
448 _this.form.setValues({
\r
449 cohead_billto_cntct_id: _this.data.cohead_billto_cntct_id_cntct_id,
\r
450 cohead_billto_cntct_id_cntct_name : _this.data.cohead_billto_cntct_id_cntct_name,
\r
459 if (action.type == 'load') {
462 _this.data = action.result.data;
464 if (!_this.data.cohead_shipto_id && _this.data.shipto_id*1 > 0) {
465 _this.form.findField('cohead_shipto_id').setValue(_this.data.shipto_id);
466 _this.form.findField('cohead_shipto_id_shipto_name').setValue(_this.data.cohead_shipto_cntct_id_cntct_name);
471 _this.dataloading = true;
472 if (_this.data.cohead_shipto_cntct_id == _this.data.cohead_billto_cntct_id) {
473 this.findField('_shipto_same').setValue(1);
474 Roo.log("set shipto 1");
476 this.findField('_shipto_same').setValue(0);
477 Roo.log("set shipto 0");
479 _this.dataloading = false;
482 this.findField('billto_address').update();
483 this.findField('shipto_address').update();
484 _this.dialog.setTitle("Edit Sales Order - " + this.findField('cohead_number').getValue());
487 if (_this.data.cohead_status == 'C') {
488 _this.closeBtn.show();
489 _this.closeBtn.setText('Re-open');
490 _this.voidBtn.hide();
491 _this.saveBtn.hide();
492 _this.reversalBtn.show();
493 } else if (_this.data.cohead_status == 'X') {
494 _this.closeBtn.hide();
495 _this.voidBtn.show();
496 _this.voidBtn.setText("Un-void / Re-open");
497 _this.saveBtn.hide();
500 _this.closeBtn.show();
501 _this.closeBtn.setText('Complete and Close');
502 _this.voidBtn.setText("Void");
503 _this.voidBtn.show();
504 _this.saveBtn.show();
507 _this.form.findField('cohead_misc_per').update();
509 // finally override the value for discount...
510 if ((''+ _this.data.cohead_misc_descrip).length) {
511 _this.form.findField('cohead_misc_descrip').setValue(_this.data.cohead_misc_descrip);
514 // update the stockcache...
517 url : baseURL + '/Roo/cohead',
520 _stockLevel : _this.data.cohead_id
522 success : function(res)
524 for (var i in res.data) {
526 if(typeof(_this.stockcache[res.data[i].item]) == 'undefined'){
527 _this.stockcache[res.data[i].item] = res.data[i];
535 if (action.type =='submit') {
538 var id = _this.form.findField('cohead_id').getValue() * 1;
541 _this.data.cohead_id = action.result.data.cohead_id;
542 this.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});
548 if (_this.callback) {
549 _this.callback.call(_this, _this.form.getValues());
555 rendered : function (form)
569 style : 'width:420px',
591 fieldLabel : 'Order#',
592 emptyText : "Automatic",
598 name : 'cohead_number'
602 style : 'float:left',
610 fieldLabel : 'Cust#',
616 name : 'cohead_cust_id_cust_number'
627 triggerAction : 'all',
628 forceSelection : true,
629 fieldLabel : 'Customer',
630 selectOnFocus : true,
632 hiddenName : 'cohead_cust_id',
634 valueField : 'cust_id',
641 name : 'cohead_cust_id_cust_name',
642 qtip : "Select custinfo",
643 queryParam : 'query[cust_name]',
644 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{cust_name}</b> </div>',
645 loadingText : "Searching..."
649 fieldLabel : 'Customer PO#',
653 name : 'cohead_custponumber'
658 fieldLabel : 'Ordered',
663 name : 'cohead_orderdate'
675 fieldLabel : 'Target Delivery',
680 name : 'cohead_targetdate'
692 boxLabel : 'same as order',
694 name : '_same_as_order',
696 check : function (_self, checked)
699 _this.form.findField('cohead_targetdate').setValue(_this.form.findField('cohead_orderdate').getValue());
714 url : baseURL + '/Roo/location.php',
723 xtype : 'JsonReader',
724 fields : [{"name":"location_id","type":"int"},"location_name"],
726 totalProperty : 'total'
731 sortInfo : { direction : 'ASC', field: 'location_name' },
734 beforeload : function (_self, o){
735 o.params = o.params || {};
737 o.params.location_netable = 1;
738 o.params.location_restrict = 0;
739 o.params._notinternalcompany = 1;
749 triggerAction : 'all',
750 fieldLabel : 'Supply From',
751 forceSelection : true,
752 selectOnFocus : true,
754 displayField : 'location_name',
755 emptyText : "Supply From",
756 hiddenName : 'cohead_location_src',
758 valueField : 'location_id',
765 name : 'cohead_location_src_location_name',
766 qtip : "Select terms",
767 queryParam : 'query[location_name]',
768 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{location_name}</b> {location_descrip} </div>',
769 loadingText : "Searching...",
783 style : 'width:420px',
800 url : baseURL + '/Roo/terms.php',
809 xtype : 'JsonReader',
811 fields : [{"name":"terms_id","type":"int"},"terms_descrip"],
812 totalProperty : 'total'
817 sortInfo : { direction : 'ASC', field: 'terms_descrip' },
820 beforeload : function (_self, o){
821 o.params = o.params || {};
832 triggerAction : 'all',
833 forceSelection : true,
834 selectOnFocus : true,
835 fieldLabel : 'Terms',
838 emptyText : "Select terms",
840 valueField : 'terms_id',
841 displayField : 'terms_descrip',
842 hiddenName : 'cohead_terms_id',
848 qtip : "Select terms",
849 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{terms_descrip}</b> </div>',
850 queryParam : 'query[terms_descrip]',
851 name : 'cohead_terms_id_terms_descrip',
852 loadingText : "Searching...",
862 url : baseURL + '/Roo/salesrep.php',
871 xtype : 'JsonReader',
873 fields : [{"name":"salesrep_id","type":"int"},"salesrep_name"],
874 totalProperty : 'total'
879 sortInfo : { direction : 'ASC', field: 'salesrep_name' },
882 beforeload : function (_self, o){
883 o.params = o.params || {};
895 triggerAction : 'all',
896 fieldLabel : 'Sales Rep',
897 forceSelection : true,
898 selectOnFocus : true,
900 displayField : 'salesrep_name',
901 emptyText : "Select salesrep",
902 hiddenName : 'cohead_display_salesrep_id',
904 valueField : 'salesrep_id',
911 name : 'cohead_display_salesrep_id_salesrep_name',
912 qtip : "Select salesrep",
913 queryParam : 'query[salesrep_name]',
914 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{salesrep_name}</b> </div>',
915 loadingText : "Searching...",
925 url : baseURL + '/Roo/salesrep.php',
934 xtype : 'JsonReader',
936 fields : [{"name":"salesrep_id","type":"int"},"salesrep_name"],
937 totalProperty : 'total'
942 sortInfo : { direction : 'ASC', field: 'salesrep_name' },
945 beforeload : function (_self, o){
946 o.params = o.params || {};
958 triggerAction : 'all',
959 fieldLabel : 'Staff I.C.',
960 forceSelection : true,
961 selectOnFocus : true,
963 displayField : 'salesrep_name',
964 emptyText : "Select Staff",
965 hiddenName : 'cohead_salesrep_id',
967 valueField : 'salesrep_id',
974 name : 'cohead_salesrep_id_salesrep_name',
975 qtip : "Select salesrep",
976 queryParam : 'query[salesrep_name]',
977 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{salesrep_name}</b> </div>',
978 loadingText : "Searching...",
986 fieldLabel : 'Order Comments',
990 name : 'cohead_ordercomments',
1000 '|xns' : 'Roo.form',
1001 style : 'width:420px',
1007 '|xns' : 'Roo.form',
1016 '|xns' : 'Roo.data',
1017 url : baseURL + '/Roo/cntct.php',
1019 xtype : 'HttpProxy',
1023 '|xns' : 'Roo.data',
1026 xtype : 'JsonReader',
1028 fields : [{"name":"cntct_id","type":"int"},"cntct_name"],
1029 totalProperty : 'total'
1031 '|xns' : 'Roo.data',
1034 sortInfo : { direction : 'ASC', field: 'cntct_name' },
1037 beforeload : function (_self, o){
1038 o.params = o.params || {};
1040 o.params._customer_id = _this.data.cohead_cust_id;
1048 '|xns' : 'Roo.form',
1051 triggerAction : 'all',
1052 fieldLabel : 'Bill To (select)',
1053 forceSelection : true,
1054 selectOnFocus : true,
1056 displayField : 'cntct_name',
1057 emptyText : "Select cntct",
1058 hiddenName : 'cohead_billto_cntct_id',
1060 valueField : 'cntct_id',
1067 name : 'cohead_billto_cntct_id_cntct_name',
1068 qtip : "Select cntct",
1069 queryParam : 'query[cntct_name]',
1070 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{cntct_name}</b> {cntct_addr_id_addr_line1}</div>',
1071 loadingText : "Searching...",
1073 add : function (combo)
1076 Pman.Dialog.XtupleQuickContact.show(
1079 customer_id : _this.form.findField('cohead_cust_id').getValue()
1084 for(var i in data) {
1086 _this.data['cohead_billto_cntct_id_' + i] = data[i];
1089 _this.form.findField('billto_address').update();
1090 // fill in the select box..
1091 _this.form.setValues( {
1092 cohead_billto_cntct_id : data.cntct_id,
1093 cohead_billto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1094 data.cntct_last_name
1099 // Pman.Dialog.XtupleCustomer.show(
1100 //{ cust_id : _this.form.findField('cohead_cust_id').getValue() },
1102 // refresh the data in the pulldown..
1106 beforeselect : function (combo, record, index)
1108 // set _this.data values ..
1110 // just add everything...
1111 for(var i in record.data) {
1112 _this.data['cohead_billto_cntct_id_' + i] = record.data[i];
1115 _this.form.findField('billto_address').update();
1127 '|xns' : 'Roo.form',
1128 fieldLabel : 'or enter Address',
1130 update : function() {
1132 var c = ['first_name', 'last_name' ] ;
1133 var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];
1135 Roo.each(c, function(e) {
1136 if (_this.data['cohead_billto_cntct_id_cntct_' +e].length) {
1137 v.push(_this.data['cohead_billto_cntct_id_cntct_' +e]);
1140 Roo.each(a, function(e) {
1141 if (_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e].length) {
1142 v.push(_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e]);
1146 this.setValue(v.join("\n"));
1148 if(_this.data.cohead_billto_cntct_id_cntct_email.length){
1149 _this.form.findField('billto_email').setValue(_this.data.cohead_billto_cntct_id_cntct_email);
1154 name : 'billto_address',
1156 render : function (_self)
1162 this.el.on('click', function() {
1163 var id = _this.form.findField('cohead_billto_cntct_id').getValue();
1164 Pman.Dialog.XtupleQuickContact.show(
1167 customer_id : _this.form.findField('cohead_cust_id').getValue()
1172 for(var i in data) {
1174 _this.data['cohead_billto_cntct_id_' + i] = data[i];
1177 _this.form.findField('billto_address').update();
1178 // fill in the select box..
1179 _this.form.setValues( {
1180 cohead_billto_cntct_id : data.cntct_id,
1181 cohead_billto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1182 data.cntct_last_name
1191 Roo.log("Click text");
1199 '|xns' : 'Roo.form',
1200 fieldLabel : 'Email',
1201 xtype : 'DisplayField',
1202 valueRenderer : function(v)
1205 return v ? String.format('<a href="mailto:{0}" target="_blank">{0}</a>',v) : '';
1208 name : 'billto_email'
1220 '|xns' : 'Roo.form',
1222 style : 'margin-left:10px',
1227 '|xns' : 'Roo.form',
1228 legend : "Price Details",
1230 style : 'width:420px',
1235 '|xns' : 'Roo.form',
1236 labelAlign : 'right',
1243 '|xns' : 'Roo.form',
1246 labelSeparator : ' ',
1253 '|xns' : 'Roo.data',
1254 url : baseURL + '/Roo/curr_symbol.php',
1256 xtype : 'HttpProxy',
1260 '|xns' : 'Roo.data',
1263 xtype : 'JsonReader',
1265 fields : [{"name":"curr_id","type":"int"},"curr_symbol"],
1266 totalProperty : 'total'
1268 '|xns' : 'Roo.data',
1271 sortInfo : { direction : 'ASC', field: 'curr_symbol' },
1274 beforeload : function (_self, o){
1275 o.params = o.params || {};
1285 '|xns' : 'Roo.form',
1287 triggerAction : 'all',
1288 fieldLabel : 'Currency',
1289 forceSelection : true,
1290 selectOnFocus : true,
1292 displayField : 'curr_name',
1293 emptyText : "Select curr_name",
1294 hiddenName : 'cohead_curr_id',
1296 valueField : 'curr_id',
1303 name : 'cohead_curr_id_curr_name',
1304 qtip : "Select Currency",
1305 queryParam : 'query[curr_name]',
1306 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{curr_name}</b> </div>',
1307 loadingText : "Searching...",
1309 beforequery : function (combo, query, forceAll, cancel, e)
1311 Roo.log('beforequery');
1313 if (_this.form.findField('cohead_number').getValue().length) {
1314 Roo.MessageBox.alert("Error", "You can not change the currency of this order");
1316 query.cancel = true;
1328 '|xns' : 'Roo.form',
1329 fieldLabel : 'Products',
1330 xtype : 'NumberField',
1331 cls : 'roo-align-right',
1333 allowDecimals : true,
1334 decimalPrecision : 3,
1337 name : 'cohead_subtotal'
1343 '|xns' : 'Roo.form',
1346 labelSeparator : ' ',
1353 '|xns' : 'Roo.data',
1354 url : baseURL + '/Roo/taxzone.php',
1355 xtype : 'HttpProxy',
1360 '|xns' : 'Roo.data',
1363 xtype : 'JsonReader',
1364 fields : [{"name":"taxzone_id","type":"int"},"taxzone_descrip"],
1366 totalProperty : 'total'
1368 '|xns' : 'Roo.data',
1371 sortInfo : { direction : 'ASC', field: 'taxzone_descrip' },
1374 beforeload : function (_self, o){
1375 o.params = o.params || {};
1378 o.params.with_date = _this.form.findField('cohead_orderdate').getValue().format('Y-m-d');
1379 Roo.log("with date?" + o.params.with_date);
1389 '|xns' : 'Roo.form',
1391 triggerAction : 'all',
1392 fieldLabel : 'Tax Zone',
1393 forceSelection : true,
1394 selectOnFocus : true,
1396 displayField : 'taxzone_descrip',
1397 emptyText : "Select taxtype",
1398 hiddenName : 'cohead_taxzone_id',
1400 valueField : 'taxzone_id',
1407 name : 'cohead_taxzone_id_taxzone_descrip',
1408 qtip : "Select taxtype",
1409 queryParam : 'query[taxzone_descrip]',
1410 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{taxzone_descrip}</b> </div>',
1411 loadingText : "Searching...",
1413 select : function (combo, record, index)
1415 _this.form.findField('cohead_tax').setValue(
1416 parseFloat(record.data.taxzone_rate) *
1417 parseFloat(_this.form.findField('cohead_subtotal').getValue())
1419 _this.form.findField('cohead_total').recalc();
1428 '|xns' : 'Roo.form',
1430 xtype : 'NumberField',
1431 cls : 'roo-align-right',
1433 allowDecimals : true,
1434 decimalPrecision : 3,
1443 '|xns' : 'Roo.form',
1444 fieldLabel : 'Pre Tax discount',
1445 xtype : 'NumberField',
1446 cls : 'roo-align-right',
1448 allowDecimals : true,
1449 decimalPrecision : 3,
1452 name : 'cohead_pretax_discount'
1455 '|xns' : 'Roo.form',
1458 labelSeparator : ' ',
1463 '|xns' : 'Roo.form',
1464 fieldLabel : 'Discount after Tax Description',
1465 xtype : 'TextField',
1468 name : 'cohead_misc_descrip'
1471 '|xns' : 'Roo.form',
1473 xtype : 'NumberField',
1474 update : function() {
1475 var m = _this.form.findField('cohead_misc_per');
1476 var pv = parseFloat(_this.form.findField('cohead_subtotal').getValue());
1477 var tax = parseFloat(_this.form.findField('cohead_tax').getValue());
1478 var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());
1480 var discount = parseFloat(_this.form.findField('cohead_posttax_discount').getValue());
1482 if (discount > 0.0) {
1490 var val = ((discount) / (pv + tax + pd)) * -100;
1492 //Roo.log("update discount?" + val);
1493 this.setValue(val.toFixed(1));
1496 _this.form.findField('cohead_misc_descrip').setValue("Discount of " + val.toFixed(1)+'%');
1502 cls : 'roo-align-right',
1503 allowDecimals : true,
1504 decimalPrecision : 1,
1507 name : 'cohead_misc_per',
1509 keyup : function (_self, e)
1511 var pv = parseFloat(_this.form.findField('cohead_subtotal').getValue());
1512 var tax = parseFloat(_this.form.findField('cohead_tax').getValue());
1513 var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());
1515 var n = this.getValue();
1516 var discount = parseFloat(n * (pv + tax + pd) * 0.01);
1518 _this.form.findField('cohead_posttax_discount').setValue(discount);
1520 _this.form.findField('cohead_total').recalc();
1521 _this.form.findField('cohead_misc').recalc();
1522 var val = discount * -1.0;
1524 _this.form.findField('cohead_misc_descrip').setValue("Discount of " + val.toFixed(1)+'%');
1532 '|xns' : 'Roo.form',
1533 fieldLabel : ' ',
1534 xtype : 'NumberField',
1535 cls : 'roo-align-right',
1536 allowDecimals : true,
1537 decimalPrecision : 3,
1540 name : 'cohead_posttax_discount',
1542 keyup : function (_self, e)
1544 _this.form.findField('cohead_misc_per').update();
1545 _this.form.findField('cohead_total').recalc();
1546 _this.form.findField('cohead_misc').recalc();
1554 '|xns' : 'Roo.form',
1555 fieldLabel : 'Total',
1556 recalc : function() {
1557 var d = _this.form.getValues();
1559 parseFloat(d.cohead_subtotal) +
1560 parseFloat(d.cohead_pretax_discount) +
1561 parseFloat(d.cohead_posttax_discount) +
1562 parseFloat(d.cohead_tax) +
1563 parseFloat(d.cohead_freight));
1565 xtype : 'NumberField',
1566 cls : 'roo-align-right',
1568 allowDecimals : true,
1569 decimalPrecision : 3,
1572 name : 'cohead_total'
1575 '|xns' : 'Roo.form',
1576 fieldLabel : 'Shipping',
1577 xtype : 'NumberField',
1578 cls : 'roo-align-right',
1579 allowDecimals : true,
1580 decimalPrecision : 3,
1583 name : 'cohead_freight',
1585 keyup : function (_self, e)
1587 _this.form.findField('cohead_total').recalc();
1592 '|xns' : 'Roo.form',
1593 fieldLabel : 'Unshipped Total',
1594 xtype : 'NumberField',
1595 cls : 'roo-align-right',
1597 allowDecimals : true,
1598 decimalPrecision : 3,
1601 name : 'cohead_unshipped'
1604 '|xns' : 'Roo.form',
1605 fieldLabel : 'Uninvoiced Total',
1606 xtype : 'NumberField',
1607 cls : 'roo-align-right',
1609 allowDecimals : true,
1610 decimalPrecision : 3,
1613 name : 'cohead_uninvoiced'
1622 '|xns' : 'Roo.form',
1623 style : 'width:420px',
1625 legend : "Shipping",
1629 '|xns' : 'Roo.form',
1636 '|xns' : 'Roo.form',
1638 labelSeparator : ' ',
1642 '|xns' : 'Roo.form',
1644 boxLabel : 'Same as Billing',
1646 name : '_shipto_same',
1648 check : function (_self, checked)
1654 if (_this.dataloading) {
1662 // copy the cohead_billto_cntct_id
1663 for (var i in _this.data) {
1664 if (!i.match(/^cohead_billto_cntct_id/)) {
1667 var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');
1668 _this.data[ni] = _this.data[i];
1670 _this.form.findField('shipto_address').update();
1671 _this.form.setValues( {
1672 cohead_shipto_cntct_id : _this.data.cohead_shipto_cntct_id,
1673 cohead_shipto_cntct_id_cntct_name : _this.data.cohead_shipto_cntct_id_cntct_first_name + ' ' +
1674 _this.data.cohead_shipto_cntct_id_cntct_last_name
1681 for (var i in _this.data) {
1682 if (!i.match(/^cohead_billto_cntct_id/)) {
1685 var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');
1687 _this.data[ni] = '';
1689 _this.form.findField('shipto_address').update();
1691 _this.form.setValues( {
1692 cohead_shipto_cntct_id : '',
1693 cohead_shipto_cntct_id_cntct_name : ''
1708 '|xns' : 'Roo.data',
1709 url : baseURL + '/Roo/cntct.php',
1711 xtype : 'HttpProxy',
1715 '|xns' : 'Roo.data',
1718 xtype : 'JsonReader',
1720 fields : [{"name":"cntct_id","type":"int"},"cntct_name"],
1721 totalProperty : 'total'
1723 '|xns' : 'Roo.data',
1726 sortInfo : { direction : 'ASC', field: 'cntct_name' },
1729 beforeload : function (_self, o){
1730 o.params = o.params || {};
1732 o.params._customer_id = _this.data.cohead_cust_id;
1740 '|xns' : 'Roo.form',
1743 triggerAction : 'all',
1744 fieldLabel : 'Ship to',
1745 forceSelection : true,
1746 selectOnFocus : true,
1748 displayField : 'cntct_name',
1749 emptyText : "Select ship to",
1750 hiddenName : 'cohead_shipto_cntct_id',
1752 valueField : 'cntct_id',
1759 name : 'cohead_shipto_cntct_id_cntct_name',
1760 qtip : "Select shiptoinfo",
1761 queryParam : 'query[cntct_name]',
1762 tpl : '<div class=\"x-grid-cell-text x-btn button\">{cntct_name} - <b>{cntct_addr_id_addr_line1}</b> </div>',
1763 loadingText : "Searching...",
1765 add : function (combo)
1767 Pman.Dialog.XtupleQuickContact.show(
1770 customer_id : _this.form.findField('cohead_cust_id').getValue()
1775 for(var i in data) {
1777 _this.data['cohead_shipto_cntct_id_' + i] = data[i];
1780 _this.form.findField('shipto_address').update();
1781 // fill in the select box..
1782 _this.form.setValues( {
1783 cohead_shipto_cntct_id : data.cntct_id,
1784 cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1785 data.cntct_last_name
1791 beforeselect : function (combo, record, index)
1794 // just add everything...
1795 for(var i in record.data) {
1796 //Roo.log('cohead_shipto_cntct_id_' + i +' =' + record.data[i]);
1797 _this.data['cohead_shipto_cntct_id_' + i] = record.data[i];
1800 _this.form.findField('shipto_address').update();
1811 '|xns' : 'Roo.form',
1812 fieldLabel : 'Address',
1814 update : function() {
1816 var c = ['first_name', 'last_name' ] ;
1817 var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];
1820 if (_this.data['cohead_shipto_vend_name'] && _this.data['cohead_shipto_vend_name'].length) {
1821 v.push(_this.data['cohead_shipto_vend_name']);
1823 if (_this.data['cohead_shipto_vendaddr_code'] && _this.data['cohead_shipto_vendaddr_code'].length) {
1824 v.push(_this.data['cohead_shipto_vendaddr_code']);
1826 Roo.each(c, function(e) {
1827 if (_this.data['cohead_shipto_cntct_id_cntct_' +e] &&
1828 _this.data['cohead_shipto_cntct_id_cntct_' +e].length) {
1829 v.push(_this.data['cohead_shipto_cntct_id_cntct_' +e]);
1832 Roo.each(a, function(e) {
1833 if (_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e] &&
1834 _this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e].length) {
1835 v.push(_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e]);
1839 this.setValue(v.join("\n"));
1844 name : 'shipto_address',
1846 render : function (_self)
1852 this.el.on('click', function() {
1853 var id = _this.form.findField('cohead_shipto_cntct_id').getValue();
1854 Pman.Dialog.XtupleQuickContact.show(
1857 customer_id : _this.form.findField('cohead_cust_id').getValue()
1862 for(var i in data) {
1864 _this.data['cohead_shipto_cntct_id_' + i] = data[i];
1867 _this.form.findField('shipto_address').update();
1868 // fill in the select box..
1869 _this.form.setValues( {
1870 cohead_shipto_cntct_id : data.cntct_id,
1871 cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+
1872 data.cntct_last_name
1881 // Roo.log("Click text");
1889 '|xns' : 'Roo.form',
1890 fieldLabel : 'Shipment Comments',
1894 name : 'cohead_shipcomments'
1906 '|xns' : 'Roo.form',
1912 '|xns' : 'Roo.form',
1915 name : 'cohead_shipto_id'
1918 '|xns' : 'Roo.form',
1921 name : 'cohead_shipto_id_shipto_name'
1924 '|xns' : 'Roo.form',
1927 name : 'cohead_max_linenumber'
1930 '|xns' : 'Roo.form',
1933 name : 'cohead_cust_id'
1936 '|xns' : 'Roo.form',
1937 recalc : function() {
1938 var d = _this.form.getValues();
1940 parseFloat(d.cohead_pretax_discount) +
1941 parseFloat(d.cohead_posttax_discount) );
1945 name : 'cohead_misc'
1948 '|xns' : 'Roo.form',
1951 name : 'taxzone_rate'
1962 '|xns' : 'Roo.grid',
1963 xtype : 'CellSelectionModel',
1965 enter_is_tab : true,
1967 tabend : function (_self)
1969 _this.addItemBtn.fireEvent('click', _this.addItemBtn);
1971 beforeeditnext : function (eventdata)
1975 // this does not work, as the reload effect cancels editng.
1976 var rec = _this.grid.ds.getAt(eventdata.cell[0]);
1977 if (rec.data.coitem_subnumber *1 < 0 ) {
1980 var r = eventdata.cell[0] + 1;
1983 if (r > _this.grid.ds.getCount()-1 ) {
1984 eventdata.cell = false;
1987 rec = _this.grid.ds.getAt(r);
1988 if (rec.data.coitem_subnumber *1 < 0 ) {
1989 eventdata.cell = [ r, eventdata.cell[1] ];
2004 xtype : 'PagingToolbar',
2005 emptyMsg : "No Items",
2008 updateSummary : function() {
2011 url : baseURL + '/Roo/Coitem',
2015 coitem_cohead_id : _this.form.findField('cohead_id').getValue()
2017 success : function(d) {
2019 f.displayEl.update(String.format(
2020 "{0} items | Subtotal: {2} | Tax: {3} | List Discount {4} | Total : {1}{5}",
2022 _this.form.findField('cohead_curr_id').el.dom.value,
2025 d.data.total_list_discount,
2034 '|xns' : 'Roo.Toolbar',
2035 text : "Fill empty Ship To",
2039 click : function (_self, e)
2042 url : baseURL + '/Roo/Cohead',
2045 _fill_shipto : _this.form.findField('cohead_id').getValue()
2047 success : function() {
2048 _this.grid.footer.onClick('first');
2055 '|xns' : 'Roo.Toolbar',
2056 text : "Update Location to match S/O",
2060 click : function (_self, e)
2062 Roo.MessageBox.confirm("Confirm", "Are you sure?<BR>"+
2063 "This will set all the locations to match the Sales Order - and remove all old locations.",
2070 url : baseURL + '/Roo/Cohead',
2073 _fill_location : _this.form.findField('cohead_id').getValue(),
2074 _location_id : _this.form.findField('cohead_location_src').getValue()
2076 success : function() {
2077 _this.grid.footer.onClick('first');
2086 '|xns' : 'Roo.Toolbar',
2087 text : "Prices with GST",
2088 enableToggle : true,
2093 toggle : function (_self, pressed)
2095 this.setText(pressed ? "Prices exc GST" : "Prices with GST");
2096 var cm = _this.grid.getColumnModel();
2098 cm.setHidden(cm.getIndexByDataIndex('coitem_price_tax'), pressed ? false : true);
2099 cm.setHidden(cm.getIndexByDataIndex('coitem_custprice_tax'), pressed ? false : true);
2100 cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal_tax'), pressed ? false : true);
2102 cm.setHidden(cm.getIndexByDataIndex('coitem_price'), pressed ? true : false);
2103 cm.setHidden(cm.getIndexByDataIndex('coitem_custprice'), pressed ? true : false);
2104 cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal'), pressed ? true : false);
2107 render : function (_self)
2109 _this.showgstBtn = _self;
2118 '|xns' : 'Roo.data',
2119 url : baseURL + '/Roo/coitem.php',
2120 xtype : 'HttpProxy',
2125 '|xns' : 'Roo.data',
2128 xtype : 'JsonReader',
2131 'name': 'coitem_linenumber',
2135 'name': 'coitem_itemsite_id',
2139 'name': 'coitem_qtyord'
2142 'name': 'coitem_unitcost'
2145 'name': 'coitem_price'
2148 'name': 'coitem_custprice'
2151 'name': 'coitem_qtyreturned'
2154 'name': 'coitem_prcost'
2157 'name': 'coitem_price_uom_id',
2161 'name': 'coitem_qtyreserved'
2165 builderCfg : '{\"cols\":[{\"table\":\"coitem\",\"column\":\"coitem_linenumber\",\"columnshort\":\"coitem_linenumber\",\"ctype\":\"int4\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Item#\"},{\"table\":\"coitem\",\"column\":\"coitem_itemsite_id\",\"columnshort\":\"coitem_itemsite_id\",\"ctype\":\"int4\",\"desc\":\"\",\"maps_to\":\"itemsite_id\",\"deps\":[{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_item_id\",\"columnshort\":\"itemsite_item_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_warehous_id\",\"columnshort\":\"itemsite_warehous_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_qtyonhand\",\"columnshort\":\"itemsite_qtyonhand\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_reorderlevel\",\"columnshort\":\"itemsite_reorderlevel\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_ordertoqty\",\"columnshort\":\"itemsite_ordertoqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_cyclecountfreq\",\"columnshort\":\"itemsite_cyclecountfreq\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_datelastcount\",\"columnshort\":\"itemsite_datelastcount\",\"ctype\":\"date\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_datelastused\",\"columnshort\":\"itemsite_datelastused\",\"ctype\":\"date\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_loccntrl\",\"columnshort\":\"itemsite_loccntrl\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_safetystock\",\"columnshort\":\"itemsite_safetystock\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_minordqty\",\"columnshort\":\"itemsite_minordqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_multordqty\",\"columnshort\":\"itemsite_multordqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_leadtime\",\"columnshort\":\"itemsite_leadtime\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_abcclass\",\"columnshort\":\"itemsite_abcclass\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_issuemethod\",\"columnshort\":\"itemsite_issuemethod\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_controlmethod\",\"columnshort\":\"itemsite_controlmethod\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_active\",\"columnshort\":\"itemsite_active\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_plancode_id\",\"columnshort\":\"itemsite_plancode_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_costcat_id\",\"columnshort\":\"itemsite_costcat_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_eventfence\",\"columnshort\":\"itemsite_eventfence\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_sold\",\"columnshort\":\"itemsite_sold\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_stocked\",\"columnshort\":\"itemsite_stocked\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_freeze\",\"columnshort\":\"itemsite_freeze\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_location_id\",\"columnshort\":\"itemsite_location_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_useparams\",\"columnshort\":\"itemsite_useparams\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_useparamsmanual\",\"columnshort\":\"itemsite_useparamsmanual\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_soldranking\",\"columnshort\":\"itemsite_soldranking\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createpr\",\"columnshort\":\"itemsite_createpr\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_location\",\"columnshort\":\"itemsite_location\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_location_comments\",\"columnshort\":\"itemsite_location_comments\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_notes\",\"columnshort\":\"itemsite_notes\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_perishable\",\"columnshort\":\"itemsite_perishable\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_nnqoh\",\"columnshort\":\"itemsite_nnqoh\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_autoabcclass\",\"columnshort\":\"itemsite_autoabcclass\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_ordergroup\",\"columnshort\":\"itemsite_ordergroup\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_disallowblankwip\",\"columnshort\":\"itemsite_disallowblankwip\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_maxordqty\",\"columnshort\":\"itemsite_maxordqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_mps_timefence\",\"columnshort\":\"itemsite_mps_timefence\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createwo\",\"columnshort\":\"itemsite_createwo\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_warrpurc\",\"columnshort\":\"itemsite_warrpurc\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_autoreg\",\"columnshort\":\"itemsite_autoreg\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_costmethod\",\"columnshort\":\"itemsite_costmethod\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_value\",\"columnshort\":\"itemsite_value\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_ordergroup_first\",\"columnshort\":\"itemsite_ordergroup_first\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_supply_itemsite_id\",\"columnshort\":\"itemsite_supply_itemsite_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_planning_type\",\"columnshort\":\"itemsite_planning_type\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_wosupply\",\"columnshort\":\"itemsite_wosupply\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_posupply\",\"columnshort\":\"itemsite_posupply\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_lsseq_id\",\"columnshort\":\"itemsite_lsseq_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_cosdefault\",\"columnshort\":\"itemsite_cosdefault\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createsopr\",\"columnshort\":\"itemsite_createsopr\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createsopo\",\"columnshort\":\"itemsite_createsopo\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_dropship\",\"columnshort\":\"itemsite_dropship\",\"ctype\":\"bool\",\"desc\":\"\"}],\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"coitem\",\"column\":\"coitem_qtyord\",\"columnshort\":\"coitem_qtyord\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Qty\"},{\"table\":\"coitem\",\"column\":\"coitem_unitcost\",\"columnshort\":\"coitem_unitcost\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Unit Cost\"},{\"table\":\"coitem\",\"column\":\"coitem_price\",\"columnshort\":\"coitem_price\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Price\"},{\"table\":\"coitem\",\"column\":\"coitem_custprice\",\"columnshort\":\"coitem_custprice\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust Price\"},{\"table\":\"coitem\",\"column\":\"coitem_qtyreturned\",\"columnshort\":\"coitem_qtyreturned\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#Returned\"},{\"table\":\"coitem\",\"column\":\"coitem_prcost\",\"columnshort\":\"coitem_prcost\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"prcost?\"},{\"table\":\"coitem\",\"column\":\"coitem_price_uom_id\",\"columnshort\":\"coitem_price_uom_id\",\"ctype\":\"int4\",\"desc\":\"\",\"maps_to\":\"uom_id\",\"deps\":[{\"table\":\"uom\",\"column\":\"coitem_price_uom_id_uom_name\",\"columnshort\":\"uom_name\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"uom\",\"column\":\"coitem_price_uom_id_uom_descrip\",\"columnshort\":\"uom_descrip\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"uom\",\"column\":\"coitem_price_uom_id_uom_item_weight\",\"columnshort\":\"uom_item_weight\",\"ctype\":\"bool\",\"desc\":\"\"}],\"use\":1,\"use_ex\":\"\",\"title\":\"Unit of\"},{\"table\":\"coitem\",\"column\":\"coitem_qtyreserved\",\"columnshort\":\"coitem_qtyreserved\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#reserved\"}],\"cols_ex\":[\"coitem_price_uom_id_uom_descrip\"],\"table\":\"coitem\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
2166 totalProperty : 'total'
2168 '|xns' : 'Roo.data',
2171 sortInfo : { field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' },
2174 beforeload : function (_self,o) {
2181 if (!_this.data || !_this.data.cohead_id) {
2184 o.params = o.params || {};
2186 o.params.coitem_cohead_id = _this.data.cohead_id;
2187 o.params._without_list_discount =1;
2188 //o.params.limit = 999;
2192 update : function (_self, rec, operation)
2195 if (operation != Roo.data.Record.COMMIT) {
2199 // row has been updated..
2200 // if the qty + item has been filled in, we should try and save it..
2203 var setRecord = function(){
2205 Roo.log("Clearing update?" + rec.data.coitem_linenumber);
2206 rec.updatePending = 0;
2207 if(rec.isInserting){
2208 rec.isInserting = 0;
2214 if (!(rec.data.coitem_itemsite_id * 1) || !(rec.data.coitem_qtyord*1)) {
2218 var doCommit = function() {
2219 Roo.log("Sending data?" + rec.data.coitem_linenumber);
2222 url : baseURL+'/Roo/coitem',
2225 success: function(res)
2228 var row = _this.grid.ds.indexOf(rec);
2229 Roo.get(_this.grid.view.getRow(row)).removeClass('dragon-not-saved');
2235 Roo.log("GOT success: " + rec.data.coitem_linenumber);
2236 //Roo.log("GOT success");
2237 // update the data...
2239 if (rec.data.item_type == 'K') {
2241 _this.grid.ds.load({});
2246 // why is this here.??
2248 if (_this.grid.activeEditor) {
2254 rec.set('coitem_id', res.data.coitem_id);
2255 rec.set('coitem_status', res.data.coitem_status);
2259 delete rec.modified;
2261 _this.grid.footer.updateSummary();
2262 _this.grid.loadAvail();
2268 failure : function(res)
2271 Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error updating");
2284 load : function (_self, records, options)
2286 // need to fetch availablity from master data..
2287 // build a list of what to ask..
2289 // query: ITEM CODE - LOCATION
2290 _this.grid.footer.updateSummary();
2291 _this.grid.loadAvail.defer(100, _this.grid);
2309 '|xns' : 'Roo.Toolbar',
2312 cls : 'x-btn-text-icon',
2313 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
2319 Roo.log("add presed");
2322 var grid = _this.grid;
2324 grid.ds.each(function(r) {
2325 if (r.data.coitem_qtyord < 1) {
2326 Roo.MessageBox.alert("Error", "you must fill in a quantity for " + r.data.item_number);
2338 var last = _this.form.findField('cohead_max_linenumber').getValue();
2345 _this.form.findField('cohead_max_linenumber').setValue(last);
2347 // this should be getting the previous row..??
2348 var ct = _this.grid.ds.getCount();
2349 var lastrow = ct ? _this.grid.ds.getAt(ct-1) : false;
2351 function lastor(k,d,kk) {
2352 var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();
2353 return lastrow ? lastrow.data[kk] : def;
2356 // uses form defaults or last row value.
2357 var nr = _this.grid.ds.reader.newRow({
2358 coitem_linenumber : last,
2362 coitem_cohead_id : _this.form.findField('cohead_id').getValue(),
2363 coitem_qtyshipped : 0,
2364 coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),
2365 coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),
2366 coitem_shipto_id : lastor('cohead_shipto_id',false, 'coitem_shipto_id'),
2367 coitem_shipto_id_shipto_name : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name'),
2368 coitem_unitcost_in_order_cur : 0,
2369 coitem_taxtype_id : _this.data.default_taxtype_id,
2370 coitem_taxtype_id_taxtype_name : 'Taxable',
2376 grid.ds.insert(grid.ds.getCount(), nr);
2377 grid.startEditing(grid.ds.getCount()-1, 1); // type..
2378 nr.updatePending = 0;
2383 render : function (_self)
2385 _this.addItemBtn = _self;
2390 '|xns' : 'Roo.Toolbar',
2391 text : "Find Products",
2393 cls : 'x-btn-text-icon',
2394 icon : rootURL + '/Pman/templates/images/search.gif',
2397 click : function (_self, e)
2399 var last = _this.form.findField('cohead_max_linenumber').getValue();
\r
2401 _this.form.findField('cohead_max_linenumber').setValue(last);
2403 var ct = _this.grid.ds.getCount();
\r
2404 var lastrow = ct ? _this.grid.ds.getAt(ct-1) : false;
\r
2406 function lastor(k,d,kk) {
\r
2407 var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();
\r
2408 return lastrow ? lastrow.data[kk] : def;
\r
2411 var cohead_cust_id = _this.form.findField('cohead_cust_id').getValue();
2412 var cohead_id = _this.form.findField('cohead_id').getValue();
2414 Pman.Dialog.XtupleSalesProductList.show( {cohead_cust_id : cohead_cust_id, cohead_id : cohead_id} , function(res) {
2416 _this.grid.stopEditing();
2418 if (_this.grid.ds.getCount() > 0) {
2419 var lr = _this.grid.ds.getAt(_this.grid.ds.getCount()-1);
2420 if (!lr.data.coitem_itemsite_id) {
2421 lr.set('coitem_itemsite_id', res.item_itemsite_id_itemsite_id);
2422 lr.set('item_number', res.item_number);
2423 lr.set('item_descrip1', res.item_descrip1);
2424 lr.set('coitem_listprice', res.item_price);
2425 lr.set('coitem_price', res.item_price);
2426 lr.set('coitem_custprice', res.item_price);
2433 var nr = _this.grid.ds.reader.newRow({
2434 coitem_linenumber : last,
2435 coitem_itemsite_id : res.item_itemsite_id_itemsite_id,
2436 item_number : res.item_number,
2437 item_descrip1 : res.item_descrip1,
2439 coitem_cohead_id : _this.form.findField('cohead_id').getValue(),
2440 coitem_qtyshipped : 0,
2441 coitem_listprice : res.item_price,
2442 coitem_price : res.item_price,
2443 coitem_custprice : res.item_price,
2445 coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),
2446 coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),
2447 coitem_shipto_id : lastor('cohead_shipto_id',false, 'coitem_shipto_id'),
2448 coitem_shipto_id_shipto_name : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name')
2451 _this.grid.ds.insert(_this.grid.ds.getCount(), nr);
2458 '|xns' : 'Roo.Toolbar',
2459 text : "Xfer all stock to HK",
2462 cls : 'x-btn-text-icon',
2463 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
2470 url : baseURL + '/Roo/coitem',
2471 mask : 'Loading Data',
2475 _hk_xfer :_this.form.findField('cohead_id').getValue()
2477 success : function() {
2478 _this.grid.ds.load({});
2483 render : function (_self)
2485 _this.xferAll = _self;
2490 '|xns' : 'Roo.Toolbar',
2491 text : "Show Inventory History",
2495 click : function (_self, e)
2497 var c = _this.grid.getSelectionModel().getSelectedCell();
2499 Roo.MessageBox.alert("Error", "Select item to show history (you can also double click on the #avail number) ");
2503 var rec = _this.grid.ds.getAt(c[0]);
2505 Pman.Dialog.XtupleInvHistory.show({
2506 itemsite_item_id_item_number : rec.data.item_number,
2507 // itemsite_item_id_item_descript1 : rec.data.item_descrip1,
2508 location_name : rec.data.coitem_location_src_location_name,
2509 location_descrip : rec.data.coitem_location_src_location_descrip,
2512 invhist_transdate : _this.form.findField('cohead_targetdate').getValue()
2520 '|xns' : 'Roo.Toolbar',
2521 xtype : 'Separator',
2525 '|xns' : 'Roo.Toolbar',
2526 text : "Apply % Discount of : ",
2531 '|xns' : 'Roo.form',
2532 xtype : 'TextField',
2536 render : function (_self)
2538 _this._applyDiscount = _self;
2543 '|xns' : 'Roo.Toolbar',
2544 text : "Apply To All",
2548 click : function (_self, e)
2550 var val = parseFloat(_this._applyDiscount.getValue());
2552 var factor = (100.0 - val)/100.0;
2554 _this.grid.ds.each(function(rec) {
2555 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2559 rec.set('coitem_price', rec.data.coitem_custprice * factor);
2560 rec.set('coitem_linedisc', val);
2561 rec.set('coitem_subtotal', rec.data.coitem_price & rec.data.ordqty);
2571 '|xns' : 'Roo.Toolbar',
2576 click : function (_self, e)
2579 if (!(1* _this.form.findField('cohead_id').getValue())) {
2580 Roo.MessageBox.alert("Error", "save the order first");
2584 Pman.Dialog.Image.show(
2587 _url : baseURL+'/Xtuple/Import/SalesOrder',
2588 onid : _this.form.findField('cohead_id').getValue()
2593 Roo.MessageBox.alert("Notice", "Uploaded");
2594 _this.grid.footer.onClick('first');
2602 '|xns' : 'Roo.Toolbar',
2607 '|xns' : 'Roo.Toolbar',
2610 cls : 'x-btn-text-icon',
2611 icon : rootURL + '/Pman/templates/images/trash.gif',
2616 _this.grid.stopEditing();
2617 // check that no shipments or invoices are done..
2618 var rc = _this.grid.getSelectionModel().getSelectedCell();
2620 var rec = _this.grid.ds.getAt(rc[0]);
2622 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2623 Roo.MessageBox.alert("Error", "That item has been shipped or invoices - void the shipments/invoices first");
2626 if (rec.data.coitem_subnumber*1 > 0) {
2627 Roo.MessageBox.alert("Error", "Delete the kit item that that belongs to.");
2630 if (!rec.data.coitem_id) {
2631 _this.grid.ds.remove(rec);
2638 url : baseURL + '/Roo/coitem',
2641 _delete : rec.data.coitem_id
2644 success : function() {
2645 if (rec.data.item_type == 'K') {
2646 _this.grid.ds.load({});
2649 _this.grid.ds.remove(rec);
2654 if (rec.data_qtyord * 1 < 1) {
2658 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that line?", function(r)
2673 '|xns' : 'Roo.Toolbar',
2674 text : "Delete All",
2676 cls : 'x-btn-text-icon',
2677 icon : rootURL + '/Pman/templates/images/trash.gif',
2682 _this.grid.stopEditing();
2683 // check that no shipments or invoices are done..
2685 _this.grid.ds.each(function(rec) {
2689 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {
2690 //Roo.MessageBox.alert("Error", "That item has been shipped or invoices - void the shipments/invoices first");
2693 if (rec.data.item_type == 'K') {
2697 if (rec.data.coitem_subnumber*1 > 0) {
2698 //Roo.MessageBox.alert("Error", "Delete the kit item that that belongs to.");
2701 if (!rec.data.coitem_id) {
2702 _this.grid.ds.remove(rec);
2705 ids.push(rec.data.coitem_id);
2711 url : baseURL + '/Roo/coitem',
2714 _delete : ids.join(',')
2717 success : function() {
2719 _this.grid.footer.onClick('first');
2724 // if (rec.data_qtyord * 1 < 1) {
2728 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete everything?", function(r)
2745 '|xns' : 'Roo.grid',
2746 autoExpandColumn : 'item_descrip1',
2747 xtype : 'EditorGrid',
2749 loadAvail : function() {
2752 this.ds.each(function(r) {
2754 if(!r.data.item_number.length){
2758 if(typeof(_this.stockcache[r.data.item_number]) != 'undefined'){
2760 r.set('avail_qty', _this.stockcache[r.data.item_number].qty);
2761 if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {
2762 r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);
2770 item : r.data.item_number,
2771 loc: r.data.coitem_location_src_location_name,
2772 id: r.data.coitem_linenumber + (r.data.coitem_subnumber ? ('.' + r.data.coitem_subnumber) : '')
2776 url : baseURL + '/Roo/itemloc',
2779 _availqty : Roo.encode(q),
2780 curr_name : _this.form.findField('cohead_curr_id').el.dom.value
2782 success : function(res)
2784 for (var i in res.data) {
2785 _this.stockcache[res.data[i].item] = res.data[i];
2787 r.set('avail_qty', _this.stockcache[r.data.item_number].qty);
2788 if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {
2789 r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);
2791 //_this.grid.ds.fireEvent("update", _this.grid.ds, r, Roo.data.Record.EDIT);
2803 '|xns' : 'Roo.grid',
2804 xtype : 'ColumnModel',
2807 renderer : function(v,x,r) {
2809 if (r.data.coitem_subnumber * 1 > 0) {
2810 return String.format('{0}.{1}', v,r.data.coitem_subnumber);
2812 return String.format('{0}', v);
2815 dataIndex : 'coitem_linenumber',
2816 builderCfg : '{\"table\":\"coitem\",\"column\":\"coitem_linenumber\",\"columnshort\":\"coitem_linenumber\",\"ctype\":\"int4\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Item#\"}'
2823 '|xns' : 'Roo.data',
2824 url : baseURL + '/Roo/itemsite.php',
2825 xtype : 'HttpProxy',
2830 '|xns' : 'Roo.data',
2833 xtype : 'JsonReader',
2834 fields : [{"name":"item_id","type":"int"},"item_number"],
2836 totalProperty : 'total'
2838 '|xns' : 'Roo.data',
2841 sortInfo : { direction : 'ASC', field: 'item_number' },
2844 beforeload : function (_self, o){
2845 o.params = o.params || {};
2846 o.params.customer_id = _this.form.findField('cohead_cust_id').getValue();
2847 o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue();
2848 //o.params.shipto_cust_id = _this.data.cohead_cust_id;
2857 '|xns' : 'Roo.form',
2859 triggerAction : 'all',
2860 forceSelection : true,
2861 selectOnFocus : true,
2863 displayField : 'itemsite_item_id_item_number',
2864 emptyText : "Select item",
2865 hiddenName : 'itemsite_item_id_item_number',
2867 valueField : 'item_number',
2873 name : 'item_number',
2874 qtip : "Select item",
2875 queryParam : 'query[number]',
2876 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>',
2877 loadingText : "Searching...",
2879 beforeselect : function (combo, record, index)
2881 // set _this.data values ..
2882 var ar = _this.grid.activeEditor.record;
2883 // Roo.log('beforeselect');
2887 // Roo.log('beforeselect-cb');
2888 ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
2889 ar.set('coitem_listprice', record.data.item_listprice);
2890 ar.set('coitem_price', record.data.item_price);
2891 ar.set('coitem_custprice', record.data.item_price);
2892 ar.set('coitem_itemsite_id', record.data.itemsite_id);
2893 ar.set('item_number', record.data.itemsite_item_id_item_number);
2894 ar.set('item_type', record.data.itemsite_item_id_item_type);
2895 ar.set('avail_qty', 0);
2906 '|xns' : 'Roo.grid',
2907 xtype : 'GridEditor',
2914 '|xns' : 'Roo.grid',
2915 xtype : 'ColumnModel',
2916 header : 'Item Code',
2918 renderer : function(v) { return String.format('{0}', v); },
2920 dataIndex : 'item_number',
2931 '|xns' : 'Roo.data',
2932 url : baseURL + '/Roo/location.php',
2933 xtype : 'HttpProxy',
2938 '|xns' : 'Roo.data',
2941 xtype : 'JsonReader',
2942 fields : [{"name":"location_id","type":"int"},"location_name"],
2944 totalProperty : 'total'
2946 '|xns' : 'Roo.data',
2949 sortInfo : { direction : 'ASC', field: 'location_name' },
2952 beforeload : function (_self, o){
2953 o.params = o.params || {};
2955 var row = _this.grid.activeEditor.record;
2957 o.params['query[item_itemsite_id]'] = row.data.coitem_itemsite_id;
2958 // need to know the date to calc the est. delivery time..
2959 //o.params['query[avail_when]'] = _this.form.findField('cohead_targetdate').getValue().format('Y-m-d');
2960 //o.params.location_netable = 1;
2961 o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue();
2963 o.params.location_restrict = 0;
2964 o.params._notinternalcompany = 1;
2968 // o.params.itemsite_id = _this.form.findField('cohead_cust_id').getValue();
2969 //o.params.shipto_cust_id = _this.data.cohead_cust_id;
2978 '|xns' : 'Roo.form',
2981 triggerAction : 'all',
2982 forceSelection : true,
2983 selectOnFocus : true,
2985 displayField : 'location_name',
2986 emptyText : "Select location",
2987 hiddenName : 'coitem_location_src',
2989 valueField : 'location_id',
2995 name : 'coitem_location_src_location_name',
2996 qtip : "Select item",
2997 queryParam : 'query[location_name]',
2998 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b> {location_name}</b> {location_descrip}</div>',
2999 loadingText : "Searching...",
3001 beforeselect : function (combo, record, index)
3003 // set _this.data values ..
3004 var ar = _this.grid.activeEditor.record;
3008 //Roo.log('beforeselect');
3012 // Roo.log('beforeselect-cb');
3013 ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
3014 ar.set('coitem_price', record.data.item_listprice);
3015 ar.set('coitem_custprice', record.data.item_price);
3016 ar.set('coitem_itemsite_id', record.data.itemsite_id);
3017 ar.set('item_number', record.data.itemsite_item_id_item_number);
3029 '|xns' : 'Roo.grid',
3030 xtype : 'GridEditor',
3037 '|xns' : 'Roo.grid',
3038 xtype : 'ColumnModel',
3041 renderer : function(v,x,r) {
3042 return String.format('{0}', r.data.coitem_location_src_location_name);
3045 dataIndex : 'coitem_location_src',
3056 '|xns' : 'Roo.data',
3057 url : baseURL + '/Roo/shiptoinfo.php',
3058 xtype : 'HttpProxy',
3063 '|xns' : 'Roo.data',
3066 xtype : 'JsonReader',
3067 fields : [{"name":"cntct_id","type":"int"},"cntct_name"],
3069 totalProperty : 'total'
3071 '|xns' : 'Roo.data',
3074 sortInfo : { direction : 'ASC', field: 'shipto_name' },
3077 beforeload : function (_self, o){
3078 o.params = o.params || {};
3079 o.params.shipto_cust_id = _this.data.cohead_cust_id;
3080 //o.params['query[with_shipinfo]'] = 1;
3089 '|xns' : 'Roo.form',
3092 triggerAction : 'all',
3093 forceSelection : true,
3094 selectOnFocus : true,
3096 displayField : 'shipto_name',
3097 emptyText : "Select cntct",
3098 hiddenName : 'cohead_shipto_id',
3100 valueField : 'shipto_id',
3107 name : 'coitem_shipto_id_shipto_name',
3108 qtip : "Select shipto",
3109 queryParam : 'query[shipto_name]',
3110 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{shipto_id}:{shipto_addr_id_addr_name}</b> </div>',
3111 loadingText : "Searching...",
3113 add : function (combo)
3116 Pman.Dialog.XtupleCustomer.show({ cust_id : _this.form.findField('cohead_cust_id').getValue() }, function(data) {
3117 // refresh the data in the pulldown..
3120 beforeselect : function (combo, record, index)
3124 for(var i = 1; i <4; i++) {
3125 _this.data['cohead_shiptoaddress'+ i] = record.data['cntct_addr_id_addr_line'+i];
3127 _this.form.findField('shipto_address').update();
3137 '|xns' : 'Roo.grid',
3138 xtype : 'GridEditor',
3145 '|xns' : 'Roo.grid',
3146 xtype : 'ColumnModel',
3149 renderer : function(v,x,r) {
3150 return String.format('{0}:{1}', v, r.data.coitem_shipto_id_shipto_name);
3153 dataIndex : 'coitem_shipto_id',
3162 '|xns' : 'Roo.form',
3163 xtype : 'TextField',
3167 '|xns' : 'Roo.grid',
3168 xtype : 'GridEditor',
3175 '|xns' : 'Roo.grid',
3176 xtype : 'ColumnModel',
3177 header : 'Item Description',
3179 renderer : function(v,x,r) {
3181 if (r.data.coitem_memo && r.data.coitem_memo.length) {
3182 return String.format('{0}', r.data.coitem_memo);
3183 if (r.data.coitem_memo != v) {
3184 r.set('item_descrip1', r.data.coitem_memo);
3188 if (v && v.length > 49) {
3189 return String.format('<span style="color:orange" qtip="line may be too long to print">{0}</span>', v);
3192 return String.format('{0}', v);
3196 dataIndex : 'item_descrip1',
3197 builderCfg : '{\"table\":\"coitem\",\"column\":\"coitem_itemsite_id\",\"columnshort\":\"coitem_itemsite_id\",\"ctype\":\"int4\",\"desc\":\"\",\"maps_to\":\"itemsite_id\",\"deps\":[{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_item_id\",\"columnshort\":\"itemsite_item_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_warehous_id\",\"columnshort\":\"itemsite_warehous_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_qtyonhand\",\"columnshort\":\"itemsite_qtyonhand\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_reorderlevel\",\"columnshort\":\"itemsite_reorderlevel\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_ordertoqty\",\"columnshort\":\"itemsite_ordertoqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_cyclecountfreq\",\"columnshort\":\"itemsite_cyclecountfreq\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_datelastcount\",\"columnshort\":\"itemsite_datelastcount\",\"ctype\":\"date\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_datelastused\",\"columnshort\":\"itemsite_datelastused\",\"ctype\":\"date\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_loccntrl\",\"columnshort\":\"itemsite_loccntrl\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_safetystock\",\"columnshort\":\"itemsite_safetystock\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_minordqty\",\"columnshort\":\"itemsite_minordqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_multordqty\",\"columnshort\":\"itemsite_multordqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_leadtime\",\"columnshort\":\"itemsite_leadtime\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_abcclass\",\"columnshort\":\"itemsite_abcclass\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_issuemethod\",\"columnshort\":\"itemsite_issuemethod\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_controlmethod\",\"columnshort\":\"itemsite_controlmethod\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_active\",\"columnshort\":\"itemsite_active\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_plancode_id\",\"columnshort\":\"itemsite_plancode_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_costcat_id\",\"columnshort\":\"itemsite_costcat_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_eventfence\",\"columnshort\":\"itemsite_eventfence\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_sold\",\"columnshort\":\"itemsite_sold\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_stocked\",\"columnshort\":\"itemsite_stocked\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_freeze\",\"columnshort\":\"itemsite_freeze\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_location_id\",\"columnshort\":\"itemsite_location_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_useparams\",\"columnshort\":\"itemsite_useparams\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_useparamsmanual\",\"columnshort\":\"itemsite_useparamsmanual\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_soldranking\",\"columnshort\":\"itemsite_soldranking\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createpr\",\"columnshort\":\"itemsite_createpr\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_location\",\"columnshort\":\"itemsite_location\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_location_comments\",\"columnshort\":\"itemsite_location_comments\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_notes\",\"columnshort\":\"itemsite_notes\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_perishable\",\"columnshort\":\"itemsite_perishable\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_nnqoh\",\"columnshort\":\"itemsite_nnqoh\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_autoabcclass\",\"columnshort\":\"itemsite_autoabcclass\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_ordergroup\",\"columnshort\":\"itemsite_ordergroup\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_disallowblankwip\",\"columnshort\":\"itemsite_disallowblankwip\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_maxordqty\",\"columnshort\":\"itemsite_maxordqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_mps_timefence\",\"columnshort\":\"itemsite_mps_timefence\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createwo\",\"columnshort\":\"itemsite_createwo\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_warrpurc\",\"columnshort\":\"itemsite_warrpurc\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_autoreg\",\"columnshort\":\"itemsite_autoreg\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_costmethod\",\"columnshort\":\"itemsite_costmethod\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_value\",\"columnshort\":\"itemsite_value\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_ordergroup_first\",\"columnshort\":\"itemsite_ordergroup_first\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_supply_itemsite_id\",\"columnshort\":\"itemsite_supply_itemsite_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_planning_type\",\"columnshort\":\"itemsite_planning_type\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_wosupply\",\"columnshort\":\"itemsite_wosupply\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_posupply\",\"columnshort\":\"itemsite_posupply\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_lsseq_id\",\"columnshort\":\"itemsite_lsseq_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_cosdefault\",\"columnshort\":\"itemsite_cosdefault\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createsopr\",\"columnshort\":\"itemsite_createsopr\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createsopo\",\"columnshort\":\"itemsite_createsopo\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_dropship\",\"columnshort\":\"itemsite_dropship\",\"ctype\":\"bool\",\"desc\":\"\"}],\"use\":1,\"use_ex\":\"\",\"title\":\"\"}',
3204 '|xns' : 'Roo.grid',
3206 xtype : 'ColumnModel',
3209 renderer : function(v) { return String.format('{0}', v); },
3211 builderCfg : '{\"table\":\"coitem\",\"column\":\"coitem_unitcost\",\"columnshort\":\"coitem_unitcost\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Unit Cost\"}',
3212 dataIndex : 'coitem_status'
3217 '|xns' : 'Roo.form',
3219 style : 'text-align:right',
3220 xtype : 'NumberField',
3221 allowDecimals : false,
3222 decimalPrecision : 0,
3225 focus : function (_self)
3227 if (this.value == 0) {
3228 this.el.dom.value = '';
3233 '|xns' : 'Roo.grid',
3234 xtype : 'GridEditor',
3241 '|xns' : 'Roo.grid',
3243 xtype : 'ColumnModel',
3246 renderer : function(v,x,r) {
3247 var v = parseInt(v);
3248 //var aq = parseInt(r.data.avail_qty);
3249 //aq = isNaN(aq) ? 0 : aq;
3251 var rate = _this.form.findField('taxzone_rate').getValue();
3252 r.data.coitem_subtotal = v * r.data.coitem_price;
3253 r.data.coitem_subtotal_tax = v * r.data.coitem_price * ( 1 + rate * 1);
3254 return String.format('{0}', v);
3258 dataIndex : 'coitem_qtyord',
3267 '|xns' : 'Roo.form',
3269 style : 'text-align:right',
3270 xtype : 'NumberField',
3271 decimalPrecision : 3,
3274 focus : function (_self)
3276 if (this.value == 0.0) {
3277 this.el.dom.value = '';
3282 '|xns' : 'Roo.grid',
3283 xtype : 'GridEditor',
3290 '|xns' : 'Roo.grid',
3292 xtype : 'ColumnModel',
3295 renderer : function(v,x,r) {
3297 var rate = _this.form.findField('taxzone_rate').getValue();
3298 r.data.coitem_subtotal = v * r.data.coitem_qtyord;
3299 r.data.coitem_subtotal_tax = v * ( 1 + rate * 1 ) * r.data.coitem_qtyord;
3300 r.data.coitem_price_tax = v * ( 1 + rate * 1 );
3301 if (parseInt(v) < 1) {
3302 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,3));
3306 //r.set('coitem_subtotal', v * r.data.coitem_qtyord);
3308 return String.format('{0}', Roo.util.Format.number(v,3));
3311 dataIndex : 'coitem_price',
3320 '|xns' : 'Roo.form',
3322 style : 'text-align:right',
3323 xtype : 'NumberField',
3324 decimalPrecision : 3,
3327 focus : function (_self)
3329 if (this.value == 0.0) {
3330 this.el.dom.value = '';
3335 '|xns' : 'Roo.grid',
3336 xtype : 'GridEditor',
3343 '|xns' : 'Roo.grid',
3346 xtype : 'ColumnModel',
3347 header : 'Sell @w/GST',
3349 renderer : function(v,x,r) {
3351 if (parseInt(v) < 1) {
3352 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,3));
3355 return String.format('{0}', Roo.util.Format.number(v,3));
3358 dataIndex : 'coitem_price_tax',
3367 '|xns' : 'Roo.form',
3369 style : 'text-align:right',
3370 xtype : 'NumberField',
3371 decimalPrecision : 2,
3375 focus : function (_self)
3377 if (this.value == 0.0) {
3378 this.el.dom.value = '';
3383 '|xns' : 'Roo.grid',
3384 xtype : 'GridEditor',
3391 '|xns' : 'Roo.grid',
3393 xtype : 'ColumnModel',
3396 renderer : function(v,x,r) {
3398 // coitem_custprice = coitem_price * ((100 - coitem_disc)/ 100)
3400 // 12 * (( 100 - 0) / 100)
3401 // coitem_custprice / coitem_price = ((100 - coitem_disc)/ 100)
3402 // 100 - ((coitem_custprice / coitem_price) * 100) = coitem_disc
3403 // 100 - 97 = 100 -3
3405 // r.data.coitem_linedisc = 100 - (
3406 // (parseFloat(r.data.coitem_custprice) /
3407 // parseFloat(r.data.coitem_price)
3409 var fl = parseFloat(r.data.coitem_linedisc);
3410 if ( isNaN(fl) || fl == 0.0 || r.data.coitem_price > r.data.coitem_custprice) {
3413 return String.format('<span style="color:green">{0}%</span>', Roo.util.Format.number( r.data.coitem_linedisc,2));
3416 dataIndex : 'coitem_linedisc',
3425 '|xns' : 'Roo.form',
3427 style : 'text-align:right',
3428 xtype : 'NumberField',
3429 decimalPrecision : 3,
3432 focus : function (_self)
3434 if (this.value == 0.0) {
3435 this.el.dom.value = '';
3440 '|xns' : 'Roo.grid',
3441 xtype : 'GridEditor',
3448 '|xns' : 'Roo.grid',
3450 xtype : 'ColumnModel',
3451 header : 'List Price',
3453 renderer : function(v,x,r) {
3455 var rate = _this.form.findField('taxzone_rate').getValue();
3456 r.data.coitem_custprice_tax = v * ( 1 + rate * 1 );
3458 var tip = 'No WRP available';
3459 if ((r.data.coitem_wrpprice * 1) > 0) {
3460 tip = "WRP : " + Roo.util.Format.number(r.data.coitem_wrpprice,3);
3462 // less than zero, show as red..
3463 if (parseFloat(v) < 1) {
3464 return String.format('<b qtip="{1}" style="color:red;">{0}</b>',
3465 Roo.util.Format.number(v,3), tip);
3467 if (r.data.customer_price_each != v) {
3468 return String.format('<b qtip="{1}" style="color:pink;">{0}</b>',
3469 Roo.util.Format.number(v,3),
3470 "List Price = " + Roo.util.Format.number(r.data.customer_price_each,3)
3476 //r.data.coitem_subtotal = v * r.data.coitem_qtyord;
3478 //r.set('coitem_subtotal', v * r.data.coitem_qtyord);
3480 return String.format('<span qtip="{1}">{0}</span>', Roo.util.Format.number(v,3), tip);
3483 dataIndex : 'coitem_custprice',
3492 '|xns' : 'Roo.form',
3494 style : 'text-align:right',
3495 xtype : 'NumberField',
3496 decimalPrecision : 3,
3499 focus : function (_self)
3501 if (this.value == 0.0) {
3502 this.el.dom.value = '';
3507 '|xns' : 'Roo.grid',
3508 xtype : 'GridEditor',
3515 '|xns' : 'Roo.grid',
3518 xtype : 'ColumnModel',
3519 header : 'List Price w/GST',
3521 renderer : function(v,x,r) {
3522 var rate = _this.form.findField('taxzone_rate').getValue();
3523 var tip = 'No WRP available';
3524 if ((r.data.coitem_wrpprice * 1) > 0) {
3525 tip = "WRP : " + Roo.util.Format.number(r.data.coitem_wrpprice,3);
3528 if (parseFloat(v) < 1) {
3529 return String.format('<b qtip="{1}" style="color:red;">{0}</b>',
3530 Roo.util.Format.number(v,3), tip);
3532 if (r.data.customer_price_each != v) {
3533 return String.format('<b qtip="{1}" style="color:pink;">{0}</b>',
3534 Roo.util.Format.number(v,3),
3535 "List Price = " + Roo.util.Format.number(r.data.customer_price_each * ( 1 + rate * 1 ),3)
3539 return String.format('<span qtip="{1}">{0}</span>', Roo.util.Format.number(v,3), tip);
3542 dataIndex : 'coitem_custprice_tax',
3549 '|xns' : 'Roo.grid',
3551 xtype : 'ColumnModel',
3552 header : 'SubTotal',
3554 renderer : function(v) {
3556 if (parseInt(v) < 1) {
3557 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,2));
3562 return Roo.util.Format.number( v, 2);
3565 dataIndex : 'coitem_subtotal'
3568 '|xns' : 'Roo.grid',
3571 xtype : 'ColumnModel',
3572 header : 'SubTotal w/GST',
3574 renderer : function(v,x,r) {
3576 if (parseInt(v) < 1) {
3577 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(v,2));
3580 return String.format('{0}', Roo.util.Format.number(v,2));
3583 dataIndex : 'coitem_subtotal_tax'
3586 '|xns' : 'Roo.grid',
3588 xtype : 'ColumnModel',
3589 header : 'Unit Cost',
3591 renderer : function(v) { return Roo.util.Format.number( v, 2); },
3593 builderCfg : '{\"table\":\"coitem\",\"column\":\"coitem_unitcost\",\"columnshort\":\"coitem_unitcost\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Unit Cost\"}',
3594 dataIndex : 'coitem_unitcost_in_order_cur'
3601 '|xns' : 'Roo.data',
3602 url : baseURL + '/Roo/taxtype.php',
3603 xtype : 'HttpProxy',
3608 '|xns' : 'Roo.data',
3611 xtype : 'JsonReader',
3612 fields : [{"name":"taxtype_id","type":"int"},"taxtype_name"],
3614 totalProperty : 'total'
3616 '|xns' : 'Roo.data',
3619 sortInfo : { direction : 'ASC', field: 'taxtype_name' },
3622 beforeload : function (_self, o){
3623 o.params = o.params || {};
3634 '|xns' : 'Roo.form',
3636 triggerAction : 'all',
3637 forceSelection : true,
3638 selectOnFocus : true,
3640 displayField : 'taxtype_name',
3641 emptyText : "Select Tax Type",
3642 hiddenName : 'coitem_taxtype_id',
3644 valueField : 'taxtype_id',
3651 name : 'coitem_taxtype_id_taxtype_name',
3652 qtip : "Select taxtype",
3653 queryParam : 'query[taxtype_id]',
3654 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{taxtype_name}</b> </div>',
3655 loadingText : "Searching...",
3661 '|xns' : 'Roo.grid',
3662 xtype : 'GridEditor',
3669 '|xns' : 'Roo.grid',
3671 xtype : 'ColumnModel',
3674 renderer : function(v,x,r) { return String.format('{0}', r.data.coitem_taxtype_id_taxtype_name); },
3676 dataIndex : 'coitem_taxtype_id',
3683 '|xns' : 'Roo.grid',
3685 xtype : 'ColumnModel',
3688 renderer : function(v,x,r) {
3690 var oq = parseInt(r.data.coitem_qtyord);
3691 var aq = parseInt(r.data.avail_qty);
3692 var sq = parseInt(r.data.coitem_qtyshipped);
3693 aq = isNaN(aq) ? 0 : aq;
3694 oq = isNaN(oq) ? 0 : oq;
3695 sq = isNaN(sq) ? 0 : sq;
3697 var unshipped = oq - sq;
3699 if ( aq < 0 || (unshipped > 0 && aq < unshipped)) {
3700 return String.format('<b style="color:red;">{0}</b>', parseInt(aq));
3703 return String.format('{0}', aq);
3707 dataIndex : 'avail_qty'
3710 '|xns' : 'Roo.grid',
3712 xtype : 'ColumnModel',
3713 header : '#reserved',
3715 renderer : function(v,x,r) {
3718 var vv = parseInt(v);
3719 vv = isNaN(vv) ? 0 : vv;
3721 var ov = parseInt(r.data.coitem_qtyord);
3722 ov = isNaN(ov) ? 0 : ov;
3724 var qs = parseInt(r.data.coitem_qtyshipped);
3725 qs = isNaN(qs) ? 0 : qs;
3730 // not enough reserved yet.
3731 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv - qs);
3734 return String.format('{0}', vv - qs);
3738 builderCfg : '{\"table\":\"coitem\",\"column\":\"coitem_qtyreserved\",\"columnshort\":\"coitem_qtyreserved\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#reserved\"}',
3739 dataIndex : 'shipitem_shipped'
3742 '|xns' : 'Roo.grid',
3744 xtype : 'ColumnModel',
3745 header : '#shipped',
3747 renderer : function(v,x,r) {
3749 var vv = parseInt(v);
3750 vv = isNaN(vv) ? 0 : vv;
3752 var ov = parseInt(r.data.coitem_qtyord);
3753 ov = isNaN(ov) ? 0 : ov;
3757 // not enought shipped.
3758 // or too many shipped.
3759 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv);
3764 return String.format('{0}', vv);
3768 builderCfg : '{\"table\":\"coitem\",\"column\":\"coitem_qtyreserved\",\"columnshort\":\"coitem_qtyreserved\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#reserved\"}',
3769 dataIndex : 'coitem_qtyshipped'
3772 '|xns' : 'Roo.grid',
3774 xtype : 'ColumnModel',
3775 header : '#invoiced',
3777 renderer : function(v,x,r) {
3779 var vv = parseInt(v);
3780 vv = isNaN(vv) ? 0 : vv;
3782 var ov = parseInt(r.data.coitem_qtyord);
3783 ov = isNaN(ov) ? 0 : ov;
3787 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv);
3789 return String.format('{0}', vv);
3793 dataIndex : 'cobill_billed'
3797 beforeedit : function (e)
3799 // we can only edit if nothing is assigned to shipping or invoices..
3803 if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0 || (rec.data.shipitem_shipped - rec.data.coitem_qtyshipped) > 0 ) {
3804 Roo.MessageBox.alert("Error", "That item has been shipped, has a draft shipment or invoices - void the shipments/invoices first");
3809 if (rec.data.coitem_subnumber * 1 > 0) {
3810 Roo.log("Edit container event");
3811 Roo.log(e); // if it's a tab..
3815 // allow editing of source / destination..
3816 case 'coitem_shipto_id':
3817 case 'coitem_location_src':
3822 Roo.MessageBox.alert("Error", "That is a kit item, edit the container.");
3826 // zero off values..
3827 //if (e.field == 'coitem_qtyord' && rec.data.coitem_qtyord == 0) {
3830 // if (e.field == 'coitem_custprice' && rec.data.coitem_qtyord == 0.0) {
3834 if (rec.data.item_type == 'K' && e.field == 'item_number') {
3835 // you can not change the product type on kits' as it messing things up..
3836 Roo.MessageBox.alert("Error", "That is a kit item,if you need to change it, delete it first.");
3845 //_this.dialog = Pman.Dialog.FILL_IN
3847 if (_this.panel.active) {
3848 this.footer.onClick('first');
3851 celldblclick : function (_self, rowIndex, columnIndex, e)
3853 var rec = this.ds.getAt(rowIndex);
3854 var di = this.cm.getDataIndex(columnIndex);
3855 if (di != 'avail_qty') {
3859 Pman.Dialog.XtupleInvHistory.show({
3860 itemsite_item_id_item_number : rec.data.item_number,
3861 // itemsite_item_id_item_descript1 : rec.data.item_descrip1,
3862 location_name : rec.data.coitem_location_src_location_name,
3863 location_descrip : rec.data.coitem_location_src_location_descrip,
3865 invhist_transdate : _this.form.findField('cohead_targetdate').getValue()
3869 afteredit : function (e)
3871 Roo.log('afteredit:' + e.record.data.coitem_linenumber);
3874 // if ( e.record && e.record.data.coitem_id) {
3875 // as we disable update to the display on the ajax callback to
3876 // allow editing flow to continue, and not refresh - we can only update
3877 // these values after something has actually been edited.
3878 // e.record.set('coitem_id', e.record.data.coitem_id);
3879 // e.record.set('coitem_status', e.record.data.coitem_status);
3882 if (e.field == 'item_number' || e.originalValue == e.value) {
3883 // afterselect handles this...
3886 if (e.field == 'item_descrip1') {
3887 e.record.set('coitem_memo', e.value);
3889 var rate = _this.form.findField('taxzone_rate').getValue();
3891 case 'coitem_linedisc':
3893 var cp = parseFloat(e.record.data.coitem_custprice);
3895 if (isNaN(cp) || cp == 0.0) {
3899 var dis = parseFloat(e.value);
3907 Math.max(0,cp * ((100.0 - parseInt(e.value))/ 100.0) )
3910 // donot need to set the subtotal here, coz we will render it automatically
3912 // 'coitem_subtotal',
3913 // e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord
3917 case 'coitem_price': // SELL@ price
3919 var cp = parseFloat(e.record.data.coitem_custprice);
3920 // list price is < price -- update it..
3921 if (isNaN(cp) || cp == 0.0 || cp < e.value) {
3922 e.record.set('coitem_custprice', e.value);
3925 // update the discount calc.
3927 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( e.value / cp) * 100.0)));
3929 // donot need to set the subtotal here, coz we will render it automatically
3931 // 'coitem_subtotal',
3932 // e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord
3936 case 'coitem_custprice':
3937 // modified customer price...
3938 // just modify the discount.. -- leave the entered price the same..
3939 var sp = parseFloat(e.record.data.coitem_price);
3940 var cp = parseFloat(e.value);
3941 if (isNaN(cp) || cp == 0.0 || cp < e.value) {
3945 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
3949 case 'coitem_custprice_tax':
3950 var cp = parseFloat(e.value / ( 1 + rate * 1 ));
3951 var sp = parseFloat(e.record.data.coitem_price);
3953 if (isNaN(cp) || cp == 0.0) {
3956 e.record.set('coitem_custprice', cp);
3957 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
3961 case 'coitem_price_tax':
3963 var cp = parseFloat(e.record.data.coitem_custprice);
3964 var sp = parseFloat(e.value / ( 1 + rate * 1 ));
3965 if (isNaN(cp) || cp == 0.0 || cp < sp) {
3966 e.record.set('coitem_custprice', sp);
3969 e.record.set('coitem_price', sp);
3970 e.record.set('coitem_linedisc', Math.max(0, 100.0 - (( sp / cp) * 100.0)));
3979 var doupdate = function() {
3980 if (!e.record.updatePending) {
3981 Roo.log('doupdate...' + e.record.data.coitem_linenumber);
3986 Roo.log('doupdate pending...' + e.record.data.coitem_linenumber);
3987 // wait until it's not peding an update..
3988 doupdate.defer(500);
3991 if(e.record.data.coitem_id * 1 < 1 && !e.record.isInserting){ // insert
3992 e.record.isInserting = 1;
3993 e.record.isUpdating = 0;
3999 if(!e.record.isInserting && !e.record.isUpdating){
4000 e.record.isUpdating = 1;
4005 if(!e.record.updatePending){
4006 e.record.updatePending = 1;
4010 Roo.log("got to end without doing an update?" + e.record.data.coitem_linenumber);
4013 rowclass : function (gridview, rowcfg)
4015 if (rowcfg.record.data.coitem_status == 'C' &&
4016 rowcfg.record.data.shipitem_shipped * 1 < 1) {
4018 rowcfg.rowClass = 'strikethrough';
4020 if (rowcfg.record.data.coitem_status == 'X' ) {
4022 rowcfg.rowClass = 'strikethrough';
4025 if (!rowcfg.record.data.coitem_id) {
4026 rowcfg.rowClass = 'dragon-not-saved';
4043 title : "Order Items",
4044 xtype : 'GridPanel',
4045 fitContainer : true,
4047 tableName : 'coitem',
4049 deactivate : function (_self)
4052 _this.grid.stopEditing();
4055 activate : function() {
4058 try { if (MODULE.isBuilder) {
4062 var id = _this.form.findField('cohead_id').getValue() * 1;
4064 Roo.MessageBox.alert("Save First", "Save the order first, before adding items");
4065 _this.dialog.layout.getRegion('center').showPanel(0);
4070 _this.grid.footer.onClick('first');
4072 //if (_this.form.findField('cohead_cust_id_cust_name').getValue() == 'Bloom and Grow HK') {
4073 // _this.xferAll.show();
4076 // _this.xferAll.hide();
4091 xtype : 'LayoutRegion',
4097 title : "Reserve Stock / Shipments",
4098 xtype : 'LayoutRegion',
4103 xtype : 'BorderLayout',
4109 '|xns' : 'Roo.grid',
4110 xtype : 'RowSelectionModel',
4111 singleSelect : true,
4116 '|xns' : 'Roo.data',
4117 url : baseURL + '/Roo/shiphead.php',
4119 xtype : 'HttpProxy',
4123 '|xns' : 'Roo.data',
4126 xtype : 'JsonReader',
4130 'name': 'shiphead_number',
4134 'name': 'shiphead_shipvia',
4138 'name': 'shiphead_shipdate',
4142 'name': 'shiphead_sfstatus'
4145 'name': 'shiphead_tracknum',
4149 totalProperty : 'total',
4150 builderCfg : '{\"cols\":[{\"table\":\"shiphead\",\"column\":\"shiphead_number\",\"columnshort\":\"shiphead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipvia\",\"columnshort\":\"shiphead_shipvia\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipdate\",\"columnshort\":\"shiphead_shipdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_sfstatus\",\"columnshort\":\"shiphead_sfstatus\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_tracknum\",\"columnshort\":\"shiphead_tracknum\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"shiphead_shipvia\"],\"table\":\"shiphead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}'
4152 '|xns' : 'Roo.data',
4155 sortInfo : { field : 'shiphead_shipvia', direction: 'ASC' },
4157 builderCfg : '{\"cols\":[{\"table\":\"shiphead\",\"column\":\"shiphead_number\",\"columnshort\":\"shiphead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipvia\",\"columnshort\":\"shiphead_shipvia\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipdate\",\"columnshort\":\"shiphead_shipdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_sfstatus\",\"columnshort\":\"shiphead_sfstatus\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_tracknum\",\"columnshort\":\"shiphead_tracknum\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"shiphead_shipvia\"],\"table\":\"shiphead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
4159 beforeload : function (_self, options)
4161 options.params = options.params || {};
4162 options.params.shiphead_order_id = _this.form.findField('cohead_id').getValue() * 1;
4163 if (options.params.shiphead_order_id < 1) {
4179 '|xns' : 'Roo.Toolbar',
4180 text : "Confirm Shipment",
4182 cls : 'x-btn-text-icon',
4183 icon : rootURL + '/Pman/templates/images/lock.gif',
4188 var sel = _this.shipgrid.getSelectionModel().getSelected();
4190 Roo.MessageBox.alert("Error", "Select a shipment");
4193 if (sel.data.shiphead_shipped) {
4194 Roo.MessageBox.alert("Error", "Shipment is already confirmed");
4199 // check current status of shipment..
4204 url : baseURL + '/Roo/shiphead',
4208 shiphead_id : sel.data.shiphead_id,
4211 success : function() {
4212 _this.shipgrid.ds.load({});
4221 '|xns' : 'Roo.Toolbar',
4222 text : "Download (as xls)",
4224 cls : 'x-btn-text-icon',
4225 icon : rootURL + '/Pman/templates/images/save.gif',
4230 var sel = _this.shipgrid.getSelectionModel().getSelected();
4232 Roo.MessageBox.alert("Error", "Select a shipment");
4237 // check current status of shipment..
4241 url : baseURL + '/Roo/shiphead',
4244 _download :sel.data.shiphead_id
4254 '|xns' : 'Roo.Toolbar',
4255 text : "Print Picking Slip",
4257 cls : 'x-btn-text-icon',
4258 icon : rootURL + '/Pman/templates/images/pdf.gif',
4263 var sel = _this.shipgrid.getSelectionModel().getSelected();
\r
4265 Roo.MessageBox.alert("Error", "Select a shipment");
\r
4268 // check current status of shipment..
4271 url : baseURL + '/Xtuple/Print',
4274 template : 'picking-slip',
4275 param : "shiphead_id:integer='" + sel.data.shiphead_id + "'",
4276 filename : 'picking-slip-' + sel.data.shiphead_number
4278 success : function() {
4289 '|xns' : 'Roo.Toolbar',
4290 text : "Print Delivery Note",
4292 cls : 'x-btn-text-icon',
4293 icon : rootURL + '/Pman/templates/images/pdf.gif',
4298 var sel = _this.shipgrid.getSelectionModel().getSelected();
\r
4300 Roo.MessageBox.alert("Error", "Select a shipment");
\r
4303 // check current status of shipment..
4306 url : baseURL + '/Xtuple/Print',
4309 template : 'delivery-note-',
4310 param : "shiphead_id:integer='" + sel.data.shiphead_id + "'",
4311 filename : 'delivery-note-' + sel.data.shiphead_number
4313 success : function() {
4324 '|xns' : 'Roo.Toolbar',
4325 text : "Send Delivery Email",
4327 cls : 'x-btn-text-icon',
4328 icon : Roo.rootURL + 'images/default/dd/email.gif',
4333 var s = _this.shipgrid.getSelectionModel().getSelected();
4335 if(!s || s.data.shiphead_id * 1 < 1){
4336 Roo.MessageBox.alert('Error', 'Please select a shipment');
4342 url: baseURL+ '/Roo/shiphead',
4344 shiphead_id : s.data.shiphead_id,
4347 success : function() {
4348 Roo.MessageBox.alert('Notice', 'SENT');
4356 '|xns' : 'Roo.Toolbar',
4361 '|xns' : 'Roo.Toolbar',
4364 cls : 'x-btn-text-icon',
4365 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
4370 if (!_this.form.findField('cohead_id').getValue()) {
4371 Roo.MessageBox.alert("Error", "Save Order first");
4374 var rv = _this.form.getFieldValues();
4376 Pman.Dialog.XtupleShipmentNew.show({
4377 shiphead_order_id : rv.cohead_id,
4378 shiphead_shipdate : _this.form.findField('cohead_targetdate').getValue().format('Y-m-d')
4381 _this.shipgrid.ds.load({});
4385 render : function (_self)
4387 _this.addShipmentBtn = _self;
4392 '|xns' : 'Roo.Toolbar',
4393 text : "Void / Unconfirm",
4395 cls : 'x-btn-text-icon',
4396 icon : rootURL + '/Pman/templates/images/trash.gif',
4401 var sel = _this.shipgrid.getSelectionModel().getSelected();
4403 Roo.MessageBox.alert("Error", "Select a shipment");
4406 // check current status of shipment..
4408 var msg = sel.data.shiphead_shipped ?
4409 "Are you sure you want to un-confirm that shipment? - It will remove items from unposted invoices" :
4410 "Are you sure you want to void that shipment?";
4412 Roo.MessageBox.confirm("Are you sure", msg,
4420 url : baseURL + '/Roo/shiphead',
4424 shiphead_id : sel.data.shiphead_id,
4427 success : function() {
4428 _this.shipgrid.ds.load({});
4445 '|xns' : 'Roo.grid',
4446 autoExpandColumn : 'shiphead_shipvia',
4450 builderCfg : '{\"cols\":[{\"table\":\"shiphead\",\"column\":\"shiphead_number\",\"columnshort\":\"shiphead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipvia\",\"columnshort\":\"shiphead_shipvia\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipdate\",\"columnshort\":\"shiphead_shipdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_sfstatus\",\"columnshort\":\"shiphead_sfstatus\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_tracknum\",\"columnshort\":\"shiphead_tracknum\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"shiphead_shipvia\"],\"table\":\"shiphead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
4453 '|xns' : 'Roo.grid',
4454 xtype : 'ColumnModel',
4457 renderer : function(v,x,r) {
4458 if (r.json.shiphead_shipdate.length) {
4459 return String.format('{0}', v);
4461 return String.format('<s>{0}</s>', v);
4464 dataIndex : 'shiphead_number',
4465 builderCfg : '{\"table\":\"shiphead\",\"column\":\"shiphead_number\",\"columnshort\":\"shiphead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}'
4468 '|xns' : 'Roo.grid',
4469 xtype : 'ColumnModel',
4470 header : 'From Location',
4472 renderer : function(v) { return String.format('{0}', v); },
4474 dataIndex : 'shiphead_location_id_location_name'
4477 '|xns' : 'Roo.grid',
4478 xtype : 'ColumnModel',
4481 renderer : function(v) { return String.format('{0}', v); },
4483 dataIndex : 'shiphead_shipto_id_shipto_name'
4486 '|xns' : 'Roo.grid',
4487 xtype : 'ColumnModel',
4488 header : 'shipdate',
4490 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
4492 builderCfg : '{\"table\":\"shiphead\",\"column\":\"shiphead_shipdate\",\"columnshort\":\"shiphead_shipdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}',
4493 dataIndex : 'shiphead_shipdate'
4496 '|xns' : 'Roo.grid',
4497 xtype : 'ColumnModel',
4500 renderer : function(v,x,r) {
4505 if (r.json.shiphead_shipdate.length) {
4507 if (r.json.shiphead_shipped) {
4511 return '<span style="color:red">Draft</span>';
4519 dataIndex : 'shiphead_sfstatus',
4520 builderCfg : '{\"table\":\"shiphead\",\"column\":\"shiphead_sfstatus\",\"columnshort\":\"shiphead_sfstatus\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}'
4523 '|xns' : 'Roo.grid',
4524 xtype : 'ColumnModel',
4527 renderer : function(v) { return String.format('{0}', v); },
4529 builderCfg : '{\"table\":\"shiphead\",\"column\":\"shiphead_shipvia\",\"columnshort\":\"shiphead_shipvia\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}',
4530 dataIndex : 'shiphead_shipvia'
4533 '|xns' : 'Roo.grid',
4534 xtype : 'ColumnModel',
4535 header : 'tracknum',
4537 renderer : function(v) { return String.format('{0}', v); },
4539 builderCfg : '{\"table\":\"shiphead\",\"column\":\"shiphead_tracknum\",\"columnshort\":\"shiphead_tracknum\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}',
4540 dataIndex : 'shiphead_tracknum'
4544 rowdblclick : function (_self, rowIndex, e)
4546 var rec = this.ds.getAt(rowIndex);
4547 if (!rec.json.shiphead_shipdate.length) {
4548 Roo.MessageBox.alert("Error", "You can not edit voided shipments, create a new one, and use the restore feature");
4552 Pman.Dialog.XtupleShipment.show({
4553 shiphead_id : rec.data.shiphead_id
4563 _this.shipgrid = this;
4564 //_this.dialog = Pman.Dialog.FILL_IN
4565 if (_this.shippanel.active) {
4580 xtype : 'GridPanel',
4581 fitContainer : true,
4583 builderCfg : '{\"cols\":[{\"table\":\"shiphead\",\"column\":\"shiphead_number\",\"columnshort\":\"shiphead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipvia\",\"columnshort\":\"shiphead_shipvia\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipdate\",\"columnshort\":\"shiphead_shipdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_sfstatus\",\"columnshort\":\"shiphead_sfstatus\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_tracknum\",\"columnshort\":\"shiphead_tracknum\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"shiphead_shipvia\"],\"table\":\"shiphead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
4584 tableName : 'shiphead',
4586 activate : function() {
4587 _this.shippanel = this;
4588 if (_this.shipgrid) {
4589 _this.shipgrid.ds.load({});
4602 '|xns' : 'Roo.data',
4603 url : baseURL + '/Roo/cobmisc.php',
4604 xtype : 'HttpProxy',
4609 '|xns' : 'Roo.data',
4612 xtype : 'JsonReader',
4615 'name': 'invchead_invcnumber',
4619 'name': 'invchead_invcdate',
4624 builderCfg : '{\"cols\":[{\"table\":\"invchead\",\"column\":\"invchead_invcnumber\",\"columnshort\":\"invchead_invcnumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"},{\"table\":\"invchead\",\"column\":\"invchead_invcdate\",\"columnshort\":\"invchead_invcdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"invchead_invcnumber\"],\"table\":\"invchead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
4625 totalProperty : 'total'
4627 '|xns' : 'Roo.data',
4630 sortInfo : { field : 'invchead_invcnumber', direction: 'ASC' },
4633 beforeload : function (_self, options)
4636 options.params = options.params || {};
4637 options.params.cobmisc_cohead_id = _this.form.findField('cohead_id').getValue() * 1;
4638 if (options.params.cobmisc_cohead_id < 1) {
4642 options.params._with_other_payment = 1;
4643 //options.params['query[invchead_ordernumber]'] = _this.form.findField('cohead_number').getValue()
4646 load : function (_self, records, options)
4651 var totalfreight = 0.0;
4652 var totalmisc = 0.0;
4655 Roo.each(records, function(r)
4657 if(r.data.cobmisc_id > 1){
4658 done += parseInt(r.data.cobmisc_qty);
4659 totalic += parseFloat(r.data.cobmisc_itemcost).toFixed(2)*1;
4660 totalmisc += parseFloat(r.data.cobmisc_misc).toFixed(2)*1;
4661 totalfreight += parseFloat(r.data.cobmisc_freight).toFixed(2)*1;
4662 totaltax += parseFloat(r.data.cobmisc_tax).toFixed(2)*1;
4663 total = parseInt(r.data.cobmisc_total_qty);
4668 _this.shipinvtab.layout.getRegion('center').getPanel(0).setTitle(
4670 "Invoices (Complete)" :
4671 ("Invoices prepared for " + done + '/' + total)
4675 var frtotal = (parseFloat(_this.form.findField('cohead_freight').getValue()) - totalfreight).toFixed(2);
4676 var misctotal = (parseFloat(_this.form.findField('cohead_misc').getValue()) - totalmisc).toFixed(2);
4677 var ictotal = (parseFloat(_this.form.findField('cohead_subtotal').getValue()) - totalic).toFixed(2);
4678 var taxtotal = (parseFloat(_this.form.findField('cohead_tax').getValue()) - totaltax).toFixed(2);
4679 var remtotal = frtotal*1 + misctotal*1 + ictotal*1 + taxtotal*1;
4681 var nr = this.reader.newRow({
4683 cobmisc_invchead_id_invchead_invcnumber : "Total Remaining",
4684 cobmisc_qty : total - done,
4685 cobmisc_freight :frtotal,
4686 cobmisc_misc : misctotal,
4687 cobmisc_itemcost : ictotal,
4688 cobmisc_tax : taxtotal,
4689 cobmisc_total : remtotal
4693 // do we need to add it somehow??
4694 _this.invgrid.ds.add(nr);
4708 '|xns' : 'Roo.Toolbar',
4709 text : "Post Invoice",
4711 cls : 'x-btn-text-icon',
4712 icon : rootURL + '/Pman/templates/images/lock.gif',
4718 var sel = _this.invgrid.getSelectionModel().getSelected();
4720 Roo.MessageBox.alert("Error", "Select a invoice");
4723 // check current status of shipment..
4725 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to Post that invoice?",
4732 url : baseURL + '/Roo/cobmisc',
4735 cobmisc_id : sel.data.cobmisc_id,
4738 success : function() {
4739 _this.invgrid.ds.load({});
4753 '|xns' : 'Roo.menu',
4758 '|xns' : 'Roo.menu',
4759 text : "Print Standard Invoice",
4766 var sel = _this.invgrid.getSelectionModel().getSelected();
4768 Roo.MessageBox.alert("Error", "Select a invoice");
4771 if (!sel.data.cobmisc_invchead_id) {
4772 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4775 // check current status of shipment..
4778 url : baseURL + '/Roo/invchead',
4781 invchead_id : sel.data.cobmisc_invchead_id,
4784 success : function() {
4795 '|xns' : 'Roo.menu',
4796 hidden : !(baseURL.match(/(hk\.php|cn\.php)$/)),
4797 text : "Print Chinese Invoice With GST in line item",
4801 click : function (_self, e)
4804 var sel = _this.invgrid.getSelectionModel().getSelected();
4806 Roo.MessageBox.alert("Error", "Select a invoice");
4809 if (!sel.data.cobmisc_invchead_id) {
4810 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4813 // check current status of shipment..
4816 url : baseURL + '/Roo/invchead',
4819 invchead_id : sel.data.cobmisc_invchead_id,
4823 success : function() {
4833 '|xns' : 'Roo.menu',
4834 hidden : !(baseURL.match(/(hk\.php|cn\.php)$/)),
4835 text : "Print Chinese Invoice",
4839 click : function (_self, e)
4842 var sel = _this.invgrid.getSelectionModel().getSelected();
4844 Roo.MessageBox.alert("Error", "Select a invoice");
4847 if (!sel.data.cobmisc_invchead_id) {
4848 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4851 // check current status of shipment..
4854 url : baseURL + '/Roo/invchead',
4857 invchead_id : sel.data.cobmisc_invchead_id,
4861 success : function() {
4871 '|xns' : 'Roo.menu',
4872 hidden : !(baseURL.match(/au\.php$/)),
4873 text : "Print Aus - GST included Invoice",
4877 click : function (_self, e)
4880 var sel = _this.invgrid.getSelectionModel().getSelected();
4882 Roo.MessageBox.alert("Error", "Select a invoice");
4885 if (!sel.data.cobmisc_invchead_id) {
4886 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4889 // check current status of shipment..
4892 url : baseURL + '/Roo/invchead',
4895 invchead_id : sel.data.cobmisc_invchead_id,
4899 success : function() {
4909 '|xns' : 'Roo.menu',
4910 hidden : !(baseURL.match(/au\.php$/)),
4911 text : "Print Bambini Pronto Invoice",
4915 click : function (_self, e)
4917 var sel = _this.invgrid.getSelectionModel().getSelected();
4919 Roo.MessageBox.alert("Error", "Select a invoice");
4922 if (!sel.data.cobmisc_invchead_id) {
4923 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4926 // check current status of shipment..
4929 url : baseURL + '/Roo/invchead',
4932 invchead_id : sel.data.cobmisc_invchead_id,
4944 '|xns' : 'Roo.menu',
4945 hidden : !(baseURL.match(/au\.php$/)),
4946 text : "Print Bambini Pro Forma Invoice",
4950 click : function (_self, e)
4953 var sel = _this.invgrid.getSelectionModel().getSelected();
4955 Roo.MessageBox.alert("Error", "Select a invoice");
4958 if (!sel.data.cobmisc_invchead_id) {
4959 Roo.MessageBox.alert("Error", "Invoice has not been posted");
4962 // check current status of shipment..
4965 url : baseURL + '/Roo/invchead',
4968 invchead_id : sel.data.cobmisc_invchead_id,
4969 _print : 'au-proforma'
4972 success : function() {
4982 '|xns' : 'Roo.menu',
4983 hidden : !( baseURL.match(/au\.php$/)),
4984 text : "Print Shipping / Commercial Invoice",
4988 click : function (_self, e)
4990 var sel = _this.invgrid.getSelectionModel().getSelected();
4992 Roo.MessageBox.alert("Error", "Select a invoice");
4996 Pman.Dialog.XtupleDiscountOfInvoice.show({invchead_id : sel.data.cobmisc_invchead_id}, function(){
5005 '|xns' : 'Roo.Toolbar',
5008 cls : 'x-btn-text-icon',
5009 icon : rootURL + '/Pman/templates/images/pdf.gif',
5018 '|xns' : 'Roo.menu',
5023 '|xns' : 'Roo.menu',
5024 text : "Receive Payment",
5026 cls : 'x-btn-text-icon',
5027 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
5030 click : function(_self,e)
5033 var sel = _this.invgrid.getSelectionModel().getSelected();
5034 if (!sel || sel.data.cobmisc_id < 1) {
5035 Roo.MessageBox.alert("Error", "Select a invoice");
5038 if(!sel.data.cobmisc_posted){
5039 Roo.MessageBox.alert("Error", "This invoice has not been posted!");
5042 if(sel.data.cobmisc_outstanding == 0){
5043 Roo.MessageBox.alert("Error", "There is no any outstanding of this invoice!");
5047 var cust_id = _this.form.findField('cohead_cust_id').getValue();
5052 cashrcpt_amount : sel.data.cobmisc_outstanding,
5053 cashrcpt_cust_id : cust_id,
5054 cashrcpt_aropen_id : sel.data.cobmisc_aropen_id_aropen_id,
5055 cashrcpt_distdate : new Date(),
5056 cashrcpt_fundstype : 'C',
5057 cashrcpt_curr_id : sel.data.cobmisc_curr_id_curr_id,
5058 cashrcpt_curr_id_curr_name : sel.data.cobmisc_curr_id_curr_name,
5059 cashrcpt_usecustdeposit : true,
5060 cashrcpt_docdate : new Date(),
5061 cashrcpt_salescat_id : -1,
5062 cashrcpt_applydate : new Date(),
5063 cashrcpt_discount : 0
5065 Pman.Dialog.XtupleReceivePayment.show( data , function() {
5066 _this.invgrid.ds.load({});
5072 '|xns' : 'Roo.menu',
5073 text : "Issue Refund",
5075 cls : 'x-btn-text-icon',
5076 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
5079 click : function(_self,e)
5081 var sel = _this.invgrid.getSelectionModel().getSelected();
5082 if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {
5083 Roo.MessageBox.alert("Error", "Select a credit memo");
5086 if(!sel.data.cobmisc_posted){
5087 Roo.MessageBox.alert("Error", "The invoice that credit memo has been applied to has been not posted");
5090 var cust_id = _this.form.findField('cohead_cust_id').getValue();
5095 if(!sel.data.cobmisc_outstanding || sel.data.cobmisc_outstanding == 0){
5096 Roo.MessageBox.alert("Error", "The amount of this credit memo is 0!");
5100 var d = _this.form.getFieldValues();
5103 'checkhead_recip_id' : cust_id,
5104 'checkhead_recip_type' : 'C',
5105 'checkhead_checkdate' : new Date(),
5106 'checkhead_amount' : sel.data.cobmisc_outstanding,
5107 'remaining_total' : sel.data.cobmisc_outstanding,
5108 'checkhead_curr_id' : d.cohead_curr_id,
5109 'checkhead_curr_id_curr_name' : d.cohead_curr_id_curr_name,
5110 'checkhead_misc' : true,
5111 'aropen_id' : sel.data.cobmisc_cobapply_aropen_id,
5112 'cmhead_number' : sel.data.cobmisc_invchead_id_invchead_invcnumber,
5113 'cust_name' : d.cohead_cust_id_cust_name,
5114 '_create_and_post' : 1
5119 Pman.Dialog.XtupleMiscellaneousCheck.show( data , function() {
5120 _this.invgrid.ds.load({});
5126 '|xns' : 'Roo.menu',
5127 xtype : 'Separator',
5131 '|xns' : 'Roo.menu',
5132 text : "Void Payment",
5134 cls : 'x-btn-text-icon',
5135 icon : rootURL + '/Pman/templates/images/trash.gif',
5138 click : function(_self,e)
5140 var sel = _this.invgrid.getSelectionModel().getSelected();
5141 if (!sel || sel.data.cobmisc_cashrcpt_id * 1 < 1) {
5142 Roo.MessageBox.alert("Error", "Select a Receive Payment");
5146 Roo.MessageBox.confirm("Confirm", "Voiding receipt will mean you will have to re-enter the receipt refund - " +
5147 "please take note of the details so you can enter it again correctly later.", function(r) {
5153 url : baseURL + '/Roo/cashrcpt',
5156 cashrcpt_id : sel.data.cobmisc_cashrcpt_id,
5159 success : function()
5161 _this.invgrid.ds.load({});
5173 '|xns' : 'Roo.menu',
5174 text : "Void Refund",
5176 cls : 'x-btn-text-icon',
5177 icon : rootURL + '/Pman/templates/images/trash.gif',
5180 click : function(_self,e)
5182 var sel = _this.invgrid.getSelectionModel().getSelected();
5183 if (!sel || sel.data.cobmisc_checkhead_id * 1 < 1) {
5184 Roo.MessageBox.alert("Error", "Select a Miscellaneours Check");
5188 Roo.MessageBox.confirm("Confirm", "Voiding refund will mean you will have to re-enter the receipt refund - " +
5189 "please take note of the details so you can enter it again correctly later.", function(r) {
5195 url : baseURL + '/Roo/checkhead',
5198 checkhead_id : sel.data.cobmisc_checkhead_id,
5201 success : function()
5203 _this.invgrid.ds.load({});
5215 '|xns' : 'Roo.menu',
5216 text : "Void Credit Memo",
5218 cls : 'x-btn-text-icon',
5219 icon : rootURL + '/Pman/templates/images/trash.gif',
5222 click : function(_self,e)
5224 var sel = _this.invgrid.getSelectionModel().getSelected();
5225 if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {
5226 Roo.MessageBox.alert("Error", "Select a credit memo");
5230 if(sel.data.cobmisc_posted){
5231 Roo.MessageBox.alert("Error", "You cann't void this credit memo, since the invoice that credit memo has been applied to has been posted");
5235 if (sel.data.cobmisc_cobapply_id < 1) {
5236 Roo.MessageBox.alert("Error", "invaild credit memo");
5239 Roo.MessageBox.confirm("Confirm", "Are you sure want to void this applied credit memo, " +
5240 "it will also void all the check that belongs to this credit memo ", function(r) {
5246 url : baseURL + '/Roo/cobapply',
5249 _delete : sel.data.cobmisc_cobapply_id,
5252 success : function()
5254 _this.invgrid.ds.load({});
5267 '|xns' : 'Roo.Toolbar',
5268 text : "Payments / Refunds / Credit Memos",
5270 cls : 'x-btn-text-icon',
5271 icon : Roo.rootURL + 'images/default/tree/leaf.gif',
5279 '|xns' : 'Roo.Toolbar',
5284 '|xns' : 'Roo.Toolbar',
5287 cls : 'x-btn-text-icon',
5288 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
5294 if (!_this.form.findField('cohead_id').getValue()) {
5295 Roo.MessageBox.alert("Error", "Save Order first");
5299 var rv = _this.form.getFieldValues();
5302 Pman.Dialog.XtupleInvoice.show({
5303 cobmisc_cohead_id : rv.cohead_id,
5304 cobmisc_shipdate : _this.form.findField('cohead_targetdate').getValue(),
5305 cobmisc_invcdate : _this.form.findField('cohead_targetdate').getValue(),
5306 cobmisc_curr_id : rv.cohead_curr_id,
5307 cobmisc_curr_id_curr_name : rv.cohead_curr_id_curr_name,
5308 // below parms for add credit memo
5310 cm_cust_id : rv.cohead_cust_id,
5311 cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,
5312 cm_curr_id : rv.cohead_curr_id,
5313 cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,
5314 cm_terms_id : rv.cohead_terms_id,
5315 cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,
5316 cm_salesrep_id : rv.cohead_salesrep_id,
5317 cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,
5318 cm_docdate : new Date(),
5319 cm_taxzone_id : rv.cohead_taxzone_id,
5320 cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,
5321 cm_billto_cntct_id : rv.cohead_billto_cntct_id,
5322 cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,
5323 cm_location_src : rv.cohead_location_src,
5324 cm_location_src_location_name : rv.cohead_location_src_location_name,
5325 cm_billto_address : rv.billto_address
5330 _this.invgrid.ds.load({});
5334 render : function (_self)
5336 _this.addInvoiceBtn = _self;
5341 '|xns' : 'Roo.Toolbar',
5342 text : "Void / Unpost",
5344 cls : 'x-btn-text-icon',
5345 icon : rootURL + '/Pman/templates/images/trash.gif',
5351 var sel = _this.invgrid.getSelectionModel().getSelected();
5353 Roo.MessageBox.alert("Error", "Select a invoice");
5356 // check current status of shipment..
5359 // cobmisc_id : sel.data.cobmisc_id,
5362 if (sel.data.cobmisc_id * 1) {
5363 params.cobmisc_id = sel.data.cobmisc_id * 1 ;
5365 if (sel.data.cobmisc_invchead_id_invchead_id * 1) {
5366 params.invchead_id = sel.data.cobmisc_invchead_id_invchead_id * 1;
5369 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to VOID that invoice?",
5376 url : baseURL + '/Roo/cobmisc',
5379 success : function() {
5380 _this.invgrid.ds.load({});
5395 '|xns' : 'Roo.grid',
5396 autoExpandColumn : 'invchead_invcnumber',
5400 builderCfg : '{\"cols\":[{\"table\":\"invchead\",\"column\":\"invchead_invcnumber\",\"columnshort\":\"invchead_invcnumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"},{\"table\":\"invchead\",\"column\":\"invchead_invcdate\",\"columnshort\":\"invchead_invcdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"invchead_invcnumber\"],\"table\":\"invchead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
5403 '|xns' : 'Roo.grid',
5404 xtype : 'ColumnModel',
5405 header : 'Invoice #',
5407 renderer : function(v,x,r) {
5409 r.data.cobmisc_invchead_id_invchead_id * 1 &&
5410 !r.data.cobmisc_invchead_id_invchead_posted) {
5411 return '<span style="color:red">' +
5412 "NEEDS Voiding then re-posted: " +
5413 String.format('{0}', v) +
5417 if(v && r.data.cobmisc_id == -2){
5418 return String.format('<span style="margin-left: 10px;"> - {0} (Credit Memo)</span>', v);
5420 if(v && r.data.cobmisc_id == -3){
5421 return String.format('<span style="margin-left: 20px;"> - {0} (Miscellaneous Check)</span>', v);
5423 if(v && r.data.cobmisc_id == -4){
5424 return String.format('<span style="margin-left: 10px;"> - {0} (Receive Payment to {2}) [ {1} ]</span>',
5425 v, r.data.cobmisc_cashrcpt_amount, r.json.cashrcpt_bankaccnt_id_bankaccnt_bankname);
5428 return v ? String.format('{0}', v) :
5429 '<span style="color:red">' + "Not Posted" + '</span>';
5432 dataIndex : 'cobmisc_invchead_id_invchead_invcnumber'
5435 '|xns' : 'Roo.grid',
5436 xtype : 'ColumnModel',
5437 header : 'invcdate',
5439 renderer : function(v,x,r) {
5441 return String.format('{0}', v && v.format ? v.format('d/M/Y') : '');
5444 dataIndex : 'cobmisc_invcdate',
5445 builderCfg : '{\"table\":\"invchead\",\"column\":\"invchead_invcdate\",\"columnshort\":\"invchead_invcdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}'
5448 '|xns' : 'Roo.grid',
5450 xtype : 'ColumnModel',
5453 renderer : function(v) { return String.format('{0}', v ? parseInt(v) : 0); },
5455 dataIndex : 'cobmisc_qty'
5458 '|xns' : 'Roo.grid',
5460 xtype : 'ColumnModel',
5461 header : 'Item Cost',
5463 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); },
5465 dataIndex : 'cobmisc_itemcost'
5468 '|xns' : 'Roo.grid',
5470 xtype : 'ColumnModel',
5471 header : 'Shipping',
5473 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : ''); },
5475 dataIndex : 'cobmisc_freight'
5478 '|xns' : 'Roo.grid',
5480 xtype : 'ColumnModel',
5483 renderer : function(v,x,r) {
5485 // tax is based on the % itemcost..
5486 // var ic = r.data.cobmisc_itemcost;
5488 var ic =r.data.cobmisc_itemcost - (1* r.data.cobmisc_itemcost_taxfree);
5490 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
5491 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
5495 var taxp = tax / totic;
5498 return String.format('{0}', (1.0*v).toFixed(2) );
5503 dataIndex : 'cobmisc_tax'
5506 '|xns' : 'Roo.grid',
5508 xtype : 'ColumnModel',
5509 header : 'Discount (Pretax)',
5511 renderer : function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); },
5513 dataIndex : 'cobmisc_cohead_id_cohead_pretax_discount'
5516 '|xns' : 'Roo.grid',
5518 xtype : 'ColumnModel',
5519 header : 'Discount (Posttax)',
5521 renderer : function(v,x,r)
5523 var vv = v - r.data.cobmisc_cohead_id_cohead_pretax_discount;
5525 return String.format('{0}', vv ? (1.0*vv).toFixed(2) : 0);
5528 dataIndex : 'cobmisc_misc'
5531 '|xns' : 'Roo.grid',
5533 xtype : 'ColumnModel',
5536 renderer : function(v,x,r) {
5539 var ic = r.data.cobmisc_itemcost;
5540 var tax= _this.form.findField('cohead_tax').getValue() * 1.0;
5541 var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;
5544 var taxp = tax / totic;
5552 return String.format('{0}',(v * 1.0).toFixed(2) );
5556 return String.format('{0}',
5557 ((d.cobmisc_itemcost * 1.0) +
5558 (d.cobmisc_freight * 1.0) +
5559 (d.cobmisc_tax * 1.0) +
5560 (d.cobmisc_misc * 1.0)
5565 dataIndex : 'cobmisc_total'
5568 '|xns' : 'Roo.grid',
5570 xtype : 'ColumnModel',
5571 header : 'Outstanding',
5573 renderer : function(v,x,r)
5576 return String.format('{0}', v ? (v * 1.0).toFixed(2) : 0 );
5579 dataIndex : 'cobmisc_outstanding'
5583 rowdblclick : function (_self, rowIndex, e)
5586 var ri = this.ds.getAt(rowIndex);
5587 if ( ri.data.cobmisc_id < 0) { // skip summary row..
5590 var rv = _this.form.getFieldValues();
5591 Pman.Dialog.XtupleInvoice.show({
5592 cobmisc_id : ri.data.cobmisc_id,
5593 // below parms for add credit memo
5595 cm_cust_id : rv.cohead_cust_id,
5596 cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,
5597 cm_curr_id : rv.cohead_curr_id,
5598 cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,
5599 cm_terms_id : rv.cohead_terms_id,
5600 cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,
5601 cm_salesrep_id : rv.cohead_salesrep_id,
5602 cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,
5603 cm_docdate : new Date(),
5604 cm_taxzone_id : rv.cohead_taxzone_id,
5605 cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,
5606 cm_billto_cntct_id : rv.cohead_billto_cntct_id,
5607 cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,
5608 cm_location_src : rv.cohead_location_src,
5609 cm_location_src_location_name : rv.cohead_location_src_location_name,
5610 cm_billto_address : rv.billto_address
5614 _this.invgrid.ds.load({});
5620 _this.invgrid = this;
5621 //_this.dialog = Pman.Dialog.FILL_IN
5622 if (_this.invpanel.active) {
5637 xtype : 'GridPanel',
5638 fitContainer : true,
5640 tableName : 'cobmisc',
5642 activate : function() {
5643 _this.invpanel = this;
5644 if (_this.invgrid) {
5645 _this.invgrid.ds.load({});
5659 xtype : 'NestedLayoutPanel',
5660 title : "Shipments / Invoices",
5663 activate : function (_self)
5665 _this.shipinvtab = _self;
5677 '|xns' : 'Roo.data',
5678 url : baseURL + '/Roo/events.php',
5680 xtype : 'HttpProxy',
5684 '|xns' : 'Roo.data',
5687 xtype : 'JsonReader',
5690 'name': 'event_when',
5702 'name': 'person_id_name',
5711 builderCfg : '{\"cols\":[{\"table\":\"events\",\"column\":\"event_when\",\"columnshort\":\"event_when\",\"ctype\":\"timestamp\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"action\",\"columnshort\":\"action\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"ipaddr\",\"columnshort\":\"ipaddr\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"person\",\"column\":\"person_id_name\",\"columnshort\":\"name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"remarks\",\"columnshort\":\"remarks\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}],\"cols_ex\":[\"remarks\"],\"table\":\"events\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
5712 totalProperty : 'total'
5714 '|xns' : 'Roo.data',
5717 sortInfo : { field : 'event_when', direction: 'DESC' },
5719 builderCfg : '{\"cols\":[{\"table\":\"events\",\"column\":\"event_when\",\"columnshort\":\"event_when\",\"ctype\":\"timestamp\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"action\",\"columnshort\":\"action\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"ipaddr\",\"columnshort\":\"ipaddr\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"person\",\"column\":\"person_id_name\",\"columnshort\":\"name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"remarks\",\"columnshort\":\"remarks\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}],\"cols_ex\":[\"remarks\"],\"table\":\"events\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
5721 beforeload : function (_self, options)
5723 options.params._related_on_table = 'cohead';
5724 options.params._related_on_id = _this.form.findField('cohead_id').getValue();
5735 xtype : 'PagingToolbar',
5736 emptyMsg : "No events found",
5739 displayMsg : "Displaying events{0} - {1} of {2}"
5741 '|xns' : 'Roo.grid',
5742 autoExpandColumn : 'remarks',
5746 builderCfg : '{\"cols\":[{\"table\":\"events\",\"column\":\"event_when\",\"columnshort\":\"event_when\",\"ctype\":\"timestamp\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"action\",\"columnshort\":\"action\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"ipaddr\",\"columnshort\":\"ipaddr\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"person\",\"column\":\"person_id_name\",\"columnshort\":\"name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"remarks\",\"columnshort\":\"remarks\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}],\"cols_ex\":[\"remarks\"],\"table\":\"events\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
5749 '|xns' : 'Roo.grid',
5750 xtype : 'ColumnModel',
5753 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); },
5755 dataIndex : 'event_when',
5756 builderCfg : '{\"table\":\"events\",\"column\":\"event_when\",\"columnshort\":\"event_when\",\"ctype\":\"timestamp\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}'
5759 '|xns' : 'Roo.grid',
5760 xtype : 'ColumnModel',
5763 renderer : function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); },
5765 dataIndex : 'action',
5766 builderCfg : '{\"table\":\"events\",\"column\":\"action\",\"columnshort\":\"action\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}'
5769 '|xns' : 'Roo.grid',
5770 xtype : 'ColumnModel',
5771 header : 'IP address',
5773 renderer : function(v) { return String.format('{0}', v); },
5775 dataIndex : 'ipaddr',
5776 builderCfg : '{\"table\":\"events\",\"column\":\"ipaddr\",\"columnshort\":\"ipaddr\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}'
5779 '|xns' : 'Roo.grid',
5780 xtype : 'ColumnModel',
5783 renderer : function(v) { return String.format('{0}', v); },
5785 dataIndex : 'person_id_name',
5786 builderCfg : '{\"table\":\"person\",\"column\":\"person_id_name\",\"columnshort\":\"name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}'
5789 '|xns' : 'Roo.grid',
5790 xtype : 'ColumnModel',
5793 renderer : function(v) { return String.format('{0}', v); },
5795 dataIndex : 'remarks',
5796 builderCfg : '{\"table\":\"events\",\"column\":\"remarks\",\"columnshort\":\"remarks\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}'
5800 rowdblclick : function (_self, rowIndex, e)
5802 if (!_this.dialog) return;
5803 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
5804 _this.grid.footer.onClick('first');
5810 //_this.dialog = Pman.Dialog.FILL_IN
5811 if (_this.hpanel.active) {
5812 this.footer.onClick('first');
5826 xtype : 'GridPanel',
5827 fitContainer : true,
5829 builderCfg : '{\"cols\":[{\"table\":\"events\",\"column\":\"event_when\",\"columnshort\":\"event_when\",\"ctype\":\"timestamp\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"action\",\"columnshort\":\"action\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"ipaddr\",\"columnshort\":\"ipaddr\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"person\",\"column\":\"person_id_name\",\"columnshort\":\"name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"remarks\",\"columnshort\":\"remarks\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}],\"cols_ex\":[\"remarks\"],\"table\":\"events\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
5830 tableName : 'events',
5832 activate : function() {
5833 _this.hpanel = this;
5835 _this.hgrid.footer.onClick('first');
5848 xtype : 'LayoutRegion',
5853 xtype : 'LayoutRegion',
5859 xtype : 'BorderLayout',
5870 '|xns' : 'Roo.Toolbar',
5871 text : "Run Apply Fifo on order",
5875 click : function (_self, e)
5879 url : baseURL + '/Roo/Cohead',
5882 _apply_fifo : _this.form.findField('cohead_id').getValue()
5884 success : function () {
5885 Roo.MessageBox.alert("Applied", "Succesfully Applied");
5892 '|xns' : 'Roo.Toolbar',
5893 text : "Run Void flagger",
5897 click : function (_self, e)
5901 url : baseURL + '/Roo/Cohead',
5904 _run_void_fix : _this.form.findField('cohead_id').getValue()
5906 success : function () {
5907 Roo.MessageBox.alert("Applied", "Succesfully Run");
5914 '|xns' : 'Roo.Toolbar',
5915 text : "Auto Reverse",
5919 click : function (_self, e)
5924 url : baseURL + '/Roo/Invdetail',
5929 _reverse_all_bad : _this.form.findField('cohead_id').getValue()
5931 success : function () {
5932 Roo.MessageBox.alert("Applied", "Succesfully Run");
5942 '|xns' : 'Roo.grid',
5943 xtype : 'RowSelectionModel',
5944 singleSelect : true,
5947 selectionchange : function (_self)
5949 _this.txdgrid.footer.onClick('first');;
5955 '|xns' : 'Roo.data',
5956 url : baseURL + '/Roo/invdetail.php',
5957 xtype : 'HttpProxy',
5962 '|xns' : 'Roo.data',
5965 xtype : 'JsonReader',
5969 'name': 'invdetail_id',
5973 'name': 'invdetail_transtype',
5977 'name': 'invdetail_invhist_id',
5981 'name': 'invdetail_location_id',
5985 'name': 'invdetail_qty',
5989 'name': 'invdetail_comments',
5993 'name': 'invdetail_qty_before',
5997 'name': 'invdetail_qty_after',
6001 'name': 'invdetail_invcitem_id',
6005 'name': 'invdetail_expiration',
6007 'dateFormat': 'Y-m-d'
6010 'name': 'invdetail_warrpurc',
6012 'dateFormat': 'Y-m-d'
6015 'name': 'invdetail_ls_id',
6019 totalProperty : 'total'
6021 '|xns' : 'Roo.data',
6024 sortInfo : { field : 'item_number', direction: 'ASC' },
6027 beforeload : function (_self, o)
6029 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
6030 if (! o.params.cohead_id ) {
6044 xtype : 'PagingToolbar',
6045 emptyMsg : "No invdetail found",
6047 displayMsg : "Displaying invdetail{0} - {1} of {2}",
6050 '|xns' : 'Roo.grid',
6051 autoExpandColumn : 'item_number',
6057 '|xns' : 'Roo.grid',
6058 xtype : 'ColumnModel',
6061 renderer : function(v) { return String.format('{0}', v); },
6063 dataIndex : 'item_number'
6066 '|xns' : 'Roo.grid',
6068 xtype : 'ColumnModel',
6071 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); },
6073 dataIndex : 'rec_shipped'
6076 '|xns' : 'Roo.grid',
6078 xtype : 'ColumnModel',
6081 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); },
6083 dataIndex : 'rec_returned'
6086 '|xns' : 'Roo.grid',
6088 xtype : 'ColumnModel',
6089 header : '#TX ship',
6091 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); },
6093 dataIndex : 'tx_shipped'
6096 '|xns' : 'Roo.grid',
6098 xtype : 'ColumnModel',
6101 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); },
6103 dataIndex : 'tx_returned'
6106 '|xns' : 'Roo.grid',
6108 xtype : 'ColumnModel',
6111 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); },
6113 dataIndex : 'tx_total'
6116 '|xns' : 'Roo.grid',
6118 xtype : 'ColumnModel',
6121 renderer : function(v,x,r) {
6123 return (v*1).toFixed(3);
6126 dataIndex : 'total_value'
6129 '|xns' : 'Roo.grid',
6131 xtype : 'ColumnModel',
6134 renderer : function(v,x,r) {
6136 var cototal = (r.data.rec_returned*1) - (r.data.rec_shipped*1);
6137 // Roo.log(cototal);
6138 var diff = (v*1) - cototal;
6143 return String.format('<span style="color:red">{0}</span>', diff );
6146 dataIndex : 'tx_total'
6152 _this.txgrid = this;
6153 //_this.dialog = Pman.Dialog.FILL_IN
6154 if (_this.txpanel.active) {
6155 this.footer.onClick('first');
6168 title : "invdetail",
6169 xtype : 'GridPanel',
6170 fitContainer : true,
6172 tableName : 'invdetail',
6174 activate : function() {
6175 _this.txpanel = this;
6177 _this.txgrid.footer.onClick('first');
6194 '|xns' : 'Roo.Toolbar',
6195 text : "Duplicate Selected",
6199 click : function (_self, e)
6201 var s = _this.txdgrid.selModel.getSelected();
6204 Roo.MessageBox.alert("Error", "Select a transaction");
6208 var reverseSel = function() {
6212 url : baseURL + '/Roo/invdetail',
6215 _duplicate : s.data.invdetail_id
6217 success : function() {
6218 _this.txdgrid.footer.onClick('first');
6226 Roo.MessageBox.confirm(
6228 "This should only be used by System Administrators - are you sure you know what you are doing!",
6244 '|xns' : 'Roo.Toolbar',
6249 '|xns' : 'Roo.Toolbar',
6250 text : "Issue Date",
6255 '|xns' : 'Roo.form',
6257 fieldLabel : 'Issue Date',
6258 xtype : 'DateField',
6262 name : 'issue_date',
6264 render : function (_self)
6266 _this.dateSel = _self;
6271 '|xns' : 'Roo.Toolbar',
6272 text : "Reverse Selected",
6276 click : function (_self, e)
6278 var s = _this.txdgrid.selModel.getSelected();
6279 var dt = _this.dateSel.getValue();
6281 Roo.MessageBox.alert("Error", "Select a transaction");
6285 var reverseSel = function(force) {
6289 url : baseURL + '/Roo/invdetail',
6292 _reverse : s.data.invdetail_id,
6293 _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
6296 success : function() {
6297 _this.txdgrid.footer.onClick('first');
6299 failure : function(res) {
6302 if (res.errors.confirm) {
6304 Roo.MessageBox.confirm(
6306 "are you really sure the totals will get messed up.",
6317 Roo.MessageBox.alert("Error", res.errorMsg);
6327 Roo.MessageBox.confirm(
6329 "This should only be used by System Administrators - are you sure you know what you are doing!",
6349 '|xns' : 'Roo.data',
6350 url : baseURL + '/Roo/invdetail.php',
6351 xtype : 'HttpProxy',
6356 '|xns' : 'Roo.data',
6359 xtype : 'JsonReader',
6363 'name': 'invdetail_id',
6367 'name': 'invdetail_transtype',
6371 'name': 'invdetail_invhist_id',
6375 'name': 'invdetail_location_id',
6379 'name': 'invdetail_qty',
6383 'name': 'invdetail_comments',
6387 'name': 'invdetail_qty_before',
6391 'name': 'invdetail_qty_after',
6395 'name': 'invdetail_invcitem_id',
6399 'name': 'invdetail_expiration',
6401 'dateFormat': 'Y-m-d'
6404 'name': 'invdetail_warrpurc',
6406 'dateFormat': 'Y-m-d'
6409 'name': 'invdetail_ls_id',
6413 totalProperty : 'total'
6415 '|xns' : 'Roo.data',
6418 sortInfo : { field : 'invdetail_id', direction: 'ASC' },
6421 beforeload : function (_self, o)
6423 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
6424 var s = _this.txgrid.selModel.getSelected();
6429 o.params.itemsite_id = s.data.invhist_itemsite_id;
6441 xtype : 'PagingToolbar',
6442 emptyMsg : "No invdetail found",
6444 displayMsg : "Displaying invdetail{0} - {1} of {2}",
6447 '|xns' : 'Roo.grid',
6448 autoExpandColumn : 'invhist_comments',
6454 '|xns' : 'Roo.grid',
6455 xtype : 'ColumnModel',
6458 renderer : function(v) { return String.format('{0}', v); },
6460 dataIndex : 'invdetail_id'
6463 '|xns' : 'Roo.grid',
6464 xtype : 'ColumnModel',
6467 renderer : function(v) { return String.format('{0}', v); },
6469 dataIndex : 'invhist_transdate'
6472 '|xns' : 'Roo.grid',
6473 xtype : 'ColumnModel',
6476 renderer : function(v,x,r) {
6477 if (r.data.invfifo_void *1 != 0) {
6478 return String.format('<s>{0}</s>', v);
6481 return String.format('{0}', v);
6484 dataIndex : 'invhist_ordnumber'
6487 '|xns' : 'Roo.grid',
6488 xtype : 'ColumnModel',
6491 renderer : function(v) { return String.format('{0}', v); },
6493 dataIndex : 'location_name'
6496 '|xns' : 'Roo.grid',
6497 xtype : 'ColumnModel',
6500 renderer : function(v) { return String.format('{0}', v); },
6502 dataIndex : 'invhist_comments'
6505 '|xns' : 'Roo.grid',
6507 xtype : 'ColumnModel',
6508 header : 'Qty Changed',
6510 renderer : function(v,x,r) {
6511 if ( r.data.coitem_shipped != v) {
6512 return String.format('{0} <span style="color:red">({1})</span>',
6513 Roo.util.Format.number(v,0),
6514 r.data.coitem_shipped
6518 return String.format('{0}', Roo.util.Format.number(v,0));
6521 dataIndex : 'invdetail_qty'
6524 '|xns' : 'Roo.grid',
6526 xtype : 'ColumnModel',
6527 header : 'Qty Changed',
6529 renderer : function(v,x,r) {
6530 var tot = r.data.invhist_value_after*1 - v*1;
6532 if (r.data.invdetail_qty >0 && tot < 0) {
6533 f = '<span style="color:red">{0}</span>';
6535 if (r.data.invdetail_qty < 0 && tot > 0) {
6536 f = '<span style="color:red">{0}</span>';
6538 return String.format(f, Roo.util.Format.number(tot));
6541 dataIndex : 'invhist_value_before'
6544 '|xns' : 'Roo.grid',
6545 xtype : 'ColumnModel',
6548 renderer : function(v,x,r) {
6550 var state = v ? '-checked' : '';
6552 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
6555 dataIndex : 'invhist_posted'
6561 _this.txdgrid = this;
6562 //_this.dialog = Pman.Dialog.FILL_IN
6563 if (_this.txdpanel.active) {
6564 this.footer.onClick('first');
6567 rowclick : function (_self, rowIndex, e)
6569 var s = _this.txdgrid.ds.getAt(rowIndex);
6570 var dt = s.data.invhist_transdate.split(' ');
6572 _this.dateSel.setValue(new Date(dt[0]));
6584 title : "invdetail",
6585 xtype : 'GridPanel',
6586 fitContainer : true,
6588 tableName : 'invdetail',
6590 activate : function() {
6591 _this.txdpanel = this;
6592 if (_this.txdgrid) {
6593 _this.txdgrid.footer.onClick('first');
6607 xtype : 'NestedLayoutPanel',
6619 xtype : 'LayoutRegion',
6624 xtype : 'LayoutRegion',
6630 xtype : 'BorderLayout',
6636 '|xns' : 'Roo.grid',
6637 xtype : 'RowSelectionModel',
6638 singleSelect : true,
6641 selectionchange : function (_self)
6643 _this.gltxdgrid.footer.onClick('first');;
6649 '|xns' : 'Roo.data',
6650 url : baseURL + '/Roo/gltrans.php',
6651 xtype : 'HttpProxy',
6656 '|xns' : 'Roo.data',
6659 xtype : 'JsonReader',
6663 'name': 'invdetail_id',
6667 'name': 'invdetail_transtype',
6671 'name': 'invdetail_invhist_id',
6675 'name': 'invdetail_location_id',
6679 'name': 'invdetail_qty',
6683 'name': 'invdetail_comments',
6687 'name': 'invdetail_qty_before',
6691 'name': 'invdetail_qty_after',
6695 'name': 'invdetail_invcitem_id',
6699 'name': 'invdetail_expiration',
6701 'dateFormat': 'Y-m-d'
6704 'name': 'invdetail_warrpurc',
6706 'dateFormat': 'Y-m-d'
6709 'name': 'invdetail_ls_id',
6713 totalProperty : 'total'
6715 '|xns' : 'Roo.data',
6718 sortInfo : { field : 'item_number', direction: 'ASC' },
6721 beforeload : function (_self, o)
6723 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
6724 if (! o.params.cohead_id ) {
6728 o.params._split_sales = _this.glsalesbtn.pressed ? 1 : 0;
6739 xtype : 'PagingToolbar',
6740 emptyMsg : "No invdetail found",
6742 displayMsg : "Displaying invdetail{0} - {1} of {2}",
6746 '|xns' : 'Roo.Toolbar',
6747 text : "Split sales",
6748 enableToggle : true,
6753 render : function (_self)
6755 _this.glsalesbtn = _self;
6757 click : function (_self, e)
6759 (function() { _this.gltxgrid.footer.onClick('first'); }).defer(100);
6766 '|xns' : 'Roo.grid',
6767 autoExpandColumn : 'gltrans_accnt_id_accnt_descrip',
6773 '|xns' : 'Roo.grid',
6774 xtype : 'ColumnModel',
6777 renderer : function(v,x,r) {
6779 var state = v*1 ? '-checked' : '';
6781 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
6784 dataIndex : 'gltrans_as_summary'
6787 '|xns' : 'Roo.grid',
6788 xtype : 'ColumnModel',
6791 renderer : function(v) { return String.format('{0}', v); },
6793 dataIndex : 'gltrans_accnt_id_accnt_descrip'
6796 '|xns' : 'Roo.grid',
6798 xtype : 'ColumnModel',
6801 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); },
6803 dataIndex : 'gltrans_amount_credit'
6806 '|xns' : 'Roo.grid',
6808 xtype : 'ColumnModel',
6811 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); },
6813 dataIndex : 'gltrans_amount_debit'
6816 '|xns' : 'Roo.grid',
6818 xtype : 'ColumnModel',
6821 renderer : function(v) { return String.format('<b>{0}</b>', Roo.util.Format.number(v,3)); },
6823 dataIndex : 'gltrans_amount_total'
6826 '|xns' : 'Roo.grid',
6828 xtype : 'ColumnModel',
6829 header : 'Unposted',
6831 renderer : function(v) { return String.format('<span style="color:red">{0}</span>', Roo.util.Format.number(v,3)); },
6833 dataIndex : 'gltrans_amount_total_unposted'
6837 cellclick : function (_self, rowIndex, columnIndex, e)
6839 if (columnIndex > 0) {
6842 var rec = this.ds.getAt(rowIndex);
6843 rec.set('gltrans_as_summary', rec.data.gltrans_as_summary *1 ? 0 : 1);
6844 _this.gltxdgrid.footer.onClick('first');
6848 _this.gltxgrid = this;
6849 //_this.dialog = Pman.Dialog.FILL_IN
6850 if (_this.gltxpanel.active) {
6851 this.footer.onClick('first');
6864 title : "invdetail",
6865 xtype : 'GridPanel',
6866 fitContainer : true,
6868 tableName : 'invdetail',
6870 activate : function() {
6871 _this.gltxpanel = this;
6872 if (_this.gltxgrid) {
6873 _this.gltxgrid.footer.onClick('first');
6886 '|xns' : 'Roo.data',
6887 url : baseURL + '/Roo/gltrans.php',
6888 xtype : 'HttpProxy',
6893 '|xns' : 'Roo.data',
6896 xtype : 'JsonReader',
6900 'name': 'invdetail_id',
6904 'name': 'invdetail_transtype',
6908 'name': 'invdetail_invhist_id',
6912 'name': 'invdetail_location_id',
6916 'name': 'invdetail_qty',
6920 'name': 'invdetail_comments',
6924 'name': 'invdetail_qty_before',
6928 'name': 'invdetail_qty_after',
6932 'name': 'invdetail_invcitem_id',
6936 'name': 'invdetail_expiration',
6938 'dateFormat': 'Y-m-d'
6941 'name': 'invdetail_warrpurc',
6943 'dateFormat': 'Y-m-d'
6946 'name': 'invdetail_ls_id',
6950 totalProperty : 'total'
6952 '|xns' : 'Roo.data',
6955 sortInfo : { field : 'gltrans_docnumber', direction: 'ASC' },
6958 beforeload : function (_self, o)
6960 o.params.cohead_id = _this.form.findField('cohead_id').getValue();
6961 var s = _this.gltxgrid.selModel.getSelected();
6966 o.params.gltrans_accnt_id = s.data.gltrans_accnt_id;
6967 o.params.gltrans_is_ship = s.data.gltrans_is_ship;
6968 o.params.gltrans_as_summary = s.data.gltrans_as_summary;
6981 xtype : 'PagingToolbar',
6982 emptyMsg : "No invdetail found",
6984 displayMsg : "Displaying invdetail{0} - {1} of {2}",
6988 '|xns' : 'Roo.Toolbar',
6993 click : function (_self, e)
6995 new Pman.Download( {
6996 grid : _this.gltxdgrid
7005 '|xns' : 'Roo.grid',
7006 autoExpandColumn : 'gltrans_notes',
7012 '|xns' : 'Roo.grid',
7013 xtype : 'ColumnModel',
7017 renderer : function(v) { return String.format('{0}', v ); },
7019 dataIndex : 'gltrans_id'
7022 '|xns' : 'Roo.grid',
7023 xtype : 'ColumnModel',
7026 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
7028 dataIndex : 'gltrans_date'
7031 '|xns' : 'Roo.grid',
7032 xtype : 'ColumnModel',
7035 renderer : function(v,x,r) {
7036 if (r.data.gltrans_deleted) {
7037 return String.format('<s>{0}</s>', v);
7039 return String.format('{0}', v);
7042 dataIndex : 'gltrans_docnumber'
7045 '|xns' : 'Roo.grid',
7046 xtype : 'ColumnModel',
7049 renderer : function(v) { return String.format('{0}', v); },
7051 dataIndex : 'gltrans_source'
7054 '|xns' : 'Roo.grid',
7055 xtype : 'ColumnModel',
7058 renderer : function(v) { return String.format('{0}', v); },
7060 dataIndex : 'gltrans_notes'
7063 '|xns' : 'Roo.grid',
7065 xtype : 'ColumnModel',
7068 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); },
7070 dataIndex : 'gltrans_amount'
7073 '|xns' : 'Roo.grid',
7074 xtype : 'ColumnModel',
7077 renderer : function(v,x,r) {
7079 var state = v ? '-checked' : '';
7081 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
7084 dataIndex : 'gltrans_posted'
7088 cellclick : function (_self, ri, ci, e)
7091 var deleteSel = function() {
7095 url : baseURL + '/Roo/gltrans',
7099 gltrans_id : rec.data.gltrans_id
7102 success : function() {
7103 rec.set('gltrans_posted', false);
7104 rec.set('gltrans_deleted', true);
7105 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
7106 _this.gltxgrid.footer.onClick('first');
7111 var undeleteSel = function() {
7115 url : baseURL + '/Roo/gltrans',
7119 gltrans_id : rec.data.gltrans_id
7122 success : function() {
7123 rec.set('gltrans_posted', true);
7124 rec.set('gltrans_deleted', false);
7125 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
7126 _this.gltxgrid.footer.onClick('first');
7132 var di = this.colModel.config[ci].dataIndex;
7133 if (di != 'gltrans_posted') {
7139 var rec = this.ds.getAt(ri);
7140 if (rec.data.gltrans_deleted) {
7142 Roo.MessageBox.confirm(
7144 "This should only be used by System Administrators - are you sure you know what you are doing!",
7158 if (!rec.data.gltrans_posted) {
7164 url : baseURL + '/Roo/gltrans',
7168 gltrans_id : rec.data.gltrans_id
7170 success : function (res)
7172 rec.set('gltrans_posted', true);
7173 _this.gltxgrid.footer.onClick('first');
7182 // we have a posted transaction.
7183 // only allow recalled to be deleted..
7184 if (!rec.data.gltrans_notes.match(/(Recall|Ship Order)/)) {
7193 Roo.MessageBox.confirm(
7195 "This should only be used by System Administrators - are you sure you know what you are doing!",
7209 _this.gltxdgrid = this;
7210 //_this.dialog = Pman.Dialog.FILL_IN
7211 if (_this.gltxdpanel.active) {
7212 this.footer.onClick('first');
7225 title : "invdetail",
7226 xtype : 'GridPanel',
7227 fitContainer : true,
7229 tableName : 'invdetail',
7231 activate : function() {
7232 _this.gltxdpanel = this;
7233 if (_this.gltxdgrid) {
7234 _this.gltxdgrid.footer.onClick('first');
7248 xtype : 'NestedLayoutPanel',
7260 '|xns' : 'Roo.data',
7261 url : baseURL + '/Roo/coitem.php',
7262 xtype : 'HttpProxy',
7267 '|xns' : 'Roo.data',
7270 xtype : 'JsonReader',
7290 'name': 'leader_id',
7294 'name': 'leader_office_id',
7298 'name': 'leader_name',
7302 'name': 'leader_phone',
7306 'name': 'leader_fax',
7310 'name': 'leader_email',
7314 'name': 'leader_company_id',
7318 'name': 'leader_role',
7322 'name': 'leader_active',
7326 'name': 'leader_remarks',
7330 'name': 'leader_passwd',
7334 'name': 'leader_owner_id',
7338 'name': 'leader_lang',
7342 'name': 'leader_no_reset_sent',
7346 'name': 'leader_action_type',
7350 'name': 'leader_project_id',
7354 'name': 'leader_deleted_by',
7358 'name': 'leader_deleted_dt',
7362 'name': 'leader_firstname',
7366 'name': 'leader_lastname',
7370 'name': 'leader_name_facebook',
7374 'name': 'leader_url_blog',
7378 'name': 'leader_url_twitter',
7382 'name': 'leader_url_linkedin',
7386 'name': 'leader_crm_lead_percentage',
7390 'name': 'leader_crm_industry_id',
7394 'name': 'leader_crm_updated_action_id',
7398 'name': 'leader_crm_created_action_id',
7402 'name': 'leader_crm_type_id',
7406 totalProperty : 'total'
7408 '|xns' : 'Roo.data',
7411 sortInfo : { field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' },
7414 beforeload : function (_self,o) {
7421 if (!_this.data || !_this.data.cohead_id) {
7424 o.params = o.params || {};
7426 o.params.coitem_cohead_id = _this.data.cohead_id;
7427 o.params._without_list_discount =1;
7428 o.params._with_profit = 1;
7440 xtype : 'PagingToolbar',
7441 emptyMsg : "No coitem found",
7443 displayMsg : "Displaying coitem{0} - {1} of {2}",
7446 '|xns' : 'Roo.grid',
7447 autoExpandColumn : 'item_number',
7453 '|xns' : 'Roo.grid',
7454 xtype : 'ColumnModel',
7455 header : 'Item Code',
7457 renderer : function(v) { return String.format('{0}', v); },
7459 dataIndex : 'item_number'
7462 '|xns' : 'Roo.grid',
7463 xtype : 'ColumnModel',
7464 header : 'SubTotal',
7466 renderer : function(v) {
7469 return Roo.util.Format.number( v, 2);
7472 dataIndex : 'calc_subtotal'
7475 '|xns' : 'Roo.grid',
7476 xtype : 'ColumnModel',
7477 header : 'Cost of goods',
7479 renderer : function(v) {
7481 return Roo.util.Format.number( v, 2);
7484 dataIndex : 'calc_cost_total'
7487 '|xns' : 'Roo.grid',
7488 xtype : 'ColumnModel',
7491 renderer : function(v,x,r) {
7493 var profit = r.data.calc_subtotal - r.data.calc_cost_total;
7495 if(parseInt(profit) < 1){
7496 return String.format('<b style="color:red;">{0}</b>', Roo.util.Format.number(profit,2));
7500 return Roo.util.Format.number( profit, 2);
7503 dataIndex : 'profit'
7509 _this.profitgrid = this;
7510 //_this.dialog = Pman.Dialog.FILL_IN
7511 if (_this.profitpanel.active) {
7512 this.footer.onClick('first');
7526 xtype : 'GridPanel',
7527 fitContainer : true,
7529 tableName : 'coitem',
7531 activate : function() {
7532 _this.profitpanel = this;
7534 try { if (MODULE.isBuilder) {
7538 var id = _this.form.findField('cohead_id').getValue() * 1;
7540 Roo.MessageBox.alert("Save First", "Save the order first, before adding items");
7541 _this.dialog.layout.getRegion('center').showPanel(0);
7545 if (_this.profitgrid) {
7546 _this.profitgrid.footer.onClick('first');