<?php
namespace App\Controllers;
SESSION_START();
use \Core\View;
use \Core\Inputs;
use \Core\Userlog;
use \Core\Menu;
use \Core\Form;
use App\Models\Homem;
use App\Email\Emails;
class Head extends \Core\Controller
{
    public static function feebreakup()
    {
        
    }
    public static function allotstdprofeebulk()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6)
        {
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4">
                            </div>
                            <div class="col-lg-4"> 
                                <form action="/Accounts/saveallotstdprofeebulk" method="POST" enctype="multipart/form-data">                                      
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <section class="box" style="margin-top: 30px;">
                                                <header class="panel_header">
                                                    <h5 class="title pull-left">Bulk Fee Collection Entry by Unique ID</h5>
                                                </header>
                                                <div class="content-body">    
                                                    <div class="row">
                                                        <div class="col-lg-12">
                                                            <div class="form-group">                                      
                                                                <input type="file" name="file" id="file" class="form-control" placeholder="Category Name">
                                                            </div>
                                                        </div>                              
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-lg-12">
                                                            <div class="form-group">   
                                                                <input type="hidden" name="type" id="type" class="form-control" value="bulk" placeholder="Type">                                         
                                                                <a href="/hindu/formats/stdnt_fee_collectiobyid_format.csv">Click Here to Download Uploading Format</a>
                                                            </div>
                                                        </div>                              
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-md-12">  
                                                            <div class="form-group">
                                                                <button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>                        
                                            </section>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getusername",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            document.getElementById("name").value = d;
                        }
                    });
                }
            </script>';
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
    private static function css()
    {
        $css = 
        '<!DOCTYPE html>
        <html lang="en">
        <head>
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
            <title>Hindu College of Engineering & Technology || Guntur</title>
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
            <title>Hindu College of Engineering & Technology || Guntur</title>
            <link rel="stylesheet" href="https://assets.hinduengg.com/hindu/assets/css/bootstrap.min.css">
            <link rel="stylesheet" href="https://assets.hinduengg.com/hindu/assets/css/style.css">
            <link rel="stylesheet" href="https://assets.hinduengg.com/hindu/assets/sweetalert2/dist/sweetalert2.min.css" >
            <style>
                @media print
                {
                    body * {
                        visibility: hidden;
                    }
                    .print-this, .print-this * {
                        visibility: visible;
                    }
                }
            </style>
            <script>
                function exportTableToExcel(tableID, filename = "")
                {
                    var downloadLink;
                    var dataType = "application/vnd.ms-excel";
                    var tableSelect = document.getElementById(tableID);
                    var tableHTML = tableSelect.outerHTML.replace(/ /g, "%20");
                    
                    // Specify file name
                    filename = filename?filename+".xls":"excel_data.xls";
                    
                    // Create download link element
                    downloadLink = document.createElement("a");
                    
                    document.body.appendChild(downloadLink);
                    
                    if(navigator.msSaveOrOpenBlob){
                        var blob = new Blob(["\ufeff", tableHTML], {
                            type: dataType
                        });
                        navigator.msSaveOrOpenBlob( blob, filename);
                    }else{
                        // Create a link to the file
                        downloadLink.href = "data:" + dataType + ", " + tableHTML;
                    
                        // Setting the file name
                        downloadLink.download = filename;
                        
                        //triggering the function
                        downloadLink.click();
                    }
                }
            </script>
        </head>';
        return $css;  
    }
    private static function script()
    {
        $script =
                '
                <div class="footer navbar-fixed-bottom text-center">        
                    <span class="text-muted text-center">Copyright &#169 2020. Hindu College of Engineering & Technology, Guntur</span>
                </div>
                <script src="https://assets.hinduengg.com/hindu/assets/word/jquery.min.js" ></script>
                <script src="https://assets.hinduengg.com/hindu/assets/js/bootstrap.min.js" ></script>
                <script src="https://assets.hinduengg.com/hindu/assets/vendor/sweetalert2/dist/sweetalert2.min.js" ></script>';
        return $script;  
    }
}