diversen nav opmerkingen
This commit is contained in:
@@ -23,15 +23,22 @@ class Employeehour extends BaseModel {
|
||||
|
||||
public static function getEmployeehours( $month, $year )
|
||||
{
|
||||
$employeehours = Employeehour::whereRaw( "MONTH(hourdate) ={$month} AND YEAR(hourdate) = {$year}" )
|
||||
$employeehours = Employeehour::whereRaw( "MONTH(hourdate) = " . ( $month + 1 ) . " AND YEAR(hourdate) = {$year}" )
|
||||
->with( [
|
||||
'user' => function ( $q ) {
|
||||
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
|
||||
}] )
|
||||
->with( 'hourtype' )
|
||||
->get();
|
||||
->with( 'hourtype' );
|
||||
|
||||
return $employeehours;
|
||||
$projecthours = Employeehour::whereRaw("MONTH(hourdate) = " . ( $month + 1 ) . " AND YEAR(hourdate) = {$year}" )->with( [
|
||||
'user' => function ( $q ) {
|
||||
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
|
||||
}] )
|
||||
->with( 'hourtype' );
|
||||
|
||||
$results = $employeehours->union($projecthours)->get();
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public static function saveEmployeehour( $employeehourID, $data )
|
||||
|
||||
@@ -45,6 +45,16 @@ class User extends BaseModel {
|
||||
return $userrole;
|
||||
}
|
||||
|
||||
public static function getUserWithprojects()
|
||||
{
|
||||
$usersWithProjects =
|
||||
User::selectRaw( "users.id, CONCAT(users.firstname, ' ', users.middlename, ' ', users.lastname) AS fullname" )
|
||||
->with( 'projectemployees.project' )
|
||||
->get();
|
||||
|
||||
return $usersWithProjects;
|
||||
}
|
||||
|
||||
public static function checkUsername( $username )
|
||||
{
|
||||
$username = strtoupper( $username );
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 15/03/2018
|
||||
* Time: 10:47
|
||||
*/
|
||||
|
||||
class EmployeehoursMonthly {
|
||||
|
||||
public static function fire($month, $year, $employeeID)
|
||||
{
|
||||
$month = $month + 1;
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname,
|
||||
hourtype_id,
|
||||
EMH.id,
|
||||
USR.id AS employee_id,
|
||||
hours,
|
||||
DATE_FORMAT(hourdate, '%d-%m-%Y') AS hourdate,
|
||||
NULL AS project_id
|
||||
FROM employeehours EMH
|
||||
JOIN users USR
|
||||
ON USR.id = EMH.employee_id
|
||||
WHERE MONTH(hourdate) = {$month}
|
||||
AND YEAR(hourdate) = {$year} ";
|
||||
if( $employeeID != 0 ) $sql.="AND USR.id = {$employeeID} ";
|
||||
$sql.="
|
||||
UNION
|
||||
SELECT CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname,
|
||||
(SELECT id FROM hourtypes WHERE `key` = 'PROJECTS' LIMIT 1) AS hourtype_id,
|
||||
PRH.id,
|
||||
USR.id AS employee_id,
|
||||
hours,
|
||||
DATE_FORMAT(hourdate, '%d-%m-%Y') AS hourdate,
|
||||
PEM.project_id
|
||||
FROM projecthours PRH
|
||||
JOIN projectemployees PEM
|
||||
ON PEM.id = PRH.projectemployee_id
|
||||
JOIN users USR
|
||||
ON USR.id = PEM.user_id
|
||||
WHERE MONTH(hourdate) = {$month}
|
||||
AND YEAR(hourdate) = {$year} ";
|
||||
if( $employeeID != 0 ) $sql.="AND USR.id = {$employeeID} ";
|
||||
$sql.="
|
||||
) Q1
|
||||
ORDER BY fullname, hourdate ";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,20 @@ class Invoices_model extends MY_Model {
|
||||
|
||||
return $invoiced;
|
||||
}
|
||||
|
||||
public function getOutstandingPerProject( $projectID )
|
||||
{
|
||||
$this->sql = "
|
||||
SELECT (own_revenue + other_revenue) - SUM(INV.invoiceamount) AS outstanding
|
||||
FROM invoices INV
|
||||
JOIN projects PRJ
|
||||
ON PRJ.id = INV.project_id
|
||||
JOIN offers OFF
|
||||
ON PRJ.id = OFF.project_id
|
||||
WHERE PRJ.id = {$projectID} ";
|
||||
|
||||
$invoiced = $this->get_query_row( 'outstanding' );
|
||||
|
||||
return $invoiced;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user