Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleRecvGrp.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Dialog.XtupleRecvGrp = {
6
7     dialog : false,
8     callback:  false,
9
10     show : function(data, cb)
11     {
12         if (!this.dialog) {
13             this.create();
14         }
15
16         this.callback = cb;
17         this.data = data;
18         this.dialog.show(this.data._el);
19         if (this.form) {
20            this.form.reset();
21            this.form.setValues(data);
22            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
23         }
24
25     },
26
27     create : function()
28     {
29         var _this = this;
30         this.dialog = Roo.factory({
31             xtype: 'LayoutDialog',
32             xns: Roo,
33             listeners : {
34                 show : function (_self)
35                 {
36                     _this.dialog.layout.getRegion('center').showPanel(0);
37                 }
38             },
39             closable : false,
40             collapsible : false,
41             height : 600,
42             modal : true,
43             resizable : false,
44             title : "Enter Item Reciept",
45             width : 900,
46             items : [
47                 {
48                     xtype: 'NestedLayoutPanel',
49                     xns: Roo,
50                     region : 'center',
51                     title : "Details",
52                     layout : {
53                         xtype: 'BorderLayout',
54                         xns: Roo,
55                         items : [
56                             {
57                                 xtype: 'ContentPanel',
58                                 xns: Roo,
59                                 region : 'north',
60                                 items : [
61                                     {
62                                         xtype: 'Form',
63                                         xns: Roo.form,
64                                         listeners : {
65                                             actioncomplete : function(_self,action)
66                                             {
67                                                 if (action.type == 'setdata') {
68                                                    //_this.dialog.el.mask("Loading");
69                                                    
70                                                    if (_this.data.recvgrp_id) {
71                                                        this.load({ method: 'GET', params: { '_id' : _this.data.recvgrp_id }});
72                                                        return;
73                                                    }
74                                                    
75                                                    if (!_this.data.recv_id) {
76                                                        _this.data.recv_date = new Date();
77                                                    }
78                                                    _this.form.setValues(_this.data);
79                                             
80                                                     _this.grid.ds.load({});
81                                                    //this.load({ method: 'GET', params: { '_id' : _this.data.id }});
82                                                    return;
83                                                 }
84                                                 if (action.type == 'load') {
85                                                     _this.grid.ds.load({});
86                                                     
87                                                     
88                                                     
89                                                     
90                                                     
91                                                     return;
92                                                 }
93                                                 if (action.type =='submit') {
94                                                 
95                                                      
96                                                     _this.dialog.hide();
97                                                 
98                                                      if (_this.callback) {
99                                                         _this.callback.call(_this, _this.form.getValues());
100                                                      }
101                                                      _this.form.reset();
102                                                      return;
103                                                 }
104                                             },
105                                             rendered : function (form)
106                                             {
107                                                 _this.form= form;
108                                             }
109                                         },
110                                         method : 'POST',
111                                         style : 'margin:10px;',
112                                         timeout : 120000,
113                                         url : baseURL + '/Roo/recvgrp.php',
114                                         items : [
115                                             {
116                                                 xtype: 'FieldSet',
117                                                 xns: Roo.form,
118                                                 legend : "Receipt Details",
119                                                 items : [
120                                                     {
121                                                         xtype: 'Row',
122                                                         xns: Roo.form,
123                                                         width : 800,
124                                                         items : [
125                                                             {
126                                                                 xtype: 'Column',
127                                                                 xns: Roo.form,
128                                                                 width : 450,
129                                                                 items : [
130                                                                     {
131                                                                         xtype: 'TextField',
132                                                                         xns: Roo.form,
133                                                                         fieldLabel : 'Order number',
134                                                                         name : 'recvgrp_pohead_id_pohead_number',
135                                                                         readOnly : true,
136                                                                         width : 200
137                                                                     },
138                                                                     {
139                                                                         xtype: 'DateField',
140                                                                         xns: Roo.form,
141                                                                         allowBlank : false,
142                                                                         altFormats : 'Y-m-d',
143                                                                         fieldLabel : 'Recv date',
144                                                                         format : 'd/M/Y',
145                                                                         name : 'recvgrp_date',
146                                                                         width : 100,
147                                                                         useIso : true
148                                                                     },
149                                                                     {
150                                                                         xtype: 'ComboBox',
151                                                                         xns: Roo.form,
152                                                                         allowBlank : false,
153                                                                         displayField : 'location_name',
154                                                                         editable : true,
155                                                                         emptyText : "Select location",
156                                                                         fieldLabel : 'Delivered to',
157                                                                         forceSelection : true,
158                                                                         hiddenName : 'recvgrp_location_id',
159                                                                         listWidth : 400,
160                                                                         loadingText : "Searching...",
161                                                                         minChars : 2,
162                                                                         name : 'recvgrp_location_id_location_name',
163                                                                         pageSize : 200,
164                                                                         qtip : "Select terms",
165                                                                         queryParam : 'query[location_name]',
166                                                                         selectOnFocus : true,
167                                                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> </div>',
168                                                                         triggerAction : 'all',
169                                                                         typeAhead : false,
170                                                                         valueField : 'location_id',
171                                                                         width : 300,
172                                                                         store : {
173                                                                             xtype: 'Store',
174                                                                             xns: Roo.data,
175                                                                             listeners : {
176                                                                                 beforeload : function (_self, o){
177                                                                                     o.params = o.params || {};
178                                                                                     
179                                                                                     o.params.location_netable = 1;
180                                                                                     o.params._notinternalcompany = 1; 
181                                                                                 }
182                                                                             },
183                                                                             remoteSort : true,
184                                                                             sortInfo : { direction : 'ASC', field: 'location_name' },
185                                                                             proxy : {
186                                                                                 xtype: 'HttpProxy',
187                                                                                 xns: Roo.data,
188                                                                                 method : 'GET',
189                                                                                 url : baseURL + '/Roo/location.php'
190                                                                             },
191                                                                             reader : {
192                                                                                 xtype: 'JsonReader',
193                                                                                 xns: Roo.data,
194                                                                                 id : 'location_id',
195                                                                                 root : 'data',
196                                                                                 totalProperty : 'total',
197                                                                                 fields : [{"name":"location_id","type":"int"},"location_name"]
198                                                                             }
199                                                                         }
200                                                                     },
201                                                                     {
202                                                                         xtype: 'TextField',
203                                                                         xns: Roo.form,
204                                                                         fieldLabel : 'Notes',
205                                                                         name : 'recv_notes',
206                                                                         width : 300
207                                                                     }
208                                                                 ]
209                                                             },
210                                                             {
211                                                                 xtype: 'Column',
212                                                                 xns: Roo.form,
213                                                                 labelAlign : 'top',
214                                                                 width : 350,
215                                                                 items : [
216                                                                     {
217                                                                         xtype: 'TextArea',
218                                                                         xns: Roo.form,
219                                                                         allowBlank : false,
220                                                                         fieldLabel : 'Goods Receipt Number',
221                                                                         name : 'recvgrp_receipt_number',
222                                                                         width : 300
223                                                                     }
224                                                                 ]
225                                                             }
226                                                         ]
227                                                     }
228                                                 ]
229                                             },
230                                             {
231                                                 xtype: 'Hidden',
232                                                 xns: Roo.form,
233                                                 name : 'recvgrp_pohead_id'
234                                             },
235                                             {
236                                                 xtype: 'Hidden',
237                                                 xns: Roo.form,
238                                                 name : 'recvgrp_id',
239                                                 value : 0
240                                             },
241                                             {
242                                                 xtype: 'Hidden',
243                                                 xns: Roo.form,
244                                                 name : 'recvgrp_void'
245                                             },
246                                             {
247                                                 xtype: 'Hidden',
248                                                 xns: Roo.form,
249                                                 name : 'recv_qtys',
250                                                 value : 0
251                                             }
252                                         ]
253                                     }
254                                 ]
255                             },
256                             {
257                                 xtype: 'GridPanel',
258                                 xns: Roo,
259                                 listeners : {
260                                     activate : function() {
261                                         _this.panel = this;
262                                          
263                                     }
264                                 },
265                                 background : false,
266                                 fitContainer : true,
267                                 fitToframe : true,
268                                 region : 'center',
269                                 tableName : 'poitem',
270                                 title : "poitem",
271                                 grid : {
272                                     xtype: 'EditorGrid',
273                                     xns: Roo.grid,
274                                     listeners : {
275                                         render : function() 
276                                         {
277                                             _this.grid = this; 
278                                             //_this.dialog = Pman.Dialog.FILL_IN
279                                              
280                                         },
281                                         rowdblclick : function (_self, rowIndex, e)
282                                         {
283                                             if (!_this.dialog) return;
284                                             _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
285                                                 _this.grid.footer.onClick('first');
286                                             }); 
287                                         },
288                                         beforeedit : function (e)
289                                         {
290                                              if (_this.form.findField('recvgrp_id').getValue() * 1 > 0) {
291                                                 Roo.MessageBox.alert("Error", "you can not modify the stock");
292                                                 e.cancel = true;
293                                             }
294                                         }
295                                     },
296                                     autoExpandColumn : 'item_descrip1',
297                                     clicksToEdit : 1,
298                                     loadMask : true,
299                                     dataSource : {
300                                         xtype: 'Store',
301                                         xns: Roo.data,
302                                         listeners : {
303                                             beforeload : function (_self, o)
304                                             {
305                                                 if (!_this.form ) {
306                                                     return false;
307                                                 }
308                                                  o.params=  o.params || {};
309                                                  
310                                                 o.params.poitem_pohead_id = _this.form.findField('recvgrp_pohead_id').getValue();
311                                                 o.params._with_item = 1;
312                                                 o.params.item_type = 'P';    
313                                                 o.params.recvgrp_id = _this.form.findField('recvgrp_id').getValue();
314                                                 o.params.limit = 3000;
315                                             }
316                                         },
317                                         remoteSort : true,
318                                         sortInfo : { field : 'poitem_linenumber', direction: 'ASC' },
319                                         proxy : {
320                                             xtype: 'HttpProxy',
321                                             xns: Roo.data,
322                                             method : 'GET',
323                                             timeout : 90000,
324                                             url : baseURL + '/Roo/poitem.php'
325                                         },
326                                         reader : {
327                                             xtype: 'JsonReader',
328                                             xns: Roo.data,
329                                             totalProperty : 'total',
330                                             root : 'data',
331                                             id : 'id',
332                                             fields : [
333                                                 {
334                                                     'name': 'poitem_id',
335                                                     'type': 'int'
336                                                 },
337                                                 {
338                                                     'name': 'poitem_status',
339                                                     'type': 'string'
340                                                 },
341                                                 {
342                                                     'name': 'poitem_pohead_id',
343                                                     'type': 'int'
344                                                 },
345                                                 {
346                                                     'name': 'poitem_linenumber',
347                                                     'type': 'int'
348                                                 },
349                                                 {
350                                                     'name': 'poitem_duedate',
351                                                     'type': 'date',
352                                                     'dateFormat': 'Y-m-d'
353                                                 },
354                                                 {
355                                                     'name': 'poitem_wohead_id',
356                                                     'type': 'int'
357                                                 },
358                                                 {
359                                                     'name': 'poitem_itemsite_id',
360                                                     'type': 'int'
361                                                 },
362                                                 {
363                                                     'name': 'poitem_vend_item_descrip',
364                                                     'type': 'string'
365                                                 },
366                                                 {
367                                                     'name': 'poitem_vend_uom',
368                                                     'type': 'string'
369                                                 },
370                                                 {
371                                                     'name': 'poitem_invvenduomratio',
372                                                     'type': 'float'
373                                                 },
374                                                 {
375                                                     'name': 'poitem_qty_ordered',
376                                                     'type': 'float'
377                                                 },
378                                                 {
379                                                     'name': 'poitem_qty_received',
380                                                     'type': 'float'
381                                                 },
382                                                 {
383                                                     'name': 'poitem_qty_returned',
384                                                     'type': 'float'
385                                                 },
386                                                 {
387                                                     'name': 'poitem_qty_vouchered',
388                                                     'type': 'float'
389                                                 },
390                                                 {
391                                                     'name': 'poitem_unitprice',
392                                                     'type': 'float'
393                                                 },
394                                                 {
395                                                     'name': 'poitem_vend_item_number',
396                                                     'type': 'string'
397                                                 },
398                                                 {
399                                                     'name': 'poitem_comments',
400                                                     'type': 'string'
401                                                 },
402                                                 {
403                                                     'name': 'poitem_qty_toreceive',
404                                                     'type': 'float'
405                                                 },
406                                                 {
407                                                     'name': 'poitem_expcat_id',
408                                                     'type': 'int'
409                                                 },
410                                                 {
411                                                     'name': 'poitem_itemsrc_id',
412                                                     'type': 'int'
413                                                 },
414                                                 {
415                                                     'name': 'poitem_freight',
416                                                     'type': 'float'
417                                                 },
418                                                 {
419                                                     'name': 'poitem_freight_received',
420                                                     'type': 'float'
421                                                 },
422                                                 {
423                                                     'name': 'poitem_freight_vouchered',
424                                                     'type': 'float'
425                                                 },
426                                                 {
427                                                     'name': 'poitem_soitem_id',
428                                                     'type': 'int'
429                                                 },
430                                                 {
431                                                     'name': 'poitem_prj_id',
432                                                     'type': 'int'
433                                                 },
434                                                 {
435                                                     'name': 'poitem_stdcost',
436                                                     'type': 'float'
437                                                 },
438                                                 {
439                                                     'name': 'poitem_bom_rev_id',
440                                                     'type': 'int'
441                                                 },
442                                                 {
443                                                     'name': 'poitem_boo_rev_id',
444                                                     'type': 'int'
445                                                 },
446                                                 {
447                                                     'name': 'poitem_manuf_name',
448                                                     'type': 'string'
449                                                 },
450                                                 {
451                                                     'name': 'poitem_manuf_item_number',
452                                                     'type': 'string'
453                                                 },
454                                                 {
455                                                     'name': 'poitem_manuf_item_descrip',
456                                                     'type': 'string'
457                                                 },
458                                                 {
459                                                     'name': 'poitem_taxtype_id',
460                                                     'type': 'int'
461                                                 },
462                                                 {
463                                                     'name': 'poitem_tax_recoverable',
464                                                     'type': 'int'
465                                                 },
466                                                 {
467                                                     'name': 'poitem_rlsd_duedate',
468                                                     'type': 'date',
469                                                     'dateFormat': 'Y-m-d'
470                                                 },
471                                                 {
472                                                     'name': 'poitem_wohead_id_wo_id',
473                                                     'type': 'int'
474                                                 },
475                                                 {
476                                                     'name': 'poitem_wohead_id_wo_number',
477                                                     'type': 'int'
478                                                 },
479                                                 {
480                                                     'name': 'poitem_wohead_id_wo_subnumber',
481                                                     'type': 'int'
482                                                 },
483                                                 {
484                                                     'name': 'poitem_wohead_id_wo_status',
485                                                     'type': 'string'
486                                                 },
487                                                 {
488                                                     'name': 'poitem_wohead_id_wo_itemsite_id',
489                                                     'type': 'int'
490                                                 },
491                                                 {
492                                                     'name': 'poitem_wohead_id_wo_startdate',
493                                                     'type': 'date'
494                                                 },
495                                                 {
496                                                     'name': 'poitem_wohead_id_wo_duedate',
497                                                     'type': 'date'
498                                                 },
499                                                 {
500                                                     'name': 'poitem_wohead_id_wo_ordtype',
501                                                     'type': 'string'
502                                                 },
503                                                 {
504                                                     'name': 'poitem_wohead_id_wo_ordid',
505                                                     'type': 'int'
506                                                 },
507                                                 {
508                                                     'name': 'poitem_wohead_id_wo_qtyord',
509                                                     'type': 'float'
510                                                 },
511                                                 {
512                                                     'name': 'poitem_wohead_id_wo_qtyrcv',
513                                                     'type': 'float'
514                                                 },
515                                                 {
516                                                     'name': 'poitem_wohead_id_wo_adhoc',
517                                                     'type': 'int'
518                                                 },
519                                                 {
520                                                     'name': 'poitem_wohead_id_wo_itemcfg_series',
521                                                     'type': 'int'
522                                                 },
523                                                 {
524                                                     'name': 'poitem_wohead_id_wo_imported',
525                                                     'type': 'int'
526                                                 },
527                                                 {
528                                                     'name': 'poitem_wohead_id_wo_wipvalue',
529                                                     'type': 'float'
530                                                 },
531                                                 {
532                                                     'name': 'poitem_wohead_id_wo_postedvalue',
533                                                     'type': 'float'
534                                                 },
535                                                 {
536                                                     'name': 'poitem_wohead_id_wo_prodnotes',
537                                                     'type': 'string'
538                                                 },
539                                                 {
540                                                     'name': 'poitem_wohead_id_wo_prj_id',
541                                                     'type': 'int'
542                                                 },
543                                                 {
544                                                     'name': 'poitem_wohead_id_wo_priority',
545                                                     'type': 'int'
546                                                 },
547                                                 {
548                                                     'name': 'poitem_wohead_id_wo_brdvalue',
549                                                     'type': 'float'
550                                                 },
551                                                 {
552                                                     'name': 'poitem_wohead_id_wo_bom_rev_id',
553                                                     'type': 'int'
554                                                 },
555                                                 {
556                                                     'name': 'poitem_wohead_id_wo_boo_rev_id',
557                                                     'type': 'int'
558                                                 },
559                                                 {
560                                                     'name': 'poitem_wohead_id_wo_cosmethod',
561                                                     'type': 'string'
562                                                 },
563                                                 {
564                                                     'name': 'poitem_wohead_id_wo_womatl_id',
565                                                     'type': 'int'
566                                                 },
567                                                 {
568                                                     'name': 'poitem_wohead_id_wo_username',
569                                                     'type': 'string'
570                                                 },
571                                                 {
572                                                     'name': 'poitem_taxtype_id_taxtype_id',
573                                                     'type': 'int'
574                                                 },
575                                                 {
576                                                     'name': 'poitem_taxtype_id_taxtype_name',
577                                                     'type': 'string'
578                                                 },
579                                                 {
580                                                     'name': 'poitem_taxtype_id_taxtype_descrip',
581                                                     'type': 'string'
582                                                 },
583                                                 {
584                                                     'name': 'poitem_taxtype_id_taxtype_sys',
585                                                     'type': 'int'
586                                                 },
587                                                 {
588                                                     'name': 'poitem_prj_id_prj_id',
589                                                     'type': 'int'
590                                                 },
591                                                 {
592                                                     'name': 'poitem_prj_id_prj_number',
593                                                     'type': 'string'
594                                                 },
595                                                 {
596                                                     'name': 'poitem_prj_id_prj_name',
597                                                     'type': 'string'
598                                                 },
599                                                 {
600                                                     'name': 'poitem_prj_id_prj_descrip',
601                                                     'type': 'string'
602                                                 },
603                                                 {
604                                                     'name': 'poitem_prj_id_prj_status',
605                                                     'type': 'string'
606                                                 },
607                                                 {
608                                                     'name': 'poitem_prj_id_prj_so',
609                                                     'type': 'int'
610                                                 },
611                                                 {
612                                                     'name': 'poitem_prj_id_prj_wo',
613                                                     'type': 'int'
614                                                 },
615                                                 {
616                                                     'name': 'poitem_prj_id_prj_po',
617                                                     'type': 'int'
618                                                 },
619                                                 {
620                                                     'name': 'poitem_prj_id_prj_owner_username',
621                                                     'type': 'string'
622                                                 },
623                                                 {
624                                                     'name': 'poitem_prj_id_prj_start_date',
625                                                     'type': 'date'
626                                                 },
627                                                 {
628                                                     'name': 'poitem_prj_id_prj_due_date',
629                                                     'type': 'date'
630                                                 },
631                                                 {
632                                                     'name': 'poitem_prj_id_prj_assigned_date',
633                                                     'type': 'date'
634                                                 },
635                                                 {
636                                                     'name': 'poitem_prj_id_prj_completed_date',
637                                                     'type': 'date'
638                                                 },
639                                                 {
640                                                     'name': 'poitem_prj_id_prj_username',
641                                                     'type': 'string'
642                                                 },
643                                                 {
644                                                     'name': 'poitem_prj_id_prj_recurring_prj_id',
645                                                     'type': 'int'
646                                                 },
647                                                 {
648                                                     'name': 'poitem_itemsrc_id_itemsrc_id',
649                                                     'type': 'int'
650                                                 },
651                                                 {
652                                                     'name': 'poitem_itemsrc_id_itemsrc_item_id',
653                                                     'type': 'int'
654                                                 },
655                                                 {
656                                                     'name': 'poitem_itemsrc_id_itemsrc_item_id',
657                                                     'type': 'int'
658                                                 },
659                                                 {
660                                                     'name': 'poitem_itemsrc_id_itemsrc_vend_id',
661                                                     'type': 'int'
662                                                 },
663                                                 {
664                                                     'name': 'poitem_itemsrc_id_itemsrc_vend_id',
665                                                     'type': 'int'
666                                                 },
667                                                 {
668                                                     'name': 'poitem_itemsrc_id_itemsrc_vend_item_number',
669                                                     'type': 'string'
670                                                 },
671                                                 {
672                                                     'name': 'poitem_itemsrc_id_itemsrc_vend_item_descrip',
673                                                     'type': 'string'
674                                                 },
675                                                 {
676                                                     'name': 'poitem_itemsrc_id_itemsrc_comments',
677                                                     'type': 'string'
678                                                 },
679                                                 {
680                                                     'name': 'poitem_itemsrc_id_itemsrc_vend_uom',
681                                                     'type': 'string'
682                                                 },
683                                                 {
684                                                     'name': 'poitem_itemsrc_id_itemsrc_invvendoruomratio',
685                                                     'type': 'float'
686                                                 },
687                                                 {
688                                                     'name': 'poitem_itemsrc_id_itemsrc_minordqty',
689                                                     'type': 'float'
690                                                 },
691                                                 {
692                                                     'name': 'poitem_itemsrc_id_itemsrc_multordqty',
693                                                     'type': 'float'
694                                                 },
695                                                 {
696                                                     'name': 'poitem_itemsrc_id_itemsrc_leadtime',
697                                                     'type': 'int'
698                                                 },
699                                                 {
700                                                     'name': 'poitem_itemsrc_id_itemsrc_ranking',
701                                                     'type': 'int'
702                                                 },
703                                                 {
704                                                     'name': 'poitem_itemsrc_id_itemsrc_active',
705                                                     'type': 'int'
706                                                 },
707                                                 {
708                                                     'name': 'poitem_itemsrc_id_itemsrc_manuf_name',
709                                                     'type': 'string'
710                                                 },
711                                                 {
712                                                     'name': 'poitem_itemsrc_id_itemsrc_manuf_item_number',
713                                                     'type': 'string'
714                                                 },
715                                                 {
716                                                     'name': 'poitem_itemsrc_id_itemsrc_manuf_item_descrip',
717                                                     'type': 'string'
718                                                 },
719                                                 {
720                                                     'name': 'poitem_itemsrc_id_itemsrc_default',
721                                                     'type': 'int'
722                                                 },
723                                                 {
724                                                     'name': 'poitem_itemsrc_id_itemsrc_upccode',
725                                                     'type': 'string'
726                                                 },
727                                                 {
728                                                     'name': 'poitem_itemsite_id_itemsite_id',
729                                                     'type': 'int'
730                                                 },
731                                                 {
732                                                     'name': 'poitem_itemsite_id_itemsite_item_id',
733                                                     'type': 'int'
734                                                 },
735                                                 {
736                                                     'name': 'poitem_itemsite_id_itemsite_warehous_id',
737                                                     'type': 'int'
738                                                 },
739                                                 {
740                                                     'name': 'poitem_itemsite_id_itemsite_qtyonhand',
741                                                     'type': 'float'
742                                                 },
743                                                 {
744                                                     'name': 'poitem_itemsite_id_itemsite_reorderlevel',
745                                                     'type': 'float'
746                                                 },
747                                                 {
748                                                     'name': 'poitem_itemsite_id_itemsite_ordertoqty',
749                                                     'type': 'float'
750                                                 },
751                                                 {
752                                                     'name': 'poitem_itemsite_id_itemsite_cyclecountfreq',
753                                                     'type': 'int'
754                                                 },
755                                                 {
756                                                     'name': 'poitem_itemsite_id_itemsite_datelastcount',
757                                                     'type': 'date'
758                                                 },
759                                                 {
760                                                     'name': 'poitem_itemsite_id_itemsite_datelastused',
761                                                     'type': 'date'
762                                                 },
763                                                 {
764                                                     'name': 'poitem_itemsite_id_itemsite_loccntrl',
765                                                     'type': 'int'
766                                                 },
767                                                 {
768                                                     'name': 'poitem_itemsite_id_itemsite_safetystock',
769                                                     'type': 'float'
770                                                 },
771                                                 {
772                                                     'name': 'poitem_itemsite_id_itemsite_minordqty',
773                                                     'type': 'float'
774                                                 },
775                                                 {
776                                                     'name': 'poitem_itemsite_id_itemsite_multordqty',
777                                                     'type': 'float'
778                                                 },
779                                                 {
780                                                     'name': 'poitem_itemsite_id_itemsite_leadtime',
781                                                     'type': 'int'
782                                                 },
783                                                 {
784                                                     'name': 'poitem_itemsite_id_itemsite_abcclass',
785                                                     'type': 'string'
786                                                 },
787                                                 {
788                                                     'name': 'poitem_itemsite_id_itemsite_issuemethod',
789                                                     'type': 'string'
790                                                 },
791                                                 {
792                                                     'name': 'poitem_itemsite_id_itemsite_controlmethod',
793                                                     'type': 'string'
794                                                 },
795                                                 {
796                                                     'name': 'poitem_itemsite_id_itemsite_active',
797                                                     'type': 'int'
798                                                 },
799                                                 {
800                                                     'name': 'poitem_itemsite_id_itemsite_plancode_id',
801                                                     'type': 'int'
802                                                 },
803                                                 {
804                                                     'name': 'poitem_itemsite_id_itemsite_costcat_id',
805                                                     'type': 'int'
806                                                 },
807                                                 {
808                                                     'name': 'poitem_itemsite_id_itemsite_eventfence',
809                                                     'type': 'int'
810                                                 },
811                                                 {
812                                                     'name': 'poitem_itemsite_id_itemsite_sold',
813                                                     'type': 'int'
814                                                 },
815                                                 {
816                                                     'name': 'poitem_itemsite_id_itemsite_stocked',
817                                                     'type': 'int'
818                                                 },
819                                                 {
820                                                     'name': 'poitem_itemsite_id_itemsite_freeze',
821                                                     'type': 'int'
822                                                 },
823                                                 {
824                                                     'name': 'poitem_itemsite_id_itemsite_location_id',
825                                                     'type': 'int'
826                                                 },
827                                                 {
828                                                     'name': 'poitem_itemsite_id_itemsite_useparams',
829                                                     'type': 'int'
830                                                 },
831                                                 {
832                                                     'name': 'poitem_itemsite_id_itemsite_useparamsmanual',
833                                                     'type': 'int'
834                                                 },
835                                                 {
836                                                     'name': 'poitem_itemsite_id_itemsite_soldranking',
837                                                     'type': 'int'
838                                                 },
839                                                 {
840                                                     'name': 'poitem_itemsite_id_itemsite_createpr',
841                                                     'type': 'int'
842                                                 },
843                                                 {
844                                                     'name': 'poitem_itemsite_id_itemsite_location',
845                                                     'type': 'string'
846                                                 },
847                                                 {
848                                                     'name': 'poitem_itemsite_id_itemsite_location_comments',
849                                                     'type': 'string'
850                                                 },
851                                                 {
852                                                     'name': 'poitem_itemsite_id_itemsite_notes',
853                                                     'type': 'string'
854                                                 },
855                                                 {
856                                                     'name': 'poitem_itemsite_id_itemsite_perishable',
857                                                     'type': 'int'
858                                                 },
859                                                 {
860                                                     'name': 'poitem_itemsite_id_itemsite_nnqoh',
861                                                     'type': 'float'
862                                                 },
863                                                 {
864                                                     'name': 'poitem_itemsite_id_itemsite_autoabcclass',
865                                                     'type': 'int'
866                                                 },
867                                                 {
868                                                     'name': 'poitem_itemsite_id_itemsite_ordergroup',
869                                                     'type': 'int'
870                                                 },
871                                                 {
872                                                     'name': 'poitem_itemsite_id_itemsite_disallowblankwip',
873                                                     'type': 'int'
874                                                 },
875                                                 {
876                                                     'name': 'poitem_itemsite_id_itemsite_maxordqty',
877                                                     'type': 'float'
878                                                 },
879                                                 {
880                                                     'name': 'poitem_itemsite_id_itemsite_mps_timefence',
881                                                     'type': 'int'
882                                                 },
883                                                 {
884                                                     'name': 'poitem_itemsite_id_itemsite_createwo',
885                                                     'type': 'int'
886                                                 },
887                                                 {
888                                                     'name': 'poitem_itemsite_id_itemsite_warrpurc',
889                                                     'type': 'int'
890                                                 },
891                                                 {
892                                                     'name': 'poitem_itemsite_id_itemsite_autoreg',
893                                                     'type': 'int'
894                                                 },
895                                                 {
896                                                     'name': 'poitem_itemsite_id_itemsite_costmethod',
897                                                     'type': 'string'
898                                                 },
899                                                 {
900                                                     'name': 'poitem_itemsite_id_itemsite_value',
901                                                     'type': 'float'
902                                                 },
903                                                 {
904                                                     'name': 'poitem_itemsite_id_itemsite_ordergroup_first',
905                                                     'type': 'int'
906                                                 },
907                                                 {
908                                                     'name': 'poitem_itemsite_id_itemsite_supply_itemsite_id',
909                                                     'type': 'int'
910                                                 },
911                                                 {
912                                                     'name': 'poitem_itemsite_id_itemsite_planning_type',
913                                                     'type': 'string'
914                                                 },
915                                                 {
916                                                     'name': 'poitem_itemsite_id_itemsite_wosupply',
917                                                     'type': 'int'
918                                                 },
919                                                 {
920                                                     'name': 'poitem_itemsite_id_itemsite_posupply',
921                                                     'type': 'int'
922                                                 },
923                                                 {
924                                                     'name': 'poitem_itemsite_id_itemsite_lsseq_id',
925                                                     'type': 'int'
926                                                 },
927                                                 {
928                                                     'name': 'poitem_itemsite_id_itemsite_cosdefault',
929                                                     'type': 'string'
930                                                 },
931                                                 {
932                                                     'name': 'poitem_itemsite_id_itemsite_createsopr',
933                                                     'type': 'int'
934                                                 },
935                                                 {
936                                                     'name': 'poitem_itemsite_id_itemsite_createsopo',
937                                                     'type': 'int'
938                                                 },
939                                                 {
940                                                     'name': 'poitem_itemsite_id_itemsite_dropship',
941                                                     'type': 'int'
942                                                 },
943                                                 {
944                                                     'name': 'poitem_expcat_id_expcat_id',
945                                                     'type': 'int'
946                                                 },
947                                                 {
948                                                     'name': 'poitem_expcat_id_expcat_code',
949                                                     'type': 'string'
950                                                 },
951                                                 {
952                                                     'name': 'poitem_expcat_id_expcat_descrip',
953                                                     'type': 'string'
954                                                 },
955                                                 {
956                                                     'name': 'poitem_expcat_id_expcat_exp_accnt_id',
957                                                     'type': 'int'
958                                                 },
959                                                 {
960                                                     'name': 'poitem_expcat_id_expcat_liability_accnt_id',
961                                                     'type': 'int'
962                                                 },
963                                                 {
964                                                     'name': 'poitem_expcat_id_expcat_active',
965                                                     'type': 'int'
966                                                 },
967                                                 {
968                                                     'name': 'poitem_expcat_id_expcat_purchprice_accnt_id',
969                                                     'type': 'int'
970                                                 },
971                                                 {
972                                                     'name': 'poitem_expcat_id_expcat_freight_accnt_id',
973                                                     'type': 'int'
974                                                 }
975                                             ]
976                                         }
977                                     },
978                                     toolbar : {
979                                         xtype: 'Toolbar',
980                                         xns: Roo,
981                                         items : [
982                                             {
983                                                 xtype: 'Button',
984                                                 xns: Roo.Toolbar,
985                                                 listeners : {
986                                                     click : function()
987                                                     {
988                                                          // reset..
989                                                          _this.grid.load({});
990                                                     }
991                                                 },
992                                                 text : "Reset"
993                                             },
994                                             {
995                                                 xtype: 'Fill',
996                                                 xns: Roo.Toolbar
997                                             },
998                                             {
999                                                 xtype: 'Button',
1000                                                 xns: Roo.Toolbar,
1001                                                 listeners : {
1002                                                     click : function()
1003                                                     {
1004                                                          if (_this.form.findField('recvgrp_id').getValue() * 1 > 0) {
1005                                                             Roo.MessageBox.alert("Error", "you can not modify the stock");
1006                                                             return;
1007                                                         }
1008                                                          // reset..
1009                                                          _this.grid.ds.each(function(r) {
1010                                                             r.set('recv_qty',  r.data.poitem_qty_ordered - 
1011                                                               r.data.poitem_qty_received + r.data.poitem_qty_returned
1012                                                             );
1013                                                         });
1014                                                         
1015                                                     }
1016                                                 },
1017                                                 cls : 'x-btn-text-icon',
1018                                                 text : "Recieve All",
1019                                                 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
1020                                             }
1021                                         ]
1022                                     },
1023                                     colModel : [
1024                                         {
1025                                             xtype: 'ColumnModel',
1026                                             xns: Roo.grid,
1027                                             dataIndex : 'poitem_linenumber',
1028                                             header : 'Line#',
1029                                             width : 50,
1030                                             renderer : function(v) { return String.format('{0}', v); }
1031                                         },
1032                                         {
1033                                             xtype: 'ColumnModel',
1034                                             xns: Roo.grid,
1035                                             dataIndex : 'item_number',
1036                                             header : 'Item No.',
1037                                             width : 75,
1038                                             renderer : function(v) { return String.format('{0}', v); }
1039                                         },
1040                                         {
1041                                             xtype: 'ColumnModel',
1042                                             xns: Roo.grid,
1043                                             dataIndex : 'item_descrip1',
1044                                             header : 'Description',
1045                                             width : 150,
1046                                             renderer : function(v) { return String.format('{0}', v); }
1047                                         },
1048                                         {
1049                                             xtype: 'ColumnModel',
1050                                             xns: Roo.grid,
1051                                             align : 'right',
1052                                             dataIndex : 'poitem_qty_ordered',
1053                                             header : 'Ordered',
1054                                             width : 75,
1055                                             renderer : function(v) { return String.format('{0}', v); }
1056                                         },
1057                                         {
1058                                             xtype: 'ColumnModel',
1059                                             xns: Roo.grid,
1060                                             align : 'right',
1061                                             dataIndex : 'poitem_qty_received',
1062                                             header : 'Remaining',
1063                                             width : 75,
1064                                             renderer : function(v,x,r) {
1065                                             
1066                                                  var vv = r.data.poitem_qty_ordered - 
1067                                                     r.data.poitem_qty_received + r.data.poitem_qty_returned;
1068                                                  return String.format('{0}', parseInt(vv)); 
1069                                                       
1070                                              }
1071                                         },
1072                                         {
1073                                             xtype: 'ColumnModel',
1074                                             xns: Roo.grid,
1075                                             align : 'right',
1076                                             dataIndex : 'recv_qty',
1077                                             header : 'Recieved',
1078                                             width : 75,
1079                                             renderer : function(v) { 
1080                                             
1081                                                 var voided = _this.form.findField('recvgrp_void').getValue() * 1;
1082                                                 var format = voided ? '<s>{0}</s>' : '{0}';
1083                                                 return String.format(format , parseInt(v)); 
1084                                             },
1085                                             editor : {
1086                                                 xtype: 'GridEditor',
1087                                                 xns: Roo.grid,
1088                                                 field : {
1089                                                     xtype: 'NumberField',
1090                                                     xns: Roo.form,
1091                                                     cls : 'align-right',
1092                                                     decimalPrecision : 0
1093                                                 }
1094                                             }
1095                                         }
1096                                     ]
1097                                 }
1098                             }
1099                         ],
1100                         center : {
1101                             xtype: 'LayoutRegion',
1102                             xns: Roo
1103                         },
1104                         north : {
1105                             xtype: 'LayoutRegion',
1106                             xns: Roo,
1107                             height : 160
1108                         }
1109                     }
1110                 },
1111                 {
1112                     xtype: 'GridPanel',
1113                     xns: Roo,
1114                     listeners : {
1115                         activate : function() {
1116                             _this.hpanel = this;
1117                             if (_this.hgrid) {
1118                                 _this.hgrid.footer.onClick('first');
1119                             }
1120                         }
1121                     },
1122                     background : true,
1123                     fitContainer : true,
1124                     fitToframe : true,
1125                     region : 'center',
1126                     tableName : 'events',
1127                     title : "History",
1128                     grid : {
1129                         xtype: 'Grid',
1130                         xns: Roo.grid,
1131                         listeners : {
1132                             render : function() 
1133                             {
1134                                 _this.hgrid = this; 
1135                                 if (_this.hpanel.active) {
1136                                    this.footer.onClick('first');
1137                                 }
1138                             }
1139                         },
1140                         autoExpandColumn : 'remarks',
1141                         loadMask : true,
1142                         dataSource : {
1143                             xtype: 'Store',
1144                             xns: Roo.data,
1145                             listeners : {
1146                                 beforeload : function (_self, options)
1147                                 {
1148                                     options.params = options.params || {};
1149                                     
1150                                     options.params.on_table = 'recvgrp';
1151                                     options.params.on_id = _this.form.findField('recvgrp_id').getValue();
1152                                 }
1153                             },
1154                             remoteSort : true,
1155                             sortInfo : { field : 'event_when', direction: 'DESC' },
1156                             proxy : {
1157                                 xtype: 'HttpProxy',
1158                                 xns: Roo.data,
1159                                 method : 'GET',
1160                                 url : baseURL + '/Roo/events.php'
1161                             },
1162                             reader : {
1163                                 xtype: 'JsonReader',
1164                                 xns: Roo.data,
1165                                 id : 'id',
1166                                 root : 'data',
1167                                 totalProperty : 'total',
1168                                 fields : [
1169                                     {
1170                                         'name': 'event_when',
1171                                         'type': 'date'
1172                                     },
1173                                     {
1174                                         'name': 'action',
1175                                         'type': 'string'
1176                                     },
1177                                     {
1178                                         'name': 'ipaddr',
1179                                         'type': 'string'
1180                                     },
1181                                     {
1182                                         'name': 'person_id_name',
1183                                         'type': 'string'
1184                                     },
1185                                     {
1186                                         'name': 'remarks',
1187                                         'type': 'string'
1188                                     }
1189                                 ]
1190                             }
1191                         },
1192                         footer : {
1193                             xtype: 'PagingToolbar',
1194                             xns: Roo,
1195                             displayInfo : true,
1196                             displayMsg : "Displaying events{0} - {1} of {2}",
1197                             emptyMsg : "No Events found",
1198                             pageSize : 25
1199                         },
1200                         colModel : [
1201                             {
1202                                 xtype: 'ColumnModel',
1203                                 xns: Roo.grid,
1204                                 dataIndex : 'event_when',
1205                                 header : 'Changed',
1206                                 width : 120,
1207                                 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); }
1208                             },
1209                             {
1210                                 xtype: 'ColumnModel',
1211                                 xns: Roo.grid,
1212                                 dataIndex : 'action',
1213                                 header : 'Action',
1214                                 width : 200,
1215                                 renderer : function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); }
1216                             },
1217                             {
1218                                 xtype: 'ColumnModel',
1219                                 xns: Roo.grid,
1220                                 dataIndex : 'ipaddr',
1221                                 header : 'IP Address',
1222                                 width : 200,
1223                                 renderer : function(v) { return String.format('{0}', v); }
1224                             },
1225                             {
1226                                 xtype: 'ColumnModel',
1227                                 xns: Roo.grid,
1228                                 dataIndex : 'person_id_name',
1229                                 header : 'Who',
1230                                 width : 75,
1231                                 renderer : function(v) { return String.format('{0}', v); }
1232                             },
1233                             {
1234                                 xtype: 'ColumnModel',
1235                                 xns: Roo.grid,
1236                                 dataIndex : 'remarks',
1237                                 header : 'Notes',
1238                                 width : 200,
1239                                 renderer : function(v) { return String.format('{0}', v); }
1240                             }
1241                         ]
1242                     }
1243                 }
1244             ],
1245             center : {
1246                 xtype: 'LayoutRegion',
1247                 xns: Roo,
1248                 tabPosition : 'top'
1249             },
1250             buttons : [
1251                 {
1252                     xtype: 'Button',
1253                     xns: Roo,
1254                     listeners : {
1255                         click : function (_self, e)
1256                         {
1257                              new Pman.Download({
1258                                 grid : _this.grid
1259                              });
1260                             
1261                            
1262                         
1263                         }
1264                     },
1265                     text : "Download"
1266                 },
1267                 {
1268                     xtype: 'Button',
1269                     xns: Roo,
1270                     listeners : {
1271                         click : function (_self, e)
1272                         {
1273                             if (!_this.form.findField('recvgrp_id').getValue()) {
1274                                 Roo.MessageBox.alert("Error", "Can not void this as it has not been saved");
1275                                 return;
1276                             }
1277                            
1278                              if (1 * _this.form.findField('recvgrp_void').getValue()) {
1279                                 Roo.MessageBox.alert("Error", "This record is already void.");
1280                                 return;
1281                             }
1282                             new Pman.Request({
1283                                 mask : 'Voiding',
1284                                 method : 'POST',
1285                                 url : baseURL + '/Roo/Recvgrp',
1286                                 timeout: 90000,
1287                                 params : {
1288                                     recvgrp_id : _this.form.findField('recvgrp_id').getValue(),
1289                                     _void : 1
1290                                 },
1291                                 success : function() {
1292                                       if (_this.callback) {
1293                                         _this.callback.call(_this, _this.form.getValues());
1294                                      }
1295                                     _this.dialog.hide();
1296                                 }
1297                             });
1298                             
1299                            
1300                         
1301                         }
1302                     },
1303                     text : "VOID"
1304                 },
1305                 {
1306                     xtype: 'Button',
1307                     xns: Roo,
1308                     listeners : {
1309                         click : function (_self, e)
1310                         {
1311                             _this.dialog.hide();
1312                         }
1313                     },
1314                     text : "Cancel"
1315                 },
1316                 {
1317                     xtype: 'Button',
1318                     xns: Roo,
1319                     listeners : {
1320                         click : function (_self, e)
1321                         {
1322                             // do some checks?
1323                              
1324                             
1325                             var c = [];
1326                             var t = 0;
1327                             _this.grid.ds.each(function(r) {
1328                                 var q = r.data.recv_qty * 1;
1329                                 if (q < 1) {
1330                                     return;
1331                                 }
1332                                 c.push({
1333                                     recv_orderitem_id : r.data.poitem_id,
1334                                     recv_qty : r.data.recv_qty
1335                                 });
1336                                 t += r.data.recv_qty * 1;
1337                             });
1338                             if (t < 1) {
1339                                 Roo.MessageBox.alert("Error", "nothing to recieve");
1340                                 return;
1341                             }
1342                             
1343                             _this.form.findField('recv_qtys').setValue( Roo.encode(c));
1344                             _this.form.doAction("submit");
1345                         
1346                         }
1347                     },
1348                     text : "Save"
1349                 }
1350             ]
1351         });
1352     }
1353 };