Qual: big uniformize code
This commit is contained in:
parent
9664f0af5f
commit
683fcb75c4
@ -134,14 +134,14 @@ class ModeleNumRefProjects
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Create object on disk
|
* Create object on disk
|
||||||
* \param db objet base de donnee
|
* @param db objet base de donnee
|
||||||
* \param deliveryid id object
|
* @param object object project
|
||||||
* \param modele force le modele a utiliser ('' to not force)
|
* @param model force le modele a utiliser ('' to not force)
|
||||||
* \param outputlangs objet lang a utiliser pour traduction
|
* @param outputlangs objet lang a utiliser pour traduction
|
||||||
* \return int 0 si KO, 1 si OK
|
* @return int 0 si KO, 1 si OK
|
||||||
*/
|
*/
|
||||||
function project_pdf_create($db, $comid, $modele,$outputlangs)
|
function project_pdf_create($db, $object, $model,$outputlangs)
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
@ -149,25 +149,25 @@ function project_pdf_create($db, $comid, $modele,$outputlangs)
|
|||||||
$dir = DOL_DOCUMENT_ROOT."/includes/modules/project/pdf/";
|
$dir = DOL_DOCUMENT_ROOT."/includes/modules/project/pdf/";
|
||||||
|
|
||||||
// Positionne modele sur le nom du modele de projet a utiliser
|
// Positionne modele sur le nom du modele de projet a utiliser
|
||||||
if (! dol_strlen($modele))
|
if (! dol_strlen($model))
|
||||||
{
|
{
|
||||||
if (! empty($conf->global->PROJECT_ADDON_PDF))
|
if (! empty($conf->global->PROJECT_ADDON_PDF))
|
||||||
{
|
{
|
||||||
$modele = $conf->global->PROJECT_ADDON_PDF;
|
$model = $conf->global->PROJECT_ADDON_PDF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$modele='baleine';
|
$model='baleine';
|
||||||
//print $langs->trans("Error")." ".$langs->trans("Error_PROJECT_ADDON_PDF_NotDefined");
|
//print $langs->trans("Error")." ".$langs->trans("Error_PROJECT_ADDON_PDF_NotDefined");
|
||||||
//return 0;
|
//return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Charge le modele
|
// Charge le modele
|
||||||
$file = "pdf_".$modele.".modules.php";
|
$file = "pdf_".$model.".modules.php";
|
||||||
if (file_exists($dir.$file))
|
if (file_exists($dir.$file))
|
||||||
{
|
{
|
||||||
$classname = "pdf_".$modele;
|
$classname = "pdf_".$model;
|
||||||
require_once($dir.$file);
|
require_once($dir.$file);
|
||||||
|
|
||||||
$obj = new $classname($db);
|
$obj = new $classname($db);
|
||||||
@ -175,10 +175,10 @@ function project_pdf_create($db, $comid, $modele,$outputlangs)
|
|||||||
// We save charset_output to restore it because write_file can change it if needed for
|
// We save charset_output to restore it because write_file can change it if needed for
|
||||||
// output format that does not support UTF8.
|
// output format that does not support UTF8.
|
||||||
$sav_charset_output=$outputlangs->charset_output;
|
$sav_charset_output=$outputlangs->charset_output;
|
||||||
if ($obj->write_file($comid,$outputlangs) > 0)
|
if ($obj->write_file($object,$outputlangs) > 0)
|
||||||
{
|
{
|
||||||
// on supprime l'image correspondant au preview
|
// on supprime l'image correspondant au preview
|
||||||
project_delete_preview($db, $comid);
|
project_delete_preview($db, $object->id);
|
||||||
|
|
||||||
$outputlangs->charset_output=$sav_charset_output;
|
$outputlangs->charset_output=$sav_charset_output;
|
||||||
return 1;
|
return 1;
|
||||||
@ -202,15 +202,15 @@ function project_pdf_create($db, $comid, $modele,$outputlangs)
|
|||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @param $db
|
* @param $db
|
||||||
* @param $projectid
|
* @param $objectid
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function project_delete_preview($db, $projectid)
|
function project_delete_preview($db, $objectid)
|
||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf;
|
||||||
|
|
||||||
$project = new Project($db,"",$projectid);
|
$project = new Project($db);
|
||||||
$project->fetch($projectid);
|
$project->fetch($objectid);
|
||||||
$client = new Societe($db);
|
$client = new Societe($db);
|
||||||
$client->fetch($project->socid);
|
$client->fetch($project->socid);
|
||||||
|
|
||||||
|
|||||||
@ -105,19 +105,6 @@ class pdf_baleine extends ModelePDFProjects
|
|||||||
|
|
||||||
if ($conf->projet->dir_output)
|
if ($conf->projet->dir_output)
|
||||||
{
|
{
|
||||||
// If $object is id instead of object
|
|
||||||
if (! is_object($object))
|
|
||||||
{
|
|
||||||
$id = $object;
|
|
||||||
$object = new Project($this->db);
|
|
||||||
$object->fetch($id);
|
|
||||||
|
|
||||||
if ($result < 0)
|
|
||||||
{
|
|
||||||
dol_print_error($db,$object->error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$nblignes = sizeof($object->lines);
|
$nblignes = sizeof($object->lines);
|
||||||
|
|
||||||
$objectref = dol_sanitizeFileName($object->ref);
|
$objectref = dol_sanitizeFileName($object->ref);
|
||||||
|
|||||||
@ -167,7 +167,7 @@ if ($_REQUEST['action'] == 'builddoc' && $user->rights->projet->creer)
|
|||||||
$outputlangs = new Translate("",$conf);
|
$outputlangs = new Translate("",$conf);
|
||||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||||
}
|
}
|
||||||
$result=project_pdf_create($db, $project->id, $project->modelpdf, $outputlangs);
|
$result=project_pdf_create($db, $project, $project->modelpdf, $outputlangs);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$result);
|
dol_print_error($db,$result);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user