aff_cart_titre());
switch ($action) {
case 'choix_quoi':
print pmb_bidi($myCart->aff_cart_nb_items());
$form = $myCart->get_choix_quoi_form("./catalog.php?categ=caddie&sub=action&quelle=transfert_to_location&action=transfert_to_location_suite&object_type=EXPL&idcaddie=".$idcaddie, "./catalog.php?categ=caddie&sub=action&quelle=transfert_to_location&idcaddie=0", $msg["caddie_menu_action_transfert_to_location"], $msg["caddie_menu_action_transfert_to_location"], "");
$destination_form = "
".gen_liste ("select distinct idlocation, location_libelle from docs_location order by location_libelle", "idlocation", "location_libelle", 'dest_id', "", $deflt_docs_location, "", "","","",0)."
";
$form = str_replace('', $destination_form, $form);
$date_pret = mktime(0, 0, 0, date("m"), date("d") + $transferts_nb_jours_pret_defaut, date("Y"));
$form = str_replace("!!date_retour_mysql!!", date("Y-m-d", $date_pret), $form);
print $form;
break;
case 'transfert_to_location_suite':
print pmb_bidi($myCart->aff_cart_nb_items());
$idcaddie = caddie::check_rights($idcaddie);
if ($idcaddie) {
$liste = array();
if($elt_flag && $elt_no_flag)
$liste = $myCart->get_cart("ALL");
if($elt_flag && !$elt_no_flag)
$liste = $myCart->get_cart("FLAG");
if($elt_no_flag && !$elt_flag)
$liste = $myCart->get_cart("NOFLAG");
$liste = array_unique($liste);
$trans = new transfert();
$trans->validation_send_event = 1;
// pour chaque exemplaire on genere les transferts
$transferts_expl_is_here = array();
$transferts_ok = array();
$transferts_in_progress = array();
$transferts_nok = array();
foreach ($liste as $id_expl) {
// L'exemplaire est déjà ici ?
$query = "SELECT expl_location FROM exemplaires WHERE expl_id=".$id_expl;
$res = pmb_mysql_query( $query );
$src_id = pmb_mysql_result($res, 0);
if($src_id == $dest_id) {
$transferts_expl_is_here[] = $id_expl;
continue;
}
// L'exemplaire est en cours de transfert ?
$query = "select id_transfert from transferts ,transferts_demande where num_transfert=id_transfert and num_expl=$id_expl and etat_transfert=0";
$res = pmb_mysql_query($query);
if (pmb_mysql_num_rows($res)) {
$transferts_in_progress[] = $id_expl;
continue;
}
$num = $trans->creer_transfert_catalogue($id_expl, $dest_id, $date_retour, stripslashes($motif), $ask_date);
if ($num) {
// Le transfert est généré !
$query = 'update transferts set transfert_ask_user_num= "'.$PMBuserid.'" where id_transfert="'.$num.'" ';
pmb_mysql_query($query);
$transferts_ok[] = $id_expl;
} else {
// Erreur, Le transfert ne peut etre généré
$transferts_nok[] = $id_expl;
}
}
print "
".$msg['caddie_menu_action_transfert_to_location_ok']."
".count($transferts_ok)."
";
//
if (count($transferts_expl_is_here)) {
print "
".$msg['caddie_menu_action_transfert_to_location_is_here']."
".count($transferts_expl_is_here)."
";
}
if (count($transferts_in_progress)) {
print "
".$msg['caddie_menu_action_transfert_to_location_in_progress']."
".count($transferts_in_progress)."
";
}
if (count($transferts_nok)) {
print "
".$msg['caddie_menu_action_transfert_to_location_nok']."
".count($transferts_nok)."
";
}
}
break;
default:
break;
}
} else {
aff_paniers($idcaddie, "EXPL", "./catalog.php?categ=caddie&sub=action&quelle=transfert_to_location", "choix_quoi", $msg["caddie_menu_action_transfert_to_location"], "EXPL", 0, 0, 0);
}