noalyss  Version-9
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 if ( ! defined ('ALLOWED')) die('Appel direct ne sont pas permis');
28 echo HtmlInput::title_box(_("Favoris"), "bookmark_div");
29 if (! isset($_GET['ac'])) {
30  /*
31  * find default module
32  */
33  $_GET['ac']= find_default_module();
34 }
35 // Add bookmark
36 if (isset($_GET['bookmark_add'])){
37  $count=$cn->get_value("select count(*) from bookmark"
38  . " where b_action=$1 and login=$2",
39  array($_GET['ac'],$g_user->login)
40  );
41  // Add bookmark only if absent
42  if ( $count == 0 ){
43  $cn->exec_sql("insert into bookmark(b_action,login) values($1,$2)",
44  array($_GET['ac'],$g_user->login));
45  } else {
46  $js="error_message('"._("Ce favori a déjà été ajouté")."');";
47  echo create_script($js);
48  }
49 }
50 // remove bookmark
51 if (isset($_GET['bookmark_delete']) && isset ($_GET['book'])){
52  $a_book=$_GET['book'];
53  for ($e=0;$e<count($a_book);$e++)
54  {
55  $cn->exec_sql("delete from bookmark where b_id=$1 and login=$2",
56  array($a_book[$e],$g_user->login));
57  }
58 }
59 
60 $bookmark_sql="select distinct b_id,b_action,b_order,me_code,me_description, javascript"
61  . " from bookmark "
62  . "join v_menu_description_favori on (code=b_action or b_action=me_code)"
63  . "where "
64  . "login=$1 order by me_code";
65 $a_bookmark=$cn->get_array($bookmark_sql,array($g_user->login));
66 $url="do.php?gDossier=".Dossier::id()."&ac=";
67 ?>
68 <div class="content">
69 <form id="bookmark_del_frm" method="get" onsubmit="remove_bookmark();return false">
70 <?php echo HtmlInput::array_to_hidden(array("gDossier",'ac'), $_REQUEST); ?>
71 
72  <table class="result">
73  <?php for ($i=0;$i<count($a_bookmark);$i++): ?>
74  <?php
75  /*
76  * Display only the last ac
77  */
78  $a_code= explode('/',$a_bookmark[$i]['b_action']);
79  $idx=count($a_code);
80  $code=$a_code[$idx-1];
81  ?>
82  <tr class="<?php echo (($i%2)==0?'odd':'even')?>">
83  <td>
84  <?php
85  $ch=new ICheckBox('book[]');
86  $ch->value=$a_bookmark[$i]['b_id'];
87  echo $ch->input();
88  ?>
89  </td>
90  <td>
91  <a class='mtitle' style='text-decoration: underline' href="<?php echo $url."&ac=".$a_bookmark[$i]['b_action']; ?>">
92  <?php echo $code ?>
93  </a>
94  </td>
95  <td>
96  <?php echo $a_bookmark[$i]['me_description'] ?>
97  </td>
98  </tr>
99  <?php endfor; ?>
100  </table>
101 <?php
102 if ( count($a_bookmark) > 0) :
103  echo HtmlInput::submit("bookmark_delete",_("Supprimez favoris sélectionnés"),"","smallbutton");
105  ?>
106 </form>
107 <form id="bookmark_frm" method="get" onsubmit="save_bookmark();return false">
108 <?php
109 echo _("Menu actuel")." : ".hb($_GET['ac']);
110 echo HtmlInput::array_to_hidden(array("gDossier","ac"), $_REQUEST);
111 ?>
112 <p>
113 <?php echo HtmlInput::submit("bookmark_add", _("Ajoutez le menu actuel à vos favoris"),"","smallbutton"); ?>
114 </form>
115 
116 
117 </div>
endif
endif
Definition: ajax_bookmark.php:104
$e
$e
Definition: result_cat_card_summary.php:26
style
$opd_description style
Definition: ajax_mod_predf_op.php:52
$bookmark_sql
if(! isset($_GET['ac'])) if(isset($_GET['bookmark_add'])) if(isset($_GET['bookmark_delete']) &&isset($_GET['book'])) $bookmark_sql
Definition: ajax_bookmark.php:60
p
p($p_string)
Definition: ac_common.php:39
tr
tr($p_string, $p_extra='')
Definition: ac_common.php:88
create_script
create_script($p_string)
create the HTML for adding the script tags around of the script
Definition: function_javascript.php:38
$_GET
$_GET['qcode']
Definition: category_followup.inc.php:53
$code
$code
Definition: ajax_bookmark.php:80
HtmlInput\title_box
static title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
Definition: html_input.class.php:838
$a_bookmark
$a_bookmark
Definition: ajax_bookmark.php:65
find_default_module
find_default_module()
Definition: ac_common.php:982
$g_user
global $g_user
Find the default module or the first one.
Definition: action.inc.php:24
$i
$i
Definition: action_document_type_mtable_input.php:83
$url
$url
Definition: ajax_bookmark.php:66
HtmlInput\submit
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
Definition: html_input.class.php:199
$idx
$idx
Definition: ajax_bookmark.php:79
$_REQUEST
$_REQUEST['ac']
Definition: ajax_search_action.php:26
hb
hb($p_string)
Definition: ac_common.php:53
endfor
endfor
Definition: stock_cfg.inc.php:108
$cn
$cn
Definition: ajax_anc_accounting.php:30
$count
$count
Definition: modele.inc.php:251
HtmlInput\array_to_hidden
static array_to_hidden($array, $global_array)
transform request data to hidden
Definition: html_input.class.php:582
table
$all table
Definition: company.inc.php:138
ICheckBox
Html Input.
Definition: icheckbox.class.php:30
td
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
$js
$js
Definition: ajax_tag_list.php:32