chore: initial import for test contour with k3s CI
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Banner;
|
||||
use App\Form\BannerType;
|
||||
use App\Repository\BannerRepository;
|
||||
use App\Repository\CityRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
||||
use Symfony\Component\String\Slugger\SluggerInterface;
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/admin/banner")
|
||||
*/
|
||||
class BannerController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/", name="admin_banner_index", methods={"GET"})
|
||||
*/
|
||||
public function index(BannerRepository $bannerRepository): Response
|
||||
{
|
||||
return $this->render('banner/index.html.twig', [
|
||||
'banners' => $bannerRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/new", name="banner_new", methods={"GET","POST"})
|
||||
*/
|
||||
public function new(Request $request, SluggerInterface $slugger): Response
|
||||
{
|
||||
$banner = new Banner();
|
||||
$form = $this->createForm(BannerType::class, $banner);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$srcFile = $form->get('file')->getData();
|
||||
|
||||
if ($srcFile) {
|
||||
$originalFilename = pathinfo($srcFile->getClientOriginalName(), PATHINFO_FILENAME);
|
||||
|
||||
$safeFilename = $slugger->slug($originalFilename);
|
||||
$newFilename = $safeFilename.'-'.uniqid().'.'.$srcFile->guessExtension();
|
||||
$srcFile->move(
|
||||
$this->getParameter('banners_directory'),
|
||||
$newFilename
|
||||
);
|
||||
|
||||
$banner->setSrc($newFilename);
|
||||
}
|
||||
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->persist($banner);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('admin_banner_index');
|
||||
}
|
||||
|
||||
return $this->render('banner/new.html.twig', [
|
||||
'banner' => $banner,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}/edit", name="banner_edit", methods={"GET","POST"})
|
||||
*/
|
||||
public function edit(Request $request, Banner $banner, SluggerInterface $slugger): Response
|
||||
{
|
||||
$form = $this->createForm(BannerType::class, $banner);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$file = $this->getParameter('banners_directory') . DIRECTORY_SEPARATOR . $banner->getSrc();
|
||||
|
||||
if (file_exists($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
$srcFile = $form->get('file')->getData();
|
||||
|
||||
if ($srcFile) {
|
||||
$originalFilename = pathinfo($srcFile->getClientOriginalName(), PATHINFO_FILENAME);
|
||||
|
||||
$safeFilename = $slugger->slug($originalFilename);
|
||||
$newFilename = $safeFilename.'-'.uniqid().'.'.$srcFile->guessExtension();
|
||||
$srcFile->move(
|
||||
$this->getParameter('banners_directory'),
|
||||
$newFilename
|
||||
);
|
||||
|
||||
$banner->setSrc($newFilename);
|
||||
}
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('admin_banner_index');
|
||||
}
|
||||
|
||||
return $this->render('banner/edit.html.twig', [
|
||||
'banner' => $banner,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="banner_delete", methods={"POST"})
|
||||
*/
|
||||
public function delete(Request $request, Banner $banner): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$banner->getId(), $request->request->get('_token'))) {
|
||||
$file = $this->getParameter('banners_directory') . DIRECTORY_SEPARATOR . $banner->getSrc();
|
||||
|
||||
if (file_exists($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->remove($banner);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('admin_banner_index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Bundle\Calltouch\Request as CalltouchRequest;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @Route("/api")
|
||||
*/
|
||||
class CalltouchAPIController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/add-calltouch", methods={"POST"})
|
||||
*/
|
||||
public function addCalltouch(Request $request): Response
|
||||
{
|
||||
$data = [
|
||||
'requestNumber' => \md5(\time()),
|
||||
'subject' => $request->request->get('subject'),
|
||||
'requestUrl' => $request->request->get('requestUrl'),
|
||||
'requestDate' => \date('d-m-Y H:i:s'),
|
||||
'fio' => $request->request->get('fio'),
|
||||
];
|
||||
|
||||
if (! empty($request->request->get('sessionId'))) {
|
||||
$data['sessionId'] = $request->request->get('sessionId');
|
||||
}
|
||||
|
||||
if (! empty($request->request->get('customSources'))) {
|
||||
if (!empty($request->request->get('customSources')['source'])) {
|
||||
$data['customSources'] = $request->request->get('customSources');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($request->request->get('tag'))) {
|
||||
$data['addTags'][] = ['tag' => $request->request->get('tag')];
|
||||
}
|
||||
|
||||
if (! empty($request->request->get('comment'))) {
|
||||
$data['comment']['text'] = json_encode($request->request->get('comment'), JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
if (! empty($request->request->get('phoneNumber'))) {
|
||||
$data['phoneNumber'] = $request->request->get('phoneNumber');
|
||||
}
|
||||
|
||||
if (! empty($request->request->get('email'))) {
|
||||
$data['email'] = $request->request->get('email');
|
||||
}
|
||||
|
||||
$calltouch = new CalltouchRequest();
|
||||
|
||||
if (! empty($request->request->get('regionId'))) {
|
||||
$calltouch->changeRegion($request->request->get('regionId'));
|
||||
}
|
||||
|
||||
$calltouch = $calltouch->create($data);
|
||||
|
||||
return $this->json(['data' => $calltouch]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\CategoryPage;
|
||||
use App\Form\CategoryPageType;
|
||||
use App\Repository\CategoryPageRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/category/page")
|
||||
*/
|
||||
class CategoryPageController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/", name="category_page_index", methods={"GET"})
|
||||
*/
|
||||
public function index(CategoryPageRepository $categoryPageRepository): Response
|
||||
{
|
||||
return $this->render('category_page/index.html.twig', [
|
||||
'category_pages' => $categoryPageRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/new", name="category_page_new", methods={"GET","POST"})
|
||||
*/
|
||||
public function new(Request $request): Response
|
||||
{
|
||||
$categoryPage = new CategoryPage();
|
||||
$form = $this->createForm(CategoryPageType::class, $categoryPage);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->persist($categoryPage);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('category_page_index');
|
||||
}
|
||||
|
||||
return $this->render('category_page/new.html.twig', [
|
||||
'category_page' => $categoryPage,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="category_page_show", methods={"GET"})
|
||||
*/
|
||||
public function show(CategoryPage $categoryPage): Response
|
||||
{
|
||||
return $this->render('category_page/show.html.twig', [
|
||||
'category_page' => $categoryPage,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}/edit", name="category_page_edit", methods={"GET","POST"})
|
||||
*/
|
||||
public function edit(Request $request, CategoryPage $categoryPage): Response
|
||||
{
|
||||
$form = $this->createForm(CategoryPageType::class, $categoryPage);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('category_page_index');
|
||||
}
|
||||
|
||||
return $this->render('category_page/edit.html.twig', [
|
||||
'category_page' => $categoryPage,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="category_page_delete", methods={"POST"})
|
||||
*/
|
||||
public function delete(Request $request, CategoryPage $categoryPage): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$categoryPage->getId(), $request->request->get('_token'))) {
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->remove($categoryPage);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('category_page_index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Bundle\Infoclinica\Region;
|
||||
use App\Entity\Filial;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use App\Repository\SpecialistRepository;
|
||||
use App\Repository\DepartmentRepository;
|
||||
use App\Repository\PriceDepartmentRepository;
|
||||
use App\Repository\PriceListRepository;
|
||||
use App\Entity\PriceList;
|
||||
use Knp\Component\Pager\PaginatorInterface;
|
||||
use App\Entity\PriceDepartment;
|
||||
use App\Form\PriceListFormType;
|
||||
use App\Form\PriceListAdminFormType;
|
||||
use App\Form\PriceListUpdateAdminFormType;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use App\Service\PriceListService;
|
||||
use App\Service\SpecialistService;
|
||||
|
||||
/**
|
||||
* @Route("/")
|
||||
*/
|
||||
class DefaultController extends AbstractController
|
||||
{
|
||||
private $client;
|
||||
|
||||
public function __construct(HttpClientInterface $client, KernelInterface $kernel)
|
||||
{
|
||||
$this->client = $client;
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_USER")
|
||||
* @Route("/", name="default_index")
|
||||
*/
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('base/index.html.twig', [
|
||||
'template' => Region::getTemplite(),
|
||||
'alias' => '',
|
||||
'title' => 'Личный кабинет'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/doctor-your-home", name="default_doc_your_home")
|
||||
*/
|
||||
public function doctorYourHome(): Response
|
||||
{
|
||||
return $this->render('base/doc_your_home.html.twig', [
|
||||
'template' => Region::getTemplite(),
|
||||
'title' => 'Вызов врача на дом'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/stoimost-uslug", name="default_price")
|
||||
*/
|
||||
public function price(PriceListService $priceListService, PaginatorInterface $paginator, Request $request): Response
|
||||
{
|
||||
$priceList = new PriceList();
|
||||
$searchForm = $this->createForm(PriceListFormType::class, $priceList, [
|
||||
'action' => $this->generateUrl('default_price'),
|
||||
'method' => 'GET',
|
||||
]);
|
||||
|
||||
$searchForm->handleRequest($request);
|
||||
|
||||
$filters = $request->query->get('price_list_form', []);
|
||||
$priceListQuery = $priceListService->getFilteredPriceListQuery($filters);
|
||||
|
||||
$pagination = $paginator->paginate(
|
||||
$priceListQuery->getQuery(),
|
||||
$request->query->getInt('page', 1),
|
||||
50
|
||||
);
|
||||
|
||||
return $this->render('base/price.html.twig', [
|
||||
'title' => 'Стоимость услуг',
|
||||
'template' => Region::getTemplite(),
|
||||
'pagination' => $pagination,
|
||||
'searchForm' => $searchForm->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/update/price-list", name="default_update_price_list", methods={"POST"})
|
||||
*/
|
||||
public function uploadPrice(Request $request): Response
|
||||
{
|
||||
$application = new Application($this->kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$input = new ArrayInput([
|
||||
'command' => 'app:UploadPice',
|
||||
'did' => $request->request->get('groupId'),
|
||||
'--nosleep' => true
|
||||
]);
|
||||
|
||||
// Вы можете использовать NullOutput(), если вам не нужен вывод
|
||||
$output = new BufferedOutput();
|
||||
$application->run($input, $output);
|
||||
|
||||
return $this->json(
|
||||
(strpos($output->fetch(), '[OK] successful') === false)? ['status' => false]: ['status' => true]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/price-list", name="default_price_list")
|
||||
*/
|
||||
public function priceList(
|
||||
PriceListService $priceListService,
|
||||
PriceListRepository $priceListRepository,
|
||||
PaginatorInterface $paginator,
|
||||
Request $request
|
||||
): Response {
|
||||
$priceList = new PriceList();
|
||||
$searchForm = $this->createForm(PriceListAdminFormType::class, $priceList, [
|
||||
'action' => $this->generateUrl('default_price_list'),
|
||||
'method' => 'GET',
|
||||
]);
|
||||
$searchForm->handleRequest($request);
|
||||
|
||||
$params = $request->query->get('default_price_list',[]);
|
||||
|
||||
$priceListQuery = $priceListService->getPriceListQuery($params);
|
||||
$pagination = $paginator->paginate(
|
||||
$priceListQuery->getQuery(),
|
||||
$request->query->getInt('page', 1),
|
||||
50
|
||||
);
|
||||
|
||||
return $this->render('base/price_list.html.twig', [
|
||||
'priceList' => $priceList,
|
||||
'dateActive' => (new \DateTime())->modify('-2 day')->format('Y-m-d 00:00:00'),
|
||||
'title' => 'Сравнение цен',
|
||||
'template' => Region::getTemplite(),
|
||||
'pagination' => $pagination,
|
||||
'searchForm' => $searchForm->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
private function getPricelist($depnum)
|
||||
{
|
||||
$response = [];
|
||||
$flag = true;
|
||||
$firstrow = 1;
|
||||
$lastrow = 500;
|
||||
|
||||
while ($flag) {
|
||||
$result = $this->client->request('GET', 'pricelist/list', [
|
||||
'verify_peer' => false,
|
||||
'verify_host' => false,
|
||||
'base_uri' => 'https://widget.sovamed.ru',
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => 'sovamed_bot'
|
||||
],
|
||||
'query' => [
|
||||
'depnum' => $depnum,
|
||||
'firstrow' => $firstrow,
|
||||
'lastrow' => $lastrow
|
||||
],
|
||||
]);
|
||||
|
||||
$firstrow = $lastrow + 1;
|
||||
$lastrow = $lastrow + 500;
|
||||
$result = $result->toArray();
|
||||
|
||||
if (empty($result['data'])) {
|
||||
$flag = false;
|
||||
} else {
|
||||
$response[] = $result['data'];
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/info", name="default_info")
|
||||
*/
|
||||
public function info(): Response
|
||||
{
|
||||
return $this->render('base/doc.html.twig', [
|
||||
'template' => Region::getTemplite(),
|
||||
'title' => 'Информация'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/help", name="default_help")
|
||||
*/
|
||||
public function help(Request $request): Response
|
||||
{
|
||||
if ($request->getMethod() == 'POST') {
|
||||
$params = $request->request->get('help');
|
||||
$to = 'i.alexandrov@sova.clinic';
|
||||
$subject = $params['team'];
|
||||
$headers = 'From: ' . $params['email'] . "\r\n" .
|
||||
'Reply-To: ' . $params['email'] . "\r\n" .
|
||||
'X-Mailer: PHP/' . phpversion();
|
||||
|
||||
$message = 'ФИО:' . $params['fio'] ."\r\n";
|
||||
$message .= 'Телефон:' . $params['phone'] ."\r\n";
|
||||
$message .= 'Вопрос:' . $params['question'] ."\r\n";
|
||||
|
||||
$message = wordwrap($message, 70, "\r\n");
|
||||
|
||||
if (mail($to, $subject, $message, $headers)) {
|
||||
$this->addFlash(
|
||||
'success',
|
||||
'Спасибо, мы получили Ваше сообщение.'
|
||||
);
|
||||
} else {
|
||||
$this->addFlash(
|
||||
'notice',
|
||||
'Cервис временно не доступен!'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('base/help.html.twig', [
|
||||
'template' => Region::getTemplite(),
|
||||
'title' => 'Помощь'
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Department;
|
||||
use App\Form\DepartmentType;
|
||||
use App\Repository\DepartmentRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/department")
|
||||
*/
|
||||
class DepartmentController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/", name="department_index", methods={"GET"})
|
||||
*/
|
||||
public function index(DepartmentRepository $departmentRepository): Response
|
||||
{
|
||||
return $this->render('department/index.html.twig', [
|
||||
'departments' => $departmentRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}/edit", name="department_edit", methods={"GET","POST"})
|
||||
*/
|
||||
public function edit(Request $request, Department $department): Response
|
||||
{
|
||||
$form = $this->createForm(DepartmentType::class, $department);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('department_index');
|
||||
}
|
||||
|
||||
return $this->render('department/edit.html.twig', [
|
||||
'department' => $department,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Bundle\Infoclinica\Region;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use App\Repository\RecordRepository;
|
||||
use OpenApi\Annotations as OA;
|
||||
use App\Repository\CityRepository;
|
||||
use App\Bundle\Utils\Logger;
|
||||
use App\Bundle\Sms\Manager as SmsManager;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Component\HttpClient\CachingHttpClient;
|
||||
use Symfony\Component\HttpKernel\HttpCache\Store;
|
||||
use App\Repository\DepartmentRepository;
|
||||
use App\Entity\Filial;
|
||||
use App\Repository\SpecialistViewRepository;
|
||||
|
||||
/**
|
||||
* @Route("/api")
|
||||
*/
|
||||
class InternalAPIController extends AbstractController
|
||||
{
|
||||
private $client;
|
||||
private $rootPath = '';
|
||||
|
||||
public function __construct(HttpClientInterface $client, string $rootPath)
|
||||
{
|
||||
$this->rootPath = $rootPath;
|
||||
$store = new Store($rootPath . '/var/HttpClient');
|
||||
$this->client = new CachingHttpClient($client, $store);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/swagger.json", name="public_api_swagger_js")
|
||||
*/
|
||||
public function swaggerJson(): Response
|
||||
{
|
||||
$openapi = \OpenApi\Generator::scan([$this->rootPath . '/src/']);
|
||||
$response = new Response(
|
||||
$openapi->toJson(),
|
||||
Response::HTTP_OK,
|
||||
['content-type' => 'application/json']
|
||||
);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/swagger", name="public_api_swagger")
|
||||
*/
|
||||
public function swaggerUI():response
|
||||
{
|
||||
return $this->render('internal_api/swagger.html.twig', [
|
||||
'title' => 'Open API sovamed'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/smart-captcha", name="public_smart_captcha", methods={"POST"})
|
||||
*/
|
||||
public function smartCaptcha(Request $request):response
|
||||
{
|
||||
$res = $this->client->request('POST', '/validate', [
|
||||
'verify_peer' => false,
|
||||
'verify_host' => false,
|
||||
'base_uri' => 'https://smartcaptcha.yandexcloud.net',
|
||||
'headers' => [
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => 'sovamed_bot',
|
||||
],
|
||||
'query' => [
|
||||
"secret" => $_ENV['SMARTCAPTCHA_SERVER_KEY'],
|
||||
"token" => $request->request->get('smart-token'),
|
||||
"ip" => $_SERVER['REMOTE_ADDR'],
|
||||
]
|
||||
]);
|
||||
|
||||
return $this->json($res->toArray());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/banner/{regionId}", name="banner_show", methods={"GET"})
|
||||
*/
|
||||
public function show($regionId, CityRepository $cityRepository): Response
|
||||
{
|
||||
$banner = $cityRepository->findOneBy(['regionId' => $regionId])->getBanner();
|
||||
$data = [
|
||||
'active' => false,
|
||||
];
|
||||
|
||||
if ($banner) {
|
||||
$data = [
|
||||
'src' => $banner->getSrc(),
|
||||
'href' => $banner->getHref(),
|
||||
'active' => $banner->getActive(),
|
||||
];
|
||||
}
|
||||
|
||||
return $this->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/log", name="api_log", methods={"POST"})
|
||||
*/
|
||||
public function log(Request $request): Response
|
||||
{
|
||||
Logger::send($request->toArray());
|
||||
|
||||
return $this->json(['success' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/count-record", methods={"POST"})
|
||||
*/
|
||||
public function countRecord(RecordRepository $recordRepository, Request $request): Response
|
||||
{
|
||||
$stDate = date('Y-m-d H:00', \time());
|
||||
$enDate = date('Y-m-d H:00', strtotime('+1 hours', time()));
|
||||
|
||||
$count = $recordRepository
|
||||
->createQueryBuilder('r')
|
||||
->select('count(r.id)')
|
||||
->where('r.hash in (:hash)')
|
||||
->andWhere('r.createAt BETWEEN :currentDate AND :nextDate')
|
||||
->setParameter('currentDate', new \DateTime($stDate))
|
||||
->setParameter('nextDate', new \DateTime($enDate))
|
||||
->setParameter('hash', md5($request->request->get('phone')))
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
|
||||
return $this->json(['data' => [
|
||||
'stDate' => $stDate,
|
||||
'enDate' => $enDate,
|
||||
'count' => $count,
|
||||
'hash' => md5($request->request->get('phone')),
|
||||
'phone' => $request->request->get('phone'),
|
||||
]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/add-record", methods={"POST"})
|
||||
*/
|
||||
public function addRecord(Request $request): Response
|
||||
{
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
|
||||
$record = new Record();
|
||||
$record
|
||||
->setSpecialistId((int) $request->request->get('dcode'))
|
||||
->setPhone($request->request->get('phone'))
|
||||
->setHash($request->request->get('phone'))
|
||||
->setCreateAt(new \DateTime('NOW'));
|
||||
|
||||
try {
|
||||
$entityManager->persist($record);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->json(['data' => true]);
|
||||
} catch (Exception $e) {
|
||||
return $this->json(['data' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* https://sms.ru/code/call?phone=79626293193&ip=33.22.11.55&api_id=B58070E1-E89B-95B0-D9BA-37A108868CAF
|
||||
* @Route("/msg", methods={"POST"})
|
||||
*/
|
||||
public function msg(Request $request): Response
|
||||
{
|
||||
return $this->json(['status' => 'OK']);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://sms.ru/code/call?phone=79626293193&ip=33.22.11.55&api_id=B58070E1-E89B-95B0-D9BA-37A108868CAF
|
||||
* @Route("/veretify", methods={"POST"})
|
||||
*/
|
||||
public function veretify(Request $request): Response
|
||||
{
|
||||
$phone = preg_replace( '/[^0-9]/', '', $request->request->get('phone'));
|
||||
$sms = new SmsManager($this->client);
|
||||
$code = rand(1000, 9999);
|
||||
$msg = 'Код: ' . $code . ' для подтверждения. Никому не сообщайте пароль.';
|
||||
|
||||
if (Region::getTemplite() == 'base') {
|
||||
$response = $sms->sendSmsSova($phone, $msg);
|
||||
} else {
|
||||
if ($response = $sms->sendSmsWmt($phone, $msg)) {
|
||||
$response['status'] = "OK";
|
||||
}
|
||||
}
|
||||
|
||||
if ($response['status'] == 'OK' ) {
|
||||
if (! empty($code)) {
|
||||
return $this->json([
|
||||
'status' => 'OK',
|
||||
'code' => base64_encode($code)
|
||||
]);
|
||||
} else {
|
||||
return $this->json(['status' => 'OK']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/search", methods={"POST"})
|
||||
*/
|
||||
public function search(
|
||||
Request $request,
|
||||
SpecialistViewRepository $specialistViewRepository,
|
||||
DepartmentRepository $departmentRepository
|
||||
): Response {
|
||||
$searchType = $request->request->get('type');
|
||||
$searchQuery = $request->request->get('q');
|
||||
|
||||
if ($searchType === 'name') {
|
||||
|
||||
$specialistQuery = $specialistViewRepository->createFilteredQueryBuilder([
|
||||
'name' => $searchQuery,
|
||||
'onlineMode' => $request->request->getInt('onlineMode', 0) === 1,
|
||||
'regionId' => $request->cookies->getInt('region', 0)
|
||||
]);
|
||||
|
||||
$query = $specialistQuery->getQuery();
|
||||
} else {
|
||||
$departmentQuery = $departmentRepository
|
||||
->createQueryBuilder('d')
|
||||
->where('d.name LIKE :name')
|
||||
->setParameter('name', '%' . mb_convert_case($searchQuery, MB_CASE_TITLE, "UTF-8") . '%');
|
||||
|
||||
$query = $departmentQuery->getQuery();
|
||||
}
|
||||
|
||||
return $this->json(['data' => $query->getResult()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/departments", methods={"GET"})
|
||||
*/
|
||||
public function departments(
|
||||
Request $request,
|
||||
DepartmentRepository $departmentRepository
|
||||
): Response {
|
||||
try {
|
||||
$regionId = $request->cookies->getInt('region');
|
||||
$regionId = ($regionId > 0) ? $regionId : null;
|
||||
$kinder = $request->query->getInt('kinder', 0);
|
||||
$kinder = ($kinder == 1) ? 1 : null;
|
||||
|
||||
// Используем ту же логику, что и в форме SpecialistSearchType
|
||||
$qb = $departmentRepository->createQueryBuilder('d')
|
||||
->select('d.did, d.name')
|
||||
->distinct()
|
||||
->innerJoin('App\Entity\LocationView', 'l', 'WITH', 'l.department = d.did AND l.active = true')
|
||||
->innerJoin('App\Entity\SpecialistView', 's', 'WITH', 's.id = l.specialistId AND s.active = true')
|
||||
->leftJoin('App\Entity\Filial', 'f', 'WITH', 'f.fid = l.filial')
|
||||
->where('f.address LIKE :address')
|
||||
->andWhere('d.did <> :did')
|
||||
->setParameter('did', 0)
|
||||
->setParameter('address', '%' . \App\Bundle\Infoclinica\Region::getCurrentName() . '%');
|
||||
|
||||
// Добавляем фильтр по региону, если он указан
|
||||
if ($regionId !== null && $regionId > 0) {
|
||||
$qb->andWhere('s.regionId = :regionId')
|
||||
->setParameter('regionId', $regionId);
|
||||
}
|
||||
|
||||
// Добавляем фильтр по детским специализациям, если выбран "Детский врач"
|
||||
if ($kinder !== null && $kinder == 1) {
|
||||
$qb->andWhere('s.sType = :sType')
|
||||
->setParameter('sType', 1);
|
||||
}
|
||||
// Если "Взрослый врач" или не выбран, показываем все специализации (без фильтра по sType)
|
||||
|
||||
$departments = $qb->orderBy('d.name', 'ASC')
|
||||
->getQuery()
|
||||
->getArrayResult();
|
||||
|
||||
$result = [];
|
||||
foreach ($departments as $department) {
|
||||
$result[] = [
|
||||
'did' => $department['did'],
|
||||
'name' => $department['name']
|
||||
];
|
||||
}
|
||||
|
||||
return $this->json(['data' => $result]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->json([
|
||||
'error' => $e->getMessage(),
|
||||
'data' => []
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Page;
|
||||
use App\Form\PageType;
|
||||
use App\Repository\CategoryPageRepository;
|
||||
use App\Repository\PageRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
||||
|
||||
/**
|
||||
* @Route("/page")
|
||||
*/
|
||||
class PageController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/", name="page_index", methods={"GET"})
|
||||
*/
|
||||
public function index(PageRepository $pageRepository): Response
|
||||
{
|
||||
return $this->render('page/index.html.twig', [
|
||||
'pages' => $pageRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/new", name="page_new", methods={"GET","POST"})
|
||||
*/
|
||||
public function new(Request $request, CategoryPageRepository $categoryPageRepository): Response
|
||||
{
|
||||
$page = new Page();
|
||||
$form = $this->createForm(PageType::class, $page);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$cp = $categoryPageRepository->findOneBy(['id' => $request->request->get('page')['category']]);
|
||||
$page->setCategory($cp);
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->persist($page);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('page_index');
|
||||
}
|
||||
|
||||
return $this->render('page/new.html.twig', [
|
||||
'page' => $page,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{alias}", name="page_show", methods={"GET"})
|
||||
*/
|
||||
public function show(Page $page): Response
|
||||
{
|
||||
return $this->render('page/show.html.twig', [
|
||||
'page' => $page,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/{id}/edit", name="page_edit", methods={"GET","POST"})
|
||||
*/
|
||||
public function edit(Request $request, Page $page): Response
|
||||
{
|
||||
$form = $this->createForm(PageType::class, $page);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('page_index');
|
||||
}
|
||||
|
||||
return $this->render('page/edit.html.twig', [
|
||||
'page' => $page,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/{id}", name="page_delete", methods={"POST"})
|
||||
*/
|
||||
public function delete(Request $request, Page $page): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$page->getId(), $request->request->get('_token'))) {
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->remove($page);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('page_index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,688 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Bundle\Infoclinica\Region;
|
||||
use App\Support\OnlineMode;
|
||||
use App\Entity\Record;
|
||||
use App\Entity\PriceDepartment;
|
||||
use App\Entity\PriceList;
|
||||
use App\Entity\Filial;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use App\Bundle\Utils\Logger;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpClient\CachingHttpClient;
|
||||
use Symfony\Component\HttpKernel\HttpCache\Store;
|
||||
use OpenApi\Annotations as OA;
|
||||
use App\Service\SpecialistService;
|
||||
use App\Service\PriceListService;
|
||||
use Knp\Component\Pager\PaginatorInterface;
|
||||
|
||||
/**
|
||||
* @OA\Info(title="Open API sovamed",
|
||||
* description="Справочник методов доступных в Open API sovamed.",
|
||||
* version="3.0.0"
|
||||
* )
|
||||
*
|
||||
* @OA\Server( url="https://dev.sovamed.ru/api", description="Open API sovamed")
|
||||
*
|
||||
* @Route("/api")
|
||||
*/
|
||||
class PublicAPIController extends AbstractController
|
||||
{
|
||||
private $client;
|
||||
|
||||
public function __construct(HttpClientInterface $client, string $rootPath)
|
||||
{
|
||||
$store = new Store($rootPath . '/var/HttpClient');
|
||||
$this->client = new CachingHttpClient($client, $store);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/anonymous-reserve", methods={"POST"})
|
||||
*/
|
||||
public function anonymousReserve(Request $request): Response
|
||||
{
|
||||
try {
|
||||
$timezone = Region::getTimezone();
|
||||
|
||||
if (!empty($request->request->get('timezone'))) {
|
||||
$timezone = (int) $request->request->get('timezone');
|
||||
}
|
||||
|
||||
$reserve = [
|
||||
'date' => date('Ymd', strtotime($request->request->get('workDate'))),
|
||||
'st' => explode('-', $request->request->get('time'))[0],
|
||||
'en' => explode('-', $request->request->get('time'))[1],
|
||||
'services' => [],
|
||||
'filial' => (int) $request->request->get('filial'),
|
||||
'timezone' => $timezone,
|
||||
'schedident' => (int) $request->request->get('schedident'),
|
||||
'rnum' => $request->request->get('rnum') === 'undefined' ? null : $request->request->get('rnum'),
|
||||
'dcode' => (int) $request->request->get('specialist')
|
||||
];
|
||||
|
||||
$requestData = [
|
||||
'accept' => 'true',
|
||||
'fio' => $request->request->get('fio'),
|
||||
'captcha' => $request->request->get('captcha'),
|
||||
'email' => $request->request->get('email'),
|
||||
'phone' => $request->request->get('phone'),
|
||||
'reserve' => json_encode($reserve, JSON_UNESCAPED_SLASHES)
|
||||
];
|
||||
|
||||
$referer = $request->headers->get('referer');
|
||||
$response = $this->client->request('POST', '/api/reservation/anonymous-reserve', [
|
||||
'verify_peer' => false,
|
||||
'verify_host' => false,
|
||||
'base_uri' => $_ENV['MIS'],
|
||||
'headers' => [
|
||||
'Referer' => $referer,
|
||||
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0',
|
||||
'Accept-Language' => 'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3',
|
||||
'Accept' => 'application/json, text/javascript, */*; q=0.01',
|
||||
'Content-Type' => 'application/json; charset=UTF-8',
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
'X-Integration-Type' => 'WEBSDK'
|
||||
],
|
||||
'body' => json_encode($requestData)
|
||||
]);
|
||||
|
||||
// Проверяем статус ответа
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
if ($statusCode !== 200) {
|
||||
throw new \Exception("External API returned status: {$statusCode}");
|
||||
}
|
||||
|
||||
$intervals = $response->toArray();
|
||||
|
||||
// Сохраняем запись
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$record = new Record();
|
||||
$record
|
||||
->setSpecialistId((int) $request->request->get('specialist'))
|
||||
->setPhone($request->request->get('phone'))
|
||||
->setHash($request->request->get('phone'))
|
||||
->setReserve($reserve)
|
||||
->setCreateAt(new \DateTime('NOW'));
|
||||
|
||||
$entityManager->persist($record);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->json([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'intervals' => $intervals,
|
||||
'hash' => md5($request->request->get('phone')),
|
||||
'phone' => $request->request->get('phone'),
|
||||
'recordId' => $record->getId(),
|
||||
]
|
||||
]);
|
||||
|
||||
} catch (\Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface $e) {
|
||||
// Ошибка 4xx
|
||||
return $this->json([
|
||||
'success' => false,
|
||||
'error' => 'Client error: ' . $e->getMessage()
|
||||
], 400);
|
||||
} catch (\Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface $e) {
|
||||
// Ошибка 5xx
|
||||
return $this->json([
|
||||
'success' => false,
|
||||
'error' => 'Server error: ' . $e->getMessage()
|
||||
], 502);
|
||||
} catch (\Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface $e) {
|
||||
// Ошибки сети
|
||||
return $this->json([
|
||||
'success' => false,
|
||||
'error' => 'Network error: ' . $e->getMessage()
|
||||
], 503);
|
||||
} catch (\Exception $e) {
|
||||
// Другие ошибки
|
||||
return $this->json([
|
||||
'success' => false,
|
||||
'error' => 'Internal error: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* tags= {"Расписание врача"},
|
||||
* path="/interval",
|
||||
* summary="Получение сетки расписания",
|
||||
* @OA\Parameter(
|
||||
* name="startInterval",
|
||||
* description="Начальная дата (Y-m-d)",
|
||||
* in="query",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="string",
|
||||
* format="Y-m-d"
|
||||
*
|
||||
* )
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="endInterval",
|
||||
* description="Конечна дата (Y-m-d)",
|
||||
* in="query",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="string",
|
||||
* format="Y-m-d"
|
||||
*
|
||||
* )
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="department",
|
||||
* description="ID отделения",
|
||||
* in="query",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="string"
|
||||
* )
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="doctor",
|
||||
* description="ID врача",
|
||||
* in="query",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="string"
|
||||
* )
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="filial",
|
||||
* description="ID филиала",
|
||||
* in="query",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="string"
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="json response"
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* @Route("/interval", methods={"GET"})
|
||||
*/
|
||||
public function interval(Request $request): Response
|
||||
{
|
||||
$dateFormat = $request->query->get('dateFormat');
|
||||
|
||||
if (empty($dateFormat)) {
|
||||
$dateFormat = 'Y-m-d';
|
||||
}
|
||||
|
||||
$startInterval = $request->query->get('startInterval');
|
||||
$endInterval = $request->query->get('endInterval');
|
||||
$doctor = $request->query->get('doctor');
|
||||
$department = $request->query->get('department');
|
||||
$filial = $request->query->get('filial');
|
||||
$onlineMode = OnlineMode::isOnline($request->query->get('onlineMode'));
|
||||
$isFree = true;
|
||||
$nearestDate = NULL;
|
||||
|
||||
if (empty($doctor) || empty($startInterval) || empty($endInterval) || empty($department) || empty($filial)) {
|
||||
throw new BadRequestHttpException('Bad request');
|
||||
}
|
||||
|
||||
$schedules = $this->getSchedule($doctor, $department, $filial, $onlineMode, $startInterval, $endInterval);
|
||||
$intervals = $this->getInterval($doctor, $department, $filial, $onlineMode, $startInterval, $endInterval);
|
||||
|
||||
$findInterval = function ($schedident, $workDate) use($intervals, $onlineMode, $isFree, $nearestDate, $dateFormat) {
|
||||
$intervalsData = [];
|
||||
|
||||
if (!empty($intervals)) {
|
||||
foreach ($intervals[date('Ymd', strtotime($workDate))] as $key => $interval) {
|
||||
if ($interval['schedident'] == $schedident) {
|
||||
$intervalsData[$key]['time'] = $interval['time'];
|
||||
$intervalsData[$key]['rNum'] = isset($interval['rNum'])? $interval['rNum']: null;
|
||||
$intervalsData[$key]['startTime'] = explode('-', $interval['time'])[0];
|
||||
$intervalsData[$key]['endTime'] = explode('-', $interval['time'])[1];
|
||||
$intervalsData[$key]['schedident'] = $interval['schedident'];
|
||||
$intervalsData[$key]['isFree'] = $interval['isFree'];
|
||||
$intervalsData[$key]['onlineMode'] = $onlineMode;
|
||||
$intervalsData[$key]['workDate'] = $interval['workDate']->format($dateFormat);
|
||||
|
||||
if ($interval['isFree'] && $isFree && is_null($nearestDate)) {
|
||||
$nearestDate = $interval['workDate']->format('Y-m-d');
|
||||
$intervalsData[$key]['nearestDate'] = $interval['workDate']->format($dateFormat);
|
||||
$isFree = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $intervalsData;
|
||||
};
|
||||
|
||||
$dataResponse = [];
|
||||
$i = 0;
|
||||
|
||||
if (isset($schedules['success'])) {
|
||||
if ($schedules['success'] == true) {
|
||||
$uniqueIntervals = [];
|
||||
|
||||
foreach ($schedules['data'] as $key => $data) {
|
||||
uasort($data['intervals'], function ($a, $b) {
|
||||
if ($a['workDate'] == $b['workDate']) {
|
||||
return $a['startInterval'] <=> $b['startInterval'];
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
foreach($data['intervals'] as $interval) {
|
||||
if ($interval['isFree'] === true) {
|
||||
$workDate = date($dateFormat, strtotime($interval['workDate']));
|
||||
|
||||
$uniqueKey = $interval['schedident']
|
||||
. '-' . $workDate
|
||||
. '-' . $interval['startInterval']
|
||||
. '-' . $interval['endInterval'];
|
||||
|
||||
if (!isset($uniqueIntervals[$uniqueKey])) {
|
||||
$dataIntervals = $findInterval($interval['schedident'], $workDate);
|
||||
if ($dataIntervals) {
|
||||
$uniqueIntervals[$uniqueKey] = [
|
||||
'workDate' => $workDate,
|
||||
'isFree' => $interval['isFree'],
|
||||
'startInterval' => $interval['startInterval'],
|
||||
'endInterval' => $interval['endInterval'],
|
||||
'intervals' => $dataIntervals
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dataResponse = array_values($uniqueIntervals);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$uid = false;
|
||||
|
||||
if (! is_null($this->getUser())) {
|
||||
$uid = $this->getUser()->getUid();
|
||||
}
|
||||
|
||||
return $this->json(['data' => ['userInfo' => $uid, 'intervalsData' => $dataResponse]]);
|
||||
}
|
||||
|
||||
private function getInterval($doctor, $department, $filial, $onlineMode, $startInterval, $endInterval)
|
||||
{
|
||||
$response = $this->client->request('GET', '/api/reservation/intervals', [
|
||||
'verify_peer' => false,
|
||||
'verify_host' => false,
|
||||
'base_uri' => $_ENV['MIS'],
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => 'sovamed_bot'
|
||||
],
|
||||
'query' => [
|
||||
'dcode' => $doctor,
|
||||
'spec' => $department,
|
||||
'onlineMode' => ($onlineMode ? 1 : 0),
|
||||
'st' => \date("Ymd", strtotime($startInterval)),
|
||||
'en' => \date("Ymd", strtotime($endInterval)),
|
||||
'filialId' => $filial,
|
||||
'inFilials' => $filial
|
||||
]
|
||||
]);
|
||||
|
||||
$intervals = $response->toArray();
|
||||
$dataResponse = [];
|
||||
|
||||
if (isset($intervals['data'])) {
|
||||
foreach ($intervals['data'] as $data) {
|
||||
if (isset($data['workdates'])) {
|
||||
foreach ($data['workdates'] as $key => $workdates) {
|
||||
foreach ($workdates as $workdate => $item) {
|
||||
$workDate = \DateTime::createFromFormat(
|
||||
'Ymd',
|
||||
$workdate
|
||||
);
|
||||
|
||||
$intervalKey = 0;
|
||||
|
||||
for ($i=0; $i < count($item); $i++) {
|
||||
foreach ($item[$i]['intervals'] as $intervaldata) {
|
||||
$dataResponse[$workdate][$intervalKey]['workDate'] = $workDate;
|
||||
$dataResponse[$workdate][$intervalKey]['schedident'] = $item[$i]['schedident'];
|
||||
$dataResponse[$workdate][$intervalKey]['time'] = $intervaldata['time'];
|
||||
$dataResponse[$workdate][$intervalKey]['isFree'] = $intervaldata['isFree'];
|
||||
$dataResponse[$workdate][$intervalKey]['rNum'] = isset($item[$i]['rnum'])? $item[$i]['rnum']: null;
|
||||
$intervalKey++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $dataResponse;
|
||||
}
|
||||
|
||||
private function getSchedule($doctor, $department, $filial, $onlineMode, $startInterval, $endInterval)
|
||||
{
|
||||
$response = $this->client->request('GET', '/api/reservation/schedule', [
|
||||
'verify_peer' => false,
|
||||
'verify_host' => false,
|
||||
'base_uri' => $_ENV['MIS'],
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => 'sovamed_bot'
|
||||
],
|
||||
'query' => [
|
||||
'doctor' => $doctor,
|
||||
'department' => $department,
|
||||
'onlineMode' => ($onlineMode ? 1 : 0),
|
||||
'st' => date("Ymd", strtotime($startInterval)),
|
||||
'en' => date("Ymd", strtotime($endInterval)),
|
||||
'filialId' => $filial
|
||||
]
|
||||
]);
|
||||
|
||||
return $response->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/userInfo", methods={"GET"})
|
||||
*/
|
||||
public function user(): Response
|
||||
{
|
||||
$uid = false;
|
||||
|
||||
if (! is_null($this->getUser())) {
|
||||
$uid = $this->getUser()->getUid();
|
||||
}
|
||||
|
||||
return $this->json(['data' => $uid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* tags= {"Услуги и цены"},
|
||||
* path="/pricelist/departments",
|
||||
* summary="Получение списка отделений",
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="json response"
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* @Route("/pricelist/departments", methods={"GET"})
|
||||
*/
|
||||
public function pricelistDepartments(Request $request): Response
|
||||
{
|
||||
$response = [];
|
||||
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$departments = $entityManager->getRepository(PriceDepartment::class)
|
||||
->findAll();
|
||||
|
||||
if ($departments) {
|
||||
foreach ($departments as $key => $item) {
|
||||
$item = $item->toArray();
|
||||
|
||||
unset($item['__initializer__']);
|
||||
unset($item['__isInitialized__']);
|
||||
unset($item['__cloner__']);
|
||||
unset($item['id']);
|
||||
$response[$key] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->json(['data' => $response]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* tags= {"Услуги и цены"},
|
||||
* path="/pricelist",
|
||||
* summary="Получение списка услуг и цен",
|
||||
* @OA\Parameter(
|
||||
* name="depnum",
|
||||
* description="ID отделения",
|
||||
* in="query",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="string"
|
||||
* )
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="filial",
|
||||
* description="ID филиала",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(
|
||||
* type="string"
|
||||
* )
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="active",
|
||||
* description="Только активные",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(
|
||||
* type="boolean"
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="json response"
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* @Route("/pricelist", methods={"GET"})
|
||||
*/
|
||||
public function pricelist(Request $request, PaginatorInterface $paginator, PriceListService $priceListService): JsonResponse
|
||||
{
|
||||
$params = [
|
||||
'kodoper' => $request->query->get('kodoper'),
|
||||
'groupId' => $request->query->get('depnum'),
|
||||
'filial' => $request->query->get('filial'),
|
||||
'actual' => $request->query->get('active')
|
||||
];
|
||||
|
||||
$priceListQuery = $priceListService->getPriceListQuery($params);
|
||||
|
||||
$pagination = $paginator->paginate(
|
||||
$priceListQuery->getQuery(),
|
||||
$request->query->getInt('page', 1),
|
||||
1000
|
||||
);
|
||||
|
||||
$totalItems = $pagination->getTotalItemCount(); // Общее количество элементов
|
||||
$itemCount = $pagination->count(); // Количество элементов на текущей странице
|
||||
$currentPage = $pagination->getCurrentPageNumber(); // Текущая страница
|
||||
$totalPages = ceil($totalItems / 1000); // Общее количество страниц
|
||||
|
||||
return $this->json([
|
||||
'items' => $pagination,
|
||||
'totalItems' => $totalItems,
|
||||
'totalPages' => $totalPages,
|
||||
'currentPage' => $currentPage,
|
||||
'itemCount' => $itemCount
|
||||
]);
|
||||
}
|
||||
|
||||
private function getSpecialistResponse($specialist)
|
||||
{
|
||||
$response = [];
|
||||
|
||||
if ($specialist) {
|
||||
$response = $specialist->toArray();
|
||||
|
||||
unset($response['pecialistMore']);
|
||||
|
||||
$response['img'] = 'https://api.sovamed.ru/specialist/picture/' . $specialist->getId();
|
||||
|
||||
if (!empty($response['kinder'])) {
|
||||
$response['kinder'] = $response['kinder'] . ' ' . $this->textYear($response['kinder'], false);
|
||||
}
|
||||
|
||||
if (!empty($response['experience'])) {
|
||||
$response['experience'] = $response['experience'] . ' ' . $this->textYear($response['experience'], true);
|
||||
}
|
||||
|
||||
$specialistMore = $specialist->getSpecialistMore();
|
||||
|
||||
if ($defaultLocation = $specialistMore->defaultLocation()) {
|
||||
$response['nearestDate'] = $defaultLocation['nearestDate'];
|
||||
$response['filial'] = [
|
||||
'id' => $defaultLocation['filial'],
|
||||
'address' => $defaultLocation['address'],
|
||||
];
|
||||
$response['department'] = [
|
||||
'id' => $defaultLocation['department'],
|
||||
'name' => $defaultLocation['name'],
|
||||
];
|
||||
}
|
||||
|
||||
$response['reviews'] = $specialistMore->getReviews();
|
||||
$response['prices'] = $specialistMore->getPrices();
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
private function textYear($year, $exp = true)
|
||||
{
|
||||
$t1 = 0;
|
||||
$t2 = 0;
|
||||
$year = abs($year);
|
||||
$t1 = $year % 10;
|
||||
$t2 = $year % 100;
|
||||
if ($exp) {
|
||||
return ($t1 == 1 && $t2 != 11 ? "год" : ($t1 >= 2 && $t1 <= 4 && ($t2 < 10 || $t2 >= 20) ? "года" : "лет"));
|
||||
} else {
|
||||
return ($t1 == 1 ? "года" : "лет");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* tags= {"Врачи"},
|
||||
* path="/doctor",
|
||||
* summary="Получение данных о враче",
|
||||
* @OA\Parameter(
|
||||
* name="sid",
|
||||
* description="ID врача",
|
||||
* in="query",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="string"
|
||||
* )
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="reviews",
|
||||
* description="Показывать отзывы",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(
|
||||
* type="boolean",
|
||||
* default=false
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="json response"
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* @Route("/doctor", methods={"GET"})
|
||||
*/
|
||||
public function doctor(SpecialistService $specialistService, Request $request): Response
|
||||
{
|
||||
if (empty($request->query->getInt('sid'))) {
|
||||
return $this->json(['data' => false]);
|
||||
}
|
||||
|
||||
$specialist = $specialistService->show([
|
||||
'dcode' => $request->query->get('sid')
|
||||
]);
|
||||
|
||||
return $this->json(['data' => $this->getSpecialistResponse($specialist)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* tags= {"Врачи"},
|
||||
* path="/doctors/{region}",
|
||||
* summary="Получение данных врачей по регионам",
|
||||
* @OA\Parameter(
|
||||
* name="region",
|
||||
* description="Название города",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="string",
|
||||
* default="saratov"
|
||||
* )
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="reviews",
|
||||
* description="Показывать отзывы",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(
|
||||
* type="boolean",
|
||||
* default=true
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="json response"
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* @Route("/doctors/{region}", methods={"GET"})
|
||||
*/
|
||||
public function index(SpecialistService $specialistService, Request $request, $region = 'saratov'): Response
|
||||
{
|
||||
$regionId = match($region) {
|
||||
'krasnodar' => 94,
|
||||
'voronej' => 93,
|
||||
'volgograd' => 92,
|
||||
default => 91
|
||||
};
|
||||
|
||||
$pagination = $specialistService->listPaginated(
|
||||
['regionId' => $regionId],
|
||||
$request->query->getInt('page', 1),
|
||||
500
|
||||
);
|
||||
|
||||
$totalItems = $pagination->getTotalItemCount(); // Общее количество элементов
|
||||
$itemCount = $pagination->count(); // Количество элементов на текущей странице
|
||||
$currentPage = $pagination->getCurrentPageNumber(); // Текущая страница
|
||||
$totalPages = ceil($totalItems / 1000); // Общее количество страниц
|
||||
|
||||
$response = [];
|
||||
|
||||
foreach ($pagination as $key => $specialist) {
|
||||
$response[$key] = $this->getSpecialistResponse($specialist);
|
||||
}
|
||||
|
||||
return $this->json([
|
||||
'data' => $response,
|
||||
'totalItems' => $totalItems,
|
||||
'totalPages' => $totalPages,
|
||||
'currentPage' => $currentPage,
|
||||
'itemCount' => $itemCount
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\ReviewSource;
|
||||
use App\Form\ReviewSourceType;
|
||||
use App\Repository\ReviewSourceRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("admin/review_source")
|
||||
*/
|
||||
class ReviewSourceController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/", name="app_review_source_index", methods={"GET"})
|
||||
*/
|
||||
public function index(ReviewSourceRepository $reviewSourceRepository): Response
|
||||
{
|
||||
return $this->render('review_source/index.html.twig', [
|
||||
'review_sources' => $reviewSourceRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/new", name="app_review_source_new", methods={"GET", "POST"})
|
||||
*/
|
||||
public function new(Request $request, ReviewSourceRepository $reviewSourceRepository): Response
|
||||
{
|
||||
$reviewSource = new ReviewSource();
|
||||
$form = $this->createForm(ReviewSourceType::class, $reviewSource);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$reviewSourceRepository->add($reviewSource);
|
||||
return $this->redirectToRoute('app_review_source_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->render('review_source/new.html.twig', [
|
||||
'review_source' => $reviewSource,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}/edit", name="app_review_source_edit", methods={"GET", "POST"})
|
||||
*/
|
||||
public function edit(Request $request, ReviewSource $reviewSource, ReviewSourceRepository $reviewSourceRepository): Response
|
||||
{
|
||||
$form = $this->createForm(ReviewSourceType::class, $reviewSource);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$reviewSourceRepository->add($reviewSource);
|
||||
return $this->redirectToRoute('app_review_source_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->render('review_source/edit.html.twig', [
|
||||
'review_source' => $reviewSource,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="app_review_source_delete", methods={"POST"})
|
||||
*/
|
||||
public function delete(Request $request, ReviewSource $reviewSource, ReviewSourceRepository $reviewSourceRepository): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$reviewSource->getId(), $request->request->get('_token'))) {
|
||||
$reviewSourceRepository->remove($reviewSource);
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_review_source_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,405 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Bundle\Infoclinica\Region;
|
||||
use App\Bundle\Infoclinica\Rest;
|
||||
use App\Form\RegistrationFormType;
|
||||
use App\Form\SettingType;
|
||||
use App\Form\RefundType;
|
||||
use App\Repository\UsrlogRepository;
|
||||
use App\Entity\Usrlog;
|
||||
use App\Security\LoginFormAuthenticator;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
use Symfony\Component\Security\Csrf\CsrfToken;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
||||
|
||||
class SecurityController extends AbstractController
|
||||
{
|
||||
public function __construct(CsrfTokenManagerInterface $csrfTokenManager, UserPasswordEncoderInterface $passwordEncoder)
|
||||
{
|
||||
$this->csrfTokenManager = $csrfTokenManager;
|
||||
$this->passwordEncoder = $passwordEncoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_USER")
|
||||
* @Route("/refund", name="security_refund", methods={"GET", "POST"})
|
||||
*/
|
||||
public function refund(Request $request): Response
|
||||
{
|
||||
$refundForm = new RefundType();
|
||||
$form = $this->createForm(RefundType::class, $refundForm);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
if ($request->request->get('filial') == 3) {
|
||||
$to = 'info.mmc@sova.clinic, i.cherednichenko@sova.clinic, y.belova@sova.clinic';
|
||||
$company_name = 'АО «Многопрофильный медицинский центр»';
|
||||
$company_director = 'Бушеневой С.Н.';
|
||||
$to_mail = 'vozvrat-vlg@sova.clinic';
|
||||
} else {
|
||||
$to = 'i.cherednichenko@sova.clinic, v.karpova@sova.clinic, n.ermakova@sova.clinic';
|
||||
$company_name = 'АО «МЛДК»';
|
||||
$company_director = 'Бурлаковой Н.Ф.';
|
||||
$to_mail = 'vozvrat@sova.clinic';
|
||||
}
|
||||
|
||||
$subject = "Пациент сформировал заявление на возврат средств по онлайн консультации";
|
||||
$headers = 'From: ' . $request->request->get('email') . "\r\n" .
|
||||
'Reply-To: ' . $request->request->get('email') . "\r\n" .
|
||||
'X-Mailer: PHP/' . phpversion();
|
||||
$message = "Здравствуйте. Пациент сформировал заявление на возврат средств по онлайн консультации. Ожидаем отправки заявления с почты пациента.\r\n Данные по консультации:\r\n";
|
||||
$message .= 'ФИО пациента:' . $form->get('fio')->getData() ."\r\n";
|
||||
$message .= 'Телефон пациента:' . $request->request->get('phone') ."\r\n";
|
||||
$message .= 'Врач:' . $request->request->get('docName') ."\r\n";
|
||||
$message .= 'Индификатор записи:' . $request->request->get('schedident') ."\r\n";
|
||||
$message .= 'Сумма возврата:' . $form->get('sum')->getData() ."\r\n";
|
||||
$message .= 'Дата платежа:' . $form->get('refund_date')->getData()->format('d.m.Y') ."\r\n";
|
||||
|
||||
mail($to, $subject, $message, $headers);
|
||||
|
||||
$html = $this->render('security/refund_blank.html.twig', [
|
||||
'template' => Region::getTemplite(),
|
||||
'to_email' => $to_mail,
|
||||
'title' => 'Заявление на возврат',
|
||||
'company_name' => $company_name,
|
||||
'company_director' => $company_director,
|
||||
'address' => $request->request->get('address'),
|
||||
'phone' => $request->request->get('phone'),
|
||||
'email' => $request->request->get('email'),
|
||||
'current_date' => \date('Y-m-d'),
|
||||
'fio' => $form->get('fio')->getData(),
|
||||
'passport_serial' => explode(' ', $form->get('passport_serial')->getData())[0],
|
||||
'passport_number' => explode(' ', $form->get('passport_serial')->getData())[1],
|
||||
'passport_issued' => $form->get('passport_issued')->getData(),
|
||||
'passport_date' => $form->get('passport_date')->getData()->format('d.m.Y'),
|
||||
'refund_bases' => $form->get('refund_bases')->getData(),
|
||||
'sum' => $form->get('sum')->getData(),
|
||||
'refund_date' => $form->get('refund_date')->getData()->format('d.m.Y')
|
||||
]);
|
||||
|
||||
$mpdf = new \Mpdf\Mpdf();
|
||||
$mpdf->WriteHTML($html);
|
||||
$mpdf->Output();
|
||||
}
|
||||
|
||||
return $this->render('security/refund_form.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_USER")
|
||||
* @Route("/case-history", name="security_case_history")
|
||||
*/
|
||||
public function case_history(): Response
|
||||
{
|
||||
return $this->render('security/case_history.html.twig', [
|
||||
'template' => Region::getTemplite(),
|
||||
'title' => 'Приемы'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_USER")
|
||||
* @Route("/referrals", name="security_referrals")
|
||||
*/
|
||||
public function referrals(): Response
|
||||
{
|
||||
$referrals = [];
|
||||
|
||||
return $this->render('security/referrals.html.twig', [
|
||||
'referrals' => $referrals,
|
||||
'template' => Region::getTemplite(),
|
||||
'title' => 'Результаты анализов',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_USER")
|
||||
* @Route("/security-card", name="security_card")
|
||||
*/
|
||||
public function securityCard(): Response
|
||||
{
|
||||
return $this->render('security/card.html.twig', [
|
||||
'template' => Region::getTemplite(),
|
||||
'title' => 'Медицинская карта',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_USER")
|
||||
* @Route("/payment", name="security_payment")
|
||||
*/
|
||||
public function payment(): Response
|
||||
{
|
||||
return $this->render('security/payment.html.twig', [
|
||||
'template' => Region::getTemplite(),
|
||||
'title' => 'Финансы',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_USER")
|
||||
* @Route("/setting", name="security_setting")
|
||||
*/
|
||||
public function setting(
|
||||
Request $request,
|
||||
UserPasswordEncoderInterface $passwordEncoder
|
||||
): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
$form = $this->createForm(SettingType::class, $user);
|
||||
$form->handleRequest($request);
|
||||
$response = [];
|
||||
|
||||
if ($request->getMethod() == 'POST') {
|
||||
|
||||
$user->setToken($form->get('plainPassword')->getData());
|
||||
$user->setPassword(
|
||||
$passwordEncoder->encodePassword(
|
||||
$user,
|
||||
$form->get('plainPassword')->getData()
|
||||
)
|
||||
);
|
||||
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
|
||||
|
||||
return $this->json([
|
||||
'success' => true,
|
||||
'redirect' => '/'
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render('security/setting.html.twig', [
|
||||
'template' => Region::getTemplite(),
|
||||
'form' => $form->createView(),
|
||||
'setting' => $response,
|
||||
'title' => 'Настройки',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/login", name="security_login")
|
||||
*/
|
||||
public function login(Request $request, AuthenticationUtils $authenticationUtils): Response
|
||||
{
|
||||
$template = preg_match('/sovamed\.ru/m', $request->getHost())? 'login' : 'login_wmtmed';
|
||||
|
||||
return $this->render('security/' . $template . '.html.twig', [
|
||||
'template' => Region::getTemplite(),
|
||||
'alias' => null,
|
||||
'last_username' => $authenticationUtils->getLastUsername(),
|
||||
'error' => $authenticationUtils->getLastAuthenticationError(),
|
||||
'title' => 'Личный кабинет - «СОВА»'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/logout", name="security_logout")
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/usrlog/logout", name="security_usrlog_logout", methods={"POST"})
|
||||
*/
|
||||
public function usrlogLogout(Request $request, UsrlogRepository $usrlogRepository): Response
|
||||
{
|
||||
$pcode = null;
|
||||
$user = $this->getUser();
|
||||
|
||||
if ($user instanceof User) {
|
||||
$pcode = (string) $user->getUid();
|
||||
} else {
|
||||
$pcode = trim((string) $request->request->get('pcode', ''));
|
||||
}
|
||||
|
||||
if ($pcode === '') {
|
||||
return $this->json(['success' => false, 'message' => 'pcode is required'], 400);
|
||||
}
|
||||
|
||||
$usrlog = new Usrlog();
|
||||
$usrlog
|
||||
->setPcode($pcode)
|
||||
->setAgent((string) ($request->headers->get('User-Agent') ?? 'unknown'))
|
||||
->setClientIp((string) ($request->getClientIp() ?? 'unknown'))
|
||||
->setMethod('выход')
|
||||
;
|
||||
|
||||
$usrlogRepository->add($usrlog);
|
||||
|
||||
return $this->json(['success' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/registration", name="security_reg", methods={"GET","POST"})
|
||||
*/
|
||||
public function registration(
|
||||
Request $request,
|
||||
UserPasswordEncoderInterface $passwordEncoder
|
||||
): Response
|
||||
{
|
||||
$user = new User();
|
||||
$form = $this->createForm(RegistrationFormType::class, $user);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$fullName = $form->get('firstName')->getData();
|
||||
$fullName .= ' ';
|
||||
$fullName .= $form->get('middleName')->getData();
|
||||
$user->setFullName($fullName);
|
||||
$user->setToken($form->get('plainPassword')->getData());
|
||||
$user->setRoles(['ROLE_USER']);
|
||||
$user->setConfirm(0);
|
||||
$user->setPassword(
|
||||
$passwordEncoder->encodePassword(
|
||||
$user,
|
||||
$form->get('plainPassword')->getData()
|
||||
)
|
||||
);
|
||||
|
||||
$infoclinica = new Rest();
|
||||
$response = $infoclinica->register($request->request->all());
|
||||
|
||||
if ($response['response']['success'] == true) {
|
||||
$user->setUid(date('U'));
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('security_confirm', [
|
||||
'id' => $user->getId(),
|
||||
'rToken' => $response['response']['data']['rToken']
|
||||
]);
|
||||
} else {
|
||||
$this->addFlash(
|
||||
'notice',
|
||||
$response['response']['data']['message'] ?? 'Cервис временно не доступен!'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('security/register.html.twig', [
|
||||
'title' => 'Регистрация',
|
||||
'template' => Region::getTemplite(),
|
||||
'form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/forget", name="security_forget", methods={"POST"})
|
||||
*/
|
||||
public function forget(Request $request, UserPasswordEncoderInterface $passwordEncoder)
|
||||
{
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$email = false;
|
||||
$uid = $request->request->get('uid');
|
||||
|
||||
if ($email = $request->request->get('login')) {
|
||||
$user = $entityManager->getRepository(User::class)
|
||||
->findOneBy(['email' => \bin2hex($email)]);
|
||||
|
||||
if ($user) {
|
||||
$uid = $user->getUid();
|
||||
}
|
||||
|
||||
return $this->json(['uid' => $uid]);
|
||||
};
|
||||
|
||||
$password = $request->request->get('password');
|
||||
|
||||
if ($uid && $password) {
|
||||
$user = $entityManager->getRepository(User::class)
|
||||
->findOneBy(['uid' => $uid]);
|
||||
|
||||
if (!$user) {
|
||||
$user = new User();
|
||||
}
|
||||
|
||||
$user->setUid($uid);
|
||||
$user->setToken($password);
|
||||
$user->setPassword(
|
||||
$passwordEncoder->encodePassword(
|
||||
$user,
|
||||
$password
|
||||
)
|
||||
);
|
||||
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->json([
|
||||
'success' => true,
|
||||
'redirect' => '/login'
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->json([
|
||||
'success' => false,
|
||||
'uid' => $uid
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/authenticated", name="security_authenticated", methods={"POST"})
|
||||
*/
|
||||
public function authenticated(Request $request,
|
||||
GuardAuthenticatorHandler $guardHandler,
|
||||
LoginFormAuthenticator $authenticator,
|
||||
UserPasswordEncoderInterface $passwordEncoder
|
||||
): Response {
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$userData = $request->request->get('user');
|
||||
|
||||
$user = $entityManager->getRepository(User::class)
|
||||
->findOneBy(['uid' => $userData['id']]);
|
||||
|
||||
if (!$user && $userData) {
|
||||
$user = new User();
|
||||
|
||||
$user
|
||||
->setFullName($userData['fullName'])
|
||||
->setEmail($userData['email'])
|
||||
->setPhone($userData['phone'])
|
||||
->setUid($userData['id'])
|
||||
->setConfirm(1)
|
||||
->setRoles(['ROLE_USER'])
|
||||
->setToken($userData['id'])
|
||||
->setPassword(
|
||||
$passwordEncoder->encodePassword(
|
||||
$user,
|
||||
$userData['id']
|
||||
)
|
||||
);
|
||||
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
$entityManager->clear();
|
||||
}
|
||||
|
||||
return $guardHandler->authenticateUserAndHandleSuccess(
|
||||
$user,
|
||||
$request,
|
||||
$authenticator,
|
||||
'main'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Service\SpecialistService;
|
||||
use App\Entity\SpecialistView;
|
||||
use App\Bundle\Infoclinica\Region;
|
||||
use App\Bundle\Bitrix\Request as Bitrix;
|
||||
use App\Form\SpecialistSearchType;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
||||
|
||||
class SpecialistController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/filter", name="specialist_filter", methods={"GET"})
|
||||
*/
|
||||
public function filter(Request $request): Response
|
||||
{
|
||||
$regionId = $request->cookies->getInt('region');
|
||||
$regionId = ($regionId > 0) ? $regionId : null;
|
||||
|
||||
// Получаем значение kinder из запроса для фильтрации специализаций
|
||||
$kinder = $request->query->get('specialist_search')['kinder'] ?? null;
|
||||
$kinder = ($kinder == 1) ? 1 : null;
|
||||
|
||||
$searchForm = $this->createForm(SpecialistSearchType::class, new SpecialistView(), [
|
||||
'action' => $this->generateUrl('specialist_index'),
|
||||
'method' => 'GET',
|
||||
'regionId' => $regionId,
|
||||
'kinder' => $kinder,
|
||||
]);
|
||||
|
||||
$searchForm->handleRequest($request);
|
||||
|
||||
return $this->render('specialist/_search_form.html.twig', [
|
||||
'searchForm' => $searchForm->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/specialists/{alias?}", name="specialist_index", methods={"GET"})
|
||||
*/
|
||||
public function index(
|
||||
SpecialistService $specialistService,
|
||||
Request $request,
|
||||
string $alias = null
|
||||
): Response {
|
||||
$regionId = $request->cookies->getInt('region');
|
||||
$regionId = ($regionId > 0) ? $regionId : null;
|
||||
|
||||
// Получаем значение kinder из запроса для фильтрации специализаций
|
||||
$kinder = $request->query->get('specialist_search')['kinder'] ?? null;
|
||||
$kinder = ($kinder == 1) ? 1 : null;
|
||||
|
||||
$searchForm = $this->createForm(SpecialistSearchType::class, new SpecialistView(), [
|
||||
'action' => $this->generateUrl('specialist_index', ['alias' => $alias]),
|
||||
'method' => 'GET',
|
||||
'regionId' => $regionId,
|
||||
'kinder' => $kinder,
|
||||
]);
|
||||
|
||||
$searchForm->handleRequest($request);
|
||||
|
||||
$page = $request->query->getInt('page', 1);
|
||||
|
||||
$filters = $request->query->get('specialist_search', ['onlineMode' => 0]);
|
||||
$filters['depAlias'] = $alias;
|
||||
|
||||
if ($regionId > 0) {
|
||||
$filters['regionId'] = $regionId;
|
||||
}
|
||||
|
||||
$pagination = $specialistService->listPaginated($filters, $page, 10);
|
||||
$view = 'specialist/index.html.twig';
|
||||
|
||||
if (Region::getTemplite() == 'krasnodar_base') {
|
||||
$view = 'specialist/krasnodar_index.html.twig';
|
||||
}
|
||||
|
||||
if (! empty($request->query->get('specialist_search')['current_date'])) {
|
||||
$currentDate = $request->query->get('specialist_search')['current_date'];
|
||||
$dates = explode('-', $currentDate);
|
||||
$startInterval = $dates[0];
|
||||
$endInterval = $dates[1];
|
||||
} else {
|
||||
$startInterval = date("Y-m-d");
|
||||
$endInterval = date("Y-m-d", strtotime('+7 day'));
|
||||
}
|
||||
|
||||
return $this->render($view, [
|
||||
'title' => 'Врачи',
|
||||
'alias' => $alias,
|
||||
'template' => Region::getTemplite(),
|
||||
'pagination' => $pagination,
|
||||
'searchForm' => $searchForm->createView(),
|
||||
'st' => $startInterval,
|
||||
'en' => $endInterval
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_USER")
|
||||
* @Route("/online-specialists", name="specialist_online_index", methods={"GET"})
|
||||
*/
|
||||
public function onlineIndex(
|
||||
SpecialistService $specialistService,
|
||||
Request $request
|
||||
): Response {
|
||||
$regionId = $request->cookies->getInt('region');
|
||||
$regionId = ($regionId > 0) ? $regionId : null;
|
||||
|
||||
// Получаем значение kinder из запроса для фильтрации специализаций
|
||||
$kinder = $request->query->get('specialist_search')['kinder'] ?? null;
|
||||
$kinder = ($kinder == 1) ? 1 : null;
|
||||
|
||||
$searchForm = $this->createForm(SpecialistSearchType::class, new SpecialistView(), [
|
||||
'action' => $this->generateUrl('specialist_online_index'),
|
||||
'method' => 'GET',
|
||||
'regionId' => $regionId,
|
||||
'kinder' => $kinder,
|
||||
]);
|
||||
|
||||
$searchForm->handleRequest($request);
|
||||
|
||||
$filters = $request->query->get('specialist_search', ['onlineMode' => 1]);
|
||||
$filters['onlineMode'] = 1;
|
||||
|
||||
if ($regionId > 0) {
|
||||
$filters['regionId'] = $regionId;
|
||||
}
|
||||
|
||||
$page = $request->query->getInt('page', 1);
|
||||
|
||||
$pagination = $specialistService->listPaginated($filters, $page, 10);
|
||||
|
||||
$view = 'specialist/index.html.twig';
|
||||
|
||||
if (Region::getTemplite() == 'krasnodar_base') {
|
||||
$view = 'specialist/krasnodar_index.html.twig';
|
||||
}
|
||||
|
||||
if (! empty($request->query->get('specialist_search')['current_date'])) {
|
||||
$currentDate = $request->query->get('specialist_search')['current_date'];
|
||||
$dates = explode('-', $currentDate);
|
||||
$startInterval = $dates[0];
|
||||
$endInterval = $dates[1];
|
||||
} else {
|
||||
$startInterval = date("Y-m-d");
|
||||
$endInterval = date("Y-m-d", strtotime('+7 day'));
|
||||
}
|
||||
|
||||
return $this->render($view, [
|
||||
'title' => 'Онлайн консультация',
|
||||
'template' => Region::getTemplite(),
|
||||
'pagination' => $pagination,
|
||||
'searchForm' => $searchForm->createView(),
|
||||
'st' => $startInterval,
|
||||
'en' => $endInterval
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/specialist/{alias}", name="specialist_show", methods={"GET"})
|
||||
*/
|
||||
public function show(
|
||||
SpecialistService $specialistService,
|
||||
Request $request,
|
||||
string $alias
|
||||
): Response {
|
||||
$filters = $request->query->get('specialist_search', ['onlineMode' => 0]);
|
||||
// $filters['regionId'] = $request->cookies->getInt('region');
|
||||
$filters['alias'] = $alias;
|
||||
|
||||
$specialist = $specialistService->show($filters);
|
||||
|
||||
if ($specialist) {
|
||||
$specialistMoreService = $specialist->getSpecialistMore();
|
||||
|
||||
if ($defaultLocation = $specialistMoreService->defaultLocation()) {
|
||||
return $this->render('specialist/show.html.twig', [
|
||||
'title' => 'Врач',
|
||||
'st' => date("Y-m-d"),
|
||||
'en' => date("Y-m-d", strtotime('+7 day')),
|
||||
'template' => Region::getTemplite(),
|
||||
'specialist' => $specialist,
|
||||
'specialistMore' => $specialistMoreService,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
throw $this->createNotFoundException('The page does not exist');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/favorites", name="default_favorites")
|
||||
*/
|
||||
public function favorites(SpecialistService $specialistService, Request $request): Response
|
||||
{
|
||||
$page = $request->query->getInt('page', 1);
|
||||
$filters['dcode'] = explode(',', $request->query->get('q'));
|
||||
|
||||
$pagination = $specialistService->listPaginated($filters, $page, 10);
|
||||
|
||||
return $this->render('base/favorites.html.twig', [
|
||||
'st' => date("Y-m-d"),
|
||||
'en' => date("Y-m-d", strtotime('+7 day')),
|
||||
'pagination' => $pagination,
|
||||
'template' => Region::getTemplite(),
|
||||
'title' => 'Избранное'
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Filial;
|
||||
use App\Repository\FilialRepository;
|
||||
use App\Entity\AlertSms;
|
||||
use App\Repository\SpecialistViewRepository as SpecialistRepository;
|
||||
use App\Repository\ReviewSourceRepository;
|
||||
use App\Repository\LocationViewRepository as LocationRepository;
|
||||
use App\Repository\RecordRepository;
|
||||
use App\Entity\User;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use App\Form\ReferenceType;
|
||||
use App\Bundle\Infoclinica\Region;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use App\Bundle\Utils\Logger;
|
||||
use App\Bundle\Sms\Manager as SmsManager;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use App\Service\SpecialistService;
|
||||
|
||||
/**
|
||||
* @Route("/widget")
|
||||
*/
|
||||
class WidgetController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/review_source/{cityId}", name="widget_review_source", methods={"GET"})
|
||||
*/
|
||||
public function reviewSource(ReviewSourceRepository $reviewSourceRepository, $cityId): Response
|
||||
{
|
||||
$reviewSources = [];
|
||||
|
||||
foreach ($reviewSourceRepository->findByCity($cityId) as $key => $reviewSource) {
|
||||
$reviewSources[$key] = $reviewSource;
|
||||
$reviewSources[$key]['isFloat'] = true;
|
||||
$f = (float) $reviewSource['rating_total'];
|
||||
|
||||
if (strpos($reviewSource['rating_total'], '.') === false) {
|
||||
$reviewSources[$key]['isFloat'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('widget/review_source.html.twig', [
|
||||
'reviewSources' => $reviewSources,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/reference", name="widget_reference")
|
||||
*/
|
||||
public function reference(Request $request): Response
|
||||
{
|
||||
$ref = $request->query->get('ref', '');
|
||||
$regionId = match (base64_decode($ref, strict: true)) {
|
||||
'https://volgograd.sovamed.ru' => 92,
|
||||
'https://voronezh.sovamed.ru' => 93,
|
||||
'https://wmtmed.ru' => 94,
|
||||
default => 91,
|
||||
};
|
||||
|
||||
$isAuthorized = $this->isGranted('ROLE_USER');
|
||||
|
||||
$referenceForm = $this->createForm(ReferenceType::class, new User, [
|
||||
'method' => 'GET',
|
||||
'isAuthorized' => $isAuthorized,
|
||||
]);
|
||||
|
||||
return $this->render('widget/reference.html.twig', [
|
||||
'regionId' => $regionId,
|
||||
'referenceForm' => $referenceForm->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/check/{hash}/{id}", name="widget_check", methods={"GET"})
|
||||
*/
|
||||
public function check(
|
||||
RecordRepository $recordRepository,
|
||||
FilialRepository $filialRepository,
|
||||
HttpClientInterface $client,
|
||||
SpecialistService $specialistService,
|
||||
$hash,
|
||||
$id
|
||||
): Response {
|
||||
$record = $recordRepository->findOneBy(['hash' => $hash, 'id' => $id]);
|
||||
|
||||
if ($record) {
|
||||
$reserve = $record->getReserve();
|
||||
$reserve['date'] = \date('d-m-Y', strtotime($reserve['date']));
|
||||
|
||||
$sms = new SmsManager($client);
|
||||
$msg = 'Ждем Вас: ';
|
||||
|
||||
$filial = $filialRepository->findOneBy(['fid' => $reserve['filial']]);
|
||||
|
||||
if ($filial) $msg .= $filial->getName() . ' ';
|
||||
|
||||
$msg .= $reserve['date'] . ' в '. $reserve['st'];
|
||||
|
||||
if (Region::getTemplite() == 'base') {
|
||||
if (!$record->getAlertSms()) {
|
||||
$response = $sms->sendSmsSova($record->getPhone(), $msg);
|
||||
|
||||
$alertSms = new AlertSms();
|
||||
$alertSms
|
||||
->setDateCreate(new \DateTime())
|
||||
->setResponse(json_encode($response, JSON_UNESCAPED_UNICODE))
|
||||
->setRecord($record);
|
||||
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->persist($alertSms);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
$html = '<img src="'
|
||||
. $this->getParameter('public_directory')
|
||||
. '/images/logo-sova.jpg" alt="logo" width="206"><hr>';
|
||||
} else {
|
||||
if (!$record->getAlertSms()) {
|
||||
$response = $sms->sendSmsWmt($record->getPhone(), $msg);
|
||||
|
||||
$alertSms = new AlertSms();
|
||||
$alertSms
|
||||
->setDateCreate(new \DateTime())
|
||||
->setResponse(json_encode($response, JSON_UNESCAPED_UNICODE))
|
||||
->setRecord($record);
|
||||
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->persist($alertSms);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
$html = '<img src="'
|
||||
. $this->getParameter('public_directory')
|
||||
. '/img/logo_wmt/logo-pdf.jpg" alt="logo" width="256"><hr>';
|
||||
}
|
||||
|
||||
|
||||
$specialist = $specialistService->show(['dcode' => $reserve['dcode']]);
|
||||
|
||||
if ($specialist) {
|
||||
$html .= '<h2>' . $specialist->getName() . '</h2>';
|
||||
}
|
||||
|
||||
$html .= '<p><b>Филиал:</b> ' . $filial->getName(). '</p>';
|
||||
$html .= '<p><b>Дата приема:</b> '. $reserve['date'] . ' c '. $reserve['st']. ' по ' . $reserve['en'] .'</p>';
|
||||
$html .= '<p><i>На Ваш номер отправлено смс с информацией о приеме</i></p>';
|
||||
|
||||
$mpdf = new \Mpdf\Mpdf();
|
||||
$mpdf->WriteHTML($html);
|
||||
$mpdf->Output();
|
||||
}
|
||||
|
||||
throw $this->createNotFoundException('The event does not exist');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\WidgetForm;
|
||||
use App\Entity\WidgetFormInput;
|
||||
use App\Form\WidgetFormType;
|
||||
use App\Repository\WidgetFormRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use App\Form\WidgetFormInputType;
|
||||
use Symfony\Component\HttpClient\CachingHttpClient;
|
||||
use Symfony\Component\HttpKernel\HttpCache\Store;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use App\Bundle\Calltouch\Request as CalltouchRequest;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
||||
|
||||
/**
|
||||
* @Route("/widget/form")
|
||||
*/
|
||||
class WidgetFormController extends AbstractController
|
||||
{
|
||||
private $client;
|
||||
|
||||
public function __construct(HttpClientInterface $client, string $rootPath)
|
||||
{
|
||||
$store = new Store($rootPath . '/var/HttpClient');
|
||||
$this->client = new CachingHttpClient($client, $store);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/", name="widget_form_index", methods={"GET"})
|
||||
*/
|
||||
public function index(WidgetFormRepository $widgetFormRepository): Response
|
||||
{
|
||||
return $this->render('widget_form/index.html.twig', [
|
||||
'widget_forms' => $widgetFormRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/new", name="widget_form_new", methods={"GET","POST"})
|
||||
*/
|
||||
public function new(Request $request): Response
|
||||
{
|
||||
$widgetForm = new WidgetForm();
|
||||
$form = $this->createForm(WidgetFormType::class, $widgetForm);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->persist($widgetForm);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('widget_form_index');
|
||||
}
|
||||
|
||||
return $this->render('widget_form/new.html.twig', [
|
||||
'widget_form' => $widgetForm,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/{id}/editor", name="widget_form_editor", methods={"GET"})
|
||||
*/
|
||||
public function editor(WidgetForm $widgetForm, Request $request, $id): Response
|
||||
{
|
||||
$widgetFormInput = new WidgetFormInput();
|
||||
$form = $this->createForm(WidgetFormInputType::class, $widgetFormInput, [
|
||||
'action' => $this->generateUrl('widget_form_input_new', ['id' => $widgetForm->getId()]),
|
||||
'method' => 'POST',
|
||||
]);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
return $this->render('widget_form/editor.html.twig', [
|
||||
'form_input' => $widgetForm->getWidgetFormInputs(),
|
||||
'widget_form' => $widgetForm,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="widget_form_show", methods={"GET", "POST"})
|
||||
*/
|
||||
public function show(Request $request, WidgetForm $widgetForm, $id): Response
|
||||
{
|
||||
$fields = [];
|
||||
|
||||
switch (base64_decode($request->query->get('ref') ?? $request->request->get('ref'))) {
|
||||
case 'https://volgograd.sovamed.ru':
|
||||
$regionId = 92;
|
||||
$fields['UF_CRM_1539951158'] = 96;
|
||||
// Волгоград
|
||||
break;
|
||||
|
||||
case 'https://voronezh.sovamed.ru':
|
||||
$regionId = 93;
|
||||
$fields['UF_CRM_1539951158'] = 98;
|
||||
// Воронеж
|
||||
break;
|
||||
|
||||
case 'https://wmtmed.ru':
|
||||
$regionId = 94;
|
||||
$fields['UF_CRM_1539951158'] = 3018;
|
||||
// Краснодар
|
||||
break;
|
||||
|
||||
case 'https://sovenok.sovamed.ru':
|
||||
$regionId = 95;
|
||||
$fields['UF_CRM_1539951158'] = 94;
|
||||
// Совенок
|
||||
break;
|
||||
|
||||
case 'https://comfort.sovamed.ru':
|
||||
$regionId = 96;
|
||||
$fields['UF_CRM_1539951158'] = 94;
|
||||
// Комфорт
|
||||
break;
|
||||
|
||||
default:
|
||||
$regionId = 91;
|
||||
$fields['UF_CRM_1539951158'] = 94;
|
||||
// Саратов
|
||||
break;
|
||||
}
|
||||
|
||||
if ($request->getMethod() == 'POST' && !empty($request->request->get('fields'))) {
|
||||
$fields = array_merge($request->request->get('fields'), $fields);
|
||||
$fields['ASSIGNED_BY_ID'] = 506;
|
||||
|
||||
if (!empty($fields['OPPORTUNITY']))
|
||||
$fields['OPPORTUNITY'] = preg_replace('/[^0-9]/', '', $fields['OPPORTUNITY']);
|
||||
|
||||
$this->client->request('POST', $_ENV['BITRIX24_URL'], [
|
||||
'verify_peer' => false,
|
||||
'verify_host' => false,
|
||||
'base_uri' => 'https://sovamed.bitrix24.ru',
|
||||
'headers' => [
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => 'sovamed_bot',
|
||||
],
|
||||
'query' => ['fields' => $fields]
|
||||
]);
|
||||
|
||||
$data = [
|
||||
'requestNumber' => \md5(\time()),
|
||||
'requestUrl' => $request->request->get('requestUrl'),
|
||||
'requestDate' => \date('d-m-Y H:i:s'),
|
||||
'subject' => $fields['TITLE'],
|
||||
'sessionId' => $request->query->get('sessionId') ?? $request->request->get('sessionId'),
|
||||
'phoneNumber' => $fields['PHONE'][0]['VALUE'],
|
||||
'fio' => $fields['NAME'],
|
||||
'tag' => str_replace(' ', '_', $fields['TITLE']),
|
||||
];
|
||||
|
||||
if ($request->request->get('utm_source')
|
||||
&& $request->request->get('utm_medium')
|
||||
&& $request->request->get('utm_campaign')
|
||||
&& $request->request->get('utm_content')
|
||||
&& $request->request->get('utm_term')) {
|
||||
$data['customSources'] = [
|
||||
"source" => $request->request->get('utm_source'),
|
||||
"medium" => $request->request->get('utm_medium'),
|
||||
"campaign" => $request->request->get('utm_campaign'),
|
||||
"content" => $request->request->get('utm_content'),
|
||||
"term" => $request->request->get('utm_term')
|
||||
];
|
||||
}
|
||||
|
||||
$calltouch = new CalltouchRequest();
|
||||
$calltouch->changeRegion($regionId);
|
||||
$calltouch = $calltouch->create($data);
|
||||
|
||||
return $this->render('widget_form/show.html.twig', [
|
||||
'widget_form' => $widgetForm,
|
||||
'renderForm' => false
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render('widget_form/show.html.twig', [
|
||||
'regionId' => $regionId,
|
||||
'widget_form' => $widgetForm,
|
||||
'renderForm' => true
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/{id}/edit", name="widget_form_edit", methods={"GET","POST"})
|
||||
*/
|
||||
public function edit(Request $request, WidgetForm $widgetForm): Response
|
||||
{
|
||||
$form = $this->createForm(WidgetFormType::class, $widgetForm);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('widget_form_index');
|
||||
}
|
||||
|
||||
return $this->render('widget_form/edit.html.twig', [
|
||||
'widget_form' => $widgetForm,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/{id}/delete", name="widget_form_delete", methods={"POST"})
|
||||
*/
|
||||
public function delete(Request $request, WidgetForm $widgetForm): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$widgetForm->getId(), $request->request->get('_token'))) {
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->remove($widgetForm);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('widget_form_index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\WidgetForm;
|
||||
use App\Entity\WidgetFormInput;
|
||||
use App\Form\WidgetFormInputType;
|
||||
use App\Repository\WidgetFormInputRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
||||
|
||||
/**
|
||||
* @IsGranted("ROLE_ADMIN")
|
||||
* @Route("/widget/form/input")
|
||||
*/
|
||||
class WidgetFormInputController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @param {id} = widgetForm.id
|
||||
* @Route("/{id}/new", name="widget_form_input_new", methods={"POST"})
|
||||
*/
|
||||
public function new(WidgetForm $widgetForm, Request $request, $id): Response
|
||||
{
|
||||
$widgetFormInput = new WidgetFormInput();
|
||||
$widgetFormInput->setWidgetForm($widgetForm);
|
||||
$form = $this->createForm(WidgetFormInputType::class, $widgetFormInput);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->persist($widgetFormInput);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('widget_form_editor', ['id' => $id]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/{id}/edit/{formId}", name="widget_form_input_edit", methods={"GET","POST"})
|
||||
*/
|
||||
public function edit(Request $request, WidgetFormInput $widgetFormInput, $formId): Response
|
||||
{
|
||||
$form = $this->createForm(WidgetFormInputType::class, $widgetFormInput);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('widget_form_editor', ['id' => $formId]);
|
||||
}
|
||||
|
||||
return $this->render('widget_form_input/edit.html.twig', [
|
||||
'widget_form_input' => $widgetFormInput,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}/{formId}", name="widget_form_input_delete", methods={"POST"})
|
||||
*/
|
||||
public function delete(Request $request, WidgetFormInput $widgetFormInput, $formId): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$widgetFormInput->getId(), $request->request->get('_token'))) {
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->remove($widgetFormInput);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('widget_form_editor', ['id' => $formId]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user