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 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20// Protection to avoid direct call of template
21if (empty($blocname)) {
22 print "Error, template page can't be called as URL";
23 exit(1);
24}
25
26$hide = true; // Hide by default
27if (isset($parameters['showblocbydefault'])) {
28 $hide = (empty($parameters['showblocbydefault']) ? true : false);
29}
30if (isset($object->extraparams[$blocname]['showhide'])) {
31 $hide = (empty($object->extraparams[$blocname]['showhide']) ? true : false);
32}
33
34?>
35<!-- BEGIN PHP TEMPLATE bloc_showhide.tpl.php -->
36
37<?php
38print '<script>'."\n";
39print '$(document).ready(function() {'."\n";
40print '$("#hide-'.$blocname.'").click(function(){'."\n";
41print ' setShowHide(0);'."\n";
42print ' $("#'.$blocname.'_bloc").hide("blind", {direction: "vertical"}, 300).removeClass("nohideobject");'."\n";
43print ' $(this).hide();'."\n";
44print ' $("#show-'.$blocname.'").show();'."\n";
45print '});'."\n";
46
47print '$("#show-'.$blocname.'").click(function(){'."\n";
48print ' setShowHide(1);'."\n";
49print ' $("#'.$blocname.'_bloc").show("blind", {direction: "vertical"}, 300).addClass("nohideobject");'."\n";
50print ' $(this).hide();'."\n";
51print ' $("#hide-'.$blocname.'").show();'."\n";
52print '});'."\n";
53
54print 'function setShowHide(status) {'."\n";
55print ' var id = '.((int) $object->id).";\n";
56print " var element = '".dol_escape_js($object->element)."';\n";
57print " var htmlelement = '".dol_escape_js($blocname)."';\n";
58print ' var type = "showhide";'."\n";
59print ' $.get("'.dol_buildpath('/core/ajax/extraparams.php', 1);
60print '?id="+id+"&element="+element+"&htmlelement="+htmlelement+"&type="+type+"&value="+status);'."\n";
61print '}'."\n";
62
63print '});'."\n";
64print '</script>'."\n";
65
66print '<div style="float:right; position: relative; top: 3px; right:5px;" id="hide-'.$blocname.'"';
67print ' class="linkobject'.($hide ? ' hideobject' : '').'">'.img_picto('', '1uparrow.png').'</div>'."\n";
68print '<div style="float:right; position: relative; top: 3px; right:5px;" id="show-'.$blocname.'"';
69print ' class="linkobject'.($hide ? '' : ' hideobject').'">'.img_picto('', '1downarrow.png').'</div>'."\n";
70print '<div id="'.$blocname.'_title" class="liste_titre">'.$title.'</div>'."\n";
71print '<div id="'.$blocname.'_bloc" class="'.($hide ? 'hideobject' : 'nohideobject').'">'."\n";
72
73include DOL_DOCUMENT_ROOT.'/core/tpl/'.$blocname.'.tpl.php';
74print '</div><br>';
75?>
76<!-- 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)