noalyss Version-9
Public Member Functions | Static Public Member Functions | Data Fields | Static Private Attributes
Calendar Class Reference

Display the calendar. More...

+ Collaboration diagram for Calendar:

Public Member Functions

 __construct ()
 
 display ($p_type, $p_notitle)
 display a calendar after a call to Calendar::fill More...
 
 fill_from_action (&$p_array, $p_style)
 fill the array given as parameter with the data from action_gestion More...
 
 fill_from_todo (&$p_array, $p_style)
 fill the array given as parameter with the data from todo More...
 
 get_preference ()
 get the periode from the preference of the current user change the value of default_periode to today More...
 
 set_month_year ()
 set correctly the month and the year with the default_periode More...
 
 set_periode ($p_per)
 set the periode to the parameter, change the value of $this->default_periode there is no check on the periode More...
 
 zoom ($p_type, $p_notitle)
 
 zoom_calendar ($notitle)
 zoom the calendar More...
 
 zoom_list ($notitle)
 Display the next events for 30 days todo list + action to remind. More...
 

Static Public Member Functions

static test_me ()
 

Data Fields

 $action
 
 $action_div
 
 $current_date
 
 $day
 
 $default_periode
 
 $hour
 
 $month
 
 $str_name
 
 $title
 
 $year
 

Static Private Attributes

static $nb_day =array(31,28,31,30,31,30,31,31,30,31,30,31)
 

Detailed Description

Display the calendar.

Definition at line 31 of file calendar.class.php.

Constructor & Destructor Documentation

◆ __construct()

Calendar::__construct ( )

Definition at line 47 of file calendar.class.php.

48 {
49 /* get the current month */
50 $this->current_date=getdate();
51 $this->month=$this->current_date['mon'];
52 $this->day=self::$nb_day[$this->month-1];
53 $this->year=$this->current_date['year'];
54 $this->action_div=array();
55 $this->action=array();
56 $this->title=array();
57
58 if ( $this->year % 4 == 0 && $this->month=2)
59 $this->day=29;
60 }
$anc_filter title

References title.

Member Function Documentation

◆ display()

Calendar::display (   $p_type,
  $p_notitle 
)

display a calendar after a call to Calendar::fill

Parameters
$p_typelong or short
Returns
HTML String

Definition at line 180 of file calendar.class.php.

181 {
182 global $g_user;
183 if ($p_type != 'long' && $p_type != 'short') {
184 throw new Exception("Calendar::display, unknow type");
185 }
186 $exercice_user=$g_user->get_exercice();
187 /* day */
188 $cell=array();
189 for ($i=0;$i<42;$i++)
190 {
191 $cell[$i]="";
192 }
193 $this->set_month_year();
194 /* weekday */
195 $week=array(_('Dimanche'),_('Lundi'),_('Mardi'),_('Mercredi'),_('Jeudi'),_('Vendredi'),_('Samedi'));
196
197 $notitle=$p_notitle;
198
199 $this->fill_from_action($cell,$p_type);
200 $this->fill_from_todo($cell,$p_type);
201 $wMonth=new ISelect('per');
203 $wMonth->value=$cn->make_array("select p_id,to_char(p_start,'MM/YYYY') from parm_periode where p_exercice = '$exercice_user' order by p_start");
204 $wMonth->selected=$this->default_periode;
205 $wMonth->javascript="onchange=change_month(this)";
206 $wMonth->set_attribute('gDossier',dossier::id());
207 $wMonth->set_attribute('type_display',$p_type);
208 $wMonth->set_attribute('notitle',$notitle);
209 $month_year=$wMonth->input().$wMonth->get_js_attr();
210 ob_start();
211 $zoom=($p_type=='short')?0:1;
212
213 require_once NOALYSS_TEMPLATE.'/calendar.php';
214
215 if (count($this->action_div) > 0)
216 {
217 foreach ($this->action_div as $day)
218 {
219 echo $day;
220 }
221 }
222 $ret=ob_get_contents();
223 ob_end_clean();
224 return $ret;
225 }
global $g_user
if no group available , then stop
$input_from id
Definition: balance.inc.php:63
$week
Definition: calendar.php:35
fill_from_action(&$p_array, $p_style)
fill the array given as parameter with the data from action_gestion
fill_from_todo(&$p_array, $p_style)
fill the array given as parameter with the data from todo
set_month_year()
set correctly the month and the year with the default_periode
static connect()
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...

