Ejemplo n.º 1
0
<?php

require_once '../lib/flip.php';
session_start();
check_valid_user();
display_html_header();
display_document_header();
display_menu();
echo '<table width="90%"' . ">\n";
if (!isset($_GET['project_id'])) {
    echo '<tr><td colspan="2" align="center" class="naglowek">Wybierz projekt<hr></td></tr>' . "\n";
    $active_projects = get_active_projects();
    echo '<tr><td width="50%">';
    show_select_project_form($active_projects, 'Projekty aktywne');
    echo '</td><td width=50%">';
    $inactive_projects = array_diff(get_projects(), $active_projects);
    show_select_project_form($inactive_projects, 'Projekty nieaktywne');
    echo '</td></tr></table>' . "\n";
    display_document_footer();
    exit;
}
$show_orgs = isset($_GET['show_orgs']) ? $_GET['show_orgs'] : 0;
$show_contacts = isset($_GET['show_contacts']) ? $_GET['show_contacts'] : 0;
echo '<tr><td align="center" class="naglowek">Dane projektu <i>' . htmlspecialchars(get_project_name($_GET['project_id'])) . '</i>';
if (is_admin()) {
    echo '&nbsp;&nbsp;&nbsp;[<a href="../admin/edit_project_form.php?project_id=' . $_GET['project_id'] . '" class="menu">Edytuj</a>]';
}
echo "<hr></td></tr>\n";
?>
<tr><td align="center">
	<table border="1" cellpadding="4" cellspacing="0" bgcolor="#eeeeee">
Ejemplo n.º 2
0
function add_org_to_project_form($existing_projects)
{
    echo "\n<br><br><br><br>";
    echo '<table width="100%">' . "\n";
    echo '<tr><td align="center" class="naglowek">Administrator<hr width="90%"></td></tr>' . "\n";
    echo '<form action="../admin/add_org_to_project.php" method="post">' . "\n";
    echo '<input type="hidden" name="organisation_id" value="' . $_GET['org_id'] . '">';
    echo '<tr><td><table><tr><td>Dodaj organizacjê do projektu:</td><td><select name="project_id">';
    $projects = array_flip(get_active_projects());
    $projects = array_diff($projects, $existing_projects);
    $projects = array_flip($projects);
    foreach ($projects as $project_id => $name) {
        echo '<option value="' . $project_id . '">' . htmlspecialchars($name) . '</option>' . "\n";
    }
    echo '</select></td>';
    echo '<td><input type="submit" value="Dodaj"></form></td></tr></table>';
    echo '</td></tr></table>' . "\n";
}
Ejemplo n.º 3
0
function get_planned_contacts($user_id)
{
    $active_projects = array_keys(get_active_projects());
    $q = 'select max(date) as M, organisation_id from contacts where user_id=' . $user_id . ' and project_id in (' . join(', ', $active_projects) . ') group by organisation_id order by M';
    db_connect();
    $r = mysql_query($q);
    if ($r === false) {
        return false;
    } else {
        if (mysql_num_rows($r) === 0) {
            return array();
        }
    }
    $last_contact_dates = array();
    while ($row = mysql_fetch_array($r, MYSQL_ASSOC)) {
        $last_contact_dates[$row['organisation_id']] = $row['M'];
    }
    $last_contacts = array();
    foreach ($last_contact_dates as $org_id => $date) {
        $q = 'select contact_id from contacts where user_id=' . $user_id . ' and organisation_id=' . $org_id . " and date='{$date}' and next_contact_date is not null order by contact_id desc limit 1";
        $r = mysql_query($q);
        if ($r === false) {
            return false;
        }
        $row = mysql_fetch_array($r, MYSQL_ASSOC);
        if (!empty($row)) {
            $last_contacts[$org_id] = $row['contact_id'];
        }
    }
    if (empty($last_contacts)) {
        return array();
    }
    $q = 'select contact_id from contacts where contact_id in (' . join(', ', $last_contacts) . ') order by next_contact_date, contact_id desc';
    $r = mysql_query($q);
    if ($r === false) {
        return false;
    }
    $sorted_contacts = array();
    while ($row = mysql_fetch_array($r)) {
        $sorted_contacts[] = $row['contact_id'];
    }
    return $sorted_contacts;
}