/*
if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off"){
$redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $redirect);
exit();
} */
session_start();
include_once 'config.php';
require('classes/Smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = 'templates/templates';
$smarty->compile_dir = 'templates/templates_c';
$smarty->cache_dir = 'templates/cache';
$smarty->config_dir = 'templates/configurari';
//include clase noi
include 'classes/database.php';
include 'classes/rpl.php';
include 'classes/categs.php';
include 'classes/products.php';
include 'classes/banks.php';
include 'classes/cart.php';
include 'classes/cities.php';
include 'classes/locations.php';
include 'classes/sources.php';
include 'classes/streets.php';
include 'classes/orders.php';
include 'classes/popups.php';
include 'classes/users.php';
include 'classes/employee.php';
include 'classes/drivers.php';
include 'classes/filtre.php';
include 'classes/concedii.php';
include 'classes/echipa.php';
include 'classes/pontaje.php';
include 'classes/settings.php';
include 'classes/reports.php';
//end include clase noi
//define link location
$segment=explode("/",$_GET['var1']);
$tip=$segment[0];
$idp=$segment[1];
//end define link location
//default title
$title='Pontaj Web';
//end default title
//init database
$db=new bazaDate();
$connect=$db->connect($dbhost,$dbname,$dbuser,$dbpass);
//init database
//login
if ($_SESSION['employee']<1)
{
if ($_POST['step']=='auth')
{
if (strlen($_POST['utilizator'])>5 and strlen($_POST['parola'])>5)
{
$employee=new employee();
if ($employee->login($_POST['utilizator'],$_POST['parola'])>0) header("Location: ".$dir.'');
else $smarty->assign('errorAuth', 'Eroare autentificare');
} else $smarty->assign('errorAuth', 'Eroare autentificare');
}
$smarty->display('login.html');
exit();
}
//end login
if ($tip!='')
{
$lunaDeLucru=$_SESSION['lunaLucru'].' / '.$_SESSION['anLucru'];
$smarty->assign('lunaDeLucru', 'Luna de lucru: '.$lunaDeLucru);
}
//lista pontaj
if ($tip=='pontaj')
{
if ($_GET['centruDeCost']!='' or ($idp=='angajat'))
{
$content.='
';
}
$employee=new employee();
if ($_GET['afisareInEchipa']==1) $afisareOre=0;
else $afisareOre=1;
$content.=''.$employee->listaLunara(date("m"),date("Y"),$afisareOre).'
';
$content.='
';
}
//end lista pontaj
//antecalcul
if ($tip=='antecalcul')
{
if ($_GET['centruDeCost']!='' or ($idp=='angajat'))
{
$content.='';
}
{
$employee=new employee();
$content.=''.$employee->listaanuala(date("Y")).'
';
}
}
//end antecalcul
//settings
if ($tip=='afisareTotaluri')
{
$settings=new settings();
$content=$settings->editAfisareTotaluri();
}
//end settings
//rapoarte
if ($tip=='raportCentralizatorAngajati')
{
$reports=new reports();
$content=$reports->raportCentralizatorAngajati();
}
if ($tip=='veziEchipa')
{
$reports=new reports();
$content=$reports->raportListaLunara($_SESSION['lunaLucru'],$_SESSION['anLucru']);
}
if ($tip=='raportComparativ')
{
$reports=new reports();
$content=$reports->raportComparativ($_SESSION['anLucru']);
}
//end rapoarte
//alocare concedii
if ($tip=='alocareConcedii')
{
$concedii=new concedii();
$content=$concedii->alocareConcedii();
}
if ($tip=='listaConcedii')
{
$concedii=new concedii();
$content=''.$concedii->showConcedii(date("Y-m",strtotime($_SESSION['anLucru'].'-'.$_SESSION['lunaLucru'].'-01'))).'
';
}
if ($tip=='echipe')
{
$echipa=new echipa();
$content=$echipa->formAdaugare();
}
if ($tip=='alocarePontaje')
{
$pontaj=new pontaj();
$content=$pontaj->formAdaugare();
}
//end alocare concedii
if ($_GET['var1']=='' and $_SESSION['employee']>0)
{
if ($_SESSION['lunaLucru']=='')
{
$_SESSION['lunaLucru']=date("n");
$_SESSION['anLucru']=date("Y");
}
if ($_POST['step']=='chLuna')
{
$_SESSION['lunaLucru']=$_POST['luna'];
$_SESSION['anLucru']=$_POST['anul'];
}
$lunalucru=$_SESSION['lunaLucru'];
$anLucru=$_SESSION['anLucru'];
$content.='';
}
if ($tip=='delete')
{
$db->simpleQuery("DELETE from angajatiCCSuplimentar where angajatId='$idp' and centruCost='".$segment[2]."' LIMIT 1");
header("Location: ".$dir.'?var1=pontaj¢ruDeCost='.$segment[2]);
}
$smarty->assign('postSearch', $_POST['search']);
$smarty->assign('rand', date("YmdHis"));
$smarty->assign('dir', $dir);
$smarty->assign('hour',date("H:i"));
$smarty->assign('title', $title);
$smarty->assign('content', $content);
switch ($tip) {
default:
$smarty->display('index.html');
}
?>