public function saveCouponForm() { $this->error = ''; if ($_POST['title'] == '') { $this->error .= 'paya_coupons_title,'; } if ($_POST['coupon_type'] == '') { $this->error .= 'paya_coupons_type,'; } if ($_POST['coupon_value'] == '') { $this->error .= 'paya_coupons_value,'; } else { $_POST['coupon_value'] = ilFormat::checkDecimal($_POST['coupon_value']); } $this->coupon_obj->setId($_GET['coupon_id']); $this->coupon_obj->setCouponUser($this->user_obj->getId()); $this->coupon_obj->setTitle(ilUtil::stripSlashes($_POST['title'])); $this->coupon_obj->setDescription(ilUtil::stripSlashes($_POST['description'])); $this->coupon_obj->setType(ilUtil::stripSlashes($_POST['coupon_type'])); $this->coupon_obj->setValue(ilUtil::stripSlashes($_POST['coupon_value'])); $this->coupon_obj->setFromDate(date("Y-m-d", mktime(0, 0, 0, $_POST['from']['date']['m'], $_POST['from']['date']['d'], $_POST['from']['date']['y']))); $this->coupon_obj->setTillDate(date("Y-m-d", mktime(0, 0, 0, $_POST['til']['date']['m'], $_POST['til']['date']['d'], $_POST['til']['date']['y']))); // $this->coupon_obj->setFromDateEnabled(ilUtil::stripSlashes($_POST['from_check'])); //$this->coupon_obj->setTillDateEnabled(ilUtil::stripSlashes($_POST['until_check'])); $this->coupon_obj->setFromDateEnabled($_POST['from_check']); $this->coupon_obj->setTillDateEnabled($_POST['until_check']); $this->coupon_obj->setUses((int) ilUtil::stripSlashes($_POST['usage'])); $this->coupon_obj->setChangeDate(date('Y-m-d H:i:s')); if ($this->error == '') { if ($_GET['coupon_id'] != "") { $this->coupon_obj->update(); } else { $_GET['coupon_id'] = $this->coupon_obj->add(); } ilUtil::sendInfo($this->lng->txt('saved_successfully')); } else { if (is_array($e = explode(',', $this->error))) { $mandatory = ''; for ($i = 0; $i < count($e); $i++) { $e[$i] = trim($e[$i]); if ($e[$i] != '') { $mandatory .= $this->lng->txt($e[$i]); if (array_key_exists($i + 1, $e) && $e[$i + 1] != '') { $mandatory .= ', '; } } } ilUtil::sendInfo($this->lng->txt('fill_out_all_required_fields') . ': ' . $mandatory); } } $this->addCoupon(); return true; }