Files
dbois/application/controllers/beheer/EmployeeTargetController.php
T
2018-05-03 19:54:32 +02:00

55 lines
1.3 KiB
PHP

<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 21/04/2018
* Time: 20:08
*/
//include_once('../application/models/eloquent/Employeetarget.php');
class EmployeeTargetController extends MY_Controller {
public function __construct()
{
parent::__construct();
}
public function index()
{
}
public function getEmployeeTargets( $employeeID )
{
$employeeTargets = Employeetarget::whereUserId( $employeeID )
->orderBy( 'id' )
->get();
$this->json( $employeeTargets );
}
public function saveEmployeeTarget()
{
$employeeTargetValidation = new EmployeeTargetValidation();
if ( ! $employeeTargetValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $employeeTargetValidation->getErrorMessages()] );
$target = $this->input->post();
$targetID = $target['id'];
unset( $target['id'] );
$target['endmonth'] = $target['endmonth'] ? $target['endmonth'] : NULL;
$target['endyear'] = $target['endyear'] ? $target['endyear'] : NULL;
$targetID = Employeetarget::saveTarget( $targetID, $target );
$this->json( ['success' => TRUE, 'targetID' => $targetID] );
}
}