<script src="{{CONFIG theme_url}}/js/highcharts/highcharts.js"></script>
<script src="{{CONFIG theme_url}}/js/highcharts/exporting.js"></script>
<link href="{{CONFIG theme_url}}/js/lib/jquery-datatable/skin/bootstrap/css/dataTables.bootstrap.min.css" rel="stylesheet">
<script src="{{CONFIG theme_url}}/js/lib/jquery-datatable/jquery.dataTables.js"></script>
<script src="{{CONFIG theme_url}}/js/lib/jquery-datatable/skin/bootstrap/js/dataTables.bootstrap.js"></script>

<div class="row">
	<div class="col-md-3">
		<div class="settings-sidebar">
			<ul class="list-group">
				<li class="list-group-item">
					<a href="{{LINK dashboard}}" data-load="?link1=dashboard"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path fill="currentColor" d="M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z"/></svg> {{LANG dashboard}}</a>
				</li>
				<li class="list-group-item">
					<a href="{{LINK video_studio}}" data-load="?link1=video_studio"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path fill="currentColor" d="M16 4a1 1 0 0 1 1 1v4.2l5.213-3.65a.5.5 0 0 1 .787.41v12.08a.5.5 0 0 1-.787.41L17 14.8V19a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h14zM7.4 8.829a.4.4 0 0 0-.392.32L7 9.228v5.542a.4.4 0 0 0 .542.374l.073-.036 4.355-2.772a.4.4 0 0 0 .063-.624l-.063-.05L7.615 8.89A.4.4 0 0 0 7.4 8.83z"/></svg> {{LANG videos}}</a>
				</li>
				<li class="list-group-item">
					<a href="{{LINK comments}}" data-load="?link1=comments"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path fill="currentColor" d="M6.455 19L2 22.5V4a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6.455zM7 10v2h2v-2H7zm4 0v2h2v-2h-2zm4 0v2h2v-2h-2z"/></svg> {{LANG comments}}</a>
				</li>
				<?php if ($pt->config->usr_v_mon == 'on' || $pt->config->sell_videos_system == 'on' || $pt->config->payed_subscribers == 'on') { ?>
					<li class="list-group-item active">
						<a href="{{LINK transactions}}" data-load="?link1=transactions"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"></path><path fill="currentColor" d="M14 2a8 8 0 0 1 3.292 15.293A8 8 0 1 1 6.706 6.707 8.003 8.003 0 0 1 14 2zm-3 7H9v1a2.5 2.5 0 0 0-.164 4.995L9 15h2l.09.008a.5.5 0 0 1 0 .984L11 16H7v2h2v1h2v-1a2.5 2.5 0 0 0 .164-4.995L11 13H9l-.09-.008a.5.5 0 0 1 0-.984L9 12h4v-2h-2V9zm3-5a5.985 5.985 0 0 0-4.484 2.013 8 8 0 0 1 8.47 8.471A6 6 0 0 0 14 4z"></path></svg> {{LANG earnings}}</a>
					</li>
				<?php } ?>
                <?php if ($pt->config->movies_videos == 'on' && PT_IsAdmin()) { ?>
					<li class="list-group-item <?php if (!empty($_GET['videos_type']) && $_GET['videos_type'] == 'movies') { echo 'active'; } ?> ">
						<a href="{{LINK video_studio?videos_type=movies}}" data-load="?link1=video_studio&videos_type=movies"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path fill="currentColor" d="M18.001 20H20v2h-8C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10a9.985 9.985 0 0 1-3.999 8zM12 10a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm-4 4a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm8 0a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm-4 4a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/></svg> {{LANG movies}}</a>
					</li>
                <?php } ?>
			</ul>
		</div>
	</div>
	<div class="col-md-9">
		<div class="user-setting-panel pt_shadow">
			<div class="yp_sett_header">
				<h4><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"></path><path fill="currentColor" d="M14 2a8 8 0 0 1 3.292 15.293A8 8 0 1 1 6.706 6.707 8.003 8.003 0 0 1 14 2zm-3 7H9v1a2.5 2.5 0 0 0-.164 4.995L9 15h2l.09.008a.5.5 0 0 1 0 .984L11 16H7v2h2v1h2v-1a2.5 2.5 0 0 0 .164-4.995L11 13H9l-.09-.008a.5.5 0 0 1 0-.984L9 12h4v-2h-2V9zm3-5a5.985 5.985 0 0 0-4.484 2.013 8 8 0 0 1 8.47 8.471A6 6 0 0 0 14 4z"></path></svg> {{LANG earnings}}</h4>
			</div>
			<div class="form-group">
				<div class="row pt_vid_stud_row">
					<div class="col-md-6 col-sm-6">
						<div class="vid_analts_stat" style="background: transparent linear-gradient(291deg, #E95F8A 0%, #FE82A9 100%) 0% 0% no-repeat padding-box;">
							<div><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path fill="currentColor" d="M17 16h2V4H9v2h8v10zm0 2v3c0 .552-.45 1-1.007 1H4.007A1.001 1.001 0 0 1 3 21l.003-14c0-.552.45-1 1.007-1H7V3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-3zM7 16v2h2v1h2v-1h.5a2.5 2.5 0 1 0 0-5h-3a.5.5 0 1 1 0-1H13v-2h-2V9H9v1h-.5a2.5 2.5 0 1 0 0 5h3a.5.5 0 1 1 0 1H7z"/></svg> <h2>{{LANG total_earn}}</h2></div>
							<p>{{TOTAL_EARN}}</p>
						</div>
					</div>
					<div class="col-md-3 col-sm-6">
						<div class="vid_analts_stat" style="background: transparent linear-gradient(308deg, #55479F 0%, #7569B3 100%) 0% 0% no-repeat padding-box;">
							<div><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path fill="currentColor" d="M17 16h2V4H9v2h8v10zm0 2v3c0 .552-.45 1-1.007 1H4.007A1.001 1.001 0 0 1 3 21l.003-14c0-.552.45-1 1.007-1H7V3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-3zM7 16v2h2v1h2v-1h.5a2.5 2.5 0 1 0 0-5h-3a.5.5 0 1 1 0-1H13v-2h-2V9H9v1h-.5a2.5 2.5 0 1 0 0 5h3a.5.5 0 1 1 0 1H7z"/></svg> <h2>{{LANG today}} {{LANG earnings}}</h2></div>
							<p>{{TODAY_EARN}}</p>
						</div>
					</div>
					<div class="col-md-3 col-sm-6">
						<div class="vid_analts_stat" style="background: transparent linear-gradient(309deg, #FE513F 0%, #FE8248 100%) 0% 0% no-repeat padding-box;">
							<div><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path fill="currentColor" d="M17 16h2V4H9v2h8v10zm0 2v3c0 .552-.45 1-1.007 1H4.007A1.001 1.001 0 0 1 3 21l.003-14c0-.552.45-1 1.007-1H7V3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-3zM7 16v2h2v1h2v-1h.5a2.5 2.5 0 1 0 0-5h-3a.5.5 0 1 1 0-1H13v-2h-2V9H9v1h-.5a2.5 2.5 0 1 0 0 5h3a.5.5 0 1 1 0 1H7z"/></svg> <h2>{{LANG this_month}} {{LANG earnings}}</h2></div>
							<p>{{MONTH_EARN}}</p>
						</div>
					</div>
				</div>
				<br>
				<select id="type" name="type" class="form-control">
					<option value="today" <?php echo ($pt->cat_type == 'today') ? 'selected': '';?>>{{LANG today}}</option>
					<option value="this_week" <?php echo ($pt->cat_type == 'this_week') ? 'selected': '';?>>{{LANG this_week}}</option>
					<option value="this_month" <?php echo ($pt->cat_type == 'this_month') ? 'selected': '';?>>{{LANG this_month}}</option>
					<option value="this_year" <?php echo ($pt->cat_type == 'this_year') ? 'selected': '';?>>{{LANG this_year}}</option>
				</select>
			</div>
			<div id="chart-container"></div>
			<div class="clear"></div>
			<?php if ($pt->config->sell_videos_system == 'on') { ?>
				<br>
				<div class="user-ads-list-container pt_vid_stud_ads_list">
					<div class="user-ads-list-header">
						<span class="pointer <?php echo ($pt->page == 'transactions') ? 'active': '';?>">
							<a href="javascript:void(0)">
								<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"></path><path fill="currentColor" d="M14 2a8 8 0 0 1 3.292 15.293A8 8 0 1 1 6.706 6.707 8.003 8.003 0 0 1 14 2zm-3 7H9v1a2.5 2.5 0 0 0-.164 4.995L9 15h2l.09.008a.5.5 0 0 1 0 .984L11 16H7v2h2v1h2v-1a2.5 2.5 0 0 0 .164-4.995L11 13H9l-.09-.008a.5.5 0 0 1 0-.984L9 12h4v-2h-2V9zm3-5a5.985 5.985 0 0 0-4.484 2.013 8 8 0 0 1 8.47 8.471A6 6 0 0 0 14 4z"></path></svg> {{LANG sales_earnings}}
							</a>
						</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<span class="pointer" title="{{LANG wallet}}">
							<a href="{{LINK settings/balance/<?php echo $pt->user->username; ?>}}" data-load="?link1=settings&page=balance&user=<?php echo $pt->user->username; ?>">
								<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"></path><path fill="currentColor" d="M22 10v10a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V10h20zm0-2H2V4a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v4zm-7 8v2h4v-2h-4z"></path></svg> {{LANG balance_}} ({{CURRENCY}}{{ME balance}})
							</a>
						</span>
						<span class="pointer pull-right">
							<a href="javascript:void(0)" onclick="$('#transfer_earnings').modal();">
								<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"></path><path fill="currentColor" d="M3.897 17.86l3.91-3.91 2.829 2.828 4.571-4.57L17 14V9h-5l1.793 1.793-3.157 3.157-2.828-2.829-4.946 4.946A9.965 9.965 0 0 1 2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10a9.987 9.987 0 0 1-8.103-4.14z"></path></svg> {{LANG transfer}}
							</a>
						</span>
					</div>
					<div class="">
						<table class="table" id="pt-user-ads-table"> 
							<thead>
								<th>{{LANG id}}</th>
								<th>{{LANG payer_name}}</th>
								<th>{{LANG video}}</th>
								<th>{{LANG amount}}</th>
								<th>{{LANG site_com}}</th>
								<th>{{LANG net_earn}}</th>
								<th>{{LANG time}}</th>
							</thead>
							<tbody>{{ADS_LIST}}</tbody>
						</table>
					</div>
				</div>
			<?php } ?>
		</div>
	</div>
