mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 09:38:23 +01:00
FIX setup of default doc template for supplier proposal when none.
This commit is contained in:
@@ -1961,11 +1961,13 @@ function version_webserver()
|
||||
* @param DoliDB $db Database handler
|
||||
* @param string $type Type of models (company, invoice, ...)
|
||||
* @param int $maxfilenamelength Max length of value to show
|
||||
* @param int $showempty Add an empty record if 1
|
||||
* @return string[]|int<-1,0> 0 if no module is activated, or array(key=>label). For modules that need directory scan, key is completed with ":filename", -1 if error
|
||||
*/
|
||||
function getListOfModels($db, $type, $maxfilenamelength = 0)
|
||||
function getListOfModels($db, $type, $maxfilenamelength = 0, $showempty = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$liste = array();
|
||||
$found = 0;
|
||||
$dirtoscan = '';
|
||||
@@ -1973,19 +1975,30 @@ function getListOfModels($db, $type, $maxfilenamelength = 0)
|
||||
$sql = "SELECT nom as id, nom as doc_template_name, libelle as label, description as description";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql .= " WHERE type = '".$db->escape($type)."'";
|
||||
$sql .= " AND entity IN (0,".$conf->entity.")";
|
||||
$sql .= " AND entity IN (0,".((int) $conf->entity).")";
|
||||
$sql .= " ORDER BY description DESC";
|
||||
|
||||
dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG);
|
||||
|
||||
$resql_models = $db->query($sql);
|
||||
if ($resql_models) {
|
||||
$num = $db->num_rows($resql_models);
|
||||
|
||||
if ($showempty) {
|
||||
$liste[0] = ' ';
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$found = 1;
|
||||
|
||||
$obj = $db->fetch_object($resql_models);
|
||||
|
||||
if ($obj->id == '0') { // We discard bad record (should not happen)
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// If this generation module needs to scan a directory, then description field is filled
|
||||
// with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...).
|
||||
if (!empty($obj->description)) { // A list of directories to scan is defined
|
||||
@@ -2034,6 +2047,7 @@ function getListOfModels($db, $type, $maxfilenamelength = 0)
|
||||
$liste[$obj->id] = $obj->label ? $obj->label : $obj->doc_template_name;
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user