From 87585c0f2a040c6cc26545d22619c033dda6b707 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Wed, 13 Nov 2019 17:32:11 +0000 Subject: [PATCH 1/3] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/adherents/card.php | 634 +++---- htdocs/core/actions_addupdatedelete.inc.php | 78 +- htdocs/core/class/CMailFile.class.php | 612 +++---- htdocs/expensereport/card.php | 708 ++++---- htdocs/install/check.php | 172 +- .../template/class/myobject.class.php | 144 +- htdocs/product/stock/productlot_card.php | 124 +- htdocs/projet/class/task.class.php | 1134 ++++++------- htdocs/reception/class/reception.class.php | 762 ++++----- htdocs/societe/card.php | 798 ++++----- htdocs/societe/class/societe.class.php | 1464 ++++++++--------- htdocs/societe/paymentmodes.php | 540 +++--- 12 files changed, 3585 insertions(+), 3585 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 417d4cd2c99c0..2a8177df6f227 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -43,19 +43,19 @@ 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")); - -$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)) +$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'); + +if (!empty($conf->mailmanspip->enabled)) { include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; @@ -74,9 +74,9 @@ // 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 @@ } // 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 @@ $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 @@ * 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 (! $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 @@ { // 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 @@ { // 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 ($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 @@ } } // Create new object - if ($result > 0 && ! $error) + if ($result > 0 && !$error) { $object->oldcopy = clone $object; @@ -291,7 +291,7 @@ $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 @@ $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 @@ //$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 ($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 (@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 @@ } 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 @@ } } - $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 @@ 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 @@ $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 @@ //$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 @@ $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 @@ $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 ($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 @@ } 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 @@ $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 (! $error) + if (!$error) { $db->commit(); } @@ -708,7 +708,7 @@ { $db->rollback(); } - $action=''; + $action = ''; } if ($user->rights->adherent->supprimer && $action == 'confirm_resign') @@ -720,30 +720,30 @@ $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 @@ $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 @@ } 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 @@ // 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 ($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 @@ // 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 @@ $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 (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 @@ /* 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 @@ function initfieldrequired() // 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 @@ function initfieldrequired() // 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 @@ function initfieldrequired() $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 @@ function initfieldrequired() 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 @@ function initfieldrequired() } // 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 @@ function initfieldrequired() 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 @@ function initfieldrequired() // 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 @@ function initfieldrequired() print '
'; print ''; print '  '; - if (! empty($backtopage)) + if (!empty($backtopage)) { print ''; } else { - print ''; + print ''; } print '
'; @@ -1108,11 +1108,11 @@ function initfieldrequired() * ********************************************/ - $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 @@ function initfieldrequired() $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 @@ function initfieldrequired() { 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 @@ function initfieldrequired() // 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 @@ function initfieldrequired() 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 @@ function initfieldrequired() 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 @@ function initfieldrequired() 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 @@ function initfieldrequired() // 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 @@ function initfieldrequired() } // 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 @@ function initfieldrequired() /* */ /* ************************************************************************** */ - $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 @@ function initfieldrequired() // 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 @@ function initfieldrequired() // 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 @@ function initfieldrequired() $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 @@ function initfieldrequired() $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 @@ function initfieldrequired() 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 @@ function initfieldrequired() 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 @@ function initfieldrequired() { 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 @@ function initfieldrequired() print ''; // Third party Dolibarr - if (! empty($conf->societe->enabled)) + if (!empty($conf->societe->enabled)) { print ''; $editenable = $user->rights->adherent->creer; @@ -1686,7 +1686,7 @@ function initfieldrequired() print ''; if ($action == 'editthirdparty') { - $htmlname='socid'; + $htmlname = 'socid'; print '
'; print ''; print ''; @@ -1702,8 +1702,8 @@ function initfieldrequired() { 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 @@ -1749,16 +1749,16 @@ function initfieldrequired() print ''.$langs->trans("Public").''.yn($object->public).''; // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print '' . $langs->trans("Categories") . ''; + print ''.$langs->trans("Categories").''; print ''; print $form->showCategories($object->id, 'member', 1); print ''; } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print "\n"; @@ -1780,7 +1780,7 @@ function initfieldrequired() { // Send if ($object->statut == 1) { - print ''; + print ''; } // Send card by email @@ -1853,7 +1853,7 @@ function initfieldrequired() } // Create third party - if (! empty($conf->societe->enabled) && ! $object->socid) + if (!empty($conf->societe->enabled) && !$object->socid) { if ($user->rights->societe->creer) { @@ -1867,7 +1867,7 @@ function initfieldrequired() } // Create user - if (! $user->socid && ! $object->user_id) + if (!$user->socid && !$object->user_id) { if ($user->rights->user->user->creer) { @@ -1891,7 +1891,7 @@ function initfieldrequired() } // Action SPIP - if (! empty($conf->mailmanspip->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) + if (!empty($conf->mailmanspip->enabled) && !empty($conf->global->ADHERENT_USE_SPIP)) { $isinspip = $mailmanspip->is_in_spip($object); @@ -1928,8 +1928,8 @@ function initfieldrequired() $filename = dol_sanitizeFileName($object->ref); //$filename = 'tmp_cards.php'; //$filedir = $conf->adherent->dir_output . '/' . get_exdir($object->id, 2, 0, 0, $object, 'member') . dol_sanitizeFileName($object->ref); - $filedir = $conf->adherent->dir_output . '/' . get_exdir(0, 0, 0, 0, $object, 'member'); - $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $object->id; + $filedir = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'member'); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id; $genallowed = $user->rights->adherent->lire; $delallowed = $user->rights->adherent->creer; @@ -1946,7 +1946,7 @@ function initfieldrequired() */ // Shon online payment link - $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); if ($useonlinepayment) { @@ -1961,11 +1961,11 @@ function initfieldrequired() $MAX = 10; $morehtmlright = ''; - $morehtmlright.= $langs->trans("SeeAll"); - $morehtmlright.= ''; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= ''; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', $MAX, '', $morehtmlright); @@ -1973,8 +1973,8 @@ function initfieldrequired() } // Presend form - $modelmail='member'; - $defaulttopic='CardContent'; + $modelmail = 'member'; + $defaulttopic = 'CardContent'; $diroutput = $conf->adherent->dir_output; $trackid = 'mem'.$object->id; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index b8db7593ef8da..45fe792c81aba 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -78,54 +78,54 @@ } } - 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 (! $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 @@ $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 @@ } // 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 @@ } 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 @@ { $newlang = $object->thirdparty->default_lang; } - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -248,11 +248,11 @@ $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 @@ $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 @@ $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 @@ } // 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 05cbcb0ca1452..22ba7b66ec856 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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() { $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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() 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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() 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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() { 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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() { 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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() // 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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() } // 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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() $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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() { 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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() $smtps->setErrorsTo($errors_to); $smtps->setDeliveryReceipt($deliveryreceipt); - $this->smtps=$smtps; + $this->smtps = $smtps; } elseif ($this->sendmode == 'swiftmailer') { @@ -385,8 +385,8 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() //$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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() 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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() } // 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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() } } - if (! empty($replyto)) { + if (!empty($replyto)) { try { $result = $this->message->SetReplyTo($this->getArrayAddress($replyto)); } catch (Exception $e) { @@ -429,10 +429,10 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() 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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() } } - 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 @@ public function __construct($subject, $to, $from, $msg, $filename_list = array() */ 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 @@ public function sendfile() } $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 @@ public function sendfile() } // 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 @@ public function sendfile() } // 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 @@ public function sendfile() } // 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 @@ public function sendfile() 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 @@ public function sendfile() $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 @@ public function sendfile() 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 @@ public function sendfile() 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 @@ public static function encodetorfc2822($stringtoencode) 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 @@ private function _encode_file($sourcefile) 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 @@ public function checkIfHTML($msg) if (!preg_match('/^[\s\t]*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 .= ""; } else { @@ -975,24 +975,24 @@ public function checkIfHTML($msg) */ public function buildCSS() { - if (! empty($this->css)) + if (!empty($this->css)) { // Style CSS $this->styleCSS = ''; + $this->styleCSS .= '}'; + $this->styleCSS .= ''; } } @@ -1013,48 +1013,48 @@ public function write_smtpheaders() // Sender //$out.= "Sender: ".getValidAddress($this->addr_from,2)).$this->eol2; - $out.= "From: ".$this->getValidAddress($this->addr_from, 3, 1).$this->eol2; - if (! empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_BA)) + $out .= "From: ".$this->getValidAddress($this->addr_from, 3, 1).$this->eol2; + if (!empty($conf->global->MAIN_MAIL_SENDMAIL_FORCE_BA)) { - $out.= "To: ".$this->getValidAddress($this->addr_to, 0, 1).$this->eol2; + $out .= "To: ".$this->getValidAddress($this->addr_to, 0, 1).$this->eol2; } // Return-Path is important because it is used by SPF. Some MTA does not read Return-Path from header but from command line. See option MAIN_MAIL_ALLOW_SENDMAIL_F for that. - $out.= "Return-Path: ".$this->getValidAddress($this->addr_from, 0, 1).$this->eol2; - if (isset($this->reply_to) && $this->reply_to) $out.= "Reply-To: ".$this->getValidAddress($this->reply_to, 2).$this->eol2; - if (isset($this->errors_to) && $this->errors_to) $out.= "Errors-To: ".$this->getValidAddress($this->errors_to, 2).$this->eol2; + $out .= "Return-Path: ".$this->getValidAddress($this->addr_from, 0, 1).$this->eol2; + if (isset($this->reply_to) && $this->reply_to) $out .= "Reply-To: ".$this->getValidAddress($this->reply_to, 2).$this->eol2; + if (isset($this->errors_to) && $this->errors_to) $out .= "Errors-To: ".$this->getValidAddress($this->errors_to, 2).$this->eol2; // Receiver - if (isset($this->addr_cc) && $this->addr_cc) $out.= "Cc: ".$this->getValidAddress($this->addr_cc, 2).$this->eol2; - if (isset($this->addr_bcc) && $this->addr_bcc) $out.= "Bcc: ".$this->getValidAddress($this->addr_bcc, 2).$this->eol2; // TODO Question: bcc must not be into header, only into SMTP command "RCPT TO". Does php mail support this ? + if (isset($this->addr_cc) && $this->addr_cc) $out .= "Cc: ".$this->getValidAddress($this->addr_cc, 2).$this->eol2; + if (isset($this->addr_bcc) && $this->addr_bcc) $out .= "Bcc: ".$this->getValidAddress($this->addr_bcc, 2).$this->eol2; // TODO Question: bcc must not be into header, only into SMTP command "RCPT TO". Does php mail support this ? // Delivery receipt - if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $out.= "Disposition-Notification-To: ".$this->getValidAddress($this->addr_from, 2).$this->eol2; + if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $out .= "Disposition-Notification-To: ".$this->getValidAddress($this->addr_from, 2).$this->eol2; //$out.= "X-Priority: 3".$this->eol2; - $out.= 'Date: ' . date("r") . $this->eol2; + $out .= 'Date: '.date("r").$this->eol2; $trackid = $this->trackid; if ($trackid) { // References is kept in response and Message-ID is returned into In-Reply-To: - $out.= 'Message-ID: <' . time() . '.phpmail-dolibarr-'. $trackid . '@' . $host . ">" . $this->eol2; // Uppercase seems replaced by phpmail - $out.= 'References: <' . time() . '.phpmail-dolibarr-'. $trackid . '@' . $host . ">" . $this->eol2; - $out.= 'X-Dolibarr-TRACKID: ' . $trackid . '@' . $host. $this->eol2; + $out .= 'Message-ID: <'.time().'.phpmail-dolibarr-'.$trackid.'@'.$host.">".$this->eol2; // Uppercase seems replaced by phpmail + $out .= 'References: <'.time().'.phpmail-dolibarr-'.$trackid.'@'.$host.">".$this->eol2; + $out .= 'X-Dolibarr-TRACKID: '.$trackid.'@'.$host.$this->eol2; } else { - $out.= 'Message-ID: <' . time() . '.phpmail@' . $host . ">" . $this->eol2; + $out .= 'Message-ID: <'.time().'.phpmail@'.$host.">".$this->eol2; } - if (! empty($_SERVER['REMOTE_ADDR'])) $out.= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. $this->eol2; - $out.= "X-Mailer: Dolibarr version " . DOL_VERSION ." (using php mail)".$this->eol2; - $out.= "Mime-Version: 1.0".$this->eol2; + if (!empty($_SERVER['REMOTE_ADDR'])) $out .= "X-RemoteAddr: ".$_SERVER['REMOTE_ADDR'].$this->eol2; + $out .= "X-Mailer: Dolibarr version ".DOL_VERSION." (using php mail)".$this->eol2; + $out .= "Mime-Version: 1.0".$this->eol2; //$out.= "From: ".$this->getValidAddress($this->addr_from,3,1).$this->eol; - $out.= "Content-Type: multipart/mixed;".$this->eol2." boundary=\"".$this->mixed_boundary."\"".$this->eol2; - $out.= "Content-Transfer-Encoding: 8bit".$this->eol2; // TODO Seems to be ignored. Header is 7bit once received. + $out .= "Content-Type: multipart/mixed;".$this->eol2." boundary=\"".$this->mixed_boundary."\"".$this->eol2; + $out .= "Content-Transfer-Encoding: 8bit".$this->eol2; // TODO Seems to be ignored. Header is 7bit once received. dol_syslog("CMailFile::write_smtpheaders smtp_header=\n".$out); return $out; @@ -1072,18 +1072,18 @@ public function write_smtpheaders() public function write_mimeheaders($filename_list, $mimefilename_list) { // phpcs:enable - $mimedone=0; + $mimedone = 0; $out = ""; if (is_array($filename_list)) { - $filename_list_size=count($filename_list); - for($i=0;$i < $filename_list_size;$i++) + $filename_list_size = count($filename_list); + for ($i = 0; $i < $filename_list_size; $i++) { if ($filename_list[$i]) { if ($mimefilename_list[$i]) $filename_list[$i] = $mimefilename_list[$i]; - $out.= "X-attachments: $filename_list[$i]".$this->eol2; + $out .= "X-attachments: $filename_list[$i]".$this->eol2; } } } @@ -1104,22 +1104,22 @@ public function write_body($msgtext) // phpcs:enable global $conf; - $out=''; + $out = ''; - $out.= "--" . $this->mixed_boundary . $this->eol; + $out .= "--".$this->mixed_boundary.$this->eol; if ($this->atleastoneimage) { - $out.= "Content-Type: multipart/alternative;".$this->eol." boundary=\"".$this->alternative_boundary."\"".$this->eol; - $out.= $this->eol; - $out.= "--" . $this->alternative_boundary . $this->eol; + $out .= "Content-Type: multipart/alternative;".$this->eol." boundary=\"".$this->alternative_boundary."\"".$this->eol; + $out .= $this->eol; + $out .= "--".$this->alternative_boundary.$this->eol; } // Make RFC821 Compliant, replace bare linefeeds - $strContent = preg_replace("/(?global->MAIN_FIX_FOR_BUGGED_MTA)) + $strContent = preg_replace("/(?global->MAIN_FIX_FOR_BUGGED_MTA)) { - $strContent = preg_replace("/\r\n/si", "\n", $strContent); // PCRE modifier /s means new lines are common chars + $strContent = preg_replace("/\r\n/si", "\n", $strContent); // PCRE modifier /s means new lines are common chars } $strContentAltText = ''; @@ -1128,7 +1128,7 @@ public function write_body($msgtext) // Similar code to forge a text from html is also in smtps.class.php $strContentAltText = preg_replace("/]*>/", " ", $strContent); $strContentAltText = html_entity_decode(strip_tags($strContentAltText)); - $strContentAltText = trim(wordwrap($strContentAltText, 75, empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)?"\r\n":"\n")); + $strContentAltText = trim(wordwrap($strContentAltText, 75, empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA) ? "\r\n" : "\n")); // Check if html header already in message, if not complete the message $strContent = $this->checkIfHTML($strContent); @@ -1137,57 +1137,57 @@ public function write_body($msgtext) // Make RFC2045 Compliant, split lines //$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content // TODO Encode main content into base64 and use the chunk_split, or quoted-printable - $strContent = rtrim(wordwrap($strContent, 75, empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)?"\r\n":"\n")); // TODO Using this method creates unexpected line break on text/plain content. + $strContent = rtrim(wordwrap($strContent, 75, empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA) ? "\r\n" : "\n")); // TODO Using this method creates unexpected line break on text/plain content. if ($this->msgishtml) { if ($this->atleastoneimage) { - $out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; + $out .= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; //$out.= "Content-Transfer-Encoding: 7bit".$this->eol; - $out.= $this->eol.($strContentAltText?$strContentAltText:strip_tags($strContent)).$this->eol; // Add plain text message - $out.= "--" . $this->alternative_boundary . $this->eol; - $out.= "Content-Type: multipart/related;".$this->eol." boundary=\"".$this->related_boundary."\"".$this->eol; - $out.= $this->eol; - $out.= "--" . $this->related_boundary . $this->eol; + $out .= $this->eol.($strContentAltText ? $strContentAltText : strip_tags($strContent)).$this->eol; // Add plain text message + $out .= "--".$this->alternative_boundary.$this->eol; + $out .= "Content-Type: multipart/related;".$this->eol." boundary=\"".$this->related_boundary."\"".$this->eol; + $out .= $this->eol; + $out .= "--".$this->related_boundary.$this->eol; } - if (! $this->atleastoneimage && $strContentAltText && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part + if (!$this->atleastoneimage && $strContentAltText && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part { - $out.= "Content-Type: multipart/alternative;".$this->eol." boundary=\"".$this->alternative_boundary."\"".$this->eol; - $out.= $this->eol; - $out.= "--" . $this->alternative_boundary . $this->eol; - $out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; + $out .= "Content-Type: multipart/alternative;".$this->eol." boundary=\"".$this->alternative_boundary."\"".$this->eol; + $out .= $this->eol; + $out .= "--".$this->alternative_boundary.$this->eol; + $out .= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; //$out.= "Content-Transfer-Encoding: 7bit".$this->eol; - $out.= $this->eol.$strContentAltText.$this->eol; - $out.= "--" . $this->alternative_boundary . $this->eol; + $out .= $this->eol.$strContentAltText.$this->eol; + $out .= "--".$this->alternative_boundary.$this->eol; } - $out.= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol; + $out .= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol; //$out.= "Content-Transfer-Encoding: 7bit".$this->eol; // TODO Use base64 - $out.= $this->eol.$strContent.$this->eol; + $out .= $this->eol.$strContent.$this->eol; - if (! $this->atleastoneimage && $strContentAltText && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part + if (!$this->atleastoneimage && $strContentAltText && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part { - $out.= "--" . $this->alternative_boundary . "--". $this->eol; + $out .= "--".$this->alternative_boundary."--".$this->eol; } } else { - $out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; + $out .= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; //$out.= "Content-Transfer-Encoding: 7bit".$this->eol; - $out.= $this->eol.$strContent.$this->eol; + $out .= $this->eol.$strContent.$this->eol; } - $out.= $this->eol; + $out .= $this->eol; // Encode images if ($this->atleastoneimage) { $out .= $this->write_images($this->images_encoded); // always end related and end alternative after inline images - $out .= "--" . $this->related_boundary . "--" . $this->eol; - $out .= $this->eol . "--" . $this->alternative_boundary . "--" . $this->eol; + $out .= "--".$this->related_boundary."--".$this->eol; + $out .= $this->eol."--".$this->alternative_boundary."--".$this->eol; $out .= $this->eol; } @@ -1208,8 +1208,8 @@ public function write_files($filename_list, $mimetype_list, $mimefilename_list) // phpcs:enable $out = ''; - $filename_list_size=count($filename_list); - for($i=0;$i < $filename_list_size;$i++) + $filename_list_size = count($filename_list); + for ($i = 0; $i < $filename_list_size; $i++) { if ($filename_list[$i]) { @@ -1218,18 +1218,18 @@ public function write_files($filename_list, $mimetype_list, $mimefilename_list) if ($encoded >= 0) { if ($mimefilename_list[$i]) $filename_list[$i] = $mimefilename_list[$i]; - if (! $mimetype_list[$i]) { + if (!$mimetype_list[$i]) { $mimetype_list[$i] = "application/octet-stream"; } - $out.= "--" . $this->mixed_boundary . $this->eol; - $out.= "Content-Disposition: attachment; filename=\"".$filename_list[$i]."\"".$this->eol; - $out.= "Content-Type: " . $mimetype_list[$i] . "; name=\"".$filename_list[$i]."\"".$this->eol; - $out.= "Content-Transfer-Encoding: base64".$this->eol; - $out.= "Content-Description: ".$filename_list[$i].$this->eol; - $out.= $this->eol; - $out.= $encoded; - $out.= $this->eol; + $out .= "--".$this->mixed_boundary.$this->eol; + $out .= "Content-Disposition: attachment; filename=\"".$filename_list[$i]."\"".$this->eol; + $out .= "Content-Type: ".$mimetype_list[$i]."; name=\"".$filename_list[$i]."\"".$this->eol; + $out .= "Content-Transfer-Encoding: base64".$this->eol; + $out .= "Content-Description: ".$filename_list[$i].$this->eol; + $out .= $this->eol; + $out .= $encoded; + $out .= $this->eol; //$out.= $this->eol; } else @@ -1261,14 +1261,14 @@ public function write_images($images_list) { dol_syslog("CMailFile::write_images: ".$img["name"]); - $out.= "--" . $this->related_boundary . $this->eol; // always related for an inline image - $out.= "Content-Type: " . $img["content_type"] . "; name=\"".$img["name"]."\"".$this->eol; - $out.= "Content-Transfer-Encoding: base64".$this->eol; - $out.= "Content-Disposition: inline; filename=\"".$img["name"]."\"".$this->eol; - $out.= "Content-ID: <".$img["cid"].">".$this->eol; - $out.= $this->eol; - $out.= $img["image_encoded"]; - $out.= $this->eol; + $out .= "--".$this->related_boundary.$this->eol; // always related for an inline image + $out .= "Content-Type: ".$img["content_type"]."; name=\"".$img["name"]."\"".$this->eol; + $out .= "Content-Transfer-Encoding: base64".$this->eol; + $out .= "Content-Disposition: inline; filename=\"".$img["name"]."\"".$this->eol; + $out .= "Content-ID: <".$img["cid"].">".$this->eol; + $out .= $this->eol; + $out .= $img["image_encoded"]; + $out .= $this->eol; } } @@ -1289,39 +1289,39 @@ public function check_server_port($host, $port) // phpcs:enable global $conf; - $_retVal=0; - $timeout=5; // Timeout in seconds + $_retVal = 0; + $timeout = 5; // Timeout in seconds if (function_exists('fsockopen')) { - $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 we use SSL/TLS - if (! empty($conf->global->$keyfortls) && function_exists('openssl_open')) $host='ssl://'.$host; + if (!empty($conf->global->$keyfortls) && function_exists('openssl_open')) $host = 'ssl://'.$host; // tls smtp start with no encryption //if (! empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) && function_exists('openssl_open')) $host='tls://'.$host; dol_syslog("Try socket connection to host=".$host." port=".$port); //See if we can connect to the SMTP server if ($socket = @fsockopen( - $host, // Host to test, IP or domain. Add ssl:// for SSL/TLS. - $port, // which Port number to use - $errno, // actual system level error - $errstr, // and any text that goes with the error + $host, // Host to test, IP or domain. Add ssl:// for SSL/TLS. + $port, // which Port number to use + $errno, // actual system level error + $errstr, // and any text that goes with the error $timeout // timeout for reading/writing data over the socket )) { // Windows still does not have support for this timeout function @@ -1334,7 +1334,7 @@ public function check_server_port($host, $port) } else { - $this->error = utf8_check('Error '.$errno.' - '.$errstr)?'Error '.$errno.' - '.$errstr:utf8_encode('Error '.$errno.' - '.$errstr); + $this->error = utf8_check('Error '.$errno.' - '.$errstr) ? 'Error '.$errno.' - '.$errstr : utf8_encode('Error '.$errno.' - '.$errstr); } } return $_retVal; @@ -1352,21 +1352,21 @@ public function check_server_port($host, $port) public function server_parse($socket, $response) { // phpcs:enable - $_retVal = true; // Indicates if Object was created or not + $_retVal = true; // Indicates if Object was created or not $server_response = ''; while (substr($server_response, 3, 1) != ' ') { - if (! ($server_response = fgets($socket, 256)) ) + if (!($server_response = fgets($socket, 256))) { - $this->error="Couldn't get mail server response codes"; + $this->error = "Couldn't get mail server response codes"; return false; } } - if( !( substr($server_response, 0, 3) == $response ) ) + if (!(substr($server_response, 0, 3) == $response)) { - $this->error="Ran into problems sending Mail.\r\nResponse: $server_response"; + $this->error = "Ran into problems sending Mail.\r\nResponse: $server_response"; $_retVal = false; } @@ -1385,11 +1385,11 @@ public function findHtmlImages($images_dir) $extensions = array_keys($this->image_types); $matches = array(); - preg_match_all('/(?:"|\')([^"\']+\.('.implode('|', $extensions).'))(?:"|\')/Ui', $this->html, $matches); // If "xxx.ext" or 'xxx.ext' found + preg_match_all('/(?:"|\')([^"\']+\.('.implode('|', $extensions).'))(?:"|\')/Ui', $this->html, $matches); // If "xxx.ext" or 'xxx.ext' found - if (! empty($matches)) + if (!empty($matches)) { - $i=0; + $i = 0; foreach ($matches[1] as $full) { if (preg_match('/file=([A-Za-z0-9_\-\/]+[\.]?[A-Za-z0-9]+)?$/i', $full, $regs)) // If xxx is 'file=aaa' @@ -1410,12 +1410,12 @@ public function findHtmlImages($images_dir) // Content type if (preg_match('/^.+\.(\w{3,4})$/', $img, $reg)) { - $ext=strtolower($reg[1]); + $ext = strtolower($reg[1]); $this->html_images[$i]["content_type"] = $this->image_types[$ext]; } // cid - $this->html_images[$i]["cid"] = dol_hash(uniqid(time()), 3); // Force md5 hash (does not contains special chars) + $this->html_images[$i]["cid"] = dol_hash(uniqid(time()), 3); // Force md5 hash (does not contains special chars) $this->html = preg_replace("/src=\"$src\"|src='$src'/i", "src=\"cid:".$this->html_images[$i]["cid"]."\"", $this->html); } $i++; @@ -1426,7 +1426,7 @@ public function findHtmlImages($images_dir) { $inline = array(); - $i=0; + $i = 0; foreach ($this->html_images as $img) { @@ -1485,13 +1485,13 @@ public static function getValidAddress($address, $format, $encode = 0, $maxnumbe { global $conf; - $ret=''; + $ret = ''; - $arrayaddress=explode(',', $address); + $arrayaddress = explode(',', $address); // Boucle sur chaque composant de l'adresse - $i=0; - foreach($arrayaddress as $val) + $i = 0; + foreach ($arrayaddress as $val) { if (preg_match('/^(.*)<(.*)>$/i', trim($val), $regs)) { @@ -1508,36 +1508,36 @@ public static function getValidAddress($address, $format, $encode = 0, $maxnumbe { $i++; - $newemail=''; + $newemail = ''; if ($format == 5) { - $newemail = $name?$name:$email; + $newemail = $name ? $name : $email; $newemail = ''.$newemail.''; } if ($format == 4) { - $newemail = $name?$name:$email; + $newemail = $name ? $name : $email; } if ($format == 2) { - $newemail=$email; + $newemail = $email; } if ($format == 1 || $format == 3) { - $newemail='<'.$email.'>'; + $newemail = '<'.$email.'>'; } if ($format == 0 || $format == 3) { - if (! empty($conf->global->MAIN_MAIL_NO_FULL_EMAIL)) $newemail='<'.$email.'>'; - elseif (! $name) $newemail='<'.$email.'>'; - else $newemail=($format==3?'"':'').($encode?self::encodetorfc2822($name):$name).($format==3?'"':'').' <'.$email.'>'; + if (!empty($conf->global->MAIN_MAIL_NO_FULL_EMAIL)) $newemail = '<'.$email.'>'; + elseif (!$name) $newemail = '<'.$email.'>'; + else $newemail = ($format == 3 ? '"' : '').($encode ?self::encodetorfc2822($name) : $name).($format == 3 ? '"' : '').' <'.$email.'>'; } - $ret=($ret ? $ret.',' : '').$newemail; + $ret = ($ret ? $ret.',' : '').$newemail; // Stop if we have too much records if ($maxnumberofemail && $i >= $maxnumberofemail) { - if (count($arrayaddress) > $maxnumberofemail) $ret.='...'; + if (count($arrayaddress) > $maxnumberofemail) $ret .= '...'; break; } } @@ -1556,12 +1556,12 @@ public function getArrayAddress($address) { global $conf; - $ret=array(); + $ret = array(); - $arrayaddress=explode(',', $address); + $arrayaddress = explode(',', $address); // Boucle sur chaque composant de l'adresse - foreach($arrayaddress as $val) + foreach ($arrayaddress as $val) { if (preg_match('/^(.*)<(.*)>$/i', trim($val), $regs)) { @@ -1574,7 +1574,7 @@ public function getArrayAddress($address) $email = trim($val); } - $ret[$email]=empty($conf->global->MAIN_MAIL_NO_FULL_EMAIL)?$name:null; + $ret[$email] = empty($conf->global->MAIN_MAIL_NO_FULL_EMAIL) ? $name : null; } return $ret; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 258f87d2d9f28..5cb869c6817aa 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -27,48 +27,48 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; -require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; -require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmfiles.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/expensereport.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/expensereport/modules_expensereport.php'; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -if (! empty($conf->accounting->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (!empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; } // Load translation files required by the page -$langs->loadLangs(array("trips","bills","mails")); +$langs->loadLangs(array("trips", "bills", "mails")); -$action=GETPOST('action', 'aZ09'); -$cancel=GETPOST('cancel', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $date_start = dol_mktime(0, 0, 0, GETPOST('date_debutmonth', 'int'), GETPOST('date_debutday', 'int'), GETPOST('date_debutyear', 'int')); $date_end = dol_mktime(0, 0, 0, GETPOST('date_finmonth', 'int'), GETPOST('date_finday', 'int'), GETPOST('date_finyear', 'int')); $date = dol_mktime(0, 0, 0, GETPOST('datemonth', 'int'), GETPOST('dateday', 'int'), GETPOST('dateyear', 'int')); -$fk_project=GETPOST('fk_project', 'int'); -$vatrate=GETPOST('vatrate', 'alpha'); -$ref=GETPOST("ref", 'alpha'); -$comments=GETPOST('comments', 'none'); -$fk_c_type_fees=GETPOST('fk_c_type_fees', 'int'); -$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('socid_id', 'int'); +$fk_project = GETPOST('fk_project', 'int'); +$vatrate = GETPOST('vatrate', 'alpha'); +$ref = GETPOST("ref", 'alpha'); +$comments = GETPOST('comments', 'none'); +$fk_c_type_fees = GETPOST('fk_c_type_fees', 'int'); +$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('socid_id', 'int'); $childids = $user->getAllChildIds(1); // Security check -$id=GETPOST("id", 'int'); -if ($user->socid) $socid=$user->socid; +$id = GETPOST("id", 'int'); +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'expensereport', $id, 'expensereport'); @@ -76,38 +76,38 @@ $rootfordata = DOL_DATA_ROOT; $rootforuser = DOL_DATA_ROOT; // If multicompany module is enabled, we redefine the root of data -if (! empty($conf->multicompany->enabled) && ! empty($conf->entity) && $conf->entity > 1) +if (!empty($conf->multicompany->enabled) && !empty($conf->entity) && $conf->entity > 1) { - $rootfordata.='/'.$conf->entity; + $rootfordata .= '/'.$conf->entity; } $conf->expensereport->dir_output = $rootfordata.'/expensereport'; // 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 // PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); -$object=new ExpenseReport($db); +$object = new ExpenseReport($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('expensereportcard','globalcard')); +$hookmanager->initHooks(array('expensereportcard', 'globalcard')); -$permissionnote = $user->rights->expensereport->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->expensereport->creer; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->rights->expensereport->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->rights->expensereport->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->expensereport->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->rights->expensereport->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref); @@ -117,9 +117,9 @@ { // Check current user can read this expense report $canread = 0; - if (! empty($user->rights->expensereport->readall)) $canread=1; - if (! empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) $canread=1; - if (! $canread) + if (!empty($user->rights->expensereport->readall)) $canread = 1; + if (!empty($user->rights->expensereport->lire) && in_array($object->fk_user_author, $childids)) $canread = 1; + if (!$canread) { accessforbidden(); } @@ -138,43 +138,43 @@ { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action=''; - - $fk_project=''; - $date_start=''; - $date_end=''; - $date=''; - $comments=''; - $vatrate=''; - $value_unit_ht=''; - $value_unit=''; - $qty=1; - $fk_c_type_fees=-1; + $action = ''; + + $fk_project = ''; + $date_start = ''; + $date_end = ''; + $date = ''; + $comments = ''; + $vatrate = ''; + $value_unit_ht = ''; + $value_unit = ''; + $qty = 1; + $fk_c_type_fees = -1; } include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if (GETPOSTISSET('sendit')) // If we just submit a file { - if ($action == 'updateline') $action='editline'; // To avoid to make the updateline now - else $action=''; // To avoid to make the addline now + if ($action == 'updateline') $action = 'editline'; // To avoid to make the updateline now + else $action = ''; // To avoid to make the addline now } - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->expensereport->creer) { - if (1==0 && ! GETPOST('clone_content', 'alpha') && ! GETPOST('clone_receivers', 'alpha')) + if (1 == 0 && !GETPOST('clone_content', 'alpha') && !GETPOST('clone_receivers', 'alpha')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } @@ -185,7 +185,7 @@ // Because createFromClone modifies the object, we must clone it so that we can restore it later if it fails $orig = clone $object; - $result=$object->createFromClone($user, GETPOST('fk_user_author', 'int')); + $result = $object->createFromClone($user, GETPOST('fk_user_author', 'int')); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -195,7 +195,7 @@ { setEventMessages($object->error, $object->errors, 'errors'); $object = $orig; - $action=''; + $action = ''; } } } @@ -224,32 +224,32 @@ $object->date_debut = $date_start; $object->date_fin = $date_end; - $object->fk_user_author = GETPOST('fk_user_author', 'int'); - if (! ($object->fk_user_author > 0)) $object->fk_user_author = $user->id; + $object->fk_user_author = GETPOST('fk_user_author', 'int'); + if (!($object->fk_user_author > 0)) $object->fk_user_author = $user->id; - $fuser=new User($db); + $fuser = new User($db); $fuser->fetch($object->fk_user_author); $object->fk_statut = 1; - $object->fk_c_paiement = GETPOST('fk_c_paiement', 'int'); - $object->fk_user_validator = GETPOST('fk_user_validator', 'int'); - $object->note_public = GETPOST('note_public', 'none'); - $object->note_private = GETPOST('note_private', 'none'); + $object->fk_c_paiement = GETPOST('fk_c_paiement', 'int'); + $object->fk_user_validator = GETPOST('fk_user_validator', 'int'); + $object->note_public = GETPOST('note_public', 'none'); + $object->note_private = GETPOST('note_private', 'none'); // Fill array 'array_options' with data from add form - if (! $error) + if (!$error) { $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; } - if (! $error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS) && $object->periode_existe($fuser, $object->date_debut, $object->date_fin)) + if (!$error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS) && $object->periode_existe($fuser, $object->date_debut, $object->date_fin)) { $error++; setEventMessages($langs->trans("ErrorDoubleDeclaration"), null, 'errors'); - $action='create'; + $action = 'create'; } - if (! $error) + if (!$error) { $db->begin(); @@ -259,7 +259,7 @@ $error++; } - if (! $error) + if (!$error) { $db->commit(); Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); @@ -269,7 +269,7 @@ { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); - $action='create'; + $action = 'create'; } } } @@ -282,7 +282,7 @@ $object->date_debut = $date_start; $object->date_fin = $date_end; - if($object->fk_statut < 3) + if ($object->fk_statut < 3) { $object->fk_user_validator = GETPOST('fk_user_validator', 'int'); } @@ -312,7 +312,7 @@ $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('EXPENSEREPORT_MODIFY'); @@ -347,11 +347,11 @@ $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); @@ -363,7 +363,7 @@ $error++; } - if (! $error && $result > 0 && $object->fk_user_validator > 0) + if (!$error && $result > 0 && $object->fk_user_validator > 0) { $langs->load("mails"); @@ -379,11 +379,11 @@ if ($emailTo && $emailFrom) { - $filename=array(); $filedir=array(); $mimetype=array(); + $filename = array(); $filedir = array(); $mimetype = array(); // SUBJECT $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; $subject = $societeName." - ".$langs->transnoentities("ExpenseReportWaitingForApproval"); @@ -409,10 +409,10 @@ if ($mailfile) { // SEND - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $mesg=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); setEventMessages($mesg, null, 'mesgs'); } else @@ -420,9 +420,9 @@ $langs->load("other"); if ($mailfile->error) { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
'.$mailfile->error; + $mesg = ''; + $mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg .= '
'.$mailfile->error; setEventMessages($mesg, null, 'errors'); } else @@ -434,17 +434,17 @@ else { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; + $action = ''; } } - if (! $error) + if (!$error) { $db->commit(); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); @@ -471,11 +471,11 @@ $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); @@ -498,11 +498,11 @@ if ($emailFrom && $emailTo) { - $filename=array(); $filedir=array(); $mimetype=array(); + $filename = array(); $filedir = array(); $mimetype = array(); // SUBJECT $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; $subject = $societeName." - ".$langs->transnoentities("ExpenseReportWaitingForReApproval"); @@ -533,10 +533,10 @@ if ($mailfile) { // SEND - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $mesg=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); setEventMessages($mesg, null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; @@ -546,9 +546,9 @@ $langs->load("other"); if ($mailfile->error) { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
'.$mailfile->error; + $mesg = ''; + $mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg .= '
'.$mailfile->error; setEventMessages($mesg, null, 'errors'); } else @@ -560,13 +560,13 @@ else { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; + $action = ''; } } else @@ -592,11 +592,11 @@ $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); @@ -614,7 +614,7 @@ // CC $emailCC = $conf->global->NDF_CC_EMAILS; - if (empty($emailTo)) $emailTo=$emailCC; + if (empty($emailTo)) $emailTo = $emailCC; // FROM $expediteur = new User($db); @@ -623,11 +623,11 @@ if ($emailFrom && $emailTo) { - $filename=array(); $filedir=array(); $mimetype=array(); + $filename = array(); $filedir = array(); $mimetype = array(); // SUBJECT $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; $subject = $societeName." - ".$langs->transnoentities("ExpenseReportApproved"); @@ -655,10 +655,10 @@ if ($mailfile) { // SEND - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $mesg=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); setEventMessages($mesg, null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; @@ -668,9 +668,9 @@ $langs->load("other"); if ($mailfile->error) { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
'.$mailfile->error; + $mesg = ''; + $mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg .= '
'.$mailfile->error; setEventMessages($mesg, null, 'errors'); } else @@ -682,23 +682,23 @@ else { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("FailedtoSetToApprove"), null, 'warnings'); - $action=''; + $action = ''; } } - if ($action == "confirm_refuse" && GETPOST('confirm', 'alpha')=="yes" && $id > 0 && $user->rights->expensereport->approve) + if ($action == "confirm_refuse" && GETPOST('confirm', 'alpha') == "yes" && $id > 0 && $user->rights->expensereport->approve) { $object = new ExpenseReport($db); $object->fetch($id); @@ -714,11 +714,11 @@ $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); @@ -741,11 +741,11 @@ if ($emailFrom && $emailTo) { - $filename=array(); $filedir=array(); $mimetype=array(); + $filename = array(); $filedir = array(); $mimetype = array(); // SUBJECT $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; $subject = $societeName." - ".$langs->transnoentities("ExpenseReportRefused"); @@ -774,10 +774,10 @@ if ($mailfile) { // SEND - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $mesg=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); setEventMessages($mesg, null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; @@ -787,9 +787,9 @@ $langs->load("other"); if ($mailfile->error) { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
'.$mailfile->error; + $mesg = ''; + $mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg .= '
'.$mailfile->error; setEventMessages($mesg, null, 'errors'); } else @@ -801,26 +801,26 @@ else { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("FailedtoSetToDeny"), null, 'warnings'); - $action=''; + $action = ''; } } //var_dump($user->id == $object->fk_user_validator);exit; - if ($action == "confirm_cancel" && GETPOST('confirm', 'alpha')=="yes" && $id > 0 && $user->rights->expensereport->creer) + if ($action == "confirm_cancel" && GETPOST('confirm', 'alpha') == "yes" && $id > 0 && $user->rights->expensereport->creer) { - if (! GETPOST('detail_cancel', 'alpha')) + if (!GETPOST('detail_cancel', 'alpha')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors'); } @@ -842,11 +842,11 @@ $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); @@ -869,11 +869,11 @@ if ($emailFrom && $emailTo) { - $filename=array(); $filedir=array(); $mimetype=array(); + $filename = array(); $filedir = array(); $mimetype = array(); // SUBJECT $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; $subject = $societeName." - ".$langs->transnoentities("ExpenseReportCanceled"); @@ -902,10 +902,10 @@ if ($mailfile) { // SEND - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $mesg=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); setEventMessages($mesg, null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; @@ -915,9 +915,9 @@ $langs->load("other"); if ($mailfile->error) { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
'.$mailfile->error; + $mesg = ''; + $mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg .= '
'.$mailfile->error; setEventMessages($mesg, null, 'errors'); } else @@ -929,19 +929,19 @@ else { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("FailedToSetToCancel"), null, 'warnings'); - $action=''; + $action = ''; } } else @@ -951,7 +951,7 @@ } } - if ($action == "confirm_setdraft" && GETPOST('confirm', 'alpha')=="yes" && $id > 0 && $user->rights->expensereport->creer) + if ($action == "confirm_setdraft" && GETPOST('confirm', 'alpha') == "yes" && $id > 0 && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); $object->fetch($id); @@ -968,11 +968,11 @@ $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); @@ -1011,11 +1011,11 @@ $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); @@ -1039,11 +1039,11 @@ $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); @@ -1067,11 +1067,11 @@ $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); @@ -1094,11 +1094,11 @@ if ($emailFrom && $emailTo) { - $filename=array(); $filedir=array(); $mimetype=array(); + $filename = array(); $filedir = array(); $mimetype = array(); // SUBJECT $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE; $subject = $societeName." - ".$langs->transnoentities("ExpenseReportPaid"); @@ -1116,10 +1116,10 @@ if ($mailfile) { // SEND - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $mesg=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2)); setEventMessages($mesg, null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; @@ -1129,9 +1129,9 @@ $langs->load("other"); if ($mailfile->error) { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
'.$mailfile->error; + $mesg = ''; + $mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg .= '
'.$mailfile->error; setEventMessages($mesg, null, 'errors'); } else @@ -1143,19 +1143,19 @@ else { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; + $action = ''; } } else { setEventMessages($langs->trans("FailedToSetPaid"), null, 'warnings'); - $action=''; + $action = ''; } } @@ -1167,12 +1167,12 @@ $fk_ecm_files = 0; if (GETPOSTISSET('attachfile')) { - $arrayoffiles=GETPOST('attachfile', 'array'); - if (is_array($arrayoffiles) && ! empty($arrayoffiles[0])) + $arrayoffiles = GETPOST('attachfile', 'array'); + if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) { include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $relativepath='expensereport/'.$object->ref.'/'.$arrayoffiles[0]; - $ecmfiles=new EcmFiles($db); + $relativepath = 'expensereport/'.$object->ref.'/'.$arrayoffiles[0]; + $ecmfiles = new EcmFiles($db); $ecmfiles->fetch(0, '', $relativepath); $fk_ecm_files = $ecmfiles->id; } @@ -1182,8 +1182,8 @@ if (empty($vatrate)) $vatrate = "0.000"; $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $vatrate)); - $value_unit_ht=price2num(GETPOST('value_unit_ht', 'alpha'), 'MU'); - $value_unit=price2num(GETPOST('value_unit', 'alpha'), 'MU'); + $value_unit_ht = price2num(GETPOST('value_unit_ht', 'alpha'), 'MU'); + $value_unit = price2num(GETPOST('value_unit', 'alpha'), 'MU'); if (empty($value_unit)) { $value_unit = price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100), 'MU'); @@ -1192,24 +1192,24 @@ $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat', 'int'); $qty = GETPOST('qty', 'int'); - if (empty($qty)) $qty=1; + if (empty($qty)) $qty = 1; - if (! ($fk_c_type_fees > 0)) + if (!($fk_c_type_fees > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $action=''; + $action = ''; } if ((int) $tmpvat < 0 || $tmpvat == '') { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("VAT")), null, 'errors'); - $action=''; + $action = ''; } // Si aucune date n'est rentrée - if (empty($date) || $date=="--") + if (empty($date) || $date == "--") { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); @@ -1227,9 +1227,9 @@ setEventMessages($langs->trans("WarningDateOfLineMustBeInExpenseReportRange"), null, 'warnings'); } - if (! $error) + if (!$error) { - $type = 0; // TODO What if service ? We should take the type product/service from the type of expense report llx_c_type_fees + $type = 0; // TODO What if service ? We should take the type product/service from the type of expense report llx_c_type_fees // Insert line $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_project, $fk_c_exp_tax_cat, $type, $fk_ecm_files); @@ -1241,9 +1241,9 @@ // Define output language $outputlangs = $langs; $newlang = GETPOST('lang_id', 'alpha'); - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) + if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -1265,7 +1265,7 @@ } } - $action=''; + $action = ''; } if ($action == 'confirm_delete_line' && GETPOST("confirm", 'alpha') == "yes" && $user->rights->expensereport->creer) @@ -1278,7 +1278,7 @@ $total_ht = $object_ligne->total_ht; $total_tva = $object_ligne->total_tva; - $result=$object->deleteline(GETPOST("rowid", 'int'), $user); + $result = $object->deleteline(GETPOST("rowid", 'int'), $user); if ($result >= 0) { if ($result > 0) @@ -1290,11 +1290,11 @@ $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); @@ -1320,12 +1320,12 @@ $fk_ecm_files = 0; if (GETPOSTISSET('attachfile')) { - $arrayoffiles=GETPOST('attachfile', 'array'); - if (is_array($arrayoffiles) && ! empty($arrayoffiles[0])) + $arrayoffiles = GETPOST('attachfile', 'array'); + if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) { include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $relativepath='expensereport/'.$object->ref.'/'.$arrayoffiles[0]; - $ecmfiles=new EcmFiles($db); + $relativepath = 'expensereport/'.$object->ref.'/'.$arrayoffiles[0]; + $ecmfiles = new EcmFiles($db); $ecmfiles->fetch(0, '', $relativepath); $fk_ecm_files = $ecmfiles->id; } @@ -1343,24 +1343,24 @@ if (empty($vatrate)) $vatrate = "0.000"; $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $vatrate)); - $value_unit_ht=price2num(GETPOST('value_unit_ht', 'alpha'), 'MU'); - $value_unit=price2num(GETPOST('value_unit', 'alpha'), 'MU'); + $value_unit_ht = price2num(GETPOST('value_unit_ht', 'alpha'), 'MU'); + $value_unit = price2num(GETPOST('value_unit', 'alpha'), 'MU'); if (empty($value_unit)) { $value_unit = price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100), 'MU'); } - if (! GETPOST('fk_c_type_fees', 'int') > 0) + if (!GETPOST('fk_c_type_fees', 'int') > 0) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $action=''; + $action = ''; } if ((int) $tmpvat < 0 || $tmpvat == '') { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Vat")), null, 'errors'); - $action=''; + $action = ''; } // Warning if date out of range if ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1))) @@ -1369,7 +1369,7 @@ setEventMessages($langs->trans("WarningDateOfLineMustBeInExpenseReportRange"), null, 'warnings'); } - if (! $error) + if (!$error) { // TODO Use update method of ExpenseReportLine $result = $object->updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $id, $fk_c_exp_tax_cat, $fk_ecm_files); @@ -1384,11 +1384,11 @@ $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); @@ -1411,9 +1411,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='EXPENSEREPORT_SENTBYMAIL'; - $autocopy='MAIN_MAIL_AUTOCOPY_EXPENSEREPORT_TO'; - $trackid='exp'.$object->id; + $trigger_name = 'EXPENSEREPORT_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_EXPENSEREPORT_TO'; + $trackid = 'exp'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc @@ -1427,15 +1427,15 @@ * View */ -$title=$langs->trans("ExpenseReport") . " - " . $langs->trans("Card"); -$helpurl="EN:Module_Expense_Reports"; +$title = $langs->trans("ExpenseReport")." - ".$langs->trans("Card"); +$helpurl = "EN:Module_Expense_Reports"; llxHeader("", $title, $helpurl); $form = new Form($db); $formfile = new FormFile($db); $formproject = new FormProjets($db); $projecttmp = new Project($db); -$paymentexpensereportstatic=new PaymentExpenseReport($db); +$paymentexpensereportstatic = new PaymentExpenseReport($db); $bankaccountstatic = new Account($db); $ecmfilesstatic = new EcmFiles($db); @@ -1457,7 +1457,7 @@ print ''; print ''.$langs->trans("DateStart").''; print ''; - print $form->selectDate($date_start?$date_start:-1, 'date_debut', 0, 0, 0, '', 1, 1); + print $form->selectDate($date_start ? $date_start : -1, 'date_debut', 0, 0, 0, '', 1, 1); print ''; print ''; @@ -1465,7 +1465,7 @@ print ''; print ''.$langs->trans("DateEnd").''; print ''; - print $form->selectDate($date_end?$date_end:-1, 'date_fin', 0, 0, 0, '', 1, 1); + print $form->selectDate($date_end ? $date_end : -1, 'date_fin', 0, 0, 0, '', 1, 1); print ''; print ''; @@ -1473,11 +1473,11 @@ print ''; print ''.$langs->trans("User").''; print ''; - $defaultselectuser=$user->id; - if (GETPOST('fk_user_author', 'int') > 0) $defaultselectuser=GETPOST('fk_user_author', 'int'); + $defaultselectuser = $user->id; + if (GETPOST('fk_user_author', 'int') > 0) $defaultselectuser = GETPOST('fk_user_author', 'int'); $include_users = 'hierarchyme'; - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expensereport->writeall_advance)) $include_users=array(); - $s=$form->select_dolusers($defaultselectuser, "fk_user_author", 0, "", 0, $include_users, '', '0,'.$conf->entity); + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expensereport->writeall_advance)) $include_users = array(); + $s = $form->select_dolusers($defaultselectuser, "fk_user_author", 0, "", 0, $include_users, '', '0,'.$conf->entity); print $s; print ''; print ''; @@ -1491,17 +1491,17 @@ if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateExpenseReport"); else { - $defaultselectuser=(empty($user->fk_user_expense_validator) ? $user->fk_user : $user->fk_user_expense_validator); // Will work only if supervisor has permission to approve so is inside include_users - if (! empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR; // Can force default approver - if (GETPOST('fk_user_validator', 'int') > 0) $defaultselectuser=GETPOST('fk_user_validator', 'int'); - $s=$form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", ((empty($defaultselectuser) || empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE))?0:1), $include_users); + $defaultselectuser = (empty($user->fk_user_expense_validator) ? $user->fk_user : $user->fk_user_expense_validator); // Will work only if supervisor has permission to approve so is inside include_users + if (!empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) $defaultselectuser = $conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR; // Can force default approver + if (GETPOST('fk_user_validator', 'int') > 0) $defaultselectuser = GETPOST('fk_user_validator', 'int'); + $s = $form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", ((empty($defaultselectuser) || empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE)) ? 0 : 1), $include_users); print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); } print ''; print ''; // Payment mode - if (! empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) + if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) { print ''; print ''.$langs->trans("ModePaiement").''; @@ -1513,7 +1513,7 @@ // Public note print ''; - print '' . $langs->trans('NotePublic') . ''; + print ''.$langs->trans('NotePublic').''; print ''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); @@ -1523,7 +1523,7 @@ // Private note if (empty($user->socid)) { print ''; - print '' . $langs->trans('NotePrivate') . ''; + print ''.$langs->trans('NotePrivate').''; print ''; $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); @@ -1553,7 +1553,7 @@ } else { - if($id > 0 || $ref) + if ($id > 0 || $ref) { $result = $object->fetch($id, $ref); @@ -1561,7 +1561,7 @@ if ($result > 0) { - if (! in_array($object->fk_user_author, $user->getAllChildIds(1))) + if (!in_array($object->fk_user_author, $user->getAllChildIds(1))) { if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) @@ -1582,7 +1582,7 @@ $head = expensereport_prepare_head($object); - if ($action == 'edit' && ($object->fk_statut < 3 || $object->fk_statut==99)) + if ($action == 'edit' && ($object->fk_statut < 3 || $object->fk_statut == 99)) { print "\n"; print ''; @@ -1590,7 +1590,7 @@ dol_fiche_head($head, 'card', $langs->trans("ExpenseReport"), 0, 'trip'); - if($object->fk_statut==99) + if ($object->fk_statut == 99) { print ''; } @@ -1599,14 +1599,14 @@ print ''; } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; print ''; print ''; print ''; print ''; print ''; - if (! empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) + if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) { print ''; print ''; @@ -1642,13 +1642,13 @@ print ''; } - if($object->fk_statut<3) + if ($object->fk_statut < 3) { print ''; - print ''; // Approbator + print ''; // Approbator print ''; print ''; @@ -1658,18 +1658,18 @@ print ''; print ''; print ''; } - if ($object->fk_statut==6) + if ($object->fk_statut == 6) { print ''; print ''; print ''; @@ -1697,70 +1697,70 @@ // Clone confirmation if ($action == 'clone') { // Create an array for form - $criteriaforfilter='hierarchyme'; - if (! empty($user->rights->expensereport->readall)) $criteriaforfilter=''; + $criteriaforfilter = 'hierarchyme'; + if (!empty($user->rights->expensereport->readall)) $criteriaforfilter = ''; $formquestion = array( 'text' => '', - array('type' => 'other','name' => 'fk_user_author','label' => $langs->trans("SelectTargetUser"),'value' => $form->select_dolusers((GETPOST('fk_user_author', 'int')> 0 ? GETPOST('fk_user_author', 'int') : $user->id), 'fk_user_author', 0, null, 0, $criteriaforfilter)) + array('type' => 'other', 'name' => 'fk_user_author', 'label' => $langs->trans("SelectTargetUser"), 'value' => $form->select_dolusers((GETPOST('fk_user_author', 'int') > 0 ? GETPOST('fk_user_author', 'int') : $user->id), 'fk_user_author', 0, null, 0, $criteriaforfilter)) ); // Paiement incomplet. On demande si motif = escompte ou autre - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneExpenseReport', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneExpenseReport', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } if ($action == 'save') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("SaveTrip"), $langs->trans("ConfirmSaveTrip"), "confirm_validate", "", "", 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("SaveTrip"), $langs->trans("ConfirmSaveTrip"), "confirm_validate", "", "", 1); } if ($action == 'save_from_refuse') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("SaveTrip"), $langs->trans("ConfirmSaveTrip"), "confirm_save_from_refuse", "", "", 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("SaveTrip"), $langs->trans("ConfirmSaveTrip"), "confirm_save_from_refuse", "", "", 1); } if ($action == 'delete') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete", "", "", 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete", "", "", 1); } if ($action == 'validate') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("ValideTrip"), $langs->trans("ConfirmValideTrip"), "confirm_approve", "", "", 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("ValideTrip"), $langs->trans("ConfirmValideTrip"), "confirm_approve", "", "", 1); } if ($action == 'paid') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("PaidTrip"), $langs->trans("ConfirmPaidTrip"), "confirm_paid", "", "", 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("PaidTrip"), $langs->trans("ConfirmPaidTrip"), "confirm_paid", "", "", 1); } if ($action == 'cancel') { - $array_input = array('text'=>$langs->trans("ConfirmCancelTrip"), array('type'=>"text",'label'=>''.$langs->trans("Comment").'','name'=>"detail_cancel",'value'=>"")); - $formconfirm=$form->formconfirm($_SEVER["PHP_SELF"]."?id=".$id, $langs->trans("Cancel"), "", "confirm_cancel", $array_input, "", 1); + $array_input = array('text'=>$langs->trans("ConfirmCancelTrip"), array('type'=>"text", 'label'=>''.$langs->trans("Comment").'', 'name'=>"detail_cancel", 'value'=>"")); + $formconfirm = $form->formconfirm($_SEVER["PHP_SELF"]."?id=".$id, $langs->trans("Cancel"), "", "confirm_cancel", $array_input, "", 1); } if ($action == 'setdraft') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("BrouillonnerTrip"), $langs->trans("ConfirmBrouillonnerTrip"), "confirm_setdraft", "", "", 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("BrouillonnerTrip"), $langs->trans("ConfirmBrouillonnerTrip"), "confirm_setdraft", "", "", 1); } if ($action == 'refuse') // Deny { - $array_input = array('text'=>$langs->trans("ConfirmRefuseTrip"), array('type'=>"text",'label'=>$langs->trans("Comment"),'name'=>"detail_refuse",'value'=>"")); - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("Deny"), '', "confirm_refuse", $array_input, "yes", 1); + $array_input = array('text'=>$langs->trans("ConfirmRefuseTrip"), array('type'=>"text", 'label'=>$langs->trans("Comment"), 'name'=>"detail_refuse", 'value'=>"")); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("Deny"), '', "confirm_refuse", $array_input, "yes", 1); } if ($action == 'delete_line') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id."&rowid=".GETPOST('rowid', 'int'), $langs->trans("DeleteLine"), $langs->trans("ConfirmDeleteLine"), "confirm_delete_line", '', 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id."&rowid=".GETPOST('rowid', 'int'), $langs->trans("DeleteLine"), $langs->trans("ConfirmDeleteLine"), "confirm_delete_line", '', 'yes', 1); } // Print form confirm print $formconfirm; // Expense report card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1); @@ -1799,7 +1799,7 @@ } } }*/ - $morehtmlref.='
'; + $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -1815,8 +1815,8 @@ print ''; print ''; - if (! empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) + if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) { print ''; print ''; @@ -1849,14 +1849,14 @@ if ($object->fk_statut <= ExpenseReport::STATUS_VALIDATED) // informed { print ''; - print ''; // approver + print ''; // approver print ''; } - elseif($object->fk_statut == ExpenseReport::STATUS_CANCELED) + elseif ($object->fk_statut == ExpenseReport::STATUS_CANCELED) { print ''; print ''; print ''; } - if ($object->fk_statut==99 || !empty($object->detail_refuse)) + if ($object->fk_statut == 99 || !empty($object->detail_refuse)) { print ''; print ''; print ''; @@ -1923,7 +1923,7 @@ print ''; } - if($object->fk_statut==6) + if ($object->fk_statut == 6) { /* TODO this fields are not yet filled print ''; @@ -1942,7 +1942,7 @@ // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'.$langs->trans("User").''; - $userfee=new User($db); + $userfee = new User($db); if ($object->fk_user_author > 0) { $userfee->fetch($object->fk_user_author); @@ -1632,7 +1632,7 @@ print '
'.$langs->trans("ModePaiement").'
'.$langs->trans("VALIDATOR").''.$langs->trans("VALIDATOR").''; $include_users = $object->fetch_users_approver_expensereport(); - $s=$form->select_dolusers($object->fk_user_validator, "fk_user_validator", 1, "", 0, $include_users); + $s = $form->select_dolusers($object->fk_user_validator, "fk_user_validator", 1, "", 0, $include_users); print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); print '
'.$langs->trans("VALIDOR").''; - $userfee=new User($db); + $userfee = new User($db); $userfee->fetch($object->fk_user_valid); print $userfee->getNomUrl(-1); print '
'.$langs->trans("AUTHORPAIEMENT").''; - $userfee=new User($db); + $userfee = new User($db); $userfee->fetch($user->id); print $userfee->getNomUrl(-1); print '
'; if ($object->fk_user_author > 0) { - $userauthor=new User($db); - $result=$userauthor->fetch($object->fk_user_author); + $userauthor = new User($db); + $result = $userauthor->fetch($object->fk_user_author); if ($result < 0) dol_print_error('', $userauthor->error); elseif ($result > 0) print $userauthor->getNomUrl(-1); } @@ -1828,7 +1828,7 @@ print get_date_range($object->date_debut, $object->date_fin, 'day', $langs, 0); print '
'.$langs->trans("ModePaiement").'
'.$langs->trans("VALIDATOR").''.$langs->trans("VALIDATOR").''; if ($object->fk_user_validator > 0) { - $userfee=new User($db); + $userfee = new User($db); $result = $userfee->fetch($object->fk_user_validator); if ($result > 0) print $userfee->getNomUrl(-1); - if (empty($userfee->email) || ! isValidEmail($userfee->email)) + if (empty($userfee->email) || !isValidEmail($userfee->email)) { $langs->load("errors"); print img_warning($langs->trans("ErrorBadEMail", $userfee->email)); @@ -1864,14 +1864,14 @@ } print '
'.$langs->trans("CANCEL_USER").''; if ($object->fk_user_cancel > 0) { - $userfee=new User($db); + $userfee = new User($db); $result = $userfee->fetch($object->fk_user_cancel); if ($result > 0) print $userfee->getNomUrl(-1); } @@ -1893,7 +1893,7 @@ print ''; if ($object->fk_user_approve > 0) { - $userapp=new User($db); + $userapp = new User($db); $result = $userapp->fetch($object->fk_user_approve); if ($result > 0) print $userapp->getNomUrl(-1); } @@ -1905,12 +1905,12 @@ print '
'.$langs->trans("REFUSEUR").''; - $userfee=new User($db); + $userfee = new User($db); $result = $userfee->fetch($object->fk_user_refuse); if ($result > 0) print $userfee->getNomUrl(-1); print '
'; @@ -1959,10 +1959,10 @@ print ''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).''; $rowspan = 5; if ($object->fk_statut <= ExpenseReport::STATUS_VALIDATED) $rowspan++; - elseif($object->fk_statut == ExpenseReport::STATUS_CANCELED) $rowspan+=2; - else $rowspan+=2; - if ($object->fk_statut == ExpenseReport::STATUS_REFUSED || !empty($object->detail_refuse)) $rowspan+=2; - if ($object->fk_statut == ExpenseReport::STATUS_CLOSED) $rowspan+=2; + elseif ($object->fk_statut == ExpenseReport::STATUS_CANCELED) $rowspan += 2; + else $rowspan += 2; + if ($object->fk_statut == ExpenseReport::STATUS_REFUSED || !empty($object->detail_refuse)) $rowspan += 2; + if ($object->fk_statut == ExpenseReport::STATUS_CLOSED) $rowspan += 2; print ""; print ''; @@ -1978,36 +1978,36 @@ // List of payments already done $nbcols = 3; - if (! empty($conf->banque->enabled)) { - $nbrows ++; - $nbcols ++; + if (!empty($conf->banque->enabled)) { + $nbrows++; + $nbcols++; } print ''; print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) { - print ''; + print ''; + print ''; + print ''; + if (!empty($conf->banque->enabled)) { + print ''; } - print ''; + print ''; print ''; print ''; // Payments already done (from payment on this expensereport) $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; - $sql.= "c.code as p_code, c.libelle as payment_type,"; - $sql.= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; - $sql.= " WHERE e.rowid = '".$id."'"; - $sql.= " AND p.fk_expensereport = e.rowid"; - $sql.= ' AND e.entity IN ('.getEntity('expensereport').')'; - $sql.= " ORDER BY dp"; + $sql .= "c.code as p_code, c.libelle as payment_type,"; + $sql .= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; + $sql .= " WHERE e.rowid = '".$id."'"; + $sql .= " AND p.fk_expensereport = e.rowid"; + $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; + $sql .= " ORDER BY dp"; $resql = $db->query($sql); if ($resql) @@ -2029,16 +2029,16 @@ print $paymentexpensereportstatic->getNomUrl(1); print ''; print '\n"; - $labeltype=$langs->trans("PaymentType".$objp->p_code)!=("PaymentType".$objp->p_code)?$langs->trans("PaymentType".$objp->p_code):$objp->payment_type; + $labeltype = $langs->trans("PaymentType".$objp->p_code) != ("PaymentType".$objp->p_code) ? $langs->trans("PaymentType".$objp->p_code) : $objp->payment_type; print "\n"; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { $bankaccountstatic->id = $objp->baid; $bankaccountstatic->ref = $objp->baref; $bankaccountstatic->label = $objp->baref; $bankaccountstatic->number = $objp->banumber; - if (! empty($conf->accounting->enabled)) { + if (!empty($conf->accounting->enabled)) { $bankaccountstatic->account_number = $objp->account_number; $accountingjournal = new AccountingJournal($db); @@ -2057,9 +2057,9 @@ $totalpaid += $objp->amount; $i++; } - if (! is_null($totalpaid)) + if (!is_null($totalpaid)) { - $totalpaid = price2num($totalpaid); // Round $totalpaid to fix floating problem after addition into loop + $totalpaid = price2num($totalpaid); // Round $totalpaid to fix floating problem after addition into loop } $remaintopay = price2num($object->total_ttc - $totalpaid); @@ -2076,11 +2076,11 @@ { $cssforamountpaymentcomplete = 'amountpaymentneutral'; } - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; $db->free($resql); } @@ -2098,8 +2098,8 @@ print '
'; - $actiontouse='updateline'; - if (($object->fk_statut==0 || $object->fk_statut==99) && $action != 'editline') $actiontouse='addline'; + $actiontouse = 'updateline'; + if (($object->fk_statut == 0 || $object->fk_statut == 99) && $action != 'editline') $actiontouse = 'addline'; print ''; print ''; @@ -2112,13 +2112,13 @@ if (!empty($object->lines)) { - $i = 0;$total = 0; + $i = 0; $total = 0; print ''; print ''; //print ''; print ''; - if (! empty($conf->projet->enabled)) print ''; + if (!empty($conf->projet->enabled)) print ''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; print ''; print ''; @@ -2155,14 +2155,14 @@ // Date print ''; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { print ''; @@ -2185,7 +2185,7 @@ print ''; // Unit price HT print ''; @@ -2312,7 +2312,7 @@ print $numline; print ''; - print ''; - $filenamelinked=''; + $filenamelinked = ''; if ($line->fk_ecm_files > 0) { $result = $ecmfilesstatic->fetch($line->fk_ecm_files); @@ -2355,7 +2355,7 @@ } } - $tredited='tredited'; + $tredited = 'tredited'; include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_addfile.tpl.php'; include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_linktofile.tpl.php'; @@ -2369,7 +2369,7 @@ print ''; // Select project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { print ''; // Unit price @@ -2441,8 +2441,8 @@ && $user->rights->expensereport->creer) { $colspan = 11; - if (! empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++; - if (! empty($conf->projet->enabled)) $colspan++; + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++; + if (!empty($conf->projet->enabled)) $colspan++; if ($action != 'editline') $colspan++; $nbFiles = $nbLinks = 0; @@ -2452,10 +2452,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); - $arrayoffiles=dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png|'.preg_quote(dol_sanitizeFileName($object->ref.'.pdf'), '/').')$'); + $upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); + $arrayoffiles = dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png|'.preg_quote(dol_sanitizeFileName($object->ref.'.pdf'), '/').')$'); $nbFiles = count($arrayoffiles); - $nbLinks=Link::count($db, $object->element, $object->id); + $nbLinks = Link::count($db, $object->element, $object->id); } // Add line with link to add new file or attach to an existing file @@ -2499,7 +2499,7 @@ print ''; print ''; print ''; - if (! empty($conf->projet->enabled)) print ''; + if (!empty($conf->projet->enabled)) print ''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; print ''; print ''; @@ -2520,18 +2520,18 @@ // Select date print ''; // Select project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { print ''; } - if (! empty($conf->global->MAIN_USE_EXPENSE_IK)) + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print ''; // Unit price net @@ -2568,7 +2568,7 @@ // Quantity print ''; // Picture @@ -2634,7 +2634,7 @@ // Send if ($object->fk_statut > ExpenseReport::STATUS_DRAFT) { //if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expensereport->expensereport_advance->send)) { - print ''; + print ''; //} else // print ''; } @@ -2665,7 +2665,7 @@ * ET fk_user_author == user courant * Afficher : "Enregistrer" / "Modifier" / "Supprimer" */ - if($user->rights->expensereport->creer && $object->fk_statut == ExpenseReport::STATUS_REFUSED) + if ($user->rights->expensereport->creer && $object->fk_statut == ExpenseReport::STATUS_REFUSED) { if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { @@ -2729,16 +2729,16 @@ } // If bank module is used - if ($user->rights->expensereport->to_paid && ! empty($conf->banque->enabled) && $object->fk_statut == ExpenseReport::STATUS_APPROVED) + if ($user->rights->expensereport->to_paid && !empty($conf->banque->enabled) && $object->fk_statut == ExpenseReport::STATUS_APPROVED) { // Pay if ($remaintopay == 0) { - print '
' . $langs->trans('DoPayment') . '
'; + print '
'.$langs->trans('DoPayment').'
'; } else { - print ''; + print ''; } } @@ -2748,7 +2748,7 @@ //if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0) if ($object->paid == 0) { - print '"; + print '"; } } @@ -2773,7 +2773,7 @@ // Clone if ($user->rights->expensereport->creer) { - print ''; + print ''; } /* If draft, validated, cancel, and user can create, he can always delete its card before it is approved */ @@ -2782,7 +2782,7 @@ // Delete print ''; } - elseif($user->rights->expensereport->supprimer && $object->fk_statut != ExpenseReport::STATUS_CLOSED) + elseif ($user->rights->expensereport->supprimer && $object->fk_statut != ExpenseReport::STATUS_CLOSED) { // Delete print ''; @@ -2809,14 +2809,14 @@ print '
'; print ''; // ancre - if($user->rights->expensereport->creer && $action != 'create' && $action != 'edit') + if ($user->rights->expensereport->creer && $action != 'create' && $action != 'edit') { - $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->expensereport->creer; - $delallowed = $user->rights->expensereport->creer; - $var = true; + $filename = dol_sanitizeFileName($object->ref); + $filedir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $user->rights->expensereport->creer; + $delallowed = $user->rights->expensereport->creer; + $var = true; print $formfile->showdocuments('expensereport', $filename, $filedir, $urlsource, $genallowed, $delallowed); $somethingshown = $formfile->numoffiles; } @@ -2832,7 +2832,7 @@ print '
'; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'expensereport', null); @@ -2840,8 +2840,8 @@ } // Presend form -$modelmail='expensereport'; -$defaulttopic='SendExpenseReportRef'; +$modelmail = 'expensereport'; +$defaulttopic = 'SendExpenseReportRef'; $diroutput = $conf->expensereport->dir_output; $trackid = 'exp'.$object->id; diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 7644dbc174881..6b6cfb2911d2b 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -35,15 +35,15 @@ $allowupgrade = false; $checksok = 1; -$setuplang=GETPOST("selectlang", 'aZ09', 3)?GETPOST("selectlang", 'aZ09', 3):$langs->getDefaultLang(); +$setuplang = GETPOST("selectlang", 'aZ09', 3) ?GETPOST("selectlang", 'aZ09', 3) : $langs->getDefaultLang(); $langs->setDefaultLang($setuplang); $langs->load("install"); // Now we load forced/pre-set values from install.forced.php file. -$useforcedwizard=false; -$forcedfile="./install.forced.php"; -if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; +$useforcedwizard = false; +$forcedfile = "./install.forced.php"; +if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; @@ -56,7 +56,7 @@ * View */ -pHeader('', ''); // No next step for navigation buttons. Next step is defined by click on links. +pHeader('', ''); // No next step for navigation buttons. Next step is defined by click on links. //print "
\n"; @@ -65,28 +65,28 @@ print '

Database '.$langs->trans("MiscellaneousChecks").":

\n"; // Check browser -$useragent=$_SERVER['HTTP_USER_AGENT']; -if (! empty($useragent)) +$useragent = $_SERVER['HTTP_USER_AGENT']; +if (!empty($useragent)) { - $tmp=getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); - $browserversion=$tmp['browserversion']; - $browsername=$tmp['browsername']; + $tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]); + $browserversion = $tmp['browserversion']; + $browsername = $tmp['browsername']; if ($browsername == 'ie' && $browserversion < 7) print 'Error '.$langs->trans("WarningBrowserTooOld")."
\n"; } // Check PHP version -$arrayphpminversionerror = array(5,5,0); -$arrayphpminversionwarning = array(5,5,0); +$arrayphpminversionerror = array(5, 5, 0); +$arrayphpminversionwarning = array(5, 5, 0); if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) // Minimum to use (error if lower) { print 'Error '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror)); - $checksok=0; // 0=error, 1=warning + $checksok = 0; // 0=error, 1=warning } elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) // Minimum supported (warning if lower) { print 'Error '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning)); - $checksok=0; // 0=error, 1=warning + $checksok = 0; // 0=error, 1=warning } else { @@ -97,12 +97,12 @@ // Check PHP support for $_POST -if (! isset($_GET["testget"]) && ! isset($_POST["testpost"])) +if (!isset($_GET["testget"]) && !isset($_POST["testpost"])) { print 'Warning '.$langs->trans("PHPSupportPOSTGETKo"); print ' ('.$langs->trans("Recheck").')'; print "
\n"; - $checksok=0; + $checksok = 0; } else { @@ -111,10 +111,10 @@ // Check if sessions enabled -if (! function_exists("session_id")) +if (!function_exists("session_id")) { print 'Error '.$langs->trans("ErrorPHPDoesNotSupportSessions")."
\n"; - $checksok=0; + $checksok = 0; } else { @@ -123,7 +123,7 @@ // Check if GD supported (we need GD for image conversion) -if (! function_exists("imagecreate")) +if (!function_exists("imagecreate")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportGD")."
\n"; @@ -136,7 +136,7 @@ // Check if Curl supported -if (! function_exists("curl_init")) +if (!function_exists("curl_init")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportCurl")."
\n"; @@ -148,7 +148,7 @@ } // Check if PHP calendar extension is available -if (! function_exists("easter_date")) +if (!function_exists("easter_date")) { print 'Error '.$langs->trans("ErrorPHPDoesNotSupportCalendar")."
\n"; } @@ -159,7 +159,7 @@ // Check if UTF8 supported -if (! function_exists("utf8_encode")) +if (!function_exists("utf8_encode")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportUTF8")."
\n"; @@ -174,7 +174,7 @@ // Check if intl methods are supported if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') { - if (! function_exists("locale_get_primary_language") || ! function_exists("locale_get_region")) + if (!function_exists("locale_get_primary_language") || !function_exists("locale_get_region")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportIntl")."
\n"; @@ -188,18 +188,18 @@ // Check memory -$memrequiredorig='64M'; -$memrequired=64*1024*1024; -$memmaxorig=@ini_get("memory_limit"); -$memmax=@ini_get("memory_limit"); +$memrequiredorig = '64M'; +$memrequired = 64 * 1024 * 1024; +$memmaxorig = @ini_get("memory_limit"); +$memmax = @ini_get("memory_limit"); if ($memmaxorig != '') { preg_match('/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg); if ($reg[2]) { - if (strtoupper($reg[2]) == 'G') $memmax=$reg[1]*1024*1024*1024; - if (strtoupper($reg[2]) == 'M') $memmax=$reg[1]*1024*1024; - if (strtoupper($reg[2]) == 'K') $memmax=$reg[1]*1024; + if (strtoupper($reg[2]) == 'G') $memmax = $reg[1] * 1024 * 1024 * 1024; + if (strtoupper($reg[2]) == 'M') $memmax = $reg[1] * 1024 * 1024; + if (strtoupper($reg[2]) == 'K') $memmax = $reg[1] * 1024; } if ($memmax >= $memrequired || $memmax == -1) { @@ -216,37 +216,37 @@ clearstatcache(); if (is_readable($conffile) && filesize($conffile) > 8) { - dolibarr_install_syslog("check: conf file '" . $conffile . "' already defined"); - $confexists=1; + dolibarr_install_syslog("check: conf file '".$conffile."' already defined"); + $confexists = 1; include_once $conffile; - $databaseok=1; + $databaseok = 1; if ($databaseok) { // Already installed for all parts (config and database). We can propose upgrade. - $allowupgrade=true; + $allowupgrade = true; } else { - $allowupgrade=false; + $allowupgrade = false; } } else { // If not, we create it - dolibarr_install_syslog("check: we try to create conf file '" . $conffile . "'"); - $confexists=0; + dolibarr_install_syslog("check: we try to create conf file '".$conffile."'"); + $confexists = 0; // First we try by copying example if (@copy($conffile.".example", $conffile)) { // Success - dolibarr_install_syslog("check: successfully copied file " . $conffile . ".example into " . $conffile); + dolibarr_install_syslog("check: successfully copied file ".$conffile.".example into ".$conffile); } else { // If failed, we try to create an empty file - dolibarr_install_syslog("check: failed to copy file " . $conffile . ".example into " . $conffile . ". We try to create it.", LOG_WARNING); + dolibarr_install_syslog("check: failed to copy file ".$conffile.".example into ".$conffile.". We try to create it.", LOG_WARNING); $fp = @fopen($conffile, "w"); if ($fp) @@ -255,17 +255,17 @@ @fputs($fp, "\n"); fclose($fp); } - else dolibarr_install_syslog("check: failed to create a new file " . $conffile . " into current dir " . getcwd() . ". Please check permissions.", LOG_ERR); + else dolibarr_install_syslog("check: failed to create a new file ".$conffile." into current dir ".getcwd().". Please check permissions.", LOG_ERR); } // First install: no upgrade necessary/required - $allowupgrade=false; + $allowupgrade = false; } // File is missing and cannot be created -if (! file_exists($conffile)) +if (!file_exists($conffile)) { print 'Error '.$langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow); print "

"; @@ -281,7 +281,7 @@ { print 'Warning '.$langs->trans("ConfFileMustBeAFileNotADir", $conffiletoshow); - $allowinstall=0; + $allowinstall = 0; } // File exists but cannot be modified elseif (!is_writable($conffile)) @@ -298,7 +298,7 @@ print 'Warning '.$langs->trans("ConfFileIsNotWritable", $conffiletoshow); print "
\n"; - $allowinstall=0; + $allowinstall = 0; } // File exists and can be modified else @@ -315,37 +315,37 @@ print 'Ok '.$langs->trans("ConfFileIsWritable", $conffiletoshow); print "
\n"; - $allowinstall=1; + $allowinstall = 1; } print "
\n"; // Requirements met/all ok: display the next step button if ($checksok) { - $ok=0; + $ok = 0; // Try to create db connection if (file_exists($conffile)) { include_once $conffile; - if (! empty($dolibarr_main_db_type) && ! empty($dolibarr_main_document_root)) + if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) { - if (! file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php")) + if (!file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php")) { print 'A '.$conffiletoshow.' file exists with a dolibarr_main_document_root to '.$dolibarr_main_document_root.' that seems wrong. Try to fix or remove the '.$conffiletoshow.' file.
'."\n"; - dol_syslog("A '" . $conffiletoshow . "' file exists with a dolibarr_main_document_root to " . $dolibarr_main_document_root . " that seems wrong. Try to fix or remove the '" . $conffiletoshow . "' file.", LOG_WARNING); + dol_syslog("A '".$conffiletoshow."' file exists with a dolibarr_main_document_root to ".$dolibarr_main_document_root." that seems wrong. Try to fix or remove the '".$conffiletoshow."' file.", LOG_WARNING); } else { require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; // If password is encoded, we decode it - if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass)) + if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) { - $dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially crypted + $dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially crypted $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); @@ -358,10 +358,10 @@ $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; - $db=getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); + $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); if ($db->connected && $db->database_selected) { - $ok=true; + $ok = true; } } } @@ -370,26 +370,26 @@ // If database access is available, we set more variables if ($ok) { - if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0; + if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; - if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey=''; + if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; $conf->setValues($db); // Reset forced setup after the setValues - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE=constant('SYSLOG_FILE'); + if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE // Version to install is DOL_VERSION - $dolibarrlastupgradeversionarray=preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL)?$conf->global->MAIN_VERSION_LAST_INSTALL:'')); - $dolibarrversiontoinstallarray=versiondolibarrarray(); + $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : '')); + $dolibarrversiontoinstallarray = versiondolibarrarray(); } // Show title - if (! empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ! empty($conf->global->MAIN_VERSION_LAST_INSTALL)) + if (!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || !empty($conf->global->MAIN_VERSION_LAST_INSTALL)) { - print $langs->trans("VersionLastUpgrade").': '.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_INSTALL:$conf->global->MAIN_VERSION_LAST_UPGRADE).' - '; + print $langs->trans("VersionLastUpgrade").': '.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE).' - '; print $langs->trans("VersionProgram").': '.DOL_VERSION.''; //print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired")); print '
'; @@ -400,7 +400,7 @@ //print $langs->trans("InstallEasy")." "; print '

'.$langs->trans("ChooseYourSetupMode").'

'; - $foundrecommandedchoice=0; + $foundrecommandedchoice = 0; $available_choices = array(); $notavailable_choices = array(); @@ -417,7 +417,7 @@ //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE); $choice .= '
'.$langs->trans("InstallChoiceSuggested").'
'; // Ok '; - $foundrecommandedchoice=1; // To show only once + $foundrecommandedchoice = 1; // To show only once } $choice .= ''; @@ -441,14 +441,14 @@ } // Show upgrade lines - $allowupgrade=true; + $allowupgrade = true; if (empty($dolibarr_main_db_host)) // This means install process was not run { - $allowupgrade=false; + $allowupgrade = false; } - if (defined("MAIN_NOT_INSTALLED")) $allowupgrade=false; - if (GETPOST('allowupgrade')) $allowupgrade=true; - $migrationscript=array( array('from'=>'3.0.0', 'to'=>'3.1.0'), + if (defined("MAIN_NOT_INSTALLED")) $allowupgrade = false; + if (GETPOST('allowupgrade')) $allowupgrade = true; + $migrationscript = array(array('from'=>'3.0.0', 'to'=>'3.1.0'), array('from'=>'3.1.0', 'to'=>'3.2.0'), array('from'=>'3.2.0', 'to'=>'3.3.0'), array('from'=>'3.3.0', 'to'=>'3.4.0'), @@ -467,26 +467,26 @@ array('from'=>'10.0.0', 'to'=>'11.0.0') ); - $count=0; + $count = 0; foreach ($migrationscript as $migarray) { $choice = ''; $count++; $recommended_choice = false; - $version=DOL_VERSION; - $versionfrom=$migarray['from']; - $versionto=$migarray['to']; - $versionarray=preg_split('/[\.-]/', $version); - $dolibarrversionfromarray=preg_split('/[\.-]/', $versionfrom); - $dolibarrversiontoarray=preg_split('/[\.-]/', $versionto); + $version = DOL_VERSION; + $versionfrom = $migarray['from']; + $versionto = $migarray['to']; + $versionarray = preg_split('/[\.-]/', $version); + $dolibarrversionfromarray = preg_split('/[\.-]/', $versionfrom); + $dolibarrversiontoarray = preg_split('/[\.-]/', $versionto); // Define string newversionxxx that are used for text to show - $newversionfrom=preg_replace('/(\.[0-9]+)$/i', '.*', $versionfrom); - $newversionto=preg_replace('/(\.[0-9]+)$/i', '.*', $versionto); - $newversionfrombis=''; + $newversionfrom = preg_replace('/(\.[0-9]+)$/i', '.*', $versionfrom); + $newversionto = preg_replace('/(\.[0-9]+)$/i', '.*', $versionto); + $newversionfrombis = ''; if (versioncompare($dolibarrversiontoarray, $versionarray) < -2) // From x.y.z -> x.y.z+1 { - $newversionfrombis=' '.$langs->trans("or").' '.$versionto; + $newversionfrombis = ' '.$langs->trans("or").' '.$versionto; } if ($ok) @@ -498,7 +498,7 @@ (versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray, $versionarray) < -2) ) { - $foundrecommandedchoice=1; // To show only once + $foundrecommandedchoice = 1; // To show only once $recommended_choice = true; } } @@ -519,7 +519,7 @@ $choice .= '
'; //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE); $choice .= '
'; - $choice .= '
'.$langs->trans("InstallChoiceSuggested").'
'; + $choice .= '
'.$langs->trans("InstallChoiceSuggested").'
'; if ($count < count($migarray)) // There are other choices after { print $langs->trans("MigrateIsDoneStepByStep", DOL_VERSION); @@ -531,10 +531,10 @@ $choice .= '
' . $langs->trans('Payments') . '' . $langs->trans('Date') . '' . $langs->trans('Type') . '' . $langs->trans('BankAccount') . ''.$langs->trans('Payments').''.$langs->trans('Date').''.$langs->trans('Type').''.$langs->trans('BankAccount').'' . $langs->trans('Amount') . ''.$langs->trans('Amount').' 
'.dol_print_date($db->jdate($objp->dp), 'day')."".$labeltype.' '.$objp->num_payment."
'.$langs->trans("AlreadyPaid").':'.price($totalpaid).'
'.$langs->trans("AmountExpected").':'.price($object->total_ttc).'
'.$langs->trans("AlreadyPaid").':'.price($totalpaid).'
'.$langs->trans("AmountExpected").':'.price($object->total_ttc).'
'.$langs->trans("RemainderToPay").':'.price($resteapayeraffiche).'
'.$langs->trans("RemainderToPay").':'.price($resteapayeraffiche).'
'.$langs->trans('LineNb').''.$langs->trans('Piece').''.$langs->trans('Date').''.$langs->trans('Project').''.$langs->trans('Project').''.$langs->trans('CarCategory').''.$langs->trans('Type').''.$langs->trans('Description').''.dol_print_date($db->jdate($line->date), 'day').''; if ($line->fk_project > 0) { - $projecttmp->id=$line->fk_project; - $projecttmp->ref=$line->projet_ref; - $projecttmp->title=$line->projet_title; + $projecttmp->id = $line->fk_project; + $projecttmp->ref = $line->projet_ref; + $projecttmp->title = $line->projet_title; print $projecttmp->getNomUrl(1); } print ''.vatrate($line->vatrate, true).''; - if (! empty($line->value_unit_ht)) + if (!empty($line->value_unit_ht)) { print price($line->value_unit_ht); } @@ -2211,33 +2211,33 @@ print ''; if ($line->fk_ecm_files > 0) { - $modulepart='expensereport'; - $maxheightmini=32; + $modulepart = 'expensereport'; + $maxheightmini = 32; $result = $ecmfilesstatic->fetch($line->fk_ecm_files); if ($result > 0) { - $relativepath=preg_replace('/expensereport\//', '', $ecmfilesstatic->filepath); + $relativepath = preg_replace('/expensereport\//', '', $ecmfilesstatic->filepath); $fileinfo = pathinfo($ecmfilesstatic->filepath.'/'.$ecmfilesstatic->filename); if (image_format_supported($fileinfo['basename']) > 0) { - $minifile=getImageFileNameForSize($fileinfo['basename'], '_mini'); // For new thumbs using same ext (in lower case howerver) than original - if (! dol_is_file($conf->expensereport->dir_output.'/'.$relativepath.'/'.$minifile)) $minifile=getImageFileNameForSize($fileinfo['basename'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension + $minifile = getImageFileNameForSize($fileinfo['basename'], '_mini'); // For new thumbs using same ext (in lower case howerver) than original + if (!dol_is_file($conf->expensereport->dir_output.'/'.$relativepath.'/'.$minifile)) $minifile = getImageFileNameForSize($fileinfo['basename'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension //print $file['path'].'/'.$minifile.'
'; - $urlforhref=getAdvancedPreviewUrl($modulepart, $relativepath.'/'.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity)); + $urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.'/'.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); if (empty($urlforhref)) { - $urlforhref=DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); + $urlforhref = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); print ''; } else { print ''; } - print ''; + print ''; print ''; } else { - $modulepart='expensereport'; - $thumbshown=0; + $modulepart = 'expensereport'; + $thumbshown = 0; if (preg_match('/\.pdf$/i', $ecmfilesstatic->filename)) { $filepdf = $conf->expensereport->dir_output.'/'.$relativepath.'/'.$ecmfilesstatic->filename; @@ -2248,31 +2248,31 @@ if ($pdfexists) { // Conversion du PDF en image png si fichier png non existant - if (! file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) + if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) { if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experience trouble with pdf thumb generation and imagick, you can disable here. { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png + $ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png if ($ret < 0) $error++; } } } - if ($pdfexists && ! $error) + if ($pdfexists && !$error) { - $heightforphotref=70; - if (! empty($conf->dol_optimize_smallscreen)) $heightforphotref=60; + $heightforphotref = 70; + if (!empty($conf->dol_optimize_smallscreen)) $heightforphotref = 60; // If the preview file is found if (file_exists($fileimage)) { - $thumbshown=1; - print ''; + $thumbshown = 1; + print ''; } } } - if (! $thumbshown) + if (!$thumbshown) { print img_mime($ecmfilesstatic->filename); } @@ -2303,7 +2303,7 @@ { // Add line with link to add new file or attach line to an existing file $colspan = 10; - if (! empty($conf->projet->enabled)) $colspan++; + if (!empty($conf->projet->enabled)) $colspan++; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++; print '
'; + print ''; print ''.$langs->trans("UploadANewFileNow"); print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); print ''; @@ -2345,7 +2345,7 @@ print ''."\n"; print '
'; $formproject->select_projects(-1, $line->fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); @@ -2396,7 +2396,7 @@ // VAT print ''; - print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$line->vatrate), $mysoc, '', 0, 0, '', false, 1); + print $form->load_tva('vatrate', (isset($_POST["vatrate"]) ? $_POST["vatrate"] : $line->vatrate), $mysoc, '', 0, 0, '', false, 1); print '
'.$langs->trans('Date').''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).''.$langs->trans('CarCategory').''.$langs->trans('Type').''.$langs->trans('Description').''; - print $form->selectDate($date?$date:-1, 'date', 0, 0, 0, '', 1, 1); + print $form->selectDate($date ? $date : -1, 'date', 0, 0, 0, '', 1, 1); print ''; $formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); print ''; $params = array('fk_expense' => $object->id); @@ -2551,9 +2551,9 @@ // Select VAT print ''; - $defaultvat=-1; - if (! empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none'; - print $form->load_tva('vatrate', ($vatrate!=''?$vatrate:$defaultvat), $mysoc, '', 0, 0, '', false, 1); + $defaultvat = -1; + if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none'; + print $form->load_tva('vatrate', ($vatrate != '' ? $vatrate : $defaultvat), $mysoc, '', 0, 0, '', false, 1); print ''; - print ''; // We must be able to enter decimal qty + print ''; // We must be able to enter decimal qty print ''; if ($allowupgrade) { - $disabled=false; + $disabled = false; if ($foundrecommandedchoice == 2) { - $disabled=true; + $disabled = true; } if ($foundrecommandedchoice == 1) { @@ -546,7 +546,7 @@ } else { - $choice .= ''.$langs->trans("Start").''; + $choice .= ''.$langs->trans("Start").''; } } else @@ -566,8 +566,8 @@ // If there is no choice at all, we show all of them. if (empty($available_choices)) { - $available_choices=$notavailable_choices; - $notavailable_choices=array(); + $available_choices = $notavailable_choices; + $notavailable_choices = array(); } // Array of install choices @@ -621,4 +621,4 @@ '; dolibarr_install_syslog("- check: end"); -pFooter(1); // Never display next button +pFooter(1); // Never display next button diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 49574ede47678..efb3013bd6d6a 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -23,7 +23,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -89,27 +89,27 @@ class MyObject extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), - 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1), - 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'), - 'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'), + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1), + 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'), + 'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), 'fk_project' =>array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1), - 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60), - 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), - 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), - 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501), + 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60), + 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), + 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), + 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501), //'date_validation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid'), - 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid'), + 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), - 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'notnull'=>-1, 'position'=>1010), - 'status' =>array('type'=>'smallint', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled')), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), + 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'notnull'=>-1, 'position'=>1010), + 'status' =>array('type'=>'smallint', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled')), ); /** @@ -214,11 +214,11 @@ public function __construct(DoliDB $db) $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; // Unset fields that are disabled - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { @@ -274,7 +274,7 @@ public function createFromClone(User $user, $fromid) // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines(); + if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); // get lines so they will be clone //foreach($this->lines as $line) @@ -287,18 +287,18 @@ public function createFromClone(User $user, $fromid) // Clear fields - $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref: $this->fields['ref']['default']; - $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref : $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach($object->array_options as $key => $option) + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); @@ -315,7 +315,7 @@ public function createFromClone(User $user, $fromid) $this->errors = $object->errors; } - if (! $error) + if (!$error) { // copy internal contacts if ($this->copy_linked_contact($object, 'internal') < 0) @@ -324,7 +324,7 @@ public function createFromClone(User $user, $fromid) } } - if (! $error) + if (!$error) { // copy external contacts if same company if (property_exists($this, 'socid') && $this->socid == $object->socid) @@ -356,7 +356,7 @@ public function createFromClone(User $user, $fromid) public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); return $result; } @@ -367,7 +367,7 @@ public function fetch($id, $ref = null) */ public function fetchLines() { - $this->lines=array(); + $this->lines = array(); $result = $this->fetchLinesCommon(); return $result; @@ -391,40 +391,40 @@ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = dol_syslog(__METHOD__, LOG_DEBUG); - $records=array(); + $records = array(); $sql = 'SELECT '; $sql .= $this->getFieldList(); - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; else $sql .= ' WHERE 1 = 1'; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key=='t.rowid') { - $sqlwhere[] = $key . '='. $value; + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; } - elseif ($key=='customsql') { + elseif ($key == 'customsql') { $sqlwhere[] = $value; } else { - $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } } if (count($sqlwhere) > 0) { - $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); + $sql .= ' '.$this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); @@ -446,8 +446,8 @@ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = return $records; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); return -1; } @@ -587,51 +587,51 @@ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss { global $conf, $langs, $hookmanager; - 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 = ''; - $label = '' . $langs->trans("MyObject") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("MyObject").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowMyObject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; + global $action, $hookmanager; $hookmanager->initHooks(array('myobjectdao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -687,10 +687,10 @@ public function LibStatut($status, $mode = 0) public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -701,7 +701,7 @@ public function info($id) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) @@ -715,7 +715,7 @@ public function info($id) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); @@ -749,7 +749,7 @@ public function initAsSpecimen() */ public function getLinesArray() { - $this->lines=array(); + $this->lines = array(); $objectline = new MyObjectLine($this->db); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_myobject = '.$this->id)); @@ -780,16 +780,16 @@ public function getLinesArray() */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("mymodule@mymodule"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'standard'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->MYOBJECT_ADDON_PDF)) { + } elseif (!empty($conf->global->MYOBJECT_ADDON_PDF)) { $modele = $conf->global->MYOBJECT_ADDON_PDF; } } @@ -814,7 +814,7 @@ public function doScheduledJob() $error = 0; $this->output = ''; - $this->error=''; + $this->error = ''; dol_syslog(__METHOD__, LOG_DEBUG); diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index d65f311acbbac..c4ec988b2690a 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -35,21 +35,21 @@ $langs->loadLangs(array('stock', 'other', 'productbatch')); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $batch = GETPOST('batch', 'alpha'); $productid = GETPOST('productid', 'int'); -$ref = GETPOST('ref', 'alpha'); // ref is productid_batch +$ref = GETPOST('ref', 'alpha'); // ref is productid_batch -$search_entity=GETPOST('search_entity', 'int'); -$search_fk_product=GETPOST('search_fk_product', 'int'); -$search_batch=GETPOST('search_batch', 'alpha'); -$search_fk_user_creat=GETPOST('search_fk_user_creat', 'int'); -$search_fk_user_modif=GETPOST('search_fk_user_modif', 'int'); -$search_import_key=GETPOST('search_import_key', 'int'); +$search_entity = GETPOST('search_entity', 'int'); +$search_fk_product = GETPOST('search_fk_product', 'int'); +$search_batch = GETPOST('search_batch', 'alpha'); +$search_fk_user_creat = GETPOST('search_fk_user_creat', 'int'); +$search_fk_user_modif = GETPOST('search_fk_user_modif', 'int'); +$search_import_key = GETPOST('search_import_key', 'int'); -if (empty($action) && empty($id) && empty($ref)) $action='list'; +if (empty($action) && empty($id) && empty($ref)) $action = 'list'; // Protection if external user @@ -73,21 +73,21 @@ { if ($ref) { - $tmp=explode('_', $ref); - $productid=$tmp[0]; - $batch=$tmp[1]; + $tmp = explode('_', $ref); + $productid = $tmp[0]; + $batch = $tmp[1]; } $object->fetch($id, $productid, $batch); $object->ref = $object->batch; // For document management ( it use $object->ref) } // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('productlotcard','globalcard')); +$hookmanager->initHooks(array('productlotcard', 'globalcard')); -$permissionnote = $user->rights->stock->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->stock->creer; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->rights->stock->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->rights->stock->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->stock->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->rights->stock->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $usercanread = $user->rights->produit->lire; $usercancreate = $user->rights->produit->creer; @@ -97,8 +97,8 @@ * Actions */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$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)) @@ -112,7 +112,7 @@ if ($action == 'setsellby' && $user->rights->stock->creer) { - $newvalue=dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); + $newvalue = dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); $result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) dol_print_error($db, $object->error); } @@ -125,7 +125,7 @@ $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('PRODUCT_LOT_MODIFY'); @@ -145,21 +145,21 @@ { if (GETPOST('cancel', 'alpha')) { - $urltogo=$backtopage?$backtopage:dol_buildpath('/stock/list.php', 1); + $urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1); header("Location: ".$urltogo); exit; } - $error=0; + $error = 0; /* object_prop_getpost_prop */ - $object->entity=GETPOST('entity', 'int'); - $object->fk_product=GETPOST('fk_product', 'int'); - $object->batch=GETPOST('batch', 'alpha'); - $object->fk_user_creat=GETPOST('fk_user_creat', 'int'); - $object->fk_user_modif=GETPOST('fk_user_modif', 'int'); - $object->import_key=GETPOST('import_key', 'int'); + $object->entity = GETPOST('entity', 'int'); + $object->fk_product = GETPOST('fk_product', 'int'); + $object->batch = GETPOST('batch', 'alpha'); + $object->fk_user_creat = GETPOST('fk_user_creat', 'int'); + $object->fk_user_modif = GETPOST('fk_user_modif', 'int'); + $object->import_key = GETPOST('import_key', 'int'); if (empty($object->ref)) { @@ -167,43 +167,43 @@ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); } - if (! $error) + if (!$error) { - $result=$object->create($user); + $result = $object->create($user); if ($result > 0) { // Creation OK - $urltogo=$backtopage?$backtopage:dol_buildpath('/stock/list.php', 1); + $urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1); header("Location: ".$urltogo); exit; } { // 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'; } } // Cancel - if ($action == 'update' && GETPOST('cancel', 'alpha')) $action='view'; + if ($action == 'update' && GETPOST('cancel', 'alpha')) $action = 'view'; // Action to update record - if ($action == 'update' && ! GETPOST('cancel', 'alpha')) + if ($action == 'update' && !GETPOST('cancel', 'alpha')) { - $error=0; + $error = 0; - $object->entity=GETPOST('entity', 'int'); - $object->fk_product=GETPOST('fk_product', 'int'); - $object->batch=GETPOST('batch', 'alpha'); - $object->fk_user_creat=GETPOST('fk_user_creat', 'int'); - $object->fk_user_modif=GETPOST('fk_user_modif', 'int'); - $object->import_key=GETPOST('import_key', 'int'); + $object->entity = GETPOST('entity', 'int'); + $object->fk_product = GETPOST('fk_product', 'int'); + $object->batch = GETPOST('batch', 'alpha'); + $object->fk_user_creat = GETPOST('fk_user_creat', 'int'); + $object->fk_user_modif = GETPOST('fk_user_modif', 'int'); + $object->import_key = GETPOST('import_key', 'int'); if (empty($object->ref)) { @@ -211,31 +211,31 @@ setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); } - if (! $error) + if (!$error) { - $result=$object->update($user); + $result = $object->update($user); if ($result > 0) { - $action='view'; + $action = 'view'; } 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='edit'; + $action = 'edit'; } } else { - $action='edit'; + $action = 'edit'; } } // Action to delete if ($action == 'confirm_delete') { - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { // Delete OK @@ -245,7 +245,7 @@ } 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'); } } @@ -265,7 +265,7 @@ llxHeader('', 'ProductLot', ''); -$form=new Form($db); +$form = new Form($db); // Part to create @@ -310,15 +310,15 @@ if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteBatch'), $langs->trans('ConfirmDeleteBatch'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBatch'), $langs->trans('ConfirmDeleteBatch'), 'confirm_delete', '', 0, 1); print $formconfirm; } - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->socid && ! in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('batch', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch'); @@ -352,7 +352,7 @@ // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'; @@ -363,8 +363,8 @@ // Buttons print '
'."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -403,12 +403,12 @@ // Documents $filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product_batch').dol_sanitizeFileName($object->ref); - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$usercanread; - $delallowed=$usercancreate; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $usercanread; + $delallowed = $usercancreate; print $formfile->showdocuments('product_batch', dol_sanitizeFileName($object->ref), $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); - $somethingshown=$formfile->numoffiles; + $somethingshown = $formfile->numoffiles; print '
'; } diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index c10e9915c3bdf..bc12236731296 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -35,17 +35,17 @@ class Task extends CommonObject /** * @var string ID to identify managed object */ - public $element='project_task'; + public $element = 'project_task'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='projet_task'; + public $table_element = 'projet_task'; /** * @var int Field with ID of parent key if this field has a parent */ - public $fk_element='fk_task'; + public $fk_element = 'fk_task'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -55,7 +55,7 @@ class Task extends CommonObject /** * @var array List of child tables. To test if we can delete object. */ - protected $childtables=array('projet_task_time'); + protected $childtables = array('projet_task_time'); /** * @var int ID parent task @@ -72,7 +72,7 @@ class Task extends CommonObject */ public $description; - public $duration_effective; // total of time spent on this task + public $duration_effective; // total of time spent on this task public $planned_workload; public $date_c; public $date_start; @@ -111,8 +111,8 @@ class Task extends CommonObject public $timespent_duration; public $timespent_old_duration; public $timespent_date; - public $timespent_datehour; // More accurate start date (same than timespent_date but includes hours, minutes and seconds) - public $timespent_withhour; // 1 = we entered also start hours for timesheet line + public $timespent_datehour; // More accurate start date (same than timespent_date but includes hours, minutes and seconds) + public $timespent_withhour; // 1 = we entered also start hours for timesheet line public $timespent_fk_user; public $timespent_note; @@ -143,7 +143,7 @@ public function create($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters $this->label = trim($this->label); @@ -154,56 +154,56 @@ public function create($user, $notrigger = 0) // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task ("; - $sql.= "fk_projet"; - $sql.= ", ref"; - $sql.= ", fk_task_parent"; - $sql.= ", label"; - $sql.= ", description"; - $sql.= ", datec"; - $sql.= ", fk_user_creat"; - $sql.= ", dateo"; - $sql.= ", datee"; - $sql.= ", planned_workload"; - $sql.= ", progress"; - $sql.= ") VALUES ("; - $sql.= $this->fk_project; - $sql.= ", ".(!empty($this->ref)?"'".$this->db->escape($this->ref)."'":'null'); - $sql.= ", ".$this->fk_task_parent; - $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", '".$this->db->escape($this->description)."'"; - $sql.= ", '".$this->db->idate($this->date_c)."'"; - $sql.= ", ".$user->id; - $sql.= ", ".($this->date_start!=''?"'".$this->db->idate($this->date_start)."'":'null'); - $sql.= ", ".($this->date_end!=''?"'".$this->db->idate($this->date_end)."'":'null'); - $sql.= ", ".(($this->planned_workload!='' && $this->planned_workload >= 0)?$this->planned_workload:'null'); - $sql.= ", ".(($this->progress!='' && $this->progress >= 0)?$this->progress:'null'); - $sql.= ")"; + $sql .= "fk_projet"; + $sql .= ", ref"; + $sql .= ", fk_task_parent"; + $sql .= ", label"; + $sql .= ", description"; + $sql .= ", datec"; + $sql .= ", fk_user_creat"; + $sql .= ", dateo"; + $sql .= ", datee"; + $sql .= ", planned_workload"; + $sql .= ", progress"; + $sql .= ") VALUES ("; + $sql .= $this->fk_project; + $sql .= ", ".(!empty($this->ref) ? "'".$this->db->escape($this->ref)."'" : 'null'); + $sql .= ", ".$this->fk_task_parent; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", '".$this->db->escape($this->description)."'"; + $sql .= ", '".$this->db->idate($this->date_c)."'"; + $sql .= ", ".$user->id; + $sql .= ", ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); + $sql .= ", ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); + $sql .= ", ".(($this->planned_workload != '' && $this->planned_workload >= 0) ? $this->planned_workload : 'null'); + $sql .= ", ".(($this->progress != '' && $this->progress >= 0) ? $this->progress : 'null'); + $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task"); - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('TASK_CREATE', $user); + $result = $this->call_trigger('TASK_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } } // Update extrafield - if (! $error) + if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -214,13 +214,13 @@ public function create($user, $notrigger = 0) // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$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 { @@ -243,41 +243,41 @@ public function fetch($id, $ref = '', $loadparentdata = 0) global $langs, $conf; $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.ref,"; - $sql.= " t.fk_projet as fk_project,"; - $sql.= " t.fk_task_parent,"; - $sql.= " t.label,"; - $sql.= " t.description,"; - $sql.= " t.duration_effective,"; - $sql.= " t.planned_workload,"; - $sql.= " t.datec,"; - $sql.= " t.dateo,"; - $sql.= " t.datee,"; - $sql.= " t.fk_user_creat,"; - $sql.= " t.fk_user_valid,"; - $sql.= " t.fk_statut,"; - $sql.= " t.progress,"; - $sql.= " t.priority,"; - $sql.= " t.note_private,"; - $sql.= " t.note_public,"; - $sql.= " t.rang"; - if (! empty($loadparentdata)) - { - $sql.=", t2.ref as task_parent_ref"; - $sql.=", t2.rang as task_parent_position"; - } - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as t"; - if (! empty($loadparentdata)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t2 ON t.fk_task_parent = t2.rowid"; - $sql.= " WHERE "; + $sql .= " t.rowid,"; + $sql .= " t.ref,"; + $sql .= " t.fk_projet as fk_project,"; + $sql .= " t.fk_task_parent,"; + $sql .= " t.label,"; + $sql .= " t.description,"; + $sql .= " t.duration_effective,"; + $sql .= " t.planned_workload,"; + $sql .= " t.datec,"; + $sql .= " t.dateo,"; + $sql .= " t.datee,"; + $sql .= " t.fk_user_creat,"; + $sql .= " t.fk_user_valid,"; + $sql .= " t.fk_statut,"; + $sql .= " t.progress,"; + $sql .= " t.priority,"; + $sql .= " t.note_private,"; + $sql .= " t.note_public,"; + $sql .= " t.rang"; + if (!empty($loadparentdata)) + { + $sql .= ", t2.ref as task_parent_ref"; + $sql .= ", t2.rang as task_parent_position"; + } + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t"; + if (!empty($loadparentdata)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t2 ON t.fk_task_parent = t2.rowid"; + $sql .= " WHERE "; if (!empty($ref)) { - $sql.="t.ref = '".$this->db->escape($ref)."'"; - }else { - $sql.="t.rowid = ".$id; + $sql .= "t.ref = '".$this->db->escape($ref)."'"; + } else { + $sql .= "t.rowid = ".$id; } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num_rows = $this->db->num_rows($resql); @@ -286,27 +286,27 @@ public function fetch($id, $ref = '', $loadparentdata = 0) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->fk_project = $obj->fk_project; - $this->fk_task_parent = $obj->fk_task_parent; - $this->label = $obj->label; - $this->description = $obj->description; - $this->duration_effective = $obj->duration_effective; - $this->planned_workload = $obj->planned_workload; - $this->date_c = $this->db->jdate($obj->datec); - $this->date_start = $this->db->jdate($obj->dateo); + $this->id = $obj->rowid; + $this->ref = $obj->ref; + $this->fk_project = $obj->fk_project; + $this->fk_task_parent = $obj->fk_task_parent; + $this->label = $obj->label; + $this->description = $obj->description; + $this->duration_effective = $obj->duration_effective; + $this->planned_workload = $obj->planned_workload; + $this->date_c = $this->db->jdate($obj->datec); + $this->date_start = $this->db->jdate($obj->dateo); $this->date_end = $this->db->jdate($obj->datee); $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_valid = $obj->fk_user_valid; $this->fk_statut = $obj->fk_statut; $this->progress = $obj->progress; $this->priority = $obj->priority; - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; - $this->rang = $obj->rang; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->rang = $obj->rang; - if (! empty($loadparentdata)) + if (!empty($loadparentdata)) { $this->task_parent_ref = $obj->task_parent_ref; $this->task_parent_position = $obj->task_parent_position; @@ -321,13 +321,13 @@ public function fetch($id, $ref = '', $loadparentdata = 0) if ($num_rows) { return 1; - }else { + } else { return 0; } } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -343,46 +343,46 @@ public function fetch($id, $ref = '', $loadparentdata = 0) public function update($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->fk_project)) $this->fk_project=trim($this->fk_project); - if (isset($this->ref)) $this->ref=trim($this->ref); + if (isset($this->fk_project)) $this->fk_project = trim($this->fk_project); + if (isset($this->ref)) $this->ref = trim($this->ref); if (isset($this->fk_task_parent)) $this->fk_task_parent = (int) $this->fk_task_parent; - if (isset($this->label)) $this->label=trim($this->label); - if (isset($this->description)) $this->description=trim($this->description); - if (isset($this->duration_effective)) $this->duration_effective=trim($this->duration_effective); - if (isset($this->planned_workload)) $this->planned_workload=trim($this->planned_workload); + if (isset($this->label)) $this->label = trim($this->label); + if (isset($this->description)) $this->description = trim($this->description); + if (isset($this->duration_effective)) $this->duration_effective = trim($this->duration_effective); + if (isset($this->planned_workload)) $this->planned_workload = trim($this->planned_workload); // Check parameters // Put here code to add control on parameters values // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; - $sql.= " fk_projet=".(isset($this->fk_project)?$this->fk_project:"null").","; - $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"'".$this->db->escape($this->id)."'").","; - $sql.= " fk_task_parent=".(isset($this->fk_task_parent)?$this->fk_task_parent:"null").","; - $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; - $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; - $sql.= " duration_effective=".(isset($this->duration_effective)?$this->duration_effective:"null").","; - $sql.= " planned_workload=".((isset($this->planned_workload) && $this->planned_workload != '')?$this->planned_workload:"null").","; - $sql.= " dateo=".($this->date_start!=''?"'".$this->db->idate($this->date_start)."'":'null').","; - $sql.= " datee=".($this->date_end!=''?"'".$this->db->idate($this->date_end)."'":'null').","; - $sql.= " progress=".(($this->progress!='' && $this->progress >= 0)?$this->progress:'null').","; - $sql.= " rang=".((!empty($this->rang))?$this->rang:"0"); - $sql.= " WHERE rowid=".$this->id; + $sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").","; + $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "'".$this->db->escape($this->id)."'").","; + $sql .= " fk_task_parent=".(isset($this->fk_task_parent) ? $this->fk_task_parent : "null").","; + $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; + $sql .= " description=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; + $sql .= " duration_effective=".(isset($this->duration_effective) ? $this->duration_effective : "null").","; + $sql .= " planned_workload=".((isset($this->planned_workload) && $this->planned_workload != '') ? $this->planned_workload : "null").","; + $sql .= " dateo=".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null').","; + $sql .= " datee=".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null').","; + $sql .= " progress=".(($this->progress != '' && $this->progress >= 0) ? $this->progress : 'null').","; + $sql .= " rang=".((!empty($this->rang)) ? $this->rang : "0"); + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } // Update extrafield - if (! $error) { + if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -390,18 +390,18 @@ public function update($user = null, $notrigger = 0) } } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('TASK_MODIFY', $user); + $result = $this->call_trigger('TASK_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } } - if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) + if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) { // We remove directory if ($conf->projet->dir_output) @@ -413,12 +413,12 @@ public function update($user = null, $notrigger = 0) $newdir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($this->ref); if (file_exists($olddir)) { - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $res=dol_move($olddir, $newdir); - if (! $res) + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $res = dol_move($olddir, $newdir); + if (!$res) { $langs->load("errors"); - $this->error=$langs->trans('ErrorFailToRenameDir', $olddir, $newdir); + $this->error = $langs->trans('ErrorFailToRenameDir', $olddir, $newdir); $error++; } } @@ -428,13 +428,13 @@ public function update($user = null, $notrigger = 0) // 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 { @@ -455,75 +455,75 @@ public function delete($user, $notrigger = 0) { global $conf, $langs; - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; + $error = 0; $this->db->begin(); if ($this->hasChildren() > 0) { dol_syslog(get_class($this)."::delete Can't delete record as it has some sub tasks", LOG_WARNING); - $this->error='ErrorRecordHasSubTasks'; + $this->error = 'ErrorRecordHasSubTasks'; $this->db->rollback(); return 0; } $objectisused = $this->isObjectUsed($this->id); - if (! empty($objectisused)) + if (!empty($objectisused)) { dol_syslog(get_class($this)."::delete Can't delete record as it has some child", LOG_WARNING); - $this->error='ErrorRecordHasChildren'; + $this->error = 'ErrorRecordHasChildren'; $this->db->rollback(); return 0; } - if (! $error) + if (!$error) { // Delete linked contacts $res = $this->delete_linked_contact(); if ($res < 0) { - $this->error='ErrorFailToDeleteLinkedContact'; + $this->error = 'ErrorFailToDeleteLinkedContact'; //$error++; $this->db->rollback(); return 0; } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time"; - $sql.= " WHERE fk_task=".$this->id; + $sql .= " WHERE fk_task=".$this->id; $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) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_extrafields"; - $sql.= " WHERE fk_object=".$this->id; + $sql .= " WHERE fk_object=".$this->id; $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) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $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('TASK_DELETE', $user); + $result = $this->call_trigger('TASK_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -532,27 +532,27 @@ public function delete($user, $notrigger = 0) // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$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 { //Delete associated link file if ($conf->projet->dir_output) { - $projectstatic=new Project($this->db); + $projectstatic = new Project($this->db); $projectstatic->fetch($this->fk_project); - $dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($projectstatic->ref) . '/' . dol_sanitizeFileName($this->id); + $dir = $conf->projet->dir_output."/".dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($this->id); dol_syslog(get_class($this)."::delete dir=".$dir, LOG_DEBUG); if (file_exists($dir)) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $res = @dol_delete_dir_recursive($dir); if (!$res) { @@ -576,24 +576,24 @@ public function delete($user, $notrigger = 0) */ public function hasChildren() { - $error=0; - $ret=0; + $error = 0; + $ret = 0; $sql = "SELECT COUNT(*) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task"; - $sql.= " WHERE fk_task_parent=".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task"; + $sql .= " WHERE fk_task_parent=".$this->id; dol_syslog(get_class($this)."::hasChildren", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } else { - $obj=$this->db->fetch_object($resql); - if ($obj) $ret=$obj->nb; + $obj = $this->db->fetch_object($resql); + if ($obj) $ret = $obj->nb; $this->db->free($resql); } - if (! $error) + if (!$error) { return $ret; } @@ -610,24 +610,24 @@ public function hasChildren() */ public function hasTimeSpent() { - $error=0; - $ret=0; + $error = 0; + $ret = 0; $sql = "SELECT COUNT(*) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time"; - $sql.= " WHERE fk_task=".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time"; + $sql .= " WHERE fk_task=".$this->id; dol_syslog(get_class($this)."::hasTimeSpent", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } else { - $obj=$this->db->fetch_object($resql); - if ($obj) $ret=$obj->nb; + $obj = $this->db->fetch_object($resql); + if ($obj) $ret = $obj->nb; $this->db->free($resql); } - if (! $error) + if (!$error) { return $ret; } @@ -654,48 +654,48 @@ public function getNomUrl($withpicto = 0, $option = '', $mode = 'task', $addlabe { global $conf, $langs, $user; - 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=''; - $label = '' . $langs->trans("ShowTask") . ''; - if (! empty($this->ref)) - $label .= '
' . $langs->trans('Ref') . ': ' . $this->ref; - if (! empty($this->label)) - $label .= '
' . $langs->trans('LabelTask') . ': ' . $this->label; + $result = ''; + $label = ''.$langs->trans("ShowTask").''; + if (!empty($this->ref)) + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->label)) + $label .= '
'.$langs->trans('LabelTask').': '.$this->label; if ($this->date_start || $this->date_end) { $label .= "
".get_date_range($this->date_start, $this->date_end, '', $langs, 0); } - $url = DOL_URL_ROOT.'/projet/tasks/'.$mode.'.php?id='.$this->id.($option=='withproject'?'&withproject=1':''); + $url = DOL_URL_ROOT.'/projet/tasks/'.$mode.'.php?id='.$this->id.($option == 'withproject' ? '&withproject=1' : ''); // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowTask"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowTask"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; - $picto='projecttask'; + $picto = 'projecttask'; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; - if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + if ($withpicto != 2) $result .= (($addlabel && $this->label) ? $sep.dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); return $result; } @@ -709,17 +709,17 @@ public function getNomUrl($withpicto = 0, $option = '', $mode = 'task', $addlabe */ public function initAsSpecimen() { - $this->id=0; - - $this->fk_project=''; - $this->ref='TK01'; - $this->fk_task_parent=null; - $this->label='Specimen task TK01'; - $this->duration_effective=''; - $this->fk_user_creat=null; - $this->progress='25'; - $this->fk_statut=null; - $this->note='This is a specimen task not'; + $this->id = 0; + + $this->fk_project = ''; + $this->ref = 'TK01'; + $this->fk_task_parent = null; + $this->label = 'Specimen task TK01'; + $this->duration_effective = ''; + $this->fk_user_creat = null; + $this->progress = '25'; + $this->fk_statut = null; + $this->note = 'This is a specimen task not'; } /** @@ -750,123 +750,123 @@ public function getTasksArray($usert = null, $userp = null, $projectid = 0, $soc // List of tasks (does not care about permissions. Filtering will be done later) $sql = "SELECT "; - if ($filteronprojuser > 0 || $filterontaskuser > 0) $sql.= " DISTINCT"; // We may get several time the same record if user has several roles on same project/task - $sql.= " p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut as projectstatus, p.usage_bill_time,"; - $sql.= " t.rowid as taskid, t.ref as taskref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut as status,"; - $sql.= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang,"; - $sql.= " s.rowid as thirdparty_id, s.nom as thirdparty_name, s.email as thirdparty_email,"; - $sql.= " p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount"; + if ($filteronprojuser > 0 || $filterontaskuser > 0) $sql .= " DISTINCT"; // We may get several time the same record if user has several roles on same project/task + $sql .= " p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut as projectstatus, p.usage_bill_time,"; + $sql .= " t.rowid as taskid, t.ref as taskref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut as status,"; + $sql .= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang,"; + $sql .= " s.rowid as thirdparty_id, s.nom as thirdparty_name, s.email as thirdparty_email,"; + $sql .= " p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount"; if (!empty($extrafields->attributes['projet']['label'])) { - foreach ($extrafields->attributes['projet']['label'] as $key => $val) $sql.=($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key.' as options_'.$key : ''); + foreach ($extrafields->attributes['projet']['label'] as $key => $val) $sql .= ($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key.' as options_'.$key : ''); } if (!empty($extrafields->attributes['projet_task']['label'])) { - foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) $sql.=($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key.' as options_'.$key : ''); + foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) $sql .= ($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key.' as options_'.$key : ''); } if ($includebilltime) { - $sql.=", SUM(tt.task_duration * ".$this->db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$this->db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; + $sql .= ", SUM(tt.task_duration * ".$this->db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$this->db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; } - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields as efp ON (p.rowid = efp.fk_object)"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields as efp ON (p.rowid = efp.fk_object)"; if ($mode == 0) { if ($filteronprojuser > 0) { - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; } - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; if ($includebilltime) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } if ($filterontaskuser > 0) { - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec2"; - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec2"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; } - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)"; - $sql.= " WHERE p.entity IN (".getEntity('project').")"; - $sql.= " AND t.fk_projet = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)"; + $sql .= " WHERE p.entity IN (".getEntity('project').")"; + $sql .= " AND t.fk_projet = p.rowid"; } elseif ($mode == 1) { if ($filteronprojuser > 0) { - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; } if ($filterontaskuser > 0) { - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; if ($includebilltime) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec2"; - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec2"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; } else { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; if ($includebilltime) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } } - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)"; - $sql.= " WHERE p.entity IN (".getEntity('project').")"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)"; + $sql .= " WHERE p.entity IN (".getEntity('project').")"; } else return 'BadValueForParameterMode'; if ($filteronprojuser > 0) { - $sql.= " AND p.rowid = ec.element_id"; - $sql.= " AND ctc.rowid = ec.fk_c_type_contact"; - $sql.= " AND ctc.element = 'project'"; - $sql.= " AND ec.fk_socpeople = ".$filteronprojuser; - $sql.= " AND ec.statut = 4"; - $sql.= " AND ctc.source = 'internal'"; + $sql .= " AND p.rowid = ec.element_id"; + $sql .= " AND ctc.rowid = ec.fk_c_type_contact"; + $sql .= " AND ctc.element = 'project'"; + $sql .= " AND ec.fk_socpeople = ".$filteronprojuser; + $sql .= " AND ec.statut = 4"; + $sql .= " AND ctc.source = 'internal'"; } if ($filterontaskuser > 0) { - $sql.= " AND t.fk_projet = p.rowid"; - $sql.= " AND p.rowid = ec2.element_id"; - $sql.= " AND ctc2.rowid = ec2.fk_c_type_contact"; - $sql.= " AND ctc2.element = 'project_task'"; - $sql.= " AND ec2.fk_socpeople = ".$filterontaskuser; - $sql.= " AND ec2.statut = 4"; - $sql.= " AND ctc2.source = 'internal'"; - } - if ($socid) $sql.= " AND p.fk_soc = ".$socid; - if ($projectid) $sql.= " AND p.rowid in (".$projectid.")"; - if ($filteronproj) $sql.= natural_search(array("p.ref", "p.title"), $filteronproj); - if ($filteronprojstatus && $filteronprojstatus != '-1') $sql.= " AND p.fk_statut IN (".$filteronprojstatus.")"; - if ($morewherefilter) $sql.=$morewherefilter; + $sql .= " AND t.fk_projet = p.rowid"; + $sql .= " AND p.rowid = ec2.element_id"; + $sql .= " AND ctc2.rowid = ec2.fk_c_type_contact"; + $sql .= " AND ctc2.element = 'project_task'"; + $sql .= " AND ec2.fk_socpeople = ".$filterontaskuser; + $sql .= " AND ec2.statut = 4"; + $sql .= " AND ctc2.source = 'internal'"; + } + if ($socid) $sql .= " AND p.fk_soc = ".$socid; + if ($projectid) $sql .= " AND p.rowid in (".$projectid.")"; + if ($filteronproj) $sql .= natural_search(array("p.ref", "p.title"), $filteronproj); + if ($filteronprojstatus && $filteronprojstatus != '-1') $sql .= " AND p.fk_statut IN (".$filteronprojstatus.")"; + if ($morewherefilter) $sql .= $morewherefilter; if ($includebilltime) { - $sql.=" GROUP BY p.rowid, p.ref, p.title, p.public, p.fk_statut, p.usage_bill_time,"; - $sql.=" t.datec, t.dateo, t.datee, t.tms,"; - $sql.=" t.rowid, t.ref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut,"; - $sql.=" t.dateo, t.datee, t.planned_workload, t.rang,"; - $sql.=" s.rowid, s.nom, s.email,"; - $sql.=" p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount"; + $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public, p.fk_statut, p.usage_bill_time,"; + $sql .= " t.datec, t.dateo, t.datee, t.tms,"; + $sql .= " t.rowid, t.ref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut,"; + $sql .= " t.dateo, t.datee, t.planned_workload, t.rang,"; + $sql .= " s.rowid, s.nom, s.email,"; + $sql .= " p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount"; if (!empty($extrafields->attributes['projet']['label'])) { - foreach ($extrafields->attributes['projet']['label'] as $key => $val) $sql.=($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key : ''); + foreach ($extrafields->attributes['projet']['label'] as $key => $val) $sql .= ($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key : ''); } if (!empty($extrafields->attributes['projet_task']['label'])) { - foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) $sql.=($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key : ''); + foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) $sql .= ($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key : ''); } } - $sql.= " ORDER BY p.ref, t.rang, t.dateo"; + $sql .= " ORDER BY p.ref, t.rang, t.dateo"; //print $sql;exit; dol_syslog(get_class($this)."::getTasksArray", LOG_DEBUG); @@ -878,56 +878,56 @@ public function getTasksArray($usert = null, $userp = null, $projectid = 0, $soc // Loop on each record found, so each couple (project id, task id) while ($i < $num) { - $error=0; + $error = 0; $obj = $this->db->fetch_object($resql); - if ((! $obj->public) && (is_object($userp))) // If not public project and we ask a filter on project owned by a user + if ((!$obj->public) && (is_object($userp))) // If not public project and we ask a filter on project owned by a user { - if (! $this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) + if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) { $error++; } } if (is_object($usert)) // If we ask a filter on a user affected to a task { - if (! $this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) + if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) { $error++; } } - if (! $error) + if (!$error) { $tasks[$i] = new Task($this->db); - $tasks[$i]->id = $obj->taskid; - $tasks[$i]->ref = $obj->taskref; + $tasks[$i]->id = $obj->taskid; + $tasks[$i]->ref = $obj->taskref; $tasks[$i]->fk_project = $obj->projectid; $tasks[$i]->projectref = $obj->ref; - $tasks[$i]->projectlabel = $obj->plabel; - $tasks[$i]->projectstatus = $obj->projectstatus; - $tasks[$i]->usage_bill_time = $obj->usage_bill_time; - $tasks[$i]->label = $obj->label; - $tasks[$i]->description = $obj->description; - $tasks[$i]->fk_parent = $obj->fk_task_parent; // deprecated - $tasks[$i]->fk_task_parent = $obj->fk_task_parent; + $tasks[$i]->projectlabel = $obj->plabel; + $tasks[$i]->projectstatus = $obj->projectstatus; + $tasks[$i]->usage_bill_time = $obj->usage_bill_time; + $tasks[$i]->label = $obj->label; + $tasks[$i]->description = $obj->description; + $tasks[$i]->fk_parent = $obj->fk_task_parent; // deprecated + $tasks[$i]->fk_task_parent = $obj->fk_task_parent; $tasks[$i]->duration = $obj->duration_effective; - $tasks[$i]->planned_workload= $obj->planned_workload; + $tasks[$i]->planned_workload = $obj->planned_workload; $tasks[$i]->tobill = $obj->tobill; - $tasks[$i]->billed = $obj->billed; + $tasks[$i]->billed = $obj->billed; $tasks[$i]->progress = $obj->progress; - $tasks[$i]->fk_statut = $obj->status; - $tasks[$i]->public = $obj->public; - $tasks[$i]->date_start = $this->db->jdate($obj->date_start); + $tasks[$i]->fk_statut = $obj->status; + $tasks[$i]->public = $obj->public; + $tasks[$i]->date_start = $this->db->jdate($obj->date_start); $tasks[$i]->date_end = $this->db->jdate($obj->date_end); $tasks[$i]->rang = $obj->rang; - $tasks[$i]->socid = $obj->thirdparty_id; // For backward compatibility - $tasks[$i]->thirdparty_id = $obj->thirdparty_id; + $tasks[$i]->socid = $obj->thirdparty_id; // For backward compatibility + $tasks[$i]->thirdparty_id = $obj->thirdparty_id; $tasks[$i]->thirdparty_name = $obj->thirdparty_name; - $tasks[$i]->thirdparty_email= $obj->thirdparty_email; + $tasks[$i]->thirdparty_email = $obj->thirdparty_email; $tasks[$i]->fk_opp_status = $obj->fk_opp_status; @@ -986,41 +986,41 @@ public function getUserRolesForProjectsOrTasks($userp, $usert, $projectid = '', // We want role of user for a projet or role of user for a task. Both are not possible. if (empty($userp) && empty($usert)) { - $this->error="CallWithWrongParameters"; + $this->error = "CallWithWrongParameters"; return -1; } - if (! empty($userp) && ! empty($usert)) + if (!empty($userp) && !empty($usert)) { - $this->error="CallWithWrongParameters"; + $this->error = "CallWithWrongParameters"; return -1; } /* Liste des taches et role sur les projets ou taches */ $sql = "SELECT pt.rowid as pid, ec.element_id, ctc.code, ctc.source"; - if ($userp) $sql.= " FROM ".MAIN_DB_PREFIX."projet as pt"; - if ($usert && $filteronprojstatus > -1) $sql.= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."projet_task as pt"; - if ($usert && $filteronprojstatus <= -1) $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sql.= " WHERE pt.rowid = ec.element_id"; - if ($userp && $filteronprojstatus > -1) $sql.= " AND pt.fk_statut = ".$filteronprojstatus; - if ($usert && $filteronprojstatus > -1) $sql.= " AND pt.fk_projet = p.rowid AND p.fk_statut = ".$filteronprojstatus; - if ($userp) $sql.= " AND ctc.element = 'project'"; - if ($usert) $sql.= " AND ctc.element = 'project_task'"; - $sql.= " AND ctc.rowid = ec.fk_c_type_contact"; - if ($userp) $sql.= " AND ec.fk_socpeople = ".$userp->id; - if ($usert) $sql.= " AND ec.fk_socpeople = ".$usert->id; - $sql.= " AND ec.statut = 4"; - $sql.= " AND ctc.source = 'internal'"; + if ($userp) $sql .= " FROM ".MAIN_DB_PREFIX."projet as pt"; + if ($usert && $filteronprojstatus > -1) $sql .= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."projet_task as pt"; + if ($usert && $filteronprojstatus <= -1) $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sql .= " WHERE pt.rowid = ec.element_id"; + if ($userp && $filteronprojstatus > -1) $sql .= " AND pt.fk_statut = ".$filteronprojstatus; + if ($usert && $filteronprojstatus > -1) $sql .= " AND pt.fk_projet = p.rowid AND p.fk_statut = ".$filteronprojstatus; + if ($userp) $sql .= " AND ctc.element = 'project'"; + if ($usert) $sql .= " AND ctc.element = 'project_task'"; + $sql .= " AND ctc.rowid = ec.fk_c_type_contact"; + if ($userp) $sql .= " AND ec.fk_socpeople = ".$userp->id; + if ($usert) $sql .= " AND ec.fk_socpeople = ".$usert->id; + $sql .= " AND ec.statut = 4"; + $sql .= " AND ctc.source = 'internal'"; if ($projectid) { - if ($userp) $sql.= " AND pt.rowid in (".$projectid.")"; - if ($usert) $sql.= " AND pt.fk_projet in (".$projectid.")"; + if ($userp) $sql .= " AND pt.rowid in (".$projectid.")"; + if ($usert) $sql .= " AND pt.fk_projet in (".$projectid.")"; } if ($taskid) { - if ($userp) $sql.= " ERROR SHOULD NOT HAPPENS"; - if ($usert) $sql.= " AND pt.rowid = ".$taskid; + if ($userp) $sql .= " ERROR SHOULD NOT HAPPENS"; + if ($usert) $sql .= " AND pt.rowid = ".$taskid; } //print $sql; @@ -1034,7 +1034,7 @@ public function getUserRolesForProjectsOrTasks($userp, $usert, $projectid = '', { $obj = $this->db->fetch_object($resql); if (empty($arrayroles[$obj->pid])) $arrayroles[$obj->pid] = $obj->code; - else $arrayroles[$obj->pid].=','.$obj->code; + else $arrayroles[$obj->pid] .= ','.$obj->code; $i++; } $this->db->free($resql); @@ -1059,7 +1059,7 @@ public function getListContactId($source = 'internal') $contactAlreadySelected = array(); $tab = $this->liste_contact(-1, $source); //var_dump($tab); - $num=count($tab); + $num = count($tab); $i = 0; while ($i < $num) { @@ -1080,14 +1080,14 @@ public function getListContactId($source = 'internal') */ public function addTimeSpent($user, $notrigger = 0) { - global $conf,$langs; + global $conf, $langs; dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); $ret = 0; // Check parameters - if (! is_object($user)) + if (!is_object($user)) { dol_print_error('', "Method addTimeSpent was called with wrong parameter user"); return -1; @@ -1100,41 +1100,41 @@ public function addTimeSpent($user, $notrigger = 0) $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time ("; - $sql.= "fk_task"; - $sql.= ", task_date"; - $sql.= ", task_datehour"; - $sql.= ", task_date_withhour"; - $sql.= ", task_duration"; - $sql.= ", fk_user"; - $sql.= ", note"; - $sql.= ") VALUES ("; - $sql.= $this->id; - $sql.= ", '".$this->db->idate($this->timespent_date)."'"; - $sql.= ", '".$this->db->idate($this->timespent_datehour)."'"; - $sql.= ", ".(empty($this->timespent_withhour)?0:1); - $sql.= ", ".$this->timespent_duration; - $sql.= ", ".$this->timespent_fk_user; - $sql.= ", ".(isset($this->timespent_note)?"'".$this->db->escape($this->timespent_note)."'":"null"); - $sql.= ")"; - - $resql=$this->db->query($sql); + $sql .= "fk_task"; + $sql .= ", task_date"; + $sql .= ", task_datehour"; + $sql .= ", task_date_withhour"; + $sql .= ", task_duration"; + $sql .= ", fk_user"; + $sql .= ", note"; + $sql .= ") VALUES ("; + $sql .= $this->id; + $sql .= ", '".$this->db->idate($this->timespent_date)."'"; + $sql .= ", '".$this->db->idate($this->timespent_datehour)."'"; + $sql .= ", ".(empty($this->timespent_withhour) ? 0 : 1); + $sql .= ", ".$this->timespent_duration; + $sql .= ", ".$this->timespent_fk_user; + $sql .= ", ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); + $sql .= ")"; + + $resql = $this->db->query($sql); if ($resql) { $tasktime_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_time"); $ret = $tasktime_id; $this->timespent_id = $ret; - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('TASK_TIMESPENT_CREATE', $user); - if ($result < 0) { $ret=-1; } + $result = $this->call_trigger('TASK_TIMESPENT_CREATE', $user); + if ($result < 0) { $ret = -1; } // End call triggers } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $ret = -1; } @@ -1142,30 +1142,30 @@ public function addTimeSpent($user, $notrigger = 0) { // Recalculate amount of time spent for task and update denormalized field $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; - if (isset($this->progress)) $sql.= ", progress = " . $this->progress; // Do not overwrite value if not provided - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; + if (isset($this->progress)) $sql .= ", progress = ".$this->progress; // Do not overwrite value if not provided + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); - if (! $this->db->query($sql) ) + if (!$this->db->query($sql)) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $ret = -2; } $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; - $sql.= " SET thm = (SELECT thm FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->timespent_fk_user.")"; // set average hour rate of user - $sql.= " WHERE rowid = ".$tasktime_id; + $sql .= " SET thm = (SELECT thm FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->timespent_fk_user.")"; // set average hour rate of user + $sql .= " WHERE rowid = ".$tasktime_id; dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); - if (! $this->db->query($sql) ) + if (!$this->db->query($sql)) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $ret = -2; } } - if ($ret >0) + if ($ret > 0) { $this->db->commit(); } @@ -1187,47 +1187,47 @@ public function getSummaryOfTimeSpent($userobj = null, $morewherefilter = '') { global $langs; - if (is_object($userobj)) $userid=$userobj->id; - else $userid=$userobj; // old method + if (is_object($userobj)) $userid = $userobj->id; + else $userid = $userobj; // old method - $id=$this->id; + $id = $this->id; if (empty($id) && empty($userid)) { dol_syslog("getSummaryOfTimeSpent called on a not loaded task without user param defined", LOG_ERR); return -1; } - $result=array(); + $result = array(); $sql = "SELECT"; - $sql.= " MIN(t.task_datehour) as min_date,"; - $sql.= " MAX(t.task_datehour) as max_date,"; - $sql.= " SUM(t.task_duration) as total_duration,"; - $sql.= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as total_amount,"; - $sql.= " COUNT(t.rowid) as nblines,"; - $sql.= " SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql.= " WHERE 1 = 1"; - if ($morewherefilter) $sql.=$morewherefilter; - if ($id > 0) $sql.= " AND t.fk_task = ".$id; - if ($userid > 0) $sql.=" AND t.fk_user = ".$userid; + $sql .= " MIN(t.task_datehour) as min_date,"; + $sql .= " MAX(t.task_datehour) as max_date,"; + $sql .= " SUM(t.task_duration) as total_duration,"; + $sql .= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as total_amount,"; + $sql .= " COUNT(t.rowid) as nblines,"; + $sql .= " SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " WHERE 1 = 1"; + if ($morewherefilter) $sql .= $morewherefilter; + if ($id > 0) $sql .= " AND t.fk_task = ".$id; + if ($userid > 0) $sql .= " AND t.fk_user = ".$userid; dol_syslog(get_class($this)."::getSummaryOfTimeSpent", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); - $result['min_date'] = $obj->min_date; // deprecated. use the ->timespent_xxx instead - $result['max_date'] = $obj->max_date; // deprecated. use the ->timespent_xxx instead - $result['total_duration'] = $obj->total_duration; // deprecated. use the ->timespent_xxx instead + $result['min_date'] = $obj->min_date; // deprecated. use the ->timespent_xxx instead + $result['max_date'] = $obj->max_date; // deprecated. use the ->timespent_xxx instead + $result['total_duration'] = $obj->total_duration; // deprecated. use the ->timespent_xxx instead - $this->timespent_min_date=$this->db->jdate($obj->min_date); - $this->timespent_max_date=$this->db->jdate($obj->max_date); - $this->timespent_total_duration=$obj->total_duration; - $this->timespent_total_amount=$obj->total_amount; - $this->timespent_nblinesnull=($obj->nblinesnull?$obj->nblinesnull:0); - $this->timespent_nblines=($obj->nblines?$obj->nblines:0); + $this->timespent_min_date = $this->db->jdate($obj->min_date); + $this->timespent_max_date = $this->db->jdate($obj->max_date); + $this->timespent_total_duration = $obj->total_duration; + $this->timespent_total_amount = $obj->total_amount; + $this->timespent_nblinesnull = ($obj->nblinesnull ? $obj->nblinesnull : 0); + $this->timespent_nblines = ($obj->nblines ? $obj->nblines : 0); $this->db->free($resql); } @@ -1250,33 +1250,33 @@ public function getSumOfAmount($fuser = '', $dates = '', $datee = '') { global $langs; - if (empty($id)) $id=$this->id; + if (empty($id)) $id = $this->id; - $result=array(); + $result = array(); $sql = "SELECT"; - $sql.= " SUM(t.task_duration) as nbseconds,"; - $sql.= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as amount, SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql.= " WHERE t.fk_task = ".$id; + $sql .= " SUM(t.task_duration) as nbseconds,"; + $sql .= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as amount, SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " WHERE t.fk_task = ".$id; if (is_object($fuser) && $fuser->id > 0) { - $sql.=" AND fk_user = ".$fuser->id; + $sql .= " AND fk_user = ".$fuser->id; } if ($dates > 0) { - $datefieldname="task_datehour"; - $sql.=" AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; + $datefieldname = "task_datehour"; + $sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; } if ($datee > 0) { - $datefieldname="task_datehour"; - $sql.=" AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; + $datefieldname = "task_datehour"; + $sql .= " AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; } //print $sql; dol_syslog(get_class($this)."::getSumOfAmount", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -1306,35 +1306,35 @@ public function fetchTimeSpent($id) global $langs; $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.fk_task,"; - $sql.= " t.task_date,"; - $sql.= " t.task_datehour,"; - $sql.= " t.task_date_withhour,"; - $sql.= " t.task_duration,"; - $sql.= " t.fk_user,"; - $sql.= " t.thm,"; - $sql.= " t.note"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql.= " WHERE t.rowid = ".$id; + $sql .= " t.rowid,"; + $sql .= " t.fk_task,"; + $sql .= " t.task_date,"; + $sql .= " t.task_datehour,"; + $sql .= " t.task_date_withhour,"; + $sql .= " t.task_duration,"; + $sql .= " t.fk_user,"; + $sql .= " t.thm,"; + $sql .= " t.note"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetchTimeSpent", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->timespent_id = $obj->rowid; - $this->id = $obj->fk_task; - $this->timespent_date = $this->db->jdate($obj->task_date); + $this->timespent_id = $obj->rowid; + $this->id = $obj->fk_task; + $this->timespent_date = $this->db->jdate($obj->task_date); $this->timespent_datehour = $this->db->jdate($obj->task_datehour); $this->timespent_withhour = $obj->task_date_withhour; - $this->timespent_duration = $obj->task_duration; + $this->timespent_duration = $obj->task_duration; $this->timespent_fk_user = $obj->fk_user; - $this->timespent_thm = $obj->thm; // hourly rate - $this->timespent_note = $obj->note; + $this->timespent_thm = $obj->thm; // hourly rate + $this->timespent_note = $obj->note; } $this->db->free($resql); @@ -1343,7 +1343,7 @@ public function fetchTimeSpent($id) } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -1359,41 +1359,41 @@ public function fetchAllTimeSpent(User $userobj, $morewherefilter = '') { global $langs; - $arrayres=array(); + $arrayres = array(); $sql = "SELECT"; - $sql.= " s.rowid as socid,"; - $sql.= " s.nom as thirdparty_name,"; - $sql.= " s.email as thirdparty_email,"; - $sql.= " ptt.rowid,"; - $sql.= " ptt.fk_task,"; - $sql.= " ptt.task_date,"; - $sql.= " ptt.task_datehour,"; - $sql.= " ptt.task_date_withhour,"; - $sql.= " ptt.task_duration,"; - $sql.= " ptt.fk_user,"; - $sql.= " ptt.note,"; - $sql.= " pt.rowid as task_id,"; - $sql.= " pt.ref as task_ref,"; - $sql.= " pt.label as task_label,"; - $sql.= " p.rowid as project_id,"; - $sql.= " p.ref as project_ref,"; - $sql.= " p.title as project_label,"; - $sql.= " p.public as public"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as ptt, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - $sql.= " WHERE ptt.fk_task = pt.rowid AND pt.fk_projet = p.rowid"; - $sql.= " AND ptt.fk_user = ".$userobj->id; - $sql.= " AND pt.entity IN (".getEntity('project').")"; - if ($morewherefilter) $sql.=$morewherefilter; + $sql .= " s.rowid as socid,"; + $sql .= " s.nom as thirdparty_name,"; + $sql .= " s.email as thirdparty_email,"; + $sql .= " ptt.rowid,"; + $sql .= " ptt.fk_task,"; + $sql .= " ptt.task_date,"; + $sql .= " ptt.task_datehour,"; + $sql .= " ptt.task_date_withhour,"; + $sql .= " ptt.task_duration,"; + $sql .= " ptt.fk_user,"; + $sql .= " ptt.note,"; + $sql .= " pt.rowid as task_id,"; + $sql .= " pt.ref as task_ref,"; + $sql .= " pt.label as task_label,"; + $sql .= " p.rowid as project_id,"; + $sql .= " p.ref as project_ref,"; + $sql .= " p.title as project_label,"; + $sql .= " p.public as public"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as ptt, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; + $sql .= " WHERE ptt.fk_task = pt.rowid AND pt.fk_projet = p.rowid"; + $sql .= " AND ptt.fk_user = ".$userobj->id; + $sql .= " AND pt.entity IN (".getEntity('project').")"; + if ($morewherefilter) $sql .= $morewherefilter; dol_syslog(get_class($this)."::fetchAllTimeSpent", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -1406,20 +1406,20 @@ public function fetchAllTimeSpent(User $userobj, $morewherefilter = '') $newobj->fk_project = $obj->project_id; $newobj->project_ref = $obj->project_ref; - $newobj->project_label = $obj->project_label; + $newobj->project_label = $obj->project_label; $newobj->public = $obj->project_public; $newobj->fk_task = $obj->task_id; - $newobj->task_ref = $obj->task_ref; - $newobj->task_label = $obj->task_label; + $newobj->task_ref = $obj->task_ref; + $newobj->task_label = $obj->task_label; - $newobj->timespent_id = $obj->rowid; - $newobj->timespent_date = $this->db->jdate($obj->task_date); + $newobj->timespent_id = $obj->rowid; + $newobj->timespent_date = $this->db->jdate($obj->task_date); $newobj->timespent_datehour = $this->db->jdate($obj->task_datehour); $newobj->timespent_withhour = $obj->task_date_withhour; $newobj->timespent_duration = $obj->task_duration; - $newobj->timespent_fk_user = $obj->fk_user; - $newobj->timespent_note = $obj->note; + $newobj->timespent_fk_user = $obj->fk_user; + $newobj->timespent_note = $obj->note; $arrayres[] = $newobj; @@ -1431,7 +1431,7 @@ public function fetchAllTimeSpent(User $userobj, $morewherefilter = '') else { dol_print_error($this->db); - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -1447,7 +1447,7 @@ public function fetchAllTimeSpent(User $userobj, $morewherefilter = '') */ public function updateTimeSpent($user, $notrigger = 0) { - global $conf,$langs; + global $conf, $langs; $ret = 0; @@ -1457,7 +1457,7 @@ public function updateTimeSpent($user, $notrigger = 0) $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")); return -1; } - if (! ($this->timespent_fk_user > 0)) + if (!($this->timespent_fk_user > 0)) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("User")); return -1; @@ -1470,21 +1470,21 @@ public function updateTimeSpent($user, $notrigger = 0) $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET"; - $sql.= " task_date = '".$this->db->idate($this->timespent_date)."',"; - $sql.= " task_datehour = '".$this->db->idate($this->timespent_datehour)."',"; - $sql.= " task_date_withhour = ".(empty($this->timespent_withhour)?0:1).","; - $sql.= " task_duration = ".$this->timespent_duration.","; - $sql.= " fk_user = ".$this->timespent_fk_user.","; - $sql.= " note = ".(isset($this->timespent_note)?"'".$this->db->escape($this->timespent_note)."'":"null"); - $sql.= " WHERE rowid = ".$this->timespent_id; + $sql .= " task_date = '".$this->db->idate($this->timespent_date)."',"; + $sql .= " task_datehour = '".$this->db->idate($this->timespent_datehour)."',"; + $sql .= " task_date_withhour = ".(empty($this->timespent_withhour) ? 0 : 1).","; + $sql .= " task_duration = ".$this->timespent_duration.","; + $sql .= " fk_user = ".$this->timespent_fk_user.","; + $sql .= " note = ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); + $sql .= " WHERE rowid = ".$this->timespent_id; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); - if ($this->db->query($sql) ) + if ($this->db->query($sql)) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('TASK_TIMESPENT_MODIFY', $user); + $result = $this->call_trigger('TASK_TIMESPENT_MODIFY', $user); if ($result < 0) { $this->db->rollback(); @@ -1497,7 +1497,7 @@ public function updateTimeSpent($user, $notrigger = 0) } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); $ret = -1; } @@ -1507,13 +1507,13 @@ public function updateTimeSpent($user, $notrigger = 0) $newDuration = $this->timespent_duration - $this->timespent_old_duration; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->db->escape($this->id).")"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->db->escape($this->id).")"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); - if (! $this->db->query($sql) ) + if (!$this->db->query($sql)) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); $ret = -2; } @@ -1534,42 +1534,42 @@ public function delTimeSpent($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time"; - $sql.= " WHERE rowid = ".$this->timespent_id; + $sql .= " WHERE rowid = ".$this->timespent_id; dol_syslog(get_class($this)."::delTimeSpent", LOG_DEBUG); $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('TASK_TIMESPENT_DELETE', $user); + $result = $this->call_trigger('TASK_TIMESPENT_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } } - if (! $error) + if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = duration_effective - ".$this->db->escape($this->timespent_duration?$this->timespent_duration:0); - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET duration_effective = duration_effective - ".$this->db->escape($this->timespent_duration ? $this->timespent_duration : 0); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::delTimeSpent", LOG_DEBUG); - if ($this->db->query($sql) ) + if ($this->db->query($sql)) { $result = 0; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $result = -2; } } @@ -1577,13 +1577,13 @@ public function delTimeSpent($user, $notrigger = 0) // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delTimeSpent ".$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 { @@ -1608,19 +1608,19 @@ public function delTimeSpent($user, $notrigger = 0) */ public function createFromClone(User $user, $fromid, $project_id, $parent_task_id, $clone_change_dt = false, $clone_affectation = false, $clone_time = false, $clone_file = false, $clone_note = false, $clone_prog = false) { - global $langs,$conf; + global $langs, $conf; - $error=0; + $error = 0; //Use 00:00 of today if time is use on task. - $now=dol_mktime(0, 0, 0, dol_print_date(dol_now(), '%m'), dol_print_date(dol_now(), '%d'), dol_print_date(dol_now(), '%Y')); + $now = dol_mktime(0, 0, 0, dol_print_date(dol_now(), '%m'), dol_print_date(dol_now(), '%d'), dol_print_date(dol_now(), '%Y')); $datec = $now; - $clone_task=new Task($this->db); - $origin_task=new Task($this->db); + $clone_task = new Task($this->db); + $origin_task = new Task($this->db); - $clone_task->context['createfromclone']='createfromclone'; + $clone_task->context['createfromclone'] = 'createfromclone'; $this->db->begin(); @@ -1631,11 +1631,11 @@ public function createFromClone(User $user, $fromid, $project_id, $parent_task_i $origin_task->fetch($fromid); - $defaultref=''; - $obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON; - if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) + $defaultref = ''; + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) { - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; + require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; $modTask = new $obj; $defaultref = $modTask->getNextValue(0, $clone_task); } @@ -1644,16 +1644,16 @@ public function createFromClone(User $user, $fromid, $project_id, $parent_task_i $clone_task->id = 0; $clone_task->ref = $defaultref; - $clone_task->fk_project = $project_id; - $clone_task->fk_task_parent = $parent_task_id; - $clone_task->date_c = $datec; - $clone_task->planned_workload = $origin_task->planned_workload; - $clone_task->rang = $origin_task->rang; + $clone_task->fk_project = $project_id; + $clone_task->fk_task_parent = $parent_task_id; + $clone_task->date_c = $datec; + $clone_task->planned_workload = $origin_task->planned_workload; + $clone_task->rang = $origin_task->rang; //Manage Task Date if ($clone_change_dt) { - $projectstatic=new Project($this->db); + $projectstatic = new Project($this->db); $projectstatic->fetch($ori_project_id); //Origin project strat date @@ -1662,50 +1662,50 @@ public function createFromClone(User $user, $fromid, $project_id, $parent_task_i //Calcultate new task start date with difference between origin proj start date and origin task start date if (!empty($clone_task->date_start)) { - $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start; + $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start; } //Calcultate new task end date with difference between origin proj end date and origin task end date if (!empty($clone_task->date_end)) { - $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start; + $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start; } } if (!$clone_prog) { - $clone_task->progress=0; + $clone_task->progress = 0; } // Create clone - $result=$clone_task->create($user); + $result = $clone_task->create($user); // Other options if ($result < 0) { - $this->error=$clone_task->error; + $this->error = $clone_task->error; $error++; } // End - if (! $error) + if (!$error) { - $clone_task_id=$clone_task->id; + $clone_task_id = $clone_task->id; $clone_task_ref = $clone_task->ref; //Note Update if (!$clone_note) { - $clone_task->note_private=''; - $clone_task->note_public=''; + $clone_task->note_private = ''; + $clone_task->note_public = ''; } else { $this->db->begin(); - $res=$clone_task->update_note(dol_html_entity_decode($clone_task->note_public, ENT_QUOTES), '_public'); + $res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_public, ENT_QUOTES), '_public'); if ($res < 0) { - $this->error.=$clone_task->error; + $this->error .= $clone_task->error; $error++; $this->db->rollback(); } @@ -1715,10 +1715,10 @@ public function createFromClone(User $user, $fromid, $project_id, $parent_task_i } $this->db->begin(); - $res=$clone_task->update_note(dol_html_entity_decode($clone_task->note_private, ENT_QUOTES), '_private'); + $res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_private, ENT_QUOTES), '_private'); if ($res < 0) { - $this->error.=$clone_task->error; + $this->error .= $clone_task->error; $error++; $this->db->rollback(); } @@ -1734,39 +1734,39 @@ public function createFromClone(User $user, $fromid, $project_id, $parent_task_i require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; //retreive project origin ref to know folder to copy - $projectstatic=new Project($this->db); + $projectstatic = new Project($this->db); $projectstatic->fetch($ori_project_id); - $ori_project_ref=$projectstatic->ref; + $ori_project_ref = $projectstatic->ref; - if ($ori_project_id!=$project_id) + if ($ori_project_id != $project_id) { $projectstatic->fetch($project_id); - $clone_project_ref=$projectstatic->ref; + $clone_project_ref = $projectstatic->ref; } else { - $clone_project_ref=$ori_project_ref; + $clone_project_ref = $ori_project_ref; } - $clone_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($clone_project_ref). "/" . dol_sanitizeFileName($clone_task_ref); - $ori_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($ori_project_ref). "/" . dol_sanitizeFileName($fromid); + $clone_task_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($clone_project_ref)."/".dol_sanitizeFileName($clone_task_ref); + $ori_task_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($ori_project_ref)."/".dol_sanitizeFileName($fromid); - $filearray=dol_dir_list($ori_task_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); - foreach($filearray as $key => $file) + $filearray = dol_dir_list($ori_task_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); + foreach ($filearray as $key => $file) { if (!file_exists($clone_task_dir)) { if (dol_mkdir($clone_task_dir) < 0) { - $this->error.=$langs->trans('ErrorInternalErrorDetected').':dol_mkdir'; + $this->error .= $langs->trans('ErrorInternalErrorDetected').':dol_mkdir'; $error++; } } - $rescopy = dol_copy($ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name'], 0, 1); + $rescopy = dol_copy($ori_task_dir.'/'.$file['name'], $clone_task_dir.'/'.$file['name'], 0, 1); if (is_numeric($rescopy) && $rescopy < 0) { - $this->error.=$langs->trans("ErrorFailToCopyFile", $ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name']); + $this->error .= $langs->trans("ErrorFailToCopyFile", $ori_task_dir.'/'.$file['name'], $clone_task_dir.'/'.$file['name']); $error++; } } @@ -1778,10 +1778,10 @@ public function createFromClone(User $user, $fromid, $project_id, $parent_task_i $origin_task = new Task($this->db); $origin_task->fetch($fromid); - foreach(array('internal','external') as $source) + foreach (array('internal', 'external') as $source) { $tab = $origin_task->liste_contact(-1, $source); - $num=count($tab); + $num = count($tab); $i = 0; while ($i < $num) { @@ -1789,14 +1789,14 @@ public function createFromClone(User $user, $fromid, $project_id, $parent_task_i if ($clone_task->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - $this->error.=$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); + $this->error .= $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); $error++; } else { - if ($clone_task->error!='') + if ($clone_task->error != '') { - $this->error.=$clone_task->error; + $this->error .= $clone_task->error; $error++; } } @@ -1805,7 +1805,7 @@ public function createFromClone(User $user, $fromid, $project_id, $parent_task_i } } - if($clone_time) + if ($clone_time) { //TODO clone time of affectation } @@ -1813,7 +1813,7 @@ public function createFromClone(User $user, $fromid, $project_id, $parent_task_i unset($clone_task->context['createfromclone']); - if (! $error) + if (!$error) { $this->db->commit(); return $clone_task_id; @@ -1821,7 +1821,7 @@ public function createFromClone(User $user, $fromid, $project_id, $parent_task_i else { $this->db->rollback(); - dol_syslog(get_class($this)."::createFromClone nbError: ".$error." error : " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::createFromClone nbError: ".$error." error : ".$this->error, LOG_ERR); return -1; } } @@ -1852,16 +1852,16 @@ public function LibStatut($status, $mode = 0) global $langs; // list of Statut of the task - $this->statuts[0]='Draft'; - $this->statuts[1]='ToDo'; - $this->statuts[2]='Running'; - $this->statuts[3]='Finish'; - $this->statuts[4]='Transfered'; - $this->statuts_short[0]='Draft'; - $this->statuts_short[1]='ToDo'; - $this->statuts_short[2]='Running'; - $this->statuts_short[3]='Completed'; - $this->statuts_short[4]='Transfered'; + $this->statuts[0] = 'Draft'; + $this->statuts[1] = 'ToDo'; + $this->statuts[2] = 'Running'; + $this->statuts[3] = 'Finish'; + $this->statuts[4] = 'Transfered'; + $this->statuts_short[0] = 'Draft'; + $this->statuts_short[1] = 'ToDo'; + $this->statuts_short[2] = 'Running'; + $this->statuts_short[3] = 'Completed'; + $this->statuts_short[4] = 'Transfered'; if ($mode == 0) { @@ -1873,30 +1873,30 @@ public function LibStatut($status, $mode = 0) } elseif ($mode == 2) { - if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); - elseif ($status==5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts_short[$status]); + if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); + elseif ($status == 5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts_short[$status]); } elseif ($mode == 3) { - if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); - elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1'); - elseif ($status==2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3'); - elseif ($status==3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); - elseif ($status==4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); - elseif ($status==5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5'); + if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); + elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1'); + elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3'); + elseif ($status == 3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); + elseif ($status == 4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); + elseif ($status == 5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5'); } elseif ($mode == 4) { - if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); - elseif ($status==1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1').' '.$langs->trans($this->statuts[$status]); - elseif ($status==2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts[$status]); - elseif ($status==3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); - elseif ($status==4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); - elseif ($status==5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts[$status]); + if ($status == 0) return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 1) return img_picto($langs->trans($this->statuts_short[$status]), 'statut1').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 2) return img_picto($langs->trans($this->statuts_short[$status]), 'statut3').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 3) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 4) return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); + elseif ($status == 5) return img_picto($langs->trans($this->statuts_short[$status]), 'statut5').' '.$langs->trans($this->statuts[$status]); } elseif ($mode == 5) { @@ -1936,16 +1936,16 @@ public function LibStatut($status, $mode = 0) */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf,$langs; + global $conf, $langs; $langs->load("projects"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'nodefault'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->PROJECT_TASK_ADDON_PDF)) { + } elseif (!empty($conf->global->PROJECT_TASK_ADDON_PDF)) { $modele = $conf->global->PROJECT_TASK_ADDON_PDF; } } @@ -1976,38 +1976,38 @@ public function load_board($user) // List of tasks (does not care about permissions. Filtering will be done later) $sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,"; - $sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; - $sql.= " t.dateo as date_start, t.datee as datee"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + $sql .= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; + $sql .= " t.dateo as date_start, t.datee as datee"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; //if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; - $sql.= " AND p.fk_statut = 1"; - $sql.= " AND t.fk_projet = p.rowid"; - $sql.= " AND t.progress < 100"; // tasks to do - if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= " WHERE p.entity IN (".getEntity('project', 0).')'; + $sql .= " AND p.fk_statut = 1"; + $sql .= " AND t.fk_projet = p.rowid"; + $sql .= " AND t.progress < 100"; // tasks to do + if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser // if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; //print $sql; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $task_static = new Task($this->db); $response = new WorkboardResponse(); - $response->warning_delay = $conf->projet->task->warning_delay/60/60/24; + $response->warning_delay = $conf->projet->task->warning_delay / 60 / 60 / 24; $response->label = $langs->trans("OpenedTasks"); if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project'; else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&mainmenu=project'; $response->img = img_object('', "task"); // This assignment in condition is not a bug. It allows walking the results. - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; @@ -2025,7 +2025,7 @@ public function load_board($user) } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2042,32 +2042,32 @@ public function load_state_board() // phpcs:enable global $user; - $mine=0; $socid=$user->socid; + $mine = 0; $socid = $user->socid; $projectstatic = new Project($this->db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $mine, 1, $socid); // List of tasks (does not care about permissions. Filtering will be done later) $sql = "SELECT count(p.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; - $sql.= " AND t.fk_projet = p.rowid"; // tasks to do - if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql .= " WHERE p.entity IN (".getEntity('project', 0).')'; + $sql .= " AND t.fk_projet = p.rowid"; // tasks to do + if ($mine || !$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; + if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id.") OR (s.rowid IS NULL))"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { // This assignment in condition is not a bug. It allows walking the results. - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["tasks"]=$obj->nb; + $this->nb["tasks"] = $obj->nb; } $this->db->free($resql); return 1; @@ -2075,7 +2075,7 @@ public function load_state_board() else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2089,7 +2089,7 @@ public function hasDelay() { global $conf; - if (! ($this->progress >= 0 && $this->progress < 100)) { + if (!($this->progress >= 0 && $this->progress < 100)) { return false; } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index c2eb7fde29e03..e43782c26037c 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -34,8 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT."/core/class/commonobjectline.class.php"; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; /** @@ -43,11 +43,11 @@ */ class Reception extends CommonObject { - public $element="reception"; - public $fk_element="fk_reception"; - public $table_element="reception"; - public $table_element_line="commande_fournisseur_dispatch"; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $element = "reception"; + public $fk_element = "fk_reception"; + public $table_element = "reception"; + public $table_element_line = "commande_fournisseur_dispatch"; + protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -59,7 +59,7 @@ class Reception extends CommonObject public $ref_int; public $brouillon; public $entrepot_id; - public $lines=array(); + public $lines = array(); public $tracking_number; public $tracking_url; public $billed; @@ -76,7 +76,7 @@ class Reception extends CommonObject // A denormalized value public $trueSize; - public $date_delivery; // Date delivery planed + public $date_delivery; // Date delivery planed /** @@ -95,7 +95,7 @@ class Reception extends CommonObject public $date_valid; public $meths; - public $listmeths; // List of carriers + public $listmeths; // List of carriers const STATUS_DRAFT = 0; @@ -155,10 +155,10 @@ public function getNextNumRef($soc) $dir = dol_buildpath($reldir."core/modules/reception/"); // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $mybool |= @include_once $dir.$file; } - if (! $mybool) + if (!$mybool) { dol_print_error('', "Failed to include file ".$file); return ''; @@ -169,7 +169,7 @@ public function getNextNumRef($soc) $numref = ""; $numref = $obj->getNextValue($soc, $this); - if ( $numref != "") + if ($numref != "") { return $numref; } @@ -197,9 +197,9 @@ public function create($user, $notrigger = 0) { global $conf, $hookmanager; - $now=dol_now(); + $now = dol_now(); - require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $error = 0; // Clean parameters @@ -213,82 +213,82 @@ public function create($user, $notrigger = 0) $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."reception ("; - $sql.= "ref"; - $sql.= ", entity"; - $sql.= ", ref_supplier"; - $sql.= ", ref_int"; - $sql.= ", date_creation"; - $sql.= ", fk_user_author"; - $sql.= ", date_reception"; - $sql.= ", date_delivery"; - $sql.= ", fk_soc"; - $sql.= ", fk_projet"; - $sql.= ", fk_shipping_method"; - $sql.= ", tracking_number"; - $sql.= ", weight"; - $sql.= ", size"; - $sql.= ", width"; - $sql.= ", height"; - $sql.= ", weight_units"; - $sql.= ", size_units"; - $sql.= ", note_private"; - $sql.= ", note_public"; - $sql.= ", model_pdf"; - $sql.= ", fk_incoterms, location_incoterms"; - $sql.= ") VALUES ("; - $sql.= "'(PROV)'"; - $sql.= ", ".$conf->entity; - $sql.= ", ".($this->ref_supplier?"'".$this->db->escape($this->ref_supplier)."'":"null"); - $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", ".$user->id; - $sql.= ", ".($this->date_reception>0?"'".$this->db->idate($this->date_reception)."'":"null"); - $sql.= ", ".($this->date_delivery>0?"'".$this->db->idate($this->date_delivery)."'":"null"); - $sql.= ", ".$this->socid; - $sql.= ", ".$this->fk_project; - $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:"null"); - $sql.= ", '".$this->db->escape($this->tracking_number)."'"; - $sql.= ", ".$this->weight; - $sql.= ", ".$this->sizeS; // TODO Should use this->trueDepth - $sql.= ", ".$this->sizeW; // TODO Should use this->trueWidth - $sql.= ", ".$this->sizeH; // TODO Should use this->trueHeight - $sql.= ", ".$this->weight_units; - $sql.= ", ".$this->size_units; - $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); - $sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); - $sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null"); - $sql.= ", ".(int) $this->fk_incoterms; - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ")"; + $sql .= "ref"; + $sql .= ", entity"; + $sql .= ", ref_supplier"; + $sql .= ", ref_int"; + $sql .= ", date_creation"; + $sql .= ", fk_user_author"; + $sql .= ", date_reception"; + $sql .= ", date_delivery"; + $sql .= ", fk_soc"; + $sql .= ", fk_projet"; + $sql .= ", fk_shipping_method"; + $sql .= ", tracking_number"; + $sql .= ", weight"; + $sql .= ", size"; + $sql .= ", width"; + $sql .= ", height"; + $sql .= ", weight_units"; + $sql .= ", size_units"; + $sql .= ", note_private"; + $sql .= ", note_public"; + $sql .= ", model_pdf"; + $sql .= ", fk_incoterms, location_incoterms"; + $sql .= ") VALUES ("; + $sql .= "'(PROV)'"; + $sql .= ", ".$conf->entity; + $sql .= ", ".($this->ref_supplier ? "'".$this->db->escape($this->ref_supplier)."'" : "null"); + $sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null"); + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", ".$user->id; + $sql .= ", ".($this->date_reception > 0 ? "'".$this->db->idate($this->date_reception)."'" : "null"); + $sql .= ", ".($this->date_delivery > 0 ? "'".$this->db->idate($this->date_delivery)."'" : "null"); + $sql .= ", ".$this->socid; + $sql .= ", ".$this->fk_project; + $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : "null"); + $sql .= ", '".$this->db->escape($this->tracking_number)."'"; + $sql .= ", ".$this->weight; + $sql .= ", ".$this->sizeS; // TODO Should use this->trueDepth + $sql .= ", ".$this->sizeW; // TODO Should use this->trueWidth + $sql .= ", ".$this->sizeH; // TODO Should use this->trueHeight + $sql .= ", ".$this->weight_units; + $sql .= ", ".$this->size_units; + $sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); + $sql .= ", ".(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null"); + $sql .= ", ".(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null"); + $sql .= ", ".(int) $this->fk_incoterms; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $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."reception"); $sql = "UPDATE ".MAIN_DB_PREFIX."reception"; - $sql.= " SET ref = '(PROV".$this->id.")'"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET ref = '(PROV".$this->id.")'"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::create", LOG_DEBUG); if ($this->db->query($sql)) { // Insert of lines - $num=count($this->lines); + $num = count($this->lines); for ($i = 0; $i < $num; $i++) { $this->lines[$i]->fk_reception = $this->id; - if (! $this->lines[$i]->create($user) > 0) + if (!$this->lines[$i]->create($user) > 0) { $error++; } } - if (! $error && $this->id && $this->origin_id) + if (!$error && $this->id && $this->origin_id) { $ret = $this->add_object_linked(); if (!$ret) @@ -299,15 +299,15 @@ public function create($user, $notrigger = 0) // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! - $action='add'; + $action = 'add'; $hookmanager->initHooks(array('receptiondao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('socid'=>$this->id); + $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -316,33 +316,33 @@ public function create($user, $notrigger = 0) } elseif ($reshook < 0) $error++; - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('RECEPTION_CREATE', $user); + $result = $this->call_trigger('RECEPTION_CREATE', $user); if ($result < 0) { $error++; } // End call triggers - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$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 { $error++; - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -3; } @@ -350,7 +350,7 @@ public function create($user, $notrigger = 0) else { $error++; - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -2; } @@ -358,7 +358,7 @@ public function create($user, $notrigger = 0) else { $error++; - $this->error=$this->db->error()." - sql=$sql"; + $this->error = $this->db->error()." - sql=$sql"; $this->db->rollback(); return -1; } @@ -383,21 +383,21 @@ public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_supplier, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut"; - $sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; - $sql.= ", e.date_reception as date_reception, e.model_pdf, e.date_delivery"; - $sql.= ", e.fk_shipping_method, e.tracking_number"; - $sql.= ", el.fk_source as origin_id, el.sourcetype as origin"; - $sql.= ", e.note_private, e.note_public"; - $sql.= ', e.fk_incoterms, e.location_incoterms'; - $sql.= ', i.libelle as label_incoterms'; - $sql.= " FROM ".MAIN_DB_PREFIX."reception as e"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; - $sql.= " WHERE e.entity IN (".getEntity('reception').")"; - if ($id) $sql.= " AND e.rowid=".$id; - if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'"; - if ($ref_ext) $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql.= " AND e.ref_int='".$this->db->escape($ref_int)."'"; + $sql .= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; + $sql .= ", e.date_reception as date_reception, e.model_pdf, e.date_delivery"; + $sql .= ", e.fk_shipping_method, e.tracking_number"; + $sql .= ", el.fk_source as origin_id, el.sourcetype as origin"; + $sql .= ", e.note_private, e.note_public"; + $sql .= ', e.fk_incoterms, e.location_incoterms'; + $sql .= ', i.libelle as label_incoterms'; + $sql .= " FROM ".MAIN_DB_PREFIX."reception as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; + $sql .= " WHERE e.entity IN (".getEntity('reception').")"; + if ($id) $sql .= " AND e.rowid=".$id; + if ($ref) $sql .= " AND e.ref='".$this->db->escape($ref)."'"; + if ($ref_ext) $sql .= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql .= " AND e.ref_int='".$this->db->escape($ref_int)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -410,23 +410,23 @@ public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') $this->id = $obj->rowid; $this->ref = $obj->ref; $this->socid = $obj->socid; - $this->ref_supplier = $obj->ref_supplier; + $this->ref_supplier = $obj->ref_supplier; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date = $this->db->jdate($obj->date_reception); // TODO deprecated - $this->date_reception = $this->db->jdate($obj->date_reception); // TODO deprecated - $this->date_reception = $this->db->jdate($obj->date_reception); // Date real - $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed + $this->date = $this->db->jdate($obj->date_reception); // TODO deprecated + $this->date_reception = $this->db->jdate($obj->date_reception); // TODO deprecated + $this->date_reception = $this->db->jdate($obj->date_reception); // Date real + $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->fk_delivery_address = $obj->fk_address; $this->modelpdf = $obj->model_pdf; - $this->shipping_method_id = $obj->fk_shipping_method; + $this->shipping_method_id = $obj->fk_shipping_method; $this->tracking_number = $obj->tracking_number; - $this->origin = ($obj->origin?$obj->origin:'commande'); // For compatibility + $this->origin = ($obj->origin ? $obj->origin : 'commande'); // For compatibility $this->origin_id = $obj->origin_id; - $this->billed = ($obj->fk_statut==2?1:0); + $this->billed = ($obj->fk_statut == 2 ? 1 : 0); $this->trueWeight = $obj->weight; $this->weight_units = $obj->weight_units; @@ -442,8 +442,8 @@ public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') $this->note_private = $obj->note_private; // A denormalized value - $this->trueSize = $obj->size."x".$obj->width."x".$obj->height; - $this->size_units = $obj->size_units; + $this->trueSize = $obj->size."x".$obj->width."x".$obj->height; + $this->size_units = $obj->size_units; //Incoterms $this->fk_incoterms = $obj->fk_incoterms; @@ -454,7 +454,7 @@ public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') if ($this->statut == 0) $this->brouillon = 1; - $file = $conf->reception->dir_output . "/" .get_exdir($this->id, 2, 0, 0, $this, 'reception') . "/" . $this->id.".pdf"; + $file = $conf->reception->dir_output."/".get_exdir($this->id, 2, 0, 0, $this, 'reception')."/".$this->id.".pdf"; $this->pdf_filename = $file; // Tracking url @@ -463,20 +463,20 @@ public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') /* * Thirdparty */ - $result=$this->fetch_thirdparty(); + $result = $this->fetch_thirdparty(); // Retrieve all extrafields for reception // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); + $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id); /* * Lines */ - $result=$this->fetch_lines(); + $result = $this->fetch_lines(); if ($result < 0) { return -3; @@ -487,13 +487,13 @@ public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') else { dol_syslog(get_class($this).'::Fetch no reception found', LOG_ERR); - $this->error='Delivery with id '.$id.' not found'; + $this->error = 'Delivery with id '.$id.' not found'; return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -520,10 +520,10 @@ public function valid($user, $notrigger = 0) return 0; } - if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->reception->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->reception->reception_advance->validate)))) + if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate)))) { - $this->error='Permission denied'; + $this->error = 'Permission denied'; dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); return -1; } @@ -538,7 +538,7 @@ public function valid($user, $notrigger = 0) // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $numref = $this->getNextNumRef($soc); } @@ -548,25 +548,25 @@ public function valid($user, $notrigger = 0) $this->newref = $numref; - $now=dol_now(); + $now = dol_now(); // Validate $sql = "UPDATE ".MAIN_DB_PREFIX."reception SET"; - $sql.= " ref='".$this->db->escape($numref)."'"; - $sql.= ", fk_statut = 1"; - $sql.= ", date_valid = '".$this->db->idate($now)."'"; - $sql.= ", fk_user_valid = ".$user->id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " ref='".$this->db->escape($numref)."'"; + $sql .= ", fk_statut = 1"; + $sql .= ", date_valid = '".$this->db->idate($now)."'"; + $sql .= ", fk_user_valid = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::valid update reception", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } // If stock increment is done on reception (recommanded choice) - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -575,15 +575,15 @@ public function valid($user, $notrigger = 0) // Loop on each product line to add a stock movement // TODO in future, reception lines may not be linked to order line $sql = "SELECT cd.fk_product, cd.subprice,"; - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql.= " ed.eatby, ed.sellby, ed.batch"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; - $sql.= " WHERE ed.fk_reception = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql .= " ed.eatby, ed.sellby, ed.batch"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; + $sql .= " WHERE ed.fk_reception = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_commandefourndet"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $cpt = $this->db->num_rows($resql); @@ -605,10 +605,10 @@ public function valid($user, $notrigger = 0) // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref)); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref)); if ($result < 0) { $error++; - $this->errors[]=$mouvS->error; + $this->errors[] = $mouvS->error; $this->errors = array_merge($this->errors, $mouvS->errors); break; } @@ -619,10 +619,10 @@ public function valid($user, $notrigger = 0) // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. // Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); if ($result < 0) { $error++; - $this->errors[]=$mouvS->error; + $this->errors[] = $mouvS->error; $this->errors = array_merge($this->errors, $mouvS->errors); break; } @@ -632,7 +632,7 @@ public function valid($user, $notrigger = 0) else { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -2; } } @@ -640,20 +640,20 @@ public function valid($user, $notrigger = 0) // Change status of order to "reception in process" $ret = $this->setStatut(4, $this->origin_id, 'commande_fournisseur'); - if (! $ret) + if (!$ret) { $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('RECEPTION_VALIDATE', $user); + $result = $this->call_trigger('RECEPTION_VALIDATE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->oldref = $this->ref; @@ -661,17 +661,17 @@ public function valid($user, $notrigger = 0) if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'reception/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'reception/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'reception/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'reception/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($numref); $dirsource = $conf->reception->dir_output.'/'.$oldref; $dirdest = $conf->reception->dir_output.'/'.$newref; - if (! $error && file_exists($dirsource)) + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); @@ -679,13 +679,13 @@ public function valid($user, $notrigger = 0) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->reception->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) + $listoffiles = dol_dir_list($conf->reception->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); } } @@ -694,26 +694,26 @@ public function valid($user, $notrigger = 0) } // Set new ref and current status - if (! $error) + if (!$error) { $this->ref = $numref; $this->statut = 1; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::valid ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -748,31 +748,31 @@ public function addline($entrepot_id, $id, $qty, $array_options = 0, $comment = $supplierorderline = new CommandeFournisseurLigne($this->db); $supplierorderline->fetch($id); - if (! empty($conf->stock->enabled) && ! empty($supplierorderline->fk_product)) + if (!empty($conf->stock->enabled) && !empty($supplierorderline->fk_product)) { $fk_product = $supplierorderline->fk_product; - if (! ($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_RECEPTIONS)) + if (!($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_RECEPTIONS)) { $langs->load("errors"); - $this->error=$langs->trans("ErrorWarehouseRequiredIntoReceptionLine"); + $this->error = $langs->trans("ErrorWarehouseRequiredIntoReceptionLine"); return -1; } } // extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used $line->array_options = $array_options; $line->fk_product = $fk_product; - $line->fk_commande = $supplierorderline->fk_commande ; - $line->fk_user = $user->id ; + $line->fk_commande = $supplierorderline->fk_commande; + $line->fk_user = $user->id; $line->comment = $comment; $line->batch = $batch; $line->eatby = $eatby; $line->sellby = $sellby; - $line->status=1; - $line->fk_reception=$this->id; + $line->status = 1; + $line->fk_reception = $this->id; $this->lines[$num] = $line; } @@ -788,29 +788,29 @@ public function addline($entrepot_id, $id, $qty, $array_options = 0, $comment = public function update($user = null, $notrigger = 0) { global $conf; - $error=0; + $error = 0; // Clean parameters - if (isset($this->ref)) $this->ref=trim($this->ref); - if (isset($this->entity)) $this->entity=trim($this->entity); - if (isset($this->ref_supplier)) $this->ref_supplier=trim($this->ref_supplier); - if (isset($this->socid)) $this->socid=trim($this->socid); - if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); - if (isset($this->fk_user_valid)) $this->fk_user_valid=trim($this->fk_user_valid); - if (isset($this->fk_delivery_address)) $this->fk_delivery_address=trim($this->fk_delivery_address); - if (isset($this->shipping_method_id)) $this->shipping_method_id=trim($this->shipping_method_id); - if (isset($this->tracking_number)) $this->tracking_number=trim($this->tracking_number); - if (isset($this->statut)) $this->statut=(int) $this->statut; - if (isset($this->trueDepth)) $this->trueDepth=trim($this->trueDepth); - if (isset($this->trueWidth)) $this->trueWidth=trim($this->trueWidth); - if (isset($this->trueHeight)) $this->trueHeight=trim($this->trueHeight); - if (isset($this->size_units)) $this->size_units=trim($this->size_units); - if (isset($this->weight_units)) $this->weight_units=trim($this->weight_units); - if (isset($this->trueWeight)) $this->weight=trim($this->trueWeight); - if (isset($this->note_private)) $this->note=trim($this->note_private); - if (isset($this->note_public)) $this->note=trim($this->note_public); - if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); + if (isset($this->ref)) $this->ref = trim($this->ref); + if (isset($this->entity)) $this->entity = trim($this->entity); + if (isset($this->ref_supplier)) $this->ref_supplier = trim($this->ref_supplier); + if (isset($this->socid)) $this->socid = trim($this->socid); + if (isset($this->fk_user_author)) $this->fk_user_author = trim($this->fk_user_author); + if (isset($this->fk_user_valid)) $this->fk_user_valid = trim($this->fk_user_valid); + if (isset($this->fk_delivery_address)) $this->fk_delivery_address = trim($this->fk_delivery_address); + if (isset($this->shipping_method_id)) $this->shipping_method_id = trim($this->shipping_method_id); + if (isset($this->tracking_number)) $this->tracking_number = trim($this->tracking_number); + if (isset($this->statut)) $this->statut = (int) $this->statut; + if (isset($this->trueDepth)) $this->trueDepth = trim($this->trueDepth); + if (isset($this->trueWidth)) $this->trueWidth = trim($this->trueWidth); + if (isset($this->trueHeight)) $this->trueHeight = trim($this->trueHeight); + if (isset($this->size_units)) $this->size_units = trim($this->size_units); + if (isset($this->weight_units)) $this->weight_units = trim($this->weight_units); + if (isset($this->trueWeight)) $this->weight = trim($this->trueWeight); + if (isset($this->note_private)) $this->note = trim($this->note_private); + if (isset($this->note_public)) $this->note = trim($this->note_public); + if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); // Check parameters @@ -819,44 +819,44 @@ public function update($user = null, $notrigger = 0) // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."reception SET"; - $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; - $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; - $sql.= " ref_supplier=".(isset($this->ref_supplier)?"'".$this->db->escape($this->ref_supplier)."'":"null").","; - $sql.= " fk_soc=".(isset($this->socid)?$this->socid:"null").","; - $sql.= " date_creation=".(dol_strlen($this->date_creation)!=0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; - $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; - $sql.= " date_valid=".(dol_strlen($this->date_valid)!=0 ? "'".$this->db->idate($this->date_valid)."'" : 'null').","; - $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->fk_user_valid:"null").","; - $sql.= " date_reception=".(dol_strlen($this->date_reception)!=0 ? "'".$this->db->idate($this->date_reception)."'" : 'null').","; - $sql.= " date_delivery=".(dol_strlen($this->date_delivery)!=0 ? "'".$this->db->idate($this->date_delivery)."'" : 'null').","; - $sql.= " fk_shipping_method=".((isset($this->shipping_method_id) && $this->shipping_method_id > 0)?$this->shipping_method_id:"null").","; - $sql.= " tracking_number=".(isset($this->tracking_number)?"'".$this->db->escape($this->tracking_number)."'":"null").","; - $sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").","; - $sql.= " height=".(($this->trueHeight != '')?$this->trueHeight:"null").","; - $sql.= " width=".(($this->trueWidth != '')?$this->trueWidth:"null").","; - $sql.= " size_units=".(isset($this->size_units)?$this->size_units:"null").","; - $sql.= " size=".(($this->trueDepth != '')?$this->trueDepth:"null").","; - $sql.= " weight_units=".(isset($this->weight_units)?$this->weight_units:"null").","; - $sql.= " weight=".(($this->trueWeight != '')?$this->trueWeight:"null").","; - $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; - $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; - $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; - $sql.= " entity=".$conf->entity; - - $sql.= " WHERE rowid=".$this->id; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; + $sql .= " ref_supplier=".(isset($this->ref_supplier) ? "'".$this->db->escape($this->ref_supplier)."'" : "null").","; + $sql .= " fk_soc=".(isset($this->socid) ? $this->socid : "null").","; + $sql .= " date_creation=".(dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').","; + $sql .= " fk_user_author=".(isset($this->fk_user_author) ? $this->fk_user_author : "null").","; + $sql .= " date_valid=".(dol_strlen($this->date_valid) != 0 ? "'".$this->db->idate($this->date_valid)."'" : 'null').","; + $sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? $this->fk_user_valid : "null").","; + $sql .= " date_reception=".(dol_strlen($this->date_reception) != 0 ? "'".$this->db->idate($this->date_reception)."'" : 'null').","; + $sql .= " date_delivery=".(dol_strlen($this->date_delivery) != 0 ? "'".$this->db->idate($this->date_delivery)."'" : 'null').","; + $sql .= " fk_shipping_method=".((isset($this->shipping_method_id) && $this->shipping_method_id > 0) ? $this->shipping_method_id : "null").","; + $sql .= " tracking_number=".(isset($this->tracking_number) ? "'".$this->db->escape($this->tracking_number)."'" : "null").","; + $sql .= " fk_statut=".(isset($this->statut) ? $this->statut : "null").","; + $sql .= " height=".(($this->trueHeight != '') ? $this->trueHeight : "null").","; + $sql .= " width=".(($this->trueWidth != '') ? $this->trueWidth : "null").","; + $sql .= " size_units=".(isset($this->size_units) ? $this->size_units : "null").","; + $sql .= " size=".(($this->trueDepth != '') ? $this->trueDepth : "null").","; + $sql .= " weight_units=".(isset($this->weight_units) ? $this->weight_units : "null").","; + $sql .= " weight=".(($this->trueWeight != '') ? $this->trueWeight : "null").","; + $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; + $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; + $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; + $sql .= " entity=".$conf->entity; + + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $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('RECEPTION_MODIFY', $user); + $result = $this->call_trigger('RECEPTION_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } @@ -865,13 +865,13 @@ public function update($user = null, $notrigger = 0) // 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 { @@ -891,8 +891,8 @@ public function delete(User $user) global $conf, $langs, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; - $this->error=''; + $error = 0; + $this->error = ''; $this->db->begin(); @@ -906,13 +906,13 @@ public function delete(User $user) // Loop on each product line to add a stock movement $sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot, ed.eatby, ed.sellby, ed.batch, ed.rowid as commande_fournisseur_dispatch_id"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; - $sql.= " WHERE ed.fk_reception = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; + $sql .= " WHERE ed.fk_reception = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_commandefourndet"; dol_syslog(get_class($this)."::delete select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $cpt = $this->db->num_rows($resql); @@ -925,42 +925,42 @@ public function delete(User $user) // we do not log origin because it will be deleted $mouvS->origin = null; - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ReceptionDeletedInDolibarr", $this->ref), '', $obj->eatby, $obj->sellby, $obj->batch); // Price is set to 0, because we don't want to see WAP changed + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, 0, $langs->trans("ReceptionDeletedInDolibarr", $this->ref), '', $obj->eatby, $obj->sellby, $obj->batch); // Price is set to 0, because we don't want to see WAP changed } } else { - $error++;$this->errors[]="Error ".$this->db->lasterror(); + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch"; - $sql.= " WHERE fk_reception = ".$this->id; + $sql .= " WHERE fk_reception = ".$this->id; - if ( $this->db->query($sql) ) + if ($this->db->query($sql)) { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."reception"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; if ($this->db->query($sql)) { // Call trigger - $result=$this->call_trigger('RECEPTION_DELETE', $user); + $result = $this->call_trigger('RECEPTION_DELETE', $user); if ($result < 0) { $error++; } // End call triggers - if (! empty($this->origin) && $this->origin_id > 0) + if (!empty($this->origin) && $this->origin_id > 0) { $this->fetch_origin(); - $origin=$this->origin; + $origin = $this->origin; if ($this->$origin->statut == 4) // If order source of reception is "partially received" { // Check if there is no more reception. If not, we can move back status of order to "validated" instead of "reception in progress" @@ -973,19 +973,19 @@ public function delete(User $user) } } - if (! $error) + if (!$error) { $this->db->commit(); // We delete PDFs $ref = dol_sanitizeFileName($this->ref); - if (! empty($conf->reception->dir_output)) + if (!empty($conf->reception->dir_output)) { - $dir = $conf->reception->dir_output . '/' . $ref ; - $file = $dir . '/' . $ref . '.pdf'; + $dir = $conf->reception->dir_output.'/'.$ref; + $file = $dir.'/'.$ref.'.pdf'; if (file_exists($file)) { - if (! dol_delete_file($file)) + if (!dol_delete_file($file)) { return 0; } @@ -994,7 +994,7 @@ public function delete(User $user) { if (!dol_delete_dir_recursive($dir)) { - $this->error=$langs->trans("ErrorCanNotDeleteDir", $dir); + $this->error = $langs->trans("ErrorCanNotDeleteDir", $dir); return 0; } } @@ -1010,21 +1010,21 @@ public function delete(User $user) } else { - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -3; } } else { - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -2; } } else { - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error = $this->db->lasterror()." - sql=$sql"; $this->db->rollback(); return -1; } @@ -1050,41 +1050,41 @@ public function fetch_lines() $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch WHERE fk_reception='.$this->id; $resql = $db->query($sql); - if(!empty($resql)){ + if (!empty($resql)) { $this->lines = array(); - while ($obj = $resql->fetch_object()){ + while ($obj = $resql->fetch_object()) { $line = new CommandeFournisseurDispatch($db); $line->fetch($obj->rowid); $line->fetch_product(); $sql_commfourndet = 'SELECT qty, ref, label, tva_tx, vat_src_code, subprice, multicurrency_subprice, remise_percent FROM llx_commande_fournisseurdet WHERE rowid='.$line->fk_commandefourndet; $resql_commfourndet = $db->query($sql_commfourndet); - if(!empty($resql_commfourndet)){ + if (!empty($resql_commfourndet)) { $obj = $db->fetch_object($resql_commfourndet); $line->qty_asked = $obj->qty; $line->description = $line->comment; - $line->desc = $line->comment; + $line->desc = $line->comment; $line->tva_tx = $obj->tva_tx; $line->vat_src_code = $obj->vat_src_code; $line->subprice = $obj->subprice; $line->multicurrency_subprice = $obj->multicurrency_subprice; $line->remise_percent = $obj->remise_percent; - $line->label = !empty($obj->label)?$obj->label:$line->product->label; + $line->label = !empty($obj->label) ? $obj->label : $line->product->label; $line->ref_supplier = $obj->ref; - }else { + } else { $line->qty_asked = 0; $line->description = ''; $line->label = $obj->label; } - $pu_ht=($line->subprice*$line->qty)*(100-$line->remise_percent)/100; - $tva = $pu_ht*$line->tva_tx/100; + $pu_ht = ($line->subprice * $line->qty) * (100 - $line->remise_percent) / 100; + $tva = $pu_ht * $line->tva_tx / 100; $this->total_ht += $pu_ht; - $this->total_tva += $pu_ht*$line->tva_tx/100; + $this->total_tva += $pu_ht * $line->tva_tx / 100; - $this->total_ttc += $pu_ht+$tva; + $this->total_ttc += $pu_ht + $tva; - $this->lines[]=$line; + $this->lines[] = $line; } return 1; @@ -1107,35 +1107,35 @@ public function fetch_lines() public function getNomUrl($withpicto = 0, $option = 0, $max = 0, $short = 0, $notooltip = 0) { global $langs; - $result=''; - $label = '' . $langs->trans("ShowReception") . ''; - $label .= '
' . $langs->trans('Ref') . ': '.$this->ref; + $result = ''; + $label = ''.$langs->trans("ShowReception").''; + $label .= '
'.$langs->trans('Ref').': '.$this->ref; $label .= '
'.$langs->trans('RefSupplier').': '.($this->ref_supplier ? $this->ref_supplier : $this->ref_client); $url = DOL_URL_ROOT.'/reception/card.php?id='.$this->id; if ($short) return $url; - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowReception"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowReception"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } $linkstart = ''; - $linkend=''; + $linkend = ''; - $picto='sending'; + $picto = 'sending'; - if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend); - if ($withpicto && $withpicto != 2) $result.=' '; - $result.=$linkstart.$this->ref.$linkend; + if ($withpicto) $result .= ($linkstart.img_object(($notooltip ? '' : $label), $picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend); + if ($withpicto && $withpicto != 2) $result .= ' '; + $result .= $linkstart.$this->ref.$linkend; return $result; } @@ -1186,7 +1186,7 @@ public function initAsSpecimen() include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php'; - $now=dol_now(); + $now = dol_now(); dol_syslog(get_class($this)."::initAsSpecimen"); @@ -1194,8 +1194,8 @@ public function initAsSpecimen() $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { @@ -1209,20 +1209,20 @@ public function initAsSpecimen() } } - $order=new CommandeFournisseur($this->db); + $order = new CommandeFournisseur($this->db); $order->initAsSpecimen(); // Initialise parametres - $this->id=0; + $this->id = 0; $this->ref = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->statut = 1; $this->livraison_id = 0; $this->date = $now; $this->date_creation = $now; $this->date_valid = $now; $this->date_delivery = $now; - $this->date_reception = $now + 24*3600; + $this->date_reception = $now + 24 * 3600; $this->entrepot_id = 0; $this->fk_delivery_address = 0; @@ -1241,14 +1241,14 @@ public function initAsSpecimen() $xnbp = 0; while ($xnbp < $nbp) { - $line=new CommandeFournisseurDispatch($this->db); - $line->desc=$langs->trans("Description")." ".$xnbp; - $line->libelle=$langs->trans("Description")." ".$xnbp; - $line->qty=10; + $line = new CommandeFournisseurDispatch($this->db); + $line->desc = $langs->trans("Description")." ".$xnbp; + $line->libelle = $langs->trans("Description")." ".$xnbp; + $line->qty = 10; - $line->fk_product=$this->commande->lines[$xnbp]->fk_product; + $line->fk_product = $this->commande->lines[$xnbp]->fk_product; - $this->lines[]=$line; + $this->lines[] = $line; $xnbp++; } } @@ -1267,11 +1267,11 @@ public function set_date_livraison($user, $date_livraison) if ($user->rights->reception->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."reception"; - $sql.= " SET date_delivery = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET date_delivery = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::set_date_livraison", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->date_delivery = $date_livraison; @@ -1279,7 +1279,7 @@ public function set_date_livraison($user, $date_livraison) } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1302,17 +1302,17 @@ public function fetch_delivery_methods() $this->meths = array(); $sql = "SELECT em.rowid, em.code, em.libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - $sql.= " WHERE em.active = 1"; - $sql.= " ORDER BY em.libelle ASC"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; + $sql .= " WHERE em.active = 1"; + $sql .= " ORDER BY em.libelle ASC"; $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { - $label=$langs->trans('ReceptionMethod'.$obj->code); - $this->meths[$obj->rowid] = ($label != 'ReceptionMethod'.$obj->code?$label:$obj->libelle); + $label = $langs->trans('ReceptionMethod'.$obj->code); + $this->meths[$obj->rowid] = ($label != 'ReceptionMethod'.$obj->code ? $label : $obj->libelle); } } } @@ -1330,19 +1330,19 @@ public function list_delivery_methods($id = '') global $langs; $this->listmeths = array(); - $i=0; + $i = 0; $sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - if ($id!='') $sql.= " WHERE em.rowid=".$id; + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; + if ($id != '') $sql .= " WHERE em.rowid=".$id; $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { $this->listmeths[$i]['rowid'] = $obj->rowid; $this->listmeths[$i]['code'] = $obj->code; - $label=$langs->trans('ReceptionMethod'.$obj->code); - $this->listmeths[$i]['libelle'] = ($label != 'ReceptionMethod'.$obj->code?$label:$obj->libelle); + $label = $langs->trans('ReceptionMethod'.$obj->code); + $this->listmeths[$i]['libelle'] = ($label != 'ReceptionMethod'.$obj->code ? $label : $obj->libelle); $this->listmeths[$i]['description'] = $obj->description; $this->listmeths[$i]['tracking'] = $obj->tracking; $this->listmeths[$i]['active'] = $obj->active; @@ -1362,20 +1362,20 @@ public function list_delivery_methods($id = '') public function update_delivery_method($id = '') { // phpcs:enable - if ($id=='') + if ($id == '') { $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)"; - $sql.=" VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; + $sql .= " VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; $resql = $this->db->query($sql); } else { $sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET"; - $sql.= " code='".$this->db->escape($this->update['code'])."'"; - $sql.= ",libelle='".$this->db->escape($this->update['libelle'])."'"; - $sql.= ",description='".$this->db->escape($this->update['description'])."'"; - $sql.= ",tracking='".$this->db->escape($this->update['tracking'])."'"; - $sql.= " WHERE rowid=".$id; + $sql .= " code='".$this->db->escape($this->update['code'])."'"; + $sql .= ",libelle='".$this->db->escape($this->update['libelle'])."'"; + $sql .= ",description='".$this->db->escape($this->update['description'])."'"; + $sql .= ",tracking='".$this->db->escape($this->update['tracking'])."'"; + $sql .= " WHERE rowid=".$id; $resql = $this->db->query($sql); } if ($resql < 0) dol_print_error($this->db, ''); @@ -1393,7 +1393,7 @@ public function activ_delivery_method($id) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; - $sql.= ' WHERE rowid='.$id; + $sql .= ' WHERE rowid='.$id; $resql = $this->db->query($sql); } @@ -1410,7 +1410,7 @@ public function disable_delivery_method($id) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; - $sql.= ' WHERE rowid='.$id; + $sql .= ' WHERE rowid='.$id; $resql = $this->db->query($sql); } @@ -1424,11 +1424,11 @@ public function disable_delivery_method($id) */ public function getUrlTrackingStatus($value = '') { - if (! empty($this->shipping_method_id)) + if (!empty($this->shipping_method_id)) { $sql = "SELECT em.code, em.tracking"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - $sql.= " WHERE em.rowid = ".$this->shipping_method_id; + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; + $sql .= " WHERE em.rowid = ".$this->shipping_method_id; $resql = $this->db->query($sql); if ($resql) @@ -1443,7 +1443,7 @@ public function getUrlTrackingStatus($value = '') if (!empty($tracking) && !empty($value)) { $url = str_replace('{TRACKID}', $value, $tracking); - $this->tracking_url = sprintf(''.($value?$value:'url').'', $url, $url); + $this->tracking_url = sprintf(''.($value ? $value : 'url').'', $url, $url); } else { @@ -1458,16 +1458,16 @@ public function getUrlTrackingStatus($value = '') */ public function setClosed() { - global $conf,$langs,$user; + global $conf, $langs, $user; - $error=0; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'reception SET fk_statut='.self::STATUS_CLOSED; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { // Set order billed if 100% of order is received (qty in reception lines match qty in order lines) @@ -1476,17 +1476,17 @@ public function setClosed() $order = new CommandeFournisseur($this->db); $order->fetch($this->origin_id); - $order->loadReceptions(self::STATUS_CLOSED); // Fill $order->receptions = array(orderlineid => qty) + $order->loadReceptions(self::STATUS_CLOSED); // Fill $order->receptions = array(orderlineid => qty) $receptions_match_order = 1; - foreach($order->lines as $line) + foreach ($order->lines as $line) { $lineid = $line->id; $qty = $line->qty; - if (($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $order->receptions[$lineid] < $qty) + if (($line->product_type == 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $order->receptions[$lineid] < $qty) { $receptions_match_order = 0; - $text='Qty for order line id '.$lineid.' is '.$qty.'. However in the receptions with status Reception::STATUS_CLOSED='.self::STATUS_CLOSED.' we have qty = '.$order->receptions[$lineid].', so we can t close order'; + $text = 'Qty for order line id '.$lineid.' is '.$qty.'. However in the receptions with status Reception::STATUS_CLOSED='.self::STATUS_CLOSED.' we have qty = '.$order->receptions[$lineid].', so we can t close order'; dol_syslog($text); break; } @@ -1498,11 +1498,11 @@ public function setClosed() } } - $this->statut=self::STATUS_CLOSED; + $this->statut = self::STATUS_CLOSED; // If stock increment is done on closing - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -1511,15 +1511,15 @@ public function setClosed() // Loop on each product line to add a stock movement // TODO possibilite de receptionner a partir d'une propale ou autre origine ? $sql = "SELECT cd.fk_product, cd.subprice,"; - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql.= " ed.eatby, ed.sellby, ed.batch"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; - $sql.= " WHERE ed.fk_reception = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql .= " ed.eatby, ed.sellby, ed.batch"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; + $sql .= " WHERE ed.fk_reception = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_commandefourndet"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { @@ -1541,7 +1541,7 @@ public function setClosed() // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $numref)); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $numref)); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1553,7 +1553,7 @@ public function setClosed() // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); if ($result < 0) { $this->error = $mouvS->error; @@ -1565,15 +1565,15 @@ public function setClosed() } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } // Call trigger - if (! $error) + if (!$error) { - $result=$this->call_trigger('RECEPTION_CLOSED', $user); + $result = $this->call_trigger('RECEPTION_CLOSED', $user); if ($result < 0) { $error++; } @@ -1585,7 +1585,7 @@ public function setClosed() $error++; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1607,7 +1607,7 @@ public function set_billed() { // phpcs:enable global $user; - $error=0; + $error = 0; $this->db->begin(); @@ -1616,20 +1616,20 @@ public function set_billed() $sql = 'UPDATE '.MAIN_DB_PREFIX.'reception SET billed=1'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->statut=2; - $this->billed=1; + $this->statut = 2; + $this->billed = 1; // Call trigger - $result=$this->call_trigger('RECEPTION_BILLED', $user); + $result = $this->call_trigger('RECEPTION_BILLED', $user); if ($result < 0) { $error++; } } else { $error++; - $this->errors[]=$this->db->lasterror; + $this->errors[] = $this->db->lasterror; } if (empty($error)) { @@ -1650,23 +1650,23 @@ public function set_billed() */ public function reOpen() { - global $conf,$langs,$user; + global $conf, $langs, $user; - $error=0; + $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'reception SET fk_statut=1, billed=0'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->statut=1; - $this->billed=0; + $this->statut = 1; + $this->billed = 0; // If stock increment is done on closing - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $numref = $this->ref; @@ -1675,15 +1675,15 @@ public function reOpen() // Loop on each product line to add a stock movement // TODO possibilite de receptionner a partir d'une propale ou autre origine $sql = "SELECT ed.fk_product, cd.subprice,"; - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql.= " ed.eatby, ed.sellby, ed.batch"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; - $sql.= " WHERE ed.fk_reception = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql .= " ed.eatby, ed.sellby, ed.batch"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; + $sql .= " WHERE ed.fk_reception = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_commandefourndet"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $cpt = $this->db->num_rows($resql); @@ -1706,7 +1706,7 @@ public function reOpen() // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref)); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref)); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1718,7 +1718,7 @@ public function reOpen() // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1729,31 +1729,31 @@ public function reOpen() } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } - if (! $error) + if (!$error) { // Call trigger - $result=$this->call_trigger('RECEPTION_REOPEN', $user); + $result = $this->call_trigger('RECEPTION_REOPEN', $user); if ($result < 0) { $error++; } } - if($this->origin == 'order_supplier'){ + if ($this->origin == 'order_supplier') { $commande = new CommandeFournisseur($this->db); $commande->fetch($this->origin_id); $commande->setStatus($user, 4); } } else { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1774,9 +1774,9 @@ public function reOpen() public function setDraft($user) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; - $error=0; + $error = 0; // Protection if ($this->statut <= self::STATUS_DRAFT) @@ -1784,24 +1784,24 @@ public function setDraft($user) return 0; } - if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->reception->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->reception->reception_advance->validate)))) + if (!((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate)))) { - $this->error='Permission denied'; + $this->error = 'Permission denied'; return -1; } $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."reception"; - $sql.= " SET fk_statut = ".self::STATUS_DRAFT; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET fk_statut = ".self::STATUS_DRAFT; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(__METHOD__, LOG_DEBUG); if ($this->db->query($sql)) { // If stock increment is done on closing - if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) + if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; @@ -1810,15 +1810,15 @@ public function setDraft($user) // Loop on each product line to add a stock movement // TODO possibilite de receptionner a partir d'une propale ou autre origine $sql = "SELECT cd.fk_product, cd.subprice,"; - $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql.= " ed.eatby, ed.sellby, ed.batch"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; - $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; - $sql.= " WHERE ed.fk_reception = ".$this->id; - $sql.= " AND cd.rowid = ed.fk_commandefourndet"; + $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; + $sql .= " ed.eatby, ed.sellby, ed.batch"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; + $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; + $sql .= " WHERE ed.fk_reception = ".$this->id; + $sql .= " AND cd.rowid = ed.fk_commandefourndet"; dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $cpt = $this->db->num_rows($resql); @@ -1841,7 +1841,7 @@ public function setDraft($user) // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref)); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref)); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1854,7 +1854,7 @@ public function setDraft($user) // line with batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1865,14 +1865,14 @@ public function setDraft($user) } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } if (!$error) { // Call trigger - $result=$this->call_trigger('RECEPTION_UNVALIDATE', $user); + $result = $this->call_trigger('RECEPTION_UNVALIDATE', $user); if ($result < 0) $error++; } if ($this->origin == 'order_supplier') @@ -1907,7 +1907,7 @@ public function setDraft($user) } if (!$error) { - $this->statut=self::STATUS_DRAFT; + $this->statut = self::STATUS_DRAFT; $this->db->commit(); return 1; } else { @@ -1917,7 +1917,7 @@ public function setDraft($user) } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -1935,17 +1935,17 @@ public function setDraft($user) */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf,$langs; + global $conf, $langs; $langs->load("receptions"); - if (! dol_strlen($modele)) + if (!dol_strlen($modele)) { $modele = 'squille'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->RECEPTION_ADDON_PDF)) { + } elseif (!empty($conf->global->RECEPTION_ADDON_PDF)) { $modele = $conf->global->RECEPTION_ADDON_PDF; } } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 6b3756790525b..cfd3e7f8b9507 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -45,24 +45,24 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $langs->loadLangs(array("companies", "commercial", "bills", "banks", "users")); -if (! empty($conf->adherent->enabled)) $langs->load("members"); -if (! empty($conf->categorie->enabled)) $langs->load("categories"); -if (! empty($conf->incoterm->enabled)) $langs->load("incoterm"); -if (! empty($conf->notification->enabled)) $langs->load("mails"); +if (!empty($conf->adherent->enabled)) $langs->load("members"); +if (!empty($conf->categorie->enabled)) $langs->load("categories"); +if (!empty($conf->incoterm->enabled)) $langs->load("incoterm"); +if (!empty($conf->notification->enabled)) $langs->load("mails"); -$mesg=''; $error=0; $errors=array(); +$mesg = ''; $error = 0; $errors = array(); $action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'); $cancel = GETPOST('cancel', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; -if (empty($socid) && $action == 'view') $action='create'; +$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); +if ($user->socid) $socid = $user->socid; +if (empty($socid) && $action == 'view') $action = 'create'; $object = new Societe($db); $extrafields = new ExtraFields($db); @@ -73,11 +73,11 @@ $socialnetworks = getArrayOfSocialNetworks(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('thirdpartycard','globalcard')); +$hookmanager->initHooks(array('thirdpartycard', 'globalcard')); if ($socid > 0) $object->fetch($socid); -if (! ($object->id > 0) && $action == 'view') +if (!($object->id > 0) && $action == 'view') { $langs->load("errors"); print($langs->trans('ErrorRecordNotFound')); @@ -86,9 +86,9 @@ // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($socid); -$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); @@ -103,16 +103,16 @@ * Actions */ -$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas); +$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) { - $action=''; - if (! empty($backtopage)) + $action = ''; + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -148,7 +148,7 @@ // Recopy some data $object->client = $object->client | $soc_origin->client; $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur; - $listofproperties=array( + $listofproperties = array( 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'twitter', 'facebook', 'linkedin', 'socialnetworks', 'url', 'barcode', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', @@ -162,7 +162,7 @@ } // Concat some data - $listofproperties=array( + $listofproperties = array( 'note_public', 'note_private' ); foreach ($listofproperties as $property) @@ -213,7 +213,7 @@ } // Move links - if (! $error) + if (!$error) { $objects = array( 'Adherent' => '/adherents/class/adherent.class.php', @@ -253,7 +253,7 @@ } // External modules should update their ones too - if (! $error) + if (!$error) { $reshook = $hookmanager->executeHooks('replaceThirdparty', array( 'soc_origin' => $soc_origin->id, @@ -268,12 +268,12 @@ } - if (! $error) + if (!$error) { - $object->context=array('merge'=>1, 'mergefromid'=>$soc_origin->id); + $object->context = array('merge'=>1, 'mergefromid'=>$soc_origin->id); // Call trigger - $result=$object->call_trigger('COMPANY_MODIFY', $user); + $result = $object->call_trigger('COMPANY_MODIFY', $user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -309,28 +309,28 @@ if (GETPOST('getcustomercode')) { // We defined value code_client - $_POST["customer_code"]="Acompleter"; + $_POST["customer_code"] = "Acompleter"; } if (GETPOST('getsuppliercode')) { // We defined value code_fournisseur - $_POST["supplier_code"]="Acompleter"; + $_POST["supplier_code"] = "Acompleter"; } - if($action=='set_localtax1') + if ($action == 'set_localtax1') { //obtidre selected del combobox - $value=GETPOST('lt1'); + $value = GETPOST('lt1'); $object->fetch($socid); - $res=$object->setValueFrom('localtax1_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); + $res = $object->setValueFrom('localtax1_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); } - if($action=='set_localtax2') + if ($action == 'set_localtax2') { //obtidre selected del combobox - $value=GETPOST('lt2'); + $value = GETPOST('lt2'); $object->fetch($socid); - $res=$object->setValueFrom('localtax2_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); + $res = $object->setValueFrom('localtax2_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); } if ($action == 'update_extras') { @@ -344,7 +344,7 @@ $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { $result = $object->insertExtraFields('COMPANY_MODIFY'); if ($result < 0) @@ -358,12 +358,12 @@ } // Add new or update third party - if ((! GETPOST('getcustomercode') && ! GETPOST('getsuppliercode')) + if ((!GETPOST('getcustomercode') && !GETPOST('getsuppliercode')) && ($action == 'add' || $action == 'update') && $user->rights->societe->creer) { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - if (! GETPOST('name')) + if (!GETPOST('name')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdPartyName")), null, 'errors'); $error++; @@ -379,51 +379,51 @@ $error++; } - if (! $error) + if (!$error) { if ($action == 'update') { - $ret=$object->fetch($socid); + $ret = $object->fetch($socid); $object->oldcopy = clone $object; } - else $object->canvas=$canvas; + else $object->canvas = $canvas; if (GETPOST("private", 'int') == 1) // Ask to create a contact { $object->particulier = GETPOST("private"); - $object->name = dolGetFirstLastname(GETPOST('firstname', 'alpha'), GETPOST('name', 'alpha')); - $object->civility_id = GETPOST('civility_id'); // Note: civility id is a code, not an int + $object->name = dolGetFirstLastname(GETPOST('firstname', 'alpha'), GETPOST('name', 'alpha')); + $object->civility_id = GETPOST('civility_id'); // Note: civility id is a code, not an int // Add non official properties - $object->name_bis = GETPOST('name', 'alpha'); - $object->firstname = GETPOST('firstname', 'alpha'); + $object->name_bis = GETPOST('name', 'alpha'); + $object->firstname = GETPOST('firstname', 'alpha'); } else { - $object->name = GETPOST('name', 'alpha'); + $object->name = GETPOST('name', 'alpha'); } - $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity); - $object->name_alias = GETPOST('name_alias'); + $object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity); + $object->name_alias = GETPOST('name_alias'); $object->address = GETPOST('address'); - $object->zip = GETPOST('zipcode', 'alpha'); - $object->town = GETPOST('town', 'alpha'); - $object->country_id = GETPOST('country_id', 'int'); - $object->state_id = GETPOST('state_id', 'int'); + $object->zip = GETPOST('zipcode', 'alpha'); + $object->town = GETPOST('town', 'alpha'); + $object->country_id = GETPOST('country_id', 'int'); + $object->state_id = GETPOST('state_id', 'int'); //$object->skype = GETPOST('skype', 'alpha'); //$object->twitter = GETPOST('twitter', 'alpha'); //$object->facebook = GETPOST('facebook', 'alpha'); //$object->linkedin = GETPOST('linkedin', 'alpha'); $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($key, 'alphanohtml'); } } } - $object->phone = GETPOST('phone', 'alpha'); + $object->phone = GETPOST('phone', 'alpha'); $object->fax = GETPOST('fax', 'alpha'); - $object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)); + $object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)); $object->url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL)); $object->idprof1 = trim(GETPOST('idprof1', 'alpha')); $object->idprof2 = trim(GETPOST('idprof2', 'alpha')); @@ -432,14 +432,14 @@ $object->idprof5 = trim(GETPOST('idprof5', 'alpha')); $object->idprof6 = trim(GETPOST('idprof6', 'alpha')); $object->prefix_comm = GETPOST('prefix_comm', 'alpha'); - $object->code_client = GETPOSTISSET('customer_code')?GETPOST('customer_code', 'alpha'):GETPOST('code_client', 'alpha'); - $object->code_fournisseur = GETPOSTISSET('supplier_code')?GETPOST('supplier_code', 'alpha'):GETPOST('code_fournisseur', 'alpha'); + $object->code_client = GETPOSTISSET('customer_code') ?GETPOST('customer_code', 'alpha') : GETPOST('code_client', 'alpha'); + $object->code_fournisseur = GETPOSTISSET('supplier_code') ?GETPOST('supplier_code', 'alpha') : GETPOST('code_fournisseur', 'alpha'); $object->capital = GETPOST('capital', 'alpha'); $object->barcode = GETPOST('barcode', 'alpha'); $object->tva_intra = GETPOST('tva_intra', 'alpha'); $object->tva_assuj = GETPOST('assujtva_value', 'alpha'); - $object->status = GETPOST('status', 'alpha'); + $object->status = GETPOST('status', 'alpha'); // Local Taxes $object->localtax1_assuj = GETPOST('localtax1assuj_value', 'alpha'); @@ -448,17 +448,17 @@ $object->localtax1_value = GETPOST('lt1', 'alpha'); $object->localtax2_value = GETPOST('lt2', 'alpha'); - $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int'); + $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int'); $object->effectif_id = GETPOST('effectif_id', 'int'); - $object->typent_id = GETPOST('typent_id', 'int'); + $object->typent_id = GETPOST('typent_id', 'int'); - $object->typent_code = dol_getIdFromCode($db, $object->typent_id, 'c_typent', 'id', 'code'); // Force typent_code too so check in verify() will be done on new type + $object->typent_code = dol_getIdFromCode($db, $object->typent_id, 'c_typent', 'id', 'code'); // Force typent_code too so check in verify() will be done on new type - $object->client = GETPOST('client', 'int'); + $object->client = GETPOST('client', 'int'); $object->fournisseur = GETPOST('fournisseur', 'int'); - $object->commercial_id = GETPOST('commercial_id', 'int'); - $object->default_lang = GETPOST('default_lang'); + $object->commercial_id = GETPOST('commercial_id', 'int'); + $object->default_lang = GETPOST('default_lang'); // Webservices url/key $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL); @@ -467,8 +467,8 @@ // Incoterms if (!empty($conf->incoterm->enabled)) { - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); - $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); } // Multicurrency @@ -485,46 +485,46 @@ } if (GETPOST('deletephoto')) $object->logo = ''; - elseif (! empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']); + elseif (!empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']); // Check parameters - if (! GETPOST('cancel', 'alpha')) + if (!GETPOST('cancel', 'alpha')) { - if (! empty($object->email) && ! isValidEMail($object->email)) + if (!empty($object->email) && !isValidEMail($object->email)) { $langs->load("errors"); $error++; setEventMessages('', $langs->trans("ErrorBadEMail", $object->email), 'errors'); } - if (! empty($object->url) && ! isValidUrl($object->url)) + if (!empty($object->url) && !isValidUrl($object->url)) { $langs->load("errors"); setEventMessages('', $langs->trans("ErrorBadUrl", $object->url), 'errors'); } - if (! empty($object->webservices_url)) { + if (!empty($object->webservices_url)) { //Check if has transport, without any the soap client will give error if (strpos($object->webservices_url, "http") === false) { $object->webservices_url = "http://".$object->webservices_url; } - if (! isValidUrl($object->webservices_url)) { + if (!isValidUrl($object->webservices_url)) { $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorBadUrl", $object->webservices_url); } } // We set country_id, country_code and country for the selected country - $object->country_id=GETPOST('country_id')!=''?GETPOST('country_id'):$mysoc->country_id; + $object->country_id = GETPOST('country_id') != '' ?GETPOST('country_id') : $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 (! $error) + if (!$error) { if ($action == 'add') { @@ -532,8 +532,8 @@ $db->begin(); - if (empty($object->client)) $object->code_client=''; - if (empty($object->fournisseur)) $object->code_fournisseur=''; + if (empty($object->client)) $object->code_client = ''; + if (empty($object->fournisseur)) $object->code_fournisseur = ''; $result = $object->create($user); @@ -542,7 +542,7 @@ if ($object->particulier) { dol_syslog("We ask to create a contact/address too", LOG_DEBUG); - $result=$object->create_individual($user); + $result = $object->create_individual($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -588,10 +588,10 @@ if (@is_dir($dir)) { - $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); - if (! $result > 0) + if (!$result > 0) { $errors[] = "ErrorFailedToSaveFile"; } @@ -605,7 +605,7 @@ } 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 @@ -631,22 +631,22 @@ $error++; } - if ($result >= 0 && ! $error) + if ($result >= 0 && !$error) { $db->commit(); - if (! empty($backtopage)) + if (!empty($backtopage)) { - $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation - if (preg_match('/\?/', $backtopage)) $backtopage.='&socid='.$object->id; // Old method + $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation + if (preg_match('/\?/', $backtopage)) $backtopage .= '&socid='.$object->id; // Old method header("Location: ".$backtopage); exit; } else { - $url=$_SERVER["PHP_SELF"]."?socid=".$object->id; // Old method - if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/card.php?socid=".$object->id; - elseif ($object->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/card.php?socid=".$object->id; + $url = $_SERVER["PHP_SELF"]."?socid=".$object->id; // Old method + if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url = DOL_URL_ROOT."/comm/card.php?socid=".$object->id; + elseif ($object->fournisseur == 1) $url = DOL_URL_ROOT."/fourn/card.php?socid=".$object->id; header("Location: ".$url); exit; @@ -655,7 +655,7 @@ else { $db->rollback(); - $action='create'; + $action = 'create'; } } @@ -665,7 +665,7 @@ if (GETPOST('cancel', 'alpha')) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -678,13 +678,13 @@ } // To not set code if third party is not concerned. But if it had values, we keep them. - if (empty($object->client) && empty($object->oldcopy->code_client)) $object->code_client=''; - if (empty($object->fournisseur)&& empty($object->oldcopy->code_fournisseur)) $object->code_fournisseur=''; + if (empty($object->client) && empty($object->oldcopy->code_client)) $object->code_client = ''; + if (empty($object->fournisseur) && empty($object->oldcopy->code_fournisseur)) $object->code_fournisseur = ''; //var_dump($object);exit; $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(), 'update', 0); - if ($result <= 0) + if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; @@ -700,7 +700,7 @@ } // Prevent thirdparty's emptying if a user hasn't rights $user->rights->categorie->lire (in such a case, post of 'custcats' is not defined) - if (! $error && !empty($user->rights->categorie->lire)) + if (!$error && !empty($user->rights->categorie->lire)) { // Customer categories association $categories = GETPOST('custcats', 'array'); @@ -726,8 +726,8 @@ $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if (GETPOST('deletephoto') && $object->logo) { - $fileimg=$dir.'/'.$object->logo; - $dirthumbs=$dir.'/thumbs'; + $fileimg = $dir.'/'.$object->logo; + $dirthumbs = $dir.'/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } @@ -739,10 +739,10 @@ if (@is_dir($dir)) { - $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); - if (! $result > 0) + if (!$result > 0) { $errors[] = "ErrorFailedToSaveFile"; } @@ -752,9 +752,9 @@ $object->addThumbs($newfile); // Index file in database - if (! empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD)) + if (!empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD)) { - require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // the dir dirname($newfile) is directory of logo, so we should have only one file at once into index, so we delete indexes for the dir deleteFilesIntoDatabaseIndex(dirname($newfile), '', ''); // now we index the uploaded logo file @@ -770,7 +770,7 @@ } 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 @@ -785,11 +785,11 @@ // Update linked member - if (! $error && $object->fk_soc > 0) + if (!$error && $object->fk_soc > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id; - if (! $object->db->query($sql)) + $sql .= " SET fk_soc = NULL WHERE fk_soc = ".$id; + if (!$object->db->query($sql)) { $error++; $object->error .= $object->db->lasterror(); @@ -797,9 +797,9 @@ } } - if (! $error && ! count($errors)) + if (!$error && !count($errors)) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -813,13 +813,13 @@ else { $object->id = $socid; - $action= "edit"; + $action = "edit"; } } } else { - $action = ($action=='add'?'create':'edit'); + $action = ($action == 'add' ? 'create' : 'edit'); } } @@ -840,7 +840,7 @@ $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $error++; - $action=''; + $action = ''; } } @@ -858,20 +858,20 @@ $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); } - $id=$socid; + $id = $socid; $object->fetch($socid); // Actions to send emails - $trigger_name='COMPANY_SENTBYMAIL'; - $paramname='socid'; - $mode='emailfromthirdparty'; - $trackid='thi'.$object->id; + $trigger_name = 'COMPANY_SENTBYMAIL'; + $paramname = 'socid'; + $mode = 'emailfromthirdparty'; + $trackid = 'thi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc $id = $socid; $upload_dir = $conf->societe->dir_output; - $permissiontoadd=$user->rights->societe->creer; + $permissiontoadd = $user->rights->societe->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -887,24 +887,24 @@ if ($socid > 0 && empty($object->id)) { - $result=$object->fetch($socid); + $result = $object->fetch($socid); if ($result <= 0) dol_print_error('', $object->error); } -$title=$langs->trans("ThirdParty"); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$langs->trans('Card'); -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = $langs->trans("ThirdParty"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$langs->trans('Card'); +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; 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)) { // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - $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 { @@ -916,82 +916,82 @@ /* * Creation */ - $private=GETPOST("private", "int"); - if (! empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && ! isset($_GET['private']) && ! isset($_POST['private'])) $private=1; - if (empty($private)) $private=0; + $private = GETPOST("private", "int"); + if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && !isset($_GET['private']) && !isset($_POST['private'])) $private = 1; + if (empty($private)) $private = 0; // Load object modCodeTiers - $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard'); + $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard'); if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { - $module = substr($module, 0, dol_strlen($module)-4); + $module = substr($module, 0, dol_strlen($module) - 4); } - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $modCodeClient = new $module; // Load object modCodeFournisseur - $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard'); + $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard'); if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { - $module = substr($module, 0, dol_strlen($module)-4); + $module = substr($module, 0, dol_strlen($module) - 4); } - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $modCodeFournisseur = new $module; // Define if customer/prospect or supplier status is set or not - if (GETPOST("type")!='f') + if (GETPOST("type") != 'f') { - $object->client=-1; - if (! empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client=3; } + $object->client = -1; + if (!empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client = 3; } } // Prospect / Customer - if (GETPOST("type")=='c') { - if (! empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) { - $object->client=$conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT; + if (GETPOST("type") == 'c') { + if (!empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) { + $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT; } else { - $object->client=3; + $object->client = 3; } } - if (GETPOST("type")=='p') { $object->client=2; } - if (! empty($conf->fournisseur->enabled) && (GETPOST("type")=='f' || (GETPOST("type")=='' && ! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { $object->fournisseur=1; } + if (GETPOST("type") == 'p') { $object->client = 2; } + if (!empty($conf->fournisseur->enabled) && (GETPOST("type") == 'f' || (GETPOST("type") == '' && !empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { $object->fournisseur = 1; } - $object->name = GETPOST('name', 'alpha'); - $object->firstname = GETPOST('firstname', 'alpha'); + $object->name = GETPOST('name', 'alpha'); + $object->firstname = GETPOST('firstname', 'alpha'); $object->particulier = $private; $object->prefix_comm = GETPOST('prefix_comm', 'alpha'); - $object->client = GETPOST('client', 'int')?GETPOST('client', 'int'):$object->client; + $object->client = GETPOST('client', 'int') ?GETPOST('client', 'int') : $object->client; if (empty($duplicate_code_error)) { $object->code_client = GETPOST('customer_code', 'alpha'); - $object->fournisseur = GETPOST('fournisseur')?GETPOST('fournisseur'):$object->fournisseur; - $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); + $object->fournisseur = GETPOST('fournisseur') ?GETPOST('fournisseur') : $object->fournisseur; + $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); } else { setEventMessages($langs->trans('NewCustomerSupplierCodeProposed'), '', 'warnings'); } - $object->address = GETPOST('address', 'alpha'); - $object->zip = GETPOST('zipcode', 'alpha'); - $object->town = GETPOST('town', 'alpha'); - $object->state_id = GETPOST('state_id', 'int'); + $object->address = GETPOST('address', 'alpha'); + $object->zip = GETPOST('zipcode', 'alpha'); + $object->town = GETPOST('town', 'alpha'); + $object->state_id = GETPOST('state_id', 'int'); //$object->skype = GETPOST('skype', 'alpha'); //$object->twitter = GETPOST('twitter', 'alpha'); //$object->facebook = GETPOST('facebook', 'alpha'); //$object->linkedin = GETPOST('linkedin', 'alpha'); $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($key, 'alphanohtml'); } } @@ -1008,30 +1008,30 @@ $object->idprof4 = GETPOST('idprof4', 'alpha'); $object->idprof5 = GETPOST('idprof5', 'alpha'); $object->idprof6 = GETPOST('idprof6', 'alpha'); - $object->typent_id = GETPOST('typent_id', 'int'); + $object->typent_id = GETPOST('typent_id', 'int'); $object->effectif_id = GETPOST('effectif_id', 'int'); $object->civility_id = GETPOST('civility_id', 'alpha'); - $object->tva_assuj = GETPOST('assujtva_value', 'int'); - $object->status = GETPOST('status', 'int'); + $object->tva_assuj = GETPOST('assujtva_value', 'int'); + $object->status = GETPOST('status', 'int'); //Local Taxes $object->localtax1_assuj = GETPOST('localtax1assuj_value', 'int'); $object->localtax2_assuj = GETPOST('localtax2assuj_value', 'int'); - $object->localtax1_value =GETPOST('lt1', 'int'); - $object->localtax2_value =GETPOST('lt2', 'int'); + $object->localtax1_value = GETPOST('lt1', 'int'); + $object->localtax2_value = GETPOST('lt2', 'int'); - $object->tva_intra = GETPOST('tva_intra', 'alpha'); + $object->tva_intra = GETPOST('tva_intra', 'alpha'); - $object->commercial_id = GETPOST('commercial_id', 'int'); - $object->default_lang = GETPOST('default_lang'); + $object->commercial_id = GETPOST('commercial_id', 'int'); + $object->default_lang = GETPOST('default_lang'); - $object->logo = (isset($_FILES['photo'])?dol_sanitizeFileName($_FILES['photo']['name']):''); + $object->logo = (isset($_FILES['photo']) ?dol_sanitizeFileName($_FILES['photo']['name']) : ''); // Gestion du logo de la société $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos"; - $file_OK = (isset($_FILES['photo'])?is_uploaded_file($_FILES['photo']['tmp_name']):false); + $file_OK = (isset($_FILES['photo']) ?is_uploaded_file($_FILES['photo']['tmp_name']) : false); if ($file_OK) { if (image_format_supported($_FILES['photo']['name'])) @@ -1040,10 +1040,10 @@ if (@is_dir($dir)) { - $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); - if (! $result > 0) + if (!$result > 0) { $errors[] = "ErrorFailedToSaveFile"; } @@ -1057,20 +1057,20 @@ } // We set country_id, country_code and country for the selected country - $object->country_id=GETPOST('country_id')?GETPOST('country_id'):$mysoc->country_id; + $object->country_id = GETPOST('country_id') ?GETPOST('country_id') : $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']; } - $object->forme_juridique_code=GETPOST('forme_juridique_code'); + $object->forme_juridique_code = GETPOST('forme_juridique_code'); /* Show create form */ - $linkback=""; + $linkback = ""; print load_fiche_titre($langs->trans("NewThirdParty"), $linkback, 'building'); - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) { print "\n".''; print "\n"; - $s.=''.$langs->trans("VATIntraCheck").''; + $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s.='country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -1435,30 +1435,30 @@ function init_supplier_categ() { // Local Taxes //TODO: Place into a function to control showing by country or study better option - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") + if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") { print ''.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; - print $form->selectyesno('localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1:0), 1); + print $form->selectyesno('localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1); print ''.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; - print $form->selectyesno('localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0), 1); + print $form->selectyesno('localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1); print ''; } - elseif($mysoc->localtax1_assuj=="1") + elseif ($mysoc->localtax1_assuj == "1") { print ''.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; - print $form->selectyesno('localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1:0), 1); + print $form->selectyesno('localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1); print ''; } - elseif($mysoc->localtax2_assuj=="1") + elseif ($mysoc->localtax2_assuj == "1") { print ''.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; - print $form->selectyesno('localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0), 1); + print $form->selectyesno('localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1); print ''; } // Type - Size print ''.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).''."\n"; - $sortparam=(empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. + $sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam); if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; @@ -1485,10 +1485,10 @@ function init_supplier_categ() { print ' '; print ''.$langs->trans("Currency".$conf->currency).''; - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { print ''.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; - print $formadmin->select_language(GETPOST('default_lang', 'alpha')?GETPOST('default_lang', 'alpha'):($object->default_lang?$object->default_lang:''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); + print $formadmin->select_language(GETPOST('default_lang', 'alpha') ?GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); print ''; print ''; } @@ -1499,18 +1499,18 @@ function init_supplier_categ() { print ''; print ''.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).''; print ''; - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:'')); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); print ''; } // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { $langs->load('categories'); // Customer //if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { - print '' . $form->editfieldkey('CustomersProspectsCategoriesShort', 'custcats', '', $object, 0) . ''; + print ''.$form->editfieldkey('CustomersProspectsCategoriesShort', 'custcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, null, "90%"); print ""; @@ -1518,7 +1518,7 @@ function init_supplier_categ() { // Supplier //if ($object->fournisseur) { - print '' . $form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0) . ''; + print ''.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1); print $form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, null, null, "90%"); print ""; @@ -1526,7 +1526,7 @@ function init_supplier_categ() { } // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; print ''.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; @@ -1536,8 +1536,8 @@ function init_supplier_categ() { } // Other attributes - $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -1550,7 +1550,7 @@ function init_supplier_categ() { print ''; $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 1); // Note: If user has no right to "see all thirdparties", we force selection of sale representative to him, so after creation he can see the record. - $selected = (count(GETPOST('commercial', 'array')) > 0 ? GETPOST('commercial', 'array') : (GETPOST('commercial', 'int') > 0 ? array(GETPOST('commercial', 'int')) : (empty($user->rights->societe->client->voir)?array($user->id):array()))); + $selected = (count(GETPOST('commercial', 'array')) > 0 ? GETPOST('commercial', 'array') : (GETPOST('commercial', 'int') > 0 ? array(GETPOST('commercial', 'int')) : (empty($user->rights->societe->client->voir) ? array($user->id) : array()))); print $form->multiselectarray('commercial', $userlist, $selected, null, null, null, null, "90%"); print ''; @@ -1568,7 +1568,7 @@ function init_supplier_categ() { print '
'; print ''; - if (! empty($backtopage)) + if (!empty($backtopage)) { print '     '; print ''; @@ -1576,7 +1576,7 @@ function init_supplier_categ() { else { print '     '; - print ''; + print ''; } print '
'."\n"; @@ -1588,21 +1588,21 @@ function init_supplier_categ() { if ($socid) { - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); //if ($res < 0) { dol_print_error($db); exit; } $head = societe_prepare_head($object); // Load object modCodeTiers - $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard'); + $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard'); if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { - $module = substr($module, 0, dol_strlen($module)-4); + $module = substr($module, 0, dol_strlen($module) - 4); } - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $modCodeClient = new $module($db); @@ -1611,15 +1611,15 @@ function init_supplier_categ() { { $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed(); } - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { - $module = substr($module, 0, dol_strlen($module)-4); + $module = substr($module, 0, dol_strlen($module) - 4); } - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $modCodeFournisseur = new $module($db); @@ -1634,25 +1634,25 @@ function init_supplier_categ() { if (GETPOSTISSET('name')) { // We overwrite with values if posted - $object->name = GETPOST('name', 'alpha'); + $object->name = GETPOST('name', 'alpha'); $object->prefix_comm = GETPOST('prefix_comm', 'alpha'); - $object->client = GETPOST('client', 'int'); + $object->client = GETPOST('client', 'int'); $object->code_client = GETPOST('customer_code', 'alpha'); $object->fournisseur = GETPOST('fournisseur', 'int'); - $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); - $object->address = GETPOST('address', 'alpha'); - $object->zip = GETPOST('zipcode', 'alpha'); - $object->town = GETPOST('town', 'alpha'); - $object->country_id = GETPOST('country_id')?GETPOST('country_id', 'int'):$mysoc->country_id; - $object->state_id = GETPOST('state_id', 'int'); + $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); + $object->address = GETPOST('address', 'alpha'); + $object->zip = GETPOST('zipcode', 'alpha'); + $object->town = GETPOST('town', 'alpha'); + $object->country_id = GETPOST('country_id') ?GETPOST('country_id', 'int') : $mysoc->country_id; + $object->state_id = GETPOST('state_id', 'int'); //$object->skype = GETPOST('skype', 'alpha'); //$object->twitter = GETPOST('twitter', 'alpha'); //$object->facebook = GETPOST('facebook', 'alpha'); //$object->linkedin = GETPOST('linkedin', 'alpha'); $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($key, 'alphanohtml'); } } @@ -1668,15 +1668,15 @@ function init_supplier_categ() { $object->idprof4 = GETPOST('idprof4', 'alpha'); $object->idprof5 = GETPOST('idprof5', 'alpha'); $object->idprof6 = GETPOST('idprof6', 'alpha'); - $object->typent_id = GETPOST('typent_id', 'int'); - $object->effectif_id = GETPOST('effectif_id', 'int'); + $object->typent_id = GETPOST('typent_id', 'int'); + $object->effectif_id = GETPOST('effectif_id', 'int'); $object->barcode = GETPOST('barcode', 'alpha'); - $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int'); - $object->default_lang = GETPOST('default_lang', 'alpha'); + $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int'); + $object->default_lang = GETPOST('default_lang', 'alpha'); $object->tva_assuj = GETPOST('assujtva_value', 'int'); $object->tva_intra = GETPOST('tva_intra', 'alpha'); - $object->status = GETPOST('status', 'int'); + $object->status = GETPOST('status', 'int'); // Webservices url/key $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL); @@ -1685,32 +1685,32 @@ function init_supplier_categ() { //Incoterms if (!empty($conf->incoterm->enabled)) { - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); - $object->location_incoterms = GETPOST('lcoation_incoterms', 'alpha'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->location_incoterms = GETPOST('lcoation_incoterms', 'alpha'); } //Local Taxes $object->localtax1_assuj = GETPOST('localtax1assuj_value'); $object->localtax2_assuj = GETPOST('localtax2assuj_value'); - $object->localtax1_value =GETPOST('lt1'); - $object->localtax2_value =GETPOST('lt2'); + $object->localtax1_value = GETPOST('lt1'); + $object->localtax2_value = GETPOST('lt2'); // We set country_id, and country_code label of the chosen country if ($object->country_id > 0) { - $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($object->localtax1_assuj==0){ - $sub=0; - }else{$sub=1;} - if($object->localtax2_assuj==0){ - $sub2=0; - }else{$sub2=1;} + if ($object->localtax1_assuj == 0) { + $sub = 0; + } else {$sub = 1; } + if ($object->localtax2_assuj == 0) { + $sub2 = 0; + } else {$sub2 = 1; } if ($conf->use_javascript_ajax) { @@ -1755,7 +1755,7 @@ function init_supplier_categ() { }); function init_customer_categ() { console.log("is customer or prospect = "+jQuery("#customerprospect").val()); - if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() == 0 || '.(empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER)?'1':'0').')) + if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() == 0 || '.(empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER) ? '1' : '0').')) { jQuery(".visibleifcustomer").hide(); } @@ -1804,7 +1804,7 @@ function init_supplier_categ() { print ''; // Ref/ID - if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print ''; // Prefix - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; // Supplier - if ((! empty($conf->fournisseur->enabled) && ! empty($user->rights->fournisseur->lire)) - || (! empty($conf->supplier_proposal->enabled) && ! empty($user->rights->supplier_proposal->lire))) + if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) + || (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->lire))) { print ''; print ''; print ''; print ''; // Address @@ -1936,14 +1936,14 @@ function init_supplier_categ() { // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) { print ''; - print ''; + print ''; print ''; - print ''; + print ''; // EMail / Web - print ''; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; - if (! empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { print ''; @@ -2011,18 +2011,18 @@ function init_supplier_categ() { // } // Prof ids - $i=1; $j=0; + $i = 1; $j = 0; while ($i <= 6) { - $idprof=$langs->transcountry('ProfId'.$i, $object->country_code); - if ($idprof!='-') + $idprof = $langs->transcountry('ProfId'.$i, $object->country_code); + if ($idprof != '-') { - $key='idprof'.$i; + $key = 'idprof'.$i; if (($j % 2) == 0) print ''; - $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; - print ''; if (($j % 2) == 1) print ''; @@ -2039,11 +2039,11 @@ function init_supplier_categ() { // Local Taxes //TODO: Place into a function to control showing by country or study better option - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") + if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") { print ''; } - elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1") + elseif ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj != "1") { print ''; } - elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") + elseif ($mysoc->localtax2_assuj == "1" && $mysoc->localtax1_assuj != "1") { print ''; print ''; print ''; // Default language - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { print ''; print ''; print ''; } // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { // Customer - print ''; + print ''; print '"; // Supplier - print ''; + print ''; print ''; print ''; @@ -2200,8 +2200,8 @@ function init_supplier_categ() { } // Other attributes - $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { @@ -2221,7 +2221,7 @@ function init_supplier_categ() { print ''; print ''; // Supplier - if (! empty($conf->fournisseur->enabled) || ! empty($conf->supplier_proposal->enabled)) + if (!empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled)) { print ''; print ''; @@ -2337,7 +2337,7 @@ function init_supplier_categ() { } // Supplier code - if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) + if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) { print ''; print ''; print ''; - if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1))) + if ($object->localtax1_assuj == "1" && (!isOnlyOneLocalTax(1))) { print ''; print ''; print ''; print ''; - if($action == 'editRE') + if ($action == 'editRE') { print ''; } - if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2))) + if ($object->localtax2_assuj == "1" && (!isOnlyOneLocalTax(2))) { print ''; print ''; print ''; print ''; - if($action == 'editIRPF'){ + if ($action == 'editIRPF') { print ''; - }else{ + } else { print ''; } print ''; } } - elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1") + elseif ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj != "1") { print ''; - if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1))) + if ($object->localtax1_assuj == "1" && (!isOnlyOneLocalTax(1))) { print ''; print ''; print ''; print ''; - if($action == 'editRE'){ + if ($action == 'editRE') { print ''; - }else{ + } else { print ''; } print ''; } } - elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") + elseif ($mysoc->localtax2_assuj == "1" && $mysoc->localtax1_assuj != "1") { print ''; - if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2))) + if ($object->localtax2_assuj == "1" && (!isOnlyOneLocalTax(2))) { print ''; print ''; print ''; print ''; - if($action == 'editIRPF'){ + if ($action == 'editIRPF') { print ''; - }else{ + } else { print ''; } print ''; @@ -2492,18 +2492,18 @@ function init_supplier_categ() { print ''; print ''; @@ -2544,11 +2544,11 @@ function init_supplier_categ() { print '
'.$langs->trans("ID").''; print $object->ref; @@ -1820,7 +1820,7 @@ function init_supplier_categ() { print '
'.$form->editfieldkey('Prefix', 'prefix', '', $object, 0).''; // It does not change the prefix mode using the auto numbering prefix @@ -1846,9 +1846,9 @@ function init_supplier_categ() { print '
'; if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto) { - $tmpcode=$object->code_client; - if (empty($tmpcode) && ! empty($object->oldcopy->code_client)) $tmpcode=$object->oldcopy->code_client; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. - if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) $tmpcode=$modCodeClient->getNextValue($object, 0); + $tmpcode = $object->code_client; + if (empty($tmpcode) && !empty($object->oldcopy->code_client)) $tmpcode = $object->oldcopy->code_client; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. + if (empty($tmpcode) && !empty($modCodeClient->code_auto)) $tmpcode = $modCodeClient->getNextValue($object, 0); print ''; } elseif ($object->codeclient_modifiable()) @@ -1861,34 +1861,34 @@ function init_supplier_categ() { print ''; } print ''; - $s=$modCodeClient->getToolTip($langs, $object, 0); + $s = $modCodeClient->getToolTip($langs, $object, 0); print $form->textwithpicto('', $s, 1); print '
'; print '
'.$form->editfieldkey('Supplier', 'fournisseur', '', $object, 0, 'string', '', 1).''; print $form->selectyesno("fournisseur", $object->fournisseur, 1); print ''; - if (! empty($conf->fournisseur->enabled) && ! empty($user->rights->fournisseur->lire)) + if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) { print $form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0); } print ''; - if (! empty($conf->fournisseur->enabled) && ! empty($user->rights->fournisseur->lire)) + if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) { print '
'; if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) { - $tmpcode=$object->code_fournisseur; - if (empty($tmpcode) && ! empty($object->oldcopy->code_fournisseur)) $tmpcode=$object->oldcopy->code_fournisseur; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. - if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) $tmpcode=$modCodeFournisseur->getNextValue($object, 1); + $tmpcode = $object->code_fournisseur; + if (empty($tmpcode) && !empty($object->oldcopy->code_fournisseur)) $tmpcode = $object->oldcopy->code_fournisseur; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. + if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) $tmpcode = $modCodeFournisseur->getNextValue($object, 1); print ''; } elseif ($object->codefournisseur_modifiable()) @@ -1901,7 +1901,7 @@ function init_supplier_categ() { print ''; } print ''; - $s=$modCodeFournisseur->getToolTip($langs, $object, 1); + $s = $modCodeFournisseur->getToolTip($langs, $object, 1); print $form->textwithpicto('', $s, 1); print '
'; } @@ -1909,7 +1909,7 @@ function init_supplier_categ() { } // Barcode - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { print '
'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).''; @@ -1918,7 +1918,7 @@ function init_supplier_categ() { // Status print '
'.$form->editfieldkey('Status', 'status', '', $object, 0).''; - print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $object->status); + print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status); print '
'.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).''; - print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id), 'country_id'); + print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id), 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '
'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).''; } @@ -1958,17 +1958,17 @@ function init_supplier_categ() { // Phone / Fax print '
'.img_picto('', 'object_phoning').' '.$form->editfieldkey('Phone', 'phone', GETPOST('phone', 'alpha'), $object, 0).''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).'
'.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (! empty($conf->global->SOCIETE_EMAIL_MANDATORY))).'
'.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).'
'.img_picto('', 'globe').' '.$form->editfieldkey('Web', 'url', GETPOST('url', 'alpha'), $object, 0).'
'.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', ! (empty($conf->global->$idprof_mandatory) || ! $object->isACompany())).''; + $idprof_mandatory = 'SOCIETE_IDPROF'.($i).'_MANDATORY'; + print ''.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).''; print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code); print '
'.$form->editfieldkey($langs->transcountry("LocalTax1IsUsed", $mysoc->country_code), 'localtax1assuj_value', '', $object, 0).''; print $form->selectyesno('localtax1assuj_value', $object->localtax1_assuj, 1); - if(! isOnlyOneLocalTax(1)) + if (!isOnlyOneLocalTax(1)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); @@ -2053,7 +2053,7 @@ function init_supplier_categ() { print ''.$form->editfieldkey($langs->transcountry("LocalTax2IsUsed", $mysoc->country_code), 'localtax2assuj_value', '', $object, 0).''; print $form->selectyesno('localtax2assuj_value', $object->localtax2_assuj, 1); - if (! isOnlyOneLocalTax(2)) + if (!isOnlyOneLocalTax(2)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); @@ -2061,11 +2061,11 @@ function init_supplier_categ() { } print '
'.$form->editfieldkey($langs->transcountry("LocalTax1IsUsed", $mysoc->country_code), 'localtax1assuj_value', '', $object, 0).''; print $form->selectyesno('localtax1assuj_value', $object->localtax1_assuj, 1); - if(! isOnlyOneLocalTax(1)) + if (!isOnlyOneLocalTax(1)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); @@ -2073,11 +2073,11 @@ function init_supplier_categ() { } print '
'.$form->editfieldkey($langs->transcountry("LocalTax2IsUsed", $mysoc->country_code), 'localtax2assuj_value', '', $object, 0).''; print $form->selectyesno('localtax2assuj_value', $object->localtax2_assuj, 1); - if(! isOnlyOneLocalTax(2)) + if (!isOnlyOneLocalTax(2)) { print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); @@ -2089,16 +2089,16 @@ function init_supplier_categ() { // VAT Code print '
'.$form->editfieldkey('VATIntra', 'intra_vat', '', $object, 0).''; - $s =''; + $s = ''; if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object)) { - $s.='   '; + $s .= '   '; if ($conf->use_javascript_ajax) { $widthpopup = 600; - if (! empty($conf->dol_use_jmobile)) $widthpopup = 350; + if (!empty($conf->dol_use_jmobile)) $widthpopup = 350; $heightpopup = 400; print "\n"; print ''; print "\n"; - $s.=''.$langs->trans("VATIntraCheck").''; + $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s.='country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -2121,7 +2121,7 @@ function init_supplier_categ() { // Type - Size print '
'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).''; - print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''.$form->editfieldkey('Staff', 'effectif_id', '', $object, 0).''; @@ -2141,7 +2141,7 @@ function init_supplier_categ() { print '"> '.$langs->trans("Currency".$conf->currency).'
'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; print $formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1); @@ -2155,20 +2155,20 @@ function init_supplier_categ() { print '
'.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).''; - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:'')); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); print '
' . $form->editfieldkey('CustomersCategoriesShort', 'custcats', '', $object, 0) . '
'.$form->editfieldkey('CustomersCategoriesShort', 'custcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER); - $arrayselected=array(); + $arrayselected = array(); foreach ($cats as $cat) { $arrayselected[] = $cat->id; } @@ -2176,12 +2176,12 @@ function init_supplier_categ() { print "
' . $form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0) . '
'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER); - $arrayselected=array(); + $arrayselected = array(); foreach ($cats as $cat) { $arrayselected[] = $cat->id; } @@ -2190,7 +2190,7 @@ function init_supplier_categ() { } // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).''; if ($object->logo) print $form->showphoto('societe', $object); - $caneditfield=1; + $caneditfield = 1; if ($caneditfield) { if ($object->logo) print "
\n"; @@ -2264,7 +2264,7 @@ function init_supplier_categ() { * View */ - if (!empty($object->id)) $res=$object->fetch_optionals(); + if (!empty($object->id)) $res = $object->fetch_optionals(); //if ($res < 0) { dol_print_error($db); exit; } @@ -2292,11 +2292,11 @@ function init_supplier_categ() { print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 250); } - dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error'); + dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
'; @@ -2311,7 +2311,7 @@ function init_supplier_categ() { print '
'.$langs->trans('Supplier').''; print yn($object->fournisseur); @@ -2319,7 +2319,7 @@ function init_supplier_categ() { } // Prefix - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; print $langs->trans('SupplierCode').''; @@ -2348,7 +2348,7 @@ function init_supplier_categ() { } // Barcode - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { print '
'; print $langs->trans('Gencod').''.$object->barcode; @@ -2357,16 +2357,16 @@ function init_supplier_categ() { } // Prof ids - $i=1; $j=0; + $i = 1; $j = 0; while ($i <= 6) { - $idprof=$langs->transcountry('ProfId'.$i, $object->country_code); - if ($idprof!='-') + $idprof = $langs->transcountry('ProfId'.$i, $object->country_code); + if ($idprof != '-') { //if (($j % 2) == 0) print '
'.$idprof.''; - $key='idprof'.$i; + $key = 'idprof'.$i; print $object->$key; if ($object->$key) { @@ -2399,9 +2399,9 @@ function init_supplier_categ() { } // Local Taxes - if ($object->fournisseur || $mysoc->country_code=='ES') + if ($object->fournisseur || $mysoc->country_code == 'ES') { - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") + if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") { print '
'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; print yn($object->localtax1_assuj); @@ -2409,13 +2409,13 @@ function init_supplier_categ() { print yn($object->localtax2_assuj); print '
'.$langs->transcountry("Localtax1", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); @@ -2427,59 +2427,59 @@ function init_supplier_categ() { } print '
'.$langs->transcountry("Localtax2", $mysoc->country_code).'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); print ''.$object->localtax2_value.'
'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; print yn($object->localtax1_assuj); print '
'.$langs->transcountry("Localtax1", $mysoc->country_code).'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); print ''.$object->localtax1_value.'
'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; print yn($object->localtax2_assuj); print '
'.$langs->transcountry("Localtax2", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); print ''.$object->localtax2_value.'
'.$langs->trans('VATIntra').''; if ($object->tva_intra) { - $s=''; - $s.=$object->tva_intra; - $s.=''; + $s = ''; + $s .= $object->tva_intra; + $s .= ''; if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object)) { - $s.='   '; + $s .= '   '; if ($conf->use_javascript_ajax) { $widthpopup = 600; - if (! empty($conf->dol_use_jmobile)) $widthpopup = 350; + if (!empty($conf->dol_use_jmobile)) $widthpopup = 350; $heightpopup = 400; print "\n"; print ''; print "\n"; - $s.=''.$langs->trans("VATIntraCheck").''; + $s .= ''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); } else { - $s.='country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + $s .= 'country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; } } print $s; @@ -2531,7 +2531,7 @@ function init_supplier_categ() { // Type + Staff $arr = $formcompany->typent_array(1); - $object->typent= $arr[$object->typent_code]; + $object->typent = $arr[$object->typent_code]; print '
'.$langs->trans("ThirdPartyType").''.$object->typent.'
'.$langs->trans("Staff").''.$object->effectif.'
'; // Tags / categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { // Customer - if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { - print ''; + if ($object->prospect || $object->client || (!$object->fournisseur && !empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { + print ''; print '"; @@ -2556,7 +2556,7 @@ function init_supplier_categ() { // Supplier if ($object->fournisseur) { - print ''; + print ''; print '"; @@ -2573,14 +2573,14 @@ function init_supplier_categ() { print ''; // Default language - if (! empty($conf->global->MAIN_MULTILANGS)) + if (!empty($conf->global->MAIN_MULTILANGS)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print ''; } @@ -2603,13 +2603,13 @@ function init_supplier_categ() { } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?socid='.$object->id); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?socid='.$object->id); } print ''; } // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; print ''; @@ -2619,8 +2619,8 @@ function init_supplier_categ() { } // Other attributes - $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; // Parent company if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) @@ -2648,16 +2648,16 @@ function init_supplier_categ() { include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; // Module Adherent - if (! empty($conf->adherent->enabled)) + if (!empty($conf->adherent->enabled)) { $langs->load("members"); print ''; print ''; } @@ -827,18 +827,18 @@ if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print ''; $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; - $resql=$db->query($sql); + $resql = $db->query($sql); if (!$resql) dol_print_error($db); $obj = $db->fetch_object($resql); $nbFactsClient = $obj->nb; - $thirdTypeArray['customer']=$langs->trans("customer"); - if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals'); - if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders'); - if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices'); - if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts'); + $thirdTypeArray['customer'] = $langs->trans("customer"); + if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); + if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); + if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); + if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); - if (! empty($conf->stripe->enabled)) + if (!empty($conf->stripe->enabled)) { $permissiontowrite = $user->rights->societe->creer; // Stripe customer key 'cu_....' stored into llx_societe_account @@ -846,14 +846,14 @@ print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', 0, 2, 'socid'); print ''; $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; - $resql=$db->query($sql); + $resql = $db->query($sql); if (!$resql) dol_print_error($db); $obj = $db->fetch_object($resql); $nbFactsClient = $obj->nb; - $thirdTypeArray['customer']=$langs->trans("customer"); - if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals'); - if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders'); - if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices'); - if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts'); + $thirdTypeArray['customer'] = $langs->trans("customer"); + if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); + if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); + if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); + if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); } - if (! empty($conf->stripe->enabled) && ! empty($conf->stripeconnect->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2) + if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { $permissiontowrite = $user->rights->societe->creer; - $stripesupplieracc = $stripe->getStripeAccount($service, $object->id); // Get Stripe OAuth connect account (no network access here) + $stripesupplieracc = $stripe->getStripeAccount($service, $object->id); // Get Stripe OAuth connect account (no network access here) // Stripe customer key 'cu_....' stored into llx_societe_account print ''; print ''; // Hook fields - $parameters=array('arrayfields'=>array(),'param'=>'','sortfield'=>'','sortorder'=>'', 'linetype'=>'stripetitle'); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>array(), 'param'=>'', 'sortfield'=>'', 'sortorder'=>'', 'linetype'=>'stripetitle'); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ""; @@ -1018,15 +1018,15 @@ $arrayofstripecard = array(); // Show local sources - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { //$societeaccount = new SocieteAccount($db); $companypaymentmodetemp = new CompanyPaymentMode($db); - $sql='SELECT rowid FROM '.MAIN_DB_PREFIX."societe_rib"; - $sql.=" WHERE type in ('card')"; - $sql.=" AND fk_soc = ".$object->id; - $sql.=" AND status = ".$servicestatus; + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."societe_rib"; + $sql .= " WHERE type in ('card')"; + $sql .= " AND fk_soc = ".$object->id; + $sql .= " AND status = ".$servicestatus; $resql = $db->query($sql); if ($resql) @@ -1034,7 +1034,7 @@ $num_rows = $db->num_rows($resql); if ($num_rows) { - $i=0; + $i = 0; while ($i < $num_rows) { $nblocal++; @@ -1044,7 +1044,7 @@ { $companypaymentmodetemp->fetch($obj->rowid); - $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref]=$companypaymentmodetemp->stripe_card_ref; + $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref; print ''; print ''; // Fields from hook - $parameters=array('arrayfields'=>array(), 'obj'=>$obj, 'linetype'=>'stripecard'); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>array(), 'obj'=>$obj, 'linetype'=>'stripecard'); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; // Local ID - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { print ''; } // Src ID print ''; // Img of credit card print ''; print ''; // Fields from hook - $parameters=array('arrayfields'=>array(), 'stripesource'=>$src, 'linetype'=>'stripecardremoteonly'); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>array(), 'stripesource'=>$src, 'linetype'=>'stripecardremoteonly'); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; } print "
' . $langs->trans("CustomersCategoriesShort") . '
'.$langs->trans("CustomersCategoriesShort").''; print $form->showCategories($object->id, 'customer', 1); print "
' . $langs->trans("SuppliersCategoriesShort") . '
'.$langs->trans("SuppliersCategoriesShort").''; print $form->showCategories($object->id, 'supplier', 1); print "
'.$langs->trans("DefaultLang").''; //$s=picto_from_langcode($object->default_lang); //print ($s?$s.' ':''); $langs->load("languages"); - $labellang = ($object->default_lang?$langs->trans('Language_'.$object->default_lang):''); + $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : ''); print $labellang; print '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'
'.$langs->trans("LinkedToDolibarrMember").''; - $adh=new Adherent($db); - $result=$adh->fetch('', '', $object->id); + $adh = new Adherent($db); + $result = $adh->fetch('', '', $object->id); if ($result > 0) { - $adh->ref=$adh->getFullName($langs); + $adh->ref = $adh->getFullName($langs); print $adh->getNomUrl(1); } else @@ -2690,8 +2690,8 @@ function init_supplier_categ() { { print '
'."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $at_least_one_email_contact = false; @@ -2705,7 +2705,7 @@ function init_supplier_categ() { } } - if (! empty($object->email) || $at_least_one_email_contact) + if (!empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); print ''.$langs->trans('SendMail').''; @@ -2721,11 +2721,11 @@ function init_supplier_categ() { print ''.$langs->trans("Modify").''."\n"; } - if (! empty($conf->adherent->enabled)) + if (!empty($conf->adherent->enabled)) { $adh = new Adherent($db); - $result=$adh->fetch('', '', $object->id); - if ($result == 0 && ($object->client == 1 || $object->client == 3) && ! empty($conf->global->MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS)) + $result = $adh->fetch('', '', $object->id); + if ($result == 0 && ($object->client == 1 || $object->client == 3) && !empty($conf->global->MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS)) { print ''.$langs->trans("NewMember").''; } @@ -2768,10 +2768,10 @@ function init_supplier_categ() { /* * Documents generes */ - $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; - $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; - $genallowed=$user->rights->societe->lire; - $delallowed=$user->rights->societe->creer; + $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; + $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; + $genallowed = $user->rights->societe->lire; + $delallowed = $user->rights->societe->creer; print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); } @@ -2779,7 +2779,7 @@ function init_supplier_categ() { // Subsidiaries list if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES)) { - $result=show_subsidiaries($conf, $langs, $db, $object); + $result = show_subsidiaries($conf, $langs, $db, $object); } print '
'; @@ -2789,31 +2789,31 @@ function init_supplier_categ() { $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt', DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id); // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, '', $socid, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty + $somethingshown = $formactions->showactions($object, '', $socid, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty print '
'; - if (! empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) + if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) { // Contacts list if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { - $result=show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); + $result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); } // Addresses list - if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) + if (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) { - $result=show_addresses($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); + $result = show_addresses($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); } } } // Presend form - $modelmail='thirdparty'; - $defaulttopic='Information'; + $modelmail = 'thirdparty'; + $defaulttopic = 'Information'; $diroutput = $conf->societe->dir_output; $trackid = 'thi'.$object->id; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 027527d20d7be..788fc45ee7ef8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -47,7 +47,7 @@ class Societe extends CommonObject /** * @var string ID to identify managed object */ - public $element='societe'; + public $element = 'societe'; /** * @var string Name of table without prefix where object is stored @@ -57,18 +57,18 @@ class Societe extends CommonObject /** * @var int Field with ID of parent key if this field has a parent */ - public $fk_element='fk_soc'; + public $fk_element = 'fk_soc'; - public $fieldsforcombobox='nom,name_alias'; + public $fieldsforcombobox = 'nom,name_alias'; /** * @var array List of child tables. To test if we can delete object. */ - protected $childtables=array("supplier_proposal"=>'SupplierProposal',"propal"=>'Proposal',"commande"=>'Order',"facture"=>'Invoice',"facture_rec"=>'RecurringInvoiceTemplate',"contrat"=>'Contract',"fichinter"=>'Fichinter',"facture_fourn"=>'SupplierInvoice',"commande_fournisseur"=>'SupplierOrder',"projet"=>'Project',"expedition"=>'Shipment',"prelevement_lignes"=>'DirectDebitRecord'); + protected $childtables = array("supplier_proposal"=>'SupplierProposal', "propal"=>'Proposal', "commande"=>'Order', "facture"=>'Invoice', "facture_rec"=>'RecurringInvoiceTemplate', "contrat"=>'Contract', "fichinter"=>'Fichinter', "facture_fourn"=>'SupplierInvoice', "commande_fournisseur"=>'SupplierOrder', "projet"=>'Project', "expedition"=>'Shipment', "prelevement_lignes"=>'DirectDebitRecord'); /** * @var array List of child tables. To know object to delete on cascade. */ - protected $childtablesoncascade=array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_account", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notify_def", "actioncomm"); + protected $childtablesoncascade = array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_account", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notify_def", "actioncomm"); /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -92,20 +92,20 @@ class Societe extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'nom' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'name_alias' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), - 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'nom' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'name_alias' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), ); @@ -147,7 +147,7 @@ class Societe extends CommonObject * Thirdparty status : 0=activity ceased, 1= in activity * @var int */ - public $status=1; + public $status = 1; /** * Id of department @@ -285,7 +285,7 @@ class Societe extends CommonObject public $prefix_comm; - public $tva_assuj=1; + public $tva_assuj = 1; /** * Intracommunitary VAT ID * @var string @@ -300,12 +300,12 @@ class Societe extends CommonObject public $managers; public $capital; - public $typent_id=0; + public $typent_id = 0; public $typent_code; public $effectif; - public $effectif_id=0; + public $effectif_id = 0; public $forme_juridique_code; - public $forme_juridique=0; + public $forme_juridique = 0; public $remise_percent; public $remise_supplier_percent; @@ -350,12 +350,12 @@ class Societe extends CommonObject * 0=no customer, 1=customer, 2=prospect, 3=customer and prospect * @var int */ - public $client=0; + public $client = 0; /** * 0=no prospect, 1=prospect * @var int */ - public $prospect=0; + public $prospect = 0; /** * 0=no supplier, 1=supplier * @var int @@ -501,7 +501,7 @@ class Societe extends CommonObject public $fk_incoterms; public $location_incoterms; - public $label_incoterms; //Used into tooltip + public $label_incoterms; //Used into tooltip // Multicurrency /** @@ -527,9 +527,9 @@ public function __construct($db) $this->client = 0; $this->prospect = 0; $this->fournisseur = 0; - $this->typent_id = 0; - $this->effectif_id = 0; - $this->forme_juridique_code = 0; + $this->typent_id = 0; + $this->effectif_id = 0; + $this->forme_juridique_code = 0; $this->tva_assuj = 1; $this->status = 1; } @@ -544,17 +544,17 @@ public function __construct($db) */ public function create(User $user) { - global $langs,$conf,$mysoc; + global $langs, $conf, $mysoc; - $error=0; + $error = 0; // Clean parameters - if (empty($this->status)) $this->status=0; - $this->name=$this->name?trim($this->name):trim($this->nom); - if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name=ucwords($this->name); - $this->nom=$this->name; // For backward compatibility - if (empty($this->client)) $this->client=0; - if (empty($this->fournisseur)) $this->fournisseur=0; + if (empty($this->status)) $this->status = 0; + $this->name = $this->name ?trim($this->name) : trim($this->nom); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = ucwords($this->name); + $this->nom = $this->name; // For backward compatibility + if (empty($this->client)) $this->client = 0; + if (empty($this->fournisseur)) $this->fournisseur = 0; $this->import_key = trim($this->import_key); if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); @@ -566,7 +566,7 @@ public function create(User $user) dol_syslog(get_class($this)."::create ".$this->name); - $now=dol_now(); + $now = dol_now(); $this->db->begin(); @@ -580,24 +580,24 @@ public function create(User $user) if ($result >= 0) { - $this->entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity); + $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key, fk_multicurrency, multicurrency_code)"; - $sql.= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'"; - $sql.= ", ".(! empty($user->id) ? "'".$user->id."'":"null"); - $sql.= ", ".(! empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'":"null"); - $sql.= ", ".$this->status; - $sql.= ", ".(! empty($this->ref_int) ? "'".$this->db->escape($this->ref_int)."'":"null"); - $sql.= ", ".(! empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'":"null"); - $sql.= ", 0"; - $sql.= ", ".(int) $this->fk_incoterms; - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ", ".(! empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'":"null"); - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."')"; + $sql .= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'"; + $sql .= ", ".(!empty($user->id) ? "'".$user->id."'" : "null"); + $sql .= ", ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null"); + $sql .= ", ".$this->status; + $sql .= ", ".(!empty($this->ref_int) ? "'".$this->db->escape($this->ref_int)."'" : "null"); + $sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); + $sql .= ", 0"; + $sql .= ", ".(int) $this->fk_incoterms; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); + $sql .= ", ".(int) $this->fk_multicurrency; + $sql .= ", '".$this->db->escape($this->multicurrency_code)."')"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe"); @@ -618,13 +618,13 @@ public function create(User $user) if ($ret >= 0) { // Call trigger - $result=$this->call_trigger('COMPANY_CREATE', $user); + $result = $this->call_trigger('COMPANY_CREATE', $user); if ($result < 0) $error++; // End call triggers } else $error++; - if (! $error) + if (!$error) { dol_syslog(get_class($this)."::Create success id=".$this->id); $this->db->commit(); @@ -641,13 +641,13 @@ public function create(User $user) { if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $this->error=$langs->trans("ErrorCompanyNameAlreadyExists", $this->name); // duplicate on a field (code or profid or ...) - $result=-1; + $this->error = $langs->trans("ErrorCompanyNameAlreadyExists", $this->name); // duplicate on a field (code or profid or ...) + $result = -1; } else { - $this->error=$this->db->lasterror(); - $result=-2; + $this->error = $this->db->lasterror(); + $result = -2; } $this->db->rollback(); return $result; @@ -673,12 +673,12 @@ public function create_individual(User $user) { // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $contact=new Contact($this->db); + $contact = new Contact($this->db); $contact->name = $this->name_bis; $contact->firstname = $this->firstname; $contact->civility_id = $this->civility_id; - $contact->socid = $this->id; // fk_soc + $contact->socid = $this->id; // fk_soc $contact->statut = 1; $contact->priv = 0; $contact->country_id = $this->country_id; @@ -694,7 +694,7 @@ public function create_individual(User $user) { $this->error = $contact->error; $this->errors = $contact->errors; - dol_syslog(get_class($this)."::create_individual ERROR:" . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::create_individual ERROR:".$this->error, LOG_ERR); } return $result; @@ -711,13 +711,13 @@ public function verify() global $conf, $langs, $mysoc; $error = 0; - $this->errors=array(); + $this->errors = array(); $result = 0; - $this->name = trim($this->name); - $this->nom=$this->name; // For backward compatibility + $this->name = trim($this->name); + $this->nom = $this->name; // For backward compatibility - if (! $this->name) + if (!$this->name) { $this->errors[] = 'ErrorBadThirdPartyName'; $result = -2; @@ -774,12 +774,12 @@ public function verify() } // Check for duplicate or mandatory fields defined into setup - $array_to_check=array('IDPROF1','IDPROF2','IDPROF3','IDPROF4','IDPROF5','IDPROF6','EMAIL'); - foreach($array_to_check as $key) + $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL'); + foreach ($array_to_check as $key) { - $keymin=strtolower($key); - $i=(int) preg_replace('/[^0-9]/', '', $key); - $vallabel=$this->$keymin; + $keymin = strtolower($key); + $i = (int) preg_replace('/[^0-9]/', '', $key); + $vallabel = $this->$keymin; if ($i > 0) { @@ -788,8 +788,8 @@ public function verify() // Check for mandatory prof id (but only if country is same than ours) if ($mysoc->country_id > 0 && $this->country_id == $mysoc->country_id) { - $idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY'; - if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) + $idprof_mandatory = 'SOCIETE_'.$key.'_MANDATORY'; + if (!$vallabel && !empty($conf->global->$idprof_mandatory)) { $langs->load("errors"); $error++; @@ -799,7 +799,7 @@ public function verify() } // Check for unicity - if (! $error && $vallabel && $this->id_prof_verifiable($i)) + if (!$error && $vallabel && $this->id_prof_verifiable($i)) { if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) { @@ -816,7 +816,7 @@ public function verify() if ($key == 'EMAIL') { // Check for mandatory - if (! empty($conf->global->SOCIETE_EMAIL_MANDATORY) && ! isValidEMail($this->email)) + if (!empty($conf->global->SOCIETE_EMAIL_MANDATORY) && !isValidEMail($this->email)) { $langs->load("errors"); $error++; @@ -824,7 +824,7 @@ public function verify() } // Check for unicity - if (! $error && $vallabel && ! empty($conf->global->SOCIETE_EMAIL_UNIQUE)) + if (!$error && $vallabel && !empty($conf->global->SOCIETE_EMAIL_UNIQUE)) { if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) { @@ -855,47 +855,47 @@ public function verify() */ public function update($id, $user = '', $call_trigger = 1, $allowmodcodeclient = 0, $allowmodcodefournisseur = 0, $action = 'update', $nosyncmember = 1) { - global $langs,$conf,$hookmanager; + global $langs, $conf, $hookmanager; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; if (empty($id)) $id = $this->id; - $error=0; + $error = 0; dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); - $now=dol_now(); + $now = dol_now(); // Clean parameters - $this->id = $id; - $this->entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity); - $this->name = $this->name?trim($this->name):trim($this->nom); - $this->nom = $this->name; // For backward compatibility - $this->name_alias = trim($this->name_alias); + $this->id = $id; + $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); + $this->name = $this->name ?trim($this->name) : trim($this->nom); + $this->nom = $this->name; // For backward compatibility + $this->name_alias = trim($this->name_alias); $this->ref_ext = trim($this->ref_ext); - $this->address = $this->address?trim($this->address):trim($this->address); - $this->zip = $this->zip?trim($this->zip):trim($this->zip); - $this->town = $this->town?trim($this->town):trim($this->town); - $this->state_id = trim($this->state_id); - $this->country_id = ($this->country_id > 0)?$this->country_id:0; + $this->address = $this->address ?trim($this->address) : trim($this->address); + $this->zip = $this->zip ?trim($this->zip) : trim($this->zip); + $this->town = $this->town ?trim($this->town) : trim($this->town); + $this->state_id = trim($this->state_id); + $this->country_id = ($this->country_id > 0) ? $this->country_id : 0; $this->phone = trim($this->phone); $this->phone = preg_replace("/\s/", "", $this->phone); $this->phone = preg_replace("/\./", "", $this->phone); $this->fax = trim($this->fax); $this->fax = preg_replace("/\s/", "", $this->fax); $this->fax = preg_replace("/\./", "", $this->fax); - $this->email = trim($this->email); - $this->url = $this->url?clean_url($this->url, 0):''; + $this->email = trim($this->email); + $this->url = $this->url ?clean_url($this->url, 0) : ''; $this->note_private = trim($this->note_private); $this->note_public = trim($this->note_public); $this->idprof1 = trim($this->idprof1); $this->idprof2 = trim($this->idprof2); $this->idprof3 = trim($this->idprof3); $this->idprof4 = trim($this->idprof4); - $this->idprof5 = (! empty($this->idprof5)?trim($this->idprof5):''); - $this->idprof6 = (! empty($this->idprof6)?trim($this->idprof6):''); - $this->prefix_comm = trim($this->prefix_comm); + $this->idprof5 = (!empty($this->idprof5) ?trim($this->idprof5) : ''); + $this->idprof6 = (!empty($this->idprof6) ?trim($this->idprof6) : ''); + $this->prefix_comm = trim($this->prefix_comm); $this->outstanding_limit = price2num($this->outstanding_limit); $this->order_min_amount = price2num($this->order_min_amount); $this->supplier_order_min_amount = price2num($this->supplier_order_min_amount); @@ -912,64 +912,64 @@ public function update($id, $user = '', $call_trigger = 1, $allowmodcodeclient = } // Local taxes - $this->localtax1_assuj=trim($this->localtax1_assuj); - $this->localtax2_assuj=trim($this->localtax2_assuj); + $this->localtax1_assuj = trim($this->localtax1_assuj); + $this->localtax2_assuj = trim($this->localtax2_assuj); - $this->localtax1_value=trim($this->localtax1_value); - $this->localtax2_value=trim($this->localtax2_value); + $this->localtax1_value = trim($this->localtax1_value); + $this->localtax2_value = trim($this->localtax2_value); - if ($this->capital != '') $this->capital=price2num(trim($this->capital)); - if (! is_numeric($this->capital)) $this->capital = ''; // '' = undef + if ($this->capital != '') $this->capital = price2num(trim($this->capital)); + if (!is_numeric($this->capital)) $this->capital = ''; // '' = undef - $this->effectif_id=trim($this->effectif_id); - $this->forme_juridique_code=trim($this->forme_juridique_code); + $this->effectif_id = trim($this->effectif_id); + $this->forme_juridique_code = trim($this->forme_juridique_code); //Gencod - $this->barcode=trim($this->barcode); + $this->barcode = trim($this->barcode); // For automatic creation if ($this->code_client == -1 || $this->code_client === 'auto') $this->get_codeclient($this, 0); if ($this->code_fournisseur == -1 || $this->code_fournisseur === 'auto') $this->get_codefournisseur($this, 1); - $this->code_compta=trim($this->code_compta); - $this->code_compta_fournisseur=trim($this->code_compta_fournisseur); + $this->code_compta = trim($this->code_compta); + $this->code_compta_fournisseur = trim($this->code_compta_fournisseur); // Check parameters. More tests are done later in the ->verify() - if (! is_numeric($this->client) && ! is_numeric($this->fournisseur)) + if (!is_numeric($this->client) && !is_numeric($this->fournisseur)) { $langs->load("errors"); $this->error = $langs->trans("BadValueForParameterClientOrSupplier"); return -1; } - $customer=false; - if (! empty($allowmodcodeclient) && ! empty($this->client)) + $customer = false; + if (!empty($allowmodcodeclient) && !empty($this->client)) { // Attention get_codecompta peut modifier le code suivant le module utilise if (empty($this->code_compta)) { - $ret=$this->get_codecompta('customer'); + $ret = $this->get_codecompta('customer'); if ($ret < 0) return -1; } - $customer=true; + $customer = true; } - $supplier=false; - if (! empty($allowmodcodefournisseur) && ! empty($this->fournisseur)) + $supplier = false; + if (!empty($allowmodcodefournisseur) && !empty($this->fournisseur)) { // Attention get_codecompta peut modifier le code suivant le module utilise if ($this->code_compta_fournisseur == "") { - $ret=$this->get_codecompta('supplier'); + $ret = $this->get_codecompta('supplier'); if ($ret < 0) return -1; } - $supplier=true; + $supplier = true; } //Web services - $this->webservices_url = $this->webservices_url?clean_url($this->webservices_url, 0):''; + $this->webservices_url = $this->webservices_url ?clean_url($this->webservices_url, 0) : ''; $this->webservices_key = trim($this->webservices_key); //Incoterms @@ -993,11 +993,11 @@ public function update($id, $user = '', $call_trigger = 1, $allowmodcodeclient = { if (in_array('ErrorBadCustomerCodeSyntax', $this->errors) && is_object($this->oldcopy) && $this->oldcopy->code_client == $this->code_client) { - if (($key = array_search('ErrorBadCustomerCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message + if (($key = array_search('ErrorBadCustomerCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message } if (in_array('ErrorBadSupplierCodeSyntax', $this->errors) && is_object($this->oldcopy) && $this->oldcopy->code_fournisseur == $this->code_fournisseur) { - if (($key = array_search('ErrorBadSupplierCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message + if (($key = array_search('ErrorBadSupplierCodeSyntax', $this->errors)) !== false) unset($this->errors[$key]); // Remove error message } if (empty($this->errors)) // If there is no more error, we can make like if there is no error at all { @@ -1011,117 +1011,117 @@ public function update($id, $user = '', $call_trigger = 1, $allowmodcodeclient = dol_syslog(get_class($this)."::update verify ok or not done"); $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql .= "entity = " . $this->db->escape($this->entity); - $sql .= ",nom = '" . $this->db->escape($this->name) ."'"; // Required - $sql .= ",name_alias = '" . $this->db->escape($this->name_alias) ."'"; - $sql .= ",ref_ext = " .(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext) ."'":"null"); - $sql .= ",address = '" . $this->db->escape($this->address) ."'"; + $sql .= "entity = ".$this->db->escape($this->entity); + $sql .= ",nom = '".$this->db->escape($this->name)."'"; // Required + $sql .= ",name_alias = '".$this->db->escape($this->name_alias)."'"; + $sql .= ",ref_ext = ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); + $sql .= ",address = '".$this->db->escape($this->address)."'"; - $sql .= ",zip = ".(! empty($this->zip)?"'".$this->db->escape($this->zip)."'":"null"); - $sql .= ",town = ".(! empty($this->town)?"'".$this->db->escape($this->town)."'":"null"); + $sql .= ",zip = ".(!empty($this->zip) ? "'".$this->db->escape($this->zip)."'" : "null"); + $sql .= ",town = ".(!empty($this->town) ? "'".$this->db->escape($this->town)."'" : "null"); - $sql .= ",fk_departement = '" . (! empty($this->state_id)?$this->state_id:'0') ."'"; - $sql .= ",fk_pays = '" . (! empty($this->country_id)?$this->country_id:'0') ."'"; + $sql .= ",fk_departement = '".(!empty($this->state_id) ? $this->state_id : '0')."'"; + $sql .= ",fk_pays = '".(!empty($this->country_id) ? $this->country_id : '0')."'"; - $sql .= ",phone = ".(! empty($this->phone)?"'".$this->db->escape($this->phone)."'":"null"); - $sql .= ",fax = ".(! empty($this->fax)?"'".$this->db->escape($this->fax)."'":"null"); - $sql .= ",email = ".(! empty($this->email)?"'".$this->db->escape($this->email)."'":"null"); + $sql .= ",phone = ".(!empty($this->phone) ? "'".$this->db->escape($this->phone)."'" : "null"); + $sql .= ",fax = ".(!empty($this->fax) ? "'".$this->db->escape($this->fax)."'" : "null"); + $sql .= ",email = ".(!empty($this->email) ? "'".$this->db->escape($this->email)."'" : "null"); $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; - $sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null"); + $sql .= ",url = ".(!empty($this->url) ? "'".$this->db->escape($this->url)."'" : "null"); - $sql .= ",parent = " . ($this->parent > 0 ? $this->parent : "null"); + $sql .= ",parent = ".($this->parent > 0 ? $this->parent : "null"); - $sql .= ",note_private = ".(! empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); - $sql .= ",note_public = ".(! empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); + $sql .= ",note_private = ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); + $sql .= ",note_public = ".(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null"); - $sql .= ",siren = '". $this->db->escape($this->idprof1) ."'"; - $sql .= ",siret = '". $this->db->escape($this->idprof2) ."'"; - $sql .= ",ape = '". $this->db->escape($this->idprof3) ."'"; - $sql .= ",idprof4 = '". $this->db->escape($this->idprof4) ."'"; - $sql .= ",idprof5 = '". $this->db->escape($this->idprof5) ."'"; - $sql .= ",idprof6 = '". $this->db->escape($this->idprof6) ."'"; + $sql .= ",siren = '".$this->db->escape($this->idprof1)."'"; + $sql .= ",siret = '".$this->db->escape($this->idprof2)."'"; + $sql .= ",ape = '".$this->db->escape($this->idprof3)."'"; + $sql .= ",idprof4 = '".$this->db->escape($this->idprof4)."'"; + $sql .= ",idprof5 = '".$this->db->escape($this->idprof5)."'"; + $sql .= ",idprof6 = '".$this->db->escape($this->idprof6)."'"; - $sql .= ",tva_assuj = ".($this->tva_assuj!=''?"'".$this->db->escape($this->tva_assuj)."'":"null"); - $sql .= ",tva_intra = '" . $this->db->escape($this->tva_intra) ."'"; - $sql .= ",status = " .$this->status; + $sql .= ",tva_assuj = ".($this->tva_assuj != '' ? "'".$this->db->escape($this->tva_assuj)."'" : "null"); + $sql .= ",tva_intra = '".$this->db->escape($this->tva_intra)."'"; + $sql .= ",status = ".$this->status; // Local taxes - $sql .= ",localtax1_assuj = ".($this->localtax1_assuj!=''?"'".$this->db->escape($this->localtax1_assuj)."'":"null"); - $sql .= ",localtax2_assuj = ".($this->localtax2_assuj!=''?"'".$this->db->escape($this->localtax2_assuj)."'":"null"); - if($this->localtax1_assuj==1) + $sql .= ",localtax1_assuj = ".($this->localtax1_assuj != '' ? "'".$this->db->escape($this->localtax1_assuj)."'" : "null"); + $sql .= ",localtax2_assuj = ".($this->localtax2_assuj != '' ? "'".$this->db->escape($this->localtax2_assuj)."'" : "null"); + if ($this->localtax1_assuj == 1) { - if($this->localtax1_value!='') + if ($this->localtax1_value != '') { - $sql .=",localtax1_value =".$this->localtax1_value; + $sql .= ",localtax1_value =".$this->localtax1_value; } - else $sql .=",localtax1_value =0.000"; + else $sql .= ",localtax1_value =0.000"; } - else $sql .=",localtax1_value =0.000"; + else $sql .= ",localtax1_value =0.000"; - if($this->localtax2_assuj==1) + if ($this->localtax2_assuj == 1) { - if($this->localtax2_value!='') + if ($this->localtax2_value != '') { - $sql .=",localtax2_value =".$this->localtax2_value; + $sql .= ",localtax2_value =".$this->localtax2_value; } - else $sql .=",localtax2_value =0.000"; + else $sql .= ",localtax2_value =0.000"; } - else $sql .=",localtax2_value =0.000"; + else $sql .= ",localtax2_value =0.000"; $sql .= ",capital = ".($this->capital == '' ? "null" : $this->capital); - $sql .= ",prefix_comm = ".(! empty($this->prefix_comm)?"'".$this->db->escape($this->prefix_comm)."'":"null"); + $sql .= ",prefix_comm = ".(!empty($this->prefix_comm) ? "'".$this->db->escape($this->prefix_comm)."'" : "null"); - $sql .= ",fk_effectif = ".(! empty($this->effectif_id)?"'".$this->db->escape($this->effectif_id)."'":"null"); + $sql .= ",fk_effectif = ".(!empty($this->effectif_id) ? "'".$this->db->escape($this->effectif_id)."'" : "null"); if (isset($this->stcomm_id)) { - $sql .= ",fk_stcomm=".(!empty($this->stcomm_id) ? $this->stcomm_id : "0"); + $sql .= ",fk_stcomm=".(!empty($this->stcomm_id) ? $this->stcomm_id : "0"); } - $sql .= ",fk_typent = ".(! empty($this->typent_id)?"'".$this->db->escape($this->typent_id)."'":"0"); - - $sql .= ",fk_forme_juridique = ".(! empty($this->forme_juridique_code)?"'".$this->db->escape($this->forme_juridique_code)."'":"null"); - - $sql .= ",mode_reglement = ".(! empty($this->mode_reglement_id)?"'".$this->db->escape($this->mode_reglement_id)."'":"null"); - $sql .= ",cond_reglement = ".(! empty($this->cond_reglement_id)?"'".$this->db->escape($this->cond_reglement_id)."'":"null"); - $sql .= ",mode_reglement_supplier = ".(! empty($this->mode_reglement_supplier_id)?"'".$this->db->escape($this->mode_reglement_supplier_id)."'":"null"); - $sql .= ",cond_reglement_supplier = ".(! empty($this->cond_reglement_supplier_id)?"'".$this->db->escape($this->cond_reglement_supplier_id)."'":"null"); - $sql .= ",fk_shipping_method = ".(! empty($this->shipping_method_id)?"'".$this->db->escape($this->shipping_method_id)."'":"null"); - - $sql .= ",client = " . (! empty($this->client)?$this->client:0); - $sql .= ",fournisseur = " . (! empty($this->fournisseur)?$this->fournisseur:0); - $sql .= ",barcode = ".(! empty($this->barcode)?"'".$this->db->escape($this->barcode)."'":"null"); - $sql .= ",default_lang = ".(! empty($this->default_lang)?"'".$this->db->escape($this->default_lang)."'":"null"); - $sql .= ",logo = ".(! empty($this->logo)?"'".$this->db->escape($this->logo)."'":"null"); - $sql .= ",logo_squarred = ".(! empty($this->logo_squarred)?"'".$this->db->escape($this->logo_squarred)."'":"null"); - $sql .= ",outstanding_limit= ".($this->outstanding_limit!=''?$this->outstanding_limit:'null'); - $sql .= ",order_min_amount= ".($this->order_min_amount!=''?$this->order_min_amount:'null'); - $sql .= ",supplier_order_min_amount= ".($this->supplier_order_min_amount!=''?$this->supplier_order_min_amount:'null'); + $sql .= ",fk_typent = ".(!empty($this->typent_id) ? "'".$this->db->escape($this->typent_id)."'" : "0"); + + $sql .= ",fk_forme_juridique = ".(!empty($this->forme_juridique_code) ? "'".$this->db->escape($this->forme_juridique_code)."'" : "null"); + + $sql .= ",mode_reglement = ".(!empty($this->mode_reglement_id) ? "'".$this->db->escape($this->mode_reglement_id)."'" : "null"); + $sql .= ",cond_reglement = ".(!empty($this->cond_reglement_id) ? "'".$this->db->escape($this->cond_reglement_id)."'" : "null"); + $sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape($this->mode_reglement_supplier_id)."'" : "null"); + $sql .= ",cond_reglement_supplier = ".(!empty($this->cond_reglement_supplier_id) ? "'".$this->db->escape($this->cond_reglement_supplier_id)."'" : "null"); + $sql .= ",fk_shipping_method = ".(!empty($this->shipping_method_id) ? "'".$this->db->escape($this->shipping_method_id)."'" : "null"); + + $sql .= ",client = ".(!empty($this->client) ? $this->client : 0); + $sql .= ",fournisseur = ".(!empty($this->fournisseur) ? $this->fournisseur : 0); + $sql .= ",barcode = ".(!empty($this->barcode) ? "'".$this->db->escape($this->barcode)."'" : "null"); + $sql .= ",default_lang = ".(!empty($this->default_lang) ? "'".$this->db->escape($this->default_lang)."'" : "null"); + $sql .= ",logo = ".(!empty($this->logo) ? "'".$this->db->escape($this->logo)."'" : "null"); + $sql .= ",logo_squarred = ".(!empty($this->logo_squarred) ? "'".$this->db->escape($this->logo_squarred)."'" : "null"); + $sql .= ",outstanding_limit= ".($this->outstanding_limit != '' ? $this->outstanding_limit : 'null'); + $sql .= ",order_min_amount= ".($this->order_min_amount != '' ? $this->order_min_amount : 'null'); + $sql .= ",supplier_order_min_amount= ".($this->supplier_order_min_amount != '' ? $this->supplier_order_min_amount : 'null'); $sql .= ",fk_prospectlevel='".$this->db->escape($this->fk_prospectlevel)."'"; - $sql .= ",webservices_url = ".(! empty($this->webservices_url)?"'".$this->db->escape($this->webservices_url)."'":"null"); - $sql .= ",webservices_key = ".(! empty($this->webservices_key)?"'".$this->db->escape($this->webservices_key)."'":"null"); + $sql .= ",webservices_url = ".(!empty($this->webservices_url) ? "'".$this->db->escape($this->webservices_url)."'" : "null"); + $sql .= ",webservices_key = ".(!empty($this->webservices_key) ? "'".$this->db->escape($this->webservices_key)."'" : "null"); //Incoterms - $sql.= ", fk_incoterms = ".$this->fk_incoterms; - $sql.= ", location_incoterms = ".(! empty($this->location_incoterms)?"'".$this->db->escape($this->location_incoterms)."'":"null"); + $sql .= ", fk_incoterms = ".$this->fk_incoterms; + $sql .= ", location_incoterms = ".(!empty($this->location_incoterms) ? "'".$this->db->escape($this->location_incoterms)."'" : "null"); if ($customer) { - $sql .= ", code_client = ".(! empty($this->code_client)?"'".$this->db->escape($this->code_client)."'":"null"); - $sql .= ", code_compta = ".(! empty($this->code_compta)?"'".$this->db->escape($this->code_compta)."'":"null"); + $sql .= ", code_client = ".(!empty($this->code_client) ? "'".$this->db->escape($this->code_client)."'" : "null"); + $sql .= ", code_compta = ".(!empty($this->code_compta) ? "'".$this->db->escape($this->code_compta)."'" : "null"); } if ($supplier) { - $sql .= ", code_fournisseur = ".(! empty($this->code_fournisseur)?"'".$this->db->escape($this->code_fournisseur)."'":"null"); - $sql .= ", code_compta_fournisseur = ".(($this->code_compta_fournisseur != "")?"'".$this->db->escape($this->code_compta_fournisseur)."'":"null"); + $sql .= ", code_fournisseur = ".(!empty($this->code_fournisseur) ? "'".$this->db->escape($this->code_fournisseur)."'" : "null"); + $sql .= ", code_compta_fournisseur = ".(($this->code_compta_fournisseur != "") ? "'".$this->db->escape($this->code_compta_fournisseur)."'" : "null"); } - $sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id:"null"); + $sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id : "null"); $sql .= ", fk_multicurrency = ".(int) $this->fk_multicurrency; $sql .= ", multicurrency_code = '".$this->db->escape($this->multicurrency_code)."'"; - $sql .= " WHERE rowid = " . (int) $id; + $sql .= " WHERE rowid = ".(int) $id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if (is_object($this->oldcopy)) // If we have information on old values @@ -1139,7 +1139,7 @@ public function update($id, $user = '', $call_trigger = 1, $allowmodcodeclient = } else { - unset($this->country_code); // We clean this, in the doubt, because it may have been changed after an update of country_id + unset($this->country_code); // We clean this, in the doubt, because it may have been changed after an update of country_id unset($this->country); unset($this->state_code); unset($this->state); @@ -1147,33 +1147,33 @@ public function update($id, $user = '', $call_trigger = 1, $allowmodcodeclient = $nbrowsaffected = $this->db->affected_rows($resql); - if (! $error && $nbrowsaffected) + if (!$error && $nbrowsaffected) { // Update information on linked member if it is an update - if (! $nosyncmember && ! empty($conf->adherent->enabled)) + if (!$nosyncmember && !empty($conf->adherent->enabled)) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; dol_syslog(get_class($this)."::update update linked member"); - $lmember=new Adherent($this->db); - $result=$lmember->fetch(0, 0, $this->id); + $lmember = new Adherent($this->db); + $result = $lmember->fetch(0, 0, $this->id); if ($result > 0) { - $lmember->company=$this->name; + $lmember->company = $this->name; //$lmember->firstname=$this->firstname?$this->firstname:$lmember->firstname; // We keep firstname and lastname of member unchanged //$lmember->lastname=$this->lastname?$this->lastname:$lmember->lastname; // We keep firstname and lastname of member unchanged - $lmember->address=$this->address; - $lmember->zip=$this->zip; - $lmember->town=$this->town; - $lmember->email=$this->email; - $lmember->socialnetworks=$this->socialnetworks; - $lmember->phone=$this->phone; - $lmember->state_id=$this->state_id; - $lmember->country_id=$this->country_id; - - $result=$lmember->update($user, 0, 1, 1, 1); // Use nosync to 1 to avoid cyclic updates + $lmember->address = $this->address; + $lmember->zip = $this->zip; + $lmember->town = $this->town; + $lmember->email = $this->email; + $lmember->socialnetworks = $this->socialnetworks; + $lmember->phone = $this->phone; + $lmember->state_id = $this->state_id; + $lmember->country_id = $this->country_id; + + $result = $lmember->update($user, 0, 1, 1, 1); // Use nosync to 1 to avoid cyclic updates if ($result < 0) { $this->error = $lmember->error; @@ -1184,33 +1184,33 @@ public function update($id, $user = '', $call_trigger = 1, $allowmodcodeclient = } elseif ($result < 0) { - $this->error=$lmember->error; + $this->error = $lmember->error; $error++; } } } - $action='update'; + $action = 'update'; // Actions on extra fields - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && $call_trigger) + if (!$error && $call_trigger) { // Call trigger - $result=$this->call_trigger('COMPANY_MODIFY', $user); + $result = $this->call_trigger('COMPANY_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { dol_syslog(get_class($this)."::Update success"); $this->db->commit(); @@ -1323,13 +1323,13 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 if ($idprof6) $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'"; if ($email) $sql .= " AND s.email = '".$this->db->escape($email)."'"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); + $num = $this->db->num_rows($resql); if ($num > 1) { - $this->error='Fetch found several records. Rename one of thirdparties to avoid duplicate.'; + $this->error = 'Fetch found several records. Rename one of thirdparties to avoid duplicate.'; dol_syslog($this->error, LOG_ERR); $result = -2; } @@ -1339,11 +1339,11 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 $this->id = $obj->rowid; $this->entity = $obj->entity; - $this->canvas = $obj->canvas; + $this->canvas = $obj->canvas; $this->ref = $obj->rowid; - $this->name = $obj->name; - $this->nom = $obj->name; // deprecated + $this->name = $obj->name; + $this->nom = $obj->name; // deprecated $this->name_alias = $obj->name_alias; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; @@ -1353,22 +1353,22 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 $this->user_creation = $obj->fk_user_creat; $this->user_modification = $obj->fk_user_modif; - $this->address = $obj->address; + $this->address = $obj->address; $this->zip = $obj->zip; $this->town = $obj->town; $this->country_id = $obj->country_id; - $this->country_code = $obj->country_id?$obj->country_code:''; - $this->country = $obj->country_id?($langs->transnoentities('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; + $this->country_code = $obj->country_id ? $obj->country_code : ''; + $this->country = $obj->country_id ? ($langs->transnoentities('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : ''; $this->state_id = $obj->state_id; $this->state_code = $obj->state_code; - $this->state = ($obj->state!='-'?$obj->state:''); + $this->state = ($obj->state != '-' ? $obj->state : ''); - $transcode=$langs->trans('StatusProspect'.$obj->fk_stcomm); - $label = ($transcode!='StatusProspect'.$obj->fk_stcomm ? $transcode : $obj->stcomm); - $this->stcomm_id = $obj->fk_stcomm; // id status prospect - $this->status_prospect_label = $label; // label status prospect + $transcode = $langs->trans('StatusProspect'.$obj->fk_stcomm); + $label = ($transcode != 'StatusProspect'.$obj->fk_stcomm ? $transcode : $obj->stcomm); + $this->stcomm_id = $obj->fk_stcomm; // id status prospect + $this->status_prospect_label = $label; // label status prospect $this->email = $obj->email; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); @@ -1377,7 +1377,7 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 $this->phone = $obj->phone; $this->fax = $obj->fax; - $this->parent = $obj->parent; + $this->parent = $obj->parent; $this->idprof1 = $obj->idprof1; $this->idprof2 = $obj->idprof2; @@ -1386,7 +1386,7 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 $this->idprof5 = $obj->idprof5; $this->idprof6 = $obj->idprof6; - $this->capital = $obj->capital; + $this->capital = $obj->capital; $this->code_client = $obj->code_client; $this->code_fournisseur = $obj->code_fournisseur; @@ -1411,23 +1411,23 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 $this->typent_code = $obj->typent_code; $this->effectif_id = $obj->effectif_id; - $this->effectif = $obj->effectif_id?$obj->effectif:''; + $this->effectif = $obj->effectif_id ? $obj->effectif : ''; - $this->forme_juridique_code= $obj->forme_juridique_code; - $this->forme_juridique = $obj->forme_juridique_code?$obj->forme_juridique:''; + $this->forme_juridique_code = $obj->forme_juridique_code; + $this->forme_juridique = $obj->forme_juridique_code ? $obj->forme_juridique : ''; $this->fk_prospectlevel = $obj->fk_prospectlevel; $this->prefix_comm = $obj->prefix_comm; - $this->remise_percent = price2num($obj->remise_client); // 0.000000 must be 0 - $this->remise_supplier_percent = $obj->remise_supplier; + $this->remise_percent = price2num($obj->remise_client); // 0.000000 must be 0 + $this->remise_supplier_percent = $obj->remise_supplier; $this->mode_reglement_id = $obj->mode_reglement; $this->cond_reglement_id = $obj->cond_reglement; $this->mode_reglement_supplier_id = $obj->mode_reglement_supplier; $this->cond_reglement_supplier_id = $obj->cond_reglement_supplier; - $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null; - $this->fk_account = $obj->fk_account; + $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; + $this->fk_account = $obj->fk_account; $this->client = $obj->client; $this->fournisseur = $obj->fournisseur; @@ -1445,7 +1445,7 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 $this->outstanding_limit = $obj->outstanding_limit; $this->order_min_amount = $obj->order_min_amount; - $this->supplier_order_min_amount = $obj->supplier_order_min_amount; + $this->supplier_order_min_amount = $obj->supplier_order_min_amount; // multiprix $this->price_level = $obj->price_level; @@ -1475,12 +1475,12 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $result = -3; } // Use first price level if level not defined for third party - if ((! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && empty($this->price_level)) $this->price_level=1; + if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && empty($this->price_level)) $this->price_level = 1; return $result; } @@ -1497,11 +1497,11 @@ public function delete($id, User $fuser = null, $call_trigger = 1) { global $langs, $conf, $user; - if (empty($fuser)) $fuser=$user; + if (empty($fuser)) $fuser = $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $entity=isset($this->entity)?$this->entity:$conf->entity; + $entity = isset($this->entity) ? $this->entity : $conf->entity; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $error = 0; @@ -1513,15 +1513,15 @@ public function delete($id, User $fuser = null, $call_trigger = 1) $this->db->begin(); // User is mandatory for trigger call - if (! $error && $call_trigger) + if (!$error && $call_trigger) { // Call trigger - $result=$this->call_trigger('COMPANY_DELETE', $fuser); + $result = $this->call_trigger('COMPANY_DELETE', $fuser); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $static_cat = new Categorie($this->db); @@ -1549,11 +1549,11 @@ public function delete($id, User $fuser = null, $call_trigger = 1) foreach ($this->childtablesoncascade as $tabletodelete) { - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete; - $sql.= " WHERE fk_soc = " . $id; - if (! $this->db->query($sql)) + $sql .= " WHERE fk_soc = ".$id; + if (!$this->db->query($sql)) { $error++; $this->errors[] = $this->db->lasterror(); @@ -1562,9 +1562,9 @@ public function delete($id, User $fuser = null, $call_trigger = 1) } // Removed extrafields - if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { - $result=$this->deleteExtraFields(); + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -1573,12 +1573,12 @@ public function delete($id, User $fuser = null, $call_trigger = 1) } // Remove links to subsidiaries companies - if (! $error) + if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql.= " SET parent = NULL"; - $sql.= " WHERE parent = " . $id; - if (! $this->db->query($sql)) + $sql .= " SET parent = NULL"; + $sql .= " WHERE parent = ".$id; + if (!$this->db->query($sql)) { $error++; $this->errors[] = $this->db->lasterror(); @@ -1586,25 +1586,25 @@ public function delete($id, User $fuser = null, $call_trigger = 1) } // Remove third party - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE rowid = " . $id; - if (! $this->db->query($sql)) + $sql .= " WHERE rowid = ".$id; + if (!$this->db->query($sql)) { $error++; $this->errors[] = $this->db->lasterror(); } } - if (! $error) + if (!$error) { $this->db->commit(); // Delete directory - if (! empty($conf->societe->multidir_output[$entity])) + if (!empty($conf->societe->multidir_output[$entity])) { - $docdir = $conf->societe->multidir_output[$entity] . "/" . $id; + $docdir = $conf->societe->multidir_output[$entity]."/".$id; if (dol_is_dir($docdir)) { dol_delete_dir_recursive($docdir); @@ -1635,13 +1635,13 @@ public function set_as_client() // phpcs:enable if ($this->id) { - $newclient=1; - if ($this->client == 2 || $this->client == 3) $newclient=3; //If prospect, we keep prospect tag + $newclient = 1; + if ($this->client == 2 || $this->client == 3) $newclient = 3; //If prospect, we keep prospect tag $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql.= " SET client = ".$newclient; - $sql.= " WHERE rowid = " . $this->id; + $sql .= " SET client = ".$newclient; + $sql .= " WHERE rowid = ".$this->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->client = $newclient; @@ -1667,10 +1667,10 @@ public function set_remise_client($remise, $note, User $user) global $conf, $langs; // Parameter cleaning - $note=trim($note); - if (! $note) + $note = trim($note); + if (!$note) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NoteReason")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NoteReason")); return -2; } @@ -1680,33 +1680,33 @@ public function set_remise_client($remise, $note, User $user) { $this->db->begin(); - $now=dol_now(); + $now = dol_now(); // Position current discount $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; - $sql.= " SET remise_client = '".$this->db->escape($remise)."'"; - $sql.= " WHERE rowid = " . $this->id; - $resql=$this->db->query($sql); - if (! $resql) + $sql .= " SET remise_client = '".$this->db->escape($remise)."'"; + $sql .= " WHERE rowid = ".$this->id; + $resql = $this->db->query($sql); + if (!$resql) { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } // Writes trace in discount history $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise"; - $sql.= " (entity, datec, fk_soc, remise_client, note, fk_user_author)"; - $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; - $sql.= " '".$this->db->escape($note)."',"; - $sql.= " ".$user->id; - $sql.= ")"; - - $resql=$this->db->query($sql); - if (! $resql) + $sql .= " (entity, datec, fk_soc, remise_client, note, fk_user_author)"; + $sql .= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; + $sql .= " '".$this->db->escape($note)."',"; + $sql .= " ".$user->id; + $sql .= ")"; + + $resql = $this->db->query($sql); + if (!$resql) { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } @@ -1730,10 +1730,10 @@ public function set_remise_supplier($remise, $note, User $user) global $conf, $langs; // Parameter cleaning - $note=trim($note); - if (! $note) + $note = trim($note); + if (!$note) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NoteReason")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NoteReason")); return -2; } @@ -1743,33 +1743,33 @@ public function set_remise_supplier($remise, $note, User $user) { $this->db->begin(); - $now=dol_now(); + $now = dol_now(); // Position current discount $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; - $sql.= " SET remise_supplier = '".$this->db->escape($remise)."'"; - $sql.= " WHERE rowid = " . $this->id; - $resql=$this->db->query($sql); - if (! $resql) + $sql .= " SET remise_supplier = '".$this->db->escape($remise)."'"; + $sql .= " WHERE rowid = ".$this->id; + $resql = $this->db->query($sql); + if (!$resql) { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } // Writes trace in discount history $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_supplier"; - $sql.= " (entity, datec, fk_soc, remise_supplier, note, fk_user_author)"; - $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; - $sql.= " '".$this->db->escape($note)."',"; - $sql.= " ".$user->id; - $sql.= ")"; - - $resql=$this->db->query($sql); - if (! $resql) + $sql .= " (entity, datec, fk_soc, remise_supplier, note, fk_user_author)"; + $sql .= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; + $sql .= " '".$this->db->escape($note)."',"; + $sql .= " ".$user->id; + $sql .= ")"; + + $resql = $this->db->query($sql); + if (!$resql) { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } @@ -1799,14 +1799,14 @@ public function set_remise_except($remise, User $user, $desc, $tva_tx = 0, $disc $desc = trim($desc); // Check parameters - if (! $remise > 0) + if (!$remise > 0) { - $this->error=$langs->trans("ErrorWrongValueForParameter", "1"); + $this->error = $langs->trans("ErrorWrongValueForParameter", "1"); return -1; } - if (! $desc) + if (!$desc) { - $this->error=$langs->trans("ErrorWrongValueForParameter", "3"); + $this->error = $langs->trans("ErrorWrongValueForParameter", "3"); return -2; } @@ -1815,25 +1815,25 @@ public function set_remise_except($remise, User $user, $desc, $tva_tx = 0, $disc require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($this->db); - $discount->fk_soc=$this->id; + $discount->fk_soc = $this->id; - $discount->discount_type=$discount_type; + $discount->discount_type = $discount_type; - $discount->amount_ht=$discount->multicurrency_amount_ht=price2num($remise, 'MT'); - $discount->amount_tva=$discount->multicurrency_amount_tva=price2num($remise*$tva_tx/100, 'MT'); - $discount->amount_ttc=$discount->multicurrency_amount_ttc=price2num($discount->amount_ht+$discount->amount_tva, 'MT'); + $discount->amount_ht = $discount->multicurrency_amount_ht = price2num($remise, 'MT'); + $discount->amount_tva = $discount->multicurrency_amount_tva = price2num($remise * $tva_tx / 100, 'MT'); + $discount->amount_ttc = $discount->multicurrency_amount_ttc = price2num($discount->amount_ht + $discount->amount_tva, 'MT'); - $discount->tva_tx=price2num($tva_tx, 'MT'); - $discount->description=$desc; + $discount->tva_tx = price2num($tva_tx, 'MT'); + $discount->description = $desc; - $result=$discount->create($user); + $result = $discount->create($user); if ($result > 0) { return $result; } else { - $this->error=$discount->error; + $this->error = $discount->error; return -3; } } @@ -1853,15 +1853,15 @@ public function getAvailableDiscounts($user = '', $filter = '', $maxvalue = 0, $ { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - $discountstatic=new DiscountAbsolute($this->db); - $result=$discountstatic->getAvailableDiscounts($this, $user, $filter, $maxvalue, $discount_type); + $discountstatic = new DiscountAbsolute($this->db); + $result = $discountstatic->getAvailableDiscounts($this, $user, $filter, $maxvalue, $discount_type); if ($result >= 0) { return $result; } else { - $this->error=$discountstatic->error; + $this->error = $discountstatic->error; return -1; } } @@ -1877,47 +1877,47 @@ public function getSalesRepresentatives(User $user, $mode = 0) { global $conf; - $reparray=array(); + $reparray = array(); $sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.office_phone, u.job, u.email, u.statut, u.entity, u.photo"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + $sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u"; + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE ((ug.fk_user = sc.fk_user"; - $sql.= " AND ug.entity = ".$conf->entity.")"; - $sql.= " OR u.admin = 1)"; + $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " WHERE ((ug.fk_user = sc.fk_user"; + $sql .= " AND ug.entity = ".$conf->entity.")"; + $sql .= " OR u.admin = 1)"; } else - $sql.= " WHERE entity in (0, ".$conf->entity.")"; + $sql .= " WHERE entity in (0, ".$conf->entity.")"; - $sql.= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".$this->id; + $sql .= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".$this->id; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); if (empty($mode)) { - $reparray[$i]['id']=$obj->rowid; - $reparray[$i]['lastname']=$obj->lastname; - $reparray[$i]['firstname']=$obj->firstname; - $reparray[$i]['email']=$obj->email; - $reparray[$i]['phone']=$obj->office_phone; - $reparray[$i]['job']=$obj->job; - $reparray[$i]['statut']=$obj->statut; - $reparray[$i]['entity']=$obj->entity; - $reparray[$i]['login']=$obj->login; - $reparray[$i]['photo']=$obj->photo; + $reparray[$i]['id'] = $obj->rowid; + $reparray[$i]['lastname'] = $obj->lastname; + $reparray[$i]['firstname'] = $obj->firstname; + $reparray[$i]['email'] = $obj->email; + $reparray[$i]['phone'] = $obj->office_phone; + $reparray[$i]['job'] = $obj->job; + $reparray[$i]['statut'] = $obj->statut; + $reparray[$i]['entity'] = $obj->entity; + $reparray[$i]['login'] = $obj->login; + $reparray[$i]['photo'] = $obj->photo; } else { - $reparray[]=$obj->rowid; + $reparray[] = $obj->rowid; } $i++; } @@ -1942,13 +1942,13 @@ public function set_price_level($price_level, User $user) // phpcs:enable if ($this->id) { - $now=dol_now(); + $now = dol_now(); $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; $sql .= " SET price_level = '".$this->db->escape($price_level)."'"; - $sql .= " WHERE rowid = " . $this->id; + $sql .= " WHERE rowid = ".$this->id; - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { dol_print_error($this->db); return -1; @@ -1958,7 +1958,7 @@ public function set_price_level($price_level, User $user) $sql .= " (datec, fk_soc, price_level, fk_user_author)"; $sql .= " VALUES ('".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($price_level)."', ".$user->id.")"; - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { dol_print_error($this->db); return -1; @@ -1979,51 +1979,51 @@ public function set_price_level($price_level, User $user) public function add_commercial(User $user, $commid) { // phpcs:enable - $error=0; + $error = 0; if ($this->id > 0 && $commid > 0) { $this->db->begin(); - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux"; - $sql.= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; + $sql .= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { dol_syslog(get_class($this)."::add_commercial Error ".$this->db->lasterror()); $error++; } } - if (! $error) + if (!$error) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_commerciaux"; - $sql.= " (fk_soc, fk_user)"; - $sql.= " VALUES (".$this->id.", ".$commid.")"; + $sql .= " (fk_soc, fk_user)"; + $sql .= " VALUES (".$this->id.", ".$commid.")"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { dol_syslog(get_class($this)."::add_commercial Error ".$this->db->lasterror()); $error++; } } - if (! $error) + if (!$error) { - $this->context=array('commercial_modified'=>$commid); + $this->context = array('commercial_modified'=>$commid); - $result=$this->call_trigger('COMPANY_LINK_SALE_REPRESENTATIVE', $user); + $result = $this->call_trigger('COMPANY_LINK_SALE_REPRESENTATIVE', $user); if ($result < 0) { $error++; } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -2049,10 +2049,10 @@ public function add_commercial(User $user, $commid) public function del_commercial(User $user, $commid) { // phpcs:enable - $error=0; - $this->context=array('commercial_modified'=>$commid); + $error = 0; + $this->context = array('commercial_modified'=>$commid); - $result=$this->call_trigger('COMPANY_UNLINK_SALE_REPRESENTATIVE', $user); + $result = $this->call_trigger('COMPANY_UNLINK_SALE_REPRESENTATIVE', $user); if ($result < 0) $error++; if ($this->id > 0 && $commid > 0) @@ -2060,7 +2060,7 @@ public function del_commercial(User $user, $commid) $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux "; $sql .= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; - if (! $this->db->query($sql) ) + if (!$this->db->query($sql)) { dol_syslog(get_class($this)."::del_commercial Erreur"); } @@ -2082,160 +2082,160 @@ public function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $notooltip { global $conf, $langs, $hookmanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $name=$this->name?$this->name:$this->nom; + $name = $this->name ? $this->name : $this->nom; - if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)){ + if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)) { if (empty($option) && $this->client > 0) $option = 'customer'; if (empty($option) && $this->fournisseur > 0) $option = 'supplier'; } - if (! empty($conf->global->SOCIETE_ADD_REF_IN_LIST) && (!empty($withpicto))) + if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST) && (!empty($withpicto))) { $code = ''; - if (($this->client) && (! empty($this->code_client)) + if (($this->client) && (!empty($this->code_client)) && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 || $conf->global->SOCIETE_ADD_REF_IN_LIST == 2 ) ) { - $code = $this->code_client . ' - '; + $code = $this->code_client.' - '; } - if (($this->fournisseur) && (! empty($this->code_fournisseur)) - && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 || $conf->global->SOCIETE_ADD_REF_IN_LIST == 3 + if (($this->fournisseur) && (!empty($this->code_fournisseur)) + && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 || $conf->global->SOCIETE_ADD_REF_IN_LIST == 3 ) ) { - $code .= $this->code_fournisseur . ' - '; + $code .= $this->code_fournisseur.' - '; } if ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1) { - $name =$code.' '.$name; + $name = $code.' '.$name; } else { - $name =$code; + $name = $code; } } if (!empty($this->name_alias)) $name .= ' ('.$this->name_alias.')'; - $result=''; $label=''; - $linkstart=''; $linkend=''; + $result = ''; $label = ''; + $linkstart = ''; $linkend = ''; - if (! empty($this->logo) && class_exists('Form')) + if (!empty($this->logo) && class_exists('Form')) { - $label.= '
'; - $label.= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. - $label.= '
'; + $label .= '
'; + $label .= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. + $label .= '
'; } - elseif (! empty($this->logo_squarred) && class_exists('Form')) + elseif (!empty($this->logo_squarred) && class_exists('Form')) { /*$label.= '
'; $label.= Form::showphoto('societe', $this, 0, 40, 0, 'photowithmargin', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip. $label.= '
';*/ } - $label.= '
'; + $label .= '
'; if ($option == 'customer' || $option == 'compta' || $option == 'category' || $option == 'category_supplier') { - $label.= '' . $langs->trans("ShowCustomer") . ''; + $label .= ''.$langs->trans("ShowCustomer").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowProspect").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowSupplier").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowAgenda").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowProject").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowMargin").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowContacts").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowBan").''; $linkstart = ''; + $label .= ''.$langs->trans("ShowCompany").''; $linkstart = 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowCompany"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowCompany"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip refurl"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip refurl"'; /* $hookmanager->initHooks(array('thirdpartydao')); @@ -2244,25 +2244,25 @@ public function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $notooltip if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ } - $linkstart.=$linkclose.'>'; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; global $user; - if (! $user->rights->societe->client->voir && $user->socid > 0 && $this->id != $user->socid) + if (!$user->rights->societe->client->voir && $user->socid > 0 && $this->id != $user->socid) { - $linkstart=''; - $linkend=''; + $linkstart = ''; + $linkend = ''; } - $result.=$linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valignmiddle"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.=($maxlen?dol_trunc($name, $maxlen):$name); - $result.=$linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valignmiddle"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($name, $maxlen) : $name); + $result .= $linkend; global $action; $hookmanager->initHooks(array('thirdpartydao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -2323,8 +2323,8 @@ public function thirdparty_and_contact_email_array($addthirdparty = 0) $contact_emails = $this->contact_property_array('email', 1); if ($this->email && $addthirdparty) { - if (empty($this->name)) $this->name=$this->nom; - $contact_emails['thirdparty']=$langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name, 16)." <".$this->email.">"; + if (empty($this->name)) $this->name = $this->nom; + $contact_emails['thirdparty'] = $langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name, 16)." <".$this->email.">"; } //var_dump($contact_emails) return $contact_emails; @@ -2343,11 +2343,11 @@ public function thirdparty_and_contact_phone_array() $contact_phone = $this->contact_property_array('mobile'); - if (! empty($this->phone)) // If a phone of thirdparty is defined, we add it ot mobile of contacts + if (!empty($this->phone)) // If a phone of thirdparty is defined, we add it ot mobile of contacts { - if (empty($this->name)) $this->name=$this->nom; + if (empty($this->name)) $this->name = $this->nom; // TODO: Tester si tel non deja present dans tableau contact - $contact_phone['thirdparty']=$langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name, 16)." <".$this->phone.">"; + $contact_phone['thirdparty'] = $langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name, 16)." <".$this->phone.">"; } return $contact_phone; } @@ -2369,46 +2369,46 @@ public function contact_property_array($mode = 'email', $hidedisabled = 0) $sql = "SELECT rowid, email, statut, phone_mobile, lastname, poste, firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople"; - $sql.= " WHERE fk_soc = ".$this->id; - $sql.= " ORDER BY lastname, firstname"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople"; + $sql .= " WHERE fk_soc = ".$this->id; + $sql .= " ORDER BY lastname, firstname"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $nump = $this->db->num_rows($resql); if ($nump) { - $sepa="("; $sepb=")"; + $sepa = "("; $sepb = ")"; if ($mode == 'email') { //$sepa="<"; $sepb=">"; - $sepa="<"; $sepb=">"; + $sepa = "<"; $sepb = ">"; } $i = 0; while ($i < $nump) { $obj = $this->db->fetch_object($resql); - if ($mode == 'email') $property=$obj->email; - elseif ($mode == 'mobile') $property=$obj->phone_mobile; - else $property=$obj->$mode; + if ($mode == 'email') $property = $obj->email; + elseif ($mode == 'mobile') $property = $obj->phone_mobile; + else $property = $obj->$mode; // Show all contact. If hidedisabled is 1, showonly contacts with status = 1 if ($obj->statut == 1 || empty($hidedisabled)) { if (empty($property)) { - if ($mode == 'email') $property=$langs->transnoentitiesnoconv("NoEMail"); - elseif ($mode == 'mobile') $property=$langs->transnoentitiesnoconv("NoMobilePhone"); + if ($mode == 'email') $property = $langs->transnoentitiesnoconv("NoEMail"); + elseif ($mode == 'mobile') $property = $langs->transnoentitiesnoconv("NoMobilePhone"); } if (!empty($obj->poste)) { - $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname, $obj->lastname)).($obj->poste?" - ".$obj->poste:"").(($mode != 'poste' && $property)?" ".$sepa.$property.$sepb:''); + $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname, $obj->lastname)).($obj->poste ? " - ".$obj->poste : "").(($mode != 'poste' && $property) ? " ".$sepa.$property.$sepb : ''); } else { - $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname, $obj->lastname)).(($mode != 'poste' && $property)?" ".$sepa.$property.$sepb:''); + $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname, $obj->lastname)).(($mode != 'poste' && $property) ? " ".$sepa.$property.$sepb : ''); } } $i++; @@ -2435,7 +2435,7 @@ public function contact_array() $contacts = array(); $sql = "SELECT rowid, lastname, firstname FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = ".$this->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $nump = $this->db->num_rows($resql); @@ -2466,11 +2466,11 @@ public function contact_array() public function contact_array_objects() { // phpcs:enable - require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contacts = array(); $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = ".$this->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $nump = $this->db->num_rows($resql); @@ -2505,15 +2505,15 @@ public function contact_array_objects() public function contact_get_property($rowid, $mode) { // phpcs:enable - $contact_property=''; + $contact_property = ''; if (empty($rowid)) return ''; $sql = "SELECT rowid, email, phone_mobile, lastname, firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople"; - $sql.= " WHERE rowid = '".$rowid."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople"; + $sql .= " WHERE rowid = '".$rowid."'"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $nump = $this->db->num_rows($resql); @@ -2544,7 +2544,7 @@ public function contact_get_property($rowid, $mode) public function display_rib($mode = 'label') { // phpcs:enable - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $bac = new CompanyBankAccount($this->db); $bac->fetch(0, $this->id); @@ -2557,7 +2557,7 @@ public function display_rib($mode = 'label') { if (empty($bac->rum)) { - require_once DOL_DOCUMENT_ROOT . '/compta/prelevement/class/bonprelevement.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; $prelevement = new BonPrelevement($this->db); $bac->fetch_thirdparty(); $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id); @@ -2581,7 +2581,7 @@ public function display_rib($mode = 'label') public function get_all_rib() { // phpcs:enable - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib WHERE type='ban' AND fk_soc = ".$this->id; $result = $this->db->query($sql); if (!$result) { @@ -2615,14 +2615,14 @@ public function get_codeclient($objsoc = 0, $type = 0) { // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON)) { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $mod = new $module(); @@ -2647,14 +2647,14 @@ public function get_codefournisseur($objsoc = 0, $type = 1) { // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON)) { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $mod = new $module(); @@ -2676,23 +2676,23 @@ public function codeclient_modifiable() { // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON)) { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $mod = new $module(); dol_syslog(get_class($this)."::codeclient_modifiable code_client=".$this->code_client." module=".$module); - if ($mod->code_modifiable_null && ! $this->code_client) return 1; + if ($mod->code_modifiable_null && !$this->code_client) return 1; if ($mod->code_modifiable_invalide && $this->check_codeclient() < 0) return 1; - if ($mod->code_modifiable) return 1; // A mettre en dernier + if ($mod->code_modifiable) return 1; // A mettre en dernier return 0; } else @@ -2712,23 +2712,23 @@ public function codefournisseur_modifiable() { // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON)) { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } $mod = new $module(); dol_syslog(get_class($this)."::codefournisseur_modifiable code_founisseur=".$this->code_fournisseur." module=".$module); - if ($mod->code_modifiable_null && ! $this->code_fournisseur) return 1; + if ($mod->code_modifiable_null && !$this->code_fournisseur) return 1; if ($mod->code_modifiable_invalide && $this->check_codefournisseur() < 0) return 1; - if ($mod->code_modifiable) return 1; // A mettre en dernier + if ($mod->code_modifiable) return 1; // A mettre en dernier return 0; } else @@ -2752,14 +2752,14 @@ public function check_codeclient() { // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON)) { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } @@ -2789,14 +2789,14 @@ public function check_codefournisseur() { // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + if (!empty($conf->global->SOCIETE_CODECLIENT_ADDON)) { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + $module = $conf->global->SOCIETE_CODECLIENT_ADDON; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$module.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) break; } @@ -2826,13 +2826,13 @@ public function get_codecompta($type) // phpcs:enable global $conf; - if (! empty($conf->global->SOCIETE_CODECOMPTA_ADDON)) + if (!empty($conf->global->SOCIETE_CODECOMPTA_ADDON)) { - $res=false; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + $res = false; + $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res=dol_include_once($dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.'.php'); + $res = dol_include_once($dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.'.php'); if ($res) break; } @@ -2877,10 +2877,10 @@ public function set_parent($id) if ($this->id) { $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql.= " SET parent = ".($id > 0 ? $id : "null"); - $sql.= " WHERE rowid = " . $this->id; + $sql .= " SET parent = ".($id > 0 ? $id : "null"); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this).'::set_parent', LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->parent = $id; @@ -2906,28 +2906,28 @@ public function id_prof_verifiable($idprof) // phpcs:enable global $conf; - switch($idprof) + switch ($idprof) { case 1: - $ret=(!$conf->global->SOCIETE_IDPROF1_UNIQUE?false:true); + $ret = (!$conf->global->SOCIETE_IDPROF1_UNIQUE ?false:true); break; case 2: - $ret=(!$conf->global->SOCIETE_IDPROF2_UNIQUE?false:true); + $ret = (!$conf->global->SOCIETE_IDPROF2_UNIQUE ?false:true); break; case 3: - $ret=(!$conf->global->SOCIETE_IDPROF3_UNIQUE?false:true); + $ret = (!$conf->global->SOCIETE_IDPROF3_UNIQUE ?false:true); break; case 4: - $ret=(!$conf->global->SOCIETE_IDPROF4_UNIQUE?false:true); + $ret = (!$conf->global->SOCIETE_IDPROF4_UNIQUE ?false:true); break; case 5: - $ret=(!$conf->global->SOCIETE_IDPROF5_UNIQUE?false:true); + $ret = (!$conf->global->SOCIETE_IDPROF5_UNIQUE ?false:true); break; case 6: - $ret=(!$conf->global->SOCIETE_IDPROF6_UNIQUE?false:true); + $ret = (!$conf->global->SOCIETE_IDPROF6_UNIQUE ?false:true); break; default: - $ret=false; + $ret = false; } return $ret; @@ -2947,35 +2947,35 @@ public function id_prof_exists($idprof, $value, $socid = 0) // phpcs:enable $field = $idprof; - switch($idprof) // For backward compatibility + switch ($idprof) // For backward compatibility { case '1': case 'idprof1': - $field="siren"; + $field = "siren"; break; case '2': case 'idprof2': - $field="siret"; + $field = "siret"; break; case '3': case 'idprof3': - $field="ape"; + $field = "ape"; break; case '4': case 'idprof4': - $field="idprof4"; + $field = "idprof4"; break; case '5': - $field="idprof5"; + $field = "idprof5"; break; case '6': - $field="idprof6"; + $field = "idprof6"; break; } //Verify duplicate entries - $sql = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."' AND entity IN (".getEntity('societe').")"; - if($socid) $sql .= " AND rowid <> ".$socid; + $sql = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."' AND entity IN (".getEntity('societe').")"; + if ($socid) $sql .= " AND rowid <> ".$socid; $resql = $this->db->query($sql); if ($resql) { @@ -3007,15 +3007,15 @@ public function id_prof_check($idprof, $soc) // phpcs:enable global $conf; - $ok=1; + $ok = 1; - if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return 1; + if (!empty($conf->global->MAIN_DISABLEPROFIDRULES)) return 1; // Check SIREN if country FR if ($idprof == 1 && $soc->country_code == 'FR') { - $chaine=trim($this->idprof1); - $chaine=preg_replace('/(\s)/', '', $chaine); + $chaine = trim($this->idprof1); + $chaine = preg_replace('/(\s)/', '', $chaine); if (!is_numeric($chaine)) return -1; if (dol_strlen($chaine) != 9) return -1; @@ -3025,7 +3025,7 @@ public function id_prof_check($idprof, $soc) // on double sa valeur et si cette dernière est supérieure à 9, on lui retranche 9 // on ajoute cette valeur à la somme totale - for ($index = 0; $index < 9; $index ++) + for ($index = 0; $index < 9; $index++) { $number = (int) $chaine[$index]; if (($index % 2) != 0) { if (($number *= 2) > 9) $number -= 9; } @@ -3039,8 +3039,8 @@ public function id_prof_check($idprof, $soc) // Verifie SIRET si pays FR if ($idprof == 2 && $soc->country_code == 'FR') { - $chaine=trim($this->idprof2); - $chaine=preg_replace('/(\s)/', '', $chaine); + $chaine = trim($this->idprof2); + $chaine = preg_replace('/(\s)/', '', $chaine); if (!is_numeric($chaine)) return -1; if (dol_strlen($chaine) != 14) return -1; @@ -3050,7 +3050,7 @@ public function id_prof_check($idprof, $soc) // on double sa valeur et si cette dernière est supérieure à 9, on lui retranche 9 // on ajoute cette valeur à la somme totale - for ($index = 0; $index < 14; $index ++) + for ($index = 0; $index < 14; $index++) { $number = (int) $chaine[$index]; if (($index % 2) == 0) { if (($number *= 2) > 9) $number -= 9; } @@ -3065,8 +3065,8 @@ public function id_prof_check($idprof, $soc) //Returns: 1 if NIF ok, 2 if CIF ok, 3 if NIE ok, -1 if NIF bad, -2 if CIF bad, -3 if NIE bad, 0 if unexpected bad if ($idprof == 1 && $soc->country_code == 'ES') { - $string=trim($this->idprof1); - $string=preg_replace('/(\s)/', '', $string); + $string = trim($this->idprof1); + $string = preg_replace('/(\s)/', '', $string); $string = strtoupper($string); //Check format @@ -3074,7 +3074,7 @@ public function id_prof_check($idprof, $soc) return 0; $num = array(); - for ($i = 0; $i < 9; $i ++) + for ($i = 0; $i < 9; $i++) { $num[$i] = substr($string, $i, 1); } @@ -3115,7 +3115,7 @@ public function id_prof_check($idprof, $soc) //Check NIE XYZ if (preg_match('/^[XYZ]{1}/', $string)) - if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) + if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X', 'Y', 'Z'), array('0', '1', '2'), $string), 0, 8) % 23, 1)) return 3; else return -3; @@ -3128,10 +3128,10 @@ public function id_prof_check($idprof, $soc) //Returns: 1 if NIF ok, -1 if NIF bad, 0 if unexpected bad if ($idprof == 1 && $soc->country_code == 'PT') { - $string=trim($this->idprof1); - $string=preg_replace('/(\s)/', '', $string); + $string = trim($this->idprof1); + $string = preg_replace('/(\s)/', '', $string); - for ($i = 0; $i < 9; $i ++) { + for ($i = 0; $i < 9; $i++) { $num[$i] = substr($string, $i, 1); } @@ -3159,35 +3159,35 @@ public function id_prof_check($idprof, $soc) public function id_prof_url($idprof, $thirdparty) { // phpcs:enable - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; - $url=''; + $url = ''; $action = ''; $hookmanager->initHooks(array('idprofurl')); - $parameters=array('idprof'=>$idprof, 'company'=>$thirdparty); - $reshook=$hookmanager->executeHooks('getIdProfUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('idprof'=>$idprof, 'company'=>$thirdparty); + $reshook = $hookmanager->executeHooks('getIdProfUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { - if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) { + if (!empty($conf->global->MAIN_DISABLEPROFIDRULES)) { return ''; } // TODO Move links to validate professional ID into a dictionary table "country" + "link" $strippedIdProf1 = str_replace(' ', '', $thirdparty->idprof1); if ($idprof == 1 && $thirdparty->country_code == 'FR') { - $url='http://www.societe.com/cgi-bin/search?champs='.$strippedIdProf1; // See also http://avis-situation-sirene.insee.fr/ + $url = 'http://www.societe.com/cgi-bin/search?champs='.$strippedIdProf1; // See also http://avis-situation-sirene.insee.fr/ } if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) { - $url='https://beta.companieshouse.gov.uk/company/'.$strippedIdProf1; + $url = 'https://beta.companieshouse.gov.uk/company/'.$strippedIdProf1; } if ($idprof == 1 && $thirdparty->country_code == 'ES') { - $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$strippedIdProf1; + $url = 'http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$strippedIdProf1; } if ($idprof == 1 && $thirdparty->country_code == 'IN') { - $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$strippedIdProf1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; + $url = 'http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$strippedIdProf1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; } if ($idprof == 1 && $thirdparty->country_code == 'PT') { - $url='http://www.nif.pt/'.$strippedIdProf1; + $url = 'http://www.nif.pt/'.$strippedIdProf1; } if ($url) { @@ -3210,7 +3210,7 @@ public function id_prof_url($idprof, $thirdparty) public function has_projects() { // phpcs:enable - $sql = 'SELECT COUNT(*) as numproj FROM '.MAIN_DB_PREFIX.'projet WHERE fk_soc = ' . $this->id; + $sql = 'SELECT COUNT(*) as numproj FROM '.MAIN_DB_PREFIX.'projet WHERE fk_soc = '.$this->id; $resql = $this->db->query($sql); if ($resql) { @@ -3236,11 +3236,11 @@ public function has_projects() public function info($id) { $sql = "SELECT s.rowid, s.nom as name, s.datec as date_creation, tms as date_modification,"; - $sql.= " fk_user_creat, fk_user_modif"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.rowid = ".$id; + $sql .= " fk_user_creat, fk_user_modif"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.rowid = ".$id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -3252,7 +3252,7 @@ public function info($id) if ($obj->fk_user_creat) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_creat); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_modif) { @@ -3261,7 +3261,7 @@ public function info($id) $this->user_modification = $muser; } - $this->ref = $obj->name; + $this->ref = $obj->name; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_modification = $this->db->jdate($obj->date_modification); } @@ -3284,14 +3284,14 @@ public function isACompany() global $conf; // Define if third party is treated as company (or not) when nature is unknown - $isacompany=empty($conf->global->MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES)?0:1; // 0 by default - if (! empty($this->tva_intra)) { + $isacompany = empty($conf->global->MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES) ? 0 : 1; // 0 by default + if (!empty($this->tva_intra)) { $isacompany = 1; } - elseif (! empty($this->idprof1) || ! empty($this->idprof2) || ! empty($this->idprof3) || ! empty($this->idprof4) || ! empty($this->idprof5) || ! empty($this->idprof6)) { + elseif (!empty($this->idprof1) || !empty($this->idprof2) || !empty($this->idprof3) || !empty($this->idprof4) || !empty($this->idprof5) || !empty($this->idprof6)) { $isacompany = 1; } - elseif (! empty($this->typent_code) && $this->typent_code != 'TE_UNKNOWN') + elseif (!empty($this->typent_code) && $this->typent_code != 'TE_UNKNOWN') { // TODO Add a field is_a_company into dictionary if (preg_match('/^TE_PRIVATE/', $this->typent_code)) $isacompany = 0; @@ -3323,13 +3323,13 @@ public function LoadSupplierCateg() // phpcs:enable $this->SupplierCategories = array(); $sql = "SELECT rowid, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE type = ".Categorie::TYPE_SUPPLIER; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie"; + $sql .= " WHERE type = ".Categorie::TYPE_SUPPLIER; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj = $this->db->fetch_object($resql) ) + while ($obj = $this->db->fetch_object($resql)) { $this->SupplierCategories[$obj->rowid] = $obj->label; } @@ -3354,9 +3354,9 @@ public function AddFournisseurInCategory($categorie_id) if ($categorie_id > 0 && $this->id > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_fournisseur (fk_categorie, fk_soc) "; - $sql.= " VALUES (".$categorie_id.", ".$this->id.")"; + $sql .= " VALUES (".$categorie_id.", ".$this->id.")"; - if ($resql=$this->db->query($sql)) return 0; + if ($resql = $this->db->query($sql)) return 0; } else { @@ -3379,43 +3379,43 @@ public function AddFournisseurInCategory($categorie_id) public function create_from_member(Adherent $member, $socname = '', $socalias = '', $customercode = '') { // phpcs:enable - global $user,$langs; + global $user, $langs; dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG); - $name = $socname?$socname:$member->societe; - if (empty($name)) $name=$member->getFullName($langs); + $name = $socname ? $socname : $member->societe; + if (empty($name)) $name = $member->getFullName($langs); - $alias = $socalias?$socalias:''; + $alias = $socalias ? $socalias : ''; // Positionne parametres - $this->nom=$name; // TODO deprecated - $this->name=$name; - $this->name_alias=$alias; - $this->address=$member->address; - $this->zip=$member->zip; - $this->town=$member->town; - $this->country_code=$member->country_code; - $this->country_id=$member->country_id; - $this->phone=$member->phone; // Prof phone - $this->email=$member->email; + $this->nom = $name; // TODO deprecated + $this->name = $name; + $this->name_alias = $alias; + $this->address = $member->address; + $this->zip = $member->zip; + $this->town = $member->town; + $this->country_code = $member->country_code; + $this->country_id = $member->country_id; + $this->phone = $member->phone; // Prof phone + $this->email = $member->email; $this->socialnetworks = $member->socialnetworks; - $this->client = 1; // A member is a customer by default - $this->code_client = ($customercode?$customercode:-1); + $this->client = 1; // A member is a customer by default + $this->code_client = ($customercode ? $customercode : -1); $this->code_fournisseur = -1; $this->db->begin(); // Cree et positionne $this->id - $result=$this->create($user); + $result = $this->create($user); if ($result >= 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql.= " SET fk_soc=".$this->id; - $sql.= " WHERE rowid=".$member->id; + $sql .= " SET fk_soc=".$this->id; + $sql .= " WHERE rowid=".$member->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->db->commit(); @@ -3423,7 +3423,7 @@ public function create_from_member(Adherent $member, $socname = '', $socalias = } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -3449,96 +3449,96 @@ public function setMysoc(Conf $conf) { global $langs; - $this->id=0; - $this->name=empty($conf->global->MAIN_INFO_SOCIETE_NOM)?'':$conf->global->MAIN_INFO_SOCIETE_NOM; - $this->address=empty($conf->global->MAIN_INFO_SOCIETE_ADDRESS)?'':$conf->global->MAIN_INFO_SOCIETE_ADDRESS; - $this->zip=empty($conf->global->MAIN_INFO_SOCIETE_ZIP)?'':$conf->global->MAIN_INFO_SOCIETE_ZIP; - $this->town=empty($conf->global->MAIN_INFO_SOCIETE_TOWN)?'':$conf->global->MAIN_INFO_SOCIETE_TOWN; - $this->region_code=empty($conf->global->MAIN_INFO_SOCIETE_REGION)?'':$conf->global->MAIN_INFO_SOCIETE_REGION; - $this->object=empty($conf->global->MAIN_INFO_SOCIETE_OBJECT)?'':$conf->global->MAIN_INFO_SOCIETE_OBJECT; + $this->id = 0; + $this->name = empty($conf->global->MAIN_INFO_SOCIETE_NOM) ? '' : $conf->global->MAIN_INFO_SOCIETE_NOM; + $this->address = empty($conf->global->MAIN_INFO_SOCIETE_ADDRESS) ? '' : $conf->global->MAIN_INFO_SOCIETE_ADDRESS; + $this->zip = empty($conf->global->MAIN_INFO_SOCIETE_ZIP) ? '' : $conf->global->MAIN_INFO_SOCIETE_ZIP; + $this->town = empty($conf->global->MAIN_INFO_SOCIETE_TOWN) ? '' : $conf->global->MAIN_INFO_SOCIETE_TOWN; + $this->region_code = empty($conf->global->MAIN_INFO_SOCIETE_REGION) ? '' : $conf->global->MAIN_INFO_SOCIETE_REGION; + $this->object = empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? '' : $conf->global->MAIN_INFO_SOCIETE_OBJECT; - $this->note_private=empty($conf->global->MAIN_INFO_SOCIETE_NOTE)?'':$conf->global->MAIN_INFO_SOCIETE_NOTE; + $this->note_private = empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? '' : $conf->global->MAIN_INFO_SOCIETE_NOTE; - $this->nom=$this->name; // deprecated + $this->nom = $this->name; // deprecated // We define country_id, country_code and country - $country_id=$country_code=$country_label=''; - if (! empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) + $country_id = $country_code = $country_label = ''; + if (!empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) { - $tmp=explode(':', $conf->global->MAIN_INFO_SOCIETE_COUNTRY); - $country_id=$tmp[0]; - if (! empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_COUNTRY is "id:code:label" + $tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_COUNTRY); + $country_id = $tmp[0]; + if (!empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_COUNTRY is "id:code:label" { - $country_code=$tmp[1]; - $country_label=$tmp[2]; + $country_code = $tmp[1]; + $country_label = $tmp[2]; } else // For backward compatibility { dol_syslog("Your country setup use an old syntax. Reedit it using setup area.", LOG_WARNING); include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - $country_code=getCountry($country_id, 2, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore - $country_label=getCountry($country_id, 0, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore + $country_code = getCountry($country_id, 2, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore + $country_label = getCountry($country_id, 0, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore } } - $this->country_id=$country_id; - $this->country_code=$country_code; - $this->country=$country_label; - if (is_object($langs)) $this->country=($langs->trans('Country'.$country_code)!='Country'.$country_code)?$langs->trans('Country'.$country_code):$country_label; + $this->country_id = $country_id; + $this->country_code = $country_code; + $this->country = $country_label; + if (is_object($langs)) $this->country = ($langs->trans('Country'.$country_code) != 'Country'.$country_code) ? $langs->trans('Country'.$country_code) : $country_label; //TODO This could be replicated for region but function `getRegion` didn't exist, so I didn't added it. // We define state_id, state_code and state - $state_id=0;$state_code=$state_label=''; - if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE)) + $state_id = 0; $state_code = $state_label = ''; + if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE)) { - $tmp=explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE); - $state_id=$tmp[0]; - if (! empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_STATE is "id:code:label" + $tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE); + $state_id = $tmp[0]; + if (!empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_STATE is "id:code:label" { - $state_code=$tmp[1]; - $state_label=$tmp[2]; + $state_code = $tmp[1]; + $state_label = $tmp[2]; } else // For backward compatibility { dol_syslog("Your state setup use an old syntax. Reedit it using setup area.", LOG_ERR); include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - $state_code=getState($state_id, 2, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore - $state_label=getState($state_id, 0, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore + $state_code = getState($state_id, 2, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore + $state_label = getState($state_id, 0, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore } } - $this->state_id=$state_id; - $this->state_code=$state_code; - $this->state=$state_label; - if (is_object($langs)) $this->state=($langs->trans('State'.$state_code)!='State'.$state_code)?$langs->trans('State'.$state_code):$state_label; + $this->state_id = $state_id; + $this->state_code = $state_code; + $this->state = $state_label; + if (is_object($langs)) $this->state = ($langs->trans('State'.$state_code) != 'State'.$state_code) ? $langs->trans('State'.$state_code) : $state_label; - $this->phone=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL; - $this->fax=empty($conf->global->MAIN_INFO_SOCIETE_FAX)?'':$conf->global->MAIN_INFO_SOCIETE_FAX; - $this->url=empty($conf->global->MAIN_INFO_SOCIETE_WEB)?'':$conf->global->MAIN_INFO_SOCIETE_WEB; + $this->phone = empty($conf->global->MAIN_INFO_SOCIETE_TEL) ? '' : $conf->global->MAIN_INFO_SOCIETE_TEL; + $this->fax = empty($conf->global->MAIN_INFO_SOCIETE_FAX) ? '' : $conf->global->MAIN_INFO_SOCIETE_FAX; + $this->url = empty($conf->global->MAIN_INFO_SOCIETE_WEB) ? '' : $conf->global->MAIN_INFO_SOCIETE_WEB; // Id prof generiques - $this->idprof1=empty($conf->global->MAIN_INFO_SIREN)?'':$conf->global->MAIN_INFO_SIREN; - $this->idprof2=empty($conf->global->MAIN_INFO_SIRET)?'':$conf->global->MAIN_INFO_SIRET; - $this->idprof3=empty($conf->global->MAIN_INFO_APE)?'':$conf->global->MAIN_INFO_APE; - $this->idprof4=empty($conf->global->MAIN_INFO_RCS)?'':$conf->global->MAIN_INFO_RCS; - $this->idprof5=empty($conf->global->MAIN_INFO_PROFID5)?'':$conf->global->MAIN_INFO_PROFID5; - $this->idprof6=empty($conf->global->MAIN_INFO_PROFID6)?'':$conf->global->MAIN_INFO_PROFID6; - $this->tva_intra=empty($conf->global->MAIN_INFO_TVAINTRA)?'':$conf->global->MAIN_INFO_TVAINTRA; // VAT number, not necessarly INTRA. - $this->managers=empty($conf->global->MAIN_INFO_SOCIETE_MANAGERS)?'':$conf->global->MAIN_INFO_SOCIETE_MANAGERS; - $this->capital=empty($conf->global->MAIN_INFO_CAPITAL)?'':$conf->global->MAIN_INFO_CAPITAL; - $this->forme_juridique_code=empty($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE)?'':$conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE; - $this->email=empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?'':$conf->global->MAIN_INFO_SOCIETE_MAIL; - $this->default_lang = (empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT); - $this->logo=empty($conf->global->MAIN_INFO_SOCIETE_LOGO)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO; - $this->logo_small=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL; - $this->logo_mini=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; - $this->logo_squarred=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED; - $this->logo_squarred_small=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL; - $this->logo_squarred_mini=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI; + $this->idprof1 = empty($conf->global->MAIN_INFO_SIREN) ? '' : $conf->global->MAIN_INFO_SIREN; + $this->idprof2 = empty($conf->global->MAIN_INFO_SIRET) ? '' : $conf->global->MAIN_INFO_SIRET; + $this->idprof3 = empty($conf->global->MAIN_INFO_APE) ? '' : $conf->global->MAIN_INFO_APE; + $this->idprof4 = empty($conf->global->MAIN_INFO_RCS) ? '' : $conf->global->MAIN_INFO_RCS; + $this->idprof5 = empty($conf->global->MAIN_INFO_PROFID5) ? '' : $conf->global->MAIN_INFO_PROFID5; + $this->idprof6 = empty($conf->global->MAIN_INFO_PROFID6) ? '' : $conf->global->MAIN_INFO_PROFID6; + $this->tva_intra = empty($conf->global->MAIN_INFO_TVAINTRA) ? '' : $conf->global->MAIN_INFO_TVAINTRA; // VAT number, not necessarly INTRA. + $this->managers = empty($conf->global->MAIN_INFO_SOCIETE_MANAGERS) ? '' : $conf->global->MAIN_INFO_SOCIETE_MANAGERS; + $this->capital = empty($conf->global->MAIN_INFO_CAPITAL) ? '' : $conf->global->MAIN_INFO_CAPITAL; + $this->forme_juridique_code = empty($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE) ? '' : $conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE; + $this->email = empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? '' : $conf->global->MAIN_INFO_SOCIETE_MAIL; + $this->default_lang = (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT); + $this->logo = empty($conf->global->MAIN_INFO_SOCIETE_LOGO) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO; + $this->logo_small = empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL; + $this->logo_mini = empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; + $this->logo_squarred = empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED; + $this->logo_squarred_small = empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL; + $this->logo_squarred_mini = empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI; // Define if company use vat or not - $this->tva_assuj=$conf->global->FACTURE_TVAOPTION; + $this->tva_assuj = $conf->global->FACTURE_TVAOPTION; // Define if company use local taxes - $this->localtax1_assuj=((isset($conf->global->FACTURE_LOCAL_TAX1_OPTION) && ($conf->global->FACTURE_LOCAL_TAX1_OPTION=='1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on'))?1:0); - $this->localtax2_assuj=((isset($conf->global->FACTURE_LOCAL_TAX2_OPTION) && ($conf->global->FACTURE_LOCAL_TAX2_OPTION=='1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on'))?1:0); + $this->localtax1_assuj = ((isset($conf->global->FACTURE_LOCAL_TAX1_OPTION) && ($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on')) ? 1 : 0); + $this->localtax2_assuj = ((isset($conf->global->FACTURE_LOCAL_TAX2_OPTION) && ($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on')) ? 1 : 0); } /** @@ -3550,51 +3550,51 @@ public function setMysoc(Conf $conf) */ public function initAsSpecimen() { - $now=dol_now(); + $now = dol_now(); // Initialize parameters - $this->id=0; + $this->id = 0; $this->name = 'THIRDPARTY SPECIMEN '.dol_print_date($now, 'dayhourlog'); - $this->nom = $this->name; // For backward compatibility + $this->nom = $this->name; // For backward compatibility $this->ref_ext = 'Ref ext'; - $this->specimen=1; - $this->address='21 jump street'; - $this->zip='99999'; - $this->town='MyTown'; - $this->state_id=1; - $this->state_code='AA'; - $this->state='MyState'; - $this->country_id=1; - $this->country_code='FR'; - $this->email='specimen@specimen.com'; + $this->specimen = 1; + $this->address = '21 jump street'; + $this->zip = '99999'; + $this->town = 'MyTown'; + $this->state_id = 1; + $this->state_code = 'AA'; + $this->state = 'MyState'; + $this->country_id = 1; + $this->country_code = 'FR'; + $this->email = 'specimen@specimen.com'; $this->socialnetworks = array( 'skype' => 'tom.hanson', 'twitter' => 'tomhanson', 'facebook' => 'tomhanson', 'linkedin' => 'tomhanson', ); - $this->url='http://www.specimen.com'; - - $this->phone='0909090901'; - $this->fax='0909090909'; - - $this->code_client='CC-'.dol_print_date($now, 'dayhourlog'); - $this->code_fournisseur='SC-'.dol_print_date($now, 'dayhourlog'); - $this->capital=10000; - $this->client=1; - $this->prospect=1; - $this->fournisseur=1; - $this->tva_assuj=1; - $this->tva_intra='EU1234567'; - $this->note_public='This is a comment (public)'; - $this->note_private='This is a comment (private)'; - - $this->idprof1='idprof1'; - $this->idprof2='idprof2'; - $this->idprof3='idprof3'; - $this->idprof4='idprof4'; - $this->idprof5='idprof5'; - $this->idprof6='idprof6'; + $this->url = 'http://www.specimen.com'; + + $this->phone = '0909090901'; + $this->fax = '0909090909'; + + $this->code_client = 'CC-'.dol_print_date($now, 'dayhourlog'); + $this->code_fournisseur = 'SC-'.dol_print_date($now, 'dayhourlog'); + $this->capital = 10000; + $this->client = 1; + $this->prospect = 1; + $this->fournisseur = 1; + $this->tva_assuj = 1; + $this->tva_intra = 'EU1234567'; + $this->note_public = 'This is a comment (public)'; + $this->note_private = 'This is a comment (private)'; + + $this->idprof1 = 'idprof1'; + $this->idprof2 = 'idprof2'; + $this->idprof3 = 'idprof3'; + $this->idprof4 = 'idprof4'; + $this->idprof5 = 'idprof5'; + $this->idprof6 = 'idprof6'; return 1; } @@ -3615,7 +3615,7 @@ public function useLocalTax($localTaxNum = 0) elseif ($localTaxNum == 2) $sql .= " AND t.localtax2_type <> '0'"; dol_syslog("useLocalTax", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { return ($this->db->num_rows($resql) > 0); @@ -3636,7 +3636,7 @@ public function useNPR() $sql .= " AND t.active = 1 AND t.recuperableonly = 1"; dol_syslog("useNPR", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { return ($this->db->num_rows($resql) > 0); @@ -3657,15 +3657,15 @@ public function useRevenueStamp() $sql .= " AND r.active = 1"; dol_syslog("useRevenueStamp", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - return (($obj->nb > 0)?true:false); + $obj = $this->db->fetch_object($resql); + return (($obj->nb > 0) ?true:false); } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return false; } } @@ -3692,11 +3692,11 @@ public function LibProspLevel($fk_prospectlevel) // phpcs:enable global $langs; - $lib=$langs->trans("ProspectLevel".$fk_prospectlevel); + $lib = $langs->trans("ProspectLevel".$fk_prospectlevel); // If lib not found in language file, we get label from cache/databse if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel)) { - $lib=$langs->getLabelFromKey($this->db, $fk_prospectlevel, 'c_prospectlevel', 'code', 'label'); + $lib = $langs->getLabelFromKey($this->db, $fk_prospectlevel, 'c_prospectlevel', 'code', 'label'); } return $lib; } @@ -3746,10 +3746,10 @@ public function LibProspCommStatut($status, $mode = 0, $label = '') if ($mode == 2) { if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1"); - elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); - elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); - elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); - elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); + elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); + elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); + elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); + elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); else { return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0).' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label); @@ -3758,10 +3758,10 @@ public function LibProspCommStatut($status, $mode = 0, $label = '') if ($mode == 3) { if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1); - elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0); - elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1); - elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2); - elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3); + elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0); + elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1); + elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2); + elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3); else { return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0); @@ -3770,10 +3770,10 @@ public function LibProspCommStatut($status, $mode = 0, $label = '') if ($mode == 4) { if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1"); - elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); - elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); - elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); - elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); + elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); + elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); + elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); + elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); else { return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0).' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label); @@ -3805,11 +3805,11 @@ public function set_OutstandingBill(User $user) */ public function getOutstandingProposals($mode = 'customer') { - $table='propal'; + $table = 'propal'; if ($mode == 'supplier') $table = 'supplier_proposal'; $sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + $sql .= " WHERE fk_soc = ".$this->id; if ($mode == 'supplier') { $sql .= " AND entity IN (".getEntity('supplier_proposal').")"; } else { @@ -3817,21 +3817,21 @@ public function getOutstandingProposals($mode = 'customer') } dol_syslog("getOutstandingProposals", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $outstandingOpened = 0; $outstandingTotal = 0; $outstandingTotalIncTax = 0; - while($obj=$this->db->fetch_object($resql)) { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; + while ($obj = $this->db->fetch_object($resql)) { + $outstandingTotal += $obj->total_ht; + $outstandingTotalIncTax += $obj->total_ttc; if ($obj->fk_statut != 0) // Not a draft { - $outstandingOpened+=$obj->total_ttc; + $outstandingOpened += $obj->total_ttc; } } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } else return array(); @@ -3845,11 +3845,11 @@ public function getOutstandingProposals($mode = 'customer') */ public function getOutstandingOrders($mode = 'customer') { - $table='commande'; + $table = 'commande'; if ($mode == 'supplier') $table = 'commande_fournisseur'; $sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + $sql .= " WHERE fk_soc = ".$this->id; if ($mode == 'supplier') { $sql .= " AND entity IN (".getEntity('supplier_order').")"; } else { @@ -3857,21 +3857,21 @@ public function getOutstandingOrders($mode = 'customer') } dol_syslog("getOutstandingOrders", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $outstandingOpened = 0; $outstandingTotal = 0; $outstandingTotalIncTax = 0; - while($obj=$this->db->fetch_object($resql)) { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; + while ($obj = $this->db->fetch_object($resql)) { + $outstandingTotal += $obj->total_ht; + $outstandingTotalIncTax += $obj->total_ttc; if ($obj->fk_statut != 0) // Not a draft { - $outstandingOpened+=$obj->total_ttc; + $outstandingOpened += $obj->total_ttc; } } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } else return array(); @@ -3885,7 +3885,7 @@ public function getOutstandingOrders($mode = 'customer') */ public function getOutstandingBills($mode = 'customer') { - $table='facture'; + $table = 'facture'; if ($mode == 'supplier') $table = 'facture_fourn'; /* Accurate value of remain to pay is to sum remaintopay for each invoice @@ -3895,9 +3895,9 @@ public function getOutstandingBills($mode = 'customer') $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); */ - if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, type, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; - else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, type, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; + else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; + $sql .= " WHERE fk_soc = ".$this->id; if ($mode == 'supplier') { $sql .= " AND entity IN (".getEntity('facture_fourn').")"; } else { @@ -3905,7 +3905,7 @@ public function getOutstandingBills($mode = 'customer') } dol_syslog("getOutstandingBills", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $outstandingOpened = 0; @@ -3914,22 +3914,22 @@ public function getOutstandingBills($mode = 'customer') if ($mode == 'supplier') { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $tmpobject=new FactureFournisseur($this->db); + $tmpobject = new FactureFournisseur($this->db); } else { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $tmpobject=new Facture($this->db); + $tmpobject = new Facture($this->db); } - while($obj=$this->db->fetch_object($resql)) { - $tmpobject->id=$obj->rowid; + while ($obj = $this->db->fetch_object($resql)) { + $tmpobject->id = $obj->rowid; if ($obj->fk_statut != $tmpobject::STATUS_DRAFT // Not a draft - && ! ($obj->fk_statut == $tmpobject::STATUS_ABANDONED && $obj->close_code == 'replaced') // Not a replaced invoice + && !($obj->fk_statut == $tmpobject::STATUS_ABANDONED && $obj->close_code == 'replaced') // Not a replaced invoice ) { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; + $outstandingTotal += $obj->total_ht; + $outstandingTotalIncTax += $obj->total_ttc; } if ($obj->paye == 0 && $obj->fk_statut != $tmpobject::STATUS_DRAFT // Not a draft @@ -3941,17 +3941,17 @@ public function getOutstandingBills($mode = 'customer') $creditnotes = $tmpobject->getSumCreditNotesUsed(); $deposits = $tmpobject->getSumDepositsUsed(); - $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; + $outstandingOpened += $obj->total_ttc - $paiement - $creditnotes - $deposits; } //if credit note is converted but not used // TODO Do this also for customer ? - if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $tmpobject->isCreditNoteUsed()) + if ($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $tmpobject->isCreditNoteUsed()) { - $outstandingOpened-=$tmpobject->getSumFromThisCreditNotesNotUsed(); + $outstandingOpened -= $tmpobject->getSumFromThisCreditNotesNotUsed(); } } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } else { @@ -3982,10 +3982,10 @@ public function LibCustProspStatut($status) global $langs; $langs->load('companies'); - if ($status==0) return $langs->trans("NorProspectNorCustomer"); - elseif ($status==1) return $langs->trans("Customer"); - elseif ($status==2) return $langs->trans("Prospect"); - elseif ($status==3) return $langs->trans("ProspectCustomer"); + if ($status == 0) return $langs->trans("NorProspectNorCustomer"); + elseif ($status == 1) return $langs->trans("Customer"); + elseif ($status == 2) return $langs->trans("Prospect"); + elseif ($status == 3) return $langs->trans("ProspectCustomer"); } @@ -4002,24 +4002,24 @@ public function LibCustProspStatut($status) */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$user,$langs; + global $conf, $user, $langs; - if (! empty($moreparams) && ! empty($moreparams['use_companybankid'])) + if (!empty($moreparams) && !empty($moreparams['use_companybankid'])) { $modelpath = "core/modules/bank/doc/"; include_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $companybankaccount = new CompanyBankAccount($this->db); $result = $companybankaccount->fetch($moreparams['use_companybankid']); - if (! $result) dol_print_error($this->db, $companybankaccount->error, $companybankaccount->errors); - $result=$companybankaccount->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + if (!$result) dol_print_error($this->db, $companybankaccount->error, $companybankaccount->errors); + $result = $companybankaccount->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } else { // Positionne le modele sur le nom du modele a utiliser - if (! dol_strlen($modele)) + if (!dol_strlen($modele)) { - if (! empty($conf->global->COMPANY_ADDON_PDF)) + if (!empty($conf->global->COMPANY_ADDON_PDF)) { $modele = $conf->global->COMPANY_ADDON_PDF; } @@ -4032,7 +4032,7 @@ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hided $modelpath = "core/modules/societe/doc/"; - $result=$this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } return $result; @@ -4052,11 +4052,11 @@ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hided */ public function setCategories($categories, $type_categ) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Decode type - if (! in_array($type_categ, array(Categorie::TYPE_CUSTOMER, Categorie::TYPE_SUPPLIER))) { - dol_syslog(__METHOD__ . ': Type ' . $type_categ . 'is an unknown company category type. Done nothing.', LOG_ERR); + if (!in_array($type_categ, array(Categorie::TYPE_CUSTOMER, Categorie::TYPE_SUPPLIER))) { + dol_syslog(__METHOD__.': Type '.$type_categ.'is an unknown company category type. Done nothing.', LOG_ERR); return -1; } diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 5636f09b3a4f9..20721dd28abcc 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -39,19 +39,19 @@ require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; -$langs->loadLangs(array("companies","commercial","banks","bills",'paypal','stripe','withdrawals')); +$langs->loadLangs(array("companies", "commercial", "banks", "bills", 'paypal', 'stripe', 'withdrawals')); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'societe', '', ''); -$id=GETPOST("id", "int"); -$source=GETPOST("source", "alpha"); // source can be a source or a paymentmode -$ribid=GETPOST("ribid", "int"); -$action=GETPOST("action", 'alpha', 3); -$cancel=GETPOST('cancel', 'alpha'); +$id = GETPOST("id", "int"); +$source = GETPOST("source", "alpha"); // source can be a source or a paymentmode +$ribid = GETPOST("ribid", "int"); +$action = GETPOST("action", 'alpha', 3); +$cancel = GETPOST('cancel', 'alpha'); $object = new Societe($db); $object->fetch($socid); @@ -66,22 +66,22 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('thirdpartybancard','globalcard')); +$hookmanager->initHooks(array('thirdpartybancard', 'globalcard')); -if (! empty($conf->stripe->enabled)) +if (!empty($conf->stripe->enabled)) { $service = 'StripeTest'; $servicestatus = 0; - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { $service = 'StripeLive'; $servicestatus = 1; } $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no network access here) - $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus); // Get remote Stripe customer 'cus_...' (no network access here) + $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no network access here) + $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus); // Get remote Stripe customer 'cus_...' (no network access here) } @@ -92,19 +92,19 @@ if ($cancel) { - $action=''; + $action = ''; } -$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas); +$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) { - $action=''; - if (! empty($backtopage)) + $action = ''; + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -114,31 +114,31 @@ if ($action == 'update') { // Modification - if (! GETPOST('label', 'alpha') || ! GETPOST('bank', 'alpha')) + if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha')) { - if (! GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - if (! GETPOST('bank', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); - $action='edit'; + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + if (!GETPOST('bank', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); + $action = 'edit'; $error++; } if ($companybankaccount->needIBAN() == 1) { - if (! GETPOST('iban')) + if (!GETPOST('iban')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); - $action='edit'; + $action = 'edit'; $error++; } - if (! GETPOST('bic')) + if (!GETPOST('bic')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); - $action='edit'; + $action = 'edit'; $error++; } } $companybankaccount->fetch($id); - if (! $error) + if (!$error) { $companybankaccount->socid = $object->id; @@ -168,7 +168,7 @@ } $result = $companybankaccount->update($user); - if (! $result) + if (!$result) { setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); } @@ -177,10 +177,10 @@ // If this account is the default bank account, we disable others if ($companybankaccount->default_rib) { - $companybankaccount->setAsDefault($id); // This will make sure there is only one default rib + $companybankaccount->setAsDefault($id); // This will make sure there is only one default rib } - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; + $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; header('Location: '.$url); exit; } @@ -190,19 +190,19 @@ if ($action == 'updatecard') { // Modification - if (! GETPOST('label', 'alpha') || ! GETPOST('proprio', 'alpha') || ! GETPOST('cardnumber', 'alpha') || ! GETPOST('exp_date_month', 'alpha') || ! GETPOST('exp_date_year', 'alpha') || ! GETPOST('cvn', 'alpha')) + if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('cardnumber', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha') || !GETPOST('cvn', 'alpha')) { - if (! GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - if (! GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); - if (! GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); - if (! (GETPOST('exp_date_month', 'alpha') > 0) || ! (GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); - if (! GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); - $action='createcard'; + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); + if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); + if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); + if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); + $action = 'createcard'; $error++; } $companypaymentmode->fetch($id); - if (! $error) + if (!$error) { $companypaymentmode->fk_soc = $object->id; @@ -219,7 +219,7 @@ $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha'); $result = $companypaymentmode->update($user); - if (! $result) + if (!$result) { setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); } @@ -228,10 +228,10 @@ // If this account is the default bank account, we disable others if ($companypaymentmode->default_rib) { - $companypaymentmode->setAsDefault($id); // This will make sure there is only one default rib + $companypaymentmode->setAsDefault($id); // This will make sure there is only one default rib } - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; + $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; header('Location: '.$url); exit; } @@ -240,17 +240,17 @@ if ($action == 'add') { - $error=0; + $error = 0; - if (! GETPOST('label', 'alpha') || ! GETPOST('bank', 'alpha')) + if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha')) { - if (! GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - if (! GETPOST('bank', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); - $action='create'; + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + if (!GETPOST('bank', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); + $action = 'create'; $error++; } - if (! $error) + if (!$error) { // Ajout $companybankaccount = new CompanyBankAccount($db); @@ -273,7 +273,7 @@ $companybankaccount->frstrecur = GETPOST('frstrecur'); $companybankaccount->rum = GETPOST('rum', 'alpha'); $companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear')); - $companybankaccount->datec = dol_now(); + $companybankaccount->datec = dol_now(); $companybankaccount->status = 1; $db->begin(); @@ -281,28 +281,28 @@ // This test can be done only once properties were set if ($companybankaccount->needIBAN() == 1) { - if (! GETPOST('iban')) + if (!GETPOST('iban')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } - if (! GETPOST('bic')) + if (!GETPOST('bic')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } } - if (! $error) + if (!$error) { $result = $companybankaccount->create($user); if ($result < 0) { $error++; setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); - $action='create'; // Force chargement page création + $action = 'create'; // Force chargement page création } if (empty($companybankaccount->rum)) @@ -312,22 +312,22 @@ } } - if (! $error) + if (!$error) { - $result = $companybankaccount->update($user); // This will set the UMR number. + $result = $companybankaccount->update($user); // This will set the UMR number. if ($result < 0) { $error++; setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); - $action='create'; + $action = 'create'; } } - if (! $error) + if (!$error) { $db->commit(); - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; + $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; header('Location: '.$url); exit; } @@ -340,20 +340,20 @@ if ($action == 'addcard') { - $error=0; + $error = 0; - if (! GETPOST('label', 'alpha') || ! GETPOST('proprio', 'alpha') || ! GETPOST('cardnumber', 'alpha') || ! GETPOST('exp_date_month', 'alpha') || ! GETPOST('exp_date_year', 'alpha') || ! GETPOST('cvn', 'alpha')) + if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('cardnumber', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha') || !GETPOST('cvn', 'alpha')) { - if (! GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - if (! GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); - if (! GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); - if (! (GETPOST('exp_date_month', 'alpha') > 0) || ! (GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); - if (! GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); - $action='createcard'; + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); + if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); + if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); + if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); + $action = 'createcard'; $error++; } - if (! $error) + if (!$error) { // Ajout $companypaymentmode = new CompanyPaymentMode($db); @@ -377,22 +377,22 @@ $db->begin(); - if (! $error) + if (!$error) { $result = $companypaymentmode->create($user); if ($result < 0) { $error++; setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); - $action='createcard'; // Force chargement page création + $action = 'createcard'; // Force chargement page création } } - if (! $error) + if (!$error) { $db->commit(); - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; + $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; header('Location: '.$url); exit; } @@ -409,7 +409,7 @@ $res = $companybankaccount->setAsDefault(GETPOST('ribid', 'int')); if ($res) { - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; + $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; header('Location: '.$url); exit; } @@ -422,7 +422,7 @@ if ($action == 'confirm_deletecard' && GETPOST('confirm', 'alpha') == 'yes') { $companypaymentmode = new CompanyPaymentMode($db); - if ($companypaymentmode->fetch($ribid?$ribid:$id)) + if ($companypaymentmode->fetch($ribid ? $ribid : $id)) { /*if ($companypaymentmode->stripe_card_ref && preg_match('/pm_/', $companypaymentmode->stripe_card_ref)) { @@ -453,7 +453,7 @@ if ($action == 'confirm_delete' && GETPOST('confirm', 'alpha') == 'yes') { $companybankaccount = new CompanyBankAccount($db); - if ($companybankaccount->fetch($ribid?$ribid:$id)) + if ($companybankaccount->fetch($ribid ? $ribid : $id)) { $result = $companybankaccount->delete($user); if ($result > 0) @@ -473,7 +473,7 @@ } } - $savid=$id; + $savid = $id; // Actions to build doc if ($action == 'builddocrib') @@ -484,18 +484,18 @@ 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id) ); $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid', 'int'), 'alpha'); - $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid', 'int'), 'alpha'); + $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid', 'int'), 'alpha'); } $id = $socid; $upload_dir = $conf->societe->multidir_output[$object->entity]; - $permissiontoadd=$user->rights->societe->creer; + $permissiontoadd = $user->rights->societe->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; $id = $savid; // Action for stripe - if (! empty($conf->stripe->enabled) && class_exists('Stripe')) + if (!empty($conf->stripe->enabled) && class_exists('Stripe')) { if ($action == 'synccustomertostripe') { @@ -508,7 +508,7 @@ { // Creation of Stripe customer + update of societe_account $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1); - if (! $cu) + if (!$cu) { $error++; setEventMessages($stripe->error, $stripe->errors, 'errors'); @@ -533,17 +533,17 @@ { // Get the Stripe customer $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); - if (! $cu) + if (!$cu) { $error++; setEventMessages($stripe->error, $stripe->errors, 'errors'); } - if (! $error) + if (!$error) { // Creation of Stripe card + update of societe_account $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1); - if (! $card) + if (!$card) { $error++; setEventMessages($stripe->error, $stripe->errors, 'errors'); @@ -565,11 +565,11 @@ $db->begin(); if (empty($newcu)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; } else { $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; - $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; - $sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + $sql .= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; + $sql .= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! } $resql = $db->query($sql); @@ -590,7 +590,7 @@ } } - if (! $error) + if (!$error) { $stripecu = $newcu; $db->commit(); @@ -610,16 +610,16 @@ $db->begin(); if (empty($newsup)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; } else { try { $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); $tokenstring['stripe_user_id'] = $stripesup->id; $tokenstring['type'] = $stripesup->type; $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token"; - $sql.= " SET tokenstring = '".dol_json_encode($tokenstring)."'"; - $sql.= " WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! - } catch(Exception $e) { + $sql .= " SET tokenstring = '".dol_json_encode($tokenstring)."'"; + $sql .= " WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + } catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } @@ -635,14 +635,14 @@ $tokenstring['type'] = $stripesup->type; $sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)"; $sql .= " VALUES ('".$service."', ".$object->id.", ".$conf->entity.", '".dol_json_encode($tokenstring)."')"; - } catch(Exception $e) { + } catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } $resql = $db->query($sql); } - if (! $error) + if (!$error) { $stripesupplieracc = $newsup; $db->commit(); @@ -658,11 +658,11 @@ try { $companypaymentmode->setAsDefault($id); - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; + $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; header('Location: '.$url); exit; } - catch(Exception $e) + catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); @@ -671,22 +671,22 @@ elseif ($action == 'setassourcedefault') // Set as default when payment mode defined remotely only { try { - $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); + $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); if (preg_match('/pm_/', $source)) { - $cu->invoice_settings->default_payment_method = (string) $source; // New + $cu->invoice_settings->default_payment_method = (string) $source; // New } else { - $cu->default_source = (string) $source; // Old + $cu->default_source = (string) $source; // Old } $result = $cu->save(); - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; + $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; header('Location: '.$url); exit; } - catch(Exception $e) + catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); @@ -717,11 +717,11 @@ } } - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; + $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; header('Location: '.$url); exit; } - catch(Exception $e) + catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); @@ -742,20 +742,20 @@ llxHeader(); -$head=societe_prepare_head($object); +$head = societe_prepare_head($object); // Show sandbox warning /*if (! empty($conf->paypal->enabled) && (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha'))) // We can force sand box with param 'forcesandbox' { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Paypal'),'','warning'); }*/ -if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) +if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); } // Load Bank account -if (! $id) +if (!$id) { $companybankaccount->fetch(0, $object->id); $companypaymentmode->fetch(0, null, $object->id, 'card'); @@ -765,14 +765,14 @@ $companybankaccount->fetch($id); $companypaymentmode->fetch($id); } -if (empty($companybankaccount->socid)) $companybankaccount->socid=$object->id; +if (empty($companybankaccount->socid)) $companybankaccount->socid = $object->id; if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer) { print '
'; print ''; - $actionforadd='update'; - if ($action == 'editcard') $actionforadd='updatecard'; + $actionforadd = 'update'; + if ($action == 'editcard') $actionforadd = 'updatecard'; print ''; print ''; } @@ -780,8 +780,8 @@ { print ''; print ''; - $actionforadd='add'; - if ($action == 'createcard') $actionforadd='addcard'; + $actionforadd = 'add'; + if ($action == 'createcard') $actionforadd = 'addcard'; print ''; } @@ -794,20 +794,20 @@ // Confirm delete ban if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $companybankaccount->getRibLabel()), "confirm_delete", '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid ? $ribid : $id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $companybankaccount->getRibLabel()), "confirm_delete", '', 0, 1); } // Confirm delete card if ($action == 'deletecard') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteACard"), $langs->trans("ConfirmDeleteCard", $companybankaccount->getRibLabel()), "confirm_deletecard", '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid ? $ribid : $id), $langs->trans("DeleteACard"), $langs->trans("ConfirmDeleteCard", $companybankaccount->getRibLabel()), "confirm_deletecard", '', 0, 1); } $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); - if (! empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account') + if (!empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account') { - $connect=''; - if (!empty($stripeacc)) $connect=$stripeacc.'/'; - $url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; + $connect = ''; + if (!empty($stripeacc)) $connect = $stripeacc.'/'; + $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; if ($servicestatus) { - $url='https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu; + $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu; } print ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; } @@ -879,35 +879,35 @@ if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print '
'; print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); - if (! empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier') + if (!empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier') { - $connect=''; + $connect = ''; - $url='https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc; + $url = 'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc; if ($servicestatus) { - $url='https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc; + $url = 'https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc; } print ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; } @@ -933,31 +933,31 @@ print '
'; // List of Stripe payment modes - if (! (empty($conf->stripe->enabled)) && $object->client) + if (!(empty($conf->stripe->enabled)) && $object->client) { - $morehtmlright=''; - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) + $morehtmlright = ''; + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { - $morehtmlright.= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=createcard'); + $morehtmlright .= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=createcard'); } - print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc?' (Stripe connection with StripeConnect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); + print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); $listofsources = array(); if (is_object($stripe)) { try { - $customerstripe=$stripe->customerStripe($object, $stripeacc, $servicestatus); + $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus); if ($customerstripe->id) { // When using the Charge API architecture if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - $listofsources=$customerstripe->sources->data; + $listofsources = $customerstripe->sources->data; } else { $service = 'StripeTest'; $servicestatus = 0; - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { $service = 'StripeLive'; $servicestatus = 1; @@ -976,7 +976,7 @@ $listofsources = $paymentmethodobjs->data; } - catch(Exception $e) + catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); @@ -1006,8 +1006,8 @@ print '
'.$langs->trans('Note').''.$langs->trans('DateModification').'
'; @@ -1054,12 +1054,12 @@ print $companypaymentmodetemp->stripe_card_ref; if ($companypaymentmodetemp->stripe_card_ref) { - $connect=''; - if (!empty($stripeacc)) $connect=$stripeacc.'/'; - $url='https://dashboard.stripe.com/'.$connect.'test/search?query='.$companypaymentmodetemp->stripe_card_ref; + $connect = ''; + if (!empty($stripeacc)) $connect = $stripeacc.'/'; + $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$companypaymentmodetemp->stripe_card_ref; if ($servicestatus) { - $url='https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref; + $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref; } print ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; } @@ -1073,8 +1073,8 @@ print ''; if ($companypaymentmodetemp->country_code) { - $img=picto_from_langcode($companypaymentmodetemp->country_code); - print $img?$img.' ':''; + $img = picto_from_langcode($companypaymentmodetemp->country_code); + print $img ? $img.' ' : ''; print getCountry($companypaymentmodetemp->country_code, 1); } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; @@ -1083,7 +1083,7 @@ print ''; if (empty($companypaymentmodetemp->default_rib)) { - print ''; + print ''; print img_picto($langs->trans("Default"), 'off'); print ''; } else { @@ -1098,8 +1098,8 @@ print dol_print_date($companypaymentmodetemp->tms, 'dayhour'); print ''; @@ -1110,11 +1110,11 @@ print ''.$langs->trans("CreateCardOnStripe").''; } - print ''; + print ''; print img_picto($langs->trans("Modify"), 'edit'); print ''; print ' '; - print ''; // source='.$companypaymentmodetemp->stripe_card_ref.'& + print ''; // source='.$companypaymentmodetemp->stripe_card_ref.'& print img_picto($langs->trans("Delete"), 'delete'); print ''; } @@ -1133,113 +1133,113 @@ { foreach ($listofsources as $src) { - if (! empty($arrayofstripecard[$src->id])) continue; // Already in previous list + if (!empty($arrayofstripecard[$src->id])) continue; // Already in previous list $nbremote++; print '
'; print ''; - $connect=''; + $connect = ''; print $src->id; - if (!empty($stripeacc)) $connect=$stripeacc.'/'; + if (!empty($stripeacc)) $connect = $stripeacc.'/'; //$url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id; - $url='https://dashboard.stripe.com/'.$connect.'test/search?query='.$src->id; + $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$src->id; if ($servicestatus) { //$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; - $url='https://dashboard.stripe.com/'.$connect.'search?query='.$src->id; + $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$src->id; } print " ".img_picto($langs->trans('ShowInStripe'), 'globe').""; print ''; - if ($src->object=='card') + if ($src->object == 'card') { print img_credit_card($src->brand); } - elseif ($src->object=='source' && $src->type=='card') + elseif ($src->object == 'source' && $src->type == 'card') { print img_credit_card($src->card->brand); } - elseif ($src->object=='source' && $src->type=='sepa_debit') + elseif ($src->object == 'source' && $src->type == 'sepa_debit') { print ''; } - elseif ($src->object=='payment_method' && $src->type=='card') + elseif ($src->object == 'payment_method' && $src->type == 'card') { print img_credit_card($src->card->brand); } - elseif ($src->object=='payment_method' && $src->type=='sepa_debit') + elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') { print ''; } print''; - if ($src->object=='card') + if ($src->object == 'card') { print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.''; print ''; if ($src->country) { - $img=picto_from_langcode($src->country); - print $img?$img.' ':''; + $img = picto_from_langcode($src->country); + print $img ? $img.' ' : ''; print getCountry($src->country, 1); } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - elseif ($src->object=='source' && $src->type=='card') + elseif ($src->object == 'source' && $src->type == 'card') { print $src->owner->name.'
....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; print '
'; if ($src->card->country) { - $img=picto_from_langcode($src->card->country); - print $img?$img.' ':''; + $img = picto_from_langcode($src->card->country); + print $img ? $img.' ' : ''; print getCountry($src->card->country, 1); } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - elseif ($src->object=='source' && $src->type=='sepa_debit') + elseif ($src->object == 'source' && $src->type == 'sepa_debit') { print 'info sepa'; print ''; if ($src->sepa_debit->country) { - $img=picto_from_langcode($src->sepa_debit->country); - print $img?$img.' ':''; + $img = picto_from_langcode($src->sepa_debit->country); + print $img ? $img.' ' : ''; print getCountry($src->sepa_debit->country, 1); } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - elseif ($src->object=='payment_method' && $src->type=='card') + elseif ($src->object == 'payment_method' && $src->type == 'card') { print $src->billing_details->name.'
....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; print '
'; if ($src->card->country) { - $img=picto_from_langcode($src->card->country); - print $img?$img.' ':''; + $img = picto_from_langcode($src->card->country); + print $img ? $img.' ' : ''; print getCountry($src->card->country, 1); } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - elseif ($src->object=='payment_method' && $src->type=='sepa_debit') + elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') { print 'info sepa'; print ''; if ($src->sepa_debit->country) { - $img=picto_from_langcode($src->sepa_debit->country); - print $img?$img.' ':''; + $img = picto_from_langcode($src->sepa_debit->country); + print $img ? $img.' ' : ''; print getCountry($src->sepa_debit->country, 1); } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; @@ -1251,9 +1251,9 @@ // Default print ''; if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) || - (! empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) + (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) { - print ''; + print ''; print img_picto($langs->trans("Default"), 'off'); print ''; } else { @@ -1269,14 +1269,14 @@ print ''; print ''; if ($user->rights->societe->creer) { - print ''; + print ''; print img_picto($langs->trans("Delete"), 'delete'); print ''; } @@ -1288,8 +1288,8 @@ if ($nbremote == 0 && $nblocal == 0) { - $colspan=8; - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) $colspan++; + $colspan = 8; + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) $colspan++; print '
'.$langs->trans("None").'
"; @@ -1298,9 +1298,9 @@ } // List of Stripe payment modes - if (! empty($conf->stripe->enabled) && ! empty($conf->stripeconnect->enabled) && $object->fournisseur && ! empty($stripesupplieracc)) + if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && $object->fournisseur && !empty($stripesupplieracc)) { - print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc?' (Stripe connection with StripeConnect account '.$stripesupplieracc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); + print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc ? ' (Stripe connection with StripeConnect account '.$stripesupplieracc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc)); print ''."\n"; print ''; @@ -1315,13 +1315,13 @@ { foreach ($balance->available as $cpt) { - $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) { - $currencybalance[$cpt->currency]->available=$cpt->amount / 100; + $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + if (!in_array($cpt->currency, $arrayzerounitcurrency)) { + $currencybalance[$cpt->currency]->available = $cpt->amount / 100; } else { - $currencybalance[$cpt->currency]->available=$cpt->amount; + $currencybalance[$cpt->currency]->available = $cpt->amount; } - $currencybalance[$cpt->currency]->currency=$cpt->currency; + $currencybalance[$cpt->currency]->currency = $cpt->currency; } } @@ -1329,11 +1329,11 @@ { foreach ($balance->pending as $cpt) { - $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) { - $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount / 100; + $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + if (!in_array($cpt->currency, $arrayzerounitcurrency)) { + $currencybalance[$cpt->currency]->pending = $currencybalance[$cpt->currency]->available + $cpt->amount / 100; } else { - $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount; + $currencybalance[$cpt->currency]->pending = $currencybalance[$cpt->currency]->available + $cpt->amount; } } } @@ -1342,7 +1342,7 @@ { foreach ($currencybalance as $cpt) { - print ''; + print ''; } } @@ -1368,7 +1368,7 @@ print_liste_field_titre("RIB"); print_liste_field_titre("IBAN"); print_liste_field_titre("BIC"); - if (! empty($conf->prelevement->enabled)) + if (!empty($conf->prelevement->enabled)) { print_liste_field_titre("RUM"); print_liste_field_titre("DateRUM"); @@ -1388,7 +1388,7 @@ print ''; // Account number print ''; // IBAN print ''; // BIC print ''; - if (! empty($conf->prelevement->enabled)) + if (!empty($conf->prelevement->enabled)) { // RUM //print ''; @@ -1460,54 +1460,54 @@ print ''; @@ -1533,8 +1533,8 @@ if (count($rib_list) == 0) { - $colspan=9; - if (! empty($conf->prelevement->enabled)) $colspan+=2; + $colspan = 9; + if (!empty($conf->prelevement->enabled)) $colspan += 2; print ''; } @@ -1555,15 +1555,15 @@ /* * Documents generes */ - $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; - $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; - $genallowed=$user->rights->societe->lire; - $delallowed=$user->rights->societe->creer; + $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; + $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; + $genallowed = $user->rights->societe->lire; + $delallowed = $user->rights->societe->creer; print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); // Show direct download link - if (! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) + if (!empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { $companybankaccounttemp = new CompanyBankAccount($db); $companypaymentmodetemp = new CompanyPaymentMode($db); @@ -1615,7 +1615,7 @@ $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
'; @@ -1630,7 +1630,7 @@ // Show fields of bank account foreach ($companybankaccount->getFieldsToShow(1) as $val) { - $require=false; + $require = false; if ($val == 'BankCode') { $name = 'code_banque'; $size = 8; @@ -1651,15 +1651,15 @@ $name = 'iban'; $size = 30; $content = $companybankaccount->iban; - if ($companybankaccount->needIBAN()) $require=true; + if ($companybankaccount->needIBAN()) $require = true; } elseif ($val == 'BIC') { $name = 'bic'; $size = 12; $content = $companybankaccount->bic; - if ($companybankaccount->needIBAN()) $require=true; + if ($companybankaccount->needIBAN()) $require = true; } - print '
'.$langs->trans($val).''; + print ''.$langs->trans($val).''; print ''; print ''; } @@ -1693,11 +1693,11 @@ print ''; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("Currency".strtoupper($cpt->currency)).''.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->available+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'
'.$langs->trans("Currency".strtoupper($cpt->currency)).''.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->available + $cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'
'.$rib->bank.''; - $string=''; + $string = ''; foreach ($rib->getFieldsToShow() as $val) { if ($val == 'BankCode') { $string .= $rib->code_banque.' '; @@ -1406,11 +1406,11 @@ // $string .= $rib->iban.' ';*/ //} } - if (! empty($rib->label) && $rib->number) { - if (! checkBanForAccount($rib)) { - $string.= ' '.img_picto($langs->trans("ValueIsNotValid"), 'warning'); + if (!empty($rib->label) && $rib->number) { + if (!checkBanForAccount($rib)) { + $string .= ' '.img_picto($langs->trans("ValueIsNotValid"), 'warning'); } else { - $string.= ' '.img_picto($langs->trans("ValueIsValid"), 'info'); + $string .= ' '.img_picto($langs->trans("ValueIsValid"), 'info'); } } @@ -1418,22 +1418,22 @@ print ''.$rib->iban; - if (! empty($rib->iban)) { - if (! checkIbanForAccount($rib)) { + if (!empty($rib->iban)) { + if (!checkIbanForAccount($rib)) { print ' '.img_picto($langs->trans("IbanNotValid"), 'warning'); } } print ''.$rib->bic; - if (! empty($rib->bic)) { - if (! checkSwiftForAccount($rib)) { + if (!empty($rib->bic)) { + if (!checkSwiftForAccount($rib)) { print ' '.img_picto($langs->trans("SwiftNotValid"), 'warning'); } } print ''.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).''; $buttonlabel = $langs->trans("BuildDoc"); - $forname='builddocrib'.$rib->id; + $forname = 'builddocrib'.$rib->id; include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; - $modellist=ModeleBankAccountDoc::liste_modeles($db); + $modellist = ModeleBankAccountDoc::liste_modeles($db); $out = ''; if (is_array($modellist) && count($modellist)) { - $out.= ''; - $out.= ''; - $out.= ''; - $out.= ''; - $out.= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; if (is_array($modellist) && count($modellist) == 1) // If there is only one element { - $arraykeys=array_keys($modellist); - $modelselected=$arraykeys[0]; + $arraykeys = array_keys($modellist); + $modelselected = $arraykeys[0]; } - if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; + if (!empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; - $out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); - $out.= ajax_combobox('modelrib'.$rib->id); + $out .= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); + $out .= ajax_combobox('modelrib'.$rib->id); // Language code (if multilang) if ($conf->global->MAIN_MULTILANGS) { include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; - $formadmin=new FormAdmin($db); - $defaultlang=$codelang?$codelang:$langs->getDefaultLang(); - $morecss='maxwidth150'; - if ($conf->browser->layout == 'phone') $morecss='maxwidth100'; - $out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); + $formadmin = new FormAdmin($db); + $defaultlang = $codelang ? $codelang : $langs->getDefaultLang(); + $morecss = 'maxwidth150'; + if ($conf->browser->layout == 'phone') $morecss = 'maxwidth100'; + $out .= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); } // Button $genbutton = 'dol_no_mouse_hover) && $modulepart != 'unpaid') + $genbutton .= ' type="submit" value="'.$buttonlabel.'"'; + if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) $genbutton .= ' disabled'; + $genbutton .= '>'; + if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') { $langs->load("errors"); - $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); + $genbutton .= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); } - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton=''; - if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton=''; - $out.= $genbutton; - $out.= ''; + if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton = ''; + if (empty($modellist) && !$showempty && $modulepart != 'unpaid') $genbutton = ''; + $out .= $genbutton; + $out .= ''; } print $out; print '
'.$langs->trans("NoBANRecord").'
'.$langs->trans("DateRUM").''.$form->selectDate(GETPOST('date_rum')?GETPOST('date_rum'):$companybankaccount->date_rum, 'date_rum', 0, 0, 1, 'date_rum').'
'.$form->selectDate(GETPOST('date_rum') ?GETPOST('date_rum') : $companybankaccount->date_rum, 'date_rum', 0, 0, 1, 'date_rum').'
'.$langs->trans("WithdrawMode").''; $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); - print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur', 'alpha')?GETPOST('frstrecur', 'alpha'):$companybankaccount->frstrecur), 0); + print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur', 'alpha') ?GETPOST('frstrecur', 'alpha') : $companybankaccount->frstrecur), 0); print '
'; @@ -1721,7 +1721,7 @@ $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
'; @@ -1769,7 +1769,7 @@ $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
'; @@ -1784,7 +1784,7 @@ // Show fields of bank account foreach ($companybankaccount->getFieldsToShow(1) as $val) { - $require=false; + $require = false; if ($val == 'BankCode') { $name = 'code_banque'; $size = 8; @@ -1800,14 +1800,14 @@ } elseif ($val == 'IBAN') { $name = 'iban'; $size = 30; - if ($companybankaccount->needIBAN()) $require=true; + if ($companybankaccount->needIBAN()) $require = true; } elseif ($val == 'BIC') { $name = 'bic'; $size = 12; - if ($companybankaccount->needIBAN()) $require=true; + if ($companybankaccount->needIBAN()) $require = true; } - print ''.$langs->trans($val).''; + print ''.$langs->trans($val).''; print ''; print ''; } @@ -1843,7 +1843,7 @@ print ''.$langs->trans("WithdrawMode").''; $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); - print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0); + print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur']) ?GETPOST('frstrecur') : 'FRST'), 0); print ''; print ''; @@ -1869,7 +1869,7 @@ $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); print '
'; From 366dfc0e5cfc01b2747cb5180b7c27e2584e24ee Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 13 Nov 2019 18:15:19 +0000 Subject: [PATCH 2/3] Fixing style errors. --- htdocs/societe/paymentmodes.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 25d38692ee084..fc9068b8127cf 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1318,10 +1318,10 @@ $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); if (! in_array($cpt->currency, $arrayzerounitcurrency)) { $currencybalance[$cpt->currency]['available'] = $cpt->amount / 100; - } else { - $currencybalance[$cpt->currency]['available'] = $cpt->amount; - } - $currencybalance[$cpt->currency]['currency'] = $cpt->currency; + } else { + $currencybalance[$cpt->currency]['available'] = $cpt->amount; + } + $currencybalance[$cpt->currency]['currency'] = $cpt->currency; } } @@ -1329,8 +1329,8 @@ { foreach ($balance->pending as $cpt) { - $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) { + $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + if (! in_array($cpt->currency, $arrayzerounitcurrency)) { $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available']+$cpt->amount / 100; } else { $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available']+$cpt->amount; @@ -1342,7 +1342,7 @@ { foreach ($currencybalance as $cpt) { - print ''.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available']+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''; + print ''.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available']+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''; } } From 16c50c212cdd5ca88c7068c1af60cc14cd0f1817 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Nov 2019 19:16:10 +0100 Subject: [PATCH 3/3] Update paymentmodes.php --- htdocs/societe/paymentmodes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index fc9068b8127cf..23a7c30f77eed 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1316,7 +1316,7 @@ foreach ($balance->available as $cpt) { $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) { + if (!in_array($cpt->currency, $arrayzerounitcurrency)) { $currencybalance[$cpt->currency]['available'] = $cpt->amount / 100; } else { $currencybalance[$cpt->currency]['available'] = $cpt->amount; @@ -1330,7 +1330,7 @@ foreach ($balance->pending as $cpt) { $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($cpt->currency, $arrayzerounitcurrency)) { + if (!in_array($cpt->currency, $arrayzerounitcurrency)) { $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available']+$cpt->amount / 100; } else { $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available']+$cpt->amount;