Skip to content

Commit

Permalink
Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git …
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
eldy committed Apr 4, 2012
2 parents a98439a + cd170db commit d30cd86
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions htdocs/admin/expedition.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
*
* 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
Expand Down Expand Up @@ -55,28 +56,36 @@

$exp = new Expedition($db);
$exp->initAsSpecimen();
//$exp->fetch_commande();

// Charge le modele
$dir = "/core/modules/expedition/doc/";
$file = "pdf_expedition_".$modele.".modules.php";
$file = dol_buildpath($dir.$file);
if (file_exists($file))
// Search template files
$file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
{
$file=dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php",0);
if (file_exists($file))
{
$filefound=1;
$classname = "pdf_".$modele;
break;
}
}

if ($filefound)
{
$classname = "pdf_expedition_".$modele;
require_once($file);

$obj = new $classname($db);
$module = new $classname($db);

if ($obj->write_file($exp,$langs) > 0)
if ($module->write_file($exp,$langs) > 0)
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expedition&file=SPECIMEN.pdf");
return;
}
else
{
$mesg='<font class="error">'.$obj->error.'</font>';
dol_syslog($obj->error, LOG_ERR);
$mesg='<font class="error">'.$module->error.'</font>';
dol_syslog($module->error, LOG_ERR);
}
}
else
Expand Down Expand Up @@ -298,8 +307,9 @@
* View
*/

$form=new Form($db);
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);

$form=new Form($db);

llxHeader("","");

Expand Down Expand Up @@ -349,9 +359,9 @@

clearstatcache();

foreach ($conf->file->dol_document_root as $dirroot)
foreach ($dirmodels as $reldir)
{
$dir = $dirroot . "/core/modules/expedition/";
$dir = dol_buildpath($reldir."core/modules/expedition/");

if (is_dir($dir))
{
Expand All @@ -362,9 +372,10 @@

while (($file = readdir($handle))!==false)
{
if (substr($file, 0, 15) == 'mod_expedition_' && substr($file, dol_strlen($file)-3, 3) == 'php')
if (preg_match('/^(mod_.*)\.php$/i',$file,$reg))
{
$file = substr($file, 0, dol_strlen($file)-4);
$file = $reg[1];
$classname = substr($file,4);

require_once(DOL_DOCUMENT_ROOT ."/core/modules/expedition/".$file.".php");

Expand Down Expand Up @@ -482,15 +493,14 @@

clearstatcache();

foreach ($conf->file->dol_document_root as $dirroot)
$var=true;
foreach ($dirmodels as $reldir)
{
$dir = $dirroot . "/core/modules/expedition/doc/";
$dir = dol_buildpath($reldir."core/modules/expedition/doc/");

if (is_dir($dir))
{
$handle=opendir($dir);
$var=true;

if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
Expand Down Expand Up @@ -613,4 +623,4 @@
$db->close();

llxFooter();
?>
?>

0 comments on commit d30cd86

Please sign in to comment.