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