Upload files to 'phpInterface'

Preselect product that has just been added.
This commit is contained in:
jens 2021-05-13 14:51:36 +02:00
parent 6d828fe56e
commit f7c470f5a1

View File

@ -7,8 +7,8 @@
// ini_set('display_errors', 0); // ini_set('display_errors', 0);
// error_reporting(0); // error_reporting(0);
// error_reporting(E_ALL & E_NOTICE); error_reporting(E_ALL & E_NOTICE);
// ini_set("display_errors","on"); ini_set("display_errors","on");
require_once("shoppingListConfig.php"); require_once("shoppingListConfig.php");
@ -206,6 +206,7 @@
if ($mysqli_result) if ($mysqli_result)
{ {
$this->ensurePlausibility(); $this->ensurePlausibility();
$this->setID(DBLink::getDbLink()->insert_id);
return true; return true;
} }
@ -341,7 +342,10 @@
$mysqli_result = DBLink::getDbLink()->query($SQL_command); $mysqli_result = DBLink::getDbLink()->query($SQL_command);
if ($mysqli_result) if ($mysqli_result)
{
$this->setID(DBLink::getDbLink()->insert_id);
return true; return true;
}
return false; return false;
} }
@ -479,6 +483,7 @@
if ($mysqli_result) if ($mysqli_result)
{ {
$this->setID(DBLink::getDbLink()->insert_id);
return true; return true;
} }
@ -619,6 +624,7 @@
if ($mysqli_result) if ($mysqli_result)
{ {
$this->setID(DBLink::getDbLink()->insert_id);
return true; return true;
} }
@ -778,6 +784,7 @@
if ($mysqli_result) if ($mysqli_result)
{ {
$this->setID(DBLink::getDbLink()->insert_id);
return true; return true;
} }
@ -878,9 +885,7 @@
} }
} }
?> /*
<!--
▄▄ ▄▄ ▄▄▄▄▄▄ ▄▄▄ ▄▄ ▄▄ ▄▄ ▄▄▄▄▄▄ ▄▄▄ ▄▄
█▄█ █▄█
█▄█ █▄█
@ -905,7 +910,8 @@
█▄▄▄█ █▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄█ █▄▄█ █▄▄▄█ █▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄█ █▄▄█
--> */
?>
<html> <html>
<head> <head>
@ -1083,7 +1089,10 @@
$p->setStoreType(StoreType::getById($_POST['productStoreTypeId'])); $p->setStoreType(StoreType::getById($_POST['productStoreTypeId']));
if($p->create()) if($p->create())
{
echo "Product has been created."; echo "Product has been created.";
$justCreatedProductId = $p->getID();
}
else else
echo "Product could not be created: ".mysqli_error(DBLink::getDbLink()); echo "Product could not be created: ".mysqli_error(DBLink::getDbLink());
} }
@ -1239,7 +1248,6 @@
mysqli_close(DBLink::getDbLink()); mysqli_close(DBLink::getDbLink());
function addToList($productId, $amount, $unitId) function addToList($productId, $amount, $unitId)
{ {
if($productId > 0 && $amount != 0 && isset($unitId) && strlen($unitId) > 0) if($productId > 0 && $amount != 0 && isset($unitId) && strlen($unitId) > 0)
@ -1292,7 +1300,6 @@
echo "Specifiy product, amount and unit."; echo "Specifiy product, amount and unit.";
} }
function removeFromList($productId, $listId, $amount, $unitId) function removeFromList($productId, $listId, $amount, $unitId)
{ {
if($productId > 0 && $amount != null && $unitId > 0) if($productId > 0 && $amount != null && $unitId > 0)
@ -1320,19 +1327,7 @@
<select name=\"productId\" id=\"productId\"> <select name=\"productId\" id=\"productId\">
<option value=\"0\">Select product to add</option> <option value=\"0\">Select product to add</option>
"; ";
/*
$SQL_command = "SELECT id, name FROM `products` ORDER BY name ASC";
$mysqli_result = DBLink::getDbLink()->query($SQL_command);
while ($row = mysqli_fetch_object($mysqli_result))
{
$currentId = (int)$row->id;
if(isset($justCreatedProductId) && $justCreatedProductId === $currentId)
echo "<option value=\"".$row->id."\" selected="selected">".$row->name."</option>";
else
echo "<option value=\"".$row->id."\">".$row->name."</option>";
}
*/
foreach(Product::getAllProducts() as $product) foreach(Product::getAllProducts() as $product)
{ {
$currentId = (int)$product->getID(); $currentId = (int)$product->getID();