diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 2568f9229d9..fffc94b679f 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -364,12 +364,12 @@ print ''; /* - * Modeles de documents + * Document templates generators */ print '
'; print_titre($langs->trans("BillsPDFModules")); -// Defini tableau def de modele invoice +// Load array def with activated templates $def = array(); $sql = "SELECT nom"; $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; @@ -407,91 +407,113 @@ clearstatcache(); $var=true; foreach ($conf->file->dol_document_root as $dirroot) { - $dir = $dirroot . "/includes/modules/facture/"; - - if (is_dir($dir)) + foreach (array('','/doc') as $valdir) { - $handle=opendir($dir); - if ($handle) + $dir = $dirroot . "/includes/modules/facture".$valdir; + + if (is_dir($dir)) { - while (($file = readdir($handle))!==false) + $handle=opendir($dir); + if ($handle) { - if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + while (($file = readdir($handle))!==false) { - $var = !$var; - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); - - require_once($dir.$file); - $module = new $classname($db); - - print ''; - print (empty($module->name)?$name:$module->name); - print "\n"; - if (method_exists($module,'info')) print $module->info($langs); - else print $module->description; - print ''; - - // Active - if (in_array($name, $def)) + if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) { - print "\n"; - if ($conf->global->FACTURE_ADDON_PDF != "$name") + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); + + require_once($dir.'/'.$file); + $module = new $classname($db); + + $modulequalified=1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + + if ($modulequalified) { - print ''; - print img_picto($langs->trans("Enabled"),'on'); - print ''; + $var = !$var; + print ''; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module,'info')) print $module->info($langs); + else print $module->description; + print ''; + + // Active + if (in_array($name, $def)) + { + print "\n"; + if ($conf->global->FACTURE_ADDON_PDF != "$name") + { + print ''; + print img_picto($langs->trans("Enabled"),'on'); + print ''; + } + else + { + print img_picto($langs->trans("Enabled"),'on'); + } + print ""; + } + else + { + print "\n"; + print ''.img_picto($langs->trans("Disabled"),'off').''; + print ""; + } + + // Defaut + print ""; + if ($conf->global->FACTURE_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print ''.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip.='
'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; + } + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); + $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); + $htmltooltip.='
'.$langs->trans("Escompte").': '.yn($module->option_escompte,1,1); + $htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); + $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); + $htmltooltip.='
'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark,1,1); + + + print ''; + print $html->textwithpicto('',$htmltooltip,1,0); + print ''; + + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"),'bill').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"),'generic'); + } + print ''; + + print "\n"; } - else - { - print img_picto($langs->trans("Enabled"),'on'); - } - print ""; } - else - { - print "\n"; - print ''.img_picto($langs->trans("Disabled"),'off').''; - print ""; - } - - // Defaut - print ""; - if ($conf->global->FACTURE_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print ''.img_picto($langs->trans("Disabled"),'off').''; - } - print ''; - - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - $htmltooltip.='
'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); - $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); - $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); - $htmltooltip.='
'.$langs->trans("Escompte").': '.yn($module->option_escompte,1,1); - $htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); - $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); - $htmltooltip.='
'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark,1,1); - - - print ''; - print $html->textwithpicto('',$htmltooltip,1,0); - print ''; - print ''; - print ''.img_object($langs->trans("Preview"),'bill').''; - print ''; - - print "\n"; } + closedir($handle); } - closedir($handle); } } } diff --git a/htdocs/admin/societe.php b/htdocs/admin/societe.php index 8d71c84d2ab..a16f3b9d19c 100644 --- a/htdocs/admin/societe.php +++ b/htdocs/admin/societe.php @@ -300,14 +300,13 @@ if ($handle) print "\n"; -// /* - * Modeles de documents + * Document templates generators */ print '
'; print_titre($langs->trans("ModelModules")); -// Defini tableau def de modele invoice +// Load array def with activated templates $def = array(); $sql = "SELECT nom"; $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; @@ -355,78 +354,87 @@ foreach ($conf->file->dol_document_root as $dirroot) { if (preg_match('/\.modules\.php$/i',$file)) { - $var = !$var; $name = substr($file, 4, dol_strlen($file) -16); $classname = substr($file, 0, dol_strlen($file) -12); require_once($dir.'/'.$file); $module = new $classname($db); - print ''; - print $module->name; - print "\n"; - if (method_exists($module,'info')) print $module->info($langs); - else print $module->description; - print ''; + $modulequalified=1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; - // Activate / Disable - if (in_array($name, $def)) + if ($modulequalified) { - print "\n"; - //if ($conf->global->COMPANY_ADDON_PDF != "$name") - //{ - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"),'on'); - print ''; - //} - //else - //{ - // print img_picto($langs->trans("Enabled"),'on'); - //} - print ""; - } - else - { - if (versioncompare($module->phpmin,versionphparray()) > 0) + $var = !$var; + print ''; + print $module->name; + print "\n"; + if (method_exists($module,'info')) print $module->info($langs); + else print $module->description; + print ''; + + // Activate / Disable + if (in_array($name, $def)) { print "\n"; - print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion",join('.',$module->phpmin))),'off'); + //if ($conf->global->COMPANY_ADDON_PDF != "$name") + //{ + print 'scandir.'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Enabled"),'on'); + print ''; + //} + //else + //{ + // print img_picto($langs->trans("Enabled"),'on'); + //} print ""; } else { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'off').''; - print ""; + if (versioncompare($module->phpmin,versionphparray()) > 0) + { + print "\n"; + print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion",join('.',$module->phpmin))),'off'); + print ""; + } + else + { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'off').''; + print ""; + } } - } - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - if ($modele->type == 'pdf') - { - $htmltooltip.='
'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; - } - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("WatermarkOnDraft").': '.yn($module->option_draft_watermark,1,1); + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + if ($modele->type == 'pdf') + { + $htmltooltip.='
'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; + } + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("WatermarkOnDraft").': '.yn($module->option_draft_watermark,1,1); - print ''; - print $form->textwithpicto('',$htmltooltip,1,0); - print ''; - print ''; - if ($modele->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"),'bill').''; - } - else - { - print img_object($langs->trans("PreviewNotAvailable"),'generic'); - } - print ''; + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; - print "\n"; + // Preview + print ''; + if ($modele->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"),'bill').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"),'generic'); + } + print ''; + + print "\n"; + } } } closedir($handle); diff --git a/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php index 36d08370b7e..052e42fccaf 100644 --- a/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -41,7 +41,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures var $emetteur; // Objet societe qui emet var $phpmin = array(5,2,0); // Minimum version of PHP required by module - + var $version = 'development'; /** * \brief Constructor @@ -70,6 +70,15 @@ class doc_generic_invoice_odt extends ModelePDFFactures $this->marge_basse=0; $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; // Support add of a watermark on drafts // Recupere emmetteur $this->emetteur=$mysoc; diff --git a/htdocs/includes/modules/modFacture.class.php b/htdocs/includes/modules/modFacture.class.php index 3eeb31bee6d..5ef5e6a5b0f 100644 --- a/htdocs/includes/modules/modFacture.class.php +++ b/htdocs/includes/modules/modFacture.class.php @@ -207,15 +207,16 @@ class modFacture extends DolibarrModules /** - * \brief Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module. - * Definit egalement les repertoires de donnees a creer pour ce module. + * Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module. + * Definit egalement les repertoires de donnees a creer pour ce module. + * @param options Options when enabling module */ - function init() + function init($options='') { global $conf; // Remove permissions and default values - $this->remove(); + $this->remove($options); require_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); $dirodt=DOL_DATA_ROOT.'/doctemplates/invoices'; @@ -227,23 +228,19 @@ class modFacture extends DolibarrModules "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','invoice',".$conf->entity.")", ); - return $this->_init($sql); + return $this->_init($sql,$option); } /** - * \brief Fonction appelee lors de la desactivation d'un module. - * Supprime de la base les constantes, boites et permissions du module. + * Fonction appelee lors de la desactivation d'un module. + * Supprime de la base les constantes, boites et permissions du module. + * @param options Options when disabling module */ - function remove() + function remove($options='') { - require_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); - $dirodt=DOL_DATA_ROOT.'/doctemplates/invoices'; - create_exdir($dirodt); - dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/invoices/template_invoice.odt',$dirodt.'/template_invoice.odt',0,0); - $sql = array(); - return $this->_remove($sql); + return $this->_remove($sql,$options); } } ?> diff --git a/htdocs/includes/modules/modSociete.class.php b/htdocs/includes/modules/modSociete.class.php index d4707bbccf8..ab8861607ea 100644 --- a/htdocs/includes/modules/modSociete.class.php +++ b/htdocs/includes/modules/modSociete.class.php @@ -265,9 +265,9 @@ class modSociete extends DolibarrModules /** - * \brief Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module. - * Definit egalement les repertoires de donnees a creer pour ce module. - * \param options Options when enabling module + * Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module. + * Definit egalement les repertoires de donnees a creer pour ce module. + * @param options Options when enabling module */ function init($options='') { @@ -287,9 +287,9 @@ class modSociete extends DolibarrModules } /** - * \brief Fonction appelee lors de la desactivation d'un module. - * Supprime de la base les constantes, boites et permissions du module. - * \param options Options when disabling module + * Fonction appelee lors de la desactivation d'un module. + * Supprime de la base les constantes, boites et permissions du module. + * @param options Options when disabling module */ function remove($options='') {