Location: PHPKode > projects > Biblioteca > html/etatadd.php
<?php
/* Biblos -- A library administration web interface
 * Copyright (C) 2007 Jean-Nicolas Lagalaye <hide@address.com>
 *
 * 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.
 */
 $sw	= $_POST['sw'];
 $etat  = $_POST['etat']; 
 $value  = $_POST['etat_value']; 

                        if($sw==1)
                        {                       
                          $requete = "select * from etats where etat ='$etat'";
                          $resultat = biblio_db_query($requete);
                          $trouve=biblio_db_num_rows($resultat);
                          if ($trouve > 0)
                          {
                           echo "<CENTER><BR>";
			   echo _("L'&eacute;tat <b>$etat</b> est d&eacute;jà existant dans la base de donn&eacute;es, recommencez!");
			   echo "<BR><BR>";
                           echo "<A HREF=\"admin.php?action=add&type=eleve\">";
			   echo _("retour");
			   echo "</A></CENTER>";
                          }
                          else 
                          {
                           
                           $requete = "insert into etats (etat,value) values ('$etat',$value)";
                           if(!($resultat = biblio_db_query($requete)))
                           { echo "PROBLEME : " .biblio_db_error(); exit;} 
                           put_log(2,$requete,$user);                          
                           echo "<CENTER><BR><b>$etat</b> ";
			   echo _("est ajout&eacute; à la base de donn&eacute;es.");
			   echo "<br></center>";
                          }
                        }
                        else
                        {
                          ?>
                                <CENTER><H3>
				<?php echo _("Ajouter un &eacute;tat de livre"); ?>
				</H3>
                                <FORM action=admin.php METHOD=POST>
                                <TABLE BORDER=0>
                                <TR>
                                <TD>
				<?php echo _("Etat"); ?>
				:</TD><TD><INPUT TYPE="text" NAME="etat" size=20></TD>                                
				</tr>
        			<tr>
				<td>
				<?php echo _("Echelle de valeur"); ?>
				:</td><td>
				<span style="background-color: #ff0000"><input type=radio name=etat_value value=0>0</span>
				<span style="background-color: #fd1006"><input type=radio name=etat_value value=1>1</span>
				<span style="background-color: #fe6b10"><input type=radio name=etat_value value=2>2</span>
				<span style="background-color: #fe7a12"><input type=radio name=etat_value value=3>3</span>
				<span style="background-color: #fed01d"><input type=radio name=etat_value value=4>4</span>
				<span style="background-color: #feea20"><input type=radio name=etat_value value=5 checked>5</span>
				<span style="background-color: #e5fe26"><input type=radio name=etat_value value=6>6</span>
				<span style="background-color: #b4fe2e"><input type=radio name=etat_value value=7>7</span>
				<span style="background-color: #7fff36"><input type=radio name=etat_value value=8>8</span>
				<span style="background-color: #33ff00"><input type=radio name=etat_value value=9>9</span>
				<span style="background-color: #65ff3b"><input type=radio name=etat_value value=10>10</span>
				</td></tr>
                                </TABLE><BR>
                                <INPUT TYPE="hidden" NAME="user" value="<?php echo $user; ?>">
                                <INPUT TYPE="hidden" NAME="action" value="<?php echo $action; ?>">
                                <INPUT TYPE="hidden" NAME="type" value="<?php echo $type; ?>">
                                <INPUT TYPE="hidden" NAME="sw" value="1">
                                <input type="Submit" value="<?php echo _("Enregistrer"); ?>">
                                </FORM>
                                </CENTER>
                                <?php
                        }
?>              
<br><br>
<div>
<span id=left-text>
<A HREF="admin.php?menu=1">
<?php echo _("retour menu administration"); ?>
</A><BR>
<A HREF="index.php">
<?php echo _("retour menu principal"); ?>
</A></span>
</div>
<br>
Return current item: Biblioteca