} } } if (Modules::IsModuleInstalled('payments') && ModulesSettings::Get('payments', 'is_active') == 'yes') { draw_title_bar(prepare_breadcrumbs(array(_MY_ACCOUNT => '', _ADVERTISE => '', $title_desc => '')), prepare_permanent_link('index.php?customer=advertise', _BUTTON_BACK)); // test mode alert if (ModulesSettings::Get('payments', 'mode') == 'TEST MODE') { draw_message(_TEST_MODE_ALERT_SHORT, true, true); } if ($task == "do_order") { if (AdvertisePlans::DoOrder($payment_type)) { AdvertisePlans::DrawPrepayment(); } else { draw_important_message(AdvertisePlans::$message); } } else { if ($task == "repeat_order") { draw_important_message($msg_text); AdvertisePlans::ReDrawPrepayment(); } else { draw_important_message(_WRONG_PARAMETER_PASSED); } } } else { draw_title_bar(_CUSTOMER); draw_important_message(_NOT_AUTHORIZED); } } else { draw_title_bar(_CUSTOMER); draw_important_message(_NOT_AUTHORIZED); }
/** * @project ApPHP Business Directory * @copyright (c) 2011 ApPHP * @author ApPHP <*****@*****.**> * @license http://www.gnu.org/licenses/ */ // *** Make sure the file isn't accessed directly defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- if ($objLogin->IsLoggedInAs('owner', 'mainadmin') && Modules::IsModuleInstalled('listings')) { $action = MicroGrid::GetParameter('action'); $rid = MicroGrid::GetParameter('rid'); $mode = 'view'; $msg = ''; $objAdvertisePlans = new AdvertisePlans(); if ($action == 'add') { $mode = 'add'; } else { if ($action == 'create') { if ($objAdvertisePlans->AddRecord()) { $msg = draw_success_message(_ADDING_OPERATION_COMPLETED, false); $mode = 'view'; } else { $msg = draw_important_message($objAdvertisePlans->error, false); $mode = 'add'; } } else { if ($action == 'edit') { $mode = 'edit'; } else {
/** * After-Updating - update listing descriptions to description table */ public function AfterUpdateRecord() { global $objLogin, $objSettings; // update translations foreach ($this->arrTranslations as $key => $val) { $sql = 'UPDATE ' . TABLE_LISTINGS_DESCRIPTION . ' SET business_name = \'' . encode_text(prepare_input($val['business_name'])) . '\', business_address = \'' . encode_text(prepare_input($val['business_address'])) . '\', business_description = \'' . encode_text(prepare_input($val['business_description'])) . '\' WHERE listing_id = ' . (int) $this->curRecordId . ' AND language_id = \'' . $key . '\''; database_void_query($sql); } // retrieve pre-moderation settings if ($objLogin->IsLoggedInAsCustomer() && ModulesSettings::Get('listings', 'pre_moderation_allow') == 'yes') { // check if we have to put listing on moderation $sql = 'SELECT * FROM ' . TABLE_LISTINGS_DESCRIPTION . ' WHERE listing_id = ' . (int) $this->curRecordId; $result = database_query($sql, DATA_AND_ROWS, ALL_ROWS); $langs_count = count($this->arrTranslations); for ($i = 0; $i < $langs_count; $i++) { $result_diff = array_diff_assoc($this->listing_info[0][$i], $result[0][$i]); if (count($result_diff) > 0) { $sql = 'UPDATE ' . TABLE_LISTINGS . ' SET is_published = 0 WHERE id = ' . (int) $this->curRecordId; if (!database_void_query($sql)) { /* echo 'error!'; */ } $this->error = _UPDATED_FOR_MODERATION; return false; } } } $access_level = MicroGrid::GetParameter('access_level', false); $advertise_plan_id = MicroGrid::GetParameter('advertise_plan_id', false); // update listings count and date of publishing if ($objLogin->IsLoggedInAsAdmin()) { $customer_id = (int) MicroGrid::GetParameter('customer_id', false); $is_published = (bool) MicroGrid::GetParameter('is_published', false); $is_published_value = ''; $recalculate_listings = false; if (!$this->is_published && $is_published) { $is_published_value = date('Y-m-d H:i:s'); $recalculate_listings = true; } else { if ($this->is_published && !$is_published) { $is_published_value = '0000-00-00 00:00:00'; $recalculate_listings = true; } else { if ($this->accessLevel == 'registered' && $access_level == 'public') { $recalculate_listings = true; } else { if ($this->accessLevel == 'public' && $access_level == 'registered') { $recalculate_listings = true; } } } } if ($recalculate_listings) { // update listings count in categories Categories::RecalculateListingsCount(); } // update finish publishing date $advertise_plan_info = AdvertisePlans::GetPlanInfo($advertise_plan_id); if ($this->advertisePlanID != $advertise_plan_id && $advertise_plan_info[1] > 0) { $duration = $advertise_plan_info[0]['duration']; $finish_publishing = $duration == '-1' ? '0000-00-00 00:00:00' : date('Y-m-d H:i:s', strtotime('+' . (int) $duration . ' day')); $sql = 'UPDATE ' . TABLE_LISTINGS . ' SET finish_publishing = \'' . $finish_publishing . '\' WHERE id = ' . (int) $this->curRecordId; if (!database_void_query($sql)) { /* echo 'error!'; */ } } if ($is_published_value != '') { $sql = 'UPDATE ' . TABLE_LISTINGS . ' SET date_published = \'' . $is_published_value . '\' ' . ($this->isApproved == '0' && $is_published_value != '0000-00-00 00:00:00' ? ', is_approved=1' : '') . ' WHERE id = ' . (int) $this->curRecordId; if (!database_void_query($sql)) { /* echo 'error!'; */ } if ($this->isApproved == '0' && $is_published_value != '0000-00-00 00:00:00') { //////////////////////////////////////////////////////////// $customer_info = Customers::GetCustomerInfo($customer_id); $email = isset($customer_info['email']) ? $customer_info['email'] : ''; $last_name = isset($customer_info['last_name']) ? $customer_info['last_name'] : ''; $first_name = isset($customer_info['first_name']) ? $customer_info['first_name'] : ''; $preferred_language = isset($customer_info['preferred_language']) ? $customer_info['preferred_language'] : ''; $business_name = MicroGrid::GetParameter('business_name_' . $preferred_language, false); $sender = $objSettings->GetParameter('admin_email'); $recipiant = $email; $listing_details = _NAME . ': ' . $business_name . ' <br>'; $listing_details .= _LINK . ': ' . APPHP_BASE . 'index.php?page=listing&lid=' . (int) $this->curRecordId . ' <br>'; send_email($recipiant, $sender, 'listing_approved_by_admin', array('{FIRST NAME}' => $first_name, '{LAST NAME}' => $last_name, '{LISTING DETAILS}' => $listing_details, '{WEB SITE}' => $_SERVER['SERVER_NAME']), $preferred_language); //////////////////////////////////////////////////////////// } } } }
/** * Sends order mail * @param $order_number * @param $order_type * @param $customer_id */ public static function SendOrderEmail($order_number, $order_type = 'accepted', $customer_id = '') { global $objSettings; $currencyFormat = get_currency_format(); $order_details = ''; // send email to customer $sql = 'SELECT o.*, CASE WHEN o.payment_type = 0 THEN "' . _ONLINE_ORDER . '" WHEN o.payment_type = 1 THEN "' . _PAYPAL . '" WHEN o.payment_type = 2 THEN "2CO" WHEN o.payment_type = 3 THEN "Authorize.Net" ELSE "' . _UNKNOWN . '" END as m_payment_type, CASE WHEN o.payment_method = 0 THEN "' . _PAYMENT_COMPANY_ACCOUNT . '" WHEN o.payment_method = 1 THEN "' . _CREDIT_CARD . '" WHEN o.payment_method = 2 THEN "E-Check" ELSE "' . _UNKNOWN . '" END as m_payment_method, CASE WHEN o.status = 0 THEN "<span style=color:#960000>' . _PREPARING . '</span>" WHEN o.status = 1 THEN "<span style=color:#FF9966>' . _PENDING . '</span>" WHEN o.status = 2 THEN "<span style=color:#336699>' . _PAID . '</span>" WHEN o.status = 3 THEN "<span style=color:#009600>' . _COMPLETED . '</span>" WHEN o.status = 4 THEN "<span style=color:#969600>' . _REFUNDED . '</span>" ELSE "' . _UNKNOWN . '" END as m_status, c.first_name, c.last_name, c.user_name as customer_name, c.preferred_language, c.email, c.b_address, c.b_address_2, c.b_city, c.b_state, count.name as b_country, c.b_zipcode, c.phone, c.fax, cur.symbol, cur.symbol_placement FROM ' . TABLE_ORDERS . ' o LEFT OUTER JOIN ' . TABLE_CURRENCIES . ' cur ON o.currency = cur.code LEFT OUTER JOIN ' . TABLE_CUSTOMERS . ' c ON o.customer_id = c.id LEFT OUTER JOIN ' . TABLE_COUNTRIES . ' count ON c.b_country = count.abbrv WHERE o.customer_id = ' . (int) $customer_id . ' AND o.order_number = "' . $order_number . '"'; $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY); if ($result[1] > 0) { $plan_info = AdvertisePlans::GetPlanInfo($result[0]['advertise_plan_id']); if (ModulesSettings::Get('payments', 'mode') == 'TEST MODE') { $order_details .= '<div style="text-align:center;padding:10px;color:#a60000;border:1px dashed #a60000;width:100px">TEST MODE!</div><br />'; } // Personal Info $order_details .= '<b>' . _PERSONAL_INFORMATION . ':</b><br />'; $order_details .= _FIRST_NAME . ' : ' . $result[0]['first_name'] . '<br />'; $order_details .= _LAST_NAME . ' : ' . $result[0]['last_name'] . '<br />'; $order_details .= _EMAIL_ADDRESS . ' : ' . $result[0]['email'] . '<br />'; $order_details .= '<br />'; // Billing Info $order_details .= '<b>' . _BILLING_INFORMATION . ':</b><br />'; $order_details .= _ADDRESS . ': ' . $result[0]['b_address'] . '<br />'; $order_details .= _ADDRESS_2 . ': ' . $result[0]['b_address_2'] . '<br />'; $order_details .= _CITY . ': ' . $result[0]['b_city'] . '<br />'; $order_details .= _STATE_PROVINCE . ': ' . $result[0]['b_state'] . '<br />'; $order_details .= _COUNTRY . ': ' . $result[0]['b_country'] . '<br />'; $order_details .= _ZIP_CODE . ': ' . $result[0]['b_zipcode'] . '<br />'; if (!empty($result[0]['phone'])) { $order_details .= _PHONE . ' : ' . $result[0]['phone'] . '<br />'; } if (!empty($result[0]['fax'])) { $order_details .= _FAX . ' : ' . $result[0]['fax'] . '<br />'; } $order_details .= '<br />'; // Order Details $order_details .= '<b>' . _ORDER_DETAILS . ':</b><br />'; $order_details .= _ORDER_DESCRIPTION . ': ' . $result[0]['order_description'] . '<br />'; $order_details .= _ADVERTISE_PLAN . ': ' . (isset($plan_info[0]['plan_name']) ? $plan_info[0]['plan_name'] : '') . '<br />'; $order_details .= _LISTINGS_COUNT . ': ' . $result[0]['listings_amount'] . '<br />'; $order_details .= _CURRENCY . ': ' . $result[0]['currency'] . '<br />'; $order_details .= _CREATED_DATE . ': ' . format_datetime($result[0]['created_date']) . '<br />'; $order_details .= _PAYMENT_DATE . ': ' . format_datetime($result[0]['payment_date']) . '<br />'; $order_details .= _PAYMENT_TYPE . ': ' . $result[0]['m_payment_type'] . '<br />'; $order_details .= _PAYMENT_METHOD . ': ' . $result[0]['m_payment_method'] . '<br />'; //$order_details .= (($result[0]['campaign_name'] != '') ? _DISCOUNT_CAMPAIGN.': '.$result[0]['campaign_name'].' ('.$result[0]['discount_percent'].'%)' : '').'<br />'; $order_details .= _ORDER_PRICE . ': ' . Currencies::PriceFormat($result[0]['order_price'], $result[0]['symbol'], $result[0]['symbol_placement'], $currencyFormat) . '<br />'; $order_details .= _VAT . ': ' . Currencies::PriceFormat($result[0]['vat_fee'], $result[0]['symbol'], $result[0]['symbol_placement'], $currencyFormat) . ' (' . $result[0]['vat_percent'] . '%)' . '<br />'; $order_details .= _TOTAL_PRICE . ': ' . Currencies::PriceFormat($result[0]['total_price'], $result[0]['symbol'], $result[0]['symbol_placement'], $currencyFormat) . '<br />'; //$order_details .= _ADDITIONAL_INFO.': '.nl2br($result[0]['additional_info']).'<br /><br />'; $send_order_copy_to_admin = ModulesSettings::Get('payments', 'send_order_copy_to_admin'); //////////////////////////////////////////////////////////// $sender = $objSettings->GetParameter('admin_email'); $recipient = $result[0]['email']; if ($order_type == 'completed') { // exit if email was already sent if ($result[0]['email_sent'] == '1') { return true; } $email_template = 'order_paid'; $admin_copy_subject = 'Client order has been paid (admin copy)'; } else { $email_template = 'order_accepted_online'; $admin_copy_subject = 'Client has placed online order (admin copy)'; } //////////////////////////////////////////////////////////// send_email($recipient, $sender, $email_template, array('{FIRST NAME}' => $result[0]['first_name'], '{LAST NAME}' => $result[0]['last_name'], '{ORDER NUMBER}' => $order_number, '{ORDER DETAILS}' => $order_details), $result[0]['preferred_language'], $send_order_copy_to_admin == 'yes' ? $sender : '', $send_order_copy_to_admin == 'yes' ? $admin_copy_subject : ''); //////////////////////////////////////////////////////////// if ($order_type == 'completed') { $sql = 'UPDATE ' . TABLE_ORDERS . ' SET email_sent = 1 WHERE order_number = \'' . $order_number . '\''; database_void_query($sql); } //////////////////////////////////////////////////////////// return true; } else { ///echo $sql; ///echo mysql_error(); } return false; }
/** * Place order * @param $order_number * @param $cc_params */ public static function PlaceOrder($order_number, $cc_params = array()) { global $objLogin; if (SITE_MODE == 'demo') { self::$message = draw_important_message(_OPERATION_BLOCKED, false); return false; } $sql = 'SELECT id, order_number FROM ' . TABLE_ORDERS . ' WHERE order_number = \'' . $order_number . '\' AND 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 = 'UPDATE ' . TABLE_ORDERS . ' SET created_date = \'' . date('Y-m-d H:i:s') . '\', status_changed = \'' . date('Y-m-d H:i:s') . '\', cc_type = \'' . $cc_params['cc_type'] . '\', cc_holder_name = \'' . $cc_params['cc_holder_name'] . '\', cc_number = AES_ENCRYPT(\'' . $cc_params['cc_number'] . '\', \'' . PASSWORDS_ENCRYPT_KEY . '\'), cc_expires_month = \'' . $cc_params['cc_expires_month'] . '\', cc_expires_year = \'' . $cc_params['cc_expires_year'] . '\', cc_cvv_code = \'' . $cc_params['cc_cvv_code'] . '\', status = \'1\' WHERE order_number = \'' . $order_number . '\''; database_void_query($sql); if (Orders::SendOrderEmail($order_number, 'accepted', $objLogin->GetLoggedID())) { // OK } else { //$this->message = draw_success_message(_ORDER_SEND_MAIL_ERROR, false); } return true; } else { self::$message = _ORDER_ERROR; return false; } }
/** * Returns lisitngs of all plans for specific customer * @param $customer_id */ public static function GetListingsForCustomer($customer_id = 0) { $result = array(); $result_listings = array(); $result_plans = array(); $result_temp = AdvertisePlans::GetAllPlans(); for ($i = 0; $i < $result_temp[1]; $i++) { $result_plans[$result_temp[0][$i]['id']] = $result_temp[0][$i]['plan_name']; } $sql = 'SELECT plan1_listings, plan2_listings, plan3_listings, plan4_listings FROM ' . TABLE_CUSTOMERS . ' WHERE id = ' . (int) $customer_id; $result_listings = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY); if ($result_listings[1] > 0) { if ($result_listings[0]['plan1_listings'] > 0) { $result[0] = array('id' => '1', 'count' => $result_listings[0]['plan1_listings'], 'name' => isset($result_plans['1']) ? $result_plans['1'] : ''); } if ($result_listings[0]['plan2_listings'] > 0) { $result[1] = array('id' => '2', 'count' => $result_listings[0]['plan2_listings'], 'name' => isset($result_plans['2']) ? $result_plans['2'] : ''); } if ($result_listings[0]['plan3_listings'] > 0) { $result[2] = array('id' => '3', 'count' => $result_listings[0]['plan3_listings'], 'name' => isset($result_plans['3']) ? $result_plans['3'] : ''); } if ($result_listings[0]['plan4_listings'] > 0) { $result[3] = array('id' => '4', 'count' => $result_listings[0]['plan4_listings'], 'name' => isset($result_plans['4']) ? $result_plans['4'] : ''); } } return $result; }
public function BeforeInsertRecord() { // check if we reached the maximum allowed categories $arr_added_categories = self::GetCategoriesForListing($this->listingId); // get maximum allowed categories for current listing $objListing = Listings::Instance($this->listingId); $adv = AdvertisePlans::GetPlanInfo($objListing->GetField('advertise_plan_id')); $maximum_categories = isset($adv[0]['categories_count']) ? (int) $adv[0]['categories_count'] : ModulesSettings::Get('listings', 'maximum_categories'); if ($arr_added_categories[1] >= $maximum_categories) { $this->error = _LISTING_MAX_CATEGORIES_ALERT; return false; } 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('listings')) { if (Modules::IsModuleInstalled('payments') && ModulesSettings::Get('payments', 'is_active') == 'yes') { draw_title_bar(prepare_breadcrumbs(array(_MY_ACCOUNT => '', _ADVERTISE => ''))); AdvertisePlans::DrawPlans(); } else { draw_title_bar(_CUSTOMER); draw_important_message(_NOT_AUTHORIZED); } } else { draw_title_bar(_CUSTOMER); draw_important_message(_NOT_AUTHORIZED); }
$registration_code = ''; $is_active = '1'; } } if (!PASSWORDS_ENCRYPTION) { $user_password = '******'' . encode_text($user_password1) . '\''; } else { if (strtolower(PASSWORDS_ENCRYPTION_TYPE) == 'aes') { $user_password = '******'' . encode_text($user_password1) . '\', \'' . PASSWORDS_ENCRYPT_KEY . '\')'; } else { if (strtolower(PASSWORDS_ENCRYPTION_TYPE) == 'md5') { $user_password = '******'' . encode_text($user_password1) . '\')'; } } } $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; // insert new user $sql = 'INSERT INTO ' . TABLE_CUSTOMERS . '( first_name, last_name, birth_date, company, b_address, b_address_2, b_city, b_zipcode, b_country, b_state, phone,
$order_number = isset($_POST['order_number']) ? prepare_input($_POST['order_number']) : ''; if ($payment_method == 'paypal') { $title_desc = _PAYPAL_ORDER; } else { if ($payment_method == '2co') { $title_desc = _2CO_ORDER; } else { if ($payment_method == 'authorize') { $title_desc = _AUTHORIZE_NET_ORDER; } else { $title_desc = _ONLINE_ORDER; } } } draw_title_bar(prepare_breadcrumbs(array(_MY_ACCOUNT => '', _CHECKOUT => '', $title_desc => '')), prepare_permanent_link('index.php?customer=advertise', _BUTTON_BACK)); // test mode alert if (ModulesSettings::Get('payments', 'mode') == 'TEST MODE') { draw_message(_TEST_MODE_ALERT_SHORT, true, true); } if ($task == "place_order") { if (AdvertisePlans::PlaceOrder($order_number, $cc_params)) { draw_success_message(_ORDER_PLACED_MSG); } else { draw_important_message(AdvertisePlans::$message); } } else { draw_important_message(_WRONG_PARAMETER_PASSED); } } else { draw_important_message(_NOT_AUTHORIZED); }
if ($params['visitor_phone'] == '') { $msg = draw_important_message(str_replace('_FIELD_', '<b>' . _PHONE . '</b>', _FIELD_CANNOT_BE_EMPTY), false); $params['focus_field'] = 'visitor_phone'; } else { if ($params['visitor_locations'] == '') { $msg = draw_important_message(str_replace('_FIELD_', '<b>' . _LOCATION . '</b>', _FIELD_CANNOT_BE_EMPTY), false); $params['focus_field'] = 'visitor_locations'; } else { if ($params['visitor_sub_locations'] == '') { $msg = draw_important_message(str_replace('_FIELD_', '<b>' . _SUB_LOCATION . '</b>', _FIELD_CANNOT_BE_EMPTY), false); $params['focus_field'] = 'visitor_sub_locations'; } else { // direct inquiry if ($params['inquiry_type'] == '1') { $objListing = Listings::Instance($params['listing_id']); $plan_info = AdvertisePlans::GetPlanInfo($objListing->GetField('advertise_plan_id')); if ($plan_info[0]['inquiry_button'] != '1') { $msg = draw_important_message(_DIRECT_INQUIRY_NOT_ALLOWED, false); } if ($objListing->GetField('customer_id') == $objLogin->GetLoggedID()) { $msg = draw_important_message(_INQUIRY_TO_YOURSELF_PROHIBITED, false); } } if (empty($msg)) { $sql = 'INSERT INTO ' . TABLE_INQUIRIES . ' ( inquiry_type, category_id, listing_id, name, email, phone,