CasperSecurity

Current Path : /var/www/orientalss.com/app/Http/Livewire/Hrms/
Upload File :
Current File : /var/www/orientalss.com/app/Http/Livewire/Hrms/OtApprovalLivewire.php

<?php

namespace App\Http\Livewire\Hrms;

use App\Models\EmployeeRegistration;
use App\Models\OtRequest;
use App\Models\Otrule;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
use Livewire\WithPagination;

class OtApprovalLivewire extends Component
{
    use WithPagination;
    protected $paginationTheme = 'bootstrap';

    public $search;
    public $perPage = 10;
    public $orderBy = 'id';
    public $orderAsc = '1';
    public $modelid;
    public $showmodal = false;

    public $successmsg = "The Ot Type  has been saved successfully.";
    public $approvemsg = "The  Ot Request has been approve successfully.";
    public $rejectmsg = "The  Ot Type data has been rejetct successfully.";
    public $errormsg = "Sorry !!! Something went wrong. Please Try Again.";

    protected $listeners = ['reject'];
    public $messages = [
        'employee_id.required' => 'This field is required',
        'req_id.required' => 'This field is required',
        'ot_type_id.required' => 'This field is required',
        'ot_date.required' => 'This field is required',
        'ot_hour.required' => 'This field is required',
    ];

    public function closemodalclick()
    {
        $this->resetValidation();

    }

    public function cleanVar()
    {
        $this->modelid = null;
        $this->status = null;
        $this->showmodal = false;
    }

    public function approveclick($id)
    {

        $response = OTRequest::find($id);
        if ($response) {
        if($response->manager_approval_status==1){
            $response->update(['manager_approval_status'=>2]);
            $this->dispatchBrowserEvent('closeOffCanvas');
            $this->dispatchBrowserEvent('showsuccessmsg', [
                'type' => 'success',
                'message' =>'Approved By Manager.Waiting for HR approval'
            ]);
        }
        elseif($response->manager_approval_status==2 && $response->hr_approval_status==1){
            $response->update(['hr_approval_status'=>2,
                               'status'=>2
                               ]);
            $this->dispatchBrowserEvent('closeOffCanvas');
            $this->dispatchBrowserEvent('showsuccessmsg', [
                'type' => 'success',
                'message' => 'Approved By HR'
            ]);
        }



            } else {
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'error',
                    'message' => $this->errormsg
                ]);
            }

    }

    public function rejectclick($id)
    {
        $response = OTRequest::find($id);
        if ($response) {
            if ($response) {
                $response->update(['status'=>0]);
                $this->cleanVar();
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'success',
                    'message' => $this->rejectmsg
                ]);
            } else {
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'error',
                    'message' => $this->errormsg
                ]);
            }
        }
    }

    public function read()
    {


        if(Auth::user()->name=="superadmin" || Auth::user()->name=="admin"){

            $ot_requests = OTRequest::search($this->search)
                ->orderBy($this->orderBy, $this->orderAsc ? 'asc' : 'desc')
                ->paginate($this->perPage);
            return $ot_requests;
        }
        else{

            $empdet=EmployeeRegistration::where('employee_id',Auth::user()->employee_id)->first();
            if($empdet){
                $ot_requests = OTRequest::where('manager_id',$empdet->id)->orWhere('hr_id',$empdet->id)
                    ->orderBy($this->orderBy, $this->orderAsc ? 'asc' : 'desc')
                    ->paginate($this->perPage);
                return $ot_requests;
            }
            else{
                return [];
            }

        }

    }

    public function render()
    {
        $datatable = [];
        $datatable = $this->read();
        if (sizeof($datatable) > 0) {
            foreach ($datatable as $key => $data) {
                $ot = Otrule::where('id', $data->ot_type_id)->first();
                if ($ot) {
                    $datatable[$key]['ot_type'] = $ot->ot_type;
                } else {
                    $datatable[$key]['ot_type'] = "NA";
                }
            }
        }
        $ottype = Otrule::where('status', 1)->get();
        return view('livewire.hrms.ot-approval-livewire', compact('datatable', 'ottype'));
    }
}
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY