<?php
//LAST MODIFIED 02.02.2026

if(isset($_POST['v'])) {

    if (!isset($_POST['terms'])) {
       echo "<script>alert('Please accept the terms and conditions!');</script>";
            return;
    }
    if (!isset($_POST['taxa'])) {
       echo "<script>alert('Please select the type of fee!');</script>";
            return;
    }
    

    $fields_with_limits = [
        'last name' => 255,
'first name' => 255,
'dateofbirth' => 20,
'email' => 65,
'phone' => 255,
'address' => 255,
    ];
    foreach ($fields_with_limits as $field => $limit) {
        if (isset($_POST[$field]) && strlen($_POST[$field]) > $limit) {
            // Generam un mesaj de eroare specific pentru campul care depaseste limita
            echo "<script>alert('The maximum number of characters allowed for " . htmlspecialchars($field) . " is " . $limit . ".');</script>";
            return;
        }
    }
    $suma = 99999;
    $moneda = 'RON';
    if ($_POST['taxa'] == '1') {
        $suma = 800;
        $desc = 'Regular';
    } elseif ($_POST['taxa'] == '2') {
        $suma = 700;
        $desc = 'Student participants';
    } elseif ($_POST['taxa'] == '3') {
        $suma = 1;
        $desc = 'Accompanying person';
    } else{
        echo "<script>alert('Something went wrong; contact us at srftimisoara@gmail.com.');</script>";
            return;
    }

    $mid = '44841002819';
    $key = 'F2DCDDB5E60E8C627DF959AF5F428E4EE1EDD857';

    $data = array(
        'amount' => $suma,
        'curr' => $moneda,
        'invoice_id' => date('YmdHis-') . mt_rand(),	
        'order_desc' => $desc,
        'merch_id' => $mid,
        'timestamp' => date('YmdHis'),
        'nonce' => md5(mt_rand() . time()),
    );
    $data['fp_hash'] = strtoupper(euplatesc_mac($data, $key));
    $data['email'] = @$_POST['email'];
    $data['fname'] = @$_POST['prenume'];
    $data['lname'] = @$_POST['nume'];
    $data['add'] = @$_POST['adresa'];
    $data['phone'] = @$_POST['telefon'];
    $data['zip'] = @$_POST['datanasterii'];
    $data['company'] = @$_POST['sectiunea1'];
    if (@$_POST['sectiunea2'] == '0.Blank') {
//	$data['scompany'] = 'null';
    }
    else {
        $data['company'] .= '; '. @$_POST['sectiunea2'];
    }

    header("location: https://secure.euplatesc.ro/tdsprocess/tranzactd.php?" . http_build_query($data));
    die();
}

function euplatesc_mac($data, $key){
    $str = NULL;
    foreach($data as $d){
        if($d === NULL || strlen($d) == 0){
            $str .= '-';
        }else{
            $str .= strlen($d) . $d;
        }
    }
    return hash_hmac('MD5',$str, pack('H*', $key));
}
?>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        .container{max-width:500px;}

        .btn-primary{
            background-color:#209b60;
            border-color:#209b60;
        }
        .btn-primary:hover{
            background-color:#30ab70;
            border-color:#30ab70;
        }
        div.settings {
    display:grid;
    grid-template-columns: max-content max-content;
    grid-gap:5px;
}
div.settings label       { text-align:right; }
form {
    display: inline-block;
}
    </style>
</head>
<body>
<?php include("inc/header.php"); ?>
<h3>Fields marked with an asterisk are required!</h3>
<form method='POST' action='' target='_parent' id='epform'>
    <div class='settings'>
            <label for="nume">Last name*:</label>
            <input type="text" class="form-control" name='nume' id="nume" required placeholder="Last Name">

            <label for="prenume">Firsr name*:</label>
            <input type="text" class="form-control" name='prenume' id="prenume" required placeholder="First Name">

            <label for="datanasterii">Date of birth*:</label>
            <input type="text" class="form-control" name='datanasterii' id="datanasterii" required placeholder="Date of birth">

            <label for="email">Email*:</label>
            <input type="text" class="form-control" name='email' id="email" required placeholder="Email">

            <label for="telefon">Phone:</label>
            <input type="text" class="form-control" name='telefon' id="telefon" placeholder="Phone">

            <label for="adresa">Address*:</label>
            <input type="text" class="form-control" name='adresa' id="adresa" required placeholder="Correspondence address">

            <label for="sectiunea1">Sectiunea 1*:</label>
            <select name="sectiunea1" required>
            	
            	<option value="9.FMC">Theoretical and Computational Physic</option>
            	<option value="3.FSC">Condensed Matter Physics</option>
            	
            	<option value="8.FMGT">Applied Physics and Interdisciplinarity</option>
            	
            	<option value="10.FE">Educational Physics</option>
            </select>

            <label for="sectiunea2">Sectiunea 2:</label>
            <select name="sectiunea2">
            	<option value="0.Blank">Selecteaza...</option>
            	
            	<option value="9.FMC">Theoretical and Computational Physic</option>
            	<option value="3.FSC">Condensed Matter Physics</option>
            	
            	<option value="8.FMGT">Applied Physics and Interdisciplinarity</option>
            	
            	<option value="10.FE">Educational Physics</option>
            </select>        

	            <label for="sectiunea2">Fee*: </label>
                <table> <tr>
                <td>
                <input type="radio" name="taxa" id="t1" value="1" required>
                <label class="form-check-label" for="t1">
                   Regular 800 RON
                </label> </td>
                <td>
                <input class="form-check-input" type="radio" name="taxa" id="t2" value="2" required>
                <label class="form-check-label" for="t2">
                    Student: 500 RON 
                </label> </td> 
                <td>
                <input class="form-check-input" type="radio" name="taxa" id="t3" value="3" required>
                <label class="form-check-label" fr="t3">
                    Accompanying person: 300 RON 
                </label> </td> 
                </tr>
                </table>


            <input type="checkbox" class="form-control" name='terms' id="terms" placeholder="Terms and Conditions**">
            <label for="terms">Please check the box to accept the <strong>terms and conditions</strong> </label>
        <br>
        <input type='hidden' name='v' value='1'/>
        <button type="submit" class="btn btn-primary btn-block">Pay Safely</button>    </div>
</form>

<p> <strong>*Indicates required field</strong> </p>

<p> <strong>**Terms and conditions apply:</strong>
The fee is non-refundable. By submitting the form above, you agree to these terms. Don't hesitate to get in touch with us at <a href=mailto:timconference@e-uvt.ro>timconference@e-uvt.ro</a> for any questions. </p>

<p> <strong>Bank account details:</strong><br/>
       Name (Nume): Filiala Timisoara a Societatii Romane de Fizica    <br/>
       Address (Adresa): Facultatea de Fizica, Universitatea de Vest din Timisoara, Bd. Vasile Parvan nr. 4, Timisoara 300223, sala F208.
<br/>
       VAT number (Cod fiscal): 27837349 <br/>
       E-mail: <a href=srftimisoara@gmail.com>srftimisoara@gmail.com</a>  <br/>
       Website FTSRF: <a href=https://physics.uvt.ro/srf-tm/>https://physics.uvt.ro/srf-tm/</a> <br/>
       Website SRF: <a href=http://www.srfizica.ro>http://www.srfizica.ro</a> <br/>

<?php include("inc/footer.php"); ?>
</body>
</html>
