i need to fetch multiple row or single row from mysql table, but my code retrieve data from table only multiple rows as given in my where clause condition is true, not fetch single row even my condition is true. plz suggest me anyone. (i know only little bit english)
<?php
include 'connection/db_connection.php';
$sqlquery=mysql_query("select * from sadmin_invoiceno order by sno desc");
$row1=mysql_fetch_assoc($sqlquery);
$invoice=$row1['invoice_no'];
/* if($row1['invoice_no']<=9)
{
$myvalue=$row1['invoice_no'];
$idvalue="".$myvalue;
}
if($row1['invoice_no']>9 && $row1['sno']<100)
{
$myvalue=$row1['invoice_no'];
$idvalue="".$myvalue;
} */
$sql="SELECT * FROM sadmin_sales where invoice_no='".$invoice."'";
$result = mysql_query($sql);
$count=mysql_num_rows($result);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>IT Flower invoice</title>
<link rel="stylesheet" href="assets/css/style_popup.css" media="all" />
<link href="assets/css/utopia-white.css" rel="stylesheet">
</head>
<body>
<div class="invoice">
<header class="clearfix">
<div id="logo">
<img src="assets/img/utopia-logo1.png">
</div>
<div id="company">
<h2 class="name">Indian Traditional Flowers</h2>
<div>10 - 3500 McNicoll Ave., <br>Toronto, Ontario ON M1V 4c7</div>
<div>+1.647.836.9999</div>
<div>info#itflowers.com</div>
</div>
</header>
<main>
<div id="details" class="clearfix">
<div id="client">
<div class="to">INVOICE TO:</div>
<h2 class="name"><?php
$sql2=mysql_query("SELECT franchies, customer FROM sadmin_sales where invoice_no='".$invoice."'");
$res1=mysql_fetch_array($sql2);echo $res1['customer'];
$franchies= $res1['franchies'];
$sql3=mysql_query("SELECT * FROM sadmin_customer where email='".$franchies."'");
$res2=mysql_fetch_array($sql3);
echo $res2['shop_name'];
?></h2>
<div class="address"> <?php echo $res2['owner_name']; ?> </div>
<div class="address"><?php echo $res2['address']; ?></div>
<div class="email"><?php echo $res2['email']; ?></div>
<div class="email"><?php echo $res2['phone']; ?></div>
</div>
<div id="invoice">
<h1>INVOICE NO: <?php echo $invoice; ?></h1>
<div class="date">Date of Invoice: <?php echo $date = date('d/m/Y h:i:s a'); ; ?></div>
</div>
</div>
<table class="inventory" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr style="text-align: center;">
<th class="no">#</th>
<th class="desc">DESCRIPTION</th>
<th class="unit">UNIT PRICE</th>
<th class="qty">QUANTITY</th>
<th class="total">TOTAL</th>
</tr>
</thead>
<tbody>
<tr>
<?php
$tax=0;
$ship=0;
$paid=0;
$bal=0;
$grand=0;
$sum=0;
for($i=1; $i<$count;)
{
while($row = mysql_fetch_array($result))
{
$franchies = $row['franchies'];
echo "<td class='no'>".$i."</td> ";
echo "<td class='desc'>" . $row['product_name'] . "</td>";
echo "<td class='unit'>" . $row['unit_price'] . "</td>";
echo "<td class='qty'>" . $row['quantity'] . "</td>";
echo "<td class='total' >".$row['total']."</td>";
echo "</tr>";
$sum=$sum + $row['total'];
$i++;
//$tax=$sum *.13;
$include=$row['tax_type'];
if ($include =='includetax')
{
$tax1=mysql_query("select * from sadmin_tax where tax_type like 'include%'");
$res1=mysql_fetch_array($tax1);
$tax2=$res1['percentage'];
$tax=$sum * $tax2/100;
$sum1=$sum - $tax;
}
else
{
$tax3=mysql_query("select * from sadmin_tax where tax_type like 'exclude%'");
$res3=mysql_fetch_array($tax3);
$tax4=$res3['percentage'];
$tax=$sum * $tax4/100;
$sum1=$sum + $tax;
}
$ship=$row['shipping_amt'];
$paid=$row['paid_amt'];
$grand=$sum1 + $ship;
$bal=$grand - $paid;
}
}
?>
</tbody>
<tfoot>
<tr>
<td colspan="2"></td>
<td colspan="2">SUBTOTAL</td>
<td>$ <?php echo $sum; ?></td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">TAX 13%</td>
<td>$ <?php echo $tax; ?></td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">SHIP</td>
<td>$<?php echo $ship; ?></td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">PAID</td>
<td>$<?php echo $paid; ?></td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">BALANCE</td>
<td>$<?php echo $bal; ?></td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">GRAND TOTAL</td>
<td>$<?php echo $grand; ?></td>
</tr>
</tfoot>
</table>
<button onclick="myFunction()" class="btn btn-primary" style="width: 106px;float: right;">Print this page</button>
<!-- <div id="thanks">Thank you!</div>
<div id="notices">
<div>NOTICE:</div>
<div class="notice">A finance charge of 1.5% will be made on unpaid balances after 30 days.</div>
</div>
</main>
<footer>
Invoice was created on a computer and is valid without the signature and seal.
</footer> -->
</div>
<script>
function myFunction() {
window.print();
}
</script>
</body>
</html>
I'm not certain I understand your question fully, are you saying you have multitple rows but only want one?
If so , check out MySQL "LIMIT " which will limit your SQL query to X number of rows, such as SELECT * FROM sadmin_customer where email='".$franchies." LIMIT 1
This will return only 1 row, the first row where the conditions are true.
Related
I'm having trouble to collapse the next row in table. My code works only for the first row of the table where ever I click the collapse button.
Code :
<table id="yourEvent" class="table table-hover">
<thead>
<tr>
<td style="text-align: center" width="20px"><strong>No.</strong></td>
<td><strong>Attendee Name</strong></td>
</tr>
</thead>
<?php while($row = mysqli_fetch_array($resultAttendeeList))
{ ?>
<tbody>
<tr>
<td class="counterCell" style="text-align: center" width="20px"></td>
<td><button type="button" class="btn btn-xs bg-maroon" style="width: 20px" data-toggle="collapse" data-target="#divCol"><i class="fa fa-plus"></i></button> <?php echo $row['fullname'];?>
<div class="collapse" id="divCol">
<table>
<tr>
<td>Address: <?php echo $row['address']; ?></td>
</tr>
<tr>
<td>Contact: 0<?php echo $row['contact']; ?></td>
</tr>
</table>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
You are using same ID for multiple divs in your loop. You can create incremental int variable and concatenate in your div IDs.
try this code: added $ctr variable increments through loop. Also, you should start your loop after the <tbody> tag.
<tbody>
<?php $ctr=1;
while($row = mysqli_fetch_array($resultAttendeeList))
{ ?>
<tr>
<td class="counterCell" style="text-align: center" width="20px"></td>
<td><button type="button" class="btn btn-xs bg-maroon" style="width: 20px" data-toggle="collapse" data-target="#divCol_<?=$ctr?>"><i class="fa fa-plus"></i></button> <?php echo $row['fullname'];?>
<div class="collapse" id="divCol_<?=$ctr?>">
<table>
<tr>
<td>Address: <?php echo $row['address']; ?></td>
</tr>
<tr>
<td>Contact: 0<?php echo $row['contact']; ?></td>
</tr>
</table>
</div>
</td>
</tr>
<?php $ctr=$ctr+1; } ?>
Please try this is complete code. Please give dynamic id. make sure when you process any jquery/javascript operation, divid should always unique. Otherwise event will not bind for all element.
<?php
$servername = "host";
$username = "user";
$password = "pass";
// Create connection
$conn = mysqli_connect($servername, $username, $password, 'testdb');
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM table ORDER BY ID limit 5";
$result = mysqli_query($conn, $sql);
// Numeric array
//$row = mysqli_fetch_array($result);
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<table id="yourEvent" class="table table-hover">
<thead>
<tr>
<td style="text-align: center" width="20px"><strong>No.</strong></td>
<td><strong>Attendee Name</strong></td>
</tr>
</thead>
<tbody>
<?php
$j = 1;
while ($row = mysqli_fetch_array($result)) {
?>
<tr>
<td class="counterCell" style="text-align: center" width="20px"><?php echo $j; ?></td>
<td>
<button type="button" class="btn btn-xs bg-maroon" style="width: 20px" data-toggle="collapse" data-target="#divCol_<?php echo $j; ?>">
<i class="fa fa-plus"></i>
</button> <?php echo $row['EMP_FULLNAME']; ?>
<div class="collapse" id="divCol_<?php echo $j; ?>">
<table>
<tr>
<td>Address: <?php echo $row['EMP_ADDRESS']; ?></td>
</tr>
<tr>
<td>Contact: 0<?php echo $row['EMP_MOBILE']; ?></td>
</tr>
</table>
</div>
</td>
</tr>
<?php
$j++;
}
?>
</tbody>
</table>
</body>
</html>
I want set page like below
I want to set the page like the picture
But it show like the below picture.
But it show like below
Now what can I do?
<?php
mysql_connect("localhost","root");
mysql_select_db("simple");
$res=mysql_query("SELECT c.*, a.* FROM simple_tb c, ac a WHERE c.id=a.sid ");
while($row=mysql_fetch_array($res))
{
?>
<link rel="stylesheet" type="text/css" href="demo.css" media="screen" /></head>
<h1 align="center"> ABC IDEAL SCHOOL AND COLLEGE</h1>
<h3 align="center">Baraiyahat, Chittagong, 01772969874 </h3>
<p align="center">Students Tuetion Fee Payment Sheet<br></p>
<table class="table" align="center"width="800" bgcolor="skyblue">
<tr><td width="25%">ID No:</td><td width="25%"><?php echo $row['sid'];?></td></tr>
<tr><td>Name:</td> <td><?php echo $row['n'];?></td></tr>
<tr><td>Class:</td><td><?php echo $row['c'];?></td></tr>
<tr><td>Roll:</td> <td><?php echo $row['r'];?></td></td></tr>
</table>
<br>
<h4 ALIGN="CENTER">PAYMENT STATUS</H4>
<table align="center"width="800" BORDER="1" bgcolor="LIGHTGREEN">
<tr><td align="center"><B>DATES</B></td><td align="center"><B>DESCRIPTION</B></td><td align="center"><B>MEMO NO</B></td><td align="center"><B>BDT</B></td></tr>
<tr>
<td align="center"><?php echo $row['d'];?></td>
<td align="center"><?php echo $row['des'];?></td>
<td align="center"><?php echo $row['m'];?></td>
<td align="center"><?php echo $row['t'];?></td>
<td align="center"></td>
</tr>
</table>
<?php
}
?>
You can use nested loops as follows, this needs a bit of tweaking since it's not tested.
<?php
mysql_connect("localhost","root");
mysql_select_db("simple");
$res=mysql_query("SELECT c.* FROM simple_tb c");
while($row=mysql_fetch_array($res))
{
?>
<link rel="stylesheet" type="text/css" href="demo.css" media="screen" /></head>
<h1 align="center"> ABC IDEAL SCHOOL AND COLLEGE</h1>
<h3 align="center">Baraiyahat, Chittagong, 01772969874 </h3>
<p align="center">Students Tuetion Fee Payment Sheet<br></p>
<table class="table" align="center"width="800" bgcolor="skyblue">
<tr><td width="25%">ID No:</td><td width="25%"><?php echo $row['id'];?></td></tr>
<tr><td>Name:</td> <td><?php echo $row['n'];?></td></tr>
<tr><td>Class:</td><td><?php echo $row['c'];?></td></tr>
<tr><td>Roll:</td> <td><?php echo $row['r'];?></td></td></tr>
</table>
<br>
<?php
mysql_connect("localhost","root");
mysql_select_db("simple");
$res=mysql_query("SELECT a.* FROM simple_tb c, ac a WHERE c.id=a.sid ");
while($row2=mysql_fetch_array($res))
{
?>
<h4 ALIGN="CENTER">PAYMENT STATUS</H4>
<table align="center"width="800" BORDER="1" bgcolor="LIGHTGREEN">
<tr><td align="center"><B>DATES</B></td><td align="center"><B>DESCRIPTION</B></td><td align="center"><B>MEMO NO</B></td><td align="center"><B>BDT</B></td></tr>
<tr>
<td align="center"><?php echo $row2['d'];?></td>
<td align="center"><?php echo $row2['des'];?></td>
<td align="center"><?php echo $row2['m'];?></td>
<td align="center"><?php echo $row2['t'];?></td>
<td align="center"></td>
</tr>
</table>
<?php
}
?>
<?php
}
?>
<?php
mysql_connect("localhost","root");
mysql_select_db("simple");
$res=mysql_query("SELECT * FROM simple_tb");
while($row=mysql_fetch_array($res))
{
?>
<link rel="stylesheet" type="text/css" href="demo.css" media="screen" /></head>
<h1 align="center"> ABC IDEAL SCHOOL AND COLLEGE</h1>
<h3 align="center">Baraiyahat, Chittagong, 01772969874 </h3>
<p align="center">Students Tuetion Fee Payment Sheet<br></p>
<table class="table" align="center"width="800" bgcolor="skyblue">
<tr><td width="25%">ID No:</td><td width="25%"><?php echo $row['id'];?></td></tr>
<tr><td>Name:</td> <td><?php echo $row['n'];?></td></tr>
<tr><td>Class:</td><td><?php echo $row['c'];?></td></tr>
<tr><td>Roll:</td> <td><?php echo $row['r'];?></td></td></tr>
</table>
<br>
<h4 ALIGN="CENTER">PAYMENT STATUS</H4>
<table align="center"width="800" BORDER="1" bgcolor="LIGHTGREEN">
<tr>
<td align="center"><B>DATES</B></td>
<td align="center"><B>DESCRIPTION</B></td>
<td align="center"><B>MEMO NO</B></td>
<td align="center"><B>BDT</B></td>
</tr>
<?php
$res2=mysql_query("SELECT * FROM ac WHERE sid=".$row['id']);
while($row2=mysql_fetch_array($res2))
{
?>
<tr>
<td align="center"><?php echo $row2['d'];?></td>
<td align="center"><?php echo $row2['des'];?></td>
<td align="center"><?php echo $row2['m'];?></td>
<td align="center"><?php echo $row2['t'];?></td>
<td align="center"></td>
</tr>
<?php
}
</table>
}
?>
This will work for you
**Look at the picture **
I want to see the page without 'Notice:' because here all the result I think works finely. But why does it shows. Any Mistake? Please help me.
The code is like:
<?php
mysql_connect("localhost","root");
mysql_select_db("simple");
$id=$_POST['id'];
$res=mysql_query("SELECT * FROM simple_tb WHERE id=$id");
while($row=mysql_fetch_array($res))
{
?>
<link rel="stylesheet" type="text/css" href="demo.css" media="screen" /></head>
<h1 align="center"> ABC IDEAL SCHOOL AND COLLEGE</h1>
<h3 align="center">Baraiyahat, Chittagong, 01772969874 </h3>
<p align="center">Students Tuetion Fee Payment Sheet<br></p>
<table class="table" align="center"width="800" bgcolor="skyblue">
<tr><td width="25%">ID No:</td><td width="25%"><?php echo $row['id'];?></td></tr>
<tr><td>Name:</td> <td><?php echo $row['n'];?></td></tr>
<tr><td>Class:</td><td><?php echo $row['c'];?></td></tr>
<tr><td>Roll:</td> <td><?php echo $row['r'];?></td></td></tr>
</table>
<br>
<h4 ALIGN="CENTER">PAYMENT STATUS</H4>
<table align="center"width="800" BORDER="1" bgcolor="red">
<tr>
<td align="center"><B>DATES</B></td>
<td align="center"><B>DESCRIPTION</B></td>
<td align="center"><B>MEMO NO</B></td>
<td align="center"><B>BDT</B></td>
<td align="center"><B>Con.Total</B></td>
</tr>
<?php
$res2=mysql_query("SELECT * FROM ac WHERE sid=".$row['id']);
while($row2=mysql_fetch_array($res2))
{ $sum+= $row2['t'];
?>
<tr bgcolor="cream">
<td bgcolor="white"align="center"><?php echo $row2['d'];?></td>
<td bgcolor="white"align="center"><?php echo $row2['des'];?></td>
<td bgcolor="white"align="center"><?php echo $row2['m'];?></td>
<td bgcolor="white"align="center"><?php echo $row2['t'];?></td>
<td bgcolor="white"align="center"><?php echo $sum."<br>";?></td>
<td bgcolor="white"align="center"></td>
</tr>
<?php
}
?></table><?php
}
Now please tell me details what can I do for the written code.
You need to assign value of sum to 0 before while loop
<?php
$sum = 0;
$res2=mysql_query("SELECT * FROM ac WHERE sid=".$row['id']);
while($row2=mysql_fetch_array($res2))
{ $sum+= $row2['t'];
?>
Try this one. You have used somewhere mysql and some where mysqli. That is one problem.
<?php
$con = mysqli_connect("localhost","root","");
mysqli_select_db($con,"simple");
$id=$_POST['id'];
$res=mysqli_query($con,"SELECT * FROM simple_tb WHERE id=$id");
while($row=mysqli_fetch_array($res))
{
?>
<link rel="stylesheet" type="text/css" href="demo.css" media="screen" />
</head>
<h1 align="center"> ABC IDEAL SCHOOL AND COLLEGE</h1>
<h3 align="center">Baraiyahat, Chittagong, 01772969874 </h3>
<p align="center">Students Tuetion Fee Payment Sheet<br></p>
<table class="table" align="center"width="800" bgcolor="skyblue">
<tr><td width="25%">ID No:</td><td width="25%"><?php echo $row['id'];?>
</td></tr>
<tr><td>Name:</td> <td><?php echo $row['n'];?></td></tr>
<tr><td>Class:</td><td><?php echo $row['c'];?></td></tr>
<tr><td>Roll:</td> <td><?php echo $row['r'];?></td></td></tr>
</table>
<br>
<h4 ALIGN="CENTER">PAYMENT STATUS</H4>
<table align="center"width="800" BORDER="1" bgcolor="red">
<tr>
<td align="center"><B>DATES</B></td>
<td align="center"><B>DESCRIPTION</B></td>
<td align="center"><B>MEMO NO</B></td>
<td align="center"><B>BDT</B></td>
<td align="center"><B>Con.Total</B></td>
</tr>
<?php
$res2=mysqli_query($con,"SELECT * FROM ac WHERE sid=".$row['id']);
while($row2=mysqli_fetch_array($res2))
{ $sum+= $row2['t'];
?>
<tr bgcolor="cream">
<td bgcolor="white"align="center"><?php echo $row2['d'];?></td>
<td bgcolor="white"align="center"><?php echo $row2['des'];?>
</td>
<td bgcolor="white"align="center"><?php echo $row2['m'];?></td>
<td bgcolor="white"align="center"><?php echo $row2['t'];?></td>
<td bgcolor="white"align="center"><?php echo $sum."<br>";?></td>
<td bgcolor="white"align="center"></td>
</tr>
<?php
}
?></table><?php
``}
I am trying to make a button that would print my database in a contact list format. Where they would be grouped under the Departments that the contacts are added to on the php forms. Like this: (BELOW IS MY CODE FOR THE CONTACT PAGE)
ADMIN
George George#snakdnasd 0282738292392
8432
IT DEPARTMENT
Tyler tyler#askdnasdksan 7492823829292 8321
I have looked around and have tried the usual commands like window.print and just print() but it just prints the actual php page.
<?php
require_once"connection.php";
$contacts = array();
$all_contacts = "select * from contacts where contact_status = '1'";
$sql_all_contacts = $conn->query($all_contacts);
$total_contacts = $sql_all_contacts->num_rows;
while ($row = mysqli_fetch_assoc($sql_all_contacts)) {
$contacts[] = $row;
}
?>
<!DOCTYPE html>
<html>
<head>
<?php include"includes/head.inc"; ?>
</head>
<body>
<div class="wrapper">
<!-- header section -->
<?php include"includes/header.inc"; ?>
<!-- content section -->
<div class="content">
<div class="floatl"><h1><?php echo $total_contacts ?> Contact(s) Total</h1></div>
<a class="floatr" href="insert_contact.php"><input class="cancel_contact_button" type="button" value="New Contact"></a>
<div class="clear"></div>
<hr class="pageTitle">
<table border ="1" style="width:100%" id="contactsTable" class="display">
<thead>
<tr align="left">
<th>Name:</th>
<th>Email:</th>
<th>Department:</th>
<th>Extension:</th>
<th>Cellphone:</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($contacts as $contact) {?>
<tr>
<td><?php echo $contact["name"];?></td>
<td><?php echo $contact["email"]; ?></td>
<td><?php echo $contact["department"]; ?></td>
<td><?php echo $contact["extension"]; ?></td>
<td><?php echo $contact["cellphone"]; ?></td>
<td><i class="fa fa-pencil"></i> | <i class="fa fa-trash-o"></i></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</body>
</html>
I have a code :
<?php
getPriceListHeader();
function getPriceListDetail($PriceListCode)
{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = "SELECT * FROM pricelisdetail where pricelist_code='".$PriceListCode."'";
$results = $readConnection->fetchAll($query);
echo "<table id='tbdata'>
<thead>
<tr>
<th>Price List Code</th>
<th>Price List Name</th>
<th>Effective From</th>
<th>Effective To</th>
</tr>
</thead>
<tbody> ";
foreach ($results as $row)
{
echo "<tr>";
echo "<td> ".$row[entity_id];
echo "<td> ".$row[sku];
echo "<td> ".$row[sku];
echo "<td> ".$row[sku];
};
echo " </tbody>
</table> ";
}
function getPriceListHeader()
{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = 'SELECT * FROM pricelistheader';
$results = $readConnection->fetchAll($query);
echo "
<h2>Price List</h2>
<div>
<h3>Please select Price List</h3>
<div>
<select class='element select large' id='pricelist' name='element_2'>";
foreach ($results as $row)
{
echo '<option value="' . $row[entity_id]. '">' . $row[sku] . '</option>';
}
echo "</select>
</div>
<input type='button' class='button' name='insert' value='Get Data' onclick='getPriceListDetail(pricelist.value)'/>
";
getPriceListDetail('');
}
?>
I have a dropdown list, a button, a table
When I select a value from dropdown list, then I click button , table will be filled data again. There are 2 method, getPriceListHeader(): load data header when load the page, getPriceListDetail : load data detail when click a button. I try to put event getPriceListDetail(value) to button, but when I click, nothing happens
Please help me how to do this.
Yes, you can call php via ajax request to server like this (very simple):
Note that the following code uses jQuery
jQuery.ajax({
type: "POST",
url: 'my_php_function.php',
dataType: 'name_the_data_type',
success: function (data) {
// here you will get the response your function
}
});
and my_php_function.php like this:
<?php
// here is your php code or function
?>
from the source How can I call PHP functions by JavaScript?
You can't attach PHP function to HTML. PHP is server-side language, so after it's displayed in users browser you can't refer to PHP again, unless you reload page.
There are 3 options I think you can do:
Reload page after changing select page and using GET prepare new data.
Send all data to user browser and than show only part of it related to selected option.
Use AJAX and ask server for new data in background.
Finally, I found out the way.It works for me. Now, I do not understand the code , I am trying to read and get it clearly.
Thanks all for your comments.
$to="";
$from="";
$show_order_statuses = 0;
$orserstatus = "";
$result_order = 0;
//var_dump($results);
//return;
if(!empty($_REQUEST['filter_type']))
{
$orders_row = array();
$filter_type = $_REQUEST['filter_type'];
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = " SELECT * FROM pricelistitem where pricelist_code='".$filter_type."' ";
// $query = 'SELECT * FROM pricelistheader1';
$results = $readConnection->fetchAll($query);
foreach ($results as $rowid)
{
$result_order=10;
$orders_row[]=array($rowid['pricelist_code'],$rowid['product_code'],number_format( $rowid['unitprice'],2),$rowid['UOM']);
// $orders_row[]=array(1,1,1,1,1);
}
}
?>
<div id="anchor-content" class="middle">
<div id="page:main-container">
<div class="content-header">
<table cellspacing="0">
<tbody>
<tr>
<td style="width:50%;"><h3 class="icon-head head-report-sales-sales"><?php echo $this->__("Price List");?></h3></td>
<td class="form-buttons"><button style="" onclick="filterFormSubmit.submit()" class="scalable " type="button" id="id_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>"><span>Show Report</span></button></td>
</tr>
</tbody>
</table>
</div>
<div>
<div class="entry-edit">
<form method="get" action="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" id="filter_form">
<?php /*?><input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" /><?php */?>
<div class="entry-edit-head">
<h4 class="icon-head head-edit-form fieldset-legend">Filter</h4>
<div class="form-buttons"></div>
</div>
<div id="sales_report_base_fieldset" class="fieldset">
<div class="hor-scroll">
<table cellspacing="0" class="form-list">
<tbody>
<tr>
<td class="label"><label for="sales_report_filter_type">Filter By <span class="required">*</span></label></td>
<td class="value">
<select class="required-entry select" name="filter_type" id="sales_report_filter_type" onchange="myFunction();">
<?php
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = " SELECT * FROM pricelistheader ";
$results = $readConnection->fetchAll($query);
$so=1;
foreach ($results as $row)
{
$selected='';
if ($filter_type==$row[pricelist_code])
$selected= ' selected=selected';
else
$selected='';
echo '<option value="' . $row[pricelist_code]. '" '.$selected.' >' . $row[pricelist_name].' '. $row[pricelist_code] . '</option>';
}
?>
</select>
</tr>
<tr>
<td class="label"><label for="effect_from">Effect From </label></td>
<td class="value">
<?php
foreach ($results as $row)
{
if ($filter_type==$row[pricelist_code])
echo $row[pricelist_fromdate];
}
?>
</td>
</tr>
<tr>
<td class="label"><label for="effect_from">Effect To </label></td>
<td class="value">
<?php
foreach ($results as $row)
{
if ($filter_type==$row[pricelist_code])
echo $row[pricelist_todate];
}
?>
</td>
</tr>
</tbody>
<script>
function myFunction() {
// document.getElementById("tbdata").deleteRow(1);
var rowCount = tbdata.rows.length;
for (var i = rowCount - 1; i > 0; i--) {
tbdata.deleteRow(i);
}
srt.value=pricelist.options[pricelist.selectedIndex].value;
";
//$('#tbdata').empty();
}
</script>
</table>
</div>
</div>
</form>
</div>
<script type="text/javascript">
//<![CDATA[
var filterFormSubmit = new varienForm('filter_form');
//]]>
</script>
<script type="text/javascript"> new FormElementDependenceController({"sales_report_order_statuses":{"sales_report_show_order_statuses":"1"}}); </script>
<style type="text/css">
.no-display{display:none;}
</style>
</div>
<div>
<?php if($result_order>0){?>
<table cellspacing="0" class="actions">
<tbody>
<tr>
<td class="pager"> </td>
<td class="export a-right">
<form method="post" action="<?php echo $this->getUrl('*/*/exportCsv')?>" id="csv_form_customer">
<input name="form_key_customer" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
</form>
<script type="text/javascript">
//<![CDATA[
var csvFormSubmitcustomer = new varienForm('csv_form_customer');
//]]>
</script>
</td>
<td class="filter-actions a-right">
<img class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>skin/adminhtml/default/default/images/icon_export.gif"> Export to:
<select style="width:8em;" id="sales_order_grid_export_customer" name="sales_order_grid_export_customer">
<option value="<?php echo $this->getUrl('*/*/exportCsv')?>">CSV</option>
</select>
<button onclick="csvFormSubmitcustomer.submit()" class="scalable task" type="button"><span>Export</span></button>
</td>
</tr>
</tbody>
</table>
<?php } ?>
<div id="id_customer<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" class="print_customer<?php echo Mage::getSingleton('core/session')->getFormKey() ?>">
<div class="grid">
<div class="hor-scroll">
<table cellspacing="0" id="id_customer<?php echo Mage::getSingleton('core/session')->getFormKey() ?>_table" class="data">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr class="headings">
<th class=" no-link"><span class="nobr">Price List Code</span></th>
<th class=" no-link"><span class="nobr">Cust Code</span></th>
<th class=" no-link"><span class="nobr">Cust Name</span></th>
</tr>
</thead>
<tbody id="">
<?php
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = " SELECT * FROM " . $resource->getTableName('catalog/product');;
$customercount=0;
$customerresults = $readConnection->fetchAll($query);
$customerresults = Mage::getModel('customer/customer')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('erp_pricelistcode_1', $filter_type)
// ->addFieldToSelect (array('created_at','customer_id','increment_id','updated_at','status','entity_id','state'))
;
// ->addAttributeToFilter('erp_pricelistcode_1','00')->load();
$so=1;
foreach ($customerresults as $row) {
$customercount++;
}
// var_dump(#$customerresults);
if($customercount>0){
foreach($customerresults as $singlerows){
$cot=0;
{
echo "<tr>";
{
$cot++;
?>
<td>
<?php
echo $singlerows->getData('erp_pricelistcode_1');
?>
</td>
<td>
<?php
echo $singlerows->getFirstname();
?>
</td>
<td>
<?php
echo $singlerows->getName();
?>
</td>
<?php
}
echo "</tr>";
}
}
}else{
?>
<tr class="even">
<td colspan="13" class="empty-text a-center">No records found.</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<div>
<?php if($result_order>0){?>
<table cellspacing="0" class="actions">
<tbody>
<tr>
<td class="pager"> </td>
<td class="export a-right">
<form method="post" action="<?php echo $this->getUrl('*/*/exportCsv')?>" id="csv_form">
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
</form>
<script type="text/javascript">
//<![CDATA[
var csvFormSubmit = new varienForm('csv_form');
//]]>
</script>
</td>
<td class="filter-actions a-right">
<img class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>skin/adminhtml/default/default/images/icon_export.gif"> Export to:
<select style="width:8em;" id="sales_order_grid_export" name="sales_order_grid_export">
<option value="<?php echo $this->getUrl('*/*/exportCsv')?>">CSV</option>
</select>
<button onclick="csvFormSubmit.submit()" class="scalable task" type="button"><span>Export</span></button>
</td>
</tr>
</tbody>
</table>
<?php } ?>
<div id="id_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" class="print_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>">
<div class="grid">
<div class="hor-scroll">
<table cellspacing="0" id="id_<?php echo Mage::getSingleton('core/session')->getFormKey() ?>_table" class="data">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr class="headings">
<th class=" no-link"><span class="nobr">Price List Code</span></th>
<th class=" no-link"><span class="nobr">Product Code</span></th>
<th class=" no-link"><span class="nobr">Unit Price</span></th>
<th class=" no-link"><span class="nobr">UOM</span></th>
</tr>
</thead>
<tbody id="">
<?php
$cot=0;
if(count($orders_row)>0){
foreach($orders_row as $singlerows){
$cot=0;
if(!empty($singlerows)){
echo "<tr>";
foreach($singlerows as $value){
$cot++;
?>
<td>
<?php
if ($cot==3 )
echo "<div style='float:right;width:30%;'>";
echo $value;
echo "</div>";
?>
</td>
<?php
}
echo "</tr>";
}
}
}else{
?>
<tr class="even">
<td colspan="13" class="empty-text a-center">No records found.</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>