add extrafields in notes
This commit is contained in:
parent
60b3d9d4db
commit
8c36dd0ad8
@ -1102,7 +1102,7 @@ abstract class CommonDocGenerator
|
|||||||
*
|
*
|
||||||
* @param object $object common object
|
* @param object $object common object
|
||||||
* @param string $extrafieldKey the extrafield key
|
* @param string $extrafieldKey the extrafield key
|
||||||
* @return null
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getExtrafieldContent($object, $extrafieldKey)
|
public function getExtrafieldContent($object, $extrafieldKey)
|
||||||
{
|
{
|
||||||
@ -1157,48 +1157,80 @@ abstract class CommonDocGenerator
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print extrafields columns content
|
* display extrafields columns content
|
||||||
*
|
*
|
||||||
* @param Tcpdf $pdf pdf object
|
|
||||||
* @param float $curY curent Y position
|
|
||||||
* @param object $object line of common object
|
* @param object $object line of common object
|
||||||
|
* @param Translate $outputlangs Output language
|
||||||
* @return double max y value
|
* @return double max y value
|
||||||
*/
|
*/
|
||||||
public function printLineExtrafieldsColumnsContent($pdf, &$curY, $object)
|
public function getExtrafieldsInHtml($object, $outputlangs)
|
||||||
{
|
{
|
||||||
global $hookmanager;
|
global $hookmanager;
|
||||||
|
|
||||||
if(empty($object->table_element) || !isset($this->extrafieldsCache[$object->table_element])){
|
if(empty($object->table_element)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nextY = $curY;
|
// Load extrafiels if not allready does
|
||||||
|
if(!isset($this->extrafieldsCache)){ $this->extrafieldsCache = array(); }
|
||||||
|
if(!isset($this->extrafieldsCache[$object->table_element])){
|
||||||
|
$extrafields = new ExtraFields($this->db);
|
||||||
|
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$extrafields = $this->extrafieldsCache[$object->table_element];
|
||||||
|
}
|
||||||
|
|
||||||
// get extrafield config from cache
|
|
||||||
$extrafields =& $this->extrafieldsCache[$object->table_element];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var $extrafields ExtraFields
|
* @var $extrafields ExtraFields
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$html = '';
|
||||||
|
$fields = array();
|
||||||
|
|
||||||
if (is_array($extrafields->attributes[$object->table_element]['label'])) {
|
if (is_array($extrafields->attributes[$object->table_element]['label'])) {
|
||||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label)
|
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label)
|
||||||
{
|
{
|
||||||
$extrafieldColKey = "options_".$key;
|
// Enable extrafield ?
|
||||||
|
$enabled = 1;
|
||||||
if ($this->getColumnStatus($extrafieldColKey) && isset($object->array_options[$extrafieldColKey]))
|
if ($enabled && isset($extrafields->attributes[$object->table_element]['enabled'][$key])){
|
||||||
{
|
$enabled = dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1);
|
||||||
// TODO : allow showOutputField to be pdf public friendly, ex: in a link to object, clean getNomUrl to remove link and images...
|
|
||||||
$columnText = $extrafields->showOutputField($key, $object->array_options[$extrafieldColKey], '', $object->table_element);
|
|
||||||
|
|
||||||
|
|
||||||
$this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $columnText);
|
|
||||||
$nextY = max($pdf->GetY(), $nextY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($enabled && isset($extrafields->attributes[$object->table_element]['list'][$key])){
|
||||||
|
$enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO : add extrafields enabled for display from extrafield config panel
|
||||||
|
|
||||||
|
if(empty($enabled)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$field = new stdClass();
|
||||||
|
$field->rank = intval($extrafields->attributes[$object->table_element]['pos'][$key]);
|
||||||
|
$field->content = $this->getExtrafieldContent($object, $key);
|
||||||
|
$field->label = $outputlangs->transnoentities($label);
|
||||||
|
|
||||||
|
$fields[] = $field;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $nextY;
|
if(!empty($fields))
|
||||||
|
{
|
||||||
|
uasort($fields, function($a, $b){
|
||||||
|
return ($a->rank > $b->rank) ? -1 : 1;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($fields as $field){
|
||||||
|
$html.= !empty($html)?'<br/>':'';
|
||||||
|
$html.= $field->label.' : '.$field->content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1314,15 +1346,16 @@ abstract class CommonDocGenerator
|
|||||||
|
|
||||||
// Enable extrafield ?
|
// Enable extrafield ?
|
||||||
$enabled = 1;
|
$enabled = 1;
|
||||||
if ($enabled && isset($extrafields->attributes[$object->table_element]['enabled'][$key]))
|
if ($enabled && isset($extrafields->attributes[$object->table_element]['enabled'][$key])){
|
||||||
{
|
|
||||||
$enabled = dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1);
|
$enabled = dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1);
|
||||||
}
|
}
|
||||||
if ($enabled && isset($extrafields->attributes[$object->table_element]['list'][$key]))
|
|
||||||
{
|
if ($enabled && isset($extrafields->attributes[$object->table_element]['list'][$key])){
|
||||||
$enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1);
|
$enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO : add extrafields $enabled from extrafield config panel
|
||||||
|
|
||||||
// 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]);
|
||||||
|
|
||||||
|
|||||||
@ -410,6 +410,13 @@ class pdf_eratosthene extends ModelePDFCommandes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extrafields in note
|
||||||
|
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
|
||||||
|
if (!empty($extranote))
|
||||||
|
{
|
||||||
|
$notetoshow = dol_concatdesc($notetoshow, $extranote);
|
||||||
|
}
|
||||||
|
|
||||||
$pagenb = $pdf->getPage();
|
$pagenb = $pdf->getPage();
|
||||||
if ($notetoshow)
|
if ($notetoshow)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -336,7 +336,17 @@ class pdf_espadon extends ModelePdfExpedition
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($object->note_public) || !empty($object->tracking_number))
|
// display note
|
||||||
|
$notetoshow = empty($object->note_public) ? '' : $object->note_public;
|
||||||
|
|
||||||
|
// Extrafields in note
|
||||||
|
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
|
||||||
|
if (!empty($extranote))
|
||||||
|
{
|
||||||
|
$notetoshow = dol_concatdesc($notetoshow, $extranote);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($notetoshow) || !empty($object->tracking_number))
|
||||||
{
|
{
|
||||||
$tab_top = 88 + $height_incoterms;
|
$tab_top = 88 + $height_incoterms;
|
||||||
$tab_top_alt = $tab_top;
|
$tab_top_alt = $tab_top;
|
||||||
@ -375,10 +385,10 @@ class pdf_espadon extends ModelePdfExpedition
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Notes
|
// Notes
|
||||||
if (!empty($object->note_public))
|
if (!empty($notetoshow))
|
||||||
{
|
{
|
||||||
$pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page
|
$pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page
|
||||||
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
|
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($notetoshow), 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$nexY = $pdf->GetY();
|
$nexY = $pdf->GetY();
|
||||||
|
|||||||
@ -447,6 +447,13 @@ class pdf_sponge extends ModelePDFFactures
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extrafields in note
|
||||||
|
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
|
||||||
|
if (!empty($extranote))
|
||||||
|
{
|
||||||
|
$notetoshow = dol_concatdesc($notetoshow, $extranote);
|
||||||
|
}
|
||||||
|
|
||||||
$pagenb = $pdf->getPage();
|
$pagenb = $pdf->getPage();
|
||||||
if ($notetoshow)
|
if ($notetoshow)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -418,6 +418,14 @@ class pdf_cyan extends ModelePDFPropales
|
|||||||
if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
|
if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extrafields in note
|
||||||
|
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
|
||||||
|
if (!empty($extranote))
|
||||||
|
{
|
||||||
|
$notetoshow = dol_concatdesc($notetoshow, $extranote);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
|
if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
|
||||||
{
|
{
|
||||||
$tmpuser = new User($this->db);
|
$tmpuser = new User($this->db);
|
||||||
|
|||||||
@ -369,6 +369,13 @@ class pdf_cornas extends ModelePDFSuppliersOrders
|
|||||||
// Affiche notes
|
// Affiche notes
|
||||||
$notetoshow = empty($object->note_public) ? '' : $object->note_public;
|
$notetoshow = empty($object->note_public) ? '' : $object->note_public;
|
||||||
|
|
||||||
|
// Extrafields in note
|
||||||
|
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
|
||||||
|
if (!empty($extranote))
|
||||||
|
{
|
||||||
|
$notetoshow = dol_concatdesc($notetoshow, $extranote);
|
||||||
|
}
|
||||||
|
|
||||||
$pagenb = $pdf->getPage();
|
$pagenb = $pdf->getPage();
|
||||||
if ($notetoshow)
|
if ($notetoshow)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user