<?php
session_start();
require_once "main.php";
//ini_set('display_errors', 1);
//error_reporting(E_ALL);
//global $db;
/*
$tx3='';
$sql = 'Select * from bill_history where id>0 order by cus_id,date';  
$st = $db->prepare($sql);
$st->execute();

$result = $st->fetchAll();
print_r($result);
for ($i = 0; $i < count($result); $i++) {
    $tx2 = $result[$i]['cus_id'];
    if ($tx2==$tx3) {
    if ($result[$i]['bamount']>0) {
    $tx1 = $tx1 - $result[$i]['bamount'];
    } else {
    $tx1 = $tx1 + $result[$i]['pamount'];    
    }
    } else {
    $tx3=$tx2;
    if ($result[$i]['bamount']>0) {
    $tx1 = $result[$i]['balance'] - $result[$i]['bamount'];
    } else {
    $tx1 = $result[$i]['balance'] + $result[$i]['pamount'];    
    }
    }
    $sql = 'update bill_history set balance="'.$tx1.'" where id="'.$result[$i]['id'].'"';
    $st = $db->prepare($sql);
    $st->execute();
    echo $sql; 
}
 */
echo 'finished';


?>
