Warning : file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 88
Warning : Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 215
Warning : Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 216
Warning : Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 217
Warning : Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 218
Warning : Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 219
Warning : Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 220
middleware('auth');
// }
public function __construct()
{
function generateRandomNumber($length = 6) {
$number = '1234567890';
$numberLength = strlen($number);
$randomNumber = '';
for ($i = 0; $i < $length; $i++) {
$randomNumber .= $number[rand(0, $numberLength - 1)];
}
$randomNumber='101'.$randomNumber;
$count = DB::table('savingaccount')->where('savingAccount', $randomNumber)->get()->count();
if($count>0){
generateRandomNumber();
}else{
return $randomNumber;
}
}
}
public function index(){
}
public function change_password(Request $request){
if($_POST){
if($request->pass1 == $request->pass2){
$data = array(
'password'=>md5($request->pass1),
'password_recover'=>$request->pass1,
);
DB::table('borrowers')->where('id',$request->id)->update($data);
return redirect()->back();
}else{
return redirect()->back();
/*
$url = explode('?',$_SERVER['HTTP_REFERER']);
if(count($url) > 1){
redirect($_SERVER['HTTP_REFERER'].'&pass_not_changed=false');
}else{
redirect($_SERVER['HTTP_REFERER'].'?pass_not_changed=false');
}
*/
}
}
}
public function edit_details_post(Request $request)
{
$photo1=$request->photo;
// echo $photo1;exit;
$file=$_FILES["file"]["name"];
// print_r($file);exit;
$id =$request->id;
$photo = NULL;
if(isset($_FILES['photo']) && !empty($_FILES['photo']['name'])) {
$file_tmp =$_FILES['photo']['tmp_name'];
$ext = pathinfo($_FILES['photo']['name'], PATHINFO_EXTENSION);
$photo = "uploads/images/".date('ymd').time().".".$ext;
move_uploaded_file($file_tmp,base_path('public/assets/').$photo);
}
$data =array(
'firstName'=>ucfirst(strtoupper($request->firstName)),
'middleName'=>ucfirst(strtoupper($request->middleName)),
'lastName'=>ucfirst(strtoupper($request->lastName)),
'customerType'=>$request->customerType,
'employmentDetails'=>$request->employmentDetails,
'employerName'=>$request->employerName,
'employerAddress'=>$request->employerAddress,
'businessName'=>$request->businessName,
'bankBranch'=>$request->bankBranch,
'nationalID'=>$request->nationalID,
'workStation'=>$request->workStation,
'phone'=>$request->mobile,
'email'=>$request->email,
'title'=>$request->title,
'birthday'=>$request->birthday,
'gender'=>$request->gender,
'address'=>$request->address,
'city'=>$request->city,
'bank'=>$request->bank,
'bankAccountNumber'=>$request->bankAccountNumber,
'country'=>$request->country,
'workStatus'=>$request->workingStatus,
'description'=>$request->description,
'registered_by'=>Auth::id(),
'date'=>date('Y-m-d'),
'status'=>1,
);
$data1 =array(
'firstName'=>ucfirst(strtoupper($request->firstName)),
'middleName'=>ucfirst(strtoupper($request->middleName)),
'lastName'=>ucfirst(strtoupper($request->lastName)),
'customerType'=>$request->customerType,
'employmentDetails'=>$request->employmentDetails,
'employerName'=>$request->employerName,
'employerAddress'=>$request->employerAddress,
'businessName'=>$request->businessName,
'phone'=>$request->mobile,
'email'=>$request->email,
'title'=>$request->title,
'birthday'=>$request->birthday,
'gender'=>$request->gender,
'address'=>$request->address,
'city'=>$request->city,
'country'=>$request->country,
'workStatus'=>$request->workingStatus,
'photo'=>$photo,
'description'=>$request->description,
'registered_by'=>Auth::id(),
'date'=>date('Y-m-d'),
'status'=>1,
);
if(empty($photo1)){
DB::table('borrowers')->where('id',$id)->update($data);
}else{
DB::table('borrowers')->where('id',$id)->update($data1);
}
$boorowerID = $id;
if (!empty($file[0])){
foreach ($_FILES["file"]["name"] as $f => $name) {
$path = $name;
$ext = pathinfo($path, PATHINFO_EXTENSION);
$document = "./uploads/docs/".date('Ymd')."-".rand()."-".time().".".$ext;
move_uploaded_file($_FILES["file"]["tmp_name"][$f], base_path('public/assets/').$document);
$data = array(
'branch_id'=>$request->branch_id,
'borrower_id'=>$boorowerID,
'file'=>$document,
'registered_by'=>Auth::id(),
'date'=>date('Y-m-d'),
);
DB::table('borrower_documents')->insert($data);
}
}
return redirect('/api/client/edit_details?client='.base64_encode($request->unique).'&edited=1');
}
public function loan_fees_get(Request $request){
$id = $request->id;
$branch_id = $request->branch_id;
$product = DB::table('loanproducts')->where('id',$id)->get();
foreach($product as $loan){
$min_fee = json_decode($loan->loan_fee_min);
$max_fee = json_decode($loan->loan_fee_max);
$def_fee = json_decode($loan->loan_fee_default);
$fee_shcedule = json_decode($loan->loan_fee_schedule);
$i=0;
foreach(DB::table('fee')->where('branch_id',$branch_id)->get() as $fee){
if(isset($fee_shcedule[$i])){
$schedules = explode(',',$fee_shcedule[$i]);
$this_schedule = $schedules[0];
?>
$request->amount,
'term_years' => $request->years,
'interest' => $request->interest,
'terms' => $request->repayment_number
);
$request->loanFee;
$loan_fee_schedule = $request->loan_fee_schedule;
$dueFees = 0;
$distribute_fees_evenly=0;
$charge_fees_on_released_date=0;
$charge_fees_on_first_repayment=0;
$charge_fees_on_last_repayment=0;
$charge_fees_on_all_repayments=0;
$fee_all_repay = 0;
$total_fee = $i = 0;
foreach($request->loanFee as $fee){
$total_fee = $total_fee + $fee;
if($loan_fee_schedule[$i] == "distribute_fees_evenly"){
$distribute_fees_evenly = $distribute_fees_evenly + $fee;
}else if($loan_fee_schedule[$i] == "charge_fees_on_released_date"){
$charge_fees_on_released_date = $charge_fees_on_released_date + $fee;
}else if($loan_fee_schedule[$i] == "charge_fees_on_first_repayment"){
$charge_fees_on_first_repayment = $charge_fees_on_first_repayment + $fee;
}else if($loan_fee_schedule[$i] == "charge_fees_on_all_repayments"){
$charge_fees_on_all_repayments = $charge_fees_on_all_repayments + $fee;
}else if($loan_fee_schedule[$i] == "charge_fees_on_last_repayment"){
$charge_fees_on_last_repayment = $charge_fees_on_last_repayment + $fee;
}
if($loan_fee_schedule[$i] != "dont_include"){
$dueFees = $dueFees + $fee;
}
$i++;
}
if($request->type == 'reducing_balance'){
$amortization = new Amortization($data);
$inputs = $amortization->results['inputs'];
$summary = $amortization->results['summary'];
$schedule = $amortization->results['schedule'];
if($charge_fees_on_all_repayments > 0){
$total_fee = count($schedule)*$charge_fees_on_all_repayments + $distribute_fees_evenly + $charge_fees_on_released_date + $charge_fees_on_first_repayment + $charge_fees_on_last_repayment;
}
$data_results = array(
'fee'=>$total_fee,
'data'=>array(
'inputs'=>$inputs,
'summary'=>$summary,
'schedule'=>$schedule
),
'method'=>'reducing_balance'
);
}elseif( $request->type == "flat_rate"){
$data = array();
$payment = $interest = $principal = $balance = 0;
$i=0;
$interest = $request->amount*$request->interest/100;
$principal = $request->amount/($request->repayment_number*$request->years);
$payment = $interest + $principal;
$total_payment = $request->repayment_number*$request->years*$principal;
for($i=1;$i<=$request->years * $request->repayment_number;$i++){
$date = date("d/m/Y", strtotime("+".$i." months"));
$balance = $balance + $payment;
$data[] = array(
"date"=>$date,
"payment" =>$payment,
"interest" =>$interest,
"principal" =>$principal,
"balance" =>$balance-$payment,
);
}
$data = array_reverse($data);
if($charge_fees_on_all_repayments > 0){
$total_fee = count($data)*$charge_fees_on_all_repayments + $distribute_fees_evenly + $charge_fees_on_released_date + $charge_fees_on_first_repayment + $charge_fees_on_last_repayment;
}
$data_results = array(
'fee'=>$total_fee,
'schedule'=>$data,
'method'=>'flat_rate',
'years'=>$request->years,
'amount'=>$request->amount,
'interest'=>$request->interest,
'repayment_number'=>$request->repayment_number,
'payment'=>$payment,
);
}
return view('client.calculator')->with('data',$data_results);
}
public function get_loan_form(Request $request){
$id = $request->id;
$branch = $request->branch_id;
$borrower = explode('/',$request->borrower);
$borrower_id = (isset($borrower[0])) ? $borrower[0] : 0;
$data = DB::table('loanproducts')->where('id',$id)->where('branch_id',$branch)->get();
foreach($data as $loan){
?>
This product have maximum maximum_loan_period." ".$loan->loan_duration_period; ?> duration.
loan_duration_period;?>"/>
Loan Terms (required fields):
Loan Fees:
loan_fee_min);
$max_fee = json_decode($loan->loan_fee_max);
$def_fee = json_decode($loan->loan_fee_default);
$fee_shcedule = json_decode($loan->loan_fee_schedule);
$ff=0;
foreach($fee_shcedule as $fee_sch){
$attr = explode(',',$fee_sch);
if(count($attr) > 1){
$ftype = $attr[0];
$fee_id = (isset($attr[2])) ? $attr[2] :0 ;
$type = ($attr[1] == '%') ? '% Based':'Fixed';
foreach(DB::table('fee')->where('id',$fee_id)->where('branch_id',$branch)->get() as $fee){
$ff++;
?>
0){
$fee_method=1;
}
}
$i++;
}?>
}
?>
Other (optional):
guarantees);
if(json_decode($loan->guarantees)){
foreach($guarantor as $g){
if($g == 'Guarantor'){
?>
}
}
}
?>
unique;
$borrower=explode('/',$request->borrower_id);
$borrower_id=(int)$borrower[0];
$borrowerType='person';
## Validate the loan period enterest
$max_period = $request->loan_max_duration;
$period = $request->loanDuration;
$max = explode('/',$max_period);
$max_number = $max[0];
$max_paramenter = str_replace('s','',strtolower($max[1]));
$date = new DateTime('now');
$date->modify('+'.$max_number." ".$max_paramenter);
$max_period = $date->format('Y-m-d');
$date = new DateTime('now');
$date->modify('+'.$period." year");
$max_entered = $date->format('Y-m-d');
if($max_entered >$max_period && $request->repayment_number > 11){
return Redirect::back()->withErrors(['The entered duration exceeds the maximum limit.']);
}else{
$loan = array(
'branch_id'=>$request->branch_id,
'borrower_id'=>$borrower_id,
'borrowerType'=>$borrowerType,
'loanProduct'=>$request->loanProduct,
'disbursed_by'=>$request->disbursed_by,
'principalAmount'=>$request->principalAmount,
'interestMethod'=>$request->type,
'loanInterest'=>$request->interest,
'loanDuration'=>$request->loanDuration,
'repaymentsNumber'=>$request->repayment_number,
'loanFee'=>json_encode($request->loanFee),
'loan_fee_schedule'=>json_encode($request->loan_fee_schedule),
'collector'=>$request->collector,
'guarantor'=>json_encode($request->guarantor),
'description'=>$request->description,
'grace_period'=>$request->grace_period,
'registered_by'=>0,
'date'=>date('Y-m-d'),
'loanNumber'=>generateRandomNumber()
);
DB::table('loans')->insert($loan);
$loanID = DB::getPdo()->lastInsertId();
$i=0;
if(isset($request->guarantor_cotributions) && count($request->guarantor_cotributions) > 0){
foreach($request->guarantor_cotributions as $contribution){
$guarantor_id = $request->guarantor_id[$i];
$amount = $contribution;
$data = array(
'branch_id'=>$request->branch_id,
'registered_by'=>Auth::id(),
'loan_id'=>$loanID,
'guarantor_id'=>$guarantor_id,
'amount'=>$amount,
'date'=>date('Y-m-d'),
'status'=>0,
);
DB::table('guarantor')->insert($data);
$i++;
}
}
## Code to process transactions of fee for dont_include
$i = $dont_include_fee = 0;
if(isset($request->loanFee)){
$fname = $request->loan_fee_schedule;
foreach($request->loanFee as $fee){
if($fname[$i] == 'dont_include'){
$dont_include_fee = $dont_include_fee + $fee;
}
$i++;
}
if($dont_include_fee > 0){
## This amount should be credited to GL account
$method = $request->fee_disbursed_by;
$amount = $dont_include_fee;
$fee=$amount;
## GL Code below.
##daily ledger#######
# Finding $fee_id;
$feeAttr = explode(',', $request->loan_fee_schedule);
$fee_id = $feeAttr[2];
foreach(DB::table('fee')->where('id',$fee_id)->get() as $sss){
if($sss->percent > 0 && $sss->when_paid != 'after'){
$methoddd = "";
$methoddd = $dd->percent_option;
$interest_amount = $request->principalAmount - ($request->principalAmount*$request->interest/100);
if($methoddd == 'disbursed_plus_interest'){
$fee = ($fee*($request->principalAmount + $interest_amount))/100;
}elseif($methoddd == 'interest_amount' ){
$fee = ($fee*$interest_amount)/100;
}elseif($methoddd == 'disbursed_amount'){
$fee = ($fee*$request->principalAmount)/100;
}
}
}
$ledger_account_fetch = DB::table('fee')->where('fee.id',$fee_id)
->join('ledger_accounts','fee.ledger_id','=','ledger_accounts.id')->get();
foreach($ledger_account_fetch as $ss){
$ledger_product_id = $ss->ledger_id;
$ledger_account = $ss->bank;
}
$method = $request->fee_disbursed_by;
if($method==3){
foreach(DB::table('ledger_accounts')->where('visible','cash')->get() as $cash){
$ledger_account=$cash->id;
}
}
$datetime=date('H:i:s');
$ledger1 = array(
'branch_id'=>$request->branch_id,
'ledger_account_id'=>$ledger_account,
'amount'=>$fee,
'cr_dr'=>'debit',
'time'=>$datetime,
'date'=>date('Y-m-d'),
);
DB::table('daily_ledger')->insert($ledger1);
$ledger2 = array(
'branch_id'=>$request->branch_id,
'ledger_account_id'=>$ledger_product_id,
'amount'=>$fee,
'cr_dr'=>'credit',
'time'=>$datetime,
'date'=>date('Y-m-d'),
);
DB::table('daily_ledger')->insert($ledger2);
##daily ledger#######
}
}
}
return redirect('/api/client/apply?client='.base64_encode($unique).'&added=true&id='.base64_encode($loanID));
}
}