Merge remote-tracking branch 'upstream/develop' into free_email

This commit is contained in:
Frédéric FRANCE 2020-05-06 22:17:43 +02:00
commit 3fcd9e6949
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
10 changed files with 274 additions and 11 deletions

View File

@ -5,6 +5,7 @@
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013-2017 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
*
* 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
@ -83,6 +84,20 @@ if ($action == 'update')
}
}
$report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha');
if (!empty($report_include_varpay))
if ($report_include_varpay == 'yes')
if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) $error++;
if ($report_include_varpay == 'no')
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) $error++;
$report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha');
if (!empty($report_include_loan))
if ($report_include_loan == 'yes')
if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) $error++;
if ($report_include_loan == 'no')
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) $error++;
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@ -158,6 +173,20 @@ foreach ($list as $key)
print '</td></tr>';
}
// Option to include various payment in results
print '<tr class="oddeven value">'."\n";
print '<td><label for="ACCOUNTING_REPORTS_INCLUDE_VARPAY">'.$langs->trans('IncludeVarpaysInResults').'</label></td>'."\n";
print '<td class="center">'."\n";
print $form->selectyesno('ACCOUNTING_REPORTS_INCLUDE_VARPAY', (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY)));
print '</td></tr>';
// Option to include loan in results
print '<tr class="oddeven value">'."\n";
print '<td><label for="ACCOUNTING_REPORTS_INCLUDE_LOAN">'.$langs->trans('IncludeLoansInResults').'</label></td>'."\n";
print '<td class="center">'."\n";
print $form->selectyesno('ACCOUNTING_REPORTS_INCLUDE_LOAN', (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_LOAN)));
print '</td></tr>';
print "</table>\n";
print '<br><br><div style="text-align:center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';

View File

