Merge branch 'develop' into NEW-scope-checkbox-oauth

This commit is contained in:
Laurent Destailleur 2022-09-19 17:40:22 +02:00 committed by GitHub
commit 9979485246
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 441 additions and 183 deletions

View File

@ -35,7 +35,7 @@ PCLZip 2.8.4 LGPL-3+ Yes
PHPDebugBar 1.15.1 MIT License Yes Used only by the module "debugbar" for developers PHPDebugBar 1.15.1 MIT License Yes Used only by the module "debugbar" for developers
PHP-Imap 2.7.2 MIT License Yes Library to use IMAP with OAuth PHP-Imap 2.7.2 MIT License Yes Library to use IMAP with OAuth
PHPSpreadSheet 1.8.2 LGPL-2.1+ Yes Read/Write XLS files, read ODS files PHPSpreadSheet 1.8.2 LGPL-2.1+ Yes Read/Write XLS files, read ODS files
php-iban 4.1 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP php-iban 4.1.1 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP
PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service
PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests
PSR/Logs 1.0 MIT License Yes Library for logs (used by DebugBar) PSR/Logs 1.0 MIT License Yes Library for logs (used by DebugBar)

View File

@ -15,7 +15,6 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/ */
/** /**
@ -38,7 +37,7 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'oauth')); $langs->loadLangs(array('admin', 'oauth', 'modulebuilder'));
// Security check // Security check
if (!$user->admin) { if (!$user->admin) {
@ -117,7 +116,7 @@ $form = new Form($db);
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup'); print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
@ -147,22 +146,16 @@ foreach ($list as $key) {
} }
print '</select>'; print '</select>';
print ajax_combobox('provider'); print ajax_combobox('provider');
print ' <input type="text" name="label" value="" placeholder="'.$langs->trans("Label").'">'; print ' <input type="text" name="label" value="" placeholder="'.$langs->trans("Label").'" pattern="^\S+$" title="'.$langs->trans("SpaceOrSpecialCharAreNotAllowed").'">';
print ' <input type="submit" class="button small" name="add" value="'.$langs->trans("Add").'">'; print ' <input type="submit" class="button small" name="add" value="'.$langs->trans("Add").'">';
print '<br>';
print '<br>';
print dol_get_fiche_end();
print '</form>'; print '</form>';
print '<br>';
print '<br>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
print '<div class="div-table-responsive">';
print '<table class="noborder centpercent">';
$i = 0;
// Define $listinsetup // Define $listinsetup
foreach ($conf->global as $key => $val) { foreach ($conf->global as $key => $val) {
@ -179,119 +172,119 @@ foreach ($conf->global as $key => $val) {
} }
// $list is defined into oauth.lib.php to the list of supporter OAuth providers. if (count($listinsetup) > 0) {
foreach ($listinsetup as $key) { print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$supported = 0; print '<input type="hidden" name="token" value="'.newToken().'">';
$keyforsupportedoauth2array = $key[0]; // May be OAUTH_GOOGLE_NAME or OAUTH_GOOGLE_xxx_NAME print '<input type="hidden" name="action" value="update">';
$keyforsupportedoauth2array = preg_replace('/^OAUTH_/', '', $keyforsupportedoauth2array);
$keyforsupportedoauth2array = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array);
if (preg_match('/^.*-/', $keyforsupportedoauth2array)) {
$keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array);
} else {
$keyforprovider = '';
}
$keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
$keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
$i = 0;
if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) { // $list is defined into oauth.lib.php to the list of supporter OAuth providers.
$supported = 1; foreach ($listinsetup as $key) {
} $supported = 0;
if (!$supported) { $keyforsupportedoauth2array = $key[0]; // May be OAUTH_GOOGLE_NAME or OAUTH_GOOGLE_xxx_NAME
continue; // show only supported $keyforsupportedoauth2array = preg_replace('/^OAUTH_/', '', $keyforsupportedoauth2array);
} $keyforsupportedoauth2array = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array);
if (preg_match('/^.*-/', $keyforsupportedoauth2array)) {
$keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array);
} else {
$keyforprovider = '';
}
$keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
$keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
$i++; if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) {
$supported = 1;
}
if (!$supported) {
continue; // show only supported
}
// Api Name $i++;
$label = $langs->trans($keyforsupportedoauth2array);
print '<tr class="liste_titre'.($i > 1 ? ' liste_titre_add' : '').'">';
print '<td>';
print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
if ($label == $keyforsupportedoauth2array) {
print $supportedoauth2array[$keyforsupportedoauth2array]['name'];
} else {
print $label;
}
if ($keyforprovider) {
print ' (<b>'.$keyforprovider.'</b>)';
} else {
print ' (<b>'.$langs->trans("NoName").'</b>)';
}
print '</td>';
print '<td>';
if (!empty($supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials'])) {
print $langs->trans("OAUTH_URL_FOR_CREDENTIAL", $supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials']);
}
print '</td>';
print '</tr>';
if ($supported) { // Api Name
$redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php'; $label = $langs->trans($keyforsupportedoauth2array);
print '<tr class="liste_titre'.($i > 1 ? ' liste_titre_add' : '').'">';
print '<td>';
print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
if ($label == $keyforsupportedoauth2array) {
print $supportedoauth2array[$keyforsupportedoauth2array]['name'];
} else {
print $label;
}
if ($keyforprovider) {
print ' (<b>'.$keyforprovider.'</b>)';
} else {
print ' (<b>'.$langs->trans("NoName").'</b>)';
}
print '</td>';
print '<td>';
if (!empty($supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials'])) {
print $langs->trans("OAUTH_URL_FOR_CREDENTIAL", $supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials']);
}
print '</td>';
print '</tr>';
// Api Id
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>'; print '<td><label for="'.$key[1].'">'.$langs->trans("OAUTH_ID").'</label></td>';
print '<td><input style="width: 80%" type"text" name="uri'.$keyforsupportedoauth2array.'" value="'.$redirect_uri.'" disabled>'; print '<td><input type="text" size="100" id="'.$key[1].'" name="'.$key[1].'" value="'.getDolGlobalString($key[1]).'">';
print '</td></tr>'; print '</td></tr>';
if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') { // Api Secret
print '<tr class="oddeven value">';
print '<td><label for="'.$key[2].'">'.$langs->trans("OAUTH_SECRET").'</label></td>';
print '<td><input type="password" size="100" id="'.$key[2].'" name="'.$key[2].'" value="'.getDolGlobalString($key[2]).'">';
print '</td></tr>';
// TODO Move this into token generation
if ($supported) {
if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
print '<tr class="oddeven value">';
print '<td>'.$langs->trans("Scopes").'</td>';
print '<td>';
print '<input style="width: 80%" type"text" name="'.$key[4].'" value="'.getDolGlobalString($key[4]).'" >';
print '</td></tr>';
} else {
$availablescopes = array_flip(explode(',', $supportedoauth2array[$keyforsupportedoauth2array]['availablescopes']));
$currentscopes = explode(',', getDolGlobalString($key[4]));
$scopestodispay = array();
foreach ($availablescopes as $keyscope => $valscope) {
if (in_array($keyscope, $currentscopes)) {
$scopestodispay[$keyscope] = 1;
} else {
$scopestodispay[$keyscope] = 0;
}
}
// Api Scope
print '<tr class="oddeven value">';
print '<td>'.$langs->trans("Scopes").'</td>';
print '<td>';
foreach ($scopestodispay as $scope => $val) {
print '<input type="checkbox" name="'.$key[4].'[]" value="'.$scope.'"'.($val ? ' checked' : '').'>';
print '<label style="margin-right: 10px" for="'.$key[4].'">'.$scope.'</label>';
}
print '</td></tr>';
}
} else {
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
print '<td>'.$langs->trans("URLOfServiceForAuthorization").'</td>'; print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>';
print '<td><input style="width: 80%" type"text" name="'.$key[3].'" value="'.getDolGlobalString($key[3]).'" >'; print '<td>'.$langs->trans("FeatureNotYetSupported").'</td>';
print '</td></tr>'; print '</td></tr>';
} }
} else {
print '<tr class="oddeven value">';
print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>';
print '<td>'.$langs->trans("FeatureNotYetSupported").'</td>';
print '</td></tr>';
} }
// Api Id print '</table>'."\n";
print '<tr class="oddeven value">'; print '</div>';
print '<td><label for="'.$key[1].'">'.$langs->trans("OAUTH_ID").'</label></td>';
print '<td><input type="text" size="100" id="'.$key[1].'" name="'.$key[1].'" value="'.getDolGlobalString($key[1]).'">';
print '</td></tr>';
// Api Secret print $form->buttonsSaveCancel("Modify", '');
print '<tr class="oddeven value">';
print '<td><label for="'.$key[2].'">'.$langs->trans("OAUTH_SECRET").'</label></td>';
print '<td><input type="password" size="100" id="'.$key[2].'" name="'.$key[2].'" value="'.getDolGlobalString($key[2]).'">';
print '</td></tr>';
// TODO Move this into token generation print '</form>';
if ($supported) {
$availablescopes = array_flip(explode(',', $supportedoauth2array[$keyforsupportedoauth2array]['availablescopes']));
$currentscopes = explode(',', getDolGlobalString($key[4]));
$scopestodispay = array();
foreach ($availablescopes as $keyscope => $valscope) {
if (in_array($keyscope, $currentscopes)) {
$scopestodispay[$keyscope] = 1;
} else {
$scopestodispay[$keyscope] = 0;
}
}
// Api Scope
print '<tr class="oddeven value">';
print '<td>'.$langs->trans("Scopes").'</td>';
print '<td>';
foreach ($scopestodispay as $scope => $val) {
print '<input type="checkbox" name="'.$key[4].'[]" value="'.$scope.'"'.($val ? ' checked' : '').'>';
print '<label style="margin-right: 10px" for="'.$key[4].'">'.$scope.'</label>';
}
print '</td></tr>';
}
} }
print '</table>'."\n";
print '</div>';
print dol_get_fiche_end();
print $form->buttonsSaveCancel("Modify", '');
print '</form>';
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -42,8 +42,12 @@ function printDropdownBookmarksList()
if (!empty($_SERVER["QUERY_STRING"])) { if (!empty($_SERVER["QUERY_STRING"])) {
if (is_array($_GET)) { if (is_array($_GET)) {
foreach ($_GET as $key => $val) { foreach ($_GET as $key => $val) {
if ($val != '') { if (is_array($val)) {
$url_param[$key]=http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); foreach ($val as $tmpsubval) {
$url_param[] = http_build_query(array(dol_escape_htmltag($key).'[]' => dol_escape_htmltag($tmpsubval)));
}
} elseif ($val != '') {
$url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val)));
} }
} }
} }
@ -61,10 +65,11 @@ function printDropdownBookmarksList()
if ((preg_match('/^search_/', $key) || in_array($key, $authorized_var)) if ((preg_match('/^search_/', $key) || in_array($key, $authorized_var))
&& $val != '' && $val != ''
&& !array_key_exists($key, $url_param)) { && !array_key_exists($key, $url_param)) {
$url_param[$key]=http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); $url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val)));
} }
} }
} }
$url .= ($tmpurl ? '?'.$tmpurl : ''); $url .= ($tmpurl ? '?'.$tmpurl : '');
if (!empty($url_param)) { if (!empty($url_param)) {
$url .= '&'.implode('&', $url_param); $url .= '&'.implode('&', $url_param);

View File

@ -4,6 +4,7 @@
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com
* Copyright (C) 2016 Frédéric France <frederic.france@free.fr> * Copyright (C) 2016 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -29,13 +30,16 @@
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('banks', 'categories', 'bills', 'companies')); $langs->loadLangs(array('banks', 'bills', 'categories', 'companies', 'salaries'));
// Security check // Security check
if (GETPOSTISSET("account") || GETPOSTISSET("ref")) { if (GETPOSTISSET("account") || GETPOSTISSET("ref")) {
@ -59,9 +63,12 @@ $hookmanager->initHooks(array('banktreso', 'globalcard'));
* View * View
*/ */
$societestatic = new Societe($db); $societestatic = new Societe($db);
$userstatic = new User($db);
$facturestatic = new Facture($db); $facturestatic = new Facture($db);
$facturefournstatic = new FactureFournisseur($db); $facturefournstatic = new FactureFournisseur($db);
$socialcontribstatic = new ChargeSociales($db); $socialcontribstatic = new ChargeSociales($db);
$salarystatic = new Salary($db);
$vatstatic = new TVA($db);
$form = new Form($db); $form = new Form($db);
@ -134,6 +141,27 @@ if (GETPOST("account") || GETPOST("ref")) {
$sql .= " ORDER BY dlr ASC"; $sql .= " ORDER BY dlr ASC";
$sqls[] = $sql; $sqls[] = $sql;
// Salaries
$sql = " SELECT 'salary' as family, sa.rowid as objid, sa.label as ref, (-1*sa.amount) as total_ttc, sa.dateep as dlr,";
$sql .= " s.rowid as socid, CONCAT(s.firstname, ' ', s.lastname) as name, 0 as fournisseur";
$sql .= " FROM ".MAIN_DB_PREFIX."salary as sa";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as s ON sa.fk_user = s.rowid";
$sql .= " WHERE sa.entity = ".$conf->entity;
$sql .= " AND sa.paye = 0"; // Not paid
$sql .= " AND (sa.fk_account IN (0, ".$object->id.") OR sa.fk_account IS NULL)"; // Id bank account of salary
$sql .= " ORDER BY dlr ASC";
$sqls[] = $sql;
// VAT
$sql = " SELECT 'vat' as family, t.rowid as objid, t.label as ref, (-1*t.amount) as total_ttc, t.datev as dlr,";
$sql .= " 0 as socid, 'noname' as name, 0 as fournisseur";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql .= " WHERE t.entity = ".$conf->entity;
$sql .= " AND t.paye = 0"; // Not paid
$sql .= " AND (t.fk_account IN (-1, 0, ".$object->id.") OR t.fk_account IS NULL)"; // Id bank account of vat
$sql .= " ORDER BY dlr ASC";
$sqls[] = $sql;
// others sql // others sql
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreSQL', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
@ -267,6 +295,26 @@ if (GETPOST("account") || GETPOST("ref")) {
$totalpayment = -1 * $socialcontribstatic->getSommePaiement(); // Payment already done $totalpayment = -1 * $socialcontribstatic->getSommePaiement(); // Payment already done
} }
if ($tmpobj->family == 'salary') {
$salarystatic->ref = $tmpobj->ref;
$salarystatic->id = $tmpobj->objid;
$salarystatic->label = $langs->trans("SalaryPayment");
$ref = $salarystatic->getNomUrl(1, '');
$userstatic->id = $tmpobj->socid;
$userstatic->name = $tmpobj->name;
$refcomp = $userstatic->getNomUrl(1);
$totalpayment = -1 * $salarystatic->getSommePaiement(); // Payment already done
}
if ($tmpobj->family == 'vat') {
$vatstatic->ref = $tmpobj->ref;
$vatstatic->id = $tmpobj->objid;
$vatstatic->type = $tmpobj->type;
$ref = $vatstatic->getNomUrl(1, '');
$totalpayment = -1 * $vatstatic->getSommePaiement(); // Payment already done
}
$parameters = array('obj' => $tmpobj, 'ref' => $ref, 'refcomp' => $refcomp, 'totalpayment' => $totalpayment); $parameters = array('obj' => $tmpobj, 'ref' => $ref, 'refcomp' => $refcomp, 'totalpayment' => $totalpayment);
$reshook = $hookmanager->executeHooks('moreFamily', $parameters, $tmpobject, $action); // Note that $action and $tmpobject may have been modified by hook $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $tmpobject, $action); // Note that $action and $tmpobject may have been modified by hook

View File

@ -124,7 +124,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes
if ($passok) { if ($passok) {
$login = $obj->login; $login = $obj->login;
} else { } else {
sleep(2); // Anti brut force protection sleep(1); // Anti brut force protection
dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO bad password for '".$usertotest."', cryptType=".$cryptType, LOG_NOTICE); dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO bad password for '".$usertotest."', cryptType=".$cryptType, LOG_NOTICE);
// Load translation files required by the page // Load translation files required by the page

View File

@ -267,7 +267,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
$ldap->ldapErrorText = ldap_error($ldap->connection); $ldap->ldapErrorText = ldap_error($ldap->connection);
dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorCode." ".$ldap->ldapErrorText); dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorCode." ".$ldap->ldapErrorText);
} }
sleep(2); // Anti brut force protection sleep(1); // Anti brut force protection
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('main', 'other', 'errors')); $langs->loadLangs(array('main', 'other', 'errors'));

View File

@ -101,7 +101,7 @@ if (empty($reshook) && isset($extrafields->attributes[$object->table_element]['l
if ($action == 'edit_extras') { if ($action == 'edit_extras') {
$value = (GETPOSTISSET("options_".$tmpkeyextra) ? GETPOST("options_".$tmpkeyextra) : $object->array_options["options_".$tmpkeyextra]); $value = (GETPOSTISSET("options_".$tmpkeyextra) ? GETPOST("options_".$tmpkeyextra) : $object->array_options["options_".$tmpkeyextra]);
} else { } else {
$value = (!empty($object->array_options["options_".$tmpkeyextra]) ? $object->array_options["options_".$tmpkeyextra] : ''); $value = (isset($object->array_options["options_".$tmpkeyextra]) ? $object->array_options["options_".$tmpkeyextra] : '');
//var_dump($tmpkeyextra.' - '.$value); //var_dump($tmpkeyextra.' - '.$value);
} }

View File

@ -0,0 +1,168 @@
<?php
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
/**
* Class PhpCollector
*
* This class collects all PHP errors, notice, advices, trigger_error,...
* Supports 15 different types included.
*/
class PhpCollector extends DataCollector implements Renderable
{
/**
* Collector name.
*
* @var string
*/
protected $name;
/**
* List of messages. Each item includes:
* 'message', 'message_html', 'is_string', 'label', 'time'.
*
* @var array
*/
protected $messages = [];
/**
* PHPCollector constructor.
*
* @param string $name The name used by this collector widget.
*/
public function __construct($name = 'Error handler')
{
$this->name = $name;
set_error_handler([$this, 'errorHandler'], E_ALL);
}
/**
* Called by the DebugBar when data needs to be collected.
*
* @return array Collected data.
*/
public function collect()
{
$messages = $this->getMessages();
return [
'count' => count($messages),
'messages' => $messages,
];
}
/**
* Returns a list of messages ordered by their timestamp.
*
* @return array A list of messages ordered by time.
*/
public function getMessages()
{
$messages = $this->messages;
usort($messages, function ($itemA, $itemB) {
if ($itemA['time'] === $itemB['time']) {
return 0;
}
return $itemA['time'] < $itemB['time'] ? -1 : 1;
});
return $messages;
}
/**
* Returns a hash where keys are control names and their values an array of options as defined in
* {@see DebugBar\JavascriptRenderer::addControl()}
*
* @return array Needed details to render the widget.
*/
public function getWidgets()
{
$name = $this->getName();
return [
$name => [
'icon' => 'list',
'widget' => 'PhpDebugBar.Widgets.MessagesWidget',
'map' => "$name.messages",
'default' => '[]',
],
"$name:badge" => [
'map' => "$name.count",
'default' => 'null',
],
];
}
/**
* Returns the unique name of the collector.
*
* @return string The widget name.
*/
public function getName()
{
return $this->name;
}
/**
* Exception error handler. Called from constructor with set_error_handler to add all details.
*
* @param int $severity Error type.
* @param string $message Message of error.
* @param string $fileName File where error is generated.
* @param int $line Line number where error is generated.
*
* @return void
*/
public function errorHandler($severity, $message, $fileName, $line)
{
for ($i = 0; $i < 15; $i++) {
if ($type = $severity & (2 ** $i)) {
$label = $this->friendlyErrorType($type);
$this->messages[] = [
'message' => $message . ' (' . $fileName . ':' . $line . ')',
'message_html' => null,
'is_string' => true,
'label' => $label,
'time' => microtime(true),
];
}
}
}
/**
* Return error name from error code.
*
* @info http://php.net/manual/es/errorfunc.constants.php
*
* @param int $type Error code.
*
* @return string Error name.
*/
private function friendlyErrorType($type)
{
$errors = [
E_ERROR => 'ERROR',
E_WARNING => 'WARNING',
E_PARSE => 'PARSE',
E_NOTICE => 'NOTICE',
E_CORE_ERROR => 'CORE_ERROR',
E_CORE_WARNING => 'CORE_WARNING',
E_COMPILE_ERROR => 'COMPILE_ERROR',
E_COMPILE_WARNING => 'COMPILE_WARNING',
E_USER_ERROR => 'USER_ERROR',
E_USER_WARNING => 'USER_WARNING',
E_USER_NOTICE => 'USER_NOTICE',
E_STRICT => 'STRICT',
E_RECOVERABLE_ERROR => 'RECOVERABLE_ERROR',
E_DEPRECATED => 'DEPRECATED',
E_USER_DEPRECATED => 'USER_DEPRECATED',
];
$result = '';
if (isset($errors[$type])) {
$result = $errors[$type];
}
return $result;
}
}

View File

@ -10,6 +10,7 @@ dol_include_once('/debugbar/class/DataCollector/DolRequestDataCollector.php');
dol_include_once('/debugbar/class/DataCollector/DolConfigCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolConfigCollector.php');
dol_include_once('/debugbar/class/DataCollector/DolTimeDataCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolTimeDataCollector.php');
dol_include_once('/debugbar/class/DataCollector/DolMemoryCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolMemoryCollector.php');
dol_include_once('/debugbar/class/DataCollector/DolPhpCollector.php');
dol_include_once('/debugbar/class/DataCollector/DolExceptionsCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolExceptionsCollector.php');
dol_include_once('/debugbar/class/DataCollector/DolQueryCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolQueryCollector.php');
dol_include_once('/debugbar/class/DataCollector/DolibarrCollector.php'); dol_include_once('/debugbar/class/DataCollector/DolibarrCollector.php');
@ -36,6 +37,7 @@ class DolibarrDebugBar extends DebugBar
$this->addCollector(new DolRequestDataCollector()); $this->addCollector(new DolRequestDataCollector());
//$this->addCollector(new DolConfigCollector()); // Disabled for security purpose //$this->addCollector(new DolConfigCollector()); // Disabled for security purpose
$this->addCollector(new DolTimeDataCollector()); $this->addCollector(new DolTimeDataCollector());
$this->addCollector(new PhpCollector());
$this->addCollector(new DolMemoryCollector()); $this->addCollector(new DolMemoryCollector());
//$this->addCollector(new DolExceptionsCollector()); //$this->addCollector(new DolExceptionsCollector());
$this->addCollector(new DolQueryCollector()); $this->addCollector(new DolQueryCollector());

View File

@ -1408,7 +1408,7 @@ if ($action == 'create') {
$deliverableQty = GETPOST($inputName, 'int'); $deliverableQty = GETPOST($inputName, 'int');
} }
print '<input '.$tooltip.' name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'" type="text" size="4" value="'.$deliverableQty.'">'; print '<input '.$tooltip.' class="qtyl" name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'" type="text" size="4" value="'.$deliverableQty.'">';
print '<input name="ent1'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$warehouse_id.'">'; print '<input name="ent1'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$warehouse_id.'">';
} else { } else {
if (!empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) { if (!empty($conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) {

View File

@ -9,10 +9,6 @@ php-iban
All parts of an IBAN can be retrieved, including country code, checksum, BBAN, financial institution or bank code, account number, and where a fixed-length national system is in use, also branch/sort code. Legacy national checksums may also be retrieved, validated and correctly set, where available, whether they apply to the account number portion, bank and branch identifiers, part or all of the above. IBAN country codes can be converted in to ISO3166-1 alpha-2 and IANA formats, the parent IBAN country acting as registrar for dependent territories may be queried, the official national currency (ISO4217 alpha code format), central bank name and central bank URL may also be queried to ease integration. IBANs may be converted between human and machine representation. IBANs may be obfuscated for presentation to humans in special circumstances such as relative identification. A database of example/test IBANs from different countries is included. Finally, highly accurate suggestions for originally intended input can be made when an incorrect IBAN is detected and is due to mistranscription error. All parts of an IBAN can be retrieved, including country code, checksum, BBAN, financial institution or bank code, account number, and where a fixed-length national system is in use, also branch/sort code. Legacy national checksums may also be retrieved, validated and correctly set, where available, whether they apply to the account number portion, bank and branch identifiers, part or all of the above. IBAN country codes can be converted in to ISO3166-1 alpha-2 and IANA formats, the parent IBAN country acting as registrar for dependent territories may be queried, the official national currency (ISO4217 alpha code format), central bank name and central bank URL may also be queried to ease integration. IBANs may be converted between human and machine representation. IBANs may be obfuscated for presentation to humans in special circumstances such as relative identification. A database of example/test IBANs from different countries is included. Finally, highly accurate suggestions for originally intended input can be made when an incorrect IBAN is detected and is due to mistranscription error.
Tested on PHP versions: ![PHP 5.2](https://img.shields.io/badge/version-PHP%205.2%2B-lightgrey.svg) ![PHP 5.3](https://img.shields.io/badge/version-PHP%205.3%2B-lightgrey.svg) ![PHP 5.4](https://img.shields.io/badge/version-PHP%205.4%2B-lightgrey.svg) ![PHP 5.5](https://img.shields.io/badge/version-PHP%205.5%2B-lightgrey.svg) ![PHP 5.6](https://img.shields.io/badge/version-PHP%205.6%2B-lightgrey.svg) ![PHP 7.0](https://img.shields.io/badge/version-PHP%207.0%2B-lightgrey.svg) ![PHP 7.4](https://img.shields.io/badge/version-PHP%207.4%2B-lightgrey.svg)
Test on HHVM versions: ![HHVM 3.3](https://img.shields.io/badge/version-HHVM%203.3%2B-lightgrey.svg) ![HHVM 3.6](https://img.shields.io/badge/version-HHVM%203.6%2B-lightgrey.svg) ![HHVM 3.9](https://img.shields.io/badge/version-HHVM%203.9%2B-lightgrey.svg) ![HHVM 3.12](https://img.shields.io/badge/version-HHVM%203.12%2B-lightgrey.svg) ![HHVM 3.15](https://img.shields.io/badge/version-HHVM%203.15%2B-lightgrey.svg) ![HHVM 3.18](https://img.shields.io/badge/version-HHVM%203.18%2B-lightgrey.svg)
The parser was built using regular expressions to adapt the contents of the _official_ IBAN registry available from SWIFT then manually modified for special cases such as [errors and omissions in SWIFT's official specifications](https://raw.githubusercontent.com/globalcitizen/php-iban/master/docs/COMEDY-OF-ERRORS). The parser was built using regular expressions to adapt the contents of the _official_ IBAN registry available from SWIFT then manually modified for special cases such as [errors and omissions in SWIFT's official specifications](https://raw.githubusercontent.com/globalcitizen/php-iban/master/docs/COMEDY-OF-ERRORS).
Various deficiencies in the initial adaptation have since been rectified, and the current version should be a fairly correct and reliable implementation. Various deficiencies in the initial adaptation have since been rectified, and the current version should be a fairly correct and reliable implementation.
@ -256,14 +252,14 @@ The following table compares __php-iban__ to other PHP projects offering IBAN-re
| Project | Lic. | Proc | OO | Began | Latest | Star | Watch | Fork | Installs | Home culture | Deps | | Project | Lic. | Proc | OO | Began | Latest | Star | Watch | Fork | Installs | Home culture | Deps |
| ---------------------------------------------------------- | ---- | ---- | --- | ------ | ------ | ---- | ----- | ---- | -------- | ------------ | ------- | | ---------------------------------------------------------- | ---- | ---- | --- | ------ | ------ | ---- | ----- | ---- | -------- | ------------ | ------- |
| __php-iban__ | LGPL | ✔ | ✔ | 2009 | 4.1.0 | 344 | 26 | 76 | ~2M* | Global* | *none* | | __php-iban__ | LGPL | ✔ | ✔ | 2009 | 4.1.1 | 414 | 28 | 98 | ~3.5M* | Global* | *none* |
| [Iban](https://github.com/jschaedl/Iban) | MIT | ✘ | ✔ | 2013 | 1.3.0 | 50 | 9 | 19 | 178.39k | German | lots | | [Iban](https://github.com/jschaedl/Iban) | MIT | ✘ | ✔ | 2013 | 1.3.0 | 50 | 9 | 19 | 178.39k | German | lots |
| [IsoCodes](https://github.com/ronanguilloux/IsoCodes) | GPL3 | ✘ | ✔ | 2012 | 2.1.1 | 466 | 22 | 54 | 145k | French | lots | | [IsoCodes](https://github.com/ronanguilloux/IsoCodes) | GPL3 | ✘ | ✔ | 2012 | 2.1.1 | 466 | 22 | 54 | 145k | French | lots |
| [SepaUtil's](https://github.com/AbcAeffchen/SepaUtilities) | GPL3 | ✘ | ✔ | 2014 | 1.2.3 | 8 | 4 | 3 | 25k | German | phpunit | | [SepaUtil's](https://github.com/AbcAeffchen/SepaUtilities) | GPL3 | ✘ | ✔ | 2014 | 1.2.3 | 8 | 4 | 3 | 25k | German | phpunit |
| [Symfony](https://github.com/symfony/symfony) | MIT | ✘ | ✔ | 2013 | 3.3.6 | 15k | 1214 | 5.6k | 23M+ | French | lots | | [Symfony](https://github.com/symfony/symfony) | MIT | ✘ | ✔ | 2013 | 3.3.6 | 15k | 1214 | 5.6k | 23M+ | French | lots |
Notes: Notes:
* Original download records for __php-iban__ releases were hosted on Google Code and are now lost. Prior to establishing a release process on Github, we just expected that people would download the code... so we're really not sure how many installs exist, but this is a fair guess (~11k + composer installs + a little bit now and then). * Original download records for __php-iban__ releases were hosted on Google Code and are now lost. Prior to establishing a release process on Github, we just expected that people would download the code... so we're really not sure how many installs exist, but this is a fair guess (now over 3M composer installs + all prior google code and Github installs).
* __php-iban__ also powers: * __php-iban__ also powers:
* [adm-gravity-iban](https://github.com/InternativeNL/adm-gravity-iban) * [adm-gravity-iban](https://github.com/InternativeNL/adm-gravity-iban)
* [Azzana consulting's XML Solver for ISO20022](http://www.azzana-consulting.com/xmlsolver/) * [Azzana consulting's XML Solver for ISO20022](http://www.azzana-consulting.com/xmlsolver/)
@ -324,6 +320,12 @@ Your Help Wanted
* If you are willing to spend some time searching, we could do with some more test IBANs for most countries, especially smaller ones... * If you are willing to spend some time searching, we could do with some more test IBANs for most countries, especially smaller ones...
News: August 2022
-----------------
__[Version 4.1.1](https://github.com/globalcitizen/php-iban/releases/tag/v4.1.1)__ has been released.
* Long-standing bug affecting Belgian pre-IBAN national checksum verification fixed - thanks to [Arne Peirs](https://github.com/Olympic1) for a [very well documented pull request](https://github.com/globalcitizen/php-iban/pull/119).
News: July 2021 News: July 2021
--------------- ---------------

View File

@ -714,13 +714,13 @@ function _iso7064_mod97_10($str) {
} }
# Implement the national checksum for a Belgium (BE) IBAN # Implement the national checksum for a Belgium (BE) IBAN
# (Credit: @gaetan-be) # (Credit: @gaetan-be, fixed by @Olympic1)
function _iban_nationalchecksum_implementation_be($iban,$mode) { function _iban_nationalchecksum_implementation_be($iban,$mode) {
if($mode != 'set' && $mode != 'find' && $mode != 'verify') { return ''; } # blank value on return to distinguish from correct execution if($mode != 'set' && $mode != 'find' && $mode != 'verify') { return ''; } # blank value on return to distinguish from correct execution
$nationalchecksum = iban_get_nationalchecksum_part($iban); $nationalchecksum = iban_get_nationalchecksum_part($iban);
$account = iban_get_account_part($iban); $bban = iban_get_bban_part($iban);
$account_less_checksum = substr($account,strlen($account)-2); $bban_less_checksum = substr($bban, 0, -strlen($nationalchecksum));
$expected_nationalchecksum = $account_less_checksum % 97; $expected_nationalchecksum = $bban_less_checksum % 97;
if($mode=='find') { if($mode=='find') {
return $expected_nationalchecksum; return $expected_nationalchecksum;
} }

View File

@ -44,8 +44,6 @@ $result = restrictedArea($user, 'societe', '', '');
$result = restrictedArea($user, 'margins'); $result = restrictedArea($user, 'margins');
$mesg = '';
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
@ -65,18 +63,18 @@ if (!$sortorder) {
} }
$startdate = $enddate = ''; $startdate = $enddate = '';
if (GETPOST('startdatemonth')) {
if (!empty($_POST['startdatemonth'])) { $startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int'));
$startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']);
} }
if (!empty($_POST['enddatemonth'])) { if (GETPOST('enddatemonth')) {
$enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); $enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('enddateday', 'int'), GETPOST('enddateyear'));
} }
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new Societe($db); $object = new Societe($db);
$hookmanager->initHooks(array('margincustomerlist')); $hookmanager->initHooks(array('margincustomerlist'));
/* /*
* View * View
*/ */
@ -189,7 +187,7 @@ print '<table class="border centpercent">';
// Total Margin // Total Margin
print '<tr><td class="titlefield">'.$langs->trans("TotalMargin").'</td><td colspan="4">'; print '<tr><td class="titlefield">'.$langs->trans("TotalMargin").'</td><td colspan="4">';
print '<span id="totalMargin"></span>'; // set by jquery (see below) print '<span id="totalMargin" class="amount"></span> <span class="amount">'.$langs->getCurrencySymbol($conf->currency).'</span>'; // set by jquery (see below)
print '</td></tr>'; print '</td></tr>';
// Margin Rate // Margin Rate
@ -272,6 +270,30 @@ $sql .= $db->order($sortfield, $sortorder);
// TODO: calculate total to display then restore pagination // TODO: calculate total to display then restore pagination
//$sql.= $db->plimit($conf->liste_limit +1, $offset); //$sql.= $db->plimit($conf->liste_limit +1, $offset);
$param = '&socid='.((int) $socid);
if (GETPOST('startdatemonth', 'int')) {
$param .= '&startdateyear='.GETPOST('startdateyear', 'int');
$param .= '&startdatemonth='.GETPOST('startdatemonth', 'int');
$param .= '&startdateday='.GETPOST('startdateday', 'int');
}
if (GETPOST('enddatemonth', 'int')) {
$param .= '&enddateyear='.GETPOST('enddateyear', 'int');
$param .= '&enddatemonth='.GETPOST('enddatemonth', 'int');
$param .= '&enddateday='.GETPOST('enddateday', 'int');
}
$listofproducts = GETPOST('products', 'array:int');
if (is_array($listofproducts)) {
foreach ($listofproducts as $val) {
$param .= '&products[]='.$val;
}
}
$listofcateg = GETPOST('categories', 'array:int');
if (is_array($listofcateg)) {
foreach ($listofcateg as $val) {
$param .= '&categories[]='.$val;
}
}
dol_syslog('margin::customerMargins.php', LOG_DEBUG); dol_syslog('margin::customerMargins.php', LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
@ -294,19 +316,19 @@ if ($result) {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (!empty($client)) { if (!empty($client)) {
print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&amp;socid=".$socid, '', $sortfield, $sortorder); print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&amp;socid=".$socid, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $param, 'align="center"', $sortfield, $sortorder);
} else { } else {
print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", "&amp;socid=".$socid, '', $sortfield, $sortorder); print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
} }
print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, 'align="right"', $sortfield, $sortorder);
if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder);
} }
if (!empty($conf->global->DISPLAY_MARK_RATES)) { if (!empty($conf->global->DISPLAY_MARK_RATES)) {
print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&amp;socid=".$socid, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder);
} }
print "</tr>\n"; print "</tr>\n";

View File

@ -74,18 +74,18 @@ if (!$sortfield) {
} }
$startdate = $enddate = ''; $startdate = $enddate = '';
if (GETPOST('startdatemonth')) {
if (!empty($_POST['startdatemonth'])) { $startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int'));
$startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']);
} }
if (!empty($_POST['enddatemonth'])) { if (GETPOST('enddatemonth')) {
$enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); $enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('enddateday', 'int'), GETPOST('enddateyear'));
} }
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new Product($db); $object = new Product($db);
$hookmanager->initHooks(array('marginproductlist')); $hookmanager->initHooks(array('marginproductlist'));
/* /*
* View * View
*/ */
@ -150,7 +150,7 @@ print '<table class="border centpercent">';
// Total Margin // Total Margin
print '<tr><td class="titlefield">'.$langs->trans("TotalMargin").'</td><td colspan="4">'; print '<tr><td class="titlefield">'.$langs->trans("TotalMargin").'</td><td colspan="4">';
print '<span id="totalMargin"></span>'; // set by jquery (see below) print '<span id="totalMargin" class="amount"></span> <span class="amount">'.$langs->getCurrencySymbol($conf->currency).'</span>'; // set by jquery (see below)
print '</td></tr>'; print '</td></tr>';
// Margin Rate // Margin Rate
@ -225,13 +225,31 @@ $sql .= $db->order($sortfield, $sortorder);
// TODO: calculate total to display then restore pagination // TODO: calculate total to display then restore pagination
//$sql.= $db->plimit($conf->liste_limit +1, $offset); //$sql.= $db->plimit($conf->liste_limit +1, $offset);
$param = '&id='.((int) $id);
if (GETPOST('startdatemonth', 'int')) {
$param .= '&startdateyear='.GETPOST('startdateyear', 'int');
$param .= '&startdatemonth='.GETPOST('startdatemonth', 'int');
$param .= '&startdateday='.GETPOST('startdateday', 'int');
}
if (GETPOST('enddatemonth', 'int')) {
$param .= '&enddateyear='.GETPOST('enddateyear', 'int');
$param .= '&enddatemonth='.GETPOST('enddatemonth', 'int');
$param .= '&enddateday='.GETPOST('enddateday', 'int');
}
$listofcateg = GETPOST('categories', 'array:int');
if (is_array($listofcateg)) {
foreach ($listofcateg as $val) {
$param .= '&categories[]='.$val;
}
}
dol_syslog('margin::productMargins.php', LOG_DEBUG); dol_syslog('margin::productMargins.php', LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
print '<br>'; print '<br>';
print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "&amp;id=".$id, $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1); print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1);
//var_dump($conf->global->MARGIN_TYPE); //var_dump($conf->global->MARGIN_TYPE);
if ($conf->global->MARGIN_TYPE == "1") { if ($conf->global->MARGIN_TYPE == "1") {
@ -248,20 +266,20 @@ if ($result) {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if ($id > 0) { if ($id > 0) {
print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&amp;id=".$id, '', $sortfield, $sortorder); print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&amp;id=".$id, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $param, '', $sortfield, $sortorder, 'center ');
} else { } else {
print_liste_field_titre("ProductService", $_SERVER["PHP_SELF"], "p.ref", "", "&amp;id=".$id, '', $sortfield, $sortorder); print_liste_field_titre("ProductService", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
} }
print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "product_qty", "", "&amp;id=".$id, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "product_qty", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&amp;id=".$id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", "&amp;id=".$id, '', $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", "", "&amp;id=".$id, '', $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"], "", "", "&amp;id=".$id, '', $sortfield, $sortorder, 'right '); 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"], "", "", "&amp;id=".$id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
} }
print "</tr>\n"; print "</tr>\n";