Php 如何使用angularjs在mysql中存储数学函数值?
我正在创建发票生成器。因为我想在我的数据库中存储总计、折扣和所有内容。 总额和折扣的计算如下Php 如何使用angularjs在mysql中存储数学函数值?,php,mysql,angularjs,Php,Mysql,Angularjs,我正在创建发票生成器。因为我想在我的数据库中存储总计、折扣和所有内容。 总额和折扣的计算如下 <tr ng-repeat="list in data"> <td> <label class="clabel">Subtotal</label> </td> <td ng-model="subtotal">{{list.sale_price*list.quantity}}</td> </tr
<tr ng-repeat="list in data">
<td>
<label class="clabel">Subtotal</label>
</td>
<td ng-model="subtotal">{{list.sale_price*list.quantity}}</td>
</tr>
<tr ng-repeat="list in data">
<td>
<label class="clabel">Tax(2%)</label>
</td>
<td ng-model="tax">{{((list.sale_price*list.quantity)*2)/100}}</td>
</tr>
<tr ng-repeat="list in data">
<td>
<label class="clabel">Discount(%)</label>
</td>
<td ng-model="discount">{{((list.sale_price*list.quantity)*list.discount)/100}}</td>
</tr>
<tr ng-repeat="list in data">
<td>
<label class="clabel">Total</label>
</td>
<td ng-model="total">{{((list.sale_price*list.quantity)+(((list.sale_price*list.quantity)*2)/100))-(((list.sale_price*list.quantity)*list.discount)/100)}}</td>
</tr>
<tr>
<td colspan="2">
<button class="btn btn-success" style="margin-left:400px;" ng-click="GenerateBill();updateAll()">Generate Invoice</button>
</td>
</tr>
请帮帮我…你可以试试这个
$scope.updateAll=function()
{
data={
subtotal:$scope.product.sale_prize*$scope.product.quantity,
tax:$scope.product.sale_prize * $scope.product.quantity*2/100,
discount:$scope.product.sale_prize * $scope.product.quantity*$scope.product.discount/100,
total:$scope.product.sale_prize * $scope.product.quantity+$scope.product.sale_prize * $scope.product.quantity*2/100-$scope.product.sale_prize *$scope.product.quantity* $scope.product.discount/100
}
$http.post("../pos_system/Widgets/updatedata.php?barc="+$scope.barc,data).success(function(data)
{
//do your stuff here;
});
}
在HTML部分进行此更改
<tr >
<td>
<label class="clabel">Subtotal</label>
</td>
<td><input type="text" class="cinput" placeholder="sale price" ng-value="list.sale_price*list.quantity" readonly="" />
</td>
</tr>
<tr >
<td>
<label class="clabel">Tax(2%)</label>
</td>
<td><input type="text" class="cinput" placeholder="sale price" ng-value="((list.sale_price*list.quantity)*2)/100" readonly="" />
</td>
</tr>
<tr>
<td>
<label class="clabel">Discount(%)</label>
</td>
<td>
<input type="text" class="cinput" placeholder="sale price" ng-value="((list.sale_price*list.quantity)*list.discount)/100" readonly="" />
</td>
</tr>
<tr >
<td>
<label class="clabel">Total</label>
</td>
<td >
<input type="text" class="cinput" placeholder="sale price" ng-value="((list.sale_price*list.quantity)+(((list.sale_price*list.quantity)*2)/100))-(((list.sale_price*list.quantity)*list.discount)/100)" readonly="" />
</td>
</tr>
<tr>
<td colspan="2">
<button class="btn btn-success" style="margin-left:400px;" ng-click="GenerateBill();updateAll()">Generate Invoice</button>
</td>
</tr>
小计
税款(2%)
折扣(%)
全部的
生成发票
如果您想让我们为您编写整个数据库层,那就太宽泛了。更不用说您还没有提供任何关于平台的信息。
<tr >
<td>
<label class="clabel">Subtotal</label>
</td>
<td><input type="text" class="cinput" placeholder="sale price" ng-value="list.sale_price*list.quantity" readonly="" />
</td>
</tr>
<tr >
<td>
<label class="clabel">Tax(2%)</label>
</td>
<td><input type="text" class="cinput" placeholder="sale price" ng-value="((list.sale_price*list.quantity)*2)/100" readonly="" />
</td>
</tr>
<tr>
<td>
<label class="clabel">Discount(%)</label>
</td>
<td>
<input type="text" class="cinput" placeholder="sale price" ng-value="((list.sale_price*list.quantity)*list.discount)/100" readonly="" />
</td>
</tr>
<tr >
<td>
<label class="clabel">Total</label>
</td>
<td >
<input type="text" class="cinput" placeholder="sale price" ng-value="((list.sale_price*list.quantity)+(((list.sale_price*list.quantity)*2)/100))-(((list.sale_price*list.quantity)*list.discount)/100)" readonly="" />
</td>
</tr>
<tr>
<td colspan="2">
<button class="btn btn-success" style="margin-left:400px;" ng-click="GenerateBill();updateAll()">Generate Invoice</button>
</td>
</tr>