Debug modulebuilder for doc generation
Conflicts: htdocs/core/class/html.formfile.class.php htdocs/modulebuilder/template/admin/setup.php
This commit is contained in:
parent
38001a4e89
commit
2324834b73
@ -672,7 +672,7 @@ class FormFile
|
|||||||
{
|
{
|
||||||
$submodulepart = $modulepart;
|
$submodulepart = $modulepart;
|
||||||
|
|
||||||
// modulepart = 'nameofmodule' or 'nameofmodule:nameofsubmodule'
|
// modulepart = 'nameofmodule' or 'nameofmodule:NameOfObject'
|
||||||
$tmp = explode(':', $modulepart);
|
$tmp = explode(':', $modulepart);
|
||||||
if (!empty($tmp[1])) {
|
if (!empty($tmp[1])) {
|
||||||
$modulepart = $tmp[0];
|
$modulepart = $tmp[0];
|
||||||
@ -680,18 +680,18 @@ class FormFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For normalized standard modules
|
// For normalized standard modules
|
||||||
$file = dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$submodulepart.'.php', 0);
|
$file = dol_buildpath('/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0);
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
$res = include_once $file;
|
$res = include_once $file;
|
||||||
}
|
}
|
||||||
// For normalized external modules.
|
// For normalized external modules.
|
||||||
else
|
else {
|
||||||
{
|
$file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0);
|
||||||
$file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.$submodulepart.'.php', 0);
|
|
||||||
$res = include_once $file;
|
$res = include_once $file;
|
||||||
}
|
}
|
||||||
$class = 'ModelePDF'.ucfirst($submodulepart);
|
|
||||||
|
$class = 'ModelePDF'.$submodulepart;
|
||||||
|
|
||||||
if (class_exists($class))
|
if (class_exists($class))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -75,6 +75,8 @@ ALTER TABLE llx_prelevement_bons ADD COLUMN type varchar(16) DEFAULT 'debit-orde
|
|||||||
|
|
||||||
ALTER TABLE llx_ecm_files MODIFY COLUMN src_object_type varchar(64);
|
ALTER TABLE llx_ecm_files MODIFY COLUMN src_object_type varchar(64);
|
||||||
|
|
||||||
|
ALTER TABLE llx_document_model MODIFY COLUMN type varchar(64);
|
||||||
|
|
||||||
|
|
||||||
-- Delete an old index that is duplicated
|
-- Delete an old index that is duplicated
|
||||||
-- VMYSQL4.1 DROP INDEX ix_fk_product_stock on llx_product_batch;
|
-- VMYSQL4.1 DROP INDEX ix_fk_product_stock on llx_product_batch;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ create table llx_document_model
|
|||||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
nom varchar(50),
|
nom varchar(50),
|
||||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||||
type varchar(20) NOT NULL,
|
type varchar(64) NOT NULL,
|
||||||
libelle varchar(255),
|
libelle varchar(255),
|
||||||
description text
|
description text
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|||||||
@ -926,6 +926,9 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
|
|||||||
dolReplaceInFile($destdir.'/core/modules/mod'.$module.'.class.php', $arrayreplacement, '', 0, 0, 1);
|
dolReplaceInFile($destdir.'/core/modules/mod'.$module.'.class.php', $arrayreplacement, '', 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Update entries '$myTmpObjects['MyObject']=array('includerefgeneration'=>0, 'includedocgeneration'=>0);'
|
||||||
|
|
||||||
|
|
||||||
// Scan for object class files
|
// Scan for object class files
|
||||||
$listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$');
|
$listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$');
|
||||||
|
|
||||||
@ -1057,7 +1060,7 @@ if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') &&
|
|||||||
$objectname = $tabobj;
|
$objectname = $tabobj;
|
||||||
|
|
||||||
$arrayoftables = array();
|
$arrayoftables = array();
|
||||||
if ($action == 'droptable') $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj);
|
if ($action == 'droptable') $arrayoftables[] = MAIN_DB_PREFIX.strtoslower($module).'_'.strtolower($tabobj);
|
||||||
if ($action == 'droptableextrafields') $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj).'_extrafields';
|
if ($action == 'droptableextrafields') $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj).'_extrafields';
|
||||||
|
|
||||||
foreach ($arrayoftables as $tabletodrop)
|
foreach ($arrayoftables as $tabletodrop)
|
||||||
|
|||||||
@ -257,7 +257,8 @@ $myTmpObjects = array();
|
|||||||
$myTmpObjects['MyObject']=array('includerefgeneration'=>0, 'includedocgeneration'=>0);
|
$myTmpObjects['MyObject']=array('includerefgeneration'=>0, 'includedocgeneration'=>0);
|
||||||
|
|
||||||
|
|
||||||
foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||||
|
if ($myTmpObjectKey == 'MyObject') continue;
|
||||||
if ($myTmpObjectArray['includerefgeneration']) {
|
if ($myTmpObjectArray['includerefgeneration']) {
|
||||||
/*
|
/*
|
||||||
* Orders Numbering model
|
* Orders Numbering model
|
||||||
|
|||||||
@ -407,31 +407,40 @@ class modMyModule extends DolibarrModules
|
|||||||
|
|
||||||
$sql = array();
|
$sql = array();
|
||||||
|
|
||||||
// ODT template
|
// Document templates
|
||||||
/*
|
$moduledir = 'mymodule';
|
||||||
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt';
|
$myTmpObjects = array();
|
||||||
$dirodt=DOL_DATA_ROOT.'/doctemplates/mymodule';
|
$myTmpObjects['MyObject']=array('includerefgeneration'=>0, 'includedocgeneration'=>0);
|
||||||
$dest=$dirodt.'/template_myobjects.odt';
|
|
||||||
|
|
||||||
if (file_exists($src) && ! file_exists($dest))
|
foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
|
||||||
{
|
if ($myTmpObjectKey == 'MyObject') continue;
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
if ($myTmpObjectArray['includerefgeneration']) {
|
||||||
dol_mkdir($dirodt);
|
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt';
|
||||||
$result=dol_copy($src, $dest, 0, 0);
|
$dirodt=DOL_DATA_ROOT.'/doctemplates/mymodule';
|
||||||
if ($result < 0)
|
$dest=$dirodt.'/template_myobjects.odt';
|
||||||
{
|
|
||||||
$langs->load("errors");
|
if (file_exists($src) && ! file_exists($dest))
|
||||||
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
|
{
|
||||||
return 0;
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
dol_mkdir($dirodt);
|
||||||
|
$result=dol_copy($src, $dest, 0, 0);
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$langs->load("errors");
|
||||||
|
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = array_merge($sql, array(
|
||||||
|
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity,
|
||||||
|
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."','".strtolower($myTmpObjectKey)."',".$conf->entity.")",
|
||||||
|
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity,
|
||||||
|
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".strtolower($myTmpObjectKey)."', ".$conf->entity.")"
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = array(
|
|
||||||
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'mymodule' AND entity = ".$conf->entity,
|
|
||||||
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','mymodule',".$conf->entity.")"
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
return $this->_init($sql, $options);
|
return $this->_init($sql, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -358,10 +358,10 @@ class pdf_standard_myobject extends ModelePDFMyObject
|
|||||||
$pdf->SetDrawColor(128, 128, 128);
|
$pdf->SetDrawColor(128, 128, 128);
|
||||||
|
|
||||||
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
|
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
|
||||||
$pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle"));
|
$pdf->SetSubject($outputlangs->transnoentities("PdfTitle"));
|
||||||
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
|
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
|
||||||
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
|
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
|
||||||
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
|
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
|
||||||
if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
|
if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
|
||||||
|
|
||||||
// Set certificate
|
// Set certificate
|
||||||
@ -633,22 +633,6 @@ class pdf_standard_myobject extends ModelePDFMyObject
|
|||||||
|
|
||||||
$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
|
$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
|
||||||
|
|
||||||
// VAT Rate
|
|
||||||
if ($this->getColumnStatus('vat'))
|
|
||||||
{
|
|
||||||
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
|
|
||||||
$this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
|
|
||||||
$nexY = max($pdf->GetY(), $nexY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unit price before discount
|
|
||||||
if ($this->getColumnStatus('subprice'))
|
|
||||||
{
|
|
||||||
$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
|
|
||||||
$this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
|
|
||||||
$nexY = max($pdf->GetY(), $nexY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Quantity
|
// Quantity
|
||||||
// Enough for 6 chars
|
// Enough for 6 chars
|
||||||
if ($this->getColumnStatus('qty'))
|
if ($this->getColumnStatus('qty'))
|
||||||
@ -658,38 +642,6 @@ class pdf_standard_myobject extends ModelePDFMyObject
|
|||||||
$nexY = max($pdf->GetY(), $nexY);
|
$nexY = max($pdf->GetY(), $nexY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Situation progress
|
|
||||||
if ($this->getColumnStatus('progress'))
|
|
||||||
{
|
|
||||||
$progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
|
|
||||||
$this->printStdColumnContent($pdf, $curY, 'progress', $progress);
|
|
||||||
$nexY = max($pdf->GetY(), $nexY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unit
|
|
||||||
if ($this->getColumnStatus('unit'))
|
|
||||||
{
|
|
||||||
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
|
|
||||||
$this->printStdColumnContent($pdf, $curY, 'unit', $unit);
|
|
||||||
$nexY = max($pdf->GetY(), $nexY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Discount on line
|
|
||||||
if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
|
|
||||||
{
|
|
||||||
$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
|
|
||||||
$this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
|
|
||||||
$nexY = max($pdf->GetY(), $nexY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Total HT line
|
|
||||||
if ($this->getColumnStatus('totalexcltax'))
|
|
||||||
{
|
|
||||||
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
|
|
||||||
$this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
|
|
||||||
$nexY = max($pdf->GetY(), $nexY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extrafields
|
// Extrafields
|
||||||
if (!empty($object->lines[$i]->array_options)) {
|
if (!empty($object->lines[$i]->array_options)) {
|
||||||
foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
|
foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
|
||||||
@ -716,7 +668,6 @@ class pdf_standard_myobject extends ModelePDFMyObject
|
|||||||
|
|
||||||
|
|
||||||
$sign = 1;
|
$sign = 1;
|
||||||
if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
|
|
||||||
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
|
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
|
||||||
$prev_progress = $object->lines[$i]->get_prev_progress($object->id);
|
$prev_progress = $object->lines[$i]->get_prev_progress($object->id);
|
||||||
if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation
|
if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation
|
||||||
@ -1006,21 +957,10 @@ class pdf_standard_myobject extends ModelePDFMyObject
|
|||||||
$pdf->SetFont('', 'B', $default_font_size + 3);
|
$pdf->SetFont('', 'B', $default_font_size + 3);
|
||||||
$pdf->SetXY($posx, $posy);
|
$pdf->SetXY($posx, $posy);
|
||||||
$pdf->SetTextColor(0, 0, 60);
|
$pdf->SetTextColor(0, 0, 60);
|
||||||
$title = $outputlangs->transnoentities("PdfInvoiceTitle");
|
$title = $outputlangs->transnoentities("PdfTitle");
|
||||||
if ($object->type == 1) $title = $outputlangs->transnoentities("InvoiceReplacement");
|
|
||||||
if ($object->type == 2) $title = $outputlangs->transnoentities("InvoiceAvoir");
|
|
||||||
if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit");
|
|
||||||
if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProForma");
|
|
||||||
if ($this->situationinvoice) $title = $outputlangs->transnoentities("InvoiceSituation");
|
|
||||||
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
|
if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
|
||||||
$title .= ' - ';
|
$title .= ' - ';
|
||||||
if ($object->type == 0) {
|
$title .= $outputlangsbis->transnoentities("PdfTitle");
|
||||||
if ($this->situationinvoice) $title .= $outputlangsbis->transnoentities("InvoiceSituation");
|
|
||||||
$title .= $outputlangsbis->transnoentities("PdfInvoiceTitle");
|
|
||||||
} elseif ($object->type == 1) $title .= $outputlangsbis->transnoentities("InvoiceReplacement");
|
|
||||||
elseif ($object->type == 2) $title .= $outputlangsbis->transnoentities("InvoiceAvoir");
|
|
||||||
elseif ($object->type == 3) $title .= $outputlangsbis->transnoentities("InvoiceDeposit");
|
|
||||||
elseif ($object->type == 4) $title .= $outputlangsbis->transnoentities("InvoiceProForma");
|
|
||||||
}
|
}
|
||||||
$pdf->MultiCell($w, 3, $title, '', 'R');
|
$pdf->MultiCell($w, 3, $title, '', 'R');
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ abstract class ModelePDFMyObject extends CommonDocGenerator
|
|||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$type = 'mymodule_myobject';
|
$type = 'myobject';
|
||||||
$list = array();
|
$list = array();
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
|
|||||||
@ -570,7 +570,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
|
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
|
||||||
$genallowed = $user->rights->mymodule->myobject->read; // If you can read, you can build the PDF to read content
|
$genallowed = $user->rights->mymodule->myobject->read; // If you can read, you can build the PDF to read content
|
||||||
$delallowed = $user->rights->mymodule->myobject->write; // If you can create/edit, you can remove a file on card
|
$delallowed = $user->rights->mymodule->myobject->write; // If you can create/edit, you can remove a file on card
|
||||||
print $formfile->showdocuments('mymodule:myobject', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
|
print $formfile->showdocuments('mymodule:MyObject', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show links to link elements
|
// Show links to link elements
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user