<?php /** * Input new genetic locus * <br/><br/> * Access to all user except of guests * @author Gabriele Droege, DNA Bank Network <contact@dnabank-network.org> * @version 2.0 * @package Input * @copyright Copyright Š 2011 DNA Bank Network http://www.dnabank-network.org<br>The contents of this file are subject to the Mozilla Public License Version 1.1 * @filesource * @license http://www.mozilla.org/MPL/ MPL */ /** * calling connection to database */ include ("../config/head.php"); /** * calling authorisation script */ include ("../auth.php"); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>DNA Module - Add New Genetic Locus</title> <link rel="stylesheet" type="text/css" href="../format.css"> <SCRIPT LANGUAGE="JavaScript1.1" src="../Functions.js"></SCRIPT> <SCRIPT LANGUAGE="JavaScript1.1" src="../ajax/ajax_functions.js"></SCRIPT> <NOSCRIPT>Please enable Javascript!</NOSCRIPT> </head> <body> <div align="center"> <?php /** * including navigation menu */ include("../tablenavi.php"); ?> <form name="formular" method="POST" action="new_geneticlocus.php"> <table id="tablemain" class="main"> <tr> <td id="tdLogo"><a href="<?php echo $Path_Wiki."/Input_DNA_Data"; ?>" target="_blank"><img border="0" src="../images/Logo-Wiki.png" height="78"></a></td> <td id="tdtitle"> <h1>Add New Genetic Locus</h1></td> <td id="tdLogo2"><?php echo $Path_Logo; ?></td> </tr> <tr> <td><?php echo "Logged in as: "; $log = $_SESSION["log"]; echo $log; ?></td><td colspan="2"><input type="submit" id="button" name="formSubmitClose" value="Close Form" style="float:right" onclick="window.close();"></td></tr> <tr> <td valign="top" align="center" valign="middle" colspan="3"> <table id="table" width="70%" border="0" style="margin:30 0 0 0"> <tr><td colspan="2"><i>With this tool you can administer all different genetic loci related to your DNA samples. Below the green box you can see all records found in the database. It is not possible to delete entries here. To do so please ask your administrator for assistance. After finishing your entries please close this window and reload (F5) the input or search mask to get the updated list from database.</i></td></tr> <tr> <td align="center" colspan="2"> <?php if (isset($_SESSION['guest']) || $_SESSION['guest']) { /******************************************************************************************** * Guests don't have permission for entering new DNA data * *********************************************************************************************/ echo "<tr><td colspan='3'><span class='error'>Sorry, as a guest you don't have permission for entering new data! If you want to search for existing DNA data please use the Search function!</span></td></tr>"; } else { if($formSubmitSave) { if(empty($formNewGeneticLocus)) { unset($formNewGeneticLocus); } if($formNewGeneticLocus=="") { echo "<span class='error'>Please complete 'Genetic Locus'</span>"; } if($formNewGeneticLocus!="") { $result= mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_GeneticLocus, GeneticLocus FROM geneticlocus " . "WHERE GeneticLocus = '$formNewGeneticLocus'"); if(mysqli_num_rows($result)) { echo "<span class='error'>Genetic Locus already exists!</span>"; } else { $NewGeneticLocus = addslashes($formNewGeneticLocus); $NewGeneticLocusRemarks = addslashes($formGeneticLocusRemarks); $sql = "INSERT INTO geneticlocus (GeneticLocus, GeneticLocusRemarks, Created_Who)" . "VALUES ('$NewGeneticLocus','$NewGeneticLocusRemarks','$log')"; $result = mysqli_query($GLOBALS["___mysqli_ston"], $sql); #######################################Error 1############################################################### if(!$result) { $msg = $sql."\n"; $msg .= "####Error 1####"; if($debug == '1') echo $msg; trigger_error($msg, E_USER_ERROR); /** * calling Error message */ include ("../config/Errorreport.php"); } ############################################################################################################# else { include("../config/DataSaved.php"); } } } }//if ($formSubmitSave) if($formSubmitUpdate) { $NewGeneticLocus = addslashes($formNewGeneticLocus); $NewGeneticLocusRemarks = addslashes($formGeneticLocusRemarks); $ID_GeneticLocus = $_POST['ID_GeneticLocus']; $Current_Date = date('Y-m-d H:i:s'); $sql = "UPDATE geneticlocus SET Geneticlocus = '$NewGeneticLocus', GeneticLocusRemarks = '$NewGeneticLocusRemarks', Updated_Who = '$log', Updated_When = '$Current_Date' WHERE ID_GeneticLocus = '$ID_GeneticLocus'"; $result = mysqli_query($GLOBALS["___mysqli_ston"], $sql); #######################################Error 2############################################################### if(!$result) { $msg = $result."\n"; $msg .= "####Error 2####"; if($debug == '1') echo $msg; trigger_error($msg, E_USER_ERROR); /** * calling Error message */ include ("../config/Errorreport.php"); } ############################################################################################################# else { include("../config/ChangesAccepted.php"); } } //if ($formSubmitUpdate) ?> </td></tr></table> <div class="geography2"> <table width="90%"><tr><td colspan="5"><hr /></td></tr> <?php if($_GET['ID'] != "") { $ID_GeneticLocus = $_GET['ID']; $result2= mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM geneticlocus WHERE ID_GeneticLocus = '$ID_GeneticLocus'"); while ($row = mysqli_fetch_object($result2)) { echo '<tr><td id="DescriptionBlack"><b>Edit Genetic Locus</b></td><td colspan="4"></td></tr>'; echo '<tr><td id="DescriptionGreen">Genetic Locus* </td><td colspan="2"><input type="hidden" name="ID_GeneticLocus" value="'.$ID_GeneticLocus.'"><input type="text" name="formNewGeneticLocus" id="InputWrapperUrl2" value="'.$row->GeneticLocus.'"/></td></tr>'; echo '<tr><td id="DescriptionGreen">Remarks </td><td colspan="2"><input type="text" name="formGeneticLocusRemarks" id="InputWrapperUrl2" value="'.$row->GeneticLocusRemarks.'"/></td></tr>'; echo '<tr><td></td><td colspan="4"><input type="submit" id="button" name="formSubmitUpdate" value="Save Edits" style="float:right"></td></tr>'; } } else { ?> <tr><td id="DescriptionBlack"><b>Add new Genetic Locus</b></td><td colspan="4"></td></tr> <tr><td id="DescriptionGreen">Genetic Locus* </td><td colspan="2"><input type="text" name="formNewGeneticLocus" id="InputWrapperURL2"></td></tr> <tr><td id="DescriptionGreen">Remarks </td><td colspan="2"><input type="text" name="formGeneticLocusRemarks" id="InputWrapperURL2"></td></tr> <tr> <td></td> <td colspan="4"><input type="submit" id="button" name="formSubmitSave" value="Save New Genetic Locus" style="float:right" onClick="return CheckNewGeneticLocus();"></td></tr> <?php } ?> </table> </div> <table> <tr><td colspan="2">* Mandatory field</td></tr> <?php } ?> </table> <?php $result= mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM geneticlocus ORDER BY GeneticLocus"); $num_rows = mysqli_num_rows($result); echo "<table width='90%'>"; if($num_rows > 0) { echo "<tr><td colspan='4'><hr/></td></tr>"; echo"<th width='300px'>GeneticLocus</th><th>Remarks</th><th width='300px'>Created</th><th></th>"; while ($row = mysqli_fetch_object($result)) { echo "<tr><td>".$row->GeneticLocus."</td><td>".$row->GeneticLocusRemarks."</td>"; echo "<td>".$row->Created_Who." (".$row->Created_When.")</td><td><a href='new_geneticlocus.php?ID=".$row->ID_GeneticLocus."' title='Edit Genetic Locus'><img src='../images/edit2.jpg' height='25'></a></td></tr>"; }} else { echo "<tr><td><span class='fine'>No entries found.</span></td></tr>"; } ((mysqli_free_result($result) || (is_object($result) && (get_class($result) == "mysqli_result"))) ? true : false); ?> </table> </td> </tr> </table> <?php /** * including footer */ include("../footer.php"); ?> </form> </div> </body> </html>