<?php
namespace App\Controllers;
use \Core\View;
use \Core\Inputs;
use \Core\Userlog;
use \Core\Menu;
use \Core\Form;
use App\Models\Homem;
use App\Email\Emails;
use App\Controllers\Menus;
class Extra extends \Core\Controller
{
    public static function feemode($id)
    {
        if($id == 1)
        {
            return "cash";
        }
        else if($id==2)
        {
            return "Bank Challan";
        }
        else if($id==3)
        {
            return "Online";
        }
        else if($id==4)
        {
            return "Scholarship";
        }
        else if($id==5)
        {
            return "Concession";
        }
        else if($id==6)
        {
            return "No Receipt ";
        }
        else
        {
            return "Payment Gateway";
        }
    }
    public static function course($id)
    {
        if($id != '')
        {
            if($_SESSION['org_id'] == 1)
            {
                if($id == 1)
                {
                    return 'B.Sc.';
                }
                if($id == 2)
                {
                    return 'B.Com.';
                }
                if($id == 3)
                {
                    return 'B.A.';
                }
                if($id == 4)
                {
                    return 'Inter';
                }
                if($id == 5)
                {
                    return 'M.Sc.';
                }
                if($id == 6)
                {
                    return 'BBA';
                }
                if($id == 7)
                {
                    return 'BCA';
                }
            }
            if($_SESSION['org_id'] == 2)
            {
                if($id == 1)
                {
                    return 'B.Sc.';
                }
                if($id == 2)
                {
                    return 'M.Sc.';
                }
                if($id == 3)
                {
                    return 'M.Sc. (Vocational)';
                }
            }
            if($_SESSION['org_id'] == 3)
            {
                if($id == 1)
                {
                    return 'Diploma';
                }
                if($id == 2)
                {
                    return 'B.Tech.';
                }
            }
            if($_SESSION['org_id'] == 4)
            {
                if($id == 1)
                {
                    return 'MCA';
                }
                if($id == 2)
                {
                    return 'M.Com';
                }
            }
            if($_SESSION['org_id'] == 5)
            {
                if($id == 1)
                {
                    return 'MBA';
                }
            }
            if($_SESSION['org_id'] == 6)
            {
                if($id == 1)
                {
                    return 'M.Com';
                }
            }
        }
    }
    public static function dept($id)
    {
        if($id != '')
        {
            if($_SESSION['org_id'] == 1)
            {
                if($id == 1)
                {
                    return 'MPCS';
                }
                if($id == 2)
                {
                    return 'MSCS';
                }
                if($id == 3)
                {
                    return 'MECS';
                }
                if($id == 4)
                {
                    return 'General';
                }
                if($id == 5)
                {
                    return 'Computers';
                }
                if($id == 6)
                {
                    return 'MPC';
                }
                if($id == 7)
                {
                    return 'BZC';
                }
                if($id == 8)
                {
                    return 'GPC';
                }
                if($id == 9)
                {
                    return 'MiBC';
                }
                if($id == 10)
                {
                    return 'BiMC';
                }
                if($id == 11)
                {
                    return 'HS';
                }
                if($id == 12)
                {
                    return 'BS';
                }
                if($id == 13)
                {
                    return 'HEP';
                }
                if($id == 14)
                {
                    return 'EHP';
                }
                if($id == 15)
                {
                    return 'MES';
                }
                if($id == 16)
                {
                    return 'EPC';
                }
                if($id == 17)
                {
                    return 'MPC';
                }
                if($id == 18)
                {
                    return 'BiPC';
                }
                if($id == 19)
                {
                    return 'MEC';
                }
                if($id == 20)
                {
                    return 'CEC';
                }
                if($id == 21)
                {
                    return 'ABC';
                }
                if($id == 22)
                {
                    return 'HBZ';
                }
                if($id == 23)
                {
                    return 'FTM';
                }
                if($id == 24)
                {
                    return 'PHY';
                }if($id == 25)
                {
                    return 'CHEM';
                }
                if($id == 26)
                {
                    return 'BOT';
                }
                if($id == 27)
                {
                    return 'FOOD';
                }
                if($id == 28)
                {
                    return 'HORT';
                }
                if($id == 29)
                {
                    return 'Gen(Un)';
                }
                if($id == 30)
                {
                    return 'Soil';
                }
                if($id == 31)
                {
                    return 'PGDip';
                }
                if($id == 32)
                {
                    return 'CSDS';
                }
                if($id == 33)
                {
                    return 'HEC';
                }
                if($id == 34)
                {
                    return 'Economics';
                }
                if($id == 35)
                {
                    return 'Maths';
                }
                if($id == 36)
                {
                    return 'Political';
                }
                if($id == 37)
                {
                    return 'SEnglish';
                }
                if($id == 38)
                {
                    return 'Stat';
                }
                if($id == 39)
                {
                    return 'Bot';
                }
                if($id == 40)
                {
                    return 'Chemi';
                }
                if($id == 41)
                {
                    return 'Geology';
                }
                if($id == 42)
                {
                    return 'Math';
                }
                if($id == 43)
                {
                    return 'Phy';
                }
                if($id == 44)
                {
                    return 'Zoology';
                }
                if($id == 45)
                {
                    return 'BCA';
                }
                if($id == 46)
                {
                    return 'BBA';
                }
                if($id == 47)
                {
                    return 'History';
                }
                if($id == 48)
                {
                    return 'Political';
                }
                if($id == 49)
                {
                    return 'Biotech';
                }
                if($id == 50)
                {
                    return 'BioMed';
                }
                if($id == 51)
                {
                    return 'MLT';
                }
                if($id == 52)
                {
                    return 'Elect';
                }
                if($id == 53)
                {
                    return 'Food';
                }
                if($id == 54)
                {
                    return 'Aqua';
                }
                if($id == 55)
                {
                    return 'Microbi';
                }
                if($id == 56)
                {
                    return 'Homes';
                }
                if($id == 57)
                {
                    return 'Nutrition';
                }
                if($id == 58)
                {
                    return 'DataSci';
                }
                if($id == 59)
                {
                    return 'AI';
                }
                if($id == 60)
                {
                    return 'Multi';
                }
                if($id == 61)
                {
                    return 'Comp';
                }
                if($id == 62)
                {
                    return 'Indchem';
                }
            }
            if($_SESSION['org_id'] == 2)
            {
                if($id == 1)
                {
                    return 'Agriculture';
                }
                if($id == 2)
                {
                    return 'Horticulture';
                }
                if($id == 3)
                {
                    return 'Food Technology';
                }
                if($id == 4)
                {
                    return 'Physics';
                }
                if($id == 5)
                {
                    return 'Chemistry';
                }
                if($id == 6)
                {
                    return 'Botany';
                }
                if($id == 7)
                {
                    return 'Food Processing (Vocational)';
                }
                if($id == 8)
                {
                    return 'Horticultural Landscaping (Vocational)';
                }
            }
            if($_SESSION['org_id'] == 3)
            {
                if($id == 1)
                {
                    return 'Civil Engineering';
                }
                else if($id == 2)
                {
                    return 'Electrical & Electronics Engineering';
                }
                else if($id == 3)
                {
                    return 'Mechanical Engineering';
                }
                else if($id == 4)
                {
                    return 'Electronics & Communication Engineering';
                }
                else if($id == 5)
                {
                    return 'Computer Science Engineering';
                }
                else if($id == 6)
                {
                    return 'S&H';
                }
                else if($id == 7)
                {
                    return 'Wed Design';
                }
                else if($id == 8)
                {
                    return 'AI&ML';
                }
                else if($id == 9)
                {
                    return 'CSE - Artificial Intelligence and Data Science';
                }
                else if($id == 10)
                {
                    return 'CSE - Cyber Security';
                }
                else
                {
                    return '';
                }
            }
            if($_SESSION['org_id'] == 4)
            {
                if($id == 1)
                {
                    return 'Computers';
                }
                if($id == 2)
                {
                    return 'Commerce';
                }
            }
            if($_SESSION['org_id'] == 5)
            {
                if($id == 1)
                {
                    return 'MBA';
                }
            }
            if($_SESSION['org_id'] == 6)
            {
                if($id == 1)
                {
                    return 'M.Com';
                }
            }
        }
    }
    public static function feetype($id)
    {
        if($id != '')
        {
            if($_SESSION['org_id'] == 1)
            {
                if($id == 1)
                {
                    return 'Tution Fee';
                }
                if($id == 2)
                {
                    return 'Add-on Course Fee';
                }
            }
            else if($_SESSION['org_id'] == 4)
            {
                if($id == 1)
                {
                    return 'Tution Fee';
                }
                if($id == 5)
                {
                    return 'Training & Project Fee';
                }
            }
            else if($_SESSION['org_id'] == 5)
            {
                if($id == 1)
                {
                    return 'Tution Fee';
                }
                if($id == 2)
                {
                    return 'Processing Fee';
                }
                if($id == 3)
                {
                    return 'TC Fee';
                }
                if($id == 4)
                {
                    return 'Library Fee';
                }
                if($id == 5)
                {
                    return 'ANU Registration Fee';
                }
                if($id == 6)
                {
                    return 'Hospital MOU Fee';
                }
                if($id == 7)
                {
                    return 'T&P, MAC FEE';
                }
                if($id == 8)
                {
                    return 'Condonation Fee';
                }
                if($id == 9)
                {
                    return '';
                }
            }
            else if($_SESSION['org_id'] == 3)
            {
                if($id == 1)
                {
                    return 'Tution Fee';
                }
                if($id == 2)
                {
                    return 'Bus Fee';
                }
                if($id == 3)
                {
                    return 'Training & Placement Fee';
                }
                if($id == 4)
                {
                    return 'Workshop Fee';
                }
                if($id == 5)
                {
                    return 'JNTUK Convocation Fee';
                }

            }
            else
            {
                if($id == 1)
                {
                    return 'Tution Fee';
                }
                if($id == 2)
                {
                    return 'Bus Fee';
                }
                if($id == 3)
                {
                    return 'TC Fee';
                }
                if($id == 4)
                {
                    return 'Library Fee';
                }
            }
        }
    }
    public static function datem($id)
    {
        $data = explode('-', $id);
        $final = $data[2].'-'.$data[1].'-'.$data[0];
        return $final;
    }
    public static function squota($id, $course)
    {
        if($id != '')
        {
            if($id == 'M' && $course==1)
            {
                return 'SPOT Admission';
            }
            if($id == 'M' && $course==2)
            {
                return 'Management Quota';
            }
            if($id == 'C' && ($course==1 || $course==2))
            {
                return 'Convenor Quota';
            }
            if($id == 'S')
            {
                return 'Spot Admission';
            }
        }
    }
    public static function nyear($id)
    {
        if($id != '')
        {
            if($id == 1)
            {
                return 'First Year';
            }
            if($id == 2)
            {
                return 'Second Year';
            }
            if($id == 3)
            {
                return 'Third Year';
            }
            if($id == 4)
            {
                return 'Fourth Year';
            }
            if($id == 5)
            {
                return 'Fifth Year';
            }
        }
    }
    public static function numtotext($number)
    {
        $decimal = round($number - ($no = floor($number)), 2) * 100;
        $hundred = null;
        $digits_length = strlen($no);
        $i = 0;
        $str = array();
        $words = array(0 => '', 1 => 'One', 2 => 'Two',
            3 => 'Three', 4 => 'Four', 5 => 'Five', 6 => 'Six',
            7 => 'Seven', 8 => 'Eight', 9 => 'Nine',
            10 => 'Ten', 11 => 'Eleven', 12 => 'Twelve',
            13 => 'Thirteen', 14 => 'Fourteen', 15 => 'Fifteen',
            16 => 'Sixteen', 17 => 'Seventeen', 18 => 'Eighteen',
            19 => 'Nineteen', 20 => 'Twenty', 30 => 'Thirty',
            40 => 'Forty', 50 => 'Fifty', 60 => 'Sixty',
            70 => 'Seventy', 80 => 'Eighty', 90 => 'Ninety');
        $digits = array('', 'Hundred','Thousand','Lakh', 'Crore');
        while( $i < $digits_length ) {
            $divider = ($i == 2) ? 10 : 100;
            $number = floor($no % $divider);
            $no = floor($no / $divider);
            $i += $divider == 10 ? 1 : 2;
            if ($number) {
                $plural = (($counter = count($str)) && $number > 9) ? 's' : null;
                $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
                $str [] = ($number < 21) ? $words[$number].' '. $digits[$counter]. $plural.' '.$hundred:$words[floor($number / 10) * 10].' '.$words[$number % 10]. ' '.$digits[$counter].$plural.' '.$hundred;
            } else $str[] = null;
        }
        $Rupees = implode('', array_reverse($str));
        $paise = ($decimal > 0) ? "." . ($words[$decimal / 10] . " " . $words[$decimal % 10]) . ' Paise' : '';
        return ($Rupees ? $Rupees . 'Rupees Only' : '') . $paise;
    }
    public static function feeaccount($course, $ftype)
    {
        if($_SESSION['org_id'] == 1)
        {
            if($course ==1 && $ftype==1)
            {
                return 'XXX1017672-UBI';
            }
            if($course ==2 && $ftype==1)
            {
                return 'XXX1017672-UBI';
            }
            if(($course ==3 || $course ==6 || $course ==7) && $ftype==1)
            {
                return 'XXX1017672-UBI';
            }
            if($course ==1 && $ftype==2)
            {
                return '027950-BOB';
            }
            if($course ==2 && $ftype==2)
            {
                return '027950-BOB';
            }
            if(($course ==3 || $course ==6 || $course ==7) && $ftype==2)
            {
                return '027950-BOB';
            }
            if($course ==4 && $ftype==1)
            {
                return '029677-UBI';
            }
            if($course ==4 && $ftype==2)
            {
                return '027950-BOB';
            }
            if($course ==5 && $ftype==1)
            {
                return '000376-UBI';
            }
            if($course ==5 && $ftype==2)
            {
                return '027950-BOB';
            }
        }
        if($_SESSION['org_id'] != 1)
        {
            return 'Tution Fee';
        }
    }
    public static function examfeeaccount($course, $ftype)
    {
        if($_SESSION['org_id'] == 1)
        {
            if($course <=8 && $course!=4)
            {
                return 'XXX1014143-UBI';
            }

        }
    }
    public static function examtype($id)
    {
        if($id == "R")
        {
            return "Regular";
        }
        if($id == "S")
        {
            return "Supply";
        }
        if($id == "RE")
        {
            return "Revaluation";
        }
        if($id == "RC")
        {
            return "Recounting";
        }
        if($id == "C")
        {
            return "Challenging Evaluation";
        }
        if($id == "SS")
        {
            return "Super-Supply";
        }
    }
    public static function romanyear($id)
    {
        if($id == 1)
        {
            return 'I';
        }
        if($id == 2)
        {
            return 'II';
        }
        if($id == 3)
        {
            return 'III';
        }
        if($id == 4)
        {
            return 'IV';
        }
    }
    public static function monthlyfeetype($id)
    {
        if($_SESSION['org_id'] == 1)
        {
            if($id == 1)
            {
                return 'Bus Fee';
            }
        }
        if($_SESSION['org_id'] == 3)
        {
            if($id == 1)
            {
                return 'Bus Fee';
            }
        }
        if($_SESSION['org_id'] == 4)
        {
            if($id == 1)
            {
                return 'Bus Fee';
            }
        }
    }
    public static function additionalfeetype($id)
    {
        if($_SESSION['org_id'] == 1)
        {
            if($id == 3)
            {
                return 'PCB Designing Course';
            }
            if($id == 4)
            {
                return 'Embedded Systems & IoT';
            }
            if($id == 5)
            {
                return 'Coaching Fee';
            }
            if($id == 2)
            {
                return 'TC Fee';
            }
            if($id == 1)
            {
                return 'Admission Fee';
            }
            
        }
        if($_SESSION['org_id'] == 3)
        {
            if($id == 1)
            {
                return 'PCB Designing Course';
            }
            if($id == 2)
            {
                return 'Embedded Systems & IoT';
            }
            if($id == 3)
            {
                return 'Stationary Fee';
            }
            if($id == 4)
            {
                return 'Record Fee';
            }
            if($id == 5)
            {
                return 'ID Card Fee';
            }
            if($id == 6)
            {
                return 'TC Fee';
            }
            if($id == 7)
            {
                return 'University Common Services Fee';
            }
            if($id == 8)
            {
                return 'Processing Fee';
            }
            if($id == 9)
            {
                return 'Study Material & Stationary Fee';
            }
            if($id == 10)
            {
                return 'Workshop Fee';
            }
            if($id == 11)
            {
                return 'Miscellaneous Fee';
            }
            if($id == 12)
            {
                return 'ID Card Tag Fee';
            }
            if($id == 13)
            {
                return 'Project Fee';
            }
            if($id == 14)
            {
                return 'Internship Fee';
            }
            if($id == 15)
            {
                return 'Library Due';
            }
        }
        if($_SESSION['org_id'] == 4)
        {
            if($id == 1)
            {
                return 'Web Development';
            }
            if($id == 2)
            {
                return 'Workshop Fee';
            }
            if($id == 3)
            {
                return 'Miscellaneous Fee';
            }
            
        }
        if($_SESSION['org_id'] == 5)
        {
            if($id == 1)
            {
                return 'EXAM & PROJECT FEE';
            }
            if($id == 2)
            {
                return 'Certification course fee';
            }
            if($id == 3)
            {
                return 'skill development program fee';
            }
            if($id == 4)
            {
                return 'Viva Voice Fee';
            }
        }
        if($_SESSION['org_id'] == 6)
        {
            if($id == 1)
            {
                return 'EXAM & PROJECT FEE';
            }
        }
    }
    public static function additionalfeefeedivisonforreports($data)
    {
        $data = json_decode($data, true);
        for($i=0; $i<sizeof($data); $i++)
        {
            $subdata = json_decode($data[$i]['fees'], true);
            for($j=1; $j<=sizeof($subdata); $j++)
            {
                $data[$i][$j] = $subdata[$j];
            }
        }
        return json_encode($data);
        
    }
    public static function additionalfeefeedivisonforreportsbysinlefeeid($data, $type)
    {
        $data = json_decode($data, true);
        $type1 = $type;
        $type = 'type'.$type;
        for($i=0; $i<sizeof($data); $i++)
        {
            if(isset($data[$i][$type1]))
            {
                $data[$i][$type] = $data[$i][$type1];
            }
            else
            {
                $data[$i][$type] = 0;
            }
        }
        return json_encode($data);
    }
    // SMS SENDING CODE START
    public static function smscredits()
    {
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => 'https://api.mylogin.co.in/api/v2/Balance?ApiKey=9FYw45bZk/traX4phb0DCEb9KFiQkNOD8suGLWVgzK8=&ClientId=38ee5f8c-f4e9-42a3-b671-9a8f02121553',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
          CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json'
          ),
        ));
        
        $response = curl_exec($curl);
        curl_close($curl);
        $a = json_decode($response, true);
        echo $a['Data'][0]['Credits'];
    }
    public static function approvedsenderids()
    {
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => 'https://api.mylogin.co.in/api/v2/SenderId?ApiKey=9FYw45bZk/traX4phb0DCEb9KFiQkNOD8suGLWVgzK8=&ClientId=38ee5f8c-f4e9-42a3-b671-9a8f02121553',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
          CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json'
          ),
        ));
        
        $response = curl_exec($curl);
        
        curl_close($curl);
        echo $response;
    }
    public static function approvedtemplates()
    {
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => 'https://api.mylogin.co.in/api/v2/Template?ApiKey=9FYw45bZk/traX4phb0DCEb9KFiQkNOD8suGLWVgzK8=&ClientId=38ee5f8c-f4e9-42a3-b671-9a8f02121553',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
        ));
        
        $response = curl_exec($curl);
        
        curl_close($curl);
        echo $response;
    }
    public static function sendsms()
    {
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => 'https://api.mylogin.co.in/api/v2/SendSMS?ApiKey=9FYw45bZk/traX4phb0DCEb9KFiQkNOD8suGLWVgzK8=&ClientId=38ee5f8c-f4e9-42a3-b671-9a8f02121553&SenderId=HNDGNT&Message=Dear%20kRISHNARJUNA%20RAO,%20we%20received%20an%20amount%20of%20Rs.5000%20on%2007-07-2021%20as%20tuition%20fee%20from%20you.%20Please%20note%20down%20receipt%20number%202017-1%20for%20future%20reference-HCHSC&MobileNumbers=919494470239&Is_Unicode=false&Is_Flash=false',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
          CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json'
          ),
        ));
        
        $response = curl_exec($curl);
        
        curl_close($curl);
        echo $response;
    }
    public static function sendsmsactive($name, $amount, $date, $receiptno, $mobile)
    {
        $name = static::shortname($name);
        $amount = $amount;
        $date = $date;
        $receiptno = $receiptno;
        $mobile = $mobile;
        $input = 'Dear '.$name.', we received an amount of Rs.'.$amount.' on '.$date.' as tuition fee from you. Please note down receipt number '.$receiptno.' for future reference-HCHSC';
        $url = 'https://api.mylogin.co.in/api/v2/SendSMS?ApiKey=9FYw45bZk/traX4phb0DCEb9KFiQkNOD8suGLWVgzK8=&ClientId=38ee5f8c-f4e9-42a3-b671-9a8f02121553&SenderId=HNDGNT&Message='.rawurlencode($input).'&MobileNumbers=91'.$mobile.'&Is_Unicode=false&Is_Flash=false';
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => $url,
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
          CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json'
          ),
        ));
        
        $response = curl_exec($curl);
        
        curl_close($curl);
        // echo $response;
        return 1;
    }
    public static function shortname($name)
    {
        $size =  strlen($name);
        if($size<50)
        {
            return $name;
        }
        else
        {
            return 'Student';
        }
        
    }
    public static function testsms()
    {
        echo static::sendsmsactive('KRISHNARJUNA SUDA', '1000', '08-08-2011', '2021', '9494470239');
    }
    // SMS SENDING CODE END
    public static function month($id)
    {
        if($id != '')
        {
            if($id == 1)
            {
                return 'Jan';
            }
            if($id == 2)
            {
                return 'Feb';
            }
            if($id == 3)
            {
                return 'Mar';
            }
            if($id == 4)
            {
                return 'Apr';
            }
            if($id == 5)
            {
                return 'May';
            }
            if($id == 6)
            {
                return 'June';
            }
            if($id == 7)
            {
                return 'July';
            }
            if($id == 8)
            {
                return 'Aug';
            }
            if($id == 9)
            {
                return 'Sept';
            }
            if($id == 10)
            {
                return 'Oct';
            }
            if($id == 11)
            {
                return 'Nov';
            }
            if($id == 12)
            {
                return 'Dec';
            }
        }
    }
    public static function resulttype($id, $count)
    {
        if($_SESSION['org_id'] == 3)
        {
            if($id == 1 && $count == 1)
            {
                return 'REG';
            }
            else if($id == 1 && $count > 1)
            {
                return 'SUP';
            }
            else if($id == 2)
            {
                return 'REV';
            }
            else
            {
                return 'REG/SUP';
            }
        }
    }
    public static function resultstatus($id, $course)
    {
        if($_SESSION['org_id'] == 3)
        {
            if($id == 1 && $course == 2)
            {
                return 'FAIL';
            }
            if($id == 0 && $course == 2)
            {
                return 'PASS';
            }
        }
    }
    public static function yearandsem($year, $sem)
    {
        if($_SESSION['org_id'] == 3)
        {
            if($year == 1 && $sem == 1)
            {
                return 'First Year - First Sem';
            }
            if($year == 1 && $sem == 2)
            {
                return 'First Year - Second Sem';
            }
            if($year == 2 && $sem == 1)
            {
                return 'Second Year - First Sem';
            }
            if($year == 2 && $sem == 2)
            {
                return 'Second Year - Second Sem';
            }
            if($year == 3 && $sem == 1)
            {
                return 'Third Year - First Sem';
            }
            if($year == 3 && $sem == 2)
            {
                return 'Third Year - Second Sem';
            }
        }
    }
    
    /* Modify date started*/
    public static function dtest() // testing for date conversion
    {
        $date = '34/35/36';
        echo static::datemodify($date);
    }
    public static function datemodify($date)
    {
        $ar = static::datesplit($date);
        if(is_array($ar))
        {
            return static::datesort($ar);
        }
    }
    public static function datesplit($date)
    {
        if(isset($date))
        {
            $d = explode("-", $date);
            if(is_array($d))
            {
                if(sizeof($d) == 3)
                {
                    return $d;
                }
                else
                {
                    $e = explode("/", $date);
                    if(is_array($e))
                    {
                        if(sizeof($e) == 3)
                        {
                            return $e;
                        }
                        else
                        {
                            $f = explode(".", $date);
                            if(is_array($f))
                            {
                                if(sizeof($f) == 3)
                                {
                                    return $f;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    public static function datesort($a)
    {
        if(strlen($a[0]) == 4)
        {
            return $a[0].'-'.static::appendzeromonth($a[1]).'-'.static::appendzerodate($a[2]);
        }
        if(strlen($a[2]) == 4)
        {
            return $a[2].'-'.static::appendzeromonth($a[1]).'-'.static::appendzerodate($a[0]);
        }
        if(strlen($a[2]) <= 2 && strlen($a[1]) <= 2 && strlen($a[0]) <= 2)
        {
            return static::apendyearfront($a[2]).'-'.static::appendzeromonth($a[1]).'-'.static::appendzerodate($a[0]);
        }
    }
    public static function appendzeromonth($m)
    {
        if($m >=1 && $m <=12)
        {
            if(strlen($m) == 2)
            {
                return $m;
            }
            else
            {
                return '0'.$m;
            }
        }
        else
        {
            return '01';
        }
    }
    public static function appendzerodate($m)
    {
        if($m >=1 && $m <=31)
        {
            if(strlen($m) == 2)
            {
                return $m;
            }
            else
            {
                return '0'.$m;
            }
        }
        else
        {
            return '01';
        }
    }
    public static function apendyearfront($a)
    {
        if(strlen($a) == 2)
        {
            if(date('y') >=$a)
            {
                return '20'.$a;
            }
            else
            {
                return date('Y');
            }
        }
    }
    /* Modify date Ended*/
    
    
}