1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.XtupleAdjustment = new Roo.XComponent({
6 part : ["Xtuple","Adjustment"],
7 order : '100-Pman.Tab.XtupleAdjustment',
9 parent : 'Pman.Tab.XtupleAdjustmentTab',
10 name : "Pman.Tab.XtupleAdjustment",
21 activate : function() {
24 _this.grid.footer.onClick('first');
33 title : "Inventory Adjustments",
41 //_this.dialog = Pman.Dialog.FILL_IN
42 if (_this.panel.active) {
43 this.footer.onClick('first');
46 afteredit : function (e)
48 if (e.record.data.invadj_posted) {
51 var req = [ 'invadj_transdate', 'invadj_location_id', 'invadj_itemsite_id',
52 'invadj_qty_by', 'invadj_comments' ];
54 Roo.each(req, function(c) {
55 var val = '' + e.record.get(c);
68 validateedit : function (e)
71 case 'invadj_transdate':
72 // e.record.setValue('invadj_transdate', Date.parseDate(e.value, 'Y-m-d'));
73 e.value = Date.parseDate(e.value, 'Y-m-d');
77 beforeedit : function (e)
80 if (e.record.data.invadj_posted) {
86 cellclick : function (_self, rowIndex, columnIndex, e)
88 var c = _this.grid.colModel.config[columnIndex];
90 if (di != 'invadj_posted') {
94 var r = _this.grid.ds.getAt(rowIndex);
95 if (r.data.invadj_posted || !r.data.invadj_id) {
98 // attempting to post..
99 // validation - done at other end..
101 url : baseURL + '/Roo/Invadj',
105 invadj_id : r.data.invadj_id,
108 success : function(res) {
109 r.set('invadj_posted', true);
110 if (r.data.invadj_voids_id > 0) {
111 _this.grid.ds.each(function(rr) {
112 if (rr.data.invadj_id == r.data.invadj_voids_id) {
113 rr.set('invadj_voided_by_id', r.data.invadj_id);
114 rr.set('invadj_comments', rr.data.invadj_comments);
124 failure : function (res) {
126 Roo.MessageBox.alert("Error",res.errorMsg);
127 if (res.errors.trandate) {
128 r.set('invadj_transdate', Date.parseDate(res.errors.trandate,'Y-m-d'));
140 autoExpandColumn : 'invadj_comments',
144 xtype: 'CellSelectionModel',
147 tabend : function (eventdata)
149 _this.addBtn.fireEvent('click', this);
158 beforeload : function (_self, options)
160 options.params.invadj_location_id = _this.locationCombo.getValue();
161 options.params.invadj_itemsite_id = _this.itemCombo.getValue();
162 switch(_this.status.getValue()) {
167 options.params._show_void = 2;
171 options.params._show_void = 1;
177 options.params.invadj_posted = 1;
181 options.params.invadj_posted = 0;
185 options.params._hide_group = 1;
188 case 'ALL-NOGROUP-WITHVOID':
189 options.params._show_void = 2;
193 options.params._show_void = 1;
194 options.params._hide_group = 1;
197 case 'POSTED-NOGROUP':
198 options.params.invadj_posted = 1;
199 options.params._hide_group = 1;
202 case 'UNPOSTED-NOGROUP':
203 options.params._hide_group = 1;
204 options.params.invadj_posted = 0;
209 options.params['query[comment]'] = _this.search.getValue();
211 update : function (_self, record, operation)
215 if (operation != 'commit' || _this.incom) {
220 var p = Roo.apply({}, record.data);
222 if (p.invadj_posted) {
225 p.invadj_transdate = record.data.invadj_transdate.format('Y-m-d');
230 url : baseURL + '/Roo/Invadj',
234 success : function(res) {
235 record.set('invadj_id', res.data.invadj_id);
240 Roo.MessageBox.alert("Error", "Saving failed");
251 sortInfo : { field : 'invadj_id', direction: 'DESC' },
256 url : baseURL + '/Roo/invadj.php'
261 totalProperty : 'total',
270 'name': 'invadj_transdate',
272 'dateFormat': 'Y-m-d'
275 'name': 'invadj_location_id',
279 'name': 'invadj_itemsite_id',
283 'name': 'invadj_qty_by',
287 'name': 'invadj_posted',
294 xtype: 'PagingToolbar',
298 displayMsg : "Displaying invadj{0} - {1} of {2}",
299 emptyMsg : "No invadj found"
309 render : function (_self)
311 _this.locationCombo = _self;
313 select : function (combo, record, index)
316 _this.grid.footer.onClick('first');
320 displayField : 'location_name',
322 emptyText : "Select location",
323 fieldLabel : 'location',
324 forceSelection : true,
325 hiddenName : 'invadj_location_id',
327 loadingText : "Searching...",
329 name : 'invadj_location_id_location_name',
331 qtip : "Select location",
332 queryParam : 'query[location_name]',
333 selectOnFocus : true,
334 tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> </div>',
335 triggerAction : 'all',
337 valueField : 'location_id',
343 beforeload : function (_self, o){
344 o.params = o.params || {};
349 sortInfo : { direction : 'ASC', field: 'location_name' },
354 url : baseURL + '/Roo/location.php'
361 totalProperty : 'total',
362 fields : [{"name":"id","type":"int"},{"name":"location_name","type":"string"}]
370 render : function (_self)
372 _this.itemCombo = _self;
374 select : function (combo, record, index)
377 _this.grid.footer.onClick('first');
381 displayField : 'itemsite_item_id_item_number',
383 emptyText : "Select itemsite",
384 fieldLabel : 'itemsite',
385 forceSelection : true,
386 hiddenName : 'invadj_itemsite_id',
388 loadingText : "Searching...",
390 name : 'invadj_itemsite_id_item_number',
392 qtip : "Select itemsite",
393 queryParam : 'query[number]',
394 selectOnFocus : true,
395 tpl : '<div class="x-grid-cell-text x-btn button"><b>{itemsite_item_id_item_number}</b> </div>',
396 triggerAction : 'all',
398 valueField : 'itemsite_id',
404 beforeload : function (_self, o){
405 o.params = o.params || {};
410 sortInfo : { direction : 'ASC', field: 'itemsite_item_id_item_number' },
415 url : baseURL + '/Roo/itemsite.php'
422 totalProperty : 'total',
423 fields : [{"name":"id","type":"int"},{"name":"itemsite_abcclass","type":"string"}]
431 render : function (_self)
433 _this.status = _self;
435 select : function (combo, record, index)
438 _this.grid.footer.onClick('first');
442 displayField : 'fname',
444 fieldLabel : 'Status',
445 hiddenName : 'cm_status',
448 name : 'cm_status_name',
449 triggerAction : 'all',
450 value : "ALL-NOGROUP",
451 valueField : 'ftype',
454 xtype: 'SimpleStore',
457 [ 'ALL-NOGROUP', "All (not in Group)"],
458 [ 'ALL-NOGROUP WITHVOID', "All (not in Group) (with Void)"],
459 [ 'UNPOSTED-NOGROUP', "Unposted only (not in Group)"] ,
460 [ 'POSTED-NOGROUP', "Posted only (not in Group)"] ,
461 [ 'VOID-NOGROUP' ,"Void (not in Group)"],
463 [ 'ALL-WITHVOID', "All (with Void)"],
464 [ 'UNPOSTED', "Unposted only"] ,
465 [ 'POSTED', "Posted only"] ,
466 [ 'VOID', "Void only"]
469 fields : [ 'ftype', 'fname']
476 specialkey : function (_self, e)
478 _this.grid.footer.onClick('first');
480 render : function (_self)
482 _this.search = _self;
491 click : function (_self, e)
493 _this.grid.footer.onClick('first');
497 icon : rootURL + '/Pman/templates/images/search.gif'
503 click : function (_self, e)
505 _this.locationCombo.reset();
506 _this.itemCombo.reset();
508 _this.grid.footer.onClick('first');
512 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
530 cls : 'x-btn-text-icon',
531 text : "Download Excel",
532 icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
541 Roo.log("add presed");
544 var grid = _this.grid;
546 // uses form defaults or last row value.
547 var nr = _this.grid.ds.reader.newRow({
549 invadj_transdate : (new Date()),
550 invadj_location_id : 0,
551 invadj_location_id_location_name : '',
552 invadj_itemsite_id : 0,
553 invadj_itemsite_id_item_number : '',
560 grid.ds.insert(0, nr);
561 grid.startEditing(0, 1); // type..
564 render : function (_self)
566 _this.addBtn = _self;
569 cls : 'x-btn-text-icon',
571 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
580 Roo.log("add presed");
582 var grid = _this.grid;
583 var r = grid.selModel.getSelectedCell();
587 Roo.MessageBox.alert("Error", "Select an adjustment");
590 var rec = grid.ds.getAt(r[0]);
592 var nrec = Roo.apply({}, rec.data);
593 nrec.invadj_qty_by *= -1;
594 nrec.invadj_comments = (rec.data.invadj_voids_id * 1 > 1) ? 'Restore of Adjustment #' + rec.data.invadj_voids_id : 'Void of Adjustment #' + rec.data.invadj_id;
595 nrec.invadj_posted = 0;
597 nrec.invadj_invdetail_id = '';
598 nrec.invadj_voids_id = rec.data.invadj_id;
599 //nrec.invadj_transdate = rec.data.invadj_transdate.format('Y-m-d');
601 var nr = _this.grid.ds.reader.newRow(nrec);
603 grid.ds.insert(r[0], nr);
605 grid.ds.getAt(r[0]).commit();
610 cls : 'x-btn-text-icon',
612 icon : rootURL + '/Pman/templates/images/trash.gif'
622 var s = g.selModel.getSelectedCell();
624 Roo.MessageBox.alert("Error", "Select Adjustment");
627 var r = g.ds.getAt(s[0]);
628 if (r.data.invadj_posted) {
629 Roo.MessageBox.alert("Error", "You can not delete posted adjustments - try voiding them");
633 url : baseURL + '/Roo/Invadj',
635 params : { _delete : r.data.invadj_id },
637 success : function(res) {
646 cls : 'x-btn-text-icon',
648 icon : rootURL + '/Pman/templates/images/trash.gif'
654 xtype: 'ColumnModel',
656 dataIndex : 'invadj_id',
660 renderer : function(v) { return String.format('{0}', v); }
663 xtype: 'ColumnModel',
665 dataIndex : 'invadj_transdate',
669 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
682 xtype: 'ColumnModel',
684 dataIndex : 'invadj_location_id',
687 renderer : function(v,x,r) {
689 return String.format('{0}',
690 r.data.invadj_location_id_location_name
700 displayField : 'location_name',
702 emptyText : "Select location",
703 fieldLabel : 'location',
704 forceSelection : true,
705 hiddenName : 'invadj_location_id',
707 loadingText : "Searching...",
709 name : 'invadj_location_id_location_name',
711 qtip : "Select location",
712 queryParam : 'query[location_name]',
713 selectOnFocus : true,
714 tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> </div>',
715 triggerAction : 'all',
717 valueField : 'location_id',
723 beforeload : function (_self, o){
724 o.params = o.params || {};
729 sortInfo : { direction : 'ASC', field: 'location_name' },
734 url : baseURL + '/Roo/location.php'
741 totalProperty : 'total',
742 fields : [{"name":"id","type":"int"},{"name":"location_name","type":"string"}]
749 xtype: 'ColumnModel',
751 dataIndex : 'invadj_itemsite_id_item_number',
752 header : 'Item Number',
756 renderer : function(v) { return String.format('{0}', v); }
759 xtype: 'ColumnModel',
761 dataIndex : 'invadj_itemsite_id',
764 renderer : function(v,x,r) { return String.format('{0}', r.data.invadj_itemsite_id_item_number); },
772 displayField : 'itemsite_item_id_item_number',
774 emptyText : "Select itemsite",
775 fieldLabel : 'itemsite',
776 forceSelection : true,
777 hiddenName : 'invadj_itemsite_id',
779 loadingText : "Searching...",
781 name : 'invadj_itemsite_id_item_number',
783 qtip : "Select itemsite",
784 queryParam : 'query[number]',
785 selectOnFocus : true,
786 tpl : '<div class="x-grid-cell-text x-btn button"><b>{itemsite_item_id_item_number}</b> </div>',
787 triggerAction : 'all',
789 valueField : 'itemsite_id',
795 beforeload : function (_self, o){
796 o.params = o.params || {};
801 sortInfo : { direction : 'ASC', field: 'itemsite_item_id_item_number' },
806 url : baseURL + '/Roo/itemsite.php'
813 totalProperty : 'total',
814 fields : [{"name":"id","type":"int"},{"name":"itemsite_abcclass","type":"string"}]
821 xtype: 'ColumnModel',
824 dataIndex : 'invadj_qty_by',
825 header : 'Adjust By #',
827 renderer : function(v) { return String.format('{0}', v); },
832 xtype: 'NumberField',
834 allowDecimals : false,
840 xtype: 'ColumnModel',
842 dataIndex : 'invadj_comments',
845 renderer : function(v,x,r) {
846 return String.format(r.data.invfifo_void * 1 > 0 ? '<s style="color:#ccc">{0}</s>' : '{0}', v);
858 xtype: 'ColumnModel',
860 dataIndex : 'invadj_posted',
863 renderer : function(v) {
864 var state = v * 1 > 0 ? '-checked' : '';
866 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';