diff --git a/build/exakat/README.md b/build/exakat/README.md
new file mode 100644
index 00000000000..3b9052e5281
--- /dev/null
+++ b/build/exakat/README.md
@@ -0,0 +1,29 @@
+
+== Install exakat ==
+mkdir exakat
+cd exakat
+curl -o exakat.phar http://dist.exakat.io/index.php?file=latest
+curl -o apache-tinkerpop-gremlin-server-3.3.5-bin.zip http://dist.exakat.io/apache-tinkerpop-gremlin-server-3.3.5-bin.zip
+unzip apache-tinkerpop-gremlin-server-3.3.5-bin.zip
+mv apache-tinkerpop-gremlin-server-3.3.5 tinkergraph
+rm -rf apache-tinkerpop-gremlin-server-3.3.5-bin.zip
+cd tinkergraph ./bin/gremlin-server.sh -i org.apache.tinkerpop neo4j-gremlin 3.3.5
+cd ..
+
+php exakat.phar version
+php exakat.phar doctor
+
+== Init project ==
+php
+
+
+Edit config.ini file to exclude some dirs:
+ignore_dirs[] = "/htdocs/includes";
+ignore_dirs[] = "/scripts";
+ignore_dirs[] = "/build";
+ignore_dirs[] = "/dev";
+ignore_dirs[] = "/documents";
+
+
+== Analyze project ==
+php
diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index 417d4cd2c99..2a8177df6f2 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -43,19 +43,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
// Load translation files required by the page
-$langs->loadLangs(array("companies","bills","members","users","other"));
+$langs->loadLangs(array("companies", "bills", "members", "users", "other"));
-$action=GETPOST('action', 'alpha');
-$cancel=GETPOST('cancel', 'alpha');
-$backtopage=GETPOST('backtopage', 'alpha');
-$confirm=GETPOST('confirm', 'alpha');
-$rowid=GETPOST('rowid', 'int');
-$id=GETPOST('id')?GETPOST('id', 'int'):$rowid;
-$typeid=GETPOST('typeid', 'int');
-$userid=GETPOST('userid', 'int');
-$socid=GETPOST('socid', 'int');
+$action = GETPOST('action', 'alpha');
+$cancel = GETPOST('cancel', 'alpha');
+$backtopage = GETPOST('backtopage', 'alpha');
+$confirm = GETPOST('confirm', 'alpha');
+$rowid = GETPOST('rowid', 'int');
+$id = GETPOST('id') ?GETPOST('id', 'int') : $rowid;
+$typeid = GETPOST('typeid', 'int');
+$userid = GETPOST('userid', 'int');
+$socid = GETPOST('socid', 'int');
-if (! empty($conf->mailmanspip->enabled))
+if (!empty($conf->mailmanspip->enabled))
{
include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php';
@@ -74,9 +74,9 @@ $socialnetworks = getArrayOfSocialNetworks();
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$object->getCanvas($id);
-$canvas = $object->canvas?$object->canvas:GETPOST("canvas");
-$objcanvas=null;
-if (! empty($canvas))
+$canvas = $object->canvas ? $object->canvas : GETPOST("canvas");
+$objcanvas = null;
+if (!empty($canvas))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
$objcanvas = new Canvas($db, $action);
@@ -84,7 +84,7 @@ if (! empty($canvas))
}
// Security check
-$result=restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objcanvas);
+$result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objcanvas);
if ($id > 0)
{
@@ -92,28 +92,28 @@ if ($id > 0)
$result = $object->fetch($id);
// Define variables to know what current user can do on users
- $canadduser=($user->admin || $user->rights->user->user->creer);
+ $canadduser = ($user->admin || $user->rights->user->user->creer);
// Define variables to know what current user can do on properties of user linked to edited member
if ($object->user_id)
{
// $User is the user who edits, $object->user_id is the id of the related user in the edited member
- $caneditfielduser=((($user->id == $object->user_id) && $user->rights->user->self->creer)
+ $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
|| (($user->id != $object->user_id) && $user->rights->user->user->creer));
- $caneditpassworduser=((($user->id == $object->user_id) && $user->rights->user->self->password)
+ $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
|| (($user->id != $object->user_id) && $user->rights->user->user->password));
}
}
// Define variables to determine what the current user can do on the members
-$canaddmember=$user->rights->adherent->creer;
+$canaddmember = $user->rights->adherent->creer;
// Define variables to determine what the current user can do on the properties of a member
if ($id)
{
- $caneditfieldmember=$user->rights->adherent->creer;
+ $caneditfieldmember = $user->rights->adherent->creer;
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$hookmanager->initHooks(array('membercard','globalcard'));
+$hookmanager->initHooks(array('membercard', 'globalcard'));
@@ -121,25 +121,25 @@ $hookmanager->initHooks(array('membercard','globalcard'));
* Actions
*/
-$parameters=array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas, 'confirm'=>$confirm);
-$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+$parameters = array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas, 'confirm'=>$confirm);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
if ($cancel)
{
- if (! empty($backtopage))
+ if (!empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
- $action='';
+ $action = '';
}
if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
{
- $error=0;
+ $error = 0;
if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only
{
if ($userid != $user->id && $userid != $object->user_id)
@@ -149,47 +149,47 @@ if (empty($reshook))
}
}
- if (! $error)
+ if (!$error)
{
if ($userid != $object->user_id) // If link differs from currently in database
{
- $result=$object->setUserId($userid);
+ $result = $object->setUserId($userid);
if ($result < 0) dol_print_error($object->db, $object->error);
- $action='';
+ $action = '';
}
}
}
if ($action == 'setsocid')
{
- $error=0;
- if (! $error)
+ $error = 0;
+ if (!$error)
{
if ($socid != $object->socid) // If link differs from currently in database
{
- $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
- $sql.=" WHERE socid = '".$socid."'";
- $sql.=" AND entity = ".$conf->entity;
+ $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
+ $sql .= " WHERE socid = '".$socid."'";
+ $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj && $obj->rowid > 0)
{
- $othermember=new Adherent($db);
+ $othermember = new Adherent($db);
$othermember->fetch($obj->rowid);
- $thirdparty=new Societe($db);
+ $thirdparty = new Societe($db);
$thirdparty->fetch($socid);
$error++;
setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors');
}
}
- if (! $error)
+ if (!$error)
{
- $result=$object->setThirdPartyId($socid);
+ $result = $object->setThirdPartyId($socid);
if ($result < 0) dol_print_error($object->db, $object->error);
- $action='';
+ $action = '';
}
}
}
@@ -202,7 +202,7 @@ if (empty($reshook))
{
// Creation user
$nuser = new User($db);
- $result=$nuser->create_from_member($object, GETPOST('login'));
+ $result = $nuser->create_from_member($object, GETPOST('login'));
if ($result < 0)
{
@@ -223,7 +223,7 @@ if (empty($reshook))
{
// User creation
$company = new Societe($db);
- $result=$company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha'));
+ $result = $company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha'));
if ($result < 0)
{
@@ -238,29 +238,29 @@ if (empty($reshook))
}
}
- if ($action == 'update' && ! $cancel && $user->rights->adherent->creer)
+ if ($action == 'update' && !$cancel && $user->rights->adherent->creer)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- $birthdate='';
+ $birthdate = '';
if (isset($_POST["birthday"]) && $_POST["birthday"]
&& isset($_POST["birthmonth"]) && $_POST["birthmonth"]
&& isset($_POST["birthyear"]) && $_POST["birthyear"])
{
- $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]);
+ $birthdate = dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]);
}
- $lastname=$_POST["lastname"];
- $firstname=$_POST["firstname"];
+ $lastname = $_POST["lastname"];
+ $firstname = $_POST["firstname"];
$gender = $_POST["gender"];
- $societe=$_POST["societe"];
- $morphy=$_POST["morphy"];
- $login=$_POST["login"];
+ $societe = $_POST["societe"];
+ $morphy = $_POST["morphy"];
+ $login = $_POST["login"];
if ($morphy != 'mor' && empty($lastname)) {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors');
}
- if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) {
+ if ($morphy != 'mor' && (!isset($firstname) || $firstname == '')) {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors');
@@ -279,7 +279,7 @@ if (empty($reshook))
}
}
// Create new object
- if ($result > 0 && ! $error)
+ if ($result > 0 && !$error)
{
$object->oldcopy = clone $object;
@@ -291,7 +291,7 @@ if (empty($reshook))
$object->login = trim(GETPOST("login", 'alpha'));
$object->pass = trim(GETPOST("pass", 'alpha'));
- $object->societe = trim(GETPOST("societe", 'alpha')); // deprecated
+ $object->societe = trim(GETPOST("societe", 'alpha')); // deprecated
$object->company = trim(GETPOST("societe", 'alpha'));
$object->address = trim(GETPOST("address", 'alpha'));
@@ -302,11 +302,11 @@ if (empty($reshook))
$object->phone = trim(GETPOST("phone", 'alpha'));
$object->phone_perso = trim(GETPOST("phone_perso", 'alpha'));
- $object->phone_mobile= trim(GETPOST("phone_mobile", 'alpha'));
+ $object->phone_mobile = trim(GETPOST("phone_mobile", 'alpha'));
$object->email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha'));
$object->socialnetworks = array();
foreach ($socialnetworks as $key => $value) {
- if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') {
+ if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
$object->socialnetworks[$key] = trim(GETPOST($key, 'alphanohtml'));
}
}
@@ -320,8 +320,8 @@ if (empty($reshook))
//$object->note = trim(GETPOST("comment","alpha"));
$object->morphy = GETPOST("morphy", 'alpha');
- if (GETPOST('deletephoto', 'alpha')) $object->photo='';
- elseif (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
+ if (GETPOST('deletephoto', 'alpha')) $object->photo = '';
+ elseif (!empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
// Get status and public property
$object->statut = GETPOST("statut", 'alpha');
@@ -332,36 +332,36 @@ if (empty($reshook))
if ($ret < 0) $error++;
// Check if we need to also synchronize user information
- $nosyncuser=0;
+ $nosyncuser = 0;
if ($object->user_id) // If linked to a user
{
- if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser=1; // Disable synchronizing
+ if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser = 1; // Disable synchronizing
}
// Check if we need to also synchronize password information
- $nosyncuserpass=0;
+ $nosyncuserpass = 0;
if ($object->user_id) // If linked to a user
{
- if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass=1; // Disable synchronizing
+ if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass = 1; // Disable synchronizing
}
- $result=$object->update($user, 0, $nosyncuser, $nosyncuserpass);
+ $result = $object->update($user, 0, $nosyncuser, $nosyncuserpass);
- if ($result >= 0 && ! count($object->errors))
+ if ($result >= 0 && !count($object->errors))
{
$categories = GETPOST('memcats', 'array');
$object->setCategories($categories);
// Logo/Photo save
- $dir= $conf->adherent->dir_output . '/' . get_exdir(0, 0, 0, 1, $object, 'member').'/photos';
+ $dir = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos';
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK)
{
if (GETPOST('deletephoto'))
{
- require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
- $fileimg=$conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/'.$object->photo;
- $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/thumbs';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ $fileimg = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/'.$object->photo;
+ $dirthumbs = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/thumbs';
dol_delete_file($fileimg);
dol_delete_dir_recursive($dirthumbs);
}
@@ -372,8 +372,8 @@ if (empty($reshook))
if (@is_dir($dir))
{
- $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
- if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0)
+ $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
+ if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0)
{
setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
}
@@ -391,7 +391,7 @@ if (empty($reshook))
}
else
{
- switch($_FILES['photo']['error'])
+ switch ($_FILES['photo']['error'])
{
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
@@ -403,11 +403,11 @@ if (empty($reshook))
}
}
- $rowid=$object->id;
- $id=$object->id;
- $action='';
+ $rowid = $object->id;
+ $id = $object->id;
+ $action = '';
- if (! empty($backtopage))
+ if (!empty($backtopage))
{
header("Location: ".$backtopage);
exit;
@@ -416,67 +416,67 @@ if (empty($reshook))
else
{
setEventMessages($object->error, $object->errors, 'errors');
- $action='';
+ $action = '';
}
}
else
{
- $action='edit';
+ $action = 'edit';
}
}
if ($action == 'add' && $user->rights->adherent->creer)
{
- if ($canvas) $object->canvas=$canvas;
- $birthdate='';
+ if ($canvas) $object->canvas = $canvas;
+ $birthdate = '';
if (isset($_POST["birthday"]) && $_POST["birthday"]
&& isset($_POST["birthmonth"]) && $_POST["birthmonth"]
&& isset($_POST["birthyear"]) && $_POST["birthyear"])
{
- $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]);
+ $birthdate = dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]);
}
- $datesubscription='';
+ $datesubscription = '';
if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"]))
{
- $datesubscription=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
+ $datesubscription = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
}
- $typeid=GETPOST("typeid", 'int');
- $civility_id=GETPOST("civility_id", 'alpha');
- $lastname=GETPOST("lastname", 'alpha');
- $firstname=GETPOST("firstname", 'alpha');
- $gender=GETPOST("gender", 'alpha');
- $societe=GETPOST("societe", 'alpha');
- $address=GETPOST("address", 'alpha');
- $zip=GETPOST("zipcode", 'alpha');
- $town=GETPOST("town", 'alpha');
- $state_id=GETPOST("state_id", 'int');
- $country_id=GETPOST("country_id", 'int');
+ $typeid = GETPOST("typeid", 'int');
+ $civility_id = GETPOST("civility_id", 'alpha');
+ $lastname = GETPOST("lastname", 'alpha');
+ $firstname = GETPOST("firstname", 'alpha');
+ $gender = GETPOST("gender", 'alpha');
+ $societe = GETPOST("societe", 'alpha');
+ $address = GETPOST("address", 'alpha');
+ $zip = GETPOST("zipcode", 'alpha');
+ $town = GETPOST("town", 'alpha');
+ $state_id = GETPOST("state_id", 'int');
+ $country_id = GETPOST("country_id", 'int');
- $phone=GETPOST("phone", 'alpha');
- $phone_perso=GETPOST("phone_perso", 'alpha');
- $phone_mobile=GETPOST("phone_mobile", 'alpha');
+ $phone = GETPOST("phone", 'alpha');
+ $phone_perso = GETPOST("phone_perso", 'alpha');
+ $phone_mobile = GETPOST("phone_mobile", 'alpha');
// $skype=GETPOST("member_skype", 'alpha');
// $twitter=GETPOST("member_twitter", 'alpha');
// $facebook=GETPOST("member_facebook", 'alpha');
// $linkedin=GETPOST("member_linkedin", 'alpha');
- $email=preg_replace('/\s+/', '', GETPOST("member_email", 'alpha'));
- $login=GETPOST("member_login", 'alpha');
- $pass=GETPOST("password", 'alpha');
- $photo=GETPOST("photo", 'alpha');
+ $email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha'));
+ $login = GETPOST("member_login", 'alpha');
+ $pass = GETPOST("password", 'alpha');
+ $photo = GETPOST("photo", 'alpha');
//$comment=GETPOST("comment",'none');
- $morphy=GETPOST("morphy", 'alpha');
- $subscription=GETPOST("subscription", 'alpha');
- $public=GETPOST("public", 'alpha');
+ $morphy = GETPOST("morphy", 'alpha');
+ $subscription = GETPOST("subscription", 'alpha');
+ $public = GETPOST("public", 'alpha');
- $userid=GETPOST("userid", 'int');
- $socid=GETPOST("socid", 'int');
+ $userid = GETPOST("userid", 'int');
+ $socid = GETPOST("socid", 'int');
$object->civility_id = $civility_id;
$object->firstname = $firstname;
$object->lastname = $lastname;
$object->gender = $gender;
- $object->societe = $societe; // deprecated
+ $object->societe = $societe; // deprecated
$object->company = $societe;
$object->address = $address;
$object->zip = $zip;
@@ -485,11 +485,11 @@ if (empty($reshook))
$object->country_id = $country_id;
$object->phone = $phone;
$object->phone_perso = $phone_perso;
- $object->phone_mobile= $phone_mobile;
+ $object->phone_mobile = $phone_mobile;
$object->socialnetworks = array();
- if (! empty($conf->socialnetworks->enabled)) {
+ if (!empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) {
- if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') {
+ if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
$object->socialnetworks[$key] = GETPOST("member_".$key, 'alphanohtml');
}
}
@@ -509,7 +509,7 @@ if (empty($reshook))
//$object->note = $comment;
$object->morphy = $morphy;
$object->user_id = $userid;
- $object->socid = $socid;
+ $object->socid = $socid;
$object->public = $public;
// Fill array 'array_options' with data from add form
@@ -555,29 +555,29 @@ if (empty($reshook))
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors');
}
- if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) {
+ if ($morphy != 'mor' && (!isset($firstname) || $firstname == '')) {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors');
}
- if (! ($typeid > 0)) { // Keep () before !
+ if (!($typeid > 0)) { // Keep () before !
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
}
- if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) {
+ if ($conf->global->ADHERENT_MAIL_REQUIRED && !isValidEMail($email)) {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors');
}
- $public=0;
- if (isset($public)) $public=1;
+ $public = 0;
+ if (isset($public)) $public = 1;
- if (! $error)
+ if (!$error)
{
$db->begin();
// Email about right and login does not exist
- $result=$object->create($user);
+ $result = $object->create($user);
if ($result > 0)
{
// Foundation categories
@@ -585,9 +585,9 @@ if (empty($reshook))
$object->setCategories($memcats);
$db->commit();
- $rowid=$object->id;
- $id=$object->id;
- $action='';
+ $rowid = $object->id;
+ $id = $object->id;
+ $action = '';
}
else
{
@@ -609,10 +609,10 @@ if (empty($reshook))
if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes')
{
- $result=$object->delete($id, $user);
+ $result = $object->delete($id, $user);
if ($result > 0)
{
- if (! empty($backtopage))
+ if (!empty($backtopage))
{
header("Location: ".$backtopage);
exit;
@@ -625,44 +625,44 @@ if (empty($reshook))
}
else
{
- $errmesg=$object->error;
+ $errmesg = $object->error;
}
}
if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes')
{
- $error=0;
+ $error = 0;
$db->begin();
$adht = new AdherentType($db);
$adht->fetch($object->typeid);
- $result=$object->validate($user);
+ $result = $object->validate($user);
- if ($result >= 0 && ! count($object->errors))
+ if ($result >= 0 && !count($object->errors))
{
// Send confirmation email (according to parameters of member type. Otherwise generic)
if ($object->email && GETPOST("send_mail"))
{
$subject = '';
- $msg= '';
+ $msg = '';
// Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
- $formmail=new FormMail($db);
+ $formmail = new FormMail($db);
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "members"));
// Get email content from template
- $arraydefaultmessage=null;
+ $arraydefaultmessage = null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION;
- if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
+ if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
- if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
+ if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
@@ -674,14 +674,14 @@ if (empty($reshook))
$error++;
}
else {
- $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
+ $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
- $moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";
+ $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";
- $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
+ $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
if ($result < 0)
{
$error++;
@@ -700,7 +700,7 @@ if (empty($reshook))
}
}
- if (! $error)
+ if (!$error)
{
$db->commit();
}
@@ -708,7 +708,7 @@ if (empty($reshook))
{
$db->rollback();
}
- $action='';
+ $action = '';
}
if ($user->rights->adherent->supprimer && $action == 'confirm_resign')
@@ -720,30 +720,30 @@ if (empty($reshook))
$adht = new AdherentType($db);
$adht->fetch($object->typeid);
- $result=$object->resiliate($user);
+ $result = $object->resiliate($user);
- if ($result >= 0 && ! count($object->errors))
+ if ($result >= 0 && !count($object->errors))
{
if ($object->email && GETPOST("send_mail"))
{
$subject = '';
- $msg= '';
+ $msg = '';
// Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
- $formmail=new FormMail($db);
+ $formmail = new FormMail($db);
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "members"));
// Get email content from template
- $arraydefaultmessage=null;
+ $arraydefaultmessage = null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION;
- if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
+ if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
- if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
+ if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
@@ -755,14 +755,14 @@ if (empty($reshook))
$error++;
}
else {
- $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
+ $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs);
- $moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";
+ $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";
- $result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
+ $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
if ($result < 0)
{
$error++;
@@ -780,10 +780,10 @@ if (empty($reshook))
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
- $action='';
+ $action = '';
}
}
- if (! empty($backtopage) && ! $error)
+ if (!empty($backtopage) && !$error)
{
header("Location: ".$backtopage);
exit;
@@ -793,7 +793,7 @@ if (empty($reshook))
// SPIP Management
if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes')
{
- if (! count($object->errors))
+ if (!count($object->errors))
{
if (!$mailmanspip->del_to_spip($object))
{
@@ -804,7 +804,7 @@ if (empty($reshook))
if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes')
{
- if (! count($object->errors))
+ if (!count($object->errors))
{
if (!$mailmanspip->add_to_spip($object))
{
@@ -818,14 +818,14 @@ if (empty($reshook))
// Actions to build doc
$upload_dir = $conf->adherent->dir_output;
- $permissiontoadd=$user->rights->adherent->creer;
+ $permissiontoadd = $user->rights->adherent->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails
- $trigger_name='MEMBER_SENTBYMAIL';
- $paramname='id';
- $mode='emailfrommember';
- $trackid='mem'.$object->id;
+ $trigger_name = 'MEMBER_SENTBYMAIL';
+ $paramname = 'id';
+ $mode = 'emailfrommember';
+ $trackid = 'mem'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
}
@@ -838,11 +838,11 @@ $form = new Form($db);
$formfile = new FormFile($db);
$formcompany = new FormCompany($db);
-$title=$langs->trans("Member") . " - " . $langs->trans("Card");
-$help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros';
+$title = $langs->trans("Member")." - ".$langs->trans("Card");
+$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros';
llxHeader('', $title, $help_url);
-$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
+$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
{
@@ -852,11 +852,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
if (empty($object->error) && $id)
{
$object = new Adherent($db);
- $result=$object->fetch($id);
+ $result = $object->fetch($id);
if ($result <= 0) dol_print_error('', $object->error);
}
- $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
- $objcanvas->display_canvas($action); // Show template
+ $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
+ $objcanvas->display_canvas($action); // Show template
}
else
{
@@ -871,23 +871,23 @@ else
/* Creation mode */
/* */
/* ************************************************************************** */
- $object->canvas=$canvas;
+ $object->canvas = $canvas;
$object->state_id = GETPOST('state_id', 'int');
// We set country_id, country_code and country for the selected country
- $object->country_id=GETPOST('country_id', 'int')?GETPOST('country_id', 'int'):$mysoc->country_id;
+ $object->country_id = GETPOST('country_id', 'int') ?GETPOST('country_id', 'int') : $mysoc->country_id;
if ($object->country_id)
{
- $tmparray=getCountry($object->country_id, 'all');
- $object->country_code=$tmparray['code'];
- $object->country=$tmparray['label'];
+ $tmparray = getCountry($object->country_id, 'all');
+ $object->country_code = $tmparray['code'];
+ $object->country = $tmparray['label'];
}
if (!empty($socid)) {
$object = new Societe($db);
if ($socid > 0) $object->fetch($socid);
- if (! ($object->id > 0))
+ if (!($object->id > 0))
{
$langs->load("errors");
print($langs->trans('ErrorRecordNotFound'));
@@ -944,14 +944,14 @@ else
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
- print '
'.$langs->trans("Login").' / '.$langs->trans("Id").' login).'" autofocus="autofocus"> ';
+ print ''.$langs->trans("Login").' / '.$langs->trans("Id").' login).'" autofocus="autofocus"> ';
}
// Password
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
- $generated_password=getRandomPassword(false);
+ $generated_password = getRandomPassword(false);
print ''.$langs->trans("Password").' ';
print ' ';
print ' ';
@@ -959,10 +959,10 @@ else
// Type
print ''.$langs->trans("MemberType").' ';
- $listetype=$adht->liste_array();
+ $listetype = $adht->liste_array();
if (count($listetype))
{
- print $form->selectarray("typeid", $listetype, GETPOST('typeid', 'int')?GETPOST('typeid', 'int'):$typeid, count($listetype)>1?1:0);
+ print $form->selectarray("typeid", $listetype, GETPOST('typeid', 'int') ?GETPOST('typeid', 'int') : $typeid, count($listetype) > 1 ? 1 : 0);
} else {
print ''.$langs->trans("NoTypeDefinedGoToSetup").' ';
}
@@ -972,51 +972,51 @@ else
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
print ' '.$langs->trans("MemberNature")." \n";
- print $form->selectarray("morphy", $morphys, GETPOST('morphy', 'alpha')?GETPOST('morphy', 'alpha'):$object->morphy, 1);
+ print $form->selectarray("morphy", $morphys, GETPOST('morphy', 'alpha') ?GETPOST('morphy', 'alpha') : $object->morphy, 1);
print " \n";
// Company
- print ''.$langs->trans("Company").' ';
+ print ''.$langs->trans("Company").' ';
// Civility
print ''.$langs->trans("UserTitle").' ';
- print $formcompany->select_civility(GETPOST('civility_id', 'int')?GETPOST('civility_id', 'int'):$object->civility_id, 'civility_id').' ';
+ print $formcompany->select_civility(GETPOST('civility_id', 'int') ?GETPOST('civility_id', 'int') : $object->civility_id, 'civility_id').'';
print ' ';
// Lastname
- print ''.$langs->trans("Lastname").' ';
+ print ''.$langs->trans("Lastname").' ';
print ' ';
// Firstname
- print ''.$langs->trans("Firstname").' ';
+ print ''.$langs->trans("Firstname").' ';
print ' ';
// Gender
print ''.$langs->trans("Gender").' ';
print '';
- $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman"));
+ $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"));
print $form->selectarray('gender', $arraygender, GETPOST('gender'), 1);
print ' ';
// EMail
- print ''.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?' ':'').' ';
+ print ''.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? ' ' : '').' ';
// Address
print ''.$langs->trans("Address").' ';
- print '';
+ print '';
print ' ';
// Zip / Town
print ''.$langs->trans("Zip").' / '.$langs->trans("Town").' ';
- print $formcompany->select_ziptown((GETPOST('zipcode', 'alphanohtml')?GETPOST('zipcode', 'alphanohtml'):$object->zip), 'zipcode', array('town','selectcountry_id','state_id'), 6);
+ print $formcompany->select_ziptown((GETPOST('zipcode', 'alphanohtml') ?GETPOST('zipcode', 'alphanohtml') : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
print ' ';
- print $formcompany->select_ziptown((GETPOST('town', 'alphanohtml')?GETPOST('town', 'alphanohtml'):$object->town), 'town', array('zipcode','selectcountry_id','state_id'));
+ print $formcompany->select_ziptown((GETPOST('town', 'alphanohtml') ?GETPOST('town', 'alphanohtml') : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
print ' ';
// Country
- $object->country_id=$object->country_id?$object->country_id:$mysoc->country_id;
+ $object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id;
print ''.$langs->trans('Country').' ';
- print $form->select_country(GETPOST('country_id', 'alpha')?GETPOST('country_id', 'alpha'):$object->country_id, 'country_id');
+ print $form->select_country(GETPOST('country_id', 'alpha') ?GETPOST('country_id', 'alpha') : $object->country_id, 'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
print ' ';
@@ -1026,7 +1026,7 @@ else
print ''.$langs->trans('State').' ';
if ($object->country_id)
{
- print $formcompany->select_state(GETPOST('state_id', 'int')?GETPOST('state_id', 'int'):$object->state_id, $object->country_code);
+ print $formcompany->select_state(GETPOST('state_id', 'int') ?GETPOST('state_id', 'int') : $object->state_id, $object->country_code);
}
else
{
@@ -1036,18 +1036,18 @@ else
}
// Pro phone
- print ' '.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").' ';
+ print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").' ';
// Personal phone
- print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").' ';
+ print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").' ';
// Mobile phone
- print ''.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").' ';
+ print ''.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").' ';
- if (! empty($conf->socialnetworks->enabled)) {
+ if (!empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) {
if (!$value['active']) break;
- print ''.$langs->trans($value['label']).' ';
+ print ''.$langs->trans($value['label']).' ';
}
}
@@ -1062,9 +1062,9 @@ else
print "\n";
// Categories
- if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
+ if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
{
- print '' .$form->editfieldkey("Categories", 'memcats', '', $object, 0) . ' ';
+ print ' '.$form->editfieldkey("Categories", 'memcats', '', $object, 0).' ';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, 'parent', null, null, 1);
print $form->multiselectarray('memcats', $cate_arbo, GETPOST('memcats', 'array'), null, null, null, null, '100%');
print " ";
@@ -1073,7 +1073,7 @@ else
// Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
//Hooks here
- $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
@@ -1087,13 +1087,13 @@ else
print '';
print ' ';
print ' ';
- if (! empty($backtopage))
+ if (!empty($backtopage))
{
print ' ';
}
else
{
- print ' ';
+ print ' ';
}
print '
';
@@ -1108,11 +1108,11 @@ else
*
********************************************/
- $res=$object->fetch($id);
+ $res = $object->fetch($id);
if ($res < 0) {
dol_print_error($db, $object->error); exit;
}
- $res=$object->fetch_optionals();
+ $res = $object->fetch_optionals();
if ($res < 0) {
dol_print_error($db); exit;
}
@@ -1121,11 +1121,11 @@ else
$adht->fetch($object->typeid);
// We set country_id, and country_code, country of the chosen country
- $country=GETPOST('country', 'int');
+ $country = GETPOST('country', 'int');
if (!empty($country) || $object->country_id)
{
- $sql = "SELECT rowid, code, label from ".MAIN_DB_PREFIX."c_country where rowid = ".(!empty($country)?$country:$object->country_id);
- $resql=$db->query($sql);
+ $sql = "SELECT rowid, code, label from ".MAIN_DB_PREFIX."c_country where rowid = ".(!empty($country) ? $country : $object->country_id);
+ $resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
@@ -1134,9 +1134,9 @@ else
{
dol_print_error($db);
}
- $object->country_id=$obj->rowid;
- $object->country_code=$obj->code;
- $object->country=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label;
+ $object->country_id = $obj->rowid;
+ $object->country_code = $obj->code;
+ $object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label;
}
$head = member_prepare_head($object);
@@ -1190,26 +1190,26 @@ else
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
- print ''.$langs->trans("Login").' / '.$langs->trans("Id").' login).'"> ';
+ print ''.$langs->trans("Login").' / '.$langs->trans("Id").' login).'"> ';
}
// Password
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
- print ''.$langs->trans("Password").' pass).'"> ';
+ print ''.$langs->trans("Password").' pass).'"> ';
}
// Morphy
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
print ''.$langs->trans("MemberNature").' ';
- print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy")?GETPOST("morphy", 'alpha'):$object->morphy));
+ print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy") ?GETPOST("morphy", 'alpha') : $object->morphy));
print " ";
// Type
print ''.$langs->trans("Type").' ';
if ($user->rights->adherent->creer)
{
- print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid")?GETPOST("typeid", 'int'):$object->typeid));
+ print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ?GETPOST("typeid", 'int') : $object->typeid));
}
else
{
@@ -1219,27 +1219,27 @@ else
print " ";
// Company
- print ''.$langs->trans("Company").' company).'"> ';
+ print ''.$langs->trans("Company").' company).'"> ';
// Civility
print ''.$langs->trans("UserTitle").' ';
- print $formcompany->select_civility(isset($_POST["civility_id"])?$_POST["civility_id"]:$object->civility_id)."\n";
+ print $formcompany->select_civility(isset($_POST["civility_id"]) ? $_POST["civility_id"] : $object->civility_id)."\n";
print ' ';
print ' ';
// Lastname
- print ''.$langs->trans("Lastname").' lastname).'"> ';
+ print ''.$langs->trans("Lastname").' lastname).'"> ';
print ' ';
// Firstname
- print ''.$langs->trans("Firstname").' firstname).'"> ';
+ print ''.$langs->trans("Firstname").' firstname).'"> ';
print ' ';
// Gender
print ''.$langs->trans("Gender").' ';
print '';
- $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman"));
- print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1);
+ $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"));
+ print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1);
print ' ';
// Photo
@@ -1258,24 +1258,24 @@ else
print '';
// EMail
- print ''.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?' ':'').' email).'"> ';
+ print ''.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? ' ' : '').' email).'"> ';
// Address
print ''.$langs->trans("Address").' ';
- print '';
+ print '';
print ' ';
// Zip / Town
print ''.$langs->trans("Zip").' / '.$langs->trans("Town").' ';
- print $formcompany->select_ziptown((isset($_POST["zipcode"])?GETPOST("zipcode", '', 2):$object->zip), 'zipcode', array('town','selectcountry_id','state_id'), 6);
+ print $formcompany->select_ziptown((isset($_POST["zipcode"]) ?GETPOST("zipcode", '', 2) : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
print ' ';
- print $formcompany->select_ziptown((isset($_POST["town"])?GETPOST("town", '', 2):$object->town), 'town', array('zipcode','selectcountry_id','state_id'));
+ print $formcompany->select_ziptown((isset($_POST["town"]) ?GETPOST("town", '', 2) : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
print ' ';
// Country
//$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined
print ''.$langs->trans('Country').' ';
- print $form->select_country(isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id, 'country_id');
+ print $form->select_country(isset($_POST["country_id"]) ? $_POST["country_id"] : $object->country_id, 'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
print ' ';
@@ -1283,23 +1283,23 @@ else
if (empty($conf->global->MEMBER_DISABLE_STATE))
{
print ''.$langs->trans('State').' ';
- print $formcompany->select_state($object->state_id, isset($_POST["country_id"])?GETPOST("country_id"):$object->country_id);
+ print $formcompany->select_state($object->state_id, isset($_POST["country_id"]) ?GETPOST("country_id") : $object->country_id);
print ' ';
}
// Pro phone
- print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").' phone).'"> ';
+ print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").' phone).'"> ';
// Personal phone
- print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").' phone_perso).'"> ';
+ print ''.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").' phone_perso).'"> ';
// Mobile phone
- print ''.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").' phone_mobile).'"> ';
+ print ''.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").' phone_mobile).'"> ';
- if (! empty($conf->socialnetworks->enabled)) {
+ if (!empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) {
if (!$value['active']) break;
- print ''.$langs->trans($value['label']).' ';
+ print ''.$langs->trans($value['label']).' ';
}
}
@@ -1310,13 +1310,13 @@ else
// Public profil
print "".$langs->trans("Public")." \n";
- print $form->selectyesno("public", (isset($_POST["public"])?GETPOST("public", '', 2):$object->public), 1);
+ print $form->selectyesno("public", (isset($_POST["public"]) ?GETPOST("public", '', 2) : $object->public), 1);
print " \n";
// Categories
- if (! empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
+ if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
{
- print '' . $form->editfieldkey("Categories", 'memcats', '', $object, 0) . ' ';
+ print ''.$form->editfieldkey("Categories", 'memcats', '', $object, 0).' ';
print '';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, null, null, null, 1);
$c = new Categorie($db);
@@ -1332,13 +1332,13 @@ else
}
// Third party Dolibarr
- if (! empty($conf->societe->enabled))
+ if (!empty($conf->societe->enabled))
{
print ' '.$langs->trans("LinkedToDolibarrThirdParty").' ';
if ($object->socid)
{
- $company=new Societe($db);
- $result=$company->fetch($object->socid);
+ $company = new Societe($db);
+ $result = $company->fetch($object->socid);
print $company->getNomUrl(1);
}
else
@@ -1380,17 +1380,17 @@ else
/* */
/* ************************************************************************** */
- $res=$object->fetch($id);
+ $res = $object->fetch($id);
if ($res < 0) {
dol_print_error($db, $object->error); exit;
}
- $res=$object->fetch_optionals();
+ $res = $object->fetch_optionals();
if ($res < 0) {
dol_print_error($db); exit;
}
$adht = new AdherentType($db);
- $res=$adht->fetch($object->typeid);
+ $res = $adht->fetch($object->typeid);
if ($res < 0) {
dol_print_error($db); exit;
}
@@ -1406,24 +1406,24 @@ else
// Confirm create user
if ($action == 'create_user')
{
- $login=$object->login;
+ $login = $object->login;
if (empty($login))
{
// Full firstname and name separated with a dot : firstname.name
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
- $login=dol_buildlogin($object->lastname, $object->firstname);
+ $login = dol_buildlogin($object->lastname, $object->firstname);
}
- if (empty($login)) $login=strtolower(substr($object->firstname, 0, 4)) . strtolower(substr($object->lastname, 0, 4));
+ if (empty($login)) $login = strtolower(substr($object->firstname, 0, 4)).strtolower(substr($object->lastname, 0, 4));
// Create a form array
- $formquestion=array(
+ $formquestion = array(
array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)
);
- $text=$langs->trans("ConfirmCreateLogin").' ';
- if (! empty($conf->societe->enabled))
+ $text = $langs->trans("ConfirmCreateLogin").' ';
+ if (!empty($conf->societe->enabled))
{
- if ($object->socid > 0) $text.=$langs->trans("UserWillBeExternalUser");
- else $text.=$langs->trans("UserWillBeInternalUser");
+ if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser");
+ else $text .= $langs->trans("UserWillBeInternalUser");
}
print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes');
}
@@ -1431,22 +1431,22 @@ else
// Confirm create third party
if ($action == 'create_thirdparty')
{
- $companyalias='';
+ $companyalias = '';
$fullname = $object->getFullName($langs);
if ($object->morphy == 'mor')
{
- $companyname=$object->company;
- if (! empty($fullname)) $companyalias=$fullname;
+ $companyname = $object->company;
+ if (!empty($fullname)) $companyalias = $fullname;
}
else
{
- $companyname=$fullname;
- if (! empty($object->company)) $companyalias=$object->company;
+ $companyname = $fullname;
+ if (!empty($object->company)) $companyalias = $object->company;
}
// Create a form array
- $formquestion=array(
+ $formquestion = array(
array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'),
array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"')
);
@@ -1463,54 +1463,54 @@ else
$adht->fetch($object->typeid);
$subject = '';
- $msg= '';
+ $msg = '';
// Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
- $formmail=new FormMail($db);
+ $formmail = new FormMail($db);
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "members"));
// Get email content from template
- $arraydefaultmessage=null;
+ $arraydefaultmessage = null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION;
- if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
+ if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
- if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
+ if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
- $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
+ $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
- $tmp=$langs->trans("SendingAnEMailToMember");
- $tmp.=' '.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.' , ';
- $tmp.=' '.$langs->trans("MailRecipient").': '.$object->email.' ';
- $helpcontent='';
- $helpcontent.=''.$langs->trans("MailFrom").' : '.$conf->global->ADHERENT_MAIL_FROM.' '."\n";
- $helpcontent.=''.$langs->trans("MailRecipient").' : '.$object->email.' '."\n";
- $helpcontent.=''.$langs->trans("Subject").' : '."\n";
- $helpcontent.=$subjecttosend."\n";
- $helpcontent.=" ";
- $helpcontent.=''.$langs->trans("Content").' : ';
- $helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
- $label=$form->textwithpicto($tmp, $helpcontent, 1, 'help');
+ $tmp = $langs->trans("SendingAnEMailToMember");
+ $tmp .= ' '.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.' , ';
+ $tmp .= ' '.$langs->trans("MailRecipient").': '.$object->email.' ';
+ $helpcontent = '';
+ $helpcontent .= ''.$langs->trans("MailFrom").' : '.$conf->global->ADHERENT_MAIL_FROM.' '."\n";
+ $helpcontent .= ''.$langs->trans("MailRecipient").' : '.$object->email.' '."\n";
+ $helpcontent .= ''.$langs->trans("Subject").' : '."\n";
+ $helpcontent .= $subjecttosend."\n";
+ $helpcontent .= " ";
+ $helpcontent .= ''.$langs->trans("Content").' : ';
+ $helpcontent .= dol_htmlentitiesbr($texttosend)."\n";
+ $label = $form->textwithpicto($tmp, $helpcontent, 1, 'help');
// Create form popup
- $formquestion=array();
- if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false));
- if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_MAILMAN)) {
- $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"),'value'=>'');
+ $formquestion = array();
+ if ($object->email) $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL ?true:false));
+ if (!empty($conf->mailman->enabled) && !empty($conf->global->ADHERENT_USE_MAILMAN)) {
+ $formquestion[] = array('type'=>'other', 'label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"), 'value'=>'');
}
- if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) {
- $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>'');
+ if (!empty($conf->mailman->enabled) && !empty($conf->global->ADHERENT_USE_SPIP)) {
+ $formquestion[] = array('type'=>'other', 'label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"), 'value'=>'');
}
print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ValidateMember"), $langs->trans("ConfirmValidateMember"), "confirm_valid", $formquestion, 'yes', 1, 220);
}
@@ -1524,58 +1524,58 @@ else
$adht->fetch($object->typeid);
$subject = '';
- $msg= '';
+ $msg = '';
// Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
- $formmail=new FormMail($db);
+ $formmail = new FormMail($db);
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "members"));
// Get email content from template
- $arraydefaultmessage=null;
+ $arraydefaultmessage = null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION;
- if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
+ if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
- if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
+ if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
- $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
+ $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs);
- $tmp=$langs->trans("SendingAnEMailToMember");
- $tmp.=' ('.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.' , ';
- $tmp.=$langs->trans("MailRecipient").': '.$object->email.' )';
- $helpcontent='';
- $helpcontent.=''.$langs->trans("MailFrom").' : '.$conf->global->ADHERENT_MAIL_FROM.' '."\n";
- $helpcontent.=''.$langs->trans("MailRecipient").' : '.$object->email.' '."\n";
- $helpcontent.=''.$langs->trans("Subject").' : '."\n";
- $helpcontent.=$subjecttosend."\n";
- $helpcontent.=" ";
- $helpcontent.=''.$langs->trans("Content").' : ';
- $helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
- $label=$form->textwithpicto($tmp, $helpcontent, 1, 'help');
+ $tmp = $langs->trans("SendingAnEMailToMember");
+ $tmp .= ' ('.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.' , ';
+ $tmp .= $langs->trans("MailRecipient").': '.$object->email.' )';
+ $helpcontent = '';
+ $helpcontent .= ''.$langs->trans("MailFrom").' : '.$conf->global->ADHERENT_MAIL_FROM.' '."\n";
+ $helpcontent .= ''.$langs->trans("MailRecipient").' : '.$object->email.' '."\n";
+ $helpcontent .= ''.$langs->trans("Subject").' : '."\n";
+ $helpcontent .= $subjecttosend."\n";
+ $helpcontent .= " ";
+ $helpcontent .= ''.$langs->trans("Content").' : ';
+ $helpcontent .= dol_htmlentitiesbr($texttosend)."\n";
+ $label = $form->textwithpicto($tmp, $helpcontent, 1, 'help');
// Create an array
- $formquestion=array();
- if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?'true':'false'));
- if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
+ $formquestion = array();
+ if ($object->email) $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? 'true' : 'false'));
+ if ($backtopage) $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ResiliateMember"), $langs->trans("ConfirmResiliateMember"), "confirm_resign", $formquestion, 'no', 1, 240);
}
// Confirm remove member
if ($action == 'delete')
{
- $formquestion=array();
- if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
+ $formquestion = array();
+ if ($backtopage) $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
print $form->formconfirm("card.php?rowid=".$id, $langs->trans("DeleteMember"), $langs->trans("ConfirmDeleteMember"), "confirm_delete", $formquestion, 'no', 1);
}
@@ -1590,9 +1590,9 @@ else
print $form->formconfirm("card.php?rowid=$id", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip');
}
- $rowspan=17;
+ $rowspan = 17;
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
- if (! empty($conf->societe->enabled)) $rowspan++;
+ if (!empty($conf->societe->enabled)) $rowspan++;
$linkback = ''.$langs->trans("BackToList").' ';
@@ -1640,10 +1640,10 @@ else
if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
else print $langs->trans("Hidden");
}
- if ((! empty($object->pass) || ! empty($object->pass_crypted)) && empty($object->user_id))
+ if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id))
{
$langs->load("errors");
- $htmltext=$langs->trans("WarningPasswordSetWithNoAccount");
+ $htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
print ' '.$form->textwithpicto('', $htmltext, 1, 'warning');
}
print ' ';
@@ -1664,7 +1664,7 @@ else
{
print $langs->trans("SubscriptionNotNeeded");
}
- elseif (! $adht->subscription)
+ elseif (!$adht->subscription)
{
print $langs->trans("SubscriptionNotRecorded");
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
@@ -1678,7 +1678,7 @@ else
print '';
// Third party Dolibarr
- if (! empty($conf->societe->enabled))
+ if (!empty($conf->societe->enabled))
{
print '';
$editenable = $user->rights->adherent->creer;
@@ -1686,7 +1686,7 @@ else
print ' ';
if ($action == 'editthirdparty')
{
- $htmlname='socid';
+ $htmlname = 'socid';
print ' \n";
- $i = 1;
+ $i = 1;
if ($num > 0)
{
while ($objp = $db->fetch_object($resql))
{
- //$account_id = $objp->bid; FIXME not used
-
- // FIXME $accounts[$objp->bid] is a label
- /*if (! isset($accounts[$objp->bid]))
- $accounts[$objp->bid]=0;
- $accounts[$objp->bid] += 1;*/
-
print '';
print ''.$i.' ';
print ''.dol_print_date($db->jdate($objp->date), 'day').' '; // Date operation
@@ -751,6 +744,15 @@ else
}
print "";
+
+ // Cheque denormalized data nbcheque is similar to real number of cheque
+ if ($num > 0 && $i < ($object->nbcheque + 1)) {
+ // Show warning that some records were removed.
+ $langs->load("errors");
+ print info_admin($langs->trans("WarningSomeBankTransactionByChequeWereRemovedAfter"), 0, 0, 'warning');
+ // TODO Fix data ->nbcheque and ->amount
+ }
+
print "";
}
else
diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php
index fb41142d970..72508c804a5 100644
--- a/htdocs/compta/prelevement/card.php
+++ b/htdocs/compta/prelevement/card.php
@@ -177,7 +177,7 @@ if ($id > 0 || $ref)
print '';
print '
';
- print '
';
+ print '';
//print ''.$langs->trans("Ref").' '.$object->getNomUrl(1).' ';
print ''.$langs->trans("Date").' '.dol_print_date($object->datec, 'day').' ';
@@ -214,7 +214,7 @@ if ($id > 0 || $ref)
print ' ';
print '
';
- print '';
+ print '';
$acc = new Account($db);
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index f1c3f70c53a..1e2050c5a47 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -74,6 +74,10 @@ class BonPrelevement extends CommonObject
public $invoice_in_error=array();
public $thirdparty_in_error=array();
+ const STATUS_DRAFT = 0;
+ const STATUS_TRANSFERED = 1;
+ const STATUS_CREDITED = 2;
+
/**
* Constructor
@@ -2001,49 +2005,23 @@ class BonPrelevement extends CommonObject
*/
public function LibStatut($status, $mode = 0)
{
- // phpcs:enable
- if (empty($this->labelStatus))
+ // phpcs:enable
+ if (empty($this->labelStatus) || empty($this->labelStatusShort))
{
global $langs;
- $langs->load("withdrawals");
- $this->labelStatus[0]=$langs->trans("StatusWaiting");
- $this->labelStatus[1]=$langs->trans("StatusTrans");
- $this->labelStatus[2]=$langs->trans("StatusCredited");
+ //$langs->load("mymodule");
+ $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('StatusWaiting');
+ $this->labelStatus[self::STATUS_TRANSFERED] = $langs->trans('StatusTrans');
+ $this->labelStatus[self::STATUS_CREDITED] = $langs->trans('StatusCredited');
+ $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('StatusWaiting');
+ $this->labelStatusShort[self::STATUS_TRANSFERED] = $langs->trans('StatusTrans');
+ $this->labelStatusShort[self::STATUS_CREDITED] = $langs->trans('StatusCredited');
}
- if ($mode == 0 || $mode == 1)
- {
- return $this->labelStatus[$status];
- }
- elseif ($mode == 2)
- {
- if ($status==0) return img_picto($this->labelStatus[$status], 'statut1').' '.$this->labelStatus[$status];
- elseif ($status==1) return img_picto($this->labelStatus[$status], 'statut3').' '.$this->labelStatus[$status];
- elseif ($status==2) return img_picto($this->labelStatus[$status], 'statut6').' '.$this->labelStatus[$status];
- }
- elseif ($mode == 3)
- {
- if ($status==0) return img_picto($this->labelStatus[$status], 'statut1');
- elseif ($status==1) return img_picto($this->labelStatus[$status], 'statut3');
- elseif ($status==2) return img_picto($this->labelStatus[$status], 'statut6');
- }
- elseif ($mode == 4)
- {
- if ($status==0) return img_picto($this->labelStatus[$status], 'statut1').' '.$this->labelStatus[$status];
- elseif ($status==1) return img_picto($this->labelStatus[$status], 'statut3').' '.$this->labelStatus[$status];
- elseif ($status==2) return img_picto($this->labelStatus[$status], 'statut6').' '.$this->labelStatus[$status];
- }
- elseif ($mode == 5)
- {
- if ($status==0) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut1');
- elseif ($status==1) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut3');
- elseif ($status==2) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut6');
- }
- elseif ($mode == 6)
- {
- if ($status==0) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut1');
- elseif ($status==1) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut3');
- elseif ($status==2) return $this->labelStatus[$status].' '.img_picto($this->labelStatus[$status], 'statut6');
- }
+ $statusType = 'status1';
+ if ($status == self::STATUS_TRANSFERED) $statusType = 'status3';
+ if ($status == self::STATUS_CREDITED) $statusType = 'status6';
+
+ return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
}
diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php
index 01acea0479a..a9fd4f1fbbc 100644
--- a/htdocs/compta/prelevement/factures.php
+++ b/htdocs/compta/prelevement/factures.php
@@ -79,7 +79,7 @@ if ($prev_id > 0 || $ref)
print '';
print '
';
- print '
';
+ print '';
//print ''.$langs->trans("Ref").' '.$object->getNomUrl(1).' ';
print ''.$langs->trans("Date").' '.dol_print_date($object->datec, 'day').' ';
@@ -111,7 +111,7 @@ if ($prev_id > 0 || $ref)
print ' ';
print '
';
- print '';
+ print '';
$acc = new Account($db);
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php
index ebb7ab7fbb2..d44ffdea4a8 100644
--- a/htdocs/compta/prelevement/fiche-rejet.php
+++ b/htdocs/compta/prelevement/fiche-rejet.php
@@ -75,7 +75,7 @@ if ($prev_id > 0 || $ref)
print '';
print '
';
- print '
'."\n";
+ print ''."\n";
//print ''.$langs->trans("Ref").' '.$object->getNomUrl(1).' ';
print ''.$langs->trans("Date").' '.dol_print_date($object->datec, 'day').' ';
@@ -112,7 +112,7 @@ if ($prev_id > 0 || $ref)
print ' ';
print '
';
- print '';
+ print '';
$acc = new Account($db);
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php
index fa7b1758435..70441ff19c2 100644
--- a/htdocs/compta/prelevement/fiche-stat.php
+++ b/htdocs/compta/prelevement/fiche-stat.php
@@ -72,7 +72,7 @@ if ($prev_id > 0 || $ref)
print '';
print '
';
- print '
'."\n";
+ print ''."\n";
//print ''.$langs->trans("Ref").' '.$object->getNomUrl(1).' ';
print ''.$langs->trans("Date").' '.dol_print_date($object->datec, 'day').' ';
@@ -109,7 +109,7 @@ if ($prev_id > 0 || $ref)
print ' ';
print '
';
- print '';
+ print '';
$acc = new Account($db);
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php
index 2bc82fc8b78..fecc5a96aa1 100644
--- a/htdocs/compta/sociales/class/chargesociales.class.php
+++ b/htdocs/compta/sociales/class/chargesociales.class.php
@@ -35,14 +35,14 @@ class ChargeSociales extends CommonObject
/**
* @var string ID to identify managed object
*/
- public $element='chargesociales';
+ public $element = 'chargesociales';
- public $table='chargesociales';
+ public $table = 'chargesociales';
/**
* @var string Name of table without prefix where object is stored
*/
- public $table_element='chargesociales';
+ public $table_element = 'chargesociales';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
@@ -175,7 +175,7 @@ class ChargeSociales extends CommonObject
}
else
{
- $this->error=$this->db->lasterror();
+ $this->error = $this->db->lasterror();
return -1;
}
}
@@ -187,10 +187,10 @@ class ChargeSociales extends CommonObject
*/
public function check()
{
- $newamount=price2num($this->amount, 'MT');
+ $newamount = price2num($this->amount, 'MT');
// Validation parametres
- if (! $newamount > 0 || empty($this->date_ech) || empty($this->periode))
+ if (!$newamount > 0 || empty($this->date_ech) || empty($this->periode))
{
return false;
}
@@ -208,55 +208,55 @@ class ChargeSociales extends CommonObject
public function create($user)
{
global $conf;
- $error=0;
+ $error = 0;
- $now=dol_now();
+ $now = dol_now();
// Nettoyage parametres
- $newamount=price2num($this->amount, 'MT');
+ $newamount = price2num($this->amount, 'MT');
if (!$this->check()) {
- $this->error="ErrorBadParameter";
+ $this->error = "ErrorBadParameter";
return -2;
}
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, date_creation)";
- $sql.= " VALUES (".$this->type;
- $sql.= ", ".($this->fk_account>0 ? $this->fk_account:'NULL');
- $sql.= ", ".($this->mode_reglement_id>0 ? $this->mode_reglement_id:"NULL");
- $sql.= ", '".$this->db->escape($this->label?$this->label:$this->lib)."'";
- $sql.= ", '".$this->db->idate($this->date_ech)."'";
- $sql.= ", '".$this->db->idate($this->periode)."'";
- $sql.= ", '".price2num($newamount)."'";
- $sql.= ", ".($this->fk_project>0?$this->fk_project:'NULL');
- $sql.= ", ".$conf->entity;
- $sql.= ", ".$user->id;
- $sql.= ", '".$this->db->idate($now)."'";
- $sql.= ")";
+ $sql .= " VALUES (".$this->type;
+ $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL');
+ $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "NULL");
+ $sql .= ", '".$this->db->escape($this->label ? $this->label : $this->lib)."'";
+ $sql .= ", '".$this->db->idate($this->date_ech)."'";
+ $sql .= ", '".$this->db->idate($this->periode)."'";
+ $sql .= ", '".price2num($newamount)."'";
+ $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 'NULL');
+ $sql .= ", ".$conf->entity;
+ $sql .= ", ".$user->id;
+ $sql .= ", '".$this->db->idate($now)."'";
+ $sql .= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
- $resql=$this->db->query($sql);
+ $resql = $this->db->query($sql);
if ($resql) {
- $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales");
+ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales");
//dol_syslog("ChargesSociales::create this->id=".$this->id);
- $result=$this->call_trigger('SOCIALCONTRIBUTION_CREATE', $user);
+ $result = $this->call_trigger('SOCIALCONTRIBUTION_CREATE', $user);
if ($result < 0) $error++;
- if(empty($error)) {
+ if (empty($error)) {
$this->db->commit();
return $this->id;
}
else {
$this->db->rollback();
- return -1*$error;
+ return -1 * $error;
}
}
else
{
- $this->error=$this->db->error();
+ $this->error = $this->db->error();
$this->db->rollback();
return -1;
}
@@ -271,23 +271,23 @@ class ChargeSociales extends CommonObject
*/
public function delete($user)
{
- $error=0;
+ $error = 0;
$this->db->begin();
// Get bank transaction lines for this social contributions
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
- $account=new Account($this->db);
- $lines_url=$account->get_url('', $this->id, 'sc');
+ $account = new Account($this->db);
+ $lines_url = $account->get_url('', $this->id, 'sc');
// Delete bank urls
foreach ($lines_url as $line_url)
{
- if (! $error)
+ if (!$error)
{
- $accountline=new AccountLine($this->db);
+ $accountline = new AccountLine($this->db);
$accountline->fetch($line_url['fk_bank']);
- $result=$accountline->delete_urls($user);
+ $result = $accountline->delete_urls($user);
if ($result < 0)
{
$error++;
@@ -296,31 +296,31 @@ class ChargeSociales extends CommonObject
}
// Delete payments
- if (! $error)
+ if (!$error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge WHERE fk_charge=".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (! $resql)
+ $resql = $this->db->query($sql);
+ if (!$resql)
{
$error++;
- $this->error=$this->db->lasterror();
+ $this->error = $this->db->lasterror();
}
}
- if (! $error)
+ if (!$error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (! $resql)
+ $resql = $this->db->query($sql);
+ if (!$resql)
{
$error++;
- $this->error=$this->db->lasterror();
+ $this->error = $this->db->lasterror();
}
}
- if (! $error)
+ if (!$error)
{
$this->db->commit();
return 1;
@@ -342,31 +342,31 @@ class ChargeSociales extends CommonObject
*/
public function update($user, $notrigger = 0)
{
- $error=0;
+ $error = 0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales";
- $sql.= " SET libelle='".$this->db->escape($this->label?$this->label:$this->lib)."'";
- $sql.= ", date_ech='".$this->db->idate($this->date_ech)."'";
- $sql.= ", periode='".$this->db->idate($this->periode)."'";
- $sql.= ", amount='".price2num($this->amount, 'MT')."'";
- $sql.= ", fk_projet=".($this->fk_project>0?$this->db->escape($this->fk_project):"NULL");
- $sql.= ", fk_user_modif=".$user->id;
- $sql.= " WHERE rowid=".$this->id;
+ $sql .= " SET libelle='".$this->db->escape($this->label ? $this->label : $this->lib)."'";
+ $sql .= ", date_ech='".$this->db->idate($this->date_ech)."'";
+ $sql .= ", periode='".$this->db->idate($this->periode)."'";
+ $sql .= ", amount='".price2num($this->amount, 'MT')."'";
+ $sql .= ", fk_projet=".($this->fk_project > 0 ? $this->db->escape($this->fk_project) : "NULL");
+ $sql .= ", fk_user_modif=".$user->id;
+ $sql .= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
- $resql=$this->db->query($sql);
+ $resql = $this->db->query($sql);
- if (! $resql) {
- $error++; $this->errors[]="Error ".$this->db->lasterror();
+ if (!$resql) {
+ $error++; $this->errors[] = "Error ".$this->db->lasterror();
}
- if (! $error)
+ if (!$error)
{
- if (! $notrigger)
+ if (!$notrigger)
{
// Call trigger
- $result=$this->call_trigger('SOCIALCHARGES_MODIFY', $user);
+ $result = $this->call_trigger('SOCIALCHARGES_MODIFY', $user);
if ($result < 0) $error++;
// End call triggers
}
@@ -375,13 +375,13 @@ class ChargeSociales extends CommonObject
// Commit or rollback
if ($error)
{
- foreach($this->errors as $errmsg)
+ foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
+ $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
- return -1*$error;
+ return -1 * $error;
}
else
{
@@ -401,9 +401,9 @@ class ChargeSociales extends CommonObject
global $conf;
$sql = "SELECT SUM(f.amount) as amount";
- $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as f";
- $sql.= " WHERE f.entity = ".$conf->entity;
- $sql.= " AND paye = 0";
+ $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as f";
+ $sql .= " WHERE f.entity = ".$conf->entity;
+ $sql .= " AND paye = 0";
if ($year) {
$sql .= " AND f.datev >= '$y-01-01' AND f.datev <= '$y-12-31' ";
@@ -441,8 +441,8 @@ class ChargeSociales extends CommonObject
{
// phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET";
- $sql.= " paye = 1";
- $sql.= " WHERE rowid = ".$this->id;
+ $sql .= " paye = 1";
+ $sql .= " WHERE rowid = ".$this->id;
$return = $this->db->query($sql);
if ($return) return 1;
else return -1;
@@ -459,8 +459,8 @@ class ChargeSociales extends CommonObject
{
// phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET";
- $sql.= " paye = 0";
- $sql.= " WHERE rowid = ".$this->id;
+ $sql .= " paye = 0";
+ $sql .= " WHERE rowid = ".$this->id;
$return = $this->db->query($sql);
if ($return) return 1;
else return -1;
@@ -549,9 +549,9 @@ class ChargeSociales extends CommonObject
{
global $langs, $conf, $user, $form;
- if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
+ if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
- $result='';
+ $result = '';
$url = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$this->id;
@@ -607,20 +607,20 @@ class ChargeSociales extends CommonObject
*/
public function getSommePaiement()
{
- $table='paiementcharge';
- $field='fk_charge';
+ $table = 'paiementcharge';
+ $field = 'fk_charge';
$sql = 'SELECT sum(amount) as amount';
- $sql.= ' FROM '.MAIN_DB_PREFIX.$table;
- $sql.= ' WHERE '.$field.' = '.$this->id;
+ $sql .= ' FROM '.MAIN_DB_PREFIX.$table;
+ $sql .= ' WHERE '.$field.' = '.$this->id;
dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
- $resql=$this->db->query($sql);
+ $resql = $this->db->query($sql);
if ($resql) {
- $amount=0;
+ $amount = 0;
$obj = $this->db->fetch_object($resql);
- if ($obj) $amount=$obj->amount?$obj->amount:0;
+ if ($obj) $amount = $obj->amount ? $obj->amount : 0;
$this->db->free($resql);
return $amount;
@@ -640,12 +640,12 @@ class ChargeSociales extends CommonObject
public function info($id)
{
$sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,";
- $sql.= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid";
- $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as e";
- $sql.= " WHERE e.rowid = ".$id;
+ $sql .= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid";
+ $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as e";
+ $sql .= " WHERE e.rowid = ".$id;
dol_syslog(get_class($this)."::info", LOG_DEBUG);
- $result=$this->db->query($sql);
+ $result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
@@ -696,14 +696,14 @@ class ChargeSociales extends CommonObject
public function initAsSpecimen()
{
// Initialize parameters
- $this->id=0;
+ $this->id = 0;
$this->ref = 'SPECIMEN';
- $this->specimen=1;
+ $this->specimen = 1;
$this->paye = 0;
$this->date = dol_now();
- $this->date_ech=$this->date+3600*24*30;
- $this->periode=$this->date+3600*24*30;
- $this->amount=100;
+ $this->date_ech = $this->date + 3600 * 24 * 30;
+ $this->periode = $this->date + 3600 * 24 * 30;
+ $this->amount = 100;
$this->label = 'Social contribution label';
$this->type = 1;
$this->type_label = 'Type of social contribution';
diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php
index b8db7593ef8..45fe792c81a 100644
--- a/htdocs/core/actions_addupdatedelete.inc.php
+++ b/htdocs/core/actions_addupdatedelete.inc.php
@@ -78,54 +78,54 @@ if ($action == 'add' && ! empty($permissiontoadd))
}
}
- if (! $error)
+ if (!$error)
{
- $result=$object->create($user);
+ $result = $object->create($user);
if ($result > 0)
{
// Creation OK
$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
- $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
+ $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
header("Location: ".$urltogo);
exit;
}
else
{
// Creation KO
- if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
+ if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
- $action='create';
+ $action = 'create';
}
}
else
{
- $action='create';
+ $action = 'create';
}
}
// Action to update record
-if ($action == 'update' && ! empty($permissiontoadd))
+if ($action == 'update' && !empty($permissiontoadd))
{
foreach ($object->fields as $key => $val)
{
- if (! GETPOSTISSET($key)) continue; // The field was not submited to be edited
- if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
+ if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited
+ if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
// Set value to update
if (in_array($object->fields[$key]['type'], array('text', 'html'))) {
$value = GETPOST($key, 'none');
- } elseif ($object->fields[$key]['type']=='date') {
+ } elseif ($object->fields[$key]['type'] == 'date') {
$value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'));
- } elseif ($object->fields[$key]['type']=='datetime') {
+ } elseif ($object->fields[$key]['type'] == 'datetime') {
$value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'));
} elseif (in_array($object->fields[$key]['type'], array('price', 'real'))) {
$value = price2num(GETPOST($key));
} else {
$value = GETPOST($key, 'alpha');
}
- if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field
- if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field
+ if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field
+ if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field
- $object->$key=$value;
+ $object->$key = $value;
if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default']))
{
$error++;
@@ -133,28 +133,28 @@ if ($action == 'update' && ! empty($permissiontoadd))
}
}
- if (! $error)
+ if (!$error)
{
- $result=$object->update($user);
+ $result = $object->update($user);
if ($result > 0)
{
- $action='view';
+ $action = 'view';
}
else
{
// Creation KO
setEventMessages($object->error, $object->errors, 'errors');
- $action='edit';
+ $action = 'edit';
}
}
else
{
- $action='edit';
+ $action = 'edit';
}
}
// Action to update one extrafield
-if ($action == "update_extras" && ! empty($permissiontoadd))
+if ($action == "update_extras" && !empty($permissiontoadd))
{
$object->fetch(GETPOST('id', 'int'));
@@ -162,7 +162,7 @@ if ($action == "update_extras" && ! empty($permissiontoadd))
$attributekeylong = 'options_'.$attributekey;
$object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, ' alpha');
- $result = $object->insertExtraFields(empty($triggermodname)?'':$triggermodname, $user);
+ $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
if ($result > 0)
{
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
@@ -176,15 +176,15 @@ if ($action == "update_extras" && ! empty($permissiontoadd))
}
// Action to delete
-if ($action == 'confirm_delete' && ! empty($permissiontodelete))
+if ($action == 'confirm_delete' && !empty($permissiontodelete))
{
- if (! ($object->id > 0))
+ if (!($object->id > 0))
{
dol_print_error('', 'Error, object must be fetched before being deleted');
exit;
}
- $result=$object->delete($user);
+ $result = $object->delete($user);
if ($result > 0)
{
// Delete OK
@@ -194,13 +194,13 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete))
}
else
{
- if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
+ if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
}
}
// Remove a line
-if ($action == 'confirm_deleteline' && $confirm == 'yes' && ! empty($permissiontoadd))
+if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd))
{
$result = $object->deleteline($user, $lineid);
if ($result > 0)
@@ -216,7 +216,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && ! empty($permissiont
{
$newlang = $object->thirdparty->default_lang;
}
- if (! empty($newlang)) {
+ if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
@@ -248,11 +248,11 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd)
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
- if (! empty($newlang)) {
+ if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
- $model=$object->modelpdf;
+ $model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
@@ -277,11 +277,11 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd)
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
- if (! empty($newlang)) {
+ if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
- $model=$object->modelpdf;
+ $model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
@@ -320,11 +320,11 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd)
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
- if (! empty($newlang)) {
+ if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
- $model=$object->modelpdf;
+ $model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
@@ -337,30 +337,30 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd)
}
// Action clone object
-if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd))
+if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd))
{
- if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
+ if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers'))
{
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
}
else
{
- $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid.
+ $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid.
//$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
// ...
- $result=$objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
+ $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
if (is_object($result) || $result > 0)
{
$newid = 0;
if (is_object($result)) $newid = $result->id;
else $newid = $result;
- header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
+ header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
exit;
}
else
{
setEventMessages($objectutil->error, $objectutil->errors, 'errors');
- $action='';
+ $action = '';
}
}
}
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index 05cbcb0ca14..22ba7b66ec8 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -41,13 +41,13 @@ class CMailFile
public $sendmode;
public $sendsetup;
- public $subject; // Topic: Subject of email
- public $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to).
+ public $subject; // Topic: Subject of email
+ public $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to).
// Sender: Who send the email ("Sender" has sent emails on behalf of "From").
// Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain.
// Return-Path: Email where to send bounds.
- public $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined)
- public $errors_to; // Errors-To: Email where to send errors.
+ public $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined)
+ public $errors_to; // Errors-To: Email where to send errors.
public $addr_to;
public $addr_cc;
public $addr_bcc;
@@ -64,10 +64,10 @@ class CMailFile
/**
* @var string Error code (or message)
*/
- public $error='';
+ public $error = '';
- public $smtps; // Contains SMTPs object (if this method is used)
- public $phpmailer; // Contains PHPMailer object (if this method is used)
+ public $smtps; // Contains SMTPs object (if this method is used)
+ public $phpmailer; // Contains PHPMailer object (if this method is used)
/**
* @var string CSS
@@ -96,9 +96,9 @@ class CMailFile
// Image
public $html;
public $image_boundary;
- public $atleastoneimage=0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used).
- public $html_images=array();
- public $images_encoded=array();
+ public $atleastoneimage = 0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used).
+ public $html_images = array();
+ public $images_encoded = array();
public $image_types = array(
'gif' => 'image/gif',
'jpg' => 'image/jpeg',
@@ -162,28 +162,28 @@ class CMailFile
{
$this->sendmode = $conf->global->MAIN_MAIL_SENDMODE_EMAILING;
}
- if (empty($this->sendmode)) $this->sendmode=$conf->global->MAIN_MAIL_SENDMODE;
- if (empty($this->sendmode)) $this->sendmode='mail';
+ if (empty($this->sendmode)) $this->sendmode = $conf->global->MAIN_MAIL_SENDMODE;
+ if (empty($this->sendmode)) $this->sendmode = 'mail';
// We define end of line (RFC 821).
- $this->eol="\r\n";
+ $this->eol = "\r\n";
// We define end of line for header fields (RFC 822bis section 2.3 says header must contains \r\n).
- $this->eol2="\r\n";
- if (! empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA))
+ $this->eol2 = "\r\n";
+ if (!empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA))
{
- $this->eol="\n";
- $this->eol2="\n";
+ $this->eol = "\n";
+ $this->eol2 = "\n";
$moreinheader = str_replace("\r\n", "\n", $moreinheader);
}
// On defini mixed_boundary
- $this->mixed_boundary = "multipart_x." . time() . ".x_boundary";
+ $this->mixed_boundary = "multipart_x.".time().".x_boundary";
// On defini related_boundary
- $this->related_boundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3); // Force md5 hash (does not contains special chars)
+ $this->related_boundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3); // Force md5 hash (does not contains special chars)
// On defini alternative_boundary
- $this->alternative_boundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); // Force md5 hash (does not contains special chars)
+ $this->alternative_boundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); // Force md5 hash (does not contains special chars)
dol_syslog("CMailFile::CMailfile: sendmode=".$this->sendmode." charset=".$conf->file->character_set_client." from=$from, to=$to, addr_cc=$addr_cc, addr_bcc=$addr_bcc, errors_to=$errors_to, trackid=$trackid sendcontext=$sendcontext", LOG_DEBUG);
dol_syslog("CMailFile::CMailfile: subject=".$subject.", deliveryreceipt=".$deliveryreceipt.", msgishtml=".$msgishtml, LOG_DEBUG);
@@ -191,13 +191,13 @@ class CMailFile
if (empty($subject))
{
dol_syslog("CMailFile::CMailfile: Try to send an email with empty subject");
- $this->error='ErrorSubjectIsRequired';
+ $this->error = 'ErrorSubjectIsRequired';
return;
}
if (empty($msg))
{
dol_syslog("CMailFile::CMailfile: Try to send an email with empty body");
- $msg='.'; // Avoid empty message (with empty message conten show a multipart structure)
+ $msg = '.'; // Avoid empty message (with empty message conten show a multipart structure)
}
// Detect if message is HTML (use fast method)
@@ -214,21 +214,21 @@ class CMailFile
global $dolibarr_main_url_root;
// Define $urlwithroot
- $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
- $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
+ $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
+ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// Replace relative /viewimage to absolute path
$msg = preg_replace('/src="'.preg_quote(DOL_URL_ROOT, '/').'\/viewimage\.php/ims', 'src="'.$urlwithroot.'/viewimage.php', $msg, -1, $nbrep);
- if (! empty($conf->global->MAIN_MAIL_FORCE_CONTENT_TYPE_TO_HTML)) $this->msgishtml=1; // To force to send everything with content type html.
+ if (!empty($conf->global->MAIN_MAIL_FORCE_CONTENT_TYPE_TO_HTML)) $this->msgishtml = 1; // To force to send everything with content type html.
// Detect images
if ($this->msgishtml)
{
$this->html = $msg;
- if (! empty($conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS))
+ if (!empty($conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS))
{
$findimg = $this->findHtmlImages($dolibarr_main_data_root.'/medias');
}
@@ -240,7 +240,7 @@ class CMailFile
{
if ($this->html_images[$i])
{
- $this->atleastoneimage=1;
+ $this->atleastoneimage = 1;
dol_syslog("CMailFile::CMailfile: html_images[$i]['name']=".$this->html_images[$i]['name'], LOG_DEBUG);
}
}
@@ -254,14 +254,14 @@ class CMailFile
{
if ($filename_list[$i])
{
- $this->atleastonefile=1;
+ $this->atleastonefile = 1;
dol_syslog("CMailFile::CMailfile: filename_list[$i]=".$filename_list[$i].", mimetype_list[$i]=".$mimetype_list[$i]." mimefilename_list[$i]=".$mimefilename_list[$i], LOG_DEBUG);
}
}
}
// Add autocopy to (Note: Adding bcc for specific modules are also done from pages)
- if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc.=($addr_bcc?', ':'').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
+ if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
// Action according to choosed sending method
if ($this->sendmode == 'mail')
@@ -276,17 +276,17 @@ class CMailFile
// Define smtp_headers
$smtp_headers = $this->write_smtpheaders();
- if (! empty($moreinheader)) $smtp_headers.=$moreinheader; // $moreinheader contains the \r\n
+ if (!empty($moreinheader)) $smtp_headers .= $moreinheader; // $moreinheader contains the \r\n
// Define mime_headers
$mime_headers = $this->write_mimeheaders($filename_list, $mimefilename_list);
- if (! empty($this->html))
+ if (!empty($this->html))
{
if (!empty($css))
{
$this->css = $css;
- $this->buildCSS(); // Build a css style (mode = all) into this->styleCSS and this->bodyCSS
+ $this->buildCSS(); // Build a css style (mode = all) into this->styleCSS and this->bodyCSS
}
$msg = $this->html;
@@ -302,15 +302,15 @@ class CMailFile
}
// We now define $this->headers and $this->message
- $this->headers = $smtp_headers . $mime_headers;
+ $this->headers = $smtp_headers.$mime_headers;
// On nettoie le header pour qu'il ne se termine pas par un retour chariot.
// This avoid also empty lines at end that can be interpreted as mail injection by email servers.
$this->headers = preg_replace("/([\r\n]+)$/i", "", $this->headers);
//$this->message = $this->eol.'This is a message with multiple parts in MIME format.'.$this->eol;
$this->message = 'This is a message with multiple parts in MIME format.'.$this->eol;
- $this->message.= $text_body . $files_encoded;
- $this->message.= "--" . $this->mixed_boundary . "--" . $this->eol;
+ $this->message .= $text_body.$files_encoded;
+ $this->message .= "--".$this->mixed_boundary."--".$this->eol;
}
elseif ($this->sendmode == 'smtps')
{
@@ -327,9 +327,9 @@ class CMailFile
$smtps->setTrackId($trackid);
$smtps->setReplyTo($this->getValidAddress($replyto, 0, 1));
- if (! empty($moreinheader)) $smtps->setMoreInHeader($moreinheader);
+ if (!empty($moreinheader)) $smtps->setMoreInHeader($moreinheader);
- if (! empty($this->html))
+ if (!empty($this->html))
{
if (!empty($css))
{
@@ -355,7 +355,7 @@ class CMailFile
{
foreach ($filename_list as $i => $val)
{
- $content=file_get_contents($filename_list[$i]);
+ $content = file_get_contents($filename_list[$i]);
$smtps->setAttachment($content, $mimefilename_list[$i], $mimetype_list[$i]);
}
}
@@ -365,7 +365,7 @@ class CMailFile
$smtps->setErrorsTo($errors_to);
$smtps->setDeliveryReceipt($deliveryreceipt);
- $this->smtps=$smtps;
+ $this->smtps = $smtps;
}
elseif ($this->sendmode == 'swiftmailer')
{
@@ -385,8 +385,8 @@ class CMailFile
//$this->message = new Swift_SignedMessage();
// Adding a trackid header to a message
$headers = $this->message->getHeaders();
- $headers->addTextHeader('X-Dolibarr-TRACKID', $trackid . '@' . $host);
- $headerID = time() . '.swiftmailer-dolibarr-' . $trackid . '@' . $host;
+ $headers->addTextHeader('X-Dolibarr-TRACKID', $trackid.'@'.$host);
+ $headerID = time().'.swiftmailer-dolibarr-'.$trackid.'@'.$host;
$msgid = $headers->get('Message-ID');
$msgid->setId($headerID);
$headers->addIdHeader('References', $headerID);
@@ -396,12 +396,12 @@ class CMailFile
try {
$result = $this->message->setSubject($subject);
} catch (Exception $e) {
- $this->errors[] = $e->getMessage();
+ $this->errors[] = $e->getMessage();
}
// Set the From address with an associative array
//$this->message->setFrom(array('john@doe.com' => 'John Doe'));
- if (! empty($from)) {
+ if (!empty($from)) {
try {
$result = $this->message->setFrom($this->getArrayAddress($from));
} catch (Exception $e) {
@@ -410,7 +410,7 @@ class CMailFile
}
// Set the To addresses with an associative array
- if (! empty($to)) {
+ if (!empty($to)) {
try {
$result = $this->message->setTo($this->getArrayAddress($to));
} catch (Exception $e) {
@@ -418,7 +418,7 @@ class CMailFile
}
}
- if (! empty($replyto)) {
+ if (!empty($replyto)) {
try {
$result = $this->message->SetReplyTo($this->getArrayAddress($replyto));
} catch (Exception $e) {
@@ -429,10 +429,10 @@ class CMailFile
try {
$result = $this->message->setCharSet($conf->file->character_set_client);
} catch (Exception $e) {
- $this->errors[] = $e->getMessage();
+ $this->errors[] = $e->getMessage();
}
- if (! empty($this->html)) {
+ if (!empty($this->html)) {
if (!empty($css)) {
$this->css = $css;
$this->buildCSS();
@@ -474,8 +474,8 @@ class CMailFile
}
}
- if (! empty($addr_cc)) $this->message->setCc($this->getArrayAddress($addr_cc));
- if (! empty($addr_bcc)) $this->message->setBcc($this->getArrayAddress($addr_bcc));
+ if (!empty($addr_cc)) $this->message->setCc($this->getArrayAddress($addr_cc));
+ if (!empty($addr_bcc)) $this->message->setBcc($this->getArrayAddress($addr_bcc));
//if (! empty($errors_to)) $this->message->setErrorsTo($this->getArrayAddress($errors_to);
if (isset($deliveryreceipt) && $deliveryreceipt == 1) $this->message->setReadReceiptTo($this->getArrayAddress($from));
}
@@ -495,25 +495,25 @@ class CMailFile
*/
public function sendfile()
{
- global $conf,$db,$langs;
+ global $conf, $db, $langs;
- $errorlevel=error_reporting();
+ $errorlevel = error_reporting();
//error_reporting($errorlevel ^ E_WARNING); // Desactive warnings
- $res=false;
+ $res = false;
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS) || !empty($conf->global->MAIN_MAIL_FORCE_SENDTO))
{
- require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
$hookmanager->initHooks(array('mail'));
- $parameters=array(); $action='';
+ $parameters = array(); $action = '';
$reshook = $hookmanager->executeHooks('sendMail', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
- $this->error = "Error in hook maildao sendMail " . $reshook;
- dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_ERR);
+ $this->error = "Error in hook maildao sendMail ".$reshook;
+ dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
return $reshook;
}
@@ -523,23 +523,23 @@ class CMailFile
}
$sendingmode = $this->sendmode;
- if ($this->context == 'emailing' && ! empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail')
+ if ($this->context == 'emailing' && !empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail')
{
// List of sending methods
- $listofmethods=array();
- $listofmethods['mail']='PHP mail function';
+ $listofmethods = array();
+ $listofmethods['mail'] = 'PHP mail function';
//$listofmethods['simplemail']='Simplemail class';
- $listofmethods['smtps']='SMTP/SMTPS socket library';
+ $listofmethods['smtps'] = 'SMTP/SMTPS socket library';
// EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent.
// You ensure that every user is using its own SMTP server when using the mass emailing module.
- $linktoadminemailbefore='';
- $linktoadminemailend=' ';
+ $linktoadminemailbefore = '';
+ $linktoadminemailend = ' ';
$this->error = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]);
$this->errors[] = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]);
$this->error .= ' '.$langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']);
$this->errors[] = $langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']);
- if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS))
+ if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS))
{
$this->error .= ' '.$langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS);
$this->errors[] = $langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS);
@@ -548,52 +548,52 @@ class CMailFile
}
// Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL
- if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL=10;
+ if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL = 10;
$tmparray1 = explode(',', $this->addr_to);
if (count($tmparray1) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL)
{
$this->error = 'Too much recipients in to:';
- dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING);
+ dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_WARNING);
return false;
}
- if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL=10;
+ if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL = 10;
$tmparray2 = explode(',', $this->addr_cc);
if (count($tmparray2) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL)
{
$this->error = 'Too much recipients in cc:';
- dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING);
+ dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_WARNING);
return false;
}
- if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL=10;
+ if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL = 10;
$tmparray3 = explode(',', $this->addr_bcc);
if (count($tmparray3) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL)
{
$this->error = 'Too much recipients in bcc:';
- dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING);
+ dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_WARNING);
return false;
}
- if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL=10;
- if ((count($tmparray1)+count($tmparray2)+count($tmparray3)) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)
+ if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL = 10;
+ if ((count($tmparray1) + count($tmparray2) + count($tmparray3)) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)
{
$this->error = 'Too much recipients in to:, cc:, bcc:';
- dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING);
+ dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_WARNING);
return false;
}
- $keyforsmtpserver='MAIN_MAIL_SMTP_SERVER';
- $keyforsmtpport ='MAIN_MAIL_SMTP_PORT';
- $keyforsmtpid ='MAIN_MAIL_SMTPS_ID';
- $keyforsmtppw ='MAIN_MAIL_SMTPS_PW';
- $keyfortls ='MAIN_MAIL_EMAIL_TLS';
- $keyforstarttls ='MAIN_MAIL_EMAIL_STARTTLS';
+ $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER';
+ $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT';
+ $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID';
+ $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW';
+ $keyfortls = 'MAIN_MAIL_EMAIL_TLS';
+ $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS';
if ($this->sendcontext == 'emailing' && !empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default')
{
- $keyforsmtpserver='MAIN_MAIL_SMTP_SERVER_EMAILING';
- $keyforsmtpport ='MAIN_MAIL_SMTP_PORT_EMAILING';
- $keyforsmtpid ='MAIN_MAIL_SMTPS_ID_EMAILING';
- $keyforsmtppw ='MAIN_MAIL_SMTPS_PW_EMAILING';
- $keyfortls ='MAIN_MAIL_EMAIL_TLS_EMAILING';
- $keyforstarttls ='MAIN_MAIL_EMAIL_STARTTLS_EMAILING';
+ $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_EMAILING';
+ $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_EMAILING';
+ $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_EMAILING';
+ $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_EMAILING';
+ $keyfortls = 'MAIN_MAIL_EMAIL_TLS_EMAILING';
+ $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_EMAILING';
}
if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO))
@@ -620,64 +620,64 @@ class CMailFile
}
// Force parameters
- if (! empty($conf->global->$keyforsmtpserver)) ini_set('SMTP', $conf->global->$keyforsmtpserver);
- if (! empty($conf->global->$keyforsmtpport)) ini_set('smtp_port', $conf->global->$keyforsmtpport);
+ if (!empty($conf->global->$keyforsmtpserver)) ini_set('SMTP', $conf->global->$keyforsmtpserver);
+ if (!empty($conf->global->$keyforsmtpport)) ini_set('smtp_port', $conf->global->$keyforsmtpport);
- $res=true;
- if ($res && ! $this->subject)
+ $res = true;
+ if ($res && !$this->subject)
{
- $this->error="Failed to send mail with php mail to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port')." Subject is empty";
+ $this->error = "Failed to send mail with php mail to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port')." Subject is empty";
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
- $res=false;
+ $res = false;
}
- $dest=$this->getValidAddress($this->addr_to, 2);
- if ($res && ! $dest)
+ $dest = $this->getValidAddress($this->addr_to, 2);
+ if ($res && !$dest)
{
- $this->error="Failed to send mail with php mail to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port')." Recipient address '$dest' invalid";
+ $this->error = "Failed to send mail with php mail to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port')." Recipient address '$dest' invalid";
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
- $res=false;
+ $res = false;
}
if ($res)
{
- $additionnalparam = ''; // By default
- if (! empty($conf->global->MAIN_MAIL_ALLOW_SENDMAIL_F))
+ $additionnalparam = ''; // By default
+ if (!empty($conf->global->MAIN_MAIL_ALLOW_SENDMAIL_F))
{
// le "Return-Path" (retour des messages bounced) dans les header ne fonctionne pas avec tous les MTA
// Le forcage de la valeur grace à l'option -f de sendmail est donc possible si la constante MAIN_MAIL_ALLOW_SENDMAIL_F est definie.
// Having this variable defined may create problems with some sendmail (option -f refused)
// Having this variable not defined may create problems with some other sendmail (option -f required)
- $additionnalparam .= ($additionnalparam?' ':'').(! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '-f' . $this->getValidAddress($conf->global->MAIN_MAIL_ERRORS_TO, 2) : ($this->addr_from != '' ? '-f' . $this->getValidAddress($this->addr_from, 2) : '') );
+ $additionnalparam .= ($additionnalparam ? ' ' : '').(!empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '-f'.$this->getValidAddress($conf->global->MAIN_MAIL_ERRORS_TO, 2) : ($this->addr_from != '' ? '-f'.$this->getValidAddress($this->addr_from, 2) : ''));
}
- if (! empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_BA)) // To force usage of -ba option. This option tells sendmail to read From: or Sender: to setup sender
+ if (!empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_BA)) // To force usage of -ba option. This option tells sendmail to read From: or Sender: to setup sender
{
- $additionnalparam .= ($additionnalparam?' ':'').'-ba';
+ $additionnalparam .= ($additionnalparam ? ' ' : '').'-ba';
}
- if (! empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_ADDPARAM)) $additionnalparam .= ($additionnalparam?' ':'').'-U '.$additionnalparam; // Use -U to add additionnal params
+ if (!empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_ADDPARAM)) $additionnalparam .= ($additionnalparam ? ' ' : '').'-U '.$additionnalparam; // Use -U to add additionnal params
dol_syslog("CMailFile::sendfile: mail start HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port').", additionnal_parameters=".$additionnalparam, LOG_DEBUG);
- $this->message=stripslashes($this->message);
+ $this->message = stripslashes($this->message);
- if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail();
+ if (!empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail();
- if (! empty($additionnalparam)) $res = mail($dest, $this->encodetorfc2822($this->subject), $this->message, $this->headers, $additionnalparam);
+ if (!empty($additionnalparam)) $res = mail($dest, $this->encodetorfc2822($this->subject), $this->message, $this->headers, $additionnalparam);
else $res = mail($dest, $this->encodetorfc2822($this->subject), $this->message, $this->headers);
- if (! $res)
+ if (!$res)
{
$langs->load("errors");
- $this->error="Failed to send mail with php mail";
- $linuxlike=1;
- if (preg_match('/^win/i', PHP_OS)) $linuxlike=0;
- if (preg_match('/^mac/i', PHP_OS)) $linuxlike=0;
- if (! $linuxlike)
+ $this->error = "Failed to send mail with php mail";
+ $linuxlike = 1;
+ if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0;
+ if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0;
+ if (!$linuxlike)
{
- $this->error.=" to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port'); // This values are value used only for non linuxlike systems
+ $this->error .= " to HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port'); // This values are value used only for non linuxlike systems
}
- $this->error.=". ";
- $this->error.=$langs->trans("ErrorPhpMailDelivery");
+ $this->error .= ". ";
+ $this->error .= $langs->trans("ErrorPhpMailDelivery");
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
}
else
@@ -692,86 +692,86 @@ class CMailFile
}
// Restore parameters
- if (! empty($conf->global->$keyforsmtpserver)) ini_restore('SMTP');
- if (! empty($conf->global->$keyforsmtpport)) ini_restore('smtp_port');
+ if (!empty($conf->global->$keyforsmtpserver)) ini_restore('SMTP');
+ if (!empty($conf->global->$keyforsmtpport)) ini_restore('smtp_port');
}
elseif ($this->sendmode == 'smtps')
{
- if (! is_object($this->smtps))
+ if (!is_object($this->smtps))
{
- $this->error="Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." Constructor of object CMailFile was not initialized without errors.";
+ $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." Constructor of object CMailFile was not initialized without errors.";
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
return false;
}
// Use SMTPS library
// ------------------------------------------
- $this->smtps->setTransportType(0); // Only this method is coded in SMTPs library
+ $this->smtps->setTransportType(0); // Only this method is coded in SMTPs library
// Clean parameters
- if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver=ini_get('SMTP');
- if (empty($conf->global->$keyforsmtpport)) $conf->global->$keyforsmtpport=ini_get('smtp_port');
+ if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver = ini_get('SMTP');
+ if (empty($conf->global->$keyforsmtpport)) $conf->global->$keyforsmtpport = ini_get('smtp_port');
// If we use SSL/TLS
- $server=$conf->global->$keyforsmtpserver;
- $secure='';
- if (! empty($conf->global->$keyfortls) && function_exists('openssl_open')) $secure='ssl';
- if (! empty($conf->global->$keyforstarttls) && function_exists('openssl_open')) $secure='tls';
- $server=($secure?$secure.'://':'').$server;
+ $server = $conf->global->$keyforsmtpserver;
+ $secure = '';
+ if (!empty($conf->global->$keyfortls) && function_exists('openssl_open')) $secure = 'ssl';
+ if (!empty($conf->global->$keyforstarttls) && function_exists('openssl_open')) $secure = 'tls';
+ $server = ($secure ? $secure.'://' : '').$server;
- $port=$conf->global->$keyforsmtpport;
+ $port = $conf->global->$keyforsmtpport;
$this->smtps->setHost($server);
$this->smtps->setPort($port); // 25, 465...;
- $loginid=''; $loginpass='';
- if (! empty($conf->global->$keyforsmtpid))
+ $loginid = ''; $loginpass = '';
+ if (!empty($conf->global->$keyforsmtpid))
{
$loginid = $conf->global->$keyforsmtpid;
$this->smtps->setID($loginid);
}
- if (! empty($conf->global->$keyforsmtppw))
+ if (!empty($conf->global->$keyforsmtppw))
{
$loginpass = $conf->global->$keyforsmtppw;
$this->smtps->setPW($loginpass);
}
- $res=true;
- $from=$this->smtps->getFrom('org');
- if ($res && ! $from)
+ $res = true;
+ $from = $this->smtps->getFrom('org');
+ if ($res && !$from)
{
- $this->error="Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." Sender address '$from' invalid";
+ $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." Sender address '$from' invalid";
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
- $res=false;
+ $res = false;
}
- $dest=$this->smtps->getTo();
- if ($res && ! $dest)
+ $dest = $this->smtps->getTo();
+ if ($res && !$dest)
{
- $this->error="Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." Recipient address '$dest' invalid";
+ $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." Recipient address '$dest' invalid";
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
- $res=false;
+ $res = false;
}
if ($res)
{
- if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->smtps->setDebug(true);
+ if (!empty($conf->global->MAIN_MAIL_DEBUG)) $this->smtps->setDebug(true);
- $result=$this->smtps->sendMsg();
+ $result = $this->smtps->sendMsg();
//print $result;
- if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail();
+ if (!empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail();
- $result=$this->smtps->getErrors();
+ $result = $this->smtps->getErrors();
if (empty($this->error) && empty($result))
{
dol_syslog("CMailFile::sendfile: mail end success", LOG_DEBUG);
- $res=true;
+ $res = true;
}
else
{
- if (empty($this->error)) $this->error=$result;
+ if (empty($this->error)) $this->error = $result;
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
- $res=false;
+ $res = false;
}
}
}
@@ -782,19 +782,19 @@ class CMailFile
require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php';
// Clean parameters
- if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver=ini_get('SMTP');
- if (empty($conf->global->$keyforsmtpport)) $conf->global->$keyforsmtpport=ini_get('smtp_port');
+ if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver = ini_get('SMTP');
+ if (empty($conf->global->$keyforsmtpport)) $conf->global->$keyforsmtpport = ini_get('smtp_port');
// If we use SSL/TLS
$server = $conf->global->$keyforsmtpserver;
$secure = '';
- if (! empty($conf->global->$keyfortls) && function_exists('openssl_open')) $secure='ssl';
- if (! empty($conf->global->$keyforstarttls) && function_exists('openssl_open')) $secure='tls';
+ if (!empty($conf->global->$keyfortls) && function_exists('openssl_open')) $secure = 'ssl';
+ if (!empty($conf->global->$keyforstarttls) && function_exists('openssl_open')) $secure = 'tls';
$this->transport = new Swift_SmtpTransport($server, $conf->global->$keyforsmtpport, $secure);
- if (! empty($conf->global->$keyforsmtpid)) $this->transport->setUsername($conf->global->$keyforsmtpid);
- if (! empty($conf->global->$keyforsmtppw)) $this->transport->setPassword($conf->global->$keyforsmtppw);
+ if (!empty($conf->global->$keyforsmtpid)) $this->transport->setUsername($conf->global->$keyforsmtpid);
+ if (!empty($conf->global->$keyforsmtppw)) $this->transport->setPassword($conf->global->$keyforsmtppw);
//$smtps->_msgReplyTo = 'reply@web.com';
// Create the Mailer using your created Transport
@@ -809,7 +809,7 @@ class CMailFile
$this->message->attachSigner($signer->ignoreHeader('Return-Path'));
}
- if (! empty($conf->global->MAIN_MAIL_DEBUG)) {
+ if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
// To use the ArrayLogger
$this->logger = new Swift_Plugins_Loggers_ArrayLogger();
// Or to use the Echo Logger
@@ -820,14 +820,14 @@ class CMailFile
try {
$result = $this->mailer->send($this->message);
} catch (Exception $e) {
- $this->error = $e->getMessage();
+ $this->error = $e->getMessage();
}
- if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail();
+ if (!empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail();
$res = true;
- if (! empty($this->error) || ! $result) {
+ if (!empty($this->error) || !$result) {
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
- $res=false;
+ $res = false;
}
else
{
@@ -842,23 +842,23 @@ class CMailFile
return 'Bad value for sendmode';
}
- $parameters=array(); $action='';
+ $parameters = array(); $action = '';
$reshook = $hookmanager->executeHooks('sendMailAfter', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
- $this->error = "Error in hook maildao sendMailAfter " . $reshook;
- dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_ERR);
+ $this->error = "Error in hook maildao sendMailAfter ".$reshook;
+ dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
return $reshook;
}
}
else
{
- $this->error='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
+ $this->error = 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
dol_syslog("CMailFile::sendfile: ".$this->error, LOG_WARNING);
}
- error_reporting($errorlevel); // Reactive niveau erreur origine
+ error_reporting($errorlevel); // Reactive niveau erreur origine
return $res;
}
@@ -885,17 +885,17 @@ class CMailFile
private function _encode_file($sourcefile)
{
// phpcs:enable
- $newsourcefile=dol_osencode($sourcefile);
+ $newsourcefile = dol_osencode($sourcefile);
if (is_readable($newsourcefile))
{
- $contents = file_get_contents($newsourcefile); // Need PHP 4.3
- $encoded = chunk_split(base64_encode($contents), 76, $this->eol); // 76 max is defined into http://tools.ietf.org/html/rfc2047
+ $contents = file_get_contents($newsourcefile); // Need PHP 4.3
+ $encoded = chunk_split(base64_encode($contents), 76, $this->eol); // 76 max is defined into http://tools.ietf.org/html/rfc2047
return $encoded;
}
else
{
- $this->error="Error: Can't read file '".$sourcefile."' into _encode_file";
+ $this->error = "Error: Can't read file '".$sourcefile."' into _encode_file";
dol_syslog("CMailFile::encode_file: ".$this->error, LOG_ERR);
return -1;
}
@@ -913,30 +913,30 @@ class CMailFile
public function dump_mail()
{
// phpcs:enable
- global $conf,$dolibarr_main_data_root;
+ global $conf, $dolibarr_main_data_root;
if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir
{
- $outputfile=$dolibarr_main_data_root."/dolibarr_mail.log";
+ $outputfile = $dolibarr_main_data_root."/dolibarr_mail.log";
$fp = fopen($outputfile, "w");
if ($this->sendmode == 'mail')
{
fputs($fp, $this->headers);
- fputs($fp, $this->eol); // This eol is added by the mail function, so we add it in log
+ fputs($fp, $this->eol); // This eol is added by the mail function, so we add it in log
fputs($fp, $this->message);
}
elseif ($this->sendmode == 'smtps')
{
- fputs($fp, $this->smtps->log); // this->smtps->log is filled only if MAIN_MAIL_DEBUG was set to on
+ fputs($fp, $this->smtps->log); // this->smtps->log is filled only if MAIN_MAIL_DEBUG was set to on
}
elseif ($this->sendmode == 'swiftmailer')
{
- fputs($fp, $this->logger->dump()); // this->logger is filled only if MAIN_MAIL_DEBUG was set to on
+ fputs($fp, $this->logger->dump()); // this->logger is filled only if MAIN_MAIL_DEBUG was set to on
}
fclose($fp);
- if (! empty($conf->global->MAIN_UMASK))
+ if (!empty($conf->global->MAIN_UMASK))
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
}
}
@@ -953,12 +953,12 @@ class CMailFile
if (!preg_match('/^[\s\t]* ";
- if (!empty($this->styleCSS)) $out.= $this->styleCSS;
- $out.= "bodyCSS)) $out.= $this->bodyCSS;
- $out.= ">";
- $out.= $msg;
- $out.= "";
+ if (!empty($this->styleCSS)) $out .= $this->styleCSS;
+ $out .= "bodyCSS)) $out .= $this->bodyCSS;
+ $out .= ">";
+ $out .= $msg;
+ $out .= "