69 lines
1.5 KiB
PHP
69 lines
1.5 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()
|
|
{
|
|
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
|
|
|
|
$models = [];
|
|
$libraries = [];
|
|
|
|
$this->load->model( $models );
|
|
$this->load->library( $libraries );
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
|
|
}
|
|
|
|
public function getAllOffers( $archive = 'F' )
|
|
{
|
|
$users = Offer::getAllOffers( $archive );
|
|
|
|
$this->json( $users );
|
|
}
|
|
|
|
public function saveOffer()
|
|
{
|
|
$userValidation = new OfferValidation();
|
|
|
|
if ( ! $userValidation->getValidationResult() )
|
|
return $this->json( [
|
|
'success' => FALSE, 'messages' => $userValidation->getErrorMessages()] );
|
|
|
|
$user = $this->input->post();
|
|
|
|
$userID = $user['id'];
|
|
unset( $user['id'] );
|
|
|
|
$userID = Offer::saveOffer( $userID, $user );
|
|
|
|
$this->json( ['success' => TRUE, 'userID' => $userID] );
|
|
}
|
|
|
|
public function archiveOffer( $userID, $status )
|
|
{
|
|
Offer::whereId( $userID )->update( ['archive' => $status] );
|
|
}
|
|
|
|
public function removeOffer( $userID )
|
|
{
|
|
$removeOffer = new RemoveOffer( $userID );
|
|
|
|
if ( $removeOffer->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
|
|
|
|
Offer::removeOffer( $userID );
|
|
|
|
$this->json( ['result' => TRUE] );
|
|
}
|
|
|
|
} |