/** * Smarty date_format modifier plugin * * Type: modifier<br> * Name: date_format<br> * Purpose: format datestamps via strftime<br> * Input:<br> * - string: input date string * - format: strftime format for output * - default_date: default date if $string is empty * @link http://smarty.php.net/manual/en/language.modifier.date.format.php * date_format (Smarty online manual) * @author Monte Ohrt <monte at ohrt dot com> * @param string * @param string * @param string * @return string|void * @uses smarty_make_timestamp() */ function smarty_modifier_date_format($string, $format = "%b %e, %Y", $default_date = null) { if ($string != '') { $timestamp = smarty_make_timestamp($string); } elseif (isset($default_date) && $default_date != '') { $timestamp = smarty_make_timestamp($default_date); } else { $timestamp = TIME; } return fn_date_format($timestamp, $format); }
function fn_check_intervals($interval, $time_from, $time_to, $limit = 0) { $intervals['0'] = db_get_row("SELECT a.* FROM ?:sales_reports_intervals as a WHERE a.interval_id = ?i", $interval); if (empty($time_from) && Registry::get('settings.Company.company_start_year')) { $time_from = mktime(0, 0, 0, 1, 1, Registry::get('settings.Company.company_start_year')); } if ($intervals['0']['value'] != 0) { $num = 0; $time_end = $time_from; while ($time_to > $time_end) { $temp = array(); $temp = $intervals[0]; $temp['interval_id'] = $temp['interval_id'] . $num; $temp['time_from'] = $time_end; $time_end += $intervals['0']['interval_id'] == '7' ? mktime(0, 0, 0, date("m", $time_end) + 1, 1, date("Y", $time_end)) - $time_end : $temp['value']; /** * If a year is leap, we should add 1 day. */ if (date('L', $temp['time_from'])) { $time_end += 86400; } $temp['time_to'] = $time_end; $num++; $temp['description'] = fn_date_format($temp['time_from'], Registry::get('settings.Reports.' . $temp['interval_code'])); $intervals[] = $temp; } unset($intervals[0]); ksort($intervals); } else { $intervals['0']['time_from'] = $time_from; $intervals['0']['time_to'] = $time_to; } //$intervals = array_reverse($intervals); if (!empty($limit)) { $i = 1; $j = 0; $temp = array(); foreach ($intervals as $k => $v) { $temp[$i][$k] = $v; $j++; if ($j == $limit) { $j = 0; $i++; } } unset($intervals); $intervals = $temp; } return $intervals; }
/** * Smarty date_format modifier plugin * * Type: modifier<br> * Name: date_format<br> * Purpose: format datestamps via strftime<br> * Input:<br> * - string: input date string * - format: strftime format for output * - default_date: default date if $string is empty * @link http://smarty.php.net/manual/en/language.modifier.date.format.php * date_format (Smarty online manual) * @author Monte Ohrt <monte at ohrt dot com> * @param string * @param string * @param string * @return string|void * @uses smarty_make_timestamp() */ function smarty_modifier_date_format($string, $format = "%b %e, %Y", $default_date = null) { /** * Include the {@link shared.make_timestamp.php} plugin */ require_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'; if ($string != '') { $timestamp = smarty_make_timestamp($string); } elseif (isset($default_date) && $default_date != '') { $timestamp = smarty_make_timestamp($default_date); } else { $timestamp = TIME; } return fn_date_format($timestamp, $format); }
$response->setData($file_url); } elseif ($meta['object'] == 'errors') { $response->returnResponse(); } elseif ($meta['object'] == 'reward_points_userlog') { $items_per_page = !empty($items_per_page) ? $items_per_page : TWG_RESPONSE_ITEMS_LIMIT; $request = $_REQUEST; $auth =& $_SESSION['auth']; $page = !empty($request['page']) ? $request['page'] : 1; list($_reward_points_log, $params) = fn_twg_get_reward_points_userlog(array('user_id' => $auth['user_id'], 'items_per_page' => $items_per_page, 'page' => $page)); $reward_points_log = array(); $statuses = fn_get_simple_statuses(STATUSES_ORDER, true, true); $actions = array(CHANGE_DUE_ORDER => 'CHANGE_DUE_ORDER', CHANGE_DUE_USE => 'CHANGE_DUE_USE', CHANGE_DUE_RMA => 'CHANGE_DUE_RMA', CHANGE_DUE_ADDITION => 'CHANGE_DUE_ADDITION', CHANGE_DUE_SUBTRACT => 'CHANGE_DUE_SUBTRACT', CHANGE_DUE_ORDER_DELETE => 'CHANGE_DUE_ORDER_DELETE', CHANGE_DUE_ORDER_PLACE => 'CHANGE_DUE_ORDER_PLACE'); foreach ($_reward_points_log as &$record) { $record['reason'] = !in_array($record['action'], array(CHANGE_DUE_ADDITION, CHANGE_DUE_SUBTRACT)) ? unserialize($record['reason']) : $record['reason']; $date_format = Registry::get('settings.Appearance.date_format') . ', ' . Registry::get('settings.Appearance.time_format'); $record['timestamp'] = fn_date_format($record['timestamp'], $date_format); $record['order_exists'] = !empty($record['reason']['order_id']) ? fn_get_order_name($record['reason']['order_id']) != false : false; $record['custom_action'] = false; if (in_array($record['action'], array_keys($actions))) { $record['action'] = $actions[$record['action']]; } else { $record['custom_action'] = true; } if (is_array($record['reason'])) { if (!empty($record['reason']['text'])) { $record['reason']['text'] = ltrim($record['reason']['text'], 'text_'); } if (!empty($statuses[$record['reason']['from']]) && !empty($statuses[$record['reason']['to']])) { $record['reason']['status'] = array('from' => $statuses[$record['reason']['from']], 'to' => $statuses[$record['reason']['to']]); } else { $record['reason']['status'] = array();
} } } Tygh::$app['view']->assign('yml_offer_types', $offers); Tygh::$app['view']->assign('yml_offer_features', $offers_features); } elseif ($mode == 'manage') { $price_lists = fn_yml_get_price_lists(); $generation_statuses = array(); foreach ($price_lists as $price_id => $price) { $price_lists[$price_id]['offset'] = 0; $price_lists[$price_id]['offset'] = fn_get_storage_data('yml2_export_offset_' . $price_id); $price_lists[$price_id]['count'] = fn_get_storage_data('yml2_export_count_' . $price_id); $time = fn_get_storage_data('yml2_export_time_' . $price_id); $price_lists[$price_id]['time'] = ""; if (!empty($time)) { $price_lists[$price_id]['time'] = fn_date_format($time, Registry::get('settings.Appearance.date_format') . " " . Registry::get('settings.Appearance.time_format')); } $runtime = fn_get_storage_data('yml2_export_start_time_' . $price_id); $price_lists[$price_id]['runtime'] = 0; if (!empty($runtime)) { $time = mktime(null, null, time() - $runtime); //$mktime = mktime(null, null, time() - $runtime); $price_lists[$price_id]['runtime'] = date("H:i:s", $time); } if ($price_lists[$price_id]['offset'] > $price_lists[$price_id]['count']) { $price_lists[$price_id]['offset'] = $price_lists[$price_id]['count']; } $price_lists[$price_id]['generate_link'] = fn_yml_get_generate_link($price); $price_lists[$price_id]['get_link'] = fn_yml_get_link($price); $generation_statuses[$price_id] = fn_get_storage_data('yml2_status_generate_' . $price_id); if ($generation_statuses[$price_id] == 'redirect') {
$__status = db_get_field("SELECT status FROM ?:orders WHERE order_id = ?i", $order_id); $pp_response = array(); $pp_response['order_status'] = $__status; $pp_response['reason_text'] = __('order_id') . '-' . $order_id; if (fn_check_payment_script('proxypay3.php', $order_id)) { fn_finish_payment($order_id, $pp_response, false); } fn_order_placement_routines('route', $order_id); } elseif ($action == 'nok') { if (empty($order_id)) { fn_set_notification('E', __('error'), __('connection_error')); fn_order_placement_routines('checkout_redirect'); } else { $pp_response = array('order_status' => 'D', 'reason_text' => __('payments.proxypay3.declined_reason_text')); fn_finish_payment($order_id, $pp_response, false); fn_order_placement_routines('route', $order_id); } } } } else { $lang = CART_LANGUAGE == 'el' ? 'GR' : 'EN'; if (in_array($processor_data['processor_params']['currency'], $totals_100)) { $total_cost = $order_info['total']; } else { $total_cost = $order_info['total'] * 100; } $order_id = $order_id . '_' . fn_date_format(time(), '%H:%M:%S'); $post_data = array('APACScommand' => 'NewPayment', 'merchantID' => $processor_data['processor_params']['merchantid'], 'amount' => $total_cost, 'merchantRef' => $order_id, 'merchantDesc' => $processor_data['processor_params']['details'], 'currency' => $processor_data['processor_params']['currency'], 'lang' => $lang, 'CustomerEmail' => $order_info['email']); fn_create_payment_form('https://' . $processor_data['processor_params']['url'], $post_data, 'Eurobank'); } exit;
$pp_response['descr_avs'] = $avs[1]; } fn_finish_payment($_REQUEST['order_id'], $pp_response, false); fn_order_placement_routines('route', $_REQUEST['order_id']); } else { if ($processor_data['processor_params']['testmode'] == 'Y') { $post_address = "https://test.sagepay.com/gateway/service/vspform-register.vsp"; } elseif ($processor_data['processor_params']['testmode'] == 'N') { $post_address = "https://live.sagepay.com/gateway/service/vspform-register.vsp"; } elseif ($processor_data['processor_params']['testmode'] == 'S') { $post_address = "https://test.sagepay.com/Simulator/VSPFormGateway.asp"; } $post["VPSProtocol"] = "2.23"; $post["TxType"] = $processor_data["processor_params"]["transaction_type"]; $post["Vendor"] = htmlspecialchars($processor_data["processor_params"]["vendor"]); $post_encrypted = 'VendorTxCode=' . $processor_data['processor_params']['order_prefix'] . ($order_info['repaid'] ? $order_id . '_' . $order_info['repaid'] : $order_id) . '-' . fn_date_format(time(), '%H_%M_%S') . "&"; $post_encrypted .= 'Amount=' . $order_info['total'] . '&'; $post_encrypted .= 'Currency=' . $processor_data['processor_params']['currency'] . '&'; $post_encrypted .= 'Description=Payment for Order' . $order_id . '&'; $post_encrypted .= 'SuccessURL=' . fn_url("payment_notification.notify?payment=sagepay_form&order_id={$order_id}", AREA, 'http') . '&'; $post_encrypted .= 'FailureURL=' . fn_url("payment_notification.notify?payment=sagepay_form&order_id={$order_id}", AREA, 'http') . '&'; $post_encrypted .= 'CustomerEMail=' . $order_info['email'] . '&'; $post_encrypted .= 'VendorEmail=' . Registry::get('settings.Company.company_orders_department') . '&'; $post_encrypted .= 'CustomerName=' . $order_info['firstname'] . ' ' . $order_info['lastname'] . '&'; $post_encrypted .= 'ContactNumber=' . $order_info['phone'] . '&'; $post_encrypted .= 'ContactFax=' . $order_info['fax'] . '&'; // Billing address $post_encrypted .= 'BillingAddress1=' . $order_info['b_address'] . '&'; if (!empty($order_info['b_address_2'])) { $post_encrypted .= 'BillingAddress2=' . $order_info['b_address_2'] . '&'; }
1 - Pre-authorization 2 - Confirmation 3 -Automatic Refund 4 - Payment by Cell Phone 5 - Recurrent Transaction 6 - Successive Transaction 7 - Authentication 8 - Confirmation of Authentication */ $currency = $processor_data['processor_params']['currency']; $merchant = $processor_data['processor_params']['merchant_id']; $terminal = $processor_data['processor_params']['terminal']; $transaction_type = 0; // authorization $clave = $processor_data['processor_params']['clave']; $postfix = fn_date_format(time(), '%S'); if (strlen($order_id) > 6) { $order_n = $order_id . $postfix . ($order_info['repaid'] ? 'x' . $order_info['repaid'] : ''); } else { $order_n = str_repeat('0', 6 - strlen($order_id)) . $order_id . $postfix . ($order_info['repaid'] ? 'x' . $order_info['repaid'] : ''); } $amount = $currency == '978' ? $order_info['total'] * 100 : $order_info['total']; $url_merchant = fn_url("payment_notification.result?payment=servired&order_id={$order_id}{$postfix}", AREA, 'current'); $url_ok = fn_url("payment_notification.notify?payment=servired&order_id={$order_id}{$postfix}", AREA, 'current'); $url_nok = fn_url("payment_notification.failed?payment=servired&order_id={$order_id}{$postfix}", AREA, 'current'); // Compute hash to sign form data $message = $amount . $order_n . $merchant . $currency . $transaction_type . $url_merchant . $clave; $signature = strtoupper(sha1($message)); $post_data = array('Ds_Merchant_Amount' => $amount, 'Ds_Merchant_Currency' => $currency, 'Ds_Merchant_Order' => $order_n, 'Ds_Merchant_MerchantCode' => $merchant, 'Ds_Merchant_Terminal' => $terminal, 'Ds_Merchant_TransactionType' => $transaction_type, 'Ds_Merchant_MerchantURL' => $url_merchant, 'Ds_Merchant_UrlOK' => $url_ok, 'Ds_Merchant_UrlKO' => $url_nok, 'Ds_Merchant_MerchantSignature' => $signature); fn_create_payment_form($post_address, $post_data, 'SERMEPA'); }
$pp_merch = $processor_data['processor_params']['vendor']; $pp_curr = $processor_data['processor_params']['currency']; if ($processor_data['processor_params']['testmode'] == 'Y') { $post_address = 'https://test.sagepay.com/gateway/service/vspdirect-register.vsp'; } elseif ($processor_data['processor_params']['testmode'] == 'N') { $post_address = 'https://live.sagepay.com/gateway/service/vspdirect-register.vsp'; } elseif ($processor_data['processor_params']['testmode'] == 'S') { $post_address = 'https://test.sagepay.com/Simulator/VSPDirectGateway.asp'; } $already_posted = false; $card_type = fn_get_payment_card($order_info['payment_info']['card_number'], array('visa' => 'VISA', 'visa_debit' => 'DELTA', 'mastercard' => 'MC', 'mastercard_debit' => 'MCDEBIT', 'amex' => 'AMEX', 'jcb' => 'JCB', 'maestro' => 'MAESTRO', 'visa_electron' => 'UKE', 'laser' => 'LASER', 'diners_club_carte_blanche' => 'DINERS', 'diners_club_international' => 'DINERS')); $post = array(); $post['VPSProtocol'] = '2.23'; $post['TxType'] = $processor_data['processor_params']['transaction_type']; $post['Vendor'] = $pp_merch; $post['VendorTxCode'] = (!empty($processor_data['processor_params']['order_prefix']) ? $processor_data['processor_params']['order_prefix'] : 'O') . '-' . ($order_info['repaid'] ? $order_info['order_id'] . '-' . $order_info['repaid'] : $order_info['order_id']) . '-' . fn_date_format(time(), '%H_%M_%S'); $post['Amount'] = $order_info["total"]; $post['Currency'] = $pp_curr; $post['Description'] = 'Your Cart'; $post['CardHolder'] = $order_info['payment_info']['cardholder_name']; $post['CardNumber'] = $order_info['payment_info']['card_number']; $post['ExpiryDate'] = $order_info['payment_info']['expiry_month'] . $order_info['payment_info']['expiry_year']; $post['CV2'] = $order_info['payment_info']['cvv2']; $post['CardType'] = $card_type; $post['Apply3DSecure'] = 0; $post['BillingAddress1'] = $order_info['b_address']; $post['BillingAddress2'] = $order_info['b_address_2']; //Workariund for the Irish customers. According to the documentation we should enter zip code anyway. $post['BillingPostCode'] = !empty($order_info['b_zipcode']) ? $order_info['b_zipcode'] : '0000'; $post['BillingCountry'] = $order_info['b_country']; if ($order_info['b_country'] == 'US') {
function fn_gift_certificates_quickbooks_export_order($order, $order_products, $spl, &$export) { $order_date = fn_date_format($order['timestamp'], "%m/%d/%Y"); $trns_class = Registry::get('addons.quickbooks.trns_class'); if (!empty($order['gift_certificates'])) { foreach ($order['gift_certificates'] as $gift) { // Check wether gift certificate is taxable $taxable = !empty($gift['tax_value']) ? 'Y' : 'N'; $export[] = sprintf($spl, $order_date, Registry::get('addons.quickbooks.accnt_product'), fn_quickbooks_escape_field($order['b_lastname']), fn_quickbooks_escape_field($order['b_firstname']), $trns_class, -$gift['amount'], $order['order_id'], 'GIFT CERTIFICATE:', $gift['gift_cert_code'], $gift['amount'], -1, 'GIFT CERTIFICATE', $taxable, ''); } } if (!empty($order['use_gift_certificates'])) { foreach ($order['use_gift_certificates'] as $code => $use_gift) { $export[] = sprintf($spl, $order_date, Registry::get('addons.quickbooks.accnt_discount'), fn_quickbooks_escape_field($order['b_lastname']), fn_quickbooks_escape_field($order['b_firstname']), Registry::get('addons.quickbooks.trns_class'), $use_gift['cost'], $order['order_id'], 'GIFT CERTIFICATE:', $code, -$use_gift['cost'], -1, 'GIFT CERTIFICATE', 'N', ''); } } }
function fn_format_rss_time($timestamp) { return fn_date_format($timestamp, '%a, %d %b %Y %T') . ' GMT'; }
/** * Generates date-time intervals of a given period for sales reports * * @param int $interval_id Sales reports interval ID * @param int $timestamp_from Timestamp of report period beginning date * @param int $timestamp_to Timestamp of report period end date * @param int $limit * * @return array */ function fn_check_intervals($interval_id, $timestamp_from, $timestamp_to, $limit = 0) { $interval_definition = db_get_row('SELECT * FROM ?:sales_reports_intervals WHERE `interval_id` = ?i', $interval_id); $intervals = array(); // Passthru given timeframe if (empty($interval_definition['value'])) { $interval = $interval_definition; $interval['time_from'] = $timestamp_from; $interval['time_to'] = $timestamp_to; $intervals[] = $interval; } else { $interval_type_map = array('day' => 'D', 'week' => 'W', 'month' => 'M', 'year' => 'Y'); $mapped_interval_type = $interval_type_map[$interval_definition['interval_code']]; $timezone = new \DateTimeZone(date_default_timezone_get()); $date_interval = new \DateInterval("P1{$mapped_interval_type}"); $datetime_from = new \DateTime("@{$timestamp_from}"); $datetime_from->setTimezone($timezone); $datetime_to = new \DateTime("@{$timestamp_to}"); $datetime_to->setTimezone($timezone); $period_iterator_datetime_from = clone $datetime_from; $period_definitions = DateTimeHelper::getPeriodDefinitions(); switch ($interval_definition['interval_code']) { case 'week': $period_iterator_start_datetime_modifier = $period_definitions[DateTimeHelper::PERIOD_THIS_WEEK]['from']; break; case 'month': $period_iterator_start_datetime_modifier = $period_definitions[DateTimeHelper::PERIOD_THIS_MONTH]['from']; break; case 'year': $period_iterator_start_datetime_modifier = $period_definitions[DateTimeHelper::PERIOD_THIS_YEAR]['from']; break; default: $period_iterator_start_datetime_modifier = null; break; } if (null !== $period_iterator_start_datetime_modifier) { $period_iterator_datetime_from->modify($period_iterator_start_datetime_modifier); } $period_list = new \DatePeriod($period_iterator_datetime_from, $date_interval, $datetime_to); foreach ($period_list as $i => $period_start) { /** @var \DateTime $period_start */ $period_end = clone $period_start; $period_end->add($date_interval)->modify('-1 second'); if ($period_start < $datetime_from) { $period_start = clone $datetime_from; } if ($period_end > $datetime_to) { $period_end = clone $datetime_to; } $interval = array('interval_id' => "{$interval_definition['interval_id']}{$i}", 'value' => $interval_definition['value'], 'interval_code' => $interval_definition['interval_code'], 'time_from' => $period_start->getTimestamp(), 'time_to' => $period_end->getTimestamp(), 'iso8601_from' => $period_start->format(\DateTime::ISO8601), 'iso8601_to' => $period_end->format(\DateTime::ISO8601)); $interval_date_format = Registry::get("settings.Reports.{$interval_definition['interval_code']}"); // String representation of interval's beginning date $interval['description'] = fn_date_format($interval['time_from'], $interval_date_format); // Week, month and year intervals may belong to two real weeks/months/years, // so we have to display both of them. if (in_array($interval_definition['interval_code'], array('week', 'month', 'year'))) { $datetime_to_description = fn_date_format($interval['time_to'], $interval_date_format); // Interval belongs to two real weeks/months/years if ($interval['description'] !== $datetime_to_description) { $interval['description'] .= " - {$datetime_to_description}"; } } $intervals[$i + 1] = $interval; // $i+1 is also preserved for BC, no algorhytmical meaning } } // This magical part of code must be working, but is left non-tested yet if (!empty($limit)) { $i = 1; $j = 0; $temp = array(); foreach ($intervals as $k => $v) { $temp[$i][$k] = $v; $j++; if ($j == $limit) { $j = 0; $i++; } } unset($intervals); $intervals = $temp; } return $intervals; }
$all_tables = array(); foreach ($status_data as $k => $v) { $database_size += $v['Data_length'] + $v['Index_length']; $all_tables[] = $v['Name']; } Registry::get('view')->assign('database_size', $database_size); Registry::get('view')->assign('all_tables', $all_tables); $files = fn_get_dir_contents(Registry::get('config.dir.database'), false, true, array('.sql', '.tgz'), '', true); sort($files, SORT_STRING); $backup_files = array(); $date_format = Registry::get('settings.Appearance.date_format') . ' ' . Registry::get('settings.Appearance.time_format'); if (is_array($files)) { foreach ($files as $file) { $backup_files[$file]['size'] = filesize(Registry::get('config.dir.database') . $file); $backup_files[$file]['type'] = strpos($file, '.tgz') === false ? 'sql' : 'tgz'; $backup_files[$file]['create'] = fn_date_format(filemtime(Registry::get('config.dir.database') . $file), $date_format); } } Registry::get('view')->assign('backup_files', $backup_files); Registry::get('view')->assign('backup_dir', fn_get_rel_dir(Registry::get('config.dir.database'))); } elseif ($mode == 'delete') { if (!empty($_REQUEST['backup_file'])) { fn_rm(Registry::get('config.dir.database') . fn_basename($_REQUEST['backup_file'])); } return array(CONTROLLER_STATUS_REDIRECT, "database.manage?selected_section=restore"); } function fn_restore_dump($files) { if (empty($files)) { return false; }
$post['x_ship_to_company'] = $order_info['company']; $post['x_ship_to_city'] = $order_info['s_city']; $post['x_ship_to_state'] = $order_info['s_state']; $post['x_ship_to_zip'] = $order_info['s_zipcode']; $post['x_ship_to_country'] = $order_info['s_country']; // Customer information $post['x_phone'] = $order_info['phone']; $post['x_fax'] = $order_info['fax']; $post['x_cust_id'] = $_SESSION['auth']['user_id']; // !!!FIXME (what about not registered?) $post['x_customer_ip'] = $_SERVER['REMOTE_ADDR']; $post['x_email'] = $order_info['email']; $post['x_email_customer'] = 'FALSE'; // Merchant information $post['x_merchant_email'] = Registry::get('settings.Company.company_orders_department'); $post['x_invoice_num'] = $processor_data['processor_params']['order_prefix'] . $order_id . ($order_info['repaid'] ? "_{$order_info['repaid']}" : '') . '_' . fn_date_format(time(), '%H_%M_%S'); $post['x_amount'] = fn_format_price($order_info['total']); $post['x_currency_code'] = $processor_data['processor_params']['currency']; $post['x_method'] = 'CC'; $post['x_recurring_billing'] = 'NO'; $post['x_type'] = $transaction_types[$trans_type]; // CC information $post['x_card_num'] = $order_info['payment_info']['card_number']; $post['x_exp_date'] = $order_info['payment_info']['expiry_month'] . '/' . $order_info['payment_info']['expiry_year']; $post['x_card_code'] = $order_info['payment_info']['cvv2']; // Cart totals $post['x_relay_response'] = 'FALSE'; $post['x_tax'] = fn_format_price($order_info['tax_subtotal']); $post['x_freight'] = fn_format_price($order_info['shipping_cost']); $payment_url = $processor_data['processor_params']['mode'] == 'developer' ? "https://test.authorize.net/gateway/transact.dll" : "https://secure.authorize.net:443/gateway/transact.dll"; Registry::set('log_cut_data', array('x_card_num', 'x_exp_date', 'x_card_code'));
function fn_twg_get_feature_value($value, $feature_type, $value_int, $variant_id, $variants) { if ($feature_type == "D") { $value = fn_date_format($value_int, REGISTRY::get('settings.Appearance.date_format')); } elseif ($feature_type == "M") { $value = array(); foreach ($variants as $variant) { if ($variant['selected']) { $value[] = $variant['variant']; } } } elseif ($variant_id) { $value = $variants[$variant_id]['variant']; } elseif ($value_int) { $value = $value_int; } return $value; }
/** * Get profile field value for printing * * @param array $profile Profile data * @param array $field Field data * @return string Field value */ function fn_get_profile_field_value($profile, $field) { $value = ''; if (!empty($field['field_name'])) { $data_id = $field['field_name']; $value = !empty($profile[$data_id]) ? $profile[$data_id] : ''; } else { $data_id = $field['field_id']; $value = !empty($profile['fields'][$data_id]) ? $profile['fields'][$data_id] : ''; } if (!empty($value)) { if (strpos("AO", $field['field_type']) !== false) { // States/Countries $title = $data_id . '_descr'; $value = !empty($profile[$title]) ? $profile[$title] : '-'; } elseif ($field['field_type'] == "C") { // Checkbox $value = $value == "Y" ? __('yes') : __('no'); } elseif ($field['field_type'] == "D") { // Date $value = fn_date_format($value, Registry::get('settings.Appearance.date_format')); } elseif (strpos("RS", $field['field_type']) !== false) { // Selectbox/Radio $value = $field['values'][$value]; } } return $value; }
foreach ($order_info['products'] as $k => $v) { $unit_price = fn_format_price($v['subtotal'] / $v['amount']); $items .= "<SKU>{$v['product_code']}</SKU>\n <Description>" . htmlspecialchars($v['product']) . "</Description>\n <Quantity>{$v['amount']}</Quantity>\n <UnitPrice>{$unit_price}</UnitPrice>"; } } if (!empty($order_info['taxes']) && Registry::get('settings.General.tax_calculation') == 'subtotal') { foreach ($order_info['taxes'] as $tax_id => $tax) { if ($tax['price_includes_tax'] == 'Y') { continue; } $unit_price = fn_format_price($tax['tax_subtotal']); $items .= "<SKU>" . htmlspecialchars($tax['description']) . "</SKU>\n <Description>" . htmlspecialchars($tax['description']) . "</Description>\n <Quantity>1</Quantity>\n <UnitPrice>{$unit_price}</UnitPrice>"; } } $payflow_expire = '20' . $order_info['payment_info']['expiry_year'] . $order_info['payment_info']['expiry_month']; $payflow_order_id = $processor_data['processor_params']['order_prefix'] . $order_id . ($order_info['repaid'] ? "_{$order_info['repaid']}" : '') . '_' . fn_date_format(time(), '%H_%M_%S'); if (!empty($order_info['shipping']) && is_array($order_info['shipping'])) { $shipping_name = reset($order_info['shipping']); } else { $shipping_name = array(); $shipping_name['shipping'] = __('no_shipping_required'); } $subtotal_discount = floatval($order_info['subtotal_discount']) ? fn_format_price($order_info['subtotal_discount']) : 0; $post = <<<XML <?xml version="1.0" encoding="UTF-8"?> <XMLPayRequest Timeout='45' version="2.0"> <RequestData> <Partner>{$payflow_partner}</Partner> <Vendor>{$payflow_vendor}</Vendor> <Transactions> <Transaction>
$_order_id = $order_info['repaid'] ? $order_id . '_' . $order_info['repaid'] : $order_id; $expiry_date = $order_info['payment_info']['expiry_month'] . $order_info['payment_info']['expiry_year']; $test = $processor_data['processor_params']['test'] == '1' ? true : false; $avs = $processor_data['processor_params']['avs'] == '1' ? true : false; $cvv = $order_info['payment_info']['cvv2']; require_once 'worldnettps_files/worldnet_tps_xml.php'; $sale = new XmlAuthRequest($processor_data['processor_params']['terminal_id'], $_order_id . fn_date_format(TIME, '%H_%M_%S'), $processor_data['processor_params']['currency'], $order_info['total'], $order_info['email'] . " " . $_order_id, $order_info['email'], $order_info['payment_info']['card_number'], $card_type, $expiry_date, $order_info['payment_info']['cardholder_name']); if ($cvv != '') { $sale->SetCvv($cvv); } if ($avs) { $address1 = $order_info['b_address']; $address2 = $order_info['b_city'] . $order_info['b_state']; $postcode = $order_info['b_zipcode']; $sale->SetAvs($address1, $address2, $postcode); } // Perform Auth $response = $sale->ProcessRequest($processor_data['processor_params']['shared_secret'], false, true); // Verify response hash $hash = md5($processor_data['processor_params']['terminal_id'] . $_order_id . fn_date_format(TIME, '%H_%M_%S') . $order_info['total'] . $response->DateTime() . $response->ResponseCode() . $response->ResponseText() . $processor_data['processor_params']['shared_secret']); $pp_response = array(); if ($response->IsError()) { $pp_response['order_status'] = "F"; $pp_response["reason_text"] = $response->ErrorString(); } elseif ($response->Hash() != $hash) { $pp_response['order_status'] = "F"; $pp_response["reason_text"] = __('worldnettps_hash_error'); } else { $pp_response['order_status'] = $response->ResponseCode() == "A" ? "P" : "F"; $pp_response["reason_text"] = $response->ResponseText(); }
function fn_gift_certificates_quickbooks_export_order($order, $order_products, $spl, &$export) { $order_date = fn_date_format($order['timestamp'], "%m/%d/%Y"); if (!empty($order['gift_certificates'])) { foreach ($order['gift_certificates'] as $gift) { $export[] = sprintf($spl, $order_date, Registry::get('addons.quickbooks.accnt_product'), $order['b_lastname'], $order['b_firstname'], Registry::get('addons.quickbooks.trns_class'), -$gift['amount'], $order['order_id'], 'GIFT CERTIFICATE:', $gift['gift_cert_code'], $gift['amount'], -1, 'GIFT CERTIFICATE', ''); } } if (!empty($order['use_gift_certificates'])) { foreach ($order['use_gift_certificates'] as $code => $use_gift) { $export[] = sprintf($spl, $order_date, Registry::get('addons.quickbooks.accnt_discount'), $order['b_lastname'], $order['b_firstname'], Registry::get('addons.quickbooks.trns_class'), $use_gift['cost'], $order['order_id'], 'GIFT CERTIFICATE:', $code, -$use_gift['cost'], -1, 'GIFT CERTIFICATE', ''); } } }
$pp_response['reason_text'] = __('kupivkredit_widget_bank_reject'); } elseif ($decision == 'ver') { $pp_response['order_status'] = 'O'; $pp_response['reason_text'] = __('kupivkredit_widget_open'); } elseif ($decision == 'agr') { $pp_response['order_status'] = 'P'; $pp_response['reason_text'] = __('kupivkredit_widget_processed'); } } if (fn_check_payment_script('kupivkredit.php', $order_id)) { fn_finish_payment($order_id, $pp_response); fn_order_placement_routines('route', $order_id, false); } } else { $url = $processor_data['processor_params']['test'] == 'Y' ? 'https://' . KVK_WIDGET_TEST_URL : 'https://' . KVK_WIDGET_URL; $kvk_order_id = ($order_info['repaid'] ? $order_info['order_id'] . '_' . $order_info['repaid'] : $order_info['order_id']) . '_' . fn_date_format(time(), '%H_%M_%S'); //We should save this iformation for the actions such as 'confirm order', 'cancel order' in the admin area. fn_update_order_payment_info($order_id, array('kvk_order_id' => $kvk_order_id)); $order = array(); foreach ($order_info['products'] as $k => $item) { $price = fn_format_price(($item['subtotal'] - fn_external_discounts($item)) / $item['amount']); $order['items'][] = array('title' => $item['product'], 'category' => db_get_field("SELECT ?:category_descriptions.category FROM ?:category_descriptions LEFT JOIN ?:products_categories ON ?:category_descriptions.category_id = ?:products_categories.category_id WHERE ?:products_categories.product_id = ?i AND ?:products_categories.link_type = ?s AND ?:category_descriptions.lang_code = ?s", $item['product_id'], 'M', $order_info['lang_code']), 'qty' => $item['amount'], 'price' => fn_format_rate_value($price, 'F', 0, '.', '', '')); } if (!empty($order_info['shipping_cost'])) { $order['items'][] = array('title' => __('shipping_cost'), 'category' => '', 'qty' => 1, 'price' => fn_format_rate_value($order_info['shipping_cost'], 'F', 0, '.', '', '')); } if (!empty($order_info['taxes'])) { foreach ($order_info['taxes'] as $tax) { if ($tax['price_includes_tax'] == 'N') { $order['items'][] = array('title' => __('tax'), 'category' => '', 'qty' => 1, 'price' => fn_format_rate_value($tax['tax_subtotal'], 'F', 0, '.', '', '')); }
foreach ($status_data as $k => $v) { $database_size += $v['Data_length'] + $v['Index_length']; $all_tables[] = $v['Name']; } $view->assign('database_size', $database_size); $view->assign('all_tables', $all_tables); $files = fn_get_dir_contents(Registry::get('config.dir.backups'), false, true, array('.sql', '.tgz', '.zip'), '', true); sort($files, SORT_STRING); $backup_files = array(); $date_format = Registry::get('settings.Appearance.date_format') . ' ' . Registry::get('settings.Appearance.time_format'); if (is_array($files)) { $backup_dir = Registry::get('config.dir.backups'); foreach ($files as $file) { $ext = fn_get_file_ext($backup_dir . $file); $backup_files[$file]['size'] = filesize($backup_dir . $file); $backup_files[$file]['create'] = fn_date_format(filemtime($backup_dir . $file), $date_format); if ($ext == 'sql') { $backup_files[$file]['type'] = 'database'; } else { $backup_files[$file]['type'] = DataKeeper::getArchiveType($backup_dir . $file); } } } $supported_archive_types = array('tgz'); $validators = new Validators(); if ($validators->isZipArchiveAvailable()) { $supported_archive_types[] = 'zip'; } $view->assign('supported_archive_types', $supported_archive_types); $view->assign('backup_files', $backup_files); $view->assign('backup_dir', fn_get_rel_dir(Registry::get('config.dir.backups')));
function fn_quickbooks_export_payments($orders, &$export) { $exists_order_complete = false; $payments = array(); $payments[] = "!TRNS\tTRNSTYPE\tDATE\tACCNT\tNAME\tAMOUNT\tPAYMETH\tDOCNUM"; $payments[] = "!SPL\tTRNSTYPE\tDATE\tACCNT\tNAME\tAMOUNT\tDOCNUM"; $payments[] = "!ENDTRNS\t"; $trns = "TRNS\tPAYMENT\t%s\tUndeposited Funds\t\"%s, %s\"\t%01.2f\t%s\t%d"; $spl = "SPL\tPAYMENT\t%s\tAccounts Receivable\t\"%s, %s\"\t%01.2f\t%d"; foreach ($orders as $order) { if (in_array($order['status'], fn_get_order_paid_statuses())) { $order_date = fn_date_format($order['timestamp'], "%m/%d/%Y"); $payments[] = sprintf($trns, $order_date, fn_quickbooks_escape_field($order['b_lastname']), fn_quickbooks_escape_field($order['b_firstname']), $order['total'], $order['payment_method']['payment'], $order['order_id']); $payments[] = sprintf($spl, $order_date, fn_quickbooks_escape_field($order['b_lastname']), fn_quickbooks_escape_field($order['b_firstname']), -$order['total'], $order['order_id']); $payments[] = "ENDTRNS\t"; $exists_order_complete = true; } } if ($exists_order_complete) { $payments[] = ''; $export = array_merge($export, $payments); } return true; }