コード例 #1
0
ファイル: client.php プロジェクト: neoloc/mscadmin
// are you logged in?
if (!isset($_SESSION['username'])) {
    gohome();
}
// are you in the correct group?
if ($_SESSION['role_id'] < 2) {
    errormsg('Your role does not have access to this resource');
} else {
    if (isset($_POST['client_id']) && get_client_name($_POST['client_id'], $mysqli)) {
        // set the client_id variable from POST
        $client_id = $_POST['client_id'];
        $client_name = get_client_name($client_id, $mysqli);
        // check if the client has attached domains
        if (get_client_domain_count($client_id, $mysqli) && ($domain_tables = get_domains_table($client_id, $mysqli))) {
            echo "\n\t\t\t<!-- Begin Content Division -->\n\t\t\t<div id='content'>\t\t\t\t\t\n\t\t\t\t<legend>Delete Client</legend>\n\t\t\t\t\n\t\t\t\t" . quickalert("warning", $client_name . " is the owner of one or more domains.") . "\n\t\t\t\t\n\t\t\t\t" . quickalert("info", "To delete this client, you can either delete all \n\t\t\t\t\tassociated domains and their transport maps, or \n\t\t\t\t\tchange the owner of any domain to another client. \n\t\t\t\t\t<a class='alert-link' href=" . SITE_URL . "/?do=list&object=domain&id=" . $client_id . "'>View Domain(s)</a>") . "\n\t\t\t\t\n\t\t\t\t" . $domain_tables . "\n\t\t\t\t\n\t\t\t<!-- End Content Division -->\n\t\t\t</div>\n\t\t\t";
        } elseif (get_client_domain_count($client_id, $mysqli)) {
            errormsg("cannot generate domains table");
        } else {
            // no domains, remove client
            if (delete_client($client_id, $mysqli)) {
                echo "\n\t\t\t\t<!-- Begin Content Division -->\n\t\t\t\t<div id='content'>\t\t\t\t\t\n\t\t\t\t\t<legend>Delete Client</legend>\n\t\t\t\t\t\n\t\t\t\t\t" . quickalert("success", "Client '" . $client_name . "' has been removed from the database.") . "\n\t\t\t\t\t\n\t\t\t\t<!-- End Content Division -->\n\t\t\t\t</div>\n\t\t\t\t";
            } else {
                errormsg("Failed to delete record from the database");
            }
        }
    } elseif (!$_POST) {
        if (isset($_GET['id'])) {
            if (get_client_name($_GET['id'], $mysqli)) {
                $selected_client_id = $_GET['id'];
            }
        }
コード例 #2
0
ファイル: client.php プロジェクト: neoloc/mscadmin
 // row count
 $tablerows = 0;
 // get all clients
 $query = "SELECT client_id,client_name FROM clients ORDER BY client_name";
 $stmt = $mysqli->prepare($query);
 $stmt->execute();
 $stmt->store_result();
 if ($stmt->num_rows > 0) {
     $table = new Jacopo\Bootstrap3Table\BootstrapTable();
     $table->setConfig(array("table-hover" => true, "table-condensed" => true, "table-striped" => true));
     $table->setHeader(array("Client Name", "Domains", "Actions"));
     // output data of each row
     $stmt->bind_result($client_id, $client_name);
     while ($stmt->fetch()) {
         // get client domain count
         $domain_count = get_client_domain_count($client_id, $mysqli);
         if ($domain_count <= 1) {
             $tmp_domain = "Domain";
         } else {
             $tmp_domain = "Domains";
         }
         // create table row for each result
         $table_row = array($client_name, "<a href=" . SITE_URL . "/?do=list&object=domain&id=" . $client_id . "><span class='glyphicon glyphicon-th-list' id='logIcon'></span> " . $domain_count . " " . $tmp_domain . "</a>", "<a href=" . SITE_URL . "/?do=delete&object=client&id=" . $client_id . "><span class='glyphicon glyphicon-remove-sign id='logIcon'></span> Delete </a>");
         $table->addRows($table_row);
         $tablerows++;
     }
 } else {
     //no clients!
     echo "\n\t\t<!-- Begin Content Division -->\n\t\t<div id='content'>\n\t\t<h2>Clients</h2>\n\t\t<div class='alert alert-error'><p>There are currently no clients in the database.</p></div>\n\t\t<p><a class='btn success' href=" . SITE_URL . "/?do=create&object=client><span class='glyphicon glyphicon-plus-sign' id='logIcon'></span> Create </a><p>\n\t\t<!-- End Content Division -->\n\t\t</div>\n\t\t";
 }
 // free result set