|
@@ -109,7 +109,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))
|
|
|
$sql = "SELECT f.rowid, f.ref, f.type, f.situation_cycle_ref, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty,";
|
|
|
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code, fd.info_bits,";
|
|
|
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,";
|
|
|
-if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
|
|
+if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
|
|
|
$sql .= " spe.accountancy_code_customer as code_compta,";
|
|
|
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
|
|
|
} else {
|
|
@@ -117,26 +117,26 @@ if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
|
|
$sql .= " s.code_compta_fournisseur,";
|
|
|
}
|
|
|
$sql .= " p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
|
|
|
-if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
|
|
+if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
|
|
|
$sql .= " ppe.accountancy_code_sell";
|
|
|
} else {
|
|
|
$sql .= " p.accountancy_code_sell";
|
|
|
}
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
|
|
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product";
|
|
|
-if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
|
|
+if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
|
|
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
|
|
|
}
|
|
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
|
|
|
$sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
|
|
|
$sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
|
|
|
-if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
|
|
+if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
|
|
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
|
|
}
|
|
|
$sql .= " WHERE fd.fk_code_ventilation > 0";
|
|
|
$sql .= " AND f.entity IN (".getEntity('invoice', 0).')'; // We don't share object for accountancy, we use source object sharing
|
|
|
$sql .= " AND f.fk_statut > 0";
|
|
|
-if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Non common setup
|
|
|
+if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { // Non common setup
|
|
|
$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
|
|
|
} else {
|
|
|
$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
|
|
@@ -146,8 +146,8 @@ if ($date_start && $date_end) {
|
|
|
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
|
|
}
|
|
|
// Define begin binding date
|
|
|
-if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
|
|
|
- $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
|
|
|
+if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
|
|
|
+ $sql .= " AND f.datef >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'";
|
|
|
}
|
|
|
// Already in bookkeeping or not
|
|
|
if ($in_bookkeeping == 'already') {
|
|
@@ -177,8 +177,8 @@ if ($result) {
|
|
|
$num = $db->num_rows($result);
|
|
|
|
|
|
// Variables
|
|
|
- $cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "")) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined';
|
|
|
- $cpttva = (!empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined';
|
|
|
+ $cptcli = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER', 'NotDefined');
|
|
|
+ $cpttva = getDolGlobalString('ACCOUNTING_VAT_SOLD_ACCOUNT', 'NotDefined');
|
|
|
|
|
|
$i = 0;
|
|
|
while ($i < $num) {
|
|
@@ -190,9 +190,9 @@ if ($result) {
|
|
|
$compta_prod = $obj->compte;
|
|
|
if (empty($compta_prod)) {
|
|
|
if ($obj->product_type == 0) {
|
|
|
- $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined';
|
|
|
+ $compta_prod = getDolGlobalString('ACCOUNTING_PRODUCT_SOLD_ACCOUNT', 'NotDefined');
|
|
|
} else {
|
|
|
- $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined';
|
|
|
+ $compta_prod = getDolGlobalString('ACCOUNTING_SERVICE_SOLD_ACCOUNT', 'NotDefined');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -257,7 +257,7 @@ if ($result) {
|
|
|
// It also seems that credit notes on situation invoices are correctly saved (but it depends on the version used in fact).
|
|
|
// For credit notes, we hope to have situation_ratio = 1 so the compensation has no effect to avoid introducing troubles with credit notes.
|
|
|
$total_ttc = $obj->total_ttc * $situation_ratio;
|
|
|
- if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY) && $obj->retained_warranty > 0) {
|
|
|
+ if (getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0) {
|
|
|
$retained_warranty = (double) price2num($total_ttc * $obj->retained_warranty / 100, 'MT');
|
|
|
$tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty;
|
|
|
$total_ttc -= $retained_warranty;
|
|
@@ -315,11 +315,11 @@ if ($action == 'writebookkeeping') {
|
|
|
$invoicestatic = new Facture($db);
|
|
|
$accountingaccountcustomer = new AccountingAccount($db);
|
|
|
|
|
|
- $accountingaccountcustomer->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true);
|
|
|
+ $accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true);
|
|
|
|
|
|
$accountingaccountcustomerwarranty = new AccountingAccount($db);
|
|
|
|
|
|
- $accountingaccountcustomerwarranty->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY, true);
|
|
|
+ $accountingaccountcustomerwarranty->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'), true);
|
|
|
|
|
|
foreach ($tabfac as $key => $val) { // Loop on each invoice
|
|
|
$errorforline = 0;
|
|
@@ -381,7 +381,7 @@ if ($action == 'writebookkeeping') {
|
|
|
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
|
|
|
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
|
|
|
|
|
- $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY;
|
|
|
+ $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY');
|
|
|
$bookkeeping->label_compte = $accountingaccountcustomerwarranty->label;
|
|
|
|
|
|
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty");
|
|
@@ -430,7 +430,7 @@ if ($action == 'writebookkeeping') {
|
|
|
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
|
|
|
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
|
|
|
|
|
- $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
|
|
+ $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER');
|
|
|
$bookkeeping->label_compte = $accountingaccountcustomer->label;
|
|
|
|
|
|
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount");
|
|
@@ -488,7 +488,7 @@ if ($action == 'writebookkeeping') {
|
|
|
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
|
|
|
$bookkeeping->thirdparty_code = $companystatic->code_client;
|
|
|
|
|
|
- if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) {
|
|
|
+ if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT')) {
|
|
|
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) {
|
|
|
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
|
|
|
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
|
@@ -657,7 +657,7 @@ $form = new Form($db);
|
|
|
|
|
|
// Export
|
|
|
if ($action == 'exportcsv') { // ISO and not UTF8 !
|
|
|
- $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
|
|
+ $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV');
|
|
|
|
|
|
$filename = 'journal';
|
|
|
$type_export = 'journal';
|
|
@@ -704,7 +704,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
|
|
print '"'.$val["ref"].'"'.$sep;
|
|
|
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
|
|
|
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
|
|
|
- print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY).'"'.$sep;
|
|
|
+ print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).'"'.$sep;
|
|
|
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
|
|
|
print '"'.$langs->trans("Thirdparty").'"'.$sep;
|
|
|
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty").'"'.$sep;
|
|
@@ -723,7 +723,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
|
|
print '"'.$val["ref"].'"'.$sep;
|
|
|
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
|
|
|
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
|
|
|
- print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER).'"'.$sep;
|
|
|
+ print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')).'"'.$sep;
|
|
|
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
|
|
|
print '"'.$langs->trans("Thirdparty").'"'.$sep;
|
|
|
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Thirdparty").'"'.$sep;
|
|
@@ -800,7 +800,7 @@ if (empty($action) || $action == 'view') {
|
|
|
$exportlink = '';
|
|
|
$builddate = dol_now();
|
|
|
$description = $langs->trans("DescJournalOnlyBindedVisible").'<br>';
|
|
|
- if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
|
|
+ if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
|
|
|
$description .= $langs->trans("DepositsAreNotIncluded");
|
|
|
} else {
|
|
|
$description .= $langs->trans("DepositsAreIncluded");
|
|
@@ -815,7 +815,8 @@ if (empty($action) || $action == 'view') {
|
|
|
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
|
|
|
|
|
|
// Button to write into Ledger
|
|
|
- if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
|
|
|
+ $acctCustomerNotConfigured = in_array(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), ['','-1']);
|
|
|
+ if ($acctCustomerNotConfigured) {
|
|
|
print '<br><div class="warning">'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
|
|
|
$desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}');
|
|
|
$desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>', $desc);
|
|
@@ -823,10 +824,10 @@ if (empty($action) || $action == 'view') {
|
|
|
print '</div>';
|
|
|
}
|
|
|
print '<div class="tabsAction tabsActionNoBottom centerimp">';
|
|
|
- if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') {
|
|
|
+ if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') {
|
|
|
print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
|
|
|
}
|
|
|
- if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
|
|
|
+ if ($acctCustomerNotConfigured) {
|
|
|
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
|
|
|
} else {
|
|
|
if ($in_bookkeeping == 'notyet') {
|
|
@@ -950,7 +951,7 @@ if (empty($action) || $action == 'view') {
|
|
|
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
|
|
|
// Account
|
|
|
print "<td>";
|
|
|
- $accountoshow = length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY);
|
|
|
+ $accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'));
|
|
|
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
|
|
|
print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
|
|
|
} else {
|
|
@@ -980,7 +981,7 @@ if (empty($action) || $action == 'view') {
|
|
|
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
|
|
|
// Account
|
|
|
print "<td>";
|
|
|
- $accountoshow = length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER);
|
|
|
+ $accountoshow = length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'));
|
|
|
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
|
|
|
print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
|
|
|
} else {
|
|
@@ -1024,7 +1025,7 @@ if (empty($action) || $action == 'view') {
|
|
|
print "</td>";
|
|
|
// Subledger account
|
|
|
print "<td>";
|
|
|
- if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) {
|
|
|
+ if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT')) {
|
|
|
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) {
|
|
|
print length_accounta($tabcompany[$key]['code_compta']);
|
|
|
}
|