| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/api.pacim.de/web/src/PaCIM/ |
Upload File : |
<?php
require_once("includes/config.inc.php");
/**
* @var \Fusio\Engine\ConnectorInterface $connector
* @var \Fusio\Engine\ContextInterface $context
* @var \Fusio\Engine\RequestInterface $request
* @var \Fusio\Engine\Response\FactoryInterface $response
* @var \Fusio\Engine\ProcessorInterface $processor
* @var \Psr\Log\LoggerInterface $logger
* @var \Psr\SimpleCache\CacheInterface $cache
*/
use PSX\Http\Exception as StatusCode;
/** @var \Doctrine\DBAL\Connection $connection */
$connection = $connector->getConnection( API_CONNECTION );
$customer = array();
// automatical assignment ticket e-mail to customer
if( isset( $_POST['email'] ) && !empty( trim( $_POST['email'] ) ) ) {
$customer = $connection->fetchAll('
SELECT
c.customer_id,
c.customer_firstname,
c.customer_lastname,
c.customer_phone,
c.customer_email,
i.invoice_id,
i.invoice_no
FROM pacim_customer c
LEFT JOIN pacim_invoice i ON i.invoice_customer = c.customer_id
WHERE c.customer_email LIKE "' . trim( $_POST['email'] ) . '"
ORDER by i.invoice_id DESC
');
// show new phone number
if( isset( $_POST['phone'] ) && !empty( trim( $_POST['phone'] ) ) ) $customer['customer_phone'] = $_POST['phone'];
}
if( !isset( $customer[0] ) ) {
$customer = array(
'customer_id' => 0,
'customer_firstname' => ( isset( $_POST['firstname'] ) ? $_POST['firstname'] : FALSE ),
'customer_lastname' => ( isset( $_POST['lastname'] ) ? $_POST['lastname'] : FALSE ),
'customer_phone' => ( isset( $_POST['phone'] ) ? $_POST['phone'] : FALSE ),
'customer_email' => ( isset( $_POST['email'] ) ? $_POST['email'] : FALSE ),
'invoice_id' => 0,
'invoice_no' => FALSE
);
} else {
$customer = $customer[0];
}
// collect contact datas
$contacts = array();
if( !empty( $customer['customer_email'] ) ) $contacts[] = $customer['customer_email'];
if( !empty( $customer['customer_phone'] ) ) $contacts[] = $customer['customer_phone'];
$additionalInfos = '';
if( !empty( $customer['customer_firstname'] ) || !empty( $customer['customer_lastname'] ) ) $additionalInfos.= '<strong>Name</strong><br />' . $customer['customer_firstname'] . " " . $customer['customer_lastname'] . '<br /><br />';
if( !empty( $customer['invoice_no'] ) ) $additionalInfos.= '<strong>Rechnungsnummer</strong><br />' . $customer['invoice_no'] . '<br /><br />';
$arrMailTemplates[] = $connection->fetchAll('SELECT * FROM pacim_templates WHERE template_id = 8')[0];
$arrMailTemplates[] = $connection->fetchAll('SELECT * FROM pacim_templates WHERE template_id = 9')[0];
$arrMails = array();
$savedMessages = array();
foreach($arrMailTemplates as $mailKey => $mailTemplate) {
$arrMails[ $mailKey ] = array(
'message_status' => 0,
'message_count' => 0,
'message_template' => $mailTemplate['template_id'],
'message_customer' => $customer['customer_id'],
'message_invoice' => $customer['invoice_id'],
'message_booking' => 0,
'message_sender' => 'info@parken-am-schiff.de',
'message_receiver' => ( $mailTemplate['template_id'] == 8 ? $customer['customer_email'] : "info@parken-am-schiff.de" ),
'message_subject' => str_replace(
array( '[ticket_date]' ),
array( date('d.m.Y') ),
$mailTemplate['template_title']
),
'message_content' => str_replace(
array(
'[ticket_date]',
'[ticket_deadline]',
'[ticket_content]',
'[ticket_contact]',
'[ticket_salut]',
'[ticket_customer_info]'
),
array(
date('d.m.Y'),
date('d.m.Y', strtotime( date("Y-m-d") . "+3 days" ) ),
nl2br( $_POST['content'] ),
implode('<br />', $contacts),
( !empty( $customer['customer_firstname'] ) && !empty( $customer['customer_lastname'] ) ? "Guten Tag " . $customer['customer_firstname'] . " " . $customer['customer_lastname'] . "!" : "Sehr geehrte Kundin, sehr geehrter Kunde!" ),
$additionalInfos,
),
$mailTemplate['template_content']
)
);
$connection->insert('pacim_messages', $arrMails[ $mailKey ]);
$savedMessages[] = $connection->lastInsertId();
}
return $response->build(200, [], array(
'status' => 'ok',
'ticket' => $arrMails
));