

<?php $__env->startSection('title'); ?>
	@parent
	Статистика выплат з/п
<?php $__env->stopSection(); ?>

<?php $__env->startSection('breadcrumbs'); ?>
	<?php /* Breadcrumbs::render('budget.salary.stat', $workProject) */ ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="row">
  <div class="col-md-12 col-lg-12 col-sm-12">
		<div class="panel panel-default">
		<?php echo $__env->make('budget/menu', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
			<div class="panel-body">
				<?php echo $__env->make('budget/salary/btns', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
				<div class="salary-user-list bottom-menu-small">
					<a class="btn link-white btn-xs btn-default <?php if( Request::is('budget/salary/stat/operations') ): ?>active <?php else: ?> bg-color-blueLight <?php endif; ?>" href="/budget/salary/stat/operations">< Все  сотрудники ></a>
					<?php foreach($salaryUsers as $salaryUser): ?>
					  <?php
						  $activeClasses = 'bg-color-blueLight';
						  if( Request::is('budget/salary/stat/operations/'.$salaryUser->id) ){
								$activeClasses = 'btn-default active';
							}
						?>
					  <a class="btn link-white btn-xs <?php echo $activeClasses; ?>" href="/budget/salary/stat/operations/<?php echo $salaryUser->id; ?>"> <?php echo $salaryUser->last_name; ?> <?php echo $salaryUser->first_name; ?> </a>
					<?php endforeach; ?>
				</div>
				<div class="clearfix"></div>
				<div class="table-responsive">
					<table class="table table-condensed table-hover">
						<thead>
							<th>Дата начисления</th>
							<th>Операция в бюджете</th>
							<th>Проект</th>
							<th>Сотрудник</th>
							<th>З/п за: </th>
							<th>Сумма</th>
							<th>Комментарий</th>
						</thead>
						<tbody>
							<?php foreach($salaryOperations as $salaryOperation): ?>
							<tr>
								<td><?php echo $salaryOperation->getDateTime('created_at'); ?></td>
								<td>№<?php echo $salaryOperation->budget_operation_id; ?>, <?php echo $salaryOperation->getDate('bo_date'); ?>, <span class="operation-amount" data-value="<?php echo $salaryOperation->bo_amount/100; ?>"> <?php echo $salaryOperation->bo_amount/100; ?></span> <i class="fa fa-rub"></i></td>
								<td><?php echo $salaryOperation->project_name; ?></td>
								<td><?php echo $salaryOperation->last_name; ?> <?php echo $salaryOperation->first_name; ?></td>
								<td><?php echo $salaryOperation->getDate('salary_date'); ?></td>
								<td><span class="salary-amount" data-value="<?php echo $salaryOperation->amount/100; ?>"> <?php echo $salaryOperation->amount/100; ?></span> <i class="fa fa-rub"></i></td>
								<td class="salary-comment"><?php echo $salaryOperation->comment; ?></td>
							</tr>
						  <?php endforeach; ?>
						</tbody>
					</table>
				</div>
				<dl class="dl-horizontal">
					<dt>Итого: </dt>
					<dd><span id="totalOperaionsSum" class="to-humanize"> </span> <i class="fa fa-rub"></i></dd>
				</dl>
			</div>
		</div>
	</div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>
	<script src="<?php echo asset('js/budget_salary.js'); ?>"></script>
	<script src="<?php echo asset('js/kmk-support.js'); ?>"></script>
	<script>
		$(document).ready(function() {
      var monthNames = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'];

			var today = new Date,
			     i = 0;

			for(i; i>=-11; i--){
				var today = new Date,
						select,
						todayMonth;

        todayMonth = today.getMonth();
				today.setMonth(todayMonth+i);

				select += '<option value="'+i+'" class="01_'+(+today.getMonth()+1)+'_'+today.getFullYear()+'">'+monthNames[today.getMonth()]+', '+today.getFullYear()+'</option>';
			}
			$('#monthSelect').html(select);

			$('#monthSelect').on('change', function(){
				var startDate, endDate, startMonthPos, today, currMonth, month, lastDay;

				startMonthPos = $(this).val();
				today = new Date;
				currMonth = today.getMonth();

		    today.setMonth(currMonth+ +startMonthPos+1);
				month = today.getMonth();
				if(month == 0){
					month = 12;
				}
				startDate = '01.'+month+'.';
				today.setDate(0);
				startDate += today.getFullYear();

				lastDay = today.getDate();
				endDate = lastDay+'.'+(+today.getMonth()+1)+'.'+today.getFullYear();

				$("#startDate").val(startDate);
				$("#endDate").val(endDate);
				reload();
				return false;
			});

      var selectedMonth = ($("#startDate").val()).split('.').join('_');
      $('body').find('.'+selectedMonth).attr('selected','selected');

			$('a.to-humanize').each(function() {
				$(this).html(humanizeNumber($(this).html()));
			});
		});
	</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.default', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>