Weekly sync 2022-07-15
This commit is contained in:
parent
6cbf608b94
commit
872da83978
|
@ -13,6 +13,7 @@ use Exception;
|
||||||
* @license GPLv3
|
* @license GPLv3
|
||||||
* @property-read mixed $changelog
|
* @property-read mixed $changelog
|
||||||
* @property-read string $sqlSelectTemplate
|
* @property-read string $sqlSelectTemplate
|
||||||
|
* @property-read string $sqlCountSelectTemplate
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
@ -35,6 +36,9 @@ class baseClass extends dbStoredBase implements \JsonSerializable, jsonImportabl
|
||||||
# if null - generated automatically
|
# if null - generated automatically
|
||||||
public static $baseSqlSelectTemplate = null;
|
public static $baseSqlSelectTemplate = null;
|
||||||
|
|
||||||
|
# if null - generated automatically
|
||||||
|
public static $baseSqlCountSelectTemplate = null;
|
||||||
|
|
||||||
# primary index field. Default is id
|
# primary index field. Default is id
|
||||||
public static $sqlIdx = "id";
|
public static $sqlIdx = "id";
|
||||||
|
|
||||||
|
@ -45,12 +49,14 @@ class baseClass extends dbStoredBase implements \JsonSerializable, jsonImportabl
|
||||||
public static $deletedFieldName = null;
|
public static $deletedFieldName = null;
|
||||||
|
|
||||||
protected $__sqlSelectTemplate = null;
|
protected $__sqlSelectTemplate = null;
|
||||||
|
protected $__sqlCountSelectTemplate = null;
|
||||||
|
|
||||||
# basic exclude props
|
# basic exclude props
|
||||||
protected static $excludePropsBase = [
|
protected static $excludePropsBase = [
|
||||||
'sql',
|
'sql',
|
||||||
'changelog',
|
'changelog',
|
||||||
'__sqlSelectTemplate',
|
'__sqlSelectTemplate',
|
||||||
|
'__sqlCountSelectTemplate',
|
||||||
'fillPrefix'
|
'fillPrefix'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -152,6 +158,12 @@ class baseClass extends dbStoredBase implements \JsonSerializable, jsonImportabl
|
||||||
$this->__sqlSelectTemplate = $this::$baseSqlSelectTemplate;
|
$this->__sqlSelectTemplate = $this::$baseSqlSelectTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($this::$baseSqlCountSelectTemplate) && ! empty($this::$sqlTable)) {
|
||||||
|
$this->__sqlCountSelectTemplate = "select count(".static::$sqlIdx.") as `count` from `" . $this::$sqlTable . "` as `i`";
|
||||||
|
} else {
|
||||||
|
$this->__sqlCountSelectTemplate = $this::$baseSqlCountSelectTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($sql)) {
|
if (isset($sql)) {
|
||||||
$this->sql = &$sql;
|
$this->sql = &$sql;
|
||||||
}
|
}
|
||||||
|
@ -430,6 +442,9 @@ class baseClass extends dbStoredBase implements \JsonSerializable, jsonImportabl
|
||||||
case "sqlSelectTemplate":
|
case "sqlSelectTemplate":
|
||||||
return $this->__sqlSelectTemplate;
|
return $this->__sqlSelectTemplate;
|
||||||
break;
|
break;
|
||||||
|
case "sqlCountSelectTemplate":
|
||||||
|
return $this->__sqlCountSelectTemplate;
|
||||||
|
break;
|
||||||
case "sql":
|
case "sql":
|
||||||
$this->checkSql();
|
$this->checkSql();
|
||||||
return $this->sql;
|
return $this->sql;
|
||||||
|
@ -545,6 +560,15 @@ class baseClass extends dbStoredBase implements \JsonSerializable, jsonImportabl
|
||||||
if (static::$sqlTable == null) {
|
if (static::$sqlTable == null) {
|
||||||
throw new \Exception("Search not implemented for ".static::class);
|
throw new \Exception("Search not implemented for ".static::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($pattern instanceof request) {
|
||||||
|
@$page=$pattern->requestBody->page;
|
||||||
|
@$pageSize=$pattern->requestBody->pageSize;
|
||||||
|
$options=(array)$pattern->requestBody;
|
||||||
|
|
||||||
|
@$pattern=$pattern->requestBody->pattern;
|
||||||
|
}
|
||||||
|
|
||||||
$ref=new static();
|
$ref=new static();
|
||||||
$sql = $ref->getSql();
|
$sql = $ref->getSql();
|
||||||
|
|
||||||
|
@ -580,9 +604,35 @@ class baseClass extends dbStoredBase implements \JsonSerializable, jsonImportabl
|
||||||
if (static::$deletedFieldName && empty($options["showDeleted"])) {
|
if (static::$deletedFieldName && empty($options["showDeleted"])) {
|
||||||
$where = (empty($where)?"":"(".$where.") AND ")."`".static::$deletedFieldName."` = 0";
|
$where = (empty($where)?"":"(".$where.") AND ")."`".static::$deletedFieldName."` = 0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$xRes=static::xSearch($where, $pattern, $options, $sql);
|
||||||
|
$where = array_key_exists("where",$xRes)?$xRes["where"]:"";
|
||||||
|
$join=array_key_exists("join",$xRes)?$xRes["join"]:"";
|
||||||
|
$groupBy=array_key_exists("group",$xRes)?$xRes["group"]:"";
|
||||||
|
$orderBy=array_key_exists("order",$xRes)?$xRes["order"]:"";
|
||||||
|
|
||||||
|
if (empty($orderBy) && array_key_exists("orderBy", $options)) {
|
||||||
|
@$orderDesc=strtoupper($options["orderDir"])=="DESC"?"DESC":"ASC";
|
||||||
|
$orderBy=common::clearInput($options["orderBy"])." ".$orderDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sqlQueryStringCount=$ref->sqlCountSelectTemplate.(empty($join)?"":" ".$join).(empty($where)?"":" WHERE ".$where).(empty($groupBy)?"":" GROUP BY ".$groupBy);
|
||||||
|
|
||||||
|
$rv=new searchResult();
|
||||||
|
|
||||||
$pageSize=is_numeric($pageSize)?((int)$pageSize):null;
|
$pageSize=is_numeric($pageSize)?((int)$pageSize):null;
|
||||||
$page=is_numeric($page)?((int)$page):null;
|
$page=is_numeric($page)?((int)$page):1;
|
||||||
|
if ($pageSize) {
|
||||||
|
$rc=$sql->quickExec1Line($sqlQueryStringCount);
|
||||||
|
$rv->pages=ceil($rc["count"]/$pageSize);
|
||||||
|
} else {
|
||||||
|
$page=1;
|
||||||
|
$rv->pages=1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rv->pages < $page) { $page=$rv->pages; }
|
||||||
|
$rv->page=$page;
|
||||||
|
|
||||||
if ($pageSize!==null) {
|
if ($pageSize!==null) {
|
||||||
if ($page<1) { $page=1;}
|
if ($page<1) { $page=1;}
|
||||||
|
@ -591,15 +641,9 @@ class baseClass extends dbStoredBase implements \JsonSerializable, jsonImportabl
|
||||||
$limit="";
|
$limit="";
|
||||||
}
|
}
|
||||||
|
|
||||||
$xRes=static::xSearch($where, $pattern, $options, $sql);
|
$sqlQueryString=$ref->sqlSelectTemplate.(empty($join)?"":" ".$join).(empty($where)?"":" WHERE ".$where).(empty($orderBy)?"":" ORDER BY ".$orderBy).(empty($groupBy)?"":" GROUP BY ".$groupBy).(empty($limit)?"":" ".$limit);
|
||||||
$where = array_key_exists("where",$xRes)?$xRes["where"]:"";
|
|
||||||
$join=array_key_exists("join",$xRes)?$xRes["join"]:"";
|
|
||||||
$groupBy=array_key_exists("group",$xRes)?$xRes["group"]:"";
|
|
||||||
|
|
||||||
$sqlQueryString=$ref->sqlSelectTemplate.(empty($join)?"":" ".$join).(empty($where)?"":" WHERE ".$where).(empty($groupBy)?"":" GROUP BY ".$groupBy).(empty($limit)?"":" ".$limit);
|
|
||||||
|
|
||||||
$res=$sql->quickExec($sqlQueryString);
|
$res=$sql->quickExec($sqlQueryString);
|
||||||
$rv=new searchResult();
|
|
||||||
$rv->setIndexByPage($page, $pageSize);
|
$rv->setIndexByPage($page, $pageSize);
|
||||||
while ($row=mysqli_fetch_assoc($res)) {
|
while ($row=mysqli_fetch_assoc($res)) {
|
||||||
$rv->push(new static($row));
|
$rv->push(new static($row));
|
||||||
|
|
|
@ -57,6 +57,7 @@ class request extends baseClass implements noSqlMigration
|
||||||
|
|
||||||
function parce()
|
function parce()
|
||||||
{
|
{
|
||||||
|
global $__foxRequestInstance;
|
||||||
$this->method = (empty($_SERVER["REQUEST_METHOD"]) ? "GET" : $_SERVER["REQUEST_METHOD"]);
|
$this->method = (empty($_SERVER["REQUEST_METHOD"]) ? "GET" : $_SERVER["REQUEST_METHOD"]);
|
||||||
if (array_key_exists("FOX_REWRITE", $_SERVER) && $_SERVER["FOX_REWRITE"] != "yes") {
|
if (array_key_exists("FOX_REWRITE", $_SERVER) && $_SERVER["FOX_REWRITE"] != "yes") {
|
||||||
$prefix = ($_SERVER["CONTEXT_PREFIX"] . "index.php/");
|
$prefix = ($_SERVER["CONTEXT_PREFIX"] . "index.php/");
|
||||||
|
@ -89,6 +90,7 @@ class request extends baseClass implements noSqlMigration
|
||||||
|
|
||||||
$this->module = ((count($req) > 0) ? $req[0] : NULL);
|
$this->module = ((count($req) > 0) ? $req[0] : NULL);
|
||||||
$this->instance=$this->module;
|
$this->instance=$this->module;
|
||||||
|
$__foxRequestInstance=$this->instance;
|
||||||
$this->function = ((count($req) > 1) ? $req[1] : NULL);
|
$this->function = ((count($req) > 1) ? $req[1] : NULL);
|
||||||
|
|
||||||
if (count($req) > 2) {
|
if (count($req) > 2) {
|
||||||
|
@ -146,8 +148,10 @@ class request extends baseClass implements noSqlMigration
|
||||||
|
|
||||||
function shift()
|
function shift()
|
||||||
{
|
{
|
||||||
|
global $__foxRequestInstance;
|
||||||
$this->instance=$this->module;
|
$this->instance=$this->module;
|
||||||
$this->module = $this->function;
|
$this->module = $this->function;
|
||||||
|
$__foxRequestInstance=$this->instance;
|
||||||
$this->function = array_shift($this->parameters);
|
$this->function = array_shift($this->parameters);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace fox;
|
namespace fox;
|
||||||
class searchResult {
|
class searchResult {
|
||||||
public $page=0;
|
public $page=1;
|
||||||
public $pages=0;
|
public $pages=0;
|
||||||
public $result=[];
|
public $result=[];
|
||||||
public $count=0;
|
public $count=0;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -117,8 +117,18 @@ export function empty() {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function createLeftPanel(panels) {
|
export function createLeftPanel(panels, config) {
|
||||||
let ref=($(".t_main #mainframe div.widget_panel_left"));
|
|
||||||
|
if (config==undefined) { config={};}
|
||||||
|
|
||||||
|
|
||||||
|
let ref;
|
||||||
|
if (config.ref) {
|
||||||
|
ref=config.ref;
|
||||||
|
} else {
|
||||||
|
if (!ref) { ref =$(".t_main #mainframe div.widget_panel_left"); }
|
||||||
|
}
|
||||||
|
|
||||||
if (ref.length==0) {
|
if (ref.length==0) {
|
||||||
ref=$("<div>", { class: "widget_panel_left" }).appendTo(".t_main #mainframe");
|
ref=$("<div>", { class: "widget_panel_left" }).appendTo(".t_main #mainframe");
|
||||||
} else {
|
} else {
|
||||||
|
@ -131,18 +141,37 @@ export function createLeftPanel(panels) {
|
||||||
}).appendTo(ref);
|
}).appendTo(ref);
|
||||||
|
|
||||||
|
|
||||||
$.each(panels,function (index,panel) {
|
$.each(panels,function (_index,panel) {
|
||||||
let px = $("<h3>",{text: panel.title, id: panel.id+"_title", append: panel.buttons, style: panel.disabled?"display: none":"" })
|
let xpdiv=$("<div>", { class: "widget lock c_contacts", id: panel.id, text: langPack.core.iface.dataLoading, style: panel.disabled?"display: none":""});
|
||||||
.add($("<div>", { class: "widget lock c_contacts", id: panel.id, text: langPack.core.iface.dataLoading, style: panel.disabled?"display: none":""}));
|
if (panel.attrs) {
|
||||||
|
$.each(panel.attrs, function (key, val) {
|
||||||
|
xpdiv.attr(key,val);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let px = $("<h3>",{text: panel.title, id: panel.id+"_title", append: panel.buttons, style: panel.disabled?"display: none":"" })
|
||||||
|
.add(xpdiv);
|
||||||
px.appendTo(divAccord);
|
px.appendTo(divAccord);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let accConfig={
|
||||||
|
heightStyle: "content",
|
||||||
|
};
|
||||||
|
if (typeof(config.beforeActivate)=="function") {
|
||||||
|
accConfig.beforeActivate=config.beforeActivate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(config.activate)=="function") {
|
||||||
|
accConfig.activate=config.activate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(config.create)=="function") {
|
||||||
|
accConfig.create=config.create;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$("#accordion" ).accordion(accConfig);
|
||||||
|
|
||||||
$( "#accordion" ).accordion({
|
|
||||||
heightStyle: "content",
|
|
||||||
activate: function( event, ui) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function panelBeforeActivate(panel, callback) {
|
function panelBeforeActivate(panel, callback) {
|
||||||
|
@ -518,9 +547,23 @@ export function date2stamp(dateString) {
|
||||||
return (new Date(dateString).getTime()/1000);
|
return (new Date(dateString).getTime()/1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function stamp2isodateq(stamp) {
|
||||||
|
var xdate = new Date(stamp*1000);
|
||||||
|
var rv=xdate.getFullYear().pad(4)+"-"+String((xdate.getMonth()+1).pad(2))+"-"+String(xdate.getDate().pad(2));
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function stamp2isodatens(stamp) {
|
||||||
|
var xdate = new Date(stamp*1000);
|
||||||
|
var rv=stamp2isodateq(stamp)+" "+xdate.getHours().pad(2)+":"+xdate.getMinutes().pad(2);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export function stamp2isodate(stamp) {
|
export function stamp2isodate(stamp) {
|
||||||
var xdate = new Date(stamp*1000);
|
var xdate = new Date(stamp*1000);
|
||||||
var rv=xdate.getFullYear().pad(4)+"-"+String((xdate.getMonth()+1).pad(2))+"-"+String(xdate.getDate().pad(2))+" "+xdate.getHours().pad(2)+":"+xdate.getMinutes().pad(2)+":"+xdate.getSeconds().pad(2);
|
var rv=stamp2isodatens(stamp)+":"+xdate.getSeconds().pad(2);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1108,6 +1151,7 @@ Number.prototype.pad = function(size) {
|
||||||
$(ref).empty();
|
$(ref).empty();
|
||||||
$(ref).prop('foxPager_prefix', options.prefix);
|
$(ref).prop('foxPager_prefix', options.prefix);
|
||||||
$(ref).addClass('foxPager_'+options.prefix);
|
$(ref).addClass('foxPager_'+options.prefix);
|
||||||
|
$(ref).addClass('foxPagerMain');
|
||||||
|
|
||||||
$("<i>",{class: "fas fa-angle-double-left", css: { padding: "0 10 0 10", cursor: 'hand' }}).click(function() {
|
$("<i>",{class: "fas fa-angle-double-left", css: { padding: "0 10 0 10", cursor: 'hand' }}).click(function() {
|
||||||
options.page = parseInt($(ref).prop('foxPager_page'));
|
options.page = parseInt($(ref).prop('foxPager_page'));
|
||||||
|
@ -1118,7 +1162,7 @@ Number.prototype.pad = function(size) {
|
||||||
sessionStorage.setItem(options.prefix+"pager", options.page);
|
sessionStorage.setItem(options.prefix+"pager", options.page);
|
||||||
$(".foxPager_"+options.prefix).find(".foxPager_label").text("Стр: "+options.page+" из "+options.pages);
|
$(".foxPager_"+options.prefix).find(".foxPager_label").text("Стр: "+options.page+" из "+options.pages);
|
||||||
$(".foxPager_"+options.prefix).prop('foxPager_page', options.page);
|
$(".foxPager_"+options.prefix).prop('foxPager_page', options.page);
|
||||||
options.callback();
|
options.callback({prefix: options.prefix, page: options.page});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.appendTo(ref);
|
.appendTo(ref);
|
||||||
|
@ -1132,7 +1176,7 @@ Number.prototype.pad = function(size) {
|
||||||
sessionStorage.setItem(options.prefix+"pager", options.page);
|
sessionStorage.setItem(options.prefix+"pager", options.page);
|
||||||
$(".foxPager_"+options.prefix).find(".foxPager_label").text("Стр: "+options.page+" из "+options.pages);
|
$(".foxPager_"+options.prefix).find(".foxPager_label").text("Стр: "+options.page+" из "+options.pages);
|
||||||
$(".foxPager_"+options.prefix).prop('foxPager_page', options.page);
|
$(".foxPager_"+options.prefix).prop('foxPager_page', options.page);
|
||||||
options.callback();
|
options.callback({prefix: options.prefix, page: options.page});
|
||||||
}
|
}
|
||||||
}).appendTo(ref);
|
}).appendTo(ref);
|
||||||
|
|
||||||
|
@ -1148,7 +1192,7 @@ Number.prototype.pad = function(size) {
|
||||||
sessionStorage.setItem(options.prefix+"pager", options.page);
|
sessionStorage.setItem(options.prefix+"pager", options.page);
|
||||||
$(".foxPager_"+options.prefix).find(".foxPager_label").text("Стр: "+options.page+" из "+options.pages);
|
$(".foxPager_"+options.prefix).find(".foxPager_label").text("Стр: "+options.page+" из "+options.pages);
|
||||||
$(".foxPager_"+options.prefix).prop('foxPager_page', options.page);
|
$(".foxPager_"+options.prefix).prop('foxPager_page', options.page);
|
||||||
options.callback();
|
options.callback({prefix: options.prefix, page: options.page});
|
||||||
}
|
}
|
||||||
}).appendTo(ref);
|
}).appendTo(ref);
|
||||||
$("<i>",{class: "fas fa-angle-double-right", css: { padding: "0 10 0 10", cursor: 'hand' } }).click(function() {
|
$("<i>",{class: "fas fa-angle-double-right", css: { padding: "0 10 0 10", cursor: 'hand' } }).click(function() {
|
||||||
|
@ -1161,7 +1205,7 @@ Number.prototype.pad = function(size) {
|
||||||
sessionStorage.setItem(options.prefix+"pager", options.page);
|
sessionStorage.setItem(options.prefix+"pager", options.page);
|
||||||
$(".foxPager_"+options.prefix).find(".foxPager_label").text("Стр: "+options.page+" из "+options.pages);
|
$(".foxPager_"+options.prefix).find(".foxPager_label").text("Стр: "+options.page+" из "+options.pages);
|
||||||
$(".foxPager_"+options.prefix).prop('foxPager_page', options.page);
|
$(".foxPager_"+options.prefix).prop('foxPager_page', options.page);
|
||||||
options.callback();
|
options.callback({prefix: options.prefix, page: options.page});
|
||||||
}
|
}
|
||||||
}).appendTo(ref);
|
}).appendTo(ref);
|
||||||
|
|
||||||
|
|
|
@ -164,6 +164,16 @@ table.datatable th.icon
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.foxPagerMain i {
|
||||||
|
margin-left: 4px;
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.foxPagerMain span.foxPager_label {
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
div.header
|
div.header
|
||||||
{
|
{
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
|
@ -1718,7 +1728,8 @@ td.hideablealt, th.hideablealt
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.widget_panel_left div.accordion div.widget {
|
/* div.widget_panel_left */
|
||||||
|
div.accordion div.widget {
|
||||||
padding: 10px 0 10px 0;
|
padding: 10px 0 10px 0;
|
||||||
height: auto;
|
height: auto;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
|
|
Loading…
Reference in New Issue