=";
$st = "<=";
if($_REQUEST['hitlist'] == "true")
{$parr = $_COOKIE;}
if($_REQUEST['hitlist'] == "")
{$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")
{
switch (key($parr))
{
case 'formDnaBankNumber':
$str = "(dnabanknumbers.DNA_Bank_Number = '' OR dnabanknumbers.DNA_Bank_Number IS NULL) AND ";
$description = " DNA Extraction No = ";
$value = "empty";
break;
case 'formRelation':
$str = "(dnabanknumbers.FK_Relation = '0' OR dnabanknumbers.FK_Relation = '' OR dnabanknumbers.FK_Relation IS NULL) AND ";
$description = " Relation to Voucher = ";
$value = "empty";
break;
case 'formType':
$str = "(dnabanknumbers.FK_Type = '0' OR dnabanknumbers.FK_Type = '' OR dnabanknumbers.FK_Type IS NULL) AND ";
$description = " DNA Type = ";
$value = "empty";
break;
case 'formPreservation':
$str = "(dnabanknumbers.FK_Preservation = '0' OR dnabanknumbers.FK_Preservation = '' OR dnabanknumbers.FK_Preservation IS NULL) AND ";
$description = " Preservation = ";
$value = "empty";
break;
case 'formTissue':
$str = "(dnabanknumbers.FK_Tissue = '0' OR dnabanknumbers.FK_Tissue = '' OR dnabanknumbers.FK_Tissue IS NULL) AND ";
$description = " Tissue = ";
$value = "empty";
break;
case 'formExtractionMethod':
$str = "(dnabanknumbers.FK_Extraction_Method = '0' OR dnabanknumbers.FK_Extraction_Method = '' OR dnabanknumbers.FK_Extraction_Method IS NULL) AND ";
$description = " Extraction Method = ";
$value = "empty";
break;
case 'formExtractionDate':
$str = "(dnabanknumbers.Extraction_Date IS NULL OR dnabanknumbers.Extraction_Date = '') AND ";
$description = " Extraction Date = ";
$value = "empty";
break;
case 'formExtractionStaff':
$str = "(dnabanknumbers.FK_Extraction_Staff = '0' OR dnabanknumbers.FK_Extraction_Staff = '' OR dnabanknumbers.FK_Extraction_Staff IS NULL) AND ";
$description = " Extraction Staff = ";
$value = "empty";
break;
case 'formPurificationMethod':
$str = "(dnabanknumbers.FK_Purification_Method = '0' OR dnabanknumbers.FK_Purification_Method = '' OR dnabanknumbers.FK_Purification_Method IS NULL) AND";
$description = " Purification Method = ";
$value = "empty";
break;
case 'formAbsorbance280':
$str = "(dnabanknumbers.Absorbance280 IS NULL OR dnabanknumbers.Absorbance280 = '') AND ";
$description = " Absorbance 280/260 = ";
$value = "empty";
break;
case 'formAbsorbance230':
$str = "(dnabanknumbers.Absorbance230 IS NULL OR dnabanknumbers.Absorbance230 = '') AND ";
$description = " Absorbance 230/260 = ";
$value = "empty";
break;
case 'formConcentration':
$str = "(dnabanknumbers.Concentration IS NULL OR dnabanknumbers.Concentration = '') AND ";
$description = " Concentration = ";
$value = "empty";
break;
case 'formCheckDate':
$str = "(dnabanknumbers.Quality_Check_Date IS NULL OR dnabanknumbers.Quality_Check_Date = '') AND ";
$description = " Quality Check Date = ";
$value = "empty";
break;
case 'formStock':
$str = "(dnabanknumbers.FK_Location_Stock = '0' OR dnabanknumbers.FK_Location_Stock = '' OR dnabanknumbers.FK_Location_Stock IS NULL) AND ";
$description = " Stock Fridge = ";
$value = "empty";
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.Block_General = "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.Block_General = '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 " .
$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 " .
$wherestr;
//echo $sqlcount;
$resultcount = mysqli_query($GLOBALS["___mysqli_ston"], $sqlcount);
$sum = mysqli_num_rows($resultcount);
} } //if($formSubmitSearch)
/********************************************************************************************
* building search query *
* Code for "Show Hitlist" see line 1596 *
* Code for "Building main query for details of single record" see line 1148 *
* Code for "Show details of single record" see line 1709 *
* 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 locked 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))
{ $ID_Cache = $row->ID_Cache; }
$count = mysqli_num_rows($resultID_Cache);
if($count == 1) //delete specimen cache record and insert the new one
{
$sqlselect = "SELECT ID_TaxonIdentified FROM cachetaxonidentified WHERE FK_Cache = '$ID_Cache'";
$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 = '$ID_Cache'";
$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 = '$ID_Cache'";
$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"; }
#############################################################################################################
$sqldelete4 = "DELETE FROM cachecollection WHERE ID_Cache = '$ID_Cache'";
$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"; }
#############################################################################################################
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($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))
{ $Provided_By_People_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.Block_Until, " .
"dnabanknumbers.Block_General, " .
"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, " .
"dnatype.Type, " .
"tissue.Tissue, " .
"relation.Relation, " .
"preservation.Preservation, " .
"methods.Method AS Extraction_Method, " .
"purification.Method AS Purification_Method, " .
"degradation.Degradation " .
"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 preservation ON dnabanknumbers.FK_Preservation = preservation.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;
$Block_Until_old = $row->Block_Until;
$BlockGeneral_old = $row->Block_General;
$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_Provided_By_People_old = $row->FK_AcquiredFrom;
$ID_Location_Stock_old = $row->FK_Location_Stock; }
/**
* 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', " .
"FK_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, ID_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 (isset($_REQUEST['c']))
{
reset($_REQUEST['c']);
foreach ($_REQUEST['c'] as $b)
{
if ($b == "SourceGone")
$SourceGone = "1";
if ($b == "StockGone")
$StockGone = "1";
if ($b == "BlockGeneral")
$BlockGeneral = "1";
if ($b == "Aliquot")
$Aliquot = "1";
if ($b == "Backup")
$Backup = "1";
}
}
if($formGenBankNumberA)
{
$sql = "INSERT INTO amplifications (FK_DNA, FK_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, FK_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, FK_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, FK_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, Block_Until, Block_General, Number_Aliquots, Source_Created_When, Source_Created_Who, Type, Tissue, Preservation, Purification, Extraction_Method, Degradation, RelationDNA_Voucher, Extraction_Staff, Provided_By_People, Update_Created_Who, Location_Stock, Backup_Aliquot) " .
"(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', " .
"'$Block_Until_old', " .
"'$BlockGeneral_old', " .
"'$Number_Aliquots_old', " .
"dnabanknumbers.Created_When, " .
"dnabanknumbers.Created_Who, " .
"'$Type_old', " .
"'$Tissue_old', " .
"'$Preservation_old', " .
"'$Purification_Method_old', " .
"'$Extraction_Method_old', " .
"'$Degradation_old', " .
"'$RelationDNA_Voucher_old', " .
"'$Extraction_Staff_old', " .
"'$Provided_By_People_old', " .
"'$log', " .
"'$Location_Stock_old', " .
"'$Backup_Aliquot_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($_POST['formExtractionDate'] == "YYYY-MM-DD" or $_POST['formExtractionDate'] == "") {unset($formExtractionDate);}
if($_POST['formCheckDate'] == "YYYY-MM-DD" or $_POST['formCheckDate'] == "") {unset($formCheckDate);}
if($_POST['formBlockDate'] == "YYYY-MM-DD" or $_POST['formBlockDate == ""']) {unset($formBlockDate);}
if($_POST['formExtractionDate'] == "YYYY-MM-DD" or $_POST['formExtractionDate'] == "") { unset($_POST['formExtractionDate']); }
else { $date = $_POST['formExtractionDate'];
if (!valiDate($date)) {
$Validation = "FALSE";
echo 'Extraction date incorrect! '; }
else { $_POST['formExtractionDate'] = $_POST['formExtractionDate']; } }
if($_POST['formCheckDate'] == "YYYY-MM-DD" or $_POST['formCheckDate'] == "") { unset($_POST['formCheckDate']); }
else { $date = $_POST['formCheckDate'];
if (!valiDate($date)) {
$Validation = "FALSE";
echo 'Quality check date incorrect! '; }
else { $_POST['formCheckDate'] = $_POST['formCheckDate']; } }
if($_POST['formBlockDate'] == "YYYY-MM-DD" or $_POST['formBlockDate'] == "") { unset($_POST['formBlockDate']); }
else { $date = $_POST['formBlockDate'];
if (!valiDate($date)) {
$Validation = "FALSE";
echo 'Block date incorrect! '; }
else { $_POST['formBlockDate'] = $_POST['formBlockDate']; } }
$sql12 = "UPDATE dnabanknumbers SET DNA_Bank_Number = '$formDnaBankNumber', " .
"Extraction_Date = '$formExtractionDate', " .
"NoExtractDate = '$formNoExtractDate', " .
"Quality_Check_Date = '$formCheckDate', " .
"Concentration = '$formConcentration', " .
"Absorbance280 = '$formAbsorbance280', " .
"Absorbance230 = '$formAbsorbance230', " .
"Notes = '$formNotes', " .
"Notes_Intern = '$formNotesIntern', " .
"Block_Until = '$formBlockDate', " .
"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_Degradation = '$formDegradation', " .
"FK_AcquiredFrom = '$formProvidedBy', " .
"Stock_Gone = '$StockGone', " .
"Source_Gone = '$SourceGone', " .
"Block_General = '$BlockGeneral', " .
"Block_Until = '$formBlockDate', " .
"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.Block_General = '0' "; }
if (isset($_SESSION['project']) || $_SESSION['project']) {
$sql .= " AND ((dnabanknumbers.Created_Who != '".$log."' AND dnabanknumbers.Block_General = '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.Block_General = '0' "; }
if (isset($_SESSION['project']) || $_SESSION['project']) {
$sql .= " AND ((dnabanknumbers.Created_Who != '".$log."' AND dnabanknumbers.Block_General = '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 "Back to Data Cleaning Overview. | ";
/********************************************************************************************
* Further message for guests and project members when query was wrong *
*********************************************************************************************/
if (isset($_SESSION['guest']) || $_SESSION['guest'] || isset($_SESSION['project']) || $_SESSION['project']) {
echo "Sorry, you don't have permission to see this record. | "; }
else { //user has access to data
/********************************************************************************************
* Search key string *
*********************************************************************************************/
echo " |