diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 04c8c9bc766..9e2c39dd1ec 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -29,6 +29,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'); require_once(DOL_DOCUMENT_ROOT."/lib/agenda.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); if (!$user->admin) accessforbidden(); @@ -54,7 +55,9 @@ if ($actionsave) { $db->begin(); - $res=dolibarr_set_const($db,'ENABLE_AGENDA_EXT'.$i,trim(GETPOST("ENABLE_AGENDA_EXT".$i)),'chaine',0); + $disableext=GETPOST("AGENDA_DISABLE_EXT"); + if ($disableext) $disableext=0; else $disableext=1; + $res=dolibarr_set_const($db,'AGENDA_DISABLE_EXT',$disableext,'chaine',0); $i=1; $error=0; @@ -115,7 +118,9 @@ dol_fiche_head($head, 'extsites', $langs->trans("Agenda")); print '
'; -print $langs->trans("ExtSitesEnableThisTool").' '.$form->selectyesno("ENABLE_AGENDA_EXT",(GETPOST("ENABLE_AGENDA_EXT"))?GETPOST("ENABLE_AGENDA_EXT"):$conf->global->ENABLE_AGENDA_EXT,1).'

'; +$selectedvalue=(GETPOST("AGENDA_DISABLE_AGENDA"))?GETPOST("AGENDA_DISABLE_EXT"):$conf->global->AGENDA_DISABLE_EXT; +if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1; +print $langs->trans("ExtSitesEnableThisTool").' '.$form->selectyesno("AGENDA_DISABLE_EXT",$selectedvalue,1).'

