';
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
- $sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
+ $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
+ if ($j > 12) $j-=12;
+ $sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
}
$sql .= " ROUND(SUM(erd.total_ht),2) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
-$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
-$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
-$sql .= " AND er.fk_statut > 0 ";
+$sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'";
+$sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'";
+$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NOT NULL";
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
@@ -269,9 +262,9 @@ $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog('htdocs/accountancy/expensereport/index.php');
$resql = $db->query($sql);
if ($resql) {
- $num = $db->num_rows($resql);
+ $num = $db->num_rows($resql);
- while ( $row = $db->fetch_row($resql)) {
+ while ( $row = $db->fetch_row($resql)) {
print '
';
if ($row[0] == 'tobind')
@@ -280,6 +273,7 @@ if ($resql) {
}
else print length_accountg($row[0]);
print '
';
+
print '
';
if ($row[0] == 'tobind')
{
@@ -303,7 +297,7 @@ print '';
-if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ?
+if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ?
{
print ' ';
print ' ';
@@ -314,20 +308,24 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
print '
';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
$nbcols+=2;
diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php
index acbcc86e07d..1ac38a93c96 100644
--- a/htdocs/compta/tva/index.php
+++ b/htdocs/compta/tva/index.php
@@ -144,8 +144,8 @@ $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0;
$i=0;
for ($m = 1 ; $m < 13 ; $m++ )
{
- $coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m);
- $coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m);
+ $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m);
+ $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m);
$action = "tva";
$object = array(&$coll_listsell, &$coll_listbuy);
diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php
index d4ccbf98804..5a05ef5974f 100644
--- a/htdocs/compta/tva/quadri_detail.php
+++ b/htdocs/compta/tva/quadri_detail.php
@@ -224,8 +224,8 @@ $total = 0;
$i=0;
// Load arrays of datas
-$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell');
-$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy');
+$x_coll = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell');
+$x_paye = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy');
if (! is_array($x_coll) || ! is_array($x_paye))
{
diff --git a/htdocs/compta/tva/quarter_report.php b/htdocs/compta/tva/quarter_report.php
index 4c054923837..dd058c6ebc2 100644
--- a/htdocs/compta/tva/quarter_report.php
+++ b/htdocs/compta/tva/quarter_report.php
@@ -260,8 +260,8 @@ $i=0;
$columns = 6;
// Load arrays of datas
-$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell');
-$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy');
+$x_coll = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell');
+$x_paye = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy');
if (!is_array($x_coll) || !is_array($x_paye)) {
$langs->load("errors");
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index 8a29a268e68..96a9e4987c3 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -384,7 +384,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
if ($mailfile->error)
{
- setEventMessage($mailfile->error, 'errors');
+ setEventMessages($mailfile->error, $mailfile->errors, 'errors');
$action='presend';
}
else
diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
index aaae010c2fe..a79f01352e8 100644
--- a/htdocs/core/class/html.formaccounting.class.php
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -243,7 +243,7 @@ class FormAccounting extends Form
*
* @param string $selectid Preselected id or code of accounting accounts (depends on $select_in)
* @param string $htmlname Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used.
- * @param int $showempty Add an empty field
+ * @param int $showempty 1=Add an empty field, 2=Add an empty field+'None' field
* @param array $event Event options
* @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number
* @param int $select_out Set value returned by select. 0=rowid (default), 1=account_number
@@ -253,7 +253,7 @@ class FormAccounting extends Form
*/
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='')
{
- global $conf;
+ global $conf, $langs;
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
@@ -318,7 +318,12 @@ class FormAccounting extends Form
}
}
- $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
+ if ($showempty == 2)
+ {
+ $options['0'] = $langs->trans("None");
+ }
+
+ $out .= Form::selectarray($htmlname, $options, $selected, ($showempty > 0 ? 1 : 0), 0, 0, '', 0, 0, 0, '', $morecss, 1);
return $out;
}
diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php
index 400ed453004..a0825cf6518 100644
--- a/htdocs/core/lib/tax.lib.php
+++ b/htdocs/core/lib/tax.lib.php
@@ -32,7 +32,7 @@
* Prepare array with list of tabs
*
* @param ChargeSociales $object Object related to tabs
- * @return array Array of tabs to show
+ * @return array Array of tabs to show
*/
function tax_prepare_head(ChargeSociales $object)
{
@@ -184,7 +184,6 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
* Gets Tax to collect for the given year (and given quarter or month)
* The function gets the Tax in split results, as the Tax declaration asks
* to report the amounts for different Tax rates as different lines.
- * This function also accounts recurrent invoices.
*
* @param string $type Tax type, either 'vat', 'localtax1' or 'localtax2'
* @param DoliDB $db Database handler object
@@ -236,7 +235,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
$total_localtax1='total_localtax1';
$total_localtax2='total_localtax2';
-
+
// CAS DES BIENS
// Define sql request
@@ -318,7 +317,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
if ($sql == 'TODO') return -2;
if ($sql != 'TODO')
{
- dol_syslog("Tax.lib.php::vat_by_date", LOG_DEBUG);
+ dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
@@ -414,7 +413,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND (d.product_type = 1"; // Limit to services
$sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
- $sql.= " ORDER BY d.rowid, d.".$fk_facture;
+ $sql.= " ORDER BY d.rowid, d.".$fk_facture;
}
else // Option vat on delivery for goods (payments) and payments for services
{
@@ -458,13 +457,13 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
if (! $sql)
{
- dol_syslog("Tax.lib.php::vat_by_date no accountancy module enabled".$sql,LOG_ERR);
+ dol_syslog("Tax.lib.php::tax_by_date no accountancy module enabled".$sql,LOG_ERR);
return -1; // -1 = Not accountancy module enabled
}
if ($sql == 'TODO') return -2; // -2 = Feature not yet available
if ($sql != 'TODO')
{
- dol_syslog("Tax.lib.php::vat_by_date", LOG_DEBUG);
+ dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
@@ -550,19 +549,19 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
}
if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")";
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
- $sql.= " AND (d.product_type = -1";
+ $sql.= " AND (d.product_type = -1";
$sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service
$sql.= " ORDER BY e.rowid";
if (! $sql)
{
- dol_syslog("Tax.lib.php::vat_by_date no accountancy module enabled".$sql,LOG_ERR);
+ dol_syslog("Tax.lib.php::tax_by_date no accountancy module enabled".$sql,LOG_ERR);
return -1; // -1 = Not accountancy module enabled
}
if ($sql == 'TODO') return -2; // -2 = Feature not yet available
if ($sql != 'TODO')
{
- dol_syslog("Tax.lib.php::vat_by_date", LOG_DEBUG);
+ dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
@@ -624,24 +623,3 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
return $list;
}
-/**
- * Gets VAT to collect for the given year (and given quarter or month)
- * The function gets the VAT in split results, as the VAT declaration asks
- * to report the amounts for different VAT rates as different lines.
- * This function also accounts recurrent invoices.
- *
- * @param DoliDB $db Database handler object
- * @param int $y Year
- * @param int $q Quarter
- * @param string $date_start Start date
- * @param string $date_end End date
- * @param int $modetax 0 or 1 (option vat on debit)
- * @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices)
- * @param int $m Month
- * @return array List of quarters with vat
- */
-function vat_by_date ($db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0)
-{
- return tax_by_date('vat', $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m);
-}
-
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index 01f7ee0c838..82c3461848b 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -1126,11 +1126,17 @@ if (empty($reshook))
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PriceUTTC")), null, 'errors');
}
+ // Warning if date out of range
+ if ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1)))
+ {
+ $langs->load("errors");
+ setEventMessages($langs->trans("WarningDateOfLineMustBeInExpenseReportRange"), null, 'warnings');
+ }
// S'il y'a eu au moins une erreur
if (! $error)
{
- $type = 0; // TODO What if service ?
+ $type = 0; // TODO What if service ? We should take the type product/service from the type of expense report llx_c_type_fees
// Insert line
$result = $object->addline($qty,$value_unit,$fk_c_type_fees,$vatrate,$date,$comments,$fk_projet,$fk_c_exp_tax_cat,$type);
@@ -1241,6 +1247,12 @@ if (empty($reshook))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Vat")), null, 'errors');
$action='';
}
+ // Warning if date out of range
+ if ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1)))
+ {
+ $langs->load("errors");
+ setEventMessages($langs->trans("WarningDateOfLineMustBeInExpenseReportRange"), null, 'warnings');
+ }
if (! $error)
{
@@ -1270,8 +1282,8 @@ if (empty($reshook))
$result = $object->recalculer($id);
- header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
- exit;
+ //header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
+ //exit;
}
else
{
diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang
index f87a30ecfb2..302c5376582 100644
--- a/htdocs/langs/en_US/errors.lang
+++ b/htdocs/langs/en_US/errors.lang
@@ -228,4 +228,5 @@ WarningTooManyDataPleaseUseMoreFilters=Too many data (more than %s lines). Pleas
WarningSomeLinesWithNullHourlyRate=Some times were recorded by some users while their hourly rate was not defined. A value of 0 %s per hour was used but this may result in wrong valuation of time spent.
WarningYourLoginWasModifiedPleaseLogin=Your login was modified. For security purpose you will have to login with your new login before next action.
WarningAnEntryAlreadyExistForTransKey=An entry already exists for the translation key for this language
-WarningNumberOfRecipientIsRestrictedInMassAction=Warning, number of different recipient is limited to %s when using the bulk actions on lists
\ No newline at end of file
+WarningNumberOfRecipientIsRestrictedInMassAction=Warning, number of different recipient is limited to %s when using the bulk actions on lists
+WarningDateOfLineMustBeInExpenseReportRange=Warning, the date of line is not in the range of the expense report
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang
index a44463d0d1b..9412cb5ebee 100644
--- a/htdocs/langs/fr_FR/holiday.lang
+++ b/htdocs/langs/fr_FR/holiday.lang
@@ -81,6 +81,10 @@ EmployeeFirstname=Prénom du salarié
TypeWasDisabledOrRemoved=Le type de congés (id %s) a été désactivé ou supprimé
LastHolidays=Les %s dernières demandes de congés
AllHolidays=Toutes les demandes de congés
+LEAVE_PAID=Congé payés
+LEAVE_SICK=Arrêt maladie
+LEAVE_OTHER=Autre congé
+LEAVE_PAID_FR=congé payés
## Configuration du Module ##
LastUpdateCP=Dernière mise à jour automatique de l'allocation des congés