projecten

This commit is contained in:
2018-01-23 08:45:44 +01:00
parent 970aa53971
commit fb19c401fd
36 changed files with 1402 additions and 184 deletions
@@ -36,6 +36,8 @@ class BaseModel extends Eloquent {
parent::boot();
static::creating( function ( $model ) {
static::$oldValue = '';
if ( AUTHENTICATED )
{
$user = User::find(USERID);
@@ -44,6 +46,8 @@ class BaseModel extends Eloquent {
}
} );
static::updating( function ( $model ) {
static::$oldValue = json_encode($model->original);
if ( AUTHENTICATED )
{
$user = User::find(USERID);
+3 -2
View File
@@ -29,13 +29,14 @@ class Customer extends BaseModel {
if( $customerID == 0)
{
$customer = Customer::create($customer);
$customerID = $customer['id'];
}
else
{
$customer = Customer::whereId($customerID)->update($customer);
Customer::whereId($customerID)->update($customer);
}
return $customer['id'];
return $customerID;
}
public static function removeCustomer($customerID)
+3 -2
View File
@@ -29,13 +29,14 @@ class External extends BaseModel {
if( $externalID == 0)
{
$external = External::create($external);
$externalID = $external['id'];
}
else
{
$external = External::whereId($externalID)->update($external);
External::whereId($externalID)->update($external);
}
return $external['id'];
return $externalID;
}
public static function removeExternal($externalID)
+23 -1
View File
@@ -8,11 +8,33 @@
class Payment extends BaseModel {
protected $table = "projects";
protected $table = "payments";
public function offer()
{
return $this->belongsTo( 'Offer' );
}
public static function savePayment( $paymentID, $payment )
{
$payment = (array) $payment;
if ( $paymentID == 0 )
{
$payment = Payment::create( $payment );
$paymentID = $payment['id'];
}
else
{
Payment::whereId( $paymentID )->update( $payment );
}
return $paymentID;
}
public static function removePayment( $paymentID )
{
Payment::whereId( $paymentID )->delete();
}
}
+22 -3
View File
@@ -68,7 +68,7 @@ class Project extends BaseModel {
'offers' => function ( $q ) {
$q->whereArchive( 'F' )
->with( [
'payment' => function ( $q ) {
'payments' => function ( $q ) {
$q->selectRaw( '*' );
}] );
}] )
@@ -76,6 +76,7 @@ class Project extends BaseModel {
'projectemployees.user' => function ( $q ) {
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
}] )
->with( 'projectemployees.projecthours' )
->with( 'customer' );
return $project;
@@ -83,10 +84,28 @@ class Project extends BaseModel {
public static function createProject()
{
$data = ['startdate'=> date('Y-m-d')];
$data = ['startdate' => date( 'Y-m-d' )];
$project = Project::create($data);
$project = Project::create( $data );
return $project->id;
}
public static function saveProject( $projectID, $project )
{
$project = (array) $project;
if ( $projectID == 0 )
{
$project = Project::create( $project );
$projectID = $project['id'];;
}
else
{
Project::whereId( $projectID )->update( $project );
}
return $projectID;
}
}
@@ -18,6 +18,11 @@ class Projectemployee extends BaseModel {
return $this->belongsTo( 'User' );
}
public function projecthours()
{
return $this->hasMany( 'Projecthour' );
}
public static function createProjectEmployee( $projectID )
{
$projectemployee = Projectemployee::create( [
@@ -27,4 +32,15 @@ class Projectemployee extends BaseModel {
return $projectemployee->id;
}
public static function saveProjectemployee( $projectemployeeID, $projectemployee )
{
Projectemployee::whereId( $projectemployeeID )
->update( $projectemployee );
}
public static function removeProjectemployee( $projectemployeeID )
{
Projectemployee::whereId( $projectemployeeID )->delete();
}
}
@@ -0,0 +1,41 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 19/01/2018
* Time: 15:51
*/
class Projecthour extends BaseModel {
protected $table = "projecthours";
public function projectemployee()
{
$this->belongsTo( 'Projectemployee' );
}
public static function saveProjecthour( $projecthourID, $projecthour )
{
$projecthour = (array) $projecthour;
if ( $projecthourID == 0 )
{
$projecthour = Projecthour::create( $projecthour );
$projecthourID = $projecthour['id'];
}
else
{
Projecthour::whereId( $projecthourID )->update( $projecthour );
}
return $projecthourID;
}
public static function removeProjecthour( $projecthourID )
{
Projecthour::whereId( $projecthourID )->delete();
}
}
+3 -2
View File
@@ -53,13 +53,14 @@ class User extends BaseModel {
if ( $userID == 0 )
{
$user = User::create( $user );
$userID = $user['id'];
}
else
{
$user = User::whereId( $userID )->update( $user );
User::whereId( $userID )->update( $user );
}
return $user['id'];
return $userID;
}
public static function removeUser( $userID )