<?
$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 dopagination(pageNumber)
{
xmlhttp=GetXmlHttpObject();
 if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }


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

var id_rate=document.getElementById("id_rate").value;
var login=document.getElementById("login").value;
var password=document.getElementById("password").value;
var limit=document.getElementById("limit").value;
var lot_id=document.getElementById("lot_id").value;
var id_reseller=document.getElementById("id_reseller").value;


if(id_reseller=="")
id_reseller = "NULL";

if(login=="")
login = "NULL";


if(password=="")
password = "NULL";


if(id_rate=="")
id_rate = "NULL";


if(lot_id=="")
lot_id = "NULL";


var url = "<?=site_url("client/sipClientListPagination")?>";

var myRandom = parseInt(Math.random()*99999999); // cache buster


xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET", url + "/" + escape(pageNumber) + "/"  + escape(limit) + "/" + escape(id_rate) + "/" + escape(login) + "/" + escape(password) + "/" + escape(lot_id) + "/" + escape(id_reseller) + "/" + myRandom, true);
xmlhttp.send(null);
}




function searchClient()
{

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



var id_rate=document.getElementById("id_rate").value;
var login=document.getElementById("login").value;
var password=document.getElementById("password").value;
var limit=document.getElementById("limit").value;
var lot_id=document.getElementById("lot_id").value;
var startoffset=0;
var id_reseller=document.getElementById("id_reseller").value;


if(id_reseller=="")
id_reseller = "NULL";

if(login=="")
login = "NULL";


if(password=="")
password = "NULL";


if(id_rate=="")
id_rate = "NULL";


if(lot_id=="")
lot_id = "NULL";


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

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


xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET", url + "/" + escape(startoffset) + "/"  + escape(limit) + "/" + escape(id_rate) + "/" + escape(login) + "/" + escape(password) + "/" + escape(lot_id) + "/" + escape(id_reseller) + "/" + myRandom, true);
xmlhttp.send(null);



}




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





</script>



<div id = "loading" style="position:absolute;top:200px;left:530px;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">

      <img src="<?=base_url()?>images/s.gif" width="600" height="1" border="0" alt="" />
      <div id="module_info">
                  <div class="quickmenu">
                      <img src="<?=base_url()?>images/qb_remove.gif" align="baseline" width="9" height="9" border="0" alt="" />
                      <a href="<?=site_url('client/addSIPForm')?>">Add New Client</a>
                  </div>

                  <span>&nbsp;&nbsp;&raquo;</span> <?=TITLE020?>  <span style='color:#BF0000'><?=$titleErrorMessage?></span>   </div>


   <!-- Search Information -->

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


<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="right">Login :</td>
    <td align="left"><input type="text" class = "formInput" name="login" id="login" value="" style="width:65px"/></td>

    <td align="right">Password :</td>
    <td align="left"><input type="text" class = "formInput" name="password" id="password" value="" style="width:65px"/></td>

    <td align="right">Lot :</td>
    <td align="left">
    <select name="lot_id" id="lot_id" class = "selectFrom" style="width:120px;">
    <?=$lotsList?>
    </select>
    </td>
    <!--
    <td align="right">Name :</td>
    <td align="left"><input type="text" class = "formInput" name="lastname" id="lastname" value="" style="width:65px"/></td>
    -->
    <td align="right">Parent :</td>
    <td align="left">
    <select name="id_reseller" id="id_reseller" class = "selectFrom" style="width:100px;">
    <?=$resellerLevel1List?>
    </select>
    </td>


    <td align="right">Tariff :</td>
    <td align="left">
    <select name="id_rate" id="id_rate" class = "selectFrom" style="width:120px;">
    <?=$rateList?>
    </select>
    </td>

    <td align="right">Rec :</td>
    <td align="left">
  <select name="limit" id="limit" class = "selectFrom" style="width:50px;" onchange="searchClient();">
	<option value="<?=LIMIT_PERPAGE?>"><?=LIMIT_PERPAGE?></option>
	<option value="<?=LIMIT_PERPAGE*2?>"><?=LIMIT_PERPAGE*2?></option>
	<option value="<?=LIMIT_PERPAGE*3?>"><?=LIMIT_PERPAGE*3?></option>
	<option value="<?=LIMIT_PERPAGE*4?>"><?=LIMIT_PERPAGE*4?></option>
