Merge branch 'development' of
https://git.server47.de/jens/ShoppingList.git into development Conflicts: phpInterface/shoppingList.php
This commit is contained in:
commit
3c752a9ef1
@ -173,7 +173,7 @@ public class ShoppingList
|
||||
return resultList;
|
||||
}
|
||||
|
||||
public boolean send()
|
||||
public boolean sendViaEmail()
|
||||
{
|
||||
StringBuilder shoppingListString = new StringBuilder();
|
||||
|
||||
|
@ -58,7 +58,10 @@ public class ShoppingListEntry
|
||||
PreparedStatement preparedStmt = null;
|
||||
Connection conn = null;
|
||||
try
|
||||
{
|
||||
{
|
||||
if(amount <= 0 && unit != null && !unit.isDummy)
|
||||
return false;
|
||||
|
||||
conn = DatabaseHandler.getInstance().getConnection();
|
||||
|
||||
if(!combinationExists(this.getParentList(), this.getProduct(), this.getUnit()))
|
||||
@ -85,7 +88,7 @@ public class ShoppingListEntry
|
||||
}
|
||||
else
|
||||
{
|
||||
return updateAmount();
|
||||
return updateAmount(false);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
@ -112,7 +115,10 @@ public class ShoppingListEntry
|
||||
PreparedStatement preparedStmt = null;
|
||||
Connection conn = null;
|
||||
try
|
||||
{
|
||||
{
|
||||
if(amount <= 0 && unit != null && !unit.isDummy)
|
||||
return false;
|
||||
|
||||
conn = DatabaseHandler.getInstance().getConnection();
|
||||
|
||||
if(this.getAmount() == 0 || this.getUnit().isDummy())
|
||||
@ -127,7 +133,7 @@ public class ShoppingListEntry
|
||||
|
||||
long numAffectedRows = preparedStmt.executeUpdate();
|
||||
Miscellaneous.logEvent("AMOUNT OF UPDATED ROWS: " + numAffectedRows, 5);
|
||||
ResultSet rs = preparedStmt.getGeneratedKeys();
|
||||
// ResultSet rs = preparedStmt.getGeneratedKeys();
|
||||
// if (numAffectedRows > 0)
|
||||
// {
|
||||
preparedStmt.close();
|
||||
@ -137,7 +143,9 @@ public class ShoppingListEntry
|
||||
else
|
||||
{
|
||||
if(combinationExists(this.getParentList(), this.getProduct(), this.getUnit()))
|
||||
return updateAmount();
|
||||
return updateAmount(true);
|
||||
else
|
||||
return true; // Combination to be deleted does not exist. So what?
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
@ -159,7 +167,7 @@ public class ShoppingListEntry
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean updateAmount()
|
||||
protected boolean updateAmount(boolean delete)
|
||||
{
|
||||
String query = "SELECT * FROM listEntries WHERE listId=? AND productId=? AND unit=?";
|
||||
|
||||
@ -179,13 +187,22 @@ public class ShoppingListEntry
|
||||
if(res.next())
|
||||
{
|
||||
float currentAmount = res.getFloat("amount");
|
||||
if(currentAmount + this.getAmount() > 0)
|
||||
|
||||
boolean condition = true;
|
||||
if(delete)
|
||||
condition = currentAmount - this.getAmount() > 0;
|
||||
|
||||
if(condition)
|
||||
{
|
||||
// Update the amount
|
||||
String updateQuery = "UPDATE listEntries set amount=? WHERE listId=? AND productId=? AND unit=?";
|
||||
preparedStmt = conn.prepareStatement(updateQuery);
|
||||
|
||||
preparedStmt.setFloat(1, currentAmount + this.getAmount());
|
||||
if(delete)
|
||||
preparedStmt.setFloat(1, currentAmount - this.getAmount());
|
||||
else
|
||||
preparedStmt.setFloat(1, currentAmount + this.getAmount());
|
||||
|
||||
preparedStmt.setLong(2, this.getParentList().getId());
|
||||
preparedStmt.setLong(3, this.getProduct().getId());
|
||||
preparedStmt.setLong(4, this.getUnit().getId());
|
||||
@ -209,7 +226,7 @@ public class ShoppingListEntry
|
||||
String updateQuery = "DELETE FROM listEntries WHERE listId=? AND productId=? AND unit=?";
|
||||
preparedStmt = conn.prepareStatement(updateQuery);
|
||||
|
||||
preparedStmt.setLong(1, this.getProduct().getId());
|
||||
preparedStmt.setLong(1, this.getParentList().getId());
|
||||
preparedStmt.setLong(2, this.getProduct().getId());
|
||||
preparedStmt.setLong(3, this.getUnit().getId());
|
||||
|
||||
@ -225,6 +242,8 @@ public class ShoppingListEntry
|
||||
preparedStmt.close();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
preparedStmt.close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,8 +273,6 @@ public class ShoppingListEntry
|
||||
|
||||
ResultSet res = preparedStmt.executeQuery();
|
||||
|
||||
boolean found = false;
|
||||
|
||||
if(res.next())
|
||||
entryAmount = res.getLong("combinationAmount");
|
||||
|
||||
@ -272,4 +289,18 @@ public class ShoppingListEntry
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if(this.getUnit() != null)
|
||||
{
|
||||
if(!this.getUnit().isDummy())
|
||||
return String.valueOf(getAmount()) + " " + getUnit().getMainName() + " " + getProduct().getName();
|
||||
}
|
||||
|
||||
return getProduct().getName();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -75,25 +75,28 @@ public class Start
|
||||
Unit u = Unit.getByName(unitName);
|
||||
Product p = Product.getByName(productName);
|
||||
|
||||
if(list == null)
|
||||
exitWithError(Settings.languageBlock.get("couldNotCreateList"));
|
||||
|
||||
if(p == null)
|
||||
exitWithError(Settings.languageBlock.get("productNotFound") + " " + productName);
|
||||
|
||||
ShoppingListEntry entry = new ShoppingListEntry();
|
||||
entry.setParentList(list);
|
||||
entry.setProduct(p);
|
||||
entry.setAmount(amount);
|
||||
entry.setUnit(u);
|
||||
|
||||
|
||||
if(amount > 0 && (u == null || u.isDummy))
|
||||
entry.setUnit(Unit.getPieceUnit());
|
||||
|
||||
if(list == null)
|
||||
exitWithError(Settings.languageBlock.get("couldNotCreateList"));
|
||||
|
||||
if(p == null)
|
||||
exitWithError(Settings.languageBlock.get("productNotFound") + " " + entry.toString());
|
||||
|
||||
if(entry.create())
|
||||
{
|
||||
DatabaseHandler.getInstance().disconnect();
|
||||
System.exit(0);
|
||||
}
|
||||
else
|
||||
exitWithError(Settings.languageBlock.get("couldNotAddProdToList") + " " + productName);
|
||||
exitWithError(Settings.languageBlock.get("couldNotAddProdToList") + " " + entry.toString());
|
||||
}
|
||||
else
|
||||
System.out.println(Settings.languageBlock.get("noProdSpecified"));
|
||||
@ -103,26 +106,31 @@ public class Start
|
||||
{
|
||||
ShoppingList list = ShoppingList.getMostRecentList();
|
||||
Product p = Product.getByName(productName);
|
||||
Unit u = Unit.getByName(unitName);
|
||||
|
||||
ShoppingListEntry entry = new ShoppingListEntry();
|
||||
entry.setParentList(list);
|
||||
entry.setProduct(p);
|
||||
entry.setAmount(amount);
|
||||
entry.setUnit(u);
|
||||
|
||||
if(amount > 0 && (u == null || u.isDummy))
|
||||
entry.setUnit(Unit.getPieceUnit());
|
||||
|
||||
if(list == null)
|
||||
exitWithError(Settings.languageBlock.get("couldNotCreateList"));
|
||||
|
||||
if(p == null)
|
||||
exitWithError(Settings.languageBlock.get("productNotFound") + " " + productName);
|
||||
|
||||
for(ShoppingListEntry entry : list.getEntries())
|
||||
{bestehende reduzieren
|
||||
if(entry.getProduct().equals(p))
|
||||
{
|
||||
if(entry.delete())
|
||||
{
|
||||
DatabaseHandler.getInstance().disconnect();
|
||||
System.exit(0);
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent(Settings.languageBlock.get("couldNotRemoveProdFromList") + " " + productName, 2);
|
||||
}
|
||||
exitWithError(Settings.languageBlock.get("productNotFound") + " " + entry.toString());
|
||||
|
||||
if(entry.delete())
|
||||
{
|
||||
DatabaseHandler.getInstance().disconnect();
|
||||
System.exit(0);
|
||||
}
|
||||
else
|
||||
exitWithError(Settings.languageBlock.get("couldNotRemoveProdFromList") + " " + entry.toString());
|
||||
|
||||
// If it wasn't on the list - why care?
|
||||
DatabaseHandler.getInstance().disconnect();
|
||||
System.exit(0);
|
||||
@ -131,7 +139,7 @@ public class Start
|
||||
System.out.println(Settings.languageBlock.get("noProdSpecified"));
|
||||
break;
|
||||
case "sendList":
|
||||
if(ShoppingList.getMostRecentList().send())
|
||||
if(ShoppingList.getMostRecentList().sendViaEmail())
|
||||
{
|
||||
// System.out.println("Liste wurde verschickt.");
|
||||
DatabaseHandler.getInstance().disconnect();
|
||||
|
@ -19,6 +19,7 @@ static ArrayList<Unit> unitCache = null;
|
||||
String abbreviation;
|
||||
boolean isDefault;
|
||||
boolean isDummy;
|
||||
boolean isPiece;
|
||||
|
||||
public long getId()
|
||||
{
|
||||
@ -29,6 +30,14 @@ static ArrayList<Unit> unitCache = null;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMainName()
|
||||
{
|
||||
if(name.contains(";"))
|
||||
return name.split(";")[0];
|
||||
else
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
@ -65,6 +74,15 @@ static ArrayList<Unit> unitCache = null;
|
||||
this.isDummy = isDummy;
|
||||
}
|
||||
|
||||
public boolean isPiece()
|
||||
{
|
||||
return isPiece;
|
||||
}
|
||||
public void setPiece(boolean isPiece)
|
||||
{
|
||||
this.isPiece = isPiece;
|
||||
}
|
||||
|
||||
public static ArrayList<Unit> readAllUnits()
|
||||
{
|
||||
if(unitCache == null)
|
||||
@ -97,6 +115,7 @@ static ArrayList<Unit> unitCache = null;
|
||||
u.setAbbreviation(res.getString("abbreviation"));
|
||||
u.setDefault(res.getInt("isDefault") == 1);
|
||||
u.setDummy(res.getInt("isDummy") == 1);
|
||||
u.setPiece(res.getInt("isPiece") == 1);
|
||||
|
||||
unitCache.add(u);
|
||||
}
|
||||
@ -133,10 +152,13 @@ static ArrayList<Unit> unitCache = null;
|
||||
|
||||
for(Unit u : readAllUnits())
|
||||
{
|
||||
if(u.getName().equalsIgnoreCase(unitName))
|
||||
return u;
|
||||
else if(u.getName().equalsIgnoreCase(unitName.replace("-", " ")))
|
||||
return u;
|
||||
for(String unitSynonym : u.getName().split(";"))
|
||||
{
|
||||
if(unitSynonym.equalsIgnoreCase(unitName))
|
||||
return u;
|
||||
else if(unitSynonym.equalsIgnoreCase(unitName.replace("-", " ")))
|
||||
return u;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -145,7 +167,10 @@ static ArrayList<Unit> unitCache = null;
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getName();
|
||||
if(getName().contains(";"))
|
||||
return getName().split(";")[0];
|
||||
else
|
||||
return getName();
|
||||
}
|
||||
|
||||
public static Unit getById(long id)
|
||||
@ -161,7 +186,7 @@ static ArrayList<Unit> unitCache = null;
|
||||
|
||||
public boolean create()
|
||||
{
|
||||
String query = "INSERT INTO units (name, abbreviation, isDefault, isDummy) VALUES (?, ?, ?, ?)";
|
||||
String query = "INSERT INTO units (name, abbreviation, isDefault, isDummy, isPiece) VALUES (?, ?, ?, ?, ?)";
|
||||
Connection conn = DatabaseHandler.getInstance().getConnection();
|
||||
PreparedStatement preparedStmt = null;
|
||||
try
|
||||
@ -179,6 +204,11 @@ static ArrayList<Unit> unitCache = null;
|
||||
preparedStmt.setInt(4, 1);
|
||||
else
|
||||
preparedStmt.setInt(4, 0);
|
||||
|
||||
if(this.isPiece)
|
||||
preparedStmt.setInt(5, 1);
|
||||
else
|
||||
preparedStmt.setInt(5, 0);
|
||||
|
||||
preparedStmt.executeUpdate();
|
||||
ResultSet rs = preparedStmt.getGeneratedKeys();
|
||||
@ -219,4 +249,26 @@ static ArrayList<Unit> unitCache = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Unit getDefaultUnit()
|
||||
{
|
||||
for(Unit u : readAllUnits())
|
||||
{
|
||||
if(u.isDefault())
|
||||
return u;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Unit getPieceUnit()
|
||||
{
|
||||
for(Unit u : readAllUnits())
|
||||
{
|
||||
if(u.isPiece())
|
||||
return u;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -67,6 +67,7 @@
|
||||
displayUnitList();
|
||||
exit(0);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
|
||||
class Unit
|
||||
@ -870,6 +871,8 @@
|
||||
|
||||
return false;
|
||||
}
|
||||
=======
|
||||
>>>>>>> branch 'development' of https://git.server47.de/jens/ShoppingList.git
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1011,7 +1014,11 @@
|
||||
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);
|
||||
@ -1214,10 +1221,20 @@
|
||||
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();
|
||||
|
||||
@ -1261,6 +1278,74 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
=======
|
||||
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.";
|
||||
@ -1269,6 +1354,7 @@
|
||||
|
||||
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())
|
||||
@ -1285,11 +1371,60 @@
|
||||
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>
|
||||
@ -1339,6 +1474,27 @@
|
||||
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>";
|
||||
@ -1396,7 +1552,11 @@
|
||||
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\">";
|
||||
}
|
||||
|
||||
@ -1410,8 +1570,11 @@
|
||||
<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)\">
|
||||
@ -1420,7 +1583,11 @@
|
||||
<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>";
|
||||
@ -1439,6 +1606,7 @@
|
||||
{
|
||||
echo "<hr />";
|
||||
|
||||
<<<<<<< HEAD
|
||||
$detailsName = "detailsMaintenance";
|
||||
$openString = "";
|
||||
if(in_array($detailsName, explode(";", $_POST['openDetailsElements'])))
|
||||
@ -1461,6 +1629,9 @@
|
||||
<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>
|
||||
|
||||
@ -1787,6 +1958,36 @@
|
||||
|
||||
|
||||
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";
|
||||
|
||||
|
@ -1,12 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
SHOPPINGITEM=""
|
||||
AMOUNT=""
|
||||
UNIT=""
|
||||
SITEID=""
|
||||
PARAMS=""
|
||||
SESSIONID=""
|
||||
|
||||
while (( "$#" )); do
|
||||
case "$1" in
|
||||
--shoppingAmount)
|
||||
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
|
||||
AMOUNT=$2
|
||||
shift 2
|
||||
else
|
||||
echo "Error: Argument for $1 is missing" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--shoppingUnit)
|
||||
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
|
||||
UNIT=$2
|
||||
shift 2
|
||||
else
|
||||
echo "Error: Argument for $1 is missing" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--shoppingProduct)
|
||||
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
|
||||
SHOPPINGITEM=$2
|
||||
@ -53,7 +73,21 @@ then
|
||||
echo "Was soll ich auf die Liste setzen?"
|
||||
exit 1
|
||||
else
|
||||
java -jar /home/pi/hc_scripts/ShoppingList.jar --action addToList --shoppingProduct $SHOPPINGITEM
|
||||
lengthAmount=${#AMOUNT}
|
||||
lengthUnit=${#UNIT}
|
||||
|
||||
if [ $lengthAmount -gt 0 ]
|
||||
then
|
||||
if [ $lengthUnit -gt 0 ]
|
||||
then
|
||||
java -jar /home/pi/hc_scripts/ShoppingList.jar --action addToList --shoppingAmount $AMOUNT --shoppingUnit $UNIT --shoppingProduct $SHOPPINGITEM
|
||||
else
|
||||
java -jar /home/pi/hc_scripts/ShoppingList.jar --action addToList --shoppingAmount $AMOUNT --shoppingProduct $SHOPPINGITEM
|
||||
fi
|
||||
else
|
||||
java -jar /home/pi/hc_scripts/ShoppingList.jar --action addToList --shoppingProduct $SHOPPINGITEM
|
||||
fi
|
||||
|
||||
if [ "$?" -eq "0" ]
|
||||
then
|
||||
exit 0
|
||||
|
@ -1,12 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
SHOPPINGITEM=""
|
||||
AMOUNT=""
|
||||
UNIT=""
|
||||
SITEID=""
|
||||
PARAMS=""
|
||||
SESSIONID=""
|
||||
|
||||
while (( "$#" )); do
|
||||
case "$1" in
|
||||
--shoppingAmount)
|
||||
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
|
||||
AMOUNT=$2
|
||||
shift 2
|
||||
else
|
||||
echo "Error: Argument for $1 is missing" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--shoppingUnit)
|
||||
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
|
||||
UNIT=$2
|
||||
shift 2
|
||||
else
|
||||
echo "Error: Argument for $1 is missing" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--shoppingProduct)
|
||||
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
|
||||
SHOPPINGITEM=$2
|
||||
@ -53,11 +73,25 @@ then
|
||||
echo "Was soll ich von der Liste streichen?"
|
||||
exit 1
|
||||
else
|
||||
java -jar /home/pi/hc_scripts/ShoppingList.jar --action removeFromList --shoppingProduct $SHOPPINGITEM
|
||||
if [ "$?" -eq "0" ]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
lengthAmount=${#AMOUNT}
|
||||
lengthUnit=${#UNIT}
|
||||
|
||||
if [ $lengthAmount -gt 0 ]
|
||||
then
|
||||
if [ $lengthUnit -gt 0 ]
|
||||
then
|
||||
java -jar /home/pi/hc_scripts/ShoppingList.jar --action removeFromList --shoppingAmount $AMOUNT --shoppingUnit $UNIT --shoppingProduct $SHOPPINGITEM
|
||||
else
|
||||
java -jar /home/pi/hc_scripts/ShoppingList.jar --action removeFromList --shoppingAmount $AMOUNT --shoppingProduct $SHOPPINGITEM
|
||||
fi
|
||||
else
|
||||
java -jar /home/pi/hc_scripts/ShoppingList.jar --action removeFromList --shoppingProduct $SHOPPINGITEM
|
||||
fi
|
||||
|
||||
if [ "$?" -eq "0" ]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
5
slotPrograms/shoppingProduct
Normal file
5
slotPrograms/shoppingProduct
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Adjust the URL to match where your php interface is.
|
||||
|
||||
curl http://yourWebserver/rhasspy/shoppingList.php?command=printProductList
|
5
slotPrograms/shoppingUnit
Normal file
5
slotPrograms/shoppingUnit
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Adjust the URL to match where your php interface is.
|
||||
|
||||
curl http://yourWebserver/rhasspy/shoppingList.php?command=printUnitList
|
Loading…
Reference in New Issue
Block a user