Skip to content

Instantly share code, notes, and snippets.

View codecowboy's full-sized avatar

Luke Mackenzie codecowboy

  • UK
View GitHub Profile
@codecowboy
codecowboy / gist:1229314
Created September 20, 2011 14:56
User Entity
<?php
namespace Gymloop\CoreBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
@codecowboy
codecowboy / gist:1200738
Created September 7, 2011 14:36
daysBetween
<script type="text/javascript" src="{{ asset('js/admin/util.js') }}"></script>
<script type="text/javascript">
var GymloopAdmin = function() {
var today = new Date(),
userTargets = [], //contains total target sessions & target sessions to date per programme per user
count = parseInt({{ users | length }},10);
var totalTargetSessions = function(startDate, endDate, weeklyTarget) {
@codecowboy
codecowboy / gist:1190852
Created September 3, 2011 08:19
tooltips
$tdCollection = $('td[class*="fc-day"]');
$.each($tdCollection,function(key,elem){
if($(elem).hasClass('pending') || $(elem).hasClass('confirmed') ) {
$(elem).wijtooltip({
content:'Click to delete session',
position: {my: "left bottom", at:"left bottom"}
});
} else {
$(elem).wijtooltip({
@codecowboy
codecowboy / gist:1186513
Created September 1, 2011 16:06
Array result
$query = $this->getEntityManager()->createQuery('
SELECT COUNT(s) FROM GymloopDiaryBundle:TrainingSession s
WHERE s.status = :completed
AND s.user = :user')
->setParameter('user',$user)
->setParameter('completed','confirmed');
$result = $query->getResult();
array(1) { [0]=> array(1) { [1]=> string(1) "0" } }
@codecowboy
codecowboy / gist:1185908
Created September 1, 2011 10:34
Get users for admin
public function findUserAdminDetails()
{
$query = $this->getEntityManager()->createQuery('
SELECT u, p, m
FROM GymloopCoreBundle:User u
JOIN u.programmes p
JOIN u.motivation m
');
$result = $query->getArrayResult(); var_dump($result); exit;
@codecowboy
codecowboy / gist:1185861
Created September 1, 2011 09:59
Motivation Entity
<?php
namespace Gymloop\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Gymloop\CoreBundle\Entity\Motivation
*
* @ORM\Table(name="gymloop_motivation")
@codecowboy
codecowboy / gist:1185843
Created September 1, 2011 09:49
Motivation repository
<?php
namespace Gymloop\CoreBundle\Entity;
use Doctrine\ORM\EntityRepository;
/**
* MotivationRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
@codecowboy
codecowboy / gist:1185840
Created September 1, 2011 09:48
User Entity
<?php
namespace Gymloop\CoreBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
$('.fc-day-number').each(function(){
lDay = parseInt($(this).text());
//check if it is another month date
if($(this).parents('td').hasClass('fc-other-month'))
{
lYear = parseInt(cYear);
//if it is belong to the previous month
if(lDay>15)
{
lMonth = parseInt(cMonth) - 1;
if($request->isXmlHttpRequest()) {
if (isset($date)) {
$date = date_create_from_format('y-m-d', $date);
//remove the training session row from the db for this user
$user = $this->get('security.context')->getToken()->getUser();
$em = $this->getDoctrine()->getEntityManager();
$query = $em->createQuery('SELECT ts from GymloopDiaryBundle:TrainingSession ts
WHERE ts.user = :user AND CAST(ts.date as DATE) = :date')
->setParameter('user', $user)