2013-12-09 13:10:15 +00:00
|
|
|
$(document).ready(function () {
|
|
|
|
$('a.js_update_line_json').on('click', function (ev) {
|
|
|
|
ev.preventDefault();
|
|
|
|
var $link = $(ev.currentTarget);
|
|
|
|
var href = $link.attr("href");
|
2014-01-03 15:54:45 +00:00
|
|
|
var order_id = href.match(/order_id=([0-9]+)/);
|
2013-12-09 13:10:15 +00:00
|
|
|
var line_id = href.match(/update_line\/([0-9]+)/);
|
2014-01-03 15:54:45 +00:00
|
|
|
var token = href.match(/token=(.*)/);
|
2013-12-09 13:10:15 +00:00
|
|
|
openerp.jsonRpc("/quote/update_line/", 'call', {
|
|
|
|
'line_id': line_id[1],
|
2013-12-16 05:24:51 +00:00
|
|
|
'order_id': parseInt(order_id[1]),
|
2014-01-03 15:54:45 +00:00
|
|
|
'token': token[1],
|
2013-12-09 13:10:15 +00:00
|
|
|
'remove': $link.is('[href*="remove"]'),
|
2013-12-16 05:24:51 +00:00
|
|
|
'unlink': $link.is('[href*="unlink"]')
|
2013-12-09 13:10:15 +00:00
|
|
|
})
|
|
|
|
.then(function (data) {
|
2013-12-10 10:44:42 +00:00
|
|
|
if(!data){
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
$link.parents('.input-group:first').find('.js_quantity').val(data[0]);
|
|
|
|
$('[data-id="total_amount"]>span').html(data[1]);
|
2013-12-09 13:10:15 +00:00
|
|
|
});
|
|
|
|
return false;
|
2013-12-02 12:34:37 +00:00
|
|
|
});
|
2014-01-07 13:42:20 +00:00
|
|
|
|
2014-01-18 10:46:34 +00:00
|
|
|
$('#modelaccept').on('shown.bs.modal', function (e) {
|
2014-01-23 13:04:29 +00:00
|
|
|
$("#signature").empty().jSignature({'decor-color' : '#D1D0CE'});
|
2014-01-18 10:46:34 +00:00
|
|
|
});
|
2014-01-20 06:18:43 +00:00
|
|
|
|
2014-01-18 10:46:34 +00:00
|
|
|
$('#sign_clean').on('click', function (e) {
|
|
|
|
$("#signature").jSignature('reset');
|
|
|
|
});
|
2014-01-20 06:18:43 +00:00
|
|
|
|
2014-01-18 10:46:34 +00:00
|
|
|
$('form.js_accept_json').submit(function(ev){
|
|
|
|
ev.preventDefault();
|
|
|
|
var $link = $(ev.currentTarget);
|
|
|
|
var href = $link.attr("action");
|
|
|
|
var order_id = href.match(/accept\/([0-9]+)/);
|
|
|
|
var token = href.match(/token=(.*)/);
|
2014-01-21 12:53:14 +00:00
|
|
|
var sign = false;
|
|
|
|
var signer_name = false;
|
|
|
|
if($('#signature').length > 0){
|
|
|
|
var isSignature=$("#signature").jSignature('getData','base30')[1].length>1?true:false;
|
|
|
|
if (isSignature)
|
2014-01-24 12:29:29 +00:00
|
|
|
{
|
2014-01-21 12:53:14 +00:00
|
|
|
sign = JSON.stringify($("#signature").jSignature("getData",'image')[1]);
|
2014-01-24 12:29:29 +00:00
|
|
|
}
|
2014-01-21 12:53:14 +00:00
|
|
|
signer_name = $("#name").val();
|
|
|
|
}
|
2014-01-18 10:46:34 +00:00
|
|
|
openerp.jsonRpc("/quote/accept/", 'call', {
|
|
|
|
'order_id': parseInt(order_id[1]),
|
|
|
|
'token': token[1],
|
2014-01-21 12:53:14 +00:00
|
|
|
'signer': signer_name,
|
|
|
|
'sign': sign,
|
2014-01-18 10:46:34 +00:00
|
|
|
})
|
|
|
|
.then(function (data) {
|
2014-01-24 12:29:29 +00:00
|
|
|
if(_.isEmpty(data[0])){
|
2014-01-21 12:53:14 +00:00
|
|
|
$('#modelaccept').modal('hide');
|
|
|
|
var url = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port : "")
|
|
|
|
window.location.replace(url +'/quote/'+order_id[1]+'/'+token[1]+'?message=3');
|
|
|
|
} else{
|
|
|
|
if (data[0]['signer']) $('#signer').addClass('has-error'); else $('#signer').removeClass('has-error');
|
|
|
|
if (data[0]['sign']) $('#drawsign').addClass('panel-danger'); else $('#drawsign').removeClass('panel-danger');
|
|
|
|
}
|
2014-01-18 10:46:34 +00:00
|
|
|
});
|
|
|
|
return false
|
|
|
|
});
|
2014-01-07 13:42:20 +00:00
|
|
|
// automatically generate a menu from h1 and h1 tag in content
|
2014-01-20 20:52:29 +00:00
|
|
|
var ul = $('[data-id="quote_sidebar"]');
|
2014-01-07 13:42:20 +00:00
|
|
|
var sub_li = null;
|
|
|
|
var sub_ul = null;
|
|
|
|
$("section h1, section h2").each(function() {
|
|
|
|
switch (this.tagName.toLowerCase()) {
|
|
|
|
case "h1":
|
2014-01-16 06:43:29 +00:00
|
|
|
id = _.uniqueId('quote_header_')
|
2014-01-20 20:52:29 +00:00
|
|
|
$(this.parentNode).attr('id',id)
|
2014-01-16 06:43:29 +00:00
|
|
|
sub_li = $("<li>").html('<a href="#'+id+'">'+$(this).text()+'</a>').appendTo(ul);
|
2014-01-07 13:42:20 +00:00
|
|
|
sub_ul = null;
|
|
|
|
break;
|
|
|
|
case "h2":
|
|
|
|
id = _.uniqueId('quote_')
|
|
|
|
if (sub_li) {
|
|
|
|
if (!sub_ul) {
|
2014-01-16 06:43:29 +00:00
|
|
|
sub_ul = $("<ul class='nav'>").appendTo(sub_li);
|
2014-01-07 13:42:20 +00:00
|
|
|
}
|
2014-01-20 20:52:29 +00:00
|
|
|
$(this.parentNode).attr('id',id)
|
2014-01-07 13:42:20 +00:00
|
|
|
$("<li>").html('<a href="#'+id+'">'+$(this).text()+'</a>').appendTo(sub_ul);
|
2014-01-20 20:52:29 +00:00
|
|
|
}
|
2014-01-07 13:42:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2014-01-16 06:43:29 +00:00
|
|
|
|
2014-01-22 12:18:56 +00:00
|
|
|
var target_date = new Date($('#validity_date').val());
|
|
|
|
|
|
|
|
setInterval(function () {
|
|
|
|
var current_date = new Date();
|
|
|
|
var days_left = Math.floor((target_date - current_date)/86400000);
|
2014-01-23 10:23:37 +00:00
|
|
|
$('#countdown').html('<span><i class="fa fa-clock-o fa-2x"/><span class="day_counter">'+((days_left > 0) ? days_left : 0)+'</span><small class="days_left">Day(s)</small></span>')
|
2014-01-22 12:18:56 +00:00
|
|
|
}, 1000);
|
|
|
|
|
2013-12-02 12:34:37 +00:00
|
|
|
//vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
|
2014-01-07 13:42:20 +00:00
|
|
|
});
|