New: Support "fulday" event in calendar module

This commit is contained in:
Laurent Destailleur 2010-11-19 23:50:27 +00:00
parent 004c15a501
commit 770bdefc54
6 changed files with 43 additions and 20 deletions

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2008-2009 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2008-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -134,7 +134,7 @@ $urlvcal='<a href="'.$urlwithouturlroot.DOL_URL_ROOT.'/public/agenda/agendaexpor
$message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'vcal',$urlvcal); $message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'vcal',$urlvcal);
$message.='<br>'; $message.='<br>';
$urlical='<a href="'.$urlwithouturlroot.DOL_URL_ROOT.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithouturlroot.DOL_URL_ROOT.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>'; $urlical='<a href="'.$urlwithouturlroot.DOL_URL_ROOT.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithouturlroot.DOL_URL_ROOT.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
$message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'ical',$urlical); $message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'ical/ics',$urlical);
$message.='<br>'; $message.='<br>';
$urlrss='<a href="'.$urlwithouturlroot.DOL_URL_ROOT.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithouturlroot.DOL_URL_ROOT.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>'; $urlrss='<a href="'.$urlwithouturlroot.DOL_URL_ROOT.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithouturlroot.DOL_URL_ROOT.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
$message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'rss',$urlrss); $message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'rss',$urlrss);

View File

