diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php index ee90787bb0b..49efb405c11 100644 --- a/htdocs/admin/fournisseur.php +++ b/htdocs/admin/fournisseur.php @@ -5,6 +5,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2011 Philippe Grand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -70,12 +71,13 @@ if ($action == 'specimen') // For orders $commande->thirdparty=$specimenthirdparty; // Charge le modele - $dir = DOL_DOCUMENT_ROOT . "/includes/modules/supplier_order/pdf/"; + $dir = "/includes/modules/supplier_order/pdf/"; $file = "pdf_".$modele.".modules.php"; - if (file_exists($dir.$file)) + $file = dol_buildpath($dir.$file); + if (file_exists($file)) { $classname = "pdf_".$modele; - require_once($dir.$file); + require_once($file); $obj = new $classname($db,$commande); @@ -106,7 +108,7 @@ if ($action == 'specimenfacture') // For invoices $facture->thirdparty=$specimenthirdparty; // Charge le modele - $dir = DOL_DOCUMENT_ROOT . "/includes/modules/supplier_invoice/pdf/"; + $dir = "/includes/modules/supplier_invoice/pdf/"; $file = "pdf_".$modele.".modules.php"; if (file_exists($dir.$file)) { @@ -233,8 +235,6 @@ print "
"; // Supplier order numbering module -$dir = DOL_DOCUMENT_ROOT."/includes/modules/supplier_order/"; - print_titre($langs->trans("OrdersNumberingModules")); print ''; @@ -248,80 +248,88 @@ print "\n"; clearstatcache(); -$handle = opendir($dir); -if (is_resource($handle)) +foreach ($conf->file->dol_document_root as $dirroot) { - $var=true; + $dir = $dirroot . "/includes/modules/supplier_order/"; - while (($file = readdir($handle))!==false) + if (is_dir($dir)) { - if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file)-3, 3) == 'php') + $handle = opendir($dir); + if (is_resource($handle)) { - $file = substr($file, 0, dol_strlen($file)-4); + $var=true; - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/supplier_order/".$file.".php"); - - $module = new $file; - - if ($module->isEnabled()) + while (($file = readdir($handle))!==false) { - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - - $var=!$var; - print ''; - - // Show example of numbering module - print ''."\n"; - - print ''; + $file = substr($file, 0, dol_strlen($file)-4); - $commande=new CommandeFournisseur($db); - $commande->initAsSpecimen(); + require_once($dir.$file.".php"); - // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $facture->type=0; - $nextval=$module->getNextValue($mysoc,$commande); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { - $htmltooltip.=''.$langs->trans("NextValue").': '; - if ($nextval) + $module = new $file; + + if ($module->isEnabled()) { - $htmltooltip.=$nextval.'
'; - } - else - { - $htmltooltip.=$langs->trans($module->error).'
'; + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + $var=!$var; + print ''; + + // Show example of numbering module + print ''."\n"; + + print ''; + + $commande=new CommandeFournisseur($db); + $commande->initAsSpecimen(); + + // Info + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $facture->type=0; + $nextval=$module->getNextValue($mysoc,$commande); + if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval + { + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) + { + $htmltooltip.=$nextval.'
'; + } + else + { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + + print ''; + + print ''; } } - - print ''; - - print ''; } + closedir($handle); } } - closedir($handle); } print '
'.$module->nom."\n"; - print $module->info(); - print ''; - $tmp=$module->getExample(); - if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp); - else print $tmp; - print ''; - if ($conf->global->COMMANDE_SUPPLIER_ADDON == "$file") + if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file)-3, 3) == 'php') { - print img_picto($langs->trans("Activated"),'on'); - } - else - { - print ''.img_picto($langs->trans("Disabled"),'off').''; - } - print '
'.$module->nom."\n"; + print $module->info(); + print ''; + $tmp=$module->getExample(); + if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp); + else print $tmp; + print ''; + if ($conf->global->COMMANDE_SUPPLIER_ADDON == "$file") + { + print img_picto($langs->trans("Activated"),'on'); + } + else + { + print ''.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + print $html->textwithpicto('',$htmltooltip,1,0); + print '
'; - print $html->textwithpicto('',$htmltooltip,1,0); - print '

'; @@ -333,8 +341,6 @@ print '
'; * Modeles documents for supplier orders */ -$dir = DOL_DOCUMENT_ROOT.'/includes/modules/supplier_order/pdf/'; - print_titre($langs->trans("OrdersModelModule")); // Defini tableau def de modele @@ -373,82 +379,92 @@ print ''."\n"; clearstatcache(); -$handle=opendir($dir); - -$var=true; -if (is_resource($handle)) +foreach ($conf->file->dol_document_root as $dirroot) { - while (($file = readdir($handle))!==false) - { - if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_') - { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $dir = $dirroot . "/includes/modules/supplier_order/pdf/"; - $var=!$var; - print "\n"; - print "".$name."\n"; - print "\n"; - require_once($dir.$file); - $module = new $classname($db,$specimenthirdparty); - print $module->description; - print "\n"; + if (is_dir($dir)) + { + $var=true; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") - { - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; - 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).'&type=order_supplier">'.img_picto($langs->trans("Disabled"),'off').''; - print ""; - } + $handle=opendir($dir); - // Defaut - print ''; - if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier"" alt="'.$langs->trans("Default").'">'.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("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $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); - print ''; - print $html->textwithpicto('',$htmltooltip,1,0); - print ''; - print ''; - print ''.img_object($langs->trans("Preview"),'order').''; - print ''; + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_') + { + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); - print "\n"; - } - } + $var=!$var; + print "\n"; + print "".$name."\n"; + print "\n"; + require_once($dir.$file); + $module = new $classname($db,$specimenthirdparty); + print $module->description; + print "\n"; - closedir($handle); + // Active + if (in_array($name, $def)) + { + print ''."\n"; + if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") + { + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; + 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).'&type=order_supplier">'.img_picto($langs->trans("Disabled"),'off').''; + print ""; + } + + // Defaut + print ''; + if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier"" alt="'.$langs->trans("Default").'">'.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("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $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); + print ''; + print $html->textwithpicto('',$htmltooltip,1,0); + print ''; + print ''; + print ''.img_object($langs->trans("Preview"),'order').''; + print ''; + + print "\n"; + } + } + + closedir($handle); + } + } } print '
'; @@ -457,8 +473,6 @@ print '
'; * Modeles documents for supplier invoices */ -$dir = DOL_DOCUMENT_ROOT.'/includes/modules/supplier_invoice/pdf/'; - print_titre($langs->trans("BillsPDFModules")); // Defini tableau def de modele @@ -497,80 +511,90 @@ print ''."\n"; clearstatcache(); -$handle=opendir($dir); -$var=true; -if (is_resource($handle)) +foreach ($conf->file->dol_document_root as $dirroot) { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_') - { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $dir = $dirroot . "/includes/modules/supplier_invoice/pdf/"; - $var=!$var; - print "\n"; - print "".$name."\n"; - print ""; - require_once($dir.$file); - $module = new $classname($db,$specimenthirdparty); - print $module->description; - print "\n"; + if (is_dir($dir)) + { + $var=true; - // Active - if (in_array($name, $def)) - { - print "\n"; - if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name") - { - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'; - 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).'&type=invoice_supplier">'.img_picto($langs->trans("Disabled"),'off').''; - print ""; - } + $handle=opendir($dir); - // Defaut - print ""; - if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; - } - print ''; + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_') + { + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $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); - print ''; - print $html->textwithpicto('',$htmltooltip,1,0); - print ''; - print ''; - print ''.img_object($langs->trans("Preview"),'bill').''; - print ''; + $var=!$var; + print "\n"; + print "".$name."\n"; + print ""; + require_once($dir.$file); + $module = new $classname($db,$specimenthirdparty); + print $module->description; + print "\n"; - print "\n"; - } - } - closedir($handle); + // Active + if (in_array($name, $def)) + { + print "\n"; + if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name") + { + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'; + 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).'&type=invoice_supplier">'.img_picto($langs->trans("Disabled"),'off').''; + print ""; + } + + // Defaut + print ""; + if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier" alt="'.$langs->trans("Default").'">'.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("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $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); + print ''; + print $html->textwithpicto('',$htmltooltip,1,0); + print ''; + print ''; + print ''.img_object($langs->trans("Preview"),'bill').''; + print ''; + + print "\n"; + } + } + closedir($handle); + } + } } print '
';