diff --git a/content/projekt/ressource.xml.php b/content/projekt/ressource.xml.php index 6fde510ea..f6eb032c4 100644 --- a/content/projekt/ressource.xml.php +++ b/content/projekt/ressource.xml.php @@ -43,6 +43,7 @@ echo ''; + '; ]]> + + + + soap/ressource_projekt.soap.php?"+gettimestamp(); + + function mycallb(obj) { + var me=obj; + this.invoke=function (respObj) { + try + { + var id = respObj.Body[0].deleteProjektRessourceResponse[0].message[0].Text; + } + catch(e) + { + var fehler = respObj.Body[0].Fault[0].faultstring[0].Text; + alert('Fehler: '+fehler); + return; + } + me.RefreshRessource(); + } + } + var cb=new mycallb(this); + + SOAPClient.SendRequest(sr,cb.invoke); + + } + catch(e) + { + debug("Ressource load failed with exception: "+e); + } + + + ]]> + + diff --git a/include/ressource.class.php b/include/ressource.class.php index 56585ef6e..7116a7c56 100644 --- a/include/ressource.class.php +++ b/include/ressource.class.php @@ -513,7 +513,66 @@ class ressource extends basis_db $this->errorsmg = 'Fehler beim Laden'; return false; } - } + + /** + * Löscht eine Ressource zu Projekt Zuordnung + * @param type $ressource_id + * @param type $projekt_kurzbz + * @return boolean + */ + public function deleteFromProjekt($ressource_id, $projekt_kurzbz) + { + if($ressource_id == '' || !is_numeric($ressource_id)) + { + $this->errormsg = 'Ressource Id ist keine gültige Zahl'; + return false; + } + + $qry="DELETE FROM fue.tbl_projekt_ressource WHERE ressource_id =".$this->db_add_param($ressource_id, FHC_INTEGER, false)." + AND projekt_kurzbz=".$this->db_add_param($projekt_kurzbz, FHC_STRING, false).';'; + + if($this->db_query($qry)) + { + return true; + } + else + { + $this->errormsg = 'Fehler beim Löschen der Daten'; + return false; + } + } + + /** + * Löscht eine Ressource zu Phase Zuordnung + * @param type $ressource_id + * @param type $projekt_kurzbz + * @return boolean + */ + public function deleteFromPhase($ressource_id, $projektphase_id) + { + if($ressource_id == '' || !is_numeric($ressource_id)) + { + $this->errormsg = 'Ressource Id ist keine gültige Zahl'; + return false; + } + + if($projektphase_id == '' || !is_numeric($projektphase_id)) + { + $this->errormsg = 'Ressource Id ist keine gültige Zahl'; + return false; + } + + $qry="DELETE FROM fue.tbl_projekt_ressource WHERE ressource_id =".$this->db_add_param($ressource_id, FHC_INTEGER, false)." + AND projektphase_id=".$this->db_add_param($projektphase_id, FHC_INTEGER, false).';'; + + if($this->db_query($qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Löschen der Daten'; + return false; + } + } } ?> \ No newline at end of file diff --git a/soap/ressource_projekt.soap.php b/soap/ressource_projekt.soap.php index 985df0e8c..620a3be36 100644 --- a/soap/ressource_projekt.soap.php +++ b/soap/ressource_projekt.soap.php @@ -33,6 +33,7 @@ require_once('../include/benutzerberechtigung.class.php'); $SOAPServer = new SoapServer(APP_ROOT."/soap/ressource_projekt.wsdl.php?".microtime()); $SOAPServer->addFunction("saveProjektRessource"); +$SOAPServer->addFunction("deleteProjektRessource"); $SOAPServer->handle(); // WSDL Chache auf aus @@ -79,6 +80,47 @@ function saveProjektRessource($username, $passwort, $projektRessource) else return new SoapFault("Server", $ressource->errormsg); } + +/** + * Löscht entweder eine Projekt zu Ressource oder Phase zu Ressource Zuordnung + * @param type $username + * @param type $passwort + * @param type $projektRessource + * @return \SoapFault + */ +function deleteProjektRessource($username, $passwort, $projektRessource) +{ + if(!$user = check_user($username, $passwort)) + return new SoapFault ("Server", "Invalid Credentials"); + + $recht = new benutzerberechtigung(); + $recht->getBerechtigungen($user); + + // if(!$rechte->isBerechtigt('planner', null, 'sui')) + // return new SoapFault("Server", "Sie haben keine Berechtigung zum Speichern von Projekten."); + + $ressource = new ressource(); + + if($projektRessource->projektphase_id != '') + { + // von Projektphase löschen + if($ressource->deleteFromPhase($projektRessource->ressource_id, $projektRessource->projektphase_id)) + return "Erfolg"; + else + return "Fehler beim Löschen"; + + } + else + { + // von Projekt löschen + if($ressource->deleteFromProjekt($projektRessource->ressource_id, $projektRessource->projekt_kurzbz)) + return "Erfolg"; + else + return "Fehler beim Löschen"; + + } +} + ?> diff --git a/soap/ressource_projekt.wsdl.php b/soap/ressource_projekt.wsdl.php index a234b4c40..45ff28953 100644 --- a/soap/ressource_projekt.wsdl.php +++ b/soap/ressource_projekt.wsdl.php @@ -33,11 +33,25 @@ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> + + + + + + + + + + + + + + @@ -51,6 +65,15 @@ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> + + " /> + + + + + + +