From ea9cfc3e5b2ff56855a3a63f6526026b421b32c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Thu, 16 Sep 2010 19:48:40 +0200 Subject: [PATCH] Fixes on job edition: sector ids removal, hq simplification. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- include/validations/entreprises.inc.php | 14 ++- modules/profile/jobs.inc.php | 100 ++++------------------ templates/include/form.valid.edit-entreprises.tpl | 2 +- templates/include/form.valid.entreprises.tpl | 2 +- templates/profile/jobs.job.tpl | 55 ++---------- upgrade/1.0.1/08_profile_foreign_keys.sql | 14 --- upgrade/1.0.1/99_jobs.sql | 5 ++ upgrade/1.0.1/README | 1 + 8 files changed, 39 insertions(+), 154 deletions(-) create mode 100644 upgrade/1.0.1/99_jobs.sql create mode 100644 upgrade/1.0.1/README diff --git a/include/validations/entreprises.inc.php b/include/validations/entreprises.inc.php index 19b7a62..e7857f2 100644 --- a/include/validations/entreprises.inc.php +++ b/include/validations/entreprises.inc.php @@ -34,9 +34,9 @@ class EntrReq extends ProfileValidate public $NAF_code = null; public $AX_code = null; - public $tel; - public $fax; - public $address; + public $tel = null; + public $fax = null; + public $address = null; public $suggestions; public $rules = 'Si l\'entreprise est déjà présente sous un autre nom dans la liste des suggestions, remplacer son nom par celui-ci avant de valider. Laisser les autres champs tels quels.'; @@ -101,16 +101,12 @@ class EntrReq extends ProfileValidate protected function handle_editor() { - foreach (array('acronym', 'url', 'email', 'NAF_code') as $field) { + foreach (array('name', 'acronym', 'url', 'email', 'NAF_code', 'tel', 'fax', 'address') as $field) { $this->$field = (Env::t($field) == '' ? null : Env::t($field)); } foreach (array('AX_code', 'holdingid') as $field) { $this->$field = (Env::i($field) == 0 ? null : Env::i($field)); } - $this->name = Env::t('name'); - $this->address['text'] = Env::t('address'); - $this->tel = Env::t('tel'); - $this->fax = Env::t('fax'); return true; } @@ -156,7 +152,7 @@ class EntrReq extends ProfileValidate 'type' => 'fixed', 'display' => $this->tel, 'pub' => 'public')); $fax = new Phone(array('link_type' => 'hq', 'link_id' => $jobid, 'id' => 1, 'type' => 'fax', 'display' => $this->fax, 'pub' => 'public')); - $address = new Address(array('jobid' => $jobid, 'type' => Address::LINK_COMPANY, 'text' => $this->address['text'])); + $address = new Address(array('jobid' => $jobid, 'type' => Address::LINK_COMPANY, 'text' => $this->address)); $phone->save(); $fax->save(); $address->format(); diff --git a/modules/profile/jobs.inc.php b/modules/profile/jobs.inc.php index 73aabe5..50510df 100644 --- a/modules/profile/jobs.inc.php +++ b/modules/profile/jobs.inc.php @@ -50,16 +50,6 @@ class ProfileSettingJob implements ProfileSetting 'jobid' => '', 'pub' => 'private', 'name' => '', - 'hq_acronym' => '', - 'hq_url' => '', - 'hq_email' => '', - 'hq_address' => $address->toFormArray(), - 'hq_fixed' => '', - 'hq_fax' => '', - 'subSubSectorName' => null, - 'sector' => '0', - 'subSector' => '0', - 'subSubSector' => '0', 'description' => '', 'w_url' => '', 'w_address' => $address->toFormArray(), @@ -91,24 +81,6 @@ class ProfileSettingJob implements ProfileSetting } } } - if (!$job['subSubSectorName']) { - $res = XDB::query("SELECT name - FROM profile_job_subsubsector_enum - WHERE id = {?}", - $job['subSubSector']); - $job['subSubSectorName'] = $res->fetchOneCell(); - } else { - $res = XDB::query("SELECT sectorid, subsectorid, id - FROM profile_job_subsubsector_enum - WHERE name = {?}", - $job['subSubSectorName']); - if ($res->numRows() != 1) { - $success = false; - $job['sector_error'] = true; - } else { - list($job['sector'], $job['subSector'], $job['subSubSector']) = $res->fetchOneRow(); - } - } if (count($job['terms'])) { $termsid = array(); foreach ($job['terms'] as $term) { @@ -168,7 +140,7 @@ class ProfileSettingJob implements ProfileSetting $job['tmp_name'] = $entreprise[$entr_val]->name; ++$entr_val; } else if ($job['name'] == '') { - if ($job['subSubSectorName'] == '' && $job['description'] == '' && $job['w_url'] == '' + if ($job['description'] == '' && $job['w_url'] == '' && $job['w_address']['text'] == '' && $job['w_email'] == '' && count($job['w_phone']) == 1 && $job['w_phone']['tel'] == '') { array_splice($value, $key, 1); @@ -187,11 +159,6 @@ class ProfileSettingJob implements ProfileSetting } array_splice($value, $key, 1); } - foreach (array('sectorid', 'subsectorid', 'subsubsectorid') as $key) { - if ($job[$key] == 0) { - $job[$key] = null; - } - } } foreach ($value as $key => &$job) { $address = new Address($job['w_address']); @@ -216,17 +183,13 @@ class ProfileSettingJob implements ProfileSetting foreach ($value as $id => &$job) { if (isset($job['name']) && $job['name']) { if (isset($job['jobid']) && $job['jobid']) { - XDB::execute("INSERT INTO profile_job (pid, id, description, sectorid, subsectorid, - subsubsectorid, email, url, pub, email_pub, jobid) - VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})", - $page->pid(), $id, $job['description'], $job['sector'], $job['subSector'], - $job['subSubSector'], $job['w_email'], $job['w_url'], $job['pub'], $job['w_email_pub'], $job['jobid']); + XDB::execute('INSERT INTO profile_job (pid, id, description, email, url, pub, email_pub, jobid) + VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', + $page->pid(), $id, $job['description'], $job['w_email'], $job['w_url'], $job['pub'], $job['w_email_pub'], $job['jobid']); } else { - XDB::execute("INSERT INTO profile_job (pid, id, description, sectorid, subsectorid, - subsubsectorid, email, url, pub, email_pub) - VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})", - $page->pid(), $id, $job['description'], $job['sector'], $job['subSector'], - $job['subSubSector'], $job['w_email'], $job['w_url'], $job['pub'], $job['w_email_pub']); + XDB::execute('INSERT INTO profile_job (pid, id, description, email, url, pub, email_pub) + VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?})', + $page->pid(), $id, $job['description'], $job['w_email'], $job['w_url'], $job['pub'], $job['w_email_pub']); } $address = new Address(array_merge($job['w_address'], array('pid' => $page->pid(), 'id' => $id, 'type' => Address::LINK_JOB))); $address->save(); @@ -249,7 +212,8 @@ class ProfileSettingJob implements ProfileSetting foreach ($value as $id => $job) { $address = Address::formArrayToString($job['w_address']); $phones = Phone::formArrayToString($job['w_phone']); - $jobs[] = 'Entreprise : ' . $job['name'] . ', secteur : ' . $job['subSubSectorName'] + // TODO: add jobterms here. + $jobs[] = 'Entreprise : ' . $job['name'] . ', description : ' . $job['description'] . ', web : ' . $job['w_url'] . ', email : ' . $job['w_email'] . ($phones ? ', ' . $phones : '') . ($address ? ', ' . $address : ''); @@ -317,41 +281,28 @@ class ProfileSettingJobs extends ProfilePage } // Build the jobs tree - $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 - FROM profile_job AS j - LEFT JOIN profile_job_enum AS je ON (j.jobid = je.id) - LEFT JOIN profile_job_subsubsector_enum AS s ON (s.id = j.subsubsectorid) + $res = XDB::iterRow('SELECT j.id, j.jobid, je.name, j.description, j.email, j.email_pub, + j.url, j.pub + FROM profile_job AS j + LEFT JOIN profile_job_enum AS je ON (j.jobid = je.id) WHERE j.pid = {?} - ORDER BY j.id", + ORDER BY j.id', $this->pid()); $this->values['jobs'] = array(); $compagnies = array(); if ($res->numRows() > 0) { - while (list($id, $jobid, $name, $sector, $subSector, $subSubSector, - $subSubSectorName, $description, $w_email, $w_emailPub, $w_url, $pub, - $hq_acronym, $hq_url, $hq_email, - $w_subAdministrativeAreaId, $w_administrativeAreaId, $w_countryId, - ) = $res->next()) { + while (list($id, $jobid, $name, $description, $w_email, $w_emailPub, $w_url, $pub) = $res->next()) { $compagnies[] = $jobid; $this->values['jobs'][] = array( 'id' => $id, 'jobid' => $jobid, 'name' => $name, - 'sector' => $sector, - 'subSector' => $subSector, - 'subSubSector' => $subSubSector, - 'subSubSectorName' => $subSubSectorName, 'description' => $description, 'pub' => $pub, 'w_email' => $w_email, 'w_email_pub' => $w_emailPub, 'w_url' => $w_url, - 'hq_acronym' => $hq_acronym, - 'hq_url' => $hq_url, - 'hq_email' => $hq_email, ); } @@ -359,10 +310,6 @@ class ProfileSettingJobs extends ProfilePage while ($address = $it->next()) { $this->values['jobs'][$address->jobid]['w_address'] = $address->toFormArray(); } - $it = Address::iterate(array(), array(Address::LINK_COMPANY), $companies); - while ($address = $it->next()) { - $this->values['jobs'][$address->jobId()]['h_address'] = $address->toFormArray(); - } $it = Phone::iterate(array($this->pid()), array(Phone::LINK_JOB)); while ($phone = $it->next()) { $this->values['jobs'][$phone->linkId()]['w_phone'][$phone->id()] = $phone->toFormArray(); @@ -393,27 +340,18 @@ class ProfileSettingJobs extends ProfilePage $job['terms'][] = $term; } + $phone = new Phone(); + $address = new Address(); foreach ($this->values['jobs'] as $id => &$job) { - $phone = new Phone(); - $address = new Address(); if (!isset($job['w_phone'])) { $job['w_phone'] = array(0 => $phone->toFormArray()); } if (!isset($job['w_address'])) { $job['w_address'] = $address->toFormArray(); } - if (!isset($job['h_address'])) { - $job['h_address'] = $address->toFormArray(); - } } $job['w_email_new'] = ''; - if (!isset($job['hq_fixed'])) { - $job['hq_fixed'] = ''; - } - if (!isset($job['hq_fax'])) { - $job['hq_fax'] = ''; - } if (!isset($job['w_email_pub'])) { $job['w_email_pub'] = 'private'; } @@ -439,10 +377,6 @@ class ProfileSettingJobs extends ProfilePage require_once 'emails.combobox.inc.php'; fill_email_combobox($page, $this->owner); - $res = XDB::query("SELECT id, name AS label - FROM profile_job_sector_enum"); - $page->assign('sectors', $res->fetchAllAssoc()); - $res = XDB::iterator("SELECT id, name FROM profile_corps_enum ORDER BY id = 1 DESC, name"); diff --git a/templates/include/form.valid.edit-entreprises.tpl b/templates/include/form.valid.edit-entreprises.tpl index 7b59719..2efe011 100644 --- a/templates/include/form.valid.edit-entreprises.tpl +++ b/templates/include/form.valid.edit-entreprises.tpl @@ -35,7 +35,7 @@ Code AX :
Adresse : -
+
Téléphone :
Fax : diff --git a/templates/include/form.valid.entreprises.tpl b/templates/include/form.valid.entreprises.tpl index 855ade8..78d2c60 100644 --- a/templates/include/form.valid.entreprises.tpl +++ b/templates/include/form.valid.entreprises.tpl @@ -55,7 +55,7 @@ Adresse : - {$valid->address.text} + {$valid->address} Téléphone : diff --git a/templates/profile/jobs.job.tpl b/templates/profile/jobs.job.tpl index 08570ce..6cd21d5 100644 --- a/templates/profile/jobs.job.tpl +++ b/templates/profile/jobs.job.tpl @@ -65,53 +65,43 @@ clique ici et complète les informations la concernant. - {/if} Acronyme - + Page web - + Email de contact - + - -
-
Adresse du siège
-
- {include file="geoloc/form.address.tpl" prefname="`$jobpref`[hq_address]" - prefid="`$jobid`_address" address=$job.hq_address} -
-
+ Adresse du siège + + Téléphone - + Fax - + + {/if} Ta place dans l'entreprise @@ -144,33 +134,6 @@ - - Secteur d'activité - - - - - - - - - - - - - - - - - - Description diff --git a/upgrade/1.0.1/08_profile_foreign_keys.sql b/upgrade/1.0.1/08_profile_foreign_keys.sql index 350adfb..5b2cd06 100644 --- a/upgrade/1.0.1/08_profile_foreign_keys.sql +++ b/upgrade/1.0.1/08_profile_foreign_keys.sql @@ -16,9 +16,6 @@ ALTER TABLE profile_education_enum MODIFY COLUMN country CHAR(2) DEFAULT 'FR'; ALTER TABLE profile_education_degree MODIFY COLUMN eduid INT(11) UNSIGNED DEFAULT 0; ALTER TABLE profile_education_degree MODIFY COLUMN degreeid INT(11) UNSIGNED DEFAULT 0; ALTER TABLE profile_job MODIFY COLUMN jobid INT(6) UNSIGNED DEFAULT NULL; -ALTER TABLE profile_job MODIFY COLUMN sectorid TINYINT(2) UNSIGNED DEFAULT NULL; -ALTER TABLE profile_job MODIFY COLUMN subsectorid SMALLINT(3) UNSIGNED DEFAULT NULL; -ALTER TABLE profile_job MODIFY COLUMN subsubsectorid SMALLINT(3) UNSIGNED DEFAULT NULL; -- Prepares table having ids set to 0. DELETE FROM profile_mentor_country WHERE country = 'YU' OR country = '00'; @@ -31,9 +28,6 @@ UPDATE profile_education SET degreeid = NULL WHERE degreeid = 0; UPDATE profile_education SET fieldid = NULL WHERE fieldid = 0; UPDATE profile_education_enum SET country = NULL WHERE country = ''; UPDATE profile_job SET jobid = NULL WHERE jobid = 0; -UPDATE profile_job SET sectorid = NULL WHERE sectorid = 0; -UPDATE profile_job SET subsectorid = NULL WHERE subsectorid = 0; -UPDATE profile_job SET subsubsectorid = NULL WHERE subsubsectorid = 0; UPDATE profile_job_enum SET holdingid = NULL WHERE holdingid = 0; -- Adds missing data in foreign tables. @@ -63,18 +57,10 @@ ALTER TABLE profile_education_enum ADD FOREIGN KEY (country) REFERENCES geoloc_c ALTER TABLE profile_education_degree ADD FOREIGN KEY (eduid) REFERENCES profile_education_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE profile_education_degree ADD FOREIGN KEY (degreeid) REFERENCES profile_education_degree_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE profile_job ADD FOREIGN KEY (jobid) REFERENCES profile_job_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE profile_job ADD FOREIGN KEY (sectorid) REFERENCES profile_job_sector_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE profile_job ADD FOREIGN KEY (subsectorid) REFERENCES profile_job_subsector_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE profile_job ADD FOREIGN KEY (subsubsectorid) REFERENCES profile_job_subsubsector_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE profile_job_alternates ADD FOREIGN KEY (subsubsectorid) REFERENCES profile_job_subsubsector_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE profile_job_enum ADD FOREIGN KEY (holdingid) REFERENCES profile_job_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE profile_job_subsector_enum ADD FOREIGN KEY (sectorid) REFERENCES profile_job_sector_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE profile_job_subsubsector_enum ADD FOREIGN KEY (sectorid) REFERENCES profile_job_sector_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE profile_job_subsubsector_enum ADD FOREIGN KEY (subsectorid) REFERENCES profile_job_subsector_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE profile_langskills ADD FOREIGN KEY (lid) REFERENCES profile_langskill_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE profile_medal_grade_enum ADD FOREIGN KEY (mid) REFERENCES profile_medal_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE profile_mentor_country ADD FOREIGN KEY (country) REFERENCES geoloc_countries (iso_3166_1_a2) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE profile_mentor_sector ADD FOREIGN KEY (sectorid) REFERENCES profile_job_sector_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE profile_skills ADD FOREIGN KEY (cid) REFERENCES profile_skill_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE profile_name ADD FOREIGN KEY (typeid) REFERENCES profile_name_enum (id) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE profile_networking ADD FOREIGN KEY (nwid) REFERENCES profile_networking_enum (nwid) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/upgrade/1.0.1/99_jobs.sql b/upgrade/1.0.1/99_jobs.sql new file mode 100644 index 0000000..73e4791 --- /dev/null +++ b/upgrade/1.0.1/99_jobs.sql @@ -0,0 +1,5 @@ +ALTER TABLE profile_job_enum DROP COLUMN sectorid; +ALTER TABLE profile_job_enum DROP COLUMN subsectorid; +ALTER TABLE profile_job_enum DROP COLUMN subsubsectorid; + +-- vim:set syntax=mysql: diff --git a/upgrade/1.0.1/README b/upgrade/1.0.1/README new file mode 100644 index 0000000..80846c3 --- /dev/null +++ b/upgrade/1.0.1/README @@ -0,0 +1 @@ +99_jobs.sql must be run after php scripts. -- 2.1.4