Works on ODT import

This commit is contained in:
Laurent Destailleur 2010-03-27 00:57:49 +00:00
parent bdf4bbaa1f
commit 9f7bb65a1d
3 changed files with 18 additions and 11 deletions

View File

@ -129,7 +129,7 @@ class FormFile
* \param genallowed Generation is allowed (1/0 or array of formats)
* \param delallowed Remove is allowed (1/0)
* \param modelselected Model to preselect by default
* \param showwarning Show warning if no model activated
* \param allowgenifempty Show warning if no model activated
* \param forcenomultilang Do not show language option (even if MAIN_MULTILANGS defined)
* \param iconPDF Show only PDF icon with link (1/0)
* \param maxfilenamelength Max length for filename shown
@ -140,7 +140,7 @@ class FormFile
* \param codelang Default language code to use on lang combo box if multilang is enabled
* \return int <0 if KO, number of shown files if OK
*/
function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$showwarning=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='')
function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='')
{
// filedir = conf->...dir_ouput."/".get_exdir(id)
include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
@ -339,7 +339,7 @@ class FormFile
// Language code (if multilang)
print '<td align="center">';
if (($showwarning || (is_array($modellist) && sizeof($modellist) > 0)) && $conf->global->MAIN_MULTILANGS && ! $forcenomultilang)
if (($allowgenifempty || (is_array($modellist) && sizeof($modellist) > 0)) && $conf->global->MAIN_MULTILANGS && ! $forcenomultilang)
{
include_once(DOL_DOCUMENT_ROOT.'/html.formadmin.class.php');
$formadmin=new FormAdmin($this->db);
@ -357,9 +357,9 @@ class FormFile
print '<input class="button" ';
//print ((is_array($modellist) && sizeof($modellist))?'':' disabled="true"') // Always allow button "Generate" (even if no model activated)
print ' type="submit" value="'.$buttonlabel.'"';
if (! $showwarning && ! is_array($modellist) && empty($modellist)) print ' disabled="true"';
if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) print ' disabled="true"';
print '>';
if ($showwarning && ! is_array($modellist) && empty($modellist))
if ($allowgenifempty && ! is_array($modellist) && empty($modellist))
{
$langs->load("errors");
print ' '.img_warning($langs->trans("WarningNoDocumentModelActivated"));

View File

@ -54,7 +54,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
$langs->load("companies");
$this->db = $db;
$this->name = "Generic ODT";
$this->name = "ODT templates";
$this->description = $langs->trans("DocumentModelOdt");
$this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan

View File

@ -1019,7 +1019,7 @@ function picto_from_langcode($codelang)
*/
function getListOfModels($db,$type)
{
global $conf;
global $conf,$langs;
$liste=array();
$found=0;
@ -1041,9 +1041,9 @@ function getListOfModels($db,$type)
$obj = $db->fetch_object($resql);
// If this generation module needs a directory scan, then description field is filled
// If this generation module needs to scan a directory, then description field is filled
// with the constant that contains list of directories to scan.
if (! empty($obj->description))
if (! empty($obj->description)) // List of directories to scan is defined
{
$const=$obj->description;
$dirtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const));
@ -1064,9 +1064,16 @@ function getListOfModels($db,$type)
}
}
foreach($listoffiles as $record)
if (sizeof($listoffiles))
{
$liste[$obj->id.':'.$record['fullname']]=dol_trunc($record['name'],24,'middle');
foreach($listoffiles as $record)
{
$liste[$obj->id.':'.$record['fullname']]=dol_trunc($record['name'],24,'middle');
}
}
else
{
$liste[0]=$obj->label.': '.$langs->trans("None");
}
}
else