forked from mtawaf/PMB
/
print_cart.php
executable file
·214 lines (202 loc) · 9.13 KB
/
print_cart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
// +-------------------------------------------------+
// © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: print_cart.php,v 1.19 2013-10-16 08:30:19 dbellamy Exp $
//Ajout aux paniers
$base_path = ".";
$base_auth = "CATALOGAGE_AUTH";
$base_title = "\$msg[print_cart_title]";
require_once($base_path."/includes/init.inc.php");
require_once($class_path."/mono_display.class.php");
require_once($include_path."/notice_authors.inc.php");
require_once($include_path."/notice_categories.inc.php");
require_once($class_path."/author.class.php");
require_once($class_path."/editor.class.php");
require_once($include_path."/isbn.inc.php");
require_once($class_path."/collection.class.php");
require_once($class_path."/subcollection.class.php");
require_once($class_path."/serie.class.php");
require_once($include_path."/explnum.inc.php");
require_once($class_path."/category.class.php");
require_once($class_path."/indexint.class.php");
require_once($class_path."/search.class.php");
require_once($include_path."/cart.inc.php");
require_once($class_path."/caddie.class.php");
require_once($class_path."/sort.class.php");
require_once($class_path."/notice.class.php");
if ($action=="print_prepare") {
print "<script type='text/javascript' src='./javascript/tablist.js'></script>";
print "<h3>".$msg["print_cart_title"]."</h3>\n";
print "<form name='print_options' action='print_cart.php?action=print' method='post'>";
//Affichage de la sélection des paniers
$requete="select caddie.*,count(object_id) as nb_objects, count(flag=1) as nb_flags from caddie left join caddie_content on caddie_id=idcaddie group by idcaddie order by type, name, comment";
$resultat=mysql_query($requete);
$ctype="";
while ($ca=mysql_fetch_object($resultat)) {
$ca_auth=explode(" ",$ca->autorisations);
$as=in_array(SESSuserid,$ca_auth);
if (($as!==false)&&($as!==null)) {
if ($ca->type!=$ctype) {
$ctype=$ca->type;
$print_cart[$ctype]["titre"]="<b>".$msg["caddie_de_".$ca->type]."</b><br />";
}
if (($parity=1-$parity)) $pair_impair = "even"; else $pair_impair = "odd";
$tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" ";
$print_cart[$ctype]["cart_list"].= pmb_bidi("<tr class='$pair_impair' $tr_javascript ><td><input type='checkbox' id='id_".$ca->idcaddie."' name='caddie[".$ca->idcaddie."]' value='".$ca->idcaddie."' /> ");
$link = "print_cart.php?action=print&object_type=".$object_type."&idcaddie=".$ca->idcaddie."&item=$item¤t_print=$current_print";
$print_cart[$ctype]["cart_list"].= pmb_bidi( "<a href='javascript:document.getElementById(\"id_".$ca->idcaddie."\").checked=true;document.forms[\"print_options\"].submit();' /><strong>".$ca->name."</strong>") ;
if ($ca->comment) $print_cart[$ctype]["cart_list"].= pmb_bidi("<br /><small>(".$ca->comment.")</small>");
$print_cart[$ctype]["cart_list"].= pmb_bidi("</td>
<td><b>".$ca->nb_flags."</b>". $msg['caddie_contient_pointes']." / <b>$ca->nb_objects</b> </td>
<td>$aff_lien</td>
</tr>");
}
}
print "
<input type='radio' name='pager' value='1'/> ".$msg["print_size_current_page"]."<br />
<input type='radio' name='pager' value='0' checked='checked' /> ".$msg["print_size_all"]."<br />
<input type='checkbox' id='include_child' name='include_child' /> ".$msg["cart_include_child"];
print "<hr />";
print pmb_bidi("<div class='row'><a href='javascript:expandAll()'><img src='./images/expand_all.gif' id='expandall' border='0'></a>
<a href='javascript:collapseAll()'><img src='./images/collapse_all.gif' id='collapseall' border='0'></a>".$msg['caddie_add_search']."</div>");
if (count($print_cart)) {
foreach($print_cart as $key => $cart_type) {
print gen_plus($key,$cart_type["titre"],"<table border='0' cellspacing='0' width='100%'>".$cart_type["cart_list"]."</table>",1);
}
}
print "<input type='hidden' name='current_print' value='$current_print'/>";
$boutons_select = '';
if (count($print_cart)) {
$boutons_select = "<input type='submit' value='".$msg['print_cart_add']."' class='bouton' />";
}
$boutons_select.= " <input type='button' value='".$msg['print_cancel']."' class='bouton' onClick='self.close();' />";
$lien_creation=1;
$object_type="NOTI";
if ($lien_creation) {
print "<div class='row'><hr />
$boutons_select <input class='bouton' type='button' value=' ".$msg['new_cart']." ' onClick=\"document.location='./cart.php?action=new_cart&object_type=".$object_type."&item=$item¤t_print=$current_print'\" />
</div>";
} else {
print "<div class='row'><hr />
$boutons_select
</div>";
}
print "</form>";
}
if ($action=="print") {
if ($_SESSION["session_history"][$current_print]) {
if($_SESSION["session_history"][$current_print]["NOTI"])
$_SESSION["PRINT_CART"]=$_SESSION["session_history"][$current_print]["NOTI"];
else if($_SESSION["session_history"][$current_print]["EXPL"])
$_SESSION["PRINT_CART"]=$_SESSION["session_history"][$current_print]["EXPL"];
$_SESSION["PRINT_CART"]["caddie"]=$caddie;
$_SESSION["PRINT_CART"]["pager"]=$pager;
$_SESSION["PRINT_CART"]["include_child"]=$include_child;
echo "<script>document.location='./print_cart.php'</script>";
} else {
echo "<script>alert(\"".$msg["print_no_search"]."\"); self.close();</script>";
}
}
if ((($action=="") || ($action=="add_item"))&&($_SESSION["PRINT_CART"])) {
$environement=$_SESSION["PRINT_CART"];
$object_type="NOTI";
if ($environement["TEXT_QUERY"]) {
$requete=$environement["TEXT_QUERY"];
if ($_SESSION["tri"]) {
$sort=new sort('notices','base');
//$requete = $sort->appliquer_tri($_SESSION["tri"], $requete, "notice_id");
if ($nb_per_page_search) {
//$requete .= " LIMIT ".$page*$nb_per_page_search.",".$nb_per_page_search;
$requete = $sort->appliquer_tri($_SESSION["tri"], $requete, "notice_id" , $page*$nb_per_page_search , $nb_per_page_search);
} else {
$requete = $sort->appliquer_tri($_SESSION["tri"], $requete, "notice_id" ,0 ,0);
}
}
if (!$environement["pager"]) {
$p=stripos($requete,"limit");
if ($p) {
$requete=substr($requete,0,$p);
}
}
} else {
switch ($environement["SEARCH_TYPE"]) {
case "extended":
$sh=new search();
$table=$sh->make_search();
$requete="select ".$table.".* from $table";
if ($_SESSION["tri"]) {
$sort=new sort('notices','base');
if ($nb_per_page_search) {
$requete = $sort->appliquer_tri($_SESSION["tri"], $requete, "notice_id" , $page*$nb_per_page_search , $nb_per_page_search);
} else {
$requete = $sort->appliquer_tri($_SESSION["tri"], $requete, "notice_id" ,0 ,0);
}
if (!$environement["pager"]) {
$p=stripos($requete,"limit");
if ($p) {
$requete=substr($requete,0,$p);
}
}
} else {
$requete .= ",notices where notices.notice_id=$table.notice_id";
if ($environement["pager"]) $requete.=" limit ".$nb_per_page_search*$page.",$nb_per_page_search";
}
break;
case "cart":
$requete="select object_id as notice_id from caddie_content";
if ($_SESSION["tri"]) {
$requete.=" where caddie_id=".$idcaddie;
$sort=new sort('notices','base');
if ($nb_per_page_search) {
$requete = $sort->appliquer_tri($_SESSION["tri"], $requete, "notice_id" , $nb_per_page_search*($page-1) , $nb_per_page_search);
} else {
$requete = $sort->appliquer_tri($_SESSION["tri"], $requete, "notice_id" ,0 ,0);
}
if (!$environement["pager"]) {
$p=stripos($requete,"limit");
if ($p) {
$requete=substr($requete,0,$p);
}
}
} else {
$requete.= ",notices where notices.notice_id=caddie_content.object_id and caddie_id=".$idcaddie;
$orderby = " order by index_sew";
if ($environement["pager"]) $requete.=$orderby." limit ".($nb_per_page_search*($page-1)).",$nb_per_page_search";
}
break;
case "expl":
$sh=new search(true,"search_fields_expl");
$table=$sh->make_search();
if ($environement["pager"]) $limit="limit ".($nb_per_page_search*$page).",$nb_per_page_search";
$requete="select expl_id as notice_id from $table ".$limit;
$object_type="EXPL";
break;
}
}
if ($environement["caddie"]) {
foreach ($environement["caddie"] as $environement_caddie) {
$c=new caddie($environement_caddie);
$nb_items_before=$c->nb_item;
$resultat=@mysql_query($requete);
print mysql_error();
while (($r=mysql_fetch_object($resultat))) {
if($environement["include_child"]) {
$tab_list_child=notice::get_list_child($r->notice_id);
if(count($tab_list_child))
foreach ($tab_list_child as $notice_id) {
$c->add_item($notice_id,$object_type);
}
} else $c->add_item($r->notice_id,$object_type);
}
$c->compte_items();
$message.=sprintf($msg["print_cart_n_added"]."\\n",($c->nb_item-$nb_items_before),$c->name);
}
print "<script>alert(\"$message\"); self.close();</script>";
} else {
print "<script>alert(\"".$msg["print_cart_no_cart_selected"]."\"); history.go(-1);</script>";
}
$_SESSION["PRINT_CART"]=false;
}
print $footer;
?>