Created
February 5, 2013 10:35
-
-
Save jblac/4713617 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$rsm = new ResultSetMapping(); | |
$rsm->addScalarResult('postDate', 'postDate'); | |
$rsm->addScalarResult('company_name', 'company_name'); | |
$rsm->addScalarResult('postDatesScheduled', 'postDatesScheduled'); | |
$rsm->addScalarResult('postDateReady', 'postDateReady'); | |
$rsm->addScalarResult('postDatesCharged', 'postDatesCharged'); | |
$rsm->addScalarResult('postDatesComplete', 'postDatesComplete'); | |
$rsm->addScalarResult('fwPotential', 'fwPotential'); | |
$rsm->addScalarResult('fwCharged', 'fwCharged'); | |
$rsm->addScalarResult('fwCapt', 'fwCapt'); | |
$dql = "SELECT p.postDate, co.company_name, | |
COUNT(*) AS `postDatesScheduled`, | |
COUNT(IF(c.postDateChargedStatus_id > 1, 1, NULL)) AS `postDateReady`, | |
SUM( IF(c.postDateChargedStatus_id = 6, 1, NULL)) AS `postDatesCharged`, | |
SUM( IF(c.`fwCompletionDate`, 1, NULL)) AS `postDatesComplete`, | |
SUM( authOnlyAmount ) AS `fwPotential`, | |
SUM( IF(p.`fwfAuthed`, p.`authOnlyAmount`, NULL)) AS `fwCharged`, | |
SUM( IF(c.`fwCompletionDate`, p.`authOnlyAmount`, NULL)) AS `fwCapt` | |
FROM customer c | |
JOIN Purchase p ON p.customer_Id = c.Id | |
JOIN User u on c.salesRep_Id = u.Id | |
JOIN Company co on c.salesCompany_Id = co.Id | |
WHERE c.`saleType_Id` = 2".$comp." | |
AND p.postDate BETWEEN :beg AND :fin | |
GROUP BY p.postDate, c.salesCompany_Id | |
ORDER BY p.postDate ASC"; | |
$query = $this->em->createNativeQuery($dql, $rsm); | |
$query->setParameters(array( | |
'beg' => $startDate, | |
'fin' => $endDate | |
)); | |
$data = $query->getArrayResult(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment