$xls = new PHPExcel();
$sheet = $xls->getActiveSheet();
$sheet->freezePane('B2');
- $standardSettings = ['book_id' => 'book_id', 'lang' => 'lang', 'theme' => 'theme', 'status' => 'status', 'proprietaire_id' => 'owner', 'date' => 'date', 'changedate' => 'changedate', 'exportdatas' => 'exportdata'];
+ $standardSettings = ['book_id' => 'book_id', 'lang' => 'lang', 'theme' => 'theme', 'status' => 'status', 'proprietaire_id' => 'owner', 'date' => 'date', 'changedate' => 'changedate', 'hosting' => 'hosting', 'exportdatas' => 'exportdata'];
$j = 0;
foreach ($standardSettings as $column => $label) {
+ $readonly = false;
if ($label === 'exportdata') {
-
+ $readonly = true;
} else {
$sheet->getColumnDimensionByColumn($j)->setAutoSize(true);
}
+ if ($label === 'hosting') {
+ $readonly = true;
+ }
+
+ if (strpos($column, 'date') !== false) {
+ $readonly = true;
+ }
+ if ($readonly) {
+ self::_readonlyStyle($sheet->getStyle(PHPExcel_Cell::stringFromColumnIndex($j)));
+ }
$sheet->setCellValueByColumnAndRow($j, 1, $label);
$j++;
}
foreach ($p->getForms() as $form) {
$form = $p->getForm($form, true);
foreach ($form['fields'] as $k => $field) {
+ $readonly = false;
if (!$field['editable']) {
- continue;
+ $readonly = true;
}
+ if ($readonly) {
+ self::_readonlyStyle($sheet->getStyle(PHPExcel_Cell::stringFromColumnIndex($j)));
+ }
$sheet->getCommentByColumnAndRow($j, 1)->getText()->createTextRun($field['label']);
$sheet->getColumnDimensionByColumn($j)->setAutoSize(true);
$sheet->setCellValueByColumnAndRow($j, 1, $k);
+
$paramCols[] = $k;
$j++;
}
foreach ($books as $id => $book) {
$j = 0;
foreach ($standardSettings as $column => $label) {
- $val = $book->$column;
+ $url = false;
+ if ($column === 'hosting') {
+ $export = json_decode($book->exportdatas, true);
+ if (isset($export['install_hosting']['online']['dir']) && $export['install_hosting']['online']['dir']) {
+ $val = 'https://hosting.fluidbook.com/' . $export['install_hosting']['online']['dir'];
+ $url = $val;
+ } else {
+ $val = '-';
+ }
+ } else {
+ $val = $book->$column;
+ }
if (strpos($column, 'date') !== false) {
$val = date('Y-m-d', $val);
}
$sheet->setCellValueByColumnAndRow($j, $i, $val);
+ if ($url) {
+ $sheet->getCellByColumnAndRow($j, $i)->getHyperlink()->setUrl($url);
+ }
+
$j++;
}
foreach ($paramCols as $col) {
$writer->save('php://output');
exit;
}
+
+ /**
+ * @param $style PHPExcel_Style
+ */
+ protected static function _readonlyStyle($style)
+ {
+ $style->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setRGB('dddddd');
+ $style->getFont()->getColor()->setRGB('666666');
+ }
}