0

hello guys ... i have a problem regarding on this error
1. Undefined index: d1 in C:\xampp\htdocs\final year project 2\collection.php on line 104
2. Undefined index: d1 in C:\xampp\htdocs\final year project 2\collection.php on line 120
3.Notice: Undefined index: d1 in C:\xampp\htdocs\final year project 2\collection.php on line 163
4.Notice: Undefined index: d2 in C:\xampp\htdocs\final year project 2\collection.php on line 164
my full line of code is this....

<?php

?>
<html>
<head>
<title>
final year project
</title>
<link href="style.css" media="screen" rel="stylesheet" type="text/css" />
<link href="menu.css" media="screen" rel="stylesheet" type="text/css" />
<!--sa poip up-->
<script src="argiepolicarpio.js" type="text/javascript" charset="utf-8"></script>
<script src="js/application.js" type="text/javascript" charset="utf-8"></script>
<link href="src/facebox.css" media="screen" rel="stylesheet" type="text/css" />
<script src="lib/jquery.js" type="text/javascript"></script>
<script src="src/facebox.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="tcal.css" />
<script type="text/javascript" src="tcal.js"></script>
<script language="javascript">
function Clickheretoprint()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=700, height=400, left=100, top=25"; 
  var content_vlue = document.getElementById("content").innerHTML; 

  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('</head><body onLoad="self.print()" style="width: 700px; font-size:11px; font-family:arial; font-weight:normal;">');          
   docprint.document.write(content_vlue); 
   docprint.document.close(); 
   docprint.focus(); 
}
</script>
</head>
<body background="bg.jpg">
<p><h2 align="center"><font face="Elephant" size=6 color="yellow">STRAWBERRY ACCOUNTING WEBSITE</font></h2></p>
<script type="text/javascript">
tday  =new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
tmonth=new Array("January","February","March","April","May","June","July","August","September","October","November","December");

function GetClock(){
d = new Date();
nday   = d.getDay();
nmonth = d.getMonth();
ndate  = d.getDate();
nyear = d.getYear();
nhour  = d.getHours();
nmin   = d.getMinutes();
nsec   = d.getSeconds();

if(nyear<1000) nyear=nyear+1900;

     if(nhour ==  0) {ap = " AM";nhour = 12;} 
else if(nhour <= 11) {ap = " AM";} 
else if(nhour == 12) {ap = " PM";} 
else if(nhour >= 13) {ap = " PM";nhour -= 12;}

if(nmin <= 9) {nmin = "0" +nmin;}
if(nsec <= 9) {nsec = "0" +nsec;}


document.getElementById('clockbox').innerHTML=""+tday[nday]+", "+tmonth[nmonth]+" "+ndate+", "+nyear+" "+nhour+":"+nmin+":"+nsec+ap+"";
setTimeout("GetClock()", 1000);
}
window.onload=GetClock;
</script>
<div id="clockbox"></div>

<center>
<div class="menu-bar">
    <ul id="menu-bar">
        <li class="active"><a href="home.php">Home</a></li>
        <li><a href="sales.php">ReportAnalysis</a>
            <ul>
                <li><a rel="facebox" href="select_customer.php">Customer Ledger</a></li>
                <li><a href="supplier.php">Suppliers</a></li>
                <li><a href="products.php">Products</a></li>
                <li><a href="#">Products Sub Menu 4</a></li>
            </ul>
        </li>
        <li><a href="accountreceivables.php">AccountPayable</a>
            <ul>
                <li><a href="customer.php">Customer</a></li>
                <li><a href="purchaseslist.php">list</a></li>
                <li><a href="collection.php">collection</a></li>
                <li><a href="#"></a></li>
            </ul>
        </li>
        <li><a href="#">About</a></li>
        <li><a href="logout.php">Logout</a>
        </li>
    </ul>
</div>
</center>

