From 28df07225d78f8b0d3d1cea610eff08f195528de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 May 2020 23:11:49 +0200 Subject: [PATCH 1/3] Debug modulebuilder --- htdocs/modulebuilder/index.php | 2 +- .../template/class/myobject.class.php | 2 +- .../doc/pdf_standard_myobject.modules.php | 60 +------------------ 3 files changed, 4 insertions(+), 60 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 1bb1c934aa4..1c7cd3a375d 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2311,7 +2311,7 @@ elseif (!empty($module)) print ''.$langs->trans("EnterNameOfObjectDesc").'

'; - print '
'; + print '
'; print ' '.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).'
'; print ' '.$form->textwithpicto($langs->trans("IncludeDocGeneration"), $langs->trans("IncludeDocGenerationHelp")).'
'; print ''; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 12400ecb087..7dc98dbf1e7 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -1027,7 +1027,7 @@ class MyObject extends CommonObject $langs->load("mymodule@mymodule"); if (!dol_strlen($modele)) { - $modele = 'standard'; + $modele = 'standard_myobject'; if ($this->modelpdf) { $modele = $this->modelpdf; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 1d08e857e96..e7bd7540835 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -295,10 +295,6 @@ class pdf_standard_myobject extends ModelePDFMyObject { $object->fetch_thirdparty(); - $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); - $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); - $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); - // Definition of $dir and $file if ($object->specimen) { @@ -1076,68 +1072,16 @@ class pdf_standard_myobject extends ModelePDFMyObject } } - $objectidnext = $object->getIdReplacingInvoice('validated'); - if ($object->type == 0 && $objectidnext) - { - $objectreplacing = new Facture($this->db); - $objectreplacing->fetch($objectidnext); - - $posy += 3; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R'); - } - if ($object->type == 1) - { - $objectreplaced = new Facture($this->db); - $objectreplaced->fetch($object->fk_facture_source); - - $posy += 4; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); - } - if ($object->type == 2 && !empty($object->fk_facture_source)) - { - $objectreplaced = new Facture($this->db); - $objectreplaced->fetch($object->fk_facture_source); - - $posy += 3; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); - } - $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title = $outputlangs->transnoentities("DateInvoice"); + $title = $outputlangs->transnoentities("Date"); if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { - $title .= ' - '.$outputlangsbis->transnoentities("DateInvoice"); + $title .= ' - '.$outputlangsbis->transnoentities("Date"); } $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R'); - if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) - { - $posy += 4; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : ".dol_print_date($object->date_pointoftax, "day", false, $outputlangs), '', 'R'); - } - - if ($object->type != 2) - { - $posy += 3; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $title = $outputlangs->transnoentities("DateDue"); - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { - $title .= ' - '.$outputlangsbis->transnoentities("DateDue"); - } - $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R'); - } - if ($object->thirdparty->code_client) { $posy += 3; From e83b754e6fe650cfc375ed8423399fef1930dd91 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 May 2020 23:32:36 +0200 Subject: [PATCH 2/3] Debug modulebuilder --- htdocs/core/lib/modulebuilder.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 6bfe70bc5f2..384fd608597 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -141,6 +141,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = if ($val['help']) $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\","; if ($val['showoncombobox']) $texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',"; if ($val['disabled']) $texttoinsert .= " 'disabled'=>'".$val['disabled']."',"; + if ($val['autofocusoncreate']) $texttoinsert .= " 'autofocusoncreate'=>'".$val['autofocusoncreate']."',"; if ($val['arrayofkeyval']) { $texttoinsert .= " 'arrayofkeyval'=>array("; From 5a8c4ad3f51ef651ead619a10742254b272b0e32 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Jun 2020 00:01:23 +0200 Subject: [PATCH 3/3] Debug modulebuilder --- htdocs/modulebuilder/index.php | 2 ++ .../doc/pdf_standard_myobject.modules.php | 11 ++++++----- .../modulebuilder/template/myobject_card.php | 19 +++++++++++-------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 1c7cd3a375d..2a01a282a90 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -917,10 +917,12 @@ if ($dirins && $action == 'initobject' && $module && $objectname) '/\$includedocgeneration = 0;/' => '$includedocgeneration = 1;' ); dolReplaceInFile($destdir.'/class/'.strtolower($objectname).'.class.php', $arrayreplacement, '', 0, 0, 1); + dolReplaceInFile($destdir.'/'.strtolower($objectname).'_card.php', $arrayreplacement, '', 0, 0, 1); $arrayreplacement = array( '/\'models\' => 0,/' => '\'models\' => 1,' ); + dolReplaceInFile($destdir.'/core/modules/mod'.$module.'.class.php', $arrayreplacement, '', 0, 0, 1); } diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index e7bd7540835..4c0ff154a04 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -226,7 +226,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies")); } - $nblines = count($object->lines); + $nblines = (is_array($object->lines) ? count($object->lines) : 0); $hidetop = 0; if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { @@ -328,7 +328,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Set nblines with the new facture lines content after hook - $nblines = count($object->lines); + $nblines = (is_array($object->lines) ? count($object->lines) : 0); // Create pdf instance $pdf = pdf_getInstance($this->format); @@ -1161,15 +1161,16 @@ class pdf_standard_myobject extends ModelePDFMyObject $result = $object->fetch_contact($arrayidcontact[0]); } - //Recipient name - // On peut utiliser le nom de la societe du contact + // Recipient name if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; } - $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); + if (is_object($thirdparty)) { + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); + } $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index de26be0cb22..07850c17491 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -560,15 +560,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print ''; // ancre + $includedocgeneration = 0; + // Documents - /*$objref = dol_sanitizeFileName($object->ref); - $relativepath = $objref . '/' . $objref . '.pdf'; - $filedir = $conf->mymodule->dir_output . '/' . $objref; - $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 - $delallowed = $user->rights->mymodule->myobject->create; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('mymodule', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); - */ + if ($includedocgeneration) { + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref . '/' . $objref . '.pdf'; + $filedir = $conf->mymodule->dir_output.'/'.$object->element.'/'.$objref; + $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 + $delallowed = $user->rights->mymodule->myobject->create; // 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); + } // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject'));