New: Yeh! Now all automatic actions are externalised in triggers. This make code so so much easier to understand and offer a lot of possible new features.

This commit is contained in:
Laurent Destailleur 2008-04-07 22:11:22 +00:00
parent 7430dc5bb3
commit f9ed5b522f
20 changed files with 420 additions and 277 deletions

View File

@ -521,6 +521,116 @@ class ActionComm
return $result;
}
/**
\brief Export fichier cal depuis base webcalendar
\param format 'ical' or 'vcal'
\param type 'event' or 'journal'
\param cachedelay Do not rebuild file if date older than cachedelay seconds
\param filename Force filename
\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)
{
global $conf,$langs,$dolibarr_main_url_root;
require_once (DOL_DOCUMENT_ROOT ."/lib/xcal.lib.php");
dolibarr_syslog("ActionComm::build_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;
// Clean parameters
if (! $filename)
{
$extension='vcs';
if ($format == 'ical') $extension='ics';
$filename=$format.'.'.$extension;
}
create_exdir($conf->agenda->dir_temp);
$outputfile=$conf->agenda->dir_temp.'/'.$filename;
$result=0;
$buildfile=true;
if ($cachedelay)
{
// \TODO Check cache
}
if ($buildfile)
{
// Build event array
$eventarray=array();
$sql = "SELECT a.id,";
$sql.= " ".$this->db->pdate("a.datep")." as datep,";
$sql.= " ".$this->db->pdate("a.datep2")." as datep2,";
$sql.= " ".$this->db->pdate("a.datea")." as datea,";
$sql.= " ".$this->db->pdate("a.datea2")." as datea2,";
$sql.= " a.durationp, a.durationa,";
$sql.= " ".$this->db->pdate("a.datec")." as datec, tms as datem,";
$sql.= " a.note, a.label, a.fk_action as type_id,";
$sql.= " a.fk_soc,";
$sql.= " a.fk_user_author, a.fk_user_mod,";
$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.priority,";
$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";
dolibarr_syslog("ActionComm::build_vcal select events sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$qualified=true;
// 'eid','startdate','duration','enddate','title','summary','category','email','url','desc','author'
$event=array();
$event['uid']='dolibarragenda-'.$this->db->database_name.'-'.$obj->id."@".$_SERVER["SERVER_NAME"];
$event['type']=$type;
$datestart=$obj->datea?$obj->datea:$obj->datep;
$dateend=$obj->datea2?$obj->datea2:$obj->datep2;
$duration=$obj->durationa?$obj->durationa:$obj->durationp;
$event['startdate']=$datestart;
$event['duration']=$duration; // Not required with type 'journal'
$event['enddate']=$dateend; // Not required with type 'journal'
$event['summary']=$obj->label;
$event['desc']=$obj->note;
$event['author']=$obj->fk_user_done>0?$obj->fk_user_done:$obj->fk_user_action;
$event['transparency']='TRANSPARENT'; // TRANSPARENT or OPAQUE
$url=$dolibarr_main_url_root.DOL_URL_ROOT;
if (! eregi('\/$',$url)) $url.='/';
$url.='comm/action/fiche.php?id='.$obj->id;
$event['url']=$url;
if ($qualified)
{
$eventarray[$datestart]=$event;
}
}
}
else
{
dolibarr_syslog("ActionComm::build_calfile ".$this->db->lasterror(), LOG_ERR);
return -1;
}
// Write file
$title='Dolibarr actions';
$desc='List of actions - built by Dolibarr';
$result=build_calfile($format,$title,$desc,$eventarray,$outputfile);
}
return $result;
}
}
?>

View File

@ -17,78 +17,109 @@
*/
/**
\file htdocs/admin/agenda.php
\file htdocs/admin/agenda_actions.php
\ingroup agenda
\brief Page de configuration du module agenda
\brief Autocreate actions for agenda module setup page
\version $Id$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/lib/agenda.lib.php');
require_once(DOL_DOCUMENT_ROOT."/lib/agenda.lib.php");
if (!$user->admin)
accessforbidden();
$langs->load("admin");
$langs->load("other");
$langs->load("agenda");
$def = array();
$actionsave=$_POST["save"];
$action=$_POST["action"];
// Sauvegardes parametres
if ($actionsave)
// List of all events supported by triggers
$eventstolog=array(
// array('id'=>'USER_CREATE', 'test'=>1),
// array('id'=>'GROUP_CREATE', 'test'=>1),
// array('id'=>'COMPANY_CREATE', 'test'=>$conf->societe->enabled),
// array('id'=>'CONTRACT_VALIDATE', 'test'=>$conf->contrat->enabled),
// array('id'=>'PROPAL_VALIDATE', 'test'=>$conf->propal->enabled),
array('id'=>'PROPAL_SENTBYMAIL', 'test'=>$conf->propal->enabled),
// array('id'=>'BILL_VALIDATE', 'test'=>$conf->facture->enabled),
// array('id'=>'BILL_PAYED', 'test'=>$conf->facture->enabled),
// array('id'=>'BILL_CANCELED', 'test'=>$conf->facture->enabled),
array('id'=>'BILL_SENTBYMAIL', 'test'=>$conf->facture->enabled),
array('id'=>'ORDER_SENTBYMAIL', 'test'=>$conf->commande->enabled),
// array('id'=>'PAYMENT_CUSTOMER_CREATE','test'=>$conf->facture->enabled),
// array('id'=>'PAYMENT_SUPPLIER_CREATE','test'=>$conf->fournisseur->enabled),
// array('id'=>'MEMBER_VALIDATE', 'test'=>$conf->adherent->enabled),
// array('id'=>'MEMBER_SUBSCRIPTION', 'test'=>$conf->adherent->enabled),
);
/*
* Actions
*/
if ($action == "save")
{
$i=0;
$db->begin();
$i+=dolibarr_set_const($db,'MAIN_PASSWORD_VCALEXPORT',trim($_POST["MAIN_PASSWORD_VCALEXPORT"]),'chaine',0);
if ($i > 0)
{
$db->commit();
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$db->rollback();
$mesg = "<font class=\"error\">".$langs->trans("SaveFailed")."</font>";
}
foreach ($eventstolog as $key => $arr)
{
$param='MAIN_AGENDA_ACTIONAUTO_'.$arr['id'];
//print "param=".$param." - ".$_POST[$param];
if (! empty($_POST[$param])) dolibarr_set_const($db,$param,$_POST[$param],'chaine',0);
else dolibarr_del_const($db,$param);
}
$db->commit();
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
/**
* Vies
* Affichage du formulaire de saisie
*/
llxHeader();
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("AgendaSetup"),$linkback,'setup');
print '<br>';
print "<br>\n";
print $langs->trans("AgendaAutoActionDesc")."<br>\n";
print "<br>\n";
$head=agenda_prepare_head();
dolibarr_fiche_head($head, 'autoactions', $langs->trans("Agenda"));
print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="action" value="save">';
$var=true;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td width=\"30%\">".$langs->trans("Parameter")."</td>";
print "<td>".$langs->trans("Value")."</td>";
//print "<td>".$langs->trans("Examples")."</td>";
print "<td>&nbsp;</td>";
print "</tr>";
print "<tr class=\"impair\">";
print "<td>".$langs->trans("PasswordTogetVCalExport")."</td>";
print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_PASSWORD_VCALEXPORT\" value=\"". ($_POST["MAIN_PASSWORD_VCALEXPORT"]?$_POST["MAIN_PASSWORD_VCALEXPORT"]:$conf->global->MAIN_PASSWORD_VCALEXPORT) . "\" size=\"40\"></td>";
print "<td>&nbsp;</td>";
print "</tr>";
print "<td colspan=\"2\">".$langs->trans("LogEvents")."</td>";
print "</tr>\n";
foreach ($eventstolog as $key => $arr)
{
if ($arr['id'])
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$arr['id'].'</td>';
print '<td>';
$key='MAIN_AGENDA_ACTIONAUTO_'.$arr['id'];
$value=$conf->global->$key;
print '<input type="checkbox" name="'.$key.'" value="1"'.($value?' checked="true"':'').'>';
print '</td></tr>'."\n";
}
}
print '</table>';
print '<br><center>';
@ -97,21 +128,13 @@ print "</center>";
print "</form>\n";
print '</div>';
clearstatcache();
if ($mesg) print "<br>$mesg<br>";
print "<br>";
// Show message
$message='';
$urlwithouturlroot=eregi_replace(DOL_URL_ROOT.'$','',$dolibarr_main_url_root);
$urlvcal='<a href="'.DOL_URL_ROOT.'/comm/action/agendaexport.php?format=vcal&exportkey=..." target="_blank">'.$urlwithouturlroot.DOL_URL_ROOT.'/comm/action/agendaexport.php?format=vcal&exportkey=...'.'</a>';
$message.=$langs->trans("WebCalUrlForVCalExport",'vcal',$urlvcal);
$message.='<br>';
$urlical='<a href="'.DOL_URL_ROOT.'/comm/action/agendaexport.php?format=ical&type=event&exportkey=..." target="_blank">'.$urlwithouturlroot.DOL_URL_ROOT.'/comm/action/agendaexport.php?format=ical&type=event&exportkey=...'.'</a>';
$message.=$langs->trans("WebCalUrlForVCalExport",'ical',$urlical);
print info_admin($message);
$db->close();