<div id="maintable"><div style="margin-top: -19px; margin-bottom: 21px;">
<br><a id="addd" href="home.php" style="float: none;">Back</a></br>
</div>
<form action="collection.php" method="get">
From : <input type="text" name="d1" class="tcal" value="" /> To: <input type="text" name="d2" class="tcal" value="" /> <input type="submit" value="Search"><a id="addd" href="javascript:Clickheretoprint()">Print</a>
</form>
<div class="content" id="content">
<div style="font-weight:bold; text-align:center;font-size:14px;margin-bottom: 15px;">
Collection Report from <?php echo $_GET['d1'] ?> to <?php echo $_GET['d2'] ?>
</div>
<table id="resultTable" data-responsive="table" style="text-align: left;">
    <thead>
        <tr>
            <th width="17%"> Transaction ID </th>
            <th width="8%"> Date </th>
            <th width="25%"> Customer Name </th>
            <th width="25%"> Invoice Number </th>
            <th width="15%"> Amount </th>
            <th width="10%"> Remarks </th>
        </tr>
    </thead>
    <tbody>

          <?php
                $d1=$_GET['d1'];
                $d2=$_GET['d2'];
                $result = $db->prepare("SELECT * FROM collection WHERE date BETWEEN :a AND :b");
                $result->bindParam(':a', $d1);
                $result->bindParam(':b', $d2);
                $result->execute();
                for($i=0; $row = $result->fetch(); $i++){
            ?>
            <tr class="record">
            <td>CTI-000<?php echo $row['transaction_id']; ?></td>
            <td><?php echo $row['date']; ?></td>
            <td><?php echo $row['name']; ?></td>
            <td><?php echo $row['invoice']; ?></td>
            <td><?php
            $dsdsd=$row['amount'];
            echo formatMoney($dsdsd, true);
            ?></td>
            <td><?php echo $row['remarks']; ?></td>
            </tr>
            <?php
                }
            ?>

    </tbody>
    <thead>
        <tr>
            <th colspan="4" style="border-top:1px solid #999999"> Total </th>
            <th colspan="2" style="border-top:1px solid #999999"> 
            <?php
                function formatMoney($number, $fractional=false) {
                    if ($fractional) {
                        $number = sprintf('%.2f', $number);
                    }
                    while (true) {
                        $replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
                        if ($replaced != $number) {
                            $number = $replaced;
                        } else {
                            break;
                        }
                    }
                    return $number;
                }
                $d1=$_GET['d1'];
                $d2=$_GET['d2'];
                $results = $db->prepare("SELECT sum(amount) FROM collection WHERE date BETWEEN :a AND :b");
                $results->bindParam(':a', $d1);
                $results->bindParam(':b', $d2);
                $results->execute();
                for($i=0; $rows = $results->fetch(); $i++){
                $ddd=$rows['sum(amount)'];
                echo formatMoney($ddd, true);
                }
                ?>
            </th>
        </tr>
    </thead>
</table>
</div>
<div class="clearfix"></div>
</div>
</body>
</html>

hope u guys can solve it from me ...thanks :)

4
Contributors
9
Replies
53
Views
2 Years
Discussion Span
Last Post by almostbob
1
104: Collection Report from <?php echo $_GET['d1'] ?> to <?php echo $_GET['d2'] ?>

It just means it's not set. It doesn't exist. You do not have d1=somevalue in your url querystring. How do you expect to echo something that hasn't been set?

Likewise:

120: $d1=$_GET['d1'];
121: $d2=$_GET['d2'];

I don't understand why you're trying to assign twice either:

163: $d1=$_GET['d1'];
164: $d2=$_GET['d2'];

The get vars do no exist. It's as the error message says.

1

In addition, you need to check if $_GET['d1'] is set, before assigning to variable $d1. Otherwise, the parser will assume it is set. You can wrap it up like this

if(isset($_GET['d1']) && isset($_GET['d2])){

          ## rest of codes here

   }
2

get rid of lines 1-3, they do nothing, and add parse time

otherwise the same answer as those above, the $_get parameters are not set, until collection.php submits to itself
checking the value of something that does not exist gives an error

Its bothersome that this is "final year project"
How does a course get through multiple years while allowing the basics to not be taught.
Piss-poor teaching standards, even if you do finish the course there won't be much value in the [joke]qualification[/joke]

Edited by almostbob

Votes + Comments
ouch AB. Just say it as it is why don't you, heh heh
1

thats not meant to attack the student softwaredeven

courses, teachers, the sylabus, left out a lot that annoys me no end, hence the rant

Keep trying, and asking, when you come across anything missed, and presenting code attempts
You'll find a lot of people who'll help out, to fill in the blanks left in the course
php.net has a good set of 'your language' downloadable help screens for the version of php you use, they will help a lot as most error messages are linked.

Edited by almostbob: happy as pigs in mud

0

thanks for the feedback guys... :)
i will also like to send my full project ... can u guys help me to solve the errors ... :)

