Fixes a SQL query in modules/axletter/axletter.inc.php.
[platal.git] / modules / profile / jobs.inc.php
index 64b96b6..d629711 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2009 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -100,12 +100,14 @@ class ProfileJob extends ProfileGeoloc
                                                     fonction, poste, adr1, adr2, adr3, postcode,
                                                     city, cityid, country, region, regiontxt,
                                                     tel, fax, mobile, email, web,
                                                     fonction, poste, adr1, adr2, adr3, postcode,
                                                     city, cityid, country, region, regiontxt,
                                                     tel, fax, mobile, email, web,
-                                                    pub, adr_pub, tel_pub, email_pub, flags)
+                                                    pub, adr_pub, tel_pub, email_pub, flags,
+                                                    glat, glng)
                                VALUES  ({?}, {?}, {?}, {?}, {?},
                                         {?}, {?}, {?}, {?}, {?}, {?},
                                         {?}, {?}, {?}, {?}, {?},
                                         {?}, {?}, {?}, {?}, {?},
                                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'],
                          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'],
@@ -113,7 +115,8 @@ class ProfileJob extends ProfileGeoloc
                          $job['adr']['regiontxt'],
                          $job['tel'], $job['fax'], $job['mobile'], $job['email'], $job['web'],
                          $job['pub'], $job['adr']['pub'], $job['tel_pub'], $job['email_pub'],
                          $job['adr']['regiontxt'],
                          $job['tel'], $job['fax'], $job['mobile'], $job['email'], $job['web'],
                          $job['pub'], $job['adr']['pub'], $job['tel_pub'], $job['email_pub'],
-                         $job['adr']['checked'] ? 'geoloc' : '');
+                         $job['adr']['checked'] ? 'geoloc' : '', $job['adr']['precise_lat'],
+                         $job['adr']['precise_lon']);
         }
     }
 }
         }
     }
 }
@@ -127,6 +130,7 @@ class ProfileJobs extends ProfilePage
         parent::__construct($wiz);
         $this->settings['cv'] = null;
         $this->settings['jobs'] = new ProfileJob();
         parent::__construct($wiz);
         $this->settings['cv'] = null;
         $this->settings['jobs'] = new ProfileJob();
+        $this->watched['cv'] = $this->watched['jobs'] = true;
     }
 
     protected function _fetchData()
     }
 
     protected function _fetchData()
@@ -145,9 +149,10 @@ class ProfileJobs extends ProfilePage
                                      e.country, gp.pays, gp.display,
                                      FIND_IN_SET('geoloc', flags),
                                      e.tel, e.fax, e.mobile, e.email, e.web, e.pub,
                                      e.country, gp.pays, gp.display,
                                      FIND_IN_SET('geoloc', flags),
                                      e.tel, e.fax, e.mobile, e.email, e.web, e.pub,
-                                     e.adr_pub, e.tel_pub, e.email_pub
+                                     e.adr_pub, e.tel_pub, e.email_pub,
+                                     e.glat AS precise_lat, e.glng AS precise_lon
                                FROM  entreprises AS e
                                FROM  entreprises AS e
-                         INNER JOIN  geoloc_pays AS gp ON(gp.a2 = e.country)
+                          LEFT JOIN  geoloc_pays AS gp ON(gp.a2 = e.country)
                               WHERE  uid = {?} AND entreprise != ''
                            ORDER BY  entrid", S::i('uid'));
         $this->values['jobs'] = array();
                               WHERE  uid = {?} AND entreprise != ''
                            ORDER BY  entrid", S::i('uid'));
         $this->values['jobs'] = array();
@@ -155,7 +160,7 @@ class ProfileJobs extends ProfilePage
                     $adr1, $adr2, $adr3, $postcode, $city, $cityid,
                     $region, $regiontxt, $country, $countrytxt, $display,
                     $checked, $tel, $fax, $mobile, $email, $web,
                     $adr1, $adr2, $adr3, $postcode, $city, $cityid,
                     $region, $regiontxt, $country, $countrytxt, $display,
                     $checked, $tel, $fax, $mobile, $email, $web,
-                    $pub, $adr_pub, $tel_pub, $email_pub) = $res->next()) {
+                    $pub, $adr_pub, $tel_pub, $email_pub, $glat, $glng) = $res->next()) {
             $this->values['jobs'][] = array('name'       => $name,
                                             'secteur'    => $secteur,
                                             'ss_secteur' => $ss_secteur,
             $this->values['jobs'][] = array('name'       => $name,
                                             'secteur'    => $secteur,
                                             'ss_secteur' => $ss_secteur,
@@ -173,14 +178,15 @@ class ProfileJobs extends ProfilePage
                                                                   'countrytxt' => $countrytxt,
                                                                   'display'    => $display,
                                                                   'pub'        => $adr_pub,
                                                                   'countrytxt' => $countrytxt,
                                                                   'display'    => $display,
                                                                   'pub'        => $adr_pub,
-                                                                  'checked'    => $checked),
+                                                                  'checked'    => $checked,
+                                                                  'precise_lat'=> $glat,
+                                                                  'precise_lon'=> $glng),
                                             'tel'        => $tel,
                                             'fax'        => $fax,
                                             'mobile'     => $mobile,
                                             'email'      => $email,
                                             'web'        => $web,
                                             'pub'        => $pub,
                                             'tel'        => $tel,
                                             'fax'        => $fax,
                                             'mobile'     => $mobile,
                                             'email'      => $email,
                                             'web'        => $web,
                                             'pub'        => $pub,
-                                            'adr_pub'    => $adr_pub,
                                             'tel_pub'    => $tel_pub,
                                             'email_pub'  => $email_pub);
         }
                                             'tel_pub'    => $tel_pub,
                                             'email_pub'  => $email_pub);
         }
@@ -196,13 +202,15 @@ class ProfileJobs extends ProfilePage
         }
     }
 
         }
     }
 
-    public function _prepare(PlatalPage &$page, $id)
+    public function _prepare(PlPage &$page, $id)
     {
     {
-        $page->assign('secteurs', XDB::iterator("SELECT  id, label
-                                                   FROM  emploi_secteur"));
-        $page->assign('fonctions', XDB::iterator("SELECT  id, fonction_fr, FIND_IN_SET('titre', flags) AS title
-                                                    FROM  fonctions_def
-                                                ORDER BY  id"));
+        $res = XDB::query("SELECT  id, label
+                             FROM  emploi_secteur");
+        $page->assign('secteurs', $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());
     }
 }
 
     }
 }