30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
34 require_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');
45 if ($id ==
'' && $label ==
'') {
54 $result =
$object->fetch($id, $label);
61 if (is_numeric($type)) {
62 $type = Categorie::$MAP_ID_TO_CODE[$type];
65 $upload_dir = $conf->categorie->multidir_output[
$object->entity];
67 $hookmanager->initHooks(array(
'categorycard'));
72 $parameters = array(
'id' => $id,
'label' => $label,
'confirm' => $confirm,
'type' => $type,
'uploaddir' => $upload_dir,
'sendfile' => (
GETPOST(
"sendit") ?
true :
false));
74 $reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
79 if (empty($reshook)) {
80 if (isset($_FILES[
'userfile']) && $_FILES[
'userfile'][
'size'] > 0 &&
GETPOST(
"sendit") &&
getDolGlobalString(
'MAIN_UPLOAD_DOC')) {
82 $file = $_FILES[
'userfile'];
83 if (is_array($file[
'name']) && count($file[
'name']) > 0) {
84 foreach ($file[
'name'] as $i => $name) {
85 if (empty($file[
'tmp_name'][$i]) || (
getDolGlobalInt(
'MAIN_UPLOAD_DOC') * 1000) <= filesize($file[
'tmp_name'][$i])) {
86 setEventMessage($file[
'name'][$i].
' : '.$langs->trans(empty($file[
'tmp_name'][$i]) ?
'ErrorFailedToSaveFile' :
'MaxSizeForUploadedFiles'));
87 unset($file[
'name'][$i], $file[
'type'][$i], $file[
'tmp_name'][$i], $file[
'error'][$i], $file[
'size'][$i]);
92 if (!empty($file[
'tmp_name'])) {
93 $object->add_photo($upload_dir, $file);
98 if ($action ==
'confirm_delete' &&
GETPOST(
"file") && $confirm ==
'yes' && $user->hasRight(
'categorie',
'creer')) {
102 if ($action ==
'addthumb' &&
GETPOST(
"file")) {
111 llxHeader(
"",
"", $langs->trans(
"Categories"));
117 $title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
122 $backtolist = (
GETPOST(
'backtolist') ?
GETPOST(
'backtolist') : DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.urlencode($type));
123 $linkback =
'<a href="'.dol_sanitizeUrl($backtolist).
'">'.$langs->trans(
"BackToList").
'</a>';
126 $morehtmlref =
'<br><div class="refidno"><a href="'.DOL_URL_ROOT.
'/categories/index.php?leftmenu=cat&type='.$type.
'">'.$langs->trans(
"Root").
'</a> >> ';
127 $ways =
$object->print_all_ways(
" >> ",
'', 1);
128 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') {
139 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&type='.urlencode($type).
'&file='.urlencode(
GETPOST(
"file")), $langs->trans(
'DeletePicture'), $langs->trans(
'ConfirmDeletePicture'),
'confirm_delete',
'', 0, 1);
144 print
'<div class="fichecenter">';
145 print
'<div class="underbanner clearboth"></div>';
146 print
'<table class="border centpercent tableforfield">';
149 print
'<tr><td class="titlefield notopnoleft">';
150 print $langs->trans(
"Description").
'</td><td>';
155 print
'<tr><td class="notopnoleft">';
156 print $langs->trans(
"Color").
'</td><td>';
157 print $formother->showColor(
$object->color);
170 print
'<div class="tabsAction">'.
"\n";
172 if ($action !=
'ajout_photo' && $user->hasRight(
'categorie',
'creer')) {
174 print
'<a class="butAction hideonsmartphone" href="'.$_SERVER[
'PHP_SELF'].
'?action=ajout_photo&id='.
$object->id.
'&type='.$type.
'">';
175 print $langs->trans(
"AddPhoto").
'</a>';
177 print
'<a class="butActionRefused classfortooltip hideonsmartphone" href="#">';
178 print $langs->trans(
"AddPhoto").
'</a>';
187 if ($action ==
'ajout_photo' && $user->hasRight(
'categorie',
'creer') &&
getDolGlobalString(
'MAIN_UPLOAD_DOC')) {
190 $formfile->form_attach_new_file($_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&type='.$type, $langs->trans(
"AddPhoto"), 1,
'', $user->hasRight(
'categorie',
'creer'), 50,
$object,
'',
false,
'', 0);
194 if ($action !=
'ajout_photo') {
202 $dir = $upload_dir.
'/'.$pdir;
204 $listofphoto =
$object->liste_photos($dir);
206 if (is_array($listofphoto) && count($listofphoto)) {
208 print
'<table width="100%" valign="top" class="center centpercent">';
210 foreach ($listofphoto as $key => $obj) {
213 if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) {
214 print
'<tr class"center valignmiddle" border="1">';
217 print
'<td width="'.ceil(100 / $nbbyrow).
'%" class="photo">';
220 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">';
223 if ($obj[
'photo_vignette']) {
224 $filename = $obj[
'photo_vignette'];
226 $filename = $obj[
'photo'];
230 $viewfilename = $obj[
'photo'];
233 $object->get_image_size($dir.$filename);
234 $imgWidth = (
$object->imgWidth < $maxWidth) ?
$object->imgWidth : $maxWidth;
235 $imgHeight = (
$object->imgHeight < $maxHeight) ?
$object->imgHeight : $maxHeight;
237 print
'<img border="0" width="'.$imgWidth.
'" height="'.$imgHeight.
'" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=category&entity='.
$object->entity.
'&file='.urlencode($pdir.$filename).
'">';
240 print
'<br>'.$viewfilename;
244 if (!$obj[
'photo_vignette'] && preg_match(
'/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $obj[
'photo']) && (
$object->imgWidth > $maxWidth ||
$object->imgHeight > $maxHeight)) {
245 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>';
247 if ($user->hasRight(
'categorie',
'creer')) {
248 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&type='.$type.
'&file='.urlencode($pdir.$viewfilename).
'">';
254 if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) {
260 while ($nbphoto % $nbbyrow) {
261 print
'<td width="'.ceil(100 / $nbbyrow).
'%"> </td>';
269 print
'<div class="opacitymedium">'.$langs->trans(
"NoPhotoYet").
"</div>";
273 print $langs->trans(
"ErrorUnknown");
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.