IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/app/Http/Controllers/School/Exam/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/app/Http/Controllers/School/Exam/ExamPrintMasterController.php

<?php

namespace App\Http\Controllers\School\Exam;

use Illuminate\Http\Request;
use App\Http\Controllers\School\SchoolController;
use DB;
use Auth;
use Session;
use App\MarksheetRoyal;
use PDF;
use App\Imports\MarksImport;
use Maatwebsite\Excel\Facades\Excel;

class ExamPrintMasterController extends SchoolController {

    /**
     * Display a listing of the resource.
     */
    public function index(Request $request) {
        $classes = ['' => '-- Select Class --'] + \App\ClassM::where('idSchool', '=', Auth::guard('school')->user()->idSchool)
                        ->orderBy('idClass')->get()->pluck('className', 'idClass')->toArray();
        $students = [];
        $subjects = [];  
        if($request->has('idClass') && in_array($request->get('idClass'),[232,233])){
            $subjects = ['ENGLISH','HINDI','MARATHI','MATHS','EVS'];
        }else if($request->has('idClass') && in_array($request->get('idClass'),[240,241])){
            $subjects = ['ENGLISH','HINDI','MATHS','SCIENCE','SOCIAL SCIENCE','I.T. (NSQF)','MARATHI'];
        } else if($request->has('idClass') && in_array($request->get('idClass'),[234,235,236,237,238,239])){
            $subjects = ['English','Hindi','Marathi','Mathematics','Science','Social Science','IT (Th + Pr)','V. E. / G. K.','Art Education'];
        }              
        if($request->has('sections') && is_array($request->sections) != null){
            $students = DB::table('students')
            ->join('classes', 'students.idClass', '=', 'classes.idClass')
            ->join('sections', 'students.idSection', '=', 'sections.idSection')
            ->where('students.idClass',$request->get('idClass'))
            ->whereIn('students.idSection',$request->get('sections'))->where('students.idSchool', '=', Auth::guard('school')->user()->idSchool)
            ->where('students.idFinancialYear',Session::get('idFinancialYear'))
            ->select('ecNo',DB::raw('CONCAT(firstName," ",COALESCE(middleName,"")," ",COALESCE(lastName,"")) as name'),'className','sectionName','idStudent')->get();
        }

        $tableParams = [];
        if($request->has('idClass') && in_array($request->get('idClass'),[232,233])){
            if($request->idType == "S")
            $tableParams = [
                'Evaluation 1 (20)','Evaluation 2 (20)','Evaluation 3 (20)','Evaluation 4 (20)','CYCLE 1','CYCLE 2','CYCLE 3','CYCLE 4','CYCLE 5','CYCLE 6','CYCLE 7','CYCLE 8'
            ];
            else{
                $fetchParam = DB::table('exam_subject_mapping')->where('idClass',$request->get('idClass'))->get();
                if($fetchParam != null){
                    $subjects = ['FIRST TERM','SECOND TERM'];
                    foreach($fetchParam as $params){
                        array_push($tableParams,$params->headerName.'('.$params->subjectName.')');
                    }
                }
                return view('schools.exams.print_exam_others1',compact('classes','subjects','students','tableParams'));
            }
            return view('schools.exams.print_exam_class1',compact('classes','subjects','students','tableParams'));
        }else if($request->has('idClass') && in_array($request->get('idClass'),[234,235,236,237,238,239])){
            if($request->idType == "S")
            $tableParams = [
                'Periodic Test 1 (40)','Periodic Test 1 (10)','Note Book (05)','Sub Enrichment (05)','Half Yearly Exam (80)','Periodic Test 2 (40)','Periodic Test 2 (10)','Note Book (05)','Sub Enrichment (05)','Half Yearly Exam (80)',
            ];
            else{
                $fetchParam = DB::table('exam_subject_mapping')->where('idClass',234)->get();
                if($fetchParam != null){
                    $subjects = ['Term - 1','Term - 2'];
                    foreach($fetchParam as $params){
                        array_push($tableParams,$params->headerName.'('.$params->subjectName.')');
                    }
                }
                return view('schools.exams.print_exam_others3',compact('classes','subjects','students','tableParams'));
            }
            return view('schools.exams.print_exam_class3',compact('classes','subjects','students','tableParams'));
        }else if($request->has('idClass') && in_array($request->get('idClass'),[240])){
            if($request->idType == "S")
            $tableParams = [
                'PT1 (40)','PT2 (40)','PT3 (40)','Weightage of PT (05)','Portfolio (05)','Multiple Assessment (05)','Subject Enrichment (05)','Annual Exam (80)'
            ];
            else{
                $fetchParam = DB::table('exam_subject_mapping')->where('idClass',240)->get();
                if($fetchParam != null){
                    $subjects = ['Grade'];
                    foreach($fetchParam as $params){
                        array_push($tableParams,$params->headerName.'('.$params->subjectName.')');
                    }
                }
                return view('schools.exams.print_exam_others3',compact('classes','subjects','students','tableParams'));
            }
            return view('schools.exams.print_exam_class3',compact('classes','subjects','students','tableParams'));
        }else if($request->has('idClass') && in_array($request->get('idClass'),[241])){
            if($request->idType == "S")
            $tableParams = [
                'PT1 (40)','PT2 (40)','Preboard 1 (80)','Preboard 2 (80)','Weightage of PT 1 (10)','Weightage of PT 2 (10)','Weightage of Preboard 1 (40)','Weightage of Preboard 2 (40)'
            ];
            else{
                $fetchParam = DB::table('exam_subject_mapping')->where('idClass',241)->get();
                if($fetchParam != null){
                    $subjects = ['Grade'];
                    foreach($fetchParam as $params){
                        array_push($tableParams,$params->headerName.'('.$params->subjectName.')');
                    }
                }
                return view('schools.exams.print_exam_others3',compact('classes','subjects','students','tableParams'));
            }
            return view('schools.exams.print_exam_class3',compact('classes','subjects','students','tableParams'));
        }

        return view('schools.exams.print_exam',compact('classes','subjects','students','tableParams'));              
    }

