Diversen
This commit is contained in:
@@ -41,6 +41,14 @@ class ProjectsController extends MY_Controller {
|
||||
$this->json( $project );
|
||||
}
|
||||
|
||||
public function getAvailableEmployees( $projectID )
|
||||
{
|
||||
$availableEmployees =
|
||||
Projectemployee::getAvailableEmployees( $projectID );
|
||||
|
||||
$this->json( $availableEmployees );
|
||||
}
|
||||
|
||||
public function addProject()
|
||||
{
|
||||
$projectID = Project::createProject();
|
||||
@@ -48,6 +56,30 @@ class ProjectsController extends MY_Controller {
|
||||
$this->json( $projectID );
|
||||
}
|
||||
|
||||
public function creatProjectFromOffer( $offerID )
|
||||
{
|
||||
$offer = Offer::find( $offerID );
|
||||
|
||||
$offernumber = $offer->offernumber;
|
||||
|
||||
$projectnumber = 'P' . substr( $offernumber, 1 );
|
||||
|
||||
$data = [
|
||||
'projectnumber' => $projectnumber,
|
||||
'projectleader_id' => $offer->offerleader_id,
|
||||
'startdate' => $offer->accepteddate,
|
||||
'customer_id' => $offer->customer_id
|
||||
];
|
||||
|
||||
$project = Project::create( $data );
|
||||
|
||||
Offer::whereId( $offerID )->update( ['project_id' => $project->id] );
|
||||
|
||||
Projectemployee::create( ['project_id' => $project->id, 'user_id' => $offer->offerleader_id] );
|
||||
|
||||
$this->json( ['success' => TRUE, 'projectnumber' => $projectnumber] );
|
||||
}
|
||||
|
||||
public function addProjectEmployee( $projectID )
|
||||
{
|
||||
Projectemployee::createProjectEmployee( $projectID );
|
||||
@@ -94,6 +126,29 @@ class ProjectsController extends MY_Controller {
|
||||
$this->json( ['success' => TRUE] );
|
||||
}
|
||||
|
||||
public function saveInvoice()
|
||||
{
|
||||
$invoiceValidation = new InvoiceValidation();
|
||||
|
||||
if ( ! $invoiceValidation->getValidationResult() )
|
||||
return $this->json( [
|
||||
'success' => FALSE, 'messages' => $invoiceValidation->getErrorMessages()] );
|
||||
|
||||
$invoice = $this->input->post();
|
||||
|
||||
$invoiceID = $invoice['id'];
|
||||
unset( $invoice['id'] );
|
||||
|
||||
$invoice['invoicedate'] = date2mysql( $invoice['invoicedate'] );
|
||||
$invoice['forecastdate'] = date2mysql( $invoice['forecastdate'] );
|
||||
$invoice['invoiceamount'] = str_replace( ',', '.', $invoice['invoiceamount'] );
|
||||
$invoice['forecastamount'] = str_replace( ',', '.', $invoice['forecastamount'] );
|
||||
|
||||
$invoiceID = Invoice::saveInvoice( $invoiceID, $invoice );
|
||||
|
||||
$this->json( ['success' => TRUE, 'invoiceID' => $invoiceID] );
|
||||
}
|
||||
|
||||
public function savePayment()
|
||||
{
|
||||
$paymentValidation = new PaymentValidation();
|
||||
@@ -108,10 +163,31 @@ class ProjectsController extends MY_Controller {
|
||||
unset( $payment['id'] );
|
||||
|
||||
$payment['paymentdate'] = date2mysql( $payment['paymentdate'] );
|
||||
$payment['paymentamount'] = str_replace( ',', '.', $payment['paymentamount'] );
|
||||
|
||||
$paymentID = Payment::savePayment( $paymentID, $payment );
|
||||
|
||||
$this->json( ['success' => TRUE, 'paymentID'=> $paymentID ] );
|
||||
$this->json( ['success' => TRUE, 'paymentID' => $paymentID] );
|
||||
}
|
||||
|
||||
public function saveProjectcost()
|
||||
{
|
||||
$projectcostValidation = new ProjectcostValidation();
|
||||
|
||||
if ( ! $projectcostValidation->getValidationResult() )
|
||||
return $this->json( [
|
||||
'success' => FALSE, 'messages' => $projectcostValidation->getErrorMessages()] );
|
||||
|
||||
$projectcost = $this->input->post();
|
||||
|
||||
$projectcostID = $projectcost['id'];
|
||||
unset( $projectcost['id'] );
|
||||
|
||||
$projectcost['date'] = date2mysql( $projectcost['date'] );
|
||||
|
||||
$projectcostID = Projectcost::saveProjectcost( $projectcostID, $projectcost );
|
||||
|
||||
$this->json( ['success' => TRUE, 'projectcostID' => $projectcostID] );
|
||||
}
|
||||
|
||||
public function saveProjecthour()
|
||||
@@ -131,7 +207,7 @@ class ProjectsController extends MY_Controller {
|
||||
|
||||
$paymentID = Projecthour::saveProjecthour( $projecthourID, $projecthour );
|
||||
|
||||
$this->json( ['success' => TRUE, 'projecthourID'=> $paymentID ] );
|
||||
$this->json( ['success' => TRUE, 'projecthourID' => $paymentID] );
|
||||
}
|
||||
|
||||
public function archiveProject( $projectID, $status )
|
||||
|
||||
Reference in New Issue
Block a user