Commit 0bb8694b authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'excelDebug' into 'master'

Excel debug

See merge request !204
parents 5b063845 af69e21b
Pipeline #2760 passed with stages
in 3 minutes and 53 seconds
......@@ -7080,7 +7080,7 @@ Parameter and (element) sources
* *uid*: `uid:<tt-content record id>` - the tt_content.uid of a QFQ PageContent record (shown on hover in the backend). This will render
only the specified QFQ content record, without any Typo3 layout elements (Menu, Body,...)
QFQ will retrieve the tt-content's bodytext from the Typo3 database, parse it, and render it as a PDF. Parameters can be
passed: `uid:<tt-content record id>[?arg1=value1][&arg2=value2][...]` and will be available in the SIP store for the QFQ PageContent,
passed: `uid:<tt-content record id>[&arg1=value1][&arg2=value2][...]` and will be available in the SIP store for the QFQ PageContent,
or passed as wkhtmltopdf arguments, if applicable.
* *WKHTML Options* for `page`, `urlParam` or `url`:
......
......@@ -39,7 +39,7 @@ class HelperFile {
}
/**
* Returns a uniqe (use for temporary) filename, prefixed with QFQ TMP_FILE_PREFIX
* Returns a uniq (use for temporary) filename, prefixed with QFQ TMP_FILE_PREFIX
*
* @return bool|string
*/
......
......@@ -222,19 +222,19 @@ class Download {
/**
* Get the mimetype of $filename and store them in $rcMimetype.
* Checks if the extension of $outputFilename fit's to the mimetype. If not, append the mimetype extension.
*
* @param string $filename
* @param string $pathFileName
* @param string $outputFilename
* @param string $rcMimetype
*
* @return string possible updated $outputFilename, according the mimetype.
*/
private
function targetFilenameExtension($filename, $outputFilename, &$rcMimetype) {
private function targetFilenameExtension($pathFileName, $outputFilename, &$rcMimetype) {
$rcMimetype = mime_content_type($filename);
if ($pathFileName != '' && file_exists($pathFileName)) {
$rcMimetype = mime_content_type($pathFileName);
}
return $outputFilename;
}
......@@ -245,8 +245,7 @@ class Download {
* @param $outputFilename
* @throws \DownloadException
*/
private
function outputFile($file, $outputFilename) {
private function outputFile($file, $outputFilename) {
$json = '';
$flagJson = ($this->getOutputFormat() === DOWNLOAD_OUTPUT_FORMAT_JSON);
......@@ -295,14 +294,16 @@ class Download {
* @throws \CodeException
* @throws \DbException
* @throws \DownloadException
* @throws \UserFormException
* @throws \UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
* @throws \UserFormException
* @throws \UserReportException
*/
private
function getElement($element, $downloadMode, &$rcData) {
private function getElement($element, $downloadMode, &$rcData) {
$filename = '';
$rcArgs = array();
......@@ -391,8 +392,7 @@ class Download {
* @throws \UserFormException
* @throws \UserReportException
*/
private
function getEvaluatedBodyText($uid, $urlParam) {
private function getEvaluatedBodyText($uid, $urlParam) {
foreach ($urlParam as $key => $paramValue) {
$this->store->setVar($key, $paramValue, STORE_SIP);
}
......@@ -415,8 +415,7 @@ class Download {
* @return string ZIP filename - has to be deleted later.
* @throws \DownloadException
*/
private
function zipFiles(array $files) {
private function zipFiles(array $files) {
$zipFile = HelperFile::tempnam();
if (false === $zipFile) {
......@@ -462,14 +461,16 @@ class Download {
* @throws \CodeException
* @throws \DbException
* @throws \DownloadException
* @throws \UserFormException
* @throws \UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
* @throws \UserFormException
* @throws \UserReportException
*/
private
function doElements(array $vars, $outputMode) {
private function doElements(array $vars, $outputMode) {
$tmpFiles = array();
......@@ -515,6 +516,13 @@ class Download {
case DOWNLOAD_MODE_EXCEL:
$excel = new Excel();
$filename = $excel->process($tmpFiles, $tmpData);
if (empty($filename) || !file_exists($filename)) {
throw new \DownloadException(json_encode(
[ERROR_MESSAGE_TO_USER => 'New created Excel file is broken.',
ERROR_MESSAGE_TO_DEVELOPER => "File: '$filename'"]), ERROR_IO_READ_FILE);
}
if (empty($vars[DOWNLOAD_EXPORT_FILENAME])) {
if (HelperFile::isQfqTemp($filename)) {
$vars[DOWNLOAD_EXPORT_FILENAME] = DOWNLOAD_OUTPUT_FILENAME . ".xlsx";
......@@ -590,8 +598,7 @@ class Download {
* @throws \UserFormException
* @throws \UserReportException
*/
private
function doThumbnail($urlParam) {
private function doThumbnail($urlParam) {
$thumbnail = new Thumbnail();
$pathFilenameThumbnail = $thumbnail->process($urlParam, THUMBNAIL_VIA_DOWNLOAD);
......@@ -609,14 +616,16 @@ class Download {
* @throws \CodeException
* @throws \DbException
* @throws \DownloadException
* @throws \UserFormException
* @throws \UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
* @throws \UserFormException
* @throws \UserReportException
*/
public
function process($vars, $outputMode = OUTPUT_MODE_DIRECT) {
public function process($vars, $outputMode = OUTPUT_MODE_DIRECT) {
if (!is_array($vars)) {
$vars = $this->store->getStore(STORE_SIP);
......@@ -630,16 +639,14 @@ class Download {
/**
* @param $outputFormat
*/
private
function setOutputFormat($outputFormat) {
private function setOutputFormat($outputFormat) {
$this->outputFormat = $outputFormat;
}
/**
* @return string - DOWNLOAD_OUTPUT_FORMAT_RAW | DOWNLOAD_OUTPUT_FORMAT_JSON
*/
public
function getOutputFormat() {
public function getOutputFormat() {
return $this->outputFormat;
}
}
......
......@@ -523,7 +523,7 @@ var QfqNS = QfqNS || {};
if (data.status === "error") {
this._createError("Error while updating form:<br>" +
(data.message ? data.message : "No reason given"));
(data.message ? data.message : "No reason given"));
return;
}
......@@ -619,23 +619,6 @@ var QfqNS = QfqNS || {};
if (tabId) {
this.bsTabs.activateTab(tabId);
}
var form = document.getElementById(this.form.formId);
var inputs = form.elements;
for (var i = 0; i < inputs.length; i++) {
var e = inputs[i];
if(!e.willValidate) {
continue;
}
if(!e.checkValidity()) {
var updateTabId = this.bsTabs.getContainingTabIdForFormControl(e.getAttribute('name'));
if(updateTabId != tabId) {
this.bsTabs.addDot(updateTabId);
}
}
}
}
// Since we might have switched the tab, re-validate to highlight errors
......@@ -646,12 +629,6 @@ var QfqNS = QfqNS || {};
alert.timeout = 3000;
alert.show();
this.form.$form.each(function() {
if (!$(this).validate) {
}
});
if (!this.skipRequiredCheck) {
return;
}
......@@ -663,6 +640,7 @@ var QfqNS = QfqNS || {};
this.clearAllValidationStates();
}
submitReason = {
"submit_reason": this.lastButtonPress === "close" ? "save,close" : this.lastButtonPress
};
......@@ -1122,7 +1100,6 @@ var QfqNS = QfqNS || {};
};
n.QfqForm.prototype.getFormGroupByControlName = function (formControlName) {
console.log("Form Control Name: " + formControlName);
var $formControl = $("[name='" + formControlName + "']");
if ($formControl.length === 0) {
n.Log.debug("QfqForm.setValidationState(): unable to find form control with name '" + formControlName + "'");
......@@ -1146,13 +1123,12 @@ var QfqNS = QfqNS || {};
var $formGroup = this.getFormGroupByControlName(formControlName);
if ($formGroup) {
$formGroup.addClass("has-" + state);
$formGroup.addClass("testitest");
}
};
n.QfqForm.prototype.resetValidationState = function (formControlName) {
var $formGroup = this.getFormGroupByControlName(formControlName).find('input');
$formGroup.removeClass("has-danger");
var $formGroup = this.getFormGroupByControlName(formControlName);
$formGroup.removeClass("has-warning");
$formGroup.removeClass("has-error");
$formGroup.removeClass("has-success");
$formGroup.removeClass("has-danger");
......@@ -1345,4 +1321,4 @@ var QfqNS = QfqNS || {};
window.history.back();
};
})(QfqNS);
\ No newline at end of file
})(QfqNS);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment