Start Repo
This commit is contained in:
commit
b718c52316
14
README.md
Normal file
14
README.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
### Installation
|
||||||
|
|
||||||
|
## Datenbank
|
||||||
|
ALTER TABLE `oxorder`
|
||||||
|
ADD COLUMN `D3LEITWEGID` VARCHAR(25) NOT NULL COMMENT 'xRechnung' AFTER `OSC_AMAZON_REMARK`
|
||||||
|
|
||||||
|
## Composer
|
||||||
|
composer require d3/xrechnung:dev-modules/rel_mod_xrechnung
|
||||||
|
|
||||||
|
## Zugangsdaten
|
||||||
|
Die Zugangdaten hinter https://xrechnung.DOMAIN.TLD/xrechnung.php? entsprechend modifizieren - .env.
|
||||||
|
|
||||||
|
|
||||||
|
|
37
composer.json
Normal file
37
composer.json
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"name": "d3/xrechnung",
|
||||||
|
"description": "xRechnung",
|
||||||
|
"type": "oxideshop-module",
|
||||||
|
"keywords": [
|
||||||
|
"oxid",
|
||||||
|
"modules",
|
||||||
|
"eShop",
|
||||||
|
"d3"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "D3 Data Development (Inh. Thomas Dartsch)",
|
||||||
|
"email": "info@shopmodule.com",
|
||||||
|
"homepage": "https://www.d3data.de",
|
||||||
|
"role": "Owner"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"email": "support@shopmodule.com"
|
||||||
|
},
|
||||||
|
"homepage": "https://www.oxidmodule.com/",
|
||||||
|
|
||||||
|
"require": {
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"oxideshop": {
|
||||||
|
"source-directory": "/src",
|
||||||
|
"target-directory": "d3/xrechnung"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"D3\\XRechnung\\": "../../../source/modules/d3/xrechnung"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
51
src/Application/views/admin/blocks/order_overview.tpl
Normal file
51
src/Application/views/admin/blocks/order_overview.tpl
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
[{$smarty.block.parent}]
|
||||||
|
|
||||||
|
[{if $edit && $oView->d3CanExport() && $oViewConf->getActiveClassName()|oxlower == 'order_overview'}]
|
||||||
|
<br>
|
||||||
|
<form name="d3CreateXml" id="d3CreateXml" action="[{$oViewConf->getSelfLink()}]" method="post" target="expXML">
|
||||||
|
[{$oViewConf->getHiddenSid()}]
|
||||||
|
<input type="hidden" name="cl" value="order_overview">
|
||||||
|
<input type="hidden" name="fnc" value="createXRechnung">
|
||||||
|
<input type="hidden" name="oxid" value="[{$oxid}]">
|
||||||
|
<input type="hidden" name="xmllanguage" value="0">
|
||||||
|
<fieldset style="padding: 5px">
|
||||||
|
<legend>xRechnung</legend>
|
||||||
|
<table style="width: 100%">
|
||||||
|
<tr>
|
||||||
|
<td rowspan="3">
|
||||||
|
<img src="[{$oViewConf->getModuleUrl('d3xrechnung', 'out/img/xrechnung.png')}]" style="height:4em;width:4em" alt="[{oxmultilang ident="D3_PDFDOCUMENTS"}]">
|
||||||
|
</td>
|
||||||
|
<td style="vertical-align: top; text-align: right" class="edittext">
|
||||||
|
<label for="exporttype">xRechnung</label>:
|
||||||
|
<select id="exporttype" name="pdftype" class="editinput" style="width:80px;">
|
||||||
|
<option value="xml" SELECTED>XML
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="text-align: right" class="edittext">
|
||||||
|
<label for="xmllanguage">Leitweg-ID:</label>
|
||||||
|
<input type="text" class="editinput" size="15" maxlength="[{$edit->oxorder__d3leitwegid->fldmax_length}]" name="editval[oxorder__d3leitwegid]"
|
||||||
|
value="[{$edit->oxorder__d3leitwegid->value}]" [{$readonly}]>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
[{*<tr>
|
||||||
|
<td style="text-align: right" class="edittext">
|
||||||
|
<label for="xmllanguage">Sprache</label>
|
||||||
|
<select id="xmllanguage" name="pdflanguage" class="saveinnewlanginput" style="width:80px;">
|
||||||
|
[{foreach from=$alangs key=lang item=slang}]
|
||||||
|
<option value="[{$lang}]" [{if $lang == "0"}]SELECTED[{/if}]>[{$slang}]</option>
|
||||||
|
[{/foreach}]
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>*}]
|
||||||
|
<tr>
|
||||||
|
<td style="text-align: right" class="edittext"><br/>
|
||||||
|
<input type="submit" class="edittext" name="save" value="Export">
|
||||||
|
<iframe name="expXML" style="width: 0; height: 0; border: none; display:none;"></iframe>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
[{/if}]
|
29
src/Application/views/admin/de/config_lang.php
Normal file
29
src/Application/views/admin/de/config_lang.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This Software is the property of Data Development and is protected
|
||||||
|
* by copyright law - it is NOT Freeware.
|
||||||
|
*
|
||||||
|
* Any unauthorized use of this software without a valid license
|
||||||
|
* is a violation of the license agreement and will be prosecuted by
|
||||||
|
* civil and criminal law.
|
||||||
|
*
|
||||||
|
* http://www.shopmodule.com
|
||||||
|
*
|
||||||
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||||
|
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||||
|
* @link http://www.oxidmodule.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
|
|
||||||
|
$sLangName = "Deutsch";
|
||||||
|
$iLangNr = 0;
|
||||||
|
|
||||||
|
$aLang = array(
|
||||||
|
//Navigation
|
||||||
|
'charset' => 'UTF-8',
|
||||||
|
'SHOP_MODULE_GROUP_d3xrechnung' => 'Einstellungen',
|
||||||
|
'SHOP_MODULE_d3xrechnung_PATH_GENERATOR' => 'Pfad xRechnung',
|
||||||
|
'SHOP_MODULE_d3xrechnung_HTACCESS_USER' => '.htaccess - User',
|
||||||
|
'SHOP_MODULE_d3xrechnung_HTACCESS_PASSWORD' => '.htaccess - Password',
|
||||||
|
);
|
58
src/Modules/Application/Controller/Admin/OrderOverview.php
Normal file
58
src/Modules/Application/Controller/Admin/OrderOverview.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace D3\XRechnung\Modules\Application\Controller\Admin;
|
||||||
|
|
||||||
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
|
|
||||||
|
class OrderOverview extends OrderOverview_parent
|
||||||
|
{
|
||||||
|
public function createXRechnung()
|
||||||
|
{
|
||||||
|
$soxId = $this->getEditObjectId();
|
||||||
|
if ($soxId != "-1" && isset($soxId)) {
|
||||||
|
// load object
|
||||||
|
$oOrder = oxNew(\OxidEsales\Eshop\Application\Model\Order::class);
|
||||||
|
if ($oOrder->load($soxId)) {
|
||||||
|
$oConfig = $this->getConfig();
|
||||||
|
$aParams = $oConfig->getRequestParameter("editval");
|
||||||
|
|
||||||
|
if($aParams["oxorder__d3leitwegid"])
|
||||||
|
{
|
||||||
|
$oOrder->assign(
|
||||||
|
array('d3leitwegid' => $aParams["oxorder__d3leitwegid"])
|
||||||
|
);
|
||||||
|
$oOrder->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
$oUtils = \OxidEsales\Eshop\Core\Registry::getUtils();
|
||||||
|
$sTrimmedBillName = trim($oOrder->oxorder__oxbilllname->getRawValue());
|
||||||
|
if(!$sTrimmedBillName) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$strx=array('#[^a-zA-Z0-9äöüß\040]#','# +#','#ä#','#ö#','#ü#','#ß#');
|
||||||
|
$stry=array(' ',' ','ae','oe','ue','ss');
|
||||||
|
$sTrimmedBillName=preg_replace($strx,$stry,$sTrimmedBillName);
|
||||||
|
$sTrimmedBillName=trim($sTrimmedBillName);
|
||||||
|
$sTrimmedBillName=strtolower($sTrimmedBillName);
|
||||||
|
}
|
||||||
|
$sFilename = $oOrder->oxorder__oxordernr->value . "_" . $sTrimmedBillName . ".xml";
|
||||||
|
$sFilename = $this->makeValidFileName($sFilename);
|
||||||
|
ob_start();
|
||||||
|
$oOrder->genXRechnung($sFilename, \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("xmllanguage"), false);
|
||||||
|
|
||||||
|
$myConfig = Registry::getConfig();
|
||||||
|
|
||||||
|
echo file_get_contents($myConfig->getConfigParam('sShopDir')."/export/xml/".$sFilename);
|
||||||
|
$sXML = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
$oUtils->setHeader("Pragma: public");
|
||||||
|
$oUtils->setHeader("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
||||||
|
$oUtils->setHeader("Expires: 0");
|
||||||
|
$oUtils->setHeader("Content-type: application/xml");
|
||||||
|
$oUtils->setHeader("Content-Disposition: attachment; filename=" . $sFilename);
|
||||||
|
\OxidEsales\Eshop\Core\Registry::getUtils()->showMessageAndExit($sXML);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
84
src/Modules/Application/Model/Order.php
Normal file
84
src/Modules/Application/Model/Order.php
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace D3\XRechnung\Modules\Application\Model;
|
||||||
|
|
||||||
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\Psr7;
|
||||||
|
use GuzzleHttp\Exception\ClientException;
|
||||||
|
|
||||||
|
class Order extends Order_parent
|
||||||
|
{
|
||||||
|
public function genXRechnung(string $sFilename, int $iSelLang = 0, bool $sendContent = false)
|
||||||
|
{
|
||||||
|
$blIsNewOrder = 0;
|
||||||
|
// setting invoice number
|
||||||
|
if (!$this->oxorder__oxbillnr->value) {
|
||||||
|
$this->oxorder__oxbillnr->setValue($this->getNextBillNum());
|
||||||
|
$blIsNewOrder = 1;
|
||||||
|
}
|
||||||
|
// setting invoice date
|
||||||
|
if ($this->oxorder__oxbilldate->value == '0000-00-00') {
|
||||||
|
$this->oxorder__oxbilldate->setValue(date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y'))));
|
||||||
|
$blIsNewOrder = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($blIsNewOrder) {
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// adding info data
|
||||||
|
switch (\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('exporttype')) {
|
||||||
|
case ('xml'):
|
||||||
|
return $this->getXRechnungXml($sFilename, $this->getId(), $iSelLang, $sendContent);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return $this->getXRechnungXml($sFilename, $this->getId(), $iSelLang, $sendContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $sOrderId
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
|
protected function getXRechnungXml(string $sFilename, string $sOrderId, int $iSelLang, bool $sendContent = false)
|
||||||
|
{
|
||||||
|
$oConfig = Registry::getConfig();
|
||||||
|
$oConfig->getConfigParam('d3xrechnung_PATH_GENERATOR');
|
||||||
|
|
||||||
|
$sPathDetails = $oConfig->getConfigParam('d3xrechnung_PATH_GENERATOR');
|
||||||
|
$sPathDetails .= 'orderid='.$sOrderId;
|
||||||
|
$sPathDetails .= '&filename='.$sFilename;
|
||||||
|
$sPathDetails .= '&iSelLang='.$iSelLang;
|
||||||
|
$sPathDetails .= '&sendContent='.$sendContent;
|
||||||
|
$sPathDetails .= '&combinexmlpdf=false';
|
||||||
|
|
||||||
|
$sUser = $oConfig->getConfigParam('d3xrechnung_HTACCESS_USER');
|
||||||
|
$sPassword = $oConfig->getConfigParam('d3xrechnung_HTACCESS_PASSWORD');
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
try {
|
||||||
|
/*
|
||||||
|
$response = $client->request('GET', $sPathDetails,
|
||||||
|
['auth' => ['schmidt', 'tGiVLrBQik!8']]
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
$response = $client->request('GET', $sPathDetails,
|
||||||
|
['auth' => [$sUser, $sPassword]]
|
||||||
|
);
|
||||||
|
|
||||||
|
if($sendContent) {
|
||||||
|
return $response->getBody(); // '{"id": 1420053, "name": "guzzle", ...}'
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (ClientException $exception) {
|
||||||
|
$logger = Registry::getLogger();
|
||||||
|
$logger->error(Psr7\Message::toString($exception->getRequest()), [$exception]);
|
||||||
|
$logger->error(Psr7\Message::toString($exception->getResponse()), [$exception]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
84
src/metadata.php
Normal file
84
src/metadata.php
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* https://www.d3data.de
|
||||||
|
*
|
||||||
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||||
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||||
|
* @link https://www.oxidmodule.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use D3\DelUserExtension\Modules\Controller\Admin\userDeletingList;
|
||||||
|
use D3\DelUserExtension\Modules\Controller\Admin\userDeletingMain;
|
||||||
|
use D3\DelUserExtension\Modules\Core\Model\ListModel;
|
||||||
|
|
||||||
|
$sMetadataVersion = '2.1';
|
||||||
|
|
||||||
|
$sModuleId = 'd3xrechnung';
|
||||||
|
$logo = '<img src="https://logos.oxidmodule.com/d3logo.svg" alt="(D3)" style="height:1em;width:1em">';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module information
|
||||||
|
*/
|
||||||
|
$aModule = [
|
||||||
|
'id' => $sModuleId,
|
||||||
|
'title' => $logo.' Anpassung: xRechnung / Zugferd',
|
||||||
|
'description' => [
|
||||||
|
'de' => '<hr>
|
||||||
|
Ruft den Generator auf, und gibt die erstellte XML-Datei an den Browser zum Download aus.<br>
|
||||||
|
Der Pfad und Zugangsschutz zum Generator wird in der Konfiguration des Moduls hinterlegt.
|
||||||
|
<hr>
|
||||||
|
<strong>Pfad:</strong> https://xrechnung.DOMAIN.TLD/xrechnung.php?<br>
|
||||||
|
<strong>Validierung:</strong><a href="https://www.epoconsulting.com/erechnung-sap/xrechnung-validator" target="_blank">https://www.epoconsulting.com/erechnung-sap/xrechnung-validator</a><br>
|
||||||
|
<strong>Tickets:</strong>
|
||||||
|
<ul>
|
||||||
|
<li>xxx: Ticket</li>
|
||||||
|
</ul>
|
||||||
|
',
|
||||||
|
'en' => '',
|
||||||
|
],
|
||||||
|
'thumbnail' => 'picture.png',
|
||||||
|
'version' => '1.0.0',
|
||||||
|
'author' => $logo.' Data Development (Inh.: Thomas Dartsch)',
|
||||||
|
'email' => 'support@shopmodule.com',
|
||||||
|
'url' => 'https://www.oxidmodule.com/',
|
||||||
|
'extend' => [
|
||||||
|
\OxidEsales\Eshop\Application\Controller\Admin\OrderOverview::class => D3\XRechnung\Modules\Application\Controller\Admin\OrderOverview::class,
|
||||||
|
\OxidEsales\Eshop\Application\Model\Order::class => \D3\XRechnung\Modules\Application\Model\Order::class
|
||||||
|
],
|
||||||
|
'templates' => [
|
||||||
|
],
|
||||||
|
'settings' => [
|
||||||
|
[
|
||||||
|
'group' => 'd3xrechnung',
|
||||||
|
'name' => 'd3xrechnung_PATH_GENERATOR',
|
||||||
|
'type' => 'str',
|
||||||
|
'value' => 'https://xrechnung.DOMAIN.TLD/xrechnung.php?'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'group' => 'd3xrechnung',
|
||||||
|
'name' => 'd3xrechnung_HTACCESS_USER',
|
||||||
|
'type' => 'str',
|
||||||
|
'value' => ''
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'group' => 'd3xrechnung',
|
||||||
|
'name' => 'd3xrechnung_HTACCESS_PASSWORD',
|
||||||
|
'type' => 'str',
|
||||||
|
'value' => ''
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'blocks' => array(
|
||||||
|
array(
|
||||||
|
'template' => 'order_overview.tpl',
|
||||||
|
'block' => 'admin_order_overview_export',
|
||||||
|
'file' => 'Application/views/admin/blocks/order_overview.tpl',
|
||||||
|
'position' => 100
|
||||||
|
),
|
||||||
|
),
|
||||||
|
];
|
BIN
src/out/img/xrechnung.png
Normal file
BIN
src/out/img/xrechnung.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
BIN
src/picture.png
Normal file
BIN
src/picture.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
Loading…
x
Reference in New Issue
Block a user