function send_reports()
 {
     $company = Companies::findById(1);
     $lTime = time() + 60 * 60 * $company->getTimezone();
     $dayOfWeek = date("l", $lTime);
     $footer = '<a href="' . externalUrl(ROOT_URL) . '">' . externalUrl(ROOT_URL) . "</a>";
     $people = Reminders::findAll(array('conditions' => 'reports_enabled = 1 and report_day = "' . $dayOfWeek . '"'));
     if (is_array($people) && count($people)) {
         foreach ($people as $person) {
             tpl_assign('settings', $person);
             $user = Users::findById($person->getUserId());
             tpl_assign('user', $user);
             $offset = 60 * 60 * $user->getTimezone();
             tpl_assign('offset', $offset);
             $allProjects = $user->getProjects();
             $emailBody = '';
             $recipient = Notifier::prepareEmailAddress($user->getEmail(), $user->getDisplayName());
             foreach ($allProjects as $project) {
                 if ($project->isActive() || $project->getCompletedOn()->getLeftInDays() > -7) {
                     tpl_assign('project', $project);
                     $condition = 'project_id = ' . $project->getId();
                     $condition .= " and is_private = 0 and is_silent = 0";
                     if (!$person->getReportsIncludeEveryone()) {
                         $condition .= ' and taken_by_id = ' . $user->getId();
                     }
                     $logs = array();
                     if ($person->getReportsIncludeActivity()) {
                         $condition .= " and created_on > Interval -7 day + now()";
                         $logs = ApplicationLogs::findAll(array('conditions' => $condition));
                     }
                     tpl_assign('logs', $logs);
                     $taskLists = $project->getAllTaskLists();
                     $emailTaskLists = array();
                     if (is_array($taskLists) && count($taskLists)) {
                         foreach ($taskLists as $taskList) {
                             $condition = 'task_list_id = ' . $taskList->getId();
                             if (!$person->getReportsIncludeEveryone()) {
                                 $condition .= " and assigned_to_user_id = " . $user->getId();
                             }
                             $condition .= " and completed_on > Interval -7 day + now()";
                             $tasks = ProjectTasks::findAll(array('conditions' => $condition));
                             if (is_array($tasks) && count($tasks)) {
                                 $emailTaskLists[] = $taskList;
                             }
                         }
                     }
                     if (count($emailTaskLists) || count($logs)) {
                         tpl_assign('taskLists', $emailTaskLists);
                         $emailBody .= tpl_fetch(get_template_path('report_per_project', 'reminders'));
                         if ($person->getReportsSummarizedBy()) {
                             try {
                                 Notifier::sendEmail($recipient, $recipient, "[ProjectPier] - Project Report - " . $project->getObjectName(), $emailBody . $footer, 'text/html');
                                 // send
                                 $emailBody = '';
                             } catch (Exception $e) {
                                 echo $e;
                             }
                         }
                     }
                 }
             }
             if (strlen($emailBody) && !$person->getReportsSummarizedBy()) {
                 $time = time() + 60 * 60 * $user->getTimezone();
                 try {
                     Notifier::sendEmail($recipient, $recipient, "[ProjectPier] - Activity Report - " . gmdate('Y/m/d', $time), $emailBody . $footer, 'text/html');
                     // send
                     $emailBody = '';
                 } catch (Exception $e) {
                     echo $e;
                 }
             }
         }
     }
 }