Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2012-03-24 15:21:09 +01:00
commit 8e745c88c5
62 changed files with 1006 additions and 395 deletions

View File

@ -59,9 +59,11 @@ class AccountancyAccount
*/
function create($user)
{
$now=dol_now();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."accountingaccount";
$sql.= " (date_creation, fk_user_author, numero,intitule)";
$sql.= " VALUES (".$this->db->idate(gmmktime()).",".$user->id.",'".$this->numero."','".$this->intitule."')";
$sql.= " VALUES (".$this->db->idate($now).",".$user->id.",'".$this->numero."','".$this->intitule."')";
$resql = $this->db->query($sql);
if ($resql)

View File

@ -87,14 +87,15 @@ if ($result)
$db->free($result);
}
$now=dol_now();
// List members up to date
// current rule: uptodate = the end date is in future whatever is type
// old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future)
$sql = "SELECT count(*) as somme , d.fk_adherent_type";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
//$sql.= " WHERE d.statut = 1 AND ((t.cotisation = 0 AND d.datefin IS NULL) OR d.datefin >= ".$db->idate(gmmktime()).')';
$sql.= " WHERE d.statut = 1 AND d.datefin >= ".$db->idate(gmmktime());
//$sql.= " WHERE d.statut = 1 AND ((t.cotisation = 0 AND d.datefin IS NULL) OR d.datefin >= ".$db->idate($now).')';
$sql.= " WHERE d.statut = 1 AND d.datefin >= ".$db->idate($now);
$sql.= " AND t.rowid = d.fk_adherent_type";
$sql.= " GROUP BY d.fk_adherent_type";
@ -321,7 +322,7 @@ foreach ($AdherentType as $key => $adhtype)
print '<td><a href="type.php?rowid='.$adhtype->id.'">'.img_object($langs->trans("ShowType"),"group").' '.$adhtype->getNomUrl(0,dol_size(16)).'</a></td>';
print '<td align="right">'.(isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0?$MemberToValidate[$key]:'').' '.$staticmember->LibStatut(-1,$adhtype->cotisation,0,3).'</td>';
print '<td align="right">'.(isset($MembersValidated[$key]) && ($MembersValidated[$key]-$MemberUpToDate[$key] > 0) ? $MembersValidated[$key]-$MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,0,3).'</td>';
print '<td align="right">'.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,gmmktime(),3).'</td>';
print '<td align="right">'.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,$now,3).'</td>';
print '<td align="right">'.(isset($MembersResiliated[$key]) && $MembersResiliated[$key]> 0 ?$MembersResiliated[$key]:'').' '.$staticmember->LibStatut(0,$adhtype->cotisation,0,3).'</td>';
print "</tr>\n";
}
@ -329,7 +330,7 @@ print '<tr class="liste_total">';
print '<td class="liste_total">'.$langs->trans("Total").'</td>';
print '<td class="liste_total" align="right">'.$SommeA.' '.$staticmember->LibStatut(-1,$adhtype->cotisation,0,3).'</td>';
print '<td class="liste_total" align="right">'.$SommeB.' '.$staticmember->LibStatut(1,$adhtype->cotisation,0,3).'</td>';
print '<td class="liste_total" align="right">'.$SommeC.' '.$staticmember->LibStatut(1,$adhtype->cotisation,gmmktime(),3).'</td>';
print '<td class="liste_total" align="right">'.$SommeC.' '.$staticmember->LibStatut(1,$adhtype->cotisation,$now,3).'</td>';
print '<td class="liste_total" align="right">'.$SommeD.' '.$staticmember->LibStatut(0,$adhtype->cotisation,0,3).'</td>';
print '</tr>';

View File

@ -312,7 +312,7 @@ foreach ($dirmodels as $reldir)
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$facture->type=0;
$commande->type=0;
$nextval=$module->getNextValue($mysoc,$commande);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{

View File

@ -344,7 +344,7 @@ foreach ($dirmodels as $reldir)
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$facture->type=0;
$propal->type=0;
$nextval=$module->getNextValue($mysoc,$propal);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{

View File

@ -101,6 +101,8 @@ class Bookmark
$this->url=trim($this->url);
$this->title=trim($this->title);
if (empty($this->position)) $this->position=0;
$now=dol_now();
$this->db->begin();
@ -109,7 +111,7 @@ class Bookmark
if ($this->fk_soc) $sql.=",fk_soc";
$sql.= ") VALUES (";
$sql.= ($this->fk_user > 0?"'".$this->fk_user."'":"0").",";
$sql.= " ".$this->db->idate(gmmktime()).",";
$sql.= " ".$this->db->idate($now).",";
$sql.= " '".$this->url."', '".$this->target."',";
$sql.= " '".$this->db->escape($this->title)."', '".$this->favicon."', '".$this->position."'";
if ($this->fk_soc) $sql.=",".$this->fk_soc;

View File

@ -314,8 +314,10 @@ class Mailing extends CommonObject
*/
function valid($user)
{
$now=dol_now();
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
$sql .= " SET statut = 1, date_valid = ".$this->db->idate(gmmktime()).", fk_user_valid=".$user->id;
$sql .= " SET statut = 1, date_valid = ".$this->db->idate($now).", fk_user_valid=".$user->id;
$sql .= " WHERE rowid = ".$this->id;
dol_syslog("Mailing::valid sql=".$sql, LOG_DEBUG);

View File

@ -1,6 +1,7 @@
<?PHP
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@uers.sourceforge.net>
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@uers.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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
@ -34,8 +35,14 @@ $langs->load("mails");
if (! $user->rights->mailing->lire || $user->societe_id > 0) accessforbidden();
$id=(GETPOST('mailid','int') ? GETPOST('mailid','int') : GETPOST('id','int'));
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
$message = '';
$object=new Mailing($db);
// Tableau des substitutions possibles
$substitutionarray=array(
'__ID__' => 'IdRecord',
@ -70,7 +77,7 @@ $substitutionarrayfortest=array(
// Action clone object
if ($_POST["action"] == 'confirm_clone' && $_POST['confirm'] == 'yes')
if ($action == 'confirm_clone' && $confirm == 'yes')
{
if (empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"]))
{
@ -78,8 +85,7 @@ if ($_POST["action"] == 'confirm_clone' && $_POST['confirm'] == 'yes')
}
else
{
$object=new Mailing($db);
$result=$object->createFromClone($_REQUEST['id'],$_REQUEST["clone_content"],$_REQUEST["clone_receivers"]);
$result=$object->createFromClone($id,$_REQUEST["clone_content"],$_REQUEST["clone_receivers"]);
if ($result > 0)
{
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
@ -88,48 +94,46 @@ if ($_POST["action"] == 'confirm_clone' && $_POST['confirm'] == 'yes')
else
{
$mesg=$object->error;
$_GET['action']='';
$_GET['id']=$_REQUEST['id'];
$action='';
}
}
}
// Action send emailing for everybody
if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes')
if ($action == 'sendallconfirmed' && $confirm == 'yes')
{
if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
{
// Pour des raisons de securite, on ne permet pas cette fonction via l'IHM,
// on affiche donc juste un message
$message='<div class="warning">'.$langs->trans("MailingNeedCommand").'</div>';
$message.='<br><textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$_GET["id"].'</textarea>';
$message.='<br><textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$id.'</textarea>';
$message.='<br><br><div class="warning">'.$langs->trans("MailingNeedCommand2").'</div>';
$_GET["action"]='';
$action='';
}
else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0)
{
$message='<div class="warning">'.$langs->trans("NotEnoughPermissions").'</div>';
$_GET["action"]='';
$action='';
}
else
{
$mil=new Mailing($db);
$result=$mil->fetch($_REQUEST['id']);
$result=$object->fetch($id);
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($mil->id,2,0,1);
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1);
if ($mil->statut == 0)
if ($object->statut == 0)
{
dol_print_error('','ErrorMailIsNotValidated');
exit;
}
$id = $mil->id;
$subject = $mil->sujet;
$message = $mil->body;
$from = $mil->email_from;
$replyto = $mil->email_replyto;
$errorsto = $mil->email_errorsto;
$id = $object->id;
$subject = $object->sujet;
$message = $object->body;
$from = $object->email_from;
$replyto = $object->email_replyto;
$errorsto = $object->email_errorsto;
// Le message est-il en html
$msgishtml=-1; // Unknown by default
if (preg_match('/[\s\t]*<html>/i',$message)) $msgishtml=1;
@ -143,7 +147,7 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes')
// ou envoyes en erreur (statut=-1)
$sql = "SELECT mc.rowid, mc.nom, mc.prenom, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
$sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id;
$sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id;
dol_syslog("fiche.php: select targets sql=".$sql, LOG_DEBUG);
$resql=$db->query($sql);
@ -154,9 +158,11 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes')
if ($num)
{
dol_syslog("comm/mailing/fiche.php: nb of targets = ".$num, LOG_DEBUG);
$now=dol_now();
// Positionne date debut envoi
$sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi=".$db->idate(gmmktime())." WHERE rowid=".$id;
$sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi=".$db->idate($now)." WHERE rowid=".$object->id;
$resql2=$db->query($sql);
if (! $resql2)
{
@ -245,7 +251,7 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes')
dol_syslog("comm/mailing/fiche.php: ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG);
$sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sql.=" SET statut=1, date_envoi=".$db->idate(gmmktime())." WHERE rowid=".$obj->rowid;
$sql.=" SET statut=1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid;
$resql2=$db->query($sql);
if (! $resql2)
{
@ -260,7 +266,7 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes')
dol_syslog("comm/mailing/fiche.php: error for #".$i.($mail->error?' - '.$mail->error:''), LOG_WARNING);
$sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sql.=" SET statut=-1, date_envoi=".$db->idate(gmmktime())." WHERE rowid=".$obj->rowid;
$sql.=" SET statut=-1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid;
$resql2=$db->query($sql);
if (! $resql2)
{
@ -283,7 +289,7 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes')
else $statut=2; // Status 'sent partially' (because not send to everybody)
}
$sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$id;
$sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id;
dol_syslog("comm/mailing/fiche.php: update global status sql=".$sql, LOG_DEBUG);
$resql2=$db->query($sql);
if (! $resql2)
@ -297,23 +303,22 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes')
dol_print_error($db);
}
$message='';
$_GET["action"] = '';
$action = '';
}
}
// Action send test emailing
if ($_POST["action"] == 'send' && empty($_POST["cancel"]))
if ($action == 'send' && empty($_POST["cancel"]))
{
$mil = new Mailing($db);
$result=$mil->fetch($_POST["mailid"]);
$result=$object->fetch($id);
$error=0;
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($mil->id,2,0,1);
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1);
$mil->sendto = $_POST["sendto"];
if (! $mil->sendto)
$object->sendto = $_POST["sendto"];
if (! $object->sendto)
{
$message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("MailTo")).'</div>';
$error++;
@ -326,8 +331,8 @@ if ($_POST["action"] == 'send' && empty($_POST["cancel"]))
if (preg_match('/[\s\t]*<html>/i',$message)) $msgishtml=1;
// Pratique les substitutions sur le sujet et message
$mil->sujet=make_substitutions($mil->sujet,$substitutionarrayfortest,$langs);
$mil->body=make_substitutions($mil->body,$substitutionarrayfortest,$langs);
$object->sujet=make_substitutions($object->sujet,$substitutionarrayfortest,$langs);
$object->body=make_substitutions($object->body,$substitutionarrayfortest,$langs);
$arr_file = array();
$arr_mime = array();
@ -335,8 +340,8 @@ if ($_POST["action"] == 'send' && empty($_POST["cancel"]))
$arr_css = array();
// Ajout CSS
if (!empty($mil->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/',$mil->bgcolor)?'':'#').$mil->bgcolor;
if (!empty($mil->bgimage)) $arr_css['bgimage'] = $mil->bgimage;
if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/',$object->bgcolor)?'':'#').$object->bgcolor;
if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage;
// Attached files
$listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0);
@ -350,86 +355,81 @@ if ($_POST["action"] == 'send' && empty($_POST["cancel"]))
}
}
$mailfile = new CMailFile($mil->sujet,$mil->sendto,$mil->email_from,$mil->body, $arr_file,$arr_mime,$arr_name,'', '', 0, $msgishtml,$mil->email_errorsto,$arr_css);
$mailfile = new CMailFile($object->sujet,$object->sendto,$object->email_from,$object->body, $arr_file,$arr_mime,$arr_name,'', '', 0, $msgishtml,$object->email_errorsto,$arr_css);
$result=$mailfile->sendfile();
if ($result)
{
$message='<div class="ok">'.$langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($mil->email_from,2),$mailfile->getValidAddress($mil->sendto,2)).'</div>';
$message='<div class="ok">'.$langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2)).'</div>';
}
else
{
$message='<div class="error">'.$langs->trans("ResultKo").'<br>'.$mailfile->error.' '.$result.'</div>';
}
$_GET["action"]='';
$_GET["id"]=$mil->id;
$action='';
}
}
// Action add emailing
if ($_POST["action"] == 'add')
if ($action == 'add')
{
$message='';
$mil = new Mailing($db);
$object->email_from = trim($_POST["from"]);
$object->email_replyto = trim($_POST["replyto"]);
$object->email_errorsto = trim($_POST["errorsto"]);
$object->titre = trim($_POST["titre"]);
$object->sujet = trim($_POST["sujet"]);
$object->body = trim($_POST["body"]);
$object->bgcolor = trim($_POST["bgcolor"]);
$object->bgimage = trim($_POST["bgimage"]);
$mil->email_from = trim($_POST["from"]);
$mil->email_replyto = trim($_POST["replyto"]);
$mil->email_errorsto = trim($_POST["errorsto"]);
$mil->titre = trim($_POST["titre"]);
$mil->sujet = trim($_POST["sujet"]);
$mil->body = trim($_POST["body"]);
$mil->bgcolor = trim($_POST["bgcolor"]);
$mil->bgimage = trim($_POST["bgimage"]);
if (! $mil->titre) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTitle"));
if (! $mil->sujet) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTopic"));
if (! $mil->body) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailBody"));
if (! $object->titre) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTitle"));
if (! $object->sujet) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTopic"));
if (! $object->body) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailBody"));
if (! $message)
{
if ($mil->create($user) >= 0)
if ($object->create($user) >= 0)
{
Header("Location: fiche.php?id=".$mil->id);
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
$message=$mil->error;
$message=$object->error;
}
$message='<div class="error">'.$message.'</div>';
$_GET["action"]="create";
$action="create";
}
// Action update description of emailing
if ($_REQUEST["action"] == 'setdesc' || $_REQUEST["action"] == 'setfrom' || $_REQUEST["action"] == 'setreplyto' || $_REQUEST["action"] == 'seterrorsto')
if ($action == 'settitre' || $action == 'setemail_from' || $actino == 'setreplyto' || $action == 'setemail_errorsto')
{
$mil = new Mailing($db);
$mil->fetch($_POST["id"]);
$object->fetch($id);
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($mil->id,2,0,1);
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1);
if ($_REQUEST["action"] == 'setdesc') $mil->titre = trim($_REQUEST["desc"]);
if ($_REQUEST["action"] == 'setfrom') $mil->email_from = trim($_REQUEST["from"]);
if ($_REQUEST["action"] == 'setreplyto') $mil->email_replyto = trim($_REQUEST["replyto"]);
if ($_REQUEST["action"] == 'seterrorsto') $mil->email_errorsto = trim($_REQUEST["errorsto"]);
if ($action == 'settitre') $object->titre = trim(GETPOST('titre','alpha'));
else if ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from','alpha'));
else if ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto','alpha'));
else if ($action == 'setemail_errorsto') $object->email_errorsto = trim(GETPOST('email_errorsto','alpha'));
if ($_REQUEST["action"] == 'setdesc' && empty($mil->titre)) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle"));
if ($_REQUEST["action"] == 'setfrom' && empty($mil->email_from)) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailFrom"));
else if ($action == 'settitre' && empty($object->titre)) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle"));
else if ($action == 'setfrom' && empty($object->email_from)) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailFrom"));
if (! $message)
{
if ($mil->update($user) >= 0)
if ($object->update($user) >= 0)
{
Header("Location: fiche.php?id=".$mil->id);
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
$message=$mil->error;
$message=$object->error;
}
$message='<div class="error">'.$message.'</div>';
$_GET["action"]="";
$_GET["id"]=$_REQUEST["id"];
$action="";
}
/*
@ -437,165 +437,132 @@ if ($_REQUEST["action"] == 'setdesc' || $_REQUEST["action"] == 'setfrom' || $_RE
*/
if (! empty($_POST['addfile']))
{
$mil = new Mailing($db);
$mil->fetch($_POST["id"]);
$object->fetch($id);
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($mil->id,2,0,1);
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1);
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
// Set tmp user directory
$mesg=dol_add_file_process($upload_dir,0,0);
$_POST["action"]=$_GET["action"]="edit";
$_GET["id"]=$_POST["id"];
$action="edit";
}
// Action update emailing
if (! empty($_POST["removedfile"]))
{
$mil = new Mailing($db);
$mil->fetch($_POST["id"]);
$object->fetch($id);
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($mil->id,2,0,1);
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1);
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$mesg=dol_remove_file_process($_POST['removedfile'],0);
$_POST["action"]=$_GET["action"]="edit";
$_GET["id"]=$_POST["id"];
$action="edit";
}
// Action update emailing
if ($_POST["action"] == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"]))
if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"]))
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$mil = new Mailing($db);
$mil->fetch($_POST["id"]);
$object->fetch($id);
$isupload=0;
if (! $isupload)
{
$mil->sujet = trim($_POST["sujet"]);
$mil->body = trim($_POST["body"]);
$mil->bgcolor = trim($_POST["bgcolor"]);
$mil->bgimage = trim($_POST["bgimage"]);
$object->sujet = trim($_POST["sujet"]);
$object->body = trim($_POST["body"]);
$object->bgcolor = trim($_POST["bgcolor"]);
$object->bgimage = trim($_POST["bgimage"]);
if (! $mil->sujet) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTopic"));
if (! $mil->body) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailBody"));
if (! $object->sujet) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTopic"));
if (! $object->body) $message.=($message?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailBody"));
if (! $message)
{
if ($mil->update($user) >= 0)
if ($object->update($user) >= 0)
{
Header("Location: fiche.php?id=".$mil->id);
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
$message=$mil->error;
$message=$object->error;
}
$message='<div class="error">'.$message.'</div>';
$_GET["action"]="edit";
$_GET["id"]=$_POST["id"];
$action="edit";
}
else
{
$_GET["action"]="edit";
$_GET["id"]=$_POST["id"];
$action="edit";
}
}
// Action confirmation validation
if ($_REQUEST["action"] == 'confirm_valid')
{
if ($_REQUEST["confirm"] == 'yes')
{
$mil = new Mailing($db);
if ($mil->fetch($_REQUEST["id"]) >= 0)
{
$mil->valid($user);
Header("Location: fiche.php?id=".$mil->id);
exit;
}
else
{
dol_print_error($db);
}
}
else
{
Header("Location: fiche.php?id=".$_REQUEST["id"]);
exit;
if ($action == 'confirm_valid' && $confirm == 'yes')
{
if ($object->fetch($id) >= 0)
{
$object->valid($user);
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
dol_print_error($db);
}
}
// Resend
if ($_REQUEST["action"] == 'confirm_reset')
{
if ($_REQUEST["confirm"] == 'yes')
{
$mil = new Mailing($db);
if ($mil->fetch($_REQUEST["id"]) >= 0)
{
$db->begin();
$result=$mil->valid($user);
if ($result > 0)
{
$result=$mil->reset_targets_status($user);
}
if ($result > 0)
{
$db->commit();
Header("Location: fiche.php?id=".$mil->id);
exit;
}
else
{
$mesg=$mil->error;
$db->rollback();
}
}
else
{
dol_print_error($db);
}
}
else
{
Header("Location: fiche.php?id=".$_REQUEST["id"]);
exit;
if ($action == 'confirm_reset' && $confirm == 'yes')
{
if ($object->fetch($id) >= 0)
{
$db->begin();
$result=$object->valid($user);
if ($result > 0)
{
$result=$object->reset_targets_status($user);
}
if ($result > 0)
{
$db->commit();
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
$mesg=$object->error;
$db->rollback();
}
}
else
{
dol_print_error($db);
}
}
// Action confirmation suppression
if ($_REQUEST["action"] == 'confirm_delete')
{
if ($_REQUEST["confirm"] == 'yes')
{
$mil = new Mailing($db);
$mil->fetch($_REQUEST["id"]);
if ($mil->delete($mil->id))
{
Header("Location: ".DOL_URL_ROOT."/comm/mailing/liste.php");
exit;
}
if ($action == 'confirm_delete' && $confirm == 'yes')
{
$object->fetch($id);
if ($object->delete($object->id))
{
Header("Location: liste.php");
exit;
}
}
if (! empty($_POST["cancel"]))
{
$action = '';
$_GET["id"] = isset($_POST["mailid"])?$_POST["mailid"]:$_POST["id"];
}
@ -609,13 +576,11 @@ llxHeader('',$langs->trans("Mailing"),$help_url);
$form = new Form($db);
$htmlother = new FormOther($db);
$mil = new Mailing($db);
if ($_GET["action"] == 'create')
if ($action == 'create')
{
// EMailing in creation mode
print '<form name="new_mailing" action="fiche.php" method="post">'."\n";
print '<form name="new_mailing" action="'.$_SERVER['PHP_SELF'].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
@ -656,44 +621,43 @@ if ($_GET["action"] == 'create')
}
else
{
if ($mil->fetch($_GET["id"]) >= 0)
if ($object->fetch($id) >= 0)
{
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($mil->id,2,0,1);
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1);
$head = emailing_prepare_head($mil);
$head = emailing_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("Mailing"), 0, 'email');
dol_htmloutput_mesg($message);
// Confirmation de la validation du mailing
if ($_GET["action"] == 'valid')
if ($action == 'valid')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$mil->id,$langs->trans("ValidMailing"),$langs->trans("ConfirmValidMailing"),"confirm_valid",'','',1);
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("ValidMailing"),$langs->trans("ConfirmValidMailing"),"confirm_valid",'','',1);
if ($ret == 'html') print '<br>';
}
// Confirm reset
if ($_GET["action"] == 'reset')
else if ($action == 'reset')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$mil->id,$langs->trans("ResetMailing"),$langs->trans("ConfirmResetMailing",$mil->ref),"confirm_reset",'','',2);
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("ResetMailing"),$langs->trans("ConfirmResetMailing",$object->ref),"confirm_reset",'','',2);
if ($ret == 'html') print '<br>';
}
// Confirm delete
if ($_GET["action"] == 'delete')
else if ($action == 'delete')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$mil->id,$langs->trans("DeleteAMailing"),$langs->trans("ConfirmDeleteMailing"),"confirm_delete",'','',1);
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("DeleteAMailing"),$langs->trans("ConfirmDeleteMailing"),"confirm_delete",'','',1);
if ($ret == 'html') print '<br>';
}
if ($_GET["action"] != 'edit')
else if ($action != 'edit')
{
/*
* Mailing en mode visu
*/
if ($_GET["action"] == 'sendall')
if ($action == 'sendall')
{
// Define message to recommand from command line
@ -705,7 +669,7 @@ else
// Pour des raisons de securite, on ne permet pas cette fonction via l'IHM,
// on affiche donc juste un message
$mesg.='<div class="warning">'.$langs->trans("MailingNeedCommand").'</div>';
$mesg.='<br><textarea cols="60" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$_GET["id"].'</textarea>';
$mesg.='<br><textarea cols="60" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>';
$mesg.='<br><br><div class="warning">'.$langs->trans("MailingNeedCommand2").'</div>';
$_GET["action"]='';
}
@ -715,12 +679,12 @@ else
if ($conf->file->mailing_limit_sendbyweb == 0)
{
$text.=$langs->trans("MailingNeedCommand");
$text.='<br><textarea cols="60" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$_GET["id"].'</textarea>';
$text.='<br><textarea cols="60" rows="'.ROWS_2.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>';
$text.='<br><br>';
}
$text.=$langs->trans('ConfirmSendingEmailing').'<br>';
$text.=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
$ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$_REQUEST['id'],$langs->trans('SendMailing'),$text,'sendallconfirmed',$formquestion,'',1,260);
$ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('SendMailing'),$text,'sendallconfirmed',$formquestion,'',1,260);
if ($ret == 'html') print '<br>';
}
}
@ -729,32 +693,32 @@ else
print '<tr><td width="25%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3">';
print $form->showrefnav($mil,'id');
print $form->showrefnav($object,'id');
print '</td></tr>';
// Description
print '<tr><td>'.$form->editfieldkey("MailTitle",'desc',$mil->titre,$mil,$user->rights->mailing->creer).'</td><td colspan="3">';
print $form->editfieldval("MailTitle",'desc',$mil->titre,$mil,$user->rights->mailing->creer);
print '<tr><td>'.$form->editfieldkey("MailTitle",'titre',$object->titre,$object,$user->rights->mailing->creer && $object->statut < 3,'string').'</td><td colspan="3">';
print $form->editfieldval("MailTitle",'titre',$object->titre,$object,$user->rights->mailing->creer && $object->statut < 3,'string');
print '</td></tr>';
// From
print '<tr><td>'.$form->editfieldkey("MailFrom",'from',$mil->email_from,$mil,$user->rights->mailing->creer && $mil->statut < 3,'email').'</td><td colspan="3">';
print $form->editfieldval("MailFrom",'from',$mil->email_from,$mil,$user->rights->mailing->creer && $mil->statut < 3,'email');
print '<tr><td>'.$form->editfieldkey("MailFrom",'email_from',$object->email_from,$object,$user->rights->mailing->creer && $object->statut < 3,'string').'</td><td colspan="3">';
print $form->editfieldval("MailFrom",'email_from',$object->email_from,$object,$user->rights->mailing->creer && $object->statut < 3,'string');
print '</td></tr>';
// Errors to
print '<tr><td>'.$form->editfieldkey("MailErrorsTo",'errorsto',$mil->email_errorsto,$mil,$user->rights->mailing->creer && $mil->statut < 3,'email').'</td><td colspan="3">';
print $form->editfieldval("MailErrorsTo",'errorsto',$mil->email_errorsto,$mil,$user->rights->mailing->creer && $mil->statut < 3,'email');
print '<tr><td>'.$form->editfieldkey("MailErrorsTo",'email_errorsto',$object->email_errorsto,$object,$user->rights->mailing->creer && $object->statut < 3,'string').'</td><td colspan="3">';
print $form->editfieldval("MailErrorsTo",'email_errorsto',$object->email_errorsto,$object,$user->rights->mailing->creer && $object->statut < 3,'string');
print '</td></tr>';
// Status
print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$mil->getLibStatut(4).'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$object->getLibStatut(4).'</td></tr>';
// Nb of distinct emails
print '<tr><td width="25%">';
print $langs->trans("TotalNbOfDistinctRecipients");
print '</td><td colspan="3">';
$nbemail = ($mil->nbemail?$mil->nbemail:img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>');
$nbemail = ($object->nbemail?$object->nbemail:img_warning('').' <font class="warning">'.$langs->trans("NoTargetYet").'</font>');
if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && is_numeric($nbemail) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
{
if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
@ -781,7 +745,7 @@ else
// Clone confirmation
if ($_GET["action"] == 'clone')
if ($action == 'clone')
{
// Create an array for form
$formquestion=array(
@ -790,7 +754,7 @@ else
array('type' => 'checkbox', 'name' => 'clone_receivers', 'label' => $langs->trans("CloneReceivers").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true)
);
// Paiement incomplet. On demande si motif = escompte ou autre
$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$mil->id,$langs->trans('CloneEMailing'),$langs->trans('ConfirmCloneEMailing',$mil->ref),'confirm_clone',$formquestion,'yes');
$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneEMailing'),$langs->trans('ConfirmCloneEMailing',$object->ref),'confirm_clone',$formquestion,'yes');
print '<br>';
}
@ -802,23 +766,22 @@ else
* Boutons d'action
*/
if (GETPOST("cancel") || GETPOST("confirm")=='no' || GETPOST("action") == ''
|| in_array(GETPOST('action'),array('valid','delete','sendall')))
if (GETPOST("cancel") || $confirm=='no' || $action == '' || in_array($action,array('valid','delete','sendall')))
{
print "\n\n<div class=\"tabsAction\">\n";
if ($mil->statut == 0 && $user->rights->mailing->creer)
if ($object->statut == 0 && $user->rights->mailing->creer)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;id='.$mil->id.'">'.$langs->trans("EditMailing").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("EditMailing").'</a>';
}
//print '<a class="butAction" href="fiche.php?action=test&amp;id='.$mil->id.'">'.$langs->trans("PreviewMailing").'</a>';
//print '<a class="butAction" href="fiche.php?action=test&amp;id='.$object->id.'">'.$langs->trans("PreviewMailing").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=test&amp;id='.$mil->id.'">'.$langs->trans("TestMailing").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=test&amp;id='.$object->id.'">'.$langs->trans("TestMailing").'</a>';
if ($mil->statut == 0)
if ($object->statut == 0)
{
if ($mil->nbemail <= 0)
if ($object->nbemail <= 0)
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NoTargetYet")).'">'.$langs->trans("ValidMailing").'</a>';
}
@ -828,11 +791,11 @@ else
}
else
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=valid&amp;id='.$mil->id.'">'.$langs->trans("ValidMailing").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=valid&amp;id='.$object->id.'">'.$langs->trans("ValidMailing").'</a>';
}
}
if (($mil->statut == 1 || $mil->statut == 2) && $mil->nbemail > 0 && $user->rights->mailing->valider)
if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->rights->mailing->valider)
{
if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0)
{
@ -840,38 +803,38 @@ else
}
else
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=sendall&amp;id='.$mil->id.'">'.$langs->trans("SendMailing").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=sendall&amp;id='.$object->id.'">'.$langs->trans("SendMailing").'</a>';
}
}
if ($user->rights->mailing->creer)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=clone&amp;object=emailing&amp;id='.$mil->id.'">'.$langs->trans("ToClone").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=clone&amp;object=emailing&amp;id='.$object->id.'">'.$langs->trans("ToClone").'</a>';
}
if (($mil->statut == 2 || $mil->statut == 3) && $user->rights->mailing->valider)
if (($object->statut == 2 || $object->statut == 3) && $user->rights->mailing->valider)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=reset&amp;id='.$mil->id.'">'.$langs->trans("ResetMailing").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=reset&amp;id='.$object->id.'">'.$langs->trans("ResetMailing").'</a>';
}
if (($mil->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer)
if (($object->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer)
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&amp;id='.$mil->id.'">'.$langs->trans("DeleteMailing").'</a>';
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&amp;id='.$object->id.'">'.$langs->trans("DeleteMailing").'</a>';
}
print '<br><br></div>';
}
// Affichage formulaire de TEST
if ($_GET["action"] == 'test')
if ($action == 'test')
{
print_titre($langs->trans("TestMailing"));
// Create l'objet formulaire mail
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
$formmail = new FormMail($db);
$formmail->fromname = $mil->email_from;
$formmail->frommail = $mil->email_from;
$formmail->fromname = $object->email_from;
$formmail->frommail = $object->email_from;
$formmail->withsubstit=1;
$formmail->withfrom=0;
$formmail->withto=$user->email?$user->email:1;
@ -889,8 +852,8 @@ else
// Tableau des parametres complementaires du post
$formmail->param["action"]="send";
$formmail->param["models"]="body";
$formmail->param["mailid"]=$mil->id;
$formmail->param["returnurl"]=DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id;
$formmail->param["mailid"]=$object->id;
$formmail->param["returnurl"]=$_SERVER['PHP_SELF']."?id=".$object->id;
$formmail->show_form();
@ -902,7 +865,7 @@ else
print '<table class="border" width="100%">';
// Subject
print '<tr><td width="25%">'.$langs->trans("MailTopic").'</td><td colspan="3">'.$mil->sujet.'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("MailTopic").'</td><td colspan="3">'.$object->sujet.'</td></tr>';
// Joined files
print '<tr><td>'.$langs->trans("MailFile").'</td><td colspan="3">';
@ -924,13 +887,13 @@ else
// Background color
/*print '<tr><td width="25%">'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
$htmlother->select_color($mil->bgcolor,'bgcolor','edit_mailing',0);
$htmlother->select_color($object->bgcolor,'bgcolor','edit_mailing',0);
print '</td></tr>';*/
// Message
print '<tr><td valign="top">'.$langs->trans("MailMessage").'</td>';
print '<td colspan="3" bgcolor="'.($mil->bgcolor?(preg_match('/^#/',$mil->bgcolor)?'':'#').$mil->bgcolor:'white').'">';
print dol_htmlentitiesbr($mil->body);
print '<td colspan="3" bgcolor="'.($object->bgcolor?(preg_match('/^#/',$object->bgcolor)?'':'#').$object->bgcolor:'white').'">';
print dol_htmlentitiesbr($object->body);
print '</td>';
print '</tr>';
@ -948,19 +911,19 @@ else
print '<table class="border" width="100%">';
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'.$mil->id.'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$mil->titre.'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td colspan="3">'.dol_print_email($mil->email_from,0,0,0,0,1).'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("MailErrorsTo").'</td><td colspan="3">'.dol_print_email($mil->email_errorsto,0,0,0,0,1).'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'.$object->id.'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$object->titre.'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("MailFrom").'</td><td colspan="3">'.dol_print_email($object->email_from,0,0,0,0,1).'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("MailErrorsTo").'</td><td colspan="3">'.dol_print_email($object->email_errorsto,0,0,0,0,1).'</td></tr>';
// Status
print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$mil->getLibStatut(4).'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("Status").'</td><td colspan="3">'.$object->getLibStatut(4).'</td></tr>';
// Nb of distinct emails
print '<tr><td width="25%">';
print $langs->trans("TotalNbOfDistinctRecipients");
print '</td><td colspan="3">';
$nbemail = ($mil->nbemail?$mil->nbemail:'<font class="error">'.$langs->trans("NoTargetYet").'</font>');
$nbemail = ($object->nbemail?$object->nbemail:'<font class="error">'.$langs->trans("NoTargetYet").'</font>');
if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && is_numeric($nbemail) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
{
$text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
@ -979,14 +942,14 @@ else
print '<form name="edit_mailing" action="fiche.php" method="post" enctype="multipart/form-data">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$mil->id.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
// Print mail content
print_fiche_titre($langs->trans("EMail"),'','');
print '<table class="border" width="100%">';
// Subject
print '<tr><td width="25%" class="fieldrequired">'.$langs->trans("MailTopic").'</td><td colspan="3"><input class="flat" type="text" size=60 name="sujet" value="'.$mil->sujet.'"></td></tr>';
print '<tr><td width="25%" class="fieldrequired">'.$langs->trans("MailTopic").'</td><td colspan="3"><input class="flat" type="text" size=60 name="sujet" value="'.$object->sujet.'"></td></tr>';
dol_init_file_process($upload_dir);
@ -1028,7 +991,7 @@ else
// Background color
print '<tr><td width="25%">'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
$htmlother->select_color($mil->bgcolor,'bgcolor','edit_mailing',0);
$htmlother->select_color($object->bgcolor,'bgcolor','edit_mailing',0);
print '</td></tr>';
// Message
@ -1049,7 +1012,7 @@ else
print '<td colspan="3">';
// Editeur wysiwyg
require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
$doleditor=new DolEditor('body',$mil->body,'',320,'dolibarr_mailings','',true,true,$conf->global->FCKEDITOR_ENABLE_MAILING,20,70);
$doleditor=new DolEditor('body',$object->body,'',320,'dolibarr_mailings','',true,true,$conf->global->FCKEDITOR_ENABLE_MAILING,20,70);
$doleditor->Create();
print '</td></tr>';
@ -1067,12 +1030,11 @@ else
}
else
{
dol_print_error($db,$mil->error);
dol_print_error($db,$object->error);
}
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -2072,7 +2072,7 @@ class Propal extends CommonObject
{
global $conf, $user;
$now=gmmktime();
$now=dol_now();
$this->nbtodo=$this->nbtodolate=0;
$clause = " WHERE";

View File

@ -74,7 +74,7 @@ if ($id > 0 || ! empty($ref))
{
if ($mesg) print $mesg;
$now=gmmktime();
$now=dol_now();
if ($object->fetch($id, $ref))
{

View File

@ -620,7 +620,8 @@ class Commande extends CommonObject
// $date_commande is deprecated
$date = ($this->date_commande ? $this->date_commande : $this->date);
$now=dol_now();
$this->db->begin();
@ -630,7 +631,7 @@ class Commande extends CommonObject
$sql.= ", remise_absolue, remise_percent";
$sql.= ", entity";
$sql.= ")";
$sql.= " VALUES ('(PROV)',".$this->socid.", ".$this->db->idate(gmmktime()).", ".$user->id;
$sql.= " VALUES ('(PROV)',".$this->socid.", ".$this->db->idate($now).", ".$user->id;
$sql.= ", ".($this->fk_project?$this->fk_project:"null");
$sql.= ", ".$this->db->idate($date);
$sql.= ", ".($this->source>=0 && $this->source != '' ?$this->source:'null');
@ -2348,7 +2349,7 @@ class Commande extends CommonObject
{
global $conf, $user;
$now=gmmktime();
$now=dol_now();
$this->nbtodo=$this->nbtodolate=0;
$clause = " WHERE";

View File

@ -91,7 +91,7 @@ class Account extends CommonObject
*
* @param DoliDB $db Database handler
*/
function Account($db)
function __construct($db)
{
global $langs;
@ -344,10 +344,9 @@ class Account extends CommonObject
/**
* Create bank account into database
*
* @param User $user Object user making action
* @return int < 0 if KO, > 0 if OK
*/
function create($user='')
function create()
{
global $langs,$conf;
@ -597,14 +596,13 @@ class Account extends CommonObject
*
* @param int $id Id of bank account to get
* @param string $ref Ref of bank account to get
* @param string $ref_ext External ref of bank account to get
* @return int <0 if KO, >0 if OK
*/
function fetch($id,$ref='',$ref_ext='')
function fetch($id,$ref='')
{
global $conf;
if (empty($id) && empty($ref) && empty($ref_ext))
if (empty($id) && empty($ref))
{
$this->error="ErrorBadParameters";
return -1;

View File

@ -1323,7 +1323,7 @@ class Contrat extends CommonObject
{
global $conf, $user;
$now=gmmktime();
$now=dol_now();
$this->nbtodo=$this->nbtodolate=0;

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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
@ -59,7 +59,7 @@ $staticcontratligne=new ContratLigne($db);
* View
*/
$now=gmmktime();
$now=dol_now();
llxHeader();

View File

@ -87,7 +87,7 @@ class box_contracts extends ModeleBoxes
if ($resql)
{
$num = $db->num_rows($resql);
$now=gmmktime();
$now=dol_now();
$i = 0;

View File

@ -93,7 +93,7 @@ class box_factures extends ModeleBoxes
if ($result)
{
$num = $db->num_rows($result);
$now=gmmktime();
$now=dol_now();
$i = 0;
$l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateEcheance')).': %s)';

View File

@ -93,7 +93,7 @@ class box_factures_fourn extends ModeleBoxes
if ($result)
{
$num = $db->num_rows($result);
$now=gmmktime();
$now=dol_now();
$i = 0;
$l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateEcheance')).': %s)';

View File

@ -91,7 +91,7 @@ class box_factures_fourn_imp extends ModeleBoxes
if ($result)
{
$num = $db->num_rows($result);
$now=gmmktime();
$now=dol_now();
$i = 0;
$l_due_date = $langs->trans('Late').' ('.$langs->trans('DateEcheance').': %s)';

View File

@ -94,7 +94,7 @@ class box_factures_imp extends ModeleBoxes
if ($result)
{
$num = $db->num_rows($result);
$now=gmmktime();
$now=dol_now();
$i = 0;
$l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateEcheance')).': %s)';

View File

@ -90,7 +90,7 @@ class box_propales extends ModeleBoxes
if ($result)
{
$num = $db->num_rows($result);
$now=gmmktime();
$now=dol_now();
$i = 0;

View File

@ -95,7 +95,7 @@ class box_services_contracts extends ModeleBoxes
if ($result)
{
$num = $db->num_rows($result);
$now=gmmktime();
$now=dol_now();
$i = 0;

View File

@ -132,7 +132,7 @@ class Canvas
{
if (empty($this->template_dir)) return 0;
if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->action.'.tpl.php')) return 1;
if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->actiontype.'.tpl.php')) return 1;
else return 0;
}
@ -148,7 +148,7 @@ class Canvas
global $db, $conf, $langs, $user, $canvas;
global $form, $formfile;
include($this->template_dir.($this->card?$this->card.'_':'').$this->action.'.tpl.php'); // Include native PHP template
include($this->template_dir.($this->card?$this->card.'_':'').$this->actiontype.'.tpl.php'); // Include native PHP template
}

View File

@ -2140,10 +2140,12 @@ abstract class CommonObject
function setExtraParameters()
{
$this->db->begin();
$extraparams = (! empty($this->extraparams) ? json_encode($this->extraparams) : null);
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= ' SET extraparams = "'.$this->db->escape(json_encode($this->extraparams)).'"';
$sql.= ' WHERE rowid = '.$this->id;
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET extraparams = ".(! empty($extraparams) ? "'".$this->db->escape($extraparams)."'" : "null");
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);

View File

@ -84,49 +84,36 @@ class Conf
*/
function Conf()
{
// Avoid warnings when filling this->xxx
$this->file = (object) array();
$this->db = (object) array();
$this->global = (object) array();
$this->mycompany = (object) array();
$this->admin = (object) array();
$this->user = (object) array();
$this->syslog = (object) array();
$this->browser = (object) array();
$this->multicompany = (object) array();
$this->expedition_bon = (object) array();
$this->livraison_bon = (object) array();
$this->fournisseur = (object) array();
$this->fournisseur->commande = (object) array();
$this->fournisseur->facture = (object) array();
$this->product = (object) array();
$this->service = (object) array();
$this->contrat = (object) array();
$this->actions = (object) array();
$this->commande = (object) array();
$this->commande->client = (object) array();
$this->commande->fournisseur = (object) array();
$this->propal = (object) array();
$this->propal->cloture = (object) array();
$this->propal->facturation = (object) array();
$this->facture = (object) array();
$this->facture->client = (object) array();
$this->facture->fournisseur = (object) array();
$this->contrat = (object) array();
$this->contrat->services = (object) array();
$this->contrat->services->inactifs = (object) array();
$this->contrat->services->expires = (object) array();
$this->adherent = (object) array();
$this->adherent->cotisation = (object) array();
$this->bank = (object) array();
$this->bank->rappro = (object) array();
$this->bank->cheque = (object) array();
$this->notification = (object) array();
$this->mailing = (object) array();
//! Charset for HTML output and for storing data in memory
$this->file->character_set_client='UTF-8'; // UTF-8, ISO-8859-1
// Avoid warnings when filling this->xxx
$this->file = (object) array();
$this->db = (object) array();
$this->global = (object) array();
$this->mycompany = (object) array();
$this->admin = (object) array();
$this->user = (object) array();
$this->syslog = (object) array();
$this->browser = (object) array();
$this->multicompany = (object) array();
// First level object
$this->expedition_bon = (object) array();
$this->livraison_bon = (object) array();
$this->fournisseur = (object) array();
$this->product = (object) array();
$this->service = (object) array();
$this->contrat = (object) array();
$this->actions = (object) array();
$this->commande = (object) array();
$this->propal = (object) array();
$this->facture = (object) array();
$this->contrat = (object) array();
$this->adherent = (object) array();
$this->bank = (object) array();
$this->notification = (object) array();
$this->mailing = (object) array();
//! Charset for HTML output and for storing data in memory
$this->file->character_set_client='UTF-8'; // UTF-8, ISO-8859-1
}
@ -225,6 +212,22 @@ class Conf
}
//var_dump($this->modules);
//var_dump($this->modules_parts);
// Second or others levels object
$this->propal->cloture = (object) array();
$this->propal->facturation = (object) array();
$this->commande->client = (object) array();
$this->commande->fournisseur = (object) array();
$this->facture->client = (object) array();
$this->facture->fournisseur = (object) array();
$this->fournisseur->commande = (object) array();
$this->fournisseur->facture = (object) array();
$this->contrat->services = (object) array();
$this->contrat->services->inactifs = (object) array();
$this->contrat->services->expires = (object) array();
$this->adherent->cotisation = (object) array();
$this->bank->rappro = (object) array();
$this->bank->cheque = (object) array();
// Clean some variables
if (empty($this->global->MAIN_MENU_STANDARD)) $this->global->MAIN_MENU_STANDARD="eldy_backoffice.php";

View File

@ -3389,6 +3389,8 @@ class Form
function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $option='', $translate=0, $maxlen=0, $disabled=0)
{
global $langs;
if ($value_as_key) $array=array_combine($array, $array);
$out='<select id="'.$htmlname.'" '.($disabled?'disabled="disabled" ':'').'class="flat" name="'.$htmlname.'" '.($option != ''?$option:'').'>';
@ -3401,9 +3403,9 @@ class Form
{
foreach($array as $key => $value)
{
$out.='<option value="'.($value_as_key?$value:$key).'"';
$out.='<option value="'.$key.'"';
// Si il faut pre-selectionner une valeur
if ($id != '' && ($id == $key || $id == $value))
if ($id != '' && $id == $key)
{
$out.=' selected="selected"';
}
@ -3430,6 +3432,81 @@ class Form
$out.="</select>";
return $out;
}
/**
* Show a multiselect form from an array.
*
* @param string $htmlname Name of select
* @param array $array Array with key+value
* @param array $selected Preselected keys
* @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value"
* @param int $value_as_key 1 to use value as key
* @param string $option Valeur de l'option en fonction du type choisi
* @param int $translate Translate and encode value
* @return string HTML multiselect string
*/
function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $option='', $translate=0)
{
global $conf, $langs;
$out = '<select id="'.$htmlname.'" class="multiselect" multiple="multiple" name="'.$htmlname.'[]"'.$option.'>'."\n";
if (is_array($array) && ! empty($array))
{
if ($value_as_key) $array=array_combine($array, $array);
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && is_array($selected) && ! empty($selected))
{
foreach ($selected as $selected_value)
{
foreach($array as $key => $value)
{
if ($selected_value == $key)
{
$value=$array[$selected_value];
$out.= '<option value="'.$key.'" selected="selected">';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n";
unset($array[$key]);
}
}
}
if (! empty($array))
{
foreach ($array as $key => $value)
{
$out.= '<option value="'.$key.'">';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n";
}
}
}
else
{
foreach ($array as $key => $value)
{
$out.= '<option value="'.$key.'"';
if (is_array($selected) && ! empty($selected) && in_array($key, $selected))
{
$out.= ' selected="selected"';
}
$out.= '>';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n";
}
}
}
$out.= '</select>'."\n";
return $out;
}
/**

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (c) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (c) 2010 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
@ -435,7 +435,7 @@ class FormFile
// Execute hooks
$parameters=array('socid'=>$GLOBALS['socid'],'id'=>$GLOBALS['id'],'modulepart'=>$modulepart);
if (is_object($hookmanager)) $out.= $hookmanager->executeHooks('formBuilddocOptions',$parameters);
if (is_object($hookmanager)) $out.= $hookmanager->executeHooks('formBuilddocOptions',$parameters,$GLOBALS['object']);
}
// Get list of files

View File

@ -275,7 +275,7 @@ function dol_shutdown()
* Return value of a param into GET or POST supervariable
*
* @param string $paramname Name of parameter to found
* @param string $check Type of check (''=no check, 'int'=check it's numeric, 'alpha'=check it's alpha only)
* @param string $check Type of check (''=no check, 'int'=check it's numeric, 'alpha'=check it's alpha only, 'array'=check it's array)
* @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get)
* @return string Value found or '' if check fails
*/
@ -289,17 +289,25 @@ function GETPOST($paramname,$check='',$method=0)
if (! empty($check))
{
$out=trim($out);
// Check if numeric
if ($check == 'int' && ! preg_match('/^[-\.,0-9]+$/i',$out)) $out='';
if ($check == 'int' && ! preg_match('/^[-\.,0-9]+$/i',$out))
{
$out=trim($out);
$out='';
}
// Check if alpha
elseif ($check == 'alpha')
{
$out=trim($out);
// '"' is dangerous because param in url can close the href= or src= and add javascript functions.
// '../' is dangerous because it allows dir transversals
if (preg_match('/"/',$out)) $out='';
else if (preg_match('/\.\.\//',$out)) $out='';
}
elseif ($check == 'array')
{
if (! is_array($out) || empty($out)) $out=array();
}
}
return $out;
@ -1102,6 +1110,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
function dol_now($mode='gmt')
{
// Note that gmmktime and mktime return same value (GMT) whithout parameters
//if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() function instead
if ($mode == 'gmt') $ret=time(); // Time for now at greenwich.
else if ($mode == 'tzserver') // Time for now with PHP server timezone added
{

View File

@ -45,7 +45,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator
* @param string $maxfilenamelength Max length of value to show
* @return array List of templates
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;

View File

@ -48,7 +48,7 @@ abstract class ModelePDFCommandes extends CommonDocGenerator
* @param string $maxfilenamelength Max length of value to show
* @return array List of templates
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;
@ -73,18 +73,20 @@ abstract class ModeleNumRefCommandes
{
var $error='';
/** Return if a module can be used or not
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
* @return boolean true if module can be used
*/
function isEnabled()
{
return true;
}
/** Renvoie la description par defaut du modele de numerotation
/**
* Renvoie la description par defaut du modele de numerotation
*
* @return string Texte descripif
* @return string Texte descripif
*/
function info()
{
@ -93,9 +95,10 @@ abstract class ModeleNumRefCommandes
return $langs->trans("NoDescription");
}
/** Renvoie un exemple de numerotation
/**
* Renvoie un exemple de numerotation
*
* @return string Example
* @return string Example
*/
function getExample()
{
@ -104,28 +107,33 @@ abstract class ModeleNumRefCommandes
return $langs->trans("NoExample");
}
/** Test si les numeros deja en vigueur dans la base ne provoquent pas de conflits qui empecheraient cette numerotation de fonctionner.
/**
* Test si les numeros deja en vigueur dans la base ne provoquent pas de conflits qui empecheraient cette numerotation de fonctionner.
*
* @return boolean false si conflit, true si ok
* @return boolean false si conflit, true si ok
*/
function canBeActivated()
{
return true;
}
/** Renvoie prochaine valeur attribuee
/**
* Renvoie prochaine valeur attribuee
*
* @return string Valeur
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Valeur
*/
function getNextValue()
function getNextValue($objsoc,$object)
{
global $langs;
return $langs->trans("NotAvailable");
}
/** Renvoie version du module numerotation
/**
* Renvoie version du module numerotation
*
* @return string Valeur
* @return string Valeur
*/
function getVersion()
{

View File

@ -71,7 +71,7 @@ class html_cerfafr extends ModeleDon
{
global $user,$conf,$langs,$mysoc;
$now=gmmktime();
$now=dol_now();
if (! is_object($outputlangs)) $outputlangs=$langs;

View File

@ -43,7 +43,7 @@ abstract class ModeleDon extends CommonDocGenerator
* @param string $maxfilenamelength Max length of value to show
* @return array List of templates
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;

View File

@ -51,7 +51,7 @@ class ModeleShippingMethod
* @param string $maxfilenamelength Max length of value to show
* @return array List of templates
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;

View File

@ -45,7 +45,7 @@ abstract class ModelePdfExpedition extends CommonDocGenerator
* @param string $maxfilenamelength Max length of value to show
* @return array List of templates
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;

View File

@ -46,7 +46,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator
* @param string $maxfilenamelength Max length of value to show
* @return array List of templates
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;

View File

@ -44,7 +44,7 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator
* @param string $maxfilenamelength Max length of value to show
* @return array List of templates
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;

View File

@ -44,7 +44,7 @@ abstract class ModelePDFDeliveryOrder extends CommonDocGenerator
* @param string $maxfilenamelength Max length of value to show
* @return array List of templates
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;

View File

@ -296,7 +296,7 @@ class modSociete extends DolibarrModules
);
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
$this->import_regex_array[$r]=array('s.status'=>'^[0|1]','s.client'=>'^[0|1|2|3]','s.fournisseur'=>'^[0|1]','s.fk_typent'=>'id@'.MAIN_DB_PREFIX.'c_typent','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
$this->import_examplevalues_array[$r]=array('s.nom'=>"MyBigCompany",'s.status'=>"0 (closed) or 1 (active)",'s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(mktime(),'%Y-%m-%d'),'s.code_client'=>"CU01-0001 or auto",'s.code_fournisseur'=>"SU01-0001 or auto",'s.address'=>"61 jump street",'s.cp'=>"123456",'s.ville'=>"Big town",'s.fk_pays'=>'US, FR, DE...','s.tel'=>"0101010101",'s.fax'=>"0101010102",'s.url'=>"http://mycompany.com",'s.email'=>"test@mycompany.com",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note'=>"This is an example of note for record",'s.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'PL_MEDIUM','s.fk_stcomm'=>'0','s.default_lang'=>'en_US','s.barcode'=>'123456789');
$this->import_examplevalues_array[$r]=array('s.nom'=>"MyBigCompany",'s.status'=>"0 (closed) or 1 (active)",'s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'s.code_client'=>"CU01-0001 or auto",'s.code_fournisseur'=>"SU01-0001 or auto",'s.address'=>"61 jump street",'s.cp'=>"123456",'s.ville'=>"Big town",'s.fk_pays'=>'US, FR, DE...','s.tel'=>"0101010101",'s.fax'=>"0101010102",'s.url'=>"http://mycompany.com",'s.email'=>"test@mycompany.com",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note'=>"This is an example of note for record",'s.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'PL_MEDIUM','s.fk_stcomm'=>'0','s.default_lang'=>'en_US','s.barcode'=>'123456789');
// Import list of contact and attributes
$r++;

View File

@ -40,7 +40,7 @@ abstract class ModelePDFProjects extends CommonDocGenerator
* @param string $maxfilenamelength Max length of value to show
* @return array List of templates
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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

View File

@ -45,7 +45,7 @@ abstract class ModelePDFPropales extends CommonDocGenerator
* @param string $maxfilenamelength Max length of value to show
* @return array List of templates
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;
@ -115,9 +115,11 @@ abstract class ModeleNumRefPropales
/**
* Renvoi prochaine valeur attribuee
*
* @return string Valeur
* @param Societe $objsoc Object third party
* @param Propal $propal Object commercial proposal
* @return string Valeur
*/
function getNextValue()
function getNextValue($objsoc,$propal)
{
global $langs;
return $langs->trans("NotAvailable");

View File

@ -135,10 +135,9 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
return -1;
}
//$date=time();
$date=gmmktime();
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1);
$date = dol_now();
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1);
dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
return $prefix.$yymm."-".$num;

View File

@ -42,7 +42,7 @@ abstract class ModeleThirdPartyDoc extends CommonDocGenerator
* @param string $maxfilenamelength Max length of value to show
* @return array List of templates
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;
@ -144,7 +144,7 @@ abstract class ModeleThirdPartyCode
* @param string $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
$liste=array();
$sql ="";

View File

@ -41,7 +41,7 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator
* @param string $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;

View File

@ -47,7 +47,7 @@ abstract class ModelePDFSuppliersOrders extends CommonDocGenerator
* @param string $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
function liste_modeles($db,$maxfilenamelength=0)
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;

View File

@ -111,7 +111,7 @@ class InterfaceLogevents
if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form)
$this->date=gmmktime();
$this->date=dol_now();
$this->duree=0;
// Actions

View File

@ -155,6 +155,8 @@ class Expedition extends CommonObject
function create($user)
{
global $conf, $langs;
$now=dol_now();
require_once DOL_DOCUMENT_ROOT ."/product/stock/class/mouvementstock.class.php";
$error = 0;
@ -192,7 +194,7 @@ class Expedition extends CommonObject
$sql.= ", ".$conf->entity;
$sql.= ", ".($this->ref_customer?"'".$this->ref_customer."'":"null");
$sql.= ", ".($this->ref_int?"'".$this->ref_int."'":"null");
$sql.= ", '".$this->db->idate(gmmktime())."'";
$sql.= ", '".$this->db->idate($now)."'";
$sql.= ", ".$user->id;
$sql.= ", ".($this->date_expedition>0?"'".$this->db->idate($this->date_expedition)."'":"null");
$sql.= ", ".($this->date_delivery>0?"'".$this->db->idate($this->date_delivery)."'":"null");

View File

@ -1665,7 +1665,7 @@ class CommandeFournisseur extends Commande
{
global $conf, $user;
$now=gmmktime();
$now=dol_now();
$this->nbtodo=$this->nbtodolate=0;
$clause = " WHERE";

View File

@ -1166,7 +1166,7 @@ class FactureFournisseur extends Facture
{
global $conf, $user;
$now=gmmktime();
$now=dol_now();
$this->nbtodo=$this->nbtodolate=0;
$sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin';

View File

@ -926,7 +926,7 @@ if ($id > 0 || ! empty($ref))
*/
if ($action == 'valid')
{
$object->date_commande=gmmktime();
$object->date_commande=dol_now();
// We check if number is temporary number
if (preg_match('/^[\(]?PROV/i',$object->ref)) $newref = $object->getNextNumRef($soc);

View File

@ -44,7 +44,7 @@ $result = restrictedArea($user, 'commande_fournisseur', $id,'');
$form = new Form($db);
$now=gmmktime();
$now=dol_now();
$ref= $_GET['ref'];

View File

@ -49,7 +49,7 @@ if ($user->societe_id > 0)
* View
*/
$now=gmmktime();
$now=dol_now();
llxHeader('',$langs->trans("BillsSuppliersUnpaid"));

View File

@ -94,7 +94,7 @@ if ($mode == 'search')
* View
*/
$now=gmmktime();
$now=dol_now();
$form=new Form($db);
$htmlother=new FormOther($db);

View File

@ -0,0 +1,20 @@
Copyright (c) 2009 Michael Aufreiter, http://www.quasipartikel.at
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,31 @@
/* Multiselect
----------------------------------*/
.ui-multiselect { border: solid 1px; font-size: 0.8em; }
.ui-multiselect ul { -moz-user-select: none; }
.ui-multiselect li { margin: 0; padding: 0; cursor: default; line-height: 20px; height: 20px; font-size: 11px; list-style: none; padding-right: 18px; overflow: hidden; }
.ui-multiselect li a { color: #999; text-decoration: none; padding: 0; display: block; float: left; cursor: pointer;}
.ui-multiselect li.ui-draggable-dragging { padding-left: 10px; }
.ui-multiselect div.selected { position: relative; padding: 0; margin: 0; border: 0; float:left; }
.ui-multiselect ul.selected { position: relative; padding: 0; overflow: auto; overflow-x: hidden; background: #fff; margin: 0; list-style: none; border: 0; position: relative; width: 100%; }
.ui-multiselect div.available { position: relative; padding: 0; margin: 0; border: 0; float:left; }
.ui-multiselect ul.available { position: relative; padding: 0; overflow: auto; overflow-x: hidden; background: #fff; margin: 0; list-style: none; border: 0; width: 100%; }
.ui-multiselect ul.available li { padding-left: 10px; }
.ui-multiselect div.right-column { border-left: 1px solid; }
.ui-multiselect .ui-state-default { border: none; margin-bottom: 1px; position: relative; padding-left: 20px;}
.ui-multiselect .ui-state-hover { border: none; }
.ui-multiselect .ui-widget-header {border: none; font-size: 11px; margin-bottom: 1px;}
.ui-multiselect .add-all { float: right; padding: 7px;}
.ui-multiselect .remove-all { float: right; padding: 7px;}
.ui-multiselect .search { float: left; padding: 4px;}
.ui-multiselect .count { float: left; padding: 7px;}
.ui-multiselect li span.ui-icon-arrowthick-2-n-s { position: absolute; left: 2px; }
.ui-multiselect li a.action { position: absolute; right: 2px; top: 2px; }
.ui-multiselect input.search { height: 14px; padding: 1px; opacity: 0.5; margin: 4px; width: 100px; }

View File

@ -0,0 +1,480 @@
/*
* jQuery UI Multiselect
*
* Authors:
* Michael Aufreiter (quasipartikel.at)
* Yanick Rochon (yanick.rochon[at]gmail[dot]com)
*
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* http://www.quasipartikel.at/multiselect/
*
*
* Depends:
* ui.core.js
* ui.sortable.js
*
* Optional:
* localization (http://plugins.jquery.com/project/localisation)
* scrollTo (http://plugins.jquery.com/project/ScrollTo)
*
* Todo:
* Make batch actions faster
* Implement dynamic insertion through remote calls
*/
(function($) {
$.widget("ui.multiselect", {
options: {
sortable: true,
dragToAdd: true,
searchable: true,
doubleClickable: true,
animated: 'fast',
show: 'slideDown',
hide: 'slideUp',
dividerLocation: 0.6,
selectedContainerOnLeft: true,
width: null,
height: null,
nodeComparator: function(node1,node2) {
var text1 = node1.text(),
text2 = node2.text();
return text1 == text2 ? 0 : (text1 < text2 ? -1 : 1);
},
includeRemoveAll: true,
includeAddAll: true,
pressEnterKeyToAddAll: false
},
_create: function() {
this.element.hide();
this.id = this.element.attr("id");
this.container = $('<div class="ui-multiselect ui-helper-clearfix ui-widget"></div>').insertAfter(this.element);
this.count = 0; // number of currently selected options
this.selectedContainer = $('<div class="selected"></div>');
if (this.options.selectedContainerOnLeft) {
this.selectedContainer.appendTo(this.container);
this.availableContainer = $('<div class="available"></div>').appendTo(this.container);
this.availableContainer.addClass('right-column');
}
else
{
this.availableContainer = $('<div class="available"></div>').appendTo(this.container);
this.selectedContainer.appendTo(this.container);
this.selectedContainer.addClass('right-column');
}
this.selectedActions = $('<div class="actions ui-widget-header ui-helper-clearfix"><span class="count">0 '+$.ui.multiselect.locale.itemsCount+'</span>'+(this.options.includeRemoveAll?'<a href="#" class="remove-all">'+$.ui.multiselect.locale.removeAll+'</a>':'<span class="remove-all">&nbsp;</span>')+'</div>').appendTo(this.selectedContainer);
this.availableActions = $('<div class="actions ui-widget-header ui-helper-clearfix"><input type="text" class="search empty ui-widget-content ui-corner-all"/>'+(this.options.includeAddAll?'<a href="#" class="add-all">'+$.ui.multiselect.locale.addAll+'</a>':'<span class="add-all">&nbsp;</span>')+'</div>').appendTo(this.availableContainer);
this.selectedList = $('<ul class="selected connected-list"><li class="ui-helper-hidden-accessible"></li></ul>').bind('selectstart', function(){return false;}).appendTo(this.selectedContainer);
this.availableList = $('<ul class="available connected-list"><li class="ui-helper-hidden-accessible"></li></ul>').bind('selectstart', function(){return false;}).appendTo(this.availableContainer);
var that = this;
var width = this.options.width;
if (!width) {
width = this.element.width();
}
var height = this.options.height;
if (!height) {
height = this.element.height();
}
// set dimensions
this.container.width(width-2);
if (this.options.selectedContainerOnLeft) {
this.selectedContainer.width(Math.floor(width*this.options.dividerLocation)-1);
this.availableContainer.width(Math.floor(width*(1-this.options.dividerLocation))-2);
}
else
{
this.selectedContainer.width(Math.floor(width*this.options.dividerLocation)-2);
this.availableContainer.width(Math.floor(width*(1-this.options.dividerLocation))-1);
}
// fix list height to match <option> depending on their individual header's heights
this.selectedList.height(Math.max(height-this.selectedActions.height(),1));
this.availableList.height(Math.max(height-this.availableActions.height(),1));
if ( !this.options.animated ) {
this.options.show = 'show';
this.options.hide = 'hide';
}
// init lists
this._populateLists(this.element.find('option'));
// make selection sortable
if (this.options.sortable) {
this.selectedList.sortable({
placeholder: 'ui-state-highlight',
axis: 'y',
update: function(event, ui) {
// apply the new sort order to the original selectbox
that.selectedList.find('li').each(function() {
if ($(this).data('optionLink'))
$(this).data('optionLink').remove().appendTo(that.element);
});
},
beforeStop: function (event, ui) {
// This lets us recognize which item was just added to
// the list in receive, per the workaround for not being
// able to reference the new element.
ui.item.addClass('dropped');
},
receive: function(event, ui) {
ui.item.data('optionLink').attr('selected', true);
// increment count
that.count += 1;
that._updateCount();
// workaround, because there's no way to reference
// the new element, see http://dev.jqueryui.com/ticket/4303
that.selectedList.children('.dropped').each(function() {
$(this).removeClass('dropped');
$(this).data('optionLink', ui.item.data('optionLink'));
$(this).data('idx', ui.item.data('idx'));
that._applyItemState($(this), true);
});
// workaround according to http://dev.jqueryui.com/ticket/4088
setTimeout(function() { ui.item.remove(); }, 1);
},
stop: function (event, ui) { that.element.change(); }
});
}
// set up livesearch
if (this.options.searchable) {
this._registerSearchEvents(this.availableContainer.find('input.search'));
} else {
$('.search').hide();
}
// batch actions
this.container.find(".remove-all").click(function() {
that._populateLists(that.element.find('option').removeAttr('selected'));
that.element.trigger('change');
return false;
});
this.container.find(".add-all").click(function() {
var options = that.element.find('option').not(":selected");
if (that.availableList.children('li:hidden').length > 1) {
that.availableList.children('li').each(function(i) {
if ($(this).is(":visible")) $(options[i-1]).attr('selected', 'selected');
});
} else {
options.attr('selected', 'selected');
}
that._populateLists(that.element.find('option'));
that.element.trigger('change');
if (that.options.pressEnterKeyToAddAll) {
//clear input after add all
$('input.search').val("");
}
return false;
});
},
destroy: function() {
this.element.show();
this.container.remove();
$.Widget.prototype.destroy.apply(this, arguments);
},
addOption: function(option) {
// Append the option
option = $(option);
var select = this.element;
select.append(option);
var item = this._getOptionNode(option).appendTo(option.attr('selected') ? this.selectedList : this.availableList).show();
if (option.attr('selected')) {
this.count += 1;
}
this._applyItemState(item, option.attr('selected'));
item.data('idx', this.count);
// update count
this._updateCount();
this._filter.apply(this.availableContainer.find('input.search'), [this.availableList]);
},
// Redisplay the lists of selected/available options.
// Call this after you've selected/unselected some options programmatically.
// GRIPE This is O(n) where n is the length of the list - seems like
// there must be a smarter way of doing this, but I have not been able
// to come up with one. I see no way to detect programmatic setting of
// the option's selected property, and without that, it seems like we
// can't have a general-case listener that does its thing every time an
// option is selected.
refresh: function() {
// Redisplay our lists.
this._populateLists(this.element.find('option'));
},
_populateLists: function(options) {
this.selectedList.children('.ui-element').remove();
this.availableList.children('.ui-element').remove();
this.count = 0;
var that = this;
var groups = $(this.element).find("optgroup").map(function(i) {
return that._getOptionGroup($(this));
});
groups.appendTo(this.selectedList.add(this.availableList));
var items = $(options.map(function(i) {
var item = that._getOptionNode(this).appendTo(that._getOptionList(this)).show();
if (this.selected) that.count += 1;
that._applyItemState(item, this.selected);
item.data('idx', i);
return item[0];
}));
// update count
this._updateCount();
that._filter.apply(this.availableContainer.find('input.search'), [that.availableList]);
},
_getOptionList: function(option) {
var selected = option.selected;
option = $(option);
var $list = selected ? this.selectedList : this.availableList;
var $group = option.closest("optgroup");
if ($group.length === 0) {
return $list;
} else {
var $groupList = $list.find("ul[title='" + $group.attr("label") + "']");
if ($groupList.length === 0) {
$groupList = $("<ul class='ui-state-default ui-element available' title='" + $group.attr("label") + "'>" + $group.attr("label") + "</ul>").appendTo($list);
}
$groupList.show();
return $groupList;
}
},
_getOptionGroup : function(optgroup) {
var groupNode = $("<ul class='ui-state-default ui-element available' title='" + optgroup.attr("label") + "'>" + optgroup.attr("label") + "</ul>").hide();
return groupNode[0];
},
_updateCount: function() {
this.selectedContainer.find('span.count').text(this.count+" "+$.ui.multiselect.locale.itemsCount);
},
_getOptionNode: function(option) {
option = $(option);
var node = $('<li class="ui-state-default ui-element" title="'+option.text()+'"><span class="ui-icon"/>'+option.text()+'<a href="#" class="action"><span class="ui-corner-all ui-icon"/></a></li>').hide();
node.data('optionLink', option);
return node;
},
// clones an item with associated data
// didn't find a smarter away around this
_cloneWithData: function(clonee) {
var clone = clonee.clone(false,false);
clone.data('optionLink', clonee.data('optionLink'));
clone.data('idx', clonee.data('idx'));
return clone;
},
_setSelected: function(item, selected) {
var temp = item.data('optionLink').attr('selected', selected);
var parent = temp.parent();
temp.detach().appendTo(parent);
this.element.trigger('change');
if (selected) {
var selectedItem = this._cloneWithData(item);
item[this.options.hide](this.options.animated, function() {
if (item.siblings().length === 0) {
item.closest("ul[title]").hide();
}
$(this).remove();
});
// get group to add it to...
var $list = this._getOptionList(selectedItem.data("optionLink")[0]);
selectedItem.appendTo($list).hide()[this.options.show](this.options.animated);
this._applyItemState(selectedItem, true);
return selectedItem;
} else {
// look for successor based on initial option index
var items = this.availableList.find('li'), comparator = this.options.nodeComparator;
var succ = null, i = item.data('idx'), direction = comparator(item, $(items[i]));
// TODO: test needed for dynamic list populating
if ( direction ) {
while (i>=0 && i<items.length) {
direction > 0 ? i++ : i--;
if ( direction != comparator(item, $(items[i])) ) {
// going up, go back one item down, otherwise leave as is
succ = items[direction > 0 ? i : i+1];
var group1 = item.closest("ul[title]"),
group2 = $(succ).closest("ul[title]");
if (group1.length !== 0 && group2.length !== 0) {
if (group1.attr("title") !== group2.attr("title")) {
succ = null;
}
}
break;
}
}
} else {
succ = items[i];
}
var availableItem = this._cloneWithData(item);
var $list = this._getOptionList(availableItem.data("optionLink")[0]);
succ ? availableItem.insertBefore($(succ)) : availableItem.appendTo($list);
item[this.options.hide](this.options.animated, function() {
if (item.siblings().length === 0) {
item.closest("ul[title]").hide();
}
$(this).remove();
});
availableItem.hide()[this.options.show](this.options.animated);
this._applyItemState(availableItem, false);
return availableItem;
}
},
_applyItemState: function(item, selected) {
if (selected) {
if (this.options.sortable)
item.children('span').addClass('ui-icon-arrowthick-2-n-s').removeClass('ui-helper-hidden').addClass('ui-icon');
else
item.children('span').removeClass('ui-icon-arrowthick-2-n-s').addClass('ui-helper-hidden').removeClass('ui-icon');
item.find('a.action span').addClass('ui-icon-minus').removeClass('ui-icon-plus');
this._registerRemoveEvents(item.find('a.action'));
} else {
item.children('span').removeClass('ui-icon-arrowthick-2-n-s').addClass('ui-helper-hidden').removeClass('ui-icon');
item.find('a.action span').addClass('ui-icon-plus').removeClass('ui-icon-minus');
this._registerAddEvents(item.find('a.action'));
}
this._registerDoubleClickEvents(item);
this._registerHoverEvents(item);
},
// taken from John Resig's liveUpdate script
_filter: function(list) {
var input = $(this);
var rows = list.find('li'),
cache = rows.map(function(){
return $(this).text().toLowerCase();
});
var term = $.trim(input.val().toLowerCase()), scores = [];
if (!term) {
rows.show();
} else {
rows.hide();
cache.each(function(i) {
if (this.indexOf(term)>-1) { scores.push(i); }
});
$.each(scores, function() {
$(rows[this]).show();
});
}
},
_registerDoubleClickEvents: function(elements) {
if (!this.options.doubleClickable) return;
elements.dblclick(function() {
elements.find('a.action').click();
});
},
_registerHoverEvents: function(elements) {
elements.removeClass('ui-state-hover');
elements.mouseover(function() {
$(this).addClass('ui-state-hover');
});
elements.mouseout(function() {
$(this).removeClass('ui-state-hover');
});
},
_registerAddEvents: function(elements) {
var that = this;
elements.click(function() {
var item = that._setSelected($(this).parent(), true);
that.count += 1;
that._updateCount();
// Prevent extra clicks from triggering bogus add events, if a user
// tries clicking during the removal process.
$(this).unbind('click');
return false;
});
// make draggable
if (this.options.sortable && this.options.dragToAdd) {
elements.each(function() {
$(this).parent().draggable({
connectToSortable: that.selectedList,
helper: function() {
var selectedItem = that._cloneWithData($(this)).width($(this).width() - 50);
selectedItem.width($(this).width());
return selectedItem;
},
appendTo: that.container,
containment: that.container,
revert: 'invalid'
});
});
}
},
_registerRemoveEvents: function(elements) {
var that = this;
elements.click(function() {
that._setSelected($(this).parent(), false);
that.count -= 1;
that._updateCount();
// Prevent extra clicks from triggering bogus remove events, if a
// user tries clicking during the removal process.
$(this).unbind('click');
return false;
});
},
_registerSearchEvents: function(input) {
var that = this;
input.focus(function() {
$(this).addClass('ui-state-active');
})
.blur(function() {
$(this).removeClass('ui-state-active');
})
.keypress(function(e) {
if (e.keyCode == 13) {
if (that.options.pressEnterKeyToAddAll) {
//on Enter, if a filter is present add all, then clear the input
var str = $('input.search').val();
if (str !== undefined && str !== null && str !== "") {
$('a.add-all').click();
$('input.search').val("");
}
}
return false;
}
})
.keyup(function() {
that._filter.apply(this, [that.availableList]);
});
}
});
$.extend($.ui.multiselect, {
locale: {
addAll:'Add all',
removeAll:'Remove all',
itemsCount:'items selected'
}
});
})(jQuery);

View File

@ -859,6 +859,10 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
//print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/ColVis/css/ColVisAlt.css" />'."\n";
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/TableTools/css/TableTools.css" />'."\n";
}
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)) // jQuery multiselect
{
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/multiselect/css/ui.multiselect.css" />'."\n";
}
}
print '<!-- Includes for Dolibarr, modules or specific pages-->'."\n";
@ -977,6 +981,11 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/ColVis/js/ColVis.min'.$ext.'"></script>'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/TableTools/js/TableTools.min'.$ext.'"></script>'."\n";
}
// jQuery Multiselect
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT))
{
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/multiselect/js/ui.multiselect.js"></script>'."\n";
}
// CKEditor
if (! empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor'))
{

View File

@ -885,7 +885,7 @@ class Product extends CommonObject
* @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT
* @return int <0 if KO, >0 if OK
*/
function update_price($id, $newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0, $newnpr=0)
function updatePrice($id, $newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0, $newnpr=0)
{
global $conf,$langs;

View File

@ -84,7 +84,7 @@ if ($action == 'update_price' && ! $_POST["cancel"] && ($user->rights->produit->
$newvat=str_replace('*','',$_POST["tva_tx"]);
}
if ($object->update_price($object->id, $newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr) > 0)
if ($object->updatePrice($object->id, $newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr) > 0)
{
$action = '';
$mesg = '<div class="ok">'.$langs->trans("RecordSaved").'</div>';
@ -446,7 +446,7 @@ if ($result)
// Il doit au moins y avoir la ligne de prix initial.
// On l'ajoute donc pour remettre a niveau (pb vieilles versions)
$object->update_price($object->id, $object->price, 'HT', $user, $newprice_min);
$object->updatePrice($object->id, $object->price, 'HT', $user, $newprice_min);
$result = $db->query($sql);
$num = $db->num_rows($result);

View File

@ -80,17 +80,9 @@ abstract class ActionsCardCommon
{
$ret = $this->getInstanceDao();
if (is_object($this->object) && method_exists($this->object,'fetch'))
{
if (! empty($id) || ! empty($ref)) $this->object->fetch($id,$ref);
}
else
{
// TODO Keep only this part of code. Previous in this method is useless
$object = new Societe($this->db);
if (! empty($id) || ! empty($ref)) $object->fetch($id,$ref);
$this->object = $object;
}
$object = new Societe($this->db);
if (! empty($id) || ! empty($ref)) $object->fetch($id,$ref);
$this->object = $object;
}
/**
@ -398,14 +390,14 @@ abstract class ActionsCardCommon
if ($conf->use_javascript_ajax)
{
$this->tpl['ajax_selecttype'] = "\n".'<script type="text/javascript" language="javascript">
jQuery(document).ready(function () {
jQuery("#radiocompany").click(function() {
$(document).ready(function () {
$("#radiocompany").click(function() {
document.formsoc.action.value="create";
document.formsoc.canvas.value="company";
document.formsoc.private.value=0;
document.formsoc.submit();
});
jQuery("#radioprivate").click(function() {
$("#radioprivate").click(function() {
document.formsoc.action.value="create";
document.formsoc.canvas.value="individual";
document.formsoc.private.value=1;
@ -421,8 +413,8 @@ abstract class ActionsCardCommon
if ($conf->use_javascript_ajax)
{
$this->tpl['ajax_selectcountry'] = "\n".'<script type="text/javascript" language="javascript">
jQuery(document).ready(function () {
jQuery("#selectcountry_id").change(function() {
$(document).ready(function () {
$("#selectcountry_id").change(function() {
document.formsoc.action.value="'.$action.'";
document.formsoc.canvas.value="'.$canvas.'";
document.formsoc.submit();

View File

@ -49,11 +49,11 @@ class CompanyBankAccount extends Account
/**
* Constructor
*
* @param DoliDB $DB Database handler
* @param DoliDB $db Database handler
*/
function CompanyBankAccount($DB)
function __construct($db)
{
$this->db = $DB;
$this->db = $db;
$this->socid = 0;
$this->clos = 0;

View File

@ -636,7 +636,7 @@ class Societe extends CommonObject
$sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode';
$sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj';
$sql .= ', s.localtax1_assuj, s.localtax2_assuj, s.fk_prospectlevel, s.default_lang, s.logo';
$sql .= ', s.import_key';
$sql .= ', s.import_key, s.canvas';
$sql .= ', fj.libelle as forme_juridique';
$sql .= ', e.libelle as effectif';
$sql .= ', p.code as country_code, p.libelle as country';
@ -676,6 +676,7 @@ class Societe extends CommonObject
$this->id = $obj->rowid;
$this->entity = $obj->entity;
$this->canvas = $obj->canvas;
$this->ref = $obj->rowid;
$this->name = $obj->name;

View File

@ -108,6 +108,11 @@ class User extends CommonObject
$this->all_permissions_are_loaded = 0;
$this->admin=0;
$this->rights = (object) array();
$this->rights->user = (object) array();
$this->rights->user->user = (object) array();
$this->rights->user->self = (object) array();
}
/**
@ -522,6 +527,8 @@ class User extends CommonObject
if ($perms)
{
if (! is_object($this->rights->$module)) $this->rights->$module = (object) array();
if (! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = (object) array();
if ($subperms)
{
if (! isset($this->rights->$module) ||

View File

@ -119,6 +119,7 @@ if ($resql)
while ($i < $num)
{
$res=1;
$now=dol_now();
$obj = $db->fetch_object($resql);
@ -192,7 +193,7 @@ if ($resql)
dol_syslog("ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG);
$sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sql.=" SET statut=1, date_envoi=".$db->idate(gmmktime())." WHERE rowid=".$obj->rowid;
$sql.=" SET statut=1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid;
$resql2=$db->query($sql);
if (! $resql2)
{
@ -207,7 +208,7 @@ if ($resql)
dol_syslog("error for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG);
$sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sql.=" SET statut=-1, date_envoi=".$db->idate(gmmktime())." WHERE rowid=".$obj->rowid;
$sql.=" SET statut=-1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid;
$resql2=$db->query($sql);
if (! $resql2)
{