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/absentReportController.php
<?php

// كنترول الموظفين
//
//the global file operation
include("../public/impOpreation.php");

//global varable
global $showoutside;

//to check if the page from .htacess
//$showoutside = $_GET['sn'];
// get the config file
include_once("../public/config.php");

//here the db files that include in the file
include("../public/include_dao.php");

require_once('../models/dao/EmployeeDAO.class.php');
require_once('../models/dto/Employee.class.php');
require_once('../models/mysql/EmployeeMySqlDAO.class.php');
require_once('../models/mysql/ext/EmployeeMySqlExtDAO.class.php');

require_once('../models/dao/YoutubeLinkDAO.class.php');
require_once('../models/dto/YoutubeLink.class.php');
require_once('../models/mysql/YoutubeLinkMySqlDAO.class.php');
require_once('../models/mysql/ext/YoutubeLinkMySqlExtDAO.class.php');


$do = $_GET['do'];

$langs = $_SESSION['erp_lang'];
include_once("../views/languages/$langs/success.php");
include_once("../views/languages/$langs/error.php");

$smarty->display("header.html");


//create object  from employee
$employeeDAO = new EmployeeMySqlDAO();
$employee = new Employee();
$employeeEX = new EmployeeMySqlExtDAO();

$youtubeLink = new YoutubeLink();
$youtubeLinkDAO = new YoutubeLinkMySqlDAO();
$youtubeLinkEX = new YoutubeLinkMySqlExtDAO();


//create object from user
//dispaly  add form
if (empty($do)) {
    include_once("../public/authentication.php");

    $queryString = '';
    if ($_SESSION['branchId'] > 0)
        $queryString = ' AND  branchid = ' . $_SESSION['branchId'];

    $allemployee = $employeeEX->queryAllSimple($queryString);
    $smarty->assign('allemployee', $allemployee);


    $startDate = date('Y-m-d');
    $endDate = date('Y-m-d');

    $Programsetting = $ProgramsettingDAO->load(1);
    if (isset($Programsetting->reportsPlusHours) && !empty($Programsetting->reportsPlusHours)) {
        $reportsPlusHours = $Programsetting->reportsPlusHours + 24; //24 to get the end of the day and add search hours to it
        $endDate = date('Y-m-d', strtotime('+' . $reportsPlusHours . ' hour +0 minutes', strtotime($endDate)));
        $startDate = date('Y-m-d', strtotime('+' . $Programsetting->reportsPlusHours . ' hour +0 minutes', strtotime($startDate)));
    } else {
        $endDate = $endDate . ' 23:59:59';
        $startDate = $startDate . " 00:00:00";
    }

    $queryString = '';
    if ($_SESSION['branchId'] > 0)
        $queryString .= ' AND  branchid = ' . $_SESSION['branchId'];

    $employes = $employeeEX->queryAllString($startDate, $endDate,$queryString);
    $smarty->assign('employes', $employes);

    $youtubes = $youtubeLinkDAO->queryAll();
    $smarty->assign("youtubes", $youtubes);

    $smarty->display("absentReportview/show.html"); //the template page
} //success
elseif ($do == "show") {

    $queryString = '';
    if ($_SESSION['branchId'] > 0)
        $queryString = ' AND  branchid = ' . $_SESSION['branchId'];

    $allemployee = $employeeEX->queryAllSimple($queryString);
    $smarty->assign('allemployee', $allemployee);

    $startDate = $_REQUEST['from'];
    $endDate = $_REQUEST['to'];
    $employeeId = $_REQUEST['chooseEmp'];
    $queryString = '';

    if (!empty($startDate) && !empty($endDate)) {

        $Programsetting = $ProgramsettingDAO->load(1);


        if (isset($Programsettingdata->reportsPlusHours) && !empty($Programsettingdata->reportsPlusHours)) {
            $reportsPlusHours = $Programsettingdata->reportsPlusHours + 24; //24 to get the end of the day and add search hours to it
            $endDate = date('Y-m-d H:i:s', strtotime('+' . $reportsPlusHours . ' hour +0 minutes', strtotime($endDate)));
            $startDate = date('Y-m-d H:i:s', strtotime('+' . $Programsettingdata->reportsPlusHours . ' hour +0 minutes', strtotime($startDate)));
            //
        } else {
            $endDate = $endDate . ' 23:59:59';
            $startDate = $startDate . " 00:00:00";
            //
        }

        $queryString .= ' AND employeeDate >= "' . $startDate . '" AND employeeDate <= "' . $endDate . '" ';
    }


    if (!empty($employeeId)) {
        $queryString .= ' AND employee.employeeId =' . $employeeId;
    }

    if ($_SESSION['branchId'] > 0)
        $queryString .= ' AND  branchid = ' . $_SESSION['branchId'];

    $allemployee = $employeeEX->queryAllSimple($queryString);

    $employes = $employeeEX->queryAllReportAbsent($queryString);
    $smarty->assign('employes', $employes);

    $youtubes = $youtubeLinkDAO->queryAll();
    $smarty->assign("youtubes", $youtubes);

    $smarty->display("absentReportview/show.html");
    $smarty->assign("customValidation", 1);
    //the template page
} elseif ($_GET['do'] == "sucess") {
    $smarty->display("succes.html");
} elseif ($_GET['do'] == "error") {
    $smarty->display("error.html");
}
$smarty->assign("customValidation", 1);
$smarty->assign("employeeendday", 1);
$smarty->display("footer.html");