コード例 #1
0
 public function company()
 {
     $id = $this->request->get('id');
     $company = $this->companyModel->getByID($id);
     if (!$company) {
         $this->server->sendNotFound();
     }
     $data = $this->relationModel->getForCompanyID($id);
     $this->server->sendData($data);
 }
コード例 #2
0
 public function destroy()
 {
     $id = $this->request->get('id');
     $relation = $this->relationModel->getByID($id);
     if ($relation) {
         if ($relation->inAgrement()) {
             $this->server->sendConflict(HLang::get(Lang::alert_cant_delete_relation__in_agreement));
         }
         $relation->getItem()->delete();
         $this->server->sendOK();
     } else {
         $this->server->sendNotFound();
     }
 }
コード例 #3
0
ファイル: Agreement.php プロジェクト: JoniJnm/dokify2
 /**
  * @param int id_relation
  */
 public function addRelation($id_relation)
 {
     $out = true;
     if ($this->isEmpty()) {
         $this->addClient($id_relation);
     } else {
         $relation = $this->relationModel->getByID($id_relation);
         if ($relation->getClient()->getItem()->id == $this->getLastProvider()->getItem()->id) {
             $this->addProvider($id_relation);
         } elseif ($relation->getProvider()->getItem()->id == $this->getFirstClient()->getItem()->id) {
             $this->addClient($id_relation);
         } else {
             $out = false;
             //invalid relation!
         }
     }
     $this->clearCache();
     return $out;
 }