Skip to content

Commit

Permalink
Merge branch 'marcosgdf-oop-pdf' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Sep 22, 2014
2 parents bd6afa1 + dc96e10 commit 7bf922c
Show file tree
Hide file tree
Showing 38 changed files with 586 additions and 993 deletions.
3 changes: 2 additions & 1 deletion htdocs/adherents/card_subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@
}
// Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email
//if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
facture_pdf_create($db, $invoice, $invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);

$invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);


}
Expand Down
20 changes: 10 additions & 10 deletions htdocs/comm/propal.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
Expand All @@ -176,7 +176,7 @@
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
} else {
$langs->load("errors");
Expand Down Expand Up @@ -475,7 +475,7 @@
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
Expand Down Expand Up @@ -676,7 +676,7 @@
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}

Expand Down Expand Up @@ -890,7 +890,7 @@
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

unset($_POST ['prod_entry_mode']);
Expand Down Expand Up @@ -1018,7 +1018,7 @@
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

unset($_POST ['qty']);
Expand Down Expand Up @@ -1060,7 +1060,7 @@
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
$result = propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);

if ($result <= 0) {
dol_print_error($db, $result);
Expand Down Expand Up @@ -1146,7 +1146,7 @@
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid'));
Expand All @@ -1165,7 +1165,7 @@
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid'));
Expand Down Expand Up @@ -2338,7 +2338,7 @@

// Build document if it not exists
if (! $file || ! is_readable($file)) {
$result = propale_pdf_create($db, $object, GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0) {
dol_print_error($db, $result);
exit();
Expand Down
40 changes: 38 additions & 2 deletions htdocs/comm/propal/class/propal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012-214 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.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 @@ -1746,7 +1747,7 @@ function cloture($user, $statut, $note)
$outputlangs->setDefaultLang($newlang);
}
//$ret=$object->fetch($id); // Reload to get new records
propale_pdf_create($this->db, $this, $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL?$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$this->generateDocument($conf->global->PROPALE_ADDON_PDF_ODT_TOBILL?$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

// Call trigger
Expand All @@ -1768,7 +1769,7 @@ function cloture($user, $statut, $note)
$outputlangs->setDefaultLang($newlang);
}
//$ret=$object->fetch($id); // Reload to get new records
propale_pdf_create($this->db, $this, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED?$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED:$this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$this->generateDocument($conf->global->PROPALE_ADDON_PDF_ODT_CLOSED?$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED:$this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

// Call trigger
Expand Down Expand Up @@ -2673,6 +2674,41 @@ function getLinesArray()
}
}

/**
* Create a document onto disk according to template module.
*
* @param string $modele Force model to use ('' to not force)
* @param Translate $outputlangs Object langs to use for output
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
* @return int 0 if KO, 1 if OK
*/
public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
{
global $conf,$user,$langs;

$langs->load("propale");

// Positionne le modele sur le nom du modele a utiliser
if (! dol_strlen($modele))
{
if (! empty($conf->global->PROPALE_ADDON_PDF))
{
$modele = $conf->global->PROPALE_ADDON_PDF;
}
else
{
$modele = 'azur';
}
}

$modelpath = "core/modules/propale/doc/";

return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}


}


Expand Down
29 changes: 16 additions & 13 deletions htdocs/commande/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$ret = $object->fetch($object->id); // Reload to get new records
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
Expand Down Expand Up @@ -491,7 +491,7 @@
}

$ret = $object->fetch($object->id); // Reload to get new records
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
}
Expand Down Expand Up @@ -722,7 +722,7 @@
$outputlangs->setDefaultLang($newlang);
}

commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

unset($_POST ['prod_entry_mode']);
Expand Down Expand Up @@ -847,7 +847,7 @@
}

$ret = $object->fetch($object->id); // Reload to get new records
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

unset($_POST ['qty']);
Expand Down Expand Up @@ -911,8 +911,9 @@
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
}
}
Expand Down Expand Up @@ -958,7 +959,7 @@
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$ret = $object->fetch($object->id); // Reload to get new records
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
}
Expand Down Expand Up @@ -1023,8 +1024,9 @@
$outputlangs->setDefaultLang($newlang);
}

if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid'));
exit();
Expand All @@ -1044,8 +1046,9 @@
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid'));
exit();
Expand Down Expand Up @@ -1073,7 +1076,7 @@
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$result = commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);

if ($result <= 0) {
dol_print_error($db, $result);
Expand Down Expand Up @@ -2462,7 +2465,7 @@

// Build document if it not exists
if (! $file || ! is_readable($file)) {
$result = commande_pdf_create($db, $object, GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0) {
dol_print_error($db, $result);
exit();
Expand Down
35 changes: 35 additions & 0 deletions htdocs/commande/class/commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Copyright (C) 2011 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.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 @@ -3011,6 +3012,40 @@ function getLinesArray()
}
}

/**
* Create a document onto disk accordign to template module.
*
* @param string $modele Force le mnodele a utiliser ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
* @return int 0 if KO, 1 if OK
*/
public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
{
global $conf,$user,$langs,$hookmanager;

$langs->load("orders");

// Positionne le modele sur le nom du modele a utiliser
if (! dol_strlen($modele))
{
if (! empty($conf->global->COMMANDE_ADDON_PDF))
{
$modele = $conf->global->COMMANDE_ADDON_PDF;
}
else
{
$modele = 'einstein';
}
}

$modelpath = "core/modules/commande/doc/";

return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

}


Expand Down

0 comments on commit 7bf922c

Please sign in to comment.