'; $var=false; print ""; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index dcb2ff5d0cd..541a94cb925 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -638,7 +638,8 @@ class ActionComm extends CommonObject if ($cachedelay) { $nowgmt = dol_now(); - if (filemtime($outputfile) > ($nowgmt - $cachedelay)) + include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); + if (dol_filemtime($outputfile) > ($nowgmt - $cachedelay)) { dol_syslog("ActionComm::build_exportfile file ".$outputfile." is not older than now - cachedelay (".$nowgmt." - ".$cachedelay."). Build is canceled"); $buildfile = false; diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index 67857289cd9..5ba1849f68f 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -30,7 +30,7 @@ class ical var $event_count; // Number of Events var $todo_count; // Number of TODOs var $last_key; //Help variable save last key (multiline string) - + /** * Read text file, icalender text file * @@ -40,9 +40,9 @@ class ical function read_file($file) { $this->file = $file; - $file_text = join ("", file ($file)); //load file + $file_text = join ("", file ($file)); //load file $file_text = preg_replace("/[\r\n]{1,} ([:;])/","\\1",$file_text); - + return $file_text; // return all text } @@ -55,7 +55,7 @@ class ical { return $this->event_count; } - + /** * Returns the number of ToDo * @@ -65,7 +65,7 @@ class ical { return $this->todo_count; } - + /** * Translate Calendar * @@ -76,16 +76,17 @@ class ical { $this->cal = array(); // new empty array - $this->event_count = -1; + $this->event_count = -1; // read FILE text $this->file_text = $this->read_file($uri); $this->file_text = preg_split("[\n]", $this->file_text); - + // is this text vcalendar standart text ? on line 1 is BEGIN:VCALENDAR if (!stristr($this->file_text[0],'BEGIN:VCALENDAR')) return 'error not VCALENDAR'; + $insidealarm=0; foreach ($this->file_text as $text) { $text = trim($text); // trim one line @@ -93,7 +94,7 @@ class ical { // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin list($key, $value) = $this->retun_key_value($text); - + switch ($text) // search special string { case "BEGIN:VTODO": @@ -106,6 +107,11 @@ class ical $type = "VEVENT"; break; + case "BEGIN:VFREEBUSY": + $this->freebusy_count = $this->freebusy_count+1; // new event begin + $type = "VFREEBUSY"; + break; + case "BEGIN:VCALENDAR": // all other special string case "BEGIN:DAYLIGHT": case "BEGIN:VTIMEZONE": @@ -115,6 +121,7 @@ class ical case "END:VTODO": // end special text - goto VCALENDAR key case "END:VEVENT": + case "END:VFREEBUSY": case "END:VCALENDAR": case "END:DAYLIGHT": @@ -123,17 +130,25 @@ class ical $type = "VCALENDAR"; break; + // Manage VALARM that are inside a VEVENT to avoid fields of VALARM to overwrites fields of VEVENT + case "BEGIN:VALARM": + $insidealarm=1; + break; + case "END:VALARM": + $insidealarm=0; + break; + default: // no special string - $this->add_to_array($type, $key, $value); // add to array + if (! $insidealarm) $this->add_to_array($type, $key, $value); // add to array break; } } } return $this->cal; } - + /** - * Add to $this->ical array one value and key. Type is VTODO, VEVENT, VCALENDAR ... . + * Add to $this->ical array one value and key. Type is VTODO, VEVENT, VFREEBUSY, VCALENDAR ... . * * @param string $type * @param string $key @@ -141,12 +156,16 @@ class ical */ function add_to_array($type, $key, $value) { + + //print 'type='.$type.' key='.$key.' value='.$value.'
'."\n"; + if ($key == false) { $key = $this->last_key; switch ($type) { case 'VEVENT': $value = $this->cal[$type][$this->event_count][$key].$value;break; + case 'VFREEBUSY': $value = $this->cal[$type][$this->freebusy_count][$key].$value;break; case 'VTODO': $value = $this->cal[$type][$this->todo_count][$key].$value;break; } } @@ -154,12 +173,16 @@ class ical if (($key == "DTSTAMP") or ($key == "LAST-MODIFIED") or ($key == "CREATED")) $value = $this->ical_date_to_unix($value); if ($key == "RRULE" ) $value = $this->ical_rrule($value); - if (stristr($key,"DTSTART") or stristr($key,"DTEND") or stristr($key,"DTSTART;VALUE=DATE") or stristr($key,"DTEND;VALUE=DATE")) + if (stristr($key,"DTSTART") or stristr($key,"DTEND") or stristr($key,"DTSTART;VALUE=DATE") or stristr($key,"DTEND;VALUE=DATE")) { if (stristr($key,"DTSTART;VALUE=DATE") or stristr($key,"DTEND;VALUE=DATE")) + { list($key,$value) = array($key,$value); + } else + { list($key,$value) = $this->ical_dt_date($key,$value); + } } switch ($type) @@ -172,15 +195,19 @@ class ical $this->cal[$type][$this->event_count][$key] = $value; break; + case "VFREEBUSY": + $this->cal[$type][$this->freebusy_count][$key] = $value; + break; + default: $this->cal[$type][$key] = $value; break; } $this->last_key = $key; } - + /** - * Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value"); + * Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value"); * * @param string $text * @return array @@ -188,19 +215,19 @@ class ical function retun_key_value($text) { preg_match("/([^:]+)[:]([\w\W]+)/", $text, $matches); - + if (empty($matches)) { return array(false,$text); - } - else + } + else { $matches = array_splice($matches, 1, 2); return $matches; } } - + /** * Parse RRULE return array * @@ -210,7 +237,7 @@ class ical function ical_rrule($value) { $rrule = explode(';',$value); - foreach ($rrule as $line) + foreach ($rrule as $line) { $rcontent = explode('=', $line); $result[$rcontent[0]] = $rcontent[1]; @@ -228,17 +255,16 @@ class ical $ical_date = str_replace('T', '', $ical_date); $ical_date = str_replace('Z', '', $ical_date); + $ntime=0; // TIME LIMITED EVENT - preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $ical_date, $date); + if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $ical_date, $date)) + $ntime=dol_mktime($date[4], $date[5], $date[6], $date[2],$date[3], $date[1], true); - // UNIX timestamps can't deal with pre 1970 dates - if ($date[1] <= 1970) - { - $date[1] = 1971; - } - return mktime($date[4], $date[5], $date[6], $date[2],$date[3], $date[1]); + //if (empty($date[4])) print 'Error bad date: '.$ical_date.' - date1='.$date[1]; + //print dol_print_date($ntime,'dayhour');exit; + return $ntime; // ntime is a GTM time } - + /** * Return unix date from iCal date format * @@ -252,21 +278,21 @@ class ical // Analyse TZID $temp = explode(";",$key); - + if (empty($temp[1])) // not TZID { $value = str_replace('T', '', $value); return array($key,$value); } - // adding $value and $tzid + // adding $value and $tzid $key = $temp[0]; $temp = explode("=", $temp[1]); $return_value[$temp[0]] = $temp[1]; $return_value['unixtime'] = $value; - + return array($key,$return_value); } - + /** * Return sorted eventlist as array or false if calenar is empty * @@ -279,12 +305,12 @@ class ical { usort($temp, array(&$this, "ical_dtstart_compare")); return $temp; - } else + } else { return false; } } - + /** * Compare two unix timestamp * @@ -294,9 +320,9 @@ class ical */ function ical_dtstart_compare($a, $b) { - return strnatcasecmp($a['DTSTART']['unixtime'], $b['DTSTART']['unixtime']); + return strnatcasecmp($a['DTSTART']['unixtime'], $b['DTSTART']['unixtime']); } - + /** * Return eventlist array (not sort eventlist array) * @@ -306,7 +332,17 @@ class ical { return $this->cal['VEVENT']; } - + + /** + * Return eventlist array (not sort eventlist array) + * + * @return array + */ + function get_freebusy_list() + { + return $this->cal['VFREEBUSY']; + } + /** * Return todo array (not sort todo array) * @@ -316,7 +352,7 @@ class ical { return $this->cal['VTODO']; } - + /** * Return base calendar data * @@ -326,7 +362,7 @@ class ical { return $this->cal['VCALENDAR']; } - + /** * Return array with all data * @@ -337,4 +373,4 @@ class ical return $this->cal; } } -?> \ No newline at end of file +?> \ No newline at end of file diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index b04a3fb859f..041e6f66102 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -21,10 +21,10 @@ */ /** - * \file htdocs/comm/action/index.php - * \ingroup agenda - * \brief Home page of calendar events - * \version $Id$ + * \file htdocs/comm/action/index.php + * \ingroup agenda + * \brief Home page of calendar events + * \version $Id$ */ require("../../main.inc.php"); @@ -58,11 +58,11 @@ $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); $canedit=1; if (! $user->rights->agenda->myactions->read) accessforbidden(); if (! $user->rights->agenda->allactions->read) $canedit=0; -if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me +if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me { - $filtera=$user->id; - $filtert=$user->id; - $filterd=$user->id; + $filtera=$user->id; + $filtert=$user->id; + $filterd=$user->id; } $action=GETPOST('action','alpha'); @@ -89,22 +89,22 @@ if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MA */ if (GETPOST("viewlist")) { - $param=''; - foreach($_POST as $key => $val) - { - if ($key=='token') continue; - $param.='&'.$key.'='.urlencode($val); - } - //print $param; - header("Location: ".DOL_URL_ROOT.'/comm/action/listactions.php?'.$param); - exit; + $param=''; + foreach($_POST as $key => $val) + { + if ($key=='token') continue; + $param.='&'.$key.'='.urlencode($val); + } + //print $param; + header("Location: ".DOL_URL_ROOT.'/comm/action/listactions.php?'.$param); + exit; } if ($action=='delete_action') { - $event = new ActionComm($db); - $event->fetch($actionid); - $result=$event->delete(); + $event = new ActionComm($db); + $event->fetch($actionid); + $result=$event->delete(); } @@ -145,11 +145,11 @@ if (empty($action) || $action=='show_month') } if ($action=='show_week') { - $prev = dol_get_first_day_week($day, $month, $year); - $prev_year = $prev['prev_year']; + $prev = dol_get_first_day_week($day, $month, $year); + $prev_year = $prev['prev_year']; $prev_month = $prev['prev_month']; $prev_day = $prev['prev_day']; - $first_day = $prev['first_day']; + $first_day = $prev['first_day']; $week = $prev['week']; @@ -215,11 +215,11 @@ if (empty($action) || $action=='show_month') } if ($action=='show_week') { - $nav ="".img_previous($langs->trans("Previous"))."\n"; - $nav.=" ".dol_print_date(dol_mktime(0,0,0,$month,1,$year),"%Y").", ".$langs->trans("Week")." ".$week; - $nav.=" \n"; - $nav.="".img_next($langs->trans("Next"))."\n"; - $picto='calendarweek'; + $nav ="".img_previous($langs->trans("Previous"))."\n"; + $nav.=" ".dol_print_date(dol_mktime(0,0,0,$month,1,$year),"%Y").", ".$langs->trans("Week")." ".$week; + $nav.=" \n"; + $nav.="".img_next($langs->trans("Next"))."\n"; + $picto='calendarweek'; } if ($action=='show_day') { @@ -280,44 +280,44 @@ $sql.= ', '.MAIN_DB_PREFIX.'c_actioncomm as ca'; $sql.= ', '.MAIN_DB_PREFIX.'user as u'; $sql.= ' WHERE a.fk_action = ca.id'; $sql.= ' AND a.fk_user_author = u.rowid'; -$sql.= ' AND u.entity in (0,'.$conf->entity.')'; // To limit to entity +$sql.= ' AND u.entity in (0,'.$conf->entity.')'; // To limit to entity $sql.= ' AND a.entity = '.$conf->entity; if ($user->societe_id) $sql.= ' AND a.fk_soc = '.$user->societe_id; // To limit to external user company if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); if ($action == 'show_day') { - $sql.= " AND ("; - $sql.= " (datep BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; - $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; - $sql.= " OR "; - $sql.= " (datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; - $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; - $sql.= " OR "; - $sql.= " (datep < '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; - $sql.= " AND datep2 > '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; - $sql.= ')'; + $sql.= " AND ("; + $sql.= " (datep BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; + $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; + $sql.= " OR "; + $sql.= " (datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; + $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; + $sql.= " OR "; + $sql.= " (datep < '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; + $sql.= " AND datep2 > '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; + $sql.= ')'; } else { - // To limit array - $sql.= " AND ("; - $sql.= " (datep BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; // Start 7 days before - $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; // End 7 days after + 3 to go from 28 to 31 - $sql.= " OR "; - $sql.= " (datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; - $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; - $sql.= " OR "; - $sql.= " (datep < '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; - $sql.= " AND datep2 > '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; - $sql.= ')'; + // To limit array + $sql.= " AND ("; + $sql.= " (datep BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; // Start 7 days before + $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; // End 7 days after + 3 to go from 28 to 31 + $sql.= " OR "; + $sql.= " (datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; + $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; + $sql.= " OR "; + $sql.= " (datep < '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; + $sql.= " AND datep2 > '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; + $sql.= ')'; } if ($filtera > 0 || $filtert > 0 || $filterd > 0) { - $sql.= " AND ("; - if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera; - if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert; - if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd; - $sql.= ")"; + $sql.= " AND ("; + if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera; + if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert; + if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd; + $sql.= ")"; } if ($status == 'done') { $sql.= " AND a.percent = 100"; } if ($status == 'todo') { $sql.= " AND a.percent < 100"; } @@ -329,23 +329,23 @@ dol_syslog("comm/action/index.php sql=".$sql, LOG_DEBUG); $resql=$db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i=0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + $num = $db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); - // Create a new object action - $event=new ActionComm($db); - $event->id=$obj->id; - $event->datep=$db->jdate($obj->datep); - $event->datef=$db->jdate($obj->datep2); - $event->type_code=$obj->code; - $event->libelle=$obj->label; - $event->percentage=$obj->percent; - $event->author->id=$obj->fk_user_author; - $event->usertodo->id=$obj->fk_user_action; - $event->userdone->id=$obj->fk_user_done; + // Create a new object action + $event=new ActionComm($db); + $event->id=$obj->id; + $event->datep=$db->jdate($obj->datep); // datep and datef are GMT date + $event->datef=$db->jdate($obj->datep2); + $event->type_code=$obj->code; + $event->libelle=$obj->label; + $event->percentage=$obj->percent; + $event->author->id=$obj->fk_user_author; + $event->usertodo->id=$obj->fk_user_action; + $event->userdone->id=$obj->fk_user_done; $event->priority=$obj->priority; $event->fulldayevent=$obj->fulldayevent; @@ -354,236 +354,260 @@ if ($resql) $event->societe->id=$obj->fk_soc; $event->contact->id=$obj->fk_contact; - // Defined date_start_in_calendar and date_end_in_calendar property - // They are date start and end of action but modified to not be outside calendar view. - if ($event->percentage <= 0) - { - $event->date_start_in_calendar=$event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; - else $event->date_end_in_calendar=$event->datep; - } - else - { - $event->date_start_in_calendar=$event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; - else $event->date_end_in_calendar=$event->datep; - } - // Define ponctual property - if ($event->date_start_in_calendar == $event->date_end_in_calendar) - { - $event->ponctuel=1; - } + // Defined date_start_in_calendar and date_end_in_calendar property + // They are date start and end of action but modified to not be outside calendar view. + if ($event->percentage <= 0) + { + $event->date_start_in_calendar=$event->datep; + if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; + else $event->date_end_in_calendar=$event->datep; + } + else + { + $event->date_start_in_calendar=$event->datep; + if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; + else $event->date_end_in_calendar=$event->datep; + } + // Define ponctual property + if ($event->date_start_in_calendar == $event->date_end_in_calendar) + { + $event->ponctuel=1; + } - // Check values - if ($event->date_end_in_calendar < $firstdaytoshow || - $event->date_start_in_calendar > $lastdaytoshow) - { - // This record is out of visible range - } - else - { - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; - if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=$lastdaytoshow; + // Check values + if ($event->date_end_in_calendar < $firstdaytoshow || + $event->date_start_in_calendar > $lastdaytoshow) + { + // This record is out of visible range + } + else + { + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; + if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=$lastdaytoshow; - // Add an entry in actionarray for each day - $daycursor=$event->date_start_in_calendar; - $annee = date('Y',$daycursor); - $mois = date('m',$daycursor); - $jour = date('d',$daycursor); + // Add an entry in actionarray for each day + $daycursor=$event->date_start_in_calendar; + $annee = date('Y',$daycursor); + $mois = date('m',$daycursor); + $jour = date('d',$daycursor); - // Loop on each day covered by action to prepare an index to show on calendar - $loop=true; $j=0; - $daykey=dol_mktime(0,0,0,$mois,$jour,$annee); - do - { - //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; + // Loop on each day covered by action to prepare an index to show on calendar + $loop=true; $j=0; + $daykey=dol_mktime(0,0,0,$mois,$jour,$annee); + do + { + //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; - $eventarray[$daykey][]=$event; - $j++; + $eventarray[$daykey][]=$event; + $j++; - $daykey+=60*60*24; - if ($daykey > $event->date_end_in_calendar) $loop=false; - } - while ($loop); + $daykey+=60*60*24; + if ($daykey > $event->date_end_in_calendar) $loop=false; + } + while ($loop); - //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); - //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; - } - $i++; + //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); + //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; + } + $i++; - } + } } else { - dol_print_error($db); + dol_print_error($db); } if ($showbirthday) { - // Add events in array - $sql = 'SELECT sp.rowid, sp.name, sp.firstname, sp.birthday'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; - $sql.= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; - $sql.= ' AND sp.entity = '.$conf->entity; - if ($action == 'show_day') - { - $sql.= ' AND MONTH(birthday) = '.$month; - $sql.= ' AND DAY(birthday) = '.$day; - } - else - { - $sql.= ' AND MONTH(birthday) = '.$month; - } - $sql.= ' ORDER BY birthday'; + // Add events in array + $sql = 'SELECT sp.rowid, sp.name, sp.firstname, sp.birthday'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; + $sql.= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; + $sql.= ' AND sp.entity = '.$conf->entity; + if ($action == 'show_day') + { + $sql.= ' AND MONTH(birthday) = '.$month; + $sql.= ' AND DAY(birthday) = '.$day; + } + else + { + $sql.= ' AND MONTH(birthday) = '.$month; + } + $sql.= ' ORDER BY birthday'; - dol_syslog("comm/action/index.php sql=".$sql, LOG_DEBUG); - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i=0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $event=new ActionComm($db); - $event->id=$obj->rowid; // We put contact id in action id for birthdays events - $datebirth=dol_stringtotime($obj->birthday); - //print 'ee'.$obj->birthday.'-'.$datebirth; - $datearray=dol_getdate($datebirth,true); - $event->datep=dol_mktime(0,0,0,$datearray['mon'],$datearray['mday'],$year); - $event->datef=$event->datep; - $event->type_code='BIRTHDAY'; - $event->libelle=$langs->trans("Birthday").' '.$obj->firstname.' '.$obj->name; - $event->percentage=100; + dol_syslog("comm/action/index.php sql=".$sql, LOG_DEBUG); + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $event=new ActionComm($db); + $event->id=$obj->rowid; // We put contact id in action id for birthdays events + $datebirth=dol_stringtotime($obj->birthday,1); + //print 'ee'.$obj->birthday.'-'.$datebirth; + $datearray=dol_getdate($datebirth,true); + $event->datep=dol_mktime(0,0,0,$datearray['mon'],$datearray['mday'],$year,true); // For full day events, date are also GMT but they wont but converted during output + $event->datef=$event->datep; + $event->type_code='BIRTHDAY'; + $event->libelle=$langs->trans("Birthday").' '.$obj->firstname.' '.$obj->name; + $event->percentage=100; + $event->fulldayevent=true; - $event->date_start_in_calendar=$event->datep; - $event->date_end_in_calendar=$event->datef; - $event->ponctuel=0; + $event->date_start_in_calendar=$event->datep; + $event->date_end_in_calendar=$event->datef; + $event->ponctuel=0; - // Add an entry in actionarray for each day - $daycursor=$event->date_start_in_calendar; - $annee = date('Y',$daycursor); - $mois = date('m',$daycursor); - $jour = date('d',$daycursor); + // Add an entry in actionarray for each day + $daycursor=$event->date_start_in_calendar; + $annee = date('Y',$daycursor); + $mois = date('m',$daycursor); + $jour = date('d',$daycursor); - $loop=true; - $daykey=dol_mktime(0,0,0,$mois,$jour,$annee); - do - { - $eventarray[$daykey][]=$event; - $daykey+=60*60*24; - if ($daykey > $event->date_end_in_calendar) $loop=false; - } - while ($loop); - $i++; - } - } - else - { - dol_print_error($db); - } + $loop=true; + $daykey=dol_mktime(0,0,0,$mois,$jour,$annee); + do + { + $eventarray[$daykey][]=$event; + $daykey+=60*60*24; + if ($daykey > $event->date_end_in_calendar) $loop=false; + } + while ($loop); + $i++; + } + } + else + { + dol_print_error($db); + } } //Exernal Calendars +$listofextcals=array(); if ($conf->global->MAIN_FEATURES_LEVEL>=2) -if ($conf->global->ENABLE_AGENDA_EXT==1 && $conf->global->AGENDA_EXT_NB>0) { - require_once(DOL_DOCUMENT_ROOT."/comm/action/class/ical.class.php"); - $numcals= $conf->global->AGENDA_EXT_NB; - $i=1; - while ($i<=$numcals) - { - $paramkey='AGENDA_EXT_SRC'.$i; - $url=$conf->global->$paramkey; - $ical=new ical(); - $ical->parse($url); - $icalevents= $ical->get_event_list(); - if(count($icalevents)>0) - { - foreach($icalevents as $icalevent) - { - // Create a new object action - $event=new ActionComm($db); - $addevent = false; - if($icalevent['DTSTART;VALUE=DATE']) //fullday event - { - $datestart=$db->jdate($icalevent['DTSTART;VALUE=DATE']); - $dateend=$db->jdate($icalevent['DTEND;VALUE=DATE']); - $event->fulldayevent=true; - $addevent=true; - } - elseif (is_array($icalevent['RRULE'])) //repeatable event - { - $addevent=false; //TODO: a faire - } - elseif(!is_array($icalevent['DTSTART'])) //non-repeatable and not fullday event - { - $datestart=$icalevent['DTSTART']; - $dateend=$icalevent['DTEND']; - $addevent=true; - } - - if($addevent) - { - $paramkey='AGENDA_EXT_NAME'.$i; - $namecal = $conf->global->$paramkey; - $paramkey='AGENDA_EXT_COLOR'.$i; - $colorcal = $conf->global->$paramkey; - $event->id=$icalevent['UID']; - $event->icalname=$namecal; - $event->icalcolor=$colorcal; - $usertime=($_SESSION['dol_tz']*60*60)+($_SESSION['dol_dst']*60*60); - $event->datep=$datestart+$usertime; - $event->datef=$dateend+$usertime; - $event->type_code="ICALEVENT"; - $event->libelle=''.$icalevent['SUMMARY'].'
'.str_replace("\\n", "
", $icalevent['DESCRIPTION']); - - $event->date_start_in_calendar=$event->datep; - - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; - else $event->date_end_in_calendar=$event->datep; - - // Define ponctual property - if ($event->date_start_in_calendar == $event->date_end_in_calendar) - { - $event->ponctuel=1; - } - - // Check values - if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar > $lastdaytoshow) - { - // This record is out of visible range - } - else - { - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; - if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=$lastdaytoshow; - - // Add an entry in actionarray for each day - $daycursor=$event->date_start_in_calendar; - $annee = date('Y',$daycursor); - $mois = date('m',$daycursor); - $jour = date('d',$daycursor); - - // Loop on each day covered by action to prepare an index to show on calendar - $loop=true; $j=0; - $daykey=dol_mktime(0,0,0,$mois,$jour,$annee); - do - { - $eventarray[$daykey][]=$event; - $daykey+=60*60*24; - if ($daykey > $event->date_end_in_calendar) $loop=false; - } - while ($loop); - } - } - } - } - $i++; - } + if (empty($conf->global->AGENDA_DISABLE_EXT) && $conf->global->AGENDA_EXT_NB > 0) + { + $i=0; + while($i < $conf->global->AGENDA_EXT_NB) + { + $i++; + $paramkey='AGENDA_EXT_SRC'.$i; + $url=$conf->global->$paramkey; + $paramkey='AGENDA_EXT_NAME'.$i; + $namecal = $conf->global->$paramkey; + $paramkey='AGENDA_EXT_COLOR'.$i; + $colorcal = $conf->global->$paramkey; + if ($url && $namecal) $listofextcals[]=array('src'=>$url,'name'=>$namecal,'color'=>$colorcal); + } + } +} +if (sizeof($listofextcals)) +{ + require_once(DOL_DOCUMENT_ROOT."/comm/action/class/ical.class.php"); + foreach($listofextcals as $extcal) + { + $url=$extcal['src']; + $namecal = $extcal['name']; + $colorcal = $extcal['color']; + //print "url=".$url." namecal=".$namecal." colorcal=".$colorcal; + $ical=new ical(); + $ical->parse($url); + $icalevents=array(); + if (is_array($ical->get_event_list())) $icalevents=array_merge($icalevents,$ical->get_event_list()); + if (is_array($ical->get_freebusy_list())) $icalevents=array_merge($icalevents,$ical->get_freebusy_list()); + + if(count($icalevents)>0) + { + foreach($icalevents as $icalevent) + { + // Create a new object action + $event=new ActionComm($db); + $addevent = false; + if($icalevent['DTSTART;VALUE=DATE']) //fullday event + { + // For full day events, date are also GMT but they wont but converted using tz during output + $datestart=dol_stringtotime($icalevent['DTSTART;VALUE=DATE'],1); + $dateend=dol_stringtotime($icalevent['DTEND;VALUE=DATE'],1)-1; // We remove one second to get last second of day + //print 'x'.$datestart.'-'.$dateend;exit; + //print dol_print_date($dateend,'dayhour','gmt'); + $event->fulldayevent=true; + $addevent=true; + } + elseif (is_array($icalevent['RRULE'])) //repeatable event + { + $addevent=false; //TODO: a faire + } + elseif(!is_array($icalevent['DTSTART'])) //non-repeatable and not fullday event + { + $datestart=$icalevent['DTSTART']; + $dateend=$icalevent['DTEND']; + $addevent=true; + } + + if($addevent) + { + $event->id=$icalevent['UID']; + $event->icalname=$namecal; + $event->icalcolor=$colorcal; + //$usertime=($_SESSION['dol_tz']*60*60)+($_SESSION['dol_dst']*60*60); + $usertime=0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output. + $event->datep=$datestart+$usertime; + $event->datef=$dateend+$usertime; + $event->type_code="ICALEVENT"; + $event->libelle=''.$icalevent['SUMMARY'].'
'.str_replace("\\n", "
", $icalevent['DESCRIPTION']); + + $event->date_start_in_calendar=$event->datep; + + if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; + else $event->date_end_in_calendar=$event->datep; + + // Define ponctual property + if ($event->date_start_in_calendar == $event->date_end_in_calendar) + { + $event->ponctuel=1; + } + + // Check values + if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar > $lastdaytoshow) + { + // This record is out of visible range + } + else + { + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; + if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=$lastdaytoshow; + + // Add an entry in actionarray for each day + $daycursor=$event->date_start_in_calendar; + $annee = date('Y',$daycursor); + $mois = date('m',$daycursor); + $jour = date('d',$daycursor); + + // Loop on each day covered by action to prepare an index to show on calendar + $loop=true; $j=0; + // daykey must be date that represent day box in calendar so must be a user time + $daykey=dol_mktime(0,0,0,$mois,$jour,$annee); + $daykeygmt=dol_mktime(0,0,0,$mois,$jour,$annee,true,0,false); + do + { + //if ($event->fulldayevent) print dol_print_date($daykeygmt,'dayhour','gmt').'-'.dol_print_date($daykey,'dayhour','gmt').'-'.dol_print_date($event->date_end_in_calendar,'dayhour','gmt').' '; + $eventarray[$daykey][]=$event; + $daykey+=60*60*24; $daykeygmt+=60*60*24; // Add one day + if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) $loop=false; + } + while ($loop); + } + } + } + } + } } -$maxlength=16; +$maxlength=18; $cachethirdparties=array(); $cachecontacts=array(); @@ -591,12 +615,12 @@ $cachecontacts=array(); $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php"; if (is_readable($color_file)) { - include_once($color_file); + include_once($color_file); } if (! is_array($theme_datacolor)) $theme_datacolor=array(array(120,130,150), array(200,160,180), array(190,190,220)); -if (empty($action) || $action == 'show_month') // View by month +if (empty($action) || $action == 'show_month') // View by month { $newparam=$param; // newparam is for birthday links $newparam=preg_replace('/action=show_month&?/i','',$newparam); @@ -605,60 +629,60 @@ if (empty($action) || $action == 'show_month') // View by month $newparam=preg_replace('/month=[0-9][0-9]&?/i','',$newparam); $newparam=preg_replace('/year=[0-9]+&?/i','',$newparam); echo '
'; - echo ' '; - $i=0; - while ($i < 7) - { - echo ' \n"; - $i++; - } - echo " \n"; + echo ' '; + $i=0; + while ($i < 7) + { + echo ' \n"; + $i++; + } + echo " \n"; - // In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month) - //var_dump($eventarray); - //print $tmpday; - for($iter_week = 0; $iter_week < 6 ; $iter_week++) - { - echo " \n"; - for($iter_day = 0; $iter_day < 7; $iter_day++) - { - /* Show days before the beginning of the current month (previous month) */ - if($tmpday <= 0) - { - $style='cal_other_month'; - echo ' \n"; - } - /* Show days of the current month */ - elseif(($tmpday <= $max_day_in_month)) - { - $curtime = dol_mktime (0, 0, 0, $month, $tmpday, $year); + // In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month) + //var_dump($eventarray); + //print $tmpday; + for($iter_week = 0; $iter_week < 6 ; $iter_week++) + { + echo " \n"; + for($iter_day = 0; $iter_day < 7; $iter_day++) + { + /* Show days before the beginning of the current month (previous month) */ + if($tmpday <= 0) + { + $style='cal_other_month'; + echo ' \n"; + } + /* Show days of the current month */ + elseif(($tmpday <= $max_day_in_month)) + { + $curtime = dol_mktime (0, 0, 0, $month, $tmpday, $year); - if ($curtime < $now) - $style='cal_current_month'; - else if($curtime == $now) - $style='cal_today'; - else - $style='cal_current_month'; + if ($curtime < $now) + $style='cal_current_month'; + else if($curtime == $now) + $style='cal_today'; + else + $style='cal_current_month'; - echo ' \n"; - } - /* Show days after the current month (next month) */ - else - { - $style='cal_other_month'; - echo ' \n"; - } - $tmpday++; - } - echo " \n"; - } - echo "
'.$langs->trans("Day".(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7))."
'.$langs->trans("Day".(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7))."
'; - show_day_events ($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW, $maxlength, $newparam); - echo "
'; + show_day_events ($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW, $maxlength, $newparam); + echo " '; - show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW, $maxlength, $newparam); - echo " '; - show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW, $maxlength, $newparam); - echo "
\n"; + echo ' '; + show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW, $maxlength, $newparam); + echo " \n"; + } + /* Show days after the current month (next month) */ + else + { + $style='cal_other_month'; + echo ' '; + show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW, $maxlength, $newparam); + echo "\n"; + } + $tmpday++; + } + echo " \n"; + } + echo "\n"; } elseif ($action == 'show_week') // View by week { @@ -668,52 +692,52 @@ elseif ($action == 'show_week') // View by week $newparam=preg_replace('/day=[0-9][0-9]&?/i','',$newparam); $newparam=preg_replace('/month=[0-9][0-9]&?/i','',$newparam); $newparam=preg_replace('/year=[0-9]+&?/i','',$newparam); - echo ''; - echo ' '; - $i=0; - while ($i < 7) - { - echo ' \n"; - $i++; - } - echo " \n"; + echo '
'.$langs->trans("Day".(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7))."
'; + echo ' '; + $i=0; + while ($i < 7) + { + echo ' \n"; + $i++; + } + echo " \n"; - // In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month) - //var_dump($eventarray); - //print $tmpday; + // In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month) + //var_dump($eventarray); + //print $tmpday; - echo " \n"; + echo " \n"; - for($iter_day = 0; $iter_day < 7; $iter_day++) - { - if(($tmpday <= $max_day_in_month)) - { - // Show days of the current week - $curtime = dol_mktime (0, 0, 0, $month, $tmpday, $year); + for($iter_day = 0; $iter_day < 7; $iter_day++) + { + if(($tmpday <= $max_day_in_month)) + { + // Show days of the current week + $curtime = dol_mktime (0, 0, 0, $month, $tmpday, $year); - if($curtime == $now) - $style='cal_today'; - else - $style='cal_current_month'; + if($curtime == $now) + $style='cal_today'; + else + $style='cal_current_month'; - echo ' \n"; - } - else - { - $style='cal_current_month'; - echo ' \n"; - } - $tmpday++; - } - echo " \n"; + echo ' \n"; + } + else + { + $style='cal_current_month'; + echo ' \n"; + } + $tmpday++; + } + echo " \n"; - echo "
'.$langs->trans("Day".(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7))."
'; - show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, 0, $maxlength, $newparam, 1, 300); - echo " '; - show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, 0, $maxlength, $newparam, 1, 300); - echo "
'; + show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, 0, $maxlength, $newparam, 1, 300); + echo " '; + show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, 0, $maxlength, $newparam, 1, 300); + echo "
\n"; + echo "\n"; } -else // View by day +else // View by day { $newparam=$param; // newparam is for birthday links $newparam=preg_replace('/action=show_month&?/i','',$newparam); @@ -722,19 +746,19 @@ else // View by day $newparam=preg_replace('/month=[0-9][0-9]&?/i','',$newparam); $newparam=preg_replace('/year=[0-9]+&?/i','',$newparam); // Code to show just one day - $style='cal_current_month'; - $timestamp=dol_mktime(12,0,0,$month,$day,$year); - $arraytimestamp=adodb_getdate(dol_mktime(12,0,0,$month,$day,$year)); - echo ''; - echo ' '; - echo ' \n"; - echo " \n"; - echo " \n"; - echo ' \n"; - echo " \n"; - echo '
'.$langs->trans("Day".$arraytimestamp['wday'])."
'; - show_day_events ($db, $day, $month, $year, $month, $style, $eventarray, 0, 80, $newparam, 1, 300); - echo "
'; + $style='cal_current_month'; + $timestamp=dol_mktime(12,0,0,$month,$day,$year); + $arraytimestamp=adodb_getdate(dol_mktime(12,0,0,$month,$day,$year)); + echo ''; + echo ' '; + echo ' \n"; + echo " \n"; + echo " \n"; + echo ' \n"; + echo " \n"; + echo '
'.$langs->trans("Day".$arraytimestamp['wday'])."
'; + show_day_events ($db, $day, $month, $year, $month, $style, $eventarray, 0, 80, $newparam, 1, 300); + echo "
'; } @@ -759,132 +783,160 @@ llxFooter('$Date$ - $Revision$'); /** * Show event of a particular day - * @param $db Database handler - * @param $day Day - * @param $month Month - * @param $year Year - * @param $monthshown Current month shown in calendar view - * @param $style Style to use for this day - * @param $eventarray Array of events - * @param $maxPrint Nb of actions to show each day on month view (0 means non limit) - * @param $maxnbofchar Nb of characters to show for event line + * @param $db Database handler + * @param $day Day + * @param $month Month + * @param $year Year + * @param $monthshown Current month shown in calendar view + * @param $style Style to use for this day + * @param $eventarray Array of events + * @param $maxPrint Nb of actions to show each day on month view (0 means non limit) + * @param $maxnbofchar Nb of characters to show for event line * @param $newparam Parameters on current URL * @param $showinfo Add extended information (used by day view) * @param $minheight Minimum height for each event. 60px by default. */ -function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxPrint=0, $maxnbofchar=14, $newparam='', $showinfo=0, $minheight=60) +function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxPrint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60) { - global $user, $conf, $langs; - global $filter, $filtera, $filtert, $filterd, $status; - global $theme_datacolor; - global $cachethirdparties, $cachecontacts; + global $user, $conf, $langs; + global $filter, $filtera, $filtert, $filterd, $status; + global $theme_datacolor; + global $cachethirdparties, $cachecontacts; - if ($_GET["maxprint"] == 'on') $maxPrint=0; // Force to remove limits + if ($_GET["maxprint"] == 'on') $maxPrint=0; // Force to remove limits - $curtime = dol_mktime (0, 0, 0, $month, $day, $year); - print ''; - print ''; - print ''; + print '
'; - print ''; - if ($showinfo) print dol_print_date($curtime,'daytext'); - else print dol_print_date($curtime,'%d'); - print ''; - print ''; - if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) - { - //$param='month='.$monthshown.'&year='.$year; - $hourminsec='100000'; - print ''; - print img_picto($langs->trans("NewAction"),'edit_add.png'); - print ''; - } - print '
'; + $curtime = dol_mktime (0, 0, 0, $month, $day, $year); + print ''; + print ''; + print ''; - print '
'; + print ''; + if ($showinfo) print dol_print_date($curtime,'daytext'); + else print dol_print_date($curtime,'%d'); + print ''; + print ''; + if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) + { + //$param='month='.$monthshown.'&year='.$year; + $hourminsec='100000'; + print ''; + print img_picto($langs->trans("NewAction"),'edit_add.png'); + print ''; + } + print '
'; - //$curtime = dol_mktime (0, 0, 0, $month, $day, $year); - $i=0; + //$curtime = dol_mktime (0, 0, 0, $month, $day, $year); + $i=0; - foreach ($eventarray as $daykey => $notused) - { - $annee = date('Y',$daykey); - $mois = date('m',$daykey); - $jour = date('d',$daykey); - if ($day==$jour && $month==$mois && $year==$annee) - { - foreach ($eventarray[$daykey] as $index => $event) - { - if ($i < $maxPrint || $maxPrint == 0) - { - $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); - // Show rect of event - $colorindex=0; - if ($event->author->id == $user->id || $event->usertodo->id == $user->id || $event->userdone->id == $user->id) $colorindex=1; - if ($event->type_code == 'BIRTHDAY') $colorindex=2; - if ($event->type_code == 'ICALEVENT') $color=$event->icalcolor; - else $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); - //print "x".$color; - - print ''; - print '
'; - if ($event->type_code != 'BIRTHDAY') - { - + foreach ($eventarray as $daykey => $notused) + { + $annee = date('Y',$daykey); + $mois = date('m',$daykey); + $jour = date('d',$daykey); + if ($day==$jour && $month==$mois && $year==$annee) + { + foreach ($eventarray[$daykey] as $index => $event) + { + if ($i < $maxPrint || $maxPrint == 0) + { + $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); + // Show rect of event + $colorindex=0; + if ($event->author->id == $user->id || $event->usertodo->id == $user->id || $event->userdone->id == $user->id) $colorindex=1; + if ($event->type_code == 'BIRTHDAY') $colorindex=2; + if ($event->type_code == 'ICALEVENT') $color=$event->icalcolor; + else $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); + //print "x".$color; + + print '
'; + print ''; + print ''; + } + } + + print ''; // Status - Percent - print '
'; + if ($event->type_code == 'BIRTHDAY') // It's a birthday + { + print $event->getNomUrl(1,$maxnbofchar,'cal_event','birthday','contact'); + } + if ($event->type_code != 'BIRTHDAY') + { + // Picto if ($showinfo && $event->type_code != 'ICALEVENT') { print $event->getNomUrl(2).' '; } - if (empty($event->fulldayevent)) - { - // Show hours (start ... end) - $tmpyearstart = date('Y',$event->date_start_in_calendar); - $tmpmonthstart = date('m',$event->date_start_in_calendar); - $tmpdaystart = date('d',$event->date_start_in_calendar); - $tmpyearend = date('Y',$event->date_end_in_calendar); - $tmpmonthend = date('m',$event->date_end_in_calendar); - $tmpdayend = date('d',$event->date_end_in_calendar); - // Hour start - if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) - { - print dol_print_date($event->date_start_in_calendar,'%H:%M'); - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) - { - if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) - print '-'; - //else - //print '...'; - } - } - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) - { - if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) - { - print '...'; - } - } - // Hour end - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) - { - if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) - print dol_print_date($event->date_end_in_calendar,'%H:%M'); - } - if ($event->type_code == 'ICALEVENT') print '
('.$event->icalname.')'; - print '
'."\n"; - } - else - { - if ($showinfo) - { - print $langs->trans("EventOnFullDay").'
'."\n"; - } - } + // Date + if (empty($event->fulldayevent)) + { + $daterange=''; - // If action related to company / contact - $linerelatedto='';$length=16; - if (! empty($event->societe->id) && ! empty($event->contact->id)) $length=round($length/2); + // Show hours (start ... end) + $tmpyearstart = date('Y',$event->date_start_in_calendar); + $tmpmonthstart = date('m',$event->date_start_in_calendar); + $tmpdaystart = date('d',$event->date_start_in_calendar); + $tmpyearend = date('Y',$event->date_end_in_calendar); + $tmpmonthend = date('m',$event->date_end_in_calendar); + $tmpdayend = date('d',$event->date_end_in_calendar); + // Hour start + if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) + { + $daterange.=dol_print_date($event->date_start_in_calendar,'%H:%M'); + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) + { + if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) + $daterange.='-'; + //else + //print '...'; + } + } + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) + { + if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) + { + $daterange.='...'; + } + } + // Hour end + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) + { + if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) + $daterange.=dol_print_date($event->date_end_in_calendar,'%H:%M'); + } + if ($event->type_code == 'ICALEVENT') $daterange.='
('.$event->icalname.')'; + //print $daterange; + if ($event->type_code != 'ICALEVENT') + { + $savlabel=$event->libelle; + $event->libelle=$daterange; + print $event->getNomUrl(0); + $event->libelle=$savlabel; + } + else + { + print $daterange; + } + print '
'."\n"; + } + else + { + if ($showinfo) + { + print $langs->trans("EventOnFullDay").'
'."\n"; + } + } + + // Show label + if ($event->type_code == 'ICALEVENT') + { + if ($event->fulldayevent) print '('.$event->icalname.')
'; + print $event->libelle; + } + else print $event->getNomUrl(0,$maxnbofchar,'cal_event'); + + // If action related to company / contact + $linerelatedto='';$length=16; + if (! empty($event->societe->id) && ! empty($event->contact->id)) $length=round($length/2); if (! empty($event->societe->id) && $event->societe->id > 0) { if (! is_object($cachethirdparties[$event->societe->id])) @@ -908,55 +960,47 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($linerelatedto) $linerelatedto.=' / '; $linerelatedto.=$contact->getNomUrl(1,'',$length); } - if ($linerelatedto) print $linerelatedto.'
'; + if ($linerelatedto) print '
'.$linerelatedto; - // Show label - if($event->type_code == 'ICALEVENT') - { - if ($event->fulldayevent) print '('.$event->icalname.')
'; - print $event->libelle; - } - else print $event->getNomUrl(0,$maxnbofchar,'cal_event'); - } - else // It's a birthday - { - print $event->getNomUrl(1,$maxnbofchar,'cal_event','birthday','contact'); - } - // Show location - if ($showinfo) - { - if ($event->location) - { - print '
'; + } + + // Show location + if ($showinfo) + { + if ($event->location) + { + print '
'; print $langs->trans("Location").': '.$event->location; - } - } - print '
'; - if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') print $event->getLibStatut(3,1); - else print ' '; - print '
'; - $i++; - } - else - { - print ''; + if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') print $event->getLibStatut(3,1); + else print ' '; + print '
'; + print ''; + $i++; + } + else + { + print ''.img_picto("all","1downarrow_selected.png").' ...'; - print ' +'.(sizeof($eventarray[$daykey])-$maxPrint); - print ''; - break; - //$ok=false; // To avoid to show twice the link - } - } - break; - } - } - if (! $i) print ' '; - print '
'; + print '">'.img_picto("all","1downarrow_selected.png").' ...'; + print ' +'.(sizeof($eventarray[$daykey])-$maxPrint); + print ''; + break; + //$ok=false; // To avoid to show twice the link + } + } + break; + } + } + if (! $i) print ' '; + print '
'; } ?> diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang index ced9a840d93..9f71cb0900f 100644 --- a/htdocs/langs/fr_FR/agenda.lang +++ b/htdocs/langs/fr_FR/agenda.lang @@ -31,7 +31,7 @@ ViewWithPredefinedFilters=Vues avec filtres prédéfinis AutoActions=Alimentation automatique de l'agenda AgendaAutoActionDesc=Définissez dans cet onglet les événements pour lesquels dolibarr créera automatiquement une action dans l'agenda. Si aucune case n'est cochée (par défaut), seules les actions manuelles seront incluses dans l'agenda. AgendaSetupOtherDesc=Cette page permet de configurer les autres paramètres du module agenda. -AgendaExtSitesDesc=Cette page permet de configurer les calendriers externes. +AgendaExtSitesDesc=Cette page permet d'ajouter des sources de calendriers externes pour les visualiser au sein de l'agenda Dolibarr. ActionsEvents=Événements pour lesquels Dolibarr doit créer une action dans l'agenda en automatique. PropalValidatedInDolibarr=Proposition %s validée InvoiceValidatedInDolibarr=Facture %s validée @@ -65,4 +65,4 @@ ExtSites=Calendriers extérieures ExtSitesEnableThisTool=Afficher les calendriers externes sur l'agenda ExtSitesNbOfAgenda=Nombre de calendriers AgendaExtNb=Calendrier no %s -ExtSiteUrlAgenda=Url de acceso al archivo .ical \ No newline at end of file +ExtSiteUrlAgenda=Url d'accès au fichier ical \ No newline at end of file diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 77cf8e0bbca..fb4c1a1ef5a 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -551,9 +551,9 @@ function dolibarr_print_date($time,$format='',$to_gmt=false,$outputlangs='',$enc * "%d/%m/%Y %H:%M", * "%d/%m/%Y %H:%M:%S", * "day", "daytext", "dayhour", "dayhourldap", "dayhourtext" - * @param tzoutput true=output string is for Greenwich location - * false or 'tzserver'=output string is for local PHP server TZ usage - * 'tzuser'=output string is for local browser TZ usage + * @param tzoutput true=output or 'gmt' => string is for Greenwich location + * false or 'tzserver' => output string is for local PHP server TZ usage + * 'tzuser' => output string is for local browser TZ usage * @param outputlangs Object lang that contains language for text translation. * @param encodetooutput false=no convert into output pagecode * @return string Formated date or '' if time is null @@ -806,7 +806,7 @@ function dolibarr_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$chec * @return timestamp Date as a timestamp, '' if error * @see dol_print_date, dol_stringtotime */ -function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) +function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1,$isdst=true) { //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; @@ -841,7 +841,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) $date=strtotime($string); print "- ".$string." ".$date." -"; */ - $date=adodb_mktime($hour,$minute,$second,$month,$day,$year,0,$gm); + $date=adodb_mktime($hour,$minute,$second,$month,$day,$year,$isdst,$gm); } else { diff --git a/htdocs/lib/xcal.lib.php b/htdocs/lib/xcal.lib.php index a5a705c4913..585b80f5c8c 100644 --- a/htdocs/lib/xcal.lib.php +++ b/htdocs/lib/xcal.lib.php @@ -41,11 +41,11 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile) if (empty($outputfile)) return -1; - // Note: A cal file is an UTF8 encoded file + // Note: A cal file is an UTF8 encoded file $calfileh=fopen($outputfile,'w'); if ($calfileh) { - $now=mktime(); + $now=dol_now(); $encoding=''; if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:'; @@ -58,8 +58,13 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile) fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."\n"); fwrite($calfileh,"CALSCALE:GREGORIAN\n"); fwrite($calfileh,"X-WR-CALNAME:".$encoding.format_cal($format,$title)."\n"); - fwrite($calfileh,"X-WR-CALDESC:".$encoding.format_cal($format,$desc)."\n"); - //fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n"); + fwrite($calfileh,"X-WR-CALDESC:".$encoding.format_cal($format,$desc)."\n"); + $hh=ConvertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'hour'); + $mm=ConvertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'min'); + $ss=ConvertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'sec'); + //fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n"); + if (! empty($conf->global->MAIN_AGENDA_EXPORT_CACHE) + && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60) fwrite($calfileh,"X-PUBLISHED-TTL: "."P".$hh."H".$mm."M".$ss."S\n"); foreach ($events_array as $date => $event) { @@ -149,31 +154,31 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile) if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n"); fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); - /* + + /* Other keys: // Status values for a "VEVENT" statvalue = "TENTATIVE" ;Indicates event is ;tentative. / "CONFIRMED" ;Indicates event is ;definite. / "CANCELLED" ;Indicates event was - ;cancelled. - ; - // Status values for "VTODO". statvalue =/ "NEEDS-ACTION" ;Indicates to-do needs action. / "COMPLETED" ;Indicates to-do completed. / "IN-PROCESS" ;Indicates to-do in process of / "CANCELLED" ;Indicates to-do was cancelled. - - // Status values for "VJOURNAL". statvalue =/ "DRAFT" ;Indicates journal is draft. / "FINAL" ;Indicates journal is final. / "CANCELLED" ;Indicates journal is removed. - */ - if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n"); //fwrite($calfileh,"CLASS:PUBLIC\n"); // PUBLIC, PRIVATE, CONFIDENTIAL + //fwrite($calfileh,"X-MICROSOFT-CDO-BUSYSTATUS:1\n"); + //ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Laurent Destailleur;X-NUM-GUESTS=0:mailto:eldy10@gmail.com + + if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n"); + if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n"); + if ($fulldayevent) fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n"); // Date must be GMT dates // Current date