</div>
<br>

<!-- Modal -->
<div class="modal fade matdialog" id="transfer_earnings" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="transfer_earningsLabel"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-dollar-sign"><line x1="12" y1="1" x2="12" y2="23"></line><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"></path></svg>  {{LANG transfer_earnings}}</h5>
      </div>
      <div class="modal-body">
      	<?php if ($pt->user->balance == 0) { ?>
      		<div class="alert alert-info"> 
				<p><i class="fa fa-info-circle"></i> <?php echo str_replace('{{balance}}', $pt->currency.''.$pt->user->balance, $lang_array['cant_transfer']) ; ?></p>
			</div>
      	<?php } ?>
		<p>- {{LANG transfer_money}}</p>
		<p>- {{LANG withdrawal_earnings}}</p>
        <input id="transfer_earnings_input" class="form-control" type="number" placeholder="{{LANG amount}}">
      </div>
      <div class="modal-footer">
        <button type="button" class="matbtn btn btn-default" data-dismiss="modal">{{LANG close}}</button>
        <button type="button" class="matbtn btn btn-primary" id="transfer_btn" onclick="transferBalance()" <?php if ($pt->user->balance == 0) { echo 'disabled'; } ?> >{{LANG transfer}}</button>
      </div>
    </div>
  </div>
