<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
date_default_timezone_get('Europe/London');


require_once("./includes/initialize3.php");

// echo $formno=$_REQUEST['emp_id'];
$formno = $_SESSION['formno'];
$user = $_SESSION['user'];
$date = date('Y-m-d h:i');
 $acc_id = $_SESSION['acc_id'];
 
$table = substr($formno, 2,2);

switch($table){
    
    case 20:
        $table="form_data";
        break;
        
    case 21:
        $table="form_data21";
        break;
}


if(isset($_POST['update'])!="")
{
    if (isset($_FILES["pix"]["name"])!=""){
        $filename = $_FILES["pix"]["name"];
        $file_ext = substr($filename, strripos($filename, '.'));
        $u_ext=strtoupper($file_ext);
        if ($u_ext== ".JPG" || $u_ext == ".PNG" ){
            $folder="../application_account/passport/";
            $folder2="./passport/";
            $destination="./passport/".$formno.'i'.$file_ext;
            $renameImg = $folder . $formno. 'i.jpg';
            $renameImg2 = $folder2 . $formno. 'i.jpg';
            $image[]=$destination;
            move_uploaded_file($_FILES["pix"]["tmp_name"] ,$renameImg);
            move_uploaded_file($_FILES["pix"]["tmp_name"] ,$renameImg2);
    }
        
    }

    $update = EDITING::update_pix ($destination,$formno);

    ?>
    <script>
        alert('Update Successfull!!');
        // window.location.href='dashboard.php?type=show_details';
    </script>
    <?php //}

}


if(isset($_POST['update1'])!="")
{
   echo  $surname=$_POST['surname'];
   echo  $othername = $_POST['othername'];
    $dept=$_POST['department'];
    $lev = $_POST['level'];
   echo  $acc_id = $_SESSION['acc_id'];

    $update1 = EDITING::update1 ($surname,$othername,$acc_id);

    ?>
    <script>
        alert('Update1 Successfull!!');
        // window.location.href='dashboard.php?type=show_details';
    </script>
    <?php //}

}


if(isset($_POST['update2'])!="")
{
    // $formno = $_SESSION['formno'];
    $religion=$_POST['reli'];
    $status = $_POST['matsta'];
    $phone=$_POST['phone'];
   // $type = $_POST['type'];    
    $sex = $_POST['sex'];
    $state = $_POST['state'];
    
    $nat=$_POST['nat'];
    $dob = $_POST['dob'];
    $lga=$_POST['lga'];
    $home = $_POST['home']; 
   

    $update2 = EDITING::update2($table, $nat,$dob,$state,$lga,$home,$sex,$religion,$status,$phone,$formno);

    ?>
    <script>
        alert('Update2 Successfull!!');
        // window.location.href='dashboard.php?type=show_details';
    </script>
<?php 

}


if(isset($_POST['update3'])!="")
{
    
    $examno=$_POST['examno'];
  
   echo "Exam Year: ". $exam_year1=$_POST['examyear'];
    $examno2=$_POST['examno2'];
   
    $exam_year2 = $_POST['examyear2'];
    $sb1 = $_POST['sb1'];
    $grd1 = $_POST['grd1'];
    $sb2 = $_POST['sb2'];    
    $grd2 = $_POST['grd2'];
    $sb3 = $_POST['sb3'];
    $grd3 = $_POST['grd3']; 
    $sb4 = $_POST['sb4'];   
    $grd4 = $_POST['grd4'];
    $sb5 = $_POST['sb5'];
    $grd5 = $_POST['grd5'];
   
    $update3 = EDITING::update3($examno,$exam_year1,$examno2,$exam_year2,$sb1,$grd1,$sb2,$grd2,$sb3,$grd3,$sb4,$grd4,$sb5,$grd5,$acc_id)


    ?>
    <script>
        alert('Update3 Successfull!!');
        // window.location.href='dashboard.php?type=show_details';
    </script>
<?php 

}


if(isset($_POST['update4'])!="")
{
    
    $jregno=$_POST['jregno'];
  
   
  
    $jscore=$_POST['jscore'];
     $jinstitution=$_POST['jinstitution'];
   
    
    $update4 = EDITING::update4($jregno,$jscore,$jinstitution,$acc_id);

    ?>
    <script>
        alert('Update4 Successfull!!');
        // window.location.href='dashboard.php?type=show_details';
    </script>
<?php 

}


if(isset($_POST['update5'])!="")
{
    
    $institution=$_POST['institution'];
    $grag = $_POST['grag'];
    $gragD=$_POST['gragD'];
    


    $update5 = EDITING::update5($institution, $grag, $gragD, $acc_id);
    ?>
    <script>
        alert('Update5 Successfull!!');
        // window.location.href='dashboard.php?type=show_details';
    </script>
<?php 

}



if(isset($_POST['update6'])!="")
{
    
   $company=$_POST['itcompany'];
  
    $dstarted=$_POST['dstarted'];
    $dcompleted = $_POST['dcompleted'];

    $update6 = EDITING:: update6($company, $dstarted, $dcompleted, $acc_id);

    ?>
    <script>
        alert('Update6 Successfull!!');
        // window.location.href='dashboard.php?type=show_details';
    </script>
<?php


}
$updateBU = EDITING::updateBU($date,$user,$formno)
?>


