CasperSecurity

Current Path : /var/www/orientalss.com/app/Http/Livewire/Finance/
Upload File :
Current File : /var/www/orientalss.com/app/Http/Livewire/Finance/OtherReceiptLivewire.php

<?php

namespace App\Http\Livewire\Finance;

use App\Models\Client;
use App\Models\FinancialTransactions;
use App\Models\FinancialTransactionsLedgerHead;
use App\Models\LedgerHead;
use App\Models\LedgerheadType;
use Livewire\Component;
use Livewire\WithPagination;

class OtherReceiptLivewire extends Component
{
    protected $fillable = [
        'voucher_type',
        'voucher_date',
        'voucher_particulars',
    ];
    use WithPagination;
    protected $paginationTheme = 'bootstrap';

    public $search;
    public $perPage = 10;
    public $orderBy = 'id';
    public $orderAsc = '1';
    public $voucher_type, $voucher_particulars, $voucher_date;
    public $finance_transaction_id, $paid_to_received_from, $reference_no, $ledger_type, $ledger_head_id, $customer_id, $amount, $data;
    public $modelid;

    public $upperid;
    public $showmodal = false;
    public $isDisable = false;
    public $modal = false;
    public $totalamount;
    public $successmsg = "The Other Payments  has been saved successfully.";
    public $updatemsg = "The  Other Payments has been updated successfully.";
    public $deletemsg = "The  Other Payments data has been deleted successfully.";
    public $duplicateerrormsg = "Sorry !!!  Other Payments name has already exists in our database. Please Try Another Name";
    public $errormsg = "Sorry !!! Something went wrong. Please Try Again.";

    protected $listeners = ['delete'];

    public $rules = [
        'voucher_type' => 'required',
        'voucher_particulars' => 'required',
        'voucher_date' => 'required',
    ];
    public $orrules = [
        'paid_to_received_from' => 'required',
        'reference_no' => 'required',
        'ledger_type' => 'required',
        'customer_id' => 'required',
        'ledger_head_id' => 'required',
        'amount' => 'required',
    ];
    /*
        public $updatedrules = [
            'voucher_type' => 'required',
            'voucher_particulars' => 'required',
            'voucher_date' => 'required',
            'paid_to_received_from' => 'required',
            'reference_no' => 'required',
            'ledger_head_id' =>'required',
            'amount' => 'required',
        ];*/

    public $messages = [
        'voucher_type.required' => 'This field is required',
        'voucher_date.required' => 'This field is required',
        'voucher_particulars.required' => 'This field is required',
    ];
    public $ormessages = [
        'paid_to_received_from.required' => 'This field is required',
        'reference_no.required' => 'This field is required',
        'ledger_type.required' => 'This field is required',
        'customer_id.required' => 'This field is required',
        'ledger_head_id.required' => 'This field is required',
        'amount.required' => 'This field is required',
    ];

    public function showmodalclick()
    {
        $this->resetValidation();
        $this->showmodal = true;
    }

    public function resetdata()
    {
        $this->voucher_type = '';
        $this->voucher_date = '';
        $this->sectionRate = [];
        $this->totalAmount = 0;
    }

    public function closemodalclick()
    {
        $this->resetValidation();
        $this->showmodal = false;
    }

    public function updateclick($id)
    {
        $this->modelid = $id;
        $this->loadData($this->modelid);
        $this->showmodal = true;
    }

    public function deleteclick($id)
    {
        $this->modelid = $id;
        $this->dispatchBrowserEvent('confirmdelete', [
            'message' => 'Are you sure want to delete this data ?',
            'funcname' => 'delete'
        ]);
    }

    public function cleanVar()
    {
        $this->modelid = null;
        $this->finance_transaction_id = null;
        $this->paid_to_received_from = null;
        $this->reference_no = null;
        $this->ledger_type = null;
        $this->ledger_head_id = null;
        $this->amount = null;
        $this->showmodal = false;
    }

   /* public function loadData($id)
    {
        $response = FinancialTransactions::find($id);
        if ($response) {
            $this->voucher_type = $response['voucher_type'];
            $this->voucher_date = $response['voucher_date'];
            $this->voucher_particulars = $response['voucher_particulars'];
        }
    }*/

