Diversen opmerkingen Peter (23-08-2019)

This commit is contained in:
2019-09-12 20:16:57 +02:00
parent f5b815d34d
commit b49fb957a3
17 changed files with 1194 additions and 1094 deletions
@@ -53,6 +53,13 @@ class usersController extends MY_Controller {
$this->json( $usersWithProjects );
}
public function getUserActiveProjects($userID)
{
$userActiveProjects = User::getUserActiveProjects($userID);
$this->json( $userActiveProjects );
}
public function getUniqueprojectEmployees()
{
$projectEmployees = User::getUniqueProjectUsers();
@@ -136,4 +143,4 @@ class usersController extends MY_Controller {
$this->email->send();
}
}
}
@@ -9,363 +9,365 @@ defined( 'BASEPATH' ) OR exit( 'No direct script access allowed' );
*/
class ProjectsController extends MY_Controller {
public function __construct()
{
parent::__construct();
public function __construct()
{
parent::__construct();
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
$models = ['projects/Invoices_model'];
$libraries = [];
$models = ['projects/Invoices_model'];
$libraries = [];
$this->load->model( $models );
$this->load->library( $libraries );
}
$this->load->model( $models );
$this->load->library( $libraries );
}
public function index()
{
public function index()
{
}
}
public function getAllProjects()
{
$archive = $this->clean_input( 'archive' );
$search = $this->clean_input( 'search' );
$order = $this->clean_input( 'order' );
$direction = $this->clean_input( 'direction' );
public function getAllProjects()
{
$archive = $this->clean_input( 'archive' );
$search = $this->clean_input( 'search' );
$order = $this->clean_input( 'order' );
$direction = $this->clean_input( 'direction' );
$projects = Project::getAllProjects( $archive, $search, $order, $direction );
$projects = Project::getAllProjects( $archive, $search, $order, $direction );
$this->json( $projects );
}
$this->json( $projects );
}
public function getProject( $projectID )
{
$project = Project::getProject( $projectID );
public function getProject( $projectID )
{
$project = Project::getProject( $projectID );
$project->invoiceDetails =
$this->Invoices_model->getOutstandingPerProject( $project->id );
$project->invoiceDetails =
$this->Invoices_model->getOutstandingPerProject( $project->id );
$project->hourTotals =
Projecthour::getTotalHoursPerProject( $project->id );
$project->hourTotals =
Projecthour::getTotalHoursPerProject( $project->id );
$this->json( $project );
}
$this->json( $project );
}
public function getAvailableEmployees( $projectID )
{
$availableEmployees =
Projectemployee::getAvailableEmployees( $projectID );
public function getAvailableEmployees( $projectID )
{
$availableEmployees =
Projectemployee::getAvailableEmployees( $projectID );
$this->json( $availableEmployees );
}
$this->json( $availableEmployees );
}
public function addProject()
{
$projectID = Project::createProject();
public function addProject()
{
$projectID = Project::createProject();
$this->json( $projectID );
}
$this->json( $projectID );
}
public function creatProjectFromOffer( $offerID )
{
$offer = Offer::find( $offerID );
public function creatProjectFromOffer( $offerID )
{
$offer = Offer::find( $offerID );
$offernumber = $offer->offernumber;
$offernumber = $offer->offernumber;
$projectnumber = 'P' . substr( $offernumber, 1 );
$projectnumber = 'P' . substr( $offernumber, 1 );
$data = [
'projectnumber' => $projectnumber,
'projectname' => $offer->offername,
'projectleader_id' => $offer->offerleader_id,
'startdate' => $offer->accepteddate,
'customer_id' => $offer->customer_id
];
$data = [
'projectnumber' => $projectnumber,
'projectname' => $offer->offername,
'projectleader_id' => $offer->offerleader_id,
'startdate' => $offer->accepteddate,
'customer_id' => $offer->customer_id
];
$project = Project::create( $data );
$project = Project::create( $data );
Offer::whereId( $offerID )->update( ['project_id' => $project->id] );
Offer::whereId( $offerID )->update( ['project_id' => $project->id] );
Projectemployee::firstOrCreateProjectemployee( $offer->offerleader_id, $project->id );
Projectemployee::firstOrCreateProjectemployee( $offer->offerleader_id, $project->id );
$offerteHours = Employeehour::whereOfferId( $offerID )->get();
foreach ( $offerteHours as $offerteHour )
{
$projectemployee =
Projectemployee::firstOrCreateProjectemployee( $offerteHour->employee_id, $project->id );
$offerteHours = Employeehour::whereOfferId( $offerID )->get();
foreach ( $offerteHours as $offerteHour )
{
$projectemployee =
Projectemployee::firstOrCreateProjectemployee( $offerteHour->employee_id, $project->id );
$data = [
'projectemployee_id' => $projectemployee->id,
'hourtype_id' => 10,
'hourdate' => $offerteHour->hourdate,
'hours' => $offerteHour->hours
];
$data = [
'projectemployee_id' => $projectemployee->id,
'hourtype_id' => 10,
'hourdate' => $offerteHour->hourdate,
'hours' => $offerteHour->hours
];
Projecthour::create( $data );
Projecthour::create( $data );
Employeehour::whereId( $offerteHour->id )->delete();
}
Employeehour::whereId( $offerteHour->id )->delete();
}
$this->json( ['success' => TRUE, 'projectnumber' => $projectnumber] );
}
$this->json( ['success' => TRUE, 'projectnumber' => $projectnumber] );
}
public function addProjectEmployee( $projectID )
{
Projectemployee::createProjectEmployee( $projectID );
}
public function addProjectEmployee( $projectID )
{
Projectemployee::createProjectEmployee( $projectID );
}
public function saveProject()
{
$projectValidation = new ProjectValidation();
public function saveProject()
{
$projectValidation = new ProjectValidation();
if ( ! $projectValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $projectValidation->getErrorMessages()] );
if ( ! $projectValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $projectValidation->getErrorMessages()] );
$project = $this->input->post();
$project = $this->input->post();
$projectID = $project['id'];
unset( $project['id'] );
$projectID = $project['id'];
unset( $project['id'] );
$project['startdate'] = date2mysql( $project['startdate'] );
$project['enddate'] = date2mysql( $project['enddate'] );
$project['startdate'] = date2mysql( $project['startdate'] );
$project['enddate'] = date2mysql( $project['enddate'] );
$projectID = Project::saveProject( $projectID, $project );
$projectID = Project::saveProject( $projectID, $project );
$this->json( ['success' => TRUE, 'projectID' => $projectID] );
}
Offer::syncProjectname( $projectID );
public function saveProjectemployee()
{
$projectemployeeValidation = new ProjectemployeeValidation();
$this->json( ['success' => TRUE, 'projectID' => $projectID] );
}
if ( ! $projectemployeeValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $projectemployeeValidation->getErrorMessages()] );
public function saveProjectemployee()
{
$projectemployeeValidation = new ProjectemployeeValidation();
$projectemployee = $this->input->post();
if ( ! $projectemployeeValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $projectemployeeValidation->getErrorMessages()] );
$projectemployeeID = $projectemployee['id'];
unset( $projectemployee['id'] );
$projectemployee = $this->input->post();
Projectemployee::saveProjectemployee( $projectemployeeID, $projectemployee );
$projectemployeeID = $projectemployee['id'];
unset( $projectemployee['id'] );
$this->json( ['success' => TRUE] );
}
Projectemployee::saveProjectemployee( $projectemployeeID, $projectemployee );
public function saveInvoice()
{
$invoiceValidation = new InvoiceValidation();
$this->json( ['success' => TRUE] );
}
if ( ! $invoiceValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $invoiceValidation->getErrorMessages()] );
public function saveInvoice()
{
$invoiceValidation = new InvoiceValidation();
$invoice = $this->input->post();
if ( ! $invoiceValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $invoiceValidation->getErrorMessages()] );
$invoiceID = $invoice['id'];
unset( $invoice['id'] );
$invoice = $this->input->post();
$invoice['invoicedate'] = date2mysql( $invoice['invoicedate'] );
$invoice['forecastdate'] = date2mysql( $invoice['forecastdate'] );
$invoice['invoiceamount'] = str_replace( ',', '.', $invoice['invoiceamount'] );
$invoice['forecastamount'] = str_replace( ',', '.', $invoice['forecastamount'] );
$invoiceID = $invoice['id'];
unset( $invoice['id'] );
$invoiceID = Invoice::saveInvoice( $invoiceID, $invoice );
$invoice['invoicedate'] = date2mysql( $invoice['invoicedate'] );
$invoice['forecastdate'] = date2mysql( $invoice['forecastdate'] );
$invoice['invoiceamount'] = str_replace( ',', '.', $invoice['invoiceamount'] );
$invoice['forecastamount'] = str_replace( ',', '.', $invoice['forecastamount'] );
$this->json( ['success' => TRUE, 'invoiceID' => $invoiceID] );
}
$invoiceID = Invoice::saveInvoice( $invoiceID, $invoice );
public function savePayment()
{
$paymentValidation = new PaymentValidation();
$this->json( ['success' => TRUE, 'invoiceID' => $invoiceID] );
}
if ( ! $paymentValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $paymentValidation->getErrorMessages()] );
public function savePayment()
{
$paymentValidation = new PaymentValidation();
$payment = $this->input->post();
if ( ! $paymentValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $paymentValidation->getErrorMessages()] );
$paymentID = $payment['id'];
unset( $payment['id'] );
$payment = $this->input->post();
$payment['paymentdate'] = date2mysql( $payment['paymentdate'] );
$payment['paymentamount'] = str_replace( ',', '.', $payment['paymentamount'] );
$paymentID = $payment['id'];
unset( $payment['id'] );
$paymentID = Payment::savePayment( $paymentID, $payment );
$payment['paymentdate'] = date2mysql( $payment['paymentdate'] );
$payment['paymentamount'] = str_replace( ',', '.', $payment['paymentamount'] );
$this->json( ['success' => TRUE, 'paymentID' => $paymentID] );
}
$paymentID = Payment::savePayment( $paymentID, $payment );
public function saveProjectcost()
{
$projectcostValidation = new ProjectcostValidation();
$this->json( ['success' => TRUE, 'paymentID' => $paymentID] );
}
if ( ! $projectcostValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $projectcostValidation->getErrorMessages()] );
public function saveProjectcost()
{
$projectcostValidation = new ProjectcostValidation();
$projectcost = $this->input->post();
if ( ! $projectcostValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $projectcostValidation->getErrorMessages()] );
$projectcostID = $projectcost['id'];
unset( $projectcost['id'] );
$projectcost = $this->input->post();
$projectcost['date'] = date2mysql( $projectcost['date'] );
$projectcostID = $projectcost['id'];
unset( $projectcost['id'] );
$projectcostID = Projectcost::saveProjectcost( $projectcostID, $projectcost );
$projectcost['date'] = date2mysql( $projectcost['date'] );
$this->json( ['success' => TRUE, 'projectcostID' => $projectcostID] );
}
$projectcostID = Projectcost::saveProjectcost( $projectcostID, $projectcost );
public function saveProjecthour()
{
$projecthourValidation = new ProjecthourValidation();
$this->json( ['success' => TRUE, 'projectcostID' => $projectcostID] );
}
if ( ! $projecthourValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $projecthourValidation->getErrorMessages()] );
public function saveProjecthour()
{
$projecthourValidation = new ProjecthourValidation();
$projecthour = $this->input->post();
if ( ! $projecthourValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $projecthourValidation->getErrorMessages()] );
$projecthourID = $projecthour['id'];
unset( $projecthour['id'] );
$projecthour = $this->input->post();
$projecthour['hourdate'] = date2mysql( $projecthour['hourdate'] );
$projecthourID = $projecthour['id'];
unset( $projecthour['id'] );
$paymentID = Projecthour::saveProjecthour( $projecthourID, $projecthour );
$projecthour['hourdate'] = date2mysql( $projecthour['hourdate'] );
$this->json( ['success' => TRUE, 'projecthourID' => $paymentID] );
}
$paymentID = Projecthour::saveProjecthour( $projecthourID, $projecthour );
public function saveForecast()
{
$forecastValidation = new ForecastValidation();
$this->json( ['success' => TRUE, 'projecthourID' => $paymentID] );
}
if ( ! $forecastValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $forecastValidation->getErrorMessages()] );
public function saveForecast()
{
$forecastValidation = new ForecastValidation();
$forecast = $this->input->post();
if ( ! $forecastValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $forecastValidation->getErrorMessages()] );
$forecastID = $forecast['id'];
unset( $forecast['id'] );
$forecast = $this->input->post();
$forecastID = Forecast::saveForecast( $forecastID, $forecast );
$forecastID = $forecast['id'];
unset( $forecast['id'] );
$this->json( ['success' => TRUE, 'forecastID' => $forecastID] );
}
$forecastID = Forecast::saveForecast( $forecastID, $forecast );
public function saveReservation()
{
$reservationValidation = new ReservationValidation();
$this->json( ['success' => TRUE, 'forecastID' => $forecastID] );
}
if ( ! $reservationValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $reservationValidation->getErrorMessages()] );
public function saveReservation()
{
$reservationValidation = new ReservationValidation();
$reservation = $this->input->post();
if ( ! $reservationValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $reservationValidation->getErrorMessages()] );
$reservationID = $reservation['id'];
unset( $reservation['id'] );
$reservation = $this->input->post();
$reservationID = Reservation::saveReservation( $reservationID, $reservation );
$reservationID = $reservation['id'];
unset( $reservation['id'] );
$this->json( ['success' => TRUE, 'reservationID' => $reservationID] );
}
$reservationID = Reservation::saveReservation( $reservationID, $reservation );
public function archiveProject( $projectID, $status )
{
Project::whereId( $projectID )->update( ['archive' => $status] );
}
$this->json( ['success' => TRUE, 'reservationID' => $reservationID] );
}
public function removeProjectemployee( $projectemployeeID )
{
$removeProjectemployee = new RemoveProjectemployee( $projectemployeeID );
public function archiveProject( $projectID, $status )
{
Project::whereId( $projectID )->update( ['archive' => $status] );
}
if ( $removeProjectemployee->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] );
public function removeProjectemployee( $projectemployeeID )
{
$removeProjectemployee = new RemoveProjectemployee( $projectemployeeID );
Projectemployee::removeProjectemployee( $projectemployeeID );
if ( $removeProjectemployee->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] );
$this->json( ['result' => TRUE] );
}
Projectemployee::removeProjectemployee( $projectemployeeID );
public function removeInvoice( $invoiceID )
{
$removeInvoice = new RemoveInvoice( $invoiceID );
$this->json( ['result' => TRUE] );
}
if ( $removeInvoice->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] );
public function removeInvoice( $invoiceID )
{
$removeInvoice = new RemoveInvoice( $invoiceID );
Invoice::whereId( $invoiceID )->delete();
if ( $removeInvoice->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] );
return $this->json( ['result' => TRUE] );
}
Invoice::whereId( $invoiceID )->delete();
public function removeIncomingInvoice( $invoiceID )
{
return $this->json( ['result' => TRUE] );
}
public function removeIncomingInvoice( $invoiceID )
{
// $removeInvoice = new RemoveInvoice( $invoiceID );
//
// if ( $removeInvoice->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] );
Projectcost::whereId( $invoiceID )->delete();
Projectcost::whereId( $invoiceID )->delete();
return $this->json( ['result' => TRUE] );
}
return $this->json( ['result' => TRUE] );
}
public function removePayment( $paymentID )
{
$removePayment = new RemovePayment( $paymentID );
public function removePayment( $paymentID )
{
$removePayment = new RemovePayment( $paymentID );
if ( $removePayment->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
if ( $removePayment->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
Payment::removePayment( $paymentID );
Payment::removePayment( $paymentID );
$this->json( ['result' => TRUE] );
}
$this->json( ['result' => TRUE] );
}
public function removeProjecthour( $projecthourID )
{
$removeProjecthour = new RemoveProjecthour( $projecthourID );
public function removeProjecthour( $projecthourID )
{
$removeProjecthour = new RemoveProjecthour( $projecthourID );
if ( $removeProjecthour->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
if ( $removeProjecthour->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
Projecthour::removeProjecthour( $projecthourID );
Projecthour::removeProjecthour( $projecthourID );
$this->json( ['result' => TRUE] );
}
$this->json( ['result' => TRUE] );
}
public function removeForecast( $forecastID )
{
$removeForecast = new RemoveForecast( $forecastID );
public function removeForecast( $forecastID )
{
$removeForecast = new RemoveForecast( $forecastID );
if ( $removeForecast->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
if ( $removeForecast->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
Forecast::removeForecast( $forecastID );
Forecast::removeForecast( $forecastID );
$this->json( ['result' => TRUE] );
}
$this->json( ['result' => TRUE] );
}
public function removeReservation( $reservationID )
{
$removeReservation = new RemoveReservation( $reservationID );
public function removeReservation( $reservationID )
{
$removeReservation = new RemoveReservation( $reservationID );
if ( $removeReservation->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
if ( $removeReservation->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
Reservation::removeReservation( $reservationID );
Reservation::removeReservation( $reservationID );
$this->json( ['result' => TRUE] );
}
$this->json( ['result' => TRUE] );
}
public function removeProject( $projectID )
{
$removeProject = new RemoveProject( $projectID );
public function removeProject( $projectID )
{
$removeProject = new RemoveProject( $projectID );
if ( $removeProject->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] );
if ( $removeProject->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] );
Project::removeProject( $projectID );
Project::removeProject( $projectID );
$this->json( ['result' => TRUE] );
}
$this->json( ['result' => TRUE] );
}
}
+2 -2
View File
@@ -16,7 +16,7 @@ class MY_Controller extends CI_Controller {
{
parent::__construct();
$this->version = '1.00.06';
$this->version = '1.00.10';
$this->load->library( 'beheer/session/RetrieveUserSession' );
@@ -65,4 +65,4 @@ class MY_Controller extends CI_Controller {
}
}
}
+69 -55
View File
@@ -9,76 +9,90 @@
class Offer extends BaseModel {
protected $table = "offers";
protected $table = "offers";
public function payments()
{
return $this->hasMany( 'Payment' );
}
public function payments()
{
return $this->hasMany( 'Payment' );
}
public function project()
{
return $this->belongsTo( 'Project' );
}
public function project()
{
return $this->belongsTo( 'Project' );
}
public function customer()
{
return $this->belongsTo( 'Customer' );
}
public function customer()
{
return $this->belongsTo( 'Customer' );
}
public static function getAllOffers( $projectID, $archive = 'F', $search, $order, $direction )
{
$offers = Offer::selectRAW('offers.*')
->join('customers AS CUS', 'CUS.id', '=', 'offers.customer_id')
->with( 'customer' )
->with( 'project' )
->where('offernumber', 'LIKE', "%{$search}%")
->orderBy($order, $direction);
public static function getAllOffers( $projectID, $archive = 'F', $search, $order, $direction )
{
$offers = Offer::selectRAW( 'offers.*' )
->join( 'customers AS CUS', 'CUS.id', '=', 'offers.customer_id' )
->with( 'customer' )
->with( 'project' )
->where( 'offernumber', 'LIKE', "%{$search}%" )
->orderBy( $order, $direction );
if ( $projectID ) $offers = $offers->whereProjectId( $projectID );
if ( $projectID ) $offers = $offers->whereProjectId( $projectID );
if ( $archive == 'F' ) $offers = $offers->where( 'offers.archive', '=', 'F' );
if ( $archive == 'F' ) $offers = $offers->where( 'offers.archive', '=', 'F' );
$offers = $offers->get();
$offers = $offers->get();
return $offers;
}
return $offers;
}
public static function getOffersWithoutProject( )
{
$offersWithoutProject = Offer::orderBy('startdate')
public static function getOffersWithoutProject()
{
$offersWithoutProject = Offer::orderBy( 'startdate' )
// ->whereNull('rejectdate')
// ->whereNull('project_id')
->whereArchive('F')
->get();
->whereArchive( 'F' )
->get();
return $offersWithoutProject;
}
return $offersWithoutProject;
}
public static function saveOffer( $offerID, $offer )
{
$offer = (array) $offer;
public static function saveOffer( $offerID, $offer )
{
$offer = (array) $offer;
$offer['startdate'] = date2mysql( $offer['startdate'] );
$offer['accepteddate'] = date2mysql( $offer['accepteddate'] );
$offer['rejectdate'] = date2mysql( $offer['rejectdate'] );
$offer['startdate'] = date2mysql( $offer['startdate'] );
$offer['accepteddate'] = date2mysql( $offer['accepteddate'] );
$offer['rejectdate'] = date2mysql( $offer['rejectdate'] );
if ( $offerID == 0 )
{
$offer = Offer::create( $offer );
if ( $offerID == 0 )
{
$offer = Offer::create( $offer );
$offerID = $offer['id'];
}
else
{
Offer::whereId( $offerID )->update( $offer );
}
$offerID = $offer['id'];
}
else
{
Offer::whereId( $offerID )->update( $offer );
return $offerID;
}
$offer = self::find( $offerID );
public static function removeOffer( $offerID )
{
Offer::whereId( $offerID )->delete();
}
}
if ( ! is_null( $offer->project_id ) ) Project::syncOffername( $offer );
}
return $offerID;
}
public static function syncProjectname( $projectID )
{
$project = Project::find( $projectID );
$offer = self::find( $projectID );
$offer->offername = $project->projectname;
$offer->save();
}
public static function removeOffer( $offerID )
{
Offer::whereId( $offerID )->delete();
}
}
+133 -128
View File
@@ -9,169 +9,174 @@
class Project extends BaseModel {
protected $table = "projects";
protected $table = "projects";
public function offers()
{
return $this->hasMany( 'Offer' );
}
public function offers()
{
return $this->hasMany( 'Offer' );
}
public function offer()
{
return $this->hasOne( 'Offer' );
}
public function offer()
{
return $this->hasOne( 'Offer' );
}
public function projectemployees()
{
return $this->hasMany( 'Projectemployee' );
}
public function projectemployees()
{
return $this->hasMany( 'Projectemployee' );
}
public function projectcosts()
{
return $this->hasMany( 'Projectcost' );
}
public function projectcosts()
{
return $this->hasMany( 'Projectcost' );
}
public function invoices()
{
return $this->hasMany( 'Invoice' );
}
public function invoices()
{
return $this->hasMany( 'Invoice' );
}
public function forecasts()
{
return $this->hasMany( 'Forecast' );
}
public function forecasts()
{
return $this->hasMany( 'Forecast' );
}
public function reservations()
{
return $this->hasMany( 'Reservation' );
}
public function reservations()
{
return $this->hasMany( 'Reservation' );
}
public function vat()
{
return $this->belongsTo( 'Vat' );
}
public function vat()
{
return $this->belongsTo( 'Vat' );
}
public function projectleader()
{
return $this->belongsTo( 'User', 'projectleader_id' );
}
public function projectleader()
{
return $this->belongsTo( 'User', 'projectleader_id' );
}
public function customer()
{
return $this->belongsTo( 'Customer' );
}
public function customer()
{
return $this->belongsTo( 'Customer' );
}
public static function getAllProjects( $archive, $search, $order, $direction )
{
$projects = Project::getBaseProject();
public static function getAllProjects( $archive, $search, $order, $direction )
{
$projects = Project::getBaseProject();
$projects = $projects->selectRaw( 'projects.*' )
->join( 'customers AS CUS', 'CUS.id', '=', 'projects.customer_id' )
->join( 'users AS USR', 'USR.id', '=', 'projects.projectleader_id' )
->where( 'projects.projectnumber', 'LIKE', "%{$search}%" )
->orderBy( $order, $direction );
$projects = $projects->selectRaw( 'projects.*' )
->join( 'customers AS CUS', 'CUS.id', '=', 'projects.customer_id' )
->join( 'users AS USR', 'USR.id', '=', 'projects.projectleader_id' )
->where( 'projects.projectnumber', 'LIKE', "%{$search}%" )
->orderBy( $order, $direction );
if ( $archive == 'F' ) $projects = $projects->where( 'projects.archive', '=', 'F' );
if ( $archive == 'F' ) $projects = $projects->where( 'projects.archive', '=', 'F' );
$projects = $projects->get();
$projects = $projects->get();
return $projects;
}
return $projects;
}
public static function getProject( $projectID )
{
$project = Project::getBaseProject();
public static function getProject( $projectID )
{
$project = Project::getBaseProject();
$project = $project->whereArchive( 'F' )
->whereId( $projectID )
->first();
$project = $project->whereArchive( 'F' )
->whereId( $projectID )
->first();
return $project;
}
return $project;
}
public static function removeProject( $projectID )
{
Offer::whereProjectId( $projectID )->update( ['project_id' => NULL] );
public static function removeProject( $projectID )
{
Offer::whereProjectId( $projectID )->update( ['project_id' => NULL] );
Project::whereId( $projectID )->delete();
}
Project::whereId( $projectID )->delete();
}
public static function getActiveProjects($archive = 'T')
{
$projects = Project::selectRaw( "projects.id, YEAR(projects.startdate) AS instroom, YEAR(projects.enddate) AS uitstroom, projectnumber, current_financial_year,
public static function getActiveProjects( $archive = 'T' )
{
$projects = Project::selectRaw( "projects.id, YEAR(projects.startdate) AS instroom, YEAR(projects.enddate) AS uitstroom, projectnumber, current_financial_year,
projectname, CUS.name, OFF.own_revenue, OFF.other_revenue" )
->join( 'customers AS CUS', 'CUS.id', '=', 'projects.customer_id' )
->join( 'offers AS OFF', 'OFF.project_id', '=', 'projects.id' )
->groupBy( 'projects.id' )
->groupBy( 'OFF.own_revenue' )
->groupBy( 'OFF.other_revenue' );
->join( 'customers AS CUS', 'CUS.id', '=', 'projects.customer_id' )
->join( 'offers AS OFF', 'OFF.project_id', '=', 'projects.id' )
->groupBy( 'projects.id' )
->groupBy( 'OFF.own_revenue' )
->groupBy( 'OFF.other_revenue' );
if( $archive == 'F') $projects = $projects->where('projects.archive', '=', 'F');
if ( $archive == 'F' ) $projects = $projects->where( 'projects.archive', '=', 'F' );
$projects = $projects->get();
$projects = $projects->get();
return $projects;
}
return $projects;
}
public static function getProjectsForReport( $orderType, $orderDirection, $archive = 'F' )
{
$projects = self::getBaseProject();
public static function getProjectsForReport( $orderType, $orderDirection, $archive = 'F' )
{
$projects = self::getBaseProject();
if ( $archive == 'F' ) $projects = $projects->whereArchive( 'F' );
if ( $archive == 'F' ) $projects = $projects->whereArchive( 'F' );
$projects = $projects->orderBy( $orderType, $orderDirection )->get();
$projects = $projects->orderBy( $orderType, $orderDirection )->get();
return $projects;
}
return $projects;
}
public static function getBaseProject()
{
$project = Project::with( [
'projectleader' => function ( $q ) {
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
}] )
->with( 'offer' )
->with( [
'projectemployees.user' => function ( $q ) {
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
}] )
->with( 'vat' )
->with( ['forecasts'] )
->with( ['reservations'] )
->with( 'projectemployees.projecthours' )
->with( 'projectcosts.external' )
->with( 'invoices.payments' )
->with( 'invoices.vat' )
->with( 'vat' )
->with( 'customer' );
public static function getBaseProject()
{
$project = Project::with( [
'projectleader' => function ( $q ) {
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
}] )
->with( 'offer' )
->with( [
'projectemployees.user' => function ( $q ) {
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
}] )
->with( 'vat' )
->with( ['forecasts'] )
->with( ['reservations'] )
->with( 'projectemployees.projecthours' )
->with( 'projectcosts.external' )
->with( 'invoices.payments' )
->with( 'invoices.vat' )
->with( 'vat' )
->with( 'customer' );
return $project;
}
return $project;
}
public static function createProject()
{
$data = ['startdate' => date( 'Y-m-d' )];
public static function createProject()
{
$data = ['startdate' => date( 'Y-m-d' )];
$project = Project::create( $data );
$project = Project::create( $data );
return $project->id;
}
return $project->id;
}
public static function saveProject( $projectID, $project )
{
$project = (array) $project;
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 );
}
if ( $projectID == 0 )
{
$project = Project::create( $project );
$projectID = $project['id'];;
}
else
{
Project::whereId( $projectID )->update( $project );
}
return $projectID;
return $projectID;
}
}
}
public static function syncOffername( $offer )
{
self::whereId( $offer->project_id )
->update( ['projectname' => $offer->offername] );
}
}
+98 -85
View File
@@ -9,117 +9,130 @@
class User extends BaseModel {
protected $table = "users";
protected $table = "users";
public function projectemployees()
{
return $this->hasMany( 'Projectemployee' );
}
public function projectemployees()
{
return $this->hasMany( 'Projectemployee' );
}
public function employeetargets()
{
return $this->hasMany( 'Employeetarget' );
}
public function employeetargets()
{
return $this->hasMany( 'Employeetarget' );
}
public function projectemployee()
{
return $this->hasOne( 'Projectemployee' );
}
public function projectemployee()
{
return $this->hasOne( 'Projectemployee' );
}
public function role()
{
return $this->belongsTo( 'Role', 'level', 'rolelevel' );
}
public function role()
{
return $this->belongsTo( 'Role', 'level', 'rolelevel' );
}
public static function getAllUsers( $archive )
{
$users = User::selectRaw( "*, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" )
->orderBy( 'lastname' );
public static function getAllUsers( $archive )
{
$users = User::selectRaw( "*, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" )
->orderBy( 'lastname' );
if ( $archive == 'F' ) $users = $users->whereArchive( 'F' );
if ( $archive == 'F' ) $users = $users->whereArchive( 'F' );
$users = $users->get();
$users = $users->get();
return $users;
}
return $users;
}
public static function getUserRoleHierarchy()
{
$userrole = User::find( USERID )->role;
public static function getUserRoleHierarchy()
{
$userrole = User::find( USERID )->role;
return $userrole;
}
return $userrole;
}
public static function getUserWithprojects()
{
$usersWithProjects =
User::selectRaw( "users.id, CONCAT(users.firstname, ' ', users.middlename, ' ', users.lastname) AS fullname" )
->with( [
'projectemployees.project' => function ( $q ) {
$q->whereArchive( 'F' );
}] )
->get();
public static function getUserWithprojects()
{
$usersWithProjects =
User::selectRaw( "users.id, CONCAT(users.firstname, ' ', users.middlename, ' ', users.lastname) AS fullname" )
->with( [
'projectemployees.project' => function ( $q ) {
$q->whereArchive( 'F' );
}] )
->get();
return $usersWithProjects;
}
return $usersWithProjects;
}
public static function checkUsername( $username )
{
$username = strtoupper( $username );
public static function getUserActiveProjects( $userID )
{
$usersActiveProjects =
User::selectRaw( "PRJ.id AS projectID, projectname, projectnumber, CONCAT(projectnumber, '-', projectname) AS projectFull" )
->join( 'projectemployees AS PRE', 'PRE.user_id', '=', 'users.id' )
->join( 'projects AS PRJ', 'PRJ.id', '=', 'PRE.project_id' )
->where( 'PRJ.archive', '=', 'F' )
->where( 'users.id', '=', $userID )
->get();
$user = User::whereRaw( "UCASE(username) = {$username}" );
return $usersActiveProjects;
}
if ( $user->count() == 0 ) return FALSE;
public static function checkUsername( $username )
{
$username = strtoupper( $username );
return TRUE;
}
$user = User::whereRaw( "UCASE(username) = {$username}" );
public static function saveUser( $userID, $user )
{
$user = (array) $user;
if ( $user->count() == 0 ) return FALSE;
if ( $userID == 0 )
{
$user = User::create( $user );
$userID = $user['id'];
}
else
{
User::whereId( $userID )->update( $user );
}
return TRUE;
}
return $userID;
}
public static function saveUser( $userID, $user )
{
$user = (array) $user;
public static function removeUser( $userID )
{
User::whereId( $userID )->delete();
}
if ( $userID == 0 )
{
$user = User::create( $user );
$userID = $user['id'];
}
else
{
User::whereId( $userID )->update( $user );
}
public static function getUniqueProjectUsers()
{
//TODO: date range
$projectusers = User::selectRaw( "
return $userID;
}
public static function removeUser( $userID )
{
User::whereId( $userID )->delete();
}
public static function getUniqueProjectUsers()
{
//TODO: date range
$projectusers = User::selectRaw( "
users.id,
CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname,
SUBSTR(MD5(users.id), 1, 6) AS slug" )
->join( 'projectemployees AS PEM', 'PEM.user_id', '=', 'users.id' )
->with( [
'projectemployee.project' => function ( $q ) {
$q->selectRaw( "id, YEAR(startdate) AS instroom, COALESCE(YEAR(enddate), '') AS uitstroom" );
}] )
->distinct()
->get();
->join( 'projectemployees AS PEM', 'PEM.user_id', '=', 'users.id' )
->with( [
'projectemployee.project' => function ( $q ) {
$q->selectRaw( "id, YEAR(startdate) AS instroom, COALESCE(YEAR(enddate), '') AS uitstroom" );
}] )
->distinct()
->get();
return $projectusers;
}
return $projectusers;
}
public static function getSaltedPassword( $password, $salt )
{
$saltedpassword = sha1( sha1( $password ) . $salt );
public static function getSaltedPassword( $password, $salt )
{
$saltedpassword = sha1( sha1( $password ) . $salt );
return $saltedpassword;
}
return $saltedpassword;
}
}
}
@@ -16,10 +16,10 @@ class ReservationTotals {
Q5.costs, reservation, payed, (reservation - fromreservation) AS saldo,
(Q5.costs - payed) AS saldoToPay, PRJ.projectnumber, EXT.contactperson,
ROUND(( (OFF.costs * (100 + (SELECT vatrate
FROM vats VTS
JOIN projects P
ON VTS.id = P.vat_id
WHERE P.id = PRJ.id LIMIT 1))) / 100 ), 0) other_revenue
FROM vats VTS
JOIN projects P
ON VTS.id = P.vat_id
WHERE P.id = PRJ.id LIMIT 1))) / 100 ), 0) other_revenue
FROM (
SELECT COALESCE(reservation, 0) AS reservation, costs, payed, Q2.external_id, Q2.project_id,
IF(from_reservation = 'T', payed, 0) fromreservation
@@ -1,7 +1,7 @@
<div class="panel panel-bordered panel-primary panel-line">
<div class="panel-heading panel-heading-project">
<h3 class="">
Reserveringen (incl. btw)
budget onderaannemers (incl. btw)
</h3>
</div>
<div class="panel-body panel-body-project">
@@ -59,4 +59,4 @@
</tfoot>
</table>
</div>
</div>
</div>
+21 -47
View File
@@ -28,87 +28,61 @@
<table class="table table-sm">
<thead>
<tr>
<th class="table-tealish-header">medewerker</th>
<th class="table-tealish-header">datum</th>
<th class="table-tealish-header">soort uren</th>
<th class="table-tealish-header">project</th>
<th class="table-tealish-header" style="min-width:100px;">uren</th>
<th class="table-tealish-header">&nbsp;</th>
<th class="table-tealish-header" width="15%">datum</th>
<th class="table-tealish-header" width="35%">soort uren</th>
<th class="table-tealish-header" width="35%">project</th>
<th class="table-tealish-header" width="10%" style="min-width:100px;">uren</th>
<th class="table-tealish-header" width="5%">&nbsp;</th>
</tr>
</thead>
<tbody data-bind="foreach:employeehours">
<tr>
<td data-bind="css:{'red-line': id() == 0}">
<span data-bind="text:dbo.helpers.findArrayElement('id', 'fullname', employee_id(), $root.employees()),
visible: ! inEdit()"></span>
<select class="form-control form-control-sm"
data-bind="options:$root.employees,
optionsText:'fullname',
optionsValue:'id',
value:employee_id,
optionsCaption: 'selecteer...',
visible:inEdit(),
enable: ! $root.selectedEmployeeID,
event:{change:$root.changeEmployee}"></select>
</td>
<td data-bind="css:{'red-line': id() == 0}">
<span data-bind="text:hourdate, visible:! inEdit()"></span>
<td data-bind="css:{'red-line': dirty}">
<input class="form-control form-control-sm"
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
value:hourdate, visible:inEdit(),
value:hourdate,
event:{change:$root.saveEmployeehour}"
</td>
<td data-bind="css:{'red-line': id() == 0}">
<span data-bind="text:dbo.helpers.findArrayElement('id', 'description', hourtype_id(), $root.hourtypes()),
visible: ! inEdit()"></span>
<td data-bind="css:{'red-line': dirty}">
<select class="form-control form-control-sm"
data-bind="options:$root.hourtypes,
optionsText:'description',
optionsValue:'id',
value:hourtype_id,
optionsCaptiuon:'selecteer...',
visible:inEdit(),
optionsCaption:'selecteer...',
event:{change:$root.saveEmployeehours}"></select>
</td>
<td data-bind="css:{'red-line': id() == 0}">
<td data-bind="css:{'red-line': dirty}">
<!-- ko if: hourType() == 'PROJECTS' -->
<span data-bind="text:dbo.helpers.findArrayElement('projectID', 'projectname', projectID(), projects()),
visible: ! inEdit()"></span>
<select class="form-control form-control-sm"
data-bind="options:projects,
optionsText:'projectname',
data-bind="options:$root.projects,
optionsText:'projectFull',
optionsValue:'projectID',
value:projectID,
optionsCaption:'selecteer...',
visible:inEdit(),
event:{change:$root.saveEmployeehours}"></select>
<!-- /ko -->
<!-- ko if: hourType() == 'OFFERS' -->
<span data-bind="text:dbo.helpers.findArrayElement('id', 'offername', projectID(), $root.offersWithoutProject()),
visible: ! inEdit()"></span>
<select class="form-control form-control-sm"
data-bind="options:$root.offersWithoutProject,
optionsText:'offername',
optionsValue:'id',
value:projectID,
optionsCaption:'selecteer...',
visible:inEdit(),
event:{change:$root.saveEmployeehours}"></select>
<!-- /ko -->
</td>
<td class="align-right" data-bind="css:{'red-line': id() == 0}">
<span data-bind=" visible: ! inEdit()">
<span data-bind="text:hours"></span>
uur
</span>
<input type="text"
<td class="align-right" data-bind="css:{'red-line': dirty}">
<input type="number"
class="form-control form-control-sm align-right"
paceholder="uren"
data-bind="textInput:hours, visible:inEdit,
event:{change:$root.saveEmployeehours,keyup:$root.validateNumber.bind($data, 'hours')}"/>
data-bind="textInput:hours,
enable:canFillInHours,
event:{keyup:$root.saveDelayedEmployeehours,
change: $root.saveDelayedEmployeehours}"/>
</td>
<td data-bind="css:{'red-line': id() == 0}">
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editEmployeehour"></i>
<td data-bind="css:{'red-line': dirty}">
<!-- <i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editEmployeehour"></i>-->
<i class="icon fa-trash redish pointer" title="verwijder"
data-bind="click:$root.removeEmployeehour"></i>
</td>
@@ -125,4 +99,4 @@
</tr>
</tfoot>
</table>
</table>
+15 -2
View File
@@ -54,7 +54,7 @@
<span data-bind="text:acceptance_chance"></span> %
</td>
<td data-bind="click:$root.selectOffer" class="pointer align-right">
€ <span data-bind="text:Math.round((acceptance_chance * own_revenue) / 100)"></span>
€ <span data-bind="text:chanceOwnRevenue"></span>
</td>
<!-- <td data-bind="click:$root.selectOffer" class="pointer">-->
<!-- <span data-bind="text:accepteddate"></span>-->
@@ -78,6 +78,19 @@
</tr>
</tbody>
<tfoot>
<tr>
<th colspan="4" class="align-right table-tealish-header">
Totaal
</th>
<th class="align-right table-tealish-header">
€ <span data-bind="text:totalOwnRevenue"></span>
</th>
<th class=" table-tealish-header">&nbsp;</th>
<th class="align-right table-tealish-header">
€ <span data-bind="text:totalChanceOwnRevenue"></span>
</th>
<th class=" table-tealish-header">&nbsp;</th>
</tr>
<tr>
<td colspan="5" class="">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newOffer">
@@ -104,4 +117,4 @@
</td>
</tr>
</tfoot>
</table>
</table>
+20 -1
View File
@@ -77,6 +77,25 @@
</tr>
</tbody>
<tfoot>
<tr>
<th colspan="4" class="align-right table-tealish-header">
Totaal
</th>
<th class="align-right table-tealish-header">
€ <span data-bind="text:totalOwnRevenue"></span>
</th>
<th class="align-right table-tealish-header">
€ <span data-bind="text:totalOtherrevenue"></span>
</th>
<th class="align-right table-tealish-header">
€ <span data-bind="text:totalCosts"></span>
</th>
<th class="align-right table-tealish-header">
€ <span data-bind="text:total"></span>
</th>
<th class="align-right table-tealish-header"></th>
</tr>
<tr>
<td colspan="5" class="">
<!-- <button class="btn btn-primary btn-round btn-sm" data-bind="click:newProject">-->
@@ -104,4 +123,4 @@
</tr>
</tfoot>
</table>
</table>
@@ -10,13 +10,13 @@
<th width="3%">&nbsp;</th>
<th width="17%">project</th>
<th width="10%" class="align-right">Kosten derden</th>
<th width="10%" class="align-right">gefactureerd</th>
<th width="10%" class="align-right">gereserveerd</th>
<th width="10%" class="align-right">factuur INK</th>
<th width="10%" class="align-right">budget onderaannemers</th>
<th width="10%" class="align-right">betaald</th>
<th width="10%" class="align-right">saldo te<br />betalen</th>
<th width="10%" class="align-right">betaald via<br />reserveringen</th>
<th width="10%" class="align-right">saldo reservering</th>
<th width="10%" class="align-right">saldo te<br />factureren</th>
<th width="10%" class="align-right">saldo facturen INK</th>
</tr>
</thead>
<!-- ko foreach:projects -->
@@ -135,4 +135,4 @@
</table>
</div>
</div>
</div>
</div>