</div>
<script>
	function transferBalance() {
		$('#transfer_btn').attr('disabled', 'true');
		transfer_amount = $('#transfer_earnings_input').val();
		$.post('{{LINK aj/ads/transfer_balance}}', {amount:transfer_amount}, function(data, textStatus, xhr) {
			if (data.status == 200) {
				Snackbar.show({text: '<i class="fa fa-check"></i> ' + data.message});
				setTimeout(function () {
					location.reload();
				},2000);
			}
			else{
				Snackbar.show({text: '<i class="fa fa-times"></i> ' + data.message});
				$('#transfer_btn').removeAttr('disabled');
			}
		});
	}
	$(document).ready( function () {
	    $('#pt-user-ads-table').DataTable( {
        "ordering": false
    } );
		$('#pt-user-ads-table').on( 'page.dt', function () {
		    PT_Delay(function(){
		    },50)
		});
	});

	
	

	function PT_DeleteAd(id){
		if (!id) {
			return false;
		}
		swal({
		  title: '{{LANG confirmation}}',
		  text: "{{LANG confirm_delete_ad}}",
		  type: 'warning',
		  showCloseButton: true,
		  showCancelButton: false,
		  focusConfirm: false,
		  confirmButtonText:"{{LANG delete}}",
		  buttonsStyling:false,
		  confirmButtonClass:'btn btn-success margin-right',
		  allowOutsideClick:true,
		}).then(function (){
			$.post('{{LINK aj/ads/delete}}', {id:id}, function(data, textStatus, xhr) {/* pass */});
			$("tr[data-ads-list='"+id+"']").slideUp(function(){
				$(this).remove();
				swal({
					title:'{{LANG deleted}}',
				    type:'success',
				    buttonsStyling:false,
				    confirmButtonClass:'btn btn-success',
				});
			});
		});
	}

	function PT_ToggleAdsStatus(id){
		if (!id) {
			return false;
		}
		$.post('{{LINK aj/ads/toggle-stat}}', {id:id}, function(data, textStatus, xhr) {/* pass */});
	}	

	$("select#type").change(function(){
        var type = $('#type').val();
        window.location.href = site_url+"/transactions?type="+type;
    });

   $(function () {
    Highcharts.setOptions({
      colors: ['#6abd46', '#ce3d3d', '#f2b92b', '#6abd46']
    });
    $('#chart-container').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: '<?php echo($pt->chart_title); ?> (Based on UTC timezone)'
        },
        xAxis: {
            <?php if ($pt->cat_type == 'today') { ?>
                categories: [
                    '00 AM',
                    '1 AM',
                    '2 AM',
                    '3 AM',
                    '4 AM',
                    '5 AM',
                    '6 AM',
                    '7 AM',
                    '8 AM',
                    '9 AM',
                    '10 AM',
                    '11 AM',
                    '12 PM',
                    '1 PM',
                    '2 PM',
                    '3 PM',
                    '4 PM',
                    '5 PM',
                    '6 PM',
                    '7 PM',
                    '8 PM',
                    '9 PM',
                    '10 PM',
                    '11 PM'
                ]
            <?php }elseif ($pt->cat_type == 'this_week') { ?>
                categories: [
                    'Saturday',
                    'Sunday',
                    'Monday',
                    'Tuesday',
                    'Wednesday',
                    'Thursday',
                    'Friday'
                ]
            <?php }elseif ($pt->cat_type == 'this_month') { ?>
                <?php if ($pt->month_days == 31) { ?>
                    categories: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]
                <?php }elseif ($pt->month_days == 30) { ?>
                    categories: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
                <?php }elseif ($pt->month_days == 29) { ?>
                    categories: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29]
                <?php }elseif ($pt->month_days == 28) {  ?>
                    categories: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]
                <?php } ?>
            <?php }elseif ($pt->cat_type == 'this_year') { ?>
                categories: [
                    'Jan',
                    'Feb',
                    'Mar',
                    'Apr',
                    'May',
                    'Jun',
                    'Jul',
                    'Aug',
                    'Sep',
                    'Oct',
                    'Nov',
                    'Dec'
                ]
            <?php } ?>,
            crosshair: true
        },
        yAxis: {
            min: 0,
            title: {
                text: '<?php echo $pt->chart_text;?>'
            }
        },
        tooltip: {
            headerFormat: '<span style="font-size:10px;color:#fff;">{point.key}</span><table>',
            pointFormat: '<tr><td style="color:#fff;padding:0">{series.name}: </td>' +
                '<td style="padding:0;color:#fff;"><b>{{CURRENCY}}{point.y}</b></td></tr>',
            footerFormat: '</table>',
            shared: true,
            useHTML: true,
            backgroundColor: '#444'
        },
        plotOptions: {
            column: {
                pointPadding: 0.2,
                borderWidth: 0
            }
        },
        series: [{
            name: '{{LANG videos_earnings}}',
            data: [<?php echo $pt->array;?>]

	        }, {
            name: '{{LANG ads_earnings}}',
            data: [<?php echo $pt->ads_array;?>]

	        }, {
            name: '{{LANG subscribe_earnings}}',
            data: [<?php echo $pt->subscribe_array;?>]

	        }]
    });
});

