text changes to registration mail content
[namibia] / public / templates / page / valuationcalendar.js
1 var template_valuationcalendar = function( static )
2 {
3         this.static = static;
4         this.elements = {
5
6                 };
7         this.construct = function()
8         {
9         $('#frmModal').modal('hide');
10         $('#modalFormContent').html('Loading...');
11
12         //console.log('App.userData',App.userData);
13
14         if(undefined != App.userData)
15         {
16             var userId = App.userData.id
17
18             App.Ajax.JSON({
19                     "url"  : 'workspace/get-calendar-events',
20                     "data" : {'userId' : userId}
21                 },
22                 $.proxy(function(response) {
23
24                     //console.log('response',response);
25
26                 var calendarEvents = [];
27
28                 $.each( response, function( responseKey, responseValue ) {
29
30                     $.each( responseValue, function( responseK, responseV ) {
31
32                         var startDate = responseV.start.replace("SAST", "T");
33                         var endDate = responseV.end.replace("SAST", "T");
34
35                         calendarEvents.push(
36                             {
37                                 'title'                                 : responseV.title,
38                                 'start'                                 : startDate,
39                                 'end'                               : endDate,
40                                 //'url'                                         : '/#/appointmentedit',
41                                 'id'                            : responseV.appointmentId,
42                                 'appointmentCompleted'  : responseV.appointmentCompleted,
43                                 'appointmentCancelled'  : responseV.appointmentCancelled
44                             }
45                         );
46
47                     });
48                 });
49                 this.createCalendar(calendarEvents);
50
51                 },this),
52                 $.proxy(function(response) {
53                     console.log('App.Notification.remove Error', response);
54                 },this)
55             );
56         }
57
58
59                 
60         };
61
62     this.createCalendar = $.proxy(function(calendarEvents) {
63
64         var d = new Date();
65         var strDate = d.getFullYear() + "/" + (d.getMonth()+1) + "/" + d.getDate();
66
67         //console.log('calendarEvents',calendarEvents);
68
69         $('#calendar').fullCalendar({
70             defaultDate: strDate,
71             editable: false,
72             header: {
73                 left: 'prev,next today',
74                 center: 'title',
75                 right: 'agendaWeek,agendaDay'
76             },
77             height: 999999999,
78             defaultView: 'agendaWeek',
79             allDaySlot:false,
80             eventLimit: false, // allow "more" link when too many events
81             events: calendarEvents,
82             disableResizing:true,
83             minTime: "07:00:00",
84             maxTime: "21:00:00",
85             weekends: false,
86             eventRender: function(event, element) {
87                 if (event.appointmentCancelled == true) {
88                     element.css('background-color', '#d42e30');
89                 }
90                 if (event.appointmentCompleted == true) {
91                     element.css('background-color', '#333');
92                 }
93             },
94             eventClick: $.proxy(function(event) {
95
96                 console.log('event',event);
97
98                 console.log('calendarEvents.id',event.id);
99
100                 _w.appointmentId = event.id;
101
102                 App.Template.register(
103                     'appointmentedit', "page", 'appointmentedit', 'modalFormContent', {},
104                     $.proxy( this.renderPage, this )
105                 );
106             }, this)
107         });
108
109         $('.fc-center').hide();
110     },this);
111
112     this.renderPage = function( id, pageName )
113     {
114         _t[pageName].publish();
115         $('#frmModal').modal({
116             show: true
117         });
118     };
119
120         this.destruct = function()
121         {
122
123         };
124 };