"Predefined Price Range" Mod
1.0.7.x
|
| Price: |
USD 0 |
| Module Type: |
Property Record Mods |
| Version: |
1.0.7.x |
| Supported?: |
Yes (free) |
|
Module Description:
|
|
|
This mod allow you to predefine the price range values and store them in mysql table..
1) Edit advsearchform.php
Change
// Price range, outputs the values according to the configuration settings // price_range_min TO price_range_max with the step of price_range_step $price_range = ''; for ($i = $conf['price_range_min']; $i <= $conf['price_range_max']; $i = $i + $conf['price_range_step']) $price_range.= '<option value="' . $i . '">' . $conf['currency'] . ' ' . number_format($i) . '</option>' . " ";
echo userform ($lang['Search_Price_Range'], ' <select name="price_min"> <option value="ANY">' . $lang['Search_Any'] . '</option> ' . $price_range . ' </select>');
echo userform ('', '
<select name="price_max"> <option value="ANY">' . $lang['Search_Any'] . '</option> ' . $price_range . ' </select>');
to
$sql = 'SELECT * FROM ' . PRICE_TABLE . ' ORDER BY price1'; $r = $db->query ( $sql ) or error ('Critical Error', mysql_error () );;
$price_range = ''; while ($f=$db->fetcharray($r)) $price_range .= '<option value="' . $f['price1'] . '">' . $f['price1'] . '</option>';
echo userform ($lang['Search_Price_Range'], ' <select name="price_min"> <option value="ANY">' . $lang['Search_Any'] . '</option> ' . $price_range . ' </select>');
$sql = 'SELECT * FROM ' . PRICE_TABLE . ' ORDER BY price2'; $r = $db->query ( $sql ) or error ('Critical Error', mysql_error () );;
$price_range = ''; while ($f=$db->fetcharray($r)) $price_range .= '<option value="' . $f['price2'] . '">' . $f['price2'] . '</option>';
echo userform ('', '
<select name="price_max"> <option value="ANY">' . $lang['Search_Any'] . '</option> ' . $price_range . ' </select>');
2) Edit config.php
add this to all other tables:
define('PRICE_TABLE', $table_prefix.'price');
3) Use this prices.php:
<?
// phpMyRealty 1.0 // // File Name: locations.php // File Location : ./ // // Copyright (c)2006 phpMyRealty.com // // e-mail: support@phpMyRealty.com
// LOCATIONS MODULE
// Set the number of listing per row in the table $setup_rows = 3;
echo table_header ( 'Price Range' );
// Select all locations from the database $sql = 'SELECT * FROM ' . PRICE_TABLE . ' ORDER BY price1'; $r = $db->query ( $sql ) or error ('Critical Error', mysql_error () );;
echo '<table width="100%" cellpadding="5" cellspacing="0" border="0"> <tr> <td width="' . 100 / $setup_rows . '%" align="left" valign="top"> <ul> ';
// Calculate the number of listings per row ($setup_rows rows) $results_amount = ceil ($db->numrows($r) / $setup_rows);
// Total Results $results_total = $db->numrows($r);
$results = 0; $rows = 0;
while ($f = $db->fetcharray($r))
{
$rows++; $results++;
if ($conf['rewrite'] == 'ON') echo '<li> <a href="' . URL . '/Price/' . $f['price1'] . '-' . $f['price2'] . '.html">' . $conf['currency'] . ' ' . number_format($f['price1']) . ' - ' . number_format($f['price2']) . '</a><br>'; else echo '<li> <a href="' . URL . '/search.php?price_min=' . $f['price1'] . '&price_max=' . $f['price2'] . '">' . $conf['currency'] . ' ' . number_format($f['price1']) . ' - ' . number_format($f['price2']) . '</a><br>';
// Restart the row each time we reach the maximum listing per row // Do not create new row if this is a last element of the array if ($rows == $results_amount && $results != $results_total)
{ echo ' </ul> </td> <td width="' . 100 / $setup_rows . '%" align="left" valign="top"> <ul> '; // Clean the $rows variable for the new row listings counter $rows = 0; }
}
echo ' </ul> </td> </tr> </table> ';
echo table_footer ();
?>
4) Create this update.php script in your PMR root folder and run it in your browser:
<?
include ('./config.php'); include ('./includes/functions.php'); include ('./includes/db.php');
$db = new Dbaccess; $db->connect ( $dbi['sql_host'], $dbi['sql_username'], $dbi['sql_password'], $dbi['sql_dbname'] ) or error('Critial Error', mysql_error () );
// Unset all sql datails for the security purposes unset ( $dbi );
$db->query('CREATE TABLE ' . PRICE_TABLE . ' (price1 varchar(255) DEFAULT NULL, price2 varchar(255) DEFAULT NULL, id int(5) UNSIGNED auto_increment, PRIMARY KEY (id))') or error('Critical Error', mysql_error () );
$db->close();
?>
5) Edit your /admin/navigation.php
add this
echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/price.php"><img src="' . URL . '/admin/template/images/icons/manage.png" valign="top" border="0" alt=""><br>Edit Price Ranges</a></td>';
after
echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/cms.php"><img src="' . URL . '/admin/template/images/icons/manage.png" valign="top" border="0" alt=""><br>CMS</a></td>';
6) Add this price.php file to your /admin folder:
<?php
// phpMyRealty 1.0 // // File Name: price.php // File Location : ./admin/ // // Copyright (c)2006 phpMyRealty.com // // e-mail: support@phpMyRealty.com
// Include configuration file and general functions include ( '.././config.php' ); include ( PATH . '/defaults.php' ); include ( PATH . '/admin/functions.php' );
// ---------------------------------------------------------------------- // ADMIN PANEL / EDIT TYPES, LOCATIONS, ETC
// Title tag $title = '';
// Template header include ( PATH . '/admin/template/header.php' );
// If logged we can start the page output if (admin_auth_check($session->fetch('login'), $session->fetch('password')))
{
// Include navigation panel include ( PATH . '/admin/navigation.php' );
// Make sure this administrator have access to this script checkprivileges ('manage_types', $session->fetch('login')) or error ('Critical Error', 'Incorrect privileges');
// Set the table to edit and the name of that table
$table = PRICE_TABLE; $name = 'PRICE RANGE';
// If the form is submitted we save the data if (isset($_POST['submit_item']) && $_POST['submit_item'] == $lang['Admin_Item_Submit']) {
echo table_header ( $lang['Information'] );
$form = array_map ( 'safehtml', $_POST );
// Initially we think that no errors were found $count_error = 0;
if ($count_error == 0)
{
// Update the database $sql = 'INSERT INTO ' . $table . '
(price1, price2) VALUES ("' . $form['price1'] . '", "' . $form['price2'] . '")';
$db->query( $sql ) or error ('Critical Error', mysql_error () );
echo $lang['Admin_Item_Added'];
}
echo table_footer ( );
}
// If the ite was removed we clean the data if (isset($_POST['remove_item']) && $_POST['remove_item'] == $lang['Admin_Item_Remove']) {
echo table_header ( $lang['Information'] );
// Get the selected checkboxes from the form $form = array_map ( 'safehtml', $_POST );
$count_error = 0;
if (empty($form['id'])) { echo $lang['Field_Empty'] . ' - <span class="warning">ID</span><br>'; $count_error++;}
if ($count_error == 0)
{
// Delete the record from the database $sql = 'DELETE FROM ' . $table . ' WHERE id = "' . $form['id'] . '"';
$db->query( $sql ) or error ('Critical Error', mysql_error () ); echo $lang['Admin_Item_Removed'];
} echo table_footer();
}
// Fetching the data from the database $sql = 'SELECT * FROM ' . $table; $r = $db->query( $sql );
// Generating the form echo table_header ( $name );
echo '<form action = "' . URL . '/admin/price.php" method="POST"> ';
echo ' <table cellpadding="5" cellspacing="0" border="0">';
while ($f = $db->fetcharray( $r )) echo ' <tr><td width="30" align="middle" align="center" ><input type="radio" name="id" value="' . $f['id'] . '"></td><td align="left" valign="top"> <span class="warning">' . $f['price1'] . ' - ' . $f['price2'] . '</span> </td></tr>';
echo ' <tr><td colspan="2" align="left" valign="top"><br><br> Price Range: <input type="text" name="price1" value="" size="10" maxlength="50"> - <input type="text" name="price2" value="" size="10" maxlength="50"> <input type="submit" name="submit_item" value="' . $lang['Admin_Item_Submit'] . '"> <input type="submit" name="remove_item" value="' . $lang['Admin_Item_Remove'] . '"> </td></tr>
';
echo ' </table> </form>';
echo table_footer ();
}
else
{
error ('Critical Error' , 'Please, login to access this script.');
}
// Template footer include ( PATH . '/admin/template/footer.php' );
?>
|
Downloaded / Viewed: 550
Submission Date: 09-15-2007
Last Update: --
|
|
|
|