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