diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php
index 516af988334..7eae1eb6536 100644
--- a/htdocs/accountancy/admin/index.php
+++ b/htdocs/accountancy/admin/index.php
@@ -48,6 +48,7 @@ $action = GETPOST('action', 'aZ09');
$list = array(
'ACCOUNTING_LENGTH_GACCOUNT',
'ACCOUNTING_LENGTH_AACCOUNT',
+// 'ACCOUNTING_LIMIT_LIST_VENTILATION' // there is already a global parameter to define the nb of records in lists, we must use it in priority. Having one parameter for nb of record for each page is deprecated.
// 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
// 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
);
diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index ebd768de1dc..830896776b5 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -85,7 +85,7 @@ $search_mvt_label = GETPOST('search_mvt_label', 'alpha');
$search_direction = GETPOST('search_direction', 'alpha');
$search_debit = GETPOST('search_debit', 'alpha');
$search_credit = GETPOST('search_credit', 'alpha');
-$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
+$search_ledger_code = GETPOST('search_ledger_code', 'array');
$search_lettering_code = GETPOST('search_lettering_code', 'alpha');
$search_not_reconciled = GETPOST('search_reconciled_option', 'alpha');
@@ -192,7 +192,7 @@ if (empty($reshook))
$search_accountancy_aux_code_end = '';
$search_mvt_label = '';
$search_direction = '';
- $search_ledger_code = '';
+ $search_ledger_code = array();
$search_date_start = '';
$search_date_end = '';
$search_date_creation_start = '';
@@ -267,7 +267,9 @@ if (empty($reshook))
}
if (!empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code;
- $param .= '&search_ledger_code='.urlencode($search_ledger_code);
+ foreach ($search_ledger_code as $code) {
+ $param .= '&search_ledger_code[]='.urlencode($code);
+ }
}
if (!empty($search_mvt_num)) {
$filter['t.piece_num'] = $search_mvt_num;
@@ -447,6 +449,8 @@ if (count($filter) > 0) {
$sqlwhere[] = natural_search($key, $value, 1, 1);
} elseif ($key == 't.reconciled_option') {
$sqlwhere[] = 't.lettering_code IS NULL';
+ } elseif ($key == 't.code_journal' && !empty($value)) {
+ $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1);
} else {
$sqlwhere[] = natural_search($key, $value, 0, 1);
}
@@ -467,7 +471,7 @@ if (!empty($sortfield)) {
// Export into a file with format defined into setup (FEC, CSV, ...)
// Must be after definition of $sql
-if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
+if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->export) {
// TODO Replace the fetchAll + ->export later that consume too much memory on large export with the query($sql) and loop on each line to export them.
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT);
@@ -495,6 +499,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " SET date_export = '".$db->idate($now)."'";
+ $sql .= " , date_validated = '".$db->idate($now)."'";
$sql .= " WHERE rowid = ".$movement->id;
dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG);
@@ -566,7 +571,25 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
llxHeader('', $title_page);
+if ($action == 'export_file') {
+ $form_question = array();
+ $form_question['notifiedexportdate'] = array(
+ 'name' => 'notifiedexportdate',
+ 'type' => 'checkbox',
+ 'label' => $langs->trans('NotifiedExportDate'),
+ 'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) ? 'false' : 'true'),
+ );
+ $form_question['notifiedvalidationdate'] = array(
+ 'name' => 'notifiedvalidationdate',
+ 'type' => 'checkbox', // We don't use select here, the journal_array is already a select html component
+ 'label' => $langs->trans('NotifiedValidationDate'),
+ 'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE) ? 'false' : 'true'),
+ );
+
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 300);
+ print $formconfirm;
+}
if ($action == 'delmouv') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num').$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
print $formconfirm;
@@ -761,7 +784,9 @@ if (!empty($arrayfields['t.lettering_code']['checked']))
// Code journal
if (!empty($arrayfields['t.code_journal']['checked']))
{
- print '
| ';
+ print '';
+ print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1);
+ print ' | ';
}
// Fields from hook
diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php
index 1bcc4129821..201e3cac95a 100644
--- a/htdocs/accountancy/class/accountancyexport.class.php
+++ b/htdocs/accountancy/class/accountancyexport.class.php
@@ -840,17 +840,19 @@ class AccountancyExport
print "DateLet".$separator;
print "ValidDate".$separator;
print "Montantdevise".$separator;
- print "Idevise";
+ print "Idevise".$separator;
+ print "DateLimitReglmt";
print $end_line;
foreach ($objectLines as $line) {
- if ($line->debit == 0 && $line->credit == 0) {
+ if ($line->debit == 0 && $line->credit == 0) {
unset($array[$line]);
} else {
- $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
- $date_document = dol_print_date($line->doc_date, '%Y%m%d');
- $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
- $date_validation = dol_print_date($line->date_validated, '%Y%m%d');
+ $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
+ $date_document = dol_print_date($line->doc_date, '%Y%m%d');
+ $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
+ $date_validation = dol_print_date($line->date_validated, '%Y%m%d');
+ $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
// FEC:JournalCode
print $line->code_journal.$separator;
@@ -865,13 +867,13 @@ class AccountancyExport
print $date_document.$separator;
// FEC:CompteNum
- print $line->numero_compte.$separator;
+ print length_accountg($line->numero_compte).$separator;
// FEC:CompteLib
print dol_string_unaccent($line->label_compte).$separator;
// FEC:CompAuxNum
- print $line->subledger_account.$separator;
+ print length_accounta($line->subledger_account).$separator;
// FEC:CompAuxLib
print dol_string_unaccent($line->subledger_label).$separator;
@@ -880,7 +882,7 @@ class AccountancyExport
print $line->doc_ref.$separator;
// FEC:PieceDate
- print dol_string_unaccent($date_creation).$separator;
+ print $date_creation.$separator;
// FEC:EcritureLib
print dol_string_unaccent($line->label_operation).$separator;
@@ -904,7 +906,10 @@ class AccountancyExport
print $line->multicurrency_amount.$separator;
// FEC:Idevise
- print $line->multicurrency_code;
+ print $line->multicurrency_code.$separator;
+
+ // FEC_suppl:DateLimitReglmt
+ print $date_limit_payment;
print $end_line;
}
@@ -939,7 +944,8 @@ class AccountancyExport
print "DateLet".$separator;
print "ValidDate".$separator;
print "Montantdevise".$separator;
- print "Idevise";
+ print "Idevise".$separator;
+ print "DateLimitReglmt";
print $end_line;
foreach ($objectLines as $line) {
@@ -950,6 +956,7 @@ class AccountancyExport
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
$date_validation = dol_print_date($line->date_validated, '%Y%m%d');
+ $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
// FEC:JournalCode
print $line->code_journal . $separator;
@@ -964,13 +971,13 @@ class AccountancyExport
print $date_creation . $separator;
// FEC:CompteNum
- print $line->numero_compte . $separator;
+ print length_accountg($line->numero_compte) . $separator;
// FEC:CompteLib
print dol_string_unaccent($line->label_compte) . $separator;
// FEC:CompAuxNum
- print $line->subledger_account . $separator;
+ print length_accounta($line->subledger_account) . $separator;
// FEC:CompAuxLib
print dol_string_unaccent($line->subledger_label) . $separator;
@@ -1003,7 +1010,10 @@ class AccountancyExport
print $line->multicurrency_amount . $separator;
// FEC:Idevise
- print $line->multicurrency_code;
+ print $line->multicurrency_code . $separator;
+
+ // FEC_suppl:DateLimitReglmt
+ print $date_limit_payment;
print $end_line;
}
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index d06f8a2ce31..6d9cabc6789 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -8,7 +8,7 @@
* Copyright (C) 2011 Remy Younes
* Copyright (C) 2012-2015 Marcos García
* Copyright (C) 2012 Christophe Battarel
- * Copyright (C) 2011-2019 Alexandre Spangaro
+ * Copyright (C) 2011-2020 Alexandre Spangaro
* Copyright (C) 2015 Ferran Marcet
* Copyright (C) 2016 Raphaël Doursenaud
* Copyright (C) 2019-2020 Frédéric France
@@ -205,7 +205,7 @@ $tabsql[17] = "SELECT id as rowid, code, label, accountancy_code, active FR
$tabsql[18] = "SELECT rowid as rowid, code, libelle, tracking, active FROM ".MAIN_DB_PREFIX."c_shipment_mode";
$tabsql[19] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif";
$tabsql[20] = "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method";
-$tabsql[21] = "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c";
+$tabsql[21] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.position FROM ".MAIN_DB_PREFIX."c_availability AS c";
$tabsql[22] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
$tabsql[23] = "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
$tabsql[24] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
@@ -250,7 +250,7 @@ $tabsqlsort[17] = "code ASC";
$tabsqlsort[18] = "code ASC, libelle ASC";
$tabsqlsort[19] = "id ASC";
$tabsqlsort[20] = "code ASC, libelle ASC";
-$tabsqlsort[21] = "code ASC, label ASC";
+$tabsqlsort[21] = "code ASC, label ASC, position ASC";
$tabsqlsort[22] = "code ASC, label ASC";
$tabsqlsort[23] = "country ASC, taux ASC";
$tabsqlsort[24] = "code ASC, label ASC";
@@ -295,7 +295,7 @@ $tabfield[17] = "code,label,accountancy_code";
$tabfield[18] = "code,libelle,tracking";
$tabfield[19] = "code,libelle";
$tabfield[20] = "code,libelle";
-$tabfield[21] = "code,label";
+$tabfield[21] = "code,label,position";
$tabfield[22] = "code,label";
$tabfield[23] = "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfield[24] = "code,label";
@@ -340,7 +340,7 @@ $tabfieldvalue[17] = "code,label,accountancy_code";
$tabfieldvalue[18] = "code,libelle,tracking";
$tabfieldvalue[19] = "code,libelle";
$tabfieldvalue[20] = "code,libelle";
-$tabfieldvalue[21] = "code,label";
+$tabfieldvalue[21] = "code,label,position";
$tabfieldvalue[22] = "code,label";
$tabfieldvalue[23] = "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldvalue[24] = "code,label";
@@ -385,7 +385,7 @@ $tabfieldinsert[17] = "code,label,accountancy_code";
$tabfieldinsert[18] = "code,libelle,tracking";
$tabfieldinsert[19] = "code,libelle";
$tabfieldinsert[20] = "code,libelle";
-$tabfieldinsert[21] = "code,label";
+$tabfieldinsert[21] = "code,label,position";
$tabfieldinsert[22] = "code,label";
$tabfieldinsert[23] = "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldinsert[24] = "code,label";
@@ -523,7 +523,7 @@ $tabhelp[17] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[18] = array('code'=>$langs->trans("EnterAnyCode"), 'tracking'=>$langs->trans("UrlTrackingDesc"));
$tabhelp[19] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[20] = array('code'=>$langs->trans("EnterAnyCode"));
-$tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode"));
+$tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[23] = array('revenuestamp_type'=>'FixedOrPercent');
$tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode"));
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index c61bfdf6819..a1bde7e4f3d 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -1584,6 +1584,8 @@ if ($resql)
{
print ''.price($marginInfo['total_margin']).' | ';
if (!$i) $totalarray['nbfield']++;
+ if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
+ $totalarray['val']['total_margin'] += $marginInfo['total_margin'];
}
// Total margin rate
if (!empty($arrayfields['total_margin_rate']['checked']))
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 492a4899376..48b8d827ee3 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -15,7 +15,7 @@
* Copyright (C) 2012-2016 Marcos García
* Copyright (C) 2012 Cedric Salvador
* Copyright (C) 2012-2015 Raphaël Doursenaud
- * Copyright (C) 2014 Alexandre Spangaro
+ * Copyright (C) 2014-2020 Alexandre Spangaro
* Copyright (C) 2018 Ferran Marcet
* Copyright (C) 2018-2019 Frédéric France
* Copyright (C) 2018 Nicolas ZABOURI
@@ -3291,7 +3291,7 @@ class Form
$langs->load('propal');
- $sql = "SELECT rowid, code, label";
+ $sql = "SELECT rowid, code, label, position";
$sql .= " FROM ".MAIN_DB_PREFIX.'c_availability';
$sql .= " WHERE active > 0";
@@ -3308,10 +3308,11 @@ class Form
$label = ($langs->trans("AvailabilityType".$obj->code) != ("AvailabilityType".$obj->code) ? $langs->trans("AvailabilityType".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
$this->cache_availability[$obj->rowid]['code'] = $obj->code;
$this->cache_availability[$obj->rowid]['label'] = $label;
+ $this->cache_availability[$obj->rowid]['position'] = $obj->position;
$i++;
}
- $this->cache_availability = dol_sort_array($this->cache_availability, 'label', 'asc', 0, 0, 1);
+ $this->cache_availability = dol_sort_array($this->cache_availability, 'position', 'asc', 0, 0, 1);
return $num;
} else {
diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
index d6f7b269da1..512e38072d0 100644
--- a/htdocs/core/class/html.formaccounting.class.php
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -59,7 +59,7 @@ class FormAccounting extends Form
/**
* Return list of journals with label by nature
*
- * @param string $selectid Preselected pcg_type
+ * @param string $selectid Preselected journal code
* @param string $htmlname Name of field in html form
* @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
* @param int $showempty Add an empty field
@@ -136,6 +136,86 @@ class FormAccounting extends Form
return $out;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Return list of journals with label by nature
+ *
+ * @param array $selectedIds Preselected journal code array
+ * @param string $htmlname Name of field in html form
+ * @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
+ * @param int $showempty Add an empty field
+ * @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code
+ * @param int $select_out Set value returned by select. 0=rowid (default), 1=code
+ * @param string $morecss More css non HTML object
+ * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
+ * @param int $disabledajaxcombo Disable ajax combo box.
+ * @return string String with HTML select
+ */
+ public function multi_select_journal($selectedIds = array(), $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = '', $usecache = '', $disabledajaxcombo = 0)
+ {
+ // phpcs:enable
+ global $conf, $langs;
+
+ $out = '';
+
+ $options = array();
+ if ($usecache && !empty($this->options_cache[$usecache]))
+ {
+ $options = $this->options_cache[$usecache];
+ $selected = $selectedIds;
+ } else {
+ $sql = "SELECT rowid, code, label, nature, entity, active";
+ $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
+ $sql .= " WHERE active = 1";
+ $sql .= " AND entity = ".$conf->entity;
+ if ($nature && is_numeric($nature)) $sql .= " AND nature = ".$nature;
+ $sql .= " ORDER BY code";
+
+ dol_syslog(get_class($this)."::multi_select_journal", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+
+ if (!$resql) {
+ $this->error = "Error ".$this->db->lasterror();
+ dol_syslog(get_class($this)."::multi_select_journal ".$this->error, LOG_ERR);
+ return -1;
+ }
+
+ $selected = array();
+ $langs->load('accountancy');
+ while ($obj = $this->db->fetch_object($resql))
+ {
+ $label = $langs->trans($obj->label);
+
+ $select_value_in = $obj->rowid;
+ $select_value_out = $obj->rowid;
+
+ // Try to guess if we have found default value
+ if ($select_in == 1) {
+ $select_value_in = $obj->code;
+ }
+ if ($select_out == 1) {
+ $select_value_out = $obj->code;
+ }
+ // Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid
+ if (!empty($selectedIds) && in_array($select_value_in, $selectedIds)) {
+ //var_dump("Found ".$selectid." ".$select_value_in);
+ $selected[] = $select_value_out;
+ }
+ $options[$select_value_out] = $label;
+ }
+ $this->db->free($resql);
+
+ if ($usecache)
+ {
+ $this->options_cache[$usecache] = $options;
+ }
+ }
+
+ $out .= Form::multiselectarray($htmlname, $options, $selected, $showempty, 0, $morecss, 0, 0, 0, 'code_journal', '', ($disabledajaxcombo ? 0 : 1));
+
+ return $out;
+ }
+
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of accounting category.
diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php
index b0c58572955..08bab0b4c76 100644
--- a/htdocs/fourn/facture/list.php
+++ b/htdocs/fourn/facture/list.php
@@ -359,6 +359,103 @@ if (empty($reshook))
}
+if ($massaction == 'transfer_request')
+{
+ $langs->load("withdrawals");
+
+ if (!$user->rights->paymentbybanktransfer->create)
+ {
+ $error++;
+ setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
+ }
+ else
+ {
+ //Checking error
+ $error = 0;
+
+ $arrayofselected = is_array($toselect) ? $toselect : array();
+ $listofbills = array();
+ foreach ($arrayofselected as $toselectid)
+ {
+ $objecttmp = new FactureFournisseur($db);
+ $result = $objecttmp->fetch($toselectid);
+ if ($result > 0)
+ {
+ $totalpaye = $objecttmp->getSommePaiement();
+ $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
+ $totaldeposits = $objecttmp->getSumDepositsUsed();
+ $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT');
+ if ($objecttmp->paye || $objecttmp->resteapayer == 0) {
+ $error++;
+ setEventMessages($objecttmp->ref.' '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors');
+ } elseif ($objecttmp->resteapayer < 0) {
+ $error++;
+ setEventMessages($objecttmp->ref.' '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors');
+ }
+ if (!($objecttmp->statut > FactureFournisseur::STATUS_DRAFT)) {
+ $error++;
+ setEventMessages($objecttmp->ref.' '.$langs->trans("Draft"), $objecttmp->errors, 'errors');
+ }
+
+ $rsql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
+ $rsql .= " , pfd.date_traite as date_traite";
+ $rsql .= " , pfd.amount";
+ $rsql .= " , u.rowid as user_id, u.lastname, u.firstname, u.login";
+ $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
+ $rsql .= " , ".MAIN_DB_PREFIX."user as u";
+ $rsql .= " WHERE fk_facture_fourn = ".$objecttmp->id;
+ $rsql .= " AND pfd.fk_user_demande = u.rowid";
+ $rsql .= " AND pfd.traite = 0";
+ $rsql .= " ORDER BY pfd.date_demande DESC";
+
+ $result_sql = $db->query($rsql);
+ if ($result_sql)
+ {
+ $numprlv = $db->num_rows($result_sql);
+ }
+
+ if ($numprlv > 0) {
+ $error++;
+ setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
+ }
+ elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'VIR') {
+ $error++;
+ setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors');
+ }
+ else {
+ $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done
+ }
+ }
+ }
+
+ //Massive withdraw request for request with no errors
+ if (!empty($listofbills))
+ {
+ $nbwithdrawrequestok = 0;
+ foreach ($listofbills as $aBill)
+ {
+ $db->begin();
+ $result = $aBill->demande_prelevement($user, $aBill->resteapayer, 'bank-transfer', 'supplier_invoice');
+ if ($result > 0)
+ {
+ $db->commit();
+ $nbwithdrawrequestok++;
+ }
+ else
+ {
+ $db->rollback();
+ setEventMessages($aBill->error, $aBill->errors, 'errors');
+ }
+ }
+ if ($nbwithdrawrequestok > 0)
+ {
+ setEventMessages($langs->trans("BankTransferRequestsDone", $nbwithdrawrequestok), null, 'mesgs');
+ }
+ }
+ }
+}
+
+
/*
* View
*/
@@ -600,6 +697,10 @@ if ($resql)
//'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
);
+ if ($conf->paymentbybanktransfer->enabled) {
+ $langs->load("withdrawals");
+ $arrayofmassactions['transfer_request'] = $langs->trans("MakeBankTransferOrder");
+ }
//if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if (!empty($conf->paymentbybanktransfer->enabled) && !empty($user->rights->paymentbybanktransfer->create)) {
$langs->load('withdrawals');
diff --git a/htdocs/install/mysql/data/llx_c_availability.sql b/htdocs/install/mysql/data/llx_c_availability.sql
index 7d834aa2809..2e06d1de8b3 100644
--- a/htdocs/install/mysql/data/llx_c_availability.sql
+++ b/htdocs/install/mysql/data/llx_c_availability.sql
@@ -1,4 +1,5 @@
-- Copyright (C) 2011 Philippe GRAND
+-- Copyright (C) 2020 Alexandre SPANGARO
--
-- 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
@@ -25,7 +26,7 @@
--
delete from llx_c_availability;
-INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (1, 'AV_NOW', 'Immediate', 1);
-INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (2, 'AV_1W', '1 week', 1);
-INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (3, 'AV_2W', '2 weeks', 1);
-INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (4, 'AV_3W', '3 weeks', 1);
+INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (1, 'AV_NOW', 'Immediate', 1, 10);
+INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (2, 'AV_1W', '1 week', 1, 20);
+INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (3, 'AV_2W', '2 weeks', 1, 30);
+INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (4, 'AV_3W', '3 weeks', 1, 40);
diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql
index 0c3ee8549da..104670ce160 100644
--- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql
+++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql
@@ -1,7 +1,7 @@
--
-- Be carefull to requests order.
-- This file must be loaded by calling /install/index.php page
--- when current version is 13.0.0 or higher.
+-- when current version is 14.0.0 or higher.
--
-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y
-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y
@@ -30,10 +30,10 @@
-- Missing in v13 or lower
-
-
-- For v14
+ALTER TABLE llx_c_availability ADD COLUMN position integer NOT NULL DEFAULT 0;
+
ALTER TABLE llx_adherent ADD COLUMN ref varchar(30) AFTER rowid;
UPDATE llx_adherent SET ref = rowid WHERE ref = '' or ref IS NULL;
ALTER TABLE llx_adherent MODIFY COLUMN ref varchar(30) NOT NULL;
diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql
index 23e7d489e09..3a612623298 100644
--- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql
+++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql
@@ -41,7 +41,7 @@ CREATE TABLE llx_accounting_bookkeeping
multicurrency_code varchar(255), -- FEC:Idevise
lettering_code varchar(255), -- FEC:EcritureLet
date_lettering datetime, -- FEC:DateLet
- date_lim_reglement datetime DEFAULT NULL, -- | date limite de reglement
+ date_lim_reglement datetime DEFAULT NULL, -- FEC_suppl:DateLimitReglmt | payment deadline
fk_user_author integer NOT NULL, -- | user creating
fk_user_modif integer, -- | user making last change
date_creation datetime, -- FEC:EcritureDate | creation date
diff --git a/htdocs/install/mysql/tables/llx_c_availability.sql b/htdocs/install/mysql/tables/llx_c_availability.sql
index cef03abe548..4cdc8d6203c 100644
--- a/htdocs/install/mysql/tables/llx_c_availability.sql
+++ b/htdocs/install/mysql/tables/llx_c_availability.sql
@@ -1,5 +1,6 @@
-- ========================================================================
-- Copyright (C) 2011 Philippe GRAND
+-- Copyright (C) 2020 Alexandre SPANGARO
--
-- 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
@@ -21,6 +22,6 @@ create table llx_c_availability
rowid integer AUTO_INCREMENT PRIMARY KEY,
code varchar(30) NOT NULL,
label varchar(60) NOT NULL,
- active tinyint DEFAULT 1 NOT NULL
-
+ active tinyint DEFAULT 1 NOT NULL,
+ position integer NOT NULL DEFAULT 0
)ENGINE=innodb;
diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang
index c7ce4ac6b0b..43a496997f3 100644
--- a/htdocs/langs/en_US/accountancy.lang
+++ b/htdocs/langs/en_US/accountancy.lang
@@ -145,7 +145,7 @@ NotVentilatedinAccount=Not bound to the accounting account
XLineSuccessfullyBinded=%s products/services successfully bound to an accounting account
XLineFailedToBeBinded=%s products/services were not bound to any accounting account
-ACCOUNTING_LIMIT_LIST_VENTILATION=Number of elements to bind shown by page (maximum recommended: 50)
+ACCOUNTING_LIMIT_LIST_VENTILATION=Maximum number of lines on list and bind page (recommended: 50)
ACCOUNTING_LIST_SORT_VENTILATION_TODO=Begin the sorting of the page "Binding to do" by the most recent elements
ACCOUNTING_LIST_SORT_VENTILATION_DONE=Begin the sorting of the page "Binding done" by the most recent elements
diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang
index 553e3ac0eaa..a3fc1207a6f 100644
--- a/htdocs/langs/en_US/withdrawals.lang
+++ b/htdocs/langs/en_US/withdrawals.lang
@@ -42,6 +42,7 @@ LastWithdrawalReceipt=Latest %s direct debit receipts
MakeWithdrawRequest=Make a direct debit payment request
MakeBankTransferOrder=Make a credit transfer request
WithdrawRequestsDone=%s direct debit payment requests recorded
+BankTransferRequestsDone=%s credit transfer requests recorded
ThirdPartyBankCode=Third-party bank code
NoInvoiceCouldBeWithdrawed=No invoice debited successfully. Check that invoices are on companies with a valid IBAN and that IBAN has a UMR (Unique Mandate Reference) with mode %s.
ClassCredited=Classify credited
diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang
index 7937bfcebbf..59ac095a763 100644
--- a/htdocs/langs/fr_FR/accountancy.lang
+++ b/htdocs/langs/fr_FR/accountancy.lang
@@ -144,7 +144,7 @@ NotVentilatedinAccount=Non lié au compte comptable
XLineSuccessfullyBinded=%s produits/service correctement liés à un compte comptable
XLineFailedToBeBinded=%s produits/services n'ont pu être liés à un compte comptable
-ACCOUNTING_LIMIT_LIST_VENTILATION=Nombre d'éléments à lier représentés par page (maximum recommandé: 50)
+ACCOUNTING_LIMIT_LIST_VENTILATION=Nombre de ligne des listes et d'éléments à lier représentés par page (maximum recommandé: 50)
ACCOUNTING_LIST_SORT_VENTILATION_TODO=Commencez le tri de la page "Lien à réaliser" par les éléments les plus récents
ACCOUNTING_LIST_SORT_VENTILATION_DONE=Commencez le tri de la page "Liens réalisés" par les éléments les plus récents
diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php
index 807d3537775..8b5bcc13920 100644
--- a/htdocs/salaries/class/paymentsalary.class.php
+++ b/htdocs/salaries/class/paymentsalary.class.php
@@ -125,8 +125,7 @@ class PaymentSalary extends CommonObject
$this->note = trim($this->note);
// Check parameters
- if (empty($this->fk_user) || $this->fk_user < 0)
- {
+ if (empty($this->fk_user) || $this->fk_user < 0) {
$this->error = 'ErrorBadParameter';
return -1;
}
@@ -156,35 +155,29 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
return -1;
}
// Update extrafield
- if (!$error)
- {
- if (!$error)
- {
- $result = $this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
+ if (!$error) {
+ $result = $this->insertExtraFields();
+ if ($result < 0) {
+ $error++;
}
}
- if (!$notrigger)
- {
+ if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('PAYMENT_SALARY_MODIFY', $user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return 1;
} else {
@@ -204,6 +197,7 @@ class PaymentSalary extends CommonObject
public function fetch($id, $user = null)
{
global $langs;
+
$sql = "SELECT";
$sql .= " s.rowid,";
@@ -232,26 +226,24 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
+ if ($resql) {
+ if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
- $this->ref = $obj->rowid;
- $this->tms = $this->db->jdate($obj->tms);
+ $this->ref = $obj->rowid;
+ $this->tms = $this->db->jdate($obj->tms);
$this->fk_user = $obj->fk_user;
- $this->datep = $this->db->jdate($obj->datep);
- $this->datev = $this->db->jdate($obj->datev);
+ $this->datep = $this->db->jdate($obj->datep);
+ $this->datev = $this->db->jdate($obj->datev);
$this->amount = $obj->amount;
$this->fk_project = $obj->fk_project;
$this->type_payement = $obj->fk_typepayment;
$this->num_payment = $obj->num_payment;
- $this->label = $obj->label;
- $this->datesp = $this->db->jdate($obj->datesp);
- $this->dateep = $this->db->jdate($obj->dateep);
- $this->note = $obj->note;
+ $this->label = $obj->label;
+ $this->datesp = $this->db->jdate($obj->datesp);
+ $this->dateep = $this->db->jdate($obj->dateep);
+ $this->note = $obj->note;
$this->fk_bank = $obj->fk_bank;
$this->fk_user_author = $obj->fk_user_author;
$this->fk_user_modif = $obj->fk_user_modif;
@@ -287,18 +279,18 @@ class PaymentSalary extends CommonObject
// Call trigger
$result = $this->call_trigger('PAYMENT_SALARY_DELETE', $user);
- if ($result < 0) return -1;
+ if ($result < 0) {
+ return -1;
+ }
// End call triggers
// Delete donation
- if (!$error)
- {
+ if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary_extrafields";
$sql .= " WHERE fk_object=".$this->id;
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$this->errors[] = $this->db->lasterror();
$error++;
}
@@ -309,8 +301,7 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
return -1;
}
@@ -331,7 +322,7 @@ class PaymentSalary extends CommonObject
$this->id = 0;
$this->tms = '';
- $this->fk_user = '';
+ $this->fk_user = 1;
$this->datep = '';
$this->datev = '';
$this->amount = '';
@@ -340,8 +331,8 @@ class PaymentSalary extends CommonObject
$this->dateep = '';
$this->note = '';
$this->fk_bank = '';
- $this->fk_user_author = '';
- $this->fk_user_modif = '';
+ $this->fk_user_author = 1;
+ $this->fk_user_modif = 1;
}
/**
@@ -361,34 +352,29 @@ class PaymentSalary extends CommonObject
$this->amount = price2num(trim($this->amount));
$this->label = trim($this->label);
$this->note = trim($this->note);
- $this->fk_bank = trim($this->fk_bank);
- $this->fk_user_author = trim($this->fk_user_author);
- $this->fk_user_modif = trim($this->fk_user_modif);
+ $this->fk_bank = (int) $this->fk_bank;
+ $this->fk_user_author = (int) $this->fk_user_author;
+ $this->fk_user_modif = (int) $this->fk_user_modif;
// Check parameters
- if (!$this->label)
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
+ if (!$this->label) {
+ $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
return -3;
}
- if ($this->fk_user < 0 || $this->fk_user == '')
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
+ if ($this->fk_user <= 0 || $this->fk_user == '') {
+ $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
return -4;
}
- if ($this->amount < 0 || $this->amount == '')
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
+ if ($this->amount < 0 || $this->amount == '') {
+ $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
return -5;
}
- if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0))
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
+ if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) {
+ $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
return -6;
}
- if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0))
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
+ if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) {
+ $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
return -7;
}
@@ -403,7 +389,9 @@ class PaymentSalary extends CommonObject
$sql .= ", salary";
$sql .= ", fk_typepayment";
$sql .= ", num_payment";
- if ($this->note) $sql .= ", note";
+ if ($this->note) {
+ $sql .= ", note";
+ }
$sql .= ", label";
$sql .= ", datesp";
$sql .= ", dateep";
@@ -421,7 +409,9 @@ class PaymentSalary extends CommonObject
$sql .= ", ".($this->salary > 0 ? $this->salary : "null");
$sql .= ", ".$this->db->escape($this->type_payment);
$sql .= ", '".$this->db->escape($this->num_payment)."'";
- if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'";
+ if ($this->note) {
+ $sql .= ", '".$this->db->escape($this->note)."'";
+ }
$sql .= ", '".$this->db->escape($this->label)."'";
$sql .= ", '".$this->db->idate($this->datesp)."'";
$sql .= ", '".$this->db->idate($this->dateep)."'";
@@ -433,30 +423,25 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary");
- if ($this->id > 0)
- {
- if (!empty($conf->banque->enabled) && !empty($this->amount))
- {
+ if ($this->id > 0) {
+ if (!empty($conf->banque->enabled) && !empty($this->amount)) {
// Insert into llx_bank
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
$result = $acc->fetch($this->accountid);
- if ($result <= 0) dol_print_error($this->db);
+ if ($result <= 0) {
+ dol_print_error($this->db);
+ }
// Update extrafield
if (!$error) {
- if (!$error)
- {
- $result = $this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
+ $result = $this->insertExtraFields();
+ if ($result < 0) {
+ $error++;
}
}
@@ -478,22 +463,19 @@ class PaymentSalary extends CommonObject
// Update fk_bank into llx_paiement.
// So we know the payment which has generate the banking ecriture
- if ($bank_line_id > 0)
- {
+ if ($bank_line_id > 0) {
$this->update_fk_bank($bank_line_id);
} else {
$this->error = $acc->error;
$error++;
}
- if (!$error)
- {
+ if (!$error) {
// Add link 'payment_salary' in bank_url between payment and bank transaction
$url = DOL_URL_ROOT.'/salaries/card.php?id=';
$result = $acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary");
- if ($result <= 0)
- {
+ if ($result <= 0) {
$this->error = $acc->error;
$error++;
}
@@ -512,8 +494,7 @@ class PaymentSalary extends CommonObject
'user'
);
- if ($result <= 0)
- {
+ if ($result <= 0) {
$this->error = $acc->error;
$error++;
}
@@ -521,12 +502,15 @@ class PaymentSalary extends CommonObject
// Call trigger
$result = $this->call_trigger('PAYMENT_SALARY_CREATE', $user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
- } else $error++;
+ } else {
+ $error++;
+ }
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return $this->id;
} else {
@@ -553,8 +537,7 @@ class PaymentSalary extends CommonObject
$sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank;
$sql .= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
return 1;
} else {
dol_print_error($this->db);
@@ -576,10 +559,10 @@ class PaymentSalary extends CommonObject
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
{
global $db, $conf, $langs, $hookmanager;
- global $dolibarr_main_authentication, $dolibarr_main_demo;
- global $menumanager;
- if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
+ if (!empty($conf->dol_no_mouse_hover)) {
+ $notooltip = 1; // Force disable tooltips
+ }
$result = '';
@@ -588,10 +571,11 @@ class PaymentSalary extends CommonObject
if (!empty($this->label)) {
$labeltoshow = $this->label;
$reg = array();
- if (preg_match('/^\((.*)\)$/i', $this->label, $reg))
- {
+ if (preg_match('/^\((.*)\)$/i', $this->label, $reg)) {
// Label generique car entre parentheses. On l'affiche en le traduisant
- if ($reg[1] == 'paiement') $reg[1] = 'Payment';
+ if ($reg[1] == 'paiement') {
+ $reg[1] = 'Payment';
+ }
$labeltoshow = $langs->trans($reg[1]);
}
$label .= '
'.$langs->trans('Label').': '.$labeltoshow;
@@ -599,19 +583,20 @@ class PaymentSalary extends CommonObject
$url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id;
- if ($option != 'nolink')
- {
+ if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
- if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ $add_save_lastsearch_values = 1;
+ }
+ if ($add_save_lastsearch_values) {
+ $url .= '&save_lastsearch_values=1';
+ }
}
$linkclose = '';
- if (empty($notooltip))
- {
- if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
- {
+ if (empty($notooltip)) {
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowMyObject");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
@@ -619,20 +604,26 @@ class PaymentSalary extends CommonObject
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
/*
- $hookmanager->initHooks(array('myobjectdao'));
- $parameters=array('id'=>$this->id);
- $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
- if ($reshook > 0) $linkclose = $hookmanager->resPrint;
- */
- } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ $hookmanager->initHooks(array('myobjectdao'));
+ $parameters=array('id'=>$this->id);
+ $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook > 0) $linkclose = $hookmanager->resPrint;
+ */
+ } else {
+ $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ }
$linkstart = '';
$linkend = '';
$result .= $linkstart;
- if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
- if ($withpicto != 2) $result .= $this->ref;
+ if ($withpicto) {
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ if ($withpicto != 2) {
+ $result .= $this->ref;
+ }
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@@ -640,8 +631,11 @@ class PaymentSalary extends CommonObject
$hookmanager->initHooks(array('salarypayment'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook > 0) $result = $hookmanager->resPrint;
- else $result .= $hookmanager->resPrint;
+ if ($reshook > 0) {
+ $result = $hookmanager->resPrint;
+ } else {
+ $result .= $hookmanager->resPrint;
+ }
return $result;
}
@@ -661,14 +655,11 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this).'::info', LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result)
- {
- if ($this->db->num_rows($result))
- {
+ if ($result) {
+ if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
- if ($obj->fk_user_author)
- {
+ if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
@@ -708,40 +699,40 @@ class PaymentSalary extends CommonObject
$langs->load('compta');
/*if ($mode == 0)
- {
- if ($status == 0) return $langs->trans('ToValidate');
- if ($status == 1) return $langs->trans('Validated');
- }
- if ($mode == 1)
- {
- if ($status == 0) return $langs->trans('ToValidate');
- if ($status == 1) return $langs->trans('Validated');
- }
- if ($mode == 2)
- {
- if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
- if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
- }
- if ($mode == 3)
- {
- if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
- if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
- }
- if ($mode == 4)
- {
- if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
- if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
- }
- if ($mode == 5)
- {
- if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
- if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
- }
- if ($mode == 6)
- {
- if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
- if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
- }*/
+ {
+ if ($status == 0) return $langs->trans('ToValidate');
+ if ($status == 1) return $langs->trans('Validated');
+ }
+ if ($mode == 1)
+ {
+ if ($status == 0) return $langs->trans('ToValidate');
+ if ($status == 1) return $langs->trans('Validated');
+ }
+ if ($mode == 2)
+ {
+ if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
+ if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
+ }
+ if ($mode == 3)
+ {
+ if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
+ if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
+ }
+ if ($mode == 4)
+ {
+ if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
+ if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
+ }
+ if ($mode == 5)
+ {
+ if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
+ if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
+ }
+ if ($mode == 6)
+ {
+ if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
+ if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
+ }*/
return '';
}
}
diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php
index b8a0ba69ef7..2b700108d10 100644
--- a/htdocs/salaries/list.php
+++ b/htdocs/salaries/list.php
@@ -26,7 +26,9 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
-if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
+if (!empty($conf->accounting->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
+}
// Load translation files required by the page
$langs->loadLangs(array("compta", "salaries", "bills", "hrm"));
@@ -46,12 +48,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
+if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
+ $page = 0;
+} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
-if (!$sortfield) $sortfield = "s.datep,s.rowid";
-if (!$sortorder) $sortorder = "DESC,DESC";
+if (!$sortfield) {
+ $sortfield = "s.datep,s.rowid";
+}
+if (!$sortorder) {
+ $sortorder = "DESC,DESC";
+}
// Initialize technical objects
$object = new PaymentSalary($db);
@@ -64,8 +72,12 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
-if (!$sortfield) $sortfield = "s.datep,s.rowid";
-if (!$sortorder) $sortorder = "DESC,DESC";
+if (!$sortfield) {
+ $sortfield = "s.datep,s.rowid";
+}
+if (!$sortorder) {
+ $sortorder = "DESC,DESC";
+}
$search_ref = GETPOST('search_ref', 'int');
$search_user = GETPOST('search_user', 'alpha');
@@ -77,14 +89,14 @@ $search_account = GETPOST('search_account', 'int');
$filtre = GETPOST("filtre", 'restricthtml');
-if (!GETPOST('search_type_id', 'int'))
-{
+if (!GETPOST('search_type_id', 'int')) {
$newfiltre = str_replace('filtre=', '', $filtre);
$filterarray = explode('-', $newfiltre);
- foreach ($filterarray as $val)
- {
+ foreach ($filterarray as $val) {
$part = explode(':', $val);
- if ($part[0] == 's.fk_typepayment') $search_type_id = $part[1];
+ if ($part[0] == 's.fk_typepayment') {
+ $search_type_id = $part[1];
+ }
}
} else {
$search_type_id = GETPOST('search_type_id', 'int');
@@ -94,22 +106,26 @@ $childids = $user->getAllChildIds(1);
// Security check
$socid = GETPOST("socid", "int");
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'salaries', '', '', '');
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha');
$search = array();
-foreach ($object->fields as $key => $val)
-{
- if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
+foreach ($object->fields as $key => $val) {
+ if (GETPOST('search_'.$key, 'alpha') !== '') {
+ $search[$key] = GETPOST('search_'.$key, 'alpha');
+ }
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array();
-foreach ($object->fields as $key => $val)
-{
- if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
+foreach ($object->fields as $key => $val) {
+ if ($val['searchall']) {
+ $fieldstosearchall['t.'.$key] = $val['label'];
+ }
}
$permissiontoread = $user->rights->salaries->read;
@@ -121,21 +137,26 @@ $permissiontodelete = $user->rights->salaries->delete;
* Actions
*/
-if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
-if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
+if (GETPOST('cancel', 'alpha')) {
+ $action = 'list';
+ $massaction = '';
+}
+if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
+ $massaction = '';
+}
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
-if (empty($reshook))
-{
+if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
- if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
- {
+ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
$search_ref = "";
$search_user = "";
$search_label = "";
@@ -146,8 +167,7 @@ if (empty($reshook))
$search_type_id = "";
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
- || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
- {
+ || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
@@ -158,8 +178,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// Validate records
- if (!$error && $massaction == 'buildsepa' && $permissiontoadd)
- {
+ if (!$error && $massaction == 'buildsepa' && $permissiontoadd) {
$objecttmp = new $objectclass($db);
// TODO
@@ -192,16 +211,32 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.ro
$sql .= " ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.rowid = s.fk_user";
$sql .= " AND s.entity IN (".getEntity('payment_salaries').")";
-if (empty($user->rights->salaries->readall)) $sql .= " AND s.fk_user IN (".join(',', $childids).")";
+if (empty($user->rights->salaries->readall)) {
+ $sql .= " AND s.fk_user IN (".join(',', $childids).")";
+}
// Search criteria
-if ($search_ref) $sql .= " AND s.rowid=".((int) $search_ref);
-if ($search_user) $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
-if ($search_label) $sql .= natural_search(array('s.label'), $search_label);
-if ($search_date_start) $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'";
-if ($search_date_end) $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'";
-if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1);
-if ($search_account > 0) $sql .= " AND b.fk_account=".((int) $search_account);
+if ($search_ref) {
+ $sql .= " AND s.rowid=".((int) $search_ref);
+}
+if ($search_user) {
+ $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
+}
+if ($search_label) {
+ $sql .= natural_search(array('s.label'), $search_label);
+}
+if ($search_date_start) {
+ $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'";
+}
+if ($search_date_end) {
+ $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'";
+}
+if ($search_amount) {
+ $sql .= natural_search("s.amount", $search_amount, 1);
+}
+if ($search_account > 0) {
+ $sql .= " AND b.fk_account=".((int) $search_account);
+}
if ($filtre) {
$filtre = str_replace(":", "=", $filtre);
$sql .= " AND ".$filtre;
@@ -213,26 +248,24 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
-if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
-{
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
- if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
- {
+ if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
$page = 0;
$offset = 0;
}
}
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
-if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
-{
+if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
$num = $nbtotalofrecords;
} else {
- if ($limit) $sql .= $db->plimit($limit + 1, $offset);
+ if ($limit) {
+ $sql .= $db->plimit($limit + 1, $offset);
+ }
$resql = $db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
dol_print_error($db);
exit;
}
@@ -248,16 +281,36 @@ llxHeader('', $title, $help_url);
$arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';
-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
-if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
-if ($search_type_id) $param .= '&search_type_id='.urlencode($search_type_id);
-if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
-if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
-if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
-if ($search_label) $param .= '&search_label='.urlencode($search_label);
-if ($search_account) $param .= '&search_account='.urlencode($search_account);
-if ($search_date_start) $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int'));
-if ($search_date_end) $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int'));
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+ $param .= '&contextpage='.urlencode($contextpage);
+}
+if ($limit > 0 && $limit != $conf->liste_limit) {
+ $param .= '&limit='.urlencode($limit);
+}
+if ($search_type_id) {
+ $param .= '&search_type_id='.urlencode($search_type_id);
+}
+if ($optioncss != '') {
+ $param .= '&optioncss='.urlencode($optioncss);
+}
+if ($search_ref) {
+ $param .= '&search_ref='.urlencode($search_ref);
+}
+if ($search_user > 0) {
+ $param .= '&search_user='.urlencode($search_user);
+}
+if ($search_label) {
+ $param .= '&search_label='.urlencode($search_label);
+}
+if ($search_account) {
+ $param .= '&search_account='.urlencode($search_account);
+}
+if ($search_date_start) {
+ $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int'));
+}
+if ($search_date_end) {
+ $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int'));
+}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@@ -267,11 +320,15 @@ $arrayofmassactions = array(
//'buildsepa'=>$langs->trans("BuildSepa"), // TODO
);
//if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete");
-if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
+if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
+ $arrayofmassactions = array();
+}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '