<?php echo $header; ?><?php echo $column_left; ?>
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <h1><?php echo $heading_title; ?></h1>
      <ul class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
        <?php } ?>
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-bar-chart"></i> <?php echo $text_list; ?></h3>
      </div>
      <div class="panel-body">
        <div class="well">
          <div class="row">
            <div class="col-sm-6">
              <div class="form-group">
                <label class="control-label" for="input-date-start"><?php echo $entry_date_start; ?></label>
                <div class="input-group date">
                  <input type="text" name="filter_date_start" value="<?php echo $filter_date_start; ?>" placeholder="<?php echo $entry_date_start; ?>" data-date-format="YYYY-MM-DD" id="input-date-start" class="form-control" />
                  <span class="input-group-btn">
                  <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
                  </span></div>
              </div>
              <div class="form-group">
                <label class="control-label" for="input-date-end"><?php echo $entry_date_end; ?></label>
                <div class="input-group date">
                  <input type="text" name="filter_date_end" value="<?php echo $filter_date_end; ?>" placeholder="<?php echo $entry_date_end; ?>" data-date-format="YYYY-MM-DD" id="input-date-end" class="form-control" />
                  <span class="input-group-btn">
                  <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
                  </span></div>
              </div>
            </div>
            <div class="col-sm-6">
              <div class="form-group">
                <label class="control-label" for="input-status">Выбрать месяц</label>
                <select name="mesyac" id="input-status" class="form-control">
				 <option value="100"></option>
		<? // 
		
	$mesyx = array(
	0 => "За Год",
    1 => "Январь",
    2 => "Февраль",
	3 => "Март",
    4 => "Апрель",
	5 => "Май",
    6 => "Июнь",
	7 => "Июль",
    8 => "Август",
	9 => "Сентябрь",
    10 => "Октябрь",
	11 => "Ноябрь",
    12 => "Декабрь",
);
			foreach ($mesyx as $key => $value) {	
	if ($key == $mesyac) {?>
                  <option value="<?php echo $key; ?>" selected="selected"><?php echo $value; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $key; ?>"><?php echo $value; ?></option>
                  <?php } 
			}
		?>		         
                </select>


              </div>

                <div class="form-group">
                    <label class="control-label" for="product-status">Категории</label>
                    <select name="period" id="product-status" class="form-control">
		 <option></option>
		<?
		$cotyx = array(
	0 => "Все",
    1 => "Коттедж",
    2 => "Люкс",
	3 => "Стандарт",
    4 => "Общий",
	);
		foreach ($cotyx as $key => $value) {	
	if ($key == $period) {?>
                  <option value="<?php echo $key; ?>" selected="selected"><?php echo $value; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $key; ?>"><?php echo $value; ?></option>
                  <?php } 
			}
		?>	      
                    </select>
                </div>

              <button type="button" id="button-filter" class="btn btn-primary pull-right"><i class="fa fa-filter"></i> <?php echo $button_filter; ?></button>
            </div>
          </div>
        </div>
	<?
	
	// $filter_date_end = date("Y-m-d");
	// $filter_date_start = '2017-08-02';
	if($_GET['filter_date_start']) { $filter_date_start = $_GET['filter_date_start']; }
	if($_GET['filter_date_end']) { $filter_date_end = $_GET['filter_date_end'];	}
	
	$datetime1 = date_create($filter_date_start);
	$datetime2 = date_create($filter_date_end);
	$interval = date_diff($datetime1, $datetime2);
	$inter = $interval->format('%a');
	$znak = $interval->format('%R');
	if( $znak == '-' ) $inter = "$znak $inter дней";
	// echo $interval->format('%R%a дней');
	//  Array ( [0] => Array ( [order_option_id] => 6402 [order_id] => 1908 [order_product_id] => 51923 [product_option_id] => 430 [product_option_value_id] => 789 [name] => Додаткове ліжко [value] => Додаткове ліжко (1 шт.) [type] => select ) ) 	
	?>	
	
<style>
.resize {
  width: 100%;
  position: relative;
  padding-top: 56.25%;
}
.resize iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1210px;
  height: 640px;
  border: solid green;
}
</style>
<?
// $tops = "period=1"; 
// echo  "period = '$period' <br> mesyac = '$mesyac' <br> tops = '$tops' <br>";  cat

	if($mesyac != 0) { $tops = "period=2&mesyac=$mesyac"; }  else { $tops = "period=1"; }
	if($period != '') { $tops = "$tops&cat=$period"; } // else { $tops = "period=1"; }
	
	if($filter_date_start != '') { 
	 $tops = "$tops&filter_date_start=$filter_date_start&filter_date_end=$filter_date_end";
						}
	
	
?>
  <script type="text/javascript"><!--
$('#button-filter').on('click', function() {
	url = 'index.php?route=report/product_grafics&token=<?php echo $token; ?>';
	
	var filter_date_start = $('input[name=\'filter_date_start\']').val();
	
	if (filter_date_start) {
		url += '&filter_date_start=' + encodeURIComponent(filter_date_start);
	}

	var filter_date_end = $('input[name=\'filter_date_end\']').val();
	
	if (filter_date_end) {
		url += '&filter_date_end=' + encodeURIComponent(filter_date_end);
	}
	
	var mesyac = $('select[name=\'mesyac\']').val();
	
	if (mesyac != 0) {
		url += '&mesyac=' + encodeURIComponent(mesyac);
	}
	var period = $('select[name=\'period\']').val();

	if (period != 0) {
		url += '&period=' + encodeURIComponent(period);
	}

	location = url;
});
//--></script> 
  <script type="text/javascript"><!--
$('.date').datetimepicker({
	pickTime: false
});
//--></script> 
<style>
	@media print {* { display: none; }#print-content { display: block; } 
	
.contentpane .table-bordered > thead > tr > th, .contentpane .table-bordered > tbody > tr > th, .contentpane .table-bordered > tfoot > tr > th, .contentpane .table-bordered > thead > tr > td, .contentpane .table-bordered > tbody > tr > td, .contentpane .table-bordered > tfoot > tr > td {
    border: 1px solid #ddd;
}
	}
	</style>
	 <script src="http://222.pmc-s.pp.ua/jquery-1.4.4.min_brech.js" type="text/javascript"></script>
	<script src="http://222.pmc-s.pp.ua/jquery.printPage_brech.js" type="text/javascript"></script>
<script>  
  $(document).ready(function() {
    $(".btnPrint").printPage();
  });
  </script>
<button type="button"  class="btn">
<a class="btnPrint" title="Распечатать проект" href="http://222.pmc-s.pp.ua/grafics_brech.php?<? echo $tops ?>">Распечатать</a>
</button>
         
<div  id="print-content" class="resize"><iframe src="http://222.pmc-s.pp.ua/grafics_brech.php?<? echo $tops ?>" marginheight="0" marginwidth="0"></iframe></div>
         
	<br>	 
		<button type="button"  class="btn">
<a class="btnPrint" title="Распечатать проект" href="http://222.pmc-s.pp.ua/graficsys_brech.php?<? echo $tops ?>">Распечатать</a>
</button>
         
<div  id="print-content" class="resize"><iframe src="http://222.pmc-s.pp.ua/graficsys_brech.php?<? echo $tops ?>" marginheight="0" marginwidth="0"></iframe></div> 
		 
        </div>
		
		
      </div>
    </div>
  </div>  

</div>
<?php echo $footer; ?>