From 700c69e127390cf31bafe053fc5e119ad5a3768a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Mar 2018 11:46:35 +0100 Subject: [PATCH] NEW Can set position of images in module tickets Mutualize code of method show_photo --- htdocs/core/ajax/row.php | 2 +- htdocs/core/class/commonobject.class.php | 240 +++++++++++++++++- htdocs/core/lib/functions.lib.php | 4 +- .../tpl/document_actions_post_headers.tpl.php | 4 +- htdocs/expedition/shipment.php | 2 +- htdocs/langs/en_US/main.lang | 3 +- htdocs/langs/en_US/ticketsup.lang | 1 - .../template/myobject_document.php | 4 +- .../product/actions_card_product.class.php | 2 +- .../service/actions_card_service.class.php | 2 +- htdocs/product/class/product.class.php | 230 +---------------- htdocs/product/document.php | 11 +- htdocs/ticketsup/card.php | 6 +- .../class/actions_ticketsup.class.php | 2 +- htdocs/ticketsup/class/ticketsup.class.php | 182 +------------ htdocs/ticketsup/contact.php | 6 +- htdocs/ticketsup/document.php | 51 ++-- htdocs/ticketsup/history.php | 6 +- htdocs/ticketsup/index.php | 5 +- htdocs/ticketsup/list.php | 11 +- htdocs/ticketsup/new.php | 5 +- 21 files changed, 302 insertions(+), 477 deletions(-) diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 71a5a0aac88..4fe31ee7ae8 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -63,7 +63,7 @@ if ((isset($_POST['roworder']) && ! empty($_POST['roworder'])) && (isset($_POST[ $row->table_element_line = $table_element_line; $row->fk_element = $fk_element; $row->id = $element_id; - $row->line_ajaxorder($newrowordertab); // This update field rank or position in table table_element_line + $row->line_ajaxorder($newrowordertab); // This update field rank or position in table row->table_element_line // Reorder line to have position of children lines sharing same counter than parent lines // This should be useless because there is no need to have children sharing same counter than parent, but well, it's cleaner into database. diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8ec7fa36b73..d80c67a8aeb 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6004,7 +6004,7 @@ abstract class CommonObject { $labeltoshow = ''.$labeltoshow.''; } - + if (empty($onetrtd)) $out .= ''; else $out .= ''; @@ -6194,6 +6194,243 @@ abstract class CommonObject return $buyPrice; } + /** + * Show photos of an object (nbmax maximum), into several columns + * + * @param string $modulepart 'product', 'ticketsup', ... + * @param string $sdir Directory to scan (full absolute path) + * @param int $size 0=original size, 1='small' use thumbnail if possible + * @param int $nbmax Nombre maximum de photos (0=pas de max) + * @param int $nbbyrow Number of image per line or -1 to use div. Used only if size=1. + * @param int $showfilename 1=Show filename + * @param int $showaction 1=Show icon with action links (resize, delete) + * @param int $maxHeight Max height of original image when size='small' (so we can use original even if small requested). If 0, always use 'small' thumb image. + * @param int $maxWidth Max width of original image when size='small' + * @param int $nolink Do not add a href link to view enlarged imaged into a new tab + * @param int $notitle Do not add title tag on image + * @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead) + * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto + */ + function show_photos($modulepart, $sdir, $size=0, $nbmax=0, $nbbyrow=5, $showfilename=0, $showaction=0, $maxHeight=120, $maxWidth=160, $nolink=0, $notitle=0, $usesharelink=0) + { + global $conf,$user,$langs; + + include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; + include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; + + $sortfield='position_name'; + $sortorder='asc'; + + $dir = $sdir . '/'; + $pdir = '/'; + if ($modulepart == 'ticketsup') + { + $dir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->track_id.'/'; + $pdir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->track_id.'/'; + } + else + { + $dir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->ref.'/'; + $pdir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->ref.'/'; + } + + // For backward compatibility + if ($modulepart == 'product' && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { + $dir = $sdir . '/'. get_exdir($this->id,2,0,0,$this,$modulepart) . $this->id ."/photos/"; + $pdir = '/' . get_exdir($this->id,2,0,0,$this,$modulepart) . $this->id ."/photos/"; + } + + // Defined relative dir to DOL_DATA_ROOT + $relativedir = ''; + if ($dir) + { + $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir); + $relativedir = preg_replace('/^[\\/]/','',$relativedir); + $relativedir = preg_replace('/[\\/]$/','',$relativedir); + } + + $dirthumb = $dir.'thumbs/'; + $pdirthumb = $pdir.'thumbs/'; + + $return =''."\n"; + $nbphoto=0; + + $filearray=dol_dir_list($dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + + /*if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs + { + $filearrayold=dol_dir_list($dirold,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $filearray=array_merge($filearray, $filearrayold); + }*/ + + completeFileArrayWithDatabaseInfo($filearray, $relativedir); + + if (count($filearray)) + { + if ($sortfield && $sortorder) + { + $filearray=dol_sort_array($filearray, $sortfield, $sortorder); + } + + foreach($filearray as $key => $val) + { + $photo=''; + $file = $val['name']; + + //if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory + + //if (dol_is_file($dir.$file) && image_format_supported($file) >= 0) + if (image_format_supported($file) >= 0) + { + $nbphoto++; + $photo = $file; + $viewfilename = $file; + + if ($size == 1 || $size == 'small') { // Format vignette + + // Find name of thumb file + $photo_vignette=basename(getImageFileNameForSize($dir.$file, '_small')); + if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette=''; + + // Get filesize of original file + $imgarray=dol_getImageSize($dir.$photo); + + if ($nbbyrow > 0) + { + if ($nbphoto == 1) $return.= ''; + + if ($nbphoto % $nbbyrow == 1) $return.= ''; + $return.= ''; + if (($nbphoto % $nbbyrow) == 0) $return.= ''; + } + else if ($nbbyrow < 0) $return.=''; + } + + if (empty($size)) { // Format origine + $return.= ''; + + if ($showfilename) $return.= '
'.$viewfilename; + if ($showaction) + { + // Special case for product + if ($modulepart == 'product' && ($user->rights->produit->creer || $user->rights->service->creer)) + { + // Link to resize + $return.= ''.img_picto($langs->trans("Resize"), 'resize', '').'   '; + + // Link to delete + $return.= ''; + $return.= img_delete().''; + } + } + } + + // On continue ou on arrete de boucler ? + if ($nbmax && $nbphoto >= $nbmax) break; + } + } + + if ($size==1 || $size=='small') + { + if ($nbbyrow > 0) + { + // Ferme tableau + while ($nbphoto % $nbbyrow) + { + $return.= ''; + $nbphoto++; + } + + if ($nbphoto) $return.= '
'; + } + else if ($nbbyrow < 0) $return .= '
'; + + $return.= "\n"; + + $relativefile=preg_replace('/^\//', '', $pdir.$photo); + if (empty($nolink)) + { + $urladvanced=getAdvancedPreviewUrl($modulepart, $relativefile, 0, 'entity='.$this->entity); + if ($urladvanced) $return.=''; + else $return.= ''; + } + + // Show image (width height=$maxHeight) + // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine + $alt=$langs->transnoentitiesnoconv('File').': '.$relativefile; + $alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; + if ($notitle) $alt=''; + + if ($usesharelink) + { + if ($val['share']) + { + if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) + { + $return.= ''; + $return.= ''; + } + else { + $return.= ''; + $return.= ''; + } + } + else + { + $return.= ''; + $return.= ''; + } + } + else + { + if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) + { + $return.= ''; + $return.= ''; + } + else { + $return.= ''; + $return.= ''; + } + } + + if (empty($nolink)) $return.= ''; + $return.="\n"; + + if ($showfilename) $return.= '
'.$viewfilename; + if ($showaction) + { + $return.= '
'; + // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites + if ($photo_vignette && (image_format_supported($photo) > 0) && ($this->imgWidth > $maxWidth || $this->imgHeight > $maxHeight)) + { + $return.= ''.img_picto($langs->trans('GenerateThumb'),'refresh').'  '; + } + // Special cas for product + if ($modulepart == 'product' && ($user->rights->produit->creer || $user->rights->service->creer)) + { + // Link to resize + $return.= ''.img_picto($langs->trans("Resize"), 'resize', '').'   '; + + // Link to delete + $return.= ''; + $return.= img_delete().''; + } + } + $return.= "\n"; + + if ($nbbyrow > 0) + { + $return.= '
 
'; + } + } + } + + $this->nbphoto = $nbphoto; + + return $return; + } /** @@ -6228,7 +6465,6 @@ abstract class CommonObject else return false; } - /** * Function test if type is date * diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 746f6c55f13..6d57f7c34c3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1327,7 +1327,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $showimage=$object->is_photo_available($conf->product->multidir_output[$object->entity]); $maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5); if ($conf->browser->phone) $maxvisiblephotos=1; - if ($showimage) $morehtmlleft.='
'.$object->show_photos($conf->product->multidir_output[$object->entity],'small',$maxvisiblephotos,0,0,0,$width,0).'
'; + if ($showimage) $morehtmlleft.='
'.$object->show_photos('product', $conf->product->multidir_output[$object->entity],'small',$maxvisiblephotos,0,0,0,$width,0).'
'; else { if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) { @@ -1346,7 +1346,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $showimage=$object->is_photo_available($conf->ticketsup->dir_output.'/'.$object->track_id); $maxvisiblephotos=(isset($conf->global->TICKETSUP_MAX_VISIBLE_PHOTO)?$conf->global->TICKETSUP_MAX_VISIBLE_PHOTO:2); if ($conf->browser->phone) $maxvisiblephotos=1; - if ($showimage) $morehtmlleft.='
'.$object->show_photos($conf->ticketsup->dir_output,'small',$maxvisiblephotos,0,0,0,$width,0).'
'; + if ($showimage) $morehtmlleft.='
'.$object->show_photos('ticketsup', $conf->ticketsup->dir_output,'small',$maxvisiblephotos,0,0,0,$width,0).'
'; else { if (!empty($conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) { diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php index 8b24605607d..65312110cc9 100644 --- a/htdocs/core/tpl/document_actions_post_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php @@ -86,8 +86,10 @@ $formfile->form_attach_new_file( $savingdocmask ); +// Drag and drop for up and down allowed on product, thirdparty, ... +// The drag and drop call the page core/ajax/row.php $disablemove=1; -if (in_array($modulepart, array('product', 'produit', 'societe', 'user'))) $disablemove=0; // Drag and drop for up and down allowed on product, thirdparty, ... +if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticketsup'))) $disablemove=0; // List of document $formfile->list_of_documents( diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index a9bb706c4d8..e3218d5f578 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -705,7 +705,7 @@ if ($id > 0 || ! empty($ref)) $text=$product_static->getNomUrl(1); $text.= ' - '.$label; $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'
'; - $description.= $product_static->show_photos($conf->product->multidir_output[$product_static->entity],1,1,0,0,0,80); + $description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80); print $form->textwithtooltip($text,$description,3,'','',$i); // Show range diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index edcdb4ef791..a8bb2ad50fd 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -938,4 +938,5 @@ Annual=Annual Local=Local Remote=Remote LocalAndRemote=Local and Remote -KeyboardShortcut=Keyboard shortcut \ No newline at end of file +KeyboardShortcut=Keyboard shortcut +AssignedTo=Assigned to \ No newline at end of file diff --git a/htdocs/langs/en_US/ticketsup.lang b/htdocs/langs/en_US/ticketsup.lang index cabf1c39ec3..cd79202c7fa 100644 --- a/htdocs/langs/en_US/ticketsup.lang +++ b/htdocs/langs/en_US/ticketsup.lang @@ -163,7 +163,6 @@ SeeTicket=See ticket TicketMarkedAsRead=Ticket has been marked as read TicketReadOn=Read on TicketCloseOn=Clotured on -UserAssignedTo=User assigned MarkAsRead=Mark ticket as read TicketMarkedAsReadButLogActionNotSaved=Ticket marked as closed but no action saved TicketHistory=Ticket history diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 3462cde52d2..3d1580e1e3b 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -45,7 +45,7 @@ dol_include_once('/mymodule/class/myobject.class.php'); dol_include_once('/mymodule/lib/myobject.lib.php'); // Load traductions files requiredby by page -$langs->loadLangs(array("mymodule@mymodule","companies","other")); +$langs->loadLangs(array("mymodule@mymodule","companies","other","mails")); $action=GETPOST('action','aZ09'); @@ -68,6 +68,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; +//if (! $sortfield) $sortfield="position_name"; // Initialize technical objects $object=new MyObject($db); @@ -108,7 +109,6 @@ if ($object->id) /* * Show tabs */ - if (! empty($conf->notification->enabled)) $langs->load("mails"); $head = myobjectPrepareHead($object); dol_fiche_head($head, 'document', $langs->trans("MyObject"), -1, 'myobject@mymodule'); diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index 09508f5c2cb..d7b91abe246 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -216,7 +216,7 @@ class ActionsCardProduct $this->tpl['nblignes'] = 4; if ($this->object->is_photo_available($conf->product->multidir_output[$this->object->entity])) { - $this->tpl['photos'] = $this->object->show_photos($conf->product->multidir_output[$this->object->entity],1,1,0,0,0,80); + $this->tpl['photos'] = $this->object->show_photos('product', $conf->product->multidir_output[$this->object->entity],1,1,0,0,0,80); } // Nature diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index 171e3960299..ba43898724e 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -211,7 +211,7 @@ class ActionsCardService $this->tpl['nblignes'] = 4; if ($this->object->is_photo_available($conf->service->multidir_output[$this->object->entity])) { - $this->tpl['photos'] = $this->object->show_photos($conf->service->multidir_output[$this->object->entity],1,1,0,0,0,80); + $this->tpl['photos'] = $this->object->show_photos('product', $conf->service->multidir_output[$this->object->entity],1,1,0,0,0,80); } // Duration diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f4722b9158e..15651ca9130 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3559,7 +3559,7 @@ class Product extends CommonObject } if (! empty($this->entity)) { - $tmpphoto = $this->show_photos($conf->product->multidir_output[$this->entity],1,1,0,0,0,80); + $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); if ($this->nbphoto > 0) $label .= '
' . $tmpphoto; } @@ -4133,234 +4133,6 @@ class Product extends CommonObject } - /** - * Show photos of a product (nbmax maximum), into several columns - * TODO Move this into html.formproduct.class.php - * - * @param string $sdir Directory to scan (full absolute path) - * @param int $size 0=original size, 1='small' use thumbnail if possible - * @param int $nbmax Nombre maximum de photos (0=pas de max) - * @param int $nbbyrow Number of image per line or -1 to use div. Used only if size=1. - * @param int $showfilename 1=Show filename - * @param int $showaction 1=Show icon with action links (resize, delete) - * @param int $maxHeight Max height of original image when size='small' (so we can use original even if small requested). If 0, always use 'small' thumb image. - * @param int $maxWidth Max width of original image when size='small' - * @param int $nolink Do not add a href link to view enlarged imaged into a new tab - * @param int $notitle Do not add title tag on image - * @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead) - * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto - */ - function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxHeight=120,$maxWidth=160,$nolink=0,$notitle=0,$usesharelink=0) - { - global $conf,$user,$langs; - - include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; - include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; - - $sortfield='position_name'; - $sortorder='asc'; - - $dir = $sdir . '/'; - $pdir = '/'; - $dir .= get_exdir(0,0,0,0,$this,'product').$this->ref.'/'; - $pdir .= get_exdir(0,0,0,0,$this,'product').$this->ref.'/'; - - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) - { - $dir = $sdir . '/'. get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; - $pdir = '/' . get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; - } - - // Defined relative dir to DOL_DATA_ROOT - $relativedir = ''; - if ($dir) - { - $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir); - $relativedir = preg_replace('/^[\\/]/','',$relativedir); - $relativedir = preg_replace('/[\\/]$/','',$relativedir); - } - - $dirthumb = $dir.'thumbs/'; - $pdirthumb = $pdir.'thumbs/'; - - $return =''."\n"; - $nbphoto=0; - - $filearray=dol_dir_list($dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); - - /*if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs - { - $filearrayold=dol_dir_list($dirold,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); - $filearray=array_merge($filearray, $filearrayold); - }*/ - - completeFileArrayWithDatabaseInfo($filearray, $relativedir); - - if (count($filearray)) - { - if ($sortfield && $sortorder) - { - $filearray=dol_sort_array($filearray, $sortfield, $sortorder); - } - - foreach($filearray as $key => $val) - { - $photo=''; - $file = $val['name']; - - //if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory - - //if (dol_is_file($dir.$file) && image_format_supported($file) >= 0) - if (image_format_supported($file) >= 0) - { - $nbphoto++; - $photo = $file; - $viewfilename = $file; - - if ($size == 1 || $size == 'small') { // Format vignette - - // Find name of thumb file - $photo_vignette=basename(getImageFileNameForSize($dir.$file, '_small')); - if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette=''; - - // Get filesize of original file - $imgarray=dol_getImageSize($dir.$photo); - - if ($nbbyrow > 0) - { - if ($nbphoto == 1) $return.= ''; - - if ($nbphoto % $nbbyrow == 1) $return.= ''; - $return.= ''; - if (($nbphoto % $nbbyrow) == 0) $return.= ''; - } - else if ($nbbyrow < 0) $return.=''; - } - - if (empty($size)) { // Format origine - $return.= ''; - - if ($showfilename) $return.= '
'.$viewfilename; - if ($showaction) - { - if ($user->rights->produit->creer || $user->rights->service->creer) - { - // Link to resize - $return.= ''.img_picto($langs->trans("Resize"), 'resize', '').'   '; - - // Link to delete - $return.= ''; - $return.= img_delete().''; - } - } - } - - // On continue ou on arrete de boucler ? - if ($nbmax && $nbphoto >= $nbmax) break; - } - } - - if ($size==1 || $size=='small') - { - if ($nbbyrow > 0) - { - // Ferme tableau - while ($nbphoto % $nbbyrow) - { - $return.= ''; - $nbphoto++; - } - - if ($nbphoto) $return.= '
'; - } - else if ($nbbyrow < 0) $return .= '
'; - - $return.= "\n"; - - $relativefile=preg_replace('/^\//', '', $pdir.$photo); - if (empty($nolink)) - { - $urladvanced=getAdvancedPreviewUrl('product', $relativefile, 0, 'entity='.$this->entity); - if ($urladvanced) $return.=''; - else $return.= ''; - } - - // Show image (width height=$maxHeight) - // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine - $alt=$langs->transnoentitiesnoconv('File').': '.$relativefile; - $alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; - if ($notitle) $alt=''; - - if ($usesharelink) - { - if ($val['share']) - { - if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) - { - $return.= ''; - $return.= ''; - } - else { - $return.= ''; - $return.= ''; - } - } - else - { - $return.= ''; - $return.= ''; - } - } - else - { - if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) - { - $return.= ''; - $return.= ''; - } - else { - $return.= ''; - $return.= ''; - } - } - - if (empty($nolink)) $return.= ''; - $return.="\n"; - - if ($showfilename) $return.= '
'.$viewfilename; - if ($showaction) - { - $return.= '
'; - // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites - if ($photo_vignette && (image_format_supported($photo) > 0) && ($this->imgWidth > $maxWidth || $this->imgHeight > $maxHeight)) - { - $return.= ''.img_picto($langs->trans('GenerateThumb'),'refresh').'  '; - } - if ($user->rights->produit->creer || $user->rights->service->creer) - { - // Link to resize - $return.= ''.img_picto($langs->trans("Resize"), 'resize', '').'   '; - - // Link to delete - $return.= ''; - $return.= img_delete().''; - } - } - $return.= "\n"; - - if ($nbbyrow > 0) - { - $return.= '
 
'; - } - } - } - - $this->nbphoto = $nbphoto; - - return $return; - } - - /** * Retourne tableau de toutes les photos du produit * diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 72312aa4643..93267538936 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -40,10 +40,10 @@ if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) $langs->load("other"); $langs->load("products"); -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action=GETPOST('action','alpha'); -$confirm=GETPOST('confirm','alpha'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action','alpha'); +$confirm= GETPOST('confirm','alpha'); // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); @@ -93,7 +93,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - //Delete line if product propal merge is linked to a file + // Delete line if product propal merge is linked to a file if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) { if ($action == 'confirm_deletefile' && $confirm == 'yes') @@ -346,7 +346,6 @@ if ($object->id) print ''; } } - } else { diff --git a/htdocs/ticketsup/card.php b/htdocs/ticketsup/card.php index 556ab3da79d..bb6b5804578 100644 --- a/htdocs/ticketsup/card.php +++ b/htdocs/ticketsup/card.php @@ -17,8 +17,8 @@ */ /** - * Card of ticket - * @ingroup ticketsup + * \file htdocs/ticketsup/card.php + * \ingroup ticketsup */ require '../main.inc.php'; @@ -343,7 +343,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print ''; // User assigned - print '' . $langs->trans("UserAssignedTo") . ''; + print '' . $langs->trans("AssignedTo") . ''; if ($object->fk_user_assign > 0) { $userstat->fetch($object->fk_user_assign); print $userstat->getNomUrl(1); diff --git a/htdocs/ticketsup/class/actions_ticketsup.class.php b/htdocs/ticketsup/class/actions_ticketsup.class.php index 9a978e2e066..035b43ea1c6 100644 --- a/htdocs/ticketsup/class/actions_ticketsup.class.php +++ b/htdocs/ticketsup/class/actions_ticketsup.class.php @@ -335,7 +335,7 @@ class ActionsTicketsup /*if (! ($usertoassign > 0)) { $error++; - array_push($this->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("UserAssignedTo"))); + array_push($this->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("AssignedTo"))); $action = 'view'; }*/ diff --git a/htdocs/ticketsup/class/ticketsup.class.php b/htdocs/ticketsup/class/ticketsup.class.php index ced9ad3ff73..e201f1ab5bd 100644 --- a/htdocs/ticketsup/class/ticketsup.class.php +++ b/htdocs/ticketsup/class/ticketsup.class.php @@ -42,6 +42,10 @@ class Ticketsup extends CommonObject * @var string Name of table without prefix where object is stored */ public $table_element = 'ticketsup'; + /** + * @var string Name of field for link to tickets + */ + public $fk_element='fk_ticket'; /** * @var int Does ticketsupcore support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ @@ -178,7 +182,7 @@ class Ticketsup extends CommonObject 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty"), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToProject"), 'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>510, 'notnull'=>1), - 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AuthorAssign', 'visible'=>1, 'enabled'=>1, 'position'=>510, 'notnull'=>1), + 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>510, 'notnull'=>1), 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>12, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>60, 'notnull'=>-1,), 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-2, 'enabled'=>1, 'position'=>40, 'notnull'=>1), @@ -2469,182 +2473,6 @@ class Ticketsup extends CommonObject return false; } - /** - * Show photos of a product (nbmax maximum), into several columns - * TODO Move this into html.formproduct.class.php - * - * @param string $sdir Directory to scan - * @param int $size 0=original size, 1='small' use thumbnail if possible - * @param int $nbmax Nombre maximum de photos (0=pas de max) - * @param int $nbbyrow Number of image per line or -1 to use div. Used only if size=1. - * @param int $showfilename 1=Show filename - * @param int $showaction 1=Show icon with action links (resize, delete) - * @param int $maxHeight Max height of original image when size='small' (so we can use original even if small requested). If 0, always use 'small' thumb image. - * @param int $maxWidth Max width of original image when size='small' - * @param int $nolink Do not add a href link to view enlarged imaged into a new tab - * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto - */ - function show_photos($sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0) - { - global $conf, $user, $langs; - - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; - - $dir = $sdir . '/'; - $pdir = '/'; - $dir .= get_exdir(0, 0, 0, 0, $this, 'ticketsup') . $this->track_id . '/'; - $pdir .= get_exdir(0, 0, 0, 0, $this, 'ticketsup') . $this->track_id . '/'; - - $dirthumb = $dir . 'thumbs/'; - $pdirthumb = $pdir . 'thumbs/'; - - $return = '' . "\n"; - $nbphoto = 0; - - $dir_osencoded = dol_osencode($dir); - if (file_exists($dir_osencoded)) { - $handle = opendir($dir_osencoded); - if (is_resource($handle)) { - while (($file = readdir($handle)) != false) { - $photo = ''; - - if (!utf8_check($file)) { - $file = utf8_encode($file); - } - // To be sure file is stored in UTF8 in memory - if (dol_is_file($dir . $file) && preg_match('/(' . $this->regeximgext . ')$/i', $dir . $file)) { - $nbphoto++; - $photo = $file; - $viewfilename = $file; - - if ($size == 1 || $size == 'small') { // Format vignette - // Find name of thumb file - $photo_vignette = basename(getImageFileNameForSize($dir . $file, '_small', '.png')); - if (!dol_is_file($dirthumb . $photo_vignette)) { - $photo_vignette = ''; - } - - // Get filesize of original file - $imgarray = dol_getImageSize($dir . $photo); - - if ($nbbyrow > 0) { - if ($nbphoto == 1) { - $return .= ''; - } - - if ($nbphoto % $nbbyrow == 1) { - $return .= ''; - } - - $return .= ''; - if (($nbphoto % $nbbyrow) == 0) { - $return .= ''; - } - } elseif ($nbbyrow < 0) { - $return .= ''; - } - } - - if (empty($size)) { // Format origine - $return .= ''; - - if ($showfilename) { - $return .= '
' . $viewfilename; - } - - if ($showaction) { - if ($user->rights->produit->creer || $user->rights->service->creer) { - // Link to resize - $return .= '' . img_picto($langs->trans("Resize"), 'resize', '') . '   '; - - // Link to delete - $return .= ''; - $return .= img_delete() . ''; - } - } - } - - // On continue ou on arrete de boucler ? - if ($nbmax && $nbphoto >= $nbmax) { - break; - } - } - } - } - - if ($size == 1 || $size == 'small') { - if ($nbbyrow > 0) { - // Ferme tableau - while ($nbphoto % $nbbyrow) { - $return .= ''; - $nbphoto++; - } - - if ($nbphoto) { - $return .= '
'; - } elseif ($nbbyrow < 0) { - $return .= '
'; - } - - $return .= "\n"; - if (empty($nolink)) { - $return .= ''; - } - - // Show image (width height=$maxHeight) - // 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('Size') . ': ' . $imgarray['width'] . 'x' . $imgarray['height']; - - if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) { - $return .= ''; - $return .= 'dol_use_jmobile ? 'max-height' : 'height') . '="' . $maxHeight . '" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=ticketsup&entity=' . $this->entity . '&file=' . urlencode($pdirthumb . $photo_vignette) . '" title="' . dol_escape_htmltag($alt) . '">'; - } else { - $return .= ''; - $return .= 'dol_use_jmobile ? 'max-height' : 'height') . '="' . $maxHeight . '" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=ticketsup&entity=' . $this->entity . '&file=' . urlencode($pdir . $photo) . '" title="' . dol_escape_htmltag($alt) . '">'; - } - - if (empty($nolink)) { - $return .= ''; - } - - $return .= "\n"; - - if ($showfilename) { - $return .= '
' . $viewfilename; - } - - if ($showaction) { - $return .= '
'; - // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites - if ($photo_vignette && preg_match('/(' . $this->regeximgext . ')$/i', $photo) && ($this->imgWidth > $maxWidth || $this->imgHeight > $maxHeight)) { - $return .= '' . img_picto($langs->trans('GenerateThumb'), 'refresh') . '  '; - } - if ($user->rights->produit->creer || $user->rights->service->creer) { - // Link to resize - $return .= '' . img_picto($langs->trans("Resize"), 'resize', '') . '   '; - - // Link to delete - $return .= ''; - $return .= img_delete() . ''; - } - } - $return .= "\n"; - - if ($nbbyrow > 0) { - $return .= '
 
'; - } - } - } - - closedir($handle); - } - - $this->nbphoto = $nbphoto; - - return $return; - } } diff --git a/htdocs/ticketsup/contact.php b/htdocs/ticketsup/contact.php index 8199b6c84a5..7202cba8dd2 100644 --- a/htdocs/ticketsup/contact.php +++ b/htdocs/ticketsup/contact.php @@ -19,9 +19,9 @@ */ /** - * \file ticketsup/contact.php - * \ingroup ticketsup - * \brief Contacts of tickets + * \file htdocs/ticketsup/contact.php + * \ingroup ticketsup + * \brief Contacts of tickets */ require '../main.inc.php'; diff --git a/htdocs/ticketsup/document.php b/htdocs/ticketsup/document.php index cadb6731bfd..3ec98fe1635 100644 --- a/htdocs/ticketsup/document.php +++ b/htdocs/ticketsup/document.php @@ -20,7 +20,7 @@ */ /** - * \file /ticketsup/document.php + * \file htdocs/ticketsup/document.php * \ingroup ticketsup * \brief files linked to a ticket */ @@ -33,13 +33,13 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT . "/core/lib/company.lib.php"; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -$langs->loadLangs(array("companies","other","ticketsup")); +$langs->loadLangs(array("companies","other","ticketsup","mails")); -$action = GETPOST('action','alpha'); -$confirm = GETPOST('confirm','alpha'); -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $track_id = GETPOST('track_id', 'alpha'); -$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); // Security check if (!$user->rights->ticketsup->read) { @@ -50,18 +50,12 @@ if (!$user->rights->ticketsup->read) { $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); -if ($page == -1) { - $page = 0; -} +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "name"; -} +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="position_name"; $object = new Ticketsup($db); $result = $object->fetch($id, $ref, $track_id); @@ -97,15 +91,11 @@ $form = new Form($db); $help_url = ''; llxHeader('', $langs->trans("TicketDocumentsLinked") . ' - ' . $langs->trans("Files"), $help_url); -if ($object->id) { - /* - * Affichage onglets - */ - if (!empty($conf->notification->enabled)) { - $langs->load("mails"); - } - - $form = new Form($db); +if ($object->id) +{ + /* + * Show tabs + */ if ($socid > 0) { $object->fetch_thirdparty(); $head = societe_prepare_head($object->thirdparty); @@ -119,6 +109,7 @@ if ($object->id) { } elseif ($user->societe_id > 0) { $object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'"; } + $head = ticketsup_prepare_head($object); dol_fiche_head($head, 'tabTicketDocument', $langs->trans("Ticket"), 0, 'ticketsup'); @@ -153,16 +144,16 @@ if ($object->id) { $totalsize += $file['size']; } - // For compatibility we use track ID for directory - $object->ref = $object->track_id; + $object->ref = $object->track_id; // For compatibility we use track ID for directory $modulepart = 'ticketsup'; $permission = $user->rights->ticketsup->write; $permtoedit = $user->rights->ticketsup->write; + $param = '&id=' . $object->id; + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; - - - print "

"; -} else { +} +else +{ accessforbidden('', 0, 0); } diff --git a/htdocs/ticketsup/history.php b/htdocs/ticketsup/history.php index 4dda4c919e8..c6de1d7c3c6 100644 --- a/htdocs/ticketsup/history.php +++ b/htdocs/ticketsup/history.php @@ -16,9 +16,9 @@ */ /** - * History of ticket - * - * @package ticketsup + * \file htdocs/ticketsup/history.php + * \ingroup ticketsup + * \brief History of ticket */ require '../main.inc.php'; diff --git a/htdocs/ticketsup/index.php b/htdocs/ticketsup/index.php index cef4faa80ba..8881b8c3ad2 100644 --- a/htdocs/ticketsup/index.php +++ b/htdocs/ticketsup/index.php @@ -16,9 +16,8 @@ */ /** - * Index page for ticket module - * - * @package ticketsup + * \file htdocs/ticketsup/history.php + * \ingroup ticketsup */ require '../main.inc.php'; diff --git a/htdocs/ticketsup/list.php b/htdocs/ticketsup/list.php index 934a528763e..d4b5733ef55 100644 --- a/htdocs/ticketsup/list.php +++ b/htdocs/ticketsup/list.php @@ -1,6 +1,6 @@ - * 2016 Christophe Battarel +/* Copyright (C) 2013-2018 Jean-François FERRY + * Copyright (C) 2016 Christophe Battarel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,9 +17,8 @@ */ /** - * Tickets List - * - * @package ticketsup + * \file htdocs/ticketsup/list.php + * \ingroup ticketsup */ require '../main.inc.php'; @@ -437,7 +436,7 @@ print ''; print ''; print ''; -$buttontocreate = ''; +$buttontocreate = '' . $langs->trans('NewTicket') . ''; print_barre_liste($langs->trans('TicketList'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_ticketsup', 0, $buttontocreate, '', $limit); diff --git a/htdocs/ticketsup/new.php b/htdocs/ticketsup/new.php index 605db702c4a..0428f5286c2 100644 --- a/htdocs/ticketsup/new.php +++ b/htdocs/ticketsup/new.php @@ -17,9 +17,8 @@ */ /** - * Display form to add new ticket - * - * @package ticketsup + * \file htdocs/ticketsup/new.php + * \ingroup ticketsup */ require '../main.inc.php';