Location: PHPKode > projects > Phpress > phpress/maquette.php
<?
/*
    Copyright (C)2004-2007  Matthieu Perez - hide@address.com

    This file is part of PhPress.

    PhPress 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 3 of the License, or
    (at your option) any later version.

    PhPress 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 PhPress.  If not, see <http://www.gnu.org/licenses/>.
*/
//////////////////////////
// maquette.php
//
// affiche la composition du journal sous forme de miniatures
session_start();
require 'program/common/constantes.php' ;
require LANG_PATH . $lang ."/msg.php";
require PROG_COM_PATH .'functions_mysql.php';
require PROG_COM_PATH . 'functions_common.php';
require 'program/html/default.css';

///////////////////////////////////////////////////////////////////////////////////////
// date reset :
if($clear_button)
{
$jd=$view_datas_jday;
}
// date backward :
if($back_arrow)
{
$jd=($jd-($interval+1));
}
// date fwd :
if($fwd_arrow)
{
$jd=($jd+($interval+1));
}

// variables :
$jd_date=get_gdate($lang, $jd);
$inter_date=get_gdate($lang, ($jd+$interval));
$titre=get_np_name($db, $npid);

$post_variables='
      <input type="hidden" name="jd" value="'.$jd.'">
      <input type="hidden" name="npid" value="'.$npid.'">
      <input type="hidden" name="interval" value="'.$interval.'">
      
      <input type="hidden" name="content_type" value="'.$content_type.'">
      <input type="hidden" name="art_cat" value="'.$art_cat.'">
      <input type="hidden" name="art_subcat" value="'.$art_subcat.'">
      <input type="hidden" name="art_rubrique" value="'.$art_rubrique.'">
      <input type="hidden" name="art_continent" value="'.$art_continent.'">
      <input type="hidden" name="art_dep" value="'.$art_dep.'">      
      <input type="hidden" name="art_country" value="'.$art_country.'">            
      <input type="hidden" name="art_com" value="'.$art_com.'">      
      
      <input type="hidden" name="hi_content_type" value="'.$hi_content_type.'">
      <input type="hidden" name="hi_art_cat" value="'.$hi_art_cat.'">
      <input type="hidden" name="hi_art_subcat" value="'.$hi_art_subcat.'">
      <input type="hidden" name="hi_art_rubrique" value="'.$hi_art_rubrique.'">
      <input type="hidden" name="hi_art_continent" value="'.$hi_art_continent.'">
      <input type="hidden" name="hi_art_country" value="'.$hi_art_country.'">      
      <input type="hidden" name="hi_art_dep" value="'.$hi_art_dep.'">      
      <input type="hidden" name="hi_art_com" value="'.$hi_art_com.'"> 
      
      <input type="hidden" name="affaire" value="'.$affaire.'">            
      ';
      
// page :
print '<TITLE>'.TXT_MAQUETTE.': '.$titre.' - '.$jd_date.'
      <table><tr>
      <td><red>'.$titre.'</red>
      &nbsp;-&nbsp;
      <date>'.$jd_date.'</date> -> <date>'.$inter_date.'</date></td>
      <td> &nbsp;&nbsp; </td>
      <td>'.TXT_INTERVAL.' : </td>
      ';
      
// interval
print '
     <FORM method="POST" name="chg_interval" target="_self" action="maquette.php">
      <input type="hidden" name="jd" value="'.$jd.'">
      <input type="hidden" name="npid" value="'.$npid.'">
    '.$post_variables.'
     <td>
     <select name="interval" onchange="document.chg_interval.submit()">';
   
   print '<option value="N"';
   select_previous($interval, "0");
   print '>0</option>';      
   print '<option value="1"';
   select_previous($interval, "1");
   print '>1</option>';
   print '<option value="2"';
   select_previous($interval, "2");
   print '>2</option>';
   print '<option value="3"';
   select_previous($interval, "3");
   print '>3</option>';
   print '<option value="5"';
   select_previous($interval, "5");
   print '>5</option>';
   print '<option value="6"';
   select_previous($interval, "6");
   print '>6</option>';
   print '<option value="7"';
   select_previous($interval, "7");
   print '>7</option> ';
   print '<option value="10"';
   select_previous($interval, "10");
   print '>10</option>';
   print '<option value="14"';
   select_previous($interval, "14");
   print '>14</option>';
   print '<option value="30"';
   select_previous($interval, "30");
   print '>30</option></td></select></form><td>&nbsp;</td>';

