hi,
I am trying to write a little code for partpayment for customers, but i am having problem for the outstanding balance , as i am considering when the customer does not have any balance to pay, or want to clear the balance and also while shopping. The point i am confused and dont know what to do also tried all my logic is when the customers is new and currently shopping i would like the outstanding to be 0, and when they are on a new shopping it should be populated with the to balance of the previous shopping, any ideas please.
<div class="primary">
<div class="action-box rounded">
<div class="titlebar">
<h2>AMOUNT</h2>
<!--COMMENT OUT<a href='totalprice.php'>Update</a>COMENT OUT-->
</div>
<div class="listbar">
<form action='orderpplac.php' method='Post' class='shlistbar'>
<table border='1'>
<?php
//echo "$totalprice";
//echo $totalprice;
?>
<tr>
<th>ORDER AMOUNT</th>
<th><?php
echo $totalprice; ?></th>
</tr>
<tr>
<th>PART PAYMENT </th>
<th><?php
$partpayment = (0.7 * $totalprice);
echo $partpayment; ?></th>
</tr>
<tr>
<th>OUTSTANDING</th>
<th><?php
?></th>
</tr>
<tr>
<th>CREDIT </th>
<th><?php
$credit = (0 + $customercredit);
echo $credit; ?></th>
</tr>
<tr>
<th>TO BALANCE</th>
<th><?php
$tobal = ($totalprice-$partpayment);
echo $tobal; ?></th>
</tr>
<tr>
<th>TO PAY NOW</th>
<th><?php
if ($tobal= 0)
{ $paynow = $outstanding;}
else
{
$paysum = ($partpayment+$outstanding);
$paynow = ($paysum-$credit);
}
echo $paynow; ?></th>
</tr>
<!--COMMENT OUTClose table and form COMMENT OUT-->
</table>
<input type='submit' name='submit1' value='UPDATE' />
<input type='submit' name='submit2' value='SUBMIT' />
</form>
so far still stucked with this , am having problem with the “outstanding”, and “to paynow” any suggestion
<div class="primary">
<div class="action-box rounded">
<div class="titlebar">
<h2>AMOUNT</h2>
<!--COMMENT OUT<a href='totalprice.php'>Update</a>COMENT OUT-->
</div>
<div class="listbar">
<form action='orderpplac.php' method='Post' class='shlistbar'>
<table border='1'>
<?php
//echo "$totalprice";
//echo $totalprice;
?>
<tr>
<th>ORDER AMOUNT</th>
<th><?php
echo $totalprice; ?></th>
</tr>
<tr>
<th>PART PAYMENT </th>
<th><?php
$partpayment = (0.7 * $totalprice);
echo $partpayment; ?></th>
</tr>
<tr>
<th>CREDIT </th>
<th><?php
$credit = (0 + $customercredit);
echo $credit; ?></th>
</tr>
<tr>
<th>TO BALANCE</th>
<th><?php
$tobal = ($totalprice-$partpayment);
echo $tobal;
if ($tobal!=0)
{ $queryreg = mysql_query("
INSERT INTO outstanding VALUES ('','{$_SESSION['username']}','$tobal')
")or die(mysql_error());}
else{
}
?></th>
</tr>
<tr>
<th>OUTSTANDING</th>
<th><?php
if($totalprice=0){
$outstanding=0;}
else
{$osresult = mysql_query("SELECT * FROM outstanding WHERE Uname = '{$_SESSION['username']}'") or die(mysql_error());
while ($row = mysql_fetch_assoc($osresult))
$outstanding = $row['outstandingbal']; }
echo $outstanding; ?></th>
</tr>
<tr>
<th>TO PAY NOW</th>
<th><?php
if ($tobal= 0)
{ $paynow = $outstanding;}
else
{
$paysum = ($partpayment+$outstanding);
$paynow = ($paysum-$credit);
}
echo $paynow; ?></th>
</tr>
</table>
</form>
Shouldn’t that read
$outstanding += $row['outstandingbal'];
so that gives the total of all outstanding balances?
I’m not exactly clear on what each of these variables, might help to explain the background in a bit more detail.
Thanks droopsnoot, i have been a lil busy, i am trying to make the outstanding bal to display the correct amount outstanding, taking into consideration previous transaction if there was any .thanks
this are the variable details
$totalprice; order amount , the amount of the goods the customer wants to purchase
$partpayment: part payment, the percentage of the order amount the customer will pay
$credit: credit, if the customer is owed money
$customercredit: the variable thru which the customer is credited
$tobal": to balance, the amount left of that particular order
outstanding table has four columns the id ,Uname ,outstandingbal,obal
$paynow: to pay now the total the customer should pay now.
<div class="listbar">
<form action='orderpplac.php' method='Post' class='shlistbar'>
<table border='1'>
<?php
//echo "$totalprice";
//echo $totalprice;
?>
<tr>
<th>ORDER AMOUNT</th>
<th><?php
echo $totalprice; ?></th>
</tr>
<tr>
<th>PART PAYMENT </th>
<th><?php
$partpayment = (0.7 * $totalprice);
echo $partpayment; ?></th>
</tr>
<tr>
<th>CREDIT </th>
<th><?php
$credit = (0 + $customercredit);
echo $credit; ?></th>
</tr>
<tr>
<th>TO BALANCE</th>
<th><?php
$tobal = ($totalprice-$partpayment);
echo $tobal;
if ($tobal!=0)
{ $queryreg = mysql_query("
INSERT INTO outstanding VALUES ('','{$_SESSION['username']}','$tobal','')
")or die(mysql_error());}
else{
}
?></th>
</tr>
<tr>
<th>OUTSTANDING</th>
<th><?php
echo $obal;
if($totalprice=0){
$queryreg = mysql_query("
UPDATE outstanding
SET obal={$outstanding}
WHERE obal='{$obal}'
AND
Uname = '{$_SESSION['username']}'
") or die(mysql_error());
$queryreg2 = mysql_query("
UPDATE outstanding
SET outstanding='0'
WHERE outstanding='{$outstanding}'
AND Uname = '{$_SESSION['username']}'
") or die(mysql_error());
}
echo $obal;
else
{} ?></th>
</tr>
<tr>
<th>TO PAY NOW</th>
<th><?php
if ($tobal= 0)
{ $paynow = $outstanding;}
else
{
$paysum = ($partpayment+$outstanding);
$paynow = ($paysum-$credit);
}
echo $paynow; ?></th>
</tr>
<!--COMMENT OUTClose table and form COMMENT OUT-->
</table>
</form>
Drummin
September 19, 2013, 9:58pm
5
You might need to add something like this so any account variables are set.
$customercredit = (isset($customercredit) ? $customercredit : 0);