HEX
Server: Apache
System: Linux server1.royalgt4.com 4.18.0-553.89.1.lve.el8.x86_64 #1 SMP Wed Dec 10 13:58:50 UTC 2025 x86_64
User: mostafedeg (1125)
PHP: 5.6.40
Disabled: mail,passthru,parse_ini_file,show_source,eval,assert,pcntl_exec,dl,putenv,proc_open,popen
Upload Files
File: /home/mostafedeg/public_html/erp/controllers/studentsReportdetails.php
<?php
include("../public/impOpreation.php");
$do = $_GET['do'];
$today = date("Y-m-d H:i:s");
$date = date("Y-m-d");
if (empty($do)) {  
 header("location:studentsReports.php");
 exit();
}else if ($do == "students") {  
    $smarty->assign("date", $date);
    $smarty->assign("show", 1);
    $smarty->display("header.html");
    $smarty->display("studentsreportdetailsview/show.html");
    $smarty->assign("student", 1);
    $smarty->display("footer.html");
}elseif ($do == "studentsubjects") {
    include_once("../public/authentication.php");
    $smarty->assign("show", 2);
    $smarty->assign("date", $date);
    $smarty->assign("student", 1);
    $smarty->display("header.html");
    $smarty->display("studentsreportdetailsview/show.html");
    $smarty->display("footer.html");
} elseif ($do == "studentaddsubjects") {
    include_once("../public/authentication.php");
    $smarty->assign("date", $date);
    $smarty->assign("student", 1);
    $smarty->display("studentsreportsview/studentaddsubjects.html");
} else if ($do == "studentabsences") {
    include_once("../public/authentication.php");
        $smarty->assign("show", 5);
    $smarty->assign("date", $date);
    $smarty->assign("student", 1);
    $smarty->display("header.html");
    $smarty->display("studentsreportdetailsview/show.html");
    $smarty->display("footer.html");
} elseif ($do == "studentsexams") {
     include_once("../public/authentication.php");
    $smarty->assign("show", 3);
    $smarty->assign("date", $date);
    $smarty->assign("student", 1);
    $smarty->display("header.html");
    $smarty->display("studentsreportdetailsview/show.html");
    $smarty->display("footer.html");
} elseif ($do == "studentspaymentsystems") {
    include_once("../public/authentication.php");
     $smarty->assign("date", $date);
    $smarty->assign("student", 1);
    $smarty->display("studentsreportsview/studentspaymentsystems.html");
} elseif ($do == "studentspays") {
      include_once("../public/authentication.php");
    $smarty->assign("show", 4);
    $smarty->assign("date", $date);
    $smarty->assign("student", 1);
    $smarty->display("header.html");
    $smarty->display("studentsreportdetailsview/show.html");
    $smarty->display("footer.html");
} elseif ($do == "branches") {
    include_once("../public/authentication.php");
 $today = date("Y-m-d");
    $branchs = R::getAll('SELECT branch.* FROM `branch` WHERE branchId > 0 ');
    $branches = json_decode (json_encode ($branchs), FALSE);
     $allcgstudentabsencesd = 0;
    $allcstudentspaysd = 0;
    foreach($branches as $branch){
        $crightstudentspays = R::count('studentspays'," left join students on studentspays.studentid = students.id WHERE studentspays.del < 2 and students.branchid = ? 
        and studentspays.payenddate  >= '$today' ", [$branch->branchId]);
        $branch->crightstudentspays =  $crightstudentspays;
        
        $cgstudentabsences = R::getcell("SELECT COUNT(*) FROM ( SELECT DISTINCT studentid FROM `studentabsences` left join students on studentabsences.studentid = students.id WHERE students.branchid = $branch->branchId and studentabsences.todaysend = '$today' ) as totals ");
        $branch->cgstudentabsences =  $cgstudentabsences;
        $allcgstudentabsencesd += $cgstudentabsences;
        
        // $studentabsences = R::count('studentabsences'," left join students on studentabsences.studentid = students.id WHERE students.branchid = ? and studentabsences.todaysend = '$today' ", [$branch->branchId]);
        // $branch->cstudentabsences =  $studentabsences;
        
        $cstudentspays = R::count('studentspays'," left join students on studentspays.studentid = students.id WHERE studentspays.del < 2 and students.branchid = ? 
        and studentspays.addtoday  >= '$today 00-00-00' and studentspays.addtoday  <= '$today 23-59-55'  ", [$branch->branchId]);
        $branch->cstudentspays =  $cstudentspays;
        $allcstudentspaysd += $cstudentspays ;
        
        $totalstudentspays = R::getcell("SELECT SUM(studentspays.payprice) FROM `studentspays` LEFT JOIN students ON  studentspays.studentid = students.id WHERE studentspays.del < 2 
        and students.branchid = ?  and studentspays.addtoday  >= '$today 00-00-00' and studentspays.addtoday  <= '$today 23-59-55' ", [$branch->branchId]);
        $branch->totalstudentspays = (int)  $totalstudentspays;
    }
    $smarty->assign('branches', $branches);
     $smarty->assign('allcgstudentabsencesd', $allcgstudentabsencesd);
      $smarty->assign('allcstudentspaysd', $allcstudentspaysd);
    
    $month = filter_input(INPUT_POST, 'months')?: date('m');
    $year = filter_input(INPUT_POST, 'years') ?: date('Y');
    $start_dates = filter_input(INPUT_POST, 'start_dates');
    $end_dates = filter_input(INPUT_POST, 'end_dates');
    $smarty->assign("year", $year);
    $smarty->assign("month", $month);
    $start_date = "01-".$month."-".$year;
    $start_time = strtotime($start_date);
    $end_time = strtotime("+1 month", $start_time);
    $allmonth = array();
    //   $allscrightstudentspays = 0;
    // $allscgstudentabsences = 0;
    $allscstudentspays = 0;
    $allstotalstudentspays = 0;
    for($i=$start_time; $i<$end_time; $i+=86400)
    {
        $today = date('Y-m-d', $i); 
        $branchs = R::getAll('SELECT branch.* FROM `branch` WHERE branchId > 0 ');
        $branches = json_decode (json_encode ($branchs), FALSE);
      
        // $allcrightstudentspays = 0;
        $allcgstudentabsences = 0;
        $allcstudentspays = 0;
        $alltotalstudentspays = 0;
        foreach($branches as $branch){
            $crightstudentspays = R::count('studentspays'," left join students on studentspays.studentid = students.id WHERE studentspays.del < 2 and students.branchid = ? 
            and studentspays.payenddate  >= '$today' ", [$branch->branchId]);
            $branch->crightstudentspays =  $crightstudentspays;
            $allcrightstudentspays += $crightstudentspays;
            
            $cgstudentabsences = R::getcell("SELECT COUNT(*) FROM ( SELECT DISTINCT studentid FROM `studentabsences` left join students on studentabsences.studentid = students.id WHERE students.branchid = $branch->branchId and studentabsences.todaysend = '$today' ) as totals ");
            $branch->cgstudentabsences =  $cgstudentabsences;
            
            // $cstudentabsences = R::count('studentabsences'," left join students on studentabsences.studentid = students.id WHERE students.branchid = ? and studentabsences.todaysend = '$today' ", [$branch->branchId]);
            // $branch->cstudentabsences =  $cstudentabsences;
            
            $allcgstudentabsences += $cgstudentabsences;
            $cstudentspays = R::count('studentspays'," left join students on studentspays.studentid = students.id WHERE studentspays.del < 2 and students.branchid = ? 
            and studentspays.addtoday  >= '$today 00-00-00' and studentspays.addtoday  <= '$today 23-59-55'  ", [$branch->branchId]);
            $branch->cstudentspays =  $cstudentspays;
             $allcstudentspays += $cstudentspays ;
            
            $totalstudentspays = R::getcell("SELECT SUM(studentspays.payprice) FROM `studentspays` LEFT JOIN students ON  studentspays.studentid = students.id WHERE studentspays.del < 2 
            and students.branchid = ?  and studentspays.addtoday  >= '$today 00-00-00' and studentspays.addtoday  <= '$today 23-59-55' ", [$branch->branchId]);
            $branch->totalstudentspays = (int) $totalstudentspays;
            $branch->todays = $today;
             $alltotalstudentspays +=  (int) $totalstudentspays;
        }
        if($allcgstudentabsences > 0  || $allcstudentspays > 0  ){
            // $allscrightstudentspays += $allcrightstudentspays;
            // $allscgstudentabsences += $allcgstudentabsences;
            $allscstudentspays += $allcstudentspays;
            $allstotalstudentspays += $alltotalstudentspays;
             array_push($allmonth, $branches); 
        }

       
    }
    $smarty->assign("allmonth", $allmonth);
      $startOfThisMonth = date('Y-m-01', strtotime($start_date));
    $endOfThisMonth = date('Y-m-t', strtotime($start_date));
    $allscrightstudentspays = R::count('studentspays'," left join students on studentspays.studentid = students.id WHERE studentspays.del < 2 
            and studentspays.payenddate  >= '$startOfThisMonth' ");
    $allscgstudentabsences = R::getcell("SELECT COUNT(*) FROM ( SELECT DISTINCT studentid FROM `studentabsences` left join students on studentabsences.studentid = students.id
    WHERE studentabsences.todaysend >= '$startOfThisMonth' and studentabsences.todaysend <= '$endOfThisMonth' ) as totals ");
    $smarty->assign("allscrightstudentspays", $allscrightstudentspays);
    $smarty->assign("allscgstudentabsences", $allscgstudentabsences);
     $smarty->assign("allscstudentspays", $allscstudentspays);
      $smarty->assign("allstotalstudentspays", $allstotalstudentspays);
      
      
      $branchs2 = R::getAll('SELECT branch.* FROM `branch` WHERE branchId > 0 ');
      $branchs2 = json_decode (json_encode ($branchs2), FALSE);
      
        $allcrightstudentspays2 = 0;
        $allcgstudentabsences2 = 0;
        $allcstudentspays2 = 0;
        $alltotalstudentspays2 = 0;
        foreach($branchs2 as $branch2){
            $crightstudentspays2 = R::count('studentspays'," left join students on studentspays.studentid = students.id WHERE studentspays.del < 2 and students.branchid = ? 
            and studentspays.payenddate  >= '$start_dates' and studentspays.payenddate  <= '$end_dates' ", [$branch2->branchId]);
            $branch2->crightstudentspays =  $crightstudentspays2;
            $allcrightstudentspays2 += $crightstudentspays2;
            
            $cgstudentabsences2 = R::getcell("SELECT COUNT(*) FROM ( SELECT DISTINCT studentid FROM `studentabsences` left join students on studentabsences.studentid = students.id WHERE students.branchid = 
            $branch2->branchId and studentabsences.todaysend >= '$start_dates' and studentabsences.todaysend <= '$end_dates') as totals ");
            $branch2->cgstudentabsences =  $cgstudentabsences2;
            $allcgstudentabsences2 += $cgstudentabsences2;
            
            $cstudentspays2 = R::count('studentspays'," left join students on studentspays.studentid = students.id WHERE studentspays.del < 2 and students.branchid = ? 
            and studentspays.addtoday  >= '$start_dates 00-00-00' and studentspays.addtoday  <= '$end_dates 23-59-55'  ", [$branch2->branchId]);
            $branch2->cstudentspays =  $cstudentspays2;
             $allcstudentspays2 += $cstudentspays2 ;
            
            $totalstudentspays2 = R::getcell("SELECT SUM(studentspays.payprice) FROM `studentspays` LEFT JOIN students ON  studentspays.studentid = students.id WHERE studentspays.del < 2 
            and students.branchid = ?  and studentspays.addtoday  >= '$start_dates 00-00-00' and studentspays.addtoday  <= '$end_dates 23-59-55' ", [$branch2->branchId]);
            $branch2->totalstudentspays = (int) $totalstudentspays2;
            $alltotalstudentspays2 +=  (int) $totalstudentspays2;
        }
      
      
      
      $smarty->assign("branchs2", $branchs2);
      $smarty->assign("allcrightstudentspays2", $allcrightstudentspays2);
      $smarty->assign("allcgstudentabsences2", $allcgstudentabsences2);
      $smarty->assign("allcstudentspays2", $allcstudentspays2);
      $smarty->assign("alltotalstudentspays2", $alltotalstudentspays2);
      
      $smarty->assign("startdate", $start_dates);
      $smarty->assign("enddate", $end_dates);
    $smarty->display("header.html");
    $smarty->display("studentsreportdetailsview/branches.html");
    $smarty->assign("student", 1);
    $smarty->display("footer.html"); 
    
    
}
?>