diff --git a/www/css/index.css b/www/css/index.css index c70666f..4a85f77 100644 --- a/www/css/index.css +++ b/www/css/index.css @@ -98,6 +98,9 @@ body.dollars span.price::before { body.dollars span.price::after { content: ''; } +span.recipeItemAmount::after { + content: 'x'; +} .subtotal { font-weight: bold; diff --git a/www/plan/do.php b/www/plan/do.php index 586e54b..f5a9076 100644 --- a/www/plan/do.php +++ b/www/plan/do.php @@ -90,7 +90,11 @@ if(!empty($data) && isset($user_id)){ returns("Missing a value: $temp", 1); } - if( ($itemID = addItem($data['storeID'], $data['name'], $data['price'])) !== false ){ + if(!isset($data['amount'])){ + $data['amount'] = 1; + } + + if( ($itemID = addItem($data['storeID'], $data['name'], $data['price'], $data['amount'])) !== false ){ returns($itemID); } else { @@ -370,13 +374,13 @@ function deleteStore($storeID, $storeName, $itemsLength){ return false; } -function addItem($storeID, $name, $price){ +function addItem($storeID, $name, $price, $amount){ global $db, $spaceID; $verifyUserOwnershipSQL = "SELECT plan_store_id FROM plan_store WHERE `space_id` = '$spaceID' AND plan_store_id = '$storeID'"; - $insertItemSQL = "INSERT INTO plan_store_item (`plan_store_id`, `pos`, `name`, `price`) - SELECT ($verifyUserOwnershipSQL), count(0)+1, '$name', $price FROM plan_store_item WHERE plan_store_id = '$storeID';"; + $insertItemSQL = "INSERT INTO plan_store_item (`plan_store_id`, `pos`, `name`, `price`, `amount`) + SELECT ($verifyUserOwnershipSQL), count(0)+1, '$name', $price, $amount FROM plan_store_item WHERE plan_store_id = '$storeID';"; if($db->query($insertItemSQL)){ return $db->insert_id; @@ -418,7 +422,7 @@ function moveItem($storeID, $itemID, $afterID){ if($sameStoreCheck = $db->query($sameStoreCheckSQL)){ $stores = $sameStoreCheck->fetch_array(); - if($stores[0] != $stores[1]){ + if(isset($stores[1]) && $stores[0] != $stores[1]){ // DIFFERENT STORES $storeID = $stores[1]; $differentStoreAddSQL = ", plan_store_id = $storeID"; diff --git a/www/plan/index.php b/www/plan/index.php index 629bf24..fbc0712 100644 --- a/www/plan/index.php +++ b/www/plan/index.php @@ -28,15 +28,55 @@
Space subtotal: 00.00

-

- +
+ + + + + + \ No newline at end of file diff --git a/www/plan/plan.js b/www/plan/plan.js index 4cd33a8..1e671e7 100644 --- a/www/plan/plan.js +++ b/www/plan/plan.js @@ -27,7 +27,7 @@ class Store { html += "
"; html += " "; html += " "; @@ -203,19 +203,20 @@ class Store { } } - addItem(text, price){ + addItem(text, price, amount){ + amount = amount || 1; if(text.length > 0){ if(this.storeID === null){ - this.getStoreID().done(json => { this.addItem(text, price); }); + this.getStoreID().done(json => { this.addItem(text, price, amount); }); return $.ajax(); } let that = this; - return ajaxReq({ plan: 'addItem', storeID: this.storeID, name: text, price: price }) + return ajaxReq({ plan: 'addItem', storeID: this.storeID, name: text, price: price, amount: amount }) .done(json => { - return that.addItemHtml(text, price, json['data']); + return that.addItemHtml(text, price, json['data'], amount); }); } @@ -233,6 +234,7 @@ class Store { let html = "\n"; html += "
  • "; // draggable='true' + // html += " "; html += " "; html += " "+text+""; @@ -524,13 +526,10 @@ class Store { var stores = []; $("#stores").html(""); -$("#addStore").click(ev => { - stores.push(new Store()); -}); - $("#refreshAll").on('click', ev => { $("#stores").css('height', $("#stores").height()); $(".tooltip").remove(); + $(".elemHolder").remove(); getStores(spaceID).done(json => { $("#stores").css('height', ''); }); }); diff --git a/www/webdata/init.php b/www/webdata/init.php index bd6a01f..8bd802f 100644 --- a/www/webdata/init.php +++ b/www/webdata/init.php @@ -12,6 +12,15 @@ if(!isset($config) || empty($config)){ $projectRoot = $config["general"]["projectRoot"]; +function getConfig($val, $group = "general"){ + global $config; + + if(isset($config[$group][ $val ])){ + return $config[$group][$val]; + } + return false; +} + function database(){ global $config; diff --git a/www/webdata/setup.php b/www/webdata/setup.php index 3726499..2366fd0 100644 --- a/www/webdata/setup.php +++ b/www/webdata/setup.php @@ -1,5 +1,15 @@ multi_query($sql); + if($error = $db->error){ + $err[] = $error; + } + else { + $msg[] = "Database tables are setup/reset."; + } + } + elseif (isset($_POST['recipeTables'])){ + $db->multi_query($recipeSQL); + if($error = $db->error){ + $err[] = $error; + } + else { + $msg[] = "Recipe tables are setup/reset."; + } + } + elseif (isset($_POST['goProject'])){ + header("Location: ".getConfig('projectRoot')."/"); + } + + $db->close(); +} + +?> + + + + + + Setup + + + + +
    +

    Setup

    + $e
    "; + } + } + if(!empty($msg)){ + foreach ($msg as $m) { + echo "
    $m
    "; + } + } + + if(isset($fatalErr)){ + die(); + } + ?> +
    + +

    Configuration-file is missing or lacks content. Fill out the data here:

    +

    Users Database

    +

    +

    +

    +

    + + + +

    +

    +
    +

    +
    + + \ No newline at end of file