diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index a70c5159370..3f0b8af0e4e 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2115,6 +2115,7 @@ else print ''.price($line->total_ttc).''; } + // Column with preview print ''; if ($line->fk_ecm_files > 0) { @@ -2141,7 +2142,50 @@ else print ''; print ''; } - else print ' '; + else + { + $modulepart='expensereport'; + $thumbshown=0; + if (preg_match('/\.pdf$/i', $ecmfilesstatic->filename)) + { + $filepdf = $conf->expensereport->dir_output.'/'.$relativepath.$ecmfilesstatic->filename; + $fileimage = $conf->expensereport->dir_output.'/'.$relativepath.$ecmfilesstatic->filename.'_preview.png'; + $relativepathimage = $relativepath.$ecmfilesstatic->filename.'_preview.png'; + + $pdfexists = file_exists($filepdf); + + if ($pdfexists) + { + // Conversion du PDF en image png si fichier png non existant + if (! file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) + { + if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experience trouble with pdf thumb generation and imagick, you can disable here. + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png + if ($ret < 0) $error++; + } + } + } + + if ($pdfexists && ! $error) + { + $heightforphotref=70; + if (! empty($conf->dol_optimize_smallscreen)) $heightforphotref=60; + // If the preview file is found + if (file_exists($fileimage)) + { + $thumbshown=1; + print ''; + } + } + } + + if (! $thumbshown) + { + print img_mime($ecmfilesstatic->filename); + } + } } } print ''; @@ -2166,77 +2210,77 @@ else if ($action == 'editline' && $line->rowid == GETPOST('rowid', 'int')) { - print ''; + print ''; - print ''; + print ''; - // Select date - print ''; - print $form->selectDate($line->date, 'date'); - print ''; + // Select date + print ''; + print $form->selectDate($line->date, 'date'); + print ''; - // Select project - if (! empty($conf->projet->enabled)) - { - print ''; - $formproject->select_projects(-1, $line->fk_project, 'fk_projet', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); - print ''; - } - - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) - { - print ''; - $params = array('fk_expense' => $object->id, 'fk_expense_det' => $line->rowid, 'date' => $line->dates); - print $form->selectExpenseCategories($line->fk_c_exp_tax_cat, 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params); - print ''; - } - - // Select type - print ''; - select_type_fees_id($line->fk_c_type_fees, 'fk_c_type_fees'); - print ''; - - // Add comments + // Select project + if (! empty($conf->projet->enabled)) + { print ''; - print ''; + $formproject->select_projects(-1, $line->fk_project, 'fk_projet', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); print ''; + } - // VAT - print ''; - print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$line->vatrate), $mysoc, '', 0, 0, '', false, 1); + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) + { + print ''; + $params = array('fk_expense' => $object->id, 'fk_expense_det' => $line->rowid, 'date' => $line->dates); + print $form->selectExpenseCategories($line->fk_c_exp_tax_cat, 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params); print ''; + } - // Unit price - print ''; - print ''; - print ''; + // Select type + print ''; + select_type_fees_id($line->fk_c_type_fees, 'fk_c_type_fees'); + print ''; - // Unit price with tax - print ''; - print ''; - print ''; + // Add comments + print ''; + print ''; + print ''; - // Quantity - print ''; - print ''; - print ''; + // VAT + print ''; + print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$line->vatrate), $mysoc, '', 0, 0, '', false, 1); + print ''; - if ($action != 'editline') - { - print ''.$langs->trans('AmountHT').''; - print ''.$langs->trans('AmountTTC').''; - } + // Unit price + print ''; + print ''; + print ''; - // Picture - print ''; - //print $line->fk_ecm_files; - print ''; + // Unit price with tax + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print '
'; - print ''; + // Quantity + print ''; + print ''; + print ''; + + if ($action != 'editline') + { + print ''.$langs->trans('AmountHT').''; + print ''.$langs->trans('AmountTTC').''; + } + + // Picture + print ''; + //print $line->fk_ecm_files; + print ''; + + print ''; + print ''; + print ''; + print '
'; + print ''; } $i++; @@ -2378,8 +2422,6 @@ else else { $modulepart='expensereport'; - //$conf->global->MAIN_DISABLE_PDF_THUMBS=1; - print '
'; $thumbshown=0; if (preg_match('/\.pdf$/i', $file['name']))