=";
$st = "<=";
if($_REQUEST['hitlist'] == "true")
{$parr = $_COOKIE; }
if($_GET['CrBy'] != "")
{$parr = $_GET;}
if($_REQUEST['hitlist'] == "" and $_GET['CrBy'] == "")
{$parr = $_POST; }
array($parr);
foreach ($parr as $varorigin)
{ $var = addslashes($varorigin);
$i ++;
if(!empty($var) and $var!="Search" and $var != $DNANo and key($parr)!="PHPSESSID" and key($parr) != "Module" and key($parr) != "_pk_id_10_1fff")
{
switch (key($parr))
{
case 'formSpecimenNumber':
$str = "cachecollection.UnitID_Specimen ".$tr." '".$var."' AND ";
$description = " Specimen Number = ";
if($_POST['formSpecimenNumber']) {$value = $formSpecimenNumber; }
else {$value = $_COOKIE['formSpecimenNumber'];}
break;
case 'formProviderIntern':
$str = "cachecollection.FK_Dataset_Specimen ".$tr." '".$var."' AND ";
$description = " Specimen Database = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_Dataset, Display FROM dataset WHERE ID_Dataset ".$tr." '".$var."'");
while($row = mysqli_fetch_object($result))
{$value = $row->Display; }
break;
case 'formProviderExtern':
$str = "cachecollection.FK_Dataset_Specimen ".$tr." '".$var."' AND ";
$description = " Specimen Database = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_Dataset, Display FROM dataset WHERE ID_Dataset ".$tr." '".$var."'");
while($row = mysqli_fetch_object($result))
{$value = $row->Display; }
break;
case 'formHigherTaxon':
$str = "cachehighertaxa.HigherTaxon ".$tr." '".$var."' AND ";
$description = " Higher Taxon = ";
if($_POST['formHigherTaxon']) {$value = $formHigherTaxon;}
else {$value = $_COOKIE['formHigherTaxon'];}
break;
case 'formTaxonName':
$str = "cachetaxonidentified.NameAuthorYear ".$lk." '".$var."%' AND ";
$description = " Taxon Name = ";
if($_POST['formTaxonName']) {$value = $formTaxonName;}
else {$value = $_COOKIE['formTaxonName'];}
break;
case 'formGenus':
$str = "cachetaxonidentified.Genus ".$tr." '".$var."' AND ";
$description = " Genus = ";
if($_POST['formGenus']) {$value = $formGenus;}
else {$value = $_COOKIE['formGenus'];}
break;
case 'formSubgenus':
$str = "cachetaxonidentified.Subgenus ".$tr." '".$var."' AND ";
$description = " Subgenus = ";
if($_POST['formSubgenus']) {$value = $formSubgenus;}
else {$value = $_COOKIE['formSubgenus'];}
break;
case 'formSpecificEpithet':
$str = "cachetaxonidentified.FirstEpithet ".$lk." '%".$var."%' AND ";
$description = " Specific Epithet = ";
if($_POST['formSpecificEpithet']) {$value = $formSpecificEpithet;}
else {$value = $_COOKIE['formSpecificEpithet'];}
break;
case 'formRank':
$str = "cachetaxonidentified.Rank ".$tr." '".$var."' AND ";
$description = " Rank = ";
if($_POST['formRank']) {$value = $formRank;}
else {$value = $_COOKIE['formRank'];}
break;
case 'formInfraspecificEpithet':
$str = "cachetaxonidentified.SecondEpithet ".$lk." '%".$var."%' AND ";
$description = " Infraspecific Epithet = ";
if($_POST['formInfraspecificEpithet']) {$value = $formInfraspecificEpithet;}
else {$value = $_COOKIE['formInfraspecificEpithet'];}
break;
case 'formCountryList':
$resultCountry = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT CountryName FROM cachecollection WHERE ID_Cache = '".$var."'");
while($row = mysqli_fetch_object($resultCountry))
{$List = $row->CountryName; }
$str = "cachecollection.CountryName ".$tr." '".addslashes($List)."' AND " ;
$description = " Country = ";
$value = $List;
break;
case 'formCountryListISO':
$resultCountry = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT CountryISO2 FROM cachecollection WHERE ID_Cache = '".$var."'");
while($row = mysqli_fetch_object($resultCountry))
{$ListISO = $row->CountryISO2; }
$str = "cachecollection.CountryISO2 ".$tr." '".addslashes($ListISO)."' AND " ;
$description = " Country ISO Code = ";
$value = $ListISO;
break;
case 'formContinent':
$str = "cachecollection.ContinentOrOcean ".$lk." '%".$var."%' AND ";
$description = " Continent or Ocean = ";
if($_POST['formContinent']) {$value = $formContinent;}
else {$value = $_COOKIE['formContinent'];}
break;
case 'formLocality':
$str = "cachecollection.Locality ".$lk." '%".$var."%' AND ";
$description = " Locality = ";
if($_POST['formLocality']) {$value = $formLocality;}
else {$value = $_COOKIE['formLocality'];}
break;
case 'formLatFrom':
$str = "cachecollection.Latitude ".$bt." '".$var."' AND ";
$description = " Latitude >= ";
if($_POST['formLatFrom']) {$value = $formLatFrom;}
else {$value = $_COOKIE['formLatFrom'];}
break;
case 'formLatTo':
$str = "cachecollection.Latitude ".$st." '".$var."' AND ";
$description = " Latitude <= ";
if($_POST['formLatTo']) {$value = $formLatTo;}
else {$value = $_COOKIE['formLatTo'];}
break;
case 'formLongFrom':
$str = "cachecollection.Longitude ".$bt." '".$var."' AND ";
$description = " Longitude >= ";
if($_POST['formLongFrom']) {$value = $formLongFrom;}
else {$value = $_COOKIE['formLongFrom'];}
break;
case 'formLongFrom':
$str = "cachecollection.Longitude ".$st." '".$var."' AND ";
$description = " Longitude <= ";
if($_POST['formLongFrom']) {$value = $formLongTo;}
else {$value = $_COOKIE['formLongFrom'];}
break;
case 'formCollector':
$str = "cachecollection.Collectors ".$lk." '%".$var."%' AND ";
$description = " Collector = ";
if($_POST['formCollector']) {$value = $formCollector;}
else {$value = $_COOKIE['formCollector'];}
break;
case 'formCollectorsNo':
$str = "cachecollection.CollectorsNo ".$lk." '%".$var."%' AND ";
$description = " Collector's No = ";
if($_POST['formCollectorsNo']) {$value = $formCollectorsNo;}
else {$value = $_COOKIE['formCollectorsNo'];}
break;
case 'formCollectionDate':
$str = "cachecollection.CollectionDate ".$lk." '%".$var."%' AND ";
$description = " Collection Date = ";
if($_POST['formCollectionDate']) {$value = $formCollectionDate;}
else {$value = $_COOKIE['formCollectionDate'];}
break;
case 'formDnaBankNumber':
if($var != $Prefix) {
$str = "(dnabanknumbers.DNA_Bank_Number ".$tr."'".$var."' OR labnumber.LabNumber ".$tr."'".$var."') AND ";
$description = " DNA Extraction / Lab No = ";
if($_POST['formDnaBankNumber']) {$value = $formDnaBankNumber;}
else {$value = $_COOKIE['formDnaBankNumber'];} }
break;
case 'formRelation':
$str = "dnabanknumbers.FK_RelationDNA_Voucher ".$tr."'".$var."' AND ";
$description = " Relation to Voucher = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_Relation, Relation FROM relation WHERE ID_Relation ".$tr." '".$var."'");
while($row = mysqli_fetch_object($result))
{$value = $row->Relation; }
break;
case 'formType':
$str = "dnabanknumbers.FK_Type ".$tr."'".$var."' AND ";
$description = " DNA Type = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_Type, Type FROM dnatype WHERE ID_Type ".$tr." '".$var."'");
while($row = mysqli_fetch_object($result))
{$value = $row->Type; }
break;
case 'formPreservation':
$str = "dnabanknumbers.FK_Preservation ".$tr."'".$var."' AND ";
$description = " Preservation = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT FK_Preservation, Preservation FROM preservation WHERE FK_Preservation ".$tr." '".$var."'");
while($row = mysqli_fetch_object($result))
{$value = $row->Preservation; }
break;
case 'formTissue':
$str = "dnabanknumbers.FK_Tissue ".$tr."'".$var."' AND ";
$description = " Tissue = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_Tissue, Tissue FROM tissue WHERE ID_Tissue ".$tr." '".$var."'");
while($row = mysqli_fetch_object($result))
{$value = $row->Tissue; }
break;
case 'formExtractionMethod':
$str = "dnabanknumbers.FK_Extraction_Method ".$tr."'".$var."' AND ";
$description = " Extraction Method = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_Method, Method FROM methods WHERE ID_Method ".$tr." '".$var."'");
while($row = mysqli_fetch_object($result))
{$value = $row->Method; }
break;
case 'formExtractionDateFrom':
if ($ExtractionDateFrom!="") {
$str = "dnabanknumbers.Extraction_Date ".$bt."'".$var."' AND ";
$description = " Extraction Date >= ";
if($_POST['formExtractionDateFrom']) {$value = $formExtractionDateFrom;}
else {$value = $_COOKIE['formExtractionDateFrom'];}
}
break;
case 'formExtractionDateTo':
if ($ExtractionDateTo!="") {
$str = "dnabanknumbers.Extraction_Date ".$st."'".$var."' AND ";
$description = " Extraction Date <= ";
if($_POST['formExtractionDateTo']) {$value = $formExtractionDateTo;}
else {$value = $_COOKIE['formExtractionDateTo'];}
}
break;
case 'formNoExtractDate':
$str = "dnabanknumbers.NoExtractDate ".$tr."'".$var."' AND ";
$description = " Extraction Date = ";
$value = "Not available";
break;
case 'formExtractionStaff':
$str = "dnabanknumbers.FK_Extraction_Staff ".$tr."'".$var."' AND ";
$description = " Extraction Staff = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_People, Name_All FROM people WHERE ID_People ".$tr." '".$var."'");
while($row = mysqli_fetch_object($result))
{$value = $row->Name_All; }
break;
case 'formPurificationMethod':
$str = "dnabanknumbers.FK_Purification_Method ".$tr."'".$var."' AND ";
$description = " Purification Method = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_Purification_Method, Method FROM purification WHERE ID_Purification ".$tr." '".$var."'");
while($row = mysqli_fetch_object($result))
{$value = $row->Method; }
break;
case 'formAbsorbance280From':
$str = "dnabanknumbers.Absorbance280 ".$bt."'".$var."' AND ";
$description = " Absorbance 280/260 >= ";
if($_POST['formAbsorbance280From']) {$value = $formAbsorbance280From;}
else {$value = $_COOKIE['formAbsorbance280From'];}
break;
case 'formAbsorbance280To':
$str = "dnabanknumbers.Absorbance280 ".$st."'".$var."' AND ";
$description = " Absorbance 280/260 <= ";
if($_POST['formAbsorbance280To']) {$value = $formAbsorbance280To;}
else {$value = $_COOKIE['formAbsorbance280To'];}
break;
case 'formAbsorbance230From':
$str = "dnabanknumbers.Absorbance230 ".$bt."'".$var."' AND ";
$description = " Absorbance 230/260 >= ";
if($_POST['formAbsorbance230From']) {$value = $formAbsorbance230From;}
else {$value = $_COOKIE['formAbsorbance230From'];}
break;
case 'formAbsorbance230To':
$str = "dnabanknumbers.Absorbance230 ".$st."'".$var."' AND ";
$description = " Absorbance 230/260 <= ";
if($_POST['formAbsorbance230To']) {$value = $formAbsorbance230To;}
else {$value = $_COOKIE['formAbsorbance230To'];}
break;
case 'formConcentrationFrom':
$str = "dnabanknumbers.Concentration ".$bt."'".$var."' AND ";
$description = " Concentration <= ";
if($_POST['formConcentrationFrom']) {$value = $formConcentrationFrom;}
else {$value = $_COOKIE['formConcentrationFrom'];}
break;
case 'formConcentrationTo':
$str = "dnabanknumbers.Concentration ".$st."'".$var."' AND ";
$description = " Concentration >= ";
if($_POST['formConcentrationTo']) {$value = $formConcentrationTo;}
else {$value = $_COOKIE['formConcentrationTo'];}
break;
case 'formDegradation':
$str = "dnabanknumbers.FK_Degradation ".$tr."'".$var."' AND ";
$description = " Quality = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_Degradation, Degradation FROM degradation WHERE ID_Degradation ".$tr." '".$var."'");
while($row = mysqli_fetch_object($result))
{$value = $row->Degradation; }
break;
case 'formCheckDateFrom':
if ($CheckDateFrom!="") {
$str = "dnabanknumbers.Quality_Check_Date ".$bt."'".$var."' AND ";
$description = " Quality Check Date >= ";
if($_POST['formCheckDateFrom']) {$value = $formCheckDateFrom;}
else {$value = $_COOKIE['formCheckDateFrom'];}
}
break;
case 'formCheckDateTo':
if ($CheckDateTo!="") {
$str = "dnabanknumbers.Quality_Check_Date ".$st."'".$var."' AND ";
$description = " Quality Check Date <= ";
if($_POST['formCheckDateTo']) {$value = $formCheckDateTo;}
else {$value = $_COOKIE['formCheckDateTo'];}
}
break;
case 'radioGel':
$description = " Gel Image = ";
if($radioGel=="Yes" or $_COOKIE['radioGel']=="Yes") {
$str = 'dnabanknumbers.FK_GelImage '.addslashes($no).' "" AND ';
$value = "available";}
if($radioGel=="No" or $_COOKIE['radioGel']=="No") {
$str = "(dnabanknumbers.FK_GelImage IS NULL OR dnabanknumber.FK_GelImage = '0') AND ";
$value = "not available";}
break;
case 'formGeneticLocus':
$str = "amplifications.FK_GeneticLocus ".$tr."'".$var."' AND ";
$description = " Genetic Locus = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_GeneticLocus, GeneticLocus FROM geneticlocus WHERE ID_GeneticLocus ".$tr." '".$var."'");
while($row = mysqli_fetch_object($result))
{$value = $row->GeneticLocus; }
break;
case 'formGenBankNumber':
$str = "amplifications.GenBankNumber ".$lk."'%".$var."%' AND ";
$description = " Gen Bank Accession No = ";
if($_POST['formGenbankNumber']) {$value = $formGenbankNumber;}
else {$value = $_COOKIE['formGenbankNumber'];}
break;
case 'radioGenBank':
$description = " NCBI/EMBL/DDBJ Accession No = ";
if($radioGenBank=="Yes" or $_COOKIE['radioGenBank']=="Yes") {
$str = 'dnabanknumbers.ID_DNA '.$tr.' amplifications.ID_DNA AND amplifications.GenBankNumber '.addslashes($no).' "" AND ';
$value = "available";}
if($radioGenBank=="No" or $_COOKIE['radioGenBank']=="No") {
$str = "dnabanknumbers.ID_DNA NOT IN (SELECT ID_DNA FROM amplifications) AND ";
$value = "not available";}
break;
case 'formStockFridge':
$str = "location_stock.FK_Stock_Fridge ".$tr."'".$var."' AND ";
$description = " Stock Fridge = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT Stock_Fridge FROM stock_fridge WHERE ID_Stock_Fridge = '".$var."'");
while($row = mysqli_fetch_object($result)) { $value = $row->Stock_Fridge; }
break;
case 'formStockRack':
$str = "location_stock.FK_Stock_Rack ".$tr."'".$var."' AND ";
$description = " Stock Rack = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT Stock_Rack FROM stock_rack WHERE ID_Stock_Rack = '".$var."'");
while($row = mysqli_fetch_object($result)) { $value = $row->Stock_Rack; }
break;
case 'formStockBox':
$str = "location_stock.FK_Stock_Box ".$tr."'".$var."' AND ";
$description = " Stock Box = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT Stock_Box FROM stock_box WHERE ID_Stock_Box = '".$var."'");
while($row = mysqli_fetch_object($result)) { $value = $row->Stock_Box; }
break;
case 'formPositionStock':
$str = "location_stock.Stock_Position ".$tr."'".$var."' AND ";
$description = " Stock Position = ";
if($_POST['formPositionStock']) {$value = $formPositionStock;}
else {$value = $_COOKIE['formPositionStock'];}
break;
case 'formBarcodeStock':
$str = "location_stock.Stock_Barcode ".$tr."'".$var."' AND ";
$description = " Stock Barcode = ";
if($_POST['formBarcodeStock']) {$value = $formBarcodeStock;}
else {$value = $_COOKIE['formBarcodeStock'];}
break;
case 'formAcquiredFrom':
$str = "dnabanknumbers.FK_AcquiredFrom ".$tr."'".$var."' AND ";
$description = " Acquired From = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_People, Name_All FROM people WHERE ID_People ".$tr." '".$var."'");
while($row = mysqli_fetch_object($result))
{$value = $row->Name_All; }
break;
case 'formAliquotsFridge':
$str = "aliquots.FK_Aliquots_Fridge ".$tr."'".$var."' AND ";
$description = " Aliquots Fridge = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT Aliquots_Fridge FROM aliquots_fridge WHERE ID_Aliquots_Fridge = '".$var."'");
while($row = mysqli_fetch_object($result)) { $value = $row->Aliquots_Fridge; }
break;
case 'formAliquotsRack':
$str = "aliquots.FK_Aliquots_Rack ".$tr."'".$var."' AND ";
$description = " Aliquots Rack = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT Aliquots_Rack FROM aliquots_rack WHERE ID_Aliquots_Rack = '".$var."'");
while($row = mysqli_fetch_object($result)) { $value = $row->Aliquots_Rack; }
break;
case 'formAliquotsBox':
$str = "aliquots.FK_Aliquots_Box ".$tr."'".$var."' AND ";
$description = " Aliquots Box = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT Aliquots_Box FROM aliquots_box WHERE ID_Aliquots_Box = '".$var."'");
while($row = mysqli_fetch_object($result)) { $value = $row->Aliquots_Box; }
break;
case 'formPositionAliquot':
$str = "aliquots.Aliquot_Position ".$tr."'".$var."' AND ";
$description = " Aliquot Position = ";
if($_POST['formPositionAliquot']) {$value = $formPositionAliquot;}
else {$value = $_COOKIE['formPositionAliquot'];}
break;
case 'formBarcodeAliquot':
$str = "aliquots.Aliquot_Barcode ".$tr."'".$var."' AND ";
$description = " Aliquot Barcode = ";
if($_POST['formBarcodeAliquot']) {$value = $formBarcodeAliquot;}
else {$value = $_COOKIE['formBarcodeAliquot'];}
break;
case 'radioSource':
$description = " Source material = ";
if($radioSource=="Yes" or $_COOKIE['radioSource']=="Yes") {
$str = "dnabanknumbers.Source_Gone ".$tr."'1' AND ";
$value = "gone";}
if($radioSource=="No" or $_COOKIE['radioSource']=="No") {
$str = "dnabanknumbers.Source_Gone ".$tr."'0' AND ";
$value = "available"; }
break;
case 'radioStock':
$description = " Stock material = ";
if($radioStock=="Yes" or $_COOKIE['radioStock']=="Yes") {
$str = "dnabanknumbers.Stock_Gone ".$tr."'1' AND ";
$value ="gone"; }
if($radioStock=="No" or $_COOKIE['radioStock']=="No") {
$str = "dnabanknumbers.Stock_Gone ".$tr."'0' AND ";
$value ="available"; }
break;
case 'radioBackup':
$description = " Backup Aliquot made = ";
if($radioBackup=="Yes" or $_COOKIE['radioBackup']=="Yes") {
$str = "dnabanknumbers.Backup_Aliquot ".$tr."'1' AND ";
$value = "yes"; }
if($radioBackup=="No" or $_COOKIE['radioBackup']=="No") {
$str = "dnabanknumbers.Backup_Aliquot ".$tr."'0' AND ";
$value = "no"; }
break;
case 'formBlockDateFrom':
if ($BlockDateFrom!="") {
$str = "dnabanknumbers.Block_Until ".$bt."'".$var."' AND ";
$description = " Block until >= ";
if($_POST['formBlockDateFrom']) {$value = $formBlockDateFrom;}
else {$value = $_COOKIE['formBlockDateFrom'];} }
break;
case 'formBlockDateTo':
if ($BlockDateTo!="") {
$str = "dnabanknumbers.Block_Until ".$st."'".$var."' AND ";
$description = " Block until <= ";
if($_POST['formBlockDateTo']) {$value = $formBlockDateTo;}
else {$value = $_COOKIE['formBlockDateTo'];} }
break;
case 'formBlockLoan':
$str = "dnabanknumbers.Blocked_For_Loaning ".$tr."'1' AND ";
$description = " Blocked for Loaning = ";
$value ="yes";
break;
case 'formBlockPublish':
$str = "dnabanknumbers.Blocked_For_Publishing ".$tr."'1' AND ";
$description = " Blocked for Publishing = ";
$value ="yes";
break;
case 'formLoanConditions':
$str = "dnabanknumbers.Loan_Conditions ".$lk."'%".$var."%' AND ";
$description = " Loan Conditions = ";
if($_POST['formLoanConditions']) {$value = $formLoanConditions;}
else {$value = $_COOKIE['formLoanConditions'];}
break;
case 'formRequest':
$str = "request.FK_People ".$tr."'".$var."' AND ";
$description = " Requested By = ";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT ID_People, Name_All FROM people WHERE ID_People ".$tr." '".$var."'");
while($row = mysqli_fetch_object($result))
{$value = $row->Name_All; }
break;
case 'formNotes':
$str = "dnabanknumbers.Notes ".$lk."'%".$var."%' AND ";
$description = " Notes = ";
if($_POST['formNotes']) {$value = $formNotes;}
else {$value = $_COOKIE['formNotes'];}
break;
case 'formNotesIntern':
$str = "dnabanknumbers.Notes_Intern ".$lk."'%".$var."%' AND ";
$description = " Internal Notes = ";
if($_POST['formNotesIntern']) {$value = $formNotesIntern;}
else {$value = $_COOKIE['formNotesIntern'];}
break;
case 'formCreatedBy':
$str = "dnabanknumbers.Created_Who ".$tr."'".$var."' AND ";
$description = " Record Created By = ";
if($_POST['formCreatedBy']) {$value = $formCreatedBy;}
else {$value = $_COOKIE['formCreatedBy'];}
break;
case 'CrBy':
$str = "dnabanknumbers.Created_Who ".$tr."'".$var."' AND ";
$description = " Record Created By = ";
$value = $_GET['CrBy'];
break;
}
$where[$i] = $str;
$descriptionall[$i] = $description;
$valueall[$i] = $value;
}
next($parr);
}
if(empty($str))
{ echo ""; }
else {
foreach($where AS $a) $string .= $a;
$l=strlen ($string);
$max = $l-4;
$where_str = substr($string, 0, $max);
$wherestr = ' WHERE ' . $where_str;
/********************************************************************************************
* Further restriction for members of group "Guest" *
* Guests don't have access to blocked samples *
*********************************************************************************************/
if (isset($_SESSION['guest']) || $_SESSION['guest']) {
$wherestr .= ' AND dnabanknumbers.Blocked_For_Publishing = "0"'; }
/********************************************************************************************
* Further restriction for members of group "Project" *
* Project members don't have access to blocked samples that are not created by themselves *
*********************************************************************************************/
if (isset($_SESSION['project']) || $_SESSION['project']) {
$wherestr .= " AND ((dnabanknumbers.Created_Who != '".$log."' AND dnabanknumbers.Blocked_For_Publishing = '0') OR dnabanknumbers.Created_Who = '".$log."') "; }
mysqli_query($GLOBALS["___mysqli_ston"], "DROP TABLE IF EXISTS tmpDnaIDs");
/********************************************************************************************
* Sorting query *
*********************************************************************************************/
if($_REQUEST['sort'] == "DU" or $_REQUEST['sort'] == "" or $Sorting == "") { $OrderBy = " ORDER BY LENGTH(dnabanknumbers.Dna_Bank_Number),dnabanknumbers.DNA_Bank_Number "; }
if($_REQUEST['sort'] == "DD") { $OrderBy = " ORDER BY LENGTH(dnabanknumbers.Dna_Bank_Number),dnabanknumbers.DNA_Bank_Number DESC "; }
if($_REQUEST['sort'] == "SU") { $OrderBy = " ORDER BY cachecollection.UnitID_Specimen "; }
if($_REQUEST['sort'] == "SD") { $OrderBy = " ORDER BY cachecollection.UnitID_Specimen DESC "; }
if($_REQUEST['sort'] == "CU") { $OrderBy = " ORDER BY cachecollection.CollectionCode_Specimen "; }
if($_REQUEST['sort'] == "CD") { $OrderBy = " ORDER BY cachecollection.CollectionCode_Specimen DESC "; }
if($_REQUEST['sort'] == "IU") { $OrderBy = " ORDER BY cachecollection.InstitutionCode_Specimen "; }
if($_REQUEST['sort'] == "ID") { $OrderBy = " ORDER BY cachecollection.InstitutionCode_Specimen DESC "; }
if($_REQUEST['sort'] == "TU") { $OrderBy = " ORDER BY cachetaxonidentified.NameAuthorYear "; }
if($_REQUEST['sort'] == "TD") { $OrderBy = " ORDER BY cachetaxonidentified.NameAuthorYear DESC "; }
/********************************************************************************************
* building main query for hitlist ($sqlType == "Dna") *
*********************************************************************************************/
$sqlType = "Dna";
$sql = $sqlcreate .
$sql = "SELECT DISTINCT dnabanknumbers.ID_DNA FROM dnabanknumbers
LEFT JOIN cachecollection ON dnabanknumbers.FK_Cache = cachecollection.ID_Cache
LEFT JOIN cachetaxonidentified ON cachecollection.ID_Cache = cachetaxonidentified.FK_Cache
LEFT JOIN cachehighertaxa ON cachetaxonidentified.ID_TaxonIdentified = cachehighertaxa.FK_CacheTaxonidentified
LEFT JOIN amplifications ON dnabanknumbers.ID_DNA = amplifications.FK_DNA
LEFT JOIN location_stock ON location_stock.ID_Location_Stock = dnabanknumbers.FK_Location_Stock
LEFT JOIN aliquots ON dnabanknumbers.ID_DNA = aliquots.FK_DNA
LEFT JOIN request ON dnabanknumbers.ID_DNA = request.FK_DNA
LEFT JOIN labnumber ON dnabanknumbers.ID_DNA = labnumber.FK_DNA " .
$wherestr.$OrderBy.$sqllimit;
$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql);
/********************************************************************************************
* building main query for counting records *
*********************************************************************************************/
$sqlcount = "SELECT DISTINCT dnabanknumbers.ID_DNA FROM dnabanknumbers
LEFT JOIN cachecollection ON dnabanknumbers.FK_Cache = cachecollection.ID_Cache
LEFT JOIN cachetaxonidentified ON cachecollection.ID_Cache = cachetaxonidentified.FK_Cache
LEFT JOIN cachehighertaxa ON cachetaxonidentified.ID_TaxonIdentified = cachehighertaxa.FK_CacheTaxonidentified
LEFT JOIN amplifications ON dnabanknumbers.ID_DNA = amplifications.FK_DNA
LEFT JOIN location_stock ON location_stock.ID_Location_Stock = dnabanknumbers.FK_Location_Stock
LEFT JOIN aliquots ON dnabanknumbers.ID_DNA = aliquots.FK_DNA
LEFT JOIN request ON dnabanknumbers.ID_DNA = request.FK_DNA
LEFT JOIN labnumber ON dnabanknumbers.ID_DNA = labnumber.FK_DNA" .
$wherestr;
$resultcount = mysqli_query($GLOBALS["___mysqli_ston"], $sqlcount);
$sum = mysqli_num_rows($resultcount);
} } //if($formSubmitSearch)
/********************************************************************************************
* building search query *
* Code for "Show Hitlist" see line 1896 *
* Code for "Building main query for details of single record" see line 1448 *
* Code for "Show details of single record" see line 2009 *
* END *
*********************************************************************************************/
else
{
/********************************************************************************************
* Saving edited record *
* 1. insert old record into _log_-tables *
* 2. update tables with new parameters *
* 3. show details of record again *
* record is blocked for editing when another user is editing the same record at the same time*
* START *
*********************************************************************************************/
if($formSubmitSave)
{
/********************************************************************************************
* Change reference to voucher *
* check if other DNA sample are involved -> if so insert a new voucher record and *
* update dnabanknumbers; if not delete old voucher record, insert the new one and update *
* dnabanknumbers *
* START *
*********************************************************************************************/
if($formUnitID[0] != "" and $_POST['changevoucher'] == "on")
{ $sqlID_Cache = "SELECT FK_Cache FROM dnabanknumbers WHERE ID_DNA = '$ID_DNA'";
$resultID_Cache = mysqli_query($GLOBALS["___mysqli_ston"], $sqlID_Cache);
while($row = mysqli_fetch_object($resultID_Cache))
{ $IDCache = $row->FK_Cache; }
$sqlCount = "SELECT FK_Cache FROM dnabanknumbers WHERE FK_Cache = '$IDCache'";
$resultCount = mysqli_query($GLOBALS["___mysqli_ston"], $sqlCount);
$count = mysqli_num_rows($resultCount);
if($count == 1) //delete specimen cache record and insert the new one
{
include("Save_New_Specimen_Step1.php");
$sqlupdate = "UPDATE dnabanknumbers SET FK_Cache = '$IDTableCache' WHERE ID_DNA = '$ID_DNA'";
$resultupdate = mysqli_query($GLOBALS["___mysqli_ston"], $sqlupdate);
// deletion of old specimen record after entering the new one (Foreign Keys restrictions)
$sqlselect = "SELECT ID_TaxonIdentified FROM cachetaxonidentified WHERE FK_Cache = '$IDCache'";
$resultselect = mysqli_query($GLOBALS["___mysqli_ston"], $sqlselect);
while($row = mysqli_fetch_object($resultselect))
{ $ID_TaxonIdentified = $row->ID_TaxonIdentified;
$sqldelete1 = "DELETE FROM cachehighertaxa WHERE FK_CacheTaxonIdentified = '$ID_TaxonIdentified'";
$resultdelete1 = mysqli_query($GLOBALS["___mysqli_ston"], $sqldelete1);
#######################################Error Delete 1###############################################################
if(!$resultdelete1)
{ $msg = $sqldelete1."\n";
$msg .= "####Error delete 1####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
$test1 = "false1"; }
#############################################################################################################
} // while($row = mysql_fetch_object($resultselect))
$sqldelete2 = "DELETE FROM cachetaxonidentified WHERE FK_Cache = '$IDCache'";
$resultdelete2 = mysqli_query($GLOBALS["___mysqli_ston"], $sqldelete2);
#######################################Error Delete 2###############################################################
if(!$resultdelete2)
{ $msg = $sqldelete2."\n";
$msg .= "####Error delete 2####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
$test1 = "false1"; }
#############################################################################################################
$sqldelete3 = "DELETE FROM cachemultimedia WHERE FK_Cache = '$IDCache'";
$resultdelete3 = mysqli_query($GLOBALS["___mysqli_ston"], $sqldelete3);
#######################################Error Delete 3###############################################################
if(!$resultdelete3)
{ $msg = $sqldelete3."\n";
$msg .= "####Error delete 3####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
$test1 = "false1"; }
#############################################################################################################
$sqlupdate = "UPDATE dnabanknumbers SET FK_Cache = NULL WHERE ID_DNA = '$ID_DNA'";
echo $sqlupdate;
$resultupdate = mysqli_query($GLOBALS["___mysqli_ston"], $sqlupdate);
$sqldelete4 = "DELETE FROM cachecollection WHERE ID_Cache = '$IDCache'";
$resultdelete4 = mysqli_query($GLOBALS["___mysqli_ston"], $sqldelete4);
#######################################Error Delete 4###############################################################
if(!$resultdelete4)
{ $msg = $sqldelete4."\n";
$msg .= "####Error delete 4####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
$test1 = "false1"; }
#############################################################################################################
} //if($count == 1)
if($count > 1) //don't delete the specimen cache record, do insert the new one and update FK_Cache column in table dnabanknumbers
{ include("Save_New_Specimen_Step1.php");
$sqlupdate = "UPDATE dnabanknumbers SET FK_Cache = '$IDTableCache' WHERE ID_DNA = '$ID_DNA'";
$resultupdate = mysqli_query($GLOBALS["___mysqli_ston"], $sqlupdate);}
} //if($formUnitID[0] != "" and $_POST['changevoucher'] == "on")
/********************************************************************************************
* Change reference to voucher *
* END *
*********************************************************************************************/
$result2a = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT dnabanknumbers.ID_DNA, " .
" people.Name_All " .
" FROM dnabanknumbers, people " .
" WHERE dnabanknumbers.FK_Extraction_Staff = people.ID_People " .
" AND dnabanknumbers.ID_DNA = '$ID_DNA'");
while($row = mysqli_fetch_object($result2a))
{ $Extraction_Staff_old = $row->Name_All; }
$result3a = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT dnabanknumbers.ID_DNA, " .
" people.Name_All " .
" FROM dnabanknumbers, people " .
" WHERE dnabanknumbers.FK_AcquiredFrom = people.ID_People " .
" AND dnabanknumbers.ID_DNA = '$ID_DNA'");
while($row = mysqli_fetch_object($result3a))
{ $AcquiredFrom_old = $row->Name_All; }
$result4a = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT dnabanknumbers.ID_DNA, " .
" stock_fridge.Stock_Fridge, " .
" stock_rack.Stock_Rack, " .
" stock_box.Stock_Box, " .
" location_stock.Fk_Stock_Fridge, " .
" location_stock.FK_Stock_Rack, " .
" location_stock.FK_Stock_Box, " .
" location_stock.Origin_Quantity, " .
" location_stock.Rest_Quantity, " .
" location_stock.Stock_Barcode, " .
" location_stock.Stock_Position " .
" FROM dnabanknumbers " .
" LEFT JOIN location_stock ON dnabanknumbers.FK_Location_Stock = location_stock.ID_Location_Stock " .
" LEFT JOIN stock_fridge ON location_stock.FK_Stock_Fridge = stock_fridge.ID_Stock_Fridge " .
" LEFT JOIN stock_rack ON location_stock.FK_Stock_Rack = stock_rack.ID_Stock_Rack " .
" LEFT JOIN stock_box ON location_stock.FK_Stock_Box = stock_box.ID_Stock_Box " .
" WHERE dnabanknumbers.ID_DNA = '$ID_DNA'");
while($row = mysqli_fetch_object($result4a))
{ $Stock_Fridge = $row->Stock_Fridge;
$Stock_Rack = $row->Stock_Rack;
$Stock_Box = $row->Stock_Box;
$ID_Stock_Fridge_old = $row->FK_Stock_Fridge;
$ID_Stock_Rack_old = $row->FK_Stock_Rack;
$ID_Stock_Box_old = $row->FK_Stock_Box;
$Stock_Origin_old = $row->Origin_Quantity;
$Stock_Rest_old = $row->Rest_Quantity;}
$Location_Stock_old = "Fridge: " . $Stock_Fridge . " Drawer: " . $Stock_Box . " Rack: " . $Stock_Rack . " Position: " . $Stock_Position . " Barcode: " . $Stock_Barcode;
$result6a = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT dnabanknumbers.Dna_Bank_Number, " .
"dnabanknumbers.FK_Cache, " .
"dnabanknumbers.Extraction_Date, " .
"dnabanknumbers.NoExtractDate, " .
"dnabanknumbers.Quality_Check_Date, " .
"dnabanknumbers.Concentration, " .
"dnabanknumbers.Absorbance280, " .
"dnabanknumbers.Absorbance230, " .
"dnabanknumbers.Stock_Gone, " .
"dnabanknumbers.Source_Gone, " .
"dnabanknumbers.Notes, " .
"dnabanknumbers.Notes_Intern, " .
"dnabanknumbers.Blocked_Until, " .
"dnabanknumbers.Blocked_For_Loaning, " .
"dnabanknumbers.Blocked_For_Publishing, " .
"dnabanknumbers.Loan_Conditions, " .
"dnabanknumbers.Backup_Aliquot, " .
"dnabanknumbers.FK_Type, " .
"dnabanknumbers.FK_Tissue, " .
"dnabanknumbers.FK_Relation, " .
"dnabanknumbers.FK_Preservation, " .
"dnabanknumbers.FK_Extraction_Method, " .
"dnabanknumbers.FK_Purification_Method, " .
"dnabanknumbers.FK_Extraction_Staff, " .
"dnabanknumbers.FK_AcquiredFrom, " .
"dnabanknumbers.FK_Location_Stock, " .
"dnabanknumbers.GUID, " .
"dnabanknumbers.FK_GelImage, " .
"dnatype.Type, " .
"tissue.Tissue, " .
"relation.Relation, " .
"preservations.Preservation, " .
"methods.Method AS Extraction_Method " .
// "purification.Method AS Purification_Method, " .
"FROM dnabanknumbers " .
"LEFT JOIN dnatype ON dnabanknumbers.FK_Type = dnatype.ID_Type " .
"LEFT JOIN tissue ON dnabanknumbers.FK_Tissue = tissue.ID_Tissue " .
"LEFT JOIN relation ON dnabanknumbers.FK_Relation = relation.ID_Relation " .
"LEFT JOIN preservations ON dnabanknumbers.FK_Preservation = preservations.ID_Preservation " .
"LEFT JOIN methods ON dnabanknumbers.FK_Extraction_Method = methods.ID_Method " .
// "LEFT JOIN purification ON dnabanknumbers.FK_Purification_Method = purification.ID_Purification_Method " .
"WHERE dnabanknumbers.ID_DNA = '$ID_DNA'");
while($row = mysqli_fetch_object($result6a))
{ $Dna_Bank_Number_old = $row->Dna_Bank_Number;
$ID_Cache_old = $row->FK_Cache;
$Extraction_Date_old = $row->Extraction_Date;
$NoExtractDate_old = $row->NoExtractDate;
$Check_Date_old = $row->Quality_Check_Date;
$Concentration_old = $row->Concentration;
$Absorbance280_old = $row->Absorbance280;
$Absorbance230_old = $row->Absorbance230;
$Stock_Gone_old = $row->Stock_Gone;
$Source_Gone_old = $row->Source_Gone;
$Backup_Aliquot_old = $row->Backup_Aliquot;
$Notes_old = $row->Notes;
$Notes_Intern_old = $row->Notes_Intern;
$ID_GelImage_old = $row->FK_GelImage;
$Block_Until_old = $row->Block_Until;
$BlockForLoan_old = $row->Blocked_For_Loaning;
$BlockForPublish_old = $row->Blocked_For_Publishing;
$LoanConditions_old = $row->Loan_Conditions;
$Type_old = $row->Type;
$ID_Type_old = $row->FK_Type;
$Tissue_old = $row->Tissue;
$ID_Tissue_old = $row->FK_Tissue;
$RelationDNA_Voucher_old = $row->Relation;
$ID_RelationDNA_Voucher_old = $row->FK_Relation;
$Preservation_old = $row->Preservation;
$ID_Preservation_old = $row->FK_Preservation;
$Extraction_Method_old = $row->Extraction_Method;
$ID_Extraction_Method_old = $row->FK_Extraction_Method;
$Purification_Method_old = $row->Purification_Method;
$ID_Extraction_Staff_old = $row->FK_Extraction_Staff;
$ID_Purification_Method_old = $row->FK_Purification_Method;
$Degradation_old = $row->Degradation;
$ID_Degradation_old = $row->FK_Degradation;
$ID_AcquiredFrom_old = $row->FK_AcquiredFrom;
$ID_Location_Stock_old = $row->FK_Location_Stock;
$GUID_old = $row->GUID; }
/*
if($_POST['formExtractionDate'] == "YYYY-MM-DD" or $_POST['formExtractionDate'] == "" or $_POST['formExtractionDate'] == "0000-00-00") {unset($formExtractionDate);}
else { $ExtractionDate = $_POST['formExtractionDate']; }
if($_POST['formCheckDate'] == "YYYY-MM-DD" or $_POST['formCheckDate'] == "" or $_POST['formCheckDate'] == "0000-00-00") {unset($formCheckDate);}
else { $CheckDate = $_POST['formCheckDate']; }
if($_POST['formBlockDate'] == "YYYY-MM-DD" or $_POST['formBlockDate'] == "" or $_POST['formBlockDate'] == "0000-00-00") {unset($formBlockDate);}
else { $BlockDate = $_POST['formBlockDate']; }
if($ExtractionDate == "YYYY-MM-DD" or $ExtractionDate == "" or $ExtractionDate == "NULL" or $ExtractionDate == "0000-00-00") { $ExtractionDate = "NULL"; }
else { $date = $ExtractionDate;
if (!valiDate($date)) {
$Validation = "FALSE";
echo 'Extraction date incorrect! '; }
else { $ExtractionDate = "'".$ExtractionDate."'"; } }
if($CheckDate == "YYYY-MM-DD" or $CheckDate == "" or $CheckDate == "NULL" or $CheckDate == "0000-00-00") { $CheckDate = "NULL"; }
else { $date = $CheckDate;
if (!valiDate($date)) {
$Validation = "FALSE";
echo 'Quality check date incorrect! '; }
else { $CheckDate = "'".$CheckDate."'"; } }
if($BlockDate == "YYYY-MM-DD" or $BlockDate == "" or $BlockDate == "NULL" or $BlockDate == "0000-00-00") { $BlockDate = "NULL"; }
else { $date = $BlockDate;
if (!valiDate($date)) {
$Validation = "FALSE";
echo 'Block date incorrect! '; }
else { $BlockDate = "'".$BlockDate."'"; } } */
/**
* include script to mask data before inserting, e.g. add slashes before additional characters etc.
*/
include("../input/addslashes_dnabanknumbers.php");
if(!empty($formAmplificationID))
{
foreach ($formAmplificationID as $index => $AmplificationIDTest)
{
$LinkTest = $formLink[$index];
$GenBankNumberTest = $formGenBankNo[$index];
$GeneticLocusIDTest = $formGeneticLocus[$index];
$resultAmplification = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT dnabanknumbers.ID_DNA, " .
" amplifications.GenBankNumber AS GenBankNumber, " .
" amplifications.Link AS Link, " .
" amplifications.FK_GeneticLocus, " .
" geneticlocus.GeneticLocus AS GeneticLocus " .
" FROM dnabanknumbers " .
" LEFT JOIN amplifications ON dnabanknumbers.ID_DNA = amplifications.FK_DNA " .
" LEFT JOIN geneticlocus ON amplifications.FK_GeneticLocus = geneticlocus.ID_GeneticLocus " .
" WHERE amplifications.ID_Amplification = '$AmplificationIDTest' " .
" ORDER BY amplifications.ID_Amplification");
if(!empty($AmplificationIDTest))
{
while($row = mysqli_fetch_object($resultAmplification))
{
$GenBankNumber_old = $row->GenBankNumber;
$Link_old = $row->Link;
$GeneticLocus_old = $row->GeneticLocus;
if ($row->Link != $LinkTest or $row->GenBankNumber != $GenBankNumberTest or $row->FK_GeneticLocus != $GeneticLocusIDTest)
{
$sql1 = "INSERT INTO _log_amplifications (ID_Amplification, ID_DNA, GeneticLocus, GenBankNumber, Link, Update_Created_Who, Source_Created_Who, Source_Created_When) " .
" (SELECT amplifications.ID_Amplification, " .
"amplifications.FK_DNA, " .
"'$GeneticLocus_old', " .
"'$GenBankNumber_old', " .
"'$Link_old', " .
"'$log', " .
"amplifications.Created_Who, " .
"amplifications.Created_When " .
"FROM amplifications " .
"WHERE amplifications.ID_Amplification = '$AmplificationIDTest')";
$result1 = mysqli_query($GLOBALS["___mysqli_ston"], $sql1);
#######################################Error 1###############################################################
if(!$result1)
{ $msg = $sql1."\n";
$msg .= "####Error 1####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
$test1 = "false1"; }
#############################################################################################################
if ($result1)
{
$sql2 = "UPDATE amplifications SET GenBankNumber = '$GenBankNumberTest', " .
"Link = '$LinkTest', " .
"ID_GeneticLocus = '$GeneticLocusIDTest', " .
"Update_Who = '$log', " .
"Update_When = '$Current_Date' " .
"WHERE amplifications.ID_Amplification = '$AmplificationIDTest'";
$result2 = mysqli_query($GLOBALS["___mysqli_ston"], $sql2);
#######################################Error 2###############################################################
if(!$result2)
{ $msg = $sql2."\n";
$msg .= "####Error 2####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
$test1 = "false2"; }
#############################################################################################################
}
}
} //while($row = mysql_fetch_object($resultAmplification))
}
} //foreach End $formGenBankID
}
if($_POST['formRestQuantity'] != "") {
$QuantityAliquots = array_sum($_POST['formRestQuantity']); }
if($formLocationAliquotsID != "") {
foreach ($formLocationAliquotsID as $index => $AliquotsID)
{
$AliquotsFridge = $formAliquotsFridge[$index];
$AliquotsRack = $formAliquotsRack[$index];
$AliquotsBox = $formAliquotsBox[$index];
$RestQuantity = $formRestQuantity[$index];
$SourceQuantity = $formSourceQuantity[$index];
$Positions = $_POST['PositionAliquot'][$index];
$Barcodes = $_POST['BarcodeAliquot'][$index];
$resultAliquots = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT dnabanknumbers.ID_DNA, " .
" aliquots.Aliquot_Number, " .
" aliquots_fridge.Aliquots_Fridge, " .
" aliquots.FK_Aliquots_Fridge, " .
" aliquots_rack.Aliquots_Rack, " .
" aliquots.FK_Aliquots_Rack, " .
" aliquots_box.Aliquots_Box, " .
" aliquots.Rest_Quantity, " .
" aliquots.Origin_Quantity, " .
" aliquots.FK_Aliquots_Box, " .
" aliquots.Aliquot_Barcode, " .
" aliquots.Aliquot_Position " .
" FROM dnabanknumbers " .
" LEFT JOIN aliquots ON dnabanknumbers.ID_DNA = aliquots.FK_DNA " .
" LEFT JOIN aliquots_fridge ON aliquots.FK_Aliquots_Fridge = aliquots_fridge.ID_Aliquots_Fridge " .
" LEFT JOIN aliquots_rack ON aliquots.FK_Aliquots_Rack = aliquots_rack.ID_Aliquots_Rack " .
" LEFT JOIN aliquots_box ON aliquots.FK_Aliquots_Box = aliquots_box.ID_Aliquots_Box " .
" WHERE aliquots.ID_Aliquots = '$AliquotsID' " .
" ORDER BY aliquots.ID_Aliquots");
while($row = mysqli_fetch_object($resultAliquots))
{
$Aliquot_Number_old = $row->Aliquot_Number;
$Aliquots_Fridge_old = $row->Aliquots_Fridge;
$Aliquots_Rack_old = $row->Aliquots_Rack;
$Aliquots_Box_old = $row->Aliquots_Box;
$Origin_Quantity_old = $row->Origin_Quantity;
$Rest_Quantity_old = $row->Rest_Quantity;
$Barcode_old = $row->Aliquot_Barcode;
$Position_old = $row->Aliquot_Position;
if ($row->FK_Aliquots_Fridge != $AliquotsFridge or $row->FK_Aliquots_Rack != $AliquotsRack or $row->FK_Aliquots_Box != $AliquotsBox or $Rest_Quantity_old != $RestQuantity or $Position_old != $Positions)
{
$sql3 = "INSERT INTO _log_aliquots (ID_Aliquots, FK_DNA, Aliquots_Box, Aliquots_Rack, Aliquots_Fridge, Aliquot_Number, Origin_Quantity, Rest_Quantity, Aliquot_Barcode, Aliquot_Position, Update_Created_Who, Source_Created_Who, Source_Created_When) " .
" (SELECT aliquots.ID_Aliquots, " .
"aliquots.FK_DNA, " .
"'$Aliquots_Box_old', " .
"'$Aliquots_Rack_old', " .
"'$Aliquots_Fridge_old', " .
"aliquots.Aliquot_Number, " .
"aliquots.Origin_Quantity, " .
"aliquots.Rest_Quantity, " .
"'$Barcode_old', " .
"'$Position_old', " .
"'$log', " .
"aliquots.Created_Who, " .
"aliquots.Created_When " .
"FROM aliquots " .
"WHERE aliquots.ID_Aliquots = '$AliquotsID')";
$result3 = mysqli_query($GLOBALS["___mysqli_ston"], $sql3);
#######################################Error 3###############################################################
if(!$result3)
{ $msg = $sql3."\n";
$msg .= "####Error 3####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
$test1 = "false1"; }
#############################################################################################################
if ($result3)
{
$sql4 = "UPDATE aliquots SET FK_Aliquots_Fridge = $AliquotsFridge, " .
"FK_Aliquots_Rack = $AliquotsRack, " .
"FK_Aliquots_Box = $AliquotsBox, " .
"Origin_Quantity = '$SourceQuantity', " .
"Rest_Quantity = '$RestQuantity', " .
"Aliquot_Position = '$Positions', " .
"Aliquot_Barcode = '$Barcodes', " .
"Update_Who = '$log', " .
"Update_When = '$Current_Date' " .
"WHERE aliquots.ID_Aliquots = '$AliquotsID'";
$result4 = mysqli_query($GLOBALS["___mysqli_ston"], $sql4);
#######################################Error 4###############################################################
if(!$result4)
{ $msg = $sql4."\n";
$msg .= "####Error 4####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
$test1 = "false2"; }
#############################################################################################################
}
}
} //while($row = mysql_fetch_object($resultAliquots))
}//foreach End $formLocationAliquotsID
} //if(isset($formLocationAliquotsID)
if(empty($formLocationAliquotsID) and $formAliquotsRack != "")
{
$AliquotNumber = $formDnaBankNumber.'-A';
$sql3a = "INSERT INTO aliquots (FK_DNA, FK_Aliquots_Box, FK_Aliquots_Rack, FK_Aliquots_Fridge, Origin_Quantity, Rest_Quantity, Aliquot_Number, Aliquot_Barcode, Aliquot_Position, Created_Who) " .
" VALUES('$ID_DNA',$AliquotsBox,$AliquotsRack,$AliquotsFridge,'$SourceQuantity','$RestQuantity','$AliquotNumber','$Barcodes','$Positions','$log')";
$result3a = mysqli_query($GLOBALS["___mysqli_ston"], $sql3a);
#######################################Error 3a/3b##############################################################
if(!$result3a)
{ $msg = $sql3a."\n";
$msg .= "####Error 3a####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
$test1 = "false1"; }
#############################################################################################################
}
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")
$BlockLoan = "1";
if ($b == "BlockPublish")
$BlockPublish = "1";
if ($b == "Aliquot")
$Aliquot = "1";
if ($b == "Backup")
$Backup = "1";
}
}
if($formGelFileURI) {
$sqlcheckgel = "SELECT * FROM gelimages where ID_Images = '$ID_GelImage_old'";
$resultcheckgel = mysqli_query($GLOBALS["___mysqli_ston"], $sqlcheckgel);
if(mysqli_num_rows($resultcheckgel) > 0)
{ while($row=mysqli_fetch_object($resultcheckgel))
{ $IDGel = $row->ID_Images; }
$sqlupdategel = "UPDATE gelimages SET FileURI = '$formGelFileURI', GelRemarks = '$formGelRemarks', GelVoltage = '$formGelVoltage', " .
" GelConcentration = '$formGelConcentration', GelDuration = '$formGelDuration', GelLadder = '$formGelLadder', Updated_Who = '$log', Updated_When = '$Current_Date' WHERE ID_Images = '$ID_GelImage_old'";
$resultupdategel = mysqli_query($GLOBALS["___mysqli_ston"], $sqlupdategel);
} //if(mysql_num_rows($resultcheck) > 0)
else {
$sqlinsertgel = "INSERT INTO gelimages (FileURI, GelRemarks, GelVoltage, GelConcentration, GelDuration, GelLadder, Created_Who) " .
"VALUES ('$formGelFileURI', '$formGelRemarks', '$formGelVoltage', '$formGelConcentration', '$formGelDuration', '$formGelLadder', '$log')";
$resultinsertgel = mysqli_query($GLOBALS["___mysqli_ston"], $sqlinsertgel);
$ID_GelImage_New = ((is_null($___mysqli_res = mysqli_insert_id($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);
$sqlupdatedna = "UPDATE dnabanknumbers SET FK_GelImage = '$ID_GelImage_New', " .
"Update_Who = '$log', " .
"Update_When = '$Current_Date' " .
"WHERE dnabanknumbers.ID_DNA = '$ID_DNA'";
$resultdna = mysqli_query($GLOBALS["___mysqli_ston"], $sqlupdatedna);
}
}
if($formGenBankNumberA)
{
$sql = "INSERT INTO amplifications (FK_DNA, ID_GeneticLocus, GenBankNumber, Link, Created_Who)" .
"VALUES ('$ID_DNA','$formGeneticLocusA','$formGenBankNumberA','$formGenBankLinkA','$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, ID_GeneticLocus, GenBankNumber, Link, Created_Who)" .
"VALUES ('$ID_DNA','$formGeneticLocusB','$formGenBankNumberB','$formGenBankLinkB','$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, ID_GeneticLocus, GenBankNumber, Link, Created_Who)" .
"VALUES ('$ID_DNA','$formGeneticLocusC','$formGenBankNumberC','$formGenBankLinkC','$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, ID_GeneticLocus, GenBankNumber, Link, Created_Who)" .
"VALUES ('$ID_DNA','$formGeneticLocusD','$formGenBankNumberD','$formGenBankLinkD','$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']))
{
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];
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 {
$resultLastAliquotsNumber = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT Aliquot_Number FROM aliquots WHERE FK_DNA = '$ID_DNA' ORDER BY Aliquot_Number DESC LIMIT 0,1");
if(!$resultLastAliquotsNumber)
{ $letter = A;
$lettercount = $letter++;
$AliquotNumber = $formDnaBankNumber.'-'.$lettercount;
}
else {
while($row = mysqli_fetch_object($resultLastAliquotsNumber))
{
$Number = $row->Aliquot_Number;
$array = explode("-",$Number);
$letter = $array[1]; }
$lettercount = $letter++;
$AliquotNumber = $formDnaBankNumber.'-'.$letter++;
$sql10 = "INSERT INTO aliquots (FK_DNA, FK_Aliquots_Fridge, FK_Aliquots_Rack, FK_Aliquots_Box,
Aliquot_Number, Origin_Quantity, Rest_Quantity, Aliquot_Barcode, Aliquot_Position, Created_Who) " .
"VALUES ('$ID_DNA','$value','$rack','$box','$AliquotNumber','$SourceQuantity','$SourceQuantity','$Barcode','$Position','$log')";
$result10 = mysqli_query($GLOBALS["___mysqli_ston"], $sql10);
#######################################Error 10###############################################################
if(!$result10)
{ $msg = $sql10."\n";
$msg .= "####Error 10####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
$test1 = "false2"; }
#############################################################################################################
} } }
}
} //foreach ($_POST['x'] as $v => $value)
$sql11 = "INSERT INTO _log_dnabanknumbers (ID_DNA, FK_Cache, DNA_Bank_Number, Extraction_Date, NoExtractDate, Quality_Check_Date, Concentration, Absorbance280, Absorbance230, Quantity_Aliquots, Stock_Gone, Source_Gone, Notes, Blocked_Until, Blocked_For_Loaning, Blocked_For_Publishing, Loan_Conditions, Number_Aliquots, Source_Created_When, Source_Created_Who, Type, Tissue, Preservation, Purification, Extraction_Method, RelationDNA_Voucher, Extraction_Staff, AcquiredFrom, Update_Created_Who, Location_Stock, Backup_Aliquot, GUID) " .
"(SELECT dnabanknumbers.ID_DNA, " .
"'$ID_Cache_old', " .
"'$Dna_Bank_Number_old', " .
"'$Extraction_Date_old', " .
"'$NoExtractDate_old', " .
"'$Check_Date_old', " .
"'$Concentration_old', " .
"'$Absorbance280_old', " .
"'$Absorbance230_old', " .
"'$Quantity_Aliquots_old', " .
"'$Stock_Gone_old', " .
"'$Source_Gone_old', " .
"'$Notes_old', " .
"'$Blocked_Until_old', " .
"'$BlockForLoan_old', " .
"'$BlockForPublish_old', " .
"'$LoanConditions_old', " .
"'$Number_Aliquots_old', " .
"dnabanknumbers.Created_When, " .
"dnabanknumbers.Created_Who, " .
"'$Type_old', " .
"'$Tissue_old', " .
"'$Preservation_old', " .
"'$Purification_Method_old', " .
"'$Extraction_Method_old', " .
"'$RelationDNA_Voucher_old', " .
"'$Extraction_Staff_old', " .
"'$AcquiredFrom_old', " .
"'$log', " .
"'$Location_Stock_old', " .
"'$Backup_Aliquot_old', " .
"'$GUID_old' " .
"FROM dnabanknumbers " .
"WHERE dnabanknumbers.ID_DNA = '$ID_DNA')";
$result11 = mysqli_query($GLOBALS["___mysqli_ston"], $sql11);
$IDDnaLog = ((is_null($___mysqli_res = mysqli_insert_id($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);
#######################################Error 11###############################################################
if(!$result11)
{ $msg = $sql11."\n";
$msg .= "####Error 11####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
$test1 = "false1"; }
#############################################################################################################
if ($result11)
{
if($formLabNumbers != $hiddenLabNumbers) {
$deleteLabNumber = "DELETE FROM labnumber where FK_DNA = '$ID_DNA'";
$resultdeletelabnumber = mysqli_query($GLOBALS["___mysqli_ston"], $deleteLabNumber);
if($formLabNumbers != "" or isset($formLabNumbers)){
$labNumberArray = explode(";", $formLabNumbers);
while($i = each($labNumberArray))
{
$labNumber = trim(addslashes($i[1]));
$sqllabnumber = "INSERT INTO labnumber (FK_DNA, LabNumber, Created_Who) VALUES ('$ID_DNA', '$labNumber', '$log')";
$resultlabnumber = mysqli_query($GLOBALS["___mysqli_ston"], $sqllabnumber);
}
#######################################Error 2###############################################################
if(!$resultlabnumber and $formLabNumber)
{ $msg = $sqllabnumber."\n";
$msg .= "####Error Lab Number####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
/**
* calling Error message
*/
include ("../config/Errorreport.php"); }
#############################################################################################################
}
}
$sql12 = "UPDATE dnabanknumbers SET DNA_Bank_Number = '$sqlDnaBankNumber', " .
"FK_Cache = '$ID_Cache_old', " .
"Extraction_Date = $ExtractionDate, " .
"NoExtractDate = '$formNoExtractDate', " .
"Quality_Check_Date = $CheckDate, " .
"Concentration = $sqlConcentration, " .
"Absorbance280 = $sqlAbsorbance280, " .
"Absorbance230 = $sqlAbsorbance230, " .
"Notes = '$sqlNotes', " .
"Notes_Intern = '$sqlNotesIntern', " .
"FK_Type = $formType, " .
"FK_Tissue = $formTissue, " .
"FK_Relation = $formRelation, " .
"FK_Preservation = $formPreservation, " .
"FK_Extraction_Method = $formExtractionMethod, " .
"FK_Extraction_Staff = $formExtractionStaff, " .
"FK_Purification_Method = $formPurificationMethod, " .
"FK_AcquiredFrom = $formAcquiredFrom, " .
"Stock_Gone = '$StockGone', " .
"Source_Gone = '$SourceGone', " .
"Blocked_For_Loaning = '$BlockLoan', " .
"Blocked_For_Publishing = '$BlockPublish', " .
"Loan_Conditions = '$sqlLoanConditions', " .
"Blocked_Until = $BlockDate, " .
"Backup_Aliquot = '$Backup', " .
"Update_Who = '$log', " .
"Update_When = '$Current_Date' " .
"WHERE dnabanknumbers.ID_DNA = '$ID_DNA'";
$result12 = mysqli_query($GLOBALS["___mysqli_ston"], $sql12);
if(empty($ID_Stock_Fridge_old) or empty($ID_Stock_Rack_old) or empty($ID_Stock_Box_old))
{
$sql13a = "INSERT INTO location_stock (FK_Stock_Fridge, FK_Stock_Rack, FK_Stock_Box, Origin_Quantity, Rest_Quantity, Created_Who) " .
"VALUES ($formStockFridge,$formStockRack,$formStockBox,'$formStockQuantity','$formStockRest','$log')";
$result13a = mysqli_query($GLOBALS["___mysqli_ston"], $sql13a);
$ID_Location_Stock_New = ((is_null($___mysqli_res = mysqli_insert_id($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);
$sql13b = "UPDATE dnabanknumbers SET FK_Location_Stock = '$ID_Location_Stock_New' " .
"WHERE dnabanknumbers.ID_DNA = '$ID_DNA'";
$result13b = mysqli_query($GLOBALS["___mysqli_ston"], $sql13b);
#######################################Error 13a/13b###############################################################
if(!$result13a or !$result13b)
{ $msg = $sql13a."\n";
$msg .= $sql13b. "\n";
$msg .= "####Error 13a/13b####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
$test1 = "false2"; }
}
#############################################################################################################
$sql13 = "UPDATE location_stock SET FK_Stock_Fridge = $formStockFridge, " .
"FK_Stock_Rack = $formStockRack, " .
"FK_Stock_Box = $formStockBox, " .
"Origin_Quantity = '$formStockQuantity', " .
"Rest_Quantity = '$formStockRest', " .
"Stock_Position = '$formPositionStock', " .
"Update_Who = '$log', " .
"Update_When = '$Current_Date' " .
"WHERE location_stock.ID_Location_Stock = '$ID_Location_Stock_old'";
$result13 = mysqli_query($GLOBALS["___mysqli_ston"], $sql13);
#######################################Error 12/13###############################################################
if(!$result12 or !$result13)
{ $msg = $sql12."\n";
$msg .= $sql13. "\n";
$msg .= "####Error 12/13####";
if($debug == '1') echo $msg;
trigger_error($msg, E_USER_ERROR);
$test1 = "false2"; }
#############################################################################################################
/********************************************************************************************
* Creating main query for details of single record after saving edits *
*********************************************************************************************/
mysqli_query($GLOBALS["___mysqli_ston"], "DROP TABLE IF EXISTS tmpDnaIDs");
$sqlType = "Detail";
$sql = $sqlcreate .
$sql = "SELECT DISTINCT dnabanknumbers.ID_DNA FROM dnabanknumbers
LEFT JOIN cachecollection ON dnabanknumbers.FK_Cache = cachecollection.ID_Cache
LEFT JOIN cachetaxonidentified ON cachecollection.ID_Cache = cachetaxonidentified.FK_Cache
LEFT JOIN cachehighertaxa ON cachetaxonidentified.ID_TaxonIdentified = cachehighertaxa.FK_CacheTaxonidentified
LEFT JOIN amplifications ON dnabanknumbers.ID_DNA = amplifications.FK_DNA
LEFT JOIN location_stock ON location_stock.ID_Location_Stock = dnabanknumbers.FK_Location_Stock
LEFT JOIN aliquots ON dnabanknumbers.ID_DNA = aliquots.FK_DNA
LEFT JOIN request ON dnabanknumbers.ID_DNA = request.FK_DNA " .
"WHERE dnabanknumbers.ID_DNA = '$ID_DNA' ";
if (isset($_SESSION['guest']) || $_SESSION['guest']) {
$sql .= " AND dnabanknumbers.Blocked_For_Publishing = '0' "; }
if (isset($_SESSION['project']) || $_SESSION['project']) {
$sql .= " AND ((dnabanknumbers.Created_Who != '".$log."' AND dnabanknumbers.Blocked_For_Publishing = '0') OR dnabanknumbers.Created_Who = '".$log."') "; }
$sql .= $sqllimit;
}
} // if (isset($_REQUEST['Aliquot']))
/********************************************************************************************
* Creating main query for details of single record *
* START *
*********************************************************************************************/
else {
mysqli_query($GLOBALS["___mysqli_ston"], "DROP TABLE IF EXISTS tmpDnaIDs");
$sqlType = "Detail";
$sql = $sqlcreate .
$sql = "SELECT DISTINCT dnabanknumbers.ID_DNA FROM dnabanknumbers
LEFT JOIN cachecollection ON dnabanknumbers.FK_Cache = cachecollection.ID_Cache
LEFT JOIN cachetaxonidentified ON cachecollection.ID_Cache = cachetaxonidentified.FK_Cache
LEFT JOIN cachehighertaxa ON cachetaxonidentified.ID_TaxonIdentified = cachehighertaxa.FK_CacheTaxonidentified
LEFT JOIN amplifications ON dnabanknumbers.ID_DNA = amplifications.FK_DNA
LEFT JOIN location_stock ON location_stock.ID_Location_Stock = dnabanknumbers.FK_Location_Stock
LEFT JOIN aliquots ON dnabanknumbers.ID_DNA = aliquots.FK_DNA
LEFT JOIN request ON dnabanknumbers.ID_DNA = request.FK_DNA " .
"WHERE dnabanknumbers.ID_DNA = '$ID_DNA' ";
if (isset($_SESSION['guest']) || $_SESSION['guest']) {
$sql .= " AND dnabanknumbers.Blocked_For_Publishing = '0' "; }
if (isset($_SESSION['project']) || $_SESSION['project']) {
$sql .= " AND ((dnabanknumbers.Created_Who != '".$log."' AND dnabanknumbers.Blocked_For_Publishing = '0') OR dnabanknumbers.Created_Who = '".$log."') "; }
$sql .= $sqllimit;
}
/********************************************************************************************
* Creating main query for details of single record *
* END *
*********************************************************************************************/
} // if(!$formSubmitUpdate and !$formSubmitVerify)
/********************************************************************************************
* Show data *
* START *
*********************************************************************************************/
$Dnacount=0;
if(!empty($sql))
{
/********************************************************************************************
* just in case it is still here: drop tmpDnaIDs *
********************************************************************************************/
mysqli_query($GLOBALS["___mysqli_ston"], "DROP TABLE IF EXISTS tmpDnaIDs");
mysqli_query($GLOBALS["___mysqli_ston"], $sql);
if(!mysqli_affected_rows($GLOBALS["___mysqli_ston"]))
{
echo "New Search. | ";
if (isset($_SESSION['guest']) || $_SESSION['guest'] || isset($_SESSION['project']) || $_SESSION['project']) {
echo "Sorry, you don't have permission to see this record. | "; }
/********************************************************************************************
* Further message for guests and project members when query was wrong *
*********************************************************************************************/
else { //user has access to data
/********************************************************************************************
* Search key string *
*********************************************************************************************/
echo " |