References $cn, $day, $default_periode, $g_user, $i, $notitle, $p_type, $ret, $week, Dossier\connect(), fill_from_action(), fill_from_todo(), id, and set_month_year().

Referenced by fill_from_action().

+ Here is the call graph for this function:

◆ fill_from_action()

Calendar::fill_from_action ( $p_array,
  $p_style 
)

fill the array given as parameter with the data from action_gestion

Parameters
$p_arrayarray of the date of the month
$p_styleis either short or long, short: for a small title, long for a complete one

Definition at line 67 of file calendar.class.php.

68 {
69 global $g_user;
70 $profile=$g_user->get_profile();
71
73 $sql="select ag_id,to_char(ag_remind_date,'DD')::integer as ag_timestamp_day,ag_title,ag_hour,
74 coalesce(name,'interne') as str_name
75 ".
76 " from action_gestion ".
77 " left join vw_fiche_name on (f_id=f_id_dest) ".
78 " where ".
79 " to_char(ag_remind_date,'MM')::integer=$1 ".
80 " and to_char(ag_remind_date,'YYYY')::integer=$2 ".
81 " and ag_dest in (select p_granted from user_sec_action_profile where p_id =$3)
82 and ag_state IN (2, 3)
83 ";
84
85 $array=$cn->get_array($sql,array($this->month,$this->year,$profile));
86 for ($i=0;$i<count($array);$i++)
87 {
88 $ind=$array[$i]['ag_timestamp_day'];
89 $this->action[$ind][]=$array[$i]['ag_id'];
90 $this->title[$ind][]=$array[$i]['ag_title'];
91 $this->hour[$ind][]=$array[$i]['ag_hour'];
92 $this->str_name[$ind][]=$array[$i]['str_name'];
93
94 }
95 /*
96 * Fill foreach day
97 */
98 if ( $p_style == "short")
99 {
100 foreach ($this->action as $day=>$aAction)
101 {
102 if ($p_array[$day]=="") {
103 $p_array[$day]='<span class="smallbutton" onclick="display_task(\'tsk'.$day.'\');">'." [ ".count($aAction)." ] ".'</span>';
104 }
105 $this->action_div[$day]='<div id="tsk'.$day.'" class="inner_box" style="width:200;display:none">';
106 $this->action_div[$day].=HtmlInput::title_box($day."/".$this->month."/".$this->year, "tsk".$day, "hide");
107 $this->action_div[$day].="<ol>";
108 for ($i=0;$i<count($aAction);$i++)
109 {
110 $this->action_div[$day].='<li>'.HtmlInput::detail_action($aAction[$i],
111 $this->hour[$day][$i]." ".
112 $this->str_name[$day][$i]." ".
113 $this->title[$day][$i]).'</li>';
114 }
115 $this->action_div[$day].='</ol>';
116 $this->action_div[$day].=' <p style="text-align: center">';
117 $this->action_div[$day].=HtmlInput::button_hide('tsk'.$day);
118 $this->action_div[$day].='</p>';
119 $this->action_div[$day].='</div>';
120 }
121 }
122 else if ( $p_style == "long")
123 {
124 foreach ($this->action as $day=>$aAction)
125 {
126 $p_array[$day].="<ol>";
127 for ($i=0;$i<count($aAction);$i++)
128 {
129 $p_array[$day].='<li>'.$this->hour[$day][$i]." ".hb($this->str_name[$day][$i]).'&rarr;'.HtmlInput::detail_action($aAction[$i], $this->hour[$day][$i]." ".$this->title[$day][$i]).'</li>';
130 }
131 $p_array[$day].='</ol>';
132 }
133 }
134 }
return false Description text align
for($i=0;$i<=6;$i++) $ind
Definition: calendar.php:34
display($p_type, $p_notitle)
display a calendar after a call to Calendar::fill
$desc width

References $array, $cn, $day, $g_user, $i, $ind, $p_array, $profile, $sql, align, Dossier\connect(), display(), title, and width.

Referenced by display(), and zoom_calendar().

+ Here is the call graph for this function:

◆ fill_from_todo()

Calendar::fill_from_todo ( $p_array,
  $p_style 
)

fill the array given as parameter with the data from todo

Parameters
$p_arrayarray of the date of the month
$p_styleis either short or long, short: for a small title, long for a complete one

Definition at line 140 of file calendar.class.php.

