<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>

<?php


$branch=$_SESSION['branch'];
$groupID=$_REQUEST['group'];
$categoryID=$_REQUEST['category'];


$sql = "SELECT * FROM eduportal_accounts_finance_bank_details where branch_id='$branch' ";

/*if (isset($_REQUEST['sub_cat'])) {
  

if($_REQUEST['sub_cat']=="All"){

} else {
$sql .= " AND sub_group_id = '" .$_REQUEST['sub_cat']. "' ";

}

if($_REQUEST['account_id']=="All"){

} else {
$sql .= " AND account_id = '" .$_REQUEST['account_id']. "' ";

}

}*/
 //print_r($sql);
$WorkAssignListings = $m->query($sql); 


?>


<!DOCTYPE html>
<html lang="en">
<head>

<title>Create Account Heads | EduPortal</title>
<?php include('RootMe/css_links.php');?>

</head>
  
<script type="text/javascript">



function getGroup(id){

//alert(id);

if (window.XMLHttpRequest) {

// code for IE7+, Firefox, Chrome, Opera, Safari

xmlhttp=new XMLHttpRequest();

} else { // code for IE6, IE5

xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

}

xmlhttp.onreadystatechange=function() {

if (xmlhttp.readyState==4 && xmlhttp.status==200) {

document.getElementById("group").innerHTML=xmlhttp.responseText;
// alert(xmlhttp.responseText);

}

}

xmlhttp.open("GET","get_account_group.php?account_id="+id,true);

xmlhttp.send();




}



          

function getBankFields(id){

//alert(id);
if (id==15) {
document.getElementById("account_branch").style.display="block";
document.getElementById("account_title").style.display="block";
document.getElementById("account_no").style.display="block";
document.getElementById("IBAN").style.display="block";
document.getElementById("swif_code").style.display="block";
document.getElementById("opening_balance").style.display="block";
} else  {
   document.getElementById("account_branch").style.display="none";
   document.getElementById("account_title").style.display="block";
   document.getElementById("account_no").style.display="none";
   document.getElementById("IBAN").style.display="none";
   document.getElementById("swif_code").style.display="none";
   document.getElementById("opening_balance").style.display="block";
   }

if (id==15) {
   document.getElementById("account_type").value="bank";
}

if (id==14) {
document.getElementById("account_type").value="cash";
}

if (id==13) {
document.getElementById("account_type").value="pettycash";
}

}



function AccountCode(id){

//alert(id);
if (window.XMLHttpRequest) {

// code for IE7+, Firefox, Chrome, Opera, Safari

xmlhttp=new XMLHttpRequest();

} else { // code for IE6, IE5

xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

}

xmlhttp.onreadystatechange=function() {

if (xmlhttp.readyState==4 && xmlhttp.status==200) {

document.getElementById("account_code").value=xmlhttp.responseText;
//alert(xmlhttp.responseText);

}

}

xmlhttp.open("GET","getAccountCode.php?accountcode="+id,true);

xmlhttp.send();


}

</script>

<body class="nav-md">
<div class="container body">
<div class="main_container">
<div class="col-md-3 left_col">

<?php include('RootMe/sidebar.php');?>

<?php include('RootMe/header.php');?>

<!-- page content -->
<div class="right_col" role="main">
<div class="" style="background-color: white;">

<a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 

<a href="#">Create Accounts </a> 

<br><br>

            
<section class="add_sub_agent" id="table_sub_agent">
<div class="container">

<div class="" style="margin-top:10px;">

<div class="clearfix"></div>
</div>

   <!-- create account -->

<a href="opening_balances.php" style="float: right;margin-top: -35px;"  style="padding: 0px 5px; font-size:14px;" class="btn btn-success">

Dfine Account Opening Balances

</a>

<a style="float: right;margin-top: -35px;" id="pay" data-toggle="modal" data-target="#CreateAccount" style="padding: 0px 5px; font-size:14px;"  href="#" class="btn btn-success">

Create Account

</a>


<!-- Modal -->
<div id="CreateAccount" class="modal fade" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"> Create Account   </h4>
</div>


<div class="modal-body">

<form class="form-style-7" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post" enctype="multipart/form-data">

<input type="hidden" name="action" value="CreateLastLevelAccountName">
<input type="hidden" name="account_type" id="account_type" value="">

<div class="col-md-12 col-xs-12" style="padding: 8px;margin-top: -12px;">
<div class="form-group ">
<label class="required">Sub Group</label>
<select name="sub_group" onChange="getBankFields(this.value)" class="chosen-multi-select inputfield form-control">

<option value="">Select Sub Group</option>

<?php
$m->where("parent_id", 8);
$accounts = $m->get("eduportal_chart_of_accounts");
foreach ($accounts as $account) { ?>

<option <?php if (16==$account['coa_id']) { echo 'disabled'; } ?> value="<?php echo $account['coa_id']; ?>"><?php echo $account['account_title']; ?></option>

<?php } ?>

</select> 
</div>
</div>


<div class="col-md-12 col-xs-12" style="padding: 8px;display: none;" id="account_branch">
<div class="form-group ">
<label class="required">Account Branch</label>

<input type="text" name="account_branch" class="form-control" value="" style="width: 100%;height: 34px;"> 

</div>
</div>

<div class="col-md-12" style="display: none;" id="account_title">
<div class="form-group" >

<label>  Account Title </label>
<input type="text" name="account_title" class="form-control" value="" style="width: 100%;height: 34px;">
</div>
</div>


<div class="col-md-12" style="display: none;" id="account_no">
<div class="form-group" >

<label>  Account No </label>
<input type="text" name="account_no" class="form-control" value="" style="width: 100%;height: 34px;">
</div>
</div>

<div class="col-md-12" style="display: none;" id="IBAN" >
<div class="form-group" >

<label>  IBAN </label>
<input type="text" name="IBAN"  class="form-control" value="" style="width: 100%;height: 34px;">
</div>
</div>


<div class="col-md-12" style="display: none;" id="swif_code" >
<div class="form-group" >

<label>  Swift Code </label>
<input type="text" name="swif_code" class="form-control" value="" style="width: 100%;height: 34px;">
</div>
</div>


<div class="col-md-12" style="display: none;" id="opening_balance" >
<div class="form-group" >

<label>  Opening Balance </label>
<input type="text" name="opening_balance" class="form-control" value="" style="width: 100%;height: 34px;">
</div>
</div>

<br>
<div class="modal-footer">

<button type="submit" class="btn btn-primary" name="submit" >Save </button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>


</div>



 </form>
</div>


                  
          </div>

        </div>
      </div>  

<!-- end create account -->      

<form class="form-style-7" action="create_accounts.php" method="get"  enctype="multipart/form-data">


      
<div class="col-md-3 col-xs-12" style="padding: 8px;">
<div class="form-group ">
<label class="required">Sub Group</label>
<select name="sub_cat" onChange="getAccountNameAgainstSubGroup(this.value)" class="chosen-multi-select inputfield form-control">

<option value="All">All</option>

<?php


$sql="SELECT * FROM eduportal_chart_of_accounts WHERE parent_id=6 || parent_id=7 || parent_id=26 || parent_id = 44 || parent_id = 72 || parent_id = 75 ";  
  $accounts = $m->query($sql); 

foreach ($accounts as $account) { ?>

<option <?php if ($_REQUEST['sub_cat']==$account['coa_id']) { echo 'selected'; } ?> value="<?php echo $account['coa_id']; ?>"><?php echo $account['account_title']; ?></option>

<?php } ?>

</select> 
</div>
</div>


<div class="col-md-3 col-xs-12" style="padding: 8px;">
<div class="form-group ">
<label class="required">Account</label>
<select name="account_id" id="account_id"  class="form-control">

<option value="All">All</option>


<?php
if($_REQUEST['account_id']!='')
{ 

$m->where("id_level_four", $_REQUEST['account_id']); 
$secondLevel = $m->get("eduportal_accounts_coa_level_four");

foreach($secondLevel as $secondLevel_val)
{

?>
<option <?php if($_REQUEST['account_id']==$secondLevel_val['id_level_four']){echo "selected";} ?> value="<?php echo $secondLevel_val['id_level_four']; ?>"><?php echo trim(utf8_encode_all($secondLevel_val['level_four_name'])); ?></option>

<?php }   ?>

<?php } ?>

</select> 
</div>
</div>
       
 

<div class="col-md-2 " style="padding:2px;">


<div class="form-group ">

