diff options
author | Camil Staps | 2016-08-01 13:48:14 +0200 |
---|---|---|
committer | Camil Staps | 2016-08-01 13:53:12 +0200 |
commit | efa2936ec538c236dcec71f419ad714524c7d2b9 (patch) | |
tree | 1d7e1903851fc4c37c72cf8ee8de006979bb8b4e | |
parent | Paypal not on by default in braintree (diff) |
Removed BusinessAdmin::get* methods, added Model::search and
Model::count
-rw-r--r-- | classes/BusinessAdmin.php | 306 | ||||
-rw-r--r-- | classes/File.php | 6 | ||||
-rw-r--r-- | classes/Model.php | 47 | ||||
-rw-r--r-- | include/assignments-overview.php | 4 | ||||
-rw-r--r-- | include/clients-overview.php | 2 | ||||
-rw-r--r-- | include/contacts-overview.php | 4 | ||||
-rw-r--r-- | include/discounts-overview.php | 4 | ||||
-rw-r--r-- | include/file-get.php | 2 | ||||
-rw-r--r-- | include/home.php | 24 | ||||
-rw-r--r-- | include/offers-overview.php | 4 | ||||
-rw-r--r-- | include/offers-view.php | 4 | ||||
-rw-r--r-- | include/settings.php | 2 | ||||
-rw-r--r-- | login.php | 2 | ||||
-rw-r--r-- | nav.php | 2 |
14 files changed, 78 insertions, 335 deletions
diff --git a/classes/BusinessAdmin.php b/classes/BusinessAdmin.php index f6abe14..7acb4ca 100644 --- a/classes/BusinessAdmin.php +++ b/classes/BusinessAdmin.php @@ -25,312 +25,6 @@ * Provides basic functions like adding elements to the database */ class BusinessAdmin { - //------------------------------------------------------------------------------ - // Getters and setters - //------------------------------------------------------------------------------ - - /** - * Get all user ids - * - * @see BusinessAdmin::getUsers() This funtion returns instances of the user class instead of just the ids - * - * @param PDO $pdo The PDO class for database connection - * @param string[] $where An array of WHERE clauses that will be AND-ed into a prepared statement - * @param mixed[] $variables An array of variables that should go into the prepared statement - * - * @throws PDOException Is something went wrong with the database - * - * @return int[] The ids - */ - public static function getUserIds($pdo, $where = [], $variables = []) { - $ids = []; - $users = $pdo->prepare("SELECT `id` FROM `".Constants::db_prefix."user`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : "")); - $users->execute($variables); - $users = $users->fetchAll(PDO::FETCH_ASSOC); - foreach ($users as $user) { - $ids[] = $user['id']; - } - return $ids; - } - - /** - * Get all users - * - * @see BusinessAdmin::getUserIds() This function returns just the ids of the users, and not instances of the user class - * - * @param PDO $pdo The PDO class for database connection - * @param string[] $where An array of WHERE clauses that will be AND-ed into a prepared statement - * @param mixed[] $variables An array of variables that should go into the prepared statement - * - * @throws PDOException If something went wrong with the database - * - * @return user[] An array indexed by id of instances of the user class - */ - public static function getUsers($pdo, $where = [], $variables = []) { - $ids = self::getUserIds($pdo, $where, $variables); - $users = []; - foreach ($ids as $id) { - $users[$id] = new User($pdo, $id); - } - return $users; - } - - /** - * Get all file ids - * - * @see BusinessAdmin::getFiles() This funtion returns instances of the file class instead of just the ids - * - * @param PDO $pdo The PDO class for database connection - * @param string[] $where An array of WHERE clauses that will be AND-ed into a prepared statement - * @param mixed[] $variables An array of variables that should go into the prepared statement - * - * @throws PDOException Is something went wrong with the database - * - * @return int[] The ids - */ - public static function getFileIds($pdo, $where = [], $variables = []) { - $ids = []; - $files = $pdo->prepare("SELECT `id` FROM `".Constants::db_prefix."file`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : "")); - $files->execute($variables); - $files = $files->fetchAll(PDO::FETCH_ASSOC); - foreach ($files as $file) { - $ids[] = $file['id']; - } - return $ids; - } - - /** - * Get all files - * - * @see BusinessAdmin::getFileIds() This function returns just the ids of the files, and not instances of the file class - * - * @param PDO $pdo The PDO class for database connection - * @param string[] $where An array of WHERE clauses that will be AND-ed into a prepared statement - * @param mixed[] $variables An array of variables that should go into the prepared statement - * - * @throws PDOException If something went wrong with the database - * - * @return file[] An array indexed by id of instances of the file class - */ - public static function getFiles($pdo, $where = [], $variables = []) { - $ids = self::getFileIds($pdo, $where, $variables); - $files = []; - foreach ($ids as $id) { - $files[$id] = new File($pdo, $id); - } - return $files; - } - - /** - * Get all client ids - * - * @see BusinessAdmin::getClients() This funtion returns instances of the client class instead of just the ids - * - * @param PDO $pdo The PDO class for database connection - * - * @throws PDOException If something went wrong with the database - * - * @return int[] The ids - */ - public static function getClientIds($pdo) { - $ids = array(); - $clients = $pdo->query("SELECT `id` FROM `".Constants::db_prefix."client`")->fetchAll(PDO::FETCH_ASSOC); - foreach ($clients as $client) { - $ids[] = $client['id']; - } - return $ids; - } - - /** - * Get all clients - * - * @see BusinessAdmin::getClientIds() This function returns just the ids of the clients, and not instances of the client class - * - * @param PDO $pdo The PDO class for database connection - * - * @throws PDOException If something went wrong with the database - * - * @return client[] An array indexed by id of instances of the client class - */ - public static function getClients($pdo) { - $ids = self::getClientIds($pdo); - $clients = array(); - foreach ($ids as $id) { - $clients[$id] = new Client($pdo, $id); - } - return $clients; - } - - /** - * Get all contact ids - * - * @see BusinessAdmin::getContacts() This funtion returns instances of the contact class instead of just the ids - * - * @param PDO $pdo The PDO class for database connection - * - * @throws PDOException Is something went wrong with the database - * - * @return int[] The ids - */ - public static function getContactIds($pdo) { - $ids = array(); - $contacts = $pdo->query("SELECT `id` FROM `".Constants::db_prefix."contact`")->fetchAll(PDO::FETCH_ASSOC); - foreach ($contacts as $contact) { - $ids[] = $contact['id']; - } - return $ids; - } - - /** - * Get all contacts - * - * @see BusinessAdmin::getContactIds() This function returns just the ids of the contacts, and not instances of the contact class - * - * @param PDO $pdo The PDO class for database connection - * - * @throws PDOException If something went wrong with the database - * - * @return contact[] An array indexed by id of instances of the contact class - */ - public static function getContacts($pdo) { - $ids = self::getContactIds($pdo); - $contacts = array(); - foreach ($ids as $id) { - $contacts[$id] = new Contact($pdo, $id); - } - return $contacts; - } - - /** - * Get all offer ids - * - * @see BusinessAdmin::getOffers() This funtion returns instances of the offer class instead of just the ids - * - * @param PDO $pdo The PDO class for database connection - * @param string[] $where An array of WHERE clauses that will be AND-ed - * - * @throws PDOException Is something went wrong with the database - * - * @return int[] The ids - */ - public static function getOfferIds($pdo, $where = array()) { - $ids = array(); - $offers = $pdo->query("SELECT `id` FROM `".Constants::db_prefix."offer`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : ""))->fetchAll(PDO::FETCH_ASSOC); - foreach ($offers as $offer) { - $ids[] = $offer['id']; - } - return $ids; - } - - /** - * Get all offers - * - * @see BusinessAdmin::getOfferIds() This function returns just the ids of the offers, and not instances of the offer class - * - * @param PDO $pdo The PDO class for database connection - * @param string[] $where An array of WHERE clauses that will be AND-ed - * - * @throws PDOException If something went wrong with the database - * - * @return offer[] An array indexed by id of instances of the offer class - */ - public static function getOffers($pdo, $where = array()) { - $ids = self::getOfferIds($pdo, $where); - $offers = array(); - foreach ($ids as $id) { - $offers[$id] = new Offer($pdo, $id); - } - return $offers; - } - - /** - * Get all assignment ids - * - * @see BusinessAdmin::getAssignments() This funtion returns instances of the assignment class instead of just the ids - * - * @param PDO $pdo The PDO class for database connection - * @param string[] $where An array of WHERE clauses that will be AND-ed - * - * @throws PDOException Is something went wrong with the database - * - * @return int[] The ids - */ - public static function getAssignmentIds($pdo, $where = array()) { - $ids = array(); - $assignments = $pdo->query("SELECT `id` FROM `".Constants::db_prefix."assignment`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : ""))->fetchAll(PDO::FETCH_ASSOC); - foreach ($assignments as $assignment) { - $ids[] = $assignment['id']; - } - return $ids; - } - - /** - * Get all assignments - * - * @see BusinessAdmin::getAssignmentIds() This function returns just the ids of the assignments, and not instances of the assignment class - * - * @param PDO $pdo The PDO class for database connection - * @param string[] $where An array of WHERE clauses that will be AND-ed - * - * @throws PDOException If something went wrong with the database - * - * @return assignment[] An array indexed by id of instances of the assignment class - */ - public static function getAssignments($pdo, $where = array()) { - $ids = self::getAssignmentIds($pdo, $where); - $assignments = array(); - foreach ($ids as $id) { - $assignments[$id] = new Assignment($pdo, $id); - } - return $assignments; - } - - /** - * Get all discount ids - * - * @see BusinessAdmin::getDiscounts() This funtion returns instances of the discount class instead of just the ids - * - * @param PDO $pdo The PDO class for database connection - * @param string[] $where An array of WHERE clauses that will be AND-ed - * - * @throws PDOException Is something went wrong with the database - * - * @return int[] The ids - */ - public static function getDiscountIds($pdo, $where = array()) { - $ids = array(); - $discounts = $pdo->query("SELECT `id` FROM `".Constants::db_prefix."discount`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : ""))->fetchAll(PDO::FETCH_ASSOC); - foreach ($discounts as $discount) { - $ids[] = $discount['id']; - } - return $ids; - } - - /** - * Get all discounts - * - * @see BusinessAdmin::getDiscountIds() This function returns just the ids of the discounts, and not instances of the discount class - * - * @param PDO $pdo The PDO class for database connection - * @param string[] $where An array of WHERE clauses that will be AND-ed - * - * @throws PDOException If something went wrong with the database - * - * @return discount[] An array indexed by id of instances of the discount class - */ - public static function getDiscounts($pdo, $where = array()) { - $ids = self::getDiscountIds($pdo, $where); - $discounts = array(); - foreach ($ids as $id) { - $discounts[$id] = new Discount($pdo, $id); - } - return $discounts; - } - - //------------------------------------------------------------------------------ - // Other functions - //------------------------------------------------------------------------------ - /** * Format a date nicely * diff --git a/classes/File.php b/classes/File.php index ad44448..68d6791 100644 --- a/classes/File.php +++ b/classes/File.php @@ -30,7 +30,11 @@ class File extends Model { $table = 'file', $fillable_columns = ['filename', 'secret_key']; - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * @param PDO $pdo {@inheritDoc} + * @param mixed[] $values {@inheritDoc} + */ public static function create($pdo, $values) { $filename = $values[0]; diff --git a/classes/Model.php b/classes/Model.php index b4f258d..4417074 100644 --- a/classes/Model.php +++ b/classes/Model.php @@ -135,9 +135,10 @@ abstract class Model { * @return self The new item */ public static function create($pdo, $values) { + $class = get_called_class(); + $columns = array_combine(static::$fillable_columns, $values); $questions = []; - $class = get_called_class(); foreach ($columns as $column => $value) { $columns[$column] = $class::mutator($column, $value); @@ -154,6 +155,50 @@ abstract class Model { } /** + * Search for rows + * + * @param PDO $pdo Database connection + * @param string[] $where Where clauses, to be ANDed + * @param mixed[] $values Variables to bind to the where clauses + * + * @throws PDOException Database error + * + * @return self[] Array of rows + */ + public static function search($pdo, $where = [], $values = []) { + $class = get_called_class(); + + $stmt = $pdo->prepare("SELECT `id` FROM `".static::table()."`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : "")); + $stmt->execute($values); + + $items = []; + foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { + $items[] = new $class($pdo, $row['id']); + } + return $items; + } + + /** + * Number of matching rows + * + * @param PDO $pdo Database connection + * @param string[] $where Where clauses, to be ANDed + * @param mixed[] $values Variables to bind to the where clauses + * + * @throws PDOException Database error + * + * @return int The number of matching rows + */ + public static function count($pdo, $where = [], $values = []) { + $class = get_called_class(); + + $stmt = $pdo->prepare("SELECT COUNT(*) FROM `".static::table()."`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : "")); + $stmt->execute($values); + + return $stmt->fetchColumn(); + } + + /** * Post-__get() hook to modify the value * * @param string $key The column diff --git a/include/assignments-overview.php b/include/assignments-overview.php index 2c2c115..c8b0de1 100644 --- a/include/assignments-overview.php +++ b/include/assignments-overview.php @@ -37,7 +37,7 @@ require_once(__DIR__ . '/../login.php'); </thead> <tbody> <?php - $assignments = BusinessAdmin::getAssignments($_pdo); + $assignments = Assignment::search($_pdo); foreach ($assignments as $assignment) { echo "<tr class='mix' data-mixer-order-id='{$assignment->id}' @@ -85,7 +85,7 @@ require_once(__DIR__ . '/../login.php'); <label>Offer:</label> <select name="offerId" class="form-control"> <?php - foreach (BusinessAdmin::getOffers($_pdo) as $offer) { + foreach (Offer::search($_pdo) as $offer) { echo "<option value='{$offer->id}'>#{$offer->id} to {$offer->getContact()->name} ({$offer->getContact()->getClient()->name})</option>"; } ?> diff --git a/include/clients-overview.php b/include/clients-overview.php index ce23058..e0160a7 100644 --- a/include/clients-overview.php +++ b/include/clients-overview.php @@ -34,7 +34,7 @@ require_once(__DIR__ . '/../login.php'); </thead> <tbody> <?php - $clients = BusinessAdmin::getClients($_pdo); + $clients = Client::search($_pdo); foreach ($clients as $client) { echo "<tr class='mix' data-mixer-order-id='{$client->id}' diff --git a/include/contacts-overview.php b/include/contacts-overview.php index 73cd5cd..2376f5a 100644 --- a/include/contacts-overview.php +++ b/include/contacts-overview.php @@ -36,7 +36,7 @@ require_once(__DIR__ . '/../login.php'); </thead> <tbody> <?php - $contacts = BusinessAdmin::getContacts($_pdo); + $contacts = Contact::search($_pdo); foreach ($contacts as $contact) { echo "<tr class='mix' data-mixer-order-id='{$contact->id}' @@ -84,7 +84,7 @@ require_once(__DIR__ . '/../login.php'); <label>Client:</label> <select name="clientId" class="form-control"> <?php - foreach (BusinessAdmin::getClients($_pdo) as $client) { + foreach (Client::search($_pdo) as $client) { echo "<option value='{$client->id}'>{$client->name}</option>"; } ?> diff --git a/include/discounts-overview.php b/include/discounts-overview.php index c6c3421..93b24d4 100644 --- a/include/discounts-overview.php +++ b/include/discounts-overview.php @@ -36,7 +36,7 @@ require_once(__DIR__ . '/../login.php'); </thead> <tbody> <?php - $discounts = BusinessAdmin::getDiscounts($_pdo); + $discounts = Discount::search($_pdo); foreach ($discounts as $discount) { echo "<tr class='mix' data-mixer-order-id='{$discount->id}' @@ -82,7 +82,7 @@ require_once(__DIR__ . '/../login.php'); <label>Offer:</label> <select name="offerId" class="form-control"> <?php - foreach (BusinessAdmin::getOffers($_pdo) as $offer) { + foreach (Offer::search($_pdo) as $offer) { echo "<option value='{$offer->id}'>#{$offer->id} to {$offer->getContact()->name} ({$offer->getContact()->getClient()->name})</option>"; } ?> diff --git a/include/file-get.php b/include/file-get.php index c04b378..2aa5de4 100644 --- a/include/file-get.php +++ b/include/file-get.php @@ -31,7 +31,7 @@ $filepath = Constants::files_folder . $filename; $key = $_REQUEST['key']; -$files = BusinessAdmin::getFiles($_pdo, ['`filename`=?'], [$filename]); +$files = File::search($_pdo, ['`filename`=?'], [$filename]); if (count($files) == 0 || !file_exists($filepath) || is_dir($filepath)) { http_response_code(404); header('Content-type: text/plain'); diff --git a/include/home.php b/include/home.php index 2b64290..b42ec8e 100644 --- a/include/home.php +++ b/include/home.php @@ -37,7 +37,7 @@ require('./header.php'); <div class="row"> <div class="col-lg-3 col-md-3 col-sm-6"> <?php - $count = count(BusinessAdmin::getOfferIds($_pdo, array("`accepted` = 0"))); + $count = Offer::count($_pdo, ["`accepted` = 0"]); ?> <div class="panel panel-<?=($count==0 ? 'primary' : 'yellow')?>"> <div class="panel-heading"> @@ -62,7 +62,7 @@ require('./header.php'); </div> <div class="col-lg-3 col-md-3 col-sm-6"> <?php - $count = count(BusinessAdmin::getOfferIds($_pdo, array("`accepted`=1", "`start_date` <= CURDATE()", "`end_date` >= CURDATE()"))); + $count = Offer::count($_pdo, ["`accepted`=1", "`start_date` <= CURDATE()", "`end_date` >= CURDATE()"]); ?> <div class="panel panel-<?=($count==0 ? 'primary' : ($count < 3) ? 'green' : ($count < 5 ? 'yellow' : 'red'))?>"> <div class="panel-heading"> @@ -87,7 +87,7 @@ require('./header.php'); </div> <div class="col-lg-3 col-md-3 col-sm-6"> <?php - $count = count(BusinessAdmin::getOfferIds($_pdo, array("`accepted`=1", "`end_date` <= CURDATE()", "`invoice_date` IS NULL OR `invoice_date`='1970-01-01' OR `invoice_date`>CURDATE()"))); + $count = Offer::count($_pdo, ["`accepted`=1", "`end_date` <= CURDATE()", "`invoice_date` IS NULL OR `invoice_date`='1970-01-01' OR `invoice_date`>CURDATE()"]); ?> <div class="panel panel-<?=($count==0 ? 'primary' : ($count < 3) ? 'green' : ($count < 5 ? 'yellow' : 'red'))?>"> <div class="panel-heading"> @@ -112,11 +112,11 @@ require('./header.php'); </div> <div class="col-lg-3 col-md-3 col-sm-6"> <?php - $count = count(BusinessAdmin::getOffers($_pdo, [ + $count = Offer::count($_pdo, [ "`invoice_date` > '1970-01-01'", "`invoice_date`<=CURDATE()", - "NOT EXISTS (SELECT * FROM `".Constants::db_prefix."payment` WHERE `offerId`=`".Constants::db_prefix."offer`.`id`)"])); - foreach (BusinessAdmin::getOffers($_pdo, ['EXISTS (SELECT * FROM `'.Constants::db_prefix.'payment` WHERE `offerId`=`'.Constants::db_prefix.'offer`.`id` AND `braintree_id` IS NOT NULL)']) as $offer) { + "NOT EXISTS (SELECT * FROM `".Constants::db_prefix."payment` WHERE `offerId`=`".Constants::db_prefix."offer`.`id`)"]); + foreach (Offer::search($_pdo, ['EXISTS (SELECT * FROM `'.Constants::db_prefix.'payment` WHERE `offerId`=`'.Constants::db_prefix.'offer`.`id` AND `braintree_id` IS NOT NULL)']) as $offer) { if (!$offer->getPayment()->isBraintreeFinished()) { $count++; } @@ -154,7 +154,7 @@ require('./header.php'); <!-- /.panel-heading --> <div class="panel-body"> <?php - $offers = BusinessAdmin::getOffers($_pdo, array("`accepted`=1", "`start_date` <= CURDATE()", "`end_date` >= CURDATE()")); + $offers = Offer::search($_pdo, ["`accepted`=1", "`start_date` <= CURDATE()", "`end_date` >= CURDATE()"]); $list = array(); foreach ($offers as $offer) { $start = BusinessAdmin::formatDate($offer->start_date, false); @@ -209,7 +209,7 @@ require('./header.php'); </thead> <tbody> <?php - $offers = BusinessAdmin::getOffers($_pdo, array("`accepted`=1", "`end_date` <= CURDATE()", "`invoice_date` IS NULL OR `invoice_date`='1970-01-01' OR `invoice_date`>CURDATE()")); + $offers = Offer::search($_pdo, ["`accepted`=1", "`end_date` <= CURDATE()", "`invoice_date` IS NULL OR `invoice_date`='1970-01-01' OR `invoice_date`>CURDATE()"]); foreach ($offers as $offer) { echo "<tr> <td><a href='offers?id={$offer->id}'>{$offer->id}</a></td> @@ -245,11 +245,11 @@ require('./header.php'); </thead> <tbody> <?php - $offers = BusinessAdmin::getOffers($_pdo, array( + $offers = Offer::search($_pdo, [ "`invoice_date` > '1970-01-01'", "`invoice_date`<=CURDATE()", - "NOT EXISTS (SELECT * FROM `".Constants::db_prefix."payment` WHERE `offerId`=`".Constants::db_prefix."offer`.`id`)")); - $open_offers = BusinessAdmin::getOffers($_pdo, + "NOT EXISTS (SELECT * FROM `".Constants::db_prefix."payment` WHERE `offerId`=`".Constants::db_prefix."offer`.`id`)"]); + $open_offers = Offer::search($_pdo, ['EXISTS (SELECT * FROM `'.Constants::db_prefix.'payment` WHERE `offerId`=`'.Constants::db_prefix.'offer`.`id` AND `braintree_id` IS NOT NULL)']); $count = count($offers); foreach ($open_offers as $offer) { @@ -300,7 +300,7 @@ require('./header.php'); <div class="panel-body"> <ul class="timeline"> <?php - $offers = BusinessAdmin::getOffers($_pdo, array('`accepted`=1')); + $offers = Offer::search($_pdo, ['`accepted`=1']); $list = array(); $sort_list = array(); foreach ($offers as $offer) { diff --git a/include/offers-overview.php b/include/offers-overview.php index 090a036..09b8cfd 100644 --- a/include/offers-overview.php +++ b/include/offers-overview.php @@ -37,7 +37,7 @@ require_once(__DIR__ . '/../login.php'); </thead> <tbody> <?php - $offers = BusinessAdmin::getOffers($_pdo); + $offers = Offer::search($_pdo); foreach ($offers as $offer) { $invoiceFile = $offer->getInvoiceFile(); @@ -122,7 +122,7 @@ require_once(__DIR__ . '/../login.php'); <label>Contact:</label> <select name="contactId" class="form-control"> <?php - foreach (BusinessAdmin::getContacts($_pdo) as $contact) { + foreach (Contact::search($_pdo) as $contact) { echo "<option value='{$contact->id}'>{$contact->name} ({$contact->getClient()->name})</option>"; } ?> diff --git a/include/offers-view.php b/include/offers-view.php index 56359ae..cce5a66 100644 --- a/include/offers-view.php +++ b/include/offers-view.php @@ -37,7 +37,7 @@ $_offer = new Offer($_pdo, $_id); </thead> <tbody> <?php - $assignments = BusinessAdmin::getAssignments($_pdo, array("offerId = {$_offer->id}")); + $assignments = $_offer->getAssignments(); foreach ($assignments as $assignment) { echo "<tr> <td class='col-min-width'>{$assignment->id}</td> @@ -80,7 +80,7 @@ $_offer = new Offer($_pdo, $_id); </thead> <tbody> <?php - $discounts = BusinessAdmin::getDiscounts($_pdo, array("offerId = {$_offer->id}")); + $discounts = $_offer->getDiscounts(); foreach ($discounts as $discount) { echo "<tr> <td class='col-min-width'>{$discount->id}</td> diff --git a/include/settings.php b/include/settings.php index 865229d..7f4c4e8 100644 --- a/include/settings.php +++ b/include/settings.php @@ -103,7 +103,7 @@ require('./header.php'); </thead> <tbody> <?php - $users = BusinessAdmin::getUsers($_pdo); + $users = User::search($_pdo); foreach ($users as $user) { echo "<tr class='mix' data-mixer-order-id='{$user->id}' @@ -37,7 +37,7 @@ if (isset($_GET['logout'])) { if (!isset($_SESSION['login']) || $_SESSION['login'] === false) { if (isset($_POST['username'])) { - $users = BusinessAdmin::getUsers($_pdo, ['`username`=?'], [$_POST['username']]); + $users = User::search($_pdo, ['`username`=?'], [$_POST['username']]); if (count($users) == 0) { $_msg = "No user {$_POST['username']} found.<br/>"; } else { @@ -45,7 +45,7 @@ </a> <ul class="dropdown-menu dropdown-tasks"> <?php - $offers = BusinessAdmin::getOffers($_pdo, array("`accepted`=1", "`start_date` <= CURDATE()", "`end_date` >= CURDATE()")); + $offers = Offer::search($_pdo, ["`accepted`=1", "`start_date` <= CURDATE()", "`end_date` >= CURDATE()"]); $list = array(); foreach ($offers as $offer) { $start = BusinessAdmin::formatDate($offer->start_date, false); |