$this->set('relationshipsSoftwaresUsers', $this->paginate($this->RelationshipsSoftwaresUsers));
$this->set('_serialize', ['relationshipsSoftwaresUsers']);
}
-
+
/**
* Returns all services providers in Comptoir du libre.
- *
+ *
*/
public function getServicesProviders (){
if ( $this->request->is( 'get' ) && $this->response->type('json')) {
- $Relationships = $this->RelationshipsSoftwaresUsers->find('all',
+ $Relationships = $this->RelationshipsSoftwaresUsers->find('all',
[
'contain' => ["Users","Relationships"],
'conditions' => ["Relationships.cd = "=> $this->request->query['Relationships']],
])
- ->distinct("user_id")
+ ->distinct("user_id")
;
$message = "Success";
-
+
$this->set('relationshipsSoftwaresUsers',['message' => $message, 'Relationships'=>$Relationships]);
$this->set('_serialize', ['message','relationshipsSoftwaresUsers']);
}else {
'message' => $message,
'relationshipsSoftwaresUser' => $relationshipsSoftwaresUser,
'_serialize' => ['message', 'relationshipsSoftwaresUser']
- ]);
+ ]);
}
-
+
}
/**
'message' => $message,
'relationshipsSoftwaresUser' => $relationshipsSoftwaresUser,
'_serialize' => ['message', 'relationshipsSoftwaresUser']
- ]);
+ ]);
}else {//Pour le template avant d'avoir poster les données.
- $softwares = $this->RelationshipsSoftwaresUsers->Softwares->find('list', ['limit' => 200]);
- $users = $this->RelationshipsSoftwaresUsers->Users->find('list', ['limit' => 200]);
- $relationships = $this->RelationshipsSoftwaresUsers->Relationships->find('list', ['limit' => 200]);
+ $softwares = $this->RelationshipsSoftwaresUsers->Softwares->find('list', ['limit' => 200])->orderAsc('softwarename');
+ $users = $this->RelationshipsSoftwaresUsers->Users->find('list', ['limit' => 200])->orderAsc('username');
+ $relationships = $this->RelationshipsSoftwaresUsers->Relationships->find('list', ['limit' => 200])->orderAsc('name');
$this->set(compact('relationshipsSoftwaresUser', 'softwares', 'users', 'relationships'));
$this->set('_serialize', ['relationshipsSoftwaresUser']);
}
-
+
}
/**
} else {
$this->Flash->error(__('The relationships softwares user could not be saved. Please, try again.'));
}
-
+
$softwares = $this->RelationshipsSoftwaresUsers->Softwares->find('list', ['limit' => 200]);
$users = $this->RelationshipsSoftwaresUsers->Users->find('list', ['limit' => 200]);
$relationships = $this->RelationshipsSoftwaresUsers->Relationships->find('list', ['limit' => 200]);
$this->set(compact('relationshipsSoftwaresUser', 'softwares', 'users', 'relationships'));
- $this->set('_serialize', ['relationshipsSoftwaresUser']);
+ $this->set('_serialize', ['relationshipsSoftwaresUser']);
}else if ($this->request->is(['patch', 'post', 'put']) && $this->request->is('json')) {
$relationshipsSoftwaresUser = $this->RelationshipsSoftwaresUsers->patchEntity($relationshipsSoftwaresUser, $this->request->data);
if ($this->RelationshipsSoftwaresUsers->save($relationshipsSoftwaresUser)) {
$users = $this->RelationshipsSoftwaresUsers->Users->find('list', ['limit' => 200]);
$relationships = $this->RelationshipsSoftwaresUsers->Relationships->find('list', ['limit' => 200]);
$this->set(compact('relationshipsSoftwaresUser', 'softwares', 'users', 'relationships'));
- $this->set('_serialize', ['relationshipsSoftwaresUser']);
+ $this->set('_serialize', ['relationshipsSoftwaresUser']);
}
-
-
+
+
}
/**
}
return $this->redirect(['action' => 'index']);
}
-
+
/**
* Returns all userOf thanks to the software id passed as parameter.
* @param type $id
'contain' => ['Users',"Softwares"],
'conditions' => ["Softwares.id = "=> $id]
]);
-
+
$relationshipsSoftwaresUser->matching('Relationships', function ($q) {
return $q->where(['Relationships.cd' => 'UserOf']);
});
-
+
$this->set(compact('relationshipsSoftwaresUser','id'));
$this->set('_serialize', ['relationshipsSoftwaresUser','id']);
}
}
-
+
/**
* Returns all providers for thanks to the software id passed as parameter.
* @param type $id
'contain' => ['Users',"Softwares",'Relationships'],
'conditions' => ["Softwares.id = "=> $id,'Relationships.cd' => "ServicesProvider"]
]);
-
-
+
+
$this->set(compact('relationshipsSoftwaresUser','id'));
$this->set('_serialize', ['relationshipsSoftwaresUser','id']);
}
}
-
+
/**
* Returns all providers for thanks to the software id passed as parameter.
* @param type $id
*/
public function getRelationshipsBySoftwareId ($id=null){
- if ( $this->request->query("id")!=null
- && $this->request->is( 'get' )
+ if ( $this->request->query("id")!=null
+ && $this->request->is( 'get' )
&& $this->response->type('json') ) {
$relationshipsSoftwaresUser = $this->RelationshipsSoftwaresUsers->find('all', [
$this->set('_serialize', ['relationshipsSoftwaresUser']);
}
}
-
-
+
+
/**
* Returns all providers for thanks to the software id passed as parameter.
- * Use query parameters to filter :: Id; code;
+ * Use query parameters to filter :: Id; code;
* @param type $id
*/
public function getRelationshipsByUserId (){
if ( $this->request->query("id")!=null && $this->request->is( 'get' ) && $this->response->type('json')) {
-
+
$this->paginate = [
'contain' => ['Users',"Softwares",'Relationships'],
'conditions' => [ "user_id = "=> $this->request->query("id"),
"Relationships.cd = " => $this->request->query("filter")]
];
-
+
$this->set("relationshipsSoftwaresUsers",$this->paginate($this->RelationshipsSoftwaresUsers));
$this->set('_serialize', ['relationshipsSoftwaresUsers','paging']);
}