Gets rid of functions.
authorStéphane Jacob <jacou@melix.net>
Sun, 29 Mar 2009 16:02:16 +0000 (18:02 +0200)
committerStéphane Jacob <jacou@melix.net>
Sun, 29 Mar 2009 17:48:24 +0000 (19:48 +0200)
modules/profile.php
modules/profile/jobs.inc.php
templates/profile/jobs.job.tpl
upgrade/newdirectory-0.0.1/11_jobs.sql

index 1c9915e..1ff0dd7 100644 (file)
@@ -481,10 +481,6 @@ class ProfileModule extends PLModule
         $res = XDB::query("SELECT  id, name AS label
                              FROM  profile_job_sector_enum");
         $page->assign('sectors', $res->fetchAllAssoc());
-        $res = XDB::query("SELECT  id, fonction_fr, FIND_IN_SET('titre', flags) AS title
-                             FROM  fonctions_def
-                         ORDER BY  id");
-        $page->assign('fonctions', $res->fetchAllAssoc());
         require_once "emails.combobox.inc.php";
         fill_email_combobox($page);
     }
index 0ee5d3a..1b67ff1 100644 (file)
@@ -157,16 +157,16 @@ class ProfileJob extends ProfileGeocoding
                      S::i('uid'));
         foreach ($value as $id=>&$job) {
             if ($job['jobid']) {
-                XDB::execute("INSERT INTO  profile_job (uid, id, functionid, description, sectorid, subsectorid,
+                XDB::execute("INSERT INTO  profile_job (uid, id, description, sectorid, subsectorid,
                                                         subsubsectorid, email, url, pub, email_pub, jobid)
                                    VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})",
-                             S::i('uid'), $id, $job['fonction'], $job['description'], $job['sector'], $job['subSector'],
+                             S::i('uid'), $id, $job['description'], $job['sector'], $job['subSector'],
                              $job['subSubSector'], $job['w_email'], $job['w_url'], $job['pub'], $job['w_email_pub'], $job['jobid']);
             } else {
-                XDB::execute("INSERT INTO  profile_job (uid, id, functionid, description, sectorid, subsectorid,
+                XDB::execute("INSERT INTO  profile_job (uid, id, description, sectorid, subsectorid,
                                                         subsubsectorid, email, url, pub, email_pub)
                                    VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})",
-                             S::i('uid'), $id, $job['fonction'], $job['description'], $job['sector'], $job['subSector'],
+                             S::i('uid'), $id, $job['description'], $job['sector'], $job['subSector'],
                              $job['subSubSector'], $job['w_email'], $job['w_url'], $job['pub'], $job['w_email_pub']);
             }
             $address = new ProfileAddress();
@@ -208,7 +208,7 @@ class ProfileJobs extends ProfilePage
         $this->values['corps'] = $res->fetchOneAssoc();
 
         // Build the jobs tree
