This commit is contained in:
Jens 2021-05-02 21:24:30 +02:00
parent 3c752a9ef1
commit 39db9470cc
1 changed files with 0 additions and 201 deletions

View File

@ -67,7 +67,6 @@
displayUnitList();
exit(0);
}
<<<<<<< HEAD
}
class Unit
@ -871,8 +870,6 @@
return false;
}
=======
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
}
?>
@ -1014,11 +1011,7 @@
switch($command)
{
case "addToList":
<<<<<<< HEAD
$productId = $_POST['productId'];
=======
$productId = $_POST['productToAdd'];
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
$amount = $_POST['amountToAdd'];
$unitId = $_POST['unitToAdd'];
addToList($productId, $amount, $unitId);
@ -1221,20 +1214,10 @@
mysqli_close(DBLink::getDbLink());
<<<<<<< HEAD
function addToList($productId, $amount, $unitId)
=======
function createList()
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
{
<<<<<<< HEAD
if($productId > 0 && $amount != 0 && isset($unitId) && strlen($unitId) > 0)
=======
$SQL_command = "INSERT INTO `lists` (creationTime) VALUES (".round(microtime(true) * 1000).")";
if (DBLink::getDbLink()->query($SQL_command))
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
{
<<<<<<< HEAD
if(!ShoppingList::oneListExists())
createList();
@ -1278,74 +1261,6 @@
}
}
}
=======
echo "List created.<br>";
return true;
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
}
<<<<<<< HEAD
else
echo "Specifiy product, amount and unit.";
=======
return false;
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
}
<<<<<<< HEAD
function removeFromList($productId, $listId, $amount, $unitId)
=======
function addToList($productId, $amount, $unitId)
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
{
<<<<<<< HEAD
=======
if($productId > 0 && $amount != 0 && isset($unitId) && strlen($unitId) > 0)
{
if(!oneListExists())
createList();
if(!entryCombinationExists($productId, $unitId))
{
$SQL_command = "INSERT IGNORE INTO listEntries (listId, productId, amount, unit) VALUES ((SELECT id FROM `lists` ORDER BY creationTime DESC LIMIT 1), ".$productId.", ".$amount.", ".$unitId.")";
if (DBLink::getDbLink()->query($SQL_command))
echo "Product added to list.<br>";
else
echo "Product could not be added to list.<br>";
}
else
{
/*
update command that adds the amount to the already existing amount
if amount is negative -> subtract from existing amount. if resulting amount <= 0 ->
*/
$SQL_command = "SELECT amount FROM listEntries WHERE listId=(SELECT id FROM `lists` ORDER BY creationTime DESC LIMIT 1) AND productId=".$productId." AND unit=".$unitId;
$mysqli_result = DBLink::getDbLink()->query($SQL_command);
if ($row = mysqli_fetch_object($mysqli_result))
{
if($row->amount + $amount > 0)
{
$SQL_command = "UPDATE listEntries set amount=".($row->amount + $amount)." WHERE listId=(SELECT id FROM `lists` ORDER BY creationTime DESC LIMIT 1) AND productId=".$productId." AND unit=".$unitId;
if (DBLink::getDbLink()->query($SQL_command))
echo "Product added to existing entry on list.<br>";
else
echo "Product could not be added to existing entry on list.<br>";
}
else
{
$SQL_command = "DELETE FROM listEntries WHERE listId=(SELECT id FROM `lists` ORDER BY creationTime DESC LIMIT 1) AND productId=".$productId." AND unit=".$unitId;
if (DBLink::getDbLink()->query($SQL_command))
echo "Product removed from list as too many pieces of this item have been removed.<br>";
else
echo "Product could not be removed from list (too many pieces of this itme have been removed).<br>";
}
}
}
}
else
echo "Specifiy product, amount and unit.";
@ -1354,7 +1269,6 @@
function removeFromList($productId, $listId, $amount, $unitId)
{
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
if($productId > 0 && $amount != null && $unitId > 0)
{
if(ShoppingList::oneListExists())
@ -1371,60 +1285,11 @@
echo "Select a product.";
}
<<<<<<< HEAD
=======
function entryCombinationExists($productId, $unitId)
{
$SQL_command = "SELECT COUNT(listId) as entryAmount FROM listEntries WHERE listId=(SELECT id FROM `lists` ORDER BY creationTime DESC LIMIT 1) AND productId=".$productId." AND unit=".$unitId;
$mysqli_result = DBLink::getDbLink()->query($SQL_command);
if ($row = mysqli_fetch_object($mysqli_result))
{
if($row->entryAmount > 0)
return true;
}
return false;
}
function oneListExists()
{
$SQL_command = "SELECT COUNT(id) as listAmount FROM lists";
$mysqli_result = DBLink::getDbLink()->query($SQL_command);
if ($row = mysqli_fetch_object($mysqli_result))
{
if($row->listAmount > 0)
return true;
}
return false;
}
function twoListsExist()
{
$SQL_command = "SELECT COUNT(id) as listAmount FROM lists";
$mysqli_result = DBLink::getDbLink()->query($SQL_command);
if ($row = mysqli_fetch_object($mysqli_result))
{
if($row->listAmount > 1)
return true;
}
return false;
}
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
function displayShoppingList($listId, $justCreatedProductId)
{
echo " <h2>Shopping list</h2>
<<<<<<< HEAD
<form id=\"addProductToListForm\" action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\" onSubmit=\"addToggleStates(this); return checkAddProductToList();\">
=======
<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
<input type=\"hidden\" id=\"command\" name=\"command\" value=\"addToList\" />
<select name=\"productId\" id=\"productId\">
<option value=\"0\">Select product to add</option>
@ -1474,27 +1339,6 @@
echo "<option value=\"".$row->id."\">".$unitArray[0]."</option>";
}
echo " </select>
<input type=\"number\" step=\"any\" id=\"amountToAdd\" name=\"amountToAdd\" value=\"1.0\" />
<select name=\"unitToAdd\" id=\"unitToAdd\">
<option value=\"0\">Select unit to add</option>
";
$SQL_command = "SELECT * FROM `units` ORDER BY name ASC";
$mysqli_result = DBLink::getDbLink()->query($SQL_command);
while ($row = mysqli_fetch_object($mysqli_result))
{
$currentId = (int)$row->id;
$unitArray = explode(";", $row->name);
if($row->isDefault == 1 || (isset($justCreatedUnitId) && $justCreatedUnitId === $currentId))
echo "<option value=\"".$row->id."\" selected>".$unitArray[0]."</option>";
else
echo "<option value=\"".$row->id."\">".$unitArray[0]."</option>";
}
echo " </select>
<input type=\"submit\" value=\"add\" />
</form>";
@ -1552,11 +1396,7 @@
if(!isset($lastShop) || $row[9] != $lastShop)
{
$lastShop = $row[9];
<<<<<<< HEAD
echo "<h3>".$lastShop."</h3>";
=======
echo $lastShop."<br>================";
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
echo "<table border=\"0\">";
}
@ -1570,11 +1410,8 @@
<td style=\"vertical-align:top;\">".$row[12]."</td>
<td style=\"vertical-align:top;\">".$row[5]."</td>";
<<<<<<< HEAD
GLOBAL $iconDelete;
=======
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
echo "
<td style=\"vertical-align:top;\">
<form id=\"removeItemFromListForm\" action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\" onSubmit=\"addToggleStates(this)\">
@ -1583,11 +1420,7 @@
<input type=\"hidden\" id=\"productToRemove\" name=\"productToRemove\" value=\"".$row[1]."\" />
<input type=\"hidden\" id=\"productAmountToRemove\" name=\"productAmountToRemove\" value=\"".$row[2]."\" />
<input type=\"hidden\" id=\"productUnitToRemove\" name=\"productUnitToRemove\" value=\"".$row[10]."\" />
<<<<<<< HEAD
<input class=\"smallButton\" type=\"submit\" value=\"".$iconDelete."\" />
=======
<input class=\"smallButton\" type=\"submit\" value=\"remove\" />
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
</form>
</td>
</tr>";
@ -1606,7 +1439,6 @@
{
echo "<hr />";
<<<<<<< HEAD
$detailsName = "detailsMaintenance";
$openString = "";
if(in_array($detailsName, explode(";", $_POST['openDetailsElements'])))
@ -1629,9 +1461,6 @@
<summary>
<strong>Manage shopping lists</strong>
</summary>
=======
echo " <h2>Data maintenance</h2>
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
<h3>Create new list</h3>
@ -1958,36 +1787,6 @@
function displayUnitList()
<<<<<<< HEAD
=======
{
$SQL_Befehl = "SELECT name FROM units ORDER BY name ASC";
$mysqli_result = DBLink::getDbLink()->query($SQL_Befehl);
$lastShop="";
while ($row = mysqli_fetch_object($mysqli_result))
{
$unitArray = explode(";", $row->name);
if(count($unitArray) == 1)
echo $unitArray[0]."\n";
else
{
$tbp = "";
for($i=1; $i<count($unitArray); $i++)
$tbp .= $unitArray[$i]."|";
$tbp = trim($tbp, "|");
echo "(".$tbp."):".$unitArray[0]."\n";
}
}
}
function createNewShoppingList()
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
{
/*$SQL_command = "SELECT name FROM units ORDER BY name ASC";