Commit 36353614 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_travel_expense: Add support for PDF as proof of payment

parent 65c1dc88
......@@ -73,7 +73,7 @@
<div class="ui-field-contain">
<label data-i18n="Photo">Photo</label>
<input name="photo" type="file" accept="image/*" capture="camera">
<input name="photo" type="file"><!--accept="image/*" capture="camera"-->
</div>
<div class="ui-field-contain">
......
......@@ -68,6 +68,7 @@
<value>
<tuple>
<string>contributor/person_module/2</string>
<string>contributor/person_module/5</string>
</tuple>
</value>
</item>
......@@ -232,7 +233,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>P4</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -246,7 +247,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.44329.14852.21316</string> </value>
<value> <string>960.56103.37527.44765</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +265,7 @@
</tuple>
<state>
<tuple>
<float>1484576962.29</float>
<float>1502900981.42</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -410,6 +410,7 @@
.push(function (result) {
img = new Image();
img.src = result.target.result;
gadget.options.doc.photo_data = img.src;
return RSVP.all([
gadget.props.deferred1.promise,
......@@ -426,7 +427,6 @@
ctx.fillText('Longitude: ' + gadget.props.geoLocation.coords.longitude +" Latitude: " + gadget.props.geoLocation.coords.latitude, 0, canvas.height - 20);
gadget.options.doc.photo_data = canvas.toDataURL();
*/
gadget.options.doc.photo_data = img.src;
preview.src = gadget.options.doc.photo_data;
});
}
......
......@@ -68,6 +68,7 @@
<value>
<tuple>
<string>contributor/person_module/2</string>
<string>contributor/person_module/5</string>
</tuple>
</value>
</item>
......@@ -228,7 +229,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>cedric.le.ninivin</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -242,7 +243,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.58658.21925.32853</string> </value>
<value> <string>961.29556.33516.42052</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +261,7 @@
</tuple>
<state>
<tuple>
<float>1486473658.84</float>
<float>1502904411.77</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -74,13 +74,17 @@ publication_section = portal.ERP5Site_getPreferredExpenseDocumentPublicationSect
photo_data = record.getPhotoData()
if photo_data:
if "," in photo_data and ticket:
photo_data = photo_data.split(",")[1]
photo_type, photo_data = photo_data.split(",")
filename="tmp.png"
# XXX This is getting more hackish
if "application/pdf" in photo_type:
filename="tmp.pdf"
image = portal.portal_contributions.newContent(
data = photo_data.decode('base64'),
reference=ticket.getReference()+ "-justificatif",
title = ticket.getReference() + " Justificatif",
description = ticket.getDescription(),
filename="tmp.png",
filename=filename,
follow_up=ticket.getRelativeUrl(),
publication_section=publication_section.getRelativeUrl(),
group=ticket.getDestinationDecisionValue().getGroup()
......
......@@ -301,7 +301,7 @@
<key> <string>_text</string> </key>
<value> <string encoding="cdata"><![CDATA[
python:\'<a href="%(image_url)s"><img src="%(image_url)s?display=large"></a>\' % {\'image_url\': here.ExpenseValidationRequest_getRelatedExpenseProofUrl()}
python:\'<a href="%(image_url)s"><img src="%(image_url)s?format=png&display=large"></a>\' % {\'image_url\': here.ExpenseValidationRequest_getRelatedExpenseProofUrl()}
]]></string> </value>
</item>
......
Markdown is supported
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