diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 2aeb2e4e2a1..ca496540a47 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -65,36 +65,44 @@ $extrafields->fetch_name_optionals_label($object->table_element); $object->getCanvas($id); $objcanvas = null; $canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas")); -if (!empty($canvas)) -{ +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('contact', 'contactcard', $canvas); } -if (GETPOST('actioncode', 'array')) -{ +if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + if (!count($actioncode)) { + $actioncode = '0'; + } } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } $search_agenda_label = GETPOST('search_agenda_label'); // Security check -if ($user->socid) $socid = $user->socid; +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 $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'); -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 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = 'a.datep, a.id'; -if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) { + $sortfield = 'a.datep, a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC'; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('contactagenda', 'globalcard')); @@ -106,20 +114,19 @@ $hookmanager->initHooks(array('contactagenda', 'globalcard')); $parameters = array('id'=>$id, 'objcanvas'=>$objcanvas); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; } // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $actioncode = ''; $search_agenda_label = ''; } @@ -133,29 +140,30 @@ if (empty($reshook)) $form = new Form($db); $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; +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); -if ($socid > 0) -{ +if ($socid > 0) { $objsoc = new Societe($db); $objsoc->fetch($socid); } -if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) -{ +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 + 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 { // ----------------------------------------- @@ -163,26 +171,27 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // ----------------------------------------- // Confirm deleting contact - if ($user->rights->societe->contact->supprimer) - { - if ($action == 'delete') - { + if ($user->rights->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 - */ + * Onglets + */ $head = array(); - if ($id > 0) - { + if ($id > 0) { // Si edition contact deja existant $object = new Contact($db); $res = $object->fetch($id, $user); - if ($res < 0) { dol_print_error($db, $object->error); exit; } + if ($res < 0) { + dol_print_error($db, $object->error); exit; + } $res = $object->fetch_optionals(); - if ($res < 0) { dol_print_error($db, $object->error); exit; } + if ($res < 0) { + dol_print_error($db, $object->error); exit; + } // Show tabs $head = contact_prepare_head($object); @@ -190,13 +199,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); } - if (!empty($id) && $action != 'edit' && $action != 'create') - { + if (!empty($id) && $action != 'edit' && $action != 'create') { $objsoc = new Societe($db); /* - * Fiche en mode visualisation - */ + * Fiche en mode visualisation + */ dol_htmloutput_errors($error, $errors); @@ -205,14 +213,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
| '; $form = new Form($db); - if ($object->birthday) - { + 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); @@ -855,8 +844,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ' | '; print ': ';
- if ($object->birthday_alert)
- {
+ if ($object->birthday_alert) {
print '';
} else {
print '';
@@ -870,8 +858,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print ' ';
print '';
- if (!empty($backtopage))
- {
+ if (!empty($backtopage)) {
print ' ';
print '';
} else {
@@ -883,12 +870,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print "";
} elseif ($action == 'edit' && !empty($id)) {
/*
- * Fiche en mode edition
- */
+ * Fiche en mode edition
+ */
// We set country_id, and country_code label of the chosen country
- if (GETPOSTISSET("country_id") || $object->country_id)
- {
+ if (GETPOSTISSET("country_id") || $object->country_id) {
$tmparray = getCountry($object->country_id, 'all');
$object->country_code = $tmparray['code'];
$object->country = $tmparray['label'];
@@ -900,8 +886,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// Show errors
dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
- if ($conf->use_javascript_ajax)
- {
+ if ($conf->use_javascript_ajax) {
print "\n".''."\n";
}
- if (!GETPOSTISSET("no_email") && !empty($object->email))
- {
+ if (!GETPOSTISSET("no_email") && !empty($object->email)) {
$result=$object->getNoEmail();
if ($result<0) {
setEventMessages($object->error, $object->errors, 'errors');
@@ -1145,36 +1128,31 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$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))
- {
+ if (empty($reshook)) {
print $object->showOptionals($extrafields, 'edit', $parameters);
}
$object->load_ref_elements();
- if (!empty($conf->commande->enabled))
- {
+ if (!empty($conf->commande->enabled)) {
print ' '.$langs->trans("ContactForOrders").' | ';
print $object->ref_commande ? $object->ref_commande : $langs->trans("NoContactForAnyOrder");
print ' | '.$langs->trans("ContactForProposals").' | ';
print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal");
print ' | '.$langs->trans("ContactForContracts").' | ';
print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract");
print ' | '.$langs->trans("ContactForInvoices").' | ';
print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice");
print ' | '.$langs->trans("DolibarrLogin").' | ';
- if ($object->user_id)
- {
+ 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");
+ } else {
+ print $langs->trans("NoDolibarrAccess");
+ }
print ' | \n"; } print '
'; - if (!empty($conf->societe->enabled)) - { - if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser"); - else $text .= $langs->trans("UserWillBeInternalUser"); + 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'); } @@ -1269,13 +1249,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = ' ';
- if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
- {
+ 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");
+ if ($objsoc->id > 0) {
+ $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
+ } else {
+ $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
+ }
}
$morehtmlref .= ' ';
@@ -1297,16 +1279,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print ''.$langs->trans("PostOrFunction").' | '.$object->poste.' | '.$langs->trans("NbOfEMailingsSend").' | ';
print ''.$object->getNbOfEMailings().' | '; print ''; @@ -1336,7 +1315,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print '
| ';
if ($action == 'editlevel') {
@@ -1354,8 +1335,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print ' ';
foreach ($object->cacheprospectstatus as $key => $val) {
$titlealt = 'default';
- if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label'];
- if ($object->stcomm_id != $val['id']) print 'id.'&stcomm='.$val['code'].'&action=setstcomm&token='.newToken().'">'.img_action($titlealt, $val['code'], $val['picto']).'';
+ if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) {
+ $titlealt = $val['label'];
+ }
+ if ($object->stcomm_id != $val['id']) {
+ print 'id.'&stcomm='.$val['code'].'&action=setstcomm&token='.newToken().'">'.img_action($titlealt, $val['code'], $val['picto']).'';
+ }
}
print ' | |||||||||||||||||||
| '.$langs->trans("ContactForProposals").' | '; print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal"); print ' | ||||||||||||||||||||||||||||||||||
| '; - if (!empty($conf->expedition->enabled)) { print $langs->trans("ContactForOrdersOrShipments"); } else print $langs->trans("ContactForOrders"); + 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"); } + if (!empty($conf->expedition->enabled)) { + $none = $langs->trans("NoContactForAnyOrderOrShipments"); + } print $object->ref_commande ? $object->ref_commande : $none; print ' | ||||||||||||||||||||||||||||||||||
| '.$langs->trans("ContactForContracts").' | '; print $object->ref_contrat ? $object->ref_contrat : $langs->trans("NoContactForAnyContract"); print ' | ||||||||||||||||||||||||||||||||||
| '.$langs->trans("ContactForInvoices").' | '; print $object->ref_facturation ? $object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); print ' | ||||||||||||||||||||||||||||||||||
| '.$langs->trans("DolibarrLogin").' | '; - if ($object->user_id) - { + 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"); + } else { + print $langs->trans("NoDolibarrAccess"); + } print ' | ||||||||||||||||||||||||||||||||||
| ';
@@ -1452,11 +1440,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if (empty($reshook) && $action != 'presend')
- {
+ if (empty($reshook) && $action != 'presend') {
if (empty($user->socid)) {
- if (!empty($object->email))
- {
+ if (!empty($object->email)) {
$langs->load("mails");
print '';
} else {
@@ -1465,30 +1451,25 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
}
}
- if ($user->rights->societe->contact->creer)
- {
+ if ($user->rights->societe->contact->creer) {
print ''.$langs->trans('Modify').'';
}
- if (!$object->user_id && $user->rights->user->user->creer)
- {
+ if (!$object->user_id && $user->rights->user->user->creer) {
print ''.$langs->trans("CreateDolibarrLogin").'';
}
// Activer
- if ($object->statut == 0 && $user->rights->societe->contact->creer)
- {
+ if ($object->statut == 0 && $user->rights->societe->contact->creer) {
print ''.$langs->trans("Reactivate").'';
}
// Desactiver
- if ($object->statut == 1 && $user->rights->societe->contact->creer)
- {
+ if ($object->statut == 1 && $user->rights->societe->contact->creer) {
print ''.$langs->trans("DisableUser").'';
}
// Delete
- if ($user->rights->societe->contact->supprimer)
- {
+ if ($user->rights->societe->contact->supprimer) {
print ''.$langs->trans('Delete').'';
}
}
@@ -1500,8 +1481,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$action = 'presend';
}
- if ($action != 'presend')
- {
+ if ($action != 'presend') {
print ' ';
print ' ';
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index 1d2cb3355a5..62d0d444c3e 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -473,40 +473,35 @@ class Contact extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."socpeople");
- if (!$error)
- {
+ if (!$error) {
$result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ...
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
$this->error = $this->db->lasterror();
}
}
- if (!$error)
- {
+ if (!$error) {
$result = $this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
$this->error = $this->db->lasterror();
}
}
- if (!$error)
- {
+ if (!$error) {
// Call trigger
$result = $this->call_trigger('CONTACT_CREATE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return $this->id;
} else {
@@ -558,13 +553,20 @@ class Contact extends CommonObject
$this->town = (empty($this->town) ? '' : trim($this->town));
$this->setUpperOrLowerCase();
$this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
- if (empty($this->statut)) $this->statut = 0;
- if (empty($this->civility_code) && !is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility
+ if (empty($this->statut)) {
+ $this->statut = 0;
+ }
+ if (empty($this->civility_code) && !is_numeric($this->civility_id)) {
+ $this->civility_code = $this->civility_id; // For backward compatibility
+ }
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET ";
- if ($this->socid > 0) $sql .= " fk_soc='".$this->db->escape($this->socid)."',";
- elseif ($this->socid == -1) $sql .= " fk_soc=null,";
+ if ($this->socid > 0) {
+ $sql .= " fk_soc='".$this->db->escape($this->socid)."',";
+ } elseif ($this->socid == -1) {
+ $sql .= " fk_soc=null,";
+ }
$sql .= " civility='".$this->db->escape($this->civility_code)."'";
$sql .= ", lastname='".$this->db->escape($this->lastname)."'";
$sql .= ", firstname='".$this->db->escape($this->firstname)."'";
@@ -586,8 +588,7 @@ class Contact extends CommonObject
$sql .= ", phone_mobile = ".(isset($this->phone_mobile) ? "'".$this->db->escape($this->phone_mobile)."'" : "null");
$sql .= ", priv = '".$this->db->escape($this->priv)."'";
$sql .= ", fk_prospectcontactlevel = '".$this->db->escape($this->fk_prospectlevel)."'";
- if (isset($this->stcomm_id))
- {
+ if (isset($this->stcomm_id)) {
$sql .= ", fk_stcommcontact = ".($this->stcomm_id > 0 || $this->stcomm_id == -1 ? $this->stcomm_id : "0");
}
$sql .= ", statut = ".$this->db->escape($this->statut);
@@ -598,8 +599,7 @@ class Contact extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
unset($this->country_code);
unset($this->country);
unset($this->state_code);
@@ -608,25 +608,21 @@ class Contact extends CommonObject
$action = 'update';
// Actions on extra fields
- if (!$error)
- {
+ if (!$error) {
$result = $this->insertExtraFields();
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
if (!$error) {
$result = $this->updateRoles();
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
- if (!$error && $this->user_id > 0)
- {
+ if (!$error && $this->user_id > 0) {
// If contact is linked to a user
$tmpobj = new User($this->db);
$tmpobj->fetch($this->user_id);
@@ -685,14 +681,18 @@ class Contact extends CommonObject
// }
if ($usermustbemodified) {
$result = $tmpobj->update($user, 0, 1, 1, 1);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
}
}
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('CONTACT_MODIFY', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
@@ -759,34 +759,69 @@ class Contact extends CommonObject
$this->fullname = $this->getFullName($langs);
// Fields
- if ($this->fullname && !empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname;
- if ($this->lastname && !empty($conf->global->LDAP_CONTACT_FIELD_NAME)) $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname;
- if ($this->firstname && !empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname;
+ if ($this->fullname && !empty($conf->global->LDAP_CONTACT_FIELD_FULLNAME)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_FULLNAME] = $this->fullname;
+ }
+ if ($this->lastname && !empty($conf->global->LDAP_CONTACT_FIELD_NAME)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_NAME] = $this->lastname;
+ }
+ if ($this->firstname && !empty($conf->global->LDAP_CONTACT_FIELD_FIRSTNAME)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME] = $this->firstname;
+ }
- if ($this->poste) $info["title"] = $this->poste;
+ if ($this->poste) {
+ $info["title"] = $this->poste;
+ }
if ($this->socid > 0) {
$soc = new Societe($this->db);
$soc->fetch($this->socid);
$info[$conf->global->LDAP_CONTACT_FIELD_COMPANY] = $soc->name;
- if ($soc->client == 1) $info["businessCategory"] = "Customers";
- if ($soc->client == 2) $info["businessCategory"] = "Prospects";
- if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers";
+ if ($soc->client == 1) {
+ $info["businessCategory"] = "Customers";
+ }
+ if ($soc->client == 2) {
+ $info["businessCategory"] = "Prospects";
+ }
+ if ($soc->fournisseur == 1) {
+ $info["businessCategory"] = "Suppliers";
+ }
+ }
+ if ($this->address && !empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address;
+ }
+ if ($this->zip && !empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip;
+ }
+ if ($this->town && !empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town;
+ }
+ if ($this->country_code && !empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code;
+ }
+ if ($this->phone_pro && !empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro;
+ }
+ if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso;
+ }
+ if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile;
+ }
+ if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax;
+ }
+ if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype;
+ }
+ if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2);
+ }
+ if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) {
+ $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email;
}
- if ($this->address && !empty($conf->global->LDAP_CONTACT_FIELD_ADDRESS)) $info[$conf->global->LDAP_CONTACT_FIELD_ADDRESS] = $this->address;
- if ($this->zip && !empty($conf->global->LDAP_CONTACT_FIELD_ZIP)) $info[$conf->global->LDAP_CONTACT_FIELD_ZIP] = $this->zip;
- if ($this->town && !empty($conf->global->LDAP_CONTACT_FIELD_TOWN)) $info[$conf->global->LDAP_CONTACT_FIELD_TOWN] = $this->town;
- if ($this->country_code && !empty($conf->global->LDAP_CONTACT_FIELD_COUNTRY)) $info[$conf->global->LDAP_CONTACT_FIELD_COUNTRY] = $this->country_code;
- if ($this->phone_pro && !empty($conf->global->LDAP_CONTACT_FIELD_PHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_PHONE] = $this->phone_pro;
- if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso;
- if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile;
- if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax;
- if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype;
- if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2);
- if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email;
- if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
- {
+ if ($conf->global->LDAP_SERVER_TYPE == 'egroupware') {
$info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware
$info['uidnumber'] = $this->id;
@@ -805,8 +840,12 @@ class Contact extends CommonObject
$info["phpgwContactOwner"] = $this->egroupware_id;
- if ($this->email) $info["rfc822Mailbox"] = $this->email;
- if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
+ if ($this->email) {
+ $info["rfc822Mailbox"] = $this->email;
+ }
+ if ($this->phone_mobile) {
+ $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
+ }
}
return $info;
@@ -834,13 +873,14 @@ class Contact extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET";
$sql .= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null");
$sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null");
- if ($user) $sql .= ", fk_user_modif=".$user->id;
+ if ($user) {
+ $sql .= ", fk_user_modif=".$user->id;
+ }
$sql .= " WHERE rowid=".$this->db->escape($id);
dol_syslog(get_class($this)."::update_perso this->birthday=".$this->birthday." -", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$error++;
$this->error = $this->db->lasterror();
}
@@ -875,7 +915,9 @@ class Contact extends CommonObject
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('CONTACT_MODIFY', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
@@ -906,8 +948,7 @@ class Contact extends CommonObject
dol_syslog(get_class($this)."::fetch id=".$id." ref_ext=".$ref_ext." email=".$email, LOG_DEBUG);
- if (empty($id) && empty($ref_ext) && empty($email))
- {
+ if (empty($id) && empty($ref_ext) && empty($email)) {
$this->error = 'BadParameter';
return -1;
}
@@ -936,8 +977,9 @@ class Contact extends CommonObject
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcommcontact as st ON c.fk_stcommcontact = st.id';
- if ($id) $sql .= " WHERE c.rowid = ".((int) $id);
- else {
+ if ($id) {
+ $sql .= " WHERE c.rowid = ".((int) $id);
+ } else {
$sql .= " WHERE c.entity IN (".getEntity($this->element).")";
if ($ref_ext) {
$sql .= " AND c.ref_ext = '".$this->db->escape($ref_ext)."'";
@@ -948,17 +990,14 @@ class Contact extends CommonObject
}
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $this->db->num_rows($resql);
- if ($num > 1)
- {
+ if ($num > 1) {
$this->error = 'Fetch found several records. Rename one of contact to avoid duplicate.';
dol_syslog($this->error, LOG_ERR);
return 2;
- } elseif ($num) // $num = 1
- {
+ } elseif ($num) { // $num = 1
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@@ -1030,10 +1069,8 @@ class Contact extends CommonObject
$sql .= " WHERE u.fk_socpeople = ".$this->id;
$resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
+ if ($resql) {
+ if ($this->db->num_rows($resql)) {
$uobj = $this->db->fetch_object($resql);
$this->user_id = $uobj->rowid;
@@ -1049,17 +1086,14 @@ class Contact extends CommonObject
$this->fetch_optionals();
// Load also alerts of this user
- if ($user)
- {
+ if ($user) {
$sql = "SELECT fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."user_alert";
$sql .= " WHERE fk_user = ".$user->id." AND fk_contact = ".$this->db->escape($id);
$resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
+ if ($resql) {
+ if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->birthday_alert = 1;
@@ -1102,11 +1136,9 @@ class Contact extends CommonObject
{
unset($this->gender);
- if (in_array($this->civility_id, array('MR')) || in_array($this->civility_code, array('MR')))
- {
+ if (in_array($this->civility_id, array('MR')) || in_array($this->civility_code, array('MR'))) {
$this->gender = 'man';
- } elseif (in_array($this->civility_id, array('MME', 'MLE')) || in_array($this->civility_code, array('MME', 'MLE')))
- {
+ } elseif (in_array($this->civility_id, array('MME', 'MLE')) || in_array($this->civility_code, array('MME', 'MLE'))) {
$this->gender = 'woman';
}
}
@@ -1135,16 +1167,18 @@ class Contact extends CommonObject
dol_syslog(get_class($this)."::load_ref_elements", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
- while ($obj = $this->db->fetch_object($resql))
- {
- if ($obj->nb)
- {
- if ($obj->element == 'facture') $this->ref_facturation = $obj->nb;
- elseif ($obj->element == 'contrat') $this->ref_contrat = $obj->nb;
- elseif ($obj->element == 'commande') $this->ref_commande = $obj->nb;
- elseif ($obj->element == 'propal') $this->ref_propal = $obj->nb;
+ if ($resql) {
+ while ($obj = $this->db->fetch_object($resql)) {
+ if ($obj->nb) {
+ if ($obj->element == 'facture') {
+ $this->ref_facturation = $obj->nb;
+ } elseif ($obj->element == 'contrat') {
+ $this->ref_contrat = $obj->nb;
+ } elseif ($obj->element == 'commande') {
+ $this->ref_commande = $obj->nb;
+ } elseif ($obj->element == 'propal') {
+ $this->ref_propal = $obj->nb;
+ }
}
}
$this->db->free($resql);
@@ -1169,8 +1203,7 @@ class Contact extends CommonObject
$this->db->begin();
- if (!$error)
- {
+ if (!$error) {
// Get all rowid of element_contact linked to a type that is link to llx_socpeople
$sql = "SELECT ec.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."element_contact ec,";
@@ -1180,21 +1213,18 @@ class Contact extends CommonObject
$sql .= " AND tc.source='external'";
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
- while ($i < $num && !$error)
- {
+ while ($i < $num && !$error) {
$obj = $this->db->fetch_object($resql);
$sqldel = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sqldel .= " WHERE rowid = ".$obj->rowid;
dol_syslog(__METHOD__, LOG_DEBUG);
$result = $this->db->query($sqldel);
- if (!$result)
- {
+ if (!$result) {
$error++;
$this->error = $this->db->error().' sql='.$sqldel;
}
@@ -1207,56 +1237,48 @@ class Contact extends CommonObject
}
}
- if (!$error)
- {
+ if (!$error) {
// Remove Roles
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople = ".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$error++;
$this->error .= $this->db->lasterror();
$errorflag = -1;
}
}
- if (!$error)
- {
+ if (!$error) {
// Remove Roles
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople = ".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$error++;
$this->error .= $this->db->lasterror();
$errorflag = -1;
}
}
- if (!$error)
- {
+ if (!$error) {
// Remove category
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_contact WHERE fk_socpeople = ".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$error++;
$this->error .= $this->db->lasterror();
$errorflag = -1;
}
}
- if (!$error)
- {
+ if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople";
$sql .= " WHERE rowid=".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG);
$result = $this->db->query($sql);
- if (!$result)
- {
+ if (!$result) {
$error++;
$this->error = $this->db->error().' sql='.$sql;
}
@@ -1266,19 +1288,21 @@ class Contact extends CommonObject
if (!$error) {
// For avoid conflicts if trigger used
$result = $this->deleteExtraFields();
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
}
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('CONTACT_DELETE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return 1;
} else {
@@ -1303,10 +1327,8 @@ class Contact extends CommonObject
$sql .= " WHERE c.rowid = ".$this->db->escape($id);
$resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
+ if ($resql) {
+ if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@@ -1346,8 +1368,7 @@ class Contact extends CommonObject
$sql .= " AND m.entity IN (".getEntity($this->element).") AND mc.statut NOT IN (-1,0)"; // -1 error, 0 not sent, 1 sent with success
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $this->db->fetch_object($resql);
$nb = $obj->nb;
@@ -1377,8 +1398,7 @@ class Contact extends CommonObject
$result = ''; $label = '';
- if (!empty($this->photo) && class_exists('Form'))
- {
+ if (!empty($this->photo) && class_exists('Form')) {
$label .= ' ';
$label .= Form::showphoto('contact', $this, 0, 40, 0, '', 'mini', 0); // Important, we must force height so image will have height tags and if image is inside a tooltip, the tooltip manager can calculate height and position correctly the tooltip.
$label .= ' ';
@@ -1388,67 +1408,83 @@ class Contact extends CommonObject
$label .= ' '.$this->getLibStatut(4);
$label .= ''.$langs->trans("Name").': '.$this->getFullName($langs); //if ($this->civility_id) $label.= ' ' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code - if (!empty($this->poste)) $label .= ' '.$langs->trans("Poste").': '.$this->poste; + if (!empty($this->poste)) { + $label .= ' '.$langs->trans("Poste").': '.$this->poste; + } $label .= ' '.$langs->trans("EMail").': '.$this->email; $phonelist = array(); $country_code = empty($this->country_code) ? '': $this->country_code; - if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $country_code, $this->id, 0, '', ' ', 'phone'); - if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $country_code, $this->id, 0, '', ' ', 'mobile'); - if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $country_code, $this->id, 0, '', ' ', 'phone'); + if ($this->phone_pro) { + $phonelist[] = dol_print_phone($this->phone_pro, $country_code, $this->id, 0, '', ' ', 'phone'); + } + if ($this->phone_mobile) { + $phonelist[] = dol_print_phone($this->phone_mobile, $country_code, $this->id, 0, '', ' ', 'mobile'); + } + if ($this->phone_perso) { + $phonelist[] = dol_print_phone($this->phone_perso, $country_code, $this->id, 0, '', ' ', 'phone'); + } $label .= ' '.$langs->trans("Phone").': '.implode(' ', $phonelist); $label .= ' '.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; - if ($option !== 'nolink') - { + if ($option !== 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } } $url .= $moreparam; $linkclose = ""; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowContact"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; - /* - $hookmanager->initHooks(array('contactdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ + /* + $hookmanager->initHooks(array('contactdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ } $linkstart = ''; $linkend = ''; - if ($option == 'xxx') - { + if ($option == 'xxx') { $linkstart = ''; $linkend = ''; } $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs)); + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + if ($withpicto != 2) { + $result .= ($maxlen ?dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs)); + } $result .= $linkend; global $action; $hookmanager->initHooks(array('contactdao')); $parameters = array('id'=>$this->id, 'getnomurl'=>$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } return $result; } @@ -1463,7 +1499,9 @@ class Contact extends CommonObject global $langs; $code = ($this->civility_code ? $this->civility_code : (!empty($this->civility_id) ? $this->civility : (!empty($this->civilite) ? $this->civilite : ''))); - if (empty($code)) return ''; + if (empty($code)) { + return ''; + } $langs->load("dict"); return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); @@ -1507,7 +1545,9 @@ class Contact extends CommonObject ); $statusType = 'status4'; - if ($status == 0 || $status == 5) $statusType = 'status5'; + if ($status == 0 || $status == 5) { + $statusType = 'status5'; + } $label = $langs->trans($labelStatus[$status]); $labelshort = $langs->trans($labelStatusShort[$status]); @@ -1527,8 +1567,11 @@ class Contact extends CommonObject { // phpcs:enable global $langs; - if ($status == '1') return $langs->trans('ContactPrivate'); - else return $langs->trans('ContactPublic'); + if ($status == '1') { + return $langs->trans('ContactPrivate'); + } else { + return $langs->trans('ContactPublic'); + } } @@ -1547,7 +1590,9 @@ class Contact extends CommonObject $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) $socid = $obj->rowid; + if ($obj) { + $socid = $obj->rowid; + } } // Initialise parameters @@ -1592,8 +1637,11 @@ class Contact extends CommonObject $error = 0; // Check parameters - if ($this->statut == $status) return 0; - else $this->statut = $status; + if ($this->statut == $status) { + return 0; + } else { + $this->statut = $status; + } $this->db->begin(); @@ -1604,16 +1652,16 @@ class Contact extends CommonObject $result = $this->db->query($sql); dol_syslog(get_class($this)."::setstatus", LOG_DEBUG); - if ($result) - { + if ($result) { // Call trigger $result = $this->call_trigger('CONTACT_ENABLEDISABLE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if ($error) - { + if ($error) { $this->db->rollback(); return -$error; } else { @@ -1725,12 +1773,10 @@ class Contact extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tab[] = array('fk_socpeople'=>$obj->id, 'type_contact'=>$obj->fk_c_type_contact); @@ -1758,7 +1804,9 @@ class Contact extends CommonObject $error = 0; - if (!isset($this->roles)) return; // Avoid to loose roles when property not set + if (!isset($this->roles)) { + return; // Avoid to loose roles when property not set + } $this->db->begin(); @@ -1800,8 +1848,7 @@ class Contact extends CommonObject $sql .= ")"; $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $this->errors[] = $this->db->lasterror().' sql='.$sql; $error++; } @@ -1830,12 +1877,13 @@ class Contact extends CommonObject global $langs; $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcommcontact"; - if ($active >= 0) $sql .= " WHERE active = ".$active; + if ($active >= 0) { + $sql .= " WHERE active = ".$active; + } $resql = $this->db->query($sql); $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $this->cacheprospectstatus[$obj->id] = array('id' => $obj->id, 'code' => $obj->code, 'label' => ($langs->trans("ST_".strtoupper($obj->code)) == "ST_".strtoupper($obj->code)) ? $obj->label : $langs->trans("ST_".strtoupper($obj->code)), 'picto' => $obj->picto); $i++; @@ -1865,8 +1913,7 @@ class Contact extends CommonObject $lib = $langs->trans("ProspectLevel".$fk_prospectlevel); // If lib not found in language file, we get label from cache/databse - if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel)) - { + if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel)) { $lib = $langs->getLabelFromKey($this->db, $fk_prospectlevel, 'c_prospectlevel', 'code', 'label'); } return $lib; @@ -1915,36 +1962,48 @@ class Contact extends CommonObject global $langs; $langs->load('customers'); - if ($mode == 2) - { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); - else { + if ($mode == 2) { + if ($statut == '-1' || $statut == 'ST_NO') { + return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); + } elseif ($statut == '0' || $statut == 'ST_NEVER') { + return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); + } elseif ($statut == '1' || $statut == 'ST_TODO') { + return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); + } elseif ($statut == '2' || $statut == 'ST_PEND') { + return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); + } elseif ($statut == '3' || $statut == 'ST_DONE') { + return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); + } else { return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); } } - if ($mode == 3) - { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto); - else { + if ($mode == 3) { + if ($statut == '-1' || $statut == 'ST_NO') { + return img_action($langs->trans("StatusProspect-1"), -1, $picto); + } elseif ($statut == '0' || $statut == 'ST_NEVER') { + return img_action($langs->trans("StatusProspect0"), 0, $picto); + } elseif ($statut == '1' || $statut == 'ST_TODO') { + return img_action($langs->trans("StatusProspect1"), 1, $picto); + } elseif ($statut == '2' || $statut == 'ST_PEND') { + return img_action($langs->trans("StatusProspect2"), 2, $picto); + } elseif ($statut == '3' || $statut == 'ST_DONE') { + return img_action($langs->trans("StatusProspect3"), 3, $picto); + } else { return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto); } } - if ($mode == 4) - { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); - else { + if ($mode == 4) { + if ($statut == '-1' || $statut == 'ST_NO') { + return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); + } elseif ($statut == '0' || $statut == 'ST_NEVER') { + return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); + } elseif ($statut == '1' || $statut == 'ST_TODO') { + return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); + } elseif ($statut == '2' || $statut == 'ST_PEND') { + return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); + } elseif ($statut == '3' || $statut == 'ST_DONE') { + return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); + } else { return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); } } @@ -1964,24 +2023,19 @@ class Contact extends CommonObject $error = 0; // Update mass emailing flag into table mailing_unsubscribe - if ($this->email) - { + if ($this->email) { $this->db->begin(); - if ($no_email) - { + if ($no_email) { $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$this->db->escape($this->email)."'"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $noemail = $obj->nb; - if (empty($noemail)) - { + if (empty($noemail)) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$this->db->escape($this->email)."', ".$this->db->escape(getEntity('mailing', 0)).", '".$this->db->idate(dol_now())."')"; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -1995,8 +2049,7 @@ class Contact extends CommonObject } else { $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$this->db->escape($this->email)."' AND entity = ".$this->db->escape(getEntity('mailing', 0)); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -2024,8 +2077,7 @@ class Contact extends CommonObject */ public function getNoEmail() { - if ($this->email) - { + if ($this->email) { $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing').") AND email = '".$this->db->escape($this->email)."'"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index da00374cc2a..1e0f5b06094 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -37,8 +37,12 @@ $id = GETPOST('id', 'int'); $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); -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(); +} $socid = $object->thirdparty->id; // Sort & Order fields @@ -46,12 +50,18 @@ $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'); -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 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder = 'DESC'; -if (!$sortfield) $sortfield = 'dateprint'; +if (!$sortorder) { + $sortorder = 'DESC'; +} +if (!$sortfield) { + $sortfield = 'dateprint'; +} // Search fields $sref = GETPOST("sref"); @@ -60,8 +70,7 @@ $month = GETPOST('month', 'int'); $year = GETPOST('year', 'int'); // Clean up on purge search criteria ? -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 -{ +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 = ''; @@ -84,7 +93,9 @@ $hookmanager->initHooks(array('consumptioncontact')); $parameters = array('id'=>$id); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} /* @@ -99,8 +110,7 @@ $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("C $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); -if (empty($id)) -{ +if (empty($id)) { dol_print_error($db); exit; } @@ -111,13 +121,15 @@ print dol_get_fiche_head($head, 'consumption', $langs->trans("ContactsAddresses" $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = ' ';
-if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
-{
+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");
+ if ($objsoc->id > 0) {
+ $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
+ } else {
+ $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
+ }
}
$morehtmlref .= ' ';
@@ -133,22 +145,34 @@ print ''.$langs->trans("UserTitle").' | ';
print $object->getCivilityLabel();
print ' | | |||||||||||||||||||||||||||||||||