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']);
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')
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++)
154 $objects .= $tmp_obj->getTitle();
158 $objects .= $this->lng->txt(
'object_not_found');
161 if ($i < count($coupon[
'objects']) - 1) $objects .=
"<br />";
171 $f_result[$counter][] = $objects;
176 $f_result[$counter][] = ($coupon[
'pc_from'] != NULL && $coupon[
'pc_from_enabled'] ==
'1') ?
ilFormat::formatDate($coupon[
'pc_from'],
'date') :
'';
177 $f_result[$counter][] = ($coupon[
'pc_till'] != NULl && $coupon[
'pc_till_enabled'] ==
'1') ?
ilFormat::formatDate($coupon[
'pc_till'],
'date') :
'';
178 $f_result[$counter][] =
179 ($coupon[
'pc_last_changed'] !=
'0000-00-00 00:00:00' ?
ilFormat::formatDate($coupon[
'pc_last_changed']) :
'') .
180 ($coupon[
'pc_last_change_usr_id'] !=
'0' ?
"[" .
ilObjUser::_lookupLogin($coupon[
'pc_last_change_usr_id']) .
"]" :
'');
181 $this->ctrl->setParameter($this,
'coupon_id', $coupon[
'pc_pk']);
182 $f_result[$counter][] =
"<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"".$this->ctrl->getLinkTarget($this,
"addCoupon").
"\">".$this->lng->txt(
"edit").
"</a></div>";
193 $tpl =& $tbl->getTemplateObject();
195 $tpl->setCurrentBlock(
"tbl_form_header");
197 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
198 $tpl->parseCurrentBlock();
200 $tbl->setTitle($this->lng->txt(
"paya_coupons_coupons"),
"icon_pays.gif", $this->lng->txt(
"paya_coupons_coupons"));
201 $tbl->setHeaderNames(array($this->lng->txt(
"paya_coupons_title"),
202 $this->lng->txt(
"paya_coupons_number_of_codes"),
203 $this->lng->txt(
"paya_coupons_usage_of_codes"),
204 $this->lng->txt(
"paya_coupons_objects"),
205 $this->lng->txt(
"paya_coupons_from"),
206 $this->lng->txt(
"paya_coupons_till"),
207 $this->lng->txt(
"last_change"),
''));
208 $header_params = $this->ctrl->getParameterArray($this,
'');
209 $tbl->setHeaderVars(array(
'pc_title',
218 $offset =
$_GET[
'offset'];
219 $order =
$_GET[
'sort_by'];
220 $direction =
$_GET[
'sort_order'] ?
$_GET[
'sort_order'] :
'desc';
221 $tbl->setOrderColumn($order,
'pc_title');
222 $tbl->setOrderDirection($direction);
223 $tbl->setOffset($offset);
224 $tbl->setLimit(
$_GET[
'limit']);
225 $tbl->setMaxCount(count($f_result));
226 $tbl->setFooter(
'tblfooter', $this->lng->txt(
'previous'), $this->lng->txt(
'next'));
227 $tbl->setData($f_result);
230 $this->tpl->setVariable(
'COUPONS_TABLE', $tbl->tpl->get());
239 if (
$_POST[
'title'] ==
'') $this->error .=
'paya_coupons_title,';
240 if (
$_POST[
'type'] ==
'') $this->error .=
'paya_coupons_type,';
241 if (
$_POST[
'value'] ==
'') $this->error .=
'paya_coupons_value,';
244 $this->coupon_obj->setId(
$_GET[
'coupon_id']);
245 $this->coupon_obj->setCouponUser($this->user_obj->getId());
250 $this->coupon_obj->setFromDate( date(
"Y-m-d",mktime(0,0,0,
$_POST[
'from'][
'm'],
$_POST[
'from'][
'd'],
$_POST[
'from'][
'y'])));
251 $this->coupon_obj->setTillDate( date(
"Y-m-d",mktime(0,0,0,
$_POST[
'till'][
'm'],
$_POST[
'till'][
'd'],
$_POST[
'till'][
'y'])));
255 $this->coupon_obj->setChangeDate(date(
'Y-m-d H:i:s'));
257 if ($this->error ==
'')
259 if (
$_GET[
'coupon_id'] !=
"")
261 $this->coupon_obj->update();
265 $_GET[
'coupon_id'] = $this->coupon_obj->add();
272 if (is_array($e = explode(
',', $this->error)))
275 for ($i = 0; $i < count($e); $i++)
277 $e[$i] = trim($e[$i]);
280 $mandatory .= $this->lng->txt($e[$i]);
281 if (array_key_exists($i + 1, $e) && $e[$i + 1] !=
'') $mandatory .=
', ';
284 ilUtil::sendInfo($this->lng->txt(
'fill_out_all_required_fields') .
': ' . $mandatory);
295 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.paya_coupons_add.html',
'payment');
297 if (isset(
$_GET[
'coupon_id']))
299 if ($this->error ==
'') $this->coupon_obj->getCouponById(
$_GET[
'coupon_id']);
301 $this->ctrl->setParameter($this,
'coupon_id', $this->coupon_obj->getId());
306 $this->tpl->setVariable(
'FORMACTION', $this->ctrl->getFormAction($this));
308 $this->tpl->setVariable(
'TXT_HEADLINE', ($this->coupon_obj->getId() !=
'' ? $this->lng->txt(
'paya_coupons_edit') : $this->lng->txt(
'paya_coupons_add')));
309 $this->tpl->setVariable(
'TXT_TITLE', $this->lng->txt(
'paya_coupons_title'));
310 $this->tpl->setVariable(
'TXT_DESCRIPTION', $this->lng->txt(
'paya_coupons_description'));
311 $this->tpl->setVariable(
'TXT_TYPE', $this->lng->txt(
'paya_coupons_type'));
312 $this->tpl->setVariable(
'TXT_FIX', $this->lng->txt(
'paya_coupons_fix'));
313 $this->tpl->setVariable(
'TXT_PERCENTAGED', $this->lng->txt(
'paya_coupons_percentaged'));
314 $this->tpl->setVariable(
'TXT_VALUE', $this->lng->txt(
'paya_coupons_value'));
315 $this->tpl->setVariable(
'TXT_ENABLED', $this->lng->txt(
'enabled'));
316 $this->tpl->setVariable(
'TXT_VALID_FROM', $this->lng->txt(
'paya_coupons_from'));
317 $this->tpl->setVariable(
'TXT_VADID_TILL', $this->lng->txt(
'paya_coupons_till'));
318 $this->tpl->setVariable(
'TXT_USAGE', $this->lng->txt(
'paya_coupons_availability'));
322 $this->tpl->setVariable(
'TYPE_' . strtoupper($this->coupon_obj->getType()),
" selected=\"selected\"");
326 $from_date = explode(
'-', $this->coupon_obj->getFromDate());
327 $from_day = $from_date[2] !=
'00' ? $from_date[2] :
'';
328 $from_month = $from_date[1] !=
'00' ? $from_date[1] :
'';
329 $from_year = $from_date[0] !=
'0000' ? $from_date[0] :
'';
331 $till_date = explode(
'-', $this->coupon_obj->getTillDate());
332 $till_day = $till_date[2] !=
'00' ? $till_date[2] :
'';
333 $till_month = $till_date[1] !=
'00' ? $till_date[1] :
'';
334 $till_year = $till_date[0] !=
'0000' ? $till_date[0] :
'';
336 if ($this->coupon_obj->getFromDateEnabled()) $this->tpl->setVariable(
'CHECKED_STARTING_DATE',
" checked=\"checked\"");
337 if ($this->coupon_obj->getTillDateEnabled()) $this->tpl->setVariable(
'CHECKED_ENDING_DATE',
" checked=\"checked\"");
339 $this->tpl->setVariable(
'DATE_FROM',
ilUtil::makeDateSelect(
"from", $from_year, $from_month, $from_day, 2004));
340 $this->tpl->setVariable(
'DATE_TILL',
ilUtil::makeDateSelect(
"till", $till_year, $till_month, $till_day, 2004));
342 $this->tpl->setVariable(
'TXT_REQUIRED_FIELDS', $this->lng->txt(
'required_field'));
343 $this->tpl->setVariable(
'TXT_SAVE',$this->lng->txt(
'save'));
344 $this->tpl->setVariable(
'TXT_CANCEL',$this->lng->txt(
'cancel'));
345 $this->tpl->setVariable(
'COUPONS',
'showCoupons');
357 $this->coupon_obj->deleteAllCodesByCouponId(
$_GET[
'coupon_id']);
368 if (!is_array(
$_POST[
'codes']))
384 if (is_array(
$_SESSION[
'paya_delete_codes']))
386 foreach(
$_SESSION[
'paya_delete_codes'] as $id)
388 $this->coupon_obj->deleteCode($id);
392 ilUtil::sendInfo($this->lng->txt(
'paya_coupons_code_deleted_successfully'));
410 $this->coupon_obj->setId(
$_GET[
'coupon_id']);
412 if (!count($codes = $this->coupon_obj->getCodesByCouponId(
$_GET[
'coupon_id'])))
423 $this->ctrl->setParameter($this,
'coupon_id',
$_GET[
'coupon_id']);
426 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.paya_coupons_codes.html',
'payment');
428 if ($a_show_delete ==
"all")
431 $this->tpl->setCurrentBlock(
"confirm_delete_all");
432 $this->tpl->setVariable(
"CONFIRM_ALL_FORMACTION",$this->ctrl->getFormAction($this));
433 $this->tpl->setVariable(
"TXT_CANCEL_ALL",$this->lng->txt(
'cancel'));
434 $this->tpl->setVariable(
"TXT_CONFIRM_ALL",$this->lng->txt(
'delete_all'));
435 $this->tpl->parseCurrentBlock();
437 if ($a_show_delete ==
"selected")
439 ilUtil::sendInfo($this->lng->txt(
'paya_coupons_sure_delete_selected_codes'));
440 $this->tpl->setCurrentBlock(
"confirm_delete");
441 $this->tpl->setVariable(
"CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
442 $this->tpl->setVariable(
"TXT_CANCEL",$this->lng->txt(
'cancel'));
443 $this->tpl->setVariable(
"TXT_CONFIRM",$this->lng->txt(
'delete'));
444 $this->tpl->parseCurrentBlock();
450 foreach ($codes as $code)
455 $f_result[$counter][] = $code[
'pcc_code'];
456 $f_result[$counter][] = $code[
'pcc_used'].
" ".strtolower($this->lng->txt(
'of')).
" ".$this->coupon_obj->getUses();
462 $tpl =& $tbl->getTemplateObject();
466 $tpl->setCurrentBlock(
"tbl_form_header");
467 $tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
468 $tpl->parseCurrentBlock();
469 $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"));
470 $tbl->setHeaderNames(array(
'', $this->lng->txt(
"paya_coupons_code"), $this->lng->txt(
'paya_coupons_usage_of_codes')));
471 $this->ctrl->setParameter($this,
"cmd",
"showCodes");
472 $header_params = $this->ctrl->getParameterArray($this,
'');
473 $tbl->setHeaderVars(array(
'',
'pcc_code',
'paya_coupons_usage_of_codes'), $header_params);
474 $offset =
$_GET[
'offset'];
475 $order =
$_GET[
'sort_by'];
476 $direction =
$_GET[
'sort_order'] ?
$_GET[
'sort_order'] :
'desc';
477 $tbl->setOrderColumn($order,
'pcc_code');
478 $tbl->setOrderDirection($direction);
479 $tbl->setOffset($offset);
480 $tbl->setLimit(
$_GET[
'limit']);
481 $tbl->setMaxCount(count($f_result));
482 $tbl->setFooter(
'tblfooter', $this->lng->txt(
'previous'), $this->lng->txt(
'next'));
483 $tbl->setData($f_result);
484 $tpl->setVariable(
'COLUMN_COUNTS', 3);
486 $tbl->enable(
'select_all');
487 $tbl->setFormName(
'cmd');
488 $tbl->setSelectAllCheckbox(
'codes');
492 $tpl->setCurrentBlock(
"tbl_action_button");
493 $tpl->setVariable(
"BTN_NAME",
"deleteCodes");
494 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"delete"));
495 $tpl->parseCurrentBlock();
497 $tpl->setCurrentBlock(
'plain_button');
498 $tpl->setVariable(
'PBTN_NAME',
'generateCodes');
499 $tpl->setVariable(
'PBTN_VALUE', $this->lng->txt(
'paya_coupons_generate_codes'));
500 $tpl->parseCurrentBlock();
502 $tpl->setCurrentBlock(
'plain_button');
503 $tpl->setVariable(
'PBTN_NAME',
'deleteAllCodes');
504 $tpl->setVariable(
'PBTN_VALUE', $this->lng->txt(
'delete_all'));
505 $tpl->parseCurrentBlock();
507 $tpl->setCurrentBlock(
"plain_button");
508 $tpl->setVariable(
"PBTN_NAME",
"exportCodes");
509 $tpl->setVariable(
"PBTN_VALUE",$this->lng->txt(
"export"));
510 $tpl->parseCurrentBlock();
512 $tbl->setColumnWidth(array(
"10%",
"90%"));
515 $this->tpl->setVariable(
'CODES_TABLE', $tbl->tpl->get());
522 $codes = $this->coupon_obj->getCodesByCouponId(
$_GET[
"coupon_id"]);
524 if (is_array($codes))
526 include_once(
'./Services/Utilities/classes/class.ilCSVWriter.php');
529 $csv->setDelimiter(
"");
531 foreach($codes as
$data)
533 if ($data[
"pcc_code"])
535 $csv->addColumn($data[
"pcc_code"]);
550 if (isset(
$_POST[
"generate"][
"length"]))
$_SESSION[
"pay_coupons"][
"code_length"] =
$_POST[
"generate"][
"length"];
551 else $_POST[
"generate"][
"length"] =
$_SESSION[
"pay_coupons"][
"code_length"];
553 if (isset(
$_POST[
"generate"][
"type"]))
$_SESSION[
"pay_coupons"][
"code_type"] =
$_POST[
"generate"][
"type"];
554 else $_POST[
"generate"][
"type"] =
$_SESSION[
"pay_coupons"][
"code_type"];
556 if (
$_POST[
"generate"][
"type"] ==
"self")
558 if (
$_GET[
"coupon_id"] && is_array(
$_POST[
"codes"]))
562 for ($i = 0; $i < count(
$_POST[
"codes"]); $i++)
566 if (
$_POST[
"codes"][$i] !=
"")
591 else if (!is_numeric(
$_POST[
"generate"][
"number"]) ||
$_POST[
"generate"][
"number"] <= 0)
602 else if (
$_POST[
"generate"][
"type"] ==
"auto")
604 if (
$_GET[
"coupon_id"] && is_numeric(
$_POST[
"generate"][
"number"]) &&
$_POST[
"generate"][
"number"] > 0)
606 for ($i = 0; $i <
$_POST[
"generate"][
"number"]; $i++)
612 $this->coupon_obj->addCode($code,
$_GET[
"coupon_id"]);
631 if ($a_code ==
"") $a_code = md5(uniqid(rand()));
633 if (strlen($a_code) > $a_length)
635 $a_code = substr($a_code, 0, $a_length);
643 $this->coupon_obj->setId(
$_GET[
'coupon_id']);
645 $this->ctrl->setParameter($this,
'coupon_id',
$_GET[
'coupon_id']);
648 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.paya_coupons_codes_generate.html',
'payment');
652 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
653 $this->tpl->setVariable(
"TXT_HEADLINE", $this->lng->txt(
"paya_coupons_coupon").
" ".$this->coupon_obj->getTitle().
": ".$this->lng->txt(
'paya_coupons_code_generation'));
655 if (
$view ==
"choice")
657 $this->tpl->setCurrentBlock(
"code_choice");
659 $this->tpl->setVariable(
"TXT_TYPE", $this->lng->txt(
'paya_coupons_generate_codes'));
660 $this->tpl->setVariable(
"TXT_AUTO", $this->lng->txt(
'paya_coupons_type_auto'));
661 $this->tpl->setVariable(
"TXT_SELF", $this->lng->txt(
'paya_coupons_type_self'));
662 $this->tpl->setVariable(
"TXT_NUMBER_OF_CODES", $this->lng->txt(
'paya_coupons_number_of_codes'));
663 $this->tpl->setVariable(
"TXT_LENGTH", $this->lng->txt(
'paya_coupons_code_length'));
664 $this->tpl->setVariable(
"TXT_CHARS", $this->lng->txt(
'paya_coupons_code_chars'));
666 $this->tpl->setVariable(
"TYPE_".strtoupper(isset(
$_POST[
"generate"][
"type"]) ?
$_POST[
"generate"][
"type"] :
"auto"),
" checked=\"checked\"");
667 $this->tpl->setVariable(
"LENGTH",
ilUtil::prepareFormOutput($_POST[
"generate"][
"length"] ? $_POST[
"generate"][
"length"] : 12,
true));
669 $this->tpl->setVariable(
"TXT_REQUIRED_FIELDS", $this->lng->txt(
"required_field"));
671 $this->tpl->parseCurrentBlock();
673 else if (
$view ==
"input")
675 $this->tpl->setCurrentBlock(
"code_input");
677 if (is_numeric(
$_POST[
"generate"][
"number"]) &&
$_POST[
"generate"][
"number"] > 0)
679 for ($i = 0; $i <
$_POST[
"generate"][
"number"]; $i++)
681 $this->tpl->setCurrentBlock(
"loop");
682 $this->tpl->setVariable(
"LOOP_CODE_INDEX", $i + 1);
683 $this->tpl->parseCurrentBlock();
687 $this->tpl->parseCurrentBlock();
690 $this->tpl->setVariable(
"TXT_SEND",$this->lng->txt(
'send'));
692 $this->tpl->setVariable(
"IMPORT_ACTION", $this->ctrl->getFormAction($this));
693 $this->tpl->setVariable(
"TXT_IMPORT",$this->lng->txt(
'import'));
700 if (is_array(
$_POST[
'objects']))
702 $this->coupon_obj->setId(
$_GET[
"coupon_id"]);
703 foreach(
$_POST[
'objects'] as $id)
707 $this->coupon_obj->assignObjectToCoupon($id);
719 if (is_array(
$_POST[
'objects']))
721 $this->coupon_obj->setId(
$_GET[
"coupon_id"]);
722 foreach(
$_POST[
'objects'] as $id)
726 $this->coupon_obj->unassignObjectFromCoupon($id);
738 $this->coupon_obj->setId(
$_GET[
'coupon_id']);
742 $this->ctrl->setParameter($this,
'coupon_id',
$_GET[
'coupon_id']);
745 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.paya_coupons_objects.html',
'payment');
747 $objects = $this->pobject->_getObjectsData($this->user_obj->getId());
751 $counter_assigned = 0;
752 $counter_unassigned = 0;
753 $f_result_assigned = array();
754 $f_result_unassigned = array();
755 foreach($objects as
$data)
757 if ($this->coupon_obj->isObjectAssignedToCoupon($data[
'ref_id']))
759 $p_counter =& $counter_assigned;
760 $p_result =& $f_result_assigned;
764 $p_counter =& $counter_unassigned;
765 $p_result =& $f_result_unassigned;
773 $p_result[$p_counter][] = $tmp_obj->getTitle();
777 $p_result[$p_counter][] = $this->lng->txt(
'object_not_found');
780 switch($data[
'status'])
782 case $this->pobject->STATUS_BUYABLE:
783 $p_result[$p_counter][] = $this->lng->txt(
'paya_buyable');
786 case $this->pobject->STATUS_NOT_BUYABLE:
787 $p_result[$p_counter][] = $this->lng->txt(
'paya_not_buyable');
790 case $this->pobject->STATUS_EXPIRES:
791 $p_result[$p_counter][] = $this->lng->txt(
'paya_expires');
794 switch($data[
'pay_method'])
796 case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
797 $p_result[$p_counter][] = $this->lng->txt(
'paya_pay_method_not_specified');
800 case $this->pobject->PAY_METHOD_BILL:
801 $p_result[$p_counter][] = $this->lng->txt(
'pays_bill');
804 case $this->pobject->PAY_METHOD_BMF:
805 $p_result[$p_counter][] = $this->lng->txt(
'pays_bmf');
808 case $this->pobject->PAY_METHOD_PAYPAL:
809 $p_result[$p_counter][] = $this->lng->txt(
'pays_paypal');
818 $this->ctrl->setParameter($this,
"cmd",
"showObjects");
820 if (count($f_result_assigned) > 0)
823 $tpl =& $tbl->getTemplateObject();
824 $tbl->setPrefix(
'assigned');
826 $tpl->setCurrentBlock(
"tbl_form_header");
827 $tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
828 $tpl->parseCurrentBlock();
829 $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"));
830 $tbl->setHeaderNames(array(
"",
831 $this->lng->txt(
"title"),
832 $this->lng->txt(
"status"),
833 $this->lng->txt(
"paya_pay_method")));
834 $header_params = $this->ctrl->getParameterArray($this,
'');
835 $tbl->setHeaderVars(array(
"",
838 "pay_method"),$header_params);
839 $offset =
$_GET[
'assignedoffset'];
840 $order =
$_GET[
'assignedsort_by'];
841 $direction =
$_GET[
'assignedsort_order'] ?
$_GET[
'assignedsort_order'] :
'desc';
842 $tbl->setOrderColumn($order,
'title');
843 $tbl->setOrderDirection($direction);
844 $tbl->setOffset($offset);
845 $tbl->setLimit(
$_GET[
'limit']);
846 $tbl->setMaxCount(count($f_result_assigned));
847 $tbl->setFooter(
'tblfooter', $this->lng->txt(
'previous'), $this->lng->txt(
'next'));
848 $tbl->setData($f_result_assigned);
849 $tpl->setVariable(
'COLUMN_COUNTS', 4);
851 $tpl->setCurrentBlock(
"tbl_action_button");
852 $tpl->setVariable(
"BTN_NAME",
"unassignObjects");
853 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"remove"));
854 $tpl->parseCurrentBlock();
855 $tbl->setColumnWidth(array(
"10%",
"20%",
"20%",
"20%"));
858 $this->tpl->setVariable(
'LINKED_OBJECTS_TABLE', $tbl->tpl->get());
861 if (count($f_result_unassigned) > 0)
864 $tpl =& $tbl->getTemplateObject();
865 $tpl->setCurrentBlock(
"tbl_form_header");
866 $tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
867 $tpl->parseCurrentBlock();
868 $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"));
869 $tbl->setHeaderNames(array(
"",
870 $this->lng->txt(
"title"),
871 $this->lng->txt(
"status"),
872 $this->lng->txt(
"paya_pay_method")));
873 $header_params = $this->ctrl->getParameterArray($this,
'');
874 $tbl->setHeaderVars(array(
"",
877 "pay_method_ua"),$header_params);
878 $offset =
$_GET[
'offset'];
879 $order =
$_GET[
'sort_by'];
880 $direction =
$_GET[
'sort_order'] ?
$_GET[
'sort_order'] :
'desc';
881 $tbl->setOrderColumn($order,
'title_ua');
882 $tbl->setOrderDirection($direction);
883 $tbl->setOffset($offset);
884 $tbl->setLimit(
$_GET[
'limit']);
885 $tbl->setMaxCount(count($f_result_unassigned));
886 $tbl->setFooter(
'tblfooter', $this->lng->txt(
'previous'), $this->lng->txt(
'next'));
887 $tbl->setData($f_result_unassigned);
888 $tpl->setVariable(
'COLUMN_COUNTS', 4);
890 $tpl->setCurrentBlock(
"tbl_action_button");
891 $tpl->setVariable(
"BTN_NAME",
"assignObjects");
892 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"add"));
893 $tpl->parseCurrentBlock();
894 $tbl->setColumnWidth(array(
"10%",
"20%",
"20%",
"20%"));
897 $this->tpl->setVariable(
'UNLINKED_OBJECTS_TABLE', $tbl->tpl->get());
905 include_once(
'./Services/Utilities/classes/class.ilCSVReader.php');
907 if ($_FILES[
"codesfile"][
"tmp_name"] !=
"")
910 $csv->setDelimiter(
"");
912 if ($csv->open($_FILES[
"codesfile"][
"tmp_name"]))
914 $data = $csv->getDataArrayFromCSVFile();
916 for ($i = 0; $i < count(
$data); $i++)
918 for ($j = 0; $j < count(
$data[$i]); $j++)
930 ilUtil::sendInfo($this->lng->txt(
"paya_coupons_import_error_opening_file"));
947 $this->ctrl->setParameter($this,
'coupon_id',
$_GET[
'coupon_id']);
952 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.paya_coupons_codes_import.html',
'payment');
954 $this->tpl->setVariable(
'TXT_IMPORT_HINT', $this->lng->txt(
'import_use_only_textfile'));
956 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
957 $this->tpl->setVariable(
"TXT_HEADLINE", $this->lng->txt(
"paya_coupons_coupon").
" ".$this->coupon_obj->getTitle().
": ".$this->lng->txt(
'paya_coupons_codes_import'));
959 $this->tpl->setVariable(
"TXT_FILE",$this->lng->txt(
'file'));
961 $this->tpl->setVariable(
"TXT_UPLOAD",$this->lng->txt(
'upload'));
962 $this->tpl->setVariable(
"TXT_REQUIRED_FIELDS", $this->lng->txt(
"required_field"));
969 $this->
showButton(
'addCoupon', $this->lng->txt(
'paya_coupons_edit'));
970 $this->
showButton(
'showCodes', $this->lng->txt(
'paya_coupons_edit_codes'));
971 $this->
showButton(
'showObjects', $this->lng->txt(
'paya_coupons_edit_objects'));
978 include_once
'./payment/classes/class.ilPaymentObject.php';
987 include_once
'./payment/classes/class.ilPaymentCoupons.php';