From b207f3419dd291059157aa59f206d79f4228bb70 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Apr 2008 23:46:01 +0000 Subject: [PATCH] Fix: Export calendar to ical --- htdocs/actioncomm.class.php | 10 +++- htdocs/comm/action/agendaexport.php | 86 +++++++++++++++++++++++++++++ htdocs/comm/action/fiche.php | 2 +- htdocs/comm/action/listactions.php | 12 ++-- htdocs/langs/fr_FR/agenda.lang | 2 +- htdocs/lib/images.lib.php | 19 ++++--- 6 files changed, 112 insertions(+), 19 deletions(-) create mode 100644 htdocs/comm/action/agendaexport.php diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php index 1e47756923b..1b2862b6042 100644 --- a/htdocs/actioncomm.class.php +++ b/htdocs/actioncomm.class.php @@ -552,7 +552,7 @@ class ActionComm $filename=$format.'.'.$extension; } - create_exdir($conf->agenda->dir_temp); + $result=create_exdir($conf->agenda->dir_temp); $outputfile=$conf->agenda->dir_temp.'/'.$filename; $result=0; @@ -583,7 +583,12 @@ class ActionComm $sql.= " c.id as type_id, c.code as type_code, c.libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c"; $sql.= " WHERE a.fk_action=c.id"; - $sql.= " order by datec"; + foreach($filters as $key => $value) + { + if ($key == 'year') $sql.=' AND '; + if ($key == 'idaction') $sql.=' AND a.id='.$value; + } + $sql.= " ORDER by datec"; dolibarr_syslog("ActionComm::build_vcal select events sql=".$sql); $resql=$this->db->query($sql); @@ -620,6 +625,7 @@ class ActionComm } else { + $this->error=$this->db->lasterror(); dolibarr_syslog("ActionComm::build_calfile ".$this->db->lasterror(), LOG_ERR); return -1; } diff --git a/htdocs/comm/action/agendaexport.php b/htdocs/comm/action/agendaexport.php new file mode 100644 index 00000000000..c804c232404 --- /dev/null +++ b/htdocs/comm/action/agendaexport.php @@ -0,0 +1,86 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** \file htdocs/comm/action/agendaexport.php + \ingroup agenda + \brief Page export agenda + \version $Id$ +*/ + +// This is to make Dolibarr working with Plesk +set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); + +require("../../master.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php'); + + +// C'est un wrapper, donc header vierge +function llxHeader() { print 'Export agenda cal'; } +function llxFooter() { print ''; } + + +// Check config +if (! $conf->agenda->enabled && empty($conf->global->MAIN_PASSWORD_VCALEXPORT)) +{ + $user->getrights(); + + llxHeader(); + print '
Module Agenda was not configured properly.
'; + llxFooter('$Date$ - $Revision$'); + exit; +} + + +$mainmenu=isset($_GET["mainmenu"])?$_GET["mainmenu"]:""; +$leftmenu=isset($_GET["leftmenu"])?$_GET["leftmenu"]:""; + +// Define format, type, filename and filter +$format='vcal'; +$type='event'; +$filename=''; +if (! empty($_GET["format"])) $format=$_GET["format"]; +if ($format == 'vcal') $filename='dolibarrcalendar.vcs'; +if ($format == 'ical') $filename='dolibarrcalendar.ics'; +if (! empty($_GET["type"])) $type=$_GET["type"]; +if (! $filename) +{ + $langs->load("main"); + $langs->load("errors"); + llxHeader(); + print '
'.$langs->trans("ErrorWrongValueForParameterX",'format').'
'; + llxFooter('$Date$ - $Revision$'); + exit; +} +$filters=array(); +if (! empty($_GET["year"])) $filters['year']=$_GET["year"]; +if (! empty($_GET["idaction"])) $filters['idaction']=$_GET["idaction"]; + +$agenda=new ActionComm($db); + +// Build file +$result=$agenda->build_calfile($format,$type,0,$filename,$filters); +if ($result >= 0) +{ + header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename)); + exit; +} + +llxHeader(); +print '
'.$agenda->error.'
'; +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 9b5c454d70e..333707a48fc 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -827,7 +827,7 @@ llxFooter('$Date$ - $Revision$'); /** \brief Ajoute une ligne de tableau a 2 colonnes pour avoir l'option synchro calendrier - \return int Retourne le nombre de lignes ajout�es + \return int Retourne le nombre de lignes ajoutees */ function add_row_for_calendar_link() { diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 4a96c27f39a..cf50a957aaa 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -230,9 +230,9 @@ if ($resql) print ""; print ''; print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"acode",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Title"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("DatePlanShort"),$_SERVER["PHP_SELF"],"a.datep",$param,'','',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateRealShort"),$_SERVER["PHP_SELF"],"a.datea2",$param,'','',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Title"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("ActionUserAsk"),$_SERVER["PHP_SELF"],"ua.login",$param,"","",$sortfield,$sortorder); @@ -260,6 +260,11 @@ if ($resql) print $actionstatic->getNomUrl(1,4); print ''; + // Titre + print ''; + print ''; - // Titre - print ''; - // Société print '
'; + print dolibarr_trunc($obj->label,12); + print ''; print dolibarr_print_date($obj->dp,"day"); $late=0; @@ -274,11 +279,6 @@ if ($resql) print dolibarr_print_date($obj->da2,"day"); print ''; - print dolibarr_trunc($obj->label,10); - print ''; $societestatic->id=$obj->socid; diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang index 3085ba35d61..98795281b97 100644 --- a/htdocs/langs/fr_FR/agenda.lang +++ b/htdocs/langs/fr_FR/agenda.lang @@ -23,5 +23,5 @@ ViewList=Voir liste ViewCal=Voir calendrier ViewWithPredefinedFilters=Vues avec filtres prédéfinis AutoActions=Création automatiques des actions -AgendaAutoActionDesc=Définissez dans cet onglet, les actions pour lesquels dolibarr créera automatique une tache dans l'agenda. Si aucune case n'est cochée (par défaut), seules les actions manuelles seront incluses dans l'agenda. +AgendaAutoActionDesc=Définissez dans cet onglet, les actions pour lesquels dolibarr créera automatiquement une tache 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. \ No newline at end of file diff --git a/htdocs/lib/images.lib.php b/htdocs/lib/images.lib.php index b1bc33a3dc7..d32095635c5 100644 --- a/htdocs/lib/images.lib.php +++ b/htdocs/lib/images.lib.php @@ -26,15 +26,16 @@ -/* - * \brief Création de 2 vignettes a partir d'un fichier image (une small et un mini) - * \brief Les extension prise en compte sont jpg et png - * \param file Chemin du fichier image a redimensionner - * \param maxWidth Largeur maximum que dois faire la miniature (160 par défaut) - * \param maxHeight Hauteur maximum que dois faire l'image (120 par défaut) - * \param extName Extension pour différencier le nom de la vignette - * \param quality Qualité de compression (0=worst, 100=best) - * \return string Chemin de la vignette +/** + * \brief Create a thumbnail from an image file (une small et un mini) + * \brief Les extensions prises en compte sont jpg et png + * \param file Chemin du fichier image a redimensionner + * \param maxWidth Largeur maximum que dois faire la miniature (160 par défaut) + * \param maxHeight Hauteur maximum que dois faire l'image (120 par défaut) + * \param extName Extension pour différencier le nom de la vignette + * \param quality Qualité de compression (0=worst, 100=best) + * \return string Full path of thumb + * \remarks With file=myfile.jpg -> myfile_small.jpg */ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50) {