function get_last_case_activity($dbh, $user)
{
    $q = $dbh->prepare("SELECT * FROM `cm_case_notes`\n\t\tWHERE username = ? ORDER BY `date` desc LIMIT 0,1");
    $q->bindParam(1, $user);
    $q->execute();
    $c = $q->fetch();
    if ($c) {
        $data = extract_date_time($c['date']) . ": " . implode(' ', convert_case_time($c['time'])) . ' on the <a href="index.php?i=Cases.php#cases/' . $c['case_id'] . '" target="_new">' . case_id_to_casename($dbh, $c['case_id']) . "</a> case.";
    } else {
        $data = "None";
    }
    return $data;
}
Example #2
0
         $activities[] = $item;
     }
 }
 //cases that have been closed
 if ($p['close_cases'] == '1' && $p['view_all_cases'] == '1') {
     $get_closed_cases = $dbh->prepare("SELECT * FROM cm\n\t\t\tWHERE time_closed >= '{$mysqldate}'");
     $get_closed_cases->execute();
     $closed = $get_closed_cases->fetchAll(PDO::FETCH_ASSOC);
     foreach ($closed as $close) {
         if ($close['closed_by'] === $username) {
             $by = 'You';
         } else {
             $by = username_to_fullname($dbh, $close['closed_by']);
         }
         $action_text = " closed a case: ";
         $casename = case_id_to_casename($dbh, $close['id']);
         $time_done = $close['time_closed'];
         $time_formatted = extract_date_time($close['time_closed']);
         $id = $close['id'];
         $what = $close['close_notes'];
         $follow_url = CC_BASE_URL . 'index.php?i=Cases.php#cases/' . $close['id'];
         $item = array('by' => $by, 'action_text' => $action_text, 'casename' => $casename, 'id' => $id, 'what' => $what, 'follow_url' => $follow_url, 'time_done' => $time_done, 'time_formatted' => $time_formatted);
         $activities[] = $item;
     }
 }
 //new users who have requested access
 if ($p['activate_users'] == '1') {
     $get_new_users = $dbh->prepare("SELECT * FROM cm_users\n\t\t\t\tWHERE date_created >= '{$mysqldate}' AND new = 'yes'");
     $get_new_users->execute();
     $news = $get_new_users->fetchAll(PDO::FETCH_ASSOC);
     foreach ($news as $new) {
Example #3
0
        <form class="navbar-search pull-left">
            <input type="text" class="case-search search-query" placeholder="Search">
            <select name="case-status" class="inline small-select search-query">
                <option value="open">Open</option>
                <option value="closed">Closed</option>
            </select>
        </form>
    </div>
    <div class="row">
    <?php 
if (empty($raw_results)) {
    echo "<p class='end'>No cases found</p>";
} else {
    echo "<ul class=\"nav nav-pills nav-stacked\">";
    foreach ($raw_results as $r) {
        extract($r);
        if ($date_close !== '') {
            echo "<li class='table-case-item table-case-closed'>";
        } else {
            echo "<li class='table-case-item table-case-open'>";
        }
        echo "<a href='index.php?i=Case.php&id={$id}'>" . case_id_to_casename($dbh, $id) . "<i class=\"pull-right icon-chevron-right\"></i></a></li>";
    }
    echo "</ul>";
}
?>
    </div>
</div>
</body>
</html>
Example #4
0
                    <li><a href="index.php?i=Board.php">Board</a>
                    <?php 
}
?>
                    <li><a href="index.php?i=QuickAdd.php">Quick Add</a>
                    <li><a href="index.php?i=Logout.php">Logout</a>
                </ul>
            </div><!--/.nav-collapse -->
        </div>
    </div>
</div>

<div class="container">
    <div class="row" id="notifications"></div>
    <div class="row"><h3><?php 
echo case_id_to_casename($dbh, $id);
?>
</h3></div>
    <ul class="nav nav-tabs" id="myTab">
        <li><a class="default-tab" data-toggle="tab" href="#caseNotes">Case Notes</a></li>
        <li><a href="#caseData" data-toggle="tab">Case Data</a></li>
        <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a>
            <ul class="dropdown-menu">
                <li><a class="multi-level" href="#caseDocs" data-toggle="tab">Documents</a></li>
                <li><a href="#caseContacts" data-toggle="tab">Contacts</a></li>
                <li><a href="#caseEvents" data-toggle="tab">Events</a></li>
            </ul>
        </li>
    </ul>
    <div class="tab-content">
        break;
    case 'case':
        $cols = array("username", "case_id", "date", "description", "time", "seconds");
        $col_data = array(array('sTitle' => 'Name'), array('sTitle' => 'Case'), array('sTitle' => 'Date'), array('sTitle' => 'Description'), array('sTitle' => 'Time (hours)'), array('sTitle' => 'Seconds', 'bVisible' => false));
        if ($columns_only) {
            $output['aoColumns'] = $col_data;
        } else {
            $case_number = substr($val, 5);
            $q = $dbh->prepare("SELECT * FROM cm_case_notes WHERE `case_id` = :val AND `date` >= :date_start AND `date` <= :date_end ORDER BY `date` ASC");
            $data = array('val' => $case_number, 'date_start' => $date_start, 'date_end' => $date_end);
            $q->execute($data);
            $error = $q->errorInfo();
            while ($result = $q->fetch(PDO::FETCH_ASSOC)) {
                $rows = array();
                $result['username'] = username_to_fullname($dbh, $result['username']);
                $result['case_id'] = case_id_to_casename($dbh, $result['case_id']);
                $result['date'] = extract_date($result['date']);
                $result['seconds'] = $result['time'];
                $result['time'] = convert_to_hours($result['time']);
                foreach ($cols as $col) {
                    $rows[] = $result[$col];
                }
                $output['aaData'][] = $rows;
            }
            if ($q->rowCount() < 1) {
                $output['aaData'] = array();
            }
            $output['aoColumns'] = $col_data;
        }
        break;
}
                 $resps[] = $responsible;
             }
         }
         $resps_flat = flatten_array($resps);
         $add_resp = $dbh->prepare("INSERT INTO cm_events_responsibles (id,event_id,username,time_added) VALUES (NULL, :last_id,:resp,NOW())");
         for ($i = 0; $i < sizeof($resps_flat); $i++) {
             $data = array('last_id' => $event_id, 'resp' => $resps_flat[$i]);
             $add_resp->execute($data);
         }
         //Then notify only the newly-added users of the assignement via email
         $new_assignees = array_diff($resps_flat, $curs_flat);
         if (!empty($new_assignees)) {
             foreach ($new_assignees as $n) {
                 $email = user_email($dbh, $resps_flat[$i]);
                 $subject = "ClinicCases: You have been assigned to an event";
                 $body = "You have been assigned to an event (" . $_POST['task'] . ")in the " . case_id_to_casename($dbh, $case_id) . " case.\n\n" . CC_EMAIL_FOOTER;
                 mail($email, $subject, $body, CC_EMAIL_HEADERS, "-f " . CC_EMAIL_FROM);
                 //TODO test on mail server
             }
         }
     }
     break;
 case 'delete':
     $delete_event = $dbh->prepare("DELETE FROM cm_events WHERE id = :event_id");
     $data = array('event_id' => $event_id);
     $delete_event->execute($data);
     $error = $delete_event->errorInfo();
     //also remove all event assignments
     if (!$error[1]) {
         $delete_assign = $dbh->prepare("DELETE FROM cm_events_responsibles WHERE event_id = :event_id");
         $data = array('event_id' => $event_id);
			<?php 
        if ($ccs) {
            echo "<p class='ccs'>Cc: " . format_name_list($dbh, $ccs) . "</p>";
        }
        ?>

			<p class = "subj">Subject: <?php 
        echo htmlentities($subject);
        ?>
</p>

			<p class = "assoc_case">Filed in: <?php 
        if (!$assoc_case) {
            echo "(Not Filed)";
        } else {
            echo case_id_to_casename($dbh, $assoc_case);
        }
        ?>
</p>

			<div class = "msg_body_text"><?php 
        echo nl2br(htmlentities(text_prepare($body)));
        ?>
</div>

			<div class = "msg_replies">


			</div>

			<div class="msg_actions">
Example #8
0
 $v = new vcalendar(array('unique_id' => CC_DOMAIN));
 // initiate new CALENDAR
 $v->setConfig('$_GET[key]', 'ClinicCases ' . CC_PROGRAM_NAME);
 // config with site domain
 $v->setProperty('X-WR-CALNAME', 'ClinicCases Upcoming Events');
 // set some X-properties
 $v->setProperty('X-WR-CALDESC', 'Your Upcoming Events on ClinicCases. For more information: log on to your account at ' . CC_BASE_URL);
 $v->setProperty('method', 'PUBLISH');
 $v->setProperty('X-WR-TIMEZONE', $time_zone);
 //Get events
 $q = $dbh->prepare("SELECT * FROM `cm_events_responsibles`,`cm_events`\n\t\tWHERE cm_events_responsibles.username = ?\n\t\tAND cm_events_responsibles.event_id = cm_events.id\n\t\tORDER by cm_events.start DESC");
 $q->bindParam(1, $user);
 $q->execute();
 $events = $q->fetchAll(PDO::FETCH_ASSOC);
 foreach ($events as $event) {
     $case_name = case_id_to_casename($dbh, $event['case_id']);
     $e = new vevent();
     // initiate EVENT
     if ($event['all_day'] == '1') {
         $start = explode(' ', $event['start']);
         //all-day events are date only
         $e->setProperty('dtstart', $start[0]);
         if ($event['end'] == null) {
             $e->setProperty('dtend', $start[0]);
             //make end same as event
         } else {
             $end = explode(' ', $event['end']);
             $e->setProperty('dtend', $end[0]);
         }
     } else {
         $e->setProperty('dtstart', $event['start']);
    if ($already_assigned) {
        $update_status = $dbh->prepare("UPDATE cm_case_assignees SET status='active' where case_id = :case_id AND username = :user");
        $update_status->bindParam(':user', $user);
        $update_status->bindParam(':case_id', $case_id);
        $update_status->execute();
    } else {
        //add user to case
        $user_add_query = $dbh->prepare("INSERT INTO  cm_case_assignees (`id` ,`username` ,`case_id` ,`status` ,`date_assigned` ,`date_removed`)VALUES (NULL ,  :user,  :case_id,  'active', CURRENT_TIMESTAMP ,  '0000-00-00 00:00:00');");
        $user_add_query->bindParam(':user', $user);
        $user_add_query->bindParam(':case_id', $case_id);
        $user_add_query->execute();
    }
    //Send email to user
    $email = user_email($dbh, $user);
    $subject = "ClinicCases: You have been assigned to a case";
    $body = "You have been assigned to the " . case_id_to_casename($dbh, $case_id) . " case.\n\n" . CC_EMAIL_FOOTER;
    mail($email, $subject, $body, CC_EMAIL_HEADERS, "-f " . CC_EMAIL_FROM);
    //Send CC message to user
    $q = $dbh->prepare("INSERT INTO `cm_messages` (`id`, `thread_id`, `to`, `from`, `ccs`, `subject`, `body`, `assoc_case`, `time_sent`, `read`, `archive`, `starred`) VALUES (NULL, '', :tos, :sender, '', :subject, :body, :assoc_case, CURRENT_TIMESTAMP, :sender_has_read, '', '');");
    $sender_has_read = $username . ',';
    $data = array('tos' => $user, 'sender' => $username, 'subject' => $subject, 'body' => $body, 'assoc_case' => $case_id, 'sender_has_read' => $sender_has_read);
    $q->execute($data);
    $error = $q->errorInfo();
    if (!$error[1]) {
        //Add thread id to message; if thread_id the same as id,
        //we know message was not a reply.
        $last_id = $dbh->lastInsertId();
        $insert_thread = $dbh->prepare("UPDATE cm_messages SET `thread_id` = '{$last_id}' WHERE `id` = '{$last_id}'");
        $insert_thread->execute();
    }
}
//4.
//use the previously generated contacts
if ($contact_number > 0) {
    $q = $dbh->prepare("SELECT * FROM cm_adverse_parties");
    $q->execute();
    $adverse = $q->fetchAll(PDO::FETCH_ASSOC);
    foreach ($adverse as $ad) {
        $contact_name = $contact['first_name'] . ' ' . $contact['last_name'];
        if (!$contact['type']) {
            $contact_type = "contact";
        } else {
            $contact_type = $contact['type'];
        }
        similar_text($contact_name, $ad['name'], $per);
        if ($per >= 80) {
            $conflicts[] = array('percentage' => $per, 'text' => "A party named <strong> " . $ad['name'] . " </strong> was adverse in the <a href='index.php?i=Cases.php#cases/" . $ad['case_id'] . "' target='_new'>" . case_id_to_casename($dbh, $ad['case_id']) . "</a> case. {$contact_name} is a\n\t\t\t{$contact_type} in this case. (" . round($per, 2) . " % match)");
        }
    }
}
//Return the data
$count = count($conflicts);
if ($type === 'alert') {
    if ($count > 0) {
        $return = array('conflicts' => true, 'number' => $count);
        echo json_encode($return);
    } else {
        $return = array('conflicts' => false);
        echo json_encode($return);
    }
} else {
    if ($count > 0) {