diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 25a220e8e2d..cde0253f99a 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -111,11 +111,9 @@ if ($action == 'updateMask') } // Activate a model -elseif ($action == 'set') -{ +elseif ($action == 'set') { $ret = addDocumentModel($value, $type, $label, $scandir); -} elseif ($action == 'del') -{ +} elseif ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { @@ -124,8 +122,7 @@ elseif ($action == 'set') } // Set default model -elseif ($action == 'setdoc') -{ +elseif ($action == 'setdoc') { if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { // The constant that was read before the new set @@ -139,8 +136,7 @@ elseif ($action == 'setdoc') { $ret = addDocumentModel($value, $type, $label, $scandir); } -} elseif ($action == 'setmod') -{ +} elseif ($action == 'setmod') { // TODO Check if numbering module chosen can be activated // by calling method canBeActivated @@ -254,6 +250,7 @@ print dol_get_fiche_head($head, 'general', $langs->trans("Orders"), -1, 'order') print load_fiche_titre($langs->trans("OrdersNumberingModules"), '', ''); +print '
'; print ''; print ''; print ''; @@ -346,7 +343,7 @@ foreach ($dirmodels as $reldir) } } } -print "
'.$langs->trans("Name").'

\n"; +print "

\n"; /* @@ -377,6 +374,7 @@ if ($resql) } +print '
'; print "\n"; print "\n"; print ''; @@ -501,6 +499,7 @@ foreach ($dirmodels as $reldir) } print '
'.$langs->trans("Name").'
'; +print '
'; /* diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index c1546f1da2c..f7e72f53e7e 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -44,10 +44,13 @@ $type = 'ticket'; $error = 0; + /* * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'updateMask') { $maskconstticket = GETPOST('maskconstticket', 'alpha'); $maskticket = GETPOST('maskticket', 'alpha'); @@ -66,7 +69,37 @@ if ($action == 'updateMask') { } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'setmod') { +} + +// Activate a model +elseif ($action == 'set') { + $ret = addDocumentModel($value, $type, $label, $scandir); +} elseif ($action == 'del') { + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->TICKET_ADDON_PDF == "$value") dolibarr_del_const($db, 'TICKET_ADDON_PDF', $conf->entity); + } +} + +// Set default model +elseif ($action == 'setdoc') { + if (dolibarr_set_const($db, "TICKET_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) + { + // The constant that was read before the new set + // We therefore requires a variable to have a coherent view + $conf->global->TICKET_ADDON_PDF = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} + +elseif ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated @@ -190,7 +223,7 @@ print dol_get_fiche_end(); /* - * Projects Numbering model + * Tickets numbering model */ print load_fiche_titre($langs->trans("TicketNumberingModules"), '', ''); @@ -291,6 +324,162 @@ print ''; print ''; print '
'; + + +/* + * Document templates generators + */ + +print load_fiche_titre($langs->trans("TicketsModelModule"), '', ''); + +// Load array def with activated templates +$def = array(); +$sql = "SELECT nom"; +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$db->escape($type)."'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); +if ($resql) +{ + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } +} else { + dol_print_error($db); +} + + +print '
'; +print "\n"; +print "\n"; +print ''; +print ''; +print '\n"; +print '\n"; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) +{ + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/ticket".$valdir; + $dir = dol_buildpath($realpath); + + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); + + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $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 ''; + + // Active + if (in_array($name, $def)) + { + print ''; + } else { + print '"; + } + + // Default + 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("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + //$htmltooltip .= '
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); + //$htmltooltip .= '
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); + //$htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + + + print ''; + + // Preview + print ''; + + print "\n"; + } + } + } + } + } + } + } +} + +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; + if ($conf->global->TICKET_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'pdf').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
'; +print '

'; + + if (!$conf->use_javascript_ajax) { print '
'; print ''; diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index b5e1fc80a1d..18f2d405acf 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -162,10 +162,10 @@ class doc_generic_bom_odt extends ModelePDFBom if ($nbofiles) { - $texte .= '