30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/categories.lib.php';
37$langs->loadlangs(array(
'categories',
'bills'));
41$label =
GETPOST(
'label',
'alpha');
42$action =
GETPOST(
'action',
'aZ09');
45if ($id ==
'' && $label ==
'') {
54$result = $object->fetch($id, $label);
60if (is_numeric($type)) {
61 $type = Categorie::$MAP_ID_TO_CODE[$type];
64$upload_dir = $conf->categorie->multidir_output[$object->entity];
70if (isset($_FILES[
'userfile']) && $_FILES[
'userfile'][
'size'] > 0 &&
GETPOST(
"sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) {
72 $file = $_FILES[
'userfile'];
73 if (is_array($file[
'name']) && count($file[
'name']) > 0) {
74 foreach ($file[
'name'] as $i => $name) {
75 if (empty($file[
'tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file[
'tmp_name'][$i])) {
76 setEventMessage($file[
'name'][$i].
' : '.$langs->trans(empty($file[
'tmp_name'][$i]) ?
'ErrorFailedToSaveFile' :
'MaxSizeForUploadedFiles'));
77 unset($file[
'name'][$i], $file[
'type'][$i], $file[
'tmp_name'][$i], $file[
'error'][$i], $file[
'size'][$i]);
82 if (!empty($file[
'tmp_name'])) {
83 $object->add_photo($upload_dir, $file);
88if ($action ==
'confirm_delete' && $_GET[
"file"] && $confirm ==
'yes' && $user->rights->categorie->creer) {
89 $object->delete_photo($upload_dir.
"/".$_GET[
"file"]);
92if ($action ==
'addthumb' && $_GET[
"file"]) {
93 $object->addThumbs($upload_dir.
"/".$_GET[
"file"]);
101llxHeader(
"",
"", $langs->trans(
"Categories"));
103$form =
new Form($db);
107 $title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
112 $backtolist = (
GETPOST(
'backtolist') ?
GETPOST(
'backtolist') : DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.urlencode($type));
113 $linkback =
'<a href="'.dol_sanitizeUrl($backtolist).
'">'.$langs->trans(
"BackToList").
'</a>';
114 $object->next_prev_filter =
'type = '.((int) $object->type);
115 $object->ref = $object->label;
116 $morehtmlref =
'<br><div class="refidno"><a href="'.DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.$type.
'">'.$langs->trans(
"Root").
'</a> >> ';
117 $ways = $object->print_all_ways(
" >> ",
'', 1);
118 foreach ($ways as $way) {
119 $morehtmlref .= $way.
"<br>\n";
121 $morehtmlref .=
'</div>';
123 dol_banner_tab($object,
'label', $linkback, ($user->socid ? 0 : 1),
'label',
'label', $morehtmlref,
'&type='.$type, 0,
'',
'', 1);
128 if ($action ==
'delete') {
129 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&type='.$type.
'&file='.$_GET[
"file"], $langs->trans(
'DeletePicture'), $langs->trans(
'ConfirmDeletePicture'),
'confirm_delete',
'', 0, 1);
134 print
'<div class="fichecenter">';
135 print
'<div class="underbanner clearboth"></div>';
136 print
'<table class="border centpercent tableforfield">';
139 print
'<tr><td class="titlefield notopnoleft">';
140 print $langs->trans(
"Description").
'</td><td>';
145 print
'<tr><td class="notopnoleft">';
146 print $langs->trans(
"Color").
'</td><td>';
147 print $formother->showColor($object->color);
160 print
'<div class="tabsAction">'.
"\n";
162 if ($action !=
'ajout_photo' && $user->rights->categorie->creer) {
163 if (!empty($conf->global->MAIN_UPLOAD_DOC)) {
164 print
'<a class="butAction hideonsmartphone" href="'.$_SERVER[
'PHP_SELF'].
'?action=ajout_photo&id='.$object->id.
'&type='.$type.
'">';
165 print $langs->trans(
"AddPhoto").
'</a>';
167 print
'<a class="butActionRefused classfortooltip hideonsmartphone" href="#">';
168 print $langs->trans(
"AddPhoto").
'</a>';
177 if ($action ==
'ajout_photo' && $user->rights->categorie->creer && !empty($conf->global->MAIN_UPLOAD_DOC)) {
180 $formfile->form_attach_new_file($_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&type='.$type, $langs->trans(
"AddPhoto"), 1,
'', $user->rights->categorie->creer, 50, $object,
'',
false,
'', 0);
184 if ($action !=
'ajout_photo') {
191 $pdir =
get_exdir($object->id, 2, 0, 0, $object,
'category').$object->id.
"/photos/";
192 $dir = $upload_dir.
'/'.$pdir;
194 $listofphoto = $object->liste_photos($dir);
196 if (is_array($listofphoto) && count($listofphoto)) {
198 print
'<table width="100%" valign="top" class="center centpercent">';
200 foreach ($listofphoto as $key => $obj) {
203 if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) {
204 print
'<tr class"center valignmiddle" border="1">';
207 print
'<td width="'.ceil(100 / $nbbyrow).
'%" class="photo">';
210 print
'<a href="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=category&entity='.$object->entity.
'&file='.urlencode($pdir.$obj[
'photo']).
'" alt="Original size" target="_blank" rel="noopener noreferrer">';
213 if ($obj[
'photo_vignette']) {
214 $filename = $obj[
'photo_vignette'];
216 $filename = $obj[
'photo'];
220 $viewfilename = $obj[
'photo'];
223 $object->get_image_size($dir.$filename);
224 $imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth;
225 $imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight;
227 print
'<img border="0" width="'.$imgWidth.
'" height="'.$imgHeight.
'" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=category&entity='.$object->entity.
'&file='.urlencode($pdir.$filename).
'">';
230 print
'<br>'.$viewfilename;
234 if (!$obj[
'photo_vignette'] && preg_match(
'/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $obj[
'photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight)) {
235 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&token='.newToken().
'&action=addthumb&type='.$type.
'&file='.urlencode($pdir.$viewfilename).
'">'.
img_picto($langs->trans(
'GenerateThumb'),
'refresh').
' </a>';
237 if ($user->rights->categorie->creer) {
238 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken().
'&type='.$type.
'&file='.urlencode($pdir.$viewfilename).
'">';
244 if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) {
250 while ($nbphoto % $nbbyrow) {
251 print
'<td width="'.ceil(100 / $nbbyrow).
'%"> </td>';
259 print
'<div class="opacitymedium">'.$langs->trans(
"NoPhotoYet").
"</div>";
263 print $langs->trans(
"ErrorUnknown");
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
categories_prepare_head(Categorie $object, $type)
Prepare array with list of tabs.
Class to manage categories.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.