12 Commits
Author SHA1 Message Date
OpenXE 529587c0f5 Extended .htaccess for setup and inline PDF 2022-12-16 17:45:17 +00:00
OpenXE 35f6532520 Teilauftrag WIP 2022-12-16 17:33:15 +00:00
OpenXE 84eaf1b495 Modified GetPOSTArray and GetGETArray, because keys were not filled in 2022-12-16 14:40:19 +00:00
OpenXE c519d8030a Version 1.7 2022-12-15 11:49:22 +00:00
OpenXE 0848148b9e shopimporter_shopware6 removed v2 from URL to allow shopware 6.4 api 2022-12-15 10:40:10 +00:00
OpenXE 6c9d8b7594 upgrade view comparison now ignores view security 2022-12-15 09:46:41 +00:00
OpenXE 51f9929228 upgrade.sh executable bit 2022-12-14 17:44:06 +00:00
OpenXE 508ee0ae8e added userdata to .gitignore 2022-12-14 17:24:17 +00:00
OpenXE ca9b48cb58 upgrade some usability improvements, upgrade.sh script 2022-12-14 17:12:12 +00:00
OpenXE 817dd802aa upgrade added info and -o option 2022-12-14 15:25:48 +00:00
OpenXE 6a5679ba23 upgrade improved folder handling, git init part 2 2022-12-14 12:38:16 +00:00
OpenXE 724c57d309 upgrade improved folder handling, git init 2022-12-13 18:40:13 +00:00
15 changed files with 709 additions and 454 deletions
+2 -3
View File
@@ -1,5 +1,4 @@
conf/user.inc.php conf/user.inc.php
conf/user_defined.php conf/user_defined.php
userdata/cronjobkey.txt userdata
userdata/tmp/ www/cache/
www/cache/
+10
View File
@@ -1261,6 +1261,16 @@ Allow from all
Order Allow,Deny Order Allow,Deny
Allow from all Allow from all
</Files> </Files>
# Allow access to setup.php
<Files setup.php>
Order Allow,Deny
Allow from all
</Files>
# Allow access to inline PDF viewer
<Files viewer.html>
Order Allow,Deny
Allow from all
</Files>
# end # end
'); ');
+341 -337
View File
@@ -1,340 +1,344 @@
<?php <?php
/* /*
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE **** **** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
* *
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019 * 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. * 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 * 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. * to obtain the text of the corresponding license version.
* *
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE **** **** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
*/ */
?> ?>
<?php <?php
/// Secure Layer, SQL Inject. Check, Syntax Check /// Secure Layer, SQL Inject. Check, Syntax Check
class Secure class Secure
{ {
public $GET; public $GET;
public $POST; public $POST;
/** /**
* Secure constructor. * Secure constructor.
* *
* @param ApplicationCore $app * @param ApplicationCore $app
*/ */
public function __construct($app){ public function __construct($app){
$this->app = $app; $this->app = $app;
// clear global variables, that everybody have to go over secure layer // clear global variables, that everybody have to go over secure layer
$this->GET = $_GET; $this->GET = $_GET;
if(isset($this->GET['msgs']) && isset($this->app->Location)) { if(isset($this->GET['msgs']) && isset($this->app->Location)) {
$this->GET['msg'] = $this->app->Location->getMessage($this->GET['msgs']); $this->GET['msg'] = $this->app->Location->getMessage($this->GET['msgs']);
} }
// $_GET=""; // $_GET="";
$this->POST = $_POST; $this->POST = $_POST;
// $_POST=""; // $_POST="";
if(!isset($this->app->stringcleaner) && file_exists(__DIR__. '/class.stringcleaner.php')) { if(!isset($this->app->stringcleaner) && file_exists(__DIR__. '/class.stringcleaner.php')) {
if(!class_exists('StringCleaner')) { if(!class_exists('StringCleaner')) {
require_once __DIR__ . '/class.stringcleaner.php'; require_once __DIR__ . '/class.stringcleaner.php';
} }
$this->app->stringcleaner = new StringCleaner($this->app); $this->app->stringcleaner = new StringCleaner($this->app);
} }
$this->AddRule('notempty','reg','.'); // at least one sign $this->AddRule('notempty','reg','.'); // at least one sign
$this->AddRule('alpha','reg','[a-zA-Z]'); $this->AddRule('alpha','reg','[a-zA-Z]');
$this->AddRule('digit','reg','[0-9]'); $this->AddRule('digit','reg','[0-9]');
$this->AddRule('space','reg','[ ]'); $this->AddRule('space','reg','[ ]');
$this->AddRule('specialchars','reg','[_-]'); $this->AddRule('specialchars','reg','[_-]');
$this->AddRule('email','reg','^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$'); $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('datum','reg','([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})');
$this->AddRule('username','glue','alpha+digit'); $this->AddRule('username','glue','alpha+digit');
$this->AddRule('password','glue','alpha+digit+specialchars'); $this->AddRule('password','glue','alpha+digit+specialchars');
} }
/** /**
* @param string $name * @param string $name
* @param null $rule * @param null $rule
* @param string $maxlength * @param string $maxlength
* @param string $sqlcheckoff * @param string $sqlcheckoff
* *
* @return array|mixed|string * @return array|mixed|string
*/ */
public function GetGET($name,$rule=null,$maxlength='',$sqlcheckoff='') public function GetGET($name,$rule=null,$maxlength='',$sqlcheckoff='')
{ {
if($name === 'msg' && isset($this->app->erp) && method_exists($this, 'xss_clean')) { 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->Syntax(isset($this->GET[$name])?$this->GET[$name]:'','',$maxlength,$sqlcheckoff);
$ret = $this->app->erp->base64_url_decode($ret); $ret = $this->app->erp->base64_url_decode($ret);
if(strpos($ret,'"button"') === false){ if(strpos($ret,'"button"') === false){
$ret = $this->xss_clean($ret); $ret = $this->xss_clean($ret);
} }
return $this->app->erp->base64_url_encode($ret); return $this->app->erp->base64_url_encode($ret);
} }
if($rule === null) { if($rule === null) {
$rule = $this->NameToRule($name); $rule = $this->NameToRule($name);
} }
return $this->Syntax(isset($this->GET[$name])?$this->GET[$name]:'',$rule,$maxlength,$sqlcheckoff); return $this->Syntax(isset($this->GET[$name])?$this->GET[$name]:'',$rule,$maxlength,$sqlcheckoff);
} }
function NameToRule($name) function NameToRule($name)
{ {
switch($name) switch($name)
{ {
case 'id': case 'id':
return 'doppelid'; return 'doppelid';
break; break;
case 'sid': case 'sid':
return 'alphadigits'; return 'alphadigits';
break; break;
case 'module': case 'module':
case 'smodule': case 'smodule':
case 'action': case 'action':
case 'saction': case 'saction':
return 'module'; return 'module';
break; break;
case 'cmd': case 'cmd':
return 'moduleminus'; return 'moduleminus';
break; break;
} }
return 'nothtml'; return 'nothtml';
} }
public function GetPOST($name,$rule=null,$maxlength="",$sqlcheckoff="") public function GetPOST($name,$rule=null,$maxlength="",$sqlcheckoff="")
{ {
if($rule === null) { if($rule === null) {
$rule = $this->NameToRule($name); $rule = $this->NameToRule($name);
if(isset($this->POST['ishtml_cke_'.$name]) && $this->POST['ishtml_cke_'.$name]) { if(isset($this->POST['ishtml_cke_'.$name]) && $this->POST['ishtml_cke_'.$name]) {
$rule = 'nojs'; $rule = 'nojs';
} }
} }
return $this->Syntax(isset($this->POST[$name])?$this->POST[$name]:'',$rule,$maxlength,$sqlcheckoff); return $this->Syntax(isset($this->POST[$name])?$this->POST[$name]:'',$rule,$maxlength,$sqlcheckoff);
} }
public function GetPOSTForForms($name,$rule="",$maxlength="",$sqlcheckoff="") public function GetPOSTForForms($name,$rule="",$maxlength="",$sqlcheckoff="")
{ {
return $this->SyntaxForForms($this->POST[$name],$rule,$maxlength,$sqlcheckoff); return $this->SyntaxForForms($this->POST[$name],$rule,$maxlength,$sqlcheckoff);
} }
public function CleanString($string, $rule='nohtml',$sqlcheckoff='') public function CleanString($string, $rule='nohtml',$sqlcheckoff='')
{ {
return $this->Syntax($string, $rule, '', $sqlcheckoff); return $this->Syntax($string, $rule, '', $sqlcheckoff);
} }
public function xss_clean($data) public function xss_clean($data)
{ {
return $this->app->stringcleaner->xss_clean($data); return $this->app->stringcleaner->xss_clean($data);
} }
public function GetPOSTArray() public function GetPOSTArray()
{ {
if(!empty($this->POST) && count($this->POST)>0) if(!empty($this->POST) && count($this->POST)>0)
{ {
foreach($this->POST as $key=>$value) foreach($this->POST as $key=>$value)
{ {
$key = $this->GetPOST($key,"alpha+digit+specialchars",20); $value = $this->GetPOST($key);
$ret[$key]=$this->GetPOST($value); if ($value !== null) {
} $ret[$key] = $value;
} }
if(!empty($ret)) }
{ }
return $ret; if(!empty($ret))
} {
return $ret;
return null; }
}
return null;
public function GetGETArray() }
{
if(!empty($this->GET) && count($this->GET)>0) public function GetGETArray()
{ {
foreach($this->GET as $key=>$value) if(!empty($this->GET) && count($this->GET)>0)
{ {
$key = $this->GetGET($key,"alpha+digit+specialchars",20); foreach($this->GET as $key=>$value)
$ret[$key]=$this->GetGET($value); {
} $value = $this->GetGET($key);
} if ($value !== null) {
if(!empty($ret)) $ret[$key] = $value;
{ }
return $ret; }
} }
if(!empty($ret))
return null; {
} return $ret;
}
function stripallslashes($string) {
return null;
while(strstr($string,'\\')) { }
$string = stripslashes($string);
} function stripallslashes($string) {
return $string;
} while(strstr($string,'\\')) {
$string = stripslashes($string);
public function smartstripslashes($str) { }
$cd1 = substr_count($str, "\""); return $string;
$cd2 = substr_count($str, "\\\""); }
$cs1 = substr_count($str, "'");
$cs2 = substr_count($str, "\\'"); public function smartstripslashes($str) {
$tmp = strtr($str, array("\\\"" => "", "\\'" => "")); $cd1 = substr_count($str, "\"");
$cb1 = substr_count($tmp, "\\"); $cd2 = substr_count($str, "\\\"");
$cb2 = substr_count($tmp, "\\\\"); $cs1 = substr_count($str, "'");
if ($cd1 == $cd2 && $cs1 == $cs2 && $cb1 == 2 * $cb2) { $cs2 = substr_count($str, "\\'");
return strtr($str, array("\\\"" => "\"", "\\'" => "'", "\\\\" => "\\")); $tmp = strtr($str, array("\\\"" => "", "\\'" => ""));
} $cb1 = substr_count($tmp, "\\");
return $str; $cb2 = substr_count($tmp, "\\\\");
} if ($cd1 == $cd2 && $cs1 == $cs2 && $cb1 == 2 * $cb2) {
return strtr($str, array("\\\"" => "\"", "\\'" => "'", "\\\\" => "\\"));
public function SyntaxForForms($value,$rule,$maxlength="",$sqlcheckoff="") }
{ return $str;
return $value;//mysqli_real_escape_string($this->app->DB->connection,$value);//mysqli_real_escape_string($value); }
}
public function SyntaxForForms($value,$rule,$maxlength="",$sqlcheckoff="")
// check actual value with given rule {
public function Syntax($value,$rule,$maxlength='',$sqlcheckoff='') return $value;//mysqli_real_escape_string($this->app->DB->connection,$value);//mysqli_real_escape_string($value);
{ }
$striptags = false;
if(is_array($value)) // check actual value with given rule
{ public function Syntax($value,$rule,$maxlength='',$sqlcheckoff='')
if($sqlcheckoff != '') {
{ $striptags = false;
return $value; if(is_array($value))
} {
foreach($value as $k => $v) if($sqlcheckoff != '')
{ {
if(is_array($v)) return $value;
{ }
$value[$k] = $v; foreach($value as $k => $v)
}else{ {
$v = str_replace("\xef\xbb\xbf","NONBLOCKINGZERO",$v); if(is_array($v))
if($striptags){ {
$v = $this->stripallslashes($v); $value[$k] = $v;
$v = $this->smartstripslashes($v); }else{
$v = $this->app->erp->superentities($v); $v = str_replace("\xef\xbb\xbf","NONBLOCKINGZERO",$v);
} if($striptags){
$value[$k] = $this->app->DB->real_escape_string($v); $v = $this->stripallslashes($v);
} $v = $this->smartstripslashes($v);
} $v = $this->app->erp->superentities($v);
return $value; }
} $value[$k] = $this->app->DB->real_escape_string($v);
}
}
$value = str_replace("\xef\xbb\xbf","NONBLOCKINGZERO",$value); return $value;
}
if($striptags){
$value = $this->stripallslashes($value);
$value = $this->smartstripslashes($value); $value = str_replace("\xef\xbb\xbf","NONBLOCKINGZERO",$value);
$value = $this->app->erp->superentities($value); if($striptags){
} $value = $this->stripallslashes($value);
$value = $this->smartstripslashes($value);
if(!empty($this->app->stringcleaner)) {
if( $sqlcheckoff == '') { $value = $this->app->erp->superentities($value);
return $this->app->DB->real_escape_string($this->app->stringcleaner->CleanString($value, $rule)); }
}
return $this->app->stringcleaner->CleanString($value, $rule); if(!empty($this->app->stringcleaner)) {
} if( $sqlcheckoff == '') {
return $this->app->DB->real_escape_string($this->app->stringcleaner->CleanString($value, $rule));
if($rule === 'nohtml') { }
if( $sqlcheckoff == '') { return $this->app->stringcleaner->CleanString($value, $rule);
return $this->app->DB->real_escape_string(strip_tags($value)); }
}
if($rule === 'nohtml') {
return strip_tags($value); if( $sqlcheckoff == '') {
return $this->app->DB->real_escape_string(strip_tags($value));
} }
if($rule === 'nojs') {
if( $sqlcheckoff == '') { return strip_tags($value);
return $this->app->DB->real_escape_string($this->xss_clean($value));
} }
if($rule === 'nojs') {
return $this->xss_clean($value); if( $sqlcheckoff == '') {
} return $this->app->DB->real_escape_string($this->xss_clean($value));
}
if($rule=='' && $sqlcheckoff == '') {
return $this->app->DB->real_escape_string($value);//mysqli_real_escape_string($value); return $this->xss_clean($value);
} }
if($rule=='' && $sqlcheckoff != '') {
return $value; if($rule=='' && $sqlcheckoff == '') {
} return $this->app->DB->real_escape_string($value);//mysqli_real_escape_string($value);
}
// build complete regexp if($rule=='' && $sqlcheckoff != '') {
return $value;
// check if rule exists }
if($this->GetRegexp($rule)!=''){ // build complete regexp
//$v = '/^['.$this->GetRegexp($rule).']+$/';
$v = $this->GetRegexp($rule); // check if rule exists
if (preg_match_all('/'.$v.'/i', $value, $teffer) ) {
if($sqlcheckoff==''){ if($this->GetRegexp($rule)!=''){
return $this->app->DB->real_escape_string($value);//mysqli_real_escape_string($value); //$v = '/^['.$this->GetRegexp($rule).']+$/';
} $v = $this->GetRegexp($rule);
if (preg_match_all('/'.$v.'/i', $value, $teffer) ) {
return $value; if($sqlcheckoff==''){
} return $this->app->DB->real_escape_string($value);//mysqli_real_escape_string($value);
return ''; }
}
return $value;
echo "<table border=\"1\" width=\"100%\" bgcolor=\"#FFB6C1\"> }
<tr><td>Rule <b>$rule</b> doesn't exists!</td></tr></table>"; return '';
return ''; }
}
echo "<table border=\"1\" width=\"100%\" bgcolor=\"#FFB6C1\">
<tr><td>Rule <b>$rule</b> doesn't exists!</td></tr></table>";
function RuleCheck($value,$rule) return '';
{ }
$found = false;
if(!empty($this->app->stringcleaner)) {
$value_ = $this->app->stringcleaner->RuleCheck($value, $rule, $found); function RuleCheck($value,$rule)
if($found) { {
if($value_) { $found = false;
return true; if(!empty($this->app->stringcleaner)) {
} $value_ = $this->app->stringcleaner->RuleCheck($value, $rule, $found);
return false; if($found) {
} if($value_) {
} return true;
}
$v = $this->GetRegexp($rule); return false;
if (preg_match_all('/'.$v.'/i', $value, $teffer) ){ }
return true; }
}
$v = $this->GetRegexp($rule);
return false; if (preg_match_all('/'.$v.'/i', $value, $teffer) ){
} return true;
}
function AddRule($name,$type,$rule)
{ return false;
// type: reg = regular expression }
// type: glue ( already exists rules copy to new e.g. number+digit)
$this->rules[$name]=array('type'=>$type,'rule'=>$rule); function AddRule($name,$type,$rule)
} {
// type: reg = regular expression
// get complete regexp by rule name // type: glue ( already exists rules copy to new e.g. number+digit)
function GetRegexp($rule) $this->rules[$name]=array('type'=>$type,'rule'=>$rule);
{ }
$rules = explode('+',$rule);
$ret = ''; // get complete regexp by rule name
foreach($rules as $key) { function GetRegexp($rule)
// check if rule is last in glue string {
if($this->rules[$key]['type']==='glue') { $rules = explode('+',$rule);
$subrules = explode('+',$this->rules[$key]['rule']); $ret = '';
if(count($subrules)>0) { foreach($rules as $key) {
foreach($subrules as $subkey) { // check if rule is last in glue string
$ret .= $this->GetRegexp($subkey); if($this->rules[$key]['type']==='glue') {
} $subrules = explode('+',$this->rules[$key]['rule']);
} if(count($subrules)>0) {
} foreach($subrules as $subkey) {
elseif($this->rules[$key]['type']==='reg') { $ret .= $this->GetRegexp($subkey);
$ret .= $this->rules[$key]['rule']; }
} }
} }
if($ret==''){ elseif($this->rules[$key]['type']==='reg') {
$ret = 'none'; $ret .= $this->rules[$key]['rule'];
} }
return $ret; }
} if($ret==''){
$ret = 'none';
} }
return $ret;
}
}
+6 -3
View File
@@ -1,16 +1,19 @@
Upgrade the OpenXE system. OpenXE upgrade system
NOTE: NOTE:
The upgrade system is for use in LINUX only and needs to have git installed. The upgrade system is for use in LINUX only and needs to have git installed.
The following steps are executed:
1. get files from git 1. get files from git
2. run database upgrade 2. run database upgrade
Files in this directory: Files in this directory:
UPGRADE.md -> This file UPGRADE.md -> This file
upgrade.php -> The upgrade program upgrade.sh -> The upgrade starter, execute with "./upgrade.sh". Execute without parameters to view possible options.
Files in the data subdirectory: Files in the data subdirectory:
.in_progress.flag -> if this file exists, an upgrade is in progress, system will be locked upgrade.php -> The upgrade program
db_schema.json -> Contains the nominal database structure db_schema.json -> Contains the nominal database structure
exported_db_schema.json -> Contains the exported database structure (optional)
remote.json -> Contains the git remote & branch which should be used for upgrade remote.json -> Contains the git remote & branch which should be used for upgrade
upgrade.log -> Contains the output from the last run that was started from within OpenXE
+3 -3
View File
@@ -114243,17 +114243,17 @@
{ {
"name": "belege", "name": "belege",
"type": "VIEW", "type": "VIEW",
"Create": "CREATE ALGORITHM=UNDEFINED DEFINER=`openxe`@`localhost` SQL SECURITY DEFINER VIEW `belege` AS select `rechnung`.`id` AS `id`,`rechnung`.`adresse` AS `adresse`,`rechnung`.`datum` AS `datum`,`rechnung`.`belegnr` AS `belegnr`,`rechnung`.`status` AS `status`,`rechnung`.`land` AS `land`,'rechnung' AS `typ`,`rechnung`.`umsatz_netto` AS `umsatz_netto`,`rechnung`.`erloes_netto` AS `erloes_netto`,`rechnung`.`deckungsbeitrag` AS `deckungsbeitrag`,`rechnung`.`provision_summe` AS `provision_summe`,`rechnung`.`vertriebid` AS `vertriebid`,`rechnung`.`gruppe` AS `gruppe` from `rechnung` where (`rechnung`.`status` <> 'angelegt') union all select `gutschrift`.`id` AS `id`,`gutschrift`.`adresse` AS `adresse`,`gutschrift`.`datum` AS `datum`,`gutschrift`.`belegnr` AS `belegnr`,`gutschrift`.`status` AS `status`,`gutschrift`.`land` AS `land`,'gutschrift' AS `typ`,(`gutschrift`.`umsatz_netto` * -(1)) AS `umsatz_netto*-1`,(`gutschrift`.`erloes_netto` * -(1)) AS `erloes_netto*-1`,(`gutschrift`.`deckungsbeitrag` * -(1)) AS `deckungsbeitrag*-1`,(`gutschrift`.`provision_summe` * -(1)) AS `provision_summe*-1`,`gutschrift`.`vertriebid` AS `vertriebid`,`gutschrift`.`gruppe` AS `gruppe` from `gutschrift` where (`gutschrift`.`status` <> 'angelegt')" "Create": "CREATE VIEW `belege` AS select `rechnung`.`id` AS `id`,`rechnung`.`adresse` AS `adresse`,`rechnung`.`datum` AS `datum`,`rechnung`.`belegnr` AS `belegnr`,`rechnung`.`status` AS `status`,`rechnung`.`land` AS `land`,'rechnung' AS `typ`,`rechnung`.`umsatz_netto` AS `umsatz_netto`,`rechnung`.`erloes_netto` AS `erloes_netto`,`rechnung`.`deckungsbeitrag` AS `deckungsbeitrag`,`rechnung`.`provision_summe` AS `provision_summe`,`rechnung`.`vertriebid` AS `vertriebid`,`rechnung`.`gruppe` AS `gruppe` from `rechnung` where `rechnung`.`status` <> 'angelegt' union all select `gutschrift`.`id` AS `id`,`gutschrift`.`adresse` AS `adresse`,`gutschrift`.`datum` AS `datum`,`gutschrift`.`belegnr` AS `belegnr`,`gutschrift`.`status` AS `status`,`gutschrift`.`land` AS `land`,'gutschrift' AS `typ`,`gutschrift`.`umsatz_netto` * -1 AS `umsatz_netto*-1`,`gutschrift`.`erloes_netto` * -1 AS `erloes_netto*-1`,`gutschrift`.`deckungsbeitrag` * -1 AS `deckungsbeitrag*-1`,`gutschrift`.`provision_summe` * -1 AS `provision_summe*-1`,`gutschrift`.`vertriebid` AS `vertriebid`,`gutschrift`.`gruppe` AS `gruppe` from `gutschrift` where `gutschrift`.`status` <> 'angelegt'"
}, },
{ {
"name": "belegegesamt", "name": "belegegesamt",
"type": "VIEW", "type": "VIEW",
"Create": "CREATE ALGORITHM=UNDEFINED DEFINER=`openxe`@`localhost` SQL SECURITY DEFINER VIEW `belegegesamt` AS select `rechnung`.`id` AS `id`,`rechnung`.`adresse` AS `adresse`,`rechnung`.`datum` AS `datum`,`rechnung`.`belegnr` AS `belegnr`,`rechnung`.`status` AS `status`,`rechnung`.`land` AS `land`,'rechnung' AS `typ`,`rechnung`.`umsatz_netto` AS `umsatz_netto`,`rechnung`.`soll` AS `umsatz_brutto`,`rechnung`.`erloes_netto` AS `erloes_netto`,`rechnung`.`deckungsbeitrag` AS `deckungsbeitrag`,`rechnung`.`provision_summe` AS `provision_summe`,`rechnung`.`vertriebid` AS `vertriebid`,`rechnung`.`gruppe` AS `gruppe`,`rechnung`.`projekt` AS `projekt` from `rechnung` union all select `gutschrift`.`id` AS `id`,`gutschrift`.`adresse` AS `adresse`,`gutschrift`.`datum` AS `datum`,`gutschrift`.`belegnr` AS `belegnr`,`gutschrift`.`status` AS `status`,`gutschrift`.`land` AS `land`,'gutschrift' AS `typ`,(`gutschrift`.`umsatz_netto` * -(1)) AS `umsatz_netto*-1`,(`gutschrift`.`soll` * -(1)) AS `umsatz_brutto*-1`,(`gutschrift`.`erloes_netto` * -(1)) AS `erloes_netto*-1`,(`gutschrift`.`deckungsbeitrag` * -(1)) AS `deckungsbeitrag*-1`,(`gutschrift`.`provision_summe` * -(1)) AS `provision_summe*-1`,`gutschrift`.`vertriebid` AS `vertriebid`,`gutschrift`.`gruppe` AS `gruppe`,`gutschrift`.`projekt` AS `projekt` from `gutschrift` union all select `auftrag`.`id` AS `id`,`auftrag`.`adresse` AS `adresse`,`auftrag`.`datum` AS `datum`,`auftrag`.`belegnr` AS `belegnr`,`auftrag`.`status` AS `status`,`auftrag`.`land` AS `land`,'auftrag' AS `typ`,`auftrag`.`umsatz_netto` AS `umsatz_netto`,`auftrag`.`gesamtsumme` AS `umsatz_brutto`,`auftrag`.`erloes_netto` AS `erloes_netto`,`auftrag`.`deckungsbeitrag` AS `deckungsbeitrag`,`auftrag`.`provision_summe` AS `provision_summe`,`auftrag`.`vertriebid` AS `vertriebid`,`auftrag`.`gruppe` AS `gruppe`,`auftrag`.`projekt` AS `projekt` from `auftrag` union all select `bestellung`.`id` AS `id`,`bestellung`.`adresse` AS `adresse`,`bestellung`.`datum` AS `datum`,`bestellung`.`belegnr` AS `belegnr`,`bestellung`.`status` AS `status`,`bestellung`.`land` AS `land`,'bestellung' AS `typ`,`bestellung`.`gesamtsumme` AS `umsatz_netto`,`bestellung`.`gesamtsumme` AS `umsatz_brutto`,'0' AS `erloes_netto`,'0' AS `deckungsbeitrag`,'0' AS `provision_summe`,'0' AS `vertriebid`,'0' AS `gruppe`,`bestellung`.`projekt` AS `projekt` from `bestellung` union all select `lieferschein`.`id` AS `id`,`lieferschein`.`adresse` AS `adresse`,`lieferschein`.`datum` AS `datum`,`lieferschein`.`belegnr` AS `belegnr`,`lieferschein`.`status` AS `status`,`lieferschein`.`land` AS `land`,'lieferschein' AS `typ`,'0' AS `umsatz_netto`,'0' AS `umsatz_brutto`,'0' AS `erloes_netto`,'0' AS `deckungsbeitrag`,'0' AS `provision_summe`,'0' AS `vertriebid`,'0' AS `gruppe`,`lieferschein`.`projekt` AS `projekt` from `lieferschein` union all select `angebot`.`id` AS `id`,`angebot`.`adresse` AS `adresse`,`angebot`.`datum` AS `datum`,`angebot`.`belegnr` AS `belegnr`,`angebot`.`status` AS `status`,`angebot`.`land` AS `land`,'angebot' AS `typ`,`angebot`.`umsatz_netto` AS `umsatz_netto`,`angebot`.`gesamtsumme` AS `umsatz_brutto`,'0' AS `erloes_netto`,`angebot`.`deckungsbeitrag` AS `deckungsbeitrag`,'0' AS `provision_summe`,`angebot`.`vertriebid` AS `vertriebid`,'0' AS `gruppe`,`angebot`.`projekt` AS `projekt` from `angebot`" "Create": "CREATE VIEW `belegegesamt` AS select `rechnung`.`id` AS `id`,`rechnung`.`adresse` AS `adresse`,`rechnung`.`datum` AS `datum`,`rechnung`.`belegnr` AS `belegnr`,`rechnung`.`status` AS `status`,`rechnung`.`land` AS `land`,'rechnung' AS `typ`,`rechnung`.`umsatz_netto` AS `umsatz_netto`,`rechnung`.`soll` AS `umsatz_brutto`,`rechnung`.`erloes_netto` AS `erloes_netto`,`rechnung`.`deckungsbeitrag` AS `deckungsbeitrag`,`rechnung`.`provision_summe` AS `provision_summe`,`rechnung`.`vertriebid` AS `vertriebid`,`rechnung`.`gruppe` AS `gruppe`,`rechnung`.`projekt` AS `projekt` from `rechnung` union all select `gutschrift`.`id` AS `id`,`gutschrift`.`adresse` AS `adresse`,`gutschrift`.`datum` AS `datum`,`gutschrift`.`belegnr` AS `belegnr`,`gutschrift`.`status` AS `status`,`gutschrift`.`land` AS `land`,'gutschrift' AS `typ`,`gutschrift`.`umsatz_netto` * -1 AS `umsatz_netto*-1`,`gutschrift`.`soll` * -1 AS `umsatz_brutto*-1`,`gutschrift`.`erloes_netto` * -1 AS `erloes_netto*-1`,`gutschrift`.`deckungsbeitrag` * -1 AS `deckungsbeitrag*-1`,`gutschrift`.`provision_summe` * -1 AS `provision_summe*-1`,`gutschrift`.`vertriebid` AS `vertriebid`,`gutschrift`.`gruppe` AS `gruppe`,`gutschrift`.`projekt` AS `projekt` from `gutschrift` union all select `auftrag`.`id` AS `id`,`auftrag`.`adresse` AS `adresse`,`auftrag`.`datum` AS `datum`,`auftrag`.`belegnr` AS `belegnr`,`auftrag`.`status` AS `status`,`auftrag`.`land` AS `land`,'auftrag' AS `typ`,`auftrag`.`umsatz_netto` AS `umsatz_netto`,`auftrag`.`gesamtsumme` AS `umsatz_brutto`,`auftrag`.`erloes_netto` AS `erloes_netto`,`auftrag`.`deckungsbeitrag` AS `deckungsbeitrag`,`auftrag`.`provision_summe` AS `provision_summe`,`auftrag`.`vertriebid` AS `vertriebid`,`auftrag`.`gruppe` AS `gruppe`,`auftrag`.`projekt` AS `projekt` from `auftrag` union all select `bestellung`.`id` AS `id`,`bestellung`.`adresse` AS `adresse`,`bestellung`.`datum` AS `datum`,`bestellung`.`belegnr` AS `belegnr`,`bestellung`.`status` AS `status`,`bestellung`.`land` AS `land`,'bestellung' AS `typ`,`bestellung`.`gesamtsumme` AS `umsatz_netto`,`bestellung`.`gesamtsumme` AS `umsatz_brutto`,'0' AS `erloes_netto`,'0' AS `deckungsbeitrag`,'0' AS `provision_summe`,'0' AS `vertriebid`,'0' AS `gruppe`,`bestellung`.`projekt` AS `projekt` from `bestellung` union all select `lieferschein`.`id` AS `id`,`lieferschein`.`adresse` AS `adresse`,`lieferschein`.`datum` AS `datum`,`lieferschein`.`belegnr` AS `belegnr`,`lieferschein`.`status` AS `status`,`lieferschein`.`land` AS `land`,'lieferschein' AS `typ`,'0' AS `umsatz_netto`,'0' AS `umsatz_brutto`,'0' AS `erloes_netto`,'0' AS `deckungsbeitrag`,'0' AS `provision_summe`,'0' AS `vertriebid`,'0' AS `gruppe`,`lieferschein`.`projekt` AS `projekt` from `lieferschein` union all select `angebot`.`id` AS `id`,`angebot`.`adresse` AS `adresse`,`angebot`.`datum` AS `datum`,`angebot`.`belegnr` AS `belegnr`,`angebot`.`status` AS `status`,`angebot`.`land` AS `land`,'angebot' AS `typ`,`angebot`.`umsatz_netto` AS `umsatz_netto`,`angebot`.`gesamtsumme` AS `umsatz_brutto`,'0' AS `erloes_netto`,`angebot`.`deckungsbeitrag` AS `deckungsbeitrag`,'0' AS `provision_summe`,`angebot`.`vertriebid` AS `vertriebid`,'0' AS `gruppe`,`angebot`.`projekt` AS `projekt` from `angebot`"
}, },
{ {
"name": "belegeregs", "name": "belegeregs",
"type": "VIEW", "type": "VIEW",
"Create": "CREATE ALGORITHM=UNDEFINED DEFINER=`openxe`@`localhost` SQL SECURITY DEFINER VIEW `belegeregs` AS select `rechnung`.`id` AS `id`,`rechnung`.`adresse` AS `adresse`,`rechnung`.`datum` AS `datum`,`rechnung`.`belegnr` AS `belegnr`,`rechnung`.`status` AS `status`,`rechnung`.`land` AS `land`,'rechnung' AS `typ`,`rechnung`.`umsatz_netto` AS `umsatz_netto`,`rechnung`.`erloes_netto` AS `erloes_netto`,`rechnung`.`deckungsbeitrag` AS `deckungsbeitrag`,`rechnung`.`provision_summe` AS `provision_summe`,`rechnung`.`vertriebid` AS `vertriebid`,`rechnung`.`gruppe` AS `gruppe`,`rechnung`.`projekt` AS `projekt` from `rechnung` union all select `gutschrift`.`id` AS `id`,`gutschrift`.`adresse` AS `adresse`,`gutschrift`.`datum` AS `datum`,`gutschrift`.`belegnr` AS `belegnr`,`gutschrift`.`status` AS `status`,`gutschrift`.`land` AS `land`,'gutschrift' AS `typ`,(`gutschrift`.`umsatz_netto` * -(1)) AS `umsatz_netto*-1`,(`gutschrift`.`erloes_netto` * -(1)) AS `erloes_netto*-1`,(`gutschrift`.`deckungsbeitrag` * -(1)) AS `deckungsbeitrag*-1`,(`gutschrift`.`provision_summe` * -(1)) AS `provision_summe*-1`,`gutschrift`.`vertriebid` AS `vertriebid`,`gutschrift`.`gruppe` AS `gruppe`,`gutschrift`.`projekt` AS `projekt` from `gutschrift`" "Create": "CREATE VIEW `belegeregs` AS select `rechnung`.`id` AS `id`,`rechnung`.`adresse` AS `adresse`,`rechnung`.`datum` AS `datum`,`rechnung`.`belegnr` AS `belegnr`,`rechnung`.`status` AS `status`,`rechnung`.`land` AS `land`,'rechnung' AS `typ`,`rechnung`.`umsatz_netto` AS `umsatz_netto`,`rechnung`.`erloes_netto` AS `erloes_netto`,`rechnung`.`deckungsbeitrag` AS `deckungsbeitrag`,`rechnung`.`provision_summe` AS `provision_summe`,`rechnung`.`vertriebid` AS `vertriebid`,`rechnung`.`gruppe` AS `gruppe`,`rechnung`.`projekt` AS `projekt` from `rechnung` union all select `gutschrift`.`id` AS `id`,`gutschrift`.`adresse` AS `adresse`,`gutschrift`.`datum` AS `datum`,`gutschrift`.`belegnr` AS `belegnr`,`gutschrift`.`status` AS `status`,`gutschrift`.`land` AS `land`,'gutschrift' AS `typ`,`gutschrift`.`umsatz_netto` * -1 AS `umsatz_netto*-1`,`gutschrift`.`erloes_netto` * -1 AS `erloes_netto*-1`,`gutschrift`.`deckungsbeitrag` * -1 AS `deckungsbeitrag*-1`,`gutschrift`.`provision_summe` * -1 AS `provision_summe*-1`,`gutschrift`.`vertriebid` AS `vertriebid`,`gutschrift`.`gruppe` AS `gruppe`,`gutschrift`.`projekt` AS `projekt` from `gutschrift`"
} }
] ]
} }
@@ -48,25 +48,22 @@ function git(string $command, &$output, bool $show_command, bool $show_output, s
echo_output($output); echo_output($output);
} }
} }
if ($retval != 0) {
echo_out($error_text."\n");
}
return($retval); return($retval);
} }
// -------------------------------- START // -------------------------------- START
// Check for correct call method // Check for correct call method
$directory = "";
if (php_sapi_name() == "cli") { if (php_sapi_name() == "cli") {
$cli = true;
$directory = "."; $directory = getcwd();
} else if (basename(getcwd()) != 'upgrade') { if (basename($directory) != 'upgrade') {
// Started from "www" abort("Must be executed from 'upgrade' directory.");
$directory = "../upgrade"; return(-1);
} else { }
abort("Must be executed from 'upgrade' directory.");
return(-1);
}
if ($cli) {
$check_git = false; $check_git = false;
$do_git = false; $do_git = false;
@@ -94,6 +91,12 @@ if ($cli) {
$force = false; $force = false;
} }
if (in_array('-o', $argv)) {
$origin = true;
} else {
$origin = false;
}
if (in_array('-connection', $argv)) { if (in_array('-connection', $argv)) {
$connection = true; $connection = true;
} else { } else {
@@ -124,7 +127,7 @@ if ($cli) {
} }
if ($check_git || $check_db || $do_git || $do_db) { if ($check_git || $check_db || $do_git || $do_db) {
upgrade_main($directory,$verbose,$check_git,$do_git,$export_db,$check_db,$do_db,$force,$connection); upgrade_main($directory,$verbose,$check_git,$do_git,$export_db,$check_db,$do_db,$force,$connection,$origin);
} else { } else {
info(); info();
} }
@@ -136,40 +139,9 @@ if ($cli) {
} }
// -------------------------------- END // -------------------------------- END
function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force, bool $connection) { function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force, bool $connection, bool $origin) {
if ($connection) { $mainfolder = dirname($directory);
$connection_file_name = $directory."/data/connection.json";
$connection_file_contents = file_get_contents($connection_file_name);
if (!$connection_file_contents) {
abort("Unable to load $connection_file_name");
return(-1);
}
$connection_info = json_decode($connection_file_contents, true);
$host = $connection_info['host'];
$user = $connection_info['user'];
$passwd = $connection_info['passwd'];
$schema = $connection_info['schema'];
} else {
class DatabaseConnectionInfo {
function __construct($dir) {
require($dir."/../conf/user.inc.php");
}
}
$dbci = new DatabaseConnectionInfo($directory);
$host = $dbci->WFdbhost;
$user = $dbci->WFdbuser;
$passwd = $dbci->WFdbpass;
$schema = $dbci->WFdbname;
}
require_once($directory.'/../vendor/mustal/mustal_mysql_upgrade_tool.php');
$datafolder = $directory."/data"; $datafolder = $directory."/data";
$lockfile_name = $datafolder."/.in_progress.flag"; $lockfile_name = $datafolder."/.in_progress.flag";
$remote_file_name = $datafolder."/remote.json"; $remote_file_name = $datafolder."/remote.json";
@@ -180,34 +152,34 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
//require_once($directory.'/../cronjobs/githash.php'); //require_once($directory.'/../cronjobs/githash.php');
$remote_info_contents = file_get_contents($remote_file_name); if ($origin) {
if (!$remote_info_contents) { $remote_info = array('host' => 'origin','branch' => 'master');
abort("Unable to load $remote_file_name"); } else {
return(-1); $remote_info_contents = file_get_contents($remote_file_name);
} if (!$remote_info_contents) {
$remote_info = json_decode($remote_info_contents, true); abort("Unable to load $remote_file_name");
return(-1);
$modified_files = false; }
$remote_info = json_decode($remote_info_contents, true);
}
if ($check_git || $do_git) { if ($check_git || $do_git) {
// Get changed files on system -> Should be empty
$output = array();
$retval = git("ls-files -m ..", $output,$verbose,false,"Git not initialized.");
if (!empty($output)) {
$modified_files = true;
echo_out("There are modified files:\n");
echo_output($output);
}
$retval = git("log HEAD --", $output,$verbose,false,"");
// Not a git repository -> Create it and then go ahead // Not a git repository -> Create it and then go ahead
if ($retval == 128) { if ($retval == 128) {
if (!$do_git) {
abort("Git not initialized, use -do to initialize.");
return(-1);
}
echo_out("Setting up git..."); echo_out("Setting up git...");
$retval = git("init ..", $output,$verbose,$verbose,"Error while initializing git!"); $retval = git("init $mainfolder", $output,$verbose,$verbose,"Error while initializing git!");
if ($retval != 0) { if ($retval != 0) {
abort(""); abort("");
return(-1); return(-1);
} }
$retval = git("add ../.", $output,$verbose,$verbose,"Error while initializing git!"); $retval = git("add $mainfolder", $output,$verbose,$verbose,"Error while initializing git!");
if ($retval != 0) { if ($retval != 0) {
abort(""); abort("");
return(-1); return(-1);
@@ -218,7 +190,7 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
return(-1); return(-1);
} }
$retval = git("checkout FETCH_HEAD -f", $output,$verbose,$verbose,"Error while initializing git!"); $retval = git("checkout FETCH_HEAD -f --", $output,$verbose,$verbose,"Error while initializing git!");
if ($retval != 0) { if ($retval != 0) {
abort(""); abort("");
return(-1); return(-1);
@@ -227,17 +199,27 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
abort("Error while executing git!"); abort("Error while executing git!");
return(-1); return(-1);
} }
// Get changed files on system -> Should be empty
$modified_files = false;
$output = array();
$retval = git("ls-files -m $mainfolder", $output,$verbose,false,"Error while checking Git status.");
if (!empty($output)) {
$modified_files = true;
echo_out("There are modified files:\n");
echo_output($output);
}
if ($verbose) { if ($verbose) {
echo_out("--------------- Upgrade history ---------------\n"); echo_out("--------------- Upgrade history ---------------\n");
$retval = git("log --date=short-local --pretty=\"%cd (%h): %s\" HEAD --not HEAD~5",$output,$verbose,$verbose,"Error while showing history!"); $retval = git("log --date=short-local --pretty=\"%cd (%h): %s\" HEAD --not HEAD~5 --",$output,$verbose,$verbose,"Error while showing history!");
if ($retval != 0) { if ($retval != 0) {
abort(""); abort("");
return(-1); return(-1);
} }
} else { } else {
echo_out("--------------- Current version ---------------\n"); echo_out("--------------- Current version ---------------\n");
$retval = git("log -1 --date=short-local --pretty=\"%cd (%h): %s\" HEAD",$output,$verbose,true,"Error while showing history!"); $retval = git("log -1 --date=short-local --pretty=\"%cd (%h): %s\" HEAD --",$output,$verbose,true,"Error while showing history!");
if ($retval != 0) { if ($retval != 0) {
return(-1); return(-1);
} }
@@ -302,6 +284,39 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
} // $check_git } // $check_git
if ($check_db || $do_db || $export_db) { if ($check_db || $do_db || $export_db) {
if ($connection) {
$connection_file_name = $directory."/data/connection.json";
$connection_file_contents = file_get_contents($connection_file_name);
if (!$connection_file_contents) {
abort("Unable to load $connection_file_name");
return(-1);
}
$connection_info = json_decode($connection_file_contents, true);
$host = $connection_info['host'];
$user = $connection_info['user'];
$passwd = $connection_info['passwd'];
$schema = $connection_info['schema'];
} else {
class DatabaseConnectionInfo {
function __construct($dir) {
require($dir."/../conf/user.inc.php");
}
}
$dbci = new DatabaseConnectionInfo($directory);
$host = $dbci->WFdbhost;
$user = $dbci->WFdbuser;
$passwd = $dbci->WFdbpass;
$schema = $dbci->WFdbname;
}
require_once($directory.'/../vendor/mustal/mustal_mysql_upgrade_tool.php');
echo_out("--------------- Loading from database '$schema@$host'... ---------------\n"); echo_out("--------------- Loading from database '$schema@$host'... ---------------\n");
$db_def = mustal_load_tables_from_db($host, $schema, $user, $passwd, $mustal_replacers); $db_def = mustal_load_tables_from_db($host, $schema, $user, $passwd, $mustal_replacers);
@@ -458,6 +473,7 @@ function info() {
echo_out("\t-do: execute all upgrades\n"); echo_out("\t-do: execute all upgrades\n");
echo_out("\t-v: verbose output\n"); echo_out("\t-v: verbose output\n");
echo_out("\t-f: force override of existing files\n"); echo_out("\t-f: force override of existing files\n");
echo_out("\t-o: update from origin instead of remote.json\n");
echo_out("\t-connection use connection.json in data folder instead of user.inc.php\n"); echo_out("\t-connection use connection.json in data folder instead of user.inc.php\n");
echo_out("\t-clean: (not yet implemented) create the needed SQL to remove items from the database not in the JSON\n"); echo_out("\t-clean: (not yet implemented) create the needed SQL to remove items from the database not in the JSON\n");
echo_out("\n"); echo_out("\n");
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
sudo -u www-data php data/upgrade.php "$@"
+4 -2
View File
@@ -68,7 +68,7 @@ $mustal_replacers = [
]; ];
// Load all db_def from a DB connection into a db_def array // Load all db_def from a DB connection into a db_def array
function mustal_load_tables_from_db(string $host, string $schema, string $user, string $passwd, $replacers) : array { function mustal_load_tables_from_db(string $host, string $schema, string $user, string $passwd, array $replacers) : array {
// First get the contents of the database table structure // First get the contents of the database table structure
$mysqli = mysqli_connect($host, $user, $passwd, $schema); $mysqli = mysqli_connect($host, $user, $passwd, $schema);
@@ -167,7 +167,9 @@ function mustal_load_tables_from_db(string $host, string $schema, string $user,
return(array()); return(array());
} }
$viewdef = mysqli_fetch_assoc($query_result); $viewdef = mysqli_fetch_assoc($query_result);
$view['Create'] = $viewdef['Create View'];
// Remove the security info from view definition
$view['Create'] = "CREATE ".stristr($viewdef['Create View'],"VIEW");
} }
$result = array(); $result = array();
+1 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
$version="OSS"; $version="OSS";
$version_revision="1.6"; $version_revision="1.7";
$githash = file_get_contents("../githash.txt"); $githash = file_get_contents("../githash.txt");
if (!empty($githash)) { if (!empty($githash)) {
$version_revision .= " (".substr($githash,0,8).")"; $version_revision .= " (".substr($githash,0,8).")";
+10
View File
@@ -13,4 +13,14 @@ Allow from all
Order Allow,Deny Order Allow,Deny
Allow from all Allow from all
</Files> </Files>
# Allow access to setup.php
<Files setup.php>
Order Allow,Deny
Allow from all
</Files>
# Allow access to inline PDF viewer
<Files viewer.html>
Order Allow,Deny
Allow from all
</Files>
# end # end
+181 -5
View File
@@ -40,6 +40,7 @@ class Auftrag extends GenAuftrag
*/ */
public function TableSearch($app, $name, $erlaubtevars) public function TableSearch($app, $name, $erlaubtevars)
{ {
switch($name) switch($name)
{ {
case 'auftraege': case 'auftraege':
@@ -711,6 +712,55 @@ class Auftrag extends GenAuftrag
break; break;
case 'positionen_teillieferung':
$id = $app->Secure->GetGET('id');
$allowed['positionen_teillieferung'] = array('list');
$heading = array('Position','Artikel','Nr.','Menge','Lager','Teilmenge','');
$width = array( '1%', '60%', '29%','5%','5%'); // Fill out manually later
// columns that are aligned right (numbers etc)
// $alignright = array(4,5,6,7,8);
$findcols = array('ap.sort','a.name_de','a.nummer','ap.menge','lager','teilmenge');
$searchsql = array('');
$defaultorder = 2;
$defaultorderdesc = 0;
$input_for_menge = "CONCAT(
'<input type = \"number\" min=\"0\" max=\"',
ap.menge,
'\" name=\"teilmenge_',
ap.id,
'\"',
' value=\"',
'\">',
'</input>'
)";
// .'(SELECT TRIM(IFNULL(SUM(l.menge),0))+0 FROM lager_platz_inhalt l WHERE l.artikel=a.id) as lager'
$sql = "SELECT SQL_CALC_FOUND_ROWS
ap.sort,
ap.sort,
a.name_de,
a.nummer,"
.$this->app->erp->FormatMenge('ap.menge').","
."(SELECT TRIM(IFNULL(SUM(l.menge),0))+0 FROM lager_platz_inhalt l WHERE l.artikel=a.id) as lager,"
.$input_for_menge
." FROM auftrag_position ap
INNER JOIN
artikel a
ON ap.artikel = a.id";
$where = " ap.auftrag = $id ";
$count = "SELECT count(DISTINCT ap.id) FROM auftrag_position ap WHERE $where";
// $groupby = "";
break;
} }
$erg = []; $erg = [];
@@ -765,7 +815,7 @@ class Auftrag extends GenAuftrag
$this->app->ActionHandler("rechnung","AuftragRechnung"); $this->app->ActionHandler("rechnung","AuftragRechnung");
$this->app->ActionHandler("lieferschein","AuftragLieferschein"); $this->app->ActionHandler("lieferschein","AuftragLieferschein");
$this->app->ActionHandler("lieferscheinrechnung","AuftragLieferscheinRechnung"); $this->app->ActionHandler("lieferscheinrechnung","AuftragLieferscheinRechnung");
$this->app->ActionHandler("teillieferung","AuftragTeillieferung");
$this->app->ActionHandler("nachlieferung","AuftragNachlieferung"); $this->app->ActionHandler("nachlieferung","AuftragNachlieferung");
// $this->app->ActionHandler("versand","AuftragVersand"); // $this->app->ActionHandler("versand","AuftragVersand");
$this->app->ActionHandler("freigabe","AuftragFreigabe"); $this->app->ActionHandler("freigabe","AuftragFreigabe");
@@ -1271,7 +1321,11 @@ class Auftrag extends GenAuftrag
$kommissionierart = $this->app->DB->Select("SELECT kommissionierverfahren FROM projekt WHERE id='$projekt' LIMIT 1"); $kommissionierart = $this->app->DB->Select("SELECT kommissionierverfahren FROM projekt WHERE id='$projekt' LIMIT 1");
//$art = $this->app->DB->Select("SELECT art FROM auftrag WHERE id='$id' LIMIT 1"); //$art = $this->app->DB->Select("SELECT art FROM auftrag WHERE id='$id' LIMIT 1");
$alleartikelreservieren = ''; $alleartikelreservieren = '';
$teillieferungen = '';
if ($status==='angelegt' || $status==='freigegeben') {
$teillieferungen = '<option value="teillieferung">Teilauftrag erstellen</option>';
}
if($status==='freigegeben') { if($status==='freigegeben') {
$alleartikelreservieren = "<option value=\"reservieren\">alle Artikel reservieren</option>"; $alleartikelreservieren = "<option value=\"reservieren\">alle Artikel reservieren</option>";
@@ -1369,9 +1423,14 @@ class Auftrag extends GenAuftrag
{ {
switch(cmd) switch(cmd)
{ {
case 'storno': if(!confirm('Wirklich stornieren?')) return document.getElementById('aktion$prefix').selectedIndex = 0; else window.location.href='index.php?module=auftrag&action=delete&id=%value%'; break; case 'storno':
case 'unstorno': if(!confirm('Wirklich stornierten Auftrag wieder freigeben?')) return document.getElementById('aktion$prefix').selectedIndex = 0; else window.location.href='index.php?module=auftrag&action=undelete&id=%value%'; break; if(!confirm('Wirklich stornieren?')) return document.getElementById('aktion$prefix').selectedIndex = 0; else window.location.href='index.php?module=auftrag&action=delete&id=%value%'; break;
case 'teillieferung': window.location.href='index.php?module=auftrag&action=teillieferung&id=%value%'; break; case 'unstorno':
if(!confirm('Wirklich stornierten Auftrag wieder freigeben?')) return document.getElementById('aktion$prefix').selectedIndex = 0; else window.location.href='index.php?module=auftrag&action=undelete&id=%value%';
break;
case 'teillieferung':
window.location.href='index.php?module=auftrag&action=teillieferung&id=%value%';
break;
case 'anfrage': if(!confirm('Wirklich rückführen?')) return document.getElementById('aktion$prefix').selectedIndex = 0; else window.location.href='index.php?module=auftrag&action=anfrage&id=%value%'; break; case 'anfrage': if(!confirm('Wirklich rückführen?')) return document.getElementById('aktion$prefix').selectedIndex = 0; else window.location.href='index.php?module=auftrag&action=anfrage&id=%value%'; break;
case 'kreditlimit': if(!confirm('Wirklich Kreditlimit für diesen Auftrag freigeben?')) return document.getElementById('aktion$prefix').selectedIndex = 0; else window.location.href='index.php?module=auftrag&action=kreditlimit&id=%value%'; break; case 'kreditlimit': if(!confirm('Wirklich Kreditlimit für diesen Auftrag freigeben?')) return document.getElementById('aktion$prefix').selectedIndex = 0; else window.location.href='index.php?module=auftrag&action=kreditlimit&id=%value%'; break;
case 'copy': if(!confirm('Wirklich kopieren?')) return document.getElementById('aktion$prefix').selectedIndex = 0; else window.location.href='index.php?module=auftrag&action=copy&id=%value%'; break; case 'copy': if(!confirm('Wirklich kopieren?')) return document.getElementById('aktion$prefix').selectedIndex = 0; else window.location.href='index.php?module=auftrag&action=copy&id=%value%'; break;
@@ -7004,4 +7063,121 @@ Die Gesamtsumme stimmt nicht mehr mit urspr&uuml;nglich festgelegten Betrag '.
header('Location: index.php?module=auftrag&action=versandzentrum'); header('Location: index.php?module=auftrag&action=versandzentrum');
} }
/*
* Split auftrag into separate documents with submit -> do it and return jump to the new split part
*/
function AuftragTeillieferung() {
$id = $this->app->Secure->GetGET('id');
$this->AuftragMenu();
$submit = $this->app->Secure->GetPOST('submit');
$sql = "SELECT * from auftrag WHERE id = $id";
$auftrag_alt = $this->app->DB->SelectArr($sql)[0];
$msg = "";
if (in_array($auftrag_alt['status'],array('angelegt','freigegeben'))) {
if ($submit != '') {
$msg = "";
switch ($submit) {
case 'speichern':
// Get parameters
$teilmenge_input = $this->app->Secure->GetPOSTArray();
$teilmengen = array();
foreach ($teilmenge_input as $key => $value) {
if ((strpos($key,'teilmenge_') === 0) && ($value !== '')) {
$posid = substr($key,'10');
$teilmenge = array('posid' => $posid, 'menge' => $value);
$teilmengen[] = $teilmenge;
}
}
if (!empty($teilmengen)) {
// Create new auftrag
$sql = "SELECT * from auftrag WHERE id = $id";
$auftrag_alt = $this->app->DB->SelectArr($sql)[0];
// Part auftrag of part auftrag -> select parent
$hauptauftrag_id = $auftrag_alt['teillieferungvon'];
if ($hauptauftrag_id != 0) {
$sql = "SELECT belegnr FROM auftrag WHERE id = $hauptauftrag_id";
$hauptauftrag_belegnr = $this->app->DB->SelectArr($sql)[0]['belegnr'];
} else {
$hauptauftrag_id = $auftrag_alt['id'];
$hauptauftrag_belegnr = $auftrag_alt['belegnr'];
}
$sql = "SELECT MAX(teillieferungnummer) as tpn FROM auftrag WHERE teillieferungvon = $hauptauftrag_id";
$teillieferungnummer = $this->app->DB->SelectArr($sql)[0]['tpn'];
if (empty($teillieferungnummer) || $teillieferungnummer == 0) {
$teillieferungnummer = '1';
} else {
$teillieferungnummer++;
}
$belegnr_neu = $hauptauftrag_belegnr."-".$teillieferungnummer;
$auftrag_neu = $auftrag_alt;
$auftrag_neu['id'] = null;
$auftrag_neu['belegnr'] = $belegnr_neu;
$auftrag_neu['teillieferungvon'] = $hauptauftrag_id;
$auftrag_neu['teillieferungnummer'] = $teillieferungnummer;
$id_neu = $this->app->DB->MysqlCopyRow('auftrag','id',$id);
$sql = "UPDATE auftrag SET belegnr = '$belegnr_neu', teillieferungvon = $hauptauftrag_id, teillieferungnummer = $teillieferungnummer WHERE id = $id_neu";
echo("---------------------------".$sql."<br>");
$this->app->DB->Update($sql);
// Adjust quantities
foreach ($teilmengen as $teilmenge) {
$sql = "SELECT menge FROM auftrag_position WHERE id = ".$teilmenge['posid'];
$menge_alt = $this->app->DB->SelectArr($sql)[0]['menge'];
$menge_neu = $teilmenge['menge'];
if ($menge_neu > $menge_alt) {
$menge_neu = $menge_alt;
}
$menge_reduziert = $menge_alt-$menge_neu;
$posid_alt = $teilmenge['posid'];
$posid_neu = $this->app->DB->MysqlCopyRow('auftrag_position','id',$posid_alt);
$sql = "UPDATE auftrag_position SET menge = $menge_reduziert WHERE id = $posid_alt";
echo("---------------------------".$sql."<br>");
$this->app->DB->Update($sql);
$sql = "UPDATE auftrag_position SET auftrag = $id_neu, menge = $menge_neu WHERE id = $posid_neu";
echo("---------------------------".$sql."<br>");
$this->app->DB->Update($sql);
}
}
break;
case 'abbrechen':
header('Location: index.php?module=auftrag&action=edit&id='.$id);
return;
break;
}
} // Submit
else {
$msg = "Teilauftrag: Auswahl der Artikel f&uuml;r den Teilauftrag.";
}
} // Status ok
else {
$msg = 'Teilauftrag in diesem Status nicht möglich.';
}
$this->app->Tpl->Add('INFOTEXT',$msg);
$this->app->YUI->TableSearch('TABLE','positionen_teillieferung', 'show','','',basename(__FILE__), __CLASS__);
$this->app->Tpl->Parse('PAGE','auftrag_teillieferung.tpl');
} // AuftragTeillieferung
} }
+29 -16
View File
@@ -1,22 +1,35 @@
<!-- gehort zu tabview -->
<div id="tabs"> <div id="tabs">
<ul> <ul>
<li><a href="#tabs-1">[TABTEXT]</a></li> <li><a href="#tabs-1">[TABTEXT]</a></li>
</ul> </ul>
<!-- ende gehort zu tabview --> <div id="tabs-1">
<div class="info">[INFOTEXT]</div>
<!-- erstes tab --> <br>
<div id="tabs-1"> <form action="" method="post">
<div class="info">Teillieferung: Auswahl der Artikel f&uuml;r eine Teillieferung. Bestimmen Sie welche Artikel als Teillieferung vorab versendet werden sollen,<br> [MESSAGE]
und wann die Rechnung versendet wird (bei aktueller oder n&auml;chster Lieferung).</div> <div class="row">
<br> <div class="row-height">
<form action="" method="post"> <div class="col-xs-14 col-md-12 col-md-height">
[MESSAGE] <div class="inside inside-full-height">
[TAB1] <fieldset>
[TAB1NEXT] [TABLE]
</form> </fieldset>
</div> </div>
</div>
<!-- tab view schließen --> <div class="col-xs-14 col-md-2 col-md-height">
<div class="inside inside-full-height">
<fieldset>
<table width="100%" border="0" class="mkTableFormular">
<legend>{|Aktionen|}</legend>
<tr><td><button name="submit" id="speichern" value="speichern" class="ui-button-icon" style="width:100%";>Teilauftrag erzeugen</button></td></tr>
<tr><td><button name="submit" id="abbrechen" value="abbrechen" class="ui-button-icon" style="width:100%";>Vorgang abbrechen</button></td></tr>
</table>
</fieldset>
</div>
</div>
</div>
</div>
</form>
</div>
</div> </div>
+19 -5
View File
@@ -10,6 +10,20 @@
--> -->
<div id="tabs-1"> <div id="tabs-1">
[MESSAGE] [MESSAGE]
<div class="row">
<div class="row-height">
<div class="col-xs-14 col-md-12 col-md-height">
<div class="inside inside-full-height">
<fieldset>
<legend>{|OpenXE Upgrade-System|}</legend>
Das Upgrade funktioniert in 2 Schritten: Dateien aktualisieren, Datenbank auffrischen. Wenn das Upgrade lange l&auml;uft, kann der Fortschritt in einem neuen Fenster mit "Anzeige auffrischen" angezeigt werden.<br><br>
Falls nach einem Abbruch oder schwerwiegenden Fehler kein Upgrade möglich ist, im Hauptordner den Ordner ".git" l&ouml;schen und das Upgrade in der Konsole erneut durchf&uuml;hren.
Dazu im Unterordner "upgrade" diesen Befehl starten: <pre>./upgrade.sh -do</pre>
</fieldset>
</div>
</div>
</div>
</div>
<form action="" method="post"> <form action="" method="post">
[FORMHANDLEREVENT] [FORMHANDLEREVENT]
<div class="row"> <div class="row">
@@ -53,12 +67,12 @@
<table width="100%" border="0" class="mkTableFormular"> <table width="100%" border="0" class="mkTableFormular">
<tr><td colspan=2><button name="submit" value="refresh" class="ui-button-icon" style="width:100%;">Anzeige auffrischen</button></td></tr> <tr><td colspan=2><button name="submit" value="refresh" class="ui-button-icon" style="width:100%;">Anzeige auffrischen</button></td></tr>
<tr><td colspan=2><button name="submit" value="check_upgrade" class="ui-button-icon" style="width:100%;">Upgrades pr&uuml;fen</button></td></tr> <tr><td colspan=2><button name="submit" value="check_upgrade" class="ui-button-icon" style="width:100%;">Upgrades pr&uuml;fen</button></td></tr>
<tr><td style="width:100%;">{|Upgrade-Details anzeigen|}:</td><td><input type="checkbox" name="details_anzeigen" value=1 size="20"></td></tr> <tr><td style="width:100%;">{|Upgrade-Details anzeigen|}:</td><td><input type="checkbox" name="details_anzeigen" value=1 [DETAILS_ANZEIGEN] size="20"></td></tr>
<tr [UPGRADE_VISIBLE]><td colspan=2><button name="submit" value="do_upgrade" class="ui-button-icon" style="width:100%;">UPGRADE</button></td></tr> <tr [UPGRADE_VISIBLE]><td colspan=2><button name="submit" formtarget="_blank" value="do_upgrade" class="ui-button-icon" style="width:100%;">UPGRADE</button></td></tr>
<tr [UPGRADE_VISIBLE]><td style="width:100%;">{|Erzwingen (-f)|}:</td><td><input type="checkbox" name="erzwingen" value=1 size="20"></td></tr> <tr [UPGRADE_VISIBLE]><td style="width:100%;">{|Erzwingen (-f)|}:</td><td><input type="checkbox" name="erzwingen" value=1 [ERZWINGEN] size="20"></td></tr>
<tr><td colspan=2><button name="submit" value="check_db" class="ui-button-icon" style="width:100%;">Datenbank pr&uuml;fen</button></td></tr> <tr><td colspan=2><button name="submit" value="check_db" class="ui-button-icon" style="width:100%;">Datenbank pr&uuml;fen</button></td></tr>
<tr><td style="width:100%;">{|Datenbank-Details anzeigen|}:</td><td><input type="checkbox" name="db_details_anzeigen" value=1 size="20"></td></tr> <tr><td style="width:100%;">{|Datenbank-Details anzeigen|}:</td><td><input type="checkbox" name="db_details_anzeigen" value=1 [DB_DETAILS_ANZEIGEN] size="20"></td></tr>
<tr [UPGRADE_DB_VISIBLE]><td colspan=2><button name="submit" value="do_db_upgrade" class="ui-button-icon" style="width:100%;">Datenbank UPGRADE</button></td></tr> <tr [UPGRADE_DB_VISIBLE]><td colspan=2><button name="submit" formtarget="_blank" value="do_db_upgrade" class="ui-button-icon" style="width:100%;">Datenbank UPGRADE</button></td></tr>
</table> </table>
</fieldset> </fieldset>
</div> </div>
+3 -3
View File
@@ -178,7 +178,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
{ {
$accessToken = $this->shopwareToken(); $accessToken = $this->shopwareToken();
$url = $this->ShopUrl; $url = $this->ShopUrl;
$url .= 'v2/' . $endpoint; $url .= $endpoint;
$ch = curl_init(); $ch = curl_init();
$headerInformation[] = 'Content-Type:application/json'; $headerInformation[] = 'Content-Type:application/json';
@@ -1430,7 +1430,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
]; ];
$this->shopwareRequest('POST', '_action/sync?_response=true', $mediaAssociationData); $this->shopwareRequest('POST', '_action/sync?_response=true', $mediaAssociationData);
$url = $this->ShopUrl . 'v2/_action/media/' . $mediaId . '/upload?extension=' . $extension . '&fileName=' . $filename; $url = $this->ShopUrl . '_action/media/' . $mediaId . '/upload?extension=' . $extension . '&fileName=' . $filename;
$ch = curl_init(); $ch = curl_init();
$setHeaders = [ $setHeaders = [
'Content-Type:image/' . $extension, 'Content-Type:image/' . $extension,
@@ -3480,7 +3480,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
$documentId = $documentData['documentId']; $documentId = $documentData['documentId'];
$accessToken = $this->shopwareToken(); $accessToken = $this->shopwareToken();
$url = $this->ShopUrl . 'v2/_action/document/' . $documentId . '/upload?_response=true&extension=pdf&fileName=' . $documentNumber; $url = $this->ShopUrl . '_action/document/' . $documentId . '/upload?_response=true&extension=pdf&fileName=' . $documentNumber;
$ch = curl_init(); $ch = curl_init();
$setHeaders = [ $setHeaders = [
+12 -6
View File
@@ -30,7 +30,10 @@ class upgrade {
$db_verbose = $this->app->Secure->GetPOST('db_details_anzeigen') === '1'; $db_verbose = $this->app->Secure->GetPOST('db_details_anzeigen') === '1';
$force = $this->app->Secure->GetPOST('erzwingen') === '1'; $force = $this->app->Secure->GetPOST('erzwingen') === '1';
include("../upgrade/upgrade.php"); $this->app->Tpl->Set('DETAILS_ANZEIGEN', $verbose?"checked":"");
$this->app->Tpl->Set('DB_DETAILS_ANZEIGEN', $db_verbose?"checked":"");
include("../upgrade/data/upgrade.php");
$logfile = "../upgrade/data/upgrade.log"; $logfile = "../upgrade/data/upgrade.log";
upgrade_set_out_file_name($logfile); upgrade_set_out_file_name($logfile);
@@ -38,27 +41,29 @@ class upgrade {
$this->app->Tpl->Set('UPGRADE_VISIBLE', "hidden"); $this->app->Tpl->Set('UPGRADE_VISIBLE', "hidden");
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "hidden"); $this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "hidden");
//function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force, bool $connection) //function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force, bool $connection, bool $origin) {
$directory = dirname(getcwd())."/upgrade";
switch ($submit) { switch ($submit) {
case 'check_upgrade': case 'check_upgrade':
$this->app->Tpl->Set('UPGRADE_VISIBLE', ""); $this->app->Tpl->Set('UPGRADE_VISIBLE', "");
unlink($logfile); unlink($logfile);
upgrade_main("../upgrade",$verbose,true,false,false,true,false,$force,false); upgrade_main($directory,$verbose,true,false,false,true,false,$force,false,false);
break; break;
case 'do_upgrade': case 'do_upgrade':
unlink($logfile); unlink($logfile);
upgrade_main("../upgrade",$verbose,true,true,false,true,true,$force,false); upgrade_main($directory,$verbose,true,true,false,true,true,$force,false,false);
break; break;
case 'check_db': case 'check_db':
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', ""); $this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "");
unlink($logfile); unlink($logfile);
upgrade_main("../upgrade",$db_verbose,false,false,false,true,false,$force,false); upgrade_main($directory,$db_verbose,false,false,false,true,false,$force,false,false);
break; break;
case 'do_db_upgrade': case 'do_db_upgrade':
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', ""); $this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "");
unlink($logfile); unlink($logfile);
upgrade_main("../upgrade",$db_verbose,false,false,false,true,true,$force,false); upgrade_main($directory,$db_verbose,false,false,false,true,true,$force,false,false);
break; break;
case 'refresh': case 'refresh':
break; break;
@@ -73,3 +78,4 @@ class upgrade {
} }