public function run() { $this->log("Start parse"); $currenciesList = CHtml::listData(Currency::model()->findAll(), 'code', function ($data) { return $data; }); $url = "http://www.cbr.ru/scripts/XML_daily.asp"; // URL, XML документ, всегда содержит актуальные данные $rate = null; // загружаем полученный документ в дерево XML if (!($xml = simplexml_load_file($url))) { $this->log("XML loading error"); die('XML loading error'); } foreach ($xml->Valute as $m) { $code = strtolower($m->CharCode); if (key_exists($code, $currenciesList)) { $rate = (double) str_replace(",", ".", (string) $m->Value); $this->log("Rate {$code} is: " . $rate); if (!empty($rate)) { $currency = $currenciesList[$code]; $currency->rate = $rate; if ($currency->update(['rate'])) { $this->log("Rate {$code} saved successfully"); } else { $this->log("Rate {$code} not saved"); } } else { $this->log("Rate {$code} is empty"); } } } $this->log("Finish parse"); }
public function actionUpdate($id) { $model = new SettingsForm(); if (isset($_POST['SettingsForm'])) { $model->attributes = $_POST['SettingsForm']; if ($model->validate() && $model->save()) { $this->redirect(array('index')); } } else { $model->loadDataFromStore($id); } $directories = glob(Yii::getPathOfAlias('webroot.themes') . "/*", GLOB_ONLYDIR); $themes = array(); foreach ($directories as $directory) { $themes[] = basename($directory); } $layouts = CHtml::listData(Layout::model()->findAll(), 'layout_id', 'name'); $countries = CHtml::listData(Country::model()->findAll(), 'country_id', 'name'); $zones = CHtml::listData(Zone::model()->findAllByAttributes(array('country_id' => $model->country)), 'zone_id', 'name'); $languages = CHtml::listData(Language::model()->findAll(), 'language_id', 'name'); $currencies = CHtml::listData(Currency::model()->findAll(), 'currency_id', 'title'); $yesNoOptions = array(0 => Yii::t('settings', 'No'), 1 => Yii::t('settings', 'Yes')); $lengthClasses = CHtml::listData(LengthClassDescription::model()->findAll(), 'length_class_id', 'title'); $weightClasses = CHtml::listData(WeightClassDescription::model()->findAll(), 'weight_class_id', 'title'); $taxesOptions = array("" => Yii::t("settings", "--- None ---"), "shipping" => Yii::t("settings", "Shipping Address"), "payment" => Yii::t("settings", "Payment Address")); $customerGroups = CHtml::listData(CustomerGroupDescription::model()->findAll(), 'customer_group_id', 'name'); $informations = array_merge(array(0 => Yii::t("settings", "--- None ---")), CHtml::listData(InformationDescription::model()->findAll(), 'information_id', 'title')); // TODO: localisation $orderStatuses = CHtml::listData(OrderStatus::model()->findAllByAttributes(array('language_id' => 1)), 'order_status_id', 'name'); // TODO: localisation $returnStatuses = CHtml::listData(ReturnStatus::model()->findAllByAttributes(array('language_id' => 1)), 'return_status_id', 'name'); $mailProtocols = array("mail" => Yii::t("settings", "Mail"), "smtp" => Yii::t("settings", "SMTP")); $this->render('update', array('model' => $model, 'themes' => $themes, 'layouts' => $layouts, 'countries' => $countries, 'zones' => $zones, 'languages' => $languages, 'currencies' => $currencies, 'yesNoOptions' => $yesNoOptions, 'lengthClasses' => $lengthClasses, 'weightClasses' => $weightClasses, 'taxesOptions' => $taxesOptions, 'customerGroups' => $customerGroups, 'informations' => $informations, 'orderStatuses' => $orderStatuses, 'returnStatuses' => $returnStatuses, 'mailProtocols' => $mailProtocols)); }
public static function updateStatusAd() { if (Yii::app()->request->getIsAjaxRequest() || !issetModule('paidservices')) { return false; } if (!oreInstall::isInstalled()) { return false; } $data = Yii::app()->statePersister->load(); // Обновляем статусы 1 раз в сутки if (isset($data['next_check_status'])) { if ($data['next_check_status'] < time()) { $data['next_check_status'] = time() + self::TIME_UPDATE; Yii::app()->statePersister->save($data); self::checkStatusAd(); self::clearApartmentsStats(); // обновляем курсы валют Currency::model()->parseCbr(); } } else { $data['next_check_status'] = time() + self::TIME_UPDATE; Yii::app()->statePersister->save($data); self::checkStatusAd(); self::clearApartmentsStats(); } }
public function run() { $models = Currency::model()->findAll(); if (empty($models)) { return; } $this->render($this->view, ['models' => $models]); }
public static function updateStatusAd() { if (Yii::app()->request->getIsAjaxRequest()) { return false; } if (!oreInstall::isInstalled()) { return false; } $data = Yii::app()->statePersister->load(); // Обновляем статусы 1 раз в сутки if (isset($data['next_check_status'])) { if ($data['next_check_status'] < time()) { $data['next_check_status'] = time() + self::TIME_UPDATE; Yii::app()->statePersister->save($data); if (issetModule('paidservices')) { self::checkStatusAd(); // обновляем курсы валют Currency::model()->parseCbr(); } self::clearDrafts(); self::clearApartmentsStats(); self::clearUsersSessions(); self::checkDateEndActivity(); self::deleteIPFromBlocklist(); } } else { $data['next_check_status'] = time() + self::TIME_UPDATE; Yii::app()->statePersister->save($data); if (issetModule('paidservices')) { self::checkStatusAd(); // обновляем курсы валют Currency::model()->parseCbr(); } self::clearDrafts(); self::clearApartmentsStats(); self::clearUsersSessions(); self::checkDateEndActivity(); self::deleteIPFromBlocklist(); } // Тарифные планы - 2 раза в сутки if (issetModule('tariffPlans') && issetModule('paidservices')) { if (isset($data['next_check_status_users_tariffs'])) { if ($data['next_check_status_users_tariffs'] < time()) { $data['next_check_status_users_tariffs'] = time() + self::TIME_UPDATE_TARIFF_PLANS; Yii::app()->statePersister->save($data); self::checkTariffPlansUsers(); } } else { $data['next_check_status_users_tariffs'] = time() + self::TIME_UPDATE_TARIFF_PLANS; Yii::app()->statePersister->save($data); self::checkTariffPlansUsers(); } } Yii::app()->cache->flush(); }
public function actionDelete($ids) { $ids = explode(',', $ids); if (count($ids) > 0) { foreach ($ids as $id) { $currency = Currency::model()->findByPk($id); $currency->delete(); } } $this->redirect(array('index')); }
public static function parse($date) { $date = date('Y-m-d', strtotime($date)); require_once 'sources/CurrencySourceBase.php'; /** @var CurrencyRaw[][] $data */ $data = []; $codes = []; foreach (static::$sources as $lang => $sourceClass) { require_once 'sources/' . $sourceClass . '.php'; /** @var CurrencySourceBase $source */ $source = new $sourceClass(); $data[$lang] = $source->parse($date); $codes = array_merge($codes, array_keys($data[$lang])); } // CVarDumper::dump($data, 3, 1);return; if (isset($data['ru'][self::UAH_CODE])) { $costRubUah = $data['ru'][self::UAH_CODE]->cost; } else { throw new Exception('Cost RUB:UAH not found'); } $tr = Yii::app()->db->beginTransaction(); Currency::model()->deleteAll('date = :date', [':date' => $date]); foreach ($codes as $code) { try { /** @var CurrencyRaw $ru */ /** @var CurrencyRaw $ua */ $ru = empty($data['ru']) == false && empty($data['ru'][$code]) == false ? $data['ru'][$code] : null; $ua = empty($data['ua']) == false && empty($data['ua'][$code]) == false ? $data['ua'][$code] : null; if (!$ru && !$ua) { continue; } $currency = new Currency(); $currency->date = $date; $currency->num_code = $code; $currency->char_code = $ru ? $ru->char_code : $ua->char_code; $currency->name_ru = $ru ? $ru->name : null; $currency->name_ua = $ua ? $ua->name : null; $currency->nominal_ru = $ru ? $ru->nominal : null; $currency->nominal_ua = $ua ? $ua->nominal : null; $currency->cost_rub = $ru ? $ru->cost / $currency->nominal_ru : null; $currency->cost_uah = $ua ? $ua->cost / $currency->nominal_ua : null; $currency->diff = $ru && $ua ? $currency->cost_uah / $costRubUah - $currency->cost_rub : null; if ($currency->save(true) == false) { // CVarDumper::dump([$currency->getAttributes(), $currency->errors], 3, 1); // $tr->rollback(); // throw new Exception('Con not save currency in DB'); } } catch (Exception $ex) { continue; } } $tr->commit(); return true; }
public function actionActivate() { $id = (int) $_GET['id']; $action = $_GET['action']; if ($id) { $model = Currency::model()->findByPk($id); if ($model->is_default == 1 && $action != 'activate') { Yii::app()->end(); } } parent::actionActivate(); }
public function init() { # php.ini - date.timezone $this->generationDate = date('c', time()); # если нет модуля "Страна->регион->город" задаём строго $this->country = 'Россия'; $this->region = 'Москва и московская область'; # валюта $this->currency = 'RUR'; # param('siteCurrency', 'RUR'); if (!isFree()) { $activeCurrencyId = Currency::getDefaultValuteId(); $activeCurrency = Currency::model()->findByPk($activeCurrencyId); $this->currency = $activeCurrency && isset($activeCurrency->char_code) ? $activeCurrency->char_code : $this->currency; } }
public function updateAction() { $model = new Gateway(); $this->performAjaxValidation($model); // Uncomment the following line if AJAX validation is needed if (isset($_POST['model']) && $_POST['model'] == 'Gateway') { if (isset($_POST['ajax'])) { $model->fillFromArray($_POST, FALSE); $model->user_id_updated = $this->user->user_id; $model->updated = 'NOW():sql'; $model->model_uset_id = $this->user->user_id; if ($model->save()) { Message::echoJsonSuccess(__('gateway_updated')); } else { Message::echoJsonError(__('gateway_no_updated')); } die; } $model->save(); $this->redirect(); die; } $id = AF::get($this->params, 'id', FALSE); if (!$id) { throw new AFHttpException(0, 'no_id'); } if (!$model->cache()->findByPk($id)) { throw new AFHttpException(0, 'incorrect_id'); } $currencies = Currency::model()->cache()->findAllInArray(); $methods = Method::model()->cache()->findAllInArray(); $systems = PSystem::model()->cache()->findAllInArray(); $gateways = Gateway::model()->cache()->findAllInArray(); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params)); $models = AFActiveDataProvider::models('GatewayLimit', $this->params, $pagination); $limits = $models->getLimitsByGatewayId($id); Assets::js('jquery.form'); $this->addToPageTitle('Update Gateway'); $this->render('update', array('model' => $model, 'currencies' => $currencies, 'limits' => $limits, 'methods' => $methods, 'systems' => $systems, 'gateways' => $gateways)); }
function newretentionAction() { $clearArray = array('campaign_id', 'detail_dates', 'detail_affiliates', 'detail_sid', 'simple', 'currency_id', 'country_id'); $this->filter($clearArray); $filterFields = $this->params; //AFActiveDataProvider::clearDateArray($this->params, array('r_dates')); if (!isset($filterFields['circle']) || isset($filterFields['circle']) && !$filterFields['circle']) { $filterFields['circle'] = 0; } if ($clearArray) { foreach ($clearArray as $value) { if (isset($filterFields[$value])) { $filterFields[$value] = explode(',', $filterFields[$value]); } } } // build filter select datasources $currencies = Currency::model()->cache()->findAllInArray(); $countries = Country::model()->cache()->findAllInArray(); $campaigns = isset($filterFields['campaign_id']) ? $filterFields['campaign_id'] : null; $country_id = isset($filterFields['country_id']) ? $filterFields['country_id'] : null; $currency_id = isset($filterFields['currency_id']) ? $filterFields['currency_id'] : null; $groupDate = isset($filterFields['detail_dates']) ? false : true; $groupAfid = isset($filterFields['detail_affiliates']) ? false : true; $groupSid = isset($filterFields['detail_sid']) ? false : true; $msql = SafeMySQL::getInstance(); $sql = 'SELECT campaign_id, campaign_name FROM `campaigns` ORDER BY `campaign_id`'; $campaignsFilterTemp = $msql->getAll($sql); $campaignsFilter = array(); foreach ($campaignsFilterTemp as $v) { $campaignsFilter[$v['campaign_id']] = $v; } unset($campaignsFilterTemp); $sql = 'SELECT aff_id, aff_name FROM `affiliates` ORDER BY `aff_id`'; $affidsTemp = $msql->getAll($sql); $affids = array(); foreach ($affidsTemp as $v) { $affids[$v['aff_id']] = $v; } unset($affidsTemp); $where = ''; if ($campaigns) { $where .= $msql->parse(" AND `campaign_id` IN (?a)", $campaigns); } if ($currency_id) { $where .= $msql->parse(" AND `campaign_id` IN ( select campaign_id from campaigns where currency_id in (?a))", $currency_id); } if ($country_id) { $where .= $msql->parse(" AND `campaign_id` IN ( select campaign_id from campaigns where country_id in (?a))", $country_id); } if (!isset($filterFields['r_dates'])) { $filterFields['r_dates'] = date('d.m.Y-d.m.Y'); } $dates = explode('-', $filterFields['r_dates']); if (isset($dates[0]) && isset($dates[1])) { $dateStartT = explode('.', $dates[0]); $dateStart = array_reverse($dateStartT); $dateStart = implode('-', $dateStart); $dateFinishT = explode('.', $dates[1]); $dateFinish = array_reverse($dateFinishT); $dateFinish = implode('-', $dateFinish); $where .= $msql->parse(" AND DATE(`date`) BETWEEN ?s AND ?s", $dateStart, $dateFinish); unset($dateStartT, $dateFinishT); } if (!isset($filterFields['report_date'])) { $filterFields['report_date'] = date('d.m.Y'); } $reportDateArray = explode('.', $filterFields['report_date']); if (isset($reportDateArray[0]) && isset($reportDateArray[1]) && isset($reportDateArray[2])) { $reportDate = array_reverse($reportDateArray); $reportDate = implode('-', $reportDate); $where .= $msql->parse("AND `id_date` <= ?s", $reportDate); unset($reportDate, $reportDateArray); } $where .= $msql->parse("AND CAST(SUBSTR(`col_name`,2,1) AS UNSIGNED) <= ?i", (int) $filterFields['circle']); $sql = "\n SELECT " . ($groupDate ? "'ALL' AS " : '') . "`date`, `campaign_id`, " . ($groupAfid ? "'ALL' AS " : '') . "`aff_id`, " . ($groupSid ? "'ALL' AS " : '') . "`sid`, `col_name`, SUM(`data`) AS `data`, `currency_id`\n FROM (\n SELECT `date`, `campaign_id`, `aff_id`, `sid`, `col_name`, `data`, `currency_id`\n FROM (\n SELECT `retention_history`.*, `campaigns`.`currency_id`\n FROM `retention_history`\n LEFT JOIN `campaigns` USING(`campaign_id`)\n WHERE 1 " . $where . "\n ORDER BY `id_date` DESC\n ) `t`\n GROUP BY `date`, `campaign_id`, `aff_id`, `col_name`\n ) `t2`\n GROUP BY " . ($groupDate ? '' : "`date`, ") . "`campaign_id`, " . ($groupAfid ? '' : "`aff_id`, ") . "`col_name`\n "; $result = $msql->getAll($sql); $report = array(); $reportCur = array(); $countR = 0; foreach ($result as $row) { if (isset($row['col_name'])) { $colNameArr = explode('_', $row['col_name']); if (isset($colNameArr[0])) { $countCycles = (int) substr($colNameArr[0], 1, 1); if ($countCycles > $countR) { $countR = $countCycles; } } } if (!isset($report[$row['date'] . '_' . $row['campaign_id'] . '_' . $row['aff_id']]['c' . ($row['col_name'][1] + 1) . '_gross'])) { if (!isset($report[$row['date'] . '_' . $row['campaign_id'] . '_' . $row['aff_id']])) { $report[$row['date'] . '_' . $row['campaign_id'] . '_' . $row['aff_id']] = array(); } $report[$row['date'] . '_' . $row['campaign_id'] . '_' . $row['aff_id']] += self::cycle_array($row['col_name'][1]); } $report[$row['date'] . '_' . $row['campaign_id'] . '_' . $row['aff_id']][$row['col_name']] = $row['data']; if (!isset($reportCur[$row['date'] . '_' . $row['campaign_id'] . '_' . $row['aff_id']])) { $reportCur[$row['date'] . '_' . $row['campaign_id'] . '_' . $row['aff_id']] = $row['currency_id']; } } $countR++; unset($result); foreach ($report as $row => $data) { for ($i = 0; isset($data['c' . ($i + 1) . '_gross']); $i++) { $report[$row]['c' . $i . '_gross'] = (int) $report[$row]['c' . $i . '_gross']; $report[$row]['c' . $i . '_declined'] = (int) $report[$row]['c' . $i . '_declined']; $report[$row]['c' . $i . '_void'] = (int) $report[$row]['c' . $i . '_void']; $report[$row]['c' . $i . '_pending'] = (int) $report[$row]['c' . $i . '_pending']; $report[$row]['c' . $i . '_rma'] = (int) $report[$row]['c' . $i . '_rma']; $report[$row]['c' . $i . '_partial_refund'] = (int) $report[$row]['c' . $i . '_partial_refund']; $report[$row]['c' . $i . '_chargeback'] = (int) $report[$row]['c' . $i . '_chargeback']; if ($i) { $report[$row]['c' . $i . '_discounts'] = (int) $report[$row]['c' . $i . '_discounts']; } $report[$row]['c' . $i . '_decline_rate'] = $report[$row]['c' . $i . '_gross'] ? round($report[$row]['c' . $i . '_declined'] / $report[$row]['c' . $i . '_gross'], 4) : NULL; $report[$row]['c' . $i . '_paid'] = $report[$row]['c' . $i . '_gross'] - $report[$row]['c' . $i . '_declined']; $report[$row]['c' . $i . '_void_rate'] = $report[$row]['c' . $i . '_paid'] ? round($report[$row]['c' . $i . '_void'] / $report[$row]['c' . $i . '_paid'], 4) : NULL; $report[$row]['c' . $i . '_net_approved'] = $report[$row]['c' . $i . '_paid'] - $report[$row]['c' . $i . '_void']; $report[$row]['c' . $i . '_approval_rate'] = $report[$row]['c' . $i . '_paid'] ? round($report[$row]['c' . $i . '_net_approved'] / $report[$row]['c' . $i . '_paid'], 4) : NULL; $report[$row]['c' . $i . '_cancelled'] = $report[$row]['c' . $i . '_paid'] - $report[$row]['c' . $i . '_pending'] - $report[$row]['c' . ($i + 1) . '_gross']; $report[$row]['c' . $i . '_cancel_rate'] = $report[$row]['c' . $i . '_paid'] ? round($report[$row]['c' . $i . '_cancelled'] / $report[$row]['c' . $i . '_paid'], 4) : NULL; $report[$row]['c' . $i . '_subscriptions_approved'] = $report[$row]['c' . $i . '_paid'] - $report[$row]['c' . $i . '_cancelled']; $report[$row]['c' . $i . '_rma_rate'] = $report[$row]['c' . $i . '_paid'] ? round($report[$row]['c' . $i . '_rma'] / $report[$row]['c' . $i . '_paid'], 4) : NULL; // $report[$row]['c'.$i.'_pending_rebill'] = $report[$row]['c'.$i.'_pending'] - $report[$row]['c'.$i.'_rma']; $report[$row]['c' . $i . '_chargeback_rate'] = $report[$row]['c' . $i . '_paid'] ? round($report[$row]['c' . $i . '_chargeback'] / $report[$row]['c' . $i . '_paid'], 4) : NULL; if ($i) { $report[$row]['c' . $i . '_retention_count_rate'] = $report[$row]['c' . ($i - 1) . '_paid'] ? round($report[$row]['c' . $i . '_paid'] / $report[$row]['c' . ($i - 1) . '_paid'], 4) : NULL; $report[$row]['c' . $i . '_retention_rate'] = $report[$row]['c' . $i . '_potential_revenue'] ? round($report[$row]['c' . $i . '_net_revenue'] / $report[$row]['c' . $i . '_potential_revenue'], 4) : NULL; } } if (isset($report[$row]['c' . $countR . '_gross']) && !$report[$row]['c' . $countR . '_gross']) { unset($report[$row]['c' . $countR . '_gross']); } } $extraFields = array(array('gross', 'declined', 'decline_rate', 'paid', 'void', 'void_rate', 'net_approved', 'approval_rate', 'cancelled', 'cancel_rate', 'subscriptions_approved', 'pending', 'rma', 'rma_rate', 'partial_refund', 'refund_amount', 'chargeback', 'chargeback_rate', 'chargeback_loss', 'net_revenue'), array('gross2', 'declined', 'decline_rate', 'paid', 'void', 'void_rate', 'net_approved', 'approval_rate', 'cancelled', 'cancel_rate', 'subscriptions_approved', 'pending', 'rma', 'rma_rate', 'discounts', 'discount_amount', 'partial_refund', 'refund_amount', 'chargeback', 'chargeback_rate', 'chargeback_loss', 'retention_count_rate', 'net_revenue', 'potential_revenue', 'retention_rate')); $simpleReportFields = array('gross', 'gross2', 'decline_rate', 'cancel_rate', 'chargeback_rate', 'pending', 'net_revenue', 'potential_revenue', 'retention_rate'); // CSV builder if (isset($this->params['download_csv']) && $this->params['download_csv']) { self::retentionCsvBuilder($report, $extraFields, $campaignsFilter, $affids, $countR, $simpleReportFields, $filterFields); die; } $tempArray = explode('-', $filterFields['r_dates']); $filterFields['r_dates_post'] = $filterFields['r_dates']; $filterFields['r_dates'] = HelperFormatted::date($tempArray[0], HelperFormatted::TIME_FORMAT_DATE) . '-' . HelperFormatted::date($tempArray[1], HelperFormatted::TIME_FORMAT_DATE); $filterFields['report_date'] = HelperFormatted::date($filterFields['report_date'], HelperFormatted::TIME_FORMAT_DATE); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_newretantion_table', array('application', 'views', 'reports'), array('access' => $this->access, 'controller' => $this->controller, 'report' => $report, 'extraFields' => $extraFields, 'countR' => $countR, 'campaignsFilter' => $campaignsFilter, 'filterFields' => $filterFields, 'affids' => $affids, 'simpleReportFields' => $simpleReportFields, 'simple' => isset($this->params['simple']) ? (int) $this->params['simple'] : 0, 'currencies' => $currencies, 'countries' => $countries, 'reportCur' => $reportCur)); die; } Assets::css('jquery-ui'); Assets::js('//code.jquery.com/ui/1.10.3/jquery-ui.js'); Assets::js('dateRange/jquery.daterange'); Assets::js('jquery.form'); // for ajax submission used to build csv Assets::js('ajax_table'); Assets::js('af_input_field'); $this->render('newretention', array('report' => $report, 'extraFields' => $extraFields, 'countR' => $countR, 'campaignsFilter' => $campaignsFilter, 'filterFields' => $filterFields, 'affids' => $affids, 'simpleReportFields' => $simpleReportFields, 'simple' => isset($this->params['simple']) ? (int) $this->params['simple'] : 0, 'currencies' => $currencies, 'countries' => $countries, 'reportCur' => $reportCur)); }
echo $form->textField($model, 'taxno', array('size' => 10, 'maxlength' => 50)); ?> <?php echo $form->error($model, 'taxno'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'currencyid'); ?> <?php echo $form->hiddenField($model, 'currencyid'); ?> <input type="text" name="currencyname" id="currencyname" style="width:100px" readonly value="<?php echo Currency::model()->findByPk($model->currencyid) !== null ? Currency::model()->findByPk($model->currencyid)->currencyname : ''; ?> "> <?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'currency_dialog', 'options' => array('title' => Yii::t('app', 'Currency'), 'width' => 'auto', 'autoOpen' => false, 'modal' => true))); $this->widget('zii.widgets.grid.CGridView', array('id' => 'currency-grid', 'dataProvider' => $currency->Searchwstatus(), 'filter' => $currency, 'template' => '{summary}{pager}<br>{items}{pager}{summary}', 'columns' => array(array('header' => '', 'type' => 'raw', 'value' => 'CHtml::Button("+", array("name" => "send_absschedule", "id" => "send_absschedule", "onClick" => "$(\\"#currency_dialog\\").dialog(\\"close\\"); $(\\"#currencyname\\").val(\\"$data->currencyname\\"); $(\\"#Company_currencyid\\").val(\\"$data->currencyid\\"); "))'), array('name' => 'currencyid', 'visible' => false, 'value' => '$data->currencyid', 'htmlOptions' => array('width' => '1%')), 'currencyname', array('class' => 'CCheckBoxColumn', 'name' => 'recordstatus', 'selectableRows' => '0', 'header' => 'Record Status', 'checked' => '$data->recordstatus')))); $this->endWidget('zii.widgets.jui.CJuiDialog'); ?> <input class="button" type="button" value="..." name="currency_button" onclick="$('#currency_dialog').dialog('open'); return false;"> <?php
// echo $form->textField($model,'city_id'); ?> <?php echo $form->error($model,'city_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'expence_id'); ?> <?php echo $form->textField($model,'expname',array('length'=>'30','readonly'=>'readonly')); ?> <?php echo CHtml::button("...",array('onclick'=>'pickValue("expence");')); ?> <?php echo $form->hiddenField($model,'expence_id'); ?> <?php echo $form->error($model,'expence_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'currency_id'); ?> <?php $list = CHtml::listData(Currency::model()->findAll(),'id', 'name'); echo $form->DropDownList($model,'currency_id',$list); // echo $form->textField($model,'currency_id'); ?> <?php echo $form->error($model,'currency_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'amount'); ?> <?php echo $form->textField($model,'amount'); ?> <?php echo $form->error($model,'amount'); ?> </div> <div class="row"> <?php echo $form->labelEx($modelp,'name'); ?> <?php echo $form->textField($modelp,'name',array('size'=>60,'maxlength'=>64)); ?> <?php echo $form->error($modelp,'name'); ?>
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Currency the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Currency::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionUpload() { parent::actionUpload(); $folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/'; // folder for uploaded files $file = $folder . basename($_FILES['uploadfile']['name']); if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { $row = 0; if (($handle = fopen($file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($row > 0) { $model = Company::model()->findByPk((int) $data[0]); if ($model === null) { $model = new Company(); } $model->companyid = (int) $data[0]; $model->companyname = $data[1]; $model->address = $data[2]; $city = City::model()->findbyattributes(array('cityname' => $data[3])); if ($city !== null) { $model->cityid = $city->cityid; } $model->zipcode = $data[4]; $model->taxno = $data[5]; $currency = Currency::model()->findbyattributes(array('currencyname' => $data[6])); if ($currency !== null) { $model->currencyid = $currency->currencyid; } $model->recordstatus = (int) $data[7]; try { if (!$model->save()) { $this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]); } } catch (Exception $e) { $this->messages = $this->messages . $e->getMessage(); } } $row++; } } else { $this->messages = $this->messages . ' memory or harddisk full'; } fclose($handle); } else { $this->messages = $this->messages . ' check your directory permission'; } if ($this->messages == '') { $this->messages = 'success'; } echo $this->messages; }
/** * @return array */ public function getCurrenciesList() { return Currency::model()->currencyList; }
echo $form->dropDownListGroup($model, 'category_id', ['widgetOptions' => ['data' => RealtyCategory::model()->categoryList, 'htmlOptions' => ['empty' => Yii::t('RealtyModule.realty', '--choose--'), 'ajax' => ['type' => 'POST', 'url' => $this->createUrl('/realty/realtyItemBackend/dynamicType', !$model->isNewRecord ? ['id' => $model->id] : []), 'update' => $typeId, 'beforeSend' => "function () {\n \$('" . $typeId . "').attr('disabled', true);\n if (\$('" . $categoryId . " option:selected').val() == '')\n return false;\n }", 'complete' => "function () {\n \$('" . $typeId . "').attr('disabled', false);\n }"]]]]); ?> </div> <div class="col-sm-3"> <?php echo $form->dropDownListGroup($model, 'type_id', ['widgetOptions' => ['data' => $model->getCategoryTypeList(), 'htmlOptions' => ['disabled' => $model->category_id ? false : true, 'empty' => Yii::t('RealtyModule.realty', '--choose--')]]]); ?> </div> <div class="col-sm-2"> </div> </div> <div class="row"> <div class="col-sm-2"> <?php echo $form->dropDownListGroup($model, 'currency_id', ['widgetOptions' => ['data' => Currency::model()->currencyList, 'htmlOptions' => ['empty' => Yii::t('RealtyModule.realty', '--choose--')]]]); ?> </div> </div> <div class="row"> <div class="col-sm-7"> <?php echo $form->textFieldGroup($model, 'name'); ?> </div> </div> <div class="row"> <div class="col-sm-7"> <?php echo $form->slugFieldGroup($model, 'alias', ['sourceAttribute' => 'name', 'widgetOptions' => ['htmlOptions' => ['placeholder' => Yii::t('RealtyModule.realty', 'For automatic generation leave this field empty')]]]);
public function actionUpload() { parent::actionUpload(); $folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/'; // folder for uploaded files $file = $folder . basename($_FILES['uploadfile']['name']); if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { $row = 0; if (($handle = fopen($file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($row > 0) { $model = Account::model()->findByPk((int) $data[0]); if ($model === null) { $model = new Account(); } $model->accountid = (int) $data[0]; $model->accountcode = $data[1]; $model->accountname = $data[2]; if ($data[3] != '') { $model->parentaccountid = (int) $data[3]; } else { $model->parentaccountid = null; } if ($data[4] != '') { $accounttype = Accounttype::model()->findbysql("select * from accounttype where upper(accounttypename) = upper('" . $data[4] . "')"); if ($accounttype != null) { $model->accounttypeid = $accounttype->accounttypeid; } else { $model->accounttypeid = null; } } else { $model->accounttypeid = null; } if ($data[5] != '') { $currency = Currency::model()->findbysql("select * from currency where upper(currencyname) = upper('" . $data[5] . "')"); if ($currency != null) { $model->currencyid = $currency->currencyid; } else { $model->currencyid = null; } } else { $model->currencyid = null; } $model->recordstatus = $data[6]; try { if (!$model->save()) { $this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]); } } catch (Exception $e) { $this->messages = $this->messages . $e->getMessage(); } } $row++; } } else { $this->messages = $this->messages . ' memory or harddisk full'; } fclose($handle); } else { $this->messages = $this->messages . ' check your directory permission'; } if ($this->messages == '') { $this->messages = 'success'; } echo $this->messages; }
public function actionDownload() { parent::actionDownload(); $pdf = new PDF(); $pdf->title = 'Absence Schedule List'; $pdf->AddPage('L'); $pdf->setFont('Arial', 'B', 12); // definisi font $pdf->setFont('Arial', 'B', 8); // menuliskan tabel $header = array('No', 'ID', 'Schedule Name', 'Absence In', 'Absence Out', 'Status', 'Wage Name', 'Currency', 'Insentif'); $model = new Absschedule('searchwstatus'); $dataprovider = $model->searchwstatus(); $dataprovider->pagination = false; $data = $dataprovider->getData(); $cols = $dataprovider->getKeys(); $dataku = array(count($data)); //var_dump($dataku); $w = array(20, 25, 30, 30, 30, 30, 30, 30, 30); $pdf->SetTableHeader(); //Header for ($i = 0; $i < count($header); $i++) { $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C', true); } $pdf->Ln(); $pdf->SetTableData(); //Data $fill = false; foreach ($data as $n => $datas) { $pdf->Cell($w[0], 6, $n, 'LR', 0, 'C', $fill); $pdf->Cell($w[1], 6, $datas['absscheduleid'], 'LR', 0, 'C', $fill); $pdf->Cell($w[2], 6, $datas['absschedulename'], 'LR', 0, 'C', $fill); $pdf->Cell($w[3], 6, $datas['absin'], 'LR', 0, 'C', $fill); $pdf->Cell($w[4], 6, $datas['absout'], 'LR', 0, 'C', $fill); $pdf->Cell($w[5], 6, Absstatus::model()->findByPk($datas['absstatusid'])->shortstat, 'LR', 0, 'C', $fill); $pdf->Cell($w[6], 6, Wagetype::model()->findByPk($datas['wagetypeid'])->wagename, 'LR', 0, 'C', $fill); $pdf->Cell($w[7], 6, Currency::model()->findByPk($datas['currencyid'])->currencyname, 'LR', 0, 'C', $fill); $pdf->Cell($w[8], 6, number_format($datas['insentif']), 'LR', 0, 'C', $fill); $pdf->Ln(); $fill = !$fill; } $pdf->Cell(array_sum($w), 0, '', 'T'); // me-render ke browser $pdf->Output(); }
<?php echo $form->textFieldControlGroup($model, 'title', array('class' => 'span8')); if ($model->stock) { echo $form->textFieldControlGroup($model, 'stock', array('help' => '库存默认为1000', 'readonly' => true)); } //echo $form->textFieldControlGroup($model, 'min_number', array('help' => '最少订货量默认为1')); echo $form->textFieldControlGroup($model, 'price'); $currency = Currency::model()->findAll(); $currency_list = CHtml::listData($currency, 'currency_id', 'name'); echo $form->dropDownListControlGroup($model, 'currency', $currency_list); //echo $form->textFieldControlGroup($model, 'outer_id'); $language = Language::model()->findAll(); $language_list = CHtml::listData($language, 'language_id', 'name'); echo $form->dropDownListControlGroup($model, 'language', $language_list); //$url = Yii::app()->createUrl('mall/item/getChildAreas'); //list($countryAreas, $stateAreas, $citeAreas) = $model->getAreas(); //echo $form->dropDownListControlGroup($model, 'country', $countryAreas, // array('class' => 'area area-country', 'data-child-area' => 'area-state', 'data-url' => $url)); //echo $form->dropDownListControlGroup($model, 'state', $stateAreas, array('class' => 'area area-state', 'data-child-area' => 'area-city', 'data-url' => $url)); //echo $form->dropDownListControlGroup($model, 'city', $citeAreas, array('class' => 'area-city')); //echo $form->textFieldControlGroup($model, 'Keywords'); //echo $form->textFieldControlGroup($model, 'description' ); //echo $form->textFieldControlGroup($model, 'title1'); ?>
public static function getCurrencyById($currencyId) { $currency = null; if (!key_exists($currencyId, self::$_currencies)) { $currency = Currency::model()->findByPK($currencyId); if (!is_null($currency)) { self::$_currencies[$currencyId] = $currency; } } else { $currency = self::$_currencies[$currencyId]; } return $currency; }
public function actionReport() { // $model=Exp::model()->with(array('city','concert','expence'))->findByPk($id); $model = new Exp('search'); $show = false; $model->unsetAttributes(); // clear any default values $model->arr_cur = Currency::model()->findAll(); if (empty($_POST)) { $model->from_date = Constants::model()->getCvalue('repf_' . Yii::app()->user->uid); $model->to_date = Constants::model()->getCvalue('rept_' . Yii::app()->user->uid); } else { $show = true; Constants::model()->setCvalue('repf_' . Yii::app()->user->uid, $_POST['Exp']['from_date']); Constants::model()->setCvalue('rept_' . Yii::app()->user->uid, $_POST['Exp']['to_date']); if (isset($_POST['Exp'])) { foreach ($_POST['Exp'] as $key => $row) { switch ($key) { case 'from_date': $model->from_date = $row; break; case 'to_date': $model->to_date = $row; break; case 'state_pay': $model->state_pay = $row; break; case 'state_cur': $model->state_cur = $row; break; case 'report_type': $model->report_type = $row; break; } } } } $this->render('report', array('model' => $model, 'show' => $show)); }
function updateAction() { $model = new Campaign(); if (isset($_POST['country_id'])) { $_POST['country_id'] = implode(',', $_POST['country_id']); } // check if this is an attachment campaign. if so, we don't want to validate the urls or fulfillment_id if it isnot presesnt $attach = false; if (isset($_POST['attach']) && $_POST['attach']) { $attach = true; $_POST['url'] = $_POST['order_url'] = $_POST['return_url'] = 'attach'; if (!strlen($_POST['fulfillment_id'])) { $_POST['fulfillment_id'] = 0; } } else { $_POST['attach'] = 0; } // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['ajax']) && $_POST['ajax'] == 'categorys-form') { $model->fillFromArray($_POST, FALSE); $model->user_id_updated = $this->user->user_id; $model->updated = 'NOW():sql'; $model->model_uset_id = $this->user->user_id; $fulfillment_change = AF::get($_POST, 'fulfillment_change'); Campaigns::fulfillmentRelationship($model->campaign_id, $model->fulfillment_id, $fulfillment_change); if ($model->restrictions()->save()) { Message::echoJsonSuccess(__('campaign_updated')); } else { Message::echoJsonError(__('campaign_no_updated')); } die; } $id = AF::get($this->params, 'id', FALSE); if (!$id) { throw new AFHttpException(0, 'no_id'); } if (!$model->restrictions()->cache()->findByPk($id)) { throw new AFHttpException(0, 'incorrect_id'); } $model->country_id = explode(',', $model->country_id); Assets::js('jquery.form'); $this->addToPageTitle('Update campaign'); //array_unshift($fulfillments, array('fulfillment_id'=>0, 'alias'=>__('none'))); // Is this used still? $ccomboModel = new CCombo(); $ccomboModel->campaign_id = $model->campaign_id; $isCombo = $ccomboModel->checkRelationship(); $countries = Country::model()->cache()->findAllInArray(); $profiles = Profile::model()->cache()->findAllInArray(); // prepend dry run gateway array_unshift($profiles, array('profile_id' => 0, 'profile_name' => 'DRY RUN GATEWAY')); $fulfillments = Fulfillment::model()->cache()->findAllInArray(); $currencies = $model->getCountOrders() > 0 ? array() : Currency::model()->cache()->findAllInArray(); $domains = Domain::model()->cache()->findAllInArray(); $this->render('update', array('model' => $model, 'countries' => $countries, 'profiles' => $profiles, 'currencies' => $currencies, 'fulfillments' => $fulfillments, 'isCombo' => $isCombo, 'domains' => $domains)); }
public static function getModelByLang($lang) { if (isFree()) { $sql = 'SELECT currency_id FROM {{lang}} WHERE name_iso=:lang'; $currency_id = Yii::app()->db->createCommand($sql)->queryScalar(array(':lang' => $lang)); } else { $currency_id = Lang::getCurrencyIdForLang($lang); } return $currency_id ? Currency::model()->findByPk($currency_id) : NULL; }
<?php $this->widget('yupe\\widgets\\BackendGridView', ['id' => 'item-grid', 'type' => 'condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => [['header' => 'Изображение', 'type' => 'raw', 'value' => '$data->image ? CHtml::image($data->getImageUrl(260, 195), $data->title) : ""', 'filter' => false, 'sortable' => false, 'htmlOptions' => ['style' => 'width: 260px']], ['class' => 'yupe.widgets.columns.CustomEditableColumn', 'name' => 'lotnum'], ['name' => 'type_id', 'type' => 'raw', 'value' => '$data->typeTitle', 'filter' => RealtyType::model()->categoryList], ['class' => 'yupe.widgets.columns.CustomEditableColumn', 'name' => 'name'], ['class' => 'yupe.widgets.columns.CustomEditableColumn', 'name' => 'alias'], ['header' => '№ квартиры', 'type' => 'raw', 'value' => 'isset($data->apartment_number)? $data->apartment_number : ""'], ['header' => 'Метраж', 'type' => 'raw', 'value' => 'isset($data->total_area)? $data->total_area : ""'], ['header' => 'Цена', 'type' => 'raw', 'value' => '$data->price'], ['name' => 'currency_id', 'type' => 'raw', 'value' => '$data->currencySign', 'filter' => Currency::model()->currencyList], ['class' => 'yupe\\widgets\\columns\\EditableStatusColumn', 'name' => 'status', 'source' => $model->getStatusList(), 'options' => [RealtyItem::STATUS_ACTIVE => ['class' => 'label-success'], RealtyItem::STATUS_NOT_ACTIVE => ['class' => 'label-default']]], ['class' => 'yupe\\widgets\\columns\\EditableStatusColumn', 'name' => 'is_special', 'source' => $model->getSpecialList(), 'options' => [RealtyItem::SPECIAL_ACTIVE => ['class' => 'label-success'], RealtyItem::SPECIAL_NOT_ACTIVE => ['class' => 'label-default']]], ['class' => 'yupe\\widgets\\columns\\EditableStatusColumn', 'name' => 'show_price', 'source' => $model->getShowPriceList(), 'options' => [RealtyItem::SHOW_PRICE_YES => ['class' => 'label-success'], RealtyItem::SHOW_PRICE_NO => ['class' => 'label-default']]], ['class' => 'yupe\\widgets\\columns\\CustomButtonColumn', 'template' => '{front_view} {duplicate} {attributes} {images} {update} {delete}', 'buttons' => ['duplicate' => ['icon' => 'wrench', 'label' => 'Дублировать', 'url' => '["/realty/realtyItemBackend/duplicate", "id" => $data->id]'], 'attributes' => ['icon' => 'list', 'label' => Yii::t('RealtyModule.realty', 'Attributes'), 'url' => '["/realty/realtyItemBackend/attributes", "id" => $data->id]'], 'images' => ['icon' => 'picture', 'label' => Yii::t('RealtyModule.realty', 'Images'), 'url' => '["/realty/realtyItemBackend/gallery", "id" => $data->id]']]]]]); ?> <style> @media (max-width: 1550px) { .panel.panel-default { display: none !important; } } </style>