<?php

include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/ui.inc");

include_once("kvcodes.inc");

$sql_cust_count = "SELECT COUNT(*) FROM `".TB_PREF."debtors_master`" ;

$sql_cust_count_result = db_query($sql_cust_count, "could not get sales type");

$cust_coubt = db_fetch_row($sql_cust_count_result);

$sql_supp_count = "SELECT COUNT(*) FROM `".TB_PREF."suppliers`" ;

$sql_supp_count_result = db_query($sql_supp_count, "could not get sales type");

$sup_count= db_fetch_row($sql_supp_count_result);


$class_balances = class_balances();
if(kv_get_option('color_scheme') == 'dark' ){
		$color_scheme = '#ffffff'; 
	}else{
		$color_scheme= '#000000';
	}	


$active_graph = kv_get_option('active_graph');
if($active_graph != false){
	//$opt =  array_values(unserialize(base64_decode($active_graph)));
}
?>
<style>
.label { display: block;padding: 0;font-size: 100%;font-weight: bold;line-height: 1;color: #000;text-align: left;}

.inbox-widget a {
    display: block;
    overflow: hidden;
}
.inbox-widget .inbox-item {
    padding: 10px 0;
    position: relative;
}
.inbox-widget .inbox-item .inbox-item-img {
    float: left;
    width: 40px;
    display: block;
    margin-right: 15px;
}
.inbox-widget .inbox-item img {
    width: 40px;
}
.inbox-widget .inbox-item .inbox-item-author {
    color: #333;
    font-weight: 600;
    display: block;
    margin: 0;
}
.inbox-widget .inbox-item .inbox-item-text {
    color: #a0a0a0;
    display: block;
    margin: 0;
    font-size: 11px;
}
.inbox-widget .inbox-item .inbox-item-date {
    position: absolute;
    top: 2px;
    right: 7px;
    color: #a9a9a9;
    font-size: 11px;
	line-height: 22px;
	margin-bottom: 0 !important;
}

.inbox-widget .inbox-item .inbox-item-total {
    right: 65px;
    margin-top: 23px;
    font-weight: 500;
    font-size: 11px;
    line-height: 22px;
    position: absolute;
    top: 2px;
    color: #a9a9a9;
}
.inbox-widget .inbox-item .inbox-item-amount{
    position: absolute;
    right: 5px;
    margin-top: -20px;
    font-weight: 500;
    /*color: #03a9f4;*/
}
</style>
<!-- Morris -->  
<link rel="stylesheet" href='<?php echo $path_to_root."/themes/".user_theme()."/css/morris.css";?>'>
<script src="<?php echo $path_to_root."/themes/".user_theme()."/js/raphael-min.js";?>"></script>
<script src="<?php echo $path_to_root."/themes/".user_theme()."/js/morris.min.js"; ?>" type="text/javascript"></script>
<div class="container-fluid">
	<div class="row">
		<div class="col-lg-3 col-md-6 col-sm-6">
			<div class="card card-stats">
				<div class="card-header" data-background-color="orange">
					<i class="icon-user-3"></i>
				</div>
				<div class="card-content">
					<h3 class="title"><?php echo $cust_coubt[0]; ?></h3>
				</div>
				<div class="card-footer">
					<div class="stats"><?php echo _("Customers"); ?></div>
				</div>
			</div>
		</div>
		<div class="col-lg-3 col-md-6 col-sm-6">
			<div class="card card-stats">
				<div class="card-header" data-background-color="green">
					<i class="icon-dollar-2"></i>
				</div>
				<div class="card-content">									
					<h3 class="title"><?php echo kv_get_current_balance(); ?></h3>
				</div>
				<div class="card-footer">
					<div class="stats"><?php echo _("Current Balance"); ?></div>
				</div>
			</div>
		</div> 
		<div class="col-lg-3 col-md-6 col-sm-6">
			<div class="card card-stats">
				<div class="card-header" data-background-color="red">
					<i class="icon-user-2"></i>
				</div>
				<div class="card-content">
					<p class="category"></p>
						<h3 class="title"><?php echo $sup_count[0]; ?></h3>
				</div>
				<div class="card-footer">
					<div class="stats"><?php echo _("Suppliers"); ?></div>
				</div>
			</div>
		</div>

		<div class="col-lg-3 col-md-6 col-sm-6">
			<div class="card card-stats">
				<div class="card-header" data-background-color="blue">
					<i class="icon-basket"></i>
				</div>
				<div class="card-content">
					<p class="category"></p>
					<h3 class="title"><?php 

					$sql_count_items = "SELECT COUNT(*) FROM `".TB_PREF."item_codes`"; 
					$sql_items_count_result = db_query($sql_count_items, "could not get sales type");

					$items_count= db_fetch_row($sql_items_count_result);
					echo $items_count[0];?> </h3>
				</div>
				<div class="card-footer"><div class="stats"><?php echo _("Items and Inventory"); ?> </div></div>
			</div>
		</div>
	</div>
	<?php   
		//Class Balances
		echo '<div class="col-sm-6" id="item-10"><div class="card panel-body pheight400"> <div class="card-header" data-background-color="orange"><h4 class="title">'._('Class Balances').'</h4></div><div class="card-content table-responsive">  <div class="col-md-12">  <div class="col-md-6">  </div> <div class="col-md-6" > <select id="ClassPeriods" class="form-control"> <option value="Till Now">'._('Till Now').'</option><option value="Last Week">'._('Last Week').'</option><option value="Last Month">'._('Last Month').'</option> <option value="This Month">'._('This Month').'</option> <option value="Last Quarter Year">'._('Last Quarter Year').'</option></select></div> </div></div> <div id="Class_Balance_chart" style="height: 250px;"></div>  </div></div>' ;

		// Sales 
		echo '<div class="col-sm-6" id="item-9"><div class="card panel-body pheight400"> <div class="card-header" data-background-color="orange"><h4 class="title">'._('Sales').'</h4></div><div class="card-content table-responsive">  <div class="col-md-12">  <div class="col-md-6">  </div> <div class="col-md-6" > <select id="SalesPeriods" class="form-control"> <option value="Till Now">'._('Till Now').'</option><option value="Last Week">'._('Last Week').'</option><option value="Last Month">'._('Last Month').'</option> <option value="This Month">'._('This Month').'</option> <option value="Last Quarter Year">'._('Last Quarter Year').'</option></select></div> </div></div><div id="Area_chart" style="height: 250px;"></div></div></div>'; 

		//Customers 
		echo '<div class="col-sm-6" id="item-15"> <div class="card panel-body pheight400"> <div class="card-header" data-background-color="orange"><h4 class="title">'._('Customers').'</h4></div><div class="card-content table-responsive">
				<div class="row" ><div class="col-md-4"> </div><div class="col-md-8" > <select id="CustomerPeriods" class="form-control"> <option value="Till Now">'._('Till Now').'</option><option value="Last Week">'._('Last Week').'</option><option value="Last Month">'._('Last Month').'</option> <option value="This Month">'._('This Month').'</option> <option value="Last Quarter Year">'._('Last Quarter Year').'</option></select></div> </div> 
				<div id="donut-customer" style="height: 250px;"></div></div></div></div>'; 
        // Suppliers
        echo '<div class="col-sm-6" id="item-16"><div class="card panel-body pheight400"> <div class="card-header" data-background-color="orange"><h4 class="title">'._('Suppliers').'</h4></div><div class="card-content table-responsive">
							<div class="row"><div class="col-md-4"> </div> <div class="col-md-8"> <select id="SupplierPeriods" class="form-control"> <option value="Till Now">'._('Till Now').'</option><option value="Last Week">'._('Last Week').'</option><option value="Last Month">'._('Last Month').'</option> <option value="This Month">'._('This Month').'</option> <option value="Last Quarter Year">'._('Last Quarter Year').'</option></select></div></div> 
							 <div id="donut-supplier" style="height: 250px;"></div></div> </div></div>';

		//Expenses
			echo  '<div class="col-sm-6" id="item-16"><div class="card panel-body pheight400"> <div class="card-header" data-background-color="orange"><h4 class="title">'._('Expenses').'</h4></div><div class="card-content table-responsive">
                     <div class="row"> <div class="col-md-4"> </div> <div class="col-md-8"> <select id="ExpensesPeriods" class="form-control"> <option value="Till Now">'._('Till Now').'</option><option value="Last Week">'._('Last Week').'</option><option value="Last Month">'._('Last Month').'</option> <option value="This Month">'._('This Month').'</option> <option value="Last Quarter Year">'._('Last Quarter Year').'</option></select></div></div><div id="expenses_chart" style="height: 250px;"></div></div></div></div>';

        //Taxes
        echo '<div class="col-sm-6" id="item-16"><div class="card panel-body pheight400"> <div class="card-header" data-background-color="orange"><h4 class="title">'._('Taxes').'</h4></div><div class="card-content table-responsive">
        	<div class="row"> <div class="col-md-4"> </div> <div class="col-md-8"> <select id="TaxPeriods" class="form-control"> <option value="Till Now">'._('Till Now').'</option><option value="Last Week">'._('Last Week').'</option><option value="Last Month">'._('Last Month').'</option> <option value="This Month">'._('This Month').'</option> <option value="Last Quarter Year">'._('Last Quarter Year').'</option></select></div></div>
        	<div id="donut-Taxes" style="height:250px;" ></div>
							<!-- <div class="row"> <div class="col-md-7 "> <p style="font-weight:500;padding-left:15px">Net Payable Tax</p></div> <div class="col-md-5 ">  <p id="GrandTaxTotal">0.00</p> </div> </div>-->  </div> </div></div>'; 
		// Payments
		 $Sales_payment_5 = Top_five_invoices(12); 
		 $payment_lines= '';
		 foreach($Sales_payment_5 as $payment){
			$payment_lines .='<tr><th scope="row">'.$payment['reference'].'</th> <td>'.$payment['name'].'</td> <td><span class="label-info" style="padding:0 5px;">'.$payment['curr_code'].'</span></td> <td>'.price_format($payment['TotalAmount']).'</td> </tr>'; 
		 }
		echo'<div class="col-sm-6" id="item-16"><div class="card panel-body pheight400"> <div class="card-header" data-background-color="orange"><h4 class="title">'._('Payments').'</h4></div><div class="card-content table-responsive"> <table class="table "><thead> <tr> <th>#</th><th>'._('Name').'</th> <th>'._('Currency').'</th> <th>'._('Total Amount').'</th></tr> </thead><tbody>'.$payment_lines.'</tbody></table></div></div></div> '; 
		$Sales_invoice_5 = Top_five_invoices(); 
		$invoice_lines = ''; 
		// foreach($Sales_invoice_5 as $invoice){
		// 	$invoice_lines .= ' <div class="inbox-widget" > <div class="inbox-item"><div class="inbox-item-img"></div><p class="inbox-item-author">'.$invoice['name'].'</p><p class="inbox-item-text">'._('Payment').' ID #'.$invoice['reference'].'</p><p class="inbox-item-date">'.$invoice['due_date'].'</p><p class="inbox-item-total">'.round($invoice['total'],2).'</p><p class="inbox-item-amount">'.round($invoice['remainder'],2).'</p></div></div>';
		// }
		// echo'<div class="col-sm-6" id="item-16"><div class="card panel-body pheight400"> <div class="card-header" data-background-color="orange"><h4 class="title">'._('Sales Invoices').'</h4></div><div class="card-content table-responsive">'.$invoice_lines.'</div></div></div> </div>';


		foreach($Sales_invoice_5 as $invoice){
			$invoice_lines .= '<tr><th scope="row">'.$invoice['reference'].'</th> <td>'.$invoice['name'].'</td> <td><span class="label-info" style="padding:0 5px;">'.$invoice['curr_code'].'</span></td> <td style="text-align:right;">'.$invoice['TotalAmount'].'</td> </tr>';
		}
		echo'<div class="col-sm-6" id="item-16"><div class="card panel-body pheight400"> <div class="card-header" data-background-color="orange"><h4 class="title">'._('Sales Invoices').'</h4></div><div class="card-content table-responsive"> <table class="table "><thead> <tr> <th>#</th><th>'._('Name').'</th> <th>'._('Currency').'</th> <th>'._('Total Amount').'</th></tr> </thead><tbody>'.$invoice_lines.'</tbody></table></div></div></div>';
		 ?>

					<!-- <div class="row">
						<div class="col-md-4">
							<div class="card">
								<div class="card-header card-chart" data-background-color="green">
									<div class="ct-chart" id="dailySalesChart">
									</div>
								</div>
								<div class="card-content">
									<h4 class="title">Daily Sales</h4>
									<p class="category"><span class="text-success"><i class="fa fa-long-arrow-up"></i> 55%  </span> increase in today sales.</p>
								</div>
								<div class="card-footer">
									<div class="stats">
										<i class="material-icons">access_time</i> updated 4 minutes ago
									</div>
								</div>
							</div>
						</div>

						<div class="col-md-4">
							<div class="card">
								<div class="card-header card-chart" data-background-color="orange">
									<div class="ct-chart" id="emailsSubscriptionChart">
									</div>
								</div>
								<div class="card-content">
									<h4 class="title">Email Subscriptions</h4>
									<p class="category">Last Campaign Performance</p>
								</div>
								<div class="card-footer">
									<div class="stats">
										<i class="material-icons">access_time</i> campaign sent 2 days ago
									</div>
								</div>

							</div>
						</div>

						<div class="col-md-4">
							<div class="card">
								<div class="card-header card-chart" data-background-color="red">
									<div class="ct-chart" id="completedTasksChart">
									</div>
								</div>
								<div class="card-content">
									<h4 class="title">Completed Tasks</h4>
									<p class="category">Last Campaign Performance</p>
								</div>
								<div class="card-footer">
									<div class="stats">
										<i class="material-icons">access_time</i> campaign sent 2 days ago
									</div>
								</div>
							</div>
						</div>
					</div> -->
		


					<div class="row">
						<div class="col-lg-7 col-md-12">
							<div class="card">
	                            <div class="card-header" data-background-color="orange">
	                                <h4 class="title"><?php echo _("Overdue Sales Invoices"); ?></h4>
	                                <p class="category">All Customer Overdue Transactions</p>
	                            </div>
	                            <div class="card-content table-responsive">
	                            	<?php  kv_customer_trans(); 	?>
	                            </div>
	                        </div>
						</div>

						<div class="col-lg-5 col-md-12">
							<div class="card">
	                            <div class="card-header" data-background-color="orange">
	                                <h4 class="title"><?php echo _("Bank Account Balances"); ?></h4>
	                                <p class="category">All Associated Account Balances</p>
	                            </div>
	                            <div class="card-content table-responsive">
	                            	<?php  kv_bank_balance(); 	?>
	                            </div>
	                        </div>
						</div>
					</div>

					<div class="row">
						<div class="col-lg-6 col-md-12">
							<div class="card">
	                            <div class="card-header" data-background-color="orange">
	                                <h4 class="title"><?php echo _("Overdue Recurrent Sales Invoices"); ?></h4>
	                            </div>
	                            <div class="card-content table-responsive">
	                            	<?php  kv_customer_recurrent_invoices(); 	?>
	                            </div>
	                        </div>
						</div>

						<div class="col-lg-6 col-md-12">
							<div class="card">
	                            <div class="card-header" data-background-color="orange">
	                                <h4 class="title"><?php echo _("Average Daily Sales"); ?></h4>
	                            </div>
	                            <div class="card-content table-responsive">
	                            	<?php  kv_weekly_sales(); 	?>
	                            </div>
	                        </div>
						</div>
					</div>

					<div class="row">
						
						<div class="col-lg-6 col-md-12">
							<div class="card">
	                            <div class="card-header" data-background-color="orange">
	                                <h4 class="title">Overdue Purchase Invoices</h4>
	                            </div>
	                            <div class="card-content table-responsive">
	                            	<?php  kv_supplier_trans(); 	?>
	                            </div>
	                        </div>
						</div>
						<div class="col-lg-6 col-md-12">
							<div class="card">
	                            <div class="card-header" data-background-color="orange">
	                                <h4 class="title">Top 10 Selling Items and Inventory</h4>
	                            </div>
	                            <div class="card-content table-responsive">
	                            	<?php  kv_stock_top(); 	?>
	                            </div>
	                        </div>
						</div>
					</div>

					<div class="row">
						<div class="col-lg-6 col-md-12">
							<div class="card">
	                            <div class="card-header" data-background-color="orange">
	                                <h4 class="title"><?php echo _("Class Balances"); ?></h4>
	                            </div>
	                            <div class="card-content table-responsive">
	                            	<?php  kv_gl_top(); 	?>
	                            </div>
	                        </div>
						</div>
						

						<div class="col-lg-6 col-md-12">
							<!--<div class="card">
	                            <div class="card-header" data-background-color="orange">
	                                <h4 class="title">Top 10 Selling Items and Inventory</h4>
	                            </div>
	                            <div class="card-content table-responsive">
	                            	<?php  //kv_stock_top(); 	?>
	                            </div>
	                        </div> -->
						</div>
					</div>


				</div>
<?php 

// $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

$protocol = $protocol = $_SERVER['REQUEST_SCHEME'] . '://'; //stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://';
$actual_link = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

$actual_link =  strtok($actual_link, '?');
$actual_link = str_replace("index.php", "", $actual_link);

 ?>

<script>
$(function(){ 
 $(".spanclosechart").on("click", function(){
	 var summa = $(this).parent().parent().parent().parent();
		 var dataclass = summa. data('class'); 		 
		 $.ajax({
				type: "POST",
				url: "<?php echo $actual_link; ?>themes/Vanigam/includes/ajax.php?Remove_Chart="+dataclass,
				data: 0,
				success: function(data){
				  if(data == 'true'){
					  summa.hide();
				  }				  
				}
		  });
	  }); 
}); 

if($("#donut-Taxes").length){ //  #################  
  var Tax_Donut_Chart = Morris.Donut({
    element: 'donut-Taxes',
    behaveLikeLine: true,
    parseTime : false,
    data: [{"value":"","label":"", labelColor: '<?php echo $color_scheme; ?>'}], 
    colors: [ '#f26c4f', '#00a651', '#00bff3', '#0072bc','#ff6264', '#455064',  '#707f9b', '#b92527',  '#242d3c', '#d13c3e', '#d13c3e',  '#ff6264', '#ffaaab', '#b92527'],
    redraw: true,
  });
  $("#TaxPeriods").on("change", function(){
       var option = $(this).val(); 
       $.ajax({
          type: "POST",
          url: "<?php echo $actual_link; ?>themes/Vanigam/includes/ajax.php?Tax_chart="+option,
          data: 0,
          dataType: 'json',
          success: function(taxdata){      
        		//var grandtotal = data.grandtotal;	 // delete data.grandtotal;	  //delete data[4];
        		console.log(taxdata);
            Tax_Donut_Chart.setData(taxdata);
        		// var arr = $.parseJSON(data);  //alert(data.grandtotal);	  //$("#GrandTaxTotal").html(grandtotal);
            /* setCookie('numbers',data,3); $('.flash').show(); $('.flash').html("Template Updated")*/
          }
    });
  }); 
 }

 if($("#expenses_chart").length){ //   ######### 
	 var Expenses_Bar_Chart = Morris.Bar({
	  element: 'expenses_chart',
	  behaveLikeLine: true,
	  parseTime : false,
	  data: [{ "y": "Nothing" , "a" : "0", "labelColor": '<?php echo $color_scheme; ?>'} ],
	  xkey: 'y',
	  ykeys: ['a'],
	  labels: ['Expenses' ],
	  barColors: ['#f26c4f', '#00a651', '#00bff3', '#0072bc', '#707f9b', '#455064', '#242d3c', '#b92527', '#d13c3e', '#ff6264', '#ffaaab'],
	  redraw: true
	});
	 $("#ExpensesPeriods").on("change", function(){
		 var option = $(this).val(); 
		 $.ajax({
				type: "POST",
				url: "<?php echo $actual_link; ?>themes/Vanigam/includes/ajax.php?Expense_chart="+option,
				data: 0,
				dataType: 'json',
				success: function(data){
				  console.log(data);
				  Expenses_Bar_Chart.setData(data);
				   /* setCookie('numbers',data,3); $('.flash').show(); $('.flash').html("Template Updated")*/
				}
		  });
	  }); 
  }

    //  ##########################################
   if($("#Class_Balance_chart").length){
      var Line_Chart = Morris.Line({
        element: 'Class_Balance_chart',
        behaveLikeLine: true,
        parseTime : false,
        data: [ <?php foreach($class_balances as $balance) { echo " { class: '".$balance['class_name']."', value: ".abs($balance['total'])." }," ; } ?> ],    
        xkey: 'class',
        ykeys: ['value'],
        labels: ['Value'],
        lineColors: ['#f26c4f', '#00a651', '#00bff3', '#0072bc', '#707f9b', '#455064', '#242d3c', '#b92527', '#d13c3e', '#ff6264', '#ffaaab'],
        redraw: true,
        pointFillColors: ['#455064']
      });

      $("#ClassPeriods").on("change", function(){
         var type = $(this).val(); 
         $.ajax({
            type: "POST",
            url: "<?php echo $actual_link; ?>themes/Vanigam/includes/ajax.php?Line_chart="+type,
            data: 0,
            dataType: 'json',
            success: function(data){    console.log(data);
              Line_Chart.setData(data);
              /* setCookie('numbers',data,3); $('.flash').show(); $('.flash').html("Template Updated")*/
            }
        });
      }); 
   }	

if($("#Area_chart").length){//  ################   
    var Area_chart = Morris.Area({
      element: 'Area_chart',  
      behaveLikeLine: true,
      parseTime : false, 
      data: [ ],
      xkey: 'y',
      ykeys: ['a', 'b'],
      labels: ['Sales', 'Cost'],
      pointFillColors: ['#707f9b'],
      pointStrokeColors: ['#ffaaab'],
      lineColors: ['#f26c4f', '#00a651', '#00bff3'],
      redraw: true      
    });

    $("#SalesPeriods").on("change", function(){
     var selected_user_ID = $(this).val(); 
     $.ajax({
            type: "POST",
            url: "<?php echo $actual_link; ?>themes/Vanigam/includes/ajax.php?Area_chart="+selected_user_ID,
            data: 0,
            dataType: 'json',
            success: function(data){
              console.log(data);
              Area_chart.setData(data);
            }
          });
  }); 
}

if($("#donut-customer").length){//  #################  
    var Customer_Donut_Chart = Morris.Donut({
      element: 'donut-customer',
      behaveLikeLine: true,
      parseTime : false,
      data: [{"value":"","label":"", "labelColor": '<?php echo $color_scheme; ?>'}],
      colors: ['#f26c4f', '#00a651', '#00bff3', '#0072bc', '#707f9b', '#455064', '#242d3c', '#b92527', '#d13c3e', '#ff6264', '#ffaaab'],
      redraw: true,
    });
    $("#CustomerPeriods").on("change", function(){
         var option = $(this).val(); 
         $.ajax({
            type: "POST",
            url: "<?php echo $actual_link; ?>themes/Vanigam/includes/ajax.php?Customer_chart="+option,
            data: 0,
            dataType: 'json',
            success: function(data){
             console.log(data);
              Customer_Donut_Chart.setData(data);
              /* setCookie('numbers',data,3); $('.flash').show(); $('.flash').html("Template Updated")*/
            }
        });
    });
}

if($("#donut-supplier").length){ //  #################  
var Supplier_Donut_Chart = Morris.Donut({
  element: 'donut-supplier',
  behaveLikeLine: true,
  parseTime : false,
  data: [{"value":"","label":"", "labelColor": '<?php echo $color_scheme; ?>'}], 
  colors: [  '#ff6264', '#455064', '#d13c3e', '#d13c3e',  '#ff6264', '#ffaaab', '#f26c4f', '#00a651', '#00bff3', '#0072bc', '#b92527', '#707f9b', '#b92527',  '#242d3c'],
  redraw: true,
});
$("#SupplierPeriods").on("change", function(){
     var option = $(this).val(); 
     $.ajax({
        type: "POST",
        url: "<?php echo $actual_link; ?>themes/Vanigam/includes/ajax.php?Supplier_chart="+option,
        data: 0,
        dataType: 'json',        
        success: function(data){
          console.log(data);
          Supplier_Donut_Chart.setData(data);
          /* setCookie('numbers',data,3); $('.flash').show(); $('.flash').html("Template Updated")*/
        }
      });
  }); 
 }

  $(document).ready(function(e){
      $("#SalesPeriods").trigger("change");
      $("#CustomerPeriods").trigger("change");
      $("#SupplierPeriods").trigger("change");
      $("#ExpensesPeriods").trigger("change");
      $("#TaxPeriods").trigger("change");
  }); 
 </script>