-
Notifications
You must be signed in to change notification settings - Fork 283
Added new functionality to allow LaTeX generation of invoices. #875
base: master
Are you sure you want to change the base?
Conversation
extensions/ki_invoice/init.php
Outdated
} elseif (file_exists($tplFile.'/invoice.tex')) { | ||
$extension = 'LaTeX'; | ||
//Test if we can execute pdflatex | ||
$output = exec($kga['LaTeXExec']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you use is_executable($kga['LaTeXExec'])
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know about that function. I can use that instead if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please.
Hi @neerdragon! One thing I would request is check(s) for the existence of the
I would suggest that we dislay an error message instead of the input field for the executable in the admin section and then disable it in the invoice section as well. |
Hi @kevinpapst ! Ok, I will do that! It is kind of automatically deactivated in the invoice section if it cannot execute, but I'll look into changing that. What about the error message? Is it ok to simply replace the input field with a message? Or should it be more "fancy", like a floater? One more thing, I added a field in the database to store the executable, i.e. LaTeXExec, but I didn't dare change anything in the update database scripts... So I guess I need help with that if this is approved! |
…on of the pdflatex is tested.
Added fixes as suggested. |
please no floater. otherwise it would open every time you go to admin panel which would be very annoying. For the db migration: make sure the installer does contain the column and the updater adds it (and increment the version number!) |
extensions/ki_adminpanel/init.php
Outdated
if(!function_exists('exec')) { | ||
// deactivate latex functionality | ||
Kimai_Logger::logfile("Cannot execute external files. LaTeX invoices will be disabled."); | ||
$view->assign('canExecute', false); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
language/en.php
Outdated
@@ -257,6 +257,8 @@ | |||
"roundTimesheetEntries" => "Round new timesheet entries to", | |||
"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.", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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... :)
No floater. I just changed the input field to a text instead. |
Where is the class Kimai_Invoice_LaTeXRenderer actually? did you forget to add it? |
Yes, indeed I forgot to add two files... Should be all now! :/ |
please adjust your code to make it PSR2 compatible (StyleCI check is green). click the Details link to automatically get a patch file and apply it. |
I had a deeper look into your code now, made some changes and improvements but here are some things to consider:
|
Ok, I can change OCR to be a class. |
You somehow messed up the indentation. Could you please align your code properly? If you are using phpstorm, use the autoformating, that works pretty well :D Please also make your db changes so that this PR can be merged. |
//Create invoiceId | ||
$in = time(); | ||
$invoiceID = date('y', $in) . $customer['customerID'] . date('m', $in) . date('d', $in); | ||
require_once 'Checksum.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be dropped as autoloading works out of the box if the class is correctly named.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
} | ||
|
||
/** | ||
* @return pdf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does not return anything but just output the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to "@return null".
@simonschaufi Please double check my change to installer.php and updater.php as I feel a bit unsure that I got it right. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good so far but you forgot to raise the revision number in includes/version.php.
installer/install.php
Outdated
@@ -345,6 +345,7 @@ function quoteForSql($input) { | |||
('roundSeconds', '0'), | |||
('allowRoundDown', '0'), | |||
('defaultStatusID', '1') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comma missing in the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops.
Fixed. And increased revision by one in version.php
@simonschaufi It's all good now? |
I would like to test it myself before I merge it but didn't have the time yet. |
@simonschaufi Any progress on this issue? |
Thank you for your ping! Just for me, is this the minimal setup for ubuntu?
|
Yes, I can add some documentation! |
I would love to test this out on ubuntu 17.10!! Also, I can help proof the documentation if needed. On Ubuntu it has (at least in the past) been a bad idea to use apt-get to install texlive, because the ubuntu packages are not updated often enough, at times years behind the current distribution. The best way is to use the net installer, as described here: https://tex.stackexchange.com/a/1094/90087 |
Hey, this is the only PR or issue related to LaTeX for templates. But it looks like it's discontinued. Any chance for merging? I'm evaluating kimai for tracking the time I spend on various freelance projects. I've got my invoices, letter-templates and basically everything else in LaTeX, so autogenerating those from within kimai would be great! I'm not a php/web developer, but experienced enough with self hosting things like this, so I could test changes. Thanks in advance! |
@dwagenk There are some conflicts with this branch as you can see so I can't just merge it like that. You can also checkout the source of the fork and see if that works for you. I don't want to waist too much time with Latex as you are the second person who is interested in it. |
Changes proposed in this pull request:
Reason for this pull request: