<?php require_once("includes/initialize.php");
error_reporting(0);
ini_set('display_errors', 0);
$user_data = Userdata::find_by_id($session->user_id);

        if ((substr($user_data->formno,2,2)!=18) and ((substr($user_data->formno,2,2)!=19))){
      
     // echo "All new table: ".substr($user_data->formno,2,2);
      
      Switch(substr($user_data->formno,2,2))
      {
          case '20':$table='form_data';
          break;
          
          case '21': $table='form_data21';
          break;
          
          case '22': $table='form_data22';
      }
  
  
      
       $biodata = Biodata2::find_by_id($table, $user_data->formno, $user_data->email);
       
       //echo "kll: ". $biodata->passport;
        $new_dp = DEPARTMENTCLASS::new_admin_dept($biodata->formno);
        
          if (!isset($new_dp->department)){
           $biodata->courses ='Nil';   
          }else{
        $biodata->courses = $new_dp->department;
          }
       $biodata->programme = $biodata->level;
  
        // $pixf = substr($biodata->passport, 10);
       $dp = DEPARTMENTCLASS::department_authenticate($new_dp->department);
       $pix = "../../admission/passport/".$biodata->passport;
    
    
    
       
  }else{
 
$biodata = Biodata::find_by_id($user_data->formno, $user_data->email);
}

// echo "Form No: ".$biodata->formno;
 
  //echo "Email : ".$biodata->email;
$current_session = SESSIONCLASS::session_authenticate();

   //echo "Session idpppppppppppppppppppppppppppppppp: ". $current_session->ses_sem_id;
//  echo "Session: ".$current_session->session;
//  echo "Status: ".$current_session->status;

$transaction = Transaction::findacceptance($user_data->formno, $user_data->email);
if ($transaction){
 $transaction= Transaction::authenticate($user_data->formno, $user_data->email);
}
$schoolfees = Schoolfees::findschoolfees($user_data->formno, $user_data->email);

if ($schoolfees){
 $schoolfees= Schoolfees::authenticate($user_data->formno, $user_data->email);
}
//$certificate = Certificate::authenticate($user_data->formno, $user_data->email);
//print_r($certificate);


if (substr($user_data->formno,2,2)=='19'){

 $new_dp = DEPARTMENTCLASS::new_admin_dept($user_data->formno);
  $biodata->courses = $new_dp->department;
  $biodata->programme = $biodata->level; 
  
  $dp = DEPARTMENTCLASS::department_authenticate($biodata->courses);
    $pix = "../application_account/passport/".$pixf;
   
}else {

$dp = DEPARTMENTCLASS::department_authenticate($biodata->courses);
$display_course = COURSECLASS::fetch_all_course($biodata->courses, $biodata->programme, $session_class->semester);
$alldp = DEPARTMENTCLASS::find_all($dp->faculty);
$pix = "../Oscotech-Wallet/passport/".$pixf;

}






    //echo "User opuuuu: ".$user_data->std_process_id.' '.$biodata->programme;

 $s= find_semester($user_data->std_process_id);
      $clevel= find_level($user_data->std_process_id,$biodata->programme);
if ($clevel!=''){
  
      //echo "<br>Clevel: ".$clevel;
      
      if (($clevel=='HND II') &&(($user_data->std_process_id==4) OR($user_data->std_process_id==5))){
          $clevel='HND I';
          
      //    echo "Pl: ".$clevel;
      }else if (($clevel=='ND II') &&(($user_data->std_process_id==4) OR($user_data->std_process_id==5))){
            $clevel='ND I';
            
      //       echo "Pl: ".$clevel;
      }
    
    //  echo "<br>Semester: ".$s;

if (($clevel=='ND I') ||($clevel=='HND I')){
    
    $prs = '20'.substr($user_data->formno,2,2);
     $se = $prs.'/'.($prs+1);
     
     
     
}else if (($clevel=='ND II') ||($clevel=='HND II')){
     $prs = '20'.(substr($user_data->formno,2,2)+1);
     $se = $prs.'/'.($prs+1);
}

//echo "Session LLLLLLLLLLLLLLLLLLLLLLL: ".$se.'  fhfghgfhf '.$s;

$status = SESSIONCLASS::session_authenticate($se, $s);
$semid='';
 $semid = $status->ses_sem_id;


}else{
    $semid='';
}








