Ejemplo n.º 1
0
    /**
     *	Draws inquiry sub form
     *		@param $params
     *		@param $draw
     */
    private static function DrawInquirySubForm($params, $draw = true)
    {
        $output = '';
        $visitor_locations = isset($params['visitor_locations']) ? $params['visitor_locations'] : '';
        $visitor_sub_locations = isset($params['visitor_sub_locations']) ? $params['visitor_sub_locations'] : '';
        $visitor_description = isset($params['visitor_description']) ? $params['visitor_description'] : '';
        $visitor_availability = isset($params['visitor_availability']) ? $params['visitor_availability'] : '';
        $visitor_preferred_contact = isset($params['visitor_preferred_contact']) ? $params['visitor_preferred_contact'] : '';
        $inquiry_type = isset($params['inquiry_type']) ? $params['inquiry_type'] : '0';
        $locations = ListingsLocations::DrawAllLocations(array('tag_name' => 'visitor_locations', 'tag_id' => 'id_visitor_locations', 'selected_value' => $visitor_locations, 'javascript_event' => 'onchange="jQuery(\'#id_act\').val(\'location_reload\');jQuery(\'#frmInquiryForm\').submit();"'), false) . '  ';
        $sub_locations = ListingsSubLocations::DrawAllSubLocations($visitor_locations, array('tag_name' => 'visitor_sub_locations', 'tag_id' => 'id_visitor_sub_locations', 'selected_value' => $visitor_sub_locations), false);
        $output .= _DESCRIBE_WHAT_YOU_NEED . '<br>';
        $output .= '<textarea id="id_visitor_description" name="visitor_description" maxlength="2048">' . $visitor_description . '</textarea><br><br>';
        $output .= '<b>' . _CONTACT_INFORMATION . '</b> <br>';
        $output .= '<div class="left_panel">
					<label>' . _NAME . ':</label> <input id="id_visitor_name" name="visitor_name" type="text" maxlength="50" autocomplete="off" value="' . (isset($params['visitor_name']) ? $params['visitor_name'] : '') . '" /><br>
					<label>' . _EMAIL . ':</label> <input id="id_visitor_email" name="visitor_email" type="text" maxlength="70" autocomplete="off" value="' . (isset($params['visitor_email']) ? $params['visitor_email'] : '') . '" /><br>
					<label>' . _PHONE . ':</label> <input id="id_visitor_phone" name="visitor_phone" type="text" maxlength="20" autocomplete="off" value="' . (isset($params['visitor_phone']) ? $params['visitor_phone'] : '') . '" />
					</div>';
        $output .= '<div class="right_panel">
					<label>' . _LOCATION . ':</label> ' . $locations . '<br>
					<label>' . _SUB_LOCATION . ':</label> ' . $sub_locations . '<br>
					
					<label>' . _I_AM_AVAILABLE . ':</label> ';
        $output .= '<select id="id_visitor_availability" name="visitor_availability">';
        foreach (self::$arr_availabilities as $key => $val) {
            $output .= '<option value="' . $key . '"' . ($visitor_availability == $key ? ' selected="selected"' : '') . '>' . $val . '</option>';
        }
        $output .= '</select><br>';
        $output .= '<label>' . _PREFERRED_TO_BE_CONTACTED . ':</label> ';
        $output .= '<select id="id_visitor_preferred_contact" name="visitor_preferred_contact">';
        foreach (self::$arr_preferred_contacts as $key => $val) {
            $output .= '<option value="' . $key . '"' . ($visitor_preferred_contact == $key ? ' selected="selected"' : '') . '>' . $val . '</option>';
        }
        $output .= '</select>';
        $output .= '
				</div>					
				<div style="margin:10px auto;text-align:center;">
					' . str_replace('_COUNT_', $inquiry_type == 1 ? '1' : ModulesSettings::Get('inquiries', 'maximum_replies'), _INQUIRY_FORM_DISCLAIMER) . '<br><br>
					<input type="submit" class="form_button" name="" value="' . _SUBMIT . '">
				</div>';
        if (isset($params['focus_field']) && !empty($params['focus_field'])) {
            $output .= '<script type="text/javascript">appSetFocus("id_' . $params['focus_field'] . '");</script>';
        }
        if ($draw) {
            echo $output;
        } else {
            return $output;
        }
    }
