function __construct($inq_id, $customer_id = 0)
    {
        parent::__construct();
        $this->params = array();
        ## for standard fields
        if (isset($_POST['inquiry_id'])) {
            $this->params['inquiry_id'] = prepare_input($_POST['inquiry_id']);
        }
        if (isset($_POST['customer_id'])) {
            $this->params['customer_id'] = prepare_input($_POST['customer_id']);
        }
        if (isset($_POST['date_added'])) {
            $this->params['date_added'] = prepare_input($_POST['date_added']);
        }
        if (isset($_POST['message'])) {
            $this->params['message'] = prepare_input($_POST['message']);
        }
        ## for checkboxes
        //$this->params['field4'] = isset($_POST['field4']) ? prepare_input($_POST['field4']) : '0';
        ## for images (not necessary)
        //if(isset($_POST['icon'])){
        //	$this->params['icon'] = prepare_input($_POST['icon']);
        //}else if(isset($_FILES['icon']['name']) && $_FILES['icon']['name'] != ''){
        //	// nothing
        //}else if (self::GetParameter('action') == 'create'){
        //	$this->params['icon'] = '';
        //}
        ## for files:
        // define nothing
        ///$this->params['language_id'] = MicroGrid::GetParameter('language_id');
        //$this->uPrefix 		= 'prefix_';
        $this->primaryKey = 'id';
        $this->tableName = TABLE_INQUIRIES_REPLIES;
        // TABLE_NAME
        $this->dataSet = array();
        $this->error = '';
        $this->formActionURL = (!empty($customer_id) ? 'index.php?customer=inquiries_reply' : 'index.php?admin=mod_inquiries_reply') . '&inq_id=' . (int) $inq_id;
        $this->actions = array('add' => false, 'edit' => false, 'details' => true, 'delete' => false);
        $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 ir.inquiry_id = ' . (int) $inq_id . (!empty($customer_id) ? ' AND customer_id = ' . (int) $customer_id : '');
        $this->GROUP_BY_CLAUSE = '';
        // GROUP BY '.$this->tableName.'.order_number
        $this->ORDER_CLAUSE = 'ORDER BY ir.date_added DESC';
        $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();
        ///$this->isAggregateAllowed = false;
        ///// define aggregate fields for View Mode
        ///$this->arrAggregateFields = array(
        ///	'field1' => array('function'=>'SUM', 'align'=>'center', 'aggregate_by'=>'', 'decimal_place'=>2),
        ///	'field2' => array('function'=>'AVG', 'align'=>'center', 'aggregate_by'=>'', 'decimal_place'=>2),
        ///);
        ///$date_format = get_date_format('view');
        ///$date_format_settings = get_date_format('view', true); /* to get pure settings format */
        ///$date_format_edit = get_date_format('edit');
        $datetime_format = get_datetime_format();
        ///$time_format = get_time_format(); /* by default 1st param - shows seconds */
        ///$currency_format = get_currency_format();
        // prepare languages array
        /// $total_languages = Languages::GetAllActive();
        /// $arr_languages      = array();
        /// foreach($total_languages[0] as $key => $val){
        /// 	$arr_languages[$val['abbreviation']] = $val['lang_name'];
        /// }
        ///////////////////////////////////////////////////////////////////////////////
        // #002. prepare translation fields array
        /// $this->arrTranslations = $this->PrepareTranslateFields(
        ///	array('field1', 'field2')
        /// );
        ///////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////
        // #003. prepare translations array for add/edit/detail modes
        /// REMEMBER! to add '.$sql_translation_description.' in EDIT_MODE_SQL
        /// $sql_translation_description = $this->PrepareTranslateSql(
        ///	TABLE_XXX_DESCRIPTION,
        ///	'gallery_album_id',
        ///	array('field1', 'field2')
        /// );
        ///////////////////////////////////////////////////////////////////////////////
        //----------------------------------------------------------------------
        // VIEW MODE
        // format: strip_tags, nl2br, readonly_text
        // 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 ir.' . $this->primaryKey . ',
									ir.inquiry_id,
									ir.customer_id,
									ir.message,
									ir.date_added,
									CONCAT(c.first_name, \' \', c.last_name) as customer_name
								FROM ' . $this->tableName . ' ir
									INNER JOIN ' . TABLE_CUSTOMERS . ' c ON ir.customer_id = c.id
								';
        // define view mode fields
        $this->arrViewModeFields = array('customer_name' => array('title' => _CUSTOMER, 'type' => 'label', 'align' => 'left', 'width' => '', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'tooltip' => '', 'maxlength' => '', 'format' => '', 'format_parameter' => ''), 'date_added' => array('title' => _DATE_ADDED, 'type' => 'label', 'align' => 'left', 'width' => '200px', 'header' => '', 'maxlength' => '', 'format' => 'date', 'format_parameter' => $datetime_format));
        //----------------------------------------------------------------------
        // 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('message' => array('title' => _MESSAGE, 'type' => 'textarea', 'width' => '510px', 'required' => true, 'readonly' => false, 'maxlength' => '2048', 'default' => '', 'height' => '200px', 'editor_type' => 'simple|wysiwyg', 'validation_type' => '', 'unique' => false, 'visible' => true), 'customer_id' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $customer_id), 'inquiry_id' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $inq_id), 'date_added' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => date('Y-m-d H:i:s')));
        //----------------------------------------------------------------------
        // 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'
        // - for editable passwords they must be defined directly in SQL : '.$this->tableName.'.user_password,
        //----------------------------------------------------------------------
        $this->EDIT_MODE_SQL = 'SELECT
								' . $this->tableName . '.' . $this->primaryKey . ',
								' . $this->tableName . '.inquiry_id,
								' . $this->tableName . '.customer_id,
								' . $this->tableName . '.message,
								' . $this->tableName . '.date_added,
								CONCAT(c.first_name, \' \', c.last_name) as customer_name
							FROM ' . $this->tableName . '
								INNER JOIN ' . TABLE_CUSTOMERS . ' c ON ' . $this->tableName . '.customer_id = c.id
							WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array('customer_name' => array('title' => _CUSTOMER, 'type' => 'label', 'format' => '', 'format_parameter' => '', 'visible' => true), 'date_added' => array('title' => _DATE_ADDED, 'type' => 'date', 'required' => true, 'readonly' => true, 'unique' => false, 'visible' => true, 'default' => '', 'validation_type' => 'date', 'format' => 'date', 'format_parameter' => $datetime_format, 'min_year' => '90', 'max_year' => '10'), 'message' => array('title' => _MESSAGE, 'type' => 'textarea', 'width' => '510px', 'required' => false, 'readonly' => true, 'maxlength' => '', 'default' => '', 'height' => '200px', 'editor_type' => 'simple|wysiwyg', 'validation_type' => '', 'unique' => false, 'visible' => true));
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL;
        $this->arrDetailsModeFields = array('customer_name' => array('title' => _CUSTOMER, 'type' => 'label', 'format' => '', 'format_parameter' => '', 'visible' => true), 'date_added' => array('title' => _DATE_ADDED, 'type' => 'datetime', 'format' => 'date', 'format_parameter' => $datetime_format, 'visible' => true), 'message' => array('title' => _MESSAGE, 'type' => 'html', 'visible' => true));
        ///////////////////////////////////////////////////////////////////////////////
        // #004. add translation fields to all modes
        /// $this->AddTranslateToModes(
        /// $this->arrTranslations,
        /// array('name'        => array('title'=>_NAME, 'type'=>'textbox', 'width'=>'410px', 'required'=>true, 'maxlength'=>'', 'readonly'=>false),
        /// 	  'description' => array('title'=>_DESCRIPTION, 'type'=>'textarea', 'width'=>'410px', 'height'=>'90px', 'required'=>false, 'maxlength'=>'', 'maxlength'=>'512', 'validation_maxlength'=>'512', 'readonly'=>false)
        /// )
        /// );
        ///////////////////////////////////////////////////////////////////////////////
    }
Esempio n. 2
0
    function __construct($login_type = '')
    {
        parent::__construct();
        global $objSettings;
        $this->params = array();
        if (isset($_POST['first_name'])) {
            $this->params['first_name'] = prepare_input($_POST['first_name']);
        }
        if (isset($_POST['last_name'])) {
            $this->params['last_name'] = prepare_input($_POST['last_name']);
        }
        if (isset($_POST['user_name'])) {
            $this->params['user_name'] = prepare_input($_POST['user_name']);
        }
        if (isset($_POST['password'])) {
            $this->params['password'] = prepare_input($_POST['password']);
        }
        if (isset($_POST['email'])) {
            $this->params['email'] = prepare_input($_POST['email']);
        }
        if (isset($_POST['preferred_language'])) {
            $this->params['preferred_language'] = prepare_input($_POST['preferred_language']);
        }
        if (isset($_POST['account_type'])) {
            $this->params['account_type'] = prepare_input($_POST['account_type']);
        }
        if (isset($_POST['date_created'])) {
            $this->params['date_created'] = prepare_input($_POST['date_created']);
        }
        if (isset($_POST['is_active'])) {
            $this->params['is_active'] = (int) $_POST['is_active'];
        } else {
            $this->params['is_active'] = '0';
        }
        if (self::$PROJECT == 'HotelSite') {
            if (isset($_POST['hotels'])) {
                $this->params['hotels'] = prepare_input($_POST['hotels']);
            }
        }
        $this->primaryKey = 'id';
        $this->tableName = TABLE_ACCOUNTS;
        $this->dataSet = array();
        $this->error = '';
        $this->formActionURL = 'index.php?admin=admins_management';
        $this->actions = array('add' => true, 'edit' => true, 'details' => true, 'delete' => true);
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->allowLanguages = false;
        if ($login_type == 'owner') {
            $this->WHERE_CLAUSE = 'WHERE (' . TABLE_ACCOUNTS . '.account_type = \'mainadmin\' || ' . TABLE_ACCOUNTS . '.account_type = \'admin\' || ' . TABLE_ACCOUNTS . '.account_type = \'hotelowner\')';
        } else {
            if ($login_type == 'mainadmin') {
                $this->WHERE_CLAUSE = 'WHERE (' . TABLE_ACCOUNTS . '.account_type = \'admin\' || ' . TABLE_ACCOUNTS . '.account_type = \'hotelowner\')';
            } else {
                if ($login_type == 'admin') {
                    $this->WHERE_CLAUSE = 'WHERE ' . TABLE_ACCOUNTS . '.account_type = \'admin\'';
                } else {
                    if ($login_type == 'hotelowner') {
                        $this->WHERE_CLAUSE = 'WHERE ' . TABLE_ACCOUNTS . '.account_type = \'hotelowner\'';
                    }
                }
            }
        }
        $this->ORDER_CLAUSE = 'ORDER BY id ASC';
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 20;
        $this->isSortingAllowed = true;
        $this->isFilteringAllowed = true;
        // define filtering fields
        $this->arrFilteringFields = array(_FIRST_NAME => array('table' => $this->tableName, 'field' => 'first_name', 'type' => 'text', 'sign' => 'like%', 'width' => '80px'), _LAST_NAME => array('table' => $this->tableName, 'field' => 'last_name', 'type' => 'text', 'sign' => 'like%', 'width' => '80px'), _ACTIVE => array('table' => $this->tableName, 'field' => 'is_active', 'type' => 'dropdownlist', 'source' => array('0' => _NO, '1' => _YES), 'sign' => '=', 'width' => '85px'));
        // prepare languages array
        $total_languages = Languages::GetAllActive();
        $arr_languages = array();
        foreach ($total_languages[0] as $key => $val) {
            $arr_languages[$val['abbreviation']] = $val['lang_name'];
        }
        $arr_account_types = array('admin' => _ADMIN, 'mainadmin' => _MAIN_ADMIN);
        if (self::$PROJECT == 'HotelSite') {
            $arr_account_types['hotelowner'] = _HOTEL_OWNER;
        }
        $arr_is_active = array('0' => '<span class=no>' . _NO . '</span>', '1' => '<span class=yes>' . _YES . '</span>');
        $datetime_format = get_datetime_format();
        if (self::$PROJECT == 'HotelSite') {
            $total_hotels = Hotels::GetAllActive();
            $arr_hotels = array();
            foreach ($total_hotels[0] as $key => $val) {
                $this->arrCompanies[$val['id']] = $val['name'];
            }
            $this->additionalFields = ', hotels';
            $this->accountTypeOnChange = 'onchange="javascript:AccountType_OnChange(this.value)"';
        }
        if ($objSettings->GetParameter('date_format') == 'mm/dd/yyyy') {
            $this->sqlFieldDatetimeFormat = '%b %d, %Y %H:%i';
        } else {
            $this->sqlFieldDatetimeFormat = '%d %b, %Y %H:%i';
        }
        $this->SetLocale(Application::Get('lc_time_name'));
        //----------------------------------------------------------------------
        // VIEW MODE
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT ' . $this->primaryKey . ',
									first_name,
		                            last_name,
									CONCAT(first_name, \' \', last_name) as full_name,
									user_name,
									email,
									preferred_language,
									account_type,
									DATE_FORMAT(date_lastlogin, \'' . $this->sqlFieldDatetimeFormat . '\') as date_lastlogin,
									is_active
									' . $this->additionalFields . '
								FROM ' . $this->tableName;
        // define view mode fields
        $this->arrViewModeFields = array('full_name' => array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => ''), 'user_name' => array('title' => _USER_NAME, 'type' => 'label', 'align' => 'left', 'width' => ''), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'link', 'maxlength' => '35', 'href' => 'mailto:{email}', 'align' => 'left', 'width' => ''), 'account_type' => array('title' => _ACCOUNT_TYPE, 'type' => 'enum', 'align' => 'center', 'width' => '120px', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'source' => $arr_account_types), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'align' => 'center', 'width' => '80px', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'source' => $arr_is_active), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label', 'align' => 'center', 'width' => '110px', 'format' => 'date', 'format_parameter' => $datetime_format), 'id' => array('title' => 'ID', 'type' => 'label', 'align' => 'center', 'width' => '40px'));
        //----------------------------------------------------------------------
        // ADD MODE
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '70', 'validation_type' => 'email', 'unique' => true)), 'separator_2' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USER_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'alpha_numeric', 'unique' => true, 'username_generator' => true), 'password' => array('title' => _PASSWORD, 'type' => 'password', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'password', 'cryptography' => PASSWORDS_ENCRYPTION, 'cryptography_type' => PASSWORDS_ENCRYPTION_TYPE, 'aes_password' => PASSWORDS_ENCRYPT_KEY, 'password_generator' => true), 'account_type' => array('title' => _ACCOUNT_TYPE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'width' => '120px', 'source' => $arr_account_types, 'javascript_event' => $this->accountTypeOnChange), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'width' => '120px', 'default' => Application::Get('lang'), 'source' => $arr_languages)), 'separator_3' => array('separator_info' => array('legend' => _OTHER), 'date_lastlogin' => array('title' => '', 'type' => 'hidden', 'required' => false, 'default' => ''), 'date_created' => array('title' => '', 'type' => 'hidden', 'required' => false, 'default' => date('Y-m-d H:i:s')), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0', 'unique' => false)));
        if (self::$PROJECT == 'HotelSite') {
            $this->arrAddModeFields['separator_3']['hotels'] = array('title' => _HOTELS, 'type' => 'enum', 'width' => '', 'required' => false, 'readonly' => false, 'default' => '', 'source' => $this->arrCompanies, 'default_option' => '', 'unique' => false, 'javascript_event' => '', 'view_type' => 'checkboxes', 'multi_select' => true);
        }
        //----------------------------------------------------------------------
        // EDIT MODE
        //----------------------------------------------------------------------
        $this->EDIT_MODE_SQL = 'SELECT
								' . $this->tableName . '.' . $this->primaryKey . ',
								' . $this->tableName . '.first_name,
								' . $this->tableName . '.last_name,
								' . $this->tableName . '.user_name,
								' . $this->tableName . '.password,
								' . $this->tableName . '.email,
								' . $this->tableName . '.account_type,
								' . $this->tableName . '.preferred_language,
								DATE_FORMAT(' . $this->tableName . '.date_created, \'' . $this->sqlFieldDatetimeFormat . '\') as date_created,
								DATE_FORMAT(' . $this->tableName . '.date_lastlogin, \'' . $this->sqlFieldDatetimeFormat . '\') as date_lastlogin,
								' . $this->tableName . '.is_active
								' . $this->additionalFields . '
							FROM ' . $this->tableName . '
							WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'textbox', 'width' => '210px', 'maxlength' => '32', 'required' => true, 'validation_type' => 'text'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'textbox', 'width' => '210px', 'maxlength' => '32', 'required' => true, 'validation_type' => 'text'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '210px', 'maxlength' => '70', 'required' => true, 'validation_type' => 'email', 'unique' => true)), 'separator_2' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USER_NAME, 'type' => 'textbox', 'width' => '210px', 'maxlength' => '32', 'required' => true, 'readonly' => true, 'validation_type' => 'alpha_numeric', 'unique' => true), 'account_type' => array('title' => _ACCOUNT_TYPE, 'type' => 'enum', 'width' => '120px', 'required' => true, 'maxlength' => '32', 'readonly' => $login_type == 'owner' ? false : true, 'source' => $arr_account_types, 'javascript_event' => $this->accountTypeOnChange), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'width' => '120px', 'required' => true, 'readonly' => false, 'source' => $arr_languages)), 'separator_3' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label'), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0')));
        if (self::$PROJECT == 'HotelSite') {
            $this->arrEditModeFields['separator_3']['hotels'] = array('title' => _HOTELS, 'type' => 'enum', 'width' => '', 'required' => false, 'readonly' => false, 'default' => '', 'source' => $this->arrCompanies, 'default_option' => '', 'unique' => false, 'javascript_event' => '', 'view_type' => 'checkboxes', 'multi_select' => true);
        }
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = 'SELECT
								' . $this->tableName . '.' . $this->primaryKey . ',
								' . $this->tableName . '.first_name,
								' . $this->tableName . '.last_name,
								' . $this->tableName . '.user_name,
								' . $this->tableName . '.password,
								' . $this->tableName . '.email,
								' . $this->tableName . '.preferred_language,
								' . $this->tableName . '.account_type,
								DATE_FORMAT(' . $this->tableName . '.date_created, \'' . $this->sqlFieldDatetimeFormat . '\') as date_created,
								DATE_FORMAT(' . $this->tableName . '.date_lastlogin, \'' . $this->sqlFieldDatetimeFormat . '\') as date_lastlogin,
								' . $this->tableName . '.is_active
								' . $this->additionalFields . '
							FROM ' . $this->tableName . '
							WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_';
        $this->arrDetailsModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'label'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'label'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'label')), 'separator_2' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USER_NAME, 'type' => 'label'), 'account_type' => array('title' => _ACCOUNT_TYPE, 'type' => 'enum', 'source' => $arr_account_types), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'source' => $arr_languages)), 'separator_3' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label'), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label'), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'source' => $arr_is_active)));
        if (self::$PROJECT == 'HotelSite') {
            $this->arrDetailsModeFields['separator_3']['hotels'] = array('title' => _HOTELS, 'type' => 'enum', 'width' => '', 'required' => false, 'readonly' => false, 'default' => '', 'source' => $this->arrCompanies, 'default_option' => '', 'unique' => false, 'javascript_event' => '', 'view_type' => 'checkboxes', 'multi_select' => true);
        }
    }