@ -596,13 +596,13 @@ class ActionComm extends CommonObject
/** /**
* \brief Export events from database into a cal file. * Export events from database into a cal file.
* \param format 'ical' or 'vcal' * @param format 'ical' or 'vcal'
* \param type 'event' or 'journal' * @param type 'event' or 'journal'
* \param cachedelay Do not rebuild file if date older than cachedelay seconds * @param cachedelay Do not rebuild file if date older than cachedelay seconds
* \param filename Force filename * @param filename Force filename
* \param filters Array of filters * @param filters Array of filters
* \return int <0 if error, nb of events in new file if ok * @return int <0 if error, nb of events in new file if ok
*/ */
function build_exportfile($format,$type,$cachedelay,$filename,$filters) function build_exportfile($format,$type,$cachedelay,$filename,$filters)
{ {
@ -661,7 +661,7 @@ class ActionComm extends CommonObject
$sql.= " a.fk_user_author, a.fk_user_mod,"; $sql.= " a.fk_user_author, a.fk_user_mod,";
$sql.= " a.fk_user_action, a.fk_user_done,"; $sql.= " a.fk_user_action, a.fk_user_done,";
$sql.= " a.fk_contact, a.fk_facture, a.percent as percentage, a.fk_commande,"; $sql.= " a.fk_contact, a.fk_facture, a.percent as percentage, a.fk_commande,";
$sql.= " a.priority, a.location,"; $sql.= " a.priority, a.fulldayevent, a.location,";
$sql.= " u.firstname, u.name,"; $sql.= " u.firstname, u.name,";
$sql.= " s.nom as socname,"; $sql.= " s.nom as socname,";
$sql.= " c.id as type_id, c.code as type_code, c.libelle"; $sql.= " c.id as type_id, c.code as type_code, c.libelle";
@ -740,6 +740,7 @@ class ActionComm extends CommonObject
$event['enddate']=$dateend; // Not required with type 'journal' $event['enddate']=$dateend; // Not required with type 'journal'
$event['author']=$obj->firstname.($obj->name?" ".$obj->name:""); $event['author']=$obj->firstname.($obj->name?" ".$obj->name:"");
$event['priority']=$obj->priority; $event['priority']=$obj->priority;
$event['fulldayevent']=$obj->fulldayevent;
$event['location']=$langs->convToOutputCharset($obj->location); $event['location']=$langs->convToOutputCharset($obj->location);
$event['transparency']='TRANSPARENT'; // TRANSPARENT or OPAQUE $event['transparency']='TRANSPARENT'; // TRANSPARENT or OPAQUE
$event['category']=$langs->convToOutputCharset($obj->libelle); // libelle type action $event['category']=$langs->convToOutputCharset($obj->libelle); // libelle type action

View File

@ -847,13 +847,15 @@ if ($id)
// Date debut // Date debut
print '<tr><td width="30%">'.$langs->trans("DateActionStart").'</td><td colspan="3">'; print '<tr><td width="30%">'.$langs->trans("DateActionStart").'</td><td colspan="3">';
print dol_print_date($act->datep,'dayhour'); if (! $act->fulldayevent) print dol_print_date($act->datep,'dayhour');
else print dol_print_date($act->datep,'day');
if ($act->percentage == 0 && $act->datep && $act->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); if ($act->percentage == 0 && $act->datep && $act->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late"));
print '</td></tr>'; print '</td></tr>';
// Date fin // Date fin
print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">';
print dol_print_date($act->datef,'dayhour'); if (! $act->fulldayevent) print dol_print_date($act->datef,'dayhour');
else print dol_print_date($act->datef,'day');
if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late"));
print '</td></tr>'; print '</td></tr>';
@ -875,7 +877,7 @@ if ($id)
if ($act->usertodo->id > 0) print $act->usertodo->getNomUrl(1); if ($act->usertodo->id > 0) print $act->usertodo->getNomUrl(1);
print '</td></tr>'; print '</td></tr>';
// Realise par // Done by
print '<tr><td nowrap>'.$langs->trans("ActionDoneBy").'</td><td colspan="3">'; print '<tr><td nowrap>'.$langs->trans("ActionDoneBy").'</td><td colspan="3">';
if ($act->userdone->id > 0) print $act->userdone->getNomUrl(1); if ($act->userdone->id > 0) print $act->userdone->getNomUrl(1);
print '</td></tr>'; print '</td></tr>';

View File

@ -469,6 +469,7 @@ function dol_print_date($time,$format='',$to_gmt=false,$outputlangs='',$encodeto
if ($format == 'dayhourlog') $format='%Y%m%d%H%M%S'; if ($format == 'dayhourlog') $format='%Y%m%d%H%M%S';
if ($format == 'dayhourldap') $format='%Y%m%d%H%M%SZ'; if ($format == 'dayhourldap') $format='%Y%m%d%H%M%SZ';
if ($format == 'dayhourxcard') $format='%Y%m%dT%H%M%SZ'; if ($format == 'dayhourxcard') $format='%Y%m%dT%H%M%SZ';
if ($format == 'dayxcard') $format='%Y%m%d';
// If date undefined or "", we return "" // If date undefined or "", we return ""
if (dol_strlen($time) == 0) return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) if (dol_strlen($time) == 0) return ''; // $time=0 allowed (it means 01/01/1970 00:00:00)

View File

@ -25,6 +25,7 @@
/** /**
* \brief Build a file from an array of events * \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 format 'vcal' or 'ical'
* \param title Title of export * \param title Title of export
* \param desc Description of export * \param desc Description of export
@ -32,7 +33,6 @@
* \param outputfile Output file * \param outputfile Output file
* \param filter Filter * \param filter Filter
* \return int <0 if ko, Nb of events in file if ok * \return int <0 if ko, Nb of events in file if ok
* \remarks All input params and data must be encoded in $conf->charset_output
*/ */
function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$filter='') function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$filter='')
{ {
@ -83,7 +83,9 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$fi
$enddate = $event['enddate']; $enddate = $event['enddate'];
$summary = $event['summary']; $summary = $event['summary'];
$category = $event['category']; $category = $event['category'];
$location = $event['location']; $priority = $event['priority'];
$fulldayevent = $event['fulldayevent'];
$location = $event['location'];
$email = $event['email']; $email = $event['email'];
$url = $event['url']; $url = $event['url'];
$transparency = $event['transparency']; // OPAQUE or TRANSPARENT $transparency = $event['transparency']; // OPAQUE or TRANSPARENT
@ -144,12 +146,15 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$fi
// Date must be GMT dates // Date must be GMT dates
fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n"); fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n");
$startdatef = dol_print_date($startdate,'dayhourxcard',true); if (! $fulldayevent) $startdatef = dol_print_date($startdate,'dayhourxcard',true);
else $startdatef = dol_print_date($startdate,'dayxcard',true);
fwrite($calfileh,"DTSTART:".$startdatef."\n"); fwrite($calfileh,"DTSTART:".$startdatef."\n");
if (empty($enddate)) $enddate=$startdate+$duration; if (empty($enddate)) $enddate=$startdate+$duration;
$enddatef = dol_print_date($enddate,'dayhourxcard',true); if (! $fulldayevent)
fwrite($calfileh,"DTEND:".$enddatef."\n"); {
$enddatef = dol_print_date($enddate,'dayhourxcard',true);
fwrite($calfileh,"DTEND:".$enddatef."\n");
}
if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n"); if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n");
if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n"); if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n");
fwrite($calfileh,"END:VEVENT\n"); fwrite($calfileh,"END:VEVENT\n");
@ -218,6 +223,7 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$fi
/** /**
* \brief Build a file from an array of events * \brief Build a file from an array of events
* All input data must be encoded in $conf->charset_output
* \param format 'rss' * \param format 'rss'
* \param title Title of export * \param title Title of export
* \param desc Description of export * \param desc Description of export
@ -225,7 +231,6 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$fi
* \param outputfile Output file * \param outputfile Output file
* \param filter Filter * \param filter Filter
* \return int <0 if ko, Nb of events in file if ok * \return int <0 if ko, Nb of events in file if ok
* \remarks All input data must be encoded in $conf->charset_output
*/ */
function build_rssfile($format='rss',$title,$desc,$events_array,$outputfile,$filter='') function build_rssfile($format='rss',$title,$desc,$events_array,$outputfile,$filter='')
{ {
@ -296,6 +301,12 @@ function build_rssfile($format='rss',$title,$desc,$events_array,$outputfile,$fil
$url = $event['url']; $url = $event['url'];
$author = $event['author']; $author = $event['author'];
$category = $event['category']; $category = $event['category'];
/* No place inside a RSS
$priority = $event['priority'];
$fulldayevent = $event['fulldayevent'];
$location = $event['location'];
$email = $event['email'];
*/
$description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']); $description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
$description=dol_string_nohtmltag($description,0); // Remove html tags $description=dol_string_nohtmltag($description,0); // Remove html tags

View File

@ -23,6 +23,14 @@
* \version $Id$ * \version $Id$
*/ */
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOLOGIN",1); // This means this output page does not require to be logged.
define("NOCSRFCHECK",1); // We accept to go on this page from external web site. define("NOCSRFCHECK",1); // We accept to go on this page from external web site.