* 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+Copy" 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 * @version 2.0 * @package Input * @copyright Copyright © 2011 DNA Bank Network http://www.dnabank-network.org
The contents of this file are subject to the Mozilla Public License Version 1.1 * @filesource * @license http://www.mozilla.org/MPL/ MPL */ if($formSubmitSave or $formSubmitCopy) { /******************************************************************************************** * some data quality checks first * * START * *********************************************************************************************/ if(empty($formDnaBankNumber) or ($formDnaBankNumber == $Prefix)) { echo 'Please define a DNA Extraction Number!'; $Validation = "FALSE"; } //else { if(!empty($formDnaBankNumber) and $formDnaBankNumber != $Prefix) { if($formExtractionDate == "YYYY-MM-DD") { unset($formExtractionDate); } else { $date = $formExtractionDate; if (!valiDate($date)) { $Validation = "FALSE"; echo 'Extraction date incorrect!
'; } else { $ExtractionDate = $formExtractionDate; } } if($formCheckDate == "YYYY-MM-DD" or $formCheckDate == "") { unset($formCheckDate); } else { $date = $formCheckDate; if (!valiDate($date)) { $Validation = "FALSE"; echo 'Quality check date incorrect!
'; } else { $CheckDate = $formCheckDate; } } if($formBlockDate == "YYYY-MM-DD" or $formBlockDate == "") { unset($formBlockDate); } else { $date = $formBlockDate; if (!valiDate($date)) { $Validation = "FALSE"; echo 'Block date incorrect!
'; } else { $BlockDate = $formBlockDate; } } if(empty($formRelation)) { $Validation = "FALSE"; echo 'Please define relation to voucher!
'; } if((empty($formExtractionDate) or $formExtractionDate == "YYYY-MM-DD") and empty($formNoExtractDate)) { $Validation = "FALSE"; echo 'Please enter extraction date or select checkbox!
'; } if(empty($formExtractionMethod)) { $Validation = "FALSE"; echo 'Please select extraction method!
'; } if(empty($formExtractionStaff)) { $Validation = "FALSE"; echo 'Please select extraction staff!
'; } if(empty($formProviderIntern) and empty($formProviderExtern) and !empty($formSpecimenNumber)) { unset($formProviderIntern); unset($formProviderExtern); echo 'Please select a Specimen database!'; $Validation = "FALSE"; } if(!empty($formProviderIntern) and !empty($formProviderExtern)) { echo 'Please select either an "Internal" or "External" Specimen database!'; $Validation = "FALSE";} if(empty($formUnitID)) { echo 'Please verify specimen first!'; $Validation = "FALSE";} } /******************************************************************************************** * some data quality checks first * * END * *********************************************************************************************/ if(!empty($formDnaBankNumber) and ($formDnaBankNumber != $Prefix) and $Validation != "FALSE") { $SpecimenNo = urlencode($_POST['formSpecimenNumber']); /******************************************************************************************** * saving specimen data * * START * *******************************************************************************************/ $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); if(!empty($variable4)) { $result = mysqli_query($GLOBALS["___mysqli_ston"], "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.FK_Schema " . " FROM dataset " . " LEFT JOIN provider ON dataset.FK_Provider = provider.ID_Provider " . " LEFT JOIN schemata ON provider.FK_Schema = schemata.ID_Schema " . " WHERE dataset.ID_Dataset = '$variable4'"); } if(!empty($variable6)) { $result = mysqli_query($GLOBALS["___mysqli_ston"], "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.FK_Schema " . " FROM dataset " . " LEFT JOIN provider ON dataset.FK_Provider = provider.ID_Provider " . " LEFT JOIN schemata ON provider.FK_Schema = schemata.ID_Schema " . " WHERE dataset.ID_Dataset = '$variable6'"); } if(!empty($formProviderIntern) or !empty($formProviderExtern)) { while($row = mysqli_fetch_object($result)) { $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->FK_Schema; } $SourceUnitID = urlencode($variable1[$mykey]); $SourceInstitutionCode = urlencode($variable2[$mykey]); $SourceCode = urlencode($variable3[$mykey]); $Digir_Resource1 = urlencode($Digir_Resource); $Digir_Source1 = urlencode($Digir_Source); } if($Provider == NULL and $ID_Dataset == "1") { include("Save_SpTool.php"); } if($ID_Dataset == "2") { include("Save_GBIF.php"); } else { if($SpecimenNo != "") { if($variable6 != '') {$test1 = 'true'; } if($variable4 != '1' and $variable4 != '') {$test2 = 'true'; } 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; } if($ID_Schema != 3) { $file = $Provider."&query=".urlencode('
search
http://www.tdwg.org/schemas/abcd/2.06 http://www.tdwg.org/schemas/abcd/2.06 '); $file .= $SourceUnitID; $file .= urlencode(''); $file .= $SourceInstitutionCode; $file .= urlencode(''); $file .= $SourceCode; $file .= urlencode('false
'); //$file = $Provider.$QueryPart1b.$Digir_Resource1.$QueryPart1_1.$Digir_Source1.$QueryPart1_2b.$SourceUnitID.$QueryPart3.$SourceInstitutionCode.$QueryPart4.$SourceCode.$QueryPart5; } //echo $file; $dom = new DOMDocument(); $dom->Load($file); if($ID_Schema == 1) { /** * calling specific script for saving data in ABCD1.2 format */ include ("Save_ABCD1.2.php");} if($ID_Schema == 2) { /** * 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");} if($ID_Schema == 4) { /** * calling specific script for saving data in ABCD2.05 format */ include ("Save_ABCD2.05.php");} } } } // if($Provider != NULL and $ID_Dataset != "1") if(empty($formUnitID[0]) and $ID_Dataset != '1') { 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= mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_DNA, Dna_Bank_Number FROM dnabanknumbers " . "WHERE Dna_Bank_Number = '$formDnaBankNumber'"); if(!mysqli_num_rows($resultExist)) {}; if(mysqli_num_rows($resultExist)) { $Validation = "FALSE"; echo "DNA Extraction Number already exist!"; } if(empty($resultExist) or !mysqli_num_rows($resultExist)) { if($formUnitID != "" or isset($formUnitID)) { if($formProviderIntern != "" or $formProviderExtern != "") { /** * include separate script for saving the final specimen data */ include ("Save_Specimen.php");} } if($error == "true" or $Specimen_Saved != "true") { $msg = "####Error in Save_Specimen.php; Specimen and DNA record have not been saved.####"; if($debug == '1') echo $msg; trigger_error($msg, E_USER_ERROR); /** * calling Error message */ include ("../config/Errorreport.php"); } /******************************************************************************************* * saving specimen data * * END * *******************************************************************************************/ else { if (isset($_REQUEST['c'])) { reset($_REQUEST['c']); foreach ($_REQUEST['c'] as $b) { if ($b == "SourceGone") $SourceGone = "1"; if ($b == "StockGone") $StockGone = "1"; if ($b == "BlockLoan") $BlockForLoan = "1"; if ($b == "BlockPublish") $BlockForPublishing = "1"; if ($b == "Aliquot") $Aliquot = "1"; if ($b == "Backup") $Backup = "1"; } } /** * include script to mask data before inserting, e.g. add slashes before additional characters etc. */ include("addslashes_dnabanknumbers.php"); $GUID = GUID(); if($formStockFridge != "" or $formStockRack != "" or $formStockBox != "" or $sqlStockQuantity != "" or $sqlStockRest != "" or $formBarcodeStock != "") { $sql1 = "INSERT INTO location_stock (FK_Stock_Box, FK_Stock_Rack, FK_Stock_Fridge, Origin_Quantity, Rest_Quantity, Stock_Barcode, Stock_Position, Created_Who)" . "VALUES ($formStockBox,$formStockRack,$formStockFridge,'$sqlStockQuantity','$sqlStockRest','$formBarcodeStock','$sqlPositionStock','$log')"; $result1 = mysqli_query($GLOBALS["___mysqli_ston"], $sql1); $IDLocationStock=((is_null($___mysqli_res = mysqli_insert_id($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res); #######################################Error 1############################################################### if(!$result1) { $msg = $sql1."\n"; $msg .= "####Error 1####"; if($debug == '1') echo $msg; trigger_error($msg, E_USER_ERROR); /** * calling Error message */ include ("../config/Errorreport.php"); } ############################################################################################################# } if($formGelFileURI or $formGelVoltage or $formGelConcentration or $formGelRemarks or $formGelDuration or $formGelLadder) { $sqlGel = "INSERT INTO gelimages (FileURI, GelRemarks, GelVoltage, GelConcentration, GelDuration, GelLadder, Created_Who) VALUES ('$sqlGelFileURI','$sqlGelRemarks','$sqlGelVoltage','$sqlGelConcentration','$sqlGelDuration','$sqlGelLadder','$log')"; $resultGel = mysqli_query($GLOBALS["___mysqli_ston"], $sqlGel); $IDGelImage = ((is_null($___mysqli_res = mysqli_insert_id($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res); #######################################Error GelImage######################################################## if(!$resultGel) { $msg = $sqlGel."\n"; $msg .= "####Error GelIimage####"; if($debug == '1') echo $msg; trigger_error($msg, E_USER_ERROR); /** * calling Error message */ 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, FK_Relation, FK_Type, " . "FK_Preservation, FK_Tissue, FK_Extraction_Method, Extraction_Date, NoExtractDate, FK_Extraction_Staff, " . "FK_Purification_Method, Absorbance280, Absorbance230, Concentration, Quality_Check_Date, FK_GelImage, " . "FK_Location_Stock, Stock_Gone, Source_Gone, Blocked_Until, " . "Blocked_For_Loaning, Blocked_For_Publishing, Loan_Conditions, FK_AcquiredFrom, Notes, Notes_Intern, Backup_Aliquot, GUID, Created_Who, FK_Cache)" . "VALUES ('$sqlDnaBankNumber',$formRelation,$formType,$formPreservation,$formTissue, $formExtractionMethod,$ExtractionDate,'$formNoExtractDate',$formExtractionStaff, $formPurificationMethod,$sqlAbsorbance2802,$sqlAbsorbance2302,$sqlConcentration2, $CheckDate,$IDGelImage,$IDLocationStock,'$StockGone','$SourceGone', $BlockDate,'$BlockedForLoan','$BlockedForPublishing','$sqlLoanConditions',$formAcquiredFrom,'$sqlNotes','$sqlNotesIntern','$Backup','$GUID','$log','$IDTableCache')"; $result2 = mysqli_query($GLOBALS["___mysqli_ston"], $sql2); $IDDna=((is_null($___mysqli_res = mysqli_insert_id($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res); #######################################Error 2############################################################### if(!$result2) { $msg = $sql2."\n"; $msg .= "####Error 2####"; if($debug == '1') echo $msg; mail("g.droege@bgbm.org", "Error report", $msg, "From: BGBM-".$_SESSION['log']); trigger_error($msg, E_USER_ERROR); /** * calling Error message */ include ("../config/Errorreport.php"); } ############################################################################################################# if($result2) { if($formLabNumbers != "" or isset($formLabNumbers)){ $labNumberArray = explode(";", $formLabNumbers); while($i = each($labNumberArray)) { $labNumber = trim(addslashes($i[1])); $sql3 = "INSERT INTO labnumber (ID_DNA, LabNumber, Created_Who) VALUES ('$IDDna', '$labNumber', '$log')"; $result3 = mysqli_query($GLOBALS["___mysqli_ston"], $sql3); } #######################################Error 2############################################################### if(!$result3 and $formLabNumber) { $msg = $sql3."\n"; $msg .= "####Error 3####"; if($debug == '1') echo $msg; mail("g.droege@bgbm.org", "Error report", $msg, "From: BGBM-".$_SESSION['log']); trigger_error($msg, E_USER_ERROR); /** * calling Error message */ include ("../config/Errorreport.php"); } ############################################################################################################# } include("../config/RecordHasBeenSaved.php"); echo "Specimen Number: ".$sqlUnitID." Institution Code: ".$sqlSourceInstitutionCode." Collection Code: ".$sqlSourceName."
Taxon Name: "; if($View != "") { echo $View; } else { if(is_array($sqlNameAuthorYearString)) { echo $sqlNameAuthorYearString[0]; } else { echo $sqlNameAuthorYearString; } } echo "
"; if ($count == '1') { echo "".$count." DNA Sample already exist for the selected specimen!
"; } if($count > 1) { echo "".$count." DNA Samples already exist for the selected specimen!
"; } echo "DNA Extraction No: ".$formDnaBankNumber."" .build_href_blank("../search/query.php", "sqlType=Detail&ID_DNA=".$IDDna, "Show this record (opens in new tab)")."
"; } if($formGenBankNumber) { $sql = "INSERT INTO amplifications (FK_DNA, FK_GeneticLocus, GenBankNumber, Link, Created_Who)" . "VALUES ('$IDDna','$formGeneticLocus','$sqlGenBankNumber','$sqlGenBankLink','$log')"; $result = mysqli_query($GLOBALS["___mysqli_ston"], $sql); #######################################Error formGenbankNumber############################################################### if(!$result) { $msg = $sql."\n"; $msg .= "####Error formGenbankNumber####"; if($debug == '1') echo $msg; trigger_error($msg, E_USER_ERROR); /** * calling Error message */ include ("../config/Errorreport.php"); } ############################################################################################################# } if($formGenBankNumberA) { $sql = "INSERT INTO amplifications (FK_DNA, FK_GeneticLocus, GenBankNumber, Link, Created_Who)" . "VALUES ('$IDDna','$formGeneticLocusA','$sqlGenBankNumberA','$sqlGenBankLinkA','$log')"; $result = mysqli_query($GLOBALS["___mysqli_ston"], $sql); #######################################Error formGenbankNumberA############################################################### if(!$result) { $msg = $sql."\n"; $msg .= "####Error formGenbankNumberA####"; if($debug == '1') echo $msg; trigger_error($msg, E_USER_ERROR); /** * calling Error message */ include ("../config/Errorreport.php"); } ############################################################################################################# } if($formGenBankNumberB) { $sql = "INSERT INTO amplifications (FK_DNA, FK_GeneticLocus, GenBankNumber, Link, Created_Who)" . "VALUES ('$IDDna','$formGeneticLocusB','$sqlGenBankNumberB','$sqlGenBankLinkB','$log')"; $result = mysqli_query($GLOBALS["___mysqli_ston"], $sql); #######################################Error formGenbankNumberB############################################################### if(!$result) { $msg = $sql."\n"; $msg .= "####Error formGenbankNumberB####"; if($debug == '1') echo $msg; trigger_error($msg, E_USER_ERROR); /** * calling Error message */ include ("../config/Errorreport.php"); } ############################################################################################################# } if($formGenBankNumberC) { $sql = "INSERT INTO amplifications (FK_DNA, FK_GeneticLocus, GenBankNumber, Link, Created_Who)" . "VALUES ('$IDDna','$formGeneticLocusC','$sqlGenBankNumberC','$sqlGenBankLinkC','$log')"; $result = mysqli_query($GLOBALS["___mysqli_ston"], $sql); #######################################Error formGenbankNumberC############################################################### if(!$result) { $msg = $sql."\n"; $msg .= "####Error formGenbankNumberC####"; if($debug == '1') echo $msg; trigger_error($msg, E_USER_ERROR); /** * calling Error message */ include ("../config/Errorreport.php"); } ############################################################################################################# } if($formGenBankNumberD) { $sql = "INSERT INTO amplifications (FK_DNA, FK_GeneticLocus, GenBankNumber, Link, Created_Who)" . "VALUES ('$IDDna','$formGeneticLocusD','$sqlGenBankNumberD','$sqlGenBankLinkD','$log')"; $result = mysqli_query($GLOBALS["___mysqli_ston"], $sql); #######################################Error formGenbankNumberD############################################################### if(!$result) { $msg = $sql."\n"; $msg .= "####Error formGenbankNumberD####"; if($debug == '1') echo $msg; trigger_error($msg, E_USER_ERROR); /** * calling Error message */ include ("../config/Errorreport.php"); } ############################################################################################################# } if (isset($_REQUEST['Aliquot'])) { $letter = B; foreach ($_POST['x'] as $v => $value) { $rack = $_POST['y'][$v]; $box = $_POST['z'][$v]; $SourceQuantity = $AliquotSourceQuantity[$v]; $RestQuantity = $AliquotRestQuantity[$v]; $Barcode = $BarcodeAliquot[$v]; $Position = $PositionAliquot[$v]; $lettercount = $letter++; $AliquotNumber = $formDnaBankNumber.'-'.$lettercount; if (!isset($_REQUEST['Aliquot'])) { unset($value); unset($rack); unset($box); unset($SourceQuantity); unset($RestQuantity); unset($Barcode); unset($Position); } else { if($value=="") { unset($value); unset($rack); unset($box); unset($SourceQuantity); unset($RestQuantity); unset($Barcode); unset($Position); } else { $sql3 = "INSERT INTO aliquots (FK_DNA, FK_Aliquots_Fridge, FK_Aliquots_Rack, FK_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')"; $result3 = mysqli_query($GLOBALS["___mysqli_ston"], $sql3); #######################################Error sql3############################################################### if(!$result3) { $msg = $sql3."\n"; $msg .= "####Error sql3####"; if($debug == '1') echo $msg; trigger_error($msg, E_USER_ERROR); /** * calling Error message */ include ("../config/Errorreport.php"); } ############################################################################################################# } } } } if(!empty($formAliquotsFridge) or !empty($formAliquotsRack) or !empty($formAliquotsBox)) { $AliquotNumber = $formDnaBankNumber.'-A'; $sql4 = "INSERT INTO aliquots (FK_DNA, FK_Aliquots_Fridge, FK_Aliquots_Rack, FK_Aliquots_Box, Aliquot_Number, Origin_Quantity, Rest_Quantity, Aliquot_Barcode, Aliquot_Position, Price, Currency, Created_Who)" . "VALUES ('$IDDna',$formAliquotsFridge,$formAliquotsRack,$formAliquotsBox,'$AliquotNumber','$sqlQuantityAliquot','$sqlAliquotRest','$sqlBarcodeAliquot','$sqlPositionAliquot','$priceperaliquot','$Currency','$log')"; $result4 = mysqli_query($GLOBALS["___mysqli_ston"], $sql4); #######################################Error sql4############################################################### if(!$result4) { $msg = $sqlt4."\n"; $msg .= "####Error sql4####"; if($debug == '1') echo $msg; trigger_error($msg, E_USER_ERROR); /** * calling Error message */ include ("../config/Errorreport.php"); } ############################################################################################################# } } } } } //} } ?>