Skip to content

Commit

Permalink
conflicts resolved.
Browse files Browse the repository at this point in the history
  • Loading branch information
suraj-webkul committed Nov 7, 2024
2 parents 0ef0e38 + 9e7b129 commit 3c04e30
Show file tree
Hide file tree
Showing 202 changed files with 4,552 additions and 1,838 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ APP_DEBUG=true
APP_URL=http://localhost
APP_TIMEZONE=Asia/Kolkata
APP_LOCALE=en
APP_CURRENCY=USD

VITE_HOST=
VITE_PORT=
Expand Down
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
## **v2.0.2 (13th of September 2024)** - *Release*
## **v2.0.2 (24th of September 2024)** - *Release*

* #1633[enhancement] Use variable instead of calling every time of use db table prefix.

* #1621[enhancement] Person view page refactor.

* #1632[fixed] Update mail view render event.

* #1631[fixed] Dark Mode UI.

* #1629[fixed] Activities participants dark mode ui fixed.

* #1628[fixed] Refactor the quotes edit and create page.

* #1627[fixed] Leads actions ui.

* #1626[fixed] Mail View Page Refactor

* #1625[fixed] Sidebar rounded menu fix in rtl view.

* #1619[fixed] Persons view page avatar and organization edit button.

* #1617[fixed] When Printing to pdf, currency Symbol gets printed with ? instead of the Symbol.

* #1603[fixed] Bug: Page resets when entering the first character in "URL And Parameters" while creating a Webhook on mobile.

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
2. [Documentation](#documentation)
3. [Requirements](#requirements)
4. [Installation & Configuration](#installation-and-configuration)
4. [Docker Installation](https://devdocs.krayincrm.com/2.0/introduction/docker.html)
5. [License](#license)
6. [Security Vulnerabilities](#security-vulnerabilities)

Expand Down Expand Up @@ -123,8 +124,8 @@ password:admin123

### License

Krayin CRM is a truly opensource CRM framework which will always be free under the [MIT License](https://github.com/krayin/laravel-crm/blob/master/LICENSE).
Krayin CRM is a truly opensource CRM framework which will always be free under the [OSL-3.0 License](https://github.com/krayin/laravel-crm/blob/master/LICENSE.txt).

### Security Vulnerabilities

Please don't disclose security vulnerabilities publicly. If you find any security vulnerability in Krayin CRM then please email us: mailto:[email protected].
Please don't disclose security vulnerabilities publicly. If you find any security vulnerability in Krayin CRM then please email us: [email protected].
1 change: 1 addition & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
'es' => 'Español',
'fa' => 'Persian',
'tr' => 'Türkçe',
'vi' => 'Vietnamese',
],

/*
Expand Down
4 changes: 2 additions & 2 deletions packages/Webkul/Admin/src/Config/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@
'icon-class' => 'icon-settings-mail',
], [
'key' => 'settings.automation.webhooks',
'name' => 'Webhooks',
'info' => 'Add Edit Delete Webhooks from CRM',
'name' => 'admin::app.layouts.webhooks',
'info' => 'admin::app.layouts.webhooks-info',
'route' => 'admin.settings.webhooks.index',
'sort' => 2,
'icon-class' => 'icon-settings-webhooks',
Expand Down
36 changes: 1 addition & 35 deletions packages/Webkul/Admin/src/DataGrids/Contact/PersonDataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,6 @@ public function prepareColumns(): void
'sortable' => true,
'filterable' => true,
'searchable' => true,
'closure' => function ($row) {
[$bgColorClass, $textColorClass] = $this->generateRandomColorClasses();

$nameParts = explode(' ', $row->person_name);

$sortName = '';

if (count($nameParts) >= 2) {
$sortName = ($nameParts[0][0].$nameParts[1][0]);
} elseif (count($nameParts) === 1) {
$sortName = substr($nameParts[0], 0, 2);
}

return "<div class='flex items-center gap-3'>
<div class='$bgColorClass $textColorClass flex h-9 w-9 cursor-pointer items-center justify-center rounded-full text-sm'>$sortName</div>
<p class='text-sm text-black dark:bg-gray-900 dark:text-gray-300'>$row->person_name</p>
</div>";
},
]);

$this->addColumn([
Expand All @@ -91,9 +73,7 @@ public function prepareColumns(): void
'sortable' => false,
'filterable' => true,
'searchable' => true,
'closure' => function ($row) {
return collect(json_decode($row->emails, true) ?? [])->pluck('value')->join(', ');
},
'closure' => fn ($row) => collect(json_decode($row->emails, true) ?? [])->pluck('value')->join(', '),
]);

$this->addColumn([
Expand Down Expand Up @@ -177,18 +157,4 @@ public function prepareMassActions(): void
]);
}
}

/**
* Generate random color classes.
*/
public function generateRandomColorClasses(): array
{
return collect([
['bg-orange-100', 'text-orange-800'],
['bg-red-100', 'text-red-800'],
['bg-green-100', 'text-green-800'],
['bg-blue-100', 'text-blue-800'],
['bg-purple-100', 'text-purple-800'],
])->random();
}
}
8 changes: 5 additions & 3 deletions packages/Webkul/Admin/src/DataGrids/Lead/LeadDataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function __construct(
*/
public function prepareQueryBuilder(): Builder
{
$tablePrefix = DB::getTablePrefix();

$queryBuilder = DB::table('leads')
->addSelect(
'leads.id',
Expand All @@ -65,7 +67,7 @@ public function prepareQueryBuilder(): Builder
'tags.name as tag_name',
'lead_pipelines.rotten_days as pipeline_rotten_days',
'lead_pipeline_stages.code as stage_code',
DB::raw('CASE WHEN DATEDIFF(NOW(),'.DB::getTablePrefix().'leads.created_at) >='.DB::getTablePrefix().'lead_pipelines.rotten_days THEN 1 ELSE 0 END as rotten_lead'),
DB::raw('CASE WHEN DATEDIFF(NOW(),'.$tablePrefix.'leads.created_at) >='.$tablePrefix.'lead_pipelines.rotten_days THEN 1 ELSE 0 END as rotten_lead'),
)
->leftJoin('users', 'leads.user_id', '=', 'users.id')
->leftJoin('persons', 'leads.person_id', '=', 'persons.id')
Expand All @@ -83,7 +85,7 @@ public function prepareQueryBuilder(): Builder
}

if (! is_null(request()->input('rotten_lead.in'))) {
$queryBuilder->havingRaw(DB::getTablePrefix().'rotten_lead = '.request()->input('rotten_lead.in'));
$queryBuilder->havingRaw($tablePrefix.'rotten_lead = '.request()->input('rotten_lead.in'));
}

$this->addFilter('id', 'leads.id');
Expand All @@ -97,7 +99,7 @@ public function prepareQueryBuilder(): Builder
$this->addFilter('tag_name', 'tags.name');
$this->addFilter('expected_close_date', 'leads.expected_close_date');
$this->addFilter('created_at', 'leads.created_at');
$this->addFilter('rotten_lead', DB::raw('DATEDIFF(NOW(), '.DB::getTablePrefix().'leads.created_at) >= '.DB::getTablePrefix().'lead_pipelines.rotten_days'));
$this->addFilter('rotten_lead', DB::raw('DATEDIFF(NOW(), '.$tablePrefix.'leads.created_at) >= '.$tablePrefix.'lead_pipelines.rotten_days'));

return $queryBuilder;
}
Expand Down
14 changes: 8 additions & 6 deletions packages/Webkul/Admin/src/DataGrids/Product/ProductDataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ProductDataGrid extends DataGrid
*/
public function prepareQueryBuilder(): Builder
{
$tablePrefix = DB::getTablePrefix();

$queryBuilder = DB::table('products')
->leftJoin('product_inventories', 'products.id', '=', 'product_inventories.product_id')
->select(
Expand All @@ -21,19 +23,19 @@ public function prepareQueryBuilder(): Builder
'products.name',
'products.price',
)
->addSelect(DB::raw('SUM('.DB::getTablePrefix().'product_inventories.in_stock) as total_in_stock'))
->addSelect(DB::raw('SUM('.DB::getTablePrefix().'product_inventories.allocated) as total_allocated'))
->addSelect(DB::raw('SUM('.DB::getTablePrefix().'product_inventories.in_stock - '.DB::getTablePrefix().'product_inventories.allocated) as total_on_hand'))
->addSelect(DB::raw('SUM('.$tablePrefix.'product_inventories.in_stock) as total_in_stock'))
->addSelect(DB::raw('SUM('.$tablePrefix.'product_inventories.allocated) as total_allocated'))
->addSelect(DB::raw('SUM('.$tablePrefix.'product_inventories.in_stock - '.$tablePrefix.'product_inventories.allocated) as total_on_hand'))
->groupBy('products.id');

if (request()->route('id')) {
$queryBuilder->where('product_inventories.warehouse_id', request()->route('id'));
}

$this->addFilter('id', 'products.id');
$this->addFilter('total_in_stock', DB::raw('SUM('.DB::getTablePrefix().'product_inventories.in_stock'));
$this->addFilter('total_allocated', DB::raw('SUM('.DB::getTablePrefix().'product_inventories.allocated'));
$this->addFilter('total_on_hand', DB::raw('SUM('.DB::getTablePrefix().'product_inventories.in_stock - '.DB::getTablePrefix().'product_inventories.allocated'));
$this->addFilter('total_in_stock', DB::raw('SUM('.$tablePrefix.'product_inventories.in_stock'));
$this->addFilter('total_allocated', DB::raw('SUM('.$tablePrefix.'product_inventories.allocated'));
$this->addFilter('total_on_hand', DB::raw('SUM('.$tablePrefix.'product_inventories.in_stock - '.$tablePrefix.'product_inventories.allocated'));

return $queryBuilder;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/Webkul/Admin/src/DataGrids/Quote/QuoteDataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class QuoteDataGrid extends DataGrid
*/
public function prepareQueryBuilder(): Builder
{
$tablePrefix = DB::getTablePrefix();

$queryBuilder = DB::table('quotes')
->addSelect(
'quotes.id',
Expand Down Expand Up @@ -45,9 +47,9 @@ public function prepareQueryBuilder(): Builder
$this->addFilter('created_at', 'quotes.created_at');

if (request()->input('expired_quotes.in') == 1) {
$this->addFilter('expired_quotes', DB::raw('DATEDIFF(NOW(), '.DB::getTablePrefix().'quotes.expired_at) >= '.DB::getTablePrefix().'NOW()'));
$this->addFilter('expired_quotes', DB::raw('DATEDIFF(NOW(), '.$tablePrefix.'quotes.expired_at) >= '.$tablePrefix.'NOW()'));
} else {
$this->addFilter('expired_quotes', DB::raw('DATEDIFF(NOW(), '.DB::getTablePrefix().'quotes.expired_at) < '.DB::getTablePrefix().'NOW()'));
$this->addFilter('expired_quotes', DB::raw('DATEDIFF(NOW(), '.$tablePrefix.'quotes.expired_at) < '.$tablePrefix.'NOW()'));
}

return $queryBuilder;
Expand Down
18 changes: 13 additions & 5 deletions packages/Webkul/Admin/src/DataGrids/Settings/AttributeDataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Query\Builder;
use Illuminate\Support\Facades\DB;
use Webkul\Attribute\Repositories\AttributeRepository;
use Webkul\DataGrid\DataGrid;

class AttributeDataGrid extends DataGrid
Expand Down Expand Up @@ -66,17 +67,24 @@ public function prepareColumns(): void
'index' => 'entity_type',
'label' => trans('admin::app.settings.attributes.index.datagrid.entity-type'),
'type' => 'string',
'sortable' => true,
'searchable' => false,
'filterable' => true,
'closure' => fn ($row) => ucfirst($row->entity_type),
]);

$this->addColumn([
'index' => 'type',
'label' => trans('admin::app.settings.attributes.index.datagrid.type'),
'type' => 'string',
'sortable' => true,
'filterable' => true,
'index' => 'type',
'label' => trans('admin::app.settings.attributes.index.datagrid.type'),
'type' => 'string',
'sortable' => true,
'filterable' => true,
'filterable_type' => 'dropdown',
'filterable_options' => app(AttributeRepository::class)
->select('type as label', 'type as value')
->distinct()
->get()
->toArray(),
]);

$this->addColumn([
Expand Down
36 changes: 11 additions & 25 deletions packages/Webkul/Admin/src/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@ public function render($request, Throwable $exception)
return parent::render($request, $exception);
}

/**
* Report the exception.
*
* @return void
*/
public function report(Throwable $exception)
{
//
}

/**
* Convert an authentication exception into a response.
*
Expand All @@ -84,48 +74,44 @@ protected function unauthenticated($request, AuthenticationException $exception)
*/
private function renderCustomResponse(Throwable $exception)
{
$path = request()->routeIs('admin.*') ? 'admin' : 'front';

if ($path == 'front') {
return redirect()->route('admin.session.create');
}

if ($exception instanceof HttpException) {
$statusCode = in_array($exception->getStatusCode(), [401, 403, 404, 503])
? $exception->getStatusCode()
: 500;

return $this->response($path, $statusCode);
return $this->response($statusCode);
}

if ($exception instanceof ValidationException) {
return parent::render(request(), $exception);
}

if ($exception instanceof ModelNotFoundException) {
return $this->response($path, 404);
return $this->response(404);
} elseif ($exception instanceof PDOException || $exception instanceof \ParseError) {
return $this->response($path, 500);
return $this->response(500);
} else {
return $this->response(500);
}
}

/**
* Return custom response.
*
* @param string $path
* @param string $statusCode
* @param string $errorCode
* @return mixed
*/
private function response($path, $statusCode)
private function response($errorCode)
{
if (request()->expectsJson()) {
return response()->json([
'message' => isset($this->jsonErrorMessages[$statusCode])
? $this->jsonErrorMessages[$statusCode]
'message' => isset($this->jsonErrorMessages[$errorCode])
? $this->jsonErrorMessages[$errorCode]
: trans('admin::app.common.something-went-wrong'),
], $statusCode);
], $errorCode);
}

return response()->view("{$path}::errors.{$statusCode}", [], $statusCode);
return response()->view('admin::errors.index', compact('errorCode'));
}
}
6 changes: 4 additions & 2 deletions packages/Webkul/Admin/src/Helpers/Reporting/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ public function getTotalOrganizations($startDate, $endDate): int
*/
public function getTopOrganizationsByRevenue($limit = null): Collection
{
$tablePrefix = DB::getTablePrefix();

$items = $this->organizationRepository
->resetModel()
->leftJoin('persons', 'organizations.id', '=', 'persons.organization_id')
->leftJoin('leads', 'persons.id', '=', 'leads.person_id')
->select('*', 'persons.id as id')
->addSelect(DB::raw('SUM('.DB::getTablePrefix().'leads.lead_value) as revenue'))
->addSelect(DB::raw('SUM('.$tablePrefix.'leads.lead_value) as revenue'))
->whereBetween('leads.closed_at', [$this->startDate, $this->endDate])
->having(DB::raw('SUM('.DB::getTablePrefix().'leads.lead_value)'), '>', 0)
->having(DB::raw('SUM('.$tablePrefix.'leads.lead_value)'), '>', 0)
->groupBy('organization_id')
->orderBy('revenue', 'DESC')
->limit($limit)
Expand Down
6 changes: 4 additions & 2 deletions packages/Webkul/Admin/src/Helpers/Reporting/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ public function getTotalPersons($startDate, $endDate): int
*/
public function getTopCustomersByRevenue($limit = null): Collection
{
$tablePrefix = DB::getTablePrefix();

$items = $this->personRepository
->resetModel()
->leftJoin('leads', 'persons.id', '=', 'leads.person_id')
->select('*', 'persons.id as id')
->addSelect(DB::raw('SUM('.DB::getTablePrefix().'leads.lead_value) as revenue'))
->addSelect(DB::raw('SUM('.$tablePrefix.'leads.lead_value) as revenue'))
->whereBetween('leads.closed_at', [$this->startDate, $this->endDate])
->having(DB::raw('SUM('.DB::getTablePrefix().'leads.lead_value)'), '>', 0)
->having(DB::raw('SUM('.$tablePrefix.'leads.lead_value)'), '>', 0)
->groupBy('person_id')
->orderBy('revenue', 'DESC')
->limit($limit)
Expand Down
Loading

0 comments on commit 3c04e30

Please sign in to comment.