|
DNA Bank Network - Edit Orders |
|
| Logout. |
Please select an aliquot!"; }
else
{
foreach ($_POST['x'] as $index => $check)
{
if(isset($check))
{
$IDRequestTest = $_POST['IDRequest'][$index];
$IDAliquotsTest = $_POST['IDAliquots'][$index];
$RestTest = $_POST['Rest'][$index];
$NotesTest = $_POST['Notes'][$index];
$AgreementTest = $_POST['formAgreement'][$index];
$RequestTest = $_POST['Request'][$index];
$formShippingDate = $_POST['Ship_Date'][$index];
$ShippingDate_split = explode (".", $formShippingDate);
$ShippingDate = $ShippingDate_split[2] . "-" . $ShippingDate_split[1] . "-" . $ShippingDate_split[0];
if(!isset($AgreementTest))
{echo "Please check the MTA box!";}
else{
if($formAction == '1')
{
$result1 = "SELECT ID_Aliquots, Rest_Quantity FROM tablealiquots WHERE ID_Aliquots = '$IDAliquotsTest'";
$sql1 = mysql_query($result1);
#######################################Error 1###############################################################
if(!$sql1)
{ $msg = $result1."\n";
$msg .= "####Error 1####";
trigger_error($msg, E_USER_ERROR); }
#############################################################################################################
while($row = mysql_fetch_object($sql1))
{ $Rest_Quantity = $row->Rest_Quantity;
}
$RestNew = $Rest_Quantity + $RestTest;
$result2 = "UPDATE tablealiquots SET Rest_Quantity = '$RestNew' WHERE ID_Aliquots = '$IDAliquotsTest'";
$sql2 = mysql_query($result2);
#######################################Error 2###############################################################
if(!$sql2)
{ $msg = $result2."\n";
$msg .= "####Error 2####";
trigger_error($msg, E_USER_ERROR); }
#############################################################################################################
if($sql1 and $sql2)
{
$result3 = "DELETE FROM tablerequest WHERE ID_Request = '$IDRequestTest'";
$sql3 = mysql_query($result3); }
#######################################Error 3###############################################################
if(!$sql3)
{ $msg = $result3."\n";
$msg .= "####Error 3####";
trigger_error($msg, E_USER_ERROR); }
#############################################################################################################
if($sql3)
{
echo "Orders have been deleted!"; }
}
if($formAction == '2')
{
if($ShippingDate > '0000-00-00' and $ShippingDate < $RequestTest)
{ echo "Shipping Date is older than Order Date!"; }
else {
$result4 = "SELECT ID_Request, Order_All, Order_Partial, Order_Rest, Shipping_All, Shipping_Partial, Shipping_Rest FROM tablerequest WHERE ID_Request = '$IDRequestTest'";
$sql4 = mysql_query($result4);
while($row = mysql_fetch_object($sql4))
{ $Order_All = $row->Order_All;
$Order_Partial = $row->Order_Partial;
$Order_Rest = $row->Order_Rest;
$Shipping_All = $row->Shipping_All;
$Shipping_Partial = $row->Shipping_Partial;
$Shipping_Rest = $row->Shipping_Rest; }
if($Order_All == 'Yes')
{ $OrderAll = '';
$ShipAll = 'Yes'; }
if($Order_Partial == 'Yes')
{ $OrderPartial = '';
$ShipPartial = 'Yes'; }
if($Order_Rest == 'Yes')
{ $OrderRest = '';
$ShipRest = 'Yes'; }
$result6 = "UPDATE tablerequest SET Shipping_Date = '$ShippingDate', Request_Notes = '$NotesTest', Order_All = '$OrderAll', Order_Partial = '$OrderPartial', Order_Rest = '$OrderRest', Shipping_All = '$ShipAll', Shipping_Partial = '$ShipPartial', Shipping_Rest = '$ShipRest', Agreement = '$AgreementTest' WHERE ID_Request = '$IDRequestTest'";
$sql6 = mysql_query($result6);
#######################################Error 6###############################################################
if(!$sql6)
{ $msg = $result6."\n";
$msg .= "####Error 6####";
trigger_error($msg, E_USER_ERROR); }
#############################################################################################################
}
}
}
}
}}
}
?>
>>> Help <<<
|
If you want to add a new order please use this form. |
Customer: |
|
edit/new
|
DNA Extraction Numbers: |
|
Order Status: | outstanding orders: > already shipped orders: > show all: > |
Order date from: | to: | |
Shipping date from: | to: | |
|
|
=";
$st = "<=";
$parr = $_POST;
array($parr);
foreach ($parr as $var)
{
$i ++;
if(!empty($var) and $var!="dd.mm.yyyy" and $var!="Check Data" and $var!="Action")
{
switch (key($parr))
{
case 'formCustomer':
$str = "tablerequest.ID_People ".$tr."'".$var."' AND ";
$description = " Customer = ";
$value = "hallo";
break;
case 'formDnaBankNumber':
$str = "tablednabanknumbers.Dna_Bank_Number ".$tr."'".$var."' AND ";
$description = " DNA Extraction Numer = ";
$value = $formDnaBankNumber;
break;
case 'formOrderDateFrom':
if ($OrderDateFrom!="") {
$str = "tablerequest.Request_Date ".$bt."'".$OrderDateFrom."' AND ";
$description = " Order Date >= ";
if($_POST['formOrderDateFrom']) {$value = $formOrderDateFrom;}
}
break;
case 'formOrderDateTo':
if ($OrderDateTo!="") {
$str = "tablerequest.Request_Date ".$st."'".$OrderDateTo."' AND ";
$description = " Order Date <= ";
if($_POST['formOrderDateTo']) {$value = $formOrderDateTo;}
}
break;
case 'formShippingDateFrom':
if ($ShippingDateFrom!="") {
$str = "tablerequest.Shipping_Date ".$bt."'".$ShippingDateFrom."' AND ";
$description = " Shipping Date >= ";
if($_POST['formShippingDateFrom']) {$value = $formShippingDateFrom;}
}
break;
case 'formShippingDateTo':
if ($ShippingDateTo!="") {
$str = "tablerequest.Shipping_Date ".$st."'".$ShippingDateTo."' AND ";
$description = " Shipping Date <= ";
if($_POST['formShippingDateTo']) {$value = $formShippingDateTo;}
}
break;
case 'radioStatus':
$description = " Order Status = ";
if($radioStatus=="order") {
$str = "(tablealiquots.Shipping_Partial ".$no."'YES' AND ";
$str .= "tablealiquots.Shipping_All ".$no."'YES') AND ";
$value = "outstanding orders"; }
if($radioStatus=="shipping") {
$str = "(tablealiquots.Shipping_Partial ".$tr."'YES' OR ";
$str .= "tablealiquots.Shipping_All ".$tr."'YES') AND ";
$value = "already shipped orders"; }
if($radioStatus=="all") {
$str = "(tablealiquots.Shipping_Partial ".$tr."'YES' OR ";
$str .= "tablealiquots.Shipping_All ".$tr."'YES' OR ";
$str .= "tablealiquots.Order_Partial ".$tr."'YES' OR ";
$str .= "tablealiquots.Order_All ".$tr."'YES') AND ";
$value = "all orders"; }
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;
//abfrage
$result = "SELECT tablerequest.ID_Request, " .
"tablerequest.ID_Aliquots, " .
"tablednabanknumbers.Dna_Bank_Number, " .
"tablerequest.Request_Number_Aliquots, " .
"tablerequest.Shipping_All, " .
"tablerequest.Shipping_Partial, " .
"tablerequest.Shipping_Rest, " .
"tablerequest.Order_All, " .
"tablerequest.Order_Partial, " .
"tablerequest.Order_Rest, " .
"tablealiquots.Aliquot_Barcode, " .
"tablealiquots.Aliquot_Position, " .
"tablealiquots_box.Aliquots_Box, " .
"tablealiquots_rack.Aliquots_Rack, " .
"tablealiquots_fridge.Aliquots_Fridge, " .
"tablerequest.Request_Date, " .
"tablerequest.Request_Volume, " .
"tablerequest.Request_Notes, " .
"tablerequest.Shipping_Date, " .
"tablerequest.Price, " .
"tablerequest.Agreement, " .
"tablerequest.Created_When, " .
"tablerequest.Created_Who, " .
"tablepeople.Name_All " .
"FROM tablerequest
LEFT JOIN tablealiquots ON tablerequest.ID_Aliquots = tablealiquots.ID_Aliquots
LEFT JOIN tablednabanknumbers ON tablerequest.ID_DNA = tablednabanknumbers.ID_DNA
LEFT JOIN tablealiquots_box ON tablealiquots.ID_Aliquots_Box = tablealiquots_box.ID_Aliquots_Box
LEFT JOIN tablealiquots_rack ON tablealiquots.ID_Aliquots_Rack = tablealiquots_rack.ID_Aliquots_Rack
LEFT JOIN tablealiquots_fridge ON tablealiquots.ID_Aliquots_Fridge = tablealiquots_fridge.ID_Aliquots_Fridge
LEFT JOIN tablepeople ON tablerequest.ID_People = tablepeople.ID_People " .
$wherestr.$sqllimit;
$sql = mysql_query($result) or die($result.' '.mysql_error());
$gesamt = mysql_num_rows($sql);
if(!mysql_num_rows($sql))
{ echo "No hits found."; }
else {
//NORMAL:
echo "
|
|
|
|