{% include 'header.twig' %}

<div class="appContent">
  <section class="dashboard-head-wrapper">
    <div class="container-fluid">
      <div class="dashboard-head card-border">
        <div class="dhead-body">
          <h2 class="title">
                        Affiliate Program
                      </h2>
          <p class="text">
                        Here you will find your personal advertising link to recruit new partners and receive commissions.
                      </p>
        </div>
        <div class="dhead-img-wrapper">
          <img src="https://cdn.mypanel.link/d8jvq7/zq30a105xwc0rwg9.png" class="dhead-img" alt="Coin Moin">
        </div>
      </div>
    </div>
  </section>
  
  
<div class="wrapper-content__body">
      <!-- Main variables *content* -->
      <div id="block_61">
	<div class="affiliates-info">
		<div class="bg"></div>
		<div class="divider-top"></div>
		<div class="divider-bottom"></div>
		<div class="container">
			<div class="row affiliate-block__main pl-0 pr-0">
				<div class="col-lg-4">
					<div class="component_card">
						<div class="card">
						    
						    {% if error %}
					<div class="alert alert-dismissible alert-danger">
						{{ errorText }}
					</div>
					<br>
				{% endif %}

				{% if success %}
					<div class="alert alert-dismissible alert-success">
						{{ successText }}
					</div>
					<br>
				{% endif %}


							<div class="affiliate-card__title">Referral link</div>
							<div class="affiliate-card__desc">
								<span id="link" class="mr-1">{{ site["url"] }}/affiliates?ref={{ user['ref_code'] }}</span>
								<a href="#">
											<span
													data-clip="true"
													title="Link copied"
													data-clipboard-action="copy"
													data-clipboard-target="#link"
													class="fas fa-clone"></span>
								</a>
							</div>
						</div>
					</div>
				</div>
				<div class="col-lg-4">
					<div class="component_card">
						<div class="card">
							<div class="affiliate-card__title">Commission rate</div>
							<div class="affiliate-card__desc">{{settings["referral_commision"]}}%</div>
						</div>
					</div>
				</div>
				<div class="col-lg-4">
					<div class="component_card">
						<div class="card">
							<div class="affiliate-card__title">Minimum payout</div>
							<div class="affiliate-card__desc">{{settings["referral_payout"]}}</div>
						</div>
					</div>
				</div>
			</div>
<br>
            <div class="row affiliates-info__alignment">
                <div class="col-lg-12">
                    <div class="table-bg component_table_statistics ">
                        <div class="table-wr table-responsive">
                            <table class="table">
                                <thead>
                                <tr>
                                    <th>Total visits</th>
                                    <th>Successful referrals</th>
                                    <th>Conversion rate</th>
                                    <th>Total earnings</th>
<th>Paid earnings</th>
                                    <th>Available earnings</th>
                    <th>Rejected earnings</th>

<th>Action</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr class="affiliates-table-border-none">
<tr>
                                   

	{% for ref in ref_content %}																
<td>{{ ref['referral_clicks'] }}</td>
<td>{{ ref['referral_sign_up'] }}</td>
<td>{{ ( ref['referral_sign_up'] / ref['referral_clicks']) * 100 }}%</td>
<td>{{ currency['symbol'] }}{{ ref['referral_total_commision']*currency["value"] }}</td>
<td>{{ currency['symbol'] }}{{ ref['referral_earned_commision']*currency["value"] }}</td>
<td>{{ currency['symbol'] }}{{ (ref['referral_total_commision'] - (ref['referral_earned_commision']  +  ref['referral_requested_commision'] +  ref['referral_rejected_commision'])) *currency["value"] }}</td>
<td>{{ currency['symbol'] }}{{ ref['referral_rejected_commision']*currency["value"] }}</td>
<td><form method="post" action="">

																				<input type="hidden" name="ref_code" value="{{ user['ref_code'] }}">
																				<input type="hidden" name="ref_amt" value="{{ ref['referral_total_commision'] - (ref['referral_earned_commision'] + ref['referral_requested_commision'] ) }}">
																				<a href="javascript:void(0)">
																				{% if (ref['referral_total_commision'] - (ref['referral_earned_commision'] + ref['referral_requested_commision'] + ref['referral_rejected_commision'] )) >= settings["referral_payout"] %} <button type="submit" style="margin-left:2px;" class="btn btn-actions">Request Paid Out</button>
															 {% endif %} 						</a>

																			</form>
																		</td>
																	</tr>
																</td>
															</tbody>
													
													{% endfor %}
	</tr>

												</tbody> 
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div></div>
<br>
<div id="block_14">
    <div class="affiliates-list">
        <div class="bg"></div>
        <div class="divider-top"></div>
        <div class="divider-bottom"></div>
        <div class="container-fluid">
            <div class="row affiliate-list__alignment">
                <div class="col-lg-12">
                    <div class="table-bg affiliate-block__table-payments component_table ">
                        <div class="table-wr table-responsive">
                            <table class="table">
                                <thead>
                                <tr>
                                    <th>Payout date</th>
                                    <th>Payout amount</th>
<th>Last Updated</th>
                                    <th>Payout status</th>
                                </tr>
                                </thead>
                                <tbody>
	{% for ref_payout in ref_payouts %}
														<tr>
<td>{{ ref_payout['r_p_requested_at'] }}</td>
<td>{{ currency['symbol'] }}{{ ref_payout['r_p_amount_requested']*currency["value"] }}</td>
<td>{{ ref_payout['r_p_updated_at'] }}</td>
<td>
																{% if (ref_payout['r_p_status'] == 0)  %}
																	{{ "Pending" }}
																{% elseif (ref_payout['r_p_status'] == 1)  %}
																	{{ "Disapproved" }}
																{% elseif (ref_payout['r_p_status'] == 2)  %}
																	{{ "Approved" }}
																{% elseif (ref_payout['r_p_status'] == 3)  %}
																	{{ "Rejected" }}
																{% endif %}
															</td>

														</tr>
													{% endfor %}
												</tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row affiliate-list__alignment">
                <div class="col-lg-12">
                    <nav class="component_pagination">
                        <div class="">
                                                    </div>
                    </nav>
                </div>
            </div>
        </div>
    </div>
</div>
</div></div>
</div>


{% include 'footer.twig' %}