// backward/forward arrows :
print '
      <form name="compare_back_arrow" target="_self" action="maquette.php" method="POST">
      '.$post_variables.'

       <INPUT type="hidden" name="back_arrow" value="BWD">
       <td> 
       <INPUT type="submit" value="<" style="width: 2em;">
       </td></form>
       <form name="compare_clear_button" target="_self" action="maquette.php" method="POST">'.$post_variables.'
       <INPUT type="hidden" name="clear_button" value="CLS">
       <td> 
       <INPUT type="submit" value="-" style="width: 2em;">
       '.$post_variables.'
       </td></form>  
       <form name="compare_fwd_arrow" target="_self" action="maquette.php" method="POST">
       '.$post_variables.'
       <INPUT type="hidden" name="fwd_arrow" value="FWD">
       <td> 
       <INPUT type="submit" value=">" style="width: 2em;">
       </td></form><td>&nbsp;
        &nbsp; 
       <INPUT type="submit" value="'.TXT_CLOSE.'" onclick="top.close ();" style="width: 8em;">
       &nbsp;&nbsp;</td> </tr></table><hr>';
///////////////////////////////////////////////////////////////////////////////////////
// choix affichages
print '<table border="0" CELLSPACING=0 CELLPADDING=2 >
<tr align="center">
<td style="width: 8em;"><blue>'.TXT_ACTION.'</blue></td>
<td><blue>'.TXT_BLOCK_TYPE.':</blue></td>
<td><blue>'.TXT_CAT.':</blue></td>
<td><blue>'.TXT_SUBCAT.':</blue></td>

<td><blue>'.TXT_RUBRIQUES.':</blue></td>
<td><blue>'.TXT_CONTINENT.':</blue></td>
<td><blue>'.TXT_COUNTRY.':</blue></td>
<td><blue>'.TXT_FR_DEP.':</blue></td>
<td><blue>'.TXT_FR_COM.':</blue></td>

</tr>
<tr bgcolor="yellow" align="center"><td>'.TXT_AFFICHER.'</td>';

print '
<FORM name="mq_type_form" method="POST" target="_self">
'.$post_variables.'
<td>
 <SELECT name="content_type" onchange="document.mq_type_form.submit();" style="width: 8em;">
  <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>';
  
  opt_list(1, TXT_REDAC, $content_type);
  opt_list(2, TXT_SERV, $content_type);
  opt_list(3, TXT_PUB, $content_type);
  opt_list(4, TXT_OURS, $content_type);   
  print '<option disabled>----------------</option>';         
  opt_list('ALL', TXT_ALL, $content_type);
                       
print '</SELECT> </td> </FORM>
<FORM name="mq_cat_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="art_cat" onchange="document.mq_cat_form.submit();" style="width: 8em;" >
  <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>';
  opt_list('ALL', TXT_ALL, $art_cat);
  print '<option disabled>----------------</option>';  
  
  // get list of categories
  if(!$content_type)
  {
  $request='';
  }
  else 
  {   
   if($content_type=='ALL')
   {
   $request="SELECT IdCat FROM ArtCat ORDER BY ContentType ";
   }
   else
   {
   $request="SELECT IdCat FROM ArtCat WHERE ContentType='$content_type' ";
   }
  }
    
   $query_result=sql_request($db, $request) ;
   while($result=mysql_fetch_array($query_result))
   {
   $cat=$result[0];
   $cat_name=get_cat($db, $lang, $cat);
   opt_list($cat, $cat_name, $art_cat);
   }

   // choix matieres
print '</SELECT> </td> </FORM>
<FORM name="mq_subcat_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="art_subcat" onchange="document.mq_subcat_form.submit();" style="width: 8em;" >
  <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>'; 
  opt_list('ALL', TXT_ALL, $art_subcat);
  print '<option disabled>----------------</option>';   
  
   if($art_cat=='ALL')
   {
   $request="SELECT IdSubcat FROM ArtSubcat ORDER BY IdCat ";
   }
   else if($art_cat)
   {
   $request="SELECT IdSubcat FROM ArtSubcat WHERE IdCat='$art_cat' ";
   }   
   
   $query_result=sql_request($db, $request) ;
   while($result=mysql_fetch_array($query_result))
   {
   $subcat=$result[0];
   $subcat_name=get_subcat($db, $lang, $subcat);
   opt_list($subcat, $subcat_name, $art_subcat);
   }

// choix rubrique
print '</SELECT> </td> </FORM>
<FORM name="mq_rubrique_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="art_rubrique" onchange="document.mq_rubrique_form.submit();" style="width: 8em;" >
  <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>'; 
  opt_list('ALL', TXT_ALL, $art_rubrique);
  print '<option disabled>----------------</option>';   
     
  $request="SELECT IdRubrique FROM Rubriques WHERE NPTitle='$npid'ORDER BY Rubrique";

  $query_result=sql_request($db, $request) ;
  while($result=mysql_fetch_array($query_result))
   {
   $rubrique=$result[0];
   $rubrique_name=get_rub($db, $rubrique); 
   opt_list($rubrique, $rubrique_name, $art_rubrique);
   }  
  
// choix continent
print '</SELECT> </td> </FORM>
<FORM name="mq_continent_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="art_continent" onchange="document.mq_continent_form.submit();" style="width: 8em;" >
    <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>'; 
  opt_list('ALL', TXT_ALL, $art_continent);
  print '<option disabled>----------------</option>';  

$continent=$art_continent;

include PROG_COM_PATH .'options_continents.php';  
     
// choix pays
print '</SELECT> </td> </FORM>
<FORM name="mq_country_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="art_country" onchange="document.mq_country_form.submit();" style="width: 8em;" >
   <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>'; 
  opt_list('ALL', TXT_ALL, $art_country);
  print '<option disabled>----------------</option>';  
  
  if(!$art_continent)
   {
   $request="SELECT LIBCOG, ANCNOM FROM GeoWorld ORDER BY OCC DESC LIMIT 0,10";
   }
   else
   {
   $request="SELECT LIBCOG, ANCNOM FROM GeoWorld WHERE CONTINENT='$art_continent' ORDER BY OCC DESC";
   }
   
  $query_result=sql_request($db, $request) ;
  while($result=mysql_fetch_array($query_result))
  {
   $country_code=$result[0]; 
   if($result[1]){$anc_nom="[ $result[1] ]";} else{$anc_nom='';}
   $country_name="$country_code $anc_nom";
       
    print '<option value="'.$country_code.'"';
    select_previous($art_country, $country_code);
    print '>'.$country_name.'</option>';
   }
   
// departements (france)
print '</SELECT> </td> </FORM>
<FORM name="mq_fr_dep_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="art_dep" onchange="document.mq_fr_dep_form.submit();" style="width: 8em;" > <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>'; 
  opt_list('ALL', TXT_ALL, $art_dep);
  print '<option disabled>----------------</option>';  
  
   // get the list of departements ordered by occurence
   
   $request_occ="SELECT DEP, NCCENR from GeoFranceDep ORDER BY OCC DESC LIMIT 0 , 5";
   $query_result_occ=sql_request($db, $request_occ);
   
   $request_alpha="SELECT DEP, NCCENR from GeoFranceDep ORDER BY DEP";
   $query_result_alpha=sql_request($db, $request_alpha);
   
   while ($result_occ=mysql_fetch_array($query_result_occ)) 
    {
     $dep_code=$result_occ[0];
     $dep_name=$result_occ[1];
       
       print '
       <option value="'.$dep_code.'"';
       select_previous($art_dep, $dep_code);
           
       print '>['.$dep_code.']&nbsp; '.$dep_name.'</option>';
      }
      print '
      <option disabled>-----</option>';
      
      // list of all departements
    while ($result_alpha = mysql_fetch_array($query_result_alpha))
      {
       $dep_code=$result_alpha[0];
       $dep_name=$result_alpha[1];
       
       print '
       <option value="'.$dep_code.'"';
       select_previous($art_dep, $dep_code);

      print '>['.$dep_code.']&nbsp; '.$dep_name.'</option>';
      }
      
// communes (france)
print '</SELECT> </td> </FORM>
<FORM name="mq_fr_com_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="art_com" onchange="document.mq_fr_com_form.submit();" style="width: 8em;" > <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>'; 
  opt_list('ALL', TXT_ALL, $art_com);
  print '<option disabled>----------------</option>';  

if($art_dep)
{  
  if($art_dep=='ALL')
  {
  $request_occ="SELECT DEP, ARTMIN, NCCENR, INSEE from GeoFranceCommunes ORDER BY OCC DESC LIMIT 0 , 30";
  }
  else 
  {
  $request_occ="SELECT DEP, ARTMIN, NCCENR, INSEE from GeoFranceCommunes WHERE DEP='$art_dep' ORDER BY OCC DESC";
  }
  $query_result=sql_request($db, $request_occ);
  
  while ($result=mysql_fetch_array($query_result))
      {
       $com_dep=$result[0];       
       $com_art=$result[1];       
       $com_name=$result[2];
       $com_insee=$result[3];       

       $get_dep_name_request="SELECT NCCENR from GeoFranceDep WHERE DEP='$com_dep'";
       $get_dep_name_query_result=sql_request($db, $get_dep_name_request);
       $get_dep_name_result=mysql_fetch_array($get_dep_name_query_result);
       $com_dep_name=$get_dep_name_result[0];
       
         print '
       <option value="'.$com_insee.'"';
       select_previous($com_insee, $art_com);
       print '> '.$com_name.'&nbsp;' .$com_art. '&nbsp;[' .$com_dep. '&nbsp;-&nbsp;'.$com_dep_name.']</option>';      
      } 
}
      
print '</SELECT> </td> </FORM></tr>';     
// 
///////////////////////////////////////////////////////////////////////////////////////
// choix surbrillance
print '<tr bgcolor="red" align="center"><td>'.TXT_HIGHLIGHT.'</td>';
print '
<FORM name="hi_type_form" method="POST" target="_self">
'.$post_variables.'
<td>
 <SELECT name="hi_content_type" onchange="document.hi_type_form.submit();" style="width: 8em;">
  <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>';
  
  opt_list(1, TXT_REDAC, $hi_content_type);
  opt_list(2, TXT_SERV, $hi_content_type);
  opt_list(3, TXT_PUB, $hi_content_type);
  opt_list(4, TXT_OURS, $hi_content_type);   
  print '<option disabled>----------------</option>';         
  opt_list('ALL', TXT_ALL, $hi_content_type);
                       
print '</SELECT> </td> </FORM>
<FORM name="hi_cat_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="hi_art_cat" onchange="document.hi_cat_form.submit();" style="width: 8em;" >
  <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>';
  opt_list('ALL', TXT_ALL, $hi_art_cat);
  print '<option disabled>----------------</option>';  
  
  // get list of categories
  if(!$hi_content_type)
  {
  $request='';
  }
  else 
  {
   if($hi_content_type=='ALL')
   {
   $request="SELECT IdCat FROM ArtCat ORDER BY ContentType ";
   }
   else
   {
   $request="SELECT IdCat FROM ArtCat WHERE ContentType='$hi_content_type' ";
   }
  }
    
   $query_result=sql_request($db, $request) ;
   while($result=mysql_fetch_array($query_result))
   {
   $hi_cat=$result[0];
   $hi_cat_name=get_cat($db, $lang, $hi_cat);
   opt_list($hi_cat, $hi_cat_name, $hi_art_cat);
   }

   // choix matieres
print '</SELECT> </td> </FORM>
<FORM name="hi_subcat_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="hi_art_subcat" onchange="document.hi_subcat_form.submit();" style="width: 8em;" >
  <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>'; 
  opt_list('ALL', TXT_ALL, $hi_art_subcat);
  print '<option disabled>----------------</option>';   
  
   if($hi_art_cat=='ALL')
   {
   $request="SELECT IdSubcat FROM ArtSubcat ORDER BY IdCat ";
   }
   else if($hi_art_cat)
   {
   $request="SELECT IdSubcat FROM ArtSubcat WHERE IdCat='$hi_art_cat' ";
   }   
   
   $query_result=sql_request($db, $request) ;
   while($result=mysql_fetch_array($query_result))
   {
   $hi_subcat=$result[0];
   $hi_subcat_name=get_subcat($db, $lang, $hi_subcat);
   opt_list($hi_subcat, $hi_subcat_name, $hi_art_subcat);
   }

// choix rubrique
print '</SELECT> </td> </FORM>
<FORM name="hi_rubrique_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="hi_art_rubrique" onchange="document.hi_rubrique_form.submit();" style="width: 8em;" >
  <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>'; 
  opt_list('ALL', TXT_ALL, $hi_art_rubrique);
  print '<option disabled>----------------</option>';   
     
  $request="SELECT IdRubrique FROM Rubriques WHERE NPTitle='$npid'ORDER BY Rubrique";

  $query_result=sql_request($db, $request) ;
  while($result=mysql_fetch_array($query_result))
   {
   $hi_rubrique=$result[0];
   $hi_rubrique_name=get_rub($db, $hi_rubrique); 
   opt_list($hi_rubrique, $hi_rubrique_name, $hi_art_rubrique);
   }  
  
// choix continent
print '</SELECT> </td> </FORM>
<FORM name="hi_continent_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="hi_art_continent" onchange="document.hi_continent_form.submit();" style="width: 8em;" >
    <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>'; 
  opt_list('ALL', TXT_ALL, $hi_art_continent);
  print '<option disabled>----------------</option>';  

$continent=$hi_art_continent;

include PROG_COM_PATH .'options_continents.php';  
     
// choix pays
print '</SELECT> </td> </FORM>
<FORM name="hi_country_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="hi_art_country" onchange="document.hi_country_form.submit();" style="width: 8em;" >
   <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>'; 
  opt_list('ALL', TXT_ALL, $hi_art_country);
  print '<option disabled>----------------</option>';  
  
  if(!$hi_art_continent)
   {
   $request="SELECT LIBCOG, ANCNOM FROM GeoWorld ORDER BY OCC DESC LIMIT 0,10";
   }
   else
   {
   $request="SELECT LIBCOG, ANCNOM FROM GeoWorld WHERE CONTINENT='$hi_art_continent' ORDER BY OCC DESC";
   }
   
  $query_result=sql_request($db, $request) ;
  while($result=mysql_fetch_array($query_result))
  {
   $hi_country_code=$result[0]; 
   if($result[1]){$hi_anc_nom="[ $result[1] ]";} else{$hi_anc_nom='';}
   $hi_country_name="$hi_country_code $hi_anc_nom";
       
    print '<option value="'.$hi_country_code.'"';
    select_previous($hi_art_country, $hi_country_code);
    print '>'.$hi_country_name.'</option>';
   }
   
// departements (france)
print '</SELECT> </td> </FORM>
<FORM name="hi_fr_dep_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="hi_art_dep" onchange="document.hi_fr_dep_form.submit();" style="width: 8em;" > <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>'; 
  opt_list('ALL', TXT_ALL, $hi_art_dep);
  print '<option disabled>----------------</option>';  
  
   // get the list of departements ordered by occurence
   $request_occ="SELECT DEP, NCCENR from GeoFranceDep ORDER BY OCC DESC LIMIT 0 , 5";
   $query_result_occ=sql_request($db, $request_occ);
   
   $request_alpha="SELECT DEP, NCCENR from GeoFranceDep ORDER BY DEP";
   $query_result_alpha=sql_request($db, $request_alpha);
   
   while ($result_occ=mysql_fetch_array($query_result_occ)) 
    {
     $hi_dep_code=$result_occ[0];
     $hi_dep_name=$result_occ[1];
       
       print '
       <option value="'.$hi_dep_code.'"';
       select_previous($hi_art_dep, $hi_dep_code);
           
       print '>['.$hi_dep_code.']&nbsp; '.$hi_dep_name.'</option>';
      }
      print '
      <option disabled>-----</option>';
      
      // list of all departements
    while ($result_alpha = mysql_fetch_array($query_result_alpha))
      {
       $hi_dep_code=$result_alpha[0];
       $hi_dep_name=$result_alpha[1];
       
       print '
       <option value="'.$hi_dep_code.'"';
       select_previous($hi_art_dep, $hi_dep_code);

      print '>['.$hi_dep_code.']&nbsp; '.$hi_dep_name.'</option>';
      }
      
// communes (france)
print '</SELECT> </td> </FORM>
<FORM name="hi_fr_com_form" method="POST" target="_self">
'.$post_variables.'
<td>
<SELECT name="hi_art_com" onchange="document.hi_fr_com_form.submit();" style="width: 8em;" > <option value="">'.TXT_NONE.'</option>
  <option disabled>----------------</option>'; 
  opt_list('ALL', TXT_ALL, $hi_art_com);
  print '<option disabled>----------------</option>';  

if($hi_art_dep)
{  
  if($hi_art_dep=='ALL')
  {
  $request_occ="SELECT DEP, ARTMIN, NCCENR, INSEE from GeoFranceCommunes ORDER BY OCC DESC LIMIT 0 , 30";
  }
  else 
  {
  $request_occ="SELECT DEP, ARTMIN, NCCENR, INSEE from GeoFranceCommunes WHERE DEP='$hi_art_dep' ORDER BY OCC DESC";
  }
  $query_result=sql_request($db, $request_occ);
  
  while ($result=mysql_fetch_array($query_result))
      {
       $com_dep=$result[0];       
       $com_art=$result[1];       
       $com_name=$result[2];
       $com_insee=$result[3];       

       $get_dep_name_request="SELECT NCCENR from GeoFranceDep WHERE DEP='$com_dep'";
       $get_dep_name_query_result=sql_request($db, $get_dep_name_request);
       $get_dep_name_result=mysql_fetch_array($get_dep_name_query_result);
       $com_dep_name=$get_dep_name_result[0];
       
         print '
       <option value="'.$com_insee.'"';
       select_previous($com_insee, $hi_art_com);
       print '> '.$com_name.'&nbsp;' .$com_art. '&nbsp;[' .$com_dep. '&nbsp;-&nbsp;'.$com_dep_name.']</option>';      
      } 
}
// affaires      
print '</SELECT> </td> </FORM></tr><tr><td>&nbsp;</td></tr>
       <tr bgcolor="blue" align="center"><td>'.TXT_AFFAIRES.' n° :</td>
       <FORM name="affire_form" method="POST" target="_self">
       '.$post_variables.'
       <td><INPUT name="affaire" type="text" style="width: 8em;" value="'.$affaire.'"></td>
       <td><INPUT type="submit" value="'.TXT_AFFAIRES.'" style="width: 8em;"></td>
       ';

print '</FORM></tr></table><hr>';
///////////////////////////////////////////////////////////////////////////////////////
// bouton validation
print '
<FORM name="print_form" method="POST" target="_self">
<input type="hidden" name="proceed" value="images">
'.$post_variables.'
<div align="center">
<INPUT type="submit" value="'.TXT_PROCEED.'" style="width: 9em;" align="center">
</div><hr></FORM>';

