<?php /** * Input new method * <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 Kind of Unit</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_kindofunit.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 Kind of Unit</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 types of kind of unit related to you DNA or tissue 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($formNewKindOfUnit)) { unset($formNewKindOfUnit); } if($formNewKindOfUnit=="") { echo "<span class='error'>Please complete 'Kind of Unit'</span>"; } if($formNewKindOfUnit!="") { $result= mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_KindOfUnit, KindOfUnit FROM kindofunit " . "WHERE KindOfUnit = '$formNewKindOfUnit'"); if(mysqli_num_rows($result)) { echo "<span class='error'>Kind of Unit already exists!</span>"; } else { $NewKindOfUnit = addslashes($formNewKindOfUnit); $KindOfUnitRemarks = addslashes($formKindOfUnitRemarks); $sql = "INSERT INTO kindofunit (KindOfUnit, KindOfUnitRemarks, Created_Who)" . "VALUES ('$NewKindOfUnit','$KindOfUnitRemarks','$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) { $NewKindOfUnit = addslashes($formNewKindOfUnit); $NewKindOfUnitRemarks = addslashes($formKindOfUnitRemarks); $ID_KindOfUnit = $_POST['ID_KindOfUnit']; $Current_Date = date('Y-m-d H:i:s'); $sql = "UPDATE kindofunit SET KindOfUnit = '$NewKindOfUnit', KindOfUnitRemarks = '$NewKindOfUnitRemarks', Updated_Who = '$log', Updated_When = '$Current_Date' WHERE ID_KindOfUnit = '$ID_KindOfUnit'"; $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_KindOfUnit = $_GET['ID']; $result2= mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * from kindofunit WHERE ID_KindOfUnit = '$ID_KindOfUnit'"); while ($row = mysqli_fetch_object($result2)) { echo '<tr><td id="DescriptionBlack"><b>Edit Kind of Unit</b></td><td colspan="4"></td></tr>'; echo '<tr><td id="DescriptionGreen">Kind of Unit* </td><td colspan="2"><input type="hidden" name="ID_KindOfUnit" value="'.$ID_KindOfUnit.'"><input type="text" name="formNewKindOfUnit" id="InputWrapperUrl2" value="'.$row->KindOfUnit.'"/></td></tr>'; echo '<tr><td id="DescriptionGreen">Kind of Unit Remarks </td><td colspan="2"><input type="text" name="formKindOfUnitRemarks" id="InputWrapperUrl2" value="'.$row->KindOfUnitRemarks.'"/></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 KindOfUnit</b></td><td colspan="4"></td></tr> <tr><td id="DescriptionGreen">Kind of Unit* </td><td colspan="2"><input type="text" name="formNewKindOfUnit" id="InputWrapperURL2"></td></tr> <tr><td id="DescriptionGreen">KindOfUnit Remarks </td><td colspan="2"><textarea name="formKindOfUnitRemarks" id="InputWrapperURL2"></textarea></td></tr> <tr> <td></td> <td colspan="4"><input type="submit" id="button" name="formSubmitSave" value="Save New Kind Of Unit" style="float:right" onClick="return CheckNewKindOfUnit();"></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 kindofunit ORDER BY KindOfUnit"); $num_rows = mysqli_num_rows($result); echo "<table>"; if($num_rows > 0) { echo "<tr><td colspan='4'><hr/></td></tr>"; echo"<th width='400px'>Kind of Unit</th><th width='300px'>Created</th><th></th>"; while ($row = mysqli_fetch_object($result)) { echo "<tr><td>".$row->KindOfUnit."</td><td>"; echo "<td align='right'>".$row->Created_Who." (".$row->Created_When.")</td><td><a href='new_kindofunit.php?ID=".$row->ID_KindOfUnit."' title='Edit Kind of Unit'><img src='../images/edit2.jpg' height='25'></a></td></tr>"; } } else { echo "<tr><td><span class='fine'>No kind of unit 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>