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 : '200-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);
62 if(di == 'item_image_filename'){
63 if(!rec.data.item_image_id){
67 if(rec.data.item_image_from_hk){
70 u = u.join('/') + '/hk.php';
73 url: u + '/Images/Download/' + rec.data.item_image_id + '/' + rec.data.item_image_filename
78 if (di == 'item_active') {
80 var nv = rec.data.item_active ? 0 : 1;
83 url : baseURL + '/Roo/Item',
85 item_id : rec.data.item_id,
88 success : function() {
89 rec.set('item_active', nv);
97 if(di == 'itemsrc_active'){
98 if(!rec.data.itemsrc_active){
99 Roo.MessageBox.alert('Error','Please edit it on Xtuple tool');
102 if(rec.data.itemsrc_active){
103 Roo.MessageBox.confirm("Confirm", "Are you sure this product is no longer purchased",
113 _this.locgrid.footer.onClick('first');
119 afteredit : function (e)
125 url : baseURL +'/Roo/Charass',
127 charass_char_id_char_name : e.field.replace(/^item_char_/,'').toUpperCase(),
128 charass_value : e.value,
129 charass_target_type : 'I',
131 charass_target_id : e.record.data.item_id
142 celldblclick : function (_self, rowIndex, columnIndex, e)
144 var s = _this.grid.ds.getAt(rowIndex);
146 Pman.Dialog.XtupleItem.show( { item_id : s.data.item_id } , function() {
147 _this.grid.footer.onClick('first');
151 autoExpandColumn : 'item_descrip1',
158 beforeload : function (_self, o)
160 o.params._with_prodcat = 1;
161 o.params._with_char = 1;
162 o.params._with_itemsrc_active = 1;
163 o.params._with_last_purchase_price = 1;
164 o.params._with_image = 1;
165 var s = _this.search.getValue();
167 o.params['query[number_or_name]'] = s;
169 if (!_this.active.pressed) {
170 o.params.item_active = 1;
172 if (_this.brandSel.getValue().length) {
173 o.params._with_brand = _this.brandSel.getValue()
176 o.params._with_stock_balance = 1;
178 update : function (_self, record, operation)
180 if(operation != 'commit'){
184 var nv = record.data.itemsrc_active ? 0 : 1;
187 url : baseURL + '/Roo/Itemsrc',
190 item_id : record.data.item_id,
193 success : function(res) {
194 record.set('itemsrc_active', nv);
198 load : function (_self, records, options)
201 var cm = _this.grid.getColumnModel();
203 cm.setColumnHeader(cm.getIndexByDataIndex('item_stock_balance'),records[0].data.default_location_name);
208 sortInfo : { field : 'item_number', direction: 'ASC' },
213 url : baseURL + '/Roo/item.php'
218 totalProperty : 'total',
227 'name': 'item_number',
231 'name': 'item_descrip1',
235 'name': 'item_descrip2',
239 'name': 'item_classcode_id',
243 'name': 'item_picklist',
247 'name': 'item_comments',
255 'name': 'item_fractional',
259 'name': 'item_active',
267 'name': 'item_prodweight',
271 'name': 'item_packweight',
275 'name': 'item_prodcat_id',
279 'name': 'item_exclusive',
283 'name': 'item_listprice',
287 'name': 'item_config',
291 'name': 'item_extdescrip',
295 'name': 'item_upccode',
299 'name': 'item_maxcost',
303 'name': 'item_inv_uom_id',
307 'name': 'item_price_uom_id',
311 'name': 'item_warrdays',
315 'name': 'item_freightclass_id',
319 'name': 'item_tax_recoverable',
323 'name': 'item_price_uom_id_uom_id',
327 'name': 'item_price_uom_id_uom_name',
331 'name': 'item_price_uom_id_uom_descrip',
335 'name': 'item_price_uom_id_uom_item_weight',
339 'name': 'item_inv_uom_id_uom_id',
343 'name': 'item_inv_uom_id_uom_name',
347 'name': 'item_inv_uom_id_uom_descrip',
351 'name': 'item_inv_uom_id_uom_item_weight',
355 'name': 'item_freightclass_id_freightclass_id',
359 'name': 'item_freightclass_id_freightclass_code',
363 'name': 'item_freightclass_id_freightclass_descrip',
367 'name': 'item_classcode_id_classcode_id',
371 'name': 'item_classcode_id_classcode_code',
375 'name': 'item_classcode_id_classcode_descrip',
379 'name': 'item_classcode_id_classcode_mfg',
383 'name': 'item_classcode_id_classcode_creator',
387 'name': 'item_classcode_id_classcode_created',
391 'name': 'item_classcode_id_classcode_modifier',
395 'name': 'item_classcode_id_classcode_modified',
399 'name': 'item_classcode_id_classcode_type',
413 render : function (_self)
415 _this.brandSel = _self;
417 select : function (combo, record, index)
419 _this.grid.footer.onClick('first');
424 displayField : 'charass_value',
426 emptyText : "Select Brand",
427 forceSelection : true,
429 loadingText : "Searching...",
432 qtip : "Select Brand",
433 queryParam : 'query[charass_value]',
434 selectOnFocus : true,
435 tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
436 triggerAction : 'all',
442 beforeload : function (_self, o)
444 o.params = o.params || {};
445 // staff can see all logs, other companies can only see their own.
446 // look for all of the charass 's with the same type= eg. brand.
448 o.params.charass_char_id_char_name = 'BRAND';
449 o.params.charass_target_type ='I';
450 o.params._distinct = 'charass_value';
451 o.params._columns = 'charass_value';
456 sortInfo : { field : 'charass_value' , direction : 'ASC' },
461 url : baseURL + '/Roo/Charass.php'
466 totalProperty : 'total',
475 'name': 'person_name',
479 'name': 'event_when',
481 'dateFormat': 'Y-m-d'
508 'name': 'person_id_id',
512 'name': 'person_id_office_id',
516 'name': 'person_id_name',
520 'name': 'person_id_phone',
524 'name': 'person_id_fax',
528 'name': 'person_id_email',
532 'name': 'person_id_company_id',
536 'name': 'person_id_role',
540 'name': 'person_id_active',
544 'name': 'person_id_remarks',
548 'name': 'person_id_passwd',
552 'name': 'person_id_owner_id',
556 'name': 'person_id_lang',
560 'name': 'person_id_no_reset_sent',
564 'name': 'person_id_action_type',
568 'name': 'person_id_project_id',
572 'name': 'person_id_deleted_by',
576 'name': 'person_id_deleted_dt',
587 render : function (_self)
589 _this.search = _self;
591 specialkey : function (_self, e)
593 _this.grid.footer.onClick('first');
596 emptyText : "Search Product"
602 click : function (_self, e)
604 _this.grid.footer.onClick('first');
608 icon : rootURL + '/Pman/templates/images/search.gif'
614 click : function (_self, e)
616 _this.search.setValue('');
620 _this.grid.footer.onClick('first');
624 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
634 toggle : function (_self, pressed)
637 this.setText(pressed ? "Hide Inactive" : "Show Inactive");
638 (function() { _this.grid.footer.onClick('first'); }).defer(100);
640 render : function (_self)
642 _this.active = _self;
646 text : "Show Inactive"
659 Pman.Dialog.XtupleItem.show( { item_id : 0 } , function() {
660 _this.grid.footer.onClick('first');
664 cls : 'x-btn-text-icon',
666 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
674 var s = _this.grid.selModel.getSelectedCell();
676 Roo.MessageBox.alert("Error", "Select a product");
679 var rec = _this.grid.ds.getAt(s[0]);
683 Roo.MessageBox.prompt(
685 "Warning changing SKU names affects historical data, and should only be done if you are sure that this is ok",
693 item_id : rec.data.item_id,
706 var change = function(params){
708 url : baseURL + '/Roo/Item',
712 success : function(res) {
714 _this.grid.footer.onClick('refresh');
715 if(typeof(res.data) == 'string'){
716 Roo.MessageBox.alert("Notice", 'SKU has been renamed');
720 Roo.each(res.data, function(o){
721 offices.push(Pman.Xtuple.offices[o]);
723 Roo.MessageBox.alert("Notice", 'SKU has been renamed in ' + offices.join(", "));
726 failure : function(res) {
729 if (res.errors.confirm.length) {
731 Roo.each(res.errors.confirm, function(o){
732 offices.push(Pman.Xtuple.offices[o]);
734 Roo.MessageBox.confirm(
736 " Do you want to change the name in " + offices.join(", ") + "?",
739 Roo.MessageBox.alert("Notice", 'SKU was not changed');
742 delete params['_check'];
743 params._can_change_sku = 1;
750 Roo.MessageBox.alert("Error", res.errorMsg);
767 text : "Report start :"
773 render : function (_self)
775 _this.dateFrom = _self;
780 value : (function() { return (new Date()).format('Y') + '-01-01'; })()
786 render : function (_self)
788 _this.datespan = _self;
792 displayField : 'fname',
794 fieldLabel : 'Status',
795 hiddenName : 'cm_status',
798 name : 'cm_status_name',
799 triggerAction : 'all',
801 valueField : 'ftype',
804 xtype: 'SimpleStore',
807 [ '1', "Single Month Sales"],
808 [ '3', "Quarter Sales"],
809 [ '6', "Half year Sales"] ,
810 [ '12', "Full Year Sales"]
812 fields : [ 'ftype', 'fname']
819 click : function (_self, e)
821 if (!_this.brandSel.getValue().length) {
822 Roo.MessageBox.alert("Error", "Select a brand to download");
827 url : baseURL + '/Xtuple/Reports/SalesByCountryItemYear',
829 date_from : _this.dateFrom.getValue(),
830 brand : _this.brandSel.getValue(),
831 span : _this.datespan.getValue()
838 text : "Download Sales Report"
843 xtype: 'PagingToolbar',
847 displayMsg : "Displaying item{0} - {1} of {2}",
848 emptyMsg : "No item found",
853 text : "Tools - Upload/Download",
862 click : function (_self, e)
866 url : baseURL + '/Roo/item',
873 text : "Download Standard costs"
879 click : function (_self, e)
881 // 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");
884 Pman.Dialog.Image.show(
886 _url : baseURL+'/Xtuple/Import/Products',
894 msg.push("Updated " + data.updated + " Products(s)");
897 msg.push("Added " + data.inserted + " Products(s)");
900 msg.push("Skipped " + data.skipped);
904 msg.push("No data changed");
906 Roo.MessageBox.alert("Notice", msg.join("\n"));
912 text : "Upload new products and costs"
922 click : function (_self, e)
924 Roo.MessageBox.progress ("Syncing Stock", "Sending");
931 url : baseURL+'/Roo/Item',
938 success : function(res) {
940 if (!res.data.total) {
941 Roo.MessageBox.hide();
944 offset += res.data.limit;
945 Roo.MessageBox.updateProgress ( offset / res.data.total, "Done " + offset + '/' + res.data.total);
955 text : "Sync Product Data from HK",
956 hidden : (function() {
958 return baseURL.match(/hk\.php$/) ? true : false;
965 click : function (_self, e)
967 Roo.MessageBox.progress ("Syncing Stock", "Sending");
974 url : baseURL+'/Roo/Item',
980 success : function(res) {
983 Roo.MessageBox.hide();
984 _this.grid.footer.onClick('refresh');
994 text : "Sync Product from HK (New Products Only)",
995 hidden : (function() {
997 return baseURL.match(/hk\.php$/) ? true : false;
1004 click : function (_self, e)
1006 Roo.MessageBox.progress ("Syncing Stock", "Sending");
1013 url : baseURL+'/Roo/Item',
1017 item_number : _this.search.getValue()
1019 success : function(res) {
1022 Roo.MessageBox.hide();
1023 _this.grid.footer.onClick('refresh');
1033 text : "Sync Product from HK (Based on Search)",
1034 hidden : (function() {
1036 return baseURL.match(/hk\.php$/) ? true : false;
1046 xtype: 'ColumnModel',
1048 dataIndex : 'item_image_id',
1049 header : 'Description',
1052 renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/100/{1}/{2}" height="100">', baseURL, v, r.data.item_image_filename); }
1055 xtype: 'ColumnModel',
1057 dataIndex : 'item_char_brand',
1061 renderer : function(v) { return String.format('{0}', v); },
1063 xtype: 'GridEditor',
1070 displayField : 'charass_value',
1072 forceSelection : false,
1074 loadingText : "Searching...",
1077 qtip : "Select Brand",
1078 queryParam : 'query[charass_value]',
1079 selectOnFocus : true,
1080 tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
1081 triggerAction : 'all',
1087 beforeload : function (_self, o)
1089 o.params = o.params || {};
1090 // staff can see all logs, other companies can only see their own.
1091 // look for all of the charass 's with the same type= eg. brand.
1093 o.params.charass_char_id_char_name = 'BRAND';
1094 o.params.charass_target_type ='I';
1095 o.params._distinct = 'charass_value';
1096 o.params._columns = 'charass_value';
1101 sortInfo : { field : 'charass_value' , direction : 'ASC' },
1106 url : baseURL + '/Roo/Charass.php'
1109 xtype: 'JsonReader',
1111 totalProperty : 'total',
1120 'name': 'person_name',
1124 'name': 'event_when',
1126 'dateFormat': 'Y-m-d'
1145 'name': 'person_id',
1153 'name': 'person_id_id',
1157 'name': 'person_id_office_id',
1161 'name': 'person_id_name',
1165 'name': 'person_id_phone',
1169 'name': 'person_id_fax',
1173 'name': 'person_id_email',
1177 'name': 'person_id_company_id',
1181 'name': 'person_id_role',
1185 'name': 'person_id_active',
1189 'name': 'person_id_remarks',
1193 'name': 'person_id_passwd',
1197 'name': 'person_id_owner_id',
1201 'name': 'person_id_lang',
1205 'name': 'person_id_no_reset_sent',
1209 'name': 'person_id_action_type',
1213 'name': 'person_id_project_id',
1217 'name': 'person_id_deleted_by',
1221 'name': 'person_id_deleted_dt',
1231 xtype: 'ColumnModel',
1233 dataIndex : 'item_char_productgroup',
1234 header : 'Product Group',
1237 renderer : function(v) { return String.format('{0}', v); },
1239 xtype: 'GridEditor',
1246 displayField : 'charass_value',
1248 forceSelection : false,
1250 loadingText : "Searching...",
1253 qtip : "Select Brand",
1254 queryParam : 'query[charass_value]',
1255 selectOnFocus : true,
1256 tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
1257 triggerAction : 'all',
1263 beforeload : function (_self, o)
1265 o.params = o.params || {};
1266 // staff can see all logs, other companies can only see their own.
1267 // look for all of the charass 's with the same type= eg. brand.
1269 o.params.charass_char_id_char_name = 'PRODUCTGROUP';
1270 o.params.charass_target_type ='I';
1271 o.params._distinct = 'charass_value';
1272 o.params._columns = 'charass_value';
1276 sortInfo : { field : 'charass_value' , direction : 'ASC' },
1281 url : baseURL + '/Roo/Charass.php'
1284 xtype: 'JsonReader',
1286 totalProperty : 'total',
1295 'name': 'person_name',
1299 'name': 'event_when',
1301 'dateFormat': 'Y-m-d'
1320 'name': 'person_id',
1328 'name': 'person_id_id',
1332 'name': 'person_id_office_id',
1336 'name': 'person_id_name',
1340 'name': 'person_id_phone',
1344 'name': 'person_id_fax',
1348 'name': 'person_id_email',
1352 'name': 'person_id_company_id',
1356 'name': 'person_id_role',
1360 'name': 'person_id_active',
1364 'name': 'person_id_remarks',
1368 'name': 'person_id_passwd',
1372 'name': 'person_id_owner_id',
1376 'name': 'person_id_lang',
1380 'name': 'person_id_no_reset_sent',
1384 'name': 'person_id_action_type',
1388 'name': 'person_id_project_id',
1392 'name': 'person_id_deleted_by',
1396 'name': 'person_id_deleted_dt',
1406 xtype: 'ColumnModel',
1408 dataIndex : 'item_number',
1412 renderer : function(v) { return String.format('<B>{0}</B>', v); }
1415 xtype: 'ColumnModel',
1417 dataIndex : 'item_char_pickface_location',
1418 header : 'Pickface',
1421 renderer : function(v) { return String.format('{0}', v); },
1423 xtype: 'GridEditor',
1432 xtype: 'ColumnModel',
1434 dataIndex : 'item_char_pallet_location',
1438 renderer : function(v) { return String.format('{0}', v); },
1440 xtype: 'GridEditor',
1449 xtype: 'ColumnModel',
1451 dataIndex : 'item_descrip1',
1452 header : 'Description',
1455 renderer : function(v) { return String.format('{0}', v); }
1458 xtype: 'ColumnModel',
1460 dataIndex : 'itemsrc_active',
1461 header : 'Purchased',
1463 renderer : function(v) {
1464 var state = v * 1 > 0 ? '-checked' : '';
1466 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1471 xtype: 'ColumnModel',
1473 dataIndex : 'item_sold',
1474 header : 'is Sold?',
1476 renderer : function(v) {
1477 var state = v * 1 > 0 ? '-checked' : '';
1479 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1484 xtype: 'ColumnModel',
1486 dataIndex : 'item_active',
1487 header : 'is Active?',
1489 renderer : function(v) {
1490 var state = v * 1 > 0 ? '-checked' : '';
1492 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1497 xtype: 'ColumnModel',
1500 dataIndex : 'last_purchase_price',
1501 header : 'Last purchase price',
1503 renderer : function(v,x,r) {
1505 return String.format('{0}{1}', r.data.last_purchase_price_curr_name, Roo.util.Format.number(v,2)) ;
1510 xtype: 'ColumnModel',
1512 dataIndex : 'item_prodcat_id_prodcat_code',
1513 header : 'Item prodcat',
1515 renderer : function(v,x,r) {
1516 return String.format('{0}/{1}', r.data.item_type, v);
1520 xtype: 'ColumnModel',
1523 dataIndex : 'item_actcost',
1526 renderer : function(v,x,r) {
1528 return String.format('{0}{1}', r.data.item_curr_name, Roo.util.Format.number(v,2)) ;
1533 xtype: 'ColumnModel',
1536 dataIndex : 'item_base_cost',
1537 header : 'Cost (base)',
1539 renderer : function(v,x,r) {
1541 return String.format('{0}{1}', r.data.item_base_curr, Roo.util.Format.number(v,2)) ;
1546 xtype: 'ColumnModel',
1549 dataIndex : 'item_stock_balance',
1552 renderer : function(v) { return String.format('{0}', v ? parseInt( v) : ''); }
1561 activate : function() {
1562 _this.locpanel = this;
1567 fitContainer : true,
1570 tableName : 'itemloc',
1578 _this.locgrid = this;
1579 //_this.dialog = Pman.Dialog.FILL_IN
1582 rowdblclick : function (_self, rowIndex, e)
1584 if (!_this.dialog) return;
1585 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
1586 _this.grid.footer.onClick('first');
1590 autoExpandColumn : 'location_name',
1596 beforeload : function (_self, o)
1598 var sel = _this.grid.selModel.getSelectedCell();
1603 var rec = _this.grid.ds.getAt(sel[0]);
1604 o.params._stock_for_item_id = rec.data.item_id;
1605 //o.params['!itemloc_qty'] = 0;
1611 sortInfo : { field : 'location_name', direction: 'ASC' },
1616 url : baseURL + '/Roo/location.php'
1619 xtype: 'JsonReader',
1621 totalProperty : 'total',
1626 'name': 'itemloc_id',
1630 'name': 'itemloc_itemsite_id',
1634 'name': 'itemloc_location_id',
1638 'name': 'itemloc_qty',
1642 'name': 'itemloc_expiration',
1644 'dateFormat': 'Y-m-d'
1647 'name': 'itemloc_consolflag',
1651 'name': 'itemloc_ls_id',
1655 'name': 'itemloc_warrpurc',
1657 'dateFormat': 'Y-m-d'
1663 xtype: 'PagingToolbar',
1667 displayMsg : "Displaying itemloc{0} - {1} of {2}",
1668 emptyMsg : "No itemloc found"
1672 xtype: 'ColumnModel',
1674 dataIndex : 'location_name',
1675 header : 'Location',
1677 renderer : function(v) { return String.format('{0}', v); }
1680 xtype: 'ColumnModel',
1682 dataIndex : 'itemloc_realqty',
1683 header : 'Itemloc qty',
1685 renderer : function(v) { return String.format('{0}', v*1 ? (v*1).toFixed(0) : ''); }
1692 xtype: 'LayoutRegion',
1696 xtype: 'LayoutRegion',