Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2023-05-02 06:12:50 +02:00
commit 017a7cb098
2 changed files with 63 additions and 22 deletions

View File

@ -7,7 +7,7 @@
* Copyright (C) 2013-2022 Open-DSI <support@open-dsi.fr>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2017-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2017-2023 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Eric Seigne <eric.seigne@cap-rel.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
@ -147,8 +147,8 @@ if ($date_start && $date_end) {
$sql .= " AND b.dateo >= '".$db->idate($date_start)."' AND b.dateo <= '".$db->idate($date_end)."'";
}
// Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND b.dateo >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
if (getDolGlobalInt('ACCOUNTING_DATE_START_BINDING')) {
$sql .= " AND b.dateo >= '".$db->idate(getDolGlobalInt('ACCOUNTING_DATE_START_BINDING'))."'";
}
// Already in bookkeeping or not
if ($in_bookkeeping == 'already') {
@ -195,13 +195,13 @@ if ($result) {
//print $sql;
// Variables
$account_supplier = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word
$account_customer = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word
$account_employee = (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word
$account_pay_vat = (!empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word
$account_pay_donation = (!empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word
$account_pay_subscription = (!empty($conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT) ? $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word
$account_transfer = (!empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined'); // NotDefined is a reserved word
$account_supplier = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER', 'NotDefined'); // NotDefined is a reserved word
$account_customer = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER', 'NotDefined'); // NotDefined is a reserved word
$account_employee = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'NotDefined'); // NotDefined is a reserved word
$account_pay_vat = getDolGlobalString('ACCOUNTING_VAT_PAY_ACCOUNT', 'NotDefined'); // NotDefined is a reserved word
$account_pay_donation = getDolGlobalString('DONATION_ACCOUNTINGACCOUNT', 'NotDefined'); // NotDefined is a reserved word
$account_pay_subscription = getDolGlobalString('ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT', 'NotDefined'); // NotDefined is a reserved word
$account_transfer = getDolGlobalString('ACCOUNTING_ACCOUNT_TRANSFER_CASH', 'NotDefined'); // NotDefined is a reserved word
$tabcompany = array();
$tabuser = array();
@ -912,7 +912,7 @@ if (!$error && $action == 'writebookkeeping') {
// Export
if ($action == 'exportcsv') { // ISO and not UTF8 !
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV');
$filename = 'journal';
$type_export = 'journal';
@ -983,13 +983,13 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print '"'.$val["type_payment"].'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
if ($tabtype[$key] == 'payment_supplier') {
print '"'.$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER.'"'.$sep;
print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER').'"'.$sep;
} elseif ($tabtype[$key] == 'payment') {
print '"'.$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER.'"'.$sep;
print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER').'"'.$sep;
} elseif ($tabtype[$key] == 'payment_expensereport') {
print '"'.$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT.'"'.$sep;
print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep;
} elseif ($tabtype[$key] == 'payment_salary') {
print '"'.$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT.'"'.$sep;
print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep;
} else {
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
}
@ -1014,8 +1014,8 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print '"'.$key.'"'.$sep;
print '"'.$date.'"'.$sep;
print '"'.$val["type_payment"].'"'.$sep;
print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep;
print '"'.length_accounta($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep;
print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep;
print '"'.length_accounta(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep;
print "".$sep;
print '"'.$reflabel.'"'.$sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
@ -1088,9 +1088,9 @@ if (empty($action) || $action == 'view') {
// Button to write into Ledger
if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1'
|| ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1'
|| empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') {
if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1'
|| getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1'
|| getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1') {
print ($desc ? '' : '<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);
@ -1105,8 +1105,8 @@ if (empty($action) || $action == 'view') {
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'
|| ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1'
|| getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
} else {
if ($in_bookkeeping == 'notyet') {

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2023 Romain Neil <contact@romain-neil.fr>
*
* This program is free software you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -221,6 +222,22 @@ class Documents extends DolibarrApi
if ($result <= 0) {
throw new RestException(500, 'Error generating document');
}
} elseif ($modulepart == 'contrat' || $modulepart == 'contract') {
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
$this->contract = new Contrat($this->db);
$result = $this->contract->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
if (!$result) {
throw new RestException(404, 'Contract not found');
}
$templateused = $doctemplate ? $doctemplate : $this->contract->model_pdf;
$result = $this->contract->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0) {
throw new RestException(500, 'Error generating document missing doctemplate parameter');
}
} else {
throw new RestException(403, 'Generation not available for this modulepart');
}
@ -502,6 +519,17 @@ class Documents extends DolibarrApi
// $upload_dir = $conf->ecm->dir_output;
// $type = 'all';
// $recursive = 0;
} elseif ($modulepart == 'contrat' || $modulepart == 'contract') {
$modulepart = 'contrat';
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
$object = new Contrat($this->db);
$result = $object->fetch($id, $ref);
if (!$result) {
throw new RestException(404, 'Contract not found');
}
$upload_dir = $conf->contrat->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'contract');
} else {
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
}
@ -667,11 +695,19 @@ class Documents extends DolibarrApi
$modulepart = 'propale';
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$object = new Propal($this->db);
} elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') {
$modulepart = 'agenda';
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
$object = new ActionComm($this->db);
} elseif ($modulepart == 'contact' || $modulepart == 'socpeople') {
$modulepart = 'contact';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$object = new Contact($this->db);
$fetchbyid = true;
} elseif ($modulepart == 'contrat' || $modulepart == 'contract') {
$modulepart = 'contrat';
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
$object = new Contrat($this->db);
} else {
// TODO Implement additional moduleparts
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
@ -752,6 +788,11 @@ class Documents extends DolibarrApi
throw new RestException(500, "File with name '".$original_file."' already exists.");
}
// in case temporary directory admin/temp doesn't exist
if (!dol_is_dir(dirname($destfiletmp))) {
dol_mkdir(dirname($destfiletmp));
}
$fhandle = @fopen($destfiletmp, 'w');
if ($fhandle) {
$nbofbyteswrote = fwrite($fhandle, $newfilecontent);