Esempio n. 3
0
/**
 *  Format datetime
 *  	@param $datetime
 *  	@param $format
 *  	@param $empty_text
 *  	@param $locale
 */
function format_datetime($datetime, $format = '', $empty_text = '', $locale = false)
{
    $format = $format == '' ? get_datetime_format() : $format;
    $datetime_check = preg_replace('/0|-| |:/', '', $datetime);
    if ($datetime_check != '') {
        $datetime_new = mktime(substr($datetime, 11, 2), substr($datetime, 14, 2), substr($datetime, 17, 2), substr($datetime, 5, 2), substr($datetime, 8, 2), substr($datetime, 0, 4));
        // convert datetime according to local settings
        if ($locale && Application::Get('lang') != 'en') {
            $format = str_replace('%b', get_month_local(@strftime('%m', $datetime_new)), get_datetime_format(true, true));
            return @strftime($format, $datetime_new);
        }
        return @date($format, $datetime_new);
    } else {
        return $empty_text;
    }
}
Esempio n. 4
0
 /**
  * Draws last inquiries side block 
  * 		@param $draw
  */
 public static function DrawLastInquiriesBlock($draw = false)
 {
     $output = draw_block_top(_INCOMING_JOBS, '', 'maximized', false);
     $max_inquiries = 10;
     $datetime_format = get_datetime_format();
     $result = self::GetAllInquiries('', 'i.date_created DESC', $max_inquiries);
     if ($result[1] > 0) {
         $output .= '<ul class="incoming_jobs">';
         for ($i = 0; $i < $result[1] && $i < $max_inquiries; $i++) {
             $output .= '<li>';
             $output .= ($result[0][$i]['inquiry_type'] == '1' ? $result[0][$i]['business_name'] : $result[0][$i]['category_name']) . '<br>';
             $output .= '<div class="location">' . $result[0][$i]['location_name'] . ' <div class="date_created">' . date($datetime_format, strtotime($result[0][$i]['date_created'])) . '</div></div>';
             $output .= '</li>';
         }
         $output .= '</ul>';
     } else {
         $output .= _NO_INCOMMING_JOBS_YET;
     }
     $output .= draw_block_bottom(false);
     if ($draw) {
         echo $output;
     } else {
         return $output;
     }
 }
