function pinAssignPro($proname, $piname) { //Recoger id del professional $p = new Professional(); $boolean = $p->getId($proname); if ($boolean == false) { $msg = "Error: Professinal not found in system"; header("Location: ../views/pinAssigPro.php?msg={$msg}"); } else { $idProfessional = $boolean[0]["idProfessional"]; $pi = new Pincho(); $bool = $pi->getData($piname); if ($bool == false) { $msg = "Error: Pincho not found in system"; header("Location: ../views/pinAssigPro.php?msg={$msg}"); } else { $idPincho = $bool[0]["code"]; $idEstablishment = $bool[0]["Establishment_idEstablishment"]; $v = new ProfessionalValorations(); $bool2 = $v->isValid($idPincho); if ($bool2 == false) { $msg = "Error: Selected Pincho is actually assigned to Professional"; header("Location: ../views/pinAssigPro.php?msg={$msg}"); } else { $insert = $v->insert($idPincho, $idProfessional, $idEstablishment); if ($insert == false) { $msg = "Internal database Error.Please, try again"; header("Location: ../views/pinAssigPro.php?msg={$msg}"); } else { $msg = "Pincho assigned to Professional. Operation Done."; header("Location: ../views/pinAssigPro.php?msg={$msg}"); } } } } }