Merge branch 'develop'

This commit is contained in:
Xenomporio 2022-07-19 17:20:14 +02:00
commit 70e3289df5
12 changed files with 7385 additions and 6887 deletions

View File

@ -12,7 +12,7 @@
class Config
{
/** @var string */
public $updateHost = 'update.xentral.biz';
public $updateHost = 'removed.upgrade.host';
public function __construct()
{

View File

@ -0,0 +1,114 @@
<?php
/*
include(dirname(__FILE__)."/../conf/main.conf.php");
include(dirname(__FILE__)."/../phpwf/plugins/class.mysql.php");
include(dirname(__FILE__)."/../www/lib/imap.inc.php");
include(dirname(__FILE__)."/../www/lib/class.erpapi.php");
class app_t {
var $DB;
var $user;
}
*/
// ende debug
/*
$debugfile = "/var/www/html/Xenomporio/debug.txt";
function file_append($filename,$text) {
$oldtext = file_get_contents($filename);
file_put_contents($filename,$oldtext.$text);
}
file_put_contents($debugfile,"1");
*/
if(empty($app)){
$app = new app_t();
}
$DEBUG = 0;
if(empty($app->Conf)){
$conf = new Config();
$app->Conf = $conf;
}
if(empty($app->DB) || empty($app->DB->connection)){
$app->DB = new DB($app->Conf->WFdbhost, $app->Conf->WFdbname, $app->Conf->WFdbuser, $app->Conf->WFdbpass, null, $app->Conf->WFdbport);
}
if(empty($app->erp)){
if(class_exists('erpAPICustom')){
$erp = new erpAPICustom($app);
}else{
$erp = new erpAPI($app);
}
$app->erp = $erp;
}
$app->String = new WawiString();
if(class_exists('RemoteCustom'))
{
$app->remote = new RemoteCustom($app);
}else{
$app->remote = new Remote($app);
}
$app->Secure = new Secure($app);
$app->User = new User($app);
if(!defined('FPDF_FONTPATH'))
{
define('FPDF_FONTPATH',dirname(__DIR__) . '/www/lib/pdf/font/');
}
$cronjobname = 'autoversand_manuell';
$mutex = $app->DB->Select(
"SELECT MAX(`mutex`) FROM `prozessstarter` WHERE (`parameter` = '".$cronjobname."')"
);
if($mutex){
$app->DB->Update(
"UPDATE `prozessstarter`
SET `mutexcounter`=`mutexcounter`+1
WHERE `mutex` = 1 AND (`parameter` = '".$cronjobname."')"
);
file_append($debugfile,"MUTEX");
return;
}
$app->DB->Update(
"UPDATE `prozessstarter` SET `mutex`='1', `mutexcounter` = 0 WHERE (`parameter` = '".$cronjobname."')"
);
// START APPLICATION
$objAuftrag = $app->loadModule('auftrag');
if($objAuftrag == null || !method_exists($objAuftrag, 'AuftragVersand')) {
$app->erp->LogFile($cronjobname." failed. Error while loading module 'auftrag'.");
exit;
}
$pendingorders = $app->DB->SelectArr(
"SELECT id
FROM auftrag AS a
WHERE a.id!='' AND (a.belegnr!=0 OR a.belegnr!='')
AND a.status='freigegeben' AND a.cronjobkommissionierung > 0"
);
if (!is_null($pendingorders)) {
$processed_orders_num = 0;
foreach ($pendingorders as $pendingorder) {
/* Process each order */
if($objAuftrag->AuftragVersand($pendingorder['id'],true)) { // Ignore shipdate -> The order has been marked, send it
$processed_orders_num++;
} else {
}
// Limit to 10 per call
if ($processed_orders_num > 10) {
break;
}
}
}
// END APPLICATION
$app->DB->Update("UPDATE prozessstarter SET mutex = 0 , mutexcounter = 0, letzteausfuerhung = now() WHERE (parameter = '".$cronjobname."' ) AND aktiv = 1");

212
cronjobs/tickets.php Normal file
View File

@ -0,0 +1,212 @@
<?php
/*
* Fetch all mails for accounts with ticket function
* Create tickets or sort mails to existing tickets
*/
use Xentral\Components\Logger\Logger;
use Xentral\Components\MailClient\MailClientFactory;
use Xentral\Modules\SystemMailClient\MailClientConfigProvider;
use Xentral\Modules\SystemMailer\Service\EmailAccountGateway;
use Xentral\Modules\Ticket\Importer\TicketFormatter;
use Xentral\Modules\Ticket\Task\TicketImportHelperFactory;
$DEBUG = 0;
$debugfile = "/var/www/html/Xenomporio/debug.txt";
function file_append($filename,$text) {
$oldtext = file_get_contents($filename);
file_put_contents($filename,$oldtext.$text);
}
file_put_contents($debugfile,"0");
/** @var ApplicationCore $app */
$erp = $app->erp;
$conf = $app->Conf;
/** @var Logger $logger */
$logger = $app->Container->get('Logger');
$cronjobname = 'tickets';
/*
$mutex = $app->DB->Select(
"SELECT MAX(`mutex`) FROM `prozessstarter` WHERE (`parameter` = '".$cronjobname."')"
);
if($mutex){
$app->DB->Update(
"UPDATE `prozessstarter`
SET `mutexcounter`=`mutexcounter`+1
WHERE `mutex` = 1 AND (`parameter` = '".$cronjobname."')"
);
file_append($debugfile,"MUTEX");
return;
}
$app->DB->Update(
"UPDATE `prozessstarter` SET `mutex`='1', `mutexcounter` = 0 WHERE (`parameter` = '".$cronjobname."')"
);
*/
// get all email Accounts that have the ticket system active
/** @var EmailAccountGateway $accountGateway */
$accountGateway = $app->Container->get('EmailAccountGateway');
$accounts = $accountGateway->getAccountsWithTicketActive();
file_append($debugfile,"Accs:".count($accounts).";");
// only load services if there is at least one account to import (performance)
$ticketModule = null;
$factory = null;
$configProvider = null;
$formatHelper = null;
$importHelperFactory = null;
if(!empty($accounts)){
/** @var Ticket $ticketModule */
$ticketModule = $app->erp->LoadModul('ticket');
/** @var MailClientFactory $factory */
$factory = $app->Container->get('MailClientFactory');
/** @var MailClientConfigProvider $configProvider */
$configProvider = $app->Container->get('MailClientConfigProvider');
/** @var TicketFormatter $formatHelper */
$formatHelper = $app->Container->get('TicketFormatter');
/** @var TicketImportHelperFactory $importHelperFactory */
$importHelperFactory = $app->Container->get('TicketImportHelperFactory');
}
$totalEmailsImportCount = 0;
foreach ($accounts as $account) {
$logger->debug(
'Start imap ticket import for {email}',
['email' => $account->getEmailAddress(), 'account' => $account]
);
file_append($debugfile,"Account ".$account->getemailAddress());
// create mail client
try {
$mailConfig = $configProvider->createImapConfigFromAccount($account);
$mailClient = $factory->createImapClient($mailConfig);
} catch (Exception $e) {
$logger->error('Failed to create email client', ['error' => (string)$e, 'account' => $account]);
file_append($debugfile,"Failed 1");
continue;
}
file_append($debugfile,"Connect to ".."SSL: ".$configProvider->isSslEnabled()." auth ".getAuthType()."\n");
// connect mail client
try {
try {
$mailClient->connect();
file_append($debugfile,"Meh");
} catch (Exception $e) {
$logger->error('Error during imap connection', ['error' => (string)$e, 'account' => $account]);
file_append($debugfile,"Error ".(string)$e);
continue;
}
}
file_append($debugfile,"2");
// connet to INBOX folder
try {
$mailClient->selectFolder('INBOX');
} catch (Exception $e) {
$logger->error('Failed to select INBOX folder', ['error' => (string)$e, 'account' => $account]);
file_append($debugfile,"Failed 2");
continue;
}
$projectId = $account->getProjectId() > 0 ? $account->getProjectId() : 1;
$delete_msg = 0;
$daysold = $account->getBackupDeleteAfterDays();
// determine search criteria for new messages
$datet = '2012-12-24';
if ($account->getImportStartDateAsString() !== '0000-00-00') {
$datesince = date('d-M-Y', strtotime($account->getImportStartDateAsString()));
$criteria = 'UNSEEN SINCE ' . $datesince;
} else {
$criteria = 'UNSEEN';
}
file_append($debugfile,"3");
// search new messages
try {
$searchResult = $mailClient->searchMessages($criteria);
} catch (Exception $e) {
$logger->error('Error during imap search', ['exception' => $e]);
file_append($debugfile,"Failed 3");
continue;
}
$logger->debug('unread emails to import: {message_count}', ['message_count' => count($searchResult)]);
// set mutex if there is more than 5 emails to import
if (count($searchResult) > 5) {
$app->DB->Update(
"UPDATE `prozessstarter`
SET `mutex`=1, `mutexcounter` = 0, `letzteausfuerhung` = NOW()
WHERE (`parameter` = '".$cronjobname."')"
);
}
$importer = $importHelperFactory->create($mailClient, $account, $projectId);
$insertedMailsCount = $importer->importMessages($searchResult);
$totalEmailsImportCount += $insertedMailsCount;
// set mutex if the total amount of imported emails is more than 10
if ($totalEmailsImportCount > 10) {
$app->DB->Update(
"UPDATE `prozessstarter`
SET `mutex`=1, `mutexcounter` = 0, `letzteausfuerhung` = NOW()
WHERE (`parameter` = '".$cronjobname."')"
);
}
$mailClient->expunge();
$mailClient->disconnect();
if (
method_exists($app->erp, 'canRunCronjob')
&& !$app->erp->canRunCronjob(['supportmails', 'tickets'])
) {
$logger->error('Tickets error');
file_append($debugfile,"Failed 5");
return;
}
$app->DB->Update(
"UPDATE `prozessstarter`
SET `mutex`=1, `mutexcounter` = 0, `letzteausfuerhung` = NOW()
WHERE (`parameter` = '".$cronjobname."')"
);
}
$app->DB->Update(
"UPDATE `prozessstarter` SET `mutex`=0,`mutexcounter`=0 WHERE (`parameter` = '".$cronjobname."')"
);
file_append($debugfile,"END");

View File

@ -10365,7 +10365,7 @@ CREATE TABLE IF NOT EXISTS `proformarechnung_protokoll` (
CREATE TABLE IF NOT EXISTS `projekt` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` text NOT NULL,
`abkuerzung` text NOT NULL,
`abkuerzung` varchar(128) NOT NULL,
`verantwortlicher` text NOT NULL,
`beschreibung` text NOT NULL,
`sonstiges` text NOT NULL,

View File

@ -2089,7 +2089,7 @@ public function NavigationHooks(&$menu)
// @refactor FileLock Komponente
function ProzessUnlock($fp)
{
if(!$fp)return;
if(gettype($fp) != 'resource') return;
fflush($fp); // leere Ausgabepuffer bevor die Sperre frei gegeben wird
flock($fp, LOCK_UN); // Gib Sperre frei
fclose($fp);
@ -22154,19 +22154,17 @@ function Gegenkonto($ust_befreit,$ustid='', $doctype = '', $doctypeId = 0)
function GetGeschaeftsBriefText($subjekt,$sprache='',$projekt='',$dokument='',$dokumentid=0)
{
$dbcheck = $this->app->DB->Select("SHOW TABLES LIKE '$dokument'");
if ($dbcheck) {
$abweichend = $this->app->DB->Select("SELECT abweichendebezeichnung FROM $dokument WHERE id='$dokumentid' LIMIT 1");
$text = '';
if ($dokument != '') {
$dbcheck = $this->app->DB->Select("SHOW TABLES LIKE '$dokument'");
if (!empty($dbcheck)) {
$abweichend = $this->app->DB->Select("SELECT abweichendebezeichnung FROM $dokument WHERE id='$dokumentid' LIMIT 1");
}
if($abweichend>0 && !preg_match('/_Abweichend/',$subjekt))
{
$text = $this->GetGeschaeftsBriefText($subjekt."_Abweichend",$sprache,$projekt,$dokument,$dokumentid);
}
}
if($abweichend>0 && !preg_match('/_Abweichend/',$subjekt))
{
$text = $this->GetGeschaeftsBriefText($subjekt."_Abweichend",$sprache,$projekt,$dokument,$dokumentid);
}else{
$text = '';
}
if($text=='')
{
@ -22200,14 +22198,16 @@ function Gegenkonto($ust_befreit,$ustid='', $doctype = '', $doctypeId = 0)
function GetGeschaeftsBriefBetreff($subjekt,$sprache="",$projekt="",$dokument="",$dokumentid=0)
{
$dbcheck = $this->app->DB->Select("SHOW TABLES LIKE '$dokument'");
if ($dbcheck) {
$abweichend = $this->app->DB->Select("SELECT abweichendebezeichnung FROM $dokument WHERE id='$dokumentid' LIMIT 1");
}
if($abweichend>0 && !preg_match('/_Abweichend/',$subjekt))
{
$text = $this->GetGeschaeftsBriefBetreff($subjekt."_Abweichend",$sprache,$projekt,$dokument,$dokumentid);
$text = '';
if ($dokument != '') {
$dbcheck = $this->app->DB->Select("SHOW TABLES LIKE '$dokument'");
if ($dbcheck) {
$abweichend = $this->app->DB->Select("SELECT abweichendebezeichnung FROM $dokument WHERE id='$dokumentid' LIMIT 1");
}
if($abweichend>0 && !preg_match('/_Abweichend/',$subjekt))
{
$text = $this->GetGeschaeftsBriefBetreff($subjekt."_Abweichend",$sprache,$projekt,$dokument,$dokumentid);
}
}
if($text=="")
@ -32659,7 +32659,6 @@ function MailSendFinal($from,$from_name,$to,$to_name,$betreff,$text,$files="",$p
$sendmail_error
);
}
if($sysMailerSent === false) {
$this->app->erp->LogFile("Mailer Error: " . $sendmail_error);
$this->MailLogFile($from,$from_name,$to,$to_name,$betreff,$text,$files,$projekt,$signature,$cc,$bcc,$system);
@ -32673,7 +32672,7 @@ function MailSendFinal($from,$from_name,$to,$to_name,$betreff,$text,$files="",$p
}
// schreiben in post ausgang
$this->MailLogFile($from,$from_name,$to,$to_name,$betreff,$text,$files,$projekt,$signature,$cc,$bcc,$system);
$imap_aktiv = $this->app->DB->Select("SELECT imap_sentfolder_aktiv FROM emailbackup WHERE email='".$fromm."' AND imap_sentfolder!='' AND geloescht!=1 LIMIT 1");
$imap_aktiv = $this->app->DB->Select("SELECT imap_sentfolder_aktiv FROM emailbackup WHERE email='".$from."' AND imap_sentfolder!='' AND geloescht!=1 LIMIT 1");
if($imap_aktiv=="1" && !preg_match("/Xentral Kopie/",$to_name) && !preg_match("/WaWision Kopie/",$to_name))
{
$imap_data = $this->app->DB->SelectRow("SELECT * FROM emailbackup WHERE email='".$from."' AND geloescht!=1 LIMIT 1");
@ -32693,7 +32692,9 @@ function MailSendFinal($from,$from_name,$to,$to_name,$betreff,$text,$files="",$p
$client = $clientProvider->createMailClientFromAccount($account);
$client->connect();
$client->appendMessage($imapCopyMessage, $account->getImapOutgoingFolder());
} catch (Exception $e) {}
} catch (Exception $e) {
$this->app->erp->LogFile("Mailer Error: " . (string)$e);
}
$this->app->erp->LogFile("IMAP Ausgang FROM ".$from." S $server P $port T $type SP $server_path B ".$imap_data['benutzername']." SF ".$imap_data['imap_sentfolder']);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,14 @@
<div id="tabs">
<ul>
<li><a href="#tabs-2">[TABTEXT2]</a></li>
[VORTABS3UEBERSCHRIFT]<li><a href="#tabs-3">[TABTEXT3]</a></li>[NACHTABS3UEBERSCHRIFT]
</ul>
<li><a href="#tabs-1">[TABTEXT1]</a></li>
[VORTABS2UEBERSCHRIFT]<li><a href="#tabs-2">[TABTEXT2]</a></li>[NACHTABS2UEBERSCHRIFT]
</ul>
<div id="tabs-2">
<div id="tabs-1">
[MESSAGE]
[AUTOVERSANDBERECHNEN]
<form action="#tabs-2" id="frmauto" name="frmauto" method="post">
<form action="#tabs-1" id="frmauto" name="frmauto" method="post">
<div class="filter-box filter-usersave">
<div class="filter-block filter-inline">
<div class="filter-title">{|Filter|}</div>
@ -34,13 +32,12 @@
<input type="checkbox" id="auftrag_lieferdatum">
<span class="slider round"></span>
</label>
<label for="auftrag_lieferdatum">{|nur Auftr&auml;ge mit zukünftigem Lieferdatum|}</label>
<label for="auftrag_lieferdatum">{|inkl. Auftr&auml;ge mit zukünftigem Lieferdatum|}</label>
</li>
</ul>
</div>
</div>
[TAB2]
[TAB1]
<fieldset>
<legend>Stapelverarbeitung</legend>
<input type="checkbox" value="1" id="autoalle" checked="checked" />&nbsp;alle markieren&nbsp;
@ -59,32 +56,17 @@
</fieldset>
</form>
</div>
<div id="tabs-3">
[VORTABS3UEBERSCHRIFT]
<form action="#tabs-3" method="post">
<div class="filter-box filter-usersave">
<div class="filter-block filter-inline">
<div class="filter-title">{|Filter|}</div>
<ul class="filter-list">
<li class="filter-item">
<label for="autoallewartend" class="switch">
<input type="checkbox" value="1" id="autoallewartend" checked="checked" />
<span class="slider round"></span>
</label>
<label for="autoallewartend">{|Alle|}</label>
</li>
</ul>
</div>
</div>
[TAB3]
<table width="100%"><tr><td><input type="submit" value="Auftr&auml;ge aus Liste entfernen" name="entfernen"></td>
<div id="tabs-2">
[VORTABS2UEBERSCHRIFT]
<form action="#tabs-2" method="post">
[TAB2]
<table width="100%"><tr><td><input type="submit" value="Gew&auml;hlte Auftr&auml;ge zurücksetzen" name="entfernen"></td>
</tr></table>
</form>
[NACHTABS3UEBERSCHRIFT]
[NACHTABS2UEBERSCHRIFT]
</div>
</div>
<script>

View File

@ -12,7 +12,7 @@ document.onkeydown = function(evt) {
<div id="tabs">
<ul>
<li><a href="#tabs-1">{|Auftr&auml;ge|}</a></li>
<li><a href="#tabs-5">{|in Bearbeitung|}</a></li>
<li><a href="#tabs-5">{|in Bearbeitung|}[TABTEXT5]</a></li>
</ul>
<div id="tabs-1">
@ -113,10 +113,6 @@ document.onkeydown = function(evt) {
<div id="tabs-5">
[TAB5]
</div>
</div>
<div id="lagermehrpopup" style="display:none;">
<div id="lagermehrpopupinhalt">

View File

@ -283,8 +283,8 @@ $width = array('10%'); // Fill out manually later
$result[0]['email'],
$result[0]['angezeigtername'],
'Xenomporio ERP: Testmail',
'Dies ist eine Testmail',
'',0,true,'','',
'Dies ist eine Testmail für Account "'.$result[0]['email'].'".',
'',0,false,'','',
true
)
) {
@ -294,7 +294,7 @@ $width = array('10%'); // Fill out manually later
}
else {
$msg = $this->app->erp->base64_url_encode(
'<div class="error">Die Testmail wurde nicht versendet: '.$this->app->erp->mail_error.'</div>'
'<div class="error">Fehler beim Versende der Testmail: '.$this->app->erp->mail_error.'</div>'
);
}
$this->app->Location->execute("index.php?module=emailbackup&id=$id&action=edit&msg=$msg");

View File

@ -480,7 +480,7 @@ class Firmendaten {
}
else {
$msg = $this->app->erp->base64_url_encode(
'<div class="error">Die Testmail wurde nicht versendet: '.$this->app->erp->mail_error.'</div>'
'<div class="error">Fehler beim Versenden der Testmail: '.$this->app->erp->mail_error.'</div>'
);
}
$this->app->Location->execute("index.php?module=firmendaten&action=edit&msg=$msg#tabs-4");

View File

@ -56,7 +56,7 @@
</div>
<div id="tabs-3">
<div class="row">
<!-- <div class="row">
<div class="row-height">
<div class="col-xs-12 col-sm-height">
<div class="inside_white inside-full-height">
@ -78,7 +78,7 @@
</div>
</div>
</div>
</div>
</div> -->
<div class="row">
<div class="row-height">
@ -148,7 +148,7 @@
</div>
<div class="col-xs-12 col-sm-6 col-sm-height">
<div class="inside inside-full-height">
<fieldset>
<fieldset disabled>
<legend>{|Stufe 2 (Pack) an Versandstation|}</legend>
<table border="0" width="100%" class="mkTable">
<tr><td width="300"></td><td>{|Drucker|}</td><td width="30%">{|Anzahl Exemplare|}</td><td width="30%">{|E-Mail|}</td></tr>

View File

@ -19,7 +19,12 @@ class WidgetProjekt extends WidgetGenProjekt
$id = $this->app->Secure->GetGET("id");
$kommissionierverfahren = array(
'rechnungsmail'=>'Ohne Lagerbuchung',
'lieferschein'=>'Einfache Lagerbuchung ohne weiteren Prozess');
'lieferschein'=>'Einfache Lagerbuchung ohne weiteren Prozess'
// 'lieferscheinscan'=>'Lieferscheinscan',
// 'lieferscheinlagerscan'=>'Lieferscheinlagerscan',
// 'lieferscheinlager'=>'Lieferscheinlager',
// 'zweistufig'=>'Zweistufig'
);
$field = new HTMLSelect("kommissionierverfahren",0);
$field->AddOptionsAsocSimpleArray($kommissionierverfahren);
$this->form->NewField($field);