/** * @param Money $money * @param Currency $counterCurrency * @param int $roundingMode * * @return Money */ public function convert(Money $money, Currency $counterCurrency, $roundingMode = Money::ROUND_HALF_UP) { $baseCurrency = $money->getCurrency(); $ratio = $this->exchange->quote($baseCurrency, $counterCurrency)->getConversionRatio(); $baseCurrencySubunit = $this->currencies->subunitFor($baseCurrency); $counterCurrencySubunit = $this->currencies->subunitFor($counterCurrency); $subunitDifference = $baseCurrencySubunit - $counterCurrencySubunit; $ratio = $ratio / pow(10, $subunitDifference); $counterValue = $money->multiply($ratio, $roundingMode); return new Money($counterValue->getAmount(), $counterCurrency); }
public function readUnits() { $con = self::openConnection(); $currencies = new Currencies(); mysqli_begin_transaction($con); $sql = "SELECT * FROM currency WHERE 1"; $res = mysqli_query($con, $sql); while ($arrRes = mysqli_fetch_assoc($res)) { $currency = new Currency(); $currency->setId($arrRes['id']); $currency->setCode($arrRes['code']); $currencies->setUnit($currency); } return $currencies; }
public function deletecurrencyAction() { global $mySession; $db = new Db(); if ($_REQUEST['Id'] != "") { $arrId = explode("|", $_REQUEST['Id']); if (count($arrId) > 0) { if ($Id > 1) { $myObj = new Currencies(); $Result = $myObj->deleteCurrency($Id); } } } exit; }
/** * Render select currency box * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_select_currency($params, &$smarty) { $value = array_var($params, 'value', null, true); $options = array(); $currencies = Currencies::findAll(); foreach ($currencies as $currency) { $option_attributes = array('code' => $currency->getCode()); if ($currency->getId() == $value) { $option_attributes['selected'] = true; } // if $options[] = option_tag($currency->getName() . ' (' . $currency->getCode() . ')', $currency->getId(), $option_attributes); } // foreach return select_box($options, $params); }
function wp_currencies($content) { $c = new Currencies(); return $c->replace($content); }
/** * Draw prepayment info * @param $draw */ public static function DrawPrepayment($plan_id = '', $payment_type = '', $currency = '', $draw = true) { global $objSettings, $objLogin; $plan_id = empty($plan_id) ? MicroGrid::GetParameter('plan_id', false) : $plan_id; $payment_type = empty($payment_type) ? MicroGrid::GetParameter('payment_type', false) : $payment_type; $currency = empty($currency) ? MicroGrid::GetParameter('currency', false) : $currency; $output = ''; // retrieve module parameters $paypal_email = ModulesSettings::Get('payments', 'paypal_email'); $collect_credit_card = ModulesSettings::Get('payments', 'online_collect_credit_card'); $two_checkout_vendor = ModulesSettings::Get('payments', 'two_checkout_vendor'); $authorize_login_id = ModulesSettings::Get('payments', 'authorize_login_id'); $authorize_transaction_key = ModulesSettings::Get('payments', 'authorize_transaction_key'); $mode = ModulesSettings::Get('payments', 'mode'); $vat_value = ModulesSettings::Get('payments', 'vat_value'); // retrieve credit card info $cc_type = isset($_REQUEST['cc_type']) ? prepare_input($_REQUEST['cc_type']) : ''; $cc_holder_name = isset($_POST['cc_holder_name']) ? prepare_input($_POST['cc_holder_name']) : ''; $cc_number = isset($_POST['cc_number']) ? prepare_input($_POST['cc_number']) : ""; $cc_expires_month = isset($_POST['cc_expires_month']) ? prepare_input($_POST['cc_expires_month']) : "1"; $cc_expires_year = isset($_POST['cc_expires_year']) ? prepare_input($_POST['cc_expires_year']) : date("Y"); $cc_cvv_code = isset($_POST['cc_cvv_code']) ? prepare_input($_POST['cc_cvv_code']) : ""; // prepare datetime format $field_date_format = get_datetime_format(); $currency_format = get_currency_format(); $arr_durations = self::PrepareDurationsArray(); // prepare clients info $sql = 'SELECT * FROM ' . TABLE_CUSTOMERS . ' WHERE id = ' . (int) $objLogin->GetLoggedID(); $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY); $client_info = array(); $client_info['first_name'] = isset($result[0]['first_name']) ? $result[0]['first_name'] : ''; $client_info['last_name'] = isset($result[0]['last_name']) ? $result[0]['last_name'] : ''; $client_info['address1'] = isset($result[0]['b_address']) ? $result[0]['b_address'] : ''; $client_info['address2'] = isset($result[0]['b_address2']) ? $result[0]['b_address2'] : ''; $client_info['city'] = isset($result[0]['b_city']) ? $result[0]['b_city'] : ''; $client_info['state'] = isset($result[0]['b_state']) ? $result[0]['b_state'] : ''; $client_info['zip'] = isset($result[0]['b_zipcode']) ? $result[0]['b_zipcode'] : ''; $client_info['country'] = isset($result[0]['b_country']) ? $result[0]['b_country'] : ''; $client_info['email'] = isset($result[0]['email']) ? $result[0]['email'] : ''; $client_info['company'] = isset($result[0]['company']) ? $result[0]['company'] : ''; $client_info['phone'] = isset($result[0]['phone']) ? $result[0]['phone'] : ''; $client_info['fax'] = isset($result[0]['fax']) ? $result[0]['fax'] : ''; if ($cc_holder_name == '') { if ($objLogin->IsLoggedIn()) { $cc_holder_name = $objLogin->GetLoggedFirstName() . ' ' . $objLogin->GetLoggedLastName(); } else { $cc_holder_name = $client_info['first_name'] . ' ' . $client_info['last_name']; } } // get order number $sql = 'SELECT id, order_number FROM ' . TABLE_ORDERS . ' WHERE customer_id = ' . (int) $objLogin->GetLoggedID() . ' AND status = 0 ORDER BY id DESC'; $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY); if ($result[1] > 0) { $order_number = $result[0]['order_number']; } else { $order_number = strtoupper(get_random_string(10)); } $additional_info = ''; $cart_total_wo_vat = 0; $vat_cost = 0; $cart_total = 0; $sql = 'SELECT ap.id, ap.listings_count, ap.price, ap.duration, ap.is_default, apd.name, apd.description FROM ' . TABLE_ADVERTISE_PLANS . ' ap LEFT OUTER JOIN ' . TABLE_ADVERTISE_PLANS_DESCRIPTION . ' apd ON ap.id = apd.advertise_plan_id AND apd.language_id = \'' . Application::Get('lang') . '\' WHERE ap.id = ' . (int) $plan_id; $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY); $fisrt_part = '<table border="0" width="97%" align="center"> <tr><td colspan="3"><h4>' . _ORDER_DESCRIPTION . '</h4></td></tr> <tr><td width="20%">' . _ORDER_DATE . ' </td><td width="2%"> : </td><td> ' . format_datetime(date('Y-m-d H:i:s'), $field_date_format) . '</td></tr>'; if ($result[1] > 0) { if ($result[0]['price'] == 0) { $payment_type = 'online'; $collect_credit_card = 'no'; } $cart_total_wo_vat = $result[0]['price'] * Application::Get('currency_rate'); $vat_cost = $cart_total_wo_vat * ($vat_value / 100); $cart_total = $cart_total_wo_vat + $vat_cost; $duration = isset($arr_durations[$result[0]['duration']]) ? $arr_durations[$result[0]['duration']] : ''; $fisrt_part .= '<tr><td>' . _ADVERTISE_PLAN . ' </td><td width="2%"> : </td><td> ' . $result[0]['name'] . '</td></tr>'; $fisrt_part .= '<tr><td>' . _DURATION . ' </td><td width="2%"> : </td><td> ' . $duration . '</td></tr>'; $fisrt_part .= '<tr><td>' . _LISTINGS . ' </td><td width="2%"> : </td><td> ' . $result[0]['listings_count'] . '</td></tr>'; $fisrt_part .= '<tr><td>' . _PRICE . ' </td><td width="2%"> : </td><td> ' . Currencies::PriceFormat($cart_total_wo_vat) . '</td></tr>'; $fisrt_part .= '<tr><td>' . _DESCRIPTION . ' </td><td width="2%"> : </td><td> ' . $result[0]['description'] . '</td></tr>'; } $pp_params = array('api_login' => '', 'transaction_key' => '', 'order_number' => $order_number, 'address1' => $client_info['address1'], 'address2' => $client_info['address2'], 'city' => $client_info['city'], 'zip' => $client_info['zip'], 'country' => $client_info['country'], 'state' => $client_info['state'], 'first_name' => $client_info['first_name'], 'last_name' => $client_info['last_name'], 'email' => $client_info['email'], 'company' => $client_info['company'], 'phone' => $client_info['phone'], 'fax' => $client_info['fax'], 'notify' => '', 'return' => 'index.php?page=payment_return', 'cancel_return' => 'index.php?page=payment_cancel', 'paypal_form_type' => '', 'paypal_form_fields' => '', 'paypal_form_fields_count' => '', 'collect_credit_card' => $collect_credit_card, 'cc_type' => '', 'cc_holder_name' => '', 'cc_number' => '', 'cc_cvv_code' => '', 'cc_expires_month' => '', 'cc_expires_year' => '', 'currency_code' => Application::Get('currency_code'), 'additional_info' => $additional_info, 'discount_value' => '', 'extras_param' => '', 'extras_sub_total' => '', 'vat_cost' => $vat_cost, 'cart_total' => number_format((double) $cart_total, (int) Application::Get('currency_decimals'), '.', ','), 'is_prepayment' => false, 'pre_payment_type' => '', 'pre_payment_value' => 0); $fisrt_part .= ' <tr><td colspan="3" nowrap="nowrap" height="10px"></td></tr> <tr><td colspan="3"><h4>' . _TOTAL . '</h4></td></tr> <tr><td>' . _SUBTOTAL . ' </td><td> : </td><td> ' . Currencies::PriceFormat($cart_total_wo_vat, '', '', $currency_format) . '</td></tr>'; $fisrt_part .= '<tr><td>' . _VAT . ' (' . $vat_value . '%) </td><td> : </td><td> ' . Currencies::PriceFormat($vat_cost, '', '', $currency_format) . '</td></tr>'; $fisrt_part .= '<tr><td>' . _PAYMENT_SUM . ' </td><td> : </td><td> <b>' . Currencies::PriceFormat($cart_total, '', '', $currency_format) . '</b></td></tr>'; $fisrt_part .= '<tr><td colspan="3" nowrap="nowrap" height="0px"></td></tr>'; $fisrt_part .= '<tr><td colspan="3">'; //if($additional_info != ''){ // $fisrt_part .= '<tr><td colspan="3" nowrap height="10px"></td></tr>'; // $fisrt_part .= '<tr><td colspan="3"><h4>'._ADDITIONAL_INFO.'</h4>'.$additional_info.'</td></tr>'; //} $second_part = ' </td></tr> </table><br />'; if ($payment_type == 'online') { $output .= $fisrt_part; $pp_params['credit_card_required'] = $collect_credit_card; $pp_params['cc_type'] = $cc_type; $pp_params['cc_holder_name'] = $cc_holder_name; $pp_params['cc_number'] = $cc_number; $pp_params['cc_cvv_code'] = $cc_cvv_code; $pp_params['cc_expires_month'] = $cc_expires_month; $pp_params['cc_expires_year'] = $cc_expires_year; $output .= PaymentIPN::DrawPaymentForm('online', $pp_params, $mode == 'TEST MODE' ? 'test' : 'real', false); $output .= $second_part; } else { if ($payment_type == 'paypal') { $output .= $fisrt_part; $pp_params['api_login'] = $paypal_email; $pp_params['notify'] = 'index.php?page=payment_notify_paypal'; $pp_params['paypal_form_type'] = 'single'; $pp_params['paypal_form_fields'] = ''; $pp_params['paypal_form_fields_count'] = ''; $output .= PaymentIPN::DrawPaymentForm('paypal', $pp_params, $mode == 'TEST MODE' ? 'test' : 'real', false); $output .= $second_part; } else { if ($payment_type == '2co') { $output .= $fisrt_part; $pp_params['api_login'] = $two_checkout_vendor; $pp_params['notify'] = 'index.php?page=payment_notify_2co'; $output .= PaymentIPN::DrawPaymentForm('2co', $pp_params, $mode == 'TEST MODE' ? 'test' : 'real', false); $output .= $second_part; } else { if ($payment_type == 'authorize') { $output .= $fisrt_part; $pp_params['api_login'] = $authorize_login_id; $pp_params['transaction_key'] = $authorize_transaction_key; $pp_params['notify'] = 'index.php?page=payment_notify_autorize_net'; // authorize.net accepts only USD, so we need to convert the sum into USD $pp_params['cart_total'] = number_format($pp_params['cart_total'] * Application::Get('currency_rate'), '2', '.', ','); $output .= PaymentIPN::DrawPaymentForm('authorize.net', $pp_params, $mode == 'TEST MODE' ? 'test' : 'real', false); $output .= $second_part; } } } } if ($draw) { echo $output; } else { $output; } }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. */ public function actionUpdate() { // check if user has permissions to updateProjects if (Yii::app()->user->checkAccess('updateProjects')) { if (Yii::app()->user->isManager) { // get Projects object from $_GET[id] parameter $model = $this->loadModel(); // if Projects form exist if (isset($_POST['Projects'])) { // set form elements to Projects model attributes $model->attributes = $_POST['Projects']; // validate and save if ($model->save()) { // save log $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'ProjectUpdated', 'log_resourceid' => $model->project_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id); Logs::model()->saveLog($attributes); // to prevent F5 keypress, redirect to create page $this->redirect(array('view', 'id' => $model->project_id)); } } // output update page $this->render('update', array('model' => $model, 'companies' => Companies::model()->findCompanyList(Yii::app()->user->id), 'currencies' => Currencies::model()->findAll())); } else { Yii::app()->controller->redirect(array("projects/view", 'id' => $_GET['id'])); } } else { throw new CHttpException(403, Yii::t('site', '403_Error')); } }
<?php include '../cfg/cfg.php'; include '../lib/dblib.php'; include '../lib/stdlib.php'; include '../lib/autoload.php'; /* Connect to DB */ db_connect($CFG->dbhost, $CFG->dbname, $CFG->dbuser, $CFG->dbpass); // memcached check $CFG->memcached = class_exists('Memcached'); $CFG->m = false; if ($CFG->memcached) { $CFG->m = new Memcached(); $CFG->m->addServer('localhost', 11211); } /* Load settings and timezone */ Settings::assign(); date_default_timezone_set($CFG->default_timezone); $dtz = new DateTimeZone($CFG->default_timezone); $dtz1 = new DateTime('now', $dtz); $CFG->timezone_offset = $dtz->getOffset($dtz1); /* Get Currencies */ $CFG->currencies = Currencies::get(); /* Current URL */ $CFG->self = basename($_SERVER['SCRIPT_FILENAME']); $CFG->cross_currency_trades = $CFG->cross_currency_trades == 'Y'; $CFG->currency_conversion_fee = $CFG->currency_conversion_fee * 0.01; $CFG->form_email = $CFG->support_email; $CFG->request_widthdrawal_id = $CFG->request_withdrawal_id;
/** * @return \yii\db\ActiveQuery */ public function getCurrency() { return $this->hasOne(Currencies::className(), ['id' => 'currency_id']); }
/** * Set configured Currency. * * @api * @author David Pauli <*****@*****.**> * @since 0.1.0 * @param String $locale The new used Locale. * @return boolean True if set the Locale works, false if not. */ public function setCurrency($currency) { return Currencies::setCurrency($currency); }
public static function Init() { global $objLogin, $objSettings, $objSiteDescription; self::$params['page'] = isset($_GET['page']) ? prepare_input($_GET['page']) : 'home'; self::$params['page_id'] = isset($_REQUEST['pid']) ? prepare_input_alphanumeric($_REQUEST['pid']) : 'home'; self::$params['system_page'] = isset($_GET['system_page']) ? prepare_input($_GET['system_page']) : ''; self::$params['type'] = isset($_GET['type']) ? prepare_input($_GET['type']) : ''; self::$params['admin'] = isset($_GET['admin']) ? prepare_input($_GET['admin']) : ''; self::$params['user'] = isset($_GET['user']) ? prepare_input($_GET['user']) : ''; self::$params['customer'] = isset($_GET['customer']) ? prepare_input($_GET['customer']) : ''; self::$params['patient'] = isset($_GET['patient']) ? prepare_input($_GET['patient']) : ''; self::$params['doctor'] = isset($_GET['doctor']) ? prepare_input($_GET['doctor']) : ''; self::$params['news_id'] = isset($_GET['nid']) ? (int) $_GET['nid'] : ''; self::$params['album_code'] = isset($_GET['acode']) ? strip_tags(prepare_input($_GET['acode'])) : ''; self::$params['search_in'] = isset($_POST['search_in']) ? prepare_input($_POST['search_in']) : ''; if (self::$params['search_in'] == '') { if (self::$PROJECT == 'BusinessDirectory') { self::$params['search_in'] = 'listings'; } else { if (self::$PROJECT == 'ShoppingCart') { self::$params['search_in'] = 'products'; } else { if (self::$PROJECT == 'HotelSite') { self::$params['search_in'] = 'rooms'; } } } } self::$params['lang'] = isset($_GET['lang']) ? prepare_input($_GET['lang']) : ''; self::$params['currency'] = isset($_GET['currency']) ? prepare_input($_GET['currency']) : ''; self::$params['token'] = isset($_GET['token']) ? prepare_input($_GET['token']) : ''; self::$params['listing_id'] = isset($_GET['lid']) ? (int) $_GET['lid'] : ''; self::$params['category_id'] = isset($_GET['cid']) ? (int) $_GET['cid'] : ''; self::$params['manufacturer_id'] = isset($_GET['mid']) ? (int) $_GET['mid'] : ''; self::$params['product_id'] = isset($_REQUEST['prodid']) ? (int) $_REQUEST['prodid'] : ''; $req_preview = isset($_GET['preview']) ? prepare_input($_GET['preview']) : ''; //------------------------------------------------------------------------------ // check and set token $token = md5(uniqid(rand(), true)); self::$params['token'] = $token; Session::Set('token', $token); //------------------------------------------------------------------------------ // save last visited page if (self::$params['allow_last_visited'] && !$objLogin->IsLoggedIn()) { $condition = !empty(self::$params['page']) && self::$params['page'] != 'home'; if (self::$PROJECT == 'HotelSite') { $condition = self::$params['page'] == 'booking' || self::$params['page'] == 'booking_details'; } else { if (self::$PROJECT == 'ShoppingCart') { $condition = self::$params['page'] == 'shopping_cart' || self::$params['page'] == 'checkout'; } else { if (self::$PROJECT == 'MedicalAppointment') { $condition = self::$params['page'] == 'checkout_signin'; } } } if ($condition) { Session::Set('last_visited', 'index.php?page=' . self::$params['page']); if (self::$params['page'] == 'pages' && !empty(self::$params['page_id']) && self::$params['page_id'] != 'home') { Session::Set('last_visited', Session::Get('last_visited') . '&pid=' . self::$params['page_id']); } else { if (self::$params['page'] == 'news' && !empty(self::$params['news_id'])) { Session::Set('last_visited', Session::Get('last_visited') . '&nid=' . self::$params['news_id']); } else { if (self::$params['page'] == 'listing' && !empty(self::$params['listing_id'])) { Session::Set('last_visited', Session::Get('last_visited') . '&lid=' . self::$params['listing_id']); } else { if (self::$params['page'] == 'category' && !empty(self::$params['category_id'])) { Session::Set('last_visited', Session::Get('last_visited') . '&cid=' . self::$params['category_id']); } else { if (self::$params['page'] == 'manufacturer' && !empty(self::$params['manufacturer_id'])) { Session::Set('last_visited', Session::Get('last_visited') . '&mid=' . self::$params['product_id']); } else { if (self::$params['page'] == 'product' && !empty(self::$params['product_id'])) { Session::Set('last_visited', Session::Get('last_visited') . '&prodid=' . self::$params['product_id']); } } } } } } } } //------------------------------------------------------------------------------ // set language if ($objLogin->IsLoggedInAsAdmin()) { $pref_lang = $objLogin->GetPreferredLang(); self::$params['lang'] = Languages::LanguageExists($pref_lang, false) ? $pref_lang : Languages::GetDefaultLang(); $language_info = Languages::GetLanguageInfo(self::$params['lang']); self::$params['lang_dir'] = $language_info['lang_dir']; self::$params['lang_name'] = $language_info['lang_name']; self::$params['lang_name_en'] = $language_info['lang_name_en']; self::$params['lc_time_name'] = $language_info['lc_time_name']; } else { if (!$objLogin->IsLoggedIn() && (self::$params['admin'] == 'login' || self::$params['admin'] == 'password_forgotten')) { self::$params['lang'] = Languages::GetDefaultLang(); $language_info = Languages::GetLanguageInfo(self::$params['lang']); self::$params['lang_dir'] = $language_info['lang_dir']; self::$params['lang_name'] = $language_info['lang_name']; self::$params['lang_name_en'] = $language_info['lang_name_en']; self::$params['lc_time_name'] = $language_info['lc_time_name']; } else { if (!empty(self::$params['lang']) && Languages::LanguageExists(self::$params['lang'])) { //self::$params['lang'] = self::$params['lang']; $language_info = Languages::GetLanguageInfo(self::$params['lang']); Session::Set('lang', self::$params['lang']); Session::Set('lang_dir', self::$params['lang_dir'] = $language_info['lang_dir']); Session::Set('lang_name', self::$params['lang_name'] = $language_info['lang_name']); Session::Set('lang_name_en', self::$params['lang_name_en'] = $language_info['lang_name_en']); Session::Set('lc_time_name', self::$params['lc_time_name'] = $language_info['lc_time_name']); } else { if (Session::Get('lang') != '' && Session::Get('lang_dir') != '' && Session::Get('lang_name') != '' && Session::Get('lang_name_en') != '') { self::$params['lang'] = Session::Get('lang'); self::$params['lang_dir'] = Session::Get('lang_dir'); self::$params['lang_name'] = Session::Get('lang_name'); self::$params['lang_name_en'] = Session::Get('lang_name_en'); self::$params['lc_time_name'] = Session::Get('lc_time_name'); } else { self::$params['lang'] = Languages::GetDefaultLang(); $language_info = Languages::GetLanguageInfo(self::$params['lang']); self::$params['lang_dir'] = isset($language_info['lang_dir']) ? $language_info['lang_dir'] : ''; self::$params['lang_name'] = isset($language_info['lang_name']) ? $language_info['lang_name'] : ''; self::$params['lang_name_en'] = isset($language_info['lang_name_en']) ? $language_info['lang_name_en'] : ''; self::$params['lc_time_name'] = isset($language_info['lc_time_name']) ? $language_info['lc_time_name'] : ''; } } } } //------------------------------------------------------------------------------ // set currency if (self::$PROJECT == 'ShoppingCart' || self::$PROJECT == 'HotelSite' || self::$PROJECT == 'BusinessDirectory' || self::$PROJECT == 'MedicalAppointment') { if (!empty(self::$params['currency']) && Currencies::CurrencyExists(self::$params['currency'])) { self::$params['currency_code'] = self::$params['currency']; $currency_info = Currencies::GetCurrencyInfo(self::$params['currency_code']); self::$params['currency_symbol'] = $currency_info['symbol']; self::$params['currency_rate'] = $currency_info['rate']; self::$params['currency_decimals'] = $currency_info['decimals']; self::$params['currency_symbol_place'] = $currency_info['symbol_placement']; Session::Set('currency_code', self::$params['currency']); Session::Set('currency_symbol', $currency_info['symbol']); Session::Set('currency_rate', $currency_info['rate']); Session::Set('currency_decimals', $currency_info['decimals']); Session::Set('symbol_placement', $currency_info['symbol_placement']); } else { if (Session::Get('currency_code') != '' && Session::Get('currency_symbol') != '' && Session::Get('currency_rate') != '' && Session::Get('currency_decimals') != '' && Session::Get('symbol_placement') != '' && Currencies::CurrencyExists(Session::Get('currency_code'))) { self::$params['currency_code'] = Session::Get('currency_code'); self::$params['currency_symbol'] = Session::Get('currency_symbol'); self::$params['currency_rate'] = Session::Get('currency_rate'); self::$params['currency_decimals'] = Session::Get('currency_decimals'); self::$params['currency_symbol_place'] = Session::Get('symbol_placement'); } else { $currency_info = Currencies::GetDefaultCurrencyInfo(); self::$params['currency_code'] = $currency_info['code']; self::$params['currency_symbol'] = $currency_info['symbol']; self::$params['currency_rate'] = $currency_info['rate']; self::$params['currency_decimals'] = $currency_info['decimals']; self::$params['currency_symbol_place'] = $currency_info['symbol_placement']; } } } // preview allowed only for admins // ----------------------------------------------------------------------------- if ($objLogin->IsLoggedInAsAdmin()) { if ($req_preview == 'yes' || $req_preview == 'no') { self::$params['preview'] = $req_preview; Session::Set('preview', self::$params['preview']); } else { if (self::$params['admin'] == '' && (Session::Get('preview') == 'yes' || Session::Get('preview') == 'no')) { self::$params['preview'] = Session::Get('preview'); } else { self::$params['preview'] = 'no'; Session::Set('preview', self::$params['preview']); } } } // *** get site description // ----------------------------------------------------------------------------- $objSiteDescription->LoadData(self::$params['lang']); // *** draw offline message // ----------------------------------------------------------------------------- if ($objSettings->GetParameter('is_offline')) { if (!$objLogin->IsLoggedIn() && self::$params['admin'] != 'login') { $offline_content = @file_get_contents('html/site_offline.html'); if (!empty($offline_content)) { $offline_content = str_ireplace(array('{HEADER_TEXT}', '{SLOGAN_TEXT}', '{OFFLINE_MESSAGE}', '{FOOTER}'), array($objSiteDescription->GetParameter('header_text'), $objSiteDescription->GetParameter('slogan_text'), $objSettings->GetParameter('offline_message'), $objSiteDescription->DrawFooter(false)), $offline_content); } else { $offline_content = $objSettings->GetParameter('offline_message'); } echo $offline_content; exit; } } // *** draw offline message // ----------------------------------------------------------------------------- if ($objSettings->GetParameter('is_offline')) { if (!$objLogin->IsLoggedIn() && self::$params['admin'] != 'login') { echo '<html>'; echo '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>'; echo '<body>' . $objSettings->GetParameter('offline_message') . '</body>'; echo '</html>'; exit; } } // *** run cron jobs file // ----------------------------------------------------------------------------- if ($objSettings->GetParameter('cron_type') == 'non-batch') { include_once 'cron.php'; } // *** default user page // ----------------------------------------------------------------------------- if (self::$PROJECT == 'MicroCMS') { if ($objLogin->IsLoggedInAsUser()) { if (self::$params['user'] == '' && self::$params['page'] == '') { self::$params['user'] = '******'; } } } else { if (self::$PROJECT == 'BusinessDirectory') { if ($objLogin->IsLoggedInAsCustomer()) { if (self::$params['customer'] == '' && self::$params['page'] == '') { self::$params['customer'] = 'home'; } } } else { if (self::$PROJECT == 'ShoppingCart') { if ($objLogin->IsLoggedInAsCustomer()) { if (self::$params['customer'] == '' && self::$params['page'] == '') { self::$params['customer'] = 'home'; } } } else { if (self::$PROJECT == 'HotelSite') { if ($objLogin->IsLoggedInAsCustomer()) { if (self::$params['customer'] == '' && self::$params['page'] == '') { self::$params['customer'] = 'home'; } } } else { if (self::$PROJECT == 'MedicalAppointment') { if ($objLogin->IsLoggedInAsPatient()) { if (self::$params['patient'] == '' && self::$params['page'] == '') { self::$params['patient'] = 'home'; } } if ($objLogin->IsLoggedInAsDoctor()) { if (self::$params['doctor'] == '' && self::$params['page'] == '') { self::$params['doctor'] = 'home'; } } } } } } } // *** get site template // ----------------------------------------------------------------------------- self::$params['template'] = $objSettings->GetTemplate() != '' ? $objSettings->GetTemplate() : DEFAULT_TEMPLATE; if ($objLogin->IsLoggedInAsAdmin() && (self::$params['preview'] != 'yes' || self::$params['admin'] != '')) { self::$params['template'] = 'admin'; } else { if (!$objLogin->IsLoggedIn() && (self::$params['admin'] == 'login' || self::$params['admin'] == 'password_forgotten')) { self::$params['template'] = 'admin'; } } // *** use direction of selected language // ----------------------------------------------------------------------------- self::$params['defined_left'] = self::$params['lang_dir'] == 'ltr' ? 'left' : 'right'; self::$params['defined_right'] = self::$params['lang_dir'] == 'ltr' ? 'right' : 'left'; self::$params['defined_alignment'] = self::$params['lang_dir'] == 'ltr' ? 'left' : 'right'; // *** prepare META tags // ----------------------------------------------------------------------------- if (self::$params['page'] == 'news' && self::$params['news_id'] != '') { $news_info = News::GetNewsInfo(self::$params['news_id'], self::$params['lang']); self::$params['tag_title'] = isset($news_info['header_text']) ? $news_info['header_text'] : $objSiteDescription->GetParameter('tag_title'); self::$params['tag_keywords'] = isset($news_info['header_text']) ? str_replace(' ', ',', $news_info['header_text']) : $objSiteDescription->GetParameter('tag_keywords'); self::$params['tag_description'] = isset($news_info['header_text']) ? $news_info['header_text'] : $objSiteDescription->GetParameter('tag_description'); } else { if (self::$params['system_page'] != '') { $objPage = new Pages(self::$params['system_page'], true); } else { $objPage = new Pages(self::$params['page_id'], true); } self::$params['tag_title'] = $objPage->GetParameter('tag_title') != '' ? $objPage->GetParameter('tag_title') : $objSiteDescription->GetParameter('tag_title'); self::$params['tag_keywords'] = $objPage->GetParameter('tag_keywords') != '' ? $objPage->GetParameter('tag_keywords') : $objSiteDescription->GetParameter('tag_keywords'); self::$params['tag_description'] = $objPage->GetParameter('tag_description') != '' ? $objPage->GetParameter('tag_description') : $objSiteDescription->GetParameter('tag_description'); if (self::$PROJECT == 'BusinessDirectory') { if (self::$params['page'] == 'category') { $category_info = Categories::GetCategoryInfo(self::$params['category_id']); self::$params['tag_title'] = isset($category_info['name']) ? strip_tags($category_info['name']) : ''; self::$params['tag_keywords'] = isset($category_info['name']) ? strip_tags($category_info['name']) : ''; self::$params['tag_description'] = isset($category_info['description']) ? strip_tags($category_info['description']) : ''; } else { if (self::$params['page'] == 'listing') { $listing_info = Listings::GetListingInfo(self::$params['listing_id']); self::$params['tag_title'] = isset($listing_info['business_name']) ? strip_tags($listing_info['business_name']) : ''; self::$params['tag_keywords'] = isset($listing_info['business_name']) ? trim(strip_tags($listing_info['business_name'])) : ''; self::$params['tag_description'] = isset($listing_info['business_address']) ? trim(strip_tags($listing_info['business_address'])) : self::$params['tag_title']; } } } } // *** included js libraries // ----------------------------------------------------------------------------- self::$params['js_included'] = array(); }
/** * Return invoice currency * * @param void * @return Currency */ function getCurrency() { if ($this->currency === false) { $this->currency = Currencies::findById($this->getCurrencyId()); } // if return $this->currency; }
public function parseCurrencies() { $currencies = new Currencies(); $keyParams = array(); foreach ($this->xmlProducts as $product) { $cur = $product->getCurrency(); if (!empty($cur) && !in_array($cur, $keyParams)) { array_push($keyParams, $cur); $currency = new Currency(); $currency->setCode($cur); $currencies->setUnit($currency); } } $currencyDAO = new CurrencyDAO(); $currencyDAO->insertUnits($currencies); $currencies = $currencyDAO->readUnits(); return $currencies; }
function price_format($a, $status = true) { // masuk 500000 ,, keluar jadi Rp. 500.000 $pengaturan = Pengaturan::where('akunId', '=', Session::get('akunid'))->remember(1)->first(); if ($pengaturan->checkoutType != 2) { $string = $a . ""; $tempKoma = ""; if (strpos($string, ".") != false) { $posKoma = strpos($string, "."); $tempKoma = substr($string, $posKoma); $tempKoma = str_replace(".", ",", $tempKoma); $tempKoma = substr($tempKoma, 0, 3); $string = substr($string, 0, strpos($string, ".")); } $jumDot = intval(strlen($string) / 3); if (strlen($string) % 3 == 0) { $jumDot = $jumDot - 1; } $aha = 0; for ($i = 0; $i < $jumDot; $i++) { $part[$i] = substr($string, strlen($string) - 3); $string = substr($string, 0, strlen($string) - 3); $aha++; } $temp = $string; $string = ""; for ($i = 0; $i < $jumDot; $i++) { $string = "." . $part[$i] . $string; } $currencies = Currencies::remember(1)->find($pengaturan->mataUang); $string = ucfirst($currencies->symbol) . ' ' . $temp . $string; if ($status == true) { if ($string != ucfirst($currencies->symbol) . " 0") { return $string; } else { $string = ucfirst($currencies->symbol) . ' 0'; return $string; } } else { if ($status == false) { return ''; } } } else { return ''; } }
/** * Get a reference to the ISO-4217 (Currencies) database singleton. * * @return \JeremyWorboys\IsoCodes\Currencies */ public static function currencies() { return Currencies::sharedInstance(); }
(SELECT ' . $selStatType . ' FROM ' . TABLE_ORDERS . ' o ' . $join_clause . ' WHERE SUBSTRING(o.payment_date, 6, 2) = \'03\' AND SUBSTRING(o.payment_date, 1, 4) = \'' . $year . '\' ' . $where_clause . ') as month3, (SELECT ' . $selStatType . ' FROM ' . TABLE_ORDERS . ' o ' . $join_clause . ' WHERE SUBSTRING(o.payment_date, 6, 2) = \'04\' AND SUBSTRING(o.payment_date, 1, 4) = \'' . $year . '\' ' . $where_clause . ') as month4, (SELECT ' . $selStatType . ' FROM ' . TABLE_ORDERS . ' o ' . $join_clause . ' WHERE SUBSTRING(o.payment_date, 6, 2) = \'05\' AND SUBSTRING(o.payment_date, 1, 4) = \'' . $year . '\' ' . $where_clause . ') as month5, (SELECT ' . $selStatType . ' FROM ' . TABLE_ORDERS . ' o ' . $join_clause . ' WHERE SUBSTRING(o.payment_date, 6, 2) = \'06\' AND SUBSTRING(o.payment_date, 1, 4) = \'' . $year . '\' ' . $where_clause . ') as month6, (SELECT ' . $selStatType . ' FROM ' . TABLE_ORDERS . ' o ' . $join_clause . ' WHERE SUBSTRING(o.payment_date, 6, 2) = \'07\' AND SUBSTRING(o.payment_date, 1, 4) = \'' . $year . '\' ' . $where_clause . ') as month7, (SELECT ' . $selStatType . ' FROM ' . TABLE_ORDERS . ' o ' . $join_clause . ' WHERE SUBSTRING(o.payment_date, 6, 2) = \'08\' AND SUBSTRING(o.payment_date, 1, 4) = \'' . $year . '\' ' . $where_clause . ') as month8, (SELECT ' . $selStatType . ' FROM ' . TABLE_ORDERS . ' o ' . $join_clause . ' WHERE SUBSTRING(o.payment_date, 6, 2) = \'09\' AND SUBSTRING(o.payment_date, 1, 4) = \'' . $year . '\' ' . $where_clause . ') as month9, (SELECT ' . $selStatType . ' FROM ' . TABLE_ORDERS . ' o ' . $join_clause . ' WHERE SUBSTRING(o.payment_date, 6, 2) = \'10\' AND SUBSTRING(o.payment_date, 1, 4) = \'' . $year . '\' ' . $where_clause . ') as month10, (SELECT ' . $selStatType . ' FROM ' . TABLE_ORDERS . ' o ' . $join_clause . ' WHERE SUBSTRING(o.payment_date, 6, 2) = \'11\' AND SUBSTRING(o.payment_date, 1, 4) = \'' . $year . '\' ' . $where_clause . ') as month11, (SELECT ' . $selStatType . ' FROM ' . TABLE_ORDERS . ' o ' . $join_clause . ' WHERE SUBSTRING(o.payment_date, 6, 2) = \'12\' AND SUBSTRING(o.payment_date, 1, 4) = \'' . $year . '\' ' . $where_clause . ') as month12 FROM ' . TABLE_ORDERS . ' GROUP BY month1 '; $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY, FETCH_ASSOC); $second_tab_content .= $nl . ' data.addRows(12);'; if ($result[1] >= 0) { $default_currency = Currencies::GetDefaultCurrency(); $second_tab_content .= draw_set_values($result[0], $chart_type, _INCOME, $default_currency); } $second_tab_content .= ' } </script>'; $second_tab_content .= '<script type="text/javascript">'; $second_tab_content .= $nl . ' google.load(\'visualization\', \'1\', {packages: [\'' . $chart_type . '\']});'; $second_tab_content .= $nl . ' google.setOnLoadCallback(drawVisualization);'; $second_tab_content .= $nl . ' function frmStatistics_Submit() { document.frmStatistics.submit(); }'; $second_tab_content .= '</script>'; $second_tab_content .= get_chart_changer('1_2', $chart_type, $year, 'mod_payments_statistics'); $second_tab_content .= '<div id="div_visualization" style="width:600px;height:310px;"> <img src="images/ajax_loading.gif" style="margin:100px auto;" alt="' . _LOADING . '..."></div>'; } else { $sql = 'SELECT COUNT(*) as cnt, c.abbrv as country_abbrv,
?> </span></h1> <!-- Временно --> <div style="clear: both;" class="operations"> <?php echo CHtml::link(Yii::t('app', 'Создать продукт'), array('create')); ?> <br/> <?php echo CHtml::link(Yii::t('app', 'Редактировать продукт'), array('update', 'id' => $model->getPrimaryKey())); ?> </div> <?php $this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array_merge(array('id', 'lang.name', 'price', 'points', array('name' => 'currency__id', 'value' => !empty($model->currency) ? Currencies::item($model->currency__id) : Yii::t('app', 'Валюта отсутствует')), array('name' => 'catalogues', 'value' => !empty($model->catalogues) ? implode(', ', CHtml::listData($model->catalogues, 'id', 'lang.name')) : Yii::t('app', 'не прикреплен к каталогам'))), $model->getCustomFieldsAsCDetailViewValues()))); ?> <h3><?php echo Yii::t('app', 'Изображения'); ?> </h3> <?php if (count($model->attachments) > 0) { ?> <ul> <?php foreach ($model->attachments as $attachment) { ?> <li><?php echo CHtml::link(CHtml::image($attachment->getThumbUrl(), $attachment->lang->description, array('title' => $attachment->lang->description)), $attachment->getFullUrl(), array('target' => '_blank')); ?>
<?php } ?> <div class="calc bigger dotted-over" <?php echo $usd_amount > 0 && Currencies::convertTo($api_amount, $api_currency, $currency_info['id'], 'up') > $available[$currency_info['currency']] ? '' : 'style="display:none;"'; ?> > <div class="label price-red"><?php echo Lang::string('merchant-insufficient-balance'); ?> </div> <div class="clear"></div> </div> <div class="mar_top2"></div> <ul class="list_empty" <?php echo $usd_amount > 0 && Currencies::convertTo($api_amount, $api_currency, $currency_info['id'], 'up') > $available[$currency_info['currency']] ? 'style="display:none;"' : ''; ?> > <li><input type="submit" name="submit" value="<?php echo Lang::string('merchant-finalize'); ?> " class="but_user" /></li> </ul> </form> <div class="clear"></div> <?php } ?> <div class="overlay"></div> </div> <?php
?> </h3> </div> <div class="portlet-body form form-horizontal"> <div class="form-body"> <div class="table-scrollable"> <table class="nav-list table table-hover" id="currencies"> <thead> <tr> <th><?php echo CurrenciesLang::model()->getAttributeLabel('name'); ?> </th> <th><?php echo Currencies::model()->getAttributeLabel('symbol'); ?> </th> <th><?php echo Yii::t('app', 'Операции'); ?> </th> </tr> </thead> <tbody> <?php foreach ($currencies as $currency) { ?> <tr> <td><?php echo CHtml::encode($currency->lang->name);
/** * Set currency as default * * @param void * @return null */ function set_as_default() { if ($this->active_currency->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if ($this->request->isSubmitted()) { $update = Currencies::setDefault($this->active_currency); if ($update && !is_error($update)) { $this->httpOk(); } else { $this->serveData($update); } // if } else { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if }
/** * @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 = ''; $objCurrencies = new Currencies(); if ($action == 'add') { $mode = 'add'; } else { if ($action == 'create') { if ($objCurrencies->AddRecord()) { $msg = draw_success_message(_ADDING_OPERATION_COMPLETED, false); $mode = 'view'; } else { $msg = draw_important_message($objCurrencies->error, false); $mode = 'add'; } } else { if ($action == 'edit') { $mode = 'edit'; } else {
/** * Returns all currencies. * * @return array All currencies. */ public function getCurrenciesItems() { return Currencies::getItems(); }
/** * @param int $count * * @return string */ public static function generateSampleProducts($count = 10) { // Type $typeIds = Producttype::getIdsOrCreateDummy(); // category $categoryIds = Productcategory::getIdsOrCreateSampelData(); // unit berat $unitIds = Units::getIdsOrCreateSampleUnits(); // parent_id $parentId = 0; $fake = static::getFake(); // // Buat Product $catId = $fake->getFake()->randomElement($categoryIds); $typeId = $fake->getFake()->randomElement($typeIds); $unitWeightId = $fake->getFake()->randomElement($unitIds); $unitWidthId = $fake->getFake()->randomElement($unitIds); $supplierIds = Suppliers::getRecordIdsOrCreate(); $currencyIds = Currencies::getIdsOrCreateSample(); // color $colorIds = Colors::getIdsOrCreate(); // gradeIds $gradeIds = Fabricgrade::getIdsOrCreate(); $productIds = array(); for ($rec = 0; $rec < $count; $rec++) { $product = $fake->getProduct()->product($catId, $typeId, $unitWeightId, $unitWidthId, $parentId, '\\Emayk\\Ics\\Repo\\Productcategory\\Productcategory'); $record = static::createRecord($product); $productId = $record->id; $productIds[] = $productId; // Image/ Photo Product $imagesIds[] = Images::getIdsOrCreate($productId, '\\Emayk\\Ics\\Repo\\Products\\Products'); // Supplier Product // Product Supplier (Product dapat dari Supplier mana ?) $supplierId = $fake->getFake()->randomElement($supplierIds); $supplierProduct = Productsuppliers::create(array('master_product_id' => $productId, 'master_supplier_id' => $supplierId)); $supplierProductId = $supplierProduct->id; // Create Detail // Buat Product Detail $unitId = $fake->getFake()->randomElement($unitIds); $colorId = $fake->getFake()->randomElement($colorIds); $gradeId = $fake->getFake()->randomElement($gradeIds); $currSp = $fake->getFake()->randomElement($currencyIds); $currSpm = $fake->getFake()->randomElement($currencyIds); $detailIds[] = Productdetails::getIdOrCreate($productId, $colorId, $unitId, $gradeId, $currSp, $currSpm); //Buat Stock // Buat Stock $stockIds[] = Stockproducts::createStock($productId); } foreach ($stockIds as $stockId) { for ($history = 0; $history < 9; $history++) { // Buat Stock Detail/History277 if ($history % 2 == 0 || $history == 0) { $typeHistory = 'in'; } else { $typeHistory = 'out'; } $firstHistory = $history == 0; // $stockHistoryIds[] = Stockproducthistory::createHistoryStockSample($stockId, $typeHistory, $firstHistory); } } return "Sudah Generate sebanyak " . count($productIds) . " records"; return s($productIds, $supplierProductId, $imagesIds, $detailIds); }
/** * Set configured Currency. * * @author David Pauli <*****@*****.**> * @param String $locale The new used Locale. * @return boolean True if set the Locale works, false if not. * @since 0.1.0 * @since 0.1.2 Add error reporting. */ public function setUsedCurrency($currency) { self::errorReset(); return Currencies::setCurrency($currency); }
/** * This function returns the parameter as string. * * @author David Pauli <*****@*****.**> * @since 0.0.0 * @since 0.1.0 Use a default Locale and Currency. * @api * @return String The parameter build with this product filter. */ private function getParameter() { $parameter = array(); array_push($parameter, "locale=" . Locales::getLocale()); array_push($parameter, "currency=" . Currencies::getCurrency()); if (!InputValidator::isEmpty($this->page)) { array_push($parameter, "page=" . $this->page); } if (!InputValidator::isEmpty($this->resultsPerPage)) { array_push($parameter, "resultsPerPage=" . $this->resultsPerPage); } if (!InputValidator::isEmpty($this->direction)) { array_push($parameter, "direction=" . $this->direction); } if (!InputValidator::isEmpty($this->sort)) { array_push($parameter, "sort=" . $this->sort); } if (!InputValidator::isEmpty($this->q)) { array_push($parameter, "q=" . $this->q); } if (!InputValidator::isEmpty($this->categoryID)) { array_push($parameter, "categoryId=" . $this->categoryID); } foreach ($this->IDs as $number => $id) { array_push($parameter, "id=" . $id); } return implode("&", $parameter); }
/** * Checks whether this currency is available in the passed context. * * @param Currencies $currencies * * @return bool */ public function isAvailableWithin(Currencies $currencies) { return $currencies->contains($this); }
/** * 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; }
/** * Create a new invoice * * @param void * @return null */ function add() { $this->wireframe->print_button = false; if (!Invoice::canAdd($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $default_currency = Currencies::findDefault(); if (!instance_of($default_currency, 'Currency')) { $this->httpError(HTTP_ERR_NOT_FOUND, 'Default currency not set'); } // if $time_report = null; $project = null; $timerecord_ids = null; $invoice_data = $this->request->post('invoice'); if (!is_array($invoice_data)) { $duplicate_invoice_id = $this->request->getId('duplicate_invoice_id'); $time_report_id = $this->request->getId('time_report_id'); $ticket_id = $this->request->getId('ticket_id'); // --------------------------------------------------- // Duplicate existing invoice // --------------------------------------------------- if ($duplicate_invoice_id) { $duplicate_invoice = Invoices::findById($duplicate_invoice_id); if (instance_of($duplicate_invoice, 'Invoice')) { $invoice_data = array('company_id' => $duplicate_invoice->getCompanyId(), 'company_address' => $duplicate_invoice->getCompanyAddress(), 'comment' => $duplicate_invoice->getComment(), 'status' => INVOICE_STATUS_DRAFT, 'project_id' => $duplicate_invoice->getProjectId(), 'note' => $duplicate_invoice->getNote(), 'currency_id' => $duplicate_invoice->getCurrencyId()); if (is_foreachable($duplicate_invoice->getItems())) { $invoice_data['items'] = array(); foreach ($duplicate_invoice->getItems() as $item) { $invoice_data['items'][] = array('description' => $item->getDescription(), 'unit_cost' => $item->getUnitCost(), 'quantity' => $item->getQuantity(), 'tax_rate_id' => $item->getTaxRateId(), 'total' => $item->getTotal(), 'subtotal' => $item->getSubtotal()); } // foreach } // if } // if // --------------------------------------------------- // Create invoice from time report // --------------------------------------------------- } else { if ($time_report_id) { $time_report = TimeReports::findById($time_report_id); if (instance_of($time_report, 'TimeReport')) { $project_id = $this->request->getId('project_id'); $client_company_id = null; if ($project_id) { $project = Projects::findById($project_id); } // if $time_report->setBillableFilter(BILLABLE_FILTER_BILLABLE); $conditions = $time_report->prepareConditions($this->logged_user, $project); if ($conditions === false) { $this->httpError(HTTP_ERR_OPERATION_FAILED, 'Failed to prepare time report conditions'); } // if $timerecord_ids = array(); $total_time = 0; $project_objects_table = TABLE_PREFIX . 'project_objects'; $invoice_time_records_table = TABLE_PREFIX . 'invoice_time_records'; $rows = db_execute_all("SELECT DISTINCT id,float_field_1 FROM {$project_objects_table} WHERE {$conditions}"); if (is_foreachable($rows)) { // find time records ids that needs to be attached to this invoice due to time record foreach ($rows as $row) { $timerecord_ids[] = (int) $row['id']; } // foreach $timerecords_filtered = Invoices::filterAvailableTimerecords($timerecord_ids); // calculate total time, but only if time record is not yet attached to the existing invoice if (is_foreachable($rows) && is_foreachable($timerecord_ids)) { foreach ($rows as $row) { if (!in_array($row['id'], $timerecord_ids)) { $total_time += (double) $row['float_field_1']; } // if } // foreach } // if } // if if ($total_time == 0) { $this->wireframe->addPageMessage(lang('You don\'t have any billable time records in this time report, or all bilable time records are already attached to existing invoice'), PAGE_MESSAGE_INFO); } else { if ($timerecords_filtered) { $this->wireframe->addPageMessage(lang('One or more billable timerecords in this time report are already attached to the existing invoice. They won\'t be counted in this one'), PAGE_MESSAGE_INFO); } } // if if (count($timerecord_ids) && $total_time) { if (instance_of($project, 'Project')) { $description = lang('Total of :total hours in :project project', array('total' => $total_time, 'project' => $project->getName())); } else { $description = lang('Total of :total hours', array('total' => $total_time)); } // if $invoice_data = array('due_on' => new DateValue(), 'currency_id' => $default_currency->getId(), 'project_id' => instance_of($project, 'Project') ? $project->getId() : null, 'company_id' => instance_of($project, 'Project') ? $project->getCompanyId() : null, 'items' => array(array('description' => $description, 'unit_cost' => $default_currency->getDefaultRate(), 'quantity' => $total_time, 'subtotal' => $default_currency->getDefaultRate() * $total_time, 'total' => $default_currency->getDefaultRate() * $total_time, 'tax_rate_id' => null, 'time_record_ids' => $timerecord_ids))); } // if } // if // --------------------------------------------------- // Create invoice from ticket // --------------------------------------------------- } else { if ($ticket_id) { $ticket = Tickets::findById($ticket_id); if (instance_of($ticket, 'Ticket')) { $timerecords_filtered = false; $items = array(); if ($ticket->getHasTime()) { $timerecords = TimeRecords::findByParent($ticket, array(BILLABLE_STATUS_BILLABLE), STATE_VISIBLE, $this->logged_user->getVisibility()); $timerecord_ids = array(); $ticket_total_time = 0; if (is_foreachable($timerecords)) { foreach ($timerecords as $timerecord) { if ($timerecord->getValue() > 0) { $timerecord_ids[] = $timerecord->getId(); } // if } // foreach $timerecords_filtered = Invoices::filterAvailableTimerecords($timerecord_ids); foreach ($timerecords as $timerecord) { if (in_array($timerecord->getId(), $timerecord_ids)) { $ticket_total_time += $timerecord->getValue(); } // if } // foreach $items[] = array('description' => lang('Ticket: :ticket_name', array('ticket_name' => $ticket->getName())), 'unit_cost' => $default_currency->getDefaultRate(), 'quantity' => $ticket_total_time, 'subtotal' => $default_currency->getDefaultRate() * $ticket_total_time, 'total' => $default_currency->getDefaultRate() * $ticket_total_time, 'tax_rate_id' => null, 'time_record_ids' => $timerecord_ids); } // if } // if $tasks = $ticket->getTasks(); if (is_foreachable($tasks)) { foreach ($tasks as $task) { if ($task->getHasTime()) { $timerecords = TimeRecords::findByParent($task, array(BILLABLE_STATUS_BILLABLE), STATE_VISIBLE, $this->logged_user->getVisibility()); $task_total_time = 0; $timerecord_ids = array(); if (is_foreachable($timerecords)) { foreach ($timerecords as $timerecord) { if ($timerecord->getValue() > 0) { $timerecord_ids[] = $timerecord->getId(); } // if } // foreach $timerecords_filtered = $timerecords_filtered || Invoices::filterAvailableTimerecords($timerecord_ids); foreach ($timerecords as $timerecord) { if (in_array($timerecord->getId(), $timerecord_ids)) { $task_total_time += $timerecord->getValue(); } // if } // foreach if (is_foreachable($timerecord_ids) && $task_total_time > 0) { $items[] = array('description' => lang('Task: :task_name', array('task_name' => $task->getName())), 'unit_cost' => $default_currency->getDefaultRate(), 'quantity' => $task_total_time, 'subtotal' => $default_currency->getDefaultRate() * $task_total_time, 'total' => $default_currency->getDefaultRate() * $task_total_time, 'tax_rate_id' => null, 'time_record_ids' => $timerecord_ids); } // if } // if } // if } // foreach } // if $project = $ticket->getProject(); $invoice_data = array('due_on' => new DateValue(), 'currency_id' => $default_currency->getId(), 'project_id' => $ticket->getProjectId(), 'company_id' => instance_of($project, 'Project') ? $project->getCompanyId() : null, 'time_record_ids' => $timerecord_ids, 'items' => $items); if ($timerecords_filtered) { $this->wireframe->addPageMessage(lang('One or more billable timerecords in this time report are already attached to the existing invoice. They won\'t be counted in this one'), PAGE_MESSAGE_INFO); } // if } // if } } } // if // --------------------------------------------------- // Start blank // --------------------------------------------------- if (!is_array($invoice_data)) { $invoice_data = array('due_on' => new DateValue(), 'currency_id' => $default_currency->getId(), 'project_id' => instance_of($project, 'Project') ? $project->getId() : null, 'time_record_ids' => null); } // if } // if $invoice_notes = InvoiceNoteTemplates::findAll(); $invoice_item_templates = InvoiceItemTemplates::findAll(); $this->smarty->assign(array('invoice_data' => $invoice_data, 'tax_rates' => TaxRates::findAll(), 'invoice_notes' => $invoice_notes, 'invoice_item_templates' => $invoice_item_templates, 'original_note' => $this->active_invoice->getNote())); $cleaned_notes = array(); if (is_foreachable($invoice_notes)) { foreach ($invoice_notes as $invoice_note) { $cleaned_notes[$invoice_note->getId()] = $invoice_note->getContent(); } // foreach } // if js_assign('invoice_notes', $cleaned_notes); js_assign('original_note', $this->active_invoice->getNote()); $cleaned_item_templates = array(); if (is_foreachable($invoice_item_templates)) { foreach ($invoice_item_templates as $invoice_item_template) { $cleaned_item_templates[$invoice_item_template->getId()] = array('description' => $invoice_item_template->getDescription(), 'unit_cost' => $invoice_item_template->getUnitCost(), 'quantity' => $invoice_item_template->getQuantity(), 'tax_rate_id' => $invoice_item_template->getTaxRateId()); } // foreach } // if js_assign('invoice_item_templates', $cleaned_item_templates); js_assign('company_details_url', assemble_url('invoice_company_details')); js_assign('move_icon_url', get_image_url('move.gif')); if ($this->request->isSubmitted()) { db_begin_work(); $this->active_invoice->setAttributes($invoice_data); $this->active_invoice->setCreatedBy($this->logged_user); $invoice_company = Companies::findById(array_var($invoice_data, 'company_id', null)); $this->active_invoice->setCompanyName($invoice_company->getName()); $save = $this->active_invoice->save(); if ($save && !is_error($save)) { $counter = 0; if (is_foreachable($invoice_data['items'])) { foreach ($invoice_data['items'] as $invoice_item_data) { $invoice_item = new InvoiceItem(); $invoice_item->setAttributes($invoice_item_data); $invoice_item->setInvoiceId($this->active_invoice->getId()); $invoice_item->setPosition($counter + 1); $item_save = $invoice_item->save(); if ($item_save && !is_error($item_save)) { $invoice_item->setTimeRecordIds(array_var($invoice_item_data, 'time_record_ids')); $counter++; } else { // error in invoice_item_data } // if } // foreach } // if if ($counter > 0) { db_commit(); flash_success('Invoice ":number" has been created', array('number' => $this->active_invoice->getName())); $this->redirectToUrl($this->active_invoice->getViewUrl()); } else { db_rollback(); $this->smarty->assign('errors', new ValidationErrors(array('items' => lang('Invoice items data is not valid. All descriptions are required and there need to be at least one unit with cost set per item!')))); } // if } else { db_rollback(); $this->smarty->assign('errors', $save); } // if } // if }
/** * Returns formatted price value * @param $price * @param $cur_symbol * @param $cur_symbol_place * @param $currency_format * @param $decimal_points */ public static function PriceFormat($price, $cur_symbol = '', $cur_symbol_place = '', $currency_format = 'american', $decimal_points = '') { if (Application::Get('currency_code') == '') { $default_currency = Currencies::GetDefaultCurrencyInfo(); $currency_code = $default_currency['code']; $currency_symbol = $default_currency['symbol']; $currency_symbol_place = $default_currency['symbol_placement']; $decimal_points = $default_currency['decimals']; } else { $currency_symbol = $cur_symbol != '' ? $cur_symbol : Application::Get('currency_symbol'); $currency_symbol_place = $cur_symbol_place != '' ? $cur_symbol_place : Application::Get('currency_symbol_place'); $decimal_points = $decimal_points != '' ? $decimal_points : Application::Get('currency_decimals'); } if ($currency_symbol_place == 'left') { $field_value_pre = $currency_symbol; $field_value_post = ''; } else { $field_value_pre = ''; $field_value_post = $currency_symbol; } if ($currency_format == 'european') { $price = str_replace('.', '#', $price); $price = str_replace(',', '.', $price); $price = str_replace('#', '.', $price); return $field_value_pre . number_format((double) $price, (int) $decimal_points, ',', '.') . $field_value_post; } else { return $field_value_pre . number_format((double) $price, (int) $decimal_points, '.', ',') . $field_value_post; } }
?> </div> <br /> <div class="col-sm-2 control-label">Portfolio:</div> <div class="col-sm-2"> <?php $ports = Portfolios::model()->findAll(['condition' => 'client_id = :client_id', 'params' => array(':client_id' => $client_id)]); $list = CHtml::listData($ports, 'id', 'portfolio'); echo CHtml::dropDownList('portfolio', $portfolio, $list, ['id' => 'portfolio', 'empty' => '-- Select --', 'onchange' => 'overviewload()', 'class' => "form-control"]); ?> </div> <div class="col-sm-2 control-label">Currency:</div> <div class="col-sm-2"> <?php echo CHtml::dropDownList('currency', 'USD', CHtml::listData(Currencies::model()->findAll(), 'currency', 'currency'), ['id' => 'currency', 'empty' => '-- Select --', 'onchange' => 'overviewload()', 'class' => "form-control"]); ?> </div> <div class="col-sm-2 control-label">Instrument:</div> <div class="col-sm-2"> <?php echo CHtml::dropDownList('instrument', '', CHtml::listData(Instruments::model()->findAll(), 'id', 'instrument'), ['id' => 'instrument', 'empty' => '-- Select --', 'onchange' => 'overviewload()', 'class' => "form-control"]); ?> </div> </div> </form> <div id="overview-view"></div> <div id="wait" style="display:none;width:69px;height:89px;position:absolute;top:50%;left:50%;padding:2px;">