|
|
|
@ -36,10 +36,69 @@ if (!empty($VARS['id']) && !is_empty($VARS['id'])) {
|
|
|
|
|
// customer id is invalid, redirect to a version of the page that won't
|
|
|
|
|
// cause an error when pressing Save
|
|
|
|
|
header('Location: app.php?page=editcustomer');
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$pricing = [];
|
|
|
|
|
|
|
|
|
|
if ($editing) {
|
|
|
|
|
$pricing = $database->select('customer_pricing', ['itemid', 'price'], ['customerid' => $custdata['id']]);
|
|
|
|
|
for ($i = 0; $i < count($pricing); $i++) {
|
|
|
|
|
$pricing[$i]['item'] = $binstack->get('items', ['itemid', 'name', 'code1', 'code2', 'cost', 'price'], ['itemid' => $pricing[$i]['itemid']]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
<div class="modal fade" tabindex="-1" role="dialog" id="pricemodal">
|
|
|
|
|
<div class="modal-dialog modal-lg" role="document">
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
<div class="modal-header">
|
|
|
|
|
<h5 class="modal-title"><i class="fas fa-user-tag"></i> <?php lang("add customer price"); ?></h5>
|
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-body">
|
|
|
|
|
<div class="input-group">
|
|
|
|
|
<div class="input-group-prepend">
|
|
|
|
|
<span class="input-group-text px-2"><i class="fas fa-barcode"></i></span>
|
|
|
|
|
</div>
|
|
|
|
|
<input type="text" class="form-control" id="pricemodalitem" placeholder="<?php lang("barcode or search"); ?>" />
|
|
|
|
|
<div class="input-group-append">
|
|
|
|
|
<button class="btn btn-link" type="button" id="pricemodalsearch"><i class="fas fa-search"></i></button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="card mt-2">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h5 class="card-title"><i class="fas fa-box"></i> <?php lang("item"); ?></h5>
|
|
|
|
|
<p>
|
|
|
|
|
<?php lang("name"); ?>: <span id="pricemodalitemname">---</span><br />
|
|
|
|
|
<?php lang("cost"); ?>: <span id="pricemodalitemcost">---</span><br />
|
|
|
|
|
<?php lang("price"); ?>: <span id="pricemodalitemprice">---</span><br />
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h5 class="card-title"><i class="fas fa-user-tag"></i> <?php lang("customer price"); ?></h5>
|
|
|
|
|
<div class="input-group">
|
|
|
|
|
<div class="input-group-prepend">
|
|
|
|
|
<span class="input-group-text">$</span>
|
|
|
|
|
</div>
|
|
|
|
|
<input class="form-control" id="pricemodalcustomerprice" type="money" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-footer">
|
|
|
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?php lang("cancel"); ?></button>
|
|
|
|
|
<button type="button" class="btn btn-primary" id="pricemodalsave"><?php lang("save"); ?></button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<form role="form" action="action.php" method="POST">
|
|
|
|
|
<div class="card border-green">
|
|
|
|
|
<h3 class="card-header text-green">
|
|
|
|
@ -78,6 +137,55 @@ if (!empty($VARS['id']) && !is_empty($VARS['id'])) {
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<hr />
|
|
|
|
|
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h5 class="card-title"><?php lang("customer pricing"); ?></h5>
|
|
|
|
|
<div class="btn-toolbar">
|
|
|
|
|
<div class="btn btn-success" id="addcustomerpricebtn">
|
|
|
|
|
<i class="fas fa-plus"></i> <?php lang("add price"); ?>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<table class="table table-hover table-sm" id="pricingtable">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th data-priority="0"></th>
|
|
|
|
|
<th data-priority="1"><?php lang('actions'); ?></th>
|
|
|
|
|
<th data-priority="1"><?php lang("item"); ?></th>
|
|
|
|
|
<th data-priority="4"><?php lang("cost"); ?></th>
|
|
|
|
|
<th data-priority="3"><?php lang("normal price"); ?></th>
|
|
|
|
|
<th data-priority="2"><?php lang("customer price"); ?></th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
<?php
|
|
|
|
|
$i = 0;
|
|
|
|
|
foreach ($pricing as $p) {
|
|
|
|
|
?>
|
|
|
|
|
<tr data-itemid="<?php echo $p['itemid']; ?>">
|
|
|
|
|
<td></td>
|
|
|
|
|
<td>
|
|
|
|
|
<div class="btn btn-sm btn-danger deletepricebtn" data-itemid="<?php echo $p['itemid']; ?>"><i class="fas fa-trash"></i> <?php lang("delete"); ?></div>
|
|
|
|
|
</td>
|
|
|
|
|
<td>
|
|
|
|
|
<input type="hidden" name="pricing[<?php echo $i; ?>][item]" value="<?php echo $p['itemid']; ?>" />
|
|
|
|
|
<?php echo $p['item']['name']; ?>
|
|
|
|
|
</td>
|
|
|
|
|
<td><?php echo $p['item']['cost']; ?></td>
|
|
|
|
|
<td><?php echo $p['item']['price']; ?></td>
|
|
|
|
|
<td>
|
|
|
|
|
<input type="hidden" name="pricing[<?php echo $i; ?>][price]" value="<?php echo $p['price']; ?>" />
|
|
|
|
|
<?php echo $p['price']; ?>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<?php
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<input type="hidden" name="id" value="<?php echo htmlspecialchars($custdata['id']); ?>" />
|
|
|
|
|
<input type="hidden" name="action" value="editcustomer" />
|
|
|
|
|
<input type="hidden" name="source" value="customers" />
|
|
|
|
|