View File

@ -14,15 +14,13 @@
* 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.
*
* $Id$
*/
/**
\file htdocs/admin/stock.php
\ingroup stock
\brief Page d'administration/configuration du module gestion de stock
\version $Revision$
\version $Id$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
@ -97,6 +95,7 @@ llxHeader('',$langs->trans("StockSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("StockSetup"),$linkback,'setup');
print '<br>';
$html=new Form($db);
$var=true;

View File

@ -15,17 +15,13 @@
* 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.
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/cactioncomm.class.php
\ingroup commercial
\brief Fichier de la classe des types d'actions commerciales
\version $Revision$
\version $Id$
*/
@ -62,7 +58,7 @@ class CActionComm {
* \param id id ou code du type d'action à récupérer
* \return int 1=ok, 0=aucune action, -1=erreur
*/
function fetch($id)
function fetch($id)
{
$sql = "SELECT id, code, type, libelle, active";

View File

@ -40,8 +40,10 @@ $sortorder=$_GET["sortorder"];
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="a.datea";
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="a.datec";
$status=isset($_GET["status"])?$_GET["status"]:$_POST["status"];
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
@ -137,7 +139,7 @@ $nav.=" $year";
$nav.=" </span>\n";
$nav.="<a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;region=".$region.$param."\">".img_next($langs->trans("Next"))."</a>\n";
print_fiche_titre($title,$nav,$_SERVER["PHP_SELF"], $param,$sortfield,$sortorder,'',$num);
print_fiche_titre($title,$nav,"");
// Filters
if ($canedit)
@ -201,6 +203,8 @@ if ($filtera > 0 || $filtert > 0 || $filterd > 0)
if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd;
$sql.= ")";
}
if ($status == 'done') { $sql.= " AND a.percent = 100"; }
if ($status == 'todo') { $sql.= " AND a.percent < 100"; }
//echo "$sql<br>";
$actionarray=array();
@ -327,7 +331,7 @@ function show_day_events($db, $day, $month, $year, $style, $actionarray)
if ($day==$jour && $month==$mois && $year==$annee)
{
if ($i) print "<br>";
print $action->getNomUrl(1,10)." ".$action->getLibStatut(3);
print $action->getNomUrl(1,9)." ".$action->getLibStatut(3);
$i++;
}
}

