SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: partpayment

  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    partpayment

    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.
    PHP Code:
    <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 
    = (+  $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 ($tobal0)
                 { 
    $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>

  2. #2
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    so far still stucked with this , am having problem with the "outstanding", and "to paynow" any suggestion


    PHP Code:
    <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 
    = (+  $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 ($tobal0)
                 { 
    $paynow =  $outstanding;}
                 else
                 { 
        
    $paysum = ($partpayment+$outstanding);
        
    $paynow = ($paysum-$credit);
        }
        
        echo 
    $paynow?></th>                
               </tr>

        </table>
      
        </form>

  3. #3
    SitePoint Addict
    Join Date
    Aug 2006
    Location
    Nantwich, Cheshire
    Posts
    359
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Shouldn't that read

    Code:
    $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.
    http://www.firenza.net - my homage to a car from the 1970s

  4. #4
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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.


    Code:
    <div class="listbar">
    
        <form action='orderpplac.php' method='Post' class='shlistbar'>
        <table border='1'>
    PHP Code:
    <?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 
    = (+  $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 ($tobal0)
                 { 
    $paynow =  $outstanding;}
                 else
                 { 
        
    $paysum = ($partpayment+$outstanding);
        
    $paynow = ($paysum-$credit);
        }
        
        echo 
    $paynow?></th>                
               </tr>
    Code:
      <!--COMMENT OUTClose table and form COMMENT OUT-->
    
        </table>
       
        </form>

  5. #5
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    668
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    You might need to add something like this so any account variables are set.
    PHP Code:
    $customercredit = (isset($customercredit) ? $customercredit 0); 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •