invoice report
This commit is contained in:
@@ -54,4 +54,15 @@ class EmployeeHoursController extends MY_Controller {
|
||||
$this->json( $result );
|
||||
}
|
||||
|
||||
public function getInvoiceOverview( $year )
|
||||
{
|
||||
$sql = Qinvoiceoverview::fire( $year );
|
||||
|
||||
$query = $this->db->query( $sql );
|
||||
|
||||
$result = $query->result();
|
||||
|
||||
$this->json( $result );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,8 +30,9 @@ class QEmployeeHours {
|
||||
0 AS revenues,
|
||||
SUM(hours) AS nonprojecthours
|
||||
FROM employeehours
|
||||
WHERE YEAR(hourdate) = '{$year}'
|
||||
AND MONTH(hourdate) = '$month'
|
||||
WHERE YEAR(hourdate) = '{$year}' ";
|
||||
if( $month != 0 ) $sql .= "AND MONTH(hourdate) = '$month' ";
|
||||
$sql .= "
|
||||
GROUP BY employee_id, MONTH(hourdate)
|
||||
UNION
|
||||
SELECT PEM.user_id,
|
||||
@@ -44,13 +45,14 @@ class QEmployeeHours {
|
||||
FROM projecthours PH
|
||||
JOIN projectemployees PEM
|
||||
ON PEM.id = PH.projectemployee_id
|
||||
WHERE YEAR(hourdate) = '{$year}'
|
||||
AND MONTH(hourdate) = '$month'
|
||||
WHERE YEAR(hourdate) = '{$year}' ";
|
||||
if( $month != 0 ) $sql .= "AND MONTH(hourdate) = '$month' ";
|
||||
$sql .= "
|
||||
GROUP BY PEM.user_id, MONTH(hourdate)
|
||||
) AS Q1
|
||||
JOIN users AS USR
|
||||
ON USR.id = Q1.user_id
|
||||
GROUP BY monthID, user_id ";
|
||||
GROUP BY user_id ";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 02/03/2018
|
||||
* Time: 15:56
|
||||
*/
|
||||
|
||||
class Qinvoiceoverview {
|
||||
|
||||
|
||||
public static function fire( $year )
|
||||
{
|
||||
$sql = "
|
||||
SELECT PRJ.id, PRJ.projectnumber,
|
||||
PRJ.projectname,
|
||||
(own_revenue + other_revenue ) AS revenues,
|
||||
CUS.name AS customername,
|
||||
IF( YEAR(invoicedate) = {$year},SUM(invoiceamount), 0) AS currentyear,
|
||||
IF( YEAR(invoicedate) != {$year},SUM(invoiceamount), 0) AS otheryear,
|
||||
COALESCE(Q1.currentyearpayed, 0) AS currentyearpayed,
|
||||
COALESCE(Q1.otheryearpayed, 0) AS otheryearpayed,
|
||||
CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname
|
||||
FROM invoices INV
|
||||
RIGHT JOIN projects PRJ
|
||||
ON PRJ.id = INV.project_id
|
||||
JOIN offers OFF
|
||||
ON PRJ.id = OFF.project_id
|
||||
JOIN customers CUS
|
||||
ON CUS.id = PRJ.customer_id
|
||||
JOIN users USR
|
||||
ON USR.id = PRJ.projectleader_id
|
||||
LEFT JOIN (
|
||||
SELECT invoice_id,
|
||||
SUM(IF(YEAR(paymentdate) = {$year},paymentamount, 0)) AS currentyearpayed,
|
||||
SUM(IF(YEAR(paymentdate) != {$year},paymentamount, 0)) AS otheryearpayed
|
||||
FROM payments
|
||||
GROUP BY invoice_id
|
||||
) AS Q1
|
||||
ON INV.id = Q1.invoice_id
|
||||
GROUP BY PRJ.projectnumber, PRJ.projectname ";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<div id="OUTGOINGINVOICES">
|
||||
<div class="row">
|
||||
<div class="col-xl-1">
|
||||
<label>jaar</label>
|
||||
</div>
|
||||
<div class="col-xl-3">
|
||||
<select class="form-control form-control-sm"
|
||||
data-bind="options:years,
|
||||
optionsText:'year',
|
||||
optionsValue: 'id',
|
||||
value:selectedYear,
|
||||
event:{change:refreshInvoiceDetails}"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<table class="table table-condensed" style="font-size:0.8em;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="rotate">
|
||||
<div><span>project</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>klant</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>status afgehandeld</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>projectleider</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>te factureren(excl btw)</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>te factureren(incl btw)</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>gefactureerd voorgaande jaren(incl btw)</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>gefactureerd lopend jaar(incl btw)</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>totaal gefactureerd(incl btw)</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>betaald voorgaande jaren</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>betaald lopend jaar</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>totaal betaald</span></div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- ko foreach: projects -->
|
||||
<tr>
|
||||
<td><span data-bind="text:projectnumber"></span></td>
|
||||
<td><span data-bind="text:customername"></span></td>
|
||||
<td><span data-bind="text:statusProject == 'CLOSED' ? 'afgesloten' : 'open'"></span></td>
|
||||
<td><span data-bind="text:fullname"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:openstaand"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:openstaandIncl"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:invoicedOtherYears"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:invoicedCurentYear"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:totalInvoiced"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:invoicedOtherYearsPayed"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:invoicedCurentYearPayed"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:totalInvoicedPayed"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- /ko -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -71,6 +71,7 @@
|
||||
<script src="js/lib/modules/projects/employeehoursModule.js?version=<?= $this->version ?>"></script>
|
||||
<script src="js/lib/modules/reports/monthlyEmployeeHoursModule.js?version=<?= $this->version ?>"></script>
|
||||
<script src="js/lib/modules/reports/employeeHours.js?version=<?= $this->version ?>"></script>
|
||||
<script src="js/lib/modules/reports/outgoingInvoices.js?version=<?= $this->version ?>"></script>
|
||||
|
||||
<!-- ***********MODALS************* -->
|
||||
|
||||
@@ -98,6 +99,7 @@
|
||||
<script src="js/lib/dataservices/vatDataservice.js"></script>
|
||||
<script src="js/lib/dataservices/employeehoursDataService.js"></script>
|
||||
<script src="js/lib/dataservices/reportsDataService.js"></script>
|
||||
<script src="js/lib/dataservices/invoiceDataService.js"></script>
|
||||
|
||||
<script src="js/lib/services/chartService.js"></script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user