Browse code

Initial commit

Benjamin Roth authored on07/09/2015 15:02:25
Showing19 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,133 @@
1
+<?php
2
+
3
+/**
4
+ * eSales Media oxVoucher for Contao Open Source CMS
5
+ *
6
+ * Copyright (c) 2015 eSales Media
7
+ *
8
+ * @author  Benjamin Roth [benjamin@esales-media.de]
9
+ * @license proprietary
10
+ */
11
+
12
+namespace eSM_oxVoucher;
13
+
14
+class TicketHandler extends Voucher
15
+{
16
+
17
+	/**
18
+	 * Oxid Database Object
19
+	 * @var \Database|null
20
+	 */
21
+	protected $oxDB = null;
22
+
23
+	/**
24
+	 * ticket database result array
25
+	 * @var Array
26
+	 */
27
+	protected $arrTicket = array();
28
+
29
+	protected $blnIsVariant = null;
30
+
31
+	/**
32
+	 * Import Oxid database instance
33
+	 */
34
+	public function __construct($strOxId)
35
+	{
36
+		$this->oxDB = Voucher::getOxDbInstance();
37
+
38
+		$this->load($strOxId);
39
+
40
+		parent::__construct();
41
+	}
42
+
43
+	public function __get($name)
44
+	{
45
+		if ($this->arrTicket[strtoupper($name)])
46
+		{
47
+			return $this->arrTicket[strtoupper($name)];
48
+		}
49
+		return null;
50
+	}
51
+
52
+	public function __set($name, $value)
53
+	{
54
+		if ($this->arrTicket[strtoupper($name)])
55
+		{
56
+			$this->arrTicket[strtoupper($name)] = $value;
57
+		}
58
+	}
59
+
60
+	public function getData()
61
+	{
62
+		return $this->arrTicket;
63
+	}
64
+
65
+	protected function load($strOxId)
66
+	{
67
+		$objSQL = $this->oxDB->prepare("SELECT a.OXID, a.OXPARENTID, a.OXTITLE, pa.OXTITLE AS 'OXPARENTTITLE', pa.OXSHORTDESC AS 'OXPARENTSHORTDESC', a.OXSHORTDESC, a.OXACTIVE, UNIX_TIMESTAMP(a.OXACTIVEFROM) AS 'OXACTIVEFROM', UNIX_TIMESTAMP(a.OXACTIVETO) AS 'OXACTIVETO', UNIX_TIMESTAMP(a.OXESSELLUNTIL) AS 'OXESSELLUNTIL', a.OXPRICE, a.OXSTOCK, a.OXVARSTOCK, a.OXVARNAME, a.OXVARSELECT FROM oxv_oxarticles_de a LEFT JOIN oxv_oxarticles_de AS pa ON pa.OXID = a.OXPARENTID AND a.OXPARENTID != ''  WHERE a.OXID = ?");
68
+
69
+		$objResult = $objSQL->execute($strOxId);
70
+
71
+		if ($objResult->numRows)
72
+		{
73
+			$this->arrTicket = $objResult->row();
74
+		}
75
+	}
76
+
77
+	protected function refresh()
78
+	{
79
+		$this->load($this->oxid);
80
+	}
81
+
82
+
83
+	public function isVariant()
84
+	{
85
+		if (is_null($this->blnIsVariant))
86
+		{
87
+			$this->blnIsVariant = (bool) ( $this->oxparentid ? $this->oxparentid : false );
88
+		}
89
+
90
+		return $this->blnIsVariant;
91
+	}
92
+
93
+	public function isBuyable()
94
+	{
95
+		if ($this->isActiveTime() && $this->oxactive && $this->oxstock > 0)
96
+		{
97
+			return true;
98
+		}
99
+		return false;
100
+	}
101
+
102
+	public function isActiveTime()
103
+	{
104
+		$Today = new \Date();
105
+		if ((is_null($this->oxactivefrom) || $this->oxactivefrom <= $Today->tstamp) && (is_null($this->oxactiveto) || $this->oxactiveto >= $Today->tstamp))
106
+		{
107
+			return true;
108
+		}
109
+		return false;
110
+	}
111
+
112
+
113
+	public function reduceStock($iVal)
114
+	{
115
+		$iVal = (int) $iVal;
116
+		if ($iVal <= $this->oxstock && $iVal > 0)
117
+		{
118
+			$objSQL = $this->oxDB->prepare("UPDATE oxarticles SET OXSTOCK = OXSTOCK - $iVal WHERE OXID = ?");
119
+			$objSQL->execute($this->oxid);
120
+
121
+			if ($this->isVariant())
122
+			{
123
+				$objSQL = $this->oxDB->prepare("UPDATE oxarticles p SET p.OXVARSTOCK = (SELECT SUM(v.OXSTOCK) FROM oxarticles v WHERE OXPARENTID = ?), p.OXSOLDAMOUNT = p.OXSOLDAMOUNT + $iVal WHERE p.OXID = ? AND p.OXPARENTID = ''");
124
+				$objSQL->execute($this->oxparentid,$this->oxparentid);
125
+			} else {
126
+				$objSQL = $this->oxDB->prepare("UPDATE oxarticles SET OXSOLDAMOUNT = OXSOLDAMOUNT + $iVal WHERE OXID = ?");
127
+				$objSQL->execute($this->oxid);
128
+			}
129
+
130
+			$this->refresh();
131
+		}
132
+	}
133
+}
0 134
\ No newline at end of file
1 135
new file mode 100644
... ...
@@ -0,0 +1,25 @@
1
+<?php
2
+
3
+/**
4
+ * eSales Media oxVoucher for Contao Open Source CMS
5
+ *
6
+ * Copyright (c) 2015 eSales Media
7
+ *
8
+ * @author  Benjamin Roth [benjamin@esales-media.de]
9
+ * @license proprietary
10
+ */
11
+
12
+namespace eSM_oxVoucher;
13
+
14
+class Voucher extends \Controller
15
+{
16
+
17
+	/**
18
+	 * Import Oxid database instance
19
+	 * @return \Database
20
+	 */
21
+	public static function getOxDbInstance()
22
+	{
23
+		return \Database::getInstance($GLOBALS['oxvoucher']['db_config']);
24
+	}
25
+}
0 26
\ No newline at end of file
1 27
new file mode 100644
... ...
@@ -0,0 +1,129 @@
1
+<?php
2
+
3
+/**
4
+ * eSales Media oxVoucher for Contao Open Source CMS
5
+ *
6
+ * Copyright (c) 2015 eSales Media
7
+ *
8
+ * @author  Benjamin Roth [benjamin@esales-media.de]
9
+ * @license proprietary
10
+ */
11
+
12
+namespace eSM_oxVoucher;
13
+
14
+class VoucherHandler extends Voucher
15
+{
16
+
17
+	/**
18
+	 * Oxid Database Object
19
+	 * @var \Database|null
20
+	 */
21
+	protected $oxDB = null;
22
+
23
+	/**
24
+	 * voucher database result array
25
+	 * @var Array
26
+	 */
27
+	protected $arrVoucher = array();
28
+
29
+	/**
30
+	 * Import Oxid database instance
31
+	 */
32
+	public function __construct($strOxId)
33
+	{
34
+		$this->oxDB = Voucher::getOxDbInstance();
35
+
36
+		$objSQL = $this->oxDB->prepare("SELECT vs.oxid as 'OXSERIEID', vs.OXSERIENR, vs.OXSERIEDESCRIPTION, vs.OXDISCOUNT AS 'OXSERIEDISCOUNT', vs.OXSTARTDATE, vs.OXRELEASEDATE, UNIX_TIMESTAMP(vs.OXBEGINDATE) as 'OXBEGINDATE', UNIX_TIMESTAMP(vs.OXENDDATE) as 'OXENDDATE', v.OXID, UNIX_TIMESTAMP(v.OXDATEUSED) as 'OXDATEUSED', v.OXORDERID, v.OXUSERID, v.OXVOUCHERNR, v.OXDISCOUNT FROM oxvouchers as v, oxvoucherseries as vs WHERE vs.OXID = v.OXVOUCHERSERIEID AND v.OXID = ?");
37
+
38
+		$objResult = $objSQL->execute($strOxId);
39
+
40
+		if ($objResult->numRows)
41
+		{
42
+			$this->arrVoucher = $objResult->row();
43
+		}
44
+
45
+		parent::__construct();
46
+	}
47
+
48
+	function __get($name)
49
+	{
50
+		if ($this->arrVoucher[strtoupper($name)])
51
+		{
52
+			return $this->arrVoucher[strtoupper($name)];
53
+		}
54
+		return null;
55
+	}
56
+
57
+
58
+	public function isValid()
59
+	{
60
+		if ((is_null($this->oxorderid) || $this->oxorderid == '') && (is_null($this->oxdateused)) AND $this->getRemainingVal() > 0 && $this->isValidTime())
61
+		{
62
+			return true;
63
+		}
64
+		return false;
65
+	}
66
+
67
+	public function isValidTime()
68
+	{
69
+		$Today = new \Date();
70
+		if ((is_null($this->oxbegindate) || $this->oxbegindate <= $Today->tstamp) && (is_null($this->oxenddate) || $this->oxenddate >= $Today->tstamp))
71
+		{
72
+			return true;
73
+		}
74
+		return false;
75
+	}
76
+
77
+
78
+	public function getUsedVal()
79
+	{
80
+		// Voucher remaining value
81
+		$objSQL = $this->oxDB->prepare("SELECT SUM(OXDISCOUNT) as 'USEDDISCOUNT' FROM oxvouchers_usage WHERE OXDATEUSED > 0 AND OXVOUCHERID = ?");
82
+		$objResult = $objSQL->execute($this->oxid);
83
+
84
+		if ($objResult->numRows < 1)
85
+		{
86
+			$fUsedVal = 0.00;
87
+		} else {
88
+			$fUsedVal = floatval($objResult->USEDDISCOUNT);
89
+		}
90
+
91
+		return $fUsedVal;
92
+	}
93
+
94
+	public function getRemainingVal()
95
+	{
96
+		return $this->oxseriediscount - $this->getUsedVal();
97
+	}
98
+
99
+	public function deductValue($fVal)
100
+	{
101
+		$fRemainingVal = $this->getRemainingVal();
102
+		if ($fVal > $fRemainingVal)
103
+		{
104
+			$fVal = $fRemainingVal;
105
+		}
106
+
107
+		$arrData = array
108
+		(
109
+			'OXVOUCHERID'   => \Input::post('OXID'),
110
+			'OXDATEUSED'    => date('Y-m-d'),
111
+			'OXORDERID'     => '_BARVERKAUF_',
112
+			'OXDISCOUNT'    => $fVal,
113
+		);
114
+		$objSQL = $this->oxDB->prepare("INSERT INTO oxvouchers_usage %s");
115
+		$objSQL->set($arrData)->execute();
116
+
117
+		if ($fVal == $fRemainingVal)
118
+		{
119
+			$arrData = array
120
+			(
121
+				'OXDATEUSED'    => date('Y-m-d'),
122
+				'OXORDERID'     => '_BARVERKAUF_',
123
+				'OXDISCOUNT'    => $this->oxseriediscount,
124
+			);
125
+			$objSQL = $this->oxDB->prepare("UPDATE oxvouchers %s WHERE OXID = ?");
126
+			$objSQL->set($arrData)->execute($this->oxid);
127
+		}
128
+	}
129
+}
0 130
\ No newline at end of file
1 131
new file mode 100644
... ...
@@ -0,0 +1,11 @@
1
+;;
2
+; List modules which are required to be loaded beforehand
3
+;;
4
+requires[] = "core"
5
+
6
+;;
7
+; Configure what you want the autoload creator to register
8
+;;
9
+register_namespaces = true
10
+register_classes    = true
11
+register_templates  = true
0 12
new file mode 100644
... ...
@@ -0,0 +1,49 @@
1
+<?php
2
+
3
+/**
4
+ * Contao Open Source CMS
5
+ *
6
+ * Copyright (c) 2005-2015 Leo Feyer
7
+ *
8
+ * @license LGPL-3.0+
9
+ */
10
+
11
+
12
+/**
13
+ * Register the namespaces
14
+ */
15
+ClassLoader::addNamespaces(array
16
+(
17
+	'eSM_oxVoucher',
18
+));
19
+
20
+
21
+/**
22
+ * Register the classes
23
+ */
24
+ClassLoader::addClasses(array
25
+(
26
+	// Classes
27
+	'eSM_oxVoucher\Voucher'              => 'system/modules/eSM_oxVoucher/classes/Voucher.php',
28
+	'eSM_oxVoucher\VoucherHandler'       => 'system/modules/eSM_oxVoucher/classes/VoucherHandler.php',
29
+	'eSM_oxVoucher\TicketHandler'        => 'system/modules/eSM_oxVoucher/classes/TicketHandler.php',
30
+
31
+	// Modules
32
+	'eSM_oxVoucher\ModuleVoucher'        => 'system/modules/eSM_oxVoucher/modules/ModuleVoucher.php',
33
+	'eSM_oxVoucher\ModuleVoucherSearch'  => 'system/modules/eSM_oxVoucher/modules/ModuleVoucherSearch.php',
34
+	'eSM_oxVoucher\ModuleVoucherDetails' => 'system/modules/eSM_oxVoucher/modules/ModuleVoucherDetails.php',
35
+	'eSM_oxVoucher\ModuleTicketSelect'   => 'system/modules/eSM_oxVoucher/modules/ModuleTicketSelect.php',
36
+	'eSM_oxVoucher\ModuleTicketDetails'  => 'system/modules/eSM_oxVoucher/modules/ModuleTicketDetails.php',
37
+));
38
+
39
+
40
+/**
41
+ * Register the templates
42
+ */
43
+TemplateLoader::addFiles(array
44
+(
45
+	'mod_oxvoucher_search'  => 'system/modules/eSM_oxVoucher/templates/modules',
46
+	'mod_oxvoucher_details' => 'system/modules/eSM_oxVoucher/templates/modules',
47
+	'mod_oxticket_select'   => 'system/modules/eSM_oxVoucher/templates/modules',
48
+	'mod_oxticket_details'  => 'system/modules/eSM_oxVoucher/templates/modules',
49
+));
0 50
new file mode 100644
... ...
@@ -0,0 +1,32 @@
1
+<?php
2
+
3
+/**
4
+ * eSales Media oxVoucher for Contao Open Source CMS
5
+ *
6
+ * Copyright (c) 2015 eSales Media
7
+ *
8
+ * @author  Benjamin Roth [benjamin@esales-media.de]
9
+ * @license proprietary
10
+ */
11
+
12
+$GLOBALS['FE_MOD']['oxVoucher'] = array
13
+(
14
+	'oxvoucher_search'      => 'ModuleVoucherSearch',
15
+	'oxvoucher_details'     => 'ModuleVoucherDetails',
16
+	'oxticket_select'       => 'ModuleTicketSelect',
17
+	'oxticket_details'      => 'ModuleTicketDetails',
18
+);
19
+
20
+$GLOBALS['oxvoucher']['db_config'] = array
21
+(
22
+	'dbDriver'   => \Config::get('dbDriver'),
23
+	'dbHost'     => 'localhost',
24
+	'dbUser'     => 'esale_DEMO_OXID',
25
+	'dbPass'     => 'Kr9b~o75',
26
+	'dbDatabase' => 'esalesmedia_DEMO_OXID',
27
+	'dbPconnect' => \Config::get('dbPconnect'),
28
+	'dbCharset'  => 'UTF8',
29
+	'dbPort'     => '3306',
30
+	'dbSocket'   => '/var/lib/mysql/mysql.sock',
31
+	'dbSqlMode'  => \Config::get('dbSqlMode')
32
+);
0 33
\ No newline at end of file
1 34
new file mode 100644
... ...
@@ -0,0 +1,44 @@
1
+<?php
2
+/**
3
+ * eSales Media oxVoucher for Contao Open Source CMS
4
+ *
5
+ * Copyright (c) 2015 eSales Media
6
+ *
7
+ * @author  Benjamin Roth [benjamin@esales-media.de]
8
+ * @license proprietary
9
+ */
10
+
11
+$GLOBALS['TL_DCA']['tl_module']['palettes']['oxvoucher_search'] = '{title_legend},name,headline,type;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space';
12
+$GLOBALS['TL_DCA']['tl_module']['palettes']['oxvoucher_details'] = '{title_legend},name,headline,type;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space';
13
+$GLOBALS['TL_DCA']['tl_module']['palettes']['oxticket_select'] = '{title_legend},name,headline,type;{oxticket_legend},oxticket_category;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space';
14
+$GLOBALS['TL_DCA']['tl_module']['palettes']['oxticket_details'] = '{title_legend},name,headline,type;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space';
15
+
16
+$GLOBALS['TL_DCA']['tl_module']['fields']['oxticket_category'] = array
17
+(
18
+	'label' => &$GLOBALS['TL_LANG']['tl_module']['oxticket_category'],
19
+	'exclude' => true,
20
+	'inputType' => 'select',
21
+	'options_callback' => array('tl_module_oxvoucher', 'getOxCategories'),
22
+	'eval' => array('chosen' => true, 'mandatory'=>true),
23
+	'sql' => "varchar(32) NOT NULL default ''"
24
+);
25
+
26
+class tl_module_oxvoucher extends \Backend {
27
+
28
+	public function getOxCategories()
29
+	{
30
+		$oxDB = \Voucher::getOxDbInstance();
31
+		$arrCategories = array();
32
+
33
+		$objResult = $oxDB->execute("SELECT OXID, OXTITLE FROM oxcategories WHERE OXACTIVE = '1' ORDER BY OXTITLE");
34
+
35
+		if ($objResult->numRows)
36
+		{
37
+			while ($objResult->next())
38
+			{
39
+				$arrCategories[$objResult->OXID] = $objResult->OXTITLE;
40
+			}
41
+		}
42
+		return $arrCategories;
43
+	}
44
+}
0 45
\ No newline at end of file
1 46
new file mode 100644
... ...
@@ -0,0 +1,64 @@
1
+<?php
2
+/**
3
+ * eSales Media oxVoucher for Contao Open Source CMS
4
+ *
5
+ * Copyright (c) 2015 eSales Media
6
+ *
7
+ * @author  Benjamin Roth [benjamin@esales-media.de]
8
+ * @license proprietary
9
+ */
10
+
11
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['searchLabel'] = 'Gutscheincode';
12
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['valueLabel'] = 'Teilbetrag';
13
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['maxValueLabel'] = 'verbleibende <strong>%s &euro;</strong> komplett einlösen';
14
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['searchSubmitLabel'] = 'Suchen';
15
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['deductSubmitLabel'] = 'Betrag einlösen';
16
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['noVoucher'] = '<h2>Gutschein nicht gefunden</h2><p>Unter der Nummer <strong>%s</strong> ist kein Gutschein vorhanden oder dieser ist nicht mehr gültig bzw. nicht für die Nutzung im Barverkauf verwendbar.</p>';
17
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['supplyVoucherNo'] = '<h2>Gutscheincode eingeben</h2><p>Bitte geben Sie einen Gutscheincode in das Suchfeld ein.</p>';
18
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['invalid'] = '<p class="invalid">Dieser Gutschein hat kein Restguthaben mehr und ist entwertet.</p>';
19
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['invalid_used'] = '<p class="invalid">Dieser Gutschein wurde am %s eingelöst und ist entwertet.</p>';
20
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['invalid_date'] = '<p class="invalid">Dieser Gutschein ist nicht mehr oder noch nicht gültig.</p>';
21
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['detailsTitle'] = 'Gutscheindetails';
22
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['deductTitle'] = 'Gutschein einlösen';
23
+
24
+
25
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblVoucherNo'] = 'Gutscheinnummer';
26
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblSerieNo'] = 'Gutscheinserie';
27
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblSerieDesc'] = 'Beschreibung';
28
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblSerieDiscount'] = 'Orig. Gutscheinwert';
29
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblValidFrom'] = 'Gültig ab';
30
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblValidTil'] = 'Gültig bis';
31
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblRemainingVal'] = 'Verbl. Guthaben';
32
+
33
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['voucher_confirm'] = 'Der Betrag von %s &euro; wurde vom Gutschein abgezogen. Es verbleiben noch %s &euro; Guthaben.';
34
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['voucher_confirm_depleted'] = 'Der Betrag von %s &euro; wurde vom Gutschein abgezogen. Der Gutschein ist jetzt komplett entwertet.';
35
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['voucher_error_gtv'] = 'Der Betrag von %s &euro; konnte nicht vom Gutschein abgezogen werden. Der verfügbare Gutscheinbetrag ist geringer!';
36
+$GLOBALS['TL_LANG']['MSC']['oxVoucher']['voucher_error_zero'] = 'Bitte geben Sie einen Betrag ein der größer als 0 &euro; ist!';
37
+
38
+
39
+
40
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['selectLabel'] = 'Tickets';
41
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['valueLabel'] = 'Anzahl';
42
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['submitLabel'] = 'Ticket laden';
43
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['sellSubmitLabel'] = 'Ticketkauf verbuchen';
44
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['noTicket'] = '<h2>Ticket nicht gefunden</h2><p>Das Ticket mit der ID <strong>%s</strong> kann leider nicht geladen werden.</p>';
45
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['outofstock'] = '<p class="invalid">Dieses Ticket ist ausverkauft!</p>';
46
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['notActiveTime'] = '<p class="invalid">Dieses Ticket kann nicht gekauft werden. Bitte den Verkaufszeitraum beachten.</p>';
47
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['notActive'] = '<p class="invalid">Dieses Ticket ist derzeit vom Verkauf ausgeschlossen.</p>';
48
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['notBuyable'] = '<p class="invalid">Dieses Ticket kann nicht gekauft werden.</p>';
49
+
50
+
51
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['lblTitle'] = 'Titel';
52
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['lblShortDesc'] = 'Kurzbeschreibung';
53
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['lblActiveFrom'] = 'Kaufbar ab';
54
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['lblActiveTo'] = 'Kaufbar bis';
55
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['lblSellTo'] = 'Verkauf im Onlineshop bis';
56
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['lblStock'] = 'Karten verfügbar';
57
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['lblPrice'] = 'Preis pro Karte';
58
+
59
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['detailsTitle'] = 'Eintrittskartendetails';
60
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['sellTitle'] = 'Eintrittskarten-Abverkauf';
61
+
62
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['not_a_natural'] = 'Bitte geben Sie eine Anzahl größer 0 ein!';
63
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['stock_is_less'] = 'Die Eintrittskarten konnten nicht verbucht werden. Der Warenbestand ist kleiner als die zu verbuchende Anzahl %s!';
64
+$GLOBALS['TL_LANG']['MSC']['oxTicket']['ticket_confirm'] = 'Der Warenbestand der Eintrittskarten wurde um %s verringert. Es verbleiben noch %s Eintrittskarten.';
0 65
\ No newline at end of file
1 66
new file mode 100644
... ...
@@ -0,0 +1,19 @@
1
+<?php
2
+/**
3
+ * eSales Media oxVoucher for Contao Open Source CMS
4
+ *
5
+ * Copyright (c) 2015 eSales Media
6
+ *
7
+ * @author  Benjamin Roth [benjamin@esales-media.de]
8
+ * @license proprietary
9
+ */
10
+
11
+$GLOBALS['TL_LANG']['FMD']['oxVoucher'] = 'OXID Gutscheinmodul';
12
+$GLOBALS['TL_LANG']['FMD']['oxvoucher_search'][0] = 'Gutscheinsuche';
13
+$GLOBALS['TL_LANG']['FMD']['oxvoucher_search'][1] = 'Fügt der Seite ein Formular zur Gutscheincode-Suche hinzu';
14
+$GLOBALS['TL_LANG']['FMD']['oxvoucher_details'][0] = 'Gutscheindetails';
15
+$GLOBALS['TL_LANG']['FMD']['oxvoucher_details'][1] = 'Zeigt die Gutscheindetails an und bietet die Möglichkeit den Gutschein ganz oder teilweise zu entwerten.';
16
+$GLOBALS['TL_LANG']['FMD']['oxticket_select'][0] = 'Eintrittskartenauswahl';
17
+$GLOBALS['TL_LANG']['FMD']['oxticket_select'][1] = 'Fügt der Seite ein Formular zur Auswahl einer Eintrittskarte hinzu.';
18
+$GLOBALS['TL_LANG']['FMD']['oxticket_details'][0] = 'Eintrittskartendetails';
19
+$GLOBALS['TL_LANG']['FMD']['oxticket_details'][1] = 'Zeigt die Eintrittskartendetails an und bietet die Möglichkeit den Lagerbestand zu reduzieren.';
0 20
new file mode 100644
... ...
@@ -0,0 +1,14 @@
1
+<?php
2
+/**
3
+ * eSales Media oxVoucher for Contao Open Source CMS
4
+ *
5
+ * Copyright (c) 2015 eSales Media
6
+ *
7
+ * @author  Benjamin Roth [benjamin@esales-media.de]
8
+ * @license proprietary
9
+ */
10
+
11
+$GLOBALS['TL_LANG']['tl_module']['oxticket_category'][0] = 'OXID Kategorie';
12
+$GLOBALS['TL_LANG']['tl_module']['oxticket_category'][1] = 'OXID Kategorie, welche sämtliche Eintrittskarten beinhaltet';
13
+
14
+$GLOBALS['TL_LANG']['tl_module']['oxticket_legend'] = 'Eintrittskarten-Konfiguration';
0 15
\ No newline at end of file
1 16
new file mode 100644
... ...
@@ -0,0 +1,161 @@
1
+<?php
2
+
3
+/**
4
+ * eSales Media oxVoucher for Contao Open Source CMS
5
+ *
6
+ * Copyright (c) 2015 eSales Media
7
+ *
8
+ * @author  Benjamin Roth [benjamin@esales-media.de]
9
+ * @license proprietary
10
+ */
11
+
12
+namespace eSM_oxVoucher;
13
+
14
+class ModuleTicketDetails extends ModuleVoucher
15
+{
16
+	/**
17
+	 * Template
18
+	 * @var string
19
+	 */
20
+	protected $strTemplate = 'mod_oxticket_details';
21
+
22
+	protected $blnHide = false;
23
+
24
+	/**
25
+	 * Parse the template
26
+	 * @return string
27
+	 */
28
+	public function generate()
29
+	{
30
+		if (TL_MODE == 'BE')
31
+		{
32
+			/** @var \BackendTemplate|object $objTemplate */
33
+			$objTemplate = new \BackendTemplate('be_wildcard');
34
+
35
+			$objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['oxticket_details'][0]) . ' ###';
36
+			$objTemplate->title = $this->headline;
37
+			$objTemplate->id = $this->id;
38
+			$objTemplate->link = $this->name;
39
+			$objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
40
+
41
+			return $objTemplate->parse();
42
+		}
43
+
44
+		$this->importOxDbInstance();
45
+
46
+		$strBuffer = parent::generate();
47
+
48
+		if (!$this->blnHide)
49
+		{
50
+			return $strBuffer;
51
+		}
52
+	}
53
+
54
+
55
+	/**
56
+	 * Compile the current element
57
+	 */
58
+	protected function compile()
59
+	{
60
+		if (\Input::get('ticket_select') || \Input::post('FORM_SUBMIT') == 'eSM_oxTicket_details')
61
+		{
62
+			$objSQL = $this->oxDB->prepare("SELECT OXID FROM oxarticles WHERE OXID = ?");
63
+			if (\Input::post('FORM_SUBMIT') == 'eSM_oxTicket_details')
64
+			{
65
+				$objTicket = $objSQL->execute(strtolower(\Input::post('OXID')));
66
+			} else
67
+			{
68
+				$objTicket = $objSQL->execute(strtolower(\Input::get('ticket_select')));
69
+			}
70
+
71
+			if ($objTicket->numRows < 1 || $objTicket->numRows > 1)
72
+			{
73
+				if (\Input::get('ticket_select'))
74
+				{
75
+					$this->Template->noTicket = sprintf($GLOBALS['TL_LANG']['MSC']['oxTicket']['noTicket'], \Input::get('ticket_select'));
76
+				}
77
+				return;
78
+			}
79
+
80
+			$objTicket = new TicketHandler($objTicket->OXID);
81
+
82
+
83
+			// Update voucher
84
+			if (\Input::post('FORM_SUBMIT') == 'eSM_oxTicket_details')
85
+			{
86
+
87
+				if (!\Validator::isNatural(\Input::post('ticket_sellamount')) || \Input::post('ticket_sellamount') < 1)
88
+				{
89
+					$strMessage = $GLOBALS['TL_LANG']['MSC']['oxTicket']['not_a_natural'];
90
+					$strType = 'error';
91
+				} else if (\Input::post('ticket_sellamount') > $objTicket->oxstock) {
92
+					$strMessage = sprintf($GLOBALS['TL_LANG']['MSC']['oxTicket']['stock_is_less'],\Input::post('ticket_sellamount'));
93
+					$strType = 'error';
94
+				} else {
95
+					$objTicket->reduceStock(\Input::post('ticket_sellamount'));
96
+					$strMessage = sprintf($GLOBALS['TL_LANG']['MSC']['oxTicket']['ticket_confirm'],\Input::post('ticket_sellamount'),$objTicket->oxstock);
97
+					$strType = 'confirm';
98
+				}
99
+
100
+				$this->setMessage($strMessage, $strType);
101
+				$this->reload();
102
+			}
103
+
104
+			// Template Vars
105
+			$blnInvalid = false;
106
+			if (!$objTicket->isBuyable())
107
+			{
108
+				$blnInvalid = true;
109
+				if ($objTicket->oxstock <= 0)
110
+				{
111
+					$strInvalid = $GLOBALS['TL_LANG']['MSC']['oxTicket']['outofstock'];
112
+				} else if (!$objTicket->isActiveTime()) {
113
+					$strInvalid = $GLOBALS['TL_LANG']['MSC']['oxTicket']['notActiveTime'];
114
+				} else if (!$objTicket->oxactive) {
115
+					$strInvalid = $GLOBALS['TL_LANG']['MSC']['oxTicket']['notActive'];
116
+				} else {
117
+					$strInvalid = $GLOBALS['TL_LANG']['MSC']['oxTicket']['notBuyable'];
118
+				}
119
+			}
120
+			$arrData = array
121
+			(
122
+				'titleDetails'      => $GLOBALS['TL_LANG']['MSC']['oxTicket']['detailsTitle'],
123
+				'titleSell'         => $GLOBALS['TL_LANG']['MSC']['oxTicket']['sellTitle'],
124
+
125
+				'lblTitle'          => $GLOBALS['TL_LANG']['MSC']['oxTicket']['lblTitle'],
126
+				'lblShortDesc'      => $GLOBALS['TL_LANG']['MSC']['oxTicket']['lblShortDesc'],
127
+				'lblActiveFrom'     => $GLOBALS['TL_LANG']['MSC']['oxTicket']['lblActiveFrom'],
128
+				'lblActiveTo'       => $GLOBALS['TL_LANG']['MSC']['oxTicket']['lblActiveTo'],
129
+				'lblSellTo'         => $GLOBALS['TL_LANG']['MSC']['oxTicket']['lblSellTo'],
130
+				'lblStock'          => $GLOBALS['TL_LANG']['MSC']['oxTicket']['lblStock'],
131
+				'lblPrice'          => $GLOBALS['TL_LANG']['MSC']['oxTicket']['lblPrice'],
132
+
133
+				'ticketOxid'        => $objTicket->oxid,
134
+				'ticketTitle'       => ($objTicket->isVariant() ? $objTicket->oxparenttitle.' '.$objTicket->oxvarselect : $objTicket->oxtitle),
135
+				'ticketShortDesc'   => ($objTicket->isVariant() && !$objTicket->oxshortdesc ? $objTicket->oxparentshortdesc : $objTicket->oxshortdesc),
136
+				'activeFrom'        => (!is_null($objTicket->oxactivefrom) ? \Date::parse(\Date::getNumericDatimFormat(),$objTicket->oxactivefrom) : ''),
137
+				'activeTo'          => (!is_null($objTicket->oxactiveto) ? \Date::parse(\Date::getNumericDatimFormat(),$objTicket->oxactiveto) : ''),
138
+				'sellTo'            => (!is_null($objTicket->oxesselluntil) ? \Date::parse(\Date::getNumericDatimFormat(),$objTicket->oxesselluntil) : ''),
139
+				'ticketStock'       => $objTicket->oxstock,
140
+				'ticketPrice'       => $this->getFormattedNumber($objTicket->oxprice),
141
+
142
+				'submitLabel'       => $GLOBALS['TL_LANG']['MSC']['oxTicket']['sellSubmitLabel'],
143
+				'valueLabel'        => $GLOBALS['TL_LANG']['MSC']['oxTicket']['valueLabel'],
144
+
145
+				'invalid'           => $blnInvalid,
146
+				'invalidStatus'     => $strInvalid,
147
+
148
+				'messages'          => $this->getMessages(),
149
+			);
150
+
151
+			$this->Template->setData($arrData);
152
+		} else
153
+		{
154
+
155
+			$this->blnHide = true;
156
+		}
157
+
158
+
159
+	}
160
+
161
+}
0 162
\ No newline at end of file
1 163
new file mode 100644
... ...
@@ -0,0 +1,71 @@
1
+<?php
2
+
3
+/**
4
+ * eSales Media oxVoucher for Contao Open Source CMS
5
+ *
6
+ * Copyright (c) 2015 eSales Media
7
+ *
8
+ * @author  Benjamin Roth [benjamin@esales-media.de]
9
+ * @license proprietary
10
+ */
11
+
12
+namespace eSM_oxVoucher;
13
+
14
+class ModuleTicketSelect extends ModuleVoucher
15
+{
16
+	/**
17
+	 * Template
18
+	 * @var string
19
+	 */
20
+	protected $strTemplate = 'mod_oxticket_select';
21
+
22
+	/**
23
+	 * Parse the template
24
+	 * @return string
25
+	 */
26
+	public function generate()
27
+	{
28
+		if (TL_MODE == 'BE')
29
+		{
30
+			/** @var \BackendTemplate|object $objTemplate */
31
+			$objTemplate = new \BackendTemplate('be_wildcard');
32
+
33
+			$objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['oxticket_select'][0]) . ' ###';
34
+			$objTemplate->title = $this->headline;
35
+			$objTemplate->id = $this->id;
36
+			$objTemplate->link = $this->name;
37
+			$objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
38
+
39
+			return $objTemplate->parse();
40
+		}
41
+
42
+		$this->importOxDbInstance();
43
+
44
+		return parent::generate();
45
+	}
46
+
47
+
48
+	/**
49
+	 * Compile the current element
50
+	 */
51
+	protected function compile()
52
+	{
53
+		$arrTickets = array();
54
+		if ($this->oxticket_category)
55
+		{
56
+			$objStatement = $this->oxDB->prepare("SELECT a.OXID, a.OXTITLE, a.OXVARSELECT, a.OXPARENTID, pa.OXTITLE AS PARENTTITLE FROM oxv_oxarticles_de a JOIN oxobject2category ac ON a.OXID = ac.OXOBJECTID OR a.OXPARENTID = ac.OXOBJECTID LEFT JOIN oxv_oxarticles_de AS pa ON pa.OXID = a.OXPARENTID AND a.OXPARENTID != '' WHERE ac.OXCATNID = ? AND (a.OXACTIVE = '1' OR (a.OXACTIVETO IS NOT NULL AND a.OXACTIVETO != '0000-00-00 00:00:00' AND a.OXACTIVETO >= ?)) AND ((a.OXPARENTID = '' AND (SELECT COUNT(sa.OXID) FROM oxarticles sa WHERE sa.OXPARENTID = a.OXID) < 1) OR a.OXPARENTID != '') ORDER BY a.OXTITLE, PARENTTITLE, a.OXVARSELECT ");
57
+
58
+			$objResult = $objStatement->execute($this->oxticket_category,date('Y-m-d H:i:s'));
59
+
60
+			if ($objResult->numRows)
61
+			{
62
+				$arrTickets = $objResult->fetchAllAssoc();
63
+			}
64
+		}
65
+
66
+		$this->Template->selectOptions = $arrTickets;
67
+		$this->Template->selectLabel = $GLOBALS['TL_LANG']['MSC']['oxTicket']['selectLabel'];
68
+		$this->Template->submitLabel = $GLOBALS['TL_LANG']['MSC']['oxTicket']['submitLabel'];
69
+	}
70
+
71
+}
0 72
\ No newline at end of file
1 73
new file mode 100644
... ...
@@ -0,0 +1,73 @@
1
+<?php
2
+
3
+/**
4
+ * eSales Media oxVoucher for Contao Open Source CMS
5
+ *
6
+ * Copyright (c) 2015 eSales Media
7
+ *
8
+ * @author  Benjamin Roth [benjamin@esales-media.de]
9
+ * @license proprietary
10
+ */
11
+
12
+namespace eSM_oxVoucher;
13
+
14
+abstract class ModuleVoucher extends \Module
15
+{
16
+
17
+	/**
18
+	 * Oxid Database Object
19
+	 * @var \Database|null
20
+	 */
21
+	protected $oxDB = null;
22
+
23
+	/**
24
+	 * Import Oxid database instance
25
+	 */
26
+	protected function importOxDbInstance()
27
+	{
28
+		$this->oxDB = Voucher::getOxDbInstance();
29
+	}
30
+
31
+	protected function setMessage($strMessage, $strType = 'info')
32
+	{
33
+
34
+		$strType = strtolower($strType);
35
+
36
+		if ($strMessage == '')
37
+		{
38
+			return;
39
+		}
40
+
41
+		if (!in_array(strtolower($strType), array('confirm','info','error')))
42
+		{
43
+			throw new \Exception("Invalid message type $strType");
44
+		}
45
+
46
+		if (!is_array($_SESSION['eSM_oxVoucher'][$strType]))
47
+		{
48
+			$_SESSION['eSM_oxVoucher'][$strType] = array();
49
+		}
50
+
51
+		$_SESSION['eSM_oxVoucher'][$strType][] = $strMessage;
52
+	}
53
+
54
+	protected function getMessages()
55
+	{
56
+		$strMessages = '';
57
+
58
+		foreach (array('confirm','info','error') as $strType)
59
+		{
60
+			if ($_SESSION['eSM_oxVoucher'][$strType])
61
+			{
62
+				foreach ($_SESSION['eSM_oxVoucher'][$strType] as $message)
63
+				{
64
+					$strMessages .= '<p class="'.$strType.'">'.$message.'</p>'."\n";
65
+				}
66
+			}
67
+		}
68
+
69
+		unset($_SESSION['eSM_oxVoucher']);
70
+
71
+		return $strMessages;
72
+	}
73
+}
0 74
\ No newline at end of file
1 75
new file mode 100644
... ...
@@ -0,0 +1,184 @@
1
+<?php
2
+
3
+/**
4
+ * eSales Media oxVoucher for Contao Open Source CMS
5
+ *
6
+ * Copyright (c) 2015 eSales Media
7
+ *
8
+ * @author  Benjamin Roth [benjamin@esales-media.de]
9
+ * @license proprietary
10
+ */
11
+
12
+namespace eSM_oxVoucher;
13
+
14
+class ModuleVoucherDetails extends ModuleVoucher
15
+{
16
+	/**
17
+	 * Template
18
+	 * @var string
19
+	 */
20
+	protected $strTemplate = 'mod_oxvoucher_details';
21
+
22
+	protected $blnHide = false;
23
+
24
+	/**
25
+	 * Parse the template
26
+	 * @return string
27
+	 */
28
+	public function generate()
29
+	{
30
+		if (TL_MODE == 'BE')
31
+		{
32
+			/** @var \BackendTemplate|object $objTemplate */
33
+			$objTemplate = new \BackendTemplate('be_wildcard');
34
+
35
+			$objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['oxvoucher_details'][0]) . ' ###';
36
+			$objTemplate->title = $this->headline;
37
+			$objTemplate->id = $this->id;
38
+			$objTemplate->link = $this->name;
39
+			$objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
40
+
41
+			return $objTemplate->parse();
42
+		}
43
+
44
+		$this->importOxDbInstance();
45
+
46
+		$strBuffer = parent::generate();
47
+
48
+		if (!$this->blnHide)
49
+		{
50
+			return $strBuffer;
51
+		}
52
+	}
53
+
54
+
55
+	/**
56
+	 * Compile the current element
57
+	 */
58
+	protected function compile()
59
+	{
60
+		if (\Input::get('voucher_search') || \Input::post('FORM_SUBMIT') == 'eSM_oxVoucher_details')
61
+		{
62
+			if (\Input::post('FORM_SUBMIT') == 'eSM_oxVoucher_details')
63
+			{
64
+				$objSQL = $this->oxDB->prepare("SELECT v.* FROM oxvouchers v, oxvoucherseries vs WHERE vs.OXID = v.OXVOUCHERSERIEID AND LOWER(v.OXID) = ? AND vs.OXDISCOUNTTYPE = 'absolute'");
65
+				$objVoucher = $objSQL->execute(strtolower(\Input::post('OXID')));
66
+			} else {
67
+				$objSQL = $this->oxDB->prepare("SELECT v.* FROM oxvouchers v, oxvoucherseries vs WHERE vs.OXID = v.OXVOUCHERSERIEID AND LOWER(v.OXVOUCHERNR) = ? AND vs.OXDISCOUNTTYPE = 'absolute'");
68
+				$objVoucher = $objSQL->execute(strtolower(\Input::get('voucher_search')));
69
+			}
70
+
71
+			if ($objVoucher->numRows < 1 || $objVoucher->numRows > 1)
72
+			{
73
+				if (!\Input::get('voucher_search'))
74
+				{
75
+					$this->Template->noVoucher = $GLOBALS['TL_LANG']['MSC']['oxVoucher']['supplyVoucherNo'];
76
+				} else {
77
+					$this->Template->noVoucher = sprintf($GLOBALS['TL_LANG']['MSC']['oxVoucher']['noVoucher'],\Input::get('voucher_search'));
78
+				}
79
+				return;
80
+			}
81
+
82
+			$objVoucher = new VoucherHandler($objVoucher->OXID);
83
+			$blnIsValid = $objVoucher->isValid();
84
+
85
+			// Voucher remaining value
86
+			$fUsedVal = $objVoucher->getUsedVal();
87
+			$fRemainingVal = ($blnIsValid ? $objVoucher->getRemainingVal() : (!$objVoucher->isValidTime() ? $objVoucher->getRemainingVal() : 0.00));
88
+
89
+			// Update voucher
90
+			if (\Input::post('FORM_SUBMIT') == 'eSM_oxVoucher_details')
91
+			{
92
+				$blnInvalidate = false;
93
+
94
+				if (\Input::post('voucher_deductAll'))
95
+				{
96
+					$fDeductVal = $fRemainingVal;
97
+				} else {
98
+					$fDeductVal = floatval(\Input::post('voucher_deductValue'));
99
+
100
+				}
101
+
102
+				if ($fDeductVal <= $fRemainingVal && $fDeductVal > 0) {
103
+					$objVoucher->deductValue($fDeductVal);
104
+
105
+					$strMessage = sprintf($GLOBALS['TL_LANG']['MSC']['oxVoucher']['voucher_confirm'],$this->getFormattedNumber($fDeductVal),$this->getFormattedNumber($objVoucher->getRemainingVal()));
106
+					$strType = 'confirm';
107
+
108
+					if ($fDeductVal == $fRemainingVal)
109
+					{
110
+						$strMessage = sprintf($GLOBALS['TL_LANG']['MSC']['oxVoucher']['voucher_confirm_depleted'],$this->getFormattedNumber($fDeductVal));
111
+					}
112
+				} else if ($fDeductVal > $fRemainingVal)
113
+				{
114
+					$strMessage = sprintf($GLOBALS['TL_LANG']['MSC']['oxVoucher']['voucher_error_gtv'],$this->getFormattedNumber($fDeductVal),$this->getFormattedNumber($objVoucher->getRemainingVal()));
115
+					$strType = 'error';
116
+				} else
117
+				{
118
+					$strMessage = $GLOBALS['TL_LANG']['MSC']['oxVoucher']['voucher_error_zero'];
119
+					$strType = 'error';
120
+				}
121
+
122
+				$this->setMessage($strMessage,$strType);
123
+				$this->reload();
124
+			}
125
+
126
+
127
+
128
+			// Voucher time
129
+			$Today = new \Date();
130
+
131
+			// Template Vars
132
+			if (!is_null($objVoucher->oxdateused))
133
+			{
134
+				$strInvalid = sprintf($GLOBALS['TL_LANG']['MSC']['oxVoucher']['invalid_used'], \Date::parse(\Date::getNumericDateFormat(), $objVoucher->oxdateused));
135
+			} else if (!$objVoucher->isValidTime()) {
136
+				$strInvalid = $GLOBALS['TL_LANG']['MSC']['oxVoucher']['invalid_date'];
137
+			} else {
138
+				$strInvalid = $GLOBALS['TL_LANG']['MSC']['oxVoucher']['invalid'];
139
+			}
140
+			$arrData = array
141
+			(
142
+				'titleDetails'      => $GLOBALS['TL_LANG']['MSC']['oxVoucher']['detailsTitle'],
143
+				'titleDeduct'       => $GLOBALS['TL_LANG']['MSC']['oxVoucher']['deductTitle'],
144
+
145
+				'lblVoucherNo'      => $GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblVoucherNo'],
146
+				'lblSerieNo'        => $GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblSerieNo'],
147
+				'lblSerieDesc'      => $GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblSerieDesc'],
148
+				'lblSerieDiscount'  => $GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblSerieDiscount'],
149
+				'lblValidFrom'      => $GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblValidFrom'],
150
+				'lblValidTil'       => $GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblValidTil'],
151
+				'lblRemainingVal'   => $GLOBALS['TL_LANG']['MSC']['oxVoucher']['lblRemainingVal'],
152
+
153
+				'voucherOxid'       => $objVoucher->oxid,
154
+				'voucherNo'         => $objVoucher->oxvouchernr,
155
+				'serieNo'           => $objVoucher->oxserienr,
156
+				'serieDesc'         => $objVoucher->oxseriedescription,
157
+				'validFrom'         => (!is_null($objVoucher->oxbegindate) ? \Date::parse(\Date::getNumericDatimFormat(),$objVoucher->oxbegindate) : ''),
158
+				'validTil'          => (!is_null($objVoucher->oxenddate) ? \Date::parse(\Date::getNumericDatimFormat(),$objVoucher->oxenddate) : ''),
159
+				'serieDiscount'     => $this->getFormattedNumber($objVoucher->oxseriediscount),
160
+				'usedVal'           => $fUsedVal,
161
+				'remainingVal'      => $fRemainingVal,
162
+				'fRemainingVal'     => $this->getFormattedNumber($fRemainingVal),
163
+
164
+				'submitLabel'       => $GLOBALS['TL_LANG']['MSC']['oxVoucher']['deductSubmitLabel'],
165
+				'valueLabel'        => $GLOBALS['TL_LANG']['MSC']['oxVoucher']['valueLabel'],
166
+				'maxValueLabel'     => sprintf($GLOBALS['TL_LANG']['MSC']['oxVoucher']['maxValueLabel'],$this->getFormattedNumber($fRemainingVal)),
167
+
168
+				'isValid'           => $blnIsValid,
169
+				'invalid'           => $strInvalid,
170
+
171
+				'messages'          => $this->getMessages(),
172
+			);
173
+
174
+			$this->Template->setData($arrData);
175
+		} else
176
+		{
177
+
178
+			$this->blnHide = true;
179
+		}
180
+
181
+
182
+	}
183
+
184
+}
0 185
\ No newline at end of file
1 186
new file mode 100644
... ...
@@ -0,0 +1,57 @@
1
+<?php
2
+
3
+/**
4
+ * eSales Media oxVoucher for Contao Open Source CMS
5
+ *
6
+ * Copyright (c) 2015 eSales Media
7
+ *
8
+ * @author  Benjamin Roth [benjamin@esales-media.de]
9
+ * @license proprietary
10
+ */
11
+
12
+namespace eSM_oxVoucher;
13
+
14
+class ModuleVoucherSearch extends ModuleVoucher
15
+{
16
+	/**
17
+	 * Template
18
+	 * @var string
19
+	 */
20
+	protected $strTemplate = 'mod_oxvoucher_search';
21
+
22
+	/**
23
+	 * Parse the template
24
+	 * @return string
25
+	 */
26
+	public function generate()
27
+	{
28
+		if (TL_MODE == 'BE')
29
+		{
30
+			/** @var \BackendTemplate|object $objTemplate */
31
+			$objTemplate = new \BackendTemplate('be_wildcard');
32
+
33
+			$objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['oxvoucher_search'][0]) . ' ###';
34
+			$objTemplate->title = $this->headline;
35
+			$objTemplate->id = $this->id;
36
+			$objTemplate->link = $this->name;
37
+			$objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;
38
+
39
+			return $objTemplate->parse();
40
+		}
41
+
42
+		$this->importOxDbInstance();
43
+
44
+		return parent::generate();
45
+	}
46
+
47
+
48
+	/**
49
+	 * Compile the current element
50
+	 */
51
+	protected function compile()
52
+	{
53
+		$this->Template->searchLabel = $GLOBALS['TL_LANG']['MSC']['oxVoucher']['searchLabel'];
54
+		$this->Template->submitLabel = $GLOBALS['TL_LANG']['MSC']['oxVoucher']['searchSubmitLabel'];
55
+	}
56
+
57
+}
0 58
\ No newline at end of file
1 59
new file mode 100644
... ...
@@ -0,0 +1,63 @@
1
+<?php $this->extend('block_searchable'); ?>
2
+
3
+<?php $this->block('content'); ?>
4
+
5
+<?php if ($this->noTicket): ?>
6
+<div class="box icon_left">
7
+	{{icon::fe:error:circle left error}}
8
+	<div>
9
+		<?= $this->noTicket ?>
10
+	</div>
11
+</div>
12
+<?php else: ?>
13
+<?php if ($this->messages): ?>
14
+<div class="box messages">
15
+	<?= $this->messages ?>
16
+</div>
17
+<?php endif; ?>
18
+<div class="eq cf">
19
+	<div class="details">
20
+		<div class="box">
21
+			<h2><?= $this->titleDetails ?></h2>
22
+			<ul>
23
+				<li><span class="label"><?= $this->lblTitle ?>:</span><?= $this->ticketTitle ?></li>
24
+				<li><span class="label"><?= $this->lblStock ?>:</span><span class="highlight<?php if ($this->invalid): ?> invalid<?php endif; ?>"><?= $this->ticketStock ?></span></li>
25
+				<li><span class="label"><?= $this->lblPrice ?>:</span><?= $this->ticketPrice ?> &euro;</li>
26
+				<li><span class="label"><?= $this->lblActiveFrom ?>:</span><?= $this->activeFrom ?></li>
27
+				<li><span class="label"><?= $this->lblActiveTo ?>:</span><?= $this->activeTo ?></li>
28
+				<li><span class="label"><?= $this->lblSellTo ?>:</span><?= $this->sellTo ?></li>
29
+				<li><span class="label"><?= $this->lblShortDesc ?>:</span><?= $this->ticketShortDesc ?></li>
30
+			</ul>
31
+		</div>
32
+	</div>
33
+
34
+	<div class="deduct">
35
+		<div class="box">
36
+			<h2><?= $this->titleSell ?></h2>
37
+			<?php if ($this->invalid): ?>
38
+				<?= $this->invalidStatus ?>
39
+			<?php else: ?>
40
+			<form id="form_oxTitleDetails_<?= $this->id ?>"<?php if ($this->action): ?> action="<?= $this->action ?>"<?php endif; ?> method="post">
41
+				<div class="formbody">
42
+					<input type="hidden" name="FORM_SUBMIT" value="eSM_oxTicket_details">
43
+					<input type="hidden" name="REQUEST_TOKEN" value="{{request_token}}">
44
+					<input type="hidden" name="OXID" value="<?= $this->ticketOxid ?>">
45
+
46
+					<div class="widget widget-text w20">
47
+						<label for="ticket_sellamount_<?= $this->id ?>"><?= $this->valueLabel ?></label>
48
+						<input type="number" name="ticket_sellamount" id="ticket_sellamount_<?= $this->id ?>" min="1" step="1" max="<?= $this->ticketStock ?>" value="0"/>
49
+					</div>
50
+
51
+					<div class="submit_container widget lblp button_block">
52
+						<button type="submit" class="submit"><?= $this->submitLabel ?></button>
53
+					</div>
54
+				</div>
55
+			</form>
56
+			<?php endif; ?>
57
+		</div>
58
+	</div>
59
+</div>
60
+
61
+<?php endif; ?>
62
+
63
+<?php $this->endblock(); ?>
0 64
new file mode 100644
... ...
@@ -0,0 +1,23 @@
1
+<?php $this->extend('block_searchable'); ?>
2
+
3
+<?php $this->block('content'); ?>
4
+
5
+<form id="form_oxTicketSelect_<?= $this->id ?>"<?php if ($this->action): ?> action="<?= $this->action ?>"<?php endif; ?> method="get">
6
+  <div class="formbody">
7
+	  <div class="widget widget-select w100">
8
+		  <label for="ticket_select_<?= $this->id ?>"><?= $this->selectLabel ?></label>
9
+		  <select class="select" name="ticket_select" id="ticket_select_<?= $this->id ?>">
10
+			  <option value="">-</option>
11
+			  <?php foreach ($this->selectOptions as $option): ?>
12
+			  <option value="<?= $option['OXID'] ?>"<?php if (\Input::get('ticket_select') && \Input::get('ticket_select') == $option['OXID']): ?> selected<?php endif; ?>><?php echo ($option['PARENTTITLE'] ? $option['PARENTTITLE'].' '.$option['OXVARSELECT'] : $option['OXTITLE']); ?></option>
13
+			  <?php endforeach; ?>
14
+		  </select>
15
+	  </div>
16
+
17
+	  <div class="submit_container widget lblp button_block">
18
+		  <button type="submit" class="submit"><?= $this->submitLabel ?></button>
19
+	  </div>
20
+  </div>
21
+</form>
22
+
23
+<?php $this->endblock(); ?>
0 24
new file mode 100644
... ...
@@ -0,0 +1,78 @@
1
+<?php $this->extend('block_searchable'); ?>
2
+
3
+<?php $this->block('content'); ?>
4
+
5
+<?php if ($this->noVoucher): ?>
6
+<div class="box icon_left">
7
+	{{icon::fe:error:circle left error}}
8
+	<div>
9
+		<?= $this->noVoucher ?>
10
+	</div>
11
+</div>
12
+<?php else: ?>
13
+<?php if ($this->messages): ?>
14
+<div class="box messages">
15
+	<?= $this->messages ?>
16
+</div>
17
+<?php endif; ?>
18
+<div class="eq cf">
19
+	<div class="details">
20
+		<div class="box">
21
+			<h2><?= $this->titleDetails ?></h2>
22
+			<ul>
23
+				<li><span class="label"><?= $this->lblVoucherNo ?>:</span><?= $this->voucherNo ?></li>
24
+				<li><span class="label"><?= $this->lblRemainingVal ?>:</span><span class="highlight<?php if (!$this->isValid): ?> invalid<?php endif; ?>"><?= $this->fRemainingVal ?> &euro;</span></li>
25
+				<li><span class="label"><?= $this->lblSerieNo ?>:</span><?= $this->serieNo ?></li>
26
+				<li><span class="label"><?= $this->lblSerieDiscount ?>:</span><?= $this->serieDiscount ?> &euro;</li>
27
+				<li><span class="label"><?= $this->lblValidFrom ?>:</span><?= $this->validFrom ?></li>
28
+				<li><span class="label"><?= $this->lblValidTil ?>:</span><?= $this->validTil ?></li>
29
+			</ul>
30
+		</div>
31
+	</div>
32
+
33
+	<div class="deduct">
34
+		<div class="box">
35
+			<h2><?= $this->titleDeduct ?></h2>
36
+			<?php if (!$this->isValid): ?>
37
+				<?= $this->invalid ?>
38
+			<?php else: ?>
39
+			<form id="form_oxVoucherDetails_<?= $this->id ?>"<?php if ($this->action): ?> action="<?= $this->action ?>"<?php endif; ?> method="post">
40
+				<div class="formbody">
41
+					<input type="hidden" name="FORM_SUBMIT" value="eSM_oxVoucher_details">
42
+					<input type="hidden" name="REQUEST_TOKEN" value="{{request_token}}">
43
+					<input type="hidden" name="OXID" value="<?= $this->voucherOxid ?>">
44
+
45
+					<div class="widget widget-text w20">
46
+						<label for="voucher_deductValue_<?= $this->id ?>"><?= $this->valueLabel ?></label>
47
+						<input type="number" name="voucher_deductValue" id="voucher_deductValue_<?= $this->id ?>" min="0.00" step="0.01" max="<?= $this->remainingVal ?>" value="0"/>
48
+					</div>
49
+
50
+					<div class="widget widget-checkbox w100 clr">
51
+						<input type="checkbox" name="voucher_deductAll" id="voucher_deductAll_<?= $this->id ?>" value="1"/>
52
+						<label for="voucher_deductAll_<?= $this->id ?>"><?= $this->maxValueLabel ?></label>
53
+					</div>
54
+
55
+					<div class="submit_container widget lblp button_block">
56
+						<button type="submit" class="submit"><?= $this->submitLabel ?></button>
57
+					</div>
58
+				</div>
59
+			</form>
60
+			<?php endif; ?>
61
+		</div>
62
+	</div>
63
+</div>
64
+<script>
65
+	$(document).ready(function(){
66
+		$('#voucher_deductAll_<?= $this->id ?>').click(function(e) {
67
+			if ($(this).is(':checked'))
68
+			{
69
+				$('#voucher_deductValue_<?= $this->id ?>').val('<?= $this->remainingVal ?>').attr('disabled',true);
70
+			} else {
71
+				$('#voucher_deductValue_<?= $this->id ?>').attr('disabled',false);
72
+			}
73
+		});
74
+	});
75
+</script>
76
+<?php endif; ?>
77
+
78
+<?php $this->endblock(); ?>
0 79
new file mode 100644
... ...
@@ -0,0 +1,18 @@
1
+<?php $this->extend('block_searchable'); ?>
2
+
3
+<?php $this->block('content'); ?>
4
+
5
+<form id="form_oxVoucherSearch_<?= $this->id ?>"<?php if ($this->action): ?> action="<?= $this->action ?>"<?php endif; ?> method="get">
6
+  <div class="formbody">
7
+	  <div class="widget widget-text w100">
8
+		  <label for="voucher_search_<?= $this->id ?>"><?= $this->searchLabel ?></label>
9
+		  <input class="text" name="voucher_search" id="voucher_search_<?= $this->id ?>" type="text"<?php if (\Input::get('voucher_search')):?> value="<?= \Input::get('voucher_search') ?>"<?php endif; ?>/>
10
+	  </div>
11
+
12
+	  <div class="submit_container widget lblp button_block">
13
+		  <button type="submit" class="submit"><?= $this->submitLabel ?></button>
14
+	  </div>
15
+  </div>
16
+</form>
17
+
18
+<?php $this->endblock(); ?>