From 57b73804361578322047f80524d30c60453d2092 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 2 Sep 2007 17:22:20 +0200 Subject: [PATCH] Binets & groups page Signed-off-by: Florent Bruneau --- modules/profile/assign_adresses.inc.php | 110 --------------- modules/profile/assign_poly.inc.php | 39 ------ modules/profile/get_adresses.inc.php | 128 ------------------ modules/profile/get_poly.inc.php | 58 -------- modules/profile/groups.inc.php | 87 ++++++++++-- modules/profile/update_adresses.inc.php | 137 ------------------- modules/profile/update_poly.inc.php | 27 ---- modules/profile/verif_adresses.inc.php | 206 ----------------------------- modules/profile/verif_poly.inc.php | 22 --- templates/profile/{poly.tpl => groups.tpl} | 65 +++++++-- 10 files changed, 132 insertions(+), 747 deletions(-) delete mode 100644 modules/profile/assign_adresses.inc.php delete mode 100644 modules/profile/assign_poly.inc.php delete mode 100644 modules/profile/get_adresses.inc.php delete mode 100644 modules/profile/get_poly.inc.php delete mode 100644 modules/profile/update_adresses.inc.php delete mode 100644 modules/profile/update_poly.inc.php delete mode 100644 modules/profile/verif_adresses.inc.php delete mode 100644 modules/profile/verif_poly.inc.php rename templates/profile/{poly.tpl => groups.tpl} (63%) diff --git a/modules/profile/assign_adresses.inc.php b/modules/profile/assign_adresses.inc.php deleted file mode 100644 index e9afd63..0000000 --- a/modules/profile/assign_adresses.inc.php +++ /dev/null @@ -1,110 +0,0 @@ - $adr){ - if (!isset($adr['tels']) || count($adr['tels']) == 0) { - $adresses[$adrid]['tels'] = array( - array('tel' => '', 'tel_pub' => 'private', 'tel_type' => 'Tél.', 'telid' => 0, 'new_tel' => true), - array('tel' => '', 'tel_pub' => 'private', 'tel_type' => 'Fax', 'telid' => 1, 'new_tel' => true)); - } elseif (count($adr['tels']) < $nb_tel_max) { - $adresses[$adrid]['tels'][] = - array('tel' => '', 'tel_pub' => 'private', 'tel_type' => 'Autre', 'telid' => generate_new_telid($adr), 'new_tel' => true); - } -} - -unset($adr); -unset($adrid); - -//tri des adresses : - -reset($adresses); -$i = 1; -foreach($adresses as $adrid_ => $adr_){ - if(($adresses[$adrid_]['active']) && ($adr_['nouvelle'] != 'new')){ - $ordre_des_adrid[$i] = $adrid_; - $i++; - $est_attribuee[$adrid_] = 1; - } - else - $est_attribuee[$adrid_] = 0; -} - -reset($adresses); -foreach($adresses as $adrid_ => $adr_){ - if(($adresses[$adrid_]['secondaire'] == 0) && ($est_attribuee[$adrid_] == 0) && ($adr_['nouvelle'] != 'new')){ // principale et non attribuee - $ordre_des_adrid[$i] = $adrid_; - $i++; - $est_attribuee[$adrid_] = 1; - } -} - -reset($adresses); -foreach($adresses as $adrid_ => $adr_){ - if(($adresses[$adrid_]['temporaire'] == 0) && ($est_attribuee[$adrid_] == 0) && ($adr_['nouvelle'] != 'new')){ // permanente et non attribuee - $ordre_des_adrid[$i] = $adrid_; - $i++; - $est_attribuee[$adrid_] = 1; - } -} -reset($adresses); -foreach($adresses as $adrid_ => $adr_){ - if($est_attribuee[$adrid_] == 0){ // non attribuee - $ordre_des_adrid[$i] = $adrid_; - $i++; - $est_attribuee[$adrid_] = 1; - } -} - -$nb_adr = $i - 1; -$page->assign_by_ref('ordre_adrid',$ordre_des_adrid); -$page->assign('nb_adr',$nb_adr+1); - -$page->assign('adresses', $adresses); - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/modules/profile/assign_poly.inc.php b/modules/profile/assign_poly.inc.php deleted file mode 100644 index d423fa2..0000000 --- a/modules/profile/assign_poly.inc.php +++ /dev/null @@ -1,39 +0,0 @@ -assign('binets', $res->fetchAllAssoc()); - -$res = XDB::query( - "SELECT text,id - FROM groupesx_ins, groupesx_def - WHERE groupesx_def.id=groupesx_ins.gid AND guid={?}", $uid); -$page->assign('groupesx', $res->fetchAllAssoc()); - -$page->assign('section', $section); - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/modules/profile/get_adresses.inc.php b/modules/profile/get_adresses.inc.php deleted file mode 100644 index 2f653b0..0000000 --- a/modules/profile/get_adresses.inc.php +++ /dev/null @@ -1,128 +0,0 @@ -fetchColumn(); - -//recuperation des donnees de la bd -$res = XDB::iterRow( - "SELECT - FIND_IN_SET('res-secondaire', statut), FIND_IN_SET('courrier', statut), - FIND_IN_SET('active', statut), FIND_IN_SET('temporaire', statut), - adr1, adr2, adr3, postcode, city, cityid, - a.country, region, regiontxt, pub, - gp.pays AS countrytxt, gp.display - FROM adresses AS a INNER JOIN geoloc_pays AS gp ON(gp.a2 = a.country) - WHERE uid = {?} AND NOT FIND_IN_SET('pro',statut) ".$sql_order -, S::v('uid', -1) -); - -$nb_adr = $res->total(); - -for ($i = 0; $i < $nb_adr; $i++) { - $adrid = $adrids[$i]; - $adresses[$adrid]['adrid'] = $adrid; - list( - $adresses[$adrid]['secondaire'], $adresses[$adrid]['courrier'], - $adresses[$adrid]['active'], $adresses[$adrid]['temporaire'], - $adresses[$adrid]['adr1'], $adresses[$adrid]['adr2'], $adresses[$adrid]['adr3'], $adresses[$adrid]['postcode'], $adresses[$adrid]['city'], $adresses[$adrid]['cityid'], - $adresses[$adrid]['country'], $adresses[$adrid]['region'], $adresses[$adrid]['regiontxt'], - $adresses[$adrid]['pub'], - $adresses[$adrid]['countrytxt'],$adresses[$adrid]['display']) = $res->next(); - $adresses[$adrid]['nouvelle'] = 'modif'; - $adresses[$adrid]['numero_formulaire'] = -1; - require_once('geoloc.inc.php'); - $adresses[$adrid]['txt'] = get_address_text($adresses[$adrid]); -} - -$restels = XDB::iterator( - "SELECT - t.adrid, telid, tel_type, t.tel_pub, t.tel - FROM tels AS t INNER JOIN adresses AS a ON(t.uid = a.uid AND t.adrid = a.adrid) - WHERE t.uid = {?} AND NOT FIND_IN_SET('pro',statut) ORDER BY t.adrid, tel_type DESC, telid" -, S::v('uid', -1) -); -while ($tel = $restels->next()) { - $adrid = $tel['adrid']; - unset($tel['adrid']); - if (!isset($adresses[$adrid]['tels'])) - $adresses[$adrid]['tels'] = array($tel); - else - $adresses[$adrid]['tels'][] = $tel; -} -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/modules/profile/get_poly.inc.php b/modules/profile/get_poly.inc.php deleted file mode 100644 index 85c2ee7..0000000 --- a/modules/profile/get_poly.inc.php +++ /dev/null @@ -1,58 +0,0 @@ -fetchOneCell(); - -replace_ifset($section,'section'); - -/************* gestion des binets ************/ -if (Env::has('binet_op')) { - // retrait binet - if( (Env::v('binet_op', '')=='retirer')&&(Env::i('binet_id', 0) != 0)) { - XDB::execute("DELETE FROM binets_ins WHERE user_id = {?} AND binet_id = {?}", S::v('uid', -1), Env::i('binet_id', -1)); - } - // ajout binet - if (Env::v('binet_op')=="ajouter" && (Env::i('binet_id', 0) != 0)) { - XDB::execute("INSERT INTO binets_ins (user_id,binet_id) VALUES({?}, {?})", S::v('uid', -1), Env::i('binet_id', -1)); - } -} -/************* gestion des groupes X ************/ -if (Env::has('groupex_op')) { - // retrait groupe X - if (Env::v('groupex_op')=="retirer" && (Env::i('groupex_id', 0) != 0)) { - XDB::execute("DELETE FROM groupesx_ins WHERE guid = {?} AND gid = {?}", S::v('uid', -1), Env::i('groupex_id', -1)); - } - // ajout groupe X - if (Env::v('groupex_op')=="ajouter" && (Env::i('groupex_id', 0) != 0)) { - XDB::execute("INSERT INTO groupesx_ins (guid, gid) VALUES ({?}, {?})", S::v('uid', -1), Env::i('groupex_id', -1)); - } -} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/modules/profile/groups.inc.php b/modules/profile/groups.inc.php index 40b8b61..dcc8298 100644 --- a/modules/profile/groups.inc.php +++ b/modules/profile/groups.inc.php @@ -19,26 +19,91 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -class ProfileGroups extends ProfilePage +class ProfileSection implements ProfileSetting { - protected $pg_template = 'profile/poly.tpl'; + public function value(ProfilePage &$page, $field, $value, &$success) + { + $success = true; + if (is_null($value)) { + $res = XDB::query("SELECT section + FROM auth_user_md5 + WHERE user_id = {?}", + S::i('uid')); + return intval($res->fetchOneCell()); + } + return intval($value); + } - public function __construct(PlWizard &$wiz) + public function save(ProfilePage &$page, $field, $value) { - parent::__construct($wiz); - $this->settings['section'] = $this->settings['binets'] - = $this->settings['groupesx'] - = null; + XDB::execute("UPDATE auth_user_md5 + SET section = {?} + WHERE user_id = {?}", + $value, S::i('uid')); + } +} + +class ProfileGroup implements ProfileSetting +{ + private $table; + private $user_field; + private $group_field; + + public function __construct($table, $user, $group) + { + $this->table = $table; + $this->user_field = $user; + $this->group_field = $group; } - protected function fetchData() + public function value(ProfilePage &$page, $field, $value, &$success) { - parent::fetchData(); + if (is_null($value)) { + $value = array(); + $res = XDB::iterRow("SELECT g.id, g.text + FROM {$this->table}_def AS g + INNER JOIN {$this->table}_ins AS i ON (i.{$this->group_field} = g.id) + WHERE i.{$this->user_field} = {?}", + S::i('uid')); + while (list($gid, $text) = $res->next()) { + $value[intval($gid)] = $text; + } + } + if (!is_array($value)) { + $value = array(); + } + ksort($value); + $success = true; + return $value; } - public function prepare(PlatalPage &$page) + public function save(ProfilePage &$page, $field, $value) + { + XDB::execute("DELETE FROM {$this->table}_ins + WHERE {$this->user_field} = {?}", + S::i('uid')); + if (!count($value)) { + return; + } + $insert = array(); + foreach ($value as $id=>$text) { + $insert[] = '(' . S::i('uid') . ", $id)"; + } + XDB::execute("INSERT INTO {$this->table}_ins ({$this->user_field}, {$this->group_field}) + VALUES " . implode(',', $insert)); + } +} + +class ProfileGroups extends ProfilePage +{ + protected $pg_template = 'profile/groups.tpl'; + + public function __construct(PlWizard &$wiz) { - parent::prepare($page); + parent::__construct($wiz); + $this->settings['section'] = new ProfileSection(); + $this->settings['binets'] = new ProfileGroup('binets', 'user_id', 'binet_id'); + $this->settings['groupesx'] = new ProfileGroup('groupesx', 'guid', 'gid'); } } diff --git a/modules/profile/update_adresses.inc.php b/modules/profile/update_adresses.inc.php deleted file mode 100644 index 0ec632f..0000000 --- a/modules/profile/update_adresses.inc.php +++ /dev/null @@ -1,137 +0,0 @@ -fetchOneCell(); - if (!$newid) $newid = 0; - XDB::execute( "INSERT INTO tels SET tel_type = {?}, tel_pub = {?}, - tel = {?}, uid = {?}, adrid = {?}, telid = {?}", - $tel['tel_type'], $tel['tel_pub'], $tel['tel'], - S::v('uid', -1), $adrid, $newid); -} - -foreach ($adresses as $adrid => $adr) { - if ($adr['nouvelle'] != 'new') { - // test si on vient de creer cette adresse dans verif_adresse.inc.php - - //construction des bits - $statut = ""; - if ($adr["secondaire"]) $statut .= 'res-secondaire,'; - if ($adr["courrier"]) $statut .= 'courrier,'; - if ($adr["active"]) $statut .= 'active,'; - if ($adr["temporaire"]) $statut .= 'temporaire,'; - if (! empty($statut)) $statut = substr($statut, 0, -1); - $precise_coords = ""; - if (isset($adr['precise_lat']) && isset($adr['precise_lon'])) { - $precise_coords = ", glat = '".$adr['precise_lat']."'"; - $precise_coords .= ", glng = '".$adr['precise_lon']."'"; - } - - if ($adr["nouvelle"] == 'ajout') { - //nouvelle adresse - if (is_adr_empty($adrid)) { - unset($adresses[$adrid]); - continue; - } - XDB::execute("INSERT INTO adresses SET adr1 = {?}, adr2 = {?}, - adr3 = {?}, postcode = {?}, city = {?}, cityid = {?}, - country = {?}, region = {?}, regiontxt = {?}, - pub = {?}, datemaj = NOW(), statut = {?}, uid = {?}, - adrid = {?}".$precise_coords, $adr['adr1'], $adr['adr2'], - $adr['adr3'], $adr['postcode'], $adr['city'], - $adr['cityid'], $adr['country'], $adr['region'], - $adr['regiontxt'], $adr['pub'], $statut, - S::v('uid', -1), $adrid); - $telsvalues = ""; - foreach ($adr['tels'] as $tel) { - insert_new_tel($adrid, $tel); - } - } else { - //c'est une mise à jour - XDB::execute("UPDATE adresses SET adr1 = {?}, adr2 = {?}, - adr3 = {?}, postcode = {?}, city = {?}, cityid = {?}, - country = {?}, region = {?}, regiontxt = {?}, - pub = {?}, datemaj = NOW(), statut = {?}".$precise_coords." - WHERE uid = {?} AND adrid = {?}", $adr['adr1'], - $adr['adr2'], $adr['adr3'], $adr['postcode'], - $adr['city'], $adr['cityid'], $adr['country'], - $adr['region'], $adr['regiontxt'], $adr['pub'], - $statut, S::v('uid', -1), $adrid); - foreach ($adr['tels'] as $tel) { - if (isset($tel['new_tel'])) { - if ($tel['new_tel']) - insert_new_tel($adrid, $tel); - } else { - if ($tel['tel'] != "") { - XDB::execute( - "UPDATE tels SET - tel_type = {?}, - tel_pub = {?}, - tel = {?} - WHERE - uid = {?} AND - adrid = {?} AND - telid = {?}", - $tel['tel_type'], - $tel['tel_pub'], - $tel['tel'], - S::v('uid', -1), - $adrid, - $tel['telid']); - } else { - XDB::execute( - "DELETE FROM tels WHERE - uid = {?} AND - adrid = {?} AND - telid = {?}", - S::v('uid', -1), - $adrid, - $tel['telid']); - } - } - } - }// fin nouvelle / ancienne adresse - }//fin if nouvellement crée -}//fin foreach - - -//on vire les adresses vides : -if(isset($adresses)){ // s'il y en a - reset($adresses); - foreach($adresses as $adrid => $adr){ - // on vire les tels vides - foreach ($adr['tels'] as $telid => $tel) { - if ($tel['tel'] == '') unset($adresses[$adrid]['tels'][$telid]); - } - if(is_adr_empty($adrid)){ - delete_address($adrid); - } - } -} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/modules/profile/update_poly.inc.php b/modules/profile/update_poly.inc.php deleted file mode 100644 index c6562ab..0000000 --- a/modules/profile/update_poly.inc.php +++ /dev/null @@ -1,27 +0,0 @@ - diff --git a/modules/profile/verif_adresses.inc.php b/modules/profile/verif_adresses.inc.php deleted file mode 100644 index 953f2c1..0000000 --- a/modules/profile/verif_adresses.inc.php +++ /dev/null @@ -1,206 +0,0 @@ - retourne 1 - return 1; - reset($adresses); - $i = 0; - $adrid_array = Array(); - foreach($adresses as $numero => $adr){ - $adrid_array[$i] = $numero; - $i++; - } - sort($adrid_array,SORT_NUMERIC); // classe les adrid dans l'ordre croissant - $new_adrid = 1; - while(list($key,$current_adrid) = each($adrid_array)){ - if($current_adrid == $new_adrid) - $new_adrid++; - else - return $new_adrid; //s'ils sont differents, il y a un trou dans la liste des adrid donc new_adrid convient - } - //si aucun convient, on retourne le plus grand des adrid actuel + 1 - return $new_adrid; -} - -function generate_new_telid($adr){ - $i = 0; - $telid_array = Array(); - foreach($adr['tels'] as $tel){ - $telid_array[$i] = $tel['telid']; - $i++; - } - sort($telid_array,SORT_NUMERIC); // classe les adrid dans l'ordre croissant - $new_telid = 0; - foreach($telid_array as $current_telid) - if ($current_telid == $new_telid) - $new_telid ++; - else - return $new_telid;//s'ils sont differents, il y a un trou dans la liste des telid donc new_telid convient - //si aucun convient, on retourne le plus grand des telid actuel + 1 - return $new_telid; -} - -function replace_ifset_adr($varname, $i){ - $tab = Env::v($varname, Array()); - if (isset($tab[$i])) - $GLOBALS['adresses'][$i][$varname] = $tab[$i]; -} - -function replace_ifset_tel($varname, $i, $t){ - $tab = Env::v($varname.$t, Array()); - if (isset($tab[$i])) - $GLOBALS['adresses'][$i]['tels'][$t][$varname] = $tab[$i]; -} - -function get_adr_arg($varname, $i) { - $tab = Env::v($varname, Array()); - return @$tab[$i]; -} - -function set_flag_adr($varname,$i){ - $tab = Env::v($varname, Array()); - if (isset($tab[$i])){ - $GLOBALS['adresses'][$i][$varname] = 1; - } - else - $GLOBALS['adresses'][$i][$varname] = '0'; -} - -function replace_tel($i, $t){ - replace_ifset_tel('telid', $i, $t); - replace_ifset_tel('tel', $i, $t); - replace_ifset_tel('tel_pub', $i, $t); - replace_ifset_tel('tel_type', $i, $t); - replace_ifset_tel('new_tel', $i, $t); -} - -function replace_address($i){ - global $adresses, $nb_tel_max; - if(!isset($adresses[$i])){ - $adresses[$i]['nouvelle'] = 'ajout'; - $adresses[$i]['adrid'] = $i; - } - - replace_ifset_adr('secondaire', $i); - set_flag_adr('courrier', $i); - replace_ifset_adr('temporaire', $i); - if(Env::i('adrid_active', $i+1) == $i) - $adresses[$i]['active'] = 1; - else - $adresses[$i]['active'] = 0; - replace_ifset_adr('adr1', $i); - replace_ifset_adr('adr2', $i); - replace_ifset_adr('adr3', $i); - replace_ifset_adr('postcode', $i); - replace_ifset_adr('city', $i); - replace_ifset_adr('cityid', $i); - replace_ifset_adr('country', $i); - replace_ifset_adr('region', $i); - replace_ifset_adr('pub', $i); - - for ($telid = 0; $telid <= $nb_tel_max; $telid++) { - $tab = Env::v('telid'.$telid, Array()); - if(isset($tab[$i])){ //ce telid etait donc present dans le formulaire - replace_tel($i, $telid); - } - } - - if (!get_adr_arg('parsevalid', $i)) replace_ifset_adr('txt', $i); - $tab = Env::v('numero_formulaire', Array()); - if($tab[$i]) - $adresses[$i]['numero_formulaire'] = $tab[$i]; - else - $adresses[$i]['numero_formulaire'] = -1; -} - -function geoloc_adresse($i) { - global $adresses; - $change = Env::v('change'.$i); - if (get_adr_arg('parsevalid', $i) || ($adresses[$i]['txt'] && $change) || (!$adresses[$i]['cityid'])) { - require_once('geoloc.inc.php'); - // erases the previous address (but not the phone or pub) - $adresses[$i] = array_merge($adresses[$i], empty_address()); - // localize new address - $new = get_address_infos($adresses[$i]['txt']); - if (compare_addresses_text($adresses[$i]['txt'], $geotxt = get_address_text($new)) || get_adr_arg('parsevalid', $i)) - $adresses[$i] = array_merge($adresses[$i], $new); - else { - $adresses[$i] = array_merge($adresses[$i], cut_address($adresses[$i]['txt'])); - $adresses[$i]['geoloc'] = $geotxt; - $adresses[$i]['geoloc_cityid'] = $new['cityid']; - } - } - $adresses[$i]['txt'] = get_address_text($adresses[$i]); -} - -//remplace par les eventuelles nouvelles valeurs : -for ($adrid = 1; $adrid <= $nb_adr_max; $adrid++) { - $tab = Env::v('adrid', Array()); - if(isset($tab[$adrid])){ //cet adrid etait donc present dans le formulaire - replace_address($adrid); - } - if (isset($adresses[$adrid]['txt'])) - geoloc_adresse($adrid); -} - -if ($opened_tab == 'adresses' && Env::has('modifier')){ // on ne valide que qd on vient du formulaire -$adresses_principales = 0; -reset($adresses); -foreach($adresses as $adrid => $adr) { - //validité de chaque adresse - $description = (($adr['numero_formulaire'] > 0)?"Adresse n°{$adr['numero_formulaire']}":"Nouvelle adresse"); - if (strlen(strtok($adr['adr1'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr1'])) { - $page->trig("Le champ '$description - Ligne 1' contient un caractère interdit."); - } - if (strlen(strtok($adr['adr2'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr2'])) { - $page->trig("Le champ '$description - Ligne 2' contient un caractère interdit."); - } - if (strlen(strtok($adr['adr3'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['adr3'])) { - $page->trig("Le champ '$description - Ligne 3' contient un caractère interdit."); - } - if (strlen(strtok($adr['postcode'],"<>{}@~?!§*`|%$^=+")) < strlen($adr['postcode'])) { - $page->trig("Le champ '$description - Code Postal' contient un caractère interdit."); - } - if (is_array($adr['tels'])) { - foreach ($adr['tels'] as $tel) { - if (strlen(strtok($tel['tel'],"<>{}@&#~:;?,!§*_`[]|%$^=\"")) < strlen($tel['tel'])) { - $page->trig("Le champ '$description - ".$tel['tel_type']."' contient un caractère interdit."); - } - } - } - if(!$adr['secondaire']) { - if($adresses_principales == 1) { //deja une adresse principale - $page->trig("Tu ne peux avoir qu'une résidence principale."); - $adresses_principales++; //pour eviter de repeter le message plusieurs fois - } else { - $adresses_principales = 1; - } - } -} - -} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/modules/profile/verif_poly.inc.php b/modules/profile/verif_poly.inc.php deleted file mode 100644 index 4c844bd..0000000 --- a/modules/profile/verif_poly.inc.php +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/templates/profile/poly.tpl b/templates/profile/groups.tpl similarity index 63% rename from templates/profile/poly.tpl rename to templates/profile/groups.tpl index 866d6a0..cf31e16 100644 --- a/templates/profile/poly.tpl +++ b/templates/profile/groups.tpl @@ -42,13 +42,38 @@ function update(type) { - if (document.forms.prof_annu[type + '_sel'].value == '0') { + var val = document.forms.prof_annu[type + '_sel'].value; + if (val == '0' || document.getElementById(type + '_' + val) != null) { document.getElementById(type + '_add').style.display = 'none'; } else { document.getElementById(type + '_add').style.display = ''; } } + function remove(cat, id) + { + $('#' + cat + '_' + id).remove(); + } + + function add(cat) + { + var cb = document.forms.prof_annu[cat + '_sel']; + var id = cb.value; + var text = cb.options[cb.selectedIndex].text; + var html = '' + + ' ' + + ' ' + + ' ' + + ' ' + + text + + ' ' + + ' cross' + + ' ' + + ' ' + + ''; + $('#' + cat).after(html); + } + //]]> {/literal} @@ -76,32 +101,54 @@ - + - {select_db_table table="binets_def" valeur=0 champ="text" pad='1'} - {icon name="add" title="Ajouter ce binet"} + {icon name="add" title="Ajouter ce binet"} + + + {foreach item=text key=bid from=$binets} + + + + + + {$text} + {icon name="cross" title="Supprimer ce binet"} + {/foreach} - + Groupe(s) X - {select_db_table table="groupesx_def" valeur=0 champ="text" pad='1'} - {icon name="add" title="Ajouter ce groupe X"} + {icon name="add" title="Ajouter ce groupe X"} + + + {foreach item=text key=bid from=$groupesx} + + + + + + {$text} + {icon name="cross" title="Supprimer ce groupe X"} + {/foreach} {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} -- 2.1.4