Add item cost and sale price fields

master
Skylar Ittner 6 years ago
parent 5785f27c8c
commit ca09f9d346

@ -79,6 +79,16 @@ switch ($VARS['action']) {
} else if (!is_numeric($VARS['want'])) { } else if (!is_numeric($VARS['want'])) {
returnToSender('field_nan'); returnToSender('field_nan');
} }
if (is_empty($VARS['cost'])) {
$VARS['cost'] = null;
} else if (!is_numeric($VARS['cost'])) {
returnToSender('field_nan');
}
if (is_empty($VARS['price'])) {
$VARS['price'] = null;
} else if (!is_numeric($VARS['price'])) {
returnToSender('field_nan');
}
if (!$database->has('categories', ['catid' => $VARS['cat']])) { if (!$database->has('categories', ['catid' => $VARS['cat']])) {
returnToSender('invalid_category'); returnToSender('invalid_category');
} }
@ -103,6 +113,8 @@ switch ($VARS['action']) {
'locid' => $VARS['loc'], 'locid' => $VARS['loc'],
'qty' => $VARS['qty'], 'qty' => $VARS['qty'],
'want' => $VARS['want'], 'want' => $VARS['want'],
'cost' => $VARS['cost'],
'price' => $VARS['price'],
'userid' => $userid 'userid' => $userid
]; ];

Binary file not shown.

@ -0,0 +1,8 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
ALTER TABLE `items`
ADD COLUMN `cost` DECIMAL(10,2) NULL DEFAULT NULL AFTER `userid`,
ADD COLUMN `price` DECIMAL(10,2) NULL DEFAULT NULL AFTER `cost`;

@ -106,5 +106,9 @@ define("STRINGS", [
"ods file" => "ODS spreadsheet", "ods file" => "ODS spreadsheet",
"html file" => "HTML web page", "html file" => "HTML web page",
"itemid" => "Item ID", "itemid" => "Item ID",
"id" => "ID" "id" => "ID",
"item cost" => "Item cost",
"sale price" => "Sale price",
"cost" => "Cost",
"price" => "Price"
]); ]);

@ -70,7 +70,9 @@ if (!is_empty($VARS['search']['value'])) {
"catname[~]" => $VARS['search']['value'], "catname[~]" => $VARS['search']['value'],
"locname[~]" => $VARS['search']['value'], "locname[~]" => $VARS['search']['value'],
"code1[~]" => $VARS['search']['value'], "code1[~]" => $VARS['search']['value'],
"code2[~]" => $VARS['search']['value'] "code2[~]" => $VARS['search']['value'],
"cost[~]" => $VARS['search']['value'],
"price[~]" => $VARS['search']['value'],
]; ];
$where = $wherenolimit; $where = $wherenolimit;
$where["LIMIT"] = [$VARS['start'], $VARS['length']]; $where["LIMIT"] = [$VARS['start'], $VARS['length']];

