Skip to content

Commit

Permalink
isk srp v1
Browse files Browse the repository at this point in the history
  • Loading branch information
jbs1 committed May 20, 2018
1 parent 859490f commit bc1895a
Show file tree
Hide file tree
Showing 15 changed files with 146 additions and 53 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Hosted here: http://eve-stuff.com/index.php

# EVE-srpmail

This is a small and simple tool to make the tedious task of of writing SRP mails easier for officers.
This is a small and simple tool to make the tedious task of writing SRP mails easier for officers.
This works for all corporations not just EVE uni as it pulls the infos about the corps and chars dynamically from the API.
Nothing will be save on the server itself for longer than the session.
As of now it only works if contracts are in stations not in citadels.
Expand Down
2 changes: 1 addition & 1 deletion ajax/corp-mem.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

try {
if(empty($_SESSION['corpmem'])){
$corpmem = $api_corp->getCorporationsCorporationIdMembers(corpid(charid()),$datasource);
$corpmem = $api_corp->getCorporationsCorporationIdMembers(corpid(),$datasource);
$split_ids=array_chunk($corpmem,100);
$chars=array();

Expand Down
3 changes: 1 addition & 2 deletions ajax/get_contracts.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

header('Content-Type: application/json;charset=utf-8');
$json=array();
$cid=corpid(charid());

$contracts = new Swagger\Client\Api\ContractsApi(null,$config);

try {
$result = $contracts->getCharactersCharacterIdContractsWithHttpInfo(charid(), $datasource);
foreach ($result[0] as $row) {
if(($row->getDateIssued()->getTimestamp()>strtotime('-6 hour'))&&($row->getStatus()=="outstanding"||$row->getStatus()=="finished")&&$row->getIssuerId()==charid()&&$row->getAvailability()=="personal"&&$row->getType()=="item_exchange"&&corpid($row->getAssigneeId())==$cid){
if(($row->getDateIssued()->getTimestamp()>strtotime('-6 hour'))&&($row->getStatus()=="outstanding"||$row->getStatus()=="finished")&&$row->getIssuerId()==charid()&&$row->getAvailability()=="personal"&&$row->getType()=="item_exchange"&&getcorpid($row->getAssigneeId())==corpid()){
array_unshift($json,json_decode(strval($row)));//avoids protected property problems
}
}
Expand Down
File renamed without changes.
24 changes: 24 additions & 0 deletions ajax/get_payments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
require_once('../header.php');

header('Content-Type: application/json;charset=utf-8');
$json=array();

$wallet = new Swagger\Client\Api\WalletApi(null,$config);

try {
$result = $wallet->getCorporationsCorporationIdWalletsDivisionJournalWithHttpInfo(corpid(), $corpwallet_id, $datasource);
foreach ($result[0] as $row) {

if (($row->getDate()->getTimestamp()>strtotime('-6 hour'))&&$row->getRefType()=="corporation_account_withdrawal"&&$row->getContextIdType()=="character_id"&&$row->getContextId()==charid()&&$row->getFirstPartyId()!=$row->getSecondPartyId()&&$row->getAmount()<=0) {
array_unshift($json,json_decode(strval($row)));//avoids protected property problems

}
}
print_r(json_encode(array($json,$result[2]['Expires'][0])));

} catch (Exception $e) {
echo 'Exception when calling WalletApi->getCorporationsCorporationIdWalletsDivisionJournal: ', $e->getMessage(), PHP_EOL;
}

?>
13 changes: 13 additions & 0 deletions ajax/get_payments_finished.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
require_once('../header.php');


header('Content-Type: application/json;charset=utf-8');

if(isset($_COOKIE['finished_payments'])){
echo json_encode($_COOKIE['finished_payments']);
} else {
echo "[]";
}

?>
17 changes: 17 additions & 0 deletions ajax/get_roles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
require_once('../header.php');

header('Content-Type: application/json;charset=utf-8');
$json=array();

$charapi = new Swagger\Client\Api\CharacterApi(null,$config);


try {
$result = $charapi->getCharactersCharacterIdRoles(charid(), $datasource);
print_r(strval($result));
} catch (Exception $e) {
echo 'Exception when calling CharacterApi->getCharactersCharacterIdRoles: ', $e->getMessage(), PHP_EOL;
}

?>
4 changes: 2 additions & 2 deletions ajax/mail-messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
I have reviewed and approved your SRP requests.
You have been paid for the following losses:
".$_GET["reason"]." ".$_GET["value"]." Million
Please check your wallet.
Expand All @@ -61,7 +61,7 @@
'ISK SRP Message',
'isk_mail_form',
false,
''
'echo "<input type=\'hidden\' id=\'payment\' name=\'payment\' value=".$_GET[\'paymentid\']."></input>";'
],
['',
'echo "Hello,
Expand Down
10 changes: 9 additions & 1 deletion ajax/sendmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@
$x = sizeof($_COOKIE['finished_contracts']);//index for new contract
setcookie("finished_contracts[$x]",$_POST["contractid"],time()+60*60*24,'/');
}
break;
break;
case 'isk':
if(!isset($_COOKIE['finished_payments'])){
setcookie('finished_payments[0]',$_POST["paymentid"],time()+60*60*24,'/');
}elseif (!in_array($_POST["paymentid"], $_COOKIE['finished_payments'])){
$x = sizeof($_COOKIE['finished_payments']);//index for new contract
setcookie("finished_payments[$x]",$_POST["paymentid"],time()+60*60*24,'/');
}
break;
}
}

Expand Down
4 changes: 2 additions & 2 deletions config.php.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
$corpwallet_id = '';
$corpwallet_id = 0;

$scope = [];
$scope = ['esi-mail.send_mail.v1', 'esi-corporations.read_corporation_membership.v1','esi-contracts.read_character_contracts.v1','esi-wallet.read_corporation_wallets.v1'];

$provider = new jbs1\OAuth2\Client\Provider\EveOnline([
'clientId' => 'demoapp', // The client ID assigned to you by the provider
Expand Down
6 changes: 5 additions & 1 deletion func.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ function charid(){
return $_SESSION['charinfo']['CharacterID'];
}

function corpid($charid){
function corpid(){
return $_SESSION['charinfo']['CorporationID'];
}

function getcorpid($charid){
global $config;
$api_instance = new Swagger\Client\Api\CharacterApi(null,$config);
try {
Expand Down
25 changes: 10 additions & 15 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
';


echo '
<link rel="stylesheet" href="css/loader.css">
<script src="js/corp.js"></script>
<script src="js/srp-hull.js"></script>
Expand All @@ -41,7 +38,6 @@
<script src="js/jquery.searchable-1.1.0.min.js"></script>
';


echo '<title>SRP Mailer</title>
</head>
<body>';
Expand Down Expand Up @@ -91,6 +87,9 @@
<li>ISK SRP (indev):</li>
<ul><li>
This tab will pull all payments from the configured corp wallet within the last 6 hours. You can select the payments you want to write an email for, by clicking on them.
</li>
<li>
One of these roles is required for this feature: <strong>Accountant/Junior Accountant</strong>
</li></ul>
<li>Messages (indev):</li>
<ul><li>
Expand All @@ -114,7 +113,6 @@
</p>
</div>';


echo' <div role="tabpanel" class="tab-pane" id="hullsrp">
<table class="table table-bordered table-hover" id="hullsrp-table">
<thead>
Expand All @@ -126,27 +124,25 @@
<tr id="no_contracts" class="warning"><td colspan=4> No contracts available! </td></tr>
</tbody>
</table>
<button type="button" class="btn btn-primary" id="contracts_refresh_button" onclick="hull_table_refresh()">Refresh!</button><br />
<button type="button" class="btn btn-primary" id="hull_refresh_button" onclick="hull_table_refresh()">Refresh!</button><br />
<span id="contracts-cached-date"></span>
</div>';


echo ' <div role="tabpanel" class="tab-pane" id="isksrp">
<div class="input-group" id="isksrp-search-div">
<span class="input-group-addon" id="isksrp-search-addon">Member-Search:</span>
<input type="text" class="form-control" id="isksrp-search" placeholder="Character Name" aria-describedby="isksrp-search-addon">
</div>
<table class="table table-bordered table-hover" id="isksrp-table">
<thead>
<tr>
<th>Membername</th><th>Member ID</th>
<th>Payment ID</th><th>Reciever</th><th>Time issued</th><th>Reason</th>
</tr>
</thead>
<tbody></tbody>
<tbody>
<tr id="no_payments" class="warning"><td colspan=4> No payments available! </td></tr>
</tbody>
</table>
<button type="button" class="btn btn-primary" id="isk_refresh_button" onclick="isk_table_refresh()">Refresh!</button><br />
<span id="payments-cached-date"></span>
</div>';


echo ' <div role="tabpanel" class="tab-pane" id="messagessrp">
<div class="input-group">
<span class="input-group-addon" id="messagessrp-search-addon">Member-Search:</span>
Expand All @@ -162,7 +158,6 @@
</table>
</div>';


echo ' </div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion js/corp.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $(function (){
},
complete: function(){
$('table#messagessrp-table').trigger('update-mem');
$('table#isksrp-table').trigger('update-mem');
// $('table#isksrp-table').trigger('update-mem');
loader_stop(1);
}
});
Expand Down
9 changes: 5 additions & 4 deletions js/srp-hull.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function hullsrp_ajax_mailform(item){
success: function(data){
$("table#hullsrp-table").hide(350);
$("span#contracts-cached-date").hide(350);
$("button#contracts_refresh_button").hide(350);
$("button#hull_refresh_button").hide(350);
var form=$('div#hullsrp').append(data).find('form#hull_mail_form');
form.submit(function(e) {
e.preventDefault();
Expand All @@ -58,8 +58,9 @@ function hullsrp_ajax_mailform(item){
alt.alert();
}
$('form#hull_mail_form').remove();
$("button#contracts_refresh_button").show(350);
$("button#hull_refresh_button").show(350);
$("table#hullsrp-table").show(350);
$("span#contracts-cached-date").show(350);
},
complete: function(){
mark_finished_contracts();
Expand All @@ -72,15 +73,15 @@ function hullsrp_ajax_mailform(item){
$('form#hull_mail_form').remove();
$("table#hullsrp-table").show(350);
$("span#contracts-cached-date").show(350);
$("button#contracts_refresh_button").show(350);
$("button#hull_refresh_button").show(350);
});
}
})
}

function mark_finished_contracts(){
$.ajax({
url: 'ajax/contracts-finished.php',
url: 'ajax/get_contracts_finished.php',
type: 'GET',
success: function(data){
for(var i in data){
Expand Down
78 changes: 55 additions & 23 deletions js/srp-isk.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,54 @@
$(function (){
if($("table#isksrp-table > tbody >tr").length == 0){
$('table#isksrp-table').on('update-mem', function(e){
$.each(mem,function(key, val){
var row = $("table#isksrp-table > tbody").append("<tr id="+key+"><td>"+val+"</td><td>"+key+"</td></tr>");
row.css('cursor', 'pointer');
row.children('#'+key).click(function(){isksrp_ajax_mailform(key)})
})
$('#isksrp-table').searchable({
searchField:'#isksrp-search',
clearOnLoad: true
});
})
}
})


function isk_table_refresh(){
$.ajax({
type: 'GET',
url: 'ajax/get_payments.php',
beforeSend: function(){
loader_start("Payments",3);
},
success: function(data){
console.log('Payments',data);
$("span#payments-cached-date").html("Payments cached until <strong>"+data[1]+"</strong>.");
if(data[0].length > 0){
$("table#isksrp-table > tbody > tr#no_payments").remove();
$.each(data[0],function(i, item){
var flag = 0;
$("table#isksrp-table > tbody > tr > td:first-child").each(function(){
if($(this).text() == item.id){
flag = 1;
}
});
if(flag==0){
var row = $("table#isksrp-table > tbody").append("<tr id="+item.id+"><td>"+item.id+"</td><td>"+mem[item.second_party_id]+"</td><td>"+item.date+"</td><td>"+item.reason+"</td></tr>");
row.css('cursor', 'pointer');
row.children('#'+item.id).click(function(){isksrp_ajax_mailform(item)})
}
})
}
},
complete: function(data){
mark_finished_payments();
loader_stop(3);
}
})
}


function isksrp_ajax_mailform(key){
function isksrp_ajax_mailform(item){
$.ajax({
type: 'GET',
url: 'ajax/mailform.php',
data: {"assignee":key,"textid":1},
data: {"assignee":item.second_party_id,"paymentid":item.id,"reason":item.reason,"value":item.amount*(-1)/1000000,"textid":1},
success: function(data){
$("div#isksrp-search-div").hide(350);
$("table#isksrp-table").hide(350);
$("span#payments-cached-date").hide(350);
$("button#isk_refresh_button").hide(350);
var form=$('div#isksrp').append(data).find('form#isk_mail_form');
form.submit(function(e) {
e.preventDefault();
$.ajax({
method: 'POST',
url: 'ajax/sendmail.php',
data: {'recv':$(this).find('#reciever').val(),'subj':$(this).find('#subject').val(),'body':$(this).find('#mail-body').val()},
data: {'special':'isk','paymentid':$(this).find('#payment').val(),'recv':$(this).find('#reciever').val(),'subj':$(this).find('#subject').val(),'body':$(this).find('#mail-body').val()},
success: function(data){
if(data["success"]){
var alt=$('#art').append('<div class="alert alert-success alert-dismissable" role="alert" ><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> Mail Sent! Mail-ID:'+data["return"]+'</div>')
Expand All @@ -41,18 +58,33 @@ function isksrp_ajax_mailform(key){
alt.alert();
}
$("form#isk_mail_form").remove();
$("div#isksrp-search-div").show(350);
$("table#isksrp-table").show(350);
$("span#payments-cached-date").show(350);
$("button#isk_refresh_button").show(350);
},
})
})
},
complete: function(){
$('form#isk_mail_form').find('button#back').click(function() {
$("form#isk_mail_form").remove();
$("div#isksrp-search-div").show(350);
$("table#isksrp-table").show(350);
$("span#payments-cached-date").show(350);
$("button#isk_refresh_button").show(350);
});
}
})
}


function mark_finished_payments(){
$.ajax({
url: 'ajax/get_payments_finished.php',
type: 'GET',
success: function(data){
for(var i in data){
$('table#isksrp-table > tbody > tr#'+data[i]).addClass('success');
}
}
})
}

0 comments on commit bc1895a

Please sign in to comment.