Ejemplo n.º 2
0
 /**
  *	Draw all locations
  *		@param $params
  *		@param $draw
  */
 public static function DrawAllLocations($params = array(), $draw = true)
 {
     $tag_name = isset($params['tag_name']) ? $params['tag_name'] : 'l_locaton';
     $tag_id = isset($params['tag_id']) ? $params['tag_id'] : 'id_l_locaton';
     $selected_value = isset($params['selected_value']) ? $params['selected_value'] : '';
     $javascript_event = isset($params['javascript_event']) ? ' ' . $params['javascript_event'] : '';
     $output = '<select name="' . $tag_name . '" id="' . $tag_id . '"' . $javascript_event . '>';
     $output .= '<option value="">-- ' . _ALL_LOCATIONS . ' --</option>';
     $locations = ListingsLocations::GetAllLocations('name ASC');
     for ($i = 0; $i < $locations[1]; $i++) {
         if ($selected_value == $locations[0][$i]['id']) {
             $selected_state = 'selected="selected"';
         } else {
             $selected_state = '';
         }
         $output .= '<option ' . $selected_state . ' value="' . $locations[0][$i]['id'] . '">' . $locations[0][$i]['name'] . '</option>';
     }
     $output .= '</select>';
     if ($draw) {
         echo $output;
     } else {
         return $output;
     }
 }
