Ejemplo n.º 1
0
 /**
  *	Draws inquiry form
  *		@param $params
  *		@param $draw
  */
 public static function DrawInquiryForm($params, $draw = true)
 {
     $output = '';
     $inquiry_category = isset($params['inquiry_category']) ? prepare_input($params['inquiry_category']) : '';
     $widget = isset($params['widget']) ? prepare_input($params['widget']) : '';
     $widget_host = isset($params['widget_host']) ? prepare_input($params['widget_host']) : '';
     $widget_key = isset($params['widget_key']) ? prepare_input($params['widget_key']) : '';
     // prepare categories array
     $objCategories = Categories::Instance();
     $total_categories = $objCategories->GetAllExistingCategories();
     $arr_categories = array();
     foreach ($total_categories as $key => $val) {
         if ($val['level'] == '1') {
             $arr_categories[$val['id']] = $val['name'];
         } else {
             if ($val['level'] == '2') {
                 $arr_categories[$val['id']] = '  • ' . $val['name'];
             } else {
                 if ($val['level'] == '3') {
                     $arr_categories[$val['id']] = '    :: ' . $val['name'];
                 }
             }
         }
     }
     if ($widget) {
         $output .= '<form id="frmInquiryForm" action="' . APPHP_BASE . 'index.php?host=' . $widget_host . '&key=' . $widget_key . '" method="post">';
     } else {
         $output .= '<form id="frmInquiryForm" action="index.php?page=inquiry_form" method="post">';
     }
     $output .= draw_token_field(false);
     $output .= draw_hidden_field('act', 'send', false, 'id_act');
     $output .= draw_hidden_field('inquiry_type', '0', false);
     $output .= '<div class="inquiry_wrapper">';
     $output .= _WHAT_DO_YOU_NEED . '<br>';
     $output .= '<select id="inquiry_category" name="inquiry_category">';
     $output .= '<option value="">-- ' . _SELECT . ' --</option>';
     foreach ($arr_categories as $key => $val) {
         $output .= '<option value="' . $key . '"' . ($inquiry_category == $key ? ' selected="selected"' : '') . '>' . $val . '</option>';
     }
     $output .= '</select><br><br>';
     $output .= self::DrawInquirySubForm($params, false);
     $output .= '</div>';
     $output .= '</form>';
     if ($draw) {
         echo $output;
     } else {
         return $output;
     }
 }
Ejemplo n.º 2
0
<?php

/**
* @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');
//--------------------------------------------------------------------------
$objCategory = Categories::Instance();
$objListings = Listings::Instance();
$category_info = $objCategory->GetLevelsInfo(Application::Get('category_id'));
$button = '';
if (Modules::IsModuleInstalled('inquiries')) {
    $listings_locations = isset($_REQUEST['listings_locations']) ? (int) $_REQUEST['listings_locations'] : '';
    $listings_sub_locations = isset($_REQUEST['listings_sub_locations']) ? (int) $_REQUEST['listings_sub_locations'] : '';
    if (!empty($category_info['first']['id'])) {
        $button = '<input type="button" class="form_button" value="' . _SUBMIT_INQUIRY . '" onclick="appGoToPage(\'index.php?page=inquiry_form\',\'&inquiry_category=' . $category_info['first']['id'] . '&visitor_locations=' . $listings_locations . '&visitor_sub_locations=' . $listings_sub_locations . '\',\'post\')">';
    }
}
draw_title_bar(prepare_breadcrumbs(array(_CATEGORIES => prepare_link('categories', '', '', 'all', _SEE_ALL, '', '', true), $category_info['third']['name'] => $category_info['third']['link'], $category_info['second']['name'] => $category_info['second']['link'], $category_info['first']['name'] => '')), $button);
$objCategory->DrawSubCategories(Application::Get('category_id'), 'listings');
$objListings->DrawListings(Application::Get('category_id'));
Ejemplo n.º 3
0
    function __construct($listing_id = 0, $account_type = '')
    {
        parent::__construct();
        $this->params = array();
        ## for standard fields
        if (isset($_POST['category_id'])) {
            $this->params['category_id'] = prepare_input($_POST['category_id']);
        }
        if (isset($_POST['listing_id'])) {
            $this->params['listing_id'] = prepare_input($_POST['listing_id']);
        }
        $this->listingId = (int) $listing_id;
        $this->selectedCategoryId = '';
        //$this->params['language_id'] = MicroGrid::GetParameter('language_id');
        //$this->uPrefix 		= 'prefix_';
        $this->primaryKey = 'id';
        $this->tableName = TABLE_LISTINGS_CATEGORIES;
        $this->dataSet = array();
        $this->error = '';
        if ($account_type == 'me') {
            $this->formActionURL = 'index.php?customer=listings_categories&listing_id=' . (int) $listing_id;
        } else {
            $this->formActionURL = 'index.php?admin=mod_listings_categories&listing_id=' . (int) $listing_id;
        }
        $this->actions = array('add' => true, 'edit' => false, 'details' => false, 'delete' => true);
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->allowTopButtons = false;
        $this->alertOnDelete = '';
        // leave empty to use default alerts
        $this->allowLanguages = false;
        $this->languageId = '';
        //($this->params['language_id'] != '') ? $this->params['language_id'] : Languages::GetDefaultLang();
        $this->WHERE_CLAUSE = '';
        // WHERE .... / 'WHERE language_id = ''.$this->languageId.''';
        $this->ORDER_CLAUSE = 'ORDER BY cd.name ASC';
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 20;
        $this->isSortingAllowed = true;
        $this->isExportingAllowed = false;
        $this->arrExportingTypes = array('csv' => false);
        $this->isFilteringAllowed = false;
        // define filtering fields
        $this->arrFilteringFields = array();
        ///$date_format = get_date_format('view');
        ///$date_format_edit = get_date_format('edit');
        ///$currency_format = get_currency_format();
        // prepare categories array
        // existing categories
        $added_categories = self::GetCategoriesForListing($this->listingId);
        $arr_added_categories = array();
        foreach ($added_categories[0] as $key => $val) {
            $arr_added_categories[] = $val['category_id'];
        }
        // subtruct existing categories from all
        $objCategories = Categories::Instance();
        $total_categories = $objCategories->GetAllExistingCategories();
        $arr_categories = array();
        foreach ($total_categories as $key => $val) {
            if (!in_array($val['id'], $arr_added_categories)) {
                if ($val['level'] == '1') {
                    $arr_categories[$val['id']] = $val['name'];
                } else {
                    if ($val['level'] == '2') {
                        $arr_categories[$val['id']] = '&nbsp;&nbsp;&bull; ' . $val['name'];
                    } else {
                        if ($val['level'] == '3') {
                            $arr_categories[$val['id']] = '&nbsp;&nbsp;&nbsp;&nbsp;:: ' . $val['name'];
                        }
                    }
                }
            }
        }
        //----------------------------------------------------------------------
        // VIEW MODE
        // format: strip_tags
        // format: nl2br
        // format: 'format'=>'date', 'format_parameter'=>'M d, Y, g:i A''
        // format: 'format'=>'currency', 'format_parameter'=>'european|2' or 'format_parameter'=>'american|4'
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT
									lc.' . $this->primaryKey . ',
									cd.name,
									cd.description
								FROM ' . $this->tableName . ' lc
									INNER JOIN ' . TABLE_CATEGORIES_DESCRIPTION . ' cd ON lc.category_id = cd.category_id 
									INNER JOIN ' . TABLE_LISTINGS . ' l ON lc.listing_id = l.id
								WHERE
									cd.language_id = \'' . Application::Get('lang') . '\' AND 
									lc.listing_id = ' . $listing_id;
        // define view mode fields
        $this->arrViewModeFields = array('name' => array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '25%', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'tooltip' => '', 'maxlength' => '40', 'format' => '', 'format_parameter' => ''), 'description' => array('title' => _DESCRIPTION, 'type' => 'label', 'align' => 'left', 'width' => '', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'tooltip' => '', 'maxlength' => '100', 'format' => '', 'format_parameter' => ''));
        //----------------------------------------------------------------------
        // ADD MODE
        // - Validation Type: alpha|numeric|float|alpha_numeric|text|email|ip_address|password|date
        // 	 Validation Sub-Type: positive (for numeric and float)
        //   Ex.: 'validation_type'=>'numeric', 'validation_type'=>'numeric|positive'
        // - Validation Max Length: 12, 255... Ex.: 'validation_maxlength'=>'255'
        // - Validation Min Length: 4, 6... Ex.: 'validation_minlength'=>'4'
        // - Validation Max Value: 12, 255... Ex.: 'validation_maximum'=>'99.99'
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array('category_id' => array('title' => _CATEGORY, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => false, 'default' => '', 'source' => $arr_categories, 'default_option' => '', 'unique' => false, 'javascript_event' => ''), 'listing_id' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $listing_id));
        //----------------------------------------------------------------------
        // EDIT MODE
        // - Validation Type: alpha|numeric|float|alpha_numeric|text|email|ip_address|password|date
        //   Validation Sub-Type: positive (for numeric and float)
        //   Ex.: 'validation_type'=>'numeric', 'validation_type'=>'numeric|positive'
        // - Validation Max Length: 12, 255... Ex.: 'validation_maxlength'=>'255'
        // - Validation Min Length: 4, 6... Ex.: 'validation_minlength'=>'4'
        // - Validation Max Value: 12, 255... Ex.: 'validation_maximum'=>'99.99'
        //----------------------------------------------------------------------
        $this->EDIT_MODE_SQL = 'SELECT
								lc.' . $this->primaryKey . ',
								lc.listing_id,
								lc.category_id,
								cd.name as category_name,
								cd.description as category_description
							FROM ' . $this->tableName . ' lc
								INNER JOIN ' . TABLE_CATEGORIES_DESCRIPTION . ' cd ON lc.category_id = cd.category_id
							WHERE lc.' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array('category_name' => array('title' => _CATEGORY, 'type' => 'label'), 'listing_id' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $listing_id));
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL;
        $this->arrDetailsModeFields = array('category_name' => array('title' => _CATEGORY, 'type' => 'label'), 'category_description' => array('title' => _DESCRIPTION, 'type' => 'label'));
    }
Ejemplo n.º 4
0
    private function __construct_all()
    {
        global $objLogin;
        $this->params = array();
        if (isset($_POST['website_url'])) {
            $website_url = prepare_input($_POST['website_url'], false, 'medium');
            if (preg_match('/www./i', $website_url) && !preg_match('/http:/i', $website_url)) {
                $website_url = 'http://' . $website_url;
            }
            $this->params['website_url'] = $website_url;
        }
        if (isset($_POST['listing_location_id'])) {
            $this->params['listing_location_id'] = prepare_input($_POST['listing_location_id']);
        }
        if (isset($_POST['listing_sub_location_id'])) {
            $this->params['listing_sub_location_id'] = prepare_input($_POST['listing_sub_location_id']);
        }
        if (isset($_POST['business_email'])) {
            $this->params['business_email'] = prepare_input($_POST['business_email']);
        }
        if (isset($_POST['business_phone'])) {
            $this->params['business_phone'] = prepare_input($_POST['business_phone']);
        }
        if (isset($_POST['business_fax'])) {
            $this->params['business_fax'] = prepare_input($_POST['business_fax']);
        }
        if (isset($_POST['priority_order'])) {
            $this->params['priority_order'] = prepare_input($_POST['priority_order']);
        }
        if (isset($_POST['is_featured'])) {
            $this->params['is_featured'] = (int) $_POST['is_featured'];
        } else {
            $this->params['is_featured'] = '0';
        }
        if (isset($_POST['is_published'])) {
            $this->params['is_published'] = (int) $_POST['is_published'];
        } else {
            $this->params['is_published'] = '0';
        }
        if (isset($_POST['is_approved'])) {
            $this->params['is_approved'] = prepare_input($_POST['is_approved']);
        }
        if (isset($_POST['access_level'])) {
            $this->params['access_level'] = prepare_input($_POST['access_level']);
        }
        if (isset($_POST['date_published'])) {
            $this->params['date_published'] = prepare_input($_POST['date_published']);
        }
        if (isset($_POST['customer_id'])) {
            $this->params['customer_id'] = (int) $_POST['customer_id'];
        }
        if (isset($_POST['map_code'])) {
            $this->params['map_code'] = prepare_input($_POST['map_code'], false, 'low');
        }
        if (isset($_POST['video_url'])) {
            $this->params['video_url'] = prepare_input($_POST['video_url'], false, 'low');
        }
        if (isset($_POST['keywords'])) {
            $this->params['keywords'] = implode(',', array_map('trim', explode(',', prepare_input($_POST['keywords']))));
        }
        if (isset($_POST['advertise_plan_id'])) {
            $this->params['advertise_plan_id'] = prepare_input($_POST['advertise_plan_id']);
        }
        ///$this->params['language_id'] 	= MicroGrid::GetParameter('language_id');
        $rid = MicroGrid::GetParameter('rid');
        $action = MicroGrid::GetParameter('action');
        $operation = MicroGrid::GetParameter('operation');
        $filter_by_cid = MicroGrid::GetParameter('filter_by_cid', false);
        $payments_module = Modules::IsModuleInstalled('payments') && ModulesSettings::Get('payments', 'is_active') == 'yes' ? true : false;
        $watermark = ModulesSettings::Get('listings', 'watermark') == 'yes' ? true : false;
        $watermark_text = ModulesSettings::Get('listings', 'watermark_text');
        if ($action != 'view') {
            $listings_info = self::GetListingInfo($rid);
        }
        ## for images
        if (isset($_POST['image_file'])) {
            $this->params['image_file'] = prepare_input($_POST['image_file']);
        } else {
            if (isset($_FILES['image_file']['name']) && $_FILES['image_file']['name'] != '') {
                // nothing
            } else {
                if (self::GetParameter('action') == 'create') {
                    $this->params['image_file'] = '';
                }
            }
        }
        if ($payments_module) {
            $listings_count = $objLogin->GetAvailableListings();
        } else {
            $listings_count = -1;
        }
        $this->primaryKey = 'id';
        $this->tableName = TABLE_LISTINGS;
        $this->dataSet = array();
        $this->error = '';
        $this->formActionURL = 'index.php?' . ($objLogin->GetLoggedType() == 'customer' ? 'customer=my_listings' : 'admin=mod_listings_management');
        $categoriesActionURL = 'index.php?' . ($objLogin->GetLoggedType() == 'customer' ? 'customer=listings_categories' : 'admin=mod_listings_categories');
        $this->actions = array('add' => $objLogin->GetLoggedType() == 'customer' && $listings_count == 0 ? false : true, 'edit' => true, 'details' => true, 'delete' => true);
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->allowTopButtons = true;
        $this->advertisePlanID = '0';
        $this->accessLevel = '';
        $this->isApproved = 0;
        $this->allowLanguages = false;
        //$this->languageId  	=  '';
        $default_lang = $objLogin->GetLoggedType() == 'customer' ? Languages::GetDefaultLang() : $objLogin->GetPreferredLang();
        $is_expired = false;
        if ($action == 'edit' && $action == 'details') {
            $is_expired = $listings_info['finish_publishing'] == '0000-00-00 00:00:00' || $listings_info['finish_publishing'] > date('Y-m-d H:i:s') ? false : true;
        }
        $this->WHERE_CLAUSE = 'WHERE ld.language_id = \'' . $default_lang . '\'';
        if ($operation != 'reset_filtering' && !empty($filter_by_cid)) {
            $this->WHERE_CLAUSE .= ' AND l.id IN (SELECT lc.listing_id FROM ' . TABLE_LISTINGS_CATEGORIES . ' lc WHERE lc.category_id = ' . (int) $filter_by_cid . ')';
        }
        $this->ORDER_CLAUSE = 'ORDER BY l.date_published ASC';
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 20;
        $this->isSortingAllowed = true;
        $this->isExportingAllowed = $objLogin->IsLoggedInAsAdmin() ? true : false;
        $this->arrExportingTypes = array('csv' => true);
        // prepare access levels array
        $arr_access_levels = array('public' => _PUBLIC, 'registered' => _REGISTERED);
        // prepare featured array
        $arr_featured = array('0' => _NO, '1' => _YES);
        // prepare published array
        $arr_published = array('0' => _NO, '1' => _YES);
        // prepare advertise plans array
        $arr_advertise_plans = array();
        $total_plans = AdvertisePlans::GetAllPlans();
        foreach ($total_plans[0] as $key => $val) {
            $arr_advertise_plans[$val['id']] = $val['plan_name'];
        }
        if ($payments_module) {
            $arr_customer_advertise_plans = array();
            if ($objLogin->IsLoggedInAsCustomer()) {
                $plans = $objLogin->GetCustomerPlans();
                foreach ($plans as $key => $val) {
                    $arr_customer_advertise_plans[$val['id']] = $val['name'] . ' (' . $val['count'] . ' ' . _LISTINGS . ')';
                }
            }
        }
        // prepare categories array
        $objCategories = Categories::Instance();
        $total_categories = $objCategories->GetAllExistingCategories();
        $arr_categories = array();
        foreach ($total_categories as $key => $val) {
            if ($val['level'] == '1') {
                $arr_categories[$val['id']] = $val['name'];
            } else {
                if ($val['level'] == '2') {
                    $arr_categories[$val['id']] = '&nbsp;&nbsp;&bull; ' . $val['name'];
                } else {
                    if ($val['level'] == '3') {
                        $arr_categories[$val['id']] = '&nbsp;&nbsp;&nbsp;&nbsp;:: ' . $val['name'];
                    }
                }
            }
        }
        $datetime_format = get_datetime_format();
        $date_format = get_date_format();
        $arr_locations = array();
        $arr_sub_locations = array();
        if ($action != 'view') {
            // prepare array for location
            $total_locations = ListingsLocations::GetAllLocations('name ASC');
            foreach ($total_locations[0] as $key => $val) {
                $arr_locations[$val['id']] = $val['name'];
            }
            if ($action != 'edit' && $action != 'details') {
                // prepare array for sub-location
                $listing_location_id = (int) MicroGrid::GetParameter('listing_location_id', false);
                $total_sub_locations = ListingsSubLocations::GetAllSubLocations($listing_location_id, 'name ASC');
                foreach ($total_sub_locations[0] as $key => $val) {
                    $arr_sub_locations[$val['id']] = $val['name'];
                }
            }
        }
        // define filtering fields
        $this->isFilteringAllowed = true;
        $this->arrFilteringFields = array(_NAME => array('table' => 'ld', 'field' => 'business_name', 'type' => 'text', 'sign' => 'like%', 'width' => '110px'), _CATEGORY => array('table' => 'c', 'field' => 'id', 'type' => 'dropdownlist', 'source' => $arr_categories, 'sign' => '=', 'width' => '', 'visible' => $objLogin->IsLoggedInAsAdmin() ? true : false, 'custom_handler' => true), _FEATURED => array('table' => 'l', 'field' => 'is_featured', 'type' => 'dropdownlist', 'source' => $arr_featured, 'sign' => '=', 'width' => '', 'visible' => $objLogin->IsLoggedInAsAdmin() ? true : false), _PUBLISHED => array('table' => 'l', 'field' => 'is_published', 'type' => 'dropdownlist', 'source' => $arr_published, 'sign' => '=', 'width' => ''));
        // retrieve pre-moderation settings
        $pre_moderation_allow = ModulesSettings::Get('listings', 'pre_moderation_allow') == 'yes' ? true : false;
        ///////////////////////////////////////////////////////////////////////////////
        // 1. prepare translation fields array
        $this->arrTranslations = $this->PrepareTranslateFields(array('business_name', 'business_address', 'business_description'));
        ///////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////
        // 2. prepare translations array for edit/detail modes
        $sql_translation_description = $this->PrepareTranslateSql(TABLE_LISTINGS_DESCRIPTION, 'listing_id', array('business_name', 'business_address', 'business_description'));
        ///////////////////////////////////////////////////////////////////////////////
        // retrieve default priority order for new record
        $default_priority_order = '';
        if (self::GetParameter('action') == 'add') {
            $default_priority_order = $this->GetMaxOrder('priority_order', 9999);
        }
        // get plan features
        $advertise_plan_id = '';
        if ($action == 'add' || $action == 'create') {
            $advertise_plan_id = MicroGrid::GetParameter('advertise_plan_id', false);
        } else {
            if (in_array($action, array('details', 'edit', 'update'))) {
                // 1st time
                if (MicroGrid::GetParameter('advertise_plan_id', false)) {
                    $advertise_plan_id = MicroGrid::GetParameter('advertise_plan_id', false);
                } else {
                    $advertise_plan_id = $listings_info['advertise_plan_id'];
                }
            }
        }
        if (empty($advertise_plan_id)) {
            $advertise_plan_id = 1;
        }
        $advertise_plan_info = AdvertisePlans::GetPlanInfo($advertise_plan_id);
        // print_r($advertise_plan_info);
        $bpf_business_name = $advertise_plan_info[0]['business_name'];
        $bpf_business_description = $advertise_plan_info[0]['business_description'];
        $bpf_address = $advertise_plan_info[0]['address'];
        $bpf_logo = $advertise_plan_info[0]['logo'];
        $bpf_images_count = $advertise_plan_info[0]['images_count'];
        $bpf_phone = $advertise_plan_info[0]['phone'];
        $bpf_map = $advertise_plan_info[0]['map'];
        $bpf_video_link = $advertise_plan_info[0]['video_link'];
        $this->bpf_keywords_count = (int) $advertise_plan_info[0]['keywords_count'];
        // not needed to be inserted: inquiries_count, inquiries_count/per month, rating_button
        //----------------------------------------------------------------------
        // VIEW MODE
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT l.' . $this->primaryKey . ',
		                            l.customer_id,
									l.image_file,
									l.image_file_thumb,
									l.website_url,
									l.business_email,
									l.business_phone,
									l.business_fax,
									l.priority_order,
									l.access_level,
									l.is_featured,
									l.advertise_plan_id,
									IF(
										l.finish_publishing = "0000-00-00 00:00:00",
										"- ' . _NEVER . ' -",
										IF(l.finish_publishing < \'' . date('Y-m-d H:i:s') . '\', "<span class=no>' . _EXPIRED . '</span>", l.finish_publishing)
									) as finish_publishing,
									CONCAT("<img src=\\"images/", IF(l.is_published, "published_g.gif", "published_x.gif"), "\\" alt=\\"\\" />") as mod_is_published,
									CONCAT("<img src=\\"images/", IF(l.is_approved, "published_g.gif", "waiting.gif"), "\\" alt=\\"\\" />") as mod_is_approved,
									ld.business_name,
									IF(l.customer_id = 0, \'Admin\', cust.user_name) as customer_username,
									CONCAT("[ ' . _CATEGORIES . ' ]", " (", (SELECT COUNT(*) FROM ' . TABLE_LISTINGS_CATEGORIES . ' lc WHERE lc.listing_id = l.id), ")") as link_categories
								FROM ' . $this->tableName . ' l
								    ' . ($objLogin->GetLoggedType() == 'customer' ? 'INNER JOIN ' . TABLE_CUSTOMERS . ' cust ON (l.customer_id = cust.id AND l.customer_id=' . (int) $objLogin->GetLoggedID() . ')' : 'LEFT OUTER JOIN ' . TABLE_CUSTOMERS . ' cust ON (l.customer_id = cust.id)') . '
									LEFT OUTER JOIN ' . TABLE_LISTINGS_DESCRIPTION . ' ld ON (l.id = ld.listing_id AND ld.language_id = \'' . $default_lang . '\')';
        // define view mode fields
        $this->arrViewModeFields = array('image_file_thumb' => array('title' => _IMAGE, 'type' => 'image', 'sortable' => false, 'align' => 'left', 'width' => '64px', 'image_width' => '50px', 'image_height' => '30px', 'target' => 'images/listings/', 'no_image' => 'no_image.png'), 'business_name' => array('title' => _NAME, 'type' => $objLogin->GetLoggedType() == 'customer' ? 'link' : 'label', 'align' => 'left', 'width' => '200px', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'tooltip' => '', 'maxlength' => '45', 'format' => '', 'format_parameter' => '', 'href' => 'index.php?page=listing&lid={id}', 'target' => '_new'), 'advertise_plan_id' => array('title' => _ADVERTISE_PLAN, 'type' => 'enum', 'align' => 'center', 'width' => '90px', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'source' => $arr_advertise_plans), 'customer_username' => array('title' => _CUSTOMER, 'type' => 'label', 'align' => 'center', 'width' => '', 'visible' => $objLogin->IsLoggedInAsAdmin() ? true : false), 'access_level' => array('title' => _ACCESS, 'type' => 'enum', 'align' => 'center', 'width' => '70px', 'sortable' => true, 'nowrap' => '', 'source' => $arr_access_levels, 'visible' => $objLogin->IsLoggedInAsAdmin() ? true : false), 'mod_is_published' => array('title' => _PUBLISHED, 'type' => 'label', 'align' => 'center', 'width' => '70px', 'visible' => $objLogin->IsLoggedInAsAdmin()), 'mod_is_approved' => array('title' => _STATUS, 'type' => 'label', 'align' => 'center', 'width' => '80px', 'visible' => $objLogin->IsLoggedInAsCustomer()), 'finish_publishing' => array('title' => _FINISH_PUBLISHING, 'type' => 'label', 'align' => 'center', 'width' => '90px', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'tooltip' => '', 'maxlength' => '', 'format' => 'date', 'format_parameter' => $date_format), 'link_categories' => array('title' => '', 'type' => 'link', 'align' => 'center', 'width' => '115px', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'tooltip' => '', 'maxlength' => '', 'format' => '', 'format_parameter' => '', 'href' => $categoriesActionURL . '&listing_id={id}', 'target' => ''), 'priority_order' => array('title' => _ORDER, 'type' => 'label', 'align' => 'center', 'width' => '60px', 'movable' => true, 'visible' => $objLogin->IsLoggedInAsAdmin() ? true : false), 'id' => array('title' => 'ID', 'type' => 'label', 'align' => 'center', 'width' => '50px'));
        //----------------------------------------------------------------------
        // ADD MODE
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'advertise_plan_id' => array('title' => _ADVERTISE_PLAN, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => false, 'default' => '', 'source' => $objLogin->IsLoggedInAsAdmin() ? $arr_advertise_plans : $arr_customer_advertise_plans, 'default_option' => '', 'unique' => false, 'javascript_event' => 'onchange="appChangePlan(\'' . $this->tableName . '\')"', 'visible' => $payments_module), 'listing_location_id' => array('title' => _LOCATION, 'type' => 'enum', 'width' => '', 'source' => $arr_locations, 'required' => true, 'default' => '', 'javascript_event' => 'onchange="appRefillLocations(\'' . $this->tableName . '\')"'), 'listing_sub_location_id' => array('title' => _SUB_LOCATION, 'type' => 'enum', 'width' => '', 'source' => $arr_sub_locations, 'required' => true, 'default' => ''), 'website_url' => array('title' => _WEBSITE_URL . ' (http://)', 'type' => 'textbox', 'width' => '270px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'maxlength' => '255'), 'business_email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => 'email', 'maxlength' => '75'), 'date_published' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $pre_moderation_allow && $objLogin->GetLoggedType() == 'customer' ? '0000-00-00 00:00:00' : date('Y-m-d H:i:s')), 'customer_id' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $objLogin->GetLoggedType() == 'customer' ? $objLogin->GetLoggedID() : '0')));
        if ($bpf_phone) {
            $this->arrAddModeFields['separator_general']['business_phone'] = array('title' => _PHONE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => '', 'maxlength' => '32');
            $this->arrAddModeFields['separator_general']['business_fax'] = array('title' => _FAX, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => '', 'maxlength' => '32');
        }
        if ($bpf_video_link) {
            $this->arrAddModeFields['separator_general']['video_url'] = array('title' => _VIDEO, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => '', 'maxlength' => '32');
        }
        if ($this->bpf_keywords_count) {
            $this->arrAddModeFields['separator_general']['keywords'] = array('title' => _KEYWORDS, 'type' => 'textarea', 'required' => false, 'width' => '480px', 'height' => '58px', 'editor_type' => 'simple', 'readonly' => false, 'default' => '', 'validation_type' => '', 'validation_maxlength' => '1024', 'unique' => false);
        } else {
            $this->arrAddModeFields['separator_general']['keywords'] = array('title' => '', 'type' => 'hidden', 'required' => false, 'readonly' => false, 'default' => '');
        }
        if ($bpf_logo) {
            $this->arrAddModeFields['separator_gallery']['separator_info'] = array('legend' => _GALLERY);
            $this->arrAddModeFields['separator_gallery']['image_file'] = array('title' => _LOGO, 'type' => 'image', 'width' => '210px', 'required' => false, 'readonly' => false, 'target' => 'images/listings/', 'no_image' => '', 'image_width' => '150px', 'image_height' => '120px', 'random_name' => 'true', 'unique' => false, 'thumbnail_create' => true, 'thumbnail_field' => 'image_file_thumb', 'thumbnail_width' => '150px', 'thumbnail_height' => '120px', 'file_maxsize' => '200k');
            for ($i = 1; $i <= $bpf_images_count; $i++) {
                $this->arrAddModeFields['separator_gallery']['image_' . $i] = array('title' => _IMAGE . ' #' . $i, 'type' => 'image', 'width' => '210px', 'required' => false, 'readonly' => false, 'target' => 'images/listings/', 'no_image' => '', 'image_width' => '150px', 'image_height' => '120px', 'random_name' => 'true', 'unique' => false, 'thumbnail_create' => true, 'thumbnail_field' => 'image_' . $i . '_thumb', 'thumbnail_width' => '150px', 'thumbnail_height' => '120px', 'file_maxsize' => '500k', 'watermark' => $watermark, 'watermark_text' => $watermark_text);
            }
        }
        if ($bpf_map) {
            $this->arrAddModeFields['separator_map']['separator_info'] = array('legend' => _MAP_CODE);
            $this->arrAddModeFields['separator_map']['map_code'] = array('title' => _MAP_CODE, 'type' => 'textarea', 'required' => false, 'width' => '480px', 'height' => '100px', 'editor_type' => 'simple', 'readonly' => false, 'default' => '', 'validation_type' => '', 'validation_maxlength' => '1024', 'unique' => false);
        } else {
            $this->arrAddModeFields['separator_general']['map_code'] = array('title' => '', 'type' => 'hidden', 'required' => false, 'readonly' => false, 'default' => '');
        }
        if ($objLogin->IsLoggedInAsAdmin()) {
            $this->arrAddModeFields['separator_general']['is_published'] = array('title' => _PUBLISHED, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0');
            $this->arrAddModeFields['separator_general']['is_approved'] = array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => '1');
            $this->arrAddModeFields['separator_general']['priority_order'] = array('title' => _ORDER, 'type' => 'textbox', 'width' => '50px', 'required' => true, 'default' => $default_priority_order, 'readonly' => false, 'validation_type' => 'numeric|positive', 'maxlength' => '4');
            $this->arrAddModeFields['separator_general']['is_featured'] = array('title' => _FEATURED, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0');
            $this->arrAddModeFields['separator_general']['access_level'] = array('title' => _ACCESSIBLE_BY, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => false, 'default' => 'public', 'source' => $arr_access_levels, 'default_option' => '', 'unique' => false, 'javascript_event' => '');
        } else {
            if ($pre_moderation_allow) {
                $this->arrAddModeFields['separator_general']['is_published'] = array('type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => '0');
                $this->arrAddModeFields['separator_general']['is_approved'] = array('type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => '0');
                $this->arrAddModeFields['separator_general']['access_level'] = array('type' => 'hidden', 'required' => true, 'default' => 'public');
            } else {
                $this->arrAddModeFields['separator_general']['is_published'] = array('type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => '1');
                $this->arrAddModeFields['separator_general']['is_approved'] = array('type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => '1');
            }
        }
        //----------------------------------------------------------------------
        // EDIT MODE
        //----------------------------------------------------------------------
        // define edit mode fields
        $this->EDIT_MODE_SQL = 'SELECT
								l.*,
								' . $sql_translation_description . '
								IF(
									l.finish_publishing = \'0000-00-00 00:00:00\',
									"- ' . _NEVER . ' -",
									IF(l.finish_publishing < \'' . date('Y-m-d H:i:s') . '\', \'<span class=no>' . _EXPIRED . '</span>\', l.finish_publishing)
								) as finish_publishing,								
								CONCAT("<img src=\\"images/listings/", l.image_file_thumb, "\\" alt=\\"\\" width=\\"40px\\ height=\\"30px\\" />") as my_image_file,
								IF(l.is_featured, \'' . _YES . '\', \'' . _NO . '\') as mod_is_featured,
								IF(l.is_published, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as mod_is_published,
								IF(l.is_approved, "<span class=yes>' . _APPROVED . '</span>", "<span class=no>' . _PENDING . '</span>") as mod_is_approved
							FROM ' . $this->tableName . ' l
								' . ($objLogin->GetLoggedType() == 'customer' ? 'INNER JOIN ' . TABLE_CUSTOMERS . ' cust ON (l.customer_id = cust.id AND l.customer_id=' . (int) $objLogin->GetLoggedID() . ')' : '') . '
							WHERE l.' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'advertise_plan_id' => array('title' => _ADVERTISE_PLAN, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => $objLogin->IsLoggedInAsAdmin() ? $is_expired ? true : false : true, 'default' => '', 'source' => $arr_advertise_plans, 'default_option' => '', 'unique' => false, 'javascript_event' => 'onchange="appChangePlan(\'' . $this->tableName . '\')"', 'visible' => $payments_module), 'listing_location_id' => array('title' => _LOCATION, 'type' => 'enum', 'width' => '', 'source' => $arr_locations, 'required' => true, 'javascript_event' => 'onchange="appRefillLocations(\'' . $this->tableName . '\')"'), 'listing_sub_location_id' => array('title' => _SUB_LOCATION, 'type' => 'enum', 'width' => '', 'source' => $arr_sub_locations, 'required' => true), 'website_url' => array('title' => _WEBSITE_URL . ' (http://)', 'type' => 'textbox', 'width' => '270px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'maxlength' => '255'), 'business_email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => 'email', 'maxlength' => '75')));
        if ($bpf_phone) {
            $this->arrEditModeFields['separator_general']['business_phone'] = array('title' => _PHONE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => '', 'maxlength' => '32');
            $this->arrEditModeFields['separator_general']['business_fax'] = array('title' => _FAX, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => '', 'maxlength' => '32');
        }
        if ($bpf_video_link) {
            $this->arrEditModeFields['separator_general']['video_url'] = array('title' => _VIDEO, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => '', 'maxlength' => '32');
        }
        if ($this->bpf_keywords_count) {
            $this->arrEditModeFields['separator_general']['keywords'] = array('title' => _KEYWORDS, 'type' => 'textarea', 'required' => false, 'width' => '480px', 'height' => '58px', 'editor_type' => 'simple', 'readonly' => false, 'default' => '', 'validation_type' => '', 'validation_maxlength' => '1024', 'unique' => false);
        }
        if ($bpf_logo) {
            $this->arrEditModeFields['separator_gallery']['separator_info'] = array('legend' => _GALLERY);
            $this->arrEditModeFields['separator_gallery']['image_file'] = array('title' => _LOGO, 'type' => 'image', 'width' => '210px', 'required' => false, 'readonly' => false, 'target' => 'images/listings/', 'no_image' => '', 'image_width' => '150px', 'image_height' => '120px', 'random_name' => 'true', 'unique' => false, 'thumbnail_create' => true, 'thumbnail_field' => 'image_file_thumb', 'thumbnail_width' => '150px', 'thumbnail_height' => '120px', 'file_maxsize' => '200k');
            for ($i = 1; $i <= $bpf_images_count; $i++) {
                $this->arrEditModeFields['separator_gallery']['image_' . $i] = array('title' => _IMAGE . ' #' . $i, 'type' => 'image', 'width' => '210px', 'required' => false, 'readonly' => false, 'target' => 'images/listings/', 'no_image' => '', 'image_width' => '150px', 'image_height' => '120px', 'random_name' => 'true', 'unique' => false, 'thumbnail_create' => true, 'thumbnail_field' => 'image_' . $i . '_thumb', 'thumbnail_width' => '150px', 'thumbnail_height' => '120px', 'file_maxsize' => '500k', 'watermark' => $watermark, 'watermark_text' => $watermark_text);
            }
        }
        if ($bpf_map) {
            $this->arrEditModeFields['separator_map']['separator_info'] = array('legend' => _MAP_CODE);
            $this->arrEditModeFields['separator_map']['map_code'] = array('title' => _MAP_CODE, 'type' => 'textarea', 'required' => false, 'width' => '480px', 'height' => '100px', 'editor_type' => 'simple', 'readonly' => false, 'default' => '', 'validation_type' => '', 'validation_maxlength' => '1024', 'unique' => false);
        }
        $this->arrEditModeFields['separator_general']['mod_is_approved'] = array('title' => _STATUS, 'type' => 'label');
        if ($objLogin->IsLoggedInAsAdmin()) {
            $this->arrEditModeFields['separator_general']['priority_order'] = array('title' => _ORDER, 'type' => 'textbox', 'width' => '50px', 'required' => true, 'readonly' => false, 'validation_type' => 'numeric|positive', 'maxlength' => '4');
            $this->arrEditModeFields['separator_general']['is_featured'] = array('title' => _FEATURED, 'type' => 'checkbox', 'readonly' => $is_expired ? true : false, 'true_value' => '1', 'false_value' => '0');
            ///$this->arrEditModeFields['separator_general']['date_published'] = array('title'=>_DATE_PUBLISHED, 'type'=>'hidden', 'required'=>true, 'readonly'=>false, 'default'=>date('Y-m-d H:i:s'));
            $this->arrEditModeFields['separator_general']['is_published'] = array('title' => _PUBLISHED, 'type' => 'checkbox', 'readonly' => $is_expired ? true : false, 'visible' => $is_expired ? false : true, 'true_value' => '1', 'false_value' => '0');
            $this->arrEditModeFields['separator_general']['access_level'] = array('title' => _ACCESSIBLE_BY, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => $is_expired ? true : false, 'default' => 'public', 'source' => $arr_access_levels, 'default_option' => '', 'unique' => false, 'javascript_event' => '');
        }
        $this->arrEditModeFields['separator_general']['finish_publishing'] = array('title' => _FINISH_PUBLISHING, 'type' => 'label', 'format' => 'date', 'format_parameter' => $date_format);
        $this->arrEditModeFields['separator_general']['customer_id'] = array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => '');
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL;
        $this->arrDetailsModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'advertise_plan_id' => array('title' => _ADVERTISE_PLAN, 'type' => 'enum', 'source' => $arr_advertise_plans, 'visible' => $payments_module), 'listing_location_id' => array('title' => _LOCATION, 'type' => 'enum', 'source' => $arr_locations), 'listing_sub_location_id' => array('title' => _SUB_LOCATION, 'type' => 'enum', 'source' => $arr_sub_locations), 'website_url' => array('title' => _WEBSITE_URL, 'type' => 'label'), 'business_email' => array('title' => _EMAIL_ADDRESS, 'type' => 'label'), 'mod_is_approved' => array('title' => _STATUS, 'type' => 'label'), 'mod_is_published' => array('title' => _PUBLISHED, 'type' => 'label'), 'date_published' => array('title' => _DATE_PUBLISHED, 'type' => 'datetime', 'format' => 'datetime', 'format_parameter' => $datetime_format)));
        if ($bpf_phone) {
            $this->arrDetailsModeFields['separator_general']['business_phone'] = array('title' => _PHONE, 'type' => 'label');
            $this->arrDetailsModeFields['separator_general']['business_fax'] = array('title' => _FAX, 'type' => 'label');
        }
        if ($bpf_video_link) {
            $this->arrDetailsModeFields['separator_general']['video_url'] = array('title' => _VIDEO, 'type' => 'label');
        }
        if ($this->bpf_keywords_count) {
            $this->arrDetailsModeFields['separator_general']['keywords'] = array('title' => _KEYWORDS, 'type' => 'label');
        }
        if ($bpf_logo) {
            $this->arrDetailsModeFields['separator_gallery']['separator_info'] = array('legend' => _GALLERY);
            $this->arrDetailsModeFields['separator_gallery']['image_file'] = array('title' => _LOGO, 'type' => 'image', 'target' => 'images/listings/', 'image_width' => '90px', 'image_height' => '80px', 'no_image' => 'no_image.png');
            for ($i = 1; $i <= $bpf_images_count; $i++) {
                $this->arrDetailsModeFields['separator_gallery']['image_' . $i] = array('title' => _IMAGE . ' #' . $i, 'type' => 'image', 'target' => 'images/listings/', 'image_width' => '90px', 'image_height' => '80px', 'no_image' => 'no_image.png');
            }
        }
        if ($bpf_map) {
            $this->arrDetailsModeFields['separator_map']['separator_info'] = array('legend' => _MAP_CODE);
            $this->arrDetailsModeFields['separator_map']['map_code'] = array('title' => _MAP_CODE, 'type' => 'html');
        }
        if ($objLogin->IsLoggedInAsAdmin()) {
            $this->arrDetailsModeFields['separator_general']['priority_order'] = array('title' => _ORDER, 'type' => 'label');
            $this->arrDetailsModeFields['separator_general']['mod_is_featured'] = array('title' => _FEATURED, 'type' => 'label');
            $this->arrDetailsModeFields['separator_general']['access_level'] = array('title' => _ACCESSIBLE_BY, 'type' => 'enum', 'source' => $arr_access_levels);
        }
        $this->arrDetailsModeFields['separator_general']['finish_publishing'] = array('title' => _FINISH_PUBLISHING, 'type' => 'label', 'format' => 'date', 'format_parameter' => $date_format);
        ///////////////////////////////////////////////////////////////////////////////
        // 3. add translation fields to all modes
        $arrTranslations = array();
        if ($bpf_business_name) {
            $arrTranslations['business_name'] = array('title' => _NAME, 'type' => 'textbox', 'required' => true, 'width' => '410px', 'maxlength' => '125');
        }
        if ($bpf_address) {
            $arrTranslations['business_address'] = array('title' => _ADDRESS, 'type' => 'textarea', 'required' => false, 'width' => '410px', 'height' => '50px', 'maxlength' => '255');
        }
        if ($bpf_business_description) {
            $arrTranslations['business_description'] = array('title' => _DESCRIPTION, 'type' => 'textarea', 'required' => false, 'width' => '410px', 'height' => '90px', 'maxlength' => '1024');
        }
        $this->AddTranslateToModes($this->arrTranslations, $arrTranslations);
        ///////////////////////////////////////////////////////////////////////////////
    }
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;
        }
    }