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