86 lines
2.8 KiB
PHP
86 lines
2.8 KiB
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* Profile Settings controlls the actions for the shop
|
||
|
|
*/
|
||
|
|
class ProfileSettingsController{
|
||
|
|
private $model;
|
||
|
|
|
||
|
|
function __construct(){
|
||
|
|
$this->model = new ProfileSettingsModel();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* get info for a user profile
|
||
|
|
* @return [type] json containg profile info
|
||
|
|
*/
|
||
|
|
public function getProfileInfo(){
|
||
|
|
$idUser = isset($_REQUEST['idUser']) ? $_REQUEST['idUser'] : '';
|
||
|
|
$json = json_encode($this->model->getProfileInfo($idUser), JSON_NUMERIC_CHECK);
|
||
|
|
echo preg_replace('/'.STRING_START.'/', '', $json);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* save info for profile
|
||
|
|
* @return [type] json containg update message
|
||
|
|
*/
|
||
|
|
public function saveProfileInfo(){
|
||
|
|
$idUser = isset($_REQUEST['idUser']) ? $_REQUEST['idUser'] : '';
|
||
|
|
$profile = isset($_REQUEST['profile']) ? $_REQUEST['profile'] : '[]';
|
||
|
|
echo json_encode($this->model->saveProfileInfo($idUser, $profile), JSON_NUMERIC_CHECK);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* save company information
|
||
|
|
* @return [type] json containing update message
|
||
|
|
*/
|
||
|
|
public function saveCompanyInfo(){
|
||
|
|
$companyInfo = isset($_REQUEST['companyInfo']) ? $_REQUEST['companyInfo'] : '[]';
|
||
|
|
echo json_encode($this->model->saveCompanyInfo($companyInfo), JSON_NUMERIC_CHECK);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* remove delivery address
|
||
|
|
* @return json update message
|
||
|
|
*/
|
||
|
|
public function removeProfileAddress(){
|
||
|
|
$idProfileAddress = isset($_REQUEST['idProfileAddress']) ? $_REQUEST['idProfileAddress'] : 0;
|
||
|
|
echo json_encode($this->model->removeProfileAddress($idProfileAddress), JSON_NUMERIC_CHECK);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* save delivery address
|
||
|
|
* @return json update message
|
||
|
|
*/
|
||
|
|
public function saveProfileAddress(){
|
||
|
|
$profileAddress = isset($_REQUEST['profileAddress']) ? $_REQUEST['profileAddress'] : '[]';
|
||
|
|
echo json_encode($this->model->saveProfileAddress($profileAddress), JSON_NUMERIC_CHECK);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* remove billing address
|
||
|
|
* @return json update message
|
||
|
|
*/
|
||
|
|
public function removeBillingAddress(){
|
||
|
|
$idBillingAddress = isset($_REQUEST['idBillingAddress']) ? $_REQUEST['idBillingAddress'] : 0;
|
||
|
|
echo json_encode($this->model->removeBillingAddress($idBillingAddress), JSON_NUMERIC_CHECK);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* save billing address
|
||
|
|
* @return json update message
|
||
|
|
*/
|
||
|
|
public function saveBillingAddress(){
|
||
|
|
$idCompany = isset($_REQUEST['idCompany']) ? $_REQUEST['idCompany'] : 0;
|
||
|
|
$billingAddress = isset($_REQUEST['billingAddress']) ? $_REQUEST['billingAddress'] : '[]';
|
||
|
|
echo json_encode($this->model->saveBillingAddress($idCompany, $billingAddress), JSON_NUMERIC_CHECK);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* get countries array
|
||
|
|
* @return json countires array
|
||
|
|
*/
|
||
|
|
public function getCoutnries(){
|
||
|
|
echo json_encode($this->model->getCoutnries(), JSON_NUMERIC_CHECK);
|
||
|
|
}
|
||
|
|
}
|