dolibarr 21.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-2024 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024 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 */
25// Protection to avoid direct call of template
26if (empty($blocname)) {
27 print "Error, template page can't be called as URL";
28 exit(1);
29}
30
31$hide = true; // Hide by default
32if (isset($parameters['showblocbydefault'])) {
33 $hide = empty($parameters['showblocbydefault']);
34}
35if (isset($object->extraparams[$blocname]['showhide'])) {
36 $hide = empty($object->extraparams[$blocname]['showhide']);
37}
38
39?>
40<!-- BEGIN PHP TEMPLATE bloc_showhide.tpl.php -->
41
42<?php
43print '<script>'."\n";
44print '$(document).ready(function() {'."\n";
45print '$("#hide-'.$blocname.'").click(function(){'."\n";
46print ' setShowHide(0);'."\n";
47print ' $("#'.$blocname.'_bloc").hide("blind", {direction: "vertical"}, 300).removeClass("nohideobject");'."\n";
48print ' $(this).hide();'."\n";
49print ' $("#show-'.$blocname.'").show();'."\n";
50print '});'."\n";
51
52print '$("#show-'.$blocname.'").click(function(){'."\n";
53print ' setShowHide(1);'."\n";
54print ' $("#'.$blocname.'_bloc").show("blind", {direction: "vertical"}, 300).addClass("nohideobject");'."\n";
55print ' $(this).hide();'."\n";
56print ' $("#hide-'.$blocname.'").show();'."\n";
57print '});'."\n";
58
59print 'function setShowHide(status) {'."\n";
60print ' var id = '.((int) $object->id).";\n";
61print " var element = '".dol_escape_js($object->element)."';\n";
62print " var htmlelement = '".dol_escape_js($blocname)."';\n";
63print ' var type = "showhide";'."\n";
64print ' $.get("'.dol_buildpath('/core/ajax/extraparams.php', 1);
65print '?id="+id+"&element="+element+"&htmlelement="+htmlelement+"&type="+type+"&value="+status);'."\n";
66print '}'."\n";
67
68print '});'."\n";
69print '</script>'."\n";
70
71print '<div style="float:right; position: relative; top: 3px; right:5px;" id="hide-'.$blocname.'"';
72print ' class="linkobject'.($hide ? ' hideobject' : '').'">'.img_picto('', '1uparrow.png').'</div>'."\n";
73print '<div style="float:right; position: relative; top: 3px; right:5px;" id="show-'.$blocname.'"';
74print ' class="linkobject'.($hide ? '' : ' hideobject').'">'.img_picto('', '1downarrow.png').'</div>'."\n";
75print '<div id="'.$blocname.'_title" class="liste_titre">'.$title.'</div>'."\n";
76print '<div id="'.$blocname.'_bloc" class="'.($hide ? 'hideobject' : 'nohideobject').'">'."\n";
77
78include DOL_DOCUMENT_ROOT.'/core/tpl/'.$blocname.'.tpl.php';
79print '</div><br>';
80?>
81<!-- END PHP TEMPLATE BLOCK SHOW/HIDE -->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)