Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Added new functionality to allow LaTeX generation of invoices. #875

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions extensions/ki_adminpanel/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@
$view->assign('roundSeconds', $kga['conf']['roundSeconds']);
}

if(!function_exists('exec')) {
// deactivate latex functionality
Kimai_Logger::logfile("Cannot execute external files. LaTeX invoices will be disabled.");
$view->assign('canExecute', false);
Copy link
Contributor

@simonschaufi simonschaufi Dec 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would name it "execAvailable". What do you think? canExecute sounds more like some internal stuff (object) can execute something.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I can change it!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

} else {
$view->assign('canExecute', true);
}

$view->assign('tab_advanced', $view->render("advanced.php"));
$view->assign('tab_database', $view->render("database.php"));
}
Expand Down
6 changes: 5 additions & 1 deletion extensions/ki_adminpanel/templates/scripts/advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@
<input type="text" name="roundSeconds" size="3" class="formfield" value="<?php echo $this->roundSeconds?>" <?php if (!$this->roundTimesheetEntries): ?> disabled="disabled" <?php endif; ?>> <?php echo $this->kga['lang']['seconds']?>
</div>
<div>
<input type="text" name="LaTeX_exec" size="45" value="<?php echo $this->escape($this->kga['LaTeXExec']) ?>" class="formfield"> <?php echo $this->kga['lang']['LaTeXExecutable']?>
<?php if ($this->canExecute): ?>
<input type="text" name="LaTeX_exec" size="45" value="<?php echo $this->escape($this->kga['LaTeXExec']) ?>" class="formfield"> <?php echo $this->kga['lang']['LaTeXExecutable']?>
<?php else: ?>
<?php echo $this->kga['lang']['cannotExecute']?>
<?php endif; ?>
</div>
<div id="formbuttons">
<input id="adminPanel_extension_form_editadv_submit" class="btn_ok" type="submit" value="<?php echo $this->kga['lang']['save']?>" />
Expand Down
3 changes: 1 addition & 2 deletions extensions/ki_invoice/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@
} elseif (file_exists($tplFile.'/invoice.tex')) {
$extension = 'LaTeX';
//Test if we can execute pdflatex
$output = exec($kga['LaTeXExec']);
if(strlen($output) == 0) {
if(!function_exists('exec') or !is_executable($kga['LaTeXExec'])) {
Kimai_Logger::logfile("Could not execute pdflatex. Check your installation!");
$extension = '';
}
Expand Down
1 change: 1 addition & 0 deletions language/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
"minutes" => "Minutes",
"seconds" => "Seconds",
"LaTeXExecutable" => "Full path to LaTeX executable, i.e., 'pdflatex'.",
"cannotExecute" => "Your system does not allow execution of external files. LaTeX invoice generation will be disabled.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a link where latex can be downloaded from?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but then it needs to be updated in case the link changes... I believe anyone who wants to use LaTeX will know where to find it. If not, a simple "google LaTeX" will give you the answer... :)

"and" => "and",
"customerlogin" => "customer login",
"expense" => "Expense",
Expand Down