-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
101 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,12 @@ | |
error_reporting(E_ALL); | ||
ini_set('display_errors', 1); | ||
|
||
use Pheal\Core\Config; | ||
use Pheal\Pheal; | ||
|
||
class Async_procedure extends CI_Controller | ||
{ | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
@@ -25,7 +29,7 @@ public function index($iduser) | |
if (!$this->input->is_cli_request()) { | ||
die('unauthorized'); | ||
} | ||
|
||
$this->db->where('iduser', $iduser); | ||
$username = $this->db->get('user')->row()->username; | ||
|
||
|
@@ -46,7 +50,7 @@ public function index($iduser) | |
$this->Updater_model->updateTotals($username, true); | ||
// send email | ||
$this->db->where('iduser', $iduser); | ||
$query = $this->db->get('user'); | ||
$query = $this->db->get('user'); | ||
$report_type = $query->row()->reports; | ||
|
||
$this->sendReport($report_type, $username); | ||
|
@@ -61,50 +65,50 @@ public function index($iduser) | |
|
||
public function sendReport(string $period, string $username) | ||
{ | ||
$period == 'daily' ? $interval = 1 : | ||
($period == 'weekly' ? $interval = 7 : | ||
($period == 'monthly' ? $interval = 30 : 'none')); | ||
$period == 'daily' ? $interval = 1 : | ||
($period == 'weekly' ? $interval = 7 : | ||
($period == 'monthly' ? $interval = 30 : 'none')); | ||
|
||
// if today is sunday send weekly report | ||
// if today is the day of the month send monthly report | ||
$day = date('D'); | ||
$date = date('d'); | ||
$day = date('D'); | ||
$date = date('d'); | ||
$month = date('m'); | ||
|
||
switch ($period) { | ||
case 'none'; | ||
return; | ||
break; | ||
break; | ||
|
||
case 'weekly': | ||
if ($day != 'Mon') { | ||
return; | ||
} | ||
break; | ||
break; | ||
|
||
case 'monthly': | ||
if (!($day == 'Mon' && $date == '30') || !($day == 'Mon' && $date == '28' && $month == 'February')) { | ||
return; | ||
} | ||
break; | ||
break; | ||
} | ||
|
||
$data['period'] = $period; | ||
$data['interval'] = $interval; | ||
$data['recap_int'] = max($interval, 7); | ||
$this->db->where('username', $username); | ||
|
||
$data['user_id'] = (int) $this->db->get('user')->row()->iduser; | ||
$characters = $this->Login_model->getCharacterList($data['user_id']); | ||
$chars = (string) $characters['aggr']; | ||
$data['char_names'] = $characters['char_names']; | ||
$data['user_id'] = (int) $this->db->get('user')->row()->iduser; | ||
$characters = $this->Login_model->getCharacterList($data['user_id']); | ||
$chars = (string) $characters['aggr']; | ||
$data['char_names'] = $characters['char_names']; | ||
|
||
if ($chars != '()') { | ||
if($chars != '()') { | ||
$data['totals'] = $this->reports->calculateTotals($chars, $interval); | ||
if ($data['totals'][1][0]['total_profit'] == 0 && $data['totals'][1][0]['total_sell'] == 0 && $data['totals'][1][0]['total_buy'] == 0) { | ||
return; | ||
} | ||
|
||
// using the icons helper | ||
$data['best_raw'] = injectIcons($this->reports->calculateBestRaw($chars, $interval)); | ||
$data['best_margin'] = injectIcons($this->reports->calculateBestMargin($chars, $interval)); | ||
|
@@ -113,23 +117,23 @@ public function sendReport(string $period, string $username) | |
$data['fastest'] = injectIcons($this->reports->calculateFastestTurnovers($chars, $interval)); | ||
$data['best_iph'] = injectIcons($this->reports->calculateBestIPH($chars, $interval)); | ||
//$data['blunders'] = $this->injectIcons($this->reports->calculateBlunders($chars, $interval)); | ||
$data['best_stations'] = $this->reports->calculateBestStations($chars, $interval); | ||
$data['recap'] = $this->reports->calculateRecap($chars, $data['recap_int']); | ||
$data['username'] = $username; | ||
$data['date_now'] = date('Y-m-d'); | ||
$data['date_prev'] = date('Y-m-d', strtotime('-' . $interval * 24 . ' hours')); | ||
$data['cl_recent'] = $this->Updater_model->getChangeLog(true); | ||
$data['best_stations'] = $this->reports->calculateBestStations($chars, $interval); | ||
$data['recap'] = $this->reports->calculateRecap($chars, $data['recap_int']); | ||
$data['username'] = $username; | ||
$data['date_now'] = date('Y-m-d'); | ||
$data['date_prev'] = date('Y-m-d', strtotime('-' . $interval * 24 . ' hours')); | ||
$data['cl_recent'] = $this->Updater_model->getChangeLog(true); | ||
|
||
$report = $this->load->view('reports/reports_v', $data, true); | ||
|
||
//mail data | ||
$address = $this->User->getUserEmail($data['user_id']); | ||
$from = "[email protected]"; | ||
$address = $this->User->getUserEmail($data['user_id']); | ||
$from = "[email protected]"; | ||
$from_name = "Eve Trade Master"; | ||
$subject = "Eve Trade Master " . $period . " earnings report for " . $data['date_now']; | ||
$body = $report; | ||
$subject = "Eve Trade Master " . $period . " earnings report for " . $data['date_now']; | ||
$body = $report; | ||
|
||
$mail = $this->Email->send($address, $from, $from_name, $subject, $body); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters