";
}else{
// celui-ci
$this->error_message=$msg['groupexpl_form_error_already_in_this_group'];
}
return 0;
}
$req="INSERT INTO groupexpl_expl SET groupexpl_num=".$this->id.", groupexpl_expl_num=".$expl_id;
mysql_query($req, $dbh);
$req="update exemplaires set expl_statut=".$this->info['statut_others']." where expl_id=".$expl_id;
mysql_query($req, $dbh);
$this->fetch_data();
$this->info_message=$msg['groupexpl_form_info_insert'];
return 1;
}
function del_expl($cb) {
global $dbh,$msg,$charset;
$this->error_message="";
if(!($expl_id=$this->get_expl_id($cb))) return 0;
$req="DELETE from groupexpl_expl WHERE groupexpl_expl_num=".$expl_id;
mysql_query($req, $dbh);
$this->fetch_data();
return 1;
}
function get_expl_display($tpl,$id){
global $msg,$dbh;
$expl = get_expl_info($id,1);
$tpl=str_replace('!!cb!!',$expl->expl_cb ,$tpl);
$tpl=str_replace('!!notice!!',$expl->aff_reduit ,$tpl);
$tpl=str_replace('!!sur_loc_libelle!!',$expl->sur_loc_libelle,$tpl);
$tpl=str_replace('!!location_libelle!!',$expl->location_libelle,$tpl);
$tpl=str_replace('!!section_libelle!!',$expl->section_libelle,$tpl);
$tpl=str_replace('!!expl_cote!!',$expl->expl_cote,$tpl);
$tpl=str_replace('!!statut_libelle!!',$expl->statut_libelle,$tpl);
return $tpl;
}
function get_form() {
global $groupexpl_form_tpl,$msg,$charset;
global $pmb_lecteurs_localises,$deflt_docs_location;
global $groupexpl_form_list_line_tpl;
$tpl=$groupexpl_form_tpl;
if($this->id){
$tpl=str_replace('!!msg_title!!',$msg['groupexpl_form_edit'],$tpl);
$tpl=str_replace('!!delete!!',"", $tpl);
$tpl=str_replace('!!see_button!!',"",$tpl);
}else{
$tpl=str_replace('!!msg_title!!',$msg['groupexpl_form_add'],$tpl);
$tpl=str_replace('!!delete!!',"",$tpl);
$tpl=str_replace('!!see_button!!',"",$tpl);
}
$tpl=str_replace('!!statut_principal!!',do_selector('docs_statut', 'statut_principal', $this->info['statut_principal']),$tpl);
$tpl=str_replace('!!statut_others!!',do_selector('docs_statut', 'statut_others', $this->info['statut_others']),$tpl);
if($pmb_lecteurs_localises){
if(!$this->info['location'])$f_loc=$deflt_docs_location;
else $f_loc=$this->info['location'];
$loc_select .= "
";
}
$items="";
foreach($this->info['expl'] as $expl){
$item=$groupexpl_form_list_line_tpl;
$item=str_replace('!!cb!!',$expl['cb'], $item);
if($expl['checked'])$checked="x";else $checked="";
$item=str_replace('!!checked!!',$checked, $item);
if($expl['id']==$this->info['resp_expl_num']) $item=str_replace('!!resp_expl_num_checked!!',"checked='checked'", $item);
else $item=str_replace('!!resp_expl_num_checked!!',"", $item);
$item=str_replace('!!expl_num!!',$expl['id'], $item);
$item=$this->get_expl_display($item,$expl['id']);
$items.=$item;
}
$tpl=str_replace('!!error_message!!',htmlentities($this->error_message,ENT_QUOTES,$charset), $tpl);
$tpl=str_replace('!!info_message!!',htmlentities($this->info_message,ENT_QUOTES,$charset), $tpl);
$tpl=str_replace('!!location!!',$loc_select, $tpl);
$tpl=str_replace('!!expl_list!!',$items,$tpl);
$tpl=str_replace('!!name!!',htmlentities($this->info['name'],ENT_QUOTES,$charset),$tpl);
$tpl=str_replace('!!comment!!',htmlentities($this->info['comment'],ENT_QUOTES,$charset),$tpl);
$tpl=str_replace('!!id!!',$this->id,$tpl);
return $tpl;
}
function save($data) {
global $dbh;
$data['resp_expl_num']+=0;
$data['location']+=0;
$data['statut_principal']+=0;
$data['statut_others']+=0;
$fields="
groupexpl_name='".$data['name']."',
groupexpl_resp_expl_num='".$data['resp_expl_num']."',
groupexpl_comment='".$data['comment']."',
groupexpl_location='".$data['location']."',
groupexpl_statut_resp='".$data['statut_principal']."',
groupexpl_statut_others='".$data['statut_others']."'
";
if(!$this->id){ // Ajout
$req="INSERT INTO groupexpl SET $fields ";
mysql_query($req, $dbh);
$this->id = mysql_insert_id($dbh);
} else {
$req="UPDATE groupexpl SET $fields where id_groupexpl=".$this->id;
mysql_query($req, $dbh);
}
$req="update exemplaires set expl_statut=".$this->info['statut_principal']." where expl_id=".$data['resp_expl_num'];
mysql_query($req, $dbh);
$this->fetch_data();
}
function delete() {
global $dbh;
$req="DELETE from groupexpl WHERE id_groupexpl=".$this->id;
mysql_query($req, $dbh);
$req_pret="delete from groupexpl_expl where groupexpl_num=".$this->id;
mysql_query($req, $dbh);
$this->fetch_data();
}
function get_see_form() {
global $groupexpl_see_form_tpl,$msg,$charset;
global $pmb_lecteurs_localises,$deflt_docs_location;
global $groupexpl_see_form_list_line_tpl,$groupexpl_see_form_principale_tpl;
$tpl=$groupexpl_see_form_tpl;
if($pmb_lecteurs_localises){
$res = mysql_query("SELECT location_libelle FROM docs_location where idlocation=".$this->info['location']);
if ($r = mysql_fetch_object($res)) {
$location_libelle="".$r->location_libelle;
}
}
$items="";
foreach($this->info['expl'] as $expl){
$item=$groupexpl_see_form_list_line_tpl;
$item=str_replace('!!cb!!',$expl['cb'], $item);
if($expl['checked']){
$checked="x";
$tpl=str_replace('!!responsable!!',$this->get_expl_display($groupexpl_see_form_principale_tpl,$expl['id']),$tpl);
}else $checked="";
$item=str_replace('!!checked!!',$checked, $item);
$item=$this->get_expl_display($item,$expl['id']);
$items.=$item;
}
$tpl=str_replace('!!error_message!!',htmlentities($this->error_message,ENT_QUOTES,$charset), $tpl);
$tpl=str_replace('!!info_message!!',htmlentities($this->info_message,ENT_QUOTES,$charset), $tpl);
$tpl=str_replace('!!location!!',$location_libelle, $tpl);
$tpl=str_replace('!!expl_list!!',$items,$tpl);
$tpl=str_replace('!!name!!',htmlentities($this->info['name'],ENT_QUOTES,$charset),$tpl);
$tpl=str_replace('!!comment!!',htmlentities($this->info['comment'],ENT_QUOTES,$charset),$tpl);
$tpl=str_replace('!!id!!',$this->id,$tpl);
return $tpl;
}
function get_confirm_form($cb) {
global $groupexpl_confirm_form_tpl,$msg,$charset;
global $pmb_lecteurs_localises,$deflt_docs_location;
global $groupexpl_confirm_form_list_line_tpl;
$is_doc_header=$this->is_doc_header($cb);
$tpl=$groupexpl_confirm_form_tpl;
if(!$is_doc_header) $message="".$msg["groupexpl_see_form_warrning"]."
";
if($pmb_lecteurs_localises){
$res = mysql_query("SELECT location_libelle FROM docs_location where idlocation=".$this->info['location']);
if ($r = mysql_fetch_object($res)) {
$location_libelle="".$r->location_libelle;
}
}
$items="";
foreach($this->info['expl'] as $expl){
$item=$groupexpl_confirm_form_list_line_tpl;
$item=str_replace('!!cb!!',$expl['cb'], $item);
if($expl['checked'])$checked="x";else $checked="";
$item=str_replace('!!checked!!',$checked, $item);
$item=$this->get_expl_display($item,$expl['id']);
if(count($expl['pret'])){
$item=str_replace('!!tr_color!!'," style='color:#FF0000'", $item);
$item=str_replace('!!emprunteur!!',"
".$msg["groupexpl_confirm_emprunteur"]." ".$expl['pret']['emprunteur'], $item);
}else {
$item=str_replace('!!tr_color!!',"", $item);
$item=str_replace('!!emprunteur!!',"", $item);
}
$items.=$item;
}
$tpl=str_replace('!!message!!',$message, $tpl);
$tpl=str_replace('!!location!!',$location_libelle, $tpl);
$tpl=str_replace('!!expl_list!!',$items,$tpl);
$tpl=str_replace('!!name!!',htmlentities($this->info['name'],ENT_QUOTES,$charset),$tpl);
$tpl=str_replace('!!comment!!',htmlentities($this->info['comment'],ENT_QUOTES,$charset),$tpl);
$tpl=str_replace('!!id!!',$this->id,$tpl);
return $tpl;
}
} //groupexpl class end
class groupexpls {
var $info=array();
var $error_message="";
var $info_message="";
function groupexpls() {
$this->error_message="";
$this->info_message="";
$this->fetch_data();
}
function fetch_data() {
global $f_loc,$montrerquoi;
$f_loc+=0;
$this->info=array();
$this->error_message="";
$this->info_message="";
$req="select * from groupexpl ";
if($f_loc){
$req.=" where groupexpl_location =$f_loc ";
}
$i=0;
$resultat=mysql_query($req);
if (mysql_num_rows($resultat)) {
while($r=mysql_fetch_object($resultat)){
$groupexpl= new groupexpl($r->id_groupexpl);
if($montrerquoi=="pret" && !$groupexpl->group_is_check_out()) continue;
if($montrerquoi=="error" && !$groupexpl->group_have_error()) continue;
$this->info[]=$groupexpl->info;
}
}
}
function set_error_message($error_message) {
$this->error_message=$error_message;
}
function get_list() {
global $pmb_lecteurs_localises,$groupexpl_list_tpl,$groupexpl_list_line_tpl,$msg;
global $f_loc,$montrerquoi;
//Sélection de la localisation
$loc_select="";
if($pmb_lecteurs_localises){
$loc_select .= "
".$msg["groupexpl_location"];
$loc_select .= "";
}
$tpl=$groupexpl_list_tpl;
$pret_checked=$error_checked=$all_checked="";
switch($montrerquoi){
case "pret" :
$pret_checked="checked='checked'";
break;
case 'checked':
$error_checked="checked='checked'";
break;
case "list":
default:
$all_checked="checked='checked'";
break;
}
$tpl=str_replace('!!pret_checked!!',$pret_checked, $tpl);
$tpl=str_replace('!!error_checked!!',$error_checked, $tpl);
$tpl=str_replace('!!all_checked!!',$all_checked, $tpl);
$tpl_list="";
$odd_even="odd";
foreach($this->info as $elt){
//printr($elt);
$tpl_elt=$groupexpl_list_line_tpl;
if($odd_even=='odd')$odd_even="even";
else $odd_even="odd";
$tpl_elt=str_replace('!!odd_even!!',$odd_even, $tpl_elt);
$tpl_elt=str_replace('!!name!!',htmlentities($elt['name'],ENT_QUOTES,$charset), $tpl_elt);
$tpl_elt=str_replace('!!emprunteur!!',$elt['pret']['emprunteur'], $tpl_elt);
$error="";
if($elt['not_checked']) $error="X";
$tpl_elt=str_replace('!!error!!',$error, $tpl_elt);
$tpl_elt=str_replace('!!id!!',$elt['id'], $tpl_elt);
$tpl_list.=$tpl_elt;
}
$tpl=str_replace('!!location_filter!!',$loc_select, $tpl);
$tpl=str_replace('!!error_message!!',htmlentities($this->error_message,ENT_QUOTES,$charset), $tpl);
$tpl=str_replace('!!info_message!!',htmlentities($this->info_message,ENT_QUOTES,$charset), $tpl);
$tpl=str_replace('!!list!!',$tpl_list, $tpl);
return $tpl;
}
function get_group_expl($cb){
$req="select id_groupexpl from groupexpl, groupexpl_expl, exemplaires where expl_id=groupexpl_expl_num and groupexpl_num=id_groupexpl and expl_cb='$cb' ";
$resultat=mysql_query($req);
if (!mysql_num_rows($resultat)){
return 0;
}
$r=mysql_fetch_object($resultat);
return $r->id_groupexpl;
}
} // groupexpls class end