Latest updates from IceHrmPro
This commit is contained in:
@@ -35,6 +35,13 @@ class CalendarTools
|
||||
return $hours;
|
||||
}
|
||||
|
||||
public static function getTimeDiffInMinutes($start, $end)
|
||||
{
|
||||
$diff = strtotime($end) - strtotime($start);
|
||||
$minutes = round($diff/(60), 2);
|
||||
return $minutes;
|
||||
}
|
||||
|
||||
public static function getDaysBetweenDates($start, $end)
|
||||
{
|
||||
$begin = new \DateTime($start);
|
||||
@@ -65,6 +72,14 @@ class CalendarTools
|
||||
return $time->format($format);
|
||||
}
|
||||
|
||||
public static function subtractMonthsFromDateTime($datetime, $months, $format = 'Y-m-d H:i:s')
|
||||
{
|
||||
$time = new \DateTime($datetime);
|
||||
$time = $time->sub(new \DateInterval('P' . $months . 'M'));
|
||||
|
||||
return $time->format($format);
|
||||
}
|
||||
|
||||
public static function getNumberOfDaysBetweenDates($later, $earlier)
|
||||
{
|
||||
$timeFirst = new \DateTime($later);
|
||||
@@ -89,4 +104,16 @@ class CalendarTools
|
||||
|
||||
return $counter;
|
||||
}
|
||||
|
||||
public static function getYearFromDate($date)
|
||||
{
|
||||
$date = \DateTime::createFromFormat("Y-m-d", $date);
|
||||
return $date->format("Y");
|
||||
}
|
||||
|
||||
public static function assignYearToDate($date, $year)
|
||||
{
|
||||
$date = \DateTime::createFromFormat("Y-m-d", $date);
|
||||
return sprintf('%s-%s', $year, $date->format("m-d"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,13 @@ use Monolog\Handler\StreamHandler;
|
||||
|
||||
class LogManager
|
||||
{
|
||||
|
||||
private static $me;
|
||||
private $active = null;
|
||||
|
||||
private $log;
|
||||
|
||||
private $logCollector;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
@@ -31,16 +33,49 @@ class LogManager
|
||||
|
||||
public function info($message)
|
||||
{
|
||||
$this->log->addInfo($message);
|
||||
$this->log->addInfo(sprintf('(client=%s) %s', CLIENT_NAME, $message));
|
||||
}
|
||||
|
||||
public function debug($message)
|
||||
{
|
||||
$this->log->addDebug($message);
|
||||
$this->log->addDebug(sprintf('(client=%s) %s', CLIENT_NAME, $message));
|
||||
}
|
||||
|
||||
public function error($message)
|
||||
{
|
||||
$this->log->addError($message);
|
||||
$this->log->addError(sprintf('(client=%s) %s', CLIENT_NAME, $message));
|
||||
}
|
||||
|
||||
public function collectLogs($logMessage)
|
||||
{
|
||||
$this->logCollector[] = sprintf('(client=%s) %s', CLIENT_NAME, $logMessage);
|
||||
}
|
||||
|
||||
public function flushCollectedLogs()
|
||||
{
|
||||
$this->logCollector = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getLogCollector()
|
||||
{
|
||||
return $this->logCollector;
|
||||
}
|
||||
|
||||
public function notifyException(\Throwable $error)
|
||||
{
|
||||
if ($this->isNewRelicActive()) {
|
||||
newrelic_notice_error(sprintf('(client=%s) %s', CLIENT_NAME, $error->getMessage()), $error);
|
||||
}
|
||||
}
|
||||
|
||||
private function isNewRelicActive()
|
||||
{
|
||||
if (is_null($this->active)) {
|
||||
$this->active = extension_loaded('newrelic');
|
||||
}
|
||||
return $this->active;
|
||||
}
|
||||
}
|
||||
|
||||
16
core/src/Utils/ScriptRunner.php
Normal file
16
core/src/Utils/ScriptRunner.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Utils;
|
||||
|
||||
class ScriptRunner
|
||||
{
|
||||
public static function executeJs($parameters, $script)
|
||||
{
|
||||
return exec(sprintf(
|
||||
'node %sexecute/execute.js %s %s',
|
||||
APP_BASE_PATH,
|
||||
base64_encode(json_encode($parameters)),
|
||||
base64_encode($script)
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user