OXID eShop CE  4.10.4
 All Classes Namespaces Files Functions Variables Pages
voucherserie_main.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
17  public $sClassDo = "voucherSerie_generate";
18 
24  protected $_oVoucherSerie = null;
25 
31  protected $_sThisTemplate = "voucherserie_main.tpl";
32 
40  public function render()
41  {
43 
44  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
45  if ($soxId != "-1" && isset($soxId)) {
46  // load object
47  $oVoucherSerie = oxNew("oxvoucherserie");
48  $oVoucherSerie->load($soxId);
49  $this->_aViewData["edit"] = $oVoucherSerie;
50 
51  }
52 
53  return $this->_sThisTemplate;
54  }
55 
61  public function save()
62  {
63  parent::save();
64 
65  // Parameter Processing
66  $soxId = $this->getEditObjectId();
67  $aSerieParams = oxRegistry::getConfig()->getRequestParameter("editval");
68 
69  // Voucher Serie Processing
70  $oVoucherSerie = oxNew("oxvoucherserie");
71  // if serie already exist use it
72  if ($soxId != "-1") {
73  $oVoucherSerie->load($soxId);
74  } else {
75  $aSerieParams["oxvoucherseries__oxid"] = null;
76  }
77 
78 
79 
80  $aSerieParams["oxvoucherseries__oxdiscount"] = abs($aSerieParams["oxvoucherseries__oxdiscount"]);
81 
82  $oVoucherSerie->assign($aSerieParams);
83  $oVoucherSerie->save();
84 
85  // set oxid if inserted
86  $this->setEditObjectId($oVoucherSerie->getId());
87  }
88 
94  public function getStatus()
95  {
96  if ($oSerie = $this->_getVoucherSerie()) {
97  return $oSerie->countVouchers();
98  }
99  }
100 
104  public function prepareExport()
105  {
106  }
107 
108 
114  protected function _getVoucherSerie()
115  {
116  if ($this->_oVoucherSerie == null) {
117  $oVoucherSerie = oxNew("oxvoucherserie");
118  $sId = oxRegistry::getConfig()->getRequestParameter("voucherid");
119  if ($oVoucherSerie->load($sId ? $sId : oxRegistry::getSession()->getVariable("voucherid"))) {
120  $this->_oVoucherSerie = $oVoucherSerie;
121  }
122  }
123 
124  return $this->_oVoucherSerie;
125  }
126 
130  public function start()
131  {
132  $this->_aViewData['refresh'] = 0;
133  $this->_aViewData['iStart'] = 0;
134  $iEnd = $this->prepareExport();
135  oxRegistry::getSession()->setVariable("iEnd", $iEnd);
136  $this->_aViewData['iEnd'] = $iEnd;
137 
138  // saving export info
139  oxRegistry::getSession()->setVariable("voucherid", oxRegistry::getConfig()->getRequestParameter("voucherid"));
140  oxRegistry::getSession()->setVariable("voucherAmount", abs((int) oxRegistry::getConfig()->getRequestParameter("voucherAmount")));
141  oxRegistry::getSession()->setVariable("randomVoucherNr", oxRegistry::getConfig()->getRequestParameter("randomVoucherNr"));
142  oxRegistry::getSession()->setVariable("voucherNr", oxRegistry::getConfig()->getRequestParameter("voucherNr"));
143  }
144 
151  public function getViewId()
152  {
153  return oxAdminView::getViewId();
154  }
155 }