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