[fixes] js templating to get cheque print view

This commit is contained in:
Saurabh 2016-05-16 15:48:21 +05:30
parent 9ca9f2d551
commit 2fc0ffad34

View File

@ -13,36 +13,39 @@ frappe.ui.form.on('Cheque Print Template', {
$(frm.fields_dict.cheque_print_preview.wrapper).empty() $(frm.fields_dict.cheque_print_preview.wrapper).empty()
$("<div style='position: relative; overflow-x: scroll;'>\
<div id='cheque_preview' style='width:"+ frm.doc.cheque_width + "cm; \ var template = '<div style="position: relative; overflow-x: scroll;">\
height: "+ frm.doc.cheque_height +"cm;\ <div id="cheque_preview" style="width: {{ cheque_width }}cm; \
background-image: url("+frm.doc.scanned_cheque+");\ height: {{ cheque_height }}cm;\
background-image: url({{ scanned_cheque }});\
background-repeat: no-repeat;\ background-repeat: no-repeat;\
background-size: cover;'>\ background-size: cover;">\
<span style='top: "+frm.doc.date_dist_from_top_edge+"cm;\ <span style="top: {{ date_dist_from_top_edge }}cm;\
left: "+ flt(frm.doc.date_dist_from_left_edge) +"cm;\ left: {{ date_dist_from_left_edge }}cm;\
position: absolute;'> "+ frappe.datetime.obj_to_user() +" </span>\ position: absolute;"> {{ frappe.datetime.obj_to_user() }} </span>\
<span style='top: "+frm.doc.acc_no_dist_from_top_edge+"cm;\ <span style="top: {{ acc_no_dist_from_top_edge }}cm;\
left: "+ frm.doc.acc_no_dist_from_left_edge +"cm;\ left: {{ acc_no_dist_from_left_edge }}cm;\
position: absolute;'> Acc. No. </span>\ position: absolute;"> Acc. No. </span>\
<span style='top:"+ frm.doc.payer_name_from_top_edge +"cm;\ <span style="top: {{ payer_name_from_top_edge }}cm;\
left: "+ flt(frm.doc.payer_name_from_left_edge) +"cm;\ left: {{ payer_name_from_left_edge }}cm;\
position: absolute;'> Payer Name </span>\ position: absolute;"> Payer Name </span>\
<span style='top:"+ frm.doc.amt_in_words_from_top_edge +"cm;\ <span style="top:{{ amt_in_words_from_top_edge }}cm;\
left: "+ flt(frm.doc.amt_in_words_from_left_edge) +"cm;\ left: {{ amt_in_words_from_left_edge }}cm;\
position: absolute;\ position: absolute;\
display: block;\ display: block;\
width: "+frm.doc.amt_in_word_width+"cm;\ width: {{ amt_in_word_width }}cm;\
line-height: "+frm.doc.amt_in_words_line_spacing+"cm;\ line-height: {{ amt_in_words_line_spacing }}cm;\
word-wrap: break-word;'> Amount in Words </span>\ word-wrap: break-word;"> Amount in Words </span>\
<span style='top:"+ frm.doc.amt_in_figures_from_top_edge +"cm;\ <span style="top: {{ amt_in_figures_from_top_edge }}cm;\
left: "+ flt(frm.doc.amt_in_figures_from_left_edge) +"cm;\ left: {{ amt_in_figures_from_left_edge }}cm;\
position: absolute;'> 1000 </span>\ position: absolute;"> 1000 </span>\
<span style='top:"+ frm.doc.signatory_from_top_edge +"cm;\ <span style="top: {{ signatory_from_top_edge }}cm;\
left: "+ flt(frm.doc.signatory_from_left_edge) +"cm;\ left: {{ signatory_from_left_edge }}cm;\
position: absolute;'> Signatory Name </span>\ position: absolute;"> Signatory Name </span>\
</div>\ </div>\
</div>").appendTo(frm.fields_dict.cheque_print_preview.wrapper) </div>';
$(frappe.render(template, frm.doc)).appendTo(frm.fields_dict.cheque_print_preview.wrapper)
} }
} }
}); });