some progress
This commit is contained in:
parent
128165e437
commit
3055949aac
|
@ -13,6 +13,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
|
@ -77,7 +78,7 @@ class AdminController extends AbstractController
|
|||
#[Route('/api/admin/reportchange/lists', name: 'app_admin_reportchange_list')]
|
||||
public function app_admin_reportchange_list(Jdate $jdate,Provider $provider,EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$rows = $entityManager->getRepository(ChangeReport::class)->findAll();
|
||||
$rows = $entityManager->getRepository(ChangeReport::class)->findBy([],['id'=>'DESC']);
|
||||
foreach ($rows as $row){
|
||||
$row->setDateSubmit($jdate->jdate('Y/n/d',$row->getDateSubmit()));
|
||||
}
|
||||
|
@ -94,4 +95,42 @@ class AdminController extends AbstractController
|
|||
}
|
||||
return $this->json(['result'=>1]);
|
||||
}
|
||||
|
||||
#[Route('/api/admin/reportchange/get/{id}', name: 'app_admin_reportchange_get')]
|
||||
public function app_admin_reportchange_get(string $id,EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$item = $entityManager->getRepository(ChangeReport::class)->find($id);
|
||||
if(!$item)
|
||||
throw $this->createNotFoundException();
|
||||
return $this->json($item);
|
||||
}
|
||||
|
||||
#[Route('/api/admin/reportchange/mod/{id}', name: 'app_admin_reportchange_mod')]
|
||||
public function app_admin_reportchange_mod(Request $request,EntityManagerInterface $entityManager, int $id = 0): JsonResponse
|
||||
{
|
||||
$item = new ChangeReport();
|
||||
$item->setDateSubmit(time());
|
||||
|
||||
if($id != 0){
|
||||
$item = $entityManager->getRepository(ChangeReport::class)->find($id);
|
||||
if(!$item)
|
||||
throw $this->createNotFoundException();
|
||||
else
|
||||
$item->setDateSubmit(time());
|
||||
|
||||
}
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if(array_key_exists('version',$params) && array_key_exists('body',$params)){
|
||||
$item->setBody($params['body']);
|
||||
$item->setVersion($params['version']);
|
||||
}
|
||||
else
|
||||
throw $this->createNotFoundException();
|
||||
$entityManager->persist($item);
|
||||
$entityManager->flush();
|
||||
return $this->json(['result'=>1]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,68 +31,6 @@ class AppController extends AbstractController
|
|||
{
|
||||
return $this->render('/app/dashboard.html.twig');
|
||||
}
|
||||
/**
|
||||
* @Route("/app/changes/list", name="app_front_changes_list")
|
||||
*/
|
||||
public function app_front_changes_list(EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
return $this->render('/app/changes/list.html.twig',[
|
||||
'items'=>$entityManager->getRepository(ChangeReport::class)->findAll()
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @Route("/app/changes/delete/{id}", name="app_front_changes_delete")
|
||||
*/
|
||||
public function app_front_changes_delete(String $id,EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$item = $entityManager->getRepository(ChangeReport::class)->find($id);
|
||||
if($item){
|
||||
$entityManager->remove($item);
|
||||
$entityManager->flush();
|
||||
}
|
||||
return $this->redirectToRoute('app_front_changes_list');
|
||||
}
|
||||
/**
|
||||
* @Route("/app/changes/new", name="app_front_changes_new")
|
||||
*/
|
||||
public function app_front_changes_new(Request $request,EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$change = new ChangeReport();
|
||||
$change->setDateSubmit(time());
|
||||
$form = $this->createForm(UpdateListType::class,$change,[]);
|
||||
|
||||
$form->handleRequest($request);
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->persist($change);
|
||||
$entityManager->flush();
|
||||
return $this->redirectToRoute('app_front_changes_list');
|
||||
}
|
||||
return $this->render('/app/changes/new.html.twig',[
|
||||
'form'=>$form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/app/changes/edit/{id}", name="app_front_changes_edit")
|
||||
*/
|
||||
public function app_front_changes_edit(string $id, Request $request,EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$change = $entityManager->getRepository(ChangeReport::class)->find($id);
|
||||
if(!$change)
|
||||
throw $this->createNotFoundException();
|
||||
$change->setDateSubmit(time());
|
||||
$form = $this->createForm(UpdateListType::class,$change,[]);
|
||||
|
||||
$form->handleRequest($request);
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->persist($change);
|
||||
$entityManager->flush();
|
||||
return $this->redirectToRoute('app_front_changes_list');
|
||||
}
|
||||
return $this->render('/app/changes/new.html.twig',[
|
||||
'form'=>$form->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/app/api/list", name="app_front_api_list")
|
||||
|
|
|
@ -82,12 +82,6 @@
|
|||
<span class="nav-main-link-name"> پیشخوان </span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-main-item">
|
||||
<a class="nav-main-link" href="/app/changes/list">
|
||||
<i class="nav-main-link-icon fa fa-history"></i>
|
||||
<span class="nav-main-link-name"> گزارش تغییرات </span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-main-item">
|
||||
<a class="nav-main-link" href="/app/api/list">
|
||||
<i class="nav-main-link-icon fa fa-book"></i>
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
{% extends "app/base.html.twig" %}
|
||||
{% block title %}لیست تغییرات{% endblock %}
|
||||
{% block body %}
|
||||
<div class="block block-rounded">
|
||||
<div class="block-header block-header-default">
|
||||
<h3 class="block-title">
|
||||
<i class="fa fa-list"></i>
|
||||
فهرست تغییرات
|
||||
</h3>
|
||||
<div class="block-options">
|
||||
<div class="block-options-item">
|
||||
<a href="/app/changes/new" class="btn btn-success">جدید</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="block-content">
|
||||
<table class="table table-hover table-vcenter">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center" style="width: 50px;">#</th>
|
||||
<th>تاریخ</th>
|
||||
<th class="d-none d-sm-table-cell" style="width: 15%;">نسخه</th>
|
||||
<th class="text-center" style="width: 100px;">عملیات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for index,item in items %}
|
||||
<tr>
|
||||
<th class="text-center" scope="row">{{ index + 1}}</th>
|
||||
<td class="fw-semibold">
|
||||
{{ item.version }}
|
||||
</td>
|
||||
<td class="d-none d-sm-table-cell">
|
||||
{{ Jdate.jdate('Y/n/d',item.dateSubmit) }}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="btn-group">
|
||||
<a href="{{ path('app_front_changes_delete',{'id':item.id}) }}" class="btn btn-sm btn-alt-secondary" aria-label=" حذف ">
|
||||
<i class="fa fa-times"></i>
|
||||
</a>
|
||||
<a href="{{ path('app_front_changes_edit',{'id':item.id}) }}" class="btn btn-sm btn-alt-secondary" aria-label=" حذف ">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -1,27 +0,0 @@
|
|||
{% extends "app/base.html.twig" %}
|
||||
{% block title %}لیست تغییر نسخه جدید{% endblock %}
|
||||
{% block body %}
|
||||
<div class="block block-rounded">
|
||||
<div class="block-header block-header-default">
|
||||
<h3 class="block-title">
|
||||
<i class="fa fa-list"></i>
|
||||
{{ block('title') }}
|
||||
</h3>
|
||||
<div class="block-options">
|
||||
<div class="block-options-item">
|
||||
<a href="/app/changes/list" class="btn btn-secondary">بازگشت</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="block-content">
|
||||
{{ form_start(form) }}
|
||||
{{ form_row(form.version,{'attr':{'class':'mb-2'}}) }}
|
||||
{{ form_row(form.body,{'attr':{'class':'mb-2'}}) }}
|
||||
<div class="mb-4">
|
||||
{{ form_widget(form.submit) }}
|
||||
<a href="/app/changes/list" class="btn btn-primary">بازگشت</a>
|
||||
</div>
|
||||
{{ form_end(form) }}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in a new issue