2022-06-15 13:24:30 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\VendorPortal;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Models\VendorContact;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
use App\Utils\TranslationHelper;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class VendorContactController extends Controller
|
|
|
|
{
|
|
|
|
use MakesHash;
|
|
|
|
|
|
|
|
public const MODULE_RECURRING_INVOICES = 1;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_CREDITS = 2;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_QUOTES = 4;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_TASKS = 8;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_EXPENSES = 16;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_PROJECTS = 32;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_VENDORS = 64;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_TICKETS = 128;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_PROPOSALS = 256;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_RECURRING_EXPENSES = 512;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_RECURRING_TASKS = 1024;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_RECURRING_QUOTES = 2048;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_INVOICES = 4096;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_PROFORMAL_INVOICES = 8192;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-06-15 13:24:30 +02:00
|
|
|
public const MODULE_PURCHASE_ORDERS = 16384;
|
|
|
|
|
|
|
|
public function edit(VendorContact $vendor_contact)
|
|
|
|
{
|
|
|
|
return $this->render('vendor_profile.edit', [
|
|
|
|
'contact' => $vendor_contact,
|
|
|
|
'vendor' => $vendor_contact->vendor,
|
|
|
|
'settings' => $vendor_contact->vendor->company->settings,
|
|
|
|
'company' => $vendor_contact->vendor->company,
|
|
|
|
'sidebar' => $this->sidebarMenu(),
|
2022-06-21 11:57:17 +02:00
|
|
|
'countries' => TranslationHelper::getCountries(),
|
2022-06-15 13:24:30 +02:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function update(VendorContact $vendor_contact)
|
|
|
|
{
|
|
|
|
$vendor_contact->fill(request()->all());
|
|
|
|
$vendor_contact->vendor->fill(request()->all());
|
|
|
|
$vendor_contact->push();
|
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
return back()->withSuccess(ctrans('texts.profile_updated_successfully'));
|
2022-06-15 13:24:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private function sidebarMenu() :array
|
|
|
|
{
|
|
|
|
$enabled_modules = auth()->guard('vendor')->user()->company->enabled_modules;
|
|
|
|
$data = [];
|
|
|
|
|
|
|
|
// TODO: Enable dashboard once it's completed.
|
|
|
|
// $this->settings->enable_client_portal_dashboard
|
|
|
|
// $data[] = [ 'title' => ctrans('texts.dashboard'), 'url' => 'client.dashboard', 'icon' => 'activity'];
|
|
|
|
|
|
|
|
if (self::MODULE_PURCHASE_ORDERS & $enabled_modules) {
|
|
|
|
$data[] = ['title' => ctrans('texts.purchase_orders'), 'url' => 'vendor.purchase_orders.index', 'icon' => 'file-text'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// $data[] = ['title' => ctrans('texts.documents'), 'url' => 'client.documents.index', 'icon' => 'download'];
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|