diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 5f6958ae206..10a91c3fb07 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1044,7 +1044,7 @@ class FormFile * @param int $disablemove 1=Disable move button, 0=Position move is possible. * @param int $addfilterfields Add line with filters * @return int <0 if KO, nb of files shown if OK - * @see list_of_autoecmfiles + * @see list_of_autoecmfiles() */ public function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0) { diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 34f6486e417..0636460de4c 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -33,10 +33,12 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmfiles.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/modules/expensereport/modules_expensereport.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php'; @@ -1348,6 +1350,7 @@ $formproject = new FormProjets($db); $projecttmp = new Project($db); $paymentexpensereportstatic=new PaymentExpenseReport($db); $bankaccountstatic = new Account($db); +$ecmfilesstatic = new EcmFiles($db); // Create if ($action == 'create') @@ -2028,7 +2031,7 @@ else if (! empty($conf->projet->enabled)) print ''.$langs->trans('Project').''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''.$langs->trans('CarCategory').''; print ''.$langs->trans('Type').''; - print ''.$langs->trans('Description').''; + print ''.$langs->trans('Description').''; print ''.$langs->trans('VAT').''; print ''.$langs->trans('PriceUHT').''; print ''.$langs->trans('PriceUTTC').''; @@ -2038,6 +2041,9 @@ else print ''.$langs->trans('AmountHT').''; print ''.$langs->trans('AmountTTC').''; } + // Picture + print ''; + print ''; // Ajout des boutons de modification/suppression if (($object->fk_statut < 2 || $object->fk_statut == 99) && $user->rights->expensereport->creer) { @@ -2110,6 +2116,37 @@ else print ''.price($line->total_ttc).''; } + print ''; + if ($line->fk_ecm_files > 0) + { + $modulepart='expensereport'; + $maxheightmini=32; + + $result = $ecmfilesstatic->fetch($line->fk_ecm_files); + if ($result > 0) + { + $relativepath=preg_replace('/expensereport\//', '', $ecmfilesstatic->filepath); + $fileinfo = pathinfo($ecmfilesstatic->filepath.'/'.$ecmfilesstatic->filename); + if (image_format_supported($fileinfo['basename']) > 0) + { + $minifile=getImageFileNameForSize($fileinfo['basename'], '_mini'); // For new thumbs using same ext (in lower case howerver) than original + if (! dol_is_file($conf->expensereport->dir_output.'/'.$relativepath.'/'.$minifile)) $minifile=getImageFileNameForSize($fileinfo['basename'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension + //print $file['path'].'/'.$minifile.'
'; + $urlforhref=getAdvancedPreviewUrl($modulepart, $relativepath.'/'.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity)); + if (empty($urlforhref)) { + $urlforhref=DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); + print ''; + } else { + print ''; + } + print ''; + print ''; + } + else print ' '; + } + } + print ''; + // Ajout des boutons de modification/suppression if (($object->fk_statut < ExpenseReport::STATUS_VALIDATED || $object->fk_statut == ExpenseReport::STATUS_REFUSED) && $user->rights->expensereport->creer) { @@ -2191,6 +2228,11 @@ else print ''.$langs->trans('AmountTTC').''; } + // Picture + print ''; + //print $line->fk_ecm_files; + print ''; + print ''; print ''; print ''; @@ -2205,7 +2247,7 @@ else // Add a line if (($object->fk_statut == ExpenseReport::STATUS_DRAFT || $object->fk_statut == ExpenseReport::STATUS_REFUSED) && $action != 'editline' && $user->rights->expensereport->creer) { - $colspan = 10; + $colspan = 11; if (! empty($conf->global->MAIN_USE_EXPENSE_IK)) $colspan++; if (! empty($conf->projet->enabled)) $colspan++; if ($action != 'editline') $colspan++; @@ -2274,10 +2316,6 @@ else { $savingdocmask=dol_sanitizeFileName($object->ref).'-__file__'; } - /*if (in_array($modulepart,array('member'))) - { - $savingdocmask=$object->login.'___file__'; - }*/ } // Show upload form (document and links) @@ -2371,7 +2409,10 @@ else print ''.$langs->trans('PriceUHT').''; print ''.$langs->trans('PriceUTTC').''; print ''.$langs->trans('Qty').''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; @@ -2432,6 +2473,9 @@ else print ''; // We must be able to enter decimal qty print ''; + // Picture + print ''; + if ($action != 'editline') { print ''; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index b4da3ec760f..b60a8a68b49 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -971,7 +971,7 @@ class ExpenseReport extends CommonObject $this->lines=array(); $sql = ' SELECT de.rowid, de.comments, de.qty, de.value_unit, de.date, de.rang,'; - $sql.= ' de.'.$this->fk_element.', de.fk_c_type_fees, de.fk_c_exp_tax_cat, de.fk_projet as fk_project, de.tva_tx,'; + $sql.= ' de.'.$this->fk_element.', de.fk_c_type_fees, de.fk_c_exp_tax_cat, de.fk_projet as fk_project, de.tva_tx, de.fk_ecm_files,'; $sql.= ' de.total_ht, de.total_tva, de.total_ttc,'; $sql.= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,'; $sql.= ' p.ref as ref_projet, p.title as title_projet'; @@ -1010,8 +1010,9 @@ class ExpenseReport extends CommonObject $deplig->fk_expensereport = $objp->fk_expensereport; $deplig->fk_c_type_fees = $objp->fk_c_type_fees; $deplig->fk_c_exp_tax_cat = $objp->fk_c_exp_tax_cat; - $deplig->fk_projet = $objp->fk_project; + $deplig->fk_projet = $objp->fk_project; // deprecated $deplig->fk_project = $objp->fk_project; + $deplig->fk_ecm_files = $objp->fk_ecm_files; $deplig->total_ht = $objp->total_ht; $deplig->total_tva = $objp->total_tva; @@ -1751,7 +1752,8 @@ class ExpenseReport extends CommonObject $this->line->fk_c_type_fees = $fk_c_type_fees; $this->line->fk_c_exp_tax_cat = $fk_c_exp_tax_cat; $this->line->comments = $comments; - $this->line->fk_projet = $fk_project; + $this->line->fk_projet = $fk_project; // deprecated + $this->line->fk_project = $fk_project; $this->line->fk_ecm_files = $fk_ecm_files; @@ -2500,6 +2502,9 @@ class ExpenseReportLine public $total_tva; public $total_ttc; + /** + * @var int ID into llx_ecm_files table to link line to attached file + */ public $fk_ecm_files; @@ -2522,7 +2527,7 @@ class ExpenseReportLine public function fetch($rowid) { $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_c_exp_tax_cat, fde.fk_projet as fk_project, fde.date,'; - $sql.= ' fde.tva_tx as vatrate, fde.vat_src_code, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; + $sql.= ' fde.tva_tx as vatrate, fde.vat_src_code, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc, fde.fk_ecm_files,'; $sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,'; $sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref'; $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde'; @@ -2537,8 +2542,8 @@ class ExpenseReportLine $objp = $this->db->fetch_object($result); $this->rowid = $objp->rowid; - $this->id = $obj->rowid; - $this->ref = $obj->ref; + $this->id = $objp->rowid; + $this->ref = $objp->ref; $this->fk_expensereport = $objp->fk_expensereport; $this->comments = $objp->comments; $this->qty = $objp->qty; @@ -2558,6 +2563,7 @@ class ExpenseReportLine $this->total_ht = $objp->total_ht; $this->total_tva = $objp->total_tva; $this->total_ttc = $objp->total_ttc; + $this->fk_ecm_files = $objp->fk_ecm_files; $this->db->free($result); } else { @@ -2652,7 +2658,7 @@ class ExpenseReportLine * @param ExpenseReportRule $rule object rule to check * @param int $fk_user user author id * @param string $mode day|EX_DAY / month|EX_MON / year|EX_YEA to get amount - * @return amount Amount + * @return float Amount */ public function getExpAmount(ExpenseReportRule $rule, $fk_user, $mode = 'day') { @@ -2689,7 +2695,7 @@ class ExpenseReportLine } /** - * update + * Update line * * @param User $user User * @return int <0 if KO, >0 if OK