2
0
forked from Wavyzz/dolibarr

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

This commit is contained in:
Laurent Destailleur (aka Eldy)
2025-01-30 12:58:03 +01:00
15 changed files with 101 additions and 43 deletions

View File

@@ -443,20 +443,19 @@ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
} }
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
$sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action";
// We must filter on resource table // We must filter on resource table
if ($resourceid > 0) { if ($resourceid > 0) {
$sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as r ON r.element_type = 'action' AND r.element_id = a.id";
} }
// We must filter on assignement table // We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) { if ($filtert > 0 || $usergroup > 0) {
$sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type='user'";
} }
if ($usergroup > 0) { if ($usergroup > 0) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
} }
$sql .= " WHERE c.id = a.fk_action"; $sql .= " WHERE a.entity IN (".getEntity('agenda').")";
$sql .= ' AND a.entity IN ('.getEntity('agenda').')';
// Condition on actioncode // Condition on actioncode
if (!empty($actioncode)) { if (!empty($actioncode)) {
if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) {
@@ -487,7 +486,7 @@ if (!empty($actioncode)) {
} }
} }
if ($resourceid > 0) { if ($resourceid > 0) {
$sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid); $sql .= " AND r.resource_id = ".((int) $resourceid);
} }
if ($pid) { if ($pid) {
$sql .= " AND a.fk_project=".((int) $pid); $sql .= " AND a.fk_project=".((int) $pid);
@@ -498,10 +497,6 @@ if (!$user->hasRight('societe', 'client', 'voir') && !$socid) {
if ($socid > 0) { if ($socid > 0) {
$sql .= " AND s.rowid = ".((int) $socid); $sql .= " AND s.rowid = ".((int) $socid);
} }
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) {
$sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
}
if ($type) { if ($type) {
$sql .= " AND c.id = ".((int) $type); $sql .= " AND c.id = ".((int) $type);
} }

View File

@@ -136,6 +136,13 @@ class FactureRec extends CommonInvoice
public $cond_reglement_code; // Code in llx_c_paiement public $cond_reglement_code; // Code in llx_c_paiement
public $mode_reglement_code; // Code in llx_c_paiement public $mode_reglement_code; // Code in llx_c_paiement
public $fk_multicurrency;
public $multicurrency_code;
public $multicurrency_tx;
public $multicurrency_total_ht;
public $multicurrency_total_tva;
public $multicurrency_total_ttc;
public $suspended; // status public $suspended; // status
public $auto_validate; // 0 to create in draft, 1 to create and validate the new invoice public $auto_validate; // 0 to create in draft, 1 to create and validate the new invoice

View File

@@ -3291,7 +3291,7 @@ class ContratLigne extends CommonObjectLine
$sql .= " t.label,"; // This field is not used. Only label of product $sql .= " t.label,"; // This field is not used. Only label of product
$sql .= " p.ref as product_ref,"; $sql .= " p.ref as product_ref,";
$sql .= " p.label as product_label,"; $sql .= " p.label as product_label,";
$sql .= " p.description as product_desc,"; $sql .= " p.description as product_description,";
$sql .= " p.fk_product_type as product_type,"; $sql .= " p.fk_product_type as product_type,";
$sql .= " t.description,"; $sql .= " t.description,";
$sql .= " t.date_commande,"; $sql .= " t.date_commande,";

View File

@@ -376,6 +376,13 @@ if (!empty($filter_opcloture) && $filter_opcloture == ' BETWEEN ') {
// Add where from extra fields // Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= $db->order($sortfield, $sortorder);
//print $sql; //print $sql;
// Count total nb of records // Count total nb of records
@@ -488,6 +495,10 @@ if ($filter_datecloture_start != '') {
} }
// Add $param from extra fields // Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// Add $param from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$param .= $hookmanager->resPrint;
// List of mass actions available // List of mass actions available
$arrayofmassactions = array( $arrayofmassactions = array(

View File

@@ -1450,6 +1450,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0,
} }
} }
} else { } else {
$ok = false; // to avoid false positive
dol_syslog("No files to delete found", LOG_DEBUG); dol_syslog("No files to delete found", LOG_DEBUG);
} }
} else { } else {

View File

@@ -277,7 +277,7 @@ class pdf_soleil extends ModelePDFFicheinter
$desc = dol_htmlentitiesbr($text, 1); $desc = dol_htmlentitiesbr($text, 1);
//print $outputlangs->convToOutputCharset($desc); exit; //print $outputlangs->convToOutputCharset($desc); exit;
$pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1); $pdf->writeHTMLCell(180, 3, $this->posxdesc - 1, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1);
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY); $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);

View File

@@ -469,6 +469,14 @@ class doc_generic_task_odt extends ModelePDFTask
return -1; return -1;
} }
// Add odtgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (!is_object($outputlangs)) { if (!is_object($outputlangs)) {
$outputlangs = $langs; $outputlangs = $langs;
} }

View File

@@ -212,6 +212,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
$hookmanager = new HookManager($this->db); $hookmanager = new HookManager($this->db);
} }
$hookmanager->initHooks(array('odtgeneration')); $hookmanager->initHooks(array('odtgeneration'));
global $action;
if (!is_object($outputlangs)) { if (!is_object($outputlangs)) {
$outputlangs = $langs; $outputlangs = $langs;

View File

@@ -284,7 +284,7 @@ class SupplierInvoices extends DolibarrApi
$this->invoice->$field = $this->_checkValForAPI($field, $value, $this->invoice); $this->invoice->$field = $this->_checkValForAPI($field, $value, $this->invoice);
} }
if ($this->invoice->update($id, DolibarrApiAccess::$user)) { if ($this->invoice->update(DolibarrApiAccess::$user)) {
return $this->get($id); return $this->get($id);
} }

