Rename class file for pdf generation to match Dolibarr standard
This commit is contained in:
parent
0ea29a9252
commit
b5cdfd5190
4 changed files with 13 additions and 103 deletions
|
|
@ -30,7 +30,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/action/rapport.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("agenda", "commercial"));
|
||||
|
|
@ -68,8 +67,10 @@ if (!$user->hasRight("agenda", "allactions", "read")) {
|
|||
*/
|
||||
|
||||
if ($action == 'builddoc') {
|
||||
$cat = new CommActionRapport($db, $month, $year);
|
||||
$result = $cat->write_file(GETPOST('id', 'int'));
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/action/doc/pdf_standard_actions.class.php';
|
||||
|
||||
$cat = new pdf_standard_actions($db, $month, $year);
|
||||
$result = $cat->write_file(0, $langs);
|
||||
if ($result < 0) {
|
||||
setEventMessages($cat->error, $cat->errors, 'errors');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -509,7 +509,7 @@ abstract class CommonDocGenerator
|
|||
public function get_substitutionarray_object($object, $outputlangs, $array_key = 'object')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $extrafields;
|
||||
global $extrafields;
|
||||
|
||||
$sumpayed = $sumdeposit = $sumcreditnote = '';
|
||||
$already_payed_all = 0;
|
||||
|
|
@ -831,8 +831,10 @@ abstract class CommonDocGenerator
|
|||
public function get_substitutionarray_shipment($object, $outputlangs, $array_key = 'object')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $extrafields;
|
||||
dol_include_once('/core/lib/product.lib.php');
|
||||
global $extrafields;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||
|
||||
$object->list_delivery_methods($object->shipping_method_id);
|
||||
$calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/action/rapport.class.php
|
||||
* \file htdocs/core/modules/action/doc/pdf_standard_actions.class.php
|
||||
* \ingroup commercial
|
||||
* \brief File to build PDF with events
|
||||
*/
|
||||
|
|
@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
|||
/**
|
||||
* Class to generate event report
|
||||
*/
|
||||
class CommActionRapport
|
||||
class pdf_standard_actions
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
|
|
@ -89,7 +89,7 @@ class CommActionRapport
|
|||
*/
|
||||
public function __construct($db, $month, $year)
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $langs;
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("commercial", "projects"));
|
||||
|
|
@ -120,11 +120,10 @@ class CommActionRapport
|
|||
* Write the object to document file to disk
|
||||
*
|
||||
* @param int $socid Thirdparty id
|
||||
* @param int $catid Cat id
|
||||
* @param Translate $outputlangs Lang object for output language
|
||||
* @return int 1=OK, 0=KO
|
||||
*/
|
||||
public function write_file($socid = 0, $catid = 0, $outputlangs = '')
|
||||
public function write_file($socid, $outputlangs)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $user, $conf, $langs, $hookmanager;
|
||||
|
|
@ -53,95 +53,3 @@ abstract class ModeleAction extends CommonDocGenerator
|
|||
return $list;
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
|
||||
/**
|
||||
* Create a product document on disk using template defined into PRODUCT_ADDON_PDF
|
||||
*
|
||||
* @param DoliDB $db data base object
|
||||
* @param Object $object Object fichinter
|
||||
* @param string $modele forces the model to use ('' by default)
|
||||
* @param Translate $outputlangs lang object to use for translation
|
||||
* @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
|
||||
*/
|
||||
function action_create($db, $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs, $user;
|
||||
$langs->load("action");
|
||||
|
||||
$error = 0;
|
||||
|
||||
$srctemplatepath = '';
|
||||
|
||||
// Position modele on the name of fichinter model to use
|
||||
if (!dol_strlen($modele)) {
|
||||
if (getDolGlobalString('ACTION_EVENT_ADDON_PDF')) {
|
||||
$modele = $conf->global->ACTION_EVENT_ADDON_PDF;
|
||||
} else {
|
||||
$modele = 'soleil';
|
||||
}
|
||||
}
|
||||
|
||||
// If selected modele is a filename template (then $modele="modelname:filename")
|
||||
$tmp = explode(':', $modele, 2);
|
||||
if (!empty($tmp[1])) {
|
||||
$modele = $tmp[0];
|
||||
$srctemplatepath = $tmp[1];
|
||||
}
|
||||
|
||||
// Search template files
|
||||
$file = '';
|
||||
$classname = '';
|
||||
$filefound = 0;
|
||||
$dirmodels = array('/');
|
||||
if (is_array($conf->modules_parts['models'])) {
|
||||
$dirmodels = array_merge($dirmodels, $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/action/doc/".$file, 0);
|
||||
if (file_exists($file)) {
|
||||
$filefound = 1;
|
||||
$classname = $prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($filefound) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Charge le modele
|
||||
if ($filefound) {
|
||||
require_once $file;
|
||||
|
||||
$obj = new $classname($db);
|
||||
|
||||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
$sav_charset_output = $outputlangs->charset_output;
|
||||
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) {
|
||||
$outputlangs->charset_output = $sav_charset_output;
|
||||
|
||||
// We delete old preview
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
dol_delete_preview($object);
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
$outputlangs->charset_output = $sav_charset_output;
|
||||
dol_print_error($db, "action_pdf_create Error: ".$obj->error);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue