<?php
session_start();
//var_dump($_FILES);
//echo $_GET["appid"];
//die();
  // $file=$_FILES["notefiles"]["tmp_name"];
include('../db_con.php');
include('methodlist.php');
$uid=get_session_user_id($con);

$sql = "insert into app_notes_table (vnotes_id, vnotes_datetime, notes_desc, notes_file, app_id, user_id) 
values ('', '$now', '$_POST[notedesc]', '', '$_POST[appid]', '$uid')";                              
//                 $filelist=$filelist."#".$file." ";

                //echo $sql;
// if (isset($_FILES['notefiles']) && !empty($_FILES['notefiles'])) {
    
//     //$no_files = count($_FILES["notefiles"]['name']);
//     //$filelist="";
//     $file=$_FILES["notefiles"]["name"];


 $result = mysqli_query($con,$sql);
   //var_dump($_POST);

//     $result0 = mysqli_query($con,"SELECT v_uid FROM applicant_table WHERE app_id='".$_GET['appid']."'");
//     $row0 = mysqli_fetch_array($result0);
//     $uid=$row0["v_uid"];
    
//     if($_GET["dtype"]==1) {
        
//         $folder="uploads/document/";
//     }

//     if($_GET["dtype"]==2) {
        
//         $folder="uploads/reports/";
//     }

//     for ($i = 0; $i < $no_files; $i++) {
        
//         if ($_FILES["files"]["error"][$i] > 0) {
//             echo "Error: " . $_FILES["files"]["error"][$i] . "<br>";
//         } 
//         else {

            
//             $file=$_FILES["files"]["name"][$i];
//             $file = $uid."-".str_replace(' ', '_', $file);
//             $allowed =  array('jpg','jpeg','pdf','doc','docx');           
//             $ext = pathinfo($file, PATHINFO_EXTENSION);
            
//             if(!in_array($ext,$allowed)){
//                 echo "Unsupported filetype uploaded.\n";
                
//             }

//             elseif (filesize($_FILES["files"]["tmp_name"][$i]) > 500000) {
//                 echo "Sorry, your file is too large.\n";
//                 //$uploadOk = 0;
//                 }

//             elseif (file_exists($folder . $file)) {
//                 echo 'File already exists : '. $file;
//             }

//             else {
                                
//                 move_uploaded_file($_FILES["files"]["tmp_name"][$i], $folder.$file);

//                 $sql = "insert into ver_notes_table (vnotes_id, vnotes_datetime, notes_desc, notes_file, app_id) values ('', '$now', '$_POST[notedesc]', '$file', '$_GET[appid]')";                              
// //                 $filelist=$filelist."#".$file." ";

//                 echo $sql;
//                 var_dump($sql) or die();

//                 exit();
// //                                     //echo $sql;
//                  $result = mysqli_query($con,$sql);
                
//                 if($i==$no_files-1){
//                     echo "<span style='color:green;'>All Files successfully uploaded</span> <button class='btn btn-primary btn-xs' onclick='reloadFunction()''>View files</button>";
                    
//                     include 'methodlist.php';
//                     session_start();

//                     if($_GET["dtype"]==1) $doctype="Document";
//                     if($_GET["dtype"]==2) $doctype="Report";

//                     ver_update_history('<b>'.$no_files.' '.$doctype.' </b>('.$filelist.') have been uploaded by', $_GET["appid"]);


//                 }
//             }
//         }
//     }
// } 
// else {
//     echo '<span style=color:red;>Please choose at least one file</span>';
// }
    
/* 
 * End of script
 */
?>