$referers = array ('ecosmartinc.com','www.ecosmartinc.com','208.179.130.93 1');
function check_referer($referers)
{if (count($referers)){
$found = false;
$temp = explode("/",getenv("HTTP_REFERER"));
$referer = $temp[2];
if ($referer==""){
$referer = $_SERVER['HTTP_REFERER'];
list($remove,$stuff)=split('//',$referer,2);
list($home,$stuff)=split('/',$stuff,2);
$referer = $home;
}
for ($x=0; $x < count($referers); $x++){
if (eregi ($referers[$x], $referer)){
$found = true;
}
}
if ($referer ==""){
$found = false;
}
if (!$found){
echo("You are coming from an unauthorized domain. ");
exit();
}
return $found;
}else{
return true;
}
}
if (!check_referer($referers))
{
}
?>
Eco-$mart Invoice - New Invoice
$dnum = date(Ymd)*4;
$from = $_GET['fr'];
if($from == ""){
$from = $_POST['fr'];
}
if($from != $dnum){
echo("<<<<Restricted Area>>>> " .
" Sorry, you must Log In to view this Page
");
exit();
}
$Note = $_POST['Note'];
$usrn = $_POST['usrn'];
$Note = stripslashes($_POST['Note']);
$ID = $_POST['ID'];
$today = date("F j, Y");
$dtnum = date(Ymd);
$dbcnx = @mysql_connect('mysql.plainhost.com', 'ecosmar_ecosmart', 'ecoman1');
mysql_select_db('ecosmar_inv', $dbcnx);
$getem = @mysql_query("SELECT ID,invnum,CID,rep,rec_co,rec_name,rec_address,rec_city,rec_state,rec_zip,rec_phone,ponum,terms,due,project,taxtotal,tax,subtotal,shiptotal,balance,payments,dtup,dtnum FROM ecoinvoice WHERE ID='$ID'");
if (!$getem) {
echo('Error retrieving Invoice Data. ' . 'Error: '. mysql_error(). '
');
}
$row = mysql_fetch_array($getem);
$ID = $row['ID'];
$invnum = $row['invnum'];
$CID = $row['CID'];
$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'];
$ponum = $row['ponum'];
$terms = $row['terms'];
$due = $row['due'];
$chunk_dueup = chunk_split($due, 2, ':');
$chunk_arrd = explode(":", $chunk_dueup);
$dueup = $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'];
$dtup = $row['dtup'];
$idtnum = $row['dtnum'];
$chunk_dtnum = chunk_split($idtnum, 2, ':');
$chunk_arr = explode(":", $chunk_dtnum);
$datus = $chunk_arr[2].'-'.$chunk_arr[3].'-'.$chunk_arr[0].$chunk_arr[1];
$status = $row['status'];
$prgrss = $row['prgrss'];
mysql_select_db('ecosmar_contacts', $dbcnx);
$listem = @mysql_query("SELECT ID,first_Name,Name,Company,Phone,Address,FAX,City,email,State,ZipCode FROM con_main WHERE ID='$CID'");
if (!$listem) {
echo('Error retrieving data from data base. ' . 'Error: '. mysql_error(). '
');
}
$rowb = mysql_fetch_array($listem);
$CID = $rowb['ID'];
$first_Name = $rowb['first_Name'];
$Name = $rowb['Name'];
$Company = $rowb['Company'];
$Phone = $rowb['Phone'];
$Address = $rowb['Address'];
$FAX = $rowb['FAX'];
$City = $rowb['City'];
$email = $rowb['email'];
$State = $rowb['State'];
$ZipCode = $rowb['ZipCode'];
$customer = "$Company $first_Name $Name $Address $City, $State $ZipCode $email $Phone $FAX";
$shipto = "$rec_co $rec_name $rec_address $rec_city, $rec_state $rec_zip";
?>
Eco-$mart, Inc.
4411 Bee Ridge Road #344 Sarasota, FL 34233
PH. 888-329-2705 FX: 941-377-9460
www.ecosmartinc.com
Invoice
Date
Invoice #
Representative
P.O. Number
Terms
Est. Delivery
Project
Item Code
Description
Quantity
Price
Amount
mysql_select_db('ecosmar_inv', $dbcnx);
$prod_inv = @mysql_query("SELECT ID,prod_name,prod_desc,prod_qty,prod_price,dtup,dtnum,status FROM inv_prod WHERE invnum='$invnum'");
if (!$prod_inv) {
echo('Error retrieving Product Data. ' . 'Error: '. mysql_error(). '
');
}
while($rowp = mysql_fetch_array($prod_inv)){
$PID = $rowp['ID'];
$PID_arr[] = $PID;
$prod_name = $rowp['prod_name'];
$prod_name_arr[] = $prod_name;
$prod_desc = $rowp['prod_desc'];
$prod_desc_arr[] = $prod_desc;
$prod_qty = $rowp['prod_qty'];
$prod_qty_arr[] = $prod_qty;
$prod_price = $rowp['prod_price'];
$dtup = $rowp['dtup'];
$dtnum = $rowp['dtnum'];
$status = $rowp['status'];
$amount = $prod_qty * $prod_price;
$amount1 = $prod_qty * $prod_price;
$amount = sprintf("%01.2f", $amount1);
echo("$prod_name $prod_desc" .
" $prod_qty" .
" $prod_price $amount" .
" ");
}
$prodcount = count($PID_arr);
$prod1 = $prod_name_arr[0]." - ".$prod_desc_arr[0]." - ".$prod_qty_arr[0];
$prod2 = $prod_name_arr[1]." - ".$prod_desc_arr[1]." - ".$prod_qty_arr[1];
if($prodcount > 2){
$prod3 = "More...";
}else{
$prod3 = $prod_name_arr[2]." - ".$prod_desc_arr[2]." - ".$prod_qty_arr[2];
}
$update = @mysql_query("UPDATE ecoinvoice SET status='Authorized' WHERE ID='$ID' LIMIT 1");
if (!$update) {
$no_up = 'Could not complete Authorization'. mysql_error();
}else{
$recipient = $rep_email.","."kent@kwgrubbs.com".","."info@ecosmartinc.com";
$subject = "Eco-\$mart Invoice Authorized";
$message ="The following Invoice has been authorized." .
"\n" .
"INVOICE #: $invnum" .
"\n" .
"Contact: $first_Name $Name" .
"\n" .
"Company: $Company" .
"\n" .
"$City, $State $ZipCode" .
"\n" .
"\n" .
"PRODUCTS:" .
"\n" .
"$prod1" .
"\n" .
"$prod2" .
"\n" .
"$prod3" .
"\n" .
"Note:" .
"\n" .
"$Note" .
"\n" .
"\n" .
"Thank You," .
"\n" .
"Matt Ross" .
"\n" .
"Eco-\$mart, Inc." .
"\n" .
"mross@eco-smart.com" .
"\n" .
"\n" .
"View and Manage this Invoice in Eco-\$mart Administration." .
"\n" .
"Go to http://www.ecosmartinc.com/ecos/ecologin.htm" .
"\n";
if(@mail($recipient, $subject, $message, "From: Matt Ross ")){
$maildone = 'yes';
}else{
$no_mail = 'Error Emailing Notification';
}
}
if($maildone == 'yes'){
$oko = @mysql_query("INSERT INTO inv_notes SET invnum='$invnum',Notes ='$Notes',dtnum='$dtnum'");
if (!$oko){
$no_notes = 'Problem posting Notes' . mysql_error();
}else{
$alldone = 'yes';
}
}
?>
Invoice Status
Subtotal
echo ("" . $subtotal . "
");
?>
if($alldone == 'yes'){
echo("" .
"" .
"Successful Authorization " .
" Data Base Updated Email sent to Rep Notes posted to Invoice" .
" " .
"Print Invoice " .
"Online Billing " .
"
");
}else{
echo("" .
"" .
"Problems with Authorization " .
" $no_up $no_mail $no_notes" .
"
");
}
?>
Sales Tax
echo ("" . $taxtotal . "
");
?>
Shipping
echo ("" . $shiptotal . "
");
?>
Total
$total = $subtotal + $taxtotal + $shiptotal;
echo ("" . $total . "
");
?>
Payments/Credits
Balance Due