0

1.Undefined index: invoice in C:\xampp\htdocs\final year project 2\sales.php
2.Notice: Undefined index: invoice in C:\xampp\htdocs\final year project 2\sales.php on line 192
3.Notice: Undefined variable: rows in C:\xampp\htdocs\final year project 2\sales.php on line 197

(sales.php)
<?php
    include('connect.php');
?>
<html>
<head>
<title>
final year project
</title>
<link href="style.css" media="screen" rel="stylesheet" type="text/css" />
<link href="menu.css" media="screen" rel="stylesheet" type="text/css" />
<!--sa poip up-->
<script src="argiepolicarpio.js" type="text/javascript" charset="utf-8"></script>
<script src="js/application.js" type="text/javascript" charset="utf-8"></script>
<link href="src/facebox.css" media="screen" rel="stylesheet" type="text/css" />
<script src="lib/jquery.js" type="text/javascript"></script>
<script src="src/facebox.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="tcal.css" />
<script type="text/javascript">
  jQuery(document).ready(function($) {
    $('a[rel*=facebox]').facebox({
      loadingImage : 'src/loading.gif',
      closeImage   : 'src/closelabel.png'
    })
  })
</script>
</head>
<body background="bg.jpg">
<p><h2 align="center"><font face="Elephant" size=6 color="yellow">STRAWBERRY ACCOUNTING WEBSITE</font></h2></p>
<script type="text/javascript">
tday  =new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
tmonth=new Array("January","February","March","April","May","June","July","August","September","October","November","December");

function GetClock(){
d = new Date();
nday   = d.getDay();
nmonth = d.getMonth();
ndate  = d.getDate();
nyear = d.getYear();
nhour  = d.getHours();
nmin   = d.getMinutes();
nsec   = d.getSeconds();

if(nyear<1000) nyear=nyear+1900;

     if(nhour ==  0) {ap = " AM";nhour = 12;} 
else if(nhour <= 11) {ap = " AM";} 
else if(nhour == 12) {ap = " PM";} 
else if(nhour >= 13) {ap = " PM";nhour -= 12;}

if(nmin <= 9) {nmin = "0" +nmin;}
if(nsec <= 9) {nsec = "0" +nsec;}


document.getElementById('clockbox').innerHTML=""+tday[nday]+", "+tmonth[nmonth]+" "+ndate+", "+nyear+" "+nhour+":"+nmin+":"+nsec+ap+"";
setTimeout("GetClock()", 1000);
}
window.onload=GetClock;
</script>
<div id="clockbox"></div>

<center>
<div class="menu-bar">
<?php
$position=$_SESSION['position'];
if($position=='admin') {
?>
    <ul id="menu-bar">
        <li class="active"><a href="home.php">Home</a></li>
        <li><a href="sales.php">ReportAnalysis</a>
            <ul>
                <li><a rel="facebox" href="select_customer.php">Customer Ledger</a></li>
                <li><a href="supplier.php">Suppliers</a></li>
                <li><a href="products.php">Products</a></li>
                <li><a href="#">Products Sub Menu 4</a></li>
            </ul>
        </li>
        <li><a href="accountreceivables.php">AccountPayable</a>
            <ul>
                <li><a href="customer.php">Customer</a></li>
                <li><a href="purchaseslist.php">list</a></li>
                <li><a href="collection.php">collection</a></li>
                <li><a href="#"></a></li>
            </ul>
        </li>
        <li><a href="#">About</a></li>
        <li><a href="logout.php">Logout</a>
        </li>
    </ul>
<?php } 
if($position=='cashier') {
?>
    <ul id="menu-bar">
        <li class="active"><a href="home.php">Home</a></li>
        <li><a href="sales.php">ReportAnalysis</a>
                    </li>
        <li><a href="logout.php">Logout</a>
        </li>
    </ul>
<?php }
?>

</div>
</center>
<div id="maintable"><div style="margin-top: -19px; margin-bottom: 21px;">
<a id="addd" href="home.php" style="float: none;">Back</a>
</div>
<form action="incoming.php" method="post" >
<input type="hidden" name="pt" value="<?php echo $_GET['id']; ?>" />
<input type="hidden" name="invoice" value="<?php echo $_GET['invoice']; ?>" />
<select name="product" style="width: 520px;">
    <?php
    $result = $db->prepare("SELECT * FROM products");
        $result->bindParam(':userid', $res);
        $result->execute();
        for($i=0; $row = $result->fetch(); $i++){
    ?>
        <option value="<?php echo $row['product_code']; ?>"><?php echo $row['product_code']; ?> - <?php echo $row['product_name']; ?></option>
    <?php
    }
    ?>
</select>
<input type="text" name="qty" value="" placeholder="Qty" autocomplete="off" style="width: 68px; padding-top: 6px; padding-bottom: 6px; margin-right: 4px;" />
<input type="text" name="discount" value="0" autocomplete="off" style="width: 68px; padding-top: 6px; padding-bottom: 6px; margin-right: 4px;" />
<input type="submit" value="save" style="width: 123px;" />
</form>
<table id="resultTable" data-responsive="table">
    <thead>
        <tr>
            <th> Product Code </th>
            <th> Product Name </th>
            <th> Qty </th>
            <th> Price </th>
            <th> Discount </th>
            <th> Amount </th>
            <th> Action </th>
        </tr>
    </thead>
    <tbody>

            <?php
                $id=$_GET['invoice'];
                $result = $db->prepare("SELECT * FROM sales_order WHERE invoice= :userid");
                $result->bindParam(':userid', $id);
                $result->execute();
                for($i=0; $row = $result->fetch(); $i++){
            ?>
            <tr class="record">
            <td><?php echo $row['product']; ?></td>
            <td><?php echo $row['name']; ?></td>
            <td><?php echo $row['qty']; ?></td>
            <td>
            <?php
            $ppp=$row['price'];
            echo formatMoney($ppp, true);
            ?>
            </td>
            <td>
            <?php
            $ddd=$row['discount'];
            echo formatMoney($ddd, true);
            ?>
            </td>
            <td>
            <?php
            $ddd=$row['amount'];
            echo formatMoney($fff, true);
            ?>
            </td>
            <td><a href="delete.php?id=<?php echo $row['transaction_id']; ?>&invoice=<?php echo $_GET['invoice']; ?>&dle=<?php echo $_GET['id']; ?>&qty=<?php echo $row['qty'];?>&code=<?php echo $row['product'];?>"> Delete </a></td>
            </tr>
            <?php
                }
            ?>
            <tr>
                <td colspan="5"><strong style="font-size: 12px; color: #222222;">Total:</strong></td>
                <td colspan="2"><strong style="font-size: 12px; color: #222222;">
                <?php
                function formatMoney($number, $fractional=false) {
                    if ($fractional) {
                        $number = sprintf('%.2f', $number);
                    }
                    while (true) {
                        $replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
                        if ($replaced != $number) {
                            $number = $replaced;
                        } else {
                            break;
                        }
                    }
                    return $number;
                }
                $ddd=$_GET['invoice'];
                $results = $db->prepare("SELECT sum(amount) FROM sales_order WHERE invoice= :a");
                $results->bindParam(':a', $ddd);
                $results->execute();
                for($i=0; $rowas = $results->fetch(); $i++){
                $fff=$rows['sum(amount)'];
                echo formatMoney($fff, true);
                }
                ?>
                </strong></td>
            </tr>

    </tbody>
</table><br>
<a rel="facebox" id="cccc" href="checkout.php?pt=<?php echo $_GET['id']?>&invoice=<?php echo $_GET['invoice']?>&total=<?php echo $fgfg ?>&cashier=<?php echo $_SESSION['SESS_FIRST_NAME']?>">Check Out</a>
<div class="clearfix"></div>
</div>
</body>
</html>

(incoming.php)
<?php
include('connect.php');
$a = $_POST['invoice'];
$b = $_POST['product'];
$c = $_POST['qty'];
$w = $_POST['pt'];
$discount = $_POST['discount'];
$result = $db->prepare("SELECT * FROM products WHERE product_code= :userid");
$result->bindParam(':userid', $b);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
$as=$row['price'];
$name=$row['product_name'];
}

//edit qty
$sql = "UPDATE products 
        SET qty=qty-?
        WHERE product_code=?";
$q = $db->prepare($sql);
$q->execute(array($c,$b));
$fff=$as-$discount;
$d=$fff*$c;
// query
$sql = "INSERT INTO sales_order (invoice,product,qty,amount,name,price,discount) VALUES (:a,:b,:c,:d,:e,:f,:g)";
$q = $db->prepare($sql);
$q->execute(array(':a'=>$a,':b'=>$b,':c'=>$c,':d'=>$d,':e'=>$name,':f'=>$as,':g'=>$discount));
header("location: sales.php?id=$w&&invoice=$a");

?>

(savesales.php)
<?php
include('connect.php');
$a = $_POST['invoice'];
$b = $_POST['cashier'];
$c = $_POST['date'];
$d = $_POST['ptype'];
$e = $_POST['amount'];
$cname = $_POST['cname'];
if($d=='credit') {
$f = $_POST['due'];
$sql = "INSERT INTO sales (invoice_number,cashier,date,type,amount,due_date,name) VALUES (:a,:b,:c,:d,:e,:f,:g)";
$q = $db->prepare($sql);
$q->execute(array(':a'=>$a,':b'=>$b,':c'=>$c,':d'=>$d,':e'=>$e,':f'=>$f,':g'=>$cname));
header("location: preview.php?invoice=$a");
exit();
}
if($d=='cash') {
$f = $_POST['cash'];
$sql = "INSERT INTO sales (invoice_number,cashier,date,type,amount,due_date,name) VALUES (:a,:b,:c,:d,:e,:f,:g)";
$q = $db->prepare($sql);
$q->execute(array(':a'=>$a,':b'=>$b,':c'=>$c,':d'=>$d,':e'=>$e,':f'=>$f,':g'=>$cname));
header("location: preview.php?invoice=$a");
exit();
}
// query



?>

(salesreport.php)
<?php
    include ("connect.php");
?>
<html>
<head>
<title>
final year project
</title>
<link href="style.css" media="screen" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="tcal.css" />
<script type="text/javascript" src="tcal.js"></script>
<script language="javascript">
function Clickheretoprint()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=700, height=400, left=100, top=25"; 
  var content_vlue = document.getElementById("content").innerHTML; 

  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('</head><body onLoad="self.print()" style="width: 700px; font-size:11px; font-family:arial; font-weight:normal;">');          
   docprint.document.write(content_vlue); 
   docprint.document.close(); 
   docprint.focus(); 
}
<div class="menu-bar">
<?php
$position=$_SESSION['position'];
if($position=='admin') {
?>
    <ul id="menu-bar">
        <li class="active"><a href="home.php">Home</a></li>
        <li><a href="sales.php">ReportAnalysis</a>
            <ul>
                <li><a rel="facebox" href="select_customer.php">Customer Ledger</a></li>
                <li><a href="supplier.php">Suppliers</a></li>
                <li><a href="products.php">Products</a></li>
                <li><a href="salesreport">SalesReport</a></li>
            </ul>
        </li>
        <li><a href="accountreceivables.php">AccountPayable</a>
            <ul>
                <li><a href="customer.php">Customer</a></li>
                <li><a href="purchaseslist.php">list</a></li>
                <li><a href="collection.php">collection</a></li>
                <li><a href="#"></a></li>
            </ul>
        </li>
        <li><a href="#">About</a></li>
        <li><a href="logout.php">Logout</a>
        </li>
    </ul>
<?php } 
if($position=='cashier') {
?>
    <ul id="menu-bar">
        <li class="active"><a href="home.php">Home</a></li>
        <li><a href="sales.php">ReportAnalysis</a></li>
        <li><a href="salesreport.php">SalesReport</a></li>

        <li><a href="logout.php">Logout</a>
        </li>
    </ul>
<?php }
?>

</div>
</script>
</head>
<body>
<div id="maintable">
<div style="margin-top: -19px; margin-bottom: 21px;">
<a id="addd" href="index.php" style="float: none;">Back</a>
</div>
<form action="salesreport.php" method="get">
From : <input type="text" name="d1" class="tcal" value="" /> To: <input type="text" name="d2" class="tcal" value="" /> <input type="submit" value="Search"><a id="addd" href="javascript:Clickheretoprint()">Print</a>
</form>
<div class="content" id="content">
<div style="font-weight:bold; text-align:center;font-size:14px;margin-bottom: 15px;">
Sales Report from&nbsp;<?php echo $_GET['d1'] ?>&nbsp;to&nbsp;<?php echo $_GET['d2'] ?>
</div>

