function __construct($id = '') { parent::__construct(); if ($id != '') { $this->__construct_single($id); } else { $this->__construct_all(); } }
function __construct($module_name = '') { parent::__construct(); global $objLogin; $this->moduleName = $module_name; $this->primaryKey = 'id'; $this->tableName = TABLE_MODULES_SETTINGS; $this->isFilteringAllowed = false; if ($objLogin->IsLoggedInAsAdmin()) { $this->__construct_admin(); } $this->__construct_public(); }
<?php /** * @project ApPHP Business Directory * @copyright (c) 2011 ApPHP * @author ApPHP <*****@*****.**> * @license http://www.gnu.org/licenses/ */ // *** Make sure the file isn't accessed directly defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- if ($objLogin->IsLoggedInAsAdmin() && Modules::IsModuleInstalled('gallery')) { $action = MicroGrid::GetParameter('action'); $rid = MicroGrid::GetParameter('rid'); $album = MicroGrid::GetParameter('album', false); $mode = 'view'; $msg = ''; $objAlbums = new GalleryAlbums(); $album_info = $objAlbums->GetAlbumInfo($album); if (count($album_info) > 0) { $objAlbumItems = new GalleryAlbumItems(); if ($action == 'add') { $mode = 'add'; } else { if ($action == 'create') { if ($objAlbumItems->AddRecord()) { $msg = draw_success_message(_ADDING_OPERATION_COMPLETED, false); $mode = 'view'; } else { $msg = draw_important_message($objAlbumItems->error, false); $mode = 'add';
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) /// ) /// ); /////////////////////////////////////////////////////////////////////////////// }
/** * Return instance of the class */ public static function Instance() { $className = self::GetCalledClass(); if (self::$instance == null) { self::$instance = new $className(); } return self::$instance; }
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); } }
<?php /** * @project ApPHP Medical Appointment * @copyright (c) 2012 ApPHP * @author ApPHP <*****@*****.**> * @license http://www.gnu.org/licenses/ */ // *** Make sure the file isn't accessed directly defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- if ($objLogin->IsLoggedInAsCustomer() && Modules::IsModuleInstalled('listings')) { $action = MicroGrid::GetParameter('action'); $rid = MicroGrid::GetParameter('rid'); $listing_id = MicroGrid::GetParameter('listing_id', false); $mode = 'view'; $msg = ''; if (!empty($listing_id)) { $objListingsCategories = new ListingsCategories($listing_id, 'me'); if ($action == 'add') { $mode = 'add'; } else { if ($action == 'create') { if ($objListingsCategories->AddRecord()) { $msg = draw_success_message(_ADDING_OPERATION_COMPLETED, false); $mode = 'view'; } else { $msg = draw_important_message($objListingsCategories->error, false); $mode = 'add'; } } else {
function __construct() { parent::__construct(); global $objLogin; $this->params = array(); if (isset($_POST['album_code'])) { $this->params['album_code'] = prepare_input($_POST['album_code']); } if (isset($_POST['album_type'])) { $this->params['album_type'] = prepare_input($_POST['album_type']); } if (isset($_POST['priority_order'])) { $this->params['priority_order'] = prepare_input($_POST['priority_order']); } if (isset($_POST['is_active'])) { $this->params['is_active'] = prepare_input($_POST['is_active']); } else { $this->params['is_active'] = '0'; } $this->primaryKey = 'id'; $this->tableName = TABLE_GALLERY_ALBUMS; $this->dataSet = array(); $this->error = ''; $this->formActionURL = 'index.php?admin=mod_gallery_management'; $this->actions = array('add' => true, 'edit' => true, 'details' => true, 'delete' => true); $this->actionIcons = true; $this->allowRefresh = true; $this->allowTopButtons = true; $this->allowLanguages = false; $this->languageId = $objLogin->GetPreferredLang(); $this->WHERE_CLAUSE = ''; // WHERE... $this->ORDER_CLAUSE = 'ORDER BY priority_order ASC'; // ORDER BY date_created DESC $this->isAlterColorsAllowed = true; $this->isPagingAllowed = true; $this->pageSize = 20; $this->isSortingAllowed = true; $this->isFilteringAllowed = false; // define filtering fields $this->arrFilteringFields = array(); /////////////////////////////////////////////////////////////////////////////// // 1. prepare translation fields array $this->arrTranslations = $this->PrepareTranslateFields(array('name', 'description')); /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // 2. prepare translations array for edit/detail modes $sql_translation_description = $this->PrepareTranslateSql(TABLE_GALLERY_ALBUMS_DESCRIPTION, 'gallery_album_id', array('name', 'description')); /////////////////////////////////////////////////////////////////////////////// // prepare album types array $arr_album_types = array('images' => _IMAGES, 'video' => _VIDEO); $arr_is_active = array('0' => '<span class=no>' . _NO . '</span>', '1' => '<span class=yes>' . _YES . '</span>'); //---------------------------------------------------------------------- // VIEW MODE //---------------------------------------------------------------------- $this->VIEW_MODE_SQL = 'SELECT ga.' . $this->primaryKey . ', ga.album_code, ga.album_type, UCASE(ga.album_code) as mod_album_code, CONCAT(UCASE(SUBSTRING(ga.album_type, 1, 1)),LCASE(SUBSTRING(ga.album_type, 2))) as mod_album_type, gad.name, gad.description, ga.priority_order, ga.is_active, CONCAT("<a href=index.php?admin=mod_gallery_upload_items&album=", album_code, ">' . _UPLOAD . '</a> (", (SELECT COUNT(*) as cnt FROM ' . TABLE_GALLERY_ALBUM_ITEMS . ' gi WHERE gi.album_code = ga.album_code) , ")") as link_upload_items FROM (' . $this->tableName . ' ga LEFT OUTER JOIN ' . TABLE_GALLERY_ALBUMS_DESCRIPTION . ' gad ON ga.id = gad.gallery_album_id AND gad.language_id = \'' . $this->languageId . '\')'; // define view mode fields $this->arrViewModeFields = array('name' => array('title' => _ALBUM_NAME, 'type' => 'label', 'align' => 'left', 'width' => '15%', 'maxlength' => '30'), 'description' => array('title' => _DESCRIPTION, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '50'), 'mod_album_code' => array('title' => _ALBUM_CODE, 'type' => 'label', 'align' => 'center', 'width' => '12%'), 'mod_album_type' => array('title' => _TYPE, 'type' => 'label', 'align' => 'center', 'width' => '8%'), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'align' => 'center', 'width' => '8%', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'source' => $arr_is_active), 'priority_order' => array('title' => _ORDER, 'type' => 'label', 'align' => 'center', 'width' => '8%', 'movable' => true), 'link_upload_items' => array('title' => _ITEMS, 'type' => 'label', 'align' => 'center', 'width' => '12%')); //---------------------------------------------------------------------- // ADD MODE //---------------------------------------------------------------------- // define add mode fields $max_order = self::GetParameter('action') == 'add' ? $this->GetMaxOrder('priority_order', 999) : 0; $this->arrAddModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'album_code' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => get_random_string(8)), 'album_type' => array('title' => _TYPE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'source' => $arr_album_types), 'priority_order' => array('title' => _ORDER, 'type' => 'textbox', 'width' => '50px', 'maxlength' => '3', 'default' => $max_order, 'required' => true, 'readonly' => false, 'validation_type' => 'numeric'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'true_value' => '1', 'false_value' => '0', 'default' => '1'))); //---------------------------------------------------------------------- // EDIT MODE //---------------------------------------------------------------------- // define edit mode fields $this->EDIT_MODE_SQL = 'SELECT ' . $this->tableName . '.' . $this->primaryKey . ', UCASE(' . $this->tableName . '.album_code) as album_code, ' . $this->tableName . '.album_type, CONCAT(UCASE(SUBSTRING(' . $this->tableName . '.album_type, 1, 1)),LCASE(SUBSTRING(' . $this->tableName . '.album_type, 2))) as mod_album_type, ' . $sql_translation_description . ' ' . $this->tableName . '.priority_order, ' . $this->tableName . '.is_active FROM ' . $this->tableName . ' WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_'; // define edit mode fields $this->arrEditModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'album_code' => array('title' => _CODE, 'type' => 'label'), 'album_type' => array('title' => _TYPE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'source' => $arr_album_types), 'priority_order' => array('title' => _ORDER, 'type' => 'textbox', 'width' => '50px', 'maxlength' => '3', 'required' => true, 'readonly' => false, 'validation_type' => 'numeric'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'true_value' => '1', 'false_value' => '0'))); //---------------------------------------------------------------------- // DETAILS MODE //---------------------------------------------------------------------- $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL; $this->arrDetailsModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'album_code' => array('title' => _CODE, 'type' => 'label'), 'mod_album_type' => array('title' => _TYPE, 'type' => 'label'), 'priority_order' => array('title' => _ORDER, 'type' => 'label'), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'source' => $arr_is_active))); /////////////////////////////////////////////////////////////////////////////// // 3. add translation fields to all modes $this->AddTranslateToModes($this->arrTranslations, array('name' => array('title' => _NAME, 'type' => 'textbox', 'width' => '410px', 'required' => true, 'maxlength' => '125', 'readonly' => false), 'description' => array('title' => _DESCRIPTION, 'type' => 'textarea', 'width' => '410px', 'height' => '90px', 'required' => false, 'maxlength' => '255', 'validation_maxlength' => '255', 'readonly' => false))); /////////////////////////////////////////////////////////////////////////////// }
function __construct() { parent::__construct(); $this->params = array(); ## for standard fields if (isset($_POST['name'])) { $this->params['name'] = prepare_input($_POST['name']); } if (isset($_POST['priority_order'])) { $this->params['priority_order'] = prepare_input($_POST['priority_order']); } ## for checkboxes $this->params['is_active'] = isset($_POST['is_active']) ? prepare_input($_POST['is_active']) : '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_FAQ_CATEGORIES; $this->dataSet = array(); $this->error = ''; $this->formActionURL = 'index.php?admin=mod_faq_management'; $this->actions = array('add' => true, 'edit' => true, 'details' => true, '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 . '.priority_order ASC'; $this->isAlterColorsAllowed = true; $this->isPagingAllowed = true; $this->pageSize = 20; $this->isSortingAllowed = true; $this->isExportingAllowed = false; $this->arrExportingTypes = array('csv' => false); $this->isFilteringAllowed = false; // define filtering fields $this->arrFilteringFields = array(); $arr_is_active = array('0' => '<span class=no>' . _NO . '</span>', '1' => '<span class=yes>' . _YES . '</span>'); ///$date_format = get_date_format('view'); ///$date_format_edit = get_date_format('edit'); ///$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 /// $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 . ', name, priority_order, is_active, CONCAT(\'<a href="index.php?admin=mod_faq_questions_management&fcid=\', id, \'">' . _QUESTIONS . '</a> (\', (SELECT COUNT(*) as cnt FROM ' . TABLE_FAQ_CATEGORY_ITEMS . ' fci WHERE fci.category_id = ' . $this->tableName . '.id), \')\') as link_faq_category_items FROM ' . $this->tableName; // define view mode fields $this->arrViewModeFields = array('name' => array('title' => _CATEGORY, 'type' => 'label', 'align' => 'left', 'width' => '', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'tooltip' => '', 'maxlength' => '70', 'format' => '', 'format_parameter' => ''), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'align' => 'center', 'width' => '90px', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'source' => $arr_is_active), 'priority_order' => array('title' => _ORDER, 'type' => 'label', 'align' => 'center', 'width' => '90px', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'tooltip' => '', 'maxlength' => '', 'format' => '', 'format_parameter' => '', 'movable' => true), 'link_faq_category_items' => array('title' => _ITEMS, 'type' => 'label', 'align' => 'center', 'width' => '130px', '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('name' => array('title' => _CATEGORY, 'type' => 'textbox', 'width' => '310px', 'required' => true, 'readonly' => false, 'maxlength' => '255', 'default' => '', 'validation_type' => '', 'unique' => false, 'visible' => true), 'priority_order' => array('title' => _ORDER, 'type' => 'textbox', 'width' => '50px', 'required' => true, 'readonly' => false, 'maxlength' => '3', 'default' => '0', 'validation_type' => 'numeric|positive', 'unique' => false, 'visible' => true), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0', 'unique' => false)); //---------------------------------------------------------------------- // 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->primaryKey . ', name, priority_order, is_active FROM ' . $this->tableName . ' WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_'; // define edit mode fields $this->arrEditModeFields = array('name' => array('title' => _CATEGORY, 'type' => 'textbox', 'width' => '310px', 'required' => true, 'readonly' => false, 'maxlength' => '255', 'default' => '', 'validation_type' => '', 'unique' => false, 'visible' => true), 'priority_order' => array('title' => _ORDER, 'type' => 'textbox', 'width' => '50px', 'required' => true, 'readonly' => false, 'maxlength' => '3', 'default' => '0', 'validation_type' => 'numeric|positive', 'unique' => false, 'visible' => true), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0', 'unique' => false)); //---------------------------------------------------------------------- // DETAILS MODE //---------------------------------------------------------------------- $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL; $this->arrDetailsModeFields = array('name' => array('title' => _CATEGORY, 'type' => 'label'), 'priority_order' => array('title' => _ORDER, 'type' => 'label'), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'source' => $arr_is_active)); /////////////////////////////////////////////////////////////////////////////// // #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) /// ) /// ); /////////////////////////////////////////////////////////////////////////////// }
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'))); }
/** * Do (prepare) order * @param $payment_type */ public static function DoOrder($payment_type = '') { //global $objSettings; global $objLogin; if (SITE_MODE == 'demo') { self::$message = draw_important_message(_OPERATION_BLOCKED, false); return false; } // check if customer has reached the maximum number of allowed 'open' orders $max_orders = ModulesSettings::Get('payments', 'maximum_allowed_orders'); $sql = 'SELECT COUNT(*) as cnt FROM ' . TABLE_ORDERS . ' WHERE customer_id = ' . (int) $objLogin->GetLoggedID() . ' AND (status = 0 OR status = 1)'; $result = database_query($sql, DATA_ONLY); $cnt = isset($result[0]['cnt']) ? (int) $result[0]['cnt'] : 0; if ($cnt >= $max_orders) { self::$message = _MAX_ORDERS_ERROR; return false; } $return = false; $currency = MicroGrid::GetParameter('currency', false); $plan_id = MicroGrid::GetParameter('plan_id', false); $payment_type = MicroGrid::GetParameter('payment_type', false); $additionalInfo = ''; $payed_by = 0; $listings_amount = 0; $order_price = 0; $vat_percent = ModulesSettings::Get('payments', 'vat_value'); $vat_cost = 0; $total_price = 0; // add order to database if (in_array($payment_type, array('online', 'paypal', '2co', 'authorize'))) { if ($payment_type == 'paypal') { $payed_by = '1'; $status = '0'; } else { if ($payment_type == '2co') { $payed_by = '2'; $status = '0'; } else { if ($payment_type == 'authorize') { $payed_by = '3'; $status = '0'; } else { $payed_by = '0'; $status = '0'; } } } $sql = 'SELECT ap.id, ap.listings_count, ap.price, ap.duration FROM ' . TABLE_ADVERTISE_PLANS . ' ap WHERE ap.id = ' . (int) $plan_id; $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY); if ($result[1] > 0) { $listings_amount = $result[0]['listings_count']; $order_price = $result[0]['price'] * Application::Get('currency_rate'); $vat_cost = $order_price * ($vat_percent / 100); $total_price = $order_price + $vat_cost; ///////////////////////////////////////////////////////////////// $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) { $sql_start = 'UPDATE ' . TABLE_ORDERS . ' SET '; $order_number = $result[0]['order_number']; $sql_end = ' WHERE order_number = \'' . $order_number . '\''; } else { $sql_start = 'INSERT INTO ' . TABLE_ORDERS . ' SET '; $order_number = strtoupper(get_random_string(10)); $sql_end = ''; } $sql_middle = 'order_number = \'' . $order_number . '\', order_description = \'' . _LISTINGS_PURCHASING . '\', order_price = ' . number_format((double) $order_price, (int) Application::Get('currency_decimals'), '.', '') . ', vat_percent = ' . $vat_percent . ', vat_fee = ' . number_format((double) $vat_cost, (int) Application::Get('currency_decimals'), '.', '') . ', total_price = ' . number_format((double) $total_price, (int) Application::Get('currency_decimals'), '.', '') . ', currency = \'' . $currency . '\', advertise_plan_id = ' . $plan_id . ', listings_amount = ' . (int) $listings_amount . ', customer_id = ' . (int) @$objLogin->GetLoggedID() . ', transaction_number = \'\', created_date = \'' . date('Y-m-d H:i:s') . '\', payment_date = \'0000-00-00 00:00:00\', payment_type = ' . $payed_by . ', payment_method = 0, coupon_number = \'\', discount_campaign_id = 0, additional_info = \'' . $additionalInfo . '\', cc_type = \'\', cc_holder_name = \'\', cc_number = \'\', cc_expires_month = \'\', cc_expires_year = \'\', cc_cvv_code = \'\', status = ' . (int) $status . ', status_changed = \'0000-00-00 00:00:00\', email_sent = 0'; $sql = $sql_start . $sql_middle . $sql_end; if (database_void_query($sql)) { $return = true; } else { self::$message = _ORDER_PEPARING_ERROR; $return = false; } } else { self::$message = _ORDER_PEPARING_ERROR; $return = false; } } else { self::$message = _ORDER_PEPARING_ERROR; $return = false; } if (SITE_MODE == 'development' && !empty(self::$message)) { self::$message .= '<br>' . $sql . '<br>' . mysql_error(); } return $return; }
function __construct($id = '') { parent::__construct(); ////////////////////////////////////////////////////////////////// $this->id = $id; if ($this->id != '') { $sql = 'SELECT id, name, name_const, description_const, icon_file, module_tables, dependent_modules, is_installed, is_system, priority_order, settings_access_by FROM ' . TABLE_MODULES . ' WHERE id = \'' . intval($this->id) . '\''; $this->modules = database_query($sql, DATA_AND_ROWS, ALL_ROWS); } else { $this->modules = $this->GetAllModules(); } $this->modulesCount = $this->modules[1]; ////////////////////////////////////////////////////////////////// $this->params = array(); ## for standard fields if (isset($_POST['is_installed'])) { $this->params['is_installed'] = prepare_input($_POST['is_installed']); } ## 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_MODULES; $this->dataSet = array(); $this->error = ''; $this->formActionURL = 'index.php?admin=modules'; $this->actions = array('add' => true, 'edit' => true, 'details' => true, 'delete' => true); $this->actionIcons = true; $this->allowRefresh = true; $this->allowLanguages = false; $this->languageId = ''; // $this->WHERE_CLAUSE = ''; // WHERE .... / 'WHERE language_id = \''.$this->languageId.'\''; $this->ORDER_CLAUSE = 'ORDER BY is_system DESC, priority_order DESC'; $this->isAlterColorsAllowed = true; $this->isPagingAllowed = true; $this->pageSize = 20; $this->isSortingAllowed = true; $this->isFilteringAllowed = false; // define filtering fields $this->arrFilteringFields = array(); $arr_installed = array('0' => _NO, '1' => _YES); $arr_system = array('0' => _NO, '1' => _YES); // prepare languages array /// $total_languages = Languages::GetAllActive(); /// $arr_languages = array(); /// foreach($total_languages[0] as $key => $val){ /// $arr_languages[$val['abbreviation']] = $val['lang_name']; /// } //---------------------------------------------------------------------- // VIEW MODE // format: strip_tags // format: nl2br // format: 'format'=>'date', 'format_parameter'=>'M d, Y, g:i A' + IF(date_created = '0000-00-00 00:00:00', '', date_created) as date_created, //---------------------------------------------------------------------- $this->VIEW_MODE_SQL = 'SELECT ' . $this->primaryKey . ', CONCAT(UCASE(SUBSTRING(name, 1, 1)),LCASE(SUBSTRING(name, 2))) as mod_name, icon_file, name_const, description_const, module_tables, dependent_modules, CASE WHEN is_installed = 1 THEN \'success_sign.gif\' ELSE \'error_sign.gif\' END as mod_is_installed, CASE WHEN is_system = 1 THEN \'success_sign.gif\' ELSE \'error_sign.gif\' END as mod_is_system FROM ' . $this->tableName; // define view mode fields $this->arrViewModeFields = array('icon_file' => array('title' => _IMAGE, 'type' => 'image', 'align' => 'left', 'width' => '60px', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'image_width' => '42px', 'image_height' => '42px', 'target' => 'images/modules_icons/', 'no_image' => 'no_image.png'), 'mod_name' => array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'tooltip' => '', 'maxlength' => '', 'format' => '', 'format_parameter' => ''), 'mod_is_installed' => array('title' => _STATUS, 'type' => 'image', 'align' => 'center', 'width' => '120px', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'image_width' => '16px', 'image_height' => '16px', 'target' => 'images/', 'no_image' => 'error_sign.gif')); //---------------------------------------------------------------------- // 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 Max Value: 12, 255... Ex.: 'validation_maximum'=>'99.99' //---------------------------------------------------------------------- // define add mode fields $this->arrAddModeFields = array(); //---------------------------------------------------------------------- // 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 Max Value: 12, 255... Ex.: 'validation_maximum'=>'99.99' //---------------------------------------------------------------------- $this->EDIT_MODE_SQL = 'SELECT ' . $this->tableName . '.' . $this->primaryKey . ', CONCAT(UCASE(REPLACE(' . $this->tableName . '.name,"_"," "))) as mod_name, ' . $this->tableName . '.name, ' . $this->tableName . '.name_const, ' . $this->tableName . '.description_const, ' . $this->tableName . '.icon_file, ' . $this->tableName . '.module_tables, ' . $this->tableName . '.dependent_modules, ' . $this->tableName . '.is_installed, ' . $this->tableName . '.is_system, "1" as truncate_tables, IF(' . TABLE_VOCABULARY . '.key_text IS NOT NULL, ' . TABLE_VOCABULARY . '.key_text, "") as mod_description FROM ' . $this->tableName . ' LEFT OUTER JOIN ' . TABLE_VOCABULARY . ' ON (' . $this->tableName . '.description_const = ' . TABLE_VOCABULARY . '.key_value AND ' . TABLE_VOCABULARY . '.language_id = \'' . Application::Get('lang') . '\') WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_'; // define edit mode fields $this->arrEditModeFields = array('mod_name' => array('title' => _NAME, 'type' => 'label'), 'mod_description' => array('title' => _DESCRIPTION, 'type' => 'label'), 'icon_file' => array('title' => _ICON_IMAGE, 'type' => 'image', 'width' => '', 'readonly' => true, 'required' => false, 'target' => 'images/modules_icons/', 'no_image' => '', 'random_name' => true, 'overwrite_image' => false, 'unique' => false, 'image_width' => '96px', 'image_height' => '96px', 'thumbnail_create' => false, 'thumbnail_field' => '', 'thumbnail_width' => '', 'thumbnail_height' => ''), 'is_system' => array('title' => _SYSTEM_MODULE, 'type' => 'enum', 'width' => '', 'required' => false, 'readonly' => true, 'source' => $arr_system, 'unique' => false), 'is_installed' => array('title' => _INSTALLED, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => false, 'source' => $arr_installed, 'unique' => false, 'javascript_event' => 'onchange="appToggleElementReadonly(this.value,0,\'truncate_tables\',false,true,false)"'), 'truncate_tables' => array('title' => _TRUNCATE_RELATED_TABLES, 'type' => 'checkbox', 'readonly' => false, 'true_value' => '1', 'false_value' => '0', 'unique' => false)); //---------------------------------------------------------------------- // DETAILS MODE //---------------------------------------------------------------------- $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL; $this->arrDetailsModeFields = array(); }
<?php /** * @project ApPHP Business Directory * @copyright (c) 2011 ApPHP * @author ApPHP <*****@*****.**> * @license http://www.gnu.org/licenses/ */ // *** Make sure the file isn't accessed directly defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- if ($objLogin->IsLoggedInAs('owner', 'mainadmin') && Modules::IsModuleInstalled('faq')) { $action = MicroGrid::GetParameter('action'); $rid = MicroGrid::GetParameter('rid'); $fcid = MicroGrid::GetParameter('fcid', false); $mode = 'view'; $msg = ''; $objFaqCategories = new FaqCategories(); $faq_info = $objFaqCategories->GetInfoById($fcid); if (count($faq_info) > 0) { $objFaqCategoryItems = new FaqCategoryItems($fcid); if ($action == 'add') { $mode = 'add'; } else { if ($action == 'create') { if ($objFaqCategoryItems->AddRecord()) { $msg .= draw_success_message(_ADDING_OPERATION_COMPLETED, false); $mode = 'view'; } else { $msg = draw_important_message($objFaqCategoryItems->error, false); $mode = 'add';
/** * Before-Delete operations */ public function BeforeDeleteRecord() { $rid = MicroGrid::GetParameter('rid'); $sql = 'SELECT lc.id, lc.category_id, lc.listing_id, l.is_published, l.access_level FROM ' . TABLE_LISTINGS_CATEGORIES . ' lc INNER JOIN ' . TABLE_LISTINGS . ' l ON lc.listing_id = l.id WHERE lc.id = ' . (int) $rid; $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY); if ($result[1] > 0) { $this->selectedCategoryId = $result[0]['category_id']; $this->isPublished = $result[0]['is_published']; $this->accessLevel = $result[0]['access_level']; } return true; }
<?php /** * @project ApPHP Business Directory * @copyright (c) 2011 ApPHP * @author ApPHP <*****@*****.**> * @license http://www.gnu.org/licenses/ */ // *** Make sure the file isn't accessed directly defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- if ($objLogin->IsLoggedInAsCustomer() && Modules::IsModuleInstalled('inquiries')) { $action = MicroGrid::GetParameter('action'); $rid = MicroGrid::GetParameter('rid'); $act = MicroGrid::GetParameter('act', false); $mode = 'view'; $msg = ''; $inq_id = isset($_GET['inq_id']) ? (int) $_GET['inq_id'] : '0'; $customer_id = $objLogin->GetLoggedID(); $objInquiries = Inquiries::Instance(); if ($objInquiries->CustomerRelatedToInquire($inq_id)) { $objInquiriesReplies = new InquiriesReplies($inq_id, $customer_id); if ($act == 'add') { $customer_replies = !empty($customer_id) ? InquiriesReplies::GetInquiryRepliesForCustomer($inq_id, $customer_id) : 0; $inquiry_info = $objInquiries->GetInfoByID($inq_id); $is_active = isset($inquiry_info['is_active']) ? $inquiry_info['is_active'] : 0; $add_mode = $is_active && !empty($customer_id) && !$customer_replies ? true : false; if ($add_mode) { $action = 'add'; $objInquiriesReplies->SetActions(array('add' => $add_mode)); }
/** * After-deleting function */ public function AfterDeleteRecord() { // delete from categories description table $cid = MicroGrid::GetParameter('rid'); $sql = 'DELETE FROM ' . TABLE_CATEGORIES_DESCRIPTION . ' WHERE category_id = ' . (int) $cid; if (!database_void_query($sql)) { /* echo 'error!'; */ } $sql = 'DELETE FROM ' . TABLE_LISTINGS_CATEGORIES . ' WHERE category_id = ' . (int) $cid; if (!database_void_query($sql)) { /* echo 'error!'; */ } }
function __construct() { parent::__construct(); global $objLogin; $this->params = array(); if (isset($_POST['link_url'])) { $link_url = prepare_input($_POST['link_url'], false, 'medium'); if (preg_match('/www./i', $link_url) && !preg_match('/http:/i', $link_url)) { $link_url = 'http://' . $link_url; } $this->params['link_url'] = $link_url; } if (isset($_POST['priority_order'])) { $this->params['priority_order'] = prepare_input($_POST['priority_order']); } if (isset($_POST['is_active'])) { $this->params['is_active'] = (int) $_POST['is_active']; } else { $this->params['is_active'] = '0'; } ///$this->params['language_id'] = MicroGrid::GetParameter('language_id'); ## for images if (isset($_POST['image_file'])) { $this->params['image_file'] = prepare_input($_POST['image_file']); } else { if (isset($_FILES['image_file']['name']) && $_FILES['image_file']['name'] != '') { // nothing } else { if (self::GetParameter('action') == 'create') { $this->params['image_file'] = ''; } } } $this->primaryKey = 'id'; $this->tableName = TABLE_BANNERS; $this->dataSet = array(); $this->error = ''; $this->formActionURL = 'index.php?admin=mod_banners_management'; $this->actions = array('add' => true, 'edit' => true, 'details' => true, 'delete' => true); $this->actionIcons = true; $this->allowRefresh = true; $this->allowTopButtons = true; $this->allowLanguages = false; $this->languageId = $objLogin->GetPreferredLang(); $this->WHERE_CLAUSE = ''; //'WHERE '; $this->ORDER_CLAUSE = 'ORDER BY priority_order ASC'; // ORDER BY date_created DESC $this->isAlterColorsAllowed = true; $this->isPagingAllowed = true; $this->pageSize = 20; $this->isSortingAllowed = true; $this->isFilteringAllowed = false; // define filtering fields $this->arrFilteringFields = array(); $arr_is_active = array('0' => '<span class=no>' . _NO . '</span>', '1' => '<span class=yes>' . _YES . '</span>'); $slideshow_caption_html = ModulesSettings::Get('banners', 'slideshow_caption_html'); /////////////////////////////////////////////////////////////////////////////// // 1. prepare translation fields array $this->arrTranslations = $this->PrepareTranslateFields(array('image_text')); /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // 2. prepare translations array for edit/detail modes $sql_translation_description = $this->PrepareTranslateSql(TABLE_BANNERS_DESCRIPTION, 'banner_id', array('image_text')); /////////////////////////////////////////////////////////////////////////////// //---------------------------------------------------------------------- // VIEW MODE //---------------------------------------------------------------------- $this->VIEW_MODE_SQL = 'SELECT b.' . $this->primaryKey . ', b.image_file, b.image_file_thumb, bd.image_text as image_text, b.priority_order, b.is_active FROM (' . $this->tableName . ' b LEFT OUTER JOIN ' . TABLE_BANNERS_DESCRIPTION . ' bd ON b.id = bd.banner_id AND bd.language_id = \'' . $this->languageId . '\')'; // define view mode fields $this->arrViewModeFields = array('image_file_thumb' => array('title' => _BANNER_IMAGE, 'type' => 'image', 'sortable' => false, 'align' => 'left', 'width' => '150px', 'image_width' => '120px', 'image_height' => '30px', 'target' => 'images/banners/', 'no_image' => 'no_image.png'), 'image_text' => array('title' => _DESCRIPTION, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '70', 'format' => 'strip_tags'), 'priority_order' => array('title' => _ORDER, 'type' => 'label', 'align' => 'center', 'width' => '60px', 'movable' => true), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'align' => 'center', 'width' => '130px', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'source' => $arr_is_active)); //---------------------------------------------------------------------- // ADD MODE //---------------------------------------------------------------------- // define add mode fields $max_order = self::GetParameter('action') == 'add' ? $this->GetMaxOrder('priority_order', 99) : 0; $this->arrAddModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'image_file' => array('title' => _BANNER_IMAGE, 'type' => 'image', 'width' => '210px', 'required' => true, 'readonly' => false, 'target' => 'images/banners/', 'no_image' => '', 'random_name' => 'true', 'unique' => false, 'thumbnail_create' => true, 'thumbnail_field' => 'image_file_thumb', 'thumbnail_width' => '140px', 'thumbnail_height' => '30px', 'file_maxsize' => '1000k'), 'link_url' => array('title' => _URL . ' (http://)', 'type' => 'textbox', 'width' => '270px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'maxlength' => '255'), 'priority_order' => array('title' => _ORDER, 'type' => 'textbox', 'width' => '50px', 'required' => true, 'default' => $max_order, 'readonly' => false, 'validation_type' => 'numeric', 'maxlength' => '2'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0'))); //---------------------------------------------------------------------- // EDIT MODE //---------------------------------------------------------------------- // define edit mode fields $this->EDIT_MODE_SQL = 'SELECT ' . $this->primaryKey . ', image_file, image_file_thumb, ' . $sql_translation_description . ' link_url, priority_order, is_active, CONCAT(\'<img src="images/banners/\', image_file_thumb, \'" alt="" width="140px" height="30px" />\') as my_image_file FROM ' . $this->tableName . ' WHERE ' . $this->primaryKey . ' = _RID_'; // define edit mode fields $this->arrEditModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'image_file' => array('title' => _BANNER_IMAGE, 'type' => 'image', 'width' => '210px', 'required' => true, 'readonly' => false, 'target' => 'images/banners/', 'no_image' => '', 'image_width' => '280px', 'image_height' => '90px', 'random_name' => 'true', 'unique' => false, 'thumbnail_create' => true, 'thumbnail_field' => 'image_file_thumb', 'thumbnail_width' => '140px', 'thumbnail_height' => '30px'), 'link_url' => array('title' => _URL . ' (http://)', 'type' => 'textbox', 'width' => '270px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'maxlength' => '255'), 'priority_order' => array('title' => _ORDER, 'type' => 'textbox', 'width' => '50px', 'required' => true, 'readonly' => false, 'validation_type' => 'numeric', 'maxlength' => '2'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'true_value' => '1', 'false_value' => '0'))); //---------------------------------------------------------------------- // DETAILS MODE //---------------------------------------------------------------------- $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL; $this->arrDetailsModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'image_file' => array('title' => _BANNER_IMAGE, 'type' => 'image', 'target' => 'images/banners/', 'image_width' => '280px', 'image_height' => '90px', 'no_image' => 'no_image.png', 'file_maxsize' => '1000k'), 'link_url' => array('title' => _URL, 'type' => 'label'), 'priority_order' => array('title' => _ORDER, 'type' => 'label'), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'source' => $arr_is_active))); /////////////////////////////////////////////////////////////////////////////// // 3. add translation fields to all modes $this->AddTranslateToModes($this->arrTranslations, array('image_text' => array('title' => _DESCRIPTION, 'type' => 'textarea', 'width' => '410px', 'height' => '90px', 'required' => false, 'maxlength' => '255', 'validation_maxlength' => '255', 'readonly' => false, 'post_html' => $slideshow_caption_html == 'yes' ? '<br>' . _CAN_USE_TAGS_MSG . ' <b>, <i>, <u>, <br>' : ''))); /////////////////////////////////////////////////////////////////////////////// }
/** * After-Updating Record */ public function AfterUpdateRecord() { $sql = 'SELECT id, is_active, is_default FROM ' . TABLE_COUNTRIES; if ($result = database_query($sql, DATA_AND_ROWS, ALL_ROWS)) { if ((int) $result[1] == 1) { // make last country always be default $sql = 'UPDATE ' . TABLE_COUNTRIES . ' SET is_default = \'1\', is_active = \'1\' WHERE id = ' . (int) $result[0][0]['id']; database_void_query($sql); return true; } else { // save all other countries to be not default $rid = MicroGrid::GetParameter('rid'); $is_default = MicroGrid::GetParameter('is_default', false); if ($is_default == '1') { $sql = 'UPDATE ' . TABLE_COUNTRIES . ' SET is_active = \'1\' WHERE id = ' . (int) $rid; database_void_query($sql); $sql = 'UPDATE ' . TABLE_COUNTRIES . ' SET is_default = \'0\' WHERE id != ' . (int) $rid; database_void_query($sql); return true; } } } return true; }
<?php /** * @project ApPHP Business Directory * @copyright (c) 2011 ApPHP * @author ApPHP <*****@*****.**> * @license http://www.gnu.org/licenses/ */ // *** Make sure the file isn't accessed directly defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- if ($objLogin->IsLoggedInAs('owner', 'mainadmin') && Modules::IsModuleInstalled('customers')) { $action = MicroGrid::GetParameter('action'); $rid = MicroGrid::GetParameter('rid'); $email = MicroGrid::GetParameter('email', false); $mode = 'view'; $msg = ''; $objCustomers = new Customers(); if ($action == 'add') { $mode = 'add'; } else { if ($action == 'create') { if ($objCustomers->AddRecord()) { $msg = draw_success_message(_ADDING_OPERATION_COMPLETED, false); $mode = 'view'; } else { $msg = draw_important_message($objCustomers->error, false); $mode = 'add'; } } else { if ($action == 'edit') {
/** * Before Edit mode */ public function BeforeEditRecord() { // prepare array for sub-location $listing_location_id = MicroGrid::GetParameter('listing_location_id', false); if (empty($listing_location_id)) { $listing_location_id = (int) $this->result[0][0]['listing_location_id']; } $total_sub_locations = ListingsSubLocations::GetAllSubLocations($listing_location_id, 'name ASC'); $arr_sub_locations = array(); foreach ($total_sub_locations[0] as $key => $val) { $arr_sub_locations[$val['id']] = $val['name']; } $this->arrEditModeFields['separator_general']['listing_sub_location_id'] = array('title' => _SUB_LOCATION, 'type' => 'enum', 'width' => '', 'source' => $arr_sub_locations, 'required' => true); }
function __construct($lid) { parent::__construct(); $this->params = array(); ## for standard fields if (isset($_POST['name'])) { $this->params['name'] = prepare_input($_POST['name']); } if (isset($_POST['location_id'])) { $this->params['location_id'] = prepare_input($_POST['location_id']); } // $this->params['language_id'] = MicroGrid::GetParameter('language_id'); $this->primaryKey = 'id'; $this->tableName = TABLE_LISTINGS_SUB_LOCATIONS; $this->dataSet = array(); $this->error = ''; $this->formActionURL = 'index.php?admin=mod_listings_sub_locations&lid=' . (int) $lid; $this->actions = array('add' => true, '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 = 'WHERE location_id = ' . (int) $lid; $this->ORDER_CLAUSE = 'ORDER BY name ASC'; // ORDER BY '.$this->tableName.'.date_created DESC $this->isAlterColorsAllowed = true; $this->isPagingAllowed = true; $this->pageSize = 100; $this->isSortingAllowed = true; $this->isFilteringAllowed = true; $arr_default_types = array('0' => _NO, '1' => _YES); $arr_activity_types = array('0' => _NO, '1' => _YES); // define filtering fields $this->arrFilteringFields = array(_NAME => array('table' => $this->tableName, 'field' => 'name', 'type' => 'text', 'sign' => 'like%', 'width' => '100px')); //---------------------------------------------------------------------- // VIEW MODE //---------------------------------------------------------------------- $this->VIEW_MODE_SQL = 'SELECT ' . $this->primaryKey . ', name FROM ' . $this->tableName; // define view mode fields $this->arrViewModeFields = array('name' => array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '', 'height' => '', 'maxlength' => '')); //---------------------------------------------------------------------- // ADD MODE // Validation Type: alpha|numeric|float|alpha_numeric|text|email // Validation Sub-Type: positive (for numeric and float) // Ex.: 'validation_type'=>'numeric', 'validation_type'=>'numeric|positive' //---------------------------------------------------------------------- // define add mode fields $this->arrAddModeFields = array('name' => array('title' => _NAME, 'type' => 'textbox', 'width' => '240px', 'required' => true, 'readonly' => false, 'maxlength' => '50', 'default' => '', 'validation_type' => 'text'), 'location_id' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $lid)); //---------------------------------------------------------------------- // EDIT MODE // Validation Type: alpha|numeric|float|alpha_numeric|text|email // Validation Sub-Type: positive (for numeric and float) // Ex.: 'validation_type'=>'numeric', 'validation_type'=>'numeric|positive' //---------------------------------------------------------------------- $this->EDIT_MODE_SQL = 'SELECT ' . $this->tableName . '.' . $this->primaryKey . ', ' . $this->tableName . '.name FROM ' . $this->tableName . ' WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_'; // define edit mode fields $this->arrEditModeFields = array('name' => array('title' => _NAME, 'type' => 'textbox', 'width' => '240px', 'required' => true, 'readonly' => false, 'maxlength' => '50', 'default' => '', 'validation_type' => 'text'), 'location_id' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $lid)); //---------------------------------------------------------------------- // DETAILS MODE //---------------------------------------------------------------------- $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL; $this->arrDetailsModeFields = array('name' => array('title' => _NAME, 'type' => 'label')); }
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)); }
/** * 'After'-operation methods */ public function AfterInsertRecord() { // clone to other languages --- $total_languages = Languages::GetAllActive(); $language_id = MicroGrid::GetParameter('language_id'); $template_code = MicroGrid::GetParameter('template_code', false); $template_name = MicroGrid::GetParameter('template_name', false); $template_subject = MicroGrid::GetParameter('template_subject', false); $template_content = MicroGrid::GetParameter('template_content', false); $is_system_template = MicroGrid::GetParameter('is_system_template', false); for ($i = 0; $i < $total_languages[1]; $i++) { if ($language_id != '' && $total_languages[0][$i]['abbreviation'] != $language_id) { $sql = 'INSERT INTO ' . TABLE_EMAIL_TEMPLATES . ' ( id, language_id, template_code, template_name, template_subject, template_content, is_system_template ) VALUES ( NULL, \'' . encode_text($total_languages[0][$i]['abbreviation']) . '\', \'' . encode_text($template_code) . '\', \'' . encode_text($template_name) . '\', \'' . encode_text($template_subject) . '\', \'' . encode_text($template_content) . '\', ' . (int) $is_system_template . ' )'; database_void_query($sql); $this->SetSQLs('insert_lan_' . $total_languages[0][$i]['abbreviation'], $sql); } } }
function __construct() { parent::__construct(); $this->params = array(); ## for standard fields if (isset($_POST['name'])) { $this->params['name'] = prepare_input($_POST['name']); } if (isset($_POST['is_active'])) { $this->params['is_active'] = (int) $_POST['is_active']; } // $this->params['language_id'] = MicroGrid::GetParameter('language_id'); $this->primaryKey = 'id'; $this->tableName = TABLE_LISTINGS_LOCATIONS; $this->dataSet = array(); $this->error = ''; $this->formActionURL = 'index.php?admin=mod_listings_locations'; $this->actions = array('add' => true, '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 = ''; // WHERE .... / 'WHERE language_id = \''.$this->languageId.'\''; $this->ORDER_CLAUSE = 'ORDER BY name ASC'; // ORDER BY '.$this->tableName.'.date_created DESC $this->isAlterColorsAllowed = true; $this->isPagingAllowed = true; $this->pageSize = 30; $this->isSortingAllowed = true; $this->isFilteringAllowed = true; $arr_default_types = array('0' => _NO, '1' => _YES); $arr_activity_types = array('0' => _NO, '1' => _YES); // define filtering fields $this->arrFilteringFields = array(_NAME => array('table' => $this->tableName, 'field' => 'name', 'type' => 'text', 'sign' => 'like%', 'width' => '100px'), _ACTIVE => array('table' => $this->tableName, 'field' => 'is_active', 'type' => 'dropdownlist', 'source' => $arr_activity_types, 'sign' => '=', 'width' => '90px', 'visible' => true)); //---------------------------------------------------------------------- // VIEW MODE //---------------------------------------------------------------------- $this->VIEW_MODE_SQL = 'SELECT ' . $this->primaryKey . ', name, CONCAT("<a href=index.php?admin=mod_listings_sub_locations&lid=", ' . $this->tableName . '.' . $this->primaryKey . ', ">[ ", "' . _SUB_LOCATIONS . ' ]</a> (", (SELECT COUNT(*) FROM ' . TABLE_LISTINGS_SUB_LOCATIONS . ' sl WHERE sl.location_id = ' . $this->tableName . '.' . $this->primaryKey . '), ")") as link_sub_locations, IF(is_active, \'<span class=yes>' . _YES . '</span>\', \'<span class=no>' . _NO . '</span>\') as mod_is_active FROM ' . $this->tableName; // define view mode fields $this->arrViewModeFields = array('name' => array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '', 'height' => '', 'maxlength' => ''), 'mod_is_active' => array('title' => _ACTIVE, 'type' => 'label', 'align' => 'center', 'width' => '110px', 'height' => '', 'maxlength' => ''), 'link_sub_locations' => array('title' => '', 'type' => 'label', 'align' => 'left', 'width' => '160px', 'maxlength' => '', 'visible' => true)); //---------------------------------------------------------------------- // ADD MODE // Validation Type: alpha|numeric|float|alpha_numeric|text|email // Validation Sub-Type: positive (for numeric and float) // Ex.: 'validation_type'=>'numeric', 'validation_type'=>'numeric|positive' //---------------------------------------------------------------------- // define add mode fields $this->arrAddModeFields = array('name' => array('title' => _NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'readonly' => false, 'maxlength' => '50', 'default' => '', 'validation_type' => 'text'), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'required' => true, 'width' => '90px', 'readonly' => false, 'default' => '1', 'source' => $arr_activity_types, 'unique' => false, 'javascript_event' => '')); //---------------------------------------------------------------------- // EDIT MODE // Validation Type: alpha|numeric|float|alpha_numeric|text|email // Validation Sub-Type: positive (for numeric and float) // Ex.: 'validation_type'=>'numeric', 'validation_type'=>'numeric|positive' //---------------------------------------------------------------------- $this->EDIT_MODE_SQL = 'SELECT ' . $this->tableName . '.' . $this->primaryKey . ', ' . $this->tableName . '.name, ' . $this->tableName . '.is_active, IF(is_active, \'<span class=yes>' . _YES . '</span>\', \'<span class=no>' . _NO . '</span>\') as mod_is_active FROM ' . $this->tableName . ' WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_'; // define edit mode fields $this->arrEditModeFields = array('name' => array('title' => _NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'readonly' => false, 'maxlength' => '50', 'default' => '', 'validation_type' => 'text'), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'required' => true, 'width' => '90px', 'readonly' => false, 'default' => '1', 'source' => $arr_activity_types, 'unique' => false, 'javascript_event' => '')); //---------------------------------------------------------------------- // DETAILS MODE //---------------------------------------------------------------------- $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL; $this->arrDetailsModeFields = array('name' => array('title' => _NAME, 'type' => 'label'), 'mod_is_active' => array('title' => _ACTIVE, 'type' => 'label')); }
/** * Before-Deleting Record */ public function BeforeDeleteRecord() { $sql = 'SELECT COUNT(*) as cnt FROM ' . TABLE_CURRENCIES . ' WHERE is_active = 1'; if ($result = database_query($sql, DATA_ONLY, FIRST_ROW_ONLY)) { if ((int) $result['cnt'] > 1) { $rid = MicroGrid::GetParameter('rid'); $sql = 'SELECT is_default FROM ' . TABLE_CURRENCIES . ' WHERE id = ' . (int) $rid; if ($result = database_query($sql, DATA_ONLY, FIRST_ROW_ONLY)) { if ($result['is_default'] == '1') { $this->error = _DEFAULT_CURRENCY_DELETE_ALERT; return false; } } return true; } else { $this->error = _LAST_CURRENCY_ALERT; return false; } } return false; }
function __construct() { parent::__construct(); global $objSettings, $objLogin; $this->params = array(); ## for standard fields if (isset($_POST['name'])) { $this->params['name'] = prepare_input($_POST['name']); } if (isset($_POST['email'])) { $this->params['email'] = prepare_input($_POST['email']); } if (isset($_POST['phone'])) { $this->params['phone'] = prepare_input($_POST['phone']); } if (isset($_POST['availability'])) { $this->params['availability'] = prepare_input($_POST['availability']); } if (isset($_POST['preferred_contact'])) { $this->params['preferred_contact'] = prepare_input($_POST['preferred_contact']); } if (isset($_POST['description'])) { $this->params['description'] = prepare_input($_POST['description']); } if (isset($_POST['date_created'])) { $this->params['date_created'] = prepare_input($_POST['date_created']); } if (isset($_POST['replies_count'])) { $this->params['replies_count'] = prepare_input($_POST['replies_count']); } ## for checkboxes $this->params['is_active'] = isset($_POST['is_active']) ? prepare_input($_POST['is_active']) : '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_INQUIRIES; $this->dataSet = array(); $this->error = ''; $this->formActionURL = 'index.php?' . ($objLogin->IsLoggedInAsAdmin() ? 'admin=mod_inquiries_management' : 'customer=inquiries'); $this->actions = array('add' => false, 'edit' => $objLogin->IsLoggedInAs('owner') ? true : false, 'details' => true, 'delete' => $objLogin->IsLoggedInAs('owner') ? true : false); $this->actionIcons = true; $this->allowRefresh = true; $this->allowLanguages = false; $this->languageId = ''; $visible = $objLogin->IsLoggedInAsCustomer() ? false : true; if ($objLogin->IsLoggedInAsCustomer()) { $this->WHERE_CLAUSE = 'WHERE (( i.inquiry_type = 1 AND i.listing_id IN (SELECT l.id FROM ' . TABLE_LISTINGS . ' l WHERE l.customer_id = ' . (int) $objLogin->GetLoggedId() . ') ) OR ( i.inquiry_type = 0 AND i.id IN (SELECT ih.inquiry_id FROM ' . TABLE_INQUIRIES_HISTORY . ' ih WHERE ih.customer_id = ' . (int) $objLogin->GetLoggedId() . ') ))'; } else { $this->WHERE_CLAUSE = ''; } $this->ORDER_CLAUSE = 'ORDER BY i.date_created DESC'; $this->isAlterColorsAllowed = true; $this->isPagingAllowed = true; $this->pageSize = 20; $this->isSortingAllowed = true; $this->isFilteringAllowed = true; // define filtering fields $this->arrFilteringFields = array(_NAME => array('table' => 'i', 'field' => 'name', 'type' => 'text', 'sign' => 'like%', 'width' => '90px', 'visible' => true), _DATE_CREATED => array('table' => 'i', 'field' => 'date_created', 'type' => 'calendar', 'date_format' => $objSettings->GetParameter('date_format'), 'sign' => 'like%', 'width' => '85px', 'visible' => true)); 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')); $arr_is_active = array('0' => '<span class=no>' . _NO . '</span>', '1' => '<span class=yes>' . _YES . '</span>'); //$replies_count = $objLogin->IsLoggedInAsCustomer() ? 1 : ModulesSettings::Get('inquiries', 'maximum_replies'); //---------------------------------------------------------------------- // VIEW MODE // format: strip_tags //---------------------------------------------------------------------- $this->VIEW_MODE_SQL = 'SELECT i.' . $this->primaryKey . ', i.inquiry_type, i.name, i.email, i.phone, i.location_id, i.sub_location_id, i.availability, i.preferred_contact, i.description, i.is_active, DATE_FORMAT(i.date_created, \'' . $this->sqlFieldDatetimeFormat . '\') as date_created, i.replies_count,'; if ($objLogin->IsLoggedInAsCustomer()) { $this->VIEW_MODE_SQL .= 'IF( ( SELECT ir.id FROM ' . TABLE_INQUIRIES_REPLIES . ' ir INNER JOIN ' . TABLE_CUSTOMERS . ' c ON ir.customer_id = c.id WHERE ir.inquiry_id = i.id AND ir.customer_id = ' . (int) $objLogin->GetLoggedId() . ' LIMIT 0, 1 ) IS NULL, IF(i.is_active = 0, "' . _CLOSED . '", CONCAT("<a href=index.php?customer=inquiries_reply&inq_id=", i.' . $this->primaryKey . ', "&act=add>[ ' . _REPLY . ' ]</a>")), CONCAT("<a href=index.php?customer=inquiries_reply&inq_id=", i.' . $this->primaryKey . ', "> ' . _ANSWERED . ' </a>") ) as link_reply_customer, "" as link_reply_admin,'; } else { $this->VIEW_MODE_SQL .= ' "" as link_reply_customer, CONCAT("<a href=index.php?admin=mod_inquiries_reply&inq_id=", i.' . $this->primaryKey . ', ">", IF((i.is_active = 1), "[ ' . _ACTIVE . ' ]", "' . _CLOSED . '"), "</a> (", i.replies_count, ")") as link_reply_admin, '; } $this->VIEW_MODE_SQL .= 'CONCAT(ll.name, " / ", lsl.name) as location_name, lcd.name as category_name FROM ' . $this->tableName . ' i LEFT OUTER JOIN ' . TABLE_CATEGORIES_DESCRIPTION . ' lcd ON i.category_id = lcd.category_id AND lcd.language_id = \'' . Application::Get('lang') . '\' LEFT OUTER JOIN ' . TABLE_LISTINGS_LOCATIONS . ' ll ON i.location_id = ll.id LEFT OUTER JOIN ' . TABLE_LISTINGS_SUB_LOCATIONS . ' lsl ON i.sub_location_id = lsl.id '; // define view mode fields $this->arrViewModeFields = array('name' => array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '160px', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'maxlength' => ''), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'link', 'href' => 'mailto:{email}', 'align' => 'left', 'width' => '', 'maxlength' => '36', 'visible' => $visible), 'category_name' => array('title' => _CATEGORY, 'align' => 'left', 'width' => '110px', 'sortable' => true, 'nowrap' => 'nowrap', 'visible' => '', 'maxlength' => ''), 'location_name' => array('title' => _LOCATION, 'align' => 'left', 'width' => '130px', 'sortable' => true, 'nowrap' => 'nowrap', 'visible' => '', 'maxlength' => ''), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label', 'align' => 'left', 'width' => '120px', 'sortable' => true, 'nowrap' => 'nowrap', 'visible' => '', 'height' => '', 'maxlength' => ''), 'inquiry_type' => array('title' => _TYPE, 'type' => 'enum', 'align' => 'center', 'width' => '70px', 'source' => self::$arr_inquiry_types, 'visible' => true), 'link_reply_customer' => array('title' => _REPLIES, 'type' => 'label', 'align' => 'center', 'width' => '65px', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'maxlength' => '', 'visible' => $objLogin->IsLoggedInAsCustomer()), 'link_reply_admin' => array('title' => _REPLIES, 'type' => 'label', 'align' => 'center', 'width' => '65px', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'maxlength' => '', 'visible' => $objLogin->IsLoggedInAsAdmin()), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'align' => 'center', 'width' => '70px', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'source' => $arr_is_active)); //---------------------------------------------------------------------- // 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 i.inquiry_type, i.category_id, cd.name as category_name, i.listing_id, ld.business_name as listing_name, i.name, i.email, i.phone, i.availability, i.preferred_contact, i.description, DATE_FORMAT(i.date_created, \'' . $this->sqlFieldDatetimeFormat . '\') as date_created, i.replies_count, i.is_active, ll.name as location_name, lsl.name as sub_location_name FROM ' . $this->tableName . ' i LEFT OUTER JOIN ' . TABLE_CATEGORIES_DESCRIPTION . ' cd ON i.category_id = cd.category_id AND cd.language_id = \'' . Application::Get('lang') . '\' LEFT OUTER JOIN ' . TABLE_LISTINGS_DESCRIPTION . ' ld ON i.listing_id = ld.listing_id AND ld.language_id = \'' . Application::Get('lang') . '\' LEFT OUTER JOIN ' . TABLE_LISTINGS_LOCATIONS . ' ll ON i.location_id = ll.id LEFT OUTER JOIN ' . TABLE_LISTINGS_SUB_LOCATIONS . ' lsl ON i.sub_location_id = lsl.id WHERE i.' . $this->primaryKey . ' = _RID_'; // define edit mode fields $this->arrEditModeFields = array('separator_contact_information' => array('separator_info' => array('legend' => _CONTACT_INFORMATION, 'columns' => '0'), 'name' => array('title' => _NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'readonly' => false, 'maxlength' => '50', 'default' => '', 'validation_type' => '', 'unique' => false, 'visible' => true), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'readonly' => false, 'maxlength' => '70', 'default' => '', 'validation_type' => '', 'unique' => false, 'visible' => $visible), 'phone' => array('title' => _PHONE, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'readonly' => false, 'maxlength' => '20', 'default' => '', 'validation_type' => '', 'unique' => false, 'visible' => true), 'location_name' => array('title' => _LOCATION, 'type' => 'label'), 'sub_location_name' => array('title' => _SUB_LOCATION, 'type' => 'label'), 'availability' => array('title' => _I_AM_AVAILABLE, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => false, 'default' => '', 'source' => self::$arr_availabilities, 'default_option' => '', 'unique' => false, 'javascript_event' => '', 'view_type' => 'dropdownlist', 'multi_select' => false), 'preferred_contact' => array('title' => _PREFERRED_TO_BE_CONTACTED, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => false, 'default' => '', 'source' => self::$arr_preferred_contacts, 'default_option' => '', 'unique' => false, 'javascript_event' => '', 'view_type' => 'dropdownlist', 'multi_select' => false)), 'separator_inquiry_details' => array('separator_info' => array('legend' => _INQUIRY_DETAILS, 'columns' => '0'), 'description' => array('title' => _DESCRIPTION, 'type' => 'textarea', 'width' => '410px', 'required' => false, 'readonly' => false, 'maxlength' => '2048', 'default' => '', 'height' => '90px', 'editor_type' => 'simple|wysiwyg', 'validation_type' => '', 'validation_maxlength' => '2048', 'unique' => false), 'inquiry_type' => array('title' => _TYPE, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => true, 'default' => '', 'source' => self::$arr_inquiry_types, 'default_option' => '', 'unique' => false, 'javascript_event' => '', 'view_type' => 'dropdownlist', 'multi_select' => false), 'category_name' => array('title' => _CATEGORY, 'type' => 'label'), 'listing_name' => array('title' => _LISTING, 'type' => 'label'), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label'), 'replies_count' => array('title' => _REPLIES, 'type' => 'label'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0', 'unique' => false))); //---------------------------------------------------------------------- // DETAILS MODE //---------------------------------------------------------------------- $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL; $this->arrDetailsModeFields = array('separator_contact_information' => array('separator_info' => array('legend' => _CONTACT_INFORMATION, 'columns' => '0'), 'name' => array('title' => _NAME, 'type' => 'label'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'label', 'visible' => $visible), 'phone' => array('title' => _PHONE, 'type' => 'label', 'visible' => $visible), 'location_name' => array('title' => _LOCATION, 'type' => 'label'), 'sub_location_name' => array('title' => _SUB_LOCATION, 'type' => 'label'), 'availability' => array('title' => _I_AM_AVAILABLE, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => false, 'default' => '', 'source' => self::$arr_availabilities, 'default_option' => '', 'unique' => false, 'javascript_event' => '', 'view_type' => 'dropdownlist', 'multi_select' => false), 'preferred_contact' => array('title' => _PREFERRED_TO_BE_CONTACTED, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => false, 'default' => '', 'source' => self::$arr_preferred_contacts, 'default_option' => '', 'unique' => false, 'javascript_event' => '', 'view_type' => 'dropdownlist', 'multi_select' => false)), 'separator_inquiry_details' => array('separator_info' => array('legend' => _INQUIRY_DETAILS, 'columns' => '0'), 'description' => array('title' => _DESCRIPTION, 'type' => 'html'), 'inquiry_type' => array('title' => _TYPE, 'type' => 'enum', 'source' => self::$arr_inquiry_types, 'visible' => $visible), 'category_name' => array('title' => _CATEGORY, 'type' => 'label', 'visible' => $visible), 'listing_name' => array('title' => _LISTING, 'type' => 'label', 'visible' => $visible), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label'), 'replies_count' => array('title' => _REPLIES, 'type' => 'label', 'visible' => $visible), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'source' => $arr_is_active))); }
function __construct() { parent::__construct(); $cid = isset($_GET['cid']) ? (int) $_GET['cid'] : '0'; $cdid = isset($_GET['cdid']) ? (int) $_GET['cdid'] : '0'; $this->params = array(); if (isset($_POST['name'])) { $this->params['name'] = prepare_input($_POST['name']); } if (isset($_POST['description'])) { $this->params['description'] = prepare_input($_POST['description']); } //$default_lang = Languages::GetDefaultLang(); // for checkboxes /// if(isset($_POST['parameter4'])) $this->params['parameter4'] = $_POST['parameter4']; else $this->params['parameter4'] = '0'; //$this->params['language_id'] = MicroGrid::GetParameter('language_id'); $this->primaryKey = 'id'; $this->tableName = TABLE_CATEGORIES_DESCRIPTION; $this->dataSet = array(); $this->error = ''; $this->formActionURL = 'index.php?admin=mod_categories_description&cid=' . (int) $cid . '&cdid=' . (int) $cdid; $this->actions = array('add' => false, 'edit' => true, 'details' => true, 'delete' => false); $this->actionIcons = true; $this->allowRefresh = true; $this->isHtmlEncoding = true; $this->allowLanguages = false; $this->languageId = ''; //($this->params['language_id'] != '') ? $this->params['language_id'] : Languages::GetDefaultLang(); $this->WHERE_CLAUSE = 'WHERE ' . $this->tableName . '.category_id = \'' . $cdid . '\''; $this->ORDER_CLAUSE = 'ORDER BY ' . $this->tableName . '.id ASC'; $this->isAlterColorsAllowed = true; $this->isPagingAllowed = false; $this->pageSize = 100; $this->isSortingAllowed = true; $this->isFilteringAllowed = false; // define filtering fields $this->arrFilteringFields = array('price' => array('title' => _CATEGORY, 'type' => 'text', 'sign' => 'like%', 'width' => '80px')); // prepare languages array //$total_languages = Languages::GetAllActive(); //$arr_languages = array(); //foreach($total_languages[0] as $key => $val){ // $arr_languages[$val['abbreviation']] = $val['lang_name']; //} //---------------------------------------------------------------------- // VIEW MODE //---------------------------------------------------------------------- $this->VIEW_MODE_SQL = 'SELECT ' . $this->tableName . '.' . $this->primaryKey . ', ' . $this->tableName . '.category_id, ' . $this->tableName . '.language_id, ' . $this->tableName . '.name, ' . $this->tableName . '.description, ' . TABLE_LANGUAGES . '.lang_name FROM ' . $this->tableName . ' INNER JOIN ' . TABLE_CATEGORIES . ' ON ' . $this->tableName . '.category_id = ' . TABLE_CATEGORIES . '.id INNER JOIN ' . TABLE_LANGUAGES . ' ON ' . $this->tableName . '.language_id = ' . TABLE_LANGUAGES . '.abbreviation AND ' . TABLE_LANGUAGES . '.is_active = 1 '; // define view mode fields $this->arrViewModeFields = array('name' => array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '200px', 'maxlength' => ''), 'description' => array('title' => _DESCRIPTION, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '50'), 'lang_name' => array('title' => _LANGUAGE, 'type' => 'label', 'align' => 'center', 'width' => '120px', 'maxlength' => '')); //---------------------------------------------------------------------- // ADD MODE //---------------------------------------------------------------------- // define add mode fields $this->arrAddModeFields = array(); //---------------------------------------------------------------------- // EDIT MODE //---------------------------------------------------------------------- $this->EDIT_MODE_SQL = 'SELECT ' . $this->tableName . '.' . $this->primaryKey . ', ' . $this->tableName . '.category_id, ' . $this->tableName . '.language_id, ' . $this->tableName . '.name, ' . $this->tableName . '.description, ' . TABLE_LANGUAGES . '.lang_name FROM ' . $this->tableName . ' INNER JOIN ' . TABLE_CATEGORIES . ' ON ' . $this->tableName . '.category_id = ' . TABLE_CATEGORIES . '.id INNER JOIN ' . TABLE_LANGUAGES . ' ON ' . $this->tableName . '.language_id = ' . TABLE_LANGUAGES . '.abbreviation AND ' . TABLE_LANGUAGES . '.is_active = 1 WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_'; // define edit mode fields $this->arrEditModeFields = array('lang_name' => array('title' => _LANGUAGE, 'type' => 'label'), 'name' => array('title' => _NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'readonly' => false, 'default' => '', 'validation_type' => 'text', 'maxlength' => '50'), 'description' => array('title' => _DESCRIPTION, 'type' => 'textarea', 'width' => '400px', 'height' => '100px', 'required' => false, 'readonly' => false, 'default' => '', 'validation_type' => 'text', 'validation_maxlength' => '255')); //---------------------------------------------------------------------- // DETAILS MODE //---------------------------------------------------------------------- $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL; $this->arrDetailsModeFields = array('lang_name' => array('title' => _LANGUAGE, 'type' => 'label'), 'name' => array('title' => _NAME, 'type' => 'label'), 'description' => array('title' => _DESCRIPTION, 'type' => 'label')); }
<?php /** * @project ApPHP Business Directory * @copyright (c) 2011 ApPHP * @author ApPHP <*****@*****.**> * @license http://www.gnu.org/licenses/ */ // *** Make sure the file isn't accessed directly defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- if ($objLogin->IsLoggedInAs('owner')) { $action = MicroGrid::GetParameter('action'); $rid = MicroGrid::GetParameter('rid'); $role_id = MicroGrid::GetParameter('role_id', false); $mode = 'view'; $msg = ''; $objRoles = new Roles(); $role_info = $objRoles->GetInfoByID($role_id); $role_info_name = isset($role_info['name']) ? $role_info['name'] : ''; if (count($role_info) > 0) { $objRolePrivileges = new RolePrivileges($role_id); if ($action == 'add') { $mode = 'add'; } else { if ($action == 'create') { if ($objRolePrivileges->AddRecord()) { $msg = draw_success_message(_ADDING_OPERATION_COMPLETED, false); $mode = 'view'; } else { $msg = draw_important_message($objRolePrivileges->error, false);
<?php /** * @project ApPHP Business Directory * @copyright (c) 2011 ApPHP * @author ApPHP <*****@*****.**> * @license http://www.gnu.org/licenses/ */ // *** Make sure the file isn't accessed directly defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- if ($objLogin->IsLoggedInAs('owner', 'mainadmin') && Modules::IsModuleInstalled('gallery')) { $action = MicroGrid::GetParameter('action'); $rid = MicroGrid::GetParameter('rid'); $mode = 'view'; $msg = ''; $objGallery = new ModulesSettings('gallery'); if ($action == 'add') { $mode = 'add'; } else { if ($action == 'create') { if ($objGallery->AddRecord()) { $msg = draw_success_message(_ADDING_OPERATION_COMPLETED, false); $mode = 'view'; } else { $msg = draw_important_message($objGallery->error, false); $mode = 'add'; } } else { if ($action == 'edit') { $mode = 'edit';
/** * Before-Deleting record */ public function BeforeDeleteRecord() { // update products count field $oid = MicroGrid::GetParameter('rid'); $sql = 'SELECT order_number, status, customer_id, advertise_plan_id, listings_amount FROM ' . TABLE_ORDERS . ' WHERE id = ' . (int) $oid; $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY, FETCH_ASSOC); if ($result[1] > 0) { $this->order_number = $result[0]['order_number']; $this->order_status = $result[0]['status']; $this->order_customer_id = $result[0]['customer_id']; $this->order_listings = $result[0]['listings_amount']; $this->order_advertise_plan_id = $result[0]['advertise_plan_id']; return true; } return false; }