@ -71,7 +71,9 @@ function getItemReport($filter = []) {
"userid", "userid",
"text1", "text1",
"text2", "text2",
"text3" "text3",
"cost",
"price"
], $filter ], $filter
); );
$header = [ $header = [
@ -83,6 +85,8 @@ function getItemReport($filter = []) {
lang("code 2", false), lang("code 2", false),
lang("quantity", false), lang("quantity", false),
lang("want", false), lang("want", false),
lang("cost", false),
lang("price", false),
lang("assigned to", false), lang("assigned to", false),
lang("description", false), lang("description", false),
lang("notes", false), lang("notes", false),
@ -105,6 +109,8 @@ function getItemReport($filter = []) {
$items[$i]["code2"], $items[$i]["code2"],
$items[$i]["qty"], $items[$i]["qty"],
$items[$i]["want"], $items[$i]["want"],
$items[$i]["cost"],
$items[$i]["price"],
$user, $user,
$items[$i]["text1"], $items[$i]["text1"],
$items[$i]["text2"], $items[$i]["text2"],

@ -1,5 +1,4 @@
<?php <?php
/* This Source Code Form is subject to the terms of the Mozilla Public /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -29,6 +28,8 @@ $itemdata = [
'text3' => '', 'text3' => '',
'qty' => 1, 'qty' => 1,
'want' => 0, 'want' => 0,
'cost' => 0.0,
'price' => 0.0,
'userid' => '']; 'userid' => ''];
$editing = false; $editing = false;
@ -62,6 +63,8 @@ if (!is_empty($VARS['id'])) {
'loccode', 'loccode',
'qty', 'qty',
'want', 'want',
'cost',
'price',
'userid' 'userid'
], [ ], [
'itemid' => $VARS['id'] 'itemid' => $VARS['id']
@ -76,23 +79,23 @@ if (!is_empty($VARS['id'])) {
<form role="form" action="action.php" method="POST"> <form role="form" action="action.php" method="POST">
<div class="card border-green"> <div class="card border-green">
<h3 class="card-header text-green"> <h3 class="card-header text-green">
<?php
if ($cloning) {
?>
<i class="fas fa-edit"></i> <?php lang2("cloning item", ['oitem' => htmlspecialchars($itemdata['name']), 'nitem' => "<span id=\"name_title\">" . htmlspecialchars($itemdata['name']) . "</span>"]); ?>
<?php
} else if ($editing) {
?>
<i class="fas fa-edit"></i> <?php lang2("editing item", ['item' => "<span id=\"name_title\">" . htmlspecialchars($itemdata['name']) . "</span>"]); ?>
<?php <?php
if ($cloning) { } else {
?>
<i class="fas fa-edit"></i> <?php lang2("cloning item", ['oitem' => htmlspecialchars($itemdata['name']), 'nitem' => "<span id=\"name_title\">" . htmlspecialchars($itemdata['name']) . "</span>"]); ?>
<?php
} else if ($editing) {
?>
<i class="fas fa-edit"></i> <?php lang2("editing item", ['item' => "<span id=\"name_title\">" . htmlspecialchars($itemdata['name']) . "</span>"]); ?>
<?php
} else {
?>
<i class="fas fa-edit"></i> <?php lang("adding item"); ?>
<?php
}
?> ?>
</h3> <i class="fas fa-edit"></i> <?php lang("adding item"); ?>
<?php
}
?>
</h3>
<div class="card-body"> <div class="card-body">
<div class="form-group"> <div class="form-group">
<label for="name"><i class="fas fa-cube"></i> <?php lang("name"); ?></label> <label for="name"><i class="fas fa-cube"></i> <?php lang("name"); ?></label>
@ -167,19 +170,34 @@ if (!is_empty($VARS['id'])) {
</div> </div>
<div class="row"> <div class="row">
<div class="col-12 col-sm-12 col-md-4"> <div class="col-12 col-md-3">
<div class="form-group">
<label for="cost"><i class="far fa-money-bill-alt"></i> <?php lang('item cost'); ?></label>
<input type="number" class="form-control" id="cost" name="cost" placeholder="0.00" step="0.01" value="<?php echo $itemdata['cost']; ?>" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<label for="price"><i class="fas fa-shopping-cart"></i> <?php lang('sale price'); ?></label>
<input type="number" class="form-control" id="price" name="price" placeholder="0.00" step="0.01" value="<?php echo $itemdata['price']; ?>" />
</div>
</div>
<div class="col-12 col-md-6">
<div class="form-group"> <div class="form-group">
<label for="info1"><i class="fas fa-info"></i> <?php lang("description"); ?></label> <label for="info1"><i class="fas fa-info"></i> <?php lang("description"); ?></label>
<textarea class="form-control" id="info1" name="text1"><?php echo htmlspecialchars($itemdata['text1']); ?></textarea> <textarea class="form-control" id="info1" name="text1"><?php echo htmlspecialchars($itemdata['text1']); ?></textarea>
</div> </div>
</div> </div>
<div class="col-12 col-sm-12 col-md-4"> </div>
<div class="row">
<div class="col-12 col-sm-12 col-md-6">
<div class="form-group"> <div class="form-group">
<label for="info2"><i class="fas fa-sticky-note"></i> <?php lang("notes"); ?></label> <label for="info2"><i class="fas fa-sticky-note"></i> <?php lang("notes"); ?></label>
<textarea class="form-control" id="info2" name="text2"><?php echo htmlspecialchars($itemdata['text2']); ?></textarea> <textarea class="form-control" id="info2" name="text2"><?php echo htmlspecialchars($itemdata['text2']); ?></textarea>
</div> </div>
</div> </div>
<div class="col-12 col-sm-12 col-md-4"> <div class="col-12 col-sm-12 col-md-6">
<div class="form-group"> <div class="form-group">
<label for="info3"><i class="fas fa-comments"></i> <?php lang("comments"); ?></label> <label for="info3"><i class="fas fa-comments"></i> <?php lang("comments"); ?></label>
<textarea class="form-control" id="info3" name="text3"><?php echo htmlspecialchars($itemdata['text3']); ?></textarea> <textarea class="form-control" id="info3" name="text3"><?php echo htmlspecialchars($itemdata['text3']); ?></textarea>

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
.banner-image { .banner-image {
max-height: 100px; max-height: 100px;
margin: 2em auto; margin: 2em auto;

Loading…
Cancel
Save