</select>
    </td>

<td align="left">

	<a href="#" onclick="javascript:searchClient();">
	<img src="<?=base_url()?>images/apply.gif" height="22" border="0" />
	</a>

</td>

  </tr>
</table>



</fieldset>

   <!-- End Search Information -->

    </td>
  </tr>

  <tr>
    <td>

<div id = "pagination">


	<?php
	$start = $startoffset * $limit + 1;
	$end = ($startoffset +1 )* $limit ;

	if($total<$start)
	$start = $total;

	if($total<=$end)
	$end = $total;
	?>


<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tableBorder">
  <tr>
    <td class="mainTableTitle">

      <span>&nbsp;&nbsp;&raquo;</span> All Client List Total : <?=$total?> Showing <?=$start?> to <?=$end?>

    </td>
  </tr>


 <tr>
    <td>

 <!-- Clinets List -->

 <table class="gbTable">

   <tr class="header">
     <td width="2%"><div align="left" style="padding-left:5px;">NR</div></td>
     <td width="8%"><div align="left" style="padding-left:5px;">Login</div></td>
     <td width="8%"><div align="left" style="padding-left:5px;">Password</div></td>
     <td width="12%"><div align="left" style="padding-left:5px;">Name</div></td>
     <td width="8%"><div align="left" style="padding-left:5px;">Parent</div></td>
     <td width="7%"><div align="left" style="padding-left:5px;">Balance</div></td>
     <td width="12%"><div align="left" style="padding-left:5px;">Tariff Name</div></td>
     <td width="9%"><div align="center" style="padding-left:5px;">RegIP</div></td>
     <td width="4%"><div align="left" style="padding-left:5px;">Limit</div></td>
     <td width="12%"><div align="center" style="padding-left:5px;">Last Use</div></td>
 	 <td width="4%"><div align="center" style="padding-left:0px;">Used</div></td>
  	 <td width="4%"><div align="center" style="padding-left:0px;">Accounts</div></td>
 	 <td width="4%"><div align="center" style="padding-left:0px;">Active?</div></td>
 	 <td width="3%"><div align="center" style="padding-left:0px;">Edit</div></td>
 	 <td width="3%"><div align="center" style="padding-left:0px;">Del</div></td>

   </tr>