View File

@ -351,19 +351,19 @@ if ($_POST['action'] == 'send')
if($subject == '')
{
$subject = $langs->trans('Propal').' '.$propal->ref;
$subject = $langs->transnoentities('Propal').' '.$propal->ref;
}
$actiontypeid=3;
$actionmsg = $langs->trans('MailSentBy').' '.$from.' '.$langs->trans('To').' '.$sendto.'.<br>';
$actiontypecode='AC_PROP';
$actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
if ($message)
{
$actionmsg.=$langs->trans('TextUsedInTheMessageBody').' :<br>';
$actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
$actionmsg.=$message;
}
$actionmsg2=$langs->trans('SendPropalByMail');
$actionmsg2=$langs->transnoentities('SendPropalByMail');
}
$filepath[0] = $file;
@ -389,23 +389,24 @@ if ($_POST['action'] == 'send')
if ($result)
{
$mesg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.</div>';
$error=0;
// Initialisation donnees
$propal->sendtoid=$sendtoid;
$propal->actiontypecode=$actiontypecode;
$propal->actionmsg = $actionmsg;
$propal->actionmsg2= $actionmsg2;
$propal->propalrowid=$propal->id;
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->run_triggers('PROPAL_SENTBYMAIL',$propal,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
// Insertion action
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php');
$actioncomm = new ActionComm($db);
$actioncomm->type_id = $actiontypeid;
$actioncomm->label = $actionmsg2;
$actioncomm->note = $actionmsg;
$actioncomm->date = time(); // L'action est faite maintenant
$actioncomm->percentage = 100;
$actioncomm->contact = new Contact($db,$sendtoid);
$actioncomm->societe = new Societe($db,$propal->socid);
$actioncomm->user = $user; // User qui a fait l'action
$actioncomm->propalrowid = $propal->id;
$ret=$actioncomm->add($user); // User qui saisit l'action
if ($ret < 0)
if ($error)
{
dolibarr_print_error($db);
}
@ -415,7 +416,7 @@ if ($_POST['action'] == 'send')
Header('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&msg='.urlencode($mesg));
exit;
}
}
}
else
{
$langs->load("other");

View File

@ -570,155 +570,156 @@ if ($_REQUEST['action'] == 'remove_file')
*/
if ($_POST['action'] == 'send')
{
$langs->load('mails');
$langs->load('mails');
$commande= new Commande($db);
if ( $commande->fetch($_POST['orderid']) )
{
$orderref = sanitize_string($commande->ref);
$file = $conf->commande->dir_output . '/' . $orderref . '/' . $orderref . '.pdf';
if (is_readable($file))
$commande= new Commande($db);
if ( $commande->fetch($_POST['orderid']) )
{
$commande->fetch_client();
$orderref = sanitize_string($commande->ref);
$file = $conf->commande->dir_output . '/' . $orderref . '/' . $orderref . '.pdf';
if ($_POST['sendto'])
{
// Le destinataire a ete fourni via le champ libre
$sendto = $_POST['sendto'];
$sendtoid = 0;
}
elseif ($_POST['receiver'])
{
// Le destinataire a ete fourni via la liste deroulante
if ($_POST['receiver'] < 0) // Id du tiers
if (is_readable($file))
{
$sendto = $commande->client->email;
$sendtoid = 0;
}
else // Id du contact
{
$sendto = $commande->client->contact_get_email($_POST['receiver']);
$sendtoid = $_POST['receiver'];
}
}
$commande->fetch_client();
if (strlen($sendto))
{
$from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
$replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>';
$message = $_POST['message'];
$sendtocc = $_POST['sendtocc'];
$deliveryreceipt = $_POST['deliveryreceipt'];
if ($_POST['action'] == 'send')
{
$subject = $_POST['subject'];
if($subject == '')
{
$subject = $langs->trans('Order').' '.$commande->ref;
}
$actiontypeid=8;
$actionmsg = $langs->trans('MailSentBy').' '.$from.' '.$langs->trans('To').' '.$sendto.'.<br>';
if ($message)
{
$actionmsg.=$langs->trans('TextUsedInTheMessageBody').' :<br>';
$actionmsg.=$message;
}
$actionmsg2=$langs->trans('SendOrderByMail');
}
$filepath[0] = $file;
$filename[0] = $commande->ref.'.pdf';
$mimetype[0] = 'application/pdf';
if ($_FILES['addedfile']['tmp_name'])
{
$filepath[1] = $_FILES['addedfile']['tmp_name'];
$filename[1] = $_FILES['addedfile']['name'];
$mimetype[1] = $_FILES['addedfile']['type'];
}
// Envoi de la commande
require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php');
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
if ($mailfile->error)
{
$mesg='<div class="error">'.$mailfile->error.'</div>';
}
else
{
$result=$mailfile->sendfile();
if ($result)
{
$mesg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.</div>';
// Insertion action
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php');
$actioncomm = new ActionComm($db);
$actioncomm->type_id = $actiontypeid;
$actioncomm->label = $actionmsg2;
$actioncomm->note = $actionmsg;
$actioncomm->date = time(); // L'action est faite maintenant
$actioncomm->percentage = 100;
$actioncomm->contact = new Contact($db,$sendtoid);
$actioncomm->societe = new Societe($db,$commande->socid);
$actioncomm->user = $user; // User qui a fait l'action
$actioncomm->orderrowid = $commande->id;
$ret=$actioncomm->add($user); // User qui saisit l'action
if ($ret < 0)
if ($_POST['sendto'])
{
dolibarr_print_error($db);
// Le destinataire a ete fourni via le champ libre
$sendto = $_POST['sendto'];
$sendtoid = 0;
}
else
elseif ($_POST['receiver'])
{
// Renvoie sur la fiche
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&msg='.urlencode($mesg));
exit;
// Le destinataire a ete fourni via la liste deroulante
if ($_POST['receiver'] < 0) // Id du tiers
{
$sendto = $commande->client->email;
$sendtoid = 0;
}
else // Id du contact
{
$sendto = $commande->client->contact_get_email($_POST['receiver']);
$sendtoid = $_POST['receiver'];
}
}
}
else
{
$langs->load("other");
$mesg='<div class="error">';
if ($mailfile->error)
if (strlen($sendto))
{
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
$mesg.='<br>'.$mailfile->error;
$from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
$replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>';
$message = $_POST['message'];
$sendtocc = $_POST['sendtocc'];
$deliveryreceipt = $_POST['deliveryreceipt'];
if ($_POST['action'] == 'send')
{
$subject = $_POST['subject'];
if($subject == '')
{
$subject = $langs->transnoentities('Order').' '.$commande->ref;
}
$actiontypecode='AC_COM';
$actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
if ($message)
{
$actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
$actionmsg.=$message;
}
$actionmsg2=$langs->transnoentities('SendOrderByMail');
}
$filepath[0] = $file;
$filename[0] = $commande->ref.'.pdf';
$mimetype[0] = 'application/pdf';
if ($_FILES['addedfile']['tmp_name'])
{
$filepath[1] = $_FILES['addedfile']['tmp_name'];
$filename[1] = $_FILES['addedfile']['name'];
$mimetype[1] = $_FILES['addedfile']['type'];
}
// Envoi de la commande
require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php');
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
if ($mailfile->error)
{
$mesg='<div class="error">'.$mailfile->error.'</div>';
}
else
{
$result=$mailfile->sendfile();
if ($result)
{
$mesg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.</div>';
$error=0;
// Initialisation donnees
$commande->sendtoid=$sendtoid;
$commande->actiontypecode=$actiontypecode;
$commande->actionmsg = $actionmsg;
$commande->actionmsg2= $actionmsg2;
$commande->orderrowid=$commande->id;
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->run_triggers('ORDER_SENTBYMAIL',$commande,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
if ($error)
{
dolibarr_print_error($db);
}
else
{
// Renvoie sur la fiche
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&msg='.urlencode($mesg));
exit;
}
}
else
{
$langs->load("other");
$mesg='<div class="error">';
if ($mailfile->error)
{
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
$mesg.='<br>'.$mailfile->error;
}
else
{
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
}
$mesg.='</div>';
}
}
}
else
else
{
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
dolibarr_syslog('Recipient email is empty');
}
$mesg.='</div>';
}
}
}
else
{
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
dolibarr_syslog('Recipient email is empty');
}
else
{
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
dolibarr_syslog('Failed to read file: '.$file);
}
}
else
else
{
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
dolibarr_syslog('Failed to read file: '.$file);
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'</div>';
dolibarr_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.');
}
}
else
{
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'</div>';
dolibarr_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.');
}
}

View File

@ -1007,26 +1007,26 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
}
$actiontypecode='AC_FAC';
$actionmsg ="Mail envoyé par ".$from." à ".$sendto.".\n";
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->trans('To').' '.$sendto.".\n";
if ($message)
{
$actionmsg.="Texte utilisé dans le corps du message:\n";
$actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
$actionmsg.=$message;
}
$actionmsg2='Envoi facture par mail';
$actionmsg2=$langs->transnoentities('SendInvoiceByMail');
}
if ($_POST['action'] == 'relance')
{
$subject = 'Relance facture '.$fac->ref;
$actiontypecode='AC_FAC';
$actionmsg="Mail envoyé par ".$from." à ".$sendto.".\n";
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
if ($message) {
$actionmsg.="Texte utilisé dans le corps du message:\n";
$actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
$actionmsg.=$message;
}
$actionmsg2='Relance facture par mail';
$actionmsg2=$langs->transnoentities('ReSendInvoiceByMail');
}
$filepath[0] = $file;
@ -1053,22 +1053,23 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
{
$mesg='<div class="ok">'.$langs->trans('MailSuccessfulySent',$from,$sendto).'.</div>';
// Insertion action
require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php');
$actioncomm = new ActionComm($db);
$actioncomm->type_code = $actiontypecode;
$actioncomm->label = $actionmsg2;
$actioncomm->note = $actionmsg;
$actioncomm->date = time(); // L'action est faite maintenant
$actioncomm->percentage = 100;
$actioncomm->contact = new Contact($db,$sendtoid);
$actioncomm->societe = new Societe($db,$fac->socid);
$actioncomm->user = $user; // User qui a fait l'action
$actioncomm->facid = $fac->id;
$error=0;
// Initialisation donnees
$fac->sendtoid=$sendtoid;
$fac->actiontypecode=$actiontypecode;
$fac->actionmsg = $actionmsg;
$fac->actionmsg2= $actionmsg2;
$fac->facid=$fac->id;
$ret=$actioncomm->add($user); // User qui saisit l'action
if ($ret < 0)
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->run_triggers('BILL_SENTBYMAIL',$fac,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
if ($error)
{
dolibarr_print_error($db);
}

View File

@ -155,6 +155,7 @@ class Conf
// Module agenda
$this->agenda->enabled=defined('MAIN_MODULE_AGENDA')?MAIN_MODULE_AGENDA:0;
$this->agenda->dir_temp=DOL_DATA_ROOT."/agenda/temp";
// Module bookmark
$this->bookmark->enabled=defined('MAIN_MODULE_BOOKMARK')?MAIN_MODULE_BOOKMARK:0;

View File

@ -378,6 +378,14 @@ if ($modulepart)
$encoding='UTF-8';
$original_file=$conf->webcal->dir_temp.'/'.$original_file;
}
// Wrapping for webcalexport
if ($modulepart == 'agenda')
{
$accessallowed=1;
$encoding='UTF-8';
$original_file=$conf->agenda->dir_temp.'/'.$original_file;
}
}
// Basic protection (against external users only)

View File

@ -47,7 +47,7 @@ class InterfaceLogevents
{
$this->db = $DB ;
$this->name = "Eventsynchro";
$this->name = "Logevents";
$this->family = "core";
$this->description = "Les triggers de ce composant permettent de logguer les evenements Dolibarr (modification status des objets).";
$this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version

View File

@ -22,3 +22,6 @@ AllActions=Toutes les actions/tasks
ViewList=View list
ViewCal=View calendar
ViewWithPredefinedFilters=View with predefined filters
AutoActions=Automatic creation of actions
AgendaAutoActionDesc=Define here, actions for which you want Dolibarr to creat automatically an action in agenda. If nothing is checked (by default), only manual actions will be included in agenda.
AgendaSetupOtherDesc=This page allows to configure other parameters.

View File

@ -21,4 +21,7 @@ AllMyActions=Toutes mes actions/taches
AllActions=Toutes les actions/taches
ViewList=Voir liste
ViewCal=Voir calendrier
ViewWithPredefinedFilters=Vues avec filtres prédéfinis
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.
AgendaSetupOtherDesc=Cette page permet de configurer les autres paramètres.

View File

@ -307,12 +307,10 @@ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $not
/**
\file htdocs/lib/company.lib.php
\brief Ensemble de fonctions de base pour le module societe
\ingroup societe
\version $Id$
\brief Define head array for tabs of security setup pages
\return Array of head
\version $Id$
*/
function security_prepare_head()
{
global $langs, $conf, $user;

View File

@ -195,4 +195,29 @@ function show_array_last_actions_done($max=5)
}
}
/**
\brief Define head array for tabs of agenda setup pages
\return Array of head
\version $Id$
*/
function agenda_prepare_head()
{
global $langs, $conf, $user;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT."/admin/agenda.php";
$head[$h][1] = $langs->trans("AutoActions");
$head[$h][2] = 'autoactions';
$h++;
$head[$h][0] = DOL_URL_ROOT."/admin/agenda_xcal.php";
$head[$h][1] = $langs->trans("Other");
$head[$h][2] = 'xcal';
$h++;
return $head;
}
?>

