|
|
|
|
@ -6,10 +6,14 @@ namespace ChamiloLMS\Controller\Admin\Administrator; |
|
|
|
|
use ChamiloLMS\Controller\CommonController; |
|
|
|
|
use Silex\Application; |
|
|
|
|
use Symfony\Component\Form\Extension\Validator\Constraints\FormValidator; |
|
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
|
|
|
use Entity; |
|
|
|
|
use ChamiloLMS\Form\BranchType; |
|
|
|
|
|
|
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Class RoleController |
|
|
|
|
* @todo @route and @method function don't work yet |
|
|
|
|
@ -19,9 +23,8 @@ use ChamiloLMS\Form\BranchType; |
|
|
|
|
class BranchController extends CommonController |
|
|
|
|
{ |
|
|
|
|
/** |
|
|
|
|
* @param \Silex\Application $app |
|
|
|
|
* |
|
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
|
|
|
|
* @Route("/") |
|
|
|
|
* @Method({"GET"}) |
|
|
|
|
*/ |
|
|
|
|
public function indexAction() |
|
|
|
|
{ |
|
|
|
|
@ -59,6 +62,11 @@ class BranchController extends CommonController |
|
|
|
|
return new Response($response, 200, array()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* @Route("/{id}", requirements={"id" = "\d+"}, defaults={"foo" = "bar"}) |
|
|
|
|
* @Method({"GET"}) |
|
|
|
|
*/ |
|
|
|
|
public function readAction($id) |
|
|
|
|
{ |
|
|
|
|
$template = $this->get('template'); |
|
|
|
|
@ -72,6 +80,10 @@ class BranchController extends CommonController |
|
|
|
|
return new Response($response, 200, array()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Route("/add") |
|
|
|
|
* @Method({"GET"}) |
|
|
|
|
*/ |
|
|
|
|
public function addAction() |
|
|
|
|
{ |
|
|
|
|
$this->app['extraJS'] = array( |
|
|
|
|
@ -82,56 +94,57 @@ class BranchController extends CommonController |
|
|
|
|
return parent::addAction(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function searchParentAction($keyword) |
|
|
|
|
{ |
|
|
|
|
/** @var \EntityRepository $repo */ |
|
|
|
|
$qb = $this->getManager()->createQueryBuilder(); |
|
|
|
|
|
|
|
|
|
$qb->select(array('b')) |
|
|
|
|
->from('Entity\BranchSync', 'b') |
|
|
|
|
->where($qb->expr()->orX( |
|
|
|
|
$qb->expr()->like('u.branchName', '') |
|
|
|
|
)) |
|
|
|
|
->orderBy('u.surname', 'ASC')) |
|
|
|
|
|
|
|
|
|
/** @var Entity\BranchSync $entity */ |
|
|
|
|
// $entity = $repo->findOneByBranchName($keyword); |
|
|
|
|
$qb->expr()->like('u.branchName', '?2') |
|
|
|
|
$qb->getQuery()->setParameter(2, '%' . $value . '%'); |
|
|
|
|
|
|
|
|
|
if ($entity) { |
|
|
|
|
echo $entity->getId(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return new Response(null, 200, array()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* @Route("/{id}/edit", requirements={"id" = "\d+"}, defaults={"foo" = "bar"}) |
|
|
|
|
* @Method({"GET"}) |
|
|
|
|
*/ |
|
|
|
|
public function editAction($id) |
|
|
|
|
{ |
|
|
|
|
return parent::editAction($id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* @Route("/{id}/delete", requirements={"id" = "\d+"}, defaults={"foo" = "bar"}) |
|
|
|
|
* @Method({"GET"}) |
|
|
|
|
*/ |
|
|
|
|
public function deleteAction($id) |
|
|
|
|
{ |
|
|
|
|
return parent::deleteAction($id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return an array with the string that are going to be generating by twig. |
|
|
|
|
* @todo could be autogenerated? |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
protected function generateLinks() |
|
|
|
|
* |
|
|
|
|
* //Route("/search/{keyword}") |
|
|
|
|
* @Route("/search/") |
|
|
|
|
* @Method({"GET"}) |
|
|
|
|
*/ |
|
|
|
|
public function searchAction() |
|
|
|
|
{ |
|
|
|
|
return array( |
|
|
|
|
'create_link' => 'admin_administrator_branches_add', |
|
|
|
|
'read_link' => 'admin_administrator_branches_read', |
|
|
|
|
'update_link' => 'admin_administrator_branches_edit', |
|
|
|
|
'delete_link' => 'admin_administrator_branches_delete', |
|
|
|
|
'list_link' => 'admin_administrator_branches' |
|
|
|
|
); |
|
|
|
|
$request = $this->getRequest(); |
|
|
|
|
$keyword = $request->get('tag'); |
|
|
|
|
$repo = $this->getRepository(); |
|
|
|
|
$entities = $repo->searchByKeyword($keyword); |
|
|
|
|
$data = array(); |
|
|
|
|
if ($entities) { |
|
|
|
|
/** Entity\BranchSync $entity */ |
|
|
|
|
foreach ($entities as $entity) { |
|
|
|
|
$data[] = array( |
|
|
|
|
'key' => $entity->getId(), |
|
|
|
|
'value' => $entity->getBranchName(), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return new JsonResponse($data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected function getControllerAlias() |
|
|
|
|
{ |
|
|
|
|
return 'branch.controller'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* {@inheritdoc} |
|
|
|
|
*/ |
|
|
|
|
@ -141,7 +154,7 @@ class BranchController extends CommonController |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* {@inheritdoc} |
|
|
|
|
* @return \Entity\Repository\BranchSyncRepository |
|
|
|
|
*/ |
|
|
|
|
protected function getRepository() |
|
|
|
|
{ |
|
|
|
|
|