Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtuplePurchaseStock.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.Tab.XtuplePurchaseStock = new Roo.XComponent({
6     part     :  ["Xtuple","PurchaseStock"],
7     order    : '200-Pman.Tab.XtuplePurchaseStock',
8     region   : 'center',
9     parent   : 'Pman.Tab.XtuplePurchases',
10     name     : "Pman.Tab.XtuplePurchaseStock",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'NestedLayoutPanel',
19             xns: Roo,
20             background : true,
21             title : "Incoming Stock Schedule",
22             layout : {
23                 xtype: 'BorderLayout',
24                 xns: Roo,
25                 items : [
26                     {
27                         xtype: 'GridPanel',
28                         xns: Roo,
29                         listeners : {
30                             activate : function() {
31                                 _this.panel = this;
32                                 if (_this.grid) {
33                                     _this.grid.footer.onClick('first');
34                                 }
35                             }
36                         },
37                         background : true,
38                         fitContainer : true,
39                         fitToframe : true,
40                         region : 'center',
41                         tableName : 'poitem',
42                         title : "Incoming Stock Schedule",
43                         grid : {
44                             xtype: 'EditorGrid',
45                             xns: Roo.grid,
46                             listeners : {
47                                 render : function() 
48                                 {
49                                     _this.grid = this; 
50                                     //_this.dialog = Pman.Dialog.FILL_IN
51                                     if (_this.panel.active) {
52                                        this.footer.onClick('first');
53                                     }
54                                 },
55                                 afteredit : function (e)
56                                 {
57                                     if (e.originalValue == e.value || e.field == 'join_poitem_location_name') {
58                                         return;
59                                     }
60                                     
61                                     e.record.commit();
62                                     
63                                 },
64                                 rowdblclick : function (_self, rowIndex, e)
65                                 {
66                                     
67                                     var r = _this.grid.ds.getAt(rowIndex);
68                                     Pman.Dialog.XtuplePurchaseOrder.show( { pohead_id : r.data.join_poitem_pohead_id , office : _this.office.getValue()}, function() {
69                                         _this.grid.footer.onClick('refresh');
70                                     }); 
71                                 },
72                                 beforeedit : function (e)
73                                 {
74                                     var office = _this.office.getValue();
75                                     var local = baseURL.split('/').pop().split('.').shift();
76                                     
77                                     if(office != local){
78                                         return false;
79                                     }
80                                 },
81                                 rowclick : function (_self, rowIndex, e)
82                                 {
83                                 
84                                 }
85                             },
86                             autoExpandColumn : 'item_descrip',
87                             clicksToEdit : 1,
88                             loadMask : true,
89                             dataSource : {
90                                 xtype: 'Store',
91                                 xns: Roo.data,
92                                 listeners : {
93                                     beforeload : function (_self, o)
94                                     {
95                                         o.params = o.params || {};
96                                         
97                                         o.params._incoming_stock = 1;
98                                         
99                                         o.params.poitem_status = _this.status.getValue();
100                                         
101                                         o.params._roo_office = _this.office.getValue();
102                                         
103                                         o.params['search[location]'] = _this.location.getValue();
104                                         
105                                         o.params['search[name]'] = _this.searchBox.getValue();
106                                     
107                                     },
108                                     update : function (_self, record, operation)
109                                     {
110                                         if (operation != 'commit') {
111                                             Roo.log(operation);
112                                             return;
113                                         }
114                                         var params = {
115                                                 pohead_id : record.data.join_poitem_pohead_id,
116                                                 pohead_comments : record.data.join_poitem_pohead_comments,
117                                                 pohead_bg_va : record.data.join_poitem_pohead_bg_va,
118                                                 pohead_bg_arrival_est_day : record.data.join_poitem_pohead_bg_arrival_est_day,
119                                                 pohead_bg_available_est_day : record.data.join_poitem_pohead_bg_available_est_day,
120                                                 pohead_bg_available_latest_day : record.data.join_poitem_pohead_bg_available_latest_day,
121                                                 pohead_notes : record.data.join_poitem_pohead_notes
122                                         };
123                                             
124                                     
125                                         new Pman.Request({
126                                             method : 'POST',
127                                             url : baseURL + '/Roo/pohead',
128                                             params :  params
129                                         });
130                                         
131                                     
132                                         _this.grid.footer.onClick('refresh');
133                                     }
134                                 },
135                                 remoteSort : true,
136                                 sortInfo : { field : 'name', direction: 'ASC' },
137                                 proxy : {
138                                     xtype: 'HttpProxy',
139                                     xns: Roo.data,
140                                     method : 'GET',
141                                     url : baseURL + '/Xtuple/Roo/Poitem.php'
142                                 },
143                                 reader : {
144                                     xtype: 'JsonReader',
145                                     xns: Roo.data,
146                                     totalProperty : 'total',
147                                     root : 'data',
148                                     id : 'id',
149                                     fields : [
150                                         {
151                                             'name': 'id',
152                                             'type': 'int'
153                                         },
154                                         {
155                                             'name': 'name',
156                                             'type': 'string'
157                                         },
158                                         {
159                                             'name': 'type',
160                                             'type': 'int'
161                                         },
162                                         {
163                                             'name': 'leader',
164                                             'type': 'int'
165                                         },
166                                         {
167                                             'name': 'leader_id',
168                                             'type': 'int'
169                                         },
170                                         {
171                                             'name': 'leader_office_id',
172                                             'type': 'int'
173                                         },
174                                         {
175                                             'name': 'leader_name',
176                                             'type': 'string'
177                                         },
178                                         {
179                                             'name': 'leader_phone',
180                                             'type': 'string'
181                                         },
182                                         {
183                                             'name': 'leader_fax',
184                                             'type': 'string'
185                                         },
186                                         {
187                                             'name': 'leader_email',
188                                             'type': 'string'
189                                         },
190                                         {
191                                             'name': 'leader_company_id',
192                                             'type': 'int'
193                                         },
194                                         {
195                                             'name': 'leader_role',
196                                             'type': 'string'
197                                         },
198                                         {
199                                             'name': 'leader_active',
200                                             'type': 'int'
201                                         },
202                                         {
203                                             'name': 'leader_remarks',
204                                             'type': 'string'
205                                         },
206                                         {
207                                             'name': 'leader_passwd',
208                                             'type': 'string'
209                                         },
210                                         {
211                                             'name': 'leader_owner_id',
212                                             'type': 'int'
213                                         },
214                                         {
215                                             'name': 'leader_lang',
216                                             'type': 'string'
217                                         },
218                                         {
219                                             'name': 'leader_no_reset_sent',
220                                             'type': 'int'
221                                         },
222                                         {
223                                             'name': 'leader_action_type',
224                                             'type': 'string'
225                                         },
226                                         {
227                                             'name': 'leader_project_id',
228                                             'type': 'int'
229                                         },
230                                         {
231                                             'name': 'leader_deleted_by',
232                                             'type': 'int'
233                                         },
234                                         {
235                                             'name': 'leader_deleted_dt',
236                                             'type': 'date'
237                                         },
238                                         {
239                                             'name': 'leader_firstname',
240                                             'type': 'string'
241                                         },
242                                         {
243                                             'name': 'leader_lastname',
244                                             'type': 'string'
245                                         },
246                                         {
247                                             'name': 'leader_name_facebook',
248                                             'type': 'string'
249                                         },
250                                         {
251                                             'name': 'leader_url_blog',
252                                             'type': 'string'
253                                         },
254                                         {
255                                             'name': 'leader_url_twitter',
256                                             'type': 'string'
257                                         },
258                                         {
259                                             'name': 'leader_url_linkedin',
260                                             'type': 'string'
261                                         },
262                                         {
263                                             'name': 'leader_crm_lead_percentage',
264                                             'type': 'int'
265                                         },
266                                         {
267                                             'name': 'leader_crm_industry_id',
268                                             'type': 'int'
269                                         },
270                                         {
271                                             'name': 'leader_crm_updated_action_id',
272                                             'type': 'int'
273                                         },
274                                         {
275                                             'name': 'leader_crm_created_action_id',
276                                             'type': 'int'
277                                         },
278                                         {
279                                             'name': 'leader_crm_type_id',
280                                             'type': 'int'
281                                         }
282                                     ]
283                                 }
284                             },
285                             toolbar : {
286                                 xtype: 'Toolbar',
287                                 xns: Roo,
288                                 items : [
289                                     {
290                                         xtype: 'TextField',
291                                         xns: Roo.form,
292                                         listeners : {
293                                             specialkey : function (_self, e)
294                                             {
295                                               _this.grid.footer.onClick('first');
296                                             },
297                                             render : function (_self)
298                                             {
299                                                 _this.searchBox = _self;
300                                             }
301                                         }
302                                     },
303                                     {
304                                         xtype: 'Button',
305                                         xns: Roo.Toolbar,
306                                         listeners : {
307                                             click : function (_self, e)
308                                             {
309                                                 _this.grid.footer.onClick('first');
310                                             }
311                                         },
312                                         cls : 'x-btn-icon',
313                                         icon : rootURL + '/Pman/templates/images/search.gif'
314                                     },
315                                     {
316                                         xtype: 'Button',
317                                         xns: Roo.Toolbar,
318                                         listeners : {
319                                             click : function (_self, e)
320                                             {
321                                                 _this.searchBox.setValue('');
322                                                 _this.grid.footer.onClick('first');
323                                             }
324                                         },
325                                         cls : 'x-btn-icon',
326                                         icon : rootURL + '/Pman/templates/images/edit-clear.gif'
327                                     },
328                                     {
329                                         xtype: 'ComboBox',
330                                         xns: Roo.form,
331                                         listeners : {
332                                             render : function (_self)
333                                             {
334                                               _this.status = _self;
335                                             },
336                                             select : function (combo, record, index)
337                                             {
338                                             
339                                                 _this.grid.footer.onClick('first');
340                                             }
341                                         },
342                                         allowBlank : true,
343                                         displayField : 'fname',
344                                         editable : false,
345                                         emptyText : "Select Status",
346                                         fieldLabel : 'Status',
347                                         hiddenName : 'poitem_status',
348                                         listWidth : 200,
349                                         mode : 'local',
350                                         name : 'poitem_status',
351                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{fname}</b> </div>',
352                                         triggerAction : 'all',
353                                         value : "",
354                                         valueField : 'ftype',
355                                         width : 150,
356                                         store : {
357                                             xtype: 'SimpleStore',
358                                             xns: Roo.data,
359                                             data : [ 
360                                                 [ 'O', "Open"],
361                                                 [ 'C' , "Closed"],
362                                                 [ 'U', "Unreleased"] 
363                                             ],
364                                             fields : [  'ftype', 'fname']
365                                         }
366                                     },
367                                     {
368                                         xtype: 'ComboBox',
369                                         xns: Roo.form,
370                                         listeners : {
371                                             render : function (_self)
372                                             {
373                                                 _this.location = _self;
374                                             },
375                                             select : function (combo, record, index)
376                                             {
377                                                 _this.grid.footer.onClick('first');
378                                             }
379                                         },
380                                         allowBlank : true,
381                                         alwaysQuery : true,
382                                         displayField : 'location_name',
383                                         editable : true,
384                                         emptyText : "Select a location",
385                                         fieldLabel : 'Location',
386                                         forceSelection : true,
387                                         hiddenName : 'pohead_location_id',
388                                         listWidth : 400,
389                                         loadingText : "Searching...",
390                                         minChars : 2,
391                                         name : 'pohead_location_id',
392                                         pageSize : 200,
393                                         qtip : "Select terms",
394                                         queryParam : 'query[location_name]',
395                                         selectOnFocus : true,
396                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> </div>',
397                                         triggerAction : 'all',
398                                         typeAhead : false,
399                                         valueField : 'location_id',
400                                         width : 200,
401                                         store : {
402                                             xtype: 'Store',
403                                             xns: Roo.data,
404                                             listeners : {
405                                                 beforeload : function (_self, o){
406                                                     o.params = o.params || {};
407                                                     // set more here
408                                                      o.params.location_netable = 1;
409                                                      o.params._roo_office = _this.office.getValue();
410                                                      o.params._notinternalcompany = 1;
411                                                 }
412                                             },
413                                             remoteSort : true,
414                                             sortInfo : { direction : 'ASC', field: 'location_name' },
415                                             proxy : {
416                                                 xtype: 'HttpProxy',
417                                                 xns: Roo.data,
418                                                 method : 'GET',
419                                                 url : baseURL + '/Xtuple/Roo/location.php'
420                                             },
421                                             reader : {
422                                                 xtype: 'JsonReader',
423                                                 xns: Roo.data,
424                                                 id : 'location_id',
425                                                 root : 'data',
426                                                 totalProperty : 'total',
427                                                 fields : [{"name":"location_id","type":"int"},"location_name"]
428                                             }
429                                         }
430                                     },
431                                     {
432                                         xtype: 'ComboBox',
433                                         xns: Roo.form,
434                                         listeners : {
435                                             render : function (_self)
436                                             {
437                                               _this.office = _self;
438                                             },
439                                             select : function (combo, record, index)
440                                             {
441                                                 _this.location.reset();
442                                                 _this.grid.footer.onClick('first');
443                                             }
444                                         },
445                                         allowBlank : false,
446                                         displayField : 'office',
447                                         editable : false,
448                                         fieldLabel : 'Office',
449                                         hiddenName : 'office',
450                                         listWidth : 200,
451                                         mode : 'local',
452                                         name : 'office',
453                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{office}</b> </div>',
454                                         triggerAction : 'all',
455                                         valueField : 'office',
456                                         width : 150,
457                                         value : (function() {  
458                                             if(uiConfig.incomming_default_company){
459                                                 return uiConfig.incomming_default_company;
460                                             }
461                                             return 'hk';  
462                                         })(),
463                                         store : {
464                                             xtype: 'SimpleStore',
465                                             xns: Roo.data,
466                                             data : (function() {             
467                                                 var officeList = []; 
468                                                 if(uiConfig.incomming_default_company){
469                                                     officeList.push([uiConfig.incomming_default_company]);
470                                                 }            
471                                                 officeList.push(['hk']);             
472                                               return officeList;
473                                             })(),
474                                             fields : ['office']
475                                         }
476                                     },
477                                     {
478                                         xtype: 'Button',
479                                         xns: Roo.Toolbar,
480                                         listeners : {
481                                             click : function()
482                                             {
483                                                 var sel = _this.grid.getSelectionModel().getSelectedCell();
484                                                 if (!sel)  {
485                                                     Roo.MessageBox.alert("Error", "Select a Row");
486                                                     return;
487                                                 } 
488                                                 var s = _this.grid.ds.getAt(sel[0]);
489                                                 if(!s.data.join_poitem_pohead_id.length){
490                                                     return;
491                                                 }
492                                                 
493                                                 var office = _this.office.getValue();
494                                                 var local = baseURL.split('/').pop().split('.').shift();
495                                             
496                                                 if(office != local){
497                                                     Roo.MessageBox.alert("Error", "You cannot edit the remote date, Only local data can be edited!");
498                                                     return;
499                                                 }
500                                                 
501                                                  Pman.Dialog.XtuplePurchaseOrderEdit.show({pohead_id : s.data.join_poitem_pohead_id} , function () {
502                                                        _this.grid.footer.onClick('refresh');
503                                                  });
504                                                 
505                                             }
506                                         },
507                                         cls : 'x-btn-text-icon',
508                                         text : "Fill location",
509                                         icon : Roo.rootURL + 'images/default/tree/leaf.gif'
510                                     }
511                                 ]
512                             },
513                             footer : {
514                                 xtype: 'PagingToolbar',
515                                 xns: Roo,
516                                 displayInfo : true,
517                                 displayMsg : "Displaying poitem{0} - {1} of {2}",
518                                 emptyMsg : "No poitem found",
519                                 pageSize : 25,
520                                 items : [
521                                     {
522                                         xtype: 'Button',
523                                         xns: Roo.Toolbar,
524                                         listeners : {
525                                             click : function ()
526                                             {
527                                                 
528                                                  new Pman.Download({
529                                                     grid : _this.grid
530                                                 });
531                                                         
532                                                
533                                             }
534                                         },
535                                         cls : 'x-btn-text-icon',
536                                         text : "Download Schedule",
537                                         icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
538                                     }
539                                 ]
540                             },
541                             colModel : [
542                                 {
543                                     xtype: 'ColumnModel',
544                                     xns: Roo.grid,
545                                     dataIndex : 'join_poitem_pohead_number',
546                                     header : 'P/O No#',
547                                     sortable : true,
548                                     width : 50,
549                                     renderer : function(v) { return String.format('{0}', v); }
550                                 },
551                                 {
552                                     xtype: 'ColumnModel',
553                                     xns: Roo.grid,
554                                     dataIndex : 'brand_value',
555                                     header : 'Brand',
556                                     width : 50,
557                                     renderer : function(v) { return String.format('{0}', v); }
558                                 },
559                                 {
560                                     xtype: 'ColumnModel',
561                                     xns: Roo.grid,
562                                     dataIndex : 'item_name',
563                                     header : 'Item (SKU)',
564                                     sortable : true,
565                                     width : 70,
566                                     renderer : function(v) { return String.format('{0}', v); }
567                                 },
568                                 {
569                                     xtype: 'ColumnModel',
570                                     xns: Roo.grid,
571                                     dataIndex : 'item_descrip',
572                                     header : 'Description',
573                                     width : 300,
574                                     renderer : function(v) { return String.format('{0}', v); }
575                                 },
576                                 {
577                                     xtype: 'ColumnModel',
578                                     xns: Roo.grid,
579                                     dataIndex : 'join_poitem_pohead_comments',
580                                     header : 'B&G reference',
581                                     width : 100,
582                                     renderer : function(v) { return String.format('{0}', v); },
583                                     editor : {
584                                         xtype: 'GridEditor',
585                                         xns: Roo.grid,
586                                         field : {
587                                             xtype: 'TextField',
588                                             xns: Roo.form
589                                         }
590                                     }
591                                 },
592                                 {
593                                     xtype: 'ColumnModel',
594                                     xns: Roo.grid,
595                                     dataIndex : 'join_poitem_pohead_bg_va',
596                                     header : 'VA?',
597                                     width : 50,
598                                     renderer : function(v) { return String.format('{0}', v); },
599                                     editor : {
600                                         xtype: 'GridEditor',
601                                         xns: Roo.grid,
602                                         field : {
603                                             xtype: 'TextField',
604                                             xns: Roo.form
605                                         }
606                                     }
607                                 },
608                                 {
609                                     xtype: 'ColumnModel',
610                                     xns: Roo.grid,
611                                     dataIndex : 'join_poitem_pohead_bg_arrival_est_day',
612                                     header : 'Est. Arrival',
613                                     width : 70,
614                                     renderer : function(v) { 
615                                         if(typeof(v) == 'object'){
616                                            return String.format('{0}',v.format('d/M/Y'));
617                                         }
618                                         var d = Date.parseDate(v, 'Y-m-d');
619                                         return String.format('{0}', d ? d.format('d/M/Y') : '');
620                                     },
621                                     editor : {
622                                         xtype: 'GridEditor',
623                                         xns: Roo.grid,
624                                         field : {
625                                             xtype: 'DateField',
626                                             xns: Roo.form,
627                                             format : 'd/M/Y',
628                                             useIso : true
629                                         }
630                                     }
631                                 },
632                                 {
633                                     xtype: 'ColumnModel',
634                                     xns: Roo.grid,
635                                     dataIndex : 'join_poitem_pohead_bg_available_est_day',
636                                     header : 'Est. Avail',
637                                     width : 70,
638                                     renderer : function(v) { 
639                                         if(typeof(v) == 'object'){
640                                            return String.format('{0}',v.format('d/M/Y'));
641                                         }
642                                         var d = Date.parseDate(v, 'Y-m-d');
643                                         return String.format('{0}', d ? d.format('d/M/Y') : '');
644                                     },
645                                     editor : {
646                                         xtype: 'GridEditor',
647                                         xns: Roo.grid,
648                                         field : {
649                                             xtype: 'DateField',
650                                             xns: Roo.form,
651                                             format : 'd/M/Y',
652                                             useIso : true
653                                         }
654                                     }
655                                 },
656                                 {
657                                     xtype: 'ColumnModel',
658                                     xns: Roo.grid,
659                                     dataIndex : 'join_poitem_pohead_bg_available_latest_day',
660                                     header : 'Confirm Avail',
661                                     sortable : true,
662                                     width : 70,
663                                     renderer : function(v) { 
664                                         if(typeof(v) == 'object'){
665                                            return String.format('{0}',v.format('d/M/Y'));
666                                         }
667                                         var d = Date.parseDate(v, 'Y-m-d');
668                                         return String.format('{0}', d ? d.format('d/M/Y') : '');
669                                     },
670                                     editor : {
671                                         xtype: 'GridEditor',
672                                         xns: Roo.grid,
673                                         field : {
674                                             xtype: 'DateField',
675                                             xns: Roo.form,
676                                             format : 'd/M/Y',
677                                             useIso : true
678                                         }
679                                     }
680                                 },
681                                 {
682                                     xtype: 'ColumnModel',
683                                     xns: Roo.grid,
684                                     dataIndex : 'join_poitem_location_name',
685                                     header : 'Location',
686                                     sortable : true,
687                                     width : 100,
688                                     renderer : function(v,x,r) 
689                                     {
690                                         
691                                         return String.format('{0}', v ? v : ''); 
692                                     },
693                                     editor : {
694                                         xtype: 'GridEditor',
695                                         xns: Roo.grid,
696                                         field : {
697                                             xtype: 'ComboBox',
698                                             xns: Roo.form,
699                                             listeners : {
700                                                 beforeselect : function (combo, record, index)
701                                                 {
702                                                     var ar = _this.grid.activeEditor.record;
703                                                     
704                                                     if(record.data.location_id == ar.data.join_poitem_location_id){
705                                                         return;
706                                                     }
707                                                     
708                                                     var params = {
709                                                             poitem_id : ar.data.poitem_id,
710                                                             poitem_location_id : record.data.location_id
711                                                     };
712                                                         
713                                                 
714                                                     new Pman.Request({
715                                                         method : 'POST',
716                                                         url : baseURL + '/Roo/poitem',
717                                                         params :  params
718                                                     });
719                                                     
720                                                 
721                                                 }
722                                             },
723                                             displayField : 'location_name',
724                                             editable : true,
725                                             emptyText : "Select a location",
726                                             forceSelection : true,
727                                             hiddenName : 'join_poitem_location_id',
728                                             listWidth : 400,
729                                             loadingText : "Searching...",
730                                             minChars : 2,
731                                             name : 'join_poitem_location_name',
732                                             pageSize : 20,
733                                             qtip : "Select a location",
734                                             queryParam : 'query[location_name]',
735                                             selectOnFocus : true,
736                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> </div>',
737                                             triggerAction : 'all',
738                                             typeAhead : false,
739                                             valueField : 'location_id',
740                                             store : {
741                                                 xtype: 'Store',
742                                                 xns: Roo.data,
743                                                 listeners : {
744                                                     beforeload : function (_self, o){
745                                                         o.params = o.params || {};
746                                                         o.params.location_netable = 1;
747                                                     }
748                                                 },
749                                                 remoteSort : true,
750                                                 sortInfo : { direction : 'ASC', field: 'location_name' },
751                                                 proxy : {
752                                                     xtype: 'HttpProxy',
753                                                     xns: Roo.data,
754                                                     method : 'GET',
755                                                     url : baseURL + '/Roo/location.php'
756                                                 },
757                                                 reader : {
758                                                     xtype: 'JsonReader',
759                                                     xns: Roo.data,
760                                                     id : 'location_id',
761                                                     root : 'data',
762                                                     totalProperty : 'total',
763                                                     fields : [{"name":"location_id","type":"int"},"location_name"]
764                                                 }
765                                             }
766                                         }
767                                     }
768                                 },
769                                 {
770                                     xtype: 'ColumnModel',
771                                     xns: Roo.grid,
772                                     dataIndex : 'join_poitem_vend_name',
773                                     header : 'Originating from',
774                                     sortable : true,
775                                     width : 100,
776                                     renderer : function(v,x,r) 
777                                     {
778                                         if(v && r.data.join_poitem_pohead_vendcountry)
779                                         {
780                                             return String.format('{0}', v + ' (' + r.data.join_poitem_pohead_vendcountry + ')'); 
781                                         }
782                                         return String.format('{0}', v); 
783                                     }
784                                 },
785                                 {
786                                     xtype: 'ColumnModel',
787                                     xns: Roo.grid,
788                                     dataIndex : 'poitem_qty_ordered',
789                                     header : 'Qty',
790                                     width : 50,
791                                     renderer : function(v) { return String.format('{0}', v ? v : '' ); }
792                                 },
793                                 {
794                                     xtype: 'ColumnModel',
795                                     xns: Roo.grid,
796                                     dataIndex : 'join_poitem_pohead_orderdate',
797                                     header : 'Order Created',
798                                     sortable : true,
799                                     width : 100,
800                                     renderer : function(v) 
801                                     { 
802                                         var d = Date.parseDate(v, 'Y-m-d');
803                                         return String.format('{0}', d ? d.format('d/M/Y') : '');
804                                     }
805                                 },
806                                 {
807                                     xtype: 'ColumnModel',
808                                     xns: Roo.grid,
809                                     dataIndex : 'poitem_duedate',
810                                     header : 'ETA Date',
811                                     sortable : true,
812                                     width : 100,
813                                     renderer : function(v) 
814                                     { 
815                                        // var d = Date.parseDate(v, 'Y-m-d');
816                                         return String.format('{0}', v ? v.format('d/M/Y') : '');
817                                     }
818                                 },
819                                 {
820                                     xtype: 'ColumnModel',
821                                     xns: Roo.grid,
822                                     dataIndex : 'join_poitem_pohead_last_updated',
823                                     header : 'Last Updated',
824                                     width : 100,
825                                     renderer : function(v,x,r) 
826                                     {
827                                        if(!v){
828                                         return '';
829                                        }
830                                        var d = (new Date()).add(Date.DAY, -15);
831                                        v = new Date(v);
832                                        
833                                        if(v > d){
834                                             return '<span style="color:red">' + v.format('d/M/Y') + '</span>';
835                                        }
836                                        
837                                        return String.format('{0}', v ? v.format('d/M/Y') : '');
838                                     }
839                                 },
840                                 {
841                                     xtype: 'ColumnModel',
842                                     xns: Roo.grid,
843                                     dataIndex : 'join_poitem_pohead_notes',
844                                     header : 'Notes',
845                                     width : 100,
846                                     renderer : function(v) { return String.format('{0}', v); },
847                                     editor : {
848                                         xtype: 'GridEditor',
849                                         xns: Roo.grid,
850                                         field : {
851                                             xtype: 'TextField',
852                                             xns: Roo.form
853                                         }
854                                     }
855                                 }
856                             ]
857                         }
858                     }
859                 ],
860                 center : {
861                     xtype: 'LayoutRegion',
862                     xns: Roo
863                 }
864             }
865         };
866     }
867 });