name = ''; $this->comment = ''; $this->nb_item = 0; $this->nb_item_pointe = 0; $this->autorisations = ""; $this->autorisations_all = 0; $this->classementGen = ""; $this->acces_rapide = 0; $this->favorite_color = ''; $this->creation_user_name = ''; $this->creation_date = '0000-00-00 00:00:00'; } protected function get_template_form() { return ""; } protected function get_warning_delete() { } protected function get_type_form() { global $msg; global $current_print; if ($this->get_idcaddie() && $this->nb_item) { $type = "caddie_de_".$this->type; return $msg[$type]; } else { $select_cart=" "; return $select_cart; } } // formulaire public function get_form($form_action="", $form_cancel="", $form_duplicate="") { global $msg, $charset; global $PMBuserid; global $current_print; global $clause, $filtered_query; $form = $this->get_template_form(); $form = str_replace ( '!!formulaire_action!!', $form_action, $form ); $form = str_replace('!!formulaire_annuler!!', $form_cancel, $form); if ($this->get_idcaddie()) { $form = str_replace ( '!!title!!', $msg['edit_cart'], $form); $form = str_replace('!!autorisations_users!!', users::get_form_autorisations($this->autorisations,0), $form); $form = str_replace('!!infos_creation!!', "
".$this->get_info_creation(), $form); $button_duplicate = " "; $form = str_replace('!!button_duplicate!!', $button_duplicate, $form); } else { $form = str_replace ( '!!title!!', $msg['new_cart'], $form); $form = str_replace('!!autorisations_users!!', users::get_form_autorisations("",1), $form); $form = str_replace('!!infos_creation!!', "", $form); $form = str_replace('!!button_duplicate!!', "", $form); } $form = str_replace('!!name!!', htmlentities($this->name,ENT_QUOTES, $charset), $form); $form = str_replace('!!comment!!', htmlentities($this->comment,ENT_QUOTES, $charset), $form); $form = str_replace('!!autorisations_all!!', ($this->autorisations_all ? "checked='checked'" : ""), $form); $classementGen = new classementGen(static::get_table_name(), $this->get_idcaddie()); $form = str_replace("!!object_type!!",$classementGen->object_type,$form); $form = str_replace("!!classements_liste!!",$classementGen->getClassementsSelectorContent($PMBuserid,$classementGen->libelle),$form); $form = str_replace("!!acces_rapide!!",($this->acces_rapide?"checked='checked'":""),$form); $form = str_replace("!!favorite_color!!", $this->favorite_color,$form); $memo_contexte = ""; if($clause) { $memo_contexte .= ""; } if($filtered_query) { $memo_contexte.=""; } $form=str_replace('', $memo_contexte, $form); return $form; } protected function get_links_form() { return ""; } public function set_properties_from_form() { global $autorisations; global $autorisations_all; global $cart_name; global $cart_comment; global $acces_rapide; global $favorite_color; if (is_array($autorisations)) { $this->autorisations=implode(" ",$autorisations); } else { $this->autorisations="1"; } $this->autorisations_all = $autorisations_all+0; $this->name = stripslashes($cart_name); $this->comment = stripslashes($cart_comment); $this->acces_rapide = (isset($acces_rapide)?1:0); $this->favorite_color = $favorite_color; } protected static function get_order_cart_list() { return " order by name, comment "; } public static function get_cart_data($temp) { return array(); } public static function get_query_cart_list($restriction_panier="",$acces_rapide = 0,$item = 0, $with_order = true) { global $PMBuserid; $query = "SELECT * FROM ".static::get_table_name(); if($item) { $query .= " JOIN ".static::get_table_content_name()." ON ".static::get_table_content_name().".".static::get_field_content_name()." = ".static::get_table_name().".".static::get_field_name()." AND ".static::get_table_content_name().".object_id = ".$item; } if ($restriction_panier=="" || (static::class == 'empr_caddie')) { $query .= " where 1 "; } else { $query .= " where type='$restriction_panier' "; } if ($PMBuserid!=1) { $query.=" and (autorisations='$PMBuserid' or autorisations like '$PMBuserid %' or autorisations like '% $PMBuserid %' or autorisations like '% $PMBuserid' or autorisations_all=1) "; } if ($acces_rapide) { $query .= " and acces_rapide=1"; } if($with_order) { $query .= static::get_order_cart_list(); } return $query; } static public function get_query_filters() { global $elt_flag, $elt_no_flag; $filter_query = ''; if ($elt_flag && $elt_no_flag ) $filter_query .= ""; if (!$elt_flag && $elt_no_flag ) $filter_query .= " and flag is null "; if ($elt_flag && !$elt_no_flag ) $filter_query .= " and flag is not null "; return $filter_query; } // liste des paniers disponibles public static function get_cart_list($restriction_panier="",$acces_rapide = 0) { $cart_list=array(); $query = static::get_query_cart_list($restriction_panier, $acces_rapide); $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)) { while ($temp = pmb_mysql_fetch_object($result)) { $cart_list[] = static::get_cart_data($temp); } } return $cart_list; } // liste des paniers dans lesquels est présent l'item public static function get_cart_list_from_item($restriction_panier="",$acces_rapide = 0, $item = 0) { $cart_list=array(); $query = static::get_query_cart_list($restriction_panier, $acces_rapide, $item); $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)) { while ($temp = pmb_mysql_fetch_object($result)) { $cart_list[] = static::get_cart_data($temp); } } return $cart_list; } public static function get_cart_list_selector($restriction_panier="", $name="", $selected=0) { global $msg, $PMBuserid; $query = "SELECT ".static::get_field_name().", name, caddie_classement FROM ".static::get_table_name()." where type='".$restriction_panier."' "; if ($PMBuserid!=1) $query.=" and (autorisations='$PMBuserid' or autorisations like '$PMBuserid %' or autorisations like '% $PMBuserid %' or autorisations like '% $PMBuserid') "; $query.=" ORDER BY caddie_classement, name "; return gen_liste ($query, static::get_field_name(), "name", $name, "", $selected, 0, $msg['dsi_panier_aucun'], 0,$msg['dsi_panier_aucun'], 0, '', 'caddie_classement'); } public static function get_cart_list_multiple_selector($restriction_panier="", $name="", $selected=array()) { global $msg, $PMBuserid; $query = "SELECT ".static::get_field_name().", name, caddie_classement FROM ".static::get_table_name()." where type='".$restriction_panier."' "; if ($PMBuserid!=1) $query.=" and (autorisations='$PMBuserid' or autorisations like '$PMBuserid %' or autorisations like '% $PMBuserid %' or autorisations like '% $PMBuserid') "; $query.=" ORDER BY caddie_classement, name "; return gen_liste_multiple ($query, static::get_field_name(), "name", "", $name, "", $selected, 0, $msg['dsi_panier_aucun'], 0,'', 10, 'caddie_classement'); } protected function get_info_user() { global $PMBuserid; $query = "SELECT CONCAT(prenom, ' ', nom) as name FROM users WHERE userid=".$PMBuserid; $result = pmb_mysql_query($query); if (pmb_mysql_num_rows($result)) { return pmb_mysql_fetch_object($result); } return false; } // l'item est-il dans le panier ? public static function has_item($idcaddie=0, $item=0) { $query = "select count(*) FROM ".static::get_table_content_name()." where ".static::get_field_content_name()."='".$idcaddie."' and object_id='".$item."' "; $result = pmb_mysql_query($query); return pmb_mysql_result($result, 0, 0); } // suppression d'un item public function del_item($item=0) { $query = "delete FROM ".static::get_table_content_name()." where ".static::get_field_content_name()."='".$this->get_idcaddie()."' and object_id='".$item."' "; $result = @pmb_mysql_query($query); $this->compte_items(); } // Dépointage de tous les items public function depointe_items() { $query = "update ".static::get_table_content_name()." set flag=null where ".static::get_field_content_name()."='".$this->get_idcaddie()."' "; $result = @pmb_mysql_query($query); $this->compte_items(); } // Dépointage d'un item public function depointe_item($item=0) { if ($item) { $query = "update ".static::get_table_content_name()." set flag=null where ".static::get_field_content_name()."='".$this->get_idcaddie()."' and object_id='".$item."' "; $result = @pmb_mysql_query($query); if ($result) { $this->compte_items(); return 1; } else { return 0; } } } public function pointe_items_from_query($query) { global $msg; if (pmb_strtolower(pmb_substr($query,0,6))!="select") { error_message_history($msg['caddie_action_invalid_query'],$msg['requete_echouee'],1); exit(); } $result_selection = pmb_mysql_query($query); if (!$result_selection) { error_message_history($msg['caddie_action_invalid_query'],$msg['requete_echouee'].pmb_mysql_error(),1); exit(); } if(pmb_mysql_num_rows($result_selection)) { while ($obj_selection = pmb_mysql_fetch_object($result_selection)) { if(static::class == 'empr_caddie') { $this->pointe_item($obj_selection->object_id); } else { $this->pointe_item($obj_selection->object_id,$obj_selection->object_type); } } } } // suppression d'un panier public function delete() { $query = "delete FROM ".static::get_table_content_name()." where ".static::get_field_content_name()."='".$this->get_idcaddie()."' "; $result = pmb_mysql_query($query); $query = "delete FROM ".static::get_table_name()." where ".static::get_field_name()."='".$this->get_idcaddie()."' "; $result = pmb_mysql_query($query); } // compte_items public function compte_items() { $this->nb_item = 0 ; $this->nb_item_pointe = 0 ; $rqt_nb_item="select count(1) from ".static::get_table_content_name()." where ".static::get_field_content_name()."='".$this->get_idcaddie()."' "; $this->nb_item = pmb_mysql_result(pmb_mysql_query($rqt_nb_item), 0, 0); $rqt_nb_item_pointe = "select count(1) from ".static::get_table_content_name()." where ".static::get_field_content_name()."='".$this->get_idcaddie()."' and (flag is not null and flag!='') "; $this->nb_item_pointe = pmb_mysql_result(pmb_mysql_query($rqt_nb_item_pointe), 0, 0); } public function add_items_by_collecte_selection($final_query) { global $msg, $charset; global $base_path; global $erreur_explain_rqt; global $pmb_procs_force_execution, $force_exec, $PMBuserid; $nb_element_a_ajouter = 0; $line = pmb_split("\n", $final_query); $nb_element_avant = $this->nb_item; foreach ($line as $cle => $valeur) { if ($valeur != '') { if ( (pmb_strtolower(pmb_substr($valeur,0,6))=="select") || (pmb_strtolower(pmb_substr($valeur,0,6))=="create")) { } else { echo pmb_substr($valeur,0,6); error_message_history($msg['caddie_action_invalid_query'],$msg['requete_selection'],1); exit(); } if (!(($pmb_procs_force_execution && $force_exec) || (($PMBuserid == 1) && $force_exec) || explain_requete($valeur))) { print "

