Offers
This commit is contained in:
@@ -29,41 +29,41 @@ class customersController extends MY_Controller {
|
||||
|
||||
public function getAllCustomers( $archive = 'F' )
|
||||
{
|
||||
$users = Customer::getAllCustomers( $archive );
|
||||
$customers = Customer::getAllCustomers( $archive );
|
||||
|
||||
$this->json( $users );
|
||||
$this->json( $customers );
|
||||
}
|
||||
|
||||
public function saveCustomer()
|
||||
{
|
||||
$userValidation = new CustomerValidation();
|
||||
$customerValidation = new CustomerValidation();
|
||||
|
||||
if ( ! $userValidation->getValidationResult() )
|
||||
if ( ! $customerValidation->getValidationResult() )
|
||||
return $this->json( [
|
||||
'success' => FALSE, 'messages' => $userValidation->getErrorMessages()] );
|
||||
'success' => FALSE, 'messages' => $customerValidation->getErrorMessages()] );
|
||||
|
||||
$user = $this->input->post();
|
||||
$customer = $this->input->post();
|
||||
|
||||
$userID = $user['id'];
|
||||
unset( $user['id'] );
|
||||
$customerID = $customer['id'];
|
||||
unset( $customer['id'] );
|
||||
|
||||
$userID = Customer::saveCustomer( $userID, $user );
|
||||
$customerID = Customer::saveCustomer( $customerID, $customer );
|
||||
|
||||
$this->json( ['success' => TRUE, 'userID' => $userID] );
|
||||
$this->json( ['success' => TRUE, 'customerID' => $customerID] );
|
||||
}
|
||||
|
||||
public function archiveCustomer( $userID, $status )
|
||||
public function archiveCustomer( $customerID, $status )
|
||||
{
|
||||
Customer::whereId( $userID )->update( ['archive' => $status] );
|
||||
Customer::whereId( $customerID )->update( ['archive' => $status] );
|
||||
}
|
||||
|
||||
public function removeCustomer( $userID )
|
||||
public function removeCustomer( $customerID )
|
||||
{
|
||||
$removeCustomer = new RemoveCustomer( $userID );
|
||||
$removeCustomer = new RemoveCustomer( $customerID );
|
||||
|
||||
if ( $removeCustomer->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
|
||||
|
||||
Customer::removeCustomer( $userID );
|
||||
Customer::removeCustomer( $customerID );
|
||||
|
||||
$this->json( ['result' => TRUE] );
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ class OffersController extends MY_Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
|
||||
|
||||
$models = [];
|
||||
@@ -27,41 +29,41 @@ class OffersController extends MY_Controller {
|
||||
|
||||
public function getAllOffers( $archive = 'F' )
|
||||
{
|
||||
$users = Offer::getAllOffers( $archive );
|
||||
$offers = Offer::getAllOffers( $archive );
|
||||
|
||||
$this->json( $users );
|
||||
$this->json( $offers );
|
||||
}
|
||||
|
||||
public function saveOffer()
|
||||
{
|
||||
$userValidation = new OfferValidation();
|
||||
$offerValidation = new OfferValidation();
|
||||
|
||||
if ( ! $userValidation->getValidationResult() )
|
||||
if ( ! $offerValidation->getValidationResult() )
|
||||
return $this->json( [
|
||||
'success' => FALSE, 'messages' => $userValidation->getErrorMessages()] );
|
||||
'success' => FALSE, 'messages' => $offerValidation->getErrorMessages()] );
|
||||
|
||||
$user = $this->input->post();
|
||||
$offer = $this->input->post();
|
||||
|
||||
$userID = $user['id'];
|
||||
unset( $user['id'] );
|
||||
$offerID = $offer['id'];
|
||||
unset( $offer['id'] );
|
||||
|
||||
$userID = Offer::saveOffer( $userID, $user );
|
||||
$offerID = Offer::saveOffer( $offerID, $offer );
|
||||
|
||||
$this->json( ['success' => TRUE, 'userID' => $userID] );
|
||||
$this->json( ['success' => TRUE, 'offerID' => $offerID] );
|
||||
}
|
||||
|
||||
public function archiveOffer( $userID, $status )
|
||||
public function archiveOffer( $offerID, $status )
|
||||
{
|
||||
Offer::whereId( $userID )->update( ['archive' => $status] );
|
||||
Offer::whereId( $offerID )->update( ['archive' => $status] );
|
||||
}
|
||||
|
||||
public function removeOffer( $userID )
|
||||
public function removeOffer( $offerID )
|
||||
{
|
||||
$removeOffer = new RemoveOffer( $userID );
|
||||
$removeOffer = new RemoveOffer( $offerID );
|
||||
|
||||
if ( $removeOffer->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
|
||||
|
||||
Offer::removeOffer( $userID );
|
||||
Offer::removeOffer( $offerID );
|
||||
|
||||
$this->json( ['result' => TRUE] );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user