diff options
author | Camil Staps | 2015-02-05 00:40:47 +0100 |
---|---|---|
committer | Camil Staps | 2015-02-05 00:40:47 +0100 |
commit | c50a323c25a0787ba2051b19721983776a229615 (patch) | |
tree | 87e13060ca6633bed3f5de2e25c5eedf866a0073 /include/clients.php | |
parent | Initial commit (diff) |
Initial commit
Diffstat (limited to 'include/clients.php')
-rw-r--r-- | include/clients.php | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/include/clients.php b/include/clients.php new file mode 100644 index 0000000..7248e0c --- /dev/null +++ b/include/clients.php @@ -0,0 +1,98 @@ +<?php +/** + * BusinessAdmin: administrative software for small companies + * Copyright (C) 2015 Camil Staps (ViviSoft) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +require_once('./index.php'); +require('./header.php'); +?> + +<div id="wrapper"> + + <?php require('./nav.php'); ?> + + <div id="page-wrapper"> + <div class="row"> + <?php + //------------------------------------------------------------------------------ + // Check for GET variables + // + // ?id=<id> View information of the client with id <id> + // ?delete=<id> Delete the client with id <id> + //------------------------------------------------------------------------------ + + // The header of the page + $header = 'Clients'; + // Whether or not to show an individual client in the end (false if not, or the id if yes) + $show_individual = false; + + // View client + if (isset($_GET['id'])) { + $id = (int) $_GET['id']; + try { + $client = new client($_pdo, $id); + $header = "<a href='".constants::url_external."clients'>Clients</a> / {$client->getName()}"; + $show_individual = $id; + } catch (PDOException $e) { + $alert = "<div class='alert alert-danger alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The client with id $id</i> could not be found.</div>"; + } catch (Exception $e) { + $alert = "<div class='alert alert-warning alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The client with id $id</i> could not be found.</div>"; + } + } + + // Show the header + echo "<div class='col-lg-12'><h1 class='page-header'>$header</h1></div>"; + if (isset($alert)) echo "<div class='col-lg-12'>$alert</div>"; + + // Delete client + if (isset($_GET['delete'])) { + echo "<div class='col-lg-12'>"; + $id = (int) $_GET['delete']; + try { + $client = new client($_pdo, $id); + if ($client->delete()) { + echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The client with name <i>{$client->getName()}</i> has been removed.</div>"; + } else { + echo "<div class='alert alert-warning alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The client with name <i>{$client->getName()}</i> could not be removed. Perhaps it's already removed?</div>"; + } + } catch (PDOException $e) { + echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The client could not be removed due to a PDO error.</div>"; + } catch (Exception $e) { + echo "<div class='alert alert-warning alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The client with id {$id} could not be found.</div>"; + } + + echo "</div>"; + } + + if ($show_individual !== false) { + $_id = $show_individual; + require('clients-view.php'); + } else { + require('clients-overview.php'); + } + ?> + </div> + <!-- /.row --> + </div> + <!-- /#page-wrapper --> + +</div> +<!-- /#wrapper --> + +<?php +require('./footer.php'); +?>
\ No newline at end of file |