some progress in archive

This commit is contained in:
Hesabix 2023-11-21 07:34:45 -05:00
parent c49045bbe7
commit c2ea1148a6
15 changed files with 300 additions and 51 deletions

1
hesabixArchive/index.php Normal file
View file

@ -0,0 +1 @@
<?php

View file

@ -0,0 +1 @@
<?php

View file

@ -5,6 +5,8 @@
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
blogMediaDir: '%kernel.project_dir%/../public_html/blog/media'
archiveMediaDir: '%kernel.project_dir%/../hesabixArchive'
archiveTempMediaDir: '%kernel.project_dir%/../hesabixArchive/temp'
services:
# default configuration for services in *this* file
_defaults:

View file

@ -2,11 +2,20 @@
namespace App\Controller;
use App\Entity\BankAccount;
use App\Entity\Business;
use App\Entity\ChangeReport;
use App\Entity\Commodity;
use App\Entity\HesabdariDoc;
use App\Entity\Person;
use App\Entity\Settings;
use App\Entity\StoreroomTicket;
use App\Entity\User;
use App\Entity\WalletTransaction;
use App\Service\Jdate;
use App\Service\Notification;
use App\Service\Provider;
use App\Service\SMS;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use Symfony\Bundle\FrameworkBundle\Console\Application;
@ -19,6 +28,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Http\Attribute\CurrentUser;
class AdminController extends AbstractController
@ -86,6 +96,86 @@ class AdminController extends AbstractController
return $this->json($resp);
}
#[Route('/api/admin/business/info/{id}', name: 'admin_business_info')]
public function admin_business_info(string $id,Jdate $jdate,#[CurrentUser] ?User $user,UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager,Request $request): Response
{
$bid = $entityManager->getRepository(Business::class)->find($id);
if(!$bid)
throw $this->createNotFoundException();
$resp = [];
$resp['id'] = $bid->getId();
$resp['name'] = $bid->getName();
$resp['owner'] = $bid->getOwner()->getFullName();
return $this->json($resp);
}
#[Route('/api/admin/business/list', name: 'admin_business_list')]
public function admin_business_list(Jdate $jdate,#[CurrentUser] ?User $user,UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager,Request $request): Response
{
$items = $entityManager->getRepository(Business::class)->findBy([],['id'=>'DESC']);
$resp = [];
foreach ($items as $item) {
$temp =[];
$temp['id'] = $item->getId();
$temp['name'] = $item->getName();
$temp['owner'] = $item->getOwner()->getFullName();
$temp['ownerMobile'] = $item->getOwner()->getMobile();
$temp['dateRegister'] = $jdate->jdate('Y/n/d',$item->getDateSubmit());
$temp['commodityCount'] = count($entityManager->getRepository(Commodity::class)->findBy(['bid'=>$item]));
$temp['personsCount'] = count($entityManager->getRepository(Person::class)->findBy(['bid'=>$item]));
$temp['hesabdariDocsCount'] = count($entityManager->getRepository(HesabdariDoc::class)->findBy(['bid'=>$item]));
$temp['StoreroomDocsCount'] = count($entityManager->getRepository(StoreroomTicket::class)->findBy(['bid'=>$item]));
$resp[] = $temp;
}
return $this->json($resp);
}
#[Route('/api/admin/settings/sms/info', name: 'admin_settings_sms_info')]
public function admin_settings_sms_info(Jdate $jdate,#[CurrentUser] ?User $user,UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager,Request $request): Response
{
$item = $entityManager->getRepository(Settings::class)->findAll()[0];
$resp = [];
$url = 'https://console.melipayamak.com/api/receive/credit/' . $item->getMelipayamakToken();
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array('Content-Type: application/json',
'Content-Length: 0')
);
$result = curl_exec($ch);
$err = curl_error($ch);
$result = json_decode($result, true, JSON_PRETTY_PRINT);
curl_close($ch);
if ($err) {
throw $this->createAccessDeniedException($err);
} else {
$resp['balanceCount'] = $result['amount'];
}
$resp['username'] = $item->getPayamakUsername();
$resp['password'] = $item->getPayamakPassword();
$resp['token'] = $item->getMelipayamakToken();
return $this->json($resp);
}
#[Route('/api/admin/settings/sms/info/save', name: 'admin_settings_sms_info_save')]
public function admin_settings_sms_info_save(Jdate $jdate,#[CurrentUser] ?User $user,UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager,Request $request): Response
{
$params = [];
if ($content = $request->getContent()) {
$params = json_decode($content, true);
}
if(array_key_exists('username',$params) && array_key_exists('password',$params) && array_key_exists('token',$params)){
$item = $entityManager->getRepository(Settings::class)->findAll()[0];
$item->setPayamakPassword($params['password']);
$item->setPayamakUsername($params['username']);
$item->setMelipayamakToken($params['token']);
$entityManager->persist($item);
$entityManager->flush();
return $this->json(['result' => 1]);
}
throw $this->createNotFoundException();
}
#[Route('/api/admin/reportchange/lists', name: 'app_admin_reportchange_list')]
public function app_admin_reportchange_list(Jdate $jdate,Provider $provider,EntityManagerInterface $entityManager): JsonResponse
{
@ -144,4 +234,97 @@ class AdminController extends AbstractController
$entityManager->flush();
return $this->json(['result'=>1]);
}
#[Route('/api/admin/wallets/list', name: 'app_admin_wallets_list')]
public function app_admin_wallets_list(Jdate $jdate,Provider $provider,EntityManagerInterface $entityManager): JsonResponse
{
$bids = $entityManager->getRepository(Business::class)->findBy(['walletEnable'=>true]);
$resp = [];
foreach ($bids as $bid){
$temp = [];
$walletPays = $entityManager->getRepository(WalletTransaction::class)->findBy(['bid'=>$bid,'type'=>'pay']);
$totalPays = 0;
foreach ($walletPays as $walletPay){
$totalPays += $walletPay->getAmount();
}
$temp['totalPays'] = $totalPays;
$walletIncomes = $entityManager->getRepository(WalletTransaction::class)->findAllIncome($bid);
$totalIcome = 0;
foreach ($walletIncomes as $walletIncome){
$totalIcome += $walletIncome->getAmount();
}
$temp['totalIncome'] = $totalIcome;
$temp['id'] = $bid->getId();
$temp['bidName'] = $bid->getName();
$temp['walletEnabled'] = $bid->isWalletEnable();
if($bid->isWalletEnable()){
$temp['bankAcName'] = $bid->getWalletMatchBank()->getName();
$temp['bankAcShaba'] = $bid->getWalletMatchBank()->getShaba();
$temp['bankAcOwner'] = $bid->getWalletMatchBank()->getOwner();
$temp['bankAcCardNum'] = $bid->getWalletMatchBank()->getCardNum();
}
$resp[] = $temp;
}
return $this->json($resp);
}
#[Route('/api/admin/wallets/transactions/list', name: 'app_admin_wallets_transactions_list')]
public function app_admin_wallets_transactions_list(Jdate $jdate,Provider $provider,EntityManagerInterface $entityManager): JsonResponse
{
$items = $entityManager->getRepository(WalletTransaction::class)->findAll();
$resp = [];
foreach ($items as $item){
$temp = [];
$temp['id'] = $item->getId();
$temp['bidName'] = $item->getBid()->getName();
$temp['walletEnabled'] = $item->getBid()->isWalletEnable();
$temp['bankAcName'] = $item->getBid()->getWalletMatchBank()->getName();
$temp['bankAcShaba'] = $item->getBid()->getWalletMatchBank()->getShaba();
$temp['bankAcOwner'] = $item->getBid()->getWalletMatchBank()->getOwner();
$temp['bankAcCardNum'] = $item->getBid()->getWalletMatchBank()->getCardNum();
$temp['type'] = $item->getType();
$temp['cardPan'] = $item->getCardPan();
$temp['refID'] = $item->getRefID();
$temp['shaba'] = $item->getShaba();
$temp['dateSubmit'] = $jdate->jdate('Y/n/d H:i',$item->getDateSubmit());
$temp['gatePay'] = $item->getGatePay();
$resp[] = $temp;
}
return $this->json($resp);
}
#[Route('/api/admin/wallets/transactions/insert', name: 'app_admin_wallets_transactions_insert')]
public function app_admin_wallets_transactions_insert(SMS $SMS,Jdate $jdate,Notification $notification,Request $request,EntityManagerInterface $entityManager): JsonResponse
{
$params = [];
if ($content = $request->getContent()) {
$params = json_decode($content, true);
}
if(array_key_exists('bank',$params) && array_key_exists('refID',$params) && array_key_exists('bid',$params) && array_key_exists('amount',$params) && array_key_exists('shaba',$params) && array_key_exists('card',$params)){
$bid = $entityManager->getRepository(Business::class)->find($params['bid']['id']);
if(!$bid)
throw $this->createNotFoundException();
$item = new WalletTransaction();
$item->setBid($bid);
$item->setType('pay');
$item->setShaba($params['shaba']);
$item->setAmount($params['amount']);
$item->setCardPan($params['card']);
$item->setDateSubmit(time());
$item->setDes('واریز به حساب کسب و کار از طرف حسابیکس');
$item->setRefID($params['refID']);
$item->setGatePay($params['bank']);
$item->setBank($bid->getWalletMatchBank()->getName());
$entityManager->persist($item);
$entityManager->flush();
$notification->insert('تسویه کیف پول انجام شد.','/acc/wallet/view',$bid,$bid->getOwner());
$SMS->send([$bid->getName()],174225,$bid->getOwner()->getMobile());
return $this->json(['result' => 1]);
}
throw $this->createNotFoundException();
}
}

View file

@ -13,20 +13,18 @@ use App\Service\Provider;
use App\Service\twigFunctions;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\HttpFoundation\File\Exception\FileException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\String\Slugger\SluggerInterface;
class ArchiveController extends AbstractController
{
#[Route('/api/archive/info', name: 'app_archive_info')]
public function app_archive_info(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,$code = 0): JsonResponse
{
$acc = $access->hasRole('archiveInfo');
if(!$acc)
throw $this->createAccessDeniedException();
private function getArchiveInfo(EntityManagerInterface $entityManager,array $acc){
$orders = $entityManager->getRepository(ArchiveOrders::class)->findBy([
'bid'=>$acc['bid'],
'status'=>100
@ -40,10 +38,19 @@ class ArchiveController extends AbstractController
$files = $entityManager->getRepository(ArchiveFile::class)->findBy(['bid'=>$acc['bid']]);
foreach ($files as $file)
$usedSize += $file->getFileSize();
return $this->json([
return [
'size' => $totalSize * 1024,
'remain'=>$usedSize
]);
];
}
#[Route('/api/archive/info', name: 'app_archive_info')]
public function app_archive_info(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,$code = 0): JsonResponse
{
$acc = $access->hasRole('archiveInfo');
if(!$acc)
throw $this->createAccessDeniedException();
$resp = $this->getArchiveInfo($entityManager,$acc);
return $this->json($resp);
}
#[Route('/api/archive/order/settings', name: 'app_archive_order_settings')]
@ -223,4 +230,38 @@ class ArchiveController extends AbstractController
}
return $this->json($resp);
}
#[Route('/api/archive/file/upload', name: 'app_archive_file_upload')]
public function app_archive_file_upload(Jdate $jdate, Provider $provider,SluggerInterface $slugger,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,$code = 0): Response
{
$acc = $access->hasRole('archiveUpload');
if (!$acc)
throw $this->createAccessDeniedException();
$info = $this->getArchiveInfo($entityManager,$acc);
if($info['remain'] > 0){
$uploadedFile = $request->files->get('image');
if ($uploadedFile) {
$originalFilename = pathinfo($uploadedFile->getClientOriginalName(), PATHINFO_FILENAME);
// this is needed to safely include the file name as part of the URL
$safeFilename = $slugger->slug($originalFilename);
$newFilename = $safeFilename.'-'.uniqid().'.'.$uploadedFile->guessExtension();
// Move the file to the directory where brochures are stored
$uploadedFile->move(
$this->getParameter('archiveTempMediaDir'),
$newFilename
);
try {} catch (FileException $e) {
// ... handle exception if something happens during file upload
}
// updates the 'brochureFilename' property to store the PDF file name
// instead of its contents
//$product->setBrochureFilename($newFilename);
return new Response('ali.jpg');
}
}
}
}

View file

@ -227,7 +227,6 @@ class BlogController extends AbstractController
#[Route('/api/admin/blog/posts', name: 'app_admin_posts_get')]
public function app_admin_posts_get(Jdate $jdate, Provider $provider,Request $request,SerializerInterface $serializer, EntityManagerInterface $entityManager): JsonResponse
{
$items = array_reverse($entityManager->getRepository(BlogPost::class)->findAll());
$response = [];
foreach ($items as $item){
@ -239,7 +238,6 @@ class BlogController extends AbstractController
$temp['url'] = $item->getUrl();
$temp['cat'] = $item->getCat()->getLabel();
$temp['dateSubmit'] = $jdate->jdate('Y/n/d H:i',$item->getDateSubmit());
$temp['submitter'] = $item->getSubmitter()->getFullName();
$response[] = $temp;
}
return $this->json($response);

View file

@ -38,7 +38,9 @@ class BlogController extends AbstractController
{
$item = $entityManager->getRepository(BlogPost::class)->findOneBy(['url'=>$url]);
if(!$item) throw $this->createNotFoundException();
$item->setViews($item->getViews() + 1);
$entityManager->persist($item);
$entityManager->flush();
$comment = new BlogComment();
$form = $this->createForm(CommentType::class,$comment);
$form->handleRequest($request);

View file

@ -20,14 +20,13 @@ class WalletController extends AbstractController
if(!$acc)
throw $this->createAccessDeniedException();
$items = $entityManager->getRepository(WalletTransaction::class)->findBy([
'bid' => $acc['bid'],
'status'=>100
'bid' => $acc['bid']
]);
$pays = 0;
$gets = 0;
foreach ($items as $item){
if($item->getType() == 'pay') $pays += $item->getAmount();
elseif ($item->getType() == 'get' || $item->getType() == 'sell') $gets += $item->getAmount();
elseif (($item->getType() == 'get' || $item->getType() == 'sell') && $item->getStatus() == 100 ) $gets += $item->getAmount();
}
return $this->json([
'deposit' => $gets - $pays,
@ -35,15 +34,26 @@ class WalletController extends AbstractController
'turnover'=>$pays + $gets,
]);
}
#[Route('/api/wallet/transactions', name: 'api_wallet_transactions')]
public function api_wallet_transactions(Jdate $jdate,EntityManagerInterface $entityManager,Access $access,Provider $provider): JsonResponse
#[Route('/api/wallet/transactions/{type}', name: 'api_wallet_transactions')]
public function api_wallet_transactions(Jdate $jdate,EntityManagerInterface $entityManager,Access $access,Provider $provider, string $type = 'all'): JsonResponse
{
$acc = $access->hasRole('wallet');
if(!$acc)
throw $this->createAccessDeniedException();
if($type == 'all'){
$items = $entityManager->getRepository(WalletTransaction::class)->findBy([
'bid' => $acc['bid']
],['id'=>'DESC']);
}
elseif($type == 'pay'){
$items = $entityManager->getRepository(WalletTransaction::class)->findBy([
'bid' => $acc['bid'],
'type' => 'pay'
],['id'=>'DESC']);
}
elseif($type == 'income'){
$items = $entityManager->getRepository(WalletTransaction::class)->findAllIncome($acc['bid']);
}
foreach ($items as $item){
$item->setDateSubmit($jdate->jdate('Y/n/d H:i',$item->getDateSubmit()));
}

View file

@ -31,6 +31,9 @@ class Settings
#[ORM\Column(length: 255, nullable: true)]
private ?string $storagePrice = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $melipayamakToken = null;
public function getId(): ?int
{
return $this->id;
@ -107,4 +110,16 @@ class Settings
return $this;
}
public function getMelipayamakToken(): ?string
{
return $this->melipayamakToken;
}
public function setMelipayamakToken(?string $melipayamakToken): static
{
$this->melipayamakToken = $melipayamakToken;
return $this;
}
}

View file

@ -2,6 +2,7 @@
namespace App\Repository;
use App\Entity\Business;
use App\Entity\WalletTransaction;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
@ -24,17 +25,17 @@ class WalletTransactionRepository extends ServiceEntityRepository
// /**
// * @return WalletTransaction[] Returns an array of WalletTransaction objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('w')
// ->andWhere('w.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('w.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
public function findAllIncome(Business $business): array
{
return $this->createQueryBuilder('w')
->andWhere('w.bid = :val')
->andWhere("w.type != 'pay'")
->setParameter('val', $business)
->orderBy('w.id', 'DESC')
->getQuery()
->getResult()
;
}
// public function findOneBySomeField($value): ?WalletTransaction
// {

View file

@ -33,33 +33,32 @@
<body>
<div id="page-container">
<!-- Header -->
<header id="page-header" class="app-header" style="background-color: #f3f9ff">
<header id="page-header" class="app-header bg-sidebar-dark border-bottom border-light" >
<!-- Header Content -->
<div class="content-header">
<div class="content-header text-light">
<!-- Left Section -->
<div class="d-flex align-items-center">
<!-- Logo -->
<img class="" src="{{ asset('/img/logo-blue.png') }}" alt="" width="32" height="32">
<img class="me-2" src="{{ asset('/img/logo-light.png') }}" alt="" width="48" height="48">
<a class="fw-semibold text-dual tracking-wide" href="{{ path('general_home') }}"><span class="opacity-75">حسابیکس</span>
<small class="fw-lighter d-none d-sm-block"> حسابداری ابری و رایگان</small>
<a class="text-light fw-semibold tracking-wide" href="{{ path('general_home') }}"><span class="opacity-75">حسابیکس</span>
<small class="fw-lighter d-none d-sm-block">نرم‌افزار حسابداری ابری و کاملا رایگان</small>
</a>
<!-- END Logo -->
</div>
<!-- END Left Section -->
<!-- Right Section -->
<div>
<a href="{{ twigFunctions.systemSettings().appSite }}/user/login" class="btn btn-sm btn-primary me-1">ورود</a>
<a href="{{ twigFunctions.systemSettings().appSite }}/user/register" class="btn btn-sm btn-success">عضویت</a>
</div>
<!-- END Right Section -->
<!-- Toggle Main Navigation -->
<div class="d-lg-none push mx-0 px-0">
<!-- Class Toggle, functionality initialized in Helpers.dmToggleClass() -->
<button class="btn btn-primary d-flex justify-content-between align-items-center" data-class="d-none" data-target="#main-navigation" data-toggle="class-toggle" type="button"> <i class="fa fa-bars"></i>
</button>
<div class="push mx-0 px-0">
<div class="btn-group" role="group" aria-label="Basic example">
<a href="{{ twigFunctions.systemSettings().appSite }}/user/login" class="btn btn-primary">ورود</a>
<a href="{{ twigFunctions.systemSettings().appSite }}/user/register" class="btn btn-success">عضویت</a>
<button class="d-lg-none btn btn-secondary" data-class="d-none" data-target="#main-navigation" data-toggle="class-toggle" type="button"> <i class="fa fa-bars"></i></button>
</div>
</div>
<!-- END Toggle Main Navigation -->
</div>
@ -77,7 +76,7 @@
</header>
<!-- Main Container -->
<main id="main-container bg-light">
<main id="main-container bg-light p-0 m-0">
<!-- Navigation -->
<div class="bg-sidebar-dark">
<div class="content py-1">
@ -154,7 +153,7 @@
</div>
<!-- END Navigation -->
<!-- Page Content -->
<div class="m-sm-3 m-0 p-0">
<div class="m-0 p-0 bg-white">
{% block body %}{% endblock %}
</div>
<!-- Footer -->

View file

@ -1,7 +1,7 @@
{% extends "base.html.twig" %}
{% block title %}نرم افزار حسابداری آنلاین ، متن باز و کاملا رایگان{% endblock %}
{% block body %}
<div class="px-4 py-3 text-center rounded-4 bg-warning">
<div class="px-4 py-3 text-center" style="background-color: #c8d7ff">
<div class="row">
<div class="col-sm-12 col-md-6">
<h1 class="fw-bold text-primary-darker">
@ -16,10 +16,6 @@
<i class="fa fa-door-open"></i>
ورود | عضویت رایگان
</a>
<button href="http://insider.hesabix.ir" disabled="disabled" class="btn btn-outline-dark btn-lg px-4 gap-3">
<i class="fa fa-door-open"></i>
پیش‌نمایش (فعلا غیرفعال است)
</button>
{% if is_granted('ROLE_ADMIN')%}
<a href="/app/dashboard" class="btn btn-alt-danger btn-lg px-4 gap-3">
<i class="fa fa-door-open"></i>

BIN
public_html/img/banner1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB