Esempio n. 1
0
                        ?>
&fdb=2">Next</a>
			</div>
		<?php 
                    }
                } else {
                    ?>
			<table width=100% height=100% border=0 class="tablecss">
				<tr>
					<td width=40% valign="top">
			<?php 
                    $lastaloan = $database->getLastloan($id);
                    $tpm = 2;
                    if (!empty($lastaloan)) {
                        $activeloanid = $lastaloan['loanid'];
                        $currenlonAmt = convertToNative($lastaloan['reqdamt'], $currRate);
                        $dcurrenlonAmt = $lastaloan['reqdamt'];
                        $bot = '';
                        if ($lastaloan['active'] == LOAN_OPEN) {
                            $bot = $lang['profile']['Bid_open'] . date('M d, Y', $lastaloan['applydate'] + $database->getAdminSetting('deadline') * 24 * 60 * 60);
                            $totBid = $database->getTotalBid($id, $activeloanid);
                            $tpm = 1;
                        } else {
                            if ($lastaloan['active'] == LOAN_FUNDED) {
                                $bot = $lang['profile']['Funded'] . date('M d, Y', $lastaloan['AcceptDate']);
                            } else {
                                if ($lastaloan['active'] == LOAN_ACTIVE) {
                                    $bot = $lang['profile']['Active'] . date('M d, Y', $lastaloan['AcceptDate']);
                                } else {
                                    if ($lastaloan['active'] == LOAN_REPAID) {
                                        $bot = $lang['profile']['Repaid'];
Esempio n. 2
0
 if ($sublevel == LENDER_GROUP_LEVEL) {
     $lusername = $lname;
 } else {
     $lusername = $rows['username'];
 }
 $data = $database->getLenderDetails($lendid);
 $hide_karma = $data['hide_karma'];
 //=0 means show karma score
 if ($hide_karma != 1) {
     $karma_score = "(" . number_format($database->getKarmaScore($lendid)) . ")";
     $karma_tooltip = $lang['profile']['karma_tooltip'];
 } else {
     $karma_score = "";
 }
 $bidamount = $rows['bidamount'];
 $kamount = convertToNative($bidamount, $CurrencyRate);
 $bidint = $rows['bidint'];
 $biddate = $rows['biddate'];
 $acceptedAmt = $rows['acceptedAmt'];
 $totBidAmt += $bidamount;
 $lendprurl = getUserProfileUrl($lendid);
 if ($rows['color'] == 0) {
     $colour = '; color:#CCBBBB';
 } else {
     $colour = '; color:##3D3D3D';
 }
 echo "<tr>";
 echo "<td>" . date('M d', $biddate) . "</td>";
 echo "<td><a href='{$lendprurl}'>{$lusername}</a> <br/><a style='cursor:pointer' class='tt'>{$karma_score}<span class='tooltip'><span class='top'></span><span class='middle'>{$karma_tooltip}</span><span class='bottom'></span></span></a>\n\t\t\t\t\t\t\t\t\t</td>";
 if ($lendid == $session->userid && !$rows['use_lender_invite_credit']) {
     $name1 = 'bidamt' . $i;
Esempio n. 3
0
 } else {
     $amt_step = 10;
     $inst_step = 1;
 }
 $rate = $database->getCurrentRate($userid);
 //loan application page 1
 $webfee = $database->getAdminSetting('fee');
 //website fee rate
 $maxLoanAppInterest = $database->getAdminSetting('maxLoanAppInterest') + $database->getAdminSetting('fee');
 $usdmaxBorrowerAmt = $session->getCurrentCreditLimit($session->userid, true);
 // function created by julia 08-12-13 used by Mohit
 $usdminBorrowerAmt = $database->getAdminSetting('minBorrowerAmt');
 //website fee rate
 $maxBorrowerAmt = ceil($usdmaxBorrowerAmt);
 /* It is in native currency */
 $minBorrowerAmt = ceil(convertToNative($usdminBorrowerAmt, $rate));
 $minIns = $session->getMinInstallment($maxBorrowerAmt, $maxperiodValue, $webfee, 0, $weekly_inst);
 $categories = $database->getLoanCategoriesForLoanApplication();
 $back = (bool) (!$form->values) && isset($_SESSION['la']);
 $bfrstloan = $database->getBorrowerFirstLoan($userid);
 if (!$bfrstloan) {
     $currency_amt = $database->getReg_CurrencyAmount($userid);
     foreach ($currency_amt as $row) {
         $currency1 = $row['currency'];
         $amount_reg = $row['Amount'];
         $amt = number_format($amount_reg, 0, ".", "");
     }
 }
 if ($back == 0) {
     $loan_amt = $form->value('amount');
     if (empty($loan_amt) || $loan_amt == 0) {
Esempio n. 4
0
     for ($i = $k; $i <= 12; $i++) {
         if ($value <= 200) {
             $value = $session->getNextLoanValue($value, $SecondLoanpercent);
             if ($i == 2) {
                 $loanusdvalue = $SecondLoanVal;
             } else {
                 $loanusdvalue = $ThirdLoanVal;
             }
             if ($loanusdvalue < $value) {
                 $value = $loanusdvalue;
             }
             $val = number_format(convertToNative($value, $rate), 0, ".", ",");
             $params['nxtLoanvalue'] .= "<br/>" . $i . ". " . $tmpcurr . ' ' . $val;
         } else {
             $value = $session->getNextLoanValue($value, $nextLoanpercent);
             $local_value = convertToNative($value, $rate);
             if ($local_value > $max_amt) {
                 $val = number_format($max_amt, 0, ".", ",");
                 $params['nxtLoanvalue'] .= "<br/>" . $i . ". and thereafter " . $tmpcurr . ' ' . $val;
                 break;
             } else {
                 $val = number_format($local_value, 0, ".", ",");
                 $params['nxtLoanvalue'] .= "<br/>" . $i . ". " . $tmpcurr . ' ' . $val;
             }
         }
     }
 }
 if ($latePayments['missedInst'] == 0 || empty($latePayments['missedInst'])) {
     $currentcreditlimit = $maxborwAmtNextLoan;
     if ($loanstatus == LOAN_FUNDED || $loanstatus == LOAN_OPEN) {
         $params['currencreditlimit'] = $tmpcurr . ' ' . number_format($loanData['AmountGot'], 0, ".", ",");
Esempio n. 5
0
 function wasFirstInstalOnTime($userid, $loanid)
 {
     global $db;
     $asof_day = time() - 86400 * 10;
     //subtract ten days to consider only installments due over ten days ago
     $timethreshold = 86400 * 10;
     //anything paid within 10 days of due date is on time
     $dollar_threshold = 10;
     //set amount threshold to ten dollars
     $CurrencyRate = $this->getExRateById($userid);
     $local_threshold = convertToNative($dollar_threshold, $CurrencyRate);
     $q1 = "SELECT min(duedate) from ! WHERE loanid = ? AND amount>0 AND duedate <= ?";
     $res1 = $db->getOne($q1, array('repaymentschedule', $loanid, $asof_day));
     $q2 = "SELECT COUNT(id) from ! WHERE loanid = ? AND duedate = ? AND paiddate <= (duedate + {$timethreshold}) AND (amount - paidamt) <= {$local_threshold} AND (amount - paidamt) <= amount";
     //shortfall cannot be more than ten dollars or size of installment
     $res2 = $db->getOne($q2, array('repaymentschedule', $loanid, $res1));
     if ($res2 > 0) {
         $ontime = 1;
         //on time
     } else {
         $ontime = 0;
         //not on time
     }
     return $ontime;
 }
Esempio n. 6
0
     $conversion = 1200;
     if ($gperiod < 2) {
         $gperiodText = $lang['loanstatn']['month'];
     } else {
         $gperiodText = $lang['loanstatn']['months'];
     }
     if ($period < 2) {
         $periodText = $lang['loanstatn']['month'];
     } else {
         $periodText = $lang['loanstatn']['months'];
     }
 }
 $feeamount = $newperiod * $amount * $fee / $conversion;
 $feelender = $newperiod * $amount * $rate / $conversion;
 $interestrate = $database->getAvgBidInterest($ud, $ld);
 $lamount = convertToNative($brw2['reqdamt'], $CurrencyRate);
 $interest = $brw2['interest'] - $webfee;
 $totToPayBack = 0;
 $totFee = 0;
 if ($brw2['active'] == LOAN_OPEN || $brw2['active'] == LOAN_FUNDED) {
     $totToPayBack = $lamount + $lamount * $newperiod * ($interest + $webfee) / $conversion;
     $totFee = $interest + $webfee;
 } else {
     $totToPayBack = $brw2['AmountGot'] + $brw2['AmountGot'] * $newperiod * ($interestrate + $webfee) / $conversion;
     $totFee = $interestrate + $webfee;
 }
 if (!$bfrstloan) {
     $currency_amt = $database->getReg_CurrencyAmount($ud);
     foreach ($currency_amt as $row) {
         $b_reg_fee_native = number_format($row['Amount'], 2);
     }
Esempio n. 7
0
 function getCurrentCreditLimit($userid, $addCreditearned)
 {
     global $database;
     $firstloan = $database->getBorrowerFirstLoan($userid);
     $loanstatus = $database->getLoanStatus($userid);
     $rate = $database->getCurrentRate($userid);
     $invitecredit = $database->getInviteCredit($userid);
     if ($loanstatus == LOAN_ACTIVE || $loanstatus == LOAN_FUNDED || $loanstatus == LOAN_OPEN) {
         //case where borrower has an active loan or fundraising application - we calculate credit limit based on current loan amount
         $loanid = $database->getCurrentLoanid($userid);
         $ontime = 1;
         //assume current loan will be repaid on time for purpose of displaying future credit limits
     } else {
         //case where borrower has repaid one or more loans and has not yet posted an application for a new one - we calculate credit limit based on most recently repaid loan amount
         $loanid = $database->getLastRepaidloanId($userid);
         $ontime = $database->isRepaidOntime($userid, $loanid);
     }
     $loanData = $database->getLoanApplic($loanid);
     $currentloanamt = $loanData['AmountGot'];
     if ($firstloan == 0) {
         //case where borrower has not yet received first loan disbursement - credit limit should equal admin 1st loan size plus invited borrower credit if applicable
         $val = $database->getAdminSetting('firstLoanValue');
         $invitedstatus = $database->getInvitee($userid);
         $text_length = $database->getTextResponseLength($userid);
         if (!empty($invitedstatus)) {
             $bonuscredit = 100;
             //adds bonus for new members who were invited by eligible existing members
         } elseif (!empty($text_length)) {
             if ($text_length >= 40 && $text_length <= 60) {
                 $bonuscredit = 100;
                 //adds bonus of for new members who entered optimal length of text response to 'How did you hear about Zidisha' optional question in application
             } else {
                 $bonuscredit = 0;
             }
         }
         $totalval = $val + $bonuscredit;
         $currentlimit = ceil(convertToNative($totalval, $rate));
         return $currentlimit;
     } elseif ($ontime != 1) {
         //case where last loan was repaid late - credit limit should equal last loan repaid on time or admin first loan setting, if no loan was ever repaid on time
         $prevamount = $database->getPreviousLoanAmount($userid, $loanid);
         if (!empty($prevamount) && $prevamount > 10) {
             $currentlimit = $prevamount;
         } else {
             $val = $database->getAdminSetting('firstLoanValue');
             $val_local = convertToNative($val, $rate);
             if ($addCreditearned == false) {
                 $currentlimit = $val_local;
             } else {
                 $currentlimit = ceil($val_local + $invitecredit);
             }
         }
         return $currentlimit;
     } else {
         //case where last loan was repaid on time, we next check whether monthly installment repayment rate meets threshold
         $repayrate = $this->RepaymentRate($userid);
         $minrepayrate = $database->getAdminSetting('MinRepayRate');
         if ($repayrate < $minrepayrate) {
             //case where last loan repaid on time but monthly installment repayment rate is below admin threshold - loan size stays same
             if ($addCreditearned == false) {
                 $currentlimit = ceil($currentloanamt);
             } else {
                 $currentlimit = ceil($currentloanamt + $invitecredit);
             }
         } else {
             //case where last loan repaid on time and overall repayment is above admin threshold - we next check whether the last loan was held long enough to qualify for credit limit increase, with the amount of time loans need to be held and size of increase both dependent on previous loan amount
             $disbdate = $database->getLoanDisburseDate($loanid);
             $currenttime = time();
             $months = $database->IntervalMonths($disbdate, $currenttime);
             $currentloanamt_usd = convertToDollar($currentloanamt, $rate);
             if ($currentloanamt_usd <= 200) {
                 $timethrshld = $database->getAdminSetting('TimeThrshld');
                 $percentincrease = $database->getAdminSetting('secondLoanPercentage');
             } elseif ($currentloanamt_usd <= 1000) {
                 $timethrshld = $database->getAdminSetting('TimeThrshldMid1');
                 $percentincrease = $database->getAdminSetting('nextLoanPercentage');
             } elseif ($currentloanamt_usd <= 3000) {
                 $timethrshld = $database->getAdminSetting('TimeThrshldMid2');
                 $percentincrease = $database->getAdminSetting('nextLoanPercentage');
             } elseif ($currentloanamt_usd > 3000) {
                 $timethrshld = $this->getAdminSetting('TimeThrshld_above');
                 $percentincrease = $database->getAdminSetting('nextLoanPercentage');
             }
             if ($months < $timethrshld) {
                 //if the loan has not been held long enough then borrower does not yet qualify for credit limit increase
                 if (!$addCreditearned) {
                     $currentlimit = ceil($currentloanamt);
                 } else {
                     $currentlimit = ceil($currentloanamt + $invitecredit);
                 }
             } else {
                 //case where last loan was repaid on time, overall repayment rate is above threshold and loan held for long enough to qualify for credit limit increase
                 $lastinst_amt = $database->getLastInstallmentAmt($userid, $loanid);
                 if ($lastinst_amt > $currentloanamt * 0.1 && convertToDollar($lastinst_amt, $rate) > 100) {
                     //case where more than 30% and $100 of last loan was paid in the last installment
                     if (!$addCreditearned) {
                         $currentlimit = ceil($currentloanamt);
                     } else {
                         $currentlimit = ceil($currentloanamt + $invitecredit);
                     }
                 } else {
                     if ($addCreditearned == false) {
                         $currentlimit = ceil($currentloanamt * $percentincrease / 100);
                         if ($loanstatus == LOAN_OPEN) {
                             $currentlimit = $currentloanamt;
                             // added by mohit to fix credit limit on edit loan page
                         }
                     } else {
                         $currentlimit = ceil($currentloanamt * $percentincrease / 100) + $invitecredit;
                     }
                 }
             }
         }
     }
     return $currentlimit;
 }