Source for file save.php
Documentation is available at save.php
* there are two ways of saving a new record
* 1. hit "Save" button and the input form will be empty after saving
* 2. hit "Save+Carry Forward" an the input form will display last entries, which is quite comfortable when entering a series of records
* Access to all user except of guests
* @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($formSubmitSave or $formSubmitCarryForward)
/********************************************************************************************
* some data quality checks first *
*********************************************************************************************/
if(empty($formDnaBankNumber)) { echo
'<span class="error">Please define a DNA Extraction Number!</span>'; }
if(empty($formSpecimenNumber)) { echo
'<br><span class="error">Please enter a specimen number!</span>'; }
if(!empty($formDnaBankNumber) and !empty($formSpecimenNumber))
if($formExtractionDate ==
"YYYY-MM-DD") { unset
($formExtractionDate); }
else { $date =
$formExtractionDate;
echo
'<span class="error">Extraction date incorrect!</span><br>'; }
else { $ExtractionDate =
$formExtractionDate; } }
if($formCheckDate ==
"YYYY-MM-DD") { unset
($formCheckDate); }
else { $date =
$formCheckDate;
echo
'<span class="error">Quality check date incorrect!</span><br>'; }
else { $CheckDate =
$formCheckDate; } }
if($formBlockDate ==
"YYYY-MM-DD") { unset
($formBlockDate); }
else { $date =
$formBlockDate;
echo
'<span class="error">Block date incorrect!</span><br>'; }
else { $BlockDate =
$formBlockDate; } }
if(empty($formRelation)) {
echo
'<span class="error">Please define relation to voucher!</span><br>'; }
if((empty($formExtractionDate) or $formExtractionDate ==
"YYYY-MM-DD") and empty($formNoExtractDate)) {
echo
'<span class="error">Please enter extraction date or select checkbox!</span><br>'; }
if(empty($formExtractionMethod)) {
echo
'<span class="error">Please select extraction method!</span><br>'; }
if(empty($formExtractionStaff)) {
echo
'<span class="error">Please select extraction staff!</span><br>'; }
if($Validation !=
"FALSE") {
$SpecimenNo =
urlencode($_POST['formSpecimenNumber']);
if(empty($formProviderIntern) and empty($formProviderExtern) and !empty($formSpecimenNumber))
unset
($formProviderIntern);
unset
($formProviderExtern);
echo
'<span class="error">Please select a Specimen database!</span>';
if(!empty($formProviderIntern) and !empty($formProviderExtern))
echo
'<span class="error">Please select either an "Internal" or "External" Specimen database!</span>'; }
echo
'<span class="error">Please verify specimen at first!</span>'; }
/********************************************************************************************
* some data quality checks first *
*********************************************************************************************/
/********************************************************************************************
*******************************************************************************************/
$variable1 =
$_POST['formUnitID'];
$CatalogNoText =
$_POST['CatalogNoText'];
$variable2 =
$_POST['formSourceInstitutionID'];
$variable3 =
$_POST['formSourceID'];
$variable4 =
$_POST['formProviderExtern'];
$variable5 =
$_POST['formTest'];
$variable6 =
$_POST['formProviderIntern'];
if($variable1 !=
"" and !$formSubmitVerify)
$mykey =
key($variable1);
("SELECT dataset.ID_Dataset AS ID_Dataset, " .
" schemata.QueryPart1b AS QueryPart1b, " .
" schemata.QueryPart1_1 AS QueryPart1_1, " .
" schemata.QueryPart1_2b AS QueryPart1_2b, " .
" schemata.QueryPart2 AS QueryPart2, " .
" schemata.QueryPart3 AS QueryPart3, " .
" schemata.QueryPart4 AS QueryPart4, " .
" schemata.QueryPart5 AS QueryPart5, " .
" provider.Provider AS Provider, " .
" dataset.Digir_Resource AS Digir_Resource, " .
" dataset.Digir_Source AS Digir_Source, " .
" provider.Provider AS Provider, " .
" provider.ID_Schema AS ID_Schema " .
" LEFT JOIN provider ON dataset.ID_Provider = provider.ID_Provider " .
" LEFT JOIN schemata ON provider.ID_Schema = schemata.ID_Schema " .
" WHERE dataset.ID_Dataset = '$variable4'");
("SELECT dataset.ID_Dataset AS ID_Dataset, " .
" schemata.QueryPart1b AS QueryPart1b, " .
" schemata.QueryPart1_1 AS QueryPart1_1, " .
" schemata.QueryPart1_2b AS QueryPart1_2b, " .
" schemata.QueryPart2 AS QueryPart2, " .
" schemata.QueryPart2a AS QueryPart2a, " .
" schemata.QueryPart3 AS QueryPart3, " .
" schemata.QueryPart4 AS QueryPart4, " .
" schemata.QueryPart5 AS QueryPart5, " .
" provider.Provider AS Provider, " .
" dataset.Digir_Resource AS Digir_Resource, " .
" dataset.Digir_Source AS Digir_Source, " .
" provider.Provider AS Provider, " .
" provider.ID_Schema AS ID_Schema " .
" LEFT JOIN provider ON dataset.ID_Provider = provider.ID_Provider " .
" LEFT JOIN schemata ON provider.ID_Schema = schemata.ID_Schema " .
" WHERE dataset.ID_Dataset = '$variable6'");
if(!empty($formProviderIntern) or !empty($formProviderExtern))
$ID_Dataset =
$row->ID_Dataset;
$Provider =
$row->Provider;
$QueryPart1b =
$row->QueryPart1b;
$QueryPart1_1 =
$row->QueryPart1_1;
$QueryPart1_2b =
$row->QueryPart1_2b;
$QueryPart2 =
$row->QueryPart2;
$QueryPart2a =
$row->QueryPart2a;
$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]);
$Digir_Resource1 =
urlencode($Digir_Resource);
if($variable4 !=
'1' and $variable4 !=
'')
if($test1 ==
'true' or $test2 ==
'true')
if($ID_Schema ==
3 and $CatalogNoText[$mykey] ==
"True")
$file =
$Provider.
$QueryPart1b.
$Digir_Resource1.
$QueryPart1_1.
$Digir_Source1.
$QueryPart1_2b.
"CatalogNumberText%3E".
$SourceUnitID.
"%3C%2Fdarwin%3ACatalogNumberText".
$QueryPart3.
$SourceInstitutionCode.
$QueryPart4.
$SourceCode.
$QueryPart5; }
if($ID_Schema ==
3 and $CatalogNoText[$mykey] !=
"True")
$file =
$Provider.
$QueryPart1b.
$Digir_Resource1.
$QueryPart1_1.
$Digir_Source1.
$QueryPart1_2b.
"CatalogNumber%3E".
$SourceUnitID.
"%3C%2Fdarwin%3ACatalogNumber".
$QueryPart3.
$SourceInstitutionCode.
$QueryPart4.
$SourceCode.
$QueryPart5; }
$file =
$Provider.
$QueryPart1b.
$Digir_Resource1.
$QueryPart1_1.
$Digir_Source1.
$QueryPart1_2b.
$SourceUnitID.
$QueryPart3.
$SourceInstitutionCode.
$QueryPart4.
$SourceCode.
$QueryPart5; }
$dom =
new DOMDocument();
* calling specific script for saving data in ABCD1.2 format
include ("Save_ABCD1.2.php");}
* calling specific script for saving data in ABCD2.06 format
include ("Save_ABCD2.06.php");}
if($ID_Schema ==
3 or $ID_Schema ==
6) {
* calling specific script for saving data in DarwinCore format
include ("Save_DarwinCore.php");}
* calling specific script for saving data in ABCD2.05 format
include ("Save_ABCD2.05.php");}
if(empty($formUnitID[0]) and $ID_Dataset !=
'')
{ echo
"<span class='error'>No hits. Please verify your entry and selection of specimen database. DNA data have not been saved!</span>";}
{ echo
"<span class='error'>Please select a specimen or verify your entry!</span>";}
if(empty($formTest[0])) {
$resultExist=
mysql_query("SELECT ID_DNA, Dna_Bank_Number FROM dnabanknumbers " .
"WHERE Dna_Bank_Number = '$formDnaBankNumber'");
$conf2 =
"<script language='javascript'>alert('DNA Extraction Number already exist!');</script>";
echo
"<span class='error'>DNA Extraction Number already exist!</span>";
if(empty($resultExist) or !mysql_num_rows($resultExist)) //empty($formDnaBankNumber))
if($formSpecimenNumber!=
"")
if($formProviderIntern!=
"" or $formProviderExtern!=
"")
* include separate script for saving the final specimen data
include ("Save_Specimen.php"); } }
{ $msg =
"####Error in Save_Specimen.php####";
include ("../config/Errorreport.php"); }
/*******************************************************************************************
*******************************************************************************************/
if (isset
($_REQUEST['c']))
foreach ($_REQUEST['c'] as $b)
if ($b ==
"BlockGeneral")
if($formStockFridge!=
"" or $formStockRack!=
"" or $formStockBox!=
"")
$sql1 =
"INSERT INTO location_stock (ID_Stock_Box, ID_Stock_Rack, ID_Stock_Fridge, Origin_Quantity, Rest_Quantity, Stock_Barcode, Stock_Position, Created_Who)" .
"VALUES ('$formStockBox','$formStockRack','$formStockFridge','$formStockQuantity','$formStockRest','$formBarcodeStock','$formPositionStock','$log')";
#######################################Error 1###############################################################
$msg .=
"####Error 1####";
include ("../config/Errorreport.php"); }
#############################################################################################################
if (!isset
($moreGenBank))
{ unset
($formGeneticLocusA);
unset
($formGenbankNumberA);
unset
($formGenbankLinkA);
unset
($formGeneticLocusB);
unset
($formGenbankNumberB);
unset
($formGenbankLinkB);
unset
($formGeneticLocusC);
unset
($formGenbankNumberC);
unset
($formGenbankLinkC);
unset
($formGeneticLocusD);
unset
($formGenbankNumberD);
unset
($formGenbankLinkD);
$sql2 =
"INSERT INTO dnabanknumbers (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, Check_Date, " .
"ID_Location_Stock, Stock_Gone, Source_Gone, Block_Until, " .
"Block_General, ID_Provided_By_People, Notes, Notes_Intern, Backup_Aliquot, Created_Who, ID_Cache)" .
"VALUES ('$formDnaBankNumber','$formRelation','$formType','$formPreservation','$formTissue',
'$formExtractionMethod','$ExtractionDate','$formNoExtractDate','$formExtractionStaff',
'$formPurificationMethod','$formAbsorbance280','$formAbsorbance230','$formConcentration',
'$formDegradation','$CheckDate','$IDLocationStock','$StockGone','$SourceGone',
'$BlockDate','$BlockGeneral','$formProvidedBy','$formNotes','$formNotesIntern','$Backup','$log','$IDTableCache')";
#######################################Error 2###############################################################
$msg .=
"####Error 2####";
mail("g.droege@bgbm.org", "Error report", $msg, "From: BGBM-".
$_SESSION['log']);
include ("../config/Errorreport.php"); }
#############################################################################################################
{echo
"<span class='fine'>DNA Extraction No: </span><span class='error'>".
$formDnaBankNumber.
"</span>"; }
$sql =
"INSERT INTO amplifications (ID_DNA, ID_GeneticLocus, GenBankNumber, Link, Created_Who)" .
"VALUES ('$IDDna','$formGeneticLocus','$formGenBankNumber','$formGenBankLink','$log')";
#######################################Error formGenbankNumber###############################################################
$msg .=
"####Error formGenbankNumber####";
include ("../config/Errorreport.php"); }
#############################################################################################################
$sql =
"INSERT INTO amplifications (ID_DNA, ID_GeneticLocus, GenBankNumber, Link, Created_Who)" .
"VALUES ('$IDDna','$formGeneticLocusA','$formGenBankNumberA','$formGenBankLinkA','$log')";
#######################################Error formGenbankNumberA###############################################################
$msg .=
"####Error formGenbankNumberA####";
include ("../config/Errorreport.php"); }
#############################################################################################################
$sql =
"INSERT INTO amplifications (ID_DNA, ID_GeneticLocus, GenBankNumber, Link, Created_Who)" .
"VALUES ('$IDDna','$formGeneticLocusB','$formGenBankNumberB','$formGenBankLinkB','$log')";
#######################################Error formGenbankNumberB###############################################################
$msg .=
"####Error formGenbankNumberB####";
include ("../config/Errorreport.php"); }
#############################################################################################################
$sql =
"INSERT INTO amplifications (ID_DNA, ID_GeneticLocus, GenBankNumber, Link, Created_Who)" .
"VALUES ('$IDDna','$formGeneticLocusC','$formGenBankNumberC','$formGenBankLinkC','$log')";
#######################################Error formGenbankNumberC###############################################################
$msg .=
"####Error formGenbankNumberC####";
include ("../config/Errorreport.php"); }
#############################################################################################################
$sql =
"INSERT INTO amplifications (ID_DNA, ID_GeneticLocus, GenBankNumber, Link, Created_Who)" .
"VALUES ('$IDDna','$formGeneticLocusD','$formGenBankNumberD','$formGenBankLinkD','$log')";
#######################################Error formGenbankNumberD###############################################################
$msg .=
"####Error formGenbankNumberD####";
include ("../config/Errorreport.php"); }
#############################################################################################################
if (isset
($_REQUEST['Aliquot']))
foreach ($_POST['x'] as $v =>
$value)
$SourceQuantity =
$AliquotSourceQuantity[$v];
$RestQuantity =
$AliquotRestQuantity[$v];
$Barcode =
$BarcodeAliquot[$v];
$Position =
$PositionAliquot[$v];
$lettercount =
$letter++
;
$AliquotNumber =
$formDnaBankNumber.
'-'.
$lettercount;
if (!isset
($_REQUEST['Aliquot']))
$sql3 =
"INSERT INTO aliquots (ID_DNA, ID_Aliquots_Fridge, ID_Aliquots_Rack, ID_Aliquots_Box,
Aliquot_Number, Origin_Quantity, Rest_Quantity, Aliquot_Barcode, Aliquot_Position, Price, Currency, Created_Who) " .
"VALUES ('$IDDna','$value','$rack','$box','$AliquotNumber','$SourceQuantity','$RestQuantity','$Barcode','$Position','$priceperaliquot','$Currency','$log')";
#######################################Error sql3###############################################################
$msg .=
"####Error sql3####";
include ("../config/Errorreport.php"); }
#############################################################################################################
if(!empty($formAliquotsFridge) or !empty($formAliquotsRack) or !empty($formAliquotsBox))
$AliquotNumber =
$formDnaBankNumber.
'-A';
$sql4 =
"INSERT INTO aliquots (ID_DNA, ID_Aliquots_Fridge, ID_Aliquots_Rack, ID_Aliquots_Box, Aliquot_Number, Origin_Quantity, Rest_Quantity, Aliquot_Barcode, Aliquot_Position, Price, Currency, Created_Who)" .
"VALUES ('$IDDna','$formAliquotsFridge','$formAliquotsRack','$formAliquotsBox','$AliquotNumber','$formQuantityAliquot','$formAliquotRest','$formBarcodeAliquot','$formPositionAliquot','$priceperaliquot','$Currency','$log')";
#######################################Error sql4###############################################################
$msg .=
"####Error sql4####";
include ("../config/Errorreport.php"); }
#############################################################################################################
Documentation generated on Tue, 29 Nov 2011 10:45:05 +0100 by phpDocumentor 1.4.3