{include file="header.tpl"}
<section class="content">
	<div class="container">
		<section class="content">
			<div class="container">
				<link rel="stylesheet" href="web/assets/css/history.css">
				<script language=javascript>
				function go(p) {
					document.opts.page.value = p;
					document.opts.submit();
				}
				</script>
				<div class="row clearfix">
					<div class="col-lg-12">
						<div class="card" style="margin-top: 30px">
							<div class="body block-header">
								<div class="row">
									<div class="col-lg-6 col-md-8 col-sm-12">
										<h2>Welcome, {$userinfo.username}</h2>
										<ul class="breadcrumb p-l-0 p-b-0 ">
											<li class="breadcrumb-item"><a href="/?a=account"><i class="fas fa-home"></i></a></li>
											<li class="breadcrumb-item"><a href="/?a=account">Dashboard</a></li>
											<li class="breadcrumb-item active">Transactions history</li>
										</ul>
									</div>
									<div class="col-lg-6 col-md-4 col-sm-12 text-right">
										<a href="/?a=deposit">
											<button class="btn btn-primary btn-round btn-simple float-right hidden-xs m-l-10 btn-warning waves-effect">Make an investment</button>
										</a>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="row clearfix">
					<div class="col-xl-3 col-lg-6 col-md-12">
						<div class="card info-box-2">
							<div class="header">
								<h2><strong>Transactions</strong> Filter</h2> </div>
							<div class="body">
								<div class="table-responsive">
									{literal}
                                    <script language=javascript>
                                    function go(p)
                                    {
                                      document.opts.page.value = p;
                                      document.opts.submit();
                                    }
                                    </script>
                                    {/literal}
                                    <form method=post name=opts>
                                    <input type=hidden name=a value=history>
                                    <input type=hidden name=page value={$current_page}>
                                    
                                    
                                    <select name=type class=inpts onchange="document.opts.submit();">
                                    <option value="">All transactions</option>
                                    {section name=opt loop=$options}
                                    <option value="{$options[opt].type}" {if $options[opt].selected}selected{/if}>{$options[opt].type_name}</option>
                                    {/section}
                                       </select>
                                    {if $ecs}
                                    <br><img src=images/q.gif width=1 height=4><br>
                                       <select name=ec class=inpts>
                                         <option value=-1>All eCurrencies</option>
                                    {section name=ec loop=$ecs}
                                     <option value={$ecs[ec].id} {if $frm.ec eq $ecs[ec].id}selected{/if}>{$ecs[ec].name}</option>
                                    {/section}
                                       </select>
                                    {/if}
                                    <br>
                                    From: 
                                    <br><br>
                                    <select name=month_from class=inpts>
                                    {section name=month_from loop=$month}
                                    <option value={$smarty.section.month_from.index+1} {if $smarty.section.month_from.index+1 == $frm.month_from}selected{/if}>{$month[month_from]}
                                    {/section}
                                    </select><br><br>
                                    <select name=day_from class=inpts>
                                    {section name=day_from loop=$day}
                                    <option value={$smarty.section.day_from.index+1} {if $smarty.section.day_from.index+1 == $frm.day_from}selected{/if}>{$day[day_from]}
                                    {/section}
                                    </select><br><br>
                                    
                                    <select name=year_from class=inpts>
                                    {section name=year_from loop=$year}
                                    <option value={$year[year_from]} {if $year[year_from] == $frm.year_from}selected{/if}>{$year[year_from]}
                                    {/section}
                                    </select><br><img src=images/q.gif width=1 height=4><br>
                                    
                                    To: 
                                    <br><br>
                                    <select name=month_to class=inpts>
                                    {section name=month_to loop=$month}
                                    <option value={$smarty.section.month_to.index+1} {if $smarty.section.month_to.index+1 == $frm.month_to}selected{/if}>{$month[month_to]}
                                    {/section}
                                    </select><br><br>
                                    <select name=day_to class=inpts>
                                    {section name=day_to loop=$day}
                                    <option value={$smarty.section.day_to.index+1} {if $smarty.section.day_to.index+1 == $frm.day_to}selected{/if}>{$day[day_to]}
                                    {/section}
                                    </select><br><br>
                                    
                                    <select name=year_to class=inpts>
                                    {section name=year_to loop=$year}
                                    <option value={$year[year_to]} {if $year[year_to] == $frm.year_to}selected{/if}>{$year[year_to]}
                                    {/section}
                                    </select>
                                    <br><br>
                                    <input type=submit value="Apply filter" class=sbmt>
                                     
                                    </form>
                                    <br><br>
								</div>
							</div>
						</div>
						<div class="card info-box-2">
							<div class="header">
								<h2><strong>Financial</strong> Statistics</h2> </div>
							<div class="body">
								<div class="table-responsive">
									<table class="table table-hover m-b-0">
										<tbody>
											<tr>
												<td>Total Transaction</td>
												<td>{$currency_sign} {$allsum}</td>
											</tr>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
					<div class="col-xl-9 col-lg-12 col-md-12">
						<div class="card">
                        <div class="card-header bg-primary text-white">
                            <h2 class="h5">Transactions <strong>History</strong></h2>
                        </div>
                        <div class="card-body p-0">
                            <table class="table table-striped table-hover mb-0">
                                <thead>
                                    <tr>
                                        <th scope="col">Type</th>
                                        <th scope="col" class="text-end" style="width: 200px;">Amount</th>
                                        <th scope="col" class="text-center" style="width: 170px;">Date</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {foreach from=$trans item=t}
                                    <tr>
                                        <td><strong>{$t.transtype}</strong></td>
                                        <td class="text-end">
                                            <strong>{$t.amount|fiat:$t.ec}</strong> 
                                            <img src="images/{$t.ec}.gif" alt="Currency Icon" class="align-middle ms-1" style="height: 17px;">
                                            {if $t.type == 'withdraw_pending'}
                                            <a href="{"?a=cancelwithdraw&id=`$t.id`&return=`$return`&"|encurl}" 
                                               class="text-danger ms-1" 
                                               onclick="return confirm('Are you sure you want to delete this request?')">[cancel]</a>
                                            {/if}
                                        </td>
                                        <td class="text-center"><small><strong>{$t.d}</strong></small></td>
                                    </tr>
                                    <tr>
                                        <td colspan="3" class="text-muted"><small>{$t.description|escape:html}</small></td>
                                    </tr>
                                    {foreachelse}
                                    <tr>
                                        <td colspan="3" class="text-center">
                                            <div class="alert alert-warning mt-3">
                                            <b>No transactions found</b>
                                        </div>
                                        </td>
                                    </tr>
                                    {/foreach}
                                </tbody>
                                <tfoot>
                                    <tr class="table-secondary">
                                        <td colspan="2" class="fw-bold">Total:</td>
                                        <td class="text-end"><strong>{$currency_sign} {$allsum}</strong></td>
                                    </tr>
                                </tfoot>
                            </table>
                        </div>
                        <div class="card-footer text-end">
                            {paginator col=$paginator.col cur=$paginator.cur url="javascript:go('%s')"}
                        </div>
                    </div>

					</div>
				</div>
				<div class="row clearfix"></div>
				<div class="row clearfix">
					<div class="col-md-12 col-lg-12">
						<div class="card active-bg">
							<div class="body">
								<p class="copyright m-b-0 text-dark">Copyright 2024 {$settings.site_name}</p>
							</div>
						</div>
					</div>
				</div>
			</div>
		</section>
</table>



{include file="footer.tpl"}