*/
include_once 'config.php';
$message_sent = 0;
$text = "";
$proj_discuss = new ProjectDiscuss();
$proj_time = new ProjectDiscuss();
//select all the  user from project discuss table for the day
$proj_discuss->query('select DISTINCT(pd.iduser) as iduser , usr.email from project_discuss pd inner join user usr on usr.iduser=pd.iduser WHERE DATEDIFF(NOW(), date_added) <= 7;');
//check if any of the user enterd worklog for the day
if ($proj_discuss->getNumRows() > 0) {
    while ($proj_discuss->fetch()) {
        $iduser = $proj_discuss->getdata('iduser');
        $email = $proj_discuss->getdata('email');
        $proj_time->query('SELECT project_discuss.discuss,project_discuss.date_added,document,
          project_discuss.iduser,sum( project_discuss.hours_work ) AS total_hrs,
          project_task.idproject, project_task.idtask FROM project_task
          left JOIN project_discuss ON project_discuss.idproject_task = project_task.idproject_task
          where DATE(project_discuss.date_added) = CURDATE() AND project_discuss.iduser = '******' ' . 'group by project_discuss.iduser');
        if ($proj_time->getNumRows() == 0) {
            //$user_id = $proj_time->getData('iduser');
            $us_obj = new User();
            $user_name = $us_obj->getFullName($iduser);
            $text .= '<h2>Dear ' . $user_name . ',</h2>';
            $text .= '<h2><u>Your Notes For ' . date('jS F Y') . '</u></h2>';
            //$text .= '<h3><b>'.$user_name.'</b>'.'</h3>';
            $text .= "<h3>Total Hours Entered : 0:00</h3>";
        } else {
            $user_id = $proj_time->getData('iduser');
            $us_obj = new User();
            $user_name = $us_obj->getFullName($user_id);
            //$text .= '<h2><u><b>'.$user_name.'</b>'.'&nbsp;&nbsp; Worklog </u></h2>';
// Copyright 2008 - 2010 all rights reserved, SQLFusion LLC, info@sqlfusion.com
// @author sarvesh kulkarni sarvesh@htmlfusion.com
/**
 * A cron job script for sending user worklog By Email
 */
include_once 'config.php';
$admin_emails = array(1 => '*****@*****.**', 2 => '*****@*****.**', 3 => '*****@*****.**', 4 => '*****@*****.**', 5 => '*****@*****.**', 6 => '*****@*****.**', 7 => '*****@*****.**', 8 => '*****@*****.**');
$type = array(1 => 'Today', 2 => 'PreviousDay', 3 => 'LastWeek');
$message_sent = 0;
$text = "";
$proj_discuss = new ProjectDiscuss();
$pd_discuss = new ProjectDiscuss();
$text .= "<h2> <u>Worklog Summary </u></h2>";
foreach ($type as $tp) {
    //select all the  user from project discuss table for the day
    $proj_discuss->query('select DISTINCT(pd.iduser) as iduser,usr.firstname, usr.email from project_discuss pd inner join user usr on usr.iduser=pd.iduser WHERE DATEDIFF(NOW(), date_added) <= 7;');
    //check if any of the user enterd worklog for the day
    if ($proj_discuss->getNumRows() > 0) {
        $text .= "<h3>Total Hours Entered   {$tp} </h3>";
        $text .= "<h4><u> Per Participants:</h4></u>";
        while ($proj_discuss->fetch()) {
            $iduser = $proj_discuss->getData('iduser');
            $name = $proj_discuss->getData('firstname');
            $total_hrs = $pd_discuss->getTotalHoursEnteredByIndividual($iduser, $tp);
            //echo 'sa'.(int)$total_hrs.'<br/>';
            if ($total_hrs != '') {
                $text .= '<b>' . $total_hrs . '</b>  Hrs By ' . $name . '<br/>';
            } else {
                $text .= '<b> 0:00</b>  Hrs  By ' . $name . '.<br/>';
            }
        }