<?
$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'});
    $('#reseller4id').attr('disabled',true);
    $('#reseller3id').attr('disabled',true);
    $('#reseller2id').attr('disabled',true);
    $('#reseller1id').attr('disabled',true);

    $('#r4select').click(function()
    {
        if($('#r4select').attr('checked'))
        {
            $('#reseller4id').attr('disabled',false);
            $('#r3select').attr('checked',false);
            $('#reseller3id').attr('disabled',true);
            $('#r2select').attr('checked',false);
            $('#reseller2id').attr('disabled',true);
            $('#r1select').attr('checked',false);
            $('#reseller1id').attr('disabled',true);
        }
        else
        {
            $('#reseller4id').attr('disabled',true);
            $('#r3select').attr('checked',false);
            $('#r2select').attr('checked',false);
            $('#r1select').attr('checked',false);
        }
    });


    $('#r3select').click(function()
    {
        if($('#r3select').attr('checked'))
        {
            $('#reseller3id').attr('disabled',false);
            $('#r4select').attr('checked',false);
            $('#reseller4id').attr('disabled',true);
            $('#r2select').attr('checked',false);
            $('#reseller2id').attr('disabled',true);
            $('#r1select').attr('checked',false);
            $('#reseller1id').attr('disabled',true);
        }
        else
        {
            $('#reseller3id').attr('disabled',true);
            $('#r4select').attr('checked',false);
            $('#r2select').attr('checked',false);
            $('#r1select').attr('checked',false);
        }
    });


    $('#r2select').click(function()
    {
        if($('#r2select').attr('checked'))
        {
            $('#reseller2id').attr('disabled',false);
            $('#r4select').attr('checked',false);
            $('#reseller4id').attr('disabled',true);
            $('#r3select').attr('checked',false);
            $('#reseller3id').attr('disabled',true);
            $('#r1select').attr('checked',false);
            $('#reseller1id').attr('disabled',true);
        }
        else
        {
            $('#reseller2id').attr('disabled',true);
            $('#r4select').attr('checked',false);
            $('#r3select').attr('checked',false);
            $('#r1select').attr('checked',false);
        }
    });


    $('#r1select').click(function()
    {
        if($('#r1select').attr('checked'))
        {
            $('#reseller1id').attr('disabled',false);
            $('#r4select').attr('checked',false);
            $('#reseller4id').attr('disabled',true);
            $('#r3select').attr('checked',false);
            $('#reseller3id').attr('disabled',true);
            $('#r2select').attr('checked',false);
            $('#reseller2id').attr('disabled',true);
        }
        else
        {
            $('#reseller1id').attr('disabled',true);
            $('#r4select').attr('checked',false);
            $('#r3select').attr('checked',false);
            $('#r2select').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 searchResellerPayment()
{
    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 reseller1id = $.trim(document.getElementById("reseller1id").value);
    if($('#reseller1id').attr('disabled'))
    {
        reseller1id = '';
    }

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

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

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

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

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

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

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

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

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


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

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

    xmlhttp.onreadystatechange=stateChanged;
    xmlhttp.open("GET", url + "/" + escape(startdate) + "/" + escape(enddate) + "/" + escape(reseller1id)  + "/" + escape(reseller2id) + "/" + escape(reseller3id) +  "/" + escape(reseller4id) + "/" +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="r4select" id="r4select" value="1">&nbsp;&nbsp;R-IV :</td>
    <td align="left">
    <select name="reseller4id" id="reseller4id" class = "selectFrom" style="width:120px">
    <?=$reseller4List?>
    </select>
    </td>

    <td align="right"><input type="checkbox" name="r3select" id="r3select" value="1">&nbsp;&nbsp;R-III :</td>
    <td align="left">
    <select name="reseller3id" id="reseller3id" class = "selectFrom" style="width:120px">
    <?=$reseller3List?>
    </select>
    </td>

    <td align="right"><input type="checkbox" name="r2select" id="r2select" value="1">&nbsp;&nbsp;R-II :</td>
    <td align="left">
    <select name="reseller2id" id="reseller2id" class = "selectFrom" style="width:120px">
    <?=$reseller2List?>
    </select>
    </td>

    <td align="right"><input type="checkbox" name="r1select" id="r1select" value="1">&nbsp;&nbsp;R-I :</td>
    <td align="left">
    <select name="reseller1id" id="reseller1id" class = "selectFrom" style="width:120px">
    <?=$reseller1List?>
    </select>
    </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:50px" onchange="searchResellerPayment();">
        <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:searchResellerPayment();">
	<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> Reseller Payment List

    </td>
  </tr>


 <tr>
    <td>

 <!-- Reseller Payment List -->

 <table class="gbTable">

   <tr class="header">
     <td width="2%"><div align="left" style="padding-left:5px;">NR</div></td>
     <td width="20%"><div align="left" style="padding-left:5px;">Date</div></td>
     <td width="15%"><div align="left" style="padding-left:5px;">Name</div></td>
     <td width="7%"><div align="left" style="padding-left:5px;">level</div></td>
     <td width="16%"><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->creationdate?></td>
 <td align=left class="tableBorderAll" style="padding-left:5px;padding-top:2px;padding-bottom:2px;">
    <?
        echo $this->generallib->get_reseller_name($row->id_reseller,$row->level)
    ?>
 </td>
 <td align=left class="tableBorderAll" style="padding-left:5px;padding-top:2px;padding-bottom:2px;"><?=$row->level?></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 reseller 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="reseller1id" id="reseller1id" value="<?=$reseller1id?>" />
	<input type="hidden" name="reseller2id" id="reseller2id" value="<?=$reseller2id?>" />
	<input type="hidden" name="reseller3id" id="reseller3id" value="<?=$reseller3id?>" />
	<input type="hidden" name="reseller4id" id="reseller4id" value="<?=$reseller4id?>" />
    </td>
  </tr>

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

    <!-- reseller 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> Reseller 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>
    <!-- reseller payment summery end -->

    </td>
  </tr>


</table>

</div>



    </td>
  </tr>

</table>


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