ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilPRGMemberExport Class Reference

export assignments of PRG More...

+ Collaboration diagram for ilPRGMemberExport:

Public Member Functions

 __construct (protected int $prg_ref_id, protected int $prg_obj_id, protected ilStudyProgrammeUserTable $prg_user_table, protected ilUserFormSettings $settings, protected ilLanguage $lng, protected DataFactory $data_factory)
 
 create (int $type, string $filename)
 
 getCSVString ()
 

Data Fields

const EXPORT_CSV = 1
 
const EXPORT_EXCEL = 2
 

Protected Member Functions

 createExcel ()
 
 createCSV ()
 
 write ()
 
 writeData (array $fields, array $data)
 
 writeRow (array $values)
 
 writeCSVRow (array $values)
 
 writeExcelRow (array $values)
 

Protected Attributes

int $export_type
 
 $writer
 
int $current_row = 0
 

Detailed Description

export assignments of PRG

Definition at line 26 of file ilPRGMemberExport.php.

Constructor & Destructor Documentation

◆ __construct()

ilPRGMemberExport::__construct ( protected int  $prg_ref_id,
protected int  $prg_obj_id,
protected ilStudyProgrammeUserTable  $prg_user_table,
protected ilUserFormSettings  $settings,
protected ilLanguage  $lng,
protected DataFactory  $data_factory 
)

Definition at line 40 of file ilPRGMemberExport.php.

47 {
48 }

Member Function Documentation

◆ create()

ilPRGMemberExport::create ( int  $type,
string  $filename 
)

Definition at line 50 of file ilPRGMemberExport.php.

51 {
52 switch ($type) {
54 $this->writer = $this->createCSV();
55 $this->write();
56 break;
58 $this->writer = $this->createExcel();
59 $this->write();
60 $this->writer->writeToFile($filename);
61 break;
62 default:
63 throw new Exception('Unknown type for export' . $this->export_type);
64 }
65 }
$filename
Definition: buildRTE.php:78

References $filename, createCSV(), createExcel(), EXPORT_CSV, EXPORT_EXCEL, and write().

+ Here is the call graph for this function:

◆ createCSV()

ilPRGMemberExport::createCSV ( )
protected

Definition at line 74 of file ilPRGMemberExport.php.

75 {
76 return new ilCSVWriter();
77 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by create().

+ Here is the caller graph for this function:

◆ createExcel()

ilPRGMemberExport::createExcel ( )
protected

Definition at line 67 of file ilPRGMemberExport.php.

67 : ilExcel
68 {
69 $writer = new ilExcel();
70 $writer->addSheet($this->lng->txt("assignments"));
71 return $writer;
72 }

References $writer, and ILIAS\Repository\lng().

Referenced by create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCSVString()

ilPRGMemberExport::getCSVString ( )

Definition at line 79 of file ilPRGMemberExport.php.

79 : ?string
80 {
81 if ($this->writer instanceof ilCSVWriter) {
82 return $this->writer->getCSVString();
83 }
84 return null;
85 }

◆ write()

ilPRGMemberExport::write ( )
protected

Definition at line 87 of file ilPRGMemberExport.php.

87 : void
88 {
89 foreach ($this->prg_user_table->getColumns($this->prg_obj_id, true) as $user_table_field) {
90 [$f_id, $f_title] = $user_table_field;
91 if ($this->settings->enabled($f_id)) {
92 $fields[$f_id] = $f_title;
93 }
94 }
95 $this->writeRow(array_values($fields));
96
97 $order = $this->data_factory->order('login', 'ASC');
98 $data = $this->prg_user_table->fetchData($this->prg_obj_id, null, $order);
99 $this->writeData(array_keys($fields), $data);
100 }
writeData(array $fields, array $data)
writeRow(array $values)

References $data, ILIAS\Repository\settings(), writeData(), and writeRow().

Referenced by create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeCSVRow()

ilPRGMemberExport::writeCSVRow ( array  $values)
protected

Definition at line 187 of file ilPRGMemberExport.php.

188 {
189 foreach ($values as $val) {
190 $this->writer->addColumn($val);
191 }
192 $this->writer->addRow();
193 }

Referenced by writeRow().

+ Here is the caller graph for this function:

◆ writeData()

ilPRGMemberExport::writeData ( array  $fields,
array  $data 
)
protected
Parameters
string[]$fields
ilStudyProgrammeUserTableRow[]$data

Definition at line 106 of file ilPRGMemberExport.php.

106 : void
107 {
108 foreach ($data as $usr_row) {
109 $row = [];
110 //$usr_data = ilObjUser::_lookupFields($usr_row->getUsrId());
111
112 foreach ($fields as $f_id) {
113 switch ($f_id) {
114 case 'name':
115 $row[] = $usr_row->getFirstname() . $usr_row->getLastname();
116 break;
117 case 'login':
118 $row[] = $usr_row->getLogin();
119 break;
120 case 'prg_orgus':
121 $row[] = $usr_row->getOrgUs();
122 break;
123 case 'prg_status':
124 $row[] = $usr_row->getStatus();
125 break;
126 case 'prg_completion_date':
127 $row[] = $usr_row->getCompletionDate();
128 break;
129 case 'prg_completion_by':
130 $row[] = $usr_row->getCompletionBy();
131 break;
132 case 'points':
133 $row[] = $usr_row->getPointsReachable();
134 break;
135 case 'points_required':
136 $row[] = $usr_row->getPointsRequired();
137 break;
138 case 'points_current':
139 $row[] = $usr_row->getPointsCurrent();
140 break;
141 case 'prg_custom_plan':
142 $row[] = $usr_row->getCustomPlan();
143 break;
144 case 'prg_belongs_to':
145 $row[] = $usr_row->getBelongsTo();
146 break;
147 case 'prg_assign_date':
148 $row[] = $usr_row->getAssignmentDate();
149 break;
150 case 'prg_assigned_by':
151 $row[] = $usr_row->getAssignmentBy();
152 break;
153 case 'prg_deadline':
154 $row[] = $usr_row->getDeadline();
155 break;
156 case 'prg_expiry_date':
157 $row[] = $usr_row->getExpiryDate();
158 break;
159 case 'prg_validity':
160 $row[] = $usr_row->getValidity();
161 break;
162 case 'active':
163 $row[] = $usr_row->getUserActive();
164 break;
165 default:
166 $row[] = $usr_row->getUserData($f_id);
167 }
168 }
169
170 $this->writeRow($row);
171 }
172 }

References $data, and writeRow().

Referenced by write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeExcelRow()

ilPRGMemberExport::writeExcelRow ( array  $values)
protected

Definition at line 195 of file ilPRGMemberExport.php.

196 {
197 $this->current_row++;
198 $current_col = 0;
199 foreach ($values as $val) {
200 $this->writer->setCell($this->current_row, $current_col, $val);
201 $current_col++;
202 }
203 }

Referenced by writeRow().

+ Here is the caller graph for this function:

◆ writeRow()

ilPRGMemberExport::writeRow ( array  $values)
protected
Parameters
string[]$values

Definition at line 177 of file ilPRGMemberExport.php.

178 {
179 if ($this->writer instanceof ilCSVWriter) {
180 $this->writeCSVRow($values);
181 }
182 if ($this->writer instanceof ilExcel) {
183 $this->writeExcelRow($values);
184 }
185 }
writeCSVRow(array $values)
writeExcelRow(array $values)

References writeCSVRow(), and writeExcelRow().

Referenced by write(), and writeData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $current_row

int ilPRGMemberExport::$current_row = 0
protected

Definition at line 38 of file ilPRGMemberExport.php.

◆ $export_type

int ilPRGMemberExport::$export_type
protected

Definition at line 31 of file ilPRGMemberExport.php.

◆ $writer

ilPRGMemberExport::$writer
protected

Definition at line 36 of file ilPRGMemberExport.php.

Referenced by createExcel().

◆ EXPORT_CSV

const ilPRGMemberExport::EXPORT_CSV = 1

◆ EXPORT_EXCEL

const ilPRGMemberExport::EXPORT_EXCEL = 2

Definition at line 29 of file ilPRGMemberExport.php.

Referenced by create(), and ilPRGMembersExportGUI\exportExcel().


The documentation for this class was generated from the following file: