Work on merge tab photos and attached files

This commit is contained in:
Laurent Destailleur 2015-06-19 00:52:58 +02:00
parent d8f86708b1
commit b5cc7ae1c8
3 changed files with 63 additions and 45 deletions

View File

@ -840,7 +840,12 @@ class FormFile
$fileinfo = pathinfo($file['name']); $fileinfo = pathinfo($file['name']);
print '<td align="center">'; print '<td align="center">';
$minifile=$fileinfo['filename'].'_mini.'.strtolower($fileinfo['extension']); // Thumbs are created with filename in lower case $minifile=$fileinfo['filename'].'_mini.'.strtolower($fileinfo['extension']); // Thumbs are created with filename in lower case
if (image_format_supported($file['name']) > 0) print '<img border="0" height="'.$maxheightmini.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($relativepath.'thumbs/'.$minifile).'" title="">'; if (image_format_supported($file['name']) > 0)
{
print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])).'" class="aphoto" target="_blank">';
print '<img border="0" height="'.$maxheightmini.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($relativepath.'thumbs/'.$minifile).'" title="">';
print '</a>';
}
else print '&nbsp;'; else print '&nbsp;';
print '</td>'; print '</td>';
} }
@ -848,6 +853,15 @@ class FormFile
// ($param must start with &) // ($param must start with &)
print '<td align="right">'; print '<td align="right">';
if ($useinecm) print '<a href="'.DOL_URL_ROOT.'/ecm/docfile.php?urlfile='.urlencode($file['name']).$param.'" class="editfilelink" rel="'.urlencode($file['name']).'">'.img_view().'</a> &nbsp; '; if ($useinecm) print '<a href="'.DOL_URL_ROOT.'/ecm/docfile.php?urlfile='.urlencode($file['name']).$param.'" class="editfilelink" rel="'.urlencode($file['name']).'">'.img_view().'</a> &nbsp; ';
else
{
if (image_format_supported($file['name']) > 0)
{
// TODO Add link from photo page here
}
}
if ($permtodelete) if ($permtodelete)
{ {
/* /*

View File

@ -3552,7 +3552,8 @@ class Product extends CommonObject
// Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine
$alt=$langs->transnoentitiesnoconv('File').': '.$pdir.$photo; $alt=$langs->transnoentitiesnoconv('File').': '.$pdir.$photo;
$alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; $alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height'];
if ($photo_vignette && $imgarray['height'] > $maxHeight) { if ($photo_vignette && $imgarray['height'] > $maxHeight)
{
$return.= '<!-- Show thumb -->'; $return.= '<!-- Show thumb -->';
$return.= '<img class="photo photowithmargin" border="0" '.($conf->dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; $return.= '<img class="photo photowithmargin" border="0" '.($conf->dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">';
} }

View File

@ -103,7 +103,7 @@ if (empty($reshook))
} }
} }
} }
// Action sending file // Action sending file
include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_pre_headers.tpl.php'; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_pre_headers.tpl.php';
@ -112,18 +112,18 @@ if (empty($reshook))
if ($action=='filemerge') { if ($action=='filemerge') {
$is_refresh = GETPOST('refresh'); $is_refresh = GETPOST('refresh');
if (empty($is_refresh)) { if (empty($is_refresh)) {
$filetomerge_file_array = GETPOST('filetoadd'); $filetomerge_file_array = GETPOST('filetoadd');
$filetomerge_file_array = GETPOST('filetoadd'); $filetomerge_file_array = GETPOST('filetoadd');
if ($conf->global->MAIN_MULTILANGS) { if ($conf->global->MAIN_MULTILANGS) {
$lang_id = GETPOST('lang_id'); $lang_id = GETPOST('lang_id');
} }
// Delete all file already associated // Delete all file already associated
$filetomerge = new Propalmergepdfproduct($db); $filetomerge = new Propalmergepdfproduct($db);
if ($conf->global->MAIN_MULTILANGS) { if ($conf->global->MAIN_MULTILANGS) {
$result=$filetomerge->delete_by_product($user, $object->id, $lang_id); $result=$filetomerge->delete_by_product($user, $object->id, $lang_id);
} else { } else {
@ -132,17 +132,17 @@ if ($action=='filemerge') {
if ($result<0) { if ($result<0) {
setEventMessage($filetomerge->error,'errors'); setEventMessage($filetomerge->error,'errors');
} }
// for each file checked add it to the product // for each file checked add it to the product
if (is_array($filetomerge_file_array)) { if (is_array($filetomerge_file_array)) {
foreach ( $filetomerge_file_array as $filetomerge_file ) { foreach ( $filetomerge_file_array as $filetomerge_file ) {
$filetomerge->fk_product = $object->id; $filetomerge->fk_product = $object->id;
$filetomerge->file_name = $filetomerge_file; $filetomerge->file_name = $filetomerge_file;
if ($conf->global->MAIN_MULTILANGS) { if ($conf->global->MAIN_MULTILANGS) {
$filetomerge->lang = $lang_id; $filetomerge->lang = $lang_id;
} }
$result=$filetomerge->create($user); $result=$filetomerge->create($user);
if ($result<0) { if ($result<0) {
setEventMessage($filetomerge->error,'errors'); setEventMessage($filetomerge->error,'errors');
@ -206,31 +206,31 @@ if ($object->id)
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
$modulepart = 'produit'; $modulepart = 'produit';
$permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); $permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer));
$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))
{ {
$filetomerge = new Propalmergepdfproduct($db); $filetomerge = new Propalmergepdfproduct($db);
if ($conf->global->MAIN_MULTILANGS) { if ($conf->global->MAIN_MULTILANGS) {
$lang_id = GETPOST('lang_id'); $lang_id = GETPOST('lang_id');
$result = $filetomerge->fetch_by_product($object->id, $lang_id); $result = $filetomerge->fetch_by_product($object->id, $lang_id);
} else { } else {
$result = $filetomerge->fetch_by_product($object->id); $result = $filetomerge->fetch_by_product($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);
// 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) {
print '<br>'; print '<br>';
@ -238,31 +238,31 @@ if ($object->id)
if (count($filetomerge->lines) > 0) { if (count($filetomerge->lines) > 0) {
print $langs->trans('PropalMergePdfProductActualFile'); print $langs->trans('PropalMergePdfProductActualFile');
} }
print '<form name="filemerge" action="' . DOL_URL_ROOT . '/product/document.php?id=' . $object->id . '" method="post">'; print '<form name="filemerge" action="' . DOL_URL_ROOT . '/product/document.php?id=' . $object->id . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="filemerge">'; print '<input type="hidden" name="action" value="filemerge">';
if (count($filetomerge->lines) == 0) { if (count($filetomerge->lines) == 0) {
print $langs->trans('PropalMergePdfProductChooseFile'); print $langs->trans('PropalMergePdfProductChooseFile');
} }
print '<table class="noborder">'; print '<table class="noborder">';
// Get language // Get language
if ($conf->global->MAIN_MULTILANGS) { if ($conf->global->MAIN_MULTILANGS) {
$langs->load("languages"); $langs->load("languages");
print '<tr class="liste_titre"><td>'; print '<tr class="liste_titre"><td>';
$delauft_lang = (empty($lang_id)) ? $langs->getDefaultLang() : $lang_id; $delauft_lang = (empty($lang_id)) ? $langs->getDefaultLang() : $lang_id;
$langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12);
print '<select class="flat" id="lang_id" name="lang_id">'; print '<select class="flat" id="lang_id" name="lang_id">';
asort($langs_available); asort($langs_available);
$uncompletelanguages = array ( $uncompletelanguages = array (
'da_DA', 'da_DA',
'fi_FI', 'fi_FI',
@ -275,8 +275,10 @@ if ($object->id)
'tr_TR', 'tr_TR',
'zh_CN' 'zh_CN'
); );
foreach ( $langs_available as $key => $value ) { foreach ( $langs_available as $key => $value )
if ($showwarning && in_array($key, $uncompletelanguages)) { {
if ($showwarning && in_array($key, $uncompletelanguages))
{
// $value.=' - '.$langs->trans("TranslationUncomplete",$key); // $value.=' - '.$langs->trans("TranslationUncomplete",$key);
} }
if ($filter && is_array($filter)) { if ($filter && is_array($filter)) {
@ -290,28 +292,28 @@ if ($object->id)
} }
} }
print '</select>'; print '</select>';
if ($conf->global->MAIN_MULTILANGS) { if ($conf->global->MAIN_MULTILANGS) {
print '<input type="submit" class="button" name="refresh" value="' . $langs->trans('Refresh') . '">'; print '<input type="submit" class="button" name="refresh" value="' . $langs->trans('Refresh') . '">';
} }
print '</td></tr>'; print '</td></tr>';
} }
$style = 'impair'; $style = 'impair';
foreach ( $filearray as $filetoadd ) { foreach ($filearray as $filetoadd)
{
if ($ext = pathinfo($filetoadd['name'], PATHINFO_EXTENSION) == 'pdf') { if ($ext = pathinfo($filetoadd['name'], PATHINFO_EXTENSION) == 'pdf')
{
if ($style == 'pair') { if ($style == 'pair') {
$style = 'impair'; $style = 'impair';
} else { } else {
$style = 'pair'; $style = 'pair';
} }
$checked = ''; $checked = '';
$filename = $filetoadd['name']; $filename = $filetoadd['name'];
if ($conf->global->MAIN_MULTILANGS) { if ($conf->global->MAIN_MULTILANGS) {
if (array_key_exists($filetoadd['name'] . '_' . $delauft_lang, $filetomerge->lines)) { if (array_key_exists($filetoadd['name'] . '_' . $delauft_lang, $filetomerge->lines)) {
$filename = $filetoadd['name'] . ' - ' . $langs->trans('Language_' . $delauft_lang); $filename = $filetoadd['name'] . ' - ' . $langs->trans('Language_' . $delauft_lang);
@ -322,23 +324,24 @@ if ($object->id)
$checked = ' checked '; $checked = ' checked ';
} }
} }
print '<tr class="' . $style . '"><td>'; print '<tr class="' . $style . '"><td>';
print '<input type="checkbox" ' . $checked . ' name="filetoadd[]" id="filetoadd" value="' . $filetoadd['name'] . '">' . $filename . '</input>'; print '<input type="checkbox" ' . $checked . ' name="filetoadd[]" id="filetoadd" value="' . $filetoadd['name'] . '">' . $filename . '</input>';
print '</td></tr>'; print '</td></tr>';
} }
} }
print '<tr><td>'; print '<tr><td>';
print '<input type="submit" class="button" name="save" value="' . $langs->trans('Save') . '">'; print '<input type="submit" class="button" name="save" value="' . $langs->trans('Save') . '">';
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '</form>'; print '</form>';
} }
} }
} }
else else
{ {