if ($biodata->programme=='Adv. Cert.'){
    
}else if ($biodata->programme=='ND'){
    $biodata->programme='nd';
 $level = strtolower($biodata->programme) . "i_tbl";
  
}else if ($biodata->programme=='ND I'){
  $biodata->programme='ndi';
 $level = strtolower($biodata->programme) . "i_tbl";
  
}else if ($biodata->programme=='HND'){
  $biodata->programme='hnd';
 $level = strtolower($biodata->programme) . "i_tbl";
  
}else if ($biodata->programme=='HND I'){
  $biodata->programme='hndi';
 $level = strtolower($biodata->programme) . "i_tbl";
  
}else {
$level = strtolower($biodata->programme) . "i_tbl";
}




$course_checker = COURSEREGCHECKER::courseform_authenticate($level, $user_data->formno, $semid);




?>
<div class="art-content-layout">
    <div class="art-content-layout-row">

        <div class="art-layout-cell layout-item-0" style="width: 100%">
<?php 
if (!$transaction){ ?>
            <marquee behavior="alternate" scrolldelay="200" onmouseover="this.setAttribute('scrollamount',0,0);"
                     onmouseout="this.setAttribute('scrollamount',6,0);">
                <div style="color:#F00; font-style:italic; font-weight:bolder;">NOTE: <span
                            style="color:#F00; font-style:italic;">To pay acceptance fees, click Payment Module and select Acceptance Fees Menu</span>
                </div>
            </marquee>
            
            <?php } else if ($transaction != "" && $transaction->responsecode != '00'){?>
            
            <marquee behavior="alternate" scrolldelay="200" onmouseover="this.setAttribute('scrollamount',0,0);"
                     onmouseout="this.setAttribute('scrollamount',6,0);">
                <div style="color:#F00; font-style:italic; font-weight:bolder;">NOTE: <span
                            style="color:#F00; font-style:italic;">Acceptance fees payment not successful, try to requery the transaction</span>
                </div>
            </marquee>
            
           <?php } else if  (($transaction != "" && $transaction->responsecode == '00') && (substr($user_data->formno,0,2)=="PU") && (!$schoolfees)){?>
            <marquee behavior="alternate" scrolldelay="200" onmouseover="this.setAttribute('scrollamount',0,0);"
                     onmouseout="this.setAttribute('scrollamount',6,0);">
                <div style="color:#F00; font-style:italic; font-weight:bolder;">NOTE: <span
                            style="color:#F00; font-style:italic;">To proceed to School Fees payment, click Payment Module and select School Fees menu</span>
                </div>
            </marquee>
            <?php } else if (($transaction != "" && $transaction->responsecode == '00') && ($user_data->std_process_id==2) &&((substr($user_data->formno,0,2)=="DP") || (substr($user_data->formno,0,2)=="FT"))){?>
            <marquee behavior="alternate" scrolldelay="200" onmouseover="this.setAttribute('scrollamount',0,0);"
                     onmouseout="this.setAttribute('scrollamount',6,0);">
                <div style="color:#F00; font-style:italic; font-weight:bolder;">NOTE: <span
                            style="color:#F00; font-style:italic;">To print your Admission Letter, click Admission Module and print your Admission Letter</span>
                </div>
            </marquee>
            <!--<?php } else if (($user_data->std_process_id==3)&& (!$schoolfees)||($schoolfees=='')) {?>
           
            <!--<marquee behavior="alternate" scrolldelay="200" onmouseover="this.setAttribute('scrollamount',0,0);"-->
            <!--         onmouseout="this.setAttribute('scrollamount',6,0);">-->
            <!--    <div style="color:#F00; font-style:italic; font-weight:bolder;">NOTE: <span-->
            <!--                style="color:#F00; font-style:italic;">To proceed to School Fees payment, click Payment Module and select School Fees menu</span>-->
            <!--    </div>-->
            <!--</marquee>-->
            <?php } else if (($user_data->std_process_id==3) &&  ($schoolfees->responsecode !=='00')) {?>
           
            <marquee behavior="alternate" scrolldelay="200" onmouseover="this.setAttribute('scrollamount',0,0);"
                     onmouseout="this.setAttribute('scrollamount',6,0);">
                <div style="color:#F00; font-style:italic; font-weight:bolder;">NOTE: <span
                            style="color:#F00; font-style:italic;">School fees payment not successful, try to requery the transaction </span>
                </div>
            </marquee>
            
            <?php } else if (($user_data->std_process_id==4) &&  ($schoolfees->responsecode=='00')) {?>
           
            <marquee behavior="alternate" scrolldelay="200" onmouseover="this.setAttribute('scrollamount',0,0);"
                     onmouseout="this.setAttribute('scrollamount',6,0);">
                <div style="color:#F00; font-style:italic; font-weight:bolder;">NOTE: <span
                            style="color:#F00; font-style:italic;">To register for your semester courses, click Registration Module and select appropriate semester</span>
                </div>
            </marquee>
            
            <?php } else if (($user_data->std_process_id==5) &&  ($schoolfees->responsecode=='00')) {?>
           
            <marquee behavior="alternate" scrolldelay="200" onmouseover="this.setAttribute('scrollamount',0,0);"
                     onmouseout="this.setAttribute('scrollamount',6,0);">
                <div style="color:#F00; font-style:italic; font-weight:bolder;">NOTE: <span
                            style="color:#F00; font-style:italic;">Next process will be activated soon. Thank you.</span>
                </div>
            </marquee>
            
            <?php }?>
        </div>
    </div>
