{% load i18n %}

{% trans 'Search the IATI Datastore for this activity' %}

{% trans 'To see your official IATI record visit' %} https://www.iatiregistry.org/publisher

{% csrf_token %}

{% trans 'Compare your information' %}

{% trans 'Below compare your local Mohinga activity with the activity reported to the IATI Registry. If these activities match, please link your IATI activity to Mohinga.' %}

{% trans "Selecting 'Create Link' will link these activities, but will not import data. You can control what financial data is imported in the next step." %}

{% trans 'Locally Reported' %} {% trans 'Reported to IATI' %}
{% trans 'IATI Activity Identifier' %}
none { data.activity.iati_identifier }
{% trans 'IATI Activity Identifier' %}
{ data.iati_data.activity.iati_id }
{% trans 'Activity Title' %}
{ _.get(data, ['activity','title_set', 0, 'title'], "-") }
{% trans 'Activity Title' %}
{ data.iati_data.activity.title }
{% trans 'Activity Status' %}
{ data.activity.activity_status.name }
{% trans 'Activity Status' %}
{ data.iati_data.activity.status }
{% trans 'Reporting Organisation' %}
{ data.activity.reporting_organisation.name }
{% trans 'Reporting Organisation' %}
{ data.iati_data.activity.reporting_org }
{% trans 'Financial Summary' %}
{% trans 'Type' %} {% trans 'Amt. (USD)' %} {% trans '#' %}
{% trans 'Commit.' %} { openly_commitments } { openly_commitments_count }
{% trans 'Incoming' %} { openly_incoming } { openly_incoming_count }
{% trans 'Outgoing' %} { openly_outgoing } { openly_outgoing_count }
{% trans 'Budget' %} { openly_budgets } { data.budgets.length }
{% trans 'Financial Summary' %}
{% trans 'Type' %} {% trans 'Amt. (USD)' %} {% trans '#' %}
{% trans 'Commit.' %} { accounting.formatMoney(data.iati_data.transactions['C']['raw_sum'], "", 0); } { data.iati_data.transactions['C']['raw_count'] }
{% trans 'Incoming' %} { accounting.formatMoney(data.iati_data.transactions['IF']['raw_sum'], "", 0); } { data.iati_data.transactions['IF']['raw_count'] }
{% trans 'Outgoing' %} { accounting.formatMoney(data.iati_data.transactions['OF']['raw_sum'], "", 0); } { data.iati_data.transactions['OF']['raw_count'] }
{% trans 'Budget' %} { accounting.formatMoney(data.iati_data.transactions['B']['raw_sum'], "", 0);} { data.iati_data.transactions['B']['raw_count'] }
var tag = this; tag.mixin('IatiSyncModalMixin'); tag.on('before-mount', function() { if (!data.iati_data.activity) { // if nothing linked yet or bad link setup default values data.iati_data.activity = { iati_id: '', title: '', status: '', reporting_org: '', }; } });

{% trans 'Are you sure you want to sync from IATI?' %}

{% trans 'This action will replace selected locally reported transactions for this activity with those contained within the IATI Registry.' %}


{% trans 'When IATI Sync is activated, you will no longer be able to edit transactions locally for the transaction types you have selected to sync. To make changes, you will need to edit the relevant official IATI Activity File reported to the IATI Registry.' %}


{% trans 'Users can choose to stop IATI Sync at any time and edit imported transactions locally. However, those local changes would be lost if users choose to turn IATI Sync back on again.' %}

var tag = this; tag.mixin('IatiSyncModalMixin')

{% trans 'Revert back to manual entry?' %}

{% trans 'The financial information in your activity will remain as of the last import date.' %}

var tag = this; tag.mixin('IatiSyncModalMixin')
var tag = this; function parent(event){return _.invoke(tag.parent, event, tag)} tag.toggle = function(){parent('toggle')} tag.hide = function(){parent('hide')} tag.save = function(e) { e.preventDefault(); var form = $("#oipaActivityLinkForm"); tag.hide(); $.confirm({ closeIcon: false, type: 'blue', theme: 'modern', columnClass: 'medium', title: 'Saving IATI Sync settings', content: function() { var self = this; var form_data = {}; self.setContentAppend('
'+'{% trans "Saving changes to IATI Sync settings" %}'+'...
'); return $.ajax({ type: 'POST', url: "{% url 'oipa_activity_link_update' %}", data: form.serialize(), headers: { 'X-CSRFTOKEN': window.csrf_token } }).done(function (res) { /* Define the wait-until-ready ajax loop */ /* Expected behaviour is a 302: redirect to the job specific page, 202s until ready, then a 200 */ var makeSyncActivitiesRequest = function(job){ var url = "{% url 'oipa_sync_activities' %}" + res.activity_id + '?celerize'; if (job) { url = url + '&job=' + job} var request = $.ajax({ type: 'GET', url: url }); request.done(function(){ if (request.status == 202){ /* 2-second Loop on a "202:Accepted" return code */ return setTimeout(function(){makeSyncActivitiesRequest(request.responseJSON.job)}, 2000); } else { /* Hopefully this is a 200 code */ setTimeout(function hide(){ /* This races the "fade in" if the result returns very quickly */ $('#iatiSyncRunning').hide(300, function() { self.setContentAppend('
'+" {% trans "IATI Sync completed." %}"+'
'); self.buttons.close_success.show(); }) }, 1000) } }).fail(function (err) { $('#iatiSyncRunning').hide(300, function() { self.setContentAppend('
'+" {% trans "Error updating IATI Sync settings." %}"+'
'); self.buttons.close_fail.show(); }); }) }; self.setContentAppend('
'+" {% trans "IATI Sync settings updated." %}"+'
'); self.setContentAppend('
'+"{% trans "Full IATI Sync of data is running..." %}"+'
'); self.setContentAppend('

'); /* Begin the request loop */ makeSyncActivitiesRequest(); }) }, buttons: { close_success: { text: "Refresh", isHidden: true, action: function() { window.location.reload(); } }, close_fail: { text: "Close", isHidden: true, action: function() { } } } }); } tag.breakUp = function(e) { var form = $("#oipaActivityLinkForm"); var xhr = $.ajax({ type: 'POST', url: "{% url 'oipa_activity_link_clear' %}", data: form.serialize(), headers: { 'X-CSRFTOKEN': window.csrf_token } }).done(function (data) { tag.hide(); window.banner_message.hide('danger'); window.banner_message.show('{% trans "Suspended IATI Sync." %}', 'success'); window.location.reload(); }).fail(function (err) { tag.hide(); window.banner_message.hide('success'); window.banner_message.show('{% trans "Error suspending IATI Sync." %}', 'danger'); }); e.preventDefault(); } tag.search_for_data = true; tag.compare_data = false; tag.oipa_temp_data = {}; tag.search_again = function (e) { tag.search_for_data = true; tag.compare_data = false; tag.update(); } tag.totals = {}; function calc_sums(trans) { return _(trans).map('value').map(_.toNumber).sum(); } tag.on('before-mount', function(){ _.map(tag.opts.totals, function(v, k){ tag.totals[k] = accounting.formatMoney(v, 'USD ', 0) }) // calculate sums for Openly transaction and budget data if (data.budgets.length > 0) { tag.openly_budgets = accounting.formatMoney(calc_sums(data.budgets), "", 0); } else { tag.openly_budgets = "0"; } if (data.transactions.length > 0) { var commitment_temp = data.transactions.filter(t => t.transaction_type == 'C'); var outgoing_temp = data.transactions.filter(t => (t.transaction_type == 'D' || t.transaction_type == 'E')); var incoming_temp = data.transactions.filter(t => t.transaction_type == 'IF'); tag.openly_commitments = commitment_temp.length > 0 ? accounting.formatMoney(calc_sums(commitment_temp), "", 0) : "0"; tag.openly_commitments_count = commitment_temp.length; tag.openly_outgoing = outgoing_temp.length > 0 ? accounting.formatMoney(calc_sums(outgoing_temp), "", 0) : "0"; tag.openly_outgoing_count = outgoing_temp.length; tag.openly_incoming = incoming_temp.length > 0 ? accounting.formatMoney(calc_sums(incoming_temp), "", 0) : "0"; tag.openly_incoming_count = incoming_temp.length; } }) tag.fetchIati = function (e) { // hide error message $('#iatiFetchError').hide(); $('#otherFetchError').hide(); // show processing spinner $('#iatiFetchLoader').show(); var request_data = { 'openly_id': document.getElementById('aims-activity-id').value, 'iati_identifier': document.getElementById('oipa-iati-id').value, 'celerize': 'True', }; if (tag.job){ request_data.job = tag.job }; var xhr = $.ajax({ type: 'GET', url: "{% url 'oipa_activity_by_iati_identifier' %}", data: request_data, headers: { 'X-CSRFTOKEN': window.csrf_token } }); xhr.done(function (res) { if (xhr.status == 202){ /* Assert that this is type 200 OR type 202 AND has a "job" UUID in json Return type 202: Accepted indicated the server is still waiting for OIPA Exit and call tag.fetchIati until we have a 200 */ if (res.job){tag.job = res.job}; if (res.info) { tag.update({xhrmessage:res.info}) }; return setTimeout(function(){tag.fetchIati(e)}, 2000); } // hide processing spinner $('#iatiFetchLoader').hide(); if (res['activity'] && res['transactions'] && res['validation_results']) { tag.compare_data = true; tag.search_for_data = false; // set iati activity and transaction data data.iati_data.activity = res['activity']; data.iati_data.transactions = res['transactions']; data.iati_data.validation_results = res['validation_results']; } else { // show error message $('#iatiFetchError').show(); // wiggle input field with JS shake function $('#oipa-iati-id').shake(); } tag.update(); }).fail(function (err) { $('#iatiFetchLoader').hide(); $('#otherFetchError').show(); $('#oipa-iati-id').shake(); }); e.preventDefault(); } tag.confirmLink = function(e) { var form = $('#iatiIdForm'); var xhr = $.ajax({ type: 'POST', url: "{% url 'iati_identifier_update' %}", data: form.serialize(), headers: { 'X-CSRFTOKEN': window.csrf_token } }).done(function (res) { window.banner_message.hide('danger'); window.banner_message.show('{% trans "IATI Identifier Link updated." %}', 'success'); window.location.reload(); }).fail(function (err) { window.banner_message.hide('success'); window.banner_message.show('{% trans "Error updating IATI Identifier Link." %}', 'danger'); }); e.preventDefault(); } tag.deleteLink = function(e) { e.preventDefault(); $.confirm({ type: 'orange', theme: 'modern', icon: 'glyphicon glyphicon-warning-sign', columnClass: 'medium', title: 'Are you sure you want to remove this IATI Identifier Link?', content: 'Removing the IATI Identifier will stop all IATI Syncing, and remove the IATI Sync record. Previously Synced data will not be affected and must be removed manually.', buttons: { confirm: { btnClass: 'btn-danger', action: function () { var form = $('#iatiIdForm'); var xhr = $.ajax({ type: 'POST', url: "{% url 'oipa_activity_link_delete' %}", data: form.serialize(), headers: { 'X-CSRFTOKEN': window.csrf_token } }).done(function (res) { window.banner_message.hide('danger'); window.banner_message.show('{% trans "IATI Identifier Link deleted." %}', 'success'); window.location.reload(); }).fail(function (err) { window.banner_message.hide('success'); window.banner_message.show('{% trans "Error deleting IATI Identifier Link." %}', 'danger'); }); } }, cancel: { btnClass: 'btn-default', action: function () { parent('hide'); } } } }); } jQuery.fn.shake = function(interval, distance, times) { interval = typeof interval == "undefined" ? 100 : interval; distance = typeof distance == "undefined" ? 10 : distance; times = typeof times == "undefined" ? 3 : times; var jTarget = $(this); jTarget.css('position','relative'); for(var iter=0;iter<(times+1);iter++) { jTarget.animate({ left: ((iter%2==0 ? distance : distance*-1))}, interval); } return jTarget.animate({ left: 0},interval); }