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 [ 'UNPOSTED-NOGROUP', "Unposted only (not in Group)"] ,
459 [ 'POSTED-NOGROUP', "Posted only (not in Group)"] ,
460 [ 'VOID-NOGROUP' ,"Void (not in Group)"],
462 [ 'UNPOSTED', "Unposted only"] ,
463 [ 'POSTED', "Posted only"] ,
464 [ 'VOID', "Void only"]
467 fields : [ 'ftype', 'fname']
474 specialkey : function (_self, e)
476 _this.grid.footer.onClick('first');
478 render : function (_self)
480 _this.search = _self;
489 click : function (_self, e)
491 _this.grid.footer.onClick('first');
495 icon : rootURL + '/Pman/templates/images/search.gif'
501 click : function (_self, e)
503 _this.locationCombo.reset();
504 _this.itemCombo.reset();
506 _this.grid.footer.onClick('first');
510 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
528 cls : 'x-btn-text-icon',
529 text : "Download Excel",
530 icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
539 Roo.log("add presed");
542 var grid = _this.grid;
544 // uses form defaults or last row value.
545 var nr = _this.grid.ds.reader.newRow({
547 invadj_transdate : (new Date()),
548 invadj_location_id : 0,
549 invadj_location_id_location_name : '',
550 invadj_itemsite_id : 0,
551 invadj_itemsite_id_item_number : '',
558 grid.ds.insert(0, nr);
559 grid.startEditing(0, 1); // type..
562 render : function (_self)
564 _this.addBtn = _self;
567 cls : 'x-btn-text-icon',
569 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
578 Roo.log("add presed");
580 var grid = _this.grid;
581 var r = grid.selModel.getSelectedCell();
585 Roo.MessageBox.alert("Error", "Select an adjustment");
588 var rec = grid.ds.getAt(r[0]);
590 var nrec = Roo.apply({}, rec.data);
591 nrec.invadj_qty_by *= -1;
592 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;
593 nrec.invadj_posted = 0;
595 nrec.invadj_invdetail_id = '';
596 nrec.invadj_voids_id = rec.data.invadj_id;
597 //nrec.invadj_transdate = rec.data.invadj_transdate.format('Y-m-d');
599 var nr = _this.grid.ds.reader.newRow(nrec);
601 grid.ds.insert(r[0], nr);
603 grid.ds.getAt(r[0]).commit();
608 cls : 'x-btn-text-icon',
610 icon : rootURL + '/Pman/templates/images/trash.gif'
620 var s = g.selModel.getSelectedCell();
622 Roo.MessageBox.alert("Error", "Select Adjustment");
625 var r = g.ds.getAt(s[0]);
626 if (r.data.invadj_posted) {
627 Roo.MessageBox.alert("Error", "You can not delete posted adjustments - try voiding them");
631 url : baseURL + '/Roo/Invadj',
633 params : { _delete : r.data.invadj_id },
635 success : function(res) {
644 cls : 'x-btn-text-icon',
646 icon : rootURL + '/Pman/templates/images/trash.gif'
652 xtype: 'ColumnModel',
654 dataIndex : 'invadj_id',
658 renderer : function(v) { return String.format('{0}', v); }
661 xtype: 'ColumnModel',
663 dataIndex : 'invadj_transdate',
667 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
680 xtype: 'ColumnModel',
682 dataIndex : 'invadj_location_id',
685 renderer : function(v,x,r) {
687 return String.format('{0}',
688 r.data.invadj_location_id_location_name
698 displayField : 'location_name',
700 emptyText : "Select location",
701 fieldLabel : 'location',
702 forceSelection : true,
703 hiddenName : 'invadj_location_id',
705 loadingText : "Searching...",
707 name : 'invadj_location_id_location_name',
709 qtip : "Select location",
710 queryParam : 'query[location_name]',
711 selectOnFocus : true,
712 tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> </div>',
713 triggerAction : 'all',
715 valueField : 'location_id',
721 beforeload : function (_self, o){
722 o.params = o.params || {};
727 sortInfo : { direction : 'ASC', field: 'location_name' },
732 url : baseURL + '/Roo/location.php'
739 totalProperty : 'total',
740 fields : [{"name":"id","type":"int"},{"name":"location_name","type":"string"}]
747 xtype: 'ColumnModel',
749 dataIndex : 'invadj_itemsite_id_item_number',
750 header : 'Item Number',
754 renderer : function(v) { return String.format('{0}', v); }
757 xtype: 'ColumnModel',
759 dataIndex : 'invadj_itemsite_id',
762 renderer : function(v,x,r) { return String.format('{0}', r.data.invadj_itemsite_id_item_number); },
770 displayField : 'itemsite_item_id_item_number',
772 emptyText : "Select itemsite",
773 fieldLabel : 'itemsite',
774 forceSelection : true,
775 hiddenName : 'invadj_itemsite_id',
777 loadingText : "Searching...",
779 name : 'invadj_itemsite_id_item_number',
781 qtip : "Select itemsite",
782 queryParam : 'query[number]',
783 selectOnFocus : true,
784 tpl : '<div class="x-grid-cell-text x-btn button"><b>{itemsite_item_id_item_number}</b> </div>',
785 triggerAction : 'all',
787 valueField : 'itemsite_id',
793 beforeload : function (_self, o){
794 o.params = o.params || {};
799 sortInfo : { direction : 'ASC', field: 'itemsite_item_id_item_number' },
804 url : baseURL + '/Roo/itemsite.php'
811 totalProperty : 'total',
812 fields : [{"name":"id","type":"int"},{"name":"itemsite_abcclass","type":"string"}]
819 xtype: 'ColumnModel',
822 dataIndex : 'invadj_qty_by',
823 header : 'Adjust By #',
825 renderer : function(v) { return String.format('{0}', v); },
830 xtype: 'NumberField',
832 allowDecimals : false,
838 xtype: 'ColumnModel',
840 dataIndex : 'invadj_comments',
843 renderer : function(v,x,r) {
844 return String.format(r.data.invfifo_void * 1 > 0 ? '<s style="color:#ccc">{0}</s>' : '{0}', v);
856 xtype: 'ColumnModel',
858 dataIndex : 'invadj_posted',
861 renderer : function(v) {
862 var state = v * 1 > 0 ? '-checked' : '';
864 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';