ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAccountCodesTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Table/classes/class.ilTable2GUI.php");
5 
16 {
20  public function __construct($a_parent_obj, $a_parent_cmd)
21  {
22  global $ilCtrl, $lng;
23 
24  $this->setId("user_account_code");
25 
26  parent::__construct($a_parent_obj, $a_parent_cmd);
27 
28  $this->addColumn("", "", "1", true);
29  $this->addColumn($lng->txt("user_account_code"), "code");
30  $this->addColumn($lng->txt("user_account_code_valid_until"), "valid_until");
31  $this->addColumn($lng->txt("user_account_code_generated"), "generated");
32  $this->addColumn($lng->txt("user_account_code_used"), "used");
33 
34  $this->setExternalSorting(true);
35  $this->setExternalSegmentation(true);
36  $this->setEnableHeader(true);
37  $this->setFormAction($ilCtrl->getFormAction($this->parent_obj, "listCodes"));
38  $this->setRowTemplate("tpl.code_list_row.html", "Services/User");
39  $this->setEnableTitle(true);
40  $this->initFilter();
41  $this->setFilterCommand("applyCodesFilter");
42  $this->setResetCommand("resetCodesFilter");
43  $this->setDefaultOrderField("generated");
44  $this->setDefaultOrderDirection("desc");
45 
46  $this->setSelectAllCheckbox("id[]");
47  $this->setTopCommands(true);
48  $this->addMultiCommand("deleteConfirmation", $lng->txt("delete"));
49 
50  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
51  $button = ilSubmitButton::getInstance();
52  $button->setCaption("user_account_codes_export");
53  $button->setCommand("exportCodes");
54  $button->setOmitPreventDoubleSubmission(true);
55  $this->addCommandButtonInstance($button);
56 
57  $this->getItems();
58  }
59 
63  public function getItems()
64  {
65  global $lng, $rbacreview, $ilObjDataCache;
66 
67  $this->determineOffsetAndOrder();
68 
69  include_once("./Services/User/classes/class.ilAccountCode.php");
70 
71  $codes_data = ilAccountCode::getCodesData(
76  $this->filter["code"],
77  $this->filter["valid_until"],
78  $this->filter["generated"]
79  );
80 
81  if (count($codes_data["set"]) == 0 && $this->getOffset() > 0) {
82  $this->resetOffset();
83  $codes_data = ilAccountCode::getCodesData(
88  $this->filter["code"],
89  $this->filter["valid_until"],
90  $this->filter["generated"]
91  );
92  }
93 
94  $result = array();
95  foreach ($codes_data["set"] as $k => $code) {
96  $result[$k]["generated"] = ilDatePresentation::formatDate(new ilDateTime($code["generated"], IL_CAL_UNIX));
97 
98  if ($code["used"]) {
100  } else {
101  $result[$k]["used"] = "";
102  }
103 
104  if ($code["valid_until"] === "0") {
105  $valid = $lng->txt("user_account_code_valid_until_unlimited");
106  } elseif (is_numeric($code["valid_until"])) {
107  $valid = $code["valid_until"] . " " . ($code["valid_until"] == 1 ? $lng->txt("day") : $lng->txt("days"));
108  } else {
110  }
111  $result[$k]["valid_until"] = $valid;
112 
113  $result[$k]["code"] = $code["code"];
114  $result[$k]["code_id"] = $code["code_id"];
115  }
116 
117  $this->setMaxCount($codes_data["cnt"]);
118  $this->setData($result);
119  }
120 
121 
125  public function initFilter()
126  {
127  global $lng, $rbacreview, $ilUser;
128 
129  include_once("./Services/User/classes/class.ilAccountCode.php");
130 
131  // code
132  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
133  $ti = new ilTextInputGUI($lng->txt("user_account_code"), "query");
135  $ti->setSize(20);
136  $ti->setSubmitFormOnEnter(true);
137  $this->addFilterItem($ti);
138  $ti->readFromSession();
139  $this->filter["code"] = $ti->getValue();
140 
141  // generated
142  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
143  $options = array("" => $lng->txt("user_account_code_generated_all"));
144  foreach ((array) ilAccountCode::getGenerationDates() as $date) {
146  }
147  $si = new ilSelectInputGUI($lng->txt("user_account_code_generated"), "generated");
148  $si->setOptions($options);
149  $this->addFilterItem($si);
150  $si->readFromSession();
151  $this->filter["generated"] = $si->getValue();
152  }
153 
157  protected function fillRow($code)
158  {
159  $this->tpl->setVariable("ID", $code["code_id"]);
160  $this->tpl->setVariable("VAL_CODE", $code["code"]);
161  $this->tpl->setVariable("VAL_VALID_UNTIL", $code["valid_until"]);
162  $this->tpl->setVariable("VAL_GENERATED", $code["generated"]);
163  $this->tpl->setVariable("VAL_USED", $code["used"]);
164  }
165 }
setExternalSorting($a_val)
Set external sorting.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addCommandButtonInstance(ilButtonBase $a_button)
Add Command button instance.
This class represents a selection list property in a property form.
$result
$code
Definition: example_050.php:99
$valid
setExternalSegmentation($a_val)
Set external segmentation.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
resetOffset($a_in_determination=false)
Reset offset.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
const IL_CAL_UNIX
TableGUI class for account codes.
getOrderDirection()
Get order direction.
static getCodesData($order_field, $order_direction, $offset, $limit, $filter_code, $filter_valid_until, $filter_generated)
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
Class ilTable2GUI.
Class for single dates.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
__construct($a_parent_obj, $a_parent_cmd)
Constructor.
getOffset()
Get offset.
addMultiCommand($a_cmd, $a_text)
Add Command button.
This class represents a text property in a property form.
Date and time handling
$ilUser
Definition: imgupload.php:18
setMaxLength($a_maxlength)
Set Max Length.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
const IL_CAL_DATE
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setEnableHeader($a_enableheader)
Set Enable Header.
getLimit()
Get limit.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setMaxCount($a_max_count)
set max.
setEnableTitle($a_enabletitle)
Set Enable Title.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
setFilterCommand($a_val, $a_caption=null)
Set filter command.