|
|
|
@ -71,7 +71,7 @@ class ListJsonTable extends JasonTable
|
|
|
|
|
if ($this->showActionColumn) {
|
|
|
|
|
$this->html .= "<th>Действия</th></th></tr>";
|
|
|
|
|
}
|
|
|
|
|
if($this->showFiltersRow){
|
|
|
|
|
if ($this->showFiltersRow) {
|
|
|
|
|
$this->getFilters($columnKeys);
|
|
|
|
|
$this->html .= "</thead>";
|
|
|
|
|
}
|
|
|
|
@ -92,8 +92,8 @@ class ListJsonTable extends JasonTable
|
|
|
|
|
}
|
|
|
|
|
foreach ($row as $key => $cell) {
|
|
|
|
|
if ($this->issetColumn($key) and $this->is_fillable($key)) {
|
|
|
|
|
if($this->beforePrintCell) {
|
|
|
|
|
if ($key === "id" and $cell === 0){
|
|
|
|
|
if ($this->beforePrintCell) {
|
|
|
|
|
if ($key === "id" and $cell === 0) {
|
|
|
|
|
$cell = $this->count;
|
|
|
|
|
}
|
|
|
|
|
$cell = $this->getCustomCell($key, $cell);
|
|
|
|
@ -104,7 +104,7 @@ class ListJsonTable extends JasonTable
|
|
|
|
|
$this->getCustomColumns($row["id"] ?? null);
|
|
|
|
|
if ($this->showActionColumn) {
|
|
|
|
|
if (isset($row["id"])) {
|
|
|
|
|
$actions = $this->getActions($row["id"]);
|
|
|
|
|
$actions = $this->getActions($row);
|
|
|
|
|
|
|
|
|
|
$this->html .= "<td>$actions</td></tr>";
|
|
|
|
|
} else {
|
|
|
|
@ -115,7 +115,7 @@ class ListJsonTable extends JasonTable
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addAction(string $actionColumn): void
|
|
|
|
|
public function addAction(string|\Closure $actionColumn): void
|
|
|
|
|
{
|
|
|
|
|
$this->customActionsArray[] = $actionColumn;
|
|
|
|
|
}
|
|
|
|
@ -148,9 +148,9 @@ class ListJsonTable extends JasonTable
|
|
|
|
|
|
|
|
|
|
private function getCurrentFilter(string $column)
|
|
|
|
|
{
|
|
|
|
|
if (is_array($this->beforePrintCell[$column])) {
|
|
|
|
|
if (isset($this->beforePrintCell[$column]) and is_array($this->beforePrintCell[$column])) {
|
|
|
|
|
if (isset($this->beforePrintCell[$column]['filter'])) {
|
|
|
|
|
if (is_array($this->beforePrintCell[$column]['filter'])) {
|
|
|
|
|
if (isset($this->beforePrintCell[$column]['filter']) and is_array($this->beforePrintCell[$column]['filter'])) {
|
|
|
|
|
return $this->beforePrintCell[$column]['filter'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -183,7 +183,6 @@ class ListJsonTable extends JasonTable
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function getColumnKeys(): array
|
|
|
|
|
{
|
|
|
|
|
$columnKeys = [];
|
|
|
|
@ -254,12 +253,16 @@ class ListJsonTable extends JasonTable
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getActions(int $id): string
|
|
|
|
|
private function getActions(array $row): string
|
|
|
|
|
{
|
|
|
|
|
$actions = "";
|
|
|
|
|
foreach ($this->actionsArray as $item) {
|
|
|
|
|
$objItem = new $item($this->baseUrl, $id);
|
|
|
|
|
$actions .= $objItem->fetch();
|
|
|
|
|
if (is_string($item)) {
|
|
|
|
|
$objItem = new $item($this->baseUrl, $row['id']);
|
|
|
|
|
$actions .= $objItem->fetch();
|
|
|
|
|
} else {
|
|
|
|
|
$actions .= $item($row, $this->baseUrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $actions;
|
|
|
|
@ -268,24 +271,22 @@ class ListJsonTable extends JasonTable
|
|
|
|
|
private function getFilters(array $columnKeys): void
|
|
|
|
|
{
|
|
|
|
|
$this->html .= "<tr><form action='$this->baseUrl/search'>";
|
|
|
|
|
foreach ($columnKeys as $key){
|
|
|
|
|
if ($this->issetFilter($key)){
|
|
|
|
|
foreach ($columnKeys as $key) {
|
|
|
|
|
if ($this->issetFilter($key)) {
|
|
|
|
|
$filter = $this->getCurrentFilter($key);
|
|
|
|
|
$params = [
|
|
|
|
|
'param' => $filter['param'] ?? '',
|
|
|
|
|
'name' => $key,
|
|
|
|
|
'value' => $filter['value'] ?? '',
|
|
|
|
|
];
|
|
|
|
|
if ($filter){
|
|
|
|
|
if ($filter) {
|
|
|
|
|
$class = new $filter['class']($params);
|
|
|
|
|
$this->html .= $class->fetch();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
$class = new InputTextFilter($params);
|
|
|
|
|
$this->html .= $class->fetch();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
$this->html .= "<td></td>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|