我的系统中有两种单独的形式,一种用于添加新产品,另一种用于更新所添加产品的数量。我想将这两种形式合并为一种形式。我想将更新库存或产品数量表单添加到添加新产品表单中,以便在添加新产品时可以包含数量。数量功能适用于不同的商店。下面是我的代码。商店=出口。我正在使用Codeigniter。
add_product.php
<?php
require_once 'includes/header.php';
?>
<style type="text/css">
.fileUpload {
position: relative;
overflow: hidden;
border-radius: 0px;
margin-left: -4px;
margin-top: -2px;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 0;
padding: 0;
font-size: 20px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
</style>
<script type="text/javascript">
$(document).ready(function(){
document.getElementById("uploadBtn").onchange = function () {
document.getElementById("uploadFile").value = this.value;
};
});
</script>
<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><?php echo $lang_add_product; ?></h1>
</div>
</div><!--/.row-->
<form action="<?=base_url()?>products/insertProduct" method="post" enctype="multipart/form-data">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-body">
<?php
if (!empty($alert_msg)) {
$flash_status = $alert_msg[0];
$flash_header = $alert_msg[1];
$flash_desc = $alert_msg[2];
if ($flash_status == 'failure') {
?>
<div class="row" id="notificationWrp">
<div class="col-md-12">
<div class="alert bg-warning" role="alert">
<i class="icono-exclamationCircle" style="color: #FFF;"></i>
<?php echo $flash_desc; ?> <i class="icono-cross" id="closeAlert" style="cursor: pointer; color: #FFF; float: right;"></i>
</div>
</div>
</div>
<?php
}
if ($flash_status == 'success') {
?>
<div class="row" id="notificationWrp">
<div class="col-md-12">
<div class="alert bg-success" role="alert">
<i class="icono-check" style="color: #FFF;"></i>
<?php echo $flash_desc; ?> <i class="icono-cross" id="closeAlert" style="cursor: pointer; color: #FFF; float: right;"></i>
</div>
</div>
</div>
<?php
}
}
?>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label><?php echo $lang_product_code; ?> <span style="color: #F00">*</span></label>
<input type="text" name="code" class="form-control" maxlength="250" autofocus required autocomplete="off" />
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label><?php echo $lang_product_name; ?> <span style="color: #F00">*</span></label>
<input type="text" name="name" class="form-control" maxlength="250" required autocomplete="off" />
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label><?php echo $lang_product_category; ?> <span style="color: #F00">*</span></label>
<select name="category" class="form-control" required>
<option value=""><?php echo $lang_select_product_category; ?></option>
<?php
$catData = $this->Constant_model->getDataOneColumn('category', 'status', '1');
for ($c = 0; $c < count($catData); ++$c) {
$cat_id = $catData[$c]->id;
$cat_name = $catData[$c]->name; ?>
<option value="<?php echo $cat_id; ?>"><?php echo $cat_name; ?></option>
<?php
}
?>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label><?php echo $lang_purchase_price; ?> (<?php echo $lang_cost; ?>) <span style="color: #F00">*</span></label>
<input type="text" name="purchase" class="form-control" maxlength="250" autofocus required autocomplete="off" />
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label><?php echo $lang_retail_price; ?> (<?php echo $lang_price; ?>) <span style="color: #F00">*</span></label>
<input type="text" name="retail" class="form-control" maxlength="250" required autocomplete="off" />
</div>
</div>
<!-------------------------- Disabled Image Function -------------------------
<div class="col-md-4">
<div class="form-group">
<label><?php echo $lang_product_image; ?> <span style="color: #F00">*</span></label>
<br />
<input id="uploadFile" readonly style="height: 40px; width: 230px; border: 1px solid #ccc" />
<div class="fileUpload btn btn-primary" style="padding: 9px 12px;">
<span><?php echo $lang_browse; ?></span>
<input id="uploadBtn" name="uploadFile" type="file" class="upload" />
</div>
</div>
</div>
<!-------------------------- END Disabled Image Function ------------------------->
<div class="col-md-4">
<!-------------------------- Start of add_qty_function ------------------------->**<!--- My added code is here ---->
<div class="form-group">
<label><?php echo $lang_product_outlet; ?> <span style="color: #F00">*</span></label>
<select name="category" class="form-control" required>
<option value=""><?php echo $lang_select_product_inventory_outlet; ?></option>
<?php
if ($user_role == 1) {
$outletData = $this->Constant_model->getDataOneColumnSortColumn('outlets', 'status', '1', 'name', 'ASC');
} else {
$outletData = $this->Constant_model->getDataOneColumn('outlets', 'id', "$user_outlet");
}
for ($t = 0; $t < count($outletData); ++$t) {
$outlet_id = $outletData[$t]->id;
$outlet_name = $outletData[$t]->name; ?>
<option value="<?php echo $outlet_id; ?>"><?php echo $outlet_name; ?></option>
<?php
}
?>
</select>
</div>
<!-------------------------- End of add_qty_function ------------------------->
</div>**
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<input type="text" class="form-control" name="qty_<?php echo $outlet_id; ?>" value="0" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<!--// <input type="hidden" name="pcode" value="<?php echo $pcode; ?>" /> -->
<button class="btn btn-primary"> <?php echo $lang_add; ?> </button>
</div>
</div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
</div>
</div><!-- Panel Body // END -->
</div><!-- Panel Default // END -->
<a href="<?=base_url()?>products/list_products" style="text-decoration: none;">
<div class="btn btn-success" style="background-color: #999; color: #FFF; padding: 0px 12px 0px 2px; border: 1px solid #999;">
<i class="icono-caretLeft" style="color: #FFF;"></i><?php echo $lang_back; ?>
</div>
</a>
</div><!-- Col md 12 // END -->
</div><!-- Row // END -->
</form>
<br /><br /><br /><br /><br />
</div><!-- Right Colmn // END -->
<?php
require_once 'includes/footer.php';
?>
我已经设法编辑前端以包括选择和添加数量所需的输入,但是尽管我没有看到错误,但该功能无法正常工作。当我添加具有相应数量的新产品时,数量仍然为零
Inventory_detail.php(添加产品数量);
<?php
require_once 'includes/header.php';
?>
<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><?php echo $lang_inventory_for_product; ?> : <?php echo $pcode; ?> | <?php echo $lang_name; ?></h1>
</div>
</div><!--/.row-->
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-body">
<h1 class="page-header" style="margin-top: 0px; padding-bottom: 4px; font-size: 30px; margin: 0px 0 11px; color: #0079c0;">
<?php echo $lang_inventory_by_outlet; ?>
</h1>
<div class="row" style="padding-top: 10px; padding-bottom: 10px;">
<div class="col-md-3"><b style="color: #0079c0; letter-spacing: 0.2px; font-size: 17px;"><?php echo $lang_outlets; ?></b></div>
<div class="col-md-9"><b style="color: #0079c0; letter-spacing: 0.2px; font-size: 17px;"><?php echo $lang_current_inventory_qty; ?></b></div>
</div>
<?php
$outletData = $this->Constant_model->getDataOneColumnSortColumn('outlets', 'status', '1', 'name', 'ASC');
for ($t = 0; $t < count($outletData); ++$t) {
$outlet_id = $outletData[$t]->id;
$outlet_name = $outletData[$t]->name; ?>
<div class="row" style="padding-top: 10px; padding-bottom: 10px;">
<div class="col-md-3" style="font-size: 16px;">
<?php echo $outlet_name; ?>
</div>
<div class="col-md-9" style="font-size: 16px;">
<?php
$invQty = 0;
$invQtyData = $this->Constant_model->getDataTwoColumn('inventory', 'product_code', $pcode, 'outlet_id', $outlet_id);
if (count($invQtyData) > 0) {
$invQty = $invQtyData[0]->qty;
}
echo $invQty; ?>
</div>
</div>
<?php
}
?>
</div><!-- Panel Body // END -->
</div><!-- Panel Default // END -->
<?php
if ($user_role < 3) {
?>
<form action="<?=base_url()?>inventory/updateInventoryQty" method="post" onsubmit="return confirm('Do you want to update Inventory?')">
<div class="panel panel-default">
<div class="panel-body">
<?php
if (!empty($alert_msg)) {
$flash_status = $alert_msg[0];
$flash_header = $alert_msg[1];
$flash_desc = $alert_msg[2];
if ($flash_status == 'failure') {
?>
<div class="row" id="notificationWrp">
<div class="col-md-12">
<div class="alert bg-warning" role="alert">
<i class="icono-exclamationCircle" style="color: #FFF;"></i>
<?php echo $flash_desc; ?> <i class="icono-cross" id="closeAlert" style="cursor: pointer; color: #FFF; float: right;"></i>
</div>
</div>
</div>
<?php
}
if ($flash_status == 'success') {
?>
<div class="row" id="notificationWrp">
<div class="col-md-12">
<div class="alert bg-success" role="alert">
<i class="icono-check" style="color: #FFF;"></i>
<?php echo $flash_desc; ?> <i class="icono-cross" id="closeAlert" style="cursor: pointer; color: #FFF; float: right;"></i>
</div>
</div>
</div>
<?php
}
} ?>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<h1 class="page-header" style="margin-top: 0px; padding-bottom: 4px; font-size: 30px; margin: 0px 0 11px; color: #0079c0; text-align: center;">
<?php echo $lang_update_inventory_by_outlet; ?>
</h1>
<div class="row" style="padding-top: 10px; padding-bottom: 10px; border-bottom: 1px solid #eee;">
<div class="col-md-6"><b style="color: #0079c0; letter-spacing: 0.2px; font-size: 17px;"><?php echo $lang_outlets; ?></b></div>
<div class="col-md-6"><b style="color: #0079c0; letter-spacing: 0.2px; font-size: 17px;"><?php echo $lang_quantity; ?></b></div>
</div>
<?php
if ($user_role == 1) {
$outletData = $this->Constant_model->getDataOneColumnSortColumn('outlets', 'status', '1', 'name', 'ASC');
} else {
$outletData = $this->Constant_model->getDataOneColumn('outlets', 'id', "$user_outlet");
}
for ($t = 0; $t < count($outletData); ++$t) {
$outlet_id = $outletData[$t]->id;
$outlet_name = $outletData[$t]->name; ?>
<div class="row" style="padding-top: 10px; padding-bottom: 10px; border-bottom: 1px solid #eee;">
<div class="col-md-6" style="padding-top: 10px; font-size: 15px;">
<?php echo $outlet_name; ?>
</div>
<div class="col-md-6">
<input type="text" class="form-control" name="qty_<?php echo $outlet_id; ?>" value="0" />
</div>
</div>
<?php
unset($outlet_id);
unset($outlet_name);
} ?>
<div class="row" style="padding-top: 10px; padding-bottom: 10px;">
<div class="col-md-12" style="text-align: center; padding-top: 10px;">
<input type="hidden" name="pcode" value="<?php echo $pcode; ?>" />
<button class="btn btn-primary" style="padding: 8px 30px; font-size: 18px;">
<?php echo $lang_update; ?>
</button>
</div>
</div>
</div>
<div class="col-md-2"></div>
</div>
</div>
</div>
</form>
<?php
}
?>
<a href="<?=base_url()?>inventory/view" style="text-decoration: none;">
<div class="btn btn-success" style="background-color: #999; color: #FFF; padding: 0px 12px 0px 2px; border: 1px solid #999;">
<i class="icono-caretLeft" style="color: #FFF;"></i><?php echo $lang_back; ?>
</div>
</a>
</div><!-- Col md 12 // END -->
</div><!-- Row // END -->
<br /><br /><br /><br /><br />
</div><!-- Right Colmn // END -->
<?php
require_once 'includes/footer.php';
?>
我是php新手,请协助我。