';
+ // Piece number
+ if (!empty($arrayfields['t.piece_num']['checked']))
+ {
+ print '';
+ $object->id = $line->id;
+ $object->piece_num = $line->piece_num;
+ print $object->getNomUrl(1, '', 0, '', 1);
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+
// Journal code
if (!empty($arrayfields['t.code_journal']['checked']))
{
@@ -654,17 +665,6 @@ while ($i < min($num, $limit))
if (!$i) $totalarray['nbfield']++;
}
- // Piece number
- if (!empty($arrayfields['t.piece_num']['checked']))
- {
- print '';
- $object->id = $line->id;
- $object->piece_num = $line->piece_num;
- print $object->getNomUrl(1, '', 0, '', 1);
- print ' ';
- if (!$i) $totalarray['nbfield']++;
- }
-
// Document ref
if (!empty($arrayfields['t.doc_ref']['checked']))
{
diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php
index 2adcbe9f360..04b59fc7816 100644
--- a/htdocs/accountancy/bookkeeping/listbysubaccount.php
+++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php
@@ -135,8 +135,8 @@ if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('searc
$arrayfields = array(
// 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1),
- 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
+ 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1),
't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
@@ -442,8 +442,8 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
$newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
- $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss' => 'marginleftonly'));
- $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php', '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
+ $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
+ $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create');
}
@@ -502,6 +502,11 @@ print '';
// Filters lines
print '';
+// Movement number
+if (!empty($arrayfields['t.piece_num']['checked']))
+{
+ print ' ';
+}
// Code journal
if (!empty($arrayfields['t.code_journal']['checked'])) {
print '';
@@ -519,10 +524,6 @@ if (!empty($arrayfields['t.doc_date']['checked'])) {
print '';
print ' ';
}
-// Movement number
-if (!empty($arrayfields['t.piece_num']['checked'])) {
- print ' ';
-}
// Ref document
if (!empty($arrayfields['t.doc_ref']['checked'])) {
print ' ';
@@ -571,15 +572,15 @@ print '';
print " \n";
print '';
+if (!empty($arrayfields['t.piece_num']['checked'])) {
+ print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder);
+}
if (!empty($arrayfields['t.code_journal']['checked'])) {
print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['t.doc_date']['checked'])) {
print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
}
-if (!empty($arrayfields['t.piece_num']['checked'])) {
- print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder);
-}
if (!empty($arrayfields['t.doc_ref']['checked'])) {
print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
}
@@ -673,8 +674,10 @@ while ($i < min($num, $limit)) {
print ''.$langs->trans("Unknown");
if ($line->subledger_label) {
print ' ('.$line->subledger_label.')';
+ $htmltext = 'EmptyStringForSubledgerAccountButSubledgerLabelDefined';
+ } else {
+ $htmltext = 'EmptyStringForSubledgerAccountAndSubledgerLabel';
}
- $htmltext = 'EmptyStringForSubledgerAccountButSubledgerLabelDefined';
print $form->textwithpicto('', $htmltext);
print ' ';
}
@@ -691,6 +694,17 @@ while ($i < min($num, $limit)) {
print ' ';
+ // Piece number
+ if (!empty($arrayfields['t.piece_num']['checked']))
+ {
+ print '';
+ $object->id = $line->id;
+ $object->piece_num = $line->piece_num;
+ print $object->getNomUrl(1, '', 0, '', 1);
+ print ' ';
+ if (!$i) $totalarray['nbfield']++;
+ }
+
// Journal code
if (!empty($arrayfields['t.code_journal']['checked'])) {
$accountingjournal = new AccountingJournal($db);
@@ -710,18 +724,6 @@ while ($i < min($num, $limit)) {
}
}
- // Piece number
- if (!empty($arrayfields['t.piece_num']['checked'])) {
- print '';
- $object->id = $line->id;
- $object->piece_num = $line->piece_num;
- print $object->getNomUrl(1, '', 0, '', 1);
- print ' ';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
-
// Document ref
if (!empty($arrayfields['t.doc_ref']['checked'])) {
if ($line->doc_type == 'customer_invoice') {
diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php
index 201e3cac95a..b936f99925a 100644
--- a/htdocs/accountancy/class/accountancyexport.class.php
+++ b/htdocs/accountancy/class/accountancyexport.class.php
@@ -820,6 +820,8 @@ class AccountancyExport
*/
public function exportFEC($objectLines)
{
+ global $langs;
+
$separator = "\t";
$end_line = "\r\n";
@@ -855,55 +857,55 @@ class AccountancyExport
$date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
// FEC:JournalCode
- print $line->code_journal.$separator;
+ print $line->code_journal . $separator;
// FEC:JournalLib
- print $line->journal_label.$separator;
+ print dol_string_unaccent($langs->transnoentities($line->journal_label)) . $separator;
// FEC:EcritureNum
- print $line->piece_num.$separator;
+ print $line->piece_num . $separator;
// FEC:EcritureDate
- print $date_document.$separator;
+ print $date_document . $separator;
// FEC:CompteNum
- print length_accountg($line->numero_compte).$separator;
+ print $line->numero_compte . $separator;
// FEC:CompteLib
- print dol_string_unaccent($line->label_compte).$separator;
+ print dol_string_unaccent($line->label_compte) . $separator;
// FEC:CompAuxNum
- print length_accounta($line->subledger_account).$separator;
+ print $line->subledger_account . $separator;
// FEC:CompAuxLib
- print dol_string_unaccent($line->subledger_label).$separator;
+ print dol_string_unaccent($line->subledger_label) . $separator;
// FEC:PieceRef
- print $line->doc_ref.$separator;
+ print $line->doc_ref . $separator;
// FEC:PieceDate
- print $date_creation.$separator;
+ print dol_string_unaccent($date_creation) . $separator;
// FEC:EcritureLib
- print dol_string_unaccent($line->label_operation).$separator;
+ print dol_string_unaccent($line->label_operation) . $separator;
// FEC:Debit
- print price2fec($line->debit).$separator;
+ print price2fec($line->debit) . $separator;
// FEC:Credit
- print price2fec($line->credit).$separator;
+ print price2fec($line->credit) . $separator;
// FEC:EcritureLet
- print $line->lettering_code.$separator;
+ print $line->lettering_code . $separator;
// FEC:DateLet
- print $date_lettering.$separator;
+ print $date_lettering . $separator;
// FEC:ValidDate
- print $date_validation.$separator;
+ print $date_validation . $separator;
// FEC:Montantdevise
- print $line->multicurrency_amount.$separator;
+ print $line->multicurrency_amount . $separator;
// FEC:Idevise
print $line->multicurrency_code.$separator;
@@ -924,6 +926,8 @@ class AccountancyExport
*/
public function exportFEC2($objectLines)
{
+ global $langs;
+
$separator = "\t";
$end_line = "\r\n";
@@ -962,7 +966,7 @@ class AccountancyExport
print $line->code_journal . $separator;
// FEC:JournalLib
- print $line->journal_label . $separator;
+ print dol_string_unaccent($langs->transnoentities($line->journal_label)) . $separator;
// FEC:EcritureNum
print $line->piece_num . $separator;
@@ -1644,15 +1648,15 @@ class AccountancyExport
($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
if ($line->doc_type == 'customer_invoice') {
// Get new customer invoice ref and company name
- $sql = 'SELECT f.facnumber, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f';
+ $sql = 'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f';
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid';
$sql .= ' WHERE f.rowid = ' . $line->fk_doc;
$resql = $this->db->query($sql);
if ($resql) {
if ($obj = $this->db->fetch_object($resql)) {
// Save invoice infos
- $invoices_infos[$line->fk_doc] = array('ref' => $obj->facnumber, 'company_name' => $obj->nom);
- $invoice_ref = $obj->facnumber;
+ $invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom);
+ $invoice_ref = $obj->ref;
$company_name = $obj->nom;
}
}
diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php
index a76be081471..6ee8a03d8ff 100644
--- a/htdocs/accountancy/class/accountingjournal.class.php
+++ b/htdocs/accountancy/class/accountingjournal.class.php
@@ -126,7 +126,7 @@ class AccountingJournal extends CommonObject
$this->rowid = $obj->rowid;
$this->code = $obj->code;
- $this->ref = $obj->code;
+ $this->ref = $obj->code;
$this->label = $obj->label;
$this->nature = $obj->nature;
$this->active = $obj->active;
diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index fe73ab9f376..f21d88bc363 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -831,7 +831,11 @@ class BookKeeping extends CommonObject
} 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);
+ if (is_array($value)) {
+ $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1);
+ } else {
+ $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1);
+ }
} else {
$sqlwhere[] = natural_search($key, $value, 0, 1);
}
diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index cb47e436cbd..2975c7de3c0 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -532,10 +532,12 @@ if ($result) {
}
// Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding)
- if (!empty($objp->company_code_sell)) {
- $objp->code_sell_t = $objp->company_code_sell;
- $objp->aarowid_suggest = $objp->aarowid_thirdparty;
- $suggestedaccountingaccountfor = '';
+ if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
+ if (!empty($objp->company_code_sell)) {
+ $objp->code_sell_t = $objp->company_code_sell;
+ $objp->aarowid_suggest = $objp->aarowid_thirdparty;
+ $suggestedaccountingaccountfor = '';
+ }
}
// Manage Deposit
@@ -616,25 +618,32 @@ if ($result) {
{
print ' ';
$s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
- $shelp = '';
+ $shelp = ''; $ttype = 'help';
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT");
- elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $shelp = $langs->trans("SaleEECWithoutVATNumber");
+ elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') {
+ $shelp = $langs->trans("SaleEECWithoutVATNumber");
+ $ttype = 'warning';
+ }
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
$s .= (empty($objp->code_sell_p) ? ''.$langs->trans("NotDefined").' ' : length_accountg($objp->code_sell_p));
- print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
+ print $form->textwithpicto($s, $shelp, 1, $ttype, '', 0, 2, '', 1);
} else {
+ if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
+ print ' ';
+ $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
+ $shelp = '';
+ $s .= $langs->trans("NotDefined");
+ print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
+ }
+ }
+ if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
print ' ';
- $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
+ $s = '3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': ';
$shelp = '';
- $s .= $langs->trans("NotDefined");
+ $s .= ($objp->code_sell_t > 0 ? length_accountg($objp->code_sell_t) : ''.$langs->trans("NotDefined").' ');
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
}
- print ' ';
- $s = '3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': ';
- $shelp = '';
- $s .= ($objp->code_sell_t > 0 ? length_accountg($objp->code_sell_t) : ''.$langs->trans("NotDefined").' ');
- print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
print '';
// Suggested accounting account
diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php
index d353041234f..c47255647cb 100644
--- a/htdocs/accountancy/journal/bankjournal.php
+++ b/htdocs/accountancy/journal/bankjournal.php
@@ -549,7 +549,7 @@ if (!$error && $action == 'writebookkeeping') {
$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
$bookkeeping->credit = ($mt < 0 ? -$mt : 0);
$bookkeeping->code_journal = $journal;
- $bookkeeping->journal_label = $journal_label;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->date_creation = $now;
@@ -605,7 +605,7 @@ if (!$error && $action == 'writebookkeeping') {
$bookkeeping->debit = ($mt < 0 ? -$mt : 0);
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
- $bookkeeping->journal_label = $journal_label;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->date_creation = $now;
@@ -737,7 +737,7 @@ if (!$error && $action == 'writebookkeeping') {
$bookkeeping->debit = ($mt < 0 ? -$mt : 0);
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
- $bookkeeping->journal_label = $journal_label;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->date_creation = $now;
$bookkeeping->label_compte = '';
diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php
index 26e2b4cdf77..70ec097cd27 100644
--- a/htdocs/accountancy/journal/expensereportsjournal.php
+++ b/htdocs/accountancy/journal/expensereportsjournal.php
@@ -223,7 +223,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
- $bookkeeping->journal_label = $journal_label;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
@@ -271,7 +271,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->code_journal = $journal;
- $bookkeeping->journal_label = $journal_label;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
@@ -329,7 +329,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->code_journal = $journal;
- $bookkeeping->journal_label = $journal_label;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php
index 94f878527dd..611dde36af5 100644
--- a/htdocs/accountancy/journal/purchasesjournal.php
+++ b/htdocs/accountancy/journal/purchasesjournal.php
@@ -322,7 +322,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
- $bookkeeping->journal_label = $journal_label;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
@@ -372,7 +372,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->code_journal = $journal;
- $bookkeeping->journal_label = $journal_label;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
@@ -433,7 +433,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->code_journal = $journal;
- $bookkeeping->journal_label = $journal_label;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
@@ -484,7 +484,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->code_journal = $journal;
- $bookkeeping->journal_label = $journal_label;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php
index 9f44e02aafa..62d2238a116 100644
--- a/htdocs/accountancy/journal/sellsjournal.php
+++ b/htdocs/accountancy/journal/sellsjournal.php
@@ -333,7 +333,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
$bookkeeping->credit = ($mt < 0) ? -$mt : 0;
$bookkeeping->code_journal = $journal;
- $bookkeeping->journal_label = $journal_label;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
@@ -383,7 +383,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->debit = ($mt < 0) ? -$mt : 0;
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
- $bookkeeping->journal_label = $journal_label;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
@@ -443,7 +443,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->debit = ($mt < 0) ? -$mt : 0;
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
- $bookkeeping->journal_label = $journal_label;
+ $bookkeeping->journal_label = $langs->transnoentities($journal_label);
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php
index 6d9e3574789..e589db3ca26 100644
--- a/htdocs/admin/system/perf.php
+++ b/htdocs/admin/system/perf.php
@@ -473,7 +473,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
$resql = $db->query($sql);
if ($resql)
{
- $limitforoptim = 10000;
+ $limitforoptim = 100000;
$num = $db->num_rows($resql);
$obj = $db->fetch_object($resql);
$nb = $obj->nb;
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index dc0ada64eb3..016201be0f3 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -454,6 +454,15 @@ $viewmode .= ' ';
+// Add more views from hooks
+$parameters = array(); $object = null;
+$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
+if (empty($reshook)) {
+ $viewmode .= $hookmanager->resPrint;
+} elseif ($reshook > 1) {
+ $viewmode = $hookmanager->resPrint;
+}
+
$newcardbutton = '';
if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php
index 7fc58b73c9f..16c2a315cdd 100644
--- a/htdocs/comm/action/list.php
+++ b/htdocs/comm/action/list.php
@@ -474,11 +474,9 @@ if ($resql)
// Calendars from hooks
$parameters = array(); $object = null;
$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
- if (empty($reshook))
- {
+ if (empty($reshook)) {
$s .= $hookmanager->resPrint;
- } elseif ($reshook > 1)
- {
+ } elseif ($reshook > 1) {
$s = $hookmanager->resPrint;
}
@@ -515,6 +513,15 @@ if ($resql)
$viewmode .= ' ';
+ // Add more views from hooks
+ $parameters = array(); $object = null;
+ $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
+ if (empty($reshook)) {
+ $viewmode .= $hookmanager->resPrint;
+ } elseif ($reshook > 1) {
+ $viewmode = $hookmanager->resPrint;
+ }
+
$tmpforcreatebutton = dol_getdate(dol_now(), true);
$newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php
index 29b86b96868..f956b5ae5f7 100644
--- a/htdocs/comm/action/pertype.php
+++ b/htdocs/comm/action/pertype.php
@@ -384,6 +384,15 @@ $viewmode .= ' ';
+// Add more views from hooks
+$parameters = array(); $object = null;
+$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
+if (empty($reshook)) {
+ $viewmode .= $hookmanager->resPrint;
+} elseif ($reshook > 1) {
+ $viewmode = $hookmanager->resPrint;
+}
+
$newcardbutton = '';
if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php
index 55e6725ba8d..2dc62a52e91 100644
--- a/htdocs/comm/action/peruser.php
+++ b/htdocs/comm/action/peruser.php
@@ -389,6 +389,15 @@ $viewmode .= ' ';
+// Add more views from hooks
+$parameters = array(); $object = null;
+$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
+if (empty($reshook)) {
+ $viewmode .= $hookmanager->resPrint;
+} elseif ($reshook > 1) {
+ $viewmode = $hookmanager->resPrint;
+}
+
$newcardbutton = '';
if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 23c960d3a4b..b81ac502552 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1581,7 +1581,7 @@ if ($action == 'create')
// Date
print ' '.$langs->trans('Date').' ';
- print img_picto('', 'object_calendarday').' '.$form->selectDate('', '', '', '', '', "addprop", 1, 1);
+ print $form->selectDate('', '', '', '', '', "addprop", 1, 1);
print ' ';
// Validaty duration
@@ -1644,7 +1644,6 @@ if ($action == 'create')
// Delivery date (or manufacturing)
print ''.$langs->trans("DeliveryDate").' ';
print '';
- print img_picto('', 'object_calendarday').' ';
if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") {
$tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60);
$syear = date("Y", $tmpdte);
@@ -1662,8 +1661,7 @@ if ($action == 'create')
$langs->load("projects");
print ' ';
print ''.$langs->trans("Project").' ';
- print img_picto('', 'project');
- $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
+ print img_picto('', 'project').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
print ' id).'"> ';
print ' ';
print ' ';
@@ -1685,7 +1683,8 @@ if ($action == 'create')
print '';
print img_picto('', 'pdf').' ';
$liste = ModelePDFPropales::liste_modeles($db);
- print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF));
+ $preselected = ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF);
+ print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1);
print " ";
// Multicurrency
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 6dd6fc6911a..66105e06fff 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -1616,14 +1616,14 @@ if ($action == 'create' && $usercancreate)
// Date
print ''.$langs->trans('Date').' ';
- print img_picto('', 'object_calendarday').' '.$form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date
+ print $form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date
print ' ';
// Date delivery planned
print ''.$langs->trans("DateDeliveryPlanned").' ';
print '';
$date_delivery = ($date_delivery ? $date_delivery : $object->date_delivery);
- print img_picto('', 'object_calendarday').' '.$form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1);
+ print $form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1);
print " \n";
print ' ';
@@ -1731,7 +1731,8 @@ if ($action == 'create' && $usercancreate)
print img_picto('', 'pdf').' ';
include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
$liste = ModelePDFCommandes::liste_modeles($db);
- print $form->selectarray('model', $liste, $conf->global->COMMANDE_ADDON_PDF);
+ $preselected = $conf->global->COMMANDE_ADDON_PDF;
+ print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1);
print "";
// Multicurrency
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 248a45c629a..bbd189239c9 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -2893,19 +2893,20 @@ class Commande extends CommonOrder
* Classify the order as invoiced
*
* @param User $user Object user making the change
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <0 if KO, >0 if OK
+ * @param int $notrigger 1=Does not execute triggers, 0=execute triggers
+ * @return int <0 if KO, 0 if already billed, >0 if OK
*/
public function classifyBilled(User $user, $notrigger = 0)
{
$error = 0;
- $this->db->begin();
if ($this->billed)
{
return 0;
}
+ $this->db->begin();
+
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 1';
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 7250d673494..16a472d878c 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -2956,7 +2956,7 @@ if ($action == 'create')
} else {
print ''.$langs->trans('Customer').' ';
print '';
- print $form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status=1)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
+ print img_picto('', 'company').$form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status=1)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
// Option to reload page to retrieve customer informations.
if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED))
{
@@ -3444,11 +3444,11 @@ if ($action == 'create')
if (!empty($conf->banque->enabled))
{
if (GETPOSTISSET('fk_account')) {
- $fk_account = GETPOST('fk_account');
+ $fk_account = GETPOST('fk_account', 'int');
}
print ' '.$langs->trans('BankAccount').' ';
- $form->select_comptes($fk_account, 'fk_account', 0, '', 1);
+ print img_picto('', 'bank_account', 'class="paddingrightonly"').$form->select_comptes($fk_account, 'fk_account', 0, '', 1, '', 0, '', 1);
print ' ';
}
@@ -3457,7 +3457,7 @@ if ($action == 'create')
{
$langs->load('projects');
print ''.$langs->trans('Project').' ';
- $numprojet = $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
+ print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
print ' id.($fac_rec ? '&fac_rec='.$fac_rec : '')).'"> ';
print ' ';
}
@@ -3504,11 +3504,11 @@ if ($action == 'create')
if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) {
// Hidden conf
$paramkey = 'FACTURE_ADDON_PDF_'.$object->type;
- $curent = !empty($conf->global->$paramkey) ? $conf->global->$paramkey : $conf->global->FACTURE_ADDON_PDF;
+ $preselected = !empty($conf->global->$paramkey) ? $conf->global->$paramkey : $conf->global->FACTURE_ADDON_PDF;
} else {
- $curent = $conf->global->FACTURE_ADDON_PDF;
+ $preselected = $conf->global->FACTURE_ADDON_PDF;
}
- print $form->selectarray('model', $liste, $curent);
+ print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1);
print "";
// Multicurrency
@@ -4144,7 +4144,7 @@ if ($action == 'create')
$result = $tmptemplate->fetch($object->fk_fac_rec_source);
if ($result > 0) {
print ' ';
- print $langs->transnoentities("GeneratedFromTemplate", ''.dol_escape_htmltag($tmptemplate->ref).' ');
+ print $langs->transnoentities("GeneratedFromTemplate", ''.dol_escape_htmltag($tmptemplate->ref).' ');
print ' ';
}
}
@@ -4285,7 +4285,7 @@ if ($action == 'create')
print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0);
print '';
if ($usercancreate && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency)
- print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).' ';
+ print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).' ';
print '
';
print '';
if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') {
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index 29e78f90af8..1a50fadcc9c 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -2072,6 +2072,8 @@ class FactureLigneRec extends CommonInvoiceLine
$sql .= ", fk_contract_line=".($this->fk_contract_line ? $this->fk_contract_line : "null");
$sql .= " WHERE rowid = ".$this->id;
+ $this->db->begin();
+
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
@@ -2091,13 +2093,18 @@ class FactureLigneRec extends CommonInvoiceLine
$result = $this->call_trigger('LINEBILLREC_UPDATE', $user);
if ($result < 0)
{
- $this->db->rollback();
- return -2;
+ $error++;
}
// End call triggers
}
- $this->db->commit();
- return 1;
+
+ if ($error) {
+ $this->db->rollback();
+ return -2;
+ } else {
+ $this->db->commit();
+ return 1;
+ }
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index 89737ca917f..2c897968320 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -401,6 +401,7 @@ class Paiement extends CommonObject
if ($result < 0)
{
$this->error = $invoice->error;
+ $this->errors = $invoice->errors;
$error++;
}
}
diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php
index 0be9d7bbd6f..1858a308756 100644
--- a/htdocs/core/boxes/box_factures_fourn.php
+++ b/htdocs/core/boxes/box_factures_fourn.php
@@ -133,7 +133,7 @@ class box_factures_fourn extends ModeleBoxes
$thirdpartystatic->id = $objp->socid;
$thirdpartystatic->name = $objp->name;
- //$thirdpartystatic->name_alias = $objp->name_alias;
+ $thirdpartystatic->name_alias = $objp->name_alias;
$thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
$thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
$thirdpartystatic->fournisseur = $objp->fournisseur;
diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php
index b957e5bf0c1..d345f3d33b0 100644
--- a/htdocs/core/boxes/box_factures_fourn_imp.php
+++ b/htdocs/core/boxes/box_factures_fourn_imp.php
@@ -130,7 +130,7 @@ class box_factures_fourn_imp extends ModeleBoxes
$thirdpartystatic->id = $objp->socid;
$thirdpartystatic->name = $objp->name;
- //$thirdpartystatic->name_alias = $objp->name_alias;
+ $thirdpartystatic->name_alias = $objp->name_alias;
$thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
$thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
$thirdpartystatic->fournisseur = $objp->fournisseur;
diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php
index 89b5a79df4b..d610203b3ad 100644
--- a/htdocs/core/class/hookmanager.class.php
+++ b/htdocs/core/class/hookmanager.class.php
@@ -156,6 +156,7 @@ class HookManager
$method,
array(
'addCalendarChoice',
+ 'addCalendarView',
'addMoreActionsButtons',
'addMoreMassActions',
'addSearchEntry',
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index b66fcb77029..502cb9d920e 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -5707,14 +5707,17 @@ class Form
$retstring .= ' onChange="dpChangeDay(\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
$retstring .= '>';
- // Icone calendrier
- if (!$disabled)
- {
- $retstring .= 'trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');"';
- $retstring .= '>'.img_object($langs->trans("SelectDate"), 'calendarday', 'class="datecallink"').' ';
- } else $retstring .= ''.img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"').' ';
+ $retstringbuttom .= ' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');"';
+ $retstringbuttom .= '>'.img_object($langs->trans("SelectDate"), 'calendarday', 'class="datecallink"').'';
+ } else {
+ $retstringbuttom = ''.img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"').' ';
+ }
+ $retstring = $retstringbuttom.$retstring;
$retstring .= ' '."\n";
$retstring .= ' '."\n";
@@ -5744,7 +5747,7 @@ class Form
if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS))
{
$retstring .= "
- showOn: 'button',
+ showOn: 'button', /* both has problem with autocompletion */
buttonImage: '".DOL_URL_ROOT."/theme/".$conf->theme."/img/object_calendarday.png',
buttonImageOnly: true";
}
@@ -5754,7 +5757,7 @@ class Form
}
// Zone de saisie manuelle de la date
- $retstring .= '';
+ $retstring .= '
';
$retstring .= ' ";*/
} else {
- $retstring .= ''.img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"').' ';
+ $retstringbutton = ''.img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"').' ';
+ $retsring = $retstringbutton.$retstring;
}
$retstring .= '
';
@@ -6497,8 +6501,7 @@ class Form
$value = $tmpvalue;
$disabled = ''; $style = '';
}
- if (!empty($disablebademail))
- {
+ if (!empty($disablebademail)) {
if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value))
|| ($disablebademail == 2 && preg_match('/---/', $value)))
{
@@ -6507,8 +6510,7 @@ class Form
}
}
- if ($key_in_label)
- {
+ if ($key_in_label) {
if (empty($nohtmlescape)) $selectOptionValue = dol_escape_htmltag($key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value));
else $selectOptionValue = $key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value);
} else {
diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
index 512e38072d0..b95f73506b9 100644
--- a/htdocs/core/class/html.formaccounting.class.php
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -427,7 +427,7 @@ class FormAccounting extends Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Return list of auxilary thirdparty accounts
+ * Return list of auxilary accounts. Cumulate list from customers, suppliers and users.
*
* @param string $selectid Preselected pcg_type
* @param string $htmlname Name of field in html form
@@ -435,24 +435,27 @@ class FormAccounting extends Form
* @param string $morecss More css
* @return string String with HTML select
*/
- public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth200')
+ public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth250')
{
// phpcs:enable
$aux_account = array();
- // Auxiliary customer account
- $sql = "SELECT DISTINCT code_compta, nom ";
+ // Auxiliary thirdparties account
+ $sql = "SELECT code_compta, code_compta_fournisseur, nom as name";
$sql .= " FROM ".MAIN_DB_PREFIX."societe";
$sql .= " WHERE entity IN (".getEntity('societe').")";
- $sql .= " ORDER BY code_compta";
+ $sql .= " AND client IN (1,3) OR fournisseur = 1";
dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if (!empty($obj->code_compta)) {
- $aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->nom.')';
+ $aux_account[$obj->code_compta] = $obj->code_compta.'
('.$obj->name.') ';
+ }
+ if (!empty($obj->code_compta_fournisseur)) {
+ $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.'
('.$obj->name.') ';
}
}
} else {
@@ -460,26 +463,9 @@ class FormAccounting extends Form
dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR);
return -1;
}
- $this->db->free($resql);
- // Auxiliary supplier account
- $sql = "SELECT DISTINCT code_compta_fournisseur, nom ";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe";
- $sql .= " WHERE entity IN (".getEntity('societe').")";
- $sql .= " ORDER BY code_compta_fournisseur";
- dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql) {
- while ($obj = $this->db->fetch_object($resql)) {
- if ($obj->code_compta_fournisseur != "") {
- $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')';
- }
- }
- } else {
- $this->error = "Error ".$this->db->lasterror();
- dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR);
- return -1;
- }
+ ksort($aux_account);
+
$this->db->free($resql);
// Auxiliary user account
@@ -492,7 +478,7 @@ class FormAccounting extends Form
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if (!empty($obj->accountancy_code)) {
- $aux_account[$obj->accountancy_code] = $obj->accountancy_code.' ('.dolGetFirstLastname($obj->firstname, $obj->lastname).')';
+ $aux_account[$obj->accountancy_code] = $obj->accountancy_code.'
('.dolGetFirstLastname($obj->firstname, $obj->lastname).') ';
}
}
} else {
diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php
index 26e184eb614..d9d0442e49e 100644
--- a/htdocs/core/class/html.formcompany.class.php
+++ b/htdocs/core/class/html.formcompany.class.php
@@ -829,7 +829,7 @@ class FormCompany extends Form
*
* @param string $selected Preselected value
* @param string $htmlname HTML select name
- * @param string $fields Fields
+ * @param array $fields Array with key of fields to refresh after selection
* @param int $fieldsize Field size
* @param int $disableautocomplete 1 To disable ajax autocomplete features (browser autocomplete may still occurs)
* @param string $moreattrib Add more attribute on HTML input field
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 1b29af772a7..6c052a3999c 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -855,9 +855,16 @@ class FormMail extends Form
$out .= ''."\n";
if (count($listofpaths)) {
foreach ($listofpaths as $key => $val) {
+ $relativepathtofile = substr($val, (strlen(DOL_DATA_ROOT) - strlen($val)));
+ if ($conf->entity > 1) {
+ $relativepathtofile = str_replace($conf->entity.'/', '', $relativepathtofile);
+ }
+ // Try to extract data from full path
+ $formfile_params = array();
+ preg_match('#^(/)(\w+)(/)(.+)$#', $relativepathtofile, $formfile_params);
+
$out .= '
';
// Preview of attachment
- preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT) - strlen($val))), $formfile_params);
$out .= img_mime($listofnames[$key]).' '.$listofnames[$key];
$out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]);
if (!$this->withfilereadonly) {
diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php
index 19965250727..534d6b5803e 100644
--- a/htdocs/core/class/interfaces.class.php
+++ b/htdocs/core/class/interfaces.class.php
@@ -179,20 +179,29 @@ class Interfaces
$objMod = new $modName($this->db);
if ($objMod)
{
+ $dblevelbefore = $this->db->transaction_opened;
+
$result = 0;
- if (method_exists($objMod, 'runTrigger')) // New method to implement
- {
+ if (method_exists($objMod, 'runTrigger')) { // New method to implement
//dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG);
$result = $objMod->runTrigger($action, $object, $user, $langs, $conf);
- } elseif (method_exists($objMod, 'run_trigger')) // Deprecated method
- {
+ } elseif (method_exists($objMod, 'run_trigger')) { // Deprecated method
dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING);
$result = $objMod->run_trigger($action, $object, $user, $langs, $conf);
} else {
dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR);
}
+ $dblevelafter = $this->db->transaction_opened;
+
+ if ($dblevelbefore != $dblevelafter) {
+ $errormessage = "Error, the balance begin/close of db transactions has been broken into trigger ".$modName." with action=".$action." before=".$dblevelbefore." after=".$dblevelafter;
+ $this->errors[] = $errormessage;
+ dol_syslog($errormessage, LOG_ERR);
+ $result = -1;
+ }
+
if ($result > 0)
{
// Action OK
diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php
index de19f674659..9f4e69dcadf 100644
--- a/htdocs/core/js/lib_foot.js.php
+++ b/htdocs/core/js/lib_foot.js.php
@@ -65,7 +65,7 @@ print "jQuery(document).ready(function () {\n";
if (empty($conf->dol_no_mouse_hover)) {
print 'jQuery(".classfortooltip").tooltip({
- show: { collision: "flipfit", effect:"toggle", delay:75, duration:150 },
+ show: { collision: "flipfit", effect:"toggle", delay:50, duration: 20 },
hide: { delay: 250, duration: 20 },
tooltipClass: "mytooltip",
content: function () {
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index 4722d5c5cbc..92748f8e26f 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -253,7 +253,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
* This use the jQuery "autocomplete" function.
*
* @param string $htmlname HTML name of input field
- * @param string $fields Other fields to autocomplete
+ * @param array $fields Array of key of fields to autocomplete
* @param string $url URL for ajax request : /chemin/fichier.php
* @param string $option More parameters on URL request
* @param int $minLength Minimum number of chars to trigger that Ajax search
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 8318291753f..6a549c6e95b 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -672,20 +672,28 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options =
if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) $out = '';
}
break;
- case 'nohtml':
+ case 'nohtml': // No html
$out = dol_string_nohtmltag($out, 0);
break;
- case 'alpha': // No html and no " and no ../
+ case 'alpha': // No html and no ../ and "
case 'alphanohtml': // Recommended for most scalar parameters and search parameters
if (!is_array($out)) {
// '"' is dangerous because param in url can close the href= or src= and add javascript functions.
// '../' is dangerous because it allows dir transversals
- $out = str_replace(array('"', '"'), "''", trim($out));
+ $out = str_replace(array('"', '"'), '', trim($out));
$out = str_replace(array('../'), '', $out);
// keep lines feed
$out = dol_string_nohtmltag($out, 0);
}
break;
+ case 'alphawithlgt': // No " and no ../ but we keep < > tags. Can be used for email string like "Name
"
+ if (!is_array($out)) {
+ // '"' is dangerous because param in url can close the href= or src= and add javascript functions.
+ // '../' is dangerous because it allows dir transversals
+ $out = str_replace(array('"', '"'), '', trim($out));
+ $out = str_replace(array('../'), '', $out);
+ }
+ break;
case 'restricthtml': // Recommended for most html textarea
$out = dol_string_onlythesehtmltags($out, 0, 1, 1);
break;
@@ -5480,6 +5488,10 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
$isacompany = $thirdparty_buyer->isACompany();
if ($isacompany)
{
+ if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID) && !isValidVATID($thirdparty_buyer)) {
+ //print 'VATRULE 6';
+ return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice);
+ }
//print 'VATRULE 3';
return 0;
} else {
diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php
index 92a767a23ea..5d3381b2719 100644
--- a/htdocs/core/tpl/card_presend.tpl.php
+++ b/htdocs/core/tpl/card_presend.tpl.php
@@ -196,7 +196,7 @@ if ($action == 'presend')
}
$formmail->withto = $liste;
- $formmail->withtofree = (GETPOSTISSET('sendto') ? (GETPOST('sendto') ? GETPOST('sendto') : '1') : '1');
+ $formmail->withtofree = (GETPOSTISSET('sendto') ? (GETPOST('sendto', 'alphawithlgt') ? GETPOST('sendto', 'alphawithlgt') : '1') : '1');
$formmail->withtocc = $liste;
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
$formmail->withtopic = $topicmail;
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 5464116c1ed..ee8fa746107 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -891,11 +891,17 @@ class CommandeFournisseur extends CommonOrder
* Class invoiced the supplier order
*
* @param User $user Object user making the change
- * @return int <0 if KO, >0 if KO
+ * @return int <0 if KO, 0 if already billed, >0 if OK
*/
public function classifyBilled(User $user)
{
$error = 0;
+
+ if ($this->billed)
+ {
+ return 0;
+ }
+
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur SET billed = 1';
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index c3ed206c9c1..c00e1d2d6e2 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -1610,7 +1610,7 @@ if ($action == 'create')
print $societe->getNomUrl(1);
print ' ';
} else {
- print $form->select_company((empty($socid) ? '' : $socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
+ print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
// reload page to retrieve customer informations
if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE))
{
@@ -1672,6 +1672,7 @@ if ($action == 'create')
{
$langs->load("bank");
print ''.$langs->trans('BankAccount').' ';
+ print img_picto('', 'bank_account', 'class="paddingrightonly"');
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print ' ';
}
@@ -1683,7 +1684,7 @@ if ($action == 'create')
$langs->load('projects');
print ''.$langs->trans('Project').' ';
- $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
+ print img_picto('', 'project').$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
print ' id).'"> ';
print ' ';
}
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index 8b4e55a6872..24b35896498 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -656,10 +656,10 @@ if (empty($reshook))
if ($ret < 0) $error++;
$dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
- $datedue = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']);
+ $datedue = dol_mktime(12, 0, 0, GETPOST('echmonth', 'int'), GETPOST('echday', 'int'), GETPOST('echyear', 'int'));
// Replacement invoice
- if ($_POST['type'] == FactureFournisseur::TYPE_REPLACEMENT)
+ if (GETPOST('type') == FactureFournisseur::TYPE_REPLACEMENT)
{
if (empty($dateinvoice)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('DateInvoice')), null, 'errors');
@@ -713,7 +713,7 @@ if (empty($reshook))
}
// Credit note invoice
- if ($_POST['type'] == FactureFournisseur::TYPE_CREDIT_NOTE)
+ if (GETPOST('type') == FactureFournisseur::TYPE_CREDIT_NOTE)
{
$sourceinvoice = GETPOST('fac_avoir', 'int');
if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE))
@@ -837,7 +837,7 @@ if (empty($reshook))
}
// Standard or deposit
- if ($_POST['type'] == FactureFournisseur::TYPE_STANDARD || $_POST['type'] == FactureFournisseur::TYPE_DEPOSIT)
+ if (GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT)
{
if (GETPOST('socid', 'int') < 1)
{
@@ -869,11 +869,12 @@ if (empty($reshook))
{
$tmpproject = GETPOST('projectid', 'int');
- // Creation facture
- $object->ref = $_POST['ref'];
- $object->ref_supplier = $_POST['ref_supplier'];
- $object->socid = $_POST['socid'];
- $object->libelle = $_POST['label'];
+ // Creation invoice
+ $object->ref = GETPOST('ref', 'nohtml');
+ $object->ref_supplier = GETPOST('ref_supplier', 'nohtml');
+ $object->socid = GETPOST('socid', 'int');
+ $object->libelle = GETPOST('label', 'nohtml'); // deprecated
+ $object->label = GETPOST('label', 'nohtml');
$object->date = $dateinvoice;
$object->date_echeance = $datedue;
$object->note_public = GETPOST('note_public', 'restricthtml');
@@ -894,7 +895,7 @@ if (empty($reshook))
$object->fetch_thirdparty();
// If creation from another object of another module
- if (!$error && $_POST['origin'] && $_POST['originid'])
+ if (!$error && GETPOST('origin', 'alpha') && GETPOST('originid'))
{
// Parse element/subelement (ex: project_task)
$element = $subelement = GETPOST('origin', 'alpha');
@@ -1385,7 +1386,9 @@ if (empty($reshook))
$fk_unit = GETPOST('units', 'alpha');
- $tva_tx = price2num($tva_tx); // When vat is text input field
+ if (!preg_match('/\((.*)\)/', $tva_tx)) {
+ $tva_tx = price2num($tva_tx); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1'
+ }
// Local Taxes
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
@@ -1805,7 +1808,7 @@ if ($action == 'create')
print $societe->getNomUrl(1);
print ' ';
} else {
- print $form->select_company($societe->id, 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
+ print img_picto('', 'company').$form->select_company($societe->id, 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
// reload page to retrieve supplier informations
if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE))
{
@@ -2020,7 +2023,7 @@ if ($action == 'create')
print ''."\n";
@@ -2071,17 +2074,7 @@ if ($action == 'create')
if (!empty($conf->banque->enabled))
{
print ''.$langs->trans('BankAccount').' ';
- $form->select_comptes((GETPOSTISSET('fk_account') ?GETPOST('fk_account', 'alpha') : $fk_account), 'fk_account', 0, '', 1);
- print ' ';
- }
-
- // Multicurrency
- if (!empty($conf->multicurrency->enabled))
- {
- print '';
- print ''.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).' ';
- print '';
- print $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ?GETPOST('multicurrency_code', 'alpha') : $currency_code), 'multicurrency_code');
+ print img_picto('', 'bank_account').$form->select_comptes((GETPOSTISSET('fk_account') ?GETPOST('fk_account', 'alpha') : $fk_account), 'fk_account', 0, '', 1, '', 0, '', 1);
print ' ';
}
@@ -2092,7 +2085,7 @@ if ($action == 'create')
$langs->load('projects');
print ''.$langs->trans('Project').' ';
- $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
+ print img_picto('', 'project').$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
print ' ';
}
@@ -2106,6 +2099,16 @@ if ($action == 'create')
print ' ';
}
+ // Multicurrency
+ if (!empty($conf->multicurrency->enabled))
+ {
+ print '