diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 85ce14aba3c..62fda9fa597 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -742,12 +742,14 @@ class ActionComm extends CommonObject
$event['priority']=$obj->priority;
$event['fulldayevent']=$obj->fulldayevent;
$event['location']=$langs->convToOutputCharset($obj->location);
- $event['transparency']='TRANSPARENT'; // TRANSPARENT or OPAQUE
+ $event['transparency']='TRANSPARENT'; // OPAQUE (busy) or TRANSPARENT (not busy)
$event['category']=$langs->convToOutputCharset($obj->libelle); // libelle type action
$url=$dolibarr_main_url_root;
if (! preg_match('/\/$/',$url)) $url.='/';
$url.='comm/action/fiche.php?id='.$obj->id;
$event['url']=$url;
+ $event['created']=$this->db->jdate($obj->datec);
+ $event['modified']=$this->db->jdate($obj->datem);
if ($qualified && $datestart)
{
diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php
index b9dd6a77846..23460ee566c 100644
--- a/htdocs/comm/action/fiche.php
+++ b/htdocs/comm/action/fiche.php
@@ -466,7 +466,7 @@ if (GETPOST('action') == 'create')
print '';
if (GETPOST("backtopage")) print '';
- if ($_GET["actioncode"] == 'AC_RDV') print_fiche_titre ($langs->trans("AddActionRendezVous"));
+ if (GETPOST("actioncode") == 'AC_RDV') print_fiche_titre ($langs->trans("AddActionRendezVous"));
else print_fiche_titre ($langs->trans("AddAnAction"));
if ($mesg) print $mesg.' ';
@@ -495,16 +495,20 @@ if (GETPOST('action') == 'create')
print '
'.$langs->trans("EventOnFullDay").'
';
// Date start
+ $datep=$actioncomm->datep;
+ if (GETPOST('datep','int',1)) $datep=dol_stringtotime(GETPOST('datep','int',1),0);
print '
'.$langs->trans("DateActionStart").'
';
- if (GETPOST("afaire") == 1) $html->select_date($actioncomm->datep,'ap',1,1,0,"action",1,1,0,0,'fulldayend');
- else if (GETPOST("afaire") == 2) $html->select_date($actioncomm->datep,'ap',1,1,1,"action",1,1,0,0,'fulldayend');
- else $html->select_date($actioncomm->datep,'ap',1,1,1,"action",1,1,0,0,'fulldaystart');
+ if (GETPOST("afaire") == 1) $html->select_date($datep,'ap',1,1,0,"action",1,1,0,0,'fulldayend');
+ else if (GETPOST("afaire") == 2) $html->select_date($datep,'ap',1,1,1,"action",1,1,0,0,'fulldayend');
+ else $html->select_date($datep,'ap',1,1,1,"action",1,1,0,0,'fulldaystart');
print '
';
// Date end
+ $datef=$actioncomm->datef;
+ if (GETPOST('datef','int',1)) $datef=dol_stringtotime(GETPOST('datef','int',1),0);
print '
'.$langs->trans("DateActionEnd").'
';
- if (GETPOST("afaire") == 1) $html->select_date($actioncomm->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
- else if (GETPOST("afaire") == 2) $html->select_date($actioncomm->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
- else $html->select_date($actioncomm->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
+ if (GETPOST("afaire") == 1) $html->select_date($datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
+ else if (GETPOST("afaire") == 2) $html->select_date($datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
+ else $html->select_date($datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
print '
';
// Status
diff --git a/htdocs/lib/date.lib.php b/htdocs/lib/date.lib.php
index 3afae41012c..ea7042e2cf1 100644
--- a/htdocs/lib/date.lib.php
+++ b/htdocs/lib/date.lib.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2004-2010 Laurent Destailleur
* Copyright (C) 2005-2008 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
@@ -20,14 +20,14 @@
/**
* \file htdocs/lib/date.lib.php
- * \brief Ensemble de fonctions de base de dolibarr sous forme d'include
+ * \brief Set of function to manipulate dates
* \version $Id$
*/
/**
* Add a delay to a date
- * @param time Date timestamp ou au format YYYY-MM-DD
+ * @param time Date timestamp (or string with format YYYY-MM-DD)
* @param duration_value Value of delay to add
* @param duration_unit Unit of added delay (d, m, y)
* @return int New timestamp
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index 01e951f5688..30e6238b027 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -434,17 +434,18 @@ function dolibarr_print_date($time,$format='',$to_gmt=false,$outputlangs='',$enc
}
/**
- * \brief Output date in a string format according to outputlangs (or langs if not defined).
- * Return charset is always UTF-8, except if encodetoouput is defined. In this cas charset is output charset.
- * \param time GM Timestamps date (or 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS')
- * \param format Output date format
+ * Output date in a string format according to outputlangs (or langs if not defined).
+ * Return charset is always UTF-8, except if encodetoouput is defined. In this cas charset is output charset.
+ * @param time GM Timestamps date (or 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS')
+ * @param format Output date format
* "%d %b %Y",
* "%d/%m/%Y %H:%M",
* "%d/%m/%Y %H:%M:%S",
* "day", "daytext", "dayhour", "dayhourldap", "dayhourtext"
- * \param to_gmt false=output string is for local server TZ usage, true=output string is for GMT usage
- * \param outputlangs Object lang that contains language for text translation.
- * \return string Formated date or '' if time is null
+ * @param to_gmt false=output string is for local server TZ usage, true=output string is for GMT usage
+ * @param outputlangs Object lang that contains language for text translation.
+ * @return string Formated date or '' if time is null
+ * @see dol_mktime, dol_stringtotime
*/
function dol_print_date($time,$format='',$to_gmt=false,$outputlangs='',$encodetooutput=false)
{
@@ -489,7 +490,7 @@ function dol_print_date($time,$format='',$to_gmt=false,$outputlangs='',$encodeto
$format=str_replace('%A','__A__',$format);
}
- // Analyse de la date (deprecated) Ex: 19700101, 19700101010000
+ // Analyze date (deprecated) Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000
if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$time,$reg)
|| preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i',$time,$reg))
{
@@ -549,17 +550,18 @@ function dol_print_date($time,$format='',$to_gmt=false,$outputlangs='',$encodeto
/**
- * \brief Convert a GM string date into a GM Timestamps date
- * \param string Date in a string
- * YYYYMMDD
- * YYYYMMDDHHMMSS
- * DD/MM/YY or DD/MM/YYYY (this format should not be used anymore)
- * DD/MM/YY HH:MM:SS or DD/MM/YYYY HH:MM:SS (this format should not be used anymore)
- * 19700101020000 -> 7200
- * \return date Date
- * \see dol_date, dol_mktime
+ * Convert a string date into a GM Timestamps date
+ * @param string Date in a string
+ * YYYYMMDD
+ * YYYYMMDDHHMMSS
+ * DD/MM/YY or DD/MM/YYYY (this format should not be used anymore)
+ * DD/MM/YY HH:MM:SS or DD/MM/YYYY HH:MM:SS (this format should not be used anymore)
+ * 19700101020000 -> 7200
+ * @param gm 1=Input date is GM date, 0=Input date is local date
+ * @return date Date
+ * @see dol_print_date, dol_mktime
*/
-function dol_stringtotime($string)
+function dol_stringtotime($string, $gm=1)
{
if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$string,$reg))
{
@@ -580,7 +582,7 @@ function dol_stringtotime($string)
$string=preg_replace('/([^0-9])/i','',$string);
$tmp=$string.'000000';
- $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),1);
+ $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
return $date;
}
@@ -651,7 +653,7 @@ function dolibarr_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$chec
* @param gm 1=Input informations are GMT values, otherwise local to server TZ
* @param check 0=No check on parameters (Can use day 32, etc...)
* @return timestamp Date as a timestamp, '' if error
- * @see dol_date, dol_stringtotime
+ * @see dol_print_date, dol_stringtotime
*/
function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
{
@@ -705,12 +707,12 @@ function dolibarr_date($fmt, $timestamp, $gm=false)
}
/**
- * \brief Returns formated date
- * \param fmt Format (Exemple: 'Y-m-d H:i:s')
- * \param timestamp Date. Example: If timestamp=0 and gm=1, return 01/01/1970 00:00:00
- * \param gm 1 if timestamp was built with gmmktime, 0 if timestamp was build with mktime
- * \return string Formated date
- * \see dol_mktime, dol_stringtotime
+ * Returns formated date
+ * @param fmt Format (Exemple: 'Y-m-d H:i:s')
+ * @param timestamp Date. Example: If timestamp=0 and gm=1, return 01/01/1970 00:00:00
+ * @param gm 1 if timestamp was built with gmmktime, 0 if timestamp was build with mktime
+ * @return string Formated date
+ * @deprecated Replaced by dol_print_date
*/
function dol_date($fmt, $timestamp, $gm=false)
{
diff --git a/htdocs/lib/xcal.lib.php b/htdocs/lib/xcal.lib.php
index edb095f6fd8..f0c1318d7ec 100644
--- a/htdocs/lib/xcal.lib.php
+++ b/htdocs/lib/xcal.lib.php
@@ -24,17 +24,16 @@
*/
/**
- * \brief Build a file from an array of events
- * All input params and data must be encoded in $conf->charset_output
- * \param format 'vcal' or 'ical'
- * \param title Title of export
- * \param desc Description of export
- * \param events_array Array of events ('eid','startdate','duration','enddate','title','summary','category','email','url','desc','author')
- * \param outputfile Output file
- * \param filter Filter
- * \return int <0 if ko, Nb of events in file if ok
+ * Build a file from an array of events
+ * All input params and data must be encoded in $conf->charset_output
+ * @param format 'vcal' or 'ical'
+ * @param title Title of export
+ * @param desc Description of export
+ * @param events_array Array of events ('eid','startdate','duration','enddate','title','summary','category','email','url','desc','author')
+ * @param outputfile Output file
+ * @return int <0 if ko, Nb of events in file if ok
*/
-function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$filter='')
+function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile)
{
global $conf,$langs;
@@ -65,20 +64,13 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$fi
foreach ($events_array as $date => $event)
{
$eventqualified=true;
- if ($filter)
- {
- // \TODO Add a filter
-
- $eventqualified=false;
- }
-
if ($eventqualified)
{
// See http://fr.wikipedia.org/wiki/ICalendar for format
// See http://www.ietf.org/rfc/rfc2445.txt for RFC
$uid = $event['uid'];
$type = $event['type'];
- $startdate = $event['startdate'];
+ $startdate = $event['startdate'];
$duration = $event['duration'];
$enddate = $event['enddate'];
$summary = $event['summary'];
@@ -88,9 +80,11 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$fi
$location = $event['location'];
$email = $event['email'];
$url = $event['url'];
- $transparency = $event['transparency']; // OPAQUE or TRANSPARENT
+ $transparency = $event['transparency']; // OPAQUE (busy) or TRANSPARENT (not busy)
$description=preg_replace('/ /i',"\n",$event['desc']);
$description=dol_string_nohtmltag($description,0); // Remove html tags
+ $created = $event['created'];
+ $modified = $event['modified'];
// Uncomment for tests
//$summary="Resume";
@@ -104,6 +98,39 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$fi
$location=format_cal($format,$location);
// Output the vCard/iCal VEVENT object
+ /*
+ Example from Google ical export for a 1 hour event:
+ BEGIN:VEVENT
+ DTSTART:20101103T120000Z
+ DTEND:20101103T130000Z
+ DTSTAMP:20101121T144902Z
+ UID:4eilllcsq8r1p87ncg7vc8dbpk@google.com
+ CREATED:20101121T144657Z
+ DESCRIPTION:
+ LAST-MODIFIED:20101121T144707Z
+ LOCATION:
+ SEQUENCE:0
+ STATUS:CONFIRMED
+ SUMMARY:Tache 1 heure
+ TRANSP:OPAQUE
+ END:VEVENT
+
+ Example from Google ical export for a 1 day event:
+ BEGIN:VEVENT
+ DTSTART;VALUE=DATE:20101102
+ DTEND;VALUE=DATE:20101103
+ DTSTAMP:20101121T144902Z
+ UID:d09t43kcf1qgapu9efsmmo1m6k@google.com
+ CREATED:20101121T144607Z
+ DESCRIPTION:
+ LAST-MODIFIED:20101121T144607Z
+ LOCATION:
+ SEQUENCE:0
+ STATUS:CONFIRMED
+ SUMMARY:Tache 1 jour
+ TRANSP:TRANSPARENT
+ END:VEVENT
+ */
if ($type == 'event')
{
fwrite($calfileh,"BEGIN:VEVENT\n");
@@ -118,9 +145,10 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$fi
fwrite($calfileh,"URL:".$url."\n");
};
- fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
+ if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
+ 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");
- //fwrite($calfileh,'STATUS:CONFIRMED'."\n");
/*
// Status values for a "VEVENT"
statvalue = "TENTATIVE" ;Indicates event is
@@ -148,22 +176,35 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$fi
//fwrite($calfileh,"CLASS:PUBLIC\n"); // PUBLIC, PRIVATE, CONFIDENTIAL
// Date must be GMT dates
+ // Current date
fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n");
- $startdatef = dol_print_date($startdate,'dayhourxcard',true);
- /* TODO Try to change value to have "fulldayevent stored"
- if (! $fulldayevent) $startdatef = dol_print_date($startdate,'dayhourxcard',true);
+ // Start date
+ $prefix='';
+ $startdatef = dol_print_date($startdate,'dayhourxcard',true);
+ if ($fulldayevent)
+ {
+ $prefix=';VALUE=DATE';
+ $startdatef = dol_print_date($startdate,'dayxcard',false); // Local time
+ }
+ fwrite($calfileh,"DTSTART".$prefix.":".$startdatef."\n");
+ // End date
+ if ($fulldayevent)
+ {
+ if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d');
+ }
else
{
- $startdatef = dol_print_date($startdate,'dayxcard',true);
+ if (empty($enddate)) $enddate=$startdate+$duration;
}
- */
- fwrite($calfileh,"DTSTART:".$startdatef."\n");
- if (empty($enddate)) $enddate=$startdate+$duration;
- //if (! $fulldayevent)
- //{
- $enddatef = dol_print_date($enddate,'dayhourxcard',true);
- fwrite($calfileh,"DTEND:".$enddatef."\n");
- //}
+ $prefix='';
+ $enddatef = dol_print_date($enddate,'dayhourxcard',true);
+ if ($fulldayevent)
+ {
+ $prefix=';VALUE=DATE';
+ $enddatef = dol_print_date($enddate+1,'dayxcard',false); // Local time
+ }
+ fwrite($calfileh,"DTEND".$prefix.":".$enddatef."\n");
+ fwrite($calfileh,'STATUS:CONFIRMED'."\n");
if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n");
if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n");
fwrite($calfileh,"END:VEVENT\n");
@@ -188,6 +229,8 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$fi
fwrite($calfileh,"URL:".$url."\n");
};
+ if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
+ 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");
fwrite($calfileh,'STATUS:CONFIRMED'."\n");
diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php
index 23254885780..ece9d4edcfb 100644
--- a/htdocs/public/agenda/agendaexport.php
+++ b/htdocs/public/agenda/agendaexport.php
@@ -96,14 +96,15 @@ $filename=$shortfilename;
// Complete long filename
foreach ($filters as $key => $value)
{
- if ($key == 'year') $filename.='-year'.$value;
- if ($key == 'id') $filename.='-id'.$value;
- if ($key == 'idfrom') $filename.='-idfrom'.$value;
- if ($key == 'idto') $filename.='-idto'.$value;
- if ($key == 'login') $filename.='-login'.$value;
- if ($key == 'logina') $filename.='-logina'.$value; // Author
- if ($key == 'logind') $filename.='-logind'.$value; // Affected to
- if ($key == 'logint') $filename.='-logint'.$value; // Done by
+ //if ($key == 'notolderthan') $filename.='-notolderthan'.$value; This filter key is already added before and does not need to be in filename
+ if ($key == 'year') $filename.='-year'.$value;
+ if ($key == 'id') $filename.='-id'.$value;
+ if ($key == 'idfrom') $filename.='-idfrom'.$value;
+ if ($key == 'idto') $filename.='-idto'.$value;
+ if ($key == 'login') $filename.='-login'.$value;
+ if ($key == 'logina') $filename.='-logina'.$value; // Author
+ if ($key == 'logind') $filename.='-logind'.$value; // Affected to
+ if ($key == 'logint') $filename.='-logint'.$value; // Done by
}
// Add extension
if ($format == 'vcal') { $shortfilename.='.vcs'; $filename.='.vcs'; }
diff --git a/htdocs/webcalendar/class/webcal.class.php b/htdocs/webcalendar/class/webcal.class.php
index cf0b517e8a2..fd2eafaf625 100644
--- a/htdocs/webcalendar/class/webcal.class.php
+++ b/htdocs/webcalendar/class/webcal.class.php
@@ -183,13 +183,13 @@ class Webcal {
\param filters Array of filters
\return int <0 if error, nb of events in new file if ok
*/
- function build_calfile($format,$type,$cachedelay,$filename,$filters)
+ function wbuild_calfile($format,$type,$cachedelay,$filename,$filters)
{
global $conf,$langs;
require_once (DOL_DOCUMENT_ROOT ."/lib/xcal.lib.php");
- dol_syslog("webcal::build_calfile Build cal file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".sizeof($filters), LOG_DEBUG);
+ dol_syslog("webcal::wbuild_calfile Build cal file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".sizeof($filters), LOG_DEBUG);
// Check parameters
if (empty($format)) return -1;
@@ -223,7 +223,7 @@ class Webcal {
$sql.= " FROM webcal_entry";
$sql.= " ORDER BY cal_date";
- dol_syslog("Webcal::build_vcal select events sql=".$sql);
+ dol_syslog("Webcal::wbuild_vcal select events sql=".$sql);
$resql=$this->localdb->query($sql);
if ($resql)
{
@@ -273,7 +273,7 @@ class Webcal {
}
else
{
- dol_syslog("webcal::build_calfile ".$this->localdb->lasterror());
+ dol_syslog("webcal::wbuild_calfile ".$this->localdb->lasterror());
return -1;
}
diff --git a/htdocs/webcalendar/webcalexport.php b/htdocs/webcalendar/webcalexport.php
index 18ecfd2ca16..b5d14280b7e 100644
--- a/htdocs/webcalendar/webcalexport.php
+++ b/htdocs/webcalendar/webcalexport.php
@@ -95,7 +95,7 @@ $filters=array();
if (! empty($_GET["year"])) $filters['year']=$_GET["year"];
// Build file
-$result=$webcal->build_calfile($format,$type,0,$filename,$filters);
+$result=$webcal->wbuild_calfile($format,$type,0,$filename,$filters);
if ($result >= 0)
{
$attachment = false;