check_submited_fields();
if ($nberrors) {
error_message_history($msg["notice_champs_perso"],$p_perso->error_message,1);
exit();
}
switch($sub) {
case 'create':
$requete = "SELECT count(1) FROM exemplaires WHERE expl_cb='$f_ex_cb' ";
$res = mysql_query($requete, $dbh);
$nbr_lignes = mysql_result($res, 0, 0);
$nbr_lignes ? $valid_requete = FALSE : $valid_requete = TRUE;
$requete = "INSERT INTO exemplaires SET create_date=sysdate(), ";
$limiter = "";
$libelle = $msg[4007];
break;
case 'update':
// ceci teste si l'exemplaire cible existe bien
$requete = "SELECT expl_id FROM exemplaires WHERE expl_cb='$org_cb' ";
$res = mysql_query($requete, $dbh);
$nbr_lignes = mysql_num_rows($res);
$nbr_lignes ? $valid_requete = TRUE : $valid_requete = FALSE;
if ($nbr_lignes) $expl_id = mysql_result($res,0,0);
// remplacement code-barre : test sur le nouveau numéro
if($org_cb != $f_ex_cb) {
$requete = "SELECT count(1) FROM exemplaires WHERE expl_cb='$f_ex_cb' ";
$res = mysql_query($requete, $dbh);
$nbr_lignes = mysql_result($res, 0, 0);
$nbr_lignes ? $valid_requete = FALSE : $valid_requete = TRUE;
}
$requete = "UPDATE exemplaires SET ";
$limiter = " WHERE expl_cb='${org_cb}' ";
$libelle = $msg[4007];
break;
}
print pmb_bidi("
$libelle
");
if(!is_numeric($f_ex_nbparts) || !$f_ex_nbparts) $f_ex_nbparts=1;
$transfert_origine="";
if($expl_id){
$rqt = "SELECT id_transfert FROM transferts, transferts_demande WHERE num_transfert=id_transfert and etat_transfert=0 AND num_expl='".$expl_id."' " ;
$res = mysql_query ( $rqt );
if (!mysql_num_rows($res)){
// pas de transfert en cours, on met à jour transfert_location_origine
$transfert_origine= ", transfert_location_origine='$f_ex_location', transfert_statut_origine='$f_ex_statut' ";
}
}else{
// en création
$transfert_origine= ", transfert_location_origine='$f_ex_location', transfert_statut_origine='$f_ex_statut' ";
}
if($expl_id){
$audit=new audit();
$audit->get_old_infos("SELECT expl_statut, expl_location, transfert_location_origine, transfert_statut_origine, expl_owner FROM exemplaires WHERE expl_cb='$f_ex_cb' ");
}
if($valid_requete) {
$requete .= "expl_cb='${f_ex_cb}'";
$requete .= ", expl_notice=${id}";
$requete .= ", expl_typdoc=${f_ex_typdoc}";
$requete .= ", expl_cote=trim('${f_ex_cote}')";
$formlocid="f_ex_section".$f_ex_location ;
$requete .= ", expl_section='".$$formlocid."'";
$requete .= ", expl_statut='${f_ex_statut}'";
$requete .= ", expl_location='$f_ex_location' $transfert_origine ";
$requete .= ", expl_codestat='${f_ex_cstat}'";
$requete .= ", expl_note='".${f_ex_note}."'";
$requete .= ", expl_comment='".${f_ex_comment}."'";
$requete .= ", expl_prix='${f_ex_prix}'";
$requete .= ", expl_owner='${f_ex_owner}'";
$requete .= ", type_antivol='${type_antivol}'";
$requete .= ", expl_nbparts='${f_ex_nbparts}'";
$requete .= $limiter;
$result = mysql_query($requete, $dbh);
if (!$expl_id) {
$expl_id=mysql_insert_id();
audit::insert_creation (AUDIT_EXPL, $expl_id) ;
} else{
$audit->get_new_infos("SELECT expl_statut, expl_location, transfert_location_origine, transfert_statut_origine, expl_owner FROM exemplaires WHERE expl_cb='$f_ex_cb' ");
$audit->save_info_modif(AUDIT_EXPL, $expl_id,"expl_update.inc.php");
}
//Insertion des champs personalisés
$p_perso->rec_fields_perso($expl_id);
// Mise a jour de la table notices_mots_global_index
notice::majNoticesMotsGlobalIndex($id,'expl');
// tout va bene, on réaffiche l'ISBD
print "";
$id_form = md5(microtime());
$retour = "./catalog.php?categ=isbd&id=$id";
print "
";
} else {
error_message($msg[301], $msg[303], 1, "./catalog.php?categ=isbd&id=$id");
}
?>