* fix cti

* fix cti

* no photo in asset lines

* no photo in asset lines

* no photo in asset lines

* no photo in asset lines

* no photo in recruitment lines

* no photo in recruitment lines

* fix

* fix dead catch
This commit is contained in:
Frédéric FRANCE
2024-06-03 13:44:14 +02:00
committed by GitHub
parent 689cfc36eb
commit 652c8526fa
9 changed files with 84 additions and 309 deletions

View File

@@ -3654,7 +3654,7 @@ class Propal extends CommonObject
}
if ($user->hasRight('propal', 'lire')) {
$datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Proposal").'</u>';
if (isset($this->statut)) {
if (isset($this->status)) {
$datas['status'] = ' '.$this->getLibStatut(5);
}
if (!empty($this->ref)) {
@@ -3674,7 +3674,7 @@ class Propal extends CommonObject
$langs->load('project');
if (empty($this->project)) {
$res = $this->fetch_project();
if ($res > 0 && $this->project instanceof Project) {
if ($res > 0 && !empty($this->project) && $this->project instanceof Project) {
$datas['project'] = '<br><b>'.$langs->trans('Project').':</b> '.$this->project->getNomUrl(1, '', 0, 1);
}
}

View File

@@ -3756,7 +3756,7 @@ class Commande extends CommonOrder
$langs->load('project');
if (empty($this->project)) {
$res = $this->fetch_project();
if ($res > 0 && $this->project instanceof Project) {
if ($res > 0 && !empty($this->project) && $this->project instanceof Project) {
$datas['project'] = '<br><b>'.$langs->trans('Project').':</b> '.$this->project->getNomUrl(1, '', 0, 1);
}
}

View File

@@ -2086,9 +2086,9 @@ class Contrat extends CommonObject
$datas['refcustomer'] = '<br><b>'.$langs->trans('RefCustomer').':</b> '. $this->ref_customer;
if (!$nofetch) {
$langs->load('project');
if (empty($this->project) && $this->project instanceof Project) {
if (empty($this->project)) {
$res = $this->fetch_project();
if ($res > 0) {
if ($res > 0 && !empty($this->project) && $this->project instanceof Project) {
$datas['project'] = '<br><b>'.$langs->trans('Project').':</b> '.$this->project->getNomUrl(1, '', 0, 1);
}
}

View File

@@ -2,6 +2,7 @@
/* Copyright (C) 2011-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -141,7 +141,7 @@ class pdf_standard_asset extends ModelePDFAsset
/**
* Function to build pdf onto disk
*
* @param Object $object Object to generate
* @param Asset $object Object to generate
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
@@ -181,62 +181,6 @@ class pdf_standard_asset extends ModelePDFAsset
$hidetop = getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE');
}
// Loop on each lines to detect if there is at least one image to show
$realpatharray = array();
$this->atleastonephoto = false;
/*
if (!empty($conf->global->MAIN_GENERATE_ASSET_WITH_PICTURE))
{
$objphoto = new Product($this->db);
for ($i = 0; $i < $nblines; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
//var_dump($objphoto->ref);exit;
if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
$pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
$pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
} else {
$pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default
$pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
}
$arephoto = false;
foreach ($pdir as $midir)
{
if (!$arephoto)
{
$dir = $conf->product->dir_output.'/'.$midir;
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
{
if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
{
if ($obj['photo_vignette'])
{
$filename = $obj['photo_vignette'];
} else {
$filename = $obj['photo'];
}
} else {
$filename = $obj['photo'];
}
$realpath = $dir.$filename;
$arephoto = true;
$this->atleastonephoto = true;
}
}
}
if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
}
}
*/
//if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
if ($conf->asset->dir_output.'/asset') {
$object->fetch_thirdparty();
@@ -495,12 +439,6 @@ class pdf_standard_asset extends ModelePDFAsset
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
// Define size of image if we need it
$imglinesize = array();
if (!empty($realpatharray[$i])) {
$imglinesize = pdf_getSizeForImage($realpatharray[$i]);
}
$pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore = $pdf->getPage();
@@ -508,32 +446,6 @@ class pdf_standard_asset extends ModelePDFAsset
$showpricebeforepagebreak = 1;
$posYAfterImage = 0;
if ($this->getColumnStatus('photo')) {
// We start with Photo of product line
if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
$pdf->AddPage('', '', true);
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
$pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
// Allows data in the first page if description is long enough to break in multiples pages
if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
$showpricebeforepagebreak = 1;
} else {
$showpricebeforepagebreak = 0;
}
}
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height'];
}
}
// Description of product line
if ($this->getColumnStatus('desc')) {
$pdf->startTransaction();
@@ -578,7 +490,7 @@ class pdf_standard_asset extends ModelePDFAsset
$pdf->setTopMargin($this->marge_haute);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description or photo were moved completely on next page
// We suppose that a too long description were moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter);
$curY = $tab_top_newpage;
@@ -872,7 +784,7 @@ class pdf_standard_asset extends ModelePDFAsset
* Show top header of page.
*
* @param TCPDF|TCPDI $pdf Object PDF
* @param Object $object Object to show
* @param Asset $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @param Translate $outputlangsbis Object lang for output bis
@@ -890,7 +802,7 @@ class pdf_standard_asset extends ModelePDFAsset
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
if ($object->statut == $object::STATUS_DRAFT && (getDolGlobalString('FACTURE_DRAFT_WATERMARK'))) {
if ($object->status == $object::STATUS_DRAFT && (getDolGlobalString('FACTURE_DRAFT_WATERMARK'))) {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
}
@@ -947,7 +859,7 @@ class pdf_standard_asset extends ModelePDFAsset
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
if ($object->statut == $object::STATUS_DRAFT) {
if ($object->status == $object::STATUS_DRAFT) {
$pdf->SetTextColor(128, 0, 0);
$textref .= ' - '.$outputlangs->transnoentities("NotValidated");
}
@@ -956,12 +868,12 @@ class pdf_standard_asset extends ModelePDFAsset
$posy += 1;
$pdf->SetFont('', '', $default_font_size - 2);
if ($object->ref_client) {
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}
// if ($object->ref_client) {
// $posy += 4;
// $pdf->SetXY($posx, $posy);
// $pdf->SetTextColor(0, 0, 60);
// $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
// }
if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
$object->fetch_projet();
@@ -992,7 +904,7 @@ class pdf_standard_asset extends ModelePDFAsset
if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
$title .= ' - '.$outputlangsbis->transnoentities("Date");
}
$pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R');
$pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date_acquisition, "day", false, $outputlangs), '', 'R');
if ($object->thirdparty->code_client) {
$posy += 3;
@@ -1124,7 +1036,7 @@ class pdf_standard_asset extends ModelePDFAsset
* Show footer of page. Need this->emetteur object
*
* @param TCPDF $pdf PDF
* @param Object $object Object to show
* @param Asset $object Object to show
* @param Translate $outputlangs Object lang for output
* @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text
@@ -1138,7 +1050,7 @@ class pdf_standard_asset extends ModelePDFAsset
/**
* Define Array Column Field
*
* @param object $object common object
* @param Asset $object common object
* @param Translate $outputlangs langs
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
@@ -1197,27 +1109,6 @@ class pdf_standard_asset extends ModelePDFAsset
),
);
// PHOTO
$rank = $rank + 10;
$this->cols['photo'] = array(
'rank' => $rank,
'width' => getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20), // in mm
'status' => false,
'title' => array(
'textkey' => 'Photo',
'label' => ' '
),
'content' => array(
'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
'border-left' => false, // remove left line separator
);
if (getDolGlobalString('MAIN_GENERATE_INVOICES_WITH_PICTURE') && !empty($this->atleastonephoto)) {
$this->cols['photo']['status'] = true;
}
$rank = $rank + 10;
$this->cols['vat'] = array(
'rank' => $rank,

View File

@@ -4,7 +4,7 @@
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2018-2019 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -395,7 +395,6 @@ class doc_generic_bom_odt extends ModelePDFBom
}
}
// Replace tags of lines
try {
$foundtagforlines = 1;
try {
$listlines = $odfHandler->setSegment('lines');
@@ -438,13 +437,14 @@ class doc_generic_bom_odt extends ModelePDFBom
}
$listlines->merge();
}
try {
$odfHandler->mergeSegment($listlines);
}
} catch (OdfException $e) {
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
}
// Replace labels translated
$tmparray = $outputlangs->get_translations_for_substitutions();

View File

@@ -219,63 +219,6 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$hidetop = getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE');
}
// Loop on each lines to detect if there is at least one image to show
$realpatharray = array();
// $this->atleastonephoto = false;
/*
if (!empty($conf->global->MAIN_GENERATE_MYOBJECT_WITH_PICTURE))
{
$objphoto = new Product($this->db);
for ($i = 0; $i < $nblines; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
$objphoto->fetch($object->lines[$i]->fk_product);
//var_dump($objphoto->ref);exit;
if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
$pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
$pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
} else {
$pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default
$pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
}
$arephoto = false;
foreach ($pdir as $midir)
{
if (!$arephoto)
{
$dir = $conf->product->dir_output.'/'.$midir;
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
{
if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
{
if ($obj['photo_vignette'])
{
$filename = $obj['photo_vignette'];
} else {
$filename = $obj['photo'];
}
} else {
$filename = $obj['photo'];
}
$realpath = $dir.$filename;
$arephoto = true;
$this->atleastonephoto = true;
}
}
}
if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
}
}
*/
//if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
if ($conf->recruitment->dir_output.'/recruitmentjobposition') {
$object->fetch_thirdparty();
@@ -532,44 +475,11 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
// Define size of image if we need it
$imglinesize = array();
if (!empty($realpatharray[$i])) {
$imglinesize = pdf_getSizeForImage($realpatharray[$i]);
}
$pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore = $pdf->getPage();
$showpricebeforepagebreak = 1;
$posYAfterImage = 0;
if ($this->getColumnStatus('photo')) {
// We start with Photo of product line
if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
$pdf->AddPage('', '', true);
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
$pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
// Allows data in the first page if description is long enough to break in multiples pages
if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
$showpricebeforepagebreak = 1;
} else {
$showpricebeforepagebreak = 0;
}
}
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height'];
}
}
// Description of product line
if ($this->getColumnStatus('desc')) {
@@ -586,8 +496,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY();
//var_dump($posyafter);
//var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
$pdf->AddPage('', '', true);
@@ -616,7 +525,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$pdf->setTopMargin($this->marge_haute);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description or photo were moved completely on next page
// We suppose that a too long description were moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter);
$curY = $tab_top_newpage;
@@ -624,8 +533,6 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par default
$parameters = array(
'object' => $object,
'i' => $i,
@@ -637,8 +544,6 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
);
$reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter) {
$pdf->setPage($pagenb);
@@ -795,7 +700,6 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
// Output Rect
$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
if (empty($hidetop)) {
@@ -826,7 +730,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
if ($object->statut == $object::STATUS_DRAFT && getDolGlobalString('RECRUITMENT_RECRUITMENTJOBPOSITION_DRAFT_WATERMARK')) {
if ($object->status == $object::STATUS_DRAFT && getDolGlobalString('RECRUITMENT_RECRUITMENTJOBPOSITION_DRAFT_WATERMARK')) {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', getDolGlobalString('RECRUITMENT_RECRUITMENTJOBPOSITION_DRAFT_WATERMARK'));
}
@@ -879,7 +783,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
if ($object->statut == $object::STATUS_DRAFT) {
if ($object->status == $object::STATUS_DRAFT) {
$pdf->SetTextColor(128, 0, 0);
$textref .= ' - '.$outputlangs->transnoentities("NotValidated");
}
@@ -1125,28 +1029,6 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio
),
);
// PHOTO
$rank = $rank + 10;
$this->cols['photo'] = array(
'rank' => $rank,
'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
'status' => false,
'title' => array(
'textkey' => 'Photo',
'label' => ' '
),
'content' => array(
'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
'border-left' => false, // remove left line separator
);
if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
{
$this->cols['photo']['status'] = true;
}
$rank = $rank + 10;
$this->cols['vat'] = array(
'rank' => $rank,

View File

@@ -2,6 +2,7 @@
/* Copyright (C) 2016-2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -4381,7 +4382,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties
print $langs->trans('WEBSITE_PAGENAME');
print '</td><td>';
print '<span class="opacitymedium spanprefix hidden"></span> ';
print '<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag((string) preg_replace('/^_[a-z]+_page_/', '', $pageurl)).'">';
print '<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag((string) preg_replace('/^_[a-z]+_page_/', '', (string) $pageurl)).'">';
print '</td></tr>';
print '<script type="text/javascript">