- Updated task editing template to handle default status for new tasks and corrected variable names. - Enhanced work time reporting by rounding time to the nearest quarter hour and adjusting amount formatting. - Introduced TasksController to manage task-related operations, including status resolution and email notifications. - Added TaskAttachmentRepository for handling task attachments, including upload, rename, and delete functionalities. - Implemented WorkTimeRepository to fetch clients with unsettled tasks and calculate total work time. - Created unit tests for TasksController and TaskAttachmentRepository to ensure functionality and correctness.
79 lines
2.3 KiB
PHP
79 lines
2.3 KiB
PHP
<?php
|
|
error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT ^ E_WARNING ^ E_DEPRECATED);
|
|
function __autoload_my_classes($classname)
|
|
{
|
|
$q = explode('\\', $classname);
|
|
$c = array_pop($q);
|
|
$base_path = 'autoload/' . implode('/', $q) . '/';
|
|
$f = $base_path . $c . '.php';
|
|
if ( !file_exists( $f ) )
|
|
$f = $base_path . 'class.' . $c . '.php';
|
|
|
|
if (file_exists($f)) {
|
|
require_once($f);
|
|
}
|
|
}
|
|
spl_autoload_register('__autoload_my_classes');
|
|
date_default_timezone_set('Europe/Warsaw');
|
|
|
|
require_once 'config.php';
|
|
require_once 'libraries/medoo/medoo.php';
|
|
require_once 'libraries/grid/config.php';
|
|
require_once 'libraries/phpmailer/class.phpmailer.php';
|
|
require_once 'libraries/phpmailer/class.smtp.php';
|
|
require_once 'libraries/rb.php';
|
|
|
|
session_start();
|
|
|
|
if (!isset($_SESSION['check'])) {
|
|
session_regenerate_id();
|
|
$_SESSION['check'] = true;
|
|
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
|
|
}
|
|
|
|
if ($_SESSION['ip'] !== $_SERVER['REMOTE_ADDR']) {
|
|
session_destroy();
|
|
header('Location: /');
|
|
exit;
|
|
}
|
|
|
|
\R::setup('mysql:host=' . $database['host'] . ';dbname=' . $database['name'], $database['user'], $database['password']);
|
|
\R::ext('xdispense', function ($type) {
|
|
return R::getRedBean() -> dispense($type);
|
|
});
|
|
|
|
$mdb = new medoo([
|
|
'database_type' => 'mysql',
|
|
'database_name' => $database['name'],
|
|
'server' => $database['host'],
|
|
'username' => $database['user'],
|
|
'password' => $database['password'],
|
|
'charset' => 'utf8'
|
|
]);
|
|
|
|
$domain = preg_replace( '#^(http(s)?://)?w{3}\.#', '$1', $_SERVER['SERVER_NAME'] );
|
|
$cookie_name = str_replace( '.', '-', $domain );
|
|
$settings = array_merge( $settings, \factory\Crm::settings());
|
|
|
|
if ( isset( $_COOKIE[$cookie_name] ) && !isset( $_SESSION['user'] ) )
|
|
{
|
|
$obj = json_decode( $_COOKIE[$cookie_name] );
|
|
$email = $obj -> {'email'};
|
|
$password = $obj -> {'hash'};
|
|
|
|
if ( $user_tmp = $mdb -> get( 'users', '*', [ 'AND' => [ 'email' => $email, 'password' => $password ] ] ) )
|
|
{
|
|
\S::set_session( 'user', $user_tmp );
|
|
}
|
|
}
|
|
|
|
$user = \S::get_session('user');
|
|
|
|
if ( !$user and !in_array( $_SERVER['REQUEST_URI'], [ '/logowanie', '/rejestracja', '/users/login/', '/cron/main_view/' ] ) )
|
|
{
|
|
header( 'Location: /logowanie' );
|
|
exit;
|
|
}
|
|
|
|
echo \view\Site::show();
|