| Server IP : 37.9.174.138 / Your IP : 216.73.216.117 Web Server : Apache System : Linux vps6.backend.sk 6.12.100+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.100-1 (2026-07-30) x86_64 User : ftpuser ( 1001) PHP Version : 8.4.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/backend-accounting.sk/app/modules/extendedDatatable/code/ |
Upload File : |
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace modules\extendedDatatable\code;
/**
* Description of TextColumnController
*
* @author maros
*/
class DateTimeColumnController extends ColumnController {
protected $tagFromConvert;
protected $tagToConvert;
public function __construct(string $column, &$config) {
$this->tagFromConvert = array(
"dnes" => "now",
"zajtra" => "tomorrow",
"vcera" => "yesterday",
"tentoTyzden" => "monday this week",
"buduciTyzden" => "monday next week",
"minulyTyzden" => "monday last week",
"tentoMesiac" => "first day of this month",
"buduciMesiac" => "first day of next month",
"minulyMesiac" => "first day of last month",
"tentoRok" => date("Y") . "-01-01",
"buduciRok" => date("Y", strtotime("+1 year")) . "-01-01",
"minulyRok" => date("Y", strtotime("-1 year")) . "-01-01",
);
$this->tagToConvert = array(
"dnes" => "now",
"zajtra" => "tomorrow",
"vcera" => "yesterday",
"tentoTyzden" => "sunday this week",
"buduciTyzden" => "sunday next week",
"minulyTyzden" => "sunday last week",
"tentoMesiac" => "last day of this month",
"buduciMesiac" => "last day of next month",
"minulyMesiac" => "last day of last month",
"tentoRok" => date("Y") . "-12-31",
"buduciRok" => date("Y", strtotime("+1 year")) . "-12-31",
"minulyRok" => date("Y", strtotime("-1 year")) . "-12-31",
);
parent::__construct($column, $config);
}
public function getTableValue($val) {
return strtotime($val) === false ? $val : date("d.m.Y H:i", strtotime($val));
}
public function renderFilterInput() {
if (!(key_exists(ExtendedDatatable::COLUMN_DISABLE_FILTER, $this->config) && $this->config[ExtendedDatatable::COLUMN_DISABLE_FILTER] === true)) {
$t = \app\classes\Translator::getInstance();
$id = uniqid();
$from = new \PFBC\Element\Textbox("", $this->column . "[0]", array("prepend" => "<div class='input-group'>", "append" => '<span id="' . $id . '" style="cursor: pointer; padding: 5px;" class="input-group-addon input-group-text btn-group"><i data-bs-toggle="dropdown" data-toggle="dropdown" style="color: #000000;" class="fa fa-hashtag dropdown-toggle"></i>'
. '<ul class="dropdown-menu" aria-labelledby="' . $id . '">'
. '<li style="padding: 0px;" onclick="$(this).parent().parent().prev().val(\'#dnes\')" class="dropdown-header"><a style="padding: 2px 5px;" href="javascript:;"><i class="fa fa-hashtag"></i> ' . $t->_get("Dnes") . '</a></li>'
. '<li style="padding: 0px;" onclick="$(this).parent().parent().prev().val(\'#zajtra\')" class="dropdown-header"><a style="padding: 2px 5px;" href="javascript:;"><i class="fa fa-hashtag"></i> ' . $t->_get("Zajtra") . '</a></li>'
. '<li style="padding: 0px;" onclick="$(this).parent().parent().prev().val(\'#vcera\')" class="dropdown-header"><a style="padding: 2px 5px;" href="javascript:;"><i class="fa fa-hashtag"></i> ' . $t->_get("Včera") . '</a></li>'
. '<li role="separator" class="divider"></li>'
. '<li style="padding: 0px;" onclick="$(this).parent().parent().prev().val(\'#tentoTyzden\')" class="dropdown-header"><a style="padding: 2px 5px;" href="javascript:;"><i class="fa fa-hashtag"></i> ' . $t->_get("Tento týždeň") . '</a></li>'
. '<li style="padding: 0px;" onclick="$(this).parent().parent().prev().val(\'#buduciTyzden\')" class="dropdown-header"><a style="padding: 2px 5px;" href="javascript:;"><i class="fa fa-hashtag"></i> ' . $t->_get("Budúci týždeň") . '</a></li>'
. '<li style="padding: 0px;" onclick="$(this).parent().parent().prev().val(\'#minulyTyzden\')" class="dropdown-header"><a style="padding: 2px 5px;" href="javascript:;"><i class="fa fa-hashtag"></i> ' . $t->_get("Minulý týždeň") . '</a></li>'
. '<li role="separator" class="divider"></li>'
. '<li style="padding: 0px;" onclick="$(this).parent().parent().prev().val(\'#tentoMesiac\')" class="dropdown-header"><a style="padding: 2px 5px;" href="javascript:;"><i class="fa fa-hashtag"></i> ' . $t->_get("Tento mesiac") . '</a></li>'
. '<li style="padding: 0px;" onclick="$(this).parent().parent().prev().val(\'#buduciMesiac\')" class="dropdown-header"><a style="padding: 2px 5px;" href="javascript:;"><i class="fa fa-hashtag"></i> ' . $t->_get("Budúci mesiac") . '</a></li>'
. '<li style="padding: 0px;" onclick="$(this).parent().parent().prev().val(\'#minulyMesiac\')" class="dropdown-header"><a style="padding: 2px 5px;" href="javascript:;"><i class="fa fa-hashtag"></i> ' . $t->_get("Minulý mesiac") . '</a></li>'
. '<li role="separator" class="divider"></li>'
. '<li style="padding: 0px;" onclick="$(this).parent().parent().prev().val(\'#tentoRok\')" class="dropdown-header"><a style="padding: 2px 5px;" href="javascript:;"><i class="fa fa-hashtag"></i> ' . $t->_get("Tento rok") . '</a></li>'
. '<li style="padding: 0px;" onclick="$(this).parent().parent().prev().val(\'#buduciRok\')" class="dropdown-header"><a style="padding: 2px 5px;" href="javascript:;"><i class="fa fa-hashtag"></i> ' . $t->_get("Budúci rok") . '</a></li>'
. '<li style="padding: 0px;" onclick="$(this).parent().parent().prev().val(\'#minulyRok\')" class="dropdown-header"><a style="padding: 2px 5px;" href="javascript:;"><i class="fa fa-hashtag"></i> ' . $t->_get("Minulý rok") . '</a></li>'
. '</ul>'
. '</span></div>', "class" => "datepicker form-control input-sm double-filter form-filter", "style" => "height: 30px;"));
$from->render();
}
}
public function getDatatableSqlConditionValue($value) {
$tagConvert = $this->convertTagDate($value);
if ($tagConvert === false) {
$value[1] = $value[0];
} else {
$value = $tagConvert;
}
$value[0] = $value[0] === "" || $value[0] === FALSE || $value[0] === NULL ? NULL : date("Y-m-d H:i:s", strtotime(date("Y-m-d", strtotime($value[0])) . " 00:00:00"));
$value[1] = $value[1] === "" || $value[1] === FALSE || $value[1] === NULL ? NULL : date("Y-m-d H:i:s", strtotime(date("Y-m-d", strtotime($value[1])) . " 23:59:59"));
/* * *********************************========= DEFAULT=========********************************** */
// $value[0] = $value[0] === "" || $value[0] === FALSE || $value[0] === NULL ? NULL : date("Y-m-d H:i:s", strtotime($value[0]));
// $value[1] = $value[1] === "" || $value[1] === FALSE || $value[1] === NULL ? NULL : date("Y-m-d H:i:s", strtotime($value[1]));
return $value;
}
public function getDatatableSqlCondition($sqlVarName, $bindArrayVarName, $value) {
if ($value[0] !== NULL && $value[1] !== NULL) {
return "(" . $sqlVarName . " >=:" . $bindArrayVarName . "0 AND " . $sqlVarName . " <=:" . $bindArrayVarName . "1)";
}
if ($value[0] !== NULL) {
return $sqlVarName . " =:" . $bindArrayVarName . "0";
}
return "";
}
protected function convertTagDate($value, $format = "Y-m-d") {
if ($value[0] === "" || $value[0] === FALSE || $value[0] === NULL || (substr($value[0], 0, 1) !== "#" && substr($value[0], 0, 1) !== "*")) {
return false;
}
$tag = substr($value[0], 1);
if (key_exists($tag, $this->tagFromConvert)) {
return array(
date($format, strtotime($this->tagFromConvert[$tag])),
date($format, strtotime($this->tagToConvert[$tag]))
);
}
return false;
}
}