Esempio n. 5
0
    function __construct($customer_id = '')
    {
        global $objLogin;
        $this->SetRunningTime();
        $this->params = array();
        if (isset($_POST['status'])) {
            $this->params['status'] = prepare_input($_POST['status']);
        }
        if (isset($_POST['status_changed'])) {
            $this->params['status_changed'] = prepare_input($_POST['status_changed']);
        }
        if (isset($_POST['additional_info'])) {
            $this->params['additional_info'] = prepare_input($_POST['additional_info']);
        }
        $this->currencyFormat = get_currency_format();
        $this->params['language_id'] = MicroGrid::GetParameter('language_id');
        $rid = MicroGrid::GetParameter('rid');
        $this->primaryKey = 'id';
        $this->tableName = TABLE_ORDERS;
        $this->dataSet = array();
        $this->error = '';
        $this->order_number = '';
        $this->order_status = '';
        $this->order_customer_id = '';
        $this->order_listings = '';
        $this->order_advertise_plan_id = '';
        $arr_statuses = array('0' => _PREPARING, '1' => _PENDING, '2' => _PAID, '3' => _COMPLETED, '4' => _REFUNDED);
        $arr_statuses_edit = array('1' => _PENDING, '2' => _PAID, '3' => _COMPLETED, '4' => _REFUNDED);
        $arr_statuses_edit_cut = array('1' => _PENDING, '2' => _PAID, '3' => _COMPLETED);
        $arr_statuses_refund = array('4' => _REFUNDED);
        $arr_statuses_customer_edit = array('4' => '');
        if ($customer_id != '') {
            $this->customer_id = $customer_id;
            $this->page = 'customer=my_orders';
            $this->actions = array('add' => false, 'edit' => false, 'details' => false, 'delete' => false);
        } else {
            $this->customer_id = '';
            $this->page = 'admin=mod_payments_orders';
            $this->actions = array('add' => false, 'edit' => false, 'details' => false, 'delete' => $objLogin->IsLoggedInAs('owner') ? true : false);
        }
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->formActionURL = 'index.php?' . $this->page;
        $this->allowLanguages = false;
        $this->languageId = '';
        // ($this->params['language_id'] != '') ? $this->params['language_id'] : Languages::GetDefaultLang();
        $this->WHERE_CLAUSE = 'WHERE 1=1';
        if ($customer_id != '') {
            $this->WHERE_CLAUSE = 'WHERE ' . $this->tableName . '.status != 0 AND ' . $this->tableName . '.customer_id = ' . (int) $customer_id;
        }
        $this->ORDER_CLAUSE = 'ORDER BY ' . $this->tableName . '.id DESC';
        // ORDER BY date_created DESC
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 30;
        $this->isSortingAllowed = true;
        $datetime_format = get_datetime_format();
        $date_format = get_date_format();
        $date_format_settings = get_date_format('view', true);
        $this->currency_format = get_currency_format();
        $pre_currency_symbol = Application::Get('currency_symbol_place') == 'left' ? Application::Get('currency_symbol') : '';
        $post_currency_symbol = Application::Get('currency_symbol_place') == 'right' ? Application::Get('currency_symbol') : '';
        $this->collect_credit_card = ModulesSettings::Get('payments', 'online_collect_credit_card');
        $this->isFilteringAllowed = true;
        // define filtering fields
        $this->arrFilteringFields = array(_ORDER_NUMBER => array('table' => $this->tableName, 'field' => 'order_number', 'type' => 'text', 'sign' => 'like%', 'width' => '70px'), _DATE => array('table' => $this->tableName, 'field' => 'payment_date', 'type' => 'calendar', 'date_format' => $date_format_settings, 'sign' => 'like%', 'width' => '80px', 'visible' => true));
        if ($this->customer_id == '') {
            $this->arrFilteringFields[_CUSTOMER] = array('table' => TABLE_CUSTOMERS, 'field' => 'user_name', 'type' => 'text', 'sign' => 'like%', 'width' => '70px');
        }
        $this->arrFilteringFields[_STATUS] = array('table' => $this->tableName, 'field' => 'status', 'type' => 'dropdownlist', 'source' => $arr_statuses_edit, 'sign' => '=', 'width' => '');
        //----------------------------------------------------------------------
        // VIEW MODE
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT
								' . $this->tableName . '.' . $this->primaryKey . ',
								' . $this->tableName . '.order_number,
								' . $this->tableName . '.order_description,
								' . $this->tableName . '.order_price,
								' . $this->tableName . '.total_price,
								CONCAT(' . TABLE_CURRENCIES . '.symbol, "", ' . $this->tableName . '.total_price) as mod_total_price,
								' . $this->tableName . '.currency,
								' . $this->tableName . '.advertise_plan_id,
								' . $this->tableName . '.listings_amount,
								' . $this->tableName . '.customer_id,
								' . $this->tableName . '.transaction_number,
								' . $this->tableName . '.created_date,
								' . $this->tableName . '.payment_date,
								' . $this->tableName . '.payment_type,
								' . $this->tableName . '.payment_method,
								' . $this->tableName . '.status,
								' . $this->tableName . '.status_changed,
								CASE
									WHEN ' . $this->tableName . '.payment_type = 0 THEN "' . _ONLINE_ORDER . '"
									WHEN ' . $this->tableName . '.payment_type = 1 THEN "' . _PAYPAL . '"
									WHEN ' . $this->tableName . '.payment_type = 2 THEN "2CO"
									WHEN ' . $this->tableName . '.payment_type = 3 THEN "Authorize.Net"
									ELSE "' . _UNKNOWN . '"
								END as m_payment_type,
								CASE
									WHEN ' . $this->tableName . '.payment_method = 0 THEN "' . _PAYMENT_COMPANY_ACCOUNT . '"
									WHEN ' . $this->tableName . '.payment_method = 1 THEN "' . _CREDIT_CARD . '"
									WHEN ' . $this->tableName . '.payment_method = 2 THEN "E-Check"
									ELSE "' . _UNKNOWN . '"
								END as m_payment_method,
								CASE
									WHEN ' . $this->tableName . '.status = 0 THEN "<span style=color:#960000>' . _PREPARING . '</span>"
									WHEN ' . $this->tableName . '.status = 1 THEN "<span style=color:#FF9966>' . _PENDING . '</span>"
									WHEN ' . $this->tableName . '.status = 2 THEN "<span style=color:#336699>' . _PAID . '</span>"
									WHEN ' . $this->tableName . '.status = 3 THEN "<span style=color:#009600>' . _COMPLETED . '</span>"
									WHEN ' . $this->tableName . '.status = 4 THEN "<span style=color:#969600>' . _REFUNDED . '</span>"
									ELSE "' . _UNKNOWN . '"
								END as m_status,
								' . TABLE_CUSTOMERS . '.user_name as customer_name,
								' . TABLE_CURRENCIES . '.symbol,
								CONCAT("<a href=\\"javascript:void(\'description\')\\" onclick=\\"javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'description\', \'", ' . $this->tableName . '.' . $this->primaryKey . ', "\')\\">[ ", "' . _DESCRIPTION . '", " ]</a>") as link_order_description,								
								IF(' . $this->tableName . '.status >= 2, CONCAT("<a href=\\"javascript:void(\'invoice\')\\" onclick=\\"javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'invoice\', \'", ' . $this->tableName . '.' . $this->primaryKey . ', "\')\\">[ ", "' . _INVOICE . '", " ]</a>"), "<span class=lightgray>' . _INVOICE . '</span>") as link_order_invoice,
								IF(' . $this->tableName . '.status = 0 OR ' . $this->tableName . '.status = 1, CONCAT("<a href=\\"javascript:void(0);\\" title=\\"Delete\\" onclick=\\"javascript:__mgDoPostBack(\'' . TABLE_ORDERS . '\', \'delete\', \'", ' . $this->tableName . '.' . $this->primaryKey . ', "\');\\">[ ' . _DELETE_WORD . ' ]</a>"), "<span class=lightgray>' . _DELETE_WORD . '</span>") as link_order_delete,
								IF(' . $this->tableName . '.status != 0, CONCAT("<a href=\\"javascript:void(0);\\" title=\\"' . _EDIT_WORD . '\\" onclick=\\"javascript:__mgDoPostBack(\'' . TABLE_ORDERS . '\', \'edit\', \'", ' . $this->tableName . '.' . $this->primaryKey . ', "\');\\">[ ' . _EDIT_WORD . ' ]</a>"), "<span class=lightgray>' . _EDIT_WORD . '</span>") as link_admin_order_edit,
								' . TABLE_ADVERTISE_PLANS_DESCRIPTION . '.name as plan_name,
								' . TABLE_CUSTOMERS . '.b_country
							FROM ' . $this->tableName . '
								LEFT OUTER JOIN ' . TABLE_CURRENCIES . ' ON ' . $this->tableName . '.currency = ' . TABLE_CURRENCIES . '.code
								LEFT OUTER JOIN ' . TABLE_CUSTOMERS . ' ON ' . $this->tableName . '.customer_id = ' . TABLE_CUSTOMERS . '.id
								LEFT OUTER JOIN ' . TABLE_ADVERTISE_PLANS_DESCRIPTION . ' ON (' . $this->tableName . '.advertise_plan_id = ' . TABLE_ADVERTISE_PLANS_DESCRIPTION . '.advertise_plan_id AND language_id = "' . Application::Get('lang') . '")
							';
        // define view mode fields
        if ($this->customer_id != '') {
            $this->arrViewModeFields = array('order_number' => array('title' => _ORDER_NUMBER, 'type' => 'label', 'align' => 'left', 'width' => '', 'header' => '', 'maxlength' => ''), 'created_date' => array('title' => _DATE, 'type' => 'label', 'align' => 'left', 'width' => '', 'header' => '', 'maxlength' => '', 'format' => 'date', 'format_parameter' => $datetime_format), 'plan_name' => array('title' => _PLAN, 'header_tooltip' => _ADVERTISE_PLAN, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'listings_amount' => array('title' => _LISTINGS, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'mod_total_price' => array('title' => _TOTAL_PRICE, 'type' => 'label', 'align' => 'right', 'width' => '', 'header' => '', 'maxlength' => '', 'sort_by' => 'total_price', 'sort_type' => 'numeric', 'format' => 'currency', 'format_parameter' => $this->currency_format . '|2'), 'm_status' => array('title' => _STATUS, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'link_order_description' => array('title' => '', 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'link_order_invoice' => array('title' => '', 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'link_order_delete' => array('title' => '', 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''));
        } else {
            $this->arrViewModeFields = array('order_number' => array('title' => _ORDER, 'type' => 'label', 'align' => 'left', 'width' => '', 'header' => '', 'maxlength' => ''), 'created_date' => array('title' => _DATE, 'type' => 'label', 'align' => 'left', 'width' => '', 'header' => '', 'maxlength' => '', 'format' => 'date', 'format_parameter' => $datetime_format), 'customer_name' => array('title' => _CUSTOMER, 'type' => 'label', 'align' => 'left', 'width' => '', 'header' => '', 'maxlength' => ''), 'b_country' => array('title' => _COUNTRY, 'type' => 'label', 'align' => 'center', 'width' => '', 'height' => '', 'maxlength' => ''), 'plan_name' => array('title' => _PLAN, 'header_tooltip' => _ADVERTISE_PLAN, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'listings_amount' => array('title' => _LISTINGS, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'm_payment_type' => array('title' => _METHOD, 'header_tooltip' => _PAYMENT_METHOD, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'total_price' => array('title' => _TOTAL_PRICE, 'type' => 'label', 'align' => 'right', 'width' => '', 'header' => '', 'maxlength' => '', 'sort_by' => 'total_price', 'sort_type' => 'numeric', 'format' => 'currency', 'format_parameter' => $this->currency_format . '|2'), 'symbol' => array('title' => '', 'type' => 'label', 'align' => 'left', 'width' => '', 'header' => '', 'maxlength' => ''), 'm_status' => array('title' => _STATUS, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'link_order_description' => array('title' => '', 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'link_order_invoice' => array('title' => '', 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'link_admin_order_edit' => array('title' => '', 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''));
        }
        //----------------------------------------------------------------------
        // ADD MODE
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array();
        //----------------------------------------------------------------------
        // EDIT MODE
        //----------------------------------------------------------------------
        $this->EDIT_MODE_SQL = 'SELECT
								' . $this->tableName . '.' . $this->primaryKey . ',
								' . $this->tableName . '.order_number,
								' . $this->tableName . '.order_number as order_number_view,
								' . $this->tableName . '.order_description,
								' . $this->tableName . '.order_price,
								' . $this->tableName . '.vat_fee,
								' . $this->tableName . '.total_price,
								' . $this->tableName . '.currency,
								' . $this->tableName . '.advertise_plan_id,
								' . $this->tableName . '.listings_amount,
								' . $this->tableName . '.customer_id,								
								' . $this->tableName . '.cc_type,
								' . $this->tableName . '.cc_holder_name,
								IF(
									LENGTH(AES_DECRYPT(' . $this->tableName . '.cc_number, "' . PASSWORDS_ENCRYPT_KEY . '")) = 4,
									CONCAT("...", AES_DECRYPT(' . $this->tableName . '.cc_number, "' . PASSWORDS_ENCRYPT_KEY . '"), " (' . _CLEANED . ')"),
									AES_DECRYPT(' . $this->tableName . '.cc_number, "' . PASSWORDS_ENCRYPT_KEY . '")
								) as m_cc_number,								
								' . $this->tableName . '.cc_cvv_code,
								' . $this->tableName . '.cc_expires_month,
								' . $this->tableName . '.cc_expires_year,
								IF(' . $this->tableName . '.cc_expires_month != "", CONCAT(' . $this->tableName . '.cc_expires_month, "/", ' . $this->tableName . '.cc_expires_year), "") as m_cc_expires_date,
								' . $this->tableName . '.transaction_number,
								' . $this->tableName . '.payment_date,
								' . $this->tableName . '.payment_type,
								' . $this->tableName . '.payment_method,
								' . $this->tableName . '.status,
								' . $this->tableName . '.status_changed,
								' . $this->tableName . '.additional_info
							FROM ' . $this->tableName . '
								LEFT OUTER JOIN ' . TABLE_CURRENCIES . ' ON ' . $this->tableName . '.currency = ' . TABLE_CURRENCIES . '.code
								LEFT OUTER JOIN ' . TABLE_CUSTOMERS . ' ON ' . $this->tableName . '.customer_id = ' . TABLE_CUSTOMERS . '.id
							';
        if ($this->customer_id != '') {
            $WHERE_CLAUSE = 'WHERE ' . $this->tableName . '.status = 3 AND
								   ' . $this->tableName . '.customer_id = ' . $this->customer_id . ' AND
			                       ' . $this->tableName . '.id = _RID_';
        } else {
            $WHERE_CLAUSE = 'WHERE ' . $this->tableName . '.id = _RID_';
        }
        $this->EDIT_MODE_SQL = $this->EDIT_MODE_SQL . $WHERE_CLAUSE;
        // prepare trigger
        $sql = 'SELECT
		            status,
					IF(TRIM(cc_number) = \'\' OR LENGTH(AES_DECRYPT(cc_number, \'' . PASSWORDS_ENCRYPT_KEY . '\')) <= 4, \'hide\', \'show\') as cc_number_trigger
				FROM ' . $this->tableName . ' WHERE id = ' . (int) $rid;
        $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY, FETCH_ASSOC);
        if ($result[1] > 0) {
            $cc_number_trigger = $result[0]['cc_number_trigger'];
            $status_trigger = $result[0]['status'];
        } else {
            $cc_number_trigger = 'hide';
            $status_trigger = '0';
        }
        // define edit mode fields
        if ($customer_id != '') {
            $this->arrEditModeFields = array('order_number_view' => array('title' => _ORDER_NUMBER, 'type' => 'label'), 'status_changed' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => date('Y-m-d H:i:s')), 'status' => array('title' => _STATUS, 'type' => 'enum', 'width' => '210px', 'required' => true, 'readonly' => false, 'source' => $arr_statuses_customer_edit), 'order_number' => array('title' => '', 'type' => 'hidden', 'required' => false, 'default' => ''), 'customer_id' => array('title' => '', 'type' => 'hidden', 'required' => false, 'default' => ''));
        } else {
            $status_readonly = $status_trigger == '6' ? true : false;
            if ($status_trigger >= '2' && $status_trigger <= '6') {
                $ind = $status_trigger;
                while ($ind--) {
                    unset($arr_statuses_edit[$ind]);
                }
                $status_source = $arr_statuses_edit;
            } else {
                $status_source = $arr_statuses_edit_cut;
            }
            $this->arrEditModeFields = array('order_number_view' => array('title' => _ORDER_NUMBER, 'type' => 'label'), 'status_changed' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => date('Y-m-d H:i:s')), 'status' => array('title' => _STATUS, 'type' => 'enum', 'width' => '210px', 'required' => true, 'readonly' => $status_readonly, 'source' => $status_source, 'javascript_event' => ''), 'order_number' => array('title' => '', 'type' => 'hidden', 'required' => false, 'default' => ''), 'customer_id' => array('title' => '', 'type' => 'hidden', 'required' => false, 'default' => ''), 'cc_type' => array('title' => _CREDIT_CARD_TYPE, 'type' => 'label'), 'cc_holder_name' => array('title' => _CREDIT_CARD_HOLDER_NAME, 'type' => 'label'), 'm_cc_number' => array('title' => _CREDIT_CARD_NUMBER, 'type' => 'label', 'post_html' => $cc_number_trigger == 'show' ? '&nbsp;[ <a href="javascript:void(0);" onclick="if(confirm(\'' . _PERFORM_OPERATION_COMMON_ALERT . '\')) __mgDoPostBack(\'' . $this->tableName . '\',\'clean_credit_card\',\'' . $rid . '\')">' . _REMOVE . '</a> ]' : ''), 'm_cc_expires_date' => array('title' => _EXPIRES, 'type' => 'label'), 'cc_cvv_code' => array('title' => _CVV_CODE, 'type' => 'label'), 'additional_info' => array('title' => _ADDITIONAL_INFO, 'type' => 'textarea', 'width' => '390px', 'header' => '90px', 'editor_type' => 'simple', 'readonly' => false, 'default' => '', 'required' => false, 'validation_type' => '', 'unique' => false));
        }
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = $this->VIEW_MODE_SQL . $WHERE_CLAUSE;
        $this->arrDetailsModeFields = array('order_number' => array('title' => _ORDER, 'type' => 'label'), 'order_description' => array('title' => _DESCRIPTION, 'type' => 'label'), 'order_price' => array('title' => _ORDER_PRICE, 'type' => 'label'), 'vat_fee' => array('title' => _VAT, 'type' => 'label'), 'total_price' => array('title' => _TOTAL_PRICE, 'type' => 'label'), 'currency' => array('title' => _CURRENCY, 'type' => 'label'), 'listings_amount' => array('title' => _LISTINGS, 'type' => 'label'), 'customer_name' => array('title' => _CUSTOMER, 'type' => 'label'), 'transaction_number' => array('title' => _TRANSACTION, 'type' => 'label'), 'payment_date' => array('title' => _DATE, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'm_payment_type' => array('title' => _PAYED_BY, 'type' => 'label'), 'm_payment_method' => array('title' => _PAYMENT_METHOD, 'type' => 'label'), 'm_status' => array('title' => _STATUS, 'type' => 'label'), 'status_changed' => array('title' => _STATUS_CHANGED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format));
    }
Esempio n. 6
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;
        }
    }
Esempio n. 7
0
    function __construct($page_id = '')
    {
        parent::__construct();
        global $objSettings;
        $this->params = array();
        ## for standard fields
        if (isset($_POST['is_published'])) {
            $this->params['is_published'] = prepare_input($_POST['is_published']);
        }
        if (isset($_POST['date_published'])) {
            $this->params['date_published'] = prepare_input($_POST['date_published']);
        }
        if ($page_id == 'home') {
            $page_id = '';
        }
        ## for checkboxes
        //$this->params['parameter4'] = isset($_POST['parameter4']) ? $_POST['parameter4'] : '0';
        ## for images
        //if(isset($_POST['icon'])){
        //	$this->params['icon'] = $_POST['icon'];
        //}else if(isset($_FILES['icon']['name']) && $_FILES['icon']['name'] != ''){
        //	// nothing
        //}else if (self::GetParameter('action') == 'create'){
        //	$this->params['icon'] = '';
        //}
        $this->params['language_id'] = MicroGrid::GetParameter('language_id');
        //$this->uPrefix 		= 'prefix_';
        $this->primaryKey = 'id';
        $this->tableName = TABLE_COMMENTS;
        $this->dataSet = array();
        $this->error = '';
        $this->formActionURL = 'index.php?admin=mod_comments_management' . ($page_id != '' ? '&pid=' . (int) $page_id : '');
        $this->actions = array('add' => false, 'edit' => true, 'details' => true, 'delete' => true);
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->allowLanguages = false;
        $this->languageId = $this->params['language_id'] != '' ? $this->params['language_id'] : Languages::GetDefaultLang();
        $this->WHERE_CLAUSE = $page_id != '' ? 'WHERE ' . $this->tableName . '.article_id=' . $page_id : '';
        $this->ORDER_CLAUSE = 'ORDER BY ' . $this->tableName . '.is_published ASC, ' . $this->tableName . '.date_created DESC';
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 20;
        $this->isSortingAllowed = true;
        $this->isFilteringAllowed = true;
        // define filtering fields
        $this->arrFilteringFields = array(_PUBLISHED => array('table' => $this->tableName, 'field' => 'is_published', 'type' => 'dropdownlist', 'source' => array('0' => _NO, '1' => _YES), 'sign' => '=', 'width' => '90px'));
        $datetime_format = get_datetime_format();
        $arr_is_published = array('0' => '<span class=no>' . _NO . '</span>', '1' => '<span class=yes>' . _YES . '</span>');
        if ($objSettings->GetParameter('date_format') == 'mm/dd/yyyy') {
            $this->sqlFieldDatetimeFormat = '%b %d, %Y %H:%i';
            $this->sqlFieldDateFormat = '%b %d, %Y';
        } else {
            $this->sqlFieldDatetimeFormat = '%d %b, %Y %H:%i';
            $this->sqlFieldDateFormat = '%d %b, %Y';
        }
        $this->SetLocale(Application::Get('lc_time_name'));
        //----------------------------------------------------------------------
        // VIEW MODE
        // format: strip_tags
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT ' . $this->tableName . '.' . $this->primaryKey . ',
									' . $this->tableName . '.article_id,
									' . $this->tableName . '.user_id,
									' . $this->tableName . '.user_name,
									' . $this->tableName . '.user_email,
									' . $this->tableName . '.comment_text,									
									DATE_FORMAT(' . $this->tableName . '.date_created, \'' . $this->sqlFieldDatetimeFormat . '\') as mod_date_created,
									CONCAT("<img src=\\"images/", IF(' . $this->tableName . '.is_published, "published_g.gif", "published_x.gif"), "\\" alt=\\"\\" />") as is_published,
									' . TABLE_PAGES . '.page_title,
									' . TABLE_LANGUAGES . '.lang_name
								FROM ' . $this->tableName . '
									LEFT OUTER JOIN ' . TABLE_PAGES . ' ON ' . $this->tableName . '.article_id = ' . TABLE_PAGES . '.id
									LEFT OUTER JOIN ' . TABLE_LANGUAGES . ' ON ' . TABLE_PAGES . '.language_id = ' . TABLE_LANGUAGES . '.abbreviation
								';
        // define view mode fields
        $this->arrViewModeFields = array('mod_date_created' => array('title' => _DATE_CREATED, 'type' => 'label', 'align' => 'left', 'width' => '160px', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'height' => '', 'maxlength' => ''), 'page_title' => array('title' => _ARTICLE, 'type' => 'label', 'align' => 'left', 'width' => '', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'height' => '', 'maxlength' => '', 'format' => ''), 'is_published' => array('title' => _PUBLISHED, 'type' => 'label', 'align' => 'center', 'width' => '80px'), 'lang_name' => array('title' => _LANGUAGE, 'type' => 'label', 'align' => 'center', 'width' => '90px', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'height' => '', 'maxlength' => '', 'format' => ''), 'user_email' => array('title' => _EMAIL_ADDRESS, 'type' => 'label', 'align' => 'center', 'width' => '130px', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'height' => '', 'maxlength' => '32', 'format' => ''), 'user_name' => array('title' => _USERNAME, 'type' => 'label', 'align' => 'center', 'width' => '', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'height' => '', 'maxlength' => '32', 'format' => ''));
        //----------------------------------------------------------------------
        // ADD MODE
        // - Validation Type: alpha|numeric|float|alpha_numeric|text|email|ip_address
        // 	 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'
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array();
        //----------------------------------------------------------------------
        // EDIT MODE
        // - Validation Type: alpha|numeric|float|alpha_numeric|text|email|ip_address
        //   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'
        //----------------------------------------------------------------------
        $this->EDIT_MODE_SQL = 'SELECT
								' . $this->tableName . '.' . $this->primaryKey . ',
								' . $this->tableName . '.article_id,
								' . $this->tableName . '.user_id,
								' . $this->tableName . '.user_name,
								' . $this->tableName . '.user_email,
								' . $this->tableName . '.comment_text,
								' . $this->tableName . '.is_published,
								DATE_FORMAT(' . $this->tableName . '.date_created, \'' . $this->sqlFieldDatetimeFormat . '\') as date_created,
								' . $this->tableName . '.date_published,
								IF(' . $this->tableName . '.date_published = "0000-00-00 00:00:00", "", DATE_FORMAT(' . $this->tableName . '.date_published, \'' . $this->sqlFieldDatetimeFormat . '\')) as m_date_published,
								' . TABLE_PAGES . '.page_title,
								' . TABLE_LANGUAGES . '.lang_name
							FROM ' . $this->tableName . '
								LEFT OUTER JOIN ' . TABLE_PAGES . ' ON ' . $this->tableName . '.article_id = ' . TABLE_PAGES . '.id
								LEFT OUTER JOIN ' . TABLE_LANGUAGES . ' ON ' . TABLE_PAGES . '.language_id = ' . TABLE_LANGUAGES . '.abbreviation
							WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array('page_title' => array('title' => _ARTICLE, 'type' => 'label'), 'user_name' => array('title' => _USERNAME, 'type' => 'label'), 'user_email' => array('title' => _EMAIL_ADDRESS, 'type' => 'label'), 'lang_name' => array('title' => _LANGUAGE, 'type' => 'label'), 'comment_text' => array('title' => _TEXT, 'type' => 'label'), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'date_published' => array('title' => '', 'type' => 'hidden', 'required' => false, 'default' => date('Y-m-d H:i:s')), 'm_date_published' => array('title' => _DATE_PUBLISHED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'is_published' => array('title' => _APPROVE, 'type' => 'enum', 'width' => '80px', 'required' => true, 'readonly' => false, 'source' => array('1' => _YES), 'unique' => false));
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL;
        $this->arrDetailsModeFields = array('page_title' => array('title' => _ARTICLE, 'type' => 'label'), 'user_name' => array('title' => _USERNAME, 'type' => 'label'), 'user_email' => array('title' => _EMAIL_ADDRESS, 'type' => 'label'), 'lang_name' => array('title' => _LANGUAGE, 'type' => 'label'), 'comment_text' => array('title' => _TEXT, 'type' => 'label', 'format' => 'nl2br'), 'is_published' => array('title' => _APPROVED, 'type' => 'enum', 'source' => $arr_is_published), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'm_date_published' => array('title' => _DATE_PUBLISHED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format));
    }
Esempio n. 8
0
    function __construct()
    {
        parent::__construct();
        $this->params = array();
        if (isset($_POST['group_id'])) {
            $this->params['group_id'] = (int) prepare_input($_POST['group_id']);
        }
        if (isset($_POST['first_name'])) {
            $this->params['first_name'] = prepare_input($_POST['first_name']);
        }
        if (isset($_POST['last_name'])) {
            $this->params['last_name'] = prepare_input($_POST['last_name']);
        }
        if (isset($_POST['birth_date']) && $_POST['birth_date'] != '') {
            $this->params['birth_date'] = prepare_input($_POST['birth_date']);
        } else {
            $this->params['birth_date'] = '0000-00-00';
        }
        if (isset($_POST['company'])) {
            $this->params['company'] = prepare_input($_POST['company']);
        }
        if (isset($_POST['b_address'])) {
            $this->params['b_address'] = prepare_input($_POST['b_address']);
        }
        if (isset($_POST['b_address_2'])) {
            $this->params['b_address_2'] = prepare_input($_POST['b_address_2']);
        }
        if (isset($_POST['b_city'])) {
            $this->params['b_city'] = prepare_input($_POST['b_city']);
        }
        if (isset($_POST['b_state'])) {
            $this->params['b_state'] = prepare_input($_POST['b_state']);
        }
        if (isset($_POST['b_country'])) {
            $this->params['b_country'] = prepare_input($_POST['b_country']);
        }
        if (isset($_POST['b_zipcode'])) {
            $this->params['b_zipcode'] = prepare_input($_POST['b_zipcode']);
        }
        if (isset($_POST['phone'])) {
            $this->params['phone'] = prepare_input($_POST['phone']);
        }
        if (isset($_POST['fax'])) {
            $this->params['fax'] = prepare_input($_POST['fax']);
        }
        if (isset($_POST['email'])) {
            $this->params['email'] = prepare_input($_POST['email']);
        }
        if (isset($_POST['url'])) {
            $this->params['url'] = prepare_input($_POST['url'], false, 'medium');
        }
        if (isset($_POST['user_name'])) {
            $this->params['user_name'] = prepare_input($_POST['user_name']);
        }
        if (isset($_POST['user_password'])) {
            $this->params['user_password'] = prepare_input($_POST['user_password']);
        }
        if (isset($_POST['preferred_language'])) {
            $this->params['preferred_language'] = prepare_input($_POST['preferred_language']);
        }
        if (isset($_POST['date_created'])) {
            $this->params['date_created'] = prepare_input($_POST['date_created']);
        }
        if (isset($_POST['date_lastlogin'])) {
            $this->params['date_lastlogin'] = prepare_input($_POST['date_lastlogin']);
        }
        if (isset($_POST['registered_from_ip'])) {
            $this->params['registered_from_ip'] = prepare_input($_POST['registered_from_ip']);
        }
        if (isset($_POST['last_logged_ip'])) {
            $this->params['last_logged_ip'] = prepare_input($_POST['last_logged_ip']);
        }
        if (isset($_POST['email_notifications'])) {
            $this->params['email_notifications'] = prepare_input($_POST['email_notifications']);
        } else {
            $this->params['email_notifications'] = '0';
        }
        if (isset($_POST['notification_status_changed'])) {
            $this->params['notification_status_changed'] = prepare_input($_POST['notification_status_changed']);
        }
        if (isset($_POST['is_active'])) {
            $this->params['is_active'] = (int) $_POST['is_active'];
        } else {
            $this->params['is_active'] = '0';
        }
        if (isset($_POST['is_removed'])) {
            $this->params['is_removed'] = (int) $_POST['is_removed'];
        } else {
            $this->params['is_removed'] = '0';
        }
        if (isset($_POST['comments'])) {
            $this->params['comments'] = prepare_input($_POST['comments']);
        }
        if (isset($_POST['registration_code'])) {
            $this->params['registration_code'] = prepare_input($_POST['registration_code']);
        }
        if (isset($_POST['plan1_listings'])) {
            $this->params['plan1_listings'] = prepare_input($_POST['plan1_listings']);
        }
        if (isset($_POST['plan2_listings'])) {
            $this->params['plan2_listings'] = prepare_input($_POST['plan2_listings']);
        }
        if (isset($_POST['plan3_listings'])) {
            $this->params['plan3_listings'] = prepare_input($_POST['plan3_listings']);
        }
        if (isset($_POST['plan4_listings'])) {
            $this->params['plan4_listings'] = prepare_input($_POST['plan4_listings']);
        }
        $rid = MicroGrid::GetParameter('rid');
        $action = MicroGrid::GetParameter('action');
        $this->email_notifications = '';
        $this->user_password = '';
        $this->allow_adding_by_admin = ModulesSettings::Get('customers', 'allow_adding_by_admin');
        $this->allow_changing_password = ModulesSettings::Get('customers', 'password_changing_by_admin');
        $this->reg_confirmation = ModulesSettings::Get('customers', 'reg_confirmation');
        $allow_adding = $this->allow_adding_by_admin == 'yes' ? true : false;
        $this->primaryKey = 'id';
        $this->tableName = TABLE_CUSTOMERS;
        $this->dataSet = array();
        $this->error = '';
        ///$this->languageId  	= (isset($_REQUEST['language_id']) && $_REQUEST['language_id'] != '') ? $_REQUEST['language_id'] : Languages::GetDefaultLang();
        $this->formActionURL = 'index.php?admin=mod_customers_management';
        $this->actions = array('add' => $allow_adding, 'edit' => true, 'details' => true, 'delete' => true);
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->allowTopButtons = true;
        $this->allowLanguages = false;
        $this->WHERE_CLAUSE = '';
        $this->ORDER_CLAUSE = 'ORDER BY id DESC';
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 20;
        $this->isSortingAllowed = true;
        $total_countries = Countries::GetAllCountries('priority_order DESC, name ASC');
        $arr_countries = array();
        foreach ($total_countries[0] as $key => $val) {
            $arr_countries[$val['abbrv']] = $val['name'];
        }
        // prepare plans array
        $total_plans = AdvertisePlans::GetAllPlans();
        $arr_plans = array();
        foreach ($total_plans[0] as $key => $val) {
            $arr_plans[$val['id']] = $val['plan_name'];
        }
        // prepare groups array
        $total_groups = CustomerGroups::GetAllGroups();
        $arr_groups = array();
        foreach ($total_groups[0] as $key => $val) {
            $arr_groups[$val['id']] = $val['name'];
        }
        // prepare languages array
        $total_languages = Languages::GetAllActive();
        $arr_languages = array();
        foreach ($total_languages[0] as $key => $val) {
            $arr_languages[$val['abbreviation']] = $val['lang_name'];
        }
        $this->isFilteringAllowed = true;
        // define filtering fields
        $this->arrFilteringFields = array(_FIRST_NAME => array('table' => 'c', 'field' => 'first_name', 'type' => 'text', 'sign' => 'like%', 'width' => '80px'), _LAST_NAME => array('table' => 'c', 'field' => 'last_name', 'type' => 'text', 'sign' => 'like%', 'width' => '80px'), _EMAIL => array('table' => 'c', 'field' => 'email', 'type' => 'text', 'sign' => 'like%', 'width' => '90px'), _ACTIVE => array('table' => 'c', 'field' => 'is_active', 'type' => 'dropdownlist', 'source' => array('0' => _NO, '1' => _YES), 'sign' => '=', 'width' => '85px'), _GROUP => array('table' => 'c', 'field' => 'group_id', 'type' => 'dropdownlist', 'source' => $arr_groups, 'sign' => '=', 'width' => '85px'));
        $customer_ip = get_current_ip();
        $datetime_format = get_datetime_format();
        $date_format_view = get_date_format('view');
        $date_format_edit = get_date_format('edit');
        $default_plan_info = AdvertisePlans::GetDefaultPlanInfo();
        $default_plan_id = isset($default_plan_info['id']) ? (int) $default_plan_info['id'] : 0;
        $default_plan_lc = isset($default_plan_info['listings_count']) ? (int) $default_plan_info['listings_count'] : 0;
        //----------------------------------------------------------------------
        // VIEW MODE
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT
									c.' . $this->primaryKey . ',
		                            c.*,
									CONCAT(c.first_name, " ", c.last_name) as full_name,
									IF(c.is_active, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as customer_active,
									cg.name as group_name
								FROM ' . $this->tableName . ' c
									LEFT OUTER JOIN ' . TABLE_CUSTOMER_GROUPS . ' cg ON c.group_id = cg.id ';
        // define view mode fields
        $this->arrViewModeFields = array('full_name' => array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '20'), 'user_name' => array('title' => _USERNAME, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '20'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'link', 'href' => 'mailto:{email}', 'align' => 'left', 'width' => '', 'maxlength' => '36'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'align' => 'left', 'width' => '', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'source' => $arr_countries), 'customer_active' => array('title' => _ACTIVE, 'type' => 'label', 'align' => 'center', 'width' => '90px'), 'group_name' => array('title' => _GROUP, 'type' => 'label', 'align' => 'left', 'width' => '90px'), 'id' => array('title' => 'ID', 'type' => 'label', 'align' => 'center', 'width' => '50px'));
        //----------------------------------------------------------------------
        // ADD MODE
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'birth_date' => array('title' => _BIRTH_DATE, 'type' => 'date', 'width' => '210px', 'required' => false, 'readonly' => false, 'default' => '', 'validation_type' => 'date', 'unique' => false, 'visible' => true, 'min_year' => '90', 'max_year' => '0', 'format' => 'date', 'format_parameter' => $date_format_edit), 'url' => array('title' => _URL, 'type' => 'textbox', 'width' => '270px', 'required' => false, 'maxlength' => '255', 'validation_type' => 'text')), 'separator_2' => array('separator_info' => array('legend' => _BILLING_ADDRESS), 'company' => array('title' => _COMPANY, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '128', 'validation_type' => 'text'), 'b_address' => array('title' => _ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_address_2' => array('title' => _ADDRESS_2, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '64', 'validation_type' => 'text'), 'b_city' => array('title' => _CITY, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_zipcode' => array('title' => _ZIP_CODE, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'width' => '', 'source' => $arr_countries, 'required' => true), 'b_state' => array('title' => _STATE_PROVINCE, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text')), 'separator_3' => array('separator_info' => array('legend' => _CONTACT_INFORMATION), 'phone' => array('title' => _PHONE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'fax' => array('title' => _FAX, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '230px', 'required' => false, 'maxlength' => '70', 'validation_type' => 'email', 'unique' => true, 'autocomplete' => 'off')), 'separator_4' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USERNAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'validation_type' => 'text', 'maxlength' => '32', 'validation_minlength' => '4', 'readonly' => false, 'unique' => true), 'user_password' => array('title' => _PASSWORD, 'type' => 'password', 'width' => '210px', 'required' => true, 'validation_type' => 'password', 'maxlength' => '20', 'cryptography' => PASSWORDS_ENCRYPTION, 'cryptography_type' => PASSWORDS_ENCRYPTION_TYPE, 'aes_password' => PASSWORDS_ENCRYPT_KEY), 'group_id' => array('title' => _CUSTOMER_GROUP, 'type' => 'enum', 'required' => false, 'readonly' => false, 'width' => '', 'source' => $arr_groups), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'width' => '120px', 'default' => Application::Get('lang'), 'source' => $arr_languages)), 'separator_5' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => date('Y-m-d H:i:s')), 'registered_from_ip' => array('title' => _REGISTERED_FROM_IP, 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $customer_ip), 'last_logged_ip' => array('title' => _LAST_LOGGED_IP, 'type' => 'hidden', 'width' => '210px', 'required' => false, 'default' => ''), 'email_notifications' => array('title' => _EMAIL_NOTIFICATION, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0', 'unique' => false), 'is_removed' => array('title' => _REMOVED, 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => '0'), 'comments' => array('title' => _COMMENTS, 'type' => 'textarea', 'width' => '420px', 'height' => '70px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'validation_maxlength' => '2048'), 'registration_code' => array('title' => _REGISTRATION_CODE, 'type' => 'hidden', 'width' => '210px', 'required' => false, 'default' => ''), 'plan1_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[1], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '1' ? (int) $default_plan_lc : '0'), 'plan2_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[2], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '2' ? (int) $default_plan_lc : '0'), 'plan3_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[3], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '3' ? (int) $default_plan_lc : '0'), 'plan4_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[4], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '4' ? (int) $default_plan_lc : '0')));
        //----------------------------------------------------------------------
        // EDIT MODE
        // * password field must be written directly in SQL!!!
        //----------------------------------------------------------------------
        $this->EDIT_MODE_SQL = 'SELECT
									' . $this->tableName . '.' . $this->primaryKey . ',
		                            ' . $this->tableName . '.*,
									' . $this->tableName . '.user_password,
									' . $this->tableName . '.date_created,
									' . $this->tableName . '.date_lastlogin,
									' . $this->tableName . '.notification_status_changed
								FROM ' . $this->tableName . '
								WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'birth_date' => array('title' => _BIRTH_DATE, 'type' => 'date', 'width' => '210px', 'required' => false, 'readonly' => false, 'default' => '', 'validation_type' => 'date', 'unique' => false, 'visible' => true, 'min_year' => '90', 'max_year' => '0', 'format' => 'date', 'format_parameter' => $date_format_edit), 'url' => array('title' => _URL, 'type' => 'textbox', 'width' => '270px', 'required' => false, 'maxlength' => '255', 'validation_type' => 'text')), 'separator_2' => array('separator_info' => array('legend' => _BILLING_ADDRESS), 'company' => array('title' => _COMPANY, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '128', 'validation_type' => 'text'), 'b_address' => array('title' => _ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_address_2' => array('title' => _ADDRESS_2, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '64', 'validation_type' => 'text'), 'b_city' => array('title' => _CITY, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_zipcode' => array('title' => _ZIP_CODE, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'width' => '', 'source' => $arr_countries, 'required' => true), 'b_state' => array('title' => _STATE_PROVINCE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '64', 'validation_type' => 'text')), 'separator_3' => array('separator_info' => array('legend' => _CONTACT_INFORMATION), 'phone' => array('title' => _PHONE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'fax' => array('title' => _FAX, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '230px', 'required' => true, 'maxlength' => '70', 'readonly' => false, 'validation_type' => 'email', 'unique' => true, 'autocomplete' => 'off')), 'separator_4' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USERNAME, 'type' => 'label'), 'user_password' => array('title' => _PASSWORD, 'type' => 'password', 'width' => '210px', 'maxlength' => '20', 'required' => true, 'validation_type' => 'password', 'cryptography' => PASSWORDS_ENCRYPTION, 'cryptography_type' => PASSWORDS_ENCRYPTION_TYPE, 'aes_password' => PASSWORDS_ENCRYPT_KEY, 'visible' => $this->allow_changing_password == 'yes' ? true : false), 'group_id' => array('title' => _CUSTOMER_GROUP, 'type' => 'enum', 'required' => false, 'readonly' => false, 'width' => '', 'source' => $arr_groups), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'width' => '120px', 'source' => $arr_languages)), 'separator_5' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'registered_from_ip' => array('title' => _REGISTERED_FROM_IP, 'type' => 'label'), 'last_logged_ip' => array('title' => _LAST_LOGGED_IP, 'type' => 'label'), 'email_notifications' => array('title' => _EMAIL_NOTIFICATION, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'notification_status_changed' => array('title' => _NOTIFICATION_STATUS_CHANGED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'is_removed' => array('title' => _REMOVED, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'comments' => array('title' => _COMMENTS, 'type' => 'textarea', 'width' => '420px', 'height' => '70px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'validation_maxlength' => '2048'), 'registration_code' => array('title' => _REGISTRATION_CODE, 'type' => 'hidden', 'width' => '210px', 'required' => false, 'default' => '')), 'separator_6' => array('separator_info' => array('legend' => _LISTINGS), 'orders_count' => array('title' => _ORDERS_COUNT, 'type' => 'label'), 'plan1_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[1], 'type' => 'label'), 'plan2_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[2], 'type' => 'label'), 'plan3_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[3], 'type' => 'label'), 'plan4_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[4], 'type' => 'label')));
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = 'SELECT
									c.' . $this->primaryKey . ',
		                            c.*,
									IF(c.email_notifications, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as email_notifications,
									IF(c.is_active, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as customer_active,
									IF(c.is_removed, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as customer_removed,
									c.date_created,
									c.date_lastlogin,
									c.notification_status_changed,
									cg.name as group_name
								FROM ' . $this->tableName . ' c
									LEFT OUTER JOIN ' . TABLE_CUSTOMER_GROUPS . ' cg ON c.group_id = cg.id
								WHERE c.' . $this->primaryKey . ' = _RID_';
        $this->arrDetailsModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'label'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'label'), 'birth_date' => array('title' => _BIRTH_DATE, 'type' => 'date', 'format' => 'date', 'format_parameter' => $date_format_view), 'url' => array('title' => _URL, 'type' => 'label')), 'separator_2' => array('separator_info' => array('legend' => _BILLING_ADDRESS), 'company' => array('title' => _COMPANY, 'type' => 'label'), 'b_address' => array('title' => _ADDRESS, 'type' => 'label'), 'b_address_2' => array('title' => _ADDRESS_2, 'type' => 'label'), 'b_city' => array('title' => _CITY, 'type' => 'label'), 'b_zipcode' => array('title' => _ZIP_CODE, 'type' => 'label'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'source' => $arr_countries), 'b_state' => array('title' => _STATE_PROVINCE, 'type' => 'label')), 'separator_3' => array('separator_info' => array('legend' => _CONTACT_INFORMATION), 'phone' => array('title' => _PHONE, 'type' => 'label'), 'fax' => array('title' => _FAX, 'type' => 'label'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'label')), 'separator_4' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USERNAME, 'type' => 'label'), 'group_name' => array('title' => _CUSTOMER_GROUP, 'type' => 'label'), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'source' => $arr_languages)), 'separator_5' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'registered_from_ip' => array('title' => _REGISTERED_FROM_IP, 'type' => 'label'), 'last_logged_ip' => array('title' => _LAST_LOGGED_IP, 'type' => 'label'), 'email_notifications' => array('title' => _EMAIL_NOTIFICATION, 'type' => 'label'), 'notification_status_changed' => array('title' => _NOTIFICATION_STATUS_CHANGED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'customer_active' => array('title' => _ACTIVE, 'type' => 'label'), 'customer_removed' => array('title' => _REMOVED, 'type' => 'label'), 'comments' => array('title' => _COMMENTS, 'type' => 'label')), 'separator_6' => array('separator_info' => array('legend' => _LISTINGS), 'orders_count' => array('title' => _ORDERS_COUNT, 'type' => 'label'), 'plan1_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[1], 'type' => 'label'), 'plan2_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[2], 'type' => 'label'), 'plan3_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[3], 'type' => 'label'), 'plan4_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[4], 'type' => 'label')));
    }
Esempio n. 9
0
    /**
     * Draw prepayment info
     * 		@param $draw
     */
    public static function DrawPrepayment($plan_id = '', $payment_type = '', $currency = '', $draw = true)
    {
        global $objSettings, $objLogin;
        $plan_id = empty($plan_id) ? MicroGrid::GetParameter('plan_id', false) : $plan_id;
        $payment_type = empty($payment_type) ? MicroGrid::GetParameter('payment_type', false) : $payment_type;
        $currency = empty($currency) ? MicroGrid::GetParameter('currency', false) : $currency;
        $output = '';
        // retrieve module parameters
        $paypal_email = ModulesSettings::Get('payments', 'paypal_email');
        $collect_credit_card = ModulesSettings::Get('payments', 'online_collect_credit_card');
        $two_checkout_vendor = ModulesSettings::Get('payments', 'two_checkout_vendor');
        $authorize_login_id = ModulesSettings::Get('payments', 'authorize_login_id');
        $authorize_transaction_key = ModulesSettings::Get('payments', 'authorize_transaction_key');
        $mode = ModulesSettings::Get('payments', 'mode');
        $vat_value = ModulesSettings::Get('payments', 'vat_value');
        // retrieve credit card info
        $cc_type = isset($_REQUEST['cc_type']) ? prepare_input($_REQUEST['cc_type']) : '';
        $cc_holder_name = isset($_POST['cc_holder_name']) ? prepare_input($_POST['cc_holder_name']) : '';
        $cc_number = isset($_POST['cc_number']) ? prepare_input($_POST['cc_number']) : "";
        $cc_expires_month = isset($_POST['cc_expires_month']) ? prepare_input($_POST['cc_expires_month']) : "1";
        $cc_expires_year = isset($_POST['cc_expires_year']) ? prepare_input($_POST['cc_expires_year']) : date("Y");
        $cc_cvv_code = isset($_POST['cc_cvv_code']) ? prepare_input($_POST['cc_cvv_code']) : "";
        // prepare datetime format
        $field_date_format = get_datetime_format();
        $currency_format = get_currency_format();
        $arr_durations = self::PrepareDurationsArray();
        // prepare clients info
        $sql = 'SELECT * FROM ' . TABLE_CUSTOMERS . ' WHERE id = ' . (int) $objLogin->GetLoggedID();
        $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY);
        $client_info = array();
        $client_info['first_name'] = isset($result[0]['first_name']) ? $result[0]['first_name'] : '';
        $client_info['last_name'] = isset($result[0]['last_name']) ? $result[0]['last_name'] : '';
        $client_info['address1'] = isset($result[0]['b_address']) ? $result[0]['b_address'] : '';
        $client_info['address2'] = isset($result[0]['b_address2']) ? $result[0]['b_address2'] : '';
        $client_info['city'] = isset($result[0]['b_city']) ? $result[0]['b_city'] : '';
        $client_info['state'] = isset($result[0]['b_state']) ? $result[0]['b_state'] : '';
        $client_info['zip'] = isset($result[0]['b_zipcode']) ? $result[0]['b_zipcode'] : '';
        $client_info['country'] = isset($result[0]['b_country']) ? $result[0]['b_country'] : '';
        $client_info['email'] = isset($result[0]['email']) ? $result[0]['email'] : '';
        $client_info['company'] = isset($result[0]['company']) ? $result[0]['company'] : '';
        $client_info['phone'] = isset($result[0]['phone']) ? $result[0]['phone'] : '';
        $client_info['fax'] = isset($result[0]['fax']) ? $result[0]['fax'] : '';
        if ($cc_holder_name == '') {
            if ($objLogin->IsLoggedIn()) {
                $cc_holder_name = $objLogin->GetLoggedFirstName() . ' ' . $objLogin->GetLoggedLastName();
            } else {
                $cc_holder_name = $client_info['first_name'] . ' ' . $client_info['last_name'];
            }
        }
        // get order number
        $sql = 'SELECT id, order_number FROM ' . TABLE_ORDERS . ' WHERE customer_id = ' . (int) $objLogin->GetLoggedID() . ' AND status = 0 ORDER BY id DESC';
        $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY);
        if ($result[1] > 0) {
            $order_number = $result[0]['order_number'];
        } else {
            $order_number = strtoupper(get_random_string(10));
        }
        $additional_info = '';
        $cart_total_wo_vat = 0;
        $vat_cost = 0;
        $cart_total = 0;
        $sql = 'SELECT
					ap.id,
					ap.listings_count,
					ap.price,
					ap.duration,
					ap.is_default,
					apd.name,
					apd.description
				FROM ' . TABLE_ADVERTISE_PLANS . ' ap
					LEFT OUTER JOIN ' . TABLE_ADVERTISE_PLANS_DESCRIPTION . ' apd ON ap.id = apd.advertise_plan_id AND apd.language_id = \'' . Application::Get('lang') . '\'
				WHERE ap.id = ' . (int) $plan_id;
        $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY);
        $fisrt_part = '<table border="0" width="97%" align="center">
			<tr><td colspan="3"><h4>' . _ORDER_DESCRIPTION . '</h4></td></tr>
			<tr><td width="20%">' . _ORDER_DATE . ' </td><td width="2%"> : </td><td> ' . format_datetime(date('Y-m-d H:i:s'), $field_date_format) . '</td></tr>';
        if ($result[1] > 0) {
            if ($result[0]['price'] == 0) {
                $payment_type = 'online';
                $collect_credit_card = 'no';
            }
            $cart_total_wo_vat = $result[0]['price'] * Application::Get('currency_rate');
            $vat_cost = $cart_total_wo_vat * ($vat_value / 100);
            $cart_total = $cart_total_wo_vat + $vat_cost;
            $duration = isset($arr_durations[$result[0]['duration']]) ? $arr_durations[$result[0]['duration']] : '';
            $fisrt_part .= '<tr><td>' . _ADVERTISE_PLAN . ' </td><td width="2%"> : </td><td> ' . $result[0]['name'] . '</td></tr>';
            $fisrt_part .= '<tr><td>' . _DURATION . ' </td><td width="2%"> : </td><td> ' . $duration . '</td></tr>';
            $fisrt_part .= '<tr><td>' . _LISTINGS . ' </td><td width="2%"> : </td><td> ' . $result[0]['listings_count'] . '</td></tr>';
            $fisrt_part .= '<tr><td>' . _PRICE . ' </td><td width="2%"> : </td><td> ' . Currencies::PriceFormat($cart_total_wo_vat) . '</td></tr>';
            $fisrt_part .= '<tr><td>' . _DESCRIPTION . ' </td><td width="2%"> : </td><td> ' . $result[0]['description'] . '</td></tr>';
        }
        $pp_params = array('api_login' => '', 'transaction_key' => '', 'order_number' => $order_number, 'address1' => $client_info['address1'], 'address2' => $client_info['address2'], 'city' => $client_info['city'], 'zip' => $client_info['zip'], 'country' => $client_info['country'], 'state' => $client_info['state'], 'first_name' => $client_info['first_name'], 'last_name' => $client_info['last_name'], 'email' => $client_info['email'], 'company' => $client_info['company'], 'phone' => $client_info['phone'], 'fax' => $client_info['fax'], 'notify' => '', 'return' => 'index.php?page=payment_return', 'cancel_return' => 'index.php?page=payment_cancel', 'paypal_form_type' => '', 'paypal_form_fields' => '', 'paypal_form_fields_count' => '', 'collect_credit_card' => $collect_credit_card, 'cc_type' => '', 'cc_holder_name' => '', 'cc_number' => '', 'cc_cvv_code' => '', 'cc_expires_month' => '', 'cc_expires_year' => '', 'currency_code' => Application::Get('currency_code'), 'additional_info' => $additional_info, 'discount_value' => '', 'extras_param' => '', 'extras_sub_total' => '', 'vat_cost' => $vat_cost, 'cart_total' => number_format((double) $cart_total, (int) Application::Get('currency_decimals'), '.', ','), 'is_prepayment' => false, 'pre_payment_type' => '', 'pre_payment_value' => 0);
        $fisrt_part .= '
			<tr><td colspan="3" nowrap="nowrap" height="10px"></td></tr>
			<tr><td colspan="3"><h4>' . _TOTAL . '</h4></td></tr>
			<tr><td>' . _SUBTOTAL . ' </td><td> : </td><td> ' . Currencies::PriceFormat($cart_total_wo_vat, '', '', $currency_format) . '</td></tr>';
        $fisrt_part .= '<tr><td>' . _VAT . ' (' . $vat_value . '%) </td><td> : </td><td> ' . Currencies::PriceFormat($vat_cost, '', '', $currency_format) . '</td></tr>';
        $fisrt_part .= '<tr><td>' . _PAYMENT_SUM . ' </td><td> : </td><td> <b>' . Currencies::PriceFormat($cart_total, '', '', $currency_format) . '</b></td></tr>';
        $fisrt_part .= '<tr><td colspan="3" nowrap="nowrap" height="0px"></td></tr>';
        $fisrt_part .= '<tr><td colspan="3">';
        //if($additional_info != ''){
        //	$fisrt_part .= '<tr><td colspan="3" nowrap height="10px"></td></tr>';
        //	$fisrt_part .= '<tr><td colspan="3"><h4>'._ADDITIONAL_INFO.'</h4>'.$additional_info.'</td></tr>';
        //}
        $second_part = '
			</td></tr>
		</table><br />';
        if ($payment_type == 'online') {
            $output .= $fisrt_part;
            $pp_params['credit_card_required'] = $collect_credit_card;
            $pp_params['cc_type'] = $cc_type;
            $pp_params['cc_holder_name'] = $cc_holder_name;
            $pp_params['cc_number'] = $cc_number;
            $pp_params['cc_cvv_code'] = $cc_cvv_code;
            $pp_params['cc_expires_month'] = $cc_expires_month;
            $pp_params['cc_expires_year'] = $cc_expires_year;
            $output .= PaymentIPN::DrawPaymentForm('online', $pp_params, $mode == 'TEST MODE' ? 'test' : 'real', false);
            $output .= $second_part;
        } else {
            if ($payment_type == 'paypal') {
                $output .= $fisrt_part;
                $pp_params['api_login'] = $paypal_email;
                $pp_params['notify'] = 'index.php?page=payment_notify_paypal';
                $pp_params['paypal_form_type'] = 'single';
                $pp_params['paypal_form_fields'] = '';
                $pp_params['paypal_form_fields_count'] = '';
                $output .= PaymentIPN::DrawPaymentForm('paypal', $pp_params, $mode == 'TEST MODE' ? 'test' : 'real', false);
                $output .= $second_part;
            } else {
                if ($payment_type == '2co') {
                    $output .= $fisrt_part;
                    $pp_params['api_login'] = $two_checkout_vendor;
                    $pp_params['notify'] = 'index.php?page=payment_notify_2co';
                    $output .= PaymentIPN::DrawPaymentForm('2co', $pp_params, $mode == 'TEST MODE' ? 'test' : 'real', false);
                    $output .= $second_part;
                } else {
                    if ($payment_type == 'authorize') {
                        $output .= $fisrt_part;
                        $pp_params['api_login'] = $authorize_login_id;
                        $pp_params['transaction_key'] = $authorize_transaction_key;
                        $pp_params['notify'] = 'index.php?page=payment_notify_autorize_net';
                        // authorize.net accepts only USD, so we need to convert the sum into USD
                        $pp_params['cart_total'] = number_format($pp_params['cart_total'] * Application::Get('currency_rate'), '2', '.', ',');
                        $output .= PaymentIPN::DrawPaymentForm('authorize.net', $pp_params, $mode == 'TEST MODE' ? 'test' : 'real', false);
                        $output .= $second_part;
                    }
                }
            }
        }
        if ($draw) {
            echo $output;
        } else {
            $output;
        }
    }
Esempio n. 10
0
    function __construct()
    {
        parent::__construct();
        global $objSettings;
        $this->params = array();
        if (isset($_POST['news_code'])) {
            $this->params['news_code'] = prepare_input($_POST['news_code']);
        }
        if (isset($_POST['header_text'])) {
            $this->params['header_text'] = prepare_input($_POST['header_text']);
        }
        if (isset($_POST['body_text'])) {
            $this->params['body_text'] = prepare_input($_POST['body_text'], false, 'medium');
        }
        if (isset($_POST['type'])) {
            $this->params['type'] = prepare_input($_POST['type']);
        }
        if (isset($_POST['date_created'])) {
            $this->params['date_created'] = prepare_input($_POST['date_created']);
        }
        $this->params['language_id'] = MicroGrid::GetParameter('language_id');
        $this->isHtmlEncoding = true;
        $this->primaryKey = 'id';
        $this->tableName = TABLE_NEWS;
        $this->dataSet = array();
        $this->error = '';
        $this->languageId = $this->params['language_id'] != '' ? $this->params['language_id'] : Languages::GetDefaultLang();
        $this->formActionURL = 'index.php?admin=mod_news_management';
        $this->actions = array('add' => true, 'edit' => true, 'details' => true, 'delete' => true);
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->allowLanguages = true;
        $this->WHERE_CLAUSE = 'WHERE language_id = \'' . $this->languageId . '\'';
        $this->ORDER_CLAUSE = 'ORDER BY date_created DESC';
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 20;
        $this->isSortingAllowed = true;
        // prepare languages array
        $total_languages = Languages::GetAllActive();
        $arr_languages = array();
        foreach ($total_languages[0] as $key => $val) {
            $arr_languages[$val['abbreviation']] = $val['lang_name'];
        }
        $arr_types = array('news' => _NEWS, 'events' => _EVENTS);
        $datetime_format = get_datetime_format();
        if ($objSettings->GetParameter('date_format') == 'mm/dd/yyyy') {
            $this->sqlFieldDatetimeFormat = '%b %d, %Y %H:%i';
            $this->sqlFieldDateFormat = '%b %d, %Y';
        } else {
            $this->sqlFieldDatetimeFormat = '%d %b, %Y %H:%i';
            $this->sqlFieldDateFormat = '%d %b, %Y';
        }
        $this->SetLocale(Application::Get('lc_time_name'));
        //----------------------------------------------------------------------
        // VIEW MODE
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT ' . $this->primaryKey . ',
									type,
									header_text,
									body_text,
									DATE_FORMAT(' . $this->tableName . '.date_created, \'' . $this->sqlFieldDatetimeFormat . '\') as mod_date_created,
									CASE
										WHEN type = "events" THEN
											CONCAT("<a href=javascript:void(0) onclick=javascript:__mgDoPostBack(\'' . $this->tableName . '\',\'details\',\'", ' . $this->primaryKey . ', "\')>events",
											       " (", (SELECT COUNT(*) as cnt FROM ' . TABLE_EVENTS_REGISTERED . ' er WHERE er.event_id = ' . $this->tableName . '.' . $this->primaryKey . '), ")</a>")
										ELSE type										
									END as type_link
								FROM ' . $this->tableName;
        // define view mode fields
        $this->arrViewModeFields = array('mod_date_created' => array('title' => _DATE_CREATED, 'type' => 'label', 'align' => 'left', 'width' => '190px', 'format' => 'date', 'format_parameter' => $datetime_format), 'header_text' => array('title' => _HEADER, 'type' => 'label', 'align' => 'left', 'width' => '', 'nowrap' => 'wrap', 'maxlength' => '90'), 'type_link' => array('title' => _TYPE, 'type' => 'label', 'align' => 'center', 'width' => '9%'));
        //----------------------------------------------------------------------
        // ADD MODE
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array('header_text' => array('title' => _HEADER, 'type' => 'textbox', 'required' => true, 'width' => '410px', 'maxlength' => '255'), 'body_text' => array('title' => _TEXT, 'type' => 'textarea', 'width' => '490px', 'height' => '200px', 'editor_type' => 'wysiwyg', 'readonly' => false, 'default' => '', 'required' => true, 'validation_type' => '', 'unique' => false, 'maxlength' => '4096', 'validation_maxlength' => '4096'), 'type' => array('title' => _TYPE, 'type' => 'enum', 'source' => $arr_types, 'required' => true, 'default' => 'news'), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'datetime', 'required' => true, 'readonly' => false, 'default' => @date('Y-m-d H:i:s'), 'validation_type' => '', 'unique' => false, 'visible' => true, 'format' => 'date', 'format_parameter' => $datetime_format, 'min_year' => '10', 'max_year' => '5'), 'language_id' => array('title' => _LANGUAGE, 'type' => 'enum', 'source' => $arr_languages, 'required' => true), 'news_code' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => get_random_string(10)));
        //----------------------------------------------------------------------
        // EDIT MODE
        //----------------------------------------------------------------------
        $this->EDIT_MODE_SQL = 'SELECT
								' . $this->tableName . '.' . $this->primaryKey . ',
								' . $this->tableName . '.type,
								' . $this->tableName . '.header_text,
								' . $this->tableName . '.body_text,
								' . $this->tableName . '.language_id,
								' . $this->tableName . '.date_created,
								DATE_FORMAT(' . $this->tableName . '.date_created, \'' . $this->sqlFieldDatetimeFormat . '\') as mod_date_created,
								' . TABLE_LANGUAGES . '.lang_name as language_name 
							FROM ' . $this->tableName . '
								INNER JOIN ' . TABLE_LANGUAGES . ' ON ' . $this->tableName . '.language_id = ' . TABLE_LANGUAGES . '.abbreviation
							WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array('header_text' => array('title' => _HEADER, 'type' => 'textbox', 'required' => true, 'width' => '410px', 'maxlength' => '255'), 'body_text' => array('title' => _TEXT, 'type' => 'textarea', 'width' => '490px', 'height' => '200px', 'editor_type' => 'wysiwyg', 'readonly' => false, 'default' => '', 'required' => true, 'validation_type' => '', 'unique' => false, 'maxlength' => '4096', 'validation_maxlength' => '4096'), 'type' => array('title' => _TYPE, 'type' => 'enum', 'source' => $arr_types, 'required' => true), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'datetime', 'required' => true, 'readonly' => false, 'unique' => false, 'visible' => true, 'format' => 'date', 'format_parameter' => $datetime_format, 'min_year' => '10', 'max_year' => '5'), 'language_id' => array('title' => _LANGUAGE, 'type' => 'enum', 'source' => $arr_languages, 'required' => true, 'readonly' => true));
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL;
        $this->arrDetailsModeFields = array('header_text' => array('title' => _HEADER, 'type' => 'label'), 'body_text' => array('title' => _TEXT, 'type' => 'html'), 'type' => array('title' => _TYPE, 'type' => 'label'), 'mod_date_created' => array('title' => _DATE_CREATED, 'type' => 'label'), 'language_name' => array('title' => _LANGUAGE, 'type' => 'label'));
    }
 /**
  * Configures the plugin settings fields.
  */
 protected function add_settings_fields()
 {
     // Load currently enabled currencies. WooCommerce default currency is
     // forcibly enabled
     $enabled_currencies = array_unique(array_merge($this->_settings_controller->get_enabled_currencies(), array($this->_settings_controller->base_currency())));
     // Add "Enabled Currencies" field
     $enabled_currencies_field_id = WC_Aelia_CurrencySwitcher_Settings::FIELD_ENABLED_CURRENCIES;
     // Prepare multi-select to allow choosing the Currencies to use
     add_settings_field($enabled_currencies_field_id, __('Select the Currencies that you would like to accept. After saving, the ' . 'options for the exchange rates will be displayed.', $this->_textdomain) . '<br /><br />' . sprintf(__('<strong>Note</strong>: WooCommerce Base Currency (%s) will be enabled automatically.', $this->_textdomain), $this->_settings_controller->base_currency()), array($this, 'render_dropdown'), $this->_settings_key, self::SECTION_CURRENCIES, array('settings_key' => $this->_settings_key, 'id' => $enabled_currencies_field_id, 'label_for' => $enabled_currencies_field_id, 'options' => $this->_settings_controller->woocommerce_currencies(), 'selected' => $enabled_currencies, 'attributes' => array('class' => $enabled_currencies_field_id, 'multiple' => 'multiple')));
     // Prepare fields to display the Exchange Rate options for each selected currency
     $exchange_rates_field_id = WC_Aelia_CurrencySwitcher_Settings::FIELD_EXCHANGE_RATES;
     $exchange_rates = $this->current_settings($exchange_rates_field_id, $this->default_settings($exchange_rates_field_id, array()));
     // Add "Exchange Rates" table
     add_settings_field($exchange_rates_field_id, __('Set the Exchange Rates for each Currency.', $this->_textdomain), array($this, 'render_exchange_rates_options'), $this->_settings_key, self::SECTION_EXCHANGE_RATES, array('settings_key' => $this->_settings_key, 'enabled_currencies' => $enabled_currencies, 'exchange_rates' => $exchange_rates, 'id' => $exchange_rates_field_id, 'label_for' => $exchange_rates_field_id, 'attributes' => array('class' => $exchange_rates_field_id)));
     $schedule_enable_field_id = WC_Aelia_CurrencySwitcher_Settings::FIELD_EXCHANGE_RATES_UPDATE_ENABLE;
     $schedule_enabled = $this->current_settings($schedule_enable_field_id);
     // Prepare select to allow choosing how often to update the Exchange Rates
     add_settings_field($schedule_enable_field_id, __('Tick this box to enable automatic updating of exchange rates.', $this->_textdomain), array($this, 'render_checkbox'), $this->_settings_key, self::SECTION_EXCHANGE_RATES_UPDATE, array('settings_key' => $this->_settings_key, 'id' => $schedule_enable_field_id, 'label_for' => $schedule_enable_field_id, 'attributes' => array('class' => $schedule_enable_field_id, 'checked' => $schedule_enabled)));
     // Add "Exchange Rates Schedule" field
     $schedule_options_field_id = WC_Aelia_CurrencySwitcher_Settings::FIELD_EXCHANGE_RATES_UPDATE_SCHEDULE;
     $current_schedule = $this->current_settings($schedule_options_field_id);
     // Retrieve the timestamp of next scheduled Exchange Rates update
     if (wp_get_schedule($this->_settings_controller->exchange_rates_update_hook()) === false) {
         $next_update_schedule = __('Not Scheduled', $this->_textdomain);
     } else {
         $next_update_schedule = date_i18n(get_datetime_format(), wp_next_scheduled($this->_settings_controller->exchange_rates_update_hook()));
     }
     // Retrieve the timestamp of last update
     if (($last_update_timestamp = $this->current_settings(WC_Aelia_CurrencySwitcher_Settings::FIELD_EXCHANGE_RATES_LAST_UPDATE)) != null) {
         $last_update_timestamp_fmt = date_i18n(get_datetime_format(), $last_update_timestamp);
     } else {
         $last_update_timestamp_fmt = __('Never updated', $this->_textdomain);
     }
     // Prepare select to allow choosing how often to update the Exchange Rates
     add_settings_field($schedule_options_field_id, __('Select how often you would like to update the exchange rates.', $this->_textdomain) . '<p>' . sprintf(__('Last update: <span id="last_exchange_rates_update">%s</span>.', $this->_textdomain), $last_update_timestamp_fmt) . '</p><p>' . sprintf(__('Next update: <span id="next_exchange_rates_update">%s</span>.', $this->_textdomain), $next_update_schedule) . '</p>', array($this, 'render_dropdown'), $this->_settings_key, self::SECTION_EXCHANGE_RATES_UPDATE, array('settings_key' => $this->_settings_key, 'id' => $schedule_options_field_id, 'label_for' => $schedule_options_field_id, 'options' => $this->_settings_controller->get_schedule_options(), 'selected' => $current_schedule, 'attributes' => array('class' => $schedule_options_field_id)));
     // Load available Exchange Rates models
     $exchange_rates_providers = $this->_settings_controller->exchange_rates_providers_options();
     asort($exchange_rates_providers);
     // Add "Exchange Rates Providers" field
     $exchange_rates_provider_field_id = WC_Aelia_CurrencySwitcher_Settings::FIELD_EXCHANGE_RATES_PROVIDER;
     $exchange_rates_keys = array_keys($exchange_rates_providers);
     $default_selected_provider = array_shift($exchange_rates_keys);
     $selected_provider = $this->current_settings($exchange_rates_provider_field_id, $default_selected_provider);
     // Prepare multi-select to allow choosing the Exchange Rates Provider
     add_settings_field($exchange_rates_provider_field_id, __('Select the Provider from which the Exchange Rates will be fetched.', $this->_textdomain), array($this, 'render_dropdown'), $this->_settings_key, self::SECTION_EXCHANGE_RATES_UPDATE, array('settings_key' => $this->_settings_key, 'id' => $exchange_rates_provider_field_id, 'label_for' => $exchange_rates_provider_field_id, 'options' => $exchange_rates_providers, 'selected' => $selected_provider, 'attributes' => array('class' => $exchange_rates_provider_field_id)));
     /*** Settings for Open Exchange Rates ***/
     $openexchange_api_key_field_id = WC_Aelia_CurrencySwitcher_Settings::FIELD_OPENEXCHANGE_API_KEY;
     $open_exchange_api_key = $this->current_settings($openexchange_api_key_field_id);
     // Prepare select to allow choosing how often to update the Exchange Rates
     add_settings_field($openexchange_api_key_field_id, __('Open Exchange Rates API Key', $this->_textdomain) . '<p>' . __('If you do not have an API Key, please visit https://openexchangerates.org/ ' . 'to register and get one.', $this->_textdomain) . '</p>', array($this, 'render_textbox'), $this->_settings_key, self::SECTION_OPENEXCHANGERATES_SETTINGS, array('settings_key' => $this->_settings_key, 'id' => $openexchange_api_key_field_id, 'label_for' => $openexchange_api_key_field_id, 'value' => $open_exchange_api_key, 'attributes' => array('class' => $openexchange_api_key_field_id)));
     /*** IP Geolocation API Settings ***/
     $ipgeolocation_enabled_field_id = WC_Aelia_CurrencySwitcher_Settings::FIELD_IPGEOLOCATION_ENABLED;
     $ipgeolocation_enabled = $this->current_settings($ipgeolocation_enabled_field_id);
     // Prepare select to allow choosing how often to update the Exchange Rates
     add_settings_field($ipgeolocation_enabled_field_id, __('Enable automatic selection of Currency depending on Visitors\' location.', $this->_textdomain), array($this, 'render_checkbox'), $this->_settings_key, self::SECTION_IPGEOLOCATION_SETTINGS, array('settings_key' => $this->_settings_key, 'id' => $ipgeolocation_enabled_field_id, 'label_for' => $ipgeolocation_enabled_field_id, 'attributes' => array('class' => $ipgeolocation_enabled_field_id, 'checked' => $ipgeolocation_enabled)));
     // Add "Enabled Currencies" field
     $ipgeolocation_default_currency_field_id = WC_Aelia_CurrencySwitcher_Settings::FIELD_IPGEOLOCATION_DEFAULT_CURRENCY;
     $ipgeolocation_default_currency = $this->current_settings($ipgeolocation_default_currency_field_id);
     // Prepare multi-select to allow choosing the Currencies to use
     add_settings_field($ipgeolocation_default_currency_field_id, __('Select the currency to use by default when a visitor comes from a country whose currency is not ' . 'supported by your site, or when geolocation resolution fails.', $this->_textdomain), array($this, 'render_dropdown'), $this->_settings_key, self::SECTION_IPGEOLOCATION_SETTINGS, array('settings_key' => $this->_settings_key, 'id' => $ipgeolocation_default_currency_field_id, 'label_for' => $ipgeolocation_default_currency_field_id, 'options' => $this->add_currency_labels($enabled_currencies), 'selected' => $ipgeolocation_default_currency, 'attributes' => array('class' => $enabled_currencies_field_id)));
     /*** Payment Gateways Settings ***/
     // Prepare fields to display the Exchange Rate options for each selected currency
     $payment_gateways_field_id = WC_Aelia_CurrencySwitcher_Settings::FIELD_PAYMENT_GATEWAYS;
     //$payment_gateways = $this->current_settings($payment_gateways_field_id, $this->default_settings($payment_gateways_field_id, array()));
     $payment_gateways = $this->current_settings($payment_gateways_field_id);
     // Add "Exchange Rates" table
     add_settings_field($payment_gateways_field_id, __('Set the payment gateways available when paying in each currency.', $this->_textdomain), array($this, 'render_payment_gateways_options'), $this->_settings_key, self::SECTION_PAYMENT_GATEWAYS_SETTINGS, array('settings_key' => $this->_settings_key, 'enabled_currencies' => $enabled_currencies, 'payment_gateways' => $payment_gateways, 'id' => $payment_gateways_field_id, 'label_for' => $payment_gateways_field_id, 'attributes' => array('class' => $payment_gateways_field_id)));
     /*** Currency selection options ***/
     $currency_by_billing_country_enabled_field_id = WC_Aelia_CurrencySwitcher_Settings::FIELD_CURRENCY_BY_BILLING_COUNTRY_ENABLED;
     $currency_by_billing_country_enabled = (int) $this->current_settings($currency_by_billing_country_enabled_field_id);
     // Prepare select to allow choosing how often to update the Exchange Rates
     add_settings_field($currency_by_billing_country_enabled_field_id, '<h3 id="currency_by_billing_country">' . __('Allow currency selection by billing country', $this->_textdomain) . '</h3>' . __('When enabled, it sets the shop currency based on the billing country ' . 'selected by the customer. This option also adds a new widget that allows ' . 'customers to choose the billing country before reaching the checkout page, ' . 'showing them the prices in the appropriate currency while they browse the site ', $this->_textdomain) . '<br />' . __('<strong>Important</strong>: if you enable this option, <strong>do not use the currency ' . 'selector widget</strong>, as any currency selected by the customer will be ignored and ' . 'overridden by this feature.', $this->_textdomain), array($this, 'render_checkbox'), $this->_settings_key, self::SECTION_CURRENCY_SELECTION_WIDGETS, array('settings_key' => $this->_settings_key, 'id' => $currency_by_billing_country_enabled_field_id, 'label_for' => $currency_by_billing_country_enabled_field_id, 'attributes' => array('class' => $currency_by_billing_country_enabled_field_id, 'checked' => $currency_by_billing_country_enabled)));
     /*** Support and troubleshooting settings ***/
     $debug_mode_enabled_field_id = WC_Aelia_CurrencySwitcher_Settings::FIELD_DEBUG_MODE_ENABLED;
     $debug_mode_enabled = (int) $this->current_settings($debug_mode_enabled_field_id);
     // Prepare select to allow choosing how often to update the Exchange Rates
     add_settings_field($debug_mode_enabled_field_id, '<h3 id="debug_mode">' . __('Enable debug mode', $this->_textdomain) . '</h3>' . sprintf(__('When debug mode is enabled, the plugin will log events to file ' . '<code>woocommerce/logs/%s-%s.txt</code>', $this->_textdomain), Logger::$log_id, sanitize_file_name(wp_hash(Logger::$log_id))), array($this, 'render_checkbox'), $this->_settings_key, self::SECTION_SUPPORT, array('settings_key' => $this->_settings_key, 'id' => $debug_mode_enabled_field_id, 'label_for' => $debug_mode_enabled_field_id, 'attributes' => array('class' => $debug_mode_enabled_field_id, 'checked' => $debug_mode_enabled)));
 }
Esempio n. 12
0
    function __construct()
    {
        parent::__construct();
        global $objSettings;
        $this->params = array();
        ## for standard fields
        if (isset($_POST['email'])) {
            $this->params['email'] = prepare_input($_POST['email']);
        }
        if (isset($_POST['date_subscribed'])) {
            $this->params['date_subscribed'] = prepare_input($_POST['date_subscribed']);
        }
        ## for checkboxes
        //$this->params['field4'] = isset($_POST['field4']) ? prepare_input($_POST['field4']) : '0';
        ## for images (not necessary)
        //if(isset($_POST['icon'])){
        //	$this->params['icon'] = prepare_input($_POST['icon']);
        //}else if(isset($_FILES['icon']['name']) && $_FILES['icon']['name'] != ''){
        //	// nothing
        //}else if (self::GetParameter('action') == 'create'){
        //	$this->params['icon'] = '';
        //}
        ## for files:
        // define nothing
        //$this->params['language_id'] = MicroGrid::GetParameter('language_id');
        //$this->uPrefix 		= 'prefix_';
        $this->primaryKey = 'id';
        $this->tableName = TABLE_NEWS_SUBSCRIBED;
        $this->dataSet = array();
        $this->error = '';
        $this->formActionURL = 'index.php?admin=mod_news_subscribed';
        $this->actions = array('add' => true, 'edit' => true, '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 ' . $this->tableName . '.date_subscribed DESC';
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 20;
        $this->isSortingAllowed = true;
        $this->isExportingAllowed = false;
        $this->arrExportingTypes = array('csv' => false);
        $this->isFilteringAllowed = true;
        // define filtering fields
        $this->arrFilteringFields = array(_EMAIL => array('table' => TABLE_NEWS_SUBSCRIBED, 'field' => 'email', 'type' => 'text', 'sign' => '%like%', 'width' => '140px', 'visible' => true));
        $datetime_format = get_datetime_format();
        ///$date_format_edit = get_date_format('edit');
        ///$currency_format = get_currency_format();
        if ($objSettings->GetParameter('date_format') == 'mm/dd/yyyy') {
            $this->sqlFieldDatetimeFormat = '%b %d, %Y %H:%i';
            $this->sqlFieldDateFormat = '%b %d, %Y';
        } else {
            $this->sqlFieldDatetimeFormat = '%d %b, %Y %H:%i';
            $this->sqlFieldDateFormat = '%d %b, %Y';
        }
        $this->SetLocale(Application::Get('lc_time_name'));
        // prepare languages array
        /// $total_languages = Languages::GetAllActive();
        /// $arr_languages      = array();
        /// foreach($total_languages[0] as $key => $val){
        /// 	$arr_languages[$val['abbreviation']] = $val['lang_name'];
        /// }
        ///////////////////////////////////////////////////////////////////////////////
        // #002. prepare translation fields array
        /// $this->arrTranslations = $this->PrepareTranslateFields(
        ///	array('field1', 'field2')
        /// );
        ///////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////
        // #003. prepare translations array for add/edit/detail modes
        /// $sql_translation_description = $this->PrepareTranslateSql(
        ///	TABLE_XXX_DESCRIPTION,
        ///	'gallery_album_id',
        ///	array('field1', 'field2')
        /// );
        ///////////////////////////////////////////////////////////////////////////////
        //----------------------------------------------------------------------
        // 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 ' . $this->primaryKey . ',
									email,
									DATE_FORMAT(' . $this->tableName . '.date_subscribed, \'' . $this->sqlFieldDatetimeFormat . '\') as mod_date_subscribed
								FROM ' . $this->tableName;
        // define view mode fields
        $this->arrViewModeFields = array('email' => array('title' => _EMAIL, 'type' => 'label', 'align' => 'left', 'width' => '', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'tooltip' => '', 'maxlength' => '', 'format' => '', 'format_parameter' => ''), 'mod_date_subscribed' => array('title' => _DATE_SUBSCRIBED, 'type' => 'label', 'align' => 'center', 'width' => '200px', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'tooltip' => '', 'maxlength' => '', '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('email' => array('title' => _EMAIL, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'readonly' => false, 'maxlength' => '70', 'default' => '', 'validation_type' => 'email', 'unique' => true, 'visible' => true, 'autocomplete' => 'off'), 'date_subscribed' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => date('Y-m-d H:i:s')));
        //----------------------------------------------------------------------
        // 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
								' . $this->tableName . '.' . $this->primaryKey . ',
									email,
									DATE_FORMAT(' . $this->tableName . '.date_subscribed, \'' . $this->sqlFieldDatetimeFormat . '\') as mod_date_subscribed
							FROM ' . $this->tableName . '
							WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array('email' => array('title' => _EMAIL, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'readonly' => false, 'maxlength' => '70', 'default' => '', 'validation_type' => 'email', 'unique' => true, 'visible' => true, 'autocomplete' => 'off'), 'mod_date_subscribed' => array('title' => _DATE_SUBSCRIBED, 'type' => 'label'));
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL;
        $this->arrDetailsModeFields = array('email' => array('title' => _EMAIL, 'type' => 'label'), 'mod_date_subscribed' => array('title' => _DATE_SUBSCRIBED, 'type' => 'label'));
        ///////////////////////////////////////////////////////////////////////////////
        // #004. add translation fields to all modes
        /// $this->AddTranslateToModes(
        /// $this->arrTranslations,
        /// array('name'        => array('title'=>_NAME, 'type'=>'textbox', 'width'=>'410px', 'required'=>true, 'maxlength'=>'', 'readonly'=>false),
        /// 	  'description' => array('title'=>_DESCRIPTION, 'type'=>'textarea', 'width'=>'410px', 'height'=>'90px', 'required'=>false, 'readonly'=>false)
        /// )
        /// );
        ///////////////////////////////////////////////////////////////////////////////
    }