Displays alternate sector names in profile edition.
authorStéphane Jacob <jacou@melix.net>
Sat, 28 Mar 2009 16:46:40 +0000 (17:46 +0100)
committerStéphane Jacob <jacou@melix.net>
Sat, 28 Mar 2009 16:46:40 +0000 (17:46 +0100)
htdocs/javascript/profile.js
modules/profile.php
templates/profile/jobs.alternates.tpl [new file with mode: 0644]
templates/profile/jobs.job.tpl
templates/profile/jobs.sub_sector.tpl

index 01d0069..bfd2059 100644 (file)
@@ -48,6 +48,7 @@ function wizPage_onLoad(id)
         for (var i = 0 ; $('#job_' + i).length != 0; ++i) {
             updateJobSector(i, $('#job_' + i).find("[name='jobs[" + i + "][subSector]']").val());
             updateJobSubSector(i, $('#job_' + i).find("[name='jobs[" + i + "][subSubSector]']").val());
+            updateJobAlternates(i);
         }
         break;
     }
@@ -474,6 +475,14 @@ function updateJobSubSector(id, sel)
     Ajax.update_html('job_' + id + '_subSubSector', 'profile/ajax/sub_sector/' + id + '/' + subSector + '/' + sel);
 }
 
+function updateJobAlternates(id)
+{
+    var subSubSector = $('#job_' + id).find("[name='jobs[" + id + "][subSubSector]']").val();
+    if (subSubSector != '') {
+        Ajax.update_html('job_' + id + '_alternates', 'profile/ajax/alternates/' + id + '/' + subSubSector);
+    }
+}
+
 function displayAllSector(id)
 {
     $('.sector_text_' + id).remove();
index 7d57cd8..3556ec8 100644 (file)
@@ -40,6 +40,7 @@ class ProfileModule extends PLModule
             'profile/ajax/job'           => $this->make_hook('ajax_job',                   AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/sector'        => $this->make_hook('ajax_sector',                AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/sub_sector'    => $this->make_hook('ajax_sub_sector',            AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/ajax/alternates'    => $this->make_hook('ajax_alternates',            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),
             'profile/ajax/buildnames'    => $this->make_hook('ajax_buildnames',            AUTH_COOKIE, 'user', NO_AUTH),
@@ -517,6 +518,23 @@ class ProfileModule extends PLModule
         $page->assign('sel', $sssect);
     }
 
+    function handler_ajax_alternates(&$page, $id, $sssect)
+    {
+        header('Content-Type: text/html; charset=utf-8');
+        $res = XDB::iterator('SELECT  name
+                                FROM  profile_job_alternates
+                               WHERE  subsubsectorid = {?}
+                            ORDER BY  id',
+                             $sssect);
+        $page->changeTpl('profile/jobs.alternates.tpl', NO_SKIN);
+        $alternate  = $res->next();
+        $alternates = $alternate['name'];
+        while ($alternate  = $res->next()) {
+            $alternates .= ', ' . $alternate['name'];
+        }
+        $page->assign('alternates', $alternates);
+    }
+
     function handler_ajax_skill(&$page, $cat, $id)
     {
         header('Content-Type: text/html; charset=utf-8');
diff --git a/templates/profile/jobs.alternates.tpl b/templates/profile/jobs.alternates.tpl
new file mode 100644 (file)
index 0000000..f8b5fb5
--- /dev/null
@@ -0,0 +1,26 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2009 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"?>
+<small>({$alternates})</small>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 3077711..f1a1d82 100644 (file)
       </td>
     </tr>
     <tr class="pair {$sector}" style="display: none">
-      <td class="titre" rowspan="3">Secteur&nbsp;d'activité</td>
+      <td class="titre" rowspan="4">Secteur&nbsp;d'activité</td>
       <td>
         <select name="{$jobpref}[sector]" onchange="updateJobSector({$i}, '')">
           <option value="">&nbsp;</option>
         <input type="hidden" name="{$jobpref}[subSubSector]" value="{$job.subSubSector|default:'-1'}" />
       </td>
     </tr>
+    <tr class="pair {$sector}" style="display: none">
+      <td id="{$jobid}_alternates">
+      </td>
+    </tr>
     <tr class="pair">
       <td class="titre">Fonction&nbsp;occupée</td>
       <td>
index b3b2106..2415b47 100644 (file)
@@ -21,7 +21,7 @@
 {**************************************************************************}
 
 <?xml version="1.0" encoding="utf-8"?>
-<select name="jobs[{$id}][subSubSector]">
+<select name="jobs[{$id}][subSubSector]" onchange="updateJobAlternates({$id})">
   <option value=""></option>
   {iterate from=$subSubSectors item=subSubSector}
   <option value="{$subSubSector.id}" {if $subSubSector.id eq $sel}selected="selected"{/if}>{$subSubSector.name}</option>