Diversen opmerkingen Peter (23-08-2019)
This commit is contained in:
@@ -53,6 +53,13 @@ class usersController extends MY_Controller {
|
|||||||
$this->json( $usersWithProjects );
|
$this->json( $usersWithProjects );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUserActiveProjects($userID)
|
||||||
|
{
|
||||||
|
$userActiveProjects = User::getUserActiveProjects($userID);
|
||||||
|
|
||||||
|
$this->json( $userActiveProjects );
|
||||||
|
}
|
||||||
|
|
||||||
public function getUniqueprojectEmployees()
|
public function getUniqueprojectEmployees()
|
||||||
{
|
{
|
||||||
$projectEmployees = User::getUniqueProjectUsers();
|
$projectEmployees = User::getUniqueProjectUsers();
|
||||||
@@ -136,4 +143,4 @@ class usersController extends MY_Controller {
|
|||||||
|
|
||||||
$this->email->send();
|
$this->email->send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,363 +9,365 @@ defined( 'BASEPATH' ) OR exit( 'No direct script access allowed' );
|
|||||||
*/
|
*/
|
||||||
class ProjectsController extends MY_Controller {
|
class ProjectsController extends MY_Controller {
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
|
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
|
||||||
|
|
||||||
$models = ['projects/Invoices_model'];
|
$models = ['projects/Invoices_model'];
|
||||||
$libraries = [];
|
$libraries = [];
|
||||||
|
|
||||||
$this->load->model( $models );
|
$this->load->model( $models );
|
||||||
$this->load->library( $libraries );
|
$this->load->library( $libraries );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllProjects()
|
public function getAllProjects()
|
||||||
{
|
{
|
||||||
$archive = $this->clean_input( 'archive' );
|
$archive = $this->clean_input( 'archive' );
|
||||||
$search = $this->clean_input( 'search' );
|
$search = $this->clean_input( 'search' );
|
||||||
$order = $this->clean_input( 'order' );
|
$order = $this->clean_input( 'order' );
|
||||||
$direction = $this->clean_input( 'direction' );
|
$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 )
|
public function getProject( $projectID )
|
||||||
{
|
{
|
||||||
$project = Project::getProject( $projectID );
|
$project = Project::getProject( $projectID );
|
||||||
|
|
||||||
$project->invoiceDetails =
|
$project->invoiceDetails =
|
||||||
$this->Invoices_model->getOutstandingPerProject( $project->id );
|
$this->Invoices_model->getOutstandingPerProject( $project->id );
|
||||||
|
|
||||||
$project->hourTotals =
|
$project->hourTotals =
|
||||||
Projecthour::getTotalHoursPerProject( $project->id );
|
Projecthour::getTotalHoursPerProject( $project->id );
|
||||||
|
|
||||||
$this->json( $project );
|
$this->json( $project );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAvailableEmployees( $projectID )
|
public function getAvailableEmployees( $projectID )
|
||||||
{
|
{
|
||||||
$availableEmployees =
|
$availableEmployees =
|
||||||
Projectemployee::getAvailableEmployees( $projectID );
|
Projectemployee::getAvailableEmployees( $projectID );
|
||||||
|
|
||||||
$this->json( $availableEmployees );
|
$this->json( $availableEmployees );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addProject()
|
public function addProject()
|
||||||
{
|
{
|
||||||
$projectID = Project::createProject();
|
$projectID = Project::createProject();
|
||||||
|
|
||||||
$this->json( $projectID );
|
$this->json( $projectID );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function creatProjectFromOffer( $offerID )
|
public function creatProjectFromOffer( $offerID )
|
||||||
{
|
{
|
||||||
$offer = Offer::find( $offerID );
|
$offer = Offer::find( $offerID );
|
||||||
|
|
||||||
$offernumber = $offer->offernumber;
|
$offernumber = $offer->offernumber;
|
||||||
|
|
||||||
$projectnumber = 'P' . substr( $offernumber, 1 );
|
$projectnumber = 'P' . substr( $offernumber, 1 );
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'projectnumber' => $projectnumber,
|
'projectnumber' => $projectnumber,
|
||||||
'projectname' => $offer->offername,
|
'projectname' => $offer->offername,
|
||||||
'projectleader_id' => $offer->offerleader_id,
|
'projectleader_id' => $offer->offerleader_id,
|
||||||
'startdate' => $offer->accepteddate,
|
'startdate' => $offer->accepteddate,
|
||||||
'customer_id' => $offer->customer_id
|
'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();
|
$offerteHours = Employeehour::whereOfferId( $offerID )->get();
|
||||||
foreach ( $offerteHours as $offerteHour )
|
foreach ( $offerteHours as $offerteHour )
|
||||||
{
|
{
|
||||||
$projectemployee =
|
$projectemployee =
|
||||||
Projectemployee::firstOrCreateProjectemployee( $offerteHour->employee_id, $project->id );
|
Projectemployee::firstOrCreateProjectemployee( $offerteHour->employee_id, $project->id );
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'projectemployee_id' => $projectemployee->id,
|
'projectemployee_id' => $projectemployee->id,
|
||||||
'hourtype_id' => 10,
|
'hourtype_id' => 10,
|
||||||
'hourdate' => $offerteHour->hourdate,
|
'hourdate' => $offerteHour->hourdate,
|
||||||
'hours' => $offerteHour->hours
|
'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 )
|
public function addProjectEmployee( $projectID )
|
||||||
{
|
{
|
||||||
Projectemployee::createProjectEmployee( $projectID );
|
Projectemployee::createProjectEmployee( $projectID );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveProject()
|
public function saveProject()
|
||||||
{
|
{
|
||||||
$projectValidation = new ProjectValidation();
|
$projectValidation = new ProjectValidation();
|
||||||
|
|
||||||
if ( ! $projectValidation->getValidationResult() )
|
if ( ! $projectValidation->getValidationResult() )
|
||||||
return $this->json( [
|
return $this->json( [
|
||||||
'success' => FALSE, 'messages' => $projectValidation->getErrorMessages()] );
|
'success' => FALSE, 'messages' => $projectValidation->getErrorMessages()] );
|
||||||
|
|
||||||
$project = $this->input->post();
|
$project = $this->input->post();
|
||||||
|
|
||||||
$projectID = $project['id'];
|
$projectID = $project['id'];
|
||||||
unset( $project['id'] );
|
unset( $project['id'] );
|
||||||
|
|
||||||
$project['startdate'] = date2mysql( $project['startdate'] );
|
$project['startdate'] = date2mysql( $project['startdate'] );
|
||||||
$project['enddate'] = date2mysql( $project['enddate'] );
|
$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()
|
$this->json( ['success' => TRUE, 'projectID' => $projectID] );
|
||||||
{
|
}
|
||||||
$projectemployeeValidation = new ProjectemployeeValidation();
|
|
||||||
|
|
||||||
if ( ! $projectemployeeValidation->getValidationResult() )
|
public function saveProjectemployee()
|
||||||
return $this->json( [
|
{
|
||||||
'success' => FALSE, 'messages' => $projectemployeeValidation->getErrorMessages()] );
|
$projectemployeeValidation = new ProjectemployeeValidation();
|
||||||
|
|
||||||
$projectemployee = $this->input->post();
|
if ( ! $projectemployeeValidation->getValidationResult() )
|
||||||
|
return $this->json( [
|
||||||
|
'success' => FALSE, 'messages' => $projectemployeeValidation->getErrorMessages()] );
|
||||||
|
|
||||||
$projectemployeeID = $projectemployee['id'];
|
$projectemployee = $this->input->post();
|
||||||
unset( $projectemployee['id'] );
|
|
||||||
|
|
||||||
Projectemployee::saveProjectemployee( $projectemployeeID, $projectemployee );
|
$projectemployeeID = $projectemployee['id'];
|
||||||
|
unset( $projectemployee['id'] );
|
||||||
|
|
||||||
$this->json( ['success' => TRUE] );
|
Projectemployee::saveProjectemployee( $projectemployeeID, $projectemployee );
|
||||||
}
|
|
||||||
|
|
||||||
public function saveInvoice()
|
$this->json( ['success' => TRUE] );
|
||||||
{
|
}
|
||||||
$invoiceValidation = new InvoiceValidation();
|
|
||||||
|
|
||||||
if ( ! $invoiceValidation->getValidationResult() )
|
public function saveInvoice()
|
||||||
return $this->json( [
|
{
|
||||||
'success' => FALSE, 'messages' => $invoiceValidation->getErrorMessages()] );
|
$invoiceValidation = new InvoiceValidation();
|
||||||
|
|
||||||
$invoice = $this->input->post();
|
if ( ! $invoiceValidation->getValidationResult() )
|
||||||
|
return $this->json( [
|
||||||
|
'success' => FALSE, 'messages' => $invoiceValidation->getErrorMessages()] );
|
||||||
|
|
||||||
$invoiceID = $invoice['id'];
|
$invoice = $this->input->post();
|
||||||
unset( $invoice['id'] );
|
|
||||||
|
|
||||||
$invoice['invoicedate'] = date2mysql( $invoice['invoicedate'] );
|
$invoiceID = $invoice['id'];
|
||||||
$invoice['forecastdate'] = date2mysql( $invoice['forecastdate'] );
|
unset( $invoice['id'] );
|
||||||
$invoice['invoiceamount'] = str_replace( ',', '.', $invoice['invoiceamount'] );
|
|
||||||
$invoice['forecastamount'] = str_replace( ',', '.', $invoice['forecastamount'] );
|
|
||||||
|
|
||||||
$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()
|
$this->json( ['success' => TRUE, 'invoiceID' => $invoiceID] );
|
||||||
{
|
}
|
||||||
$paymentValidation = new PaymentValidation();
|
|
||||||
|
|
||||||
if ( ! $paymentValidation->getValidationResult() )
|
public function savePayment()
|
||||||
return $this->json( [
|
{
|
||||||
'success' => FALSE, 'messages' => $paymentValidation->getErrorMessages()] );
|
$paymentValidation = new PaymentValidation();
|
||||||
|
|
||||||
$payment = $this->input->post();
|
if ( ! $paymentValidation->getValidationResult() )
|
||||||
|
return $this->json( [
|
||||||
|
'success' => FALSE, 'messages' => $paymentValidation->getErrorMessages()] );
|
||||||
|
|
||||||
$paymentID = $payment['id'];
|
$payment = $this->input->post();
|
||||||
unset( $payment['id'] );
|
|
||||||
|
|
||||||
$payment['paymentdate'] = date2mysql( $payment['paymentdate'] );
|
$paymentID = $payment['id'];
|
||||||
$payment['paymentamount'] = str_replace( ',', '.', $payment['paymentamount'] );
|
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()
|
$this->json( ['success' => TRUE, 'paymentID' => $paymentID] );
|
||||||
{
|
}
|
||||||
$projectcostValidation = new ProjectcostValidation();
|
|
||||||
|
|
||||||
if ( ! $projectcostValidation->getValidationResult() )
|
public function saveProjectcost()
|
||||||
return $this->json( [
|
{
|
||||||
'success' => FALSE, 'messages' => $projectcostValidation->getErrorMessages()] );
|
$projectcostValidation = new ProjectcostValidation();
|
||||||
|
|
||||||
$projectcost = $this->input->post();
|
if ( ! $projectcostValidation->getValidationResult() )
|
||||||
|
return $this->json( [
|
||||||
|
'success' => FALSE, 'messages' => $projectcostValidation->getErrorMessages()] );
|
||||||
|
|
||||||
$projectcostID = $projectcost['id'];
|
$projectcost = $this->input->post();
|
||||||
unset( $projectcost['id'] );
|
|
||||||
|
|
||||||
$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()
|
$this->json( ['success' => TRUE, 'projectcostID' => $projectcostID] );
|
||||||
{
|
}
|
||||||
$projecthourValidation = new ProjecthourValidation();
|
|
||||||
|
|
||||||
if ( ! $projecthourValidation->getValidationResult() )
|
public function saveProjecthour()
|
||||||
return $this->json( [
|
{
|
||||||
'success' => FALSE, 'messages' => $projecthourValidation->getErrorMessages()] );
|
$projecthourValidation = new ProjecthourValidation();
|
||||||
|
|
||||||
$projecthour = $this->input->post();
|
if ( ! $projecthourValidation->getValidationResult() )
|
||||||
|
return $this->json( [
|
||||||
|
'success' => FALSE, 'messages' => $projecthourValidation->getErrorMessages()] );
|
||||||
|
|
||||||
$projecthourID = $projecthour['id'];
|
$projecthour = $this->input->post();
|
||||||
unset( $projecthour['id'] );
|
|
||||||
|
|
||||||
$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()
|
$this->json( ['success' => TRUE, 'projecthourID' => $paymentID] );
|
||||||
{
|
}
|
||||||
$forecastValidation = new ForecastValidation();
|
|
||||||
|
|
||||||
if ( ! $forecastValidation->getValidationResult() )
|
public function saveForecast()
|
||||||
return $this->json( [
|
{
|
||||||
'success' => FALSE, 'messages' => $forecastValidation->getErrorMessages()] );
|
$forecastValidation = new ForecastValidation();
|
||||||
|
|
||||||
$forecast = $this->input->post();
|
if ( ! $forecastValidation->getValidationResult() )
|
||||||
|
return $this->json( [
|
||||||
|
'success' => FALSE, 'messages' => $forecastValidation->getErrorMessages()] );
|
||||||
|
|
||||||
$forecastID = $forecast['id'];
|
$forecast = $this->input->post();
|
||||||
unset( $forecast['id'] );
|
|
||||||
|
|
||||||
$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()
|
$this->json( ['success' => TRUE, 'forecastID' => $forecastID] );
|
||||||
{
|
}
|
||||||
$reservationValidation = new ReservationValidation();
|
|
||||||
|
|
||||||
if ( ! $reservationValidation->getValidationResult() )
|
public function saveReservation()
|
||||||
return $this->json( [
|
{
|
||||||
'success' => FALSE, 'messages' => $reservationValidation->getErrorMessages()] );
|
$reservationValidation = new ReservationValidation();
|
||||||
|
|
||||||
$reservation = $this->input->post();
|
if ( ! $reservationValidation->getValidationResult() )
|
||||||
|
return $this->json( [
|
||||||
|
'success' => FALSE, 'messages' => $reservationValidation->getErrorMessages()] );
|
||||||
|
|
||||||
$reservationID = $reservation['id'];
|
$reservation = $this->input->post();
|
||||||
unset( $reservation['id'] );
|
|
||||||
|
|
||||||
$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 )
|
$this->json( ['success' => TRUE, 'reservationID' => $reservationID] );
|
||||||
{
|
}
|
||||||
Project::whereId( $projectID )->update( ['archive' => $status] );
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeProjectemployee( $projectemployeeID )
|
public function archiveProject( $projectID, $status )
|
||||||
{
|
{
|
||||||
$removeProjectemployee = new RemoveProjectemployee( $projectemployeeID );
|
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 )
|
$this->json( ['result' => TRUE] );
|
||||||
{
|
}
|
||||||
$removeInvoice = new RemoveInvoice( $invoiceID );
|
|
||||||
|
|
||||||
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 );
|
// $removeInvoice = new RemoveInvoice( $invoiceID );
|
||||||
//
|
//
|
||||||
// if ( $removeInvoice->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] );
|
// 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 )
|
public function removePayment( $paymentID )
|
||||||
{
|
{
|
||||||
$removePayment = new 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 )
|
public function removeProjecthour( $projecthourID )
|
||||||
{
|
{
|
||||||
$removeProjecthour = new 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 )
|
public function removeForecast( $forecastID )
|
||||||
{
|
{
|
||||||
$removeForecast = new 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 )
|
public function removeReservation( $reservationID )
|
||||||
{
|
{
|
||||||
$removeReservation = new 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 )
|
public function removeProject( $projectID )
|
||||||
{
|
{
|
||||||
$removeProject = new 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] );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class MY_Controller extends CI_Controller {
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->version = '1.00.06';
|
$this->version = '1.00.10';
|
||||||
|
|
||||||
$this->load->library( 'beheer/session/RetrieveUserSession' );
|
$this->load->library( 'beheer/session/RetrieveUserSession' );
|
||||||
|
|
||||||
@@ -65,4 +65,4 @@ class MY_Controller extends CI_Controller {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,76 +9,90 @@
|
|||||||
|
|
||||||
class Offer extends BaseModel {
|
class Offer extends BaseModel {
|
||||||
|
|
||||||
protected $table = "offers";
|
protected $table = "offers";
|
||||||
|
|
||||||
public function payments()
|
public function payments()
|
||||||
{
|
{
|
||||||
return $this->hasMany( 'Payment' );
|
return $this->hasMany( 'Payment' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function project()
|
public function project()
|
||||||
{
|
{
|
||||||
return $this->belongsTo( 'Project' );
|
return $this->belongsTo( 'Project' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function customer()
|
public function customer()
|
||||||
{
|
{
|
||||||
return $this->belongsTo( 'Customer' );
|
return $this->belongsTo( 'Customer' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllOffers( $projectID, $archive = 'F', $search, $order, $direction )
|
public static function getAllOffers( $projectID, $archive = 'F', $search, $order, $direction )
|
||||||
{
|
{
|
||||||
$offers = Offer::selectRAW('offers.*')
|
$offers = Offer::selectRAW( 'offers.*' )
|
||||||
->join('customers AS CUS', 'CUS.id', '=', 'offers.customer_id')
|
->join( 'customers AS CUS', 'CUS.id', '=', 'offers.customer_id' )
|
||||||
->with( 'customer' )
|
->with( 'customer' )
|
||||||
->with( 'project' )
|
->with( 'project' )
|
||||||
->where('offernumber', 'LIKE', "%{$search}%")
|
->where( 'offernumber', 'LIKE', "%{$search}%" )
|
||||||
->orderBy($order, $direction);
|
->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( )
|
public static function getOffersWithoutProject()
|
||||||
{
|
{
|
||||||
$offersWithoutProject = Offer::orderBy('startdate')
|
$offersWithoutProject = Offer::orderBy( 'startdate' )
|
||||||
// ->whereNull('rejectdate')
|
// ->whereNull('rejectdate')
|
||||||
// ->whereNull('project_id')
|
// ->whereNull('project_id')
|
||||||
->whereArchive('F')
|
->whereArchive( 'F' )
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return $offersWithoutProject;
|
return $offersWithoutProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function saveOffer( $offerID, $offer )
|
public static function saveOffer( $offerID, $offer )
|
||||||
{
|
{
|
||||||
$offer = (array) $offer;
|
$offer = (array) $offer;
|
||||||
|
|
||||||
$offer['startdate'] = date2mysql( $offer['startdate'] );
|
$offer['startdate'] = date2mysql( $offer['startdate'] );
|
||||||
$offer['accepteddate'] = date2mysql( $offer['accepteddate'] );
|
$offer['accepteddate'] = date2mysql( $offer['accepteddate'] );
|
||||||
$offer['rejectdate'] = date2mysql( $offer['rejectdate'] );
|
$offer['rejectdate'] = date2mysql( $offer['rejectdate'] );
|
||||||
|
|
||||||
if ( $offerID == 0 )
|
if ( $offerID == 0 )
|
||||||
{
|
{
|
||||||
$offer = Offer::create( $offer );
|
$offer = Offer::create( $offer );
|
||||||
|
|
||||||
$offerID = $offer['id'];
|
$offerID = $offer['id'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Offer::whereId( $offerID )->update( $offer );
|
Offer::whereId( $offerID )->update( $offer );
|
||||||
}
|
|
||||||
|
|
||||||
return $offerID;
|
$offer = self::find( $offerID );
|
||||||
}
|
|
||||||
|
|
||||||
public static function removeOffer( $offerID )
|
if ( ! is_null( $offer->project_id ) ) Project::syncOffername( $offer );
|
||||||
{
|
}
|
||||||
Offer::whereId( $offerID )->delete();
|
|
||||||
}
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,169 +9,174 @@
|
|||||||
|
|
||||||
class Project extends BaseModel {
|
class Project extends BaseModel {
|
||||||
|
|
||||||
protected $table = "projects";
|
protected $table = "projects";
|
||||||
|
|
||||||
public function offers()
|
public function offers()
|
||||||
{
|
{
|
||||||
return $this->hasMany( 'Offer' );
|
return $this->hasMany( 'Offer' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function offer()
|
public function offer()
|
||||||
{
|
{
|
||||||
return $this->hasOne( 'Offer' );
|
return $this->hasOne( 'Offer' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function projectemployees()
|
public function projectemployees()
|
||||||
{
|
{
|
||||||
return $this->hasMany( 'Projectemployee' );
|
return $this->hasMany( 'Projectemployee' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function projectcosts()
|
public function projectcosts()
|
||||||
{
|
{
|
||||||
return $this->hasMany( 'Projectcost' );
|
return $this->hasMany( 'Projectcost' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invoices()
|
public function invoices()
|
||||||
{
|
{
|
||||||
return $this->hasMany( 'Invoice' );
|
return $this->hasMany( 'Invoice' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function forecasts()
|
public function forecasts()
|
||||||
{
|
{
|
||||||
return $this->hasMany( 'Forecast' );
|
return $this->hasMany( 'Forecast' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reservations()
|
public function reservations()
|
||||||
{
|
{
|
||||||
return $this->hasMany( 'Reservation' );
|
return $this->hasMany( 'Reservation' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function vat()
|
public function vat()
|
||||||
{
|
{
|
||||||
return $this->belongsTo( 'Vat' );
|
return $this->belongsTo( 'Vat' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function projectleader()
|
public function projectleader()
|
||||||
{
|
{
|
||||||
return $this->belongsTo( 'User', 'projectleader_id' );
|
return $this->belongsTo( 'User', 'projectleader_id' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function customer()
|
public function customer()
|
||||||
{
|
{
|
||||||
return $this->belongsTo( 'Customer' );
|
return $this->belongsTo( 'Customer' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllProjects( $archive, $search, $order, $direction )
|
public static function getAllProjects( $archive, $search, $order, $direction )
|
||||||
{
|
{
|
||||||
$projects = Project::getBaseProject();
|
$projects = Project::getBaseProject();
|
||||||
|
|
||||||
$projects = $projects->selectRaw( 'projects.*' )
|
$projects = $projects->selectRaw( 'projects.*' )
|
||||||
->join( 'customers AS CUS', 'CUS.id', '=', 'projects.customer_id' )
|
->join( 'customers AS CUS', 'CUS.id', '=', 'projects.customer_id' )
|
||||||
->join( 'users AS USR', 'USR.id', '=', 'projects.projectleader_id' )
|
->join( 'users AS USR', 'USR.id', '=', 'projects.projectleader_id' )
|
||||||
->where( 'projects.projectnumber', 'LIKE', "%{$search}%" )
|
->where( 'projects.projectnumber', 'LIKE', "%{$search}%" )
|
||||||
->orderBy( $order, $direction );
|
->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 )
|
public static function getProject( $projectID )
|
||||||
{
|
{
|
||||||
$project = Project::getBaseProject();
|
$project = Project::getBaseProject();
|
||||||
|
|
||||||
$project = $project->whereArchive( 'F' )
|
$project = $project->whereArchive( 'F' )
|
||||||
->whereId( $projectID )
|
->whereId( $projectID )
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
return $project;
|
return $project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function removeProject( $projectID )
|
public static function removeProject( $projectID )
|
||||||
{
|
{
|
||||||
Offer::whereProjectId( $projectID )->update( ['project_id' => NULL] );
|
Offer::whereProjectId( $projectID )->update( ['project_id' => NULL] );
|
||||||
|
|
||||||
Project::whereId( $projectID )->delete();
|
Project::whereId( $projectID )->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getActiveProjects($archive = 'T')
|
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,
|
$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" )
|
projectname, CUS.name, OFF.own_revenue, OFF.other_revenue" )
|
||||||
->join( 'customers AS CUS', 'CUS.id', '=', 'projects.customer_id' )
|
->join( 'customers AS CUS', 'CUS.id', '=', 'projects.customer_id' )
|
||||||
->join( 'offers AS OFF', 'OFF.project_id', '=', 'projects.id' )
|
->join( 'offers AS OFF', 'OFF.project_id', '=', 'projects.id' )
|
||||||
->groupBy( 'projects.id' )
|
->groupBy( 'projects.id' )
|
||||||
->groupBy( 'OFF.own_revenue' )
|
->groupBy( 'OFF.own_revenue' )
|
||||||
->groupBy( 'OFF.other_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' )
|
public static function getProjectsForReport( $orderType, $orderDirection, $archive = 'F' )
|
||||||
{
|
{
|
||||||
$projects = self::getBaseProject();
|
$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()
|
public static function getBaseProject()
|
||||||
{
|
{
|
||||||
$project = Project::with( [
|
$project = Project::with( [
|
||||||
'projectleader' => function ( $q ) {
|
'projectleader' => function ( $q ) {
|
||||||
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
|
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
|
||||||
}] )
|
}] )
|
||||||
->with( 'offer' )
|
->with( 'offer' )
|
||||||
->with( [
|
->with( [
|
||||||
'projectemployees.user' => function ( $q ) {
|
'projectemployees.user' => function ( $q ) {
|
||||||
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
|
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
|
||||||
}] )
|
}] )
|
||||||
->with( 'vat' )
|
->with( 'vat' )
|
||||||
->with( ['forecasts'] )
|
->with( ['forecasts'] )
|
||||||
->with( ['reservations'] )
|
->with( ['reservations'] )
|
||||||
->with( 'projectemployees.projecthours' )
|
->with( 'projectemployees.projecthours' )
|
||||||
->with( 'projectcosts.external' )
|
->with( 'projectcosts.external' )
|
||||||
->with( 'invoices.payments' )
|
->with( 'invoices.payments' )
|
||||||
->with( 'invoices.vat' )
|
->with( 'invoices.vat' )
|
||||||
->with( 'vat' )
|
->with( 'vat' )
|
||||||
->with( 'customer' );
|
->with( 'customer' );
|
||||||
|
|
||||||
return $project;
|
return $project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function createProject()
|
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;
|
return $project->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function saveProject( $projectID, $project )
|
public static function saveProject( $projectID, $project )
|
||||||
{
|
{
|
||||||
$project = (array) $project;
|
$project = (array) $project;
|
||||||
|
|
||||||
if ( $projectID == 0 )
|
if ( $projectID == 0 )
|
||||||
{
|
{
|
||||||
$project = Project::create( $project );
|
$project = Project::create( $project );
|
||||||
$projectID = $project['id'];;
|
$projectID = $project['id'];;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Project::whereId( $projectID )->update( $project );
|
Project::whereId( $projectID )->update( $project );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $projectID;
|
return $projectID;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
public static function syncOffername( $offer )
|
||||||
}
|
{
|
||||||
|
self::whereId( $offer->project_id )
|
||||||
|
->update( ['projectname' => $offer->offername] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,117 +9,130 @@
|
|||||||
|
|
||||||
class User extends BaseModel {
|
class User extends BaseModel {
|
||||||
|
|
||||||
protected $table = "users";
|
protected $table = "users";
|
||||||
|
|
||||||
public function projectemployees()
|
public function projectemployees()
|
||||||
{
|
{
|
||||||
return $this->hasMany( 'Projectemployee' );
|
return $this->hasMany( 'Projectemployee' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function employeetargets()
|
public function employeetargets()
|
||||||
{
|
{
|
||||||
return $this->hasMany( 'Employeetarget' );
|
return $this->hasMany( 'Employeetarget' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function projectemployee()
|
public function projectemployee()
|
||||||
{
|
{
|
||||||
return $this->hasOne( 'Projectemployee' );
|
return $this->hasOne( 'Projectemployee' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function role()
|
public function role()
|
||||||
{
|
{
|
||||||
return $this->belongsTo( 'Role', 'level', 'rolelevel' );
|
return $this->belongsTo( 'Role', 'level', 'rolelevel' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllUsers( $archive )
|
public static function getAllUsers( $archive )
|
||||||
{
|
{
|
||||||
$users = User::selectRaw( "*, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" )
|
$users = User::selectRaw( "*, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" )
|
||||||
->orderBy( 'lastname' );
|
->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()
|
public static function getUserRoleHierarchy()
|
||||||
{
|
{
|
||||||
$userrole = User::find( USERID )->role;
|
$userrole = User::find( USERID )->role;
|
||||||
|
|
||||||
return $userrole;
|
return $userrole;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUserWithprojects()
|
public static function getUserWithprojects()
|
||||||
{
|
{
|
||||||
$usersWithProjects =
|
$usersWithProjects =
|
||||||
User::selectRaw( "users.id, CONCAT(users.firstname, ' ', users.middlename, ' ', users.lastname) AS fullname" )
|
User::selectRaw( "users.id, CONCAT(users.firstname, ' ', users.middlename, ' ', users.lastname) AS fullname" )
|
||||||
->with( [
|
->with( [
|
||||||
'projectemployees.project' => function ( $q ) {
|
'projectemployees.project' => function ( $q ) {
|
||||||
$q->whereArchive( 'F' );
|
$q->whereArchive( 'F' );
|
||||||
}] )
|
}] )
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return $usersWithProjects;
|
return $usersWithProjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function checkUsername( $username )
|
public static function getUserActiveProjects( $userID )
|
||||||
{
|
{
|
||||||
$username = strtoupper( $username );
|
$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 )
|
if ( $user->count() == 0 ) return FALSE;
|
||||||
{
|
|
||||||
$user = (array) $user;
|
|
||||||
|
|
||||||
if ( $userID == 0 )
|
return TRUE;
|
||||||
{
|
}
|
||||||
$user = User::create( $user );
|
|
||||||
$userID = $user['id'];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
User::whereId( $userID )->update( $user );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $userID;
|
public static function saveUser( $userID, $user )
|
||||||
}
|
{
|
||||||
|
$user = (array) $user;
|
||||||
|
|
||||||
public static function removeUser( $userID )
|
if ( $userID == 0 )
|
||||||
{
|
{
|
||||||
User::whereId( $userID )->delete();
|
$user = User::create( $user );
|
||||||
}
|
$userID = $user['id'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
User::whereId( $userID )->update( $user );
|
||||||
|
}
|
||||||
|
|
||||||
public static function getUniqueProjectUsers()
|
return $userID;
|
||||||
{
|
}
|
||||||
//TODO: date range
|
|
||||||
$projectusers = User::selectRaw( "
|
public static function removeUser( $userID )
|
||||||
|
{
|
||||||
|
User::whereId( $userID )->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getUniqueProjectUsers()
|
||||||
|
{
|
||||||
|
//TODO: date range
|
||||||
|
$projectusers = User::selectRaw( "
|
||||||
users.id,
|
users.id,
|
||||||
CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname,
|
CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname,
|
||||||
SUBSTR(MD5(users.id), 1, 6) AS slug" )
|
SUBSTR(MD5(users.id), 1, 6) AS slug" )
|
||||||
->join( 'projectemployees AS PEM', 'PEM.user_id', '=', 'users.id' )
|
->join( 'projectemployees AS PEM', 'PEM.user_id', '=', 'users.id' )
|
||||||
->with( [
|
->with( [
|
||||||
'projectemployee.project' => function ( $q ) {
|
'projectemployee.project' => function ( $q ) {
|
||||||
$q->selectRaw( "id, YEAR(startdate) AS instroom, COALESCE(YEAR(enddate), '') AS uitstroom" );
|
$q->selectRaw( "id, YEAR(startdate) AS instroom, COALESCE(YEAR(enddate), '') AS uitstroom" );
|
||||||
}] )
|
}] )
|
||||||
->distinct()
|
->distinct()
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return $projectusers;
|
return $projectusers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSaltedPassword( $password, $salt )
|
public static function getSaltedPassword( $password, $salt )
|
||||||
{
|
{
|
||||||
$saltedpassword = sha1( sha1( $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, reservation, payed, (reservation - fromreservation) AS saldo,
|
||||||
(Q5.costs - payed) AS saldoToPay, PRJ.projectnumber, EXT.contactperson,
|
(Q5.costs - payed) AS saldoToPay, PRJ.projectnumber, EXT.contactperson,
|
||||||
ROUND(( (OFF.costs * (100 + (SELECT vatrate
|
ROUND(( (OFF.costs * (100 + (SELECT vatrate
|
||||||
FROM vats VTS
|
FROM vats VTS
|
||||||
JOIN projects P
|
JOIN projects P
|
||||||
ON VTS.id = P.vat_id
|
ON VTS.id = P.vat_id
|
||||||
WHERE P.id = PRJ.id LIMIT 1))) / 100 ), 0) other_revenue
|
WHERE P.id = PRJ.id LIMIT 1))) / 100 ), 0) other_revenue
|
||||||
FROM (
|
FROM (
|
||||||
SELECT COALESCE(reservation, 0) AS reservation, costs, payed, Q2.external_id, Q2.project_id,
|
SELECT COALESCE(reservation, 0) AS reservation, costs, payed, Q2.external_id, Q2.project_id,
|
||||||
IF(from_reservation = 'T', payed, 0) fromreservation
|
IF(from_reservation = 'T', payed, 0) fromreservation
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="panel panel-bordered panel-primary panel-line">
|
<div class="panel panel-bordered panel-primary panel-line">
|
||||||
<div class="panel-heading panel-heading-project">
|
<div class="panel-heading panel-heading-project">
|
||||||
<h3 class="">
|
<h3 class="">
|
||||||
Reserveringen (incl. btw)
|
budget onderaannemers (incl. btw)
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body panel-body-project">
|
<div class="panel-body panel-body-project">
|
||||||
@@ -59,4 +59,4 @@
|
|||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -28,87 +28,61 @@
|
|||||||
<table class="table table-sm">
|
<table class="table table-sm">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="table-tealish-header">medewerker</th>
|
<th class="table-tealish-header" width="15%">datum</th>
|
||||||
<th class="table-tealish-header">datum</th>
|
<th class="table-tealish-header" width="35%">soort uren</th>
|
||||||
<th class="table-tealish-header">soort uren</th>
|
<th class="table-tealish-header" width="35%">project</th>
|
||||||
<th class="table-tealish-header">project</th>
|
<th class="table-tealish-header" width="10%" style="min-width:100px;">uren</th>
|
||||||
<th class="table-tealish-header" style="min-width:100px;">uren</th>
|
<th class="table-tealish-header" width="5%"> </th>
|
||||||
<th class="table-tealish-header"> </th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody data-bind="foreach:employeehours">
|
<tbody data-bind="foreach:employeehours">
|
||||||
<tr>
|
<tr>
|
||||||
<td data-bind="css:{'red-line': id() == 0}">
|
<td data-bind="css:{'red-line': dirty}">
|
||||||
<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>
|
|
||||||
<input class="form-control form-control-sm"
|
<input class="form-control form-control-sm"
|
||||||
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
|
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
|
||||||
value:hourdate, visible:inEdit(),
|
value:hourdate,
|
||||||
event:{change:$root.saveEmployeehour}"
|
event:{change:$root.saveEmployeehour}"
|
||||||
</td>
|
</td>
|
||||||
<td data-bind="css:{'red-line': id() == 0}">
|
<td data-bind="css:{'red-line': dirty}">
|
||||||
<span data-bind="text:dbo.helpers.findArrayElement('id', 'description', hourtype_id(), $root.hourtypes()),
|
|
||||||
visible: ! inEdit()"></span>
|
|
||||||
<select class="form-control form-control-sm"
|
<select class="form-control form-control-sm"
|
||||||
data-bind="options:$root.hourtypes,
|
data-bind="options:$root.hourtypes,
|
||||||
optionsText:'description',
|
optionsText:'description',
|
||||||
optionsValue:'id',
|
optionsValue:'id',
|
||||||
value:hourtype_id,
|
value:hourtype_id,
|
||||||
optionsCaptiuon:'selecteer...',
|
optionsCaption:'selecteer...',
|
||||||
visible:inEdit(),
|
|
||||||
event:{change:$root.saveEmployeehours}"></select>
|
event:{change:$root.saveEmployeehours}"></select>
|
||||||
</td>
|
</td>
|
||||||
<td data-bind="css:{'red-line': id() == 0}">
|
<td data-bind="css:{'red-line': dirty}">
|
||||||
<!-- ko if: hourType() == 'PROJECTS' -->
|
<!-- 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"
|
<select class="form-control form-control-sm"
|
||||||
data-bind="options:projects,
|
data-bind="options:$root.projects,
|
||||||
optionsText:'projectname',
|
optionsText:'projectFull',
|
||||||
optionsValue:'projectID',
|
optionsValue:'projectID',
|
||||||
value:projectID,
|
value:projectID,
|
||||||
optionsCaption:'selecteer...',
|
optionsCaption:'selecteer...',
|
||||||
visible:inEdit(),
|
|
||||||
event:{change:$root.saveEmployeehours}"></select>
|
event:{change:$root.saveEmployeehours}"></select>
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
<!-- ko if: hourType() == 'OFFERS' -->
|
<!-- 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"
|
<select class="form-control form-control-sm"
|
||||||
data-bind="options:$root.offersWithoutProject,
|
data-bind="options:$root.offersWithoutProject,
|
||||||
optionsText:'offername',
|
optionsText:'offername',
|
||||||
optionsValue:'id',
|
optionsValue:'id',
|
||||||
value:projectID,
|
value:projectID,
|
||||||
optionsCaption:'selecteer...',
|
optionsCaption:'selecteer...',
|
||||||
visible:inEdit(),
|
|
||||||
event:{change:$root.saveEmployeehours}"></select>
|
event:{change:$root.saveEmployeehours}"></select>
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
</td>
|
</td>
|
||||||
<td class="align-right" data-bind="css:{'red-line': id() == 0}">
|
<td class="align-right" data-bind="css:{'red-line': dirty}">
|
||||||
<span data-bind=" visible: ! inEdit()">
|
<input type="number"
|
||||||
<span data-bind="text:hours"></span>
|
|
||||||
uur
|
|
||||||
</span>
|
|
||||||
<input type="text"
|
|
||||||
class="form-control form-control-sm align-right"
|
class="form-control form-control-sm align-right"
|
||||||
paceholder="uren"
|
paceholder="uren"
|
||||||
data-bind="textInput:hours, visible:inEdit,
|
data-bind="textInput:hours,
|
||||||
event:{change:$root.saveEmployeehours,keyup:$root.validateNumber.bind($data, 'hours')}"/>
|
enable:canFillInHours,
|
||||||
|
event:{keyup:$root.saveDelayedEmployeehours,
|
||||||
|
change: $root.saveDelayedEmployeehours}"/>
|
||||||
</td>
|
</td>
|
||||||
<td data-bind="css:{'red-line': id() == 0}">
|
<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-edit pointer" title="wijzig" data-bind="click:$root.editEmployeehour"></i>-->
|
||||||
<i class="icon fa-trash redish pointer" title="verwijder"
|
<i class="icon fa-trash redish pointer" title="verwijder"
|
||||||
data-bind="click:$root.removeEmployeehour"></i>
|
data-bind="click:$root.removeEmployeehour"></i>
|
||||||
</td>
|
</td>
|
||||||
@@ -125,4 +99,4 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
<span data-bind="text:acceptance_chance"></span> %
|
<span data-bind="text:acceptance_chance"></span> %
|
||||||
</td>
|
</td>
|
||||||
<td data-bind="click:$root.selectOffer" class="pointer align-right">
|
<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>
|
||||||
<!-- <td data-bind="click:$root.selectOffer" class="pointer">-->
|
<!-- <td data-bind="click:$root.selectOffer" class="pointer">-->
|
||||||
<!-- <span data-bind="text:accepteddate"></span>-->
|
<!-- <span data-bind="text:accepteddate"></span>-->
|
||||||
@@ -78,6 +78,19 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<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"> </th>
|
||||||
|
<th class="align-right table-tealish-header">
|
||||||
|
€ <span data-bind="text:totalChanceOwnRevenue"></span>
|
||||||
|
</th>
|
||||||
|
<th class=" table-tealish-header"> </th>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="">
|
<td colspan="5" class="">
|
||||||
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newOffer">
|
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newOffer">
|
||||||
@@ -104,4 +117,4 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -77,6 +77,25 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<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>
|
<tr>
|
||||||
<td colspan="5" class="">
|
<td colspan="5" class="">
|
||||||
<!-- <button class="btn btn-primary btn-round btn-sm" data-bind="click:newProject">-->
|
<!-- <button class="btn btn-primary btn-round btn-sm" data-bind="click:newProject">-->
|
||||||
@@ -104,4 +123,4 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -10,13 +10,13 @@
|
|||||||
<th width="3%"> </th>
|
<th width="3%"> </th>
|
||||||
<th width="17%">project</th>
|
<th width="17%">project</th>
|
||||||
<th width="10%" class="align-right">Kosten derden</th>
|
<th width="10%" class="align-right">Kosten derden</th>
|
||||||
<th width="10%" class="align-right">gefactureerd</th>
|
<th width="10%" class="align-right">factuur INK</th>
|
||||||
<th width="10%" class="align-right">gereserveerd</th>
|
<th width="10%" class="align-right">budget onderaannemers</th>
|
||||||
<th width="10%" class="align-right">betaald</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">saldo te<br />betalen</th>
|
||||||
<th width="10%" class="align-right">betaald via<br />reserveringen</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 reservering</th>
|
||||||
<th width="10%" class="align-right">saldo te<br />factureren</th>
|
<th width="10%" class="align-right">saldo facturen INK</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<!-- ko foreach:projects -->
|
<!-- ko foreach:projects -->
|
||||||
@@ -135,4 +135,4 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -28,12 +28,19 @@ dbo.userDataService = {
|
|||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
getUserWithprojects: function ( callback ) {
|
getUserWithprojects: function ( callback ) {
|
||||||
$.getJSON( 'index.php/beheer/usersController/getUserWithprojects' )
|
$.getJSON( 'index.php/beheer/usersController/getUserWithprojects' )
|
||||||
.done( function ( data ) {
|
.done( function ( data ) {
|
||||||
callback( data );
|
callback( data );
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getUserActiveProjects: function ( userID, callback ) {
|
||||||
|
$.getJSON( 'index.php/beheer/usersController/getUserActiveProjects/' + userID )
|
||||||
|
.done( function ( data ) {
|
||||||
|
callback( data );
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
getUniqueProjectEmployees: function ( callback ) {
|
getUniqueProjectEmployees: function ( callback ) {
|
||||||
$.post( 'index.php/beheer/usersController/getUniqueprojectEmployees', 'json' )
|
$.post( 'index.php/beheer/usersController/getUniqueprojectEmployees', 'json' )
|
||||||
@@ -88,4 +95,4 @@ dbo.userDataService = {
|
|||||||
|
|
||||||
dbo.userDataService.getCurrentUser(function(data){
|
dbo.userDataService.getCurrentUser(function(data){
|
||||||
dbo.currentUser = data;
|
dbo.currentUser = data;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,237 +8,257 @@
|
|||||||
|
|
||||||
dbo.employeehoursInit = function () {
|
dbo.employeehoursInit = function () {
|
||||||
|
|
||||||
if ( dbo.employeehoursModel !== undefined ) {
|
var timeout;
|
||||||
dbo.employeehoursModel.init();
|
|
||||||
} else {
|
|
||||||
dbo.employeehoursModel = {
|
|
||||||
|
|
||||||
employeehours : ko.observableArray( [] ),
|
if ( dbo.employeehoursModel !== undefined ) {
|
||||||
archive : ko.observable( false ),
|
dbo.employeehoursModel.init();
|
||||||
months : ko.observableArray( [] ),
|
} else {
|
||||||
years : ko.observableArray( [] ),
|
dbo.employeehoursModel = {
|
||||||
hourtypes : ko.observableArray( [] ),
|
|
||||||
employees : ko.observableArray( [] ),
|
|
||||||
selectedYear : ko.observable(),
|
|
||||||
selectedMonth : ko.observable(),
|
|
||||||
busy : false,
|
|
||||||
selectedEmployeeID : ko.observable(),
|
|
||||||
offersWithoutProject: ko.observableArray( [] ),
|
|
||||||
|
|
||||||
init: function () {
|
employeehours : ko.observableArray( [] ),
|
||||||
var vm = dbo.employeehoursModel;
|
archive : ko.observable( false ),
|
||||||
|
months : ko.observableArray( [] ),
|
||||||
|
years : ko.observableArray( [] ),
|
||||||
|
hourtypes : ko.observableArray( [] ),
|
||||||
|
employees : ko.observableArray( [] ),
|
||||||
|
selectedYear : ko.observable(),
|
||||||
|
selectedMonth : ko.observable(),
|
||||||
|
busy : false,
|
||||||
|
selectedEmployeeID : ko.observable(),
|
||||||
|
offersWithoutProject: ko.observableArray( [] ),
|
||||||
|
projects : ko.observableArray( [] ),
|
||||||
|
|
||||||
vm.busy = true;
|
init: function () {
|
||||||
|
var vm = dbo.employeehoursModel;
|
||||||
|
|
||||||
vm.months( dbo.monthArray );
|
vm.busy = true;
|
||||||
vm.years( dbo.years );
|
|
||||||
|
|
||||||
vm.selectedMonth( dbo.currentMonth );
|
vm.months( dbo.monthArray );
|
||||||
vm.selectedYear( dbo.currentYear );
|
vm.years( dbo.years );
|
||||||
|
|
||||||
dbo.employeehoursDataService.getHourtypes( function ( data ) {
|
vm.selectedMonth( dbo.currentMonth );
|
||||||
vm.hourtypes( data );
|
vm.selectedYear( dbo.currentYear );
|
||||||
dbo.offerDataService.getOffersWithoutProject( function ( data ) {
|
|
||||||
vm.offersWithoutProject( data );
|
|
||||||
dbo.userDataService.getUserWithprojects( function ( data ) {
|
|
||||||
vm.employees.removeAll();
|
|
||||||
_.each( data, function ( p ) {
|
|
||||||
vm.employees.push( new vm.Employee( p ) );
|
|
||||||
} );
|
|
||||||
vm.selectedEmployeeID( dbo.currentUser.id )
|
|
||||||
|
|
||||||
vm.busy = false;
|
vm.selectedEmployeeID( dbo.currentUser.id );
|
||||||
vm.refreshEmployeehours();
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
},
|
|
||||||
|
|
||||||
newEmployeehour: function () {
|
dbo.userDataService.getAllUsers( 'F', function ( data ) {
|
||||||
var vm = dbo.employeehoursModel;
|
vm.employees( data );
|
||||||
|
|
||||||
var employeeHour = vm.employeehours()[vm.employeehours().length - 1];
|
dbo.employeehoursDataService.getHourtypes( function ( data ) {
|
||||||
|
vm.hourtypes( data );
|
||||||
|
dbo.offerDataService.getOffersWithoutProject( function ( data ) {
|
||||||
|
vm.offersWithoutProject( data );
|
||||||
|
vm.busy = false;
|
||||||
|
vm.refreshEmployeehours();
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
var employeeID = null;
|
newEmployeehour: function () {
|
||||||
if ( !vm.selectedEmployeeID ) {
|
var vm = dbo.employeehoursModel;
|
||||||
employeeID = employeeHour ? employeeHour.employee_id() : null;
|
|
||||||
} else {
|
|
||||||
employeeID = vm.selectedEmployeeID();
|
|
||||||
}
|
|
||||||
|
|
||||||
var employeehour = {
|
var employeeHour = vm.employeehours()[vm.employeehours().length - 1];
|
||||||
id : 0,
|
|
||||||
employee_id: employeeID,
|
|
||||||
hourdate : employeeHour ? employeeHour.hourdate() : null,
|
|
||||||
hourtype_id: employeeHour ? employeeHour.hourtype_id() : 9,
|
|
||||||
project_id : employeeHour ? employeeHour.projectID() : null,
|
|
||||||
hours : 0,
|
|
||||||
inEdit : true
|
|
||||||
};
|
|
||||||
|
|
||||||
vm.employeehours.push( new vm.Employeehour( employeehour ) );
|
var employeeID = null;
|
||||||
},
|
if ( !vm.selectedEmployeeID ) {
|
||||||
|
employeeID = employeeHour ? employeeHour.employee_id() : null;
|
||||||
|
} else {
|
||||||
|
employeeID = vm.selectedEmployeeID();
|
||||||
|
}
|
||||||
|
|
||||||
toggleArchive: function () {
|
var employeehour = {
|
||||||
var vm = dbo.employeeemployeehoursModel;
|
id : 0,
|
||||||
|
employee_id: employeeID,
|
||||||
|
hourdate : employeeHour ? employeeHour.hourdate() : null,
|
||||||
|
hourtype_id: employeeHour ? employeeHour.hourtype_id() : 9,
|
||||||
|
project_id : employeeHour ? employeeHour.projectID() : null,
|
||||||
|
hours : 0,
|
||||||
|
inEdit : true,
|
||||||
|
dirty : true
|
||||||
|
};
|
||||||
|
|
||||||
vm.archive( !vm.archive() );
|
vm.employeehours.push( new vm.Employeehour( employeehour ) );
|
||||||
|
},
|
||||||
|
|
||||||
vm.refreshHours();
|
toggleArchive: function () {
|
||||||
},
|
var vm = dbo.employeehoursModel;
|
||||||
|
|
||||||
saveEmployeehours: function ( self = false ) {
|
vm.archive( !vm.archive() );
|
||||||
if ( !self ) self = this;
|
|
||||||
|
|
||||||
if ( !self.employee_id() ) return;
|
vm.refreshHours();
|
||||||
if ( !self.hourtype_id() ) return;
|
},
|
||||||
if ( !self.hourdate() ) return;
|
|
||||||
if ( self.hourType() == 'PROJECTS' && !self.projectID() ) return;
|
|
||||||
if ( self.hourType() == 'OFFERS' && !self.projectID() ) return;
|
|
||||||
|
|
||||||
var submitDATA = {
|
saveDelayedEmployeehours: function () {
|
||||||
id : self.id(),
|
var vm = dbo.employeehoursModel;
|
||||||
employee_id: self.employee_id(),
|
var self = this;
|
||||||
hourdate : self.hourdate(),
|
self.dirty( true );
|
||||||
hourtype_id: self.hourtype_id(),
|
if ( timeout ) {
|
||||||
hours : self.hours(),
|
clearTimeout( timeout );
|
||||||
hourType : self.hourType(),
|
timeout = null;
|
||||||
project_id : self.projectID()
|
}
|
||||||
};
|
timeout = setTimeout( function () {
|
||||||
|
vm.saveEmployeehours( self );
|
||||||
|
}, 300 );
|
||||||
|
},
|
||||||
|
|
||||||
dbo.employeehoursDataService.saveEmployeehour( submitDATA, function ( data ) {
|
saveEmployeehours: function ( self = false ) {
|
||||||
self.id( data.employeehourID );
|
self.dirty( true );
|
||||||
} );
|
if ( !self ) self = this;
|
||||||
},
|
|
||||||
|
|
||||||
editEmployeehour: function () {
|
if ( !self.employee_id() ) return;
|
||||||
dbo.employeehoursModel.saveEmployeehours( this );
|
if ( !self.hourtype_id() ) return;
|
||||||
this.inEdit( !this.inEdit() );
|
if ( !self.hourdate() ) return;
|
||||||
},
|
if ( self.hours() <= 0 ) return;
|
||||||
|
if ( self.hourType() == 'PROJECTS' && !self.projectID() ) return;
|
||||||
|
if ( self.hourType() == 'OFFERS' && !self.projectID() ) return;
|
||||||
|
|
||||||
changeEmployee: function () {
|
var submitDATA = {
|
||||||
var vm = dbo.employeehoursModel;
|
id : self.id(),
|
||||||
this.projects( vm.setEmployeeProjects( this ) );
|
employee_id: self.employee_id(),
|
||||||
|
hourdate : self.hourdate(),
|
||||||
|
hourtype_id: self.hourtype_id(),
|
||||||
|
hours : self.hours(),
|
||||||
|
hourType : self.hourType(),
|
||||||
|
project_id : self.projectID()
|
||||||
|
};
|
||||||
|
|
||||||
this.projectID( null );
|
dbo.employeehoursDataService.saveEmployeehour( submitDATA, function ( data ) {
|
||||||
|
self.id( data.employeehourID );
|
||||||
|
self.dirty( false );
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
vm.saveEmployeehours( this );
|
editEmployeehour: function () {
|
||||||
},
|
dbo.employeehoursModel.saveEmployeehours( this );
|
||||||
|
this.inEdit( !this.inEdit() );
|
||||||
|
},
|
||||||
|
|
||||||
removeEmployeehour: function () {
|
changeEmployee: function () {
|
||||||
var vm = dbo.employeehoursModel;
|
var vm = dbo.employeehoursModel;
|
||||||
var self = this;
|
this.projects( vm.setEmployeeProjects( this ) );
|
||||||
|
|
||||||
tellMe( {
|
this.projectID( null );
|
||||||
title : 'verwijderen uren',
|
|
||||||
message : 'weet u zeker dat u deze uren wilt verwijderen, dit kan niet ongedaan worden gemaakt',
|
|
||||||
notify : true,
|
|
||||||
noText : 'nee verwijder de uren niet',
|
|
||||||
yesText : 'ja verwijder de uren',
|
|
||||||
modalClass: 'modal-warning'
|
|
||||||
}, function ( response ) {
|
|
||||||
if ( response ) {
|
|
||||||
dbo.employeehoursDataService.removeEmployeehour( self.id(), self.hourType(), function ( data ) {
|
|
||||||
if ( data.result ) {
|
|
||||||
vm.refreshEmployeehours();
|
|
||||||
} else {
|
|
||||||
tellMe( {
|
|
||||||
title : 'fout bij verwijderen uren',
|
|
||||||
message : 'de uren konden niet worden verwijderd',
|
|
||||||
modalClass: 'modal-danger'
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
},
|
|
||||||
|
|
||||||
refreshEmployeehours: function () {
|
vm.saveEmployeehours( this );
|
||||||
var vm = dbo.employeehoursModel;
|
},
|
||||||
|
|
||||||
if( vm.busy == true ) return;
|
removeEmployeehour: function () {
|
||||||
|
var vm = dbo.employeehoursModel;
|
||||||
|
var self = this;
|
||||||
|
|
||||||
var employeeID = vm.selectedEmployeeID() || 0;
|
tellMe( {
|
||||||
|
title : 'verwijderen uren',
|
||||||
|
message : 'weet u zeker dat u deze uren wilt verwijderen, dit kan niet ongedaan worden gemaakt',
|
||||||
|
notify : true,
|
||||||
|
noText : 'nee verwijder de uren niet',
|
||||||
|
yesText : 'ja verwijder de uren',
|
||||||
|
modalClass: 'modal-warning'
|
||||||
|
}, function ( response ) {
|
||||||
|
if ( response ) {
|
||||||
|
dbo.employeehoursDataService.removeEmployeehour( self.id(), self.hourType(), function ( data ) {
|
||||||
|
if ( data.result ) {
|
||||||
|
vm.refreshEmployeehours();
|
||||||
|
} else {
|
||||||
|
tellMe( {
|
||||||
|
title : 'fout bij verwijderen uren',
|
||||||
|
message : 'de uren konden niet worden verwijderd',
|
||||||
|
modalClass: 'modal-danger'
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
vm.employeehours.removeAll();
|
refreshEmployeehours: function () {
|
||||||
dbo.employeehoursDataService.getEmployeehours(
|
var vm = dbo.employeehoursModel;
|
||||||
vm.selectedMonth(), vm.selectedYear(), employeeID, function ( data ) {
|
|
||||||
$.each( data, function ( i, p ) {
|
|
||||||
vm.employeehours.push( new vm.Employeehour( p ) );
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
},
|
|
||||||
|
|
||||||
validateNumber: function ( field ) {
|
if ( vm.busy == true ) return;
|
||||||
this[field]( dbo.helpers.validateNumber( this[field](), true ) );
|
|
||||||
},
|
|
||||||
|
|
||||||
Employee: function ( data ) {
|
var employeeID = vm.selectedEmployeeID() || 0;
|
||||||
var vm = dbo.employeehoursModel;
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
self.id = data.id;
|
vm.employeehours.removeAll();
|
||||||
self.fullname = data.fullname;
|
dbo.employeehoursDataService.getEmployeehours(
|
||||||
|
vm.selectedMonth(), vm.selectedYear(), employeeID, function ( data ) {
|
||||||
|
$.each( data, function ( i, p ) {
|
||||||
|
vm.employeehours.push( new vm.Employeehour( p ) );
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
self.projecten = ko.observableArray( [] );
|
validateNumber: function ( field ) {
|
||||||
_.each( data.projectemployees, function ( p ) {
|
this[field]( dbo.helpers.validateNumber( this[field](), true ) );
|
||||||
if ( p.project )
|
},
|
||||||
self.projecten.push( new vm.Project( p ) );
|
|
||||||
} );
|
Employee: function ( data ) {
|
||||||
|
var vm = dbo.employeehoursModel;
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
self.id = data.id;
|
||||||
|
self.fullname = data.fullname;
|
||||||
|
|
||||||
|
self.projecten = ko.observableArray( [] );
|
||||||
|
_.each( data.projectemployees, function ( p ) {
|
||||||
|
if ( p.project )
|
||||||
|
self.projecten.push( new vm.Project( p ) );
|
||||||
|
} );
|
||||||
// _.each( vm.offersWithoutProject(), function ( p ) {
|
// _.each( vm.offersWithoutProject(), function ( p ) {
|
||||||
// self.projecten.push( new vm.Offer( p, self.id ) );
|
// self.projecten.push( new vm.Offer( p, self.id ) );
|
||||||
// } );
|
// } );
|
||||||
},
|
},
|
||||||
|
|
||||||
Project: function ( data ) {
|
Project: function ( data ) {
|
||||||
this.projectEmployeeID = data.id;
|
this.projectEmployeeID = data.id;
|
||||||
this.type = 'PROJECT';
|
this.type = 'PROJECT';
|
||||||
this.projectID = data.project.id;
|
this.projectID = data.project.id;
|
||||||
this.project = data.project.projectnumber + ' - ' + data.project.projectname;
|
this.project = data.project.projectnumber + ' - ' + data.project.projectname;
|
||||||
},
|
this.projectname = data.project.projectnumber + ' - ' + data.project.projectname;
|
||||||
|
},
|
||||||
|
|
||||||
Offer: function ( data, employeeID ) {
|
Offer: function ( data, employeeID ) {
|
||||||
this.projectemployeeID = employeeID;
|
this.projectemployeeID = employeeID;
|
||||||
this.type = 'OFFER';
|
this.type = 'OFFER';
|
||||||
this.projectID = data.id;
|
this.projectID = data.id;
|
||||||
this.project = data.offernumber + ' - ' + data.offername;
|
this.project = data.offernumber + ' - ' + data.offername;
|
||||||
},
|
},
|
||||||
|
|
||||||
Employeehour: function ( data ) {
|
Employeehour: function ( data ) {
|
||||||
var vm = dbo.employeehoursModel;
|
var vm = dbo.employeehoursModel;
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
self.id = ko.observable( data.id );
|
self.id = ko.observable( data.id );
|
||||||
self.employee_id = ko.observable( data.employee_id );
|
self.employee_id = ko.observable( data.employee_id );
|
||||||
self.hourtype_id = ko.observable( data.hourtype_id );
|
self.hourtype_id = ko.observable( data.hourtype_id );
|
||||||
self.hourdate = ko.observable( data.hourdate );
|
self.hourdate = ko.observable( data.hourdate );
|
||||||
self.hours = ko.observable( data.hours );
|
self.hours = ko.observable( data.hours );
|
||||||
self.inEdit = ko.observable( data.inEdit || false );
|
self.inEdit = ko.observable( data.inEdit || false );
|
||||||
self.projectID = ko.observable( data.project_id );
|
self.projectID = ko.observable( data.project_id );
|
||||||
self.hourType = ko.pureComputed( function () {
|
self.dirty = ko.observable( data.dirty || false );
|
||||||
return dbo.helpers.findArrayElement( 'id', 'key', this.hourtype_id(), vm.hourtypes() );
|
self.hourType = ko.pureComputed( function () {
|
||||||
}, this );
|
return dbo.helpers.findArrayElement( 'id', 'key', this.hourtype_id(), vm.hourtypes() );
|
||||||
|
}, this );
|
||||||
|
self.canFillInHours = ko.pureComputed( function () {
|
||||||
|
if ( self.hourType() == 'PROJECTS' || self.hourType() == 'OFFERS' ) {
|
||||||
|
if ( !self.projectID() ) {
|
||||||
|
self.hours( 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vm.setEmployeeProjects( self );
|
|
||||||
},
|
|
||||||
|
|
||||||
setEmployeeProjects: function ( self ) {
|
return true;
|
||||||
var vm = dbo.employeehoursModel;
|
} );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var employeeProjects =
|
dbo.employeehoursModel.init();
|
||||||
dbo.helpers.findArrayElement( 'id', 'projecten', self.employee_id(), vm.employees() );
|
|
||||||
self.projects = ko.observableArray( [] );
|
|
||||||
_.each( employeeProjects, function ( p ) {
|
|
||||||
self.projects.push( {
|
|
||||||
projectID : p.projectID,
|
|
||||||
projectname: p.project
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
dbo.employeehoursModel.init();
|
ko.applyBindings( dbo.employeehoursModel, document.getElementById( 'EMPLOYEEHOURS' ) );
|
||||||
|
|
||||||
ko.applyBindings( dbo.employeehoursModel, document.getElementById( 'EMPLOYEEHOURS' ) );
|
dbo.employeehoursModel.selectedEmployeeID.subscribe( function () {
|
||||||
}
|
dbo.userDataService.getUserActiveProjects( dbo.currentUser.id, function ( data ) {
|
||||||
|
dbo.employeehoursModel.projects( data );
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,87 +7,89 @@
|
|||||||
|
|
||||||
|
|
||||||
dbo.offersInit = function () {
|
dbo.offersInit = function () {
|
||||||
var timeout;
|
var timeout;
|
||||||
|
|
||||||
if ( dbo.offersModel !== undefined ) {
|
if ( dbo.offersModel !== undefined ) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dbo.offersModel = {
|
dbo.offersModel = {
|
||||||
|
|
||||||
tableName : 'OFFER',
|
tableName : 'OFFER',
|
||||||
offers : ko.observableArray( [] ),
|
offers : ko.observableArray( [] ),
|
||||||
offer : ko.observable(),
|
offer : ko.observable(),
|
||||||
archive : ko.observable( false ),
|
archive : ko.observable( false ),
|
||||||
comments : ko.observableArray( [] ),
|
comments : ko.observableArray( [] ),
|
||||||
documents : ko.observableArray( [] ),
|
documents : ko.observableArray( [] ),
|
||||||
selectedRowID: ko.observable(),
|
selectedRowID : ko.observable(),
|
||||||
projectID : 0,
|
projectID : 0,
|
||||||
search : ko.observable(''),
|
search : ko.observable( '' ),
|
||||||
order : ko.observable('offernumber'),
|
order : ko.observable( 'offernumber' ),
|
||||||
direction : ko.observable(),
|
direction : ko.observable(),
|
||||||
|
totalOwnRevenue : ko.observable( 0 ),
|
||||||
|
totalChanceOwnRevenue: ko.observable( 0 ),
|
||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
service.vm = dbo.offersModel;
|
service.vm = dbo.offersModel;
|
||||||
|
|
||||||
service.refreshOffers();
|
service.refreshOffers();
|
||||||
},
|
},
|
||||||
|
|
||||||
searchOffers: function () {
|
searchOffers: function () {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
if ( timeout ) {
|
if ( timeout ) {
|
||||||
clearTimeout( timeout );
|
clearTimeout( timeout );
|
||||||
timeout = null;
|
timeout = null;
|
||||||
}
|
}
|
||||||
timeout = setTimeout( function () {
|
timeout = setTimeout( function () {
|
||||||
service.refreshOffers();
|
service.refreshOffers();
|
||||||
}, 700 );
|
}, 700 );
|
||||||
},
|
},
|
||||||
|
|
||||||
directionOrderOffers : function(field){
|
directionOrderOffers: function ( field ) {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
|
|
||||||
service.directionOrderOffers(field);
|
service.directionOrderOffers( field );
|
||||||
},
|
},
|
||||||
|
|
||||||
newOffer: function () {
|
newOffer: function () {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
service.vm = dbo.offersModel;
|
service.vm = dbo.offersModel;
|
||||||
|
|
||||||
service.newOffer();
|
service.newOffer();
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleArchive: function () {
|
toggleArchive: function () {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
service.vm = dbo.offersModel;
|
service.vm = dbo.offersModel;
|
||||||
|
|
||||||
service.toggleArchive();
|
service.toggleArchive();
|
||||||
},
|
},
|
||||||
|
|
||||||
editOffer: function () {
|
editOffer: function () {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
service.vm = dbo.offersModel;
|
service.vm = dbo.offersModel;
|
||||||
|
|
||||||
service.editOffer( this );
|
service.editOffer( this );
|
||||||
},
|
},
|
||||||
|
|
||||||
archiveOffer: function () {
|
archiveOffer: function () {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
service.vm = dbo.offersModel;
|
service.vm = dbo.offersModel;
|
||||||
|
|
||||||
service.archiveOffer( this );
|
service.archiveOffer( this );
|
||||||
},
|
},
|
||||||
|
|
||||||
removeOffer: function () {
|
removeOffer: function () {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
service.vm = dbo.offersModel;
|
service.vm = dbo.offersModel;
|
||||||
|
|
||||||
service.removeOffer( this );
|
service.removeOffer( this );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
dbo.offersModel.init();
|
dbo.offersModel.init();
|
||||||
|
|
||||||
ko.applyBindings( dbo.offersModel, document.getElementById( 'OFFERS' ) );
|
ko.applyBindings( dbo.offersModel, document.getElementById( 'OFFERS' ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,196 +7,212 @@
|
|||||||
|
|
||||||
|
|
||||||
dbo.projectsInit = function () {
|
dbo.projectsInit = function () {
|
||||||
var timeout;
|
var timeout;
|
||||||
|
|
||||||
if ( dbo.projectsModel !== undefined ) {
|
if ( dbo.projectsModel !== undefined ) {
|
||||||
dbo.projectsModel.refreshProjects();
|
dbo.projectsModel.refreshProjects();
|
||||||
} else {
|
} else {
|
||||||
dbo.projectsModel = {
|
dbo.projectsModel = {
|
||||||
|
|
||||||
projects : ko.observableArray( [] ),
|
projects : ko.observableArray( [] ),
|
||||||
project : ko.observable(),
|
project : ko.observable(),
|
||||||
archive : ko.observable( false ),
|
archive : ko.observable( false ),
|
||||||
selectedRowID: ko.observable(),
|
selectedRowID : ko.observable(),
|
||||||
busy : false,
|
busy : false,
|
||||||
search : ko.observable(),
|
search : ko.observable(),
|
||||||
order : ko.observable( 'projectnumber' ),
|
order : ko.observable( 'projectnumber' ),
|
||||||
direction : ko.observable(),
|
direction : ko.observable(),
|
||||||
|
totalOwnRevenue : ko.observable( 0 ),
|
||||||
|
totalOtherrevenue: ko.observable( 0 ),
|
||||||
|
totalCosts : ko.observable( 0 ),
|
||||||
|
total : ko.observable( 0 ),
|
||||||
|
|
||||||
init: function () {
|
|
||||||
var vm = dbo.projectsModel;
|
|
||||||
|
|
||||||
vm.refreshProjects();
|
init: function () {
|
||||||
},
|
var vm = dbo.projectsModel;
|
||||||
|
|
||||||
searchProjects: function () {
|
vm.refreshProjects();
|
||||||
var vm = dbo.projectsModel;
|
},
|
||||||
if ( timeout ) {
|
|
||||||
clearTimeout( timeout );
|
|
||||||
timeout = null;
|
|
||||||
}
|
|
||||||
timeout = setTimeout( function () {
|
|
||||||
vm.refreshProjects();
|
|
||||||
}, 700 );
|
|
||||||
},
|
|
||||||
|
|
||||||
directionOrderProjects: function ( field ) {
|
searchProjects: function () {
|
||||||
var vm = dbo.projectsModel;
|
var vm = dbo.projectsModel;
|
||||||
|
if ( timeout ) {
|
||||||
|
clearTimeout( timeout );
|
||||||
|
timeout = null;
|
||||||
|
}
|
||||||
|
timeout = setTimeout( function () {
|
||||||
|
vm.refreshProjects();
|
||||||
|
}, 700 );
|
||||||
|
},
|
||||||
|
|
||||||
if ( field == vm.order() ) {
|
directionOrderProjects: function ( field ) {
|
||||||
vm.direction( !vm.direction() );
|
var vm = dbo.projectsModel;
|
||||||
} else {
|
|
||||||
vm.direction( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
vm.order( field );
|
if ( field == vm.order() ) {
|
||||||
|
vm.direction( !vm.direction() );
|
||||||
|
} else {
|
||||||
|
vm.direction( true );
|
||||||
|
}
|
||||||
|
|
||||||
vm.refreshProjects();
|
vm.order( field );
|
||||||
},
|
|
||||||
|
|
||||||
newProject: function () {
|
vm.refreshProjects();
|
||||||
var vm = dbo.projectsModel;
|
},
|
||||||
dbo.editProjectModal.addProject( function () {
|
|
||||||
vm.refreshProjects();
|
|
||||||
} );
|
|
||||||
},
|
|
||||||
|
|
||||||
toggleArchive: function () {
|
newProject: function () {
|
||||||
var vm = dbo.projectsModel;
|
var vm = dbo.projectsModel;
|
||||||
|
dbo.editProjectModal.addProject( function () {
|
||||||
|
vm.refreshProjects();
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
vm.archive( !vm.archive() );
|
toggleArchive: function () {
|
||||||
|
var vm = dbo.projectsModel;
|
||||||
|
|
||||||
vm.refreshProjects();
|
vm.archive( !vm.archive() );
|
||||||
},
|
|
||||||
|
|
||||||
editProject: function () {
|
vm.refreshProjects();
|
||||||
var project = this;
|
},
|
||||||
var vm = dbo.projectsModel;
|
|
||||||
|
|
||||||
dbo.editProjectModal.editProject( project.id, function () {
|
editProject: function () {
|
||||||
vm.refreshProjects();
|
var project = this;
|
||||||
} );
|
var vm = dbo.projectsModel;
|
||||||
},
|
|
||||||
|
|
||||||
selectProject: function () {
|
dbo.editProjectModal.editProject( project.id, function () {
|
||||||
var vm = dbo.projectsModel;
|
vm.refreshProjects();
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
vm.selectedRowID( this.id );
|
selectProject: function () {
|
||||||
},
|
var vm = dbo.projectsModel;
|
||||||
|
|
||||||
archiveProject: function () {
|
vm.selectedRowID( this.id );
|
||||||
var vm = dbo.projectsModel;
|
},
|
||||||
var self = this;
|
|
||||||
|
|
||||||
var status = self.archive == 'F' ? 'T' : 'F';
|
archiveProject: function () {
|
||||||
|
var vm = dbo.projectsModel;
|
||||||
|
var self = this;
|
||||||
|
|
||||||
dbo.projectDataService.archiveProject( self.id, status, function () {
|
var status = self.archive == 'F' ? 'T' : 'F';
|
||||||
vm.refreshProjects();
|
|
||||||
} );
|
|
||||||
},
|
|
||||||
|
|
||||||
removeProject: function () {
|
dbo.projectDataService.archiveProject( self.id, status, function () {
|
||||||
var vm = dbo.projectsModel;
|
vm.refreshProjects();
|
||||||
var self = this;
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
tellMe( {
|
removeProject: function () {
|
||||||
title : 'verwijderen projecte',
|
var vm = dbo.projectsModel;
|
||||||
message : 'weet u zeker dat u de project wilt verwijderen, dit kan niet ongedaan worden gemaakt',
|
var self = this;
|
||||||
notify : true,
|
|
||||||
noText : 'nee verwijder de project niet',
|
|
||||||
yesText : 'ja verwijder de project',
|
|
||||||
modalClass: 'modal-warning'
|
|
||||||
}, function ( response ) {
|
|
||||||
console.log( response );
|
|
||||||
if ( response ) {
|
|
||||||
dbo.projectDataService.removeProject( self.id, function ( data ) {
|
|
||||||
if ( data.result ) {
|
|
||||||
tellMe( {
|
|
||||||
title : 'project verwijderd',
|
|
||||||
message : 'de project is succesvol verwijderd',
|
|
||||||
modalClass: 'modal-success'
|
|
||||||
}, function () {
|
|
||||||
vm.refreshProjects();
|
|
||||||
} );
|
|
||||||
} else {
|
|
||||||
tellMe( {
|
|
||||||
title : 'fout bij verwijderen project',
|
|
||||||
message : 'de project kan niet worden verwijderd, verwijder eerst de gerelateerde gegevens (facturen, reserveringen, projectmedewerkers, prognoses) ',
|
|
||||||
modalClass: 'modal-danger'
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
},
|
|
||||||
|
|
||||||
refreshProjects: function () {
|
tellMe( {
|
||||||
var vm = dbo.projectsModel;
|
title : 'verwijderen projecte',
|
||||||
var projectsObject = {
|
message : 'weet u zeker dat u de project wilt verwijderen, dit kan niet ongedaan worden gemaakt',
|
||||||
archive : vm.archive() ? 'T' : 'F',
|
notify : true,
|
||||||
search : vm.search(),
|
noText : 'nee verwijder de project niet',
|
||||||
order : vm.order(),
|
yesText : 'ja verwijder de project',
|
||||||
direction: vm.direction() ? 'ASC' : 'DESC'
|
modalClass: 'modal-warning'
|
||||||
}
|
}, function ( response ) {
|
||||||
|
console.log( response );
|
||||||
|
if ( response ) {
|
||||||
|
dbo.projectDataService.removeProject( self.id, function ( data ) {
|
||||||
|
if ( data.result ) {
|
||||||
|
tellMe( {
|
||||||
|
title : 'project verwijderd',
|
||||||
|
message : 'de project is succesvol verwijderd',
|
||||||
|
modalClass: 'modal-success'
|
||||||
|
}, function () {
|
||||||
|
vm.refreshProjects();
|
||||||
|
} );
|
||||||
|
} else {
|
||||||
|
tellMe( {
|
||||||
|
title : 'fout bij verwijderen project',
|
||||||
|
message : 'de project kan niet worden verwijderd, verwijder eerst de gerelateerde gegevens (facturen, reserveringen, projectmedewerkers, prognoses) ',
|
||||||
|
modalClass: 'modal-danger'
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
dbo.projectDataService.getAllProjects( projectsObject, function ( data ) {
|
refreshProjects: function () {
|
||||||
vm.projects.removeAll();
|
var vm = dbo.projectsModel;
|
||||||
$.each( data, function ( i, p ) {
|
var projectsObject = {
|
||||||
vm.projects.push( new vm.Project( p ) );
|
archive : vm.archive() ? 'T' : 'F',
|
||||||
} )
|
search : vm.search(),
|
||||||
} );
|
order : vm.order(),
|
||||||
},
|
direction: vm.direction() ? 'ASC' : 'DESC'
|
||||||
|
}
|
||||||
|
|
||||||
Project: function ( data ) {
|
dbo.projectDataService.getAllProjects( projectsObject, function ( data ) {
|
||||||
var vm = dbo.projectsModel;
|
vm.totalOwnRevenue(0);
|
||||||
|
vm.totalOtherrevenue(0);
|
||||||
|
vm.totalCosts(0);
|
||||||
|
vm.total(0);
|
||||||
|
vm.projects.removeAll();
|
||||||
|
$.each( data, function ( i, p ) {
|
||||||
|
vm.projects.push( new vm.Project( p ) );
|
||||||
|
} )
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
var self = this;
|
Project: function ( data ) {
|
||||||
self.id = data.id;
|
var vm = dbo.projectsModel;
|
||||||
self.projectnumber = data.projectnumber;
|
|
||||||
self.projectleader = data.projectleader ? data.projectleader.fullname : '#NB';
|
|
||||||
self.projectname = data.projectname;
|
|
||||||
self.customer = data.customer ? data.customer.name : '#NB';
|
|
||||||
self.startdate = data.startdate;
|
|
||||||
self.enddate = data.enddate;
|
|
||||||
self.archive = data.archive;
|
|
||||||
|
|
||||||
self.totalOwnrevenue = Number( data.offer.own_revenue );
|
var self = this;
|
||||||
self.totalOtherrevenue = Number( data.offer.other_revenue );
|
self.id = data.id;
|
||||||
self.costs = Number( data.offer.costs );
|
self.projectnumber = data.projectnumber;
|
||||||
self.total = Number( data.offer.own_revenue ) + Number( data.offer.other_revenue ) + Number( data.offer.costs );
|
self.projectleader = data.projectleader ? data.projectleader.fullname : '#NB';
|
||||||
},
|
self.projectname = data.projectname;
|
||||||
|
self.customer = data.customer ? data.customer.name : '#NB';
|
||||||
|
self.startdate = data.startdate;
|
||||||
|
self.enddate = data.enddate;
|
||||||
|
self.archive = data.archive;
|
||||||
|
|
||||||
Revenue: function ( data ) {
|
self.totalOwnrevenue = Number( data.offer.own_revenue );
|
||||||
var vm = dbo.projectsModel;
|
self.totalOtherrevenue = Number( data.offer.other_revenue );
|
||||||
var self = this;
|
self.costs = Number( data.offer.costs );
|
||||||
|
self.total = Number( data.offer.own_revenue ) + Number( data.offer.other_revenue ) + Number( data.offer.costs );
|
||||||
|
|
||||||
self.id = data.id;
|
vm.totalOwnRevenue( vm.totalOwnRevenue() + self.totalOwnrevenue )
|
||||||
self.offernumber = data.offernumber;
|
vm.totalOtherrevenue( vm.totalOtherrevenue() + self.totalOtherrevenue )
|
||||||
self.startdate = dbo.helpers.mysql2date( self.startdate );
|
vm.totalCosts( vm.totalCosts() + self.costs )
|
||||||
self.accepteddate = dbo.helpers.mysql2date( self.accepteddate );
|
vm.total( Math.round(vm.total() + self.total) )
|
||||||
self.rejectdate = dbo.helpers.mysql2date( self.rejectdate );
|
|
||||||
self.own_revenue = data.own_revenue;
|
|
||||||
self.other_revenue = data.other_revenue;
|
|
||||||
self.acceptance_chance = data.acceptance_chance;
|
|
||||||
|
|
||||||
self.payed = 0;
|
|
||||||
self.payments = ko.observableArray( [] );
|
|
||||||
$.each( data.payments, function ( i, p ) {
|
|
||||||
self.payed = +p.paymentamount;
|
|
||||||
|
|
||||||
self.payments.push( new vm.Payment( p ) );
|
},
|
||||||
} );
|
|
||||||
},
|
|
||||||
|
|
||||||
Payment: function ( data ) {
|
Revenue: function ( data ) {
|
||||||
self.id = data.id;
|
var vm = dbo.projectsModel;
|
||||||
self.paymentdate = dbo.helpers.mysql2date( self.paymentdate );
|
var self = this;
|
||||||
self.paymentamount = data.paymentamount;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
dbo.projectsModel.init();
|
self.id = data.id;
|
||||||
|
self.offernumber = data.offernumber;
|
||||||
|
self.startdate = dbo.helpers.mysql2date( self.startdate );
|
||||||
|
self.accepteddate = dbo.helpers.mysql2date( self.accepteddate );
|
||||||
|
self.rejectdate = dbo.helpers.mysql2date( self.rejectdate );
|
||||||
|
self.own_revenue = data.own_revenue;
|
||||||
|
self.other_revenue = data.other_revenue;
|
||||||
|
self.acceptance_chance = data.acceptance_chance;
|
||||||
|
|
||||||
ko.applyBindings( dbo.projectsModel, document.getElementById( 'PROJECTS' ) );
|
self.payed = 0;
|
||||||
}
|
self.payments = ko.observableArray( [] );
|
||||||
}
|
$.each( data.payments, function ( i, p ) {
|
||||||
|
self.payed = +p.paymentamount;
|
||||||
|
|
||||||
|
self.payments.push( new vm.Payment( p ) );
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
|
Payment: function ( data ) {
|
||||||
|
self.id = data.id;
|
||||||
|
self.paymentdate = dbo.helpers.mysql2date( self.paymentdate );
|
||||||
|
self.paymentamount = data.paymentamount;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
dbo.projectsModel.init();
|
||||||
|
|
||||||
|
ko.applyBindings( dbo.projectsModel, document.getElementById( 'PROJECTS' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,128 +8,136 @@
|
|||||||
|
|
||||||
dbo.offersService = {
|
dbo.offersService = {
|
||||||
|
|
||||||
vm: null,
|
vm: null,
|
||||||
|
|
||||||
newOffer: function (projectID=false, customerID=false) {
|
newOffer: function ( projectID = false, customerID = false ) {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
|
|
||||||
dbo.editOfferModal.newEditOffer( false, projectID, customerID, true, function () {
|
dbo.editOfferModal.newEditOffer( false, projectID, customerID, true, function () {
|
||||||
service.refreshOffers();
|
service.refreshOffers();
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleArchive: function () {
|
toggleArchive: function () {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
var vm = dbo.offersService.vm;
|
var vm = dbo.offersService.vm;
|
||||||
|
|
||||||
vm.archive( !vm.archive() );
|
vm.archive( !vm.archive() );
|
||||||
|
|
||||||
service.refreshOffers();
|
service.refreshOffers();
|
||||||
},
|
},
|
||||||
|
|
||||||
editOffer: function ( that, projectID=false, custormerID=false, hasProject=false ) {
|
editOffer: function ( that, projectID = false, custormerID = false, hasProject = false ) {
|
||||||
var offer = that;
|
var offer = that;
|
||||||
|
|
||||||
dbo.editOfferModal.newEditOffer( offer, projectID, custormerID, hasProject, function () {
|
dbo.editOfferModal.newEditOffer( offer, projectID, custormerID, hasProject, function () {
|
||||||
dbo.offersService.refreshOffers();
|
dbo.offersService.refreshOffers();
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
archiveOffer: function ( that ) {
|
archiveOffer: function ( that ) {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
|
|
||||||
var status = that.archive == 'F' ? 'T' : 'F';
|
var status = that.archive == 'F' ? 'T' : 'F';
|
||||||
|
|
||||||
dbo.offerDataService.archiveOffer( that.id, status, function () {
|
dbo.offerDataService.archiveOffer( that.id, status, function () {
|
||||||
service.refreshOffers();
|
service.refreshOffers();
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
removeOffer: function ( that ) {
|
removeOffer: function ( that ) {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
|
|
||||||
tellMe( {
|
tellMe( {
|
||||||
title : 'verwijderen offerte',
|
title : 'verwijderen offerte',
|
||||||
message : 'weet u zeker dat u de offerte wilt verwijderen, dit kan niet ongedaan worden gemaakt',
|
message : 'weet u zeker dat u de offerte wilt verwijderen, dit kan niet ongedaan worden gemaakt',
|
||||||
notify : true,
|
notify : true,
|
||||||
noText : 'nee verwijder de offerte niet',
|
noText : 'nee verwijder de offerte niet',
|
||||||
yesText : 'ja verwijder de offerte',
|
yesText : 'ja verwijder de offerte',
|
||||||
modalClass: 'modal-warning'
|
modalClass: 'modal-warning'
|
||||||
}, function ( response ) {
|
}, function ( response ) {
|
||||||
if ( response ) {
|
if ( response ) {
|
||||||
dbo.offerDataService.removeOffer( that.id, function ( data ) {
|
dbo.offerDataService.removeOffer( that.id, function ( data ) {
|
||||||
if ( data.result ) {
|
if ( data.result ) {
|
||||||
tellMe( {
|
tellMe( {
|
||||||
title : 'offerte verwijderd',
|
title : 'offerte verwijderd',
|
||||||
message : 'de offerte is succesvol verwijderd',
|
message : 'de offerte is succesvol verwijderd',
|
||||||
modalClass: 'modal-success'
|
modalClass: 'modal-success'
|
||||||
}, function () {
|
}, function () {
|
||||||
service.refreshOffers();
|
service.refreshOffers();
|
||||||
} );
|
} );
|
||||||
} else {
|
} else {
|
||||||
tellMe( {
|
tellMe( {
|
||||||
title : 'fout bij verwijderen offerte',
|
title : 'fout bij verwijderen offerte',
|
||||||
message : 'de offerte kan niet worden verwijderd, verwijder eerst het gerelateerde project',
|
message : 'de offerte kan niet worden verwijderd, verwijder eerst het gerelateerde project',
|
||||||
modalClass: 'modal-danger'
|
modalClass: 'modal-danger'
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
directionOrderOffers: function ( field ) {
|
directionOrderOffers: function ( field ) {
|
||||||
var vm = dbo.offersModel;
|
var vm = dbo.offersModel;
|
||||||
var self = dbo.offersService;
|
var self = dbo.offersService;
|
||||||
|
|
||||||
if ( field == vm.order() ) {
|
if ( field == vm.order() ) {
|
||||||
vm.direction( !vm.direction() );
|
vm.direction( !vm.direction() );
|
||||||
} else {
|
} else {
|
||||||
vm.direction( true );
|
vm.direction( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.order( field );
|
vm.order( field );
|
||||||
|
|
||||||
self.refreshOffers();
|
self.refreshOffers();
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshOffers: function () {
|
refreshOffers: function () {
|
||||||
var vm = dbo.offersService.vm;
|
var vm = dbo.offersService.vm;
|
||||||
var self = dbo.offersService;
|
var self = dbo.offersService;
|
||||||
|
|
||||||
var offersObject = {
|
var offersObject = {
|
||||||
projectID: vm.projectID,
|
projectID: vm.projectID,
|
||||||
archive : vm.archive() ? 'T' : 'F',
|
archive : vm.archive() ? 'T' : 'F',
|
||||||
search : vm.search(),
|
search : vm.search(),
|
||||||
order : vm.order(),
|
order : vm.order(),
|
||||||
direction: vm.direction() ? 'ASC' : 'DESC'
|
direction: vm.direction() ? 'ASC' : 'DESC'
|
||||||
}
|
}
|
||||||
|
|
||||||
dbo.offerDataService.getAllOffers( offersObject, function ( data ) {
|
dbo.offerDataService.getAllOffers( offersObject, function ( data ) {
|
||||||
vm.offers.removeAll();
|
vm.offers.removeAll();
|
||||||
$.each( data, function ( i, p ) {
|
$.each( data, function ( i, p ) {
|
||||||
vm.offers.push( new self.Offer( p ) );
|
vm.totalOwnRevenue( 0 );
|
||||||
} );
|
vm.totalChanceOwnRevenue( 0 );
|
||||||
} );
|
vm.offers.push( new self.Offer( p ) );
|
||||||
},
|
} );
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
Offer: function ( data ) {
|
Offer: function ( data ) {
|
||||||
this.id = data.id;
|
var vm = dbo.offersModel;
|
||||||
this.offernumber = data.offernumber;
|
this.id = data.id;
|
||||||
this.offername = data.offername;
|
this.offernumber = data.offernumber;
|
||||||
this.offerleader_id = data.offerleader_id;
|
this.offername = data.offername;
|
||||||
this.project_id = data.project_id;
|
this.offerleader_id = data.offerleader_id;
|
||||||
this.acceptance_chance = data.acceptance_chance;
|
this.project_id = data.project_id;
|
||||||
this.projectNumber = data.project ? data.project.projectnumber : null;
|
this.acceptance_chance = data.acceptance_chance;
|
||||||
this.customerName = data.customer ? data.customer.name : null;
|
this.projectNumber = data.project ? data.project.projectnumber : null;
|
||||||
this.customer_id = data.customer_id;
|
this.customerName = data.customer ? data.customer.name : null;
|
||||||
this.startdate = data.startdate ? dbo.helpers.mysql2date( data.startdate ) : null;
|
this.customer_id = data.customer_id;
|
||||||
this.rejectdate = data.rejectdate ? dbo.helpers.mysql2date( data.rejectdate ) : null;
|
this.startdate = data.startdate ? dbo.helpers.mysql2date( data.startdate ) : null;
|
||||||
this.accepteddate = data.accepteddate ? dbo.helpers.mysql2date( data.accepteddate ) : null;
|
this.rejectdate = data.rejectdate ? dbo.helpers.mysql2date( data.rejectdate ) : null;
|
||||||
this.acceptance_chance = data.acceptance_chance ? data.acceptance_chance : 0;
|
this.accepteddate = data.accepteddate ? dbo.helpers.mysql2date( data.accepteddate ) : null;
|
||||||
this.own_revenue = data.own_revenue;
|
this.acceptance_chance = data.acceptance_chance ? data.acceptance_chance : 0;
|
||||||
this.other_revenue = data.other_revenue;
|
this.other_revenue = data.other_revenue;
|
||||||
this.costs = data.costs;
|
this.own_revenue = data.own_revenue;
|
||||||
this.archive = data.archive;
|
this.chanceOwnRevenue = Math.round( (Number( data.own_revenue ) * data.acceptance_chance) / 100 );
|
||||||
}
|
this.costs = data.costs;
|
||||||
};
|
this.archive = data.archive;
|
||||||
|
|
||||||
|
vm.totalOwnRevenue( Number( vm.totalOwnRevenue() ) + Number( this.own_revenue ) );
|
||||||
|
vm.totalChanceOwnRevenue( Number( vm.totalChanceOwnRevenue() ) + Number( this.chanceOwnRevenue ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user