public function handleClientDesign(Context $context)
 {
     $insertDate = explode('/', $_POST['insertdate']);
     $mysqlFormattedDate = $insertDate[2] . "-" . $insertDate[1] . "-" . $insertDate[0];
     $clientId = ClientDao::getClientByLogin(LoginDao::getLoginByUsername(SessionUtil::getUsername()))->getID();
     $filename = $this->saveSampleImage($context, $_FILES['sampleimage'], $clientId);
     if ($filename != "") {
         InsertionOrderDao::createForClientWithImage(ClientDao::getClientByLogin(LoginDao::getLoginByUsername(SessionUtil::getUsername()))->getID(), $mysqlFormattedDate, $_POST['design'], $_POST['color'], $_POST['columns'], $_POST['height'], $_POST['inserts'], $_POST['placements'], $filename);
     }
 }
Beispiel #2
0
 public static function updateClient($client, $name, $email, $phone, $address)
 {
     if ($client instanceof Client) {
         $query = "UPDATE " . Database::addPrefix('clients') . "\n\t\t\t\tSET Name = '" . $name . "', Email = '" . $email . "',\n\t\t\t\tPhone = '" . $phone . "', Address = '" . $address . "'\n\t\t\t \tWHERE ClientID = '" . Database::makeStringSafe($client->getID()) . "' LIMIT 1";
         Database::doQuery($query);
         return ClientDao::getClientByID($client->getID());
     } else {
         $query = "UPDATE " . Database::addPrefix('clients') . "\n\t\t\t\t\t\t\tSET Name = '" . $name . "', Email = '" . $email . "',\n\t\t\t\t\t\t\tPhone = '" . $phone . "', Address = '" . $address . "'\n\t\t\t\t\t\t \tWHERE ClientID = '" . Database::makeStringSafe($client) . "' LIMIT 1";
         Database::doQuery($query);
         return ClientDao::getClientByID($client->getID());
     }
 }
 public function generateClientHTML()
 {
     $adRep = new AdRep(1, "Andrew Melton", "*****@*****.**", "804-267-0327");
     $status = new Status(1, "Design", "Your ad has been aproved and is being designed.");
     $designStatus = new Status(1, "To Be Designed", "A designer is working on your ad.");
     $billingStatus = new Status(1, "Paid", "");
     $orders = InsertionOrderDao::getOrdersByClientID(ClientDao::getClientByLogin(LoginDao::getLoginByUsername(SessionUtil::getUsername()))->getID());
     $ordersHTML = "";
     foreach ($orders as $order) {
         $ordersHTML = $ordersHTML . $order->generateDualRowHTML();
     }
     return "<br />\n\t\t\t\t<div id=\"insertsheader\">\n\t\t\t\t<table id=\"report2\" border=\"0\">\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t\n\t\t\t\t\t\t<th class=\"adrep\">Your Ad Rep</th>\n\t\t\t\t\t\t<th class=\"created\">Created</th>\n\t\t\t\t\t\t<th class=\"updated\">Updated</th>\n\t\t\t\t\t\t<th class=\"issue\">Issue</th>\n\t\t\t\t\t\t<th class=\"status\">Status</th>\n\t\t\t\t\t\t<th class=\"designstatus\">Design-Status</th>\n\t\t\t\t\t\t<th class=\"billingstatus\">Billing</th>\n\t\t\t\t\t\t<!--<th class=\"arrow\"></th>-->\n\t\t\t\t\t\t\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t\t</div>\n\t\t\t\n\t\t\t\t<div id=\"contentdiv\" class=\"scroll\">\n\t\t\t\t\n\t\t\t\t\t<table id=\"report\" border=\"0\">\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . $ordersHTML . "\n\t\t\t\t\t\n\t\t\t\t\t</table>\n\t\t\t\t\n\t\t\t\t</div>";
 }
 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.");
         }
     }
 }
 public function handleForm(Context $context, $action)
 {
     if ($action == "client") {
         if ($_POST['name'] != "" && $_POST['username'] != "" && $_POST['password'] != "" && $_POST['repeatpassword'] != "" && $_POST['email'] != "" && $_POST['phone'] != "" && $_POST['address'] != "") {
             if ($_POST['password'] == $_POST['repeatpassword']) {
                 if (LoginDao::usernameFree($_POST['username'])) {
                     $newLogin = LoginDao::createLogin($_POST['username'], $_POST['password'], Login::CLIENT);
                     $newClient = ClientDao::createClient($newLogin, $_POST['name'], $_POST['email'], $_POST['phone'], $_POST['address']);
                     SessionUtil::login($newLogin);
                     $context->setPageID("home");
                 } else {
                     $context->addError("Username already taken.");
                 }
             } else {
                 $context->addError("Passwords don't match.");
             }
         } else {
             $context->addError("Required field left blank.");
         }
     } else {
         $context->addError("Incorrect Action.");
     }
 }
Beispiel #8
0
<?php

if (!defined("SQLI_HELPER_F")) {
    include "../../utils/sqliHelper.php";
}
if (!defined("API_HELPER_F")) {
    include "../../utils/apiHelper.php";
}
if (!defined("CLIENT_DAO_F")) {
    include "../../DAOs/ClientDao.php";
}
session_start();
if (!empty($_SESSION["user"])) {
    $clients = ClientDao::getAllClients();
} else {
    $clients = null;
}
if ($clients) {
    echo response(0, $clients);
} else {
    echo response(1, array('message' => 'noClients'));
}
Beispiel #9
0
require_once './lib/Util/SessionUtil.php';
require_once './lib/Util/SimpleImage.php';
if (!SessionUtil::start()) {
    echo "Error Starting Session";
}
Database::Open();
if (isset($_GET['insertId'])) {
    $insert = InsertionOrderDao::getByID($_GET['insertId']);
    if (!$insert) {
        $image = new SimpleImage();
        $image->load('./images/notfound.png');
        header('Content-Type: image/jpeg');
        echo $image->output();
        exit;
    }
    $client = ClientDao::getClientByLogin(LoginDao::getLoginByUsername(SessionUtil::getUsername()));
    if ($insert->getClient()->getID() == $client->getID() && file_exists($insert->getImageLoc())) {
        $image = new SimpleImage();
        $image->load($insert->getImageLoc());
        $hratio = 150 / $image->getHeight();
        $wratio = 150 / $image->getWidth();
        $image->scale(min($hratio, $wratio) * 100);
        header('Content-Type: image/jpeg');
        echo $image->output();
    } else {
        $image = new SimpleImage();
        $image->load('./images/notfound.png');
        header('Content-Type: image/jpeg');
        echo $image->output();
        exit;
    }
Beispiel #10
0
<?php

if (!defined("SQLI_HELPER_F")) {
    include "../../utils/sqliHelper.php";
}
if (!defined("API_HELPER_F")) {
    include "../../utils/apiHelper.php";
}
if (!defined("CLIENT_DAO_F")) {
    include "../../DAOs/ClientDao.php";
}
session_start();
if (!empty($_SESSION["user"])) {
    $name = $_GET('name');
    $clients = ClientDao::getClientsByName($name);
} else {
    $clients = null;
}
if ($clients) {
    echo response(0, $clients);
} else {
    echo response(1, array('message' => 'noClients'));
}