| @@ -0,0 +1,34 @@ | |||
| <?php | |||
| //Deprecated | |||
| class Alerts { | |||
| private $msgList; | |||
| function __construct() { | |||
| $this->msgList = [ | |||
| //Contents | |||
| 'SHOW_MORE' => _('Show more...'), | |||
| 'SESS_PERM' => _('Session expired or permission denied. Please try to log in again.'), | |||
| 'PERM_DENI' => _('Permission denied.'), | |||
| 'SESS_EXPI' => _('Session expired, please log in again.'), | |||
| 'SHOW_CONT' => _('Click Load button to load this content...'), | |||
| 'CONT_EMPT' => _('This content is currently empty, please try again in a few minutes.'), | |||
| 'NODT_LIST' => _('No data available in this list.'), | |||
| 'NODT_VALI' => _('Not valid data.'), | |||
| 'PASS_MESG' => _('The password provided is not valid. The password must contain at least %s characters and at least 1 non-alphanumeric symbol (!, ?, -, etc.)'), | |||
| 'PASS_MATC' => _('The password fields do not match.'), | |||
| ]; | |||
| } | |||
| function get($code='') { | |||
| if (isset($this->msgList[$code])) { | |||
| return $this->msgList[$code]; | |||
| } | |||
| return ''; | |||
| } | |||
| } | |||
| @@ -0,0 +1,266 @@ | |||
| <?php | |||
| class Controller { | |||
| public $config; | |||
| public $locale; | |||
| public $layout; | |||
| public $user; | |||
| //public $helper; | |||
| public $utility; | |||
| public $view; | |||
| public $viewDir; | |||
| public $appTitle; | |||
| public $db; | |||
| public $security; | |||
| public $cookie; | |||
| public $session; | |||
| public $logger; | |||
| public $media; | |||
| public $allow; | |||
| public $allowedRoles; | |||
| public $permissionDenied; | |||
| public $showBreadcrumbs; | |||
| public $breadcrumbs; | |||
| public $actionTitle; | |||
| public $appRequestType; //web [default], mob, desk (TODO: read the http header appRequestType) | |||
| public $memoryCache; | |||
| public $alerts; | |||
| public $paginationRange; | |||
| public $userLocale; | |||
| function __construct() { | |||
| global $config, $layout, $locale, $memoryCache, $user, $db, $security, $session, $cookie, $logger; | |||
| $this->db = $db; | |||
| $this->config = $config; | |||
| $this->layout = $layout; | |||
| $this->locale = $locale; | |||
| $this->defLang = $this->locale->defaultLanguage; | |||
| $this->utility = new Utility(); | |||
| //$this->helper = new Helper(); | |||
| $this->alerts = new Alerts(); //Deprecated | |||
| $this->media = new Media(); | |||
| $this->user = $user; | |||
| $this->view = new stdClass(); | |||
| $this->viewDir = null; | |||
| $this->appTitle = $this->config['settings']['app-title']; | |||
| $this->security = $security; | |||
| $this->session = $session; | |||
| $this->cookie = $cookie; | |||
| $this->logger = $logger; | |||
| $this->allow = []; | |||
| $this->permissionDenied = false; | |||
| $this->appRequestType = 'web'; | |||
| $this->memoryCache = $memoryCache; | |||
| $this->paginationRange = 10; | |||
| $this->userLocale = null; | |||
| $this->showBreadcrumbs = true; | |||
| $this->breadcrumbs = []; | |||
| $this->actionTitle = ''; | |||
| $this->controllerName = ''; | |||
| $this->actionName = ''; | |||
| $this->setContentLocale(); | |||
| } | |||
| public function allowAccess() { | |||
| return false; | |||
| } | |||
| public function beforeRender($content=null) { | |||
| return false; | |||
| } | |||
| public function checkPermissions($allowedRoles=[]) { | |||
| if (is_array($allowedRoles) && !empty($allowedRoles)) { | |||
| return $this->user->checkPermissions($allowedRoles); | |||
| } | |||
| return true; | |||
| } | |||
| public function setContentLocale() { | |||
| $this->userLocale = $this->locale->setCurrentLanguage(); | |||
| $this->view->userLocale = $this->userLocale; | |||
| $this->locale->setLocaleEnvironment($this->userLocale); | |||
| } | |||
| public function setView($file=null, $compact=true) { | |||
| $content = ''; | |||
| //Check whether allowAccess() method is overriden in the child class and return its content | |||
| if (!in_array($file, $this->allow)) { | |||
| $allowAccess = $this->allowAccess(); | |||
| if ($allowAccess !== false) { | |||
| $data = json_decode($allowAccess, true); | |||
| return $data['html']; | |||
| } | |||
| } | |||
| if (!is_null($file)) { | |||
| $ob_string = $this->config['settings']['gzip-content'] ? 'ob_gzhandler' : ''; | |||
| ob_start($ob_string); | |||
| include VIEWS_DIR.$this->viewDir.'/'.$file.'.view.php'; | |||
| $content = ob_get_clean(); | |||
| } | |||
| $isUTF8 = mb_detect_encoding($content, 'UTF-8', true); | |||
| if (!$isUTF8) | |||
| return utf8_encode(utf8_decode($content)); | |||
| else | |||
| return $content; | |||
| } | |||
| public function setJsonView($file=null, $compress=true, $jsRedirect='', $jsonData=[]) { | |||
| $content = $this->setView($file, $compress); | |||
| //You can overraid this method in mainController for all controllers or in a specific controller | |||
| $beforeRender = $this->beforeRender($content); | |||
| if ($beforeRender !== false) { | |||
| $content = $beforeRender; | |||
| } | |||
| return $this->setRawJsonResponse('ok', null, ['jsonData'=>$jsonData, 'page'=>1, 'html'=>$content, 'jsRedirect'=>$jsRedirect]); | |||
| } | |||
| public function setRawJsonResponse($status='ok', $msg=null, $args=[], $jsArgs=null) { | |||
| return json_encode(array_merge(['status'=>$status, 'msg'=>$msg, 'jsArgs'=>$jsArgs, 'userId'=>$this->user->getUserId(), 'groupId'=>$this->user->getGroupId(), 'username'=>$this->user->getUserField('userUsername'), 'apiKey' => $this->config['settings']['api-key'], 'userLang'=>$this->locale->setCurrentLanguage()], $args)); | |||
| } | |||
| public function setJsonError($msg='', $action=null) { | |||
| return $this->setRawJsonResponse('err', $msg, ['action', $action]); | |||
| } | |||
| public function partial($path, $params=[], $compact=true) { | |||
| if (!empty($params)) extract($params); | |||
| ob_start(); | |||
| include VIEWS_DIR.'Elements/'.$path.'.part.php'; | |||
| $content = ob_get_clean(); | |||
| return $content; | |||
| } | |||
| public function setPagination($dbRef, $totalRows, $currentPage, $link) { | |||
| $this->view->totalPages = $dbRef->totalPages; | |||
| $this->view->totalRows = $totalRows; | |||
| $this->view->currentPage = $currentPage; | |||
| $this->view->pageNumbers = []; | |||
| $this->view->hasPrevPage = $this->view->currentPage > 1 ? true : false; | |||
| $this->view->hasNextPage = $this->view->currentPage < $this->view->totalPages ? true : false; | |||
| $this->view->prevPageLink = $this->utility->setHash($link.'/'.((int)$this->view->currentPage-1)); | |||
| $this->view->nextPageLink = $this->utility->setHash($link.'/'.((int)$this->view->currentPage+1)); | |||
| $this->view->pagNumbRange = $this->paginationRange; | |||
| $this->view->pagLimitLeft = 1; | |||
| $this->view->pagLimitRight = ($this->view->pagNumbRange<$this->view->totalPages) | |||
| ? $this->view->pagLimitLeft+($this->view->pagNumbRange-1) : $this->view->totalPages; | |||
| if ($this->view->currentPage > $this->view->pagNumbRange) { | |||
| if ($this->view->totalPages > $this->view->pagNumbRange) { | |||
| //$this->view->pagLimitLeft = $this->view->totalPages-$this->view->pagNumbRange; | |||
| //$this->view->pagLimitRight = $this->view->pagLimitLeft+$this->view->pagNumbRange; | |||
| $this->view->pagLimitLeft = $this->view->pagNumbRange+1; | |||
| $this->view->pagLimitRight = ($this->view->pagLimitLeft+$this->view->pagNumbRange) < $this->view->totalPages ? $this->view->pagLimitLeft+$this->view->pagNumbRange : $this->view->totalPages; | |||
| } | |||
| } | |||
| if ($this->view->totalPages > 1) { | |||
| for($i=$this->view->pagLimitLeft; $i<=$this->view->pagLimitRight; $i++) { | |||
| $pageActive = $i == $this->view->currentPage ? true : false; | |||
| $this->view->pageNumbers[$i] = ['active'=>$pageActive, 'label'=>$i, 'link'=>$this->utility->setHash($link.'/'.$i)]; | |||
| } | |||
| } | |||
| } | |||
| public function validateForm($data=[], $checkPasswords=false) { | |||
| if (is_array($data) && !empty($data)) { | |||
| $pwd1 = null; | |||
| $pwd2 = null; | |||
| foreach($data as $key => $item) { | |||
| if (isset($item['required']) && (int)$item['required'] == 1) { | |||
| if (trim($item['value']) == '') { | |||
| return ['msg'=>vsprintf(_('"%s" is a required field.'), [$item['label']]), 'class'=>$item['class']]; | |||
| } | |||
| if ($item['type'] == 'email' && trim($item['value']) != '') { | |||
| if (!filter_var($item['value'], FILTER_VALIDATE_EMAIL)) { | |||
| return ['msg'=>vsprintf(_('"%s" is not a valid email address.'), [$item['label']]), 'class'=>$item['class']]; | |||
| } | |||
| } | |||
| if ($checkPasswords) { | |||
| if ($item['type'] == 'password1' || $item['type'] == 'password2' || $item['type'] == 'password') { | |||
| /*if (strlen($item['value']) < $this->security->passwordMinLength) { | |||
| return ['msg'=>vsprintf(_('"%s" field length is too short.'), [$item['label']]), 'class'=>$item['class']]; | |||
| }*/ | |||
| if (!$this->security->validatePassword($item['value'])) { | |||
| return ['msg'=>vsprintf(_('The password provided is not valid. The password must contain at least %s characters and at least 1 non-alphanumeric symbol (!, ?, -, etc.)'), [$item['label'], $this->security->passwordMinLength]), 'class'=>$item['class']]; | |||
| } | |||
| } | |||
| if ($item['type'] == 'password1') { | |||
| $pwd1 = trim($item['value']); | |||
| } | |||
| if ($item['type'] == 'password2') { | |||
| $pwd2 = trim($item['value']); | |||
| } | |||
| if (!is_null($pwd1) && !is_null($pwd2)) { | |||
| if ($pwd1 != $pwd2) { | |||
| return ['msg'=>_('The password fields do not match.'), 'class'=>$item['class']]; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| public function setJson($structure=null) { | |||
| return json_encode($structure); | |||
| } | |||
| public function parseArgs($args) { | |||
| $params = isset($args['params']) ? $args['params'] : false; | |||
| if ($params !== false) { | |||
| parse_str($params, $output); | |||
| } else { | |||
| $output = null; | |||
| } | |||
| return $output; | |||
| } | |||
| public function getPost($key=null, $default=false) { | |||
| $value = isset($_POST[$key]) ? $_POST[$key] : $default; | |||
| return $value; | |||
| } | |||
| public function redirect($controller, $action, $args=null) { | |||
| $args = $this->parseArgs($args); | |||
| return Dispatch::route($controller, $action, $args); | |||
| } | |||
| public function compactText($content=null) { | |||
| $content = str_replace(array("\n","\r","\t"), '', $content); | |||
| $content = preg_replace('/\s+/', ' ', $content); | |||
| return $content; | |||
| } | |||
| } | |||
| @@ -0,0 +1,61 @@ | |||
| <?php | |||
| class Cookie { | |||
| private $security; | |||
| private $config; | |||
| public $isSecure; | |||
| function __construct() { | |||
| global $config, $security; | |||
| $this->config = $config; | |||
| $this->isSecure = $this->config['settings']['encrypt-cookie']; | |||
| $this->security = $security; | |||
| } | |||
| public function refreshCookie($key, $data=null, $expire=0, $path='/', $domain='', $secure=false, $httponly=false) { | |||
| $saveData = (is_array($data) || is_object($data) || is_bool($data)) ? json_encode($data) : $data; | |||
| if (isset($_COOKIE[$key])) unset($_COOKIE[$key]); | |||
| if ($this->isSecure) { | |||
| $saveData = $this->security->secureString($saveData, 'e'); | |||
| } | |||
| return setcookie($key, $saveData, $expire, $path, $domain, $secure, $httponly); | |||
| } | |||
| public function readCookie($key=null) { | |||
| if (isset($_COOKIE[$key])) { | |||
| $cookieData = $_COOKIE[$key]; | |||
| if ($this->isSecure) { | |||
| $cookieData = $this->security->secureString($cookieData, 'd'); | |||
| } | |||
| if ($this->isJson($cookieData)) { | |||
| return json_decode($cookieData, true); | |||
| } else { | |||
| return $cookieData; | |||
| } | |||
| } | |||
| return false; | |||
| } | |||
| public function deleteCookie($key=null) { | |||
| if (isset($_COOKIE[$key])) { | |||
| unset($_COOKIE[$key]); | |||
| setcookie($key, null, time()-3600, '/'); | |||
| } | |||
| return !isset($_COOKIE[$key]); | |||
| } | |||
| private function isJson($string) { | |||
| return is_string($string) && is_array(json_decode($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false; | |||
| } | |||
| } | |||
| @@ -0,0 +1,19 @@ | |||
| <?php | |||
| class Dispatch { | |||
| private static $initialized = false; | |||
| public static $user; | |||
| public static $controller; | |||
| public static $action; | |||
| public static $args; | |||
| public static function route($controller, $action, $args=[]) { | |||
| self::$controller = $controller; | |||
| self::$action = $action; | |||
| self::$args = $args; | |||
| $class = self::$controller.'Controller'; | |||
| $response = call_user_func(array(new $class(), self::$action), self::$args); | |||
| return $response; | |||
| } | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| <?php | |||
| class Image { | |||
| public $defaultType; | |||
| public $defaultWidth; | |||
| public $defaultCompression; | |||
| function __construct() { | |||
| $this->defaultType = 'jpg'; | |||
| $this->defaultWidth = 150; | |||
| $this->defaultCompression = 85; | |||
| } | |||
| public function resize() { | |||
| } | |||
| public optimize() { | |||
| } | |||
| } | |||
| @@ -0,0 +1,715 @@ | |||
| <?php | |||
| //namespace Gumlet; | |||
| /** | |||
| * PHP class to resize and scale images | |||
| */ | |||
| class ImageResize | |||
| { | |||
| const CROPTOP = 1; | |||
| const CROPCENTRE = 2; | |||
| const CROPCENTER = 2; | |||
| const CROPBOTTOM = 3; | |||
| const CROPLEFT = 4; | |||
| const CROPRIGHT = 5; | |||
| const CROPTOPCENTER = 6; | |||
| const IMG_FLIP_HORIZONTAL = 0; | |||
| const IMG_FLIP_VERTICAL = 1; | |||
| const IMG_FLIP_BOTH = 2; | |||
| public $quality_jpg = 85; | |||
| public $quality_webp = 85; | |||
| public $quality_png = 6; | |||
| public $quality_truecolor = true; | |||
| public $interlace = 1; | |||
| public $source_type; | |||
| protected $source_image; | |||
| protected $original_w; | |||
| protected $original_h; | |||
| protected $dest_x = 0; | |||
| protected $dest_y = 0; | |||
| protected $source_x; | |||
| protected $source_y; | |||
| protected $dest_w; | |||
| protected $dest_h; | |||
| protected $source_w; | |||
| protected $source_h; | |||
| protected $source_info; | |||
| protected $filters = []; | |||
| /** | |||
| * Create instance from a strng | |||
| * | |||
| * @param string $image_data | |||
| * @return ImageResize | |||
| * @throws ImageResizeException | |||
| */ | |||
| public static function createFromString($image_data) | |||
| { | |||
| if (empty($image_data) || $image_data === null) { | |||
| throw new ImageResizeException('image_data must not be empty'); | |||
| } | |||
| $resize = new self('data://application/octet-stream;base64,' . base64_encode($image_data)); | |||
| return $resize; | |||
| } | |||
| /** | |||
| * Add filter function for use right before save image to file. | |||
| * | |||
| * @param callable $filter | |||
| * @return $this | |||
| */ | |||
| public function addFilter(callable $filter) | |||
| { | |||
| $this->filters[] = $filter; | |||
| return $this; | |||
| } | |||
| /** | |||
| * Apply filters. | |||
| * | |||
| * @param $image resource an image resource identifier | |||
| * @param $filterType filter type and default value is IMG_FILTER_NEGATE | |||
| */ | |||
| protected function applyFilter($image, $filterType = IMG_FILTER_NEGATE) | |||
| { | |||
| foreach ($this->filters as $function) { | |||
| $function($image, $filterType); | |||
| } | |||
| } | |||
| /** | |||
| * Loads image source and its properties to the instanciated object | |||
| * | |||
| * @param string $filename | |||
| * @return ImageResize | |||
| * @throws ImageResizeException | |||
| */ | |||
| public function __construct($filename) | |||
| { | |||
| if (!defined('IMAGETYPE_WEBP')) { | |||
| define('IMAGETYPE_WEBP', 18); | |||
| } | |||
| if ($filename === null || empty($filename) || (substr($filename, 0, 7) !== 'data://' && !is_file($filename))) { | |||
| throw new ImageResizeException('File does not exist'); | |||
| } | |||
| $finfo = finfo_open(FILEINFO_MIME_TYPE); | |||
| if (strstr(finfo_file($finfo, $filename), 'image') === false) { | |||
| throw new ImageResizeException('Unsupported file type'); | |||
| } | |||
| if (!$image_info = getimagesize($filename, $this->source_info)) { | |||
| $image_info = getimagesize($filename); | |||
| } | |||
| if (!$image_info) { | |||
| throw new ImageResizeException('Could not read file'); | |||
| } | |||
| list( | |||
| $this->original_w, | |||
| $this->original_h, | |||
| $this->source_type | |||
| ) = $image_info; | |||
| switch ($this->source_type) { | |||
| case IMAGETYPE_GIF: | |||
| $this->source_image = imagecreatefromgif($filename); | |||
| break; | |||
| case IMAGETYPE_JPEG: | |||
| $this->source_image = $this->imageCreateJpegfromExif($filename); | |||
| // set new width and height for image, maybe it has changed | |||
| $this->original_w = ImageSX($this->source_image); | |||
| $this->original_h = ImageSY($this->source_image); | |||
| break; | |||
| case IMAGETYPE_PNG: | |||
| $this->source_image = imagecreatefrompng($filename); | |||
| break; | |||
| case IMAGETYPE_WEBP: | |||
| if (version_compare(PHP_VERSION, '5.5.0', '<')) { | |||
| throw new ImageResizeException('For WebP support PHP >= 5.5.0 is required'); | |||
| } | |||
| $this->source_image = imagecreatefromwebp($filename); | |||
| break; | |||
| default: | |||
| throw new ImageResizeException('Unsupported image type'); | |||
| } | |||
| if (!$this->source_image) { | |||
| throw new ImageResizeException('Could not load image'); | |||
| } | |||
| return $this->resize($this->getSourceWidth(), $this->getSourceHeight()); | |||
| } | |||
| // http://stackoverflow.com/a/28819866 | |||
| public function imageCreateJpegfromExif($filename) | |||
| { | |||
| $img = imagecreatefromjpeg($filename); | |||
| if (!function_exists('exif_read_data') || !isset($this->source_info['APP1']) || strpos($this->source_info['APP1'], 'Exif') !== 0) { | |||
| return $img; | |||
| } | |||
| $exif = @exif_read_data($filename); | |||
| if (!$exif || !isset($exif['Orientation'])) { | |||
| return $img; | |||
| } | |||
| $orientation = $exif['Orientation']; | |||
| if ($orientation === 6 || $orientation === 5) { | |||
| $img = imagerotate($img, 270, null); | |||
| } elseif ($orientation === 3 || $orientation === 4) { | |||
| $img = imagerotate($img, 180, null); | |||
| } elseif ($orientation === 8 || $orientation === 7) { | |||
| $img = imagerotate($img, 90, null); | |||
| } | |||
| if ($orientation === 5 || $orientation === 4 || $orientation === 7) { | |||
| if(function_exists('imageflip')) { | |||
| imageflip($img, IMG_FLIP_HORIZONTAL); | |||
| } else { | |||
| $this->imageFlip($img, IMG_FLIP_HORIZONTAL); | |||
| } | |||
| } | |||
| return $img; | |||
| } | |||
| /** | |||
| * Saves new image | |||
| * | |||
| * @param string $filename | |||
| * @param string $image_type | |||
| * @param integer $quality | |||
| * @param integer $permissions | |||
| * @return \static | |||
| */ | |||
| public function save($filename, $image_type = null, $quality = null, $permissions = null) | |||
| { | |||
| $image_type = $image_type ?: $this->source_type; | |||
| $quality = is_numeric($quality) ? (int) abs($quality) : null; | |||
| switch ($image_type) { | |||
| case IMAGETYPE_GIF: | |||
| $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); | |||
| $background = imagecolorallocatealpha($dest_image, 255, 255, 255, 1); | |||
| imagecolortransparent($dest_image, $background); | |||
| imagefill($dest_image, 0, 0, $background); | |||
| imagesavealpha($dest_image, true); | |||
| break; | |||
| case IMAGETYPE_JPEG: | |||
| $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); | |||
| $background = imagecolorallocate($dest_image, 255, 255, 255); | |||
| imagefilledrectangle($dest_image, 0, 0, $this->getDestWidth(), $this->getDestHeight(), $background); | |||
| break; | |||
| case IMAGETYPE_WEBP: | |||
| if (version_compare(PHP_VERSION, '5.5.0', '<')) { | |||
| throw new ImageResizeException('For WebP support PHP >= 5.5.0 is required'); | |||
| } | |||
| $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); | |||
| $background = imagecolorallocate($dest_image, 255, 255, 255); | |||
| imagefilledrectangle($dest_image, 0, 0, $this->getDestWidth(), $this->getDestHeight(), $background); | |||
| break; | |||
| case IMAGETYPE_PNG: | |||
| if (!$this->quality_truecolor && !imageistruecolor($this->source_image)) { | |||
| $dest_image = imagecreate($this->getDestWidth(), $this->getDestHeight()); | |||
| $background = imagecolorallocatealpha($dest_image, 255, 255, 255, 1); | |||
| imagecolortransparent($dest_image, $background); | |||
| imagefill($dest_image, 0, 0, $background); | |||
| } else { | |||
| $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); | |||
| } | |||
| imagealphablending($dest_image, false); | |||
| imagesavealpha($dest_image, true); | |||
| break; | |||
| } | |||
| imageinterlace($dest_image, $this->interlace); | |||
| imagecopyresampled( | |||
| $dest_image, | |||
| $this->source_image, | |||
| $this->dest_x, | |||
| $this->dest_y, | |||
| $this->source_x, | |||
| $this->source_y, | |||
| $this->getDestWidth(), | |||
| $this->getDestHeight(), | |||
| $this->source_w, | |||
| $this->source_h | |||
| ); | |||
| $this->applyFilter($dest_image); | |||
| switch ($image_type) { | |||
| case IMAGETYPE_GIF: | |||
| imagegif($dest_image, $filename); | |||
| break; | |||
| case IMAGETYPE_JPEG: | |||
| if ($quality === null || $quality > 100) { | |||
| $quality = $this->quality_jpg; | |||
| } | |||
| imagejpeg($dest_image, $filename, $quality); | |||
| break; | |||
| case IMAGETYPE_WEBP: | |||
| if (version_compare(PHP_VERSION, '5.5.0', '<')) { | |||
| throw new ImageResizeException('For WebP support PHP >= 5.5.0 is required'); | |||
| } | |||
| if ($quality === null) { | |||
| $quality = $this->quality_webp; | |||
| } | |||
| imagewebp($dest_image, $filename, $quality); | |||
| break; | |||
| case IMAGETYPE_PNG: | |||
| if ($quality === null || $quality > 9) { | |||
| $quality = $this->quality_png; | |||
| } | |||
| imagepng($dest_image, $filename, $quality); | |||
| break; | |||
| } | |||
| if ($permissions) { | |||
| chmod($filename, $permissions); | |||
| } | |||
| imagedestroy($dest_image); | |||
| return $this; | |||
| } | |||
| /** | |||
| * Convert the image to string | |||
| * | |||
| * @param int $image_type | |||
| * @param int $quality | |||
| * @return string | |||
| */ | |||
| public function getImageAsString($image_type = null, $quality = null) | |||
| { | |||
| $string_temp = tempnam(sys_get_temp_dir(), ''); | |||
| $this->save($string_temp, $image_type, $quality); | |||
| $string = file_get_contents($string_temp); | |||
| unlink($string_temp); | |||
| return $string; | |||
| } | |||
| /** | |||
| * Convert the image to string with the current settings | |||
| * | |||
| * @return string | |||
| */ | |||
| public function __toString() | |||
| { | |||
| return $this->getImageAsString(); | |||
| } | |||
| /** | |||
| * Outputs image to browser | |||
| * @param string $image_type | |||
| * @param integer $quality | |||
| */ | |||
| public function output($image_type = null, $quality = null) | |||
| { | |||
| $image_type = $image_type ?: $this->source_type; | |||
| header('Content-Type: ' . image_type_to_mime_type($image_type)); | |||
| $this->save(null, $image_type, $quality); | |||
| } | |||
| /** | |||
| * Resizes image according to the given short side (short side proportional) | |||
| * | |||
| * @param integer $max_short | |||
| * @param boolean $allow_enlarge | |||
| * @return \static | |||
| */ | |||
| public function resizeToShortSide($max_short, $allow_enlarge = false) | |||
| { | |||
| if ($this->getSourceHeight() < $this->getSourceWidth()) { | |||
| $ratio = $max_short / $this->getSourceHeight(); | |||
| $long = $this->getSourceWidth() * $ratio; | |||
| $this->resize($long, $max_short, $allow_enlarge); | |||
| } else { | |||
| $ratio = $max_short / $this->getSourceWidth(); | |||
| $long = $this->getSourceHeight() * $ratio; | |||
| $this->resize($max_short, $long, $allow_enlarge); | |||
| } | |||
| return $this; | |||
| } | |||
| /** | |||
| * Resizes image according to the given long side (short side proportional) | |||
| * | |||
| * @param integer $max_long | |||
| * @param boolean $allow_enlarge | |||
| * @return \static | |||
| */ | |||
| public function resizeToLongSide($max_long, $allow_enlarge = false) | |||
| { | |||
| if ($this->getSourceHeight() > $this->getSourceWidth()) { | |||
| $ratio = $max_long / $this->getSourceHeight(); | |||
| $short = $this->getSourceWidth() * $ratio; | |||
| $this->resize($short, $max_long, $allow_enlarge); | |||
| } else { | |||
| $ratio = $max_long / $this->getSourceWidth(); | |||
| $short = $this->getSourceHeight() * $ratio; | |||
| $this->resize($max_long, $short, $allow_enlarge); | |||
| } | |||
| return $this; | |||
| } | |||
| /** | |||
| * Resizes image according to the given height (width proportional) | |||
| * | |||
| * @param integer $height | |||
| * @param boolean $allow_enlarge | |||
| * @return \static | |||
| */ | |||
| public function resizeToHeight($height, $allow_enlarge = false) | |||
| { | |||
| $ratio = $height / $this->getSourceHeight(); | |||
| $width = $this->getSourceWidth() * $ratio; | |||
| $this->resize($width, $height, $allow_enlarge); | |||
| return $this; | |||
| } | |||
| /** | |||
| * Resizes image according to the given width (height proportional) | |||
| * | |||
| * @param integer $width | |||
| * @param boolean $allow_enlarge | |||
| * @return \static | |||
| */ | |||
| public function resizeToWidth($width, $allow_enlarge = false) | |||
| { | |||
| $ratio = $width / $this->getSourceWidth(); | |||
| $height = $this->getSourceHeight() * $ratio; | |||
| $this->resize($width, $height, $allow_enlarge); | |||
| return $this; | |||
| } | |||
| /** | |||
| * Resizes image to best fit inside the given dimensions | |||
| * | |||
| * @param integer $max_width | |||
| * @param integer $max_height | |||
| * @param boolean $allow_enlarge | |||
| * @return \static | |||
| */ | |||
| public function resizeToBestFit($max_width, $max_height, $allow_enlarge = false) | |||
| { | |||
| if ($this->getSourceWidth() <= $max_width && $this->getSourceHeight() <= $max_height && $allow_enlarge === false) { | |||
| return $this; | |||
| } | |||
| $ratio = $this->getSourceHeight() / $this->getSourceWidth(); | |||
| $width = $max_width; | |||
| $height = $width * $ratio; | |||
| if ($height > $max_height) { | |||
| $height = $max_height; | |||
| $width = $height / $ratio; | |||
| } | |||
| return $this->resize($width, $height, $allow_enlarge); | |||
| } | |||
| /** | |||
| * Resizes image according to given scale (proportionally) | |||
| * | |||
| * @param integer|float $scale | |||
| * @return \static | |||
| */ | |||
| public function scale($scale) | |||
| { | |||
| $width = $this->getSourceWidth() * $scale / 100; | |||
| $height = $this->getSourceHeight() * $scale / 100; | |||
| $this->resize($width, $height, true); | |||
| return $this; | |||
| } | |||
| /** | |||
| * Resizes image according to the given width and height | |||
| * | |||
| * @param integer $width | |||
| * @param integer $height | |||
| * @param boolean $allow_enlarge | |||
| * @return \static | |||
| */ | |||
| public function resize($width, $height, $allow_enlarge = false) | |||
| { | |||
| if (!$allow_enlarge) { | |||
| // if the user hasn't explicitly allowed enlarging, | |||
| // but either of the dimensions are larger then the original, | |||
| // then just use original dimensions - this logic may need rethinking | |||
| if ($width > $this->getSourceWidth() || $height > $this->getSourceHeight()) { | |||
| $width = $this->getSourceWidth(); | |||
| $height = $this->getSourceHeight(); | |||
| } | |||
| } | |||
| $this->source_x = 0; | |||
| $this->source_y = 0; | |||
| $this->dest_w = $width; | |||
| $this->dest_h = $height; | |||
| $this->source_w = $this->getSourceWidth(); | |||
| $this->source_h = $this->getSourceHeight(); | |||
| return $this; | |||
| } | |||
| /** | |||
| * Crops image according to the given width, height and crop position | |||
| * | |||
| * @param integer $width | |||
| * @param integer $height | |||
| * @param boolean $allow_enlarge | |||
| * @param integer $position | |||
| * @return \static | |||
| */ | |||
| public function crop($width, $height, $allow_enlarge = false, $position = self::CROPCENTER) | |||
| { | |||
| if (!$allow_enlarge) { | |||
| // this logic is slightly different to resize(), | |||
| // it will only reset dimensions to the original | |||
| // if that particular dimenstion is larger | |||
| if ($width > $this->getSourceWidth()) { | |||
| $width = $this->getSourceWidth(); | |||
| } | |||
| if ($height > $this->getSourceHeight()) { | |||
| $height = $this->getSourceHeight(); | |||
| } | |||
| } | |||
| $ratio_source = $this->getSourceWidth() / $this->getSourceHeight(); | |||
| $ratio_dest = $width / $height; | |||
| if ($ratio_dest < $ratio_source) { | |||
| $this->resizeToHeight($height, $allow_enlarge); | |||
| $excess_width = ($this->getDestWidth() - $width) / $this->getDestWidth() * $this->getSourceWidth(); | |||
| $this->source_w = $this->getSourceWidth() - $excess_width; | |||
| $this->source_x = $this->getCropPosition($excess_width, $position); | |||
| $this->dest_w = $width; | |||
| } else { | |||
| $this->resizeToWidth($width, $allow_enlarge); | |||
| $excess_height = ($this->getDestHeight() - $height) / $this->getDestHeight() * $this->getSourceHeight(); | |||
| $this->source_h = $this->getSourceHeight() - $excess_height; | |||
| $this->source_y = $this->getCropPosition($excess_height, $position); | |||
| $this->dest_h = $height; | |||
| } | |||
| return $this; | |||
| } | |||
| /** | |||
| * Crops image according to the given width, height, x and y | |||
| * | |||
| * @param integer $width | |||
| * @param integer $height | |||
| * @param integer $x | |||
| * @param integer $y | |||
| * @return \static | |||
| */ | |||
| public function freecrop($width, $height, $x = false, $y = false) | |||
| { | |||
| if ($x === false || $y === false) { | |||
| return $this->crop($width, $height); | |||
| } | |||
| $this->source_x = $x; | |||
| $this->source_y = $y; | |||
| if ($width > $this->getSourceWidth() - $x) { | |||
| $this->source_w = $this->getSourceWidth() - $x; | |||
| } else { | |||
| $this->source_w = $width; | |||
| } | |||
| if ($height > $this->getSourceHeight() - $y) { | |||
| $this->source_h = $this->getSourceHeight() - $y; | |||
| } else { | |||
| $this->source_h = $height; | |||
| } | |||
| $this->dest_w = $width; | |||
| $this->dest_h = $height; | |||
| return $this; | |||
| } | |||
| /** | |||
| * Gets source width | |||
| * | |||
| * @return integer | |||
| */ | |||
| public function getSourceWidth() | |||
| { | |||
| return $this->original_w; | |||
| } | |||
| /** | |||
| * Gets source height | |||
| * | |||
| * @return integer | |||
| */ | |||
| public function getSourceHeight() | |||
| { | |||
| return $this->original_h; | |||
| } | |||
| /** | |||
| * Gets width of the destination image | |||
| * | |||
| * @return integer | |||
| */ | |||
| public function getDestWidth() | |||
| { | |||
| return $this->dest_w; | |||
| } | |||
| /** | |||
| * Gets height of the destination image | |||
| * @return integer | |||
| */ | |||
| public function getDestHeight() | |||
| { | |||
| return $this->dest_h; | |||
| } | |||
| /** | |||
| * Gets crop position (X or Y) according to the given position | |||
| * | |||
| * @param integer $expectedSize | |||
| * @param integer $position | |||
| * @return integer | |||
| */ | |||
| protected function getCropPosition($expectedSize, $position = self::CROPCENTER) | |||
| { | |||
| $size = 0; | |||
| switch ($position) { | |||
| case self::CROPBOTTOM: | |||
| case self::CROPRIGHT: | |||
| $size = $expectedSize; | |||
| break; | |||
| case self::CROPCENTER: | |||
| case self::CROPCENTRE: | |||
| $size = $expectedSize / 2; | |||
| break; | |||
| case self::CROPTOPCENTER: | |||
| $size = $expectedSize / 4; | |||
| break; | |||
| } | |||
| return $size; | |||
| } | |||
| /** | |||
| * Flips an image using a given mode if PHP version is lower than 5.5 | |||
| * | |||
| * @param resource $image | |||
| * @param integer $mode | |||
| * @return null | |||
| */ | |||
| public function imageFlip($image, $mode) | |||
| { | |||
| switch($mode) { | |||
| case self::IMG_FLIP_HORIZONTAL: { | |||
| $max_x = imagesx($image) - 1; | |||
| $half_x = $max_x / 2; | |||
| $sy = imagesy($image); | |||
| $temp_image = imageistruecolor($image)? imagecreatetruecolor(1, $sy): imagecreate(1, $sy); | |||
| for ($x = 0; $x < $half_x; ++$x) { | |||
| imagecopy($temp_image, $image, 0, 0, $x, 0, 1, $sy); | |||
| imagecopy($image, $image, $x, 0, $max_x - $x, 0, 1, $sy); | |||
| imagecopy($image, $temp_image, $max_x - $x, 0, 0, 0, 1, $sy); | |||
| } | |||
| break; | |||
| } | |||
| case self::IMG_FLIP_VERTICAL: { | |||
| $sx = imagesx($image); | |||
| $max_y = imagesy($image) - 1; | |||
| $half_y = $max_y / 2; | |||
| $temp_image = imageistruecolor($image)? imagecreatetruecolor($sx, 1): imagecreate($sx, 1); | |||
| for ($y = 0; $y < $half_y; ++$y) { | |||
| imagecopy($temp_image, $image, 0, 0, 0, $y, $sx, 1); | |||
| imagecopy($image, $image, 0, $y, 0, $max_y - $y, $sx, 1); | |||
| imagecopy($image, $temp_image, 0, $max_y - $y, 0, 0, $sx, 1); | |||
| } | |||
| break; | |||
| } | |||
| case self::IMG_FLIP_BOTH: { | |||
| $sx = imagesx($image); | |||
| $sy = imagesy($image); | |||
| $temp_image = imagerotate($image, 180, 0); | |||
| imagecopy($image, $temp_image, 0, 0, 0, 0, $sx, $sy); | |||
| break; | |||
| } | |||
| default: | |||
| return null; | |||
| } | |||
| imagedestroy($temp_image); | |||
| } | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| <?php | |||
| //namespace Gumlet; | |||
| /** | |||
| * PHP Exception used in the ImageResize class | |||
| */ | |||
| class ImageResizeException extends \Exception | |||
| { | |||
| } | |||
| @@ -0,0 +1,74 @@ | |||
| <?php | |||
| Class Layout { | |||
| public $locale; | |||
| protected $config; | |||
| protected $settings; | |||
| function __construct() { | |||
| global $locale, $config; | |||
| $this->locale = $locale; | |||
| $this->config = $config; | |||
| $this->settings = $this->config['settings']; | |||
| } | |||
| public function getPage($file) { | |||
| $cache = $this->settings['cache-layout']; | |||
| $file_path = LAYOUTS_DIR.$file.'.php'; | |||
| if (file_exists($file_path)) { | |||
| if ($cache) { | |||
| return $this->cacheFile($file, $this->requireFile($file_path)); | |||
| } else { | |||
| return $this->requireFile($file_path); | |||
| } | |||
| } else { | |||
| return 'Layout file not found in '.LAYOUTS_DIR; | |||
| } | |||
| } | |||
| public function setFileTimestamp() { | |||
| $ts = ''; | |||
| if ($this->settings['debug']) { | |||
| $ts = '?t='.time(); | |||
| } | |||
| return $ts; | |||
| } | |||
| public function getPublicUri() { | |||
| $protocol = $this->settings['http-protocol']; | |||
| $domain = $_SERVER['SERVER_NAME']; | |||
| return $protocol.$domain.'/'; | |||
| } | |||
| private function requireFile($file_path) { | |||
| $ob_string = $this->config['settings']['gzip-content'] ? 'ob_gzhandler' : ''; | |||
| ob_start($ob_string); | |||
| require($file_path); | |||
| return ob_get_clean(); | |||
| } | |||
| private function cacheFile($file_name, $file_data=null) { | |||
| $cache_dir = CACHE_DIR.'Layouts/'; | |||
| if (is_writable($cache_dir)) { | |||
| $file_path = $cache_dir.$file_name.'-cache.html'; | |||
| if (!file_exists($file_path)) { | |||
| file_put_contents($file_path, $file_data); | |||
| } | |||
| return file_get_contents($file_path); | |||
| } else { | |||
| return 'Layout cache directory is not writable.'; | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,45 @@ | |||
| <?php | |||
| class Logger { | |||
| private $db; | |||
| function __construct() { | |||
| global $db; | |||
| $this->db = $db; | |||
| } | |||
| public function logUserAccess($user=null, $result=0, $msg='', $dataProvided=null) { | |||
| if (is_array($user) && !empty($user)) { | |||
| $user_id = $user['id']; | |||
| } else { | |||
| $user_id = 0; | |||
| } | |||
| $data = [ | |||
| 'user_id' => $user_id, | |||
| 'remote_ip' => $_SERVER['REMOTE_ADDR'], | |||
| 'access_result' => $result, | |||
| 'access_message' => $msg, | |||
| 'data_provided' => json_encode($dataProvided), | |||
| 'time_zone' => date_default_timezone_get(), | |||
| 'user_agent' => $_SERVER['HTTP_USER_AGENT'], | |||
| 'created_at' => date('Y-m-d H:i:s') | |||
| ]; | |||
| $this->db->insert('log_access', $data); | |||
| } | |||
| public function logUserAction($userId=0, $actionType=null, $errorMsg=null) { | |||
| $data = [ | |||
| 'user_id' => $userId, | |||
| 'remote_ip' => $_SERVER['REMOTE_ADDR'], | |||
| 'action_type' => $actionType, | |||
| 'user_agent' => $_SERVER['HTTP_USER_AGENT'], | |||
| 'error_msg' => $errorMsg, | |||
| 'created_at' => date('Y-m-d H:i:s') | |||
| ]; | |||
| $this->db->insert('log_actions', $data); | |||
| } | |||
| } | |||
| @@ -0,0 +1,37 @@ | |||
| <?php | |||
| class Media { | |||
| private $config; | |||
| function __construct() { | |||
| global $config; | |||
| $this->config = $config; | |||
| } | |||
| public function getPendingUploads($groupId=0) { | |||
| $files = glob(MEDIA_TMP_DIR.'*.info'); | |||
| $infos = []; | |||
| if (is_array($files) && !empty($files)) { | |||
| foreach($files as $file) { | |||
| $json = json_decode(file_get_contents($file), true); | |||
| if (isset($json['MetaData']['groupId'])) { | |||
| if ($json['MetaData']['groupId'] == $groupId) { | |||
| $fileName = MEDIA_TMP_DIR.$json['ID'].'.bin'; | |||
| $currentSize = filesize($fileName); | |||
| $percentage = $currentSize*100/$json['Size']; | |||
| $json['percentage'] = $percentage; | |||
| $json['lastUpdate'] = date('Y-m-d H:i:s', filemtime($fileName)); | |||
| $infos[] = $json; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return $infos; | |||
| } | |||
| } | |||
| @@ -0,0 +1,45 @@ | |||
| <?php | |||
| class MemoryCache { | |||
| private $db; | |||
| function __construct() { | |||
| global $db; | |||
| $this->db = $db; | |||
| } | |||
| public function write($key, $value=null, $expires='+10 minutes') { | |||
| $value = is_array($value) || is_object($value) || is_bool($value) ? json_encode($value) : $value; | |||
| $expireDate = date('Y-m-d H:i:s', strtotime($expires)); | |||
| $this->db->rawQuery('REPLACE INTO cache_memory SET cache_key = ?, cache_value = ?, cache_expire = ?', [$key, $value, $expireDate]); | |||
| } | |||
| public function read($key) { | |||
| $return = null; | |||
| $value = $this->db->where('cache_key', $key)->where('cache_expire >= NOW()')->getOne('cache_memory'); | |||
| if (isset($value['cache_value'])) { | |||
| $value = $value['cache_value']; | |||
| if ($this->isJson($value)) { | |||
| $return = json_decode($value, true); | |||
| } else { | |||
| $return = $value; | |||
| } | |||
| } else { | |||
| //Try to remove the expired key (if it is) | |||
| $this->remove($key); | |||
| } | |||
| return $return; | |||
| } | |||
| public function remove($key) { | |||
| return $this->db->where('cache_key', $key)->delete('cache_memory'); | |||
| } | |||
| private function isJson($string) { | |||
| return is_string($string) && is_array(json_decode($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false; | |||
| } | |||
| } | |||
| @@ -0,0 +1,86 @@ | |||
| <?php | |||
| class Security { | |||
| public $csrfTokenName; | |||
| public $passwordMinLength; | |||
| private $session; | |||
| private $config; | |||
| function __construct() { | |||
| global $session, $config; | |||
| $this->csrfTokenName = 'csrf_token'; | |||
| $this->session = $session; | |||
| $this->config = $config; | |||
| $this->passwordMinLength = $this->config['settings']['password-min-lenght']; | |||
| } | |||
| public function setCSRFToken() { | |||
| //if ($this->session->sessionExists($this->csrfTokenName)) { | |||
| if (function_exists('random_bytes')) { //Only PHP 7 | |||
| $this->session->refreshSession($this->csrfTokenName, bin2hex(random_bytes(32))); | |||
| } else { | |||
| $this->session->refreshSession($this->csrfTokenName, bin2hex(openssl_random_pseudo_bytes(32))); | |||
| } | |||
| //} | |||
| return $this->session->getSessionValue($this->csrfTokenName); | |||
| } | |||
| public function getCSRFToken() { | |||
| return $this->session->getSessionValue($this->csrfTokenName); | |||
| } | |||
| public function compareCSRFToken($token=null) { | |||
| $sessionToken = $this->getCSRFToken(); | |||
| if ($sessionToken !== false) { | |||
| return hash_equals($sessionToken, $token); | |||
| } | |||
| return false; | |||
| } | |||
| public function secureString($string, $action='e') { | |||
| $output = false; | |||
| $encryptMethod = "AES-256-CBC"; | |||
| $secretKey = $this->config['settings']['secret-key']; | |||
| $secretIv = $this->config['settings']['secret-iv']; | |||
| $key = hash('sha256', $secretKey); | |||
| $iv = substr(hash('sha256', $secretIv), 0, 16); | |||
| if ($action == 'e') { | |||
| $output = openssl_encrypt($string, $encryptMethod, $key, 0, $iv); | |||
| $output = base64_encode($output); | |||
| } else if ($action == 'd') { | |||
| $output = openssl_decrypt(base64_decode($string), $encryptMethod, $key, 0, $iv); | |||
| } | |||
| return $output; | |||
| } | |||
| public function validatePassword($password='') { | |||
| if(!preg_match( '/[^A-Za-z0-9]+/', $password) || strlen($password) < $this->passwordMinLength) { | |||
| return false; | |||
| } | |||
| return true; | |||
| } | |||
| public function getGUID() { | |||
| if (function_exists('com_create_guid') === true) { | |||
| return trim(com_create_guid(), '{}'); | |||
| } | |||
| return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,38 @@ | |||
| <?php | |||
| class Session { | |||
| public function getSessionId() { | |||
| return session_id(); | |||
| } | |||
| public function getSessionValue($key) { | |||
| if (isset($_SESSION[$key])) { | |||
| return $_SESSION[$key]; | |||
| } else { | |||
| return false; | |||
| } | |||
| } | |||
| public function refreshSession($key=null, $value=null) { | |||
| $sessionValue = ''; | |||
| if (!is_null($key)) { | |||
| if (isset($_SESSION[$key])) unset($_SESSION[$key]); | |||
| $_SESSION[$key] = $value; | |||
| $sessionValue = $_SESSION[$key]; | |||
| } | |||
| return $sessionValue; | |||
| } | |||
| public function deleteSession($key) { | |||
| if (isset($_SESSION[$key])) unset($_SESSION[$key]); | |||
| return !isset($_SESSION[$key]); | |||
| } | |||
| public function sessionExists($key) { | |||
| return isset($_SESSION[$key]); | |||
| } | |||
| } | |||
| @@ -0,0 +1,59 @@ | |||
| <?php | |||
| class SessionDBHandler implements SessionHandlerInterface { | |||
| private $db; | |||
| private $config; | |||
| function __construct() { | |||
| global $config; | |||
| $this->config = $config; | |||
| } | |||
| function open($savePath, $sessionName) { | |||
| $this->db = MysqliDb::getInstance(); | |||
| return true; | |||
| } | |||
| function close() { | |||
| return true; | |||
| } | |||
| function read($id) { | |||
| $session_data = ''; | |||
| $result = $this->db->rawQuery('SELECT session_data FROM sessions WHERE session_id = ? AND session_expires > ?', [$id, date('Y-m-d H:i:s')]); | |||
| $session_data = isset($result[0]['session_data']) && !empty($result[0]['session_data']) ? $result[0]['session_data'] : ''; | |||
| if (!is_string($session_data)) $session_data = ''; | |||
| return $session_data; | |||
| } | |||
| function write($id, $data) { | |||
| $dateTime = date('Y-m-d H:i:s'); | |||
| $expireTime = $this->config['settings']['session-expires']; | |||
| $newDateTime = date('Y-m-d H:i:s', strtotime($dateTime.' '.$expireTime)); | |||
| $this->db->rawQuery("INSERT INTO sessions (session_id, user_ip, session_expires, session_updated_at, session_data) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE session_id=?, user_ip=?, session_expires=?, session_updated_at=?, session_data=?", [$id, $_SERVER['REMOTE_ADDR'], $newDateTime, $dateTime, $data, $id, $_SERVER['REMOTE_ADDR'], $newDateTime, $dateTime, $data]); | |||
| return $this->db->getLastErrno() === 0 ? true : false; | |||
| } | |||
| function destroy($id) { | |||
| if ($this->db->where('session_id', $id)->delete('sessions')) { | |||
| return true; | |||
| } else { | |||
| return false; | |||
| } | |||
| } | |||
| function gc($maxlifetime) { | |||
| $this->db->rawQuery("DELETE FROM sessions WHERE ((UNIX_TIMESTAMP(session_expires) + ?) < ?)", [$maxlifetime, $maxlifetime]); | |||
| return $this->db->getLastErrno() === 0 ? true : false; | |||
| } | |||
| } | |||
| @@ -0,0 +1,470 @@ | |||
| <?php | |||
| Class User { | |||
| public $userSessionName; | |||
| public $avatarDir; | |||
| private $session; | |||
| private $db; | |||
| private $config; | |||
| function __construct() { | |||
| global $config, $session, $db; | |||
| $this->userSessionName = 'userSession'; | |||
| $this->db = $db; | |||
| $this->session = $session; | |||
| $this->avatarDir = AVATAR_IMG_DIR; | |||
| $this->config = $config; | |||
| } | |||
| public function login($userData=null) { | |||
| return $this->refreshUserSession($userData); | |||
| } | |||
| public function refreshUserSession($userData=null) { | |||
| if (is_array($userData) && !empty($userData)) { | |||
| if (!isset($userData['id'])) return false; | |||
| if (!isset($userData['username'])) return false; | |||
| if (!isset($userData['name'])) return false; | |||
| if (!isset($userData['surname'])) return false; | |||
| if (!isset($userData['language_default'])) return false; | |||
| if (!isset($userData['language_data'])) return false; | |||
| if (!isset($userData['country_data'])) return false; //Could be an empty array | |||
| if (!isset($userData['roles'])) return false; | |||
| if (!isset($userData['updated_at'])) return false; | |||
| if (!isset($userData['group_id'])) return false; | |||
| $roleLocale = []; | |||
| if (is_array($userData['roles'])) { | |||
| foreach($userData['roles'] as $roleItem) { | |||
| $roleLocale[$roleItem['id']] = $roleItem['role_names']; | |||
| } | |||
| } | |||
| $data['userId'] = $userData['id']; | |||
| $data['userStatus'] = $userData['status']; | |||
| $data['userUsername'] = $userData['username']; | |||
| $data['userName'] = $userData['name']; | |||
| $data['userSurname'] = $userData['surname']; | |||
| $data['userDefaultLang'] = $userData['language_default']; | |||
| $data['userDefaultString'] = isset($userData['language_data']['name_string']) ? $userData['language_data']['name_string'] : null; | |||
| $data['userCountryId'] = isset($userData['country_data']['id']) ? $userData['country_data']['id'] : 0; | |||
| $data['userCountryName'] = isset($userData['country_data']['country_name']) ? $userData['country_data']['country_name'] : ''; | |||
| $data['userCountryCode'] = isset($userData['country_data']['country_iso2_code']) ? $userData['country_data']['country_iso2_code'] : ''; | |||
| $data['userRoles'] = $userData['roles']; | |||
| $data['userRolesLocale'] = is_array($roleLocale) ? $roleLocale : []; | |||
| $data['userUpdatedAt'] = $userData['updated_at']; | |||
| $data['userGroupId'] = $userData['group_id']; | |||
| $medicalSpecialties = []; | |||
| if (isset($roleLocale[REFERRER_ROLE_ID])) { | |||
| $medicalSpecialties = $this->getMedicalSpecialties($userData['id']); | |||
| } | |||
| $data['medicalSpecialties'] = $medicalSpecialties; | |||
| $this->session->refreshSession($this->userSessionName, $data); | |||
| } | |||
| return $this->session->sessionExists($this->userSessionName); | |||
| } | |||
| public function refreshSessionField($fieldKey, $value=null) { | |||
| $userSession = $this->getUser(); | |||
| if (isset($userSession[$fieldKey])) { | |||
| $userSession[$fieldKey] = $value; | |||
| return $this->session->refreshSession($this->userSessionName, $userSession); | |||
| } | |||
| return false; | |||
| } | |||
| public function logout() { | |||
| return $this->session->deleteSession($this->userSessionName); | |||
| } | |||
| public function getValidUserData($username='') { | |||
| return $this->db->where('status', 0, '<>')->where('username', $username, 'like')->getOne('users'); | |||
| } | |||
| public function setUserMeta($user=[]) { | |||
| $user['roles'] = $this->getUserRolesDB($user['id']); | |||
| $user['country_data'] = []; | |||
| $user['language_data'] = []; | |||
| $countryData = $this->db->where('country_iso2_code', $user['country_code'])->getOne('countries'); | |||
| if (is_array($countryData) && !empty($countryData)) { | |||
| $user['country_data'] = $countryData; | |||
| } | |||
| $languageData = $this->db->where('lang_code', $user['language_default'])->getOne('users_languages'); | |||
| if (is_array($languageData) && !empty($languageData)) { | |||
| $user['language_data'] = $languageData; | |||
| } | |||
| return $user; | |||
| } | |||
| public function getUserId() { | |||
| $userData = $this->session->getSessionValue($this->userSessionName); | |||
| if (is_array($userData) && isset($userData['userId'])) return (int)$userData['userId']; | |||
| return false; | |||
| } | |||
| public function isUsernameInUse($username='') { | |||
| $return = true; | |||
| $user = $this->db->where('username', $username, 'like')->getOne('users'); | |||
| $return = is_array($user) && !empty($user) ? true : false; | |||
| return $return; | |||
| } | |||
| public function getUserStatus() { | |||
| $userData = $this->session->getSessionValue($this->userSessionName); | |||
| if (is_array($userData) && isset($userData['userStatus'])) return (int)$userData['userStatus']; | |||
| return false; | |||
| } | |||
| public function getGroupId() { | |||
| $userData = $this->session->getSessionValue($this->userSessionName); | |||
| if (is_array($userData) && isset($userData['userGroupId'])) return (int)$userData['userGroupId']; | |||
| return false; | |||
| } | |||
| public function getUserLang() { | |||
| $userData = $this->session->getSessionValue($this->userSessionName); | |||
| if (is_array($userData) && isset($userData['userDefaultLang'])) return $userData['userDefaultLang']; | |||
| return false; | |||
| } | |||
| public function getMedicalSpecialties($passedUserId=0) { | |||
| $userId = $passedUserId == 0 ? $this->getUserId() : $passedUserId; | |||
| $specialties = []; | |||
| $results = $this->db | |||
| ->where('umst.user_id', $userId) | |||
| ->join('users_medical_specialties ums', 'ums.id=umst.specialty_id', 'INNER') | |||
| ->orderBy('ums.description', 'asc') | |||
| ->get('users_medical_specialties_to umst', null, ['ums.description']); | |||
| if (is_array($results)) { | |||
| foreach($results as $result) { | |||
| $specialties[] = _($result['description']); | |||
| } | |||
| } | |||
| return $specialties; | |||
| } | |||
| public function getUser() { | |||
| if ($this->isLogged()) { | |||
| return $this->session->getSessionValue($this->userSessionName); | |||
| } else { | |||
| return false; | |||
| } | |||
| } | |||
| public function getUserField($fieldKey='') { | |||
| $user = $this->getUser(); | |||
| if ($user !== false) { | |||
| return isset($user[$fieldKey]) ? $user[$fieldKey] : false; | |||
| } | |||
| return false; | |||
| } | |||
| //Deprecated | |||
| public function getUserRoles() { | |||
| $userData = $this->session->getSessionValue($this->userSessionName); | |||
| if (is_array($userData) && isset($userData['userRoles'])) { | |||
| return $userData['userRoles']; | |||
| } | |||
| return false; | |||
| } | |||
| public function getUserRolesLocale() { | |||
| $userData = $this->session->getSessionValue($this->userSessionName); | |||
| if (is_array($userData) && isset($userData['userRolesLocale'])) { | |||
| return $userData['userRolesLocale']; | |||
| } | |||
| return false; | |||
| } | |||
| public function getUserDB($passedUserId=0) { | |||
| $userId = $passedUserId == 0 ? $this->getUserId() : $passedUserId; | |||
| if ($userId !== false) { | |||
| return $this->db->where('id', $userId)->getOne('users'); | |||
| } | |||
| return false; | |||
| } | |||
| public function getUserRolesDB($passedUserId=false) { | |||
| $userId = $passedUserId !== false ? $passedUserId : $this->getUserId(); | |||
| $roleList = []; | |||
| if ($userId !== false) { | |||
| $roles = $this->db->rawQuery("SELECT ur.id, ur.name_translations, GET_JSON_VALUE_BY_KEY(ur.name_translations, u.language_default, '".$this->config['settings']['default-lang']."') AS role_names FROM users_roles_to AS urt JOIN users_roles AS ur ON ur.id=urt.role_id JOIN users AS u on u.id=urt.user_id WHERE urt.user_id=? AND ur.role_status=?", [$userId, 1]); | |||
| if (is_array($roles) && !empty($roles)) { | |||
| foreach($roles as $index => $values) { | |||
| $roleList[$values['id']] = $values; | |||
| } | |||
| } | |||
| } | |||
| return $roleList; | |||
| } | |||
| //Deprecated (see userController) | |||
| public function getRoleList() { | |||
| return []; | |||
| $list = []; | |||
| $helper = new Helper(); | |||
| $roles = $this->getUserField('userRoles'); | |||
| if (is_array($roles) && !empty($roles)) { | |||
| foreach($roles as $role) { | |||
| $list[] = $helper->getJsonTranslation($role['name_translations'], $this->getUserLang(), $role['role_name']); | |||
| } | |||
| } | |||
| return $list; | |||
| } | |||
| public function gerRoleStringByArray($array=[]) { | |||
| $tmp = []; | |||
| $helper = new Helper(); | |||
| if (is_array($array) && !empty($array)) { | |||
| foreach($array as $item) { | |||
| $tmp[] = $helper->getJsonTranslation($item['name_translations'], $this->getUserLang(), $item['role_name']); | |||
| } | |||
| } | |||
| return implode(', ', $tmp); | |||
| } | |||
| /*public function getRoles() { | |||
| $roles = $this->db->where('id', 1, '<>')->where('role_status', 1)->orderBy('role_name', 'ASC')->get('users_roles'); | |||
| $roles = $this->db->rawQuery("SELECT ur.id, ur.name_translations, GET_JSON_VALUE_BY_KEY(ur.name_translations, u.language_default, ?) AS role_names FROM users_roles_to AS urt JOIN users_roles AS ur ON ur.id=urt.role_id JOIN users AS u on u.id=urt.user_id WHERE urt.user_id=? AND ur.role_status=?", [$this->config['settings']['default-lang'], $userId, 1]); | |||
| if (is_array($roles) && !empty($roles)) { | |||
| $helper = new Helper(); | |||
| foreach($roles as $index => $role) { | |||
| $roles[$index]['role_name'] = $helper->getJsonTranslation($role['name_translations'], $this->getUserLang(), $role['role_name']); | |||
| } | |||
| } | |||
| return !(empty($roles) && is_array($roles)) ? $roles : false; | |||
| }*/ | |||
| public function getRoles() { | |||
| $list = []; | |||
| $roles = $this->db->where('r.role_status', 1)->where('r.id', 1, '<>')->orderBy('role_name', 'asc')->get('users_roles r', null, ["r.id", "GET_JSON_VALUE_BY_KEY(r.name_translations, '".$this->getLanguage()."', '".$this->config['settings']['default-lang']."') role_name"]); | |||
| if (is_array($roles) && !empty($roles)) { | |||
| foreach($roles as $role) { | |||
| $list[$role['id']] = $role['role_name']; | |||
| } | |||
| } | |||
| return $list; | |||
| } | |||
| public function getUserAltLangsDB($passedUserId=0) { | |||
| $userId = $passedUserId == 0 ? $this->getUserId() : $passedUserId; | |||
| $altLangList = []; | |||
| if ($userId !== false) { | |||
| $altLangs = $this->db->rawQuery("SELECT ul.* FROM users_languages_to AS ult JOIN users_languages AS ul ON ul.id=ult.language_id WHERE ult.user_id=?", [$userId]); | |||
| if (is_array($altLangs) && !empty($altLangs)) { | |||
| foreach($altLangs as $index => $values) { | |||
| $altLangList[$values['id']] = $values; | |||
| } | |||
| } | |||
| } | |||
| return $altLangList; | |||
| } | |||
| public function disclaimerAccepted() { | |||
| $userId = $this->getUserId(); | |||
| $result = $this->db->where('id', $userId)->getOne('users'); | |||
| return $result['disclaimers_accepted'] && (int)$result['disclaimers_accepted'] > 0 ? true : false; | |||
| } | |||
| public function isLogged() { | |||
| return $this->session->sessionExists($this->userSessionName); | |||
| } | |||
| public function removeUserSession() { | |||
| return $this->session->deleteSession($this->userSessionName); | |||
| } | |||
| public function setUserIdSessionField() { | |||
| $userId = $this->getUserId(); | |||
| $sessionId = $this->session->getSessionId(); | |||
| if ($userId !== false) { | |||
| $this->db->where('session_id', $sessionId); | |||
| if ($this->db->update('sessions', ['user_id' => $userId, 'session_updated_at' => date('Y-m-d H:i:s')])) { | |||
| return true; | |||
| } else { | |||
| return false; | |||
| } | |||
| } | |||
| } | |||
| public function removeAllUserSessionRecords($passedUserId=0) { | |||
| $this->db->where('user_id', $passedUserId); | |||
| return $this->db->delete('sessions'); | |||
| } | |||
| public function getLanguage() { | |||
| return $this->getUserField('userDefaultLang'); | |||
| } | |||
| public function setDisplayName($passedUser=[]) { | |||
| $user = (empty($passedUser) || !is_array($passedUser)) ? $this->getUser() : $passedUser; | |||
| $helper = new Helper(); | |||
| if ($user !== false) { | |||
| return $helper->setDottedFullname($user['userName'], $user['userSurname']); | |||
| } | |||
| return ''; | |||
| } | |||
| public function is($roleIds=null) { | |||
| $userRoles = $this->getUserRoles(); | |||
| if (is_array($roleIds)) { | |||
| foreach($roleIds as $roleId) { | |||
| if (isset($userRoles[$roleId])) { | |||
| return true; | |||
| } | |||
| } | |||
| } else if (is_integer($roleIds)) { | |||
| return isset($userRoles[$roleIds]); | |||
| } | |||
| return false; | |||
| } | |||
| public function hasOneRole($roleId=0) { | |||
| $userRoles = $this->getUserRoles(); | |||
| if (count($userRoles) == 1 && isset($userRoles[$roleId])) return true; | |||
| return false; | |||
| } | |||
| public function checkPermissions($allowedRoles=[]) { | |||
| $user = $this->getUser(); | |||
| if (is_array($allowedRoles)) { | |||
| foreach($allowedRoles as $roleId) { | |||
| if (isset($user['userRoles'][$roleId])) { | |||
| return true; | |||
| } | |||
| } | |||
| } | |||
| return false; | |||
| } | |||
| public function setAvatar($passedUserId=0, $tmpFileName=null) { | |||
| try { | |||
| $userId = $passedUserId == 0 ? $this->getUserId() : $passedUserId; | |||
| $image = new ImageResize($tmpFileName); | |||
| $image->quality_jpg = $this->config['settings']['avatar-jpg-quality']; | |||
| $image->resizeToBestFit($this->config['settings']['avatar-width'], $this->config['settings']['avatar-height']); | |||
| $fileName = $userId.'.jpg'; | |||
| $fileNamePath = AVATAR_IMG_DIR.$fileName; | |||
| if (file_exists($fileNamePath)) { | |||
| @unlink($fileNamePath); | |||
| } | |||
| @unlink($tmpFileName); | |||
| $image->save($fileNamePath, IMAGETYPE_JPEG); | |||
| return true; | |||
| } catch (ImageResizeException $e) { | |||
| return false; | |||
| } | |||
| return false; | |||
| } | |||
| public function getAvatar($passedUserId=0) { | |||
| $userId = $passedUserId == 0 ? $this->getUserId() : $passedUserId; | |||
| $fileName = $userId.'.jpg'; | |||
| $fileNamePath = AVATAR_IMG_DIR.$fileName; | |||
| $uri = $this->config['settings']['avatar-uri']; | |||
| if (file_exists($fileNamePath)) { | |||
| return $uri.$fileName; | |||
| } else { | |||
| return $uri.$this->config['settings']['avatar-default']; | |||
| } | |||
| } | |||
| public function deleteAvatar($passedUserId=0) { | |||
| $userId = $passedUserId == 0 ? $this->getUserId() : $passedUserId; | |||
| $fileName = $userId.'.jpg'; | |||
| $fileNamePath = AVATAR_IMG_DIR.$fileName; | |||
| $uri = $this->config['settings']['avatar-uri']; | |||
| if (file_exists($fileNamePath)) { | |||
| @unlink($fileNamePath); | |||
| } | |||
| return !file_exists($fileNamePath); | |||
| } | |||
| public function getDefaultAvatar() { | |||
| $uri = $this->config['settings']['avatar-uri']; | |||
| $image = $this->config['settings']['avatar-default']; | |||
| return $uri.$image; | |||
| } | |||
| public function hasAvatar($passedUserId=0) { | |||
| $userId = $passedUserId == 0 ? $this->getUserId() : $passedUserId; | |||
| $fileName = $userId.'.jpg'; | |||
| $fileNamePath = AVATAR_IMG_DIR.$fileName; | |||
| return file_exists($fileNamePath); | |||
| } | |||
| } | |||
| @@ -0,0 +1,389 @@ | |||
| <?php | |||
| class Utility { | |||
| private $user; | |||
| function __construct() { | |||
| global $user; | |||
| $this->user = $user; | |||
| } | |||
| public function setHash($destination='') { | |||
| return '#/'.$destination; | |||
| } | |||
| public function validateEmail($email='') { | |||
| return filter_var($email, FILTER_VALIDATE_EMAIL); | |||
| } | |||
| public function setDateToIsoFormat($string='', $separator='/') { | |||
| $iso = null; | |||
| if (strpos($string, $separator) !== false) { | |||
| $tmp = explode($separator, $string); | |||
| if (is_array($tmp) && !empty($tmp)) { | |||
| $y = trim($tmp[2]); | |||
| $m = trim($tmp[1]); | |||
| $d = trim($tmp[0]); | |||
| if (checkdate((int)$m, (int)$d, (int)$y)) { | |||
| $iso = $y.'-'.$m.'-'.$d; | |||
| } | |||
| } | |||
| } | |||
| return $iso; | |||
| } | |||
| public function setDateToItalianFormat($string='', $separator='-') { | |||
| $date = null; | |||
| if (strpos($string, $separator) !== false) { | |||
| $tmp = explode($separator, $string); | |||
| if (is_array($tmp) && !empty($tmp)) { | |||
| $y = trim($tmp[0]); | |||
| $m = trim($tmp[1]); | |||
| $d = trim($tmp[2]); | |||
| if (checkdate((int)$m, (int)$d, (int)$y)) { | |||
| $date = $d.'/'.$m.'/'.$y; | |||
| } | |||
| } | |||
| } | |||
| return $date; | |||
| } | |||
| public function isValidDate($date='', $format='Y-m-d') { | |||
| $d = DateTime::createFromFormat($format, $date); | |||
| return $d && $d->format($format) === $date; | |||
| } | |||
| public function formatNumber($float=0, $decimals=0) { | |||
| $lang = $this->user->getUserLang(); | |||
| if ($lang == 'en') { | |||
| $format = number_format($float, $decimals, '.', ','); | |||
| } else { | |||
| $format = number_format($float, $decimals, ',', '.'); | |||
| } | |||
| return $format; | |||
| } | |||
| public function isDateInThePast($iso_date) { | |||
| $date = new DateTime($iso_date); | |||
| $now = new DateTime(); | |||
| if ($date < $now) { | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| public function getAge($date='') { | |||
| $from = new DateTime($date); | |||
| $to = new DateTime('today'); | |||
| return $from->diff($to)->y; | |||
| } | |||
| public function orderArray($array=[], $key='', $dir='asc', $type='regular') { | |||
| $tmp = []; | |||
| $ordered = []; | |||
| $returnArray = []; | |||
| $sortType = SORT_REGULAR; | |||
| if (is_array($array) && !empty($array)) { | |||
| foreach($array as $item) { | |||
| $ordered[$item[$key]] = $item; | |||
| } | |||
| switch($type) { | |||
| case 'numeric': | |||
| $sortType = SORT_NUMERIC; | |||
| break; | |||
| case 'string': | |||
| $sortType = SORT_STRING; | |||
| break; | |||
| } | |||
| if ($dir == 'asc') { | |||
| ksort($ordered, $sortType); | |||
| } else { | |||
| krsort($ordered, $sortType); | |||
| } | |||
| } | |||
| if (!empty($ordered)) { | |||
| foreach($ordered as $item) { | |||
| $returnArray[] = $item; | |||
| } | |||
| } | |||
| return $returnArray; | |||
| } | |||
| public function slugify($text='') { | |||
| // replace non letter or digits by - | |||
| $text = preg_replace('~[^\pL\d]+~u', '-', $text); | |||
| // transliterate | |||
| $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); | |||
| // remove unwanted characters | |||
| $text = preg_replace('~[^-\w]+~', '', $text); | |||
| // trim | |||
| $text = trim($text, '-'); | |||
| // remove duplicate - | |||
| $text = preg_replace('~-+~', '-', $text); | |||
| // lowercase | |||
| //$text = strtolower($text); | |||
| if (empty($text)) { | |||
| return 'n-a'; | |||
| } | |||
| return $text; | |||
| } | |||
| public function deepTrim($element){ | |||
| if(!is_array($element)){ | |||
| if(!is_bool($element)){ | |||
| if(is_null($element)) return $element; | |||
| if(is_int($element)) return (int)trim($element); | |||
| if(is_float($element)) return (float)trim($element); | |||
| return trim($element); | |||
| } else { // is_bool | |||
| // no-op | |||
| } | |||
| } else { // is_array | |||
| foreach($element as $key => $value){ | |||
| $element[$key] = $this->deepTrim($value); | |||
| } | |||
| } | |||
| return $element; | |||
| } | |||
| public function sureHtml($str, $flag=ENT_QUOTES, $encoding='UTF-8', $allowed_tags=null){ | |||
| return strip_tags(htmlspecialchars($str, $flag, $encoding), $allowed_tags); | |||
| } | |||
| public function mime2ext($mime) { | |||
| $mime_map = [ | |||
| 'video/3gpp2' => '3g2', | |||
| 'video/3gp' => '3gp', | |||
| 'video/3gpp' => '3gp', | |||
| 'application/x-compressed' => '7zip', | |||
| 'audio/x-acc' => 'aac', | |||
| 'audio/ac3' => 'ac3', | |||
| 'application/postscript' => 'ai', | |||
| 'audio/x-aiff' => 'aif', | |||
| 'audio/aiff' => 'aif', | |||
| 'audio/x-au' => 'au', | |||
| 'video/x-msvideo' => 'avi', | |||
| 'video/msvideo' => 'avi', | |||
| 'video/avi' => 'avi', | |||
| 'application/x-troff-msvideo' => 'avi', | |||
| 'application/macbinary' => 'bin', | |||
| 'application/mac-binary' => 'bin', | |||
| 'application/x-binary' => 'bin', | |||
| 'application/x-macbinary' => 'bin', | |||
| 'image/bmp' => 'bmp', | |||
| 'image/x-bmp' => 'bmp', | |||
| 'image/x-bitmap' => 'bmp', | |||
| 'image/x-xbitmap' => 'bmp', | |||
| 'image/x-win-bitmap' => 'bmp', | |||
| 'image/x-windows-bmp' => 'bmp', | |||
| 'image/ms-bmp' => 'bmp', | |||
| 'image/x-ms-bmp' => 'bmp', | |||
| 'application/bmp' => 'bmp', | |||
| 'application/x-bmp' => 'bmp', | |||
| 'application/x-win-bitmap' => 'bmp', | |||
| 'application/cdr' => 'cdr', | |||
| 'application/coreldraw' => 'cdr', | |||
| 'application/x-cdr' => 'cdr', | |||
| 'application/x-coreldraw' => 'cdr', | |||
| 'image/cdr' => 'cdr', | |||
| 'image/x-cdr' => 'cdr', | |||
| 'zz-application/zz-winassoc-cdr' => 'cdr', | |||
| 'application/mac-compactpro' => 'cpt', | |||
| 'application/pkix-crl' => 'crl', | |||
| 'application/pkcs-crl' => 'crl', | |||
| 'application/x-x509-ca-cert' => 'crt', | |||
| 'application/pkix-cert' => 'crt', | |||
| 'text/css' => 'css', | |||
| 'text/x-comma-separated-values' => 'csv', | |||
| 'text/comma-separated-values' => 'csv', | |||
| 'application/vnd.msexcel' => 'csv', | |||
| 'application/x-director' => 'dcr', | |||
| 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx', | |||
| 'application/x-dvi' => 'dvi', | |||
| 'message/rfc822' => 'eml', | |||
| 'application/x-msdownload' => 'exe', | |||
| 'video/x-f4v' => 'f4v', | |||
| 'audio/x-flac' => 'flac', | |||
| 'video/x-flv' => 'flv', | |||
| 'image/gif' => 'gif', | |||
| 'application/gpg-keys' => 'gpg', | |||
| 'application/x-gtar' => 'gtar', | |||
| 'application/x-gzip' => 'gzip', | |||
| 'application/mac-binhex40' => 'hqx', | |||
| 'application/mac-binhex' => 'hqx', | |||
| 'application/x-binhex40' => 'hqx', | |||
| 'application/x-mac-binhex40' => 'hqx', | |||
| 'text/html' => 'html', | |||
| 'image/x-icon' => 'ico', | |||
| 'image/x-ico' => 'ico', | |||
| 'image/vnd.microsoft.icon' => 'ico', | |||
| 'text/calendar' => 'ics', | |||
| 'application/java-archive' => 'jar', | |||
| 'application/x-java-application' => 'jar', | |||
| 'application/x-jar' => 'jar', | |||
| 'image/jp2' => 'jp2', | |||
| 'video/mj2' => 'jp2', | |||
| 'image/jpx' => 'jp2', | |||
| 'image/jpm' => 'jp2', | |||
| 'image/jpeg' => 'jpeg', | |||
| 'image/pjpeg' => 'jpeg', | |||
| 'application/x-javascript' => 'js', | |||
| 'application/json' => 'json', | |||
| 'text/json' => 'json', | |||
| 'application/vnd.google-earth.kml+xml' => 'kml', | |||
| 'application/vnd.google-earth.kmz' => 'kmz', | |||
| 'text/x-log' => 'log', | |||
| 'audio/x-m4a' => 'm4a', | |||
| 'application/vnd.mpegurl' => 'm4u', | |||
| 'audio/midi' => 'mid', | |||
| 'application/vnd.mif' => 'mif', | |||
| 'video/quicktime' => 'mov', | |||
| 'video/x-sgi-movie' => 'movie', | |||
| 'audio/mpeg' => 'mp3', | |||
| 'audio/mpg' => 'mp3', | |||
| 'audio/mpeg3' => 'mp3', | |||
| 'audio/mp3' => 'mp3', | |||
| 'video/mp4' => 'mp4', | |||
| 'video/mpeg' => 'mpeg', | |||
| 'application/oda' => 'oda', | |||
| 'audio/ogg' => 'ogg', | |||
| 'video/ogg' => 'ogg', | |||
| 'application/ogg' => 'ogg', | |||
| 'application/x-pkcs10' => 'p10', | |||
| 'application/pkcs10' => 'p10', | |||
| 'application/x-pkcs12' => 'p12', | |||
| 'application/x-pkcs7-signature' => 'p7a', | |||
| 'application/pkcs7-mime' => 'p7c', | |||
| 'application/x-pkcs7-mime' => 'p7c', | |||
| 'application/x-pkcs7-certreqresp' => 'p7r', | |||
| 'application/pkcs7-signature' => 'p7s', | |||
| 'application/pdf' => 'pdf', | |||
| 'application/octet-stream' => 'pdf', | |||
| 'application/x-x509-user-cert' => 'pem', | |||
| 'application/x-pem-file' => 'pem', | |||
| 'application/pgp' => 'pgp', | |||
| 'application/x-httpd-php' => 'php', | |||
| 'application/php' => 'php', | |||
| 'application/x-php' => 'php', | |||
| 'text/php' => 'php', | |||
| 'text/x-php' => 'php', | |||
| 'application/x-httpd-php-source' => 'php', | |||
| 'image/png' => 'png', | |||
| 'image/x-png' => 'png', | |||
| 'application/powerpoint' => 'ppt', | |||
| 'application/vnd.ms-powerpoint' => 'ppt', | |||
| 'application/vnd.ms-office' => 'ppt', | |||
| 'application/msword' => 'doc', | |||
| 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'pptx', | |||
| 'application/x-photoshop' => 'psd', | |||
| 'image/vnd.adobe.photoshop' => 'psd', | |||
| 'audio/x-realaudio' => 'ra', | |||
| 'audio/x-pn-realaudio' => 'ram', | |||
| 'application/x-rar' => 'rar', | |||
| 'application/rar' => 'rar', | |||
| 'application/x-rar-compressed' => 'rar', | |||
| 'audio/x-pn-realaudio-plugin' => 'rpm', | |||
| 'application/x-pkcs7' => 'rsa', | |||
| 'text/rtf' => 'rtf', | |||
| 'text/richtext' => 'rtx', | |||
| 'video/vnd.rn-realvideo' => 'rv', | |||
| 'application/x-stuffit' => 'sit', | |||
| 'application/smil' => 'smil', | |||
| 'text/srt' => 'srt', | |||
| 'image/svg+xml' => 'svg', | |||
| 'application/x-shockwave-flash' => 'swf', | |||
| 'application/x-tar' => 'tar', | |||
| 'application/x-gzip-compressed' => 'tgz', | |||
| 'image/tiff' => 'tiff', | |||
| 'text/plain' => 'txt', | |||
| 'text/x-vcard' => 'vcf', | |||
| 'application/videolan' => 'vlc', | |||
| 'text/vtt' => 'vtt', | |||
| 'audio/x-wav' => 'wav', | |||
| 'audio/wave' => 'wav', | |||
| 'audio/wav' => 'wav', | |||
| 'application/wbxml' => 'wbxml', | |||
| 'video/webm' => 'webm', | |||
| 'audio/x-ms-wma' => 'wma', | |||
| 'application/wmlc' => 'wmlc', | |||
| 'video/x-ms-wmv' => 'wmv', | |||
| 'video/x-ms-asf' => 'wmv', | |||
| 'application/xhtml+xml' => 'xhtml', | |||
| 'application/excel' => 'xl', | |||
| 'application/msexcel' => 'xls', | |||
| 'application/x-msexcel' => 'xls', | |||
| 'application/x-ms-excel' => 'xls', | |||
| 'application/x-excel' => 'xls', | |||
| 'application/x-dos_ms_excel' => 'xls', | |||
| 'application/xls' => 'xls', | |||
| 'application/x-xls' => 'xls', | |||
| 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx', | |||
| 'application/vnd.ms-excel' => 'xlsx', | |||
| 'application/xml' => 'xml', | |||
| 'text/xml' => 'xml', | |||
| 'text/xsl' => 'xsl', | |||
| 'application/xspf+xml' => 'xspf', | |||
| 'application/x-compress' => 'z', | |||
| 'application/x-zip' => 'zip', | |||
| 'application/zip' => 'zip', | |||
| 'application/x-zip-compressed' => 'zip', | |||
| 'application/s-compressed' => 'zip', | |||
| 'multipart/x-zip' => 'zip', | |||
| 'text/x-scriptzsh' => 'zsh', | |||
| ]; | |||
| return isset($mime_map[$mime]) === true ? $mime_map[$mime] : false; | |||
| } | |||
| public function splitWords($string, $limit=2) { | |||
| $tmp = explode(' ', $string); | |||
| $words = []; | |||
| if (is_array($tmp)) { | |||
| foreach($tmp as $word) { | |||
| $word = trim($word); | |||
| if (strlen($word) > $limit) { | |||
| if (strpos($word, "'") !== false) { | |||
| $pos = strpos($word, "'"); | |||
| $word = substr($word, $pos+1); | |||
| } | |||
| if (strlen($word) > $limit) | |||
| $words[] = trim($word); | |||
| } | |||
| } | |||
| } | |||
| return $words; | |||
| } | |||
| } | |||
| @@ -0,0 +1,197 @@ | |||
| <?php | |||
| class l18n { | |||
| public $supportedLanguages; | |||
| public $defaultLanguage; | |||
| public $defaultLocale; | |||
| private $cookie; | |||
| private $config; | |||
| private $session; | |||
| private $memoryCache; | |||
| private $cacheKey; | |||
| private $cookieLng; | |||
| private $user; | |||
| function __construct() { | |||
| global $config, $memoryCache, $user, $session, $cookie, $db; | |||
| $this->config = $config; | |||
| $this->db = $db; | |||
| $this->memoryCache = $memoryCache; | |||
| $this->defaultLanguage = $this->config['settings']['default-lang']; | |||
| $this->defaultLocale = $this->config['settings']['default-locale']; | |||
| $this->user = $user; | |||
| $this->cookie = $cookie; | |||
| $this->session = $session; | |||
| $this->cacheKey = 'sprtdLngs'; //Supported Languages memory cache key | |||
| $this->cookieLng = 'usrLng'; | |||
| $this->supportedLanguages = $this->getSupportedLanguages(); | |||
| } | |||
| public function getLanguages() { | |||
| return $this->supportedLanguages; | |||
| } | |||
| public function getLanguageStringList() { | |||
| $languages = array(); | |||
| if (is_array($this->supportedLanguages)) { | |||
| foreach($this->supportedLanguages as $item) { | |||
| $selected = $item['lang_code'] == $this->setCurrentLanguage() ? true : false; | |||
| $languages[] = ['code'=>$item['lang_code'], 'string'=>$item['name_string'], 'selected'=>$selected]; | |||
| } | |||
| } | |||
| return $languages; | |||
| } | |||
| public function getLangNameByCode($langCode='') { | |||
| $languages = $this->getLanguageStringList(); | |||
| if (is_array($languages)) { | |||
| foreach($languages as $language) { | |||
| if ($language['code'] == $langCode) return $language['string']; | |||
| } | |||
| } | |||
| return $langCode; | |||
| } | |||
| public function gerLangStringByArray($array=[]) { | |||
| $tmp = []; | |||
| if (is_array($array) && !empty($array)) { | |||
| foreach($array as $item) { | |||
| $tmp[] = $item['name_string']; | |||
| } | |||
| } | |||
| return implode(', ', $tmp); | |||
| } | |||
| public function getLocale($langCode) { | |||
| $currentLocale = $this->defaultLocale; | |||
| if (is_array($this->supportedLanguages)) { | |||
| foreach($this->supportedLanguages as $values) { | |||
| if ($langCode == $values['lang_code']) return $values['locale_string']; | |||
| } | |||
| } | |||
| return $currentLocale; | |||
| } | |||
| public function setCurrentLanguage($passedLanguage='') { | |||
| if ($this->user->isLogged()) { | |||
| $userLng = $this->user->getLanguage(); | |||
| if ($userLng !== false) { | |||
| $this->setLocaleEnvironment($this->getLocale($userLng)); | |||
| return $userLng; | |||
| } | |||
| } | |||
| if ($passedLanguage == '') { | |||
| $cookieLng = $this->cookie->readCookie($this->cookieLng); | |||
| if ($cookieLng === false) { | |||
| $language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); | |||
| } else { | |||
| $language = $cookieLng; | |||
| } | |||
| $this->setLocaleEnvironment($this->getLocale($language)); | |||
| return $language; | |||
| } else { | |||
| if ($this->filterValidLanguage($passedLanguage)) { | |||
| $this->cookie->refreshCookie($this->cookieLng, $passedLanguage, strtotime('+10 years')); | |||
| $this->setLocaleEnvironment($this->getLocale($passedLanguage)); | |||
| return $passedLanguage; | |||
| } else { | |||
| //Delete cookie if it exists and set default values | |||
| $this->cookie->deleteCookie($this->cookieLng); | |||
| } | |||
| } | |||
| $this->setLocaleEnvironment($this->getLocale($this->defaultLanguage)); | |||
| return $this->defaultLanguage; | |||
| } | |||
| public function filterValidLanguage($language) { | |||
| if ($this->checkLanguage($language)) { | |||
| return $language; | |||
| } else { | |||
| return $this->defaultLanguage; | |||
| } | |||
| } | |||
| public function checkLanguage($language) { | |||
| if (is_array($this->supportedLanguages)) { | |||
| foreach($this->supportedLanguages as $values) { | |||
| if ($language == $values['lang_code']) return true; | |||
| } | |||
| } | |||
| return false; | |||
| } | |||
| public function getCountries($selectedId=0) { | |||
| $countries = $this->db->orderBy('country_name', 'ASC')->get('countries'); | |||
| foreach($countries as $index => $country) { | |||
| $countries[$index]['selected'] = $country['id'] == $selectedId ? true : false; | |||
| } | |||
| return $countries; | |||
| } | |||
| public function getCountriesByISO2Code($selectedISO2Code='') { | |||
| $countries = $this->db->orderBy('country_name', 'ASC')->get('countries'); | |||
| foreach($countries as $index => $country) { | |||
| $countries[$index]['selected'] = $country['country_iso2_code'] == $selectedISO2Code ? true : false; | |||
| } | |||
| return $countries; | |||
| } | |||
| public function getPhoneCodes($slectedPhoneCode='') { | |||
| $countries = $this->db->orderBy('country_name', 'ASC')->get('countries'); | |||
| $phoneCodes = []; | |||
| foreach($countries as $index => $country) { | |||
| $phoneCodes[$index]['phonecode'] = $country['country_phonecode']; | |||
| $phoneCodes[$index]['countryName'] = $country['country_name']; | |||
| $phoneCodes[$index]['selected'] = $country['country_phonecode'] == $slectedPhoneCode ? true : false; | |||
| } | |||
| return $phoneCodes; | |||
| } | |||
| public function getSupportedLanguages() { | |||
| $supportedLanguages = $this->memoryCache->read($this->cacheKey); | |||
| if (is_null($supportedLanguages)) { | |||
| $supportedLanguages = $this->db->orderBy('name_string', 'ASC')->get('users_languages'); | |||
| $this->memoryCache->write($this->cacheKey, $supportedLanguages, '+1 year'); | |||
| } | |||
| return $supportedLanguages; | |||
| } | |||
| public function setLocaleEnvironment($locale) { | |||
| $domain = 'messages'; | |||
| $locale = $locale.'.UTF-8'; | |||
| putenv('LC_ALL='.$locale); | |||
| setlocale(LC_ALL, $locale); | |||
| bindtextdomain($domain, LOCALE_DIR); | |||
| textdomain($domain); | |||
| setlocale(LC_TIME, $locale); | |||
| bind_textdomain_codeset($domain, 'UTF-8'); | |||
| } | |||
| } | |||
| @@ -0,0 +1,271 @@ | |||
| <?php | |||
| class centerController extends mainController { | |||
| function __construct() { | |||
| parent::__construct(); | |||
| //To change for every Controllers | |||
| $this->viewDir = 'Center'; | |||
| //$this->allow = []; | |||
| } | |||
| public function index(){ | |||
| if(!isset($this->user->getRoles()[ADMIN_ROLE_ID])) | |||
| return $this->setRawJsonResponse('err', _('Access denied.'), [], ['button'=>'goto', 'destination'=>'dashboard']); | |||
| $this->actionTitle = _("Clinical center"); | |||
| $user_id = $this->user->getUserId(); | |||
| $center_id = $this->getPost('center_id', 0); | |||
| $this->view->centerId = $center_id; | |||
| $this->view->isEditing = $center_id == 0 ? false : true; | |||
| $center_data = null; | |||
| if($this->view->isEditing){ | |||
| $center_data = $this->db->where('id', $center_id)->getOne('clinical_centers'); | |||
| if($center_data == null) | |||
| return $this->setRawJsonResponse('err', 'Access denied.', [], ['button'=>'goto', 'destination'=>'dashboard']); | |||
| // centerData['medical_specialties'] => [[index] => specialty_id] | |||
| $center_data['medical_specialties'] = $this->db->where('center_id', $center_id)->getValue('clinical_center_medical_specialties_to', 'specialty_id', null); | |||
| } | |||
| $this->view->centerData = $center_data; | |||
| $this->view->continents = array_merge([0=>['code'=>null, 'name'=>'...']], $this->db->get('continents')); | |||
| if($this->view->isEditing){ | |||
| $this->view->countries = $this->db | |||
| ->orderBy('country_name', 'ASC') | |||
| ->where('continent_iso2_code', $center_data['continent_code']) | |||
| ->get('countries', null, ['country_iso2_code as code', 'country_name as name']); | |||
| } | |||
| $this->view->allSpecialties = $this->db | |||
| ->orderBy('description', 'ASC') | |||
| ->get('users_medical_specialties'); // [index] => [id, description, status] | |||
| //$this->view->DEBUG = 'NULL'; | |||
| return $this->setJsonView('index'); | |||
| } | |||
| // Ajax function: dynamic loading of the Countries select by Continent | |||
| public function filterCountries() { | |||
| $continent_code = $this->getPost('continent_code', null); | |||
| if($this->db->where('code', $continent_code)->getOne('continents') == null){ | |||
| return $this->setRawJsonResponse('err', $continent_code . ': ' . _('invalid continent code.'), [], []); | |||
| } | |||
| $countries = []; | |||
| $countries_db = $this->db | |||
| ->orderBy('country_name', 'ASC') | |||
| ->where('continent_iso2_code', $continent_code) | |||
| ->get('countries', null, ['country_iso2_code as code', 'country_name as name']); | |||
| foreach ($countries_db as $country) { | |||
| $countries[$country['code']] = $country['name']; | |||
| } | |||
| return $this->setRawJsonResponse('ok', '', ['countries'=>$countries]); | |||
| } | |||
| // Main function for Clinical Center saving and updating | |||
| public function centerSave(){ | |||
| // Check: only Administrator can save | |||
| if(!isset($this->user->getRoles()[ADMIN_ROLE_ID])) | |||
| return $this->setRawJsonResponse('err', _('Save denied.'), [], ['button'=>'goto', 'destination'=>'dashboard']); | |||
| $now = date('Y-m-d H:i:s'); | |||
| $user_id = $this->user->getUserId(); | |||
| $data = $this->getPost('data', null); | |||
| $center_id = $data['center_id']['value']; | |||
| // Check: modify a clinical center only if exists | |||
| if($center_id != 0 && $this->db->where('id', $center_id)->getOne('clinical_centers') == null) | |||
| return $this->setRawJsonResponse('err', _('Save denied.'), [], ['button'=>'goto', 'destination'=>'dashboard']); | |||
| $center_validate_data = []; | |||
| $center_validate_data = $this->centerValidate($data); | |||
| $specialties_validate_data = []; | |||
| $devices_validate_data = []; | |||
| $this->view->DEBUG = $center_validate_data; | |||
| return $this->setJsonView('centerSave'); | |||
| if(isset($center_validate_data['ok'])){ | |||
| //unset($center_validate_data['ok']['center_id']); | |||
| $specialties_validate_data = $center_validate_data['ok']['medical_specialties']; | |||
| unset($center_validate_data['ok']['medical_specialties']); | |||
| $center_validate_data['ok']['updated_by'] = $user_id; | |||
| $center_validate_data['ok']['updated_at'] = $now; | |||
| //$this->view->DEBUG = $center_validate_data; | |||
| //return $this->setJsonView('centerSave'); | |||
| if($center_id == 0){ // INSERT | |||
| $center_validate_data['ok']['created_by'] = $user_id; | |||
| $center_validate_data['ok']['created_at'] = $now; | |||
| $center_id = $this->db->insert('clinical_centers', $center_validate_data['ok']); | |||
| if($center_id) return $this->setRawJsonResponse('ok', _('Clinical center created successfully.'), [], ['button'=>'goto', 'destination'=>'centers/'.time()]); | |||
| else return $this->setRawJsonResponse('err', _('Clinical center insert error.'), [], ['button'=>'goto', 'destination'=>'centers/'.time()]); | |||
| } else { // UPDATE | |||
| if($this->db->where('id', $center_id)->update('clinical_centers', $center_validate_data['ok'])) | |||
| return $this->setRawJsonResponse('ok', _('Clinical center updated successfully.'), [], ['button'=>'goto', 'destination'=>'centers/'.time()]); | |||
| else return $this->setRawJsonResponse('err', _('Clinical center update error.'), [], ['button'=>'goto', 'destination'=>'centers/'.time()]); | |||
| } | |||
| } | |||
| if(isset($center_validate_data['err'])){ | |||
| $err_class = isset($center_validate_data['err']['field-class']) ? ['class'=>$center_validate_data['err']['field-class']] : []; | |||
| return $this->setRawJsonResponse('err', $center_validate_data['err']['err_msg'], $err_class); | |||
| } | |||
| // For debugging... | |||
| // $this->view->DEBUG = 'DEBUG CONTENT'; | |||
| // return $this->setJsonView('centerSave'); | |||
| // return $this->setRawJsonResponse('ok', _('MESSAGGIO DI CONFERMA'), [], ['button'=>'goto', 'destination'=>'centers/'.time()]); | |||
| // return $this->setRawJsonResponse('err', 'MESSAGGIO DI ERRORE del tipo <b>label</b>: required field', ['class'=>'field-CAMPO1']); | |||
| } | |||
| // Return an array | |||
| // [ok] => [field => value] | |||
| // [err] => [ | |||
| // err_msg => error message formatted | |||
| // field-class => filed-FieldName to highlight the error on the page | |||
| // ] | |||
| private function centerValidate($form_data){ | |||
| $result = []; | |||
| if($form_data['description']['value'] == null){ | |||
| $result['err']['err_msg'] = '<b>' . $form_data['description']['label'] . '</b>:' . _(' required field.'); | |||
| $result['err']['field-class'] = 'field-description'; | |||
| return $result; | |||
| } | |||
| if((int)$form_data['anonymize']['value'] != 0 && (int)$form_data['anonymize']['value'] != 1){ | |||
| $result['err']['err_msg'] = '<b>' . $form_data['anonymize']['label'] . '</b>:' . _(' invalid value.'); | |||
| $result['err']['field-class'] = 'field-anonymize'; | |||
| return $result; | |||
| } | |||
| if($form_data['continent_code']['value'] == null){ | |||
| $result['err']['err_msg'] = '<b>' . $form_data['continent_code']['label'] . '</b>:' . _(' required field.'); | |||
| $result['err']['field-class'] = 'field-continent_code'; | |||
| return $result; | |||
| } | |||
| if($this->db->where('code', $form_data['continent_code']['value'])->getOne('continents') == null){ | |||
| $result['err']['err_msg'] = _('Save denied. ') . $form_data['continent_code']['value'] . _(': invalid value.'); | |||
| $result['err']['field-class'] = 'field-continent_code'; | |||
| return $result; | |||
| } | |||
| if($form_data['country_code']['value'] == null){ | |||
| $result['err']['err_msg'] = '<b>' . $form_data['continent_code']['label'] . '</b>:' . _(' required field.'); | |||
| $result['err']['field-class'] = 'field-country_code'; | |||
| return $result; | |||
| } | |||
| if($this->db->where('country_iso2_code', $form_data['country_code']['value'])->getOne('countries') == null){ | |||
| $result['err']['err_msg'] = _('Save denied. ') . $form_data['country_code']['value'] . _(': invalid value.'); | |||
| $result['err']['field-class'] = 'field-country_code'; | |||
| return $result; | |||
| } | |||
| if($this->db->where('country_iso2_code', $form_data['country_code']['value'])->getOne('countries')['continent_iso2_code'] != $form_data['continent_code']['value']){ | |||
| $result['err']['err_msg'] = _('Save denied.'); | |||
| $result['err']['field-class'] = 'field-country_code'; | |||
| return $result; | |||
| } | |||
| if($form_data['lat']['value']!=null && !preg_match('/^[-]?[0-9]{1,2}\.[0-9]{1,8}$/', $form_data['lat']['value'])){ | |||
| $result['err']['err_msg'] = '<b>' . $form_data['lat']['label'] . '</b>:' . _(' invalid value.'); | |||
| $result['err']['field-class'] = 'field-lat'; | |||
| return $result; | |||
| } | |||
| if($form_data['lng']['value']!=null && !preg_match('/^[-]?[0-9]{1,2}\.[0-9]{1,8}$/', $form_data['lng']['value'])){ | |||
| $result['err']['err_msg'] = '<b>' . $form_data['lng']['label'] . '</b>:' . _(' invalid value.'); | |||
| $result['err']['field-class'] = 'field-lng'; | |||
| return $result; | |||
| } | |||
| if($form_data['lat']['value']!=null && $form_data['lng']['value']==null){ | |||
| $result['err']['err_msg'] = '<b>' . $form_data['lng']['label'] . '</b>:' . _(' required field.'); | |||
| $result['err']['field-class'] = 'field-lng'; | |||
| return $result; | |||
| } | |||
| if($form_data['lat']['value']==null && $form_data['lng']['value']!=null){ | |||
| $result['err']['err_msg'] = '<b>' . $form_data['lat']['label'] . '</b>:' . _(' required field.'); | |||
| $result['err']['field-class'] = 'field-lat'; | |||
| return $result; | |||
| } | |||
| // Medical specialties validation | |||
| if(isset($form_data['medical_specialties']['value']) && is_array($form_data['medical_specialties']['value'])){ | |||
| $all_active_specialties = $this->db->where('status', 1)->getValue('users_medical_specialties', 'id', null); | |||
| $center_specialties = $this->db->where('center_id', $form_data['center_id']['value'])->getValue('clinical_center_medical_specialties_to', 'specialty_id', null); | |||
| foreach ($form_data['medical_specialties']['value'] as $specialty_id) { | |||
| if(!in_array($specialty_id, $all_active_specialties)){ | |||
| $result['err']['err_msg'] = '<b>' . $form_data['medical_specialties']['label'] . '</b>:' . _(' invalid value.'); | |||
| $result['err']['field-class'] = 'field-medical_specialties'; | |||
| return $result; | |||
| } | |||
| } | |||
| } else $form_data['medical_specialties']['value'] = []; | |||
| // List of editable fields of the clinical center | |||
| $center_writable_fields = []; | |||
| foreach($this->db->rawQuery('describe clinical_centers') as $attribute) $center_writable_fields[] = $attribute['Field']; | |||
| $center_writable_fields[] = 'medical_specialties'; // Field not in clinical_centers table | |||
| // The following fields are editable only from the controller | |||
| $center_writable_fields = array_diff($center_writable_fields, ['id', 'group_id', 'country_id', 'created_by', 'created_at', 'updated_by', 'updated_at', 'deleted_by', 'deleted_at']); | |||
| foreach ($center_writable_fields as $field) { | |||
| $result['ok'][$field] = $this->utility->deepTrim($form_data[$field]['value']); | |||
| } | |||
| // foreach ($form_data as $form_field => $values) { | |||
| // if(in_array($form_field, $center_writable_fields)){ | |||
| // $result['ok'][$form_field] = $values['value']; | |||
| // } else { | |||
| // | |||
| // } | |||
| // } | |||
| return $result; | |||
| } | |||
| //List all Clinical Centers in the Group | |||
| function centersList() { | |||
| if(!$this->checkPermissions([ADMIN_ROLE_ID])) { | |||
| return $this->redirect('login', 'permissionDenied'); | |||
| } | |||
| $results = $this->db | |||
| ->where('cc.group_id', $this->userGroupId) | |||
| ->join('continents cnts', 'cnts.code=cc.continent_code', 'INNER') | |||
| ->join('countries cntrs', 'cntrs.country_iso2_code=cc.country_code', 'INNER') | |||
| ->orderBy('cnts.name', 'asc') | |||
| ->get('clinical_centers cc', null, ['cc.id center_id', 'cc.description', 'cnts.name continent_name', 'cntrs.country_name', 'cc.anonymize', 'cc.notes']); | |||
| $activeSpecialties = $this->getActiveMedicalSpecialtiesIdByGroupId($this->userGroupId); | |||
| foreach($results as $index => $item) { | |||
| $specialties = $this->db | |||
| ->where('ccmst.center_id', $item['center_id']) | |||
| ->join('users_medical_specialties ums', 'ums.id=ccmst.specialty_id', 'INNER') | |||
| ->get('clinical_center_medical_specialties_to ccmst', null, ['ums.id', 'ums.description']); | |||
| $translated = []; | |||
| if (!empty($specialties)) { | |||
| foreach($specialties as $indecSpec => $specialty) { | |||
| $translated[$specialty['id']]['description'] = _($specialty['description']); | |||
| $translated[$specialty['id']]['active'] = in_array($specialty['id'], $activeSpecialties) ? true : false; | |||
| } | |||
| } | |||
| $results[$index]['specialties'] = $translated; | |||
| } | |||
| $this->view->centers = $results; | |||
| $this->actionTitle = _('Clinical Centers'); | |||
| $this->breadcrumbs = [['hash'=>null, 'label'=>$this->actionTitle]]; | |||
| return $this->setJsonView('centersList'); | |||
| } | |||
| } | |||
| @@ -0,0 +1,134 @@ | |||
| <?php | |||
| class dashboardController extends mainController { | |||
| private $dashboardPageLimit; | |||
| function __construct() { | |||
| parent::__construct(); | |||
| $this->dashboardPageLimit = 5; | |||
| //To change for every Controller | |||
| $this->viewDir = 'Dashboard'; | |||
| //$this->allow = []; | |||
| } | |||
| public function index($args=null) { | |||
| if (!$this->user->isLogged()) { | |||
| return $this->redirect('login', 'permissionDenied'); | |||
| } | |||
| $this->view->userData = $this->user->getUser(); | |||
| $this->view->showRoleLabel = count($this->view->userData['userRolesLocale']) > 1 ? true : false; //Statistics | |||
| $this->showBreadcrumbs = false; | |||
| return $this->setJsonView('index'); | |||
| } | |||
| public function indexNoPrivacy() { | |||
| return $this->setJsonView('indexNoPrivacy'); | |||
| } | |||
| //Last sessions on Dashboard for administrator | |||
| public function loadLastSessions() { | |||
| if(!$this->checkPermissions([ADMIN_ROLE_ID])) { | |||
| return $this->redirect('login', 'permissionDenied'); | |||
| } | |||
| $userGroupId = $this->user->getUserField('userGroupId'); | |||
| $page = 1; | |||
| $this->db->pageLimit = $this->dashboardPageLimit; | |||
| $sessions = $this->db | |||
| ->join('users u', 'u.id=s.user_id', 'INNER') | |||
| ->where('s.user_id', 0, '>') | |||
| ->where('u.group_id', $userGroupId) | |||
| ->orderBy('s.session_updated_at', 'DESC') | |||
| ->paginate('sessions s', $page, ['s.*', 'u.surname', 'u.name', 'u.updated_at']); | |||
| $this->view->sessions = $sessions; | |||
| return $this->setJsonView('loadLastSessions'); | |||
| } | |||
| public function loadLastSubscriptions() { | |||
| if(!$this->checkPermissions([ADMIN_ROLE_ID])) { | |||
| return $this->redirect('login', 'permissionDenied'); | |||
| } | |||
| $userGroupId = $this->user->getUserField('userGroupId'); | |||
| $page = 1; | |||
| $this->db->pageLimit = $this->dashboardPageLimit; | |||
| $this->view->usersList = $this->db->where('group_id', $userGroupId)->orderBy('created_at', 'DESC')->paginate('users', $page); | |||
| return $this->setJsonView('loadLastSubscriptions'); | |||
| } | |||
| public function loadLastAccesses() { | |||
| if(!$this->checkPermissions([ADMIN_ROLE_ID])) { | |||
| return $this->redirect('login', 'permissionDenied'); | |||
| } | |||
| $userGroupId = $this->user->getUserField('userGroupId'); | |||
| $page = 1; | |||
| $this->db->pageLimit = $this->dashboardPageLimit; | |||
| $accesses = $this->db | |||
| ->join('users u', 'u.id=a.user_id', 'INNER') | |||
| ->where('a.user_id', 0, '>') | |||
| ->where('u.group_id', $userGroupId) | |||
| ->orderBy('a.created_at', 'DESC') | |||
| ->paginate('log_access a', $page, ['a.*', 'a.created_at AS access_date', 'u.username', 'u.surname', 'u.name', 'u.updated_at AS user_updated_at']); | |||
| $this->view->accesses = $accesses; | |||
| return $this->setJsonView('loadLastAccesses'); | |||
| } | |||
| public function loadStatistics() { | |||
| $roleId = $this->getPost('roleId', 0); | |||
| if(!$this->checkPermissions([ADMIN_ROLE_ID, MODERATOR_ROLE_ID, REFERRER_ROLE_ID, APPLICANT_ROLE_ID, GUEST_ROLE_ID])) { | |||
| return $this->redirect('login', 'permissionDenied'); | |||
| } | |||
| $handleRequest = new HandleRequest(); | |||
| $triageData = $handleRequest->getStatistics('triage_color', $roleId, $this); | |||
| $statusData = $handleRequest->getStatistics('request_status', $roleId, $this); | |||
| $this->view->statData = $statusData; | |||
| $this->view->roleId = $roleId; | |||
| $this->view->triageQty = array_sum($triageData['values']); | |||
| $this->view->statusQty = array_sum($statusData['values']); | |||
| //return $this->setJsonView('loadStatistics'); | |||
| $html = $this->partial('Dashboard/statistics-charts'); | |||
| return $this->setRawJsonResponse('ok', '', ['html'=>$html, 'chartTitle'=>'', | |||
| 'barTriageLabels'=>$triageData['labelsValues'], | |||
| 'pieTriageLabels'=>$triageData['labelsPerc'], | |||
| 'TriageColors'=>$triageData['colors'], | |||
| 'TriageBorders'=>$triageData['borders'], | |||
| 'TriageValues'=>$triageData['values'], | |||
| 'TriagePerc'=>$triageData['perc'], | |||
| 'barStatusLabels'=>$statusData['labelsValues'], | |||
| 'pieStatusLabels'=>$statusData['labelsPerc'], | |||
| 'StatusColors'=>$statusData['colors'], | |||
| 'StatusBorders'=>$statusData['borders'], | |||
| 'StatusValues'=>$statusData['values'], | |||
| 'StatusPerc'=>$statusData['perc'], | |||
| ]); | |||
| } | |||
| public function allowAccess() { | |||
| if (!$this->user->isLogged()) { | |||
| return $this->redirect('login', 'index', ['jsRedirect'=>'/']); | |||
| } | |||
| return false; | |||
| } | |||
| } | |||
| @@ -0,0 +1,178 @@ | |||
| <?php | |||
| class loginController extends mainController { | |||
| function __construct() { | |||
| parent::__construct(); | |||
| //To change for every Controller | |||
| $this->viewDir = 'Login'; | |||
| } | |||
| //Do not show the Disclaimer in this controller actions (see mainController) | |||
| public function beforeRender($content=null) { | |||
| return false; | |||
| } | |||
| public function index($args=null) { | |||
| $jsRedirect = isset($args['jsRedirect']) ? $args['jsRedirect'] : '/'; | |||
| //Avoid to show the login form if the user is logged in | |||
| if ($this->user->isLogged()) { | |||
| return $this->redirect('login', 'indexLogged'); | |||
| } | |||
| $this->view->appTitle = $this->config['settings']['app-title']; | |||
| $this->view->languageList = $this->locale->getLanguageStringList(); | |||
| $this->view->token = $this->security->setCSRFToken(); | |||
| return $this->setJsonView('index', true, $jsRedirect); | |||
| } | |||
| public function indexLogged($args=null) { | |||
| $this->view->appTitle = $this->config['settings']['app-title']; | |||
| return $this->setJsonView('indexLogged'); | |||
| } | |||
| public function access($args=null) { | |||
| $data = $this->getPost('data'); | |||
| $hr = new HandleRequest(); | |||
| if ($data !== false) { | |||
| $username = trim($data['username']); | |||
| $passwd = trim($data['password']); | |||
| $token = $data['token']; | |||
| //$keep_connected = $data['keep_connected']; | |||
| //if ($this->security->compareCSRFToken($token)) { | |||
| //$user = $this->db->where('status', 0, '<>')->where('username', $username, 'like')->getOne('users'); | |||
| $user = $this->user->getValidUserData($username); | |||
| if (isset($user['id'])) { | |||
| if ($user['password'] == md5($passwd)) { | |||
| $user = $this->user->setUserMeta($user); | |||
| $this->user->logout(); | |||
| //Log the user (create user's session) | |||
| if ($this->user->login($user)) { | |||
| //Associate user id to the current session | |||
| $updateSession = $this->user->setUserIdSessionField(); | |||
| $this->logger->logUserAccess($user, 1, 'Login'); | |||
| $hr->setActivityLog($this->user->getUserId(), 'USR_LOGGED_IN', ['userId'=>$this->user->getUserId()]); | |||
| return $this->setRawJsonResponse('ok', null); | |||
| } else { | |||
| $hr->setActivityLog(0, 'USR_LOGIN_FAILED', ['username'=>$username]); | |||
| $this->logger->logUserAccess($user, 0, 'User session error', ['Username'=>$username]); | |||
| return $this->setJsonError(_('An error occurred creating user session. Please try again in a few minutes.')); | |||
| } | |||
| } else { | |||
| $hr->setActivityLog(0, 'USR_LOGIN_FAILED', ['username'=>$username]); | |||
| $this->logger->logUserAccess(null, 0, 'Password', ['Username'=>$username]); | |||
| return $this->setJsonError(_('The Password provided is not valid.')); | |||
| } | |||
| } else { | |||
| $hr->setActivityLog(0, 'USR_LOGIN_FAILED', ['username'=>$username]); | |||
| $this->logger->logUserAccess(null, 0, 'Username', ['Username'=>$username]); | |||
| return $this->setJsonError(_('The Username provided is not valid.')); | |||
| } | |||
| /*} else { | |||
| $this->logger->logUserAccess(null, 0, 'CSRFT', ['Username'=>$username]); | |||
| return $this->setJsonError(_('The provided login information are not valid.')); | |||
| }*/ | |||
| } else { | |||
| $hr->setActivityLog(0, 'USR_LOGIN_FAILED', ['username'=>$username]); | |||
| $this->logger->logUserAccess(null, 0, 'POST', ['Username'=>$username]); | |||
| return $this->setJsonError(_('Login information data are empty.')); | |||
| } | |||
| } | |||
| public function autoLogin() { | |||
| $token = $this->getPost('autologinToken', null); | |||
| $requestID = $this->getPost('requestId', null); | |||
| $expireDays = $this->config['settings']['autologin-expire-days']; | |||
| $hr = new HandleRequest(); | |||
| $userInfo = $this->db | |||
| ->where('autologin_token', $token) | |||
| ->where('DATEDIFF(NOW(), autologin_expires_at)', $expireDays, '<=') | |||
| ->getOne('users'); | |||
| if (is_array($userInfo) && !empty($userInfo)) { | |||
| $user = $this->user->getValidUserData($userInfo['username']); | |||
| if (is_array($user) && !empty($user)) { | |||
| $user = $this->user->setUserMeta($user); | |||
| $this->user->logout(); | |||
| if ($this->user->login($user)) { | |||
| //Associate user id to the current session | |||
| $updateSession = $this->user->setUserIdSessionField(); | |||
| $hr->setActivityLog($this->user->getUserId(), 'USR_AUTO_LOGGED_IN', ['userId'=>$this->user->getUserId()]); | |||
| $this->logger->logUserAccess($user, 1, 'Login', ['Auto'=>true, 'RequestID'=>$requestID]); | |||
| return $this->setRawJsonResponse('ok', null, ['RequestID'=>$requestID, 'ts'=>time()]); | |||
| } else { | |||
| $hr->setActivityLog(0, 'USR_AUTO_LOGIN_FAILED', ['username'=>$userInfo['username']]); | |||
| $this->logger->logUserAccess($user, 0, 'Auto Login Error', ['Username'=>$username]); | |||
| return $this->setRawJsonResponse('ok', null, []); | |||
| } | |||
| } else { | |||
| $hr->setActivityLog(0, 'USR_AUTO_LOGIN_FAILED', ['username'=>'']); | |||
| $this->logger->logUserAccess($user, 0, 'Auto Login Not Valid User', ['Username'=>$username, 'RequestID'=>$requestID]); | |||
| return $this->setRawJsonResponse('ok', null, []); | |||
| } | |||
| } else { | |||
| $hr->setActivityLog(0, 'USR_AUTO_LOGIN_FAILED', ['username'=>'']); | |||
| $this->logger->logUserAccess($user, 0, 'Auto Login Not Valid User Info', ['Username'=>$username, 'RequestID'=>$requestID]); | |||
| return $this->setRawJsonResponse('ok', null, []); | |||
| } | |||
| } | |||
| public function permissionDenied() { | |||
| //return $this->setJsonView('permissionDenied'); | |||
| return $this->setRawJsonResponse('err', _('Session expired or permission denied. Please try to log in again.'), [], ['button'=>'login', 'dialogType'=>'sessionExpired']); | |||
| } | |||
| public function changeLang() { | |||
| $passedLng = $this->getPost('passedLng'); | |||
| if ($passedLng !== false) { | |||
| $this->locale->setCurrentLanguage($passedLng); | |||
| } | |||
| return $this->setRawJsonResponse('ok', null); | |||
| } | |||
| public function logout() { | |||
| $result = $this->user->logout(); | |||
| if ($result) { | |||
| $status = 'ok'; | |||
| $msg = ''; | |||
| } else { | |||
| $status = 'err'; | |||
| $msg = _('Logout failed. Please try again in a few minutes.'); | |||
| } | |||
| return $this->setRawJsonResponse($status, $msg); | |||
| } | |||
| } | |||
| @@ -0,0 +1,231 @@ | |||
| <?php | |||
| class mainController extends Controller { | |||
| public $userGroupId = 0; | |||
| public $helper; | |||
| public $notification; | |||
| function __construct() { | |||
| parent::__construct(); | |||
| $this->helper = new Helper($this->utility); | |||
| $this->notification = new Notification($this, 0); //2 for debug | |||
| $this->userGroupId = $this->user->getUserField('userGroupId'); | |||
| $groupInfoKey = 'group:info:'.$this->userGroupId; | |||
| $groupInfoCache = $this->memoryCache->read($groupInfoKey); | |||
| if (is_null($groupInfoCache)) { | |||
| $this->groupInfo = $this->db->where('id', $this->userGroupId)->getOne('users_groups'); | |||
| $this->memoryCache->write($groupInfoKey, $this->groupInfo, '+10 years'); | |||
| } else { | |||
| $this->groupInfo = $groupInfoCache; | |||
| } | |||
| $this->view->groupName = $this->groupInfo['group_name']; | |||
| $this->view->groupId = $this->groupInfo['id']; | |||
| $this->view->currentUserId = $this->user->getUserId(); | |||
| define('STATUS_TECH_NAME', _('Technician')); | |||
| define('AGE_MONTH_LIMIT', 18); | |||
| if($_SERVER['REMOTE_ADDR'] != '195.181.176.98') { | |||
| //exit(); | |||
| } | |||
| } | |||
| public function beforeRender($content=null) { | |||
| return $content; | |||
| //TODO: check to groupId (?) | |||
| //if ((int)$this->userGroupId < 1) { | |||
| //} | |||
| if (!$this->user->disclaimerAccepted()) { | |||
| $this->viewDir = 'Main'; | |||
| return $this->setView('indexNoPrivacy'); | |||
| } else { | |||
| return false; | |||
| } | |||
| } | |||
| public function convertOldUserLang($checkLang='') { | |||
| if (strlen($checkLang) == 2) return $checkLang; | |||
| $map = ['ENGLISH'=>'en', 'ITALIANO'=>'it', 'PORTUGUES'=>'pt', 'FRANCAIS'=>'fr']; | |||
| return isset($map[$checkLang]) ? $map[$checkLang] : $this->config['settings']['default-lang']; | |||
| } | |||
| public function getClinicalCenterCountries($groupByContinent=false) { | |||
| $this->db->where('cc.group_id', $this->userGroupId) | |||
| ->join('countries c', 'c.country_iso2_code=cc.country_code', 'INNER') | |||
| ->join('continents cn', 'cn.code=cc.continent_code', 'INNER') | |||
| ->groupBy('c.country_iso2_code'); | |||
| if ($groupByContinent) { | |||
| $this->db | |||
| ->orderBy('cn.name', 'asc') | |||
| ->orderBy('c.country_name', 'asc'); | |||
| } else { | |||
| $this->db->orderBy('c.country_name', 'asc'); | |||
| } | |||
| $results = $this->db->get('clinical_centers cc', null, ['c.country_iso2_code country_code', 'c.country_name country_name', 'cn.code continent_code', 'cn.name continent_name', '(SELECT COUNT(*) AS total FROM clinical_centers WHERE clinical_centers.country_code=c.country_iso2_code AND clinical_centers.group_id='.$this->userGroupId.') cc_count', '(SELECT COUNT(*) AS total FROM clinical_centers WHERE clinical_centers.continent_code=cn.code AND clinical_centers.group_id='.$this->userGroupId.') cn_count']); | |||
| if ($groupByContinent) { | |||
| $grouped = []; | |||
| if (is_array($results)) { | |||
| foreach($results as $result) { | |||
| $grouped[$result['continent_code']]['name'] = $result['continent_name']; | |||
| $grouped[$result['continent_code']]['count'] = $result['cn_count']; | |||
| $grouped[$result['continent_code']]['list'][] = $result; | |||
| } | |||
| } | |||
| return $grouped; | |||
| } | |||
| return $results; | |||
| } | |||
| public function getUserClinicalCenters($userId, $roleId=0) { | |||
| $reindexedResults = []; | |||
| $key = 'clinical:center:'.$userId.':'.$roleId; | |||
| $value = $this->memoryCache->read($key); | |||
| $value = null; //Non usare la cache | |||
| if (is_null($value)) { | |||
| $results = $this->db | |||
| ->where('ucct.user_id', $userId) | |||
| ->where('ucct.role_id', $roleId) | |||
| //->where('cc.group_id', $this->userGroupId) | |||
| ->join('clinical_centers cc', 'cc.id=ucct.center_id', 'INNER') | |||
| ->orderBy('cc.description', 'asc') | |||
| ->get('users_clinical_centers_to ucct', null, ['cc.id', 'cc.description', 'cc.address', 'cc.anonymize', 'cc.has_remote_visit', 'cc.notes']); | |||
| //Assign the Clinical Center id to the array index | |||
| if (is_array($results)) { | |||
| foreach($results as $result) { | |||
| $reindexedResults[$result['id']] = $result; | |||
| } | |||
| } | |||
| $this->memoryCache->write($key, $reindexedResults, '+10 years'); | |||
| } else { | |||
| $reindexedResults = $value; | |||
| } | |||
| return $reindexedResults; | |||
| } | |||
| public function getUserMedicalSpecialties($userId=0) { | |||
| $reindexedResults = []; | |||
| $key = 'medical:specialties:'.$userId; | |||
| $value = $this->memoryCache->read($key); | |||
| if (is_null($value)) { | |||
| $results = $this->db | |||
| ->where('umst.user_id', $userId) | |||
| ->join('users_medical_specialties ms', 'ms.id=umst.specialty_id', 'INNER') | |||
| ->orderBy('ms.description', 'asc') | |||
| ->get('users_medical_specialties_to umst', null, ['ms.id', 'ms.description']); | |||
| //Assign the Medical Specialty id to the array index | |||
| if (is_array($results)) { | |||
| foreach($results as $result) { | |||
| $reindexedResults[$result['id']] = $result; | |||
| } | |||
| } | |||
| $this->memoryCache->write($key, $reindexedResults, '+10 years'); | |||
| } else { | |||
| $reindexedResults = $value; | |||
| } | |||
| return $reindexedResults; | |||
| } | |||
| public function getActiveMedicalSpecialtiesIdByGroupId($groupId=0) { | |||
| $specialties = []; | |||
| $results = $this->db | |||
| ->where('u.group_id', $groupId) | |||
| ->where('u.status', 1) | |||
| ->join('users u', 'u.id=umst.user_id', 'INNER') | |||
| ->groupBy('umst.specialty_id') | |||
| ->get('users_medical_specialties_to umst', null, ['umst.specialty_id']); | |||
| if (is_array($results)) { | |||
| foreach($results as $result) { | |||
| $specialties[] = $result['specialty_id']; | |||
| } | |||
| } | |||
| return $specialties; | |||
| } | |||
| public function getGUID(){ | |||
| if (function_exists('com_create_guid')){ | |||
| return com_create_guid(); | |||
| } | |||
| else { | |||
| mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up. | |||
| $charid = strtoupper(md5(uniqid(rand(), true))); | |||
| $hyphen = chr(45);// "-" | |||
| $uuid = | |||
| substr($charid, 0, 8).$hyphen. | |||
| substr($charid, 8, 4).$hyphen. | |||
| substr($charid,12, 4).$hyphen. | |||
| substr($charid,16, 4).$hyphen. | |||
| substr($charid,20,12); | |||
| return $uuid; | |||
| } | |||
| } | |||
| public function setMessageQueue($subject, $body, $recipient, $survey_id=0, $delay=null) { | |||
| $this->db->insert('survey_queue', [ | |||
| 'survey_id'=>$survey_id, | |||
| 'msg_subject'=>$subject, | |||
| 'msg_body'=>$body, | |||
| 'msg_recipient'=>$recipient, | |||
| 'msg_delay_at'=>$delay | |||
| ]); | |||
| } | |||
| public function canViewRemoteVisit() { | |||
| $cc = []; | |||
| if ($this->user->is(APPLICANT_ROLE_ID)) { | |||
| $cc = $this->getUserClinicalCenters($this->user->getUserId(), APPLICANT_ROLE_ID); | |||
| if (is_array($cc) && !empty($cc)) { | |||
| foreach($cc as $item) { | |||
| if ($item['has_remote_visit'] == 1) { | |||
| return true; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return false; | |||
| } | |||
| public function getSetting($key=null) { | |||
| $value = $this->db->where('title', $key, 'LIKE')->getOne('settings'); | |||
| return isset($value[$key]) ? $value[$key] : false; | |||
| } | |||
| //TODO | |||
| public function deleteUserCacheKeys($userId=0) { | |||
| } | |||
| } | |||
| @@ -0,0 +1,120 @@ | |||
| <?php | |||
| class publicController extends mainController { | |||
| function __construct() { | |||
| parent::__construct(); | |||
| //To change for every Controller | |||
| $this->viewDir = 'Public'; | |||
| } | |||
| public function beforeRender($content=null) { | |||
| return false; | |||
| } | |||
| public function getGloablJs() { | |||
| return $this->setView('getGloablJs'); | |||
| } | |||
| public function recoveryPassword() { | |||
| $email = $this->getPost('email', ''); | |||
| $validate = $this->utility->validateEmail($email); | |||
| if (!$validate) { | |||
| return $this->setRawJsonResponse('err', null); | |||
| } | |||
| $user = $this->db->where('email', $email, 'like')->getOne('users'); | |||
| if (is_array($user) && !empty($user)) { | |||
| $passwd = uniqid(); | |||
| $encrPasswd = md5($passwd); | |||
| $upadate = $this->db->where('id', $user['id'])->update('users', ['password'=>$encrPasswd]); | |||
| if ($upadate) { | |||
| $recipientName = ucwords(strtolower($user['name'].' '.$user['surname'])); | |||
| $recipientUsername = $user['username']; | |||
| $loginPage = '<a href="'.$this->config['settings']['email']['footer-home-link'].'" target="_blank">'.$this->config['settings']['email']['footer-home-link'].'</a>'; | |||
| $defaultGreeting = $this->config['settings']['email']['final-greeting']; | |||
| $mailID = uniqid(); | |||
| $mailContent = _("Dear %s,<br> | |||
| you've just requested a Temporary Password:<br><br><b>Username</b>: %s<br><b>Password</b>: %s<br><b>Login Page</b>: %s<br><br>After logging in, you can change the password in your <b>Profile</b> page.<br><br>%s"); | |||
| $mailSubject = _('Password recovery'); | |||
| $mailHTML = $this->partial('Message/Email/template', ['mailID'=>$mailID, 'body'=>vsprintf($mailContent, [$recipientName, $recipientUsername, $passwd, $loginPage, $defaultGreeting]), 'showTemplate'=>true]); | |||
| $this->notification->sendEmail($email, $mailSubject, $mailHTML, $mailID); | |||
| } else { | |||
| return $this->setRawJsonResponse('err', null); | |||
| } | |||
| } else{ | |||
| return $this->setRawJsonResponse('err', null); | |||
| } | |||
| return $this->setRawJsonResponse('ok', null, []); | |||
| } | |||
| public function emailPreview() { | |||
| $args = func_get_args(); | |||
| $emailId = isset($args[0]['id']) ? $args[0]['id'] : null; | |||
| $mailResult = $this->db->where('id', $emailId)->getOne('log_notifications'); | |||
| $mailBody = isset($mailResult['mail_body']) ? $mailResult['mail_body'] : null; | |||
| $showTemplate = is_null($mailBody) ? true : false; | |||
| $mailBody = is_null($mailBody) ? _('Invalid e-mail content.') : $mailBody; | |||
| $this->view->html = $this->partial('Message/Email/template', ['mailID'=>$emailId, 'body'=>$mailBody, 'showTemplate'=>$showTemplate]); | |||
| return $this->setView('emailPreview'); | |||
| } | |||
| public function showAttachementsInDream() { | |||
| $request_code = $this->getPost('request_code', null); | |||
| $handleRequest = new HandleRequest(); | |||
| $this->view->request = []; | |||
| $this->view->attachments = []; | |||
| $this->view->groupedAttachments = []; | |||
| $this->actionTitle = 'Request'; | |||
| $this->view->patientInfo = ''; | |||
| if (!is_null($request_code)) { | |||
| $request = $this->db | |||
| ->join('requests_registry rr', 'rr.request_id=r.id') | |||
| ->where('r.unique_code', $request_code) | |||
| ->getOne('requests r', "r.*, rr.name patient_name, rr.surname patient_surname, rr.birthdate patient_dob"); | |||
| if (isset($request['id'])) { | |||
| $this->actionTitle = 'Request #'.$request['id']; | |||
| $this->view->patientInfo = $request['patient_surname'].' '.$request['patient_name'].', '.$this->helper->getDateString($request['patient_dob'], false); | |||
| $this->view->request = $request; | |||
| $this->view->attachments = $handleRequest->getAttachmentsByRequestId($request['id']); | |||
| //Group attachments by date | |||
| if (is_array($this->view->attachments) && !empty($this->view->attachments)) { | |||
| foreach($this->view->attachments as $attachment) { | |||
| //$ext = $this->helper->getExtension($attachment['file_name']); | |||
| $attachment['previewType'] = $this->helper->getPreviewType($attachment['file_name']); | |||
| $this->view->groupedAttachments[date('Y-m-d 00:00:00', strtotime($attachment['created_at']))][] = $attachment; | |||
| } | |||
| if (!empty($this->view->groupedAttachments)) { | |||
| foreach($this->view->groupedAttachments as $ext => $attachList) { | |||
| sort($attachList); | |||
| $this->view->groupedAttachments[$ext] = $attachList; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return $this->setJsonView('showAttachementsInDream'); | |||
| } | |||
| } | |||
| @@ -0,0 +1,630 @@ | |||
| <?php | |||
| class surveyController extends mainController { | |||
| function __construct() { | |||
| parent::__construct(); | |||
| //To change for every Controller | |||
| $this->viewDir = 'Survey'; | |||
| } | |||
| public function beforeRender($content=null) { | |||
| return false; | |||
| } | |||
| //Public (Servey form) | |||
| /*public function index() { | |||
| $this->view->survey_code = $this->getPost('code', 0); | |||
| $survey_type = []; | |||
| $this->view->survey_title = null; | |||
| $this->view->survey_tag = null; | |||
| $this->view->survey_type_id = 0; | |||
| $this->view->structure = null; | |||
| $this->view->survey_patient_string = ''; | |||
| $this->view->survey_answered = false; | |||
| $this->view->survey_date = null; | |||
| $survey = $this->db | |||
| ->where('sy.code', $this->view->survey_code) | |||
| ->join('survey_registry syr', 'syr.survey_id=sy.id') | |||
| ->getOne('survey sy', "sy.type_id survey_type_id, sy.aswered_recipient, sy.aswered_date, syr.surname patient_surname, syr.name patient_name, syr.birthdate partient_bday, syr.email patient_email"); | |||
| if (isset($survey['survey_type_id'])) { | |||
| $survey_type = $this->db->where('id', $survey['survey_type_id'])->where('status', 1)->getOne('survey_types'); | |||
| $this->view->survey_answered = $survey['aswered_recipient'] == 1 ? true : false; | |||
| $this->view->survey_date = $survey['aswered_date']; | |||
| $this->db->where('code', $this->view->survey_code)->update('survey', ['opened_recipient'=>1, 'updated_at'=>date('Y-m-d H:i:s')]); | |||
| } | |||
| //$this->view->debug = $survey; | |||
| if (is_array($survey_type) && !empty($survey_type)) { | |||
| $this->view->survey_type_id = $survey_type['type_id']; | |||
| $this->view->survey_title = $survey_type['survey_label']; | |||
| $this->view->survey_tag = $survey_type['survey_tag']; | |||
| $survey_lang = $survey_type['survey_lang']; | |||
| //$structure = json_decode(file_get_contents(RESOURCE_DIR.'survey/'.$survey_lang.'/'.$this->view->survey_tag.'.json'), true); | |||
| //$global_fields = json_decode(file_get_contents(RESOURCE_DIR.'survey/'.$survey_lang.'/global.json'), true); | |||
| $this->setSurveyForm($survey_lang, $this->view->survey_tag, $survey); | |||
| //$this->view->structure = array_merge($structure, $global_fields); | |||
| //$this->view->survey_patient_string = strip_tags($survey['patient_surname']).' '.strip_tags($survey['patient_name']).', '.$this->helper->getDateString($survey['partient_bday'], false).', '.$survey['patient_email']; | |||
| } | |||
| return $this->setJsonView('index'); | |||
| } | |||
| //Private (managers) | |||
| public function surveyPrivateSend() { | |||
| $data = $this->getPost('data', null); | |||
| return $this->setRawJsonResponse('ok', null, ['data'=>$data]); | |||
| } | |||
| //Public (people) | |||
| public function surveyPublicSend() { | |||
| $data = $this->getPost('data', null); | |||
| $code = $this->getPost('survey_code', null); | |||
| $files = $_FILES; | |||
| $max_file_size = 1048576*5; //5 MB | |||
| //Remove file information | |||
| if (isset($data['file'])) unset($data['file']); | |||
| //Remove privacy information (last item) | |||
| array_pop($data); | |||
| //Remove file group information | |||
| array_pop($data); | |||
| $insert_data = [ | |||
| 'json_answers'=>json_encode($data), | |||
| 'aswered_recipient'=>1, | |||
| 'aswered_date'=>date('Y-m-d H:i:s'), | |||
| 'updated_at'=>date('Y-m-d H:i:s') | |||
| ]; | |||
| $update = $this->db->where('code', $code)->update('survey', $insert_data); | |||
| if ($update) { | |||
| if (isset($files['data'])) { | |||
| foreach($files['data']['name']['file'] as $index => $item) { | |||
| if ((int)$files['data']['error']['file'][$index] == 0) { | |||
| $file_name = $this->utility->slugify($files['data']['name']['file'][$index]); | |||
| $file_type = $files['data']['type']['file'][$index]; | |||
| $file_tmp_name = $files['data']['tmp_name']['file'][$index]; | |||
| $file_ext = strtolower(pathinfo($files['data']['name']['file'][$index], PATHINFO_EXTENSION)); | |||
| $file_size = $files['data']['size']['file'][$index]; | |||
| $file_uuid = $this->getGUID(); | |||
| if ($file_size <= $max_file_size) { | |||
| //Unique index on survey_uuid and file_title to avoid duplicate on multiple submits (i.g. poor connection) | |||
| $insert = $this->db->insert('survey_attachments', [ | |||
| 'uuid'=>$file_uuid, | |||
| 'survey_uuid'=>$code, | |||
| 'file_title'=>$file_name, | |||
| 'file_type'=>$file_type, | |||
| 'file_ext'=>$file_ext, | |||
| 'file_size'=>$file_size, | |||
| 'created_at'=>date('Y-m-d H:i:s') | |||
| ]); | |||
| if ($insert) { | |||
| $moved = move_uploaded_file($file_tmp_name, ATTACH_DIR.$file_uuid); | |||
| //If not moved, try to delete the record | |||
| if (!$moved) { | |||
| $this->db->where('uuid', $file_uuid)->delete('survey_attachments'); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return $this->setRawJsonResponse('ok', null); | |||
| }*/ | |||
| public function surveyList() { | |||
| if(!$this->checkPermissions([ADMIN_ROLE_ID, GLOBAL_MANAGER_ID, MANAGER_ID])) { | |||
| return $this->redirect('login', 'permissionDenied'); | |||
| } | |||
| $this->view->currentPage = $this->getPost('pageNumb', 1); | |||
| $this->view->orderField = $this->getPost('orderField', 'created_at'); | |||
| $this->view->orderDir = $this->getPost('orderDir', 'desc'); | |||
| $this->view->isGlobal = $this->user->is([GLOBAL_MANAGER_ID]) ? true : false; | |||
| $this->view->typeList = []; | |||
| $searchData = $this->getPost('searchData', []); | |||
| parse_str($searchData, $this->view->strOutput); | |||
| //Get all users (Manager and Global manager) in current user centers | |||
| $cc_list = []; | |||
| $cc_user_list = []; | |||
| $query_user_list = []; | |||
| $cc = $this->db | |||
| ->where('ucct.user_id', $this->user->getUserId()) | |||
| ->where('ucct.role_id IN('.MANAGER_ID.', '.GLOBAL_MANAGER_ID.')') | |||
| ->get('users_clinical_centers_to ucct', null, ['ucct.center_id']); | |||
| if (is_array($cc)) { | |||
| foreach($cc as $item) { | |||
| //Get unique array | |||
| $cc_list[$item['center_id']] = $item['center_id']; | |||
| } | |||
| if (!empty($cc_list)) { | |||
| $cc_user_list = $this->db | |||
| ->where('ucct.center_id IN('.implode(',', $cc_list).')') | |||
| ->where('ucct.role_id IN('.MANAGER_ID.')') | |||
| ->get('users_clinical_centers_to ucct', null, ['ucct.user_id']); | |||
| if (is_array($cc_user_list) && !empty($cc_user_list)) { | |||
| foreach($cc_user_list as $item) { | |||
| $query_user_list[] = $item['user_id']; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| $this->view->debugcc = $cc_list; | |||
| $survey_types = null; | |||
| if (is_array($cc_list) && !empty($cc_list)) { | |||
| $survey_types = $this->db | |||
| ->where('status', 1) | |||
| ->where('center_id IN('.implode(',', $cc_list).')') | |||
| ->orderBy('survey_label', 'ASC') | |||
| ->get('survey_types'); | |||
| } | |||
| if (is_array($survey_types) && !empty($survey_types)) { | |||
| foreach($survey_types as $item) { | |||
| $this->view->typeList[$item['id']] = '... '.str_ireplace('QUESTIONARIO ', '', $item['survey_label']); | |||
| } | |||
| } | |||
| if ($this->user->is([GLOBAL_MANAGER_ID])) { | |||
| if (!empty($query_user_list)) { | |||
| $this->db->where('sy.manager_id IN('.implode(',', $query_user_list).')'); | |||
| } else { | |||
| $this->db->where('sy.manager_id', $this->user->getUserId()); | |||
| } | |||
| } else { | |||
| $this->db->where('sy.manager_id', $this->user->getUserId()); | |||
| } | |||
| $survey_type = 0; | |||
| if (isset($this->view->strOutput['searchData']['survey_type'])) { | |||
| $this->session->deleteSession('search_survey_type'); | |||
| $survey_type = (int)$this->view->strOutput['searchData']['survey_type']; | |||
| $this->session->refreshSession('search_survey_type', $survey_type); | |||
| } else { | |||
| if ($this->session->getSessionValue('search_survey_type') !== false) { | |||
| $survey_type = $this->session->getSessionValue('search_survey_type'); | |||
| } | |||
| } | |||
| if ((int)$survey_type > 0) { | |||
| $this->db->where('sy.type_id', $survey_type); | |||
| } else { | |||
| $this->session->deleteSession('search_survey_type'); | |||
| } | |||
| $survey_patient = ''; | |||
| if (isset($this->view->strOutput['searchData']['survey_patient'])) { | |||
| $this->session->deleteSession('search_survey_patient'); | |||
| $survey_patient = $this->view->strOutput['searchData']['survey_patient']; | |||
| $this->session->refreshSession('search_survey_patient', $survey_patient); | |||
| } else { | |||
| if ($this->session->getSessionValue('search_survey_patient') !== false) { | |||
| $survey_patient = $this->session->getSessionValue('search_survey_patient'); | |||
| } | |||
| } | |||
| if (trim($survey_patient) != '') { | |||
| //$this->db->where("CONCAT(sry.name, ' ', sry.name)", $survey_patient, 'LIKE'); | |||
| $patient_words = $this->utility->splitWords($survey_patient); | |||
| $patient_subquery = []; | |||
| if (is_array($patient_words)) { | |||
| foreach($patient_words as $word) { | |||
| $patient_subquery[] = "CONCAT(sry.name, ' ', sry.surname) LIKE '%$word%'"; | |||
| } | |||
| if (!empty($patient_subquery)) { | |||
| $patient_subquery = implode(' AND ', $patient_subquery); | |||
| } | |||
| } | |||
| if (!is_array($patient_subquery)) { | |||
| $this->db->where("(".$patient_subquery.")"); | |||
| } | |||
| } else { | |||
| $this->session->deleteSession('search_survey_patient'); | |||
| } | |||
| $this->view->survey = $this->db | |||
| ->join('survey_registry sry', 'sry.survey_id=sy.id') | |||
| ->join('users u', 'u.id=sy.manager_id') | |||
| ->join('survey_types sts', 'sts.id=sy.type_id') | |||
| ->orderBy('sy.'.$this->view->orderField, $this->view->orderDir) | |||
| ->paginate('survey sy', $this->view->currentPage, ['sy.*', 'sry.*', 'sy.id survey_id', 'sy.created_at survey_created_at', 'u.name manager_name', 'u.surname manager_surname', 'sts.survey_label survey_label', "(SELECT COUNT(*) FROM survey_attachments satt WHERE satt.survey_uuid LIKE sy.code) attach_count"]); | |||
| if (is_array($this->view->survey) && !empty($this->view->survey)) { | |||
| foreach($this->view->survey as $index => $item) { | |||
| if (($item['manager_id'] == $this->user->getUserId()) || $this->user->is([ADMIN_ROLE_ID, GLOBAL_MANAGER_ID])) { | |||
| $this->view->survey[$index]['extra_buttons'] = true; | |||
| } else { | |||
| $this->view->survey[$index]['extra_buttons'] = false; | |||
| } | |||
| } | |||
| } | |||
| $this->view->testt = $this->db->getLastQuery(); | |||
| $this->setPagination($this->db, $this->db->totalCount, $this->view->currentPage, $this->view->baseUri.'survey-list/'.time().'/'.$this->view->orderField.'/'.$this->view->orderDir); | |||
| $this->actionTitle = _('Survey'); | |||
| return $this->setJsonView('surveyList'); | |||
| } | |||
| public function surveyEdit() { | |||
| if(!$this->checkPermissions([ADMIN_ROLE_ID, GLOBAL_MANAGER_ID, MANAGER_ID])) { | |||
| return $this->redirect('login', 'permissionDenied'); | |||
| } | |||
| $id = $this->getPost('id', 0); | |||
| $this->view->id = $id; | |||
| $op_label = $id == 0 ? _('New') : _('Edit'); | |||
| $this->view->debug = $data; | |||
| //Manager clinical center | |||
| $this->view->manager_cc = []; | |||
| $cc = $this->db | |||
| ->where('ucct.user_id', $this->user->getUserId()) | |||
| ->where('ucct.role_id', MANAGER_ID) | |||
| ->join('clinical_centers cc', 'cc.id=ucct.center_id') | |||
| ->getOne('users_clinical_centers_to ucct', 'ucct.center_id, cc.description'); | |||
| if (isset($cc['center_id'])) { | |||
| $this->view->manager_cc = $cc; | |||
| } | |||
| $survey_types = $this->db->where('status', 1)->where('center_id', $cc['center_id'])->orderBy('survey_label', 'asc')->get('survey_types'); | |||
| $this->view->survey_type_list = []; | |||
| if (is_array($survey_types)) { | |||
| foreach($survey_types as $item) { | |||
| $this->view->survey_type_list[$item['id']] = $item['survey_label']; | |||
| } | |||
| } | |||
| $this->view->userData = $this->db | |||
| ->where('sy.id', $id) | |||
| ->join('survey_registry sry', 'sry.survey_id=sy.id', 'INNER') | |||
| ->getOne('survey sy', 'sy.*, sry.*, sy.id survey_id'); | |||
| $this->actionTitle = _('Survey').' : '.$op_label; | |||
| return $this->setJsonView('surveyEdit'); | |||
| } | |||
| //Survey saved and sent by Manager | |||
| public function surveySave() { | |||
| if(!$this->checkPermissions([ADMIN_ROLE_ID, GLOBAL_MANAGER_ID, MANAGER_ID])) { | |||
| return $this->redirect('login', 'permissionDenied'); | |||
| } | |||
| $data = $this->getPost('data', null); | |||
| $survey_id = $data['id']['value']; | |||
| $center_id = (int)$data['center_id']['value']; | |||
| /*$bpMin = (int)$data['request_bp_min']['value']; | |||
| $bpMax = (int)$data['request_bp_max']['value']; | |||
| $heartRate = (int)$data['request_heart_rate']['value']; | |||
| $oxygenSaturation = (int)$data['request_oxy_sat']['value'];*/ | |||
| //Clinical center documents | |||
| $documents = $this->db->where('center_id', $center_id)->get('clinical_center_documents'); | |||
| if ($center_id < 1) { | |||
| return $this->setRawJsonResponse('err', "Impossibile inviare la scheda, il centro clinico dell'utente corrente non è valido."); | |||
| } | |||
| if (empty($documents)) { | |||
| return $this->setRawJsonResponse('err', "Impossibile inviare la scheda, il centro clinico dell'utente corrente non è provvisto di documenti validi (testo e-mail per i pazienti, informativa sulla privacy, ecc.)"); | |||
| } | |||
| if (trim($data['name']['value']) == '') { | |||
| return $this->setRawJsonResponse('err', _('Please provide the Name'), ['class'=>$data['name']['class']]); | |||
| } | |||
| if (trim($data['surname']['value']) == '') { | |||
| return $this->setRawJsonResponse('err', _('Please provide the Surname'), ['class'=>$data['surname']['class']]); | |||
| } | |||
| if (trim($data['birthdate']['value']) == '') { | |||
| return $this->setRawJsonResponse('err', _('Birthdate is required'), ['class'=>$data['birthdate']['class']]); | |||
| } | |||
| if (trim($data['sex']['value']) == '') { | |||
| return $this->setRawJsonResponse('err', _('Please provide the Sex'), ['class'=>$data['sex']['class']]); | |||
| } | |||
| if (strtotime($data['birthdate']['value']) > time()) { | |||
| return $this->setRawJsonResponse('err', _('Birthdate cannot be in the future'), ['class'=>$data['birthdate']['class']]); | |||
| } | |||
| if (!$this->utility->validateEmail($data['email']['value'])) { | |||
| return $this->setRawJsonResponse('err', _('E-mail is required and must be a valid address'), ['class'=>$data['email']['class']]); | |||
| } | |||
| if (trim($data['phone']['value']) == '') { | |||
| return $this->setRawJsonResponse('err', _('Phone is required'), ['class'=>$data['phone']['class']]); | |||
| } | |||
| if ((int)$data['survey_type']['value'] == 0) { | |||
| return $this->setRawJsonResponse('err', _('Survey types is required'), ['class'=>$data['survey_type']['class']]); | |||
| } | |||
| $survey_email = null; | |||
| $email_subject = null; | |||
| $survey_privacy = null; | |||
| foreach($documents as $document) { | |||
| switch($document['ducument_type']) { | |||
| case 'recipient_mail': | |||
| $survey_email = $document['document_file']; | |||
| $email_subject = $document['document_subject']; | |||
| break; | |||
| case 'privacy': | |||
| $survey_privacy = $document['document_file']; | |||
| break; | |||
| } | |||
| } | |||
| $email_file = RESOURCE_DIR.'survey/it/documents/centers/'.$center_id.'/'.$survey_email; | |||
| $privacy_file = RESOURCE_DIR.'survey/it/documents/centers/'.$center_id.'/'.$survey_privacy; | |||
| if (!file_exists($email_file) || !file_exists($privacy_file)) { | |||
| return $this->setRawJsonResponse('err', "Impossibile inviare la scheda, i testi associati al centro clinico corrente non sono validi."); | |||
| } | |||
| /*if ($bpMax > 250) { | |||
| return $this->setRawJsonResponse('err', _("Maximum Blood Pressure is too high."), ['class'=>$data['request_bp_max']['class']]); | |||
| } | |||
| if ($bpMin > 250) { | |||
| return $this->setRawJsonResponse('err', _("Minimum Blood Pressure is too high."), ['class'=>$data['request_bp_min']['class']]); | |||
| } | |||
| if ($bpMin > 0 && $bpMax > 0) { | |||
| if ($bpMin > $bpMax) { | |||
| return $this->setRawJsonResponse('err', _("Minimum Blood Pressure cannot be higher than the Maximum one.")); | |||
| } | |||
| } | |||
| if ($heartRate > 250) { | |||
| return $this->setRawJsonResponse('err', _("Heart Rate cannot be higher then 250 bpm."), ['class'=>$data['request_heart_rate']['class']]); | |||
| } | |||
| if ($oxygenSaturation > 100) { | |||
| return $this->setRawJsonResponse('err', _("Oxygen Saturation cannot be higher than 100%."), ['class'=>$data['request_oxy_sat']['class']]); | |||
| }*/ | |||
| $survey_code = strtoupper($this->getGUID()); | |||
| if ($survey_id == 0) { | |||
| $survey_id = $this->db->insert('survey', [ | |||
| 'manager_id'=>$this->user->getUserId(), | |||
| 'type_id'=>$data['survey_type']['value'], | |||
| 'code'=>$survey_code, | |||
| //'bp_min'=>$bpMin, | |||
| //'bn_max'=>$bpMax, | |||
| //'hrate'=>$heartRate, | |||
| //'oxsat'=>$oxygenSaturation, | |||
| 'notes'=>trim(strip_tags($data['request_medremarks']['value'])), | |||
| 'updated_at'=>date('Y-m-d H:i:s'), | |||
| 'created_at'=>date('Y-m-d H:i:s') | |||
| ]); | |||
| } else { | |||
| $this->db->where('id', $survey_id)->update('survey', [ | |||
| 'manager_id'=>$this->user->getUserId(), | |||
| 'type_id'=>$data['survey_type']['value'], | |||
| 'email_failure'=>0, | |||
| 'opened_recipient'=>0, | |||
| 'aswered_recipient'=>0, | |||
| 'remote_added'=>0, | |||
| //'bp_min'=>$bpMin, | |||
| //'bn_max'=>$bpMax, | |||
| //'hrate'=>$heartRate, | |||
| //'oxsat'=>$oxygenSaturation, | |||
| 'notes'=>trim(strip_tags($data['request_medremarks']['value'])), | |||
| 'updated_at'=>date('Y-m-d H:i:s') | |||
| ]); | |||
| $code_result = $this->db->where('id', $survey_id)->getOne('survey', 'code'); | |||
| if (isset($code_result['code'])) { | |||
| $survey_code = $code_result['code']; | |||
| } | |||
| } | |||
| $this->db->replace('survey_registry', [ | |||
| 'survey_id'=>$survey_id, | |||
| 'name'=>trim($data['name']['value']), | |||
| 'surname'=>trim($data['surname']['value']), | |||
| 'sex'=>$data['sex']['value'], | |||
| 'birthdate'=>$data['birthdate']['value'], | |||
| 'email'=>strtolower($data['email']['value']), | |||
| 'phone'=>trim($data['phone']['value']), | |||
| 'created_at'=>date('Y-m-d H:i:s') | |||
| ]); | |||
| $survey_domain = $this->config['settings']['sportellocura']['domain']; | |||
| $survey_link = $survey_domain.'#/survey/'.$survey_code; | |||
| $string_body = file_get_contents($email_file); | |||
| $tmp_body = vsprintf($string_body, [trim($data['name']['value']), trim($data['surname']['value']), $survey_link]); | |||
| $html_mail_body = $this->partial('Message/Email/survey-template', ['body'=>$tmp_body, 'email_title'=>$email_subject]); | |||
| $this->setMessageQueue($email_subject, $html_mail_body, $data['email']['value'], $survey_id); | |||
| return $this->setRawJsonResponse('ok', "Scheda inviata correttamente.", ['log'=>[]], ['button'=>'goto', 'destination'=>'survey-list/'.time().'/created_at/desc/1']); | |||
| } | |||
| public function getSurveyEmptyForm() { | |||
| $type_id = $this->getPost('survey_type_id', 0); | |||
| $html = ''; | |||
| if ($type_id > 0) { | |||
| $type = $this->db->where('id', $type_id)->getOne('survey_types'); | |||
| $this->setSurveyForm($type['survey_lang'], $type['survey_tag'], []); | |||
| $html = $this->partial('Survey/form'); | |||
| } | |||
| return $this->setRawJsonResponse('ok', '', ['html'=>$html]); | |||
| } | |||
| //Ajax for modal preview | |||
| public function getSurveyAnswers() { | |||
| $id = $this->getPost('survey_id', 0); | |||
| $attachs = []; | |||
| $survey_data = []; | |||
| $html = null; | |||
| $survey = $this->db | |||
| ->join('survey_registry sr', 'sr.survey_id=s.id') | |||
| ->where('s.id', $id) | |||
| ->getOne('survey s', 's.code, s.bp_min, s.bn_max, s.hrate, s.oxsat, s.notes, s.json_answers, sr.name, sr.surname, sr.birthdate, sr.email, sr.phone'); | |||
| if (isset($survey['code'])) { | |||
| $survey_data = json_decode($survey['json_answers'], true); | |||
| $attachs = $this->db->where('survey_uuid', $survey['code'], 'LIKE')->get('survey_attachments'); | |||
| } | |||
| $html = $this->partial('Survey/survey-list-preview', ['survey'=>$survey, 'data'=>$survey_data, 'attachs'=>$attachs]); | |||
| return $this->setRawJsonResponse('ok', '', ['html'=>$html]); | |||
| } | |||
| //Ajax | |||
| public function sendbackSurveyMessage() { | |||
| if(!$this->checkPermissions([ADMIN_ROLE_ID, GLOBAL_MANAGER_ID, MANAGER_ID])) { | |||
| return $this->setRawJsonResponse('err', _('Permission denied.')); | |||
| } | |||
| $survey_uuid = $this->getPost('survey_uuid', null); | |||
| $recipient = $this->getPost('recipient', null); | |||
| if (!is_null($survey_uuid)) { | |||
| $update1 = $this->db | |||
| ->where('code', $survey_uuid) | |||
| ->update('survey', [ | |||
| 'json_answers'=>NULL, | |||
| 'opened_recipient'=>0, | |||
| 'aswered_recipient'=>0, | |||
| 'aswered_date'=>NULL, | |||
| 'remote_added'=>0, | |||
| 'remote_added_date'=>NULL, | |||
| 'remote_report_created'=>0, | |||
| 'updated_at'=>date('Y-m-d H:i:s'), | |||
| 'created_at'=>date('Y-m-d H:i:s') | |||
| ]); | |||
| if ($update1) { | |||
| $update2 = $this->db | |||
| ->where('msg_body', '%'.$survey_uuid.'%', 'LIKE') | |||
| ->where('msg_sent', 1) | |||
| ->update('survey_queue', [ | |||
| 'msg_sent'=>0, | |||
| 'msg_sent_date'=>NULL | |||
| ]); | |||
| if ($update2) { | |||
| //Log | |||
| $this->db->insert('survey_sentback_log', [ | |||
| 'survey_uuid'=>$survey_uuid, | |||
| 'recipient'=>$recipient, | |||
| 'created_at'=>date('Y-m-d H:i:s') | |||
| ]); | |||
| return $this->setRawJsonResponse('ok', 'Scheda inviata correttamente.'); | |||
| } else { | |||
| return $this->setRawJsonResponse('err', _('Update error (Cod. 2)')); | |||
| } | |||
| } else { | |||
| return $this->setRawJsonResponse('err', _('Update error (Cod. 1)')); | |||
| } | |||
| } else { | |||
| return $this->setRawJsonResponse('err', _('Data not valid'), []); | |||
| } | |||
| } | |||
| //Ajax | |||
| public function deleteSurvey() { | |||
| if(!$this->checkPermissions([ADMIN_ROLE_ID, GLOBAL_MANAGER_ID, MANAGER_ID])) { | |||
| return $this->setRawJsonResponse('err', _('Permission denied.')); | |||
| } | |||
| $survey_uuid = $this->getPost('survey_uuid', null); | |||
| $survey_id = $this->getPost('survey_id', null); | |||
| $attach = $this->db->where('survey_uuid', $survey_uuid)->get('survey_attachments'); | |||
| if (is_array($attach) && !empty($attach)) { | |||
| foreach($attach as $item) { | |||
| @unlink(ATTACH_DIR.$item['uuid']); | |||
| $this->db->where('uuid', $item['uuid'])->delete('survey_attachments'); | |||
| } | |||
| } | |||
| $registry = $this->db->where('survey_id', $survey_id)->delete('survey_registry'); | |||
| $sentback_log = $this->db->where('survey_uuid', $survey_uuid)->delete('survey_sentback_log'); | |||
| if ($this->db->where('code', $survey_uuid)->delete('survey')) { | |||
| return $this->setRawJsonResponse('ok', _('Survey successfully deleted')); | |||
| } else { | |||
| return $this->setRawJsonResponse('err', _('Unable to delete the survey')); | |||
| } | |||
| } | |||
| private function setSurveyForm($survey_lang, $survey_tag, $survey=[]) { | |||
| $structure = json_decode(file_get_contents(RESOURCE_DIR.'survey/'.$survey_lang.'/'.$survey_tag.'.json'), true); | |||
| $global_fields = json_decode(file_get_contents(RESOURCE_DIR.'survey/'.$survey_lang.'/global.json'), true); | |||
| $this->view->structure = array_merge($structure, $global_fields); | |||
| if (is_array($survey) && !empty($survey)) { | |||
| $this->view->survey_patient_string = strip_tags($survey['patient_surname']).' '.strip_tags($survey['patient_name']).', '.$this->helper->getDateString($survey['partient_bday'], false).', '.$survey['patient_email']; | |||
| } else { | |||
| $this->view->survey_patient_string = ''; | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,63 @@ | |||
| <?php | |||
| if (!function_exists('debug')) { | |||
| function debug($structure=null, $html=true) { | |||
| global $config; | |||
| if ($config['settings']['debug']) { | |||
| $nl = !$html ? "\n" : "<br>"; | |||
| if (is_array($structure) || is_object($structure)) { | |||
| if (!$html) { | |||
| print "\n"; print_r($structure); | |||
| } else { | |||
| print '<pre>'; print_r($structure); print '</pre>'; | |||
| } | |||
| return; | |||
| } | |||
| if (is_bool($structure)) { | |||
| echo $structure === true ? "\n".'Bool: true'.$nl : "\n".'Bool: false'.$nl; | |||
| return; | |||
| } | |||
| if (is_numeric($structure)) { | |||
| echo "\n".'Numeric: ', $structure.$nl; | |||
| return; | |||
| } | |||
| if (is_string($structure)) { | |||
| echo "\n".'String: ', $structure.$nl; | |||
| return; | |||
| } | |||
| if (is_null($structure)) { | |||
| echo "null\n"; | |||
| return; | |||
| } | |||
| echo "\n".$structure; | |||
| } else { | |||
| return null; | |||
| } | |||
| } //function | |||
| } //if | |||
| function _t($textId) { | |||
| //return utf8_encode(_($textId)); | |||
| } | |||
| function leadingZeros($number) { | |||
| return (int)$number<10 ? "0$number" : $number; | |||
| } | |||
| function optionSelected($value) { | |||
| if ($value === true) return 'selected="selected"'; | |||
| return null; | |||
| } | |||
| @@ -0,0 +1,121 @@ | |||
| <!doctype html> | |||
| <html lang="<?php echo $this->locale->setCurrentLanguage(); ?>"> | |||
| <head> | |||
| <meta charset="utf-8"> | |||
| <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |||
| <style> | |||
| #loader-wrapper {position: absolute; top: 0; left: 50%; z-index: 10001; font-size: 12px; } | |||
| #loader-content {position: relative; left: -50%; background-color: #F9EDC3; color: #222222; padding: 5px; text-align: center; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border: 1px solid #EDC584; -webkit-box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75); | |||
| -moz-box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75); | |||
| box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75);} | |||
| </style> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/bootstrap.min.css"> | |||
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.css" /> | |||
| <link rel="stylesheet" type="text/css" href="<?php echo $this->getPublicUri(); ?>css/tooltipster.bundle.min.css" /> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/style.css<?php echo $this->setFileTimestamp(); ?>"> | |||
| <title><?php echo $this->settings['app-title']; ?></title> | |||
| <script id="global-js-variables" src="<?php echo $this->getPublicUri(); ?>global-js"></script> | |||
| <link rel="shortcut icon" href="/favicon/favicon.ico" type="image/x-icon"> | |||
| </head> | |||
| <body class="decorated"> | |||
| <div id="loader-wrapper"> | |||
| <div id="loader-content"> | |||
| <?php echo _('Loading...'); ?> | |||
| </div> | |||
| </div> | |||
| <input type="hidden" id="api-key" value="<?php echo $this->config['settings']['api-key']; ?>"> | |||
| <input type="hidden" id="group-id" value="0"> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="user-id" value="0"> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="user-username" value=""> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="static-uri" value="<?php echo $this->config['settings']['static-uri']; ?>"> | |||
| <div id="main" class="h-100"></div> | |||
| <div id="transfer-manager"> | |||
| <div id="tm-arrow-wrapper"> | |||
| <div id="tm-arrow"><?php echo _('Done'); ?></div> | |||
| </div> | |||
| <div id="tm-title"> | |||
| <div class="row"> | |||
| <div class="col-lg-6"><span class="icon-upload3"></span> (<span id="tm-status-label">Online</span>)</div> | |||
| <div class="col-lg-6 clearfix"> | |||
| <div class="float-right"> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div id="tm-container"> | |||
| <form method="post" id="post-tus-upload"> | |||
| <div class="row"> | |||
| <div class="col-lg-2 margin-bottom-20"> | |||
| <input type="file" multiple="multiple" class="" id="tus-upload-control"> | |||
| <button type="button" class="btn btn-success" id="tus-upload-select-dialog"><span class="icon-folder-open"></span> </button> | |||
| <button type="button" class="btn btn-primary" id="btn-tus-upload" data-postid="1"><span class="icon-play2"></span></button> | |||
| </div> | |||
| <div class="col-lg-10"> | |||
| <div id="upload-list-table-wrapper"> | |||
| <table class="table table-sm table-hover" id="tus-upload-file-list"> | |||
| <thead> | |||
| <tr> | |||
| <!--<th width="5%"><?php echo _('#ID'); ?></th>--> | |||
| <th width="3%"></th> | |||
| <th><?php echo _('Name'); ?></th> | |||
| <th width="15%" class="text-center"></th> | |||
| <th width="10%">MB</th> | |||
| <th width="5%" class="text-center"> | |||
| <button type="button" class="btn btn-warning btn-sm btn-clean-upload-list"><span class="icon-paint-format"></span></button> | |||
| </th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| </div> | |||
| </div> | |||
| <div id="overlay"> | |||
| <div id="text"><img src="/images/spinner.svg" /></div> | |||
| </div> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/fonts.css"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/font-awesome.min.css"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/component-chosen.min.css"> | |||
| <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.js"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/bootstrap.min.js"></script> | |||
| <script src="https://rawgit.com/saribe/eModal/master/dist/eModal.min.js"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/chosen.jquery.min.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/tus.min.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/sammy/sammy-latest.min.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/router.js<?php echo $this->setFileTimestamp(); ?>" type="text/javascript" charset="utf-8"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/app.js<?php echo $this->setFileTimestamp(); ?>" type="text/javascript" charset="utf-8"></script> | |||
| <script type="text/javascript" src="<?php echo $this->getPublicUri(); ?>js/tooltipster.bundle.min.js"></script> | |||
| <script async defer src="https://maps.googleapis.com/maps/api/js?key=<?php echo $this->config['settings']['google-maps-key']; ?>&language=en&callback=initMap" | |||
| type="text/javascript"></script> | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,114 @@ | |||
| <!doctype html> | |||
| <html lang="<?php echo $this->locale->setCurrentLanguage(); ?>"> | |||
| <head> | |||
| <meta charset="utf-8"> | |||
| <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |||
| <style> | |||
| #loader-wrapper {position: absolute; top: 0; left: 50%; z-index: 10001; font-size: 12px; } | |||
| #loader-content {position: relative; left: -50%; background-color: #F9EDC3; color: #222222; padding: 5px; text-align: center; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border: 1px solid #EDC584; -webkit-box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75); | |||
| -moz-box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75); | |||
| box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75);} | |||
| </style> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/bootstrap.min.css"> | |||
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.css" /> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/style.css<?php echo $this->setFileTimestamp(); ?>"> | |||
| <title><?php echo $this->settings['app-title']; ?></title> | |||
| <script id="global-js-variables" src="<?php echo $this->getPublicUri(); ?>global-js"></script> | |||
| </head> | |||
| <body class="decorated"> | |||
| <div id="loader-wrapper"> | |||
| <div id="loader-content"> | |||
| <?php echo _('Loading...'); ?> | |||
| </div> | |||
| </div> | |||
| <input type="hidden" id="api-key" value="<?php echo $this->config['settings']['api-key']; ?>"> | |||
| <input type="hidden" id="group-id" value="0"> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="user-id" value="0"> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="static-uri" value="<?php echo $this->config['settings']['static-uri']; ?>"> | |||
| <div id="main" class="h-100"></div> | |||
| <div id="transfer-manager"> | |||
| <div id="tm-arrow-wrapper"> | |||
| <div id="tm-arrow"><?php echo _('Done'); ?></div> | |||
| </div> | |||
| <div id="tm-title"> | |||
| <div class="row"> | |||
| <div class="col-lg-6"><span class="icon-upload3"></span> (<span id="tm-status-label">Online</span>)</div> | |||
| <div class="col-lg-6 clearfix"> | |||
| <div class="float-right"> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div id="tm-container"> | |||
| <form method="post" id="post-tus-upload"> | |||
| <div class="row"> | |||
| <div class="col-lg-2 margin-bottom-20"> | |||
| <input type="file" multiple="multiple" class="" id="tus-upload-control"> | |||
| <button type="button" class="btn btn-success" id="tus-upload-select-dialog"><span class="icon-folder-open"></span> </button> | |||
| <button type="button" class="btn btn-primary" id="btn-tus-upload" data-postid="1"><span class="icon-play2"></span></button> | |||
| </div> | |||
| <div class="col-lg-10"> | |||
| <div id="upload-list-table-wrapper"> | |||
| <table class="table table-sm table-hover" id="tus-upload-file-list"> | |||
| <thead> | |||
| <tr> | |||
| <!--<th width="5%"><?php echo _('#ID'); ?></th>--> | |||
| <th width="3%"></th> | |||
| <th><?php echo _('Name'); ?></th> | |||
| <th width="15%" class="text-center"></th> | |||
| <th width="10%">MB</th> | |||
| <th width="5%" class="text-center"> | |||
| <button type="button" class="btn btn-warning btn-sm btn-clean-upload-list"><span class="icon-paint-format"></span></button> | |||
| </th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| </div> | |||
| </div> | |||
| <div id="overlay"> | |||
| <div id="text"><img src="/images/spinner.svg" /></div> | |||
| </div> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/fonts.css"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/component-chosen.min.css"> | |||
| <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.js"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/bootstrap.min.js"></script> | |||
| <script src="//rawgit.com/saribe/eModal/master/dist/eModal.min.js"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/chosen.jquery.min.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/tus.min.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/sammy/sammy-latest.min.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/router.js<?php echo $this->setFileTimestamp(); ?>" type="text/javascript" charset="utf-8"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/app.js<?php echo $this->setFileTimestamp(); ?>" type="text/javascript" charset="utf-8"></script> | |||
| <script async defer src="https://maps.googleapis.com/maps/api/js?key=<?php echo $this->config['settings']['google-maps-key']; ?>&language=en&callback=initMap" | |||
| type="text/javascript"></script> | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,70 @@ | |||
| <!doctype html> | |||
| <html lang="<?php echo $this->locale->setCurrentLanguage(); ?>"> | |||
| <head> | |||
| <meta charset="utf-8"> | |||
| <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |||
| <style> | |||
| #loader-wrapper {position: absolute; top: 0; left: 50%; z-index: 10001; font-size: 12px; } | |||
| #loader-content {position: relative; left: -50%; background-color: #F9EDC3; color: #222222; padding: 5px; text-align: center; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border: 1px solid #EDC584; -webkit-box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75); | |||
| -moz-box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75); | |||
| box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75);} | |||
| </style> | |||
| <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/font-awesome.min.css"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/jquery.datetimepicker.css"> | |||
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.css" /> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/remote-visit-style.css<?php echo $this->setFileTimestamp(); ?>"> | |||
| <title><?php echo $this->settings['app-title']; ?></title> | |||
| <script id="global-js-variables" src="<?php echo $this->getPublicUri(); ?>global-js"></script> | |||
| <link rel="shortcut icon" href="/images/logo-icons/favicon.ico" type="image/x-icon"> | |||
| </head> | |||
| <body> | |||
| <div id="loader-wrapper"> | |||
| <div id="loader-content"> | |||
| <?php echo _('Loading...'); ?> | |||
| </div> | |||
| </div> | |||
| <input type="hidden" id="api-key" value="<?php echo $this->config['settings']['api-key']; ?>"> | |||
| <input type="hidden" id="group-id" value="0"> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="user-id" value="0"> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="user-username" value=""> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="static-uri" value="<?php echo $this->config['settings']['static-uri']; ?>"> | |||
| <div id="main" class="h-100"></div> | |||
| <div id="overlay"> | |||
| <div id="text"><img src="/images/spinner.svg" /></div> | |||
| </div> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/fonts.css"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/component-chosen.min.css"> | |||
| <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> | |||
| <!-- | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/bootstrap.min.js"></script> | |||
| --> | |||
| <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script> | |||
| <script src="https://unpkg.com/emodal@1.2.69/dist/eModal.min.js"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.js"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/chosen.jquery.min.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/jquery.datetimepicker.full.min.js"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/sammy/sammy-latest.min.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/jquery.mask.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/router.js<?php echo $this->setFileTimestamp(); ?>" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/app.js<?php echo $this->setFileTimestamp(); ?>" type="text/javascript" charset="utf-8"></script> | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,70 @@ | |||
| <!doctype html> | |||
| <html lang="<?php echo $this->locale->setCurrentLanguage(); ?>"> | |||
| <head> | |||
| <meta charset="utf-8"> | |||
| <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |||
| <style> | |||
| #loader-wrapper {position: absolute; top: 0; left: 50%; z-index: 10001; font-size: 12px; } | |||
| #loader-content {position: relative; left: -50%; background-color: #F9EDC3; color: #222222; padding: 5px; text-align: center; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border: 1px solid #EDC584; -webkit-box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75); | |||
| -moz-box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75); | |||
| box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75);} | |||
| </style> | |||
| <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/font-awesome.min.css"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/jquery.datetimepicker.css"> | |||
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.css" /> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/remote-visit-style.css<?php echo $this->setFileTimestamp(); ?>"> | |||
| <title><?php echo $this->settings['app-title']; ?></title> | |||
| <script id="global-js-variables" src="<?php echo $this->getPublicUri(); ?>global-js"></script> | |||
| <link rel="shortcut icon" href="/images/logo-icons/favicon.ico" type="image/x-icon"> | |||
| </head> | |||
| <body> | |||
| <div id="loader-wrapper"> | |||
| <div id="loader-content"> | |||
| <?php echo _('Loading...'); ?> | |||
| </div> | |||
| </div> | |||
| <input type="hidden" id="api-key" value="<?php echo $this->config['settings']['api-key']; ?>"> | |||
| <input type="hidden" id="group-id" value="0"> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="user-id" value="0"> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="user-username" value=""> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="static-uri" value="<?php echo $this->config['settings']['static-uri']; ?>"> | |||
| <div id="main" class="h-100"></div> | |||
| <div id="overlay"> | |||
| <div id="text"><img src="/images/spinner.svg" /></div> | |||
| </div> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/fonts.css"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/component-chosen.min.css"> | |||
| <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> | |||
| <!-- | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/bootstrap.min.js"></script> | |||
| --> | |||
| <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script> | |||
| <script src="https://unpkg.com/emodal@1.2.69/dist/eModal.min.js"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.js"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/chosen.jquery.min.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/jquery.datetimepicker.full.min.js"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/sammy/sammy-latest.min.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/jquery.mask.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/router.js<?php echo $this->setFileTimestamp(); ?>" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/app.js<?php echo $this->setFileTimestamp(); ?>" type="text/javascript" charset="utf-8"></script> | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,136 @@ | |||
| <!doctype html> | |||
| <html lang="<?php echo $this->locale->setCurrentLanguage(); ?>"> | |||
| <head> | |||
| <meta charset="utf-8"> | |||
| <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |||
| <style> | |||
| #loader-wrapper {position: absolute; top: 0; left: 50%; z-index: 10001; font-size: 12px; } | |||
| #loader-content {position: relative; left: -50%; background-color: #F9EDC3; color: #222222; padding: 5px; text-align: center; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border: 1px solid #EDC584; -webkit-box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75); | |||
| -moz-box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75); | |||
| box-shadow: 0px 1px 11px -2px rgba(0,0,0,0.75);} | |||
| </style> | |||
| <!--<link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/bootstrap.min.css">--> | |||
| <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous"> | |||
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.css" /> | |||
| <link rel="stylesheet" type="text/css" href="<?php echo $this->getPublicUri(); ?>css/tooltipster.bundle.min.css" /> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/jquery.datetimepicker.css"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/font-awesome.min.css"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/style.css<?php echo $this->setFileTimestamp(); ?>"> | |||
| <title><?php echo $this->settings['app-title']; ?></title> | |||
| <script id="global-js-variables" src="<?php echo $this->getPublicUri(); ?>global-js"></script> | |||
| <?php /* | |||
| <link rel="shortcut icon" href="/favicon/favicon.ico" type="image/x-icon"> | |||
| */ ?> | |||
| </head> | |||
| <body class="decorated"> | |||
| <div id="loader-wrapper"> | |||
| <div id="loader-content"> | |||
| <?php echo _('Loading...'); ?> | |||
| </div> | |||
| </div> | |||
| <input type="hidden" id="api-key" value="<?php echo $this->config['settings']['api-key']; ?>"> | |||
| <input type="hidden" id="group-id" value="0"> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="user-id" value="0"> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="user-username" value=""> <!-- Set by login (AJAX) --> | |||
| <input type="hidden" id="static-uri" value="<?php echo $this->config['settings']['static-uri']; ?>"> | |||
| <div id="main" class="h-100"></div> | |||
| <div id="transfer-manager"> | |||
| <div id="tm-arrow-wrapper"> | |||
| <div id="tm-arrow"><?php echo _('Done'); ?></div> | |||
| </div> | |||
| <div id="tm-title"> | |||
| <div class="row"> | |||
| <div class="col-lg-6"><span class="icon-upload3"></span> (<span id="tm-status-label">Online</span>)</div> | |||
| <div class="col-lg-6 clearfix"> | |||
| <div class="float-right"> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div id="tm-container"> | |||
| <form method="post" id="post-tus-upload"> | |||
| <div class="row"> | |||
| <div class="col-lg-2 margin-bottom-20"> | |||
| <input type="file" multiple="multiple" class="" id="tus-upload-control"> | |||
| <button type="button" class="btn btn-success" id="tus-upload-select-dialog"><span class="icon-folder-open"></span> </button> | |||
| <button type="button" class="btn btn-primary" id="btn-tus-upload" data-postid="1"><span class="icon-play2"></span></button> | |||
| </div> | |||
| <div class="col-lg-10"> | |||
| <div id="upload-list-table-wrapper"> | |||
| <table class="table table-sm table-hover" id="tus-upload-file-list"> | |||
| <thead> | |||
| <tr> | |||
| <!--<th width="5%"><?php echo _('#ID'); ?></th>--> | |||
| <th width="3%"></th> | |||
| <th><?php echo _('Name'); ?></th> | |||
| <th width="15%" class="text-center"></th> | |||
| <th width="10%">MB</th> | |||
| <th width="5%" class="text-center"> | |||
| <button type="button" class="btn btn-warning btn-sm btn-clean-upload-list"><span class="icon-paint-format"></span></button> | |||
| </th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| </div> | |||
| </div> | |||
| <div id="overlay"> | |||
| <div id="text"><img src="/images/spinner.svg" /></div> | |||
| </div> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/fonts.css"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/component-chosen.min.css"> | |||
| <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> | |||
| <!-- | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/bootstrap.min.js"></script> | |||
| --> | |||
| <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.js"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script> | |||
| <script src="https://unpkg.com/emodal@1.2.69/dist/eModal.min.js"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/chosen.jquery.min.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/jquery.datetimepicker.full.min.js"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/tus.min.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/sammy/sammy-latest.min.js" type="text/javascript" charset="utf-8"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/router.js<?php echo $this->setFileTimestamp(); ?>" type="text/javascript" charset="utf-8"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script> | |||
| <script src="<?php echo $this->getPublicUri(); ?>js/app.js<?php echo $this->setFileTimestamp(); ?>" type="text/javascript" charset="utf-8"></script> | |||
| <script type="text/javascript" src="<?php echo $this->getPublicUri(); ?>js/tooltipster.bundle.min.js"></script> | |||
| <script async defer src="https://maps.googleapis.com/maps/api/js?key=<?php echo $this->config['settings']['google-maps-key']; ?>&language=en&callback=initMap" | |||
| type="text/javascript"></script> | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,19 @@ | |||
| <!doctype html> | |||
| <html> | |||
| <head> | |||
| <!-- Required meta tags --> | |||
| <meta charset="utf-8"> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |||
| <!-- Bootstrap CSS --> | |||
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> | |||
| <title></title> | |||
| </head> | |||
| <body> | |||
| [content] | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,28 @@ | |||
| <!doctype html> | |||
| <html lang="<?php echo $this->locale->getCurrentLanguage(); ?>"> | |||
| <head> | |||
| <!-- Required meta tags --> | |||
| <meta charset="utf-8"> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |||
| <!-- Bootstrap CSS --> | |||
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/style.css<?php echo $this->setFileTimestamp(); ?>"> | |||
| <title><?php echo $this->settings['app-title']; ?></title> | |||
| </head> | |||
| <body class="decorated"> | |||
| <div id="main" class="h-100"></div> | |||
| <!-- Optional JavaScript --> | |||
| <!-- jQuery first, then Popper.js, then Bootstrap JS --> | |||
| <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> | |||
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,103 @@ | |||
| <!doctype html> | |||
| <html lang="en"> | |||
| <head> | |||
| <!-- Required meta tags --> | |||
| <meta charset="utf-8"> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |||
| <!-- Bootstrap CSS --> | |||
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> | |||
| <link rel="stylesheet" href="<?php echo $this->getPublicUri(); ?>css/style.css<?php echo $this->setFileTimestamp(); ?>"> | |||
| <title>Test URL</title> | |||
| <style> | |||
| .loader {display: none;} | |||
| </style> | |||
| </head> | |||
| <body class="decorated"> | |||
| <div class="container"> | |||
| <h1>Test HTTP</h1> | |||
| <hr> | |||
| <form id="api-form"> | |||
| <div class="form-group row"> | |||
| <label for="url" class="col-sm-2 col-form-label">URL</label> | |||
| <div class="col-sm-10"> | |||
| <input type="text" class="form-control" id="url" value=""> | |||
| </div> | |||
| </div> | |||
| <div class="form-group row"> | |||
| <label for="url" class="col-sm-2 col-form-label">Params</label> | |||
| <div class="col-sm-10"> | |||
| <input type="text" class="form-control" id="params" value="{}"> | |||
| </div> | |||
| </div> | |||
| <div class="form-group row"> | |||
| <label for="header" class="col-sm-2 col-form-label">Header</label> | |||
| <div class="col-sm-10"> | |||
| <input type="text" class="form-control" id="header" value='{"api-key":""}'> | |||
| </div> | |||
| </div> | |||
| <div class="clearfix"> | |||
| <button type="button" class="btn btn-primary btn-test float-right">Test<span class="loader"> [...]</span></button> | |||
| </div> | |||
| <hr> | |||
| <div class="card"> | |||
| <div class="card-body"> | |||
| <textarea class="form-control" rows="15" id="output"></textarea> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| </div> | |||
| <!-- Optional JavaScript --> | |||
| <!-- jQuery first, then Popper.js, then Bootstrap JS --> | |||
| <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> | |||
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> | |||
| <script> | |||
| $(document).ready(function () { | |||
| $('.btn-test').click(function() { | |||
| var url = $('#url').val(); | |||
| var params = $.trim($('#params').val()); | |||
| var header = $('#header').val(); | |||
| if (params == '') params = '{}'; | |||
| params = $.parseJSON(params); | |||
| $('.loader').show(); | |||
| $('#output').html(''); | |||
| $.ajax({ | |||
| dataType: "text", | |||
| url:url, | |||
| data: params, | |||
| headers: $.parseJSON(header), | |||
| method: 'POST', | |||
| success: function(ret) { | |||
| $('.loader').hide(); | |||
| $('#output').html(ret); | |||
| }, | |||
| error: function(XMLHttpRequest, textStatus, errorThrown) { | |||
| $('#output').html('Error: '+textStatus); | |||
| $('.loader').hide(); | |||
| } | |||
| }); | |||
| }); | |||
| }); | |||
| </script> | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,277 @@ | |||
| <?php | |||
| //Wizards | |||
| _('< 10 mins'); | |||
| _('> 10 mins'); | |||
| _('Anasarca'); | |||
| _('Ankles'); | |||
| _('Arrhythmias'); | |||
| _('Arrhythmic'); | |||
| _('Ascites'); | |||
| _('Asthenia'); | |||
| _('At exertion'); | |||
| _('At rest'); | |||
| _('At risk'); | |||
| _('Back'); | |||
| _('Bases wheeze'); | |||
| _('Cardiac activity'); | |||
| _('Central'); | |||
| _('The appearance has been changing'); | |||
| _('Chest pain duration'); | |||
| _('Chest pain time'); | |||
| _('Confusion of mind'); | |||
| _('Constipation'); | |||
| _('Contact with new substances'); | |||
| _('Cough'); | |||
| _('Cough with sputum'); | |||
| _('Cyanosis'); | |||
| _('Diabetes'); | |||
| _('Diabetes mellitus'); | |||
| _('Diarrhea'); | |||
| _('Dry cough'); | |||
| _('Dyslipidemia'); | |||
| _('Dyspnea (Objective exam)'); | |||
| _('Dyspnea (symptom)'); | |||
| _('Dyspnea at rest'); | |||
| _('Edema not classified elsewhere'); | |||
| _('Ended spontaneously'); | |||
| _('Epigastric'); | |||
| _('Essential hypertension (primitive)'); | |||
| _('Faded'); | |||
| _('Family members with the same symptomatology'); | |||
| _('Fever'); | |||
| _('First episode'); | |||
| _('Gastric ulcer'); | |||
| _('Gastritis'); | |||
| _('Gastritis / Ulcers'); | |||
| _('Generalized edema'); | |||
| _('Hallucinations'); | |||
| _('Heartburn'); | |||
| _('Burning'); | |||
| _('Hemoptysis'); | |||
| _('Hepatomegaly'); | |||
| _('Hepatomegaly and unclassified splenomegaly'); | |||
| _('Hypertension'); | |||
| _('Hypertriglyceridemia'); | |||
| _('Inhalation of new substances'); | |||
| _('Insulin'); | |||
| _('Insulin-dependent'); | |||
| _('Itch'); | |||
| _('Legs'); | |||
| _('Lipotimia'); | |||
| _('Margins'); | |||
| _('Metabolism disorders of lipoproteins and other dyslipidemias'); | |||
| _('Mucous sputum'); | |||
| _('Nail clubbing'); | |||
| _('Nausea and vomit'); | |||
| _('Neck, jaw'); | |||
| _('One or more episodes in the last 2 days'); | |||
| _('Oral antidiabetics'); | |||
| _('Other episodes'); | |||
| _('Other information 1'); | |||
| _('Other information 2'); | |||
| _('Other skin changes'); | |||
| _('Pain'); | |||
| _('Peripheral'); | |||
| _('Clear'); | |||
| _('Pleural effusion'); | |||
| _('Pleural effusion in morbid conditions'); | |||
| _('Polycyclic'); | |||
| _('Precordial'); | |||
| _('Presacral'); | |||
| _('Random'); | |||
| _('Respiratory abnormalities'); | |||
| _('Retrosternal'); | |||
| _('Rhythmic'); | |||
| _('Right arm'); | |||
| _('Seconds'); | |||
| _('Sexual intercourse'); | |||
| _('Shoulder, left arm'); | |||
| _('Sputum'); | |||
| _('Sputum with blood'); | |||
| _('Stress dyspnea'); | |||
| _('Sweating'); | |||
| _('Symptoms'); | |||
| _('Syncope'); | |||
| _('Taking new drugs'); | |||
| _('Taking new foods'); | |||
| _('Raised'); | |||
| _('Thyroid diseases'); | |||
| _('Treated with electrical cardioversion'); | |||
| _('Treated with medication'); | |||
| _('Undermined'); | |||
| _('Unspecified kidney failure'); | |||
| _('Visible jugulars'); | |||
| _('Wheezes at the bases'); | |||
| _('Whistles'); | |||
| _('With new partner'); | |||
| _('Ear Symptoms'); | |||
| _('Associated symptoms'); | |||
| _('Otological examination'); | |||
| _('Vestibular system'); | |||
| _('Ear pain'); | |||
| _('Ear discharge'); | |||
| _('Aural fullness'); | |||
| _('Hearing loss'); | |||
| _('Tinnitus'); | |||
| _('Vertigo'); | |||
| _('Vertigo'); | |||
| _('Tumoral mass'); | |||
| _('Cranial nerve palsy I-XII'); | |||
| _('Ear pruritus'); | |||
| _('Fever/chills'); | |||
| _('Nose obstruction'); | |||
| _('Nausea/vomiting'); | |||
| _('Dysphagia/Dysphonia'); | |||
| _('Pinna/pre/retroauricular region'); | |||
| _('Malformation'); | |||
| _('Tumefaction'); | |||
| _('Rush'); | |||
| _('Trauma: laceration, seroma/hematoma, rupture'); | |||
| _('Pain'); | |||
| _('Neoplastic lesions'); | |||
| _('Tympanic membrane (Eardrum)'); | |||
| _('Pre/retroauricular: tags, sinus, pit'); | |||
| _('Stenosis'); | |||
| _('Tumefaction'); | |||
| _('Wax'); | |||
| _('Foreign body'); | |||
| _('Discharge'); | |||
| _('Trauma'); | |||
| _('Neoplastic lesions'); | |||
| _('Perforation'); | |||
| _('Retraction'); | |||
| _('Bulging'); | |||
| _('Inflammation'); | |||
| _('Rush/blisters'); | |||
| _('Anatomical landmarks absent/modified'); | |||
| _('Middle ear'); | |||
| _('Fluid/air-fluid level'); | |||
| _('Purulent collection'); | |||
| _('Cholestestoma (white mass)'); | |||
| _('Tumor'); | |||
| _('Blood'); | |||
| _('Polyps'); | |||
| _('Tuning fork tests'); | |||
| _('Weber lateralized right'); | |||
| _('Weber lateralized left'); | |||
| _('Rinne negative right'); | |||
| _('Rinne positive right'); | |||
| _('Rinne negative left'); | |||
| _('Rinne negative right'); | |||
| _('Eye movements'); | |||
| _('Spontaneous/gaze-evoked nystagmus present'); | |||
| _('Convergence insufficiency'); | |||
| _('Smooth pursuit abnormal'); | |||
| _('Saccades'); | |||
| _('Dix-Hallpike maneuver positive'); | |||
| _('Vestibulo-occular reflex'); | |||
| _('Head-impulse test positive'); | |||
| _('Head shake test positive'); | |||
| _('Fistula test positive'); | |||
| _('Gait pathologic'); | |||
| _('Romberg test positive'); | |||
| _('Unterbeger test positive'); | |||
| _('Cranial nerves examination'); | |||
| _('Normal'); | |||
| _('Facial nerve palsy'); | |||
| _('Facial twitching'); | |||
| _('Facial pain'); | |||
| _('Vocal cord palsy'); | |||
| _('Tongue palsy/fasciculations'); | |||
| //Medical specialties | |||
| _('01TEST_CLINICO'); | |||
| _('02TEST_CLINICO'); | |||
| _('03TEST_CLINICO'); | |||
| _('Pain management'); | |||
| _('Burns'); | |||
| _('Cardiology'); | |||
| _('Category A'); | |||
| _('Dermatology'); | |||
| _('Endocrinology'); | |||
| _('Gastroenterology'); | |||
| _('Geriatrics'); | |||
| _('Hematology'); | |||
| _('Infect. Disease'); | |||
| _('Int. Medicine'); | |||
| _('Speech-Language Pathology'); | |||
| _('Nephrology'); | |||
| _('Neurology'); | |||
| _('Nutrition'); | |||
| _('Dentistry'); | |||
| _('Oncology'); | |||
| _('Ophthalmology'); | |||
| _('Orthopedics'); | |||
| _('Orthopedics'); | |||
| _('Pediatrics'); | |||
| _('Radiology'); | |||
| _('General surgery'); | |||
| _('Urology'); | |||
| _('Vascular Disease'); | |||
| _('Pneumology'); | |||
| _('Wound Care'); | |||
| _('Diabetology'); | |||
| _('Obstetrics'); | |||
| _('Physiatry'); | |||
| _('The fit'); | |||
| _('Loss of consciousness'); | |||
| _('Usual duration of the loss of consciousness'); | |||
| _('From 1 to 5 minutes'); | |||
| _('From 5 to 30 minutes'); | |||
| _('More than 30 minutes'); | |||
| _('During the fit'); | |||
| _('Uncontrolled involuntary movements - Jerkings on both sides'); | |||
| _('Uncontrolled involuntary movements - Jerkings on one side'); | |||
| _('Atypical movements during the fit'); | |||
| _('Tongue bite'); | |||
| _('Foaming'); | |||
| _('Before the fit, are there any premonitory symptoms/phenomena as'); | |||
| _('Mental or behavioural changes'); | |||
| _('Abnormal sensations as'); | |||
| _('Earing voices'); | |||
| _('Seeing persons, animals, things that are not there'); | |||
| _('Strange/bad smelling'); | |||
| _('Others'); | |||
| _('Developmental delay'); | |||
| _('Malaria with brain symptoms in infancy'); | |||
| _('Previous meningitis or encephalitis'); | |||
| _('Head trauma in the past'); | |||
| _('Familial occurrence of epilepsy'); | |||
| _('Abnormalities of neurological examination'); | |||
| _('Neurological examination, main findings'); | |||
| _('Normal gait'); | |||
| _('Unsteady gait (loss of balance)'); | |||
| _('Weakness of one side of the body'); | |||
| _('Normal speech'); | |||
| _('Weakness of both lower limbs (walking still possible)'); | |||
| _('Weakness of both lower limbs (walking not possible)'); | |||
| _('Normal deep tendon reflexes'); | |||
| _('Increased deep tendon reflexes'); | |||
| _('Absent reflexes'); | |||
| _('Babinski sign'); | |||
| _('Reduced sensation on one body side'); | |||
| _('Reduced sensation in stockings distribution'); | |||
| _('Reduced sensation in gloves distribution'); | |||
| _('Tremor or involuntary movements of upper limbs'); | |||
| _('L'); | |||
| _('R'); | |||
| _('Y'); | |||
| _('N'); | |||
| //Languages | |||
| _('italian'); | |||
| _('english'); | |||
| _('french'); | |||
| _('spanish'); | |||
| _('portoguese'); | |||
| //Misc | |||
| _('! Referted'); | |||
| _('! referted'); | |||
| _('referted'); | |||
| _('Referted'); | |||
| _('white'); | |||
| _('green'); | |||
| _('yellow'); | |||
| _('red'); | |||
| @@ -0,0 +1,44 @@ | |||
| <?php | |||
| /*$this->any('/login-window', function ($request, $response, $args) { | |||
| global $locale; | |||
| $response = $response->withJson([ | |||
| 'user' => [], | |||
| 'status' => 'ok', | |||
| 'languageList' => $locale->getLanguageStringList(), | |||
| 'strings' => [ | |||
| 'appTitle' => $locale->config['settings']['app-title'], | |||
| 'username' => _('Username'), | |||
| 'password' => _('Password'), | |||
| 'keep_connected' => _('Keep connected'), | |||
| 'access_button' => _('Login') | |||
| ], | |||
| 'baseInfo' => $locale->getAppInfo() | |||
| ]); | |||
| return $response; | |||
| });*/ | |||
| //Example: http://dev-ght.ttre.cloud/api/login/mainForm/dd=4&de=3 | |||
| /*Array | |||
| ( | |||
| [dd] => 4 | |||
| [de] => 3 | |||
| )*/ | |||
| $this->any('/{controller}/{action}[/{params:.*}]', function ($request, $response, $args) { | |||
| $controller = $args['controller']; | |||
| $action = $args['action']; | |||
| require CONTROLLER_DIR.$controller.'Controller.php'; | |||
| $class = $controller.'Controller'; | |||
| $response = call_user_func(array(new $class(), $action), $args); | |||
| return $response; | |||
| }); | |||
| @@ -0,0 +1,9 @@ | |||
| <?php | |||
| $this->any('/user', function ($request, $response, $args) { | |||
| global $user; | |||
| $response = $response->withJson($user->getList()); | |||
| return $response; | |||
| }); | |||
| @@ -0,0 +1,96 @@ | |||
| <?php | |||
| use \Psr\Http\Message\ServerRequestInterface as Request; | |||
| use \Psr\Http\Message\ResponseInterface as Response; | |||
| //TODO: log errors | |||
| $validateGet = function ($request, $response, $next) { | |||
| if ($request->isGet()) { | |||
| $response = $next($request, $response); | |||
| } else { | |||
| $response = $response->withJson(['status'=>'err', 'msg'=>'Not valid method']); | |||
| } | |||
| return $response; | |||
| }; | |||
| $validateApi = function ($request, $response, $next) { | |||
| global $config; | |||
| $apiKey = $config['settings']['api-key']; | |||
| if ($request->isPost()) { | |||
| $headerApiKey = $request->getHeader('Api-Key'); | |||
| if ($headerApiKey[0] != $apiKey) { | |||
| $response = $response->withJson(['status'=>'err', 'msg'=>'Not valid API request']); | |||
| } else { | |||
| $response = $next($request, $response); | |||
| } | |||
| } else { | |||
| $response = $response->withJson(['status'=>'err', 'msg'=>'Not valid API request method']); | |||
| } | |||
| return $response; | |||
| }; | |||
| if ($config['settings']['debug']) { | |||
| $app->get('/testcall', function (Request $request, Response $response, array $args) { | |||
| global $layout; | |||
| $response->getBody()->write($layout->getPage('urlit')); | |||
| return $response; | |||
| })->add($validateGet); | |||
| } | |||
| $app->get('/global-js', function (Request $request, Response $response, array $args) { | |||
| global $layout; | |||
| $response->getBody()->write(Dispatch::route('public', 'getGloablJs')); | |||
| return $response; | |||
| })->add($validateGet); | |||
| $app->get('/email-preview[/{id}]', function (Request $request, Response $response, array $args) { | |||
| global $layout; | |||
| $response->getBody()->write(Dispatch::route('public', 'emailPreview', $args)); | |||
| return $response; | |||
| })->add($validateGet); | |||
| $app->get('/dashboard-redirect', function (Request $request, Response $response, array $args) { | |||
| header('Location: /#/dashboard'); | |||
| exit(); | |||
| })->add($validateGet); | |||
| $app->get('/', function (Request $request, Response $response, array $args) { | |||
| global $layout; | |||
| $response->getBody()->write($layout->getPage('main')); | |||
| return $response; | |||
| })->add($validateGet); | |||
| $app->group('/api', function() { | |||
| $this->any('/{controller}/{action}[/{params:.*}]', function ($request, $response, $args) { | |||
| $controller = !empty($args['controller']) ? $args['controller'] : 'login'; | |||
| $action = !empty($args['action']) ? $args['action'] : 'index'; | |||
| return Dispatch::route($controller, $action, $args); | |||
| }); | |||
| })->add($validateApi); | |||
| @@ -0,0 +1,76 @@ | |||
| <?php | |||
| class Checkmail { | |||
| private $config = null; | |||
| private $mbox = null; | |||
| private $email_list = []; | |||
| function __construct($cofig) { | |||
| $this->config = $cofig; | |||
| } | |||
| public function openImap() { | |||
| $this->mbox = imap_open($this->config['settings']['imap']['connection'].'INBOX', $this->config['settings']['smtp']['username'], $this->config['settings']['smtp']['password']); | |||
| } | |||
| public function closeImap() { | |||
| imap_close($this->mbox); | |||
| $this->mbox = null; | |||
| } | |||
| public function fetchFailedOverview() { | |||
| $MC = imap_check($this->mbox); | |||
| $result = imap_fetch_overview($this->mbox, "1:{$MC->Nmsgs}", 0); | |||
| if (is_array($result)) { | |||
| foreach ($result as $overview) { | |||
| if ($this->filterSubject($overview->subject, 'Delivery Status Notification')) { | |||
| $this->email_list[] = $overview->msgno; | |||
| } | |||
| } | |||
| } | |||
| return $this->email_list; | |||
| } | |||
| //$range = "1,2,3,4" | |||
| public function moveMessageTo($range, $to='') { | |||
| return imap_mail_move($this->mbox, $range , $to); | |||
| } | |||
| public function listMailBoxes() { | |||
| $mailboxes = imap_list($this->mbox, $this->config['settings']['imap']['connection'], '*'); | |||
| return $mailboxes; | |||
| } | |||
| public function readEmail($number) { | |||
| return imap_qprint(imap_body($this->mbox, $number)); | |||
| } | |||
| public function getSurveyUUID($mail_body='', $check_string='', $length=36) { | |||
| $start = strpos($mail_body, $check_string)+strlen($check_string); | |||
| return substr($mail_body, $start, $length); | |||
| } | |||
| private function emptyEmailList() { | |||
| $this->email_list = []; | |||
| } | |||
| public function markDelete($number) { | |||
| imap_delete($this->mbox, $number); | |||
| } | |||
| public function expungeDelete() { | |||
| imap_expunge($this->mbox); | |||
| } | |||
| private function filterSubject($subject='', $filter='') { | |||
| if (strpos($subject, $filter) !== false) | |||
| return true; | |||
| else | |||
| return false; | |||
| } | |||
| } | |||
| @@ -0,0 +1,479 @@ | |||
| <?php | |||
| class Helper { | |||
| private $utility; | |||
| function __construct($utility=null) { | |||
| $this->utility = $utility; | |||
| } | |||
| public function setHash($destination='') { | |||
| return $this->utility->setHash($destination); | |||
| } | |||
| public function setSortableCol($label='', $destination, $field, $dir) { | |||
| $currentField = isset($_POST['orderField']) ? $_POST['orderField'] : null; | |||
| $currentDir = isset($_POST['orderDir']) ? $_POST['orderDir'] : null; | |||
| $pageNumb = isset($_POST['pageNumb']) ? $_POST['pageNumb'] : 1; | |||
| $icon = ''; | |||
| if ($field == $currentField) { | |||
| if ($currentDir == 'desc') $dir = 'asc'; else $dir = 'desc'; | |||
| if ($dir == 'asc') | |||
| $icon = '<span class="icon-menu4 opacize"></span>'; | |||
| else | |||
| $icon = '<span class="icon-menu3 opacize"></span>'; | |||
| } | |||
| return '<a href="'.$this->setHash($destination.'/'.$field.'/'.$dir.'/'.$pageNumb).'">'.$label.'</a> '.$icon; | |||
| } | |||
| public function wrapVector($vector, $start, $end='', $space=' ') { | |||
| $string = ''; | |||
| if (is_array($vector)) { | |||
| foreach($vector as $value) { | |||
| $string .= $start.$value.$end.$space; | |||
| } | |||
| } | |||
| return $string; | |||
| } | |||
| public function setCommaList($vector=[], $sep=', ') { | |||
| return is_array($vector) ? implode($sep, $vector) : ''; | |||
| } | |||
| public function dateIntervalString($date) { | |||
| $start = date_create($date); | |||
| $end = date_create(); | |||
| $diff = date_diff($start, $end); | |||
| if ($diff->y > 0) { | |||
| if ($diff->m > 0) { | |||
| return vsprintf(_('%s<sup>y</sup> %s<sup>mo</sup>'), [$diff->y, $diff->m]); | |||
| } else { | |||
| return vsprintf(_('%s<sup>y</sup>'), [$diff->y]); | |||
| } | |||
| } | |||
| if ($diff->y <= 0 && $diff->m > 0) { | |||
| if ($diff->d > 0) { | |||
| return vsprintf(_('%s<sup>mo</sup> %s<sup>d</sup>'), [$diff->m, $diff->d]); | |||
| } else { | |||
| return vsprintf(_('%s<sup>mo</sup>'), [$diff->m]); | |||
| } | |||
| } | |||
| if ($diff->y <= 0 && $diff->m <= 0 && $diff->d > 0) { | |||
| if ($diff->h > 0) { | |||
| return vsprintf(_('%s<sup>d</sup> %s<sup>h</sup>'), [$diff->d, $diff->h]); | |||
| } else { | |||
| return vsprintf(_('%s<sup>d</sup>'), [$diff->d]); | |||
| } | |||
| } | |||
| if ($diff->y <= 0 && $diff->m <= 0 && $diff->d <= 0) { | |||
| if ($diff->h > 0) { | |||
| return vsprintf(_('%s<sup>h</sup> %s<sup>mi</sup>'), [$diff->h, $diff->i]); | |||
| } else { | |||
| if ($diff->i > 0) { | |||
| return vsprintf(_('%s<sup>mi</sup>'), [$diff->i]); | |||
| } | |||
| } | |||
| } | |||
| return vsprintf(_('%s<sup>s</sup>'), [$diff->s]); | |||
| } | |||
| public function setYesNo($number=0) { | |||
| return $number==1 ? _('Yes') : _('No'); | |||
| } | |||
| public function getDateString($date=null, $withTime=true) { | |||
| if ($withTime) { | |||
| $dateString = '%d/%b/%Y %H.%M'; | |||
| } else { | |||
| $dateString = '%d/%b/%Y'; | |||
| } | |||
| if (!empty($date)) | |||
| return strftime($dateString, strtotime($date)); | |||
| else | |||
| return ''; | |||
| } | |||
| public function getTimeString($date=null, $sep='.', $withSecs=false) { | |||
| $secs = $withSecs ? $sep.'s' : ''; | |||
| return date('H'.$sep.'i'.$secs, strtotime($date)); | |||
| } | |||
| public function getJsonTranslation($jsonField, $langCode=null, $default='') { | |||
| $data = json_decode($jsonField, true); | |||
| return is_array($data) && isset($data[$langCode]) ? $data[$langCode] : $default; | |||
| } | |||
| public function getRoleNameInList($string='', $roleList=[]) { | |||
| $string = '{'.$string.'}'; | |||
| $array = json_decode($string, true); | |||
| $list = []; | |||
| if (is_array($array)) { | |||
| foreach($array as $roleId => $roleName) { //Role name is in English because of the query in usersController::usersList() | |||
| if (isset($roleList[$roleId])) { | |||
| $list[] = $roleList[$roleId]['name']; | |||
| } | |||
| } | |||
| } | |||
| return !empty($list) && is_array($list) ? implode(', ', $list) : null; | |||
| } | |||
| public function requestSubject($data=[]) { | |||
| $surname = isset($data['patientSurname']) ? $this->cleanText($data['patientSurname']) : ''; | |||
| $name = isset($data['patientName']) ? $this->cleanText($data['patientName']) : ''; | |||
| $years = isset($data['ageYears']) ? (int)$data['ageYears'] : 0; | |||
| $months = isset($data['ageMonths']) ? (int)$data['ageMonths'] : 0; | |||
| $days = isset($data['ageDays']) ? (int)$data['ageDays'] : 0; | |||
| $gender = isset($data['patientGender']) ? trim($data['patientGender']) : ''; | |||
| $anonymous = isset($data['anonymous']) ? $data['anonymous'] : 0; | |||
| $age = $months > AGE_MONTH_LIMIT ? $years : $months; //AGE_MONTH_LIMIT is in mainController | |||
| //$ageString = $months > AGE_MONTH_LIMIT ? vsprintf(_('%s y.'), [$years]) : vsprintf(_('%s m.'), [$months]); | |||
| if ($months > AGE_MONTH_LIMIT) { | |||
| $ageString = vsprintf(_('%s y.'), [$years]); | |||
| } else { | |||
| if ($months > 0) { | |||
| //if ($days == 0) { | |||
| $ageString = vsprintf(_('%s m.'), [$months]); | |||
| //} else { | |||
| //$ageString = vsprintf(_('%s m. %s d.'), [$months, $days]); | |||
| //} | |||
| } else { | |||
| $ageString = vsprintf(_('%s d.'), [$days]); | |||
| } | |||
| } | |||
| $genderLabel = $gender == 'm' ? strtolower(_('Mal.'))[0] : strtolower(_('Fem.'))[0]; | |||
| if ($gender == '') $genderLabel = ''; //Overwrite the value if no gender is passed | |||
| if ($anonymous == 0) { | |||
| $fullName = '<span class="badge badge-secondary">'.$this->setDottedFullname($name, $surname, false).'</span>'; | |||
| } else { | |||
| $fullName = '<span class="badge badge-light">'.$this->getObfuscateString($name.' '.$surname).'</span>'; | |||
| } | |||
| return $fullName.' <span class="badge badge-secondary">'.$ageString.'</span> <span class="badge badge-dark">'.$genderLabel.'</span>'; | |||
| } | |||
| public function patient_age($data=[]) { | |||
| $years = isset($data['ageYears']) ? (int)$data['ageYears'] : 0; | |||
| $months = isset($data['ageMonths']) ? (int)$data['ageMonths'] : 0; | |||
| $days = isset($data['ageDays']) ? (int)$data['ageDays'] : 0; | |||
| $anonymous = isset($data['anonymous']) ? $data['anonymous'] : 0; | |||
| $age = $months > AGE_MONTH_LIMIT ? $years : $months; //AGE_MONTH_LIMIT is in mainController | |||
| if ($months > AGE_MONTH_LIMIT) { | |||
| $ageString = vsprintf(_('%s y.'), [$years]); | |||
| } else { | |||
| if ($months > 0) { | |||
| $ageString = vsprintf(_('%s m.'), [$months]); | |||
| } else { | |||
| $ageString = vsprintf(_('%s d.'), [$days]); | |||
| } | |||
| } | |||
| return $ageString; | |||
| } | |||
| public function getObfuscateString($string='') { | |||
| //return str_repeat('●', strlen($string)); | |||
| return str_repeat('●', 3); | |||
| } | |||
| //TODO: some cleaning operations | |||
| public function cleanText($text='') { | |||
| //return utf8_encode($text); | |||
| return $text; | |||
| } | |||
| public function hashtag($text) { | |||
| return preg_replace('/(?<!\S)#([0-9a-zA-Z]+)/', '<a class="badge badge-info" href="/requests-edit/'.time().'/$1/view/hashtag/my/hashtag/created_at/desc/1">#$1</a>', $text); | |||
| } | |||
| public function linkfy($label='', $href='', $class="", $target='_self', $meta='') { | |||
| return '<a href="'.$href.'" class="'.$class.'" target="'.$target.'" '.$meta.'>'.$label.'</a>'; | |||
| } | |||
| public function getExtension($file) { | |||
| return pathinfo($file, PATHINFO_EXTENSION); | |||
| } | |||
| public function getPreviewType($fileName=null) { | |||
| $images = ['gif', 'jpg', 'jpeg', 'png', 'bmp', 'tif']; | |||
| $videos = ['mp4', 'm4p', 'm4v', 'mov', 'mpg', 'mpeg', 'mp2', 'mpeg', 'mpe', 'mpv', 'webm', 'ogv', 'ogg']; | |||
| $audio = ['mp3', 'mpa', 'aac', 'oga']; | |||
| $files = ['pdf']; | |||
| if (!is_null($fileName)) { | |||
| $ext = strtolower($this->getExtension($fileName)); | |||
| if (in_array($ext, $images)) { | |||
| return 'images'; | |||
| } | |||
| if (in_array($ext, $videos)) { | |||
| return 'video'; | |||
| } | |||
| if (in_array($ext, $audio)) { | |||
| return 'audio'; | |||
| } | |||
| if (in_array($ext, $files)) { | |||
| return 'iframe'; | |||
| } | |||
| } | |||
| return 'download'; | |||
| } | |||
| public function getPreviewLink($attach=[], $showUser=true, $wrapStart=null, $wrapEnd=null, $linkClass=null) { | |||
| $previewType = $this->getPreviewType($attach['file_name']); | |||
| $attachId = $attach['id']; | |||
| $attachTitle = $attach['file_title']; | |||
| $attachExt = $attach['file_ext']; | |||
| $attachSize = $attach['file_size']; | |||
| $titleLength = 20; | |||
| $wrapStart = is_null($wrapStart) ? '<div class="attach-row">' : $wrapStart; | |||
| $wrapEnd = is_null($wrapEnd) ? '</div><div class="clearfix"><small class="text-muted float-right mr-1"><i>'.$this->byte_convert($attachSize).'</i></small><small class="text-muted float-right"><i>'.strtoupper($attachExt).'</i> - </small></div></div>' : $wrapEnd; | |||
| $user = $showUser ? '<div class="clearfix"><small class="text-muted">'.$attach['name'].' '.$attach['surname'].' <span class="float-right">'.$this->getTimeString($attach['created_at']).'</span></small></div><div class="clearfix">' : ''; | |||
| if ($previewType != 'download') { | |||
| switch ($previewType) { | |||
| case 'images': | |||
| return $wrapStart.$user.'<a data-options=\'{"hash":false}\' data-toggle="tooltip" data-placement="top" title="'.$attach['file_title'].'.'.$attach['file_ext'].'" data-fancybox="images" data-caption="'.htmlspecialchars($this->setDottedFullname($attach['name'], $attach['surname'], false)).' - '.htmlspecialchars($attachTitle).' - '.$this->getDateString($attach['created_at']).'" data-src="/downlaod/?attach_id='.$attachId.'" href="#" class="'.$linkClass.'"><span class="icon-file-picture"> </span>'.$this->truncate($attachTitle, $titleLength).'</a>'.$wrapEnd; | |||
| break; | |||
| case 'video': | |||
| case 'audio': | |||
| return $wrapStart.$user.'<a data-options=\'{"hash":false}\' data-toggle="tooltip" data-placement="top" title="'.$attach['file_title'].'.'.$attach['file_ext'].'" data-fancybox data-type="iframe" data-src="/downlaod/?attach_id='.$attachId.'" href="#" class="'.$linkClass.'"><span class="icon-file-picture"></span> '.$this->truncate($attachTitle, $titleLength).'</a>'.$wrapEnd; | |||
| break; | |||
| default: | |||
| return $wrapStart.$user.'<a data-options=\'{"hash":false}\' data-toggle="tooltip" data-placement="top" title="'.$attach['file_title'].'.'.$attach['file_ext'].'" data-fancybox data-type="iframe" data-src="/downlaod/?attach_id='.$attachId.'" href="#" class="'.$linkClass.'"><span class="icon-download3"></span> '.$this->truncate($attachTitle, $titleLength).'</a>'.$wrapEnd; | |||
| } | |||
| } else { | |||
| return $wrapStart.$user.'<a class="download '.$linkClass.'" data-toggle="tooltip" data-placement="top" title="'.$attach['file_title'].'.'.$attach['file_ext'].'" data-forcedownload="1" href="/downlaod/?attach_id='.$attachId.'"><span class="icon-download3"></span> '.$this->truncate($attachTitle, $titleLength).'</a>'.$wrapEnd; | |||
| } | |||
| } | |||
| public function getDocName($attach=[], $showUser=true, $wrapStart=null, $wrapEnd=null, $linkClass=null) { | |||
| $previewType = $this->getPreviewType($attach['file_name']); | |||
| $attachId = $attach['id']; | |||
| $attachTitle = $attach['file_title']; | |||
| $attachExt = $attach['file_ext']; | |||
| $attachSize = $attach['file_size']; | |||
| // $titleLength = 20; | |||
| $wrapStart = is_null($wrapStart) ? '<div class="attach-row">' : $wrapStart; | |||
| $wrapEnd = is_null($wrapEnd) ? '<small class="float-right text-muted">'.$this->byte_convert($attachSize).' - '.strtoupper($attachExt).'</small></div>' : $wrapEnd; | |||
| $user = $showUser ? '<div class="clearfix"><small class="text-muted">'.$attach['name'].' '.$attach['surname'].' <span class="float-right">'.$this->getTimeString($attach['created_at']).'</span></small></div>' : ''; | |||
| if ($previewType != 'download') { | |||
| switch ($previewType) { | |||
| case 'images': | |||
| return $wrapStart.$user.'<a data-options=\'{"hash":false}\' data-fancybox="images" data-caption="'.htmlspecialchars($this->setDottedFullname($attach['name'], $attach['surname'], false)).' - '.htmlspecialchars($attachTitle).' - '.$this->getDateString($attach['created_at']).'" data-src="/downlaod/?attach_id='.$attachId.'" href="#" class="'.$linkClass.'"><span class="icon-file-picture"> </span>'.$attachTitle.'.'.$attachExt.'</a>'.$wrapEnd; | |||
| break; | |||
| case 'video': | |||
| case 'audio': | |||
| return $wrapStart.$user.'<a data-options=\'{"hash":false}\' data-fancybox data-type="iframe" data-src="/downlaod/?attach_id='.$attachId.'" href="#" class="'.$linkClass.'"><span class="icon-file-picture"></span> '.$attachTitle.'</a>'.$wrapEnd; | |||
| break; | |||
| default: | |||
| return $wrapStart.$user.'<a data-options=\'{"hash":false}\' data-fancybox data-type="iframe" data-src="/downlaod/?attach_id='.$attachId.'" href="#" class="'.$linkClass.'"><span class="icon-download3"></span> '.$attachTitle.'</a>'.$wrapEnd; | |||
| } | |||
| } else { | |||
| return $wrapStart.$user.'<a class="download '.$linkClass.'" data-forcedownload="1" href="/downlaod/?attach_id='.$attachId.'"><span class="icon-download3"></span> '.$attachTitle.'</a>'.$wrapEnd; | |||
| } | |||
| } | |||
| public function truncate($string=null, $len=15, $ell='...') { | |||
| if (strlen($string) >= $len) { | |||
| return trim(substr($string, 0, $len)).$ell; | |||
| } else { | |||
| return $string; | |||
| } | |||
| } | |||
| public function formatNumber($float=0, $decimals=0) { | |||
| return $this->utility->formatNumber($float, $decimals); | |||
| } | |||
| public function replaceLinks($string='', $class='') { | |||
| return preg_replace("~[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]~","<a href=\"\\0\" class=\"$class\">\\0</a>", $string); | |||
| } | |||
| public function setRequestStatus($label='') { | |||
| switch(trim($label)) { | |||
| case 'pending': | |||
| return '<span class="badge badge-light text-muted"><i>'._('Sending').'...</i></span>'; | |||
| break; | |||
| case 'draft': | |||
| return '<span class="badge badge-light">'._('Draft').'</span>'; | |||
| break; | |||
| case 'opened': | |||
| return '<span class="badge badge-secondary">'._('Opened').'</span>'; | |||
| break; | |||
| case 'referted': | |||
| return '<span class="badge badge-success">'._('Answered').'</span>'; | |||
| break; | |||
| case 'reopened': | |||
| return '<span class="badge badge-danger">'._('Reopened').'</span>'; | |||
| break; | |||
| case '! referted': | |||
| return '<span class="badge badge-warning">'._('Partially answered').'</span>'; | |||
| break; | |||
| default: | |||
| return '<span class="badge badge-light">'.$label.'</span>'; | |||
| } | |||
| } | |||
| public function getRequestExam($exams=[], $label='', $examType='') { | |||
| $html = ''; | |||
| $examItem = []; | |||
| $arrayItem = isset($exams[$label]) ? $exams[$label] : []; | |||
| if (!empty($arrayItem)) { | |||
| foreach($arrayItem as $examId => $examInfo) { | |||
| if ($examInfo['type'] == $examType) { | |||
| $examItem = $examInfo; | |||
| break; | |||
| } | |||
| } | |||
| if (!empty($examItem)) { | |||
| $examLabel = $examItem['description']; | |||
| $examId = $examItem['id']; | |||
| $examType = $examItem['type']; | |||
| $children = $examItem['children']; | |||
| $checked = $examItem['checked'] ? 'checked' : ''; | |||
| $checkbox = '<input type="checkbox" name="data[exam_'.$examType.'][value][]" class="request-exam-checkbox exam-'.$examType.'" data-label="%s" data-checkboxclass="exam-'.$examType.'" data-wizardcontainer="exam-wrapper-'.$examType.'" id="exam-%s" value="%s" %s> '; | |||
| $html .= '<ul>'; | |||
| $html .= '<li class="list-no-type"><label>'; | |||
| $html .= empty($children) ? vsprintf($checkbox, [$examLabel, $examId, $examId, $checked]) : ''; | |||
| //$html .= vsprintf($checkbox, [$examLabel, $examId, $examId, $checked]); | |||
| $html .= $examLabel; | |||
| $html .= '</label>'; | |||
| if (is_array($children) && !empty($children)) { | |||
| $html .= '<ul>'; | |||
| foreach($children as $childId => $childInfo) { | |||
| $checked = $childInfo['checked'] ? 'checked' : ''; | |||
| $html .= '<li class="list-no-type">'.vsprintf($checkbox, [$examLabel.' / '.$childInfo['description'], $childId, $childId, $checked]).$childInfo['description'].'</li>'; | |||
| } | |||
| $html .= '</ul>'; | |||
| } | |||
| $html .= '</li></ul>'; | |||
| } | |||
| } | |||
| return $html; | |||
| } | |||
| public function getUserFlag($userCountryCode=null, $width=50) { | |||
| $imageUrl = '/images/flags/svg/'.strtolower($userCountryCode).'.svg'; | |||
| $imagePath = PUBLIC_HTML.$imageUrl; | |||
| if (file_exists($imagePath)) { | |||
| return '<img src='.$imageUrl.' width="'.$width.'" style="vertical-align:middle;">'; | |||
| } | |||
| return null; | |||
| } | |||
| public function setDottedFullname($name, $surname, $nameFirst=true) { | |||
| $nameParts = explode(' ', trim($name)); | |||
| $chars = []; | |||
| foreach($nameParts as $part) { | |||
| if (isset($part[0])) $chars[] = strtoupper($part[0]); | |||
| } | |||
| if ($nameFirst) | |||
| return implode('. ', $chars).'. '.ucwords(strtolower($surname)); | |||
| else | |||
| return ucwords(strtolower($surname)).' '.implode('. ', $chars).'.'; | |||
| } | |||
| public function setAvatarView($avatarImagePath, $params=[]) { | |||
| global $config; | |||
| $timestamp = isset($params['timestamp']) ? $params['timestamp'] : time(); | |||
| $strTimestamp = "?t=$timestamp"; | |||
| $cssClass = isset($params['class']) ? $params['class'] : 'list-avatar'; | |||
| $cssId = isset($params['cssId']) ? $params['cssId'] : null; | |||
| $strCssId = !is_null($cssId) ? 'id="'.$cssId.'"' : ''; | |||
| $status = isset($params['status']) ? (int)$params['status'] : 1; | |||
| if ($status == 0) { | |||
| $avatarImagePath = $config['settings']['avatar-uri'].$config['settings']['avatar-default']; | |||
| $strTimestamp = ''; | |||
| } | |||
| return '<div class="'.$cssClass.'" '.$strCssId.' style="background-image: url('.$avatarImagePath.$strTimestamp.');"></div>'; | |||
| } | |||
| public function byte_convert($number = 0, $precision = 1){ | |||
| if( !is_numeric($number) ){ | |||
| return false; | |||
| } | |||
| $unit = ''; //suffisso dell'unità di misura | |||
| //terabyte | |||
| if($number >= 1000000000000){ | |||
| $number = round($number / 1099511627776, $precision); | |||
| $unit = 'TB'; | |||
| //gigabyte | |||
| }elseif($number >= 1000000000){ | |||
| $number = round($number / 1073741824, $precision); | |||
| $unit = 'GB'; | |||
| //megabyte | |||
| }elseif($number >= 1000000){ | |||
| $number = round($number / 1048576, $precision); | |||
| $unit = 'MB'; | |||
| //kilobyte | |||
| }elseif($number >= 1000){ | |||
| $number = round($number / 1024, $precision); | |||
| $unit = 'KB'; | |||
| //byte | |||
| }else{ | |||
| $unit = 'byte'; | |||
| return number_format($number).' '.$unit; | |||
| } | |||
| return number_format($number, $precision).' '.$unit; | |||
| } | |||
| } | |||
| @@ -0,0 +1,162 @@ | |||
| <?php | |||
| class Notification { | |||
| private $ctrl; | |||
| private $config; | |||
| private $mail; | |||
| private $db; | |||
| private $sms; | |||
| private $wa; | |||
| public $fromName; | |||
| public $fromAddress; | |||
| public $smsAuth; | |||
| private $skebby; | |||
| function __construct($ctrl=null, $SMTPDebug=0) { | |||
| global $db, $mailer, $config; //App/boostrap.php | |||
| $this->mail = $mailer; | |||
| $this->ctrl = $ctrl; | |||
| $this->config = $config; | |||
| $this->db = $db; | |||
| $this->smsAuth = null; | |||
| $this->mail->SMTPDebug = $SMTPDebug; | |||
| $this->mail->isSMTP(); | |||
| //$mail->mail->CharSet = 'UTF-8'; | |||
| $this->mail->Host = $this->config['settings']['smtp']['host']; | |||
| $this->mail->SMTPAuth = true; | |||
| $this->mail->Username = $this->config['settings']['smtp']['username']; | |||
| $this->mail->Password = $this->config['settings']['smtp']['password']; | |||
| $this->mail->SMTPSecure = $this->config['settings']['smtp']['secure']; | |||
| $this->mail->Port = $this->config['settings']['smtp']['port']; | |||
| $this->mail->isHTML(true); | |||
| $this->fromAddress = $this->config['settings']['smtp']['from-address']; | |||
| $this->fromName = $this->config['settings']['smtp']['from-name']; | |||
| } | |||
| public function sendEmail($to='', $subject='', $body='', $mailID='', $from=[], $attachs=[]) { | |||
| $fromName = $this->fromName; | |||
| $fromAddress = $this->fromAddress; | |||
| if (!empty($from)) { | |||
| if (isset($from['fromAddress']) && isset($from['fromName'])) { | |||
| $fromName = $from['fromName']; | |||
| $fromAddress = $from['fromAddress']; | |||
| } | |||
| } | |||
| $this->mail->setFrom($fromAddress, $fromName); | |||
| $this->mail->addAddress($to); | |||
| if (is_array($attachs) && !empty($attachs)) { | |||
| foreach($attachs as $attach) { | |||
| $this->mail->addAttachment($attach['path'], $attach['name']); | |||
| } | |||
| } | |||
| $this->mail->Subject = $subject; | |||
| $this->mail->Body = $body; | |||
| $this->mail->AltBody = $this->setHtmlToPlainText($body); | |||
| $mailResult = 0; | |||
| $mailErrorInfo = ''; | |||
| if ($this->mail->send()) { | |||
| $mailResult = 1; | |||
| } else { | |||
| $mailErrorInfo = $this->mail->ErrorInfo; | |||
| } | |||
| $this->logEmail($mailID, $fromAddress, $to, $subject, $body, $mailResult, $mailErrorInfo); | |||
| $this->mail->clearAddresses(); | |||
| $this->mail->clearAttachments(); | |||
| } | |||
| public function loginSMS() { | |||
| $endpoint = $this->config['settings']['skebby']['endpoint']; | |||
| $username = $this->config['settings']['skebby']['username']; | |||
| $password = $this->config['settings']['skebby']['password']; | |||
| $sender = $this->config['settings']['skebby']['sender']; | |||
| $this->skebby = new Skebby($username, $password, $endpoint, $sender); | |||
| $this->smsAuth = $this->skebby->login(); | |||
| return $this->smsAuth; | |||
| } | |||
| public function sendSMS($message, $recipients=[]) { | |||
| $result = $this->skebby->sendSMS($message, $recipients); | |||
| $this->logSMS($message, $recipients, $result); | |||
| } | |||
| public function receiveSMS($idSim='', $limit=100, $auth=[]) { | |||
| $result = $this->skebby->receiveSMS($idSim, $limit, $auth); | |||
| return $result; | |||
| } | |||
| public function setNotificationAsSent($queueId=0) { | |||
| return $this->db->where('id', $queueId)->update('requests_messages_queue', ['sent_status'=>1, 'sent_at'=>date('Y-m-d H:i:s')]); | |||
| } | |||
| public function setSurveyNotificationAsSent($queueId=0) { | |||
| return $this->db->where('id', $queueId)->update('survey_queue', ['msg_sent'=>1, 'msg_sent_date'=>date('Y-m-d H:i:s')]); | |||
| } | |||
| private function setHtmlToPlainText($html='') { | |||
| $breaks = array("<br />","<br>","<br/>"); | |||
| $html = str_ireplace($breaks, "\r\n", $html); | |||
| return strip_tags($html); | |||
| } | |||
| private function logSMS($msg='', $recipients=[], $result=[]) { | |||
| $id = uniqid(); | |||
| $user = []; | |||
| if (empty($recipients)) { | |||
| return false; | |||
| } else { | |||
| $recipients = !is_array($recipients) ? [$recipients] : $recipients; | |||
| foreach($recipients as $recipient) { | |||
| $number = str_replace('+', '', $recipient); | |||
| $user = $this->db->where('mobile_number', $number)->getOne('users', 'id'); | |||
| $this->db->insert('log_notifications', [ | |||
| 'id' => $id, | |||
| 'user_id' => isset($user['id']) ? $user['id'] : -1, | |||
| 'notif_type' => 'sms', | |||
| 'phone_to' => $recipient, | |||
| 'phone_msg' => $msg, | |||
| 'request_result' => isset($result['result']) && $result['result'] == 'OK' ? 1 : 0, | |||
| 'request_error_info' => isset($result['result']) && $result['result'] == 'ERR' ? json_encode($result) : null, | |||
| 'created_at' => date('Y-m-d H:i:s') | |||
| ]); | |||
| } | |||
| } | |||
| return $id; | |||
| } | |||
| private function logEmail($mailId='', $from='', $to='', $subject='', $body='', $result=0, $errorInfo='') { | |||
| $user = $this->db->where('email', trim($to))->getOne('users', 'id'); | |||
| $this->db->insert('log_notifications', [ | |||
| 'id' => $mailId, | |||
| 'user_id' => isset($user['id']) ? $user['id'] : -1, | |||
| 'notif_type' => 'email', | |||
| 'mail_from' => $from, | |||
| 'mail_to' => $to, | |||
| 'mail_subject' => $subject, | |||
| 'mail_body' => $body, | |||
| 'request_result' => $result, | |||
| 'request_error_info' => $errorInfo, | |||
| 'created_at' => date('Y-m-d H:i:s') | |||
| ]); | |||
| return $mailId; | |||
| } | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| <?php | |||
| //https://wkhtmltopdf.org/usage/wkhtmltopdf.txt | |||
| class PdfPrinter { | |||
| private $binPath; | |||
| private $config; | |||
| function __construct() { | |||
| global $config; | |||
| $this->config = $config; | |||
| $this->binPath = $this->config['settings']['wkhtmltopdf-bin-path']; | |||
| } | |||
| //https://gist.github.com/davejamesmiller/1965886 | |||
| function convertHtmlToPdf($html='', $headerURL=null, $footerURL=null) { | |||
| $descriptorspec = array( | |||
| 0 => array('pipe', 'r'), // stdin | |||
| 1 => array('pipe', 'w'), // stdout | |||
| 2 => array('pipe', 'w'), // stderr | |||
| ); | |||
| $httpUser = $this->config['settings']['http-username']; | |||
| $httpPass = $this->config['settings']['http-password']; | |||
| $process = proc_open($this->binPath.' -q -B 2cm -T 2cm --username '.$httpUser.' --password '.$httpPass.' --header-html "'.$headerURL.'" --footer-html "'.$footerURL.'" - -', $descriptorspec, $pipes); | |||
| // Send the HTML on stdin | |||
| fwrite($pipes[0], $html); | |||
| fclose($pipes[0]); | |||
| // Read the outputs | |||
| $pdf = stream_get_contents($pipes[1]); | |||
| $errors = stream_get_contents($pipes[2]); | |||
| // Close the process | |||
| fclose($pipes[1]); | |||
| $return_value = proc_close($process); | |||
| // Output the results | |||
| if ($errors) { | |||
| file_put_contents(PUBLIC_HTML.'pdf_errors.log', $errors); | |||
| //return false; | |||
| } | |||
| return $pdf; | |||
| } | |||
| } | |||
| @@ -0,0 +1,68 @@ | |||
| <?php | |||
| class Remote { | |||
| private $config; | |||
| private $db; | |||
| function __construct() { | |||
| global $db, $config; //App/boostrap.php | |||
| $this->config = $config; | |||
| $this->db = $db; | |||
| } | |||
| public function createRemoteRequest($survey_code=null) { | |||
| $attach = []; | |||
| $status = 'ok'; | |||
| $survey = $this->db | |||
| ->join('survey_registry sry', 'sry.survey_id=sy.id') | |||
| ->join('survey_types stp', 'stp.id=sy.type_id') | |||
| ->where('sy.code', $survey_code) | |||
| ->where('sy.json_answers', NULL, 'IS NOT') | |||
| ->where('sy.remote_added', 0) | |||
| ->getOne('survey sy', "sy.*, sry.*, sy.id survey_id, stp.survey_label, stp.cc_id, stp.ms_id, sry.created_at registry_created_at"); | |||
| if (isset($survey['code'])) { | |||
| $attach = $this->db->where('survey_uuid', $survey_code)->get('survey_attachments'); | |||
| if (is_array($attach) && !empty($attach)) { | |||
| foreach($attach as $index => $file) { | |||
| $attach[$index]['data'] = base64_encode(file_get_contents(ATTACH_DIR.$file['uuid'])); | |||
| } | |||
| } | |||
| } else { | |||
| $status = 'err'; | |||
| } | |||
| $return_data = json_encode(['status'=>$status, 'survey'=>$survey, 'survey_code'=>$survey_code, 'attach'=>$attach]); | |||
| $endpoint = $this->config['settings']['sportellocura']['api']['endpoint']; | |||
| $cmd = (int)$survey['remote_auto_tlc_id'] > 0 ? 'update-request' : 'create-request'; | |||
| $remote_auto_tlc_id = (isset($survey['remote_auto_tlc_id'])&&(int)$survey['remote_auto_tlc_id']>0) ? $survey['remote_auto_tlc_id'] : 0; | |||
| $vars = ['data'=>$return_data, 'cmd'=>$cmd, 'request-id'=>$remote_auto_tlc_id]; | |||
| $ch = curl_init(); | |||
| curl_setopt($ch, CURLOPT_URL, $endpoint); | |||
| curl_setopt($ch, CURLOPT_POST, 1); | |||
| curl_setopt($ch, CURLOPT_POSTFIELDS, $vars); //Post Fields | |||
| //curl_setopt($ch, CURLOPT_USERPWD, "dev-ght:demo"); | |||
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |||
| curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); | |||
| curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout in seconds | |||
| $curldata = curl_exec($ch); | |||
| $curl_info = curl_getinfo($ch); | |||
| file_put_contents(PUBLIC_HTML.'request.log', json_encode(curl_getinfo($ch))); | |||
| curl_close($ch); | |||
| return $curldata; | |||
| } | |||
| } | |||
| @@ -0,0 +1,134 @@ | |||
| <?php | |||
| define("MESSAGE_HIGH_QUALITY", "GP"); | |||
| define("MESSAGE_MEDIUM_QUALITY", "TI"); | |||
| define("MESSAGE_LOW_QUALITY", "SI"); | |||
| class Skebby { | |||
| public $username = null; | |||
| public $password = null; | |||
| public $endpoint = null; | |||
| public $messageType = null; | |||
| public $returnCredits = null; | |||
| public $sender = null; | |||
| private $auth = null; | |||
| function __construct($username, $password, $endpoint, $sender='') { | |||
| $this->endpoint = $endpoint; | |||
| $this->username = $username; | |||
| $this->password = $password; | |||
| $this->messageType = MESSAGE_HIGH_QUALITY; | |||
| $this->returnCredits = true; | |||
| $this->sender = $sender; | |||
| } | |||
| /** | |||
| * Authenticates the user given it's username and password. | |||
| * Returns the pair user_key, Session_key | |||
| */ | |||
| public function login() { | |||
| $ch = curl_init(); | |||
| curl_setopt($ch, CURLOPT_URL, $this->endpoint . | |||
| 'login?username=' . $this->username . | |||
| '&password=' . $this->password); | |||
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |||
| $response = curl_exec($ch); | |||
| $info = curl_getinfo($ch); | |||
| curl_close($ch); | |||
| if ($info['http_code'] != 200) { | |||
| return null; | |||
| } | |||
| $auth = explode(";", $response); | |||
| $this->auth = $auth; | |||
| //file_put_contents('/home/aosga/skebby.log', $this->auth); | |||
| return $auth; | |||
| } | |||
| /** | |||
| * Sends an SMS message | |||
| */ | |||
| public function sendSMS($message='', $recipients=[], $auth=[]) { | |||
| $auth = empty($auth) ? $this->auth : $auth; | |||
| if (empty($recipients)) { | |||
| return ['result'=>'ERR', 'httpCode'=>0, 'bodyMsg'=>'No recipients provided']; | |||
| } else { | |||
| $recipients = !is_array($recipients) ? [$recipients] : $recipients; | |||
| } | |||
| foreach($recipients as $index => $recipient) { | |||
| $recipients[$index] = $this->prepareNumber($recipient); | |||
| } | |||
| $ch = curl_init(); | |||
| curl_setopt($ch, CURLOPT_URL, $this->endpoint . 'sms'); | |||
| curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |||
| 'Content-type: application/json', | |||
| 'user_key: ' . $auth[0], | |||
| 'Session_key: ' . $auth[1] | |||
| )); | |||
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |||
| curl_setopt($ch, CURLOPT_POST, 1); | |||
| curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($this->prepareStructure($message, $recipients))); | |||
| $response = curl_exec($ch); | |||
| $info = curl_getinfo($ch); | |||
| curl_close($ch); | |||
| if ($info['http_code'] != 201) { | |||
| file_put_contents('/home/aosga/skebby.log', $response); | |||
| return ['result'=>'ERR', 'httpCode'=>$info['http_code'], 'bodyMsg'=>$response]; | |||
| } else { | |||
| file_put_contents('/home/aosga/skebby.log', $response); | |||
| return json_decode($response, true); | |||
| } | |||
| } | |||
| /** | |||
| * Receive new SMS messages | |||
| */ | |||
| public function receiveSMS($idSim='', $limit=100, $auth=[]) { | |||
| $auth = empty($auth) ? $this->auth : $auth; | |||
| $ch = curl_init(); | |||
| curl_setopt($ch, CURLOPT_URL, $this->endpoint . 'newsrsmsmessage/' . $idSim . '?limit=' . $limit); | |||
| curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |||
| 'Content-type: application/json', | |||
| 'user_key: ' . $auth[0], | |||
| 'Session_key: ' . $auth[1] | |||
| )); | |||
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |||
| $response = curl_exec($ch); | |||
| $info = curl_getinfo($ch); | |||
| curl_close($ch); | |||
| if ($info['http_code'] != 200) { | |||
| //return null; | |||
| return ['result'=>'ERR', 'httpCode'=>$info['http_code'], 'bodyMsg'=>$response]; | |||
| } | |||
| return json_decode($response, true); | |||
| } | |||
| private function prepareStructure($message='', $recipients=[]) { | |||
| return [ | |||
| 'message' => $message, | |||
| 'message_type' => $this->messageType, | |||
| 'returnCredits' => $this->returnCredits, | |||
| 'recipient' => $recipients, | |||
| 'sender' => $this->sender | |||
| ]; | |||
| } | |||
| private function prepareNumber($number='') { | |||
| $number = trim(preg_replace('/[^0-9]/', '', $number)); | |||
| $number = strpos('+', $number) === false ? '+'.$number : $number; | |||
| return $number; | |||
| } | |||
| } | |||
| @@ -0,0 +1,3 @@ | |||
| <?php | |||
| debug($this->view->DEBUG); | |||
| ?> | |||
| @@ -0,0 +1,67 @@ | |||
| <?php echo $this->partial('Layout/nav'); ?> | |||
| <div class="container-fluid"> | |||
| <div class="container-page-wrapper shodowed bordered"> | |||
| <div class="container-page-container"> | |||
| <?php //debug($this->view->centers); ?> | |||
| <div class="row"> | |||
| <div class="col-lg-8"> | |||
| <h1><?php echo $this->actionTitle; ?></h1> | |||
| </div> | |||
| <div class="col-lg-4 clearfix"> | |||
| <div class="float-right"> | |||
| <div class="float-left margin-right-20"> | |||
| <!-- Other buttons... --> | |||
| </div> | |||
| <div class="float-right"> | |||
| <!-- Other buttons... --> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="table-overflow"> | |||
| <form id="table-search-users"> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th nowrap><?php echo _('Name'); ?></th> | |||
| <th nowrap><?php echo _('Continent'); ?></th> | |||
| <th nowrap><?php echo _('Country'); ?></th> | |||
| <th nowrap><?php echo _('Anonymize'); ?></th> | |||
| <th nowrap><?php echo _('Notes'); ?></th> | |||
| <th nowrap><?php echo _('Med. Spec.'); ?></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php if (!empty($this->view->centers)): ?> | |||
| <?php foreach($this->view->centers as $centers): ?> | |||
| <tr> | |||
| <td><?php echo $centers['description']; ?></td> | |||
| <td><?php echo $centers['continent_name']; ?></td> | |||
| <td><?php echo $centers['country_name']; ?></td> | |||
| <td class="text-center"><?php echo (int)$centers['anonymize'] == 1 ? _('Yes') : _('No'); ?></td> | |||
| <td><?php echo $centers['notes']; ?></td> | |||
| <td> | |||
| <?php foreach($centers['specialties'] as $specialties): ?> | |||
| <?php $badgeClass = $specialties['active'] ? 'light' : 'danger' ?> | |||
| <?php echo '<span class="badge badge-'.$badgeClass.'">', $specialties['description'], '</span>'; ?> | |||
| <?php endforeach; ?> | |||
| </td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| <?php endif; ?> | |||
| </tbody> | |||
| </table> | |||
| <?php if (empty($this->view->centers)): ?> | |||
| <div class="alert alert-warning" role="alert"> | |||
| <?php echo _('No data available in this list.'); ?> | |||
| </div> | |||
| <?php endif; ?> | |||
| </form> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,196 @@ | |||
| <?php echo $this->partial('Layout/nav'); ?> | |||
| <div class="container"> | |||
| <div class="container-page-wrapper shodowed bordered"> | |||
| <div class="container-page-container"> | |||
| <div class="row"> | |||
| <div class="col-lg-6"> | |||
| <h1><?php echo $this->actionTitle; ?></h1> | |||
| </div> | |||
| <div class="col-lg-6 clearfix"> | |||
| <div class="float-right"> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <?php | |||
| //if (is_array($this->view->centerData)): | |||
| if(true) : | |||
| ?> | |||
| <form id="center-form"> | |||
| <input type="hidden" name="data[center_id][value]" value="<?php echo $this->view->centerId; ?>"> | |||
| <input type="hidden" name="data[center_id][required]" value="0"> | |||
| <div class="form-row"> | |||
| <div class="form-group col-lg-12"> | |||
| <hr> | |||
| <h4 class="text-center"><?php echo _('Clinical center information'); ?></h4> | |||
| <hr> | |||
| </div> | |||
| <div class="form-group col-lg-8"> | |||
| <label class="label-main" for="profile_description"><?php echo _('Clinical center name'); ?></label> | |||
| <input type="text" class="form-control field-description" value="<?php echo isset($this->view->centerData['description']) ? $this->utility->sureHtml($this->view->centerData['description']) : ''; ?>" id="profile_description" name="data[description][value]"> | |||
| <input type="hidden" name="data[description][required]" value="1"> | |||
| <input type="hidden" name="data[description][type]" value="text"> | |||
| <input type="hidden" name="data[description][class]" value="field-description"> | |||
| <input type="hidden" name="data[description][label]" value="<?php echo _('Clinical center name'); ?>"> | |||
| </div> | |||
| <div class="form-group col-lg-4"> | |||
| <label class="label-main"><?php echo _('Anonymize'); ?></label> | |||
| <div> | |||
| <div class="form-check form-check-inline"> | |||
| <input type="hidden" name="data[anonymize][value]" value="0"> | |||
| <input class="form-check-input" type="checkbox" id="profile-anonymize" value="1" name="data[anonymize][value]" | |||
| <?php echo (int)$this->view->centerData['anonymize'] == 1 ? 'checked' : ''; ?> | |||
| > | |||
| <label class="form-check-label" for="profile-anonymize ?>"><?php echo _('Yes') . '/' . _('No'); ?></label> | |||
| <input type="hidden" name="data[anonymize][required]" value="0"> | |||
| <input type="hidden" name="data[anonymize][type]" value="checkbox"> | |||
| <input type="hidden" name="data[anonymize][class]" value="field-anonymize"> | |||
| <input type="hidden" name="data[anonymize][label]" value="<?php echo _('Anonymize'); ?>"> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="form-group col-lg-6"> | |||
| <label class="label-main" for="profile_continent_code"><?php echo _('Continent'); ?></label> | |||
| <select class="form-control field-continent_code" id="profile_continent_code" name="data[continent_code][value]"> | |||
| <?php foreach($this->view->continents as $continent): ?> | |||
| <option <?php echo $continent['code'] == $this->view->centerData['continent_code'] ? 'selected' : '' ?> value="<?php echo $continent['code']; ?>"><?php echo $continent['name']; ?></option> | |||
| <?php endforeach; ?> | |||
| </select> | |||
| <input type="hidden" name="data[continent_code][required]" value="1"> | |||
| <input type="hidden" name="data[continent_code][type]" value="select"> | |||
| <input type="hidden" name="data[continent_code][class]" value="field-continent_code"> | |||
| <input type="hidden" name="data[continent_code][label]" value="<?php echo _('Continent'); ?>"> | |||
| </div> | |||
| <div class="form-group col-lg-6"> | |||
| <label class="label-main" for="profile_country_code"><?php echo _('Country'); ?></label> | |||
| <select class="form-control field-country_code" id="profile_country_code" name="data[country_code][value]" <?php echo !$this->view->isEditing ? 'disabled' : ''; ?>> | |||
| <?php foreach($this->view->countries as $country): ?> | |||
| <option <?php echo $country['code'] == $this->view->centerData['country_code'] ? 'selected' : '' ?> value="<?php echo $country['code']; ?>"><?php echo $country['name']; ?></option> | |||
| <?php endforeach; ?> | |||
| </select> | |||
| <input type="hidden" name="data[country_code][required]" value="1"> | |||
| <input type="hidden" name="data[country_code][type]" value="select"> | |||
| <input type="hidden" name="data[country_code][class]" value="field-country_code"> | |||
| <input type="hidden" name="data[country_code][label]" value="<?php echo _('Country'); ?>"> | |||
| </div> | |||
| <div class="form-group col-lg-12"> | |||
| <label class="label-main" for="profile_address"><?php echo _('Address'); ?></label> <?php //htmlspecialchars($string, ENT_HTML5, 'UTF-8'); ?> | |||
| <input type="text" class="form-control field-address" value="<?php echo isset($this->view->centerData['address']) ? $this->utility->sureHtml($this->view->centerData['address']) : ''; ?>" id="profile_address" name="data[address][value]"> | |||
| <input type="hidden" name="data[address][required]" value="0"> | |||
| <input type="hidden" name="data[address][type]" value="text"> | |||
| <input type="hidden" name="data[address][class]" value="field-address"> | |||
| <input type="hidden" name="data[address][label]" value="<?php echo _('Address'); ?>"> | |||
| </div> | |||
| <div class="form-group col-lg-6"> | |||
| <label class="label-main" for="profile_lat"><?php echo _('Latitude'); ?></label> | |||
| <input type="text" class="form-control field-lat" value="<?php echo isset($this->view->centerData['lat']) && $this->view->centerData['lat']!=0 ? $this->view->centerData['lat'] : ''; ?>" id="profile_lat" name="data[lat][value]"> | |||
| <input type="hidden" name="data[lat][required]" value="0"> | |||
| <input type="hidden" name="data[lat][type]" value="text"> | |||
| <input type="hidden" name="data[lat][class]" value="field-lat"> | |||
| <input type="hidden" name="data[lat][label]" value="<?php echo _('Latitude'); ?>"> | |||
| </div> | |||
| <div class="form-group col-lg-6"> | |||
| <label class="label-main" for="profile_lng"><?php echo _('Longitude'); ?></label> | |||
| <input type="text" class="form-control field-lng" value="<?php echo isset($this->view->centerData['lng']) && $this->view->centerData['lng']!=0 ? $this->view->centerData['lng'] : ''; ?>" id="profile_lng" name="data[lng][value]"> | |||
| <input type="hidden" name="data[lng][required]" value="0"> | |||
| <input type="hidden" name="data[lng][type]" value="text"> | |||
| <input type="hidden" name="data[lng][class]" value="field-lng"> | |||
| <input type="hidden" name="data[lng][label]" value="<?php echo _('Longitude'); ?>"> | |||
| </div> | |||
| <div class="form-group col-lg-12"> | |||
| <label class="label-main" for="profile_notes"><?php echo _('Notes'); ?></label> | |||
| <textarea class="form-control field-notes" id="profile_notes" name="data[notes][value]" rows="4"><?php echo isset($this->view->centerData['notes']) ? $this->utility->sureHtml($this->view->centerData['notes']) : ''; ?></textarea> | |||
| <input type="hidden" name="data[notes][required]" value="0"> | |||
| <input type="hidden" name="data[notes][type]" value="textarea"> | |||
| <input type="hidden" name="data[notes][class]" value="field-notes"> | |||
| <input type="hidden" name="data[notes][label]" value="<?php echo _('Notes'); ?>"> | |||
| </div> | |||
| <div class="form-group col-lg-12"> | |||
| <hr> | |||
| <h4 class="text-center"><?php echo _('Medical specialties association'); ?></h4> | |||
| <hr> | |||
| </div> | |||
| <div class="col-lg"> | |||
| <label class="label-main" for="profile_medical_specialties"><?php echo _('Medical specialties'); ?></label> | |||
| </div> | |||
| <div class="col-lg-auto clearfix"> | |||
| <div class="float-right"> | |||
| <div class="btn-group" role="group"> | |||
| <button type="button" class="btn btn-outline-primary btn-sm font-weight-bold btn-all-medical_specialties" data-action="select"><?php echo _('Select all') ?></button> | |||
| <button type="button" class="btn btn-outline-primary btn-sm font-weight-bold btn-all-medical_specialties" data-action="deselect"><?php echo _('Deselect all') ?></button> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="form-group col-lg-12"> | |||
| <select multiple class="form-control field-medical_specialties chosen-select" id="profile_medical_specialties" name="data[medical_specialties][value][]"> | |||
| <?php $inactive_specilties_msg = ''; ?> | |||
| <?php foreach ($this->view->allSpecialties as $specialty) : ?> | |||
| <?php if((int)$specialty['status'] == 1): ?> | |||
| <option class="medical_specialty" value="<?php echo $specialty['id']; ?>" | |||
| <?php | |||
| if(isset($this->view->centerData['medical_specialties']) && is_array($this->view->centerData['medical_specialties'])) | |||
| echo in_array($specialty['id'], $this->view->centerData['medical_specialties']) ? 'selected' : ''; | |||
| ?> | |||
| ><?php echo _($specialty['description']); ?></option> | |||
| <?php endif; ?> | |||
| <?php if(isset($this->view->centerData['medical_specialties']) && is_array($this->view->centerData['medical_specialties'])) : ?> | |||
| <?php if((int)$specialty['status'] == 0 && in_array($specialty['id'], $this->view->centerData['medical_specialties'])) : ?> | |||
| <?php $inactive_specilties_msg .= ' ' . _($specialty['description']) . ','; ?> | |||
| <option class="medical_specialty" value="<?php echo $specialty['id']; ?>" selected><?php echo _($specialty['description']); ?></option> | |||
| <?php endif; ?> | |||
| <?php endif; ?> | |||
| <?php endforeach; ?> | |||
| </select> | |||
| <!-- <?php if($inactive_specilties_msg != ''): ?> --> | |||
| <div class="small font-weight-bold text-danger"> | |||
| <?php echo _('No more active medical specialties are assigned:') . substr($inactive_specilties_msg, 0, -1) . ('.'); ?> | |||
| </div> | |||
| <!-- <?php endif; ?> --> | |||
| <input type="hidden" name="data[medical_specialties][required]" value="0"> | |||
| <input type="hidden" name="data[medical_specialties][type]" value="multiselect"> | |||
| <input type="hidden" name="data[medical_specialties][class]" value="field-medical_specialties"> | |||
| <input type="hidden" name="data[medical_specialties][label]" value="<?php echo _('Medical specialties'); ?>"> | |||
| </div> | |||
| <div class="form-group col-lg-12"> | |||
| <hr> | |||
| <h4 class="text-center"><?php echo _('Medical devices'); ?></h4> | |||
| <hr> | |||
| </div> | |||
| </div> | |||
| <div class="form-row"> | |||
| <?php debug($this->view->DEBUG); ?> | |||
| <hr> | |||
| <?php debug($this->view->centerData); ?> | |||
| </div> | |||
| <hr> | |||
| <div class="clearfix"> | |||
| <button type="button" class="btn btn-primary btn-center-save float-right"><?php echo _('Save'); ?></button> | |||
| </div> | |||
| </form> | |||
| <?php else: ?> | |||
| <div class="alert alert-warning" role="alert"><?php echo _("Unable to get user's information right now. Please try in a few minutes."); ?></div> | |||
| <?php endif; ?> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,89 @@ | |||
| <?php echo $this->partial('Layout/nav'); ?> | |||
| <div class="container"> | |||
| <?php echo $this->partial('User/profile-summary', ['showBottomLink'=>true]); ?> | |||
| <?php if($this->user->is(REFERRER_ROLE_ID)): ?> | |||
| <div class="row"> | |||
| <div class="col-lg-12 col-xl-12"> | |||
| <div class="container-page-wrapper shodowed bordered"> | |||
| <div class="container-page-container text-center"> | |||
| <a href="<?php echo $this->helper->setHash('requests/'.time().'/reports/request_status_number/asc/1'); ?>" class="btn btn-primary btn-lg active" role="button" aria-pressed="true"><?php echo _('My Reports'); ?></a> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <?php endif; ?> | |||
| <?php if($this->user->is(APPLICANT_ROLE_ID)): ?> | |||
| <?php echo $this->partial('Dashboard/statistics', ['showRoleLabel'=>$this->view->showRoleLabel, 'roleId'=>APPLICANT_ROLE_ID, 'roleLabel'=>_('Requester')]); ?> | |||
| <?php endif; ?> | |||
| <?php if($this->user->is(GUEST_ROLE_ID)): ?> | |||
| <?php echo $this->partial('Dashboard/statistics', ['showRoleLabel'=>$this->view->showRoleLabel, 'roleId'=>GUEST_ROLE_ID, 'roleLabel'=>_('Guest')]); ?> | |||
| <?php endif; ?> | |||
| <?php if($this->user->is(REFERRER_ROLE_ID)): ?> | |||
| <?php echo $this->partial('Dashboard/statistics', ['showRoleLabel'=>$this->view->showRoleLabel, 'roleId'=>REFERRER_ROLE_ID, 'roleLabel'=>_('Requester')]); ?> | |||
| <?php endif; ?> | |||
| <?php if($this->user->is(MODERATOR_ROLE_ID)): ?> | |||
| <?php echo $this->partial('Dashboard/statistics', ['showRoleLabel'=>$this->view->showRoleLabel, 'roleId'=>MODERATOR_ROLE_ID, 'roleLabel'=>_('Moderator')]); ?> | |||
| <?php endif; ?> | |||
| <?php if($this->user->is(ADMIN_ROLE_ID)): ?> | |||
| <?php echo $this->partial('Dashboard/statistics', ['showRoleLabel'=>$this->view->showRoleLabel, 'roleId'=>ADMIN_ROLE_ID, 'roleLabel'=>_('Administrator')]); ?> | |||
| <?php endif; ?> | |||
| <?php if($this->checkPermissions([2])): ?> | |||
| <div class="row"> | |||
| <div class="col-lg-6 col-xl-6"> | |||
| <div class="container-page-wrapper shodowed bordered"> | |||
| <div class="container-page-container"> | |||
| <h4><?php echo _('Last subscriptions'); ?></h4> | |||
| <hr> | |||
| <div id="admin-last-subscriptions"><small class="form-text text-muted"><?php echo _('Click Load button to load this content...'); ?></small></div> | |||
| <div class="clearfix"> | |||
| <hr> | |||
| <button type="button" class="btn btn-primary float-right btn-sm btn-dash-show-subscrip"><?php echo _('Load'); ?> <span class="icon-spinner11"></span></button> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="col-lg-6 col-xl-6"> | |||
| <div class="container-page-wrapper shodowed bordered"> | |||
| <div class="container-page-container"> | |||
| <h4><?php echo _('Last sessions'); ?></h4> | |||
| <hr> | |||
| <div id="admin-last-sessions"><small class="form-text text-muted"><?php echo _('Click Load button to load this content...'); ?></small></div> | |||
| <div class="clearfix"> | |||
| <hr> | |||
| <button type="button" class="btn btn-primary float-right btn-sm btn-dash-show-sess"><?php echo _('Load'); ?> <span class="icon-spinner11"></span></button> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-lg-6 col-xl-6"> | |||
| <div class="container-page-wrapper shodowed bordered"> | |||
| <div class="container-page-container"> | |||
| <h4><?php echo _('Last accesses'); ?></h4> | |||
| <hr> | |||
| <div id="admin-last-accesses"><small class="form-text text-muted"><?php echo _('Click Load button to load this content...'); ?></small></div> | |||
| <div class="clearfix"> | |||
| <hr> | |||
| <button type="button" class="btn btn-primary float-right btn-sm btn-dash-show-accesses"><?php echo _('Load'); ?> <span class="icon-spinner11"></span></button> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <?php endif; ?> | |||
| </div> | |||
| @@ -0,0 +1,28 @@ | |||
| <?php if(is_array($this->view->accesses) && !empty($this->view->accesses)): ?> | |||
| <div class="clearfix"> | |||
| <a href="<?php echo $this->helper->setHash('users-access-logs/1'); ?>" class="float-right"><?php echo _('Show more...'); ?></a> | |||
| </div> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th width="1%"></th> | |||
| <th><?php echo _('Surname'); ?></th> | |||
| <th><?php echo _('Name'); ?></th> | |||
| <th class="text-right"><?php echo _('Interval'); ?></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($this->view->accesses as $access): ?> | |||
| <tr> | |||
| <td><?php echo $this->helper->setAvatarView($this->user->getAvatar($access['user_id']), ['timestamp'=>md5($access['user_updated_at'])]); ?></td> | |||
| <td><?php echo $access['surname']; ?></td> | |||
| <td><?php echo $access['name']; ?></td> | |||
| <td class="text-right"><?php echo $this->helper->dateIntervalString($access['created_at']); ?></td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| <?php else: ?> | |||
| <div class="alert alert-light" role="alert"><?php echo _('The accesses content is currently empty, please try again in a few minutes.'); ?></div> | |||
| <?php endif; ?> | |||
| @@ -0,0 +1,28 @@ | |||
| <?php if(is_array($this->view->sessions) && !empty($this->view->sessions)): ?> | |||
| <div class="clearfix"> | |||
| <a href="<?php echo $this->helper->setHash('users-sessions/1'); ?>" class="float-right"><?php echo _('Show more...'); ?></a> | |||
| </div> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th width="1%"></th> | |||
| <th><?php echo _('Surname'); ?></th> | |||
| <th><?php echo _('Name'); ?></th> | |||
| <th class="text-right"><?php echo _('Last action'); ?></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($this->view->sessions as $session): ?> | |||
| <tr> | |||
| <td><?php echo $this->helper->setAvatarView($this->user->getAvatar($session['user_id']), ['timestamp'=>md5($session['updated_at'])]); ?></td> | |||
| <td><?php echo $session['surname']; ?></td> | |||
| <td><?php echo $session['name']; ?></td> | |||
| <td class="text-right"><?php echo $this->helper->dateIntervalString($session['session_updated_at']); ?></td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| <?php else: ?> | |||
| <div class="alert alert-light" role="alert"><?php echo _('The sessions content is currently empty, please try again in a few minutes.'); ?></div> | |||
| <?php endif; ?> | |||
| @@ -0,0 +1,29 @@ | |||
| <?php if (is_array($this->view->usersList) && !empty($this->view->usersList)): ?> | |||
| <div class="clearfix"> | |||
| <a href="<?php echo $this->helper->setHash('users/'.time().'/surname/desc/1'); ?>" class="float-right"><?php echo _('Show more...'); ?></a> | |||
| </div> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th width="1%"></th> | |||
| <th><?php echo _('Surname'); ?></th> | |||
| <th><?php echo _('Name'); ?></th> | |||
| <th class="text-right"><?php echo _('Subscription'); ?></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($this->view->usersList as $user): ?> | |||
| <tr> | |||
| <td><?php echo $this->helper->setAvatarView($this->user->getAvatar($user['id']), ['timestamp'=>md5($user['updated_at'])]); ?></td> | |||
| <td><?php echo $user['surname']; ?></td> | |||
| <td><?php echo $user['name']; ?></td> | |||
| <td class="text-right"><?php echo $this->helper->dateIntervalString($user['created_at']); ?></td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| <?php else: ?> | |||
| <div class="alert alert-light" role="alert"><?php echo _('The subscriptions content is currently empty, please try again in a few minutes.'); ?></div> | |||
| <?php endif; ?> | |||
| @@ -0,0 +1,31 @@ | |||
| <?php //debug($this->view->statData); ?> | |||
| <h5 class="text-center"><?php echo _('Triage'); ?></h5> | |||
| <div class="text-center"> | |||
| <div><span class="badge badge-secondary"><?php echo _('Opened'); ?></span> <span class="badge badge-secondary"><?php echo _('Reopened'); ?></span> <span class="badge badge-secondary"><?php echo _('Partially answered'); ?></span></div> | |||
| </div> | |||
| <hr> | |||
| <div class="row"> | |||
| <div class="col-lg-6"> | |||
| <h5 class="text-center"><?php echo vsprintf(_('Q.ty (%s)'), $this->helper->formatNumber($this->view->triageQty)); ?></h5> | |||
| <canvas class="chart-canvas" id="triage-bar-char-role-<?php echo $this->view->roleId; ?>"></canvas> | |||
| </div> | |||
| <div class="col-lg-6 dashboard-pie-wrapper"> | |||
| <h5 class="text-center">%</h5> | |||
| <canvas class="chart-canvas" id="triage-doughnut-char-role-<?php echo $this->view->roleId; ?>"></canvas> | |||
| </div> | |||
| </div> | |||
| <hr> | |||
| <h5 class="text-center"><?php echo _('Status'); ?></h5> | |||
| <hr> | |||
| <div class="row"> | |||
| <div class="col-lg-6"> | |||
| <h5 class="text-center"><?php echo vsprintf(_('Q.ty (%s)'), $this->helper->formatNumber($this->view->statusQty)); ?></h5> | |||
| <canvas class="chart-canvas" id="status-bar-char-role-<?php echo $this->view->roleId; ?>"></canvas> | |||
| </div> | |||
| <div class="col-lg-6 dashboard-pie-wrapper"> | |||
| <h5 class="text-center">%</h5> | |||
| <canvas class="chart-canvas" id="status-doughnut-char-role-<?php echo $this->view->roleId; ?>"></canvas> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,22 @@ | |||
| <div class="container-page-wrapper shodowed bordered"> | |||
| <div class="container-page-container"> | |||
| <div class="row"> | |||
| <div class="col-lg-8"> | |||
| <h4><?php echo _('Statistics'); ?></h4> | |||
| </div> | |||
| <div class="col-lg-4 text-right"> | |||
| <?php if($showRoleLabel): ?> | |||
| <span class="badge badge-secondary"><?php echo $roleLabel; ?></span> | |||
| <?php endif; ?> | |||
| </div> | |||
| </div> | |||
| <hr> | |||
| <div id="statistics-<?php echo $roleId; ?>"><small class="form-text text-muted"><?php echo _('Click Load button to load this content...'); ?></small></div> | |||
| <div class="clearfix"> | |||
| <hr> | |||
| <button type="button" class="btn btn-primary float-right btn-sm btn-load-stats" data-roleid="<?php echo $roleId; ?>"><?php echo _('Load'); ?> <span class="icon-spinner11"></span></button> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,3 @@ | |||
| <div class="text-center"> | |||
| <img src="/images/404.svg" width="250"></div> | |||
| </div> | |||
| @@ -0,0 +1,5 @@ | |||
| <!--<div class="container text-center margin-top-20 margin-bottom-20"> | |||
| <small>Powered by <a href="https://www.ttreinformatica.it/" class="external" target="_blank"><img src="https://www.ttreinformatica.it/wp-content/themes/ttretheme/images/logo.png" width="50" alt="TTRE S.r.l."></a></small> | |||
| </div>--> | |||
| <div style="padding:10px;"></div> | |||
| @@ -0,0 +1,21 @@ | |||
| <!--<div class="container-fluid"> | |||
| <div class="row"> | |||
| <div class="col-lg-2 col-xl-1"> | |||
| <div class="logo-wrapper text-center"><img src="/images/steto.svg" width="100" height="100"></div> | |||
| </div> | |||
| <div class="col-lg-10 col-xl-11"> | |||
| <div class="page-header-content"> | |||
| <div class="row"> | |||
| <div class="col"> | |||
| <h1 class="page-header-title"><span><?php echo $this->appTitle; ?></span></h1> | |||
| <div class="page-header-subtitle"><?php echo $this->view->tagline; ?></div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div>--> | |||
| <div class="margin-top-20"></div> | |||
| @@ -0,0 +1,141 @@ | |||
| <div id="upload-warning-wrapper"> | |||
| <div id="upload-warning"><img src="/images/spinner.svg" width="25" /> <?php echo _("Uploading... Don't close or refresh this window..."); ?></div> | |||
| </div> | |||
| <nav class="navbar sticky-top navbar-expand-lg navbar-dark" style="background-color: #055896;"> | |||
| <a class="navbar-brand" href="<?php echo $this->helper->setHash('dashboard'); ?>"> | |||
| <img src="/images/logo-64-w-nob.png" class="d-inline-block align-top logo-image" alt="Logo"> | |||
| </a> | |||
| <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation"> | |||
| <span class="navbar-toggler-icon"></span> | |||
| </button> | |||
| <div class="collapse navbar-collapse" id="navbarTogglerDemo01"> | |||
| <a class="navbar-brand" href="<?php echo $this->helper->setHash('dashboard'); ?>"><?php echo $this->appTitle; ?> - TTRE-TLC</a> | |||
| <ul class="navbar-nav mr-auto mt-2 mt-lg-0"> | |||
| <?php if($this->checkPermissions([ADMIN_ROLE_ID])): ?> | |||
| <li class="nav-item dropdown"> | |||
| <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |||
| Admin | |||
| </a> | |||
| <div class="dropdown-menu" aria-labelledby="navbarDropdown"> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('users/'.time().'/surname/desc/1'); ?>"><?php echo _('Users'); ?></a> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('users-search/'.time().'/surname/asc/1'); ?>"><span class="icon-search"></span> <?php echo _('User search'); ?></a> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('centers/'.time()); ?>"><?php echo _('Clinical Centers'); ?></a> | |||
| <div class="dropdown-divider"></div> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('users-access-logs/1'); ?>"><?php echo _('Access logs'); ?></a> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('users-sessions/1'); ?>"><?php echo _('Sessions'); ?></a> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('notification-tracker/'.time().'/email/1'); ?>"><?php echo _('Notification tracker'); ?></a> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('requests/'.time().'/logs'); ?>"><?php echo _('Activity logs'); ?></a> | |||
| </div> | |||
| </li> | |||
| <?php endif; ?> | |||
| <?php /*if($this->canViewRemoteVisit()): ?> | |||
| <li class="nav-item dropdown"> | |||
| <a class="nav-link dropdown-toggle" id="navbarDropdownModerations" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#"><?php echo _('Remote visits'); ?></a> | |||
| <div class="dropdown-menu" aria-labelledby="navbarDropdownModerations"> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('survey-list/'.time().'/created_at/desc/1'); ?>"><?php echo _('All'); ?></a> | |||
| <?php if($this->checkPermissions([MANAGER_ID])): ?> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('survey-edit/'.time().'/0'); ?>"><?php echo _('New'); ?></a> | |||
| <?php endif; ?> | |||
| </div> | |||
| </li> | |||
| <?php endif;*/ ?> | |||
| <?php if($this->checkPermissions([APPLICANT_ROLE_ID])): ?> | |||
| <li class="nav-item dropdown"> | |||
| <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |||
| <?php echo _('Requests'); ?> | |||
| </a> | |||
| <div class="dropdown-menu" aria-labelledby="navbarDropdown"> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('requests/'.time().'/my/created_at/desc/1'); ?>"><?php echo _('My requests'); ?></a> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('requests/'.time().'/center/created_at/desc/1'); ?>"><?php echo _('Center requests'); ?></a> | |||
| <?php if($this->canViewRemoteVisit()): ?> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('survey-list/'.time().'/sy.created_at/desc/1'); ?>"><?php echo _('Center remote visits'); ?></a> | |||
| <?php endif; ?> | |||
| <?php if($this->controllerName == 'request' && $this->actionName == 'index'): ?> | |||
| <div class="dropdown-divider"></div> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('requests-edit/'.time().'/0/new-edit/'.$this->view->actionTitle.'/'.$this->view->scope.'/'.$this->view->parentBaseUri.'/'.$this->view->orderField.'/'.$this->view->orderDir.'/'.$this->view->currentPage); ?>"><?php echo _('New request'); ?></a> | |||
| <?php endif; ?> | |||
| <div class="dropdown-divider"></div> | |||
| <a class="dropdown-item btn-show-tranfer" href="#"><?php echo _('Transfer Manager'); ?></a> | |||
| </div> | |||
| </li> | |||
| <?php endif; ?> | |||
| <?php /*if($this->checkPermissions([APPLICANT_ROLE_ID])): ?> | |||
| <a class="nav-link btn-show-tranfer" href="#"><?php echo _('Transfer Manager'); ?></a> | |||
| <?php endif;*/ ?> | |||
| <?php if($this->checkPermissions([MODERATOR_ROLE_ID])): ?> | |||
| <li class="nav-item dropdown"> | |||
| <a class="nav-link dropdown-toggle" id="navbarDropdownModerations" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#"><?php echo _('Moderations'); ?></a> | |||
| <div class="dropdown-menu" aria-labelledby="navbarDropdownModerations"> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('requests/'.time().'/moderations/request_status_number/asc/1'); ?>"><?php echo _('Center requests'); ?></a> | |||
| </div> | |||
| </li> | |||
| <?php endif; ?> | |||
| <?php if($this->checkPermissions([GUEST_ROLE_ID])): ?> | |||
| <li class="nav-item dropdown"> | |||
| <a class="nav-link dropdown-toggle" id="navbarDropdownModerations" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#"><?php echo _('Requests'); ?></a> | |||
| <div class="dropdown-menu" aria-labelledby="navbarDropdownModerations"> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('requests/'.time().'/center-guest/created_at/desc/1'); ?>"><?php echo _('Center requests'); ?></a> | |||
| </div> | |||
| </li> | |||
| <?php endif; ?> | |||
| <?php if($this->checkPermissions([REFERRER_ROLE_ID])): ?> | |||
| <li class="nav-item dropdown"> | |||
| <a class="nav-link dropdown-toggle" id="navbarDropdownModerations" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#"><?php echo _('Reports'); ?></a> | |||
| <div class="dropdown-menu" aria-labelledby="navbarDropdownModerations"> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('requests/'.time().'/reports/request_status_number/asc/1'); ?>"><?php echo _('My reports'); ?></a> | |||
| </div> | |||
| </li> | |||
| <?php endif; ?> | |||
| <!--<li class="nav-item"> | |||
| <a class="nav-link" href="#">Link</a> | |||
| </li>--> | |||
| </ul> | |||
| <div class="my-2 my-lg-0"> | |||
| <ul class="navbar-nav mr-auto mt-2 mt-lg-0"> | |||
| <li class="nav-item dropdown"> | |||
| <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |||
| <?php echo $this->helper->setAvatarView($this->user->getAvatar(), ['class'=>'nav-avatar', 'cssId'=>'nav-left-avatar', 'timestamp'=>md5($this->user->getUserField('userUpdatedAt'))]); ?> | |||
| <span id="nav-display-name"><?php echo $this->user->setDisplayName(); ?><?php echo $this->user->getUserStatus() == STATUS_TECH_ID ? ' <span class="icon-wrench"></span>' : ''; ?> (<?php echo strtoupper($this->user->getUserField('userDefaultLang')); ?>) <?php echo $this->helper->getUserFlag($this->user->getUserField('userCountryCode'), 20); ?></span> | |||
| </a> | |||
| <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown"> | |||
| <a class="dropdown-item" href="<?php echo $this->helper->setHash('profile/'.time()); ?>"><?php echo _('Profile'); ?></a> | |||
| <div class="dropdown-divider"></div> | |||
| <a class="dropdown-item btn-logout" href="#"><?php echo _('Logout'); ?></a> | |||
| </div> | |||
| </li> | |||
| </ul> | |||
| </div> | |||
| </div> | |||
| </nav> | |||
| <?php if($this->showBreadcrumbs): ?> | |||
| <nav aria-label="breadcrumb"> | |||
| <ol class="breadcrumb"> | |||
| <li class="breadcrumb-item"><span class="icon-home"></span> <a href="<?php echo $this->helper->setHash('dashboard'); ?>">Home</a></li> | |||
| <?php if(is_array($this->breadcrumbs) && !empty($this->breadcrumbs)): ?> | |||
| <?php foreach($this->breadcrumbs as $bc): ?> | |||
| <li class="breadcrumb-item" aria-current="page"> | |||
| <?php if(!is_null($bc['hash'])): ?> | |||
| <a href="#/<?php echo $bc['hash']; ?>"><?php echo rawurldecode($bc['label']); ?></a> | |||
| <?php else: ?> | |||
| <?php echo $bc['label']; ?> | |||
| <?php endif; ?> | |||
| </li> | |||
| <?php endforeach; ?> | |||
| <?php endif; ?> | |||
| </ol> | |||
| </nav> | |||
| <?php endif; ?> | |||
| @@ -0,0 +1,33 @@ | |||
| <?php if(isset($this->view->totalPages) && (int)$this->view->totalPages > 0): ?> | |||
| <hr> | |||
| <div class="row"> | |||
| <div class="col-lg-6 col-xl-6"> | |||
| <p><small><?php echo vsprintf(_('Pag. %s of %s, %s total elements'), [$this->view->currentPage, $this->view->totalPages, $this->view->totalRows]); ?></small></p> | |||
| </div> | |||
| <div class="col-lg-6 col-xl-6 clearfix"> | |||
| <div class="float-right"> | |||
| <ul class="pagination pagination"> | |||
| <li class="page-item <?php echo !$this->view->hasPrevPage ? 'disabled' : ''; ?>"> | |||
| <a class="page-link" href="<?php echo $this->view->prevPageLink; ?>"> | |||
| <span aria-hidden="true">«</span> | |||
| </a> | |||
| </li> | |||
| <?php /*foreach($this->view->pageNumbers as $item): ?> | |||
| <li class="page-item <?php echo $item['active'] ? 'disabled' : ''; ?>"> | |||
| <a class="page-link" href="<?php echo $item['link']; ?>" tabindex="-1" data-element="pippo"><?php echo $item['label']; ?></a> | |||
| </li> | |||
| <?php endforeach;*/ ?> | |||
| <li class="page-item <?php echo !$this->view->hasNextPage ? 'disabled' : ''; ?>"> | |||
| <a class="page-link" href="<?php echo $this->view->nextPageLink; ?>"> | |||
| <span aria-hidden="true">»</span> | |||
| </a> | |||
| </li> | |||
| </ul> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <?php endif; ?> | |||
| @@ -0,0 +1,37 @@ | |||
| <div id="tm-container"> | |||
| <form method="post" id="post-tus-upload"> | |||
| <div class="row"> | |||
| <div class="col-lg-2 margin-bottom-20"> | |||
| <input type="file" multiple="multiple" class="" id="tus-upload-control"> | |||
| <button type="button" class="btn btn-success" id="tus-upload-select-dialog"><span class="icon-folder-open"></span> <?php echo _('Choose files...'); ?></button> | |||
| <button type="button" class="btn btn-primary" id="btn-tus-upload" data-postid="1"><span class="icon-play2"></span></button> | |||
| </div> | |||
| <div class="col-lg-10"> | |||
| <div id="upload-list-table-wrapper"> | |||
| <table class="table table-sm table-hover" id="tus-upload-file-list"> | |||
| <thead> | |||
| <tr> | |||
| <!--<th width="5%"><?php echo _('#ID'); ?></th>--> | |||
| <th width="3%"></th> | |||
| <th><?php echo _('Name'); ?></th> | |||
| <th width="15%" class="text-center"></th> | |||
| <th width="10%">MB</th> | |||
| <th width="5%" class="text-center"> | |||
| <button type="button" class="btn btn-warning btn-sm btn-clean-upload-list"><span class="icon-paint-format"></span></button> | |||
| </th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,34 @@ | |||
| <div class="modal fade" tabindex="-1" role="dialog" id="password-recovery-dialog"> | |||
| <div class="modal-dialog modal-lg" role="document"> | |||
| <div class="modal-content"> | |||
| <div class="modal-header"> | |||
| <h5 class="modal-title"><?php echo _('Password recovery'); ?></h5> | |||
| <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||
| <span aria-hidden="true">×</span> | |||
| </button> | |||
| </div> | |||
| <div class="modal-body"> | |||
| <div class="text-center recovery-password-done-msg"> | |||
| <div><img src="/images/like.svg" alt="<?php echo _('Password recovery'); ?>" width="100"></div> | |||
| <div class="margin-top-20"><?php echo _('The temporary password has been sent. Check your e-mail box as soon as possible. Thanks!'); ?></div> | |||
| </div> | |||
| <div class="recovery-password-form"> | |||
| <div class="alert alert-info" role="alert"> | |||
| <?php echo _('Please provide your e-mail address to receive a new temporary password.'); ?> | |||
| </div> | |||
| <form> | |||
| <div class="form-group"> | |||
| <label for="recovery_email"><?php echo _('E-mail'); ?></label> | |||
| <input type="text" class="form-control" name="data[recovery_email]" id="recovery_email" /> | |||
| </div> | |||
| </form> | |||
| </div> | |||
| </div> | |||
| <div class="modal-footer"> | |||
| <button type="button" class="btn btn-light" data-dismiss="modal"><?php echo _('Close'); ?></button> | |||
| <button type="button" class="btn btn-success btn-send-temporary-password"><?php echo _('Send'); ?></button> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,24 @@ | |||
| <?php global $config; ?> | |||
| <div id="mail-wrapper" style="width:100%; background-color: #F5F5F5; padding: 20px 0 20px 0;"> | |||
| <div id="mail-container" style="width: 600px; background-color: #FFF; border-radius: 5px; padding: 10px; margin: 0 auto; border:1px solid #eee;"> | |||
| <div id="mail-header" style="padding: 10px; border-bottom: 1px solid #eee; background-color: #0061f2;"> | |||
| <div id="mail-title"> | |||
| <h1 style="font-size: 20px; color: #fff; padding: 0; margin: 0; display: flex; align-items: center;"> | |||
| <?php echo $email_title; ?> | |||
| </h1> | |||
| </div> | |||
| </div> | |||
| <div id="mail-body" style="padding: 10px 10px 10px 0; margin: 20px 0 20px 0;"> | |||
| <?php echo $body; ?> | |||
| </div> | |||
| <!-- | |||
| <div id="mail-footer" style="text-align: center; font-size: 12px; color: #666; padding: 10px; border-top: 1px solid #eee;"> | |||
| <div style="text-align: center;"> | |||
| </div> | |||
| </div> | |||
| --> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,27 @@ | |||
| <?php global $config; ?> | |||
| <?php if($showTemplate): ?> | |||
| <div id="mail-wrapper" style="width:100%; background-color: #F5F5F5; padding: 20px 0 20px 0;"> | |||
| <div style="font-size: 12px; text-align: center; padding: 0 0 10px 0;"><?php echo vsprintf(_("Can't you correctly read this e-email? Try %sclicking here%s."), ['<a href="'.$config['settings']['email']['preview-link'].$mailID.'" target="_blank">', '</a>']); ?></div> | |||
| <div id="mail-container" style="width: 600px; background-color: #FFF; border-radius: 5px; padding: 10px; margin: 0 auto; border:1px solid #eee;"> | |||
| <div id="mail-header" style="padding: 10px; border-bottom: 1px solid #eee;"> | |||
| <div id="mail-title"> | |||
| <h1 style="font-size: 20px; padding: 0; margin: 0; display: flex; align-items: center;"><img style="margin-right: 10px;" src="<?php echo $config['settings']['email']['logo-uri'], $mailID, '_', 'logo-email.png'; ?>" width="<?php echo $config['settings']['email']['logo-width']; ?>" alt="Logo"> <?php echo $config['settings']['app-title']; ?></h1> | |||
| </div> | |||
| </div> | |||
| <div id="mail-body" style="padding: 10px 10px 10px 0; margin: 20px 0 20px 0;"> | |||
| <?php echo $body; ?> | |||
| </div> | |||
| <div id="mail-footer" style="text-align: center; font-size: 12px; color: #666; padding: 10px; border-top: 1px solid #eee;"> | |||
| <?php /*<div><a href="<?php echo $config['settings']['email']['footer-home-link']; ?>" target="_blank"><?php echo $config['settings']['app-title']; ?></a></div>*/ ?> | |||
| <div> | |||
| <?php echo $config['settings']['email']['footer-message']; ?> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <?php else: ?> | |||
| <?php echo $body; ?> | |||
| <?php endif; ?> | |||
| @@ -0,0 +1,31 @@ | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th><?php echo _('Surname'); ?></th> | |||
| <th><?php echo _('Name'); ?></th> | |||
| <th><?php echo _('E-mail'); ?></th> | |||
| <th><?php echo _('E-mail Subject'); ?></th> | |||
| <th class="text-center"><?php echo _('Sent'); ?></th> | |||
| <th class="text-center"><?php echo _('E-mail opened'); ?></th> | |||
| <th class="text-right"><?php echo _('Opened (GMT)'); ?></th> | |||
| <th class="text-right"><?php echo _('Sent (GMT)'); ?></th> | |||
| <th width="1%"></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($this->view->trackers as $tracker): ?> | |||
| <tr> | |||
| <td><?php echo $tracker['surname']; ?></td> | |||
| <td><?php echo $tracker['name']; ?></td> | |||
| <td><?php echo $tracker['mail_to']; ?></td> | |||
| <td><?php echo $tracker['mail_subject']; ?></td> | |||
| <td class="text-center"><?php echo $this->helper->setYesNo($tracker['request_result']); ?></td> | |||
| <td class="text-center"><?php echo $this->helper->setYesNo($tracker['mail_opened']); ?></td> | |||
| <td class="text-right"><?php echo $this->helper->getDateString($tracker['mail_opened_at']); ?></td> | |||
| <td class="text-right"><?php echo $this->helper->getDateString($tracker['created_at']); ?></td> | |||
| <td><button type="button" class="btn btn-outline-dark btn-sm"><span class="icon-eye"></span></button></td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| @@ -0,0 +1,31 @@ | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th><?php echo _('Surname'); ?></th> | |||
| <th><?php echo _('Name'); ?></th> | |||
| <th><?php echo _('E-mail'); ?></th> | |||
| <th><?php echo _('E-mail Subject'); ?></th> | |||
| <th class="text-center"><?php echo _('Sent'); ?></th> | |||
| <th class="text-center"><?php echo _('E-mail opened'); ?></th> | |||
| <th class="text-right"><?php echo _('Opened (GMT)'); ?></th> | |||
| <th class="text-right"><?php echo _('Sent (GMT)'); ?></th> | |||
| <th width="1%"></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($this->view->trackers as $tracker): ?> | |||
| <tr> | |||
| <td><?php echo $tracker['surname']; ?></td> | |||
| <td><?php echo $tracker['name']; ?></td> | |||
| <td><?php echo $tracker['mail_to']; ?></td> | |||
| <td><?php echo $tracker['mail_subject']; ?></td> | |||
| <td class="text-center"><?php echo $this->helper->setYesNo($tracker['request_result']); ?></td> | |||
| <td class="text-center"><?php echo $this->helper->setYesNo($tracker['mail_opened']); ?></td> | |||
| <td class="text-right"><?php echo $this->helper->getDateString($tracker['mail_opened_at']); ?></td> | |||
| <td class="text-right"><?php echo $this->helper->getDateString($tracker['created_at']); ?></td> | |||
| <td><button type="button" class="btn btn-outline-dark btn-sm"><span class="icon-eye"></span></button></td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| @@ -0,0 +1,27 @@ | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th><?php echo _('Surname'); ?></th> | |||
| <th><?php echo _('Name'); ?></th> | |||
| <th><?php echo _('Number'); ?></th> | |||
| <th><?php echo _('Message'); ?></th> | |||
| <th class="text-center"><?php echo _('Delivered'); ?></th> | |||
| <th class="text-right"><?php echo _('Sent (GMT)'); ?></th> | |||
| <th width="1%"></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($this->view->trackers as $tracker): ?> | |||
| <tr> | |||
| <td><?php echo $tracker['surname']; ?></td> | |||
| <td><?php echo $tracker['name']; ?></td> | |||
| <td><?php echo $tracker['phone_to']; ?></td> | |||
| <td><?php echo $tracker['phone_msg']; ?></td> | |||
| <td class="text-center"><?php echo $this->helper->setYesNo($tracker['request_result']); ?></td> | |||
| <td class="text-right"><?php echo $this->helper->getDateString($tracker['created_at']); ?></td> | |||
| <td><button type="button" class="btn btn-outline-dark btn-sm"><span class="icon-eye"></span></button></td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| @@ -0,0 +1,343 @@ | |||
| <!doctype html> | |||
| <html lang="en-US"> | |||
| <head> | |||
| <meta charset="utf-8"> | |||
| <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |||
| <link rel="stylesheet" href="<?php echo $publicUri; ?>css/bootstrap.min.css"> | |||
| <link rel="stylesheet" href="<?php echo $publicUri; ?>css/style.css?t=<?php echo time(); ?>"> | |||
| <link rel="stylesheet" href="<?php echo $publicUri; ?>css/fonts.css"> | |||
| <style media="screen"> | |||
| .text_info{color: #777777} | |||
| .borderless td, .borderless th { | |||
| border: none; | |||
| } | |||
| .border-right {border-right:1px solid #cccccc !important} | |||
| .text-health{font-size: 18px} | |||
| h5{margin:0px;padding:0px !important} | |||
| hr{margin-top:1px} | |||
| @media screen { | |||
| .page { | |||
| page-break-after: always !important; | |||
| } | |||
| } | |||
| </style> | |||
| </head> | |||
| <body> | |||
| <div class="container"> | |||
| <div class="container-page-wrapper"> | |||
| <div class="container-page-container"> | |||
| <div class="row"> | |||
| <div class="col" style="width:100%;padding:0px;margin:0px"> | |||
| <table class="table borderless table-sm" style="width:100%;padding:0px;margin:0px; border: 1px solid #cccccc"> | |||
| <tr style="text-align:center"> | |||
| <td class="border-right" style="width:32%; border-bottom:1px solid #cccccc" colspan="2"><b><?php echo strtoupper(_('Patient_data')); ?></b></td> | |||
| <td class="border-right" style="width:31%; border-bottom:1px solid #cccccc" colspan="2"><b><?php echo strtoupper(_('Request specialist')); ?></b></td> | |||
| <td class="border-right" style="width:37%; border-bottom:1px solid #cccccc" colspan="2"><b><?php echo strtoupper(_('Teleconsultation')); ?></b></td> | |||
| </tr> | |||
| <!-- RIGA 1 --> | |||
| <tr> | |||
| <td style="width:9%" class="text_info"><?php echo _('Name'); ?></td> | |||
| <td class="border-right" style="width:25%"> | |||
| <b> | |||
| <?php if($this->view->requestData['request_anonymous'] == '0'): ?> | |||
| <?php echo $this->view->requestData['patient_name']; ?> | |||
| <?php else: ?> | |||
| <?php echo '...' ?> | |||
| <?php endif; ?> | |||
| </b> | |||
| </td> | |||
| <td style="text-align:center"> | |||
| <?php if(is_array($this->view->requestMedicalSpecialties)): ?> | |||
| <?php $i = 1 ?> | |||
| <?php foreach($this->view->requestMedicalSpecialties as $item): ?> | |||
| <?php if($i == 1): ?> | |||
| <b><?php echo $item['description']; ?></b> | |||
| <?php endif; ?> | |||
| <?php $i++ ?> | |||
| <?php endforeach; ?> | |||
| <?php endif; ?> | |||
| </td> | |||
| <td style="text-align:center" class="border-right"> | |||
| <?php if(is_array($this->view->requestMedicalSpecialties)): ?> | |||
| <?php $i = 1 ?> | |||
| <?php foreach($this->view->requestMedicalSpecialties as $item): ?> | |||
| <?php if($i == 2): ?> | |||
| <b><?php echo $item['description']; ?></b> | |||
| <?php endif; ?> | |||
| <?php $i++ ?> | |||
| <?php endforeach; ?> | |||
| <?php endif; ?> | |||
| </td> | |||
| <td style="width:10%" class="text_info"><?php echo _('Number ID'); ?></td> | |||
| <td class="border-right" style="width:25%"><b><?php echo $this->actionTitlePDF; ?></b></td> | |||
| </tr> | |||
| <!-- RIGA 2 --> | |||
| <tr> | |||
| <td style="width:8%" class="text_info"><?php echo _('Surname'); ?></td> | |||
| <td class="border-right"> | |||
| <b> | |||
| <?php if($this->view->requestData['request_anonymous'] == '0'): ?> | |||
| <?php echo $this->view->requestData['patient_surname']; ?> | |||
| <?php else: ?> | |||
| <?php echo '...' ?> | |||
| <?php endif; ?> | |||
| </b> | |||
| </td> | |||
| <td style="text-align:center"> | |||
| <?php if(is_array($this->view->requestMedicalSpecialties)): ?> | |||
| <?php $i = 1 ?> | |||
| <?php foreach($this->view->requestMedicalSpecialties as $item): ?> | |||
| <?php if($i == 3): ?> | |||
| <b><?php echo $item['description']; ?></b> | |||
| <?php endif; ?> | |||
| <?php $i++ ?> | |||
| <?php endforeach; ?> | |||
| <?php endif; ?> | |||
| </td> | |||
| <td style="text-align:center" class="border-right"> | |||
| <?php if(is_array($this->view->requestMedicalSpecialties)): ?> | |||
| <?php $i = 1 ?> | |||
| <?php foreach($this->view->requestMedicalSpecialties as $item): ?> | |||
| <?php if($i == 4): ?> | |||
| <b><?php echo $item['description']; ?></b> | |||
| <?php endif; ?> | |||
| <?php $i++ ?> | |||
| <?php endforeach; ?> | |||
| <?php endif; ?> | |||
| </td> | |||
| <td style="width:15%" class="text_info"><?php echo _('Health Center'); ?></td> | |||
| <td class="border-right" ><b><?php echo $this->view->requestData['center_description']; ?></b></td> | |||
| </tr> | |||
| <!-- RIGA 3 --> | |||
| <tr> | |||
| <td style="width:8%" class="text_info"><?php echo _('Gender'); ?></td> | |||
| <td class="border-right"> | |||
| <b> | |||
| <?php if($this->view->requestData['gender'] == 'm'): ?> | |||
| <?php echo _('Male') ?> | |||
| <?php else: ?> | |||
| <?php echo _('Female') ?> | |||
| <?php endif; ?> | |||
| </b> | |||
| </td> | |||
| <td style="text-align:center"> | |||
| <?php if(is_array($this->view->requestMedicalSpecialties)): ?> | |||
| <?php $i = 1 ?> | |||
| <?php foreach($this->view->requestMedicalSpecialties as $item): ?> | |||
| <?php if($i == 5): ?> | |||
| <b><?php echo $item['description']; ?></b> | |||
| <?php endif; ?> | |||
| <?php $i++ ?> | |||
| <?php endforeach; ?> | |||
| <?php endif; ?> | |||
| </td> | |||
| <td style="text-align:center" class="border-right"> | |||
| <?php if(is_array($this->view->requestMedicalSpecialties)): ?> | |||
| <?php $i = 1 ?> | |||
| <?php foreach($this->view->requestMedicalSpecialties as $item): ?> | |||
| <?php if($i == 6): ?> | |||
| <b><?php echo $item['description']; ?></b> | |||
| <?php endif; ?> | |||
| <?php $i++ ?> | |||
| <?php endforeach; ?> | |||
| <?php endif; ?> | |||
| </td> | |||
| <td style="width:10%" class="text_info"><?php echo _('Request date'); ?></td> | |||
| <td class="border-right" ><b><?php echo date('d/m/Y H:i', strtotime($this->view->requestData['created_at'])); ?></b></td> | |||
| </tr> | |||
| <!-- RIGA 4 --> | |||
| <tr> | |||
| <td style="width:8%" class="text_info"><?php echo _('Age'); ?></td> | |||
| <td class="border-right"> | |||
| <b> | |||
| <?php echo $this->helper->patient_age(['anonymous'=>$this->view->requestData['request_anonymous'], 'ageYears'=>$this->view->requestData['age_years'], 'ageMonths'=>$this->view->requestData['age_months'], 'ageDays'=>$this->view->requestData['age_days']]); ?></td> | |||
| </b> | |||
| </td> | |||
| <td style="text-align:center"> | |||
| <?php if(is_array($this->view->requestMedicalSpecialties)): ?> | |||
| <?php $i = 1 ?> | |||
| <?php foreach($this->view->requestMedicalSpecialties as $item): ?> | |||
| <?php if($i == 7): ?> | |||
| <?php echo $item['description']; ?> | |||
| <?php endif; ?> | |||
| <?php $i++ ?> | |||
| <?php endforeach; ?> | |||
| <?php endif; ?> | |||
| </td> | |||
| <td style="text-align:center" class="border-right"> | |||
| <?php if(is_array($this->view->requestMedicalSpecialties)): ?> | |||
| <?php $i = 1 ?> | |||
| <?php foreach($this->view->requestMedicalSpecialties as $item): ?> | |||
| <?php if($i == 8): ?> | |||
| <?php echo $item['description']; ?> | |||
| <?php endif; ?> | |||
| <?php $i++ ?> | |||
| <?php endforeach; ?> | |||
| <?php endif; ?> | |||
| </td> | |||
| <td class="text_info"><?php echo _('Requester'); ?></td> | |||
| <td class="border-right"><b><?php echo $this->view->requestData['sender_surname'].' '.$this->view->requestData['sender_name']; ?></b></td> | |||
| </tr> | |||
| </table> | |||
| </div> | |||
| </div> | |||
| <!-- FINE TRE COLONNE PRINCIPALI --> | |||
| <div class="card-body"> | |||
| <?php if(trim($this->view->requestData['medical_history']) != ''): ?> | |||
| <h5><?php echo _('Medical History'); ?></h5> | |||
| <hr> | |||
| <?php echo $this->helper->hashtag(nl2br(trim(strip_tags($this->view->requestData['medical_history'])))); ?> | |||
| <?php endif; ?> | |||
| <h5 class="mt-4"><?php echo _('Medical Remarks'); ?></h5> | |||
| <hr style="margin-bottom:0px"> | |||
| <div class="row mt-2 mb-2"> | |||
| <?php if ((float)$this->view->requestData['min_arterial_pressure'] > 0 && (float)$this->view->requestData['max_arterial_pressure'] > 0): ?> | |||
| <div class="col text-center"> | |||
| <div class="text-health"><small><?php echo _('Blood Pressure'); ?></small><b class="ml-3"><?php echo $this->view->requestData['max_arterial_pressure']; ?>/<?php echo $this->view->requestData['min_arterial_pressure']; ?></b> <sup>mmHg</sup></div> | |||
| </div> | |||
| <?php endif; ?> | |||
| <?php if ((float)$this->view->requestData['heart_rate'] > 0): ?> | |||
| <div class="col text-center"> | |||
| <div class="text-health"><small><?php echo _('Heart Rate'); ?></small><b class="ml-3"><?php echo $this->view->requestData['heart_rate']; ?></b> <sup>bpm</sup></div> | |||
| </div> | |||
| <?php endif; ?> | |||
| <?php if ((float)$this->view->requestData['saturation'] > 0): ?> | |||
| <div class="col text-center"> | |||
| <div class="text-health"><small><?php echo vsprintf(_('%s Sat.'), 'O<sub>2</sub>'); ?></small><b class="ml-3"> | |||
| <?php if($this->view->requestData['saturation'] == '0'): ?> | |||
| <?php echo '-'; ?> | |||
| <?php else: ?> | |||
| <?php echo $this->view->requestData['saturation']; ?> <sup>%</sup> | |||
| <?php endif; ?> | |||
| </b> | |||
| </div> | |||
| <?php endif; ?> | |||
| </div> | |||
| </div> | |||
| <hr> | |||
| <?php echo nl2br(trim(strip_tags($this->view->requestData['clinical_remarks']))); ?> | |||
| </div> | |||
| <?php if(is_array($this->view->symptoms) && !empty($this->view->symptoms)): ?> | |||
| <div class="card margin-top-10"> | |||
| <div class="card-body"> | |||
| <h5 class="card-title"><?php echo _('ICD-10'); ?></h5> | |||
| <ol class="list-no-margin-bottom"> | |||
| <?php foreach($this->view->symptoms as $symptom): ?> | |||
| <li><?php echo ucfirst($symptom['symptom_label']); ?></li> | |||
| <?php endforeach; ?> | |||
| </ol> | |||
| </div> | |||
| </div> | |||
| <?php endif; ?> | |||
| <?php if(is_array($this->view->wizards)): ?> | |||
| <?php foreach($this->view->wizards as $type => $items): ?> | |||
| <div class="card margin-top-10"> | |||
| <div class="card-body"> | |||
| <h5 class="card-title"><?php echo isset($this->view->wizardTitles[$type]) ? $this->view->wizardTitles[$type] : '-'; ?></h5> | |||
| <ol class="list-no-margin-bottom"> | |||
| <?php foreach($items as $item): ?> | |||
| <li><?php echo $item['description']; ?></li> | |||
| <?php endforeach; ?> | |||
| </ol> | |||
| <?php if($type == 'derma'): ?> | |||
| <?php if(is_array($this->view->dermaPositions)): ?> | |||
| <div><b><?php echo _('Position'); ?></b></div> | |||
| <ol> | |||
| <?php foreach($this->view->dermaPositions as $positionType => $positionData): ?> | |||
| <li><?php echo isset($this->view->dermaPositionLabels[$positionData['position_type']]) ? $this->view->dermaPositionLabels[$positionData['position_type']] : '-'; ?></li> | |||
| <?php endforeach; ?> | |||
| </ol> | |||
| <?php endif; ?> | |||
| <?php endif; ?> | |||
| </div> | |||
| </div> | |||
| <?php endforeach; ?> | |||
| <?php endif; ?> | |||
| <!-- <div class="page"></div> --> | |||
| <div class="mb-1"> </div> | |||
| <!-- DOMANDA --> | |||
| <table class="table table-sm" style="border-top: none !important;"> | |||
| <tr> | |||
| <td style="border-top:4px solid gray; border-bottom:4px solid gray" colspan="2"><b><?php echo _('Question'); ?></b></td> | |||
| </tr> | |||
| <tr> | |||
| <td style="border-top: none !important" ><?php echo _('From'); ?>: <b><?php echo $this->view->requestData['sender_surname'].' '.$this->view->requestData['sender_name']; ?></b></td> | |||
| <td style="border-top: none !important; width:25%; text-align:right"><?php echo date('d/m/Y H:i', strtotime($this->view->requestData['created_at'])); ?></td> | |||
| </tr> | |||
| <tr> | |||
| <td colspan="2"><?php echo $this->helper->hashtag($this->view->requestData['request_question']); ?></td> | |||
| </tr> | |||
| </table> | |||
| <!-- FINE DOMANDA --> | |||
| <!-- LISTA COMMENTI --> | |||
| <div id="request-comment-wrapper"> | |||
| <?php echo $this->partial('Request/comment-list-pdf', ['comments'=>$this->view->comments]); ?> | |||
| </div> | |||
| <!-- FINE COMMENTI --> | |||
| <hr> | |||
| <!-- <div class="page"></div> --> | |||
| <!-- ATTACHMENT --> | |||
| <?php if(is_array($this->view->groupedAttachments) && !empty($this->view->groupedAttachments)): ?> | |||
| <div class="mb-1"> </div> | |||
| <div class="card margin-top-10"> | |||
| <div class="card-body"> | |||
| <h5 class="card-title"><?php echo _('Attachments'); ?></h5> | |||
| <?php foreach($this->view->groupedAttachments as $created_at => $attachments): ?> | |||
| <label class="label-main"><?php echo date('d/m/Y H:i', strtotime($created_at)); ?></label> | |||
| <ul class="list-no-type margin-bottom-10"> | |||
| <?php foreach($attachments as $attach): ?> | |||
| <li class="list-no-type padding-left-10"> | |||
| <?php echo $this->helper->getDocName($attach); ?> | |||
| </li> | |||
| <?php endforeach; ?> | |||
| </ul> | |||
| <?php endforeach; ?> | |||
| </div> | |||
| </div> | |||
| <?php endif; ?> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> | |||
| <script src="<?php echo $publicUri; ?>js/bootstrap.min.js"></script> | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,2 @@ | |||
| <?php | |||
| debug($this->view->requestId); | |||
| @@ -0,0 +1,14 @@ | |||
| <?php if(isset($attachments) && is_array($attachments)): ?> | |||
| <table class="table table-striped table-hover" id="attach-list-<?php echo $requestUniqueCode; ?>"> | |||
| <tbody> | |||
| <?php foreach($attachments as $attach): ?> | |||
| <tr id="attach-row-id-<?php echo $attach['id']; ?>"> | |||
| <td> | |||
| <?php echo $this->helper->getPreviewLink($attach, false); ?> | |||
| </td> | |||
| <td width="1%" class="text-right"><button type="button" class="btn btn-danger btn-sm rounded-button delete-attach" data-attachtitle="<?php echo $attach['file_title']; ?>" data-attachname="<?php echo $attach['file_name']; ?>" data-attachid="<?php echo $attach['id']; ?>"><span class="icon-cross"></span></button></td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| <?php endif; ?> | |||
| @@ -0,0 +1,16 @@ | |||
| <div class="modal fade" tabindex="-1" role="dialog" id="modal-file-preview"> | |||
| <div class="modal-dialog modal-lg modal-full-size" role="document"> | |||
| <div class="modal-content"> | |||
| <div class="modal-header"> | |||
| <h5 class="modal-title"><?php echo _('Attachment Preview'); ?></h5> | |||
| <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||
| <span aria-hidden="true">×</span> | |||
| </button> | |||
| </div> | |||
| <div class="modal-body"> | |||
| <!--<div class="text-center" id="attachment-loader"><img src="<?php echo $this->layout->getPublicUri(); ?>images/ajaxloader.svg" width="100"></div>--> | |||
| <div id="request-attachment-content"></div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,34 @@ | |||
| <div class="modal fade" tabindex="-1" role="dialog" id="modal-cc-dialog"> | |||
| <div class="modal-dialog modal-lg" role="document"> | |||
| <div class="modal-content"> | |||
| <div class="modal-header"> | |||
| <h5 class="modal-title"><?php echo $this->view->requestData['center_description']; ?></h5> | |||
| <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||
| <span aria-hidden="true">×</span> | |||
| </button> | |||
| </div> | |||
| <div class="modal-body"> | |||
| <div> | |||
| <?php if(trim($this->view->requestData['center_notes']) != ''): ?> | |||
| <div class="row"> | |||
| <?php if((float)$this->view->requestData['lat'] != 0): ?> | |||
| <div class="col"> | |||
| <div class="text-right"><small><span class="icon-location"></span> <?php echo $this->view->requestData['center_address']; ?>, <?php echo $this->view->requestData['center_continent']; ?></small></div> | |||
| <div id="map"></div> | |||
| </div> | |||
| <?php endif; ?> | |||
| <div class="col"> | |||
| <?php echo nl2br($this->view->requestData['center_notes']); ?> | |||
| </div> | |||
| </div> | |||
| <?php else: ?> | |||
| <i><?php echo _('No description available yet.'); ?></i> | |||
| <?php endif; ?> | |||
| </div> | |||
| </div> | |||
| <div class="modal-footer"> | |||
| <button type="button" class="btn btn-primary" data-dismiss="modal"><?php echo _('Close'); ?></button> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,59 @@ | |||
| <div class="row chat-page" style="<?php echo $style; ?>"> | |||
| <div class="tooltip_templates"> | |||
| <div id="tooltip_content_<?php echo $commentId; ?>"> | |||
| <div class="tooltip-title"><?php echo $userName." ".$userSurname ?></div> | |||
| <?php echo trim($userExtra) != '' && $show_specialties ? '<div class="tooltip-extra">'.$userExtra.'</div>' : ''; ?> | |||
| <?php echo $userNote != '' ? '<div class="tooltip-content">'.$this->helper->truncate($userNote, 500).'</div>' : ''; ?> | |||
| </div> | |||
| </div> | |||
| <?php if($commentPosition=='right'): ?> | |||
| <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 text-<?php echo $commentPosition; ?> ad-col-image hide-mobile" style="<?php echo $show_meta ? 'margin-top:30px;' : ''; ?>"> | |||
| <?php if ($show_meta) echo $this->helper->setAvatarView($this->user->getAvatar($userId), ['timestamp'=>md5($userUpdatedAt), 'class'=>'list-avatar']); ?> | |||
| </div> | |||
| <?php endif; ?> | |||
| <div class="col-xs-12 col-sm-12 col-md-10 col-lg-10" style="<?php echo $show_meta ? 'margin-top:30px;' : ''; ?>"> | |||
| <div class="row bubble-date-code"> | |||
| <div class="col-xs-8 col-sm-8 col-md-8 col-lg-8 bubble-text-left"> | |||
| <?php if($show_meta): ?> | |||
| <span data-tooltip-content="#tooltip_content_<?php echo $commentId; ?>" class="<?php echo $isResponder ? 'tooltipstered tooltip-underline' : ''; ?> <?php echo $is_moderator ? 'badge badge-primary' : 'badge badge-light'; ?>"> | |||
| <?php echo $userName." ".$userSurname ?> | |||
| <?php echo $is_moderator ? ' ('._('Moderator').')' : ''; ?> | |||
| <?php echo trim($userExtra) != '' && $show_specialties ? '<span> ('.$this->helper->truncate($userExtra, 25).')</span>' : ''; ?> | |||
| </span> | |||
| <?php endif; ?> | |||
| </div> | |||
| <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4 text-right bubble-text-right"> | |||
| <!--<small><?php echo $this->helper->getDateString($commentCreatedAt, true); ?></small>--> | |||
| </div> | |||
| </div> | |||
| <div class="bubble-<?php echo $commentPosition=='right' ? 'left' : 'right' ?> <?php echo $is_moderator ? 'bubble-moderator' : ''; ?> <?php echo !$show_meta ? 'bubble-remove-arrow' : ''; ?>"> | |||
| <div class="text-right margin-bottom-20"><small class="text-muted"><?php echo $this->helper->getDateString($commentCreatedAt, true); ?></small></div> | |||
| <?php echo $this->helper->hashtag(nl2br(strip_tags($commentText))); ?> | |||
| <?php if(!empty($attachments)): ?> | |||
| <hr> | |||
| <div> | |||
| <?php foreach($attachments as $attachment): ?> | |||
| <?php echo $this->helper->getPreviewLink($attachment, false, '', '', 'badge badge-light'); ?> | |||
| <?php endforeach; ?> | |||
| </div> | |||
| <?php endif; ?> | |||
| </div> | |||
| </div> | |||
| <?php if($commentPosition=='left' && $show_meta): ?> | |||
| <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 text-<?php echo $commentPosition; ?> ad-col-image hide-mobile" style="<?php echo $show_meta ? 'margin-top:30px;' : ''; ?>"> | |||
| <?php echo $this->helper->setAvatarView($this->user->getAvatar($userId), ['timestamp'=>md5($userUpdatedAt), 'class'=>'list-avatar']); ?> | |||
| </div> | |||
| <?php endif; ?> | |||
| </div> | |||
| @@ -0,0 +1,24 @@ | |||
| <style > | |||
| #table_respond td, #table_respond th{padding:0.35rem !important} | |||
| </style> | |||
| <table class="table" id="table_respond"> | |||
| <tr> | |||
| <td style="border-top:4px solid gray; border-bottom:4px solid gray" colspan="2"><b><?php echo _('Specialist respond'); ?></b></td> | |||
| </tr> | |||
| <?php if(is_array($comments) && !empty($comments)): ?> | |||
| <?php foreach($comments as $index => $comment): ?> | |||
| <tr style="border-bottom: 1px solid gray; <?php echo $comment['is_the_author'] ? 'background-color:#cccccc' :'' ?>"> | |||
| <td style="border-top: none !important" ><?php echo _('From'); ?>: <b><?php echo ucwords($comment['user_surname']).' '.ucwords($comment['user_name']); ?><?php echo $comment['show_specialties'] ? ' ('.$comment['medspec_list'].')':'' ?></b></td> | |||
| <td style="border-top: none !important; width:25%; text-align:right"><?php echo date('d/m/Y H:i', strtotime($comment['created_at'])); ?></td> | |||
| </tr> | |||
| <tr> | |||
| <td colspan="2" style="border-top: none !important" ><?php echo $comment['comment']; ?></td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| <?php else: ?> | |||
| <div class="alert alert-info"><?php echo _('No comments so far.'); ?></div> | |||
| <?php endif; ?> | |||
| </table> | |||
| @@ -0,0 +1,18 @@ | |||
| <style > | |||
| #table_respond td, #table_respond th{padding:0.35rem !important} | |||
| </style> | |||
| <table class="table" id="table_respond"> | |||
| <?php if(is_array($comments) && !empty($comments)): ?> | |||
| <?php foreach($comments as $index => $comment): ?> | |||
| <?php | |||
| echo $this->partial('Request/comment-element', ['commentId'=>$comment['id'], 'commentPosition'=>$comment['position'], 'show_specialties'=>$comment['show_specialties'], 'show_meta'=>$comment['show_meta'], 'is_moderator'=>$comment['is_moderator'], 'style'=>'margin-bottom:5px;', 'userId'=>$comment['user_id'], 'userUpdatedAt'=>$comment['user_updated_at'], 'userName'=>ucwords($comment['user_name']), 'userSurname'=>ucwords($comment['user_surname']), 'userExtra'=>$comment['medspec_list'], 'isResponder'=>$comment['is_responder'], 'userNote'=>$comment['remarks_public'], 'commentCreatedAt'=>$comment['created_at'], 'commentText'=>htmlspecialchars($comment['comment']), 'attachments'=>$comment['attachments']]); | |||
| ?> | |||
| <?php endforeach; ?> | |||
| <?php else: ?> | |||
| <div class="alert alert-info"><?php echo _('No comments so far.'); ?></div> | |||
| <?php endif; ?> | |||
| </table> | |||
| @@ -0,0 +1,194 @@ | |||
| <?php | |||
| //debug($exams); | |||
| ?> | |||
| <?php if (!empty($registry)): ?> | |||
| <div class="text-right"><span class="badge badge-secondary">ID: <?php echo $registry['idCartella']; ?></span></div> | |||
| <h4><?php echo _('Registry'); ?></h4> | |||
| <div class="table-overflow table-overflow-popup"> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th><?php echo _('Age'); ?></th> | |||
| <th><?php echo _('Sex'); ?></th> | |||
| <th><?php echo _('HIV-positive'); ?></th> | |||
| <th><?php echo _('AIDS Stage'); ?></th> | |||
| <th><?php echo _('ART'); ?></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <tr> | |||
| <td><?php echo $registry['age']; ?></td> | |||
| <td><?php echo $registry['sesso']; ?></td> | |||
| <td> | |||
| <?php | |||
| if (isset($HivTestHistory['HIV_Stato'])) { | |||
| echo $HivTestHistory['HIV_Stato']=='HIV_YES' ? _('Yes') : _('No'); | |||
| } | |||
| ?> | |||
| </td> | |||
| <td> | |||
| <?php | |||
| if (isset($HivStages['StadioSida'])) { | |||
| echo $HivStages['StadioSida']; | |||
| } | |||
| ?> | |||
| </td> | |||
| <td> | |||
| <?php | |||
| if (isset($TarvHistory['StatoTerapia'])) { | |||
| echo $TarvHistory['StatoTerapia']=='TARV_SI' ? _('Yes') : _('No'); | |||
| } | |||
| ?> | |||
| </td> | |||
| </tr> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| <?php endif; ?> | |||
| <?php if (!empty($exams)): ?> | |||
| <h4><?php echo _('Examen'); ?></h4> | |||
| <div class="table-overflow table-overflow-popup"> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th><?php echo _('Date'); ?></th> | |||
| <?php foreach($examsAcr as $label): ?> | |||
| <th><?php echo $label; ?></th> | |||
| <?php endforeach; ?> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($exams as $exam): ?> | |||
| <tr> | |||
| <td><?php echo $this->helper->getDateString($exam['Data'], false) ?? ''; ?></td> | |||
| <?php foreach($examsAcr as $label): ?> | |||
| <td><?php echo $exam[$label] ?? ''; ?></td> | |||
| <?php endforeach; ?> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| <?php endif; ?> | |||
| <?php if (!empty($dailyData)): ?> | |||
| <h4><?php echo _('Daily'); ?></h4> | |||
| <div class="row margin-bottom-10"> | |||
| <?php foreach($examStats as $year => $stat): ?> | |||
| <div class="col-lg-4 col-xl-4"><canvas id="daily-chart-values-<?php echo $year; ?>"></canvas></div> | |||
| <?php endforeach; ?> | |||
| </div> | |||
| <div class="table-overflow table-overflow-popup"> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th><?php echo _('Date'); ?></th> | |||
| <th>BMI</th> | |||
| <th>TAmax</th> | |||
| <th>TAmin</th> | |||
| <th>FC</th> | |||
| <th>FR</th> | |||
| <th>TC</th> | |||
| <th><?php echo _('Notes'); ?></th> | |||
| <th><?php echo _('Diagnosis'); ?></th> | |||
| <th><?php echo _('Symptoms'); ?></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($dailyData as $idDiaria => $diariaData): ?> | |||
| <tr> | |||
| <td><?php echo $this->helper->getDateString($diariaData['Diaria']['Data'], false) ?? ''; ?></td> | |||
| <td><?php echo $diariaData['Diaria']['BMI'] ?? ''; ?></td> | |||
| <td><?php echo $diariaData['Diaria']['TAmax'] ?? ''; ?></td> | |||
| <td><?php echo $diariaData['Diaria']['TAmin'] ?? ''; ?></td> | |||
| <td><?php echo $diariaData['Diaria']['FC'] ?? ''; ?></td> | |||
| <td><?php echo $diariaData['Diaria']['FR'] ?? ''; ?></td> | |||
| <td><?php echo $diariaData['Diaria']['TC'] ?? ''; ?></td> | |||
| <td><?php echo $diariaData['Diaria']['Note'] ?? ''; ?></td> | |||
| <td> | |||
| <?php if(isset($diariaData['Sintomi']) && is_array($diariaData['Sintomi'])): ?> | |||
| <ul> | |||
| <?php foreach($diariaData['Sintomi'] as $symptoms): ?> | |||
| <li><?php echo $symptoms['Sintomi']; ?></li> | |||
| <?php endforeach; ?> | |||
| </ul> | |||
| <?php endif; ?> | |||
| </td> | |||
| <td> | |||
| <?php if(isset($diariaData['Diagnosi']) && is_array($diariaData['Diagnosi'])): ?> | |||
| <ul> | |||
| <?php foreach($diariaData['Diagnosi'] as $symptoms): ?> | |||
| <li><?php echo $symptoms['Diagnosi']; ?></li> | |||
| <?php endforeach; ?> | |||
| </ul> | |||
| <?php endif; ?> | |||
| </td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| <?php endif; ?> | |||
| <?php if (!empty($TarvHistory)): ?> | |||
| <h4><?php echo _('TARV'); ?></h4> | |||
| <div class="table-overflow table-overflow-popup"> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th><?php echo _('Date'); ?></th> | |||
| <th><?php echo _('Status'); ?></th> | |||
| <th><?php echo _('Reason'); ?></th> | |||
| <th><?php echo _('Line Description'); ?></th> | |||
| <th><?php echo _('Therapy Description'); ?></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($TarvHistory as $tHistory): ?> | |||
| <tr> | |||
| <td><?php echo $this->helper->getDateString($tHistory['DataInizio'], false) ?? ''; ?></td> | |||
| <td><?php echo $tHistory['StatoTerapia'] == 'TARV_SI' ? _('Yes') : _('No'); ?></td> | |||
| <td><?php echo $tHistory['Motivo'] ?? ''; ?></td> | |||
| <td><?php echo $tHistory['Descrizione_Linea'] ?? ''; ?></td> | |||
| <td><?php echo $tHistory['Descrizione_Terapia'] ?? ''; ?></td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| <?php endif; ?> | |||
| <?php if (!empty($ListaFarmaci)): ?> | |||
| <h4><?php echo _('Available drugs'); ?></h4> | |||
| <div class="table-overflow table-overflow-popup"> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th><?php echo _('Commercial name'); ?></th> | |||
| <th><?php echo _('Active substance name'); ?></th> | |||
| <th><?php echo _('Dosage'); ?></th> | |||
| <th><?php echo _('Quantity'); ?></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($ListaFarmaci as $lFarmaci): ?> | |||
| <tr> | |||
| <td><?php echo $lFarmaci['NomeCommerciale'] ?? ''; ?></td> | |||
| <td><?php echo $lFarmaci['NomeComposto'] ?? ''; ?></td> | |||
| <td><?php echo $lFarmaci['Posologia'] ?? ''; ?></td> | |||
| <td><?php echo $lFarmaci['Quantita'] ?? ''; ?></td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| <?php endif; ?> | |||
| @@ -0,0 +1,194 @@ | |||
| <?php | |||
| //debug($dreamData); | |||
| ?> | |||
| <?php if (!empty($registry)): ?> | |||
| <div class="text-right"><span class="badge badge-secondary">ID: <?php echo $registry['idCartella']; ?></span></div> | |||
| <h4><?php echo _('Registry'); ?></h4> | |||
| <div class="table-overflow table-overflow-popup"> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th><?php echo _('Age'); ?></th> | |||
| <th><?php echo _('Sex'); ?></th> | |||
| <th><?php echo _('HIV-positive'); ?></th> | |||
| <th><?php echo _('AIDS Stage'); ?></th> | |||
| <th><?php echo _('ART'); ?></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <tr> | |||
| <td><?php echo $registry['age']; ?></td> | |||
| <td><?php echo $registry['sesso']; ?></td> | |||
| <td> | |||
| <?php | |||
| if (isset($HivTestHistory['status'])) { | |||
| echo $HivTestHistory['status']=='HIV_YES' ? _('Yes') : _('No'); | |||
| } | |||
| ?> | |||
| </td> | |||
| <td> | |||
| <?php | |||
| if (isset($HivStages['status_diag'])) { | |||
| echo $HivStages['status_diag']; | |||
| } | |||
| ?> | |||
| </td> | |||
| <td> | |||
| <?php | |||
| if (isset($TarvHistory['StatoTerapia'])) { | |||
| echo $TarvHistory['StatoTerapia']=='TARV_SI' ? _('Yes') : _('No'); | |||
| } | |||
| ?> | |||
| </td> | |||
| </tr> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| <?php endif; ?> | |||
| <?php if (!empty($exams)): ?> | |||
| <h4><?php echo _('Examen'); ?></h4> | |||
| <div class="table-overflow table-overflow-popup"> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th><?php echo _('Date'); ?></th> | |||
| <?php foreach($examsAcr as $label): ?> | |||
| <th><?php echo $label; ?></th> | |||
| <?php endforeach; ?> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($exams as $exam): ?> | |||
| <tr> | |||
| <td><?php echo $this->helper->getDateString($exam['Data'], false) ?? ''; ?></td> | |||
| <?php foreach($examsAcr as $label): ?> | |||
| <td><?php echo $exam[$label] ?? ''; ?></td> | |||
| <?php endforeach; ?> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| <?php endif; ?> | |||
| <?php if (!empty($dailyData)): ?> | |||
| <h4><?php echo _('Daily'); ?></h4> | |||
| <div class="row margin-bottom-10"> | |||
| <?php foreach($examStats as $year => $stat): ?> | |||
| <div class="col-lg-4 col-xl-4"><canvas id="daily-chart-values-<?php echo $year; ?>"></canvas></div> | |||
| <?php endforeach; ?> | |||
| </div> | |||
| <div class="table-overflow table-overflow-popup"> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th><?php echo _('Date'); ?></th> | |||
| <th>BMI</th> | |||
| <th>TAmax</th> | |||
| <th>TAmin</th> | |||
| <th>FC</th> | |||
| <th>FR</th> | |||
| <th>TC</th> | |||
| <th><?php echo _('Notes'); ?></th> | |||
| <th><?php echo _('Diagnosis'); ?></th> | |||
| <th><?php echo _('Symptoms'); ?></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($dailyData as $idDiaria => $diariaData): ?> | |||
| <tr> | |||
| <td><?php echo $this->helper->getDateString($diariaData['Diaria']['date_event'], false) ?? ''; ?></td> | |||
| <td><?php /*BMI*/ echo $diariaData['Diaria']['vn2'] ?? ''; ?></td> | |||
| <td><?php echo $diariaData['Diaria']['TAmax'] ?? ''; ?></td> | |||
| <td><?php echo $diariaData['Diaria']['TAmin'] ?? ''; ?></td> | |||
| <td><?php /*FC*/ echo $diariaData['Diaria']['vn10'] ?? ''; ?></td> | |||
| <td><?php /*FR*/ echo $diariaData['Diaria']['vn11'] ?? ''; ?></td> | |||
| <td><?php /*TC*/ echo $diariaData['Diaria']['vn27'] ?? ''; ?></td> | |||
| <td><?php /*Note*/ echo $diariaData['Diaria']['vn27'] ?? ''; ?></td> | |||
| <td> | |||
| <?php if(isset($diariaData['Sintomi']) && is_array($diariaData['Sintomi'])): ?> | |||
| <ul> | |||
| <?php foreach($diariaData['Sintomi'] as $symptoms): ?> | |||
| <li><?php echo $symptoms['Sintomi']; ?></li> | |||
| <?php endforeach; ?> | |||
| </ul> | |||
| <?php endif; ?> | |||
| </td> | |||
| <td> | |||
| <?php if(isset($diariaData['Diagnosi']) && is_array($diariaData['Diagnosi'])): ?> | |||
| <ul> | |||
| <?php foreach($diariaData['Diagnosi'] as $symptoms): ?> | |||
| <li><?php echo $symptoms['Diagnosi']; ?></li> | |||
| <?php endforeach; ?> | |||
| </ul> | |||
| <?php endif; ?> | |||
| </td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| <?php endif; ?> | |||
| <?php if (!empty($TarvHistory)): ?> | |||
| <h4><?php echo _('TARV'); ?></h4> | |||
| <div class="table-overflow table-overflow-popup"> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th><?php echo _('Date'); ?></th> | |||
| <th><?php echo _('Status'); ?></th> | |||
| <th><?php echo _('Reason'); ?></th> | |||
| <th><?php echo _('Line Description'); ?></th> | |||
| <th><?php echo _('Therapy Description'); ?></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($TarvHistory as $tHistory): ?> | |||
| <tr> | |||
| <td><?php echo $this->helper->getDateString($tHistory['DataInizio'], false) ?? ''; ?></td> | |||
| <td><?php echo $tHistory['StatoTerapia'] == 'TARV_SI' ? _('Yes') : _('No'); ?></td> | |||
| <td><?php echo $tHistory['Motivo'] ?? ''; ?></td> | |||
| <td><?php echo $tHistory['Descrizione_Linea'] ?? ''; ?></td> | |||
| <td><?php echo $tHistory['Descrizione_Terapia'] ?? ''; ?></td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| <?php endif; ?> | |||
| <?php if (!empty($ListaFarmaci)): ?> | |||
| <h4><?php echo _('Available drugs'); ?></h4> | |||
| <div class="table-overflow table-overflow-popup"> | |||
| <table class="table table-hover"> | |||
| <thead class="thead-light"> | |||
| <tr> | |||
| <th><?php echo _('Commercial name'); ?></th> | |||
| <th><?php echo _('Active substance name'); ?></th> | |||
| <th><?php echo _('Dosage'); ?></th> | |||
| <th><?php echo _('Quantity'); ?></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <?php foreach($ListaFarmaci as $lFarmaci): ?> | |||
| <tr> | |||
| <td><?php echo $lFarmaci['NomeCommerciale'] ?? ''; ?></td> | |||
| <td><?php echo $lFarmaci['NomeComposto'] ?? ''; ?></td> | |||
| <td><?php echo $lFarmaci['Posologia'] ?? ''; ?></td> | |||
| <td><?php echo $lFarmaci['Quantita'] ?? ''; ?></td> | |||
| </tr> | |||
| <?php endforeach; ?> | |||
| </tbody> | |||
| </table> | |||
| </div> | |||
| <?php endif; ?> | |||
| @@ -0,0 +1,19 @@ | |||
| <div class="modal fade" tabindex="-1" role="dialog" id="modal-dream-dialog"> | |||
| <div class="modal-dialog modal-lg modal-95" role="document"> | |||
| <div class="modal-content"> | |||
| <div class="modal-header"> | |||
| <h5 class="modal-title"><?php echo _('DREAM Information'); ?></h5> | |||
| <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||
| <span aria-hidden="true">×</span> | |||
| </button> | |||
| </div> | |||
| <div class="modal-body"> | |||
| <div class="text-center" id="dialog-loader-dream"><img src="<?php echo $this->layout->getPublicUri(); ?>images/ajaxloader.svg" width="50"></div> | |||
| <div class="modal-body-dream"></div> | |||
| </div> | |||
| <div class="modal-footer"> | |||
| <button type="button" class="btn btn-primary" data-dismiss="modal"><?php echo _('Close'); ?></button> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,47 @@ | |||
| <?php //debug($deseases); ?> | |||
| <?php if(is_array($deseases) && !empty($deseases)): ?> | |||
| <?php | |||
| $checkedAttr = isset($checked) && $checked ? 'checked' : ''; | |||
| $checkbox = '<input type="checkbox" name="data[icd10_desease][value][]" class="desease-id-checkbox" id="desease-id-checkbox-%s" value="%s" data-label="%s" '.$checkedAttr.' %s> '; | |||
| $parentLabel = ''; | |||
| $subDeseaseLabel = ''; | |||
| ?> | |||
| <ul> | |||
| <?php foreach($deseases as $index => $desease): ?> | |||
| <li class="list-no-type margin-bottom-10"> | |||
| <?php if($desease['parent_label'] != ''): ?> | |||
| <?php $parentLabel = $this->helper->cleanText($desease['parent_label']); ?> | |||
| <div class="text-muted"><small><?php echo $parentLabel; ?></small></div> | |||
| <?php endif; ?> | |||
| <?php //if($desease['label'] != ''): ?> | |||
| <label class="label-main <?php echo isset($desease['disabled']) && $desease['disabled'] != '' ? 'text-muted' : ''; ?>" for=""> | |||
| <?php echo !isset($desease['subdeseases']) || empty($desease['subdeseases']) ? vsprintf($checkbox, [$desease['id'], $desease['id'], $parentLabel.' / '.$this->helper->cleanText($desease['label']), isset($desease['disabled']) ? $desease['disabled'] : '']) : ''; ?> | |||
| <?php | |||
| $subDeseaseLabel = $this->helper->cleanText($desease['label']); | |||
| echo $subDeseaseLabel; | |||
| ?> | |||
| </label> | |||
| <?php //endif; ?> | |||
| <?php if(isset($desease['subdeseases']) && is_array($desease['subdeseases']) && !empty($desease['subdeseases'])): ?> | |||
| <ul> | |||
| <?php foreach($desease['subdeseases'] as $deseaseId => $deseaseInfo): ?> | |||
| <li class="list-no-type"> | |||
| <label for="" class="<?php echo $deseaseInfo['disabled'] != '' ? 'text-muted' : ''; ?>"> | |||
| <?php echo vsprintf($checkbox, [$deseaseId, $deseaseId, $subDeseaseLabel.' / '.$deseaseInfo['label'], $deseaseInfo['disabled']]); ?> | |||
| <?php echo $deseaseInfo['label']; ?> | |||
| </label> | |||
| </li> | |||
| <?php endforeach; ?> | |||
| </ul> | |||
| <?php endif; ?> | |||
| </li> | |||
| <?php endforeach; ?> | |||
| </ul> | |||
| <?php endif; ?> | |||