71 lines
1.6 KiB
PHP
71 lines
1.6 KiB
PHP
<?php
|
|
defined( 'BASEPATH' ) OR exit( 'No direct script access allowed' );
|
|
|
|
/**
|
|
* Created by Pensare Software.
|
|
* User: Theo Weijmer
|
|
* Date: 05/01/2018
|
|
* Time: 15:03
|
|
*/
|
|
class OffersController extends MY_Controller {
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
|
|
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
|
|
|
|
$models = [];
|
|
$libraries = [];
|
|
|
|
$this->load->model( $models );
|
|
$this->load->library( $libraries );
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
|
|
}
|
|
|
|
public function getAllOffers( $projectID, $archive = 'F' )
|
|
{
|
|
$offers = Offer::getAllOffers( $projectID, $archive );
|
|
|
|
$this->json( $offers );
|
|
}
|
|
|
|
public function saveOffer()
|
|
{
|
|
$offerValidation = new OfferValidation();
|
|
|
|
if ( ! $offerValidation->getValidationResult() )
|
|
return $this->json( [
|
|
'success' => FALSE, 'messages' => $offerValidation->getErrorMessages()] );
|
|
|
|
$offer = $this->input->post();
|
|
|
|
$offerID = $offer['id'];
|
|
unset( $offer['id'] );
|
|
|
|
$offerID = Offer::saveOffer( $offerID, $offer );
|
|
|
|
$this->json( ['success' => TRUE, 'offerID' => $offerID] );
|
|
}
|
|
|
|
public function archiveOffer( $offerID, $status )
|
|
{
|
|
Offer::whereId( $offerID )->update( ['archive' => $status] );
|
|
}
|
|
|
|
public function removeOffer( $offerID )
|
|
{
|
|
$removeOffer = new RemoveOffer( $offerID );
|
|
|
|
if ( $removeOffer->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
|
|
|
|
Offer::removeOffer( $offerID );
|
|
|
|
$this->json( ['result' => TRUE] );
|
|
}
|
|
|
|
} |