View File

@@ -2292,6 +2292,18 @@ class CommandeFournisseur extends CommonOrder
} }
$main = $this->db->prefix().'commande_fournisseurdet'; $main = $this->db->prefix().'commande_fournisseurdet';
if (!$error) {
$sql1 = "UPDATE ".$this->db->prefix()."commandedet SET fk_commandefourndet = NULL WHERE fk_commandefourndet IN (SELECT rowid FROM ".$main." WHERE fk_commande = ".((int) $this->id).")";
dol_syslog(__METHOD__." linked order lines", LOG_DEBUG);
if (!$this->db->query($sql1)) {
$error++;
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
}
}
if (!$error) {
$ef = $main."_extrafields"; $ef = $main."_extrafields";
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".((int) $this->id).")"; $sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".((int) $this->id).")";
dol_syslog(get_class($this)."::delete extrafields lines", LOG_DEBUG); dol_syslog(get_class($this)."::delete extrafields lines", LOG_DEBUG);
@@ -2300,7 +2312,9 @@ class CommandeFournisseur extends CommonOrder
$this->errors[] = $this->db->lasterror(); $this->errors[] = $this->db->lasterror();
$error++; $error++;
} }
}
if (!$error) {
$sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseurdet WHERE fk_commande =".((int) $this->id); $sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseurdet WHERE fk_commande =".((int) $this->id);
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if (!$this->db->query($sql)) { if (!$this->db->query($sql)) {
@@ -2308,7 +2322,9 @@ class CommandeFournisseur extends CommonOrder
$this->errors[] = $this->db->lasterror(); $this->errors[] = $this->db->lasterror();
$error++; $error++;
} }
}
if (!$error) {
$sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseur WHERE rowid =".((int) $this->id); $sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseur WHERE rowid =".((int) $this->id);
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if ($resql = $this->db->query($sql)) { if ($resql = $this->db->query($sql)) {
@@ -2322,6 +2338,7 @@ class CommandeFournisseur extends CommonOrder
$this->errors[] = $this->db->lasterror(); $this->errors[] = $this->db->lasterror();
$error++; $error++;
} }
}
// Remove extrafields // Remove extrafields
if (!$error) { if (!$error) {
@@ -3980,6 +3997,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
return -2; return -2;
} }
} }
/** /**
* Update the line object into db * Update the line object into db
* *

View File

@@ -229,7 +229,12 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
} }
// Add odtgeneration hook // Add odtgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration')); $hookmanager->initHooks(array('odtgeneration'));
global $action;
if (!is_object($outputlangs)) { if (!is_object($outputlangs)) {
$outputlangs = $langs; $outputlangs = $langs;

View File

@@ -493,6 +493,11 @@ if (getDolGlobalString('PRODUCT_USE_UNITS')) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units cu ON cu.rowid = p.fk_unit"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units cu ON cu.rowid = p.fk_unit";
} }
// Add table from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= ' WHERE p.entity IN ('.getEntity('product').')'; $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
if ($sall) { if ($sall) {
// Clean $fieldstosearchall // Clean $fieldstosearchall

View File

@@ -65,7 +65,10 @@ if ($reshook < 0) {
} }
if ($id > 0 || $ref) { if ($id > 0 || $ref) {
$object->fetch($id, $ref); $ret = $object->fetch($id, $ref);
if ($ret > 0) {
$projectstatic->fetch($object->fk_project);
}
} }
// Security check // Security check
@@ -204,14 +207,14 @@ if ($action == 'remove_file' && $user->hasRight('projet', 'creer')) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$langs->load("other"); $langs->load("other");
$upload_dir = $conf->project->dir_output; $upload_dir = $conf->project->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref);
$file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file')); $file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file'));
$ret = dol_delete_file($file); $ret = dol_delete_file($file);
if ($ret) { if ($ret) {
setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
} }
} }
@@ -222,7 +225,6 @@ if ($action == 'remove_file' && $user->hasRight('projet', 'creer')) {
$form = new Form($db); $form = new Form($db);
$formother = new FormOther($db); $formother = new FormOther($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$result = $projectstatic->fetch($object->fk_project);
$title = $object->ref; $title = $object->ref;
if (!empty($withproject)) { if (!empty($withproject)) {
@@ -692,7 +694,7 @@ if ($id > 0 || !empty($ref)) {
/* /*
* Generated documents * Generated documents
*/ */
$filename = dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); $filename = '';
$filedir = $conf->project->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); $filedir = $conf->project->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref);
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = ($user->rights->projet->lire); $genallowed = ($user->rights->projet->lire);

View File

@@ -232,7 +232,12 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi
} }
// Add odtgeneration hook // Add odtgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration')); $hookmanager->initHooks(array('odtgeneration'));
global $action;
if (!is_object($outputlangs)) { if (!is_object($outputlangs)) {
$outputlangs = $langs; $outputlangs = $langs;

View File

@@ -307,7 +307,7 @@ class Zapier extends DolibarrApi
$this->hook->$field = $value; $this->hook->$field = $value;
} }
if ($this->hook->update($id, DolibarrApiAccess::$user) > 0) { if ($this->hook->update(DolibarrApiAccess::$user) > 0) {
return $this->get($id); return $this->get($id);
} else { } else {
throw new RestException(500, $this->hook->error); throw new RestException(500, $this->hook->error);