2020-09-26 16:19:37 +02:00
|
|
|
// Cadre "debouchés" sur fiche etudiant
|
|
|
|
// affichage et saisie des informations sur l'avenir de l'étudiant.
|
|
|
|
|
|
|
|
// console.log('etud_debouche.js loaded');
|
|
|
|
|
2021-06-21 18:46:35 +02:00
|
|
|
$(function () {
|
2023-09-21 10:24:09 +02:00
|
|
|
display_itemsuivis(false);
|
2020-09-26 16:19:37 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
function display_itemsuivis(active) {
|
2023-09-21 10:24:09 +02:00
|
|
|
var etudid = $("div#fichedebouche").data("etudid");
|
|
|
|
var readonly = $("div#fichedebouche").data("readonly"); // present ro interface
|
|
|
|
|
|
|
|
if (!readonly) {
|
|
|
|
$("#adddebouchelink")
|
|
|
|
.off("click")
|
|
|
|
.click(function (e) {
|
|
|
|
e.preventDefault();
|
2024-04-10 18:40:32 +02:00
|
|
|
$.post(SCO_URL + "itemsuivi_create", {
|
2023-09-21 10:24:09 +02:00
|
|
|
etudid: etudid,
|
|
|
|
fmt: "json",
|
|
|
|
}).done(item_insert_new);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// add existing items
|
|
|
|
$.get(
|
2024-04-10 18:40:32 +02:00
|
|
|
SCO_URL + "itemsuivi_list_etud",
|
2023-09-21 10:24:09 +02:00
|
|
|
{ etudid: etudid, fmt: "json" },
|
|
|
|
function (L) {
|
|
|
|
for (var i in L) {
|
|
|
|
item_insert(
|
|
|
|
L[i]["itemsuivi_id"],
|
|
|
|
L[i]["item_date"],
|
|
|
|
L[i]["situation"],
|
|
|
|
L[i]["tags"],
|
|
|
|
readonly
|
|
|
|
);
|
|
|
|
}
|
2020-09-26 16:19:37 +02:00
|
|
|
}
|
2023-09-21 10:24:09 +02:00
|
|
|
);
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2023-09-21 10:24:09 +02:00
|
|
|
$("div#fichedebouche").accordion({
|
|
|
|
heightStyle: "content",
|
|
|
|
collapsible: true,
|
|
|
|
active: active,
|
|
|
|
});
|
2020-09-26 16:19:37 +02:00
|
|
|
}
|
|
|
|
|
2021-06-21 18:46:35 +02:00
|
|
|
function item_insert_new(it) {
|
2023-09-21 10:24:09 +02:00
|
|
|
item_insert(it.itemsuivi_id, it.item_date, it.situation, "", false);
|
2020-09-26 16:19:37 +02:00
|
|
|
}
|
|
|
|
|
2021-06-21 18:46:35 +02:00
|
|
|
function item_insert(itemsuivi_id, item_date, situation, tags, readonly) {
|
2023-09-21 10:24:09 +02:00
|
|
|
if (item_date === undefined) item_date = Date2DMY(new Date());
|
|
|
|
if (situation === undefined) situation = "";
|
|
|
|
if (tags === undefined) tags = "";
|
|
|
|
|
|
|
|
var nodes = item_nodes(itemsuivi_id, item_date, situation, tags, readonly);
|
|
|
|
// insert just before last li:
|
|
|
|
if ($("ul.listdebouches li.adddebouche").length > 0) {
|
|
|
|
$("ul.listdebouches").children(":last").before(nodes);
|
|
|
|
} else {
|
|
|
|
// mode readonly, pas de li "ajouter"
|
|
|
|
$("ul.listdebouches").append(nodes);
|
|
|
|
}
|
|
|
|
}
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
function item_nodes(itemsuivi_id, item_date, situation, tags, readonly) {
|
2023-09-21 10:24:09 +02:00
|
|
|
// console.log('item_nodes: itemsuivi_id=' + itemsuivi_id);
|
|
|
|
var sel_mois =
|
|
|
|
'Situation à la date du <input type="text" class="itemsuividatepicker" size="10" value="' +
|
|
|
|
item_date +
|
|
|
|
'"/><span class="itemsuivi_suppress" onclick="itemsuivi_suppress(\'' +
|
|
|
|
itemsuivi_id +
|
|
|
|
'\')"><img width="10" height="9" border="0" title="" alt="supprimer cet item" src="/ScoDoc/static/icons/delete_small_img.png"/></span>';
|
|
|
|
|
|
|
|
var h = sel_mois;
|
|
|
|
// situation
|
|
|
|
h +=
|
|
|
|
'<div class="itemsituation editable" data-type="textarea" data-url="itemsuivi_set_situation" data-placeholder="<em>décrire situation...</em>" data-object="' +
|
|
|
|
itemsuivi_id +
|
|
|
|
'">' +
|
|
|
|
situation +
|
|
|
|
"</div>";
|
|
|
|
// tags:
|
|
|
|
h +=
|
|
|
|
'<div class="itemsuivi_tag_edit"><textarea class="itemsuivi_tag_editor">' +
|
|
|
|
tags +
|
|
|
|
"</textarea></div>";
|
|
|
|
|
|
|
|
var nodes = $($.parseHTML('<li class="itemsuivi">' + h + "</li>"));
|
|
|
|
var dp = nodes.find(".itemsuividatepicker");
|
|
|
|
dp.blur(function (e) {
|
|
|
|
var date = this.value;
|
|
|
|
// console.log('selected text: ' + date);
|
2024-04-10 18:40:32 +02:00
|
|
|
$.post(SCO_URL + "itemsuivi_set_date", {
|
2023-09-21 10:24:09 +02:00
|
|
|
item_date: date,
|
|
|
|
itemsuivi_id: itemsuivi_id,
|
2020-09-26 16:19:37 +02:00
|
|
|
});
|
2023-09-21 10:24:09 +02:00
|
|
|
});
|
|
|
|
dp.datepicker({
|
|
|
|
onSelect: function (date, instance) {
|
|
|
|
// console.log('selected: ' + date + 'for itemsuivi_id ' + itemsuivi_id);
|
2024-04-10 18:40:32 +02:00
|
|
|
$.post(SCO_URL + "itemsuivi_set_date", {
|
2023-09-21 10:24:09 +02:00
|
|
|
item_date: date,
|
|
|
|
itemsuivi_id: itemsuivi_id,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
showOn: "button",
|
|
|
|
buttonImage: "/ScoDoc/static/icons/calendar_img.png",
|
|
|
|
buttonImageOnly: true,
|
|
|
|
dateFormat: "dd/mm/yy",
|
|
|
|
duration: "fast",
|
|
|
|
disabled: readonly,
|
|
|
|
});
|
|
|
|
dp.datepicker(
|
|
|
|
"option",
|
|
|
|
$.extend({ showMonthAfterYear: false }, $.datepicker.regional["fr"])
|
|
|
|
);
|
|
|
|
|
|
|
|
if (readonly) {
|
|
|
|
// show tags read-only
|
|
|
|
readOnlyTags(nodes.find(".itemsuivi_tag_editor"));
|
|
|
|
} else {
|
|
|
|
// bind tag editor
|
|
|
|
nodes.find(".itemsuivi_tag_editor").tagEditor({
|
|
|
|
initialTags: "",
|
|
|
|
placeholder: "Tags...",
|
|
|
|
onChange: function (field, editor, tags) {
|
|
|
|
$.post("itemsuivi_tag_set", {
|
|
|
|
itemsuivi_id: itemsuivi_id,
|
|
|
|
taglist: tags.join(),
|
2021-06-21 18:46:35 +02:00
|
|
|
});
|
2023-09-21 10:24:09 +02:00
|
|
|
},
|
|
|
|
autocomplete: {
|
|
|
|
delay: 200, // ms before suggest
|
|
|
|
position: { collision: "flip" }, // automatic menu position up/down
|
|
|
|
source: "itemsuivi_tag_search",
|
|
|
|
},
|
|
|
|
});
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2023-09-21 10:24:09 +02:00
|
|
|
// bind inplace editor
|
|
|
|
nodes.find("div.itemsituation").jinplace();
|
|
|
|
}
|
2021-06-21 18:46:35 +02:00
|
|
|
|
2023-09-21 10:24:09 +02:00
|
|
|
return nodes;
|
|
|
|
}
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
function Date2DMY(date) {
|
2023-09-21 10:24:09 +02:00
|
|
|
var year = date.getFullYear();
|
2021-06-21 18:46:35 +02:00
|
|
|
|
2023-09-21 10:24:09 +02:00
|
|
|
var month = (1 + date.getMonth()).toString();
|
|
|
|
month = month.length > 1 ? month : "0" + month;
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2023-09-21 10:24:09 +02:00
|
|
|
var day = date.getDate().toString();
|
|
|
|
day = day.length > 1 ? day : "0" + day;
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2023-09-21 10:24:09 +02:00
|
|
|
return day + "/" + month + "/" + year;
|
2020-09-26 16:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function itemsuivi_suppress(itemsuivi_id) {
|
2024-04-10 18:40:32 +02:00
|
|
|
$.post(SCO_URL + "itemsuivi_suppress", { itemsuivi_id: itemsuivi_id });
|
2023-09-21 10:24:09 +02:00
|
|
|
// Clear items and rebuild:
|
|
|
|
$("ul.listdebouches li.itemsuivi").remove();
|
|
|
|
display_itemsuivis(0);
|
2020-09-26 16:19:37 +02:00
|
|
|
}
|