mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-01 20:17:35 -04:00 
			
		
		
		
	Actitivity output for React
This commit is contained in:
		
							parent
							
								
									cf141e36c8
								
							
						
					
					
						commit
						1e43e172a7
					
				| @ -91,6 +91,30 @@ class ActivityController extends BaseController | ||||
|         $activities = Activity::orderBy('created_at', 'DESC')->company() | ||||
|                                 ->take($default_activities); | ||||
| 
 | ||||
|         if($request->has('react')){ | ||||
| 
 | ||||
|             $system = ctrans('texts.system'); | ||||
| 
 | ||||
|             $data = $activities->cursor()->map(function ($activity) use($system){ | ||||
| 
 | ||||
|                 return ctrans('texts.activity_'.$activity->activity_type_id,[ | ||||
|                       'client' => $activity->client ? $activity->client->present()->name() : $system, | ||||
|                       'contact' => $activity->contact ? $activity->contact->first_name . " " .$activity->contact->last_name : $system, | ||||
|                       'quote' => $activity->quote ? $activity->quote->number : $system, | ||||
|                       'user' => $activity->user ? $activity->user->present()->name() : $system, | ||||
|                       'expense' => $activity->expense ? $activity->expense->number : $system, | ||||
|                       'invoice' => $activity->invoice ? $activity->invoice->number : $system, | ||||
|                       'recurring_invoice' => $activity->recurring_invoice ? $activity->recurring_invoice->number : $system, | ||||
|                       'payment' => $activity->payment ? $activity->payment->number : $system, | ||||
|                       'credit' => $activity->credit ? $activity->credit->number : $system, | ||||
|                       'task' => $activity->task ? $activity->task->number : $system, | ||||
|                 ]); | ||||
| 
 | ||||
|             }); | ||||
| 
 | ||||
|             return response()->json(['data' => $data->toArray()], 200); | ||||
|         } | ||||
| 
 | ||||
|         return $this->listResponse($activities); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -56,9 +56,10 @@ class TaskScheduler implements ShouldQueue | ||||
|             Scheduler::with('company','job') | ||||
|                 ->where('paused', false) | ||||
|                 ->where('is_deleted', false) | ||||
|                 ->whereDate('scheduled_run', '<=', Carbon::now()) | ||||
|                 ->where('scheduled_run', '<', now()) | ||||
|                 ->cursor() | ||||
|                 ->each(function ($scheduler){ | ||||
| 
 | ||||
|                     $this->doJob($scheduler); | ||||
| 
 | ||||
|                 }); | ||||
| @ -69,6 +70,8 @@ class TaskScheduler implements ShouldQueue | ||||
| 
 | ||||
|     private function doJob(Scheduler $scheduler) | ||||
|     { | ||||
|         nlog("Doing job {$scheduler->id}"); | ||||
|          | ||||
|         $job = $scheduler->job; | ||||
|         $company = $scheduler->company; | ||||
| 
 | ||||
|  | ||||
| @ -70,6 +70,7 @@ class Activity extends StaticModel | ||||
|     const ARCHIVE_USER = 50;  | ||||
|     const DELETE_USER = 51;  | ||||
|     const RESTORE_USER = 52;  | ||||
|      | ||||
|     const MARK_SENT_INVOICE = 53; // not needed?
 | ||||
|     const PAID_INVOICE = 54; //
 | ||||
|     const EMAIL_INVOICE_FAILED = 57; | ||||
| @ -138,13 +139,11 @@ class Activity extends StaticModel | ||||
|         return $this->hasOne(Backup::class); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     public function history() | ||||
|     { | ||||
|         return $this->hasOne(Backup::class); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * @return mixed | ||||
|      */ | ||||
| @ -177,6 +176,14 @@ class Activity extends StaticModel | ||||
|         return $this->belongsTo(Invoice::class)->withTrashed(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @return mixed | ||||
|      */ | ||||
|     public function recurring_invoice() | ||||
|     { | ||||
|         return $this->belongsTo(RecurringInvoice::class)->withTrashed(); | ||||
|     } | ||||
| 
 | ||||
|     public function credit() | ||||
|     { | ||||
|         return $this->belongsTo(Credit::class)->withTrashed(); | ||||
| @ -198,15 +205,16 @@ class Activity extends StaticModel | ||||
|         return $this->belongsTo(Payment::class)->withTrashed(); | ||||
|     } | ||||
| 
 | ||||
|     // public function task()
 | ||||
|     // {
 | ||||
|     //     return $this->belongsTo(Task::class)->withTrashed();
 | ||||
|     // }
 | ||||
|     public function expense() | ||||
|     { | ||||
|         return $this->belongsTo(Expense::class)->withTrashed(); | ||||
|     } | ||||
| 
 | ||||
|     public function task() | ||||
|     { | ||||
|         return $this->belongsTo(Task::class)->withTrashed(); | ||||
|     } | ||||
| 
 | ||||
|     // public function expense()
 | ||||
|     // {
 | ||||
|     //     return $this->belongsTo(Expense::class)->withTrashed();
 | ||||
|     // }
 | ||||
| 
 | ||||
|     public function company() | ||||
|     { | ||||
|  | ||||
| @ -13,6 +13,10 @@ namespace App\Transformers; | ||||
| 
 | ||||
| use App\Models\Activity; | ||||
| use App\Models\Backup; | ||||
| use App\Models\ClientContact; | ||||
| use App\Models\Invoice; | ||||
| use App\Models\Task; | ||||
| use App\Models\User; | ||||
| use App\Utils\Traits\MakesHash; | ||||
| 
 | ||||
| class ActivityTransformer extends EntityTransformer | ||||
| @ -25,7 +29,17 @@ class ActivityTransformer extends EntityTransformer | ||||
|      * @var array | ||||
|      */ | ||||
|     protected $availableIncludes = [ | ||||
|         'history' | ||||
|         'history', | ||||
|         'user', | ||||
|         'client', | ||||
|         'contact', | ||||
|         'recurring_invoice', | ||||
|         'invoice', | ||||
|         'credit', | ||||
|         'quote', | ||||
|         'payment', | ||||
|         'expense', | ||||
|         'task', | ||||
|     ]; | ||||
| 
 | ||||
|     /** | ||||
| @ -66,4 +80,75 @@ class ActivityTransformer extends EntityTransformer | ||||
| 
 | ||||
|         return $this->includeItem($activity->backup, $transformer, Backup::class); | ||||
|     } | ||||
| 
 | ||||
|     public function includeClient(Activity $activity) | ||||
|     { | ||||
|         $transformer = new ClientTransformer($this->serializer); | ||||
| 
 | ||||
|         return $this->includeItem($activity->client, $transformer, Client::class); | ||||
|     } | ||||
| 
 | ||||
|     public function includeContact(Activity $activity) | ||||
|     { | ||||
|         $transformer = new ClientContactTransformer($this->serializer); | ||||
| 
 | ||||
|         return $this->includeItem($activity->contact, $transformer, ClientContact::class); | ||||
|     } | ||||
| 
 | ||||
|     public function includeRecurringInvoice(Activity $activity) | ||||
|     { | ||||
|         $transformer = new RecurringInvoiceTransformer($this->serializer); | ||||
| 
 | ||||
|         return $this->includeItem($activity->recurring_invoice, $transformer, RecurringInvoice::class); | ||||
|     } | ||||
| 
 | ||||
|     public function includeQuote(Activity $activity) | ||||
|     { | ||||
|         $transformer = new RecurringInvoiceTransformer($this->serializer); | ||||
| 
 | ||||
|         return $this->includeItem($activity->quote, $transformer, Quote::class); | ||||
|     } | ||||
| 
 | ||||
|     public function includeInvoice(Activity $activity) | ||||
|     { | ||||
|         $transformer = new InvoiceTransformer($this->serializer); | ||||
| 
 | ||||
|         return $this->includeItem($activity->invoice, $transformer, Invoice::class); | ||||
|     } | ||||
| 
 | ||||
|     public function includeCredit(Activity $activity) | ||||
|     { | ||||
|         $transformer = new CreditTransformer($this->serializer); | ||||
| 
 | ||||
|         return $this->includeItem($activity->credit, $transformer, Credit::class); | ||||
|     } | ||||
| 
 | ||||
|     public function includePayment(Activity $activity) | ||||
|     { | ||||
|         $transformer = new PaymentTransformer($this->serializer); | ||||
| 
 | ||||
|         return $this->includeItem($activity->payment, $transformer, Payment::class); | ||||
|     } | ||||
| 
 | ||||
|     public function includeUser(Activity $activity) | ||||
|     { | ||||
|         $transformer = new UserTransformer($this->serializer); | ||||
| 
 | ||||
|         return $this->includeItem($activity->user, $transformer, User::class); | ||||
|     } | ||||
| 
 | ||||
|     public function includeExpense(Activity $activity) | ||||
|     { | ||||
|         $transformer = new ExpenseTransformer($this->serializer); | ||||
| 
 | ||||
|         return $this->includeItem($activity->expense, $transformer, Expense::class); | ||||
|     } | ||||
| 
 | ||||
|     public function includeTask(Activity $activity) | ||||
|     { | ||||
|         $transformer = new TaskTransformer($this->serializer); | ||||
| 
 | ||||
|         return $this->includeItem($activity->task, $transformer, Task::class); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -35,6 +35,7 @@ class TaskSchedulerTransformer extends EntityTransformer | ||||
|     { | ||||
|         return [ | ||||
|             'id' => $this->encodePrimaryKey($scheduler->id), | ||||
|             'is_deleted' => (bool)$scheduler->is_deleted, | ||||
|             'paused' => (bool)$scheduler->paused, | ||||
|             'repeat_every' => (string)$scheduler->repeat_every, | ||||
|             'start_from' => (int)$scheduler->start_from, | ||||
|  | ||||
| @ -794,12 +794,12 @@ $LANG = array( | ||||
|     'activity_45' => ':user deleted task :task', | ||||
|     'activity_46' => ':user restored task :task', | ||||
|     'activity_47' => ':user updated expense :expense', | ||||
|     'activity_48' => ':user updated ticket :ticket', | ||||
|     'activity_49' => ':user closed ticket :ticket', | ||||
|     'activity_50' => ':user merged ticket :ticket', | ||||
|     'activity_51' => ':user split ticket :ticket', | ||||
|     'activity_52' => ':contact opened ticket :ticket', | ||||
|     'activity_53' => ':contact reopened ticket :ticket', | ||||
|     'activity_48' => ':user created user :user', | ||||
|     'activity_49' => ':user updated user :user', | ||||
|     'activity_50' => ':user archived user :user', | ||||
|     'activity_51' => ':user deleted user :user', | ||||
|     'activity_52' => ':user restored user :user', | ||||
|     'activity_53' => ':user marked sent :invoice', | ||||
|     'activity_54' => ':user reopened ticket :ticket', | ||||
|     'activity_55' => ':contact replied ticket :ticket', | ||||
|     'activity_56' => ':user viewed ticket :ticket', | ||||
| @ -4583,8 +4583,30 @@ $LANG = array( | ||||
|     'alternate_pdf_viewer' => 'Alternate PDF Viewer', | ||||
|     'alternate_pdf_viewer_help' => 'Improve scrolling over the PDF preview [BETA]', | ||||
|     'currency_cayman_island_dollar' => 'Cayman Island Dollar', | ||||
|     'download_report_description' => 'Please see attached file to check your report.' | ||||
| 
 | ||||
|     'download_report_description' => 'Please see attached file to check your report.', | ||||
|     'left' => 'Left', | ||||
|     'right' => 'Right', | ||||
|     'center' => 'Center', | ||||
|     'page_numbering' => 'Page Numbering', | ||||
|     'page_numbering_alignment' => 'Page Numbering Alignment', | ||||
|     'invoice_sent_notification_label' => 'Invoice Sent', | ||||
|     'show_product_description' => 'Show Product Description', | ||||
|     'show_product_description_help' => 'Include the description in the product dropdown', | ||||
|     'invoice_items' => 'Invoice Items', | ||||
|     'quote_items' => 'Quote Items', | ||||
|     'profitloss' => 'Profit and Loss', | ||||
|     'import_format' => 'Import Format', | ||||
|     'export_format' => 'Export Format', | ||||
|     'export_type' => 'Export Type', | ||||
|     'stop_on_unpaid' => 'Stop On Unpaid', | ||||
|     'stop_on_unpaid_help' => 'Stop creating recurring invoices if the last invoice is unpaid.', | ||||
|     'use_quote_terms' => 'Use Quote Terms', | ||||
|     'use_quote_terms_help' => 'When converting a quote to an invoice', | ||||
|     'add_country' => 'Add Country', | ||||
|     'enable_tooltips' => 'Enable Tooltips', | ||||
|     'enable_tooltips_help' => 'Show tooltips when hovering the mouse', | ||||
|     'multiple_client_error' => 'Error: records belong to more than one client', | ||||
|     'login_label' => 'Login to an existing account', | ||||
| 
 | ||||
| ); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user