$hite = $_POST['hite'];
echo("Here is $hite");
$dtnum = date(Ymd);
$dnum = date(Ymd)*4;
$today = date("F j, Y");
$dbcnx = @mysql_connect('mysql.plainhost.com', 'ecosmar_ecosmart', 'ecoman1');
$invnum = $_GET['inv'];
if($invnum == ""){
$invnum = $_POST['inv'];
}
if($invnum == ""){
echo("Error: No Invoice Number");
exit();
}else{
$invnum = $invnum + 0;
mysql_select_db('ecosmar_inv', $dbcnx);
$newinv = mysql_query("SELECT ID,invnum,CID,rep,rep_email,rec_co,rec_name,rec_address,rec_city,rec_state,rec_zip,rec_phone,ponum,terms,due,project,dtnum,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'];
$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'];
$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'];
$dtnum = $row['dtnum'];
$special = $row['special'];
if($special == "wholesale"){
$z = 3;
}elseif($special == "dealer"){
$z = 4;
}elseif($special == "distributor"){
$z = 5;
}else{
$z = 2;
}
}
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";
}
}//exit else
$right = "So";
$special = $_POST['special'];
$additem1 = $_POST[additem];
$adddesc1 = $_POST[adddesc];
$addprice1 = $_POST[addprice];
$addunit1 = $_POST[addunit];
$addqty1 = $_POST[addqty];
$addtot1 = $_POST[addtot];
mysql_select_db('ecosmar_products', $dbcnx);
$newprod = $_POST['newprod'];
$newqty = $_POST['newqty'];
$outprod = $_POST['outprod'];
if($outprod != ""){
$additem = array();
$adddesc = array();
$addprice = array();
$addunit = array();
$addqty = array();
$addtot = array();
$i = 0;
$count = count($additem1);
while($i < $count){
if($additem1[$i] != $outprod){
$additem[] = $additem1[$i];
$adddesc[] = $adddesc1[$i];
$addprice[] = $addprice1[$i];
$addunit[] = $addunit1[$i];
$addqty[] = $addqty1[$i];
$addtot[] = $addtot1[$i];
}//if
$i = $i + 1;
}//while
}else{
$additem = $additem1;
$adddesc = $adddesc1;
$addprice = $addprice1;
$addunit = $addunit1;
$addqty = $addqty1;
$addtot = $addtot1;
}
if(empty($additem)){
$opening = "Add a product by selecting, entering quantity, and clicking the green button to the right. Click Finished when all products are added.";
}else{
$opening = "Continue adding products or remove a product by clicking the red button to the left. Click Finished when all products are added.";
}
?>
|
Eco-$mart, Inc.
4411 Bee Ridge Road #344
Sarasota, FL 34233
PH. 888-329-2705 FX: 941-377-9460
www.ecosmartinc.com
|
Quote
Date
| Invoice #
|
|
|
Representative
|
|
|
Bill To:
| Ship To:
|
|
if($rec_zip == ""){
echo $c_ship;
}else{
echo $shipto;
}
?>
|
P.O. Number
| Terms
| Est. Delivery
| Project
|
| | | |
|
if($newprod != ""){
if(!in_array($newprod, $additem)){
$getadd = mysql_query("SELECT productname,description,retail,wholesale,dealer,distributor,unit,minimum FROM prices WHERE productname='$newprod'");
if(!$getadd){
echo("Error Getting Product Info!
Error:" . mysql_error() . "
");
}else{
$grow = mysql_fetch_array($getadd);
$gproductname = $grow[0];
$gdescription = $grow[1];
$gprice = $grow[$z];
$gunit = $grow[6];
$gminimum = $grow[7];
if($newqty == ""){
$qtymess = "Please Enter Quantity
";
$right = "Not";
$pprod = $gproductname;
$pdes = $gdescription;
$ppr = $gprice;
$pun = $gunit;
$pmin = $gminimum;
}elseif($newqty < $gminimum){
$qtymess = "Minimum Order: ".$gminimum."
";
$right = "Not";
$pprod = $gproductname;
$pdes = $gdescription;
$ppr = $gprice;
$pun = $gunit;
$pmin = $gminimum;
}else{
$additem[] = $gproductname;
$adddesc[] = $gdescription;
$addprice[] = $gprice;
$addunit[] = $gunit;
$addqty[] = $newqty;
$addtot[] = $newqty * $gprice;
}
}
}
}
$result = @mysql_query("SELECT id,productname,description,unit,minimum FROM prices ORDER BY productname");
if (!$result){
echo ("Error Getting Product Info!
Error:" . mysql_error() . "
");
}else{
while($row = mysql_fetch_array($result)){
$pid[] = $row[0];
$productname[] = $row[1];
$description[] = $row[2];
$unit[] = $row[3];
$minimum[] = $row[4];
}
}
$tsum = array_sum($addtot);
$total = sprintf("%01.2f", $tsum);
?>
Item Code
| Description
| Price
| Unit
| QTY
| Total
|
$said = " ";
if(!empty($additem)){
$i = 0;
$addcount = count($additem);
while($i < $addcount){
if($addprice[$i] == 0 or $addprice[$i] == ""){
$said = " Not including Quoted ";
$pricey = "Quoted";
$totty = "Q ";
}else{
$pry = sprintf("%01.2f", $addprice[$i]);
$pricey = "$".$pry;
$toy = sprintf("%01.2f", $addtot[$i]);
$totty = "$".$toy;
}
echo("" .
"" .
" | $adddesc[$i] | $pricey | $addunit[$i] | $addqty[$i] | $totty |
");
$i = $i + 1;
}
}
if(!empty($addtot)){
echo("SUB-TOTAL: $said $$total |
");
}
?>