".$valeur."

".$msg["proc_param_explain_failed"]."

".$erreur_explain_rqt; if($pmb_procs_force_execution || $PMBuserid == 1) { print "

"; } die(); } $result_selection = pmb_mysql_query($valeur); if (!$result_selection) { error_message_history($msg['caddie_action_invalid_query'],$msg['requete_echouee'].pmb_mysql_error(),1); exit(); } if (pmb_strtolower(pmb_substr($valeur,0,6))=="select") { $nb_element_a_ajouter += pmb_mysql_num_rows($result_selection); if(pmb_mysql_num_rows($result_selection)) { while ($obj_selection = pmb_mysql_fetch_object($result_selection)) if(static::class == 'empr_caddie') { $this->add_item($obj_selection->object_id); } else { $this->add_item($obj_selection->object_id,$obj_selection->object_type); } } // fin if mysql_num_rows $this->compte_items(); } // fin if rqt sélection } //fin valeur nonvide } // fin while list $cle $nb_element_apres = $this->nb_item; $msg["caddie_affiche_nb_ajouts"] = str_replace('!!nb_a_ajouter!!', $nb_element_a_ajouter, $msg["caddie_affiche_nb_ajouts"]); $msg["caddie_affiche_nb_ajouts"] = str_replace('!!nb_ajoutes!!', ($nb_element_apres-$nb_element_avant), $msg["caddie_affiche_nb_ajouts"]); $res_exec = "
$msg[caddie_affiche_nb_ajouts]
"; return $res_exec; } protected function replace_in_action_query($query, $by) { $final_query = $query; return $final_query; } public function update_items_by_action_selection($final_query) { global $msg; global $elt_flag; global $elt_no_flag; $error_message_flag = ''; $error_message_no_flag = ''; //Sélection des éléments du panier $nb_elements_flag=0; $nb_elements_no_flag=0; if ($elt_flag) { $liste_flag=$this->get_cart("FLAG"); if (count($liste_flag)) { if (pmb_strtolower(pmb_substr($final_query,0,6))=='insert') { // procédure insert for ($icount=0; $icountreplace_in_action_query($final_query, $liste_flag[$icount]); $result_selection_flag= pmb_mysql_query($query); $nb_elts_traites = pmb_mysql_affected_rows() ; if ($nb_elts_traites>0) $nb_elements_flag+=$nb_elts_traites; } // fin for } else { // autre procédure $query=preg_replace("/CADDIE\([^\)]*\)/i",implode(",",$liste_flag),$final_query); $result_selection_flag= pmb_mysql_query($query); if ($result_selection_flag) { $nb_elements_flag=pmb_mysql_affected_rows(); } else $error_message_flag=pmb_mysql_error(); } // fin if autre procédure } } if ($elt_no_flag) { $liste_no_flag=$this->get_cart("NOFLAG"); if (count($liste_no_flag)) { if (pmb_strtolower(pmb_substr($final_query,0,6))=='insert') { // procédure insert for ($icount=0; $icountreplace_in_action_query($final_query, $liste_no_flag[$icount]); $result_selection_no_flag= pmb_mysql_query($query); $nb_elts_traites = pmb_mysql_affected_rows() ; if ($nb_elts_traites>0) $nb_elements_no_flag+=$nb_elts_traites; } // fin for } else { // autre procédure $query=preg_replace("/CADDIE\([^\)]*\)/i",implode(",",$liste_no_flag),$final_query); $result_selection_no_flag= pmb_mysql_query($query); if ($result_selection_no_flag) { $nb_elements_no_flag=pmb_mysql_affected_rows(); } else $error_message_no_flag=pmb_mysql_error(); } // fin if autre procédure } } $error_message=""; print sprintf($msg["caddie_action_flag_processed"],$nb_elements_flag)."
"; print sprintf($msg["caddie_action_no_flag_processed"],$nb_elements_no_flag)."
"; print "".sprintf($msg["caddie_action_total_processed"],($nb_elements_no_flag+$nb_elements_flag))."