View File

@ -14,15 +14,13 @@
* 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.
*
* $Id$
*/
/**
\file htdocs/lib/xcal.lib.php
\brief Function to manage calendar files (vcal/ical/...)
\version $Revision$
\version $Id$
*/
/**

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -15,15 +15,12 @@
* 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.
*
* $Id$
* $Source$
*/
/**
\file htdocs/notify.class.php
\brief Fichier de la classe de gestion des notifications
\version $Revision$
\version $Id$
*/
require_once(DOL_DOCUMENT_ROOT ."/lib/CMailFile.class.php");

View File

@ -135,31 +135,9 @@ if ($_POST["action"] == 'send' || $_POST["action"] == 'relance')
{
$msg='<div class="ok">'.$langs->trans("MailSuccessfulySent",$from,$sendto).'.</div>';
// Insertion action
$actioncomm = new ActionComm($db);
$actioncomm->type_id = $actiontypeid;
$actioncomm->label = $actionmsg2;
$actioncomm->note = $actionmsg;
$actioncomm->date = time();
$actioncomm->percentage = 100;
$actioncomm->contact = new Contact($db,$sendtoid);
$actioncomm->societe = new Societe($db,$fac->socid);
$actioncomm->user = $user; // User qui a fait l'action
$actioncomm->facid = $fac->id;
$ret=$actioncomm->add($user); // User qui saisi l'action
if ($ret < 0)
{
dolibarr_print_error($db);
}
else
{
// Renvoie sur la fiche
Header("Location: facture.php?facid=".$fac->id."&msg=".urlencode($msg));
exit;
}
}
else
{

View File

@ -15,8 +15,6 @@
* 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.
*
* $Id$
*/
/**
@ -25,7 +23,7 @@
\brief Ensemble des fonctions permettant d'acceder a la database webcalendar.
\author Rodolphe Quiedeville.
\author Laurent Destailleur.
\version $Revision$
\version $Id$
*/

View File

@ -33,9 +33,8 @@ require_once(DOL_DOCUMENT_ROOT.'/webcal/webcal.class.php');
function llxHeader() { print '<html><title>Export cal</title><body>'; }
function llxFooter() { print '</body></html>'; }
// Check config
if (empty($conf->global->PHPWEBCALENDAR_URL))
if (! $conf->webcal->enabled && empty($conf->global->PHPWEBCALENDAR_URL))
{
$user->getrights();