Fix: merge problem

This commit is contained in:
Regis Houssin 2012-03-01 08:03:27 +01:00
parent f3cb926c3c
commit 6aa7e90834
4 changed files with 142 additions and 103 deletions

View File

@ -76,32 +76,41 @@ if ($action == 'specimen') // For orders
$commande->initAsSpecimen(); $commande->initAsSpecimen();
$commande->thirdparty=$specimenthirdparty; $commande->thirdparty=$specimenthirdparty;
// Charge le modele // Search template files
$dir = "/core/modules/supplier_order/pdf/"; $file=''; $classname=''; $filefound=0;
$file = "pdf_".$modele.".modules.php"; $dirmodels=array_merge(array('/'),$conf->modules_parts['models']);
$file = dol_buildpath($dir.$file); foreach($dirmodels as $reldir)
if (file_exists($file))
{ {
$classname = "pdf_".$modele; $file=dol_buildpath($reldir."core/modules/supplier_order/pdf/pdf_".$modele.".modules.php",0);
require_once($file); if (file_exists($file))
{
$filefound=1;
$classname = "pdf_".$modele;
break;
}
}
$obj = new $classname($db,$commande); if ($filefound)
{
require_once($file);
if ($obj->write_file($commande,$langs) > 0) $module = new $classname($db);
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); if ($module->write_file($commande,$langs) > 0)
return; {
} header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf");
else return;
{ }
$mesg='<div class="error">'.$obj->error.'</div>'; else
dol_syslog($obj->error, LOG_ERR); {
} $mesg='<font class="error">'.$module->error.'</font>';
dol_syslog($module->error, LOG_ERR);
}
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>'; $mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} }
@ -113,32 +122,41 @@ if ($action == 'specimenfacture') // For invoices
$facture->initAsSpecimen(); $facture->initAsSpecimen();
$facture->thirdparty=$specimenthirdparty; // Define who should has build the invoice (so the supplier) $facture->thirdparty=$specimenthirdparty; // Define who should has build the invoice (so the supplier)
// Charge le modele // Search template files
$dir = "/core/modules/supplier_invoice/pdf/"; $file=''; $classname=''; $filefound=0;
$file = "pdf_".$modele.".modules.php"; $dirmodels=array_merge(array('/'),$conf->modules_parts['models']);
$file = dol_buildpath($dir.$file); foreach($dirmodels as $reldir)
if (file_exists($file))
{ {
$classname = "pdf_".$modele; $file=dol_buildpath($reldir."core/modules/supplier_invoice/pdf/pdf_".$modele.".modules.php",0);
require_once($file); if (file_exists($file))
{
$filefound=1;
$classname = "pdf_".$modele;
break;
}
}
$obj = new $classname($db,$facture); if ($filefound)
{
require_once($file);
if ($obj->write_file($facture,$langs) > 0) $module = new $classname($db);
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf"); if ($module->write_file($facture,$langs) > 0)
return; {
} header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
else return;
{ }
$mesg='<div class="error">'.$obj->error.'</div>'; else
dol_syslog($obj->error, LOG_ERR); {
} $mesg='<font class="error">'.$module->error.'</font>';
dol_syslog($module->error, LOG_ERR);
}
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>'; $mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} }
@ -244,10 +262,12 @@ if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT')
* View * View
*/ */
$form=new Form($db); $dirmodels=array_merge(array('/'),$conf->modules_parts['models']);
llxHeader(); llxHeader();
$form=new Form($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("SuppliersSetup"),$linkback,'setup'); print_fiche_titre($langs->trans("SuppliersSetup"),$linkback,'setup');
@ -269,9 +289,9 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($conf->file->dol_document_root as $dirroot) foreach ($dirmodels as $reldir)
{ {
$dir = $dirroot . "/core/modules/supplier_order/"; $dir = dol_buildpath($reldir."core/modules/supplier_order/");
if (is_dir($dir)) if (is_dir($dir))
{ {
@ -403,9 +423,9 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($conf->file->dol_document_root as $dirroot) foreach ($dirmodels as $reldir)
{ {
$dir = $dirroot . "/core/modules/supplier_order/pdf/"; $dir = dol_buildpath($reldir."core/modules/supplier_order/pdf/");
if (is_dir($dir)) if (is_dir($dir))
{ {
@ -536,9 +556,9 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($conf->file->dol_document_root as $dirroot) foreach ($dirmodels as $reldir)
{ {
$dir = $dirroot . "/core/modules/supplier_invoice/pdf/"; $dir = dol_buildpath($reldir."core/modules/supplier_invoice/pdf/");
if (is_dir($dir)) if (is_dir($dir))
{ {
@ -645,7 +665,6 @@ print '</form>';
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
llxFooter();
$db->close(); $db->close();
llxFooter();
?> ?>

View File

@ -65,9 +65,6 @@ class Conf
public $barcode_modules = array(); public $barcode_modules = array();
public $substitutions_modules = array(); public $substitutions_modules = array();
public $societe_modules = array(); public $societe_modules = array();
public $facture_modules = array();
public $commande_modules = array();
public $propale_modules = array();
var $logbuffer = array(); var $logbuffer = array();
@ -171,7 +168,7 @@ class Conf
$arrValue = @unserialize($value); $arrValue = @unserialize($value);
if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue; if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue;
else if (in_array($partname,array('login','menus','triggers'))) $value = '/'.$modulename.'/core/'.$partname.'/'; else if (in_array($partname,array('login','menus','triggers'))) $value = '/'.$modulename.'/core/'.$partname.'/';
else if (in_array($partname,array('models','facture','commande','propale'))) $value = '/'.$modulename.'/'; else if (in_array($partname,array('models'))) $value = '/'.$modulename.'/';
else if ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/'; else if ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/';
$this->$varname = array_merge($this->$varname, array($modulename => $value)); // TODO deprecated $this->$varname = array_merge($this->$varname, array($modulename => $value)); // TODO deprecated
$this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value));

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> /* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -76,7 +77,6 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs)
@set_time_limit(120); @set_time_limit(120);
error_reporting($err); error_reporting($err);
$dir = "/core/modules/supplier_invoice/";
$srctemplatepath=''; $srctemplatepath='';
// Positionne modele sur le nom du modele de invoice fournisseur a utiliser // Positionne modele sur le nom du modele de invoice fournisseur a utiliser
@ -102,19 +102,23 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs)
// Search template file // Search template file
$file=''; $classname=''; $filefound=0; $file=''; $classname=''; $filefound=0;
foreach(array('doc','pdf') as $prefix) $dirmodels=array_merge(array('/'),$conf->modules_parts['models']);
foreach($dirmodels as $reldir)
{ {
$file = $prefix."_".$modele.".modules.php"; foreach(array('doc','pdf') as $prefix)
{
$file = $prefix."_".$modele.".modules.php";
// On verifie l'emplacement du modele // On verifie l'emplacement du modele
$file = dol_buildpath($dir.'pdf/'.$file); // TODO rename into doc/ $file=dol_buildpath($reldir."core/modules/supplier_invoice/pdf/".$file,0);
if (file_exists($file))
if (file_exists($file)) {
{ $filefound=1;
$filefound=1; $classname=$prefix.'_'.$modele;
$classname=$prefix.'_'.$modele; break;
break; }
} }
if ($filefound) break;
} }
// Charge le modele // Charge le modele

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* *
@ -154,42 +154,61 @@ function supplier_order_pdf_create($db, $object, $model, $outputlangs, $hidedeta
global $conf,$langs; global $conf,$langs;
$langs->load("suppliers"); $langs->load("suppliers");
$dir = "/core/modules/supplier_order/pdf/"; $error=0;
// Increase limit for PDF build
$err=error_reporting();
error_reporting(0);
@set_time_limit(120);
error_reporting($err);
$srctemplatepath=''; $srctemplatepath='';
$modelisok=0;
$liste=array();
// Positionne modele sur le nom du modele de commande fournisseur a utiliser // Positionne le modele sur le nom du modele a utiliser
$file = "pdf_".$model.".modules.php"; if (! dol_strlen($modele))
// On verifie l'emplacement du modele
$file = dol_buildpath($dir.$file);
if ($model && file_exists($file)) $modelisok=1;
// Si model pas encore bon
if (! $modelisok)
{ {
if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF) $model = $conf->global->COMMANDE_SUPPLIER_ADDON_PDF; if (! empty($conf->global->COMMANDE_SUPPLIER_ADDON_PDF))
$file = "pdf_".$model.".modules.php"; {
// On verifie l'emplacement du modele $modele = $conf->global->COMMANDE_SUPPLIER_ADDON_PDF;
$file = dol_buildpath($dir.$file); }
if (file_exists($file)) $modelisok=1; else
{
$modele = 'muscadet';
}
} }
// Si model pas encore bon // If selected modele is a filename template (then $modele="modelname:filename")
if (! $modelisok) $tmp=explode(':',$modele,2);
if (! empty($tmp[1]))
{ {
$liste=ModelePDFSuppliersOrders::liste_modeles($db); $modele=$tmp[0];
$model=key($liste); // Renvoie la premiere valeur de cle trouvee dans le tableau $srctemplatepath=$tmp[1];
$file = "pdf_".$model.".modules.php"; }
// On verifie l'emplacement du modele
$file = dol_buildpath($dir.$file); // Search template files
if (file_exists($file)) $modelisok=1; $file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'),$conf->modules_parts['models']);
foreach($dirmodels as $reldir)
{
foreach(array('doc','pdf') as $prefix)
{
$file = $prefix."_".$modele.".modules.php";
// On verifie l'emplacement du modele
$file=dol_buildpath($reldir."core/modules/supplier_order/pdf/".$file,0);
if (file_exists($file))
{
$filefound=1;
$classname=$prefix.'_'.$modele;
break;
}
}
if ($filefound) break;
} }
// Charge le modele // Charge le modele
if ($modelisok) if ($filefound)
{ {
$classname = "pdf_".$model;
require_once($file); require_once($file);
$obj = new $classname($db); $obj = new $classname($db);