forked from loulou6666/Giftcard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGiftCardClass.php
144 lines (119 loc) · 4.47 KB
/
GiftCardClass.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class GiftCardClass extends ObjectModel
{
/** @var integer giftcard id*/
public $id_giftcard;
/** @var integer giftcard id shop*/
public $id_shop;
/** @var integer info image_path*/
public $image_path;
/** @var integer info id_product*/
public $id_product;
/** @var integer info id_category*/
public $id_category;
/** @var string display_duration*/
public $display_duration;
/** @var string duration*/
public $duration;
/** @var string validity*/
public $validity;
/** @var string display_code*/
public $display_code;
/** @var string pos_code_x*/
public $pos_code_x;
/** @var string pos_code_y*/
public $pos_code_y;
/** @var string colorcode*/
public $colorcode;
/** @var string display_text*/
public $display_text;
/** @var string colortext*/
public $colortext;
/** @var string pos_text_x*/
public $pos_text_x;
/** @var string pos_text_y*/
public $pos_text_y;
/** @var string text_size*/
public $text_size;
/** @var string display_shadow*/
public $display_shadow;
/** @var string colorshadow*/
public $colorshadow;
/** @var string partial_use*/
public $tax;
/** @var string partial_use*/
public $partial_use;
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'giftcard',
'primary' => 'id_giftcard',
'multilang' => false,
'fields' => array(
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt', 'required' => true),
'image_path' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 32),
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt' ),
'id_category' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt' ),
'display_duration'=> array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'duration' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
'validity' => array('type' => self::TYPE_DATE),
'display_code' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'colorcode' => array('type' => self::TYPE_STRING),
'pos_code_x' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt' ),
'pos_code_y' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt' ),
'display_text' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'colortext' => array('type' => self::TYPE_STRING),
'pos_text_x' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt' ),
'pos_text_y' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt' ),
'text_size' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt' ),
'display_shadow'=> array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'colorshadow' => array('type' => self::TYPE_STRING),
'tax' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'partial_use' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
)
);
static public function getByIdShop($id_shop)
{
$id = Db::getInstance()->getvalue('SELECT `id_giftcard` FROM `'._DB_PREFIX_.'giftcard` WHERE `id_shop` ='.(int)$id_shop);
return new GiftCardClass($id);
}
static public function getByIdProduct($id_shop, $id_product)
{
$id = Db::getInstance()->getvalue('SELECT `id_giftcard` FROM `'._DB_PREFIX_.'giftcard` WHERE `id_shop` ='.(int)$id_shop.' AND `id_product` = '.$id_product);
return new GiftCardClass($id);
}
public function copyFromPost()
{
/* Classical fields */
foreach ($_POST as $key => $value)
{
if (key_exists($key, $this) && $key != 'id_'.$this->table)
$this->{$key} = $value;
}
}
}