From bdf4bbaa1f267ca2e87266f3349f525e3d273e38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Mar 2010 00:33:28 +0000 Subject: [PATCH] Works on ODT import --- htdocs/admin/tools/dolibarr_export.php | 2 +- htdocs/admin/tools/export.php | 2 +- htdocs/comm/index.php | 4 ++-- htdocs/comm/propal.php | 4 ++-- htdocs/commande/fiche.php | 2 +- htdocs/commande/index.php | 6 +++--- htdocs/commande/liste.php | 2 +- htdocs/compta/commande/liste.php | 2 +- htdocs/compta/facture.php | 4 ++-- htdocs/compta/facture/impayees.php | 4 ++-- htdocs/compta/index.php | 6 +++--- htdocs/compta/propal.php | 2 +- htdocs/expedition/fiche.php | 10 +++++----- htdocs/exports/export.php | 2 +- htdocs/fichinter/fiche.php | 2 +- htdocs/html.formfile.class.php | 13 +++++++------ htdocs/lib/functions2.lib.php | 14 +++++++++----- htdocs/livraison/fiche.php | 6 +++--- htdocs/soc.php | 2 +- 19 files changed, 47 insertions(+), 42 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 899fb6d1cfc..280aa0dcc65 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -664,7 +664,7 @@ if (window.parent.frames[1]) { show_documents('systemtools','backup',$conf->admin->dir_output.'/backup',$_SERVER['PHP_SELF'],0,1,'','',0,0,54,0,'',$langs->trans("PreviousDumpFiles")); +$result=$formfile->show_documents('systemtools','backup',$conf->admin->dir_output.'/backup',$_SERVER['PHP_SELF'],0,1,'',1,0,0,54,0,'',$langs->trans("PreviousDumpFiles")); //if ($result) print '

'; diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 08f15e72add..5b2276342ee 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -296,7 +296,7 @@ if ($what) } } -$result=$formfile->show_documents('systemtools','backup',$conf->admin->dir_output.'/backup',$_SERVER['PHP_SELF'],0,1,'',array(),0,0,54,0,'',$langs->trans("PreviousDumpFiles")); +$result=$formfile->show_documents('systemtools','backup',$conf->admin->dir_output.'/backup',$_SERVER['PHP_SELF'],0,1,'',1,0,0,54,0,'',$langs->trans("PreviousDumpFiles")); if ($result == 0) { diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 857655fee68..0913e65e63a 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -319,7 +319,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire) $filename=dol_sanitizeFileName($objp->ref); $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($objp->ref); $urlsource=$_SERVER['PHP_SELF'].'?propalid='.$objp->propalid; - $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','','','',1); + $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; print ''; @@ -579,7 +579,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire) $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?propalid='.$obj->propalid; - $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','','','',1); + $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; print ""; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index a7bed3755ba..cbbf0cc6efb 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1955,7 +1955,7 @@ if ($id > 0 || ! empty($ref)) $var=true; - $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf,'',0,0,28,0,'',0,'',$societe->default_lang); + $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf,1,0,0,28,0,'',0,'',$societe->default_lang); /* @@ -2215,7 +2215,7 @@ else $filename=dol_sanitizeFileName($objp->ref); $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($objp->ref); $urlsource=$_SERVER['PHP_SELF'].'?propalid='.$objp->propalid; - $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','','','',1); + $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; if ($objp->client == 1) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index c1c7868653f..c06fc2fdbab 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -2188,7 +2188,7 @@ else $genallowed=$user->rights->commande->creer; $delallowed=$user->rights->commande->supprimer; - $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf,'',0,0,28,0,'','','',$soc->default_lang); + $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); /* * Liste des factures diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index e0ae6bf4a2c..a1e3b124dde 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -173,7 +173,7 @@ if ($resql) $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; - $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','','','',1); + $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; print ''; @@ -240,7 +240,7 @@ if ($conf->commande->enabled) $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; - $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','','','',1); + $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; print ''; @@ -309,7 +309,7 @@ if ($conf->commande->enabled) $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; - $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','','','',1); + $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; print ''; diff --git a/htdocs/commande/liste.php b/htdocs/commande/liste.php index 5b1daf118a9..7960d137855 100644 --- a/htdocs/commande/liste.php +++ b/htdocs/commande/liste.php @@ -205,7 +205,7 @@ if ($resql) $filename=dol_sanitizeFileName($objp->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->rowid; - $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','','','',1); + $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; print ''; diff --git a/htdocs/compta/commande/liste.php b/htdocs/compta/commande/liste.php index 9c708a736ed..b268c84bd73 100644 --- a/htdocs/compta/commande/liste.php +++ b/htdocs/compta/commande/liste.php @@ -151,7 +151,7 @@ if ($resql) $filename=dol_sanitizeFileName($objp->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->rowid; - $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','','','',1); + $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index deb1495c441..662ae73b0da 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3502,7 +3502,7 @@ else $var=true; print '
'; - $somethingshown=$formfile->show_documents('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$fac->modelpdf,'',0,0,28,0,'','','',$soc->default_lang); + $somethingshown=$formfile->show_documents('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$fac->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); /* * Propales rattachees @@ -3961,7 +3961,7 @@ else $filename=dol_sanitizeFileName($objp->facnumber); $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($objp->facnumber); $urlsource=$_SERVER['PHP_SELF'].'?facid='.$objp->facid; - $formfile->show_documents('facture',$filename,$filedir,$urlsource,'','','','','',1); + $formfile->show_documents('facture',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; print ''; diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index 2f0089e2446..9b4c78c0041 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -341,7 +341,7 @@ if ($result) print ''; $filename=dol_sanitizeFileName($objp->facnumber); $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($objp->facnumber); - $foundpdf=$formfile->show_documents('facture',$filename,$filedir,$urlsource,'','','','','',1,$param); + $foundpdf=$formfile->show_documents('facture',$filename,$filedir,$urlsource,'','','',1,'',1,$param); print ''; print ''; @@ -403,7 +403,7 @@ if ($result) print '
'; print ''; - $formfile->show_documents('unpaid','',$filedir,$urlsource,$genallowed,$delallowed,'','',0,0,48,1,$param,'',$langs->trans("PDFMerge")); + $formfile->show_documents('unpaid','',$filedir,$urlsource,$genallowed,$delallowed,'',1,0,0,48,1,$param,'',$langs->trans("PDFMerge")); print ''; $db->free(); diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 5b8ca968beb..3578a304d1d 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -354,7 +354,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire) $filename=dol_sanitizeFileName($obj->facnumber); $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->facnumber); $urlsource=$_SERVER['PHP_SELF'].'?facid='.$obj->rowid; - $formfile->show_documents('facture',$filename,$filedir,$urlsource,'','','','','',1); + $formfile->show_documents('facture',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; print ''; @@ -714,7 +714,7 @@ if ($conf->facture->enabled && $conf->commande->enabled && $user->rights->comman $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; - $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','','','',1); + $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; print ''; @@ -809,7 +809,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire) $filename=dol_sanitizeFileName($obj->facnumber); $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->facnumber); $urlsource=$_SERVER['PHP_SELF'].'?facid='.$obj->rowid; - $formfile->show_documents('facture',$filename,$filedir,$urlsource,'','','','','',1); + $formfile->show_documents('facture',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; print ''; diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index cd81c5dcc74..73dd9644ef1 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -724,7 +724,7 @@ else $filename=dol_sanitizeFileName($objp->ref); $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($objp->ref); $urlsource=$_SERVER['PHP_SELF'].'?propalid='.$objp->propalid; - $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','','','',1); + $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 863228b125e..7236195bb07 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -315,7 +315,7 @@ if ($_GET["action"] == 'create') // Date print "".$langs->trans("Date").""; print ''.dol_print_date($object->date,"day")."\n"; - + // Date delivery planned print ''.$langs->trans("DateDeliveryPlanned").''; print ''.dol_print_date($object->date_livraison,'day')."\n"; @@ -599,7 +599,7 @@ else { print '
'.$mesg.'
'; } - + $typeobject = $expedition->origin; $origin = $expedition->origin; $expedition->fetch_object(); @@ -614,7 +614,7 @@ else // delivery link $expedition->load_object_linked($expedition->id,$expedition->element,-1,-1); - + $head=shipping_prepare_head($expedition); dol_fiche_head($head, 'shipping', $langs->trans("Sending"), 0, 'sending'); @@ -709,7 +709,7 @@ else print ''.$langs->trans("Date").''; print ''.dol_print_date($expedition->date,"daytext")."\n"; print ''; - + // Date delivery planned print ''.$langs->trans("DateDeliveryPlanned").''; print ''.dol_print_date($expedition->date_delivery,'daytext')."\n"; @@ -948,7 +948,7 @@ else //$genallowed=1; //$delallowed=0; - $somethingshown=$formfile->show_documents('expedition',$expeditionref,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf,'',0,0,28,0,'','','',$soc->default_lang); + $somethingshown=$formfile->show_documents('expedition',$expeditionref,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); if ($genallowed && ! $somethingshown) $somethingshown=1; } diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 1d319407de3..d3aaa80bc8c 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -759,7 +759,7 @@ if ($step == 4 && $datatoexport) // Affiche liste des documents // NB: La fonction show_documents rescanne les modules qd genallowed=1, sinon prend $liste - $formfile->show_documents('export','',$conf->export->dir_temp.'/'.$user->id,$_SERVER["PHP_SELF"].'?step=4&datatoexport='.$datatoexport,$liste,1,(! empty($_POST['model'])?$_POST['model']:'csv'),'',1); + $formfile->show_documents('export','',$conf->export->dir_temp.'/'.$user->id,$_SERVER["PHP_SELF"].'?step=4&datatoexport='.$datatoexport,$liste,1,(! empty($_POST['model'])?$_POST['model']:'csv'),1,1); print ' '; print ''; diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index b6d1ea7a021..e8f96683ce7 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -916,7 +916,7 @@ elseif ($fichinterid) $var=true; print "
\n"; - $somethingshown=$formfile->show_documents('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$fichinter->modelpdf,'',0,0,28,0,'','','',$societe->default_lang); + $somethingshown=$formfile->show_documents('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$fichinter->modelpdf,1,0,0,28,0,'','','',$societe->default_lang); print ""; print " "; diff --git a/htdocs/html.formfile.class.php b/htdocs/html.formfile.class.php index cdcc35f33fc..13dd7877c7c 100644 --- a/htdocs/html.formfile.class.php +++ b/htdocs/html.formfile.class.php @@ -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 modelliste Array of possible models. Use '' to hide this combo select list. + * \param showwarning 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='',$modelliste=array(),$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='') + 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='') { // filedir = conf->...dir_ouput."/".get_exdir(id) include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); @@ -153,7 +153,6 @@ class FormFile $genallowed = ''; $delallowed = 0; $modelselected = ''; - $modelliste = ''; $forcenomultilang=0; } @@ -340,7 +339,7 @@ class FormFile // Language code (if multilang) print ''; - if($conf->global->MAIN_MULTILANGS && ! $forcenomultilang) + if (($showwarning || (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,8 +356,10 @@ class FormFile print ''; print ''; - if (is_array($modellist) && ! sizeof($modellist)) + print ' type="submit" value="'.$buttonlabel.'"'; + if (! $showwarning && ! is_array($modellist) && empty($modellist)) print ' disabled="true"'; + print '>'; + if ($showwarning && ! is_array($modellist) && empty($modellist)) { $langs->load("errors"); print ' '.img_warning($langs->trans("WarningNoDocumentModelActivated")); diff --git a/htdocs/lib/functions2.lib.php b/htdocs/lib/functions2.lib.php index 2bd731fdfb6..96ffaeb86ca 100644 --- a/htdocs/lib/functions2.lib.php +++ b/htdocs/lib/functions2.lib.php @@ -1013,14 +1013,15 @@ function picto_from_langcode($codelang) /** * \brief Return list of activated modules usable for document generation. - * \param $db Database handler - * \param $type Type of models (company, invoice, ...) - * \return array array(key=>label). For modules that need directory scan, key is completed with ":filename". + * \param $db Database handler + * \param $type Type of models (company, invoice, ...) + * \return int or array 0 if no module is activated, or array(key=>label). For modules that need directory scan, key is completed with ":filename". */ function getListOfModels($db,$type) { global $conf; $liste=array(); + $found=0; $dirtoscan=''; @@ -1036,10 +1037,12 @@ function getListOfModels($db,$type) $i = 0; while ($i < $num) { + $found=1; + $obj = $db->fetch_object($resql); // If this generation module needs a directory scan, then description field is filled - // with constant that constains list of directories. + // with the constant that contains list of directories to scan. if (! empty($obj->description)) { $const=$obj->description; @@ -1079,5 +1082,6 @@ function getListOfModels($db,$type) return -1; } - return $liste; + if ($found) return $liste; + else return 0; } diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php index 1ce9dede4e2..4ba2719d16c 100644 --- a/htdocs/livraison/fiche.php +++ b/htdocs/livraison/fiche.php @@ -473,7 +473,7 @@ else print ''.$langs->trans("Date").''; print ''.dol_print_date($delivery->date_creation,'daytext')."\n"; print ''; - + // Date delivery planned print ''.$langs->trans("DateDeliveryPlanned").''; print ''.dol_print_date($delivery->date_delivery,'daytext')."\n"; @@ -573,7 +573,7 @@ else if ($user->societe_id == 0) { print '
'; - + if ($delivery->statut == 0 && $user->rights->expedition->livraison->valider && $num_prod > 0) { print ''.$langs->trans("Validate").''; @@ -608,7 +608,7 @@ else $genallowed=$user->rights->expedition->livraison->creer; $delallowed=$user->rights->expedition->livraison->supprimer; - $somethingshown=$formfile->show_documents('livraison',$deliveryref,$filedir,$urlsource,$genallowed,$delallowed,$delivery->modelpdf,'',0,0,28,0,'','','',$soc->default_lang); + $somethingshown=$formfile->show_documents('livraison',$deliveryref,$filedir,$urlsource,$genallowed,$delallowed,$delivery->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); if ($genallowed && ! $somethingshown) $somethingshown=1; print ''; diff --git a/htdocs/soc.php b/htdocs/soc.php index 362d3d79a0f..2bb73c8afc5 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -1451,7 +1451,7 @@ else $var=true; - $somethingshown=$formfile->show_documents('company',$soc->id,$filedir,$urlsource,$genallowed,$delallowed,'','',0,0,28,0,'',0,'',$soc->default_lang); + $somethingshown=$formfile->show_documents('company',$soc->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$soc->default_lang); print ''; print '';