16 $this->ctrl->saveParameter($this,
'baseClass');
29 $ilTabs->setTabActive(
'paya_header');
30 $ilTabs->setSubTabActive(
'paya_coupons_coupons');
37 $cmd = $this->ctrl->getCmd();
38 switch ($this->ctrl->getNextClass($this))
41 if (!
$cmd = $this->ctrl->getCmd())
53 unset($_POST[
'title_type']);
54 unset($_POST[
'title_value']);
55 unset($_POST[
'type']);
56 unset($_POST[
'from'][
'd']);
57 unset($_POST[
'from'][
'm']);
58 unset($_POST[
'from'][
'y']);
59 unset($_POST[
'till'][
'd']);
60 unset($_POST[
'till'][
'm']);
61 unset($_POST[
'till'][
'y']);
62 unset($_POST[
'from_enabled']);
63 unset($_POST[
'till_enabled']);
72 include_once(
"Services/User/classes/class.ilObjUser.php");
74 $this->
showButton(
'addCoupon', $this->lng->txt(
'paya_coupons_add'));
76 if ($_POST[
'updateView'] ==
'1')
78 $_SESSION[
'pay_coupons'][
'title_type'] = $_POST[
'title_type'];
79 $_SESSION[
'pay_coupons'][
'title_value'] = $_POST[
'title_value'];
80 $_SESSION[
'pay_coupons'][
'type'] = $_POST[
'type'];
81 $_SESSION[
'pay_coupons'][
'from'][
'd'] = $_POST[
'from'][
'd'];
82 $_SESSION[
'pay_coupons'][
'from'][
'm'] = $_POST[
'from'][
'm'];
83 $_SESSION[
'pay_coupons'][
'from'][
'y'] = $_POST[
'from'][
'y'];
84 $_SESSION[
'pay_coupons'][
'till'][
'd'] = $_POST[
'till'][
'd'];
85 $_SESSION[
'pay_coupons'][
'till'][
'm'] = $_POST[
'till'][
'm'];
86 $_SESSION[
'pay_coupons'][
'till'][
'y'] = $_POST[
'till'][
'y'];
87 $_SESSION[
'pay_coupons'][
'from_enabled'] = $_POST[
'from_enabled'];
88 $_SESSION[
'pay_coupons'][
'till_enabled'] = $_POST[
'till_enabled'];
104 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.paya_coupons.html',
'payment');
106 $this->tpl->setVariable(
"TXT_FILTER", $this->lng->txt(
'pay_filter'));
107 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
109 $this->tpl->setVariable(
"TXT_COUPON",$this->lng->txt(
'paya_coupons_title'));
110 $this->tpl->setVariable(
"TXT_STARTING",$this->lng->txt(
'pay_starting'));
111 $this->tpl->setVariable(
"TXT_ENDING",$this->lng->txt(
'pay_ending'));
112 $this->tpl->setVariable(
"TXT_TYPE",$this->lng->txt(
'paya_coupons_type'));
113 $this->tpl->setVariable(
"TXT_TYPE_FIX",$this->lng->txt(
'paya_coupons_fix'));
114 $this->tpl->setVariable(
"TXT_TYPE_PERCENTAGED",$this->lng->txt(
'paya_coupons_percentaged'));
115 $this->tpl->setVariable(
"TXT_VALID_DATE_FROM",$this->lng->txt(
'paya_coupons_from'));
116 $this->tpl->setVariable(
"TXT_VALID_DATE_TILL",$this->lng->txt(
'paya_coupons_till'));
117 $this->tpl->setVariable(
"TXT_UPDATE_VIEW",$this->lng->txt(
'pay_update_view'));
118 $this->tpl->setVariable(
"TXT_RESET_FILTER",$this->lng->txt(
'pay_reset_filter'));
119 $this->tpl->setVariable(
'TXT_ENABLED', $this->lng->txt(
'enabled'));
120 $this->tpl->setVariable(
"TITLE_TYPE_" . $this->coupon_obj->getSearchTitleType(),
" selected=\"selected\"");
122 $this->tpl->setVariable(
"TYPE_" . strtoupper($this->coupon_obj->getSearchType()),
" selected=\"selected\"");
125 if ($this->coupon_obj->getSearchFromDateEnabled()) $this->tpl->setVariable(
'CHECKED_STARTING_DATE',
" checked=\"checked\"");
126 if ($this->coupon_obj->getSearchTillDateEnabled()) $this->tpl->setVariable(
'CHECKED_ENDING_DATE',
" checked=\"checked\"");
127 $this->tpl->setVariable(
'DATE_FROM',
ilUtil::makeDateSelect(
"from", $this->coupon_obj->getSearchFromYear(), $this->coupon_obj->getSearchFromMonth(), $this->coupon_obj->getSearchFromDay(), 2004,
true, array(
"first_option_empty" =>
true)));
128 $this->tpl->setVariable(
'DATE_TILL',
ilUtil::makeDateSelect(
"till", $this->coupon_obj->getSearchTillYear(), $this->coupon_obj->getSearchTillMonth(), $this->coupon_obj->getSearchTillDay(), 2004,
true, array(
"first_option_empty" =>
true)));
130 if (!count($coupons = $this->coupon_obj->getCoupons()))
140 foreach ($coupons as $coupon)
142 $f_result[$counter][] = $coupon[
'pc_title'];
143 $f_result[$counter][] = $coupon[
'number_of_codes'];
144 $f_result[$counter][] = $coupon[
'usage_of_codes'];
146 if (!empty($coupon[
'objects']))
149 for ($i = 0; $i < count($coupon[
'objects']); $i++)
152 $objects .= $tmp_obj->getTitle();
154 if ($i < count($coupon[
'objects']) - 1) $objects .=
"<br />";
164 $f_result[$counter][] = $objects;
167 $f_result[$counter][] = ($coupon[
'pc_from'] !=
'0000-00-00' && $coupon[
'pc_from_enabled'] ==
'1') ?
ilFormat::formatDate($coupon[
'pc_from'],
'date') :
'';
168 $f_result[$counter][] = ($coupon[
'pc_till'] !=
'0000-00-00' && $coupon[
'pc_till_enabled'] ==
'1') ?
ilFormat::formatDate($coupon[
'pc_till'],
'date') :
'';
169 $f_result[$counter][] =
170 ($coupon[
'pc_last_changed'] !=
'0000-00-00 00:00:00' ?
ilFormat::formatDate($coupon[
'pc_last_changed']) :
'') .
171 ($coupon[
'pc_last_change_usr_id'] !=
'0' ?
"[" .
ilObjUser::_lookupLogin($coupon[
'pc_last_change_usr_id']) .
"]" :
'');
172 $this->ctrl->setParameter($this,
'coupon_id', $coupon[
'pc_pk']);
173 $f_result[$counter][] =
"<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,
"addCoupon").
"\">".$this->lng->txt(
"edit").
"</a></div>";
184 $tpl =& $tbl->getTemplateObject();
186 $tpl->setCurrentBlock(
"tbl_form_header");
188 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
189 $tpl->parseCurrentBlock();
191 $tbl->setTitle($this->lng->txt(
"paya_coupons_coupons"),
"icon_pays.gif", $this->lng->txt(
"paya_coupons_coupons"));
192 $tbl->setHeaderNames(array($this->lng->txt(
"paya_coupons_title"),
193 $this->lng->txt(
"paya_coupons_number_of_codes"),
194 $this->lng->txt(
"paya_coupons_usage_of_codes"),
195 $this->lng->txt(
"paya_coupons_objects"),
196 $this->lng->txt(
"paya_coupons_from"),
197 $this->lng->txt(
"paya_coupons_till"),
198 $this->lng->txt(
"last_change"),
''));
199 $header_params = $this->ctrl->getParameterArray($this,
'');
200 $tbl->setHeaderVars(array(
'pc_title',
209 $offset =
$_GET[
'offset'];
210 $order =
$_GET[
'sort_by'];
211 $direction =
$_GET[
'sort_order'] ?
$_GET[
'sort_order'] :
'desc';
212 $tbl->setOrderColumn($order,
'pc_title');
213 $tbl->setOrderDirection($direction);
214 $tbl->setOffset($offset);
215 $tbl->setLimit(
$_GET[
'limit']);
216 $tbl->setMaxCount(count($f_result));
217 $tbl->setFooter(
'tblfooter', $this->lng->txt(
'previous'), $this->lng->txt(
'next'));
218 $tbl->setData($f_result);
221 $this->tpl->setVariable(
'COUPONS_TABLE', $tbl->tpl->get());
230 if ($_POST[
'title'] ==
'') $this->error .=
'paya_coupons_title,';
231 if ($_POST[
'type'] ==
'') $this->error .=
'paya_coupons_type,';
232 if ($_POST[
'value'] ==
'') $this->error .=
'paya_coupons_value,';
235 $this->coupon_obj->setId(
$_GET[
'coupon_id']);
236 $this->coupon_obj->setCouponUser($this->user_obj->getId());
241 $this->coupon_obj->setFromDate(
ilUtil::stripSlashes($_POST[
'from'][
'y'].
"-".$_POST[
'from'][
'm'].
"-".$_POST[
'from'][
'd']));
242 $this->coupon_obj->setTillDate(
ilUtil::stripSlashes($_POST[
'till'][
'y'].
"-".$_POST[
'till'][
'm'].
"-".$_POST[
'till'][
'd']));
246 $this->coupon_obj->setChangeDate(date(
'Y-m-d H:i:s'));
248 if ($this->error ==
'')
250 if (
$_GET[
'coupon_id'] !=
"")
252 $this->coupon_obj->update();
256 $_GET[
'coupon_id'] = $this->coupon_obj->add();
263 if (is_array($e = explode(
',', $this->error)))
266 for ($i = 0; $i < count($e); $i++)
268 $e[$i] = trim($e[$i]);
271 $mandatory .= $this->lng->txt($e[$i]);
272 if (array_key_exists($i + 1, $e) && $e[$i + 1] !=
'') $mandatory .=
', ';
275 ilUtil::sendInfo($this->lng->txt(
'fill_out_all_required_fields') .
': ' . $mandatory);
286 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.paya_coupons_add.html',
'payment');
288 if (isset(
$_GET[
'coupon_id']))
290 if ($this->error ==
'') $this->coupon_obj->getCouponById(
$_GET[
'coupon_id']);
292 $this->ctrl->setParameter($this,
'coupon_id', $this->coupon_obj->getId());
297 $this->tpl->setVariable(
'FORMACTION', $this->ctrl->getFormAction($this));
299 $this->tpl->setVariable(
'TXT_HEADLINE', ($this->coupon_obj->getId() !=
'' ? $this->lng->txt(
'paya_coupons_edit') : $this->lng->txt(
'paya_coupons_add')));
300 $this->tpl->setVariable(
'TXT_TITLE', $this->lng->txt(
'paya_coupons_title'));
301 $this->tpl->setVariable(
'TXT_DESCRIPTION', $this->lng->txt(
'paya_coupons_description'));
302 $this->tpl->setVariable(
'TXT_TYPE', $this->lng->txt(
'paya_coupons_type'));
303 $this->tpl->setVariable(
'TXT_FIX', $this->lng->txt(
'paya_coupons_fix'));
304 $this->tpl->setVariable(
'TXT_PERCENTAGED', $this->lng->txt(
'paya_coupons_percentaged'));
305 $this->tpl->setVariable(
'TXT_VALUE', $this->lng->txt(
'paya_coupons_value'));
306 $this->tpl->setVariable(
'TXT_ENABLED', $this->lng->txt(
'enabled'));
307 $this->tpl->setVariable(
'TXT_VALID_FROM', $this->lng->txt(
'paya_coupons_from'));
308 $this->tpl->setVariable(
'TXT_VADID_TILL', $this->lng->txt(
'paya_coupons_till'));
309 $this->tpl->setVariable(
'TXT_USAGE', $this->lng->txt(
'paya_coupons_availability'));
313 $this->tpl->setVariable(
'TYPE_' . strtoupper($this->coupon_obj->getType()),
" selected=\"selected\"");
317 $from_date = explode(
'-', $this->coupon_obj->getFromDate());
318 $from_day = $from_date[2] !=
'00' ? $from_date[2] :
'';
319 $from_month = $from_date[1] !=
'00' ? $from_date[1] :
'';
320 $from_year = $from_date[0] !=
'0000' ? $from_date[0] :
'';
322 $till_date = explode(
'-', $this->coupon_obj->getTillDate());
323 $till_day = $till_date[2] !=
'00' ? $till_date[2] :
'';
324 $till_month = $till_date[1] !=
'00' ? $till_date[1] :
'';
325 $till_year = $till_date[0] !=
'0000' ? $till_date[0] :
'';
327 if ($this->coupon_obj->getFromDateEnabled()) $this->tpl->setVariable(
'CHECKED_STARTING_DATE',
" checked=\"checked\"");
328 if ($this->coupon_obj->getTillDateEnabled()) $this->tpl->setVariable(
'CHECKED_ENDING_DATE',
" checked=\"checked\"");
330 $this->tpl->setVariable(
'DATE_FROM',
ilUtil::makeDateSelect(
"from", $from_year, $from_month, $from_day, 2004));
331 $this->tpl->setVariable(
'DATE_TILL',
ilUtil::makeDateSelect(
"till", $till_year, $till_month, $till_day, 2004));
333 $this->tpl->setVariable(
'TXT_REQUIRED_FIELDS', $this->lng->txt(
'required_field'));
334 $this->tpl->setVariable(
'TXT_SAVE',$this->lng->txt(
'save'));
335 $this->tpl->setVariable(
'TXT_CANCEL',$this->lng->txt(
'cancel'));
336 $this->tpl->setVariable(
'COUPONS',
'showCoupons');
348 $this->coupon_obj->deleteAllCodesByCouponId(
$_GET[
'coupon_id']);
357 $_SESSION[
'paya_delete_codes'] = $_POST[
'codes'];
359 if (!is_array($_POST[
'codes']))
375 if (is_array(
$_SESSION[
'paya_delete_codes']))
377 foreach(
$_SESSION[
'paya_delete_codes'] as $id)
379 $this->coupon_obj->deleteCode($id);
383 ilUtil::sendInfo($this->lng->txt(
'paya_coupons_code_deleted_successfully'));
401 $this->coupon_obj->setId(
$_GET[
'coupon_id']);
403 if (!count($codes = $this->coupon_obj->getCodesByCouponId(
$_GET[
'coupon_id'])))
414 $this->ctrl->setParameter($this,
'coupon_id',
$_GET[
'coupon_id']);
417 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.paya_coupons_codes.html',
'payment');
419 if ($a_show_delete ==
"all")
422 $this->tpl->setCurrentBlock(
"confirm_delete_all");
423 $this->tpl->setVariable(
"CONFIRM_ALL_FORMACTION",$this->ctrl->getFormAction($this));
424 $this->tpl->setVariable(
"TXT_CANCEL_ALL",$this->lng->txt(
'cancel'));
425 $this->tpl->setVariable(
"TXT_CONFIRM_ALL",$this->lng->txt(
'delete_all'));
426 $this->tpl->parseCurrentBlock();
428 if ($a_show_delete ==
"selected")
430 ilUtil::sendInfo($this->lng->txt(
'paya_coupons_sure_delete_selected_codes'));
431 $this->tpl->setCurrentBlock(
"confirm_delete");
432 $this->tpl->setVariable(
"CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
433 $this->tpl->setVariable(
"TXT_CANCEL",$this->lng->txt(
'cancel'));
434 $this->tpl->setVariable(
"TXT_CONFIRM",$this->lng->txt(
'delete'));
435 $this->tpl->parseCurrentBlock();
441 foreach ($codes as $code)
446 $f_result[$counter][] = $code[
'pcc_code'];
447 $f_result[$counter][] = $code[
'pcc_used'].
" ".strtolower($this->lng->txt(
'of')).
" ".$this->coupon_obj->getUses();
453 $tpl =& $tbl->getTemplateObject();
457 $tpl->setCurrentBlock(
"tbl_form_header");
458 $tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
459 $tpl->parseCurrentBlock();
460 $tbl->setTitle($this->lng->txt(
"paya_coupons_coupon").
" ".$this->coupon_obj->getTitle().
": ".$this->lng->txt(
"paya_coupons_codes"),
"icon_pays.gif", $this->lng->txt(
"paya_coupons_codes"));
461 $tbl->setHeaderNames(array(
'', $this->lng->txt(
"paya_coupons_code"), $this->lng->txt(
'paya_coupons_usage_of_codes')));
462 $this->ctrl->setParameter($this,
"cmd",
"showCodes");
463 $header_params = $this->ctrl->getParameterArray($this,
'');
464 $tbl->setHeaderVars(array(
'',
'pcc_code',
'paya_coupons_usage_of_codes'), $header_params);
465 $offset =
$_GET[
'offset'];
466 $order =
$_GET[
'sort_by'];
467 $direction =
$_GET[
'sort_order'] ?
$_GET[
'sort_order'] :
'desc';
468 $tbl->setOrderColumn($order,
'pcc_code');
469 $tbl->setOrderDirection($direction);
470 $tbl->setOffset($offset);
471 $tbl->setLimit(
$_GET[
'limit']);
472 $tbl->setMaxCount(count($f_result));
473 $tbl->setFooter(
'tblfooter', $this->lng->txt(
'previous'), $this->lng->txt(
'next'));
474 $tbl->setData($f_result);
475 $tpl->setVariable(
'COLUMN_COUNTS', 3);
477 $tbl->enable(
'select_all');
478 $tbl->setFormName(
'cmd');
479 $tbl->setSelectAllCheckbox(
'codes');
483 $tpl->setCurrentBlock(
"tbl_action_button");
484 $tpl->setVariable(
"BTN_NAME",
"deleteCodes");
485 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"delete"));
486 $tpl->parseCurrentBlock();
488 $tpl->setCurrentBlock(
'plain_button');
489 $tpl->setVariable(
'PBTN_NAME',
'generateCodes');
490 $tpl->setVariable(
'PBTN_VALUE', $this->lng->txt(
'paya_coupons_generate_codes'));
491 $tpl->parseCurrentBlock();
493 $tpl->setCurrentBlock(
'plain_button');
494 $tpl->setVariable(
'PBTN_NAME',
'deleteAllCodes');
495 $tpl->setVariable(
'PBTN_VALUE', $this->lng->txt(
'delete_all'));
496 $tpl->parseCurrentBlock();
498 $tpl->setCurrentBlock(
"plain_button");
499 $tpl->setVariable(
"PBTN_NAME",
"exportCodes");
500 $tpl->setVariable(
"PBTN_VALUE",$this->lng->txt(
"export"));
501 $tpl->parseCurrentBlock();
503 $tbl->setColumnWidth(array(
"10%",
"90%"));
506 $this->tpl->setVariable(
'CODES_TABLE', $tbl->tpl->get());
513 $codes = $this->coupon_obj->getCodesByCouponId(
$_GET[
"coupon_id"]);
515 if (is_array($codes))
517 include_once(
'./Services/Utilities/classes/class.ilCSVWriter.php');
520 $csv->setDelimiter(
"");
522 foreach($codes as
$data)
524 if ($data[
"pcc_code"])
526 $csv->addColumn($data[
"pcc_code"]);
541 if (isset($_POST[
"generate"][
"length"]))
$_SESSION[
"pay_coupons"][
"code_length"] = $_POST[
"generate"][
"length"];
542 else $_POST[
"generate"][
"length"] =
$_SESSION[
"pay_coupons"][
"code_length"];
544 if (isset($_POST[
"generate"][
"type"]))
$_SESSION[
"pay_coupons"][
"code_type"] = $_POST[
"generate"][
"type"];
545 else $_POST[
"generate"][
"type"] =
$_SESSION[
"pay_coupons"][
"code_type"];
547 if ($_POST[
"generate"][
"type"] ==
"self")
549 if (
$_GET[
"coupon_id"] && is_array($_POST[
"codes"]))
553 for ($i = 0; $i < count($_POST[
"codes"]); $i++)
555 $_POST[
"codes"][$i] = trim($_POST[
"codes"][$i]);
557 if ($_POST[
"codes"][$i] !=
"")
582 else if (!is_numeric($_POST[
"generate"][
"number"]) || $_POST[
"generate"][
"number"] <= 0)
593 else if ($_POST[
"generate"][
"type"] ==
"auto")
595 if (
$_GET[
"coupon_id"] && is_numeric($_POST[
"generate"][
"number"]) && $_POST[
"generate"][
"number"] > 0)
597 for ($i = 0; $i < $_POST[
"generate"][
"number"]; $i++)
603 $this->coupon_obj->addCode($code,
$_GET[
"coupon_id"]);
622 if ($a_code ==
"") $a_code = md5(uniqid(rand()));
624 if (strlen($a_code) > $a_length)
626 $a_code = substr($a_code, 0, $a_length);
634 $this->coupon_obj->setId(
$_GET[
'coupon_id']);
636 $this->ctrl->setParameter($this,
'coupon_id',
$_GET[
'coupon_id']);
639 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.paya_coupons_codes_generate.html',
'payment');
643 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
644 $this->tpl->setVariable(
"TXT_HEADLINE", $this->lng->txt(
"paya_coupons_coupon").
" ".$this->coupon_obj->getTitle().
": ".$this->lng->txt(
'paya_coupons_code_generation'));
646 if ($view ==
"choice")
648 $this->tpl->setCurrentBlock(
"code_choice");
650 $this->tpl->setVariable(
"TXT_TYPE", $this->lng->txt(
'paya_coupons_generate_codes'));
651 $this->tpl->setVariable(
"TXT_AUTO", $this->lng->txt(
'paya_coupons_type_auto'));
652 $this->tpl->setVariable(
"TXT_SELF", $this->lng->txt(
'paya_coupons_type_self'));
653 $this->tpl->setVariable(
"TXT_NUMBER_OF_CODES", $this->lng->txt(
'paya_coupons_number_of_codes'));
654 $this->tpl->setVariable(
"TXT_LENGTH", $this->lng->txt(
'paya_coupons_code_length'));
655 $this->tpl->setVariable(
"TXT_CHARS", $this->lng->txt(
'paya_coupons_code_chars'));
657 $this->tpl->setVariable(
"TYPE_".strtoupper(isset($_POST[
"generate"][
"type"]) ? $_POST[
"generate"][
"type"] :
"auto"),
" checked=\"checked\"");
658 $this->tpl->setVariable(
"LENGTH",
ilUtil::prepareFormOutput($_POST[
"generate"][
"length"] ? $_POST[
"generate"][
"length"] : 12,
true));
660 $this->tpl->setVariable(
"TXT_REQUIRED_FIELDS", $this->lng->txt(
"required_field"));
662 $this->tpl->parseCurrentBlock();
664 else if ($view ==
"input")
666 $this->tpl->setCurrentBlock(
"code_input");
668 if (is_numeric($_POST[
"generate"][
"number"]) && $_POST[
"generate"][
"number"] > 0)
670 for ($i = 0; $i < $_POST[
"generate"][
"number"]; $i++)
672 $this->tpl->setCurrentBlock(
"loop");
673 $this->tpl->setVariable(
"LOOP_CODE_INDEX", $i + 1);
674 $this->tpl->parseCurrentBlock();
678 $this->tpl->parseCurrentBlock();
681 $this->tpl->setVariable(
"TXT_SEND",$this->lng->txt(
'send'));
683 $this->tpl->setVariable(
"IMPORT_ACTION", $this->ctrl->getFormAction($this));
684 $this->tpl->setVariable(
"TXT_IMPORT",$this->lng->txt(
'import'));
691 if (is_array($_POST[
'objects']))
693 $this->coupon_obj->setId(
$_GET[
"coupon_id"]);
694 foreach($_POST[
'objects'] as $id)
698 $this->coupon_obj->assignObjectToCoupon($id);
710 if (is_array($_POST[
'objects']))
712 $this->coupon_obj->setId(
$_GET[
"coupon_id"]);
713 foreach($_POST[
'objects'] as $id)
717 $this->coupon_obj->unassignObjectFromCoupon($id);
729 $this->coupon_obj->setId(
$_GET[
'coupon_id']);
733 $this->ctrl->setParameter($this,
'coupon_id',
$_GET[
'coupon_id']);
736 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.paya_coupons_objects.html',
'payment');
738 $objects = $this->pobject->_getObjectsData($this->user_obj->getId());
742 $counter_assigned = 0;
743 $counter_unassigned = 0;
744 $f_result_assigned = array();
745 $f_result_unassigned = array();
746 foreach($objects as
$data)
748 if ($this->coupon_obj->isObjectAssignedToCoupon($data[
'ref_id']))
750 $p_counter =& $counter_assigned;
751 $p_result =& $f_result_assigned;
755 $p_counter =& $counter_unassigned;
756 $p_result =& $f_result_unassigned;
762 $p_result[$p_counter][] = $tmp_obj->getTitle();
763 switch($data[
'status'])
765 case $this->pobject->STATUS_BUYABLE:
766 $p_result[$p_counter][] = $this->lng->txt(
'paya_buyable');
769 case $this->pobject->STATUS_NOT_BUYABLE:
770 $p_result[$p_counter][] = $this->lng->txt(
'paya_not_buyable');
773 case $this->pobject->STATUS_EXPIRES:
774 $p_result[$p_counter][] = $this->lng->txt(
'paya_expires');
777 switch($data[
'pay_method'])
779 case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
780 $p_result[$p_counter][] = $this->lng->txt(
'paya_pay_method_not_specified');
783 case $this->pobject->PAY_METHOD_BILL:
784 $p_result[$p_counter][] = $this->lng->txt(
'pays_bill');
787 case $this->pobject->PAY_METHOD_BMF:
788 $p_result[$p_counter][] = $this->lng->txt(
'pays_bmf');
791 case $this->pobject->PAY_METHOD_PAYPAL:
792 $p_result[$p_counter][] = $this->lng->txt(
'pays_paypal');
801 $this->ctrl->setParameter($this,
"cmd",
"showObjects");
803 if (count($f_result_assigned) > 0)
806 $tpl =& $tbl->getTemplateObject();
807 $tbl->setPrefix(
'assigned');
809 $tpl->setCurrentBlock(
"tbl_form_header");
810 $tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
811 $tpl->parseCurrentBlock();
812 $tbl->setTitle($this->lng->txt(
"paya_coupons_coupon").
" ".$this->coupon_obj->getTitle().
": ".$this->lng->txt(
"paya_coupons_assigned_objects"),
"icon_pays.gif",$this->lng->txt(
"paya_coupons_assigned_objects"));
813 $tbl->setHeaderNames(array(
"",
814 $this->lng->txt(
"title"),
815 $this->lng->txt(
"status"),
816 $this->lng->txt(
"paya_pay_method")));
817 $header_params = $this->ctrl->getParameterArray($this,
'');
818 $tbl->setHeaderVars(array(
"",
821 "pay_method"),$header_params);
822 $offset =
$_GET[
'assignedoffset'];
823 $order =
$_GET[
'assignedsort_by'];
824 $direction =
$_GET[
'assignedsort_order'] ?
$_GET[
'assignedsort_order'] :
'desc';
825 $tbl->setOrderColumn($order,
'title');
826 $tbl->setOrderDirection($direction);
827 $tbl->setOffset($offset);
828 $tbl->setLimit(
$_GET[
'limit']);
829 $tbl->setMaxCount(count($f_result_assigned));
830 $tbl->setFooter(
'tblfooter', $this->lng->txt(
'previous'), $this->lng->txt(
'next'));
831 $tbl->setData($f_result_assigned);
832 $tpl->setVariable(
'COLUMN_COUNTS', 4);
834 $tpl->setCurrentBlock(
"tbl_action_button");
835 $tpl->setVariable(
"BTN_NAME",
"unassignObjects");
836 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"remove"));
837 $tpl->parseCurrentBlock();
838 $tbl->setColumnWidth(array(
"10%",
"20%",
"20%",
"20%"));
841 $this->tpl->setVariable(
'LINKED_OBJECTS_TABLE', $tbl->tpl->get());
844 if (count($f_result_unassigned) > 0)
847 $tpl =& $tbl->getTemplateObject();
848 $tpl->setCurrentBlock(
"tbl_form_header");
849 $tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
850 $tpl->parseCurrentBlock();
851 $tbl->setTitle($this->lng->txt(
"paya_coupons_coupon").
" ".$this->coupon_obj->getTitle().
": ".$this->lng->txt(
"paya_coupons_unassigned_objects"),
"icon_pays.gif",$this->lng->txt(
"paya_coupons_unassigned_objects"));
852 $tbl->setHeaderNames(array(
"",
853 $this->lng->txt(
"title"),
854 $this->lng->txt(
"status"),
855 $this->lng->txt(
"paya_pay_method")));
856 $header_params = $this->ctrl->getParameterArray($this,
'');
857 $tbl->setHeaderVars(array(
"",
860 "pay_method_ua"),$header_params);
861 $offset =
$_GET[
'offset'];
862 $order =
$_GET[
'sort_by'];
863 $direction =
$_GET[
'sort_order'] ?
$_GET[
'sort_order'] :
'desc';
864 $tbl->setOrderColumn($order,
'title_ua');
865 $tbl->setOrderDirection($direction);
866 $tbl->setOffset($offset);
867 $tbl->setLimit(
$_GET[
'limit']);
868 $tbl->setMaxCount(count($f_result_unassigned));
869 $tbl->setFooter(
'tblfooter', $this->lng->txt(
'previous'), $this->lng->txt(
'next'));
870 $tbl->setData($f_result_unassigned);
871 $tpl->setVariable(
'COLUMN_COUNTS', 4);
873 $tpl->setCurrentBlock(
"tbl_action_button");
874 $tpl->setVariable(
"BTN_NAME",
"assignObjects");
875 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"add"));
876 $tpl->parseCurrentBlock();
877 $tbl->setColumnWidth(array(
"10%",
"20%",
"20%",
"20%"));
880 $this->tpl->setVariable(
'UNLINKED_OBJECTS_TABLE', $tbl->tpl->get());
888 include_once(
'./Services/Utilities/classes/class.ilCSVReader.php');
890 if ($_FILES[
"codesfile"][
"tmp_name"] !=
"")
893 $csv->setDelimiter(
"");
895 if ($csv->open($_FILES[
"codesfile"][
"tmp_name"]))
897 $data = $csv->getDataArrayFromCSVFile();
899 for ($i = 0; $i < count(
$data); $i++)
901 for ($j = 0; $j < count(
$data[$i]); $j++)
913 ilUtil::sendInfo($this->lng->txt(
"paya_coupons_import_error_opening_file"));
930 $this->ctrl->setParameter($this,
'coupon_id',
$_GET[
'coupon_id']);
935 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.paya_coupons_codes_import.html',
'payment');
937 $this->tpl->setVariable(
'TXT_IMPORT_HINT', $this->lng->txt(
'import_use_only_textfile'));
939 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
940 $this->tpl->setVariable(
"TXT_HEADLINE", $this->lng->txt(
"paya_coupons_coupon").
" ".$this->coupon_obj->getTitle().
": ".$this->lng->txt(
'paya_coupons_codes_import'));
942 $this->tpl->setVariable(
"TXT_FILE",$this->lng->txt(
'file'));
944 $this->tpl->setVariable(
"TXT_UPLOAD",$this->lng->txt(
'upload'));
945 $this->tpl->setVariable(
"TXT_REQUIRED_FIELDS", $this->lng->txt(
"required_field"));
952 $this->
showButton(
'addCoupon', $this->lng->txt(
'paya_coupons_edit'));
953 $this->
showButton(
'showCodes', $this->lng->txt(
'paya_coupons_edit_codes'));
954 $this->
showButton(
'showObjects', $this->lng->txt(
'paya_coupons_edit_objects'));
961 include_once
'./payment/classes/class.ilPaymentObject.php';
970 include_once
'./payment/classes/class.ilPaymentCoupons.php';