Source for file Save_Specimen.php
Documentation is available at Save_Specimen.php
* saving specimen data from original specimen data provider
* final script, all subfiles ("Save_xy.php") provide final content in standardised way
* @author Gabriele Droege, DNA Bank Network <contact@dnabank-network.org>
* @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
* @license http://www.mozilla.org/MPL/ MPL
if (isset
($_SESSION['guest']) ||
$_SESSION['guest']) {
echo
"<tr><td colspan='3'><span class='error'>Sorry, as a guest you don't have permission for entering new DNA data! If you want to search for existing DNA data please use the Search function!</span></td></tr>"; }
if($formProviderIntern) { $IDDataset =
$formProviderIntern; }
if($formProviderExtern) { $IDDataset =
$formProviderExtern; }
/********************************************************************************************
* at first, check if specimen data are already in cache tables *
* if so, count jhow many DNA samples are yet connected to this record *
********************************************************************************************/
$test =
mysql_query("SELECT ID_Cache FROM cachecollection " .
"WHERE UnitID_Specimen = '$sqlUnitID' " .
" AND CollectionCode_Specimen = '$sqlSourceName' " .
" AND InstitutionCode_Specimen = '$sqlSourceInstitutionCode' " .
" AND ID_Dataset_Specimen = '$IDDataset'");
{ $ID_Cache =
$row->ID_Cache; }
$test2 =
mysql_query("SELECT ID_TaxonIdentified, NameAuthorYear FROM cachetaxonidentified WHERE ID_Cache = '$ID_Cache'");
{ $View =
$row->NameAuthorYear; }
{$IDTableCache =
$ID_Cache;
$Exist =
mysql_query("SELECT ID_DNA, DNA_Bank_Number FROM dnabanknumbers " .
"WHERE ID_Cache = '$IDTableCache'");
echo
"<span class='fine'>Data have been saved: <br />Specimen Number: </span><span class='error'>".
$sqlUnitID.
"</span><span class='fine'> Institution Code: </span><span class='error'>".
$sqlSourceInstitutionCode.
"</span><span class='fine'> Collection Code: </span><span class='error'>".
$sqlSourceName.
"</span><span class='fine'> Taxon Name: </span><span class='error'>".
$View.
"</span><br />";
{ echo
"<span class='fine'>".
$count.
" DNA Sample already exist for the selected specimen!</span><br />"; }
{ echo
"<span class='fine'>".
$count.
" DNA Samples already exist for the selected specimen!</span><br />"; }
if(isset
($Identifications))
/********************************************************************************************
* first table to fill is cachecollection *
********************************************************************************************/
$sql4 =
"INSERT INTO cachecollection (UnitID_Specimen, CollectionCode_Specimen, InstitutionCode_Specimen, ContinentOrOcean, CountryName, CountryISO2, Collectors, CollectionDate, CollectionDateMin, CollectionDateMax, CollectorsNo, Locality, Longitude, Latitude, Altitude, CollectionInfo_Other, ID_Dataset_Specimen, Created_Who) VALUES ('$sqlUnitID','$sqlSourceName','$sqlSourceInstitutionCode','$sqlContinentOrOcean','$sqlCountryName','$sqlISO2','$sqlPersonName','$sqlCollectionDate','$sqlCollectionDateMin','$sqlCollectionDateMax','$sqlCollectorsNo','$sqlLocality','$sqlLongitude','$sqlLatitude','$sqlAltitude','$sqlGatheringOther','$IDDataset','$log')";
###############################################Error 4####################################################
$msg .=
"####Error 4####";
include ("../config/Errorreport.php");
#########################################################################################################
foreach ($Identifications as $IndexIdentification =>
$Identification) {
/********************************************************************************************
* for each identification tag entering one row in cachetaxonidentified *
********************************************************************************************/
$Genus =
$sqlGenus[$IndexIdentification];
$Subgenus =
$sqlSubgenus[$IndexIdentification];
$FirstEpithet =
$sqlFirstEpithet[$IndexIdentification];
$SecondEpithet =
$sqlSecondEpithet[$IndexIdentification];
$Rank =
$sqlRank[$IndexIdentification];
$HybridFlag =
$sqlHybridFlag[$IndexIdentification];
$NameAuthorYear =
$sqlNameAuthorYearString[$IndexIdentification];
$Name_All =
$sqlName_All[$IndexIdentification];
$PreferredFlag =
$sqlPreferredIdentificationFlag[$IndexIdentification];
$sql5 =
"INSERT INTO cachetaxonidentified (ID_Cache, Genus, Subgenus, FirstEpithet, SecondEpithet, Rank, HybridFlag, NameAuthorYear, Other, PreferredFlag, Created_Who) VALUES ('$IDTableCache','$Genus','$Subgenus','$FirstEpithet','$SecondEpithet','$Rank','$HybridFlag','$NameAuthorYear','$Name_All','$PreferredFlag','$log')";
#################################################Error 5################################################
$msg .=
"####Error 5####";
include ("../config/Errorreport.php");
########################################################################################################
foreach ($HigherTaxa as $index =>
$HigherTaxon) { // more than one HigherTaxon per Identification possible
/********************************************************************************************
* for each identification tag and higher taxon tag entering one row in cachehighertaxa *
********************************************************************************************/
$TaxonHigher =
$sqlHigherTaxon[$index];
$RankHigher =
$sqlHigherTaxonRank[$index];
$sql6 =
"INSERT INTO cachehighertaxa (ID_CacheTaxonIdentified, HigherTaxon, TaxonRank, Created_Who) VALUES ('$IDTableCacheTaxonIdentified','$TaxonHigher','$RankHigher','$log')";
#################################################Error 6################################################
$msg .=
"####Error 6####";
include ("../config/Errorreport.php");
########################################################################################################
foreach ($sqlFileURI as $MultiMediaObject)
/*********************************************************************************************
* for each multimedia tag entering one row in cacheimages *
*********************************************************************************************/
$sql7 =
"INSERT INTO cacheimages (ID_Cache, Images, Created_Who) VALUES ('$IDTableCache','$MultiMediaObject','$log')";
#######################################Error 7###############################################################
$msg .=
"####Error 7####";
include ("../config/Errorreport.php");
#############################################################################################################
foreach ($sqlProductURI as $MultiMediaObject)
$sql8=
"INSERT INTO cacheimages (ID_Cache, Images, Created_Who) VALUES ('$IDTableCache','$MultiMediaObject','$log')";
#######################################Error 8###############################################################
$msg .=
"####Error 8####";
include ("../config/Errorreport.php");
#############################################################################################################
echo
"<span class='fine'>Data have been saved: <br />Specimen Number: </span><span class='error'>".
$sqlUnitID.
"</span><span class='fine'> Institution Code: </span><span class='error'>".
$sqlSourceInstitutionCode.
"</span><span class='fine'> Collection Code: </span><span class='error'>".
$sqlSourceName.
"</span><span class='fine'> Taxon Name: </span><span class='error'>".
$NameAuthorYear.
"</span><br />"; }
$sql7 =
"INSERT INTO cachecollection (UnitID_Specimen, CollectionCode_Specimen, InstitutionCode_Specimen, ContinentOrOcean, CountryName, Collectors, CollectionDate, CollectionDateMin, CollectionDateMax, CollectorsNo, Locality, Longitude, Latitude, Altitude, ID_Dataset_Specimen, Created_Who) VALUES ('$sqlUnitID','$sqlSourceName','$sqlSourceInstitutionCode','$sqlContinentOrOcean','$sqlCountryName','$sqlPersonName','$sqlCollectionDate','$sqlCollectionDateMin','$sqlCollectionDateMax','$sqlCollectorsNo','$sqlLocality','$sqlLongitude','$sqlLatitude','$sqlAltitude','$IDDataset','$log')";
#######################################Error 7###############################################################
$msg .=
"####Error 7####";
include ("../config/Errorreport.php");
#############################################################################################################
echo
"<span class='fine'>Data have been saved: <br />Specimen Number: </span><span class='error'>".
$sqlUnitID.
"</span><span class='fine'> Institution Code: </span><span class='error'>".
$sqlSourceInstitutionCode.
"</span><span class='fine'> Collection Code: </span><span class='error'>".
$sqlSourceName.
"</span><span class='fine'> Taxon Name: </span><span class='error'>".
$sqlNameAuthorYearString.
"</span><br />"; }
$sql8 =
"INSERT INTO cachetaxonidentified (ID_Cache, Genus, Subgenus, FirstEpithet, SecondEpithet, Rank, NameAuthorYear, Created_Who) VALUES ('$IDTableCache','$sqlGenus','$sqlSubgenus','$sqlFirstEpithet','$sqlSecondEpithet','$sqlRank','$sqlNameAuthorYearString','$log')";
######################################################Error 8###########################################
$msg .=
"####Error 8####";
include ("../config/Errorreport.php");
########################################################################################################
foreach ($sqlHigherTaxon as $index =>
$HigherTaxa) { // more than one HigherTaxon per Identification possible
if(!empty($sqlHigherTaxon[$index])) {
$TaxonHigher =
$sqlHigherTaxon[$index];
$RankHigher =
$sqlHigherTaxonRank[$index];
$sql9 =
"INSERT INTO cachehighertaxa (ID_CacheTaxonIdentified, HigherTaxon, TaxonRank, Created_Who) VALUES ('$IDTableCacheTaxonIdentified','$TaxonHigher','$RankHigher','$log')";
########################################################Error 9###########################################
$msg .=
"####Error 9####";
include ("../config/Errorreport.php");
##########################################################################################################
foreach ($sqlFileURI as $MultiMediaObject)
$sql10 =
"INSERT INTO cacheimages (ID_Cache, Images, Created_Who) VALUES ('$IDTableCache','$MultiMediaObject','$log')";
#######################################Error 10###############################################################
$msg .=
"####Error 10####";
include ("../config/Errorreport.php");
#############################################################################################################
foreach ($sqlProductURI as $MultiMediaObject)
$sql11=
"INSERT INTO cacheimages (ID_Cache, Images, Created_Who) VALUES ('$IDTableCache','$MultiMediaObject','$log')";
#######################################Error 11###############################################################
$msg .=
"####Error 11####";
include ("../config/Errorreport.php");
#############################################################################################################
Documentation generated on Tue, 29 Nov 2011 10:45:11 +0100 by phpDocumentor 1.4.3