diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php
index 86ae7ea9b0a..4aad88df54d 100644
--- a/htdocs/accountancy/customer/index.php
+++ b/htdocs/accountancy/customer/index.php
@@ -207,8 +207,8 @@ for($i = 1; $i <= 12; $i ++) {
}
print '
' . $langs->trans("Total") . ' | ';
-$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,";
-$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,";
+$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,";
+$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
}
@@ -234,8 +234,20 @@ if ($resql) {
while ( $row = $db->fetch_row($resql)) {
- print '| ' . length_accountg($row[0]) . ' | ';
- print '' . $row[1] . ' | ';
+ print '
| ';
+ if ($row[0] == 'tobind')
+ {
+ print $langs->trans("Unknown");
+ }
+ else print length_accountg($row[0]);
+ print ' | ';
+ print '';
+ if ($row[0] == 'tobind')
+ {
+ print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
+ }
+ else print $row[1];
+ print ' | ';
for($i = 2; $i <= 12; $i ++) {
print '' . price($row[$i]) . ' | ';
}
@@ -264,8 +276,8 @@ for($i = 1; $i <= 12; $i ++) {
}
print '' . $langs->trans("Total") . ' |
';
-$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,";
-$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,";
+$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,";
+$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
}
@@ -291,7 +303,20 @@ if ($resql) {
while ( $row = $db->fetch_row($resql)) {
- print '| ' . length_accountg($row[0]) . ' | ';
+ print '
| ';
+ if ($row[0] == 'tobind')
+ {
+ print $langs->trans("Unknown");
+ }
+ else print length_accountg($row[0]);
+ print ' | ';
+ print '';
+ if ($row[0] == 'tobind')
+ {
+ print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
+ }
+ else print $row[1];
+ print ' | ';
print '' . $row[1] . ' | ';
for($i = 2; $i <= 12; $i ++) {
print '' . price($row[$i]) . ' | ';
@@ -360,6 +385,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
print "\n";
print '';
+
if (! empty($conf->margin->enabled)) {
print "
\n";
print '';
diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php
index 26fcf7a4606..d7d8d6d2bec 100644
--- a/htdocs/accountancy/expensereport/index.php
+++ b/htdocs/accountancy/expensereport/index.php
@@ -184,8 +184,8 @@ for($i = 1; $i <= 12; $i ++) {
}
print '
' . $langs->trans("Total") . ' |
';
-$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,";
-$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,";
+$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
+$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
}
@@ -207,9 +207,21 @@ if ($resql) {
while ( $row = $db->fetch_row($resql)) {
- print '| ' . length_accountg($row[0]) . ' | ';
- print '' . $row[1] . ' | ';
- for($i = 2; $i <= 12; $i ++) {
+ print '
| ';
+ if ($row[0] == 'tobind')
+ {
+ print $langs->trans("Unknown");
+ }
+ else print length_accountg($row[0]);
+ print ' | ';
+ print '';
+ if ($row[0] == 'tobind')
+ {
+ print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
+ }
+ else print $row[1];
+ print ' | ';
+ for($i = 2; $i <= 12; $i ++) {
print '' . price($row[$i]) . ' | ';
}
print '' . price($row[13]) . ' | ';
@@ -238,8 +250,8 @@ for($i = 1; $i <= 12; $i ++) {
}
print '' . $langs->trans("Total") . ' |
';
-$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,";
-$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,";
+$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
+$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
}
@@ -261,9 +273,21 @@ if ($resql) {
while ( $row = $db->fetch_row($resql)) {
- print '| ' . length_accountg($row[0]) . ' | ';
- print '' . $row[1] . ' | ';
- for($i = 2; $i <= 12; $i ++) {
+ print '
| ';
+ if ($row[0] == 'tobind')
+ {
+ print $langs->trans("Unknown");
+ }
+ else print length_accountg($row[0]);
+ print ' | ';
+ print '';
+ if ($row[0] == 'tobind')
+ {
+ print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
+ }
+ else print $row[1];
+ print ' | ';
+ for($i = 2; $i <= 12; $i ++) {
print '' . price($row[$i]) . ' | ';
}
print '' . price($row[13]) . ' | ';
diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php
index 71a21dffeab..6e44ab633d2 100644
--- a/htdocs/accountancy/journal/bankjournal.php
+++ b/htdocs/accountancy/journal/bankjournal.php
@@ -102,12 +102,15 @@ $idpays = $mysoc->country_id;
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,";
$sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,";
-$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop,";
-$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop";
+$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop_company,";
+$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop_user,";
+$sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier";
$sql .= " FROM " . MAIN_DB_PREFIX . "bank as b";
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'";
+$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'";
+$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid";
$sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal;
@@ -145,6 +148,7 @@ $result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
+ //print $sql;
// Variables
$account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word
@@ -170,13 +174,31 @@ if ($result) {
{
$obj = $db->fetch_object($result);
- // Set accountancy code (for bank and thirdparty)
+ $lineisapurchase = -1;
+ $lineisasale = -1;
+ // Old method to detect if it's a sale or purchase
+ if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') $lineisapurchase=1;
+ if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') $lineisasale=1;
+ // Try a more reliable method to detect if record is a supplier payment or a customer payment
+ if ($lineisapurchase < 0)
+ {
+ if ($obj->typeop_payment_supplier == 'payment_supplier') $lineisapurchase = 1;
+ }
+ if ($lineisasale < 0)
+ {
+ if ($obj->typeop_payment == 'payment') $lineisasale = 1;
+ }
+ //var_dump($obj->type_payment); var_dump($obj->type_payment_supplier);
+ //var_dump($lineisapurchase); //var_dump($lineisasale);
+
+ // Set accountancy code for bank
$compta_bank = $obj->account_number;
+ // Set accountancy code for thirdparty
$compta_soc = 'NotDefined';
- if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)')
+ if ($lineisapurchase > 0)
$compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier);
- if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)')
+ if ($lineisasale > 0)
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer);
$tabcompany[$obj->rowid] = array (
@@ -185,6 +207,7 @@ if ($result) {
'code_compta' => $compta_soc,
);
+ // Set accountancy code for user
$compta_user = (! empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee);
$tabuser[$obj->rowid] = array (
@@ -200,6 +223,7 @@ if ($result) {
$tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; // CHQ, VIR, LIQ, CB, ...
$tabpay[$obj->rowid]["ref"] = $obj->label; // By default. Not unique. May be changed later
$tabpay[$obj->rowid]["fk_bank"] = $obj->rowid;
+ $tabpay[$obj->rowid]["bank_account_ref"] = $obj->baref;
$tabpay[$obj->rowid]["fk_bank_account"] = $obj->fk_account;
if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) {
$tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]);
@@ -212,7 +236,7 @@ if ($result) {
//var_dump($tabpay);
// By default
- $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or old record with no links in bank_url.
+ $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url.
$tabtype[$obj->rowid] = 'unknown';
// get_url may return -1 which is not traversable
@@ -602,6 +626,8 @@ if (! $error && $action == 'writebookkeeping') {
}
}
+
+
// Export
if ($action == 'exportcsv') { // ISO and not UTF8 !
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
@@ -735,6 +761,22 @@ if (empty($action) || $action == 'view') {
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
+
+ // Test that setup is complete
+ $sql='SELECT COUNT(rowid) as nb FROM '.MAIN_DB_PREFIX.'bank_account WHERE fk_accountancy_journal IS NULL';
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $obj=$db->fetch_object($resql);
+ if ($obj->nb > 0)
+ {
+ print img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount");
+ print ' : '.$langs->trans("AccountancyAreaDescBank", 9, ''.$langs->transnoentitiesnoconv("MenuBankCash").'');
+ }
+ }
+ else dol_print_error($db);
+
+
// Button to write into Ledger
if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1'
|| empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1'
@@ -796,8 +838,10 @@ if (empty($action) || $action == 'view') {
// Bank
foreach ( $tabbq[$key] as $k => $mt )
{
+ //var_dump($tabpay[$key]);
+ print '';
print '
';
- print " | ";
+ print " | ";
print "" . $date . " | ";
print "" . $ref . " | ";
// Ledger account
@@ -818,11 +862,14 @@ if (empty($action) || $action == 'view') {
}
else print $accounttoshow;*/
print "";
- if ($val['soclib'] == '') {
- print "" . $langs->trans("Bank") . " - " . $reflabel . " | ";
- } else {
- print "" . $langs->trans("Bank") . " - " . $val['soclib'] . " | ";
+ print "";
+ //var_dump($tabpay[$key]);
+ print $langs->trans("Bank");
+ print ' '.$val['bank_account_ref'];
+ if (! empty($val['soclib'])) {
+ print " - " . $val['soclib'];
}
+ print " | ";
print "" . $val["type_payment"] . " | ";
print "" . ($mt >= 0 ? price($mt) : '') . " | ";
print "" . ($mt < 0 ? price(- $mt) : '') . " | ";
@@ -833,14 +880,15 @@ if (empty($action) || $action == 'view') {
if (is_array($tabtp[$key])) {
foreach ( $tabtp[$key] as $k => $mt ) {
if ($k != 'type') {
+ print '';
print '
';
- print " | ";
+ print " | ";
print "" . $date . " | ";
print "" . $ref . " | ";
// Ledger account
print "";
$account_ledger = $k;
-
+ // Try to force general ledger account depending on type
if ($tabtype[$key] == 'payment') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
if ($tabtype[$key] == 'payment_supplier') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
if ($tabtype[$key] == 'payment_expensereport') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
@@ -877,7 +925,11 @@ if (empty($action) || $action == 'view') {
{
if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined')
{
- print ''.$langs->trans("ThirdpartyAccountNotDefined").'';
+ /*var_dump($tabpay[$key]);
+ var_dump($tabtype[$key]);
+ var_dump($tabbq[$key]);*/
+ //print ''.$langs->trans("ThirdpartyAccountNotDefined").'';
+ print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown").'';
}
else print $accounttoshowsubledger;
}
@@ -892,8 +944,9 @@ if (empty($action) || $action == 'view') {
}
} else {
foreach ( $tabbq[$key] as $k => $mt ) {
+ print '';
print ' |
';
- print " | ";
+ print " | ";
print "" . $date . " | ";
print "" . $ref . " | ";
// Ledger account
@@ -936,7 +989,7 @@ $db->close();
* Return source for doc_ref of a bank transaction
*
* @param string $val Array of val
- * @param string $typerecord Type of record
+ * @param string $typerecord Type of record ('payment', 'payment_supplier', 'payment_expensereport', 'payment_vat', ...)
* @return string|unknown
*/
function getSourceDocRef($val, $typerecord)
diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php
index 96b250434ef..74f071836aa 100644
--- a/htdocs/accountancy/supplier/index.php
+++ b/htdocs/accountancy/supplier/index.php
@@ -183,8 +183,8 @@ for($i = 1; $i <= 12; $i ++) {
}
print '' . $langs->trans("Total") . ' |
';
-$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,";
-$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,";
+$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
+$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
}
@@ -206,8 +206,20 @@ if ($resql) {
while ( $row = $db->fetch_row($resql)) {
- print '| ' . length_accountg($row[0]) . ' | ';
- print '' . $row[1] . ' | ';
+ print '
| ';
+ if ($row[0] == 'tobind')
+ {
+ print $langs->trans("Unknown");
+ }
+ else print length_accountg($row[0]);
+ print ' | ';
+ print '';
+ if ($row[0] == 'tobind')
+ {
+ print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
+ }
+ else print $row[1];
+ print ' | ';
for($i = 2; $i <= 12; $i ++) {
print '' . price($row[$i]) . ' | ';
}
@@ -237,8 +249,8 @@ for($i = 1; $i <= 12; $i ++) {
}
print '' . $langs->trans("Total") . ' |
';
-$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,";
-$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,";
+$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
+$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
}
@@ -260,9 +272,21 @@ if ($resql) {
while ( $row = $db->fetch_row($resql)) {
- print '| ' . length_accountg($row[0]) . ' | ';
- print '' . $row[1] . ' | ';
- for($i = 2; $i <= 12; $i ++) {
+ print '
| ';
+ if ($row[0] == 'tobind')
+ {
+ print $langs->trans("Unknown");
+ }
+ else print length_accountg($row[0]);
+ print ' | ';
+ print '';
+ if ($row[0] == 'tobind')
+ {
+ print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
+ }
+ else print $row[1];
+ print ' | ';
+ for($i = 2; $i <= 12; $i ++) {
print '' . price($row[$i]) . ' | ';
}
print '' . price($row[13]) . ' | ';
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 32145f47d7c..97bc3417100 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -1142,7 +1142,7 @@ if ($id)
}
if ($id == 4) print ' | ';
- print '';
+ print ' | ';
if ($action != 'edit')
{
print '';
diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php
index 9ac33f1cc3d..65b38970a6e 100644
--- a/htdocs/admin/index.php
+++ b/htdocs/admin/index.php
@@ -70,13 +70,13 @@ if (! empty($conf->global->MAIN_MOTD_SETUPPAGE))
print $langs->trans("SetupDescription1").' ';
print $langs->trans("AreaForAdminOnly").' ';
-print $langs->trans("SetupDescription2", $langs->trans("MenuCompanySetup"), $langs->trans("Modules"))."
";
+print $langs->trans("SetupDescription2", $langs->transnoentities("MenuCompanySetup"), $langs->transnoentities("Modules"))."
";
print ' ';
// Show info setup company
if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete=1;
-print img_picto('','puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit'), $langs->trans("Setup"), $langs->trans("MenuCompanySetup"));
+print img_picto('','puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit'), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup"));
if (! empty($setupcompanynotcomplete))
{
$langs->load("errors");
@@ -88,7 +88,7 @@ print ' ';
print ' ';
// Show info setup module
-print img_picto('','puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->trans("Setup"), $langs->trans("Modules"));
+print img_picto('','puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules"));
if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled
{
$langs->load("errors");
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 538f07133c5..12804a5fab9 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -1548,17 +1548,30 @@ class Categorie extends CommonObject
dol_mkdir($dir);
}
- if (file_exists($dir))
- {
- $originImage = $dir . $file['name'];
+ if (file_exists($dir)) {
+ if (is_array($file['name']) && count($file['name']) > 0) {
+ for($i = 0; $i <= count($file['name']); $i ++) {
- // Cree fichier en taille origine
- dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0);
+ $originImage = $dir . $file['name'][$i];
- if (file_exists($originImage))
- {
- // Create thumbs
- $this->addThumbs($originImage);
+ // Cree fichier en taille origine
+ dol_move_uploaded_file($file['tmp_name'][$i], $originImage, 1, 0, 0);
+
+ if (file_exists($originImage)) {
+ // Create thumbs
+ $this->addThumbs($originImage);
+ }
+ }
+ } else {
+ $originImage = $dir . $file['name'];
+
+ // Cree fichier en taille origine
+ dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0);
+
+ if (file_exists($originImage)) {
+ // Create thumbs
+ $this->addThumbs($originImage);
+ }
}
}
}
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index e40070adbbc..de549889a91 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -3207,6 +3207,14 @@ else if ($id > 0 || ! empty($ref))
$facthatreplace->fetch($objectidnext);
print ' (' . $langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)) . ')';
}
+
+ if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) {
+ $discount = new DiscountAbsolute($db);
+ $result = $discount->fetch(0, $object->id);
+ if ($result > 0){
+ print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(), $discount->getNomUrl(1, 'discount')).' ';
+ }
+ }
print ' |
';
// Relative and absolute discounts
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index db6631300c4..c88d98c00ea 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -1355,7 +1355,6 @@ class FactureRec extends CommonInvoice
*/
class FactureLigneRec extends CommonInvoiceLine
{
-
public $element='facturedetrec';
public $table_element='facturedet_rec';
@@ -1364,36 +1363,40 @@ class FactureLigneRec extends CommonInvoiceLine
*
* @return int <0 if KO, >0 if OK
*/
- function delete()
+ function delete(User $user, $notrigger = false)
{
- global $conf,$langs,$user;
+ $error=0;
- $error=0;
+ $this->db->begin();
- $this->db->begin();
+ if (! $error) {
+ if (! $notrigger) {
+ // Call triggers
+ $result=$this->call_trigger('LINEBILLREC_DELETE', $user);
+ if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail
+ // End call triggers
+ }
+ }
- $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".($this->rowid > 0 ? $this->rowid : $this->id);
- dol_syslog(get_class($this)."::delete", LOG_DEBUG);
- if ($this->db->query($sql) )
- {
- // Call trigger
- $result=$this->call_trigger('LINEBILLREC_DELETE',$user);
- if ($result < 0)
- {
- $this->db->rollback();
- return -1;
- }
- // End call triggers
+ if (! $error)
+ {
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id;
- $this->db->commit();
- return 1;
- }
- else
- {
- $this->error=$this->db->error()." sql=".$sql;
- $this->db->rollback();
- return -1;
- }
+ $res = $this->db->query($sql);
+ if($res===false) {
+ $error++;
+ $this->errors[] = $this->db->lasterror();
+ }
+ }
+
+ // Commit or rollback
+ if ($error) {
+ $this->db->rollback();
+ return -1;
+ } else {
+ $this->db->commit();
+ return 1;
+ }
}
@@ -1551,4 +1554,6 @@ class FactureLigneRec extends CommonInvoiceLine
}
+=======
+>>>>>>> branch '6.0' of git@github.com:Dolibarr/dolibarr.git
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 572e59e737a..5c787f0a343 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -439,7 +439,6 @@ class Facture extends CommonInvoice
$sql.= ", ".(double) $this->multicurrency_tx;
$sql.=")";
- dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@@ -449,7 +448,6 @@ class Facture extends CommonInvoice
$this->ref='(PROV'.$this->id.')';
$sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET facnumber='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id;
- dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) $error++;
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index 8c2c7bdf7ec..6d89cd07cd4 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -665,7 +665,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
}
}
// Hook fields
-$parameters=array('arrayfields'=>$arrayfields);
+$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index 15a17feaea8..ad224fec97d 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -83,11 +83,12 @@ class Conf
$this->file = new stdClass();
$this->db = new stdClass();
$this->global = new stdClass();
- $this->mycompany = new stdClass();
- $this->admin = new stdClass();
+ $this->mycompany = new stdClass();
+ $this->admin = new stdClass();
$this->user = new stdClass();
$this->syslog = new stdClass();
$this->browser = new stdClass();
+ $this->medias = new stdClass();
$this->multicompany = new stdClass();
//! Charset for HTML output and for storing data in memory
@@ -96,7 +97,7 @@ class Conf
// First level object
// TODO Remove this part.
$this->expedition_bon = new stdClass();
- $this->livraison_bon = new stdClass();
+ $this->livraison_bon = new stdClass();
$this->fournisseur = new stdClass();
$this->product = new stdClass();
$this->service = new stdClass();
@@ -106,12 +107,12 @@ class Conf
$this->propal = new stdClass();
$this->facture = new stdClass();
$this->contrat = new stdClass();
- $this->usergroup = new stdClass();
+ $this->usergroup = new stdClass();
$this->adherent = new stdClass();
$this->bank = new stdClass();
$this->notification = new stdClass();
$this->mailing = new stdClass();
- $this->expensereport = new stdClass();
+ $this->expensereport = new stdClass();
}
@@ -322,6 +323,10 @@ class Conf
$this->propal->dir_output=$rootfordata."/propale";
$this->propal->dir_temp=$rootfordata."/propale/temp";
+ // For medias storage
+ $this->medias->multidir_output = array($this->entity => $rootfordata."/medias");
+ $this->medias->multidir_temp = array($this->entity => $rootfordata."/medias/temp");
+
// Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
// Sous module bons d'expedition
diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php
index 41c5d67688c..443534eb1b3 100644
--- a/htdocs/core/class/discount.class.php
+++ b/htdocs/core/class/discount.class.php
@@ -64,7 +64,7 @@ class DiscountAbsolute
* @param int $fk_facture_source fk_facture_source
* @return int <0 if KO, =0 if not found, >0 if OK
*/
- function fetch($rowid,$fk_facture_source=0)
+ function fetch($rowid, $fk_facture_source=0)
{
global $conf;
@@ -386,7 +386,7 @@ class DiscountAbsolute
function getSumDepositsUsed($invoice, $multicurrency=0)
{
dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG);
-
+
if ($invoice->element == 'facture' || $invoice->element == 'invoice')
{
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
@@ -407,7 +407,7 @@ class DiscountAbsolute
dol_print_error($this->error);
return -1;
}
-
+
$resql=$this->db->query($sql);
if ($resql)
{
@@ -432,7 +432,7 @@ class DiscountAbsolute
function getSumCreditNotesUsed($invoice, $multicurrency=0)
{
dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG);
-
+
if ($invoice->element == 'facture' || $invoice->element == 'invoice')
{
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
@@ -453,7 +453,7 @@ class DiscountAbsolute
dol_print_error($this->error);
return -1;
}
-
+
$resql=$this->db->query($sql);
if ($resql)
{
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index c686d5e3904..1cc0c209591 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -1964,7 +1964,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
if ($modulepart == 'medias' && !empty($dolibarr_main_data_root))
{
$accessallowed=1;
- $original_file=$dolibarr_main_data_root.'/medias/'.$original_file;
+ $original_file=$conf->medias->multidir_output[$entity].'/'.$original_file;
}
// Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log
elseif ($modulepart == 'logs' && !empty($dolibarr_main_data_root))
diff --git a/htdocs/core/modules/syslog/mod_syslog_syslog.php b/htdocs/core/modules/syslog/mod_syslog_syslog.php
index e0283ac9a9f..1f2f499fbac 100644
--- a/htdocs/core/modules/syslog/mod_syslog_syslog.php
+++ b/htdocs/core/modules/syslog/mod_syslog_syslog.php
@@ -49,7 +49,7 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
public function isActive()
{
global $conf;
-
+
// This function does not exists on some ISP (Ex: Free in France)
if (!function_exists('openlog')) return 0;
@@ -81,15 +81,15 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
*/
public function checkConfiguration()
{
- global $langs;
+ global $conf, $langs;
$errors = array();
- $facility = SYSLOG_FACILITY;
+ $facility = constant($conf->global->SYSLOG_FACILITY);
if ($facility)
{
// Only LOG_USER supported on Windows
- if (! empty($_SERVER["WINDIR"])) $facility='LOG_USER';
+ if (! empty($_SERVER["WINDIR"])) $facility=constant('LOG_USER');
dol_syslog("admin/syslog: facility ".$facility);
}
diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php
index 38d9ce62f50..36d71568566 100644
--- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php
+++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php
@@ -313,7 +313,7 @@ class doc_generic_user_odt extends ModelePDFUser
{
$socobject=$object->client;
}
-
+
// Open and load template
require_once ODTPHP_PATH.'odf.php';
try {
@@ -332,7 +332,7 @@ class doc_generic_user_odt extends ModelePDFUser
$this->error=$e->getMessage();
return -1;
}
-
+
// Make substitutions into odt
$array_user=$this->get_substitutionarray_user($object,$outputlangs);
$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
@@ -366,7 +366,7 @@ class doc_generic_user_odt extends ModelePDFUser
{
}
}
-
+
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)
@@ -422,12 +422,13 @@ class doc_generic_user_odt extends ModelePDFUser
return -1;
}
- function get_substitutionarray_object($object,$outputlangs) {
+ function get_substitutionarray_object($object,$outputlangs,$array_key='object') {
+ $array_other=array();
foreach($object as $key => $value) {
- if(!is_array($value) && !is_object($value)) {
- $array_other['object_'.$key] = $value;
+ if (!is_array($value) && !is_object($value)) {
+ $array_other[$array_key.'_'.$key] = $value;
}
- }
+ }
return $array_other;
}
diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php
index d6defba0fa9..c7b3ea7342f 100644
--- a/htdocs/core/tpl/contacts.tpl.php
+++ b/htdocs/core/tpl/contacts.tpl.php
@@ -35,13 +35,13 @@ elseif ($module == 'project') { $permission=$user->rights->projet->creer; }
elseif ($module == 'action') { $permission=$user->rights->agenda->myactions->create; }
elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer; }
elseif ($module == 'project_task') { $permission=$user->rights->projet->creer; }
-elseif (! isset($permission) && isset($user->rights->$module->creer))
-{
- $permission=$user->rights->$module->creer;
+elseif (! isset($permission) && isset($user->rights->$module->creer))
+{
+ $permission=$user->rights->$module->creer;
}
elseif (! isset($permission) && isset($user->rights->$module->write))
{
- $permission=$user->rights->$module->write;
+ $permission=$user->rights->$module->write;
}
$formcompany= new FormCompany($db);
@@ -55,8 +55,8 @@ $userstatic=new User($db);