    public function save()
    {
        //dd($this->isDisable);
        if ($this->isDisable == false) {
            //dd('');
            $this->validate($this->rules, $this->messages);
            $data = FinancialTransactions::where('voucher_type', $this->voucher_type);
            $response = FinancialTransactions::create([
                'voucher_type' => $this->voucher_type,
                'voucher_date' => $this->voucher_date,
                'voucher_particulars' => $this->voucher_particulars,
            ]);
            if ($response) {
                /*            $this->validate($this->tdsrules, $this->tdsmessages);*/
                $this->upperid = $response->id;
                $this->validate($this->orrules, $this->ormessages);
                $sectionRate = FinancialTransactionsLedgerHead::create([
                    'finance_transaction_id' => $response->id,
                    'paid_to_received_from' => $this->paid_to_received_from,
                    'reference_no' => $this->reference_no,
                    'ledger_type' => $this->ledger_type,
                    'customer_id' => $this->customer_id,
                    'ledger_head_id' => $this->ledger_head_id,
                    'amount' => $this->amount,
                ]);

                if ($sectionRate) {
                    $this->isDisable = true;
                    $this->cleanVar();
                    $this->dispatchBrowserEvent('closeOffCanvas');
                    $this->dispatchBrowserEvent('showsuccessmsg', [
                        'type' => 'success',
                        'message' => $this->successmsg
                    ]);
                } else {
                    $this->dispatchBrowserEvent('showsuccessmsg', [
                        'type' => 'error',
                        'message' => $this->errormsg
                    ]);
                }
            }


        } else {

        }
        //dd($sectionRate);

    }


    public function updatesub()
    {
        $this->validate($this->orrules, $this->ormessages);
        $sectionRate = FinancialTransactionsLedgerHead::create([
            'finance_transaction_id' => $this->upperid,
            'paid_to_received_from' => $this->paid_to_received_from,
            'reference_no' => $this->reference_no,
            'ledger_type' => $this->ledger_type,
            'customer_id' => $this->customer_id,
            'ledger_head_id' => $this->ledger_head_id,
            'amount' => $this->amount,
        ]);

        if ($sectionRate) {
            $this->isDisable = true;
            $this->cleanVar();
            $this->dispatchBrowserEvent('closeOffCanvas');
            $this->dispatchBrowserEvent('showsuccessmsg', [
                'type' => 'success',
                'message' => $this->successmsg
            ]);
        } else {
            $this->dispatchBrowserEvent('showsuccessmsg', [
                'type' => 'error',
                'message' => $this->errormsg
            ]);
        }
    }

    public function mount()
    {
        $this->upperid == null;
/*        $this->isDisable == null;*/
    }


    public function delete()
    {
        $response = FinancialTransactionsLedgerHead::find($this->modelid);
        if ($response) {
            if ($response->delete()) {
                $this->cleanVar();
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'success',
                    'message' => $this->deletemsg
                ]);
            } else {
                $this->dispatchBrowserEvent('showsuccessmsg', [
                    'type' => 'error',
                    'message' => $this->errormsg
                ]);
            }
        }
    }

    public function receipt()
    {
        $financial_transactions = FinancialTransactions::search($this->search)
            ->orderBy($this->orderBy, $this->orderAsc ? 'asc' : 'desc')
            ->paginate($this->perPage);
        return $financial_transactions;
    }

    public function read($id)
    {
        $financial_transactions_ledger_heads = FinancialTransactionsLedgerHead::where('finance_transaction_id', $id)->get();
       /* orderBy($this->orderBy, $this->orderAsc ? 'asc' : 'desc')
        ->paginate($this->perPage);*/
        return $financial_transactions_ledger_heads;
    }

    public function render()
    {
        //dd($this->upperid);
        if ($this->upperid == null) {
            $datatable = [];
        } else {
            $datatable = $this->read($this->upperid);
        }

        if (sizeof($datatable) > 0) {
            foreach ($datatable as $key => $data) {

                $ledger = LedgerHead::where('id', $data->ledger_head_id)->first();

                if ($ledger) {
                    $datatable[$key]['ledger_head_name'] = $ledger->ledger_head_name;
                } else {
                    $datatable[$key]['ledger_head_name'] = "NA";
                }
            }
        }
/*        $ledgerhead = LedgerHead::where('status', 1)->get();*/
        $customers = Client::where('status', 1)->get();
        $othertable = [];
        $othertable = $this->receipt();
        //dd($othertable);

        $totalamount = [];
        $amount = 0;
        foreach ($totalamount as $item) {
            $amount += $item['amount'];
        }
        /*echo $amount;*/
        /*        $datatable=FinancialTransactionsLedgerHead::where('id',$this->finance_transaction_id)->get();*/
        $accledgertype=LedgerheadType::where('ledger_type','Accounts Recievable')->get();
        $ledgerhead=LedgerHead::where('status',1)->get();
        return view('livewire.finance.other-receipt-livewire', compact('datatable','accledgertype','othertable','ledgerhead','customers', 'totalamount'));
    }
}
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