<?
$this->load->view('cpanel/header');
?>


<script>

var xmlhttp;

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}


function searchLCR()
{

xmlhttp=GetXmlHttpObject();
 if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }

	var prefix=document.getElementById("prefix").value;
	var rateIDs=document.getElementById("rateIDs");
	var selectedList = [];

	if(prefix=="")
	prefix = "NULL";


  for (var i = 0; i < rateIDs.options.length; i++) {
     if(rateIDs.options[i].selected ==true){
          selectedList.push(rateIDs.options[i].value);
      }
  }


 	document.getElementById("loading").style.display = "block";
 	document.getElementById("loading").style.visibility = "visible";

	var url = "<?=site_url("rate/tariffAnalysisProcess")?>";
	var myRandom = parseInt(Math.random()*99999999); // cache buster


xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET", url + "/" + escape(prefix) + "/"  + escape(selectedList) + "/" + myRandom, true);
xmlhttp.send(null);



}


function exportRate()
{


	var prefix=document.getElementById("prefix").value;
	var starttime=document.getElementById("starttime").value;
	var stoptime=document.getElementById("stoptime").value;
	var rate_id=document.getElementById("rate_id").value;
	var rType=document.getElementById("rType").value;
	var limit=document.getElementById("limit").value;
	var startoffset=0;


	if(prefix=="")
	prefix = "NULL";

	if(starttime=="")
	starttime = "NULL";

	if(stoptime=="")
	stoptime = "NULL";

	if(rate_id=="")
	rate_id = "NULL";

	if(rType=="")
	rType = 1;


var url = "<?=site_url("rate/exportRatePlan")?>";
var myRandom = parseInt(Math.random()*99999999); // cache buster

window.location= url + "/" + escape(startoffset) + "/"  + escape(limit) + "/" + escape(prefix) + "/" + escape(starttime) + "/" + escape(stoptime) + "/" + escape(rate_id) + "/" + escape(rType) + "/" + myRandom;


}




function stateChanged()
{
	if (xmlhttp.readyState==4)
	{
		rowID = "pagination";
		document.getElementById("loading").style.visibility = "hidden";
		document.getElementById(rowID).innerHTML=xmlhttp.responseText;
	}
}


$(document).ready(function() {
    $('#selecctall').click(function(event) {  //on click
        if(this.checked) { // check select status
            $('.checkActiveAll').each(function() { //loop through each checkbox
                this.checked = true;  //select all checkboxes with class "checkbox1"
            });
        }else{
            $('.checkActiveAll').each(function() { //loop through each checkbox
                this.checked = false; //deselect all checkboxes with class "checkbox1"
            });
        }
    });

});

function deleteALL(){
        $('#loading').show();
        var query = $('#theForm').serialize();
        var url = "<?=site_url('rate/deleteRatePlanAll')?>"
        $.post(url, query, function (response) {
         //alert (response);
         window.location= response;
        });
    }

</script>

<div id = "loading" style="position:absolute;top:200px;left:500px;width;100px;height:100px; bgcolor:#f2f2f2; border:0px solid #99BBE8;zindex:250;display:none;">
<img src="<?=base_url()?>images/indicator2.gif?>" border="0" />
</div>


<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td id="right">
      <div id="module_info">

                  <div class="quickmenu" style='padding-left:10px;'>
                      <a href="#" onclick="javascript:exportRate();"><i class="fa fa-files-o"></i><b>Export</b></a>
                  </div>

                  <i class="fa fa-camera-retro"></i>Tariff Analysis </div>


   <!-- Search Information -->

<fieldset class="search_box" id="advancedSearch" style="margin-bottom:0px;"><legend>Filter Options</legend>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>

    <td align="right" valign="top">Prefix :</td>
    <td align="left" valign="top"><input type="text" class = "formInput01" name="prefix" id="prefix" value="" style="width:150px;"/></td>



	<td align="right" valign="top">Tariff List :</td>
	<td align="left" valign="top">

	<select class="selectFrom" name="rateIDs" id="rateIDs" multiple="multiple" style="width:330px;height:180px;">
	<?=$rateList?>
	</select>
	</td>

  </tr>

  <tr>
    <td align="center" colspan="5" valign="top" style="padding:15px;">
	<a href="#" onclick="javascript:searchLCR();">
	<img src="<?=base_url()?>images/big_search.jpg" height="40" border="0" />
	</a>
    </td>
  </tr>

</table>


</fieldset>

   <!-- End Search Information -->

    </td>
  </tr>

  <tr>
    <td>

<div id = "pagination">


</div>
    </td>
  </tr>
</table>

<?
$this->load->view('cpanel/footer');
?>