<?
$i=1;
if(is_array($clientLIst))
{
foreach($clientLIst as $row)
{
$passid =$row->id;


if($row->status == 1)
$checkActive = "checked='checked'";
else
$checkActive = "";


$parent = $this->generallib->getResellerLogin($row->id_reseller,1);
$ipAddress = $this->generallib->getRegisterIPAddress($row->id,SIP_USER);
$fullContactDetails = $this->generallib->getfullContactDetails($row->id,SIP_USER);


?>

      <?

	  		if($i%2==0)
	  		 {

	  		 $str = "
	  		 		 <TR id = \"$passid\" class=\"row2 \"
	  		 		               onmousedown=\"rowPointer(this, 'down', 'row2', 'rowSel', 'rowMark')\"
	  		 		               onmouseover=\"rowPointer(this, 'over', 'row2', 'rowSel', 'rowMark')\"
	  		               onmouseout=\"rowPointer(this, 'out', 'row2', 'rowSel', 'rowMark')\">";


	  		 }
	  		else
	  		 {
	  			$str = "
	  					 <TR id = \"$passid\" class=\"row1 \"
	  					               onmousedown=\"rowPointer(this, 'down', 'row1', 'rowSel', 'rowMark')\"
	  					               onmouseover=\"rowPointer(this, 'over', 'row1', 'rowSel', 'rowMark')\"
	  		               onmouseout=\"rowPointer(this, 'out', 'row1', 'rowSel', 'rowMark')\">";
	  		 }



	  echo $str;

	  ?>

 <td align=center class="tableBorderAll" style="padding-left:0px;"><input name="checkActive" type="checkbox"  id="checkActive" value="1" /></td>
 <td align=left class="tableBorderAll" style="padding-left:5px;"><?=$row->login?></td>
 <td align=left class="tableBorderAll" style="padding-left:5px;"><?=$row->password?></td>
 <td align=left class="tableBorderAll" style="padding-left:5px;"><?=$row->full_name?></td>
 <td align=left class="tableBorderAll" style="padding-left:5px;"><?=$parent?></td>
 <td align=left class="tableBorderAll" style="padding-left:5px;"><b><?=$row->balance?></b></td>
 <td align=left class="tableBorderAll" style="padding-left:5px;"><a href="<?=site_url('rate/rateChartList/'.$row->id_rate)?>" target="_blank" title="Rate Chart" ><?=$this->generallib->getReteName($row->id_rate)?></a></td>
 <td align=center class="tableBorderAll" style="padding-left:0px;"><a href="#"  title="<?=$fullContactDetails?>" ><?=$ipAddress?></a></td>
 <td align=center class="tableBorderAll" style="padding-left:0px;"><?=$row->calllimit?></td>
 <td align=center class="tableBorderAll" style="padding-left:0px;"><?=$row->lastuse?></td>
 <td align=center class="tableBorderAll" style="padding-left:0px;"><?=$row->numuse?></td>

 <td align=center class="tableBorderAll" style="padding-left:0px;">
   <a href="<?=site_url('client/sipEditForm/'.$row->id)?>"  title="Add Payment" >
   <img src="<?=base_url()?>images/add_payment.gif" border="0" height="18">
   </a>
 </td>


 <td align=center class="tableBorderAll" style="padding-left:0px;"><input name="checkActive" type="checkbox"  disabled="disabled" id="checkActive" value="1"  <?=$checkActive?> /></td>

 <td align=center class="tableBorderAll" style="padding-left:0px;">
   <a href="<?=site_url('client/sipEditForm/'.$row->id)?>" title="Edit SIP Client" >
   <img src="<?=base_url()?>images/contact_blue_edit.png" border="0" height="16">
   </a>
 </td>

 <td align=center  style="padding-left:5px;">
  <a href="<?=site_url('client/deleteSipClient/'.$row->id)?>" onclick="return confirm('Do you really want to remove this client, Name:<?=$row->full_name?> ?')" title="Delete" >
  <img src="<?=base_url()?>images/remove.png" border="0" height="16">
  </a>
 </td>

   </tr>

<?
$i++;
}

}

?>


 </table>

<!-- End Clients List -->

    </td>
  </tr>

  <tr>
    <td align="center" style="padding-top:5px;">

    <input type="hidden" name="login" id="login" value="<?=$login?>" />
	<input type="hidden" name="password" id="password" value="<?=$password?>" />
	<input type="hidden" name="lot_id" id="lot_id" value="<?=$lot_id?>" />
	<input type="hidden" name="limit" id="limit" value="<?=$limit?>" />
	<input type="hidden" name="startoffset" id="startoffset" value="<?=$startoffset?>" />
	<input type="hidden" name="id_rate" id="id_rate" value="<?=$id_rate?>" />
	<input type="hidden" name="id_reseller" id="id_reseller" value="<?=$id_reseller?>" />



<?


      $p = new paginationClass;
      $p->Items($total);

      if($startoffset==0)
      $startoffset = 1;

      $p->limit($limit);
      $p->target("paginator.php");
      $p->currentPage($startoffset);
      $p->adjacents(3);
      $p->show();



?>


    </td>
  </tr>

</table>

</div>



    </td>
  </tr>

</table>


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