Please select a Specimen database!';
}
else {
if(!empty($formProviderIntern) and !empty($formProviderExtern))
{
echo 'Please select either an "Internal" or "External" Specimen database!'; }
if(isset($_REQUEST['NoSpecimenAvailable']) and !empty($formSpecimenNumber))
{
echo 'Please complete neither a Specimen Number or select the checkbox!'; }
if(empty($formUnitID))
{
echo 'Please verify the selected specimen at first!'; }
else
{
$variable1 = $_POST[formUnitID];
$variable2 = $_POST[formSourceInstitutionID];
$variable3 = $_POST[formSourceID];
$variable4 = $_POST[formProviderExtern];
$variable5 = $_POST[formTest];
$variable6 = $_POST[formProviderIntern];
if($variable1 != "" and !$formSubmitVerify)
{
$mykey = key($variable1);
if(!empty($variable4))
{
$sql = mysql_query
("SELECT tabledataset.ID_Dataset AS ID_Dataset, " .
" tableschema.QueryPart1b AS QueryPart1b, " .
" tableschema.QueryPart1_1 AS QueryPart1_1, " .
" tableschema.QueryPart1_2b AS QueryPart1_2b, " .
" tableschema.QueryPart2 AS QueryPart2, " .
" tableschema.QueryPart3 AS QueryPart3, " .
" tableschema.QueryPart4 AS QueryPart4, " .
" tableschema.QueryPart5 AS QueryPart5, " .
" tableprovider.Provider AS Provider, " .
" tabledataset.Digir_Resource AS Digir_Resource, " .
" tabledataset.Digir_Source AS Digir_Source, " .
" tableprovider.Provider AS Provider, " .
" tableprovider.ID_Schema AS ID_Schema " .
" FROM tabledataset " .
" LEFT JOIN tableprovider ON tabledataset.ID_Provider = tableprovider.ID_Provider " .
" LEFT JOIN tableschema ON tableprovider.ID_Schema = tableschema.ID_Schema " .
" WHERE tabledataset.ID_Dataset = '$variable4'");
}
if(!empty($variable6))
{
$sql = mysql_query
("SELECT tabledataset.ID_Dataset AS ID_Dataset, " .
" tableschema.QueryPart1b AS QueryPart1b, " .
" tableschema.QueryPart1_1 AS QueryPart1_1, " .
" tableschema.QueryPart1_2b AS QueryPart1_2b, " .
" tableschema.QueryPart2 AS QueryPart2, " .
" tableschema.QueryPart3 AS QueryPart3, " .
" tableschema.QueryPart4 AS QueryPart4, " .
" tableschema.QueryPart5 AS QueryPart5, " .
" tableprovider.Provider AS Provider, " .
" tabledataset.Digir_Resource AS Digir_Resource, " .
" tabledataset.Digir_Source AS Digir_Source, " .
" tableprovider.Provider AS Provider, " .
" tableprovider.ID_Schema AS ID_Schema " .
" FROM tabledataset " .
" LEFT JOIN tableprovider ON tabledataset.ID_Provider = tableprovider.ID_Provider " .
" LEFT JOIN tableschema ON tableprovider.ID_Schema = tableschema.ID_Schema " .
" WHERE tabledataset.ID_Dataset = '$variable6'");
}
if(!empty($formProviderIntern) or !empty($formProviderExtern))
{
while($row = mysql_fetch_object($sql))
{
$ID_Dataset = $row->ID_Dataset;
$Provider = $row->Provider;
$QueryPart1b = $row->QueryPart1b;
$QueryPart1_1 = $row->QueryPart1_1;
$QueryPart1_2b = $row->QueryPart1_2b;
$QueryPart2 = $row->QueryPart2;
$QueryPart3 = $row->QueryPart3;
$QueryPart4 = $row->QueryPart4;
$QueryPart5 = $row->QueryPart5;
$Digir_Resource = $row->Digir_Resource;
$Digir_Source = $row->Digir_Source;
$ID_Schema = $row->ID_Schema;
}
$SourceUnitID = urlencode($variable1[$mykey]);
$SourceInstitutionCode = urlencode($variable2[$mykey]);
$SourceCode = urlencode($variable3[$mykey]);
$Digir_Resource1 = urlencode($Digir_Resource);
$Digir_Source1 = urlencode($Digir_Source);
}
if($abfrage != "" or isset($_REQUEST['NoSpecimenAvailable']))
{
if($variable6 != '1' and $variable6 != '')
{$test1 = 'true'; }
if($variable4 != '1' and $variable4 != '')
{$test2 = 'true'; }
if($test1 == 'true' or $test2 == 'true')
{
$file = $Provider.$QueryPart1b.$Digir_Resource1.$QueryPart1_1.$Digir_Source1.$QueryPart1_2b.$SourceUnitID.$QueryPart3.$SourceInstitutionCode.$QueryPart4.$SourceCode.$QueryPart5;
//echo $file;
if ($version > 5)
{$dom = new DOMDocument();
$dom->Load($file);}
if ($version < 5)
{$xml = file_get_contents($file);}
if($ID_Schema == 1) {
if ($version > 5)
{include ("Save_ABCD1.2.php");}
if($version < 5)
{include ("Save_ABCD1.2_php4.php");} }
if($ID_Schema == 2) {
if ($version > 5)
{include ("Save_ABCD2.06.php");}
if($version < 5)
{include ("Save_ABCD2.06_php4.php");} }
if($ID_Schema == 3 OR $ID_Schema == 6) {
if ($version > 5)
{include ("Save_digir.php");}
if($version < 5)
{include ("Save_digir_php4.php");} }
if($ID_Schema == 4) {
{include ("Save_ABCD2.05.php");}
if($version < 5)
{include ("Save_ABCD2.05_php4.php");} }
}
}
if(empty($formUnitID[0]) and $ID_Dataset != '1' and $ID_Dataset != '')
{ echo "No hits. Please verify your entry and selection of specimen database. DNA data have not been saved!";}
if($formTest[0] != "")
{ echo "Please select a specimen or verify your entry!";}
}
if(empty($formTest[0])) {
$resultExist= mysql_query("SELECT ID_DNA, Dna_Bank_Number FROM tablednabanknumbers " .
"WHERE Dna_Bank_Number = '$formDnaBankNumber'");
if(!mysql_num_rows($resultExist)) {};
if(mysql_num_rows($resultExist))
{
// $conf2 = "";
// echo $conf2;
echo "DNA Extraction Number already exist!";
}
if(empty($resultExist) or !mysql_num_rows($resultExist)) //empty($formDnaBankNumber)) //wenn DNA Extraction Number noch nicht in DB oder Feld leer
{
if($formSpecimenNumber!="" or isset($_REQUEST['NoSpecimenAvailable']))
{
if($formProviderIntern!="" or $formProviderExtern!="")
{include ("Save_Specimen.php"); } }
if($error == "true")
{ $msg = "####Error in Save_Specimen.php####";
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php"); }
else {
include ("date.php");
//Checkboxen auswerten [x]
if (isset($_REQUEST['c']))
{
reset($_REQUEST['c']);
foreach ($_REQUEST['c'] as $b)
{
if ($b == "SourceGone")
$SourceGone = "1";
if ($b == "StockGone")
$StockGone = "1";
if ($b == "BlockGeneral")
$BlockGeneral = "1";
if ($b == "Aliquot")
$Aliquot = "1";
if ($b == "Backup")
$Backup = "1";
}
}
if($formStockFridge!="" or $formStockRack!="" or $formStockBox!="")
{
$result1 = "INSERT INTO tablelocation_stock (ID_Stock_Box, ID_Stock_Rack, ID_Stock_Fridge, Origin_Quantity, Rest_Quantity, Stock_Barcode, Stock_Position, Created_Who)" .
"VALUES ('$formStockBox','$formStockRack','$formStockFridge','$formSourceQuantity','$formSourceQuantity','$formBarcodeStock','$formPositionStock','$log')";
$sql1 = mysql_query($result1);
$IDLocationStock=mysql_insert_id();
#######################################Error 1###############################################################
if(!$sql1)
{ $msg = $result1."\n";
$msg .= "####Error 1####";
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php"); }
#############################################################################################################
}
if (!isset($Amplification))
{ unset($AmplificationDate);
unset($formAmplificationStaff);
unset($formFragment);
unset($formGenbankNumber);
unset($formGenbankLink);
unset($AmplificationDateA);
unset($formAmplificationStaffA);
unset($formFragmentA);
unset($formGenbankNumberA);
unset($formGenbankLinkA);
unset($AmplificationDateB);
unset($formAmplificationStaffB);
unset($formFragmentB);
unset($formGenbankNumberB);
unset($formGenbankLinkB);
unset($AmplificationDateC);
unset($formAmplificationStaffC);
unset($formFragmentC);
unset($formGenbankNumberC);
unset($formGenbankLinkC);
unset($AmplificationDateD);
unset($formAmplificationStaffD);
unset($formFragmentD);
unset($formGenbankNumberD);
unset($formGenbankLinkD);
}
// NORMAL:
if(empty($formAliquotsFridge) and empty($formAliquotsRack) and empty($AliquotsBox))
// ZSM München:
//if(empty($formAliquotsFridge) and empty($formAliquotsRack) and empty($AliquotsBox) and empty($formBarcodeAliquot))
{ unset($formQuantityAliquots);
unset($formNumberAliquots);}
if(isset($_REQUEST['Aliquot']))
{
if($_POST['Quantity']!="")
{
unset($formQuantityAliquots);
unset($formNumberAliquots);
$QuantityAliquots = array_sum($_POST['Quantity']);
//print $QuantityAliquots."
";
//so gehts auch
//$array=array_count_values($_POST['Quantity']);
//$total= count($_POST['Quantity']) - $array[""];
//echo $total;
$NumberAliquots=0;
foreach($_POST['Quantity'] as $Test123)
{ if($Test123!="")
{ $NumberAliquots+=1; } }
}}
else { $QuantityAliquots = $formQuantityAliquots * $formNumberAliquots;
$NumberAliquots = $formNumberAliquots; }
$result2 = "INSERT INTO tablednabanknumbers (Dna_Bank_Number, ID_RelationDNA_Voucher, ID_Type, " .
"ID_Preservation, ID_Tissue, ID_Extraction_Method, Extraction_Date, NoExtractDate, ID_Extraction_Staff, " .
"ID_Purification, Absorbance280, Absorbance230, Concentration, ID_Degradation, Degradation_Date, " .
"Number_Aliquots, Quantity_Aliquots, ID_Location_Stock, Stock_Gone, Source_Gone, Block_Until, " .
"Block_General, ID_Provided_By_People, Notes, Backup_Aliquot, Created_Who, ID_Cache)" .
"VALUES ('$formDnaBankNumber','$formRelation','$formType','$formPreservation','$formTissue',
'$formExtractionMethod','$ExtractionDate','$formNoExtractDate','$formExtractionStaff',
'$formPurificationMethod','$formAbsorbance280','$formAbsorbance230','$formConcentration',
'$formDegradation','$DegradationDate','$NumberAliquots','$QuantityAliquots',
'$IDLocationStock','$StockGone','$SourceGone','$BlockDate','$BlockGeneral',
'$formProvidedBy','$formNotes','$Backup','$log','$IDTableCache')";
$sql2 = mysql_query($result2);
$IDDna=mysql_insert_id();
#######################################Error 2###############################################################
if(!$sql2)
{ $msg = $result2."\n";
$msg .= "####Error 2####";
mail("g.droege@bgbm.org", "Error report", $msg, "From: BGBM-".$_SESSION['log']);
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php"); }
#############################################################################################################
if($sql2)
{echo "DNA Extraction No: ".$formDnaBankNumber.""; }
if($formAmplificationStaff)
{
$result = "INSERT INTO tableamplifications (ID_DNA, ID_Fragment, GenBankNumber, Link, Amplification_Date, ID_Amplification_Staff, Amplification_Success, Created_Who)" .
"VALUES ('$IDDna','$formFragment','$formGenbankNumber','$formGenbankLink','$AmplificationDate','$formAmplificationStaff','$radioAmplification','$log')";
$sql = mysql_query($result);
#######################################Error formGenbankNumber###############################################################
if(!$sql)
{ $msg = $result."\n";
$msg .= "####Error formGenbankNumber####";
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php"); }
#############################################################################################################
}
if($formAmplificationStaffA)
{
$result = "INSERT INTO tableamplifications (ID_DNA, ID_Fragment, GenBankNumber, Link, Amplification_Date, ID_Amplification_Staff, Amplification_Success, Created_Who)" .
"VALUES ('$IDDna','$formFragmentA','$formGenbankNumberA','$formGenbankLinkA','$AmplificationDateA','$formAmplificationStaffA','$radioAmplificationA','$log')";
$sql = mysql_query($result);
#######################################Error formGenbankNumberA###############################################################
if(!$sql)
{ $msg = $result."\n";
$msg .= "####Error formGenbankNumberA####";
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php"); }
#############################################################################################################
}
if($formAmplificationStaffB)
{
$result = "INSERT INTO tableamplifications (ID_DNA, ID_Fragment, GenBankNumber, Link, Amplification_Date, ID_Amplification_Staff, Amplification_Success, Created_Who)" .
"VALUES ('$IDDna','$formFragmentB','$formGenbankNumberB','$formGenbankLinkB','$AmplificationDateB','$formAmplificationStaffB','$radioAmplificationB','$log')";
$sql = mysql_query($result);
#######################################Error formGenbankNumberB###############################################################
if(!$sql)
{ $msg = $result."\n";
$msg .= "####Error formGenbankNumberB####";
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php"); }
#############################################################################################################
}
if($formAmplificationStaffC)
{
$result = "INSERT INTO tableamplifications (ID_DNA, ID_Fragment, GenBankNumber, Link, Amplification_Date, ID_Amplification_Staff, Amplification_Success, Created_Who)" .
"VALUES ('$IDDna','$formFragmentC','$formGenbankNumberC','$formGenbankLinkC','$AmplificationDateC','$formAmplificationStaffC','$radioAmplificationC','$log')";
$sql = mysql_query($result);
#######################################Error formGenbankNumberC###############################################################
if(!$sql)
{ $msg = $result."\n";
$msg .= "####Error formGenbankNumberC####";
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php"); }
#############################################################################################################
}
if($formAmplificationStaffD)
{
$result = "INSERT INTO tableamplifications (ID_DNA, ID_Fragment, GenBankNumber, Link, Amplification_Date, ID_Amplification_Staff, Amplification_Success, Created_Who)" .
"VALUES ('$IDDna','$formFragmentD','$formGenbankNumberD','$formGenbankLinkD','$AmplificationDateD','$formAmplificationStaffD','$radioAmplificationD','$log')";
$sql = mysql_query($result);
#######################################Error formGenbankNumberD###############################################################
if(!$sql)
{ $msg = $result."\n";
$msg .= "####Error formGenbankNumberD####";
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php"); }
#############################################################################################################
}
if (isset($_REQUEST['Aliquot']))
{ unset($formAliquotsFridge);
unset($formAliquotsRack);
unset($formAliquotsBox);
unset($formNumberAliquots);
unset($formQuantityAliqots);
$letter = A;
foreach ($_POST['x'] as $v => $value)
{
$rack = $_POST['y'][$v];
$box = $_POST['z'][$v];
$Quantities = $_POST['Quantity'][$v];
$Barcodes = $_POST['BarcodeAliquot'][$v];
$Positions = $_POST['BarcodePosition'][$v];
$lettercount = $letter++;
$AliquotNumber = $formDnaBankNumber.'-'.$lettercount;
if (!isset($_REQUEST['Aliquot']))
{ unset($value);
unset($rack);
unset($box);
unset($Quantities); }
else {
if($value=="")
{ unset($value);
unset($rack);
unset($box);
unset($Quantities);}
else {
$result3 = "INSERT INTO tablealiquots (ID_DNA, ID_Aliquots_Fridge, ID_Aliquots_Rack, ID_Aliquots_Box,
Aliquot_Number, Origin_Quantity, Rest_Quantity, Aliquot_Barcode, Aliquot_Position, Created_Who) " .
"VALUES ('$IDDna','$value','$rack','$box','$AliquotNumber','$Quantities','$Quantities','$Barcodes','$Positions','$log')";
$sql3 = mysql_query($result3);
#######################################Error sql3###############################################################
if(!$sql3)
{ $msg = $result3."\n";
$msg .= "####Error sql3####";
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php"); }
#############################################################################################################
}
}
}
}
else {
//NORMAL
if(!empty($formAliquotsFridge) and !empty($formAliquotsRack) and !empty($formAliquotsBox))
//ZSM München
//if(!empty($formAliquotsFridge) or !empty($formAliquotsRack) or !empty($formAliquotsBox) or !empty($formBarcodeAliquot))
{
$num = 1;
$letter = A;
while ($num <= $formNumberAliquots) {
$num++;
$lettercount = $letter++;
$AliquotNumber = $formDnaBankNumber.'-'.$lettercount;
$result4 = "INSERT INTO tablealiquots (ID_DNA, ID_Aliquots_Fridge, ID_Aliquots_Rack, ID_Aliquots_Box, Aliquot_Number, Origin_Quantity, Rest_Quantity, Aliquot_Barcode, Aliquot_Position, Created_Who)" .
"VALUES ('$IDDna','$formAliquotsFridge','$formAliquotsRack','$formAliquotsBox','$AliquotNumber','$formQuantityAliquots','$formQuantityAliquots','$formBarcodeAliquot','$formPositionAliquot','$log')";
$sql4 = mysql_query($result4);
#######################################Error sql4###############################################################
if(!$sql4)
{ $msg = $result4."\n";
$msg .= "####Error sql4####";
trigger_error($msg, E_USER_ERROR);
include ("Errorreport.php"); }
#############################################################################################################
}
}
}
}
}
}
}
}
}
}
?>