4 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
5 include_once
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
6 include_once
'./Services/Payment/classes/class.ilShopTableGUI.php';
22 $this->ctrl->saveParameter($this,
'baseClass');
35 $ilTabs->setTabActive(
'paya_header');
36 $ilTabs->setSubTabActive(
'paya_coupons_coupons');
43 $cmd = $this->ctrl->getCmd();
44 switch ($this->ctrl->getNextClass($this))
47 if (!
$cmd = $this->ctrl->getCmd())
60 unset(
$_POST[
"title_type"]);
61 unset(
$_POST[
"title_value"]);
62 unset(
$_POST[
"coupon_type"]);
63 unset(
$_POST[
"updateView"]);
64 unset(
$_POST[
'from_check']);
65 unset(
$_POST[
'until_check']);
76 include_once(
"Services/User/classes/class.ilObjUser.php");
78 $ilToolbar->addButton($this->lng->txt(
'paya_coupons_add'), $this->ctrl->getLinkTarget($this,
'addCoupon'));
79 if(!
$_POST[
'show_filter'] &&
$_POST[
'updateView'] ==
'1')
84 if (
$_POST[
'updateView'] == 1)
87 $_SESSION[
'pay_coupons'][
'updateView'] =
true;
93 if(
$_SESSION[
'pay_coupons'][
'from_check'] ==
'1')
95 $_SESSION[
'pay_coupons'][
'from'][
'date'][
'd'] =
$_POST[
'from'][
'date'][
'd'];
96 $_SESSION[
'pay_coupons'][
'from'][
'date'][
'm'] =
$_POST[
'from'][
'date'][
'm'];
97 $_SESSION[
'pay_coupons'][
'from'][
'date'][
'y'] =
$_POST[
'from'][
'date'][
'y'];
101 $_SESSION[
'pay_coupons'][
'from'][
'date'][
'd'] =
'';
102 $_SESSION[
'pay_coupons'][
'from'][
'date'][
'm'] =
'';
103 $_SESSION[
'pay_coupons'][
'from'][
'date'][
'y'] =
'';
106 if(
$_SESSION[
'pay_coupons'][
'until_check']==
'1')
108 $_SESSION[
'pay_coupons'][
'til'][
'date'][
'd'] =
$_POST[
'til'][
'date'][
'd'];
109 $_SESSION[
'pay_coupons'][
'til'][
'date'][
'm'] =
$_POST[
'til'][
'date'][
'm'];
110 $_SESSION[
'pay_coupons'][
'til'][
'date'][
'y'] =
$_POST[
'til'][
'date'][
'y'];
114 $_SESSION[
'pay_coupons'][
'til'][
'date'][
'd'] =
'';
115 $_SESSION[
'pay_coupons'][
'til'][
'date'][
'm'] =
'';
116 $_SESSION[
'pay_coupons'][
'til'][
'date'][
'y'] =
'';
127 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.main_view.html',
'Services/Payment');
130 $filter_form->setFormAction($this->ctrl->getFormAction($this));
131 $filter_form->setTitle($this->lng->txt(
'pay_filter'));
132 $filter_form->setId(
'formular');
133 $filter_form->setTableWidth(
'100 %');
135 $o_hide_check =
new ilCheckBoxInputGUI($this->lng->txt(
'show_filter'),
'show_filter');
136 $o_hide_check->setValue(1);
137 $o_hide_check->setChecked(
$_SESSION[
'pay_coupons'][
'show_filter'] ? 1 : 0);
140 $o_hidden->setValue(1);
141 $o_hidden->setPostVar(
'updateView');
142 $o_hide_check->addSubItem($o_hidden);
146 $title_option = array($this->lng->txt(
'pay_starting'),$this->lng->txt(
'pay_ending'));
147 $title_value = array(
'0',
'1');
148 $o_title_type->setTitle($this->lng->txt(
'title'));
149 $o_title_type->setOptions($title_option);
150 $o_title_type->setValue(
$_SESSION[
'pay_coupons'][
'title_type']);
151 $o_title_type->setPostVar(
'title_type');
152 $o_hide_check->addSubItem($o_title_type);
156 $o_title_val->setValue(
$_SESSION[
'pay_coupons'][
'title_value']);
157 $o_title_val->setPostVar(
'title_value');
158 $o_hide_check->addSubItem($o_title_val);
162 $coupon_option = array(
''=>
'',
'fix'=>$this->lng->txt(
'paya_coupons_fix'),
'percent'=>$this->lng->txt(
'paya_coupons_percentaged'));
164 $o_coupon_type->setTitle($this->lng->txt(
'coupon_type'));
165 $o_coupon_type->setOptions($coupon_option);
166 $o_coupon_type->setValue(
$_SESSION[
'pay_coupons'][
'coupon_type']);
167 $o_coupon_type->setPostVar(
'coupon_type');
169 $o_hide_check->addSubItem($o_coupon_type);
172 $o_from_check =
new ilCheckBoxInputGUI($this->lng->txt(
'pay_order_date_from'),
'from_check');
173 $o_from_check->setValue(1);
174 $o_from_check->setChecked(
$_SESSION[
'pay_coupons'][
'from_check'] ? 1 : 0);
177 $o_date_from->setPostVar(
'from');
179 if(
$_SESSION[
'pay_coupons'][
'from_check'] ==
'1')
181 $o_date_from->checkInput();
184 $o_from_check->addSubItem($o_date_from);
185 $o_hide_check->addSubItem($o_from_check);
188 $o_until_check =
new ilCheckBoxInputGUI($this->lng->txt(
'pay_order_date_til'),
'until_check');
189 $o_until_check->setValue(1);
190 $o_until_check->setChecked(
$_SESSION[
'pay_coupons'][
'until_check'] ? 1 : 0);
193 $o_date_until->setPostVar(
'til');
195 if(
$_SESSION[
'pay_coupons'][
'until_check'] ==
'1')
197 $o_date_until->checkInput();
200 $o_until_check->addSubItem($o_date_until);
201 $o_hide_check->addSubItem($o_until_check);
203 $filter_form->addCommandButton(
'showCoupons', $this->lng->txt(
'pay_update_view'));
204 $filter_form->addCommandButton(
'resetFilter', $this->lng->txt(
'pay_reset_filter'));
206 $filter_form->addItem($o_hide_check);
208 $this->tpl->setVariable(
'FORM', $filter_form->getHTML());
210 if (!count($coupons = $this->coupon_obj->getCoupons()))
220 foreach ($coupons as $coupon)
222 $f_result[$counter][
'pc_title'] = $coupon[
'pc_title'];
223 $f_result[$counter][
'number_of_codes'] = $coupon[
'number_of_codes'];
224 $f_result[$counter][
'usage_of_codes'] = $coupon[
'usage_of_codes'];
226 if (!empty($coupon[
'objects']))
229 for ($i = 0; $i < count($coupon[
'objects']); $i++)
234 $objects .= $tmp_obj->getTitle();
238 $objects .= $this->lng->txt(
'object_not_found');
241 if ($i < count($coupon[
'objects']) - 1) $objects .=
"<br />";
251 $f_result[$counter][
'objects'] = $objects;
252 $f_result[$counter][
'pc_from'] = ($coupon[
'pc_from'] != NULL && $coupon[
'pc_from_enabled'] ==
'1') ? $coupon[
'pc_from'] :
'';
253 $f_result[$counter][
'pc_till'] = ($coupon[
'pc_till'] != NULL && $coupon[
'pc_till_enabled'] ==
'1') ? $coupon[
'pc_till'] :
'';
254 $f_result[$counter][
'pc_last_changed'] = ($coupon[
'pc_last_changed'] != NULL ? $coupon[
'pc_last_changed'] :
'');
255 $f_result[$counter][
'pc_last_changed_author'] = ($coupon[
'pc_last_change_usr_id'] > 0 ?
ilObjUser::_lookupLogin($coupon[
'pc_last_change_usr_id']) : ilObjUser::_lookupLogin($coupon[
'usr_id']));
256 $this->ctrl->setParameter($this,
'coupon_id', $coupon[
'pc_pk']);
257 $f_result[$counter][
'options'] =
"<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,
"addCoupon").
"\">".$this->lng->txt(
"edit").
"</a></div>";
267 require_once
'Services/Payment/classes/class.ilShopCouponsTableGUI.php';
269 $tbl->setTitle($this->lng->txt(
"paya_coupons_coupons"));
270 $tbl->setId(
'tbl_show_coupons');
271 $tbl->setRowTemplate(
"tpl.shop_coupons_row.html",
"Services/Payment");
273 $tbl->addColumn($this->lng->txt(
'paya_coupons_title'),
'pc_title',
'10%');
274 $tbl->addColumn($this->lng->txt(
'paya_coupons_number_of_codes'),
'number_of_codes',
'10%');
275 $tbl->addColumn($this->lng->txt(
'paya_coupons_usage_of_codes'),
'usage_of_codes',
'10%');
276 $tbl->addColumn($this->lng->txt(
'paya_coupons_objects'),
'objects',
'10%');
277 $tbl->addColumn($this->lng->txt(
'paya_coupons_from'),
'pc_from',
'10%');
278 $tbl->addColumn($this->lng->txt(
'paya_coupons_till'),
'pc_till',
'10%');
279 $tbl->addColumn($this->lng->txt(
'last_change'),
'pc_last_changed',
'10%');
280 $tbl->addColumn($this->lng->txt(
'author'),
'pc_last_changed_author',
'10%');
281 $tbl->addColumn(
'',
'options',
'10%');
283 $tbl->setData($f_result);
284 $this->tpl->setVariable(
'TABLE', $tbl->getHTML());
293 if (
$_POST[
'title'] ==
'') $this->error .=
'paya_coupons_title,';
294 if (
$_POST[
'coupon_type'] ==
'') $this->error .=
'paya_coupons_type,';
295 if (
$_POST[
'coupon_value'] ==
'') $this->error .=
'paya_coupons_value,';
298 $this->coupon_obj->setId(
$_GET[
'coupon_id']);
299 $this->coupon_obj->setCouponUser($this->user_obj->getId());
304 $this->coupon_obj->setFromDate( date(
"Y-m-d",mktime(0,0,0,
$_POST[
'from'][
'date'][
'm'],
$_POST[
'from'][
'date'][
'd'],
$_POST[
'from'][
'date'][
'y'])));
305 $this->coupon_obj->setTillDate( date(
"Y-m-d",mktime(0,0,0,
$_POST[
'til'][
'date'][
'm'],
$_POST[
'til'][
'date'][
'd'],
$_POST[
'til'][
'date'][
'y'])));
309 $this->coupon_obj->setFromDateEnabled(
$_POST[
'from_check']);
310 $this->coupon_obj->setTillDateEnabled(
$_POST[
'until_check']);
312 $this->coupon_obj->setChangeDate(date(
'Y-m-d H:i:s'));
314 if ($this->error ==
'')
316 if (
$_GET[
'coupon_id'] !=
"")
318 $this->coupon_obj->update();
323 $_GET[
'coupon_id'] = $this->coupon_obj->add();
330 if (is_array($e = explode(
',', $this->error)))
333 for ($i = 0; $i < count($e); $i++)
335 $e[$i] = trim($e[$i]);
338 $mandatory .= $this->lng->txt($e[$i]);
339 if (array_key_exists($i + 1, $e) && $e[$i + 1] !=
'') $mandatory .=
', ';
342 ilUtil::sendInfo($this->lng->txt(
'fill_out_all_required_fields') .
': ' . $mandatory);
353 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.main_view.html',
'Services/Payment');
355 if (isset(
$_GET[
'coupon_id']))
357 if ($this->error ==
'') $this->coupon_obj->getCouponById(
$_GET[
'coupon_id']);
359 $this->ctrl->setParameter($this,
'coupon_id', $this->coupon_obj->getId());
366 $oForm->setId(
'frm_add_coupon');
367 $oForm->setFormAction($this->ctrl->getFormAction($this,
'saveCouponForm'));
368 $oForm->setTitle($this->coupon_obj->getId() ? $this->lng->txt(
'paya_coupons_edit') : $this->lng->txt(
'paya_coupons_add'));
371 $oTitle =
new ilTextInputGUI($this->lng->txt(paya_coupons_title),
'title');
372 $oTitle->
setValue($this->coupon_obj->getTitle());
373 $oTitle->setRequired(
true);
374 $oForm->addItem($oTitle);
377 $oDescription =
new ilTextAreaInputGUI($this->lng->txt(paya_coupons_description),
'description');
378 $oDescription->
setValue($this->coupon_obj->getDescription());
379 $oForm->addItem($oDescription);
383 $coupon_option = array(
'fix'=>$this->lng->txt(
'paya_coupons_fix'),
'percent'=>$this->lng->txt(
'paya_coupons_percentaged'));
385 $o_coupon_type->setTitle($this->lng->txt(
'coupon_type'));
386 $o_coupon_type->setOptions($coupon_option);
387 $o_coupon_type->setValue($this->coupon_obj->getType());
388 $o_coupon_type->setRequired(
true);
389 $o_coupon_type->setPostVar(
'coupon_type');
391 $oForm->addItem($o_coupon_type);
394 include_once
'./Services/Payment/classes/class.ilGeneralSettings.php';
397 $o_coupon_value =
new ilNumberInputGUI($this->lng->txt(
'paya_coupons_value'),
'coupon_value');
399 $o_coupon_value->setValue($this->coupon_obj->getValue());
401 $o_coupon_value->setRequired(
true);
402 $oForm->addItem($o_coupon_value);
405 $o_from_check =
new ilCheckBoxInputGUI($this->lng->txt(
'paya_coupons_from'),
'from_check');
406 $o_from_check->setValue(1);
407 $o_from_check->setChecked($this->coupon_obj->getFromDateEnabled() ? 1 : 0);
410 $o_date_from->setPostVar(
'from');
412 $from_date = explode(
'-', $this->coupon_obj->getFromDate());
413 $date_f[
'from'][
'date'][
'd'] = $from_date[2] !=
'00' ? $from_date[2] :
'';
414 $date_f[
'from'][
'date'][
'm'] = $from_date[1] !=
'00' ? $from_date[1] :
'';
415 $date_f[
'from'][
'date'][
'y'] = $from_date[0] !=
'0000' ? $from_date[0] :
'';
417 $_POST[
'from'] = $date_f[
'from'];
418 if($this->coupon_obj->getFromDateEnabled() ==
'1')
420 $o_date_from->checkInput();
423 $o_from_check->addSubItem($o_date_from);
424 $oForm->addItem($o_from_check);
427 $o_until_check =
new ilCheckBoxInputGUI($this->lng->txt(
'paya_coupons_till'),
'until_check');
428 $o_until_check->setValue(1);
429 $o_until_check->setChecked($this->coupon_obj->getTillDateEnabled() ? 1 : 0);
432 $o_date_until->setPostVar(
'til');
434 $till_date = explode(
'-', $this->coupon_obj->getTillDate());
435 $date_t[
'til'][
'date'][
'd']= $till_date[2] !=
'00' ? $till_date[2] :
'';
436 $date_t[
'til'][
'date'][
'm'] = $till_date[1] !=
'00' ? $till_date[1] :
'';
437 $date_t[
'til'][
'date'][
'y'] = $till_date[0] !=
'0000' ? $till_date[0] :
'';
439 $_POST[
'til'] = $date_t[
'til'];
440 if($this->coupon_obj->getTillDateEnabled() ==
'1')
442 $o_date_until->checkInput();
445 $o_until_check->addSubItem($o_date_until);
446 $oForm->addItem($o_until_check);
448 $o_usage =
new ilNumberInputGUI($this->lng->txt(
'paya_coupons_availability'),
'usage');
450 $o_usage->setValue($this->coupon_obj->getUses());
451 $oForm->addItem($o_usage);
453 $oForm->addCommandButton(
'saveCouponForm', $this->lng->txt(
'save'));
454 $oForm->addCommandButton(
'showCoupons', $this->lng->txt(
'cancel'));
456 $this->tpl->setVariable(
'FORM',$oForm->getHTML());
468 $this->coupon_obj->deleteAllCodesByCouponId(
$_GET[
'coupon_id']);
479 if (!is_array(
$_POST[
'codes']))
495 if (is_array(
$_SESSION[
'paya_delete_codes']))
497 foreach(
$_SESSION[
'paya_delete_codes'] as $id)
499 $this->coupon_obj->deleteCode($id);
503 ilUtil::sendInfo($this->lng->txt(
'paya_coupons_code_deleted_successfully'));
521 $this->coupon_obj->setId(
$_GET[
'coupon_id']);
523 if (!count($codes = $this->coupon_obj->getCodesByCouponId(
$_GET[
'coupon_id'])))
533 $this->ctrl->setParameter($this,
'coupon_id',
$_GET[
'coupon_id']);
536 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.main_view.html',
'Services/Payment');
540 switch($a_show_delete)
542 case 'all': $del_cmd =
'performDeleteAllCodes';
543 $del_info = $this->lng->txt(
'paya_coupons_sure_delete_all_codes');
545 case 'selected': $del_cmd =
'performDeleteCodes';
546 $del_info = $this->lng->txt(
'paya_coupons_sure_delete_selected_codes');
552 $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this, $del_cmd));
553 $oConfirmationGUI->setHeaderText($del_info);
554 $oConfirmationGUI->setCancel($this->lng->txt(
"cancel"),
"cancelDelete");
555 $oConfirmationGUI->setConfirm($this->lng->txt(
"confirm"), $del_cmd);
557 foreach ($codes as $code)
559 if(in_array($code[
'pcc_pk'],
$_SESSION[
'paya_delete_codes']))
561 $oConfirmationGUI->addItem(
'',$code[
'pcc_code'], $code[
'pcc_code']);
565 $this->tpl->setVariable(
'CONFIRMATION', $oConfirmationGUI->getHTML());
572 foreach ($codes as $code)
575 "codes[]", $code[
'pcc_pk']);
576 $f_result[$counter][
'coupon_code'] = $code[
'pcc_code'];
577 $f_result[$counter][
'usage_of_codes'] = $code[
'pcc_used'].
" ".strtolower($this->lng->txt(
'of')).
" ".$this->coupon_obj->getUses();
583 $tbl->setTitle($this->lng->txt(
"paya_coupons_coupons"));
584 $tbl->setId(
'tbl_show_codes');
585 $tbl->setRowTemplate(
"tpl.shop_coupons_row.html",
"Services/Payment");
587 $tbl->addColumn(
'',
'coupon_id',
'1%');
588 $tbl->addColumn($this->lng->txt(
'paya_coupons_code'),
'coupon_code',
'30%');
589 $tbl->addColumn($this->lng->txt(
'paya_coupons_usage_of_codes'),
'usage_of_codes',
'60%');
591 $tbl->setSelectAllCheckbox(
'codes[]');
593 $tbl->addCommandButton(
'generateCodes',$this->lng->txt(
'paya_coupons_generate_codes'));
594 $tbl->addCommandButton(
'exportCodes',$this->lng->txt(
'export'));
596 $tbl->addMultiCommand(
"deleteCodes", $this->lng->txt(
"delete"));
598 $tbl->setData($f_result);
599 $this->tpl->setVariable(
'TABLE', $tbl->getHTML());
606 $codes = $this->coupon_obj->getCodesByCouponId(
$_GET[
"coupon_id"]);
608 if (is_array($codes))
610 include_once(
'./Services/Utilities/classes/class.ilCSVWriter.php');
613 $csv->setDelimiter(
"");
615 foreach($codes as
$data)
617 if ($data[
"pcc_code"])
619 $csv->addColumn($data[
"pcc_code"]);
634 if (isset(
$_POST[
"generate_length"]))
$_SESSION[
"pay_coupons"][
"code_length"] =
$_POST[
"generate_length"];
635 else $_POST[
"generate_length"] =
$_SESSION[
"pay_coupons"][
"code_length"];
640 if (
$_POST[
"generate_type"] ==
"self")
642 if (
$_GET[
"coupon_id"] && is_array(
$_POST[
"codes"]))
646 for ($i = 0; $i < count(
$_POST[
"codes"]); $i++)
650 if (
$_POST[
"codes"][$i] !=
"")
675 else if (!is_numeric(
$_POST[
"generate_number"]) ||
$_POST[
"generate_number"] <= 0)
686 else if (
$_POST[
"generate_type"] ==
"auto")
688 if (
$_GET[
"coupon_id"] && is_numeric(
$_POST[
"generate_number"]) &&
$_POST[
"generate_number"] > 0)
690 for ($i = 0; $i <
$_POST[
"generate_number"]; $i++)
696 $this->coupon_obj->addCode($code,
$_GET[
"coupon_id"]);
715 if ($a_code ==
"") $a_code = md5(uniqid(rand()));
717 if (is_numeric($a_length) && strlen($a_code) > $a_length)
719 $a_code = substr($a_code, 0, $a_length);
727 $this->coupon_obj->setId(
$_GET[
'coupon_id']);
729 $this->ctrl->setParameter($this,
'coupon_id',
$_GET[
'coupon_id']);
734 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.main_view.html',
'Services/Payment');
736 $oForm_1->setId(
'save_frm');
737 $oForm_1->setFormAction($this->ctrl->getFormAction($this),
'saveCodeForm');
738 $oForm_1->setTitle($this->lng->txt(
"paya_coupons_coupon").
" ".$this->coupon_obj->getTitle().
": ".$this->lng->txt(
'paya_coupons_code_generation'));
740 if ($view ==
"choice")
742 $oTypeRadio =
new ilRadioGroupInputGUI($this->lng->txt(
'paya_coupons_generate_codes'),
'generate_type');
744 $radio_option =
new ilRadioOption($this->lng->txt(
'paya_coupons_type_auto'),
'auto');
745 $oTypeRadio->addOption($radio_option);
746 $radio_option =
new ilRadioOption($this->lng->txt(
'paya_coupons_type_self'),
'self');
747 $oTypeRadio->addOption($radio_option);
750 $oTypeRadio->setPostVar(
'generate_type');
751 $oForm_1->addItem($oTypeRadio);
753 $oNumCodes =
new ilNumberInputGUI($this->lng->txt(
"paya_coupons_number_of_codes"),
'generate_number');
755 $oNumCodes->setValue($_POST[
'generate_number']);
756 $oNumCodes->setRequired(
true);
757 $oForm_1->addItem($oNumCodes);
759 $oLength =
new ilNumberInputGUI($this->lng->txt(
"paya_coupons_code_length"),
'generate_length');
761 $oLength->setValue($_POST[
'generate_length']);
762 $oLength->setInfo($this->lng->txt(
'paya_coupons_type_self'));
763 $oForm_1->addItem($oLength);
765 $oForm_1->addCommandButton(
'saveCodeForm',$this->lng->txt(
'save'));
767 $this->tpl->setVariable(
'FORM', $oForm_1->getHTML());
769 $oForm_2 =
new ilPropertyformGUI();
770 $oForm_2->setId(
'import_frm');
771 $oForm_2->setFormAction($this->ctrl->getFormAction($this),
'showCodeImport');
772 $oForm_2->addCommandButton(
'showCodeImport',$this->lng->txt(
'import'));
773 $this->tpl->setVariable(
'FORM_2', $oForm_2->getHTML());
776 else if ($view ==
"input")
778 if (is_numeric(
$_POST[
'generate_number']) &&
$_POST[
'generate_number'] > 0)
780 for ($i = 0; $i <
$_POST[
'generate_number']; $i++)
784 $oForm_1->addItem($oLoopCode);
786 $oForm_1->addCommandButton(
'saveCodeForm',$this->lng->txt(
'save'));
789 $this->tpl->setVariable(
'FORM',$oForm_1->getHTML());
799 if (is_array(
$_POST[
'object_id']))
801 $this->coupon_obj->setId(
$_GET[
"coupon_id"]);
802 foreach(
$_POST[
'object_id'] as $id)
806 $this->coupon_obj->assignObjectToCoupon($id);
818 if (is_array(
$_POST[
'object_id']))
820 $this->coupon_obj->setId(
$_GET[
"coupon_id"]);
821 foreach(
$_POST[
'object_id'] as $id)
825 $this->coupon_obj->unassignObjectFromCoupon($id);
837 $this->coupon_obj->setId(
$_GET[
'coupon_id']);
841 $this->ctrl->setParameter($this,
'coupon_id',
$_GET[
'coupon_id']);
844 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.main_view.html',
'Services/Payment');
846 $objects = $this->pobject->_getObjectsData($this->user_obj->getId());
850 $counter_assigned = 0;
851 $counter_unassigned = 0;
852 $f_result_assigned = array();
853 $f_result_unassigned = array();
854 foreach($objects as
$data)
856 if ($this->coupon_obj->isObjectAssignedToCoupon($data[
'ref_id']))
858 $p_counter =& $counter_assigned;
859 $p_result =& $f_result_assigned;
863 $p_counter =& $counter_unassigned;
864 $p_result =& $f_result_unassigned;
872 $p_result[$p_counter][
'title'] = $tmp_obj->getTitle();
876 $p_result[$p_counter][
'title'] = $this->lng->txt(
'object_not_found');
878 switch($data[
'status'])
880 case $this->pobject->STATUS_BUYABLE:
881 $p_result[$p_counter][
'status'] = $this->lng->txt(
'paya_buyable');
884 case $this->pobject->STATUS_NOT_BUYABLE:
885 $p_result[$p_counter][
'status'] = $this->lng->txt(
'paya_not_buyable');
888 case $this->pobject->STATUS_EXPIRES:
889 $p_result[$p_counter][
'status'] = $this->lng->txt(
'paya_expires');
892 include_once
'./Services/Payment/classes/class.ilPayMethods.php';
893 $p_result[$p_counter][
'pay_method'] = ilPaymethods::getStringByPaymethod($data[
'pay_method']);
900 $this->ctrl->setParameter($this,
"cmd",
"showObjects");
902 if (count($f_result_assigned) > 0)
905 $tbl->setTitle($this->lng->txt(
"paya_coupons_coupon").
" ".$this->coupon_obj->getTitle().
": ".$this->lng->txt(
"paya_coupons_assigned_objects"));
906 $tbl->setId(
'tbl_show_assigned');
907 $tbl->setPrefix(
'assigned');
908 $tbl->setRowTemplate(
"tpl.shop_objects_row.html",
"Services/Payment");
910 $tbl->addColumn(
'',
'object_id',
'1%');
911 $tbl->addColumn($this->lng->txt(
'title'),
'title',
'10%');
912 $tbl->addColumn($this->lng->txt(
'status'),
'status',
'30%');
913 $tbl->addColumn($this->lng->txt(
'paya_pay_method'),
'paya_pay_method',
'60%');
915 $tbl->setSelectAllCheckbox(
'object_id');
917 $tbl->addMultiCommand(
'unassignObjects',$this->lng->txt(
'remove'));
920 $tbl->setData($f_result_assigned);
922 $this->tpl->setVariable(
'TABLE', $tbl->getHTML());
925 if (count($f_result_unassigned) > 0)
928 $tbl_2->setTitle($this->lng->txt(
"paya_coupons_coupon").
" ".$this->coupon_obj->getTitle().
": ".$this->lng->txt(
"paya_coupons_unassigned_objects"));
929 $tbl_2->setId(
'tbl_show_unassigned');
930 $tbl_2->setPrefix(
'unassigned');
931 $tbl_2->setRowTemplate(
"tpl.shop_objects_row.html",
"Services/Payment");
933 $tbl_2->addColumn(
'',
'object_id',
'1%');
934 $tbl_2->addColumn($this->lng->txt(
'title'),
'title',
'10%');
935 $tbl_2->addColumn($this->lng->txt(
'status'),
'status',
'30%');
936 $tbl_2->addColumn($this->lng->txt(
'paya_pay_method'),
'pay_method',
'60%');
938 $tbl_2->setSelectAllCheckbox(
'object_id');
940 $tbl_2->addMultiCommand(
'assignObjects',$this->lng->txt(
'add'));
943 $tbl_2->setData($f_result_unassigned);
945 $this->tpl->setVariable(
'TABLE_2', $tbl_2->getHTML());
953 include_once(
'./Services/Utilities/classes/class.ilCSVReader.php');
955 if ($_FILES[
"codesfile"][
"tmp_name"] !=
"")
958 $csv->setDelimiter(
"");
960 if ($csv->open($_FILES[
"codesfile"][
"tmp_name"]))
962 $data = $csv->getDataArrayFromCSVFile();
964 for ($i = 0; $i < count(
$data); $i++)
966 for ($j = 0; $j < count(
$data[$i]); $j++)
978 ilUtil::sendInfo($this->lng->txt(
"paya_coupons_import_error_opening_file"));
995 $this->ctrl->setParameter($this,
'coupon_id',
$_GET[
'coupon_id']);
997 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.main_view.html',
'Services/Payment');
1001 $oForm->setId(
'coup_form');
1002 $oForm->setFormAction($this->ctrl->getFormAction($this),
'importCodes');
1003 $oForm->setTitle( $this->lng->txt(
"paya_coupons_coupon").
" ".$this->coupon_obj->getTitle().
": ".$this->lng->txt(
'paya_coupons_codes_import'));
1005 $oFile =
new ilFileInputGUI($this->lng->txt(
'file'),
'codesfile');
1007 $oFile->setRequired(
true);
1008 $oFile->setInfo($this->lng->txt(
'import_use_only_textfile'));
1009 $oForm->addItem($oFile);
1011 $oForm->addCommandButton(
'importCodes',$this->lng->txt(
'upload'));
1013 $this->tpl->setVariable(
'FORM', $oForm->getHTML());
1022 $ilToolbar->addButton($this->lng->txt(
'paya_coupons_edit'), $this->ctrl->getLinkTarget($this,
'addCoupon'));
1023 $ilToolbar->addButton($this->lng->txt(
'paya_coupons_edit_codes'), $this->ctrl->getLinkTarget($this,
'showCodes'));
1024 $ilToolbar->addButton($this->lng->txt(
'paya_coupons_edit_objects'), $this->ctrl->getLinkTarget($this,
'showObjects'));
1031 include_once
'./Services/Payment/classes/class.ilPaymentObject.php';
1040 include_once
'./Services/Payment/classes/class.ilPaymentCoupons.php';