<table id="resultTable" data-responsive="table" style="text-align: left;">
    <thead>
        <tr>
            <th width="17%"> Transaction ID </th>
            <th width="8%"> Date </th>
            <th width="25%"> Customer Name </th>
            <th width="25%"> Invoice Number </th>
            <th width="15%"> Amount </th>
            <th width="10%"> Remarks </th>
        </tr>
    </thead>
    <tbody>

            <?php
                $d1=$_GET['d1'];
                $d2=$_GET['d2'];
                $result = $db->prepare("SELECT * FROM sales WHERE date BETWEEN :a AND :b");
                $result->bindParam(':a', $d1);
                $result->bindParam(':b', $d2);
                $result->execute();
                for($i=0; $row = $result->fetch(); $i++){
            ?>
            <tr class="record">
            <td>STI-000<?php echo $row['transaction_id']; ?></td>
            <td><?php echo $row['date']; ?></td>
            <td><?php echo $row['name']; ?></td>
            <td><?php echo $row['invoice_number']; ?></td>
            <td><?php
            $dsdsd=$row['amount'];
            echo formatMoney($dsdsd, true);
            ?></td>
            <td><?php echo $row['type']; ?></td>
            </tr>
            <?php
                }
            ?>

    </tbody>
    <thead>
        <tr>
            <th colspan="4" style="border-top:1px solid #999999"> Total </th>
            <th colspan="2" style="border-top:1px solid #999999"> 
            <?php
                function formatMoney($number, $fractional=false) {
                    if ($fractional) {
                        $number = sprintf('%.2f', $number);
                    }
                    while (true) {
                        $replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
                        if ($replaced != $number) {
                            $number = $replaced;
                        } else {
                            break;
                        }
                    }
                    return $number;
                }
                $d1=$_GET['d1'];
                $d2=$_GET['d2'];
                $results = $db->prepare("SELECT sum(amount) FROM sales WHERE date BETWEEN :a AND :b");
                $results->bindParam(':a', $d1);
                $results->bindParam(':b', $d2);
                $results->execute();
                for($i=0; $rows = $results->fetch(); $i++){
                $dsdsd=$rows['sum(amount)'];
                echo formatMoney($dsdsd, true);
                }
                ?>
            </th>
        </tr>
    </thead>
</table>
</div>
<div class="clearfix"></div>
</div>
</body>
</html>

(priview.php)
<?php
    include "connect.php";
?>
<link href="style.css" media="screen" rel="stylesheet" type="text/css" />
<script language="javascript">
function Clickheretoprint()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=800, height=400, left=100, top=25"; 
  var content_vlue = document.getElementById("content").innerHTML; 

  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('</head><body onLoad="self.print()" style="width: 800px; font-size: 13px; font-family: arial;">');          
   docprint.document.write(content_vlue); 
   docprint.document.close(); 
   docprint.focus(); 
}
</script>
<a href="javascript:Clickheretoprint()" style="font-size:20px";>Print</a>|<a href="home.php" style="font-size:20px";>Back</a>
<?php
$invoice=$_GET['invoice'];
$result = $db->prepare("SELECT * FROM sales WHERE invoice_number= :userid");
$result->bindParam(':userid', $invoice);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
$cname=$row['name'];
$invoice=$row['invoice_number'];
$date=$row['date'];
$cash=$row['due_date'];
$cashier=$row['cashier'];

$pt=$row['type'];
$am=$row['amount'];
if($pt=='cash'){
$cash=$row['due_date'];
$amount=$cash-$am;
}
}
?><br>
<br>

<div class="content" id="content">
<div style="margin: 0 auto; padding: 20px; width: 700px; font-weight: normal;">
    <div style="width: 100%; height: 190px;" >
    <div style="width: 459px; float: left;">
    <img src="../initial.png" /><br>
    Street Address<br>
    Brgy<br>
    TIN:<br>
    Contact No : <br>
    Email Add : <br>
    <div>
    <?php
    $resulta = $db->prepare("SELECT * FROM customer WHERE customer_name= :a");
    $resulta->bindParam(':a', $cname);
    $resulta->execute();
    for($i=0; $rowa = $resulta->fetch(); $i++){
    $address=$rows['address'];
    $contact=$rows['contact'];
    }
    ?>
    <table border="1" cellpadding="4" cellspacing="0" style="font-family: arial; font-size: 12px;text-align:left;width : 100%;">
        <tr>
            <td width="25%">Received From : </td>
            <td width="75%"><?php echo $cname ?></td>
        </tr>
        <tr>
            <td width="25%">Address : </td>
            <td width="75%"><?php echo $address ?></td>
        </tr>
        <tr>
            <td width="25%">Contact No : </td>
            <td width="75%"><?php echo $contact ?></td>
        </tr>
    </table>
    </div>
    </div>
    <div style="width: 236px; float: right; height: 178px;">
    <table border="1" cellpadding="4" cellspacing="0" style="font-family: arial; font-size: 12px;text-align:left;width : 100%;">
        <tr>
            <td colspan="2"><div style="text-align: center; font-weight: bold;">

            <?php
            if($pt=='cash'){
            echo 'OFFICIAL RECEIPT:';
            }
            if($pt=='credit'){
            echo 'CREDIT RECEIPT:';
            }
            ?>
            </div></td>
        </tr>
        <tr>
            <td>OR No.</td>
            <td><?php echo $invoice ?></td>
        </tr>
        <tr>
            <td>Date</td>
            <td><?php echo $date ?></td>
        </tr>
        <tr style="height: 109px; vertical-align: top;">
            <td>Remarks</td>
            <td><?php echo $cash ?></td>
        </tr>
    </table>

    </div>
    <div class="clearfix"></div>
    </div>
    <div style="width: 100%">
    <table border="1" cellpadding="4" cellspacing="0" style="font-family: arial; font-size: 12px;text-align:left;" width="100%">
        <thead>
            <tr>
                <th> Product Code </th>
                <th> Product Name </th>
                <th> Qty </th>
                <th> Price </th>
                <th> Discount </th>
                <th> Amount </th>
            </tr>
        </thead>
        <tbody>

                <?php
                    $id=$_GET['invoice'];
                    $result = $db->prepare("SELECT * FROM sales_order WHERE invoice= :userid");
                    $result->bindParam(':userid', $id);
                    $result->execute();
                    for($i=0; $row = $result->fetch(); $i++){
                ?>
                <tr class="record">
                <td><?php echo $row['product']; ?></td>
                <td><?php echo $row['name']; ?></td>
                <td><?php echo $row['qty']; ?></td>
                <td>
                <?php
                $ppp=$row['price'];
                echo formatMoney($ppp, true);
                ?>
                </td>
                <td>
                <?php
                $ddd=$row['discount'];
                echo formatMoney($ddd, true);
                ?>
                </td>
                <td>
                <?php
                $dfdf=$row['amount'];
                echo formatMoney($dfdf, true);
                ?>
                </td>
                </tr>
                <?php
                    }
                ?>
                <tr>
                    <td colspan="5"><strong style="font-size: 12px; color: #222222;">Total:</strong></td>
                    <td colspan="2"><strong style="font-size: 12px; color: #222222;">
                    <?php
                    $sdsd=$_GET['invoice'];
                    $result = $db->prepare("SELECT sum(amount) FROM sales_order WHERE invoice= :a");
                    $result->bindParam(':a', $sdsd);
                    $result->execute();
                    for($i=0; $rows = $result->fetch(); $i++){
                    $ggg=$rowas['sum(amount)'];
                    echo formatMoney($ggg, true);
                    }
                    ?>
                    </strong></td>
                </tr>
                <?php if($pt=='cash'){
                ?>
                <tr>
                    <td colspan="5"><strong style="font-size: 12px; color: #222222;">Cash Tendered:</strong></td>
                    <td colspan="2"><strong style="font-size: 12px; color: #222222;">
                    <?php
                    echo formatMoney($cash, true);
                    ?>
                    </strong></td>
                </tr>
                <?php
                }
                ?>
                <tr>
                    <td colspan="5"><strong style="font-size: 12px; color: #222222;">
                    <?php
                    if($pt=='cash'){
                    echo 'Change:';
                    }
                    if($pt=='credit'){
                    echo 'Due Date:';
                    }
                    ?>
                    </strong></td>
                    <td colspan="2"><strong style="font-size: 12px; color: #222222;">
                    <?php
                    function formatMoney($number, $fractional=false) {
                        if ($fractional) {
                            $number = sprintf('%.2f', $number);
                        }
                        while (true) {
                            $replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
                            if ($replaced != $number) {
                                $number = $replaced;
                            } else {
                                break;
                            }
                        }
                        return $number;
                    }
                    if($pt=='credit'){
                    echo $cash;
                    }
                    if($pt=='cash'){
                    echo formatMoney($amount, true);
                    }
                    ?>
                    </strong></td>
                </tr>

        </tbody>
    </table>
    </div>

