Initial commit
This commit is contained in:
35
application/Espo/Modules/Crm/Controllers/Account.php
Normal file
35
application/Espo/Modules/Crm/Controllers/Account.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class Account extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
}
|
||||
59
application/Espo/Modules/Crm/Controllers/Activities.php
Normal file
59
application/Espo/Modules/Crm/Controllers/Activities.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Modules\Crm\Tools\Activities\Service as Service;
|
||||
|
||||
class Activities
|
||||
{
|
||||
public function __construct(
|
||||
private Service $service
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
*/
|
||||
public function postActionRemovePopupNotification(Request $request): bool
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$id = $data->id;
|
||||
|
||||
$this->service->removeReminder($id);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
213
application/Espo/Modules/Crm/Controllers/Call.php
Normal file
213
application/Espo/Modules/Crm/Controllers/Call.php
Normal file
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Controllers\Record;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Mail\Exceptions\SendingError;
|
||||
use Espo\Core\Utils\Json;
|
||||
use Espo\Modules\Crm\Entities\Call as CallEntity;
|
||||
use Espo\Modules\Crm\Tools\Meeting\InvitationService;
|
||||
use Espo\Modules\Crm\Tools\Meeting\Invitation\Invitee;
|
||||
use Espo\Modules\Crm\Tools\Meeting\Service;
|
||||
use stdClass;
|
||||
|
||||
class Call extends Record
|
||||
{
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws Error
|
||||
* @throws SendingError
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionSendInvitations(Request $request): bool
|
||||
{
|
||||
$id = $request->getParsedBody()->id ?? null;
|
||||
|
||||
if (!$id) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$invitees = $this->fetchInvitees($request);
|
||||
|
||||
$resultList = $this->injectableFactory
|
||||
->create(InvitationService::class)
|
||||
->send(CallEntity::ENTITY_TYPE, $id, $invitees);
|
||||
|
||||
return $resultList !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws Error
|
||||
* @throws SendingError
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionSendCancellation(Request $request): bool
|
||||
{
|
||||
$id = $request->getParsedBody()->id ?? null;
|
||||
|
||||
if (!$id) {
|
||||
throw new BadRequest("No id.");
|
||||
}
|
||||
|
||||
$invitees = $this->fetchInvitees($request);
|
||||
|
||||
$resultList = $this->injectableFactory
|
||||
->create(InvitationService::class)
|
||||
->sendCancellation(CallEntity::ENTITY_TYPE, $id, $invitees);
|
||||
|
||||
return $resultList !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return ?\Espo\Modules\Crm\Tools\Meeting\Invitation\Invitee[]
|
||||
* @throws BadRequest
|
||||
*/
|
||||
private function fetchInvitees(Request $request): ?array
|
||||
{
|
||||
$targets = $request->getParsedBody()->targets ?? null;
|
||||
|
||||
if ($targets === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_array($targets)) {
|
||||
throw new BadRequest("No targets.");
|
||||
}
|
||||
|
||||
$invitees = [];
|
||||
|
||||
foreach ($targets as $target) {
|
||||
if (!$target instanceof stdClass) {
|
||||
throw new BadRequest("Bad target.");
|
||||
}
|
||||
|
||||
$targetEntityType = $target->entityType ?? null;
|
||||
$targetId = $target->id ?? null;
|
||||
|
||||
if (!is_string($targetEntityType) || !is_string($targetId)) {
|
||||
throw new BadRequest("No entityType or id.");
|
||||
}
|
||||
|
||||
$invitees[] = new Invitee($targetEntityType, $targetId);
|
||||
}
|
||||
|
||||
return $invitees;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function postActionMassSetHeld(Request $request): bool
|
||||
{
|
||||
$ids = $request->getParsedBody()->ids ?? null;
|
||||
|
||||
if (!is_array($ids)) {
|
||||
throw new BadRequest("No `ids`.");
|
||||
}
|
||||
|
||||
$this->injectableFactory
|
||||
->create(Service::class)
|
||||
->massSetHeld(CallEntity::ENTITY_TYPE, $ids);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function postActionMassSetNotHeld(Request $request): bool
|
||||
{
|
||||
$ids = $request->getParsedBody()->ids ?? null;
|
||||
|
||||
if (!is_array($ids)) {
|
||||
throw new BadRequest("No `ids`.");
|
||||
}
|
||||
|
||||
$this->injectableFactory
|
||||
->create(Service::class)
|
||||
->massSetNotHeld(CallEntity::ENTITY_TYPE, $ids);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws NotFound
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function postActionSetAcceptanceStatus(Request $request): bool
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
if (empty($data->id) || empty($data->status)) {
|
||||
throw new BadRequest("No id or status.");
|
||||
}
|
||||
|
||||
$this->injectableFactory
|
||||
->create(Service::class)
|
||||
->setAcceptance(CallEntity::ENTITY_TYPE, $data->id, $data->status);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function getActionAttendees(Request $request, Response $response): void
|
||||
{
|
||||
$id = $request->getRouteParam('id');
|
||||
|
||||
if (!$id) {
|
||||
throw new BadRequest("No id.");
|
||||
}
|
||||
|
||||
$collection = $this->injectableFactory
|
||||
->create(Service::class)
|
||||
->getAttendees(CallEntity::ENTITY_TYPE, $id);
|
||||
|
||||
$response->writeBody(
|
||||
Json::encode(['list' => $collection->getValueMapList()])
|
||||
);
|
||||
}
|
||||
}
|
||||
35
application/Espo/Modules/Crm/Controllers/Campaign.php
Normal file
35
application/Espo/Modules/Crm/Controllers/Campaign.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
use Espo\Core\Controllers\Record;
|
||||
|
||||
class Campaign extends Record
|
||||
{}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class CampaignLogRecord extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class CampaignTrackingUrl extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
}
|
||||
71
application/Espo/Modules/Crm/Controllers/CaseObj.php
Normal file
71
application/Espo/Modules/Crm/Controllers/CaseObj.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
use Espo\Core\Acl\Table;
|
||||
use Espo\Core\Controllers\Record;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Modules\Crm\Entities\CaseObj as CaseEntity;
|
||||
use Espo\Modules\Crm\Tools\Case\Service;
|
||||
use stdClass;
|
||||
|
||||
class CaseObj extends Record
|
||||
{
|
||||
protected $name = CaseEntity::ENTITY_TYPE;
|
||||
|
||||
/**
|
||||
* @return stdClass[]
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function getActionEmailAddressList(Request $request): array
|
||||
{
|
||||
$id = $request->getQueryParam('id');
|
||||
|
||||
if (!$id) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!$this->acl->checkScope(CaseEntity::ENTITY_TYPE, Table::ACTION_READ)) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$result = $this->injectableFactory
|
||||
->create(Service::class)
|
||||
->getEmailAddressList($id);
|
||||
|
||||
return array_map(
|
||||
fn ($item) => $item->getValueMap(),
|
||||
$result
|
||||
);
|
||||
}
|
||||
}
|
||||
35
application/Espo/Modules/Crm/Controllers/Contact.php
Normal file
35
application/Espo/Modules/Crm/Controllers/Contact.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class Contact extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
}
|
||||
85
application/Espo/Modules/Crm/Controllers/Document.php
Normal file
85
application/Espo/Modules/Crm/Controllers/Document.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
use Espo\Core\Controllers\Record;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Api\Request;
|
||||
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Modules\Crm\Tools\Document\Service;
|
||||
use Espo\Tools\Attachment\FieldData;
|
||||
use stdClass;
|
||||
|
||||
class Document extends Record
|
||||
{
|
||||
|
||||
/**
|
||||
* @return stdClass[]
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws Error
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionGetAttachmentList(Request $request): array
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
$id = $data->id ?? null;
|
||||
$field = $data->field ?? null;
|
||||
$parentType = $data->parentType ?? null;
|
||||
$relatedType = $data->relatedType ?? null;
|
||||
|
||||
if (!$id || !$field) {
|
||||
throw new BadRequest("No `id` or `field`.");
|
||||
}
|
||||
|
||||
try {
|
||||
$fieldData = new FieldData(
|
||||
$field,
|
||||
$parentType,
|
||||
$relatedType
|
||||
);
|
||||
} catch (Error $e) {
|
||||
throw new BadRequest($e->getMessage());
|
||||
}
|
||||
|
||||
$attachment = $this->getDocumentService()->copyAttachment($id, $fieldData);
|
||||
|
||||
return [$attachment->getValueMap()];
|
||||
}
|
||||
|
||||
private function getDocumentService(): Service
|
||||
{
|
||||
return $this->injectableFactory->create(Service::class);
|
||||
}
|
||||
}
|
||||
35
application/Espo/Modules/Crm/Controllers/DocumentFolder.php
Normal file
35
application/Espo/Modules/Crm/Controllers/DocumentFolder.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class DocumentFolder extends \Espo\Core\Templates\Controllers\CategoryTree
|
||||
{
|
||||
|
||||
}
|
||||
38
application/Espo/Modules/Crm/Controllers/EmailQueueItem.php
Normal file
38
application/Espo/Modules/Crm/Controllers/EmailQueueItem.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class EmailQueueItem extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
protected function checkAccess(): bool
|
||||
{
|
||||
return $this->user->isAdmin();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
use Espo\Core\Controllers\Record;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Select\SearchParams;
|
||||
use Espo\Core\Select\Where\Item as WhereItem;
|
||||
use Espo\Core\Utils\Json;
|
||||
use Espo\Modules\Crm\Tools\KnowledgeBase\Service as KBService;
|
||||
|
||||
use Espo\Tools\Attachment\FieldData;
|
||||
use stdClass;
|
||||
|
||||
class KnowledgeBaseArticle extends Record
|
||||
{
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionGetCopiedAttachments(Request $request): stdClass
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
$id = $data->id ?? null;
|
||||
$field = $data->field ?? null;
|
||||
$parentType = $data->parentType ?? null;
|
||||
$relatedType = $data->relatedType ?? null;
|
||||
|
||||
if (!$id || !$field) {
|
||||
throw new BadRequest("No `id` or `field`.");
|
||||
}
|
||||
|
||||
try {
|
||||
$fieldData = new FieldData(
|
||||
$field,
|
||||
$parentType,
|
||||
$relatedType
|
||||
);
|
||||
} catch (Error $e) {
|
||||
throw new BadRequest($e->getMessage());
|
||||
}
|
||||
|
||||
$list = $this->getArticleService()->copyAttachments($id, $fieldData);
|
||||
|
||||
$ids = array_map(
|
||||
fn ($item) => $item->getId(),
|
||||
$list
|
||||
);
|
||||
|
||||
$names = (object) [];
|
||||
|
||||
foreach ($list as $item) {
|
||||
$names->{$item->getId()} = $item->getName();
|
||||
}
|
||||
|
||||
return (object) [
|
||||
'ids' => $ids,
|
||||
'names' => $names,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws Error
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionMoveToTop(Request $request): bool
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$searchParams = $this->fetchSearchParams($request);
|
||||
|
||||
$this->getArticleService()->moveToTop($data->id, $searchParams);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws Error
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionMoveUp(Request $request): bool
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$searchParams = $this->fetchSearchParams($request);
|
||||
|
||||
$this->getArticleService()->moveUp($data->id, $searchParams);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws Error
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionMoveDown(Request $request): bool
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$searchParams = $this->fetchSearchParams($request);
|
||||
|
||||
$this->getArticleService()->moveDown($data->id, $searchParams);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws Error
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionMoveToBottom(Request $request): bool
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$searchParams = $this->fetchSearchParams($request);
|
||||
|
||||
$this->getArticleService()->moveToBottom($data->id, $searchParams);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function getArticleService(): KBService
|
||||
{
|
||||
return $this->injectableFactory->create(KBService::class);
|
||||
}
|
||||
|
||||
private function fetchSearchParams(Request $request): SearchParams
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
|
||||
$searchParams = SearchParams::create();
|
||||
|
||||
if ($body->whereGroup ?? null) {
|
||||
$rawWhere = Json::decode(Json::encode($body->whereGroup), true);
|
||||
|
||||
$searchParams = SearchParams::fromRaw(['where' => $rawWhere]);
|
||||
}
|
||||
|
||||
return $searchParams;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class KnowledgeBaseCategory extends \Espo\Core\Templates\Controllers\CategoryTree
|
||||
{
|
||||
|
||||
}
|
||||
102
application/Espo/Modules/Crm/Controllers/Lead.php
Normal file
102
application/Espo/Modules/Crm/Controllers/Lead.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
use Espo\Core\Controllers\Record;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Exceptions\Conflict;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Modules\Crm\Tools\Lead\Convert\Params as ConvertParams;
|
||||
use Espo\Modules\Crm\Tools\Lead\Convert\Values;
|
||||
use Espo\Modules\Crm\Tools\Lead\ConvertService;
|
||||
use stdClass;
|
||||
|
||||
class Lead extends Record
|
||||
{
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws Conflict
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionConvert(Request $request): stdClass
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
$id = $data->id ?? null;
|
||||
$records = $data->records ?? (object) [];
|
||||
|
||||
if (!$id) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!$records instanceof stdClass) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$recordsPayload = Values::create();
|
||||
|
||||
foreach (get_object_vars($records) as $entityType => $payload) {
|
||||
$recordsPayload = $recordsPayload->with($entityType, $payload);
|
||||
}
|
||||
|
||||
$skipDuplicateCheck = $data->skipDuplicateCheck ?? false;
|
||||
|
||||
$params = new ConvertParams($skipDuplicateCheck);
|
||||
|
||||
$lead = $this->injectableFactory
|
||||
->create(ConvertService::class)
|
||||
->convert($id, $recordsPayload, $params);
|
||||
|
||||
return $lead->getValueMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function postActionGetConvertAttributes(Request $request): stdClass
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
if (empty($data->id)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$data = $this->injectableFactory
|
||||
->create(ConvertService::class)
|
||||
->getValues($data->id);
|
||||
|
||||
return $data->getRaw();
|
||||
}
|
||||
}
|
||||
89
application/Espo/Modules/Crm/Controllers/MassEmail.php
Normal file
89
application/Espo/Modules/Crm/Controllers/MassEmail.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
use Espo\Core\Controllers\Record;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Mail\Exceptions\NoSmtp;
|
||||
use Espo\Modules\Crm\Entities\MassEmail as MassEmailEntity;
|
||||
use Espo\Modules\Crm\Tools\MassEmail\Service;
|
||||
|
||||
use Espo\Core\Acl\Table;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class MassEmail extends Record
|
||||
{
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws Error
|
||||
* @throws NoSmtp
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionSendTest(Request $request): bool
|
||||
{
|
||||
$id = $request->getParsedBody()->id ?? null;
|
||||
$targetList = $request->getParsedBody()->targetList ?? null;
|
||||
|
||||
if (!$id || !is_array($targetList)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->getMassEmailService()->processTest($id, $targetList);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return stdClass[]
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function getActionSmtpAccountDataList(): array
|
||||
{
|
||||
if (
|
||||
!$this->acl->checkScope(MassEmailEntity::ENTITY_TYPE, Table::ACTION_CREATE) &&
|
||||
!$this->acl->checkScope(MassEmailEntity::ENTITY_TYPE, Table::ACTION_EDIT)
|
||||
) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
return $this->getMassEmailService()->getSmtpAccountDataList();
|
||||
}
|
||||
|
||||
private function getMassEmailService(): Service
|
||||
{
|
||||
return $this->injectableFactory->create(Service::class);
|
||||
}
|
||||
}
|
||||
213
application/Espo/Modules/Crm/Controllers/Meeting.php
Normal file
213
application/Espo/Modules/Crm/Controllers/Meeting.php
Normal file
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Controllers\Record;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Mail\Exceptions\SendingError;
|
||||
use Espo\Core\Utils\Json;
|
||||
use Espo\Modules\Crm\Entities\Meeting as MeetingEntity;
|
||||
use Espo\Modules\Crm\Tools\Meeting\InvitationService;
|
||||
use Espo\Modules\Crm\Tools\Meeting\Invitation\Invitee;
|
||||
use Espo\Modules\Crm\Tools\Meeting\Service;
|
||||
use stdClass;
|
||||
|
||||
class Meeting extends Record
|
||||
{
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws Error
|
||||
* @throws SendingError
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionSendInvitations(Request $request): bool
|
||||
{
|
||||
$id = $request->getParsedBody()->id ?? null;
|
||||
|
||||
if (!$id) {
|
||||
throw new BadRequest("No id.");
|
||||
}
|
||||
|
||||
$invitees = $this->fetchInvitees($request);
|
||||
|
||||
$resultList = $this->injectableFactory
|
||||
->create(InvitationService::class)
|
||||
->send(MeetingEntity::ENTITY_TYPE, $id, $invitees);
|
||||
|
||||
return $resultList !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws Error
|
||||
* @throws SendingError
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionSendCancellation(Request $request): bool
|
||||
{
|
||||
$id = $request->getParsedBody()->id ?? null;
|
||||
|
||||
if (!$id) {
|
||||
throw new BadRequest("No id.");
|
||||
}
|
||||
|
||||
$invitees = $this->fetchInvitees($request);
|
||||
|
||||
$resultList = $this->injectableFactory
|
||||
->create(InvitationService::class)
|
||||
->sendCancellation(MeetingEntity::ENTITY_TYPE, $id, $invitees);
|
||||
|
||||
return $resultList !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return ?Invitee[]
|
||||
* @throws BadRequest
|
||||
*/
|
||||
private function fetchInvitees(Request $request): ?array
|
||||
{
|
||||
$targets = $request->getParsedBody()->targets ?? null;
|
||||
|
||||
if ($targets === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_array($targets)) {
|
||||
throw new BadRequest("No targets.");
|
||||
}
|
||||
|
||||
$invitees = [];
|
||||
|
||||
foreach ($targets as $target) {
|
||||
if (!$target instanceof stdClass) {
|
||||
throw new BadRequest("Bad target.");
|
||||
}
|
||||
|
||||
$targetEntityType = $target->entityType ?? null;
|
||||
$targetId = $target->id ?? null;
|
||||
|
||||
if (!is_string($targetEntityType) || !is_string($targetId)) {
|
||||
throw new BadRequest("No entityType or id.");
|
||||
}
|
||||
|
||||
$invitees[] = new Invitee($targetEntityType, $targetId);
|
||||
}
|
||||
|
||||
return $invitees;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function postActionMassSetHeld(Request $request): bool
|
||||
{
|
||||
$ids = $request->getParsedBody()->ids ?? null;
|
||||
|
||||
if (!is_array($ids)) {
|
||||
throw new BadRequest("No `ids`.");
|
||||
}
|
||||
|
||||
$this->injectableFactory
|
||||
->create(Service::class)
|
||||
->massSetHeld(MeetingEntity::ENTITY_TYPE, $ids);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function postActionMassSetNotHeld(Request $request): bool
|
||||
{
|
||||
$ids = $request->getParsedBody()->ids ?? null;
|
||||
|
||||
if (!is_array($ids)) {
|
||||
throw new BadRequest("No `ids`.");
|
||||
}
|
||||
|
||||
$this->injectableFactory
|
||||
->create(Service::class)
|
||||
->massSetNotHeld(MeetingEntity::ENTITY_TYPE, $ids);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws NotFound
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function postActionSetAcceptanceStatus(Request $request): bool
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
if (empty($data->id) || empty($data->status)) {
|
||||
throw new BadRequest("No id or status.");
|
||||
}
|
||||
|
||||
$this->injectableFactory
|
||||
->create(Service::class)
|
||||
->setAcceptance(MeetingEntity::ENTITY_TYPE, $data->id, $data->status);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function getActionAttendees(Request $request, Response $response): void
|
||||
{
|
||||
$id = $request->getRouteParam('id');
|
||||
|
||||
if (!$id) {
|
||||
throw new BadRequest("No id.");
|
||||
}
|
||||
|
||||
$collection = $this->injectableFactory
|
||||
->create(Service::class)
|
||||
->getAttendees(MeetingEntity::ENTITY_TYPE, $id);
|
||||
|
||||
$response->writeBody(
|
||||
Json::encode(['list' => $collection->getValueMapList()])
|
||||
);
|
||||
}
|
||||
}
|
||||
193
application/Espo/Modules/Crm/Controllers/Opportunity.php
Normal file
193
application/Espo/Modules/Crm/Controllers/Opportunity.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
use Espo\Core\Acl\Table;
|
||||
use Espo\Core\Controllers\Record;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Field\Date;
|
||||
use Espo\Modules\Crm\Entities\Opportunity as OpportunityEntity;
|
||||
use Espo\Modules\Crm\Tools\Opportunity\Report\ByLeadSource;
|
||||
use Espo\Modules\Crm\Tools\Opportunity\Report\ByStage;
|
||||
use Espo\Modules\Crm\Tools\Opportunity\Report\DateRange;
|
||||
use Espo\Modules\Crm\Tools\Opportunity\Report\SalesByMonth;
|
||||
use Espo\Modules\Crm\Tools\Opportunity\Report\SalesPipeline;
|
||||
use Espo\Modules\Crm\Tools\Opportunity\Service;
|
||||
use stdClass;
|
||||
|
||||
class Opportunity extends Record
|
||||
{
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function getActionReportByLeadSource(Request $request): stdClass
|
||||
{
|
||||
if (!$this->acl->checkScope(OpportunityEntity::ENTITY_TYPE)) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$dateFrom = $request->getQueryParam('dateFrom');
|
||||
$dateTo = $request->getQueryParam('dateTo');
|
||||
$dateFilter = $request->getQueryParam('dateFilter');
|
||||
|
||||
if (!$dateFilter) {
|
||||
throw new BadRequest("No `dateFilter` parameter.");
|
||||
}
|
||||
|
||||
$range = new DateRange(
|
||||
$dateFilter,
|
||||
$dateFrom ? Date::fromString($dateFrom) : null,
|
||||
$dateTo ? Date::fromString($dateTo) : null
|
||||
);
|
||||
|
||||
return $this->injectableFactory
|
||||
->create(ByLeadSource::class)
|
||||
->run($range);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function getActionReportByStage(Request $request): stdClass
|
||||
{
|
||||
if (!$this->acl->checkScope(OpportunityEntity::ENTITY_TYPE)) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$dateFrom = $request->getQueryParam('dateFrom');
|
||||
$dateTo = $request->getQueryParam('dateTo');
|
||||
$dateFilter = $request->getQueryParam('dateFilter');
|
||||
|
||||
if (!$dateFilter) {
|
||||
throw new BadRequest("No `dateFilter` parameter.");
|
||||
}
|
||||
|
||||
$range = new DateRange(
|
||||
$dateFilter,
|
||||
$dateFrom ? Date::fromString($dateFrom) : null,
|
||||
$dateTo ? Date::fromString($dateTo) : null
|
||||
);
|
||||
|
||||
return $this->injectableFactory
|
||||
->create(ByStage::class)
|
||||
->run($range);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function getActionReportSalesByMonth(Request $request): stdClass
|
||||
{
|
||||
if (!$this->acl->checkScope(OpportunityEntity::ENTITY_TYPE)) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$dateFrom = $request->getQueryParam('dateFrom');
|
||||
$dateTo = $request->getQueryParam('dateTo');
|
||||
$dateFilter = $request->getQueryParam('dateFilter');
|
||||
|
||||
if (!$dateFilter) {
|
||||
throw new BadRequest("No `dateFilter` parameter.");
|
||||
}
|
||||
|
||||
$range = new DateRange(
|
||||
$dateFilter,
|
||||
$dateFrom ? Date::fromString($dateFrom) : null,
|
||||
$dateTo ? Date::fromString($dateTo) : null
|
||||
);
|
||||
|
||||
return $this->injectableFactory
|
||||
->create(SalesByMonth::class)
|
||||
->run($range);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function getActionReportSalesPipeline(Request $request): stdClass
|
||||
{
|
||||
if (!$this->acl->checkScope(OpportunityEntity::ENTITY_TYPE)) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$dateFrom = $request->getQueryParam('dateFrom');
|
||||
$dateTo = $request->getQueryParam('dateTo');
|
||||
$dateFilter = $request->getQueryParam('dateFilter');
|
||||
$useLastStage = $request->getQueryParam('useLastStage') === 'true';
|
||||
$teamId = $request->getQueryParam('teamId') ?? null;
|
||||
|
||||
if (!$dateFilter) {
|
||||
throw new BadRequest("No `dateFilter` parameter.");
|
||||
}
|
||||
|
||||
$range = new DateRange(
|
||||
$dateFilter,
|
||||
$dateFrom ? Date::fromString($dateFrom) : null,
|
||||
$dateTo ? Date::fromString($dateTo) : null
|
||||
);
|
||||
|
||||
return $this->injectableFactory
|
||||
->create(SalesPipeline::class)
|
||||
->run($range, $useLastStage, $teamId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return stdClass[]
|
||||
* @throws Forbidden
|
||||
* @throws BadRequest
|
||||
*/
|
||||
public function getActionEmailAddressList(Request $request): array
|
||||
{
|
||||
$id = $request->getQueryParam('id');
|
||||
|
||||
if (!$id) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (!$this->acl->checkScope(OpportunityEntity::ENTITY_TYPE, Table::ACTION_READ)) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$result = $this->injectableFactory
|
||||
->create(Service::class)
|
||||
->getEmailAddressList($id);
|
||||
|
||||
return array_map(
|
||||
fn ($item) => $item->getValueMap(),
|
||||
$result
|
||||
);
|
||||
}
|
||||
}
|
||||
37
application/Espo/Modules/Crm/Controllers/Target.php
Normal file
37
application/Espo/Modules/Crm/Controllers/Target.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
class Target extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
}
|
||||
122
application/Espo/Modules/Crm/Controllers/TargetList.php
Normal file
122
application/Espo/Modules/Crm/Controllers/TargetList.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Controllers\Record;
|
||||
use Espo\Modules\Crm\Tools\TargetList\OptOutService;
|
||||
use Espo\Modules\Crm\Tools\TargetList\RecordService;
|
||||
|
||||
class TargetList extends Record
|
||||
{
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Forbidden
|
||||
* @throws NotFound
|
||||
*/
|
||||
public function postActionUnlinkAll(Request $request): bool
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
$id = $data->id ?? null;
|
||||
$link = $data->link ?? null;
|
||||
|
||||
if (
|
||||
!is_string($id) ||
|
||||
!is_string($link)
|
||||
) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->injectableFactory->create(RecordService::class)->unlinkAll($id, $link);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws NotFound
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function postActionOptOut(Request $request): bool
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
$id = $data->id ?? null;
|
||||
$targetType = $data->targetType ?? null;
|
||||
$targetId = $data->targetId ?? null;
|
||||
|
||||
if (
|
||||
!is_string($id) ||
|
||||
!is_string($targetType) ||
|
||||
!is_string($targetId)
|
||||
) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->getOptOutService()->optOut($id, $targetType, $targetId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws NotFound
|
||||
* @throws Forbidden
|
||||
*/
|
||||
public function postActionCancelOptOut(Request $request): bool
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
$id = $data->id ?? null;
|
||||
$targetType = $data->targetType ?? null;
|
||||
$targetId = $data->targetId ?? null;
|
||||
|
||||
if (
|
||||
!is_string($id) ||
|
||||
!is_string($targetType) ||
|
||||
!is_string($targetId)
|
||||
) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->getOptOutService()->cancelOptOut($id, $targetType, $targetId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function getOptOutService(): OptOutService
|
||||
{
|
||||
return $this->injectableFactory->create(OptOutService::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
use Espo\Core\Templates\Controllers\CategoryTree;
|
||||
|
||||
class TargetListCategory extends CategoryTree
|
||||
{
|
||||
}
|
||||
35
application/Espo/Modules/Crm/Controllers/Task.php
Normal file
35
application/Espo/Modules/Crm/Controllers/Task.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Modules\Crm\Controllers;
|
||||
|
||||
class Task extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user