-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from pilot/task-33
Update event schedule manage, #34
- Loading branch information
Showing
11 changed files
with
277 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/Event/EventBundle/Entity/Repository/ProgramRepository.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace Event\EventBundle\Entity\Repository; | ||
|
||
use Doctrine\ORM\EntityRepository; | ||
use Doctrine\ORM\QueryBuilder; | ||
|
||
/** | ||
* ProgramRepository | ||
*/ | ||
class ProgramRepository extends EntityRepository | ||
{ | ||
/** | ||
* @param integer $eventId | ||
* @param string $searchQuery | ||
* @param array $order | ||
* @param integer $start | ||
* @param integer $length | ||
* | ||
* @return array | ||
*/ | ||
public function getProgramByParameters($eventId, $searchQuery, $order, $start, $length) | ||
{ | ||
$qb = $this->createQueryBuilder('p') | ||
->innerJoin('p.events', 'e'); | ||
|
||
if (count($order)) { | ||
for ($i = 0, $ien = count($order); $i < $ien; $i++) { | ||
switch ($order[$i]['column']) { | ||
case '0': | ||
$qb->addOrderBy('p.id', $order[$i]['dir']); | ||
break; | ||
case '1': | ||
$qb->addOrderBy('p.title', $order[$i]['dir']); | ||
break; | ||
case '2': | ||
$qb->addOrderBy('p.startDate', $order[$i]['dir']); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
$qb = $this->programQueryAddParams($qb, $eventId, $searchQuery); | ||
|
||
$qb->setFirstResult($start) | ||
->setMaxResults($length); | ||
|
||
return $qb->getQuery()->getResult(); | ||
} | ||
|
||
/** | ||
* @param integer $eventId | ||
* @param string $searchQuery | ||
* | ||
* @return array | ||
*/ | ||
public function getProgramCountByParameters($eventId, $searchQuery) | ||
{ | ||
$qb = $this->createQueryBuilder('p') | ||
->innerJoin('p.events', 'e') | ||
->select('COUNT(DISTINCT p.id)'); | ||
|
||
$qb = $this->programQueryAddParams($qb, $eventId, $searchQuery); | ||
|
||
return $qb->getQuery()->getSingleScalarResult(); | ||
} | ||
|
||
/** | ||
* @param QueryBuilder $qb | ||
* @param integer $eventId | ||
* @param string $searchQuery | ||
* | ||
* @return \Doctrine\ORM\QueryBuilder | ||
*/ | ||
protected function programQueryAddParams(QueryBuilder $qb, $eventId, $searchQuery) | ||
{ | ||
if ($searchQuery != '') { | ||
$qb->where($qb->expr()->like('LOWER(p.title)', ':query')); | ||
|
||
$qb->setParameter('query', '%'.mb_strtolower(trim($searchQuery), mb_detect_encoding($searchQuery)).'%'); | ||
} | ||
|
||
if ($eventId) { | ||
$qb->andWhere($qb->expr()->eq('e.id', ':eventId')) | ||
->setParameter('eventId', $eventId); | ||
} | ||
|
||
return $qb; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/Event/EventBundle/Resources/public/css/program/program.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.events-list { | ||
text-align: right; | ||
} | ||
|
||
#program_length select, #select-event { | ||
width: auto; | ||
} | ||
|
||
#program_wrapper table.dataTable thead th, | ||
#program_wrapper table.dataTable thead td { | ||
border-bottom: none; | ||
} | ||
|
||
#program_wrapper table.dataTable.no-footer { | ||
border-bottom: 1px solid #ddd; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/Event/EventBundle/Resources/public/js/program/program.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
$(function() { | ||
var $body = $('body'); | ||
|
||
/* calls list table */ | ||
var dataTable = $('#program').DataTable({ | ||
processing: false, | ||
serverSide: true, | ||
lengthMenu: [50, 100, 200, 300], | ||
order: [[2, 'asc']], | ||
pagingType: 'full_numbers', | ||
dom: "<'row'<'span3'l><'span6'f>r>t<'row'<'span3'i><'span6'p>>", | ||
ajax: { | ||
url: Routing.generate('backend_program_ajax_program_list'), | ||
data: function (d) { | ||
d.event = $('#select-event').val(); | ||
} | ||
}, | ||
language: { | ||
lengthMenu: "_MENU_ records per page", | ||
infoEmpty: '0 of 0 entries' | ||
}, | ||
createdRow: function(row, data, index) { | ||
$(row).attr('id', 'item-' + data[0]); | ||
}, | ||
columnDefs: [ | ||
{searchable: false, orderable: true, targets: 0, width: '5%'}, | ||
{searchable: true, orderable: true, targets: 1}, | ||
{searchable: false, orderable: true, targets: 2, width: '30%'}, | ||
{searchable: false, orderable: false, targets: 3, width: '10%', | ||
render: function(data, type, row) { | ||
return '\ | ||
<div class="btn-group">\ | ||
<a class="btn btn-small" href="' + data['editUrl'] + '"><i class="icon-edit"></i> Edit</a>\ | ||
<a class="btn btn-small dropdown-toggle actions-' + row[0] + '" data-toggle="dropdown" href="#"><span class="caret"></span></a>\ | ||
<ul class="dropdown-menu">\ | ||
<li><a href="' + data['deleteUrl'] + '" class="delete-call" id="modal-confirm-' + row[0] + '"><i class="icon-trash"></i> Delete</a></li>\ | ||
</ul>\ | ||
</div>\ | ||
'; | ||
} | ||
} | ||
] | ||
}); | ||
/* end calls list table */ | ||
|
||
$body.on('change', '#select-event', function() { | ||
dataTable.ajax.reload(); | ||
}); | ||
}); |
Oops, something went wrong.