"; if ($error_message_flag) { $error_message.=sprintf($msg["caddie_action_error"],$error_message_flag)."
"; } if ($error_message_no_flag) { $error_message.=sprintf($msg["caddie_action_error"],$error_message_no_flag); } if ($error_message) { error_message_history($msg["caddie_action_invalid_query"],$error_message,1); exit(); } } public function get_edition_switch_form($mode="simple", $action="") { global $msg; return "
"; } protected function get_edition_template_form() { return ""; } public function get_edition_form($action="", $action_cancel="") { global $msg; $form = $this->get_edition_template_form(); $form = str_replace('!!action!!', $action, $form); $form = str_replace('!!action_cancel!!', $action_cancel, $form); $form = str_replace('!!titre_form!!', $msg["caddie_choix_edition"], $form); $suppl = "      " ; $form = str_replace('', $suppl.'', $form); return $form; } protected function get_js_script_cart_objects($module='ajax') { global $msg; return " "; } // affichage des filtres d'un caddie public function aff_filters_form_objects ($url_base="") { global $msg, $charset; global $current_module; global $elt_flag,$elt_no_flag; $filters_form = "

".$msg["filters"]."

 
"; return $filters_form; } // affichage du contenu complet d'un caddie public function aff_cart_objects ($url_base="", $no_del=false, $rec_history=0, $no_point=false) { } public function aff_cart_nb_items() { global $msg; return "
".$msg['caddie_contient']."
".$msg['caddie_contient_total']."
".$msg['caddie_contient_nb_pointe']."
".$msg['caddie_contient_total']."
".$this->nb_item."
".$this->nb_item_pointe."

