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

<!-- required plugins -->
<script type="text/javascript" src="<?=base_url()?>js/date.js"></script>
<!-- jquery.datePicker.js -->
<script type="text/javascript" src="<?=base_url()?>js/jquery.datePicker.js"></script>
<link rel="stylesheet" type="text/css" href="<?=base_url()?>css/datePicker.css" media="screen" />
<link rel="stylesheet" type="text/css" href="<?=base_url()?>css/demo.css" media="screen" />
<script type="text/javascript">
$(function()
{
    $('.formInputDate').datePicker({startDate:'01/01/1996'});
    $('#wholesale_id').attr('disabled',true);
    $('#gk_register_id').attr('disabled',true);
    $('#ivr_id').attr('disabled',true);

    $('#whole_saleselect').click(function()
    {
        if($('#whole_saleselect').attr('checked'))
        {
            $('#wholesale_id').attr('disabled',false);
            $('#gk_registerselect').attr('checked',false);
            $('#gk_register_id').attr('disabled',true);
            $('#ivrselect').attr('checked',false);
            $('#ivr_id').attr('disabled',true);
        }
        else
        {
            $('#wholesale_id').attr('disabled',true);
            $('#gk_registerselect').attr('checked',false);
            $('#ivrselect').attr('checked',false);
        }
    });


    $('#gk_registerselect').click(function()
    {
        if($('#gk_registerselect').attr('checked'))
        {
            $('#gk_register_id').attr('disabled',false);
            $('#whole_saleselect').attr('checked',false);
            $('#wholesale_id').attr('disabled',true);
            $('#ivrselect').attr('checked',false);
            $('#ivr_id').attr('disabled',true);
        }
        else
        {
            $('#gk_register_id').attr('disabled',true);
            $('#whole_saleselect').attr('checked',false);
            $('#ivrselect').attr('checked',false);
        }
    });


    $('#ivrselect').click(function()
    {
        if($('#ivrselect').attr('checked'))
        {
            $('#ivr_id').attr('disabled',false);
            $('#whole_saleselect').attr('checked',false);
            $('#wholesale_id').attr('disabled',true);
            $('#gk_registerselect').attr('checked',false);
            $('#gk_register_id').attr('disabled',true);
        }
        else
        {
            $('#ivr_id').attr('disabled',true);
            $('#whole_saleselect').attr('checked',false);
            $('#gk_registerselect').attr('checked',false);
        }
    });
});
</script>


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

    var startdate = $.trim(document.getElementById("startdate").value);
    var enddate = $.trim(document.getElementById("enddate").value);

    var wholesale_id = $.trim(document.getElementById("wholesale_id").value);
    if($('#wholesale_id').attr('disabled'))
    {
        wholesale_id = '';
    }

    var gk_register_id = $.trim(document.getElementById("gk_register_id").value);
    if($('#gk_register_id').attr('disabled'))
    {
        gk_register_id = '';
    }

    var ivr_id = $.trim(document.getElementById("ivr_id").value);
    if($('#ivr_id').attr('disabled'))
    {
        ivr_id = '';
    }

    if(startdate=="")
    {
        startdate = "NULL";
    }

    if(enddate=="")
    {
        enddate = "NULL";
    }

    if(wholesale_id=="")
    {
        wholesale_id = "NULL";
    }

    if(gk_register_id=="")
    {
        gk_register_id = "NULL";
    }

    if(ivr_id=="")
    {
        ivr_id = "NULL";
    }

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

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

    xmlhttp.onreadystatechange=stateChanged;
    xmlhttp.open("GET", url + "/" + escape(startdate) + "/" + escape(enddate) + "/" + escape(wholesale_id)  + "/" + escape(gk_register_id) + "/" + escape(ivr_id) +  "/" + 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" style='padding-left:10px;'>
                </div>

                  <span>&nbsp;&nbsp;&raquo;</span> <?=$titleMessage?>  <?=$titleErrorMessage?>   </div>


   <!-- Search Information -->

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

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>
    <!-- First Part -->

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="right"><input type="checkbox" name="whole_saleselect" id="whole_saleselect" value="1">&nbsp;&nbsp;Wholesale Client :</td>
    <td align="left">
        <input type="text" id="wholesale_id" class = "formInput" name="wholesale_id" value="" style="width:90px">
    </td>

    <td align="right"><input type="checkbox" name="gk_registerselect" id="gk_registerselect" value="1">&nbsp;&nbsp;GK/Register Client :</td>
    <td align="left">
        <input type="text" class = "formInput" id="gk_register_id" name="gk_register_id" value="" style="width:90px">
    </td>

    <td align="right"><input type="checkbox" name="ivrselect" id="ivrselect" value="1">&nbsp;&nbsp;IVR Client :</td>
    <td align="left">
        <input type="text" class = "formInput" id="ivr_id" name="ivr_id" value="" style="width:90px">
    </td>

  </tr>
</table>
    <!-- End First part-->
    </td>
  </tr>
  <tr>
    <td>


<!-- Second Part -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>

    <td align="right">From :</td>
    <td align="left"><input type="text" class = "formInputDate" name="startdate" id="startdate" value="<?=$startdate?>" style="width:100px"/></td>

    <td align="right">To :</td>
    <td align="left"><input type="text" class = "formInputDate" name="enddate" id="enddate" value="<?=$enddate?>" style="width:100px"/></td>

    <td align="right">&nbsp;</td>
    <td align="left">&nbsp;</td>

    <td align="right">&nbsp;</td>
    <td align="left">&nbsp;</td>

    <td align="right">&nbsp;</td>
    <td align="left">&nbsp;</td>

    <td align="right">Rec :</td>
    <td align="left">
      <select name="limit" id="limit" class = "selectFrom" style="width:60px" onchange="searchClientPayment();">
        <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:searchClientPayment();">
	<img src="<?=base_url()?>images/apply.gif" height="22" border="0" />
	</a>

</td>

  </tr>

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






</fieldset>

   <!-- End Search Information -->

    </td>
  </tr>

  <tr>
    <td>

<div id = "pagination">



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

      <span>&nbsp;&nbsp;&raquo;</span> Client Payment List

    </td>
  </tr>


 <tr>
    <td>

 <!-- Client Payment List -->

 <table class="gbTable">

   <tr class="header">
     <td width="2%"><div align="left" style="padding-left:5px;">NR</div></td>
     <td width="15%"><div align="left" style="padding-left:5px;">Date</div></td>
     <td width="12%"><div align="left" style="padding-left:5px;">Login</div></td>
     <td width="7%"><div align="left" style="padding-left:5px;">Parent</div></td>
     <td width="12%"><div align="left" style="padding-left:5px;">Client Type</div></td>
     <td width="12%"><div align="left" style="padding-left:5px;">Amount</div></td>
     <td width="10%"><div align="left" style="padding-left:5px;">Type</div></td>
     <td width="30%"><div align="left" style="padding-left:5px;">Description</div></td>
   </tr>



<?
$i=1;
$add = 0;
$return = 0;
if(is_array($paymentList))
{
    foreach($paymentList as $row)
    {
        $passid = $i;
?>

      <?
	  		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;padding-top:2px;padding-bottom:2px;"><input name="checkActive" type="checkbox"  id="checkActive" value="1" /></td>
 <td align=left class="tableBorderAll" style="padding-left:5px;padding-top:2px;padding-bottom:2px;"><?=$row->paymentdate?></td>
 <td align=left class="tableBorderAll" style="padding-left:5px;padding-top:2px;padding-bottom:2px;"><?=$row->login?></td>
 <td align=left class="tableBorderAll" style="padding-left:5px;padding-top:2px;padding-bottom:2px;"><?=$row->id_reseller?></td>
 <td align=left class="tableBorderAll" style="padding-left:5px;padding-top:2px;padding-bottom:2px;"><?=$row->clienttype?></td>
 <td align=left class="tableBorderAll" style="padding-left:5px;padding-top:2px;padding-bottom:2px;"><?=$row->amount?></td>
 <td align=left class="tableBorderAll" style="padding-left:5px;padding-top:2px;padding-bottom:2px;">
    <?
        if($row->type==1)
        {
            $add += $row->amount;
            echo'Add';
        }
        else
        {
            $return += $row->amount;
            echo'Return';
        }
    ?>
 </td>
 <td align=left class="tableBorderAll" style="padding-left:5px;padding-top:2px;padding-bottom:2px;"><?=$row->description?></td>

   </tr>

<?
$i++;
}

}

?>


 </table>

<!-- End client payment List -->

    </td>
  </tr>

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

    <input type="hidden" name="startdate" id="startdate" value="<?=$startdate?>" />
    <input type="hidden" name="enddate" id="enddate" value="<?=$enddate?>" />
    <input type="hidden" name="wholesale_id" id="wholesale_id" value="<?=$wholesale_id?>" />
	<input type="hidden" name="gk_register_id" id="gk_register_id" value="<?=$gk_register_id?>" />
	<input type="hidden" name="ivr_id" id="ivr_id" value="<?=$ivr_id?>" />
    </td>
  </tr>

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

    <!-- Client payment summery start -->
        <table width="50%" border="0" cellspacing="0" cellpadding="0" class="tableBorder">
          <tr>
            <td colspan="2" class="mainTableTitle"><span>&nbsp;&nbsp;&raquo;</span> Client Payment Summary</td>
          </tr>

         <tr>
            <td class='formLabelRigit' width="50%" style='padding-top:10px;'> Total Add :  </td>
            <td class='formLabelLeft' width="50%" style='padding-top:10px;'><?=$add?></td>
         </tr>

         <tr>
            <td class='formLabelRigit'>  Total Return :  </td>
            <td class='formLabelLeft'><?=$return?></td>
         </tr>
       </table>
    <!-- Client payment summery end -->

    </td>
  </tr>


</table>

</div>



    </td>
  </tr>

</table>


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