</div>

<div class="art-content-layout">
    <div class="art-content-layout-row">

        <div class="art-layout-cell layout-item-0" style="width: 100%">


            <div style="text-transform:uppercase; font-stretch:extra-expanded;color:#03C; font-weight:bolder; font-size:17px;border-bottom:inset #000 thin">
                brief biodata
            </div>

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


<?php if ($current_session->session == $biodata->session) { ?>

    <div class="art-content-layout">
        <div class="art-content-layout-row">
            <div class="art-layout-cell layout-item-0" style="width: 20%; font-size:16px">
                <div>Form no:</div>
                <div>Fullname:</div>
                <div>Current level:</div>
                <div>Department:</div>
                <div>State of origin:</div>


            </div>

            <div class="art-layout-cell layout-item-0" style="width: 40%; font-size:16px">
                <div> <?php echo $biodata->formno; ?></div>

                <div> <?php echo strtoupper($biodata->surname . " " . $biodata->othernames); ?></div>
                <div><?php 
                
                if ($biodata->programme=='Adv. Cert.'){
                 echo $biodata->programme;
                }else{ echo strtoupper($biodata->programme." I"); }?></div>
                <div><?php echo ucwords($biodata->courses); ?></div>
                <div><?php echo ucwords($biodata->state); ?></div>
            </div>
        </div>
    </div>
    <br/>
    <div class="art-content-layout">
        <div class="art-content-layout-row">
            <div class="art-layout-cell layout-item-0" style="width: 100%">
                <div style=" text-align:left; font-stretch:extra-expanded; text-transform:uppercase; color:#03C; font-weight:bolder; font-size:16px; margin-bottom:10px">
                    current semester information
                </div>
            </div>
        </div>
    </div>

    <div class="art-content-layout">
        <div class="art-content-layout-row">
            <div class="art-layout-cell layout-item-0" style="width: 30%; font-size:16px">
                <div> Current session:</div>
                <!--<div>Registration status:</div>-->
                <div>Normal registration closes:</div>
                <div>Late registration closes:</div>
                <div>Acceptance fees payment:</div>
                <div>School fees payment:</div>
                <div>Certificate fees payment:</div>

            </div>


            <div class="art-layout-cell layout-item-0" style="width: 20%; font-size:16px">

                <div><?php echo $current_session->session; ?> </div>


                <div><?php echo "Nil" /*12/11/2018"$biodata->programme*/
                    ; ?> </div>
                <div>   <?php echo "Nil"/* 01/01/2019 "//$biodata->courses;*/ ?> </div>
                <div>    <?php
                    //echo $transaction->responsecode;
                    if ($transaction != "" && $transaction->status == 'Approved Successful') {
                        echo "Completed";
                    } else {
                        echo "Not Completed";
                    }


                    ?> </div>
                <div>    <?php

                    if ($schoolfees != "" && $schoolfees->session == $current_session->session && $schoolfees->status = 'Approved Successful') {

                        echo "Completed";
                    } else {
                        echo "Not Completed";
                    }


                    ?> </div>
                <div>    <?php

                    if ($certificate != "" && $schoolfees->session == $current_session->session && $certificate->status = 'Approved Successful') {
                        echo "Not Completed";
                    } else {
                        echo "Not Completed";
                    }


                    ?> </div>

            </div>
            <div class="art-layout-cell layout-item-0" style="width: 30%;font-size:16px">

                <div> Current semester:</div>

                <div> Course registration:</div>
                <div>First semester:</div>
                <div>Second semester:</div>
                <div></div>
            </div>

            <div class="art-layout-cell layout-item-0" style="width: 20%;font-size:14px">

                <div> <?php echo(ucfirst(strtolower($current_session->semester))); ?></div>
                <div><?php echo "Details" ?></div>
                <div> <?php
                    if ($course_checker != "" /*&& $current_session->semester=="FIRST"*/) {
                        echo "Completed";
                    } else {
                        echo "Not Completed";
                    }


                    ?></div>
                <div> <?php

                    if ($course_checker != "" && $current_session->semester == "SECOND") {
                        echo "Completed";
                    } else {
                        echo "Not Completed";
                    }


                    ?></div>
                <div></div>
            </div>
        </div>

    </div>
    </div>


    </article></div>
    <?php
} else { ?>


    <div class="art-content-layout">
        <div class="art-content-layout-row">
            <div class="art-layout-cell layout-item-0" style="width: 20%; font-size:16px">
                <div>Form no:</div>
                <div>Fullname:</div>
                <div>Current level:</div>
                <div>Department:</div>
                <div>State of origin:</div>


            </div>

            <div class="art-layout-cell layout-item-0" style="width: 40%; font-size:16px">
                <div> <?php echo $biodata->formno; ?></div>

                <div> <?php echo strtoupper($biodata->surname . " " . $biodata->othernames); ?></div>
                <div><?php echo $biodata->programme; ?></div>
                <div><?php echo $biodata->courses; ?></div>
                <div><?php echo $biodata->state; ?></div>
            </div>
        </div>
    </div>
    <br/>
    <div class="art-content-layout">
        <div class="art-content-layout-row">
            <div class="art-layout-cell layout-item-0" style="width: 100%">
                <div style=" text-align:left; font-stretch:extra-expanded; text-transform:uppercase; color:#03C; font-weight:bolder; font-size:16px; margin-bottom:10px">
                    current semester information
                </div>
            </div>
        </div>
    </div>

    <div class="art-content-layout">
        <div class="art-content-layout-row">
            <div class="art-layout-cell layout-item-0" style="width: 30%; font-size:16px">
                <div> Current session:</div>
                <!--<div>Registration status:</div>-->
                <div>Normal registration closes: </div>
                <div>Late registration closes: </div>
                <div>Acceptance fees payment:</div>
                <div>School fees payment:</div>
                <div>Certificate fees payment:</div>

            </div>


            <div class="art-layout-cell layout-item-0" style="width: 20%; font-size:16px">

                <div><?php echo $current_session->session; ?> </div>


                <div><?php echo "31/01/2019"; 
                     ?> </div>
                <div>   <?php echo "08/02/2019"; ?> </div>
                <div>    <?php
                    if ($acceptance != "") {
                        echo "Completed";
                    } else {
                        echo "Not Completed";
                    }


                    ?> </div>
                <div>    <?php

                    if ($schoolfees != "" && $schoolfees->session == $current_session->session && $schoolfees->responsecode = 'Approved Successful') {
                        echo "Completed";
                    } else {
                        echo "Not Completed";
                    }


                    ?> </div>
                <div>    <?php

                    /*if (!$certificate ) {
                        echo "Completed";
                    } else {
                        echo "Not Completed";
                    }
*/

                    ?> </div>

            </div>
            <div class="art-layout-cell layout-item-0" style="width: 30%;font-size:16px">

                <div> Current semester:</div>

                <div> Course registration:</div>
                <div>First semester:</div>
                <div>Second semester:</div>
                <div></div>
            </div>

            <div class="art-layout-cell layout-item-0" style="width: 20%;font-size:14px">

                <div> <?php echo(ucfirst(strtolower($current_session->semester))); ?></div>
                <div><?php echo "Details" ?></div>
                <div> <?php
                    if ($course_checker != "" /*&& $current_session->semester=="FIRST"*/) {
                        echo "Completed";
                    } else {
                        echo "Not Completed";
                    }


                    ?></div>
                <div> <?php

                    if ($course_checker != "" && $current_session->semester == "SECOND") {
                        echo "Completed";
                    } else {
                        echo "Not Completed";
                    }


                    ?></div>
                <div></div>
            </div>
        </div>

    </div>
    </div>


    </article></div>


<?php } ?>
   
