diff --git a/htdocs/mailmanspip/class/mailmanspip.class.php b/htdocs/mailmanspip/class/mailmanspip.class.php
index a0a636dd136..d08f6f65094 100644
--- a/htdocs/mailmanspip/class/mailmanspip.class.php
+++ b/htdocs/mailmanspip/class/mailmanspip.class.php
@@ -77,8 +77,7 @@ class MailmanSpip
*/
public function isSpipEnabled()
{
- if (defined("ADHERENT_USE_SPIP") && (ADHERENT_USE_SPIP == 1))
- {
+ if (defined("ADHERENT_USE_SPIP") && (ADHERENT_USE_SPIP == 1)) {
return true;
}
@@ -92,10 +91,8 @@ class MailmanSpip
*/
public function checkSpipConfig()
{
- if (defined('ADHERENT_SPIP_SERVEUR') && defined('ADHERENT_SPIP_USER') && defined('ADHERENT_SPIP_PASS') && defined('ADHERENT_SPIP_DB'))
- {
- if (ADHERENT_SPIP_SERVEUR != '' && ADHERENT_SPIP_USER != '' && ADHERENT_SPIP_PASS != '' && ADHERENT_SPIP_DB != '')
- {
+ if (defined('ADHERENT_SPIP_SERVEUR') && defined('ADHERENT_SPIP_USER') && defined('ADHERENT_SPIP_PASS') && defined('ADHERENT_SPIP_DB')) {
+ if (ADHERENT_SPIP_SERVEUR != '' && ADHERENT_SPIP_USER != '' && ADHERENT_SPIP_PASS != '' && ADHERENT_SPIP_DB != '') {
return true;
}
}
@@ -112,8 +109,7 @@ class MailmanSpip
{
$resource = getDoliDBInstance('mysql', ADHERENT_SPIP_SERVEUR, ADHERENT_SPIP_USER, ADHERENT_SPIP_PASS, ADHERENT_SPIP_DB, ADHERENT_SPIP_PORT);
- if ($resource->ok)
- {
+ if ($resource->ok) {
return $resource;
}
@@ -165,8 +161,7 @@ class MailmanSpip
dol_syslog('result curl_exec='.$result);
//An error was found, we store it in $this->error for later
- if ($result === false || curl_errno($ch) > 0)
- {
+ if ($result === false || curl_errno($ch) > 0) {
$this->error = curl_errno($ch).' '.curl_error($ch);
dol_syslog('Error using curl '.$this->error, LOG_ERR);
}
@@ -188,14 +183,11 @@ class MailmanSpip
// phpcs:enable
dol_syslog(get_class($this)."::add_to_spip");
- if ($this->isSpipEnabled())
- {
- if ($this->checkSpipConfig())
- {
+ if ($this->isSpipEnabled()) {
+ if ($this->checkSpipConfig()) {
$mydb = $this->connectSpip();
- if ($mydb)
- {
+ if ($mydb) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$mdpass = dol_hash($object->pass);
$htpass = crypt($object->pass, makesalt());
@@ -205,13 +197,20 @@ class MailmanSpip
$mydb->close();
- if ($result)
- {
+ if ($result) {
return 1;
- } else $this->error = $mydb->lasterror();
- } else $this->error = 'Failed to connect to SPIP';
- } else $this->error = 'BadSPIPConfiguration';
- } else $this->error = 'SPIPNotEnabled';
+ } else {
+ $this->error = $mydb->lasterror();
+ }
+ } else {
+ $this->error = 'Failed to connect to SPIP';
+ }
+ } else {
+ $this->error = 'BadSPIPConfiguration';
+ }
+ } else {
+ $this->error = 'SPIPNotEnabled';
+ }
return 0;
}
@@ -228,27 +227,31 @@ class MailmanSpip
// phpcs:enable
dol_syslog(get_class($this)."::del_to_spip");
- if ($this->isSpipEnabled())
- {
- if ($this->checkSpipConfig())
- {
+ if ($this->isSpipEnabled()) {
+ if ($this->checkSpipConfig()) {
$mydb = $this->connectSpip();
- if ($mydb)
- {
+ if ($mydb) {
$query = "DELETE FROM spip_auteurs WHERE login='".$object->login."'";
$result = $mydb->query($query);
$mydb->close();
- if ($result)
- {
+ if ($result) {
return 1;
- } else $this->error = $mydb->lasterror();
- } else $this->error = 'Failed to connect to SPIP';
- } else $this->error = 'BadSPIPConfiguration';
- } else $this->error = 'SPIPNotEnabled';
+ } else {
+ $this->error = $mydb->lasterror();
+ }
+ } else {
+ $this->error = 'Failed to connect to SPIP';
+ }
+ } else {
+ $this->error = 'BadSPIPConfiguration';
+ }
+ } else {
+ $this->error = 'SPIPNotEnabled';
+ }
return 0;
}
@@ -263,22 +266,17 @@ class MailmanSpip
public function is_in_spip($object)
{
// phpcs:enable
- if ($this->isSpipEnabled())
- {
- if ($this->checkSpipConfig())
- {
+ if ($this->isSpipEnabled()) {
+ if ($this->checkSpipConfig()) {
$mydb = $this->connectSpip();
- if ($mydb)
- {
+ if ($mydb) {
$query = "SELECT login FROM spip_auteurs WHERE login='".$object->login."'";
$result = $mydb->query($query);
- if ($result)
- {
- if ($mydb->num_rows($result))
- {
+ if ($result) {
+ if ($mydb->num_rows($result)) {
// nous avons au moins une reponse
$mydb->close($result);
return 1;
@@ -291,9 +289,15 @@ class MailmanSpip
$this->error = $mydb->lasterror();
$mydb->close();
}
- } else $this->error = 'Failed to connect to SPIP';
- } else $this->error = 'BadSPIPConfiguration';
- } else $this->error = 'SPIPNotEnabled';
+ } else {
+ $this->error = 'Failed to connect to SPIP';
+ }
+ } else {
+ $this->error = 'BadSPIPConfiguration';
+ }
+ } else {
+ $this->error = 'SPIPNotEnabled';
+ }
return -1;
}
@@ -316,36 +320,32 @@ class MailmanSpip
$this->mladded_ok = array();
$this->mladded_ko = array();
- if (!function_exists("curl_init"))
- {
+ if (!function_exists("curl_init")) {
$langs->load("errors");
$this->error = $langs->trans("ErrorFunctionNotAvailableInPHP", "curl_init");
return -1;
}
- if ($conf->adherent->enabled) // Synchro for members
- {
- if (!empty($conf->global->ADHERENT_MAILMAN_URL))
- {
- if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) $lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS);
- else $lists = explode(',', $listes);
+ if ($conf->adherent->enabled) { // Synchro for members
+ if (!empty($conf->global->ADHERENT_MAILMAN_URL)) {
+ if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) {
+ $lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS);
+ } else {
+ $lists = explode(',', $listes);
+ }
$categstatic = new Categorie($this->db);
- foreach ($lists as $list)
- {
+ foreach ($lists as $list) {
// Filter on type something (ADHERENT_MAILMAN_LISTS = "mailinglist0,TYPE:typevalue:mailinglist1,CATEG:categvalue:mailinglist2")
$tmp = explode(':', $list);
- if (!empty($tmp[2]))
- {
+ if (!empty($tmp[2])) {
$list = $tmp[2];
- if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) // Filter on member type label
- {
+ if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) { // Filter on member type label
dol_syslog("We ignore list ".$list." because object member type ".$object->type." does not match ".$tmp[1], LOG_DEBUG);
continue;
}
- if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) // Filter on member category
- {
+ if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) { // Filter on member category
dol_syslog("We ignore list ".$list." because object member is not into category ".$tmp[1], LOG_DEBUG);
continue;
}
@@ -354,11 +354,12 @@ class MailmanSpip
//We call Mailman to subscribe the user
$result = $this->callMailman($object, $conf->global->ADHERENT_MAILMAN_URL, $list);
- if ($result === false)
- {
+ if ($result === false) {
$this->mladded_ko[$list] = $object->email;
return -2;
- } else $this->mladded_ok[$list] = $object->email;
+ } else {
+ $this->mladded_ok[$list] = $object->email;
+ }
}
return count($lists);
} else {
@@ -387,36 +388,32 @@ class MailmanSpip
$this->mlremoved_ok = array();
$this->mlremoved_ko = array();
- if (!function_exists("curl_init"))
- {
+ if (!function_exists("curl_init")) {
$langs->load("errors");
$this->error = $langs->trans("ErrorFunctionNotAvailableInPHP", "curl_init");
return -1;
}
- if ($conf->adherent->enabled) // Synchro for members
- {
- if (!empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL))
- {
- if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) $lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS);
- else $lists = explode(',', $listes);
+ if ($conf->adherent->enabled) { // Synchro for members
+ if (!empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL)) {
+ if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) {
+ $lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS);
+ } else {
+ $lists = explode(',', $listes);
+ }
$categstatic = new Categorie($this->db);
- foreach ($lists as $list)
- {
+ foreach ($lists as $list) {
// Filter on type something (ADHERENT_MAILMAN_LISTS = "mailinglist0,TYPE:typevalue:mailinglist1,CATEG:categvalue:mailinglist2")
$tmp = explode(':', $list);
- if (!empty($tmp[2]))
- {
+ if (!empty($tmp[2])) {
$list = $tmp[2];
- if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) // Filter on member type label
- {
+ if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) { // Filter on member type label
dol_syslog("We ignore list ".$list." because object member type ".$object->type." does not match ".$tmp[1], LOG_DEBUG);
continue;
}
- if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) // Filter on member category
- {
+ if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) { // Filter on member category
dol_syslog("We ignore list ".$list." because object member is not into category ".$tmp[1], LOG_DEBUG);
continue;
}
@@ -425,11 +422,12 @@ class MailmanSpip
//We call Mailman to unsubscribe the user
$result = $this->callMailman($object, $conf->global->ADHERENT_MAILMAN_UNSUB_URL, $list);
- if ($result === false)
- {
+ if ($result === false) {
$this->mlremoved_ko[$list] = $object->email;
return -2;
- } else $this->mlremoved_ok[$list] = $object->email;
+ } else {
+ $this->mlremoved_ok[$list] = $object->email;
+ }
}
return count($lists);
} else {
diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php
index d9c470b7acd..c041700fa18 100644
--- a/htdocs/margin/admin/margin.php
+++ b/htdocs/margin/admin/margin.php
@@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
$langs->loadLangs(array("admin", "bills", "margins", "stocks"));
-if (!$user->admin) accessforbidden();
+if (!$user->admin) {
+ accessforbidden();
+}
$action = GETPOST('action', 'aZ09');
@@ -40,11 +42,9 @@ $action = GETPOST('action', 'aZ09');
* Action
*/
-if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
-{
+if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
$code = $reg[1];
- if (dolibarr_set_const($db, $code, 1, 'yesno', 0, '', $conf->entity) > 0)
- {
+ if (dolibarr_set_const($db, $code, 1, 'yesno', 0, '', $conf->entity) > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
@@ -52,11 +52,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
}
}
-if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
-{
+if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
$code = $reg[1];
- if (dolibarr_del_const($db, $code, $conf->entity) > 0)
- {
+ if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
@@ -64,30 +62,24 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
}
}
-if ($action == 'remises')
-{
- if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0)
- {
+if ($action == 'remises') {
+ if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
} else {
dol_print_error($db);
}
}
-if ($action == 'typemarges')
-{
- if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0)
- {
+if ($action == 'typemarges') {
+ if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
} else {
dol_print_error($db);
}
}
-if ($action == 'contact')
-{
- if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0)
- {
+if ($action == 'contact') {
+ if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
} else {
dol_print_error($db);
@@ -126,18 +118,23 @@ print '
';
print '| '.$langs->trans("ForceBuyingPriceIfNull").' | ';
print '';
-if (!empty($conf->use_javascript_ajax))
-{
+if (!empty($conf->use_javascript_ajax)) {
print ajax_constantonoff('ForceBuyingPriceIfNull');
} else {
- if (empty($conf->global->ForceBuyingPriceIfNull))
- {
+ if (empty($conf->global->ForceBuyingPriceIfNull)) {
print ''.img_picto($langs->trans("Disabled"), 'off').'';
} else {
print ''.img_picto($langs->trans("Enabled"), 'on').'';
diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php
index d97d992b99d..717e2d02c1b 100644
--- a/htdocs/margin/agentMargins.php
+++ b/htdocs/margin/agentMargins.php
@@ -39,16 +39,21 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (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 = "ASC";
-if (!$sortfield)
-{
- if ($agentid > 0)
+if (!$sortorder) {
+ $sortorder = "ASC";
+}
+if (!$sortfield) {
+ if ($agentid > 0) {
$sortfield = "s.nom";
- else $sortfield = "u.lastname";
+ } else {
+ $sortfield = "u.lastname";
+ }
}
$startdate = $enddate = '';
@@ -60,10 +65,12 @@ $enddateday = GETPOST('enddateday', 'int');
$enddatemonth = GETPOST('enddatemonth', 'int');
$enddateyear = GETPOST('enddateyear', 'int');
-if (!empty($startdatemonth))
+if (!empty($startdatemonth)) {
$startdate = dol_mktime(0, 0, 0, $startdatemonth, $startdateday, $startdateyear);
-if (!empty($enddatemonth))
+}
+if (!empty($enddatemonth)) {
$enddate = dol_mktime(23, 59, 59, $enddatemonth, $enddateday, $enddateyear);
+}
// Security check
if ($user->rights->margins->read->all) {
@@ -154,23 +161,31 @@ $sql .= " WHERE f.fk_soc = s.rowid";
$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
$sql .= " AND sc.fk_soc = f.fk_soc";
$sql .= " AND (d.product_type = 0 OR d.product_type = 1)";
-if (!empty($conf->global->AGENT_CONTACT_TYPE))
+if (!empty($conf->global->AGENT_CONTACT_TYPE)) {
$sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))";
-else $sql .= " AND sc.fk_user = u.rowid";
+} else {
+ $sql .= " AND sc.fk_user = u.rowid";
+}
$sql .= " AND f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")";
$sql .= ' AND s.entity IN ('.getEntity('societe').')';
$sql .= " AND d.fk_facture = f.rowid";
if ($agentid > 0) {
- if (!empty($conf->global->AGENT_CONTACT_TYPE))
- $sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))";
- else $sql .= " AND sc.fk_user = ".$agentid;
+ if (!empty($conf->global->AGENT_CONTACT_TYPE)) {
+ $sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))";
+ } else {
+ $sql .= " AND sc.fk_user = ".$agentid;
+ }
+}
+if (!empty($startdate)) {
+ $sql .= " AND f.datef >= '".$db->idate($startdate)."'";
+}
+if (!empty($enddate)) {
+ $sql .= " AND f.datef <= '".$db->idate($enddate)."'";
}
-if (!empty($startdate))
- $sql .= " AND f.datef >= '".$db->idate($startdate)."'";
-if (!empty($enddate))
- $sql .= " AND f.datef <= '".$db->idate($enddate)."'";
$sql .= " AND d.buy_price_ht IS NOT NULL";
-if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0";
+if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) {
+ $sql .= " AND d.buy_price_ht <> 0";
+}
//if ($agentid > 0) $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname";
//else $sql.= " GROUP BY u.rowid, u.login, u.lastname, u.firstname";
$sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname";
@@ -183,28 +198,42 @@ print ' ';
print img_info('').' '.$langs->trans("MarginPerSaleRepresentativeWarning").' ';
$param = '';
-if (!empty($agentid)) $param .= "&agentid=".urlencode($agentid);
-if (!empty($startdateday)) $param .= "&startdateday=".urlencode($startdateday);
-if (!empty($startdatemonth)) $param .= "&startdatemonth=".urlencode($startdatemonth);
-if (!empty($startdateyear)) $param .= "&startdateyear=".urlencode($startdateyear);
-if (!empty($enddateday)) $param .= "&enddateday=".urlencode($enddateday);
-if (!empty($enddatemonth)) $param .= "&enddatemonth=".urlencode($enddatemonth);
-if (!empty($enddateyear)) $param .= "&enddateyear=".urlencode($enddateyear);
+if (!empty($agentid)) {
+ $param .= "&agentid=".urlencode($agentid);
+}
+if (!empty($startdateday)) {
+ $param .= "&startdateday=".urlencode($startdateday);
+}
+if (!empty($startdatemonth)) {
+ $param .= "&startdatemonth=".urlencode($startdatemonth);
+}
+if (!empty($startdateyear)) {
+ $param .= "&startdateyear=".urlencode($startdateyear);
+}
+if (!empty($enddateday)) {
+ $param .= "&enddateday=".urlencode($enddateday);
+}
+if (!empty($enddatemonth)) {
+ $param .= "&enddatemonth=".urlencode($enddatemonth);
+}
+if (!empty($enddateyear)) {
+ $param .= "&enddateyear=".urlencode($enddateyear);
+}
dol_syslog('margin::agentMargins.php', LOG_DEBUG);
$result = $db->query($sql);
-if ($result)
-{
+if ($result) {
$num = $db->num_rows($result);
print ' ';
print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1);
- if ($conf->global->MARGIN_TYPE == "1")
+ if ($conf->global->MARGIN_TYPE == "1") {
$labelcostprice = 'BuyingPrice';
- else // value is 'costprice' or 'pmp'
+ } else { // value is 'costprice' or 'pmp'
$labelcostprice = 'CostPrice';
+ }
$moreforfilter = '';
@@ -213,21 +242,24 @@ if ($result)
print ''."\n";
print '';
- if ($agentid > 0)
+ if ($agentid > 0) {
print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
- else print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder);
+ } else {
+ print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder);
+ }
print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, '', $sortfield, $sortorder, 'right ');
- if (!empty($conf->global->DISPLAY_MARGIN_RATES))
+ if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
- if (!empty($conf->global->DISPLAY_MARK_RATES))
+ }
+ if (!empty($conf->global->DISPLAY_MARK_RATES)) {
print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
+ }
print " \n";
- if ($num > 0)
- {
+ if ($num > 0) {
$group_list = array();
while ($objp = $db->fetch_object($result)) {
if ($agentid > 0) {
@@ -295,10 +327,12 @@ if ($result)
print ''.price(price2num($pv, 'MT')).' | ';
print ''.price(price2num($pa, 'MT')).' | ';
print ''.price(price2num($marge, 'MT')).' | ';
- if (!empty($conf->global->DISPLAY_MARGIN_RATES))
+ if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").' | ';
- if (!empty($conf->global->DISPLAY_MARK_RATES))
+ }
+ if (!empty($conf->global->DISPLAY_MARK_RATES)) {
print ''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").' | ';
+ }
print "\n";
$i++;
@@ -319,10 +353,12 @@ if ($result)
print ''.price(price2num($cumul_vente, 'MT')).' | ';
print ''.price(price2num($cumul_achat, 'MT')).' | ';
print ''.price(price2num($totalMargin, 'MT')).' | ';
- if (!empty($conf->global->DISPLAY_MARGIN_RATES))
+ if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").' | ';
- if (!empty($conf->global->DISPLAY_MARK_RATES))
+ }
+ if (!empty($conf->global->DISPLAY_MARK_RATES)) {
print ''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").' | ';
+ }
print '';
print ' ';
diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php
index 5d019b2693a..f61d8d02e55 100644
--- a/htdocs/margin/checkMargins.php
+++ b/htdocs/margin/checkMargins.php
@@ -44,12 +44,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (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 = 'f.ref';
+if (!$sortorder) {
+ $sortorder = "DESC";
+}
+if (!$sortfield) {
+ $sortfield = 'f.ref';
+}
$startdate = $enddate = '';
@@ -73,15 +79,20 @@ if (GETPOST("button_search_x") || GETPOST("button_search")) {
* Actions
*/
-if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
-if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
+if (GETPOST('cancel', 'alpha')) {
+ $action = 'list'; $massaction = '';
+}
+if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
+ $massaction = '';
+}
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+if ($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';
@@ -108,23 +119,22 @@ if (empty($reshook))
}
// 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_ref = '';
$search_array_options = array();
}
// Mass actions
/*
- $objectclass='Product';
- if ((string) $type == '1') { $objectlabel='Services'; }
- if ((string) $type == '0') { $objectlabel='Products'; }
+ $objectclass='Product';
+ if ((string) $type == '1') { $objectlabel='Services'; }
+ if ((string) $type == '0') { $objectlabel='Products'; }
- $permissiontoread = $user->rights->produit->lire;
- $permissiontodelete = $user->rights->produit->supprimer;
- $uploaddir = $conf->product->dir_output;
- include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
- */
+ $permissiontoread = $user->rights->produit->lire;
+ $permissiontodelete = $user->rights->produit->supprimer;
+ $uploaddir = $conf->product->dir_output;
+ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
+ */
}
@@ -146,12 +156,24 @@ llxHeader('', $title);
// print load_fiche_titre($text);
$param = '';
-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
-if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
-if ($search_ref != '') $param .= '&search_ref='.urlencode($search_ref);
-if (!empty($startdate)) $param .= '&startdatemonth='.GETPOST('startdatemonth', 'int').'&startdateday='.GETPOST('startdateday', 'int').'&startdateyear='.GETPOST('startdateyear', 'int');
-if (!empty($enddate)) $param .= '&enddatemonth='.GETPOST('enddatemonth', 'int').'&enddateday='.GETPOST('enddateday', 'int').'&enddateyear='.GETPOST('enddateyear', 'int');
-if ($optioncss != '') $param .= '&optioncss='.$optioncss;
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+ $param .= '&contextpage='.$contextpage;
+}
+if ($limit > 0 && $limit != $conf->liste_limit) {
+ $param .= '&limit='.$limit;
+}
+if ($search_ref != '') {
+ $param .= '&search_ref='.urlencode($search_ref);
+}
+if (!empty($startdate)) {
+ $param .= '&startdatemonth='.GETPOST('startdatemonth', 'int').'&startdateday='.GETPOST('startdateday', 'int').'&startdateyear='.GETPOST('startdateyear', 'int');
+}
+if (!empty($enddate)) {
+ $param .= '&enddatemonth='.GETPOST('enddatemonth', 'int').'&enddateday='.GETPOST('enddateday', 'int').'&enddateyear='.GETPOST('enddateyear', 'int');
+}
+if ($optioncss != '') {
+ $param .= '&optioncss='.$optioncss;
+}
// Show tabs
$head = marges_prepare_head($user);
@@ -194,9 +216,15 @@ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as d ON d.fk_facture = f.rowi
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
$sql .= " WHERE f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")";
$sql .= " AND f.entity IN (".getEntity('invoice').") ";
-if (!empty($startdate)) $sql .= " AND f.datef >= '".$db->idate($startdate)."'";
-if (!empty($enddate)) $sql .= " AND f.datef <= '".$db->idate($enddate)."'";
-if ($search_ref) $sql .= natural_search('f.ref', $search_ref);
+if (!empty($startdate)) {
+ $sql .= " AND f.datef >= '".$db->idate($startdate)."'";
+}
+if (!empty($enddate)) {
+ $sql .= " AND f.datef <= '".$db->idate($enddate)."'";
+}
+if ($search_ref) {
+ $sql .= natural_search('f.ref', $search_ref);
+}
$sql .= " AND d.buy_price_ht IS NOT NULL";
$sql .= $db->order($sortfield, $sortorder);
@@ -205,8 +233,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
dol_syslog(__FILE__, LOG_DEBUG);
$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;
}
@@ -221,10 +248,11 @@ if ($result) {
print ' ';
print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
- if ($conf->global->MARGIN_TYPE == "1")
+ if ($conf->global->MARGIN_TYPE == "1") {
$labelcostprice = 'BuyingPrice';
- else // value is 'costprice' or 'pmp'
+ } else { // value is 'costprice' or 'pmp'
$labelcostprice = 'CostPrice';
+ }
$moreforfilter = '';
@@ -260,8 +288,7 @@ if ($result) {
print " |
\n";
$i = 0;
- while ($i < min($num, $limit))
- {
+ while ($i < min($num, $limit)) {
$objp = $db->fetch_object($result);
print '