141 {
143 if ($p_style=="short")
144 {
145 $sql="select count(*) as nb,to_char(tl_date,'DD')::integer as tl_date_day ".
146 " from todo_list ".
147 " where ".
148 " to_char(tl_date,'MM')::integer=$1 ".
149 " and to_char(tl_date,'YYYY')::integer=$2 ".
150 " and use_login=$3 group by to_char(tl_date,'DD')::integer ";
151 $array=$cn->get_array($sql,array($this->month,$this->year,$_SESSION[SESSION_KEY.'g_user']));
152 for ($i=0;$i<count($array);$i++)
153 {
154 $ind=$array[$i]['tl_date_day'];
155 $p_array[$ind].="<span style=\"display:block\" class=\"todo\">".h($array[$i]['nb'])." "._('Notes').'</span>';
156 }
157 } else if ($p_style=="long")
158 {
159 $sql="select to_char(tl_date,'DD')::integer as tl_date_day,tl_title ".
160 " from todo_list ".
161 " where ".
162 " to_char(tl_date,'MM')::integer=$1 ".
163 " and to_char(tl_date,'YYYY')::integer=$2 ".
164 " and use_login=$3 ";
165 $array=$cn->get_array($sql,array($this->month,$this->year,$_SESSION[SESSION_KEY.'g_user']));
166 for ($i=0;$i<count($array);$i++)
167 {
168 $ind=$array[$i]['tl_date_day'];
169
170 $p_array[$ind].="<span style=\"display:block\" class=\"todo\">".h($array[$i]['tl_title']).'</span>';
171 }
172 }
173 }

References $array, $i, $ind, and $p_array.

Referenced by display(), and zoom_calendar().

◆ get_preference()

Calendar::get_preference ( )

get the periode from the preference of the current user change the value of default_periode to today

Returns
$this->default_periode

Definition at line 245 of file calendar.class.php.

246 {
247 global $g_user;
249 $today=date('d.m.Y');
250 $p_id=$cn->get_value("
251 select p_id from parm_periode
252 where
253 p_start <= to_date($1,'DD.MM.YYYY')
254 and
255 p_end >= to_date($1,'DD.MM.YYYY')",
256 array($today));
257 if ( $p_id == '')
258 {
259 $p_id=$g_user->get_periode();
260 }
261 $this->default_periode=$p_id;
262 return $p_id;
263 }
$cal default_periode

References $cn, $g_user, $p_id, Dossier\connect(), and default_periode.

+ Here is the call graph for this function:

◆ set_month_year()

Calendar::set_month_year ( )

set correctly the month and the year with the default_periode

Definition at line 229 of file calendar.class.php.

230 {
232 $array=$cn->get_array("select to_char(p_start,'MM') as month, to_char(p_start,'YYYY') as year ".
233 " from parm_periode where p_id=$1",array($this->default_periode));
234 $this->month=(int)$array[0]['month'];
235 $this->year=(int)$array[0]['year'];
236 $this->day=self::$nb_day[$this->month-1];
237 if ( $this->year % 4 == 0 && $this->month==2)
238 $this->day=29;
239 }

References $array, $cn, Dossier\connect(), and default_periode.

Referenced by display(), and zoom_calendar().

+ Here is the call graph for this function:

◆ set_periode()

Calendar::set_periode (   $p_per)

set the periode to the parameter, change the value of $this->default_periode there is no check on the periode

Definition at line 268 of file calendar.class.php.

269 {
270 $this->default_periode=$p_per;
271 }

References default_periode.

◆ test_me()

static Calendar::test_me ( )
static

Definition at line 365 of file calendar.class.php.

365 {
366
367 }

◆ zoom()

Calendar::zoom (   $p_type,
  $p_notitle 
)

Definition at line 352 of file calendar.class.php.

353 {
354 switch ($p_type)
355 {
356 case 'cal':
357 return $this->zoom_calendar($p_notitle);
358 break;
359 case 'list':
360 return $this->zoom_list($p_notitle);
361 break;
362 }
363 }
zoom_calendar($notitle)
zoom the calendar
zoom_list($notitle)
Display the next events for 30 days todo list + action to remind.

References $p_type, zoom_calendar(), and zoom_list().

+ Here is the call graph for this function:

◆ zoom_calendar()

Calendar::zoom_calendar (   $notitle)

zoom the calendar

Definition at line 275 of file calendar.class.php.

276 {
277 global $g_user;
278 $exercice_user=$g_user->get_exercice();
279 /* day */
280 $cell=array();
281 for ($i=0;$i<42;$i++)
282 {
283 $cell[$i]="";
284 }
285 $this->set_month_year();
286 /* weekday */
287 $week=array(_('Dimanche'),_('Lundi'),_('Mardi'),_('Mercredi'),_('Jeudi'),_('Vendredi'),_('Samedi'));
288
289 $this->fill_from_action($cell,"long");
290 $this->fill_from_todo($cell,"long");
291 $wMonth=new ISelect('per_div');
293 $wMonth->value=$cn->make_array("select p_id,to_char(p_start,'MM/YYYY') from parm_periode where p_exercice = $1 order by p_start"
294 ,0,array($exercice_user));
295 $wMonth->selected=$this->default_periode;
296 $wMonth->javascript=sprintf("onchange=calendar_zoom({gDossier:%d,invalue:'%s',outvalue:'%s',distype:'%s',notitle:%d})",
297 dossier::id(),'per_div','calendar_zoom_div','cal',$notitle);
298 $wMonth->set_attribute('gDossier',dossier::id());
299 $month_year=$wMonth->input().$wMonth->get_js_attr();
300 ob_start();
301 $zoom=1;
302 require_once NOALYSS_TEMPLATE.'/calendar.php';
303
304 if (count($this->action_div) > 0)
305 {
306 foreach ($this->action_div as $day)
307 {
308 echo $day;
309 }
310 }
311 $ret=ob_get_contents();
312 ob_end_clean();
313 return $ret;
314 }

References $cn, $day, $default_periode, $g_user, $i, $notitle, $ret, $week, Dossier\connect(), fill_from_action(), fill_from_todo(), id, and set_month_year().

Referenced by zoom().

+ Here is the call graph for this function:

◆ zoom_list()

Calendar::zoom_list (   $notitle)

Display the next events for 30 days todo list + action to remind.

Definition at line 319 of file calendar.class.php.

320 {
321 global $g_user;
323 $profile=$g_user->get_profile();
324
325 // Get the event from now and before 30 before
326 // union the TODO list
327 $sql = "
328 select ag_id,ag_remind_date,to_char(ag_remind_date,'DD.MM.YY') as str_date,ag_title,ag_hour,
329 coalesce(name,'interne') as str_name,
330 case when ag_remind_date < now() then 'R'
331 when ag_remind_date = now() then 'N'
332 else 'F'
333 end as status,
334 coalesce (ag_remind_date::date,current_date) - current_date as delta_days
335 from action_gestion
336 left join vw_fiche_name on (f_id=f_id_dest)
337 where
338 ag_dest in (select p_granted from user_sec_action_profile where p_id =$1)
339 and ag_state IN (2, 3)
340 and ag_remind_date is not null
341 order by ag_remind_date,ag_hour
342 ";
343 $a_event=$cn->get_array($sql,array($profile));
344 ob_start();
345 require_once NOALYSS_TEMPLATE.'/calendar-list.php';
346 $ret=ob_get_clean();
347 return $ret;
348
349
350 }

References $cn, $g_user, $profile, $ret, $sql, and Dossier\connect().

Referenced by zoom().

+ Here is the call graph for this function:

Field Documentation

◆ $action

Calendar::$action

Definition at line 41 of file calendar.class.php.

◆ $action_div

Calendar::$action_div

Definition at line 38 of file calendar.class.php.

◆ $current_date

Calendar::$current_date

Definition at line 33 of file calendar.class.php.

◆ $day

Calendar::$day

Definition at line 36 of file calendar.class.php.

Referenced by display(), fill_from_action(), and zoom_calendar().

◆ $default_periode

Calendar::$default_periode

Definition at line 45 of file calendar.class.php.

Referenced by display(), and zoom_calendar().

◆ $hour

Calendar::$hour

Definition at line 44 of file calendar.class.php.

◆ $month

Calendar::$month

Definition at line 35 of file calendar.class.php.

◆ $nb_day

Calendar::$nb_day =array(31,28,31,30,31,30,31,31,30,31,30,31)
staticprivate

Definition at line 34 of file calendar.class.php.

◆ $str_name

Calendar::$str_name

Definition at line 42 of file calendar.class.php.

◆ $title

Calendar::$title

Definition at line 43 of file calendar.class.php.

◆ $year

Calendar::$year

Definition at line 37 of file calendar.class.php.


The documentation for this class was generated from the following file: