';
print '| '.$langs->trans("DisableProspectCustomerType").' | ';
print ' | ';
print '';
-if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS))
-{
+if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
print '';
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
diff --git a/htdocs/societe/admin/societe_extrafields.php b/htdocs/societe/admin/societe_extrafields.php
index 16d88142588..d1ffffd6b87 100644
--- a/htdocs/societe/admin/societe_extrafields.php
+++ b/htdocs/societe/admin/societe_extrafields.php
@@ -36,13 +36,17 @@ $form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
-foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
+foreach ($tmptype2label as $key => $val) {
+ $type2label[$key] = $langs->transnoentitiesnoconv($val);
+}
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'societe'; //Must be the $element of the class that manage extrafield
-if (!$user->admin) accessforbidden();
+if (!$user->admin) {
+ accessforbidden();
+}
/*
@@ -77,8 +81,7 @@ print dol_get_fiche_end();
// Buttons
-if ($action != 'create' && $action != 'edit')
-{
+if ($action != 'create' && $action != 'edit') {
print '";
@@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit')
/* */
/* ************************************************************************** */
-if ($action == 'create')
-{
+if ($action == 'create') {
print ' ';
print load_fiche_titre($langs->trans('NewAttribute'));
@@ -104,8 +106,7 @@ if ($action == 'create')
/* Edition d'un champ optionnel */
/* */
/* ************************************************************************** */
-if ($action == 'edit' && !empty($attrname))
-{
+if ($action == 'edit' && !empty($attrname)) {
print ' ';
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php
index f98f7ac7ccf..8789427c64b 100644
--- a/htdocs/societe/agenda.php
+++ b/htdocs/societe/agenda.php
@@ -34,10 +34,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->loadLangs(array("companies", "bills", "propal", "orders"));
-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));
}
@@ -45,19 +46,27 @@ $search_agenda_label = GETPOST('search_agenda_label');
// Security check
$socid = GETPOST('socid', 'int');
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'societe', $socid, '&societe');
$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,DESC';
+if (!$sortfield) {
+ $sortfield = 'a.datep,a.id';
+}
+if (!$sortorder) {
+ $sortorder = 'DESC,DESC';
+}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('agendathirdparty'));
@@ -69,20 +78,19 @@ $hookmanager->initHooks(array('agendathirdparty'));
$parameters = array('id'=>$socid);
$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 tests are required to be compatible with all browsers
- {
+ 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
$actioncode = '';
$search_agenda_label = '';
}
@@ -96,8 +104,7 @@ if (empty($reshook))
$form = new Form($db);
-if ($socid > 0)
-{
+if ($socid > 0) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@@ -105,10 +112,14 @@ if ($socid > 0)
$result = $object->fetch($socid);
$title = $langs->trans("Agenda");
- if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title;
+ if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
+ $title = $object->name." - ".$title;
+ }
llxHeader('', $title);
- if (!empty($conf->notification->enabled)) $langs->load("mails");
+ if (!empty($conf->notification->enabled)) {
+ $langs->load("mails");
+ }
$head = societe_prepare_head($object);
print dol_get_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, 'company');
@@ -137,29 +148,31 @@ if ($socid > 0)
$out = '';
$permok = $user->rights->agenda->myactions->create;
- if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok)
- {
- if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : ''));
+ if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
+ if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') {
+ $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : ''));
+ }
$out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&percentage=-1';
$out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog');
}
$newcardbutton = '';
- if (!empty($conf->agenda->enabled))
- {
- if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create))
- {
+ if (!empty($conf->agenda->enabled)) {
+ if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
$newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
}
}
- if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
- {
+ if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
print ' ';
$param = '&socid='.$socid;
- if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
- if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
+ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+ $param .= '&contextpage='.$contextpage;
+ }
+ if ($limit > 0 && $limit != $conf->liste_limit) {
+ $param .= '&limit='.$limit;
+ }
print load_fiche_titre($langs->trans("ActionsOnCompany"), $newcardbutton, '');
//print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1);
diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php
index a56fa0d9f81..ba33386f360 100644
--- a/htdocs/societe/ajax/company.php
+++ b/htdocs/societe/ajax/company.php
@@ -22,12 +22,24 @@
* \brief File to return Ajax response on thirdparty list request
*/
-if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
-if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
-if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
-if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
-if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
-if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
+if (!defined('NOTOKENRENEWAL')) {
+ define('NOTOKENRENEWAL', 1); // Disables token renewal
+}
+if (!defined('NOREQUIREMENU')) {
+ define('NOREQUIREMENU', '1');
+}
+if (!defined('NOREQUIREHTML')) {
+ define('NOREQUIREHTML', '1');
+}
+if (!defined('NOREQUIREAJAX')) {
+ define('NOREQUIREAJAX', '1');
+}
+if (!defined('NOREQUIRESOC')) {
+ define('NOREQUIRESOC', '1');
+}
+if (!defined('NOCSRFCHECK')) {
+ define('NOCSRFCHECK', '1');
+}
require '../../main.inc.php';
@@ -48,16 +60,14 @@ $showtype = GETPOST('showtype', 'int');
dol_syslog(join(',', $_GET));
//print_r($_GET);
-if (!empty($action) && $action == 'fetch' && !empty($id))
-{
+if (!empty($action) && $action == 'fetch' && !empty($id)) {
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$outjson = array();
$object = new Societe($db);
$ret = $object->fetch($id);
- if ($ret > 0)
- {
+ if ($ret > 0) {
$outref = $object->ref;
$outname = $object->name;
$outdesc = '';
@@ -74,7 +84,9 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
top_httphead();
- if (empty($htmlname)) return;
+ if (empty($htmlname)) {
+ return;
+ }
$match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET));
sort($match);
@@ -83,12 +95,18 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
// When used from jQuery, the search term is added as GET param "term".
$searchkey = (($id && GETPOST($id, 'alpha')) ?GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ?GETPOST($htmlname, 'alpha') : ''));
- if (!$searchkey) return;
+ if (!$searchkey) {
+ return;
+ }
- if (!is_object($form)) $form = new Form($db);
+ if (!is_object($form)) {
+ $form = new Form($db);
+ }
$arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson);
$db->close();
- if ($outjson) print json_encode($arrayresult);
+ if ($outjson) {
+ print json_encode($arrayresult);
+ }
}
diff --git a/htdocs/societe/ajaxcompanies.php b/htdocs/societe/ajaxcompanies.php
index da7591a419b..3221aafff55 100644
--- a/htdocs/societe/ajaxcompanies.php
+++ b/htdocs/societe/ajaxcompanies.php
@@ -23,12 +23,24 @@
* \brief File to return Ajax response on third parties request
*/
-if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
-if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
-if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
-if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
-if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
-if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
+if (!defined('NOTOKENRENEWAL')) {
+ define('NOTOKENRENEWAL', 1); // Disables token renewal
+}
+if (!defined('NOREQUIREMENU')) {
+ define('NOREQUIREMENU', '1');
+}
+if (!defined('NOREQUIREHTML')) {
+ define('NOREQUIREHTML', '1');
+}
+if (!defined('NOREQUIREAJAX')) {
+ define('NOREQUIREAJAX', '1');
+}
+if (!defined('NOREQUIRESOC')) {
+ define('NOREQUIRESOC', '1');
+}
+if (!defined('NOCSRFCHECK')) {
+ define('NOCSRFCHECK', '1');
+}
require '../main.inc.php';
@@ -50,24 +62,25 @@ dol_syslog(join(',', $_GET));
// Generation liste des societes
-if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn'))
-{
+if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) {
$return_arr = array();
// Define filter on text typed
$socid = $_GET['newcompany'] ? $_GET['newcompany'] : '';
- if (!$socid) $socid = $_GET['socid'] ? $_GET['socid'] : '';
- if (!$socid) $socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : '';
+ if (!$socid) {
+ $socid = $_GET['socid'] ? $_GET['socid'] : '';
+ }
+ if (!$socid) {
+ $socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : '';
+ }
$sql = "SELECT rowid, nom";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.entity IN (".getEntity('societe').")";
- if ($socid)
- {
+ if ($socid) {
$sql .= " AND (";
// Add criteria on name/code
- if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) // Can use index
- {
+ if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) { // Can use index
$sql .= "nom LIKE '".$db->escape($socid)."%'";
$sql .= " OR code_client LIKE '".$db->escape($socid)."%'";
$sql .= " OR code_fournisseur LIKE '".$db->escape($socid)."%'";
@@ -76,7 +89,9 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn'))
$sql .= " OR code_client LIKE '%".$db->escape($socid)."%'";
$sql .= " OR code_fournisseur LIKE '%".$db->escape($socid)."%'";
}
- if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) $sql .= " OR rowid = '".$db->escape($socid)."'";
+ if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) {
+ $sql .= " OR rowid = '".$db->escape($socid)."'";
+ }
$sql .= ")";
}
//if (GETPOST("filter")) $sql.= " AND (".GETPOST("filter", "alpha").")"; // Add other filters
@@ -84,12 +99,12 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn'))
//dol_syslog("ajaxcompanies", LOG_DEBUG);
$resql = $db->query($sql);
- if ($resql)
- {
- while ($row = $db->fetch_array($resql))
- {
+ if ($resql) {
+ while ($row = $db->fetch_array($resql)) {
$label = $row['nom'];
- if ($socid) $label = preg_replace('/('.preg_quote($socid, '/').')/i', '$1', $label, 1);
+ if ($socid) {
+ $label = preg_replace('/('.preg_quote($socid, '/').')/i', '$1', $label, 1);
+ }
$row_array['label'] = $label;
$row_array['value'] = $row['nom'];
$row_array['key'] = $row['rowid'];
diff --git a/htdocs/societe/ajaxcountries.php b/htdocs/societe/ajaxcountries.php
index dfc4ffd9015..a4efc4ecc94 100644
--- a/htdocs/societe/ajaxcountries.php
+++ b/htdocs/societe/ajaxcountries.php
@@ -22,12 +22,24 @@
* \brief File to return Ajax response on country request
*/
-if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
-if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
-if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
-if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
-if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
-if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
+if (!defined('NOTOKENRENEWAL')) {
+ define('NOTOKENRENEWAL', 1); // Disables token renewal
+}
+if (!defined('NOREQUIREMENU')) {
+ define('NOREQUIREMENU', '1');
+}
+if (!defined('NOREQUIREHTML')) {
+ define('NOREQUIREHTML', '1');
+}
+if (!defined('NOREQUIREAJAX')) {
+ define('NOREQUIREAJAX', '1');
+}
+if (!defined('NOREQUIRESOC')) {
+ define('NOREQUIRESOC', '1');
+}
+if (!defined('NOCSRFCHECK')) {
+ define('NOCSRFCHECK', '1');
+}
require '../main.inc.php';
@@ -50,8 +62,7 @@ print '';
+ // print "\n";
+ // print '';
}
print ' ';
@@ -155,8 +149,7 @@ print $langs->trans("VATIntraManualCheck", $langs->trans("VATIntraCheckURL"), $l
print ' ';
print '';
-if ($messagetoshow)
-{
+if ($messagetoshow) {
print '
';
print "\n".'Error returned: ';
print nl2br($messagetoshow);
diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php
index 82984409325..37ad82602fb 100644
--- a/htdocs/societe/class/api_contacts.class.php
+++ b/htdocs/societe/class/api_contacts.class.php
@@ -34,7 +34,7 @@ class Contacts extends DolibarrApi
*
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
- static $FIELDS = array(
+ public static $FIELDS = array(
'lastname',
);
@@ -71,8 +71,7 @@ class Contacts extends DolibarrApi
*/
public function get($id, $includecount = 0, $includeroles = 0)
{
- if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
- {
+ if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
throw new RestException(401, 'No permission to read contacts');
}
if ($id == 0) {
@@ -81,23 +80,19 @@ class Contacts extends DolibarrApi
$result = $this->contact->fetch($id);
}
- if (!$result)
- {
+ if (!$result) {
throw new RestException(404, 'Contact not found');
}
- if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
- {
+ if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- if ($includecount)
- {
+ if ($includecount) {
$this->contact->load_ref_elements();
}
- if ($includeroles)
- {
+ if ($includeroles) {
$this->contact->fetchRoles();
}
@@ -119,8 +114,7 @@ class Contacts extends DolibarrApi
*/
public function getByEmail($email, $includecount = 0, $includeroles = 0)
{
- if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
- {
+ if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
throw new RestException(401, 'No permission to read contacts');
}
if (empty($email)) {
@@ -129,23 +123,19 @@ class Contacts extends DolibarrApi
$result = $this->contact->fetch('', '', '', $email);
}
- if (!$result)
- {
+ if (!$result) {
throw new RestException(404, 'Contact not found');
}
- if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
- {
+ if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- if ($includecount)
- {
+ if ($includecount) {
$this->contact->load_ref_elements();
}
- if ($includeroles)
- {
+ if ($includeroles) {
$this->contact->fetchRoles();
}
@@ -176,8 +166,7 @@ class Contacts extends DolibarrApi
$obj_ret = array();
- if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
- {
+ if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
throw new RestException(401, 'No permission to read contacts');
}
@@ -186,8 +175,9 @@ class Contacts extends DolibarrApi
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
- if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)
+ if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
$search_sale = DolibarrApiAccess::$user->id;
+ }
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
@@ -201,15 +191,18 @@ class Contacts extends DolibarrApi
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON t.fk_soc = s.rowid";
$sql .= ' WHERE t.entity IN ('.getEntity('socpeople').')';
- if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")";
+ if ($socids) {
+ $sql .= " AND t.fk_soc IN (".$socids.")";
+ }
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0)
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= " AND t.fk_soc = sc.fk_soc";
- if ($search_sale > 0)
+ }
+ if ($search_sale > 0) {
$sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
+ }
// Insert sale filter
- if ($search_sale > 0)
- {
+ if ($search_sale > 0) {
$sql .= " AND sc.fk_user = ".$search_sale;
}
@@ -220,10 +213,8 @@ class Contacts extends DolibarrApi
}
// Add sql filters
- if ($sqlfilters)
- {
- if (!DolibarrApi::_checkFilters($sqlfilters))
- {
+ if ($sqlfilters) {
+ if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@@ -232,10 +223,8 @@ class Contacts extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder);
- if ($limit)
- {
- if ($page < 0)
- {
+ if ($limit) {
+ if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
@@ -243,24 +232,19 @@ class Contacts extends DolibarrApi
$sql .= $this->db->plimit($limit + 1, $offset);
}
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0;
- while ($i < $min)
- {
+ while ($i < $min) {
$obj = $this->db->fetch_object($result);
$contact_static = new Contact($this->db);
- if ($contact_static->fetch($obj->rowid))
- {
+ if ($contact_static->fetch($obj->rowid)) {
$contact_static->fetchRoles();
- if ($includecount)
- {
+ if ($includecount) {
$contact_static->load_ref_elements();
}
- if ($includeroles)
- {
+ if ($includeroles) {
$contact_static->fetchRoles();
}
@@ -272,8 +256,7 @@ class Contacts extends DolibarrApi
} else {
throw new RestException(503, 'Error when retrieve contacts : '.$sql);
}
- if (!count($obj_ret))
- {
+ if (!count($obj_ret)) {
throw new RestException(404, 'Contacts not found');
}
return $obj_ret;
@@ -287,15 +270,13 @@ class Contacts extends DolibarrApi
*/
public function post($request_data = null)
{
- if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
- {
+ if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
throw new RestException(401, 'No permission to create/update contacts');
}
// Check mandatory fields
$result = $this->_validate($request_data);
- foreach ($request_data as $field => $value)
- {
+ foreach ($request_data as $field => $value) {
$this->contact->$field = $value;
}
if ($this->contact->create(DolibarrApiAccess::$user) < 0) {
@@ -313,30 +294,29 @@ class Contacts extends DolibarrApi
*/
public function put($id, $request_data = null)
{
- if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
- {
+ if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
throw new RestException(401, 'No permission to create/update contacts');
}
$result = $this->contact->fetch($id);
- if (!$result)
- {
+ if (!$result) {
throw new RestException(404, 'Contact not found');
}
- if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
- {
+ if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- foreach ($request_data as $field => $value)
- {
- if ($field == 'id') continue;
+ foreach ($request_data as $field => $value) {
+ if ($field == 'id') {
+ continue;
+ }
$this->contact->$field = $value;
}
- if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update'))
+ if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) {
return $this->get($id);
+ }
return false;
}
@@ -349,18 +329,15 @@ class Contacts extends DolibarrApi
*/
public function delete($id)
{
- if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer)
- {
+ if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer) {
throw new RestException(401, 'No permission to delete contacts');
}
$result = $this->contact->fetch($id);
- if (!$result)
- {
+ if (!$result) {
throw new RestException(404, 'Contact not found');
}
- if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
- {
+ if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->contact->oldcopy = clone $this->contact;
@@ -382,10 +359,12 @@ class Contacts extends DolibarrApi
//throw new RestException(401);
//}
- if (!isset($request_data["login"]))
+ if (!isset($request_data["login"])) {
throw new RestException(400, "login field missing");
- if (!isset($request_data["password"]))
+ }
+ if (!isset($request_data["password"])) {
throw new RestException(400, "password field missing");
+ }
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
throw new RestException(401, 'No permission to read contacts');
diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php
index 3e8a6c91f92..be61d3a3436 100644
--- a/htdocs/societe/class/api_thirdparties.class.php
+++ b/htdocs/societe/class/api_thirdparties.class.php
@@ -33,7 +33,7 @@ class Thirdparties extends DolibarrApi
*
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
- static $FIELDS = array(
+ public static $FIELDS = array(
'name'
);
@@ -137,46 +137,68 @@ class Thirdparties extends DolibarrApi
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
- if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
+ if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
+ $search_sale = DolibarrApiAccess::$user->id;
+ }
$sql = "SELECT t.rowid";
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
+ $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
+ }
$sql .= " FROM ".MAIN_DB_PREFIX."societe as t";
if ($category > 0) {
- if ($mode != 4) $sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c";
- if (!in_array($mode, array(1, 2, 3))) $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as cc";
+ if ($mode != 4) {
+ $sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c";
+ }
+ if (!in_array($mode, array(1, 2, 3))) {
+ $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as cc";
+ }
+ }
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
}
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st";
$sql .= " WHERE t.entity IN (".getEntity('societe').")";
$sql .= " AND t.fk_stcomm = st.id";
- if ($mode == 1) $sql .= " AND t.client IN (1, 3)";
- elseif ($mode == 2) $sql .= " AND t.client IN (2, 3)";
- elseif ($mode == 3) $sql .= " AND t.client IN (0)";
- elseif ($mode == 4) $sql .= " AND t.fournisseur IN (1)";
+ if ($mode == 1) {
+ $sql .= " AND t.client IN (1, 3)";
+ } elseif ($mode == 2) {
+ $sql .= " AND t.client IN (2, 3)";
+ } elseif ($mode == 3) {
+ $sql .= " AND t.client IN (0)";
+ } elseif ($mode == 4) {
+ $sql .= " AND t.fournisseur IN (1)";
+ }
// Select thirdparties of given category
if ($category > 0) {
- if (!empty($mode) && $mode != 4) { $sql .= " AND c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid"; }
- elseif (!empty($mode) && $mode == 4) { $sql .= " AND cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid"; }
- else { $sql .= " AND ((c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid) OR (cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid))"; }
+ if (!empty($mode) && $mode != 4) {
+ $sql .= " AND c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid";
+ } elseif (!empty($mode) && $mode == 4) {
+ $sql .= " AND cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid";
+ } else {
+ $sql .= " AND ((c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid) OR (cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid))";
+ }
}
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc";
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
+ $sql .= " AND t.rowid = sc.fk_soc";
+ }
//if ($email != NULL) $sql.= " AND s.email = \"".$email."\"";
- if ($socids) $sql .= " AND t.rowid IN (".$socids.")";
- if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
+ if ($socids) {
+ $sql .= " AND t.rowid IN (".$socids.")";
+ }
+ if ($search_sale > 0) {
+ $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
+ }
// Insert sale filter
- if ($search_sale > 0)
- {
+ if ($search_sale > 0) {
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
- if ($sqlfilters)
- {
- if (!DolibarrApi::_checkFilters($sqlfilters))
- {
+ if ($sqlfilters) {
+ if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@@ -195,13 +217,11 @@ class Thirdparties extends DolibarrApi
}
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0;
- while ($i < $min)
- {
+ while ($i < $min) {
$obj = $this->db->fetch_object($result);
$soc_static = new Societe($this->db);
if ($soc_static->fetch($obj->rowid)) {
@@ -235,8 +255,9 @@ class Thirdparties extends DolibarrApi
foreach ($request_data as $field => $value) {
$this->company->$field = $value;
}
- if ($this->company->create(DolibarrApiAccess::$user) < 0)
+ if ($this->company->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error creating thirdparty', array_merge(array($this->company->error), $this->company->errors));
+ }
return $this->company->id;
}
@@ -264,7 +285,9 @@ class Thirdparties extends DolibarrApi
}
foreach ($request_data as $field => $value) {
- if ($field == 'id') continue;
+ if ($field == 'id') {
+ continue;
+ }
$this->company->$field = $value;
}
@@ -295,8 +318,7 @@ class Thirdparties extends DolibarrApi
$error = 0;
- if ($id == $idtodelete)
- {
+ if ($id == $idtodelete) {
throw new RestException(400, 'Try to merge a thirdparty into itself');
}
@@ -345,26 +367,26 @@ class Thirdparties extends DolibarrApi
'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur',
'model_pdf', 'fk_projet'
);
- foreach ($listofproperties as $property)
- {
- if (empty($object->$property)) $object->$property = $soc_origin->$property;
+ foreach ($listofproperties as $property) {
+ if (empty($object->$property)) {
+ $object->$property = $soc_origin->$property;
+ }
}
// Concat some data
$listofproperties = array(
'note_public', 'note_private'
);
- foreach ($listofproperties as $property)
- {
+ foreach ($listofproperties as $property) {
$object->$property = dol_concatdesc($object->$property, $soc_origin->$property);
}
// Merge extrafields
- if (is_array($soc_origin->array_options))
- {
- foreach ($soc_origin->array_options as $key => $val)
- {
- if (empty($object->array_options[$key])) $object->array_options[$key] = $val;
+ if (is_array($soc_origin->array_options)) {
+ foreach ($soc_origin->array_options as $key => $val) {
+ if (empty($object->array_options[$key])) {
+ $object->array_options[$key] = $val;
+ }
}
}
@@ -378,8 +400,7 @@ class Thirdparties extends DolibarrApi
// If thirdparty has a new code that is same than origin, we clean origin code to avoid duplicate key from database unique keys.
if ($soc_origin->code_client == $object->code_client
|| $soc_origin->code_fournisseur == $object->code_fournisseur
- || $soc_origin->barcode == $object->barcode)
- {
+ || $soc_origin->barcode == $object->barcode) {
dol_syslog("We clean customer and supplier code so we will be able to make the update of target");
$soc_origin->code_client = '';
$soc_origin->code_fournisseur = '';
@@ -389,8 +410,7 @@ class Thirdparties extends DolibarrApi
// Update
$result = $object->update($object->id, $user, 0, 1, 1, 'merge');
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
@@ -425,8 +445,7 @@ class Thirdparties extends DolibarrApi
);
//First, all core objects must update their tables
- foreach ($objects as $object_name => $object_file)
- {
+ foreach ($objects as $object_name => $object_file) {
require_once DOL_DOCUMENT_ROOT.$object_file;
if (!$error && !$object_name::replaceThirdparty($this->db, $soc_origin->id, $object->id)) {
@@ -584,8 +603,7 @@ class Thirdparties extends DolibarrApi
}
$result = $this->company->fetch($id);
- if (!$result)
- {
+ if (!$result) {
throw new RestException(404, 'Thirdparty not found');
}
@@ -593,13 +611,11 @@ class Thirdparties extends DolibarrApi
$result = $categories->getListForItem($id, 'customer', $sortfield, $sortorder, $limit, $page);
- if (is_numeric($result) && $result < 0)
- {
+ if (is_numeric($result) && $result < 0) {
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
}
- if (is_numeric($result) && $result == 0) // To fix a return of 0 instead of empty array of method getListForItem
- {
+ if (is_numeric($result) && $result == 0) { // To fix a return of 0 instead of empty array of method getListForItem
return array();
}
@@ -702,8 +718,7 @@ class Thirdparties extends DolibarrApi
}
$result = $this->company->fetch($id);
- if (!$result)
- {
+ if (!$result) {
throw new RestException(404, 'Thirdparty not found');
}
@@ -711,13 +726,11 @@ class Thirdparties extends DolibarrApi
$result = $categories->getListForItem($id, 'supplier', $sortfield, $sortorder, $limit, $page);
- if (is_numeric($result) && $result < 0)
- {
+ if (is_numeric($result) && $result < 0) {
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
}
- if (is_numeric($result) && $result == 0) // To fix a return of 0 instead of empty array of method getListForItem
- {
+ if (is_numeric($result) && $result == 0) { // To fix a return of 0 instead of empty array of method getListForItem
return array();
}
@@ -1005,8 +1018,12 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT f.ref, f.type as factype, re.fk_facture_source, re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc, re.description, re.fk_facture, re.fk_facture_line";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.rowid = re.fk_facture_source AND re.fk_soc = ".$id;
- if ($filter == "available") $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL";
- if ($filter == "used") $sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)";
+ if ($filter == "available") {
+ $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL";
+ }
+ if ($filter == "used") {
+ $sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)";
+ }
$sql .= $this->db->order($sortfield, $sortorder);
@@ -1137,7 +1154,9 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
- if ($id) $sql .= " WHERE fk_soc = ".$id." ";
+ if ($id) {
+ $sql .= " WHERE fk_soc = ".$id." ";
+ }
$result = $this->db->query($sql);
@@ -1150,11 +1169,9 @@ class Thirdparties extends DolibarrApi
$accounts = array();
- if ($result)
- {
+ if ($result) {
$num = $this->db->num_rows($result);
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $this->db->fetch_object($result);
$account = new CompanyBankAccount($this->db);
if ($account->fetch($obj->rowid)) {
@@ -1209,8 +1226,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value;
}
- if ($account->create(DolibarrApiAccess::$user) < 0)
+ if ($account->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error creating Company Bank account');
+ }
if (empty($account->rum)) {
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
@@ -1219,8 +1237,9 @@ class Thirdparties extends DolibarrApi
$account->date_rum = dol_now();
}
- if ($account->update(DolibarrApiAccess::$user) < 0)
+ if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating values');
+ }
return $this->_cleanObjectDatas($account);
}
@@ -1264,8 +1283,9 @@ class Thirdparties extends DolibarrApi
$account->date_rum = dol_now();
}
- if ($account->update(DolibarrApiAccess::$user) < 0)
+ if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating values');
+ }
return $this->_cleanObjectDatas($account);
}
@@ -1290,8 +1310,9 @@ class Thirdparties extends DolibarrApi
$account->fetch($bankaccount_id);
- if (!$account->socid == $id)
+ if (!$account->socid == $id) {
throw new RestException(401);
+ }
return $account->delete(DolibarrApiAccess::$user);
}
@@ -1342,8 +1363,12 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
- if ($id) $sql .= " WHERE fk_soc = ".$id." ";
- if ($companybankid) $sql .= " AND rowid = ".$companybankid."";
+ if ($id) {
+ $sql .= " WHERE fk_soc = ".$id." ";
+ }
+ if ($companybankid) {
+ $sql .= " AND rowid = ".$companybankid."";
+ }
$i = 0;
$accounts = array();
@@ -1409,7 +1434,9 @@ class Thirdparties extends DolibarrApi
*/
$sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account";
$sql .= " WHERE fk_soc = $id";
- if ($site) $sql .= " AND site ='$site'";
+ if ($site) {
+ $sql .= " AND site ='$site'";
+ }
$result = $this->db->query($sql);
@@ -1422,8 +1449,7 @@ class Thirdparties extends DolibarrApi
$accounts = array();
$num = $this->db->num_rows($result);
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $this->db->fetch_object($result);
$account = new SocieteAccount($this->db);
@@ -1493,8 +1519,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value;
}
- if ($account->create(DolibarrApiAccess::$user) < 0)
+ if ($account->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error creating SocieteAccount entity. Ensure that the ID of thirdparty provided does exist!');
+ }
$this->_cleanObjectDatas($account);
@@ -1582,8 +1609,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value;
}
- if ($account->update(DolibarrApiAccess::$user) < 0)
+ if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating SocieteAccount entity.');
+ }
}
$this->_cleanObjectDatas($account);
@@ -1624,8 +1652,9 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."' ";
$result = $this->db->query($sql);
- if ($result && $this->db->num_rows($result) !== 0)
+ if ($result && $this->db->num_rows($result) !== 0) {
throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key.");
+ }
}
$obj = $this->db->fetch_object($result);
@@ -1636,8 +1665,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value;
}
- if ($account->update(DolibarrApiAccess::$user) < 0)
+ if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating SocieteAccount account');
+ }
$this->_cleanObjectDatas($account);
@@ -1713,8 +1743,7 @@ class Thirdparties extends DolibarrApi
$i = 0;
$num = $this->db->num_rows($result);
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $this->db->fetch_object($result);
$account = new SocieteAccount($this->db);
$account->fetch($obj->rowid);
@@ -1781,8 +1810,9 @@ class Thirdparties extends DolibarrApi
{
$thirdparty = array();
foreach (Thirdparties::$FIELDS as $field) {
- if (!isset($data[$field]))
+ if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
+ }
$thirdparty[$field] = $data[$field];
}
return $thirdparty;
diff --git a/htdocs/societe/class/client.class.php b/htdocs/societe/class/client.class.php
index f88027b1491..6b09d88ac71 100644
--- a/htdocs/societe/class/client.class.php
+++ b/htdocs/societe/class/client.class.php
@@ -64,8 +64,7 @@ class Client extends Societe
$sql = "SELECT count(s.rowid) as nb, s.client";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
- if (!$user->rights->societe->client->voir && !$user->socid)
- {
+ if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql .= " WHERE sc.fk_user = ".$user->id;
$clause = "AND";
@@ -75,12 +74,14 @@ class Client extends Societe
$sql .= " GROUP BY s.client";
$resql = $this->db->query($sql);
- if ($resql)
- {
- while ($obj = $this->db->fetch_object($resql))
- {
- if ($obj->client == 1 || $obj->client == 3) $this->nb["customers"] += $obj->nb;
- if ($obj->client == 2 || $obj->client == 3) $this->nb["prospects"] += $obj->nb;
+ if ($resql) {
+ while ($obj = $this->db->fetch_object($resql)) {
+ if ($obj->client == 1 || $obj->client == 3) {
+ $this->nb["customers"] += $obj->nb;
+ }
+ if ($obj->client == 2 || $obj->client == 3) {
+ $this->nb["prospects"] += $obj->nb;
+ }
}
$this->db->free($resql);
return 1;
@@ -101,8 +102,10 @@ class Client extends Societe
{
global $langs;
- $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcomm";
- if ($active >= 0) $sql .= " WHERE active = ".$active;
+ $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcomm";
+ if ($active >= 0) {
+ $sql .= " WHERE active = ".$active;
+ }
$resql = $this->db->query($sql);
$num = $this->db->num_rows($resql);
$i = 0;
diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php
index a123fa749c9..ab8271d7b70 100644
--- a/htdocs/societe/class/companybankaccount.class.php
+++ b/htdocs/societe/class/companybankaccount.class.php
@@ -84,32 +84,33 @@ class CompanyBankAccount extends Account
$error = 0;
// Correct default_rib to be sure to have always one default
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'";
- $result = $this->db->query($sql);
- if ($result)
- {
+ $result = $this->db->query($sql);
+ if ($result) {
$numrows = $this->db->num_rows($result);
- if ($this->default_rib && $numrows > 0) $this->default_rib = 0;
- if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1;
+ if ($this->default_rib && $numrows > 0) {
+ $this->default_rib = 0;
+ }
+ if (empty($this->default_rib) && $numrows == 0) {
+ $this->default_rib = 1;
+ }
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
$sql .= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
$resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->affected_rows($resql))
- {
+ if ($resql) {
+ if ($this->db->affected_rows($resql)) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib");
- if (!$notrigger)
- {
- // Call trigger
+ if (!$notrigger) {
+ // Call trigger
$result = $this->call_trigger('COMPANY_RIB_CREATE', $user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
- if (!$error)
- {
+ if (!$error) {
return 1;
} else {
return 0;
@@ -136,10 +137,16 @@ class CompanyBankAccount extends Account
global $conf;
$error = 0;
- if (!$this->id) return -1;
+ if (!$this->id) {
+ return -1;
+ }
- if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
- if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
+ if (dol_strlen($this->domiciliation) > 255) {
+ $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
+ }
+ if (dol_strlen($this->owner_address) > 255) {
+ $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
+ }
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
$sql .= " bank = '".$this->db->escape($this->bank)."'";
@@ -153,28 +160,28 @@ class CompanyBankAccount extends Account
$sql .= ",proprio = '".$this->db->escape($this->proprio)."'";
$sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'";
$sql .= ",default_rib = ".$this->default_rib;
- if ($conf->prelevement->enabled)
- {
+ if ($conf->prelevement->enabled) {
$sql .= ",frstrecur = '".$this->db->escape($this->frstrecur)."'";
$sql .= ",rum = '".$this->db->escape($this->rum)."'";
$sql .= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null");
}
- if (trim($this->label) != '')
+ if (trim($this->label) != '') {
$sql .= ",label = '".$this->db->escape($this->label)."'";
- else $sql .= ",label = NULL";
+ } else {
+ $sql .= ",label = NULL";
+ }
$sql .= " WHERE rowid = ".$this->id;
$result = $this->db->query($sql);
- if ($result)
- {
- if (!$notrigger)
- {
+ if ($result) {
+ if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('COMPANY_RIB_MODIFY', $user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
- if (!$error)
- {
+ if (!$error) {
return 1;
} else {
return -1;
@@ -199,24 +206,29 @@ class CompanyBankAccount extends Account
*/
public function fetch($id, $socid = 0, $default = 1, $type = 'ban')
{
- if (empty($id) && empty($socid)) return -1;
+ if (empty($id) && empty($socid)) {
+ return -1;
+ }
$sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
- if ($id) $sql .= " WHERE rowid = ".$id;
- if ($socid)
- {
+ if ($id) {
+ $sql .= " WHERE rowid = ".$id;
+ }
+ if ($socid) {
$sql .= " WHERE fk_soc = ".$socid;
- if ($default > -1) $sql .= " AND default_rib = ".$this->db->escape($default);
- if ($type) $sql .= " AND type ='".$this->db->escape($type)."'";
+ if ($default > -1) {
+ $sql .= " AND default_rib = ".$this->db->escape($default);
+ }
+ if ($type) {
+ $sql .= " AND type ='".$this->db->escape($type)."'";
+ }
}
$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->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref
@@ -268,28 +280,26 @@ class CompanyBankAccount extends Account
$this->db->begin();
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('COMPANY_RIB_DELETE', $user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if (!$error)
- {
+ if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib";
$sql .= " WHERE rowid = ".$this->id;
- if (!$this->db->query($sql))
- {
+ if (!$this->db->query($sql)) {
$error++;
$this->errors[] = $this->db->lasterror();
}
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return 1;
} else {
@@ -332,10 +342,8 @@ class CompanyBankAccount extends Account
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result1 = $this->db->query($sql1);
- if ($result1)
- {
- if ($this->db->num_rows($result1) == 0)
- {
+ if ($result1) {
+ if ($this->db->num_rows($result1) == 0) {
return 0;
} else {
$obj = $this->db->fetch_object($result1);
@@ -352,8 +360,7 @@ class CompanyBankAccount extends Account
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result3 = $this->db->query($sql3);
- if (!$result2 || !$result3)
- {
+ if (!$result2 || !$result3) {
dol_print_error($this->db);
$this->db->rollback();
return -1;
diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php
index e88ea0e4f7c..39b14862f12 100644
--- a/htdocs/societe/class/companypaymentmode.class.php
+++ b/htdocs/societe/class/companypaymentmode.class.php
@@ -232,8 +232,12 @@ class CompanyPaymentMode extends CommonObject
$this->db = $db;
- if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0;
- if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0;
+ if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
+ $this->fields['rowid']['visible'] = 0;
+ }
+ if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
+ $this->fields['entity']['enabled'] = 0;
+ }
}
/**
@@ -313,8 +317,12 @@ class CompanyPaymentMode extends CommonObject
*/
public function fetch($id, $ref = null, $socid = 0, $type = '', $morewhere = '')
{
- if ($socid) $morewhere .= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1";
- if ($type) $morewhere .= " AND type = '".$this->db->escape($type)."'";
+ if ($socid) {
+ $morewhere .= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1";
+ }
+ if ($type) {
+ $morewhere .= " AND type = '".$this->db->escape($type)."'";
+ }
$result = $this->fetchCommon($id, $ref, $morewhere);
//if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
@@ -375,7 +383,9 @@ class CompanyPaymentMode extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
- if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
+ if (!empty($conf->dol_no_mouse_hover)) {
+ $notooltip = 1; // Force disable tooltips
+ }
$result = '';
$companylink = '';
@@ -386,33 +396,40 @@ class CompanyPaymentMode extends CommonObject
$url = dol_buildpath('/monmodule/companypaymentmode_card.php', 1).'?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';
+ }
}
$linkclose = '';
- if (empty($notooltip))
- {
- if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
- {
+ if (empty($notooltip)) {
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowCompanyPaymentMode");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
- } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ } else {
+ $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ }
$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 .= $this->ref;
+ if ($withpicto) {
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ if ($withpicto != 2) {
+ $result .= $this->ref;
+ }
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@@ -433,33 +450,36 @@ class CompanyPaymentMode extends CommonObject
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result1 = $this->db->query($sql1);
- if ($result1)
- {
- if ($this->db->num_rows($result1) == 0)
- {
+ if ($result1) {
+ if ($this->db->num_rows($result1) == 0) {
return 0;
} else {
$obj = $this->db->fetch_object($result1);
$type = '';
- if (empty($alltypes)) $type = $obj->type;
+ if (empty($alltypes)) {
+ $type = $obj->type;
+ }
$this->db->begin();
$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0, tms = tms";
$sql2 .= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc;
- if ($type) $sql2 .= " AND type = '".$this->db->escape($type)."'";
+ if ($type) {
+ $sql2 .= " AND type = '".$this->db->escape($type)."'";
+ }
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result2 = $this->db->query($sql2);
$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
$sql3 .= " WHERE rowid = ".$obj->id;
- if ($type) $sql3 .= " AND type = '".$this->db->escape($type)."'";
+ if ($type) {
+ $sql3 .= " AND type = '".$this->db->escape($type)."'";
+ }
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result3 = $this->db->query($sql3);
- if (!$result2 || !$result3)
- {
+ if (!$result2 || !$result3) {
dol_print_error($this->db);
$this->db->rollback();
return -1;
@@ -496,8 +516,7 @@ class CompanyPaymentMode extends CommonObject
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
- if (empty($this->labelStatus) || empty($this->labelStatusShort))
- {
+ if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
//$langs->load("mymodule");
$this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled');
@@ -507,7 +526,9 @@ class CompanyPaymentMode extends CommonObject
}
$statusType = 'status5';
- if ($status == self::STATUS_ENABLED) $statusType = 'status4';
+ if ($status == self::STATUS_ENABLED) {
+ $statusType = 'status4';
+ }
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
@@ -525,28 +546,23 @@ class CompanyPaymentMode extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql);
- if ($result)
- {
- if ($this->db->num_rows($result))
- {
+ if ($result) {
+ if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
- if ($obj->fk_user_author)
- {
+ if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
- if ($obj->fk_user_valid)
- {
+ if ($obj->fk_user_valid) {
$vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
- if ($obj->fk_user_cloture)
- {
+ if ($obj->fk_user_cloture) {
$cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser;
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 115750dd0ab..6121625ba41 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -905,9 +905,8 @@ class Societe extends CommonObject
// Ajout du commercial affecte
if ($this->commercial_id != '' && $this->commercial_id != -1) {
$this->add_commercial($user, $this->commercial_id);
- }
- // si un commercial cree un client il lui est affecte automatiquement
- elseif (empty($user->rights->societe->client->voir)) {
+ } elseif (empty($user->rights->societe->client->voir)) {
+ // si un commercial cree un client il lui est affecte automatiquement
$this->add_commercial($user, $user->id);
}
@@ -2626,20 +2625,17 @@ class Societe extends CommonObject
$s = '';
if (empty($option) || preg_match('/prospect/', $option)) {
- if (($this->client == 2 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
- {
+ if (($this->client == 2 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
$s .= ''.dol_substr($langs->trans("Prospect"), 0, 1).'';
}
}
if (empty($option) || preg_match('/customer/', $option)) {
- if (($this->client == 1 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
- {
+ if (($this->client == 1 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$s .= ''.dol_substr($langs->trans("Customer"), 0, 1).'';
}
}
if (empty($option) || preg_match('/supplier/', $option)) {
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $this->fournisseur)
- {
+ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $this->fournisseur) {
$s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).'';
}
}
@@ -3811,8 +3807,7 @@ class Societe extends CommonObject
dol_syslog("We ask to create a contact/address too", LOG_DEBUG);
$result = $this->create_individual($user);
- if ($result < 0)
- {
+ if ($result < 0) {
setEventMessages($this->error, $this->errors, 'errors');
$this->db->rollback();
return -1;
@@ -4682,8 +4677,7 @@ class Societe extends CommonObject
$this->db->commit();
return 1;
- }
- else {
+ } else {
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php
index a315044683b..64a914ff549 100644
--- a/htdocs/societe/class/societeaccount.class.php
+++ b/htdocs/societe/class/societeaccount.class.php
@@ -172,7 +172,9 @@ class SocieteAccount extends CommonObject
$this->db = $db;
- if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0;
+ if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
+ $this->fields['rowid']['visible'] = 0;
+ }
}
/**
@@ -248,7 +250,9 @@ class SocieteAccount extends CommonObject
public function fetch($id, $ref = null)
{
$result = $this->fetchCommon($id, $ref);
- if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
+ if ($result > 0 && !empty($this->table_element_line)) {
+ $this->fetchLines();
+ }
return $result;
}
@@ -375,7 +379,9 @@ class SocieteAccount extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
- if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
+ if (!empty($conf->dol_no_mouse_hover)) {
+ $notooltip = 1; // Force disable tooltips
+ }
$result = '';
@@ -388,33 +394,40 @@ class SocieteAccount extends CommonObject
$url = dol_buildpath('/website/websiteaccount_card.php', 1).'?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';
+ }
}
$linkclose = '';
- if (empty($notooltip))
- {
- if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
- {
+ if (empty($notooltip)) {
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("WebsiteAccount");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
- } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ } else {
+ $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ }
$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 .= $this->ref;
+ if ($withpicto) {
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ if ($withpicto != 2) {
+ $result .= $this->ref;
+ }
$result .= $linkend;
return $result;
@@ -444,35 +457,49 @@ class SocieteAccount extends CommonObject
// phpcs:enable
global $langs;
- if ($mode == 0)
- {
+ if ($mode == 0) {
$prefix = '';
- if ($status == 1) return $langs->trans('Enabled');
- elseif ($status == 0) return $langs->trans('Disabled');
- } elseif ($mode == 1)
- {
- if ($status == 1) return $langs->trans('Enabled');
- elseif ($status == 0) return $langs->trans('Disabled');
- } elseif ($mode == 2)
- {
- if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
- elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
- } elseif ($mode == 3)
- {
- if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
- elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
- } elseif ($mode == 4)
- {
- if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
- elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
- } elseif ($mode == 5)
- {
- if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
- elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
- } elseif ($mode == 6)
- {
- if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
- elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
+ if ($status == 1) {
+ return $langs->trans('Enabled');
+ } elseif ($status == 0) {
+ return $langs->trans('Disabled');
+ }
+ } elseif ($mode == 1) {
+ if ($status == 1) {
+ return $langs->trans('Enabled');
+ } elseif ($status == 0) {
+ return $langs->trans('Disabled');
+ }
+ } elseif ($mode == 2) {
+ if ($status == 1) {
+ return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
+ } elseif ($status == 0) {
+ return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
+ }
+ } elseif ($mode == 3) {
+ if ($status == 1) {
+ return img_picto($langs->trans('Enabled'), 'statut4');
+ } elseif ($status == 0) {
+ return img_picto($langs->trans('Disabled'), 'statut5');
+ }
+ } elseif ($mode == 4) {
+ if ($status == 1) {
+ return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
+ } elseif ($status == 0) {
+ return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
+ }
+ } elseif ($mode == 5) {
+ if ($status == 1) {
+ return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
+ } elseif ($status == 0) {
+ return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
+ }
+ } elseif ($mode == 6) {
+ if ($status == 1) {
+ return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
+ } elseif ($status == 0) {
+ return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
+ }
}
}
@@ -489,28 +516,23 @@ class SocieteAccount extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql);
- if ($result)
- {
- if ($this->db->num_rows($result))
- {
+ if ($result) {
+ if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
- if ($obj->fk_user_author)
- {
+ if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
- if ($obj->fk_user_valid)
- {
+ if ($obj->fk_user_valid) {
$vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
- if ($obj->fk_user_cloture)
- {
+ if ($obj->fk_user_cloture) {
$cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser;
diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php
index f2ba112b3d0..9b58ea1bc5d 100644
--- a/htdocs/societe/consumption.php
+++ b/htdocs/societe/consumption.php
@@ -35,22 +35,32 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thi
// Security check
$socid = GETPOST('socid', 'int');
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'societe', $socid, '&societe');
$object = new Societe($db);
-if ($socid > 0) $object->fetch($socid);
+if ($socid > 0) {
+ $object->fetch($socid);
+}
// Sort & Order fields
$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");
@@ -59,8 +69,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 = '';
@@ -83,7 +92,9 @@ $hookmanager->initHooks(array('consumptionthirdparty'));
$parameters = array('id'=>$socid);
$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');
+}
@@ -96,12 +107,13 @@ $formother = new FormOther($db);
$productstatic = new Product($db);
$title = $langs->trans("Referers", $object->name);
-if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title;
+if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
+ $title = $object->name." - ".$title;
+}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
-if (empty($socid))
-{
+if (empty($socid)) {
dol_print_error($db);
exit;
}
@@ -118,15 +130,13 @@ print '';
print ' ';
print ' ';
-if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
-{
+if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
print '| '.$langs->trans('Prefix').' | '.$object->prefix_comm.' | ';
}
//if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events');
-if ($object->client)
-{
+if ($object->client) {
print '| ';
print $langs->trans('CustomerCode').' | ';
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
@@ -137,21 +147,32 @@ if ($object->client)
print ' | ';
$sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid;
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
$obj = $db->fetch_object($resql);
$nbFactsClient = $obj->nb;
$thirdTypeArray['customer'] = $langs->trans("customer");
- if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals');
- if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders');
- if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices');
- if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts');
+ if ($conf->propal->enabled && $user->rights->propal->lire) {
+ $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals');
+ }
+ if ($conf->commande->enabled && $user->rights->commande->lire) {
+ $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders');
+ }
+ if ($conf->facture->enabled && $user->rights->facture->lire) {
+ $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices');
+ }
+ if ($conf->contrat->enabled && $user->rights->contrat->lire) {
+ $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts');
+ }
}
-if (!empty($conf->ficheinter->enabled) && !empty($user->rights->ficheinter->lire)) $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
+if (!empty($conf->ficheinter->enabled) && !empty($user->rights->ficheinter->lire)) {
+ $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
+}
-if ($object->fournisseur)
-{
+if ($object->fournisseur) {
$langs->load("supplier_proposal");
print '| ';
print $langs->trans('SupplierCode').' | ';
@@ -163,14 +184,22 @@ if ($object->fournisseur)
print ' | ';
$sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".$socid;
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
$obj = $db->fetch_object($resql);
$nbCmdsFourn = $obj->nb;
$thirdTypeArray['supplier'] = $langs->trans("supplier");
- if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
- if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders');
- if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal'] = $langs->transnoentitiesnoconv('SupplierProposals');
+ if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) {
+ $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
+ }
+ if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) {
+ $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders');
+ }
+ if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) {
+ $elementTypeArray['supplier_proposal'] = $langs->transnoentitiesnoconv('SupplierProposals');
+ }
}
print ' ';
@@ -194,8 +223,7 @@ $sql_select = '';
$dateprint = 'f.datep';
$doc_number='f.id';
}*/
-if ($type_element == 'fichinter')
-{ // Customer : show products from invoices
+if ($type_element == 'fichinter') { // Customer : show products from invoices
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
$documentstatic = new Fichinter($db);
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, ';
@@ -205,8 +233,7 @@ if ($type_element == 'fichinter')
$dateprint = 'f.datec';
$doc_number = 'f.ref';
}
-if ($type_element == 'invoice')
-{ // Customer : show products from invoices
+if ($type_element == 'invoice') { // Customer : show products from invoices
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$documentstatic = new Facture($db);
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, ';
@@ -218,8 +245,7 @@ if ($type_element == 'invoice')
$doc_number = 'f.ref';
$thirdTypeSelect = 'customer';
}
-if ($type_element == 'propal')
-{
+if ($type_element == 'propal') {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$documentstatic = new Propal($db);
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, ';
@@ -231,8 +257,7 @@ if ($type_element == 'propal')
$doc_number = 'c.ref';
$thirdTypeSelect = 'customer';
}
-if ($type_element == 'order')
-{
+if ($type_element == 'order') {
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$documentstatic = new Commande($db);
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, ';
@@ -244,8 +269,7 @@ if ($type_element == 'order')
$doc_number = 'c.ref';
$thirdTypeSelect = 'customer';
}
-if ($type_element == 'supplier_invoice')
-{ // Supplier : Show products from invoices.
+if ($type_element == 'supplier_invoice') { // Supplier : Show products from invoices.
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$documentstatic = new FactureFournisseur($db);
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, ';
@@ -257,8 +281,7 @@ if ($type_element == 'supplier_invoice')
$doc_number = 'f.ref';
$thirdTypeSelect = 'supplier';
}
-if ($type_element == 'supplier_proposal')
-{
+if ($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, ';
@@ -270,8 +293,7 @@ if ($type_element == 'supplier_proposal')
$doc_number = 'c.ref';
$thirdTypeSelect = 'supplier';
}
-if ($type_element == 'supplier_order')
-{ // Supplier : Show products from orders.
+if ($type_element == 'supplier_order') { // Supplier : Show products from orders.
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$documentstatic = new CommandeFournisseur($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, ';
@@ -283,8 +305,7 @@ if ($type_element == 'supplier_order')
$doc_number = 'c.ref';
$thirdTypeSelect = 'supplier';
}
-if ($type_element == 'contract')
-{ // Order
+if ($type_element == 'contract') { // Order
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
$documentstatic = new Contrat($db);
$documentstaticline = new ContratLigne($db);
@@ -301,26 +322,42 @@ if ($type_element == 'contract')
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
-if (!empty($sql_select))
-{
+if (!empty($sql_select)) {
$sql = $sql_select;
$sql .= ' d.description as description,';
- 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,';
+ }
$sql .= " s.rowid as socid ";
- 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";
+ }
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".$tables_from;
- 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 ';
+ }
$sql .= $where;
$sql .= dolSqlDateFilter($dateprint, 0, $month, $year);
- if ($sref) $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'";
- if ($sprod_fulldescr)
- {
+ 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)."%'";
+ 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 .= ")";
}
$sql .= $db->order($sortfield, $sortorder);
@@ -334,8 +371,7 @@ if (!empty($sql_select))
$disabled = 0;
$showempty = 2;
-if (empty($elementTypeArray) && !$object->client && !$object->fournisseur)
-{
+if (empty($elementTypeArray) && !$object->client && !$object->fournisseur) {
$showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef");
$disabled = 1;
}
@@ -354,21 +390,36 @@ $param .= "&type_element=".urlencode($type_element);
$total_qty = 0;
-if ($sql_select)
-{
+if ($sql_select) {
$resql = $db->query($sql);
- if (!$resql) dol_print_error($db);
+ if (!$resql) {
+ dol_print_error($db);
+ }
$num = $db->num_rows($resql);
$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);
+ 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);
@@ -412,8 +463,7 @@ if ($sql_select)
$i = 0;
- while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit))
- {
+ while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit)) {
$documentstatic->id = $objp->doc_id;
$documentstatic->ref = $objp->doc_number;
$documentstatic->type = $objp->doc_type;
@@ -423,7 +473,9 @@ if ($sql_select)
$documentstatic->status = $objp->status;
$documentstatic->paye = $objp->paid;
- if (is_object($documentstaticline)) $documentstaticline->statut = $objp->status;
+ if (is_object($documentstaticline)) {
+ $documentstaticline->statut = $objp->status;
+ }
print ' ';
print '';
@@ -447,8 +499,7 @@ if ($sql_select)
$text = ''; $description = ''; $type = 0;
// Code to show product duplicated from commonobject->printObjectLine
- if ($objp->fk_product > 0)
- {
+ if ($objp->fk_product > 0) {
$product_static = new Product($db);
$product_static->type = $objp->fk_product_type;
@@ -459,20 +510,21 @@ if ($sql_select)
}
// Product
- if ($objp->fk_product > 0)
- {
+ if ($objp->fk_product > 0) {
// Define output language
- if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
- {
+ if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
$prod = new Product($db);
$prod->fetch($objp->fk_product);
$outputlangs = $langs;
$newlang = '';
- 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)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
@@ -491,39 +543,40 @@ if ($sql_select)
trans("ShowReduc"), 'reduc').' ';
- 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");
+ }
//else $txt=$langs->trans("Discount");
print $txt;
?>
description)
- {
- if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0)
- {
+ if ($objp->description) {
+ if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) {
$discount = new DiscountAbsolute($db);
$discount->fetch($objp->fk_remise_except);
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
}
- if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0)
- {
+ if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) {
$discount = new DiscountAbsolute($db);
$discount->fetch($objp->fk_remise_except);
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0));
- } elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0)
- {
+ } elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) {
$discount = new DiscountAbsolute($db);
$discount->fetch($objp->fk_remise_except);
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0));
- } elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0)
- {
+ } elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) {
$discount = new DiscountAbsolute($db);
$discount->fetch($objp->fk_remise_except);
echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
// Add date of deposit
- if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')';
+ if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
+ echo ' ('.dol_print_date($discount->datec).')';
+ }
} else {
echo ($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description);
}
@@ -536,15 +589,16 @@ if ($sql_select)
echo get_date_range($objp->date_start, $objp->date_end);
// Add description in form
- if (!empty($conf->global->PRODUIT_DESC_IN_FORM))
- {
+ if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
print (!empty($objp->description) && $objp->description != $objp->product_label) ? ' '.dol_htmlentitiesbr($objp->description) : '';
}
} else {
- 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');
+ }
if (!empty($objp->label)) {
$text .= ' '.$objp->label.'';
@@ -580,7 +634,9 @@ if ($sql_select)
print ' | ';
//print ''.$prodreftxt.' | ';
- if ($type_element == 'invoice' && $objp->doc_type == Facture::TYPE_CREDIT_NOTE) $objp->prod_qty = -($objp->prod_qty);
+ if ($type_element == 'invoice' && $objp->doc_type == Facture::TYPE_CREDIT_NOTE) {
+ $objp->prod_qty = -($objp->prod_qty);
+ }
print ''.$objp->prod_qty.' | ';
$total_qty += $objp->prod_qty;
@@ -606,9 +662,7 @@ if ($sql_select)
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
}
$db->free($resql);
-}
-elseif (empty($type_element) || $type_element == -1)
-{
+} elseif (empty($type_element) || $type_element == -1) {
print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', (!empty($num) ? $num : 0), '', '');
print ''."\n";
diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php
index e57c059a633..570d8531efc 100644
--- a/htdocs/societe/contact.php
+++ b/htdocs/societe/contact.php
@@ -42,12 +42,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
-if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
+if (!empty($conf->adherent->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
+}
$langs->loadLangs(array("companies", "commercial", "bills", "banks", "users"));
-if (!empty($conf->categorie->enabled)) $langs->load("categories");
-if (!empty($conf->incoterm->enabled)) $langs->load("incoterm");
-if (!empty($conf->notification->enabled)) $langs->load("mails");
+if (!empty($conf->categorie->enabled)) {
+ $langs->load("categories");
+}
+if (!empty($conf->incoterm->enabled)) {
+ $langs->load("incoterm");
+}
+if (!empty($conf->notification->enabled)) {
+ $langs->load("mails");
+}
$mesg = ''; $error = 0; $errors = array();
@@ -56,8 +64,12 @@ $cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$confirm = GETPOST('confirm');
$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
-if ($user->socid) $socid = $user->socid;
-if (empty($socid) && $action == 'view') $action = 'create';
+if ($user->socid) {
+ $socid = $user->socid;
+}
+if (empty($socid) && $action == 'view') {
+ $action = 'create';
+}
$object = new Societe($db);
$extrafields = new ExtraFields($db);
@@ -68,8 +80,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('thirdpartycontact', 'globalcard'));
-if ($object->fetch($socid) <= 0 && $action == 'view')
-{
+if ($object->fetch($socid) <= 0 && $action == 'view') {
$langs->load("errors");
print($langs->trans('ErrorRecordNotFound'));
exit;
@@ -78,8 +89,7 @@ if ($object->fetch($socid) <= 0 && $action == 'view')
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$canvas = $object->canvas ? $object->canvas : GETPOST("canvas");
$objcanvas = null;
-if (!empty($canvas))
-{
+if (!empty($canvas)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
$objcanvas = new Canvas($db, $action);
$objcanvas->getCanvas('thirdparty', 'card', $canvas);
@@ -87,7 +97,9 @@ if (!empty($canvas))
// Security check
$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0);
-if (empty($user->rights->societe->contact->lire)) accessforbidden();
+if (empty($user->rights->societe->contact->lire)) {
+ accessforbidden();
+}
/*
@@ -96,15 +108,14 @@ if (empty($user->rights->societe->contact->lire)) accessforbidden();
$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
-if (empty($reshook))
-{
- if ($cancel)
- {
+if (empty($reshook)) {
+ if ($cancel) {
$action = '';
- if (!empty($backtopage))
- {
+ if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
@@ -124,21 +135,26 @@ $formfile = new FormFile($db);
$formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db);
-if ($socid > 0 && empty($object->id))
-{
+if ($socid > 0 && empty($object->id)) {
$result = $object->fetch($socid);
- if ($result <= 0) dol_print_error('', $object->error);
+ if ($result <= 0) {
+ dol_print_error('', $object->error);
+ }
}
$title = $langs->trans("ThirdParty");
-if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$langs->trans('Card');
+if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
+ $title = $object->name." - ".$langs->trans('Card');
+}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
-if (!empty($object->id)) $res = $object->fetch_optionals();
+if (!empty($object->id)) {
+ $res = $object->fetch_optionals();
+}
//if ($res < 0) { dol_print_error($db); exit; }
@@ -154,11 +170,9 @@ print dol_get_fiche_end();
print ' ';
-if ($action != 'presend')
-{
+if ($action != 'presend') {
// Contacts list
- if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
- {
+ if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
$result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
}
}
diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php
index fdd5ef08756..600cb03af1a 100644
--- a/htdocs/societe/document.php
+++ b/htdocs/societe/document.php
@@ -40,8 +40,7 @@ $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'))
$ref = GETPOST('ref', 'alpha');
// Security check
-if ($user->socid > 0)
-{
+if ($user->socid > 0) {
unset($action);
$socid = $user->socid;
}
@@ -52,20 +51,29 @@ $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 (!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; }
+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;
+}
-if (!$sortorder) $sortorder = "ASC";
-if (!$sortfield) $sortfield = "position_name";
+if (!$sortorder) {
+ $sortorder = "ASC";
+}
+if (!$sortfield) {
+ $sortfield = "position_name";
+}
$object = new Societe($db);
-if ($id > 0 || !empty($ref))
-{
+if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref);
$upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
@@ -91,16 +99,19 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
$form = new Form($db);
$title = $langs->trans("ThirdParty").' - '.$langs->trans("Files");
-if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Files");
+if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
+ $title = $object->name.' - '.$langs->trans("Files");
+}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
-if ($object->id)
-{
+if ($object->id) {
/*
* Show tabs
*/
- if (!empty($conf->notification->enabled)) $langs->load("mails");
+ if (!empty($conf->notification->enabled)) {
+ $langs->load("mails");
+ }
$head = societe_prepare_head($object);
$form = new Form($db);
@@ -111,8 +122,7 @@ if ($object->id)
// 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)
- {
+ foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
}
@@ -126,13 +136,11 @@ if ($object->id)
print '';
// Prefix
- if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
- {
+ if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
print '| '.$langs->trans('Prefix').' | '.$object->prefix_comm.' | ';
}
- if ($object->client)
- {
+ if ($object->client) {
print '| ';
print $langs->trans('CustomerCode').' | ';
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
@@ -143,8 +151,7 @@ if ($object->id)
print ' | ';
}
- if ($object->fournisseur)
- {
+ if ($object->fournisseur) {
print '| ';
print $langs->trans('SupplierCode').' | ';
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php
index 9ce38458c7f..0647a11d626 100644
--- a/htdocs/societe/index.php
+++ b/htdocs/societe/index.php
@@ -38,7 +38,9 @@ $hookmanager->initHooks(array('thirdpartiesindex'));
$langs->load("companies");
$socid = GETPOST('socid', 'int');
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
// Security check
$result = restrictedArea($user, 'societe', 0, '', '', '', '');
@@ -75,37 +77,62 @@ $total = 0;
$sql = "SELECT s.rowid, s.client, s.fournisseur";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+if (!$user->rights->societe->client->voir && !$socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+}
$sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
-if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
-if ($socid) $sql .= " AND s.rowid = ".$socid;
-if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
+if (!$user->rights->societe->client->voir && !$socid) {
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+}
+if ($socid) {
+ $sql .= " AND s.rowid = ".$socid;
+}
+if (!$user->rights->fournisseur->lire) {
+ $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
+}
//print $sql;
$result = $db->query($sql);
-if ($result)
-{
- while ($objp = $db->fetch_object($result))
- {
+if ($result) {
+ while ($objp = $db->fetch_object($result)) {
$found = 0;
- if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found = 1; $third['prospect']++; }
- if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found = 1; $third['customer']++; }
- if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found = 1; $third['supplier']++; }
- if (!empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found = 1; $third['other']++; }
- if ($found) $total++;
+ if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) {
+ $found = 1; $third['prospect']++;
+ }
+ if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) {
+ $found = 1; $third['customer']++;
+ }
+ if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) {
+ $found = 1; $third['supplier']++;
+ }
+ if (!empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) {
+ $found = 1; $third['other']++;
+ }
+ if ($found) {
+ $total++;
+ }
}
-} else dol_print_error($db);
+} else {
+ dol_print_error($db);
+}
print '';
print ' '."\n";
print '| '.$langs->trans("Statistics").' | ';
-if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2))
-{
+if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2)) {
print '| ';
$dataseries = array();
- if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[] = array($langs->trans("Prospects"), round($third['prospect']));
- if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[] = array($langs->trans("Customers"), round($third['customer']));
- if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[] = array($langs->trans("Suppliers"), round($third['supplier']));
- if (!empty($conf->societe->enabled)) $dataseries[] = array($langs->trans("Others"), round($third['other']));
+ if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
+ $dataseries[] = array($langs->trans("Prospects"), round($third['prospect']));
+ }
+ if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) {
+ $dataseries[] = array($langs->trans("Customers"), round($third['customer']));
+ }
+ if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) {
+ $dataseries[] = array($langs->trans("Suppliers"), round($third['supplier']));
+ }
+ if (!empty($conf->societe->enabled)) {
+ $dataseries[] = array($langs->trans("Others"), round($third['other']));
+ }
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
@@ -117,20 +144,17 @@ if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) +
print $dolgraph->show();
print ' | '."\n";
} else {
- if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))
- {
+ if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
$statstring = "";
$statstring .= '| '.$langs->trans("Prospects").' | '.round($third['prospect']).' | ';
$statstring .= " ";
}
- if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS))
- {
+ if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) {
$statstring .= "";
$statstring .= '| '.$langs->trans("Customers").' | '.round($third['customer']).' | ';
$statstring .= " ";
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire)
- {
+ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire) {
$statstring2 = "";
$statstring2 .= '| '.$langs->trans("Suppliers").' | '.round($third['supplier']).' | ';
$statstring2 .= " ";
@@ -144,8 +168,7 @@ print '';
print ' ';
print ' ';
-if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES))
-{
+if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$elementtype = 'societe';
@@ -159,26 +182,24 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
$sql .= " WHERE c.type = 2";
- if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql .= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
+ if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) {
+ $sql .= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'";
+ }
$sql .= " AND c.entity IN (".getEntity('category').")";
$sql .= " GROUP BY c.label";
$total = 0;
$result = $db->query($sql);
- if ($result)
- {
+ if ($result) {
$num = $db->num_rows($result);
$i = 0;
- if (!empty($conf->use_javascript_ajax))
- {
+ if (!empty($conf->use_javascript_ajax)) {
$dataseries = array();
$rest = 0;
$nbmax = 10;
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($result);
- if ($i < $nbmax)
- {
+ if ($i < $nbmax) {
$dataseries[] = array($obj->label, round($obj->nb));
} else {
$rest += $obj->nb;
@@ -186,8 +207,7 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA
$total += $obj->nb;
$i++;
}
- if ($i > $nbmax)
- {
+ if ($i > $nbmax) {
$dataseries[] = array($langs->trans("Other"), round($rest));
}
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@@ -200,8 +220,7 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA
$dolgraph->draw('idgraphcateg');
print $dolgraph->show();
} else {
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($result);
print ' | | '.$obj->label.' | '.$obj->nb.' | ';
@@ -234,24 +253,30 @@ $sql .= ", s.logo";
$sql .= ", s.entity";
$sql .= ", s.canvas, s.tms as date_modification, s.status as status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+if (!$user->rights->societe->client->voir && !$socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+}
$sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
-if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
-if ($socid) $sql .= " AND s.rowid = ".$socid;
-if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur != 1 OR s.client != 0)";
+if (!$user->rights->societe->client->voir && !$socid) {
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+}
+if ($socid) {
+ $sql .= " AND s.rowid = ".$socid;
+}
+if (!$user->rights->fournisseur->lire) {
+ $sql .= " AND (s.fournisseur != 1 OR s.client != 0)";
+}
$sql .= $db->order("s.tms", "DESC");
$sql .= $db->plimit($max, 0);
//print $sql;
$result = $db->query($sql);
-if ($result)
-{
+if ($result) {
$num = $db->num_rows($result);
$i = 0;
- if ($num > 0)
- {
+ if ($num > 0) {
$transRecordedType = $langs->trans("LastModifiedThirdParties", $max);
print "\n\n";
@@ -263,8 +288,7 @@ if ($result)
print ''.$langs->trans("FullList").' | ';
print ''."\n";
- while ($i < $num)
- {
+ while ($i < $num) {
$objp = $db->fetch_object($result);
$thirdparty_static->id = $objp->rowid;
diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php
index e62b17559ee..76394916550 100644
--- a/htdocs/societe/list.php
+++ b/htdocs/societe/list.php
@@ -50,14 +50,15 @@ $confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartylist';
-if ($contextpage == 'poslist')
-{
+if ($contextpage == 'poslist') {
$_GET['optioncss'] = 'print';
}
// Security check
$socid = GETPOST('socid', 'int');
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'societe', $socid, '');
$search_all = trim(GETPOST('search_all', 'alphanohtml') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
@@ -113,17 +114,47 @@ $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 (!$sortorder) $sortorder = "ASC";
-if (!$sortfield) $sortfield = "s.nom";
-if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
+if (!$sortorder) {
+ $sortorder = "ASC";
+}
+if (!$sortfield) {
+ $sortfield = "s.nom";
+}
+if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
+ $page = 0;
+} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
-if ($type == 'c') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'customerlist'; if ($search_type == '') $search_type = '1,3'; }
-if ($type == 'p') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'prospectlist'; if ($search_type == '') $search_type = '2,3'; }
-if ($type == 't') { if (empty($contextpage) || $contextpage == 'poslist') $contextpage = 'poslist'; if ($search_type == '') $search_type = '1,2,3'; }
-if ($type == 'f') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'supplierlist'; if ($search_type == '') $search_type = '4'; }
+if ($type == 'c') {
+ if (empty($contextpage) || $contextpage == 'thirdpartylist') {
+ $contextpage = 'customerlist';
+ } if ($search_type == '') {
+ $search_type = '1,3';
+ }
+}
+if ($type == 'p') {
+ if (empty($contextpage) || $contextpage == 'thirdpartylist') {
+ $contextpage = 'prospectlist';
+ } if ($search_type == '') {
+ $search_type = '2,3';
+ }
+}
+if ($type == 't') {
+ if (empty($contextpage) || $contextpage == 'poslist') {
+ $contextpage = 'poslist';
+ } if ($search_type == '') {
+ $search_type = '1,2,3';
+ }
+}
+if ($type == 'f') {
+ if (empty($contextpage) || $contextpage == 'thirdpartylist') {
+ $contextpage = 'supplierlist';
+ } if ($search_type == '') {
+ $search_type = '4';
+ }
+}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new Societe($db);
@@ -154,12 +185,22 @@ $fieldstosearchall = array(
's.phone'=>"Phone",
's.fax'=>"Fax",
);
-if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4'] = 'ProfId4';
-if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5'] = 'ProfId5';
-if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6'] = 'ProfId6';
-if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode'] = 'Gencod';
+if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') {
+ $fieldstosearchall['s.idprof4'] = 'ProfId4';
+}
+if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') {
+ $fieldstosearchall['s.idprof5'] = 'ProfId5';
+}
+if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') {
+ $fieldstosearchall['s.idprof6'] = 'ProfId6';
+}
+if (!empty($conf->barcode->enabled)) {
+ $fieldstosearchall['s.barcode'] = 'Gencod';
+}
// Personalized search criterias. Example: $conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS = 's.nom=ThirdPartyName;s.name_alias=AliasNameShort;s.code_client=CustomerCode'
-if (!empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall = dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS);
+if (!empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) {
+ $fieldstosearchall = dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS);
+}
// Define list of fields to show into list
@@ -216,8 +257,7 @@ $arrayfields = array(
's.status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
);
-if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
-{
+if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
$arrayfields['s.price_level'] =array('label'=>"PriceLevel", 'position'=>30, 'checked'=>0);
}
@@ -232,16 +272,14 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
* Actions
*/
-if ($action == "change") // Change customer for TakePOS
-{
+if ($action == "change") { // Change customer for TakePOS
$idcustomer = GETPOST('idcustomer', '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)
- {
+ 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"];
@@ -257,35 +295,39 @@ if ($action == "change") // Change customer for TakePOS
$sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
$resql = $db->query($sql);
?>
-
-
+ 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)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// 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
- {
+ 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_id = '';
$search_nom = '';
$search_alias = '';
@@ -319,10 +361,10 @@ if (empty($reshook))
$search_staff = '';
$search_status = -1;
$search_stcomm = '';
- $search_level = '';
- $search_parent_name = '';
- $search_import_key = '';
- $toselect = '';
+ $search_level = '';
+ $search_parent_name = '';
+ $search_import_key = '';
+ $toselect = '';
$search_array_options = array();
}
@@ -335,19 +377,22 @@ if (empty($reshook))
$uploaddir = $conf->societe->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
- if ($action == 'setstcomm')
- {
+ if ($action == 'setstcomm') {
$object = new Client($db);
$result = $object->fetch(GETPOST('stcommsocid'));
$object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm');
$result = $object->update($object->id, $user);
- if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
+ if ($result < 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
$action = '';
}
}
-if ($search_status == '') $search_status = 1; // always display active thirdparty first
+if ($search_status == '') {
+ $search_status = 1; // always display active thirdparty first
+}
@@ -375,9 +420,15 @@ $prospectstatic->loadCacheOfProspStatus();
$title = $langs->trans("ListOfThirdParties");
-if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title = $langs->trans("ListOfCustomers");
-if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) $title = $langs->trans("ListOfProspects");
-if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) $title = $langs->trans("ListOfSuppliers");
+if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) {
+ $title = $langs->trans("ListOfCustomers");
+}
+if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) {
+ $title = $langs->trans("ListOfProspects");
+}
+if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) {
+ $title = $langs->trans("ListOfSuppliers");
+}
// Select every potentiels, and note each potentiels which fit in search parameters
$tab_level = array();
@@ -386,16 +437,18 @@ $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
$sql .= " WHERE active > 0";
$sql .= " ORDER BY sortorder";
$resql = $db->query($sql);
-if ($resql)
-{
- while ($obj = $db->fetch_object($resql))
- {
+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);
+ if ($level == $obj->code) {
+ $level = $langs->trans($obj->label);
+ }
$tab_level[$obj->code] = $level;
}
-} else dol_print_error($db);
+} else {
+ dol_print_error($db);
+}
$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.address, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,";
$sql .= " s.entity,";
@@ -410,13 +463,21 @@ $sql .= " country.code as country_code, country.label as country_label,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";
$sql .= " region.code_region as region_code, region.nom as region_name";
// We'll need these fields in order to filter by sale (including the case where the user can only see his prospects)
-if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user";
+if ($search_sale) {
+ $sql .= ", sc.fk_soc, sc.fk_user";
+}
// We'll need these fields in order to filter by categ
-if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
-if ($search_categ_sup) $sql .= ", cs.fk_categorie, cs.fk_soc";
+if ($search_categ_cus) {
+ $sql .= ", cc.fk_categorie, cc.fk_soc";
+}
+if ($search_categ_sup) {
+ $sql .= ", cs.fk_categorie, cs.fk_soc";
+}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
- foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
+ $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
+ }
}
// Add fields from hooks
$parameters = array();
@@ -424,80 +485,186 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N
$sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s.parent = s2.rowid";
-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 (s.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 (s.rowid = ef.fk_object)";
+}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region = state.fk_region)";
// We'll need this table joined to the select in order to filter by categ
-if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
-if (!empty($search_categ_sup)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ
+if (!empty($search_categ_cus)) {
+ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
+}
+if (!empty($search_categ_sup)) {
+ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ
+}
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id";
// We'll need this table joined to the select in order to filter by sale
-if ($search_sale == -2) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
-//elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-elseif ($search_sale || (empty($user->rights->societe->client->voir) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+if ($search_sale == -2) {
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
+ //elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+} elseif ($search_sale || (empty($user->rights->societe->client->voir) && !$socid)) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+}
$sql .= " WHERE s.entity IN (".getEntity('societe').")";
//if (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
-if (empty($user->rights->societe->client->voir) && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
-if ($search_sale && $search_sale != -2) $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
-if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
-if ($search_sale == -2) $sql .= " AND sc.fk_user IS NULL";
-elseif ($search_sale > 0) $sql .= " AND sc.fk_user = ".$db->escape($search_sale);
-if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
-if ($search_categ_sup > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ_sup);
-if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL";
-if ($search_categ_sup == -2) $sql .= " AND cs.fk_categorie IS NULL";
+if (empty($user->rights->societe->client->voir) && !$socid) {
+ $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+}
+if ($search_sale && $search_sale != -2) {
+ $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
+}
+if (!$user->rights->fournisseur->lire) {
+ $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
+}
+if ($search_sale == -2) {
+ $sql .= " AND sc.fk_user IS NULL";
+} elseif ($search_sale > 0) {
+ $sql .= " AND sc.fk_user = ".$db->escape($search_sale);
+}
+if ($search_categ_cus > 0) {
+ $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
+}
+if ($search_categ_sup > 0) {
+ $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ_sup);
+}
+if ($search_categ_cus == -2) {
+ $sql .= " AND cc.fk_categorie IS NULL";
+}
+if ($search_categ_sup == -2) {
+ $sql .= " AND cs.fk_categorie IS NULL";
+}
-if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
-if (strlen($search_cti)) $sql .= natural_search('s.phone', $search_cti);
+if ($search_all) {
+ $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
+}
+if (strlen($search_cti)) {
+ $sql .= natural_search('s.phone', $search_cti);
+}
-if ($search_id > 0) $sql .= natural_search("s.rowid", $search_id, 1);
-if ($search_nom) $sql .= natural_search("s.nom", $search_nom);
-if ($search_alias) $sql .= natural_search("s.name_alias", $search_alias);
-if ($search_nom_only) $sql .= natural_search("s.nom", $search_nom_only);
-if ($search_customer_code) $sql .= natural_search("s.code_client", $search_customer_code);
-if ($search_supplier_code) $sql .= natural_search("s.code_fournisseur", $search_supplier_code);
-if ($search_account_customer_code) $sql .= natural_search("s.code_compta", $search_account_customer_code);
-if ($search_account_supplier_code) $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code);
-if ($search_address) $sql.= natural_search('s.address', $search_address);
-if ($search_town) $sql .= natural_search("s.town", $search_town);
-if (strlen($search_zip)) $sql .= natural_search("s.zip", $search_zip);
-if ($search_state) $sql .= natural_search("state.nom", $search_state);
-if ($search_region) $sql .= natural_search("region.nom", $search_region);
-if ($search_country && $search_country != '-1') $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
-if ($search_email) $sql .= natural_search("s.email", $search_email);
-if (strlen($search_phone)) $sql .= natural_search("s.phone", $search_phone);
-if (strlen($search_fax)) $sql .= natural_search("s.fax", $search_fax);
-if ($search_url) $sql .= natural_search("s.url", $search_url);
-if (strlen($search_idprof1)) $sql .= natural_search("s.siren", $search_idprof1);
-if (strlen($search_idprof2)) $sql .= natural_search("s.siret", $search_idprof2);
-if (strlen($search_idprof3)) $sql .= natural_search("s.ape", $search_idprof3);
-if (strlen($search_idprof4)) $sql .= natural_search("s.idprof4", $search_idprof4);
-if (strlen($search_idprof5)) $sql .= natural_search("s.idprof5", $search_idprof5);
-if (strlen($search_idprof6)) $sql .= natural_search("s.idprof6", $search_idprof6);
-if (strlen($search_vat)) $sql .= natural_search("s.tva_intra", $search_vat);
+if ($search_id > 0) {
+ $sql .= natural_search("s.rowid", $search_id, 1);
+}
+if ($search_nom) {
+ $sql .= natural_search("s.nom", $search_nom);
+}
+if ($search_alias) {
+ $sql .= natural_search("s.name_alias", $search_alias);
+}
+if ($search_nom_only) {
+ $sql .= natural_search("s.nom", $search_nom_only);
+}
+if ($search_customer_code) {
+ $sql .= natural_search("s.code_client", $search_customer_code);
+}
+if ($search_supplier_code) {
+ $sql .= natural_search("s.code_fournisseur", $search_supplier_code);
+}
+if ($search_account_customer_code) {
+ $sql .= natural_search("s.code_compta", $search_account_customer_code);
+}
+if ($search_account_supplier_code) {
+ $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code);
+}
+if ($search_address) {
+ $sql.= natural_search('s.address', $search_address);
+}
+if ($search_town) {
+ $sql .= natural_search("s.town", $search_town);
+}
+if (strlen($search_zip)) {
+ $sql .= natural_search("s.zip", $search_zip);
+}
+if ($search_state) {
+ $sql .= natural_search("state.nom", $search_state);
+}
+if ($search_region) {
+ $sql .= natural_search("region.nom", $search_region);
+}
+if ($search_country && $search_country != '-1') {
+ $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
+}
+if ($search_email) {
+ $sql .= natural_search("s.email", $search_email);
+}
+if (strlen($search_phone)) {
+ $sql .= natural_search("s.phone", $search_phone);
+}
+if (strlen($search_fax)) {
+ $sql .= natural_search("s.fax", $search_fax);
+}
+if ($search_url) {
+ $sql .= natural_search("s.url", $search_url);
+}
+if (strlen($search_idprof1)) {
+ $sql .= natural_search("s.siren", $search_idprof1);
+}
+if (strlen($search_idprof2)) {
+ $sql .= natural_search("s.siret", $search_idprof2);
+}
+if (strlen($search_idprof3)) {
+ $sql .= natural_search("s.ape", $search_idprof3);
+}
+if (strlen($search_idprof4)) {
+ $sql .= natural_search("s.idprof4", $search_idprof4);
+}
+if (strlen($search_idprof5)) {
+ $sql .= natural_search("s.idprof5", $search_idprof5);
+}
+if (strlen($search_idprof6)) {
+ $sql .= natural_search("s.idprof6", $search_idprof6);
+}
+if (strlen($search_vat)) {
+ $sql .= natural_search("s.tva_intra", $search_vat);
+}
// Filter on type of thirdparty
-if ($search_type > 0 && in_array($search_type, array('1,3', '1,2,3', '2,3'))) $sql .= " AND s.client IN (".$db->sanitize($db->escape($search_type)).")";
-if ($search_type > 0 && in_array($search_type, array('4'))) $sql .= " AND s.fournisseur = 1";
-if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0";
-if ($search_status != '' && $search_status >= 0) $sql .= natural_search("s.status", $search_status, 2);
-if (!empty($conf->barcode->enabled) && $search_barcode) $sql .= natural_search("s.barcode", $search_barcode);
-if ($search_prive_level && $search_prive_level != '-1') $sql .= natural_search("s.price_level", $search_prive_level, 2);
-if ($search_type_thirdparty && $search_type_thirdparty > 0) $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2);
-if (!empty($search_staff) && $search_staff != '-1') $sql .= natural_search("s.fk_effectif", $search_staff, 2);
-if ($search_level) $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3);
-if ($search_parent_name) $sql .= natural_search("s2.nom", $search_parent_name);
-if ($search_stcomm != '' && $search_stcomm != -2) $sql .= natural_search("s.fk_stcomm", $search_stcomm, 2);
-if ($search_import_key) $sql .= natural_search("s.import_key", $search_import_key);
+if ($search_type > 0 && in_array($search_type, array('1,3', '1,2,3', '2,3'))) {
+ $sql .= " AND s.client IN (".$db->sanitize($db->escape($search_type)).")";
+}
+if ($search_type > 0 && in_array($search_type, array('4'))) {
+ $sql .= " AND s.fournisseur = 1";
+}
+if ($search_type == '0') {
+ $sql .= " AND s.client = 0 AND s.fournisseur = 0";
+}
+if ($search_status != '' && $search_status >= 0) {
+ $sql .= natural_search("s.status", $search_status, 2);
+}
+if (!empty($conf->barcode->enabled) && $search_barcode) {
+ $sql .= natural_search("s.barcode", $search_barcode);
+}
+if ($search_prive_level && $search_prive_level != '-1') {
+ $sql .= natural_search("s.price_level", $search_prive_level, 2);
+}
+if ($search_type_thirdparty && $search_type_thirdparty > 0) {
+ $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2);
+}
+if (!empty($search_staff) && $search_staff != '-1') {
+ $sql .= natural_search("s.fk_effectif", $search_staff, 2);
+}
+if ($search_level) {
+ $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3);
+}
+if ($search_parent_name) {
+ $sql .= natural_search("s2.nom", $search_parent_name);
+}
+if ($search_stcomm != '' && $search_stcomm != -2) {
+ $sql .= natural_search("s.fk_stcomm", $search_stcomm, 2);
+}
+if ($search_import_key) {
+ $sql .= natural_search("s.import_key", $search_import_key);
+}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
$parameters = array('socid' => $socid);
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
- if ($socid) $sql .= " AND s.rowid = ".$socid;
+ if ($socid) {
+ $sql .= " AND s.rowid = ".$socid;
+ }
}
$sql .= $hookmanager->resPrint;
@@ -505,12 +672,10 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
-if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
-{
+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
- {
+ if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
@@ -519,8 +684,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
-if (!$resql)
-{
+if (!$resql) {
dol_print_error($db);
exit;
}
@@ -551,52 +715,133 @@ $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $langs->trans("ThirdParty"), $help_url);
$param = '';
-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
-if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
-if ($search_all != '') $param = "&sall=".urlencode($search_all);
-if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus);
-if ($search_categ_sup > 0) $param .= '&search_categ_sup='.urlencode($search_categ_sup);
-if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
-if ($search_id > 0) $param .= "&search_id=".urlencode($search_id);
-if ($search_nom != '') $param .= "&search_nom=".urlencode($search_nom);
-if ($search_alias != '') $param .= "&search_alias=".urlencode($search_alias);
-if ($search_address != '') $param .= '&search_address=' . urlencode($search_address);
-if ($search_town != '') $param .= "&search_town=".urlencode($search_town);
-if ($search_zip != '') $param .= "&search_zip=".urlencode($search_zip);
-if ($search_phone != '') $param .= "&search_phone=".urlencode($search_phone);
-if ($search_fax != '') $param .= "&search_fax=".urlencode($search_fax);
-if ($search_email != '') $param .= "&search_email=".urlencode($search_email);
-if ($search_url != '') $param .= "&search_url=".urlencode($search_url);
-if ($search_state != '') $param .= "&search_state=".urlencode($search_state);
-if ($search_country != '') $param .= "&search_country=".urlencode($search_country);
-if ($search_customer_code != '') $param .= "&search_customer_code=".urlencode($search_customer_code);
-if ($search_supplier_code != '') $param .= "&search_supplier_code=".urlencode($search_supplier_code);
-if ($search_account_customer_code != '') $param .= "&search_account_customer_code=".urlencode($search_account_customer_code);
-if ($search_account_supplier_code != '') $param .= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
-if ($search_barcode != '') $param .= "&search_barcode=".urlencode($search_barcode);
-if ($search_idprof1 != '') $param .= '&search_idprof1='.urlencode($search_idprof1);
-if ($search_idprof2 != '') $param .= '&search_idprof2='.urlencode($search_idprof2);
-if ($search_idprof3 != '') $param .= '&search_idprof3='.urlencode($search_idprof3);
-if ($search_idprof4 != '') $param .= '&search_idprof4='.urlencode($search_idprof4);
-if ($search_idprof5 != '') $param .= '&search_idprof5='.urlencode($search_idprof5);
-if ($search_idprof6 != '') $param .= '&search_idprof6='.urlencode($search_idprof6);
-if ($search_vat != '') $param .= '&search_vat='.urlencode($search_vat);
-if ($search_prive_level != '') $param .= '&search_prive_level='.urlencode($search_prive_level);
-if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
-if ($search_type != '') $param .= '&search_type='.urlencode($search_type);
-if (is_array($search_level) && count($search_level)) foreach ($search_level as $slevel) $param .= '&search_level[]='.urlencode($slevel);
-if ($search_status != '') $param .= '&search_status='.urlencode($search_status);
-if ($search_stcomm != '') $param .= '&search_stcomm='.urlencode($search_stcomm);
-if ($search_parent_name != '') $param .= '&search_parent_name='.urlencode($search_parent_name);
-if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key);
-if ($type != '') $param .= '&type='.urlencode($type);
-if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+ $param .= '&contextpage='.urlencode($contextpage);
+}
+if ($limit > 0 && $limit != $conf->liste_limit) {
+ $param .= '&limit='.urlencode($limit);
+}
+if ($search_all != '') {
+ $param = "&sall=".urlencode($search_all);
+}
+if ($search_categ_cus > 0) {
+ $param .= '&search_categ_cus='.urlencode($search_categ_cus);
+}
+if ($search_categ_sup > 0) {
+ $param .= '&search_categ_sup='.urlencode($search_categ_sup);
+}
+if ($search_sale > 0) {
+ $param .= '&search_sale='.urlencode($search_sale);
+}
+if ($search_id > 0) {
+ $param .= "&search_id=".urlencode($search_id);
+}
+if ($search_nom != '') {
+ $param .= "&search_nom=".urlencode($search_nom);
+}
+if ($search_alias != '') {
+ $param .= "&search_alias=".urlencode($search_alias);
+}
+if ($search_address != '') {
+ $param .= '&search_address=' . urlencode($search_address);
+}
+if ($search_town != '') {
+ $param .= "&search_town=".urlencode($search_town);
+}
+if ($search_zip != '') {
+ $param .= "&search_zip=".urlencode($search_zip);
+}
+if ($search_phone != '') {
+ $param .= "&search_phone=".urlencode($search_phone);
+}
+if ($search_fax != '') {
+ $param .= "&search_fax=".urlencode($search_fax);
+}
+if ($search_email != '') {
+ $param .= "&search_email=".urlencode($search_email);
+}
+if ($search_url != '') {
+ $param .= "&search_url=".urlencode($search_url);
+}
+if ($search_state != '') {
+ $param .= "&search_state=".urlencode($search_state);
+}
+if ($search_country != '') {
+ $param .= "&search_country=".urlencode($search_country);
+}
+if ($search_customer_code != '') {
+ $param .= "&search_customer_code=".urlencode($search_customer_code);
+}
+if ($search_supplier_code != '') {
+ $param .= "&search_supplier_code=".urlencode($search_supplier_code);
+}
+if ($search_account_customer_code != '') {
+ $param .= "&search_account_customer_code=".urlencode($search_account_customer_code);
+}
+if ($search_account_supplier_code != '') {
+ $param .= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
+}
+if ($search_barcode != '') {
+ $param .= "&search_barcode=".urlencode($search_barcode);
+}
+if ($search_idprof1 != '') {
+ $param .= '&search_idprof1='.urlencode($search_idprof1);
+}
+if ($search_idprof2 != '') {
+ $param .= '&search_idprof2='.urlencode($search_idprof2);
+}
+if ($search_idprof3 != '') {
+ $param .= '&search_idprof3='.urlencode($search_idprof3);
+}
+if ($search_idprof4 != '') {
+ $param .= '&search_idprof4='.urlencode($search_idprof4);
+}
+if ($search_idprof5 != '') {
+ $param .= '&search_idprof5='.urlencode($search_idprof5);
+}
+if ($search_idprof6 != '') {
+ $param .= '&search_idprof6='.urlencode($search_idprof6);
+}
+if ($search_vat != '') {
+ $param .= '&search_vat='.urlencode($search_vat);
+}
+if ($search_prive_level != '') {
+ $param .= '&search_prive_level='.urlencode($search_prive_level);
+}
+if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
+ $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
+}
+if ($search_type != '') {
+ $param .= '&search_type='.urlencode($search_type);
+}
+if (is_array($search_level) && count($search_level)) {
+ foreach ($search_level as $slevel) {
+ $param .= '&search_level[]='.urlencode($slevel);
+ }
+}
+if ($search_status != '') {
+ $param .= '&search_status='.urlencode($search_status);
+}
+if ($search_stcomm != '') {
+ $param .= '&search_stcomm='.urlencode($search_stcomm);
+}
+if ($search_parent_name != '') {
+ $param .= '&search_parent_name='.urlencode($search_parent_name);
+}
+if ($search_import_key != '') {
+ $param .= '&search_import_key='.urlencode($search_import_key);
+}
+if ($type != '') {
+ $param .= '&type='.urlencode($type);
+}
+if ($optioncss != '') {
+ $param .= '&optioncss='.urlencode($optioncss);
+}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// Show delete result message
-if (GETPOST('delsoc'))
-{
+if (GETPOST('delsoc')) {
setEventMessages($langs->trans("CompanyDeleted", GETPOST('delsoc')), null, 'mesgs');
}
@@ -606,20 +851,31 @@ $arrayofmassactions = array(
// 'builddoc'=>$langs->trans("PDFMerge"),
);
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
-if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete");
-if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag");
-if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) $arrayofmassactions = array();
+if ($user->rights->societe->supprimer) {
+ $arrayofmassactions['predelete'] = ''.$langs->trans("Delete");
+}
+if ($user->rights->societe->creer) {
+ $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag");
+}
+if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
+ $arrayofmassactions = array();
+}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$typefilter = '';
$label = 'MenuNewThirdParty';
-if (!empty($type))
-{
+if (!empty($type)) {
$typefilter = '&type='.$type;
- if ($type == 'p') $label = 'MenuNewProspect';
- if ($type == 'c') $label = 'MenuNewCustomer';
- if ($type == 'f') $label = 'NewSupplier';
+ if ($type == 'p') {
+ $label = 'MenuNewProspect';
+ }
+ if ($type == 'c') {
+ $label = 'MenuNewCustomer';
+ }
+ if ($type == 'f') {
+ $label = 'NewSupplier';
+ }
}
if ($contextpage == 'poslist' && $type == 't' && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) {
@@ -630,7 +886,9 @@ if ($contextpage == 'poslist' && $type == 't' && (!empty($conf->global->PRODUIT_
// but allow it too, when a user has the rights to create a new customer
if ($contextpage != 'poslist') {
$url = DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter;
- if (!empty($socid)) $url .= '&socid='.$socid;
+ if (!empty($socid)) {
+ $url .= '&socid='.$socid;
+ }
$newcardbutton = dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->rights->societe->creer);
} elseif ($user->rights->societe->creer) {
$url = DOL_URL_ROOT.'/societe/card.php?action=create&type=t&contextpage=poslist&optioncss=print&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type=t&contextpage=poslist&nomassaction=1&optioncss=print&place='.$place);
@@ -639,7 +897,9 @@ if ($contextpage != 'poslist') {
}
print ' |