"; } public function aff_nb_items_reduit() { global $msg; return "".$this->nb_item_pointe."". $msg['caddie_contient_pointes']." / ".$this->nb_item." "; } protected function get_choix_quoi_template_form() { return ""; } public function get_choix_quoi_form($action="", $action_cancel="", $titre_form="", $bouton_valider="",$onclick="", $aff_choix_dep = false) { global $msg; global $elt_flag,$elt_no_flag; $form = $this->get_choix_quoi_template_form(); $form = str_replace('!!action!!', $action, $form); $form = str_replace('!!action_cancel!!', $action_cancel, $form); $form = str_replace('!!titre_form!!', $titre_form, $form); $form = str_replace('!!bouton_valider!!', $bouton_valider, $form); if ($onclick!="") $form = str_replace('!!onclick_valider!!','onClick="'.$onclick.'"',$form); else $form = str_replace('!!onclick_valider!!','',$form); if ($elt_flag) { $form = str_replace('!!elt_flag_checked!!', 'checked=\'checked\'', $form); } else { $form = str_replace('!!elt_flag_checked!!', '', $form); } if ($elt_no_flag) { $form = str_replace('!!elt_no_flag_checked!!', 'checked=\'checked\'', $form); } else { $form = str_replace('!!elt_no_flag_checked!!', '', $form); } return $form; } public function get_info_creation() { global $msg; if ($this->creation_date != '0000-00-00 00:00:00') { $create_date = new DateTime($this->creation_date); return sprintf($msg["empr_caddie_creation_info"], $create_date->format('d/m/Y'),$this->creation_user_name); } else { return $msg['empr_caddie_creation_no_info']; } } public function get_classement_label() { if(!trim($this->classementGen)) { return classementGen::getDefaultLibelle(); } return $this->classementGen; } public static function check_rights($id) { global $msg; global $PMBuserid; if ($id) { $query = "SELECT autorisations, autorisations_all FROM ".static::get_table_name()." WHERE ".static::get_field_name()."='$id' "; $result = @pmb_mysql_query($query); if(pmb_mysql_num_rows($result)) { $temp = pmb_mysql_fetch_object($result); if($temp->autorisations_all) return $id; $rqt_autorisation=explode(" ",$temp->autorisations); if (array_search ($PMBuserid, $rqt_autorisation)!==FALSE || $PMBuserid == 1) return $id ; } } return 0 ; } public function reindex_from_list($liste=array()) { global $msg; $pb=new progress_bar($msg['caddie_situation_reindex_encours'],count($liste),5); foreach ($liste as $cle => $object) { $this->reindex_object($object); $pb->progress(); } $pb->hide(); } public function del_items_base_from_list($liste=array()) { return ''; } public function get_tab_list() { global $elt_flag, $elt_no_flag; $list = array(); if (($elt_flag=="") && ($elt_no_flag=="")) { $elt_no_flag = 1; $elt_flag = 1; } $query = "SELECT ".static::$table_content_name.".* FROM ".static::$table_content_name." where ".static::$field_content_name."='".$this->get_idcaddie()."' "; if ($elt_flag && $elt_no_flag ) $complement_clause = ""; if (!$elt_flag && $elt_no_flag ) $complement_clause = " and flag is null "; if ($elt_flag && !$elt_no_flag ) $complement_clause = " and flag is not null "; $query .= $complement_clause." order by object_id"; $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)) { while ($row = pmb_mysql_fetch_object($result)) { $list[] = array('object_id' => $row->object_id, 'flag' => $row->flag ) ; } } return $list; } public static function get_type_label($object_type) { global $msg; switch ($object_type) { case 'EXPL': return $msg['expl_carts']; case 'BULL': return $msg['bull_carts']; case 'NOTI': return $msg['396']; case 'EMPR': return $msg['empr_carts']; default: return $msg['authorities_carts']; } } protected function write_header_tableau() { } protected function write_content_tableau() { } protected function get_display_header_tableauhtml() { } protected function get_display_content_tableauhtml() { } public function write_tableau() { $this->write_header_tableau(); $this->write_content_tableau(); } public function get_display_tableauhtml() { $display = ""; $display .= $this->get_display_header_tableauhtml(); $display .= $this->get_display_content_tableauhtml(); $display .= "
"; return $display; } public function get_export_iframe($param_exp='') { global $elt_flag, $elt_no_flag, $keep_expl, $keep_explnum, $export_type; return "