@ -8,6 +8,7 @@
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
*
* 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
@ -38,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
// Load translation files required by the page
$langs->loadLangs(array('compta', 'bills', 'donation', 'salaries', 'accountancy'));
$langs->loadLangs(array('compta', 'bills', 'donation', 'salaries', 'accountancy', 'loan'));
$date_startmonth = GETPOST('date_startmonth', 'int');
$date_startday = GETPOST('date_startday', 'int');
@ -953,6 +954,115 @@ else
print '</tr>';
}
/*
* Various Payments
*/
if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && !empty($conf->banque->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES"))
{
$subtotal_ht = 0;
$subtotal_ttc = 0;
print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("VariousPayment").'</td></tr>';
// Debit
$sql = "SELECT SUM(p.amount) AS amount FROM ".MAIN_DB_PREFIX."payment_various as p";
$sql .= ' WHERE 1 = 1';
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql .= ' GROUP BY p.sens';
$sql .= ' ORDER BY p.sens';
dol_syslog('get various payments', LOG_DEBUG);
$result = $db->query($sql);
if ($result)
{
// Debit
$obj = $db->fetch_object($result);
if (isset($obj->amount))
{
$subtotal_ht += -$obj->amount;
$subtotal_ttc += -$obj->amount;
}
print '<tr class="oddeven"><td>&nbsp;</td>';
print "<td>".$langs->trans("Debit")."</td>\n";
if ($modecompta == 'CREANCES-DETTES') print '<td class="right">'.price(-$obj->amount).'</td>';
print '<td class="right">'.price(-$obj->amount)."</td>\n";
print "</tr>\n";
// Credit
$obj = $db->fetch_object($result);
if (isset($obj->amount))
{
$subtotal_ht += $obj->amount;
$subtotal_ttc += $obj->amount;
}
print '<tr class="oddeven"><td>&nbsp;</td>';
print "<td>".$langs->trans("Credit")."</td>\n";
if ($modecompta == 'CREANCES-DETTES') print '<td class="right">'.price($obj->amount).'</td>';
print '<td class="right">'.price($obj->amount)."</td>\n";
print "</tr>\n";
// Total
$total_ht += $subtotal_ht;
$total_ttc += $subtotal_ttc;
print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" class="right">'.price($subtotal_ht).'</td>';
print '<td colspan="3" class="right">'.price($subtotal_ttc).'</td>';
print '</tr>';
}
else dol_print_error($db);
}
/*
* Payement Loan
*/
if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_LOAN) && !empty($conf->loan->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES"))
{
$subtotal_ht = 0;
$subtotal_ttc = 0;
print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("PaymentLoan").'</td></tr>';
$sql = 'SELECT l.rowid as id, l.label AS label, SUM(p.amount_capital + p.amount_insurance + p.amount_interest) as amount FROM '.MAIN_DB_PREFIX.'payment_loan as p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'loan AS l ON l.rowid = p.fk_loan';
$sql .= ' WHERE 1 = 1';
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql .= ' GROUP BY p.fk_loan';
$sql .= ' ORDER BY p.fk_loan';
dol_syslog('get loan payments', LOG_DEBUG);
$result = $db->query($sql);
if ($result)
{
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
$loan_static = new Loan($db);
while ($obj = $db->fetch_object($result))
{
$loan_static->id = $obj->id;
$loan_static->ref = $obj->id;
$loan_static->label = $obj->label;
print '<tr class="oddeven"><td>&nbsp;</td>';
print "<td>".$loan_static->getNomUrl(1).' - '.$obj->label."</td>\n";
if ($modecompta == 'CREANCES-DETTES') print '<td class="right">'.price(-$obj->amount).'</td>';
print '<td class="right">'.price(-$obj->amount)."</td>\n";
print "</tr>\n";
$subtotal_ht -= $obj->amount;
$subtotal_ttc -= $obj->amount;
}
$total_ht += $subtotal_ht;
$total_ttc += $subtotal_ttc;
print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" class="right">'.price($subtotal_ht).'</td>';
print '<td colspan="3" class="right">'.price($subtotal_ttc).'</td>';
print '</tr>';
}
else dol_print_error($db);
}
/*
* VAT

View File

@ -6,6 +6,7 @@
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
*
* 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
@ -794,6 +795,113 @@ elseif ($modecompta == 'BOOKKEEPING') {
// Nothing from this table
}
/*
* Various Payments
*/
if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && !empty($conf->banque->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES"))
{
// decaiss
$sql = "SELECT date_format(p.datep, '%Y-%m') AS dm, SUM(p.amount) AS amount FROM ".MAIN_DB_PREFIX."payment_various as p";
$sql .= ' WHERE p.sens = 0';
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql .= ' GROUP BY dm';
dol_syslog("get various payments");
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($result);
if (!isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm] = 0;
if (isset($obj->amount)) $decaiss_ttc[$obj->dm] += $obj->amount;
$i++;
}
}
}
else
{
dol_print_error($db);
}
// encaiss
$sql = "SELECT date_format(p.datep, '%Y-%m') AS dm, SUM(p.amount) AS amount FROM ".MAIN_DB_PREFIX."payment_various AS p";
$sql .= ' WHERE p.sens = 1';
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql .= ' GROUP BY dm';
dol_syslog("get various payments");
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($result);
if (!isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm] = 0;
if (isset($obj->amount)) $encaiss_ttc[$obj->dm] += $obj->amount;
$i++;
}
}
}
else
{
dol_print_error($db);
}
}
// Useless with BOOKKEEPING
//elseif ($modecompta == 'BOOKKEEPING') {
//}
/*
* Payement Loan
*/
if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_LOAN) && !empty($conf->loan->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES"))
{
$sql = "SELECT date_format(p.datep, '%Y-%m') AS dm, SUM(p.amount_capital + p.amount_insurance + p.amount_interest) AS amount FROM ".MAIN_DB_PREFIX."payment_loan AS p";
$sql .= ' WHERE 1 = 1';
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql .= ' GROUP BY dm';
dol_syslog("get loan payments");
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($result);
if (!isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm] = 0;
if (isset($obj->amount)) $decaiss_ttc[$obj->dm] += $obj->amount;
$i++;
}
}
}
else
{
dol_print_error($db);
}
}
// Useless with BOOKKEEPING
//elseif ($modecompta == 'BOOKKEEPING') {
//}
/*

View File

@ -40,6 +40,7 @@ if (!empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax = 1;
$php_self = $_SERVER['PHP_SELF'];
$php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '';
$php_self = str_replace('action=validatenewpassword', '', $php_self);
$titleofpage = $langs->trans('SendNewPassword');

View File

@ -262,3 +262,5 @@ RulesPurchaseTurnoverIn=- It includes all the effective payments of invoices don
RulesPurchaseTurnoverTotalPurchaseJournal=It includes all debit lines from the purchase journal.
ReportPurchaseTurnover=Purchase turnover invoiced
ReportPurchaseTurnoverCollected=Purchase turnover collected
IncludeVarpaysInResults = Include various payments in reports
IncludeLoansInResults = Include loans in reports

View File

@ -78,6 +78,7 @@ UserWillBeExternalUser=Created user will be an external user (because linked to
IdPhoneCaller=Id phone caller
NewUserCreated=User %s created
NewUserPassword=Password change for %s
NewPasswordValidated=Your new password have been validated and must be used now to login.
EventUserModified=User %s modified
UserDisabled=User %s disabled
UserEnabled=User %s activated

View File

@ -262,3 +262,5 @@ RulesPurchaseTurnoverIn=- It includes all the effective payments of invoices don
RulesPurchaseTurnoverTotalPurchaseJournal=It includes all debit lines from the purchase journal.
ReportPurchaseTurnover=Purchase turnover invoiced
ReportPurchaseTurnoverCollected=Purchase turnover collected
IncludeVarpaysInResults = Inclure les payments divers dans les rapports
IncludeLoansInResults = Inclure les emprunts dans les rapports

View File

@ -68,7 +68,7 @@ print load_fiche_titre($langs->trans("StockSetup"), $linkback, 'title_setup');
$head = stock_admin_prepare_head();
dol_fiche_head($head, 'attributes', $langs->trans("Warehouses"), -1, 'stock');
dol_fiche_head($head, 'attributes', $langs->trans("StockSetup"), -1, 'stock');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';

View File

@ -1838,7 +1838,7 @@ class User extends CommonObject
/**
* Change password of a user
*
* @param User $user Object user of user making change
* @param User $user Object user of user requesting the change (not the user for who we change the password). May be unknown.
* @param string $password New password in clear text (to generate if not provided)
* @param int $changelater 1=Change password only after clicking on confirm email
* @param int $notrigger 1=Does not launch triggers
@ -1972,7 +1972,7 @@ class User extends CommonObject
/**
* Send new password by email
*
* @param User $user Object user that send email
* @param User $user Object user that send the email (not the user we send too)
* @param string $password New password
* @param int $changelater 0=Send clear passwod into email, 1=Change password only after clicking on confirm email. @todo Add method 2 = Send link to reset password
* @return int < 0 si erreur, > 0 si ok
@ -1997,8 +1997,9 @@ class User extends CommonObject
{ // If user has defined its own language (rare because in most cases, auto is used)
$outputlangs->getDefaultLang($this->conf->MAIN_LANG_DEFAULT);
}
if ($user->conf->MAIN_LANG_DEFAULT) {
$outputlangs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT);
if ($this->conf->MAIN_LANG_DEFAULT) {
$outputlangs->setDefaultLang($this->conf->MAIN_LANG_DEFAULT);
}
else
{ // If user has not defined its own language, we used current language
@ -2028,7 +2029,7 @@ class User extends CommonObject
$mesg .= $outputlangs->transnoentitiesnoconv("ClickHereToGoTo", $appli).': '.$url."\n\n";
$mesg .= "--\n";
$mesg .= $user->getFullName($outputlangs); // Username that make then sending
$mesg .= $user->getFullName($outputlangs); // Username that send the email (not the user for who we want to reset password)
dol_syslog(get_class($this)."::send_password changelater is off, url=".$url);
}
@ -2048,6 +2049,8 @@ class User extends CommonObject
dol_syslog(get_class($this)."::send_password changelater is on, url=".$url);
}
$trackid = 'use'.$this->id;
$mailfile = new CMailFile(
$subject,
$this->email,
@ -2059,7 +2062,10 @@ class User extends CommonObject
'',
'',
0,
$msgishtml
$msgishtml,
'',
'',
$trackid
);
if ($mailfile->sendfile())

View File

@ -77,7 +77,11 @@ if ($action == 'validatenewpassword' && $username && $passwordhash)
{
if (dol_verifyHash($edituser->pass_temp, $passwordhash))
{
$newpassword = $edituser->setPassword($user, $edituser->pass_temp, 0);
// Clear session
unset($_SESSION['dol_login']);
$_SESSION['dol_loginmesg'] = $langs->trans('NewPasswordValidated'); // Save message for the session page
$newpassword = $edituser->setPassword($user, $edituser->pass_temp, 0);
dol_syslog("passwordforgotten.php new password for user->id=".$edituser->id." validated in database");
header("Location: ".DOL_URL_ROOT.'/');
exit;
@ -131,9 +135,9 @@ if ($action == 'buildnewpassword' && $username)
else
{
// Success
if ($edituser->send_password($edituser, $newpassword, 1) > 0)
if ($edituser->send_password($user, $newpassword, 1) > 0)
{
$message = '<div class="ok">'.$langs->trans("PasswordChangeRequestSent", $edituser->login, dolObfuscateEmail($edituser->email)).'</div>';
$message = '<div class="ok'.(empty($conf->global->MAIN_LOGIN_BACKGROUND) ? '' : ' backgroundsemitransparent').'">'.$langs->trans("PasswordChangeRequestSent", $edituser->login, dolObfuscateEmail($edituser->email)).'</div>';
$username = '';
}
else