| Current Path : /home/h/a/p/happyrenas/old/happy-and-pay.fr/administration/templates/admin3/ |
Linux webd005.cluster105.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 |
| Current File : /home/h/a/p/happyrenas/old/happy-and-pay.fr/administration/templates/admin3/fiche_remboursement.php |
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors','On');
include("config.php");
$proprietaire_mail = $db->escape($_GET['proprietaire_mail']);
if (!$proprietaire_mail) {$proprietaire_mail = $db->escape($_POST['proprietaire_mail']);}
$reservation_id = $_REQUEST['reservation_id'];
?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="fr" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8"/>
<title>ADMINISTRATION HAPPY RENTALS</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<meta content="" name="description"/>
<meta content="" name="author"/>
<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css"/>
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN PAGE LEVEL PLUGIN STYLES -->
<link href="../../assets/global/plugins/bootstrap-daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/plugins/fullcalendar/fullcalendar.min.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/plugins/jqvmap/jqvmap/jqvmap.css" rel="stylesheet" type="text/css"/>
<!-- END PAGE LEVEL PLUGIN STYLES -->
<!-- BEGIN PAGE STYLES -->
<link href="../../assets/admin/pages/css/tasks.css" rel="stylesheet" type="text/css"/>
<!-- END PAGE STYLES -->
<!-- BEGIN THEME STYLES -->
<link href="../../assets/global/css/components.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/css/plugins.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/admin/layout2/css/layout.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/admin/layout2/css/themes/grey.css" rel="stylesheet" type="text/css" id="style_color"/>
<link href="../../assets/admin/layout2/css/custom.css" rel="stylesheet" type="text/css"/>
<!-- END THEME STYLES -->
<link rel="shortcut icon" href="favicon.ico"/>
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<!-- DOC: Apply "page-header-fixed-mobile" and "page-footer-fixed-mobile" class to body element to force fixed header or footer in mobile devices -->
<!-- DOC: Apply "page-sidebar-closed" class to the body and "page-sidebar-menu-closed" class to the sidebar menu element to hide the sidebar by default -->
<!-- DOC: Apply "page-sidebar-hide" class to the body to make the sidebar completely hidden on toggle -->
<!-- DOC: Apply "page-sidebar-closed-hide-logo" class to the body element to make the logo hidden on sidebar toggle -->
<!-- DOC: Apply "page-sidebar-hide" class to body element to completely hide the sidebar on sidebar toggle -->
<!-- DOC: Apply "page-sidebar-fixed" class to have fixed sidebar -->
<!-- DOC: Apply "page-footer-fixed" class to the body element to have fixed footer -->
<!-- DOC: Apply "page-sidebar-reversed" class to put the sidebar on the right side -->
<!-- DOC: Apply "page-full-width" class to the body element to have full width page without the sidebar menu -->
<body class="page-boxed page-header-fixed page-sidebar-closed-hide-logo page-container-bg-solid page-sidebar-closed-hide-logo">
<!-- BEGIN HEADER -->
<?include("header_top.php");?>
<!-- END HEADER -->
<div class="clearfix">
</div>
<!-- BEGIN CONTAINER -->
<div class="container">
<div class="page-container">
<!-- BEGIN SIDEBAR -->
<div class="page-sidebar-wrapper">
<!-- DOC: Set data-auto-scroll="false" to disable the sidebar from auto scrolling/focusing -->
<!-- DOC: Change data-auto-speed="200" to adjust the sub menu slide up/down speed -->
<div class="page-sidebar navbar-collapse collapse">
<?include("header_left.php");?>
</div>
</div>
<!-- END SIDEBAR -->
<!-- BEGIN CONTENT -->
<div class="page-content-wrapper">
<div class="page-content">
<?
////////////////////////////////////////////
////////////////////////////////////////////
require_once 'mangopay/vendor/autoload.php';
$MangopayApi = new \MangoPay\MangoPayApi();
$MangopayApi->Config->ClientId = 'philippe2015';
$MangopayApi->Config->ClientPassword = 'hK15oQKQig9N2UFEXQpCoirptU4VTeU28p0CTyiprt0fQuwFPP';
$MangopayApi->Config->TemporaryFolder = 'temp';
$MangopayApi->Config->BaseUrl = 'https://api.mangopay.com';
////////////////////////////////////////////
$remboursement_id = "";
$paymentid = "";
$amount = "";
$AuthorId = "";
$error_refund = "";
$requete = "";
if (isset($_POST['paymentid'])) {$paymentid = $_POST['paymentid'];}
if (isset($_POST['amount'])) {$amount = $_POST['amount'];}
$remboursement_date = date("Y-m-d H:i:s");
$remboursement_date = date("Y-m-d", strtotime($remboursement_date));
if($paymentid && $amount && $proprietaire_mail)
{
/// SET EMAILER
require_once('includes/class.phpmailer.php');
require_once('includes/class.smtp.php');
//GET AMOUNT AND AUTHOR ID
$payin = $MangopayApi->PayIns->Get($paymentid);
$amount_credited = $payin->CreditedFunds->Amount;
$AuthorId = $payin->AuthorId;
$amount_credited=$amount_credited/100;
/// GET DATABASE INFO
$myquery = "SELECT * from client_reservation where payment_id = '".$paymentid."'";
$reservation = $db->get_row($myquery);
$id = $reservation->id;
$is_repayed = $reservation->is_repayed;
/// check if asked amount is inferior to debited amount
if($amount_credited>=$amount && $is_repayed == 0 && $id!="")
{
/// FORCE remboursement_montant
$remboursement_montant = $amount;
$remboursement_montant=str_replace(".",",",$remboursement_montant);
//$remboursement_montant = "4.85";
//Build the parameters for the request
$Refund = new \MangoPay\Refund();
$Refund->AuthorId = $AuthorId;
$Refund->DebitedFunds = new \MangoPay\Money();
$Refund->DebitedFunds->Currency = "EUR";
$Refund->DebitedFunds->Amount = $remboursement_montant*100;
$Refund->Fees = new \MangoPay\Money();
$Refund->Fees->Currency = "EUR";
$Refund->Fees->Amount = 0;
// DEBUG
//echo $paymentid."<br>";
//echo $AuthorId."<br>";
//echo $remboursement_montant;
//echo "<pre>";print_r($Refund);echo "</pre>";
// DEBUG
//DO THE REFUND
$Result = $MangopayApi->PayIns->CreateRefund($paymentid, $Refund);
$remboursement_id = $Result ->Id;
/// MAIL TO THE CLIENT
include('tpl_remboursement.php');
$objet="Remboursement";
$from = "no-reply@happy-and-pay.fr";
$destinataire = "phil_aph@hotmail.com";
$reply = $from;
$mail = new PHPmailer();
$mail->SMTPDebug = 0;
$mail->CharSet = "UTF-8";
$mail->IsHTML(true);
$mail->From=$from;
$mail->AddAddress($destinataire);
$mail->AddBCC("phil_aph@hotmail.com");
$mail->AddBCC("happyendpay@happy-rentals.com");
$mail->AddReplyTo($reply);
$mail->Subject=$objet;
$mail->Body=$message;
//if(!$mail->Send())
//{echo $mail->ErrorInfo;}
//else{echo '';}
unset($mail);
//// UPDATE DATABASE
$requete = "UPDATE client_reservation SET is_repayed = 1, remboursement_id = '".$remboursement_id."', remboursement_destinataire = '".$AuthorId."', remboursement_date = '".$remboursement_date."', remboursement_montant = '".$remboursement_montant."' WHERE `id` =".$id;
$db->query($requete);
}
else
{
$AuthorId = '';
if($amount_credited<$amount) {$error_refund = 'Le montant demandé ('.$amount.' €) est supérieur au montant débité au client ( '.$amount_credited.' €)';}
if($id=='') {$error_refund = 'Aucune reservation associee a cet ID de transaction';}
if($is_repayed > 0) {$error_refund = 'Cette transaction a deja ete remboursee';}
}
}
if($AuthorId!='') {echo "<div class='alert alert-info alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Remboursement de ".$remboursement_montant." euros pour la réservation ".$id ."</div>";}
if($error_refund!='') {echo "<div class='alert alert-info alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$error_refund."</div>";}
$myquery="select * from client_reservation where 1 AND proprietaire_mail = '$proprietaire_mail' AND id = '$reservation_id'";
$transaction = $db->get_row($myquery);
$paymentid=$transaction->payment_id;
$amount=$transaction->payment_id_montant-$transaction->payment_id_commission;
?>
<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
<!-- /.modal -->
<!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
<!-- BEGIN PAGE HEADER-->
<h3 class="page-title">
Tableau de bord</h3>
<div class="page-bar">
<ul class="page-breadcrumb">
<li>
<i class="fa fa-home"></i>
<a href="index.php">Accueil</a>
<i class="fa fa-angle-right"></i>
</li>
<li>
<a href="#">Tableau de bord</a>
</li>
</ul>
</div>
<!-- END PAGE HEADER-->
<?// CLIENTS //?>
<div class="row">
<div class="col-md-12">
<div class="portlet box blue-hoki">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-cogs"></i>Remboursement
</div>
<div class="tools">
<a href="javascript:;" onclick='location.reload(true); return false;' class="reload">
</a>
</div>
</div>
<div class="portlet-body form">
<form action="<?echo $_SERVER['PHP_SELF'];?>" method="POST" class="form-horizontal">
<input type="hidden" name="reservation_id" value="<?echo $reservation_id;?>">
<input type="hidden" name="proprietaire_mail" value="<?echo $transaction->proprietaire_mail;?>">
<div class="form-body">
<div class="form-group">
<label class="control-label col-md-3">Transaction : </label>
<div class="col-md-6">
<input readonly style="background:#ff6400;color:#fff;" value="<?echo $paymentid;?>" type="text" name="paymentid" placeholder="" maxlength="100" class="form-control c-square c-theme input-lg" required/>
</div>
</div>
<div class="form-group" >
<label class="control-label col-md-3">Montant : </label>
<div class="col-md-6">
<input style="background:#ff6400;color:#fff;" value="<?echo $amount;?>" type="text" name="amount" placeholder="" maxlength="100" class="form-control c-square c-theme input-lg" required/>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-md-9">
<button type="submit" class="btn btn-primary btn-lg c-btn-uppercase">VALIDER</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<?include("footer.php");?>