migration de x.php
authorx2000coic <x2000coic>
Fri, 6 Aug 2004 17:50:22 +0000 (17:50 +0000)
committerx2000coic <x2000coic>
Fri, 6 Aug 2004 17:50:22 +0000 (17:50 +0000)
c'est un peu laid mais ca marche à peu près

htdocs/css/fiche.css [new file with mode: 0644]
htdocs/fiche.php [new file with mode: 0644]
htdocs/fiche_referent.php
htdocs/images/mail.png [new file with mode: 0644]
templates/add_fiche_css.tpl [new file with mode: 0644]
templates/fiche.tpl [new file with mode: 0644]
templates/fiche_referent.tpl

diff --git a/htdocs/css/fiche.css b/htdocs/css/fiche.css
new file mode 100644 (file)
index 0000000..bf53282
--- /dev/null
@@ -0,0 +1,31 @@
+div.boite{
+  border: 1px solid #5555BB;
+  background-color: #FFFFC0;
+  padding: 5px;
+  margin: 5px;
+}
+
+div.boite div.titre{
+  background-color: #9999FF;
+  margin: 5px;
+  padding: 5px;
+  text-align: center;
+}
+
+div.spacer{
+  clear: both;
+}
+
+div.boite div.item{
+  float: left;
+  padding: 5px;
+  margin: 5px;
+}
+
+div.item div.title{
+  font-weight: bold;
+}
+
+div.item div.value{
+
+}
diff --git a/htdocs/fiche.php b/htdocs/fiche.php
new file mode 100644 (file)
index 0000000..f2afb55
--- /dev/null
@@ -0,0 +1,217 @@
+<?php
+
+require("auto.prepend.inc.php");
+new_simple_page('fiche.tpl',AUTH_COOKIE, false, 'add_fiche_css.tpl');
+
+require_once('applis.func.inc.php');
+
+//$isnetscape = !empty($_SESSION['skin_compatible']);
+
+if (!isset($_REQUEST['user']) && !isset($_REQUEST['mat']))
+  exit;
+
+if (isset($_REQUEST["modif"]) && $_REQUEST["modif"]=="new") {
+    $new = true;
+} else {
+    $new = false;
+}
+
+if (isset($_REQUEST['user']))
+    $where_clause = " WHERE username = '{$_REQUEST['user']}'";
+else
+    $where_clause = " WHERE u.matricule = '{$_REQUEST['mat']}'";
+
+$reqsql = "SELECT u.prenom, u.nom, u.epouse, nationalites.text"
+  .", u.user_id, u.username, u.alias, u.matricule, i.deces != 0 as dcd"
+  .", i.deces"
+  .", u.date"
+  .", u.cv, sections.text"
+  .", u.mobile, u.web, u.libre, u.promo"
+  .", c.uid IS NOT NULL"
+  .", p.x, p.y"
+  ." FROM auth_user_md5 as u"
+  ." LEFT JOIN contacts as c ON (c.uid = {$_SESSION['uid']} and c.contact = u.user_id)"
+  ." INNER JOIN nationalites ON(nationalites.id = u.nationalite)"
+  ." INNER JOIN sections ON(sections.id = u.section)"
+  ." INNER JOIN identification AS i ON(u.matricule = i.matricule)"
+  ." LEFT  JOIN photo as p ON(p.uid = u.user_id)"
+// conversion du username en user_id si nécessaire
+  .$where_clause;
+$result = mysql_query($reqsql);
+
+if (mysql_num_rows($result)!=1)
+        exit;
+
+if (list($prenom, $nom, $epouse, $nationalite, 
+        $user_id, $username, $alias, $matricule, $dcd, $deces, 
+        $date,
+        $cv, $section, 
+        $mobile, $web, $libre, $promo,
+        $is_contact, $size_x, $size_y) = mysql_fetch_row($result)) {
+
+$page->assign('prenom', $prenom);
+$page->assign('nom', $nom);
+$page->assign('promo', $promo);
+$page->assign('cv', $cv);
+$page->assign('username', $username);
+$page->assign('epouse', $epouse);
+$page->assign('nationalite', $nationalite);
+$page->assign('user_id', $user_id);
+$page->assign('alias', $alias);
+$page->assign('matricule', $matricule);
+$page->assign('dcd', $dcd);
+$page->assign('deces', $deces);
+$page->assign('date', $date);
+$page->assign('section', $section);
+$page->assign('mobile', $mobile);
+$page->assign('web', $web);
+$page->assign('libre', $libre);
+
+// reformatage is_contact
+$is_contact = (bool) $is_contact;
+$page->assign('is_contact', $is_contact);
+
+// photo
+
+$photo="getphoto.php?x=".$user_id.(SID == '' ? '' : '&amp;'.SID).($new ? '&amp;modif=new' : '');
+if(!isset($size_y) and !isset($size_x)) list($size_x, $size_y) = getimagesize("none.png");
+if(!isset($size_y) or $size_y < 1) $size_y=1;
+if(!isset($size_x) or $size_x < 1) $size_x=1;
+if($size_y > 300){
+    $size_x = (integer)($size_x*300/$size_y);
+    $size_y = 300;
+}
+if($size_x < 180){
+    $size_y = (integer)($size_y*180/$size_x);
+    $size_x = 180;
+}
+$page->assign('photo_url', $photo);
+$page->assign('size_x', $size_x);
+$page->assign('size_y', $size_y);
+
+
+mysql_free_result($result);
+
+//recuperation des infos professionnelles
+$reqsql = 
+   "SELECT e.entreprise, s.label as secteur , ss.label as sous_secteur , f.fonction_fr as fonction,
+           e.poste, e.adr1, e.adr2, e.adr3, e.cp, e.ville,
+          gp.pays, gr.name, e.tel, e.fax
+   FROM entreprises AS e
+   LEFT JOIN emploi_secteur AS s ON(e.secteur = s.id)
+   LEFT JOIN emploi_ss_secteur AS ss ON(e.ss_secteur = ss.id AND e.secteur = ss.secteur)
+   LEFT JOIN fonctions_def AS f ON(e.fonction = f.id)
+   LEFT JOIN geoloc_pays AS gp ON (gp.a2 = e.pays)
+   LEFT JOIN geoloc_region AS gr ON (gr.a2 = e.pays and gr.region = e.region)
+   WHERE e.uid = $user_id
+   ORDER BY e.entrid
+   ";
+
+$result = mysql_query($reqsql);
+
+$i = 0;
+while(list($adr_pro[$i]['entreprise'], $adr_pro[$i]['secteur'], $adr_pro[$i]['ss_secteur'],
+           $adr_pro[$i]['fonction'], $adr_pro[$i]['poste'],
+          $adr_pro[$i]['adr1'], $adr_pro[$i]['adr2'], $adr_pro[$i]['adr3'],
+          $adr_pro[$i]['cp'], $adr_pro[$i]['ville'],
+          $adr_pro[$i]['pays'], $adr_pro[$i]['region'],
+          $adr_pro[$i]['tel'], $adr_pro[$i]['fax']) = mysql_fetch_row($result)){
+    if(!empty($adr_pro[$i]['entreprise']) || !empty($adr_pro[$i]['secteur']) ||
+       !empty($adr_pro[$i]['fonction']) || !empty($adr_pro[$i]['poste']) ||
+       !empty($adr_pro[$i]['adr1']) || !empty($adr_pro[$i]['adr2']) || !empty($adr_pro[$i]['adr3']) ||
+       !empty($adr_pro[$i]['cp']) || !empty($adr_pro[$i]['ville']) ||
+       !empty($adr_pro[$i]['pays']) || !empty($adr_pro[$i]['tel']) || !empty($adr_pro[$i]['fax'])
+      ){
+    $i++;
+   }
+}
+unset($adr_pro[$i]);
+$nb_infos_pro = $i;
+$page->assign('nb_infos_pro', $nb_infos_pro);
+$page->assign_by_ref('adr_pro', $adr_pro);
+mysql_free_result($result);
+
+//recuperation des adresses
+$reqsql =
+   "SELECT a.adr1,a.adr2,a.adr3,a.cp,a.ville,
+           gp.pays,gr.name AS region,a.tel,a.fax,
+           FIND_IN_SET('active', a.statut),
+           FIND_IN_SET('res-secondaire', a.statut)
+    FROM adresses AS a
+    LEFT JOIN geoloc_pays AS gp ON (gp.a2=a.pays)
+    LEFT JOIN geoloc_region AS gr ON (gr.a2=a.pays and gr.region=a.region)
+    WHERE uid=$user_id AND NOT FIND_IN_SET('pro',a.statut)
+    ORDER BY NOT FIND_IN_SET('active',a.statut), FIND_IN_SET('temporaire',a.statut), FIND_IN_SET('res-secondaire',a.statut)";
+
+$result = mysql_query($reqsql);
+
+$nbadr=mysql_num_rows($result);
+
+for ($i=0;$row = mysql_fetch_row($result);$i++) {
+
+    list(  $adr[$i]['adr1'], $adr[$i]['adr2'], $adr[$i]['adr3'],
+          $adr[$i]['cp'], $adr[$i]['ville'],
+          $adr[$i]['pays'], $adr[$i]['region'],
+          $adr[$i]['tel'], $adr[$i]['fax'], 
+           $adr[$i]['active'], $adr[$i]['secondaire']) = $row;
+
+    if ($adr[$i]['active'])
+            $adr[$i]['title'] = "Mon adresse actuelle :";
+    elseif ($adr[$i]['secondaire'])
+            $adr[$i]['title'] = "Adresse secondaire :";
+    else
+            $adr[$i]['title'] = "Adresse principale :";
+
+}
+$page->assign_by_ref('adr', $adr);
+mysql_free_result($result);
+
+
+// reformatage binets
+$result = mysql_query("SELECT text
+                       FROM binets_ins
+                       LEFT JOIN binets_def
+                       ON binets_ins.binet_id = binets_def.id
+                      WHERE user_id = '$user_id'");
+if (list($binets) = mysql_fetch_row($result)){
+        while (list($binet) = mysql_fetch_row($result))
+                $binets .= ", $binet";
+        } 
+}
+mysql_free_result($result);
+$page->assign('binets', $binets);
+
+// reformatage Groupes X
+$result = mysql_query("SELECT text, url
+                       FROM groupesx_ins
+                      LEFT JOIN groupesx_def ON groupesx_ins.gid = groupesx_def.id
+                      WHERE guid = '$user_id'");
+$gxs = "";
+while (list($gxt,$gxu) = mysql_fetch_row($result)) {
+        if ($gxs) $gxs .= ", ";
+        if ($gxu) $gxs .= "<a target=\"_blank\" href=\"$gxu\">";
+        $gxs .= $gxt;
+        if ($gxu) $gxs .= "</a>";
+} 
+mysql_free_result($result);
+$page->assign('groupes', $gxs);
+
+// reformatage appli
+$result = mysql_query("SELECT applis_def.text, applis_def.url, applis_ins.type
+                       FROM applis_ins
+                      INNER JOIN applis_def ON applis_def.id = applis_ins.aid
+                      WHERE uid='$user_id'
+                      ORDER by ordre");
+if (list($rapp_txt, $rapp_url, $rapp_type) = mysql_fetch_row($result)) {
+        $applis = applis_fmt($rapp_type, $rapp_txt, $rapp_url);
+        while (list($rapp_txt, $rapp_url, $rapp_type) = mysql_fetch_row($result)) {
+                $applis .=", ";
+                $applis .= applis_fmt($rapp_type, $rapp_txt, $rapp_url);
+        }
+}
+mysql_free_result($result);
+$page->assign('applis', $applis);
+
+$page->run();
+
+?>
index 310ed81..4e4946c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 require("auto.prepend.inc.php");
-new_simple_page('fiche_referent.tpl',AUTH_COOKIE);
+new_simple_page('fiche_referent.tpl',AUTH_COOKIE, false, 'add_fiche_css.tpl');
 
 //$isnetscape = !empty($_SESSION['skin_compatible']);
 
@@ -63,10 +63,6 @@ unset($adr_pro[$i]);
 $nb_infos_pro = $i;
 $page->assign('nb_infos_pro', $nb_infos_pro);
 $page->assign_by_ref('adr_pro', $adr_pro);
-if ($nb_infos_pro!=0)
-  $taille_adr_pro=(int)(100/$nb_infos_pro);
-else
-  $taille_adr_pro=100;
 mysql_free_result($result);
 
 /////  recuperations infos referent
diff --git a/htdocs/images/mail.png b/htdocs/images/mail.png
new file mode 100644 (file)
index 0000000..d7110f7
Binary files /dev/null and b/htdocs/images/mail.png differ
diff --git a/templates/add_fiche_css.tpl b/templates/add_fiche_css.tpl
new file mode 100644 (file)
index 0000000..39084a2
--- /dev/null
@@ -0,0 +1 @@
+<link rel="stylesheet" type="text/css" href="{"css/fiche.css"|url}" media="screen" />
diff --git a/templates/fiche.tpl b/templates/fiche.tpl
new file mode 100644 (file)
index 0000000..d7afff5
--- /dev/null
@@ -0,0 +1,132 @@
+{dynamic}
+<div class="boite">
+  <div class="item" style="text-align:center;padding-left: 20px;padding-right: 20px;">
+  <strong>{$prenom|htmlentities} {$nom|htmlentities}</strong><br />
+  <span>X {$promo|htmlentities}</span><br />
+  <span>Fiche mise à jour le {$date|date_format:"%d/%m/%Y"}</span><br />
+  <span><a href="vcard.php/{$username}.vcf?x={$username}"><img src="images/vcard.png" alt="Afficher la carte de visite" /></a>&nbsp;
+  {if !$is_contact}
+  <a href="javascript:x()"  onclick="popWin('mescontacts.php?action=ajouter&amp;user={$username}')"><img src="images/ajouter.gif" alt="Ajouter parmi mes contacts" /></a>&nbsp;
+  {/if}
+  <a target="_blank" href="sendmail.php?contenu=Tu%20trouveras%20ci-apres%20la%20fiche%20de%20{$prenom}%20{$nom}%20https://www.polytechnique.org/fiche.php?x={$username}"><img src="images/mail.png" alt="Envoyer l'URL" /></a></span><br />
+  <a href="mailto:{$username}@polytechnique.org">{$username}@polytechnique.org</a><br />
+  <span><em>Section</em> : {$section|htmlentities}</span><br />
+  <span><em>Binet(s)</em> : {$binets|htmlentities}</span><br />
+  <span><em>Groupe(s) X</em> : {$groupes|htmlentities}</span><br />
+  {if $mobile}<br /><span><em>Mobile</em> : {$mobile|htmlentities}</span><br />{/if}
+  {if $libre}<br /><span><em>Commentaires</em> :</span><br /><span>{$libre|htmlentities|nl2br}</span>{/if}
+  </div>
+  <div class="item">
+    <img alt="Photo de {$username}" src="{$photo_url}" width="{$size_x}" height="{$size_y}" />
+  </div>
+  <div class="spacer">&nbsp;</div>
+</div>
+
+{foreach from=$adr item="address" key="i"}
+<div class="boite">
+   <div class="titre">{$address.title}</div>
+         {if $address.adr1 || $address.pays || $address.ville}
+           <div class="item">
+            <div class="title">Adresse :</div>
+            <div class="value">
+              {if $address.adr1}<span>{$address.adr1|htmlentities}</span><br />{/if}
+              {if $address.adr2}<span>{$address.adr2|htmlentities}</span><br />{/if}
+              {if $address.adr3}<span>{$address.adr3|htmlentities}</span><br />{/if}
+              {if $address.ville}<span>{$address.cp|htmlentities} {$address.ville|htmlentities}</span><br />{/if}
+             {if $address.pays}
+              <span>{$address.pays|htmlentities}{if $address.region} ({$address.region|htmlentities}){/if}</span>
+             {/if}
+           </div>
+          </div>
+         {/if}
+       <div class="spacer">&nbsp;</div>
+         
+         {if $address.tel}
+           <div class="item">
+             <div class="title">Tél :</div>
+             <div class="value">{$address.tel|htmlentities}</div>
+           </div>
+         {/if}
+
+         {if $address.fax}
+           <div class="item">
+             <div class="title">Fax :</div>
+             <div class="value">{$address.fax|htmlentities}</div>
+           </div>
+         {/if}
+       <div class="spacer">&nbsp;</div>
+</div>
+{/foreach}
+
+{foreach from=$adr_pro item="address" key="i"}
+<div class="boite">
+   <div class="titre">Infos professionnelles - Entreprise n°{$i+1}</div>
+          {if $address.entreprise}
+           <div class="item">
+            <div class="title">Entreprise/Organisme :</div>
+             <div class="value">{$address.entreprise|htmlentities}</div>
+           </div>
+         {/if}
+         {if $address.secteur}
+           <div class="item">
+            <div class="title">Secteur :</div>
+            <div class="value">{$address.secteur|htmlentities}{if $address.ss_secteur} ({$address.ss_secteur|htmlentities}){/if}</div>
+           </div>
+         {/if}
+       <div class="spacer">&nbsp;</div>
+
+         {if $address.adr1 || $address.pays || $address.ville}
+           <div class="item">
+            <div class="title">Adresse :</div>
+            <div class="value">
+              {if $address.adr1}<span>{$address.adr1|htmlentities}</span><br />{/if}
+              {if $address.adr2}<span>{$address.adr2|htmlentities}</span><br />{/if}
+              {if $address.adr3}<span>{$address.adr3|htmlentities}</span><br />{/if}
+              {if $address.ville}<span>{$address.cp|htmlentities} {$address.ville|htmlentities}</span><br />{/if}
+             {if $address.pays}
+              <span>{$address.pays|htmlentities}{if $address.region} ({$address.region|htmlentities}){/if}</span>
+             {/if}
+           </div>
+          </div>
+         {/if}
+       <div class="spacer">&nbsp;</div>
+         
+         {if $address.fonction}
+           <div class="item">
+             <div class="title">Fonction :</div>
+             <div class="value">{$address.fonction|htmlentities}</div>
+           </div>
+         {/if}
+         {if $address.poste}
+           <div class="item">
+             <div class="title">Poste :</div>
+             <div class="value">{$address.poste|htmlentities}</div>
+           </div>
+         {/if}
+       <div class="spacer">&nbsp;</div>
+
+         {if $address.tel}
+           <div class="item">
+             <div class="title">Tél :</div>
+             <div class="value">{$address.tel|htmlentities}</div>
+           </div>
+         {/if}
+
+         {if $address.fax}
+           <div class="item">
+             <div class="title">Fax :</div>
+             <div class="value">{$address.fax|htmlentities}</div>
+           </div>
+         {/if}
+       <div class="spacer">&nbsp;</div>
+</div>
+{/foreach}
+
+{if $cv}
+<div class="boite">
+  <div class="titre">CV</div>
+  <div class="item">{$cv|htmlentities|nl2br}</div>
+  <div class="spacer">&nbsp;</div>
+</div>
+{/if}
+{/dynamic}
index 3c2b24f..63c9f2e 100644 (file)
@@ -1,41 +1,4 @@
 {dynamic}
-{literal}
-<style type="text/css" media="screen,print">
-div.boite{
-  border: 1px solid #5555BB;
-  background-color: #FFFFC0;
-  padding: 5px;
-  margin: 5px;
-}
-
-div.boite div.titre{
-  background-color: #9999FF;
-  margin: 5px;
-  padding: 5px;
-  text-align: center;
-}
-
-div.spacer{
-  clear: both;
-}
-
-div.boite div.item{
-  float: left;
-  padding: 5px;
-  margin: 5px;
-}
-
-div.item div.title{
-  font-weight: bold;
-}
-
-div.item div.value{
-
-}
-
-</style>
-{/literal}
-
 <div class="boite" style="text-align:center;">
   <span>{$prenom} {$nom}</span><br />
   <span>X{$promo}&nbsp;-&nbsp;</span>