app = $app; if ($intern) { return; } $this->app->ActionHandlerInit($this); $this->app->ActionHandler('list', 'GetMyInvoicesList'); $this->app->ActionHandlerListen($app); $this->app->erp->Headlines('GetMyInvoices'); } public function GetMyInvoicesMenu() { $this->app->erp->MenuEintrag("index.php?module=appstore&action=list","Zurück zur Übersicht"); $this->app->erp->MenuEintrag("index.php?module=getmyinvoices&action=list","Übersicht"); } public function GetMyInvoicesList() { $this->GetMyInvoicesMenu(); /** @var ApiAccountService $apiAccountService */ $apiAccountService = $this->app->Container->get('ApiAccountService'); try { $apiAccount = $apiAccountService->getApiAccountByRemoteDomain('getmyinvoices'); $apiAccountExists = true; } catch (ApiAccountNotFoundException $exception){ $apiAccountExists = false; } if($apiAccountExists === false){ /** @var Request $request */ $request = $this->app->Container->get('Request'); if($request->getPost('create_api_account')){ $title = "getmyinvoices"; $serverUrl = $request->getBaseUrl() . '/'; $password = md5(uniqid('', true)); $permissions = '["create_scanned_document"]'; $formData = [ 'id' => 0, 'name' => $title, 'init_key' => $password, 'import_queue_name' => '', 'event_url' => $serverUrl, 'remotedomain' => $title, 'active' => true, 'import_queue' => false, 'cleanutf8' => true, 'transfer_account_id' => 0, 'project_id' => 0, 'permissions' => $permissions, 'is_legacy' => false, 'is_html_transformation' => false ]; try { $apiAccountData = ApiAccountData::fromFormData($formData); $apiAccountId = $apiAccountService->createApiAccount($apiAccountData); $apiAccount = $apiAccountService->getApiAccountById($apiAccountId); $apiAccountExists = true; } catch (ApiAccountNotFoundException $exception) { $this->app->Tpl->Set('MESSAGE', '
API-Account konnte nicht gefunden werden!
'); } catch (Exception $exception) { $this->app->Tpl->Set('MESSAGE', '
API-Account konnte nicht angelegt werden!
'); } } } if($apiAccountExists){ $getmyInvoiceExistingAccountHtml = '
{|URL|}: '.$apiAccount->getEventUrl().'
{|Benutzername|}: '.$apiAccount->getRemoteDomain().'
{|Passwort|}: '.$apiAccount->getInitKey().'
'; $this->app->Tpl->Set('GETMYINVOICES', $getmyInvoiceExistingAccountHtml); }else{ $getmyInvoiceCreateAccountHtml = '
Legt einen API-Account an.
'; $this->app->Tpl->Set('GETMYINVOICES', $getmyInvoiceCreateAccountHtml); } $this->app->Tpl->Parse("PAGE","getmyinvoices_list.tpl"); } }