public static function updateAdRep($adRep, $name, $email, $phone) { if ($adRep instanceof AdRep) { $query = "UPDATE " . Database::addPrefix('adreps') . "\n\t\t\t\t\tSET name = '" . $name . "', email = '" . $email . "',\n\t\t\t\t\tphone = '" . $phone . "'\n\t\t\t\t \tWHERE AdRepID = '" . Database::makeStringSafe($adRep->getID()) . "' LIMIT 1"; Database::doQuery($query); return AdRepDao::getAdRepByID($adRep->getID()); } else { $query = "UPDATE " . Database::addPrefix('clients') . "\n\t\t\t\t\t\t\t\tSET name = '" . $name . "', email = '" . $email . "',\n\t\t\t\t\t\t\t\tphone = '" . $phone . "', address = '" . $address . "'\n\t\t\t\t\t\t\t \tWHERE AdRepID = '" . Database::makeStringSafe($client) . "' LIMIT 1"; Database::doQuery($query); return AdRepDao::getAdRepByID($adRep); } }
function generateHTML() { $login = LoginDao::getLoginByUsername(SessionUtil::getUsername()); if ($login->getType() == Login::CLIENT) { $client = ClientDao::getClientByLogin($login); return $this->context->getErrorHTML() . "<div class=\"centered\">\n\t\t\n\t\t\t\t<h3>Login</h3>\n\t\t\t\t\n\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"changePassword\" />\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"password\" placeholder=\"Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Repeat Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"repeatpassword\" placeholder=\"Repeat Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<input type=\"submit\" value=\"Change Password\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t</form>\n\t\t\t\t\n\t\t\t\t<h3>Account Info</h3>\n\t\t\t\t\n\t\t\t\t<div style=\"width: 45%; margin-left: auto; margin-right: auto;\">\n\t\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t\t<div style=\"float: left; text-align: left;\">\n\t\t\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"updateAccount\" />\n\t\t\t\t\t\t\t<label for=\"name\" class=\"above\">Name</label>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"name\" placeholder=\"Name\" value=\"" . $client->getName() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t\t<label for=\"email\" class=\"above\">Email</label>\n\t\t\t\t\t\t\t<input type=\"email\" name=\"email\" placeholder=\"Email\" value=\"" . $client->getEmail() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t\t<label for=\"phone\" class=\"above\">Phone</label>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"phone\" placeholder=\"Phone\" value=\"" . $client->getPhone() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div style=\"float: right; text-align: right;\">\n\t\t\t\t\t\t\t<br /><label for=\"address\" class=\"above\">Address</label>\n\t\t\t\t\t\t\t<textarea name=\"address\" rows=\"3\" cols=\"23\" class=\"text bluefocus\">" . $client->getAddress() . "</textarea>\n\t\t\t\t\t\t\t<br /><br /><input type=\"submit\" value=\"Update Account\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</form>\n\t\t\t\t</div>\n\t\t\t\n\t\t\t</div>"; } else { if ($login->getType() == Login::ADREP) { $adrep = AdRepDao::getAdRepByLogin($login); return $this->context->getErrorHTML() . "<div class=\"centered\">\n\t\t\n\t\t\t\t<h3>Login Info</h3>\n\t\t\t\t\n\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"changePassword\" />\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"password\" placeholder=\"Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Repeat Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"repeatpassword\" placeholder=\"Repeat Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<input type=\"submit\" value=\"Change Password\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t</form>\n\t\t\t\t\n\t\t\t\t<h3>Account Info (Ad Rep)</h3>\n\t\t\t\t\n\t\t\t\t<div style=\"width: 45%; margin-left: auto; margin-right: auto;\">\n\t\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t\t<div style=\"float: left; text-align: left;\">\n\t\t\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"updateAccount\" />\n\t\t\t\t\t\t\t<label for=\"name\" class=\"above\">Name</label>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"name\" placeholder=\"Name\" value=\"" . $adrep->getName() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t\t<label for=\"email\" class=\"above\">Email</label>\n\t\t\t\t\t\t\t<input type=\"email\" name=\"email\" placeholder=\"Email\" value=\"" . $adrep->getEmail() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div style=\"float: right; text-align: right;\">\n\t\t\t\t\t\t\t<label for=\"phone\" class=\"above\">Phone</label>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"phone\" placeholder=\"Phone\" value=\"" . $adrep->getPhone() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t\t<br /><br /><input type=\"submit\" value=\"Update Account\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</form>\n\t\t\t\t</div>\n\t\t\t\n\t\t\t</div>"; } else { return $this->context->getErrorHTML() . "<div class=\"centered\">\n\t\t\t\n\t\t\t\t<h3>Login Info</h3>\n\t\t\t\t\n\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"changePassword\" />\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"password\" placeholder=\"Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Repeat Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"repeatpassword\" placeholder=\"Repeat Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<input type=\"submit\" value=\"Change Password\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t</form>\n\t\t\t\t\n\t\t\t\t<h3>Account Info</h3>\n\t\t\t\t\n\t\t\t\t<div class=\"centered error\">Unknown Account Type</div>\n\t\t\t\n\t\t\t</div>"; } } }
private static function populateInsertionOrder($row) { $adRep; if (isset($row['AdRepId'])) { $adRep = AdRepDao::getAdRepByID($row['AdRepId']); } else { $adRep = AdRep::unassignedAdRep(); } $client = ClientDao::getClientByID($row['ClientID']); $status = InsertStatusDao::getByID($row['StatusID']); if (isset($row['DesignStatusID'])) { $designStatus = DesignStatusDao::getByID($row['DesignStatusID']); } else { $designStatus = DesignStatus::emptyDesignStatus(); } $billingStatus = BillingStatus::getStatusForName($row['BillingStatus']); return new InsertionOrder($row['InsertID'], $adRep, $client, $status, $designStatus, $billingStatus, $row['CreatedDate'], $row['UpdatedDate'], $row['InsertDate'], $row['Columns'], $row['Height'], $row['NumPlacements'], $row['Design'], $row['Color'], $row['NumInserts'], $row['Image']); }
public function handleForm(Context $context, $action) { if ($action == "changePassword") { if ($_POST['password'] != "" && $_POST['repeatpassword'] != "") { $sessionLogin = LoginDao::getLoginByUsername(SessionUtil::getUsername()); if ($_POST['password'] == $_POST['repeatpassword']) { LoginDao::updateUserPassword($sessionLogin, $_POST['password']); } else { $context->addError("Passwords don't match."); } } else { $context->addError("Required field left blank."); } } else { if ($action == "updateAccount") { if ($_POST['name'] != "" && $_POST['email'] != "" && $_POST['phone'] != "") { $sessionLogin = LoginDao::getLoginByUsername(SessionUtil::getUsername()); if ($sessionLogin->getType() == Login::ADREP) { $adrep = AdRepDao::getAdRepByLogin($sessionLogin); AdRepDao::updateAdRep($adrep, $_POST['name'], $_POST['email'], $_POST['phone']); } else { if ($sessionLogin->getType() == Login::CLIENT) { if ($_POST['address'] != "") { $client = ClientDao::getClientByLogin($sessionLogin); ClientDao::updateClient($client, $_POST['name'], $_POST['email'], $_POST['phone'], $_POST['address']); } else { $context->addError("Required field left blank."); } } else { $context->addError("Unknown Account Type."); } } } else { $context->addError("Required field left blank."); } } else { $context->addError("Incorrect Action."); } } }