debug = false; $dbh = $dbconn->Connect($dbhost, $dbuname, $dbpass, $dbname); if (!$dbh) { $dbpass = ""; die("$dbtype://$dbuname:$dbpass@$dbhost/$dbname failed to connect" . $dbconn->ErrorMsg()); } global $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; // force oracle to a consistent date format for comparison methods later on if (strcmp($dbtype, 'oci8') == 0) { $dbconn->Execute("alter session set NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'"); } return true; } /** * get database connection * @return database connection */ function lfDBGetConn(){ global $dbconn; return $dbconn; } //make unique key define('_SYLLABELS', "*abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789"); define('_MAKEPASS_LEN', 8); define('_MAKEPASS_BOX', 5000); //randome seed function _make_seed(){ list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } //make random password function makePass(){ // init some $result = ''; mt_srand(_make_seed()); $syllabels = _SYLLABELS; $len = strlen($syllabels) - 1; $box = ""; // create box for($i = 0; $i < _MAKEPASS_BOX; $i++) { $ch = $syllabels[mt_rand(0, $len)]; // about 20% upper case letters if (mt_rand(0, $len) % 5 == 1) { $ch = strtoupper($ch); } // filling up the box with random chars $box .= $ch; } // now collect password from box for($i = 0; $i < _MAKEPASS_LEN; $i++) { $result .= $box[mt_rand(0, (_MAKEPASS_BOX - 1))]; } return $result; } //check email address function lfValidateEmail($var){ $length = strlen($var); $idx = 0; while($length--) { $c = $var[$idx++]; if(ord($c) > 127){ return false; } } $regexp = '/^(?:[^\s\000-\037\177\(\)<>@,;:\\"\[\]]\.?)+@(?:[^\s\000-\037\177\(\)<>@,;:\\\"\[\]]\.?)+\.[a-z]{2,6}$/Ui'; if(preg_match($regexp,$var)) { return true; } else { return false; } } //send mail function lfMail($to, $subject, $message){ global $lfconfig; $from = $lfconfig['adminMail']; $headers = "From: $from\n"; $headers .= "Content-Type: text/plain; charset=iso-2022-jp\n" ."X-Mailer: FPCafe mail system\n" ."Content-Transfer-Encoding: 7bit\n"; $subject = "=?iso-2022-jp?B?" . base64_encode(JcodeConvert($subject,0,3)) . "?="; $message = JcodeConvert($message,0,3); // Mail message mail($to, $subject, $message, $headers); } //redirect function lfRedirect($redirecturl) { global $lfconfig; if (preg_match('!^http!', $redirecturl)) { // Absolute URL - simple redirect Header("Location: $redirecturl"); return; } else { // Removing leading slashes from redirect url $redirecturl = preg_replace('!^/*!', '', $redirecturl); // Get base URL $baseurl = $lfconfig['baseURL']; Header("Location: $baseurl$redirecturl"); } } //小学校 get Element school array function getEdu1List() { //global $dbconn; $result = array(); //mst_edu の edu_id と 学校名の関連付け $result['1'] = '公立小学校'; //公立小学校 $result['2'] = '私立小学校'; //私立小学校 return $result; } //中学校 get Element school array function getEdu2List() { //global $dbconn; $result = array(); //mst_edu の edu_id と 学校名の関連付け $result['3'] = '公立中学校'; //公立中学校 $result['4'] = '私立中学校'; //私立中学校 return $result; } //高校 get Element school array function getEdu3List() { //global $dbconn; $result = array(); //mst_edu の edu_id と 学校名の関連付け $result['5'] = '公立高校'; //公立高校 $result['6'] = '私立高校'; //私立高校 return $result; } //その他 get Element school array function getEdu4List() { //global $dbconn;bhgg $result = array(); //mst_edu の edu_id と 学校名の関連付け $result['7'] = '公立大学'; //公立 $result['8'] = '私立大学'; //私立 $result['9'] = '専門学校'; // $result['10'] = '短期大学'; // return $result; } //専門学校と短期大学の年齢は大学と違うのでここで分ける function getEdu4aList() { $result = array(); $result['9'] = '専門学校'; // $result['10'] = '短期大学'; // } //マスターテーブルから学費を取得する function getMsEducationFee($eduList) { global $dbconn; $result = array(); $eduInStr = ""; while (list($key, $value) = each ($eduList)) { if ($eduInStr != "") { $eduInStr .= ","; } $eduInStr .= $key; } $eduInStr = "( " . $eduInStr . ")"; $query = "SELECT edu_id, tuition FROM mst_edu WHERE edu_id IN ".$eduInStr; $eduFee=$dbconn->Execute($query); for (; !$eduFee->EOF; $eduFee->MoveNext()) { list($edu_id,$tuition) = $eduFee->fields; //万円の単位 $tuition = round($tuition/10000,1); $result[$edu_id] = $tuition; } return $result; } //学校の年齢を計算する function getSchoolYearOld($birthday,$thisyear) { $result = 0; $temp = getdate(strtotime($birthday)); $result = $thisyear - $temp['year']; if ($temp['mon'] > 4) { $result --; } elseif ($temp['mon'] == 4) { if ($temp['mday'] > 1) { $result --; } } return $result; } //学校の学費を取得する //パラメータ : 学校の年齢期間,成年月日、学校タイプ,マスターデータ function getEducationFee($minSchoolYear, $maxSchoolYear, $birthday,$thisyear, $schoolkbn,$eduMsFee) { $schoolYearOld = getSchoolYearOld($birthday,$thisyear); //学校の年齢 if (($schoolYearOld < $minSchoolYear) || ($schoolYearOld > $maxSchoolYear)) { $fee = 0; } else { if (isset($eduMsFee[$schoolkbn])) { $fee = $eduMsFee[$schoolkbn]; } else { $fee = 0; } } //echo " fee " . $fee; return $fee; } //initialize db lfInit(); ?>id = $vars['id']; //$this->key = $vars['key']; $this->uname = $vars['uname']; $this->birthyear = $vars['birthyear']; $this->birthmonth = $vars['birthmonth']; $this->birthdate = $vars['birthdate']; $this->birthday = $this->birthyear.'/'.$this->birthmonth.'/'.$this->birthdate; $this->sex = $vars['sex']; $this->postno1 = $vars['postno1']; $this->postno2 = $vars['postno2']; $this->postno = $vars['postno1'].$vars['postno2']; $this->mail = $vars['mail']; $this->keyid= $vars['keyid']; if ($this->keyid == '') { $this->newuser = true; $this->keyid = makePass(); } } //男?女 function getSexStr($sex) { if ($sex == 0) return "男"; else if ($sex == 1) return "女"; else return ""; } //妻?夫 function getPartnerStr() { if ($this->sex == 0) return "妻"; else if ($this->sex == 1) return "夫"; else return ""; } //check submited personal information function checkPersonalInfo() { if ($this->uname == '') $this->errors['no_name'] = 'お名前を入力してください。'; if (!checkdate ($this->birthmonth, $this->birthdate, $this->birthyear)) $this->errors['wrong_birthday'] = '生年月日を正しく入力してください。'; if ($this->sex == '') $this->errors['no_sex'] = '性別を選択してください。'; if (!lfValidateEmail($this->mail)) $this->errors['wrong_mail'] = 'メールアドレスを正しく入力してください。'; //if (!isset($this->postno)) $this->errors['no_postno'] = '郵便番号を入力してください。'; if (count($this->errors) > 0) return false; else return true; } //register new user function registerPersonalInfo() { global $dbconn,$usertable; $query = "SELECT id from lf_user WHERE mail = '$this->mail' AND keyid = '$this->keyid'"; $personalinfo=$dbconn->Execute($query); if (($dbconn->ErrorNo()<>0) || ($personalinfo->numRows() == 0) ){ $query = "INSERT INTO lf_user (uname,birthday,sex,postno,mail,keyid,registertime) VALUES ('$this->uname', '$this->birthday','$this->sex','$this->postno','$this->mail','$this->keyid',now())"; } else { list($uid) = $personalinfo->fields; $query = "UPDATE lf_user SET uname = '$this->uname' , birthday = '$this->birthday', sex = '$this->sex', postno = '$this->postno', mail = '$this->mail' WHERE id = $uid"; } $dbconn->Execute($query); } //send mail to user after they register personal info function mailUser() { global $lfconfig; $subject = "登録完了"; $body = "$this->uname様 LifePlanサイトをご登録いただきまして誠にありがとうございます \n 続きまして、家族構成と収入、支出を入力するとシミュレーション結果がわかります。\n 以下のURLをアクセスしてください。\n". $lfconfig['baseURL']."lifeplan.php?keyid=".$this->keyid."\n\n あなたのID:".$this->keyid."\n\n"; lfMail($this->mail, $subject,$body); } //send url(with keyid) to user function mailURL() { global $lfconfig; $subject = "LifePlanサイト"; $body = "$this->uname様\n LifePlanサイトをご登録いただきまして誠にありがとうございます \n 続きまして、家族構成と収入、支出を入力するとシミュレーション結果がわかります。\n 以下のURLをアクセスしてください。\n". $lfconfig['baseURL']."lifeplan.php?keyid=".$this->keyid."\n\n あなたのID:".$this->keyid."\n\n"; lfMail($this->mail, $subject,$body); } //get keyid specified by $mail function getPersonalDBFromMail($mail) { global $dbconn; $query = "SELECT id, keyid, uname FROM lf_user WHERE mail = '$mail' ORDER BY id DESC"; $personalinfo=$dbconn->Execute($query); if (($dbconn->ErrorNo()<>0) || ($personalinfo->numRows() == 0) ){ $this->errors['no_userdb'] = '登録したメールアドレスのユーザ情報が見つかりません。'; return false; } else { list($this->id,$this->keyid,$this->uname) = $personalinfo->fields; $this->mail = $mail; return true; } } //get user personal information from database //@param id : mail and keyid function getPersonalDB($mail, $key) { global $dbconn; $query = "SELECT id, uname, sex, birthday, postno, partner from lf_user WHERE mail = '$mail' AND keyid = '$key'"; $personalinfo=$dbconn->Execute($query); if (($dbconn->ErrorNo()<>0) || ($personalinfo->numRows() == 0) ){ $this->errors['no_userdb'] = 'ユーザ情報が見つかりません。'; return false; } else { list($this->id,$this->uname,$this->sex,$this->birthday, $this->postno) = $personalinfo->fields; $this->mail = $mail; $this->keyid = $key; $temp = getdate(strtotime($this->birthday)); $this->birthyear = $temp['year']; $this->birthmonth = $temp['mon']; $this->birthdate = $temp['mday']; $this->postno1 = substr($this->postno,0,3); $this->postno2 = substr($this->postno,3); return true; } } //family register function getFormFamily($vars) { $this->partner = $vars['partner']; $this->partner_birthyear = $vars['partner_birthyear']; $this->partner_birthmonth = $vars['partner_birthmonth']; $this->partner_birthdate = $vars['partner_birthdate']; $this->partner_birthday = $this->partner_birthyear.'/'.$this->partner_birthmonth.'/'.$this->partner_birthdate; $this->child1 = $vars['child1']; $this->child1_sex = $vars['child1_sex']; $this->child1_birthyear = $vars['child1_birthyear']; $this->child1_birthmonth = $vars['child1_birthmonth']; $this->child1_birthdate = $vars['child1_birthdate']; $this->child1_birthday = $this->child1_birthyear.'/'.$this->child1_birthmonth.'/'.$this->child1_birthdate; $this->child1_edu1 = $vars['child1_edu1']; $this->child1_edu2 = $vars['child1_edu2']; $this->child1_edu3 = $vars['child1_edu3']; $this->child1_edu4 = $vars['child1_edu4']; $this->child2 = $vars['child2']; $this->child2_sex = $vars['child2_sex']; $this->child2_birthyear = $vars['child2_birthyear']; $this->child2_birthmonth = $vars['child2_birthmonth']; $this->child2_birthdate = $vars['child2_birthdate']; $this->child2_birthday = $this->child2_birthyear.'/'.$this->child2_birthmonth.'/'.$this->child2_birthdate; $this->child2_edu1 = $vars['child2_edu1']; $this->child2_edu2 = $vars['child2_edu2']; $this->child2_edu3 = $vars['child2_edu3']; $this->child2_edu4 = $vars['child2_edu4']; $this->child3 = $vars['child3']; $this->child3_sex = $vars['child3_sex']; $this->child3_birthyear = $vars['child3_birthyear']; $this->child3_birthmonth = $vars['child3_birthmonth']; $this->child3_birthdate = $vars['child3_birthdate']; $this->child3_birthday = $this->child3_birthyear.'/'.$this->child3_birthmonth.'/'.$this->child3_birthdate; $this->child3_edu1 = $vars['child3_edu1']; $this->child3_edu2 = $vars['child3_edu2']; $this->child3_edu3 = $vars['child3_edu3']; $this->child3_edu4 = $vars['child3_edu4']; } //check submited family information function checkFamilyInfo() { //if ($this->partner == '') $this->errors['no_partner'] = $this->getPartnerStr().'の名前を入力してください。'; if ($this->partner != '') { if (!checkdate ($this->partner_birthmonth, $this->partner_birthdate, $this->partner_birthyear)) $this->errors['wrong_partner_birthday'] = $this->getPartnerStr().'の生年月日を正しく入力してください。'; } //if ($this->child1 == '') $this->errors['no_child1'] = '第一子供の名前を入力してください。'; if ($this->child1 != '') { if (!checkdate ($this->child1_birthmonth, $this->child1_birthdate, $this->child1_birthyear)) $this->errors['wrong_child1_birthday'] = '第一子供の生年月日を正しく入力してください。'; if ($this->child1_sex == '') $this->errors['no_child1_sex'] = '第一子供の性別を選択してください。'; } //if ($this->child2 == '') $this->errors['no_child2'] = '第一子供の名前を入力してください。'; if ($this->child2 != '') { if (!checkdate ($this->child2_birthmonth, $this->child2_birthdate, $this->child2_birthyear)) $this->errors['wrong_child2_birthday'] = '第二子供の生年月日を正しく入力してください。'; if ($this->child2_sex == '') $this->errors['no_child2_sex'] = '第二子供の性別を選択してください。'; } //if ($this->child3 == '') $this->errors['no_child3'] = '第三子供の名前を入力してください。'; if ($this->child3 != '') { if (!checkdate ($this->child3_birthmonth, $this->child3_birthdate, $this->child3_birthyear)) $this->errors['wrong_child3_birthday'] = '第三子供の生年月日を正しく入力してください。'; if ($this->child3_sex == '') $this->errors['no_child3_sex'] = '第一子供の性別を選択してください。'; } if (count($this->errors) > 0) return false; else return true; } //update family members function updateFamily() { global $dbconn,$usertable; $query = ""; if ( ($this->partner != '') || ( $this->child1 != '') || ( $this->child2 != '') || ( $this->child3 != '') ) { $query = "UPDATE lf_user SET "; if ($this->partner != '') $query .= "partner = '$this->partner', partner_birthday = '$this->partner_birthday',"; if ( $this->child1 != '') $query .= "child1 = '$this->child1', child1_sex = '$this->child1_sex', child1_birthday = '$this->child1_birthday', child1_edu1 = '$this->child1_edu1', child1_edu2 = '$this->child1_edu2', child1_edu3 = '$this->child1_edu3', child1_edu4 = '$this->child1_edu4',"; if ( $this->child2 != '') $query .= "child2 = '$this->child2', child2_sex = '$this->child2_sex', child2_birthday = '$this->child2_birthday', child2_edu1 = '$this->child2_edu1', child2_edu2 = '$this->child2_edu2', child2_edu3 = '$this->child2_edu3', child2_edu4 = '$this->child2_edu4',"; if ( $this->child3 != '') $query .= "child3 = '$this->child3', child3_sex = '$this->child3_sex', child3_birthday = '$this->child3_birthday', child3_edu1 = '$this->child3_edu1', child3_edu2 = '$this->child3_edu2', child3_edu3 = '$this->child3_edu3', child3_edu4 = '$this->child3_edu4',"; $query = substr($query,0,strlen($query)-1); $query .= " WHERE id = $this->id"; $dbconn->Execute($query); } } //Famini db function getFamilyDB() { global $dbconn; $query = "SELECT partner, partner_birthday, child1, child1_sex, child1_birthday, child1_edu1,child1_edu2,child1_edu3,child1_edu4, child2, child2_sex, child2_birthday, child2_edu1,child2_edu2,child2_edu3,child2_edu4, child3, child3_sex, child3_birthday, child3_edu1,child3_edu2,child3_edu3,child3_edu4 FROM lf_user WHERE id = $this->id"; $personalinfo=$dbconn->Execute($query); if (($dbconn->ErrorNo()<>0) || ($personalinfo->numRows() == 0) ){ $this->errors['no_userdb'] = 'ユーザ情報が見つかりません。'; return false; } else { list($this->partner,$this->partner_birthday, $this->child1,$this->child1_sex, $this->child1_birthday, $this->child1_edu1, $this->child1_edu2,$this->child1_edu3,$this->child1_edu4, $this->child2,$this->child2_sex, $this->child2_birthday, $this->child2_edu1, $this->child2_edu2,$this->child2_edu3,$this->child2_edu4, $this->child3,$this->child3_sex, $this->child3_birthday, $this->child3_edu1, $this->child3_edu2,$this->child3_edu3,$this->child3_edu4 ) = $personalinfo->fields; if ($this->partner_birthday != '') { $temp = getdate(strtotime($this->partner_birthday)); $this->partner_birthyear = $temp['year']; $this->partner_birthmonth = $temp['mon']; $this->partner_birthdate = $temp['mday']; } if ($this->child1_birthday != '') { $temp = getdate(strtotime($this->child1_birthday)); $this->child1_birthyear = $temp['year']; $this->child1_birthmonth = $temp['mon']; $this->child1_birthdate = $temp['mday']; } if ($this->child2_birthday != '') { $temp = getdate(strtotime($this->child2_birthday)); $this->child2_birthyear = $temp['year']; $this->child2_birthmonth = $temp['mon']; $this->child2_birthdate = $temp['mday']; } if ($this->child3_birthday != '') { $temp = getdate(strtotime($this->child3_birthday)); $this->child3_birthyear = $temp['year']; $this->child3_birthmonth = $temp['mon']; $this->child3_birthdate = $temp['mday']; } return true; } } //get imcome parameters form form value function getFormIncome($vars) { $this->my_income = $vars['my_income']; $this->my_income_rate = $vars['my_income_rate']; $this->my_pension = $vars['my_pension']; $this->my_pension_year = $vars['my_pension_year']; $this->pa_income = $vars['pa_income']; $this->pa_income_rate = $vars['pa_income_rate']; $this->pa_pension = $vars['pa_pension']; $this->pa_pension_year = $vars['pa_pension_year']; } //check income form function checkIncomeInfo () { if ($this->my_income == '') $this->my_income = 0; else if (!is_numeric($this->my_income)) { $this->errors['wrong_my_income'] = '収入を正しく入力してください。'; } if ($this->my_income_rate == '') $this->my_income_rate = 0; else if (!is_numeric($this->my_income_rate)) { $this->errors['wrong_my_income_rate'] = '収入を正しく入力してください。'; } if ($this->my_pension == '') $this->my_pension = 0; else if (!is_numeric($this->my_pension)) { $this->errors['wrong_my_pension'] = '年金を正しく入力してください。'; } $today = getdate(); if ($this->my_pension_year == '') $this->my_pension_year = $today['year']; else if (!is_numeric($this->my_pension_year)) { $this->errors['wrong_my_pension_year'] = '年金受取開始年度を正しく入力してください。'; } if ($this->pa_income == '') $this->pa_income = 0; else if (!is_numeric($this->pa_income)) { $this->errors['wrong_pa_income'] = '収入を正しく入力してください。'; } if ($this->pa_income_rate == '') $this->pa_income_rate = 0; else if (!is_numeric($this->pa_income_rate)) { $this->errors['wrong_pa_income_rate'] = '収入を正しく入力してください。'; } if ($this->pa_pension == '') $this->pa_pension = 0; else if (!is_numeric($this->pa_pension)) { $this->errors['wrong_pa_pension'] = '年金を正しく入力してください。'; } if ($this->pa_pension_year == '') $this->pa_pension_year = $today['year']; else if (!is_numeric($this->pa_pension_year)) { $this->errors['wrong_pa_pension_year'] = '年金受取開始年度を正しく入力してください。'; } if (count($this->errors) > 0) return false; else return true; } function updateIncome() { global $dbconn,$usertable; $query = "SELECT id from lf_income WHERE id = $this->id"; $incomeinfo=$dbconn->Execute($query); if ($incomeinfo->numRows() == 0 ) { //insert $query = "INSERT INTO lf_income (id, my_income, my_income_rate,my_pension,my_pension_year,pa_income, pa_income_rate,pa_pension,pa_pension_year) VALUES ($this->id, $this->my_income, $this->my_income_rate, $this->my_pension, $this->my_pension_year, $this->pa_income, $this->pa_income_rate, $this->pa_pension, $this->pa_pension_year)"; } else { $query = "UPDATE lf_income SET my_income = $this->my_income, my_income_rate = $this->my_income_rate, my_pension = $this->my_pension, my_pension_year = $this->my_pension_year, pa_income = $this->pa_income, pa_income_rate = $this->pa_income_rate, pa_pension = $this->pa_pension, pa_pension_year = $this->pa_pension_year WHERE id = $this->id "; } $dbconn->Execute($query); } //get income from db function getIncomeDB() { global $dbconn; $query = "SELECT my_income, my_income_rate, my_pension, my_pension_year, pa_income, pa_income_rate, pa_pension, pa_pension_year FROM lf_income WHERE id = $this->id "; $personalinfo=$dbconn->Execute($query); if (($dbconn->ErrorNo()<>0) || ($personalinfo->numRows() == 0) ){ $this->errors['no_userdb'] = 'ユーザ情報が見つかりません。'; return false; } else { list($this->my_income,$this->my_income_rate,$this->my_pension,$this->my_pension_year, $this->pa_income,$this->pa_income_rate,$this->pa_pension,$this->pa_pension_year) = $personalinfo->fields; return true; } } //payment //get payment parameters form form value function getFormPayment($vars) { $this->living_fee = $vars['living_fee']; $this->living_fee_rate = $vars['living_fee_rate']; $this->housing_fee = $vars['housing_fee']; $this->other_fee = $vars['other_fee']; $this->tmp_fee = $vars['tmp_fee']; } //check income form function checkPaymentInfo () { if ($this->living_fee == '') $this->living_fee = 0; else if (!is_numeric($this->living_fee)) { $this->errors['wrong_living_fee'] = '生活費を正しく入力してください。'; } if ($this->living_fee_rate == '') $this->living_fee_rate = 0; else if (!is_numeric($this->living_fee_rate)) { $this->errors['wrong_living_fee_rate'] = '生活費の上昇率を正しく入力してください。'; } if ($this->housing_fee == '') $this->housing_fee = 0; else if (!is_numeric($this->housing_fee)) { $this->errors['wrong_housing_fee'] = '住居費を正しく入力してください。'; } $today = getdate(); if ($this->other_fee == '') $this->other_fee = 0; else if (!is_numeric($this->other_fee)) { $this->errors['wrong_other_fee'] = 'その他のを正しく入力してください。'; } if (count($this->errors) > 0) return false; else return true; } function updatePayment() { global $dbconn,$usertable; $query = "SELECT id from lf_payment WHERE id = $this->id"; $paymentinfo=$dbconn->Execute($query); if ($paymentinfo->numRows() == 0 ) { //insert $query = "INSERT INTO lf_payment (id, living_fee, living_fee_rate,housing_fee, other_fee) VALUES ($this->id, $this->living_fee, $this->living_fee_rate, $this->housing_fee, $this->other_fee)"; } else { $query = "UPDATE lf_payment SET living_fee = $this->living_fee, living_fee_rate = $this->living_fee_rate, housing_fee = $this->housing_fee, other_fee = $this->other_fee WHERE id = $this->id "; } $dbconn->Execute($query); } //get payment from db function getPaymentDB(){ global $dbconn; $query = "SELECT living_fee, living_fee_rate, housing_fee, other_fee FROM lf_payment WHERE id = $this->id "; $personalinfo=$dbconn->Execute($query); if (($dbconn->ErrorNo()<>0) || ($personalinfo->numRows() == 0) ){ $this->errors['no_userdb'] = 'ユーザ情報が見つかりません。'; return false; } else { list($this->living_fee,$this->living_fee_rate,$this->housing_fee,$this->other_fee) = $personalinfo->fields; return true; } } //calculate fortune function getAllIncome($year) { global $lfconfig; $myincome = 0; if ($year < $this->my_pension_year ) { $myincome = $this->my_income * pow((1+ $this->my_income_rate/100),($year-$lfconfig['start_year'])); } else { $myincome = $this->my_pension; } $paincome = 0; if ($year < $this->pa_pension_year ) { $paincome = $this->pa_income * pow((1 + $this->pa_income_rate/100),($year-$lfconfig['start_year'])); } else { $paincome = $this->pa_pension; } $in = $myincome + $paincome; $in = round($in,1); $this->allIncome[$year] = $in; return $in; } function getAllPayment($year) { global $lfconfig; $out = $this->living_fee * pow((1+ $this->living_fee_rate/100),($year-$lfconfig['start_year'])); $out = $out + $this->housing_fee + $this->other_fee; $out = round($out,1); $this->allPayment[$year] = $out; return $out; } //all getAllPayment, getAllIncome before call this function getAllFortune($year) { global $lfconfig; if ($year == $lfconfig['start_year']) { $fortune = $this->allIncome[$year] - $this->allPayment[$year]; } else { $fortune = $this->allFortune[$year-1] + $this->allIncome[$year] - $this->allPayment[$year] - $this->allEducationFee[$year] ; } $this->allFortune[$year] = $fortune; return $fortune; } function initEducationFee() { $this->edu1list = getEdu1List(); $this->edu2list = getEdu2List(); $this->edu3list = getEdu3List(); $this->edu4list = getEdu4List(); $this->edu1Fee = getMsEducationFee($this->edu1list); $this->edu2Fee = getMsEducationFee($this->edu2list); $this->edu3Fee = getMsEducationFee($this->edu3list); $this->edu4Fee = getMsEducationFee($this->edu4list); } //get education fee of a child function getChildEducationFee($birthday,$year, $schoolkbn1,$schoolkbn2,$schoolkbn3,$schoolkbn4) { if ($birthday != '') { $fee = 0; //小学校の学費 $fee = $fee + getEducationFee(6, 11, $birthday,$year, $schoolkbn1,$this->edu1Fee); //中学校 $fee = $fee + getEducationFee(12, 14, $birthday,$year, $schoolkbn2,$this->edu2Fee); //高校 $fee = $fee + getEducationFee(15, 17, $birthday,$year, $schoolkbn3,$this->edu3Fee); //専門学校 $edu4aList = getEdu4aList(); if (isset($edu4aList[$schoolkbn4])) { $fee = $fee + getEducationFee(18, 19, $birthday,$year, $schoolkbn4,$this->edu4Fee); } else { //大学 $fee = $fee + getEducationFee(18, 21, $birthday,$year, $schoolkbn4,$this->edu4Fee); } } else { $fee = 0; } return $fee; } function getAllEducationFee($year) { $fee = 0; //child1 $fee = $fee + $this->getChildEducationFee($this->child1_birthday,$year,$this->child1_edu1, $this->child1_edu2,$this->child1_edu3,$this->child1_edu4); $fee = $fee + $this->getChildEducationFee($this->child2_birthday,$year,$this->child2_edu1, $this->child2_edu2,$this->child2_edu3,$this->child2_edu4); $fee = $fee + $this->getChildEducationFee($this->child3_birthday,$year,$this->child3_edu1, $this->child3_edu2,$this->child3_edu3,$this->child3_edu4); $this->allEducationFee[$year] = $fee; return $fee; } }