29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/categories.lib.php';
36 $langs->loadlangs(array(
'categories',
'bills'));
40 $label =
GETPOST(
'label',
'alpha');
42 $action =
GETPOST(
'action',
'aZ09');
45 if ($id ==
'' && $label ==
'')
55 $result = $object->fetch($id, $label, $type);
59 $object->fetch_optionals();
63 $upload_dir = $conf->categorie->multidir_output[$object->entity];
65 if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type];
71 if (isset($_FILES[
'userfile']) && $_FILES[
'userfile'][
'size'] > 0 && $_POST[
"sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC))
74 $file = $_FILES[
'userfile'];
75 if (is_array($file[
'name']) && count($file[
'name']) > 0)
77 foreach ($file[
'name'] as $i => $name)
79 if (empty($file[
'tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file[
'tmp_name'][$i]))
81 setEventMessage($file[
'name'][$i].
' : '.$langs->trans(empty($file[
'tmp_name'][$i]) ?
'ErrorFailedToSaveFile' :
'MaxSizeForUploadedFiles'));
82 unset($file[
'name'][$i], $file[
'type'][$i], $file[
'tmp_name'][$i], $file[
'error'][$i], $file[
'size'][$i]);
87 if (!empty($file[
'tmp_name'])) {
88 $object->add_photo($upload_dir, $file);
93 if ($action ==
'confirm_delete' && $_GET[
"file"] && $confirm ==
'yes' && $user->rights->categorie->creer)
95 $object->delete_photo($upload_dir.
"/".$_GET[
"file"]);
98 if ($action ==
'addthumb' && $_GET[
"file"])
100 $object->addThumbs($upload_dir.
"/".$_GET[
"file"]);
108 llxHeader(
"",
"", $langs->trans(
"Categories"));
110 $form =
new Form($db);
115 $title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
122 $linkback =
'<a href="'.DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.$type.
'">'.$langs->trans(
"BackToList").
'</a>';
123 $object->next_prev_filter =
' type = '.$object->type;
124 $object->ref = $object->label;
125 $morehtmlref =
'<br><div class="refidno"><a href="'.DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.$type.
'">'.$langs->trans(
"Root").
'</a> >> ';
126 $ways = $object->print_all_ways(
" >> ",
'', 1);
127 foreach ($ways as $way)
129 $morehtmlref .= $way.
"<br>\n";
131 $morehtmlref .=
'</div>';
133 dol_banner_tab($object,
'label', $linkback, ($user->socid ? 0 : 1),
'label',
'label', $morehtmlref,
'&type='.$type, 0,
'',
'', 1);
138 if ($action ==
'delete')
140 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&type='.$type.
'&file='.$_GET[
"file"], $langs->trans(
'DeletePicture'), $langs->trans(
'ConfirmDeletePicture'),
'confirm_delete',
'', 0, 1);
145 print '<div class="fichecenter">';
146 print '<div class="underbanner clearboth"></div>';
147 print '<table class="border centpercent tableforfield">';
150 print '<tr><td class="titlefield notopnoleft">';
151 print $langs->trans(
"Description").
'</td><td>';
156 print '<tr><td class="notopnoleft">';
157 print $langs->trans(
"Color").
'</td><td>';
158 print $formother->showColor($object->color);
174 print '<div class="tabsAction">'.
"\n";
176 if ($action !=
'ajout_photo' && $user->rights->categorie->creer)
178 if (!empty($conf->global->MAIN_UPLOAD_DOC))
180 print '<a class="butAction hideonsmartphone" href="'.$_SERVER[
'PHP_SELF'].
'?action=ajout_photo&id='.$object->id.
'&type='.$type.
'">';
181 print $langs->trans(
"AddPhoto").
'</a>';
183 print '<a class="butActionRefused classfortooltip hideonsmartphone" href="#">';
184 print $langs->trans(
"AddPhoto").
'</a>';
193 if ($action ==
'ajout_photo' && $user->rights->categorie->creer && !empty($conf->global->MAIN_UPLOAD_DOC))
197 $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);
201 if ($action !=
'ajout_photo')
209 $pdir =
get_exdir($object->id, 2, 0, 0, $object,
'category').$object->id.
"/photos/";
210 $dir = $upload_dir.
'/'.$pdir;
212 $listofphoto = $object->liste_photos($dir);
214 if (is_array($listofphoto) && count($listofphoto))
217 print '<table width="100%" valign="top" align="center">';
219 foreach ($listofphoto as $key => $obj)
223 if ($nbbyrow && ($nbphoto % $nbbyrow == 1))
print '<tr align=center valign=middle border=1>';
224 if ($nbbyrow)
print '<td width="'.ceil(100 / $nbbyrow).
'%" class="photo">';
226 print '<a href="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=category&entity='.$object->entity.
'&file='.urlencode($pdir.$obj[
'photo']).
'" alt="Taille origine" target="_blank">';
229 if ($obj[
'photo_vignette'])
231 $filename = $obj[
'photo_vignette'];
233 $filename = $obj[
'photo'];
237 $viewfilename = $obj[
'photo'];
240 $object->get_image_size($dir.$filename);
241 $imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth;
242 $imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight;
244 print '<img border="0" width="'.$imgWidth.
'" height="'.$imgHeight.
'" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=category&entity='.$object->entity.
'&file='.urlencode($pdir.$filename).
'">';
247 print '<br>'.$viewfilename;
251 if (!$obj[
'photo_vignette'] && preg_match(
'/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $obj[
'photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight))
253 print '<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addthumb&type='.$type.
'&file='.urlencode($pdir.$viewfilename).
'">'.
img_picto($langs->trans(
'GenerateThumb'),
'refresh').
' </a>';
255 if ($user->rights->categorie->creer)
257 print '<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'&type='.$type.
'&file='.urlencode($pdir.$viewfilename).
'">';
260 if ($nbbyrow)
print '</td>';
261 if ($nbbyrow && ($nbphoto % $nbbyrow == 0))
print '</tr>';
265 while ($nbphoto % $nbbyrow)
267 print '<td width="'.ceil(100 / $nbbyrow).
'%"> </td>';
276 print '<div class="opacitymedium">'.$langs->trans(
"NoPhotoYet").
"</div>";
280 print $langs->trans(
"ErrorUnknown");
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
categories_prepare_head(Categorie $object, $type)
Prepare array with list of tabs.
setEventMessage($mesgs, $style= 'mesgs')
Set event message in dol_events session object.
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...
Class to manage categories.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.