@@ -35,2 +33,0 @@
-
-// Load Dolibarr environment
@@ -45 +41,0 @@
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
@@ -57 +52,0 @@
-// Get parameters
@@ -61 +55,0 @@
-$cancel = GETPOST('cancel', 'alpha');
@@ -63,3 +57,2 @@
-$socid = GETPOST('socid', 'int');
-
-// Initialize technical object
+$socid = GETPOST('socid', 'int');
+
@@ -78,4 +71,5 @@
-if (!empty($canvas)) {
- require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
- $objcanvas = new Canvas($db, $action);
- $objcanvas->getCanvas('contact', 'contactcard', $canvas);
+if (!empty($canvas))
+{
+ require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
+ $objcanvas = new Canvas($db, $action);
+ $objcanvas->getCanvas('contact', 'contactcard', $canvas);
@@ -82,0 +77,4 @@
+
+// Security check
+if ($user->socid) $socid = $user->socid;
+$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission
@@ -87,6 +85,4 @@
-if ($id > 0) {
- $object->fetch($id);
- $object->info($id);
-}
-
-if (!($object->id > 0) && $action == 'view') {
+if ($id > 0) $object->fetch($id);
+
+if (!($object->id > 0) && $action == 'view')
+{
@@ -98,13 +93,0 @@
-$triggermodname = 'CONTACT_MODIFY';
-$permissiontoadd = $user->hasRight('societe', 'contact', 'creer');
-
-// Security check
-if ($user->socid) {
- $socid = $user->socid;
-}
-if ($object->priv && $object->user_creation_id != $user->id) {
- accessforbidden();
-}
-$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission
-
-
@@ -117,14 +100,58 @@
-if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-}
-
-if (empty($reshook)) {
- $backurlforlist = DOL_URL_ROOT.'/contact/list.php';
-
- if (empty($backtopage) || ($cancel && empty($id))) {
- if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
- if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
- $backtopage = $backurlforlist;
- } else {
- $backtopage = DOL_URL_ROOT.'/contact/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
- }
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+if (empty($reshook))
+{
+ // Cancel
+ if (GETPOST('cancel', 'alpha') && !empty($backtopage))
+ {
+ header("Location: ".$backtopage);
+ exit;
+ }
+
+ // Creation utilisateur depuis contact
+ if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer)
+ {
+ // Recuperation contact actuel
+ $result = $object->fetch($id);
+
+ if ($result > 0)
+ {
+ $db->begin();
+
+ // Creation user
+ $nuser = new User($db);
+ $result = $nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha)
+
+ if ($result > 0)
+ {
+ $result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha)
+ if ($result2)
+ {
+ $db->commit();
+ }
+ else
+ {
+ $error = $nuser->error; $errors = $nuser->errors;
+ $db->rollback();
+ }
+ }
+ else
+ {
+ $error = $nuser->error; $errors = $nuser->errors;
+ $db->rollback();
+ }
+ }
+ else
+ {
+ $error = $object->error; $errors = $object->errors;
+ }
+ }
+
+
+ // Confirmation desactivation
+ if ($action == 'disable')
+ {
+ $object->fetch($id);
+ if ($object->setstatus(0) < 0)
+ {
+ setEventMessages($object->error, $object->errors, 'errors');
@@ -132,52 +159,2 @@
- }
-
- if ($cancel) {
- if (!empty($backtopageforcancel)) {
- header("Location: ".$backtopageforcancel);
- exit;
- } elseif (!empty($backtopage)) {
- header("Location: ".$backtopage);
- exit;
- }
- $action = '';
- }
-
- // Creation utilisateur depuis contact
- if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->hasRight('user', 'user', 'creer')) {
- // Recuperation contact actuel
- $result = $object->fetch($id);
-
- if ($result > 0) {
- $db->begin();
-
- // Creation user
- $nuser = new User($db);
- $result = $nuser->create_from_contact($object, GETPOST("login")); // Do not use GETPOST(alpha)
-
- if ($result > 0) {
- $result2 = $nuser->setPassword($user, GETPOST("password"), 0, 0, 1); // Do not use GETPOST(alpha)
- if (is_int($result2) && $result2 < 0) {
- $error = $nuser->error;
- $errors = $nuser->errors;
- $db->rollback();
- } else {
- $db->commit();
- }
- } else {
- $error = $nuser->error;
- $errors = $nuser->errors;
- $db->rollback();
- }
- } else {
- $error = $object->error;
- $errors = $object->errors;
- }
- }
-
-
- // Confirmation desactivation
- if ($action == 'disable' && !empty($permissiontoadd)) {
- $object->fetch($id);
- if ($object->setstatus(0) < 0) {
- setEventMessages($object->error, $object->errors, 'errors');
- } else {
+ else
+ {
@@ -190 +167,2 @@
- if ($action == 'enable' && !empty($permissiontoadd)) {
+ if ($action == 'enable')
+ {
@@ -192 +170,2 @@
- if ($object->setstatus(1) < 0) {
+ if ($object->setstatus(1) < 0)
+ {
@@ -194 +173,3 @@
- } else {
+ }
+ else
+ {
@@ -201 +182,2 @@
- if ($action == 'add' && !empty($permissiontoadd)) {
+ if ($action == 'add' && $user->rights->societe->contact->creer)
+ {
@@ -204,44 +186,44 @@
- if ($canvas) {
- $object->canvas = $canvas;
- }
-
- $object->entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : $conf->entity);
- $object->socid = $socid;
- $object->lastname = (string) GETPOST("lastname", 'alpha');
- $object->firstname = (string) GETPOST("firstname", 'alpha');
- $object->civility_code = (string) GETPOST("civility_code", 'alpha');
- $object->poste = (string) GETPOST("poste", 'alpha');
- $object->address = (string) GETPOST("address", 'alpha');
- $object->zip = (string) GETPOST("zipcode", 'alpha');
- $object->town = (string) GETPOST("town", 'alpha');
- $object->country_id = (int) GETPOST("country_id", 'int');
- $object->state_id = (int) GETPOST("state_id", 'int');
- $object->socialnetworks = array();
- if (isModEnabled('socialnetworks')) {
- foreach ($socialnetworks as $key => $value) {
- if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
- $object->socialnetworks[$key] = (string) GETPOST($key, 'alphanohtml');
- }
- }
- }
- $object->email = (string) GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
- $object->no_email = GETPOST("no_email", "int");
- $object->phone_pro = (string) GETPOST("phone_pro", 'alpha');
- $object->phone_perso = (string) GETPOST("phone_perso", 'alpha');
- $object->phone_mobile = (string) GETPOST("phone_mobile", 'alpha');
- $object->fax = (string) GETPOST("fax", 'alpha');
- $object->priv = GETPOST("priv", 'int');
- $object->note_public = (string) GETPOST("note_public", 'restricthtml');
- $object->note_private = (string) GETPOST("note_private", 'restricthtml');
- $object->roles = GETPOST("roles", 'array');
-
- $object->statut = 1; //Default status to Actif
-
- // Note: Correct date should be completed with location to have exact GM time of birth.
- $object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth", 'int'), GETPOST("birthdayday", 'int'), GETPOST("birthdayyear", 'int'));
- $object->birthday_alert = GETPOST("birthday_alert", 'alpha');
-
- //Default language
- $object->default_lang = GETPOST('default_lang');
-
- // Fill array 'array_options' with data from add form
+ if ($canvas) $object->canvas = $canvas;
+
+ $object->entity = (GETPOSTISSET('entity') ?GETPOST('entity', 'int') : $conf->entity);
+ $object->socid = GETPOST("socid", 'int');
+ $object->lastname = GETPOST("lastname", 'alpha');
+ $object->firstname = GETPOST("firstname", 'alpha');
+ $object->civility_code = GETPOST("civility_code", 'alpha');
+ $object->poste = GETPOST("poste", 'alpha');
+ $object->address = GETPOST("address", 'alpha');
+ $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->jabberid = GETPOST("jabberid", 'alpha');
+ //$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)) {
+ foreach ($socialnetworks as $key => $value) {
+ if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
+ $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
+ }
+ }
+ }
+ $object->email = GETPOST("email", 'alpha');
+ $object->no_email = GETPOST("no_email", "int");
+ $object->phone_pro = GETPOST("phone_pro", 'alpha');
+ $object->phone_perso = GETPOST("phone_perso", 'alpha');
+ $object->phone_mobile = GETPOST("phone_mobile", 'alpha');
+ $object->fax = GETPOST("fax", 'alpha');
+ $object->priv = GETPOST("priv", 'int');
+ $object->note_public = GETPOST("note_public", 'none');
+ $object->note_private = GETPOST("note_private", 'none');
+ $object->roles = GETPOST("roles", 'array');
+
+ $object->statut = 1; //Defult status to Actif
+
+ // Note: Correct date should be completed with location to have exact GM time of birth.
+ $object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth", 'int'), GETPOST("birthdayday", 'int'), GETPOST("birthdayyear", 'int'));
+ $object->birthday_alert = GETPOST("birthday_alert", 'alpha');
+
+ // Fill array 'array_options' with data from add form
@@ -249 +231,2 @@
- if ($ret < 0) {
+ if ($ret < 0)
+ {
@@ -254,55 +237,13 @@
- if (isModEnabled('mailing') && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 && $object->no_email == -1 && !empty($object->email)) {
- $error++;
- $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email"));
- $action = 'create';
- }
-
- if (!empty($object->email) && !isValidEMail($object->email)) {
- $langs->load("errors");
- $error++;
- $errors[] = $langs->trans("ErrorBadEMail", GETPOST('email', 'alpha'));
- $action = 'create';
- }
-
- if (empty($object->lastname)) {
- $error++;
- $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label"));
- $action = 'create';
- }
-
- if (empty($error)) {
- $id = $object->create($user);
- if ($id <= 0) {
- $error++;
- $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
- $action = 'create';
- }
- }
-
- if (empty($error)) {
- // Categories association
- $contcats = GETPOST('contcats', 'array');
- if (count($contcats) > 0) {
- $result = $object->setCategories($contcats);
- if ($result <= 0) {
- $error++;
- $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
- $action = 'create';
- }
- }
- }
-
- if (empty($error) && isModEnabled('mailing') && !empty($object->email)) {
- // Add mass emailing flag into table mailing_unsubscribe
- $result = $object->setNoEmail($object->no_email);
- if ($result < 0) {
- $error++;
- $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
- $action = 'create';
- }
- }
-
- if (empty($error) && $id > 0) {
- $db->commit();
- if (!empty($backtopage)) {
- $url = str_replace('__ID__', $id, $backtopage);
+ if (!GETPOST("lastname"))
+ {
+ $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label"));
+ $action = 'create';
+ }
+
+ if (!$error)
+ {
+ $id = $object->create($user);
+ if ($id <= 0)
+ {
+ $error++; $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
+ $action = 'create';
@@ -310,78 +251,16 @@
- $url = 'card.php?id='.$id;
- }
- header("Location: ".$url);
- exit;
- } else {
- $db->rollback();
- }
- }
-
- if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('societe', 'contact', 'supprimer')) {
- $result = $object->fetch($id);
- $object->oldcopy = clone $object;
-
- $result = $object->delete($user);
- if ($result > 0) {
- setEventMessages("RecordDeleted", null, 'mesgs');
- if ($backurlforlist) {
- header("Location: ".$backurlforlist);
- exit;
- } else {
- header("Location: ".DOL_URL_ROOT.'/contact/list.php');
- exit;
- }
- } else {
- setEventMessages($object->error, $object->errors, 'errors');
- }
- }
-
- if ($action == 'update' && empty($cancel) && !empty($permissiontoadd)) {
- if (!GETPOST("lastname", 'alpha')) {
- $error++;
- $errors = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
- $action = 'edit';
- }
-
- if (isModEnabled('mailing') && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 && GETPOST("no_email", "int") == -1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) {
- $error++;
- $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email"));
- $action = 'edit';
- }
-
- if (!empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)) && !isValidEMail(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) {
- $langs->load("errors");
- $error++;
- $errors[] = $langs->trans("ErrorBadEMail", GETPOST('email', 'alpha'));
- $action = 'edit';
- }
-
- if (!$error) {
- $contactid = GETPOST("contactid", 'int');
- $object->fetch($contactid);
- $object->fetchRoles();
-
- // Photo save
- $dir = $conf->societe->multidir_output[$object->entity]."/contact/".$object->id."/photos";
- $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
- if (GETPOST('deletephoto') && $object->photo) {
- $fileimg = $dir.'/'.$object->photo;
- $dirthumbs = $dir.'/thumbs';
- dol_delete_file($fileimg);
- dol_delete_dir_recursive($dirthumbs);
- $object->photo = '';
- }
- if ($file_OK) {
- if (image_format_supported($_FILES['photo']['name']) > 0) {
- dol_mkdir($dir);
-
- if (@is_dir($dir)) {
- $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
- $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
-
- if (!($result > 0)) {
- $errors[] = "ErrorFailedToSaveFile";
- } else {
- $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
-
- // Create thumbs
- $object->addThumbs($newfile);
+ // Categories association
+ $contcats = GETPOST('contcats', 'array');
+ $object->setCategories($contcats);
+
+ // Add mass emailing flag into table mailing_unsubscribe
+ if (GETPOST('no_email', 'int') && $object->email)
+ {
+ $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $obj = $db->fetch_object($resql);
+ if (empty($obj->nb))
+ {
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')";
+ $resql = $db->query($sql);
@@ -389,37 +267,0 @@
- }
- } else {
- $errors[] = "ErrorBadImageFormat";
- }
- } else {
- 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
- $errors[] = "ErrorFileSizeTooLarge";
- break;
- case 3: //uploaded file was only partially uploaded
- $errors[] = "ErrorFilePartiallyUploaded";
- break;
- }
- }
-
- $object->oldcopy = clone $object;
-
- $object->socid = $socid;
- $object->lastname = (string) GETPOST("lastname", 'alpha');
- $object->firstname = (string) GETPOST("firstname", 'alpha');
- $object->civility_code = (string) GETPOST("civility_code", 'alpha');
- $object->poste = (string) GETPOST("poste", 'alpha');
-
- $object->address = (string) GETPOST("address", 'alpha');
- $object->zip = (string) GETPOST("zipcode", 'alpha');
- $object->town = (string) GETPOST("town", 'alpha');
- $object->state_id = GETPOST("state_id", 'int');
- $object->country_id = GETPOST("country_id", 'int');
-
- $object->email = (string) GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
- $object->no_email = GETPOST("no_email", "int");
- $object->socialnetworks = array();
- if (isModEnabled('socialnetworks')) {
- foreach ($socialnetworks as $key => $value) {
- if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
- $object->socialnetworks[$key] = (string) GETPOST($key, 'alphanohtml');
@@ -429,17 +271,203 @@
- $object->phone_pro = (string) GETPOST("phone_pro", 'alpha');
- $object->phone_perso = (string) GETPOST("phone_perso", 'alpha');
- $object->phone_mobile = (string) GETPOST("phone_mobile", 'alpha');
- $object->fax = (string) GETPOST("fax", 'alpha');
- $object->priv = (string) GETPOST("priv", 'int');
- $object->note_public = (string) GETPOST("note_public", 'restricthtml');
- $object->note_private = (string) GETPOST("note_private", 'restricthtml');
-
- $object->roles = GETPOST("roles", 'array'); // Note GETPOSTISSET("role") is null when combo is empty
-
- //Default language
- $object->default_lang = GETPOST('default_lang');
-
- // Fill array 'array_options' with data from add form
- $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
- if ($ret < 0) {
- $error++;
+ }
+
+ if (!$error && $id > 0)
+ {
+ $db->commit();
+ if (!empty($backtopage)) $url = $backtopage;
+ else $url = 'card.php?id='.$id;
+ header("Location: ".$url);
+ exit;
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
+
+ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->contact->supprimer)
+ {
+ $result = $object->fetch($id);
+ $object->oldcopy = clone $object;
+
+ $object->old_lastname = GETPOST("old_lastname");
+ $object->old_firstname = GETPOST("old_firstname");
+
+ $result = $object->delete();
+ if ($result > 0)
+ {
+ if ($backtopage)
+ {
+ header("Location: ".$backtopage);
+ exit;
+ }
+ else
+ {
+ header("Location: ".DOL_URL_ROOT.'/contact/list.php');
+ exit;
+ }
+ }
+ else
+ {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ }
+
+ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer)
+ {
+ if (empty($_POST["lastname"]))
+ {
+ $error++; $errors = array($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
+ $action = 'edit';
+ }
+
+ if (!$error)
+ {
+ $contactid = GETPOST("contactid", 'int');
+ $object->fetch($contactid);
+
+ // Photo save
+ $dir = $conf->societe->multidir_output[$object->entity]."/contact/".$object->id."/photos";
+ $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
+ if (GETPOST('deletephoto') && $object->photo)
+ {
+ $fileimg = $dir.'/'.$object->photo;
+ $dirthumbs = $dir.'/thumbs';
+ dol_delete_file($fileimg);
+ dol_delete_dir_recursive($dirthumbs);
+ $object->photo = '';
+ }
+ if ($file_OK)
+ {
+ if (image_format_supported($_FILES['photo']['name']) > 0)
+ {
+ dol_mkdir($dir);
+
+ if (@is_dir($dir))
+ {
+ $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
+ $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
+
+ if (!$result > 0)
+ {
+ $errors[] = "ErrorFailedToSaveFile";
+ }
+ else
+ {
+ $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
+
+ // Create thumbs
+ $object->addThumbs($newfile);
+ }
+ }
+ }
+ else
+ {
+ $errors[] = "ErrorBadImageFormat";
+ }
+ }
+ else
+ {
+ 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
+ $errors[] = "ErrorFileSizeTooLarge";
+ break;
+ case 3: //uploaded file was only partially uploaded
+ $errors[] = "ErrorFilePartiallyUploaded";
+ break;
+ }
+ }
+
+ $object->oldcopy = clone $object;
+
+ $object->old_lastname = GETPOST("old_lastname", 'alpha');
+ $object->old_firstname = GETPOST("old_firstname", 'alpha');
+
+ $object->socid = GETPOST("socid", 'int');
+ $object->lastname = GETPOST("lastname", 'alpha');
+ $object->firstname = GETPOST("firstname", 'alpha');
+ $object->civility_code = GETPOST("civility_code", 'alpha');
+ $object->poste = GETPOST("poste", 'alpha');
+
+ $object->address = GETPOST("address", 'alpha');
+ $object->zip = GETPOST("zipcode", 'alpha');
+ $object->town = GETPOST("town", 'alpha');
+ $object->state_id = GETPOST("state_id", 'int');
+ $object->country_id = GETPOST("country_id", 'int');
+
+ $object->email = GETPOST("email", 'alpha');
+ $object->no_email = GETPOST("no_email", "int");
+ //$object->jabberid = GETPOST("jabberid", 'alpha');
+ //$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)) {
+ foreach ($socialnetworks as $key => $value) {
+ if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
+ $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
+ }
+ }
+ }
+ $object->phone_pro = GETPOST("phone_pro", 'alpha');
+ $object->phone_perso = GETPOST("phone_perso", 'alpha');
+ $object->phone_mobile = GETPOST("phone_mobile", 'alpha');
+ $object->fax = GETPOST("fax", 'alpha');
+ $object->priv = GETPOST("priv", 'int');
+ $object->note_public = GETPOST("note_public", 'none');
+ $object->note_private = GETPOST("note_private", 'none');
+ $object->roles = GETPOST("roles", 'array');
+
+ // Fill array 'array_options' with data from add form
+ $ret = $extrafields->setOptionalsFromPost(null, $object);
+ if ($ret < 0) $error++;
+
+ if (!$error)
+ {
+ $result = $object->update($contactid, $user);
+
+ if ($result > 0) {
+ // Categories association
+ $categories = GETPOST('contcats', 'array');
+ $object->setCategories($categories);
+
+ $no_email = GETPOST('no_email', 'int');
+
+ // Update mass emailing flag into table mailing_unsubscribe
+ if (GETPOSTISSET('no_email') && $object->email)
+ {
+ if ($no_email)
+ {
+ $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $obj = $db->fetch_object($resql);
+ $noemail = $obj->nb;
+ if (empty($noemail))
+ {
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')";
+ $resql = $db->query($sql);
+ }
+ }
+ }
+ else
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$db->escape($object->email)."' AND entity = ".$db->escape(getEntity('mailing', 0));
+ $resql = $db->query($sql);
+ }
+
+ $object->no_email = $no_email;
+ }
+
+ $object->old_lastname = '';
+ $object->old_firstname = '';
+ $action = 'view';
+ }
+ else
+ {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $action = 'edit';
+ }
@@ -447,104 +475,13 @@
-
- if (!$error) {
- $result = $object->update($contactid, $user);
-
- if ($result > 0) {
- // Categories association
- $categories = GETPOST('contcats', 'array');
- $object->setCategories($categories);
-
- // Update mass emailing flag into table mailing_unsubscribe
- if (GETPOSTISSET('no_email') && $object->email) {
- $no_email = GETPOST('no_email', 'int');
- $result = $object->setNoEmail($no_email);
- if ($result < 0) {
- $error++;
- setEventMessages($object->error, $object->errors, 'errors');
- }
- }
- } else {
- $error++;
- setEventMessages($object->error, $object->errors, 'errors');
- }
- }
- }
-
- if (!$error && empty($errors)) {
- if (!empty($backtopage)) {
- header("Location: ".$backtopage);
- exit;
- }
- $action = 'view';
- } else {
- $action = 'edit';
- }
- }
-
- if ($action == 'setprospectcontactlevel' && !empty($permissiontoadd)) {
- $object->fetch($id);
- $object->fk_prospectlevel = GETPOST('prospect_contact_level_id', 'alpha');
- $result = $object->update($object->id, $user);
- if ($result < 0) {
- setEventMessages($object->error, $object->errors, 'errors');
- }
- }
-
- // set communication status
- if ($action == 'setstcomm' && !empty($permissiontoadd)) {
- $object->fetch($id);
- $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcommcontact');
- $result = $object->update($object->id, $user);
- if ($result < 0) {
- setEventMessages($object->error, $object->errors, 'errors');
- }
- }
-
- // Update extrafields
- if ($action == "update_extras" && !empty($permissiontoadd)) {
- $object->fetch(GETPOST('id', 'int'));
-
- $attributekey = GETPOST('attribute', 'alpha');
- $attributekeylong = 'options_'.$attributekey;
-
- if (GETPOSTISSET($attributekeylong.'day') && GETPOSTISSET($attributekeylong.'month') && GETPOSTISSET($attributekeylong.'year')) {
- // This is properties of a date
- $object->array_options['options_'.$attributekey] = dol_mktime(GETPOST($attributekeylong.'hour', 'int'), GETPOST($attributekeylong.'min', 'int'), GETPOST($attributekeylong.'sec', 'int'), GETPOST($attributekeylong.'month', 'int'), GETPOST($attributekeylong.'day', 'int'), GETPOST($attributekeylong.'year', 'int'));
- //var_dump(dol_print_date($object->array_options['options_'.$attributekey]));exit;
- } else {
- $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, 'alpha');
- }
-
- $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
- if ($result > 0) {
- setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
- $action = 'view';
- } else {
- setEventMessages($object->error, $object->errors, 'errors');
- $action = 'edit_extras';
- }
- }
-
- // Update extrafields
- if ($action == 'update_extras' && $user->hasRight('societe', 'contact', 'creer')) {
- $object->oldcopy = dol_clone($object, 2);
-
- // Fill array 'array_options' with data from update form
- $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
- if ($ret < 0) {
- $error++;
- }
-
- if (!$error) {
- $result = $object->insertExtraFields('CONTACT_MODIFY');
- if ($result < 0) {
- setEventMessages($object->error, $object->errors, 'errors');
- $error++;
- }
- }
-
- if ($error) {
- $action = 'edit_extras';
- }
- }
-
- // Actions to send emails
+ }
+
+ if (!$error && empty($errors))
+ {
+ if (!empty($backtopage))
+ {
+ header("Location: ".$backtopage);
+ exit;
+ }
+ }
+ }
+
+ // Actions to send emails
@@ -561,0 +499,6 @@
+
+$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
+if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname;
+$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
+llxHeader('', $title, $help_url);
+
@@ -563 +505,0 @@
-$formadmin = new FormAdmin($db);
@@ -566,3 +508,6 @@
-$objsoc = new Societe($db);
-if ($socid > 0) {
- $objsoc->fetch($socid);
+$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
+
+if ($socid > 0)
+{
+ $objsoc = new Societe($db);
+ $objsoc->fetch($socid);
@@ -571,3 +516,13 @@
-$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
-if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
- $title = $object->lastname;
+if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
+{
+ // -----------------------------------------
+ // When used with CANVAS
+ // -----------------------------------------
+ if (empty($object->error) && $id)
+ {
+ $object = new Contact($db);
+ $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
@@ -575,78 +530,66 @@
-$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
-if (empty($object->id)) {
- $title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("NewContact") : $langs->trans("NewContactAddress"));
-}
-
-llxHeader('', $title, $help_url);
-
-$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
-
-if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
- // -----------------------------------------
- // When used with CANVAS
- // -----------------------------------------
- if (empty($object->error) && $id) {
- $object = new Contact($db);
- $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
-} else {
- // -----------------------------------------
- // When used in standard mode
- // -----------------------------------------
-
- // Confirm deleting contact
- if ($user->hasRight('societe', 'contact', 'supprimer')) {
- if ($action == 'delete') {
- print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1);
- }
- }
-
- /*
- * Onglets
- */
- $head = array();
- if ($id > 0) {
- // Si edition contact deja existant
- $object = new Contact($db);
- $res = $object->fetch($id, $user);
- if ($res < 0) {
- setEventMessages($object->error, $object->errors, 'errors');
- }
-
- $object->fetchRoles();
-
- // Show tabs
- $head = contact_prepare_head($object);
- }
-
- if ($user->hasRight('societe', 'contact', 'creer')) {
- if ($action == 'create') {
- /*
- * Fiche en mode creation
- */
- $object->canvas = $canvas;
-
- $object->state_id = GETPOST("state_id", "int");
-
- // We set country_id, country_code and label for the selected country
- $object->country_id = GETPOST("country_id") ? GETPOST("country_id", "int") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id);
- if ($object->country_id) {
- $tmparray = getCountry($object->country_id, 'all');
- $object->country_code = $tmparray['code'];
- $object->country = $tmparray['label'];
- }
-
- $linkback = '';
-
- print load_fiche_titre($title, $linkback, 'address');
-
- // Show errors
- dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
-
- if ($conf->use_javascript_ajax) {
- print "\n".''."\n";
- }
- if (!GETPOSTISSET("no_email") && !empty($object->email)) {
- $result = $object->getNoEmail();
- if ($result < 0) {
- setEventMessages($object->error, $object->errors, 'errors');
- }
- }
- print '';
- print ' | ';
- print '';
- print $form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'int') : getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS')), 1, false, (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2));
- print ' | ';
- print '
';
- }
-
- // Social network
- if (isModEnabled('socialnetworks')) {
- $object->showSocialNetwork($socialnetworks, ($conf->browser->layout == 'phone' ? 2 : 4));
- }
-
- // Visibility
- print ' | ';
- $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate"));
- print $form->selectarray('priv', $selectarray, (GETPOST("priv", 'alpha') ? GETPOST("priv", 'alpha') : $object->priv), 0);
- print ' |
';
-
- //Default language
- if (getDolGlobalInt('MAIN_MULTILANGS')) {
- print ''.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).' | '."\n";
- print img_picto('', 'language', 'class="pictofixedwidth"').$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 '
';
- }
+ if (!empty($conf->mailing->enabled))
+ {
+ $noemail = '';
+ if (empty($noemail) && !empty($object->email))
+ {
+ $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'";
+ //print $sql;
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $obj = $db->fetch_object($resql);
+ $noemail = $obj->nb;
+ }
+ }
+
+ print '';
+ print ' | ';
+ print ''.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'alpha') : $noemail), 1).' | ';
+ print '
';
+ }
+ print '';
+
+ if (!empty($conf->socialnetworks->enabled)) {
+ foreach ($socialnetworks as $key => $value) {
+ if ($value['active']) {
+ print '';
+ print ' | ';
+ print '';
+ print '';
+ print ' | ';
+ print '
';
+ } elseif (!empty($object->socialnetworks[$key])) {
+ print '';
+ }
+ }
+ }
+ // if (! empty($conf->socialnetworks->enabled))
+ // {
+ // // Jabber
+ // if (! empty($conf->global->SOCIALNETWORKS_JABBER))
+ // {
+ // print ' | ';
+ // print 'jabberid).'"> |
';
+ // }
+ // // Skype
+ // if (! empty($conf->global->SOCIALNETWORKS_SKYPE))
+ // {
+ // print ' | ';
+ // print 'skype).'"> |
';
+ // }
+ // // Twitter
+ // if (! empty($conf->global->SOCIALNETWORKS_TWITTER))
+ // {
+ // print ' | ';
+ // print 'twitter).'"> |
';
+ // }
+ // // Facebook
+ // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK))
+ // {
+ // print ' | ';
+ // print 'facebook).'"> |
';
+ // }
+ // // LinkedIn
+ // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN))
+ // {
+ // print ' | ';
+ // print 'linkedin).'"> |
';
+ // }
+ // }
+
+ // Visibility
+ print ' | ';
+ $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate"));
+ print $form->selectarray('priv', $selectarray, (GETPOST("priv", 'alpha') ?GETPOST("priv", 'alpha') : $object->priv), 0);
+ print ' |
';
@@ -878 +834 @@
- if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
+ if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
@@ -881 +837 @@
- print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), null, null, null, null, '90%');
+ print $form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), null, null, null, null, '90%');
@@ -885,14 +841,19 @@
- // Contact by default
- if (!empty($socid)) {
- print ''.$langs->trans("ContactByDefaultFor").' | ';
- print '';
- $contactType = $object->listeTypeContacts('external', '', 1);
- print $form->multiselectarray('roles', $contactType, array(), 0, 0, 'minwidth500');
- print ' |
';
- }
-
- // Other attributes
- $parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3, 'colspanvalue' => 3);
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
-
- print "
";
+ // Contact by default
+ if (!empty($socid)) {
+ print ''.$langs->trans("ContactByDefaultFor").' | ';
+ print '';
+ $contactType = $object->listeTypeContacts('external', '', 1);
+ print $form->multiselectarray('roles', $contactType);
+ print ' |
';
+ }
+
+ // Other attributes
+ $parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 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))
+ {
+ print $object->showOptionals($extrafields, 'edit', $parameters);
+ }
+
+ print "
";
@@ -902,42 +863,63 @@
- // Add personnal information
- print load_fiche_titre(''.$langs->trans("PersonalInformations").'
', '', '');
-
- print '';
-
- // Date To Birth
- print ' | ';
- $form = new Form($db);
- if ($object->birthday) {
- print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0);
- } else {
- print $form->selectDate('', 'birthday', 0, 0, 1, "perso", 1, 0);
- }
- print ' | ';
-
- print ': ';
- if (!empty($object->birthday_alert)) {
- print '';
- } else {
- print '';
- }
- print ' | ';
- print '
';
-
- print "
";
-
- print dol_get_fiche_end();
-
- print $form->buttonsSaveCancel("Add");
-
- print "";
- } elseif ($action == 'edit' && !empty($id)) {
- /*
- * Fiche en mode edition
- */
-
- // We set country_id, and country_code label of the chosen country
- if (GETPOSTISSET("country_id") || $object->country_id) {
- $tmparray = getCountry($object->country_id, 'all');
- $object->country_code = $tmparray['code'];
- $object->country = $tmparray['label'];
- }
+ // Add personnal information
+ print load_fiche_titre(''.$langs->trans("PersonalInformations").'
', '', '');
+
+ print '';
+
+ // Date To Birth
+ print ' | ';
+ $form = new Form($db);
+ if ($object->birthday)
+ {
+ print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0);
+ }
+ else
+ {
+ print $form->selectDate('', 'birthday', 0, 0, 1, "perso", 1, 0);
+ }
+ print ' | ';
+
+ print ': ';
+ if ($object->birthday_alert)
+ {
+ print '';
+ }
+ else
+ {
+ print '';
+ }
+ print ' | ';
+ print '
';
+
+ print "
";
+
+ dol_fiche_end();
+
+ print '';
+ print '';
+ if (!empty($backtopage))
+ {
+ print ' ';
+ print '';
+ }
+ else
+ {
+ print ' ';
+ print '';
+ }
+ print '
';
+
+ print "";
+ }
+ elseif ($action == 'edit' && !empty($id))
+ {
+ /*
+ * Fiche en mode edition
+ */
+
+ // We set country_id, and country_code label of the chosen country
+ if (isset($_POST["country_id"]) || $object->country_id)
+ {
+ $tmparray = getCountry($object->country_id, 'all');
+ $object->country_code = $tmparray['code'];
+ $object->country = $tmparray['label'];
+ }
@@ -951,2 +933,3 @@
- if ($conf->use_javascript_ajax) {
- print "\n".''."\n";
- }
- if (!GETPOSTISSET("no_email") && !empty($object->email)) {
- $result = $object->getNoEmail();
- if ($result < 0) {
- setEventMessages($object->error, $object->errors, 'errors');
- }
- }
- print '';
- print ' | ';
- print '';
- $useempty = (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2);
- print $form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'int') : $object->no_email), 1, false, $useempty);
- print ' | ';
- print '
';
- }
-
- // Social network
- if (isModEnabled('socialnetworks')) {
- $object->showSocialNetwork($socialnetworks, ($conf->browser->layout == 'phone' ? 2 : 4));
- }
-
- // Visibility
- print ' | ';
- $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate"));
- print $form->selectarray('priv', $selectarray, $object->priv, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth150');
- print ' |
';
-
- // Default language
- if (getDolGlobalInt('MAIN_MULTILANGS')) {
- print ''.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).' | '."\n";
- print img_picto('', 'language', 'class="pictofixedwidth"').$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 '
';
- }
-
- // Note Public
- print ' | ';
- $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3, '90%');
- print $doleditor->Create(1);
- print ' |
';
-
- // Note Private
- print ' | ';
- $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3, '90%');
- print $doleditor->Create(1);
- print ' |
';
-
- // Status
- print ''.$langs->trans("Status").' | ';
- print '';
- print $object->getLibStatut(4);
- print ' |
';
+ print '';
+
+ if (!empty($conf->socialnetworks->enabled)) {
+ foreach ($socialnetworks as $key => $value) {
+ if ($value['active']) {
+ print '';
+ print ' | ';
+ print '';
+ print '';
+ print ' | ';
+ print '
';
+ } elseif (!empty($object->socialnetworks[$key])) {
+ print '';
+ }
+ }
+ }
+ // if (! empty($conf->socialnetworks->enabled))
+ // {
+ // // Jabber ID
+ // if (! empty($conf->global->SOCIALNETWORKS_JABBER))
+ // {
+ // print ' | ';
+ // print 'jabberid).'"> |
';
+ // }
+ // // Skype
+ // if (! empty($conf->global->SOCIALNETWORKS_SKYPE))
+ // {
+ // print ' | ';
+ // print 'skype).'"> |
';
+ // }
+ // // Twitter
+ // if (! empty($conf->global->SOCIALNETWORKS_TWITTER))
+ // {
+ // print ' | ';
+ // print 'twitter).'"> |
';
+ // }
+ // // Facebook
+ // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK))
+ // {
+ // print ' | ';
+ // print 'facebook).'"> |
';
+ // }
+ // // LinkedIn
+ // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN))
+ // {
+ // print ' | ';
+ // print 'linkedin).'"> |
';
+ // }
+ // }
+
+ // Visibility
+ print ' | ';
+ $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate"));
+ print $form->selectarray('priv', $selectarray, $object->priv, 0);
+ print ' |
';
+
+ // Note Public
+ print ' | ';
+ $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ print $doleditor->Create(1);
+ print ' |
';
+
+ // Note Private
+ print ' | ';
+ $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ print $doleditor->Create(1);
+ print ' |
';
+
+ // Status
+ print ''.$langs->trans("Status").' | ';
+ print '';
+ print $object->getLibStatut(4);
+ print ' |
';
@@ -1174,2 +1179 @@
- if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
- $arrayselected = array();
+ if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
@@ -1184 +1188 @@
- print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('contcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%');
+ print $form->multiselectarray('contcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%');
@@ -1189,51 +1193,200 @@
- if (!empty($object->socid)) {
- print ''.$langs->trans("ContactByDefaultFor").' | ';
- print '';
- print $formcompany->showRoles("roles", $object, 'edit', $object->roles);
- print ' |
';
- }
-
- // Other attributes
- $parameters = array('colspan' => ' colspan="3"', 'cols'=> '3', 'colspanvalue'=> '3');
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
-
- $object->load_ref_elements();
-
- if (isModEnabled('commande')) {
- print ''.$langs->trans("ContactForOrders").' | ';
- print $object->ref_commande ? $object->ref_commande : (''.$langs->trans("NoContactForAnyOrder").'');
- print ' |
';
- }
-
- if (isModEnabled("propal")) {
- print ''.$langs->trans("ContactForProposals").' | ';
- print $object->ref_propal ? $object->ref_propal : (''.$langs->trans("NoContactForAnyProposal").'');
- print ' |
';
- }
-
- if (isModEnabled('contrat')) {
- print ''.$langs->trans("ContactForContracts").' | ';
- print $object->ref_contrat ? $object->ref_contrat : (''.$langs->trans("NoContactForAnyContract").'');
- print ' |
';
- }
-
- if (isModEnabled('facture')) {
- print ''.$langs->trans("ContactForInvoices").' | ';
- print $object->ref_facturation ? $object->ref_facturation : (''.$langs->trans("NoContactForAnyInvoice").'');
- print ' |
';
- }
-
- // Login Dolibarr
- print ''.$langs->trans("DolibarrLogin").' | ';
- if ($object->user_id) {
- $dolibarr_user = new User($db);
- $result = $dolibarr_user->fetch($object->user_id);
- print $dolibarr_user->getLoginUrl(1);
- } else {
- print ''.$langs->trans("NoDolibarrAccess").'';
- }
- print ' |
';
-
- // Photo
- print '';
- print ''.$langs->trans("PhotoFile").' | ';
+ if (!empty($object->socid)) {
+ print '
'.$langs->trans("ContactByDefaultFor").' | ';
+ print '';
+ print $formcompany->showRoles("roles", $object, 'edit', $object->roles);
+ print ' |
';
+ }
+
+ // Other attributes
+ $parameters = array('colspan' => ' colspan="3"', 'cols'=> '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))
+ {
+ print $object->showOptionals($extrafields, 'edit', $parameters);
+ }
+
+ $object->load_ref_elements();
+
+ if (!empty($conf->commande->enabled))
+ {
+ print ''.$langs->trans("ContactForOrders").' | ';
+ print $object->ref_commande ? $object->ref_commande : $langs->trans("NoContactForAnyOrder");
+ print ' |
';
+ }
+
+ if (!empty($conf->propal->enabled))
+ {
+ print ''.$langs->trans("ContactForProposals").' | ';
+ print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal");
+ print ' |
';
+ }
+
+ if (!empty($conf->contrat->enabled))
+ {
+ print ''.$langs->trans("ContactForContracts").' | ';
+ print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract");
+ print ' |
';
+ }
+
+ if (!empty($conf->facture->enabled))
+ {
+ print ''.$langs->trans("ContactForInvoices").' | ';
+ print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice");
+ print ' |
';
+ }
+
+ // Login Dolibarr
+ print ''.$langs->trans("DolibarrLogin").' | ';
+ if ($object->user_id)
+ {
+ $dolibarr_user = new User($db);
+ $result = $dolibarr_user->fetch($object->user_id);
+ print $dolibarr_user->getLoginUrl(1);
+ }
+ else print $langs->trans("NoDolibarrAccess");
+ print ' |
';
+
+ // Photo
+ print '';
+ print ''.$langs->trans("PhotoFile").' | ';
+ print '';
+ if ($object->photo) {
+ print $form->showphoto('contact', $object);
+ print " \n";
+ }
+ print '';
+
+ print ' | ';
+ print '
';
+
+ print '';
+
+ dol_fiche_end();
+
+ print '';
+ print '';
+ print ' ';
+ print '';
+ print '
';
+
+ print "";
+ }
+ }
+
+ if (!empty($id) && $action != 'edit' && $action != 'create')
+ {
+ $objsoc = new Societe($db);
+
+ // View mode
+
+ // Show errors
+ dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
+
+ dol_fiche_head($head, 'card', $title, -1, 'contact');
+
+ if ($action == 'create_user')
+ {
+ // Full firstname and lastname separated with a dot : firstname.lastname
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+ $login = dol_buildlogin($object->lastname, $object->firstname);
+
+ $generated_password = '';
+ if (!$ldap_sid) // TODO ldap_sid ?
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
+ $generated_password = getRandomPassword(false);
+ }
+ $password = $generated_password;
+
+ // Create a form array
+ $formquestion = array(
+ array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login),
+ array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password),
+ //array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External')))
+ );
+ $text = $langs->trans("ConfirmCreateContact").'
';
+ if (!empty($conf->societe->enabled))
+ {
+ if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser");
+ else $text .= $langs->trans("UserWillBeInternalUser");
+ }
+ print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes');
+ }
+
+ $linkback = ''.$langs->trans("BackToList").'';
+
+ $morehtmlref = '';
+ if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
+ {
+ $objsoc->fetch($object->socid);
+ // Thirdparty
+ $morehtmlref .= $langs->trans('ThirdParty').' : ';
+ if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
+ else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
+ }
+ $morehtmlref .= '
';
+
+ dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
+
+
+ print '';
+ print '
';
+
+ print '
';
+ print '
';
+
+ // Civility
+ print ''.$langs->trans("UserTitle").' | ';
+ print $object->getCivilityLabel();
+ print ' |
';
+
+ // Job / position
+ print ''.$langs->trans("PostOrFunction").' | '.$object->poste.' |
';
+
+ // Email
+ if (!empty($conf->mailing->enabled))
+ {
+ $langs->load("mails");
+ print ''.$langs->trans("NbOfEMailingsSend").' | ';
+ print ''.$object->getNbOfEMailings().' |
';
+ }
+
+ // Unsubscribe opt-out
+ if (!empty($conf->mailing->enabled))
+ {
+ //print 'eee'.$object->email;
+ $noemail = $object->no_email;
+ if (empty($noemail) && !empty($object->email))
+ {
+ $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$db->escape($object->email)."'";
+ //print $sql;
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $obj = $db->fetch_object($resql);
+ $noemail = $obj->nb;
+ }
+ }
+ print ''.$langs->trans("No_Email").' | '.yn($noemail).' |
';
+ }
+
+ print ''.$langs->trans("ContactVisibility").' | ';
+ print $object->LibPubPriv($object->priv);
+ print ' |
';
+
+ print '
';
+
+ print '
';
+ print '
';
+
+ print '
';
+ print '
';
+
+ // Categories
+ if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
+ print ''.$langs->trans("Categories").' | ';
@@ -1241,203 +1393,0 @@
- if ($object->photo) {
- print $form->showphoto('contact', $object);
- print "
\n";
- }
- print '';
-
- print '';
- print '
';
-
- print '
';
-
- print dol_get_fiche_end();
-
- print $form->buttonsSaveCancel();
-
- print "";
- }
- }
-
- // Select mail models is same action as presend
- if (GETPOST('modelselected', 'alpha')) {
- $action = 'presend';
- }
-
- // View mode
- if (!empty($id) && $action != 'edit' && $action != 'create') {
- $objsoc = new Societe($db);
-
- // Show errors
- dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
-
- print dol_get_fiche_head($head, 'card', $title, -1, 'contact');
-
- if ($action == 'create_user') {
- // Full firstname and lastname separated with a dot : firstname.lastname
- include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
- $login = dol_buildlogin($object->lastname, $object->firstname);
-
- $generated_password = '';
- if (empty($ldap_sid)) { // TODO ldap_sid ?
- require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
- $generated_password = getRandomPassword(false);
- }
- $password = $generated_password;
-
- // Create a form array
- $formquestion = array(
- array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login),
- array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password),
- //array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External')))
- );
- $text = $langs->trans("ConfirmCreateContact").'
';
- if (isModEnabled("societe")) {
- if ($object->socid > 0) {
- $text .= $langs->trans("UserWillBeExternalUser");
- } else {
- $text .= $langs->trans("UserWillBeInternalUser");
- }
- }
- print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes');
- }
-
- $linkback = '
'.$langs->trans("BackToList").'';
-
- $morehtmlref = '
';
- $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
- $morehtmlref .= '';
-
- $morehtmlref .= '
';
- if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) {
- $objsoc->fetch($object->socid);
- // Thirdparty
- if ($objsoc->id > 0) {
- $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
- } else {
- $morehtmlref .= ''.$langs->trans("ContactNotLinkedToCompany").'';
- }
- }
- $morehtmlref .= '
';
-
- dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
-
-
- print '
';
- print '
';
-
- print '
';
- print '
';
-
- // Civility
- print ''.$langs->trans("UserTitle").' | ';
- print $object->getCivilityLabel();
- print ' |
';
-
- // Job / position
- print ''.$langs->trans("PostOrFunction").' | '.$object->poste.' |
';
-
- // Email
- if (isModEnabled('mailing')) {
- $langs->load("mails");
- print ''.$langs->trans("NbOfEMailingsSend").' | ';
- print ''.$object->getNbOfEMailings().' |
';
- }
-
- // Unsubscribe opt-out
- if (isModEnabled('mailing')) {
- $result = $object->getNoEmail();
- if ($result < 0) {
- setEventMessages($object->error, $object->errors, 'errors');
- }
- print ''.$langs->trans("No_Email").' | ';
- if ($object->email) {
- print yn($object->no_email);
- } else {
- print ''.$langs->trans("EMailNotDefined").'';
- }
- print ' |
';
- }
-
- // Default language
- if (getDolGlobalInt('MAIN_MULTILANGS')) {
- require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
- 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) : '');
- print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"');
- print $labellang;
- print ' |
';
- }
-
- print ''.$langs->trans("ContactVisibility").' | ';
- print $object->LibPubPriv($object->priv);
- print ' |
';
-
- print '
';
- print '
';
-
- $object->fetch_thirdparty();
-
-
- print '
';
-
- print '
';
- print '
';
-
-
- if (getDolGlobalString('THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES')) {
- if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3) {
- // Level of prospect
- print '';
- print '';
- print ' | ';
- if ($action == 'editlevel') {
- $formcompany->formProspectContactLevel($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_prospectlevel, 'prospect_contact_level_id', 1);
- } else {
- print $object->getLibProspLevel();
- }
- print " | ";
- print '
';
-
- // Status of prospection
- $object->loadCacheOfProspStatus();
- print ''.$langs->trans("StatusProsp").' | '.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']);
- print ' ';
- print ' |
';
- }
- }
-
- // Categories
- if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
- print ''.$langs->trans("Categories").' | ';
- print '';
@@ -1448,71 +1398,74 @@
- if (!empty($object->socid)) {
- print ' |
'.$langs->trans("ContactByDefaultFor").' | ';
- print '';
- print $formcompany->showRoles("roles", $object, 'view', $object->roles);
- print ' |
';
- }
-
- // Other attributes
- $parameters = array('socid'=>$socid);
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
-
- $object->load_ref_elements();
-
- if (isModEnabled("propal")) {
- print ''.$langs->trans("ContactForProposals").' | ';
- print $object->ref_propal ? $object->ref_propal : ''.$langs->trans("NoContactForAnyProposal").'';
- print ' |
';
- }
-
- if (isModEnabled('commande') || isModEnabled("expedition")) {
- print '';
- if (isModEnabled("expedition")) {
- print $langs->trans("ContactForOrdersOrShipments");
- } else {
- print $langs->trans("ContactForOrders");
- }
- print ' | ';
- $none = ''.$langs->trans("NoContactForAnyOrder").'';
- if (isModEnabled("expedition")) {
- $none = ''.$langs->trans("NoContactForAnyOrderOrShipments").'';
- }
- print $object->ref_commande ? $object->ref_commande : $none;
- print ' |
';
- }
-
- if (isModEnabled('contrat')) {
- print ''.$langs->trans("ContactForContracts").' | ';
- print $object->ref_contrat ? $object->ref_contrat : ''.$langs->trans("NoContactForAnyContract").'';
- print ' |
';
- }
-
- if (isModEnabled('facture')) {
- print ''.$langs->trans("ContactForInvoices").' | ';
- print $object->ref_facturation ? $object->ref_facturation : ''.$langs->trans("NoContactForAnyInvoice").'';
- print ' |
';
- }
-
- print ''.$langs->trans("DolibarrLogin").' | ';
- if ($object->user_id) {
- $dolibarr_user = new User($db);
- $result = $dolibarr_user->fetch($object->user_id);
- print $dolibarr_user->getLoginUrl(-1);
- } else {
- //print ''.$langs->trans("NoDolibarrAccess").'';
- if (!$object->user_id && $user->hasRight('user', 'user', 'creer')) {
- print ''.img_picto($langs->trans("CreateDolibarrLogin"), 'add', 'class="pictofixedwidth"').$langs->trans("CreateDolibarrLogin").'';
- }
- }
- print ' |
';
-
- print "
";
-
- print '
';
- print '
';
-
- print dol_get_fiche_end();
-
- /*
- * Action bar
- */
- print '
';
+ if (!empty($object->socid)) {
+ print '
'.$langs->trans("ContactByDefaultFor").' | ';
+ print '';
+ print $formcompany->showRoles("roles", $object, 'view');
+ print ' |
';
+ }
+
+ // Other attributes
+ $cols = 3;
+ $parameters = array('socid'=>$socid);
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
+
+ $object->load_ref_elements();
+
+ if (!empty($conf->propal->enabled))
+ {
+ print '
'.$langs->trans("ContactForProposals").' | ';
+ print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal");
+ print ' |
';
+ }
+
+ if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled))
+ {
+ print '
';
+ if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); }
+ else print $langs->trans("ContactForOrders");
+ print ' | ';
+ $none = $langs->trans("NoContactForAnyOrder");
+ if (!empty($conf->expedition->enabled)) { $none = $langs->trans("NoContactForAnyOrderOrShipments"); }
+ print $object->ref_commande ? $object->ref_commande : $none;
+ print ' |
';
+ }
+
+ if (!empty($conf->contrat->enabled))
+ {
+ print '
'.$langs->trans("ContactForContracts").' | ';
+ print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract");
+ print ' |
';
+ }
+
+ if (!empty($conf->facture->enabled))
+ {
+ print '
'.$langs->trans("ContactForInvoices").' | ';
+ print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice");
+ print ' |
';
+ }
+
+ print '
'.$langs->trans("DolibarrLogin").' | ';
+ if ($object->user_id)
+ {
+ $dolibarr_user = new User($db);
+ $result = $dolibarr_user->fetch($object->user_id);
+ print $dolibarr_user->getLoginUrl(1);
+ }
+ else print $langs->trans("NoDolibarrAccess");
+ print ' |
';
+
+ print '
';
+ print $langs->trans("VCard").' | ';
+ print '';
+ print img_picto($langs->trans("Download"), 'vcard.png', 'class="paddingrightonly"');
+ print $langs->trans("Download");
+ print '';
+ print ' |
';
+
+ print "";
+
+ print '
';
+ print '
';
+
+ dol_fiche_end();
+
+ // Barre d'actions
+ print '
';
@@ -1522 +1475,2 @@
- if (empty($reshook) && $action != 'presend') {
+ if (empty($reshook) && $action != 'presend')
+ {
@@ -1524 +1478,2 @@
- if (!empty($object->email)) {
+ if (!empty($object->email))
+ {
@@ -1527 +1482,3 @@
- } else {
+ }
+ else
+ {
@@ -1533,51 +1490,38 @@
- if ($user->hasRight('societe', 'contact', 'creer')) {
- print '
'.$langs->trans('Modify').'';
- }
-
- // Activer
- if ($object->statut == 0 && $user->hasRight('societe', 'contact', 'creer')) {
- print '
'.$langs->trans("Reactivate").'';
- }
- // Desactiver
- if ($object->statut == 1 && $user->hasRight('societe', 'contact', 'creer')) {
- print '
'.$langs->trans("DisableUser").'';
- }
-
- // Delete
- if ($user->hasRight('societe', 'contact', 'supprimer')) {
- print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().($backtopage ? '&backtopage='.urlencode($backtopage) : ''), 'delete', $user->hasRight('societe', 'contact', 'supprimer'));
- }
- }
-
- print "
";
-
- //Select mail models is same action as presend
- if (GETPOST('modelselected')) {
- $action = 'presend';
- }
-
- if ($action != 'presend') {
- print '
';
-
- print '
';
-
- $MAXEVENT = 10;
-
- $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/contact/agenda.php?id='.$object->id);
-
- // List of actions on element
- include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
- $formactions = new FormActions($db);
- $somethingshown = $formactions->showactions($object, 'contact', $object->socid, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty
-
- print '
';
- }
-
- // Presend form
- $modelmail = 'contact';
- $defaulttopic = 'Information';
- $diroutput = $conf->societe->dir_output.'/contact/';
- $trackid = 'ctc'.$object->id;
-
- include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
- }
+ if ($user->rights->societe->contact->creer)
+ {
+ print '
'.$langs->trans('Modify').'';
+ }
+
+ if (!$object->user_id && $user->rights->user->user->creer)
+ {
+ print '
'.$langs->trans("CreateDolibarrLogin").'';
+ }
+
+ // Activer
+ if ($object->statut == 0 && $user->rights->societe->contact->creer)
+ {
+ print '
'.$langs->trans("Reactivate").'';
+ }
+ // Desactiver
+ if ($object->statut == 1 && $user->rights->societe->contact->creer)
+ {
+ print '
'.$langs->trans("DisableUser").'';
+ }
+
+ // Delete
+ if ($user->rights->societe->contact->supprimer)
+ {
+ print '
'.$langs->trans('Delete').'';
+ }
+ }
+
+ print "
";
+
+ // Presend form
+ $modelmail = 'contact';
+ $defaulttopic = 'Information';
+ $diroutput = $conf->contact->dir_output;
+ $trackid = 'con'.$object->id;
+
+ include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
+ }
--- /tmp/dsg/dolibarr/htdocs/contact/github_19.0.3_consumption.php
+++ /tmp/dsg/dolibarr/htdocs/contact/client_consumption.php
@@ -23 +23 @@
- * \file htdocs/contact/consumption.php
+ * \file htdocs/societe/consumption.php
@@ -25 +25 @@
- * \brief Add a tab on thirdparty view to list all products/services bought or sells by thirdparty
+ * \brief Add a tab on thirpdarty view to list all products/services bought or sells by thirdparty
@@ -28,2 +27,0 @@
-
-// Load Dolibarr environment
@@ -37,3 +35 @@
-$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
-$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
-
+// Security check
@@ -41,0 +38 @@
+$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
@@ -43,6 +40,2 @@
-if ($id > 0) {
- $object->fetch($id);
-}
-if (empty($object->thirdparty)) {
- $object->fetch_thirdparty();
-}
+if ($id > 0) $object->fetch($id);
+if (empty($object->thirdparty)) $object->fetch_thirdparty();
@@ -52,3 +45,3 @@
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST("sortfield", 'alpha');
+$sortorder = GETPOST("sortorder", 'alpha');
@@ -56,3 +49 @@
-if (empty($page) || $page == -1) {
- $page = 0;
-} // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
@@ -62,6 +53,2 @@
-if (!$sortorder) {
- $sortorder = 'DESC';
-}
-if (!$sortfield) {
- $sortfield = 'dateprint';
-}
+if (!$sortorder) $sortorder = 'DESC';
+if (!$sortfield) $sortfield = 'dateprint';
@@ -76,5 +63,6 @@
-if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
- $sref = '';
- $sprod_fulldescr = '';
- $year = '';
- $month = '';
+if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
+{
+ $sref = '';
+ $sprod_fulldescr = '';
+ $year = '';
+ $month = '';
@@ -84 +72 @@
-$type_element = GETPOSTISSET('type_element') ? GETPOST('type_element') : '';
+$type_element = GETPOSTISSET('type_element') ?GETPOST('type_element') : '';
@@ -91,2 +78,0 @@
-
-$result = restrictedArea($user, 'contact', $object->id, 'socpeople&societe');
@@ -101,3 +87 @@
-if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-}
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -114 +98 @@
-$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
+$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
@@ -118 +102,2 @@
-if (empty($id)) {
+if (empty($id))
+{
@@ -124 +109 @@
-print dol_get_fiche_head($head, 'consumption', $langs->trans("ContactsAddresses"), -1, 'contact');
+dol_fiche_head($head, 'consumption', $langs->trans("ContactsAddresses"), -1, 'contact');
@@ -128,13 +113,8 @@
-$morehtmlref = '';
-$morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
-$morehtmlref .= '';
-
-$morehtmlref .= '';
-if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) {
- $objsoc->fetch($socid);
- // Thirdparty
- if ($objsoc->id > 0) {
- $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
- } else {
- $morehtmlref .= '
'.$langs->trans("ContactNotLinkedToCompany").'';
- }
+$morehtmlref = '
';
+if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
+{
+ $objsoc->fetch($socid);
+ // Thirdparty
+ $morehtmlref .= $langs->trans('ThirdParty').' : ';
+ if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
+ else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
@@ -156 +136,2 @@
-if ($object->thirdparty->client) {
+if ($object->thirdparty->client)
+{
@@ -158,19 +139,10 @@
- if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) {
- $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals');
- }
- if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) {
- $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders');
- }
- if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) {
- $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices');
- }
- if (isModEnabled('contrat') && $user->hasRight('contrat', 'lire')) {
- $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts');
- }
-}
-
-if (isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'lire')) {
- $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
-}
-
-if ($object->thirdparty->fournisseur) {
+ 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 ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
+
+if ($object->thirdparty->fournisseur)
+{
@@ -178,6 +150,2 @@
- if ((isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) {
- $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
- }
- if ((isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'commande', 'lire')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire'))) {
- $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders');
- }
+ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
+ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order']= $langs->transnoentitiesnoconv('SuppliersOrders');
@@ -186 +154 @@
- // if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals');
+ // if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals');
@@ -193 +161 @@
-print dol_get_fiche_end();
+dol_fiche_end();
@@ -201 +169,2 @@
-if ($type_element == 'fichinter') { // Customer : show products from invoices
+if ($type_element == 'fichinter')
+{ // Customer : show products from invoices
@@ -206,4 +175,4 @@
- $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid';
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople = '.((int) $object->id);
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)";
- $where = ' WHERE f.entity IN ('.getEntity('intervention').')';
+ $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid';
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id;
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)";
+ $where = ' WHERE f.entity IN ('.getEntity('ficheinter').')';
@@ -212 +181,3 @@
-} elseif ($type_element == 'invoice') { // Customer : show products from invoices
+}
+elseif ($type_element == 'invoice')
+{ // Customer : show products from invoices
@@ -217,4 +188,4 @@
- $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid';
- $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople = '.((int) $object->id);
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)";
+ $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid';
+ $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id;
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)";
@@ -225 +196,3 @@
-} elseif ($type_element == 'propal') {
+}
+elseif ($type_element == 'propal')
+{
@@ -230,4 +203,4 @@
- $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid';
- $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople = '.((int) $object->id);
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)";
+ $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid';
+ $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)";
@@ -235 +208 @@
- $dateprint = 'c.datep';
+ $datePrint = 'c.datep';
@@ -238 +211,3 @@
-} elseif ($type_element == 'order') {
+}
+elseif ($type_element == 'order')
+{
@@ -243,4 +218,4 @@
- $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid';
- $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople = '.((int) $object->id);
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)";
+ $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid';
+ $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)";
@@ -251 +226,3 @@
-} elseif ($type_element == 'supplier_invoice') { // Supplier : Show products from invoices.
+}
+elseif ($type_element == 'supplier_invoice')
+{ // Supplier : Show products from invoices.
@@ -256,4 +233,4 @@
- $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid';
- $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople = '.((int) $object->id);
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)";
+ $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid';
+ $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id;
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)";
@@ -264,13 +241,16 @@
- //} elseif ($type_element == 'supplier_proposal') {
- // require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
- // $documentstatic=new SupplierProposal($db);
- // $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, ';
- // $tables_from = MAIN_DB_PREFIX."supplier_proposal as c,".MAIN_DB_PREFIX."supplier_proposaldet as d";
- // $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid);
- // $where.= " AND d.fk_supplier_proposal = c.rowid";
- // $where.= " AND c.entity = ".$conf->entity;
- // $dateprint = 'c.date_valid';
- // $doc_number='c.ref';
- // $thirdTypeSelect='supplier';
- //}
-} elseif ($type_element == 'supplier_order') { // Supplier : Show products from orders.
+}
+//elseif ($type_element == 'supplier_proposal')
+//{
+// require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
+// $documentstatic=new SupplierProposal($db);
+// $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, ';
+// $tables_from = MAIN_DB_PREFIX."supplier_proposal as c,".MAIN_DB_PREFIX."supplier_proposaldet as d";
+// $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid;
+// $where.= " AND d.fk_supplier_proposal = c.rowid";
+// $where.= " AND c.entity = ".$conf->entity;
+// $dateprint = 'c.date_valid';
+// $doc_number='c.ref';
+// $thirdTypeSelect='supplier';
+//}
+elseif ($type_element == 'supplier_order')
+{ // Supplier : Show products from orders.
@@ -281,4 +261,4 @@
- $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid';
- $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople = '.((int) $object->id);
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)";
+ $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid';
+ $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)";
@@ -289 +269,3 @@
-} elseif ($type_element == 'contract') { // Order
+}
+elseif ($type_element == 'contract')
+{ // Order
@@ -295,4 +277,4 @@
- $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid';
- $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople = '.((int) $object->id);
- $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)";
+ $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid';
+ $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
+ $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)";
@@ -308 +290,2 @@
-if (!empty($sql_select)) {
+if (!empty($sql_select))
+{
@@ -311,12 +294,4 @@
- if ($type_element != 'fichinter' && $type_element != 'contract' && $type_element != 'supplier_proposal') {
- $sql .= ', d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
- }
- if ($type_element == 'supplier_proposal') {
- $sql .= ', d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
- }
- if ($type_element == 'contract') {
- $sql .= ', d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
- }
- if ($type_element != 'fichinter') {
- $sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity';
- }
+ if ($type_element != 'fichinter' && $type_element != 'contract' && $type_element != 'supplier_proposal') $sql .= ', d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
+ if ($type_element == 'supplier_proposal') $sql .= ', d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
+ if ($type_element == 'contract') $sql .= ', d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, ';
+ if ($type_element != 'fichinter') $sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity';
@@ -324,3 +299 @@
- if ($type_element != 'fichinter') {
- $sql .= ", p.ref as prod_ref, p.label as product_label";
- }
+ if ($type_element != 'fichinter') $sql .= ", p.ref as prod_ref, p.label as product_label";
@@ -328 +301 @@
- // if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid ';
+ // if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid ';
@@ -331,12 +304,7 @@
- if ($sref) {
- $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'";
- }
- if ($sprod_fulldescr) {
- $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'";
- if (GETPOST('type_element') != 'fichinter') {
- $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'";
- }
- if (GETPOST('type_element') != 'fichinter') {
- $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'";
- }
- $sql .= ")";
+ if ($sref) $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'";
+ if ($sprod_fulldescr)
+ {
+ $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'";
+ if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'";
+ if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'";
+ $sql .= ")";
@@ -354,2 +322,2 @@
- $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef");
- $disabled = 1;
+ $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef");
+ $disabled = 1;
@@ -360 +328 @@
-$button = '
';
+$button = '
';
@@ -371,2 +339,3 @@
-$num=0;
-if ($sql_select) {
+
+if ($sql_select)
+{
@@ -374,3 +343 @@
- if (!$resql) {
- dol_print_error($db);
- }
+ if (!$resql) dol_print_error($db);
@@ -380,65 +347,51 @@
- $param = "&socid=".urlencode($socid)."&type_element=".urlencode($type_element)."&id=".urlencode($id);
- if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
- $param .= '&contextpage='.urlencode($contextpage);
- }
- if ($limit > 0 && $limit != $conf->liste_limit) {
- $param .= '&limit='.((int) $limit);
- }
- if ($sprod_fulldescr) {
- $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr);
- }
- if ($sref) {
- $param .= "&sref=".urlencode($sref);
- }
- if ($month) {
- $param .= "&month=".urlencode($month);
- }
- if ($year) {
- $param .= "&year=".urlencode($year);
- }
- if ($optioncss != '') {
- $param .= '&optioncss='.urlencode($optioncss);
- }
-
- print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit);
-
- print '
';
- print '
'."\n";
-
- // Filters
- print '';
- print '';
- print '';
- print ' | ';
- print ''; // date
- print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle');
- print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 1);
- print ' | ';
- print '';
- print ' | ';
- print '';
- print '';
- print ' | ';
- print ''; // TODO: Add filters !
- print ' | ';
- print '';
- print ' | ';
- print '';
- print ' | ';
- print '';
- $searchpicto = $form->showFilterAndCheckAddButtons(0);
- print $searchpicto;
- print ' | ';
- print '
';
-
- // Titles with sort buttons
- print '';
- print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left ');
- print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center ');
- print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_statut', '', $param, '', $sortfield, $sortorder, 'center ');
- print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left ');
- print_liste_field_titre('ContactType', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left ');
- print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right ');
- print_liste_field_titre('TotalHT', $_SERVER['PHP_SELF'], 'total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
- print_liste_field_titre('UnitPrice', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
- print "
\n";
+ $param = "&socid=".urlencode($socid)."&type_element=".urlencode($type_element);
+ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
+ if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
+ if ($sprod_fulldescr) $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr);
+ if ($sref) $param .= "&sref=".urlencode($sref);
+ if ($month) $param .= "&month=".urlencode($month);
+ if ($year) $param .= "&year=".urlencode($year);
+ if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
+
+ print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit);
+
+ print '';
+ print '
'."\n";
+
+ // Filters
+ print '';
+ print '';
+ print '';
+ print ' | ';
+ print ''; // date
+ print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle');
+ $formother->select_year($year ? $year : -1, 'year', 1, 20, 1);
+ print ' | ';
+ print '';
+ print ' | ';
+ print '';
+ print '';
+ print ' | ';
+ print ''; // TODO: Add filters !
+ print ' | ';
+ print '';
+ print ' | ';
+ print '';
+ print ' | ';
+ print '';
+ $searchpicto = $form->showFilterAndCheckAddButtons(0);
+ print $searchpicto;
+ print ' | ';
+ print '
';
+
+ // Titles with sort buttons
+ print '';
+ print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left ');
+ print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center ');
+ print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_statut', '', $param, '', $sortfield, $sortorder, 'center ');
+ print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left ');
+ print_liste_field_titre('ContactType', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left ');
+ print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right ');
+ print_liste_field_titre('TotalHT', $_SERVER['PHP_SELF'], 'total_ht', '', $param, '', $sortfield, $sortorder, 'right ');
+ print_liste_field_titre('UnitPrice', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
+ print "
\n";
@@ -448,3 +401,2 @@
- $total_qty = 0;
- $total_ht = 0;
- while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit)) {
+ while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit))
+ {
@@ -454 +405,0 @@
-
@@ -455,0 +407 @@
+ $documentstatic->fk_status = $objp->status;
@@ -458 +409,0 @@
-
@@ -462,3 +413 @@
- if (is_object($documentstaticline)) {
- $documentstaticline->statut = $objp->status;
- }
+ if (is_object($documentstaticline)) $documentstaticline->statut = $objp->status;
@@ -474 +423,2 @@
- if ($type_element == 'contract') {
+ if ($type_element == 'contract')
+ {
@@ -476 +426,3 @@
- } else {
+ }
+ else
+ {
@@ -484,3 +436 @@
- $text = '';
- $description = '';
- $type = 0;
+ $text = ''; $description = ''; $type = 0;
@@ -489 +439,2 @@
- if ($objp->fk_product > 0) {
+ if ($objp->fk_product > 0)
+ {
@@ -500 +451,2 @@
- if ($objp->fk_product > 0) {
+ if ($objp->fk_product > 0)
+ {
@@ -502 +454,2 @@
- if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ {
@@ -508,7 +461,4 @@
- if (empty($newlang) && GETPOST('lang_id', 'aZ09')) {
- $newlang = GETPOST('lang_id', 'aZ09');
- }
- if (empty($newlang)) {
- $newlang = $object->default_lang;
- }
- if (!empty($newlang)) {
+ if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
+ if (empty($newlang)) $newlang = $object->default_lang;
+ if (!empty($newlang))
+ {
@@ -520 +470,3 @@
- } else {
+ }
+ else
+ {
@@ -525,4 +477,5 @@
- $description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($objp->description));
- }
-
- if (($objp->info_bits & 2) == 2) {
+ $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($objp->description));
+ }
+
+ if (($objp->info_bits & 2) == 2)
+ {
@@ -532,7 +485,3 @@
- if ($objp->description == '(DEPOSIT)') {
- $txt = $langs->trans("Deposit");
- } elseif ($objp->description == '(EXCESS RECEIVED)') {
- $txt = $langs->trans("ExcessReceived");
- } elseif ($objp->description == '(EXCESS PAID)') {
- $txt = $langs->trans("ExcessPaid");
- }
+ if ($objp->description == '(DEPOSIT)') $txt = $langs->trans("Deposit");
+ elseif ($objp->description == '(EXCESS RECEIVED)') $txt = $langs->trans("ExcessReceived");
+ elseif ($objp->description == '(EXCESS PAID)') $txt = $langs->trans("ExcessPaid");
@@ -541,3 +490,5 @@
- print '';
- if ($objp->description) {
- if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) {
+ print '';
+ if ($objp->description)
+ {
+ if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0)
+ {
@@ -546,3 +497,4 @@
- echo($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
- }
- if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) {
+ echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
+ }
+ if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0)
+ {
@@ -551,2 +503,4 @@
- echo($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0));
- } elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) {
+ echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0));
+ }
+ elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0)
+ {
@@ -555,2 +509,4 @@
- echo($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0));
- } elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) {
+ echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0));
+ }
+ elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0)
+ {
@@ -559 +515 @@
- echo($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
+ echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
@@ -561,5 +517,5 @@
- if (getDolGlobalString('INVOICE_ADD_DEPOSIT_DATE')) {
- echo ' ('.dol_print_date($discount->datec).')';
- }
- } else {
- echo($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description);
+ if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')';
+ }
+ else
+ {
+ echo ($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description);
@@ -568 +524,3 @@
- } else {
+ }
+ else
+ {
@@ -576 +534,2 @@
- if (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) {
+ if (!empty($conf->global->PRODUIT_DESC_IN_FORM))
+ {
@@ -580,6 +539,4 @@
- if (!empty($objp->label) || !empty($objp->description)) {
- if ($type == 1) {
- $text = img_object($langs->trans('Service'), 'service');
- } else {
- $text = img_object($langs->trans('Product'), 'product');
- }
+ if (!empty($objp->label) || !empty($objp->description))
+ {
+ if ($type == 1) $text = img_object($langs->trans('Service'), 'service');
+ else $text = img_object($langs->trans('Product'), 'product');
@@ -613,3 +570,3 @@
- if (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE'))
- {
- $prodreftxt .= (!empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):'';
+ if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
+ {
+ $prodreftxt .= (! empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):'';
@@ -637 +594 @@
- print ' | ';
+ print ' | ';
@@ -649,13 +606,13 @@
- print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', '');
-
- print ''."\n";
- // Titles with sort buttons
- print '';
- print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left ');
- print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center ');
- print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_status', '', $param, '', $sortfield, $sortorder, 'center ');
- print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left ');
- print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right ');
- print "
\n";
-
- print ''.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).' |
';
+ print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', '');
+
+ print ''."\n";
+ // Titles with sort buttons
+ print '';
+ print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left ');
+ print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center ');
+ print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_status', '', $param, '', $sortfield, $sortorder, 'center ');
+ print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left ');
+ print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right ');
+ print "
\n";
+
+ print ''.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).' |
';
@@ -665,5 +622,5 @@
- print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', '');
-
- print ''."\n";
-
- print ''.$langs->trans("FeatureNotYetAvailable").' |
';
+ print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', '');
+
+ print ''."\n";
+
+ print ''.$langs->trans("FeatureNotYetAvailable").' |
';
--- /tmp/dsg/dolibarr/htdocs/contact/github_19.0.3_document.php
+++ /tmp/dsg/dolibarr/htdocs/contact/client_document.php
@@ -2,3 +2,3 @@
-/* Copyright (C) 2014 Alexandre Spangaro
- * Copyright (C) 2015-2021 Frederic France
- * Copyright (C) 2017 Regis Houssin
+/* Copyright (C) 2014 Alexandre Spangaro
+ * Copyright (C) 2015 Frederic France
+ * Copyright (C) 2017 Regis Houssin
@@ -26,2 +25,0 @@
-
-// Load Dolibarr environment
@@ -38 +35,0 @@
-// Get parameters
@@ -49,4 +46,5 @@
-if (!empty($canvas)) {
- require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
- $objcanvas = new Canvas($db, $action);
- $objcanvas->getCanvas('contact', 'contactcard', $canvas);
+if (!empty($canvas))
+{
+ require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
+ $objcanvas = new Canvas($db, $action);
+ $objcanvas->getCanvas('contact', 'contactcard', $canvas);
@@ -53,0 +52,4 @@
+
+// Security check
+if ($user->socid) $socid = $user->socid;
+$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission
@@ -57,2 +59,2 @@
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
+$sortfield = GETPOST("sortfield", 'alpha');
+$sortorder = GETPOST("sortorder", 'alpha');
@@ -60,3 +62 @@
-if (empty($page) || $page == -1) {
- $page = 0;
-} // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
@@ -67,6 +67,2 @@
-if (getDolGlobalString('MAIN_DOC_SORT_FIELD')) {
- $sortfield = $conf->global->MAIN_DOC_SORT_FIELD;
-}
-if (getDolGlobalString('MAIN_DOC_SORT_ORDER')) {
- $sortorder = $conf->global->MAIN_DOC_SORT_ORDER;
-}
+if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield = $conf->global->MAIN_DOC_SORT_FIELD; }
+if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; }
@@ -74,6 +70,2 @@
-if (!$sortorder) {
- $sortorder = "ASC";
-}
-if (!$sortfield) {
- $sortfield = "name";
-}
+if (!$sortorder) $sortorder = "ASC";
+if (!$sortfield) $sortfield = "name";
@@ -81,3 +73 @@
-if ($id > 0) {
- $object->fetch($id);
-}
+if ($id > 0) $object->fetch($id);
@@ -87,11 +76,0 @@
-
-// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$hookmanager->initHooks(array('contactdocument'));
-
-// Security check
-if ($user->socid) {
- $socid = $user->socid;
-}
-$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission
-
-$permissiontoadd = $user->hasRight('societe', 'contact', 'creer'); // Used by the include of actions_dellink.inc.php
@@ -113,4 +92,2 @@
-$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
-if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
- $title = $object->lastname;
-}
+$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
+if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname;
@@ -118 +95 @@
-llxHeader('', $title, $help_url);
+llxHeader('', $title, $helpurl);
@@ -120,3 +97,4 @@
-if ($object->id) {
- $head = contact_prepare_head($object);
- $title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
+if ($object->id)
+{
+ $head = contact_prepare_head($object);
+ $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
@@ -124 +102 @@
- print dol_get_fiche_head($head, 'documents', $title, -1, 'contact');
+ dol_fiche_head($head, 'documents', $title, -1, 'contact');
@@ -127,6 +105,7 @@
- // Build file list
- $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
- $totalsize = 0;
- foreach ($filearray as $key => $file) {
- $totalsize += $file['size'];
- }
+ // Build file list
+ $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
+ $totalsize = 0;
+ foreach ($filearray as $key => $file)
+ {
+ $totalsize += $file['size'];
+ }
@@ -134 +113 @@
- $linkback = ''.$langs->trans("BackToList").'';
+ $linkback = ''.$langs->trans("BackToList").'';
@@ -136,3 +115,11 @@
- $morehtmlref = '';
- $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
- $morehtmlref .= '';
+ $morehtmlref = '';
+ if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
+ {
+ $objsoc = new Societe($db);
+ $objsoc->fetch($object->socid);
+ // Thirdparty
+ $morehtmlref .= $langs->trans('ThirdParty').' : ';
+ if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1);
+ else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
+ }
+ $morehtmlref .= '
';
@@ -140,12 +127 @@
- $morehtmlref .= '';
- if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) {
- $objsoc = new Societe($db);
- $objsoc->fetch($object->socid);
- // Thirdparty
- if ($objsoc->id > 0) {
- $morehtmlref .= $objsoc->getNomUrl(1);
- } else {
- $morehtmlref .= ''.$langs->trans("ContactNotLinkedToCompany").'';
- }
- }
- $morehtmlref .= '
';
+ dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
@@ -153 +129 @@
- dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
+ print '';
@@ -155 +131,2 @@
- print '
';
+ print '
';
+ print '
';
@@ -157,2 +134,8 @@
- print '';
- print '';
+ // Company
+ /*
+ if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
+ {
+ if ($object->socid > 0)
+ {
+ $objsoc = new Societe($db);
+ $objsoc->fetch($object->socid);
@@ -160,8 +143,2 @@
- // Company
- /*
- if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
- {
- if ($object->socid > 0)
- {
- $objsoc = new Societe($db);
- $objsoc->fetch($object->socid);
+ print ''.$langs->trans("ThirdParty").' | '.$objsoc->getNomUrl(1).' |
';
+ }
@@ -169,2 +146,7 @@
- print ''.$langs->trans("ThirdParty").' | '.$objsoc->getNomUrl(1).' |
';
- }
+ else
+ {
+ print ''.$langs->trans("ThirdParty").' | ';
+ print $langs->trans("ContactNotLinkedToCompany");
+ print ' |
';
+ }
+ }*/
@@ -172,7 +154,4 @@
- else
- {
- print ''.$langs->trans("ThirdParty").' | ';
- print $langs->trans("ContactNotLinkedToCompany");
- print ' |
';
- }
- }*/
+ // Civility
+ print ''.$langs->trans("UserTitle").' | ';
+ print $object->getCivilityLabel();
+ print ' |
';
@@ -180,4 +159,3 @@
- // Civility
- print ''.$langs->trans("UserTitle").' | ';
- print $object->getCivilityLabel();
- print ' |
';
+ print ''.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
+ print ''.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize, 1, 1).' |
';
+ print '
';
@@ -185,3 +163 @@
- print ''.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print ''.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize, 1, 1).' |
';
- print '
';
+ print '
';
@@ -189 +165 @@
- print '
';
+ dol_fiche_end();
@@ -191,7 +167,5 @@
- print dol_get_fiche_end();
-
- $modulepart = 'contact';
- $permissiontoadd = $user->hasRight('societe', 'contact', 'creer');
- $permtoedit = $user->hasRight('societe', 'contact', 'creer');
- $param = '&id='.$object->id;
- include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
+ $modulepart = 'contact';
+ $permission = $user->rights->societe->contact->creer;
+ $permtoedit = $user->rights->societe->contact->creer;
+ $param = '&id='.$object->id;
+ include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
@@ -199 +173 @@
- print $langs->trans("ErrorUnknown");
+ print $langs->trans("ErrorUnknown");
--- /tmp/dsg/dolibarr/htdocs/contact/github_19.0.3_info.php
+++ /tmp/dsg/dolibarr/htdocs/contact/client_info.php
@@ -26,2 +25,0 @@
-
-// Load Dolibarr environment
@@ -39,3 +37 @@
-if ($user->socid) {
- $socid = $user->socid;
-}
+if ($user->socid) $socid = $user->socid;
@@ -54 +50 @@
-$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
+$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
@@ -58 +54,2 @@
-if ($id > 0) {
+if ($id > 0)
+{
@@ -66 +63 @@
- print dol_get_fiche_head($head, 'info', $title, -1, 'contact');
+ dol_fiche_head($head, 'info', $title, -1, 'contact');
@@ -83 +80 @@
- print dol_get_fiche_end();
+ dol_fiche_end();
--- /tmp/dsg/dolibarr/htdocs/contact/github_19.0.3_ldap.php
+++ /tmp/dsg/dolibarr/htdocs/contact/client_ldap.php
@@ -3 +3 @@
- * Copyright (C) 2006-2021 Regis Houssin
+ * Copyright (C) 2006-2017 Regis Houssin
@@ -25 +24,0 @@
-// Load Dolibarr environment
@@ -40,3 +39 @@
-if ($user->socid) {
- $socid = $user->socid;
-}
+if ($user->socid) $socid = $user->socid;
@@ -46 +43,2 @@
-if ($id > 0) {
+if ($id > 0)
+{
@@ -55 +53,2 @@
-if ($action == 'dolibarr2ldap') {
+if ($action == 'dolibarr2ldap')
+{
@@ -67 +66,2 @@
- if ($result >= 0) {
+ if ($result >= 0)
+ {
@@ -70 +70,3 @@
- } else {
+ }
+ else
+ {
@@ -83 +85 @@
-$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
+$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
@@ -89 +91 @@
-print dol_get_fiche_head($head, 'ldap', $title, -1, 'contact');
+dol_fiche_head($head, 'ldap', $title, -1, 'contact');
@@ -101 +103,2 @@
-if ($object->socid > 0) {
+if ($object->socid > 0)
+{
@@ -106 +109,3 @@
-} else {
+}
+else
+{
@@ -118 +123 @@
-print 'LDAP '.$langs->trans("LDAPContactDn").' | '.getDolGlobalString('LDAP_CONTACT_DN')." |
\n";
+print 'LDAP '.$langs->trans("LDAPContactDn").' | '.$conf->global->LDAP_CONTACT_DN." |
\n";
@@ -121 +126 @@
-print 'LDAP '.$langs->trans("LDAPNamingAttribute").' | '.getDolGlobalString('LDAP_KEY_CONTACTS')." |
\n";
+print 'LDAP '.$langs->trans("LDAPNamingAttribute").' | '.$conf->global->LDAP_KEY_CONTACTS." |
\n";
@@ -124,3 +129,3 @@
-print 'LDAP '.$langs->trans("LDAPPrimaryServer").' | '.getDolGlobalString('LDAP_SERVER_HOST')." |
\n";
-print 'LDAP '.$langs->trans("LDAPSecondaryServer").' | '.getDolGlobalString('LDAP_SERVER_HOST_SLAVE')." |
\n";
-print 'LDAP '.$langs->trans("LDAPServerPort").' | '.getDolGlobalString('LDAP_SERVER_PORT')." |
\n";
+print 'LDAP '.$langs->trans("LDAPPrimaryServer").' | '.$conf->global->LDAP_SERVER_HOST." |
\n";
+print 'LDAP '.$langs->trans("LDAPSecondaryServer").' | '.$conf->global->LDAP_SERVER_HOST_SLAVE." |
\n";
+print 'LDAP '.$langs->trans("LDAPServerPort").' | '.$conf->global->LDAP_SERVER_PORT." |
\n";
@@ -132 +137 @@
-print dol_get_fiche_end();
+dol_fiche_end();
@@ -136,2 +141,3 @@
- * Action bar
- */
+ * Barre d'actions
+ */
+
@@ -140 +146,2 @@
-if (getDolGlobalString('LDAP_CONTACT_ACTIVE') && getDolGlobalInt('LDAP_CONTACT_ACTIVE') != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
+if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr')
+{
@@ -146,3 +153 @@
-if (getDolGlobalString('LDAP_CONTACT_ACTIVE') && getDolGlobalInt('LDAP_CONTACT_ACTIVE') != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
- print "
\n";
-}
+if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') print "
\n";
@@ -165 +170,2 @@
-if ($result > 0) {
+if ($result > 0)
+{
@@ -175,4 +181,8 @@
- if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) {
- if (!is_array($records)) {
- print ''.$langs->trans("ErrorFailedToReadLDAP").' |
';
- } else {
+ if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0))
+ {
+ if (!is_array($records))
+ {
+ print ''.$langs->trans("ErrorFailedToReadLDAP").' |
';
+ }
+ else
+ {
@@ -181,2 +191,4 @@
- } else {
- print ''.$langs->trans("LDAPRecordNotFound").' (dn='.dol_escape_htmltag($dn).' - search='.dol_escape_htmltag($search).') |
';
+ }
+ else
+ {
+ print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.') |
';
@@ -186 +198,4 @@
-} else {
+ $ldap->close();
+}
+else
+{
--- /tmp/dsg/dolibarr/htdocs/contact/github_19.0.3_list.php
+++ /tmp/dsg/dolibarr/htdocs/contact/client_list.php
@@ -14 +13,0 @@
- * Copyright (C) 2020 Open-Dsi
@@ -36,2 +34,0 @@
-
-// Load Dolibarr environment
@@ -49,2 +46 @@
-// Get parameters
-$action = GETPOST('action', 'aZ09');
+$action = GETPOST('action', 'alpha');
@@ -55,6 +51 @@
-$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'contactlist';
-$mode = GETPOST('mode', 'alpha');
-
-if ($contextpage == 'poslist') {
- $_GET['optioncss'] = 'print';
-}
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contactlist';
@@ -66,3 +57 @@
-if ($user->socid) {
- $socid = $user->socid;
-}
+if ($user->socid) $socid = $user->socid;
@@ -71 +60 @@
-$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
+$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
@@ -75 +64 @@
-$search_id = GETPOST("search_id", "int");
+$search_id = trim(GETPOST("search_id", "int"));
@@ -80 +68,0 @@
-$search_societe_alias = GETPOST("search_societe_alias", 'alpha');
@@ -87,6 +75,2 @@
-if (isModEnabled('mailing')) {
- $search_no_email = GETPOSTISSET("search_no_email") ? GETPOST("search_no_email", 'int') : -1;
-} else {
- $search_no_email = -1;
-}
-if (isModEnabled('socialnetworks')) {
+$search_no_email = GETPOST("search_no_email", 'int');
+if (!empty($conf->socialnetworks->enabled)) {
@@ -95 +79 @@
- $search_[$key] = GETPOST("search_".$key, 'alpha');
+ $search_{$key} = GETPOST("search_".$key, 'alpha');
@@ -105 +88,0 @@
-$search_address = GETPOST('search_address', 'alpha');
@@ -108 +91 @@
-$search_import_key = GETPOST("search_import_key", 'alpha');
+$search_import_key = GETPOST("search_import_key", "alpha");
@@ -111,11 +94,2 @@
-$search_level = GETPOST("search_level", 'array');
-$search_stcomm = GETPOST('search_stcomm', 'int');
-$search_birthday_start = dol_mktime(0, 0, 0, GETPOST('search_birthday_startmonth', 'int'), GETPOST('search_birthday_startday', 'int'), GETPOST('search_birthday_startyear', 'int'));
-$search_birthday_end = dol_mktime(23, 59, 59, GETPOST('search_birthday_endmonth', 'int'), GETPOST('search_birthday_endday', 'int'), GETPOST('search_birthday_endyear', 'int'));
-
-if ($search_status === '') {
- $search_status = 1; // always display active customer first
-}
-if ($search_no_email === '') {
- $search_no_email = -1;
-}
+
+if ($search_status == '') $search_status = 1; // always display active customer first
@@ -125 +98,0 @@
-$place = GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'; // $place is string id of table for Bar or Restaurant
@@ -129,0 +103,4 @@
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST('sortfield', 'alpha');
+$sortorder = GETPOST('sortorder', 'alpha');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
@@ -132,16 +109,3 @@
-
-// Load variable for pagination
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
-$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (!$sortorder) {
- $sortorder = "ASC";
-}
-if (!$sortfield) {
- $sortfield = "p.lastname";
-}
-if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
- // If $page is not defined, or '' or -1 or if we click on clear filters
- $page = 0;
-}
+if (!$sortorder) $sortorder = "ASC";
+if (!$sortfield) $sortfield = "p.lastname";
+if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; }
@@ -149,10 +113,6 @@
-$pageprev = $page - 1;
-$pagenext = $page + 1;
-
-
-$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
-if ($type == "p") {
- if (empty($contextpage) || $contextpage == 'contactlist') {
- $contextpage = 'contactprospectlist';
- }
- $title .= ' ('.$langs->trans("ThirdPartyProspects").')';
+
+$titre = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses"));
+if ($type == "p")
+{
+ if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactprospectlist';
+ $titre .= ' ('.$langs->trans("ThirdPartyProspects").')';
@@ -161,5 +121,4 @@
-if ($type == "c") {
- if (empty($contextpage) || $contextpage == 'contactlist') {
- $contextpage = 'contactcustomerlist';
- }
- $title .= ' ('.$langs->trans("ThirdPartyCustomers").')';
+if ($type == "c")
+{
+ if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactcustomerlist';
+ $titre .= ' ('.$langs->trans("ThirdPartyCustomers").')';
@@ -167,5 +126,5 @@
-} elseif ($type == "f") {
- if (empty($contextpage) || $contextpage == 'contactlist') {
- $contextpage = 'contactsupplierlist';
- }
- $title .= ' ('.$langs->trans("ThirdPartySuppliers").')';
+}
+elseif ($type == "f")
+{
+ if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactsupplierlist';
+ $titre .= ' ('.$langs->trans("ThirdPartySuppliers").')';
@@ -173,5 +132,5 @@
-} elseif ($type == "o") {
- if (empty($contextpage) || $contextpage == 'contactlist') {
- $contextpage = 'contactotherlist';
- }
- $title .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')';
+}
+elseif ($type == "o")
+{
+ if (empty($contextpage) || $contextpage == 'contactlist') $contextpage = 'contactotherlist';
+ $titre .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')';
@@ -181 +140 @@
-// Initialize technical object
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@@ -182,0 +142 @@
+$hookmanager->initHooks(array('contactlist'));
@@ -184 +143,0 @@
-$hookmanager->initHooks(array($contextpage));
@@ -187 +146 @@
-$extrafields->fetch_name_optionals_label($object->table_element);
+$extrafields->fetch_name_optionals_label('contact');
@@ -192,58 +151,36 @@
-$fieldstosearchall = array();
-foreach ($object->fields as $key => $val) {
- // don't allow search in private notes for external users when doing "search in all"
- if (!empty($user->socid) && $key == "note_private") {
- continue;
- }
-
- if (empty($val['searchall'])) {
- continue;
- }
-
- $fieldstosearchall['p.'.$key] = $val['label'];
-}
-
-// Add none object fields for "search in all"
-if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) {
- $fieldstosearchall['s.nom'] = "ThirdParty";
- $fieldstosearchall['s.name_alias'] = "AliasNames";
-}
-
-$parameters = array('fieldstosearchall'=>$fieldstosearchall);
-$reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook > 0) {
- $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
-} elseif ($reshook == 0) {
- $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']);
-}
-
-// Definition of array of fields for columns
-$arrayfields = array();
-foreach ($object->fields as $key => $val) {
- // If $val['visible']==0, then we never show the field
- if (!empty($val['visible'])) {
- $visible = (int) dol_eval($val['visible'], 1);
- $arrayfields['p.'.$key] = array(
- 'label'=>$val['label'],
- 'checked'=>(($visible < 0) ? 0 : 1),
- 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
- 'position'=>$val['position'],
- 'help'=> isset($val['help']) ? $val['help'] : ''
- );
- }
-}
-
-// Add none object fields to fields for list
-$arrayfields['country.code_iso'] = array('label'=>"Country", 'position'=>66, 'checked'=>0);
-if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) {
- $arrayfields['s.nom'] = array('label'=>"ThirdParty", 'position'=>113, 'checked'=> 1);
- $arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'position'=>114, 'checked'=> 1);
-}
-
-$arrayfields['unsubscribed'] = array(
- 'label'=>'No_Email',
- 'checked'=>0,
- 'enabled'=>(isModEnabled('mailing')),
- 'position'=>111);
-
-if (isModEnabled('socialnetworks')) {
+$fieldstosearchall = array(
+ 'p.lastname'=>'Lastname',
+ 'p.firstname'=>'Firstname',
+ 'p.email'=>'EMail',
+ 's.nom'=>"ThirdParty",
+ 'p.phone'=>"Phone",
+ 'p.phone_perso'=>"PhonePerso",
+ 'p.phone_mobile'=>"PhoneMobile",
+ 'p.fax'=>"Fax",
+ 'p.note_public'=>"NotePublic",
+ 'p.note_private'=>"NotePrivate",
+);
+
+// Definition of fields for list
+$arrayfields = array(
+ 'p.rowid'=>array('label'=>"TechnicalID", 'position'=>1, 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0)),
+ 'p.lastname'=>array('label'=>"Lastname", 'position'=>2, 'checked'=>1),
+ 'p.firstname'=>array('label'=>"Firstname", 'position'=>3, 'checked'=>1),
+ 'p.poste'=>array('label'=>"PostOrFunction", 'position'=>10, 'checked'=>1),
+ 'p.town'=>array('label'=>"Town", 'position'=>20, 'checked'=>0),
+ 'p.zip'=>array('label'=>"Zip", 'position'=>21, 'checked'=>0),
+ 'country.code_iso'=>array('label'=>"Country", 'position'=>22, 'checked'=>0),
+ 'p.phone'=>array('label'=>"Phone", 'position'=>30, 'checked'=>1),
+ 'p.phone_perso'=>array('label'=>"PhonePerso", 'position'=>31, 'checked'=>0),
+ 'p.phone_mobile'=>array('label'=>"PhoneMobile", 'position'=>32, 'checked'=>1),
+ 'p.fax'=>array('label'=>"Fax", 'position'=>33, 'checked'=>0),
+ 'p.email'=>array('label'=>"EMail", 'position'=>40, 'checked'=>1),
+ 'p.no_email'=>array('label'=>"No_Email", 'position'=>41, 'checked'=>0, 'enabled'=>(!empty($conf->mailing->enabled))),
+ 'p.thirdparty'=>array('label'=>"ThirdParty", 'position'=>50, 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)),
+ 'p.priv'=>array('label'=>"ContactVisibility", 'checked'=>1, 'position'=>200),
+ 'p.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500),
+ 'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
+ 'p.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
+ 'p.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
+);
+if (!empty($conf->socialnetworks->enabled)) {
@@ -260 +196,0 @@
-
@@ -262,2 +198,8 @@
-include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
-
+if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
+{
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
+ {
+ if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
+ $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
+ }
+}
@@ -265 +206,0 @@
-//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
@@ -269 +210,2 @@
-if (($id > 0 || !empty($ref)) && $action != 'add') {
+if (($id > 0 || !empty($ref)) && $action != 'add')
+{
@@ -271,11 +213 @@
- if ($result < 0) {
- dol_print_error($db);
- }
-}
-
-$permissiontoread = $user->hasRight('societe', 'lire');
-$permissiontodelete = $user->hasRight('societe', 'supprimer');
-$permissiontoadd = $user->hasRight('societe', 'creer');
-
-if (!$permissiontoread) {
- accessforbidden();
+ if ($result < 0) dol_print_error($db);
@@ -289,54 +221,2 @@
-if ($action == "change" && $user->hasRight('takepos', 'run')) { // Change customer for TakePOS
- $idcustomer = GETPOST('idcustomer', 'int');
- $idcontact = GETPOST('idcontact', 'int');
-
- // Check if draft invoice already exists, if not create it
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' AND entity IN (".getEntity('invoice').")";
- $result = $db->query($sql);
- $num_lines = $db->num_rows($result);
- if ($num_lines == 0) {
- require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
- $invoice = new Facture($db);
- $constforthirdpartyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
- $invoice->socid = getDolGlobalInt($constforthirdpartyid);
- $invoice->date = dol_now();
- $invoice->module_source = 'takepos';
- $invoice->pos_source = $_SESSION["takeposterminal"];
- $placeid = $invoice->create($user);
- $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid);
- $db->query($sql);
- }
-
- $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".((int) $idcustomer)." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
- $resql = $db->query($sql);
-
- // set contact on invoice
- if (!isset($invoice)) {
- require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
- $invoice = new Facture($db);
- $invoice->fetch(null, "(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")");
- $invoice->delete_linked_contact('external', 'BILLING');
- }
- $invoice->add_contact($idcontact, 'BILLING'); ?>
-
- error, $hookmanager->errors, 'errors');
-}
-
-if (empty($reshook)) {
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+if (empty($reshook))
+{
@@ -354,3 +233,4 @@
- // Purge search criteria
- if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
- $search_all = "";
+ // Did we click on purge search criteria ?
+ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
+ {
+ $sall = "";
@@ -362 +241,0 @@
- $search_societe_alias = "";
@@ -364 +242,0 @@
- $search_address = "";
@@ -375 +253 @@
- if (isModEnabled('socialnetworks')) {
+ if (!empty($conf->socialnetworks->enabled)) {
@@ -378 +256 @@
- $search_[$key] = "";
+ $search_{$key} = "";
@@ -383,2 +260,0 @@
- $search_stcomm = '';
- $search_level = '';
@@ -390 +266 @@
- $toselect = array();
+ $toselect = '';
@@ -393,2 +268,0 @@
- $search_birthday_start = '';
- $search_birthday_end = '';
@@ -399,0 +274,2 @@
+ $permissiontoread = $user->rights->societe->lire;
+ $permissiontodelete = $user->rights->societe->supprimer;
@@ -402,17 +278,3 @@
-
- if ($action == 'setstcomm') {
- $object = new Contact($db);
- $result = $object->fetch(GETPOST('stcommcontactid'));
- $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcommcontact');
- $result = $object->update($object->id, $user);
- if ($result < 0) {
- setEventMessages($object->error, $object->errors, 'errors');
- }
-
- $action = '';
- }
-}
-
-if ($search_priv < 0) {
- $search_priv = '';
-}
+}
+
+if ($search_priv < 0) $search_priv = '';
@@ -430,38 +292,4 @@
-$now = dol_now();
-
-$title = $langs->trans("Contacts")." - ".$langs->trans("List");
-$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas';
-$morejs = array();
-$morecss = array();
-
-if (getDolGlobalString('THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES')) {
- $contactstatic->loadCacheOfProspStatus();
-}
-
-$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
-$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
-
-// Select every potentiels, and note each potentiels which fit in search parameters
-$tab_level = array();
-$sql = "SELECT code, label, sortorder";
-$sql .= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel";
-$sql .= " WHERE active > 0";
-$sql .= " ORDER BY sortorder";
-$resql = $db->query($sql);
-if ($resql) {
- while ($obj = $db->fetch_object($resql)) {
- // Compute level text
- $level = $langs->trans($obj->code);
- if ($level == $obj->code) {
- $level = $langs->trans($obj->label);
- }
- $tab_level[$obj->code] = $level;
- }
-} else {
- dol_print_error($db);
-}
-
-// Build and execute select
-// --------------------------------------------------------------------
-$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias as alias,";
-$sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email, p.birthday,";
+$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
+
+$sql = "SELECT s.rowid as socid, s.nom as name,";
+$sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,";
@@ -470,2 +297,0 @@
-$sql .= " p.import_key, p.fk_stcommcontact as stcomm_id, p.fk_prospectlevel,";
-$sql .= " st.libelle as stcomm, st.picto as stcomm_picto,";
@@ -475,8 +301,2 @@
- foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
- $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
- }
-}
-if (isModEnabled('mailing')) {
- $sql .= ", (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) as unsubscribed";
-}
-
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
+}
@@ -485 +305 @@
-$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
@@ -487,4 +306,0 @@
-$sql = preg_replace('/,\s*$/', '', $sql);
-
-$sqlfields = $sql; // $sql fields to remove for count total
-
@@ -492,3 +308 @@
-if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
-}
+if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
@@ -497,21 +311,12 @@
-$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact";
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
-}
-
-// Add fields from hooks - ListFrom
-$parameters = array();
-$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-$sql .= $hookmanager->resPrint;
-$sql .= ' WHERE p.entity IN ('.getEntity('contact').')';
-if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { //restriction
- $sql .= " AND (sc.fk_user = ".((int) $user->id)." OR p.fk_soc IS NULL)";
-}
-if (!empty($userid)) { // propre au commercial
- $sql .= " AND p.fk_user_creat=".((int) $userid);
-}
-if ($search_level) {
- $sql .= natural_search("p.fk_prospectlevel", join(',', $search_level), 3);
-}
-if ($search_stcomm != '' && $search_stcomm != -2) {
- $sql .= natural_search("p.fk_stcommcontact", $search_stcomm, 2);
+if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ
+if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ
+if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ
+if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
+$sql .= ' WHERE p.entity IN ('.getEntity('socpeople').')';
+if (!$user->rights->societe->client->voir && !$socid) //restriction
+{
+ $sql .= " AND (sc.fk_user = ".$user->id." OR p.fk_soc IS NULL)";
+}
+if (!empty($userid)) // propre au commercial
+{
+ $sql .= " AND p.fk_user_creat=".$db->escape($userid);
@@ -521,28 +326,36 @@
-if ($search_priv != '0' && $search_priv != '1') {
- $sql .= " AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat=".((int) $user->id)."))";
-} else {
- if ($search_priv == '0') {
- $sql .= " AND p.priv='0'";
- }
- if ($search_priv == '1') {
- $sql .= " AND (p.priv='1' AND p.fk_user_creat=".((int) $user->id).")";
- }
-}
-
-
-// Search Contact Categories
-$searchCategoryContactList = $search_categ ? array($search_categ) : array();
-$searchCategoryContactOperator = 0;
-// Search for tag/category ($searchCategoryContactList is an array of ID)
-if (!empty($searchCategoryContactList)) {
- $searchCategoryContactSqlList = array();
- $listofcategoryid = '';
- foreach ($searchCategoryContactList as $searchCategoryContact) {
- if (intval($searchCategoryContact) == -2) {
- $searchCategoryContactSqlList[] = "NOT EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE p.rowid = ck.fk_socpeople)";
- } elseif (intval($searchCategoryContact) > 0) {
- if ($searchCategoryContactOperator == 0) {
- $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE p.rowid = ck.fk_socpeople AND ck.fk_categorie = ".((int) $searchCategoryContact).")";
- } else {
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact);
- }
+if ($search_priv != '0' && $search_priv != '1')
+{
+ $sql .= " AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat=".$user->id."))";
+}
+else
+{
+ if ($search_priv == '0') $sql .= " AND p.priv='0'";
+ if ($search_priv == '1') $sql .= " AND (p.priv='1' AND p.fk_user_creat=".$user->id.")";
+}
+
+if ($search_categ > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ);
+if ($search_categ == -2) $sql .= " AND cc.fk_categorie IS NULL";
+if ($search_categ_thirdparty > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ_thirdparty);
+if ($search_categ_thirdparty == -2) $sql .= " AND cs.fk_categorie IS NULL";
+if ($search_categ_supplier > 0) $sql .= " AND cs2.fk_categorie = ".$db->escape($search_categ_supplier);
+if ($search_categ_supplier == -2) $sql .= " AND cs2.fk_categorie IS NULL";
+
+if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
+if (strlen($search_phone)) $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_phone);
+if (strlen($search_cti)) $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_cti);
+if (strlen($search_firstlast_only)) $sql .= natural_search(array('p.lastname', 'p.firstname'), $search_firstlast_only);
+
+if ($search_id > 0) $sql .= natural_search("p.rowid", $search_id, 1);
+if ($search_lastname) $sql .= natural_search('p.lastname', $search_lastname);
+if ($search_firstname) $sql .= natural_search('p.firstname', $search_firstname);
+if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
+if ($search_country) $sql .= " AND p.fk_pays IN (".$search_country.')';
+if (strlen($search_poste)) $sql .= natural_search('p.poste', $search_poste);
+if (strlen($search_phone_perso)) $sql .= natural_search('p.phone_perso', $search_phone_perso);
+if (strlen($search_phone_pro)) $sql .= natural_search('p.phone', $search_phone_pro);
+if (strlen($search_phone_mobile)) $sql .= natural_search('p.phone_mobile', $search_phone_mobile);
+if (strlen($search_fax)) $sql .= natural_search('p.fax', $search_fax);
+if (!empty($conf->socialnetworks->enabled)) {
+ foreach ($socialnetworks as $key => $value) {
+ if ($value['active'] && strlen($search_{$key})) {
+ $sql .= ' AND p.socialnetworks LIKE \'%"'.$key.'":"'.$search_{$key}.'%\'';
@@ -551,157 +364,4 @@
- if ($listofcategoryid) {
- $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE p.rowid = ck.fk_socpeople AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
- }
- if ($searchCategoryContactOperator == 1) {
- if (!empty($searchCategoryContactSqlList)) {
- $sql .= " AND (".implode(' OR ', $searchCategoryContactSqlList).")";
- }
- } else {
- if (!empty($searchCategoryContactSqlList)) {
- $sql .= " AND (".implode(' AND ', $searchCategoryContactSqlList).")";
- }
- }
-}
-
- // Search Customer Categories
-$searchCategoryCustomerList = $search_categ_thirdparty ? array($search_categ_thirdparty) : array();
-$searchCategoryCustomerOperator = 0;
- // Search for tag/category ($searchCategoryCustomerList is an array of ID)
-if (!empty($searchCategoryCustomerList)) {
- $searchCategoryCustomerSqlList = array();
- $listofcategoryid = '';
- foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
- if (intval($searchCategoryCustomer) == -2) {
- $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
- } elseif (intval($searchCategoryCustomer) > 0) {
- if ($searchCategoryCustomerOperator == 0) {
- $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategoryCustomer).")";
- } else {
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
- }
- }
- }
- if ($listofcategoryid) {
- $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
- }
- if ($searchCategoryCustomerOperator == 1) {
- if (!empty($searchCategoryCustomerSqlList)) {
- $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
- }
- } else {
- if (!empty($searchCategoryCustomerSqlList)) {
- $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
- }
- }
-}
-
-// Search Supplier Categories
-$searchCategorySupplierList = $search_categ_supplier ? array($search_categ_supplier) : array();
-$searchCategorySupplierOperator = 0;
- // Search for tag/category ($searchCategorySupplierList is an array of ID)
-if (!empty($searchCategorySupplierList)) {
- $searchCategorySupplierSqlList = array();
- $listofcategoryid = '';
- foreach ($searchCategorySupplierList as $searchCategorySupplier) {
- if (intval($searchCategorySupplier) == -2) {
- $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
- } elseif (intval($searchCategorySupplier) > 0) {
- if ($searchCategorySupplierOperator == 0) {
- $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategorySupplier).")";
- } else {
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier);
- }
- }
- }
- if ($listofcategoryid) {
- $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
- }
- if ($searchCategorySupplierOperator == 1) {
- if (!empty($searchCategorySupplierSqlList)) {
- $sql .= " AND (".implode(' OR ', $searchCategorySupplierSqlList).")";
- }
- } else {
- if (!empty($searchCategorySupplierSqlList)) {
- $sql .= " AND (".implode(' AND ', $searchCategorySupplierSqlList).")";
- }
- }
-}
-
-if ($search_all) {
- $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
-}
-if (strlen($search_phone)) {
- $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_phone);
-}
-if (strlen($search_cti)) {
- $sql .= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_cti);
-}
-if (strlen($search_firstlast_only)) {
- $sql .= natural_search(array('p.lastname', 'p.firstname'), $search_firstlast_only);
-}
-
-if ($search_id > 0) {
- $sql .= natural_search('p.rowid', $search_id, 1);
-}
-if ($search_lastname) {
- $sql .= natural_search('p.lastname', $search_lastname);
-}
-if ($search_firstname) {
- $sql .= natural_search('p.firstname', $search_firstname);
-}
-if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) {
- $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe);
-} else {
- if ($search_societe) {
- $sql .= natural_search('s.nom', $search_societe);
- }
- if ($search_societe_alias) {
- $sql .= natural_search('s.name_alias', $search_societe_alias);
- }
-}
-if ($search_country) {
- $sql .= " AND p.fk_pays IN (".$db->sanitize($search_country).')';
-}
-if (strlen($search_poste)) {
- $sql .= natural_search('p.poste', $search_poste);
-}
-if (strlen($search_phone_perso)) {
- $sql .= natural_search('p.phone_perso', $search_phone_perso);
-}
-if (strlen($search_phone_pro)) {
- $sql .= natural_search('p.phone', $search_phone_pro);
-}
-if (strlen($search_phone_mobile)) {
- $sql .= natural_search('p.phone_mobile', $search_phone_mobile);
-}
-if (strlen($search_fax)) {
- $sql .= natural_search('p.fax', $search_fax);
-}
-if (isModEnabled('socialnetworks')) {
- foreach ($socialnetworks as $key => $value) {
- if ($value['active'] && strlen($search_[$key])) {
- $searchkeyinjsonformat = preg_replace('/"$/', '', preg_replace('/^"/', '', json_encode($search_[$key])));
- if (in_array($db->type, array('mysql', 'mysqli'))) {
- $sql .= " AND p.socialnetworks REGEXP '\"".$db->escape($db->escapeforlike($key))."\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat))."'";
- } elseif ($db->type == 'pgsql') {
- $sql .= " AND p.socialnetworks ~ '\"".$db->escape($db->escapeforlike($key))."\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat))."'";
- } else {
- // Works with all database but not reliable because search only for social network code starting with earched value
- $sql .= " AND p.socialnetworks LIKE '%\"".$db->escape($db->escapeforlike($key))."\":\"".$db->escape($db->escapeforlike($searchkeyinjsonformat))."%'";
- }
- }
- }
-}
-//print $sql;
-
-if (strlen($search_email)) {
- $sql .= natural_search('p.email', $search_email);
-}
-if (strlen($search_address)) {
- $sql .= natural_search("p.address", $search_address);
-}
-if (strlen($search_zip)) {
- $sql .= natural_search("p.zip", $search_zip);
-}
-if (strlen($search_town)) {
- $sql .= natural_search("p.town", $search_town);
-}
+}
+if (strlen($search_email)) $sql .= natural_search('p.email', $search_email);
+if (strlen($search_zip)) $sql .= natural_search("p.zip", $search_zip);
+if (strlen($search_town)) $sql .= natural_search("p.town", $search_town);
@@ -709,15 +369,8 @@
- $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".$db->sanitize(implode(',', $search_roles))."))";
-}
-if ($search_no_email != -1 && $search_no_email > 0) {
- $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) > 0";
-}
-if ($search_no_email != -1 && $search_no_email == 0) {
- $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) = 0 AND p.email IS NOT NULL AND p.email <> ''";
-}
-if ($search_status != '' && $search_status >= 0) {
- $sql .= " AND p.statut = ".((int) $search_status);
-}
-if ($search_import_key) {
- $sql .= natural_search("p.import_key", $search_import_key);
-}
-if ($type == "o") { // filter on type
+ $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))";
+}
+
+if ($search_no_email != '' && $search_no_email >= 0) $sql .= " AND p.no_email = ".$db->escape($search_no_email);
+if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status);
+if ($search_import_key) $sql .= natural_search("p.import_key", $search_import_key);
+if ($type == "o") // filtre sur type
+{
@@ -725 +378,3 @@
-} elseif ($type == "f") { // filter on type
+}
+elseif ($type == "f") // filtre sur type
+{
@@ -727 +382,3 @@
-} elseif ($type == "c") { // filter on type
+}
+elseif ($type == "c") // filtre sur type
+{
@@ -729 +386,3 @@
-} elseif ($type == "p") { // filter on type
+}
+elseif ($type == "p") // filtre sur type
+{
@@ -732,10 +391,4 @@
-if (!empty($socid)) {
- $sql .= " AND s.rowid = ".((int) $socid);
-}
-if ($search_birthday_start) {
- $sql .= " AND p.birthday >= '".$db->idate($search_birthday_start)."'";
-}
-if ($search_birthday_end) {
- $sql .= " AND p.birthday <= '".$db->idate($search_birthday_end)."'";
-}
-
+if (!empty($socid))
+{
+ $sql .= " AND s.rowid = ".$socid;
+}
@@ -744 +396,0 @@
-
@@ -747 +399 @@
-$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
@@ -749,6 +401,9 @@
-//print $sql;
-
-// Add GroupBy from hooks
-$parameters = array('fieldstosearchall' => $fieldstosearchall);
-$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-$sql .= $hookmanager->resPrint;
+// Add order
+if ($view == "recent")
+{
+ $sql .= $db->order("p.datec", "DESC");
+}
+else
+{
+ $sql .= $db->order($sortfield, $sortorder);
+}
@@ -758,13 +413,6 @@
-if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
- /* The fast and low memory method to get and count full list converts the sql into a sql count */
- $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
- $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
- $resql = $db->query($sqlforcount);
- if ($resql) {
- $objforcount = $db->fetch_object($resql);
- $nbtotalofrecords = $objforcount->nbtotalofrecords;
- } else {
- dol_print_error($db);
- }
-
- if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+{
+ $result = $db->query($sql);
+ $nbtotalofrecords = $db->num_rows($result);
+ if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
+ {
@@ -774,15 +422,7 @@
- $db->free($resql);
-}
-
-// Complete request and execute it with limit
-if ($view == "recent") {
- $sql .= $db->order("p.datec", "DESC");
-} else {
- $sql .= $db->order($sortfield, $sortorder);
-}
-if ($limit) {
- $sql .= $db->plimit($limit + 1, $offset);
-}
-
-$resql = $db->query($sql);
-if (!$resql) {
+}
+
+$sql .= $db->plimit($limit + 1, $offset);
+
+$result = $db->query($sql);
+if (!$result)
+{
@@ -793,4 +433,6 @@
-$num = $db->num_rows($resql);
-
-// Direct jump if only one record found
-if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && ($search_all != '' || $search_cti != '') && !$page) {
+$num = $db->num_rows($result);
+
+$arrayofselected = is_array($toselect) ? $toselect : array();
+
+if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall != '' || $search_cti != ''))
+{
@@ -803,7 +445,2 @@
-
-// Output page
-// --------------------------------------------------------------------
-
-llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');
-
-$arrayofselected = is_array($toselect) ? $toselect : array();
+$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas';
+llxHeader('', $title, $help_url);
@@ -812,100 +449,28 @@
-if (!empty($mode)) {
- $param .= '&mode='.urlencode($mode);
-}
-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
- $param .= '&contextpage='.urlencode($contextpage);
-}
-if ($limit > 0 && $limit != $conf->liste_limit) {
- $param .= '&limit='.((int) $limit);
-}
-if ($optioncss != '') {
- $param .= '&optioncss='.urlencode($optioncss);
-}
-$param .= '&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($search_all);
-$param .= '&type='.urlencode($type).'&view='.urlencode($view);
-if (!empty($search_categ) && $search_categ != '-1') {
- $param .= '&search_categ='.urlencode($search_categ);
-}
-if (!empty($search_categ_thirdparty) && $search_categ_thirdparty != '-1') {
- $param .= '&search_categ_thirdparty='.urlencode($search_categ_thirdparty);
-}
-if (!empty($search_categ_supplier) && $search_categ_supplier != '-1') {
- $param .= '&search_categ_supplier='.urlencode($search_categ_supplier);
-}
-if ($search_all != '') {
- $param .= '&search_all='.urlencode($search_all);
-}
-if ($search_id > 0) {
- $param .= "&search_id=".urlencode($search_id);
-}
-if ($search_lastname != '') {
- $param .= '&search_lastname='.urlencode($search_lastname);
-}
-if ($search_firstname != '') {
- $param .= '&search_firstname='.urlencode($search_firstname);
-}
-if ($search_societe != '') {
- $param .= '&search_societe='.urlencode($search_societe);
-}
-if ($search_societe_alias != '') {
- $param .= '&search_societe_alias='.urlencode($search_societe_alias);
-}
-if ($search_address != '') {
- $param .= '&search_address='.urlencode($search_address);
-}
-if ($search_zip != '') {
- $param .= '&search_zip='.urlencode($search_zip);
-}
-if ($search_town != '') {
- $param .= '&search_town='.urlencode($search_town);
-}
-if ($search_country != '') {
- $param .= "&search_country=".urlencode($search_country);
-}
-if ($search_poste != '') {
- $param .= '&search_poste='.urlencode($search_poste);
-}
-if ($search_phone_pro != '') {
- $param .= '&search_phone_pro='.urlencode($search_phone_pro);
-}
-if ($search_phone_perso != '') {
- $param .= '&search_phone_perso='.urlencode($search_phone_perso);
-}
-if ($search_phone_mobile != '') {
- $param .= '&search_phone_mobile='.urlencode($search_phone_mobile);
-}
-if ($search_fax != '') {
- $param .= '&search_fax='.urlencode($search_fax);
-}
-if ($search_email != '') {
- $param .= '&search_email='.urlencode($search_email);
-}
-if ($search_no_email != '') {
- $param .= '&search_no_email='.urlencode($search_no_email);
-}
-if ($search_status != '') {
- $param .= '&search_status='.urlencode($search_status);
-}
-if ($search_priv == '0' || $search_priv == '1') {
- $param .= "&search_priv=".urlencode($search_priv);
-}
-if ($search_stcomm != '') {
- $param .= '&search_stcomm='.urlencode($search_stcomm);
-}
-if (is_array($search_level) && count($search_level)) {
- foreach ($search_level as $slevel) {
- $param .= '&search_level[]='.urlencode($slevel);
- }
-}
-if ($search_import_key != '') {
- $param .= '&search_import_key='.urlencode($search_import_key);
-}
-if (count($search_roles) > 0) {
- $param .= implode('&search_roles[]=', $search_roles);
-}
-if ($search_birthday_start) {
- $param .= '&search_birthday_start='.urlencode(dol_print_date($search_birthday_start, '%d')).'&search_birthday_startmonth='.urlencode(dol_print_date($search_birthday_start, '%m')).'&search_birthday_startyear='.urlencode(dol_print_date($search_birthday_start, '%Y'));
-}
-if ($search_birthday_end) {
- $param .= '&search_birthday_end='.urlencode(dol_print_date($search_birthday_end, '%d')).'&search_birthday_endmonth='.urlencode(dol_print_date($search_birthday_end, '%m')).'&search_birthday_endyear='.urlencode(dol_print_date($search_birthday_end, '%Y'));
-}
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
+if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
+$param .= '&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($sall);
+$param .= '&type='.urlencode($type).'&view='.urlencode($view);
+if (!empty($search_categ)) $param .= '&search_categ='.urlencode($search_categ);
+if (!empty($search_categ_thirdparty)) $param .= '&search_categ_thirdparty='.urlencode($search_categ_thirdparty);
+if (!empty($search_categ_supplier)) $param .= '&search_categ_supplier='.urlencode($search_categ_supplier);
+if ($sall != '') $param .= '&sall='.urlencode($sall);
+if ($search_id > 0) $param .= "&search_id=".urlencode($search_id);
+if ($search_lastname != '') $param .= '&search_lastname='.urlencode($search_lastname);
+if ($search_firstname != '') $param .= '&search_firstname='.urlencode($search_firstname);
+if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe);
+if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip);
+if ($search_town != '') $param .= '&search_town='.urlencode($search_town);
+if ($search_country != '') $param .= "&search_country=".urlencode($search_country);
+if ($search_poste != '') $param .= '&search_poste='.urlencode($search_poste);
+if ($search_phone_pro != '') $param .= '&search_phone_pro='.urlencode($search_phone_pro);
+if ($search_phone_perso != '') $param .= '&search_phone_perso='.urlencode($search_phone_perso);
+if ($search_phone_mobile != '') $param .= '&search_phone_mobile='.urlencode($search_phone_mobile);
+if ($search_fax != '') $param .= '&search_fax='.urlencode($search_fax);
+if ($search_email != '') $param .= '&search_email='.urlencode($search_email);
+if ($search_no_email != '') $param .= '&search_no_email='.urlencode($search_no_email);
+if ($search_status != '') $param .= '&search_status='.urlencode($search_status);
+if ($search_priv == '0' || $search_priv == '1') $param .= "&search_priv=".urlencode($search_priv);
+if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key);
+if ($optioncss != '') $param .= '&optioncss='.$optioncss;
+if (count($search_roles) > 0) $param .= implode('&search_roles[]=', $search_roles);
+
@@ -917,2 +482,2 @@
- 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
-// 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
+// 'presend'=>$langs->trans("SendByMail"),
+// 'builddoc'=>$langs->trans("PDFMerge"),
@@ -921,17 +486,12 @@
-if (!empty($permissiontodelete)) {
- $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
-}
-if (isModEnabled('category') && $user->hasRight('societe', 'creer')) {
- $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
-}
-if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
- $arrayofmassactions = array();
-}
-if ($contextpage != 'poslist') {
- $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
-}
-
-print '';
+
+
--- /tmp/dsg/dolibarr/htdocs/contact/github_19.0.3_note.php
+++ /tmp/dsg/dolibarr/htdocs/contact/client_note.php
@@ -28 +27,0 @@
-// Load Dolibarr environment
@@ -37,0 +37 @@
+// Security check
@@ -38,0 +39,2 @@
+if ($user->socid) $id = $user->socid;
+$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
@@ -41,3 +43 @@
-if ($id > 0) {
- $object->fetch($id);
-}
+if ($id > 0) $object->fetch($id);
@@ -45,14 +45 @@
-// Security check
-if ($user->socid > 0) {
- if ($object->fk_soc > 0 && $object->fk_soc != $user->socid) {
- accessforbidden();
- }
-}
-$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
-
-
-$permissionnote = $user->hasRight('societe', 'creer'); // Used by the include of actions_setnotes.inc.php
-
-// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-// $hookmanager->initHooks(array('contactcard')); -> Name conflict with product/card.php
-$hookmanager->initHooks(array('contactnote'));
+$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php
@@ -65,8 +52 @@
-$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)) {
- 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 includ_once
@@ -81 +61 @@
-$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
+$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
@@ -88,7 +68,6 @@
-if ($id > 0) {
- /*
- * Affichage onglets
- */
- if (isModEnabled('notification')) {
- $langs->load("mails");
- }
+if ($id > 0)
+{
+ /*
+ * Affichage onglets
+ */
+ if (!empty($conf->notification->enabled)) $langs->load("mails");
@@ -96 +75 @@
- $head = contact_prepare_head($object);
+ $head = contact_prepare_head($object);
@@ -98 +77 @@
- print dol_get_fiche_head($head, 'note', $title, -1, 'contact');
+ dol_fiche_head($head, 'note', $title, -1, 'contact');
@@ -100 +79 @@
- $linkback = ''.$langs->trans("BackToList").'';
+ $linkback = ''.$langs->trans("BackToList").'';
@@ -102,3 +81,11 @@
- $morehtmlref = '';
- $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
- $morehtmlref .= '';
+ $morehtmlref = '';
+ if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
+ {
+ $objsoc = new Societe($db);
+ $objsoc->fetch($object->socid);
+ // Thirdparty
+ $morehtmlref .= $langs->trans('ThirdParty').' : ';
+ if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1);
+ else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
+ }
+ $morehtmlref .= '
';
@@ -106,12 +93 @@
- $morehtmlref .= '';
- if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) {
- $objsoc = new Societe($db);
- $objsoc->fetch($object->socid);
- // Thirdparty
- if ($objsoc->id > 0) {
- $morehtmlref .= $objsoc->getNomUrl(1);
- } else {
- $morehtmlref .= ''.$langs->trans("ContactNotLinkedToCompany").'';
- }
- }
- $morehtmlref .= '
';
+ dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
@@ -119 +95,3 @@
- dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
+ $cssclass = 'titlefield';
+ //if ($action == 'editnote_public') $cssclass='titlefieldcreate';
+ //if ($action == 'editnote_private') $cssclass='titlefieldcreate';
@@ -121,6 +99,2 @@
- $cssclass = 'titlefield';
- //if ($action == 'editnote_public') $cssclass='titlefieldcreate';
- //if ($action == 'editnote_private') $cssclass='titlefieldcreate';
-
- print '';
- print '
';
+ print '
';
+ print '
';
@@ -130,4 +104,4 @@
- // Civility
- print '
'.$langs->trans("UserTitle").' | ';
- print $object->getCivilityLabel();
- print ' |
';
+ // Civility
+ print '
'.$langs->trans("UserTitle").' | ';
+ print $object->getCivilityLabel();
+ print ' |
';
@@ -135 +109 @@
- print "
";
+ print "
";
@@ -143 +117 @@
- print dol_get_fiche_end();
+ dol_fiche_end();
--- /tmp/dsg/dolibarr/htdocs/contact/github_19.0.3_perso.php
+++ /tmp/dsg/dolibarr/htdocs/contact/client_perso.php
@@ -5 +5 @@
- * Copyright (C) 2018-2021 Frédéric France
+ * Copyright (C) 2018 Frédéric France
@@ -27 +26,0 @@
-// Load Dolibarr environment
@@ -30 +28,0 @@
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
@@ -37 +35 @@
-$action = GETPOST('action', 'aZ09');
+$action = GETPOST('action', 'alpha');
@@ -40,3 +38 @@
-if ($user->socid) {
- $socid = $user->socid;
-}
+if ($user->socid) $socid = $user->socid;
@@ -45,3 +40,0 @@
-
-$errors = array();
-
@@ -53 +46,2 @@
-if ($action == 'update' && !GETPOST("cancel") && $user->hasRight('societe', 'contact', 'creer')) {
+if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer)
+{
@@ -57,8 +51,5 @@
- $object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth"), GETPOST("birthdayday"), GETPOST("birthdayyear"));
- $object->birthday_alert = GETPOST("birthday_alert");
-
- if (GETPOST('deletephoto')) {
- $object->photo = '';
- } elseif (!empty($_FILES['photo']['name'])) {
- $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
- }
+ $object->birthday = dol_mktime(0, 0, 0, $_POST["birthdaymonth"], $_POST["birthdayday"], $_POST["birthdayyear"]);
+ $object->birthday_alert = $_POST["birthday_alert"];
+
+ if (GETPOST('deletephoto')) $object->photo = '';
+ elseif (!empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
@@ -67,3 +58,4 @@
- if ($result > 0) {
- $object->oldcopy = dol_clone($object, 2);
-
+ if ($result > 0)
+ {
+ $object->old_name = '';
+ $object->old_firstname = '';
@@ -74 +66,2 @@
- if ($file_OK) {
+ if ($file_OK)
+ {
@@ -76,2 +69,3 @@
- require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
- if (GETPOST('deletephoto')) {
+ if (GETPOST('deletephoto'))
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -84 +78,2 @@
- if (image_format_supported($_FILES['photo']['name']) > 0) {
+ if (image_format_supported($_FILES['photo']['name']) > 0)
+ {
@@ -87 +82,2 @@
- if (@is_dir($dir)) {
+ if (@is_dir($dir))
+ {
@@ -89 +85,2 @@
- if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) {
+ if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0)
+ {
@@ -91,3 +88,5 @@
- } else {
- // Create thumbs
- $object->addThumbs($newfile);
+ }
+ else
+ {
+ // Create thumbs
+ $object->addThumbs($newfile);
@@ -96 +95,3 @@
- } else {
+ }
+ else
+ {
@@ -99,2 +100,5 @@
- } else {
- switch ($_FILES['photo']['error']) {
+ }
+ else
+ {
+ switch ($_FILES['photo']['error'])
+ {
@@ -110 +114,3 @@
- } else {
+ }
+ else
+ {
@@ -122,4 +128,2 @@
-$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
-if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
- $title = $object->lastname;
-}
+$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
+if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname;
@@ -127 +131 @@
-llxHeader('', $title, $help_url);
+llxHeader('', $title, $helpurl);
@@ -130 +133,0 @@
-$formcompany = new FormCompany($db);
@@ -136,2 +139,3 @@
-if ($action == 'edit') {
- /*
+if ($action == 'edit')
+{
+ /*
@@ -141,184 +145,83 @@
- print '";
-} else {
- // View mode
-
- print dol_get_fiche_head($head, 'perso', $title, -1, 'contact');
-
- $linkback = ''.$langs->trans("BackToList").'';
-
- $morehtmlref = '';
- $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
- $morehtmlref .= '';
-
- $morehtmlref .= '';
- if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) {
- $objsoc = new Societe($db);
- $objsoc->fetch($object->socid);
- // Thirdparty
- if ($objsoc->id > 0) {
- $morehtmlref .= $objsoc->getNomUrl(1);
- } else {
- $morehtmlref .= ''.$langs->trans("ContactNotLinkedToCompany").'';
- }
- }
- $morehtmlref .= '
';
-
-
- dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
-
-
- print '';
-
- print '
';
- print '
';
-
- // Company
- /*
- if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
- {
- if ($object->socid > 0)
- {
- $objsoc = new Societe($db);
- $objsoc->fetch($object->socid);
-
- print ''.$langs->trans("ThirdParty").' | '.$objsoc->getNomUrl(1).' |
';
- }
-
- else
- {
- print ''.$langs->trans("ThirdParty").' | ';
- print $langs->trans("ContactNotLinkedToCompany");
- print ' |
';
- }
- }*/
-
- // Civility
- print ''.$langs->trans("UserTitle").' | ';
- print $object->getCivilityLabel();
- print ' |
';
-
- // Date To Birth
- print '';
- if (!empty($object->birthday)) {
- include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-
- print ''.$langs->trans("DateOfBirth").' | '.dol_print_date($object->birthday, "day");
-
- print ' ';
- //var_dump($birthdatearray);
- $ageyear = convertSecondToTime($now - $object->birthday, 'year') - 1970;
- $agemonth = convertSecondToTime($now - $object->birthday, 'month') - 1;
- if ($ageyear >= 2) {
- print '('.$ageyear.' '.$langs->trans("DurationYears").')';
- } elseif ($agemonth >= 2) {
- print '('.$agemonth.' '.$langs->trans("DurationMonths").')';
- } else {
- print '('.$agemonth.' '.$langs->trans("DurationMonth").')';
- }
-
-
- print ' - ';
- if ($object->birthday_alert) {
- print $langs->trans("BirthdayAlertOn");
- } else {
- print $langs->trans("BirthdayAlertOff");
- }
- print ' | ';
- } else {
- print ''.$langs->trans("DateOfBirth").' | | ';
- }
- print "
";
-
- print "
";
-
- print '
';
-
- print dol_get_fiche_end();
+ print '";
@@ -326,15 +229,87 @@
-
-
-if ($action != 'edit') {
- /*
- * Action bar
- */
- if ($user->socid == 0) {
- print '";
- }
+else
+{
+ // View mode
+
+ dol_fiche_head($head, 'perso', $title, -1, 'contact');
+
+ $linkback = ''.$langs->trans("BackToList").'';
+
+ $morehtmlref = '';
+ if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
+ {
+ $objsoc = new Societe($db);
+ $objsoc->fetch($object->socid);
+ // Thirdparty
+ $morehtmlref .= $langs->trans('ThirdParty').' : ';
+ if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1);
+ else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
+ }
+ $morehtmlref .= '
';
+
+
+ dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
+
+
+ print '';
+
+ print '
';
+ print '
';
+
+ // Company
+ /*
+ if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
+ {
+ if ($object->socid > 0)
+ {
+ $objsoc = new Societe($db);
+ $objsoc->fetch($object->socid);
+
+ print ''.$langs->trans("ThirdParty").' | '.$objsoc->getNomUrl(1).' |
';
+ }
+
+ else
+ {
+ print ''.$langs->trans("ThirdParty").' | ';
+ print $langs->trans("ContactNotLinkedToCompany");
+ print ' |
';
+ }
+ }*/
+
+ // Civility
+ print ''.$langs->trans("UserTitle").' | ';
+ print $object->getCivilityLabel();
+ print ' |
';
+
+ // Date To Birth
+ print '';
+ if (!empty($object->birthday))
+ {
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+
+ print ''.$langs->trans("DateToBirth").' | '.dol_print_date($object->birthday, "day");
+
+ print ' ';
+ //var_dump($birthdatearray);
+ $ageyear = convertSecondToTime($now - $object->birthday, 'year') - 1970;
+ $agemonth = convertSecondToTime($now - $object->birthday, 'month') - 1;
+ if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')';
+ elseif ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')';
+ else print '('.$agemonth.' '.$langs->trans("DurationMonth").')';
+
+
+ print ' - ';
+ if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn");
+ else print $langs->trans("BirthdayAlertOff");
+ print ' | ';
+ }
+ else
+ {
+ print ''.$langs->trans("DateToBirth").' | | ';
+ }
+ print "
";
+
+ print "
";
+
+ print '
';
+
+ dol_fiche_end();
@@ -343,0 +319,17 @@
+if ($action != 'edit')
+{
+ // Barre d'actions
+ if ($user->socid == 0)
+ {
+ print '";
+ }
+}
+
+
--- /tmp/dsg/dolibarr/htdocs/contact/github_19.0.3_vcard.php
+++ /tmp/dsg/dolibarr/htdocs/contact/client_vcard.php
@@ -27 +26,0 @@
-// Load Dolibarr environment
@@ -43,2 +42,3 @@
-if ($result <= 0) {
- dol_print_error($db, $contact->error);
+if ($result <= 0)
+{
+ dol_print_error($contact->error);
@@ -47,0 +48 @@
+$physicalperson = 1;
@@ -50 +51,2 @@
-if ($contact->socid) {
+if ($contact->socid)
+{
@@ -67 +69 @@
-$country = $contact->country_code ? $contact->country : '';
+$country = $contact->country_code ? $contact->country : '' ;
@@ -77 +79,2 @@
-if ($company->id) {
+if ($company->id)
+{
@@ -79,9 +82,3 @@
- if (!$contact->phone_pro) {
- $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE");
- }
- if (!$contact->fax) {
- $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX");
- }
- if (!$contact->zip) {
- $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL");
- }
+ if (! $contact->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE");
+ if (! $contact->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX");
+ if (! $contact->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL");
@@ -90 +87,2 @@
- if (empty(trim($company->email))) {
+ if (empty(trim($company->email)))
+ {
@@ -92,2 +90,4 @@
- } elseif (empty(trim($contact->email))) {
- // when contact e-mail is empty, use only company e-mail
+ }
+ // when contact e-mail is empty, use only company e-mail
+ elseif (empty(trim($contact->email)))
+ {
@@ -95,3 +95,5 @@
- } else {
- $tmpcontact = explode("@", trim($contact->email));
- $tmpcompany = explode("@", trim($company->email));
+ }
+ // when e-mail domain of contact and company are the same, use contact e-mail at first (and company e-mail at second)
+ elseif (strtolower(end(explode("@", $contact->email))) == strtolower(end(explode("@", $company->email))))
+ {
+ $v->setEmail($contact->email);
@@ -99,3 +101,7 @@
- if (strtolower(end($tmpcontact)) == strtolower(end($tmpcompany))) {
- // when e-mail domain of contact and company are the same, use contact e-mail at first (and company e-mail at second)
- $v->setEmail($contact->email);
+ // support by Microsoft Outlook (2019 and possible earlier)
+ $v->setEmail($company->email, 'INTERNET');
+ }
+ // when e-mail of contact and company complete different use company e-mail at first (and contact e-mail at second)
+ else
+ {
+ $v->setEmail($company->email);
@@ -103,9 +109,2 @@
- // support by Microsoft Outlook (2019 and possible earlier)
- $v->setEmail($company->email, 'INTERNET');
- } else {
- // when e-mail of contact and company complete different use company e-mail at first (and contact e-mail at second)
- $v->setEmail($company->email);
-
- // support by Microsoft Outlook (2019 and possible earlier)
- $v->setEmail($contact->email, 'INTERNET');
- }
+ // support by Microsoft Outlook (2019 and possible earlier)
+ $v->setEmail($contact->email, 'INTERNET');
@@ -115,3 +114 @@
- if ($company->typent_code != 'TE_PRIVATE') {
- $v->setOrg($company->name);
- }
+ if ($contact->typent_code != 'TE_PRIVATE') $v->setOrg($company->name);
@@ -122,3 +119 @@
-if ($contact->birthday) {
- $v->setBirthday($contact->birthday);
-}
+if ($contact->birthday) $v->setBirthday($contact->birthday);
@@ -133 +128 @@
-$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf"
+$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf"