dolibarr 24.0.0-beta
bloc_showhide.tpl.php
1<?php
2/* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
26'
27@phan-var-force string $blocname
28@phan-var-force string $title
29@phan-var-force array<string,null|string|int> $parameters
30';
31
32// Protection to avoid direct call of template
33if (empty($blocname)) {
34 print "Error, template page can't be called as URL";
35 exit(1);
36}
37
38$hide = true; // Hide by default
39if (isset($parameters['showblocbydefault'])) {
40 $hide = empty($parameters['showblocbydefault']);
41}
42if (isset($object->extraparams[$blocname]['showhide'])) {
43 $hide = empty($object->extraparams[$blocname]['showhide']);
44}
45
46?>
47<!-- BEGIN PHP TEMPLATE bloc_showhide.tpl.php -->
48
49<?php
50print '<script>'."\n";
51print '$(document).ready(function() {'."\n";
52print '$("#hide-'.$blocname.'").click(function(){'."\n";
53print ' setShowHide(0);'."\n";
54print ' $("#'.$blocname.'_bloc").hide("blind", {direction: "vertical"}, 300).removeClass("nohideobject");'."\n";
55print ' $(this).hide();'."\n";
56print ' $("#show-'.$blocname.'").show();'."\n";
57print '});'."\n";
58
59print '$("#show-'.$blocname.'").click(function(){'."\n";
60print ' setShowHide(1);'."\n";
61print ' $("#'.$blocname.'_bloc").show("blind", {direction: "vertical"}, 300).addClass("nohideobject");'."\n";
62print ' $(this).hide();'."\n";
63print ' $("#hide-'.$blocname.'").show();'."\n";
64print '});'."\n";
65
66print 'function setShowHide(status) {'."\n";
67print ' var id = '.((int) $object->id).";\n";
68print " var element = '".dol_escape_js($object->element)."';\n";
69print " var htmlelement = '".dol_escape_js($blocname)."';\n";
70print ' var type = "showhide";'."\n";
71print ' $.get("'.dol_buildpath('/core/ajax/extraparams.php', 1);
72print '?id="+id+"&element="+element+"&htmlelement="+htmlelement+"&type="+type+"&value="+status);'."\n";
73print '}'."\n";
74
75print '});'."\n";
76print '</script>'."\n";
77
78print '<div style="float:right; position: relative; top: 3px; right:5px;" id="hide-'.$blocname.'"';
79print ' class="linkobject'.($hide ? ' hideobject' : '').'">'.img_picto('', '1uparrow').'</div>'."\n";
80print '<div style="float:right; position: relative; top: 3px; right:5px;" id="show-'.$blocname.'"';
81print ' class="linkobject'.($hide ? '' : ' hideobject').'">'.img_picto('', '1downarrow').'</div>'."\n";
82print '<div id="'.$blocname.'_title" class="liste_titre">'.$title.'</div>'."\n";
83print '<div id="'.$blocname.'_bloc" class="'.($hide ? 'hideobject' : 'nohideobject').'">'."\n";
84
85include DOL_DOCUMENT_ROOT.'/core/tpl/'.$blocname.'.tpl.php';
86print '</div><br>';
87?>
88<!-- END PHP TEMPLATE BLOCK SHOW/HIDE -->
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)