Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/ts.corals.io/corals-api/Corals/modules/Timesheet/Observers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/ts.corals.io/corals-api/Corals/modules/Timesheet/Observers/EntryObserver.php
<?php

namespace Corals\Modules\Timesheet\Observers;


use Corals\Modules\Timesheet\Events\AlertsEvent;
use Corals\Modules\Timesheet\Facades\Timesheet;
use Corals\Modules\Timesheet\Models\Entry;
use Corals\Settings\Facades\Settings;
use Corals\User\Models\Role;
use Corals\User\Models\User;

class EntryObserver
{

    protected function setEntryCalculations(Entry $entry)
    {
        $evalHours = $entry->evaluation_hours ?? 0;
        $evalMinutes = $entry->evaluation_minutes ?? 0;

        $entryCalculation = Timesheet::getEntryHourlyRate(
            $entry->project_id,
            $entry->user_id,
            $entry->activity_id,
            $evalHours + ($evalMinutes / 60)
        );

        $entry->hourly_rate = data_get($entryCalculation, 'hourly_rate');
        $entry->amount = data_get($entryCalculation, 'amount');


        $user = User::findOrFail($entry->user_id);

        $entryTotalHours = ($entry->hours ?? 0) + (($entry->minutes ?? 0) / 60);

        $userRate = $user->hourly_rate ?? 0;

        if (!$userRate && $user->salary) {
            $userRate = round($user->salary / Settings::get('total_working_hours_per_month', 176), 1);
        }

        $entry->cost = $entryTotalHours * $userRate;
    }

    public function creating(Entry $entry)
    {
        $this->setEntryCalculations($entry);
    }

    public function updating(Entry $entry)
    {
        $this->setEntryCalculations($entry);
    }

    /**
     * @param Entry $entry
     */
    public function created(Entry $entry)
    {
        Timesheet::notifyAdministrationRoles();
    }

    /**
     * @param Entry $entry
     */
    public function updated(Entry $entry)
    {
        Timesheet::notifyAdministrationRoles();
    }

    /**
     * @param Entry $entry
     * @throws \Exception
     */
    public function deleted(Entry $entry)
    {
        Timesheet::notifyAdministrationRoles();
    }
}

Spamworldpro Mini