Ejemplo n.º 3
0
    /**
     * Draws listings in category
     * 		@param $category_id
     * 		@param $draw
     */
    public function DrawListings($category_id, $draw = true)
    {
        global $objLogin, $objSettings;
        $lang = Application::Get('lang');
        $nl = "\n";
        if (empty($lang)) {
            $lang = Languages::GetDefaultLang();
        }
        $listings_locations = isset($_REQUEST['listings_locations']) ? prepare_input($_REQUEST['listings_locations']) : '';
        $listings_sub_locations = isset($_REQUEST['listings_sub_locations']) ? prepare_input($_REQUEST['listings_sub_locations']) : '';
        $listings_sort_by = isset($_REQUEST['listings_sort_by']) && $_REQUEST['listings_sort_by'] != '' ? prepare_input($_REQUEST['listings_sort_by']) : 'rating';
        $listings_order_by = isset($_REQUEST['listings_order_by']) && $_REQUEST['listings_order_by'] != '' ? prepare_input($_REQUEST['listings_order_by']) : 'ASC';
        $sort_by = '';
        $order_by = '';
        $output = '';
        if ($listings_sort_by == 'name') {
            $sort_by = 'ld.business_name';
            $order_by = $listings_order_by;
        } else {
            if ($listings_sort_by == 'date') {
                $sort_by = 'l.date_published';
                $order_by = $listings_order_by;
            } else {
                if ($listings_sort_by == 'rating') {
                    // rating according to advertising plans high rate = high advertising plan
                    $sort_by = 'l.advertise_plan_id';
                    $order_by = ($listings_order_by == 'ASC' ? 'DESC' : 'ASC') . ', RAND()';
                } else {
                    $sort_by = 'l.priority_order';
                    $order_by = $listings_order_by;
                }
            }
        }
        if (!Application::Get('js_included', 'lytebox')) {
            $output .= '<!-- LyteBox v3.22 Author: Markus F. Hay Website: http://www.dolem.com/lytebox -->' . $nl;
            $output .= '<link rel="stylesheet" href="modules/lytebox/css/lytebox.css" type="text/css" media="screen" />' . $nl;
            $output .= '<script type="text/javascript" src="modules/lytebox/js/lytebox.js"></script>' . $nl;
        }
        // draw category description
        $category_info = Categories::GetCategoryInfo($category_id);
        if ($category_info['description'] != '') {
            $output .= draw_message($category_info['description'], false);
        }
        // draw result
        $sql_from = TABLE_LISTINGS . ' l 
					INNER JOIN ' . TABLE_LISTINGS_DESCRIPTION . ' ld ON l.id = ld.listing_id
					INNER JOIN ' . TABLE_LISTINGS_LOCATIONS . ' ll ON l.listing_location_id = ll.id
				WHERE
					' . (!empty($listings_locations) ? 'l.listing_location_id = \'' . $listings_locations . '\' AND ' : '') . '
					' . (!empty($listings_sub_locations) ? 'l.listing_sub_location_id = \'' . $listings_sub_locations . '\' AND ' : '') . '
					' . (!$objLogin->IsLoggedIn() ? 'l.access_level=\'public\' AND ' : '') . '
					l.is_published = 1 AND
					' . ($this->show_expired_listings != 'yes' ? ' ((l.finish_publishing = \'0000-00-00 00:00:00\') OR (l.finish_publishing > \'' . date('Y-m-d H:i:s') . '\')) AND ' : '') . '
					ld.language_id = \'' . $lang . '\'
					' . ($category_id != '' ? ' AND l.id IN (SELECT listing_id FROM ' . TABLE_LISTINGS_CATEGORIES . ' lc WHERE category_id = ' . (int) $category_id . ')' : '') . '
				ORDER BY ' . $sort_by . ' ' . $order_by;
        // pagination prepare
        $page_size = ModulesSettings::Get('listings', 'listings_per_page');
        $start_row = '0';
        $total_pages = '1';
        pagination_prepare($page_size, $sql_from, $start_row, $total_pages);
        $sql = 'SELECT l.id,
					l.image_file,
					l.image_file_thumb,
					l.priority_order,
					l.date_published,
					l.website_url,
					l.business_email,
					l.advertise_plan_id,
					ll.name as listing_location_name,
					ld.language_id,					
					ld.business_name,
					ld.business_address,
					ld.business_description
				FROM ' . $sql_from . '
				LIMIT ' . $start_row . ', ' . $page_size;
        $result = database_query($sql, DATA_AND_ROWS, ALL_ROWS);
        if ($result[1] > 0 || !empty($listings_locations)) {
            $output .= '<form id="frmCategoryView" action="index.php?page=category&cid=' . $category_id . '" method="post">';
            $output .= draw_token_field(false);
            $output .= draw_hidden_field('p', '1', false);
            $output .= '<table width="98%" border="0" align="center">';
            $output .= '<tr><th colspan="3" nowrap="nowrap" height="5px"></th></tr>';
            $output .= '<tr><th colspan="2" align="' . Application::Get('defined_left') . '" valign="middle">';
            $output .= '&nbsp;' . _FILTER_BY . ': ';
            $output .= ListingsLocations::DrawAllLocations(array('tag_name' => 'listings_locations', 'selected_value' => $listings_locations, 'javascript_event' => 'onchange="jQuery(\'#frmCategoryView\').submit();"'), false) . ' &nbsp;';
            $output .= ListingsSubLocations::DrawAllSubLocations($listings_locations, array('tag_name' => 'listings_sub_locations', 'selected_value' => $listings_sub_locations, 'javascript_event' => 'onchange="jQuery(\'#frmCategoryView\').submit();"'), false);
            $output .= '</th>';
            $output .= '<th colspan="2" align="' . Application::Get('defined_right') . '" valign="middle">';
            $output .= _SORT_BY . ': 
					<select name="listings_sort_by" onchange="jQuery(\'#frmCategoryView\').submit();">
						<option value="rating" ' . ($listings_sort_by == 'rating' ? ' selected="selected"' : '') . '>' . _RATING . '</option>
						<option value="name" ' . ($listings_sort_by == 'name' ? ' selected="selected"' : '') . '>' . _NAME . '</option>
						<option value="date" ' . ($listings_sort_by == 'date' ? ' selected="selected"' : '') . '>' . _DATE_PUBLISHED . '</option>
					</select>&nbsp;
					<select name="listings_order_by" onchange="jQuery(\'#frmCategoryView\').submit();">
						<option value="ASC" ' . ($listings_order_by == 'ASC' ? ' selected="selected"' : '') . '>' . _ASCENDING . '</option>
						<option value="DESC" ' . ($listings_order_by == 'DESC' ? ' selected="selected"' : '') . '>' . _DESCENDING . '</option>
					</select>
					</th>
				</tr>
			</table>
			</form>';
        }
        if ($result[1] > 0) {
            $output .= '<table width="99%" border="0" align="center">';
            $output .= '<tr><th colspan="2" nowrap="nowrap" height="5px"></th></tr>
				<tr>
					<th align="' . Application::Get('defined_left') . '">&nbsp; ' . _LISTINGS . ' &nbsp;</th>
					<th align="center">' . _IMAGE . '</th>
				</tr>';
            for ($i = 0; $i < $result[1]; $i++) {
                $image_file = $result[0][$i]['image_file'] != '' ? $result[0][$i]['image_file'] : 'no_image.png';
                ///$result[0][$i]['advertise_plan_id'] > 1 &&
                $image_file_thumb = $result[0][$i]['image_file_thumb'] != '' ? $result[0][$i]['image_file_thumb'] : 'no_image.png';
                $output .= '<tr><td colspan="2" style="padding:7px;">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>
					<tr valign="top">
						<td>';
                $link_1 = prepare_link('listing', 'lid', $result[0][$i]['id'], '', $result[0][$i]['business_name'], '', _CLICK_TO_SEE_DESCR);
                $link_2 = prepare_link('listing', 'lid', $result[0][$i]['id'], '', _MORE_INFO, '', _CLICK_TO_SEE_DESCR);
                $output .= '<div class="listing_info">';
                $output .= '<div class="header">' . $link_1 . '</div>';
                $output .= '<div class="address">' . substr_by_word(strip_tags($result[0][$i]['business_address']), 300, true, Application::Get('lang')) . ' ' . $result[0][$i]['listing_location_name'] . '</div>';
                $output .= '<div class="description">' . substr_by_word(strip_tags($result[0][$i]['business_description']), 180, true, Application::Get('lang')) . '</div>';
                $output .= '<div class="links">
											' . $link_2 . '
											' . ($result[0][$i]['website_url'] != '' ? ' : <a href="' . $result[0][$i]['website_url'] . '" target="_new">' . _WEBSITE_URL . '</a>' : '') . '
											' . ($result[0][$i]['business_email'] != '' ? ' : <a href="mailto:' . $result[0][$i]['business_email'] . '">' . _EMAIL . '</a>' : '') . '
											' . ($result[0][$i]['date_published'] != '0000-00-00 00:00:00' ? '<div class="published">' . _PUBLISHED . ': ' . format_datetime($result[0][$i]['date_published'], get_datetime_format(false), _UNKNOWN) . '<div>' : '') . '
										</div>';
                $output .= '</div>';
                $output .= '
						</td>
						<td width="130px" align="center">
							<div class="listing_icon">';
                if ($image_file != 'no_image.png') {
                    $output .= '<a href="images/listings/' . $image_file . '" rel="lyteshow_' . $result[0][$i]['id'] . '">';
                }
                $output .= '<img class="listings_image' . ($image_file == 'no_image.png' ? ' no_hover' : '') . '" src="images/listings/' . $image_file_thumb . '" width="120px" height="90px" title="' . ($image_file != 'no_image.png' ? _CLICK_TO_INCREASE : '') . '" alt="" />';
                if ($image_file != 'no_image.png') {
                    $output .= '</a>';
                }
                $output .= '
							</div>
						</td>
					</tr>';
            }
            // draw pagination links
            if ($total_pages > 1) {
                $output .= '<tr><td colspan="2" style="padding:7px;">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>';
            }
            $output .= '<tr><td colspan="2">';
            $output .= pagination_get_links($total_pages, '');
            $output .= '</td></tr>';
            $output .= '<tr><td colspan="2">&nbsp;</td></tr>';
            $output .= '</table>';
        } else {
            // draw message only if this is a last-level empty category
            $categories = Categories::GetAllActive('c.parent_id = ' . (int) $category_id);
            if (!$categories[1]) {
                $output .= draw_message(_NO_LISTINGS_FOUND, false, true);
            }
        }
        if ($draw) {
            echo $output;
        } else {
            return $output;
        }
    }
Ejemplo n.º 4
0
/**
* @project ApPHP Business Directory
* @copyright (c) 2011 ApPHP
* @author ApPHP <*****@*****.**>
* @license http://www.gnu.org/licenses/
*/
// *** Make sure the file isn't accessed directly
defined('APPHP_EXEC') or die('Restricted Access');
//--------------------------------------------------------------------------
if ($objLogin->IsLoggedInAs('owner', 'mainadmin') && Modules::IsModuleInstalled('listings')) {
    $action = MicroGrid::GetParameter('action');
    $rid = MicroGrid::GetParameter('rid');
    $mode = 'view';
    $msg = '';
    $objListingsLocations = new ListingsLocations();
    if ($action == 'add') {
        $mode = 'add';
    } else {
        if ($action == 'create') {
            if ($objListingsLocations->AddRecord()) {
                $msg = draw_success_message(_ADDING_OPERATION_COMPLETED, false);
                $mode = 'view';
            } else {
                $msg = draw_important_message($objListingsLocations->error, false);
                $mode = 'add';
            }
        } else {
            if ($action == 'edit') {
                $mode = 'edit';
            } else {
Ejemplo n.º 5
0
    /**
     * Draws advanced search form
     * 		@param $draw
     */
    public static function DrawAdvancedSearch($draw = true)
    {
        $keyword = isset($_POST['keyword']) ? trim(prepare_input($_POST['keyword'])) : '';
        $keyword = str_replace('"', '&#034;', $keyword);
        $keyword = str_replace("'", '&#039;', $keyword);
        $search_in = Application::Get('search_in');
        $sel_categories = isset($_POST['sel_categories']) ? (int) $_POST['sel_categories'] : '';
        $sel_listings_locations = isset($_POST['sel_listings_locations']) ? prepare_input($_POST['sel_listings_locations']) : '';
        $sel_listings_sub_locations = isset($_POST['sel_listings_sub_locations']) ? prepare_input($_POST['sel_listings_sub_locations']) : '';
        $sel_view = isset($_POST['sel_view']) ? prepare_input($_POST['sel_view']) : '';
        $sel_sortby = isset($_POST['sel_sortby']) ? prepare_input($_POST['sel_sortby']) : '';
        $sel_orderby = isset($_POST['sel_orderby']) ? prepare_input($_POST['sel_orderby']) : '';
        $chk_with_images = isset($_POST['chk_with_images']) ? prepare_input($_POST['chk_with_images']) : '';
        // prepare categories array
        $objCategories = Categories::Instance();
        $total_categories = $objCategories->GetAllExistingCategories();
        $total_countries = Countries::GetAllCountries('priority_order DESC, name ASC');
        $output = '<form style="margin:10px" id="frmAdvSearch" name="frmAdvSearch" action="index.php?page=search_advanced" method="post">
			' . draw_hidden_field('task', 'advanced_search', false) . '
			' . draw_hidden_field('p', '1', false) . '
			' . draw_hidden_field('search_in', 'listings') . '
			' . draw_token_field(false) . '
		
			<input type="text" name="keyword" value="' . $keyword . '" placeholder="' . _SEARCH_KEYWORDS . '...">		
			<span>' . _IN . '</span>
			<select name="sel_categories">';
        $output .= '<option value="">-- ' . _ALL . ' --</option>';
        foreach ($total_categories as $key => $val) {
            if ($val['level'] == '1') {
                $category_name = $val['name'];
            } else {
                if ($val['level'] == '2') {
                    $category_name = '&nbsp;&nbsp;&bull; ' . $val['name'];
                } else {
                    if ($val['level'] == '3') {
                        $category_name = '&nbsp;&nbsp;&nbsp;&nbsp;:: ' . $val['name'];
                    }
                }
            }
            $output .= '<option ' . ($sel_categories == $val['id'] ? 'selected="selected"' : '') . ' value="' . $val['id'] . '">' . $category_name . '</option>';
        }
        $output .= '</select>&nbsp;';
        $output .= ListingsLocations::DrawAllLocations(array('tag_name' => 'sel_listings_locations', 'selected_value' => $sel_listings_locations, 'javascript_event' => 'onchange="jQuery(\'#frmAdvSearch\').submit();"'), false) . ' &nbsp;';
        $output .= ListingsSubLocations::DrawAllSubLocations($sel_listings_locations, array('tag_name' => 'sel_listings_sub_locations', 'selected_value' => $sel_listings_sub_locations), false);
        $output .= '<span style="float:right;">
			<input value="' . _SEARCH . '" class="form_button" type="submit">
			</span>
		
			<div style="padding-top:4px;margin-left:-3px;">
			<table><tbody><tr>
			<td>' . _VIEW . ':
				<select name="sel_view">
					<option value="0" ' . ($sel_view == '0' ? ' selected="selected"' : '') . '>-- ' . _ALL . ' --</option>
					<option value="1" ' . ($sel_view == '1' ? ' selected="selected"' : '') . '>' . _TODAY . '</option>
					<option value="2" ' . ($sel_view == '2' ? ' selected="selected"' : '') . '>' . _YESTERDAY . '</option>
					<option value="3" ' . ($sel_view == '3' ? ' selected="selected"' : '') . '>' . _LAST_7_DAYS . '</option>
				</select>&nbsp;
			</td>
			<td>' . _SORT_BY . ':
				<select name="sel_sortby">
					<option value="0" ' . ($sel_sortby == '0' ? ' selected="selected"' : '') . '>' . _DATE . '</option>
					<option value="1" ' . ($sel_sortby == '1' ? ' selected="selected"' : '') . '>' . _VIEW . '</option>
				</select>&nbsp;
			</td>
			<td>' . _ORDER_BY . ':
				<select name="sel_orderby">
					<option value="ASC" ' . ($sel_orderby == 'ASC' ? ' selected="selected"' : '') . '>' . _ASCENDING . '</option>
					<option value="DESC" ' . ($sel_orderby == 'DESC' ? ' selected="selected"' : '') . '>' . _DESCENDING . '</option>
				</select>&nbsp;
			</td>
			<td style="padding-top:4px;"><input name="chk_with_images" type="checkbox" ' . ($chk_with_images == '1' ? ' checked="checked"' : '') . ' value="1">' . _WITH_IMAGES_ONLY . '</td>
			</tr>
			</tbody>
			</table>
			</div>
			
		</form>';
        if ($draw) {
            echo $output;
        } else {
            return $output;
        }
    }
* @project ApPHP Business Directory
* @copyright (c) 2011 ApPHP
* @author ApPHP <*****@*****.**>
* @license http://www.gnu.org/licenses/
*/
// *** Make sure the file isn't accessed directly
defined('APPHP_EXEC') or die('Restricted Access');
//--------------------------------------------------------------------------
if ($objLogin->IsLoggedInAs('owner', 'mainadmin') && Modules::IsModuleInstalled('listings')) {
    $action = MicroGrid::GetParameter('action');
    $rid = MicroGrid::GetParameter('rid');
    $lid = isset($_GET['lid']) ? (int) $_GET['lid'] : '0';
    $mode = 'view';
    $msg = '';
    // Start main content
    $objListingsLocations = new ListingsLocations();
    $location_info = $objListingsLocations->GetInfoByID($lid);
    $location_info_name = isset($location_info['name']) ? $location_info['name'] : '';
    if (!empty($lid) && count($location_info)) {
        $objListingsSubLocations = new ListingsSubLocations($lid);
        if ($action == 'add') {
            $mode = 'add';
        } else {
            if ($action == 'create') {
                if ($objListingsSubLocations->AddRecord()) {
                    $msg = draw_success_message(_ADDING_OPERATION_COMPLETED, false);
                    $mode = 'view';
                } else {
                    $msg = draw_important_message($objListingsSubLocations->error, false);
                    $mode = 'add';
                }