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;
182 options.params._show_void = 2;
186 options.params._hide_group = 1;
189 case 'ALL-NOGROUP-WITHVOID':
190 options.params._show_void = 2;
191 options.params._hide_group = 1;
195 options.params._show_void = 1;
196 options.params._hide_group = 1;
199 case 'POSTED-NOGROUP':
200 options.params.invadj_posted = 1;
201 options.params._hide_group = 1;
204 case 'UNPOSTED-NOGROUP':
205 options.params._hide_group = 1;
206 options.params.invadj_posted = 0;
207 options.params._show_void = 2;
212 options.params['query[comment]'] = _this.search.getValue();
214 update : function (_self, record, operation)
218 if (operation != 'commit' || _this.incom) {
223 var p = Roo.apply({}, record.data);
225 if (p.invadj_posted) {
228 p.invadj_transdate = record.data.invadj_transdate.format('Y-m-d');
233 url : baseURL + '/Roo/Invadj',
237 success : function(res) {
238 record.set('invadj_id', res.data.invadj_id);
243 Roo.MessageBox.alert("Error", "Saving failed");
254 sortInfo : { field : 'invadj_id', direction: 'DESC' },
259 url : baseURL + '/Roo/invadj.php'
264 totalProperty : 'total',
273 'name': 'invadj_transdate',
275 'dateFormat': 'Y-m-d'
278 'name': 'invadj_location_id',
282 'name': 'invadj_itemsite_id',
286 'name': 'invadj_qty_by',
290 'name': 'invadj_posted',
297 xtype: 'PagingToolbar',
301 displayMsg : "Displaying invadj{0} - {1} of {2}",
302 emptyMsg : "No invadj found"
312 render : function (_self)
314 _this.locationCombo = _self;
316 select : function (combo, record, index)
319 _this.grid.footer.onClick('first');
323 displayField : 'location_name',
325 emptyText : "Select location",
326 fieldLabel : 'location',
327 forceSelection : true,
328 hiddenName : 'invadj_location_id',
330 loadingText : "Searching...",
332 name : 'invadj_location_id_location_name',
334 qtip : "Select location",
335 queryParam : 'query[location_name]',
336 selectOnFocus : true,
337 tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> </div>',
338 triggerAction : 'all',
340 valueField : 'location_id',
346 beforeload : function (_self, o){
347 o.params = o.params || {};
352 sortInfo : { direction : 'ASC', field: 'location_name' },
357 url : baseURL + '/Roo/location.php'
364 totalProperty : 'total',
365 fields : [{"name":"id","type":"int"},{"name":"location_name","type":"string"}]
373 render : function (_self)
375 _this.itemCombo = _self;
377 select : function (combo, record, index)
380 _this.grid.footer.onClick('first');
384 displayField : 'itemsite_item_id_item_number',
386 emptyText : "Select itemsite",
387 fieldLabel : 'itemsite',
388 forceSelection : true,
389 hiddenName : 'invadj_itemsite_id',
391 loadingText : "Searching...",
393 name : 'invadj_itemsite_id_item_number',
395 qtip : "Select itemsite",
396 queryParam : 'query[number]',
397 selectOnFocus : true,
398 tpl : '<div class="x-grid-cell-text x-btn button"><b>{itemsite_item_id_item_number}</b> </div>',
399 triggerAction : 'all',
401 valueField : 'itemsite_id',
407 beforeload : function (_self, o){
408 o.params = o.params || {};
413 sortInfo : { direction : 'ASC', field: 'itemsite_item_id_item_number' },
418 url : baseURL + '/Roo/itemsite.php'
425 totalProperty : 'total',
426 fields : [{"name":"id","type":"int"},{"name":"itemsite_abcclass","type":"string"}]
434 render : function (_self)
436 _this.status = _self;
438 select : function (combo, record, index)
441 _this.grid.footer.onClick('first');
445 displayField : 'fname',
447 fieldLabel : 'Status',
448 hiddenName : 'cm_status',
451 name : 'cm_status_name',
452 triggerAction : 'all',
453 value : "ALL-NOGROUP",
454 valueField : 'ftype',
457 xtype: 'SimpleStore',
460 [ 'ALL-NOGROUP', "All (not in Group)"],
461 [ 'ALL-NOGROUP WITHVOID', "All (not in Group) (with Void)"],
462 [ 'UNPOSTED-NOGROUP', "Unposted only (not in Group)"] ,
463 [ 'POSTED-NOGROUP', "Posted only (not in Group)"] ,
464 [ 'VOID-NOGROUP' ,"Void (not in Group)"],
466 [ 'ALL-WITHVOID', "All (with Void)"],
467 [ 'UNPOSTED', "Unposted only"] ,
468 [ 'POSTED', "Posted only"] ,
469 [ 'VOID', "Void only"]
472 fields : [ 'ftype', 'fname']
479 specialkey : function (_self, e)
481 _this.grid.footer.onClick('first');
483 render : function (_self)
485 _this.search = _self;
494 click : function (_self, e)
496 _this.grid.footer.onClick('first');
500 icon : rootURL + '/Pman/templates/images/search.gif'
506 click : function (_self, e)
508 _this.locationCombo.reset();
509 _this.itemCombo.reset();
511 _this.grid.footer.onClick('first');
515 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
533 cls : 'x-btn-text-icon',
534 text : "Download Excel",
535 icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
544 Roo.log("add presed");
547 var grid = _this.grid;
549 // uses form defaults or last row value.
550 var nr = _this.grid.ds.reader.newRow({
552 invadj_transdate : (new Date()),
553 invadj_location_id : 0,
554 invadj_location_id_location_name : '',
555 invadj_itemsite_id : 0,
556 invadj_itemsite_id_item_number : '',
563 grid.ds.insert(0, nr);
564 grid.startEditing(0, 1); // type..
567 render : function (_self)
569 _this.addBtn = _self;
572 cls : 'x-btn-text-icon',
574 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
583 Roo.log("add presed");
585 var grid = _this.grid;
586 var r = grid.selModel.getSelectedCell();
590 Roo.MessageBox.alert("Error", "Select an adjustment");
593 var rec = grid.ds.getAt(r[0]);
595 var nrec = Roo.apply({}, rec.data);
596 nrec.invadj_qty_by *= -1;
597 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;
598 nrec.invadj_posted = 0;
600 nrec.invadj_invdetail_id = '';
601 nrec.invadj_voids_id = rec.data.invadj_id;
602 //nrec.invadj_transdate = rec.data.invadj_transdate.format('Y-m-d');
604 var nr = _this.grid.ds.reader.newRow(nrec);
606 grid.ds.insert(r[0], nr);
608 grid.ds.getAt(r[0]).commit();
613 cls : 'x-btn-text-icon',
615 icon : rootURL + '/Pman/templates/images/trash.gif'
625 var s = g.selModel.getSelectedCell();
627 Roo.MessageBox.alert("Error", "Select Adjustment");
630 var r = g.ds.getAt(s[0]);
631 if (r.data.invadj_posted) {
632 Roo.MessageBox.alert("Error", "You can not delete posted adjustments - try voiding them");
636 url : baseURL + '/Roo/Invadj',
638 params : { _delete : r.data.invadj_id },
640 success : function(res) {
649 cls : 'x-btn-text-icon',
651 icon : rootURL + '/Pman/templates/images/trash.gif'
657 xtype: 'ColumnModel',
659 dataIndex : 'invadj_id',
663 renderer : function(v) { return String.format('{0}', v); }
666 xtype: 'ColumnModel',
668 dataIndex : 'invadj_transdate',
672 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
685 xtype: 'ColumnModel',
687 dataIndex : 'invadj_location_id',
690 renderer : function(v,x,r) {
692 return String.format('{0}',
693 r.data.invadj_location_id_location_name
703 displayField : 'location_name',
705 emptyText : "Select location",
706 fieldLabel : 'location',
707 forceSelection : true,
708 hiddenName : 'invadj_location_id',
710 loadingText : "Searching...",
712 name : 'invadj_location_id_location_name',
714 qtip : "Select location",
715 queryParam : 'query[location_name]',
716 selectOnFocus : true,
717 tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> </div>',
718 triggerAction : 'all',
720 valueField : 'location_id',
726 beforeload : function (_self, o){
727 o.params = o.params || {};
732 sortInfo : { direction : 'ASC', field: 'location_name' },
737 url : baseURL + '/Roo/location.php'
744 totalProperty : 'total',
745 fields : [{"name":"id","type":"int"},{"name":"location_name","type":"string"}]
752 xtype: 'ColumnModel',
754 dataIndex : 'invadj_itemsite_id_item_number',
755 header : 'Item Number',
759 renderer : function(v) { return String.format('{0}', v); }
762 xtype: 'ColumnModel',
764 dataIndex : 'invadj_itemsite_id',
767 renderer : function(v,x,r) { return String.format('{0}', r.data.invadj_itemsite_id_item_number); },
775 displayField : 'itemsite_item_id_item_number',
777 emptyText : "Select itemsite",
778 fieldLabel : 'itemsite',
779 forceSelection : true,
780 hiddenName : 'invadj_itemsite_id',
782 loadingText : "Searching...",
784 name : 'invadj_itemsite_id_item_number',
786 qtip : "Select itemsite",
787 queryParam : 'query[number]',
788 selectOnFocus : true,
789 tpl : '<div class="x-grid-cell-text x-btn button"><b>{itemsite_item_id_item_number}</b> </div>',
790 triggerAction : 'all',
792 valueField : 'itemsite_id',
798 beforeload : function (_self, o){
799 o.params = o.params || {};
804 sortInfo : { direction : 'ASC', field: 'itemsite_item_id_item_number' },
809 url : baseURL + '/Roo/itemsite.php'
816 totalProperty : 'total',
817 fields : [{"name":"id","type":"int"},{"name":"itemsite_abcclass","type":"string"}]
824 xtype: 'ColumnModel',
827 dataIndex : 'invadj_qty_by',
828 header : 'Adjust By #',
830 renderer : function(v) { return String.format('{0}', v); },
835 xtype: 'NumberField',
837 allowDecimals : false,
843 xtype: 'ColumnModel',
845 dataIndex : 'invadj_comments',
848 renderer : function(v,x,r) {
849 return String.format(r.data.invfifo_void * 1 > 0 ? '<s style="color:#ccc">{0}</s>' : '{0}', v);
861 xtype: 'ColumnModel',
863 dataIndex : 'invadj_posted',
866 renderer : function(v) {
867 var state = v * 1 > 0 ? '-checked' : '';
869 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';