-        $res = XDB::iterRow("SELECT  j.id, j.jobid, je.name, j.functionid, j.sectorid, j.subsectorid, j.subsubsectorid,
+        $res = XDB::iterRow("SELECT  j.id, j.jobid, je.name, j.sectorid, j.subsectorid, j.subsubsectorid,
                                      s.name, j.description, j.email, j.email_pub, j.url, j.pub,
                                      je.acronym, je.url, je.email,
                                      aw.accuracy, aw.text, aw.postalText, aw.postalCode, aw.localityId,
@@ -229,7 +229,7 @@ class ProfileJobs extends ProfilePage
                            ORDER BY  j.id",
                             S::i('uid'));
         $this->values['jobs'] = array();
-        while (list($id, $jobid, $name, $function, $sector, $subSector, $subSubSector,
+        while (list($id, $jobid, $name, $sector, $subSector, $subSubSector,
                     $subSubSectorName, $description, $w_email, $w_emailPub, $w_url, $pub,
                     $hq_acronym, $hq_url, $hq_email,
                     $w_accuracy, $w_text, $w_postalText, $w_postalCode, $w_localityId,
@@ -244,7 +244,6 @@ class ProfileJobs extends ProfilePage
             $this->values['jobs'][] = array('id'               => $id,
                                             'jobid'            => $jobid,
                                             'name'             => $name,
-                                            'function'         => $function,
                                             'sector'           => $sector,
                                             'subSector'        => $subSector,
                                             'subSubSector'     => $subSubSector,
@@ -351,10 +350,6 @@ class ProfileJobs extends ProfilePage
         $res = XDB::query("SELECT  id, name AS label
                              FROM  profile_job_sector_enum");
         $page->assign('sectors', $res->fetchAllAssoc());
-        $res = XDB::query("SELECT  id, fonction_fr, FIND_IN_SET('titre', flags) AS title
-                             FROM  fonctions_def
-                         ORDER BY  id");
-        $page->assign('functions', $res->fetchAllAssoc());
 
         $res = XDB::iterator("SELECT  id, name
                                 FROM  profile_corps_enum
index f1a1d82..7489ede 100644 (file)
       </td>
     </tr>
     <tr class="pair">
-      <td class="titre">Fonction&nbsp;occupée</td>
-      <td>
-        <select name="{$jobpref}[fonction]">
-          <option value="">&nbsp;</option>
-          {assign var=ingroup value=false}
-          {foreach from=$fonctions item=fonct}
-          {if $fonct.title}
-            {if $ingroup}</optgroup>{/if}
-            <optgroup label="{$fonct.fonction_fr}">
-            {assign var=ingroup value=true}
-          {/if}
-          <option value="{$fonct.id}" {if $fonct.id eq $job.fonction}selected="selected"{/if}>
-            {$fonct.fonction_fr}
-          </option>
-          {/foreach}
-          {if $ingroup}</optgroup>{/if}
-        </select>
-      </td>
-    </tr>
-    <tr class="pair">
       <td class="titre">Description</td>
       <td>
         <input type="text" size="35" maxlength="120" {if $job.description_error}class="error"{/if}
index 85d193b..b10dbc6 100644 (file)
@@ -19,7 +19,6 @@ 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,
@@ -36,18 +35,14 @@ INSERT IGNORE INTO  profile_job_enum (name, url)
             SELECT  entreprise, web
               FROM  entreprises;
 
-INSERT INTO  profile_job (id, uid, jobid, description, email, pub, email_pub, functionid)
-     SELECT  e.entrid, e.uid, j.id, e.poste, e.email, e.pub, e.email_pub, e.fonction
-       FROM  entreprises      AS e
- INNER JOIN  profile_job_enum AS j ON (e.entreprise = j.name);
-
-DROP TABLE IF EXISTS profile_job_function_enum;
-
-CREATE TABLE IF NOT EXISTS profile_job_function_enum (
-  id SMALLINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
-  name VARCHAR(255) NOT NULL DEFAULT '',
-  PRIMARY KEY (id),
-  UNIQUE KEY (name)
-) CHARSET=utf8;
+INSERT INTO  profile_job (id, uid, jobid, email, pub, email_pub, description)
+     SELECT  e.entrid, e.uid, j.id, e.email, e.pub, e.email_pub,
+             CONCAT_WS(', ', IF(e.poste = '', NULL, e.poste), IF(e.fonction = 0, NULL, f.fonction_fr),
+                       IF(e.ss_secteur IS NULL , IF(e.secteur IS NULL, NULL, s.label), ss.label))
+       FROM  entreprises       AS e
+ INNER JOIN  profile_job_enum  AS j  ON (e.entreprise = j.name)
+  LEFT JOIN  fonctions_def     AS f  ON (f.id = e.fonction)
+  LEFT JOIN  emploi_ss_secteur AS ss ON (ss.id = e.ss_secteur)
+  LEFT JOIN  emploi_secteur    AS s  ON (s.id = e.secteur);
 
 -- vim:set syntax=mysql: