diff options
Diffstat (limited to 'classes/BusinessAdmin.php')
-rw-r--r-- | classes/BusinessAdmin.php | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/classes/BusinessAdmin.php b/classes/BusinessAdmin.php index 347c9c6..3e654a2 100644 --- a/classes/BusinessAdmin.php +++ b/classes/BusinessAdmin.php @@ -44,7 +44,7 @@ class BusinessAdmin { */ 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 = $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) { @@ -70,7 +70,7 @@ class BusinessAdmin { $ids = self::getUserIds($pdo, $where, $variables); $users = []; foreach ($ids as $id) { - $users[$id] = new user($pdo, $id); + $users[$id] = new User($pdo, $id); } return $users; } @@ -88,7 +88,7 @@ class BusinessAdmin { */ public static function getClientIds($pdo) { $ids = array(); - $clients = $pdo->query("SELECT `id` FROM `".constants::db_prefix."client`")->fetchAll(PDO::FETCH_ASSOC); + $clients = $pdo->query("SELECT `id` FROM `".Constants::db_prefix."client`")->fetchAll(PDO::FETCH_ASSOC); foreach ($clients as $client) { $ids[] = $client['id']; } @@ -110,7 +110,7 @@ class BusinessAdmin { $ids = self::getClientIds($pdo); $clients = array(); foreach ($ids as $id) { - $clients[$id] = new client($pdo, $id); + $clients[$id] = new Client($pdo, $id); } return $clients; } @@ -128,7 +128,7 @@ class BusinessAdmin { */ public static function getContactIds($pdo) { $ids = array(); - $contacts = $pdo->query("SELECT `id` FROM `".constants::db_prefix."contact`")->fetchAll(PDO::FETCH_ASSOC); + $contacts = $pdo->query("SELECT `id` FROM `".Constants::db_prefix."contact`")->fetchAll(PDO::FETCH_ASSOC); foreach ($contacts as $contact) { $ids[] = $contact['id']; } @@ -150,7 +150,7 @@ class BusinessAdmin { $ids = self::getContactIds($pdo); $contacts = array(); foreach ($ids as $id) { - $contacts[$id] = new contact($pdo, $id); + $contacts[$id] = new Contact($pdo, $id); } return $contacts; } @@ -169,7 +169,7 @@ class BusinessAdmin { */ 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); + $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']; } @@ -192,7 +192,7 @@ class BusinessAdmin { $ids = self::getOfferIds($pdo, $where); $offers = array(); foreach ($ids as $id) { - $offers[$id] = new offer($pdo, $id); + $offers[$id] = new Offer($pdo, $id); } return $offers; } @@ -211,7 +211,7 @@ class BusinessAdmin { */ 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); + $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']; } @@ -234,7 +234,7 @@ class BusinessAdmin { $ids = self::getAssignmentIds($pdo, $where); $assignments = array(); foreach ($ids as $id) { - $assignments[$id] = new assignment($pdo, $id); + $assignments[$id] = new Assignment($pdo, $id); } return $assignments; } @@ -253,7 +253,7 @@ class BusinessAdmin { */ 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); + $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']; } @@ -276,7 +276,7 @@ class BusinessAdmin { $ids = self::getDiscountIds($pdo, $where); $discounts = array(); foreach ($ids as $id) { - $discounts[$id] = new discount($pdo, $id); + $discounts[$id] = new Discount($pdo, $id); } return $discounts; } @@ -296,10 +296,10 @@ class BusinessAdmin { * @return client|bool A new instance of the client object, or false on failure */ public static function createClient($pdo, $name) { - $stmt = $pdo->prepare("INSERT INTO `".constants::db_prefix."client` (`name`) VALUES (?)"); + $stmt = $pdo->prepare("INSERT INTO `".Constants::db_prefix."client` (`name`) VALUES (?)"); $stmt->execute(array($name)); if ($stmt->rowCount() == 1) { - return new client($pdo, $pdo->lastInsertId()); + return new Client($pdo, $pdo->lastInsertId()); } else { return false; } @@ -318,21 +318,21 @@ class BusinessAdmin { */ public static function createFile($pdo, $filename) { // Check for file existence - if (file_exists(constants::files_folder . $filename)) { + if (file_exists(Constants::files_folder . $filename)) { throw new Exception("$filename already exists."); } // Try to create the file - if (file_put_contents(constants::files_folder . $filename, '') === false) { + if (file_put_contents(Constants::files_folder . $filename, '') === false) { throw new Exception("$filename could not be created. Check the permissions."); } - $stmt = $pdo->prepare("INSERT INTO `".constants::db_prefix."file` (`filename`) VALUES (?)"); + $stmt = $pdo->prepare("INSERT INTO `".Constants::db_prefix."file` (`filename`) VALUES (?)"); $stmt->execute(array($filename)); if ($stmt->rowCount() == 1) { - return new file($pdo, $pdo->lastInsertId()); + return new File($pdo, $pdo->lastInsertId()); } else { - unlink(constants::files_folder . $filename); + unlink(Constants::files_folder . $filename); throw new Exception("$filename could not be added to the database"); } } @@ -349,10 +349,10 @@ class BusinessAdmin { * @return user|bool A new instance of the user object, or false on failure */ public static function createUser($pdo, $username, $password) { - $stmt = $pdo->prepare("INSERT INTO `".constants::db_prefix."user` (`username`, `password`) VALUES (?,?)"); + $stmt = $pdo->prepare("INSERT INTO `".Constants::db_prefix."user` (`username`, `password`) VALUES (?,?)"); $stmt->execute([$username, user::hash($password)]); if ($stmt->rowCount() == 1) { - return new user($pdo, $pdo->lastInsertId()); + return new User($pdo, $pdo->lastInsertId()); } else { return false; } |