<button type="submit" class="btn btn-primary" style="margin-top: 26px;">Search</button>
<?php 
if( $_REQUEST['age']!=""){
?>

<a target="_blank" title="Print Arrear Report" href="print_age_wise_students_report.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&orderByAge=<?php echo $_GET['orderByAge'];?>&age=<?php echo $_GET['age'];?>&gender=<?php echo $_GET['gender'];?>&8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156a61oe8lqc1" class="fa fa-print btn btn-primary" style="margin-top: 34px;padding: 9px;">&nbsp;Print

</a>

<?php 
}
?>
</div>




</div>
      <br><br>
<?php  if(isset($_SESSION['alreadyLastName'])){?>


<div class="alert alert-danger" id="msg">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Warning!</strong> You Cannot Add Duplicated Record, Please Change Account Name!
</div>

<?php  unset($_SESSION['alreadyLastName']); } ?>


<table id="listofstudents" style="font-size: 17px;" data-page-length='100' class="table table-striped table-bordered" style="width:100%">

<thead>
<tr>
<th width="3%" class=" center"> S.No</th>
<th width="8%" class="center"> Account Head</th>
<th width="8%" class="center"> Account Code</th>             
<th width="8%" class=" center"> Account Name</th>
<th width="8%" class=" center"> Balance</th>
<th width="8%" class=" center"> Type</th>
<th width="5%" class=" center"> Action </th>  

</tr>
</thead>
<tbody>
<?php 
$count=1;
foreach($WorkAssignListings as $WorkAssignListVal)
{ 

$m->where("coa_id", $WorkAssignListVal['coa_id']);
$AccountsData = $m->get("eduportal_chart_of_accounts");


?>
<tr> 
<td class="center"> <?php echo $count; $count++;?> </td>

<td style="padding-left:1%;"><?php echo $AccountsData[0]['account_title'];  ?></td>

<td style="padding-left:1%;"><?php echo $WorkAssignListVal['account_no'];  ?></td>

<td style="padding-left:1%;"><?php echo  $WorkAssignListVal['account_title'];  ?></td>

<td style="padding-left:1%;"><?php echo  $WorkAssignListVal['opening_balance'];  ?></td>

<td style="padding-left:1%;"><?php echo  $WorkAssignListVal['type'];  ?></td>

<td class="center"> 

<a data-toggle="modal" data-target="#EditLastAccountName<?php echo $WorkAssignListVal['finance_account_id'];?>" style="padding: 0px 5px; font-size:14px;" href="#" class="btn btn-success">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a> 



<!-- Employee Edit Salary Popup start -->


<div id="EditLastAccountName<?php echo $WorkAssignListVal['finance_account_id'];?>" class="modal fade" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" style="border-bottom:none;">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title" style="text-align:center;"> Edit Account Name </h4>
</div>

<div class="modal-body">

<form class="form-style-7" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post"  enctype="multipart/form-data">

<input type="hidden" name="action" value="EditLastAccName">

<input type="hidden" id="date"  name="accID" value="<?php echo  $WorkAssignListVal['finance_account_id'];  ?>" /> 


<div class="col-md-12" >
<div class="form-group" >

<label>  Account Name </label>
<input style="height:40px;padding-left:1%;" type="text" value="<?php echo  $WorkAssignListVal['last_level_account_name'];  ?>"  class="form-control field"  name="last_level_account_name"/>
</div>
</div>

<div class="modal-footer">

<button type="submit" style="margin: 30px;" class="btn btn-primary" name="submit" >Submit </button>
</div>



</form>

</div>

</div>

</div>
</div>

<!-- Employee Edit Salary popup ending -->


</td>                            

</tr>

<?php } ?>





</tbody>

</table>



</form>
</div>

<br><br>


</div>
<div class="clearfix"></div>
</section>


</div>
</div>

</div>
</div>
</div>
<!-- /page content -->



<?php include('RootMe/js_linksscript.php');?>

<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
$('#listofstudents').DataTable();
} 
);
</script>

<!-- searchable dropdown -->

<link href="autosearch_select/select2.css" rel="stylesheet">
<link href="autosearch_select/select2-default.css" rel="stylesheet">
<script src="autosearch_select/select2.min.js"></script>

<script>
$(function() {
$('.chosen-select').select2( { width:'100%', maximumSelectionSize: 1 } );
$(document).ready(function() {
$(".chosen-multi-select").select2( { width:'100%', } ); }); }); function slideout(){ setTimeout(function(){
$(".alert-success").fadeOut("slow", function () { });
$(".alert-danger").fadeOut("slow", function () { }); }, 4000);}
</script>
</body>
</html>
