name = '';
$this->comment = '';
$this->nb_item = 0;
$this->nb_item_pointe = 0;
$this->autorisations = "";
$this->classementGen = "";
$this->acces_rapide = 0;
$this->creation_user_name = '';
$this->creation_date = '0000-00-00 00:00:00';
}
protected function get_template_form() {
return "";
}
protected function get_warning_delete() {
}
// formulaire
public function get_form($form_action="", $form_cancel="") {
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);
} 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('!!name!!', htmlentities($this->name,ENT_QUOTES, $charset), $form);
$form = str_replace('!!comment!!', htmlentities($this->comment,ENT_QUOTES, $charset), $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);
$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 $cart_name;
global $cart_comment;
global $acces_rapide;
if (is_array($autorisations)) {
$this->autorisations=implode(" ",$autorisations);
} else {
$this->autorisations="1";
}
$this->name = stripslashes($cart_name);
$this->comment = stripslashes($cart_comment);
$this->acces_rapide = (isset($acces_rapide)?1:0);
}
protected static function get_order_cart_list() {
return " order by name, comment ";
}
public static function get_cart_data($temp) {
return array();
}
// liste des paniers disponibles
public static function get_cart_list($restriction_panier="",$acces_rapide = 0) {
global $PMBuserid;
$cart_list=array();
if ($restriction_panier=="") {
$requete = "SELECT * FROM ".static::get_table_name()." where 1 ";
} else {
$requete = "SELECT * FROM ".static::get_table_name()." where type='$restriction_panier' ";
}
if ($PMBuserid!=1) {
$requete.=" and (autorisations='$PMBuserid' or autorisations like '$PMBuserid %' or autorisations like '% $PMBuserid %' or autorisations like '% $PMBuserid') ";
}
if ($acces_rapide) {
$requete .= " and acces_rapide=1";
}
$requete .= static::get_order_cart_list();
$result = pmb_mysql_query($requete);
if(pmb_mysql_num_rows($result)) {
while ($temp = pmb_mysql_fetch_object($result)) {
$cart_list[] = static::get_cart_data($temp);
}
}
return $cart_list;
}
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;
}
// 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(get_called_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;
$nb_element_a_ajouter = 0;
$line = pmb_split("\n", $final_query);
$nb_element_avant = $this->nb_item;
while(list($cle, $valeur)= each($line)) {
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 (!explain_requete($valeur)) die("
".$valeur."
".$msg["proc_param_explain_failed"]."
".$erreur_explain_rqt);
$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(get_called_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 = "