Ajax.update_html(id + '_sss_secteur', 'profile/ajax/ssecteur/' + nb + '/' + ssecteur + '/' + sel);
}
-function displayAllSector()
+function displayAllSector(id)
{
- $('.sector_text').remove();
- $('.sector').show();
+ $('.sector_text_' + id).remove();
+ $('.sector_' + id).show();
}
function makeAddJob(id)
$.get(platal_baseurl + 'profile/ajax/job/' + i, makeAddJob(i));
}
+function addEntreprise(id)
+{
+ $('.entreprise_' + id).toggle();
+}
// Skills
$this->type = $_type;
$res = XDB::query("SELECT promo_display AS promo
FROM profile_display
- WHERE uid={?}", $_uid);
+ WHERE uid={?}", $this->user->id());
$this->promo = $res->fetchOneCell();
}
--- /dev/null
+<?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 *
+ ***************************************************************************/
+
+// {{{ class EntrReq
+
+class EntrReq extends Validate
+{
+ // {{{ properties
+
+ public $id;
+ public $name;
+ public $acronym;
+ public $url;
+ public $email;
+ public $holdingid;
+ public $NAF_code;
+ public $AX_code;
+
+ public $tel;
+ public $fax;
+
+ //TODO: addresses
+
+ // }}}
+ // {{{ constructor
+
+ public function __construct(User &$_user, $_id, $_name, $_acronym, $_url, $_email, $_tel, $_fax, $_stamp = 0)
+ {
+ parent::__construct($_user, true, 'entreprise', $_stamp);
+ $this->id = $_id;
+ $this->name = $_name;
+ $this->acronym = $_acronym;
+ $this->url = $_url;
+ $this->email = $_email;
+ $this->tel = $_tel;
+ $this->fax = $_fax;
+ }
+
+ // }}}
+ // {{{ function formu()
+
+ public function formu()
+ {
+ return 'include/form.valid.entreprises.tpl';
+ }
+
+ // }}}
+ // {{{ function editor()
+
+ public function editor()
+ {
+ return 'include/form.valid.edit-entreprises.tpl';
+ }
+
+ // }}}
+ // {{{ function handle_editor()
+
+ protected function handle_editor()
+ {
+ if (Env::has('holdingid')) {
+ $this->holdingid = trim(Env::v('holdingid'));
+ }
+ if (Env::has('name')) {
+ $this->name = trim(Env::v('name'));
+ if (Env::has('acronym')) {
+ $this->acronym = trim(Env::v('acronym'));
+ if (Env::has('url')) {
+ $this->url = trim(Env::v('url'));
+ if (Env::has('NAF_code')) {
+ $this->NAF_code = trim(Env::v('NAF_code'));
+ if (Env::has('AX_code')) {
+ $this->AX_code = trim(Env::v('AX_code'));
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ // }}}
+ // {{{ function _mail_subj
+
+ protected function _mail_subj()
+ {
+ return "[Polytechnique.org/Entreprises] Demande d'ajout d'une entreprise : " . $this->name;
+ }
+
+ // }}}
+ // {{{ function _mail_body
+
+ protected function _mail_body($isok)
+ {
+ if ($isok) {
+ return " L'entreprise " . $this->name . " vient d'être ajoutée à ta fiche.";
+ } else {
+ return " La demande que tu avais faite pour l'entreprise " . $this->name .
+ " a été refusée, car elle figure déjà dans notre base.";
+ }
+ }
+
+ // }}}
+ // {{{ function commit()
+
+ public function commit()
+ {
+ $res = XDB::query('SELECT id
+ FROM profile_job_enum
+ WHERE name = {?}',
+ $this->name);
+ if ($res->numRows() != 1) {
+ require_once("profil.func.inc.php");
+
+ XDB::execute('INSERT INTO profile_job_enum (name, acronym, url, email, holdingid, NAF_code, AX_code)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?})',
+ $this->name, $this->acronym, $this->url, $this->email,
+ $this->holdingid, $this->NAF_code, $this->AX_code);
+ $jobid = XDB::insertId();
+ $display_tel = format_display_number($this->tel, $error_tel);
+ $display_fax =format_display_number($this->fax, $error_fax);
+ XDB::execute('INSERT INTO profile_phones (uid, link_type, link_id, tel_id, tel_type,
+ search_tel, display_tel, pub)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}),
+ ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
+ $jobid, 'hq', $this->id, 0, 'fixed', format_phone_number($this->tel), $display_tel, 'public',
+ $jobid, 'hq', $this->id, 1, 'fax', format_phone_number($this->fax), $display_fax, 'public');
+ } else {
+ $jobid = $res->fetchOneCell();
+ $success = true;
+ }
+ return XDB::execute('UPDATE profile_job
+ SET jobid = {?}
+ WHERE uid = {?} AND id = {?}',
+ $jobid, $this->user->id(), $this->id);
+ }
+
+ // }}}
+}
+
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
$page->assign('i', $id);
$page->assign('job', array());
$page->assign('new', true);
- $res = XDB::query("SELECT id, label
- FROM emploi_secteur");
+ $res = XDB::query("SELECT id, name AS label
+ FROM profile_job_sector_enum");
$page->assign('secteurs', $res->fetchAllAssoc());
$res = XDB::query("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title
FROM fonctions_def
class ProfileEdu implements ProfileSetting
{
- public function __construct()
- {
- }
+ public function __construct(){}
static function sortByGradYear($line1, $line2) {
$a = (int) $line1['grad_year'];
}
}
}
-
}
class ProfileEmailDirectory implements ProfileSetting
{
- public function __construct()
- {
- }
+ public function __construct(){}
+ public function save(ProfilePage &$page, $field, $value){}
public function value(ProfilePage &$page, $field, $value, &$success)
{
}
return $value;
}
-
- public function save(ProfilePage &$page, $field, $value)
- {
- }
}
class ProfileNetworking implements ProfileSetting
'pub' => array('pub', 'w_email_pub'));
}
- private function cleanJob(ProfilePage &$page,$jobid, array &$job, &$success)
+ private function cleanJob(ProfilePage &$page, $jobid, array &$job, &$success)
{
$success = true;
foreach ($this->checks as $obj=>&$fields) {
}
}
}
- if (!isset($job['sss_secteur_name'])) {
+ if (!$job['sss_secteur_name']) {
$res = XDB::query("SELECT name
FROM profile_job_subsubsector_enum
WHERE id = {?}",
list($job['secteur'], $job['ss_secteur'], $job['sss_secteur']) = $res->fetchOneRow();
}
}
- if (!isset($job['jobid'])) {
+ if ($job['name']) {
$res = XDB::query("SELECT id
FROM profile_job_enum
WHERE name = {?}",
$job['name']);
if ($res->numRows() != 1) {
- $success = false;
- $job['name_error'] = true;
+ $user = S::user();
+ $req = new EntrReq($user, $jobid, $job['name'], $job['acronym'], $job['hq_web'], $job['hq_email'], $job['hq_tel'], $job['hq_fax']);
+ $req->submit();
+ $job['jobid'] = null;
} else {
$job['jobid'] = $res->fetchOneCell();
}
public function value(ProfilePage &$page, $field, $value, &$success)
{
+ require_once('validations.inc.php');
+ $entreprise = Validate::get_typed_requests(S::i('uid'), 'entreprise');
+ $entr_val = 0;
+
$init = false;
if (is_null($value)) {
$value = $page->values['jobs'];
}
$success = true;
foreach ($value as $key=>&$job) {
- if (@$job['removed'] || !trim($job['name'])) {
+ $job['name'] = trim($job['name']);
+ if (!$job['name']) {
+ $job['tmp_name'] = $entreprise[$entr_val]->name;
+ $entr_val ++;
+ }
+ if (@$job['removed']) {
unset($value[$key]);
}
}
public function save(ProfilePage &$page, $field, $value)
{
require_once('profil.func.inc.php');
+ require_once('validations.inc.php');
+
XDB::execute("DELETE FROM profile_job
WHERE uid = {?}",
S::i('uid'));
XDB::execute("DELETE FROM profile_phones
WHERE uid = {?} AND link_type = 'pro'",
S::i('uid'));
- $i = 0;
- foreach ($value as $jobid=>&$job) {
+ foreach ($value as $id=>&$job) {
if ($job['w_email'] == "new@example.org") {
$job['w_email'] = $job['w_email_new'];
}
- 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);
+ if ($job['jobid']) {
+ XDB::execute("INSERT INTO profile_job (uid, id, functionid, description, sectorid, subsectorid,
+ subsubsectorid, email, url, pub, email_pub, jobid)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})",
+ S::i('uid'), $id, $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']);
+ } else {
+ XDB::execute("INSERT INTO profile_job (uid, id, functionid, description, sectorid, subsectorid,
+ subsubsectorid, email, url, pub, email_pub)
+ VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})",
+ S::i('uid'), $id, $job['fonction'], $job['description'], $job['secteur'], $job['ss_secteur'],
+ $job['sss_secteur'], $job['w_email'], $job['w_web'], $job['pub'], $job['w_email_pub']);
+ }
+ $profiletel = new ProfilePhones('pro', $id);
$profiletel->saveTels('tel', $job['w_tel']);
- $i++;
}
}
}
{
private $tel;
private $pub;
+ protected $id;
protected $link_type;
protected $link_id;
- public function __construct($type, $id)
+ public function __construct($type, $link_id, $id = 0)
{
+ if ($id != 0) {
+ $this->id = $id;
+ } else {
+ $this->id = S::i('uid');
+ }
$this->tel = new ProfileTel();
$this->pub = new ProfilePub();
$this->link_type = $type;
- $this->link_id = $id;
+ $this->link_id = $link_id;
}
public function value(ProfilePage &$page, $field, $value, &$success)
$success = true;
if (is_null($value) || !is_array($value)) {
$value = array();
- $res = XDB::iterator("SELECT t.display_tel AS tel, t.tel_type AS type, t.pub, t.comment
- FROM profile_phones AS t
- WHERE t.uid = {?} AND t.link_type = {?}
- ORDER BY t.tel_id",
- S::v('uid'), $this->link_type);
+ $res = XDB::iterator("SELECT t.display_tel AS tel, t.tel_type AS type, t.pub, t.comment
+ FROM profile_phones AS t
+ WHERE t.uid = {?} AND t.link_type = {?}
+ ORDER BY t.tel_id",
+ $this->id, $this->link_type);
$value = $res->fetchAllAssoc();
}
foreach ($value as $key=>&$phone) {
search_tel, display_tel, pub, comment)
VALUES ({?}, {?}, {?}, {?}, {?},
{?}, {?}, {?}, {?})",
- S::i('uid'), $this->link_type, $this->link_id, $telid, $phone['type'],
- format_phone_number($phone['tel']), $phone['tel'], $phone['pub'], $phone['comment']);
+ $this->id, $this->link_type, $this->link_id, $telid, $phone['type'],
+ format_phone_number($phone['tel']), $phone['tel'], $phone['pub'], $phone['comment']);
}
}
{
XDB::execute("DELETE FROM profile_phones
WHERE uid = {?} AND link_type = {?} AND link_id = {?}",
- S::i('uid'), $this->link_type, $this->link_id);
+ $this->id, $this->link_type, $this->link_id);
$this->saveTels($field, $value);
}
--- /dev/null
+{**************************************************************************}
+{* *}
+{* 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 *}
+{* *}
+{**************************************************************************}
+
+<strong>Nom :</strong>
+<input type="text" name="name" size="25" maxlength="200" value="{$valid->name}" /><br />
+<strong>Acronyme :</strong>
+<input type="text" name="acronym" size="25" maxlength="200" value="{$valid->acronym}" /><br />
+<strong>Site web :</strong>
+<input type="text" name="url" size="25" maxlength="200" value="{$valid->url}" /><br />
+<strong>Email :</strong>
+<input type="text" name="url" size="25" maxlength="200" value="{$valid->email}" /><br />
+<strong>Holding :</strong>
+<input type="text" name="holdingid" size="25" maxlength="200" value="{$valid->holdingid}" /><br />
+<strong>Code NAF :</strong>
+<input type="text" name="NAF_code" size="25" maxlength="200" value="{$valid->NAF_code}" /><br />
+<strong>Code AX :</strong>
+<input type="text" name="AX_code" size="25" maxlength="200" value="{$valid->AX_code}" /><br />
+<strong>Téléphone :</strong>
+<input type="text" name="tel" size="25" maxlength="200" value="{$valid->tel}" /><br />
+<strong>Fax :</strong>
+<input type="text" name="fax" size="25" maxlength="200" value="{$valid->fax}" /><br />
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
--- /dev/null
+{**************************************************************************}
+{* *}
+{* 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 *}
+{* *}
+{**************************************************************************}
+
+
+<tr class="pair">
+ <td class="titre">Nom :</td>
+ <td>{$valid->name}</td>
+</tr>
+<tr class="pair">
+ <td class="titre">Acronyme :</td>
+ <td>{$valid->acronym}</td>
+</tr>
+<tr class="pair">
+ <td class="titre">Site web :</td>
+ <td>{$valid->url}</td>
+</tr>
+<tr class="pair">
+ <td class="titre">Email :</td>
+ <td>{$valid->email}</td>
+</tr>
+<tr class="pair">
+ <td class="titre">Holding :</td>
+ <td>{$valid->holdingid}</td>
+</tr>
+<tr class="pair">
+ <td class="titre">Code NAF :</td>
+ <td>{$valid->NAF_code}</td>
+</tr>
+<tr class="pair">
+ <td class="titre">Code AX :</td>
+ <td>{$valid->AX_code}</td>
+</tr>
+<tr class="pair">
+ <td class="titre">Téléphone :</td>
+ <td>{$valid->tel}</td>
+</tr>
+<tr class="pair">
+ <td class="titre">Fax :</td>
+ <td>{$valid->fax}</td>
+</tr>
+<tr class="pair">
+ <td colspan="2" class="center">
+ <small>Bien remplir tous les champs, en particulier les <a href="http://societe.com/">codes NAF</a> et AX !</small>
+ </td>
+</tr>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{assign var=jobid value="job_`$i`"}
{assign var=jobpref value="jobs[`$i`]"}
+{assign var=sector_text value="sector_text_"|cat:$i}
+{assign var=sector value="sector_"|cat:$i}
+{assign var=entreprise value="entreprise_"|cat:$i}
<div id="{$jobid}">
<input type="hidden" name="{$jobpref}[removed]" value="0" />
<input type="hidden" name="{$jobpref}[new]" value="{if $new}1{else}0{/if}" />
<tr>
<td class="titre">Nom de l'entreprise</td>
<td>
+ {if $job.tmp_name}{$job.tmp_name} <small>(en cours de validation)</small>{else}
<input type="text" class="enterprise_name {if $job.name_error}error{/if}" size="35" maxlength="100"
name="{$jobpref}[name]" value="{$job.name}" />
+ {/if}
+ </td>
+ </tr>
+ {if !$job.tmp_name}
+ <tr class="{$entreprise}">
+ <td class="center" colspan="2">
+ <small>Si ton entreprise ne figure pas dans la liste,
+ <a href="javascript:addEntreprise({$i})">clique ici</a> et complète les informations la concernant.</small>
+ </td>
+ </tr>
+ {/if}
+ <tr class="{$entreprise}" style="display: none">
+ <td class="titre">Acronyme</td>
+ <td>
+ <input type="text" size="35" maxlength="255" {if $job.acronym_error}class="error"{/if}
+ name="{$jobpref}[acronym]" value="{$job.acronym}" />
+ </td>
+ </tr>
+ <tr class="{$entreprise}" style="display: none">
+ <td class="titre">Page Web</td>
+ <td>
+ <input type="text" size="35" maxlength="255" {if $job.hq_web_error}class="error"{/if}
+ name="{$jobpref}[hq_web]" value="{$job.hq_web}" />
+ </td>
+ </tr>
+ <tr class="{$entreprise}" style="display: none">
+ <td class="titre">Email de contact</td>
+ <td>
+ <input type="text" maxlength="60" {if $job.hq_email_error}class="error"{/if}
+ name="{$jobpref}[hq_email]" value="{$job.hq_email}" />
+ </td>
+ </tr>
+ <!--<tr class="{$entreprise}" style="display: none">
+ <td colspan="2">
+ <div style="float: left">
+ <div class="titre">Adresse du siège</div>
+ <div style="margin-top: 20px; clear: both">
+ {include file="geoloc/form.address.tpl" name="`$jobpref`[hq_adr]" id="`$jobid`_adr" adr=$job.hq_adr}
+ </div>
+ </div>
+ </td>
+ </tr>-->
+ <tr class="{$entreprise}" style="display: none">
+ <td class="titre">Téléphone</td>
+ <td>
+ <input type="text" maxlength="28" {if $job.hq_tel_error}class="error"{/if}
+ name="{$jobpref}[hq_tel]" value="{$job.hq_tel}" />
+ </td>
+ </tr>
+ <tr class="{$entreprise}" style="display: none">
+ <td class="titre">Fax</td>
+ <td>
+ <input type="text" maxlength="28" {if $job.hq_fax_error}class="error"{/if}
+ name="{$jobpref}[hq_fax]" value="{$job.hq_fax}" />
</td>
</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">
+ <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>
+ <a href="javascript:displayAllSector({$i})">{icon name="table" title="Tous les secteurs"}</a>
</td>
</tr>
- <tr class="pair sector" style="display: none">
+ <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;">
</select>
</td>
</tr>
- <tr class="pair sector" style="display: none">
+ <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 class="pair sector" style="display: none">
+ <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>
name VARCHAR(255) NOT NULL DEFAULT '',
acronym VARCHAR(255) NOT NULL DEFAULT '',
url VARCHAR(255) NOT NULL DEFAULT '',
+ email 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,
ALTER TABLE profile_job_subsector_enum DROP COLUMN sect;
ALTER TABLE profile_job_subsector_enum DROP COLUMN subsector;
+
+ALTER TABLE profile_phones CHANGE COLUMN link_type link_type ENUM('address','pro','user', 'hq') NOT NULL DEFAULT 'user';
+
-- vim:set syntax=mysql: