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 @@ ...@@ -73,7 +73,7 @@
<div class="ui-field-contain"> <div class="ui-field-contain">
<label data-i18n="Photo">Photo</label> <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>
<div class="ui-field-contain"> <div class="ui-field-contain">
......
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
<value> <value>
<tuple> <tuple>
<string>contributor/person_module/2</string> <string>contributor/person_module/2</string>
<string>contributor/person_module/5</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -232,7 +233,7 @@ ...@@ -232,7 +233,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>P4</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -246,7 +247,7 @@ ...@@ -246,7 +247,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.44329.14852.21316</string> </value> <value> <string>960.56103.37527.44765</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -264,7 +265,7 @@ ...@@ -264,7 +265,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1484576962.29</float> <float>1502900981.42</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -410,6 +410,7 @@ ...@@ -410,6 +410,7 @@
.push(function (result) { .push(function (result) {
img = new Image(); img = new Image();
img.src = result.target.result; img.src = result.target.result;
gadget.options.doc.photo_data = img.src;
return RSVP.all([ return RSVP.all([
gadget.props.deferred1.promise, gadget.props.deferred1.promise,
...@@ -426,7 +427,6 @@ ...@@ -426,7 +427,6 @@
ctx.fillText('Longitude: ' + gadget.props.geoLocation.coords.longitude +" Latitude: " + gadget.props.geoLocation.coords.latitude, 0, canvas.height - 20); 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 = canvas.toDataURL();
*/ */
gadget.options.doc.photo_data = img.src;
preview.src = gadget.options.doc.photo_data; preview.src = gadget.options.doc.photo_data;
}); });
} }
......
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
<value> <value>
<tuple> <tuple>
<string>contributor/person_module/2</string> <string>contributor/person_module/2</string>
<string>contributor/person_module/5</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -228,7 +229,7 @@ ...@@ -228,7 +229,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>cedric.le.ninivin</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -242,7 +243,7 @@ ...@@ -242,7 +243,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.58658.21925.32853</string> </value> <value> <string>961.29556.33516.42052</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +261,7 @@ ...@@ -260,7 +261,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1486473658.84</float> <float>1502904411.77</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -74,13 +74,17 @@ publication_section = portal.ERP5Site_getPreferredExpenseDocumentPublicationSect ...@@ -74,13 +74,17 @@ publication_section = portal.ERP5Site_getPreferredExpenseDocumentPublicationSect
photo_data = record.getPhotoData() photo_data = record.getPhotoData()
if photo_data: if photo_data:
if "," in photo_data and ticket: 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( image = portal.portal_contributions.newContent(
data = photo_data.decode('base64'), data = photo_data.decode('base64'),
reference=ticket.getReference()+ "-justificatif", reference=ticket.getReference()+ "-justificatif",
title = ticket.getReference() + " Justificatif", title = ticket.getReference() + " Justificatif",
description = ticket.getDescription(), description = ticket.getDescription(),
filename="tmp.png", filename=filename,
follow_up=ticket.getRelativeUrl(), follow_up=ticket.getRelativeUrl(),
publication_section=publication_section.getRelativeUrl(), publication_section=publication_section.getRelativeUrl(),
group=ticket.getDestinationDecisionValue().getGroup() group=ticket.getDestinationDecisionValue().getGroup()
......
...@@ -301,7 +301,7 @@ ...@@ -301,7 +301,7 @@
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string encoding="cdata"><![CDATA[ <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> ]]></string> </value>
</item> </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