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

This commit is contained in:
Laurent Destailleur 2023-10-01 16:06:58 +02:00
commit b8bd760e28
13 changed files with 63 additions and 28 deletions

View File

@ -2021,6 +2021,8 @@ Following changes may create regressions for some external modules, but were nec
* v14 seems to work correctly on PHP v8 but it generates a lot of verbose warnings. Currently, v14 i snot yet officialy supported with PHP 8.
* To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in
method executeCLI() available into core/class/utils.class.php
* the trigger "*_DELETE_CONTACT" inside "delete_contact()" function from commonobject.class.php is call before delete the object element
and a $object->context['contact_id'] is now available for this trigger
***** ChangeLog for 13.0.5 compared to 13.0.4 *****

View File

@ -2168,9 +2168,12 @@ if ($action == 'create') {
/*
* Show object in view mode
*/
$soc = new Societe($db);
$soc->fetch($object->socid);
$object->fetch_thirdparty();
if ($object->thirdparty) {
$soc = $object->thirdparty;
} else {
$soc = new Societe($db);
}
$head = propal_prepare_head($object);
print dol_get_fiche_head($head, 'comm', $langs->trans('Proposal'), -1, 'propal');
@ -2420,9 +2423,9 @@ if ($action == 'create') {
$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1);
// Thirdparty
$morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
$morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherProposals").'</a>)';
$morehtmlref .= '<br><span class="hideonsmartphone">'.$langs->trans('ThirdParty').' : </span>'.$soc->getNomUrl(1, 'customer');
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $soc->id > 0) {
$morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$soc->id.'&search_societe='.urlencode($soc->name).'">'.$langs->trans("OtherProposals").'</a>)';
}
// Project
if (isModEnabled('project')) {

View File

@ -1943,6 +1943,8 @@ if (empty($reshook)) {
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
$object->remise_absolue =price2num(GETPOST('remise_absolue'), 'MU', 2);
$object->remise_percent = price2num(GETPOST('remise_percent'), '', 2);
$object->fk_account = GETPOST('fk_account', 'int');
// Proprietes particulieres a facture de remplacement

View File

@ -1152,6 +1152,7 @@ class Facture extends CommonInvoice
$facture->origin = $this->origin;
$facture->origin_id = $this->origin_id;
$facture->fk_account = $this->fk_account;
$facture->lines = $this->lines; // Array of lines of invoice
$facture->situation_counter = $this->situation_counter;

View File

@ -1162,8 +1162,8 @@ abstract class CommonDocGenerator
*/
public function getColumnContentXStart($colKey)
{
$colDef = $this->cols[$colKey];
return (isset($colDef['xStartPos']) ? $colDef['xStartPos'] : 0) + $colDef['content']['padding'][3];
$colDef = (isset($this->cols[$colKey]) ? $this->cols[$colKey] : null);
return (is_array($colDef) ? ((isset($colDef['xStartPos']) ? $colDef['xStartPos'] : 0) + $colDef['content']['padding'][3]) : 0);
}
/**

View File

@ -1217,22 +1217,34 @@ abstract class CommonObject
// phpcs:enable
global $user;
$error = 0;
$this->db->begin();
$sql = "DELETE FROM ".$this->db->prefix()."element_contact";
$sql .= " WHERE rowid = ".((int) $rowid);
dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG);
if ($this->db->query($sql)) {
if (!$notrigger) {
$result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user);
if ($result < 0) {
$this->db->rollback();
return -1;
}
if (!$error && empty($notrigger)) {
// Call trigger
$this->context['contact_id'] = ((int) $rowid);
$result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
if (!$error) {
dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sql .= " WHERE rowid = ".((int) $rowid);
$result = $this->db->query($sql);
if (!$result) {
$error++;
$this->errors[] = $this->db->lasterror();
}
}
if (!$error) {
$this->db->commit();
return 1;
} else {

View File

@ -68,6 +68,12 @@ class Interfaces
public function run_triggers($action, $object, $user, $langs, $conf)
{
// phpcs:enable
if (getDolGlobalInt('MAIN_TRIGGER_DEBUG')) {
// This his too much verbose, enabled if const enabled only
dol_syslog(get_class($this)."::run_triggers action=".$action." Launch run_triggers", LOG_DEBUG);
}
// Check parameters
if (!is_object($object) || !is_object($conf)) { // Error
$error = 'function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf);
@ -82,7 +88,6 @@ class Interfaces
dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING);
$user = new User($this->db);
}
//dol_syslog(get_class($this)."::run_triggers action=".$action." Launch run_triggers", LOG_DEBUG);
$nbfile = $nbtotal = $nbok = $nbko = 0;

View File

@ -2571,7 +2571,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs
// See format of addresses on https://en.wikipedia.org/wiki/Address
// Address
if (empty($mode)) {
$ret .= ($extralangcode ? $object->array_languages['address'][$extralangcode] : (empty($object->address) ? '' : preg_replace('/[\n\r]/', $sep, $object->address)));
$ret .= ($extralangcode ? $object->array_languages['address'][$extralangcode] : (empty($object->address) ? '' : preg_replace('/(\r\n|\r|\n)+/', $sep, $object->address)));
}
// Zip/Town/State
if (isset($object->country_code) && in_array($object->country_code, array('AU', 'CA', 'US', 'CN')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) {

View File

@ -3301,7 +3301,8 @@ class CommandeFournisseur extends CommonOrder
$outputlangs->load("products");
$modelpath = "core/modules/supplier_order/doc/";
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
$result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
return $result;
}
}

View File

@ -2226,6 +2226,7 @@ class FactureFournisseur extends CommonInvoice
$supplierinvoiceline->info_bits = $info_bits;
$supplierinvoiceline->fk_remise_except = $fk_remise_except;
$supplierinvoiceline->special_code = ((string) $special_code != '' ? $special_code : $this->special_code);
$supplierinvoiceline->fk_parent_line = $fk_parent_line;
$supplierinvoiceline->origin = $this->origin;

View File

@ -694,7 +694,7 @@ if (empty($reshook)) {
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) {
dol_print_error($db, $result);
setEventMessages($object->error, $object->errors, 'errors');
}
}

View File

@ -511,7 +511,8 @@ if (empty($reshook)) {
$lines[$i]->info_bits,
'HT',
$product_type,
$lines[$i]->rang,
// we dont use the rank from orderline because we may have lines from several orders
-1,
false,
$lines[$i]->array_options,
$lines[$i]->fk_unit,
@ -1237,7 +1238,7 @@ if ($resql) {
//var_dump($_REQUEST);
print '<input type="hidden" name="massaction" value="confirm_createsupplierbills">';
print '<table class="noborder" width="100%" >';
print '<table class="noborder centpercent">';
print '<tr>';
print '<td class="titlefield">';
print $langs->trans('DateInvoice');
@ -1264,12 +1265,12 @@ if ($resql) {
print '</tr>';
print '</table>';
print '<br>';
print '<div class="center">';
print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisCustomer').'"> ';
print '<input type="submit" class="button button-cancel" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '<br>';
print '<br>';
}
if ($sall) {

View File

@ -68,10 +68,17 @@ function inventoryAdminPrepareHead()
*/
function inventoryPrepareHead(&$inventory, $title = 'Inventory', $get = '')
{
global $langs;
global $langs, $conf;
return array(
$head = array(
array(dol_buildpath('/product/inventory/card.php?id='.$inventory->id.$get, 1), $langs->trans('Card'), 'card'),
array(dol_buildpath('/product/inventory/inventory.php?id='.$inventory->id.$get, 1), $langs->trans('Inventory'), 'inventory')
);
$h=2;
complete_head_from_modules($conf, $langs, $inventory, $head, $h, 'inventory');
complete_head_from_modules($conf, $langs, $inventory, $head, $h, 'inventory', 'remove');
return $head;
}