]> 91.132.146.200 Git - emere.git/commitdiff
item creation
authorBanana <mail@bananas-playground.net>
Sun, 18 Sep 2022 17:06:37 +0000 (19:06 +0200)
committerBanana <mail@bananas-playground.net>
Sun, 18 Sep 2022 17:06:37 +0000 (19:06 +0200)
webroot/lib/item.class.php
webroot/view/_menu.php
webroot/view/entry/entry.html [deleted file]
webroot/view/entry/entry.php [deleted file]
webroot/view/item/item.html [new file with mode: 0644]
webroot/view/item/item.php [new file with mode: 0644]

index 4838cbea6abc694e81b48d1f171cbaaa8e4a6956..fc067718b610a8301d68ac827bf10c20bb9bd2a3 100644 (file)
@@ -24,14 +24,14 @@ class Item {
      *
      * @var mysqli
      */
-    private $_DB;
+    private mysqli $_DB;
 
     /**
      * The data for this item
      *
      * @var array
      */
-    private $_data;
+    private array $_data;
 
     /**
      * @param mysqli $databaseConnectionObject
@@ -39,4 +39,12 @@ class Item {
     public function __construct(mysqli $databaseConnectionObject) {
         $this->_DB = $databaseConnectionObject;
     }
-}
\ No newline at end of file
+
+       public function create(array $data): string {
+               $ret = "";
+
+
+
+               return $ret;
+       }
+}
index d356180e2081afc657fd60df1d3ba6b8a516d048..d491c4bec356131b5adc38ce9e71d499c24533a3 100644 (file)
@@ -1,5 +1,5 @@
 <?php
 ?>
 <nav>
-    <a href="index.php">Home</a> | <a href="index.php?p=entry">New</a> | <a href="index.php?p=list">Search</a>
+    <a href="index.php">Home</a> | <a href="index.php?p=item">New</a> | <a href="index.php?p=list">Search</a>
 </nav>
diff --git a/webroot/view/entry/entry.html b/webroot/view/entry/entry.html
deleted file mode 100644 (file)
index ac61228..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<form>
-    <fieldset>
-        <label for="receipt">Receipt <small>Just leave it blank to create a new based on data and market name.</small></label>
-        <input name="fdata[receipt]" id="receipt" type="text" list="receiptList" autocomplete="off"
-               value="<?php echo Summoner::ifset($TemplateData['editData'], 'receipt'); ?>" />
-        <datalist id="receiptList">
-            <option>Rewe</option>
-            <option>Lidl</option>
-        </datalist>
-
-        <label for="receiptdate">Date and time</label>
-        <input name="fdata[receiptdate]" id="receiptdate" type="datetime-local" autocomplete="off"
-               value="<?php echo Summoner::ifset($TemplateData['editData'], 'receiptdate'); ?>" />
-
-        <label for="market">Market</label>
-        <input name="fdata[market]" id="market" type="text" list="marketList" autocomplete="off"
-               value="<?php echo Summoner::ifset($TemplateData['editData'], 'market'); ?>" />
-        <datalist id="marketList">
-            <option>Rewe</option>
-            <option>Lidl</option>
-        </datalist>
-
-        <label for="product">Product</label>
-        <input name="fdata[product]" id="product" type="text" list="productList" autocomplete="off"
-               value="<?php echo Summoner::ifset($TemplateData['editData'], 'product'); ?>"/>
-        <datalist id="productList">
-            <option>Rewe</option>
-            <option>Lidl</option>
-        </datalist>
-
-        <label for="manufacturer">Manufacturer</label>
-        <input name="fdata[manufacturer]" id="manufacturer" type="text" list="manufacturerList" autocomplete="off"
-               value="<?php echo Summoner::ifset($TemplateData['editData'], 'manufacturer'); ?>"/>
-        <datalist id="manufacturerList">
-            <option>Rewe</option>
-            <option>Lidl</option>
-        </datalist>
-
-        <label for="weight">Weight(g)</label>
-        <input name="fdata[weight]" id="weight" type="number" autocomplete="off"
-               value="<?php echo Summoner::ifset($TemplateData['editData'], 'weight'); ?>"/>
-
-        <label for="itemcount">Itemcount</label>
-        <input name="fdata[itemcount]" id="itemcount" type="number" autocomplete="off"
-               value="<?php echo Summoner::ifset($TemplateData['editData'], 'itemcount'); ?>"/>
-
-        <label for="price">Price</label>
-        <input name="fdata[price]" id="price" type="number" autocomplete="off"
-               value="<?php echo Summoner::ifset($TemplateData['editData'], 'price'); ?>"/>
-
-        <label for="catalog">Catalog</label>
-        <input name="fdata[catalog]" id="catalog" type="text" list="catalogList" autocomplete="off"
-               value="<?php echo Summoner::ifset($TemplateData['editData'], 'catalog'); ?>"/>
-        <datalist id="catalogList">
-            <option>Rewe</option>
-            <option>Lidl</option>
-        </datalist>
-
-        <input type="submit" class="tui-button" value="Save" name="submitForm" />
-    </fieldset>
-</form>
diff --git a/webroot/view/entry/entry.php b/webroot/view/entry/entry.php
deleted file mode 100644 (file)
index 0cf5b3b..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-require_once 'lib/item.class.php';
-$Item = new Item($DB);
-
-$_id = false;
-if(isset($_GET['id']) && !empty($_GET['id'])) {
-    $_id = trim($_GET['id']);
-    $_id = Summoner::validate($_id,'nospace') ? $_id : false;
-}
-
-$TemplateData['pageTitle'] = 'New item';
-if(!empty($_id)) {
-    $TemplateData['pageTitle'] = 'Edit item';
-}
-
-$TemplateData['editData'] = array();
-
-$TemplateData['message']['content'] = "";
-$TemplateData['message']['status'] = "";
-
-if(isset($_POST['fdata']) && !empty($_POST['fdata']) && isset($_POST['submitForm'])) {
-    $fdata = $_POST['fdata'];
-    if (!empty($fdata)) {
-
-    } else {
-        $TemplateData['message']['content'] = "Collection could not be loaded.";
-        $TemplateData['message']['status'] = "error";
-    }
-}
diff --git a/webroot/view/item/item.html b/webroot/view/item/item.html
new file mode 100644 (file)
index 0000000..729a382
--- /dev/null
@@ -0,0 +1,61 @@
+<form method="post">
+    <fieldset>
+        <label for="receipt">Receipt* <small>Just leave it blank to create a new based on data and market name.</small></label>
+        <input name="fdata[receipt]" id="receipt" type="text" list="receiptList" autocomplete="off" required
+               value="<?php echo Summoner::ifset($TemplateData['editData'], 'receipt'); ?>" />
+        <datalist id="receiptList">
+            <option>Rewe</option>
+            <option>Lidl</option>
+        </datalist>
+
+        <label for="receiptdate">Date and time*</label>
+        <input name="fdata[receiptdate]" id="receiptdate" type="datetime-local" autocomplete="off" required
+               value="<?php echo Summoner::ifset($TemplateData['editData'], 'receiptdate'); ?>" />
+
+        <label for="market">Market*</label>
+        <input name="fdata[market]" id="market" type="text" list="marketList" autocomplete="off" required
+               value="<?php echo Summoner::ifset($TemplateData['editData'], 'market'); ?>" />
+        <datalist id="marketList">
+            <option>Rewe</option>
+            <option>Lidl</option>
+        </datalist>
+
+        <label for="product">Product*</label>
+        <input name="fdata[product]" id="product" type="text" list="productList" autocomplete="off" required
+               value="<?php echo Summoner::ifset($TemplateData['editData'], 'product'); ?>"/>
+        <datalist id="productList">
+            <option>Rewe</option>
+            <option>Lidl</option>
+        </datalist>
+
+        <label for="manufacturer">Manufacturer*</label>
+        <input name="fdata[manufacturer]" id="manufacturer" type="text" list="manufacturerList" autocomplete="off" required
+               value="<?php echo Summoner::ifset($TemplateData['editData'], 'manufacturer'); ?>"/>
+        <datalist id="manufacturerList">
+            <option>Rewe</option>
+            <option>Lidl</option>
+        </datalist>
+
+        <label for="weight">Weight(g)</label>
+        <input name="fdata[weight]" id="weight" type="number" autocomplete="off"
+               value="<?php echo Summoner::ifset($TemplateData['editData'], 'weight'); ?>"/>
+
+        <label for="itemcount">Itemcount</label>
+        <input name="fdata[itemcount]" id="itemcount" type="number" autocomplete="off"
+               value="<?php echo Summoner::ifset($TemplateData['editData'], 'itemcount'); ?>"/>
+
+        <label for="price">Price*</label>
+        <input name="fdata[price]" id="price" type="number" autocomplete="off" required
+               value="<?php echo Summoner::ifset($TemplateData['editData'], 'price'); ?>"/>
+
+        <label for="catalog">Catalog</label>
+        <input name="fdata[catalog]" id="catalog" type="text" list="catalogList" autocomplete="off"
+               value="<?php echo Summoner::ifset($TemplateData['editData'], 'catalog'); ?>"/>
+        <datalist id="catalogList">
+            <option>Rewe</option>
+            <option>Lidl</option>
+        </datalist>
+
+        <input type="submit" class="tui-button" value="Save" name="submitForm" />
+    </fieldset>
+</form>
diff --git a/webroot/view/item/item.php b/webroot/view/item/item.php
new file mode 100644 (file)
index 0000000..930332f
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+require_once 'lib/item.class.php';
+$Item = new Item($DB);
+
+$_id = false;
+if(isset($_GET['id']) && !empty($_GET['id'])) {
+    $_id = trim($_GET['id']);
+    $_id = Summoner::validate($_id,'nospace') ? $_id : false;
+}
+
+$TemplateData['pageTitle'] = 'New item';
+if(!empty($_id)) {
+    $TemplateData['pageTitle'] = 'Edit item';
+}
+
+$TemplateData['editData'] = array();
+
+$TemplateData['message']['content'] = "";
+$TemplateData['message']['status'] = "";
+
+if(isset($_POST['fdata']) && !empty($_POST['fdata']) && isset($_POST['submitForm'])) {
+    $fdata = $_POST['fdata'];
+    if (!empty($fdata)) {
+
+               var_dump($fdata);
+
+    } else {
+        $TemplateData['message']['content'] = "Collection could not be loaded.";
+        $TemplateData['message']['status'] = "error";
+    }
+}