diff --git a/htdocs/ai/class/ai.class.php b/htdocs/ai/class/ai.class.php index 0ba6852a021..0f831c488e2 100644 --- a/htdocs/ai/class/ai.class.php +++ b/htdocs/ai/class/ai.class.php @@ -76,7 +76,7 @@ class Ai * @param string $model Model name ('gpt-3.5-turbo', 'gpt-4-turbo', 'dall-e-3', ...) * @param string $function Code of the feature we want to use ('textgeneration', 'transcription', 'audiogeneration', 'imagegeneration', 'translation') * @param string $format Format for output ('', 'html', ...) - * @return string|array{error:bool,message:string,code?:int,curl_error_no?:''|int,format?:string,service?:string,function?:string} $response Text or array if error + * @return string|array{error:bool,message:string,code?:int,curl_error_no?:int,format?:string,service?:string,function?:string} $response Text or array if error */ public function generateContent($instructions, $model = 'auto', $function = 'textgeneration', $format = '') { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ecce50d4665..6d76e3b0cbf 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9865,7 +9865,7 @@ abstract class CommonObject $filearray=array_merge($filearray, $filearrayold); }*/ - completeFileArrayWithDatabaseInfo($filearray, $relativedir); + completeFileArrayWithDatabaseInfo($filearray, $relativedir, $this); '@phan-var-force array $filearray'; if (count($filearray)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a96961a0259..25eb61424eb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4411,7 +4411,7 @@ class Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Load int a cache property the list of possible delivery delays. + * Load int a cache property the list of possible delivery delays. * * @return int Nb of lines loaded, <0 if KO */ diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 878028f6750..f681037724b 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -938,7 +938,7 @@ class FormFile // Get list of files stored into database for same relative directory if ($relativedir) { - completeFileArrayWithDatabaseInfo($file_list, $relativedir); + completeFileArrayWithDatabaseInfo($file_list, $relativedir, $object); '@phan-var-force array $file_list'; //var_dump($sortfield.' - '.$sortorder); @@ -977,7 +977,6 @@ class FormFile // Show file name with link to download $imgpreview = $this->showPreview($file, $modulepart, $relativepath, 0, $param); - $out .= ''; if ($imgpreview) { $out .= ''; @@ -995,7 +994,6 @@ class FormFile $out .= 'target="_blank" '; } $out .= 'href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param ? '&'.$param : '').'"'; - $mime = dol_mimetype($relativepath, '', 0); if (preg_match('/text/', $mime)) { $out .= ' target="_blank" rel="noopener noreferrer"'; @@ -1006,12 +1004,14 @@ class FormFile $out .= dol_trunc($file["name"], 150); $out .= ''; } + $out .= ''."\n"; if (!getDolGlobalInt('PREVIEW_PICTO_ON_LEFT_OF_NAME')) { $out .= $imgpreview; } $out .= ''; + // Show file size $size = (!empty($file['size']) ? $file['size'] : dol_filesize($filedir."/".$file["name"])); $out .= ''.dol_print_size($size, 1, 1).''; @@ -1440,7 +1440,7 @@ class FormFile // Get list of files stored into database for same relative directory if ($relativedir) { - completeFileArrayWithDatabaseInfo($filearray, $relativedir); + completeFileArrayWithDatabaseInfo($filearray, $relativedir, $object); '@phan-var-force array $filearray'; //var_dump($sortfield.' - '.$sortorder); diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index bf0652760f4..25d06737e69 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -266,14 +266,18 @@ function dol_dir_list($utf8_path, $types = "all", $recursive = 0, $filter = "", * @param int $sortorder Sort order (SORT_ASC, SORT_DESC) * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like description * @param string $sqlfilters Filter as an Universal Search string. + * @param ?Object $object Object used * Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')' * @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...) * @see dol_dir_list() */ -function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $sortcriteria = "name", $sortorder = SORT_ASC, $mode = 0, $sqlfilters = "") +function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $sortcriteria = "name", $sortorder = SORT_ASC, $mode = 0, $sqlfilters = "", $object = null) { global $conf, $db; + if (is_null($object)) { + $object = new stdClass(); + } $sql = " SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams,"; $sql .= " date_c, tms as date_m, fk_user_c, fk_user_m, acl, position, share"; @@ -281,7 +285,11 @@ function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $s $sql .= ", description"; } $sql .= " FROM ".MAIN_DB_PREFIX."ecm_files"; - $sql .= " WHERE entity = ".((int) $conf->entity); + if (!empty($object->entity) && $object->entity != $conf->entity) { + $sql .= " WHERE entity = ".((int) $object->entity); + } else { + $sql .= " WHERE entity = ".((int) $conf->entity); + } if (preg_match('/%$/', $path)) { $sql .= " AND (filepath LIKE '".$db->escape($path)."' OR filepath = '".$db->escape(preg_replace('/\/%$/', '', $path))."')"; } else { @@ -355,13 +363,18 @@ function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $s * * @param array $filearray Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...) Array of files obtained using dol_dir_list * @param string $relativedir Relative dir from DOL_DATA_ROOT + * @param ?Object $object Object used * @return void */ -function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir) +function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir, $object = null) { global $conf, $db, $user; - $filearrayindatabase = dol_dir_list_in_database($relativedir, '', null, 'name', SORT_ASC); + if (is_null($object)) { + $object = new stdClass(); + } + + $filearrayindatabase = dol_dir_list_in_database($relativedir, '', null, 'name', SORT_ASC, 0, '', $object); // TODO Remove this when PRODUCT_USE_OLD_PATH_FOR_PHOTO will be removed global $modulepart; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 80b44696732..765e3035aa5 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1424,7 +1424,7 @@ class pdf_einstein extends ModelePDFCommandes if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) { $object->fetchProject(); if (!empty($object->project->ref)) { - $posy += 3; + $posy = $pdf->GetY(); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R'); @@ -1435,20 +1435,20 @@ class pdf_einstein extends ModelePDFCommandes $object->fetchProject(); if (!empty($object->project->ref)) { $outputlangs->load("projects"); - $posy += 3; + $posy = $pdf->GetY(); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R'); } } - $posy += 4; + $posy = $pdf->GetY(); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) { - $posy += 4; + $posy = $pdf->GetY(); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 75a12484038..77d95b1fcd7 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -1025,8 +1025,6 @@ class EcmFiles extends CommonObject $tmppath = preg_replace('/^[^\/]+\//', '', $this->filepath); } } - //var_dump($this->filepath); - $url = DOL_URL_ROOT.'/document.php?modulepart='.urlencode($option).'&file='.urlencode($tmppath.'/'.$this->filename).'&entity='.((int) $this->entity); } else { $url = DOL_URL_ROOT.'/ecm/file_card.php?id='.$this->id; diff --git a/htdocs/user/agenda.php b/htdocs/user/agenda.php index 6b4719d18a4..704f14f52af 100644 --- a/htdocs/user/agenda.php +++ b/htdocs/user/agenda.php @@ -173,7 +173,7 @@ $out = ''; $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objUser->id) || !empty($objcon->id)) && $permok) { if (is_object($objUser) && get_class($objUser) == 'User') { - $out .= '&originid='.$objUser->id.($objUser->id > 0 ? '&userid='.$objUser->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objUser->id > 0 ? '?userid='.$objUser->id : '')); + $out .= '&originid='.$objUser->id.($objUser->id > 0 ? '&assignedtouser='.$objUser->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objUser->id > 0 ? '?id='.$objUser->id : '')); } $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : ''); $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog', 'tzuserrel');