Merge pull request #4770 from FHenry/3.8

FIX : #4768
This commit is contained in:
Laurent Destailleur 2016-03-10 13:40:25 +01:00
commit e346559219
4 changed files with 50 additions and 20 deletions

View File

@ -685,21 +685,39 @@ class pdf_azur extends ModelePDFPropales
if (count($filetomerge->lines) > 0) { if (count($filetomerge->lines) > 0) {
foreach ( $filetomerge->lines as $linefile ) { foreach ( $filetomerge->lines as $linefile ) {
if (! empty($linefile->id) && ! empty($linefile->file_name)) { if (! empty($linefile->id) && ! empty($linefile->file_name)) {
if (! empty($conf->product->enabled))
$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . dol_sanitizeFileName($line->product_ref);
elseif (! empty($conf->service->enabled)) if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . dol_sanitizeFileName($line->product_ref); {
if (! empty($conf->product->enabled)) {
$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
} elseif (! empty($conf->service->enabled)) {
$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
}
}
else
{
if (! empty($conf->product->enabled)) {
$filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
} elseif (! empty($conf->service->enabled)) {
$filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref);
}
}
dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG); dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG);
$infile = $filetomerge_dir . '/' . $linefile->file_name; $infile = $filetomerge_dir . '/' . $linefile->file_name;
if (is_file($infile)) { if (file_exists($infile) && is_readable($infile)) {
$pagecount = $pdf->setSourceFile($infile); $pagecount = $pdf->setSourceFile($infile);
for($i = 1; $i <= $pagecount; $i ++) { for($i = 1; $i <= $pagecount; $i ++) {
$tplidx = $pdf->ImportPage($i); $tplIdx = $pdf->importPage(1);
$s = $pdf->getTemplatesize($tplidx); if ($tplIdx!==false) {
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); $s = $pdf->getTemplatesize($tplIdx);
$pdf->useTemplate($tplidx); $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
$pdf->useTemplate($tplIdx);
} else {
setEventMessages(null, array($infile.' cannot be added, probably protected PDF'),'warnings');
}
} }
} }
} }
@ -709,10 +727,6 @@ class pdf_azur extends ModelePDFPropales
} }
} }
//exit;
$pdf->Close(); $pdf->Close();
$pdf->Output($file,'F'); $pdf->Output($file,'F');

View File

@ -797,3 +797,14 @@ ALTER TABLE llx_societe_remise_except MODIFY COLUMN description text NOT NULL;
update llx_opensurvey_sondage set format = 'D' where format = 'D+'; update llx_opensurvey_sondage set format = 'D' where format = 'D+';
update llx_opensurvey_sondage set format = 'A' where format = 'A+'; update llx_opensurvey_sondage set format = 'A' where format = 'A+';
--Deal with holidays_user that do not have rowid
CREATE TABLE llx_holiday_users_tmp
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
fk_user integer NOT NULL,
fk_type integer NOT NULL,
nb_holiday real NOT NULL DEFAULT '0'
) ENGINE=innodb;
INSERT INTO llx_holiday_users_tmp(fk_user,fk_type,nb_holiday) SELECT fk_user,fk_type,nb_holiday FROM llx_holiday_users;
DROP TABLE llx_holiday_users;
ALTER TABLE llx_holiday_users_tmp RENAME TO llx_holiday_users;

View File

@ -18,8 +18,8 @@
CREATE TABLE llx_holiday_users CREATE TABLE llx_holiday_users
( (
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
fk_user integer NOT NULL, fk_user integer NOT NULL,
fk_type integer NOT NULL, fk_type integer NOT NULL,
nb_holiday real NOT NULL DEFAULT '0' nb_holiday real NOT NULL DEFAULT '0'
) ) ENGINE=innodb;
ENGINE=innodb;

View File

@ -228,7 +228,6 @@ if ($object->id)
$param = '&id=' . $object->id; $param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
// Merge propal PDF docuemnt PDF files // Merge propal PDF docuemnt PDF files
if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
{ {
@ -243,8 +242,14 @@ if ($object->id)
$form = new Form($db); $form = new Form($db);
$filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1);
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs
{
$filearray = dol_dir_list($upload_dirold, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1);
}
// For each file build select list with PDF extention // For each file build select list with PDF extention
if (count($filearray) > 0) if (count($filearray) > 0)
{ {