<?php
/*
 #########################################################################
 #                       xt:Commerce Shopsoftware
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #
 # Copyright 2021 xt:Commerce GmbH All Rights Reserved.
 # This file may not be redistributed in whole or significant part.
 # Content of this file is Protected By International Copyright Laws.
 #
 # ~~~~~~ xt:Commerce Shopsoftware IS NOT FREE SOFTWARE ~~~~~~~
 #
 # https://www.xt-commerce.com
 #
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #
 # @copyright xt:Commerce GmbH, www.xt-commerce.com
 #
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #
 # xt:Commerce GmbH, Maximilianstrasse 9, 6020 Innsbruck
 #
 # office@xt-commerce.com
 #
 #########################################################################
 */

defined('_VALID_CALL') or die('Direct Access is not allowed.');

global $info, $xtPlugin, $xtLink, $brotkrumen, $filter, $_content;

/** @var $shop_content_data array */


$brotkrumen->_addItem($xtLink->_link(array('page'=>'content', 'params'=>'coID='.$shop_content_data['content_id'],'seo_url' => $shop_content_data['url_text'],'conn'=>'SSL')),$shop_content_data['title']);

if($_SESSION['registered_customer'])
    $email = $_SESSION["customer"]->customer_info["customers_email_address"];
else if($getEmail = $filter->_filter($_GET['email'])){
    $email = $getEmail;
}

$order_id = null;
if($getOrderId = $filter->_filterXSS($_GET['order'])){
    $order_id = $getOrderId;
}

global $_content;
$priv = $_content->getHookContent(2, true);
$priv_link = $priv ? $priv["content_link"] : '';
$resc = $_content->getHookContent(7, true);
$resc_link = $resc ? $resc["content_link"] : '';

$legal_txt_tpl = __text('TEXT_LEGAL_INFO_1');
$legal_text = str_replace('[LINK_PRIVACY]', $priv_link, $legal_txt_tpl);
$legal_text = str_replace('[LINK_RESCISSION]', $resc_link, $legal_text);

$template = new Template();

$tpl = 'rescission_select_order.tpl.html';

$tpl_data = array(
    'message'=>$info->info_content,
    'email' => $email,
    'order_id' => $order_id,
    'data'=>$shop_content_data,
    'subdata'=>!empty($subdata) ? $subdata : [],
    'captcha_link'=>$xtLink->_link(array('default_page'=>'captcha.php','conn'=>'SSL')),
    'legal_text'=>$legal_text,
);

$page_data = $template->getTemplate('smarty', '/'._SRV_WEB_CORE.'forms/'.$tpl, $tpl_data);