///////////////////////////////////////////////////////////////////////////////////////
// creation des images
if($proceed)
{
// les jours concernés :
$end_jd=($interval+$jd);
$request="SELECT COUNT(Page), JDay FROM Pages WHERE CDGroup ='$npid' AND JDay BETWEEN '$jd' AND '$end_jd' GROUP BY JDay";
$query_result=sql_request($db, $request) ; 
while($result=mysql_fetch_array($query_result))
{
$count=$result[0];
$curr_jd=$result[1];

$g_date=get_gdate($lang, $curr_jd);
$titre=get_np_name($db, $npid);
$text="$titre - $g_date";

// on calcule la taille de l'image
$img_width = ($count*$miniature_width)+($count*10);
$maxh_request= "SELECT MAX(PNG_Height) FROM Pages WHERE CDGroup ='$npid' AND JDay='$curr_jd'";
$maxh_query_result=sql_request($db, $maxh_request) ; 
$maxh_result=mysql_fetch_array($maxh_query_result) ;
$max_heigth=$maxh_result[0];
$maxw_request= "SELECT MAX(PNG_Width) FROM Pages WHERE CDGroup ='$npid' AND JDay='$curr_jd'";
$maxw_query_result=sql_request($db, $maxw_request) ; 
$maxw_result=mysql_fetch_array($maxw_query_result) ;
$max_width=$maxw_result[0];

// determines $i
$i=($miniature_width/$max_width);

// image heigth
$img_height=(int)($max_heigth*$i)+35;

// fond de l'image
// creates image
$im = imagecreatetruecolor ($img_width, $img_height);

$white = imagecolorallocate($im, 255,255,255);
$black = imagecolorallocate($im, 0,0,0);
//$background= imagecolorallocate($im, 230,230,230);
$background= imagecolorallocate($im, 0,0,0);
$printed = imagecolorallocate($im, 209,209,209);
$transp = imagecolortransparent ($im, $black);
$textcolor = imagecolorallocate($im, 0, 0, 255);
$border = imagecolorallocate($im, 0,0,1);

$blue = imagecolorallocate($im, 0, 0, 160);
$red = imagecolorallocate($im, 255, 69, 0);
$yellow = imagecolorallocate($im, 255, 255, 0);
$teal = imagecolorallocate($im, 0,128,128);
$purple = imagecolorallocate($im, 160,32,240);
$palegreen = imagecolorallocate($im, 152,251,152);

// background
imagefilledrectangle($im, 0, 0, $img_width, $img_height, $background);

// titre de l'image
imagestring($im, 3, 10, 0, $text, $textcolor);

// on remet à zéro l'espace entre les miniatures
$img_space='10';

// pages
// get page info
$png_request="SELECT PNG_Width, PNG_Height, A_x, A_y, B_x, B_y, C_x, C_y, D_x, D_y, Page FROM Pages WHERE JDay='$curr_jd' AND CDGroup='$npid'";
$png_query_result=sql_request($db, $png_request);
while($png_result=mysql_fetch_array($png_query_result))
{ 
// source :
$PNG_Width=$png_result[0];
$PNG_Height=$png_result[1];
$PNG_Page=$png_result[10];

// determines $i
$i=($miniature_width/$PNG_Width);

// miniature heigth
$miniature_height=(int)($PNG_Height*$i);

$x1=$img_space;
$y1=15;
$x2=$img_space+$miniature_width;
$y2=$miniature_height+15;

imagefilledrectangle($im, $x1, $y1, $x2, $y2, $white);

// n° de la page
$text_page=$PNG_Page;
imagestring($im, 3, ($img_space+($miniature_width/2)), ($img_height-15), $text_page, $textcolor);

//printed surface
$mini_p_A_x=(int)($png_result[2]*$i)+$x1 ;
$mini_p_A_y=(int)($png_result[3]*$i)+$y1 ;
$mini_p_B_x=(int)($png_result[4]*$i)+$x1 ;
$mini_p_B_y=(int)($png_result[5]*$i)+$y1 ;
$mini_p_C_x=(int)($png_result[6]*$i)+$x1 ;
$mini_p_C_y=(int)($png_result[7]*$i)+$y1 ;
$mini_p_D_x=(int)($png_result[8]*$i)+$x1 ;
$mini_p_D_y=(int)($png_result[9]*$i)+$y1 ;

creates_polygon($im, $printed, $mini_p_A_x, $mini_p_A_y, $mini_p_B_x, $mini_p_B_y, $mini_p_C_x, $mini_p_C_y, $mini_p_D_x, $mini_p_D_y);

////////////////////////////////////////////////////////////////////////////////////
// articles
/////////////////////////////////////////////////////////////////////////////////////
// premier passage : les articles à afficher
$afficher_valeurs=$content_type.$art_cat.$art_subcat.$art_rubrique.$art_continent.$art_dep.$art_dep.$art_country.$art_com ;
// si on a des données :
if($afficher_valeurs)
{
// content_type
   if(!$content_type) { $sql_content=' AND ContentType IS NULL '; }
   else if($content_type=='ALL') {$sql_content='';}
   else { $sql_content=" AND ContentType ='$content_type' "; }

// $art_cat
   if(!$art_cat) { $sql_cat=' AND  ArticleType IS NULL '; }
   else if($art_cat=='ALL') {$sql_cat='';}
   else { $sql_cat=" AND ArticleType ='$art_cat' "; }  

// $art_subcat
   if(!$art_subcat) { $sql_subcat=' AND Subcategory IS NULL '; }
   else if($art_subcat=='ALL') {$sql_subcat='';}
   else { $sql_subcat=" AND  Subcategory ='$art_subcat' "; }    
   
// $art_rubrique
   if(!$art_rubrique) { $sql_rubrique=' AND Rubrique IS NULL '; }
   else if($art_rubrique=='ALL') {$sql_rubrique='';}
   else { $sql_rubrique=" AND Rubrique ='$art_rubrique' "; }       
   
// $art_continent
   if(!$art_continent) { $sql_continent=' AND  Continent IS NULL '; }
   else if($art_continent=='ALL') {$sql_continent='';}
   else { $sql_continent=" AND  Continent ='$art_continent' "; }    
   
// $art_country
   if(!$art_country) { $sql_country=' AND  Country IS NULL '; }
   else if($art_country=='ALL') {$sql_country='';}
   else { $sql_country=" AND  Country ='$art_country' "; }  
   
// $art_dep
   if(!$art_dep) { $sql_dep=' AND  Departement IS NULL '; }
   else if($art_dep=='ALL') {$sql_dep='';}
   else { $sql_dep=" AND  Departement ='$art_dep' "; }   
   
// $art_com
   if(!$art_com) { $sql_com=' AND  INSEE IS NULL '; }
   else if($art_com=='ALL') {$sql_com='';}
   else { $sql_com=" AND  INSEE ='$art_com' "; }
   
// request :
   $articles_request="SELECT IdArticle, ContentType FROM Articles WHERE  JDay='$curr_jd' AND NPTitle ='$npid' AND Page='$PNG_Page' $sql_content $sql_cat $sql_subcat $sql_rubrique $sql_continent $sql_country $sql_dep $sql_com ";   
   
   $articles_query_result=sql_request($db, $articles_request);
   while($articles_result=mysql_fetch_array($articles_query_result))
   { 
   $id_article=$articles_result[0];
   $curr_content_type=$articles_result[1];
   
   if($curr_content_type=='1'){ $art_color=$yellow; }
   else if($curr_content_type=='2'){ $art_color=$teal; }
   else if($curr_content_type=='3'){ $art_color=$purple; }
   else if($curr_content_type=='4'){ $art_color=$palegreen; }

   // determines the mini block area
   $block_request="SELECT A_x, A_y, B_x, B_y, C_x, C_y, D_x, D_y FROM Blocks WHERE  IdArticle='$id_article'";
   $block_query_result=sql_request($db, $block_request) ; 
   while($block_result=mysql_fetch_array($block_query_result)) 
   {
   $mini_b_A_x=(int)($block_result[0]*$i)+$x1;
   $mini_b_A_y=(int)($block_result[1]*$i)+$y1;
   $mini_b_B_x=(int)($block_result[2]*$i)+$x1;
   $mini_b_B_y=(int)($block_result[3]*$i)+$y1;
   $mini_b_C_x=(int)($block_result[4]*$i)+$x1;
   $mini_b_C_y=(int)($block_result[5]*$i)+$y1;
   $mini_b_D_x=(int)($block_result[6]*$i)+$x1;
   $mini_b_D_y=(int)($block_result[7]*$i)+$y1;

   creates_polygon($im, $art_color, $mini_b_A_x, $mini_b_A_y, $mini_b_B_x, $mini_b_B_y, $mini_b_C_x, $mini_b_C_y, $mini_b_D_x, $mini_b_D_y);
   }  
   
   }
   
             
}
///////////////////////////////////////////////////////////////////////////////////
// deuxième passage : les articles à souligner
$hi_afficher_valeurs=$hi_content_type.$hi_art_cat.$hi_art_subcat.$hi_art_rubrique.$hi_art_continent.$hi_art_dep.$hi_art_dep.$hi_art_country.$hi_art_com ;

// si on a des données :
if($hi_afficher_valeurs)
{
// content_type
   if(!$hi_content_type) { $sql_content=' AND ContentType IS NULL '; }
   else if($hi_content_type=='ALL') {$sql_content='';}
   else { $sql_content=" AND ContentType ='$hi_content_type' "; }

// $art_cat
   if(!$hi_art_cat) { $sql_cat=' AND  ArticleType IS NULL '; }
   else if($hi_art_cat=='ALL') {$sql_cat='';}
   else { $sql_cat=" AND ArticleType ='$hi_art_cat' "; }  

// $art_subcat
   if(!$hi_art_subcat) { $sql_subcat=' AND Subcategory IS NULL '; }
   else if($hi_art_subcat=='ALL') {$sql_subcat='';}
   else { $sql_subcat=" AND  Subcategory ='$hi_art_subcat' "; }    
   
// $art_rubrique
   if(!$hi_art_rubrique) { $sql_rubrique=' AND Rubrique IS NULL '; }
   else if($hi_art_rubrique=='ALL') {$sql_rubrique='';}
   else { $sql_rubrique=" AND Rubrique ='$hi_art_rubrique' "; }       
   
// $art_continent
   if(!$hi_art_continent) { $sql_continent=' AND  Continent IS NULL '; }
   else if($hi_art_continent=='ALL') {$sql_continent='';}
   else { $sql_continent=" AND  Continent ='$hi_art_continent' "; }    
   
// $art_country
   if(!$hi_art_country) { $sql_country=' AND  Country IS NULL '; }
   else if($hi_art_country=='ALL') {$sql_country='';}
   else { $sql_country=" AND  Country ='$hi_art_country' "; }  
   
// $art_dep
   if(!$hi_art_dep) { $sql_dep=' AND  Departement IS NULL '; }
   else if($hi_art_dep=='ALL') {$sql_dep='';}
   else { $sql_dep=" AND  Departement ='$hi_art_dep' "; }   
   
// $art_com
   if(!$hi_art_com) { $sql_com=' AND  INSEE IS NULL '; }
   else if($hi_art_com=='ALL') {$sql_com='';}
   else { $sql_com=" AND  INSEE ='$hi_art_com' "; }
   
// request :
   $hi_articles_request="SELECT IdArticle FROM Articles WHERE  JDay='$curr_jd' AND NPTitle ='$npid' AND Page='$PNG_Page' $sql_content $sql_cat $sql_subcat $sql_rubrique $sql_continent $sql_country $sql_dep $sql_com ";   
   
   $hi_articles_query_result=sql_request($db, $hi_articles_request);
   while($hi_articles_result=mysql_fetch_array($hi_articles_query_result))
   { 
   $id_article=$hi_articles_result[0];
   //$curr_content_type=$articles_result[1];

   // determines the mini block area
   $block_request="SELECT A_x, A_y, B_x, B_y, C_x, C_y, D_x, D_y FROM Blocks WHERE  IdArticle='$id_article'";
   $block_query_result=sql_request($db, $block_request) ; 
   while($block_result=mysql_fetch_array($block_query_result)) 
   {
   $mini_b_A_x=(int)($block_result[0]*$i)+$x1;
   $mini_b_A_y=(int)($block_result[1]*$i)+$y1;
   $mini_b_B_x=(int)($block_result[2]*$i)+$x1;
   $mini_b_B_y=(int)($block_result[3]*$i)+$y1;
   $mini_b_C_x=(int)($block_result[4]*$i)+$x1;
   $mini_b_C_y=(int)($block_result[5]*$i)+$y1;
   $mini_b_D_x=(int)($block_result[6]*$i)+$x1;
   $mini_b_D_y=(int)($block_result[7]*$i)+$y1;

   creates_polygon($im, $red, $mini_b_A_x, $mini_b_A_y, $mini_b_B_x, $mini_b_B_y, $mini_b_C_x, $mini_b_C_y, $mini_b_D_x, $mini_b_D_y);
   }  
   }
 }
 //////////////////////////////////////////////////////////////////////////////////
// troisieme passage : affaire
 if($affaire)
 {
 // request :
   $affaire_request="SELECT IdArticle FROM Articles WHERE  JDay='$curr_jd' AND NPTitle ='$npid' AND Page='$PNG_Page' AND Affair='$affaire' ";   
   
   $affaire_query_result=sql_request($db, $affaire_request);
   while($affaire_result=mysql_fetch_array($affaire_query_result))
   { 
   $id_article=$affaire_result[0];
   //$curr_content_type=$articles_result[1];

   // determines the mini block area
   $block_request="SELECT A_x, A_y, B_x, B_y, C_x, C_y, D_x, D_y FROM Blocks WHERE  IdArticle='$id_article'";
   $block_query_result=sql_request($db, $block_request) ; 
   while($block_result=mysql_fetch_array($block_query_result)) 
   {
   $mini_b_A_x=(int)($block_result[0]*$i)+$x1;
   $mini_b_A_y=(int)($block_result[1]*$i)+$y1;
   $mini_b_B_x=(int)($block_result[2]*$i)+$x1;
   $mini_b_B_y=(int)($block_result[3]*$i)+$y1;
   $mini_b_C_x=(int)($block_result[4]*$i)+$x1;
   $mini_b_C_y=(int)($block_result[5]*$i)+$y1;
   $mini_b_D_x=(int)($block_result[6]*$i)+$x1;
   $mini_b_D_y=(int)($block_result[7]*$i)+$y1;

   creates_polygon($im, $blue, $mini_b_A_x, $mini_b_A_y, $mini_b_B_x, $mini_b_B_y, $mini_b_C_x, $mini_b_C_y, $mini_b_D_x, $mini_b_D_y);
   }  

   }

 }
 // on souligne les bords des pages :
 imagerectangle($im, $x1, $y1, $x2, $y2, $border);
 
//////////////////////////////////////////////////////////////////////////////////
// mise a jour de img_space

   if(!is_int($PNG_Page/2))
   {
   $img_space=($img_space+$miniature_width+12);
   }
   else
   {
   $img_space=($img_space+$miniature_width);
   }
}

///////////////////////////////////////////////////////////////////////////:
// creation de l'image
if($user)
{
$print_png='users/'.$user.'/tmp/mini_tmp_'.$npid.'_'.$curr_jd.'.png';
}
else
{
// tmp 
$print_png=$tmp_nobody_dir.'mini_tmp_'.$npid.'_'.$curr_jd.'.png';
}

imagepng ($im, $print_png);
print '<IMG src="'.$print_png.'" width="'.$img_width.'" height="'.$img_height.'" border="1"><br><br>';

imagedestroy ($im);

}
}
?>
Return current item: Phpress