WIP file attachment on expense report lines
This commit is contained in:
parent
a0206d554e
commit
5ff76e2c13
@ -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)
|
||||
{
|
||||
|
||||
@ -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 '<td class="minwidth100imp">'.$langs->trans('Project').'</td>';
|
||||
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print '<td>'.$langs->trans('CarCategory').'</td>';
|
||||
print '<td class="center">'.$langs->trans('Type').'</td>';
|
||||
print '<td class="left">'.$langs->trans('Description').'</td>';
|
||||
print '<td>'.$langs->trans('Description').'</td>';
|
||||
print '<td class="right">'.$langs->trans('VAT').'</td>';
|
||||
print '<td class="right">'.$langs->trans('PriceUHT').'</td>';
|
||||
print '<td class="right">'.$langs->trans('PriceUTTC').'</td>';
|
||||
@ -2038,6 +2041,9 @@ else
|
||||
print '<td class="right">'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td class="right">'.$langs->trans('AmountTTC').'</td>';
|
||||
}
|
||||
// Picture
|
||||
print '<td>';
|
||||
print '</td>';
|
||||
// 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 '<td class="right">'.price($line->total_ttc).'</td>';
|
||||
}
|
||||
|
||||
print '<td class="center">';
|
||||
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.'<br>';
|
||||
$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 '<a href="'.$urlforhref.'" class="aphoto" target="_blank">';
|
||||
} else {
|
||||
print '<a href="'.$urlforhref['url'].'" class="'.$urlforhref['css'].'" target="'.$urlforhref['target'].'" mime="'.$urlforhref['mime'].'">';
|
||||
}
|
||||
print '<img class="photo" height="'.$maxheightmini.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.'/'.$minifile).'" title="">';
|
||||
print '</a>';
|
||||
}
|
||||
else print ' ';
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// 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 '<td class="right">'.$langs->trans('AmountTTC').'</td>';
|
||||
}
|
||||
|
||||
// Picture
|
||||
print '<td class="center">';
|
||||
//print $line->fk_ecm_files;
|
||||
print '</td>';
|
||||
|
||||
print '<td class="center">';
|
||||
print '<input type="hidden" name="rowid" value="'.$line->rowid.'">';
|
||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans('Save').'">';
|
||||
@ -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 '<td class="right">'.$langs->trans('PriceUHT').'</td>';
|
||||
print '<td class="right">'.$langs->trans('PriceUTTC').'</td>';
|
||||
print '<td class="right">'.$langs->trans('Qty').'</td>';
|
||||
print '<td colspan="3"></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
@ -2432,6 +2473,9 @@ else
|
||||
print '<input type="text" min="0" class="right maxwidth50" name="qty" value="'.dol_escape_htmltag($qty?$qty:1).'">'; // We must be able to enter decimal qty
|
||||
print '</td>';
|
||||
|
||||
// Picture
|
||||
print '<td></td>';
|
||||
|
||||
if ($action != 'editline')
|
||||
{
|
||||
print '<td class="right"></td>';
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user