9 use PhpOffice\PhpWord\Element\Section;
10 use PhpOffice\PhpWord\Style;
11 use PhpOffice\PhpWord\SimpleType\JcTable;
12 use PhpOffice\PhpWord\Style\Table;
30 "borderColor" =>
"000000",
32 "alignment" => JcTable::START,
33 "layout" => Table::LAYOUT_FIXED
44 public function __construct()
47 $this->uploadDao = $container->get(
'dao.upload');
57 $allOtherLicenses =
"";
58 if (!empty($licenses)) {
59 $licenses = array_unique(array_column($licenses,
'content'));
60 foreach ($licenses as $otherLicenses) {
61 $allOtherLicenses .= $otherLicenses.
", ";
63 $allOtherLicenses = rtrim($allOtherLicenses,
", ");
65 return $allOtherLicenses;
82 function summaryTable(Section $section, $uploadId, $userName, $mainLicenses, $licenses, $histLicenses, $otherStatement, $timestamp, $groupName, $packageUri, $assignedToUserName)
84 $cellRowContinue = array(
"vMerge" =>
"continue");
85 $firstRowStyle = array(
"size" => 14,
"bold" =>
true);
86 $firstRowStyle1 = array(
"size" => 12,
"bold" =>
true);
88 $cellRowSpan = array(
"vMerge" =>
"restart",
"valign" =>
"top");
89 $cellColSpan = array(
"gridSpan" => 3,
"valign" =>
"center");
94 $cellSecondLen = 3800;
100 $allHistLicenses =
"";
101 if (!empty($histLicenses)) {
102 foreach ($histLicenses as $histLicense) {
103 $allHistLicenses .= $histLicense[
"licenseShortname"].
", ";
105 $allHistLicenses = rtrim($allHistLicenses,
", ");
108 $newSw360Component = array();
109 $table = $section->addTable($this->tablestyle);
111 $table->addRow($rowWidth);
112 $table->addCell($cellFirstLen, $cellColSpan)->addText(htmlspecialchars(
" OSS Component Clearing report"),
113 $firstRowStyle,
"pStyle");
115 $table->addRow($rowWidth);
116 $table->addCell($cellFirstLen, $cellRowSpan)->addText(htmlspecialchars(
" Clearing Information"), $firstRowStyle,
"pStyle");
117 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
" Department"), $firstRowStyle1,
"pStyle");
118 $table->addCell($cellThirdLen)->addText(htmlspecialchars($otherStatement[
'ri_department']),
null,
"pStyle");
120 $table->addRow($rowWidth);
121 $table->addCell($cellFirstLen, $cellRowContinue);
122 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
" Report Created by"), $firstRowStyle1,
"pStyle");
123 $table->addCell($cellThirdLen)->addText(htmlspecialchars(
124 date(
"Y/m/d", $timestamp).
" ".$userName.
" (".$groupName.
") "),
null,
"pStyle");
126 $table->addRow($rowWidth);
127 $table->addCell($cellFirstLen, $cellRowContinue);
128 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
" Analyzed by"),$firstRowStyle1,
"pStyle");
129 $table->addCell($cellThirdLen)->addText(htmlspecialchars($assignedToUserName),
null,
"pStyle");
131 $table->addRow($rowWidth);
132 $table->addCell($cellFirstLen, $cellRowContinue);
133 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
" Reviewed by (opt.)"),$firstRowStyle1,
"pStyle");
134 $table->addCell($cellThirdLen)->addText(htmlspecialchars($otherStatement[
'ri_reviewed']),
null,
"pStyle");
136 $table->addRow($rowWidth);
137 $table->addCell($cellFirstLen, $cellRowContinue);
138 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
" Report release date"), $firstRowStyle1,
"pStyle");
139 $table->addCell($cellThirdLen)->addText(htmlspecialchars($otherStatement[
'ri_report_rel']),
null,
"pStyle");
141 $table->addRow($rowWidth);
142 $table->addCell($cellFirstLen, $cellRowSpan)->addText(htmlspecialchars(
" Component Information"), $firstRowStyle,
"pStyle");
143 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
" Community"), $firstRowStyle1,
"pStyle");
144 if (!empty($newSw360Component[
"Community"])) {
145 $table->addCell($cellThirdLen)->addText(htmlspecialchars($newSw360Component[
"Community"]),
null,
"pStyle");
147 $table->addCell($cellThirdLen)->addText(htmlspecialchars($otherStatement[
'ri_community']),
null,
"pStyle");
149 $table->addRow($rowWidth);
150 $table->addCell($cellFirstLen, $cellRowContinue);
151 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
" Component"), $firstRowStyle1,
"pStyle");
153 if (!empty($newSw360Component[
"Component"])) {
154 $table->addCell($cellThirdLen)->addText(htmlspecialchars($newSw360Component[
"Component"]),
null,
"pStyle");
156 $table->addCell($cellThirdLen)->addText(htmlspecialchars($otherStatement[
'ri_component']),
null,
"pStyle");
158 $table->addRow($rowWidth);
159 $table->addCell($cellFirstLen, $cellRowContinue);
160 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
" Version"), $firstRowStyle1,
"pStyle");
162 if (!empty($newSw360Component[
"Version"])) {
163 $table->addCell($cellThirdLen)->addText(htmlspecialchars($newSw360Component[
"Version"]),
null,
"pStyle");
165 $table->addCell($cellThirdLen)->addText(htmlspecialchars($otherStatement[
'ri_version']),
null,
"pStyle");
167 $table->addRow($rowWidth);
168 $table->addCell($cellFirstLen, $cellRowContinue);
169 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
" Component hash (SHA-1)"), $firstRowStyle1,
"pStyle");
171 $componentHash = $this->uploadDao->getUploadHashes($uploadId);
173 $table->addCell($cellThirdLen)->addText(htmlspecialchars($componentHash[
"sha1"]),
null,
"pStyle");
175 $table->addRow($rowWidth);
176 $table->addCell($cellFirstLen, $cellRowContinue);
177 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
" Release date"), $firstRowStyle1,
"pStyle");
179 if (!empty($newSw360Component[
"Release date"])) {
180 $table->addCell($cellThirdLen)->addText(htmlspecialchars($newSw360Component[
"Release date"]),
null,
"pStyle");
182 $table->addCell($cellThirdLen)->addText(htmlspecialchars($otherStatement[
'ri_release_date']),
null,
"pStyle");
185 $table->addRow($rowWidth);
186 $table->addCell($cellFirstLen, $cellRowContinue);
187 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
" Component Id"), $firstRowStyle1,
"pStyle");
189 if (!empty($newSw360Component[
"Component Id"])) {
190 $table->addCell($cellThirdLen)->addText(htmlspecialchars($newSw360Component[
"Component Id"]),
null,
"pStyle");
193 empty($otherStatement[
'ri_component_id']) ||
194 $otherStatement[
'ri_component_id'] ==
"NA"
198 $componentType = ComponentType::TYPE_MAP[
199 $otherStatement[
'ri_component_type']
202 $table->addCell($cellThirdLen)->addText(
203 $componentType . htmlspecialchars($otherStatement[
'ri_component_id']),
207 $table->addRow($rowWidth);
208 $table->addCell($cellFirstLen, $cellRowContinue);
209 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
" Main license(s)"), $firstRowStyle1,
"pStyle");
210 if (!empty($allMainLicenses)) {
211 $table->addCell($cellThirdLen)->addText(htmlspecialchars(
"$allMainLicenses."),
null,
"pStyle");
213 $table->addCell($cellThirdLen)->addText(htmlspecialchars(
"Main License(s) Not selected."),
null,
"pStyle");
216 $table->addRow($rowWidth2);
217 $table->addCell($cellFirstLen, $cellRowSpan)->addText(htmlspecialchars(
" "), $firstRowStyle,
"pStyle");
218 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
"Other license(s)"), $firstRowStyle1,
"pStyle");
219 if (!empty($allOtherLicenses)) {
220 $table->addCell($cellThirdLen)->addText(htmlspecialchars(
"$allOtherLicenses."),
null,
"pStyle");
222 $table->addCell($cellThirdLen)->addText(htmlspecialchars(
"License(s) Not Identified."),
null,
"pStyle");
225 $table->addRow($rowWidth2);
226 $table->addCell($cellFirstLen, $cellRowSpan)->addText(htmlspecialchars(
" "), $firstRowStyle,
"pStyle");
227 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
"Fossology Upload/Package Link"), $firstRowStyle1,
"pStyle");
228 $table->addCell($cellThirdLen)->addText(htmlspecialchars(
" ".$packageUri.
""),
null,
"pStyle");
230 $table->addRow($rowWidth2);
231 $table->addCell($cellFirstLen, $cellRowSpan)->addText(htmlspecialchars(
" "), $firstRowStyle,
"pStyle");
232 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
"SW360 Portal Link"), $firstRowStyle1,
"pStyle");
233 $table->addCell($cellThirdLen)->addText(htmlspecialchars($otherStatement[
'ri_sw360_link']),
null,
"pStyle");
235 $table->addRow($rowWidth2);
236 $table->addCell($cellFirstLen, $cellRowSpan)->addText(htmlspecialchars(
" "), $firstRowStyle,
"pStyle");
237 $table->addCell($cellSecondLen)->addText(htmlspecialchars(
"Result of License Scan"), $firstRowStyle1,
"pStyle");
238 if (!empty($allHistLicenses)) {
239 $table->addCell($cellThirdLen)->addText(htmlspecialchars(
"$allHistLicenses."),
null,
"pStyle");
241 $table->addCell($cellThirdLen)->addText(htmlspecialchars(
"No License found by the Scanner"),
null,
"pStyle");
244 $section->addTextBreak();
245 $section->addTextBreak();
summaryTable(Section $section, $uploadId, $userName, $mainLicenses, $licenses, $histLicenses, $otherStatement, $timestamp, $groupName, $packageUri, $assignedToUserName)
Design the summaryTable of the report.
accumulateLicenses($licenses)
Remove the duplicate licenses.