mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
bug fixes
This commit is contained in:
parent
57544a771c
commit
9cec0dc33d
@ -23,14 +23,15 @@ class SendRecurringInvoices extends Command {
|
|||||||
$this->info(date('Y-m-d') . ' Running SendRecurringInvoices...');
|
$this->info(date('Y-m-d') . ' Running SendRecurringInvoices...');
|
||||||
|
|
||||||
$today = new DateTime();
|
$today = new DateTime();
|
||||||
|
|
||||||
$invoices = Invoice::with('account', 'invoice_items')->whereRaw('is_recurring is true AND start_date <= ? AND (end_date IS NULL OR end_date >= ?)', array($today, $today))->get();
|
$invoices = Invoice::with('account', 'invoice_items')->whereRaw('is_recurring is true AND start_date <= ? AND (end_date IS NULL OR end_date >= ?)', array($today, $today))->get();
|
||||||
$this->info(count($invoices) . ' recurring invoice(s) found');
|
$this->info(count($invoices) . ' recurring invoice(s) found');
|
||||||
|
|
||||||
foreach ($invoices as $recurInvoice)
|
foreach ($invoices as $recurInvoice)
|
||||||
{
|
{
|
||||||
|
$this->info($recurInvoice->invoice_date);
|
||||||
$this->info('Processing Invoice ' . $recurInvoice->id . ' - Should send ' . ($recurInvoice->shouldSendToday() ? 'YES' : 'NO'));
|
$this->info('Processing Invoice ' . $recurInvoice->id . ' - Should send ' . ($recurInvoice->shouldSendToday() ? 'YES' : 'NO'));
|
||||||
|
|
||||||
if (!$recurInvoice->shouldSendToday())
|
if (!$recurInvoice->shouldSendToday())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -18,13 +18,13 @@ class Utils
|
|||||||
{
|
{
|
||||||
$count = Session::get('error_count', 0);
|
$count = Session::get('error_count', 0);
|
||||||
Session::put('error_count', ++$count);
|
Session::put('error_count', ++$count);
|
||||||
if ($count > LOGGED_ERROR_LIMIT) return 'logged';
|
if ($count > 100) return 'logged';
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'context' => $context,
|
'context' => $context,
|
||||||
'user_id' => Auth::check() ? Auth::user()->id : 0,
|
'user_id' => Auth::check() ? Auth::user()->id : 0,
|
||||||
'url' => Input::get('url'),
|
'url' => Input::get('url'),
|
||||||
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
|
'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '',
|
||||||
'ip' => Request::getClientIp(),
|
'ip' => Request::getClientIp(),
|
||||||
'count' => Session::get('error_count', 0)
|
'count' => Session::get('error_count', 0)
|
||||||
];
|
];
|
||||||
|
@ -12,13 +12,18 @@ class EntityModel extends Eloquent
|
|||||||
$className = get_called_class();
|
$className = get_called_class();
|
||||||
$entity = new $className();
|
$entity = new $className();
|
||||||
|
|
||||||
if ($parent) {
|
if ($parent)
|
||||||
|
{
|
||||||
$entity->user_id = $parent->user_id;
|
$entity->user_id = $parent->user_id;
|
||||||
$entity->account_id = $parent->account_id;
|
$entity->account_id = $parent->account_id;
|
||||||
} else if (Auth::check()) {
|
}
|
||||||
|
else if (Auth::check())
|
||||||
|
{
|
||||||
$entity->user_id = Auth::user()->id;
|
$entity->user_id = Auth::user()->id;
|
||||||
$entity->account_id = Auth::user()->account_id;
|
$entity->account_id = Auth::user()->account_id;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Utils::fatalError();
|
Utils::fatalError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,27 +89,34 @@ class Invoice extends EntityModel
|
|||||||
|
|
||||||
public function shouldSendToday()
|
public function shouldSendToday()
|
||||||
{
|
{
|
||||||
|
//$dayOfWeekStart = strtotime($this->start_date);
|
||||||
|
return false;
|
||||||
|
|
||||||
$dayOfWeekToday = date('w');
|
$dayOfWeekToday = date('w');
|
||||||
$dayOfWeekStart = date('w', strtotime($this->start_date));
|
$dayOfWeekStart = date('w', strtotime($this->start_date));
|
||||||
|
|
||||||
$dayOfMonthToday = date('j');
|
$dayOfMonthToday = date('j');
|
||||||
$dayOfMonthStart = date('j', strtotime($this->start_date));
|
$dayOfMonthStart = date('j', strtotime($this->start_date));
|
||||||
|
|
||||||
if (!$this->last_sent_date) {
|
if (!$this->last_sent_date)
|
||||||
|
{
|
||||||
$daysSinceLastSent = 0;
|
$daysSinceLastSent = 0;
|
||||||
$monthsSinceLastSent = 0;
|
$monthsSinceLastSent = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$date1 = new DateTime($this->last_sent_date);
|
$date1 = new DateTime($this->last_sent_date);
|
||||||
$date2 = new DateTime();
|
$date2 = new DateTime();
|
||||||
$diff = $date2->diff($date1);
|
$diff = $date2->diff($date1);
|
||||||
$daysSinceLastSent = $diff->format("%a");
|
$daysSinceLastSent = $diff->format("%a");
|
||||||
$monthsSinceLastSent = ($diff->format('%y') * 12) + $diff->format('%m');
|
$monthsSinceLastSent = ($diff->format('%y') * 12) + $diff->format('%m');
|
||||||
|
|
||||||
if ($daysSinceLastSent == 0) {
|
if ($daysSinceLastSent == 0)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($this->frequency_id)
|
switch ($this->frequency_id)
|
||||||
{
|
{
|
||||||
case FREQUENCY_WEEKLY:
|
case FREQUENCY_WEEKLY:
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
//dd(gethostname());
|
//dd(gethostname());
|
||||||
//Log::error('test');
|
//Log::error('test');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Event::listen('illuminate.query', function($query, $bindings, $time, $name)
|
Event::listen('illuminate.query', function($query, $bindings, $time, $name)
|
||||||
{
|
{
|
||||||
@ -45,6 +48,14 @@ Event::listen('illuminate.query', function($query, $bindings, $time, $name)
|
|||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Route::get('/test', function() {
|
||||||
|
foreach (Invoice::all() as $invoice) {
|
||||||
|
echo $invoice->id . ' ' . $invoice->shouldSendToday() . '<br/>';
|
||||||
|
}
|
||||||
|
dd(true);
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
// TODO_FIX replace with cron
|
// TODO_FIX replace with cron
|
||||||
Route::get('/send_emails', function() {
|
Route::get('/send_emails', function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user