From: Stéphane Jacob Date: Mon, 11 Aug 2008 17:34:14 +0000 (+0200) Subject: Changes thoroughly education's implementation : allows multiple education, adds data... X-Git-Tag: xorg/1.0.0~332^2~536 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=043bbacf7d5ceaeba4db582ac0ea7c75d6f13c80;p=platal.git Changes thoroughly education's implementation : allows multiple education, adds data, improves display. --- diff --git a/bin/cron/checkdb.php b/bin/cron/checkdb.php index 5103817..66b74aa 100755 --- a/bin/cron/checkdb.php +++ b/bin/cron/checkdb.php @@ -90,9 +90,9 @@ check("SELECT a.* LEFT JOIN auth_user_md5 AS u ON u.user_id=a.id WHERE (a.type='alias' OR a.type='a_vie') AND u.prenom is null"); -/* validite de applis_ins */ -check("select a.* from applis_ins as a left join auth_user_md5 as u on u.user_id=a.uid where u.prenom is null"); -check("select a.* from applis_ins as a left join applis_def as ad on ad.id=a.aid where ad.text is null"); +/* validite de profile_education */ +check("select a.* from profile_education as a left join auth_user_md5 as u on u.user_id=a.uid where u.prenom is null"); +check("select a.* from profile_education as a left join profile_education_enum as ad on ad.id=a.eduid where ad.name is null"); /* validite de binet_users */ check("select b.* from binets_ins as b left join auth_user_md5 as u on u.user_id=b.user_id where u.prenom is null"); diff --git a/bin/cron/clean.php b/bin/cron/clean.php index 9744d97..243ebdd 100755 --- a/bin/cron/clean.php +++ b/bin/cron/clean.php @@ -37,7 +37,7 @@ query("DELETE FROM register_pending WHERE TO_DAYS(NOW()) - TO_DAYS(date) >= 365" query("DELETE FROM register_pending WHERE hash = 'INSCRIT'"); // quelques tables sont triées pour que la lecture triée soit plus facile -query("ALTER TABLE applis_def ORDER BY text"); +query("ALTER TABLE profile_education_enum ORDER BY name"); query("ALTER TABLE binets_def ORDER BY text"); query("ALTER TABLE groupesx_def ORDER BY text"); query("ALTER TABLE secteur ORDER BY text"); diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index 3ce7b6a..4afe8be 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -24,10 +24,14 @@ function wizPage_onLoad(id) { switch (id) { case 'general': - fillType(document.forms.prof_annu['edu_0[type]'], document.forms.prof_annu['edu_0[id]'].selectedIndex-1); - selectType(document.forms.prof_annu['edu_0[type]'], document.forms.prof_annu['edu_0_tmp'].value); - fillType(document.forms.prof_annu['edu_1[type]'], document.forms.prof_annu['edu_1[id]'].selectedIndex-1); - selectType(document.forms.prof_annu['edu_1[type]'], document.forms.prof_annu['edu_1_tmp'].value); + var i = 0; + var prefix = 'edu_'; + while (document.getElementById(prefix + i) != null) { + i++; + } + for (var j = 0; j < i; j++) { + prepareType(j); + } break; case 'poly': updateGroupSubLink(document.forms.prof_annu.groupesx_sub); @@ -54,6 +58,7 @@ function wizPage_onLoad(id) var applisType; var applisTypeAll; +var applisTypeName; // General @@ -62,33 +67,43 @@ var names; function fillType(selectCtrl, appli, fill) { var i; - var i0=0; + var i0 = 0; - for (i = selectCtrl.options.length; i >=0; i--) { + for (i = selectCtrl.options.length; i >= 0; i--) { selectCtrl.options[i] = null; } - if (fill || appli <0) { + if (fill || appli < 0) { selectCtrl.options[0] = new Option(' '); - i0=1; + i0 = 1; + } + if (appli >= 0) { + for (i = 0; i < applisType[appli].length; i++) { + selectCtrl.options[i0 + i] = new Option(applisTypeName[applisType[appli][i] - 1], applisType[appli][i]); + } + } else if (fill) { + for (i = 0; i < applisTypeAll.length; i++) { + selectCtrl.options[i0 + i] = new Option(applisTypeName[applisTypeAll[i] - 1], applisTypeAll[i]); + } } - if (appli>=0) - for (i=0; i < applisType[appli].length; i++) - selectCtrl.options[i0+i] = new Option(applisType[appli][i]); - else if (fill) - for (i=0; i < applisTypeAll.length; i++) - selectCtrl.options[i0+i] = new Option(applisTypeAll[i]); } function selectType(selectCtrl, type) { for (i = 0; i < selectCtrl.options.length; i++) { - if (selectCtrl.options[i].text == type) - selectCtrl.selectedIndex=i; + if (selectCtrl.options[i].value == type) { + selectCtrl.selectedIndex = i; + } } } +function prepareType(i) +{ + fillType(document.forms.prof_annu["edus[" + i + "][degreeid]"], document.forms.prof_annu["edus[" + i + "][eduid]"].selectedIndex - 1); + selectType(document.forms.prof_annu["edus[" + i + "][degreeid]"], document.forms.prof_annu["edu_" + i + "_tmp"].value); +} + function addSearchName() { var i = 0; @@ -255,6 +270,26 @@ function addAddress() Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress); } +function addEdu() +{ + var i = 0; + var prefix = 'edu_'; + while (document.getElementById(prefix + i) != null) { + i++; + } + $('#edu_add').before('
'); + $.get(platal_baseurl + 'profile/ajax/edu/' + i, + function(data) { + $("#" + prefix + i).html(data); + prepareType(i); + }); +} + +function removeEdu(id) +{ + $('#' + id).remove(); +} + function addTel(prefid, prefname) { var i = 0; diff --git a/include/applis.func.inc.php b/include/applis.func.inc.php index 82235db..c5b3915 100644 --- a/include/applis.func.inc.php +++ b/include/applis.func.inc.php @@ -19,73 +19,142 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -function applis_options($current=0) { - $html = ''; - $res = XDB::iterator("select * from applis_def order by text"); +function applis_options($current=0) +{ + $html = ''; + $res = XDB::iterator("SELECT * + FROM profile_education_enum + ORDER BY name"); while ($arr_appli = $res->next()) { - $html .= '