Initial xentral_oss_20.3.c9ffacf
This commit is contained in:
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
use Xentral\Components\Http\JsonResponse;
|
||||
use Xentral\Components\Http\RedirectResponse;
|
||||
|
||||
function WithGUI($first = false)
|
||||
{
|
||||
if (defined('API_REQUEST') && (bool)API_REQUEST === true) {
|
||||
return false;
|
||||
}
|
||||
if(isset($_GET['withgui']) && $_GET['withgui']){
|
||||
return true;
|
||||
}
|
||||
$module = isset($_GET['module'])?$_GET['module']:'';
|
||||
$action = isset($_GET['action'])?$_GET['action']:'';
|
||||
if($action === 'editable') {
|
||||
return false;
|
||||
}
|
||||
if(!$first && isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest'))
|
||||
{
|
||||
if($action === 'positionen' || strpos($action,'minidetail') === 0){
|
||||
return true;
|
||||
}
|
||||
if($module === 'adresse'){
|
||||
return true;
|
||||
}
|
||||
if($action === 'verkauf'){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return !($module==='ajax' || $module==='api'
|
||||
|| ($module==='welcome' && $action==='css')
|
||||
|| ($module==='report' && $action==='export')
|
||||
|| ($module==='welcome' && $action==='cronjob')
|
||||
|| ($module==='welcome' && $action==='adapterbox')
|
||||
|| ($module==='welcome' && $action==='logo')
|
||||
|| ($module==='artikel' && $action==='ajaxwerte')
|
||||
|| ($module==='artikel' && $action==='thumbnail')
|
||||
|| ($module==='wiki' && $action==='getfile')
|
||||
|| ($module==='benutzer' && $action==='chrights')
|
||||
|| ($module==='callcenter' && $action==='call')
|
||||
|| ($module==='waage' && $action==='gewicht')
|
||||
|| ($module==='welcome' && $action==='poll')
|
||||
|| ($module==='artikel' && $action==='thumbnail')
|
||||
);
|
||||
}
|
||||
|
||||
//include ('phpwf/engine/class.engine.php';
|
||||
if(WithGUI())
|
||||
{
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.formhandler.php';
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.pagebuilder.php';
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.widgetapi.php';
|
||||
include dirname(__DIR__).'/phpwf/widgets/easytable.php';
|
||||
include dirname(__DIR__).'/phpwf/widgets/grouptable.php';
|
||||
include dirname(__DIR__).'/phpwf/widgets/childtable.php';
|
||||
include dirname(__DIR__).'/phpwf/widgets/table.php';
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.picosafelogin.php';
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.wawision_otp.php';
|
||||
include dirname(__DIR__).'/phpwf/htmltags/all.php';
|
||||
include dirname(__DIR__).'/phpwf/types/class.simplelist.php';
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.modulescriptcache.php';
|
||||
}
|
||||
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.templateparser.php';
|
||||
//include dirname(__DIR__).'/phpwf/plugins/class.yui.php';
|
||||
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.acl.php';
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.user.php';
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.page.php';
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.phpwfapi.php';
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.secure.php';
|
||||
//if(is_file(__DIR__.'/www/lib/class.location.php'))@include (dirname(__DIR__).'/www/lib/class.location.php';
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.wfmonitor.php';
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.string.php';
|
||||
include dirname(__DIR__).'/phpwf/plugins/class.objectapi.php';
|
||||
|
||||
/**
|
||||
* @property Config $Conf
|
||||
* @property Secure $Secure
|
||||
* @property TemplateParser $Tpl
|
||||
* @property FormHandler $FormHandler
|
||||
* @property Table $Table
|
||||
* @property WidgetAPI $Widget
|
||||
* @property PageBuilder $PageBuilder
|
||||
* @property Page $Page
|
||||
* @property ObjectAPI $ObjAPI
|
||||
* @property WFMonitor $WFM
|
||||
* @property ModuleScriptCache $ModuleScriptCache
|
||||
* @property YUI $YUI
|
||||
* @property User $User
|
||||
* @property Acl $acl
|
||||
* @property phpWFAPI $WF
|
||||
* @property WawiString $String
|
||||
* @property DB $DB
|
||||
*/
|
||||
class Application extends ApplicationCore
|
||||
{
|
||||
|
||||
public $ActionHandlerList;
|
||||
public $ActionHandlerDefault;
|
||||
public $http;
|
||||
public $caller;
|
||||
public $BuildNavigation;
|
||||
public $PopupJS;
|
||||
public $NoHooks;
|
||||
|
||||
public function __construct($config,$group='')
|
||||
{
|
||||
parent::__construct($config,$group);
|
||||
|
||||
/*if(!isset($_GET['module']) || $_GET['module'] != 'api') {
|
||||
if(!(isset($_GET['module']) && isset($_GET['action']) && isset($_GET['cmd']) && $_GET['module'] == 'welcome' && (($_GET['action'] == 'login' && $_GET['cmd'] == 'checkrfid') || $_GET['action'] == 'cronjob' || $_GET['action'] == 'adapterbox'))) {
|
||||
// @session_cache_limiter('private');
|
||||
//@session_start();
|
||||
}
|
||||
}*/
|
||||
|
||||
$this->Conf= $config;
|
||||
|
||||
//include dirname(__DIR__).'/phpwf/plugins/class.mysql.php';
|
||||
|
||||
if(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on'){
|
||||
$this->http = 'https';
|
||||
}
|
||||
else{
|
||||
$this->http = 'http';
|
||||
}
|
||||
|
||||
//$this->Secure = new Secure($this); // empty $_GET, and $_POST so you
|
||||
// have to need the secure layer always
|
||||
|
||||
|
||||
if(WithGUI()){
|
||||
$this->Tpl = new TemplateParser($this);
|
||||
$this->FormHandler = new FormHandler($this);
|
||||
$this->Table = new Table($this);
|
||||
$this->Widget = new WidgetAPI($this);
|
||||
$this->PageBuilder = new PageBuilder($this);
|
||||
$this->Page = new Page($this);
|
||||
$this->ObjAPI = new ObjectAPI($this);
|
||||
$this->WFM = new WFMonitor($this);
|
||||
$this->ModuleScriptCache = new ModuleScriptCache();
|
||||
}
|
||||
|
||||
//$this->YUI = new YUI($this);
|
||||
//$this->User = new User($this);
|
||||
//$this->acl = new Acl($this);
|
||||
//$this->WF = new phpWFAPI($this);
|
||||
//$this->String = new WawiString();
|
||||
|
||||
$this->BuildNavigation = true;
|
||||
$this->PopupJS = false;
|
||||
|
||||
//$this->DB = new DB($this->Conf->WFdbhost,$this->Conf->WFdbname,$this->Conf->WFdbuser,$this->Conf->WFdbpass,$this);
|
||||
|
||||
if(WithGUI()){
|
||||
$this->Tpl->ReadTemplatesFromPath(__DIR__ . '/widgets/templates/');
|
||||
$this->Tpl->Set('LAYOUTFIXMARKERCLASS', 'layoutfix');
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
//$this->DB->Close();
|
||||
}
|
||||
|
||||
public function ActionHandlerInit($caller)
|
||||
{
|
||||
$this->caller = $caller;
|
||||
}
|
||||
|
||||
public function ActionHandler($command,$function)
|
||||
{
|
||||
$this->ActionHandlerList[$command]=$function;
|
||||
}
|
||||
|
||||
public function DefaultActionHandler($command)
|
||||
{
|
||||
$this->ActionHandlerDefault=$command;
|
||||
}
|
||||
|
||||
public function ActionHandlerListen($app)
|
||||
{
|
||||
$fkt = '';
|
||||
$action = $app->Secure->GetGET('action');
|
||||
$module = $app->Secure->GetGET('module');
|
||||
if(!empty($this->ActionHandlerList)) {
|
||||
$app->erp->addActionHandler($module, $this->ActionHandlerList);
|
||||
}
|
||||
if(!empty($action))
|
||||
{
|
||||
if(!empty($this->ActionHandlerList[$action]))
|
||||
{
|
||||
$fkt = $this->ActionHandlerList[$action];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(empty($this->ActionHandlerDefault) && isset($this->ActionHandlerList['list']))
|
||||
{
|
||||
if(empty($action))
|
||||
{
|
||||
$app->Secure->GET['action'] = 'list';
|
||||
}
|
||||
$this->ActionHandlerDefault = 'list';
|
||||
}
|
||||
if(!empty($this->ActionHandlerDefault))
|
||||
{
|
||||
$fkt = $this->ActionHandlerList[$this->ActionHandlerDefault];
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($fkt)){
|
||||
$callhooks = empty($this->NoHooks) || !in_array($action,$this->NoHooks);
|
||||
if($callhooks){
|
||||
$app->erp->RunHook($module . '_' . $action . '_before');
|
||||
}
|
||||
$response = @$this->caller->$fkt();
|
||||
if($callhooks){
|
||||
$app->erp->RunHook($module . '_' . $action . '_after');
|
||||
}
|
||||
|
||||
if($response instanceof JsonResponse) {
|
||||
$response->send();
|
||||
$this->ExitXentral();
|
||||
}
|
||||
if($response instanceof RedirectResponse) {
|
||||
$response->send();
|
||||
$this->ExitXentral();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function DisableLayoutFix()
|
||||
{
|
||||
if(WithGUI()){
|
||||
$this->Tpl->Set('LAYOUTFIXMARKERCLASS', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,593 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
use Xentral\Core\LegacyConfig\ConfigLoader;
|
||||
|
||||
/**
|
||||
* @property User $User
|
||||
* @property TemplateParser $Tpl
|
||||
* @property Config $Conf
|
||||
* @property YUI $YUI
|
||||
* @property WawiString $String
|
||||
* @property FormHandler $FormHandler
|
||||
* @property Table $Table
|
||||
* @property phpWFAPI $WF
|
||||
* @property WFMonitor $WFM
|
||||
* @property Secure $Secure
|
||||
* @property PHPMailer $mail
|
||||
* @property Help $help
|
||||
* @property StringCleaner $stringcleaner
|
||||
* @property Acl $acl
|
||||
* @property ModuleScriptCache $ModuleScriptCache
|
||||
* @property ObjectAPI $ObjAPI
|
||||
* @property erpAPI $erp
|
||||
* @property Remote $remote
|
||||
* @property Printer $printer
|
||||
* @property Location $Location
|
||||
* @property DatabaseUpgrade $DatabaseUpgrade
|
||||
* @property DB $DB
|
||||
*/
|
||||
class ApplicationCore
|
||||
{
|
||||
protected $getter;
|
||||
protected $gettercustom;
|
||||
protected $props;
|
||||
protected $loadedModules;
|
||||
|
||||
/** @var \Xentral\Core\DependencyInjection\ServiceContainer $Container */
|
||||
public $Container;
|
||||
|
||||
public function __construct($config = null,$group='')
|
||||
{
|
||||
if($config === null)
|
||||
{
|
||||
$this->Conf = ConfigLoader::load();
|
||||
}else{
|
||||
$this->Conf = $config;
|
||||
}
|
||||
|
||||
$registry = include dirname(__DIR__) . '/classes/bootstrap.php';
|
||||
$registry->add('LegacyApplication', $this);
|
||||
$this->Container = $registry->get('ServiceContainer');
|
||||
|
||||
$this->getter = array(
|
||||
'User'=>array('class'=>'User','app'=>true),
|
||||
'Tpl'=>array('class'=>'TemplateParser','app'=>true),
|
||||
'Conf'=>array('class'=>'Config'),
|
||||
'YUI'=>array('class'=>'YUI','app'=>true),
|
||||
'String'=>array('class'=>'WawiString'),
|
||||
'FormHandler'=>array('class'=>'FormHandler','app'=>true),
|
||||
'Table'=>array('class'=>'Table','app'=>true),
|
||||
'WF'=>array('class'=>'phpWFAPI','app'=>true),
|
||||
'WFM'=>array('class'=>'WFMonitor','app'=>true),
|
||||
'Secure'=>array('class'=>'Secure','app'=>true),
|
||||
'mail'=>array('class'=>'PHPMailer','app'=>true),
|
||||
'help'=>array('class'=>'Help','app'=>true),
|
||||
'stringcleaner'=>array('class'=>'StringCleaner','app'=>true),
|
||||
'acl'=>array('class'=>'Acl','app'=>true),
|
||||
'ModuleScriptCache'=>array('class'=>'ModuleScriptCache'),
|
||||
'ObjAPI'=>array('class'=>'ObjectAPI','app'=>true),
|
||||
'FormSecure'=>array('class'=>'FormSecure','app'=>true),
|
||||
'Location'=>array('class'=>'Location','app'=>true),
|
||||
'DatabaseUpgrade'=>array('class'=>'DatabaseUpgrade','app'=>true),
|
||||
'PageBuilder' => ['class' => 'PageBuilder','app'=>true],
|
||||
);
|
||||
$this->gettercustom = array(
|
||||
'erp'=>array(
|
||||
'class'=>'erpAPI',
|
||||
'class_custom'=>'erpAPICustom',
|
||||
'file'=>dirname(__DIR__).'/www/lib/class.erpapi.php',
|
||||
'file_custom'=>dirname(__DIR__).'/www/lib/class.erpapi_custom.php'
|
||||
),
|
||||
'remote'=>array(
|
||||
'class'=>'Remote',
|
||||
'class_custom'=>'RemoteCustom',
|
||||
'file'=>dirname(__DIR__).'/www/lib/class.remote.php',
|
||||
'file_custom'=>dirname(__DIR__).'/www/lib/class.remote_custom.php'
|
||||
),
|
||||
'printer'=>array(
|
||||
'class'=>'Printer',
|
||||
'class_custom'=>'PrinterCustom',
|
||||
'file'=>dirname(__DIR__).'/www/lib/class.printer.php',
|
||||
'file_custom'=>dirname(__DIR__).'/www/lib/class.printer_custom.php'
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDbs()
|
||||
{
|
||||
return ConfigLoader::loadAllDescriptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $status
|
||||
*/
|
||||
public function ExitXentral($status = 0)
|
||||
{
|
||||
if(class_exists('DevTools')){
|
||||
DevTools::exitcustom($this, $status);
|
||||
}
|
||||
|
||||
$dbConnected = !empty($this->DB) && !empty($this->DB->connection);
|
||||
$cronjobToClose = defined('CRONJOBUID') && defined('FROMSTARTER2');
|
||||
if($dbConnected && $cronjobToClose && method_exists($this->erp,'closeAndLogCronjob')) {
|
||||
$this->erp->closeAndLogCronjob(CRONJOBUID, FROMSTARTER2);
|
||||
}
|
||||
|
||||
if($dbConnected){
|
||||
$this->DB->Close();
|
||||
}
|
||||
|
||||
exit($status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($value)
|
||||
{
|
||||
if(isset($this->getter[$value]))
|
||||
{
|
||||
$class = $this->getter[$value]['class'];
|
||||
if($this->getter[$value]['app']){
|
||||
$this->$value = new $class($this);
|
||||
return $this->$value;
|
||||
}
|
||||
$this->$value = new $class();
|
||||
return $this->$value;
|
||||
}
|
||||
if(isset($this->gettercustom[$value]))
|
||||
{
|
||||
if(is_file($this->gettercustom[$value]['file_custom']))
|
||||
{
|
||||
$class = $this->gettercustom[$value]['class_custom'];
|
||||
}else{
|
||||
$class = $this->gettercustom[$value]['class'];
|
||||
}
|
||||
$this->$value = new $class($this);
|
||||
return $this->$value;
|
||||
}
|
||||
if($value === 'DB')
|
||||
{
|
||||
$this->DB = new DB($this->Conf->WFdbhost,$this->Conf->WFdbname,$this->Conf->WFdbuser,$this->Conf->WFdbpass,$this,$this->Conf->WFdbport);
|
||||
return $this->DB;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($value)
|
||||
{
|
||||
if (isset($this->$value)){
|
||||
return true;
|
||||
}
|
||||
|
||||
if($value === 'DB'){
|
||||
return class_exists('DB', true);
|
||||
}
|
||||
|
||||
if(isset($this->getter[$value])){
|
||||
$className = $this->getter[$value]['class'];
|
||||
if(class_exists($className, true)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($this->gettercustom[$value])){
|
||||
$className = $this->gettercustom[$value]['class'];
|
||||
$classNameCustom = $this->gettercustom[$value]['class_custom'];
|
||||
if(class_exists($classNameCustom, true) || class_exists($className, true)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->$name = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param bool $ownInstance
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function loadModule($class, $ownInstance = true) {
|
||||
$class = ucfirst($class);
|
||||
$classcustom = $class.'Custom';
|
||||
if(!$ownInstance && !empty($this->loadedModules[$classcustom])) {
|
||||
return $this->loadedModules[$classcustom];
|
||||
}
|
||||
if(!$ownInstance && !empty($this->loadedModules[$class])) {
|
||||
return $this->loadedModules[$class];
|
||||
}
|
||||
$phpname = strtolower($class);
|
||||
if(!class_exists($class) && @is_file(dirname(__DIR__) . '/www/pages/' . $phpname . '.php')){
|
||||
include_once dirname(__DIR__) . '/www/pages/' . $phpname . '.php';
|
||||
}
|
||||
if(!class_exists($classcustom) && @is_file(dirname(__DIR__) . '/www/pages/' . $phpname . '_custom.php') && class_exists($class)) {
|
||||
include_once dirname(__DIR__) . '/www/pages/' . $phpname . '_custom.php';
|
||||
}
|
||||
|
||||
if(class_exists($classcustom)) {
|
||||
if(method_exists($classcustom, '__construct')) {
|
||||
try {
|
||||
$r = new ReflectionMethod($classcustom, '__construct');
|
||||
$params = $r->getParameters();
|
||||
} catch( Exception $e) {
|
||||
return null;
|
||||
}
|
||||
$anzargs = count($params);
|
||||
if($anzargs > 1) {
|
||||
$obj = new $classcustom($this, true);
|
||||
}
|
||||
}else{
|
||||
$obj = new $classcustom($this, true);
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($obj)) {
|
||||
if($ownInstance) {
|
||||
return $obj;
|
||||
}
|
||||
$this->loadedModules[$classcustom] = $obj;
|
||||
return $this->loadedModules[$classcustom];
|
||||
}
|
||||
if(!class_exists($class)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(method_exists($class, '__construct'))
|
||||
{
|
||||
try {
|
||||
$r = new ReflectionMethod($class, '__construct');
|
||||
$params = $r->getParameters();
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
$anzargs = count($params);
|
||||
if($anzargs > 1) {
|
||||
$obj = new $class($this, true);
|
||||
}
|
||||
}else{
|
||||
$obj = new $class($this, true);
|
||||
}
|
||||
if(empty($obj)) {
|
||||
return null;
|
||||
}
|
||||
if($ownInstance) {
|
||||
return $obj;
|
||||
}
|
||||
$this->loadedModules[$class] = $obj;
|
||||
return $this->loadedModules[$class];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
function getAppList()
|
||||
{
|
||||
/** @var Appstore $obj */
|
||||
$obj = $this->loadModule('appstore');
|
||||
if(!empty($obj) && method_exists($obj,'getAppList'))
|
||||
{
|
||||
return $obj->getAppList();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function IsWindows()
|
||||
{
|
||||
return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
|
||||
}
|
||||
|
||||
public function getTmpFolder()
|
||||
{
|
||||
$userdata = $this->Conf->WFuserdata;
|
||||
|
||||
if ($this->IsWindows()) {
|
||||
$tmp = $userdata."\\tmp\\";
|
||||
} else {
|
||||
$tmp = $userdata."/tmp/";
|
||||
}
|
||||
|
||||
$tmp = str_replace('//','/',$tmp);
|
||||
|
||||
if(!is_dir($tmp) && !mkdir($tmp) && !is_dir($tmp)) {
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public function GetLandLang($isocode)
|
||||
{
|
||||
$flipped = array_flip($this->GetLaender());
|
||||
if(isset($flipped[$isocode])){
|
||||
$land = $flipped[$isocode];
|
||||
}
|
||||
else
|
||||
{
|
||||
$land = 'unkown';
|
||||
}
|
||||
return $land;
|
||||
}
|
||||
public function GetLaender()
|
||||
{
|
||||
$laender = array(
|
||||
'Afghanistan' => 'AF',
|
||||
'Ägypten' => 'EG',
|
||||
'Albanien' => 'AL',
|
||||
'Algerien' => 'DZ',
|
||||
'Andorra' => 'AD',
|
||||
'Angola' => 'AO',
|
||||
'Anguilla' => 'AI',
|
||||
'Antarktis' => 'AQ',
|
||||
'Antigua und Barbuda' => 'AG',
|
||||
'Äquatorial Guinea' => 'GQ',
|
||||
'Argentinien' => 'AR',
|
||||
'Armenien' => 'AM',
|
||||
'Aruba' => 'AW',
|
||||
'Aserbaidschan' => 'AZ',
|
||||
'Äthiopien' => 'ET',
|
||||
'Australien' => 'AU',
|
||||
'Bahamas' => 'BS',
|
||||
'Bahrain' => 'BH',
|
||||
'Bangladesh' => 'BD',
|
||||
'Barbados' => 'BB',
|
||||
'Belgien' => 'BE',
|
||||
'Belize' => 'BZ',
|
||||
'Benin' => 'BJ',
|
||||
'Bermudas' => 'BM',
|
||||
'Bhutan' => 'BT',
|
||||
'Birma' => 'MM',
|
||||
'Bolivien' => 'BO',
|
||||
'Bosnien-Herzegowina' => 'BA',
|
||||
'Botswana' => 'BW',
|
||||
'Bouvet Inseln' => 'BV',
|
||||
'Brasilien' => 'BR',
|
||||
'Britisch-Indischer Ozean' => 'IO',
|
||||
'Brunei' => 'BN',
|
||||
'Bulgarien' => 'BG',
|
||||
'Burkina Faso' => 'BF',
|
||||
'Burundi' => 'BI',
|
||||
'Chile' => 'CL',
|
||||
'China' => 'CN',
|
||||
'Christmas Island' => 'CX',
|
||||
'Cook Inseln' => 'CK',
|
||||
'Costa Rica' => 'CR',
|
||||
'Dänemark' => 'DK',
|
||||
'Deutschland' => 'DE',
|
||||
'Djibuti' => 'DJ',
|
||||
'Dominika' => 'DM',
|
||||
'Dominikanische Republik' => 'DO',
|
||||
'Ecuador' => 'EC',
|
||||
'El Salvador' => 'SV',
|
||||
'Elfenbeinküste' => 'CI',
|
||||
'Eritrea' => 'ER',
|
||||
'Estland' => 'EE',
|
||||
'Falkland Inseln' => 'FK',
|
||||
'Färöer Inseln' => 'FO',
|
||||
'Fidschi' => 'FJ',
|
||||
'Finnland' => 'FI',
|
||||
'Frankreich' => 'FR',
|
||||
'Französisch Guyana' => 'GF',
|
||||
'Französisch Polynesien' => 'PF',
|
||||
'Französisches Süd-Territorium' => 'TF',
|
||||
'Gabun' => 'GA',
|
||||
'Gambia' => 'GM',
|
||||
'Georgien' => 'GE',
|
||||
'Ghana' => 'GH',
|
||||
'Gibraltar' => 'GI',
|
||||
'Grenada' => 'GD',
|
||||
'Griechenland' => 'GR',
|
||||
'Grönland' => 'GL',
|
||||
'Großbritannien' => 'UK',
|
||||
'Großbritannien (UK)' => 'GB',
|
||||
'Guadeloupe' => 'GP',
|
||||
'Guam' => 'GU',
|
||||
'Guatemala' => 'GT',
|
||||
'Guinea' => 'GN',
|
||||
'Guinea Bissau' => 'GW',
|
||||
'Guyana' => 'GY',
|
||||
'Haiti' => 'HT',
|
||||
'Heard und McDonald Islands' => 'HM',
|
||||
'Honduras' => 'HN',
|
||||
'Hong Kong' => 'HK',
|
||||
'Indien' => 'IN',
|
||||
'Indonesien' => 'ID',
|
||||
'Irak' => 'IQ',
|
||||
'Iran' => 'IR',
|
||||
'Irland' => 'IE',
|
||||
'Island' => 'IS',
|
||||
'Israel' => 'IL',
|
||||
'Italien' => 'IT',
|
||||
'Jamaika' => 'JM',
|
||||
'Japan' => 'JP',
|
||||
'Jemen' => 'YE',
|
||||
'Jordanien' => 'JO',
|
||||
'Jugoslawien' => 'YU',
|
||||
'Kaiman Inseln' => 'KY',
|
||||
'Kambodscha' => 'KH',
|
||||
'Kamerun' => 'CM',
|
||||
'Kanada' => 'CA',
|
||||
'Kap Verde' => 'CV',
|
||||
'Kasachstan' => 'KZ',
|
||||
'Kenia' => 'KE',
|
||||
'Kirgisistan' => 'KG',
|
||||
'Kiribati' => 'KI',
|
||||
'Kokosinseln' => 'CC',
|
||||
'Kolumbien' => 'CO',
|
||||
'Komoren' => 'KM',
|
||||
'Kongo' => 'CG',
|
||||
'Kongo, Demokratische Republik' => 'CD',
|
||||
'Kosovo' => 'KO',
|
||||
'Kroatien' => 'HR',
|
||||
'Kuba' => 'CU',
|
||||
'Kuwait' => 'KW',
|
||||
'Laos' => 'LA',
|
||||
'Lesotho' => 'LS',
|
||||
'Lettland' => 'LV',
|
||||
'Libanon' => 'LB',
|
||||
'Liberia' => 'LR',
|
||||
'Libyen' => 'LY',
|
||||
'Liechtenstein' => 'LI',
|
||||
'Litauen' => 'LT',
|
||||
'Luxemburg' => 'LU',
|
||||
'Macao' => 'MO',
|
||||
'Madagaskar' => 'MG',
|
||||
'Malawi' => 'MW',
|
||||
'Malaysia' => 'MY',
|
||||
'Malediven' => 'MV',
|
||||
'Mali' => 'ML',
|
||||
'Malta' => 'MT',
|
||||
'Marianen' => 'MP',
|
||||
'Marokko' => 'MA',
|
||||
'Marshall Inseln' => 'MH',
|
||||
'Martinique' => 'MQ',
|
||||
'Mauretanien' => 'MR',
|
||||
'Mauritius' => 'MU',
|
||||
'Mayotte' => 'YT',
|
||||
'Mazedonien' => 'MK',
|
||||
'Mexiko' => 'MX',
|
||||
'Mikronesien' => 'FM',
|
||||
'Mocambique' => 'MZ',
|
||||
'Moldavien' => 'MD',
|
||||
'Monaco' => 'MC',
|
||||
'Mongolei' => 'MN',
|
||||
'Montenegro' => 'ME',
|
||||
'Montserrat' => 'MS',
|
||||
'Namibia' => 'NA',
|
||||
'Nauru' => 'NR',
|
||||
'Nepal' => 'NP',
|
||||
'Neukaledonien' => 'NC',
|
||||
'Neuseeland' => 'NZ',
|
||||
'Nicaragua' => 'NI',
|
||||
'Niederlande' => 'NL',
|
||||
'Niederländische Antillen' => 'AN',
|
||||
'Niger' => 'NE',
|
||||
'Nigeria' => 'NG',
|
||||
'Niue' => 'NU',
|
||||
'Nord Korea' => 'KP',
|
||||
'Norfolk Inseln' => 'NF',
|
||||
'Norwegen' => 'NO',
|
||||
'Oman' => 'OM',
|
||||
'Österreich' => 'AT',
|
||||
'Pakistan' => 'PK',
|
||||
'Palästina' => 'PS',
|
||||
'Palau' => 'PW',
|
||||
'Panama' => 'PA',
|
||||
'Papua Neuguinea' => 'PG',
|
||||
'Paraguay' => 'PY',
|
||||
'Peru' => 'PE',
|
||||
'Philippinen' => 'PH',
|
||||
'Pitcairn' => 'PN',
|
||||
'Polen' => 'PL',
|
||||
'Portugal' => 'PT',
|
||||
'Puerto Rico' => 'PR',
|
||||
'Qatar' => 'QA',
|
||||
'Reunion' => 'RE',
|
||||
'Ruanda' => 'RW',
|
||||
'Rumänien' => 'RO',
|
||||
'Rußland' => 'RU',
|
||||
'Saint Lucia' => 'LC',
|
||||
'Sambia' => 'ZM',
|
||||
'Samoa' => 'AS',
|
||||
'Samoa' => 'WS',
|
||||
'San Marino' => 'SM',
|
||||
'Sao Tome' => 'ST',
|
||||
'Saudi Arabien' => 'SA',
|
||||
'Schweden' => 'SE',
|
||||
'Schweiz' => 'CH',
|
||||
'Senegal' => 'SN',
|
||||
'Serbien' => 'RS',
|
||||
'Seychellen' => 'SC',
|
||||
'Sierra Leone' => 'SL',
|
||||
'Singapur' => 'SG',
|
||||
'Slowakei -slowakische Republik-' => 'SK',
|
||||
'Slowenien' => 'SI',
|
||||
'Solomon Inseln' => 'SB',
|
||||
'Somalia' => 'SO',
|
||||
'South Georgia, South Sandwich Isl.' => 'GS',
|
||||
'Spanien' => 'ES',
|
||||
'Sri Lanka' => 'LK',
|
||||
'St. Helena' => 'SH',
|
||||
'St. Kitts Nevis Anguilla' => 'KN',
|
||||
'St. Pierre und Miquelon' => 'PM',
|
||||
'St. Vincent' => 'VC',
|
||||
'Süd Korea' => 'KR',
|
||||
'Südafrika' => 'ZA',
|
||||
'Sudan' => 'SD',
|
||||
'Surinam' => 'SR',
|
||||
'Svalbard und Jan Mayen Islands' => 'SJ',
|
||||
'Swasiland' => 'SZ',
|
||||
'Syrien' => 'SY',
|
||||
'Tadschikistan' => 'TJ',
|
||||
'Taiwan' => 'TW',
|
||||
'Tansania' => 'TZ',
|
||||
'Thailand' => 'TH',
|
||||
'Timor' => 'TP',
|
||||
'Togo' => 'TG',
|
||||
'Tokelau' => 'TK',
|
||||
'Tonga' => 'TO',
|
||||
'Trinidad Tobago' => 'TT',
|
||||
'Tschad' => 'TD',
|
||||
'Tschechische Republik' => 'CZ',
|
||||
'Tunesien' => 'TN',
|
||||
'Türkei' => 'TR',
|
||||
'Turkmenistan' => 'TM',
|
||||
'Turks und Kaikos Inseln' => 'TC',
|
||||
'Tuvalu' => 'TV',
|
||||
'Uganda' => 'UG',
|
||||
'Ukraine' => 'UA',
|
||||
'Ungarn' => 'HU',
|
||||
'Uruguay' => 'UY',
|
||||
'Usbekistan' => 'UZ',
|
||||
'Vanuatu' => 'VU',
|
||||
'Vatikan' => 'VA',
|
||||
'Venezuela' => 'VE',
|
||||
'Vereinigte Arabische Emirate' => 'AE',
|
||||
'Vereinigte Staaten von Amerika' => 'US',
|
||||
'Vietnam' => 'VN',
|
||||
'Virgin Island (Brit.)' => 'VG',
|
||||
'Virgin Island (USA)' => 'VI',
|
||||
'Wallis et Futuna' => 'WF',
|
||||
'Weißrußland' => 'BY',
|
||||
'Westsahara' => 'EH',
|
||||
'Zentralafrikanische Republik' => 'CF',
|
||||
'Zimbabwe' => 'ZW',
|
||||
'Zypern' => 'CY'
|
||||
);
|
||||
return $laender;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,430 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
/* Author: Benedikt Sauter, sauter@ibat.de, 2007
|
||||
* Player for PHP Applications
|
||||
*/
|
||||
|
||||
class Player {
|
||||
|
||||
public $DefautTemplates;
|
||||
public $DefautTheme;
|
||||
|
||||
/** @var erpooSystem $app the application object */
|
||||
public $app;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->DefautTemplates="defaulttemplates";
|
||||
$this->DefautTheme="default";
|
||||
}
|
||||
|
||||
function SetDefaultTemplates($path)
|
||||
{
|
||||
}
|
||||
|
||||
function SetDefaultTheme($path)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function BuildNavigation()
|
||||
{
|
||||
if(!WithGUI() || !method_exists($this->app->Page,'CreateNavigation') || !method_exists('erpAPI','Navigation')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->app->Page->CreateNavigation($this->app->erp->Navigation());
|
||||
}
|
||||
|
||||
public function Run($sessionObj)
|
||||
{
|
||||
$this->app = $sessionObj->app;
|
||||
// play application only when layer 2 said that its ok
|
||||
if(!$sessionObj->GetCheck()) {
|
||||
if($sessionObj->reason=='PLEASE_LOGIN')
|
||||
{
|
||||
$module = 'welcome';
|
||||
$action = 'login';
|
||||
$this->app->Secure->GET['module']='welcome';
|
||||
$this->app->Secure->GET['action']='login';
|
||||
}
|
||||
} else {
|
||||
$hasModuleAndAction = !empty($this->app->Secure->GET['module']) && !empty($this->app->Secure->GET['action']);
|
||||
if($hasModuleAndAction &&
|
||||
$this->app->Secure->GET['module'] === 'artikel' && $this->app->Secure->GET['action'] === 'thumbnail') {
|
||||
/** @var Artikel $obj */
|
||||
$obj = $this->app->loadModule('artikel');
|
||||
if(!empty($obj) && method_exists($obj, 'ArtikelThumbnailCache')) {
|
||||
$obj->ArtikelThumbnailCache();
|
||||
}
|
||||
}
|
||||
elseif($hasModuleAndAction &&
|
||||
$this->app->Secure->GET['module'] === 'wiki' && $this->app->Secure->GET['action'] === 'getfile') {
|
||||
/** @var Wiki $obj */
|
||||
$obj = $this->app->loadModule('wiki');
|
||||
if(!empty($obj) && method_exists($obj, 'WikiGetFileCache')) {
|
||||
$obj->WikiGetFileCache();
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->app->Secure->GET['module']) && !empty($this->app->Secure->GET['action']) &&
|
||||
in_array($this->app->Secure->GET['module'],['backup', 'systemtemplates']) && $this->app->Secure->GET['action'] === 'readstatus'){
|
||||
$sessionFile = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . 'session.txt';
|
||||
if(file_exists($sessionFile) && ((string) $bckSession = file_get_contents($sessionFile)) && trim($bckSession) === session_id()){
|
||||
$obj = $this->app->loadModule($this->app->Secure->GET['module']);
|
||||
$obj->ReadStatus();
|
||||
}
|
||||
}
|
||||
|
||||
// Get actual commands from URL
|
||||
$module = $this->app->Secure->GetGET('module','module');
|
||||
$action = $this->app->Secure->GetGET('action','module');
|
||||
if($module =='') {
|
||||
$module = 'welcome';
|
||||
$action = 'main';
|
||||
}
|
||||
|
||||
|
||||
if($this->app->erp->isIoncube() && method_exists($this->app->erp, 'IoncubeProperty')
|
||||
&& WithGUI() && !(($module=='welcome' && $action=='upgrade') || $module=='' || ($module=='welcome' && $action=='start')))
|
||||
{
|
||||
if(method_exists('erpAPI','Ioncube_getMaxUser'))
|
||||
{
|
||||
$maxuser = erpAPI::Ioncube_getMaxUser();
|
||||
}elseif(method_exists($this->app->erp, 'IoncubegetMaxUser'))
|
||||
{
|
||||
$maxuser = $this->app->erp->IoncubegetMaxUser();
|
||||
}else{
|
||||
$maxuser = 0;
|
||||
}
|
||||
if(method_exists('erpAPI','Ioncube_getMaxLightusers'))
|
||||
{
|
||||
$maxlightuser = erpAPI::Ioncube_getMaxLightusers();
|
||||
}else{
|
||||
$maxlightuser = 0;
|
||||
}
|
||||
if($maxuser)
|
||||
{
|
||||
$anzuser2 = 0;
|
||||
if($maxlightuser > 0) {
|
||||
$anzuser2 = (int)$this->app->DB->Select("SELECT count(DISTINCT u.id) FROM `user` u WHERE activ = 1 AND type = 'lightuser' ");
|
||||
$anzuser = (int)$this->app->DB->Select("SELECT count(id) FROM `user` WHERE activ = 1 AND not isnull(hwtoken) AND hwtoken <> 4") - $anzuser2;
|
||||
$anzuserzeiterfassung = (int)$this->app->DB->Select("SELECT count(*) from user where activ = 1 AND hwtoken = 4 AND type != 'lightuser'");
|
||||
}else{
|
||||
$anzuser = $this->app->DB->Select("SELECT count(*) from user where activ = 1 AND hwtoken <> 4 ");
|
||||
$anzuserzeiterfassung = (int)$this->app->DB->Select("SELECT count(*) from user where activ = 1 AND hwtoken = 4");
|
||||
}
|
||||
|
||||
$maxmitarbeiterzeiterfassung = $this->app->erp->ModulVorhanden('mitarbeiterzeiterfassung')?$maxuser:0;
|
||||
if($anzuser > $maxuser
|
||||
|| (
|
||||
($anzuser + $anzuserzeiterfassung + $anzuser2) >
|
||||
$maxmitarbeiterzeiterfassung + $maxuser + $maxlightuser
|
||||
)
|
||||
|| (($anzuser + $anzuserzeiterfassung) > $maxmitarbeiterzeiterfassung + $maxuser)
|
||||
) {
|
||||
if(!(($module == 'welcome' &&
|
||||
($action=='info' || $action == 'start' || $action == 'logout' || $action == '' || $action == 'main')) ||
|
||||
($module == 'einstellungen' && ($action == 'list' || $action == '')) ||
|
||||
$module == 'benutzer'
|
||||
))
|
||||
{
|
||||
if($this->app->erp->RechteVorhanden('benutzer','list'))
|
||||
{
|
||||
$module = 'benutzer';
|
||||
$action = 'list';
|
||||
|
||||
if($maxlightuser > 0){
|
||||
$error = 'Es existieren mehr aktive Benutzer als Ihre Lizenz erlaubt: Benutzer ' . ($anzuser + $anzuser2) . ($maxlightuser > 0 ? ' (davon ' . $anzuser2 . ' Light-User)' : '') . ' von ' . ($maxuser + $maxlightuser) . ($maxlightuser > 0 ? ' (' . $maxlightuser . ' Light-User)' : '');
|
||||
}else{
|
||||
$error = 'Es existieren mehr aktive Benutzer als Ihre Lizenz erlaubt: Benutzer ' . ($anzuser + $anzuser2) . ($maxlightuser > 0 ? ' (davon ' . $anzuser2 . ' Zeiterfassungs-User)' : '') . ' von ' . ($maxuser + $anzuser2) . ($anzuser2 > 0 ? ' (' . $anzuser2 . ' Zeiterfassungs-User)' : '');
|
||||
}
|
||||
$error = '<div class="error">'.$error.'</div>';
|
||||
$this->app->Tpl->Add('MESSAGE', $error);
|
||||
$this->app->Secure->GET['msg'] = $this->app->erp->base64_url_encode($error);
|
||||
}else{
|
||||
$module = 'welcome';
|
||||
$action = 'info';
|
||||
}
|
||||
$this->app->Secure->GET['module'] = $module;
|
||||
$this->app->Secure->GET['action'] = $action;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(method_exists('erpAPI','Ioncube_Property'))
|
||||
{
|
||||
$deaktivateonexp = erpAPI::Ioncube_Property('deaktivateonexp');
|
||||
}else{
|
||||
$deaktivateonexp = $this->app->erp->IoncubeProperty('deaktivateonexp');
|
||||
}
|
||||
if($deaktivateonexp)
|
||||
{
|
||||
if(method_exists('erpAPI','Ioncube_HasExpired'))
|
||||
{
|
||||
$IoncubeHasExpired = erpAPI::Ioncube_HasExpired();
|
||||
}elseif(method_exists($this->app->erp, 'IoncubeHasExpired'))
|
||||
{
|
||||
$IoncubeHasExpired = $this->app->erp->IoncubeHasExpired();
|
||||
}else{
|
||||
$IoncubeHasExpired = false;
|
||||
}
|
||||
}else{
|
||||
$IoncubeHasExpired = false;
|
||||
}
|
||||
if($deaktivateonexp && $IoncubeHasExpired
|
||||
&& !(($module == 'welcome' && $action='logout') || ($module == 'welcome' && $action='start') || ($module == 'welcome' && $action='main'))
|
||||
)
|
||||
{
|
||||
$module = 'welcome';
|
||||
$action = 'info';
|
||||
$this->app->Secure->GET['module'] = $module;
|
||||
$this->app->Secure->GET['action'] = $action;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($action!="list" && $action!="css" && $action!="logo" && $action!="poll" && $module!="ajax" && $module!="protokoll" && $action!="thumbnail"){
|
||||
$this->app->erp->Protokoll();
|
||||
}
|
||||
$id = $this->app->Secure->GetGET('id');
|
||||
$lid = $this->app->Secure->GetGET('lid');
|
||||
if($module !== 'welcome' && $action !== 'poll' && $module !== 'ajax'){
|
||||
if(($module !== 'artikel' || $action !== 'thumbnail')
|
||||
&& ($module !== 'wiki' || $action !== 'getfile')
|
||||
&& $action !== 'editable' && $action !== 'positionen'){
|
||||
$this->app->Laender($module, $action, $id, $lid);
|
||||
}
|
||||
}
|
||||
|
||||
// plugin instanzieren
|
||||
// start module
|
||||
if(file_exists(dirname(__DIR__).'/www/pages/'.$module.'.php')){
|
||||
if(file_exists(dirname(__DIR__).'/www/pages/'.$module.'_custom.php')){
|
||||
include_once dirname(__DIR__).'/www/pages/'.$module.'.php';
|
||||
include_once dirname(__DIR__).'/www/pages/'.$module.'_custom.php';
|
||||
//create dynamical an object
|
||||
$constr = strtoupper($module[0]) . substr($module, 1) . 'Custom';
|
||||
if(class_exists($constr))
|
||||
{
|
||||
$myApp = new $constr($this->app);
|
||||
}else{
|
||||
$constr = strtoupper($module[0]) . substr($module, 1);
|
||||
if(class_exists($constr))
|
||||
{
|
||||
$myApp = new $constr($this->app);
|
||||
}
|
||||
elseif(file_exists(dirname(__DIR__).'/www/pages/'.$module.'.php')){
|
||||
include dirname(__DIR__).'/www/pages/'.$module.'.php';
|
||||
if(class_exists($constr)){
|
||||
$myApp = new $constr($this->app);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(method_exists($constr, 'AllowedVersion') && isset($this->app->User) && $this->app->User && method_exists($this->app->User, 'GetType') && $this->app->User->GetType() == 'admin')
|
||||
{
|
||||
$r2 = new ReflectionMethod($constr, 'AllowedVersion');
|
||||
if($r2->isStatic())
|
||||
{
|
||||
$allowed = $constr::AllowedVersion();
|
||||
include(dirname(__DIR__) . '/version.php');
|
||||
if((isset($allowed['max']) && ((float)$allowed['max'] < (float)$version_revision))
|
||||
||
|
||||
(isset($allowed['versionen']) && (
|
||||
(is_array($allowed['versionen']) && !in_array($version_revision, $allowed['versionen']))
|
||||
|| (!is_array($allowed['versionen']) && $allowed['versionen'] != $version_revision)
|
||||
))
|
||||
)
|
||||
{
|
||||
$title = 'Inkompatibilität festgestellt';
|
||||
$message = 'Die Datei '.$module."_custom.php".' auf Ihrem System, ist nicht für Ihre Version geeignet';
|
||||
|
||||
/** @var \Xentral\Modules\SystemNotification\Gateway\NotificationGateway $notifyGateway */
|
||||
$notifyGateway = $this->app->Container->get('NotificationGateway');
|
||||
if (!$notifyGateway->hasDuplicatedMessage($this->app->User->GetID(), $title, $message)) {
|
||||
/** @var \Xentral\Modules\SystemNotification\Service\NotificationServiceInterface $notifyService */
|
||||
$notifyService = $this->app->Container->get('NotificationService');
|
||||
$notifyService->create($this->app->User->GetID(), 'warning', $title, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
include_once(dirname(__DIR__)."/www/pages/".$module.".php");
|
||||
//create dynamical an object
|
||||
$constr = strtoupper($module[0]) . substr($module, 1);
|
||||
if(class_exists($constr))$myApp = new $constr($this->app);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(file_exists(dirname(__DIR__)."/www/pages/_gen/".$module.".php")){
|
||||
include_once(dirname(__DIR__)."/www/pages/_gen/".$module.".php");
|
||||
//create dynamical an object
|
||||
$constr = "Gen" . strtoupper($module[0]) . substr($module, 1);
|
||||
$myApp = new $constr($this->app);
|
||||
}
|
||||
else {
|
||||
if(file_exists(dirname(__DIR__)."/www/pages/_gen/".$module.".php")){
|
||||
include_once(dirname(__DIR__)."/www/pages/_gen/".$module.".php");
|
||||
//create dynamical an object
|
||||
$constr = "Gen" . strtoupper($module[0]) . substr($module, 1);
|
||||
$myApp = new $constr($this->app);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->app->erp->RunHook('player_run_before_include_js_css');
|
||||
|
||||
/** @deprecated-block-start Wird später über den Installer eingebunden */
|
||||
if (class_exists('Xentral\Modules\SystemNotification\Bootstrap', true)) {
|
||||
$javascript = forward_static_call(['Xentral\\Modules\\SystemNotification\\Bootstrap', 'registerJavascript']);
|
||||
foreach ($javascript as $cacheName => $jsFiles) {
|
||||
$this->app->ModuleScriptCache->IncludeJavascriptFiles($cacheName, $jsFiles);
|
||||
}
|
||||
$stylesheets = forward_static_call(['Xentral\\Modules\\SystemNotification\\Bootstrap', 'registerStylesheets']);
|
||||
foreach ($stylesheets as $cacheName => $cssFiles) {
|
||||
$this->app->ModuleScriptCache->IncludeStylesheetFiles($cacheName, $cssFiles);
|
||||
}
|
||||
}
|
||||
if (class_exists('Xentral\Modules\Wizard\Bootstrap', true)) {
|
||||
$javascript = forward_static_call(['Xentral\\Modules\\Wizard\\Bootstrap', 'registerJavascript']);
|
||||
foreach ($javascript as $cacheName => $jsFiles) {
|
||||
$this->app->ModuleScriptCache->IncludeJavascriptFiles($cacheName, $jsFiles);
|
||||
}
|
||||
$stylesheets = forward_static_call(['Xentral\\Modules\\Wizard\\Bootstrap', 'registerStylesheets']);
|
||||
foreach ($stylesheets as $cacheName => $cssFiles) {
|
||||
$this->app->ModuleScriptCache->IncludeStylesheetFiles($cacheName, $cssFiles);
|
||||
}
|
||||
}
|
||||
if (class_exists('Xentral\\Widgets\\ClickByClickAssistant\\Bootstrap', true)) {
|
||||
$this->app->ModuleScriptCache->IncludeWidgetNew('ClickByClickAssistant');
|
||||
}
|
||||
if (class_exists('Xentral\\Widgets\\SuperSearch\\Bootstrap', true)) {
|
||||
$this->app->ModuleScriptCache->IncludeWidgetNew('SuperSearch');
|
||||
}
|
||||
/** @deprecated-block-end */
|
||||
|
||||
$moduleClassName = strtoupper($module[0]) . substr($module, 1);
|
||||
$this->app->ModuleScriptCache->IncludeModule($moduleClassName);
|
||||
$this->app->Tpl->Add('MODULESTYLESHEET', $this->app->ModuleScriptCache->GetStylesheetHtmlTags());
|
||||
$this->app->Tpl->Add('MODULEJAVASCRIPTHEAD', $this->app->ModuleScriptCache->GetJavascriptHtmlTags('head'));
|
||||
$this->app->Tpl->Add('MODULEJAVASCRIPTBODY', $this->app->ModuleScriptCache->GetJavascriptHtmlTags('body'));
|
||||
|
||||
$permission = true;
|
||||
if(isset($myApp) && method_exists($myApp,'CheckRights'))$permission = $myApp->CheckRights();
|
||||
|
||||
if(!$permission)
|
||||
{
|
||||
if($this->app->User->GetID()<=0)
|
||||
{
|
||||
$this->app->erp->Systemlog("Keine gueltige Benutzer ID erhalten",1);
|
||||
@session_destroy();
|
||||
echo str_replace('BACK',"index.php?module=welcome&action=login",$this->app->Tpl->FinalParse("permissiondenied.tpl"));
|
||||
}
|
||||
else {
|
||||
$this->app->erp->Systemlog("Fehlendes Recht",1);
|
||||
echo str_replace('BACK',isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'',$this->app->Tpl->FinalParse("permissiondenied.tpl"));
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->app->calledWhenAuth($this->app->User->GetType());
|
||||
if($this->app->BuildNavigation==true)
|
||||
$this->BuildNavigation();
|
||||
|
||||
$this->app->endtime = microtime();
|
||||
|
||||
$right = $this->app->Secure->GetGET("right");
|
||||
|
||||
$tmpfirmendatenfkt = 'Firmendaten';
|
||||
if(method_exists($this->app->erp,'TplFirmendaten'))$tmpfirmendatenfkt = 'TplFirmendaten';
|
||||
|
||||
|
||||
$firmenfarbehell = $this->app->erp->$tmpfirmendatenfkt("firmenfarbehell");
|
||||
if($firmenfarbehell =="")
|
||||
$firmenfarbehell = "#3fbac9";
|
||||
$this->app->Tpl->Set('COLOR1',$firmenfarbehell);
|
||||
|
||||
$this->app->calledBeforeFinish();
|
||||
|
||||
$this->app->Tpl->Set('JQUERYMIGRATESRC', './js/jquery/jquery-migrate-3.2.0.min.js');
|
||||
|
||||
$this->app->Tpl->Set('TESTLIZENZABLAUF', '');
|
||||
if($this->app->BuildNavigation==true)
|
||||
{
|
||||
if($right==1)
|
||||
echo $this->app->Tpl->FinalParse('right.tpl');
|
||||
else
|
||||
{
|
||||
if($module==='welcome' && $action==='login'){
|
||||
if(is_file(dirname(__DIR__).'/www/themes/new/templates/loginslider.tpl')) {
|
||||
$this->app->Tpl->Set(
|
||||
'LOGINSLIDER',
|
||||
file_get_contents(dirname(__DIR__).'/www/themes/new/templates/loginslider.tpl')
|
||||
);
|
||||
}
|
||||
else{
|
||||
$this->app->Tpl->Set(
|
||||
'LOGINSLIDER',
|
||||
'<div class="slide" style="background-image: url(\'./themes/new/templates/white-cup-filled-by-coffee.jpg\');">
|
||||
</div>'
|
||||
);
|
||||
}
|
||||
|
||||
$this->app->erp->RunHook('loginpage');
|
||||
echo $this->app->Tpl->FinalParse('loginpage.tpl');
|
||||
}
|
||||
elseif($module==='welcome' && $action==='passwortvergessen'){
|
||||
echo $this->app->Tpl->FinalParse('passwortvergessenpage.tpl');
|
||||
}
|
||||
else {
|
||||
$this->app->erp->addFav();
|
||||
|
||||
$this->app->erp->HelpIconAndTooltip();
|
||||
|
||||
if(
|
||||
($module !== 'welcome'
|
||||
|| ($action !== 'settings' && $action !== 'logout' && $action !== 'login'
|
||||
&& $action !== 'start'&& $action !== 'startseite' && $action !== 'main'
|
||||
)
|
||||
)
|
||||
&& ($isadminadmin = $this->app->acl->IsAdminadmin()))
|
||||
{
|
||||
header('Location: index.php?module=welcome&action=start');
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->app->HeaderBoxen();
|
||||
if($this->app->erp->UserDevice()==='smartphone'){
|
||||
echo $this->app->Tpl->FinalParse('page_smartphone.tpl');
|
||||
}
|
||||
else{
|
||||
|
||||
$this->app->Tpl->Set('VUEJS', 'vue.min.js');
|
||||
$this->app->erp->RunHook('before_final_parse_page');
|
||||
echo $this->app->Tpl->FinalParse('page.tpl');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if($this->app->PopupJS){
|
||||
echo $this->app->Tpl->FinalParse('popup_js.tpl');
|
||||
}
|
||||
else{
|
||||
echo $this->app->Tpl->FinalParse('popup.tpl');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
class Session
|
||||
{
|
||||
|
||||
// set check to true when user have permissions
|
||||
private $check = false;
|
||||
|
||||
public $module;
|
||||
public $action;
|
||||
/** @var Application $app */
|
||||
public $app;
|
||||
public $reason;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Application $appObj
|
||||
*/
|
||||
public function Check($appObj)
|
||||
{
|
||||
$this->app = $appObj;
|
||||
$this->check = true;
|
||||
|
||||
$db = $this->app->Secure->GetPOST('db','nothtml','',true);
|
||||
$dbselect = $this->app->Secure->GetPOST('dbselect','nothtml','',true);
|
||||
if(!empty($db) && $dbselect === 'true')
|
||||
{
|
||||
$_COOKIE['DBSELECTED'] = $db;
|
||||
setcookie('DBSELECTED', $db);
|
||||
}
|
||||
$hasModuleAction = !empty($this->app->Secure->GET['module']) && !empty($this->app->Secure->GET['action']);
|
||||
if ($hasModuleAction &&
|
||||
(
|
||||
($this->app->Secure->GET['module'] === 'artikel' && $this->app->Secure->GET['action'] === 'thumbnail')
|
||||
|| ($this->app->Secure->GET['module'] === 'wiki' && $this->app->Secure->GET['action'] === 'getfile')
|
||||
)
|
||||
) {
|
||||
if (!$this->app->User->getUserByCache()) {
|
||||
$this->check = false;
|
||||
$this->reason = 'PLEASE_LOGIN';
|
||||
}
|
||||
else {
|
||||
$this->check = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($this->app->Secure->GET['module']) && !empty($this->app->Secure->GET['action']) &&
|
||||
in_array($this->app->Secure->GET['module'],['backup', 'systemtemplates']) && $this->app->Secure->GET['action'] === 'readstatus'){
|
||||
$sessionFile = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . 'session.txt';
|
||||
if(file_exists($sessionFile) && ((string) $bckSession = file_get_contents($sessionFile)) && trim($bckSession) === session_id()){
|
||||
$this->check = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->module = $this->app->Secure->GetGET('module');
|
||||
$this->action = $this->app->Secure->GetGET('action');
|
||||
|
||||
/*
|
||||
* Skip the permissions check on all listed actions.
|
||||
* The module name is required as key, the action(s)
|
||||
* can be either a single string or a list of strings.
|
||||
*
|
||||
* e.G.:
|
||||
* valid whitelistings are:
|
||||
*
|
||||
* 'awesomemodule' => 'worldchangingaction'
|
||||
* or:
|
||||
* 'awesomemodule' => ['worldchangingaction']
|
||||
* or:
|
||||
* 'awesomemodule' => ['worldchangingaction', 'anotherbeautifulaction']
|
||||
*/
|
||||
$whitelist = [
|
||||
'snapaddy' => 'single',
|
||||
];
|
||||
|
||||
if (array_key_exists($this->module, $whitelist)) {
|
||||
$actions = $whitelist[$this->module];
|
||||
// convert to array if not, so multiple actions
|
||||
$actions = (array)$actions;
|
||||
|
||||
if (in_array($this->action, $actions)) {
|
||||
/*
|
||||
* The module and it's action are listed in
|
||||
* $whitelist, so make sure, the check flag
|
||||
* is set to true and return.
|
||||
*/
|
||||
$this->check = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->app->acl->CheckTimeOut()
|
||||
&& $this->module !== 'api'
|
||||
&& !($this->module === 'kalender' && $this->action === 'ics')
|
||||
&& !($this->module === 'welcome' && $this->action === 'cronjob')
|
||||
&& !($this->module === 'welcome' && $this->action === 'cronjob2')
|
||||
&& !($this->module === 'welcome' && $this->action === 'adapterbox')
|
||||
&& !($this->module === 'onlineshops' && $this->action === 'getapi')
|
||||
&& !($this->module === 'callcenter' && $this->action === 'call')
|
||||
&& !($this->module === 'welcome' && $this->action === 'poll')
|
||||
&& !($this->module === 'welcome' && $this->action === 'passwortvergessen')
|
||||
&& !($this->module === 'report' && $this->action === 'export')
|
||||
&& !($this->module === 'googleapi' && $this->action === 'redirect')
|
||||
) {
|
||||
$this->check = false;
|
||||
$this->reason = 'PLEASE_LOGIN';
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->module === 'api') {
|
||||
$this->check = true;
|
||||
header('Access-Control-Allow-Origin: *'); // Externe Domains duerfen auf API zugreifen
|
||||
return;
|
||||
}
|
||||
if ($this->module === 'kalender' && $this->action === 'ics'){
|
||||
$this->check = true;
|
||||
return;
|
||||
}
|
||||
if ($this->module === 'welcome'
|
||||
&& in_array($this->action,
|
||||
[
|
||||
'cronjob',
|
||||
'cronjob2',
|
||||
'passwortvergessen',
|
||||
'adapterbox',
|
||||
'poll',
|
||||
])
|
||||
){
|
||||
$this->check = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->module === 'appstore' && $this->action === 'list') {
|
||||
$this->check = true;
|
||||
return;
|
||||
}
|
||||
if ($this->module === 'onlineshops' && $this->action === 'getapi') {
|
||||
$this->check = true;
|
||||
return;
|
||||
}
|
||||
if ($this->module === 'report' && $this->action === 'export') {
|
||||
$this->check = true;
|
||||
return;
|
||||
}
|
||||
if ($this->module === 'googleapi' && $this->action === 'redirect') {
|
||||
$this->check = true;
|
||||
return;
|
||||
}
|
||||
if ($this->module === 'callcenter' && $this->action === 'call'){
|
||||
$this->check = true;
|
||||
return;
|
||||
}
|
||||
if (
|
||||
$this->app->acl->Check(//benutzer ist schon mal erfolgreich angemeldet
|
||||
$this->app->User->GetType(),
|
||||
$this->module, $this->action,
|
||||
$this->app->User->GetID()
|
||||
)
|
||||
) {
|
||||
$this->check = true;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->reason = 'NO_PERMISSIONS';
|
||||
$this->check = false;
|
||||
}
|
||||
|
||||
public function GetCheck()
|
||||
{
|
||||
return $this->check;
|
||||
}
|
||||
|
||||
public function UserSessionCheck()
|
||||
{
|
||||
$this->check = false;
|
||||
$this->reason = 'PLEASE_LOGIN';
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<table border="0" celpadding="0" cellspacing="4" width="100%"
|
||||
height="100%" align="center">
|
||||
<tr height="100%">
|
||||
<td valign="top">
|
||||
<form action="[ACTION]" method="post"><br>
|
||||
<br>
|
||||
<table align="center">
|
||||
<tr>
|
||||
<td colspan="2" height="20"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Benutzer:</td>
|
||||
<td><input name="username" type="text" size="30"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Passwort:</td>
|
||||
<td><input name="password" type="password" size="30"></td>
|
||||
</tr>
|
||||
<tr align="center">
|
||||
<td></td>
|
||||
<td><input type="submit" value="Anmelden"> <input type="reset"
|
||||
name="Submit" value="Zurücksetzen"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<div align="center">
|
||||
<p> [LOGINMSG]</p>
|
||||
<p style="color:red">[LOGINERRORMSG]</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -0,0 +1 @@
|
||||
<h2>Sie haben nicht die benötigten Rechte diese Seite anzuschauen.</h2>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
include("class.form.php");
|
||||
include("class.table.php");
|
||||
?>
|
||||
@@ -0,0 +1,361 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
/// represent a HTML Form structure
|
||||
class HTMLForm
|
||||
{
|
||||
var $action;
|
||||
var $method;
|
||||
var $name;
|
||||
var $id;
|
||||
|
||||
var $FieldList;
|
||||
|
||||
function __construct($action="",$method="post",$name="",$id="")
|
||||
{
|
||||
$this->action=$action;
|
||||
$this->name=$name;
|
||||
$this->method=$method;
|
||||
$this->id=$id;
|
||||
}
|
||||
|
||||
function Set($value)
|
||||
{
|
||||
}
|
||||
|
||||
function Get()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function GetClose()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class HTMLTextarea
|
||||
{
|
||||
var $name;
|
||||
var $rows;
|
||||
var $value;
|
||||
var $cols;
|
||||
var $id="";
|
||||
var $readonly="";
|
||||
var $disabled="";
|
||||
var $class;
|
||||
|
||||
function __construct($name,$rows,$cols,$defvalue="",$id="",$readonly="",$disabled="",$class="")
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->rows = $rows;
|
||||
$this->cols = $cols;
|
||||
$this->class = $class;
|
||||
$this->value = $defvalue;
|
||||
$this->id = $id;
|
||||
|
||||
if($id=="")
|
||||
$this->id = $name;
|
||||
|
||||
$this->readonly = $readonly;
|
||||
$this->disabled = $disabled;
|
||||
}
|
||||
|
||||
function Get()
|
||||
{
|
||||
// TEMP ACHTUNG HIER IST MIST!!!
|
||||
$value = $this->value;
|
||||
/*
|
||||
if(!defined('WFHTMLTextareabr') || !WFHTMLTextareabr)$value = preg_replace('/<br\\s*?\/??>/i', "\n", $value);
|
||||
*/
|
||||
// $value = str_replace("\\r\\n","\n",$value);
|
||||
|
||||
$html = "<textarea rows=\"{$this->rows}\" id=\"{$this->id}\" class=\"{$this->class}\"
|
||||
name=\"{$this->name}\" cols=\"{$this->cols}\"
|
||||
{$this->readonly} {$this->disabled} [COMMONREADONLYINPUT]>$value</textarea>";
|
||||
return $html;
|
||||
}
|
||||
|
||||
function GetClose()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// fuer Datenfelder die mit in die Datenbank o.ae. kommen sollen, aber nicht durch den
|
||||
/// user in irgendeiner art und weise gesehen und manipuliert werden koennen
|
||||
|
||||
class BlindField
|
||||
{
|
||||
var $name;
|
||||
var $value;
|
||||
|
||||
function __construct($name,$value)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
}
|
||||
function Get(){}
|
||||
function GetClose(){}
|
||||
}
|
||||
|
||||
|
||||
class HTMLInput
|
||||
{
|
||||
var $name;
|
||||
var $type;
|
||||
var $value;
|
||||
var $dbvalue;
|
||||
var $checkvalue;
|
||||
var $onchange;
|
||||
var $onclick;
|
||||
var $defvalue;
|
||||
var $size;
|
||||
var $maxlength;
|
||||
var $tabindex;
|
||||
var $id="";
|
||||
var $readonly="";
|
||||
var $disabled="";
|
||||
var $placeholder="";
|
||||
var $class;
|
||||
var $checked;
|
||||
|
||||
function __construct($name,$type,$value,$size="",$maxlength="",$id="",$defvalue="",$checked="",$readonly="",$disabled="",$class="",$onclick="",$tabindex="",$placeholder="")
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->type = $type;
|
||||
$this->value = $value;
|
||||
$this->size = $size;
|
||||
$this->maxlength = $maxlength;
|
||||
$this->id = $id;
|
||||
$this->readonly = $readonly;
|
||||
$this->disabled = $disabled;
|
||||
$this->class=$class;
|
||||
$this->checked=$checked;
|
||||
$this->tabindex=$tabindex;
|
||||
$this->placeholder=$placeholder;
|
||||
$this->defvalue=$defvalue; // if value is empty use this
|
||||
$this->onclick=$onclick;
|
||||
|
||||
}
|
||||
|
||||
function Get()
|
||||
{
|
||||
if($this->id=="") $this->id = $this->name;
|
||||
|
||||
switch($this->type)
|
||||
{
|
||||
case "text":
|
||||
$html = "<input type=\"{$this->type}\" id=\"{$this->id}\" class=\"{$this->class}\" tabindex=\"{$this->tabindex}\"
|
||||
name=\"{$this->name}\" value=\"".preg_replace("/\"/",""",$this->value)."\" size=\"{$this->size}\" placeholder=\"{$this->placeholder}\"
|
||||
maxlength=\"{$this->maxlength}\" {$this->readonly} {$this->disabled} [COMMONREADONLYINPUT]>";
|
||||
break;
|
||||
case "password":
|
||||
$html = "<input type=\"{$this->type}\" id=\"{$this->id}\" class=\"{$this->class}\" tabindex=\"{$this->tabindex}\"
|
||||
name=\"{$this->name}\" value=\"{$this->value}\" size=\"{$this->size}\"
|
||||
maxlength=\"{$this->maxlength}\" {$this->readonly} {$this->disabled} [COMMONREADONLYINPUT]>";
|
||||
break;
|
||||
case "checkbox":
|
||||
$html = "<input type=\"{$this->type}\" id=\"{$this->id}\" class=\"{$this->class}\" tabindex=\"{$this->tabindex}\"
|
||||
name=\"{$this->name}\" value=\"{$this->value}\" {$this->checked} onchange=\"{$this->onchange}\" onclick=\"{$this->onclick}\"
|
||||
{$this->readonly} {$this->disabled} [COMMONREADONLYINPUT]>";
|
||||
break;
|
||||
case "radio":
|
||||
|
||||
if($this->value==$this->defvalue) $this->checked="checked";
|
||||
|
||||
$tmpname = str_replace('_'.$this->defvalue,'',$this->name);
|
||||
|
||||
$html = "<input type=\"{$this->type}\" id=\"{$this->id}\" class=\"{$this->class}\" tabindex=\"{$this->tabindex}\"
|
||||
name=\"{$tmpname}\" value=\"{$this->defvalue}\" {$this->checked} onchange=\"{$this->onchange}\"
|
||||
{$this->readonly} {$this->disabled} [COMMONREADONLYINPUT]>";
|
||||
break;
|
||||
case "submit":
|
||||
$html = "<input type=\"{$this->type}\" id=\"{$this->id}\" class=\"{$this->class}\"
|
||||
name=\"{$this->name}\" value=\"{$this->value}\"
|
||||
{$this->readonly} {$this->disabled}>";
|
||||
break;
|
||||
case "hidden":
|
||||
$html = "<input type=\"{$this->type}\" id=\"{$this->id}\" class=\"{$this->class}\"
|
||||
name=\"{$this->name}\" value=\"{$this->value}\" size=\"{$this->size}\"
|
||||
maxlength=\"{$this->maxlength}\" {$this->readonly} {$this->disabled}>";
|
||||
break;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function GetClose()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class HTMLCheckbox extends HTMLInput
|
||||
{
|
||||
function __construct($name,$value,$defvalue,$checkvalue="",$onclick="",$tabindex="")
|
||||
{
|
||||
|
||||
if($checkvalue!="")
|
||||
$this->checkvalue=$checkvalue;
|
||||
else
|
||||
$this->checkvalue=$value;
|
||||
|
||||
$this->name = $name;
|
||||
$this->type = "checkbox";
|
||||
$this->checkradiovalue = isset($okvalue)?$okvalue:null;
|
||||
$this->defvalue = $defvalue;
|
||||
$this->value = $value;
|
||||
$this->onclick= $onclick;
|
||||
$this->tabindex= $tabindex;
|
||||
$this->orgvalue = $value;
|
||||
}
|
||||
|
||||
|
||||
function Get()
|
||||
{
|
||||
if(($this->value=="" && $this->defvalue==$this->checkvalue)) {
|
||||
}
|
||||
if($this->checkvalue==$this->value) {
|
||||
$this->checked="checked";
|
||||
}
|
||||
if($this->value=="" && $this->defvalue!=$this->checkvalue)
|
||||
$this->checked="";
|
||||
|
||||
$this->value = $this->checkvalue;
|
||||
//$this->value=1;
|
||||
return parent::Get();
|
||||
}
|
||||
|
||||
function GetClose()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class HTMLSelect
|
||||
{
|
||||
var $name;
|
||||
var $size;
|
||||
var $id;
|
||||
var $readonly;
|
||||
var $disabled;
|
||||
|
||||
var $options;
|
||||
var $onchange;
|
||||
var $selected;
|
||||
var $tabindex;
|
||||
|
||||
var $class;
|
||||
|
||||
function __construct($name,$size,$id="",$readonly=false,$disabled=false,$tabindex="")
|
||||
{
|
||||
$this->name=$name;
|
||||
$this->size=$size;
|
||||
$this->id=$id;
|
||||
$this->readonly=$readonly;
|
||||
$this->disabled=$disabled;
|
||||
$this->tabindex=$tabindex;
|
||||
$this->class="";
|
||||
|
||||
if($id=="")
|
||||
$this->id = $name;
|
||||
}
|
||||
|
||||
function AddOption($option,$value)
|
||||
{
|
||||
$this->options[] = array($option,$value);
|
||||
}
|
||||
|
||||
function AddOptionsDimensionalArray($values)
|
||||
{
|
||||
foreach($values as $key=>$value)
|
||||
{
|
||||
$this->options[] = array($value[wert],$value[schluessel]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function AddOptionsAsocSimpleArray($values)
|
||||
{
|
||||
foreach($values as $key=>$value)
|
||||
$this->options[] = array($value,$key);
|
||||
}
|
||||
|
||||
function AddOptionsSimpleArray($values)
|
||||
{
|
||||
if(is_array($values))
|
||||
{
|
||||
foreach($values as $key=>$value)
|
||||
{
|
||||
if(!is_numeric($key))
|
||||
$this->options[] = array($value,$key);
|
||||
else
|
||||
$this->options[] = array($value,$value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function AddOptions($values)
|
||||
{
|
||||
$number=0;
|
||||
if(count($values)>0)
|
||||
{
|
||||
foreach($values as $key=>$row)
|
||||
foreach($row as $value)
|
||||
{
|
||||
if($number==0){
|
||||
$option=$value;
|
||||
$number=1;
|
||||
}
|
||||
else {
|
||||
$this->options[] = array($option,$value);
|
||||
$number=0;
|
||||
$option="";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function Get()
|
||||
{
|
||||
$html = "<select name=\"{$this->name}\" size=\"{$this->size}\" tabindex=\"{$this->tabindex}\"
|
||||
id=\"{$this->id}\" class=\"{$this->class}\" onchange=\"{$this->onchange}\" [COMMONREADONLYSELECT]>";
|
||||
|
||||
if($this->options && count($this->options)>0)
|
||||
{
|
||||
foreach($this->options as $key=>$value)
|
||||
{
|
||||
if($this->value==$value[1])
|
||||
$html .="<option value=\"{$value[1]}\" selected>{$value[0]}</option>";
|
||||
else
|
||||
$html .="<option value=\"{$value[1]}\">{$value[0]}</option>";
|
||||
}
|
||||
|
||||
}
|
||||
$html .="</select>";
|
||||
return $html;
|
||||
}
|
||||
|
||||
function GetClose()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,407 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
class HTMLTable
|
||||
{
|
||||
var $border;
|
||||
var $cellpadding;
|
||||
var $cellspacing;
|
||||
var $width;
|
||||
var $height;
|
||||
|
||||
var $color1;
|
||||
var $color2;
|
||||
|
||||
var $nextcolor=0;
|
||||
|
||||
var $xpointer; // start at 0
|
||||
var $ypointer; // start at 0
|
||||
|
||||
var $Table;
|
||||
|
||||
var $hidecols;
|
||||
var $headings;
|
||||
var $width_headings;
|
||||
var $widths;
|
||||
|
||||
var $CompleteRow;
|
||||
var $CompleteCol;
|
||||
|
||||
var $cellclass;
|
||||
var $cellonclick;
|
||||
var $celltitle;
|
||||
var $nowrap;
|
||||
var $customAttributes;
|
||||
|
||||
/// Representiert eine HTML Tabelle
|
||||
function __construct($border="1",$width="",$height="",$cellpadding="3",$cellspacing="3",$style="")
|
||||
{
|
||||
$this->border=$border;
|
||||
$this->cellpadding=$cellpadding;
|
||||
$this->cellspacing=$cellspacing;
|
||||
$this->width=$width;
|
||||
$this->height=$height;
|
||||
$this->style=$style;
|
||||
$this->nowrap="nowrap";
|
||||
}
|
||||
|
||||
/// komplette spalte einer tabelle mit neuem inhalt ersetzten, der alte ist in %value%
|
||||
function ReplaceCol($colnumber,$newtext)
|
||||
{
|
||||
reset($this->Table);
|
||||
$first =1;
|
||||
$rowcounter=0;
|
||||
foreach($this->Table as $coln => $row)
|
||||
{
|
||||
if($first==1)
|
||||
{
|
||||
$first=0;
|
||||
continue 1;
|
||||
}
|
||||
foreach($row as $col => $val)
|
||||
{
|
||||
if( ($col+1)==$colnumber )
|
||||
{
|
||||
$old = $this->Table[$coln][$col];
|
||||
$new=str_replace('%value%',$old,$newtext);
|
||||
if(count($this->Table[$coln])>1)
|
||||
$new=str_replace('%field1%',$this->Table[$coln][1],$new);
|
||||
$ccoln = !empty($this->Table[$coln])?count($this->Table[$coln]):0;
|
||||
for($i=1; $i <= $ccoln; $i++)
|
||||
$new=str_replace("%$i%",$this->Table[$coln][$i-1],$new);
|
||||
|
||||
$new=str_replace('%pos%',$coln,$new);
|
||||
$new=str_replace('%togl%',$coln%2,$new);
|
||||
if(is_numeric($this->Table[$coln][$col]))
|
||||
$this->Table[$coln][$col]=$new;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function HideCol($number)
|
||||
{
|
||||
$this->hidecols[$number]=$number;
|
||||
}
|
||||
|
||||
/// erzwingt den Cursor in eine neue Zeile
|
||||
function NewRow()
|
||||
{
|
||||
if(!$this->Table || count($this->Table)==0)
|
||||
{
|
||||
$this->xpointer=0;
|
||||
$this->ypointer=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->xpointer=0;
|
||||
$this->ypointer++;
|
||||
}
|
||||
}
|
||||
/// fuegt eine komplette Zeile an der aktuellen Zeigerpostion ein
|
||||
function AddRowAsHeading($cols)
|
||||
{
|
||||
$this->NewRow();
|
||||
$cell=0;
|
||||
foreach($cols as $value)
|
||||
{
|
||||
if(isset($this->width_headings[$cell]))
|
||||
$this->AddCol("<div style=\"font-weight:bold;width:".$this->width_headings[$cell].";\">".ucfirst($value)."</div>","",$this->width_headings[$cell]);
|
||||
else
|
||||
$this->AddCol("<b>".ucfirst($value)."</b>");
|
||||
|
||||
$cell++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// fuegt eine komplette Zeile an der aktuellen Zeigerpostion ein
|
||||
function AddRow($cols)
|
||||
{
|
||||
$this->NewRow();
|
||||
foreach($cols as $value)
|
||||
$this->AddCol($value);
|
||||
}
|
||||
|
||||
|
||||
function AddField($field)
|
||||
{
|
||||
$rows = count($field);
|
||||
for($i=0;$i<$rows;$i++)
|
||||
{
|
||||
$this->NewRow();
|
||||
if(count($field[$i])>0)
|
||||
{
|
||||
foreach($field[$i] as $key=>$value)
|
||||
{
|
||||
$this->AddCol(nl2br($value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// fuegt neue eine neue Tabellenzelle an aktuellen Zeiger ein
|
||||
function AddCol($value="",$align="",$width="", $colspan = "")
|
||||
{
|
||||
$this->Table[$this->ypointer][$this->xpointer]=$value;
|
||||
$this->Align[$this->ypointer][$this->xpointer]=$align;
|
||||
$this->Width[$this->ypointer][$this->xpointer]=$width;
|
||||
$this->Colspan[$this->ypointer][$this->xpointer]=$colspan;
|
||||
$this->xpointer++;
|
||||
}
|
||||
|
||||
function AddCellClass($class, $y = null, $x = null)
|
||||
{
|
||||
if(is_null($y))
|
||||
{
|
||||
$y = $this->ypointer;
|
||||
} else $y = (int)$y;
|
||||
if(is_null($x))
|
||||
{
|
||||
$x = $this->xpointer;
|
||||
} else $x = (int)$x;
|
||||
$this->cellclass[$y][$x][] = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $attributes
|
||||
* @param string|null $y
|
||||
* @param string|null $x
|
||||
*/
|
||||
public function AddCustomAttributes(array $attributes, string $y = null, string $x = null): void
|
||||
{
|
||||
if(is_null($y)){
|
||||
$y = $this->ypointer;
|
||||
}else $y = (int)$y;
|
||||
if(is_null($x)){
|
||||
$x = $this->xpointer;
|
||||
}else $x = (int)$x;
|
||||
$this->customAttributes[$y][$x] = $attributes;
|
||||
}
|
||||
|
||||
function AddCellonclick($js, $y = null, $x = null)
|
||||
{
|
||||
if(is_null($y))
|
||||
{
|
||||
$y = $this->ypointer;
|
||||
} else $y = (int)$y;
|
||||
if(is_null($x))
|
||||
{
|
||||
$x = $this->xpointer;
|
||||
} else $x = (int)$x;
|
||||
$this->cellonclick[$y][$x] = $js;
|
||||
}
|
||||
|
||||
function AddCellTitle($title, $y = null, $x = null)
|
||||
{
|
||||
if(is_null($y))
|
||||
{
|
||||
$y = $this->ypointer;
|
||||
} else $y = (int)$y;
|
||||
if(is_null($x))
|
||||
{
|
||||
$x = $this->xpointer;
|
||||
} else $x = (int)$x;
|
||||
$this->celltitle[$y][$x] = $title;
|
||||
}
|
||||
|
||||
// fuegt eine komplette spalte am schluss dazu
|
||||
function AddCompleteCol($colnumber,$string,$value="")
|
||||
{
|
||||
$this->CompleteCol[]=array($colnumber,$string,$value);
|
||||
}
|
||||
|
||||
function ActualCompleteRow($actualrow)
|
||||
{
|
||||
if($actualrow==0)
|
||||
return "";
|
||||
$ret = '';
|
||||
$cols = is_array($this->CompleteCol)?count($this->CompleteCol):0;
|
||||
|
||||
for($i=0;$i < $cols;$i++)
|
||||
{
|
||||
$ret .="<td>";
|
||||
$newvalue = $this->Table[$actualrow][$this->CompleteCol[$i][0]];
|
||||
$value = $this->Table[$actualrow][$this->CompleteCol[$i][2]];
|
||||
$text = str_replace('%col%',$newvalue,$this->CompleteCol[$i][1]);
|
||||
$ret .= str_replace('%value%',$value,$text);
|
||||
$ret .="</td>";
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function GetMaxCols()
|
||||
{
|
||||
|
||||
$max = 0;
|
||||
$count = count($this->Table);
|
||||
|
||||
for($i=0;$i<$count;$i++)
|
||||
{
|
||||
if(count($this->Table[$i]) > $max )
|
||||
$max = count($this->Table[$i]);
|
||||
}
|
||||
return $max;
|
||||
}
|
||||
|
||||
|
||||
function ChangingRowColors($color1,$color2)
|
||||
{
|
||||
$this->color1=$color1;
|
||||
$this->color2=$color2;
|
||||
}
|
||||
|
||||
function GetNextColor()
|
||||
{
|
||||
$this->nextcolor++;
|
||||
if($this->nextcolor % 2==0)
|
||||
return $this->color2;
|
||||
else return $this->color1;
|
||||
}
|
||||
|
||||
|
||||
function GetSpecialCSSClasses($columns,$editlastrow=false, $clastrows = 1)
|
||||
{
|
||||
$hidden = null;
|
||||
//hidden jede zweite zeile ist versteckt
|
||||
$rows = count($this->Table);
|
||||
if($rows>0)
|
||||
{
|
||||
$html = "<table border=\"{$this->border}\" cellpadding=\"{$this->cellpadding}\" id=\"tableone\"
|
||||
cellspacing=\"{$this->cellspacing}\" width=\"{$this->width}\" height=\"{$this->height}\">";
|
||||
|
||||
$cols = $this->GetMaxCols();
|
||||
|
||||
for($i=0;$i<$rows;$i++)
|
||||
{
|
||||
if(($i % 2)==0 && $i > 1 && $hidden==1) $none="none"; else $none="";
|
||||
|
||||
// zwei zeilen kriegen die gleiche nummer nur eins edit hinten dran
|
||||
//echo $i." $none<br>";
|
||||
$html .="<tr style=\"background-color:".$this->GetNextColor().";display:$none;\" id=\"{$i}\">\n";
|
||||
|
||||
for($j=0;$j<$cols;$j++)
|
||||
{
|
||||
if($this->hidecols[$j+1]=="")
|
||||
{
|
||||
$last = count($this->Table[$i]);
|
||||
|
||||
//$id="1233";
|
||||
// suche nach erste id
|
||||
|
||||
$pattern = '/&sid=[0-9]+/i';
|
||||
$subject = $this->Table[$i][$last-1];
|
||||
|
||||
preg_match_all($pattern, $subject, $matches);
|
||||
$id = str_replace("&sid=","",!empty($matches[0])?$matches[0][0]:'');
|
||||
|
||||
if($editlastrow)$limi = $rows; else $limi = $rows -1;
|
||||
if(!$editlastrow && $clastrows > 1)$limi = $rows - $clastrows;
|
||||
|
||||
if(in_array($j,$columns) && $i > 0 && $i < $limi)
|
||||
$html .="<td class=\"editable\" ".(($this->nowrap && is_array($this->nowrap))? (in_array($j, $this->nowrap)?' nowrap ':'') :$this->nowrap)." id=\"{$id}split{$j}\">";
|
||||
else {
|
||||
if($this->Width[$i][$j]!="")
|
||||
$html .="<td class=\"gentable\" ".(($this->nowrap && is_array($this->nowrap))? (in_array($j, $this->nowrap)?' nowrap ':'') :$this->nowrap)." width=\"".$this->Width[$i][$j]."\">";
|
||||
else
|
||||
$html .="<td class=\"gentable\" ".(($this->nowrap && is_array($this->nowrap))? (in_array($j, $this->nowrap)?' nowrap ':'') :$this->nowrap).">";
|
||||
}
|
||||
$html .= $this->Table[$i][$j]?$this->Table[$i][$j]:"";
|
||||
$html .="</td>";
|
||||
}
|
||||
}
|
||||
// get complete cols
|
||||
$html .=$this->ActualCompleteRow($i);
|
||||
$html .="</tr>";
|
||||
}
|
||||
$html .="</table>";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
function Get($hidden="")
|
||||
{
|
||||
//hidden jede zweite zeile ist versteckt
|
||||
$rows = count($this->Table);
|
||||
if($rows>0)
|
||||
{
|
||||
// $html = "<table border=\"{$this->border}\" cellpadding=\"{$this->cellpadding}\" id=\"tableone\" class=\"mkTable\"
|
||||
// cellspacing=\"{$this->cellspacing}\" width=\"{$this->width}\" height=\"{$this->height}\" style=\"{$this->style}\">";
|
||||
|
||||
if($this->cellpadding==3 && $this->cellspacing==1) {
|
||||
|
||||
$this->cellpadding=0;
|
||||
$this->cellspacing=0;
|
||||
}
|
||||
|
||||
$html = '<div class="table-responsive">'."<table cellpadding=\"{$this->cellpadding}\" cellspacing=\"{$this->cellspacing}\" class=\"mkTable\" width=\"{$this->width}\" height=\"{$this->height}\">";
|
||||
|
||||
$cols = $this->GetMaxCols();
|
||||
$modulo = 2;
|
||||
$rest = 2;
|
||||
if(isset($hidden)&& is_numeric($hidden) && $hidden > 1)$modulo = $hidden;
|
||||
if($hidden > 1)$rest = $hidden - 1;
|
||||
for($i=0;$i<$rows;$i++)
|
||||
{
|
||||
if(($i % $modulo==$rest) && $i > 1 && $hidden>=1) $none="none"; else $none="";
|
||||
|
||||
// zwei zeilen kriegen die gleiche nummer nur eins edit hinten dran
|
||||
//echo $i." $none<br>";
|
||||
//$html .="<tr style=\"background-color:".$this->GetNextColor().";display:$none;\" id=\"{$i}\">\n";
|
||||
$html .="<tr style=\"display:$none;\">\n";
|
||||
for($j=0;$j<$cols;$j++)
|
||||
{
|
||||
if($this->hidecols[$j+1]=="")
|
||||
{
|
||||
$colspan = (isset($this->Colspan) && isset($this->Colspan[$i]) && isset($this->Colspan[$i][$j]) && $this->Colspan[$i][$j]?$this->Colspan[$i][$j]:null);
|
||||
$html .="<td ".((isset($this->nowrap) && $this->nowrap && is_array($this->nowrap) && in_array(($j+1),$this->nowrap))?' nowrap ':'')."width=\"".$this->Width[$i][$j]."\" ".($colspan?' colspan="'.$this->Colspan[$i][$j].'" ':'' )." align=\"".$this->Align[$i][$j]."\" ".(isset($this->cellonclick[$i]) && isset($this->cellonclick[$i][$j]) && ($this->cellonclick[$i][$j])?' onclick="'.$this->cellonclick[$i][$j].'" ':'').(isset($this->celltitle[$i]) && isset($this->celltitle[$i][$j]) && ($this->celltitle[$i][$j])?' title="'.$this->celltitle[$i][$j].'" ':'');
|
||||
if(isset($this->cellclass[$i]) && isset($this->cellclass[$i][$j]) && is_array($this->cellclass[$i][$j]))
|
||||
{
|
||||
foreach($this->cellclass[$i][$j] as $class)
|
||||
{
|
||||
$html .=' class="'.$class.'"';
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($this->customAttributes[$i]) && isset($this->customAttributes[$i][$j]) && is_array($this->customAttributes[$i][$j]))
|
||||
{
|
||||
foreach($this->customAttributes[$i][$j] as $name => $value)
|
||||
{
|
||||
$html .=' '.$name.'="'.$value.'"';
|
||||
}
|
||||
}
|
||||
|
||||
$html .=" ".$this->nowrap.">";
|
||||
$html .= $this->Table[$i][$j]?$this->Table[$i][$j]:" ";
|
||||
$html .="</td>";
|
||||
if($colspan)$j += $colspan;
|
||||
}
|
||||
}
|
||||
// get complete cols
|
||||
$html .=$this->ActualCompleteRow($i);
|
||||
$html .="</tr>";
|
||||
}
|
||||
$html .="</table>".'</div>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
function GetClose(){}
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,726 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
final class DatabaseUpgrade
|
||||
{
|
||||
/** @var Application $app */
|
||||
private $app;
|
||||
|
||||
/** @var array $CheckColumnTableCache */
|
||||
private $CheckColumnTableCache;
|
||||
|
||||
/** @var bool $check_column_missing_run */
|
||||
private $check_column_missing_run=false;
|
||||
|
||||
/** @var array $check_column_missing */
|
||||
private $check_column_missing=array();
|
||||
|
||||
/** @var array $check_index_missing */
|
||||
private $check_index_missing=array();
|
||||
|
||||
/** @var array */
|
||||
private $allTables = [];
|
||||
|
||||
/** @var array */
|
||||
private $indexe = [];
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
*/
|
||||
public function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
public function emptyTableCache(){
|
||||
$this->CheckColumnTableCache = [];
|
||||
$this->allTables = [];
|
||||
$this->indexe = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @var bool $force
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllTables($force = false)
|
||||
{
|
||||
if($force || empty($this->allTables)) {
|
||||
$this->allTables = $this->app->DB->SelectFirstCols('SHOW TABLES');
|
||||
}
|
||||
|
||||
return $this->allTables;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @param string $pk
|
||||
*/
|
||||
public function createTable($table, $pk = 'id')
|
||||
{
|
||||
$sql = "CREATE TABLE `$table` (`".$pk."` INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (`".$pk."`)) ENGINE = InnoDB DEFAULT CHARSET=utf8";
|
||||
$this->app->DB->Query($sql);
|
||||
$this->addPrimary($table, $pk);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @param string $pk
|
||||
*/
|
||||
public function addPrimary($table, $pk = 'id')
|
||||
{
|
||||
$this->CheckAlterTable(
|
||||
"ALTER TABLE `$table`
|
||||
ADD PRIMARY KEY (`".$pk."`)",
|
||||
true
|
||||
);
|
||||
$this->CheckAlterTable(
|
||||
"ALTER TABLE `$table`
|
||||
MODIFY `".$pk."` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1",
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @param bool $force
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getIndexeCached($table, $force = false)
|
||||
{
|
||||
if($force || !isset($this->indexe[$table])){
|
||||
$this->indexe[$table] = $this->app->DB->SelectArr(sprintf('SHOW INDEX FROM `%s`', $table));
|
||||
if($this->indexe[$table] === null) {
|
||||
$this->indexe[$table] = [];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->indexe[$table];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
*/
|
||||
public function clearIndexCached($table)
|
||||
{
|
||||
if(!isset($this->indexe[$table])) {
|
||||
return;
|
||||
}
|
||||
unset($this->indexe[$table]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @param string $pk
|
||||
*/
|
||||
public function hasPrimaryKey($table, $pk = 'id')
|
||||
{
|
||||
$indexe = $this->getIndexeCached($table);
|
||||
if(empty($indexe)) {
|
||||
return false;
|
||||
}
|
||||
foreach($indexe as $index) {
|
||||
if($index['Column_name'] === $pk
|
||||
&& $index['Key_name'] === 'PRIMARY'
|
||||
&& (int)$index['Non_unique'] === 0
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @param string $pk
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function CheckTable($table, $pk = 'id')
|
||||
{
|
||||
if($pk === 'id') {
|
||||
$tables = $this->getAllTables();
|
||||
if(!empty($tables)){
|
||||
if(!in_array($table, $tables)){
|
||||
$this->createTable($table, $pk);
|
||||
return;
|
||||
}
|
||||
if(!$this->hasPrimaryKey($table, $pk)) {
|
||||
$this->addPrimary($table, $pk);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
$found = false;
|
||||
$tables = $this->getAllTables(true);
|
||||
if($tables) {
|
||||
$found = in_array($table, $tables);
|
||||
}
|
||||
else{
|
||||
$check = $this->app->DB->Select("SELECT $pk FROM `$table` LIMIT 1");
|
||||
if($check) {
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
if($found==false)
|
||||
{
|
||||
$sql = "CREATE TABLE `$table` (`".$pk."` INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (`".$pk."`)) ENGINE = InnoDB DEFAULT CHARSET=utf8";
|
||||
$this->app->DB->Update($sql);
|
||||
$this->CheckAlterTable("ALTER TABLE `$table`
|
||||
ADD PRIMARY KEY (`".$pk."`)");
|
||||
$this->CheckAlterTable("ALTER TABLE `$table`
|
||||
MODIFY `".$pk."` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1");
|
||||
}
|
||||
if($pk !== 'id') {
|
||||
$this->CheckColumn('created_at','timestamp',$table,"DEFAULT CURRENT_TIMESTAMP NOT NULL");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param string $type
|
||||
* @param string $table
|
||||
* @param string $default
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function UpdateColumn($column,$type,$table,$default="NOT NULL")
|
||||
{
|
||||
$fields = $this->app->DB->SelectArr("show columns from `".$table."`");
|
||||
if($fields)
|
||||
{
|
||||
foreach($fields as $val)
|
||||
{
|
||||
$field_array[] = $val['Field'];
|
||||
}
|
||||
}
|
||||
if (in_array($column, $field_array))
|
||||
{
|
||||
$this->app->DB->Query('ALTER TABLE `'.$table.'` CHANGE `'.$column.'` `'.$column.'` '.$type.' '.$default.';');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param string $table
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function DeleteColumn($column,$table)
|
||||
{
|
||||
$this->app->DB->Query('ALTER TABLE `'.$table.'` DROP `'.$column.'`;');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param string $type
|
||||
* @param string $table
|
||||
* @param string $default
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function CheckColumn($column,$type,$table,$default="")
|
||||
{
|
||||
if($table === 'firmendaten')
|
||||
{
|
||||
if($this->app->DB->Select("SELECT `id` FROM `firmendaten_werte` WHERE `name` = '$column' LIMIT 1"))return;
|
||||
}
|
||||
if(!isset($this->CheckColumnTableCache[$table]))
|
||||
{
|
||||
$tmp=$this->app->DB->SelectArr("show columns from `".$table."`");
|
||||
if($tmp)
|
||||
{
|
||||
foreach($tmp as $val)
|
||||
{
|
||||
$this->CheckColumnTableCache[$table][] = $val['Field'];
|
||||
//$types[$val['Field']] = strtolower($val['Type']);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($this->CheckColumnTableCache[$table]) && !in_array($column, $this->CheckColumnTableCache[$table]))
|
||||
{
|
||||
if($this->check_column_missing_run)
|
||||
{
|
||||
//$result = mysqli_query($this->app->DB->connection,'ALTER TABLE `'.$table.'` ADD `'.$column.'` '.$type.' '.$default.';');
|
||||
$this->check_column_missing[$table][]=$column;
|
||||
} else {
|
||||
$result = $this->app->DB->Query('ALTER TABLE `'.$table.'` ADD `'.$column.'` '.$type.' '.$default.';');
|
||||
if($table === 'firmendaten' && $this->app->DB->error())
|
||||
{
|
||||
if((method_exists($this->app->DB, 'errno2') && $this->app->DB->errno() == '1118')
|
||||
|| strpos($this->app->DB->error(),'Row size too large') !== false
|
||||
)
|
||||
{
|
||||
$this->ChangeFirmendatenToMyIsam();
|
||||
$this->app->DB->Query('ALTER TABLE `'.$table.'` ADD `'.$column.'` '.$type.' '.$default.';');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $indexe
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getGroupedIndexe($indexe)
|
||||
{
|
||||
if(empty($indexe)) {
|
||||
return $indexe;
|
||||
}
|
||||
$return = [];
|
||||
foreach($indexe as $index) {
|
||||
$keyName = $index['Key_name'];
|
||||
$isUnique = $index['Non_unique'] == '0';
|
||||
$seq = $index['Seq_in_index'];
|
||||
$columnName = $index['Column_name'];
|
||||
$return[$isUnique?'unique':'index'][$keyName][(int)$seq - 1] = $columnName;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $indexe
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getDoubleIndexeFromGroupedIndexe($indexe)
|
||||
{
|
||||
if(empty($indexe)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$ret = [];
|
||||
foreach($indexe as $type => $indexArrs) {
|
||||
$columnStrings = [];
|
||||
foreach($indexArrs as $indexKey => $columns) {
|
||||
$columnString = implode('|', $columns);
|
||||
if(in_array($columnString, $columnStrings)) {
|
||||
$ret[$type][] = $indexKey;
|
||||
continue;
|
||||
}
|
||||
$columnStrings[] = $columnString;
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @param array $indexe
|
||||
* @param bool $noCache
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function CheckDoubleIndex($table, $indexe, $noCache = false)
|
||||
{
|
||||
$query = $noCache?null:$this->CheckAlterTable("SHOW INDEX FROM `$table`");
|
||||
if(!$query) {
|
||||
$indexeGrouped = $this->getGroupedIndexe($indexe);
|
||||
$doubleIndexe = $this->getDoubleIndexeFromGroupedIndexe($indexeGrouped);
|
||||
if(!empty($doubleIndexe)) {
|
||||
$indexe = $this->getIndexeCached($table, true);
|
||||
$indexeGrouped = $this->getGroupedIndexe($indexe);
|
||||
$doubleIndexe = $this->getDoubleIndexeFromGroupedIndexe($indexeGrouped);
|
||||
if(empty($doubleIndexe)) {
|
||||
return $indexe;
|
||||
}
|
||||
|
||||
foreach($doubleIndexe as $type => $doubleIndex) {
|
||||
foreach($doubleIndex as $indexName) {
|
||||
$this->app->DB->Query("ALTER TABLE `".$table."` DROP INDEX `".$indexName."`");
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($noCache) {
|
||||
return $indexe;
|
||||
}
|
||||
$this->CheckAlterTable("SHOW INDEX FROM `$table`", true);
|
||||
|
||||
return $this->getIndexeCached($table, true);
|
||||
}
|
||||
if(empty($indexe) || count($indexe) == 1){
|
||||
return $indexe;
|
||||
}
|
||||
$uniquearr = array();
|
||||
$indexarr = array();
|
||||
foreach($indexe as $index)
|
||||
{
|
||||
if($index['Key_name'] !== 'PRIMARY' && !empty($index['Column_name']))
|
||||
{
|
||||
if($index['Non_unique'])
|
||||
{
|
||||
$indexarr[$index['Key_name']][] = $index['Column_name'];
|
||||
}else{
|
||||
$uniquearr[$index['Key_name']][] = $index['Column_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$cindex = count($indexarr);
|
||||
$cuniqe = count($uniquearr);
|
||||
$changed = false;
|
||||
if($cindex > 1)
|
||||
{
|
||||
$check = array();
|
||||
foreach($indexarr as $key => $value)
|
||||
{
|
||||
if(empty($value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(count($value) > 1){
|
||||
sort($value);
|
||||
}
|
||||
$vstr = implode(',', $value);
|
||||
if(in_array($vstr, $check))
|
||||
{
|
||||
$this->app->DB->Query("DROP INDEX `".$key."` ON `".$table."`");
|
||||
$changed = true;
|
||||
}else{
|
||||
$check[] = $vstr;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($cuniqe > 1)
|
||||
{
|
||||
$check = array();
|
||||
foreach($uniquearr as $key => $value)
|
||||
{
|
||||
if(empty($value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(count($value) > 1){
|
||||
sort($value);
|
||||
}
|
||||
$vstr = implode(',', $value);
|
||||
if(in_array($vstr, $check))
|
||||
{
|
||||
$this->app->DB->Query("DROP UNIQUE `".$key."` ON `".$table."`");
|
||||
$changed = true;
|
||||
}else{
|
||||
$check[] = $vstr;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($changed) {
|
||||
return $this->getIndexeCached($table, true);
|
||||
}
|
||||
return $indexe;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @param string|array $column
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function CheckFulltextIndex($table,$column)
|
||||
{
|
||||
if(empty($table) || empty($column))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!is_array($column))
|
||||
{
|
||||
$column = [$column];
|
||||
}
|
||||
$columnmasked = [];
|
||||
foreach($column as $keyColumn => $valueColumn)
|
||||
{
|
||||
if(!empty($valueColumn))
|
||||
{
|
||||
$columnmasked[] = "`$valueColumn`";
|
||||
}else{
|
||||
unset($column[$keyColumn]);
|
||||
}
|
||||
}
|
||||
if(empty($column))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$columnsFound = [];
|
||||
$indexe = $this->getIndexeCached($table, true);
|
||||
$indexeFound = [];
|
||||
if(!empty($indexe))
|
||||
{
|
||||
foreach($indexe as $index)
|
||||
{
|
||||
if($index['Index_type'] === 'FULLTEXT')
|
||||
{
|
||||
$indexeFound[] = $index['Column_name'];
|
||||
if(!in_array($index['Column_name'], $columnsFound))
|
||||
{
|
||||
$columnsFound[] = $index['Column_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$cindexeFound = count($indexeFound);
|
||||
$column = count($column);
|
||||
if(($column === $cindexeFound) && (count($columnsFound) === $column))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if($cindexeFound > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
$this->app->DB->Query(
|
||||
"ALTER TABLE `$table`
|
||||
ADD FULLTEXT INDEX `FullText`
|
||||
(".implode(',',$columnmasked).");"
|
||||
);
|
||||
$error = $this->app->DB->error();
|
||||
|
||||
return empty($error);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @param string $column
|
||||
* @param bool $unique
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function CheckIndex($table, $column, $unique = false)
|
||||
{
|
||||
$indexex = null;
|
||||
$indexexother = null;
|
||||
$indexe = $this->getIndexeCached($table);
|
||||
if($indexe)
|
||||
{
|
||||
$indexe = $this->CheckDoubleIndex($table, $indexe, true);
|
||||
foreach($indexe as $index)
|
||||
{
|
||||
if(is_array($column) && $index['Key_name'] !== 'PRIMARY')
|
||||
{
|
||||
if($unique && !$index['Non_unique'])
|
||||
{
|
||||
if(in_array($index['Column_name'], $column))
|
||||
{
|
||||
$indexex[$index['Key_name']][$index['Column_name']] = true;
|
||||
}else{
|
||||
$indexexother[$index['Key_name']][$index['Column_name']] = true;
|
||||
}
|
||||
}
|
||||
elseif(!$unique){
|
||||
if(in_array($index['Column_name'], $column)) {
|
||||
$indexex[$index['Key_name']][$index['Column_name']] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif(!is_array($column)){
|
||||
if($index['Column_name'] == $column)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($this->check_column_missing_run)
|
||||
{
|
||||
$this->check_index_missing[$table][] = $column;
|
||||
}
|
||||
if(!$unique)
|
||||
{
|
||||
if(is_array($column))
|
||||
{
|
||||
if($indexex)
|
||||
{
|
||||
foreach($indexex as $k => $v) {
|
||||
if(count($v) === 1 && count($column) > 1) {
|
||||
$this->app->DB->Query("DROP INDEX `".$k."` ON `".$table."`");
|
||||
$this->clearIndexCached($table);
|
||||
unset($indexex[$k]);
|
||||
}
|
||||
}
|
||||
foreach($indexex as $k => $v)
|
||||
{
|
||||
if(count($v) == count($column)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
foreach($indexex as $k => $v)
|
||||
{
|
||||
if(!isset($indexexother[$k]))
|
||||
{
|
||||
$this->app->DB->Query("DROP INDEX `".$k."` ON `".$table."`");
|
||||
$cols = null;
|
||||
foreach($column as $c) {
|
||||
$cols[] = "`$c`";
|
||||
}
|
||||
$this->CheckAlterTable("ALTER TABLE `$table` ADD INDEX(".implode(', ',$cols)."); ",true);
|
||||
$this->clearIndexCached($table);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
$cols = null;
|
||||
foreach($column as $c) {
|
||||
$cols[] = "`$c`";
|
||||
}
|
||||
$this->CheckAlterTable("ALTER TABLE `$table` ADD INDEX(".implode(', ',$cols)."); ", true);
|
||||
$this->clearIndexCached($table);
|
||||
}
|
||||
else{
|
||||
$this->CheckAlterTable("ALTER TABLE `$table` ADD INDEX(`$column`); ", true);
|
||||
$this->clearIndexCached($table);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(is_array($column))
|
||||
{
|
||||
if($indexex)
|
||||
{
|
||||
foreach($indexex as $k => $v)
|
||||
{
|
||||
if(count($v) == count($column))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
foreach($indexex as $k => $v)
|
||||
{
|
||||
if(!isset($indexexother[$k]))
|
||||
{
|
||||
$this->app->DB->Query("DROP INDEX `".$k."` ON `".$table."`");
|
||||
$cols = null;
|
||||
foreach($column as $c) {
|
||||
$cols[] = "`$c`";
|
||||
}
|
||||
$this->CheckAlterTable("ALTER TABLE `$table` ADD UNIQUE(".implode(', ',$cols)."); ", true);
|
||||
$this->clearIndexCached($table);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
$cols = null;
|
||||
foreach($column as $c) {
|
||||
$cols[] = "`$c`";
|
||||
}
|
||||
$this->CheckAlterTable("ALTER TABLE `$table` ADD UNIQUE(".implode(', ',$cols)."); ", true);
|
||||
$this->clearIndexCached($table);
|
||||
}else{
|
||||
$this->CheckAlterTable("ALTER TABLE `$table` ADD UNIQUE(`$column`); ", true);
|
||||
$this->clearIndexCached($table);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif(!is_array($column))
|
||||
{
|
||||
if(!$unique)
|
||||
{
|
||||
$this->CheckAlterTable("ALTER TABLE `$table` ADD INDEX(`$column`); ");
|
||||
}else{
|
||||
$this->CheckAlterTable("ALTER TABLE `$table` ADD UNIQUE(`$column`); ");
|
||||
}
|
||||
$this->clearIndexCached($table);
|
||||
}
|
||||
elseif(is_array($column))
|
||||
{
|
||||
$cols = null;
|
||||
foreach($column as $c) {
|
||||
$cols[] = "`$c`";
|
||||
}
|
||||
$this->CheckAlterTable("ALTER TABLE `$table` ADD UNIQUE(".implode(', ',$cols)."); ");
|
||||
$this->clearIndexCached($table);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sql
|
||||
* @param bool $force
|
||||
*
|
||||
* @return mysqli_result|bool
|
||||
*/
|
||||
function CheckAlterTable($sql, $force = false)
|
||||
{
|
||||
$sqlmd5 = md5($sql);
|
||||
$check = $this->app->DB->Select("SELECT id FROM checkaltertable WHERE checksum='$sqlmd5' LIMIT 1");
|
||||
if($check > 0 && !$force) return;
|
||||
$query = $this->app->DB->Query($sql);
|
||||
if($query && empty($check) && !$this->app->DB->error()){
|
||||
$this->app->DB->Insert("INSERT INTO checkaltertable (id,checksum) VALUES ('','$sqlmd5')");
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function ChangeFirmendatenToMyIsam()
|
||||
{
|
||||
$this->app->DB->Query("ALTER TABLE firmendaten ENGINE = MyISAM;");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSortedIndexColumnsByIndexName($table): array
|
||||
{
|
||||
$indexesByName = [];
|
||||
$indexes = $this->app->DB->SelectArr(sprintf('SHOW INDEX FROM `%s`', $table));
|
||||
if(empty($indexes)) {
|
||||
return $indexesByName;
|
||||
}
|
||||
foreach($indexes as $index) {
|
||||
$indexesByName[$index['Key_name']][] = $index['Column_name'];
|
||||
}
|
||||
foreach($indexesByName as $indexName => $columns) {
|
||||
$columns = array_unique($columns);
|
||||
sort($columns);
|
||||
$indexesByName[$indexName] = $columns;
|
||||
}
|
||||
|
||||
return $indexesByName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated will be removed in 21.4
|
||||
*
|
||||
* @param string $table
|
||||
* @param array $columns
|
||||
*/
|
||||
public function dropIndex($table, $columns): void
|
||||
{
|
||||
if(empty($table) || empty($columns)) {
|
||||
return;
|
||||
}
|
||||
$columns = array_unique($columns);
|
||||
sort($columns);
|
||||
$countColumns = count($columns);
|
||||
$indexes = $this->getSortedIndexColumnsByIndexName($table);
|
||||
if(empty($indexes)) {
|
||||
return;
|
||||
}
|
||||
foreach($indexes as $indexName => $indexColumns) {
|
||||
if(count($indexColumns) !== $countColumns) {
|
||||
continue;
|
||||
}
|
||||
if(count(array_intersect($indexColumns, $columns)) === $countColumns) {
|
||||
$this->app->DB->Query(sprintf('ALTER TABLE `%s` DROP INDEX `%s`', $table, $indexName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,470 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class ModuleScriptCache
|
||||
*
|
||||
* Cache-Datei mit zufälligem Namen generieren
|
||||
* @example IncludeJavascriptFiles('chat', $files) => cache/chat-1234abcd.js
|
||||
*
|
||||
* Cache-Datei mit festen Dateinamen generieren (erster Parameter muss mit .js oder .css enden)
|
||||
* @example IncludeJavascriptFiles('chat.js', $files) => cache/chat.js?hash=1234abcd
|
||||
*/
|
||||
class ModuleScriptCache
|
||||
{
|
||||
/** @var string $baseDir Absoluter Pfad zur Xentral-Installation */
|
||||
protected $baseDir;
|
||||
|
||||
/** @var string $absoluteCacheDir Absoluter Pfad zum Cache-Ordner (muss in www sein) */
|
||||
protected $absoluteCacheDir;
|
||||
|
||||
/** @var string $relativeCacheDir Relativer Pfad zum Cache-Ordner (ausgehend von www) */
|
||||
protected $relativeCacheDir;
|
||||
|
||||
/** @var array $javascriptFiles Absolute Pfade zu Javascript-Dateien die gecached werden sollen */
|
||||
protected $javascriptFiles = [
|
||||
'head' => [],
|
||||
'body' => [],
|
||||
];
|
||||
|
||||
/** @var array $stylesheetFiles Absolute Pfade zu Stylesheet-Dateien die gecached werden sollen */
|
||||
protected $stylesheetFiles = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->baseDir = dirname(dirname(__DIR__));
|
||||
$this->absoluteCacheDir = $this->baseDir . '/www/cache';
|
||||
$this->relativeCacheDir = './cache';
|
||||
|
||||
// Cache-Ordner anzulegen, falls nicht existent
|
||||
if (!is_dir($this->absoluteCacheDir)) {
|
||||
if(!mkdir($concurrentDirectory = $this->absoluteCacheDir, 0777) && !is_dir($concurrentDirectory)){
|
||||
throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $legacyModuleClassName Kompletter Klassenname das alten Moduls
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function IncludeModule($legacyModuleClassName)
|
||||
{
|
||||
$newModuleName = $this->DetermineNewModuleName($legacyModuleClassName);
|
||||
|
||||
// Neuer Modulname konnte nicht ermittelt werden; MODULE_NAME Konstante fehlt im alten Modul
|
||||
if ($newModuleName === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Javascript- und Stylesheet-Dateien sind als Eigenschaft im Modul definiert
|
||||
$javascript = $this->GetClassProperty($legacyModuleClassName, 'javascript');
|
||||
$stylesheet = $this->GetClassProperty($legacyModuleClassName, 'stylesheet');
|
||||
|
||||
// Falls nicht im Modul definiert > Defaults verwenden
|
||||
if (empty($javascript)) {
|
||||
$javascript = [$this->GetDefaultModuleJavascriptFile($newModuleName)];
|
||||
}
|
||||
if (empty($stylesheet)) {
|
||||
$stylesheet = [$this->GetDefaultModuleStylesheetFile($newModuleName)];
|
||||
}
|
||||
|
||||
$this->IncludeJavascriptFiles($newModuleName, $javascript);
|
||||
$this->IncludeStylesheetFiles($newModuleName, $stylesheet);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $widgetName
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function IncludeWidgetNew($widgetName)
|
||||
{
|
||||
$widgetNameCleaned = preg_replace('/[^a-z]+/im', '', $widgetName);
|
||||
if ($widgetName !== $widgetNameCleaned) {
|
||||
throw new RuntimeException(sprintf(
|
||||
'Widget name "%s" contains illegal characters. Valid characters: A-Z, a-z', $widgetName
|
||||
));
|
||||
}
|
||||
if (empty($widgetName)){
|
||||
throw new RuntimeException('Widget name can not be empty.');
|
||||
}
|
||||
|
||||
$javascript = $stylesheet = [];
|
||||
|
||||
// Javascript- und CSS-Dateien aus Bootstrap holen
|
||||
$widgetBootstrapClass = sprintf('Xentral\\Widgets\\%s\\Bootstrap', $widgetName);
|
||||
if (class_exists($widgetBootstrapClass, true)) {
|
||||
$javascript = (array)@forward_static_call([$widgetBootstrapClass, 'registerJavascript']);
|
||||
foreach ($javascript as $cacheName => $jsFiles) {
|
||||
$this->IncludeJavascriptFiles($cacheName, $jsFiles);
|
||||
}
|
||||
$stylesheets = (array)@forward_static_call([$widgetBootstrapClass, 'registerStylesheets']);
|
||||
foreach ($stylesheets as $cacheName => $cssFiles) {
|
||||
$this->IncludeStylesheetFiles($cacheName, $cssFiles);
|
||||
}
|
||||
}
|
||||
|
||||
// Falls nicht in Bootstrap definiert > Fallback auf Defaults
|
||||
if (empty($javascript)) {
|
||||
$javascript = [$this->GetDefaultWidgetJavascriptFile($widgetName)];
|
||||
$this->IncludeJavascriptFiles($widgetName, $javascript);
|
||||
}
|
||||
if (empty($stylesheet)) {
|
||||
$stylesheet = [$this->GetDefaultWidgetStylesheetFile($widgetName)];
|
||||
$this->IncludeStylesheetFiles($widgetName, $stylesheet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $cacheName Name unter dem die Cache-Datei zusammengefasst werden
|
||||
* @param array $files Array mit relativen Pfaden zur Xentral-Installation
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function IncludeJavascriptFiles($cacheName, array $files)
|
||||
{
|
||||
foreach ($files as $section => $file) {
|
||||
// Neues Verhalten => Trennung nach Head und Body
|
||||
if ($section === 'head' && is_array($file)) {
|
||||
$this->IncludeJavascriptHeadFiles($cacheName, $file);
|
||||
continue;
|
||||
}
|
||||
if ($section === 'body' && is_array($file)) {
|
||||
$this->IncludeJavascriptBodyFiles($cacheName, $file);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Altes Verhalten (vor Trennung in Head un Body) => Alles in Body
|
||||
$realPath = realpath($this->baseDir . '/' . $file);
|
||||
if(is_file($realPath)){
|
||||
$this->javascriptFiles['body'][$cacheName][] = $realPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $cacheName
|
||||
* @param array $files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function IncludeJavascriptHeadFiles($cacheName, array $files)
|
||||
{
|
||||
// Prüfen ob Dateien existieren
|
||||
foreach ($files as $file) {
|
||||
$realPath = realpath($this->baseDir . '/' . $file);
|
||||
if(is_file($realPath)){
|
||||
$this->javascriptFiles['head'][$cacheName . '-head'][] = $realPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $cacheName
|
||||
* @param array $files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function IncludeJavascriptBodyFiles($cacheName, array $files)
|
||||
{
|
||||
// Prüfen ob Dateien existieren
|
||||
foreach ($files as $file) {
|
||||
$realPath = realpath($this->baseDir . '/' . $file);
|
||||
if(is_file($realPath)){
|
||||
$this->javascriptFiles['body'][$cacheName . '-body'][] = $realPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $cacheName Name unter dem die Cache-Datei zusammengefasst werden
|
||||
* @param array $files Array mit relativen Pfaden zur Xentral-Installation
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function IncludeStylesheetFiles($cacheName, array $files)
|
||||
{
|
||||
// Prüfen ob Dateien existieren
|
||||
foreach ($files as $file) {
|
||||
$realPath = realpath($this->baseDir . '/' . $file);
|
||||
if(is_file($realPath)){
|
||||
$this->stylesheetFiles[$cacheName][] = $realPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetStylesheetHtmlTags()
|
||||
{
|
||||
if (empty($this->stylesheetFiles)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$html = '';
|
||||
foreach ($this->stylesheetFiles as $moduleName => $files) {
|
||||
$cacheFilesUri = $this->GetCacheFileUri($moduleName, 'css', $files);
|
||||
if (!empty($cacheFilesUri)){
|
||||
$html .= sprintf('<link href="%s" rel="stylesheet" type="text/css" />', $cacheFilesUri);
|
||||
$html .= "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $section [head|body]
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetJavascriptHtmlTags($section = 'body')
|
||||
{
|
||||
if ($section !== 'body' && $section !== 'head') {
|
||||
throw new RuntimeException(sprintf('Invalid section parameter "%s"', $section));
|
||||
}
|
||||
|
||||
if (empty($this->javascriptFiles[$section])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$html = '';
|
||||
foreach ($this->javascriptFiles[$section] as $moduleName => $files) {
|
||||
$cacheFilesUri = $this->GetCacheFileUri($moduleName, 'js', $files);
|
||||
if (!empty($cacheFilesUri)){
|
||||
$html .= sprintf('<script type="text/javascript" src="%s" charset="UTF-8"></script>', $cacheFilesUri);
|
||||
$html .= "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetAbsoluteCacheDir()
|
||||
{
|
||||
return $this->absoluteCacheDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetRelativeCacheDir()
|
||||
{
|
||||
return $this->relativeCacheDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsCacheDirWritable()
|
||||
{
|
||||
$randomData = md5(microtime(true));
|
||||
$tempFile = $this->absoluteCacheDir . '/' . $randomData . '.tmp';
|
||||
if (!file_put_contents($tempFile, $randomData)) {
|
||||
return false;
|
||||
}
|
||||
unlink($tempFile);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $moduleName Neuer Modulename
|
||||
* @param string $fileType [js|css]
|
||||
* @param array $files Array mit absoluten Pfaden zu Resourcen
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function GetCacheFileUri($moduleName, $fileType, array $files = [])
|
||||
{
|
||||
if(!in_array($fileType, ['css', 'js'])){
|
||||
return '';
|
||||
}
|
||||
|
||||
$files = array_unique($files);
|
||||
|
||||
// Hash über alle Dateien bilden
|
||||
$hash = $this->CalculateFilesHash($files);
|
||||
|
||||
// Pfad zur Cache-Datei bestimmen
|
||||
if(substr($moduleName, -3) === '.js' || substr($moduleName, -4) === '.css'){
|
||||
$hashFilename = $moduleName;
|
||||
$cacheFileUri = $this->relativeCacheDir . '/' . $hashFilename . '?hash=' . $hash;
|
||||
}else{
|
||||
$hashFilename = strtolower($moduleName) . '-' . $hash . '.' . $fileType;
|
||||
$cacheFileUri = $this->relativeCacheDir . '/' . $hashFilename;
|
||||
}
|
||||
|
||||
// Cache-Datei anlegen, falls nicht existent
|
||||
$cacheFilePath = $this->absoluteCacheDir . '/' . $hashFilename;
|
||||
if(!is_file($cacheFilePath)){
|
||||
$this->CreateCacheFile($files, $cacheFilePath);
|
||||
}
|
||||
|
||||
return $cacheFileUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Führt mehrere Dateieninhalte in eine Datei zusammen
|
||||
*
|
||||
* @param array $sourceFiles
|
||||
* @param string $destFile
|
||||
*/
|
||||
protected function CreateCacheFile($sourceFiles, $destFile)
|
||||
{
|
||||
$destHandle = fopen($destFile, 'wb');
|
||||
if ($destHandle === false) {
|
||||
throw new RuntimeException(sprintf(
|
||||
'Could not create cache file #1. Please make "%s" directory writable. Failed file: %s',
|
||||
$this->GetRelativeCacheDir(),
|
||||
$destFile
|
||||
));
|
||||
}
|
||||
foreach ($sourceFiles as $sourceFile) {
|
||||
$sourceContents = '/********* ' . basename($sourceFile) . ' *********/ ' . "\r\n";
|
||||
$sourceContents .= file_get_contents($sourceFile);
|
||||
$sourceContents .= "\r\n\r\n";
|
||||
$writeResult = fwrite($destHandle, $sourceContents);
|
||||
if ($writeResult === false) {
|
||||
throw new RuntimeException(sprintf(
|
||||
'Could not create cache file #2. Please make "%s" directory writable. Failed file: %s',
|
||||
$this->GetRelativeCacheDir(),
|
||||
$destFile
|
||||
));
|
||||
}
|
||||
}
|
||||
fclose($destHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Berechnet einen Hash über mehrere Dateien
|
||||
*
|
||||
* Der Hash wird über das Änderungsdatum und die Dateigröße generiert.
|
||||
*
|
||||
* Die Hash-Berechnung über die Dateiinhalte (md5_file) wäre akkurater; ist aber mindestens 10 mal langsamer.
|
||||
*
|
||||
* @param array $files
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function CalculateFilesHash($files)
|
||||
{
|
||||
$md5s = [];
|
||||
foreach ($files as $file) {
|
||||
$md5s[] = md5(filemtime($file) . filesize($file));
|
||||
}
|
||||
|
||||
// Hash über alle Dateien ermitteln
|
||||
return count($md5s) === 1 ? $md5s[0] : md5(implode('', $md5s), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $moduleName
|
||||
*
|
||||
* @return string Relativer Pfad zur Javascript-Datei im neuen Modul-Verzeichnis
|
||||
*/
|
||||
protected function GetDefaultModuleJavascriptFile($moduleName)
|
||||
{
|
||||
return sprintf('./classes/Modules/%s/www/js/%s.js', $moduleName, strtolower($moduleName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $moduleName
|
||||
*
|
||||
* @return string Relativer Pfad zur Stylesheet-Datei im neuen Modul-Verzeichnis
|
||||
*/
|
||||
protected function GetDefaultModuleStylesheetFile($moduleName)
|
||||
{
|
||||
return sprintf('./classes/Modules/%s/www/css/%s.css', $moduleName, strtolower($moduleName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $widgetName
|
||||
*
|
||||
* @return string Relativer Pfad zur Javascript-Datei im neuen Widgets-Verzeichnis
|
||||
*/
|
||||
protected function GetDefaultWidgetJavascriptFile($widgetName)
|
||||
{
|
||||
return sprintf('./classes/Widgets/%s/www/js/%s.js', $widgetName, strtolower($widgetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $widgetName
|
||||
*
|
||||
* @return string Relativer Pfad zur Stylesheet-Datei im neuen Widgets-Verzeichnis
|
||||
*/
|
||||
protected function GetDefaultWidgetStylesheetFile($widgetName)
|
||||
{
|
||||
return sprintf('./classes/Widgets/%s/www/css/%s.css', $widgetName, strtolower($widgetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $legacyModuleClassName
|
||||
* @param string $property
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function GetClassProperty($legacyModuleClassName, $property)
|
||||
{
|
||||
if(!class_exists($legacyModuleClassName, true)){
|
||||
include_once sprintf('%s/www/pages/%s.php', $this->baseDir, strtolower($legacyModuleClassName));
|
||||
}
|
||||
if (!class_exists($legacyModuleClassName, false)) {
|
||||
return null;
|
||||
}
|
||||
if (!property_exists($legacyModuleClassName, $property)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$properties = get_class_vars($legacyModuleClassName);
|
||||
|
||||
return $properties[$property];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt, anhand des alten Moduls, den Name des neuen Moduls
|
||||
*
|
||||
* Ist notwendig da die alten Module in Deutsch betitelt sind, und die neuen Module in Englisch.
|
||||
*
|
||||
* Beispiel @see Chat::MODULE_NAME
|
||||
*
|
||||
* @param string $legacyModuleClassName
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function DetermineNewModuleName($legacyModuleClassName)
|
||||
{
|
||||
if(!class_exists($legacyModuleClassName, true)){
|
||||
$legacyModuleClassFile = sprintf('%s/www/pages/%s.php', $this->baseDir, strtolower($legacyModuleClassName));
|
||||
if (is_file($legacyModuleClassFile)) {
|
||||
include_once $legacyModuleClassFile;
|
||||
}
|
||||
}
|
||||
if(!defined($legacyModuleClassName . '::MODULE_NAME')){
|
||||
return null;
|
||||
}
|
||||
|
||||
return constant($legacyModuleClassName . '::MODULE_NAME');
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
class ObjectAPI
|
||||
{
|
||||
private $app;
|
||||
|
||||
function __construct($app)
|
||||
{
|
||||
$this->app = &$app;
|
||||
}
|
||||
|
||||
function Get($name)
|
||||
{
|
||||
|
||||
|
||||
if(file_exists("objectapi/mysql/object.$name.php")) {
|
||||
include_once("objectapi/mysql/object.$name.php");
|
||||
//echo "es gibt ein modifiziertes objecy";
|
||||
$classname = "Obj".ucfirst($name);
|
||||
return new $classname($this->app);
|
||||
} else {
|
||||
//echo "es gibt nur das generiewrte";
|
||||
include_once("objectapi/mysql/_gen/object.gen.$name.php");
|
||||
//echo "es gibt ein modifiziertes objecy";
|
||||
$classname = "ObjGen".ucfirst($name);
|
||||
return new $classname($this->app);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
function CreatePage($widgets,$tplfile)
|
||||
{
|
||||
if(count($widgets)>0){
|
||||
foreach($widgets as $key=>$varname) {
|
||||
// pruefen ob es ein widget sein soll
|
||||
if(preg_match("/^[\[]WIDGET_/",$varname)) {
|
||||
$classname = "";
|
||||
$varname = str_replace('[','',$varname);
|
||||
$varname = str_replace(']','',$varname);
|
||||
list($type,$classname,$action)=split('_',$varname);
|
||||
|
||||
// pruefe ob es ein abgeleitetes gibt wenn nicht starte das generierte
|
||||
if(file_exists("widgets/widget.".strtolower($classname).".php")) {
|
||||
$filename = "widget.".strtolower($classname).".php";
|
||||
$classname = "Widget".ucfirst(strtolower($classname));
|
||||
$action = ucfirst(strtolower($action));
|
||||
include_once("widgets/$filename");
|
||||
} else {
|
||||
$filename = "widget.gen.".strtolower($classname).".php";
|
||||
$classname = "WidgetGen".ucfirst(strtolower($classname));
|
||||
$action = ucfirst(strtolower($action));
|
||||
include_once("widgets/_gen/$filename");
|
||||
}
|
||||
|
||||
|
||||
$mywidget = new $classname(&$this->app,$varname);
|
||||
$mywidget->$action();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->app->Tpl->Parse(PAGE,$tplfile);
|
||||
}
|
||||
*/
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,301 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
/// central config board for the engine
|
||||
class Page
|
||||
{
|
||||
var $engine;
|
||||
/** @var Application $app */
|
||||
|
||||
/**
|
||||
* Page constructor.
|
||||
*
|
||||
* @param Application $app
|
||||
*/
|
||||
function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
//$this->engine = &$engine;
|
||||
}
|
||||
|
||||
/// load a themeset set
|
||||
function LoadTheme($theme)
|
||||
{
|
||||
//$this->app->Tpl->ReadTemplatesFromPath("themes/$theme/templates/");
|
||||
$this->app->Tpl->ReadTemplatesFromPath(__DIR__."/../../www/themes/$theme/templates/");
|
||||
}
|
||||
|
||||
/// show complete page
|
||||
function Show()
|
||||
{
|
||||
return $this->app->Tpl->FinalParse('page.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $menu
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function removeDoubleMenuEntries($menu)
|
||||
{
|
||||
if(empty($menu)) {
|
||||
return $menu;
|
||||
}
|
||||
foreach($menu as $key=>$value) {
|
||||
if($value['first'][2] !== 'direktzugriff'){
|
||||
if(!empty($value['sec']) && count($value['sec']) > 0){
|
||||
$secKeys = [];
|
||||
foreach ($value['sec'] as $key2 => $secnav) {
|
||||
$secNavString = implode('|', $secnav);
|
||||
if(in_array($secNavString, $secKeys)) {
|
||||
unset($menu[$key]['sec'][$key2], $value['sec'][$key2]);
|
||||
continue;
|
||||
}
|
||||
$secKeys[] = $secNavString;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $menu
|
||||
* @param string $module
|
||||
* @param string $action
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSelectionKeysByModuleAction($menu, $module, $action)
|
||||
{
|
||||
$moduleKey = -1;
|
||||
$actionKey = -1;
|
||||
$moduleKey3 = -1;
|
||||
$actionKey3 = -1;
|
||||
foreach($menu as $key => $value){
|
||||
if($value['first'][2]!=='direktzugriff') {
|
||||
if(!empty($value['sec']) && count($value['sec'])>0){
|
||||
foreach($value['sec'] as $key2 => $secnav){
|
||||
$isModuleSecNav = $module == $secnav[1];
|
||||
if($isModuleSecNav && $action == $secnav[2]) {
|
||||
return [$key, $key2];
|
||||
}
|
||||
if($isModuleSecNav && $secnav[2] === 'list' && $moduleKey3 === -1) {
|
||||
$actionKey3 = $key2;
|
||||
$moduleKey3 = $key;
|
||||
}
|
||||
elseif($isModuleSecNav && $moduleKey === -1) {
|
||||
$actionKey = $key2;
|
||||
$moduleKey = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($moduleKey3 != -1) {
|
||||
return [$moduleKey3, $actionKey3];
|
||||
}
|
||||
|
||||
return [$moduleKey, $actionKey];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $menu
|
||||
* @param bool $returnJson
|
||||
* @param null|string $aktmodule
|
||||
* @param null|string $aktaction
|
||||
*
|
||||
* @return array|void
|
||||
*/
|
||||
public function CreateNavigation($menu, $returnJson = false, $aktmodule = null, $aktaction = null)
|
||||
{
|
||||
if(method_exists($this->app->erp, 'NavigationHooks')) {
|
||||
$this->app->erp->NavigationHooks($menu);
|
||||
}
|
||||
|
||||
$menu = $this->removeDoubleMenuEntries($menu);
|
||||
|
||||
if(isset($menu) && count($menu)>0){
|
||||
if($aktmodule === null) {
|
||||
$aktmodule = (string)$this->app->Secure->GetGET('module');
|
||||
}
|
||||
if($aktaction === null) {
|
||||
$aktaction = (string)$this->app->Secure->GetGET('action');
|
||||
}
|
||||
$actKeys = $this->getSelectionKeysByModuleAction($menu, $aktmodule, $aktaction);
|
||||
$aktmodulekey = $actKeys[0];
|
||||
$aktactionkey = $actKeys[1];
|
||||
$jsonMenu = [];
|
||||
$breadCrumb= [];
|
||||
foreach($menu as $key=>$value){
|
||||
$main = [
|
||||
'active' => false,
|
||||
'sec' => [],
|
||||
'link' => null,
|
||||
];
|
||||
if($value['first'][2]!=='direktzugriff') {
|
||||
if($aktmodulekey == $key) {
|
||||
$main['active'] = true;
|
||||
}
|
||||
if($value['first'][2]!='') {
|
||||
$main['title'] = $this->app->Tpl->pruefeuebersetzung($value['first'][0],'menu');
|
||||
$main['original_title'] = $value['first'][0];
|
||||
}
|
||||
else {
|
||||
if($aktmodule == $value['first'][1]) {
|
||||
$main['active'] = true;
|
||||
}
|
||||
$main['module'] = $value['first'][1];
|
||||
$main['link'] = 'index.php?module='.$value['first'][1].'&top='.base64_encode($value['first'][0]);
|
||||
$main['original_title'] = $value['first'][0];
|
||||
$main['title'] = $this->app->Tpl->pruefeuebersetzung($value['first'][0],'menu');
|
||||
}
|
||||
}
|
||||
else {
|
||||
if($value['first'][2]!='') {
|
||||
$main['original_title'] = $value['first'][0];
|
||||
$main['title'] = $this->app->Tpl->pruefeuebersetzung($value['first'][0],'menu');
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($value['sec']) && count($value['sec'])>0){
|
||||
foreach($value['sec'] as $key2 => $secnav){
|
||||
$sec = [
|
||||
'active' => false,
|
||||
];
|
||||
if($secnav[2]!='') {
|
||||
$sec['module'] = $secnav[1];
|
||||
$sec['action'] = $secnav[2];
|
||||
$sec['link'] = 'index.php?module='.$secnav[1].'&action='.$secnav[2].'&top='.base64_encode($value['first'][0]);
|
||||
$sec['original_title'] = $secnav[0];
|
||||
$sec['title'] = $this->app->Tpl->pruefeuebersetzung($secnav[0],'menu');
|
||||
if($aktmodule == $secnav[1]) {
|
||||
$breadCrumb[] = [
|
||||
'link' => 'index.php?module='.$secnav[1].'&action='.$secnav[2].'&top='.base64_encode($value['first'][0]),
|
||||
'title' => $this->app->Tpl->pruefeuebersetzung($secnav[0],'menu'),
|
||||
];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$sec['module'] = $secnav[1];
|
||||
$sec['link'] = 'href="index.php?module='.$secnav[1].'&top='.base64_encode($value['first'][0]);
|
||||
$sec['original_title'] = $secnav[0];
|
||||
$sec['title'] = $this->app->Tpl->pruefeuebersetzung($secnav[0],'menu');
|
||||
$breadCrumb[] = [
|
||||
'link' => 'index.php?module='.$secnav[1].'&action='.$secnav[2].'&top='.base64_encode($value['first'][0]),
|
||||
'title' => $this->app->Tpl->pruefeuebersetzung($secnav[0],'menu'),
|
||||
];
|
||||
}
|
||||
|
||||
if($aktmodulekey == $key && $aktactionkey == $key2)
|
||||
{
|
||||
$sec['active'] = true;
|
||||
}
|
||||
if(!empty($sec)) {
|
||||
$main['sec'][] = $sec;
|
||||
}
|
||||
}
|
||||
}
|
||||
$jsonMenu[] = $main;
|
||||
}
|
||||
if($returnJson) {
|
||||
return $jsonMenu;
|
||||
}
|
||||
|
||||
$this->drawMenu($menu, $aktmodulekey, $aktmodule, $aktactionkey);
|
||||
$this->app->Tpl->Add(
|
||||
'BODYENDE',
|
||||
'<script id="mainMenuJson" type="application/json">'.json_encode($jsonMenu).'</script>'
|
||||
);
|
||||
$this->app->Tpl->Add(
|
||||
'BODYENDE',
|
||||
'<script id="breadCrumbJson" type="application/json">'.json_encode($breadCrumb).'</script>'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $menu
|
||||
* @param string $aktmodulekey
|
||||
* @param string $aktmodule
|
||||
* @param int $aktactionkey
|
||||
*/
|
||||
public function drawMenu($menu, $aktmodulekey, $aktmodule, $aktactionkey) {
|
||||
foreach($menu as $key=>$value){
|
||||
$aktiv = 0;
|
||||
if($value['first'][2]!=='direktzugriff') {
|
||||
if($aktmodulekey == $key) {
|
||||
$aktiv = 1;
|
||||
}
|
||||
|
||||
if($value['first'][2]!='') {
|
||||
$this->app->Tpl->Set('FIRSTNAV',' href="#">'.$this->app->Tpl->pruefeuebersetzung($value['first'][0],'menu').'</a>');
|
||||
if($aktiv) {
|
||||
$this->app->Tpl->Set('FIRSTNAVCLASS','active');
|
||||
}
|
||||
else{
|
||||
$this->app->Tpl->Set('FIRSTNAVCLASS','');
|
||||
}
|
||||
}
|
||||
else {
|
||||
if($aktmodule == $value['first'][1]) {
|
||||
$this->app->Tpl->Set('FIRSTNAVCLASS','active');
|
||||
}
|
||||
else {
|
||||
$this->app->Tpl->Set('FIRSTNAVCLASS','');
|
||||
}
|
||||
$this->app->Tpl->Set('FIRSTNAV',' href="index.php?module='.$value['first'][1].'&top='.base64_encode($value['first'][0]).'" >'.$this->app->Tpl->pruefeuebersetzung($value['first'][0],'menu').'</a>');
|
||||
}
|
||||
}
|
||||
else {
|
||||
if($value['first'][2]!="") {
|
||||
$this->app->Tpl->Set('FIRSTNAVCLASS','navnichtdirekt');
|
||||
$this->app->Tpl->Set('FIRSTNAV',' href="#" >'.$this->app->Tpl->pruefeuebersetzung($value['first'][0],'menu').'</a>');
|
||||
}
|
||||
}
|
||||
|
||||
$this->app->Tpl->Parse('NAV','firstnav.tpl');
|
||||
if(isset($value['sec']) && count($value['sec'])>0){
|
||||
$this->app->Tpl->Add('NAV','<ul class="submenu">');
|
||||
foreach($value['sec'] as $key2 => $secnav){
|
||||
if($secnav[2]!='') {
|
||||
$this->app->Tpl->Set('SECNAV',' href="index.php?module='.$secnav[1].'&action='.$secnav[2].'&top='.base64_encode($value['first'][0]).'">'.$this->app->Tpl->pruefeuebersetzung($secnav[0],'menu').'</a>');
|
||||
if($aktmodule == $secnav[1]) {
|
||||
$this->app->Tpl->Set('BREADCRUMB','<a href="index.php?module='.$secnav[1].'&action='.$secnav[2].'&top='.base64_encode($value['first'][0]).'">'.$this->app->Tpl->pruefeuebersetzung($secnav[0],'menu').'</a> ► ');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->app->Tpl->Set('SECNAV',' href="index.php?module='.$secnav[1].'&top='.base64_encode($value['first'][0]).'">'.$this->app->Tpl->pruefeuebersetzung($secnav[0],'menu').'aa</a>');
|
||||
$this->app->Tpl->Set('BREADCRUMB','<a href="index.php?module='.$secnav[1].'&top='.base64_encode($value['first'][0]).'">'.$secnav[0].'aa</a> ► ');
|
||||
}
|
||||
|
||||
if($aktmodulekey == $key && $aktactionkey == $key2)
|
||||
{
|
||||
$this->app->Tpl->Set('SECNAVCLASS','active');
|
||||
}
|
||||
else {
|
||||
$this->app->Tpl->Set('SECNAVCLASS','');
|
||||
}
|
||||
$this->app->Tpl->Parse('NAV','secnav.tpl');
|
||||
}
|
||||
$this->app->Tpl->Add('NAV','</ul></li>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
class PageBuilder
|
||||
{
|
||||
private $app;
|
||||
|
||||
function __construct($app)
|
||||
{
|
||||
$this->app = &$app;
|
||||
}
|
||||
|
||||
|
||||
function CreateGen($tplfile)
|
||||
{
|
||||
$widgets = $this->app->Tpl->GetVars("pages/content/_gen/".$tplfile);
|
||||
$this->CreatePage($widgets,$tplfile);
|
||||
}
|
||||
|
||||
function Create($tplfile)
|
||||
{
|
||||
$widgets = $this->app->Tpl->GetVars("pages/content/".$tplfile);
|
||||
$this->CreatePage($widgets,$tplfile);
|
||||
}
|
||||
|
||||
|
||||
function CreatePage($widgets,$tplfile)
|
||||
{
|
||||
if(count($widgets)>0){
|
||||
foreach($widgets as $key=>$varname) {
|
||||
// pruefen ob es ein widget sein soll
|
||||
if(preg_match("/^[\[]WIDGET_/",$varname)) {
|
||||
$classname = "";
|
||||
$varname = str_replace('[','',$varname);
|
||||
$varname = str_replace(']','',$varname);
|
||||
if(count(explode('_',$varname))>3)
|
||||
{
|
||||
list($type,$classname,$tmp,$action)=explode('_',$varname);
|
||||
$classname = $classname."_".$tmp;
|
||||
}
|
||||
else {
|
||||
list($type,$classname,$action)=explode('_',$varname);
|
||||
}
|
||||
// pruefe ob es ein abgeleitetes gibt wenn nicht starte das generierte
|
||||
$classnamecustom = $classname.'Custom';
|
||||
$filenamecustom = strtolower($classname.'_custom');
|
||||
if(file_exists("widgets/widget.".$filenamecustom.".php")) {
|
||||
$classname = "Widget".ucfirst(strtolower($classname)).'Custom';
|
||||
$filename = "widget.".$filenamecustom.".php";
|
||||
include_once("widgets/$filename");
|
||||
}elseif(file_exists("widgets/widget.".strtolower($classname).".php")) {
|
||||
$filename = "widget.".strtolower($classname).".php";
|
||||
$classname = "Widget".ucfirst(strtolower($classname));
|
||||
$action = ucfirst(strtolower($action));
|
||||
include_once("widgets/$filename");
|
||||
} else {
|
||||
$filename = "widget.gen.".strtolower($classname).".php";
|
||||
$classname = "WidgetGen".ucfirst(strtolower($classname));
|
||||
|
||||
$action = ucfirst(strtolower($action));
|
||||
include_once("widgets/_gen/$filename");
|
||||
}
|
||||
|
||||
$mywidget = new $classname($this->app,$varname);
|
||||
$mywidget->$action();
|
||||
// $mywidget->__destruct();
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->app->Tpl->Parse('PAGE',$tplfile);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
|
||||
/// special layer for webapplications
|
||||
class phpWFAPI
|
||||
{
|
||||
function __construct(&$app)
|
||||
{
|
||||
$this->app=&$app;
|
||||
}
|
||||
|
||||
function ReBuildPageFrame()
|
||||
{
|
||||
$this->app->Tpl->ResetParser();
|
||||
$this->BuildPageFrame();
|
||||
}
|
||||
|
||||
|
||||
function BuildPageFrame()
|
||||
{
|
||||
$this->app->Tpl->ReadTemplatesFromPath(__DIR__."/../defaulttemplates/");
|
||||
|
||||
// build template tree
|
||||
$this->app->Page->LoadTheme($this->app->WFconf['defaulttheme']);
|
||||
|
||||
if($this->app->User->GetType()=="")
|
||||
$this->app->Page->CreateNavigation($this->app->WFconf['menu'][$this->app->WFconf['defaultgroup']]);
|
||||
else
|
||||
$this->app->Page->CreateNavigation($this->app->WFconf['menu'][$this->app->User->GetType()]);
|
||||
|
||||
// start acutally application instance
|
||||
$this->app->Tpl->ReadTemplatesFromPath("pages/content/_gen");
|
||||
$this->app->Tpl->ReadTemplatesFromPath("pages/content/");
|
||||
}
|
||||
|
||||
|
||||
function StartRequestedCommand()
|
||||
{
|
||||
$defaultpage = $this->app->WFconf['defaultpage'];
|
||||
$defaultpageaction = $this->app->WFconf['defaultpageaction'];
|
||||
|
||||
$module = $this->app->Secure->GetGET('module','alpha');
|
||||
$action = $this->app->Secure->GetGET('action','alpha');
|
||||
|
||||
if(!file_exists("pages/".$module.".php"))
|
||||
$module = $defaultpage;
|
||||
|
||||
if($action=="")
|
||||
$action = $defaultpageaction;
|
||||
|
||||
if(!$this->app->acl->Check($this->app->User->GetType(),$module,$action))
|
||||
return;
|
||||
|
||||
|
||||
// start module
|
||||
if(file_exists("pages/".$module.".php"))
|
||||
{
|
||||
include("pages/".$module.".php");
|
||||
//create dynamical an object
|
||||
$constr=strtoupper($module[0]).substr($module, 1);
|
||||
$myApp = new $constr($this->app);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $this->app->WFM->Error("Module <b>$module</b> doesn't exists in pages/");
|
||||
|
||||
}
|
||||
$this->app->acl->CheckTimeOut();
|
||||
}
|
||||
|
||||
/// mit dem "erstellen Formular" einfach bearbeiten liste + formular anzeigen
|
||||
function EasyTableList($tablename,$cols,$parsetarget,$pkname,$delmsg,$delmsgcol)
|
||||
{
|
||||
// show list
|
||||
|
||||
// create html table
|
||||
$table = new HTMLTable("0","100%");
|
||||
$table->AddRowAsHeading($cols);
|
||||
|
||||
$all = $this->app->DB->SelectTable($tablename,$cols);
|
||||
|
||||
$table->AddField($all);
|
||||
|
||||
$action = $this->app->Secure->GetGET("action","alpha");
|
||||
$module = $this->app->Secure->GetGET("module","alpha");
|
||||
|
||||
$table->AddCompleteCol(0,
|
||||
"<a href=\"index.php?module=$module&action=$action&id=%col%\">bearbeiten</a>");
|
||||
|
||||
$table->AddCompleteCol(0,
|
||||
"<a href=\"#\" onclick=\"str = confirm('{$delmsg}');
|
||||
if(str!='' & str!=null)
|
||||
window.document.location.href='index.php?module=$module&action=$action&id=%col%&formaction=delete';\">
|
||||
loeschen</a>",$delmsgcol);
|
||||
|
||||
$table->ChangingRowColors('#ffffff','#dddddd');
|
||||
|
||||
$this->app->Tpl->Set($parsetarget,$table->Get());
|
||||
}
|
||||
|
||||
function Message($msg,$parsetarget='MSGBOX')
|
||||
{
|
||||
$this->app->Tpl->Add('MSGBOXTEXT',$msg);
|
||||
$this->app->Tpl->Parse($parsetarget,"messagebox.tpl");
|
||||
}
|
||||
// emailvorlage aus db senden
|
||||
|
||||
function EmailFromTemplate($template,$to,$values)
|
||||
{
|
||||
$betreff = $this->app->DB->Select("SELECT betreff
|
||||
FROM emailvorlagen WHERE name='$template' LIMIT 1");
|
||||
|
||||
$nachricht = $this->app->DB->Select("SELECT nachricht
|
||||
FROM emailvorlagen WHERE name='$template' LIMIT 1");
|
||||
|
||||
if(count($values) > 0)
|
||||
{
|
||||
foreach($values as $key=>$value)
|
||||
{
|
||||
$nachricht = str_replace("%".$key."%",$value,$nachricht);
|
||||
$betreff = str_replace("%".$key."%",$value,$betreff);
|
||||
}
|
||||
}
|
||||
|
||||
$nachricht = str_replace('#BR#',"\n",$nachricht);
|
||||
mail($to,$betreff,$nachricht,"From: ActConnect Team <info@actconnect.de>");
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Login + Accesslayer for OTP Keys
|
||||
*
|
||||
* @package picosafeaes
|
||||
* @subpackage class.picosafe.php
|
||||
* @author WaWision GmbH
|
||||
* @version 1.0
|
||||
* ...
|
||||
*/
|
||||
|
||||
class PicosafeLogin {
|
||||
|
||||
var $error_message;
|
||||
var $timestamp_valid_password;
|
||||
|
||||
var $user_aes;
|
||||
var $user_datablock;
|
||||
var $user_counter;
|
||||
|
||||
var $last_valid_counter;
|
||||
|
||||
function __construct($timezone="Europe/Berlin")
|
||||
{
|
||||
// time zone for server + picosafe aes
|
||||
date_default_timezone_set($timezone);
|
||||
|
||||
// 3 minutes
|
||||
$this->seconds_valid_password=180;
|
||||
}
|
||||
|
||||
// please overload these methods
|
||||
function GetUserAES()
|
||||
{
|
||||
// PLEASE FILL WITH YOUR DATA!!
|
||||
|
||||
// 32 signs
|
||||
//return "soopu9goBoay9vongooth2ooLu8keed1";
|
||||
return $this->user_aes;//"soopu9goBoay9vongooth2ooLu8keed1";
|
||||
}
|
||||
|
||||
function GetUserCounter()
|
||||
{
|
||||
// PLEASE FILL WITH YOUR DATA!!
|
||||
return $this->user_counter;//179;
|
||||
}
|
||||
|
||||
function GetUserDatablock()
|
||||
{
|
||||
// PLEASE FILL WITH YOUR DATA!!
|
||||
// 10 signs
|
||||
return $this->user_datablock;//"eeng5jo7th";
|
||||
}
|
||||
|
||||
function SetUserLastCounter($username,$counter)
|
||||
{
|
||||
// PLEASE FILL WITH YOUR DATA!!
|
||||
// set internal counter from user to new value givn from givenOtp
|
||||
}
|
||||
|
||||
function IsPicosafeLocked($username)
|
||||
{
|
||||
// PLEASE FILL WITH YOUR DATA!!
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function GetServerTimestamp()
|
||||
{
|
||||
// instead of the local time function a server time or something other can be used
|
||||
date_default_timezone_set("UTC");
|
||||
return time();
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
// or use set methods to load user values from external
|
||||
|
||||
function SetUserAES($aes)
|
||||
{
|
||||
$this->user_aes = $aes;
|
||||
}
|
||||
|
||||
function SetUserDatablock($datablock)
|
||||
{
|
||||
$this->user_datablock = $datablock;
|
||||
}
|
||||
|
||||
|
||||
function SetUserCounter($counter)
|
||||
{
|
||||
$this->user_counter = $counter;
|
||||
}
|
||||
|
||||
|
||||
function GetLastValidCounter()
|
||||
{
|
||||
return $this->last_valid_counter;
|
||||
}
|
||||
|
||||
|
||||
/************************************************/
|
||||
|
||||
function LoginOTP($givenOtp)//,$aes,$datablock,$counter)//$username)
|
||||
{
|
||||
$aes = $this->GetUserAES();
|
||||
|
||||
// $aes = substr($server_aes, 0, 32);
|
||||
// $data = substr($server_aes, 32, 10);
|
||||
|
||||
$counter = $this->GetUserCounter();
|
||||
$data = $this->GetUserDatablock();
|
||||
$locked = $this->IsPicosafeLocked();
|
||||
|
||||
|
||||
// check if device is locked? perhaps the user lost his device ....
|
||||
if($locked)
|
||||
{
|
||||
$this->error_message = "Picosafe is locked";
|
||||
return false;
|
||||
}
|
||||
$datablock = null;
|
||||
$result = $this->ParseOTP($givenOtp,$aes,$datablock);
|
||||
|
||||
//check if is the right aes for the given user
|
||||
if($result['datablock']!=$datablock && $datablock!="")
|
||||
{
|
||||
$this->error_message = "Wrong Key to given username";
|
||||
return false;
|
||||
}
|
||||
|
||||
// server counter is greater than aes counter
|
||||
if($result['counter'] < $counter)
|
||||
{
|
||||
$this->error_message = "Server counter is greater than aes counter";
|
||||
return false;
|
||||
}
|
||||
|
||||
// time differences
|
||||
$time_diff_abs_between_aes_server = abs($this->GetServerTimestamp() - $result['timestamp']);
|
||||
|
||||
if($time_diff_abs_between_aes_server > $this->seconds_valid_password)
|
||||
{
|
||||
$this->error_message = "Time difference between server and aes greater than ".$this->seconds_valid_password." seconds";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update Counter in server
|
||||
//$this->SetUserLastCounter($username,$result['counter']);
|
||||
$this->last_valid_counter = $result['counter'];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function ParseOTP($givenOtp,$aes,$datablock = null)
|
||||
{
|
||||
// base64 Kodierung des Sticks korrigieren
|
||||
$givenOtp = rtrim($givenOtp);
|
||||
|
||||
// Sonderzeichen in korrekte Sonderzeichen umwandeln
|
||||
// (diese werden vom Stick anders vorgegeben, um von
|
||||
// unterschiedl. Tastaturlayouts unabhängig zu werden)
|
||||
$cgivenOtp = strlen($givenOtp);
|
||||
for($i = 0; $i < $cgivenOtp; $i++) {
|
||||
if($givenOtp[$i] == "!") { $givenOtp[$i] = "/"; }
|
||||
elseif($givenOtp[$i] == ".") { $givenOtp[$i] = "="; }
|
||||
elseif($givenOtp[$i] == "-") { $givenOtp[$i] = "+"; }
|
||||
}
|
||||
|
||||
// erstes Zeichen pruefen ob z oder y
|
||||
// abhaengig davon alle y durch z ersetzen und umgekehrt
|
||||
$z = $givenOtp[0];
|
||||
$crypted = substr($givenOtp, 1);
|
||||
|
||||
if($z == "y" or $z == "Y") {
|
||||
$ccrypted = strlen($crypted);
|
||||
for($i = 0; $i < $ccrypted; $i++) {
|
||||
if ($crypted[$i] == 'y') { $crypted[$i] = "z"; }
|
||||
elseif($crypted[$i] == 'Y') { $crypted[$i] = "Z"; }
|
||||
elseif($crypted[$i] == 'z') { $crypted[$i] = "y"; }
|
||||
elseif($crypted[$i] == 'Z') { $crypted[$i] = "Y"; }
|
||||
}
|
||||
}
|
||||
|
||||
if($z == "Y" or $z == "Z") {
|
||||
$ccrypted = strlen($crypted);
|
||||
for($i = 0; $i < $ccrypted; $i++) {
|
||||
if(ctype_upper($crypted[$i])) {
|
||||
$crypted[$i] = strtolower($crypted[$i]);
|
||||
} else {
|
||||
$crypted[$i] = strtoupper($crypted[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$crypted = base64_decode($crypted);
|
||||
// gegebenes One Time Passwort mit AES entschluesseln
|
||||
$td = mcrypt_module_open("rijndael-128", "", "ecb", "");
|
||||
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_DEV_URANDOM);
|
||||
mcrypt_generic_init($td, $aes, $iv);
|
||||
$plain = mdecrypt_generic($td, $crypted);
|
||||
|
||||
|
||||
// aktueller Zaehlstand
|
||||
$i = substr($plain, 0,1);
|
||||
$j = substr($plain, 1,1);
|
||||
$n = ord($i) + (ord($j) << 8);
|
||||
$timestamp = (ord($plain[12]) << 24) + (ord($plain[13]) << 16) + (ord($plain[14]) << 8) + ord($plain[15]);
|
||||
|
||||
// entschluesseltes Passwort aufteilen in
|
||||
// und Datenblock
|
||||
$plain = substr($plain, 2, 10);
|
||||
|
||||
$result['counter']=$n;
|
||||
$result['datablock']=$plain;
|
||||
$result['timestamp']=$timestamp;
|
||||
|
||||
|
||||
/*
|
||||
echo "<br>";
|
||||
echo "Nummer: " . $n . "<br>";
|
||||
echo "Datenblock: " . $plain . " (" . $data . ") <br>";
|
||||
echo "Timestamp: " . $timestamp . "<br>";
|
||||
echo "Datetime: " . date("d.m.Y H:i:s",$timestamp) . "<br>";
|
||||
*/
|
||||
//printf("4 Byte: %x \n", substr($plain,10));
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,340 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
/// Secure Layer, SQL Inject. Check, Syntax Check
|
||||
class Secure
|
||||
{
|
||||
public $GET;
|
||||
public $POST;
|
||||
|
||||
/**
|
||||
* Secure constructor.
|
||||
*
|
||||
* @param ApplicationCore $app
|
||||
*/
|
||||
public function __construct($app){
|
||||
$this->app = $app;
|
||||
// clear global variables, that everybody have to go over secure layer
|
||||
$this->GET = $_GET;
|
||||
if(isset($this->GET['msgs']) && isset($this->app->Location)) {
|
||||
$this->GET['msg'] = $this->app->Location->getMessage($this->GET['msgs']);
|
||||
}
|
||||
// $_GET="";
|
||||
$this->POST = $_POST;
|
||||
// $_POST="";
|
||||
if(!isset($this->app->stringcleaner) && file_exists(__DIR__. '/class.stringcleaner.php')) {
|
||||
if(!class_exists('StringCleaner')) {
|
||||
require_once __DIR__ . '/class.stringcleaner.php';
|
||||
}
|
||||
$this->app->stringcleaner = new StringCleaner($this->app);
|
||||
}
|
||||
|
||||
$this->AddRule('notempty','reg','.'); // at least one sign
|
||||
$this->AddRule('alpha','reg','[a-zA-Z]');
|
||||
$this->AddRule('digit','reg','[0-9]');
|
||||
$this->AddRule('space','reg','[ ]');
|
||||
$this->AddRule('specialchars','reg','[_-]');
|
||||
$this->AddRule('email','reg','^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$');
|
||||
$this->AddRule('datum','reg','([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})');
|
||||
|
||||
$this->AddRule('username','glue','alpha+digit');
|
||||
$this->AddRule('password','glue','alpha+digit+specialchars');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param null $rule
|
||||
* @param string $maxlength
|
||||
* @param string $sqlcheckoff
|
||||
*
|
||||
* @return array|mixed|string
|
||||
*/
|
||||
public function GetGET($name,$rule=null,$maxlength='',$sqlcheckoff='')
|
||||
{
|
||||
if($name === 'msg' && isset($this->app->erp) && method_exists($this, 'xss_clean')) {
|
||||
$ret = $this->Syntax(isset($this->GET[$name])?$this->GET[$name]:'','',$maxlength,$sqlcheckoff);
|
||||
$ret = $this->app->erp->base64_url_decode($ret);
|
||||
if(strpos($ret,'"button"') === false){
|
||||
$ret = $this->xss_clean($ret);
|
||||
}
|
||||
|
||||
return $this->app->erp->base64_url_encode($ret);
|
||||
}
|
||||
if($rule === null) {
|
||||
$rule = $this->NameToRule($name);
|
||||
}
|
||||
return $this->Syntax(isset($this->GET[$name])?$this->GET[$name]:'',$rule,$maxlength,$sqlcheckoff);
|
||||
}
|
||||
|
||||
function NameToRule($name)
|
||||
{
|
||||
switch($name)
|
||||
{
|
||||
case 'id':
|
||||
return 'doppelid';
|
||||
break;
|
||||
case 'sid':
|
||||
return 'alphadigits';
|
||||
break;
|
||||
case 'module':
|
||||
case 'smodule':
|
||||
case 'action':
|
||||
case 'saction':
|
||||
return 'module';
|
||||
break;
|
||||
case 'cmd':
|
||||
return 'moduleminus';
|
||||
break;
|
||||
}
|
||||
return 'nothtml';
|
||||
}
|
||||
|
||||
public function GetPOST($name,$rule=null,$maxlength="",$sqlcheckoff="")
|
||||
{
|
||||
if($rule === null) {
|
||||
$rule = $this->NameToRule($name);
|
||||
if(isset($this->POST['ishtml_cke_'.$name]) && $this->POST['ishtml_cke_'.$name]) {
|
||||
$rule = 'nojs';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->Syntax(isset($this->POST[$name])?$this->POST[$name]:'',$rule,$maxlength,$sqlcheckoff);
|
||||
}
|
||||
|
||||
public function GetPOSTForForms($name,$rule="",$maxlength="",$sqlcheckoff="")
|
||||
{
|
||||
return $this->SyntaxForForms($this->POST[$name],$rule,$maxlength,$sqlcheckoff);
|
||||
}
|
||||
|
||||
public function CleanString($string, $rule='nohtml',$sqlcheckoff='')
|
||||
{
|
||||
return $this->Syntax($string, $rule, '', $sqlcheckoff);
|
||||
}
|
||||
|
||||
public function xss_clean($data)
|
||||
{
|
||||
return $this->app->stringcleaner->xss_clean($data);
|
||||
}
|
||||
|
||||
public function GetPOSTArray()
|
||||
{
|
||||
if(!empty($this->POST) && count($this->POST)>0)
|
||||
{
|
||||
foreach($this->POST as $key=>$value)
|
||||
{
|
||||
$key = $this->GetPOST($key,"alpha+digit+specialchars",20);
|
||||
$ret[$key]=$this->GetPOST($value);
|
||||
}
|
||||
}
|
||||
if(!empty($ret))
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function GetGETArray()
|
||||
{
|
||||
if(!empty($this->GET) && count($this->GET)>0)
|
||||
{
|
||||
foreach($this->GET as $key=>$value)
|
||||
{
|
||||
$key = $this->GetGET($key,"alpha+digit+specialchars",20);
|
||||
$ret[$key]=$this->GetGET($value);
|
||||
}
|
||||
}
|
||||
if(!empty($ret))
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function stripallslashes($string) {
|
||||
|
||||
while(strstr($string,'\\')) {
|
||||
$string = stripslashes($string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function smartstripslashes($str) {
|
||||
$cd1 = substr_count($str, "\"");
|
||||
$cd2 = substr_count($str, "\\\"");
|
||||
$cs1 = substr_count($str, "'");
|
||||
$cs2 = substr_count($str, "\\'");
|
||||
$tmp = strtr($str, array("\\\"" => "", "\\'" => ""));
|
||||
$cb1 = substr_count($tmp, "\\");
|
||||
$cb2 = substr_count($tmp, "\\\\");
|
||||
if ($cd1 == $cd2 && $cs1 == $cs2 && $cb1 == 2 * $cb2) {
|
||||
return strtr($str, array("\\\"" => "\"", "\\'" => "'", "\\\\" => "\\"));
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function SyntaxForForms($value,$rule,$maxlength="",$sqlcheckoff="")
|
||||
{
|
||||
return $value;//mysqli_real_escape_string($this->app->DB->connection,$value);//mysqli_real_escape_string($value);
|
||||
}
|
||||
|
||||
// check actual value with given rule
|
||||
public function Syntax($value,$rule,$maxlength='',$sqlcheckoff='')
|
||||
{
|
||||
$striptags = false;
|
||||
if(is_array($value))
|
||||
{
|
||||
if($sqlcheckoff != '')
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
foreach($value as $k => $v)
|
||||
{
|
||||
if(is_array($v))
|
||||
{
|
||||
$value[$k] = $v;
|
||||
}else{
|
||||
$v = str_replace("\xef\xbb\xbf","NONBLOCKINGZERO",$v);
|
||||
if($striptags){
|
||||
$v = $this->stripallslashes($v);
|
||||
$v = $this->smartstripslashes($v);
|
||||
$v = $this->app->erp->superentities($v);
|
||||
}
|
||||
$value[$k] = $this->app->DB->real_escape_string($v);
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
$value = str_replace("\xef\xbb\xbf","NONBLOCKINGZERO",$value);
|
||||
|
||||
if($striptags){
|
||||
$value = $this->stripallslashes($value);
|
||||
$value = $this->smartstripslashes($value);
|
||||
|
||||
$value = $this->app->erp->superentities($value);
|
||||
}
|
||||
|
||||
if(!empty($this->app->stringcleaner)) {
|
||||
if( $sqlcheckoff == '') {
|
||||
return $this->app->DB->real_escape_string($this->app->stringcleaner->CleanString($value, $rule));
|
||||
}
|
||||
return $this->app->stringcleaner->CleanString($value, $rule);
|
||||
}
|
||||
|
||||
if($rule === 'nohtml') {
|
||||
if( $sqlcheckoff == '') {
|
||||
return $this->app->DB->real_escape_string(strip_tags($value));
|
||||
}
|
||||
|
||||
return strip_tags($value);
|
||||
|
||||
}
|
||||
if($rule === 'nojs') {
|
||||
if( $sqlcheckoff == '') {
|
||||
return $this->app->DB->real_escape_string($this->xss_clean($value));
|
||||
}
|
||||
|
||||
return $this->xss_clean($value);
|
||||
}
|
||||
|
||||
if($rule=='' && $sqlcheckoff == '') {
|
||||
return $this->app->DB->real_escape_string($value);//mysqli_real_escape_string($value);
|
||||
}
|
||||
if($rule=='' && $sqlcheckoff != '') {
|
||||
return $value;
|
||||
}
|
||||
|
||||
// build complete regexp
|
||||
|
||||
// check if rule exists
|
||||
|
||||
if($this->GetRegexp($rule)!=''){
|
||||
//$v = '/^['.$this->GetRegexp($rule).']+$/';
|
||||
$v = $this->GetRegexp($rule);
|
||||
if (preg_match_all('/'.$v.'/i', $value, $teffer) ) {
|
||||
if($sqlcheckoff==''){
|
||||
return $this->app->DB->real_escape_string($value);//mysqli_real_escape_string($value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
echo "<table border=\"1\" width=\"100%\" bgcolor=\"#FFB6C1\">
|
||||
<tr><td>Rule <b>$rule</b> doesn't exists!</td></tr></table>";
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
function RuleCheck($value,$rule)
|
||||
{
|
||||
$found = false;
|
||||
if(!empty($this->app->stringcleaner)) {
|
||||
$value_ = $this->app->stringcleaner->RuleCheck($value, $rule, $found);
|
||||
if($found) {
|
||||
if($value_) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$v = $this->GetRegexp($rule);
|
||||
if (preg_match_all('/'.$v.'/i', $value, $teffer) ){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function AddRule($name,$type,$rule)
|
||||
{
|
||||
// type: reg = regular expression
|
||||
// type: glue ( already exists rules copy to new e.g. number+digit)
|
||||
$this->rules[$name]=array('type'=>$type,'rule'=>$rule);
|
||||
}
|
||||
|
||||
// get complete regexp by rule name
|
||||
function GetRegexp($rule)
|
||||
{
|
||||
$rules = explode('+',$rule);
|
||||
$ret = '';
|
||||
foreach($rules as $key) {
|
||||
// check if rule is last in glue string
|
||||
if($this->rules[$key]['type']==='glue') {
|
||||
$subrules = explode('+',$this->rules[$key]['rule']);
|
||||
if(count($subrules)>0) {
|
||||
foreach($subrules as $subkey) {
|
||||
$ret .= $this->GetRegexp($subkey);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($this->rules[$key]['type']==='reg') {
|
||||
$ret .= $this->rules[$key]['rule'];
|
||||
}
|
||||
}
|
||||
if($ret==''){
|
||||
$ret = 'none';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,443 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
class WawiString
|
||||
{
|
||||
|
||||
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
function Convert($value,$input,$output)
|
||||
{
|
||||
if($input=="")
|
||||
return $value;
|
||||
|
||||
|
||||
/*if (strpos($a, '\\') !== false)
|
||||
$input = str_replace('/','\/',$input);*/
|
||||
|
||||
$array = $this->FindPercentValues($input);
|
||||
$regexp = $this->BuildRegExp($array);
|
||||
|
||||
$elements =
|
||||
preg_split($regexp,$value,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
// input und elements stimmmen ueberein
|
||||
|
||||
$newout = $output;
|
||||
$i = 0;
|
||||
foreach($array as $key=>$value)
|
||||
{
|
||||
$newout = str_replace($key,isset($elements[$i])?$elements[$i]:'',$newout);
|
||||
$i++;
|
||||
}
|
||||
return $newout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function removeUtf8Bom($string) {
|
||||
if(!is_string($string) || strlen($string)< 3) {
|
||||
return $string;
|
||||
}
|
||||
if(ord($string[0]) === 239 && ord($string[1]) === 187 && ord($string[2]) === 191) {
|
||||
return substr($string,3);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
function BuildRegExp($array)
|
||||
{
|
||||
|
||||
$regexp = '/^';
|
||||
foreach($array as $value)
|
||||
{
|
||||
$value = str_replace('.','\.',$value);
|
||||
$value = str_replace('+','\+',$value);
|
||||
$value = str_replace('*','\*',$value);
|
||||
$value = str_replace('?','\?',$value);
|
||||
$regexp .= '(\S+)'.$value;
|
||||
}
|
||||
$regexp .= '/';
|
||||
|
||||
return $regexp;
|
||||
}
|
||||
|
||||
function FindPercentValues($pattern)
|
||||
{
|
||||
preg_match_all('/(?:(%[0-9]+)|.)/i', $pattern, $matches);
|
||||
$hash = '';
|
||||
$collect = '';
|
||||
$start = true;
|
||||
foreach($matches[1] as $key=>$value)
|
||||
{
|
||||
if($value=="")
|
||||
$collecting = true;
|
||||
else
|
||||
{
|
||||
$collecting = false;
|
||||
$oldhash = isset($hash)?$hash:null;
|
||||
$hash = $value;
|
||||
}
|
||||
|
||||
if(!$collecting)
|
||||
{
|
||||
if(!$start)
|
||||
$replace[$oldhash] = $collect;
|
||||
$collect="";
|
||||
}
|
||||
else
|
||||
$collect .=$matches[0][$key];
|
||||
$start = false;
|
||||
}
|
||||
$replace[$hash] = $collect;
|
||||
return $replace;
|
||||
}
|
||||
|
||||
function encodeText($string)
|
||||
{
|
||||
$string = str_replace("\\r\\n","#BR#",$string);
|
||||
$string = str_replace("\n","#BR#",$string);
|
||||
$encoded = htmlspecialchars(stripslashes($string), ENT_QUOTES);
|
||||
|
||||
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
function decodeText($_str, $_form=true)
|
||||
{
|
||||
if ($_form) {
|
||||
$_str = str_replace("#BR#", "\r\n", $_str);
|
||||
}
|
||||
else {
|
||||
$_str = str_replace("#BR#", "<br>", $_str);
|
||||
}
|
||||
return($_str);
|
||||
}
|
||||
|
||||
function valid_utf8( $string )
|
||||
{
|
||||
return !((bool)preg_match('~\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF\xC0\xC1~ms',$string));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fixeUmlaute($text) {
|
||||
if(!is_string($text)) {
|
||||
return $text;
|
||||
}
|
||||
$umlaute = $this->getUmlauteArray();
|
||||
|
||||
return str_replace(array_keys($umlaute),array_values($umlaute), $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getUmlauteArray() {
|
||||
return array( 'ü'=>'ü', 'ä'=>'ä', 'ö'=>'ö', 'Ö'=>'Ö', 'Ã?'=>'ß','ß'=>'ß', 'à '=>'à', 'á'=>'á', 'â'=>'â', 'ã'=>'ã', 'ù'=>'ù', 'ú'=>'ú', 'û'=>'û', 'Ù'=>'Ù', 'Ú'=>'Ú', 'Û'=>'Û', 'Ü'=>'Ü', 'ò'=>'ò', 'ó'=>'ó', 'ô'=>'ô', 'è'=>'è', 'é'=>'é', 'ê'=>'ê', 'ë'=>'ë', 'À'=>'À', 'Ã<81>'=>'Á', 'Â'=>'Â', 'Ã'=>'Ã', 'Ä'=>'Ä', 'Ã…'=>'Å', 'Ç'=>'Ç', 'È'=>'È', 'É'=>'É', 'Ê'=>'Ê', 'Ë'=>'Ë', 'ÃŒ'=>'Ì', 'Ã<8d>'=>'Í', 'ÃŽ'=>'Î', 'Ã<8f>'=>'Ï', 'Ñ'=>'Ñ', 'Ã’'=>'Ò', 'Ó'=>'Ó', 'Ô'=>'Ô', 'Õ'=>'Õ', 'Ø'=>'Ø', 'Ã¥'=>'å', 'æ'=>'æ', 'ç'=>'ç', 'ì'=>'ì', 'Ã'=>'í', 'î'=>'î', 'ï'=>'ï', 'ð'=>'ð', 'ñ'=>'ñ', 'õ'=>'õ', 'ø'=>'ø', 'ý'=>'ý', 'ÿ'=>'ÿ', '€'=>'€' );
|
||||
}
|
||||
|
||||
|
||||
function unicode_decode($content) {
|
||||
$ISO10646XHTMLTrans = array(
|
||||
"&"."#34;" => """,
|
||||
"&"."#38;" => "&",
|
||||
"&"."#39;" => "'",
|
||||
"&"."#60;" => "<",
|
||||
"&"."#62;" => ">",
|
||||
"&"."#128;" => "€",
|
||||
"&"."#160;" => "",
|
||||
"&"."#161;" => "¡",
|
||||
"&"."#162;" => "¢",
|
||||
"&"."#163;" => "£",
|
||||
"&"."#164;" => "¤",
|
||||
"&"."#165;" => "¥",
|
||||
"&"."#166;" => "¦",
|
||||
"&"."#167;" => "§",
|
||||
"&"."#168;" => "¨",
|
||||
"&"."#169;" => "©",
|
||||
"&"."#170;" => "ª",
|
||||
"&"."#171;" => "«",
|
||||
"&"."#172;" => "¬",
|
||||
"&"."#173;" => "",
|
||||
"&"."#174;" => "®",
|
||||
"&"."#175;" => "¯",
|
||||
"&"."#176;" => "°",
|
||||
"&"."#177;" => "±",
|
||||
"&"."#178;" => "²",
|
||||
"&"."#179;" => "³",
|
||||
"&"."#180;" => "´",
|
||||
"&"."#181;" => "µ",
|
||||
"&"."#182;" => "¶",
|
||||
"&"."#183;" => "·",
|
||||
"&"."#184;" => "¸",
|
||||
"&"."#185;" => "¹",
|
||||
"&"."#186;" => "º",
|
||||
"&"."#187;" => "»",
|
||||
"&"."#188;" => "¼",
|
||||
"&"."#189;" => "½",
|
||||
"&"."#190;" => "¾",
|
||||
"&"."#191;" => "¿",
|
||||
"&"."#192;" => "À",
|
||||
"&"."#193;" => "Á",
|
||||
"&"."#194;" => "Â",
|
||||
"&"."#195;" => "Ã",
|
||||
"&"."#196;" => "Ä",
|
||||
"&"."#197;" => "Å",
|
||||
"&"."#198;" => "Æ",
|
||||
"&"."#199;" => "Ç",
|
||||
"&"."#200;" => "È",
|
||||
"&"."#201;" => "É",
|
||||
"&"."#202;" => "Ê",
|
||||
"&"."#203;" => "Ë",
|
||||
"&"."#204;" => "Ì",
|
||||
"&"."#205;" => "Í",
|
||||
"&"."#206;" => "Î",
|
||||
"&"."#207;" => "Ï",
|
||||
"&"."#208;" => "Ð",
|
||||
"&"."#209;" => "Ñ",
|
||||
"&"."#210;" => "Ò",
|
||||
"&"."#211;" => "Ó",
|
||||
"&"."#212;" => "Ô",
|
||||
"&"."#213;" => "Õ",
|
||||
"&"."#214;" => "Ö",
|
||||
"&"."#215;" => "×",
|
||||
"&"."#216;" => "Ø",
|
||||
"&"."#217;" => "Ù",
|
||||
"&"."#218;" => "Ú",
|
||||
"&"."#219;" => "Û",
|
||||
"&"."#220;" => "Ü",
|
||||
"&"."#221;" => "Ý",
|
||||
"&"."#222;" => "Þ",
|
||||
"&"."#223;" => "ß",
|
||||
"&"."#224;" => "à",
|
||||
"&"."#225;" => "á",
|
||||
"&"."#226;" => "â",
|
||||
"&"."#227;" => "ã",
|
||||
"&"."#228;" => "ä",
|
||||
"&"."#229;" => "å",
|
||||
"&"."#230;" => "æ",
|
||||
"&"."#231;" => "ç",
|
||||
"&"."#232;" => "è",
|
||||
"&"."#233;" => "é",
|
||||
"&"."#234;" => "ê",
|
||||
"&"."#235;" => "ë",
|
||||
"&"."#236;" => "ì",
|
||||
"&"."#237;" => "í",
|
||||
"&"."#238;" => "î",
|
||||
"&"."#239;" => "ï",
|
||||
"&"."#240;" => "ð",
|
||||
"&"."#241;" => "ñ",
|
||||
"&"."#242;" => "ò",
|
||||
"&"."#243;" => "ó",
|
||||
"&"."#244;" => "ô",
|
||||
"&"."#245;" => "õ",
|
||||
"&"."#246;" => "ö",
|
||||
"&"."#247;" => "÷",
|
||||
"&"."#248;" => "ø",
|
||||
"&"."#249;" => "ù",
|
||||
"&"."#250;" => "ú",
|
||||
"&"."#251;" => "û",
|
||||
"&"."#252;" => "ü",
|
||||
"&"."#253;" => "ý",
|
||||
"&"."#254;" => "þ",
|
||||
"&"."#255;" => "ÿ",
|
||||
"&"."#338;" => "Œ",
|
||||
"&"."#339;" => "œ",
|
||||
"&"."#352;" => "Š",
|
||||
"&"."#353;" => "š",
|
||||
"&"."#376;" => "Ÿ",
|
||||
"&"."#402;" => "ƒ",
|
||||
"&"."#710;" => "ˆ",
|
||||
"&"."#732;" => "˜",
|
||||
"&"."#913;" => "Α",
|
||||
"&"."#914;" => "Β",
|
||||
"&"."#915;" => "Γ",
|
||||
"&"."#916;" => "Δ",
|
||||
"&"."#917;" => "Ε",
|
||||
"&"."#918;" => "Ζ",
|
||||
"&"."#919;" => "Η",
|
||||
"&"."#920;" => "Θ",
|
||||
"&"."#921;" => "Ι",
|
||||
"&"."#922;" => "Κ",
|
||||
"&"."#923;" => "Λ",
|
||||
"&"."#924;" => "Μ",
|
||||
"&"."#925;" => "Ν",
|
||||
"&"."#926;" => "Ξ",
|
||||
"&"."#927;" => "Ο",
|
||||
"&"."#928;" => "Π",
|
||||
"&"."#929;" => "Ρ",
|
||||
"&"."#931;" => "Σ",
|
||||
"&"."#932;" => "Τ",
|
||||
"&"."#933;" => "Υ",
|
||||
"&"."#934;" => "Φ",
|
||||
"&"."#935;" => "Χ",
|
||||
"&"."#936;" => "Ψ",
|
||||
"&"."#937;" => "Ω",
|
||||
"&"."#945;" => "α",
|
||||
"&"."#946;" => "β",
|
||||
"&"."#947;" => "γ",
|
||||
"&"."#948;" => "δ",
|
||||
"&"."#949;" => "ε",
|
||||
"&"."#950;" => "ζ",
|
||||
"&"."#951;" => "η",
|
||||
"&"."#952;" => "θ",
|
||||
"&"."#953;" => "ι",
|
||||
"&"."#954;" => "κ",
|
||||
"&"."#955;" => "λ",
|
||||
"&"."#956;" => "μ",
|
||||
"&"."#957;" => "ν",
|
||||
"&"."#958;" => "ξ",
|
||||
"&"."#959;" => "ο",
|
||||
"&"."#960;" => "π",
|
||||
"&"."#961;" => "ρ",
|
||||
"&"."#962;" => "ς",
|
||||
"&"."#963;" => "σ",
|
||||
"&"."#964;" => "τ",
|
||||
"&"."#965;" => "υ",
|
||||
"&"."#966;" => "φ",
|
||||
"&"."#967;" => "χ",
|
||||
"&"."#968;" => "ψ",
|
||||
"&"."#969;" => "ω",
|
||||
"&"."#977;" => "ϑ",
|
||||
"&"."#978;" => "ϒ",
|
||||
"&"."#982;" => "ϖ",
|
||||
"&"."#8194;" => " ",
|
||||
"&"."#8195;" => " ",
|
||||
"&"."#8201;" => " ",
|
||||
"&"."#8204;" => "‌",
|
||||
"&"."#8205;" => "‍",
|
||||
"&"."#8206;" => "‎",
|
||||
"&"."#8207;" => "‏",
|
||||
"&"."#8211;" => "–",
|
||||
"&"."#8212;" => "—",
|
||||
"&"."#8216;" => "‘",
|
||||
"&"."#8217;" => "’",
|
||||
"&"."#8218;" => "‚",
|
||||
"&"."#8220;" => "“",
|
||||
"&"."#8221;" => "”",
|
||||
"&"."#8222;" => "„",
|
||||
"&"."#8224;" => "†",
|
||||
"&"."#8225;" => "‡",
|
||||
"&"."#8226;" => "•",
|
||||
"&"."#8230;" => "…",
|
||||
"&"."#8240;" => "‰",
|
||||
"&"."#8242;" => "′",
|
||||
"&"."#8243;" => "″",
|
||||
"&"."#8249;" => "‹",
|
||||
"&"."#8250;" => "›",
|
||||
"&"."#8254;" => "‾",
|
||||
"&"."#8260;" => "⁄",
|
||||
"&"."#8364;" => "€",
|
||||
"&"."#8465;" => "ℑ",
|
||||
"&"."#8472;" => "℘",
|
||||
"&"."#8476;" => "ℜ",
|
||||
"&"."#8482;" => "™",
|
||||
"&"."#8501;" => "ℵ",
|
||||
"&"."#8592;" => "←",
|
||||
"&"."#8593;" => "↑",
|
||||
"&"."#8594;" => "→",
|
||||
"&"."#8595;" => "↓",
|
||||
"&"."#8596;" => "↔",
|
||||
"&"."#8629;" => "↵",
|
||||
"&"."#8656;" => "⇐",
|
||||
"&"."#8657;" => "⇑",
|
||||
"&"."#8658;" => "⇒",
|
||||
"&"."#8659;" => "⇓",
|
||||
"&"."#8660;" => "⇔",
|
||||
"&"."#8704;" => "∀",
|
||||
"&"."#8706;" => "∂",
|
||||
"&"."#8707;" => "∃",
|
||||
"&"."#8709;" => "∅",
|
||||
"&"."#8711;" => "∇",
|
||||
"&"."#8712;" => "∈",
|
||||
"&"."#8713;" => "∉",
|
||||
"&"."#8715;" => "∋",
|
||||
"&"."#8719;" => "∏",
|
||||
"&"."#8721;" => "∑",
|
||||
"&"."#8722;" => "−",
|
||||
"&"."#8727;" => "∗",
|
||||
"&"."#8730;" => "√",
|
||||
"&"."#8733;" => "∝",
|
||||
"&"."#8734;" => "∞",
|
||||
"&"."#8736;" => "∠",
|
||||
"&"."#8743;" => "∧",
|
||||
"&"."#8744;" => "∨",
|
||||
"&"."#8745;" => "∩",
|
||||
"&"."#8746;" => "∪",
|
||||
"&"."#8747;" => "∫",
|
||||
"&"."#8756;" => "∴",
|
||||
"&"."#8764;" => "∼",
|
||||
"&"."#8773;" => "≅",
|
||||
"&"."#8776;" => "≈",
|
||||
"&"."#8800;" => "≠",
|
||||
"&"."#8801;" => "≡",
|
||||
"&"."#8804;" => "≤",
|
||||
"&"."#8805;" => "≥",
|
||||
"&"."#8834;" => "⊂",
|
||||
"&"."#8835;" => "⊃",
|
||||
"&"."#8836;" => "⊄",
|
||||
"&"."#8838;" => "⊆",
|
||||
"&"."#8839;" => "⊇",
|
||||
"&"."#8853;" => "⊕",
|
||||
"&"."#8855;" => "⊗",
|
||||
"&"."#8869;" => "⊥",
|
||||
"&"."#8901;" => "⋅",
|
||||
"&"."#8968;" => "⌈",
|
||||
"&"."#8969;" => "⌉",
|
||||
"&"."#8970;" => "⌊",
|
||||
"&"."#8971;" => "⌋",
|
||||
"&"."#9001;" => "⟨",
|
||||
"&"."#9002;" => "⟩",
|
||||
"&"."#9674;" => "◊",
|
||||
"&"."#9824;" => "♠",
|
||||
"&"."#9827;" => "♣",
|
||||
"&"."#9829;" => "♥",
|
||||
"&"."#9830;" => "♦"
|
||||
);
|
||||
|
||||
return str_replace(array_keys($ISO10646XHTMLTrans), array_values($ISO10646XHTMLTrans), $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ReadyForPDF($string='')
|
||||
{
|
||||
return trim(
|
||||
html_entity_decode(
|
||||
str_replace(
|
||||
['“','„','–',"’","'","NONBLOCKINGZERO"],
|
||||
['"','','-',"'","'",''],
|
||||
$string
|
||||
),
|
||||
ENT_QUOTES,
|
||||
'UTF-8'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,451 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
class StringCleaner
|
||||
{
|
||||
private $elements;
|
||||
private $htmlpuriferconfig;
|
||||
private $htmlpurifer;
|
||||
private $ruleregexps;
|
||||
/** @var Application */
|
||||
private $app;
|
||||
|
||||
/**
|
||||
* StringCleaner constructor.
|
||||
*
|
||||
* @param null|Application $app
|
||||
*/
|
||||
public function __construct($app = null)
|
||||
{
|
||||
$this->app = $app;
|
||||
if(class_exists('HTMLPurifier_Config')) {
|
||||
$this->htmlpuriferconfig = HTMLPurifier_Config::createDefault();
|
||||
$this->htmlpuriferconfig->set('Core.Encoding', 'UTF-8');
|
||||
$this->htmlpuriferconfig->set('Attr.AllowedFrameTargets', ['_blank']); // Allow hyperlinks with target="_blank"
|
||||
//$this->htmlpuriferconfig->set('HTML.AllowedElements', 'h1,h2,h3,h4,h5,h6,p,a,strong,em,ol,ul,li,img,param,div,br,form,label,fieldset,input,textarea,select,option');
|
||||
$this->htmlpurifer = new HTMLPurifier($this->htmlpuriferconfig);
|
||||
}
|
||||
$this->elements = array('nohtml'=> array('ust_befreit','abweichendelieferadresse','bestellungsart','bearbeiter','datum','lieferdatum','name','anrede','partner','packstation_inhaber','packstation_station','packstation_ident','packstation_plz','packstation_ort','partnerid','kennen','ihrebestellnummer'
|
||||
,'abteilung','unterabteilung','ansprechpartner','adresszusatz','strasse','land','bundesstaat','plz','ort','versandart','internet','transaktionsnummer','vertrieb','zahlungsweise'
|
||||
,'lieferabteilung','lieferunterabteilung','lieferansprechpartner','lieferadresszusatz','lieferstrasse','lieferland','lieferbundesstaat','lieferplz','lieferort'
|
||||
,'bank_inhaber','bank_institut','bank_blz','bank_konto'
|
||||
,'email','telefon','telefax','ustid','partner','projekt','herstellernummer','ean','nummer','name_de','name_ean'),
|
||||
'nojs' => array('anabregstext','anabregstext_en','uebersicht_de','uebersicht_en','kurztext_de','kurztext_en','internebemerkung','internebezeichnung','freitext'));
|
||||
|
||||
$this->rulechecks = array('digit'=>'/^[0-9]+$/'
|
||||
,'alpha'=>'/^[a-zA-Z]+$/'
|
||||
,'alphadigit'=>'/^[0-9a-zA-Z]+$/'
|
||||
,'username'=>'/^[0-9a-zA-Z\.\-]+$/'
|
||||
,'space'=>'/^[\x20]+$/'
|
||||
,'module'=>'/^[0-9a-zA-Z\_]$/'
|
||||
,'password'=>'/^[^\s\n]{1}[^\n]{5}.*$/'
|
||||
,'email'=>'/^[^@\s\x00-\x20]+@[^@\s\x00-\x20\.]+\.[^@\s\x00-\x20\.]+[^@\s\x00-\x20]*$/'
|
||||
);
|
||||
|
||||
$this->ruleregexps = array(
|
||||
'digit'=>'/[^0-9]/'
|
||||
,'username'=>'/[^0-9a-zA-Z\.\-]/'
|
||||
,'alpha'=>'/[^a-zA-Z]/'
|
||||
,'alphadigits'=>'/[^0-9a-zA-Z]/'
|
||||
,'module'=>'/[^0-9a-zA-Z\_]/'
|
||||
,'moduleminus'=>'/[^0-9a-zA-Z\_\-]/'
|
||||
,'alphadigitsspecial'=>'/[^0-9a-zA-Z\_\.\(\)]/'
|
||||
,'base64'=>'/[^0-9a-zA-Z\=\+\-\_\/]/'
|
||||
);
|
||||
}
|
||||
|
||||
function SyntaxByElement($key, $default = '')
|
||||
{
|
||||
foreach($this->elements as $type => $arr) {
|
||||
if(in_array($key, $arr)) {
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
function CleanSQLReturn($value, $columnname, $default = '')
|
||||
{
|
||||
if($value == '' || is_numeric($value))
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
if(in_array($columnname, array('nummer','name','kundennummer','bezeichnung','bezeichnunglieferant','lieferantennummer','mitarbeiternummer','name_de','name_en',
|
||||
'kurzbezeichnung','abkuerzung',
|
||||
'strasse','plz','ort','land','ansprechpartner','abteilung','unterabteilung',
|
||||
'liefername','lieferstrasse','lieferplz','lieferort','lieferland','lieferansprechpartner','lieferabteilung','lieferunterabteilung'))){
|
||||
return strip_tags($value);
|
||||
}
|
||||
if($default == 'xss_clean')
|
||||
{
|
||||
return $this->xss_clean($value, false);
|
||||
}
|
||||
if($this->htmlpurifer)
|
||||
{
|
||||
return $this->htmlpurifer->purify($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function RuleCheck($string, $rule = null, &$found = false)
|
||||
{
|
||||
if(isset($this->rulechecks[$rule]))
|
||||
{
|
||||
$found = true;
|
||||
return preg_match_all($this->rulechecks[$rule], $string, $dummy);
|
||||
}
|
||||
switch($rule)
|
||||
{
|
||||
case 'datum':
|
||||
$found = true;
|
||||
|
||||
if(preg_match_all('/([0-9]+)\.([0-9]+)\.$/', $string, $matches))
|
||||
{
|
||||
$string = $matches[1][0].'.'.$matches[2][0].'.'.date('Y');
|
||||
}
|
||||
|
||||
try {
|
||||
if($x = new DateTime($string)) {
|
||||
return $x->format('Y') > 0;
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CheckSQLHtml($sql)
|
||||
{
|
||||
$start = 0;
|
||||
$len = strlen($sql);
|
||||
$lvl = 0;
|
||||
$col = 0;
|
||||
$ret = array(0);
|
||||
$instring = false;
|
||||
for($i = $start; $i < $len; $i++)
|
||||
{
|
||||
$char = $sql[$i];
|
||||
switch($char)
|
||||
{
|
||||
case "'":
|
||||
if($instring)
|
||||
{
|
||||
if($sql[$i-1] != '\\')
|
||||
{
|
||||
$instring = false;
|
||||
}
|
||||
}else{
|
||||
if($sql[$i-1] != '\\'){
|
||||
$instring = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "(":
|
||||
if($instring)
|
||||
{
|
||||
|
||||
}else{
|
||||
$lvl++;
|
||||
}
|
||||
break;
|
||||
case ")":
|
||||
if($instring)
|
||||
{
|
||||
|
||||
}else{
|
||||
$lvl--;
|
||||
}
|
||||
break;
|
||||
case "<":
|
||||
if($instring)
|
||||
{
|
||||
if(preg_match('/<[a-zA-Z]/',$char.$sql[$i+1]))
|
||||
{
|
||||
if($ret[$col] != 2)
|
||||
{
|
||||
$ret[$col] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ',':
|
||||
if($instring)
|
||||
{
|
||||
|
||||
}else{
|
||||
if($lvl == 0)
|
||||
{
|
||||
$col++;
|
||||
$ret[$col] = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
case 'O':
|
||||
if($instring)
|
||||
{
|
||||
if($i < $len -4)
|
||||
{
|
||||
if(strtolower(substr($sql, $i, 2)) == 'on')
|
||||
{
|
||||
if(preg_match('/^on[a-z]+(\s*)=/', substr($sql, $i)))
|
||||
{
|
||||
$ret[$col] = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'F':
|
||||
case 'f':
|
||||
if($instring)
|
||||
{
|
||||
|
||||
}else{
|
||||
if($lvl == 0)
|
||||
{
|
||||
if($i < $len - 4)
|
||||
{
|
||||
if(strtolower(substr($sql, $i, 4)) == 'from')
|
||||
{
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$where = strripos($sql, 'where');
|
||||
$restsql = substr($sql, $i, $where - $i);
|
||||
if(preg_match('/<[a-zA-Z]/', $restsql))
|
||||
{
|
||||
if(preg_match('/on[a-z]+(\s*)=/',$restsql))
|
||||
{
|
||||
if($ret)
|
||||
{
|
||||
foreach($ret as $k => $v)
|
||||
{
|
||||
$ret[$k] = 2;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if($ret)
|
||||
{
|
||||
foreach($ret as $k => $v)
|
||||
{
|
||||
if($v != 2)
|
||||
{
|
||||
$ret[$k] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function CleanString($string, $rule = null, &$found = false)
|
||||
{
|
||||
if(is_null($rule))
|
||||
{
|
||||
$rule = 'nothml';
|
||||
}
|
||||
switch($rule)
|
||||
{
|
||||
case 'email':
|
||||
if($this->RuleCheck($string, $rule))
|
||||
{
|
||||
return $string;
|
||||
}
|
||||
return '';
|
||||
break;
|
||||
case 'nohtml':
|
||||
$found = true;
|
||||
if($string == '' || is_numeric($string))
|
||||
{
|
||||
return $string;
|
||||
}
|
||||
if(strpos($string,'<') === false)
|
||||
{
|
||||
return $string;
|
||||
}
|
||||
return strip_tags($string);
|
||||
break;
|
||||
case 'datum':
|
||||
$found = true;
|
||||
$string_ = $string;
|
||||
if(preg_match_all('/([0-9]+)\.([0-9]+)\.$/', $string, $matches))
|
||||
{
|
||||
$string_ = $matches[1][0].'.'.$matches[2][0].'.'.date('Y');
|
||||
}
|
||||
try
|
||||
{
|
||||
if($x = new DateTime($string_))
|
||||
{
|
||||
if($x->format('Y') <= 0)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return '';
|
||||
}
|
||||
return '';
|
||||
break;
|
||||
case 'xss_clean':
|
||||
$found = true;
|
||||
if($string == '' || is_numeric($string))
|
||||
{
|
||||
return $string;
|
||||
}
|
||||
if(strpos($string,'<') === false){
|
||||
return $string;
|
||||
}
|
||||
return $this->xss_clean($string, false);
|
||||
break;
|
||||
case 'nojs':
|
||||
$found = true;
|
||||
if($string == '' || is_numeric($string))return $string;
|
||||
if(strpos($string,'<') === false)return $string;
|
||||
if($this->htmlpurifer)
|
||||
{
|
||||
return $this->htmlpurifer->purify($string);
|
||||
}
|
||||
return $this->xss_clean($string);
|
||||
break;
|
||||
case 'id':
|
||||
$found = true;
|
||||
if((String)$string === '')
|
||||
{
|
||||
return $string;
|
||||
}
|
||||
return (int)$string;
|
||||
break;
|
||||
case 'doppelid':
|
||||
$found = true;
|
||||
if((String)$string === '')
|
||||
{
|
||||
return $string;
|
||||
}
|
||||
$stringa = explode('-', $string, 2);
|
||||
if(count($stringa) == 1)return (int)$stringa[0];
|
||||
return ($stringa[0]===''?'':(int)$stringa[0]).'-'.(int)$stringa[1];
|
||||
break;
|
||||
case 'module':
|
||||
$found = true;
|
||||
return preg_replace ($this->ruleregexps[$rule], '' , $string);
|
||||
break;
|
||||
default:
|
||||
if(isset($this->ruleregexps[$rule]))
|
||||
{
|
||||
$found = true;
|
||||
return preg_replace ($this->ruleregexps[$rule], '' , $string);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function xss_clean($data, $usepurify = true)
|
||||
{
|
||||
if($usepurify && !empty($this->htmlpurifer))
|
||||
{
|
||||
return $this->htmlpurifer->purify($data);
|
||||
}
|
||||
// Fix &entity\n;
|
||||
$data = str_replace(array('&','<','>'), array('&amp;','&lt;','&gt;'), $data);
|
||||
$data = preg_replace('/(&#*\w+)[\x00-\x20]+;/u', '$1;', $data);
|
||||
$data = preg_replace('/(&#x*[0-9A-F]+);*/iu', '$1;', $data);
|
||||
$data = html_entity_decode($data, ENT_COMPAT, 'UTF-8');
|
||||
return $data;
|
||||
// Remove any attribute starting with "on" or xmlns
|
||||
$data = preg_replace('#(<[^>]+?[\x00-\x20"\'])(?:on|xmlns)[^>]*+>#iu', '$1>', $data);
|
||||
|
||||
// Remove javascript: and vbscript: protocols
|
||||
$data = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([`\'"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu', '$1=$2nojavascript...', $data);
|
||||
$data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu', '$1=$2novbscript...', $data);
|
||||
$data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#u', '$1=$2nomozbinding...', $data);
|
||||
|
||||
// Only works in IE: <span style="width: expression(alert('Ping!'));"></span>
|
||||
$data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?expression[\x00-\x20]*\([^>]*+>#i', '$1>', $data);
|
||||
$data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?behaviour[\x00-\x20]*\([^>]*+>#i', '$1>', $data);
|
||||
$data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*+>#iu', '$1>', $data);
|
||||
|
||||
// Remove namespaced elements (we do not need them)
|
||||
$data = preg_replace('#</*\w+:\w[^>]*+>#i', '', $data);
|
||||
|
||||
do
|
||||
{
|
||||
// Remove really unwanted tags
|
||||
$old_data = $data;
|
||||
$data = preg_replace('#</*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#i', '', $data);
|
||||
}
|
||||
while ($old_data !== $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function XMLArray_clean(&$xml, $lvl = 0)
|
||||
{
|
||||
if(is_string($xml))
|
||||
{
|
||||
|
||||
}elseif(is_array($xml))
|
||||
{
|
||||
if(count($xml) > 0)
|
||||
{
|
||||
foreach($xml as $k => $v)
|
||||
{
|
||||
if(is_string($v))
|
||||
{
|
||||
$xml[$k] = $this->CleanString($v, $this->SyntaxByElement($k,'nojs'));
|
||||
}
|
||||
if($lvl < 10)
|
||||
{
|
||||
$this->XMLArray_clean($v, $lvl + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}elseif(is_object($xml))
|
||||
{
|
||||
if(count($xml) > 0)
|
||||
{
|
||||
foreach($xml as $k => $v)
|
||||
{
|
||||
if(count($v) > 0)
|
||||
{
|
||||
if($lvl < 10)
|
||||
{
|
||||
$this->XMLArray_clean($v, $lvl + 1);
|
||||
}
|
||||
}elseif((String)$v != '')
|
||||
{
|
||||
if(isset($xml->$k))
|
||||
{
|
||||
//$xml->$k = $this->CleanString($v, $this->SyntaxByElement($k,'nojs'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $xml;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,773 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
/****************************************************************************
|
||||
1. zu jedem Template muss es in einem anderen Template eine Variable geben
|
||||
in htmlheader.tpl PAGE fuer page.tpl
|
||||
****************************************************************************/
|
||||
|
||||
/// represent a template (file.tpl)
|
||||
class ThemeTemplate {
|
||||
var $NAME; //Name des Templates
|
||||
var $PATH; //PFAD des Templates
|
||||
var $parsed; //Zustand
|
||||
var $ORIGINAL; //Parse - Text Vorlage
|
||||
var $VARS; //assoziatives Array mit Variablennamen als Index
|
||||
var $Elements;
|
||||
var $vararraycreated;
|
||||
function __construct($_path, $_file){
|
||||
|
||||
/*
|
||||
$fp=@fopen($_path.$_file,"r");
|
||||
if($fp){
|
||||
if(filesize($_path.$_file)>0)
|
||||
$contents = fread ($fp, filesize($_path.$_file));
|
||||
fclose($fp);
|
||||
}*/
|
||||
$this->vararraycreated = false;
|
||||
$this->PATH=$_path;
|
||||
$this->NAME=$_file;
|
||||
$this->readFile();
|
||||
}
|
||||
|
||||
function readFile()
|
||||
{
|
||||
$_path = $this->PATH;
|
||||
$_file = $this->NAME;
|
||||
$fp=@fopen($_path.$_file,"r");
|
||||
if($fp){
|
||||
if(filesize($_path.$_file)>0)
|
||||
$contents = fread ($fp, filesize($_path.$_file));
|
||||
fclose($fp);
|
||||
}
|
||||
$this->ORIGINAL=isset($contents)?$contents:'';
|
||||
//$this->CreateVarArray();
|
||||
}
|
||||
|
||||
|
||||
function CreateVarArray(){
|
||||
$this->vararraycreated = true;
|
||||
$this->SetVar("",'');
|
||||
$pattern = '/((\[[A-Z0-9_]+\]))/';
|
||||
preg_match_all($pattern,$this->ORIGINAL,$matches, PREG_OFFSET_CAPTURE);
|
||||
if(!$matches)return;
|
||||
//TODO Parser umbauen, damit Variablen nicht doppelt genommen werden.
|
||||
if(count($matches[0]) > 0)
|
||||
{
|
||||
$cmatches = count($matches[0]);
|
||||
for($i=0;$i<$cmatches;$i++)
|
||||
{
|
||||
$this->Elements[$i]['before'] = substr($this->ORIGINAL, $i==0?0:($matches[0][$i-1][1] +strlen($matches[0][$i-1][0]) ), $matches[0][$i][1] - ($i==0 ?0 : ($matches[0][$i-1][1]+strlen($matches[0][$i-1][0])) ) );
|
||||
$this->Elements[$i]['el'] = $matches[0][$i][0];
|
||||
$this->Elements[$i]['el'] = str_replace('[','',$this->Elements[$i]['el']);
|
||||
$this->Elements[$i]['el'] = str_replace(']','',$this->Elements[$i]['el']);
|
||||
if($i > 0)$this->Elements[$i-1]['nach'] = $this->Elements[$i]['before'];
|
||||
}
|
||||
$this->Elements[count($matches[0])-1]['nach'] = substr($this->ORIGINAL, $matches[0][count($matches[0])-1][1]+strlen($matches[0][count($matches[0])-1][0]));
|
||||
for($i=0;$i<$cmatches;$i++)
|
||||
{
|
||||
$matches[0][$i][0] = str_replace('[','',$matches[0][$i][0]);
|
||||
$matches[0][$i][0] = str_replace(']','',$matches[0][$i][0]);
|
||||
if(!isset($this->VARS[$matches[0][$i][0]]))
|
||||
{
|
||||
$this->SetVar($matches[0][$i][0],'');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Parsed()
|
||||
{
|
||||
return 1;
|
||||
if($this->parsed!=1)
|
||||
{
|
||||
$fp=@fopen($this->PATH.$this->NAME,"r");
|
||||
if($fp){
|
||||
$contents = fread ($fp, filesize($this->PATH.$this->FILE));
|
||||
fclose($fp);
|
||||
}
|
||||
$this->ORIGINAL=$contents;
|
||||
$this->CreateVarArray();
|
||||
|
||||
}
|
||||
$this->parsed=1;
|
||||
}
|
||||
|
||||
function AddVar($_var, $_value){ $this->VARS[$_var]=$this->VARS[$_var].$_value; }
|
||||
function SetVar($_var, $_value){ $this->VARS[$_var]=$_value; }
|
||||
|
||||
}
|
||||
|
||||
/*********************** Class PcmsTemplate ****************************/
|
||||
/// Main Parser for building the html skin (gui)
|
||||
class TemplateParser {
|
||||
var $TEMPLATELIST;
|
||||
var $VARARRAY;
|
||||
var $VARVARARRAY;
|
||||
|
||||
|
||||
/**
|
||||
* TemplateParser constructor.
|
||||
*
|
||||
* @param Application $app
|
||||
*/
|
||||
public function __construct($app){
|
||||
$this->app = $app;
|
||||
$this->TEMPLATELIST=null;
|
||||
$this->VARVARARRAY = null;
|
||||
}
|
||||
|
||||
public function htmlspecialchars($value)
|
||||
{
|
||||
$value = str_replace(array('ö','ä','ü','Ö','&Auuml;','Ü','ß'),array('ö','ä','ü','Ö','Ä','Ü','ß'),$value);
|
||||
$value = htmlspecialchars($value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function addTextLink($_var, $link, $text, $target = null)
|
||||
{
|
||||
$ret = '<a href="'.$link.'"'.($target?' target="'.$target.'"':'').'>'.$this->htmlspecialchars($text).'</a>';
|
||||
if($_var === 'return')
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
return $this->Add($_var, $ret);
|
||||
}
|
||||
|
||||
public function addInput($_var, $value, $type = 'text', $class = '', $id = '', $name = '')
|
||||
{
|
||||
$options = array('type'=>$type);
|
||||
if($id != '')
|
||||
{
|
||||
$options['id'] = $id;
|
||||
}
|
||||
if($name != '')
|
||||
{
|
||||
$options['name'] = $name;
|
||||
}
|
||||
return $this->addButton($_var, $value, null, null, $class, $options);
|
||||
}
|
||||
|
||||
public function addMessage($class, $text, $html = false, $_var = 'MESSAGE')
|
||||
{
|
||||
$ret = '';
|
||||
switch($class)
|
||||
{
|
||||
case 'error':
|
||||
case 'warning':
|
||||
case 'info':
|
||||
|
||||
break;
|
||||
default:
|
||||
$class = 'info';
|
||||
break;
|
||||
}
|
||||
if(!$html)
|
||||
{
|
||||
$text = $this->htmlspecialchars($text);
|
||||
}
|
||||
$ret .= '<div class="'.$class.'">'.$text.'</div>';
|
||||
if($_var === 'return')
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
return $this->app->Tpl->Add($_var, $ret);
|
||||
}
|
||||
|
||||
public function addSelect($_var, $id, $name, $options, $selected = '', $class = '')
|
||||
{
|
||||
$extra = '';
|
||||
foreach(array('id','name','class') as $k)
|
||||
{
|
||||
if($$k != '')
|
||||
{
|
||||
$extra .= ' '.$k.'="'.str_replace('"','"',$$k).'"';
|
||||
}
|
||||
}
|
||||
$ret = '<select'.$extra.'>';
|
||||
if(is_array($options))
|
||||
{
|
||||
foreach($options as $k => $v)
|
||||
{
|
||||
$ret .= '<option'.
|
||||
($k == $selected?' selected="selected"':'').' value="'.str_replace('"','"',$k).
|
||||
'">'.$this->htmlspecialchars($v).
|
||||
'</option>';
|
||||
}
|
||||
}
|
||||
$ret .= '</select>';
|
||||
if($_var === 'return')
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
return $this->app->Tpl->Add($_var, $ret);
|
||||
}
|
||||
|
||||
public function addButton($_var, $text, $link = null, $target = null, $class = '', $options = null)
|
||||
{
|
||||
$ret = '';
|
||||
$type = 'button';
|
||||
$extra = '';
|
||||
$extraa = array();
|
||||
if(isset($options['type'])) {
|
||||
$type = $options['type'];
|
||||
}
|
||||
if($link) {
|
||||
$ret .= '<a href="'.$link.'"'.($target?' target="'.$target.'"':'').'>';
|
||||
}
|
||||
if(is_array($options)) {
|
||||
foreach($options as $k => $v) {
|
||||
switch($k) {
|
||||
case 'name':
|
||||
case 'id':
|
||||
$extraa[] = $k.'="'.str_replace('"','"',(String)$v).'"';
|
||||
break;
|
||||
default:
|
||||
if(strpos($k,'data-') === 0) {
|
||||
$extraa[] = $k.'="'.str_replace('"','"',(String)$v).'"';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count($extraa) > 0){
|
||||
$extra = ' ' . implode(' ', $extraa);
|
||||
}
|
||||
|
||||
$ret .= '<input type="'.$type.'" value="'.str_replace('"','"',$text).'" '.
|
||||
($class!=''?' class="'.str_replace('"','',$class).'"':'').
|
||||
$extra.' />';
|
||||
if($link) {
|
||||
$ret .= '</a>';
|
||||
}
|
||||
if($_var === 'return') {
|
||||
return $ret;
|
||||
}
|
||||
$this->app->Tpl->Add($_var, $ret);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function GetVars($tplfile)
|
||||
{
|
||||
$fp=@fopen($tplfile,"r");
|
||||
if($fp){
|
||||
$contents = fread ($fp, filesize($tplfile));
|
||||
fclose($fp);
|
||||
}
|
||||
$suchmuster = '/[\[][A-Z_]+[\]]/';
|
||||
preg_match_all($suchmuster, $contents, $treffer);
|
||||
return $treffer[0];
|
||||
}
|
||||
|
||||
function ResetParser()
|
||||
{
|
||||
unset($this->TEMPLATELIST);
|
||||
unset($this->VARARRAY);
|
||||
}
|
||||
|
||||
function ReadTemplatesFromPath($_path){
|
||||
|
||||
$this->loadUebersetzung();
|
||||
|
||||
$this->addPath($_path);
|
||||
$directory=opendir($_path);
|
||||
$i = 1;
|
||||
while ($file=readdir($directory)){
|
||||
if(strstr($file, '.tpl')){
|
||||
$i++;
|
||||
$this->TEMPLATELIST[$file] = new ThemeTemplate($_path,$file);
|
||||
}
|
||||
}
|
||||
closedir($directory);
|
||||
}
|
||||
|
||||
private function loadUebersetzung(){
|
||||
}
|
||||
|
||||
protected function addPath($_path)
|
||||
{
|
||||
$rpos = strrpos($_path, '/www/');
|
||||
if($rpos !== false)
|
||||
{
|
||||
$this->pathes[] = substr($_path, $rpos);
|
||||
}else{
|
||||
$this->pathes[] = $_path;
|
||||
}
|
||||
}
|
||||
|
||||
protected function pathLoaded($_path)
|
||||
{
|
||||
if(!$this->pathes)return false;
|
||||
$rpos = strrpos($_path, '/www/');
|
||||
if($rpos !== false)
|
||||
{
|
||||
$_path = substr($_path, $rpos);
|
||||
}
|
||||
if(in_array($_path, $this->pathes))return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function LoadPathes()
|
||||
{
|
||||
$pathes = array(dirname(dirname(__DIR__))."/www/widgets/templates/_gen/",
|
||||
dirname(dirname(__DIR__))."/www/widgets/templates/",
|
||||
dirname(dirname(__DIR__))."/www/themes/".$this->app->Conf->WFconf['defaulttheme']."/templates/",
|
||||
dirname(dirname(__DIR__))."/www/pages/content/_gen/",
|
||||
dirname(dirname(__DIR__))."/www/pages/content/"
|
||||
);
|
||||
foreach($pathes as $path)
|
||||
{
|
||||
if(!$this->pathLoaded($path))$this->ReadTemplatesFromPath($path);
|
||||
}
|
||||
}
|
||||
|
||||
function CreateVarArray(){
|
||||
foreach($this->TEMPLATELIST as $template=>$templatename){
|
||||
if(count($this->TEMPLATELIST[$template]->VARS) > 0){
|
||||
foreach($this->TEMPLATELIST[$template]->VARS as $key=>$value){
|
||||
$this->VARARRAY[$key]=$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ShowVariables(){
|
||||
foreach($this->VARARRAY as $key=>$value)
|
||||
echo "<b>$key =></b>".htmlspecialchars($value)."<br>";
|
||||
}
|
||||
|
||||
function ParseVariables($text){
|
||||
foreach($this->VARARRAY as $key=>$value)
|
||||
{
|
||||
if($key=!"")
|
||||
$text = str_replace('['.$key.']',$value,$text);
|
||||
}
|
||||
// fill empty vars
|
||||
return $text;
|
||||
}
|
||||
|
||||
function ShowTemplates(){
|
||||
foreach ($this->TEMPLATELIST as $key=> $value){
|
||||
foreach ($value as $key1=> $text){
|
||||
if(!is_array($text))echo "$key ".htmlspecialchars($text)."<br>";
|
||||
if(is_array($text))foreach($text as $key2=>$value2) echo $key2." ".$value2;
|
||||
}
|
||||
echo '<br><br>';
|
||||
}
|
||||
}
|
||||
function SetText($_var, $_value)
|
||||
{
|
||||
$this->VARARRAY[$_var]= $this->htmlspecialchars($_value);
|
||||
}
|
||||
|
||||
function AddText($_var,$_value, $variable = false){
|
||||
$this->VARARRAY[$_var]=isset($this->VARARRAY[$_var])?$this->VARARRAY[$_var].$this->htmlspecialchars($_value):$this->htmlspecialchars($_value);
|
||||
if($variable)
|
||||
$this->VARVARARRAY[$_var] = $variable;
|
||||
}
|
||||
|
||||
function Set($_var,$_value, $variable = false){
|
||||
$this->VARARRAY[$_var]=$_value;
|
||||
if($variable)
|
||||
$this->VARVARARRAY[$_var] = $variable;
|
||||
}
|
||||
|
||||
function Add($_var,$_value, $variable = false){
|
||||
$this->VARARRAY[$_var]=isset($this->VARARRAY[$_var])?$this->VARARRAY[$_var].$_value:$_value;
|
||||
if($variable)
|
||||
$this->VARVARARRAY[$_var] = $variable;
|
||||
}
|
||||
|
||||
function Get($_var){
|
||||
return $this->VARARRAY[$_var]." ";
|
||||
}
|
||||
|
||||
function Output($_template)
|
||||
{
|
||||
echo $this->app->erp->ClearDataBeforeOutput($this->ParseTranslation($this->Parse("",$_template,1)));
|
||||
}
|
||||
|
||||
|
||||
function OutputAsString($_template)
|
||||
{
|
||||
return $this->app->erp->ClearDataBeforeOutput($this->Parse("",$_template,1));
|
||||
}
|
||||
|
||||
|
||||
function pruefeuebersetzung($text, $_type = 'page', $element = null, $withspan = true)
|
||||
{
|
||||
if(is_null($this->uebersetzungmodulvorhanden))
|
||||
{
|
||||
$this->uebersetzungmodulvorhanden = true;
|
||||
if(!$this->app->erp->ModulVorhanden('wawision_uebersetzung'))$this->uebersetzungmodulvorhanden = false;
|
||||
}
|
||||
if(!$this->uebersetzungmodulvorhanden)return $text;
|
||||
if(is_array($text))
|
||||
{
|
||||
foreach($text as $k => $v)
|
||||
{
|
||||
$text[$k] = $this->pruefeuebersetzung($v, $_type, $element, $withspan);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
if($text === '')return '';
|
||||
if(is_null($element) && isset($this->app->Secure) && method_exists($this->app->Secure, 'GetGET'))$element = $this->app->Secure->GetGET('module');
|
||||
$start = '';
|
||||
$end = '';
|
||||
|
||||
return $start.$text.$end;
|
||||
}
|
||||
|
||||
|
||||
function ParseTranslation($text)
|
||||
{
|
||||
$pattern = '/((\{\|)(.*?)(\|\}))/s';
|
||||
$ok = preg_match_all($pattern,$text,$matches, PREG_OFFSET_CAPTURE);
|
||||
if(!$ok)return $text;
|
||||
//TODO Parser umbauen, damit Variablen nicht doppelt genommen werden.
|
||||
if(count($matches[0]) > 0)
|
||||
{
|
||||
$cmatches = count($matches[0]);
|
||||
for($i=0;$i<$cmatches;$i++)
|
||||
{
|
||||
$Elements[$i]['before'] = substr($text, $i==0?0:($matches[0][$i-1][1] +strlen($matches[0][$i-1][0]) ), $matches[0][$i][1] - ($i==0 ?0 : ($matches[0][$i-1][1]+strlen($matches[0][$i-1][0])) ) );
|
||||
$Elements[$i]['el'] = $matches[0][$i][0];
|
||||
$Elements[$i]['el'] = str_replace('{|','',$Elements[$i]['el']);
|
||||
$Elements[$i]['el'] = str_replace('|}','',$Elements[$i]['el']);
|
||||
if($i > 0)$Elements[$i-1]['nach'] = $Elements[$i]['before'];
|
||||
}
|
||||
$Elements[count($matches[0])-1]['nach'] = substr($text, $matches[0][count($matches[0])-1][1]+strlen($matches[0][count($matches[0])-1][0]));
|
||||
}else return $text;
|
||||
$cmatches = count($matches[0]);
|
||||
for($i=0;$i<$cmatches;$i++)
|
||||
{
|
||||
$matches[0][$i][0] = str_replace('{|','',$matches[0][$i][0]);
|
||||
$matches[0][$i][0] = str_replace('|}','',$matches[0][$i][0]);
|
||||
}
|
||||
$ret = "";
|
||||
if($Elements){
|
||||
foreach($Elements as $k => $v)
|
||||
{
|
||||
if(isset($v['before']) && $k == 0)$ret .= $v['before'];
|
||||
|
||||
if(isset($v['before']) && strlen((String)$v['before']) > 0 && substr($v['before'],-1) == '"')
|
||||
{
|
||||
|
||||
$pos1 = strripos($v['before'],'input');
|
||||
$pos2 = strripos($v['before'],'<');
|
||||
|
||||
if($pos2 !== false && $pos1 !== false && $pos2 < $pos1)
|
||||
{
|
||||
$ret .= $this->pruefeuebersetzung($v['el'],'page',null, '****');
|
||||
}else{
|
||||
$ret .= $this->pruefeuebersetzung($v['el'],'page',null, false);
|
||||
}
|
||||
}else{
|
||||
$ret .= $this->pruefeuebersetzung($v['el']);
|
||||
}
|
||||
if(isset($v['nach']))$ret .= $v['nach'];
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function Parse($_var, $_template,$return=0){
|
||||
if(!isset($this->TEMPLATELIST[$_template]))
|
||||
{
|
||||
$this->LoadPathes();
|
||||
}
|
||||
// check if custom template exists_template
|
||||
$checkcustom = str_replace('.tpl','_custom.tpl',$_template);
|
||||
if(isset($this->TEMPLATELIST[$checkcustom])) $_template = $checkcustom;
|
||||
|
||||
//$this->AjaxParse();
|
||||
if($_var == 'PAGE')$this->app->erp->ParseMenu();
|
||||
$this->ParseVarVars();
|
||||
if($_template!=""){
|
||||
if(isset($this->TEMPLATELIST[$_template]) && !($this->TEMPLATELIST[$_template]->vararraycreated))
|
||||
{
|
||||
$this->TEMPLATELIST[$_template]->CreateVarArray();
|
||||
}
|
||||
|
||||
//alle template variablen aufuellen mit den werten aus VARARRAY
|
||||
if(isset($this->TEMPLATELIST[$_template]) && isset($this->TEMPLATELIST[$_template]->VARS) && count($this->TEMPLATELIST[$_template]->VARS)>0){
|
||||
foreach ($this->TEMPLATELIST[$_template]->VARS as $key=> $value){
|
||||
$this->TEMPLATELIST[$_template]->SetVar($key,isset($this->VARARRAY[$key])?$this->VARARRAY[$key]:'');
|
||||
}
|
||||
|
||||
//ORIGINAL auffuellen
|
||||
$tmptpl = $this->TEMPLATELIST[$_template]->ORIGINAL;
|
||||
foreach ($this->TEMPLATELIST[$_template]->VARS as $key=>$value){
|
||||
if(!is_numeric($key) && $key!="")
|
||||
$tmptpl = str_replace("[".$key."]",$value, $tmptpl);
|
||||
}
|
||||
} else $tmptpl = '';
|
||||
//aufgefuelltes ORIGINAL in $t_var add($_var,ORIGINAL)
|
||||
if($return==1)
|
||||
return $tmptpl;
|
||||
else
|
||||
$this->Add($_var,$tmptpl);
|
||||
}
|
||||
}
|
||||
|
||||
function AddAndParse($_var, $_value, $_varparse, $_templateparse){
|
||||
$this->Set($_var, $_value);
|
||||
$this->Parse($_varparse,$_templateparse);
|
||||
}
|
||||
|
||||
function ParseVarVars()
|
||||
{
|
||||
$pattern = '/((\[[A-Z0-9_]+\]))/';
|
||||
if(!empty($this->VARVARARRAY) && is_array($this->VARVARARRAY))
|
||||
{
|
||||
foreach($this->VARVARARRAY as $k => $el)
|
||||
{
|
||||
preg_match_all($pattern,$this->VARARRAY[$k],$matches, PREG_OFFSET_CAPTURE);
|
||||
|
||||
$cmatches = $matches?count($matches[0]):0;
|
||||
for($i=0;$i<$cmatches;$i++)
|
||||
{
|
||||
$matches[0][$i][0] = str_replace('[','',$matches[0][$i][0]);
|
||||
$matches[0][$i][0] = str_replace(']','',$matches[0][$i][0]);
|
||||
if(isset($this->VARARRAY[$matches[0][$i][0]]))
|
||||
{
|
||||
$this->VARARRAY[$k] = str_replace('['.$matches[0][$i][0].']',$this->VARARRAY[$matches[0][$i][0]],$this->VARARRAY[$k]);
|
||||
}
|
||||
}
|
||||
unset($matches);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function FinalParse($_template){
|
||||
$printtype = '';
|
||||
if(isset($this->TEMPLATELIST[substr($_template,0,strlen($_template)-4).'_custom.tpl']))
|
||||
{
|
||||
$_template = substr($_template,0,strlen($_template)-4).'_custom.tpl';
|
||||
}
|
||||
$this->app->erp->ParseMenu();
|
||||
$this->ParseVarVars();
|
||||
if(isset($this->TEMPLATELIST[$_template]) && !($this->TEMPLATELIST[$_template]->vararraycreated))
|
||||
{
|
||||
$this->TEMPLATELIST[$_template]->CreateVarArray();
|
||||
}
|
||||
$print = $this->app->Secure->GetGET("print");
|
||||
$printcontent = $this->app->Secure->GetGET("printcontent");
|
||||
|
||||
if($printcontent=="") $printcontent="TAB1";
|
||||
if($print=="true") {
|
||||
|
||||
switch($printtype)
|
||||
{
|
||||
default:
|
||||
$out = str_replace("[PRINT]",$this->VARARRAY[$printcontent],$this->TEMPLATELIST['print.tpl']->ORIGINAL);
|
||||
echo $this->ParseTranslation($out);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
if($_template!="" && isset($this->TEMPLATELIST)){
|
||||
//alle template variablen aufuellen mit den werten aus VARARRAY
|
||||
if(count($this->TEMPLATELIST[$_template]->VARS)>0){
|
||||
foreach ($this->TEMPLATELIST[$_template]->VARS as $key=> $value)
|
||||
{
|
||||
$this->TEMPLATELIST[$_template]->SetVar($key,(isset($this->VARARRAY[$key])?$this->VARARRAY[$key]:''));
|
||||
}
|
||||
}
|
||||
}
|
||||
//ORIGINAL auffuellen
|
||||
|
||||
|
||||
$new = false;
|
||||
if($new)
|
||||
{
|
||||
//macht Noch Probleme
|
||||
$tmptpl = '';
|
||||
if(!empty($this->TEMPLATELIST[$_template]->Elements))
|
||||
{
|
||||
foreach($this->TEMPLATELIST[$_template]->Elements as $k)
|
||||
{
|
||||
$tmptpl .= $this->ParseTranslation($k['before']);
|
||||
if(!empty($this->TEMPLATELIST[$_template]->VARS[$k['el']]))
|
||||
{
|
||||
$tmptpl .= $this->TEMPLATELIST[$_template]->VARS[$k['el']];
|
||||
}
|
||||
}
|
||||
$tmptpl .= $this->ParseTranslation($this->TEMPLATELIST[$_template]->Elements[count($this->TEMPLATELIST[$_template]->Elements)-1]['nach']);
|
||||
}else $tmptpl = $this->TEMPLATELIST[$_template]->ORIGINAL;
|
||||
}else
|
||||
{
|
||||
$tmptpl = isset($this->TEMPLATELIST[$_template]->ORIGINAL)?$this->TEMPLATELIST[$_template]->ORIGINAL:'';
|
||||
if(isset($this->TEMPLATELIST[$_template]->VARS) && count($this->TEMPLATELIST[$_template]->VARS)>0){
|
||||
foreach ($this->TEMPLATELIST[$_template]->VARS as $key=>$value)
|
||||
{
|
||||
if($key!="")
|
||||
$tmptpl = str_replace("[".$key."]",$value, $tmptpl);
|
||||
}
|
||||
}
|
||||
|
||||
if(count($this->VARARRAY)>0)
|
||||
foreach($this->VARARRAY as $key=>$value)
|
||||
{
|
||||
if($key!="")
|
||||
$tmptpl = str_replace('['.$key.']',$value,$tmptpl);
|
||||
}
|
||||
}
|
||||
|
||||
// In Auftrags-Positionen-IFrame: Leere Form-Actions nicht durch # ersetzen; ansonsten springt das IFrame im Chrome
|
||||
$replaceEmptyFormAction = !$this->IsVorgangPositionenIframe();
|
||||
|
||||
$tmptpl = $this->ParseTranslation($this->app->erp->ClearDataBeforeOutput($tmptpl, $replaceEmptyFormAction));
|
||||
if(isset($this->edittranslation) && $this->edittranslation)$tmptpl = $this->FormatTranslation($tmptpl);
|
||||
return $tmptpl;
|
||||
}
|
||||
|
||||
function FormatTranslation($text)
|
||||
{
|
||||
$start = '<span class="edittranslation">';
|
||||
//$end = '</span>';
|
||||
$texta = explode($start, $text);
|
||||
//$anz = count($texta);
|
||||
$script = false;
|
||||
$textres = '';
|
||||
foreach($texta as $k => $v)
|
||||
{
|
||||
$scriptpos = strripos($v, '<script');
|
||||
$scriptendpos = strripos($v, '</script>');
|
||||
if($scriptpos !== false && $scriptendpos !== false)
|
||||
{
|
||||
if($scriptendpos > $scriptpos)
|
||||
{
|
||||
$script = false;
|
||||
}else{
|
||||
$script = true;
|
||||
}
|
||||
}elseif($scriptpos !== false)
|
||||
{
|
||||
$script = true;
|
||||
}elseif($scriptendpos !== false)
|
||||
{
|
||||
$script = false;
|
||||
}else{
|
||||
//Keine Aenderung
|
||||
}
|
||||
|
||||
if($k > 0)
|
||||
{
|
||||
$pipe1 = (int)strpos($v, '|');
|
||||
$pipe2 = (int)strpos($v, '|', (int)$pipe1+1);
|
||||
$pipe3 = (int)strpos($v, '|', (int)$pipe2+1);
|
||||
$pipe4 = (int)strpos($v, '|', (int)$pipe3+1);
|
||||
$spos = 0;
|
||||
$_text = '';
|
||||
$_type = '';
|
||||
$_elem = '';
|
||||
if($pipe4 > $pipe3 && $pipe3 > $pipe2 && $pipe2 > $pipe1)
|
||||
{
|
||||
$_text = substr($v,$pipe1+1, $pipe2 - $pipe1 - 1);
|
||||
$_type = substr($v,$pipe2+1, $pipe3 - $pipe2 - 1);
|
||||
$_elem = substr($v,$pipe3+1, $pipe4 - $pipe3 - 1);
|
||||
$spos = $pipe4 + 1;
|
||||
}
|
||||
|
||||
$endespan = strpos($v, '</span>');
|
||||
$erlaubt = true;
|
||||
$starttag = strpos($v, '<', $endespan+6);
|
||||
$startquote = strpos($v, '"', $endespan+6);
|
||||
if($starttag && strtolower(substr($v,$starttag,5)) != '</td>' && strtolower(substr($v,$starttag,5)) != '</th>' && strtolower(substr($v,$starttag,4)) != '</a>' && strtolower(substr($v,$starttag,6)) != '</div>' && strtolower(substr($v,$starttag,4)) != '</i>' && strtolower(substr($v,$starttag,9)) != '</legend>' && strtolower(substr($v,$starttag,8)) != '</label>')
|
||||
{
|
||||
$erlaubt = false;
|
||||
}
|
||||
if(substr($v,$endespan+8,1) == '"' || substr($v,$endespan+7,1) == '"')
|
||||
{
|
||||
$erlaubt = false;
|
||||
}
|
||||
if($endespan !== false && $starttag !== false && $startquote !== false && $startquote < $starttag)
|
||||
{
|
||||
$erlaubt = false;
|
||||
}
|
||||
|
||||
if($script || !$erlaubt)
|
||||
{
|
||||
if(!$script)
|
||||
{
|
||||
$substr = $texta[$k-1];
|
||||
|
||||
$pos1 = strripos($substr, 'input');
|
||||
$pos2 = strrpos($substr, '<');
|
||||
if($pos1 !== false && $pos2 !== false && $pos2 < $pos1)
|
||||
{
|
||||
$textres .= '****'.substr($v,$spos, $endespan - $spos).substr($v,$endespan+7);
|
||||
}else{
|
||||
$textres .= substr($v,$spos, $endespan - $spos).substr($v,$endespan+7);
|
||||
}
|
||||
}else{
|
||||
$textres .= substr($v,$spos, $endespan - $spos).substr($v,$endespan+7);
|
||||
}
|
||||
}else{
|
||||
$textres .= $start.substr($v,$spos, $endespan - $spos).'</span><span><input type="hidden" class="wawision_uebersetzung_text" value="'.base64_encode($_text).'" /><input type="hidden" class="wawision_uebersetzung_type" value="'.base64_encode($_type).'" /><input type="hidden" class="wawision_uebersetzung_elem" value="'.base64_encode($_elem).'" /></span>'.substr($v,$endespan+7);
|
||||
}
|
||||
}else{
|
||||
$textres .= $v;
|
||||
}
|
||||
}
|
||||
return $textres;
|
||||
}
|
||||
|
||||
function AjaxParse()
|
||||
{
|
||||
|
||||
foreach($this->TEMPLATELIST as $key=>$value)
|
||||
{
|
||||
foreach ($this->TEMPLATELIST[$key]->VARS as $var=>$tmp)
|
||||
{
|
||||
if(strstr($var,"AJAX"))
|
||||
{
|
||||
//$this->Set(AJAX_SELECT_PROJEKT,"Hallo");
|
||||
//$this->VARARRAY[$var]="XVZ";
|
||||
//print_r($this->VARARRAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function KeywordParse()
|
||||
{
|
||||
|
||||
foreach($this->TEMPLATELIST as $key=>$value)
|
||||
{
|
||||
foreach ($this->TEMPLATELIST[$key]->VARS as $var=>$tmp)
|
||||
if(strstr($var,"AJAX"))
|
||||
{
|
||||
echo $var;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function IsVorgangPositionenIframe()
|
||||
{
|
||||
$vorgaenge = ['anfrage','angebot','arbeitsnachweis','auftrag','bestellung','gutschrift','kalkulation','lieferschein','preisanfrage','produktion','proformarechnung','rechnung','reisekosten','verbindlichkeit'];
|
||||
|
||||
$isPopup = ($this->app->BuildNavigation !== true);
|
||||
$isVorgangModule = in_array($this->app->Secure->GetGET('module'), $vorgaenge);
|
||||
$isPositionenAction = (strpos($this->app->Secure->GetGET('action'), 'position') !== false);
|
||||
|
||||
return ($isPopup && $isVorgangModule && $isPositionenAction) ? true : false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,735 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
class User
|
||||
{
|
||||
/** @var array */
|
||||
var $cache;
|
||||
|
||||
/**
|
||||
* User constructor.
|
||||
*
|
||||
* @param ApplicationCore $app
|
||||
*/
|
||||
public function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getUserProjects()
|
||||
{
|
||||
return $this->getUserProjectsByParameter($this->GetAdresse(), $this->GetType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPublicProjects()
|
||||
{
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(!empty($this->cache[$cacheKey]['public_projects'])) {
|
||||
return $this->cache[$cacheKey]['public_projects'];
|
||||
}
|
||||
$this->loadProjectsInCacheProperty();
|
||||
|
||||
return $this->cache[$cacheKey]['public_projects'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAllProjects()
|
||||
{
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(!empty($this->cache[$cacheKey]['all_projects'])) {
|
||||
return $this->cache[$cacheKey]['all_projects'];
|
||||
}
|
||||
$this->loadProjectsInCacheProperty();
|
||||
|
||||
return $this->cache[$cacheKey]['all_projects'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function createCache()
|
||||
{
|
||||
$allProjects = $this->getAllProjects();
|
||||
$file = $this->app->getTmpFolder().'cache_useronline';
|
||||
$arr = $this->app->DB->SelectArr(
|
||||
"SELECT uo.user_id, uo.sessionid, u.type, u.adresse
|
||||
FROM `useronline` AS `uo`
|
||||
INNER JOIN `user` AS `u` ON uo.user_id = u.id AND u.activ = 1
|
||||
WHERE uo.login = 1"
|
||||
);
|
||||
$ret = [];
|
||||
if(is_file($file)) {
|
||||
$ret = file_get_contents($file);
|
||||
if(empty(!$ret)) {
|
||||
$ret = json_decode($ret, true);
|
||||
}
|
||||
if(empty($ret)) {
|
||||
$ret = [];
|
||||
}
|
||||
}
|
||||
$cacheKey = $this->getCacheKey();
|
||||
$ret[$cacheKey] = [];
|
||||
if(!empty($arr)) {
|
||||
foreach($arr as $row) {
|
||||
if($row['type'] === 'admin') {
|
||||
$projects = $allProjects;
|
||||
} else {
|
||||
$projects = $this->getUserProjectsByParameter($row['adresse'], $row['type']);
|
||||
}
|
||||
$sessionId = $row['sessionid'];
|
||||
$sha1SessionId = sha1($sessionId);
|
||||
$ret[$cacheKey][$sha1SessionId] = ['type'=>$row['type'],'project'=>$projects];
|
||||
}
|
||||
}
|
||||
file_put_contents($file, json_encode($ret));
|
||||
|
||||
return $ret[$cacheKey];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $createIfEmpty
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getUserByCache($createIfEmpty = true)
|
||||
{
|
||||
$file = $this->app->getTmpFolder().'cache_useronline';
|
||||
if(isset($_COOKIE['CH42SESSION']) && $_COOKIE['CH42SESSION']!='') {
|
||||
$tmp = $_COOKIE['CH42SESSION'];
|
||||
} else {
|
||||
$tmp = session_id();
|
||||
}
|
||||
$sha1Tmp = sha1($tmp);
|
||||
$content = '';
|
||||
if(is_file($file)){
|
||||
$content = file_get_contents($file);
|
||||
}
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(!empty($content)) {
|
||||
$content = json_decode($content, true);
|
||||
if(empty($content[$cacheKey])) {
|
||||
$content[$cacheKey] = $this->createCache();
|
||||
}
|
||||
$content = $content[$cacheKey];
|
||||
if(!empty($content[$sha1Tmp])) {
|
||||
return $content[$sha1Tmp];
|
||||
}
|
||||
} else {
|
||||
if(!$createIfEmpty) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if(!empty($tmp)) {
|
||||
$content = $this->createCache();
|
||||
if(!empty($content[$sha1Tmp])) {
|
||||
return $content[$sha1Tmp];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $projektId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function projectOk($projektId): ?bool
|
||||
{
|
||||
$user = $this->getUserByCache(false);
|
||||
if(empty($user)) {
|
||||
return null;
|
||||
}
|
||||
if($projektId <= 0) {
|
||||
return true;
|
||||
}
|
||||
if($user['type'] === 'admin') {
|
||||
return true;
|
||||
}
|
||||
if(empty($user['project'])) {
|
||||
return false;
|
||||
}
|
||||
if(in_array($projektId, $user['project'])) {
|
||||
return true;
|
||||
}
|
||||
//@todo Projekt aus Cache holen
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function GetID(): int
|
||||
{
|
||||
if(isset($_COOKIE['CH42SESSION']) && $_COOKIE['CH42SESSION']!='') {
|
||||
$tmp = $_COOKIE['CH42SESSION'];
|
||||
} else {
|
||||
$tmp = session_id();
|
||||
}
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(empty($this->cache[$cacheKey])
|
||||
|| !isset($this->cache[$cacheKey]['time']) || !isset($this->cache[$cacheKey]['tmp'])
|
||||
|| $this->cache[$cacheKey]['time'] + 10 < microtime(true) || $this->cache[$cacheKey]['tmp'] != $tmp) {
|
||||
$this->cache = null;
|
||||
$user_id = (int)$this->app->DB->Select(
|
||||
sprintf(
|
||||
"SELECT `user_id`
|
||||
FROM `useronline`
|
||||
WHERE `sessionid` != '' AND `sessionid` = '%s' AND `login` = 1
|
||||
LIMIT 1",
|
||||
$this->app->DB->real_escape_string($tmp)
|
||||
)
|
||||
);
|
||||
if($user_id > 0) {
|
||||
$this->cache[$cacheKey]['user_id'] = $user_id;
|
||||
$this->cache[$cacheKey]['tmp'] = $tmp;
|
||||
$this->cache[$cacheKey]['time'] = microtime(true);
|
||||
}
|
||||
|
||||
return $user_id;
|
||||
}
|
||||
|
||||
return (int)$this->cache[$cacheKey]['user_id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetType(): string
|
||||
{
|
||||
$userId = (int)$this->GetID();
|
||||
if($userId <= 0) {
|
||||
return (string)$this->app->Conf->WFconf['defaultgroup'];
|
||||
}
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(!empty($this->cache[$cacheKey]) && isset($this->cache[$cacheKey]['type'])) {
|
||||
return (string)$this->cache[$cacheKey]['type'];
|
||||
}
|
||||
$this->loadUserRowInCacheProperty($userId);
|
||||
|
||||
return (string)$this->cache[$cacheKey]['type'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|string|array $settings
|
||||
*/
|
||||
function SettingsToUserKonfiguration($settings = null)
|
||||
{
|
||||
$id = (int)$this->GetID();
|
||||
if(!$id) {
|
||||
return;
|
||||
}
|
||||
if($settings === null) {
|
||||
$settings = $this->app->DB->Select(sprintf('SELECT `settings` FROM `user` WHERE `id` = %d LIMIT 1', $id));
|
||||
$cacheKey = $this->getCacheKey();
|
||||
$this->cache[$cacheKey]['settings'] = $settings;
|
||||
}
|
||||
if(empty($settings)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if($settings != '') {
|
||||
$settings = @unserialize($settings);
|
||||
}
|
||||
if(empty($settings) || !is_array($settings)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($settings as $k => $v) {
|
||||
$check = $this->app->DB->Select("SELECT `id` FROM `userkonfiguration` WHERE `name` = '".$this->app->DB->real_escape_string($k)."' AND `user` = '$id' LIMIT 1");
|
||||
if($check) {
|
||||
$this->app->DB->Update("UPDATE `userkonfiguration` set `value` = '".$this->app->DB->real_escape_string($v)."' WHERE `id` = '$check' LIMIT 1");
|
||||
}else{
|
||||
$this->app->DB->Insert("INSERT INTO `userkonfiguration` (`user`,`name`,`value`) VALUES ('$id','".$this->app->DB->real_escape_string($k)."','".$this->app->DB->real_escape_string($v)."')");
|
||||
}
|
||||
}
|
||||
if(!$this->app->DB->error()) {
|
||||
$this->app->DB->Update(sprintf("UPDATE `user` SET `settings` = '' WHERE `id` = %d LIMIT 1", $id));
|
||||
$cacheKey = $this->getCacheKey();
|
||||
$this->cache[$cacheKey]['settings'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @var int|null $userId
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function GetSettings($userId = null)
|
||||
{
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(!empty($this->cache[$cacheKey]) && isset($this->cache[$cacheKey]['settings'])) {
|
||||
return $this->cache[$cacheKey]['settings'];
|
||||
}
|
||||
$this->loadUserRowInCacheProperty($userId);
|
||||
|
||||
return $this->cache[$cacheKey]['settings'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $index
|
||||
*
|
||||
* @return array|mixed|string|null
|
||||
*/
|
||||
public function GetParameter($index)
|
||||
{
|
||||
$userId = (int)$this->GetID();
|
||||
$settings = $this->GetSettings($userId);
|
||||
if(!empty($settings)) {
|
||||
$this->SettingsToUserKonfiguration($settings);
|
||||
}
|
||||
|
||||
if((is_array($index) && count($index) === 0) || (!is_array($index) && (string)$index === '')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(is_array($index)) {
|
||||
$index = array_map('trim', $index);
|
||||
$indexNames = array_map([$this->app->DB, 'real_escape_string'], $index);
|
||||
$sql = sprintf(
|
||||
"SELECT `name`, MAX(`value`) AS `value`
|
||||
FROM `userkonfiguration`
|
||||
WHERE `user` = %d AND `name` IN ('%s')
|
||||
GROUP BY `name`",
|
||||
$userId, implode("', '", $indexNames)
|
||||
);
|
||||
$arr = $this->app->DB->SelectPairs($sql);
|
||||
$ret = null;
|
||||
foreach($index as $ind) {
|
||||
if(isset($arr[$ind])) {
|
||||
$ret[] = [ 'name'=>$ind, 'value'=> $arr[$ind] ];
|
||||
}
|
||||
else {
|
||||
$ret[] = [ 'name'=>$ind, 'value'=> '' ];
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
return $this->app->DB->Select(
|
||||
sprintf(
|
||||
"SELECT `value`
|
||||
FROM `userkonfiguration`
|
||||
WHERE `name` = '%s' AND `user` = %d
|
||||
LIMIT 1",
|
||||
$this->app->DB->real_escape_string($index), $userId
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// value koennen beliebige Datentypen aus php sein (serialisiert)
|
||||
|
||||
/**
|
||||
* @param string $index
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function SetParameter($index, $value)
|
||||
{
|
||||
if((string)$index === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$id = (int)$this->GetID();
|
||||
|
||||
$settings = $this->GetSettings($id);
|
||||
if(!empty($settings)) {
|
||||
$this->SettingsToUserKonfiguration($settings);
|
||||
}
|
||||
|
||||
$check = $this->app->DB->SelectRow(
|
||||
sprintf(
|
||||
"SELECT `id`, `value`
|
||||
FROM `userkonfiguration` WHERE `name` = '%s' AND `user` = %d
|
||||
LIMIT 1",
|
||||
$this->app->DB->real_escape_string($index), $id
|
||||
)
|
||||
);
|
||||
if(empty($check)) {
|
||||
$this->app->DB->Insert(
|
||||
sprintf(
|
||||
"INSERT INTO `userkonfiguration` (`user`, `name`, `value`) VALUES (%d, '%s', '%s')",
|
||||
$id, $this->app->DB->real_escape_string($index), $this->app->DB->real_escape_string($value)
|
||||
)
|
||||
);
|
||||
$this->cache = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if((string)$value === (string)$check['value']) {
|
||||
return;
|
||||
}
|
||||
$this->app->DB->Update(
|
||||
sprintf(
|
||||
"UPDATE `userkonfiguration`
|
||||
SET `value` = '%s'
|
||||
WHERE `id` = %d
|
||||
LIMIT 1",
|
||||
$this->app->DB->real_escape_string($value), $check['id']
|
||||
)
|
||||
);
|
||||
$this->cache = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $index
|
||||
*/
|
||||
public function deleteParameter($index)
|
||||
{
|
||||
if(empty($index)) {
|
||||
return;
|
||||
}
|
||||
$id = $this->GetID();
|
||||
$this->app->DB->Delete(
|
||||
sprintf(
|
||||
'DELETE FROM `userkonfiguration` WHERE `user` = %d AND `name` = \'%s\'',
|
||||
$id, $this->app->DB->real_escape_string($index)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prefix
|
||||
*/
|
||||
public function deleteParameterPrefix($prefix)
|
||||
{
|
||||
if(empty($prefix)) {
|
||||
return;
|
||||
}
|
||||
$id = $this->GetID();
|
||||
$this->app->DB->Delete(
|
||||
sprintf(
|
||||
'DELETE FROM `userkonfiguration` WHERE `user` = %d AND `name` LIKE \'%s%%\'',
|
||||
$id, $this->app->DB->real_escape_string($prefix)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function GetUsername()
|
||||
{
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(!empty($this->cache[$cacheKey]) && isset($this->cache[$cacheKey]['username'])) {
|
||||
return $this->cache[$cacheKey]['username'];
|
||||
}
|
||||
$this->loadUserRowInCacheProperty();
|
||||
|
||||
return $this->cache[$cacheKey]['username'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function GetDescription()
|
||||
{
|
||||
return $this->GetName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function GetMail()
|
||||
{
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(!empty($this->cache[$cacheKey]) && isset($this->cache[$cacheKey]['email'])) {
|
||||
return $this->cache[$cacheKey]['email'];
|
||||
}
|
||||
$this->loadAddressRowInCacheProperty();
|
||||
|
||||
return $this->cache[$cacheKey]['email'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function GetName()
|
||||
{
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(!empty($this->cache[$cacheKey]) && isset($this->cache[$cacheKey]['name'])) {
|
||||
return $this->cache[$cacheKey]['name'];
|
||||
}
|
||||
$this->loadAddressRowInCacheProperty();
|
||||
|
||||
return $this->cache[$cacheKey]['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function GetSprachen()
|
||||
{
|
||||
$userId = (int)$this->GetId();
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(empty($this->cache[$cacheKey]) || !isset($this->cache[$cacheKey]['sprachebevorzugen'])) {
|
||||
$this->loadUserRowInCacheProperty($userId);
|
||||
}
|
||||
$defaultLanguages = ['german','english'];
|
||||
$languages = $this->cache[$cacheKey]['sprachebevorzugen'];
|
||||
|
||||
if(empty($languages)) {
|
||||
return $defaultLanguages;
|
||||
}
|
||||
$ret = [];
|
||||
$languagesArray = explode(';',str_replace(',',';',$languages));
|
||||
foreach($languagesArray as $language) {
|
||||
$language = trim($language);
|
||||
if($language != '') {
|
||||
$ret[] = $language;
|
||||
}
|
||||
}
|
||||
if(empty($ret)) {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
return $defaultLanguages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetSprache()
|
||||
{
|
||||
$sprachen = $this->GetSprachen();
|
||||
|
||||
return reset($sprachen);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function GetAdresse()
|
||||
{
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(!empty($this->cache[$cacheKey]) && isset($this->cache[$cacheKey]['adresse'])) {
|
||||
return $this->cache[$cacheKey]['adresse'];
|
||||
}
|
||||
$this->loadUserRowInCacheProperty();
|
||||
|
||||
return $this->cache[$cacheKey]['adresse'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
function GetProjektleiter()
|
||||
{
|
||||
$result = $this->app->DB->SelectRow(
|
||||
"SELECT `parameter`
|
||||
FROM `adresse_rolle`
|
||||
WHERE `subjekt` = 'Projektleiter' AND (`bis` = '0000-00-00' OR `bis` <= CURDATE())
|
||||
AND `adresse` = '".$this->app->User->GetAdresse()."'
|
||||
LIMIT 1"
|
||||
);
|
||||
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
function DefaultProjekt()
|
||||
{
|
||||
$adresse = $this->GetAdresse();
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(empty($this->cache[$cacheKey]) || !isset($this->cache[$cacheKey]['projekt'])) {
|
||||
$this->loadAddressRowInCacheProperty($adresse);
|
||||
$projekt = $this->cache[$cacheKey]['projekt'];
|
||||
}
|
||||
else {
|
||||
$projekt = $this->cache[$cacheKey]['projekt'];
|
||||
}
|
||||
if($projekt <=0){
|
||||
$projekt = $this->app->DB->Select(
|
||||
"SELECT `standardprojekt` FROM `firma` WHERE `id`='" . $this->app->User->GetFirma() . "' LIMIT 1"
|
||||
);
|
||||
}
|
||||
|
||||
return $projekt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
function GetEmail()
|
||||
{
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(!empty($this->cache[$cacheKey]) && isset($this->cache[$cacheKey]['email'])) {
|
||||
return $this->cache[$cacheKey]['email'];
|
||||
}
|
||||
$this->loadAddressRowInCacheProperty();
|
||||
|
||||
return $this->cache[$cacheKey]['email'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function GetFirma(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function GetFirmaName()
|
||||
{
|
||||
$cacheKey = $this->getCacheKey();
|
||||
if(!empty($this->cache[$cacheKey]) && isset($this->cache[$cacheKey]['firmaname'])) {
|
||||
return $this->cache[$cacheKey]['firmaname'];
|
||||
}
|
||||
$name = $this->app->DB->Select(sprintf('SELECT `name` FROM `firma` WHERE `id` = %d', $this->GetFirma()));
|
||||
$this->cache[$cacheKey]['firmaname'] = $name;
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetField($field)
|
||||
{
|
||||
$value = $this->app->DB->Select(
|
||||
sprintf(
|
||||
'SELECT `%s` FROM `user` WHERE id = %d ',
|
||||
$field, $this->GetID()
|
||||
)
|
||||
);
|
||||
if(in_array($value, ['settings', 'type', 'username', 'adresse', 'sprachebevorzugen'])) {
|
||||
$cacheKey = $this->getCacheKey();
|
||||
$this->cache[$cacheKey][$field] = $value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $userId
|
||||
*/
|
||||
protected function loadUserRowInCacheProperty(?int $userId = null): void
|
||||
{
|
||||
if($userId === null){
|
||||
$userId = (int)$this->GetID();
|
||||
}
|
||||
$cacheKey = $this->getCacheKey();
|
||||
$userData = (array)$this->app->DB->SelectRow(
|
||||
sprintf(
|
||||
'SELECT `settings`, `type`, `username`, `adresse`, `sprachebevorzugen` FROM `user` WHERE `id` = %d LIMIT 1',
|
||||
$userId
|
||||
)
|
||||
);
|
||||
if(!isset($this->cache[$cacheKey])) {
|
||||
$this->cache[$cacheKey] = $userData;
|
||||
}
|
||||
else{
|
||||
$this->cache[$cacheKey] = array_merge($this->cache[$cacheKey], $userData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $addressId
|
||||
*/
|
||||
protected function loadAddressRowInCacheProperty(?int $addressId = null): void
|
||||
{
|
||||
if($addressId === null){
|
||||
$addressId = (int)$this->GetAdresse();
|
||||
}
|
||||
$cacheKey = $this->getCacheKey();
|
||||
$addressData = (array)$this->app->DB->SelectRow(
|
||||
sprintf('SELECT `name`, `email`, `projekt` FROM `adresse` WHERE `id` = %d LIMIT 1', $addressId)
|
||||
);
|
||||
if(!isset($this->cache[$cacheKey])) {
|
||||
$this->cache[$cacheKey] = $addressData;
|
||||
}
|
||||
else{
|
||||
$this->cache[$cacheKey] = array_merge($this->cache[$cacheKey], $addressData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getCacheKey(): string
|
||||
{
|
||||
return (string)$this->app->Conf->WFdbname;
|
||||
}
|
||||
|
||||
|
||||
protected function loadProjectsInCacheProperty(): void
|
||||
{
|
||||
$cacheKey = $this->getCacheKey();
|
||||
$projects = $this->app->DB->SelectPairs('SELECT `id`, `oeffentlich` FROM `projekt` WHERE `geloescht` <> 1');
|
||||
$this->cache[$cacheKey]['all_projects'] = array_keys($projects);
|
||||
$this->cache[$cacheKey]['public_projects'] = [];
|
||||
foreach($projects as $projectId => $public) {
|
||||
if($public) {
|
||||
$this->cache[$cacheKey]['public_projects'][] = $projectId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $addressId
|
||||
* @param string $type
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getUserProjectsByParameter($addressId, $type)
|
||||
{
|
||||
if($type==='admin' ||
|
||||
$this->app->DB->Select(
|
||||
"SELECT `id`
|
||||
FROM `adresse_rolle`
|
||||
WHERE (`bis` IS NULL OR `bis` = '0000-00-00' OR `bis` <= CURDATE()) AND `adresse` = '".$addressId."'
|
||||
AND (`parameter` = '' OR `parameter` = '0')"
|
||||
)
|
||||
) {
|
||||
return $this->getAllProjects();
|
||||
}
|
||||
$public = $this->getPublicProjects();
|
||||
$roles = $this->app->DB->SelectFirstCols(
|
||||
sprintf(
|
||||
"SELECT DISTINCT `parameter`
|
||||
FROM `adresse_rolle`
|
||||
WHERE (`bis` IS NULL OR `bis` = '0000-00-00' OR `bis` <= CURDATE()) AND `adresse` = %d
|
||||
AND `parameter` >= 0 AND `objekt` LIKE 'Projekt'",
|
||||
$addressId
|
||||
)
|
||||
);
|
||||
$projects = $this->app->DB->SelectFirstCols(
|
||||
sprintf(
|
||||
"SELECT DISTINCT `projekt`
|
||||
FROM `adresse_rolle`
|
||||
WHERE (`bis` IS NULL OR `bis` = '0000-00-00' OR bis <= CURDATE()) AND `adresse` = %d AND `projekt` > 0",
|
||||
$addressId
|
||||
)
|
||||
);
|
||||
|
||||
return array_unique(array_merge($public, $roles, $projects));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
//include("xtea.class.php");
|
||||
|
||||
/*
|
||||
$serial = "abcdefghijklmNopqrstuvwxyz";
|
||||
$key = pack('V*', 0x01,0x02,0x03,0x04);
|
||||
$pad = "4371353838310545596909623831103272086622087173752843453214777855055965572268047010384215";
|
||||
*/
|
||||
//print(wawision_pad_verify($pad,$key,$serial));
|
||||
|
||||
//print(wawision_pad_verify($pad,$key,$serial));
|
||||
|
||||
class WaWisionOTP
|
||||
{
|
||||
|
||||
function wawision_encode($base64) {
|
||||
$output = "";
|
||||
for($i = 0; $i < strlen($base64)-1; $i++) {
|
||||
$c = ord($base64[$i])-ord('+');
|
||||
|
||||
$output .= chr($c/10 + ord('0'));
|
||||
$output .= chr($c%10 + ord('0'));
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function wawision_decode($input)
|
||||
{
|
||||
$base64_str = "";
|
||||
|
||||
for ($i=0; $i<strlen($input)/2; $i++) {
|
||||
$ten = ord($input[2*$i]) - ord('0');
|
||||
$one = ord($input[2*$i+1]) - ord('0');
|
||||
|
||||
/* check if input is valid */
|
||||
$value = $ten*10+$one;
|
||||
if($ten < 0 || $ten > 9 || $one < 0 || $one > 9) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$base64_str .= chr($value + ord("+"));
|
||||
}
|
||||
|
||||
return $base64_str;
|
||||
}
|
||||
|
||||
function wawision_pad_verify($pad,$key,$serial)
|
||||
{
|
||||
$cipher = $this->wawision_decode($pad);
|
||||
if($cipher == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$xtea = new XTEA($key);
|
||||
$plain = $xtea->decrypt($cipher);
|
||||
|
||||
if($plain == FALSE)
|
||||
return FALSE;
|
||||
|
||||
/* check serial */
|
||||
if($plain[0] != $serial[0] ||
|
||||
$plain[1] != $serial[1] ||
|
||||
$plain[2] != $serial[2] ||
|
||||
$plain[3] != $serial[3] ||
|
||||
$plain[4] != $serial[4] ||
|
||||
|
||||
$plain[8] != $serial[5] ||
|
||||
$plain[9] != $serial[6] ||
|
||||
$plain[10] != $serial[7] ||
|
||||
$plain[11] != $serial[8] ||
|
||||
$plain[12] != $serial[9] ||
|
||||
|
||||
$plain[16] != $serial[10] ||
|
||||
$plain[17] != $serial[11] ||
|
||||
$plain[18] != $serial[12] ||
|
||||
$plain[19] != $serial[13] ||
|
||||
$plain[20] != $serial[14]) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* check rnd */
|
||||
$rnd1 = ord($plain[7]);
|
||||
$rnd2 = ord($plain[15]);
|
||||
$rnd12 = ord($plain[23]);
|
||||
if(($rnd1 + $rnd2) % 256 != $rnd12)
|
||||
return FALSE;
|
||||
|
||||
/* extract counter */
|
||||
$counter = ord($plain[5]) << 24;
|
||||
$counter += ord($plain[6]) << 16;
|
||||
$counter += ord($plain[13]) << 8;
|
||||
$counter += ord($plain[14]);
|
||||
|
||||
/* success */
|
||||
return $counter;
|
||||
}
|
||||
|
||||
function wawision_pad_create($key, $serial, $counter)
|
||||
{
|
||||
/* 1st block */
|
||||
$plain = $serial[0];
|
||||
$plain .= $serial[1];
|
||||
$plain .= $serial[2];
|
||||
$plain .= $serial[3];
|
||||
$plain .= $serial[4];
|
||||
$plain .= chr($counter >> 24);
|
||||
$plain .= chr($counter >> 16);
|
||||
$plain .= chr(rand());
|
||||
|
||||
/* 2nd block */
|
||||
$plain .= $serial[5];
|
||||
$plain .= $serial[6];
|
||||
$plain .= $serial[7];
|
||||
$plain .= $serial[8];
|
||||
$plain .= $serial[9];
|
||||
$plain .= chr($counter >> 8);
|
||||
$plain .= chr($counter);
|
||||
$plain .= chr(rand());
|
||||
|
||||
/* 3rd block */
|
||||
$plain .= $serial[10];
|
||||
$plain .= $serial[11];
|
||||
$plain .= $serial[12];
|
||||
$plain .= $serial[13];
|
||||
$plain .= $serial[14];
|
||||
$plain .= chr(rand());
|
||||
$plain .= chr(rand());
|
||||
$plain .= chr((ord($plain[7])+ord($plain[15])) % 256);
|
||||
|
||||
/* encrypt using XTEA CBC */
|
||||
$xtea = new XTEA($key);
|
||||
$cipher = $xtea->encrypt($plain);
|
||||
|
||||
/* encode using wawision_encode */
|
||||
return $this->wawision_encode($cipher);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
class WFMonitor
|
||||
{
|
||||
|
||||
|
||||
function __construct(&$app)
|
||||
{
|
||||
$this->app = &$app;
|
||||
}
|
||||
|
||||
|
||||
function Error($msg)
|
||||
{
|
||||
$this->ErrorBox($msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function ErrorBox($content)
|
||||
{
|
||||
$box .="
|
||||
<table border=\"1\" width=\"100%\" bgcolor=\"#ffB6C1\">
|
||||
<tr><td>phpWebFrame Error: $content</td></tr>
|
||||
</table>";
|
||||
|
||||
echo $box;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
class WidgetAPI
|
||||
{
|
||||
private $app;
|
||||
|
||||
function __construct(&$app)
|
||||
{
|
||||
$this->app = &$app;
|
||||
}
|
||||
|
||||
function Get($name, $parsetarget)
|
||||
{
|
||||
if(file_exists("widgets/widget.$name.php")) {
|
||||
include_once("widgets/widget.$name.php");
|
||||
//echo "es gibt ein modifiziertes objecy";
|
||||
$classname = "Widget".ucfirst($name);
|
||||
return new $classname($this->app,$parsetarget);
|
||||
} else {
|
||||
//echo "es gibt nur das generiewrte";
|
||||
include_once("widgets/_gen/widget.gen.$name.php");
|
||||
//echo "es gibt ein modifiziertes objecy";
|
||||
$classname = "WidgetGen".ucfirst($name);
|
||||
return new $classname($this->app,$parsetarget);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
|
||||
class SimpleList
|
||||
{
|
||||
var $actual = 0;
|
||||
var $items = 0;
|
||||
|
||||
var $List = array();
|
||||
|
||||
function __construct(){}
|
||||
|
||||
function Add($data)
|
||||
{
|
||||
$this->List[] = $data;
|
||||
$this->actual = $this->items;
|
||||
$this->items++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
function &getFirst()
|
||||
{
|
||||
$this->actual = 0;
|
||||
return $this->getActual();
|
||||
}
|
||||
|
||||
|
||||
function getLast()
|
||||
{
|
||||
$last = count($this->List);
|
||||
$this->actual = $last;
|
||||
return $this->getActual();
|
||||
}
|
||||
|
||||
|
||||
function &getNext()
|
||||
{
|
||||
$this->actual++;
|
||||
return $this->getActual();
|
||||
}
|
||||
|
||||
function &getActual()
|
||||
{
|
||||
if($this->actual >=0 && $this->actual < $this->items)
|
||||
return $this->List[$this->actual];
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
function getPrev()
|
||||
{
|
||||
$this->actual++;
|
||||
return $this->getActual();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,866 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @deprecated Neue Chart-Klasse stattdessen verwenden
|
||||
* @see \Xentral\Widgets\Chart\Chart
|
||||
*/
|
||||
class Chart {
|
||||
public static $instancescount = 0;
|
||||
var $app;
|
||||
|
||||
var $rows;
|
||||
var $dataset;
|
||||
var $align;
|
||||
var $headings;
|
||||
var $lheadings;
|
||||
var $type;
|
||||
var $animate;
|
||||
var $colors;
|
||||
var $labels;
|
||||
var $background;
|
||||
var $colorcol;
|
||||
|
||||
function __construct(&$app, $type = 'line', $targetjquery = 'JQUERYREADY')
|
||||
{
|
||||
$this->app = &$app;
|
||||
$this->background = false;
|
||||
$this->labels = false;
|
||||
$this->animate = true;
|
||||
$this->type = $type;
|
||||
$this->sql ="";
|
||||
$this->limit ="";
|
||||
$this->stacked = false;
|
||||
$this->duration = 1000;
|
||||
$this->datasets = null;
|
||||
$this->headings = null;
|
||||
$this->lheadings = null;
|
||||
$this->yAxes = null;
|
||||
$this->colorcol = false;
|
||||
|
||||
|
||||
$this->colors = array(
|
||||
'45b9d3','a2c55a','0e8394','f69e06','f2c289','8dd4de','cbe0a4','c5e3e9',
|
||||
'0b8092', 'a9ca45', 'FF6600','f69e06', 'be3978', 'cb5a20', '41b3ce', '85cddb',
|
||||
'000000', '993300', '333300', '000080', '333399', '333333', '800000',
|
||||
'808000', '008000', '008080', '0000FF', '666699', '808080', 'FF0000', 'FF9900',
|
||||
'99CC00', '339966', '33CCCC', '3366FF', '800080', '999999', 'FF00FF', 'FFCC00',
|
||||
'FFFF00', '00FF00', '00FFFF', '00CCFF', '993366', 'C0C0C0', 'FF99CC', 'FFCC99',
|
||||
'FFFF99', 'CCFFFF', '99CCFF', '808cc8', 'FFFFFF');
|
||||
foreach($this->colors as $k => $v)$this->colors[$k] = '#'.$v;
|
||||
self::$instancescount++;
|
||||
if(false && self::$instancescount == 1)
|
||||
{
|
||||
$this->app->Tpl->Add($targetjquery,'
|
||||
|
||||
Chart.pluginService.register({
|
||||
beforeRender: function (chart) {
|
||||
if (chart.config.options.showAllTooltips) {
|
||||
chart.pluginTooltips = [];
|
||||
chart.config.data.datasets.forEach(function (dataset, i) {
|
||||
chart.getDatasetMeta(i).data.forEach(function (sector, j) {
|
||||
chart.pluginTooltips.push(new Chart.Tooltip({
|
||||
_chart: chart.chart,
|
||||
_chartInstance: chart,
|
||||
_data: chart.data,
|
||||
_options: chart.options.tooltips,
|
||||
_active: [sector]
|
||||
}, chart));
|
||||
});
|
||||
});
|
||||
|
||||
chart.options.tooltips.enabled = false;
|
||||
}
|
||||
},
|
||||
afterDraw: function (chart, easing) {
|
||||
if (chart.config.options.showAllTooltips) {
|
||||
if (!chart.allTooltipsOnce) {
|
||||
if (easing !== 1)
|
||||
return;
|
||||
chart.allTooltipsOnce = true;
|
||||
}
|
||||
|
||||
chart.options.tooltips.enabled = true;
|
||||
Chart.helpers.each(chart.pluginTooltips, function (tooltip) {
|
||||
tooltip.initialize();
|
||||
tooltip.update();
|
||||
tooltip.pivot();
|
||||
tooltip.transition(easing).draw();
|
||||
});
|
||||
chart.options.tooltips.enabled = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function AddRow($rows)
|
||||
{
|
||||
$this->datasets[] = $rows;
|
||||
}
|
||||
|
||||
function Query($sql,$labels=false,$fuelleluecken = false,$limit="")
|
||||
{
|
||||
$this->labels = $labels;
|
||||
$this->sql = $sql;
|
||||
$this->limit= $limit;
|
||||
$this->headings=null;
|
||||
$xcol = 0;
|
||||
if($limit!=0){
|
||||
$page = $this->app->Secure->GetGET("page");
|
||||
if(!is_numeric($page)) $page = 1;
|
||||
|
||||
$this->page = $page;
|
||||
$this->start= ($page-1) * $this->limit;
|
||||
|
||||
if(!is_array($sql))$sql.= " LIMIT {$this->start},{$this->limit}";
|
||||
}
|
||||
$this->searchrow="";
|
||||
if(is_array($sql))
|
||||
{
|
||||
$daten = $sql;
|
||||
}else{
|
||||
$daten = $this->app->DB->SelectArr($sql);
|
||||
}
|
||||
if(count($daten)>0){
|
||||
foreach($daten[0] as $colkey=>$value)
|
||||
{
|
||||
$this->headings[]=ucfirst($colkey);
|
||||
$this->lheadings[] = $colkey;
|
||||
$empty[$colkey] = 0;
|
||||
}
|
||||
}
|
||||
$first = $daten[0][$this->lheadings[$xcol]];
|
||||
$mysqlformat = true;
|
||||
if(strpos($first,'.') !== false)$mysqlformat = false;
|
||||
$last = $daten[count($fuelleluecken) - 1][$this->lheadings[$xcol]];
|
||||
if($fuelleluecken && is_array($fuelleluecken) && isset($fuelleluecken['typ']))
|
||||
{
|
||||
$von = false;
|
||||
$bis = false;
|
||||
$zeitraum = false;
|
||||
if(isset($fuelleluecken['von']))
|
||||
{
|
||||
$von = $fuelleluecken['von'];
|
||||
}
|
||||
if(isset($fuelleluecken['bis']))
|
||||
{
|
||||
$bis = $fuelleluecken['bis'];
|
||||
}
|
||||
if(isset($fuelleluecken['zeitraum']))
|
||||
{
|
||||
$zeitraum = $fuelleluecken['zeitraum'];
|
||||
}
|
||||
if($von || $bis || $zeitraum)
|
||||
{
|
||||
switch($fuelleluecken['typ'])
|
||||
{
|
||||
case 'tag':
|
||||
case 'tage':
|
||||
if(!$von && !$bis)
|
||||
{
|
||||
$bis = date('Y-m-d');
|
||||
$date=new DateTime(date('Y-m-d'));
|
||||
$date->sub(new DateInterval('P'.$zeitraum.'D'));
|
||||
$von = $date->format('Y-m-d');
|
||||
|
||||
}elseif(!$von)
|
||||
{
|
||||
if(strpos($bis, '.') !== false)$bis = $this->app->String->Convert($bis, "%1.%2.%3","%3-%2-%1");
|
||||
$date=new DateTime($bis);
|
||||
$date->sub(new DateInterval('P'.$zeitraum.'D'));
|
||||
$von = $date->format('Y-m-d');
|
||||
}elseif(!$bis)
|
||||
{
|
||||
if(strpos($von, '.') !== false)$von = $this->app->String->Convert($von, "%1.%2.%3","%3-%2-%1");
|
||||
$date=new DateTime($von);
|
||||
$date->add(new DateInterval('P'.$zeitraum.'D'));
|
||||
$bis = $date->format('Y-m-d');
|
||||
}
|
||||
if($von && $bis)
|
||||
{
|
||||
$datetime1 = new DateTime($bis);
|
||||
$datetime2 = new DateTime($von);
|
||||
$interval = $datetime1->diff($datetime2);
|
||||
$zeitraum = $interval->format('%a');
|
||||
foreach($daten as $key => $data)
|
||||
{
|
||||
$aktdat = $data[$this->lheadings[$xcol]];
|
||||
if(strpos($aktdat,'.') !== false)$aktdat = $this->app->String->Convert($aktdat ,"%1.%2.%3","%3-%2-%1");
|
||||
$datumzuid[$aktdat] = $key;
|
||||
}
|
||||
$aktdat = $datetime2;
|
||||
for($i = 0; $i <= $zeitraum; $i++)
|
||||
{
|
||||
if($i > 0)$aktdat->add(new DateInterval('P1D'));
|
||||
$aktdatstr = $aktdat->format('Y-m-d');
|
||||
if(isset($datumzuid[$aktdatstr]))
|
||||
{
|
||||
$this->datasets[] = $daten[$datumzuid[$aktdatstr]];
|
||||
}else{
|
||||
if($mysqlformat)
|
||||
{
|
||||
$empty[$this->lheadings[$xcol]] = $aktdatstr;
|
||||
}else{
|
||||
$empty[$this->lheadings[$xcol]] = $this->app->String->Convert($aktdatstr,"%3-%2-%1","%1.%2.%3");
|
||||
}
|
||||
$this->datasets[] = $empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'monat':
|
||||
case 'monate':
|
||||
if(!$von && !$bis)
|
||||
{
|
||||
$bis = date('m/Y');
|
||||
$date=new DateTime(date("Y-m-d"));
|
||||
$date->sub(new DateInterval('P'.($zeitraum-1).'M'));
|
||||
$von = $date->format('m/Y');
|
||||
|
||||
}elseif(!$von)
|
||||
{
|
||||
if(strpos($bis, '.') !== false)$bis = $this->app->String->Convert($bis, "%1.%2.%3","%2\/%3");
|
||||
$date=new DateTime($bis);
|
||||
$date->sub(new DateInterval('P'.($zeitraum-1).'M'));
|
||||
$von = $date->format('m/Y');
|
||||
}elseif(!$bis)
|
||||
{
|
||||
if(strpos($von, '.') !== false)$von = $this->app->String->Convert($von, "%1.%2.%3","%2\/%3");
|
||||
$date=new DateTime($von);
|
||||
$date->add(new DateInterval('P'.($zeitraum-1).'M'));
|
||||
$bis = $date->format('m/Y');
|
||||
}
|
||||
if($von && $bis)
|
||||
{
|
||||
|
||||
$von = $this->app->String->Convert($von,"%2\/%3","%3-%2-01");
|
||||
$bis = $this->app->String->Convert($bis,"%2\/%3","%3-%2-01");
|
||||
$datetime1 = new DateTime($bis);
|
||||
$datetime2 = new DateTime($von);
|
||||
$interval = $datetime1->diff($datetime2);
|
||||
|
||||
$zeitraum = ($interval->format('%d') > 27?1:0)+$interval->format('%m')+12*$interval->format('%y');
|
||||
|
||||
$_zeitbis = new DateTime($bis);
|
||||
$_zeitbis->add(new DateInterval('P'.$zeitraum.'M'));
|
||||
if($datetime1->format('m/Y') != $_zeitbis->format('m/Y'))$zeitraum++;
|
||||
|
||||
foreach($daten as $key => $data)
|
||||
{
|
||||
$aktdat = $data[$this->lheadings[$xcol]];
|
||||
if(strpos($aktdat,'.') !== false)$aktdat = $this->app->String->Convert($aktdat ,"%1.%2.%3","%2\/%3");
|
||||
$datumzuid[$aktdat] = $key;
|
||||
}
|
||||
$aktdat = $datetime2;
|
||||
for($i = 0; $i < $zeitraum; $i++)
|
||||
{
|
||||
if($i > 0)$aktdat->add(new DateInterval('P1M'));
|
||||
$aktdatstr = $aktdat->format('m/Y');
|
||||
if(isset($datumzuid[$aktdatstr]))
|
||||
{
|
||||
$this->datasets[] = $daten[$datumzuid[$aktdatstr]];
|
||||
}else{
|
||||
if($mysqlformat)
|
||||
{
|
||||
$empty[$this->lheadings[$xcol]] = $aktdatstr;
|
||||
}else{
|
||||
$empty[$this->lheadings[$xcol]] = $this->app->String->Convert($aktdatstr,"%1.%2.%3","%2\/%3");
|
||||
}
|
||||
$this->datasets[] = $empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
$this->datasets = $daten;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->datasets = $daten;
|
||||
}
|
||||
}
|
||||
|
||||
function kommulieren()
|
||||
{
|
||||
if($this->datasets)
|
||||
{
|
||||
|
||||
foreach($this->datasets as $k => $row)
|
||||
{
|
||||
$first = true;
|
||||
foreach($row as $key => $v)
|
||||
{
|
||||
if($first)
|
||||
{
|
||||
$first = false;
|
||||
}else{
|
||||
if(!isset($sum[$key]))$sum[$key] = 0;
|
||||
$sum[$key] += $v;
|
||||
$this->datasets[$k][$key] = $sum[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function replaceLabelsDate($label)
|
||||
{
|
||||
if(preg_match_all('/^[1-2]{1}[0-9]{3}\-[0-1]{1}[0-9]{1}\-[0-3]{1}[0-9]{1}$/', $label, $erg))$label = $this->app->String->Convert($label, '%1-%2-%3', '%3.%2.%1');
|
||||
return $label;
|
||||
}
|
||||
|
||||
// Fügt $value in $array ein, an der Stelle $index
|
||||
function array_insert($array, $index, $value)
|
||||
{
|
||||
return array_merge(array_slice($array, 0, $index), $value, array_slice($array, $index));
|
||||
}
|
||||
|
||||
function DisplayWithBox($parsetarget,$id,$name,$width = "300",$height = "250",$style="")
|
||||
{
|
||||
$this->calcbcolors();
|
||||
$_width = $width;
|
||||
$this->app->Tpl->Add($parsetarget, '<div class="dashbox dashbox_grey" id="db'.$id.'" style="width:98%; display:block;">
|
||||
'.($name?'<div class="dashbox_header" style="display:block;">'.$name.'</div>':'').'
|
||||
<div class="dashbox_content" width="100%" style="display:block;">');
|
||||
switch($this->type)
|
||||
{
|
||||
case 'polarArea':
|
||||
case 'doughnut':
|
||||
if(count($this->datasets) > 0 && $this->labels)
|
||||
{
|
||||
$this->app->Tpl->Add($parsetarget,'<ul class="chart_legendbox" style="display:block;position:relative;padding-top:2px;padding-right:2px;margin:0;min-height:50px;float:right;list-style-type:none;font-size:65%;">');
|
||||
$j = 0;
|
||||
$i = 1;
|
||||
$sum = 0;
|
||||
foreach($this->datasets as $row)
|
||||
{
|
||||
$el = (float)$row[$this->lheadings[$i]];
|
||||
$sum += $el;
|
||||
}
|
||||
|
||||
foreach($this->datasets as $row)
|
||||
{
|
||||
$_label = $row[$this->lheadings[0]];
|
||||
$wert = $row[$this->lheadings[$i]];
|
||||
$proz = 100*($sum > 0?($wert / $sum):0);
|
||||
if($this->colors && count($this->colors) > 0);
|
||||
|
||||
$farbe = $this->colors[$j % count($this->colors)];
|
||||
$this->app->Tpl->Add($parsetarget,'<li><span style="background-color:'.$farbe.';width:10px;left:20px;position:absolute;height:10px;margin:0;display:inline-block;"></span><span style="text-align:left;width:100%;display:inline-block;">'.$_label.' '.number_format($wert,2,',','.').' ('.round($proz,1).'%)</span></li>');
|
||||
$j++;
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget,'</ul>');
|
||||
}
|
||||
break;
|
||||
}
|
||||
$this->Display($parsetarget, $id, $width,(int)$height-50, $style);
|
||||
$this->app->Tpl->Add($parsetarget,'</div></div><div style="clear:both;"></div>');
|
||||
}
|
||||
|
||||
function calcbcolors($alpha = 0.1)
|
||||
{
|
||||
if($this->colorcol)
|
||||
{
|
||||
if(isset($this->lheadings[$this->colorcol-1]))
|
||||
{
|
||||
foreach($this->datasets as $k => $row)
|
||||
{
|
||||
if(isset($row[$this->lheadings[$this->colorcol-1]]) && $row[$this->lheadings[$this->colorcol-1]] && strtolower(str_replace('#','',$row[$this->lheadings[$this->colorcol-1]])) != 'ffffff')
|
||||
{
|
||||
|
||||
$this->colors[$k] = str_replace('#','',$row[$this->lheadings[$this->colorcol-1]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($this->colors as $key => $v)
|
||||
{
|
||||
$v = strtoupper(str_replace('#','',$v));
|
||||
if(strlen($v) == 3) $v = $v[0].$v[0].$v[1].$v[1].$v[2].$v[2];
|
||||
$this->colors[$key] = '#'.$v;
|
||||
$r = (int)hexdec($v[0].$v[1]);
|
||||
$g = (int)hexdec($v[2].$v[3]);
|
||||
$b = (int)hexdec($v[4].$v[5]);
|
||||
$this->bcolors[$key] = 'rgba('.$r.','.$g.','.$b.','.$alpha.')';
|
||||
}
|
||||
}
|
||||
|
||||
function Display($parsetarget,$id,$width = "300",$height = "200",$style="")
|
||||
{
|
||||
$this->calcbcolors();
|
||||
$this->app->Tpl->Add($parsetarget, '<canvas id="'.$id.'" width="'.$width.'" height="'.$height.'"></canvas>
|
||||
<script>
|
||||
var myChart'.$id.' = null;
|
||||
|
||||
var ctx'.$id.' = document.getElementById("'.$id.'");
|
||||
|
||||
setTimeout(function(){
|
||||
myChart'.$id.' = new Chart(ctx'.$id.', {
|
||||
type: \''.$this->type.'\',
|
||||
animation:{
|
||||
animateScale:'.($this->animate?'true':'false').',
|
||||
duration:'.$this->duration.'
|
||||
},
|
||||
|
||||
data: {
|
||||
');
|
||||
|
||||
switch($this->type)
|
||||
{
|
||||
case 'line':
|
||||
|
||||
if($this->labels)
|
||||
{
|
||||
$this->app->Tpl->Add($parsetarget,'labels: ["');
|
||||
if(count($this->datasets)>0){
|
||||
foreach($this->datasets as $row){
|
||||
foreach($row as $col)
|
||||
{
|
||||
$tmplabel[] = $this->replaceLabelsDate($col);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget, implode('","',$tmplabel));
|
||||
}
|
||||
|
||||
$this->app->Tpl->Add($parsetarget,'"],');
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget,'datasets: [');
|
||||
for($i = 0; $i < count($this->headings); $i++)
|
||||
{
|
||||
if($i > 0 || !$this->labels)
|
||||
{
|
||||
$this->app->Tpl->Add($parsetarget, '{
|
||||
label: "'.$this->headings[$i].'",
|
||||
|
||||
'.(!is_null($this->yAxes)?'
|
||||
yAxisID: "y-axis-'.$this->yAxes[$i-($this->labels?1:0)].'",
|
||||
':'').'
|
||||
|
||||
fill: '.($this->background?'true':'false').',
|
||||
lineTension: 0.1,
|
||||
|
||||
borderColor:"'.$this->colors[$i-($this->labels?1:0)].'",
|
||||
|
||||
borderCapStyle: "butt",
|
||||
borderDash: [],
|
||||
borderDashOffset: 0.0,
|
||||
borderJoinStyle: "miter",
|
||||
backgroundColor: "'.$this->bcolors[$i-($this->labels?1:0)].'",
|
||||
pointBackgroundColor: "'.$this->colors[$i-($this->labels?1:0)].'",
|
||||
pointBorderWidth: 1,
|
||||
pointHoverRadius: 5,
|
||||
|
||||
pointHoverBorderWidth: 2,
|
||||
pointRadius: 1,
|
||||
pointHitRadius: 10,
|
||||
data: [');
|
||||
if(count($this->datasets) > 0)
|
||||
{
|
||||
foreach($this->datasets as $row)
|
||||
{
|
||||
$els[] = $row[$this->lheadings[$i]];
|
||||
}
|
||||
|
||||
$this->app->Tpl->Add($parsetarget,implode(',', $els));
|
||||
unset($els);
|
||||
}
|
||||
|
||||
$this->app->Tpl->Add($parsetarget,"],}\r\n");
|
||||
if($i < count($this->headings) - 1)$this->app->Tpl->Add($parsetarget,',');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget,"]\r\n");
|
||||
$this->app->Tpl->Add($parsetarget,'},
|
||||
options: {
|
||||
xAxes: [{
|
||||
display: false
|
||||
}],responsive: true ,scales: {
|
||||
xAxes: [{
|
||||
'.($this->stacked?'stacked: true,':'').'
|
||||
}],
|
||||
yAxes: [
|
||||
'.(!is_null($this->yAxes)?'
|
||||
{
|
||||
position: "left",
|
||||
type:"linear",
|
||||
display:true,
|
||||
id: "y-axis-1"
|
||||
'.($this->stacked?',stacked: true':'').'
|
||||
|
||||
},{
|
||||
position: "right",
|
||||
type:"linear",
|
||||
display:true,
|
||||
id: "y-axis-2"
|
||||
'.($this->stacked?',stacked: true':'').'
|
||||
|
||||
}
|
||||
':'
|
||||
{
|
||||
'.($this->stacked?'stacked: true':'').'
|
||||
}
|
||||
').'
|
||||
|
||||
]
|
||||
}, tooltips: {
|
||||
callbacks: {
|
||||
label: function(tooltipItem, data) {
|
||||
var dataset = data.datasets[tooltipItem.datasetIndex];
|
||||
var total = dataset.data.reduce(function(previousValue, currentValue, currentIndex, array) {
|
||||
return previousValue + currentValue;
|
||||
});
|
||||
var currentValue = dataset.data[tooltipItem.index];
|
||||
var name = dataset.label;
|
||||
name = name +\': \';
|
||||
//name = \'\';
|
||||
|
||||
var x = parseFloat(currentValue);
|
||||
var k = (x.toFixed(2)).toString().replace(\'.\',\',\');
|
||||
var anzstellen = k.length;
|
||||
var vorzeichen = 0;
|
||||
if(k.substring(0,1) == \'-\')
|
||||
{
|
||||
vorzeichen = 1;
|
||||
}
|
||||
if(anzstellen - 1 <= 6){
|
||||
currentValue = k;
|
||||
}else{
|
||||
var vorzeichenstring = \'\';
|
||||
if(vorzeichen)vorzeichenstring = k.substring(0, 1);
|
||||
var vorkomma = k.substring(vorzeichen, anzstellen - 3);
|
||||
var ret = vorzeichenstring;
|
||||
var modstellen = vorkomma.length % 3;
|
||||
if(modstellen > 0)ret = ret + vorkomma.substring(0, modstellen)+\'.\';
|
||||
var nachkomma = k.substring(anzstellen - 3, anzstellen);
|
||||
|
||||
var i = 0;
|
||||
for(i = 0; i < Math.floor(vorkomma.length / 3); i++)
|
||||
{
|
||||
if(i > 0)ret = ret + \'.\';
|
||||
ret = ret + vorkomma.substring(i*3+modstellen, (i+1)*3+modstellen);
|
||||
}
|
||||
ret = ret+nachkomma;
|
||||
currentValue = ret;
|
||||
}
|
||||
|
||||
return name+currentValue;
|
||||
}
|
||||
},backgroundColor: "rgba(0,0,0,0.5)"
|
||||
}
|
||||
}
|
||||
|
||||
});');
|
||||
|
||||
break;
|
||||
case 'bar':
|
||||
if($this->labels)
|
||||
{
|
||||
$this->app->Tpl->Add($parsetarget,'labels: ["');
|
||||
if(count($this->datasets)>0){
|
||||
foreach($this->datasets as $row){
|
||||
foreach($row as $col)
|
||||
{
|
||||
$tmplabel[] = $this->replaceLabelsDate($col);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget, implode('","',$tmplabel));
|
||||
}
|
||||
|
||||
$this->app->Tpl->Add($parsetarget,'"],');
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget,'datasets: [');
|
||||
for($i = 0; $i < count($this->headings); $i++)
|
||||
{
|
||||
if($i > 0 || !$this->labels)
|
||||
{
|
||||
$this->app->Tpl->Add($parsetarget, '{
|
||||
label: "'.$this->headings[$i].'",
|
||||
backgroundColor:"'.$this->colors[$i-($this->labels?1:0)].'",
|
||||
|
||||
'.(!is_null($this->yAxes)?'
|
||||
yAxisID: "y-axis-'.$this->yAxes[$i-($this->labels?1:0)].'",
|
||||
':'').'
|
||||
data: [');
|
||||
if(count($this->datasets) > 0)
|
||||
{
|
||||
foreach($this->datasets as $row)
|
||||
{
|
||||
$els[] = $row[$this->lheadings[$i]];
|
||||
}
|
||||
|
||||
$this->app->Tpl->Add($parsetarget,implode(',', $els));
|
||||
unset($els);
|
||||
}
|
||||
|
||||
$this->app->Tpl->Add($parsetarget,"],}\r\n");
|
||||
if($i < count($this->headings) - 1)$this->app->Tpl->Add($parsetarget,',');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget,"]\r\n");
|
||||
$this->app->Tpl->Add($parsetarget,'},
|
||||
options: {
|
||||
xAxes: [{
|
||||
display: false
|
||||
}]
|
||||
|
||||
|
||||
,scales: {
|
||||
xAxes: [{
|
||||
'.($this->stacked?'stacked: true,':'').'
|
||||
}],
|
||||
yAxes: [
|
||||
'.(!is_null($this->yAxes)?'
|
||||
{
|
||||
position: "left",
|
||||
type:"linear",
|
||||
display:true,
|
||||
id: "y-axis-1"
|
||||
'.($this->stacked?',stacked: true':'').'
|
||||
|
||||
},{
|
||||
position: "right",
|
||||
type:"linear",
|
||||
display:true,
|
||||
id: "y-axis-2"
|
||||
'.($this->stacked?',stacked: true':'').'
|
||||
|
||||
}
|
||||
':'
|
||||
{
|
||||
'.($this->stacked?'stacked: true':'').'
|
||||
}
|
||||
').'
|
||||
|
||||
]
|
||||
}, tooltips: {
|
||||
callbacks: {
|
||||
label: function(tooltipItem, data) {
|
||||
var dataset = data.datasets[tooltipItem.datasetIndex];
|
||||
var total = dataset.data.reduce(function(previousValue, currentValue, currentIndex, array) {
|
||||
return previousValue + currentValue;
|
||||
});
|
||||
var currentValue = dataset.data[tooltipItem.index];
|
||||
var name = dataset.label;
|
||||
name = name +\': \';
|
||||
//name = \'\';
|
||||
|
||||
var x = parseFloat(currentValue);
|
||||
var k = (x.toFixed(2)).toString().replace(\'.\',\',\');
|
||||
var anzstellen = k.length;
|
||||
var vorzeichen = 0;
|
||||
if(k.substring(0,1) == \'-\')
|
||||
{
|
||||
vorzeichen = 1;
|
||||
}
|
||||
if(anzstellen - 1 <= 6){
|
||||
currentValue = k;
|
||||
}else{
|
||||
var vorzeichenstring = \'\';
|
||||
if(vorzeichen)vorzeichenstring = k.substring(0, 1);
|
||||
var vorkomma = k.substring(vorzeichen, anzstellen - 3);
|
||||
var ret = vorzeichenstring;
|
||||
var modstellen = vorkomma.length % 3;
|
||||
if(modstellen > 0)ret = ret + vorkomma.substring(0, modstellen)+\'.\';
|
||||
var nachkomma = k.substring(anzstellen - 3, anzstellen);
|
||||
|
||||
var i = 0;
|
||||
for(i = 0; i < Math.floor(vorkomma.length / 3); i++)
|
||||
{
|
||||
if(i > 0)ret = ret + \'.\';
|
||||
ret = ret + vorkomma.substring(i*3+modstellen, (i+1)*3+modstellen);
|
||||
}
|
||||
ret = ret+nachkomma;
|
||||
currentValue = ret;
|
||||
}
|
||||
|
||||
return name+currentValue;
|
||||
}
|
||||
},backgroundColor: "rgba(0,0,0,0.5)"
|
||||
}
|
||||
,responsive: true
|
||||
}
|
||||
|
||||
});');
|
||||
|
||||
break;
|
||||
case 'polarArea':
|
||||
case 'doughnut':
|
||||
$this->app->Tpl->Add($parsetarget,'labels: ["');
|
||||
if(count($this->datasets)>0){
|
||||
foreach($this->datasets as $row){
|
||||
foreach($row as $col)
|
||||
{
|
||||
$tmplabel[] = $col;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget, implode('","',$tmplabel));
|
||||
}
|
||||
|
||||
$this->app->Tpl->Add($parsetarget,'"],');
|
||||
$this->app->Tpl->Add($parsetarget,'datasets: [');
|
||||
if(count($this->datasets) > 0)
|
||||
{
|
||||
$i = 1;
|
||||
if($i > 0 || !$this->labels)
|
||||
{
|
||||
$this->app->Tpl->Add($parsetarget, '{
|
||||
label: "'.$this->headings[$i].'",
|
||||
data: [');
|
||||
if(count($this->datasets) > 0)
|
||||
{
|
||||
foreach($this->datasets as $row)
|
||||
{
|
||||
$els[] = $row[$this->lheadings[$i]];
|
||||
}
|
||||
|
||||
$this->app->Tpl->Add($parsetarget,implode(',', $els));
|
||||
unset($els);
|
||||
}
|
||||
|
||||
$this->app->Tpl->Add($parsetarget,"],\r\n");
|
||||
|
||||
|
||||
$this->app->Tpl->Add($parsetarget, 'backgroundColor:[');
|
||||
if(count($this->datasets) > 0)
|
||||
{
|
||||
$j = 0;
|
||||
foreach($this->datasets as $row)
|
||||
{
|
||||
if($this->colors && count($this->colors) > 0);
|
||||
if($j > 0)$this->app->Tpl->Add($parsetarget,',');
|
||||
$this->app->Tpl->Add($parsetarget,'"'.$this->colors[$j % count($this->colors)].'"');
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget,"]}\r\n");
|
||||
//if($i < count($this->headings) - 1)$this->app->Tpl->Add($parsetarget,',');
|
||||
}
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget,"]\r\n");
|
||||
$this->app->Tpl->Add($parsetarget,'},
|
||||
options: {showAllTooltips: true,
|
||||
cutoutPercentage: 50');
|
||||
if(!$this->labels || true)
|
||||
{
|
||||
$this->app->Tpl->Add($parsetarget,'
|
||||
,legend:{display:false}
|
||||
');
|
||||
}else{
|
||||
$this->app->Tpl->Add($parsetarget,'
|
||||
,legend: {
|
||||
position: \'top\',
|
||||
}
|
||||
');
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget, '
|
||||
,showTooltips: true,
|
||||
|
||||
tooltips: {
|
||||
callbacks: {
|
||||
label: function(tooltipItem, data) {
|
||||
var dataset = data.datasets[tooltipItem.datasetIndex];
|
||||
var total = dataset.data.reduce(function(previousValue, currentValue, currentIndex, array) {
|
||||
return previousValue + currentValue;
|
||||
});
|
||||
var currentValue = dataset.data[tooltipItem.index];
|
||||
var precentage = Math.floor(((currentValue/total) * 100)+0.5);
|
||||
var name = data.labels[tooltipItem.index];
|
||||
name = name +\': \';
|
||||
//name = \'\';
|
||||
|
||||
var x = parseFloat(currentValue);
|
||||
var k = (x.toFixed(2)).toString().replace(\'.\',\',\');
|
||||
var anzstellen = k.length;
|
||||
var vorzeichen = 0;
|
||||
if(k.substring(0,1) == \'-\')
|
||||
{
|
||||
vorzeichen = 1;
|
||||
}
|
||||
if(anzstellen - 1 <= 6){
|
||||
currentValue = k;
|
||||
}else{
|
||||
var vorzeichenstring = \'\';
|
||||
if(vorzeichen)vorzeichenstring = k.substring(0, 1);
|
||||
var vorkomma = k.substring(vorzeichen, anzstellen - 3);
|
||||
var ret = vorzeichenstring;
|
||||
var modstellen = vorkomma.length % 3;
|
||||
if(modstellen > 0)ret = ret + vorkomma.substring(0, modstellen)+\'.\';
|
||||
var nachkomma = k.substring(anzstellen - 3, anzstellen);
|
||||
|
||||
var i = 0;
|
||||
for(i = 0; i < Math.floor(vorkomma.length / 3); i++)
|
||||
{
|
||||
if(i > 0)ret = ret + \'.\';
|
||||
ret = ret + vorkomma.substring(i*3+modstellen, (i+1)*3+modstellen);
|
||||
}
|
||||
ret = ret+nachkomma;
|
||||
currentValue = ret;
|
||||
}
|
||||
return name+currentValue+\' (\'+ precentage + "%)";
|
||||
}
|
||||
},backgroundColor: "rgba(0,0,0,0.5)"
|
||||
},responsive: true,responsiveAnimationDuration:'.$this->duration.'
|
||||
|
||||
|
||||
}
|
||||
|
||||
}); ');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$this->app->Tpl->Add($parsetarget, '
|
||||
|
||||
var aktc = 0
|
||||
$(\'.chart_legendbox\').each(function(){if(aktc < $(this).height())aktc = $(this).height();
|
||||
});
|
||||
if(aktc != 0)
|
||||
{
|
||||
$(\'.chart_legendbox\').each(function(){
|
||||
if(aktc < $(this).height())aktc = $(this).height();
|
||||
if($(this).height() < aktc)
|
||||
{
|
||||
$(this).css(\'height\',aktc+\'px\');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
,100);</script>');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CHild Tabelle
|
||||
* Stellt eine -Formatierte Child Tabelle mit optionalem Zeilenmenü zur Verfügung.
|
||||
*
|
||||
* @package
|
||||
* @author Benedikt Sauter <sauter@ixbat.de>
|
||||
* @author coma ag <info@coma.de>
|
||||
* @author *105 - Multimediabüro <development@stern105.de>
|
||||
* @version 1.0
|
||||
* @since PHP 4.x
|
||||
*/
|
||||
class ChildTable {
|
||||
|
||||
/**
|
||||
* Target template to wich the table will be parsed. [Default: PAGE]
|
||||
* @type string
|
||||
*/
|
||||
var $parsetarget;
|
||||
|
||||
/**
|
||||
* HTMLTable. Apply format changes to this object.
|
||||
* @type Object
|
||||
* @access public
|
||||
*/
|
||||
var $table;
|
||||
|
||||
var $editdate;
|
||||
var $datasetssql;
|
||||
|
||||
|
||||
var $arrayuse;
|
||||
|
||||
/**
|
||||
* Constructor method
|
||||
*
|
||||
* @param $app Default application class
|
||||
*
|
||||
* @return Generated object ($this)
|
||||
* @access public
|
||||
*/
|
||||
function __construct(&$app, $name, $parsetarget="PAGE",$editdate=false) {
|
||||
$this->app = &$app;
|
||||
$this->parsetarget=$parsetarget;
|
||||
$this->name=$name;
|
||||
$this->editdate = $editdate;
|
||||
} // end of constructor
|
||||
|
||||
|
||||
// defines all datasets
|
||||
function DataSets($sql) {
|
||||
$this->datasetssql = $sql;
|
||||
} // end of function
|
||||
|
||||
function Register($pointer, $event, $function) {
|
||||
$this->events[$event] = $function;
|
||||
$this->pointer = $pointer;
|
||||
} // end of function
|
||||
|
||||
function CatchEvents() {
|
||||
$event=$this->app->Secure->GetPOST("{$this->name}_event");
|
||||
|
||||
if(is_array($event)){
|
||||
$function = $this->events[key($event)];
|
||||
$this->pointer->$function($event[key($event)]);
|
||||
} // end of if
|
||||
} // end of function
|
||||
|
||||
|
||||
function MarkLineIfColHasValue($col,$value,$replace,$exclude)
|
||||
{
|
||||
$this->mark_col = $col;
|
||||
$this->mark_value = $value;
|
||||
$this->mark_replace = $replace;
|
||||
$this->mark_exclude = $exclude;
|
||||
|
||||
$this->mark = true;
|
||||
}
|
||||
|
||||
/* Diese Funktion dient fuer tabellen in denen die sipchildtables zeilen verschiedene bedeutungen haben
|
||||
*/
|
||||
|
||||
function ShowMultiRow($contentArr){
|
||||
$this->arrayuse = true;
|
||||
|
||||
//$this->app->Table->CreateTable($this->datasetssql, $this->parsetarget, 400);
|
||||
//$contentArr = $this->app->DB->SelectArr( $this->datasetssql );
|
||||
$this->app->Table->CreateTableFromArray($contentArr, $this->parsetarget, 450);
|
||||
//$this->app->Table->FormatCondition(1, "", "<span style=\"color:red;\"class=\"inactive\">%value%</span>", array(5,6));
|
||||
|
||||
$this->Show();
|
||||
}
|
||||
|
||||
function Show() {
|
||||
$this->CatchEvents();
|
||||
if(!$this->arrayuse)
|
||||
$this->app->Table->CreateTable($this->datasetssql, $this->parsetarget, 400);
|
||||
|
||||
|
||||
$numberofdatasets = count($this->app->DB->SelectArr($this->datasetssql));
|
||||
$module = $this->app->Secure->GetGET("module");
|
||||
$id = $this->app->Secure->GetGET("id");
|
||||
|
||||
$delbutton = "<input type=\"submit\" class=\"bu_delete\" title=\"Eintrag löschen\" name=\"{$this->name}_event[delete]\" value=\"%value%\">";
|
||||
// $editbutton = "<input type=\"submit\" class=\"bu_edit\" title=\"Datum bearbeiten\" name=\"{$this->name}_event[editdate]\" value=\"%value%\">";
|
||||
$editbutton = "<input type=\"button\"
|
||||
onclick=\"window.location.href='index.php?module=$module&action=editdate&id=$id&value=%value%&childtable={$this->name}'\"
|
||||
class=\"bu_edit\" title=\"Datum bearbeiten\">";
|
||||
$downbutton = "<input type=\"submit\" class=\"bu_down\" title=\"Nach unten\" name=\"{$this->name}_event[down]\" value=\"%value%\">";
|
||||
$upbutton = "<input type=\"submit\" class=\"bu_up\" title=\"Nach oben\" name=\"{$this->name}_event[up]\" value=\"%value%\">";
|
||||
$addbutton = "<input type=\"button\"
|
||||
onclick=\"window.location.href='index.php?module=$module&action=addafter&id=$id&value=%value%&childtable={$this->name}'\"
|
||||
class=\"bu_add\" title=\"Nach diesem Eintrag einfügen\">";
|
||||
$addfbutton = "<input type=\"button\"
|
||||
onclick=\"window.location.href='index.php?module=$module&action=addfafter&hut=$id&value=%value%&childtable={$this->name}'\"
|
||||
class=\"bu_addf\" title=\"Nach diesem Eintrag einfügen\">";
|
||||
|
||||
|
||||
$menunew = $addbutton;
|
||||
$menusingle = $delbutton.$addbutton.$addfbutton;
|
||||
$menufirst = $delbutton.$addbutton.$addfbutton.$downbutton;
|
||||
$menu = $delbutton.$addbutton.$addfbutton.$downbutton.$upbutton;
|
||||
$menulast = $delbutton.$addbutton.$addfbutton.$upbutton;
|
||||
|
||||
// falls zeit relation berarbeitet werden soll
|
||||
if($this->editdate)
|
||||
{
|
||||
$menulast .= $editbutton;
|
||||
$menu .= $editbutton;
|
||||
$menufirst .= $editbutton;
|
||||
$menusingle .= $editbutton;
|
||||
|
||||
$header = '
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="divider">Nr.</th>
|
||||
<th class="divider">Name</th>
|
||||
<th class="divider">ID</th>
|
||||
<th class="divider">Gültig von - bis</th>
|
||||
';
|
||||
}
|
||||
else {
|
||||
$header = '
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="divider">Nr.</th>
|
||||
<th class="divider">Name</th>
|
||||
<th class="divider">ID</th>
|
||||
';
|
||||
}
|
||||
|
||||
|
||||
if(count($this->events)>0)
|
||||
$header .= '<th class="divider">Aktion</th>';
|
||||
|
||||
$header .= '
|
||||
</tr>
|
||||
</thead>';
|
||||
|
||||
$this->app->Table->HeadingTop($header);
|
||||
|
||||
|
||||
if($this->editdate){
|
||||
$arr = array(1, 2, 3, 4,6);
|
||||
}
|
||||
else{
|
||||
$arr = array(1, 2, 3, 5);
|
||||
}
|
||||
|
||||
// erstellen der richtigen menues
|
||||
for($i=1;$i<=$numberofdatasets;$i++) {
|
||||
if($numberofdatasets==1)
|
||||
$this->app->Table->FormatCondition(1, 1, $menusingle, $arr);
|
||||
else if($i==1)
|
||||
$this->app->Table->FormatCondition(1, 1, $menufirst, $arr);
|
||||
else if($i == $numberofdatasets)
|
||||
$this->app->Table->FormatCondition(1, $numberofdatasets, $menulast, $arr);
|
||||
else
|
||||
$this->app->Table->FormatCondition(1, $i, $menu, $arr);
|
||||
} // end of for
|
||||
|
||||
|
||||
if(count($this->events)==0) {
|
||||
if($this->editdate){
|
||||
$this->app->Table->FormatCondition(6, 0, "<span class=\"inactive\">%value%</span>", array(5,6));
|
||||
$this->app->Table->HideCol(6);
|
||||
}
|
||||
else {
|
||||
$this->app->Table->FormatCondition(5, 0, "<span class=\"inactive\">%value%</span>", array(4, 5));
|
||||
$this->app->Table->HideCol(5);
|
||||
$this->app->Table->HideCol(4); // menu ausblenden falls keine events registriert sind
|
||||
}
|
||||
} else {
|
||||
// inaktiv zeile
|
||||
if($this->editdate){
|
||||
$this->app->Table->FormatCondition(6, 0, "<span class=\"inactive\">%value%</span>", array(5, 6));
|
||||
$this->app->Table->HideCol(6);
|
||||
}
|
||||
else {
|
||||
$this->app->Table->FormatCondition(5, 0, "<span class=\"inactive\">%value%</span>", array(4, 5));
|
||||
$this->app->Table->HideCol(5);
|
||||
}
|
||||
} // end of if/else
|
||||
|
||||
|
||||
|
||||
if($this->mark && count($this->events)!=0) {
|
||||
$this->app->Table->FormatCondition($this->mark_col, $this->mark_value, $this->mark_replace,$this->mark_exclude);
|
||||
$this->app->Table->HideCol(6);
|
||||
}
|
||||
|
||||
|
||||
if ($numberofdatasets > 0)
|
||||
$this->app->Table->Show();
|
||||
else {
|
||||
$table = '
|
||||
<table width=400 cellpadding="0" cellspacing="0">
|
||||
[TABLEHEADER]
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>keine Elemente vorhanden</td>
|
||||
<td></td>';
|
||||
|
||||
if(count($this->events)!=0)
|
||||
$table .= '<td>'.$menunew.'</td>';
|
||||
|
||||
$table .= '</tr></table>';
|
||||
//$this->app->Tpl->Set(TABLEHEADER,$header);
|
||||
$this->app->Tpl->Set($this->parsetarget,$table, array('TABLEHEADER'));
|
||||
} // end of if
|
||||
} // end of function
|
||||
|
||||
} // end of class
|
||||
?>
|
||||
@@ -0,0 +1,428 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class DownloadSpoolerTable
|
||||
*/
|
||||
class DownloadSpoolerTable
|
||||
{
|
||||
/** @var erpooSystem $app */
|
||||
protected $app;
|
||||
|
||||
/** @var int $printerId */
|
||||
protected $printerId;
|
||||
|
||||
/** @var array $columns */
|
||||
protected $columns = [];
|
||||
|
||||
/** @var array $filter */
|
||||
protected $filter = [];
|
||||
|
||||
/** @var array $order Initiale Sortierung */
|
||||
protected $order = [[0, 'asc']];
|
||||
|
||||
/** @var string $sqlTemplate */
|
||||
protected $sqlTemplate = '';
|
||||
|
||||
/** @var string $sqlCount */
|
||||
protected $sqlCount = '';
|
||||
|
||||
/**
|
||||
* @param erpooSystem $app
|
||||
* @param int $printerId
|
||||
*/
|
||||
public function __construct($app, $printerId)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->printerId = (int)$printerId;
|
||||
|
||||
$this->Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function Init()
|
||||
{
|
||||
$table = $this->GetAdressenTable();
|
||||
|
||||
$this->sqlTemplate = $table['sql_template'];
|
||||
$this->sqlCount = $table['sql_count'];
|
||||
$this->columns = $table['columns'];
|
||||
$this->filter = $table['filter'];
|
||||
$this->order = $table['order'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $filterParams
|
||||
* @param string|null $searchQuery Suchbegriff
|
||||
* @param int $orderCol Spalten-Index
|
||||
* @param string $orderDir [asc|desc]
|
||||
* @param int $offset
|
||||
* @param int $limit
|
||||
* @param int $draw
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetData(
|
||||
$filterParams = [],
|
||||
$searchQuery = null,
|
||||
$orderCol = 0,
|
||||
$orderDir = 'asc',
|
||||
$offset = 0,
|
||||
$limit = 10,
|
||||
$draw = 1
|
||||
)
|
||||
{
|
||||
$where = [];
|
||||
|
||||
// Suche
|
||||
if ($searchQuery !== null){
|
||||
$searchParts = [];
|
||||
foreach ($this->columns as $column) {
|
||||
if (!isset($column['search'])) {
|
||||
continue;
|
||||
}
|
||||
$searchParts[] = sprintf(' %s LIKE \'%%%s%%\' ', $column['search'], $searchQuery);
|
||||
}
|
||||
$where[] = '(' . implode(' OR ', $searchParts) .')';
|
||||
}
|
||||
|
||||
// Filter
|
||||
if (!empty($filterParams)) {
|
||||
foreach ($filterParams as $filterName => $filterActive) {
|
||||
$where[] = $this->GenerateFilterSql($filterName, $filterActive);
|
||||
}
|
||||
}
|
||||
$whereString = implode(' AND ', $where);
|
||||
if (empty($whereString)) {
|
||||
$whereString = ' 1 ';
|
||||
}
|
||||
|
||||
// Sortierung
|
||||
$orderColumnName = !empty(array_column($this->columns, 'search')[$orderCol])?
|
||||
array_column($this->columns, 'search')[$orderCol]:
|
||||
array_column($this->columns, 'data')[$orderCol];
|
||||
$orderDirection = strtolower($orderDir) === 'desc' ? 'DESC' : 'ASC';
|
||||
$orderBy = !empty($orderColumnName) ? $orderColumnName . ' ' . $orderDirection . ' ' : '';
|
||||
|
||||
// SQL zusammenbauen
|
||||
$sql = $this->sqlTemplate;
|
||||
$sql = str_replace(
|
||||
['{{limit}}', '{{offset}}', '{{where}}', '{{orderby}}'],
|
||||
[(int)$limit, (int)$offset, $whereString, $orderBy],
|
||||
$sql
|
||||
);
|
||||
|
||||
// Ergebnisse abrufen
|
||||
$result = $this->app->DB->SelectArr($sql);
|
||||
$countFiltered = $this->app->DB->Select('SELECT FOUND_ROWS()');
|
||||
$countTotal = $this->app->DB->Select($this->sqlCount);
|
||||
|
||||
return [
|
||||
'draw' => (int)$draw,
|
||||
'recordsTotal' => (int)$countTotal,
|
||||
'recordsFiltered' => (int)$countFiltered,
|
||||
'data' => (array)$result,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filtername
|
||||
* @param bool $active
|
||||
*
|
||||
* @return string|null Filter-SQL
|
||||
*/
|
||||
protected function GenerateFilterSql($filtername, $active = false)
|
||||
{
|
||||
foreach ($this->GetFilter() as $item) {
|
||||
if ($item['name'] === $filtername) {
|
||||
return (bool)$active ? $item['sql']['active'] : $item['sql']['inactive'];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter für DataTable-Einstellungen
|
||||
*
|
||||
* @param string $ajaxUrl
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetSettings($ajaxUrl)
|
||||
{
|
||||
return [
|
||||
'ajax' => $ajaxUrl,
|
||||
'columns' => $this->GetColumns(),
|
||||
'order' => $this->order,
|
||||
'processing' => true,
|
||||
'serverSide' => true,
|
||||
'responsive' => true,
|
||||
'autoWidth' => true,
|
||||
'paging' => true,
|
||||
'language' => [
|
||||
'decimal' => ',',
|
||||
'thousands' => '.',
|
||||
'paginate' => [
|
||||
'first' => 'Erste',
|
||||
'last' => 'Letzte',
|
||||
'next' => '>>',
|
||||
'previous' => '<<',
|
||||
],
|
||||
'emptyTable' => 'Keine Daten vorhanden',
|
||||
'info' => 'Zeige _START_ bis _END_ von _TOTAL_ Einträgen',
|
||||
'infoEmpty' => 'Zeige 0 bis 0 von 0 Einträge',
|
||||
'infoFiltered' => '(gefiltert von _MAX_ Einträgen)',
|
||||
'infoPostFix' => '',
|
||||
'lengthMenu' => '_MENU_ Einträge pro Seite',
|
||||
'loadingRecords' => 'Loading...',
|
||||
'processing' => '',
|
||||
'search' => 'Suche:',
|
||||
'searchPlaceholder' => '',
|
||||
'zeroRecords' => 'Keine Einträge gefunden',
|
||||
'aria' => [
|
||||
'sortAscending' => ': activate to sort column ascending',
|
||||
'sortDescending' => ': activate to sort column descending',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Konfiguration für DataTable-Spalten
|
||||
*
|
||||
* "Zuweisen"-Button als zusätzliche Spalte einfügen
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function GetColumns()
|
||||
{
|
||||
// Prüfen ob Spalte mit ID existiert; wird für Zuweisung benötigt
|
||||
$hasIdColumn = false;
|
||||
foreach ($this->columns as $column) {
|
||||
if ($column['data'] === 'id') {
|
||||
$hasIdColumn = true;
|
||||
}
|
||||
}
|
||||
if ($hasIdColumn === false) {
|
||||
throw new RuntimeException('ID-Spalte fehlt. Eine Spalte muss mit "data => id" ausgewiesen sein.');
|
||||
}
|
||||
|
||||
// "Zuweisen"-Button als zusätzliche Spalte einfügen
|
||||
$columns = (array)$this->columns;
|
||||
$columns[] = [
|
||||
'title' => 'Menü',
|
||||
'class' => 'dt-right',
|
||||
'width' => '1%',
|
||||
'data' => null,
|
||||
'sortable' => false,
|
||||
'searchable' => false,
|
||||
'defaultContent' => '',
|
||||
];
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function GetFilter()
|
||||
{
|
||||
if (!is_array($this->filter)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string HTML
|
||||
*/
|
||||
public function GetContentHtml()
|
||||
{
|
||||
$html = <<<'HTML'
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-md-12 col-md-height">
|
||||
<div class="inside-full-height">
|
||||
<div>
|
||||
<div class="info">Hinweis: Die Druckeraufträge werden automatisch nach 10 Tagen gelöscht.</div>
|
||||
HTML;
|
||||
$html .= $this->GetFilterHtml();
|
||||
$html .= '<form action="./index.php?module=welcome&action=spooler&id=' . $this->printerId . '" method="post">';
|
||||
$html .= $this->GetTableHtml();
|
||||
$html .= <<<'HTML'
|
||||
<fieldset>
|
||||
<legend>Stapelverarbeitung</legend>
|
||||
<label><input type="checkbox" id="markall_trigger"> alle markieren </label>
|
||||
<input type="submit" class="btnBlue" value="ZIP erstellen" name="makezip">
|
||||
<input type="submit" class="btnBlue" value="Sammel-PDF öffnen" name="makepdf">
|
||||
<input type="hidden" name="markall_selection" id="markall_selection">
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
HTML;
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function GetFilterHtml()
|
||||
{
|
||||
$html = '';
|
||||
$filter = $this->GetFilter();
|
||||
|
||||
if (!empty($filter)){
|
||||
$html .= '<fieldset>';
|
||||
$html .= '<legend>Filter</legend>';
|
||||
$html .= '<div class="row">';
|
||||
$html .= '<div class="col-md-9">';
|
||||
|
||||
foreach ($filter as $item) {
|
||||
$html .= sprintf(
|
||||
'<label><input type="checkbox" class="spooler-filter-checkbox" data-filter-name="%s" data-filter-column="%s" %s> %s</label>',
|
||||
$item['name'],
|
||||
$item['column'],
|
||||
((bool)$item['active'] === true) ? 'checked="checked"' : '',
|
||||
$item['label']
|
||||
);
|
||||
}
|
||||
$html .= '</div>';
|
||||
$html .= '</fieldset>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function GetTableHtml()
|
||||
{
|
||||
$columns = $this->GetColumns();
|
||||
|
||||
// Tabellenkopf
|
||||
$html = '<table id="downloadspooler-table" class="display" border="0" cellpadding="0" cellspacing="0">';
|
||||
$html .= '<thead><tr>';
|
||||
foreach ($columns as $column) {
|
||||
$html .= '<th>' . $column['title'] . '</th>';
|
||||
}
|
||||
$html .= '</tr></thead>';
|
||||
|
||||
// Tabellenfuß
|
||||
$html .= '<tfoot><tr>';
|
||||
foreach ($columns as $column) {
|
||||
$html .= '<th>' . $column['title'] . '</th>';
|
||||
}
|
||||
$html .= '</tr></tfoot>';
|
||||
$html .= '</table>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function GetAdressenTable()
|
||||
{
|
||||
$filter = [[
|
||||
'active' => true,
|
||||
'label' => 'Nur ungedruckte Dateien',
|
||||
'name' => 'ungedruckt',
|
||||
'column' => 5,
|
||||
'sql' => [
|
||||
'active' => 's.gedruckt = 0',
|
||||
'inactive' => '(s.gedruckt = 1 OR s.gedruckt = 0)',
|
||||
],
|
||||
]];
|
||||
|
||||
$columns = [
|
||||
[
|
||||
'title' => '',
|
||||
'data' => 'id',
|
||||
'visible' => true,
|
||||
'searchable' => false,
|
||||
'orderable' => false,
|
||||
'search' => 's.id',
|
||||
],
|
||||
[
|
||||
'title' => 'Zeit',
|
||||
'data' => 'zeit',
|
||||
'search' => 's.zeitstempel',
|
||||
'class' => 'dt-center',
|
||||
],
|
||||
[
|
||||
'title' => 'Dateiname',
|
||||
'data' => 'dateiname',
|
||||
'search' => 's.filename',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Drucker',
|
||||
'data' => 'drucker',
|
||||
'search' => 'd.name',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Bearbeiter',
|
||||
'data' => 'bearbeiter',
|
||||
'search' => 'a.name',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Gedruckt',
|
||||
'data' => 'gedruckt',
|
||||
'search' => 's.gedruckt',
|
||||
'class' => 'dt-center',
|
||||
],
|
||||
];
|
||||
|
||||
$sqlTemplate =
|
||||
"SELECT
|
||||
SQL_CALC_FOUND_ROWS s.id,
|
||||
DATE_FORMAT(s.zeitstempel,'%d.%m.%Y %H:%i:%s') AS zeit,
|
||||
d.name AS drucker,
|
||||
IF(s.filename != '', s.filename, 'Kein Dateiname vorhanden') AS dateiname,
|
||||
a.name AS bearbeiter,
|
||||
IF(s.gedruckt = 1, 'ja', 'nein') AS gedruckt
|
||||
FROM drucker_spooler AS s
|
||||
LEFT JOIN drucker AS d ON s.drucker = d.id
|
||||
LEFT JOIN `user` AS u ON u.id = s.user
|
||||
LEFT JOIN adresse AS a ON a.id = u.adresse
|
||||
WHERE d.id = {$this->printerId}
|
||||
AND {{where}}
|
||||
ORDER BY {{orderby}}
|
||||
LIMIT {{offset}}, {{limit}}";
|
||||
|
||||
$sqlCount = 'SELECT COUNT(s.id) AS num FROM drucker_spooler AS s WHERE 1';
|
||||
|
||||
return [
|
||||
'sql_template' => $sqlTemplate,
|
||||
'sql_count' => $sqlCount,
|
||||
'columns' => $columns,
|
||||
'filter' => $filter,
|
||||
'order' => [[1, 'desc']],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
|
||||
class EasyCalendar {
|
||||
|
||||
var $app;
|
||||
var $year;
|
||||
var $rows;
|
||||
var $dataset;
|
||||
var $headings;
|
||||
var $cells;
|
||||
var $js;
|
||||
var $title;
|
||||
var $monatheading;
|
||||
var $maxcellcount;
|
||||
var $customcellcolor;
|
||||
var $additionalMonthInfo = [];
|
||||
var $holidays = [];
|
||||
function __construct(&$app, $jahr = null)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->year = date('Y');
|
||||
if($jahr)$this->year = $jahr;
|
||||
$this->sql ="";
|
||||
$this->maxcellcount = 1;
|
||||
$this->customcellcolor = '#0B8092';
|
||||
$this->limit ="";
|
||||
$this->headings[] = '{|Monat|}';
|
||||
for($i = 1; $i <= 31; $i++)$this->headings[] = $i;
|
||||
$this->monatheading = array(1=>'{|Januar|}',2=>'{|Februar|}',3=>'{|März|}',4=>'{|April|}',5=>'{|Mai|}',6=>'{|Juni|}',7=>'{|Juli|}',8=>'{|August|}',9=>'{|September|}',10=>'{|Oktober|}',11=>'{|November|}',12=>'{|Dezember|}');
|
||||
}
|
||||
|
||||
function AddHolidays($holidays){
|
||||
$this->holidays = $holidays;
|
||||
}
|
||||
|
||||
|
||||
function AddCell($datum, $el)
|
||||
{
|
||||
$datumu = strtotime($datum);
|
||||
|
||||
$jahr = (int)date('Y',$datumu);
|
||||
$tag = (int)date('d',$datumu);
|
||||
$monat = (int)date('m',$datumu);
|
||||
$this->cells[$jahr][$monat][$tag][] = $el;
|
||||
}
|
||||
|
||||
function AddOnCellClick($datum, $js)
|
||||
{
|
||||
$datumu = strtotime($datum);
|
||||
|
||||
$jahr = (int)date('Y',$datumu);
|
||||
$tag = (int)date('d',$datumu);
|
||||
$monat = (int)date('m',$datumu);
|
||||
$this->js[$jahr][$monat][$tag] = $js;
|
||||
}
|
||||
|
||||
function AddCellTitle($datum, $title)
|
||||
{
|
||||
$datumu = strtotime($datum);
|
||||
|
||||
$jahr = (int)date('Y',$datumu);
|
||||
$tag = (int)date('d',$datumu);
|
||||
$monat = (int)date('m',$datumu);
|
||||
$this->title[$jahr][$monat][$tag] = $title;
|
||||
}
|
||||
|
||||
function Display($parsetarget,$clickmodule="",$clickaction="",$clicklabel="",$newevent="")
|
||||
{
|
||||
|
||||
$htmltable = new HTMLTable(0,"100%","",3,1);
|
||||
$htmltable->width_headings = $this->width_headings;
|
||||
$htmltable->AddRowAsHeading($this->headings);
|
||||
|
||||
$htmltable->ChangingRowColors('#eee','#eee');
|
||||
|
||||
for($monat = 1; $monat <= 12 ; $monat++)
|
||||
{
|
||||
$htmltable->NewRow();
|
||||
if(isset($row))unset($row);
|
||||
$field = $this->monatheading[$monat];
|
||||
|
||||
if(!empty($this->additionalMonthInfo)){
|
||||
if(isset($this->additionalMonthInfo[$monat])){
|
||||
|
||||
$field = '<table class="vacationDayTable"><tr><td><b>'.$field.'</b></td></tr>';
|
||||
foreach($this->additionalMonthInfo[$monat] as $member){
|
||||
$field.='<tr><td>'.$member.'</td></tr>';
|
||||
}
|
||||
$field .='</table>';
|
||||
}
|
||||
else{
|
||||
$field = '<table class="vacationDayTable"><tr><td><b>'.$field.'</b></td></tr></table>';
|
||||
}
|
||||
}
|
||||
|
||||
$htmltable->AddCellClass('monat');
|
||||
$htmltable->AddCol($field);
|
||||
for($tag = 1; $tag <= 31; $tag++)
|
||||
{
|
||||
$css = 'standard';
|
||||
if(checkdate($monat , $tag , $this->year ))
|
||||
{
|
||||
$kalenderTag = date('w', mktime(0,0,0,$monat,$tag,$this->year));
|
||||
if ($kalenderTag == 0 || $kalenderTag == 6) {
|
||||
$css = 'wochenende';
|
||||
}
|
||||
} else {
|
||||
$css = 'keintag';
|
||||
}
|
||||
|
||||
if(!empty($this->holidays)){
|
||||
$curDate = $this->year.'-'.($monat<10?'0'.$monat:$monat).'-'.($tag<10?'0'.$tag:$tag);
|
||||
if(array_key_exists($curDate,$this->holidays)){
|
||||
$css = 'feiertag';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(is_array($this->cells) && isset($this->cells[$this->year]) && isset($this->cells[$this->year][$monat]) && isset($this->cells[$this->year][$monat][$tag]) && is_array($this->cells[$this->year][$monat][$tag]))
|
||||
{
|
||||
$anz = count($this->cells[$this->year][$monat][$tag]);
|
||||
|
||||
if($this->maxcellcount > 0)
|
||||
{
|
||||
if($anz < 1)
|
||||
{
|
||||
$field = '';
|
||||
}elseif($anz == 1){
|
||||
$field = $this->cells[$this->year][$monat][$tag][0];
|
||||
}elseif($anz <= $this->maxcellcount) {
|
||||
$zelle = '<table>';
|
||||
foreach($this->cells[$this->year][$monat][$tag] as $value)
|
||||
{
|
||||
$zelle .= '<tr><td>'.$value.'</td></tr>';
|
||||
}
|
||||
$zelle .= '</table>';
|
||||
$field = $zelle;
|
||||
} else {
|
||||
$zelle = '<table>';
|
||||
for($i = 0; $i < $this->maxcellcount; $i++)
|
||||
{
|
||||
$zelle .= '<tr><td>'.$this->cells[$this->year][$monat][$tag][$i].'</td></tr>';
|
||||
}
|
||||
$zelle .= '</table>';
|
||||
$field = $zelle;
|
||||
}
|
||||
} else {
|
||||
if($anz)
|
||||
{
|
||||
$field = '<span style="width:100%;display:inline-block;" title="';
|
||||
for($i = 0; $i < $anz; $i++)
|
||||
{
|
||||
if($i > 0)$field .= ', ';
|
||||
$field .= $this->cells[$this->year][$monat][$tag][$i];
|
||||
}
|
||||
|
||||
$field .= '">'.$anz.'</span>';
|
||||
$css = 'custom';
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
$field = '';
|
||||
}
|
||||
|
||||
if($css)$htmltable->AddCellClass($css);
|
||||
if($css == 'standard'){
|
||||
$htmltable->AddCustomAttributes(['data-day'=>$tag,'data-month'=>$monat,'data-year'=>$this->year]);
|
||||
}
|
||||
if(isset($this->js[$this->year][$monat][$tag]) && $this->js[$this->year][$monat][$tag])$htmltable->AddCellonclick($this->js[$this->year][$monat][$tag]);
|
||||
if(isset($this->title[$this->year][$monat][$tag]) && $this->title[$this->year][$monat][$tag])$htmltable->AddCellTitle($this->title[$this->year][$monat][$tag]);
|
||||
$htmltable->AddCol($field);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->app->Tpl->Add($parsetarget,'<div class="easycalendar">');
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->Get());
|
||||
$this->app->Tpl->Add($parsetarget,'</div>');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,556 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
|
||||
class EasyTable {
|
||||
/** @var ApplicationCore $app */
|
||||
var $app;
|
||||
/** @var array */
|
||||
var $rows;
|
||||
/** @var array */
|
||||
var $datasets;
|
||||
/** @var array */
|
||||
var $align;
|
||||
/** @var array */
|
||||
var $headings;
|
||||
/** @var array */
|
||||
public $width_headings;
|
||||
/** @var int|string */
|
||||
public $page;
|
||||
|
||||
/**
|
||||
* EasyTable constructor.
|
||||
*
|
||||
* @param ApplicationCore $app
|
||||
*/
|
||||
function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->sql ='';
|
||||
$this->limit ='';
|
||||
}
|
||||
|
||||
|
||||
function AddRow($rows)
|
||||
{
|
||||
$this->datasets[] = $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $sql
|
||||
* @param string|int $limit
|
||||
* @param string $newevent
|
||||
*/
|
||||
function Query($sql,$limit='',$newevent='')
|
||||
{
|
||||
if(!is_array($sql)) {
|
||||
$this->sql = $sql;
|
||||
$this->limit = $limit;
|
||||
$this->headings = null;
|
||||
|
||||
if($limit != 0){
|
||||
$page = $this->app->Secure->GetGET('page');
|
||||
if(!is_numeric($page)){
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$this->page = $page;
|
||||
$this->start = ($page - 1) * $this->limit;
|
||||
|
||||
$sql .= " LIMIT {$this->start},{$this->limit}";
|
||||
}
|
||||
$this->searchrow = '';
|
||||
$jsarray = null;
|
||||
if(!empty($this->app->stringcleaner)){
|
||||
$jsarray = $this->app->stringcleaner->CheckSQLHtml($sql);
|
||||
}
|
||||
$this->app->DB->DisableHTMLClearing(true);
|
||||
$this->app->DB->DisableJSClearing(true);
|
||||
$this->datasets = $this->app->DB->SelectArr($sql);
|
||||
$this->app->DB->DisableHTMLClearing(false);
|
||||
$this->app->DB->DisableJSClearing(false);
|
||||
}
|
||||
else {
|
||||
$this->datasets = $sql;
|
||||
}
|
||||
|
||||
if($jsarray && $this->datasets)
|
||||
{
|
||||
foreach($this->datasets as $k => $arr)
|
||||
{
|
||||
$j = 0;
|
||||
foreach($arr as $k2 => $v)
|
||||
{
|
||||
if(isset($jsarray[$j]) && !$jsarray[$j])
|
||||
{
|
||||
$this->datasets[$k][$k2] = strip_tags($v);
|
||||
}elseif(isset($jsarray[$j]) && 1 == $jsarray[$j])
|
||||
{
|
||||
$this->datasets[$k][$k2] = $this->app->stringcleaner->xss_clean($v, false);//CleanString($v, 'nojs', $dummy);
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!empty($this->datasets) && count($this->datasets)>0){
|
||||
foreach($this->datasets[0] as $colkey=>$value)
|
||||
{
|
||||
$this->headings[]=ucfirst($colkey);
|
||||
//$this->searchrow[0][$colkey]="<form action=\"\" method=\"post\"><input type=\"text\" style=\"width:100%; background-color:#fff;\"></form>";
|
||||
}
|
||||
}
|
||||
//$this->searchrow[0][id]="";
|
||||
|
||||
//if(count($this->datasets)>=$limit)
|
||||
// $this->datasets = $this->array_insert($this->datasets,0,$this->searchrow);
|
||||
|
||||
$this->searchrow='';
|
||||
if($newevent!=='noAction')
|
||||
{
|
||||
$this->headings[!empty($this->headings)?(count($this->headings)-1):0] = 'Aktion';
|
||||
$this->width_headings[count($this->headings)-1] = '120px'; //TMP fuer Belegtabelle
|
||||
}
|
||||
|
||||
}
|
||||
// Fügt $value in $array ein, an der Stelle $index
|
||||
function array_insert($array, $index, $value)
|
||||
{
|
||||
return array_merge(array_slice($array, 0, $index), $value, array_slice($array, $index));
|
||||
}
|
||||
|
||||
|
||||
function DisplayWithSort($parsetarget)
|
||||
{
|
||||
|
||||
$htmltable = new HTMLTable(0,"100%","",3,1);
|
||||
$htmltable->width_headings = $this->width_headings;
|
||||
$htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table'));
|
||||
|
||||
$htmltable->ChangingRowColors('#e0e0e0','#fff');
|
||||
|
||||
if(count($this->datasets)>0){
|
||||
foreach($this->datasets as $row){
|
||||
$htmltable->NewRow();
|
||||
foreach($row as $field)
|
||||
$htmltable->AddCol($field);
|
||||
}
|
||||
}
|
||||
$module = $this->app->Secure->GetGET("module");
|
||||
$htmltable->ReplaceCol(count($this->headings),
|
||||
"<a href=\"index.php?module=$module&action=edit&id=%value%\"><img border=\"0\" src=\"./themes/[THEME]/images/edit.svg\"></a>
|
||||
<a href=\"index.php?module=$module&action=delete&id=%value%\"><img border=\"0\" src=\"./themes/[THEME]/images/new.png\"></a>
|
||||
<a href=\"index.php?module=$module&action=delete&id=%value%\"><img border=\"0\" src=\"./themes/[THEME]/images/delete.png\"></a>
|
||||
<a href=\"index.php?module=$module&action=delete&id=%value%\"><img border=\"0\" src=\"./themes/[THEME]/images/up.png\"></a>
|
||||
<a href=\"index.php?module=$module&action=delete&id=%value%\"><img border=\"0\" src=\"./themes/[THEME]/images/down.png\"></a>
|
||||
");
|
||||
|
||||
$this->app->Tpl->Set($parsetarget,$htmltable->Get());
|
||||
}
|
||||
|
||||
function DisplayWithDelivery($parsetarget)
|
||||
{
|
||||
|
||||
$htmltable = new HTMLTable(0,"100%","",3,1);
|
||||
$htmltable->width_headings = $this->width_headings;
|
||||
$htmltable->AddRowAsHeading(array($this->app->Tpl->pruefeuebersetzung('Suchen','table'),'','',''));
|
||||
|
||||
$htmltable->ChangingRowColors('#e0e0e0','#fff');
|
||||
|
||||
if(count($this->datasets)>0){
|
||||
foreach($this->datasets as $row){
|
||||
$htmltable->NewRow();
|
||||
$link="";
|
||||
$cols=0;
|
||||
foreach($row as $key=>$field){
|
||||
if($cols<3){
|
||||
$htmltable->AddCol($field);
|
||||
$cols++;
|
||||
}
|
||||
if($key!="id")
|
||||
$link = $link."window.opener.document.getElementsByName('$key')[0].value='$field';";
|
||||
}
|
||||
$htmltable->AddCol("<input type=\"button\" onclick=\"
|
||||
$link
|
||||
window.close();
|
||||
\" value=\"OK\">
|
||||
");
|
||||
|
||||
}
|
||||
}
|
||||
$module = $this->app->Secure->GetGET("module");
|
||||
/*
|
||||
$htmltable->ReplaceCol(4,
|
||||
"<input type=\"button\" onclick=\"
|
||||
$link
|
||||
window.close();
|
||||
\" value=\"OK\">
|
||||
");
|
||||
*/
|
||||
$this->app->Tpl->Set($parsetarget,$htmltable->Get());
|
||||
}
|
||||
|
||||
|
||||
function DisplayOwn($parsetarget,$click,$limit=30,$idlabel="id",$tmpid="")
|
||||
{
|
||||
$newevent = null;
|
||||
$pages = round(count($this->app->DB->SelectArr($this->sql)) / $this->limit);
|
||||
if($pages==0)$pages=1;
|
||||
|
||||
$module = $this->app->Secure->GetGET("module");
|
||||
$action = $this->app->Secure->GetGET("action");
|
||||
|
||||
if($tmpid>0)
|
||||
$id = $tmpid;
|
||||
else
|
||||
$id = $this->app->Secure->GetGET($idlabel);
|
||||
|
||||
|
||||
if($this->page ==0 || $this->page=="") $this->page = 1;
|
||||
if($this->page <=1) $before = $this->page; else $before=$this->page-1;
|
||||
if($this->page >=$pages) $next = $this->page; else $next=$this->page+1;
|
||||
|
||||
$colmenu = "<table width=\"100%\"><tr><td><a href=\"index.php?module=$module&action={$action}&$idlabel=$id&page=1\"><img border=\"0\" src=\"./themes/[THEME]/images/first.png\"></a>
|
||||
<a href=\"index.php?module=$module&action={$action}&$idlabel=$id&page=".$before."\"><img border=\"0\" src=\"./themes/[THEME]/images/before.png\"></a></td>";
|
||||
|
||||
//for($i=0;($i<$pages && $i< 10);$i++)
|
||||
//{
|
||||
/*
|
||||
if($this->page==($i+1))
|
||||
{
|
||||
$colmenu .= "<td><a href=\"index.php?module=$module&action={$action}&$idlabel=$id&page=".($i+1)."\"><b>".
|
||||
($i+1)."</b></a></td>";
|
||||
} else {
|
||||
$colmenu .= "<td><a href=\"index.php?module=$module&action={$action}&$idlabel=$id&page=".($i+1)."\">".
|
||||
($i+1)."</a></td>";
|
||||
}
|
||||
*/
|
||||
//}
|
||||
$colmenu .= "<td align=center>Seite {$this->page} von $pages</td>";
|
||||
|
||||
$colmenu .= "<td align=right><a href=\"index.php?module=$module&action={$action}&$idlabel=$id&page=".($next)."\"><img border=\"0\" src=\"./themes/[THEME]/images/next.png\"></a>
|
||||
<a href=\"index.php?module=$module&action={$action}&$idlabel=$id&page=$pages\"><img border=\"0\" src=\"./themes/[THEME]/images/last.png\"></a></td></tr></table>";
|
||||
|
||||
$this->app->Tpl->Set($parsetarget,$colmenu);
|
||||
|
||||
$htmltable = new HTMLTable(0,"100%","",3,1);
|
||||
$htmltable->width_headings = $this->width_headings;
|
||||
$htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table'));
|
||||
|
||||
$htmltable->ChangingRowColors('#e0e0e0','#fff');
|
||||
|
||||
|
||||
if(count($this->datasets)>0){
|
||||
foreach($this->datasets as $row){
|
||||
$htmltable->NewRow();
|
||||
foreach($row as $field)
|
||||
$htmltable->AddCol($field);
|
||||
}
|
||||
$module = $this->app->Secure->GetGET("module");
|
||||
if($newevent!="noAction"){
|
||||
$htmltable->ReplaceCol(count($this->headings),$click);
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->Get());
|
||||
}
|
||||
else {
|
||||
if($newevent=="noAction") $newevent="";
|
||||
$this->app->Tpl->Set($parsetarget,"<div class=\"info\">Keine Daten vorhanden! $newevent</div>");
|
||||
}
|
||||
/*
|
||||
if(count($this->datasets)>0){
|
||||
foreach($this->datasets as $row){
|
||||
$htmltable->NewRow();
|
||||
foreach($row as $field)
|
||||
$htmltable->AddCol($field);
|
||||
}
|
||||
|
||||
for($i=0;$i<count($menu);$i++)
|
||||
{
|
||||
$menustring .= "<a href=\"index.php?module=$module&action={$menu[$i]}&$idlabel=%value%&id=$id\">{$menu[$i]}</a> ";
|
||||
}
|
||||
|
||||
$htmltable->ReplaceCol(count($this->headings),$menustring);
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->Get());
|
||||
}
|
||||
else {
|
||||
$this->app->Tpl->Add($parsetarget,"Keine Daten vorhanden!");
|
||||
}
|
||||
*/
|
||||
$this->app->Tpl->Add($parsetarget,$colmenu);
|
||||
}
|
||||
|
||||
|
||||
function DisplayWidthInlineEdit($parsetarget,$click="",$newevent="",$nomenu="false")
|
||||
{
|
||||
$htmltable = new HTMLTable(0,"100%","",3,1);
|
||||
$htmltable->width_headings = $this->width_headings;
|
||||
$htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table'));
|
||||
|
||||
$htmltable->ChangingRowColors('#e0e0e0','#fff');
|
||||
|
||||
if(count($this->datasets)>0){
|
||||
foreach($this->datasets as $row){
|
||||
$htmltable->NewRow();
|
||||
foreach($row as $field)
|
||||
$htmltable->AddCol($field);
|
||||
|
||||
$htmltable->NewRow();
|
||||
|
||||
$start = "<form>";
|
||||
foreach($row as $key=>$field){
|
||||
if($key!="id")
|
||||
$htmltable->AddCol($start."<input type=\"text\" size=\"10\" value=\"$field\">");
|
||||
else
|
||||
$htmltable->AddCol($field."</form>");
|
||||
|
||||
$start="";
|
||||
}
|
||||
}
|
||||
$module = $this->app->Secure->GetGET("module");
|
||||
if($newevent!="noAction"){
|
||||
$htmltable->ReplaceCol(count($this->headings),$click);
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->Get(1));
|
||||
}
|
||||
else {
|
||||
$this->app->Tpl->Add($parsetarget,"Keine Daten vorhanden! $newevent");
|
||||
}
|
||||
}
|
||||
|
||||
function DisplayEditable($parsetarget,$click="",$newevent="",$nomenu="false",$arrayEditable="",$editlastrow=false,$nowarp=true)
|
||||
{
|
||||
$module = $this->app->Secure->GetGET("module");
|
||||
$this->app->erp->RunHook('EasyTableDisplayEditableClick', 3, $module, $click, $newevent);
|
||||
$htmltable = new HTMLTable(0,"100%","",3,1);
|
||||
|
||||
if(!$nowarp)$htmltable->nowrap="";
|
||||
// Letzte Spalte aendern
|
||||
if($newevent == "noAction")
|
||||
$this->headings[count($this->headings)-1] = $click;
|
||||
|
||||
$htmltable->width_headings = $this->width_headings;
|
||||
$htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table'));
|
||||
$htmltable->ChangingRowColors('#e0e0e0','#fff');
|
||||
|
||||
$result = '';
|
||||
|
||||
$htmltable->nowrap = array(count($this->headings)-1);
|
||||
|
||||
if(count($this->datasets)>0){
|
||||
foreach($this->datasets as $row){
|
||||
$htmltable->NewRow();
|
||||
foreach($row as $field)
|
||||
$htmltable->AddCol($field);
|
||||
}
|
||||
|
||||
if($newevent!="noAction"){
|
||||
$htmltable->ReplaceCol(count($this->headings),$click);
|
||||
}
|
||||
if($parsetarget=="return")
|
||||
$result .= $htmltable->GetSpecialCSSClasses($arrayEditable,$editlastrow);
|
||||
else
|
||||
{
|
||||
if(is_array($arrayEditable))
|
||||
{
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses($arrayEditable,$editlastrow,2));
|
||||
}
|
||||
else {
|
||||
if($module=="lieferschein" || $module=="anfrage" || $module=="preisanfrage")
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4,5),$editlastrow,1));
|
||||
else if($module==='retoure'){
|
||||
$this->app->Tpl->Add($parsetarget, $htmltable->GetSpecialCSSClasses(array(4, 5, 7, 8, 10), $editlastrow, 1));
|
||||
}
|
||||
else if($module=="produktion")
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4),$editlastrow,1));
|
||||
else if($module=="arbeitsnachweis")
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(2,3,4,5,6),$editlastrow,2));
|
||||
else if($module=="reisekosten")
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(1,3),$editlastrow,2));
|
||||
else if($module=="kalkulation")
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(2),$editlastrow,2));
|
||||
else if($module=="inventur")
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(1,4,5),$editlastrow,2));
|
||||
else if($module=="auftrag" || $module=="rechnung" || $module=="gutschrift"|| $module=="bestellung" || $module=="angebot" || $module=="proformarechnung")
|
||||
{
|
||||
if($module=='bestellung')
|
||||
{
|
||||
$editcols = array(4,5,6,7);
|
||||
}else{
|
||||
$einkaufspreiseerlaubt = false;
|
||||
if($einkaufspreiseerlaubt)
|
||||
{
|
||||
$editcols =array(4,5,6,7,8,9);
|
||||
//$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4,5,6,7,8,9),$editlastrow,2));
|
||||
}else{
|
||||
$editcols = array(4,5,6,7,8);
|
||||
//$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4,5,6,7,8),$editlastrow,2));
|
||||
}
|
||||
}
|
||||
$clastRow = 2;
|
||||
$this->app->erp->RunHook('EasyTableDisplayEditable', 4, $module, $editcols, $editlastrow,$clastRow);
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses($editcols,$editlastrow,$clastRow));
|
||||
}
|
||||
else
|
||||
{
|
||||
$editcols = array(4,5,6);
|
||||
$clastRow = 2;
|
||||
$this->app->erp->RunHook('EasyTableDisplayEditable', 4, $module, $editcols, $editlastrow, $clastRow);
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses($editcols,$editlastrow,$clastRow));
|
||||
}
|
||||
//$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4,5,6),$editlastrow,2));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if($newevent=="noAction") $newevent="";
|
||||
|
||||
if($parsetarget=="return")
|
||||
$result .= "<div class=\"info\">Keine Daten vorhanden! $newevent</div>";
|
||||
else
|
||||
$this->app->Tpl->Set($parsetarget,"<div class=\"info\">Keine Daten vorhanden! $newevent</div>");
|
||||
}
|
||||
|
||||
if($parsetarget=="return") return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $parsetarget
|
||||
* @param string $click
|
||||
* @param string $newevent
|
||||
* @param string $nomenu
|
||||
* @param int $columns
|
||||
* @param int $rows
|
||||
* @param bool $nowrap
|
||||
*
|
||||
* @return string|void
|
||||
*/
|
||||
function DisplayNew($parsetarget,$click='',$newevent='',$nomenu='false',$columns=0,$rows=0,$nowrap=true)
|
||||
{
|
||||
$result = '';
|
||||
$secondline = isset($this->secondline)?$this->secondline:false;
|
||||
$htmltable = new HTMLTable(0,"99.9%","",3,1,"font-size: 90%; ");
|
||||
|
||||
if(!$nowrap) $htmltable->nowrap="";
|
||||
if($secondline) {
|
||||
unset($this->headings[count($this->headings)-1]);
|
||||
}
|
||||
// Letzte Spalte aendern
|
||||
if($newevent === 'noAction'){
|
||||
$this->headings[count($this->headings) - 1] = $click;
|
||||
}
|
||||
|
||||
$htmltable->width_headings = isset($this->width_headings)?$this->width_headings:null;
|
||||
$htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table'));
|
||||
$htmltable->ChangingRowColors('#e0e0e0','#fff');
|
||||
|
||||
if(!empty($this->datasets) && count($this->datasets)>0){
|
||||
$rowcounter=0;
|
||||
foreach($this->datasets as $row){
|
||||
$htmltable->NewRow();
|
||||
$aligncounter=0;
|
||||
$c = 0;
|
||||
$crow = count($row);
|
||||
$_field = '';
|
||||
foreach($row as $field)
|
||||
{
|
||||
$c++;
|
||||
if($c < $crow || !$secondline) {
|
||||
if (isset($this->align[$aligncounter]))
|
||||
$htmltable->AddCol($field, $this->align[$aligncounter]);
|
||||
else
|
||||
$htmltable->AddCol($field);
|
||||
$aligncounter++;
|
||||
}elseif($secondline)$_field = $field;
|
||||
}
|
||||
if($secondline)
|
||||
{
|
||||
$htmltable->NewRow();
|
||||
$htmltable->AddCol('','','',$crow-1);
|
||||
$htmltable->NewRow();
|
||||
$field = $_field;
|
||||
if (isset($this->align[$aligncounter]))
|
||||
$htmltable->AddCol($field, $this->align[$aligncounter],'',$crow-1);
|
||||
else
|
||||
$htmltable->AddCol($field,'','',$crow-1);
|
||||
}
|
||||
$rowcounter++;
|
||||
}
|
||||
|
||||
if($rowcounter<=$rows){
|
||||
for($rowcounter;$rows > $rowcounter;$rowcounter++)
|
||||
{
|
||||
$htmltable->NewRow();
|
||||
for($i_c=0;$i_c<$columns;$i_c++)
|
||||
$htmltable->AddCol('');
|
||||
}
|
||||
}
|
||||
|
||||
$module = $this->app->Secure->GetGET("module");
|
||||
if($newevent!="noAction"){
|
||||
$htmltable->ReplaceCol(count($this->headings),$click);
|
||||
}
|
||||
if($parsetarget=="return")
|
||||
$result .= $htmltable->Get($secondline?3:false);
|
||||
else
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->Get($secondline?3:false));
|
||||
}
|
||||
else {
|
||||
if($newevent=="noAction") $newevent="";
|
||||
if($newevent=="Menü") $newevent="";
|
||||
|
||||
if($parsetarget=="return")
|
||||
$result .= "<div class=\"info\">Keine Daten vorhanden! $newevent</div>";
|
||||
else
|
||||
$this->app->Tpl->Set($parsetarget,"<div class=\"info\">Keine Daten vorhanden! $newevent</div>");
|
||||
}
|
||||
|
||||
if($parsetarget=="return") return $result;
|
||||
}
|
||||
|
||||
function Display($parsetarget,$clickmodule="",$clickaction="",$clicklabel="",$newevent="")
|
||||
{
|
||||
|
||||
$htmltable = new HTMLTable(0,"100%","",3,1);
|
||||
$htmltable->width_headings = $this->width_headings;
|
||||
$htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table'));
|
||||
|
||||
$htmltable->ChangingRowColors('#e0e0e0','#fff');
|
||||
|
||||
if(count($this->datasets)>0){
|
||||
foreach($this->datasets as $row){
|
||||
$htmltable->NewRow();
|
||||
foreach($row as $field)
|
||||
$htmltable->AddCol($field);
|
||||
}
|
||||
$module = $this->app->Secure->GetGET("module");
|
||||
if($clickaction=="") {
|
||||
$htmltable->ReplaceCol(count($this->headings),
|
||||
"<a href=\"index.php?module=$module&action=edit&id=%value%\" alt=\"edit\"><img border=\"0\" src=\"./themes/[THEME]/images/edit.svg\"></a>
|
||||
<!--<a href=\"index.php?module=$module&action=copy&id=%value%\">copy</a>-->
|
||||
<a href=\"index.php?module=$module&action=delete&id=%value%\" alt=\"del\"><img border=\"0\" src=\"./themes/[THEME]/images/delete.svg\"></a>");
|
||||
} else {
|
||||
$htmltable->ReplaceCol(count($this->headings),
|
||||
"<a href=\"index.php?module=$clickmodule&action=$clickaction&id=%value%\">$clicklabel</a>");
|
||||
|
||||
}
|
||||
$this->app->Tpl->Add($parsetarget,$htmltable->Get());
|
||||
}
|
||||
else {
|
||||
$this->app->Tpl->Add($parsetarget,"Keine Daten vorhanden! $newevent");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,968 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class FileTable
|
||||
*
|
||||
* @todo Berechtigungen prüfen
|
||||
*/
|
||||
class FileTable
|
||||
{
|
||||
/** @var array $validTypes */
|
||||
protected static $validTypes = ['adressen', 'bestellung', 'kasse', 'reisekosten', 'verbindlichkeit'];
|
||||
|
||||
/** @var erpooSystem $app */
|
||||
protected $app;
|
||||
|
||||
/** @var string $type */
|
||||
protected $type;
|
||||
|
||||
/** @var int $fileId */
|
||||
protected $fileId;
|
||||
|
||||
/** @var array $columns */
|
||||
protected $columns = [];
|
||||
|
||||
/** @var array $filter */
|
||||
protected $filter = [];
|
||||
|
||||
/** @var array $order Initiale Sortierung */
|
||||
protected $order = [[0, 'asc']];
|
||||
|
||||
/** @var string $sqlTemplate */
|
||||
protected $sqlTemplate = '';
|
||||
|
||||
/** @var string $sqlCount */
|
||||
protected $sqlCount = '';
|
||||
|
||||
/**
|
||||
* @param erpooSystem $app
|
||||
* @param string $documentType
|
||||
* @param int $fileId
|
||||
*/
|
||||
public function __construct($app, $documentType, $fileId)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->fileId = (int)$fileId;
|
||||
$this->type = strtolower($documentType);
|
||||
|
||||
$this->Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function Init()
|
||||
{
|
||||
switch ($this->type) {
|
||||
case 'adressen':
|
||||
$table = $this->GetAdressenTable();
|
||||
break;
|
||||
|
||||
case 'bestellung':
|
||||
$table = $this->GetBestellungenTable();
|
||||
break;
|
||||
|
||||
case 'kasse':
|
||||
$table = $this->GetKassenbuchTable();
|
||||
break;
|
||||
|
||||
case 'reisekosten':
|
||||
$table = $this->GetReisekostenTable();
|
||||
break;
|
||||
|
||||
case 'verbindlichkeit':
|
||||
$table = $this->GetVerbindlichkeitenTable();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException(sprintf(
|
||||
'Type "%s" is not valid. Valid types are: %s', $this->type, implode(', ', self::$validTypes)
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->sqlTemplate = $table['sql_template'];
|
||||
$this->sqlCount = $table['sql_count'];
|
||||
$this->columns = $table['columns'];
|
||||
$this->filter = $table['filter'];
|
||||
$this->order = $table['order'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $filterParams
|
||||
* @param string|null $searchQuery Suchbegriff
|
||||
* @param int $orderCol Spalten-Index
|
||||
* @param string $orderDir [asc|desc]
|
||||
* @param int $offset
|
||||
* @param int $limit
|
||||
* @param int $draw
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetData(
|
||||
$filterParams = [],
|
||||
$searchQuery = null,
|
||||
$orderCol = 0,
|
||||
$orderDir = 'asc',
|
||||
$offset = 0,
|
||||
$limit = 10,
|
||||
$draw = 1
|
||||
)
|
||||
{
|
||||
$where = '';
|
||||
|
||||
// Suche
|
||||
if ($searchQuery !== null){
|
||||
$searchParts = [];
|
||||
foreach ($this->columns as $column) {
|
||||
if (!isset($column['search'])) {
|
||||
continue;
|
||||
}
|
||||
$searchParts[] = sprintf(' %s LIKE \'%%%s%%\' ', $column['search'], $searchQuery);
|
||||
}
|
||||
$where .= ' AND (' . implode(' OR ', $searchParts) .') ';
|
||||
}
|
||||
|
||||
// Filter
|
||||
if (!empty($filterParams)) {
|
||||
foreach ($filterParams as $filterName => $filterActive) {
|
||||
$where .= $this->GenerateFilterSql($filterName, $filterActive);
|
||||
}
|
||||
}
|
||||
|
||||
// Sortierung
|
||||
$orderColumnName = array_column($this->columns, 'data')[$orderCol];
|
||||
$orderDirection = strtolower($orderDir) === 'desc' ? 'DESC' : 'ASC';
|
||||
$orderBy = !empty($orderColumnName) ? $orderColumnName . ' ' . $orderDirection . ' ' : '';
|
||||
|
||||
// SQL zusammenbauen
|
||||
$sql = $this->sqlTemplate;
|
||||
$sql = str_replace(
|
||||
['{{limit}}', '{{offset}}', '{{where}}', '{{orderby}}'],
|
||||
[(int)$limit, (int)$offset, $where, $orderBy],
|
||||
$sql
|
||||
);
|
||||
|
||||
// Ergebnisse abrufen
|
||||
$result = $this->app->DB->SelectArr($sql);
|
||||
$countFiltered = $this->app->DB->Select('SELECT FOUND_ROWS()');
|
||||
$countTotal = $this->app->DB->Select($this->sqlCount);
|
||||
|
||||
return [
|
||||
'draw' => (int)$draw,
|
||||
'recordsTotal' => (int)$countTotal,
|
||||
'recordsFiltered' => (int)$countFiltered,
|
||||
'data' => (array)$result,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filtername
|
||||
* @param bool $active
|
||||
*
|
||||
* @return string Filter-SQL
|
||||
*/
|
||||
protected function GenerateFilterSql($filtername, $active = false)
|
||||
{
|
||||
foreach ($this->GetFilter() as $item) {
|
||||
if ($item['name'] === $filtername) {
|
||||
return (bool)$active ? $item['sql']['active'] : $item['sql']['inactive'];
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter für DataTable-Einstellungen
|
||||
*
|
||||
* @param string $ajaxUrl
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetSettings($ajaxUrl)
|
||||
{
|
||||
return [
|
||||
'ajax' => $ajaxUrl,
|
||||
'columns' => $this->GetColumns(),
|
||||
'order' => $this->order,
|
||||
'processing' => true,
|
||||
'serverSide' => true,
|
||||
'responsive' => true,
|
||||
'autoWidth' => true,
|
||||
'paging' => true,
|
||||
'language' => [
|
||||
'decimal' => ',',
|
||||
'thousands' => '.',
|
||||
'paginate' => [
|
||||
'first' => 'Erste',
|
||||
'last' => 'Letzte',
|
||||
'next' => '>>',
|
||||
'previous' => '<<',
|
||||
],
|
||||
'emptyTable' => 'Keine Daten vorhanden',
|
||||
'info' => 'Zeige _START_ bis _END_ von _TOTAL_ Einträgen',
|
||||
'infoEmpty' => 'Zeige 0 bis 0 von 0 Einträge',
|
||||
'infoFiltered' => '(gefiltert von _MAX_ Einträgen)',
|
||||
'infoPostFix' => '',
|
||||
'lengthMenu' => '_MENU_ Einträge pro Seite',
|
||||
'loadingRecords' => 'Loading...',
|
||||
'processing' => '',
|
||||
'search' => 'Suche:',
|
||||
'searchPlaceholder' => '',
|
||||
'zeroRecords' => 'Keine Einträge gefunden',
|
||||
'aria' => [
|
||||
'sortAscending' => ': activate to sort column ascending',
|
||||
'sortDescending' => ': activate to sort column descending',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Konfiguration für DataTable-Spalten
|
||||
*
|
||||
* "Zuweisen"-Button als zusätzliche Spalte einfügen
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function GetColumns()
|
||||
{
|
||||
// Prüfen ob Spalte mit ID existiert; wird für Zuweisung benötigt
|
||||
$hasIdColumn = false;
|
||||
foreach ($this->columns as $column) {
|
||||
if ($column['data'] === 'id') {
|
||||
$hasIdColumn = true;
|
||||
}
|
||||
}
|
||||
if ($hasIdColumn === false) {
|
||||
throw new RuntimeException('ID-Spalte fehlt. Eine Spalte muss mit "data => id" ausgewiesen sein.');
|
||||
}
|
||||
|
||||
// "Zuweisen"-Button als zusätzliche Spalte einfügen
|
||||
$columns = (array)$this->columns;
|
||||
$columns[] = [
|
||||
'title' => 'Menü',
|
||||
'class' => 'dt-center',
|
||||
'data' => null,
|
||||
'sortable' => false,
|
||||
'searchable' => false,
|
||||
'defaultContent' => sprintf(
|
||||
'<a href="#" class="document-assign-action" title="Datei zuweisen">' .
|
||||
'<img src="themes/%s/images/forward.svg" align="center" alt="Datei zuweisen">' .
|
||||
'</a>',
|
||||
$this->app->Conf->WFconf['defaulttheme']),
|
||||
];
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function GetFilter()
|
||||
{
|
||||
if (!is_array($this->filter)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetTabsHtml()
|
||||
{
|
||||
return
|
||||
'<div id="filetabs">
|
||||
<ul>
|
||||
<li data-type="verbindlichkeit"><a href="#verbindlichkeit-tab">Verbindlichkeiten</a></li>
|
||||
<li data-type="kasse"><a href="#kasse-tab">Kassenbuch</a></li>
|
||||
<li data-type="reisekosten"><a href="#reisekosten-tab">Reisekosten</a></li>
|
||||
<li data-type="bestellung"><a href="#bestellung-tab">Bestellungen</a></li>
|
||||
<li data-type="adressen"><a href="#adressen-tab">Adressen</a></li>
|
||||
</ul>
|
||||
<div id="adressen-tab"></div>
|
||||
<div id="bestellung-tab"></div>
|
||||
<div id="kasse-tab"></div>
|
||||
<div id="reisekosten-tab"></div>
|
||||
<div id="verbindlichkeit-tab"></div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetTabContentHtml()
|
||||
{
|
||||
// Prüfen ob Modul vorhanden ist
|
||||
if (in_array($this->type, ['kasse', 'reisekosten', 'verbindlichkeit'], true)) {
|
||||
$moduleName = $this->type;
|
||||
if ($this->type === 'adressen') {
|
||||
$moduleName = 'adresse';
|
||||
}
|
||||
if(!$this->app->erp->ModulVorhanden($moduleName)){
|
||||
$html = '<div class="module-disabled">';
|
||||
$html .= sprintf(
|
||||
'<div class="info">Das Modul "%s" ist nicht vorhanden.</div>',
|
||||
ucfirst($moduleName)
|
||||
);
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
$html = '<div class="document-table-container">';
|
||||
$html .= $this->GetFilterHtml();
|
||||
$html .= $this->GetTableHtml();
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function GetFilterHtml()
|
||||
{
|
||||
$html = '';
|
||||
$filter = $this->GetFilter();
|
||||
|
||||
if (!empty($filter)){
|
||||
$html .= '<fieldset>';
|
||||
$html .= '<legend>Filter</legend>';
|
||||
$html .= '<div class="row">';
|
||||
$html .= '<div class="col-md-9">';
|
||||
|
||||
foreach ($filter as $item) {
|
||||
$html .= sprintf(
|
||||
'<label><input type="checkbox" class="document-filter-checkbox" data-filter-name="%s" data-filter-column="%s" %s> %s</label>',
|
||||
$item['name'],
|
||||
$item['column'],
|
||||
((bool)$item['active'] === true) ? 'checked="checked"' : '',
|
||||
$item['label']
|
||||
);
|
||||
}
|
||||
$html .= '</div>';
|
||||
|
||||
if ($this->type === 'verbindlichkeit') {
|
||||
$html .= '<div class="col-md-3">';
|
||||
$html .= '<input type="button" class="btnGreen create-liability-button" value="Verbindlichkeit anlegen">';
|
||||
$html .= '</div>';
|
||||
}
|
||||
|
||||
$html .= '</fieldset>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function GetTableHtml()
|
||||
{
|
||||
$columns = $this->GetColumns();
|
||||
|
||||
// Tabellenkopf
|
||||
$html = '<table class="display" border="0" cellpadding="0" cellspacing="0">';
|
||||
$html .= '<thead><tr>';
|
||||
foreach ($columns as $column) {
|
||||
$html .= '<th>' . $column['title'] . '</th>';
|
||||
}
|
||||
$html .= '</tr></thead>';
|
||||
|
||||
// Tabellenfuß
|
||||
$html .= '<tfoot><tr>';
|
||||
foreach ($columns as $column) {
|
||||
$html .= '<th>' . $column['title'] . '</th>';
|
||||
}
|
||||
$html .= '</tr></tfoot>';
|
||||
$html .= '</table>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function GetAdressenTable()
|
||||
{
|
||||
$filter = [[
|
||||
'active' => true,
|
||||
'label' => 'Nur Adressen ohne Dateien',
|
||||
'name' => 'dateianzahl',
|
||||
'column' => 8,
|
||||
'sql' => [
|
||||
'active' => ' AND dateien.anzahl IS NULL ',
|
||||
'inactive' => '',
|
||||
],
|
||||
]];
|
||||
|
||||
$columns = [
|
||||
[
|
||||
'title' => '',
|
||||
'data' => 'id',
|
||||
'visible' => false,
|
||||
'searchable' => false,
|
||||
],
|
||||
[
|
||||
'title' => 'Name',
|
||||
'data' => 'name',
|
||||
'search' => 'a.name',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Kunde',
|
||||
'data' => 'kundennummer',
|
||||
'search' => 'a.kundennummer',
|
||||
'class' => 'dt-center',
|
||||
],
|
||||
[
|
||||
'title' => 'Lieferant',
|
||||
'data' => 'lieferantennummer',
|
||||
'search' => 'a.lieferantennummer',
|
||||
'class' => 'dt-center',
|
||||
],
|
||||
[
|
||||
'title' => 'Land',
|
||||
'data' => 'land',
|
||||
'search' => 'a.land',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'PLZ',
|
||||
'data' => 'plz',
|
||||
'search' => 'a.plz',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Ort',
|
||||
'data' => 'ort',
|
||||
'search' => 'a.ort',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Projekt',
|
||||
'data' => 'projekt',
|
||||
'search' => 'p.name',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Dateien',
|
||||
'data' => 'dateianzahl',
|
||||
'class' => 'dt-center',
|
||||
'defaultContent' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
$sqlTemplate =
|
||||
"SELECT SQL_CALC_FOUND_ROWS a.id,
|
||||
CONCAT(a.name, IF(a.ansprechpartner != '', '<br><i style=color:#999>',''), a.ansprechpartner, IF(a.ansprechpartner != '', '</i>', '')) AS name,
|
||||
if(a.kundennummer!='',a.kundennummer,'-') AS kundennummer,
|
||||
if(a.lieferantennummer!='',a.lieferantennummer,'-') AS lieferantennummer,
|
||||
a.land AS land,
|
||||
a.plz AS plz,
|
||||
a.ort AS ort,
|
||||
p.abkuerzung AS projekt,
|
||||
dateien.anzahl AS dateianzahl
|
||||
FROM adresse AS a
|
||||
LEFT JOIN projekt AS p ON p.id = a.projekt
|
||||
LEFT JOIN (
|
||||
SELECT ds.parameter AS adresse_id, COUNT(ds.datei) AS anzahl
|
||||
FROM datei_stichwoerter AS ds
|
||||
WHERE ds.objekt LIKE 'Adressen'
|
||||
GROUP BY ds.parameter, ds.objekt
|
||||
) AS dateien ON dateien.adresse_id = a.id
|
||||
WHERE a.geloescht = 0 " . $this->app->erp->ProjektRechte('p.id', true, 'a.vertrieb') . '
|
||||
{{where}}
|
||||
ORDER BY {{orderby}}
|
||||
LIMIT {{offset}}, {{limit}}';
|
||||
|
||||
$sqlCount =
|
||||
'SELECT COUNT(a.id) AS num FROM adresse a
|
||||
LEFT JOIN projekt p ON p.id = a.projekt
|
||||
WHERE a.geloescht = 0 ' . $this->app->erp->ProjektRechte('p.id', true, 'a.vertrieb');
|
||||
|
||||
return [
|
||||
'sql_count' => $sqlCount,
|
||||
'sql_template' => $sqlTemplate,
|
||||
'columns' => $columns,
|
||||
'filter' => $filter,
|
||||
'order' => [[1, 'asc']],
|
||||
];
|
||||
}
|
||||
|
||||
protected function GetBestellungenTable()
|
||||
{
|
||||
$filter = [[
|
||||
'active' => true,
|
||||
'label' => 'Nur Bestellungen ohne Dateien',
|
||||
'name' => 'dateianzahl',
|
||||
'column' => 9,
|
||||
'sql' => [
|
||||
'active' => ' AND dateien.anzahl IS NULL ',
|
||||
'inactive' => '',
|
||||
],
|
||||
]];
|
||||
|
||||
$columns = [
|
||||
[
|
||||
'title' => '',
|
||||
'data' => 'id',
|
||||
'searchable' => false,
|
||||
'visible' => false,
|
||||
],
|
||||
[
|
||||
'title' => 'Bestellung',
|
||||
'data' => 'belegnr',
|
||||
'search' => 'b.belegnr',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Vom',
|
||||
'data' => 'vom',
|
||||
'search' => 'DATE_FORMAT(b.datum, "%d.%m.%Y")',
|
||||
'class' => 'dt-center',
|
||||
],
|
||||
[
|
||||
'title' => 'Lf-Nr.',
|
||||
'data' => 'lieferantennummer',
|
||||
'search' => 'adr.lieferantennummer',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Lieferant',
|
||||
'data' => 'lieferant',
|
||||
'search' => 'CONCAT(b.name, " ", b.internebezeichnung)',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Land',
|
||||
'data' => 'land',
|
||||
'search' => 'b.land',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Projekt',
|
||||
'data' => 'projekt',
|
||||
'search' => 'p.name',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Betrag (brutto)',
|
||||
'data' => 'summe',
|
||||
'search' => $this->app->erp->FormatPreis('b.gesamtsumme',2),
|
||||
'class' => 'dt-right',
|
||||
],
|
||||
[
|
||||
'title' => 'Status',
|
||||
'data' => 'status',
|
||||
'search' => 'b.status',
|
||||
'class' => 'dt-center',
|
||||
],
|
||||
[
|
||||
'title' => 'Dateien',
|
||||
'data' => 'dateianzahl',
|
||||
'class' => 'dt-center',
|
||||
'defaultContent' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
$extended_mysql55 = ", 'de_DE'";
|
||||
|
||||
$sqlTemplate =
|
||||
"SELECT SQL_CALC_FOUND_ROWS b.id,
|
||||
IF(b.status = 'storniert', CONCAT(b.belegnr), b.belegnr) AS belegnr,
|
||||
IF(b.status = 'storniert', CONCAT(DATE_FORMAT(b.datum,'%d.%m.%Y')), DATE_FORMAT(b.datum,'%d.%m.%Y')) AS vom,
|
||||
IF(b.status = 'storniert', CONCAT(adr.lieferantennummer), adr.lieferantennummer) AS lieferantennummer,
|
||||
IF(b.status = 'storniert', CONCAT(" . $this->app->erp->MarkerUseredit("b.name", "b.useredittimestamp") . ", IF(b.internebezeichnung != '', CONCAT('<br><i style=color:#999>', b.internebezeichnung, '</i>'), '')), CONCAT(" . $this->app->erp->MarkerUseredit("b.name", "b.useredittimestamp") . ", IF(b.internebezeichnung != '', CONCAT('<br><i style=color:#999>', b.internebezeichnung, '</i>'), ''))) AS lieferant,
|
||||
IF(b.status = 'storniert', CONCAT(b.land), b.land) AS land,
|
||||
IF(b.status = 'storniert', CONCAT(p.abkuerzung), p.abkuerzung) AS projekt,
|
||||
IF(b.status = 'storniert', CONCAT(FORMAT(b.gesamtsumme, 2{$extended_mysql55})), FORMAT(b.gesamtsumme, 2{$extended_mysql55})) AS summe,
|
||||
IF(b.status = 'storniert', CONCAT('<font color=red>', UPPER(b.status), '</font>'), UPPER(b.status)) AS status,
|
||||
dateien.anzahl AS dateianzahl
|
||||
FROM bestellung AS b
|
||||
LEFT JOIN projekt AS p ON p.id = b.projekt
|
||||
LEFT JOIN adresse AS adr ON b.adresse = adr.id
|
||||
LEFT JOIN (
|
||||
SELECT ds.parameter AS bestellung_id, COUNT(ds.datei) AS anzahl
|
||||
FROM datei_stichwoerter AS ds
|
||||
WHERE ds.objekt LIKE 'Bestellung'
|
||||
GROUP BY ds.parameter, ds.objekt
|
||||
) AS dateien ON dateien.bestellung_id = b.id
|
||||
WHERE b.id != '' AND b.status != 'angelegt' " . $this->app->erp->ProjektRechte() . '
|
||||
{{where}}
|
||||
ORDER BY {{orderby}}
|
||||
LIMIT {{offset}}, {{limit}}';
|
||||
|
||||
$sqlCount =
|
||||
'SELECT COUNT(b.id) AS num
|
||||
FROM bestellung AS b
|
||||
LEFT JOIN projekt AS p ON p.id = b.projekt
|
||||
WHERE b.status != \'angelegt\' ' . $this->app->erp->ProjektRechte();
|
||||
|
||||
return [
|
||||
'sql_count' => $sqlCount,
|
||||
'sql_template' => $sqlTemplate,
|
||||
'columns' => $columns,
|
||||
'filter' => $filter,
|
||||
'order' => [[1, 'desc']],
|
||||
];
|
||||
}
|
||||
|
||||
protected function GetKassenbuchTable()
|
||||
{
|
||||
$filter = [[
|
||||
'active' => true,
|
||||
'label' => 'Nur Kassenbuch-Einträge ohne Dateien',
|
||||
'name' => 'dateianzahl',
|
||||
'column' => 8,
|
||||
'sql' => [
|
||||
'active' => ' AND dateien.anzahl IS NULL ',
|
||||
'inactive' => '',
|
||||
],
|
||||
]];
|
||||
|
||||
$columns = [
|
||||
[
|
||||
'title' => '',
|
||||
'data' => 'id',
|
||||
'searchable' => false,
|
||||
'visible' => false,
|
||||
],
|
||||
[
|
||||
'title' => 'Nr.',
|
||||
'data' => 'nummer',
|
||||
'search' => 'k.nummer',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Kasse',
|
||||
'data' => 'bezeichnung',
|
||||
'search' => 'kon.bezeichnung',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Datum',
|
||||
'data' => 'datum',
|
||||
'search' => 'DATE_FORMAT(k.datum, "%d.%m.%Y")',
|
||||
'class' => 'dt-center',
|
||||
],
|
||||
[
|
||||
'title' => 'Firma',
|
||||
'data' => 'firmenname',
|
||||
'search' => 'a.name',
|
||||
'class' => 'dt-center',
|
||||
],
|
||||
[
|
||||
'title' => 'Name/Verwendungszweck',
|
||||
'data' => 'verwendungszweck',
|
||||
'search' => 'k.grund',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Konto',
|
||||
'data' => 'kontoname',
|
||||
'search' => 'CONCAT(k.sachkonto, " ", ko.beschriftung)',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Projekt',
|
||||
'data' => 'projekt',
|
||||
'search' => 'p.abkuerzung',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Dateien',
|
||||
'data' => 'dateianzahl',
|
||||
'class' => 'dt-center',
|
||||
'defaultContent' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
// SQL statement
|
||||
$sqlTemplate =
|
||||
"SELECT SQL_CALC_FOUND_ROWS k.id,
|
||||
k.nummer,
|
||||
kon.bezeichnung,
|
||||
IF(k.wert < 0, CONCAT('<font color=red>', DATE_FORMAT(k.datum,'%d.%m.%Y'), '</font>'), DATE_FORMAT(k.datum,'%d.%m.%Y')) AS datum,
|
||||
a.name AS firmenname,
|
||||
CONCAT(
|
||||
k.grund,
|
||||
IF(k.adresse > 0, CONCAT(' (',if(a.kundennummer != '', a.kundennummer, a.mitarbeiternummer), ' ', a.name, ')<br>'), '<br>'),
|
||||
IF(k.storniert_grund != '', CONCAT('<i style=color:#999>', k.storniert_grund, '</i>'), '')
|
||||
) AS verwendungszweck,
|
||||
CONCAT(k.sachkonto, ' ', LEFT(ko.beschriftung, 30)) AS kontoname,
|
||||
p.abkuerzung AS projekt,
|
||||
dateien.anzahl AS dateianzahl
|
||||
FROM kasse AS k
|
||||
INNER JOIN konten AS kon ON k.konto = kon.id
|
||||
LEFT JOIN adresse AS a ON a.id = k.adresse
|
||||
LEFT JOIN kontorahmen AS ko ON ko.sachkonto = k.sachkonto
|
||||
LEFT JOIN projekt AS p ON p.id = k.projekt
|
||||
LEFT JOIN (
|
||||
SELECT ds.parameter AS kasse_id, COUNT(ds.datei) AS anzahl
|
||||
FROM datei_stichwoerter AS ds
|
||||
WHERE ds.objekt LIKE 'Kasse'
|
||||
GROUP BY ds.parameter, ds.objekt
|
||||
) AS dateien ON dateien.kasse_id = k.id
|
||||
WHERE 1 " . $this->app->erp->ProjektRechte() . '
|
||||
{{where}}
|
||||
ORDER BY {{orderby}}
|
||||
LIMIT {{offset}}, {{limit}}';
|
||||
|
||||
$sqlCount =
|
||||
'SELECT COUNT(k.id) AS num
|
||||
FROM kasse AS k
|
||||
LEFT JOIN projekt AS p ON p.id = k.projekt
|
||||
WHERE 1 ' . $this->app->erp->ProjektRechte();
|
||||
|
||||
return [
|
||||
'sql_count' => $sqlCount,
|
||||
'sql_template' => $sqlTemplate,
|
||||
'columns' => $columns,
|
||||
'filter' => $filter,
|
||||
'order' => [[1, 'desc']],
|
||||
];
|
||||
}
|
||||
|
||||
protected function GetReisekostenTable()
|
||||
{
|
||||
$filter = [[
|
||||
'active' => true,
|
||||
'label' => 'Nur Reisekosten ohne Dateien',
|
||||
'name' => 'dateianzahl',
|
||||
'column' => 9,
|
||||
'sql' => [
|
||||
'active' => ' AND dateien.anzahl IS NULL ',
|
||||
'inactive' => '',
|
||||
],
|
||||
]];
|
||||
|
||||
$columns = [
|
||||
[
|
||||
'title' => '',
|
||||
'data' => 'id',
|
||||
'searchable' => false,
|
||||
'visible' => false,
|
||||
],
|
||||
[
|
||||
'title' => 'Mitarbeiter',
|
||||
'data' => 'mitarbeiter',
|
||||
'search' => 'ma.name',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Reisekosten',
|
||||
'data' => 'belegnr',
|
||||
'search' => 'l.belegnr',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Vom',
|
||||
'data' => 'vom',
|
||||
'search' => 'DATE_FORMAT(l.datum, "%d.%m.%Y")',
|
||||
'class' => 'dt-center',
|
||||
],
|
||||
[
|
||||
'title' => 'Kd-Nr.',
|
||||
'data' => 'kundennummer',
|
||||
'search' => 'adr.kundennummer',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Kunde',
|
||||
'data' => 'kundenname',
|
||||
'search' => 'l.name',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Anlass',
|
||||
'data' => 'anlass',
|
||||
'search' => 'l.anlass',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Projekt',
|
||||
'data' => 'projekt',
|
||||
'search' => 'p.name',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Status',
|
||||
'data' => 'status',
|
||||
'search' => 'l.status',
|
||||
'class' => 'dt-center',
|
||||
],
|
||||
[
|
||||
'title' => 'Dateien',
|
||||
'data' => 'dateianzahl',
|
||||
'class' => 'dt-center',
|
||||
'defaultContent' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
$sqlTemplate =
|
||||
"SELECT SQL_CALC_FOUND_ROWS l.id,
|
||||
ma.name AS mitarbeiter,
|
||||
l.belegnr,
|
||||
DATE_FORMAT(l.datum, '%d.%m.%Y') AS vom,
|
||||
adr.kundennummer AS kundennummer,
|
||||
l.name AS kundenname,
|
||||
l.anlass AS anlass,
|
||||
p.abkuerzung AS projekt,
|
||||
UPPER(l.status) AS status,
|
||||
dateien.anzahl AS dateianzahl
|
||||
FROM reisekosten AS l
|
||||
LEFT JOIN projekt AS p ON p.id = l.projekt
|
||||
LEFT JOIN adresse AS adr ON l.adresse = adr.id
|
||||
LEFT JOIN adresse AS ma ON ma.id = l.mitarbeiter
|
||||
LEFT JOIN (
|
||||
SELECT ds.parameter AS reisekosten_id, COUNT(ds.datei) AS anzahl
|
||||
FROM datei_stichwoerter AS ds
|
||||
WHERE ds.objekt LIKE 'Reisekosten'
|
||||
GROUP BY ds.parameter, ds.objekt
|
||||
) AS dateien ON dateien.reisekosten_id = l.id
|
||||
WHERE l.id != '' AND l.status != 'angelegt' " . $this->app->erp->ProjektRechte() . '
|
||||
{{where}}
|
||||
ORDER BY {{orderby}}
|
||||
LIMIT {{offset}}, {{limit}}';
|
||||
|
||||
$sqlCount =
|
||||
"SELECT COUNT(l.id) AS num
|
||||
FROM reisekosten AS l
|
||||
LEFT JOIN projekt AS p ON p.id = l.projekt
|
||||
WHERE l.id != '' AND l.status != 'angelegt' " . $this->app->erp->ProjektRechte();
|
||||
|
||||
return [
|
||||
'sql_count' => $sqlCount,
|
||||
'sql_template' => $sqlTemplate,
|
||||
'columns' => $columns,
|
||||
'filter' => $filter,
|
||||
'order' => [[2, 'desc']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function GetVerbindlichkeitenTable()
|
||||
{
|
||||
$filter = [[
|
||||
'active' => true,
|
||||
'label' => 'Nur Verbindlichkeiten ohne Dateien',
|
||||
'name' => 'dateianzahl',
|
||||
'column' => 7,
|
||||
'sql' => [
|
||||
'active' => ' AND dateien.anzahl IS NULL ',
|
||||
'inactive' => '',
|
||||
],
|
||||
]];
|
||||
|
||||
$columns = [
|
||||
[
|
||||
'title' => '',
|
||||
'data' => 'id',
|
||||
'searchable' => false,
|
||||
'visible' => false,
|
||||
],
|
||||
[
|
||||
'title' => 'Nr.',
|
||||
'data' => 'verbindlichkeitnr',
|
||||
'search' => 'v.belegnr',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'Lf-Nr.',
|
||||
'data' => 'lieferantennr',
|
||||
'search' => 'a.lieferantennummer',
|
||||
'class' => 'dt-center',
|
||||
],
|
||||
[
|
||||
'title' => 'Lieferant',
|
||||
'data' => 'lieferant',
|
||||
'search' => 'a.name',
|
||||
'class' => 'dt-left',
|
||||
],
|
||||
[
|
||||
'title' => 'RE-Datum',
|
||||
'data' => 'rechnungsdatum',
|
||||
'search' => 'DATE_FORMAT(v.rechnungsdatum, "%d.%m.%Y")',
|
||||
'class' => 'dt-center',
|
||||
],
|
||||
[
|
||||
'title' => 'RE-Nr.',
|
||||
'data' => 'rechnungsnr',
|
||||
'search' => 'v.rechnung',
|
||||
'class' => 'dt-center',
|
||||
],
|
||||
[
|
||||
'title' => 'Betrag',
|
||||
'data' => 'betrag',
|
||||
'search' => $this->app->erp->FormatPreis('v.betrag',2),
|
||||
'class' => 'dt-right',
|
||||
],
|
||||
[
|
||||
'title' => 'Dateien',
|
||||
'data' => 'dateianzahl',
|
||||
'class' => 'dt-center',
|
||||
'defaultContent' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
$sqlTemplate =
|
||||
"SELECT SQL_CALC_FOUND_ROWS v.id,
|
||||
if(v.status <> 'storniert', v.belegnr, concat('<s>', v.belegnr, '</s>')) AS verbindlichkeitnr,
|
||||
if(v.status <> 'storniert', a.lieferantennummer,concat('<s>', a.lieferantennummer, '</s>')) AS lieferantennr,
|
||||
if(v.status <> 'storniert', a.name, concat('<s>', a.name, '</s>')) AS lieferant,
|
||||
DATE_FORMAT(v.rechnungsdatum, '%d.%m.%Y') AS rechnungsdatum,
|
||||
IF(v.betrag < 0, CONCAT('<font color=red>', v.verwendungszweck, ' ', IF(v.rechnung != '', 'RE ' ,''), v.rechnung, '</font>'), v.rechnung) AS rechnungsnr,
|
||||
(".$this->app->erp->FormatPreis('v.betrag', 2).") AS betrag,
|
||||
dateien.anzahl AS dateianzahl
|
||||
FROM verbindlichkeit v
|
||||
LEFT JOIN adresse AS a ON v.adresse = a.id
|
||||
LEFT JOIN zahlungsweisen AS z ON v.zahlungsweise = z.type
|
||||
LEFT JOIN projekt AS p ON p.id = v.projekt
|
||||
LEFT JOIN (
|
||||
SELECT ds.parameter AS verbindlichkeit_id, COUNT(ds.datei) AS anzahl
|
||||
FROM datei_stichwoerter AS ds
|
||||
WHERE ds.objekt LIKE 'Verbindlichkeit'
|
||||
GROUP BY ds.parameter, ds.objekt
|
||||
) AS dateien ON dateien.verbindlichkeit_id = v.id
|
||||
WHERE v.id > 0 " . $this->app->erp->ProjektRechte() . '
|
||||
{{where}}
|
||||
ORDER BY {{orderby}}
|
||||
LIMIT {{offset}}, {{limit}}';
|
||||
|
||||
$sqlCount =
|
||||
'SELECT COUNT(v.id) AS num
|
||||
FROM verbindlichkeit AS v
|
||||
LEFT JOIN projekt AS p ON p.id = v.projekt
|
||||
WHERE v.id > 0 ' . $this->app->erp->ProjektRechte();
|
||||
|
||||
return [
|
||||
'sql_count' => $sqlCount,
|
||||
'sql_template' => $sqlTemplate,
|
||||
'columns' => $columns,
|
||||
'filter' => $filter,
|
||||
'order' => [[0, 'desc']],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
|
||||
class GroupTable{
|
||||
|
||||
var $app;
|
||||
|
||||
var $rows;
|
||||
var $dataset;
|
||||
var $headings;
|
||||
var $sourceitemsdataset;
|
||||
var $sourceitemsheadings;
|
||||
|
||||
function __construct(&$app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
function DatabaseTable($table)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function Group($groupid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
function Search($searchwidget)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
function Table(&$listwidget)
|
||||
{
|
||||
}
|
||||
|
||||
function SourceItems($sql)
|
||||
{
|
||||
$this->sourceitemsdatasets = $this->app->DB->SelectArr($sql);
|
||||
foreach($this->sourceitemsdatasets[0] as $colkey=>$value)
|
||||
$this->sourceitemsheadings[]=ucfirst($colkey);
|
||||
//$this->sourceitemsheadings[count($this->sourceitemsheadings)-1] = 'Aktion';
|
||||
}
|
||||
|
||||
|
||||
function DynamicTable($sql)
|
||||
{
|
||||
|
||||
//$sql.= " LIMIT 1,10";
|
||||
$sql.= " order by position";
|
||||
$this->datasets = $this->app->DB->SelectArr($sql);
|
||||
foreach($this->datasets[0] as $colkey=>$value)
|
||||
$this->headings[]=ucfirst($colkey);
|
||||
|
||||
$this->headings[count($this->headings)-1] = 'Aktion';
|
||||
}
|
||||
|
||||
function GetTableWithArrows()
|
||||
{
|
||||
$htmltable = new HTMLTable(0,"100%","",3,1);
|
||||
$htmltable->AddRowAsHeading($this->headings);
|
||||
|
||||
$htmltable->ChangingRowColors('#FFf1c5','#FFcc99');
|
||||
|
||||
foreach($this->datasets as $row){
|
||||
$htmltable->NewRow();
|
||||
foreach($row as $field)
|
||||
$htmltable->AddCol($field);
|
||||
}
|
||||
|
||||
$module = $this->app->Secure->GetGET("module");
|
||||
$action = $this->app->Secure->GetGET("action");
|
||||
$id = $this->app->Secure->GetGET("id");
|
||||
|
||||
$htmltable->ReplaceCol(count($this->headings),
|
||||
"<a href=\"index.php?module=$module&action=$action&eventid=%value%&event=del&id=$id\">del</a>
|
||||
<a href=\"index.php?module=$module&action=$action&eventid=%value%&event=new&id=$id\">new</a>
|
||||
<a href=\"index.php?module=$module&action=$action&eventid=%value%&event=up&id=$id\">nauf</a>
|
||||
<a href=\"index.php?module=$module&action=$action&eventid=%value%&event=down&id=$id\">nunda</a>
|
||||
");
|
||||
|
||||
return $htmltable->Get();
|
||||
}
|
||||
|
||||
function Step($step,$widget,$method,$parsetarget)
|
||||
{
|
||||
$mywidget = $this->app->Widget->Get($widget,$parsetarget);
|
||||
$mywidget->$method();
|
||||
}
|
||||
|
||||
function SaveItem($widget,$method,$formvar)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
function SaveValue($widget,$method,$formvar)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function Execute($verknuepftabelle,$hauptpunkttabelle,$hauptpunkttabelleid,
|
||||
$untertabelle,$parsetarget=PAGE)
|
||||
{
|
||||
$event = $this->app->Secure->GetGET("event");
|
||||
$eventid = $this->app->Secure->GetGET("eventid");
|
||||
$module = $this->app->Secure->GetGET("module");
|
||||
$action = $this->app->Secure->GetGET("action");
|
||||
|
||||
$id = $this->app->Secure->GetGET("id");
|
||||
|
||||
switch($event) {
|
||||
case "new":
|
||||
//echo "nach $id und item $eventid";
|
||||
$eventnewitem = $this->app->Secure->GetPOST("eventnewitem");
|
||||
if(is_numeric($eventnewitem))
|
||||
{
|
||||
/* speichern */
|
||||
//wenn nichts dann als erstes
|
||||
$this->app->DB->Insert("INSERT INTO $verknuepftabelle (id,$hauptpunkttabelle,
|
||||
$untertabelle,position) VALUES ('','$hauptpunkttabelleid','$eventnewitem',1)");
|
||||
//echo $eventnewitem." ".$id;
|
||||
//sonst alles nachrutschen
|
||||
|
||||
/* redirect auf module und action + id */
|
||||
header("Location: index.php?module=$module&action=$action&id=$id");
|
||||
|
||||
} else
|
||||
{
|
||||
$htmltable = new HTMLTable(0,"100%","",3,1);
|
||||
$htmltable->AddRowAsHeading($this->sourceitemsheadings);
|
||||
|
||||
$htmltable->ChangingRowColors('#FFf1c5','#FFcc99');
|
||||
|
||||
foreach($this->sourceitemsdatasets as $row){
|
||||
$htmltable->NewRow();
|
||||
foreach($row as $field)
|
||||
$htmltable->AddCol($field);
|
||||
}
|
||||
$htmltable->ReplaceCol(1,
|
||||
"<input type=\"radio\" name=\"eventnewitem\" value=\"%value%\">");
|
||||
|
||||
/* anzeige */
|
||||
$this->app->Tpl->Set($parsetarget,$htmltable->Get());
|
||||
}
|
||||
break;
|
||||
|
||||
case "del":
|
||||
echo "hau ab!";
|
||||
$this->app->Tpl->Set($parsetarget,$this->GetTableWithArrows());
|
||||
break;
|
||||
|
||||
case "up":
|
||||
echo "nauf";
|
||||
$this->app->Tpl->Set($parsetarget,$this->GetTableWithArrows());
|
||||
break;
|
||||
|
||||
case "down":
|
||||
echo "nunda";
|
||||
$this->app->Tpl->Set($parsetarget,$this->GetTableWithArrows());
|
||||
break;
|
||||
|
||||
default:
|
||||
// entweder fertige tabelle mit pfeilen
|
||||
if(count($this->datasets[0])>0)
|
||||
$this->app->Tpl->Set($parsetarget,$this->GetTableWithArrows());
|
||||
else
|
||||
$this->app->Tpl->Set($parsetarget,
|
||||
"Keine Datensätze vorhanden -> Datensatz
|
||||
<a href=\"index.php?module=$module&action=$action&event=new&id=$id\">
|
||||
einfügen</a>.");
|
||||
//$this->app->Tpl->Parse($parsetarget,"dialog.tpl");
|
||||
}
|
||||
|
||||
// oder suche + tabelle mit radiobuttons
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,774 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SIP Tabelle
|
||||
* Stellt eine SIP-Formatierte Tabelle mit optionalem Zeilenmenü zur Verfügung.
|
||||
*
|
||||
* @package SIP
|
||||
* @author Benedikt Sauter <sauter@sistecs.de>
|
||||
* @author coma ag <info@coma.de>
|
||||
* @author *105 - Multimediabüro <development@stern105.de>
|
||||
* @version 1.0
|
||||
* @since PHP 4.x
|
||||
*/
|
||||
class Table {
|
||||
|
||||
/**
|
||||
* Target template to wich the table will be parsed. [Default: PAGE]
|
||||
* @type string
|
||||
*/
|
||||
var $parsetarget;
|
||||
|
||||
/**
|
||||
* HTMLTable. Apply format changes to this object.
|
||||
* @type Object
|
||||
* @access public
|
||||
*/
|
||||
var $table;
|
||||
|
||||
/**
|
||||
* SQL statement to fill table content. Altrnatively use CreateTableFromArray().
|
||||
* @type string
|
||||
* @access private
|
||||
*/
|
||||
var $sql;
|
||||
|
||||
/**
|
||||
* Data array to fill table content. Altrnatively use CreateTableFromSQL().
|
||||
* @type string
|
||||
* @access private
|
||||
*/
|
||||
var $contentArr;
|
||||
|
||||
/**
|
||||
* Indicates whether data is gathered from SQL statement od provided array
|
||||
* @type bool
|
||||
* @access private
|
||||
*/
|
||||
var $fromSQL = true;
|
||||
|
||||
var $searchform=false; // normally true
|
||||
var $sortheading=true;
|
||||
var $html;
|
||||
var $menu;
|
||||
var $rowlimit=0;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor method
|
||||
*
|
||||
* @param $app Default application class
|
||||
*
|
||||
* @return Generated object ($this)
|
||||
* @access public
|
||||
*/
|
||||
function __construct($app) {
|
||||
$this->app = $app;
|
||||
$this->app->Tpl->Set('TABLEHEADER', "");
|
||||
$this->app->Tpl->Set('TABLEFOOTER', "");
|
||||
} // end of constructor
|
||||
|
||||
/**
|
||||
* Standard method to create a table. The data is gathered
|
||||
* from provided sql statement and formatted, finally printed
|
||||
* to screen.
|
||||
*
|
||||
* <br /><br /><strong>
|
||||
* NOTE: Method is deprecated. Use CreateTableFromArray() or
|
||||
* CreateTableFromSQL() instead!
|
||||
* </strong>
|
||||
*
|
||||
* @param $sql SQL stemenet (Select) to fill the table content
|
||||
* @param $parsetarget Target template to where the content is parsed [Default: PAGE]
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function CreateTable($sql, $parsetarget='PAGE',$size="") {
|
||||
$this->CreateTableFromSQL($sql, $parsetarget,$size);
|
||||
} // end of function
|
||||
|
||||
/**
|
||||
* Standard method to create a table: The data is gathered
|
||||
* from provided sql statement and formatted, finally printed
|
||||
* to screen.
|
||||
*
|
||||
* @param $sql SQL stemenet (Select) to fill the table content
|
||||
* @param $parsetarget Target template to where the content is parsed [Default: PAGE]
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function CreateTableFromSQL($sql, $parsetarget='PAGE', $size="")
|
||||
{
|
||||
$order=$this->app->Secure->GetGET("order");
|
||||
if($order!="")
|
||||
$sql = $sql." ORDER By $order";
|
||||
|
||||
$this->parsetarget = $parsetarget;
|
||||
$this->sql = $sql;
|
||||
$this->contentArr = $this->app->DB->SelectArr($this->sql);
|
||||
$this->html = "";
|
||||
$this->fromSQL = true;
|
||||
$this->InitTable($size);
|
||||
} // end of function
|
||||
|
||||
/**
|
||||
* Alternative method to create a table: The data is gathered
|
||||
* from provided data array, then formatted and finally printed
|
||||
* to screen.
|
||||
*
|
||||
* @param $contentArr SQL stemenet (Select) to fill the table content
|
||||
* @param $parsetarget Target template to where the content is parsed [Default: PAGE]
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function CreateTableFromArray($contentArr, $parsetarget=PAGE, $size="")
|
||||
{
|
||||
/*
|
||||
echo "<pre>";
|
||||
print_r($contentArr[0]);
|
||||
echo "</pre>";
|
||||
*/
|
||||
|
||||
|
||||
$order=$this->app->Secure->GetGET("order");
|
||||
if($order!="")
|
||||
$contentArr = $this->SortTableArray($contentArr,$order);
|
||||
|
||||
$this->parsetarget = $parsetarget;
|
||||
$this->contentArr = $contentArr;
|
||||
$this->fromSQL = false;
|
||||
$this->InitTable($size);
|
||||
} // end of function
|
||||
|
||||
|
||||
function SortTableArray($data,$order)
|
||||
{
|
||||
|
||||
// to be sure, that we have a numeric array
|
||||
for ($i=0; $i<count($data); $i++) {
|
||||
foreach($data[$i] as $key=>$value)
|
||||
{
|
||||
$numarr[$i][]=$value;
|
||||
}
|
||||
}
|
||||
$data = $numarr;
|
||||
|
||||
// Obtain a list of columns
|
||||
// We have an array of rows, but array_multisort() requires an array of columns,
|
||||
// so we use the below code to obtain the columns, then perform the sorting.
|
||||
if(count($data)>0)
|
||||
foreach ($data as $key => $row) {
|
||||
for($i=0;$i<count($row);$i++)
|
||||
{
|
||||
$sort[$i][$key] = $row[$i];
|
||||
}
|
||||
//$stueck[$key] = $row[7];
|
||||
}
|
||||
// print_r($sort);
|
||||
// Sort the data with volume descending, edition ascending
|
||||
// Add $data as the last parameter, to sort by the common key
|
||||
@array_multisort($sort[$order],SORT_ASC,SORT_NUMERIC,$data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes an HTML table
|
||||
*
|
||||
* @param $size width table [Default: 700]
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function InitTable($size=700) {
|
||||
// Create html table
|
||||
$this->table = new HTMLTable("0",$size,"","0","0");
|
||||
$this->table->SetTDClass("divider");
|
||||
$this->table->ChangingRowColors('#F5F5F5', '');
|
||||
$this->Generate();
|
||||
} // end of function
|
||||
|
||||
/**
|
||||
* Use Array $contentArr to fill table with data
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function Generate($fromSQL=true) {
|
||||
// Check for empty array
|
||||
if (count($this->contentArr) < 1)
|
||||
return;
|
||||
|
||||
// Build table
|
||||
while (list($key, $row) = @each($this->contentArr)) {
|
||||
|
||||
$this->table->NewRow();
|
||||
while (list($col, $val) = @each($row)) {
|
||||
|
||||
if(count($this->cols)==0) {
|
||||
$this->table->AddCol($val);
|
||||
} else {
|
||||
if(isset($this->cols[$col]))
|
||||
$this->table->AddCol($val);
|
||||
} // end of if
|
||||
} // end of inner while
|
||||
} // end of outer while
|
||||
} // end of function
|
||||
|
||||
|
||||
function DeleteAsk($colnumber,$msg,$module,$action){
|
||||
$link = "<a href=\"#\" onclick=\"str = confirm('{$msg}');
|
||||
if(str!='' & str!=null)
|
||||
window.document.location.href='index.php?module=$module&action=$action&id=%value%';\">
|
||||
loeschen</a>";
|
||||
|
||||
$this->table->ReplaceCol($colnumber,$link);
|
||||
} // end of function
|
||||
|
||||
|
||||
function ReplaceCol($colnumber,$link) {
|
||||
$this->table->ReplaceCol($colnumber,$link);
|
||||
} // end of function
|
||||
|
||||
|
||||
function RowMenu($col, $menu) {
|
||||
$this->menu = $menu;
|
||||
|
||||
switch($menu) {
|
||||
case 'special':
|
||||
// $this->RowMenuSpecial($col, "personenform");
|
||||
break;
|
||||
|
||||
case 'personen':
|
||||
$this->RowMenuGeneric($col, "personenform", true, true);
|
||||
break;
|
||||
|
||||
case 'formel':
|
||||
$this->RowMenuGeneric($col, "formelform", false, true);
|
||||
break;
|
||||
|
||||
case 'produkt':
|
||||
$this->RowMenuGeneric($col, "produktform", true, true);
|
||||
break;
|
||||
|
||||
case 'hut':
|
||||
$this->RowMenuHut($col, "hutform", true, true);
|
||||
break;
|
||||
|
||||
case 'statistikauswertung_ordner':
|
||||
$this->RowMenuAuswertung($col, "statistikauswerten");
|
||||
break;
|
||||
|
||||
case 'statistikverwaltung_ordner':
|
||||
$this->RowMenuVerwaltungOrdner($col, "statistikverwalten");
|
||||
break;
|
||||
|
||||
case 'statistikverwaltung_formeln':
|
||||
$this->RowMenuVerwaltungFormeln($col, "statistikverwaltenformel");
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->RowMenuGeneric($col, $menu."form", true);
|
||||
} // end of switch
|
||||
|
||||
} // end of function
|
||||
|
||||
/* spalten nummer ( von 1 gezaehlt), dann der if wert also wenn value gleich
|
||||
dem aktuellen Wert in der Zelle ist, dann wird der text in der
|
||||
Zeile durch replacestring ersetzt. Im replacestring muss
|
||||
sich %value% befinden, an der Stelle wird der alte Wert eingefuegt.
|
||||
|
||||
Falls bestimmte Spalten nicht ersetzt werden sollen, koennen diese
|
||||
im array dontreplacecols angegeben werden.
|
||||
*/
|
||||
|
||||
function FormatCondition($col, $value, $replacestring, $dontreplacecols=array()) {
|
||||
$rows = count($this->table->Table);
|
||||
for($i=0;$i<$rows;$i++) {
|
||||
|
||||
// check ob der wert in der spalte mit dem $value uebereinstimmt
|
||||
// wenn ja ersetze jede zeile auser die aus dem array dontreplacecols
|
||||
if($this->table->Table[$i][$col-1]==$value) {
|
||||
|
||||
// ersetze spalten auser die in dontreplacecols
|
||||
$cols = count($this->table->Table[$i]);
|
||||
|
||||
for($j=0;$j<$cols;$j++) {
|
||||
if(!in_array($j+1,$dontreplacecols)) {
|
||||
$content = $this->table->Table[$i][$j];
|
||||
$this->table->Table[$i][$j] = str_replace("%value%", $content, $replacestring);
|
||||
} // end of if
|
||||
} // end of for
|
||||
} // end of if
|
||||
} // end of for
|
||||
} // end of function
|
||||
|
||||
/**
|
||||
* Formats a table coolumn with SIP specific format options.
|
||||
* Available options are listed below:
|
||||
* <ul>
|
||||
* <li>numeric: aligns right</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param Int $col Column number for menu
|
||||
* @param String $sipStyle use options from available list (see above)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function FormatColumn($col, $sipStyle) {
|
||||
switch ($sipStyle){
|
||||
case "numeric":
|
||||
$cssStyle = "divider alignRight";
|
||||
break;
|
||||
|
||||
case "currency":
|
||||
$cssStyle = "divider alignRight number";
|
||||
break;
|
||||
|
||||
default:
|
||||
$cssStyle = "divider";
|
||||
} // end of switch
|
||||
|
||||
$this->table->FormatCol($col, $cssStyle);
|
||||
} // end of function
|
||||
|
||||
/**
|
||||
* Creates a generic menu for each table row.
|
||||
* Presets for this generic menu are:
|
||||
* <ul>
|
||||
* <li>the menu column contains the data records id (primary key)</li>
|
||||
* <li>1st column contains the same id as above</li>
|
||||
* <li>2nd column contains 0 or 1 as relevant value for activate and deactivate (zustand / active) if param $showActivate is set to true</li>
|
||||
* <li>3rd column contains 0 or 1 as relevant value for delete (deletable or not) if param $showDelete is set to true</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param Int $col Column number for menu
|
||||
* @param String $module Modulename used to build links (e.g. personenform, hutform, etc.)
|
||||
* @param Bool $showActivate Show active/deactivate buttons depending on value in 2nd column
|
||||
* @param Bool $showDelete Show delete button if value indicates that (value in 3rd column)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function RowMenuGeneric($col, $module, $showActivate=true, $showDelete=false) {
|
||||
$rows = count($this->table->Table);
|
||||
|
||||
for($i=0;$i<$rows;$i++) {
|
||||
$cols = count($this->table->Table[$i]);
|
||||
|
||||
for($j=0;$j<$cols;$j++) {
|
||||
|
||||
if($j==($col-1)){
|
||||
$id = $this->table->Table[$i][$j];
|
||||
$menu = "";
|
||||
//historie
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=history&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_history.gif\" border=\"0\" alt=\"Historie\">";
|
||||
$menu .= "</a> ";
|
||||
|
||||
// bearbeiten wenn aktiv
|
||||
if ($this->table->Table[$i][1] != 0) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=edit&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_edit.gif\" border=\"0\" alt=\"bearbeiten\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if
|
||||
|
||||
// aktivieren wenn inaktiv, sonst deaktivieren
|
||||
if (($this->table->Table[$i][1] == 0) && ($showActivate)){
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=activate&id=$id&order=[ORDER]\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_reactivate.gif\" border=\"0\" alt=\"reaktivieren\">";
|
||||
$menu .= "</a> ";
|
||||
} else {
|
||||
if($showActivate) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=deactivate&id=$id&order=[ORDER]\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_deactivate.gif\" border=\"0\" alt=\"deaktivieren\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if
|
||||
} // end of if - anzeige von deaktivieren ODER aktivieren
|
||||
|
||||
// l�sch button einblenden wenn delete kriterium 1
|
||||
if ($showDelete) {
|
||||
// print_r($this->table->Table);
|
||||
if ($this->table->Table[$i][2] == 1) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=delete&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_delete.gif\" border=\"0\" alt=\"löschen\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if - anzeige des l�schen buttons oder nicht nach wert
|
||||
} // end of if - anzeige von l�schen oder nicht nach funktionsparmeter
|
||||
|
||||
// wenn noch nicht verlinkt
|
||||
$this->table->Table[$i][$j] = $menu;
|
||||
|
||||
} // end of outer if
|
||||
} // end of inner for
|
||||
} // end pof outer for
|
||||
} // end of function
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates a specific form for Hut
|
||||
*
|
||||
* @param Int $col Column number for menu
|
||||
* @param String $module Modulename used to build links (e.g. personenform, hutform, etc.)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function RowMenuHut($col, $module, $showActivate=true, $showDelete=false) {
|
||||
$rows = count($this->table->Table);
|
||||
|
||||
for($i=0;$i<$rows;$i++) {
|
||||
$cols = count($this->table->Table[$i]);
|
||||
|
||||
for($j=0;$j<$cols;$j++) {
|
||||
|
||||
if($j==($col-1)){
|
||||
$id = $this->table->Table[$i][$j];
|
||||
$menu = "";
|
||||
//historie
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=history&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_history.gif\" border=\"0\" alt=\"Historie\">";
|
||||
$menu .= "</a> ";
|
||||
|
||||
// bearbeiten wenn aktiv
|
||||
if ($this->table->Table[$i][1] != 0) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=edit&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_edit.gif\" border=\"0\" alt=\"bearbeiten\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if
|
||||
|
||||
// aktivieren wenn inaktiv, sonst deaktivieren
|
||||
if (($this->table->Table[$i][1] == 0) && ($showActivate)){
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=activate&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_reactivate.gif\" border=\"0\" alt=\"reaktivieren\">";
|
||||
$menu .= "</a> ";
|
||||
} else {
|
||||
if($showActivate) {
|
||||
if (strlen($this->table->Table[$i][8]) == 51) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=deactivate&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_deactivate.gif\" border=\"0\" alt=\"deaktivieren\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if
|
||||
} // end of if
|
||||
} // end of if - anzeige von deaktivieren ODER aktivieren
|
||||
|
||||
// l�sch button einblenden wenn delete kriterium 1
|
||||
if ($showDelete) {
|
||||
// print_r($this->table->Table);
|
||||
if ($this->table->Table[$i][2] == 1) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=delete&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_delete.gif\" border=\"0\" alt=\"löschen\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if - anzeige des l�schen buttons oder nicht nach wert
|
||||
} // end of if - anzeige von l�schen oder nicht nach funktionsparmeter
|
||||
|
||||
// wenn noch nicht verlinkt
|
||||
$this->table->Table[$i][$j] = $menu;
|
||||
|
||||
} // end of outer if
|
||||
} // end of inner for
|
||||
} // end pof outer for
|
||||
} // end of function
|
||||
|
||||
|
||||
/**
|
||||
* Creates a specific form for OIC Module Statistik Auswertung / Ordner�bersicht
|
||||
*
|
||||
* @param Int $col Column number for menu
|
||||
* @param String $module Modulename used to build links (e.g. personenform, hutform, etc.)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function RowMenuAuswertung($col, $module) {
|
||||
$rows = count($this->table->Table);
|
||||
|
||||
for($i=0;$i<$rows;$i++) {
|
||||
$cols = count($this->table->Table[$i]);
|
||||
|
||||
for($j=0;$j<$cols;$j++) {
|
||||
|
||||
if($j==($col-1)){
|
||||
$id = $this->table->Table[$i][$j];
|
||||
$menu = "";
|
||||
|
||||
if ($this->table->Table[$i][3] != 0) {
|
||||
// Detailansicht
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=showordner&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_view.gif\" border=\"0\" alt=\"Detailansicht\">";
|
||||
$menu .= "</a> ";
|
||||
|
||||
// Graph
|
||||
$menu .= "<a href=\"#\" onclick=\"GesamtGraphOrdnerID($id)\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_statgraph.gif\" border=\"0\" alt=\"Graph\">";
|
||||
$menu .= "</a> ";
|
||||
|
||||
} else {
|
||||
$menu .= "keine Formeln vorhanden";
|
||||
} // end of if - nicht anzeigen wenn keine Formeln im Ordner sind
|
||||
|
||||
// wenn noch nicht verlinkt
|
||||
$this->table->Table[$i][$j] = $menu;
|
||||
|
||||
} // end of outer if
|
||||
} // end of inner for
|
||||
} // end pof outer for
|
||||
} // end of function
|
||||
|
||||
|
||||
/**
|
||||
* Creates a specific form for OIC Module Statistik Verwaltung / Ordner�bersicht
|
||||
*
|
||||
* @param Int $col Column number for menu
|
||||
* @param String $module Modulename used to build links (e.g. personenform, hutform, etc.)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function RowMenuVerwaltungOrdner($col, $module) {
|
||||
$rows = count($this->table->Table);
|
||||
|
||||
for($i=0; $i<$rows; $i++) {
|
||||
$cols = count($this->table->Table[$i]);
|
||||
|
||||
for($j=0; $j<$cols; $j++) {
|
||||
|
||||
if($j==($col-1)){
|
||||
$id = $this->table->Table[$i][$j];
|
||||
$menu = "";
|
||||
|
||||
// Edit
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=edit&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_edit.gif\" border=\"0\" alt=\"Ordner bearbeiten\">";
|
||||
$menu .= "</a> ";
|
||||
|
||||
// Formeln bearbeiten
|
||||
$menu .= "<a href=\"index.php?module=".$module."formel&action=list&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_formeln.gif\" border=\"0\" alt=\"Formeln bearbeiten\">";
|
||||
$menu .= "</a> ";
|
||||
|
||||
// Nach unten (wenn nicht letztes in Liste)
|
||||
if ($i != $rows-1) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=movedown&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_down.gif\" border=\"0\" alt=\"Nach unten\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if
|
||||
|
||||
// Nach oben (wenn nicht erstes in Liste)
|
||||
if ($i != 0) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=moveup&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_up.gif\" border=\"0\" alt=\"Nach oben\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if
|
||||
|
||||
// Delete - Wenn in Spalte 3 eine 0 steht (keine Formeln mehr im Ordner)
|
||||
if ($this->table->Table[$i][3] == 0) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=delete&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_delete.gif\" border=\"0\" alt=\"löschen\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if - anzeige des l�schen buttons oder nicht nach wert
|
||||
|
||||
// wenn noch nicht verlinkt
|
||||
$this->table->Table[$i][$j] = $menu;
|
||||
|
||||
} // end of outer if
|
||||
} // end of inner for
|
||||
} // end pof outer for
|
||||
} // end of function
|
||||
|
||||
/**
|
||||
* Creates a specific form for OIC Module Statistik Verwaltung / Formel�bersicht innerhalb eines Ordners
|
||||
*
|
||||
* @param Int $col Column number for menu
|
||||
* @param String $module Modulename used to build links (e.g. personenform, hutform, etc.)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function RowMenuVerwaltungFormeln($col, $module) {
|
||||
$rows = count($this->table->Table);
|
||||
|
||||
if ($rows == 0) {
|
||||
$this->table->Table[] = Array("", "", "", "Bisher existiert kein Eintrag in dieser Liste.", "", "", "", "-1");
|
||||
$rows = count($this->table->Table);
|
||||
} // end of if
|
||||
|
||||
for($i=0; $i<$rows; $i++) {
|
||||
$cols = count($this->table->Table[$i]);
|
||||
|
||||
for($j=0; $j<$cols; $j++) {
|
||||
|
||||
if($j==($col-1)){
|
||||
$id = $this->table->Table[$i][$j];
|
||||
$menu = "";
|
||||
|
||||
// Ansicht (1 oder 1/4)
|
||||
if ($this->table->Table[$i][1] == 4 && $id != -1) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=viewfull&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_ansicht_1_1.gif\" border=\"0\" alt=\"Ansicht Vollformat\">";
|
||||
$menu .= "</a> ";
|
||||
} else if ($this->table->Table[$i][0] != "") {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=viewquarter&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_ansicht_1_4.gif\" border=\"0\" alt=\"Ansicht Viertelformat\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if - Ansicht 1 oder 1/4
|
||||
|
||||
// Delete - Wenn in Spalte 3 eine 0 steht (keine Formeln mehr im Ordner)
|
||||
//echo $this->table->Table[$i][1]."<br>";
|
||||
//if ($this->table->Table[$i][1] == 0 && $id != -1) {
|
||||
if ($id != -1) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=delete&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_delete.gif\" border=\"0\" alt=\"löschen\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if - anzeige des l�schen buttons oder nicht nach wert
|
||||
|
||||
// Formeln hinzuf�gen
|
||||
if ($id != -1) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=addafter&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_add.gif\" border=\"0\" alt=\"Nach diesem hinzuf�gen\">";
|
||||
$menu .= "</a> ";
|
||||
} else {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=add&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_add.gif\" border=\"0\" alt=\"Formel hinzuf�gen\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if
|
||||
|
||||
// Nach unten (wenn nicht letztes in Liste)
|
||||
if ($i != $rows-1 && $id != -1) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=movedown&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_down.gif\" border=\"0\" alt=\"Nach unten\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if
|
||||
|
||||
// Nach oben (wenn nicht erstes in Liste)
|
||||
if ($i != 0 && $id != -1) {
|
||||
$menu .= "<a href=\"index.php?module=".$module."&action=moveup&id=$id\">";
|
||||
$menu .= "<img src=\"./sip/themes/[THEME]/images/buttons/bu_up.gif\" border=\"0\" alt=\"Nach oben\">";
|
||||
$menu .= "</a> ";
|
||||
} // end of if
|
||||
|
||||
// wenn noch nicht verlinkt
|
||||
$this->table->Table[$i][$j] = $menu;
|
||||
|
||||
} // end of outer if
|
||||
} // end of inner for
|
||||
} // end pof outer for
|
||||
|
||||
/*
|
||||
<tr class="odd">
|
||||
<td class="divider alignRight">1</td>
|
||||
<td class="divider"><a href="#">Abgeschlossene Verträge </a></td>
|
||||
<td class="divider">F3</td>
|
||||
<td class="divider">Pkt/Stk</td>
|
||||
<td class="divider">1</td>
|
||||
<td><a href=""><img src="images/buttons/bu_ansicht_1_4.gif" alt="Ansicht 1/4" width="18" height="18" class="icon" title="Ansicht 1/4" /></a> <a href=""><img src="images/buttons/bu_delete.gif" alt="löschen" class="icon" title="löschen" /></a> <a href=""><img src="images/buttons/bu_add.gif" alt="nach dieser hinzufügen" class="icon" title="nach dieser hinzufügen" /></a> <a href=""><img src="images/buttons/bu_down.gif" alt="nach unten" class="icon" title="nach unten" /></a> </td>
|
||||
</tr>
|
||||
*/
|
||||
|
||||
} // end of function
|
||||
|
||||
|
||||
/**
|
||||
* Shows the siptable
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function Show() {
|
||||
$this->html = "";
|
||||
if($this->searchform)
|
||||
$this->html .= $this->SortAndSearchForm();
|
||||
|
||||
//$this->html .= $this->table->Get(" ","");
|
||||
$this->html .= $this->table->Get(" ",$this->headingtop);
|
||||
$this->app->Tpl->Add($this->parsetarget, $this->html);
|
||||
} // end of function
|
||||
|
||||
|
||||
function RowLimit($number) {
|
||||
$this->rowlimit=$number;
|
||||
}
|
||||
|
||||
|
||||
function Cols($fields)
|
||||
{
|
||||
$this->cols=array_flip($fields);
|
||||
}
|
||||
|
||||
function HideCol($number)
|
||||
{
|
||||
$this->table->HideCol($number);
|
||||
}
|
||||
|
||||
function HeadingTop($value)
|
||||
{
|
||||
$this->headingtop=$value;
|
||||
|
||||
}
|
||||
|
||||
function Headings($descriptions)
|
||||
{
|
||||
$this->table->AddRowAsHeading($descriptions);
|
||||
$this->descriptions=$descriptions;
|
||||
}
|
||||
|
||||
function SetSortAndSearchForm($bool)
|
||||
{
|
||||
$this->searchform=$bool;
|
||||
}
|
||||
|
||||
function SetSortHeading($bool)
|
||||
{
|
||||
$this->sortheading=$bool;
|
||||
}
|
||||
|
||||
|
||||
function SortAndSearchForm()
|
||||
{
|
||||
$select = new HTMLSelect("sort",1);
|
||||
if(count($this->cols)==0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
while (list($col, $val) = @each($this->cols))
|
||||
{
|
||||
if($this->descriptions[$col]!="")
|
||||
$select->AddOption("Nach {$this->descriptions[$col]} Sortieren",$col);
|
||||
else
|
||||
$select->AddOption("Nach $col Sortieren",$col);
|
||||
|
||||
}
|
||||
}
|
||||
$html = $select->Get();
|
||||
|
||||
$search = new HTMLInput("search","text","",20);
|
||||
$html .= $search->Get();
|
||||
|
||||
$html .="<input type=\"submit\" value=\"Suchen\">";
|
||||
|
||||
$html .="<br>";
|
||||
|
||||
$alphabet = range('A', 'Z');
|
||||
$html .="<table width=\"100%\" cellpadding=\"7\"><tr>";
|
||||
foreach ($alphabet as $letter)
|
||||
$html .= "<td><a href=\"\">$letter</a></td>";
|
||||
|
||||
$html .="</tr></table>";
|
||||
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
} // end of class
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,5 @@
|
||||
[SEARCH]
|
||||
<br>
|
||||
<br>
|
||||
[TABLE]
|
||||
|
||||
Reference in New Issue
Block a user