<div style="text-align: right; margin-top: 13px;">Cashier : <?php echo $cashier ?></div>
</div>
</div>


(checkout.php)
<html>
<head>
<title>Checkout</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
<script>
function suggest(inputString){
        if(inputString.length == 0) {
            $('#suggestions').fadeOut();
        } else {
        $('#country').addClass('load');
            $.post("autosuggestname.php", {queryString: ""+inputString+""}, function(data){
                if(data.length >0) {
                    $('#suggestions').fadeIn();
                    $('#suggestionsList').html(data);
                    $('#country').removeClass('load');
                }
            });
        }
    }

    function fill(thisValue) {
        $('#country').val(thisValue);
        setTimeout("$('#suggestions').fadeOut();", 600);
    }

</script>

<style>
#result {
    height:20px;
    font-size:16px;
    font-family:Arial, Helvetica, sans-serif;
    color:#333;
    padding:5px;
    margin-bottom:10px;
    background-color:#FFFF99;
}
#country{
    border: 1px solid #999;
    background: #EEEEEE;
    padding: 5px 10px;
    box-shadow:0 1px 2px #ddd;
    -moz-box-shadow:0 1px 2px #ddd;
    -webkit-box-shadow:0 1px 2px #ddd;
}
.suggestionsBox {
    position: absolute;
    left: 10px;
    margin: 0;
    width: 268px;
    top: 40px;
    padding:0px;
    background-color: #000;
    color: #fff;
}
.suggestionList {
    margin: 0px;
    padding: 0px;
}
.suggestionList ul li {
    list-style:none;
    margin: 0px;
    padding: 6px;
    border-bottom:1px dotted #666;
    cursor: pointer;
}
.suggestionList ul li:hover {
    background-color: #FC3;
    color:#000;
}
ul {
    font-family:Arial, Helvetica, sans-serif;
    font-size:11px;
    color:#FFF;
    padding:0;
    margin:0;
}

.load{
background-image:url(loader.gif);
background-position:right;
background-repeat:no-repeat;
}

#suggest {
    position:relative;
}
.combopopup{
    padding:3px;
    width:268px;
    border:1px #CCC solid;
}

</style> 
</head>
<body onLoad="document.getElementById('country').focus();">
<form action="savesales.php" method="post">
<div id="ac">
<input type="hidden" name="date" value="<?php echo date("m/d/Y"); ?>" />
<input type="hidden" name="invoice" value="<?php echo $_GET['invoice']; ?>" />
<input type="hidden" name="amount" value="<?php echo $_GET['total']; ?>" />
<input type="hidden" name="ptype" value="<?php echo $_GET['pt']; ?>" />
<input type="hidden" name="cashier" value="<?php echo $_GET['cashier']; ?>" />
<input type="text" size="25" value="" name="cname" id="country" onKeyUp="suggest(this.value);" onBlur="fill();" class="" autocomplete="off" placeholder="Enter Customer Name" style="width: 268px;" /><br><br>

      <div class="suggestionsBox" id="suggestions" style="display: none;">
        <div class="suggestionList" id="suggestionsList"> &nbsp; </div>
      </div>
<?php
$asas=$_GET['pt'];
if($asas=='credit') {
?><input type="text" name="due" placeholder="Due Date" style="width: 268px; margin-bottom: 15px;" /><br>
<?php
}
if($asas=='cash') {
?><input type="text" name="cash" placeholder="Cash" style="width: 268px; margin-bottom: 15px;" /><br>
<?php
}
?><input id="btn" type="submit" value="save" style="width: 268px;" />
</div>
</form>
</body>
</html>

need your help guys... :)

0

YOU are going to love this part
2.Notice: Undefined index: invoice in C:\xampp\htdocs\final year project 2\sales.php on line 192
is not on line 192 of this file
its at the 192nd line of code at execution
counting through 192 lines of all included files, connect.php will push the line count back by however many lines of code are in it

 <td colspan="5"><strong style="font-size: 12px; color: #222222;">Total:</strong></td>

is poor on so many levels, tables: inline styles; all are replaced by better allternatives, very outdated, the course really pisses me off

debugging is so much harder than bugging

Edited by almostbob

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.