<link rel="stylesheet" href="css/new_mxerp.css">


<script type="text/javascript">
  function checkdate(date)
{
  var from =document.getElementById('from').value;
  var to =document.getElementById('to').value;
  
    var cdate=date.split("/");
    var sdate=from.split("/");
    var edate=to.split("/");

    cdate[1]=cdate[1]-1;
    sdate[1]=sdate[1]-1;
    edate[1]=edate[1]-1;
       
    var dateC = new Date(cdate[2], cdate[1], cdate[0]); //Year, Month, Date 
    var dateS = new Date(sdate[2], sdate[1], sdate[0]); //Year, Month, Date
      var dateE = new Date(edate[2], edate[1], edate[0]); //Year, Month, Date

      if (dateS > dateE) {
          alert("Start Date is not greather then Date End.");
          document.getElementById('fromdate').value=from;
          document.getElementById('todate').value=to;
          
      }

      if (dateC > dateE) {
          alert("Date Not greather than "+to);
         document.getElementById('fromdate').value=from;
          document.getElementById('todate').value=to;
         
      }

      if (dateC < dateS) {
          alert(" Date Not less than "+from);
          document.getElementById('fromdate').value=from;
          document.getElementById('todate').value=to;
         
      } 
  
  
}
</script>

<div class="body_contain">
<div class="tab_div">
<h1>Purchase Order Approval</h1>
<div class="new_tab">
	<!--Inside tab-->
	<div class="inside_tab">
	<ul>
      <?php  //echo "SELECT M.id AS mainID,M.no_of_assignee,C.approval_name,C.id AS childID,C.approval_by FROM conf_purch_approval AS M INNER JOIN conf_purch_app_details AS C ON M.id=C.purch_approval_id WHERE M.company_id='".$_SESSION['ACGCompanyId']."' AND M.doc_type='PO' ORDER BY C.seq_no";
      
      
      $purchase_approval=DB_query("SELECT M.id AS mainID,M.no_of_assignee,C.approval_name,C.id AS childID,C.approval_by 
        FROM conf_purch_approval AS M INNER JOIN conf_purch_app_details AS C ON M.id=C.purch_approval_id WHERE M.company_id='".$_SESSION['ACGCompanyId']."'
         AND M.doc_type='PO' ORDER BY C.seq_no",$db);
      
      $i=0;
      if(DB_num_rows($purchase_approval)>0){
      while($purchase_result=DB_fetch_array($purchase_approval)){
        $Headlist=explode(",",$purchase_result['approval_by']);
        
        if($_SESSION['UserType']=='SuperAdmin')
         {
         $flag=0;   
        }
        else
        {
         $flag=1;
        }
        if(in_array($_SESSION['UserID'],$Headlist) || $flag==0 )
        {
        //print_r($Headlist);
        ?>
	<li><a href="index.php?route=POModule/po_approval&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&tab=<?php echo $i;?>&type=POModule/po_head_approval&id=<?php echo $purchase_result['childID'];?>&pid=<?php echo $purchase_result['mainID']?>"><?php echo $purchase_result['approval_name']?></a></li>
        <?php $i++;}
      }
     }?>
	</ul>
	</div>
	<!--End of Inside tab-->
</div>

<div style="width:100%; ">
			

	<?php  
        if($_REQUEST['tab']!='')
	{
	include("po_head_approval.php");
	}
//        
//	if($_REQUEST['tab']=='')
//	{
//	include("pend_issued_index.php");
//	}
	?>
</div>
<?php if(isset($_SESSION['success_msg']))
{ ?>
	<script> alert("<?php echo ($_SESSION['success_msg']);?>");</script>
<?php 
}	unset($_SESSION['success_msg']);
?>
</div>
</div>

<!--Tabs script starts-->
<!--<script type="text/javascript" src="js/prototype.lite.js"></script>
<script type="text/javascript" src="js/moo.fx.js"></script>
<script type="text/javascript" src="js/moo.fx.pack.js"></script>
<script type="text/javascript">
function init(){
  var stretchers = document.getElementsByClassName('box');
  var toggles = document.getElementsByClassName('tab');
  var myAccordion = new fx.Accordion(
    toggles, stretchers, {opacity: false, height: true, duration: 600}
  );
  //hash functions
  var found = false;
  toggles.each(function(h3, i){
    var div = Element.find(h3, 'nextSibling');
      if (window.location.href.indexOf(h3.title) > 0) {
        myAccordion.showThisHideOpen(div);
        found = true;
      }
    });
    if (!found) myAccordion.showThisHideOpen(stretchers[0]);
}
</script>-->
