allow in extrafield conf to choose to add extrafield in a new col or append it to description, it could be useful for html or long text extrafields
This commit is contained in:
parent
93c9f07cb9
commit
5ecef88b35
@ -184,7 +184,7 @@ if ($action == 'add')
|
|||||||
GETPOST('langfile', 'alpha'),
|
GETPOST('langfile', 'alpha'),
|
||||||
1,
|
1,
|
||||||
(GETPOST('totalizable', 'alpha')?1:0),
|
(GETPOST('totalizable', 'alpha')?1:0),
|
||||||
(GETPOST('documentpdf', 'alpha')?1:0)
|
GETPOST('documentpdf', 'alpha')
|
||||||
);
|
);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
@ -354,7 +354,7 @@ if ($action == 'update')
|
|||||||
GETPOST('langfile'),
|
GETPOST('langfile'),
|
||||||
1,
|
1,
|
||||||
(GETPOST('totalizable', 'alpha')?1:0),
|
(GETPOST('totalizable', 'alpha')?1:0),
|
||||||
(GETPOST('documentpdf', 'alpha')?1:0)
|
GETPOST('documentpdf', 'alpha')
|
||||||
);
|
);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1074,7 +1074,7 @@ abstract class CommonDocGenerator
|
|||||||
/**
|
/**
|
||||||
* print standard column content
|
* print standard column content
|
||||||
*
|
*
|
||||||
* @param PDF $pdf pdf object
|
* @param TCPDF $pdf pdf object
|
||||||
* @param float $curY curent Y position
|
* @param float $curY curent Y position
|
||||||
* @param string $colKey the column key
|
* @param string $colKey the column key
|
||||||
* @param string $columnText column text
|
* @param string $columnText column text
|
||||||
@ -1179,6 +1179,8 @@ abstract class CommonDocGenerator
|
|||||||
$defaultParams = array(
|
$defaultParams = array(
|
||||||
'style' => '',
|
'style' => '',
|
||||||
'display' => 'auto', // auto, table, list
|
'display' => 'auto', // auto, table, list
|
||||||
|
'documentpdfEnable' => array(1),
|
||||||
|
'documentpdfEnableNotEmpty' => array(2),
|
||||||
|
|
||||||
'table' => array(
|
'table' => array(
|
||||||
'maxItemsInRow' => 2,
|
'maxItemsInRow' => 2,
|
||||||
@ -1213,7 +1215,18 @@ abstract class CommonDocGenerator
|
|||||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label)
|
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label)
|
||||||
{
|
{
|
||||||
// Enable extrafield ?
|
// Enable extrafield ?
|
||||||
$enabled = !empty($extrafields->attributes[$object->table_element]['documentpdf'][$key]);
|
$enabled = 0;
|
||||||
|
$disableOnEmpty = 0;
|
||||||
|
if(!empty($extrafields->attributes[$object->table_element]['documentpdf'][$key])) {
|
||||||
|
$documentpdf = intval($extrafields->attributes[$object->table_element]['documentpdf'][$key]);
|
||||||
|
if(in_array($documentpdf,$params['documentpdfEnable']) || in_array($documentpdf,$params['documentpdfEnableNotEmpty']) ) {
|
||||||
|
$enabled = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($documentpdf,$params['documentpdfEnableNotEmpty'])) {
|
||||||
|
$disableOnEmpty = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(empty($enabled)){
|
if(empty($enabled)){
|
||||||
continue;
|
continue;
|
||||||
@ -1225,6 +1238,11 @@ abstract class CommonDocGenerator
|
|||||||
$field->label = $outputlangs->transnoentities($label);
|
$field->label = $outputlangs->transnoentities($label);
|
||||||
$field->type = $extrafields->attributes[$object->table_element]['type'][$key];
|
$field->type = $extrafields->attributes[$object->table_element]['type'][$key];
|
||||||
|
|
||||||
|
// dont display if empty
|
||||||
|
if($disableOnEmpty && empty($field->content)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$fields[] = $field;
|
$fields[] = $field;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1234,10 +1252,7 @@ abstract class CommonDocGenerator
|
|||||||
// Sort extrafields by rank
|
// Sort extrafields by rank
|
||||||
uasort($fields, function ($a, $b) {
|
uasort($fields, function ($a, $b) {
|
||||||
return ($a->rank > $b->rank) ? -1 : 1;
|
return ($a->rank > $b->rank) ? -1 : 1;
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// define some HTML content with style
|
// define some HTML content with style
|
||||||
$html.= '<style>'.$params['style'].'</style>';
|
$html.= '<style>'.$params['style'].'</style>';
|
||||||
@ -1425,8 +1440,16 @@ abstract class CommonDocGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enable extrafield ?
|
// Enable extrafield ?
|
||||||
$enabled = !empty($extrafields->attributes[$object->table_element]['documentpdf'][$key]);
|
$enabled = 0;
|
||||||
|
if(!empty($extrafields->attributes[$object->table_element]['documentpdf'][$key])) {
|
||||||
|
$documentpdf = intval($extrafields->attributes[$object->table_element]['documentpdf'][$key]);
|
||||||
|
if($documentpdf === 1 || $documentpdf === 2) {
|
||||||
|
$enabled = 1;
|
||||||
|
}
|
||||||
|
// Note : if $documentpdf === 3 or 4 so, it's displayed after line description not in cols
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$enabled){ continue; } // don't wast resourses if we don't need them...
|
||||||
|
|
||||||
// Load language if required
|
// Load language if required
|
||||||
if (!empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $outputlangs->load($extrafields->attributes[$object->table_element]['langfile'][$key]);
|
if (!empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $outputlangs->load($extrafields->attributes[$object->table_element]['langfile'][$key]);
|
||||||
|
|||||||
@ -638,12 +638,34 @@ class pdf_sponge extends ModelePDFFactures
|
|||||||
{
|
{
|
||||||
$pdf->startTransaction();
|
$pdf->startTransaction();
|
||||||
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
|
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
|
||||||
|
$posYAfterDescription = $pdf->GetY();
|
||||||
|
$params = array(
|
||||||
|
'display' => 'list',
|
||||||
|
'documentpdfEnable' => array(3),
|
||||||
|
'documentpdfEnableNotEmpty' => array(4)
|
||||||
|
);
|
||||||
|
$extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params);
|
||||||
|
if(!empty($extrafieldDesc)){
|
||||||
|
$this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc);
|
||||||
|
}
|
||||||
|
|
||||||
$pageposafter = $pdf->getPage();
|
$pageposafter = $pdf->getPage();
|
||||||
if ($pageposafter > $pageposbefore) // There is a pagebreak
|
if ($pageposafter > $pageposbefore) // There is a pagebreak
|
||||||
{
|
{
|
||||||
$pdf->rollbackTransaction(true);
|
$pdf->rollbackTransaction(true);
|
||||||
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
|
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
|
||||||
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
|
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
|
||||||
|
$posYAfterDescription = $pdf->GetY();
|
||||||
|
$params = array(
|
||||||
|
'display' => 'list',
|
||||||
|
'documentpdfEnable' => array(3),
|
||||||
|
'documentpdfEnableNotEmpty' => array(4)
|
||||||
|
);
|
||||||
|
$extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params);
|
||||||
|
if(!empty($extrafieldDesc)){
|
||||||
|
$this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc);
|
||||||
|
}
|
||||||
|
|
||||||
$pageposafter = $pdf->getPage();
|
$pageposafter = $pdf->getPage();
|
||||||
$posyafter = $pdf->GetY();
|
$posyafter = $pdf->GetY();
|
||||||
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
|
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
|
||||||
@ -673,7 +695,7 @@ class pdf_sponge extends ModelePDFFactures
|
|||||||
$posYAfterDescription = $pdf->GetY();
|
$posYAfterDescription = $pdf->GetY();
|
||||||
}
|
}
|
||||||
|
|
||||||
$nexY = $pdf->GetY();
|
$nexY = $pdf->GetY();
|
||||||
$pageposafter = $pdf->getPage();
|
$pageposafter = $pdf->getPage();
|
||||||
$pdf->setPage($pageposbefore);
|
$pdf->setPage($pageposbefore);
|
||||||
$pdf->setTopMargin($this->marge_haute);
|
$pdf->setTopMargin($this->marge_haute);
|
||||||
|
|||||||
@ -198,7 +198,7 @@ $langs->load("modulebuilder");
|
|||||||
</td><td class="valeur"><input id="list" class="minwidth100" type="text" name="list" value="<?php echo GETPOST('list', 'int')!='' ? GETPOST('list', 'int') : '1'; ?>"></td></tr>
|
</td><td class="valeur"><input id="list" class="minwidth100" type="text" name="list" value="<?php echo GETPOST('list', 'int')!='' ? GETPOST('list', 'int') : '1'; ?>"></td></tr>
|
||||||
<!-- Visibility for PDF-->
|
<!-- Visibility for PDF-->
|
||||||
<tr><td class="extra_pdf"><?php echo $form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")); ?>
|
<tr><td class="extra_pdf"><?php echo $form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")); ?>
|
||||||
</td><td class="valeur"><input id="documentpdf" type="checkbox" name="documentpdf"<?php echo GETPOST('documentpdf', 'alpha')?' checked':''; ?>></td></tr>
|
</td><td class="valeur"><input id="documentpdf" class="minwidth100" type="text" name="documentpdf" value="<?php echo dol_escape_htmltag(GETPOST('documentpdf', 'int')); ?>"></td></tr>
|
||||||
<!-- Totalizable -->
|
<!-- Totalizable -->
|
||||||
<tr class="extra_totalizable"><td><?php echo $langs->trans("Totalizable"); ?></td><td class="valeur"><input id="totalizable" type="checkbox" name="totalizable"<?php echo ((GETPOST('totalizable', 'alpha') || GETPOST('button', 'alpha'))?' checked':''); ?>></td></tr>
|
<tr class="extra_totalizable"><td><?php echo $langs->trans("Totalizable"); ?></td><td class="valeur"><input id="totalizable" type="checkbox" name="totalizable"<?php echo ((GETPOST('totalizable', 'alpha') || GETPOST('button', 'alpha'))?' checked':''); ?>></td></tr>
|
||||||
<!-- Help tooltip -->
|
<!-- Help tooltip -->
|
||||||
|
|||||||
@ -267,7 +267,7 @@ else
|
|||||||
</td><td class="valeur"><input id="list" class="minwidth100" type="text" name="list" value="<?php echo ($list!=''?$list:'1'); ?>"></td></tr>
|
</td><td class="valeur"><input id="list" class="minwidth100" type="text" name="list" value="<?php echo ($list!=''?$list:'1'); ?>"></td></tr>
|
||||||
<!-- Visibility for PDF-->
|
<!-- Visibility for PDF-->
|
||||||
<tr><td class="extra_pdf"><?php echo $form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")); ?>
|
<tr><td class="extra_pdf"><?php echo $form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")); ?>
|
||||||
</td><td class="valeur"><input id="documentpdf" type="checkbox" name="documentpdf"<?php echo !empty($documentpdf)?' checked':''; ?>></td></tr>
|
</td><td class="valeur"><input id="documentpdf" class="minwidth100" type="text" name="documentpdf" value="<?php echo dol_escape_htmltag($documentpdf); ?>"></td></tr>
|
||||||
<tr class="extra_totalizable"><td><?php echo $form->textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")); ?></td><td class="valeur"><input id="totalizable" type="checkbox" name="totalizable"<?php echo ($totalizable?' checked':''); ?>></td></tr>
|
<tr class="extra_totalizable"><td><?php echo $form->textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")); ?></td><td class="valeur"><input id="totalizable" type="checkbox" name="totalizable"<?php echo ($totalizable?' checked':''); ?>></td></tr>
|
||||||
<!-- Help tooltip -->
|
<!-- Help tooltip -->
|
||||||
<tr class="help"><td><?php echo $form->textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?></td><td class="valeur"><input id="help" class="quatrevingtpercent" type="text" name="help" value="<?php echo dol_escape_htmltag($help); ?>"></td></tr>
|
<tr class="help"><td><?php echo $form->textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?></td><td class="valeur"><input id="help" class="quatrevingtpercent" type="text" name="help" value="<?php echo dol_escape_htmltag($help); ?>"></td></tr>
|
||||||
|
|||||||
@ -93,7 +93,7 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel
|
|||||||
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['required'][$key])."</td>\n";
|
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['required'][$key])."</td>\n";
|
||||||
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."</td>\n";
|
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."</td>\n";
|
||||||
print '<td class="center">'.$extrafields->attributes[$elementtype]['list'][$key]."</td>\n";
|
print '<td class="center">'.$extrafields->attributes[$elementtype]['list'][$key]."</td>\n";
|
||||||
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['documentpdf'][$key])."</td>\n";
|
print '<td class="center">'.$extrafields->attributes[$elementtype]['documentpdf'][$key]."</td>\n";
|
||||||
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."</td>\n";
|
print '<td class="center">'.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."</td>\n";
|
||||||
if (! empty($conf->multicompany->enabled)) {
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user