function calendar_get_events_agenda($start, $end, $pn = array(), $id_user = "", $show_projects = 1, $show_tasks = 1, $show_events = 1, $show_wo = 1, $show_clients = 1)
{
    global $config;
    $cal_events = array();
    $day_in_seconds = 24 * 3600;
    //Calculate mysql dates
    $mysql_start = date('Y-m-d', $start);
    $mysql_end = date('Y-m-d', $end);
    //Get project information
    if ($show_projects) {
        $agenda_project = calendar_get_project_date_range($mysql_start, $mysql_end);
        foreach ($agenda_project as $agenda_pitem) {
            list($pname, $idp, $pend, $owner, $pstart) = explode("|", $agenda_pitem);
            $url = "index.php?sec=projects&sec2=operation/projects/project_detail&id_project=" . $idp;
            array_push($cal_events, array("name" => $pname, "start" => strtotime($pstart), "end" => strtotime($pend), "bgColor" => "#E46554", "allDay" => true, "url" => $url));
        }
    }
    //Get tasks information
    if ($show_tasks) {
        $agenda_task = calendar_get_task_date_range($mysql_start, $mysql_end);
        foreach ($agenda_task as $agenda_titem) {
            list($tname, $idt, $tend, $pname, $idp, $tstart) = explode("|", $agenda_titem);
            $url = "index.php?sec=projects&sec2=operation/projects/task_detail&id_task=" . $idt . "&operation=view";
            array_push($cal_events, array("name" => $tname, "start" => strtotime($tstart), "end" => strtotime($tend), "bgColor" => "#80D580", "allDay" => true, "url" => $url));
        }
    }
    if ($show_wo) {
        $agenda_wo = calendar_get_wo_date_range($mysql_start, $mysql_end, $config["id_user"]);
        foreach ($agenda_wo as $agenda_woitem) {
            list($idwo, $woname, $woowner, $wocreator, $wopriority, $woend, $wostart) = explode("|", $agenda_woitem);
            $url = "index.php?sec=projects&sec2=operation/workorders/wo&operation=view&id=" . $idwo;
            $wopriority_img = print_priority_flag_image($wopriority, true);
            array_push($cal_events, array("name" => $woname, "start" => strtotime($wostart), "end" => strtotime($woend), "bgColor" => "#6A6D6D", "allDay" => true, "url" => $url));
        }
    }
    if ($show_events) {
        for ($i = $start; $i <= $end; $i = $i + $day_in_seconds) {
            $mysql_date = date('Y-m-d', $i);
            // Search for agenda item for this date
            $sqlquery = "SELECT * FROM tagenda WHERE timestamp LIKE '{$mysql_date}%' ORDER BY timestamp ASC";
            $res = mysql_query($sqlquery);
            while ($row = mysql_fetch_array($res)) {
                $event_public = $row["public"];
                $event_user = $row["id_user"];
                if (agenda_get_entry_permission($id_user, $row["id"])) {
                    $dur_sec = $row["duration"] * 3600;
                    //Duration in seconds
                    $start_timestamp = strtotime($row["timestamp"]);
                    $start_timestamp = $start_timestamp + $dur_sec;
                    $end_date = $start_timestamp;
                    $url_date = date("Y-m-d", $start_timestamp);
                    $url = "javascript: show_agenda_entry(" . $row["id"] . ", '" . $url_date . "', '0', true)";
                    array_push($cal_events, array("name" => $row["title"], "start" => strtotime($row["timestamp"]), "end" => $end_date, "bgColor" => "#8EC8DF", "allDay" => false, "url" => $url));
                }
            }
        }
    }
    if ($show_clients and !$show_events) {
        for ($i = $start; $i <= $end; $i = $i + $day_in_seconds) {
            $mysql_date = date('Y-m-d', $i);
            // Search for agenda item for this date
            $sqlquery = "SELECT tagenda.* FROM tagenda, tinvoice WHERE tagenda.title like CONCAT('%',(tinvoice.bill_id),'%') and tagenda.timestamp LIKE '{$mysql_date}%' ORDER BY tagenda.timestamp ASC";
            $res = mysql_query($sqlquery);
            while ($row = mysql_fetch_array($res)) {
                $event_public = $row["public"];
                $event_user = $row["id_user"];
                if (agenda_get_entry_permission($id_user, $row["id"])) {
                    $dur_sec = $row["duration"] * 3600;
                    //Duration in seconds
                    $start_timestamp = strtotime($row["timestamp"]);
                    $start_timestamp = $start_timestamp + $dur_sec;
                    $end_date = $start_timestamp;
                    $url_date = date("Y-m-d", $start_timestamp);
                    $url = "javascript: show_agenda_entry(" . $row["id"] . ", '" . $url_date . "', '0', true)";
                    array_push($cal_events, array("name" => $row["title"], "start" => strtotime($row["timestamp"]), "end" => $end_date, "bgColor" => "#8EC8DF", "allDay" => false, "url" => $url));
                }
            }
        }
    }
    return $cal_events;
}
Beispiel #2
0
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
global $config;
require_once 'include/functions_db.php';
require_once 'include/functions_agenda.php';
if (!give_acl($config['id_user'], 0, "AR")) {
    // Doesn't have access to this page
    audit_db($config['id_user'], $config["REMOTE_ADDR"], "ACL Violation", "Trying to access agenda");
    include "general/noaccess.php";
    exit;
}
$show_agenda_entry = (bool) get_parameter('show_agenda_entry');
$update_agenda_entry = (bool) get_parameter('update_agenda_entry');
$delete_agenda_entry = (bool) get_parameter('delete_agenda_entry');
$id = (int) get_parameter('id');
$permission = agenda_get_entry_permission($config['id_user'], $id);
if ($show_agenda_entry) {
    $date = (string) get_parameter('date');
    $entry = array();
    if (!empty($id)) {
        $entry = get_db_row('tagenda', 'id', $id);
        if (!$entry) {
            $entry = array();
        } else {
            // Get the entry privacy
            $groups = get_db_all_rows_filter('tagenda_groups', array('agenda_id' => $id), 'group_id');
            if (empty($groups)) {
                $groups = array();
            }
            // Extract the groups from the result
            $groups = array_map(function ($item) {