1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.XtupleItem = new Roo.XComponent({
6 part : ["Xtuple","Item"],
7 order : '001-Pman.Tab.XtupleItem',
9 parent : 'Pman.Tab.XtupleManage',
10 name : "Pman.Tab.XtupleItem",
18 xtype: 'NestedLayoutPanel',
24 xtype: 'BorderLayout',
31 activate : function() {
34 _this.grid.footer.onClick('first');
51 //_this.dialog = Pman.Dialog.FILL_IN
52 if (_this.panel.active) {
53 this.footer.onClick('first');
56 cellclick : function (_self, row, col, e)
58 var di = _this.grid.colModel.getDataIndex(col);
60 var rec = _this.grid.ds.getAt(row);
63 if (di == 'item_active') {
65 var nv = rec.data.item_active ? 0 : 1;
68 url : baseURL + '/Roo/Item',
70 item_id : rec.data.item_id,
73 success : function() {
74 rec.set('item_active', nv);
82 if(di == 'itemsrc_active'){
87 if(rec.data.itemsrc_active * 1){
88 Roo.MessageBox.confirm("Confirm", "Are you sure this product is no longer purchased",
97 Pman.Dialog.XtupleItem.show( { item_id : s.data.item_id } , function() {
98 _this.grid.footer.onClick('first');
103 _this.locgrid.footer.onClick('first');
109 afteredit : function (e)
115 url : baseURL +'/Roo/Charass',
117 charass_char_id_char_name : e.field.replace(/^item_char_/,'').toUpperCase(),
118 charass_value : e.value,
119 charass_target_type : 'I',
121 charass_target_id : e.record.data.item_id
132 celldblclick : function (_self, rowIndex, columnIndex, e)
134 var s = _this.grid.ds.getAt(rowIndex);
136 Pman.Dialog.XtupleItem.show( { item_id : s.data.item_id } , function() {
137 _this.grid.footer.onClick('first');
141 autoExpandColumn : 'item_descrip1',
148 beforeload : function (_self, o)
150 o.params._with_prodcat = 1;
151 o.params._with_char = 1;
152 o.params._with_itemsrc_active = 1;
153 o.params._with_last_purchase_price = 1;
154 o.params._with_image = 1;
155 var s = _this.search.getValue();
157 o.params['query[number_or_name]'] = s;
159 if (!_this.active.pressed) {
160 o.params.item_active = 1;
162 if (_this.brandSel.getValue().length) {
163 o.params._with_brand = _this.brandSel.getValue()
166 o.params._with_stock_balance = 1;
168 update : function (_self, record, operation)
170 if(operation != 'commit'){
174 var nv = record.data.itemsrc_active ? 0 : 1;
177 url : baseURL + '/Roo/Itemsrc',
180 item_id : record.data.item_id,
183 success : function(res) {
184 record.set('itemsrc_active', nv);
188 load : function (_self, records, options)
191 var cm = _this.grid.getColumnModel();
193 cm.setColumnHeader(cm.getIndexByDataIndex('item_stock_balance'),records[0].data.default_location_name);
198 sortInfo : { field : 'item_number', direction: 'ASC' },
203 url : baseURL + '/Roo/item.php'
208 totalProperty : 'total',
217 'name': 'item_number',
221 'name': 'item_descrip1',
225 'name': 'item_descrip2',
229 'name': 'item_classcode_id',
233 'name': 'item_picklist',
237 'name': 'item_comments',
245 'name': 'item_fractional',
249 'name': 'item_active',
257 'name': 'item_prodweight',
261 'name': 'item_packweight',
265 'name': 'item_prodcat_id',
269 'name': 'item_exclusive',
273 'name': 'item_listprice',
277 'name': 'item_config',
281 'name': 'item_extdescrip',
285 'name': 'item_upccode',
289 'name': 'item_maxcost',
293 'name': 'item_inv_uom_id',
297 'name': 'item_price_uom_id',
301 'name': 'item_warrdays',
305 'name': 'item_freightclass_id',
309 'name': 'item_tax_recoverable',
313 'name': 'item_price_uom_id_uom_id',
317 'name': 'item_price_uom_id_uom_name',
321 'name': 'item_price_uom_id_uom_descrip',
325 'name': 'item_price_uom_id_uom_item_weight',
329 'name': 'item_inv_uom_id_uom_id',
333 'name': 'item_inv_uom_id_uom_name',
337 'name': 'item_inv_uom_id_uom_descrip',
341 'name': 'item_inv_uom_id_uom_item_weight',
345 'name': 'item_freightclass_id_freightclass_id',
349 'name': 'item_freightclass_id_freightclass_code',
353 'name': 'item_freightclass_id_freightclass_descrip',
357 'name': 'item_classcode_id_classcode_id',
361 'name': 'item_classcode_id_classcode_code',
365 'name': 'item_classcode_id_classcode_descrip',
369 'name': 'item_classcode_id_classcode_mfg',
373 'name': 'item_classcode_id_classcode_creator',
377 'name': 'item_classcode_id_classcode_created',
381 'name': 'item_classcode_id_classcode_modifier',
385 'name': 'item_classcode_id_classcode_modified',
389 'name': 'item_classcode_id_classcode_type',
403 render : function (_self)
405 _this.brandSel = _self;
407 select : function (combo, record, index)
409 _this.grid.footer.onClick('first');
414 displayField : 'charass_value',
416 emptyText : "Select Brand",
417 forceSelection : true,
419 loadingText : "Searching...",
422 qtip : "Select Brand",
423 queryParam : 'query[charass_value]',
424 selectOnFocus : true,
425 tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
426 triggerAction : 'all',
432 beforeload : function (_self, o)
434 o.params = o.params || {};
435 // staff can see all logs, other companies can only see their own.
436 // look for all of the charass 's with the same type= eg. brand.
438 o.params.charass_char_id_char_name = 'BRAND';
439 o.params.charass_target_type ='I';
440 o.params._distinct = 'charass_value';
441 o.params._columns = 'charass_value';
446 sortInfo : { field : 'charass_value' , direction : 'ASC' },
451 url : baseURL + '/Roo/Charass.php'
456 totalProperty : 'total',
465 'name': 'person_name',
469 'name': 'event_when',
471 'dateFormat': 'Y-m-d'
498 'name': 'person_id_id',
502 'name': 'person_id_office_id',
506 'name': 'person_id_name',
510 'name': 'person_id_phone',
514 'name': 'person_id_fax',
518 'name': 'person_id_email',
522 'name': 'person_id_company_id',
526 'name': 'person_id_role',
530 'name': 'person_id_active',
534 'name': 'person_id_remarks',
538 'name': 'person_id_passwd',
542 'name': 'person_id_owner_id',
546 'name': 'person_id_lang',
550 'name': 'person_id_no_reset_sent',
554 'name': 'person_id_action_type',
558 'name': 'person_id_project_id',
562 'name': 'person_id_deleted_by',
566 'name': 'person_id_deleted_dt',
577 render : function (_self)
579 _this.search = _self;
581 specialkey : function (_self, e)
583 _this.grid.footer.onClick('first');
586 emptyText : "Search Product"
592 click : function (_self, e)
594 _this.grid.footer.onClick('first');
598 icon : rootURL + '/Pman/templates/images/search.gif'
604 click : function (_self, e)
606 _this.search.setValue('');
610 _this.grid.footer.onClick('first');
614 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
624 toggle : function (_self, pressed)
627 this.setText(pressed ? "Hide Inactive" : "Show Inactive");
628 (function() { _this.grid.footer.onClick('first'); }).defer(100);
630 render : function (_self)
632 _this.active = _self;
636 text : "Show Inactive"
649 Pman.Dialog.XtupleItem.show( { item_id : 0 } , function() {
650 _this.grid.footer.onClick('first');
654 cls : 'x-btn-text-icon',
656 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
664 var s = _this.grid.selModel.getSelectedCell();
666 Roo.MessageBox.alert("Error", "Select a product");
669 var rec = _this.grid.ds.getAt(s[0]);
673 Roo.MessageBox.prompt(
675 "Warning changing SKU names affects historical data, and should only be done if you are sure that this is ok",
683 item_id : rec.data.item_id,
696 var change = function(params){
698 url : baseURL + '/Roo/Item',
702 success : function(res) {
704 _this.grid.footer.onClick('refresh');
705 if(typeof(res.data) == 'string'){
706 Roo.MessageBox.alert("Notice", 'SKU has been renamed');
710 Roo.each(res.data, function(o){
711 offices.push(Pman.Xtuple.offices[o]);
713 Roo.MessageBox.alert("Notice", 'SKU has been renamed in ' + offices.join(", "));
716 failure : function(res) {
719 if (res.errors.confirm.length) {
721 Roo.each(res.errors.confirm, function(o){
722 offices.push(Pman.Xtuple.offices[o]);
724 Roo.MessageBox.confirm(
726 " Do you want to change the name in " + offices.join(", ") + "?",
729 Roo.MessageBox.alert("Notice", 'SKU was not changed');
732 delete params['_check'];
733 params._can_change_sku = 1;
740 Roo.MessageBox.alert("Error", res.errorMsg);
757 text : "Report start :"
763 render : function (_self)
765 _this.dateFrom = _self;
770 value : (function() { return (new Date()).format('Y') + '-01-01'; })()
776 render : function (_self)
778 _this.datespan = _self;
782 displayField : 'fname',
784 fieldLabel : 'Status',
785 hiddenName : 'cm_status',
788 name : 'cm_status_name',
789 triggerAction : 'all',
791 valueField : 'ftype',
794 xtype: 'SimpleStore',
797 [ '1', "Single Month Sales"],
798 [ '3', "Quarter Sales"],
799 [ '6', "Half year Sales"] ,
800 [ '12', "Full Year Sales"]
802 fields : [ 'ftype', 'fname']
809 click : function (_self, e)
811 if (!_this.brandSel.getValue().length) {
812 Roo.MessageBox.alert("Error", "Select a brand to download");
817 url : baseURL + '/Xtuple/Reports/SalesByCountryItemYear',
819 date_from : _this.dateFrom.getValue(),
820 brand : _this.brandSel.getValue(),
821 span : _this.datespan.getValue()
828 text : "Download Sales Report"
833 xtype: 'PagingToolbar',
837 displayMsg : "Displaying item{0} - {1} of {2}",
838 emptyMsg : "No item found",
843 text : "Tools - Upload/Download",
852 click : function (_self, e)
856 url : baseURL + '/Roo/item',
863 text : "Download Standard costs"
869 click : function (_self, e)
871 // Roo.MessageBox.alert("Disabled", "Can you please send Alan the test file for this - there is a problem and we need to fix it before you use this again");
874 Pman.Dialog.Image.show(
876 _url : baseURL+'/Xtuple/Import/Products',
884 msg.push("Updated " + data.updated + " Products(s)");
887 msg.push("Added " + data.inserted + " Products(s)");
890 msg.push("Skipped " + data.skipped);
894 msg.push("No data changed");
896 Roo.MessageBox.alert("Notice", msg.join("\n"));
902 text : "Upload new products and costs"
912 click : function (_self, e)
914 Roo.MessageBox.progress ("Syncing Stock", "Sending");
921 url : baseURL+'/Roo/Item',
928 success : function(res) {
930 if (!res.data.total) {
931 Roo.MessageBox.hide();
934 offset += res.data.limit;
935 Roo.MessageBox.updateProgress ( offset / res.data.total, "Done " + offset + '/' + res.data.total);
945 text : "Sync Product Data from HK",
946 hidden : (function() {
948 return baseURL.match(/hk\.php$/) ? true : false;
955 click : function (_self, e)
957 Roo.MessageBox.progress ("Syncing Stock", "Sending");
964 url : baseURL+'/Roo/Item',
970 success : function(res) {
973 Roo.MessageBox.hide();
974 _this.grid.footer.onClick('refresh');
984 text : "Sync Product from HK (New Products Only)",
985 hidden : (function() {
987 return baseURL.match(/hk\.php$/) ? true : false;
994 click : function (_self, e)
996 Roo.MessageBox.progress ("Syncing Stock", "Sending");
1003 url : baseURL+'/Roo/Item',
1007 item_number : _this.search.getValue()
1009 success : function(res) {
1012 Roo.MessageBox.hide();
1013 _this.grid.footer.onClick('refresh');
1023 text : "Sync Product from HK (Based on Search)",
1024 hidden : (function() {
1026 return baseURL.match(/hk\.php$/) ? true : false;
1036 xtype: 'ColumnModel',
1038 dataIndex : 'item_image_id',
1042 renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/50/{1}/{2}" height="50">', baseURL, v, r.data.item_image_filename); }
1045 xtype: 'ColumnModel',
1047 dataIndex : 'item_char_brand',
1051 renderer : function(v) { return String.format('{0}', v); },
1053 xtype: 'GridEditor',
1060 displayField : 'charass_value',
1062 forceSelection : false,
1064 loadingText : "Searching...",
1067 qtip : "Select Brand",
1068 queryParam : 'query[charass_value]',
1069 selectOnFocus : true,
1070 tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
1071 triggerAction : 'all',
1077 beforeload : function (_self, o)
1079 o.params = o.params || {};
1080 // staff can see all logs, other companies can only see their own.
1081 // look for all of the charass 's with the same type= eg. brand.
1083 o.params.charass_char_id_char_name = 'BRAND';
1084 o.params.charass_target_type ='I';
1085 o.params._distinct = 'charass_value';
1086 o.params._columns = 'charass_value';
1091 sortInfo : { field : 'charass_value' , direction : 'ASC' },
1096 url : baseURL + '/Roo/Charass.php'
1099 xtype: 'JsonReader',
1101 totalProperty : 'total',
1110 'name': 'person_name',
1114 'name': 'event_when',
1116 'dateFormat': 'Y-m-d'
1135 'name': 'person_id',
1143 'name': 'person_id_id',
1147 'name': 'person_id_office_id',
1151 'name': 'person_id_name',
1155 'name': 'person_id_phone',
1159 'name': 'person_id_fax',
1163 'name': 'person_id_email',
1167 'name': 'person_id_company_id',
1171 'name': 'person_id_role',
1175 'name': 'person_id_active',
1179 'name': 'person_id_remarks',
1183 'name': 'person_id_passwd',
1187 'name': 'person_id_owner_id',
1191 'name': 'person_id_lang',
1195 'name': 'person_id_no_reset_sent',
1199 'name': 'person_id_action_type',
1203 'name': 'person_id_project_id',
1207 'name': 'person_id_deleted_by',
1211 'name': 'person_id_deleted_dt',
1221 xtype: 'ColumnModel',
1223 dataIndex : 'item_char_productgroup',
1224 header : 'Product Group',
1227 renderer : function(v) { return String.format('{0}', v); },
1229 xtype: 'GridEditor',
1236 displayField : 'charass_value',
1238 forceSelection : false,
1240 loadingText : "Searching...",
1243 qtip : "Select Brand",
1244 queryParam : 'query[charass_value]',
1245 selectOnFocus : true,
1246 tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
1247 triggerAction : 'all',
1253 beforeload : function (_self, o)
1255 o.params = o.params || {};
1256 // staff can see all logs, other companies can only see their own.
1257 // look for all of the charass 's with the same type= eg. brand.
1259 o.params.charass_char_id_char_name = 'PRODUCTGROUP';
1260 o.params.charass_target_type ='I';
1261 o.params._distinct = 'charass_value';
1262 o.params._columns = 'charass_value';
1266 sortInfo : { field : 'charass_value' , direction : 'ASC' },
1271 url : baseURL + '/Roo/Charass.php'
1274 xtype: 'JsonReader',
1276 totalProperty : 'total',
1285 'name': 'person_name',
1289 'name': 'event_when',
1291 'dateFormat': 'Y-m-d'
1310 'name': 'person_id',
1318 'name': 'person_id_id',
1322 'name': 'person_id_office_id',
1326 'name': 'person_id_name',
1330 'name': 'person_id_phone',
1334 'name': 'person_id_fax',
1338 'name': 'person_id_email',
1342 'name': 'person_id_company_id',
1346 'name': 'person_id_role',
1350 'name': 'person_id_active',
1354 'name': 'person_id_remarks',
1358 'name': 'person_id_passwd',
1362 'name': 'person_id_owner_id',
1366 'name': 'person_id_lang',
1370 'name': 'person_id_no_reset_sent',
1374 'name': 'person_id_action_type',
1378 'name': 'person_id_project_id',
1382 'name': 'person_id_deleted_by',
1386 'name': 'person_id_deleted_dt',
1396 xtype: 'ColumnModel',
1398 dataIndex : 'item_number',
1402 renderer : function(v) { return String.format('<B>{0}</B>', v); }
1405 xtype: 'ColumnModel',
1407 dataIndex : 'item_char_pickface_location',
1408 header : 'Pickface',
1411 renderer : function(v) { return String.format('{0}', v); },
1413 xtype: 'GridEditor',
1422 xtype: 'ColumnModel',
1424 dataIndex : 'item_char_pallet_location',
1428 renderer : function(v) { return String.format('{0}', v); },
1430 xtype: 'GridEditor',
1439 xtype: 'ColumnModel',
1441 dataIndex : 'item_descrip1',
1442 header : 'Description',
1445 renderer : function(v) { return String.format('{0}', v); }
1448 xtype: 'ColumnModel',
1450 dataIndex : 'itemsrc_active',
1451 header : 'Purchased',
1454 renderer : function(v) {
1455 var state = v * 1 > 0 ? '-checked' : '';
1457 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1462 xtype: 'ColumnModel',
1464 dataIndex : 'item_sold',
1465 header : 'is Sold?',
1468 renderer : function(v) {
1469 var state = v * 1 > 0 ? '-checked' : '';
1471 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1476 xtype: 'ColumnModel',
1478 dataIndex : 'item_active',
1479 header : 'is Active?',
1482 renderer : function(v) {
1483 var state = v * 1 > 0 ? '-checked' : '';
1485 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1490 xtype: 'ColumnModel',
1493 dataIndex : 'last_purchase_price',
1494 header : 'Last purchase price',
1496 renderer : function(v,x,r) {
1498 return String.format('{0}{1}', r.data.last_purchase_price_curr_name, Roo.util.Format.number(v,2)) ;
1503 xtype: 'ColumnModel',
1505 dataIndex : 'item_prodcat_id_prodcat_code',
1506 header : 'Item prodcat',
1508 renderer : function(v,x,r) {
1509 return String.format('{0}/{1}', r.data.item_type, v);
1513 xtype: 'ColumnModel',
1516 dataIndex : 'item_actcost',
1519 renderer : function(v,x,r) {
1521 return String.format('{0}{1}', r.data.item_curr_name, Roo.util.Format.number(v,2)) ;
1526 xtype: 'ColumnModel',
1529 dataIndex : 'item_base_cost',
1530 header : 'Cost (base)',
1532 renderer : function(v,x,r) {
1534 return String.format('{0}{1}', r.data.item_base_curr, Roo.util.Format.number(v,2)) ;
1539 xtype: 'ColumnModel',
1542 dataIndex : 'item_stock_balance',
1545 renderer : function(v) { return String.format('{0}', v ? parseInt( v) : ''); }
1554 activate : function() {
1555 _this.locpanel = this;
1560 fitContainer : true,
1563 tableName : 'itemloc',
1571 _this.locgrid = this;
1572 //_this.dialog = Pman.Dialog.FILL_IN
1575 rowdblclick : function (_self, rowIndex, e)
1577 if (!_this.dialog) return;
1578 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
1579 _this.grid.footer.onClick('first');
1583 autoExpandColumn : 'location_name',
1589 beforeload : function (_self, o)
1591 var sel = _this.grid.selModel.getSelectedCell();
1596 var rec = _this.grid.ds.getAt(sel[0]);
1597 o.params._stock_for_item_id = rec.data.item_id;
1598 //o.params['!itemloc_qty'] = 0;
1604 sortInfo : { field : 'location_name', direction: 'ASC' },
1609 url : baseURL + '/Roo/location.php'
1612 xtype: 'JsonReader',
1614 totalProperty : 'total',
1619 'name': 'itemloc_id',
1623 'name': 'itemloc_itemsite_id',
1627 'name': 'itemloc_location_id',
1631 'name': 'itemloc_qty',
1635 'name': 'itemloc_expiration',
1637 'dateFormat': 'Y-m-d'
1640 'name': 'itemloc_consolflag',
1644 'name': 'itemloc_ls_id',
1648 'name': 'itemloc_warrpurc',
1650 'dateFormat': 'Y-m-d'
1656 xtype: 'PagingToolbar',
1660 displayMsg : "Displaying itemloc{0} - {1} of {2}",
1661 emptyMsg : "No itemloc found"
1665 xtype: 'ColumnModel',
1667 dataIndex : 'location_name',
1668 header : 'Location',
1670 renderer : function(v) { return String.format('{0}', v); }
1673 xtype: 'ColumnModel',
1675 dataIndex : 'itemloc_realqty',
1676 header : 'Itemloc qty',
1678 renderer : function(v) { return String.format('{0}', v*1 ? (v*1).toFixed(0) : ''); }
1685 xtype: 'LayoutRegion',
1689 xtype: 'LayoutRegion',