    public function uploadData(Request $request){
        $classes = ['' => '-- Select Class --'] + \App\ClassM::where('idSchool', '=', Auth::guard('school')->user()->idSchool)
                        ->orderBy('idClass')->get()->pluck('className', 'idClass')->toArray();
        return view('schools.exams.print_exam_upload',compact('classes'));
    }

    /**
     * Show the form for creating a new resource.
     */
    public function create(Request $request) {
        //
        $classes = ['' => '-- Select Class --'] + \App\ClassM::where('idSchool', '=', Auth::guard('school')->user()->idSchool)
                        ->orderBy('idClass')->get()->pluck('className', 'idClass')->toArray();
        $students = [];             
        if($request->has('sections') && is_array($request->sections) != null){
            $students = DB::table('students')
            ->join('classes', 'students.idClass', '=', 'classes.idClass')
            ->join('sections', 'students.idSection', '=', 'sections.idSection')
            ->where('students.idClass',$request->get('idClass'))
            ->whereIn('students.idSection',$request->get('sections'))->where('students.idSchool', '=', Auth::guard('school')->user()->idSchool)
            ->where('students.idFinancialYear',Session::get('idFinancialYear'))
            ->select('ecNo',DB::raw('CONCAT(firstName," ",COALESCE(middleName,"")," ",COALESCE(lastName,"")) as name'),'className','sectionName','idStudent','idFinancialYear','students.idClass')->get();
        }
        return view('schools.exams.show_exam',compact('classes','students'));   
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     * */
    public function store(Request $request) {
        ini_set('memory_limit', '512M');
        $request->validate([
            'idClass' => 'required',
            'file' => 'required|mimes:xlsx,csv',
        ]);
        if(MarksheetRoyal::orderBy('id','DESC')->first() != null)
        $id = MarksheetRoyal::orderBy('id','DESC')->first()->id + 1;
        else $id = 1;
        $data = [
            'idClass' => $request->idClass,
            'idType' => $request->idType,
            'idSchool' => Auth::guard('school')->user()->idSchool,
            'created_by' => Auth::guard('school')->user()->idSchoolUser,
            'idFinancialYear' => Session::get('idFinancialYear')
        ];
        Excel::import(new MarksImport( $data ,$id ), $request->file('file'));
        return redirect('/school/exam-print/master/create')->with('success', 'Marks imported successfully!');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id,Request $request) {
        ini_set('memory_limit', '512M');
        $roll = "";
        if($request->get('rollNo') != ""){
            $roll = $request->get('rollNo');
        }
        $school = \App\School::where('idSchool',Auth::guard('school')->user()->idSchool)->first();
        $students = DB::table('students')
            ->join('classes', 'students.idClass', '=', 'classes.idClass')
            ->join('sections', 'students.idSection', '=', 'sections.idSection')
            ->where('idStudent',$id)
            ->where('students.idFinancialYear',Session::get('idFinancialYear'))
            ->where('students.idSchool', '=', Auth::guard('school')->user()->idSchool)
            ->select('resAddress','resPincode','resCity','students.idClass','ecNo',DB::raw('CONCAT(firstName," ",COALESCE(middleName,"")," ",COALESCE(lastName,"")) as name'),'className','sectionName','idStudent','studentDob',DB::raw('CONCAT(father_fname," ",COALESCE(father_lname,"")) as father'),DB::raw('CONCAT(mother_fname," ",COALESCE(mother_lname,"")) as mother'),'contactPersonTel','contactPersonMobile')->first();
        $fy = \App\FinancialYear::where('idFinancialYear',Session::get('idFinancialYear'))->first();
        if(in_array($students->idClass,[232,233])){
            $pdf = PDF::loadView('schools.exams.royal_marksheet_print1', ['margin_top' => 20 ,'school' => $school,'students' => $students, 'fy' => $fy, 'roll' => $roll],[],[ 
            'title' => 'Certificate', 
            'format' => 'A4-L',
            'orientation' => 'L'
            ]);
            return $pdf->stream('marksheet.pdf');
        }else if(in_array($students->idClass,[234,235,236,237,238,239])){
            $pdf = PDF::loadView('schools.exams.royal_marksheet_print3', ['margin_top' => 20,'school' => $school,'students' => $students, 'fy' => $fy, 'roll' => $roll]);
            return $pdf->stream('marksheet.pdf');
        }else if(in_array($students->idClass,[240])){
            $pdf = PDF::loadView('schools.exams.royal_marksheet_print9', ['margin_top' => 20,'school' => $school,'students' => $students, 'fy' => $fy, 'roll' => $roll]);
            return $pdf->stream('marksheet.pdf');
        }else if(in_array($students->idClass,[241])){
            $pdf = PDF::loadView('schools.exams.royal_marksheet_print10', ['margin_top' => 20,'school' => $school,'students' => $students, 'fy' => $fy, 'roll' => $roll]);
            return $pdf->stream('marksheet.pdf');
        }
        else $pdf = PDF::loadView('schools.exams.royal_marksheet_print', ['margin_top' => 20 ,'school' => $school,'students' => $students, 'fy' => $fy, 'roll' => $roll]);
        return $pdf->stream('marksheet.pdf');
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id) {
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id) {

    }

}

Copyright © 2021 - 2025 IMMREX7