New: Can set a past delay to limit calendar export

This commit is contained in:
Laurent Destailleur 2010-05-22 09:50:32 +00:00
parent 7148eb584c
commit 8c0a14fa6d
7 changed files with 30 additions and 11 deletions

View File

@ -3,6 +3,7 @@ English Dolibarr ChangeLog
***** ChangeLog for 2.9 compared to 2.8 *****
For users:
- New: Can set a past delay to limit calendar export.
- New: Can join files on emailing campaigns.
- New: Add statistics on trips and expenses module.
- New: Can reopen a closed customer order.

View File

@ -46,9 +46,10 @@ if ($actionsave)
$db->begin();
$i+=dolibarr_set_const($db,'MAIN_AGENDA_XCAL_EXPORTKEY',trim($_POST["MAIN_AGENDA_XCAL_EXPORTKEY"]),'chaine',0,'',$conf->entity);
$i+=dolibarr_set_const($db,'MAIN_AGENDA_EXPORT_PAST_DELAY',trim($_POST["MAIN_AGENDA_EXPORT_PAST_DELAY"]),'chaine',0,'',$conf->entity);
$i+=dolibarr_set_const($db,'MAIN_AGENDA_EXPORT_CACHE',trim($_POST["MAIN_AGENDA_EXPORT_CACHE"]),'chaine',0,'',$conf->entity);
if ($i >= 2)
if ($i >= 3)
{
$db->commit();
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
@ -66,6 +67,8 @@ if ($actionsave)
* View
*/
if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100;
llxHeader();
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
@ -98,6 +101,12 @@ print "<td>&nbsp;</td>";
print "</tr>";
print "<tr class=\"pair\">";
print "<td>".$langs->trans("PastDelayVCalExport")."</td>";
print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_PAST_DELAY\" value=\"". ($_POST["MAIN_AGENDA_EXPORT_PAST_DELAY"]?$_POST["MAIN_AGENDA_EXPORT_PAST_DELAY"]:$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY) . "\" size=\"10\"> ".$langs->trans("days")."</td>";
print "<td>&nbsp;</td>";
print "</tr>";
print "<tr class=\"impair\">";
print "<td>".$langs->trans("UseACacheDelay")."</td>";
print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_CACHE\" value=\"". ($_POST["MAIN_AGENDA_EXPORT_CACHE"]?$_POST["MAIN_AGENDA_EXPORT_CACHE"]:$conf->global->MAIN_AGENDA_EXPORT_CACHE) . "\" size=\"10\"></td>";
print "<td>&nbsp;</td>";

View File

@ -585,6 +585,7 @@ class ActionComm
global $conf,$langs,$dolibarr_main_url_root;
require_once (DOL_DOCUMENT_ROOT ."/lib/xcal.lib.php");
require_once (DOL_DOCUMENT_ROOT ."/lib/date.lib.php");
dol_syslog("ActionComm::build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".sizeof($filters), LOG_DEBUG);
@ -609,12 +610,14 @@ class ActionComm
$buildfile=true;
$login='';$logina='';$logind='';$logint='';
$now = dol_now();
if ($cachedelay)
{
$now = gmmktime();
if (filemtime($outputfile) > ($now - $cachedelay))
$nowgmt = dol_now('gmt');
if (filemtime($outputfile) > ($nowgmt - $cachedelay))
{
dol_syslog("ActionComm::build_exportfile file ".$outputfile." not older than now - cachedelay (".$now." - ".$cachedelay."). Build is canceled");
dol_syslog("ActionComm::build_exportfile file ".$outputfile." is not older than now - cachedelay (".$nowgmt." - ".$cachedelay."). Build is canceled");
$buildfile = false;
}
}
@ -625,8 +628,8 @@ class ActionComm
$eventarray=array();
$sql = "SELECT a.id,";
$sql.= " a.datep,";
$sql.= " a.datep2,";
$sql.= " a.datep,"; // Start
$sql.= " a.datep2,"; // End
$sql.= " a.durationp,";
$sql.= " a.datec, a.tms as datem,";
$sql.= " a.note, a.label, a.fk_action as type_id,";
@ -644,7 +647,8 @@ class ActionComm
$sql.= " WHERE a.fk_action=c.id";
foreach ($filters as $key => $value)
{
if ($key == 'year') $sql.=' AND a.datep BETWEEN ( )'; // TODO Put year range
if ($key == 'notolderthan') $sql.=" AND a.datep >= '".$this->db->idate($now-($value*24*60*60))."'";
if ($key == 'year') $sql.=" AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($value,1))."' AND '".$this->db->idate(dol_get_last_day($value,12))."'";
if ($key == 'idaction') $sql.=' AND a.id='.$value;
if ($key == 'login')
{
@ -680,8 +684,8 @@ class ActionComm
}
}
$sql.= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import
//$sql.= " AND a.datep != 'null'"; // To exclude corrupted events and avoid errors in lightning/sunbird import
$sql.= " ORDER by datep";
//print $sql;exit;
dol_syslog("ActionComm::build_exportfile select events sql=".$sql);
$resql=$this->db->query($sql);

View File

@ -1136,6 +1136,7 @@ YourCompanyDoesNotUseVAT=Your company has been defined to not use VAT (Home - Se
##### Agenda #####
AgendaSetup=Actions and agenda module setup
PasswordTogetVCalExport=Key to authorize export link
PastDelayVCalExport=Do not export event older than
##### ClickToDial #####
ClickToDialDesc=This module allows to add an icon after the phone number of Dolibarr contacts. A click on this icon, will call a serveur with a particular URL you define below. This can be used to call a call center system from Dolibarr that can call the phone number on a SIP system for example.
##### Point Of Sales (CashDesk) #####

View File

@ -1138,6 +1138,7 @@ YourCompanyDoesNotUseVAT=Votre institution est configurée comme non assujettie
##### Agenda #####= undefined
AgendaSetup= Configuration du module actions et agenda
PasswordTogetVCalExport= Clé pour autoriser lien export
PastDelayVCalExport=Ne pas exporter les évênements de plus de
##### ClickToDial #####= undefined
ClickToDialDesc= Ce module permet d'ajouter un petit picto à côté des numéros de téléphones des contacts. Un clic sur ce picto provoque l'appel de l'URL définie dans ce paramétrage. Ceci permet de provoquer des appels à un serveur de téléphonie depuis Dolibarr qui peut alors composer le numéro sur un system SIP par exemple.
##### Point Of Sales (CashDesk) #####

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2008-2009 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2008-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -306,7 +306,7 @@ function agenda_prepare_head()
$h++;
$head[$h][0] = DOL_URL_ROOT."/admin/agenda_xcal.php";
$head[$h][1] = $langs->trans("Other");
$head[$h][1] = $langs->trans("Export");
$head[$h][2] = 'xcal';
$h++;

View File

@ -51,7 +51,9 @@ if (! empty($_GET["login"])) $filters['login']=$_GET["login"];
if (! empty($_GET["logina"])) $filters['logina']=$_GET["logina"];
if (! empty($_GET["logint"])) $filters['logint']=$_GET["logint"];
if (! empty($_GET["logind"])) $filters['logind']=$_GET["logind"];
// Not older than
if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100;
$filters['notolderthan']=$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY;
// Check config
if (empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY))
@ -75,6 +77,7 @@ if (empty($_GET["exportkey"]) || $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY != $_
exit;
}
// Define filename with prefix on filters predica (each predica set must have on cache file)
$filename='';
$shortfilename='';