/** * Проверяет корректность введённых данных и подготавливает массив для работы с моделью * @param array $params * @return array */ public function check($params) { $valid = array(); $args = $params; // Проверяем ID //подготавливаем отправляемый массив в модель $valid[1] = (string) @$params['name']; $valid['id'] = (int) @$params['id']; $valid[2] = (int) @$params['type']; $valid[7] = trim(@$params['comment']); $valid[29] = (int) @$params['currency']; $valid[8] = (int) @$params['bank']; $valid[11] = (int) @$params['yearPercent']; $valid[17] = @formatRussianDate2MysqlDate($params['dateGet']); $valid[18] = @formatRussianDate2MysqlDate($params['dateOff']); $valid[10] = (int) @$params['loanGiver']; //подготовим объект $this->name = $valid[1]; $this->type = $valid[2]; $this->comment = $valid[7]; $this->currency = $valid[29]; //$this->bank = $valid[8]; //$this->yearPercent = $valid[11]; //$this->dateGet = $valid[17]; //$this->dateOff = $valid[18]; //$this->loanGiver = $valid[10]; return $valid; }
/** * Проверяет корректность введённых данных и подготавливает массив для работы с моделью * @param array $params * @return array */ public function check($params) { $valid = array(); $args = $params; // Проверяем ID //подготавливаем отправляемый массив в модель $valid[1] = (string) @$params['name']; $valid['id'] = (int) @$params['id']; $valid[2] = (int) @$params['type']; $valid[7] = trim(@$params['comment']); $valid[29] = (int) @$params['currency']; $valid[26] = (string) @$params['typeMetal']; $valid[8] = (string) @$params['bank']; //$valid[12] = (float)@$params['incomeYearPercent']; $valid[6] = (double) @$params['currentmarketCost']; $valid[15] = @formatRussianDate2MysqlDate($params['dateOpen']); //подготовим объект $this->name = $valid[1]; $this->type = $valid[2]; $this->comment = $valid[7]; $this->currency = $valid[29]; //$this->bank = $valid[8]; //$this->metall = $valid[26]; //$this->currentMarketCost = $valid[6]; //$this->incomeYearPercent = $valid[12]; //$this->dateOpen = $valid[15]; /*if ( in_array('amount', $params) ) { $valid['4'] = (int)@$params['amount']; }*/ //die (print_r($valid)); return $valid; }
/** * Проверяет корректность введённых данных и подготавливает массив для работы с моделью * @param array $params * @return array */ public function check($params) { $valid = array(); $args = $params; // Проверяем ID //подготавливаем отправляемый массив в модель $valid[1] = (string) @$params['name']; $valid['id'] = (int) @$params['id']; $valid[2] = (int) @$params['type']; $valid[7] = trim(@$params['comment']); $valid[29] = (int) @$params['currency']; $valid[8] = (string) @$params['bank']; $valid[11] = (int) @$params['yearPercent']; $valid[22] = (int) @$params['paySystem']; $valid[23] = @formatRussianDate2MysqlDate($params['validityPeriod']); $valid[19] = (int) @$params['creditLimit']; $valid[21] = (int) @$params['graisePeriod']; //подготовим объект $this->name = $valid[1]; $this->type = $valid[2]; //$this->bank = $valid[8]; $this->comment = $valid[7]; $this->currency = $valid[29]; //$this->yearPercent = $valid[11]; //$this->paySystem = $valid[22]; //$this->validityPeriod = $valid[23]; //$this->creditLimit = $valid[19]; //$this->graisePeriod = $valid[21]; return $valid; }
/** * */ function getData() { $report = trim(@$_GET['report']); $start = formatRussianDate2MysqlDate(@$_GET['dateFrom']); $end = formatRussianDate2MysqlDate(@$_GET['dateTo']); $start2 = formatRussianDate2MysqlDate(@$_GET['dateFrom2']); $end2 = formatRussianDate2MysqlDate(@$_GET['dateTo2']); $account = (int) @$_GET['account']; $currency = (int) @$_GET['currency']; $acclist = @$_GET['acclist']; if (!empty($account)) { $accounts = $account; } else { $accounts = ''; $acc = explode(',', $_GET['acclist']); foreach ($acc as $value) { if ((int) $value > 0) { if (!empty($accounts)) { $accounts .= ','; } $accounts .= (int) $value; } } } switch ($report) { case 'graph_profit': //Доходы $this->_renderJson($this->_model->getPie(1, $start, $end, $accounts, $currency)); case 'graph_loss': // Расходы $this->_renderJson($this->_model->getPie(0, $start, $end, $accounts, $currency)); case 'graph_profit_loss': //Сравнение расходов и доходов $this->_renderJson($this->_model->getBars($start, $end, $accounts, $currency)); case 'txt_profit': //Детальные доходы $this->_renderJson($this->_model->SelectDetailed(1, $start, $end, $accounts, $currency)); case 'txt_loss': //Детальные расходы $this->_renderJson($this->_model->SelectDetailed(0, $start, $end, $accounts, $currency)); case 'txt_loss_difference': //Сравнение расходов за периоды $this->_renderJson($this->_model->CompareForPeriods(0, $start, $end, $start2, $end2, $accounts, $currency)); case 'txt_profit_difference': //Сравнение доходов за периоды $this->_renderJson($this->_model->CompareForPeriods(1, $start, $end, $start2, $end2, $accounts, $currency)); default: die(' "elements": [{ "type": "pie", "alpha": 0.6, "start-angle": 35, "animate": [ { "type": "fade" } ], "colours": [ "#1C9E05", "#FF368D" ], "values": [1,2,3,4,5,6,7] }]'); } }
/** * Разбираем пришедшие от пользователя данные * * @param array $data * @return array */ private function _parseData(array $data) { $anketa = array(); $currencies = array('RUR', 'USD', 'EUR'); // Личные данные пользователя $anketa['personal']['last_name'] = (string) $data['wz_surname']; $anketa['personal']['last_name_lat_trans'] = (string) $data['wz_surname_translit']; $anketa['personal']['first_name'] = (string) $data['wz_name']; $anketa['personal']['first_name_lat_trans'] = (string) $data['wz_name_translit']; $anketa['personal']['second_name'] = (string) $data['wz_midname']; $anketa['personal']['control_name'] = (string) $data['wz_password']; $anketa['personal']['birth_place'] = (string) $data['wz_birthplace']; $anketa['personal']['birth_date'] = formatRussianDate2MysqlDate((string) $data['wz_birthdate']); $anketa['personal']['gender'] = (int) $data['wz_sex'] == 1 ? "ж" : "м"; $anketa['personal']['nationality'] = (string) $data['wz_citizenship']; $anketa['personal']['inn'] = (string) $data['wz_inn']; // Адрес прописки / регистрации $anketa['registration_address']['country'] = (string) $data['wz_reg_country']; $anketa['registration_address']['region'] = (string) $data['wz_reg_region']; $anketa['registration_address']['city'] = (string) $data['wz_reg_city']; $anketa['registration_address']['index'] = (string) $data['wz_reg_index']; $anketa['registration_address']['street'] = (string) $data['wz_reg_street']; $anketa['registration_address']['house_number'] = (string) $data['wz_reg_house']; $anketa['registration_address']['bulk_number'] = (string) $data['wz_reg_building']; $anketa['registration_address']['room_number'] = (string) $data['wz_reg_appartment']; // Адрес проживания (для переписки) $anketa['live_address']['country'] = (string) $data['wz_actual_country']; $anketa['live_address']['region'] = (string) $data['wz_actual_region']; $anketa['live_address']['city'] = (string) $data['wz_actual_city']; $anketa['live_address']['index'] = (string) $data['wz_actual_index']; $anketa['live_address']['street'] = (string) $data['wz_actual_street']; $anketa['live_address']['house_number'] = (string) $data['wz_actual_house']; $anketa['live_address']['bulk_number'] = (string) $data['wz_actual_building']; $anketa['live_address']['room_number'] = (string) $data['wz_actual_appartment']; // Данные основного документа клиента $anketa['main_doc']['title'] = (string) $data['wz_doc_title']; $anketa['main_doc']['serial'] = (string) $data['wz_rf_id_series']; $anketa['main_doc']['number'] = (string) $data['wz_rf_id_number']; $anketa['main_doc']['who_delivery'] = (string) $data['wz_rf_id_organisation']; $anketa['main_doc']['issue_date'] = formatRussianDate2MysqlDate((string) $data['wz_rf_id_date']); $anketa['main_doc']['expiration_date'] = formatRussianDate2MysqlDate((string) $data['wz_rf_expiration_date']); $anketa['main_doc']['unit_code'] = (string) $data['wz_rf_id_organisation_code']; // Миграционная карта $anketa['migratory_card']['number'] = (string) $data['wz_migration_id_number']; $anketa['migratory_card']['issue_date'] = formatRussianDate2MysqlDate((string) $data['wz_migration_id_date']); $anketa['migratory_card']['expiration_date'] = formatRussianDate2MysqlDate((string) $data['wz_migration_id_expire']); // Данные документа подтверждающего право на жительство $anketa['residence_doc']['title'] = (string) $data['wz_residence_title']; $anketa['residence_doc']['serial'] = (string) $data['wz_foreign_id_series']; $anketa['residence_doc']['number'] = (string) $data['wz_foreign_id_number']; $anketa['residence_doc']['issue_date'] = formatRussianDate2MysqlDate((string) $data['wz_foreign_id_date']); $anketa['residence_doc']['expiration_date'] = formatRussianDate2MysqlDate((string) $data['wz_foreign_id_expire']); // Контактная информация $anketa['contacts']['home_phone'] = (string) $data['wz_phone_home']; $anketa['contacts']['mobile_phone'] = (string) $data['wz_phone_mob']; $anketa['contacts']['email'] = (string) $data['wz_card_account_mail']; $anketa['contacts']['other'] = (string) $data['wz_other_contacts']; // Место работы $anketa['work_place']['organisation_name'] = (string) $data['wz_work_name']; $anketa['work_place']['organization_address'] = (string) $data['wz_work_address']; $anketa['work_place']['character_position'] = (string) $data['wz_work_position']; $anketa['work_place']['phone'] = (string) $data['wz_work_phone']; // Международная банковская карта $anketa['card']['is_main'] = (string) $data['wz_card_is_main'] ? 'true' : 'false'; $anketa['card']['currency'] = @$currencies[$data['wz_card_currency']]; $anketa['card']['type'] = (string) $data['wz_card_type']; $anketa['card']['is_planning'] = $data['wz_card_rush'] ? 'true' : 'false'; $anketa['card']['expiration_time'] = (string) $data['wz_card_expiration']; $anketa['card']['informSms'] = $data['wz_card_sms_info'] ? 'true' : 'false'; $anketa['card']['report_type'] = (string) $data['wz_card_account_info_to']; $anketa['card']['report_email'] = (string) $data['wz_card_account_mail']; // Информация по доп. карте $anketa['additionalCard']['lastName'] = (string) $data['wz_addit_card_lastname']; $anketa['additionalCard']['firstName'] = (string) $data['wz_addit_card_firstname']; $anketa['additionalCard']['secondName'] = (string) $data['wz_addit_card_secondname']; $anketa['additionalCard']['mainSKS'] = (string) $data['wz_addit_card_sks_number']; $anketa['additionalCard']['choiseLimits'] = (string) $data['wz_addit_card_limit']; // Если заказывается дополнительная карта для лица в возрасте до 14 лет $anketa['additionalDocument']['type'] = (string) $data['wz_addit_card14_document']; $anketa['additionalDocument']['who_delivery'] = (string) $data['wz_addit_card14_organisation']; $anketa['additionalDocument']['delivery_date'] = formatRussianDate2MysqlDate((string) $data['wz_addit_card14_date']); return $anketa; }
$date = date("d/m/Y"); $dateCBR = str_replace('.', '/', date("m/d/Y")); $linkCBR = "http://www.cbr.ru/scripts/XML_daily.asp?date_req=" . $date; //центральный банк России $linkBEL = "http://www.nbrb.by/Services/XmlExRates.aspx?ondate=" . $dateCBR; //национальный банк республики Беларусь $linkUKR = "http://bank-ua.com/export/currrate.xml"; //национальный хохляндский банк. $linkKAZ = "http://www.nationalbank.kz/rss/rates_all.xml"; //национальный казахстанский банк //Создаём ДОМ объект $dom = new DOMDocument('1.0', 'windows-1251'); $dom->load($linkCBR); // Иногда, ЦБР подло меняет разделители знаков в дате на слеш, поэтому перестраховываемся $date = str_replace('/', '.', $dom->getElementsByTagName('ValCurs')->item(0)->getAttribute('Date')); $date = formatRussianDate2MysqlDate($date); //Если на эту дату уже существует, то прекращать выполнение скрипта if (trim($result[0]['currency_date']) === trim($date)) { die('Has already loaded for date ' . $date); } $sql = ''; $sql_update = "UPDATE\n currency\n SET\n rate = ?f,\n updated_at = NOW()\n WHERE cur_char_code = ?"; foreach ($dom->getElementsByTagName('Valute') as $elem) { if (!empty($sql)) { $sql .= ','; } $charCode = $elem->getElementsByTagName('CharCode')->item(0)->nodeValue; $getId = "SELECT cur_id FROM currency WHERE cur_char_code=?"; $re = $db->query($getId, $charCode); $id = $re[0]['cur_id']; //Готовим движение курса
/** * Проверяет данные и возвращает ассоциативный массив, если успешно. False - при ошибке * @return array mixed */ public function checkData() { $data = array(); $data['id'] = (int) @$_POST['id']; if (@$_POST['type'] == 'd') { $data['type'] = 'd'; } else { $data['type'] = 'r'; } $data['category'] = (int) @$_POST['category']; if ($data['category'] == 0) { $this->errorData['category'] = "Категория цели"; } $data['title'] = htmlspecialchars(@$_POST['title']); if (empty($data['title'])) { $this->errorData['title'] = "Наименование цели"; } if (is_numeric((double) $_POST['amount'])) { $data['amount'] = (double) $_POST['amount']; } else { $data['amount'] = 0; } if (is_numeric((double) $_POST['money'])) { $data['money'] = (double) $_POST['money']; } else { $data['money'] = 0; } $data['start'] = formatRussianDate2MysqlDate(@$_POST['start']); if (!$data['start']) { $this->errorData['start'] = "Дата начала"; } $data['end'] = formatRussianDate2MysqlDate(@$_POST['end']); if (!$data['end']) { $this->errorData['end'] = "Дата окончания"; } if (strtotime($data['start'] . ' 00:00:00') > strtotime($data['end'] . ' 00:00:00')) { $this->errorData['end'] = "Неверно указана дата окончания"; } $data['photo'] = htmlspecialchars(@$_POST['photo']); $data['url'] = htmlspecialchars(@$_POST['url']); $data['comment'] = htmlspecialchars(@$_POST['comment']); $data['account'] = (int) @$_POST['account']; //$data['comment'] = htmlspecialchars( $data['comment'] , ENT_NOQUOTES); //$data['title'] = htmlspecialchars( $data['title'] , ENT_NOQUOTES); if ((int) $_POST['visible']) { $data['visible'] = 1; } else { $data['visible'] = 0; } return $data; }