Splits jobs interface between user and entreprise data, polishes user related part...
authorStéphane Jacob <jacou@melix.net>
Wed, 5 Nov 2008 23:43:51 +0000 (00:43 +0100)
committerStéphane Jacob <jacou@melix.net>
Mon, 8 Dec 2008 20:16:50 +0000 (21:16 +0100)
15 files changed:
htdocs/css/default.css
htdocs/javascript/profile.js
modules/profile.php
modules/profile/jobs.inc.php
modules/search.php
modules/search/classes.inc.php
modules/search/search.inc.php
templates/include/emails.combobox.tpl
templates/profile/jobs.job.tpl
templates/profile/jobs.secteur.tpl
templates/profile/jobs.soussecteur.tpl [new file with mode: 0644]
templates/search/adv.form.tpl
upgrade/merge-0.0.1/connect.db.inc.php [new file with mode: 0644]
upgrade/newdirectory-0.0.1/11_jobs.sql [new file with mode: 0644]
upgrade/newdirectory-0.0.1/12_secteurs.sql [new file with mode: 0644]

index 70e0fed..a164cfa 100644 (file)
@@ -228,6 +228,18 @@ td.action {
 }
 td.action a { padding: 0px 2px 0px 2px; }
 
+div.titre {
+    color: #000000;
+    background: inherit;
+    font-weight: bold;
+}
+
+span.titre {
+    color: #000000;
+    background: inherit;
+    font-weight: bold;
+}
+
 /*******************************************************************************
     4   Tableau de choix de skins
         [ Styles pour les tableaux de types de ceux des skins ]
index 315fc38..64dc174 100644 (file)
@@ -50,6 +50,8 @@ function wizPage_onLoad(id)
         for (var i = 0 ; document.getElementById('job_' + i) != null ; ++i) {
             updateJobSecteur(i, 'job_' + i, 'jobs[' + i + ']',
                              document.forms.prof_annu["jobs[" + i + "][ss_secteur]"].value);
+            updateJobSousSecteur(i, 'job_' + i, 'jobs[' + i + ']',
+                             document.forms.prof_annu["jobs[" + i + "][sss_secteur]"].value);
         }
         setTimeout('registerEnterpriseAutocomplete(-1)', 100);
         break;
@@ -503,7 +505,22 @@ function updateJobSecteur(nb, id, pref, sel)
     if (secteur == '') {
         secteur = '-1';
     }
-    Ajax.update_html(id + '_ss_secteur', 'profile/ajax/secteur/' +nb + '/' + secteur + '/' + sel);
+    Ajax.update_html(id + '_ss_secteur', 'profile/ajax/secteur/' + nb + '/' + id + '/' + pref + '/' + secteur + '/' + sel);
+}
+
+function updateJobSousSecteur(nb, id, pref, sel)
+{
+    var ssecteur = document.forms.prof_annu[pref + '[ss_secteur]'].value;
+    if (ssecteur == '') {
+        ssecteur = '-1';
+    }
+    Ajax.update_html(id + '_sss_secteur', 'profile/ajax/ssecteur/' + nb + '/' + ssecteur + '/' + sel);
+}
+
+function displayAllSector()
+{
+    $('.sector_text').remove();
+    $('.sector').show();
 }
 
 function makeAddJob(id)
@@ -671,6 +688,20 @@ function registerEnterpriseAutocomplete(id)
         }
       }
     );
+
+    $(".sector_name").each(
+      function() {
+        if (id == -1 || this.name == "jobs[" + id + "][sss_secteur_name]") {
+            $(this).autocomplete(platal_baseurl + "search/autocomplete/sss_secteur",
+                                 {
+                                   selectOnly:1,
+                                   field:this.name,
+                                   matchSubset:0,
+                                   width:$(this).width()
+                                 });
+        }
+      }
+    );
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index a7b4b1b..7f77793 100644 (file)
@@ -39,6 +39,7 @@ class ProfileModule extends PLModule
             'profile/networking'         => $this->make_hook('networking',                 AUTH_PUBLIC),
             'profile/ajax/job'           => $this->make_hook('ajax_job',                   AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/secteur'       => $this->make_hook('ajax_secteur',               AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/ajax/ssecteur'      => $this->make_hook('ajax_ssecteur',              AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/skill'         => $this->make_hook('ajax_skill',                 AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/searchname'    => $this->make_hook('ajax_searchname',            AUTH_COOKIE, 'user', NO_AUTH),
             'javascript/education.js'    => $this->make_hook('education_js',               AUTH_COOKIE),
@@ -472,16 +473,30 @@ class ProfileModule extends PLModule
         $page->assign('fonctions', $res->fetchAllAssoc());
     }
 
-    function handler_ajax_secteur(&$page, $id, $sect, $ssect = -1)
+    function handler_ajax_secteur(&$page, $id, $jobid, $jobpref, $sect, $ssect = -1)
     {
         header('Content-Type: text/html; charset=utf-8');
-        $res = XDB::iterator("SELECT  id, label
-                                FROM  emploi_ss_secteur
-                               WHERE  secteur = {?}", $sect);
+        $res = XDB::iterator("SELECT  id, name AS label, FIND_IN_SET('optgroup', flags) AS optgroup
+                                FROM  profile_job_subsector_enum
+                               WHERE  sectorid = {?}", $sect);
         $page->changeTpl('profile/jobs.secteur.tpl', NO_SKIN);
         $page->assign('id', $id);
         $page->assign('ssecteurs', $res);
         $page->assign('sel', $ssect);
+        $page->assign('jobid', $jobid);
+        $page->assign('jobpref', $jobpref);
+    }
+
+    function handler_ajax_ssecteur(&$page, $id, $ssect, $sssect = -1)
+    {
+        header('Content-Type: text/html; charset=utf-8');
+        $res = XDB::iterator("SELECT  id, name AS label
+                                FROM  profile_job_subsubsector_enum
+                               WHERE  subsectorid = {?}", $ssect);
+        $page->changeTpl('profile/jobs.soussecteur.tpl', NO_SKIN);
+        $page->assign('id', $id);
+        $page->assign('sssecteurs', $res);
+        $page->assign('sel', $sssect);
     }
 
     function handler_ajax_skill(&$page, $cat, $id)
index fce8920..5d95ae4 100644 (file)
@@ -30,16 +30,16 @@ class ProfileJob extends ProfileGeoloc
 
     public function __construct()
     {
-        $this->pub  = new ProfilePub();
+        $this->pub    = new ProfilePub();
         $this->mail
-                    = $this->mail_new
-                    = new ProfileEmail();
-        $this->web  = new ProfileWeb();
-        $this->bool = new ProfileBool();
-        $this->checks = array('web' => array('web'),
-                              'mail_new' => array('email_new'),
-                              'mail' => array('email'),
-                              'pub' => array('pub', 'email_pub'));
+                      = $this->mail_new
+                      = new ProfileEmail();
+        $this->web    = new ProfileWeb();
+        $this->bool   = new ProfileBool();
+        $this->checks = array('web'      => array('w_web'),
+                              'mail_new' => array('w_email_new'),
+                              'mail'     => array('w_email'),
+                              'pub'      => array('pub', 'w_email_pub'));
     }
 
     private function cleanJob(ProfilePage &$page,$jobid, array &$job, &$success)
@@ -48,9 +48,9 @@ class ProfileJob extends ProfileGeoloc
         foreach ($this->checks as $obj=>&$fields) {
             $chk =& $this->$obj;
             foreach ($fields as $field) {
-                if ($field == "email_new") {
-                    if ($job['email'] == "new@example.org") {
-                        $job['email'] = $job[$field];
+                if ($field == "w_email_new") {
+                    if ($job['w_email'] == "new@example.org") {
+                        $job['w_email'] = $job[$field];
                     }
                     continue;
                 }
@@ -61,18 +61,48 @@ class ProfileJob extends ProfileGeoloc
                 }
             }
         }
-        $job['adr']['pub'] = $this->pub->value($page, 'adr_pub', @$job['adr']['pub'], $s);
-        $job['adr']['checked'] = $this->bool->value($page, 'adr_checked', @$job['adr']['checked'], $s);
-        if (!isset($job['tel'])) {
-            $job['tel'] = array();
+        if (!isset($job['sss_secteur_name'])) {
+            $res = XDB::query("SELECT  name
+                                 FROM  profile_job_subsubsector_enum
+                                WHERE  id = {?}",
+                              $job['sss_secteur']);
+            $job['sss_secteur_name'] = $res->fetchOneCell();
+        } else {
+            $res = XDB::query("SELECT  sectorid, subsectorid, id
+                                 FROM  profile_job_subsubsector_enum
+                                WHERE  name = {?}",
+                              $job['sss_secteur_name']);
+            if ($res->numRows() != 1) {
+                $success = false;
+                $job['sector_error'] = true;
+            } else {
+                list($job['secteur'], $job['ss_secteur'], $job['sss_secteur']) = $res->fetchOneRow();
+            }
+        }
+        if (!isset($job['jobid'])) {
+            $res = XDB::query("SELECT  id
+                                 FROM  profile_job_enum
+                                WHERE  name = {?}",
+                              $job['name']);
+            if ($res->numRows() != 1) {
+                $success = false;
+                $job['name_error'] = true;
+            } else {
+                $job['jobid'] = $res->fetchOneCell();
+            }
+        }
+        $job['w_adr']['pub'] = $this->pub->value($page, 'adr_pub', @$job['w_adr']['pub'], $s);
+        $job['w_adr']['checked'] = $this->bool->value($page, 'adr_checked', @$job['w_adr']['checked'], $s);
+        if (!isset($job['w_tel'])) {
+            $job['w_tel'] = array();
         }
         $profiletel = new ProfilePhones('pro', $jobid);
-        $job['tel'] = $profiletel->value($page, 'tel', $job['tel'], $s);
+        $job['w_tel'] = $profiletel->value($page, 'tel', $job['w_tel'], $s);
         unset($job['removed']);
         unset($job['new']);
-        unset($job['adr']['changed']);
-        unset($job['adr']['parsevalid']);
-        unset($job['adr']['display']);
+        unset($job['w_adr']['changed']);
+        unset($job['w_adr']['parsevalid']);
+        unset($job['w_adr']['display']);
     }
 
     public function value(ProfilePage &$page, $field, $value, &$success)
@@ -90,7 +120,7 @@ class ProfileJob extends ProfileGeoloc
         }
         foreach ($value as $key=>&$job) {
             $ls = true;
-            $this->geolocAddress($job['adr'], $s);
+            $this->geolocAddress($job['w_adr'], $s);
             $ls = ($ls && $s);
             $this->cleanJob($page, $key, $job, $s);
             $ls = ($ls && $s);
@@ -104,7 +134,7 @@ class ProfileJob extends ProfileGeoloc
     public function save(ProfilePage &$page, $field, $value)
     {
         require_once('profil.func.inc.php');
-        XDB::execute("DELETE FROM  entreprises
+        XDB::execute("DELETE FROM  profile_job
                             WHERE  uid = {?}",
                      S::i('uid'));
         XDB::execute("DELETE FROM  profile_phones
@@ -112,32 +142,16 @@ class ProfileJob extends ProfileGeoloc
                      S::i('uid'));
         $i = 0;
         foreach ($value as $jobid=>&$job) {
-            if ($job['email'] == "new@example.org") {
-                $job['email'] = $job['email_new'];
+            if ($job['w_email'] == "new@example.org") {
+                $job['w_email'] = $job['w_email_new'];
             }
-            XDB::execute("INSERT INTO  entreprises (uid, entrid, entreprise, secteur, ss_secteur,
-                                                    fonction, poste, adr1, adr2, adr3, postcode,
-                                                    city, cityid, country, region, regiontxt,
-                                                    email, web,
-                                                    pub, adr_pub, email_pub, flags,
-                                                    glat, glng)
-                               VALUES  ({?}, {?}, {?}, {?}, {?},
-                                        {?}, {?}, {?}, {?}, {?}, {?},
-                                        {?}, {?}, {?}, {?}, {?},
-                                        {?}, {?},
-                                        {?}, {?}, {?}, {?},
-                                        {?}, {?})",
-                         S::i('uid'), $i, $job['name'], $job['secteur'], $job['ss_secteur'],
-                         $job['fonction'], $job['poste'], $job['adr']['adr1'], $job['adr']['adr2'], $job['adr']['adr3'],
-                         $job['adr']['postcode'],
-                         $job['adr']['city'], $job['adr']['cityid'], $job['adr']['country'], $job['adr']['region'], 
-                         $job['adr']['regiontxt'],
-                         $job['email'], $job['web'],
-                         $job['pub'], $job['adr']['pub'], $job['email_pub'],
-                         $job['adr']['checked'] ? 'geoloc' : '', $job['adr']['precise_lat'],
-                         $job['adr']['precise_lon']);
+            XDB::execute("INSERT INTO  profile_job (uid, id, functionid, description, sectorid, subsectorid,
+                                                    subsubsectorid, email, url, pub, email_pub, jobid)
+                               VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})",
+                         S::i('uid'), $i, $job['fonction'], $job['description'], $job['secteur'], $job['ss_secteur'],
+                         $job['sss_secteur'], $job['w_email'], $job['w_web'], $job['pub'], $job['w_email_pub'], $job['jobid']);
             $profiletel = new ProfilePhones('pro', $jobid);
-            $profiletel->saveTels('tel', $job['tel']);
+            $profiletel->saveTels('tel', $job['w_tel']);
             $i++;
         }
     }
@@ -174,50 +188,55 @@ class ProfileJobs extends ProfilePage
         $this->values['corps'] = $res->fetchOneAssoc();
 
         // Build the jobs tree
-        $res = XDB::iterRow("SELECT  e.entrid, e.entreprise, e.secteur, e.ss_secteur,
-                                     e.fonction, e.poste, e.adr1, e.adr2, e.adr3,
+        $res = XDB::iterRow("SELECT  j.id, je.name, j.functionid, j.sectorid, j.subsectorid,
+                                     j.subsubsectorid, j.description, e.adr1, e.adr2, e.adr3,
                                      e.postcode, e.city, e.cityid, e.region, e.regiontxt,
                                      e.country, gp.pays, gp.display,
                                      FIND_IN_SET('geoloc', flags),
-                                     e.email, e.web, e.pub,
-                                     e.adr_pub, e.email_pub,
-                                     e.glat AS precise_lat, e.glng AS precise_lon
-                               FROM  entreprises AS e
-                          LEFT JOIN  geoloc_pays AS gp ON(gp.a2 = e.country)
-                              WHERE  e.uid = {?} AND entreprise != ''
+                                     j.email, j.url, j.pub,
+                                     e.adr_pub, j.email_pub,
+                                     e.glat, e.glng, s.name
+                               FROM  profile_job                   AS j
+                          LEFT JOIN  profile_job_enum              AS je ON (j.jobid = je.id)
+                          LEFT JOIN  entreprises                   AS e  ON (j.uid = e.uid AND j.id = e.entrid)
+                          LEFT JOIN  geoloc_pays                   AS gp ON (gp.a2 = e.country)
+                          LEFT JOIN  profile_job_subsubsector_enum AS s  ON (s.id = j.subsubsectorid)
+                              WHERE  j.uid = {?}
                            ORDER BY  entrid", S::i('uid'));
         $this->values['jobs'] = array();
-        while (list($id, $name, $secteur, $ss_secteur, $fonction, $poste,
-                    $adr1, $adr2, $adr3, $postcode, $city, $cityid,
-                    $region, $regiontxt, $country, $countrytxt, $display,
-                    $checked, $email, $web,
-                    $pub, $adr_pub, $email_pub, $glat, $glng
+        while (list($id, $name, $function, $secteur, $ss_secteur, $sss_secteur, $description,
+                    $w_adr1, $w_adr2, $w_adr3, $w_postcode, $w_city, $w_cityid,
+                    $w_region, $w_regiontxt, $w_country, $w_countrytxt, $w_display,
+                    $w_checked, $w_email, $w_web,
+                    $pub, $w_adr_pub, $w_email_pub, $w_glat, $w_glng, $sss_secteur_name
                    ) = $res->next()) {
-            $this->values['jobs'][] = array('id'         => $id,
-                                            'name'       => $name,
-                                            'secteur'    => $secteur,
-                                            'ss_secteur' => $ss_secteur,
-                                            'fonction'   => $fonction,
-                                            'poste'      => $poste,
-                                            'adr'        => array('adr1'       => $adr1,
-                                                                  'adr2'       => $adr2,
-                                                                  'adr3'       => $adr3,
-                                                                  'postcode'   => $postcode,
-                                                                  'city'       => $city,
-                                                                  'cityid'     => $cityid,
-                                                                  'region'     => $region,
-                                                                  'regiontxt'  => $regiontxt,
-                                                                  'country'    => $country,
-                                                                  'countrytxt' => $countrytxt,
-                                                                  'display'    => $display,
-                                                                  'pub'        => $adr_pub,
-                                                                  'checked'    => $checked,
-                                                                  'precise_lat'=> $glat,
-                                                                  'precise_lon'=> $glng),
-                                            'email'      => $email,
-                                            'web'        => $web,
-                                            'pub'        => $pub,
-                                            'email_pub'  => $email_pub);
+            $this->values['jobs'][] = array('id'               => $id,
+                                            'name'             => $name,
+                                            'fonction'         => $function,
+                                            'secteur'          => $secteur,
+                                            'ss_secteur'       => $ss_secteur,
+                                            'sss_secteur'      => $sss_secteur,
+                                            'sss_secteur_name' => $sss_secteur_name,
+                                            'description'      => $description,
+                                            'w_adr'            => array('adr1'        => $w_adr1,
+                                                                        'adr2'        => $w_adr2,
+                                                                        'adr3'        => $w_adr3,
+                                                                        'postcode'    => $w_postcode,
+                                                                        'city'        => $w_city,
+                                                                        'cityid'      => $w_cityid,
+                                                                        'region'      => $w_region,
+                                                                        'regiontxt'   => $w_regiontxt,
+                                                                        'country'     => $w_country,
+                                                                        'countrytxt'  => $w_countrytxt,
+                                                                        'display'     => $w_display,
+                                                                        'pub'         => $w_adr_pub,
+                                                                        'checked'     => $w_checked,
+                                                                        'precise_lat' => $w_glat,
+                                                                        'precise_lon' => $w_glng),
+                                            'w_email'          => $w_email,
+                                            'w_web'            => $w_web,
+                                            'pub'              => $pub,
+                                            'w_email_pub'      => $w_email_pub);
         }
 
         $res = XDB::iterator("SELECT  link_id AS jobid, tel_type AS type, pub, display_tel AS tel, comment
@@ -237,16 +256,16 @@ class ProfileJobs extends ProfilePage
                 break;
             }
             $job =& $this->values['jobs'][$i];
-            if (!isset($job['tel'])) {
-                $job['tel'] = array();
+            if (!isset($job['w_tel'])) {
+                $job['w_tel'] = array();
             }
             if ($job['id'] == $jobid) {
-                $job['tel'][] = $tel;
+                $job['w_tel'][] = $tel;
             }
         }
         foreach ($this->values['jobs'] as $id=>&$job) {
-            if (!isset($job['tel'])) {
-                $job['tel'] = array();
+            if (!isset($job['w_tel'])) {
+                $job['w_tel'] = array();
             }
             unset($job['id']);
         }
@@ -276,8 +295,8 @@ class ProfileJobs extends ProfilePage
         require_once "emails.combobox.inc.php";
         fill_email_combobox($page);
 
-        $page->assign('secteurs', XDB::iterator("SELECT  id, label
-                                                   FROM  emploi_secteur"));
+        $page->assign('secteurs', XDB::iterator("SELECT  id, name AS label
+                                                   FROM  profile_job_sector_enum"));
         $page->assign('fonctions', XDB::iterator("SELECT  id, fonction_fr, FIND_IN_SET('titre', flags) AS title
                                                     FROM  fonctions_def
                                                 ORDER BY  id"));
index 582de73..9761dd4 100644 (file)
@@ -166,7 +166,7 @@ class SearchModule extends PLModule
             $textFields = array(
                 'country'         => array('field' => 'a2', 'table' => 'geoloc_pays', 'text' => 'pays', 'exact' => false),
                 'fonction'        => array('field' => 'id', 'table' => 'fonctions_def', 'text' => 'fonction_fr', 'exact' => true),
-                'secteur'         => array('field' => 'id', 'table' => 'emploi_secteur', 'text' => 'label', 'exact' => false),
+                'secteur'         => array('field' => 'id', 'table' => 'profile_job_sector_enum', 'text' => 'name', 'exact' => false),
                 'nationalite'     => array('field' => 'a2', 'table' => 'geoloc_pays', 'text' => 'nat', 'exact' => 'false'),
                 'binet'           => array('field' => 'id', 'table' => 'binets_def', 'text' => 'text', 'exact' => false),
                 'networking_type' => array('field' => 'network_type', 'table' => 'profile_networking_enum',
@@ -251,6 +251,7 @@ class SearchModule extends PLModule
         $beginwith = true;
         $field2 = false;
         $qsearch = str_replace(array('%', '_'), '', $q);
+        $distinct = true;
 
         switch ($type) {
           case 'binetTxt':
@@ -283,20 +284,21 @@ class SearchModule extends PLModule
             $realid = '`geoloc_pays`.`a2`';
             break;
           case 'entreprise':
-            $db = '`entreprises`';
-            $field = '`entreprise`';
-            $unique = '`uid`';
+            $db     = 'profile_job_enum INNER JOIN
+                       profile_job ON (profile_job.jobid = profile_job_enum.id)';
+            $field  = 'profile_job_enum.name';
+            $unique = 'profile_job.uid';
             break;
           case 'firstname':
             $field = '`prenom`';
             $beginwith = false;
             break;
           case 'fonctionTxt':
-            $db = '`fonctions_def` INNER JOIN
-                   `entreprises` ON(`entreprises`.`fonction` = `fonctions_def`.`id`)';
-            $field = '`fonction_fr`';
-            $unique = '`uid`';
-            $realid = '`fonctions_def`.`id`';
+            $db        = 'fonctions_def INNER JOIN
+                          profile_job ON (profile_job.fonctionid = fonctions_def.id)';
+            $field     = 'fonction_fr';
+            $unique    = 'uid';
+            $realid    = 'fonctions_def.id';
             $beginwith = false;
             break;
           case 'groupexTxt':
@@ -331,10 +333,10 @@ class SearchModule extends PLModule
             $db = '`auth_user_quick`';
             $beginwith = false;
             break;
-          case 'poste':
-            $db = '`entreprises`';
-            $field = '`poste`';
-            $unique = '`uid`';
+          case 'description':
+            $db     = 'profile_job';
+            $field  = 'description';
+            $unique = 'uid';
             break;
           case 'schoolTxt':
             $db = 'profile_education_enum INNER JOIN
@@ -346,12 +348,19 @@ class SearchModule extends PLModule
                 $beginwith = false;
             break;
           case 'secteurTxt':
-            $db = '`emploi_secteur` INNER JOIN
-                   `entreprises` ON(`entreprises`.`secteur` = `emploi_secteur`.`id`)';
-            $field = '`emploi_secteur`.`label`';
-            $realid = '`emploi_secteur`.`id`';
-            $unique = '`uid`';
+            $db        = 'profile_job_sector_enum INNER JOIN
+                          profile_job ON (profile_job.sectorid = profile_job_sector_enum.id)';
+            $field     = 'profile_job_sector_enum.name';
+            $realid    = 'profile_job_sector_enum.id';
+            $unique    = 'uid';
+            $beginwith = false;
+            break;
+          case 'sss_secteur':
+            $db        = 'profile_job_subsubsector_enum';
+            $field     = 'name';
             $beginwith = false;
+            $unique    = 'name';
+            $distinct  = false;
             break;
           case 'sectionTxt':
             $db = '`sections` INNER JOIN
@@ -378,14 +387,14 @@ class SearchModule extends PLModule
             $field2_t = make_field_test($field2, $beginwith);
             $field_select = 'IF(' . $field_t . ', ' . $field . ', ' . $field2. ')';
         }
-        $list = XDB::iterator('SELECT  ' . $field_select . ' AS field,
-                                       COUNT(DISTINCT ' . $unique . ') AS nb
-                                       . ($realid ? (', ' . $realid . ' AS id') : '') . '
+        $list = XDB::iterator('SELECT  ' . $field_select . ' AS field'
+                                       . ($distinct ? (', COUNT(DISTINCT ' . $unique . ') AS nb') : '')
+                                       . ($realid ? (', ' . $realid . ' AS id') : '') . '
                                  FROM  ' . $db . '
                                 WHERE  ' . $field_t .
                                         ($field2 ? (' OR ' . $field2_t) : '') . '
                              GROUP BY  ' . $field_select . '
-                             ORDER BY  nb DESC
+                             ORDER BY  ' . ($distinct ? 'nb DESC' : $field_select) . '
                                 LIMIT  11',
                                $qsearch, $qsearch, $qsearch, $qsearch, $qsearch, $qsearch, $qsearch, $qsearch,
                                $qsearch, $qsearch, $qsearch, $qsearch, $qsearch, $qsearch, $qsearch, $qsearch);
@@ -398,7 +407,9 @@ class SearchModule extends PLModule
                 $res .= $q."|-1\n";
             } else {
                 $res .= $result['field'].'|';
-                $res .= $result['nb'];
+                if (isset($result['nb'])) {
+                    $res .= $result['nb'];
+                }
                 if (isset($result['id'])) {
                     $res  .= '|'.$result['id'];
                 }
@@ -474,8 +485,10 @@ class SearchModule extends PLModule
             $db = '`sections`';
             break;
           case 'secteur':
-            $db = '`emploi_secteur`';
-            $field = '`label`';
+            $db    = 'profile_job_sector_enum INNER JOIN
+                      profile_job ON (profile_job.sectorid = profile_job_sector_enum.id)';
+            $field = 'profile_job_sector_enum.name';
+            $id    = 'profile_job_sector_enum.id';
             break;
           default: exit();
         }
index 0fefe5d..6d81622 100644 (file)
@@ -37,7 +37,7 @@
     edu2.grad_year AS edugrad_year2, f2.field AS edufield2, edu2.program AS eduprogram2,
     ede3.name AS eduname3, ede3.url AS eduurl3, edd3.degree AS edudegree3,
     edu3.grad_year AS edugrad_year3, f3.field AS edufield3, edu3.program AS eduprogram3,
-    es.label AS secteur, ef.fonction_fr AS fonction,
+    es.name AS secteur, ef.fonction_fr AS fonction,
     IF(n1.nat=\'\',n1.pays,n1.nat) AS nat1, n1.a2 AS iso3166_1,
     IF(n2.nat=\'\',n2.pays,n2.nat) AS nat2, n2.a2 AS iso3166_2,
     IF(n3.nat=\'\',n3.pays,n3.nat) AS nat3, n3.a2 AS iso3166_3,
@@ -47,7 +47,7 @@ if (S::logged())
     $globals->search->result_fields .='
         q.profile_freetext AS freetext,
         adr.city, gp.pays AS countrytxt, gr.name AS region,
-        e.entreprise,
+        ee.name,
         nw.address AS networking_address,
         nwe.name AS networking_name,';
 else
@@ -56,7 +56,7 @@ else
         IF(adr.pub='public', adr.city, '')   AS city,
         IF(adr.pub='public', gp.pays, '')    AS countrytxt,
         IF(adr.pub='public', gr.name, '')    AS region,
-        IF(e.pub='public', e.entreprise, '') AS entreprise,
+        IF(e.pub='public', ee.name, '')      AS entreprise,
         IF(nw.pub='public', nw.address, '')  AS networking_address,
         IF(nw.pub='public', nwe.name, '')    AS networking_name,";
 @$globals->search->result_where_statement = '
@@ -76,8 +76,9 @@ else
     LEFT JOIN  profile_education_enum        AS ede3 ON (ede3.id = edu3.eduid)
     LEFT JOIN  profile_education_degree_enum AS edd3 ON (edd3.id = edu3.degreeid)
     LEFT JOIN  profile_education_field_enum  AS f3   ON (f3.id = edu3.fieldid)
-    LEFT JOIN  entreprises                   AS e    ON (e.entrid = 0 AND e.uid = u.user_id)
-    LEFT JOIN  emploi_secteur                AS es   ON (e.secteur = es.id)
+    LEFT JOIN  profile_job                   AS e    ON (e.uid = u.user_id)
+    LEFT JOIN  profile_job_enum              AS ee   ON (e.jobid = ee.id)
+    LEFT JOIN  profile_job_sector_enum       AS es   ON (es.id = e.sectorid)
     LEFT JOIN  fonctions_def                 AS ef   ON (e.fonction = ef.id)
     LEFT JOIN  geoloc_pays                   AS n1   ON (u.nationalite = n1.a2)
     LEFT JOIN  geoloc_pays                   AS n2   ON (u.nationalite2 = n2.a2)
index e988faf..9c4a8a2 100644 (file)
@@ -57,10 +57,12 @@ function advancedSearchFromInput()
     $mapField           = new MapSField('mapid',  array('sgcim.map_id'), array('adresses', 'geoloc_city_in_maps'),
                                         array('amp', 'sgcim'), array(getadr_join('amp'), 'amp.cityid = sgcim.city_id'));
 
-    $entrepriseField    = new RefSField('entreprise', array('ee.entreprise'), 'entreprises', 'ee', 'u.user_id = ee.uid', false);
-    $posteField         = new RefSField('poste', array('ep.poste'), 'entreprises', 'ep', 'u.user_id = ep.uid', false);
-    $fonctionField      = new RefSField('fonction', array('en.fonction'), 'entreprises', 'en', 'u.user_id = en.uid');
-    $secteurField       = new RefSField('secteur', array('fm.secteur'), 'entreprises', 'fm', 'u.user_id = fm.uid');
+    $entrepriseField    = new RefSField('entreprise', array('ee.name'), 'profile_job_enum', 'ee',
+                                        'u.user_id = profile_job.uid AND profile_job.jobid = profile_job_enum.id', false);
+    $posteField         = new RefSField('poste', array('ep.description'), 'profile_job', 'ep', 'u.user_id = ep.uid', false);
+    $fonctionField      = new RefSField('fonction', array('en.fonction_fr'), 'fonctions_def', 'en',
+                                        'u.user_id = profile_job.uid AND fonctions_def.id = profile_job.functionid');
+    $secteurField       = new RefSField('secteur', array('fm.sectorid'), 'profile_job', 'fm', 'u.user_id = fm.uid');
     $cvField            = new RefSField('cv', array('u.cv'), '', '', '', false);
 
     $natField           = new RefSField('nationalite', array('u.nationalite', 'u.nationalite2', 'u.nationalite3'), '', '', '');
index c5cce09..628d33a 100644 (file)
       {icon name="flag_orange" title="Visible sur l'annuaire"}
     {elseif $name neq "email"}
       <span class="flags">
-        {include file="include/flags.radio.tpl" name="`$jobpref`[email_pub]" val=$job.mail_pub}
+        {include file="include/flags.radio.tpl" name="`$jobpref`[`$prefix`email_pub]" val=$pub}
       </span>
     {/if}
     <br />
     <span class="new" style="display: none">
       <input type="text" maxlength="60" {if $error}class="error" value="{$val}"{/if} name="{if (($name neq "email_directory")
-      && ($name neq "email"))}jobs[{$i}][email_new]{else}{$name}_new{/if}"/>
+      && ($name neq "email"))}jobs[{$i}][{$prefix}email_new]{else}{$name}_new{/if}"/>
     </span>
     <script type="text/javascript">//<![CDATA[
       {literal}
index 3669c7a..a9fc99b 100644 (file)
         <div class="flags" style="float: left; text-align: left">
           {include file="include/flags.radio.tpl" name="`$jobpref`[pub]" val=$job.pub}
         </div>
-        Entreprise n°{$i+1}&nbsp;:
-        <input type="text" class="enterprise_name {if $job.name_error}error{/if}" size="35" maxlength="100"
-               name="{$jobpref}[name]" value="{$job.name}" />
+        Entreprise n°{$i+1}
         <a href="javascript:removeJob('{$jobid}', '{$jobpref}')">
           {icon name=cross title="Supprimer cet emploi"}
         </a>
       </th>
     </tr>
     <tr>
-      <td class="titre">Page Web</td>
+      <td colspan="2" class="center" style="font-style: italic">Ton entreprise</td>
+    </tr>
+    <tr>
+      <td class="titre">Nom de l'entreprise</td>
       <td>
-        <input type="text" size="35" maxlength="255" {if $job.web_error}class="error"{/if}
-               name="{$jobpref}[web]" value="{$job.web}" />
+        <input type="text" class="enterprise_name {if $job.name_error}error{/if}" size="35" maxlength="100"
+               name="{$jobpref}[name]" value="{$job.name}" />
       </td>
     </tr>
-    <tr>
+
+    <tr class="pair">
+      <td colspan="2" class="center" style="font-style: italic">Ta place dans l'entreprise</td>
+    </tr>
+    <tr class="pair sector_text">
       <td class="titre">Secteur d'activité</td>
       <td>
+        <input type="text" class="sector_name {if $job.sector_error}error{/if}" size="35" maxlength="100"
+               name="{$jobpref}[sss_secteur_name]" value="{$job.sss_secteur_name}" />
+        <a href="javascript:displayAllSector()">{icon name="table" title="Tous les secteurs"}</a>
+      </td>
+    </tr>
+    <tr class="pair sector" style="display: none">
+      <td class="titre" rowspan="3">Secteur d'activité</td>
+      <td>
         <select name="{$jobpref}[secteur]" onchange="updateJobSecteur({$i}, '{$jobid}', '{$jobpref}', ''); return true;">
           <option value="">&nbsp;</option>
           {foreach from=$secteurs item=secteur}
         </select>
       </td>
     </tr>
-    <tr>
-      <td class="titre">Sous-secteur d'activité</td>
+    <tr class="pair sector" style="display: none">
       <td id="{$jobid}_ss_secteur">
         <input type="hidden" name="{$jobpref}[ss_secteur]" value="{$job.ss_secteur|default:'-1'}" />
       </td> 
     </tr>
-    <tr>
-      <td class="titre">Poste occupé</td>
-      <td>
-        <input type="text" size="35" maxlength="120" {if $job.poste_error}class="error"{/if}
-               name="{$jobpref}[poste]" value="{$job.poste}" />
-      </td>
+    <tr class="pair sector" style="display: none">
+      <td id="{$jobid}_sss_secteur">
+        <input type="hidden" name="{$jobpref}[sss_secteur]" value="{$job.sss_secteur|default:'-1'}" />
+      </td> 
     </tr>
-    <tr>
+    <tr class="pair">
       <td class="titre">Fonction occupée</td>
       <td>
         <select name="{$jobpref}[fonction]">
         </select>
       </td>
     </tr>
-    <tr class="titre">
-      <td class="center" colspan="2">
-        <small>Si des informations font défaut dans les listes ci-dessus,
-        <a href="mailto:support@{#globals.mail.domain#}">contacte-nous</a>.</small>
+    <tr class="pair">
+      <td class="titre">Description</td>
+      <td>
+        <input type="text" size="35" maxlength="120" {if $job.description_error}class="error"{/if}
+               name="{$jobpref}[description]" value="{$job.description}" />
+      </td>
+    </tr>
+    <tr class="pair">
+      <td class="titre">Page Web</td>
+      <td>
+        <input type="text" size="35" maxlength="255" {if $job.w_web_error}class="error"{/if}
+               name="{$jobpref}[w_web]" value="{$job.w_web}" />
       </td>
     </tr>
-    {include file="include/emails.combobox.tpl" name=$jobpref|cat:'[email]' val=$job.email class="pair" i=$i error=$job.email_error}
+    {include file="include/emails.combobox.tpl" name=$jobpref|cat:'[w_email]' val=$job.w_email class="pair" i=$i error=$job.w_email_error prefix="w_" pub=$job.w_email_pub}
     <tr class="pair">
       <td colspan="2">
         <div style="float: left">
           <div class="titre">Adresse</div>
           <div class="flags">
-            {include file="include/flags.radio.tpl" name="`$jobpref`[adr][pub]" val=$job.adr.pub}
+            {include file="include/flags.radio.tpl" name="`$jobpref`[w_adr][pub]" val=$job.w_adr.pub}
           </div>
           <div style="margin-top: 20px; clear: both">
-            {include file="geoloc/form.address.tpl" name="`$jobpref`[adr]" id="`$jobid`_adr" adr=$job.adr}
+            {include file="geoloc/form.address.tpl" name="`$jobpref`[w_adr]" id="`$jobid`_adr" adr=$job.w_adr}
           </div>
         </div>
       </td>
     </tr>
     <tr class="pair">
       <td colspan="2">
-        {foreach from=$job.tel key=t item=tel}
-          <div id="{"`$jobid`_tel_`$t`"}" style="clear: both">
-            {include file="profile/phone.tpl" prefname="`$jobpref`[tel]" prefid="`$jobid`_tel" telid=$t tel=$tel}
+        {foreach from=$job.w_tel key=t item=tel}
+          <div id="{"`$jobid`_w_tel_`$t`"}" style="clear: both">
+            {include file="profile/phone.tpl" prefname="`$jobpref`[w_tel]" prefid="`$jobid`_w_tel" telid=$t tel=$tel}
           </div>
         {/foreach}
-        {if $job.tel|@count eq 0}
-          <div id="{"`$jobid`_tel_0"}" style="clear: both">
-            {include file="profile/phone.tpl" prefname="`$jobpref`[tel]" prefid="`$jobid`_tel" telid=0 tel=0}
+        {if $job.w_tel|@count eq 0}
+          <div id="{"`$jobid`_w_tel_0"}" style="clear: both">
+            {include file="profile/phone.tpl" prefname="`$jobpref`[w_tel]" prefid="`$jobid`_w_tel" telid=0 tel=0}
           </div>
         {/if}
-        <div id="{$jobid}_tel_add" class="center" style="clear: both; padding-top: 4px;">
-          <a href="javascript:addTel('{$jobid}_tel', '{$jobpref}[tel]')">
+        <div id="{$jobid}_w_tel_add" class="center" style="clear: both; padding-top: 4px;">
+          <a href="javascript:addTel('{$jobid}_w_tel', '{$jobpref}[w_tel]')">
             {icon name=add title="Ajouter un numéro de téléphone"} Ajouter un numéro de téléphone
           </a>
         </div>
index 5a22d5a..fddea2e 100644 (file)
 {**************************************************************************}
 
 <?xml version="1.0" encoding="utf-8"?>
-<select name="jobs[{$id}][ss_secteur]">
+<select name="jobs[{$id}][ss_secteur]" onchange="updateJobSousSecteur({$id}, '{$jobid}', '{$jobpref}', ''); return true;">
   <option value=""></option>
   {iterate from=$ssecteurs item=ssecteur}
+  {if $ssecteur.optgroup}
+  {if $gp}
+  </optgroup>
+  {/if}
+  <optgroup label="{$ssecteur.label}">
+  {assign var=1 name=gp}
+  {else}
   <option value="{$ssecteur.id}" {if $ssecteur.id eq $sel}selected="selected"{/if}>{$ssecteur.label}</option>
+  {/if}
+  {if $gp}
+  </optgroup>
+  {/if}
   {/iterate}
 </select>
 
diff --git a/templates/profile/jobs.soussecteur.tpl b/templates/profile/jobs.soussecteur.tpl
new file mode 100644 (file)
index 0000000..a4263ac
--- /dev/null
@@ -0,0 +1,31 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<?xml version="1.0" encoding="utf-8"?>
+<select name="jobs[{$id}][sss_secteur]">
+  <option value=""></option>
+  {iterate from=$sssecteurs item=sssecteur}
+  <option value="{$sssecteur.id}" {if $sssecteur.id eq $sel}selected="selected"{/if}>{$sssecteur.label}</option>
+  {/iterate}
+</select>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 29bdea5..8b767aa 100644 (file)
@@ -318,8 +318,8 @@ checked="checked"{/if}/>Chercher uniquement les adresses où les camarades sont
       </td>
     </tr>
     <tr>
-      <td>Poste</td>
-      <td><input type="text" class="autocomplete" name="poste" size="32" value="{$smarty.request.poste}" /></td>
+      <td>Description</td>
+      <td><input type="text" class="autocomplete" name="description" size="32" value="{$smarty.request.description}" /></td>
     </tr>
     <tr>
       <td>Secteur</td>
diff --git a/upgrade/merge-0.0.1/connect.db.inc.php b/upgrade/merge-0.0.1/connect.db.inc.php
new file mode 100644 (file)
index 0000000..4feecc7
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+ini_set('include_path', dirname(__FILE__) . '/../../core/include:'
+                      . dirname(__FILE__) . '/../../include:'
+                      . dirname(__FILE__) . '/../../core/classes:'
+                      . dirname(__FILE__) . '/../../classes:'
+                      . '/usr/share/php');
+require_once('xorg.inc.php');
+
+new Xorg('core');
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
diff --git a/upgrade/newdirectory-0.0.1/11_jobs.sql b/upgrade/newdirectory-0.0.1/11_jobs.sql
new file mode 100644 (file)
index 0000000..0830cee
--- /dev/null
@@ -0,0 +1,43 @@
+DROP TABLE IF EXISTS profile_job_enum;
+
+CREATE TABLE IF NOT EXISTS profile_job_enum (
+  id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
+  name VARCHAR(255) NOT NULL DEFAULT '',
+  acronym VARCHAR(255) NOT NULL DEFAULT '',
+  url VARCHAR(255) NOT NULL DEFAULT '',
+  holdingid INT(6) UNSIGNED DEFAULT NULL,
+  NAF_code CHAR(5) NOT NULL DEFAULT '',
+  AX_code BIGINT(10) UNSIGNED NOT NULL,
+  PRIMARY KEY (id),
+  UNIQUE KEY (name)
+) CHARSET=utf8;
+
+DROP TABLE IF EXISTS profile_job;
+
+CREATE TABLE IF NOT EXISTS profile_job (
+  id TINYINT(1) UNSIGNED NOT NULL,
+  uid INT(11) NOT NULL DEFAULT 0,
+  jobid INT(6) UNSIGNED NOT NULL DEFAULT 0,
+  functionid SMALLINT(3) UNSIGNED NOT NULL DEFAULT 0,
+  sectorid TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
+  subsectorid TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
+  subsubsectorid SMALLINT(3) UNSIGNED NOT NULL DEFAULT 0,
+  description VARCHAR(255) NOT NULL DEFAULT '',
+  url VARCHAR(255) NOT NULL DEFAULT '',
+  email VARCHAR(255) NOT NULL DEFAULT '',
+  pub ENUM('private', 'ax', 'public') DEFAULT 'private',
+  email_pub ENUM('private', 'ax', 'public') DEFAULT 'private',
+  PRIMARY KEY (uid, id)
+) CHARSET=utf8;
+
+INSERT INTO  profile_job_enum (name)
+     SELECT  DISTINCT(entreprise)
+       FROM  entreprises;
+
+INSERT INTO  profile_job (id, uid, jobid, description, email, pub, email_pub, functionid, url)
+     SELECT  e.entrid, e.uid, j.id, e.poste, e.email, e.pub, e.email_pub, e.fonction, e.web
+       FROM  entreprises      AS e
+ INNER JOIN  profile_job_enum AS j ON (e.entreprise = j.name);
+
+
+-- vim:set syntax=mysql:
diff --git a/upgrade/newdirectory-0.0.1/12_secteurs.sql b/upgrade/newdirectory-0.0.1/12_secteurs.sql
new file mode 100644 (file)
index 0000000..9ed21a6
--- /dev/null
@@ -0,0 +1,87 @@
+DROP TABLE IF EXISTS tmp_sectors;
+
+CREATE TEMPORARY TABLE IF NOT EXISTS tmp_sectors (
+  id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
+  sect CHAR(1) NOT NULL,
+  subsector TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
+  subsubsector TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
+  name VARCHAR(256) NOT NULL DEFAULT '',
+  PRIMARY KEY(id)
+) CHARSET=utf8;
+
+LOAD DATA LOCAL INFILE 'rome-v3.csv' INTO TABLE  tmp_sectors FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'
+(sect, subsector, subsubsector, name);
+
+ALTER TABLE tmp_sectors ADD INDEX (sect);
+ALTER TABLE tmp_sectors ADD INDEX (subsector);
+ALTER TABLE tmp_sectors ADD INDEX (subsubsector);
+ALTER TABLE tmp_sectors ADD INDEX (name);
+
+DROP TABLE IF EXISTS profile_job_sector_enum;
+
+CREATE TABLE IF NOT EXISTS profile_job_sector_enum (
+  id TINYINT(2) UNSIGNED NOT NULL AUTO_INCREMENT,
+  name VARCHAR(256) NOT NULL DEFAULT '',
+  sect CHAR(1) NOT NULL,
+  PRIMARY KEY(id),
+  UNIQUE KEY(name)
+) CHARSET=utf8;
+
+INSERT INTO  profile_job_sector_enum (name, sect)
+     SELECT  name, sect
+       FROM  tmp_sectors
+      WHERE  subsector = 0 AND subsubsector = 0
+   ORDER BY  id;
+
+DROP TABLE IF EXISTS profile_job_subsector_enum;
+
+CREATE TABLE IF NOT EXISTS profile_job_subsector_enum (
+  id TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
+  sectorid TINYINT(2) UNSIGNED NOT NULL,
+  flags SET('optgroup') DEFAULT '' NOT NULL,
+  name VARCHAR(256) NOT NULL DEFAULT '',
+  sect CHAR(1) NOT NULL,
+  subsector TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
+  PRIMARY KEY(id)
+) CHARSET=utf8;
+
+INSERT INTO  profile_job_subsector_enum (sectorid, name, sect, subsector)
+     SELECT  s.id, t.name, t.sect, t.subsector
+       FROM  tmp_sectors             AS t
+ INNER JOIN  profile_job_sector_enum AS s ON (t.sect = s.sect)
+      WHERE  t.subsector != 0 AND t.subsubsector = 0
+   ORDER BY  t.id;
+
+    UPDATE  profile_job_subsector_enum AS su
+INNER JOIN  profile_job_sector_enum    AS se
+       SET  flags = 'optgroup'
+     WHERE  (se.name = "Industrie" AND (su.name = "Logistique"
+                                        OR su.name = "Transport aérien et activités aéroportuaires"
+                                        OR su.name = "Transport maritime et fluvial et activités portuaires"
+                                        OR su.name = "Transport terrestre"))
+            OR (se.name = "Transport et logistique" AND (su.name = "Études et supports techniques à l'industrie"
+                                                         OR su.name = "Production industrielle"));
+
+DROP TABLE IF EXISTS profile_job_subsubsector_enum;
+
+CREATE TABLE IF NOT EXISTS profile_job_subsubsector_enum (
+  id SMALLINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
+  sectorid TINYINT(2) UNSIGNED NOT NULL,
+  subsectorid TINYINT(3) UNSIGNED NOT NULL,
+  name VARCHAR(256) NOT NULL DEFAULT '',
+  PRIMARY KEY(id),
+  UNIQUE KEY(name)
+) CHARSET=utf8;
+
+INSERT INTO  profile_job_subsubsector_enum (sectorid, subsectorid, name)
+     SELECT  s.sectorid, s.id, t.name
+       FROM  tmp_sectors                AS t
+ INNER JOIN  profile_job_subsector_enum AS s ON (t.sect = s.sect AND t.subsector = s.subsector)
+      WHERE  t.subsector != 0 AND t.subsubsector != 0
+   ORDER BY  t.id;
+
+ALTER TABLE profile_job_sector_enum DROP COLUMN sect;
+ALTER TABLE profile_job_subsector_enum DROP COLUMN sect;
+ALTER TABLE profile_job_subsector_enum DROP COLUMN subsector;
+
+-- vim:set syntax=mysql: