Update usw. fertig
This commit is contained in:
parent
ead2838bc1
commit
ad1327cc01
|
|
@ -8,7 +8,7 @@ return [
|
|||
# AGENCY
|
||||
//['name' => 'agency#show', 'url' => '/getagencydata', 'verb' => 'GET'],
|
||||
['name' => 'agency#show', 'url' => '/getagencydata', 'verb' => 'GET'],
|
||||
['name' => 'agency#update', 'url' => '/update', 'verb' => 'PUT'],
|
||||
['name' => 'agency#updateagencydata', 'url' => '/updateagencydata', 'verb' => 'PUT'],
|
||||
# DEVELOPMENT
|
||||
['name' => 'test#filetest', 'url' => '/filetest', 'verb' => 'GET'],
|
||||
]
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class AgencyManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* getAgencyIdByUser
|
||||
* getAgencyByUser
|
||||
*
|
||||
* @param:
|
||||
* - $request
|
||||
|
|
@ -42,15 +42,16 @@ class AgencyManager {
|
|||
* Return the Agency-ID by filtering the id from default agency-group, ex: agency_1 -> 1 (int)
|
||||
*
|
||||
*/
|
||||
public function getAgencyIdByUser(IUserSession $userSession){
|
||||
public function getAgencyByUser(IUserSession $userSession){
|
||||
$groups = $this->groupManager->getUserGroups($userSession->getUser());
|
||||
$agency_group_id = "";
|
||||
foreach($groups as $group){
|
||||
if(str_contains($group->getGId(), 'agency')){
|
||||
$agency_group_id = explode("_", strval($group->getGId()))[1];
|
||||
if(str_contains($group->getGId(), 'agencymaingroupid_')){
|
||||
$agency_group_id_array = explode("_", strval($group->getGId()));
|
||||
$agency_group_id = $agency_group_id_array[0]."_".$agency_group_id_array[1];
|
||||
}
|
||||
}
|
||||
return intval($agency_group_id);
|
||||
return $this->agencyMapper->getAgencyByGId($agency_group_id);
|
||||
#return $agency_group_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -44,10 +44,10 @@ class AgencyController extends Controller {
|
|||
*
|
||||
*/
|
||||
public function show() {
|
||||
$id = $this->agencyManager->getAgencyIdByUser($this->userSession);
|
||||
return $this->handleNotFound(function () use ($id) {
|
||||
return $this->service->find($id);
|
||||
});
|
||||
return $this->agencyManager->getAgencyByUser($this->userSession);
|
||||
#return $this->handleNotFound(function () use ($id) {
|
||||
# return $this->service->find($id);
|
||||
#});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -72,14 +72,12 @@ class AgencyController extends Controller {
|
|||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $title
|
||||
*/
|
||||
public function update(string $name = null, string $inhaber = null, string $street = null, string $plz = null, string $city = null, string $agencymail = null, string $phone = null) {
|
||||
public function updateagencydata(string $name = null, string $inhaber = null, string $street = null, string $plz = null, string $city = null, string $agencymail = null, string $phone = null) {
|
||||
|
||||
$id = $this->agencyManager->getAgencyIdByUser($this->userSession);
|
||||
$id = $this->agencyManager->getAgencyByUser($this->userSession)->getId();
|
||||
|
||||
return $this->handleNotFound(function () use ($id, $name, $inhaber, $street, $plz, $city, $agencymail, $phone) {
|
||||
# TODO: ABfrage machen!
|
||||
return $this->service->update($id, $name, $inhaber, $street, $plz, $city, $agencymail, $phone);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,4 +21,15 @@ class AgencyMapper extends QBMapper {
|
|||
|
||||
return $this->findEntity($qb);
|
||||
}
|
||||
|
||||
public function getAgencyByGId(string $gid) {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from($this->getTableName())
|
||||
->where(
|
||||
$qb->expr()->eq('agencygid', $qb->createNamedParameter($gid))
|
||||
);
|
||||
|
||||
return $this->findEntity($qb);
|
||||
}
|
||||
}
|
||||
|
|
@ -37,15 +37,8 @@ class AgencyService {
|
|||
}
|
||||
|
||||
//Create an Agency
|
||||
public function create(string $name = null, string $inhaber = null, string $street = null, string $plz = null, string $city = null, string $agencymail = null, string $phone = null, string $agencygid, string $agencydirid, string $standarddirid) {
|
||||
public function create(string $agencygid, string $agencydirid, string $standarddirid) {
|
||||
$agency = new Agency();
|
||||
$agency->setName($name);
|
||||
$agency->setInhaber($inhaber);
|
||||
$agency->setStreet($street);
|
||||
$agency->setPlz($plz);
|
||||
$agency->setCity($city);
|
||||
$agency->setAgencymail($agencymail);
|
||||
$agency->setPhone($phone);
|
||||
$agency->setAgencygid($agencygid);
|
||||
$agency->setAgencydirid($agencydirid);
|
||||
$agency->setStandarddirid($standarddirid);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,12 @@
|
|||
<b-col>
|
||||
<FormulateInput name="plz"
|
||||
label="PLZ"
|
||||
type="text" />
|
||||
type="text"
|
||||
:validation="[
|
||||
['required'],
|
||||
['max', 99999],
|
||||
['min', 10000]
|
||||
]" />
|
||||
</b-col>
|
||||
<b-col>
|
||||
<FormulateInput name="agencymail"
|
||||
|
|
@ -80,6 +85,7 @@
|
|||
import Content from '@nextcloud/vue/dist/Components/Content'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import '@braid/vue-formulate/themes/snow/snow.scss'
|
||||
// const axios = require('axios').default
|
||||
import axios from '@nextcloud/axios'
|
||||
|
||||
export default ({
|
||||
|
|
@ -103,7 +109,7 @@ export default ({
|
|||
this.isLoading = true
|
||||
},
|
||||
async submitHandler(data) {
|
||||
const response = await axios.put(generateUrl('/apps/agency/update'), data)
|
||||
const response = await axios.put(generateUrl('/apps/agency/updateagencydata'), data)
|
||||
console.log(response)
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue