diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 840bb93a49f..3c35a03f218 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -2197,6 +2197,7 @@ class Facture extends CommonInvoice
else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num));
if ($result < 0) {
$error++;
+ $this->error = $mouvP->error;
}
}
}
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index fca8ac511da..a888e4a7656 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -413,6 +413,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$object->trackid = $trackid;
$object->fk_element = $object->id;
$object->elementtype = $object->element;
+ $object->attachedfiles = $attachedfiles;
// Call of triggers
if (! empty($trigger_name))
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index e799579b181..0632f4d723f 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -242,9 +242,9 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu
{
foreach($feature2 as $subfeature)
{
- if (empty($user->rights->$feature->$subfeature->creer)
- && empty($user->rights->$feature->$subfeature->write)
- && empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; }
+ if (empty($user->rights->$feature->$subfeature->creer)
+ && empty($user->rights->$feature->$subfeature->write)
+ && empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; }
else { $createok=1; break; } // Break to bypass second test if the first is ok
}
}
@@ -306,6 +306,9 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu
else if ($feature == 'ftp')
{
if (! $user->rights->ftp->write) $deleteok=0;
+ }else if ($feature == 'salaries')
+ {
+ if (! $user->rights->salaries->delete) $deleteok=0;
}
else if (! empty($feature2)) // This should be used for future changes
{
diff --git a/htdocs/index.php b/htdocs/index.php
index 8c91b006638..9144fe8610f 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -548,7 +548,7 @@ if (! empty($valid_dashboardlines))
$boxwork.='
| ';
foreach($valid_dashboardlines as $board)
{
- if (empty($boad->nbtodo)) $nbworkboardempty++;
+ if (empty($board->nbtodo)) $nbworkboardempty++;
$textlate = $langs->trans("NActionsLate",$board->nbtodolate);
$textlate.= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')';
diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php
index 4f61aa833bf..f44316ba45d 100644
--- a/htdocs/loan/card.php
+++ b/htdocs/loan/card.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2014-2017 Alexandre Spangaro
* Copyright (C) 2015 Frederic France
* Copyright (C) 2017 Laurent Destailleur
*
@@ -18,9 +18,9 @@
*/
/**
- * \file htdocs/loan/card.php
- * \ingroup loan
- * \brief Loan card
+ * \file htdocs/loan/card.php
+ * \ingroup loan
+ * \brief Loan card
*/
require '../main.inc.php';
@@ -61,129 +61,81 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
- // Classify paid
- if ($action == 'confirm_paid' && $confirm == 'yes')
- {
- $object->fetch($id);
- $result = $object->set_paid($user);
- if ($result > 0)
- {
- setEventMessages($langs->trans('LoanPaid'), null, 'mesgs');
- }
- else
- {
- setEventMessages($loan->error, null, 'errors');
- }
- }
+ // Classify paid
+ if ($action == 'confirm_paid' && $confirm == 'yes')
+ {
+ $object->fetch($id);
+ $result = $object->set_paid($user);
+ if ($result > 0)
+ {
+ setEventMessages($langs->trans('LoanPaid'), null, 'mesgs');
+ }
+ else
+ {
+ setEventMessages($loan->error, null, 'errors');
+ }
+ }
- // Delete loan
- if ($action == 'confirm_delete' && $confirm == 'yes')
- {
- $object->fetch($id);
- $result=$object->delete($user);
- if ($result > 0)
- {
- setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs');
- header("Location: index.php");
- exit;
- }
- else
- {
- setEventMessages($loan->error, null, 'errors');
- }
- }
+ // Delete loan
+ if ($action == 'confirm_delete' && $confirm == 'yes')
+ {
+ $object->fetch($id);
+ $result=$object->delete($user);
+ if ($result > 0)
+ {
+ setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs');
+ header("Location: index.php");
+ exit;
+ }
+ else
+ {
+ setEventMessages($loan->error, null, 'errors');
+ }
+ }
- // Add loan
- if ($action == 'add' && $user->rights->loan->write)
- {
- if (! $cancel)
- {
- $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int'));
- $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int'));
- $capital = price2num(GETPOST('capital'));
- $rate = GETPOST('rate');
+ // Add loan
+ if ($action == 'add' && $user->rights->loan->write)
+ {
+ if (! $cancel)
+ {
+ $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int'));
+ $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int'));
+ $capital = price2num(GETPOST('capital'));
+ $rate = GETPOST('rate');
- if (! $capital)
- {
- $error++; $action = 'create';
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
- }
- if (! $datestart)
- {
- $error++; $action = 'create';
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateStart")), null, 'errors');
- }
- if (! $dateend)
- {
- $error++; $action = 'create';
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors');
- }
- if ($rate == '')
- {
- $error++; $action = 'create';
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Rate")), null, 'errors');
- }
+ if (! $capital)
+ {
+ $error++; $action = 'create';
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
+ }
+ if (! $datestart)
+ {
+ $error++; $action = 'create';
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateStart")), null, 'errors');
+ }
+ if (! $dateend)
+ {
+ $error++; $action = 'create';
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors');
+ }
+ if ($rate == '')
+ {
+ $error++; $action = 'create';
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Rate")), null, 'errors');
+ }
- if (! $error)
- {
- $object->label = GETPOST('label');
- $object->fk_bank = GETPOST('accountid');
- $object->capital = $capital;
- $object->datestart = $datestart;
- $object->dateend = $dateend;
- $object->nbterm = GETPOST('nbterm');
- $object->rate = $rate;
- $object->note_private = GETPOST('note_private');
- $object->note_public = GETPOST('note_public');
- $object->fk_project = GETPOST('projectid','int');
-
- $accountancy_account_capital = GETPOST('accountancy_account_capital');
- $accountancy_account_insurance = GETPOST('accountancy_account_insurance');
- $accountancy_account_interest = GETPOST('accountancy_account_interest');
-
- if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; }
- if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; }
- if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; }
-
- $id=$object->create($user);
- if ($id <= 0)
- {
- $error++;
- setEventMessages($object->error, $object->errors, 'errors');
- $action = 'create';
- }
- }
- }
- else
- {
- header("Location: index.php");
- exit();
- }
- }
-
- // Update record
- else if ($action == 'update' && $user->rights->loan->write)
- {
- if (! $cancel)
- {
- $result = $object->fetch($id);
-
- $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int'));
- $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int'));
- $capital = price2num(GETPOST('capital'));
-
- if (! $capital)
- {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
- $action = 'edit';
- }
- else
- {
- $object->datestart = $datestart;
- $object->dateend = $dateend;
- $object->capital = $capital;
- $object->nbterm = GETPOST("nbterm");
- $object->rate = GETPOST("rate");
+ if (! $error)
+ {
+ $object->label = GETPOST('label');
+ $object->fk_bank = GETPOST('accountid');
+ $object->capital = $capital;
+ $object->datestart = $datestart;
+ $object->dateend = $dateend;
+ $object->nbterm = GETPOST('nbterm');
+ $object->rate = $rate;
+ $object->note_private = GETPOST('note_private');
+ $object->note_public = GETPOST('note_public');
+ $object->fk_project = GETPOST('projectid','int');
$accountancy_account_capital = GETPOST('accountancy_account_capital');
$accountancy_account_insurance = GETPOST('accountancy_account_insurance');
@@ -192,43 +144,91 @@ if (empty($reshook))
if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; }
if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; }
if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; }
- }
- $result = $object->update($user);
+ $id=$object->create($user);
+ if ($id <= 0)
+ {
+ $error++;
+ setEventMessages($object->error, $object->errors, 'errors');
+ $action = 'create';
+ }
+ }
+ }
+ else
+ {
+ header("Location: index.php");
+ exit();
+ }
+ }
- if ($result > 0)
- {
- header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
- exit;
- }
- else
- {
- setEventMessages($object->error, $object->errors, 'errors');
- }
- }
- else
- {
- header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
- exit;
- }
- }
+ // Update record
+ else if ($action == 'update' && $user->rights->loan->write)
+ {
+ if (! $cancel)
+ {
+ $result = $object->fetch($id);
+
+ $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int'));
+ $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int'));
+ $capital = price2num(GETPOST('capital'));
+
+ if (! $capital)
+ {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
+ $action = 'edit';
+ }
+ else
+ {
+ $object->datestart = $datestart;
+ $object->dateend = $dateend;
+ $object->capital = $capital;
+ $object->nbterm = GETPOST("nbterm");
+ $object->rate = GETPOST("rate");
+
+ $accountancy_account_capital = GETPOST('accountancy_account_capital');
+ $accountancy_account_insurance = GETPOST('accountancy_account_insurance');
+ $accountancy_account_interest = GETPOST('accountancy_account_interest');
+
+ if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; }
+ if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; }
+ if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; }
+ }
+
+ $result = $object->update($user);
+
+ if ($result > 0)
+ {
+ header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
+ exit;
+ }
+ else
+ {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ }
+ else
+ {
+ header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
+ exit;
+ }
+ }
// Link to a project
if ($action == 'classin' && $user->rights->loan->write)
{
- $object->fetch($id);
- $result = $object->setProject($projectid);
+ $object->fetch($id);
+ $result = $object->setProject($projectid);
if ($result < 0)
- setEventMessages($object->error, $object->errors, 'errors');
+ setEventMessages($object->error, $object->errors, 'errors');
}
- if ($action == 'setlabel' && $user->rights->loan->write)
- {
- $object->fetch($id);
- $result = $object->setValueFrom('label', GETPOST('label'), '', '', 'text', '', $user, 'LOAN_MODIFY');
- if ($result < 0)
- setEventMessages($object->error, $object->errors, 'errors');
- }
+ if ($action == 'setlabel' && $user->rights->loan->write)
+ {
+ $object->fetch($id);
+ $result = $object->setValueFrom('label', GETPOST('label'), '', '', 'text', '', $user, 'LOAN_MODIFY');
+ if ($result < 0)
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
}
@@ -249,19 +249,19 @@ llxHeader("",$title,$help_url);
if ($action == 'create')
{
//WYSIWYG Editor
- require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- print load_fiche_titre($langs->trans("NewLoan"), '', 'title_accountancy.png');
+ print load_fiche_titre($langs->trans("NewLoan"), '', 'title_accountancy.png');
- $datec = dol_mktime(12, 0, 0, GETPOST('remonth','int'), GETPOST('reday','int'), GETPOST('reyear','int'));
+ $datec = dol_mktime(12, 0, 0, GETPOST('remonth','int'), GETPOST('reday','int'), GETPOST('reyear','int'));
- print ' |