mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-08 02:28:23 +01:00
New: Support "fulday" event in calendar module
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -466,7 +466,7 @@ if (GETPOST('action') == 'create')
|
||||
print '<input type="hidden" name="action" value="add_action">';
|
||||
if (GETPOST("backtopage")) print '<input type="hidden" name="backtopage" value="'.(GETPOST("backtopage") != 1 ? GETPOST("backtopage") : $_SERVER["HTTP_REFERER"]).'">';
|
||||
|
||||
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.'<br>';
|
||||
@@ -495,16 +495,20 @@ if (GETPOST('action') == 'create')
|
||||
print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td><input type="checkbox" id="fullday" name="fullday" '.(GETPOST('fullday')?' checked="checked"':'').'></td></tr>';
|
||||
|
||||
// Date start
|
||||
$datep=$actioncomm->datep;
|
||||
if (GETPOST('datep','int',1)) $datep=dol_stringtotime(GETPOST('datep','int',1),0);
|
||||
print '<tr><td width="30%" nowrap="nowrap"><span class="fieldrequired">'.$langs->trans("DateActionStart").'</span></td><td>';
|
||||
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 '</td></tr>';
|
||||
// Date end
|
||||
$datef=$actioncomm->datef;
|
||||
if (GETPOST('datef','int',1)) $datef=dol_stringtotime(GETPOST('datef','int',1),0);
|
||||
print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td>';
|
||||
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 '</td></tr>';
|
||||
|
||||
// Status
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -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).
|
||||
* 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
|
||||
* @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
|
||||
* 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
|
||||
* \return date Date
|
||||
* \see dol_date, dol_mktime
|
||||
* @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)
|
||||
{
|
||||
|
||||
@@ -24,17 +24,16 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Build a file from an array of events
|
||||
* 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
|
||||
* @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,13 +64,6 @@ 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
|
||||
@@ -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('/<br[\s\/]?>/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");
|
||||
};
|
||||
|
||||
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");
|
||||
// Start date
|
||||
$prefix='';
|
||||
$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);
|
||||
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);
|
||||
}
|
||||
*/
|
||||
fwrite($calfileh,"DTSTART:".$startdatef."\n");
|
||||
if (empty($enddate)) $enddate=$startdate+$duration;
|
||||
//if (! $fulldayevent)
|
||||
//{
|
||||
}
|
||||
$prefix='';
|
||||
$enddatef = dol_print_date($enddate,'dayhourxcard',true);
|
||||
fwrite($calfileh,"DTEND:".$enddatef."\n");
|
||||
//}
|
||||
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");
|
||||
|
||||
@@ -96,6 +96,7 @@ $filename=$shortfilename;
|
||||
// Complete long filename
|
||||
foreach ($filters as $key => $value)
|
||||
{
|
||||
//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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user