$dtnum = date(Ymd);
$dnum = date(Ymd) * 4;
$today = date("F j, Y");
$dbcnx = @mysql_connect('mysql.plainhost.com', 'ecosmar_ecosmart', 'ecoman1');
$invnum = $_GET[invnum];
if($invnum == ""){
$invnum = $_POST[inv];
}
$numcnt = strlen($invnum);
if($invnum == "" or $numcnt < 9){
echo("Error: No Input");
exit();
}else{
mysql_select_db('ecosmar_inv', $dbcnx);
$newinv = mysql_query("SELECT ID,invnum,CID,RID,rep,rep_email,rec_co,rec_name,rec_address,rec_city,rec_state,rec_zip,rec_phone,ponum,terms,due,project,taxtotal,tax,subtotal,shiptotal,balance,payments,special from ecoinvoice WHERE invnum='$invnum'");
if(!$newinv){
echo("
Problem getting invoice data. Error: ".mysql_error()."
");
}else{
$row = mysql_fetch_array($newinv);
$ID = $row['ID'];
$invnu = $row['invnum'];
$invnum = $invnu + 0;
$CID = $row['CID'];
$RID = $row['RID'];
$rep = $row['rep'];
$rep_email = $row['rep_email'];
$rec_co = $row['rec_co'];
$rec_name = $row['rec_name'];
$rec_address = $row['rec_address'];
$rec_city = $row['rec_city'];
$rec_state = $row['rec_state'];
$rec_zip = $row['rec_zip'];
$rec_phone = $row['rec_phone'];
$ponum = $row['ponum'];
$terms = $row['terms'];
$due = $row['due'];
$chunk_due = chunk_split($due, 2, ':');
$chunk_arrd = explode(":", $chunk_due);
$doit = $chunk_arrd[2].'/'.$chunk_arrd[3].'/'.$chunk_arrd[0].$chunk_arrd[1];
$project = $row['project'];
$taxtotal = $row['taxtotal'];
$tax = $row['tax'];
$subtotal = $row['subtotal'];
$shiptotal = $row['shiptotal'];
$balance = $row['balance'];
$payments = $row['payments'];
$special = $row['special'];
}
$getprod = mysql_query("SELECT invnum,prod_name,prod_desc,prod_qty,prod_price FROM inv_prod WHERE invnum='$invnum' ORDER BY prod_name");
if(!$getprod){
echo("Could not retrieve Product Information
".mysql_error()." ");
}else{
while($rop = mysql_fetch_array($getprod)){
$prod_name[] = $rop['prod_name'];
$prod_desc[] = $rop['prod_desc'];
$prod_q = $rop['prod_qty'];
$prod_qty[] = $prod_q;
$prod_pr = $rop['prod_price'];
$prod_price[] = $prod_pr;
$prod_amount[] = $prod_pr * $prod_q;
}
}
$getship = mysql_query("SELECT prod_name,carrier,charge FROM inv_ship WHERE invnum='$invnum' ORDER BY prod_name");
if(!$getship){
echo("Could not retrieve Shipping Information
".mysql_error()." ");
}else{
while($ros = mysql_fetch_array($getship)){
$ship_name[] = $ros['prod_name'];
$carrier[] = $ros['carrier'];
$charge[] = $ros['charge'];
}
$carrs = array_unique($carrier);
$shiptot = array_sum($charge);
$shiptotal = sprintf("%01.2f", $shiptot);
}
mysql_select_db('ecosmar_contacts', $dbcnx);
$contact = mysql_query("SELECT first_Name,Name,Company,Address,City,State,ZipCode from con_main WHERE ID='$CID'");
if(!$contact){
echo("
Problem getting contact data. Error: ".mysql_error()."
");
}else{
$rowc = mysql_fetch_array($contact);
$first_Name = $rowc['first_Name'];
$Name = $rowc['Name'];
$Company = $rowc['Company'];
$Address = $rowc['Address'];
$City = $rowc['City'];
$State = $rowc['State'];
$ZipCode = $rowc['ZipCode'];
$customer = "$Company
$first_Name $Name
$Address
$City, $State $ZipCode
$email
$Phone
$FAX";
$c_ship = "$Company
$first_Name $Name
$Address
$City, $State $ZipCode
$Phone";
$shipto = "$rec_co
$rec_name
$rec_address
$rec_city, $rec_state $rec_zip
$rec_phone";
}
}
$right = "So";
?>
Eco-$mart, Inc.
4411 Bee Ridge Road #344
Sarasota, FL 34233
PH. 888-329-2705 FX: 941-377-9460
www.ecosmartinc.com
Quote
Bill To:
Ship To:
if($rec_zip == ""){
echo $c_ship;
}else{
echo $shipto;
}
?>
P.O. Number
Terms
Est. Delivery
Project
Item Code
Description
QTY
Price
Unit
Total
$prod_count = count($prod_name);
$i = 0;
while($i < $prod_count){
$amount = $prod_amount[$i];
$formamount = sprintf("%01.2f", $amount);
$full_amount[] = $amount;
echo("$prod_name[$i] " .
"$prod_desc[$i]" .
" $prod_qty[$i]" .
" $prod_price[$i] " .
"$prod_unit[$i] " .
"$$formamount " .
" ");
$i++;
}
?>
Thank you for working with Eco-$mart.
Subtotal
$subtot = array_sum($prod_amount);
$subtotal = sprintf("%01.2f", $subtot);
echo ("$" . $subtotal . "
");
?>
Purchaser acknowledges that Eco-$mart, Inc. neither provides nor has any responsibility for any product or installation warranties, oral or written, expressed or implied, including the IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Products are warranted by the manufacturer only and in the event of any product or installation defects, purchaser shall seek its remedies solely from the manufacturer or installer, regardless of the legal theory or recovery. Additionally, in the event of a dispute, the prevailing party shall be entitled to reimbursement of its attorneys fees and costs from the non-prevailing party, including through all appeals. Purchaser agrees that Eco-$mart’s liability in any event shall be limited to 10% of the Invoice amount, or $1000.00, which ever is less. Past due Invoices accrue interest charges of 1.5% per month.
All prices are subject to final approval by Eco-$mart, Inc. Central Administration.
Sales Tax
$tax = sprintf("%01.2f", $taxtotal);
echo ("$" . $tax . "
");
?>
Shipping
echo ("$" . $shiptotal . "
");
?>
Total
$tota = $subtotal + $taxtotal + $shiptotal;
$total = sprintf("%01.2f", $tota);
echo ("$" . $total . "
");
?>
Payments/Credits
if($payments > 0){
mysql_select_db('ecosmar_inv', $dbcnx);
$paycheck = mysql_query("SELECT amount,dtnum FROM inv_pay WHERE invnum='$invnum'");
if(!$paycheck){
echo("Could not get Payment Data");
}else{
while($rod = mysql_fetch_array($paycheck)){
$pamount[] = $rod['amount'];
$pdtnum[] = $rod['dtnum'];
}
$ptot = array_sum($pamount);
$ptotal = sprintf("%01.2f", $ptot);
echo ("
$" . $ptotal . "
" .
"");
$paycount = count($pamount);
$i = 0;
while($i < $paycount){
$pdtnum = $pdtnum[$i];
$chunk_pdtnum = chunk_split($pdtnum, 2, ':');
$chunk_arrp = explode(":", $chunk_pdtnum);
$paidit = $chunk_arrp[2].'/'.$chunk_arrp[3].'/'.$chunk_arrp[0].$chunk_arrp[1];
echo(":$paidit - $pamount[$i]:");
$i = $i + 1;
}
echo("
");
}
}else{
echo ("0.00
");
}
?>
Balance Due
$