noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
ajax_bookmark.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS 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 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS 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 NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21// Copyright Author Dany De Bontridder danydb@aevalys.eu
22
23/**
24 * @file
25 * @brief user's bookmark
26 */
27/**
28 * @var $cn Database inherited
29 * @var $g_user User_Noalyss inherited
30 */
31if ( ! defined ('ALLOWED')) die('Appel direct ne sont pas permis');
32echo HtmlInput::title_box(_("Favoris"), "bookmark_div");
33if (! isset($_GET['ac'])) {
34 /*
35 * find default module
36 */
38}
39//-------------------------------------------------------------------------------------------
40//
41// Add bookmark
42//-------------------------------------------------------------------------------------------
43if (isset($_GET['bookmark_add'])){
44 $count=$cn->get_value("select count(*) from bookmark"
45 . " where b_action=$1 and login=$2",
46 array($_GET['ac'],$g_user->login)
47 );
48 // Add bookmark only if absent
49 if ( $count == 0 ){
50 $cn->exec_sql("insert into bookmark(b_action,login) values($1,$2)",
51 array($_GET['ac'],$g_user->login));
52 } else {
53 $js="error_message('"._("Ce favori a déjà été ajouté")."');";
54 echo create_script($js);
55 }
56}
57//-------------------------------------------------------------------------------------------
58// remove bookmark
59//
60//-------------------------------------------------------------------------------------------
61if (isset($_GET['bookmark_delete']) && isset ($_GET['book'])){
62 $a_book=$_GET['book'];
63 for ($e=0;$e<count($a_book);$e++)
64 {
65 $cn->exec_sql("delete from bookmark where b_id=$1 and login=$2",
66 array($a_book[$e],$g_user->login));
67 }
68}
69
70$bookmark_sql="select distinct b_id,b_action,b_order,me_code,me_description, javascript"
71 . " from bookmark "
72 . "join v_menu_description_favori on (code=b_action or b_action=me_code)"
73 . "where "
74 . "login=$1 order by me_code";
75$a_bookmark=$cn->get_array($bookmark_sql,array($g_user->login));
76$url="do.php?gDossier=".Dossier::id();
77//-------------------------------------------------------------------------------------------
78// Display content
79//-------------------------------------------------------------------------------------------
80?>
81<div class="content">
82 <?=\HtmlInput::filter_table("bookmark_tb","1,2",0)?>
83<form id="bookmark_del_frm" method="get" onsubmit="bookmark.remove();return false">
84<?php echo HtmlInput::array_to_hidden(array("gDossier",'ac'), $_REQUEST); ?>
85
86 <table id="bookmark_tb" class="result">
87 <?php for ($i=0;$i<count($a_bookmark);$i++): ?>
88 <?php
89 /*
90 * Display only the last ac
91 */
92 $a_code= explode('/',$a_bookmark[$i]['b_action']);
93 $idx=count($a_code);
94 $code=$a_code[$idx-1];
95 ?>
96 <tr class="<?php echo (($i%2)==0?'odd':'even')?>">
97 <td>
98 <?php
99 $ch=new ICheckBox('book[]');
100 $ch->value=$a_bookmark[$i]['b_id'];
101 echo $ch->input();
102 ?>
103 </td>
104 <td>
105 <a class='mtitle' style='text-decoration: underline' href="<?php echo $url."&ac=".$a_bookmark[$i]['b_action']; ?>">
106 <?php echo $code ?>
107 </a>
108 </td>
109 <td>
110 <?php echo $a_bookmark[$i]['me_description'] ?>
111 </td>
112 </tr>
113 <?php endfor; ?>
114 </table>
115<?php
116if ( count($a_bookmark) > 0) :
117 echo HtmlInput::submit("bookmark_delete",_("Supprimez favoris sélectionnés"),"","smallbutton");
119 ?>
120</form>
121<form id="bookmark_frm" method="get" onsubmit="bookmark.save();return false">
122<?php
123echo _("Menu actuel")." : ".hb($_GET['ac']);
124echo HtmlInput::array_to_hidden(array("gDossier","ac"), $_REQUEST);
125?>
126<p>
127<?php echo HtmlInput::submit("bookmark_add", _("Ajoutez le menu actuel à vos favoris"),"","smallbutton"); ?>
128</form>
129
130
131</div>
hb($p_string)
Definition ac_common.php:53
p($p_string, $p_extra='')
Definition ac_common.php:39
find_default_module()
tr($p_string, $p_extra='')
Definition ac_common.php:88
td($p_string='', $p_extra='')
surround the string with td
Definition ac_common.php:83
global $g_user
if no group available , then stop
if(! isset($_GET['ac'])) if(isset( $_GET[ 'bookmark_add'])) if(isset($_GET['bookmark_delete']) &&isset($_GET['book'])) $bookmark_sql
$a_bookmark
$opd_description style
$_REQUEST['ac']
_("actif, passif,charge,...")
$_GET['qcode']
static title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n', $raw="", $refresh='')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
Html Input.
$all table
$count
create_script($p_string)
create the HTML for adding the script tags around of the script