include 'conf/conf.main.php';
include '../admin/class/class.sql.php';
$sql = new Sql($cfg['db']['host'], $cfg['db']['username'], $cfg['db']['password'], $cfg['db']['dbname']);
$sql->run('SET NAMES UTF8');
$article_content ='';
$query = "SELECT " .
"products.id, " .
"pr_name, " .
"pr_desc, " .
"pr_price, " .
"pr_proc, " .
"su_id, " .
"ct_name, " .
"ct_desc " .
"FROM products " .
"JOIN categories ON (categories.id=products.ct_id) " .
"JOIN suppliers ON (suppliers.id=products.su_id) " .
"WHERE (ct_lng='" . $cfg['lng'] . "' OR ct_lng='universal') " .
((isset($_GET['product_id']) && $_GET['product_id']>0) ? "AND products.id=" . $_GET['product_id'] . " ": "") .
" ORDER BY products.gen, products.ct_id, pr_name ASC " .
((isset($_GET['product_id']) && $_GET['product_id']>0) ? " LIMIT 1 ": "");
$sql->query($query);
if ($sql->result && $sql->num_rows()>0) {
$article_content .= '
' . "\r\n";
$last = "";
$i = 0;
if (!isset($_GET['product_id'])) {
$article_content .= '' . "\r\n";
$article_content .= '';
if (isset($_GET['product_id']) && $_GET['product_id']>0) $article_content .= 'id';
else $article_content .= '№';
$article_content .= ' | ';
$article_content .= 'Pavadinimas | ';
$article_content .= 'Kaina | ';
$article_content .= '
';
}
while($row = $sql->fetch_assoc()) {
$i++;
if($last != $row['ct_name']) {
$article_content .= '';
$article_content .= '';
$article_content .= '' . "\r\n";
$article_content .= ' | ';
$article_content .= '';
$article_content .= '' . htmlspecialchars(stripslashes($row['ct_name'])) . ' | ';
$article_content .= ' | ';
$article_content .= ' ';
$article_content .= '' . "\r\n";
$article_content .= ' | ';
$article_content .= ' | ';
$article_content .= ' ';
$article_content .= '' . "\r\n";
$article_content .= ' | ';
$article_content .= ' | ';
$article_content .= ' ';
$article_content .= ' ';
$article_content .= ' |
';
$last = $row['ct_name'];
}
if (isset($_GET['product_id']) && $_GET['product_id']>0) {
$article_content .= '' . "\r\n";
$article_content .= '';
$article_content .= '';
$article_content .= '' . "\r\n";
$article_content .= ' | ';
$article_content .= 'Kaina:' . number_format((($row['pr_price']*$row['pr_proc']/100 + $row['pr_price'])*0.18 + $row['pr_price']*$row['pr_proc']/100 + $row['pr_price']), 2, ".", " ") . ' ' . $cfg['currency'] . ' | ';
$article_content .= ' | ';
$article_content .= ' ';
$article_content .= '' . "\r\n";
$article_content .= ' | ';
$article_content .= ' | ';
$article_content .= ' ';
$article_content .= '' . "\r\n";
$article_content .= ' | ';
$article_content .= ' | ';
$article_content .= ' ';
$article_content .= ' ';
$article_content .= ' | ';
$article_content .= '
';
$article_content .= '' . "\r\n";
$article_content .= '' . stripslashes(trim($row['pr_desc'])) . ' |
| ';
$article_content .= '
';
} else {
$article_content .= '' . "\r\n";
$article_content .= '' . "\r\n";
$article_content .= '' . $i . ' | ';
$article_content .= '' . htmlspecialchars(stripslashes($row['pr_name'])) . ' | ';
$article_content .= '' . number_format((($row['pr_price']*$row['pr_proc']/100 + $row['pr_price'])*0.18 + $row['pr_price']*$row['pr_proc']/100 + $row['pr_price']), 2, ".", " ") . " " .$cfg['currency'] . ' | ';
$article_content .= '
';
$article_content .= '';
$article_content .= ' | ';
$article_content .= '
' . "\r\n";
$article_content .= ' |
';
}
/*
|
*/
}
$article_content .= '
';
}
?>