Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
FullCalendar.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
40  class FullCalendar extends ZurmoWidget
41  {
42  public $inputId;
43 
44  public $startDate;
45 
46  public $endDate;
47 
48  public $defaultView;
49 
53  public function init()
54  {
55  parent::init();
56  }
57 
58  public function run()
59  {
60  $defaultView = $this->defaultView;
61  $inputId = $this->inputId;
62  $eventsUrl = Yii::app()->createUrl('calendars/default/getEvents');
63  //Set the goto date for calendar
64  $startDate = $this->startDate;
65  $startDateAttr = explode('-', $startDate);
66  $year = $startDateAttr[0];
67  $month = intval($startDateAttr[1]) - 1;
68  $day = intval($startDateAttr[2]);
69 
70  $currentYear = date('Y');
71  $currentMonth = intval(date('m')) - 1;
72  $currentDay = date('d');
73 
74  $maxCount = CalendarItemsDataProvider::MAXIMUM_CALENDAR_ITEMS_COUNT;
75 
76  //Register full calendar script and css
77  self::registerFullCalendarScriptAndCss();
78 
79  //Register qtip for event render
80  $qtip = new ZurmoTip();
81  $qtip->addQTip(".fc-event");
82 
83  $cs = Yii::app()->getClientScript();
84  $loadingText = Zurmo::t('Core', 'Loading..');
85  // Begin Not Coding Standard
86 
87  $script = "$(document).on('ready', function() {
88  $('#{$inputId}').fullCalendar({
89  editable: false,
90  header: {
91  left: 'prev,next today',
92  center: 'title',
93  right: 'month,basicWeek,basicDay'
94  },
95  defaultView: '{$defaultView}',
96  firstDay :1,
97  ignoreTimeZone:false,
98  lazyFetching : false,
99  loading: function(bool)
100  {
101  if (bool)
102  {
103  $(this).makeLargeLoadingSpinner(true, '#{$inputId}');
104  }
105  else
106  {
107  $(this).makeLargeLoadingSpinner(false, '#{$inputId}');
108  }
109  },
110  eventSources: [
111  getCalendarEvents('{$eventsUrl}', '{$inputId}')
112  ],
113  eventRender: function(event, element, view) {
114  element.qtip({
115  content: {
116  text: '{$loadingText}',
117  ajax: {
118  url: event.description,
119  type: 'get'
120  },
121  title: {
122  text: event.title,
123  button: 'Close'
124  }
125  },
126  style: {classes:'calendar-event-tooltip'},
127  show:{
128  event: 'click'
129  },
130  hide: {
131  event: 'false'
132  },
133  position: {
134  my: 'bottom center',
135  at: 'top center',
136  target: 'mouse',
137  viewport: $('#calendar'),
138  adjust: {
139  mouse: false,
140  scroll: false
141  }
142  }
143  });
144  },
145  timeFormat: {
146  'month' : '',
147  'basicDay': 'h:mm-{h:mm}tt',
148  'basicWeek': 'h:mm-{h:mm}tt'
149  }
150  });
151  $('#{$inputId}').fullCalendar('gotoDate', {$year}, {$month}, {$day});
152  $('.fc-button-today').click(function() {
153  $('#{$inputId}').fullCalendar('changeView', 'basicDay');
154  $('#{$inputId}').fullCalendar('gotoDate', {$currentYear}, {$currentMonth}, {$currentDay});
155  });
156  });";
157 
158  // End Not Coding Standard
159  $cs->registerScript('loadCalendarScript', $script, ClientScript::POS_END);
160  }
161 
165  protected static function registerFullCalendarScriptAndCss()
166  {
167  $cs = Yii::app()->getClientScript();
168  $baseScriptUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.core.widgets.assets'));
169  $cs->registerScriptFile($baseScriptUrl . '/fullCalendar/fullcalendar.min.js', ClientScript::POS_HEAD);
170  $cs->registerCssFile($baseScriptUrl . '/fullCalendar/fullcalendar.css');
171  }
172  }
173 ?>
static registerFullCalendarScriptAndCss()
Generated on Sun Jul 12 2020 07:10:28
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.