1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.XtuplePriceLists = new Roo.XComponent({
6 part : ["Xtuple","PriceLists"],
7 order : '001-Pman.Tab.XtuplePriceLists',
9 parent : 'Pman.Tab.XtupleManage',
10 name : "Pman.Tab.XtuplePriceLists",
18 xtype: 'NestedLayoutPanel',
26 xtype: 'BorderLayout',
33 activate : function() {
36 _this.grid.footer.onClick('first');
44 tableName : 'ipshead',
45 title : "Price Lists",
53 _this.dialog = Pman.Dialog.XtuplePriceList
54 if (_this.panel.active) {
55 this.footer.onClick('first');
58 rowdblclick : function (_self, rowIndex, e)
60 if (!_this.dialog) return;
61 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
62 _this.grid.footer.onClick('first');
67 autoExpandColumn : 'ipshead_descrip',
73 sortInfo : { field : 'ipshead_name', direction: 'ASC' },
78 url : baseURL + '/Roo/ipshead.php'
83 totalProperty : 'total',
92 'name': 'ipshead_name',
96 'name': 'ipshead_descrip',
100 'name': 'ipshead_effective',
102 'dateFormat': 'Y-m-d'
105 'name': 'ipshead_expires',
107 'dateFormat': 'Y-m-d'
110 'name': 'ipshead_curr_id',
114 'name': 'ipshead_updated',
116 'dateFormat': 'Y-m-d'
119 'name': 'ipshead_curr_id_curr_id',
123 'name': 'ipshead_curr_id_curr_base',
127 'name': 'ipshead_curr_id_curr_name',
131 'name': 'ipshead_curr_id_curr_symbol',
135 'name': 'ipshead_curr_id_curr_abbr',
142 xtype: 'PagingToolbar',
145 displayMsg : "Displaying ipshead{0} - {1} of {2}",
146 emptyMsg : "No ipshead found",
157 click : function (_self, e)
161 url : baseURL + '/Roo/Ipsiteminfo',
168 text : "Download Price Matrix"
174 click : function (_self, e)
176 Pman.Dialog.Image.show(
178 _url : baseURL+'/Xtuple/Pricing'
184 msg.push("Deleted " + data.deleted + " Price(s)");
187 msg.push("Updated " + data.updated + " Price(s)");
190 msg.push("Added " + data.inserted + " Price(s)");
193 msg.push("No data changed");
195 Roo.MessageBox.alert("Notice", msg.join("\n"));
201 text : "Upload Price Matrix"
211 cls : 'x-btn-text-icon',
212 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
216 if (!_this.dialog) return;
217 _this.dialog.show( { id : 0 } , function() {
218 _this.grid.footer.onClick('first');
227 cls : 'x-btn-text-icon',
228 icon : rootURL + '/Pman/templates/images/trash.gif',
232 Pman.genericDelete(_this, 'ipshead');
240 xtype: 'ColumnModel',
242 dataIndex : 'ipshead_curr_id_curr_name',
243 header : 'Ipshead curr',
246 renderer : function(v) { return String.format('{0}', v); }
249 xtype: 'ColumnModel',
251 dataIndex : 'ipshead_name',
252 header : 'Ipshead name',
255 renderer : function(v) { return String.format('{0}', v); }
258 xtype: 'ColumnModel',
260 header : 'Ipshead descrip',
262 dataIndex : 'ipshead_descrip',
263 renderer : function(v) { return String.format('{0}', v); }
266 xtype: 'ColumnModel',
268 header : 'Ipshead effective',
270 dataIndex : 'ipshead_effective',
271 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
274 xtype: 'ColumnModel',
276 dataIndex : 'ipshead_expires',
277 header : 'Ipshead expires',
279 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
282 xtype: 'ColumnModel',
284 header : 'Ipshead updated',
286 dataIndex : 'ipshead_updated',
287 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
296 activate : function() {
299 // _this.igrid.footer.onClick('first');
316 //_this.dialog = Pman.Dialog.FILL_IN
317 if (_this.ipanel.active) {
318 //this.footer.onClick('first');
321 cellclick : function (_self, row, col, e)
323 var di = _this.grid.colModel.getDataIndex(col);
325 var rec = _this.grid.ds.getAt(row);
327 if(di == 'item_image_filename'){
328 if(!rec.data.item_image_id){
332 if(rec.data.item_image_from_hk){
335 u = u.join('/') + '/hk.php';
338 url: u + '/Images/Download/' + rec.data.item_image_id + '/' + rec.data.item_image_filename
343 if (di == 'item_active') {
345 var nv = rec.data.item_active ? 0 : 1;
348 url : baseURL + '/Roo/Item',
350 item_id : rec.data.item_id,
353 success : function() {
354 rec.set('item_active', nv);
362 if(di == 'itemsrc_active'){
363 if(!rec.data.itemsrc_active){
364 Roo.MessageBox.alert('Error','Please edit it on Xtuple tool');
367 if(rec.data.itemsrc_active){
368 Roo.MessageBox.confirm("Confirm", "Are you sure this product is no longer purchased",
378 _this.locgrid.footer.onClick('first');
384 afteredit : function (e)
390 url : baseURL +'/Roo/Charass',
392 charass_char_id_char_name : e.field.replace(/^item_char_/,'').toUpperCase(),
393 charass_value : e.value,
394 charass_target_type : 'I',
396 charass_target_id : e.record.data.item_id
407 rowdblclick : function (_self, rowIndex, e)
409 if (!_this.dialog) return;
410 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
411 _this.grid.footer.onClick('first');
415 autoExpandColumn : 'item_descrip1',
422 beforeload : function (_self, o)
424 o.params._with_prodcat = 1;
425 o.params._with_char = 1;
426 o.params._with_itemsrc_active = 1;
427 o.params._with_last_purchase_price = 1;
428 o.params._with_image = 1;
429 var s = _this.search.getValue();
431 o.params['query[number_or_name]'] = s;
433 if (!_this.active.pressed) {
434 o.params.item_active = 1;
436 if (_this.brandSel.getValue().length) {
437 o.params._with_brand = _this.brandSel.getValue()
440 update : function (_self, record, operation)
442 if(operation != 'commit'){
446 var nv = record.data.itemsrc_active ? 0 : 1;
449 url : baseURL + '/Roo/Itemsrc',
452 item_id : record.data.item_id,
455 success : function(res) {
456 record.set('itemsrc_active', nv);
462 sortInfo : { field : 'item_number', direction: 'ASC' },
467 url : baseURL + '/Roo/item.php'
472 totalProperty : 'total',
481 'name': 'item_number',
485 'name': 'item_descrip1',
489 'name': 'item_descrip2',
493 'name': 'item_classcode_id',
497 'name': 'item_picklist',
501 'name': 'item_comments',
509 'name': 'item_fractional',
513 'name': 'item_active',
521 'name': 'item_prodweight',
525 'name': 'item_packweight',
529 'name': 'item_prodcat_id',
533 'name': 'item_exclusive',
537 'name': 'item_listprice',
541 'name': 'item_config',
545 'name': 'item_extdescrip',
549 'name': 'item_upccode',
553 'name': 'item_maxcost',
557 'name': 'item_inv_uom_id',
561 'name': 'item_price_uom_id',
565 'name': 'item_warrdays',
569 'name': 'item_freightclass_id',
573 'name': 'item_tax_recoverable',
577 'name': 'item_price_uom_id_uom_id',
581 'name': 'item_price_uom_id_uom_name',
585 'name': 'item_price_uom_id_uom_descrip',
589 'name': 'item_price_uom_id_uom_item_weight',
593 'name': 'item_inv_uom_id_uom_id',
597 'name': 'item_inv_uom_id_uom_name',
601 'name': 'item_inv_uom_id_uom_descrip',
605 'name': 'item_inv_uom_id_uom_item_weight',
609 'name': 'item_freightclass_id_freightclass_id',
613 'name': 'item_freightclass_id_freightclass_code',
617 'name': 'item_freightclass_id_freightclass_descrip',
621 'name': 'item_classcode_id_classcode_id',
625 'name': 'item_classcode_id_classcode_code',
629 'name': 'item_classcode_id_classcode_descrip',
633 'name': 'item_classcode_id_classcode_mfg',
637 'name': 'item_classcode_id_classcode_creator',
641 'name': 'item_classcode_id_classcode_created',
645 'name': 'item_classcode_id_classcode_modifier',
649 'name': 'item_classcode_id_classcode_modified',
653 'name': 'item_classcode_id_classcode_type',
667 render : function (_self)
669 _this.brandSel = _self;
671 select : function (combo, record, index)
673 _this.grid.footer.onClick('first');
678 displayField : 'charass_value',
680 forceSelection : true,
682 loadingText : "Searching...",
685 qtip : "Select Brand",
686 queryParam : 'query[charass_value]',
687 selectOnFocus : true,
688 tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
689 triggerAction : 'all',
695 beforeload : function (_self, o)
697 o.params = o.params || {};
698 // staff can see all logs, other companies can only see their own.
699 // look for all of the charass 's with the same type= eg. brand.
701 o.params.charass_char_id_char_name = 'BRAND';
702 o.params.charass_target_type ='I';
703 o.params._distinct = 'charass_value';
704 o.params._columns = 'charass_value';
709 sortInfo : { field : 'charass_value' , direction : 'ASC' },
714 url : baseURL + '/Roo/Charass.php'
719 totalProperty : 'total',
728 'name': 'person_name',
732 'name': 'event_when',
734 'dateFormat': 'Y-m-d'
761 'name': 'person_id_id',
765 'name': 'person_id_office_id',
769 'name': 'person_id_name',
773 'name': 'person_id_phone',
777 'name': 'person_id_fax',
781 'name': 'person_id_email',
785 'name': 'person_id_company_id',
789 'name': 'person_id_role',
793 'name': 'person_id_active',
797 'name': 'person_id_remarks',
801 'name': 'person_id_passwd',
805 'name': 'person_id_owner_id',
809 'name': 'person_id_lang',
813 'name': 'person_id_no_reset_sent',
817 'name': 'person_id_action_type',
821 'name': 'person_id_project_id',
825 'name': 'person_id_deleted_by',
829 'name': 'person_id_deleted_dt',
840 render : function (_self)
842 _this.search = _self;
844 specialkey : function (_self, e)
846 _this.grid.footer.onClick('first');
854 click : function (_self, e)
856 _this.grid.footer.onClick('first');
860 icon : rootURL + '/Pman/templates/images/search.gif'
866 click : function (_self, e)
868 _this.search.setValue('');
872 _this.grid.footer.onClick('first');
876 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
886 toggle : function (_self, pressed)
889 this.setText(pressed ? "Hide Inactive" : "Show Inactive");
890 (function() { _this.grid.footer.onClick('first'); }).defer(100);
892 render : function (_self)
894 _this.active = _self;
898 text : "Show Inactive"
907 text : "Report start :"
913 render : function (_self)
915 _this.dateFrom = _self;
920 value : (function() { return (new Date()).format('Y') + '-01-01'; })()
926 render : function (_self)
928 _this.datespan = _self;
932 displayField : 'fname',
934 fieldLabel : 'Status',
935 hiddenName : 'cm_status',
938 name : 'cm_status_name',
939 triggerAction : 'all',
941 valueField : 'ftype',
944 xtype: 'SimpleStore',
947 [ '1', "Single Month Sales"],
948 [ '3', "Quarter Sales"],
949 [ '6', "Half year Sales"] ,
950 [ '12', "Full Year Sales"]
952 fields : [ 'ftype', 'fname']
959 click : function (_self, e)
961 if (!_this.brandSel.getValue().length) {
962 Roo.MessageBox.alert("Error", "Select a brand to download");
967 url : baseURL + '/Xtuple/Reports/SalesByCountryItemYear',
969 date_from : _this.dateFrom.getValue(),
970 brand : _this.brandSel.getValue(),
971 span : _this.datespan.getValue()
978 text : "Download Sales Report"
983 xtype: 'PagingToolbar',
987 displayMsg : "Displaying item{0} - {1} of {2}",
988 emptyMsg : "No item found",
994 click : function (_self, e)
998 url : baseURL + '/Roo/item',
1005 text : "Download Standard costs"
1011 click : function (_self, e)
1013 Pman.Dialog.Image.show(
1015 _url : baseURL+'/Xtuple/Import/Products'
1022 msg.push("Updated " + data.updated + " Products(s)");
1024 if (data.inserted) {
1025 msg.push("Added " + data.inserted + " Products(s)");
1028 msg.push("Skipped " + data.skipped);
1032 msg.push("No data changed");
1034 Roo.MessageBox.alert("Notice", msg.join("\n"));
1040 text : "Upload new products and costs"
1046 click : function (_self, e)
1049 var sel = _this.grid.selModel.getSelectedCell();
1051 Roo.MessageBox.alert("Error", "Select a row");
1055 var rec = _this.grid.ds.getAt(sel[0]);
1056 if(rec.data.item_id * 1 < 1){
1060 Pman.Dialog.Image.show({
1061 id : rec.data.item_image_id ? rec.data.item_image_id : 0,
1062 onid : rec.data.item_id,
1066 _this.grid.footer.onClick('first');
1073 text : "Upload an image"
1079 click : function (_self, e)
1081 Roo.MessageBox.progress ("Syncing Stock", "Sending");
1085 function runSync() {
1088 url : baseURL+'/Roo/Item',
1094 success : function(res) {
1096 if (!res.data.total) {
1097 Roo.MessageBox.hide();
1100 offset += res.data.limit;
1101 Roo.MessageBox.updateProgress ( offset / res.data.total, "Done " + offset + '/' + res.data.total);
1111 text : "Sync Product Data from HK",
1112 hidden : (function() {
1114 return baseURL.match(/hk\.php$/) ? true : false;
1121 xtype: 'ColumnModel',
1123 dataIndex : 'item_image_filename',
1124 header : 'Image ( Click to download )',
1126 renderer : function(v,x,r)
\r
1131 if(r.data.item_image_from_hk){
1132 var url = baseURL.split('/');
1134 url = url.join('/');
1135 return '<img src="' + url + '/hk.php/Images/Thumb/150x150/' + r.data.item_image_id + '/' + v + '" width="150" height="150" />';
1137 return '<img src="' + baseURL + '/Images/Thumb/150x150/' + r.data.item_image_id + '/' + v + '" width="150" height="150" />';
\r
1141 xtype: 'ColumnModel',
1143 dataIndex : 'item_char_brand',
1147 renderer : function(v) { return String.format('{0}', v); },
1149 xtype: 'GridEditor',
1156 displayField : 'charass_value',
1158 forceSelection : false,
1160 loadingText : "Searching...",
1163 qtip : "Select Brand",
1164 queryParam : 'query[charass_value]',
1165 selectOnFocus : true,
1166 tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
1167 triggerAction : 'all',
1173 beforeload : function (_self, o)
1175 o.params = o.params || {};
1176 // staff can see all logs, other companies can only see their own.
1177 // look for all of the charass 's with the same type= eg. brand.
1179 o.params.charass_char_id_char_name = 'BRAND';
1180 o.params.charass_target_type ='I';
1181 o.params._distinct = 'charass_value';
1182 o.params._columns = 'charass_value';
1187 sortInfo : { field : 'charass_value' , direction : 'ASC' },
1192 url : baseURL + '/Roo/Charass.php'
1195 xtype: 'JsonReader',
1197 totalProperty : 'total',
1206 'name': 'person_name',
1210 'name': 'event_when',
1212 'dateFormat': 'Y-m-d'
1231 'name': 'person_id',
1239 'name': 'person_id_id',
1243 'name': 'person_id_office_id',
1247 'name': 'person_id_name',
1251 'name': 'person_id_phone',
1255 'name': 'person_id_fax',
1259 'name': 'person_id_email',
1263 'name': 'person_id_company_id',
1267 'name': 'person_id_role',
1271 'name': 'person_id_active',
1275 'name': 'person_id_remarks',
1279 'name': 'person_id_passwd',
1283 'name': 'person_id_owner_id',
1287 'name': 'person_id_lang',
1291 'name': 'person_id_no_reset_sent',
1295 'name': 'person_id_action_type',
1299 'name': 'person_id_project_id',
1303 'name': 'person_id_deleted_by',
1307 'name': 'person_id_deleted_dt',
1317 xtype: 'ColumnModel',
1319 dataIndex : 'item_char_productgroup',
1320 header : 'Product Group',
1322 renderer : function(v) { return String.format('{0}', v); },
1324 xtype: 'GridEditor',
1331 displayField : 'charass_value',
1333 forceSelection : false,
1335 loadingText : "Searching...",
1338 qtip : "Select Brand",
1339 queryParam : 'query[charass_value]',
1340 selectOnFocus : true,
1341 tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
1342 triggerAction : 'all',
1348 beforeload : function (_self, o)
1350 o.params = o.params || {};
1351 // staff can see all logs, other companies can only see their own.
1352 // look for all of the charass 's with the same type= eg. brand.
1354 o.params.charass_char_id_char_name = 'PRODUCTGROUP';
1355 o.params.charass_target_type ='I';
1356 o.params._distinct = 'charass_value';
1357 o.params._columns = 'charass_value';
1361 sortInfo : { field : 'charass_value' , direction : 'ASC' },
1366 url : baseURL + '/Roo/Charass.php'
1369 xtype: 'JsonReader',
1371 totalProperty : 'total',
1380 'name': 'person_name',
1384 'name': 'event_when',
1386 'dateFormat': 'Y-m-d'
1405 'name': 'person_id',
1413 'name': 'person_id_id',
1417 'name': 'person_id_office_id',
1421 'name': 'person_id_name',
1425 'name': 'person_id_phone',
1429 'name': 'person_id_fax',
1433 'name': 'person_id_email',
1437 'name': 'person_id_company_id',
1441 'name': 'person_id_role',
1445 'name': 'person_id_active',
1449 'name': 'person_id_remarks',
1453 'name': 'person_id_passwd',
1457 'name': 'person_id_owner_id',
1461 'name': 'person_id_lang',
1465 'name': 'person_id_no_reset_sent',
1469 'name': 'person_id_action_type',
1473 'name': 'person_id_project_id',
1477 'name': 'person_id_deleted_by',
1481 'name': 'person_id_deleted_dt',
1491 xtype: 'ColumnModel',
1493 dataIndex : 'item_number',
1496 renderer : function(v) { return String.format('{0}', v); }
1499 xtype: 'ColumnModel',
1501 dataIndex : 'item_descrip1',
1502 header : 'Description',
1504 renderer : function(v) { return String.format('{0}', v); }
1507 xtype: 'ColumnModel',
1509 dataIndex : 'itemsrc_active',
1510 header : 'Purchased',
1512 renderer : function(v) {
1513 var state = v * 1 > 0 ? '-checked' : '';
1515 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1520 xtype: 'ColumnModel',
1522 dataIndex : 'item_sold',
1523 header : 'is Sold?',
1525 renderer : function(v) {
1526 var state = v * 1 > 0 ? '-checked' : '';
1528 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1533 xtype: 'ColumnModel',
1535 dataIndex : 'item_active',
1536 header : 'is Active?',
1538 renderer : function(v) {
1539 var state = v * 1 > 0 ? '-checked' : '';
1541 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1546 xtype: 'ColumnModel',
1548 dataIndex : 'last_purchase_price',
1549 header : 'Last purchase price',
1551 renderer : function(v,x,r) {
1553 return String.format('{0}{1}', r.data.last_purchase_price_curr_name, Roo.util.Format.number(v,2)) ;
1558 xtype: 'ColumnModel',
1560 dataIndex : 'item_type',
1561 header : 'Item type',
1563 renderer : function(v) { return String.format('{0}', v); }
1566 xtype: 'ColumnModel',
1568 dataIndex : 'item_prodcat_id_prodcat_code',
1569 header : 'Item prodcat',
1571 renderer : function(v) { return String.format('{0}', v); }
1574 xtype: 'ColumnModel',
1577 dataIndex : 'item_actcost',
1580 renderer : function(v,x,r) {
1582 return String.format('{0}{1}', r.data.item_curr_name, Roo.util.Format.number(v,2)) ;
1587 xtype: 'ColumnModel',
1590 dataIndex : 'item_base_cost',
1591 header : 'Cost (base)',
1593 renderer : function(v,x,r) {
1595 return String.format('{0}{1}', r.data.item_base_curr, Roo.util.Format.number(v,2)) ;
1604 xtype: 'LayoutRegion',
1608 xtype: 'LayoutRegion',