diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 9720399fb5e..3134dfa95ba 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -441,26 +441,40 @@ class AccountingJournal extends CommonObject $langs->loadLangs(array("assets")); // Clean parameters - if (empty($type)) $type = 'view'; - if (empty($in_bookkeeping)) $in_bookkeeping = 'notyet'; + if (empty($type)) { + $type = 'view'; + } + if (empty($in_bookkeeping)) { + $in_bookkeeping = 'notyet'; + } $sql = ""; - if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { + + // FIXME sql error with Mysql 5.7 + /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { $sql .= "WITH in_accounting_bookkeeping(fk_docdet) AS ("; $sql .= " SELECT DISTINCT fk_docdet"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql .= " WHERE doc_type = 'asset'"; $sql .= ")"; - } + }*/ + $sql .= "SELECT ad.fk_asset AS rowid, a.ref AS asset_ref, a.label AS asset_label, a.acquisition_value_ht AS asset_acquisition_value_ht"; $sql .= ", a.disposal_date AS asset_disposal_date, a.disposal_amount_ht AS asset_disposal_amount_ht, a.disposal_subject_to_vat AS asset_disposal_subject_to_vat"; $sql .= ", ad.rowid AS depreciation_id, ad.depreciation_mode, ad.ref AS depreciation_ref, ad.depreciation_date, ad.depreciation_ht, ad.accountancy_code_debit, ad.accountancy_code_credit"; $sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation as ad"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "asset as a ON a.rowid = ad.fk_asset"; - if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { + // FIXME sql error with Mysql 5.7 + /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { $sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid"; - } + }*/ $sql .= " WHERE a.entity IN (" . getEntity('asset', 0) . ')'; // We don't share object for accountancy, we use source object sharing + // Compatibility with Mysql 5.7 + if ($in_bookkeeping == 'already') { + $sql .= " AND EXISTS (SELECT iab.fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS iab WHERE iab.fk_docdet = ad.rowid AND doc_type = 'asset')"; + } elseif ($in_bookkeeping == 'notyet') { + $sql .= " AND NOT EXISTS (SELECT iab.fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS iab WHERE iab.fk_docdet = ad.rowid AND doc_type = 'asset')"; + } $sql .= " AND ad.ref != ''"; // not reversal lines if ($date_start && $date_end) { $sql .= " AND ad.depreciation_date >= '" . $this->db->idate($date_start) . "' AND ad.depreciation_date <= '" . $this->db->idate($date_end) . "'"; @@ -470,9 +484,10 @@ class AccountingJournal extends CommonObject $sql .= " AND ad.depreciation_date >= '" . $this->db->idate($conf->global->ACCOUNTING_DATE_START_BINDING) . "'"; } // Already in bookkeeping or not - if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { + // FIXME sql error with Mysql 5.7 + /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { $sql .= " AND iab.fk_docdet IS" . ($in_bookkeeping == 'already' ? " NOT" : "") . " NULL"; - } + }*/ $sql .= " ORDER BY ad.depreciation_date"; dol_syslog(__METHOD__, LOG_DEBUG); diff --git a/htdocs/accountancy/journal/variousjournal.php b/htdocs/accountancy/journal/variousjournal.php index b56271850e5..8f6297e480a 100644 --- a/htdocs/accountancy/journal/variousjournal.php +++ b/htdocs/accountancy/journal/variousjournal.php @@ -290,19 +290,21 @@ print '
| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' | ||||
| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' | ||||
| ';
print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"), $langs->trans("ParameterActiveForNextInputOnly"));
@@ -191,7 +214,7 @@ if ($action == 'edit') {
print '';
print ' ';
- print ''.$langs->trans("Modify").'';
+ print ''.$langs->trans("Modify").'';
print ' ';
}
diff --git a/htdocs/api/index.php b/htdocs/api/index.php
index 0abf864084d..085dd338e69 100644
--- a/htdocs/api/index.php
+++ b/htdocs/api/index.php
@@ -122,7 +122,7 @@ if (empty($conf->global->MAIN_MODULE_API)) {
// Test if explorer is not disabled
if (preg_match('/api\/index\.php\/explorer/', $url) && !empty($conf->global->API_EXPLORER_DISABLED)) {
$langs->load("admin");
- dol_syslog("Call Dolibarr API interfaces with module REST disabled");
+ dol_syslog("Call Dolibarr API interfaces with module API REST disabled");
print $langs->trans("WarningAPIExplorerDisabled").'.'; //session_destroy(); exit(0); @@ -155,6 +155,10 @@ preg_match('/index\.php\/([^\/]+)(.*)$/', $url, $reg); $refreshcache = (empty($conf->global->API_PRODUCTION_DO_NOT_ALWAYS_REFRESH_CACHE) ? true : false); if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { $refreshcache = true; + if (!is_writable($conf->api->dir_temp)) { + print 'Erreur temp dir api/temp not writable'; + exit(0); + } } $api = new DolibarrApi($db, '', $refreshcache); diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index ea6ec241b16..7b4e06c897f 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -119,13 +119,23 @@ class AdvanceTargetingMailing extends CommonObject '3' => $langs->trans('ThirdParty'), '4' => $langs->trans('ContactsWithThirdpartyFilter') ); - $this->type_statuscommprospect = array( - -1 => $langs->trans("StatusProspect-1"), - 0 => $langs->trans("StatusProspect0"), - 1 => $langs->trans("StatusProspect1"), - 2 => $langs->trans("StatusProspect2"), - 3 => $langs->trans("StatusProspect3") - ); + + require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; + $customerStatic = new Client($this->db); + $customerStatic->loadCacheOfProspStatus(); + if (!empty($customerStatic->cacheprospectstatus)) { + foreach ($customerStatic->cacheprospectstatus as $dataProspectSt) { + $this->type_statuscommprospect[$dataProspectSt['id']]=$dataProspectSt['label']; + } + } else { + $this->type_statuscommprospect = array( + -1 => $langs->trans("StatusProspect-1"), + 0 => $langs->trans("StatusProspect0"), + 1 => $langs->trans("StatusProspect1"), + 2 => $langs->trans("StatusProspect2"), + 3 => $langs->trans("StatusProspect3") + ); + } } /** diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 9e10d51031e..50169438baa 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -355,7 +355,7 @@ class FormAdvTargetEmailing extends Form $out = ''; $sql = "SELECT c.rowid, c.name, c.fk_element"; - $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as c"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_advtarget as c"; $sql .= " WHERE type_element = '".$this->db->escape($type_element)."'"; $sql .= " ORDER BY c.name"; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 638022b855a..d535da76199 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1228,6 +1228,15 @@ class Contact extends CommonObject $this->db->begin(); + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('CONTACT_DELETE', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + if (!$error) { // Get all rowid of element_contact linked to a type that is link to llx_socpeople $sql = "SELECT ec.rowid"; @@ -1318,15 +1327,6 @@ class Contact extends CommonObject } } - if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('CONTACT_DELETE', $user); - if ($result < 0) { - $error++; - } - // End call triggers - } - if (!$error) { $this->db->commit(); return 1; diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index 9966b9c6093..7866b972db1 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -28,9 +28,10 @@ if (!defined('NOREQUIREHTML')) { if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } -if (!defined('NOREQUIRESOC')) { +// Needed to create other objects with workflow +/*if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); -} +}*/ // Do not check anti CSRF attack test if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1d93ed833ae..f9a64330ce6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9137,7 +9137,7 @@ abstract class CommonObject // Clean and check mandatory foreach ($keys as $key) { - // If field is an implicit foreign key field + // If field is an implicit foreign key field (so type = 'integer:...') if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') { $values[$key] = ''; } @@ -9157,7 +9157,7 @@ abstract class CommonObject $values[$key] = $this->quote($this->fields[$key]['default'], $this->fields[$key]); } - // If field is an implicit foreign key field + // If field is an implicit foreign key field (so type = 'integer:...') if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) { if (isset($this->fields[$key]['default'])) { $values[$key] = ((int) $this->fields[$key]['default']); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9ab6874836d..409bf47d715 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6371,7 +6371,7 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, // Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. if (($seller_country_code == $buyer_country_code) - || (in_array($seller_country_code, array('FR,MC')) && in_array($buyer_country_code, array('FR', 'MC')))) { // Warning ->country_code not always defined + || (in_array($seller_country_code, array('FR', 'MC')) && in_array($buyer_country_code, array('FR', 'MC')))) { // Warning ->country_code not always defined //print 'VATRULE 2'; return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice); } diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 54e639058c4..18ebc363768 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -753,7 +753,10 @@ function getCustomerInvoiceLatestEditTable($maxCount = 5, $socid = 0) $result .= ' | '.$companystatic->getNomUrl(1, 'customer').' | '; $result .= ''.dol_print_date($db->jdate($obj->datec), 'day').' | '; $result .= ''.price($obj->total_ttc).' | '; - $result .= ''.$objectstatic->getLibStatut(5).' | '; + + // Load amount of existing payment of invoice (needed for complete status) + $payment = $objectstatic->getSommePaiement(); + $result .= ''.$objectstatic->getLibStatut(5, $payment).' | '; $result .= '