</script>

<form class="replenish-wallet-form hidden text-center yp_ads_add">
	<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#3F51B5"><path d="M8.32,21.97C8.21,21.92 8.08,21.76 8.06,21.65C8.03,21.5 8,21.76 8.66,17.56C9.26,13.76 9.25,13.82 9.33,13.71C9.46,13.54 9.44,13.54 10.94,13.53C12.26,13.5 12.54,13.5 13.13,13.41C16.38,12.96 18.39,11.05 19.09,7.75C19.13,7.53 19.17,7.34 19.18,7.34C19.18,7.33 19.25,7.38 19.33,7.44C20.36,8.22 20.71,9.66 20.32,11.58C19.86,13.87 18.64,15.39 16.74,16.04C15.93,16.32 15.25,16.43 14.05,16.46C13.25,16.5 13.23,16.5 13,16.65C12.83,16.82 12.84,16.79 12.45,19.2C12.18,20.9 12.08,21.45 12.04,21.55C11.97,21.71 11.83,21.85 11.67,21.93L11.56,22H10C8.71,22 8.38,22 8.32,21.97V21.97M3.82,19.74C3.63,19.64 3.5,19.47 3.5,19.27C3.5,19 6.11,2.68 6.18,2.5C6.27,2.32 6.5,2.13 6.68,2.06L6.83,2H10.36C14.27,2 14.12,2 15,2.2C17.62,2.75 18.82,4.5 18.37,7.13C17.87,10.06 16.39,11.8 13.87,12.43C13,12.64 12.39,12.7 10.73,12.7C9.42,12.7 9.32,12.71 9.06,12.85C8.8,13 8.59,13.27 8.5,13.6C8.46,13.67 8.23,15.07 7.97,16.7C7.71,18.33 7.5,19.69 7.5,19.72L7.47,19.78H5.69C4.11,19.78 3.89,19.78 3.82,19.74V19.74Z"></path></svg>
	<div class="w100">
		<label>{{LANG replenish_my_balance}}</label>
	</div>
	<div class="form-group w100 add-amount">
		<h5>
			<span>{{CURRENCY}}</span>
			<b><input type="text" placeholder="0.00"></b>
		</h5>
	</div>
</form>