<?php include 'inc_classes.php';?>
<?php include "../classes/thumbnail_images.class.php";?>
<?php
require 'PHPMailer-5.2.14/class.phpmailer.php';
function convertToHoursMins($time, $format = '%02d:%02d')
{
    if ($time < 1) {
        return;
    }
    $hours = floor($time / 60);
    $minutes = ($time % 60);
    return sprintf($format, $hours, $minutes);
}
$emilDate=date("Y-m-d");
$date=date('Y-m-d',strtotime('-1 days'));
echo $date.'<br>';
$sel_admin_id="select admin_id,name,type,cm_id,email from site_setting where 1 and system_status='Enabled'"; //and admin_id='283'
$ptr_admin_id=mysql_query($sel_admin_id);
while($data_admin_id=mysql_fetch_array($ptr_admin_id))
{
        // ============================== Updating in_complete task =====================================
        $sel_in_complete="select staff_task_id,points,staff_id,cm_id,admin_id from tk_individual_task where DATE(due_date) ='".$date."' and staff_id='".$data_admin_id['admin_id']."' and status='in_complete' and Validation='valid'";
        $ptr_in_complt=mysql_query($sel_in_complete);
        while($data_in_cmplt=mysql_fetch_array($ptr_in_complt))
        {
            $point=$data_in_cmplt['points'];
            $points='-'.$point;
            $rating_point='0';
            $ins_per="insert into tk_employee_performance (`staff_task_id`,`staff_id`,`earn_points`,`rating_point`,`date`,`cm_id`,`admin_id`)values('".$data_in_cmplt['staff_task_id']."','".$data_in_cmplt['staff_id']."','".$points."','".$rating_point."','".$date."','".$data_in_cmplt['cm_id']."','".$data_in_cmplt['admin_id']."')";
            $ptr_p=mysql_query($ins_per);
        
            '<br>In complete task - '. $update_status="update tk_individual_task set `status`='in_complete',`earn_points`='".$points."',`rating_point`='".$rating_point."',`sta_updated_admin_id`='".$data_in_cmplt['admin_id']."',`due_date`='".date('Y-m-d : H:i:s')."',`sta_complete_date`='".date('Y-m-d : H:i:s')."' where staff_task_id='".$data_in_cmplt['staff_task_id']."'";
            $ptr_ins_t=mysql_query($update_status); 
        }
        // ============================== Updating in-Progress task =====================================
        $sel_in_progress="select staff_task_id,points,staff_id,cm_id,admin_id from tk_individual_task where DATE(due_date) ='".$date."' and staff_id='".$data_admin_id['admin_id']."' and status='in_progress' and Validation='valid'";
        $ptr_in_progress=mysql_query($sel_in_progress);
        while($data_in_progress=mysql_fetch_array($ptr_in_progress))
        {
            $point=$data_in_progress['points'];
            $points='-'.$point;
            $rating_point='0';
            $ins_pers="insert into tk_employee_performance (`staff_task_id`,`staff_id`,`earn_points`,`rating_point`,`date`,`cm_id`,`admin_id`)values('".$data_in_progress['staff_task_id']."','".$data_in_progress['staff_id']."','".$points."','".$rating_point."','".$date."','".$data_in_progress['cm_id']."','".$data_in_progress['admin_id']."')";
            $ptr_ps=mysql_query($ins_pers);
        
            $update_status1="update tk_individual_task set `status`='in_complete',`earn_points`='".$points."',`rating_point`='".$rating_point."',`sta_updated_admin_id`='".$data_in_progress['admin_id']."',`due_date`='".date('Y-m-d : H:i:s')."',`sta_complete_date`='".date('Y-m-d : H:i:s')."' where staff_task_id='".$data_in_progress['staff_task_id']."'";
            $ptr_ins_task=mysql_query($update_status1); 
        }
        //  ===========================send incomplete task mail============================================
        $message = '';
        '<br>'.$sel_in_completeMail = "select task_name,assign_by,hours,staff_id,added_date from tk_individual_task where staff_id='".$data_admin_id['admin_id']."' and status='in_complete' and Validation='valid'"; 
        $ptr_in_compltMail = mysql_query($sel_in_completeMail);
        $tot_in_compltMail = mysql_num_rows($ptr_in_compltMail);
        if($tot_in_compltMail)
        {
            $b = 1;
            $tablStart = "<h3 style='font-family: Arial, sans-serif; margin-bottom: 10px; color: #444;'>Total Incomplete Records [" . $tot_in_compltMail . "]</h3>
            <table style='width: 100%; border-collapse: collapse; font-size: 16px; text-align: left;'>
                <tr>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Sr. No.</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Task Name</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Task Time</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Assign By</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Added Date</th>
                </tr>";
            while ($data_in_cmpltMail = mysql_fetch_array($ptr_in_compltMail)) 
            {
                $selName = "select admin_id,name from site_setting where 1 and admin_id='" . $data_in_cmpltMail['assign_by'] . "'";
                $ptrName = mysql_query($selName);
                $dataName = mysql_fetch_array($ptrName);
                $message .= "<tr>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $b++ . "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $data_in_cmpltMail['task_name'] . "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . convertToHoursMins($data_in_cmpltMail['hours'], '%02d hour %02d min') . "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $dataName['name'] . "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . date('d-m-Y', strtotime($data_in_cmpltMail['added_date'])). "</td>
                            </tr>";
            }
            $tablEnd = "</table>";
            $tmsLink = "<br>
            <div style='margin-top: 10px; font-family: Arial, sans-serif; font-size: 16px; color: #444;'>
                Please click on the link and complete your pending task: 
                <a href='https://tms.isasbeautyschool.org/login.php' target='_blank' style='color: #007BFF; text-decoration: none;'>
                    Click Here
                </a>
            </div>";
            $lastMassage=$tablStart . $message . $tablEnd . $tmsLink;
            $lastMassage;
            $staff_mail=$data_admin_id['email'];
            $mail = new PHPMailer(true);
            try 
            {
                //$mail->IsSMTP();                                      // Set mailer to use SMTP
                $mail->SMTPDebug=1;  
                $mail->Host = 'smtp.gmail.com';                       // Specify main and backup server
                $mail->SMTPAuth = true;                               // Enable SMTP authentication
                $mail->Username = 'erp.isas@gmail.com';                   // SMTP username
                $mail->Password = 'erp@frespa';                            // SMTP password
                $mail->SMTPSecure = 'ssl';                            // Enable encryption, 'tls' also accepted
                $mail->Port = 465;
                $mail->setFrom('info@isasbeautyschool.com', 'ISAS');
                $mail->addAddress("erp.isas@gmail.com"); 
                $mail->addCC($staff_mail); 
        
                $mail->Subject = 'In-Complete Task '.date('d M Y').'';
                $sendMessage=$lastMassage;
                
                $mail->WordWrap = 3000;
                $mail->isHTML(true);
                $mail->Body = $sendMessage;
                
                $mail->Send();
                ?>
                <script>//alert("Mail Send Successfully")</script>
                <?php
            } 
            catch (phpmailerException $e) {
            echo $e->errorMessage(); 
            } catch (Exception $e) {
            echo $e->getMessage(); 
            }
        }
        // =============================== Task Point And Task Quality Point ================================
        $sel_task_per="select earn_points,rating_point,staff_task_id from tk_employee_performance where date='".$date."' and staff_id='".$data_admin_id['admin_id']."'";
        $ptr_task_per=mysql_query($sel_task_per);
        $count=mysql_num_rows($ptr_task_per);
        $task_point1=0;
        $qualty_point=0;
        $task_quality_point=0;
        while($data_task_per=mysql_fetch_array($ptr_task_per))
        {
            // echo '<br>staff_id-'.$data_admin_id['admin_id']. '---- staff_name-'.$data_admin_id['name'];   
            $task_point1+=$data_task_per['earn_points'];
            $qualty_point=$data_task_per['rating_point'];
            $task_quality_point+=$qualty_point;
        }
        $task_point=$task_point1;
        $tot_cont=$count*100;
        $tot_quality_point= ($task_quality_point/$tot_cont)*100;
        // $task_tot_point=$task_point+$tot_quality_point;
        // $task_hour='';
        '<br>' .$sel_hour="select sum(hours) as today_hour from tk_individual_task where 1 and DATE(added_date)='".$date."
        ' and staff_id='".$data_admin_id['admin_id']."' and status!='halt' and status!='cancle' and Validation='valid '";
         $ptr_hour=mysql_query($sel_hour);
         $data_hour=mysql_fetch_array( $ptr_hour);
        echo '<br>'. $today_hours=$data_hour['today_hour'];
        echo '<br>'. $task_hour=$today_hours/60;

        echo '<br>'. $sel_key_point_per="select total_percentage,status from pm_total_keypoint_performancee where date='".$date."' and employee_id='".$data_admin_id['admin_id']."'";
        $ptr_key_point_per=mysql_query($sel_key_point_per);
        $tot_kpi_record=mysql_num_rows($ptr_key_point_per);
        // $task_point='';
        // $tot_key_point='';
        $data_key_point_per=mysql_fetch_array($ptr_key_point_per);
            echo '<br>staff_name-'.$data_admin_id['name'];
            $tot_key_point=$data_key_point_per['total_percentage'];
            // if($data_admin_id['type']=='C' || $data_admin_id['type']=='A')
            // {
               echo '<br>' .$sel_conc_pnt="select total_minute from tk_sales_point where 1 and DATE(added_date)='".$date."' and staff_id='".$data_admin_id['admin_id']."' and total_minute > 0";
                $ptr_conc_pnt=mysql_query($sel_conc_pnt);
                $tot_sale_record=mysql_num_rows($ptr_conc_pnt);
                $data_conc_pnt=mysql_fetch_array( $ptr_conc_pnt);
                $tot_conc_time=$data_conc_pnt['total_minute'];
                '<br>Tot Councillor point '.$tot_conc_pnt=round($tot_conc_time*0.208);
                '<br>Tot Councillor Hour '.$tot_conc_hour= $tot_conc_time/60;
            // }
        // ======================Student performance for faculty=================
        if($data_admin_id['type']=='F')
        {
                $tot_daily_feedback_percentage='';
                // $sel_student_batch="select distinct(batch_id) from student_batch_feedback where staff_id='".$data_admin_id['admin_id']."' and attendance_date='".$date."'";
                // echo '<br>'.$sel_student_batch="select distinct(course_batch_id) from student_attendence where 1 and attendence_date='".$date."' and admin_id='".$data_admin_id['admin_id']."'";
                //$sel_student_batch="select DISTINCT(s.course_batch_id) as batch_id from student_attendence s, course_batch_mapping b where s.course_batch_id=b.c_b_id and b.staff_id='".$data_admin_id['admin_id']."' and DATE(s.attendence_date)='".$date."'";
                '<br>' . $sel_student_batch = "SELECT DISTINCT(s.course_batch_id) FROM student_attendence s, batch_timetable b WHERE s.attendence_date = '" . $date . "' AND s.admin_id = '" . $data_admin_id['admin_id'] . "' AND s.course_batch_id = b.c_b_id AND s.attendence_date = b.date AND b.review_status = 'yes'";
                $ptr_student_batch=mysql_query($sel_student_batch);
                if($tot_batch_id=mysql_num_rows($ptr_student_batch))
                {
                    echo '<br> today batch- '. $batch_cnt=$tot_batch_id*100;
                    $i=1;
                    $total_feedback_point=0;
                    $total_feedback_percentage=0;
                    while($data_student_batch=mysql_fetch_array($ptr_student_batch))
                    {
                        //taking all present student of perticular batch
                        $sel_tot_batch_std="select count(enroll_id) as student_count from student_attendence where attendence='present' and course_batch_id='".$data_student_batch['course_batch_id']."' and attendence_date='".$date."'";
                        $ptr_count=mysql_query($sel_tot_batch_std);
                        $data_count=mysql_fetch_array( $ptr_count);
                        $tot_std_fed=$data_count['student_count'];
                        echo '<br> present student- '.$point_cnt=$tot_std_fed*100;
                        '<br>'.$sel_std_fed="select teaching_method,monitoring_class,faculty_behaviour,class_attention,management_approach,phone_submission from student_batch_feedback where staff_id='".$data_admin_id['admin_id']."' and batch_id='".$data_student_batch['course_batch_id']."' and attendance_date='".$date."'";
                        $ptr_std_fed=mysql_query($sel_std_fed);
                        $tot_std_fed=mysql_num_rows($ptr_std_fed);
                        //$point_cnt=$tot_std_fed*100;
                        $teaching_method=0;
                        $monitoring_class=0;
                        $faculty_behaviour=0;
                        $class_attention=0;
                        $phone_submission=0;
                        // $tot_managemnt_approch=0;
                        while($sata_student_fed=mysql_fetch_array($ptr_std_fed))
                        {
                            $teaching_method+=$sata_student_fed['teaching_method'];
                            $monitoring_class+=$sata_student_fed['monitoring_class'];
                            $faculty_behaviour+=$sata_student_fed['faculty_behaviour'];
                            $class_attention+=$sata_student_fed['class_attention'];
                            $phone_submission+=$sata_student_fed['phone_submission'];
                            // $management_approach+=$sata_student_fed['management_approach'];
                        }
                        echo '<br> <b> Lecture NO -'.$data_student_batch['course_batch_id'].'</b>';
                        echo '<br> teaching_method -'.$teaching_method;
                        echo '<br> monitoring_class -'.$monitoring_class;
                        echo '<br> faculty_behaviour -'.$faculty_behaviour;
                        echo '<br> class_attention -'.$class_attention;
                        echo '<br> phone_submission -'.$phone_submission;
                        // echo '<br> management_approach -'.$management_approach;
                        echo '<br>'.$teaching_method_point=($teaching_method/$point_cnt)*100;
                        echo '<br>'.$monitoring_class_point=($monitoring_class/$point_cnt)*100;
                        echo '<br>'.$faculty_behaviour_point=($faculty_behaviour/$point_cnt)*100;
                        echo '<br>'.$class_attention_point=($class_attention/$point_cnt)*100;
                        echo '<br>'.$phone_submission_point=($phone_submission/$point_cnt)*100;
                        // echo '<br>'.$management_approach_point=($management_approach/$point_cnt)*100;
                        '<br>'.$total_feedback_point=$teaching_method_point+$monitoring_class_point+$faculty_behaviour_point+$class_attention_point+$phone_submission_point;
                        echo '<br> total_percentage = '.$total_feedback_point;
                        $total_feedback_percentage+=($total_feedback_point/500)*100;
                        // echo '<br> Final_percentage one Lecture = '.$total_feedback_percentage;
                    }
                    $tot_daily_feedback_percentage=($total_feedback_percentage/$batch_cnt)*100;
                }
            //Student Feedback percentage
            echo '<br> ToTal Student Feedback percentage '.$ins_tot_daily_feedback_percentage=round($tot_daily_feedback_percentage);
            //   '<br>'.$sel_lec_hour="select distinct(course_batch_id) from student_attendence where attendence_date='".$date."' and admin_id='".$data_admin_id['admin_id']."'";
            //   $ptr_lec_hour=mysql_query($sel_lec_hour);
            //  $tot_batch_daily=mysql_num_rows($ptr_lec_hour);
            '<br>'. $sel_student_batch_cnt="select distinct(course_batch_id) from student_attendence where 1 and attendence_date='".$date."' and admin_id='".$data_admin_id['admin_id']."'";
            $ptr_student_batch_cnt=mysql_query($sel_student_batch_cnt);
            $tot_student_batch_cnt=mysql_num_rows($ptr_student_batch_cnt);
            echo  '<br> ToTal batch_hour_cnt = '.  $batch_hour_cnt=$tot_student_batch_cnt*2.5;
        }    
        // total task point
        echo '<br> ToTal_Task_Points '.$ins_task_point=round($task_point);
        // total task quality point of day out of 100
        echo '<br> ToTal_Task_ Qualty_Points '.$ins_tot_quality_point=round($tot_quality_point);
        // total key point of day
        echo '<br> ToTal_Key_Points '.$ins_tot_key_point=round($tot_key_point);

            '<br>'.$sel_minute="select minutes from pm_sales_kpi where action_name='add_lead'";
                $ptr_mintute=mysql_query($sel_minute);
                $data_minute=mysql_fetch_array($ptr_mintute);
                $lead_min=$data_minute['minutes'];
                $sel_lead="select count(inquiry_id) as tot_lead from inquiry where DATE(added_date)='".$date."' and admin_id='".$data_admin_id['admin_id']."'";
                $ptr_lead=mysql_query($sel_lead);
                $lead_record=mysql_num_rows($ptr_lead);
                $data_lead=mysql_fetch_array($ptr_lead);
                $lead_point=0;
                $ins_lead_point=0;
                // $lead_hour='';
                if($lead_record){
                '<br>Lead Count- '.$tot_lead=$data_lead['tot_lead'];
                '<br>Lead Time- '.$lead_time=$tot_lead*$lead_min;
                $lead_hour=$lead_time/60;
                '<br>Lead Point- '.$lead_point=$lead_time*0.208;
                $ins_lead_point=round($lead_point);
                }
                // else{
                //     '<br>Lead Point- '.$lead_point=0;
                //     $ins_lead_point=0;
                // }
        if($data_admin_id['type']=='F')
        {
            $hours=7.5;
            '<br> Todays hour Reduce - '. $hour_calc=$hours-($task_hour + $batch_hour_cnt);
            echo '<br> Today Hour Work '.$today_hour=$task_hour+ $batch_hour_cnt;
             '<br> Todays hour Reduce Point- '. $hour_reduce_point=round(abs($hour_calc)*13.3);
            // $total_day_per=$task_point+$tot_quality_point+$tot_key_point+$tot_daily_feedback_percentage;
            $total_day_per=$task_point+$tot_quality_point+$tot_key_point;

            // $total_day_per=38+100+100+100;
            if($today_hours!='' || $today_hours!=0)
            {
                // if($tot_daily_feedback_percentage!='' || $tot_daily_feedback_percentage!=0)
                // {
                //     if($today_hour <= $hours )
                //     {
                //         echo '<br> divide '.$tot_div=($task_hour*12.5)+300;
                //         echo '<br> Todays hour Reduce - '.$hour_reduce=round($hour_calc);
                //         echo '<br> Todays Minute Reduce - '. $minute_reduce=abs($hour_calc*60);
                //         echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=round($hour_reduce_point);
                //     }
                //     elseif($today_hour > $hours)
                //     {
                //         echo '<br> divide '.$tot_div=400;
                //         echo '<br> Todays hour Reduce - '.$hour_reduce=0;
                //         echo '<br> Todays Minute Reduce - '. $minute_reduce=$hour_reduce;
                //         echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=0;
                //     }
                // }
                // else
                // {
                    if($today_hour <= $hours )
                    {
                        echo '<br> divide '.$tot_div=300;
                        echo '<br> Todays hour Reduce - '.$hour_reduce=round($hour_calc);
                        echo '<br> Todays Minute Reduce - '. $minute_reduce=abs($hour_calc*60);
                        echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=round($hour_reduce_point);
                    }
                    elseif($today_hour > $hours)
                    {
                        echo '<br> divide '.$tot_div=300;
                        echo '<br> Todays hour Reduce - '.$hour_reduce=0;
                        echo '<br> Todays Minute Reduce - '. $minute_reduce=$hour_reduce;
                        echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=0;
                    }
                // }
            }
            else 
            {
                if($today_hour <= $hours )
                {
                    echo '<br> divide '.$tot_div=100;
                    echo '<br> Todays hour Reduce - '.$hour_reduce=round($hour_calc);
                    echo '<br> Todays Minute Reduce - '. $minute_reduce=abs($hour_calc*60);
                    echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=round($hour_reduce_point);
                }
                elseif($today_hour > $hours)
                {
                    echo '<br> divide '.$tot_div=100;
                    echo '<br> Todays hour Reduce - '.$hour_reduce=0;
                    echo '<br> Todays Minute Reduce - '. $minute_reduce=$hour_reduce;
                    echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=0;
                }
                // echo '<br> divide '.$tot_div=200;
            }
            echo "<br/> CALC ".$total_day_per.' - '.$tot_div;
            $performance=($total_day_per/$tot_div)*100;
            if($today_hour >= $hours)
            {
                echo "<br> Total Hour Work=yes";
                $final_performance=$performance+$hour_reduce_point;
                echo '<br> 1 Total One Day Performance without reducing point '.$ins_performance=round($final_performance);
            }
            elseif( $today_hour < $hours)
            {
                echo "<br> Total Hour Work=no";
                $final_performance=$performance-$hour_reduce_point;
                echo '<br> 2Total One Day Performance without reducing point '.$ins_performance=round($performance);
            }
            echo '<br> Final One Day Performance '.$ins_final_performance=round($final_performance);   //final_performance
        }
        // elseif($data_admin_id['type']=='C' || $data_admin_id['type']=='A')
        elseif($tot_sale_record)
        {
            if($data_admin_id['type']=='A')
            {
                // $sel_tot_batch_stds="select count(enroll_id) as student_counts from student_attendence where attendence='present' and attendence_date='".$date."'";
                '<br>' . $sel_tot_batch_stds = "SELECT DISTINCT(s.course_batch_id) FROM student_attendence s, batch_timetable b WHERE s.attendence_date = '" . $date . "'AND s.attendence='present' AND s.course_batch_id = b.c_b_id AND s.attendence_date = b.date AND b.review_status = 'yes'";
                $ptr_counts=mysql_query($sel_tot_batch_stds);
                $tot_std_pre=mysql_num_rows($ptr_counts);
                if($tot_std_pre)
                {
                    $sel_tot_batch_stds1="select count(enroll_id) as student_counts from student_attendence where attendence='present' and attendence_date='".$date."'";
                    $ptr_counts1=mysql_query($sel_tot_batch_stds1);
                    $data_counts=mysql_fetch_array($ptr_counts1);
                    $tot_stds_fed=$data_counts['student_counts'];
                    echo '<br>divides - '.$point_cnts=$tot_stds_fed*100;
                    '<br>'.$sel_std_fed="select management_approach from student_batch_feedback where 1 and  attendance_date='".$date."'";
                    $ptr_std_fed=mysql_query($sel_std_fed);
                    $tot_std_fed=mysql_num_rows($ptr_std_fed);
                    $management_approach=0;
                    $tot_managemnt_approch=0;
                    while($sata_student_fed=mysql_fetch_array($ptr_std_fed))
                    {
                        $management_approach+=$sata_student_fed['management_approach'];
                    }
                    $management_approach_point=($management_approach/$point_cnts)*100;
                    echo '<br>management_approach- '.$management_pts=$management_approach_point;
                    $tot_managemnt_approch=round($management_pts);
                    $management_ptot=100;
                }
                else{
                    echo '<br>management_approach'.$management_pts=0;
                    $management_ptot=0;
                }
            }
            else{
                echo '<br>management_approach'.$management_pts=0;
                $management_ptot=0;
            }
            $hours=8;
            '<br> Todays hour Reduce - '. $hour_calc=$hours-($task_hour + $tot_conc_hour+$lead_hour);
            echo '<br> Today Hour Work '.$today_hour=$task_hour+ $tot_conc_hour+$lead_hour;
            '<br> Todays hour Reduce Point- '. $hour_reduce_point=round(abs($hour_calc)*12.5);
            // '<br> Todays hour Reduce Point- '. $hour_reduce_point=round(abs($hour_calc)*12.5);
            $total_day_per=$task_point+$tot_quality_point+$tot_key_point+$tot_conc_pnt+$management_pts+$lead_point;
            // $total_day_per=38+100+100+100;
            if($task_point!='' && $tot_quality_point!='')
            {
                if($today_hour <= $hours )
                {
                    echo '<br> divide '.$tot_div=300 + $management_ptot;
                    echo '<br> Todays hour Reduce - '.$hour_reduce=round($hour_calc);
                    echo '<br> Todays Minute Reduce - '. $minute_reduce=abs($hour_calc*60);
                    echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=round($hour_reduce_point);
                }
                elseif($today_hour > $hours)
                {
                    echo '<br> divide '.$tot_div=300 +  $management_ptot;
                    echo '<br> Todays hour Reduce - '.$hour_reduce=0;
                    echo '<br> Todays Minute Reduce - '. $minute_reduce=$hour_reduce;
                    echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=0;
                }
            }
            else 
            {
                if($today_hour <= $hours )
                {
                    echo '<br> divide '.$tot_div=200 +  $management_ptot;
                    echo '<br> Todays hour Reduce - '.$hour_reduce=round($hour_calc);
                    echo '<br> Todays Minute Reduce - '. $minute_reduce=abs($hour_calc*60);
                    echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=round($hour_reduce_point);
                }
                elseif($today_hour > $hours)
                {
                    echo '<br> divide '.$tot_div=200 +  $management_ptot;
                    echo '<br> Todays hour Reduce - '.$hour_reduce=0;
                    echo '<br> Todays Minute Reduce - '. $minute_reduce=$hour_reduce;
                    echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=0;
                }
            }
            echo '<br> divide '.$tot_div;
            $performance=($total_day_per/$tot_div)*100;
            if($today_hour >= $hours)
            {
                echo "<br> Total Hour Work=yes";
                $final_performance=$performance+$hour_reduce_point;
                echo '<br> Total One Day Performance without reducing point '.$ins_performance=round($final_performance);
            }
            elseif( $today_hour <= $hours){
                echo "<br> Total Hour Work=no";
                $final_performance=$performance-$hour_reduce_point;
                echo '<br> Total One Day Performance without reducing point '.$ins_performance=round($performance);
            }
            echo '<br> Final One Day Performance '.$ins_final_performance=round($final_performance);   //final_performance
        }
        else
        {
            $hours=8;
            // echo'<br>'.$sel_minute="select minutes from pm_sales_kpi where action_name='add_lead'";
            // $ptr_mintute=mysql_query($sel_minute);
            // $data_minute=mysql_fetch_array($ptr_mintute);
            // $lead_min=$data_minute['minutes'];
            // $sel_lead="select count(inquiry_id) as tot_lead from inquiry where DATE(added_date)='".$date."' and admin_id='".$data_admin_id['admin_id']."'";
            // $ptr_lead=mysql_query($sel_lead);
            // $data_lead=mysql_fetch_array($ptr_lead);
            // echo'<br>Lead Count- '.$tot_lead=$data_lead['tot_lead'];
            // echo'<br>Lead Time- '.$lead_time=$tot_lead*$lead_min;
            // $lead_hour=$lead_time/60;
            // echo'<br>Lead Point- '.$lead_point=$lead_time*0.208;
            // $ins_lead_point=round($lead_point);
            // echo'<br>Lead Point- '.$lead_quality=100;
            $today_hour=$task_hour+$lead_hour;
            echo'<br> Todays hour Reduce - '.$hour_calc=$hours-$today_hour;
            echo '<br> Today Hour Work- '.$today_hour;
            '<br> Todays hour Reduce Point- '.$hour_reduce_point=abs($hour_calc)*12.5;
        
            '<br>'.$total_day_per=$task_point+$lead_point+$tot_quality_point+$tot_key_point;
            // echo'<br>'.$total_day_per=110+100+100;
            // if($task_hour < $hours ){
            //     echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=$hour_reduce_point;
            // }
            // elseif($task_hour > $hours){
            //     echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=0;
            // }
            $performance=($total_day_per/300)*100;
            // $final_performance=$performance $hour_reduce_point;
            if($today_hour >= $hours)
                {
                    echo "<br> Total Hour Work=yes";
                    echo '<br> Todays hour Reduce - '.$hour_reduce=0;
                    echo '<br> Todays Minute Reduce - '. $minute_reduce=$hour_reduce;
                    echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=0;
                    $final_performance=$performance+$hour_reduce_point;
                    echo '<br> Total One Day Performance without reducing point '.$ins_performance=round($final_performance);
                }
                elseif( $today_hour <= $hours)
                {
                    echo "<br> Total Hour Work=no";
                    echo '<br> Todays hour Reduce - '.$hour_reduce=round($hour_calc);
                    echo '<br> Todays Minute Reduce - '. $minute_reduce=abs($hour_calc*60);
                    echo '<br> Todays hour Reduce Point- '. $hour_reduce_point_f=round($hour_reduce_point);
                    $final_performance=$performance-$hour_reduce_point;
                    echo '<br> Total One Day Performance without reducing point '.$ins_performance=round($performance);
                }
            echo '<br> Final One Day Performance '.$ins_final_performance=round($final_performance);
        }
        // }
        // http://localhost/faculty_login-1/performance_calc.php
        // select distinct(course_batch_id) from student_attendence where attendence_date='2022-09-01' and admin_id='244'
        // if($tot_kpi_record!=''){
    '<br>'.$selct_record="select * from pm_daily_emp_performance where 1 and staff_id='".$data_admin_id['admin_id']."' and date='".$date."'";
    $ptr_record=mysql_query($selct_record);
    $data_records=mysql_fetch_array($ptr_record);
    $data_date=$data_records['date'];
    $data_staff=$data_records['staff_id'];
    if( $data_date &&  $data_staff)
    {
        if($data_key_point_per['status']=='present')
        {
            '<br>'.  $upd_query="update pm_daily_emp_performance set `staff_id`='".$data_staff."',`staff_type`='".$data_admin_id['type']."',`status`='".$data_key_point_per['status']."',`date`='".$data_date."',`task_percentage`='".$ins_task_point."',`task_quality_percentage`='".$ins_tot_quality_point."',`key_point_percentage`='".$ins_tot_key_point."',`student_feedback_percentage`='".$ins_tot_daily_feedback_percentage."',`councelling_point`='".$tot_conc_pnt."',`lead_point`='".$ins_lead_point."',`feedback_management_approach`='".$tot_managemnt_approch."',`total_hour`='".$hours."',`hour_not_worked`='".$minute_reduce."',`total_percentage`='".$ins_performance."',`point_reduce`='".$hour_reduce_point_f."',`final_percentage`='".$ins_final_performance."' ,`added_date`='".$data_records['added_date']."' ,`admin_id`='".$data_admin_id['admin_id']."',`cm_id`='".$data_admin_id['cm_id']."' where staff_id='".$data_admin_id['admin_id']."'and date='".$date."'";
            $ptr_Update=mysql_query($upd_query);
            $tablStart1 = "<h3 style='font-family: Arial, sans-serif; margin-bottom: 10px; color: #444;'> Updated Performance " . $date . "</h3>
            <table style='width: 100%; border-collapse: collapse; font-size: 16px; text-align: left;'>
                <tr>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Name</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Task point</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Task Quality point</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Key Performance Indicators</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Student Feedback Point</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Sales Point</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Management Approach</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Total Point</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Not Working Hour</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Reduce Point</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Final Performance(%)</th>
                </tr>";
                $message1 .= "<tr>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $data_admin_id['name']. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $ins_task_point . "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $ins_tot_quality_point. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $ins_tot_key_point. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $ins_tot_daily_feedback_percentage. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $tot_conc_pnt. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $tot_managemnt_approch. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $ins_performance. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . convertToHoursMins($minute_reduce, '%02d hour %02d min') . "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $hour_reduce_point_f . "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'><b>" . $ins_final_performance. "</b></td>

                            </tr>";
            $tablEnd1 = "</table>";
            $tmsLink1 = "<br>
            <div style='margin-top: 10px; font-family: Arial, sans-serif; font-size: 16px; color: #444;'>
                Please click on the link and check in details: 
                <a href='https://tms.isasbeautyschool.org/login.php' target='_blank' style='color: #007BFF; text-decoration: none;'>
                    Click Here
                </a>
            </div>";
            $lastMassage1=$tablStart1 . $message1 . $tablEnd1 . $tmsLink1;
            // $lastMassage;
            $staff_mail1=$data_admin_id['email'];
            $mail = new PHPMailer(true);
            try 
            {
                //$mail->IsSMTP();                                      // Set mailer to use SMTP
                $mail->SMTPDebug=1;   
                $mail->Host = 'smtp.gmail.com';                       // Specify main and backup server
                $mail->SMTPAuth = true;                               // Enable SMTP authentication
                $mail->Username = 'erp.isas@gmail.com';                   // SMTP username
                $mail->Password = 'erp@frespa';                            // SMTP password
                $mail->SMTPSecure = 'ssl';                            // Enable encryption, 'tls' also accepted
                $mail->Port = 465;
                $mail->setFrom('info@isasbeautyschool.com', 'ISAS');
                $mail->addAddress("erp.isas@gmail.com"); 
                $mail->addCC($staff_mail1); 
        
                $mail->Subject = $data_admin_id['name'].' Performance '.$date.'';
                $sendMessage1=$lastMassage1;
                
                $mail->WordWrap = 3000;
                $mail->isHTML(true);
                $mail->Body = $sendMessage1;
                
                $mail->Send();
                ?>
                <!-- <script>//alert("Mail Send Successfully")</script> -->
                <?php
            } 
            catch (phpmailerException $e) {
            echo $e->errorMessage(); 
            } catch (Exception $e) {
            echo $e->getMessage(); 
            }
        }
        elseif($data_key_point_per['status']=='absent')
        {
            '<br>'. $sel_key_point_pers="select total_percentage from pm_total_keypoint_performancee where date='".$data_date."' and employee_id='".$data_staff."'";
            $ptr_key_point_pers=mysql_query($sel_key_point_pers);
            $data_key_point_pers=mysql_fetch_array($ptr_key_point_pers);
             '<br>staff_name-'.$data_admin_id['name'];
            $tot_key_points=$data_key_point_pers['total_percentage'];
             '<br>'.$upd_querys="update pm_daily_emp_performance set `staff_id`='".$data_staff."',`staff_type`='".$data_admin_id['type']."',`status`='absent',`date`='".$data_date."',`task_percentage`='0',`task_quality_percentage`='0',`key_point_percentage`='".$tot_key_points."',`student_feedback_percentage`='0',`councelling_point`='0',`lead_point`='0',`feedback_management_approach`='0',`total_hour`='0',`hour_not_worked`='0',`total_percentage`='".$tot_key_points."',`point_reduce`='0',`final_percentage`='".$tot_key_points."' ,`added_date`='".$data_records['added_date']."' ,`admin_id`='".$data_admin_id['admin_id']."',`cm_id`='".$data_admin_id['cm_id']."' where staff_id='".$data_admin_id['admin_id']."'and date='".$date."'";
            $ptr_Updates=mysql_query($upd_querys);
        }
    }
    else
    {
        if($data_key_point_per['status']=='present')
        {
            '<br>'.$ins_performances="insert into pm_daily_emp_performance (`staff_id`,`staff_type`,`status`,`date`,`task_percentage`,`task_quality_percentage`,`key_point_percentage`,`student_feedback_percentage`,`councelling_point`,`lead_point`,`feedback_management_approach`,`total_hour`,`hour_not_worked`,`total_percentage`,`point_reduce`,`final_percentage`,`added_date`,`admin_id`,`cm_id`)values('".$data_admin_id['admin_id']."','".$data_admin_id['type']."','present','".$date."','".$ins_task_point."','".$ins_tot_quality_point."','".$ins_tot_key_point."','".$ins_tot_daily_feedback_percentage."','".$tot_conc_pnt."','".$ins_lead_point."','".$tot_managemnt_approch."','".$hours."','".$minute_reduce."','".$ins_performance."','".$hour_reduce_point_f."','".$ins_final_performance."','".date('Y-m-d : H:i:s')."','".$_SESSION['admin_id']."','".$data_admin_id['cm_id']."')";
            $ptr_ins_performance=mysql_query($ins_performances);
            $tablStarts = "<h3 style='font-family: Arial, sans-serif; margin-bottom: 10px; color: #444;'>Performance " . $date . "</h3>
            <table style='width: 100%; border-collapse: collapse; font-size: 16px; text-align: left;'>
                <tr>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Name</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Task point</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Task Quality point</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Key Performance Indicators</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Student Feedback Point</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Sales Point</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Management Approach</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Total Point</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Not Working Hour</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Reduce Point</th>
                    <th style='border: 1px solid #dddddd; padding: 8px 12px; background-color: #f4f4f4; color: #333;'>Final Performance(%)</th>
                </tr>";
                $messages .= "<tr>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $data_admin_id['name']. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $ins_task_point . "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $ins_tot_quality_point. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $ins_tot_key_point. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $ins_tot_daily_feedback_percentage. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $tot_conc_pnt. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $tot_managemnt_approch. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $ins_performance. "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . convertToHoursMins($minute_reduce, '%02d hour %02d min') . "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'>" . $hour_reduce_point_f . "</td>
                                <td style='border: 1px solid #dddddd; padding: 8px 12px;'><b>" . $ins_final_performance. "</b></td>

                            </tr>";
            $tablEnds = "</table>";
            $tmsLinks = "<br>
            <div style='margin-top: 10px; font-family: Arial, sans-serif; font-size: 16px; color: #444;'>
                Please click on the link and check in details: 
                <a href='https://tms.isasbeautyschool.org/login.php' target='_blank' style='color: #007BFF; text-decoration: none;'>
                    Click Here
                </a>
            </div>";
            $lastMassages=$tablStarts . $messages . $tablEnds . $tmsLinks;
            // $lastMassage;
            $staff_mails=$data_admin_id['email'];
            $mail = new PHPMailer(true);
            try 
            {
                //$mail->IsSMTP();                                      // Set mailer to use SMTP
                $mail->SMTPDebug=1;   
                $mail->Host = 'smtp.gmail.com';                       // Specify main and backup server
                $mail->SMTPAuth = true;                               // Enable SMTP authentication
                $mail->Username = 'erp.isas@gmail.com';                   // SMTP username
                $mail->Password = 'erp@frespa';                            // SMTP password
                $mail->SMTPSecure = 'ssl';                            // Enable encryption, 'tls' also accepted
                $mail->Port = 465;
                $mail->setFrom('info@isasbeautyschool.com', 'ISAS');
                $mail->addAddress("erp.isas@gmail.com"); 
                $mail->addCC($staff_mails); 
        
                $mail->Subject = $data_admin_id['name'].' Performance '.$date.'';
                $sendMessages=$lastMassages;
                
                $mail->WordWrap = 3000;
                $mail->isHTML(true);
                $mail->Body = $sendMessages;
                
                $mail->Send();
                ?>
                <!-- <script>//alert("Mail Send Successfully")</script> -->
                <?php
            } 
            catch (phpmailerException $e) {
            echo $e->errorMessage(); 
            } catch (Exception $e) {
            echo $e->getMessage(); 
            }
        }
        elseif($data_key_point_per['status']=='absent')
        {
            '<br>'. $sel_key_point_per="select total_percentage from pm_total_keypoint_performancee where date='".$date."' and employee_id='".$data_admin_id['admin_id']."'";
            $ptr_key_point_per=mysql_query($sel_key_point_per);
            $data_key_point_per=mysql_fetch_array($ptr_key_point_per);
            echo'<br>staff_name-'.$data_admin_id['name'];
            $tot_key_point=$data_key_point_per['total_percentage'];
            echo '<br>'.$ins_performances="insert into pm_daily_emp_performance (`staff_id`,`staff_type`,`status`,`date`,`task_percentage`,`task_quality_percentage`,`key_point_percentage`,`student_feedback_percentage`,`councelling_point`,`lead_point`,`feedback_management_approach`,`total_hour`,`hour_not_worked`,`total_percentage`,`point_reduce`,`final_percentage`,`added_date`,`admin_id`,`cm_id`)values('".$data_admin_id['admin_id']."','".$data_admin_id['type']."','absent','".$date."','0','0','".$tot_key_point."','0','0','0','0','0','0','".$tot_key_point."','0','".$tot_key_point."','".date('Y-m-d : H:i:s')."','".$_SESSION['admin_id']."','".$data_admin_id['cm_id']."')";
            $ptr_ins_performance=mysql_query($ins_performances);
        }
    }
    // echo '<hr>';
}
//===================================================================
// require 'PHPMailer-5.2.14/class.phpmailer.php';

// $mail = new PHPMailer(true);
// try {
// 		//$mail->IsSMTP();                                      // Set mailer to use SMTP
// 		$mail->SMTPDebug=1;   
// 		$mail->Host = 'smtp.gmail.com';                       // Specify main and backup server
// 		$mail->SMTPAuth = true;                               // Enable SMTP authentication
// 		$mail->Username = 'erp.isas@gmail.com';                   // SMTP username
// 		$mail->Password = 'erp@frespa';                            // SMTP password
// 		$mail->SMTPSecure = 'ssl';                            // Enable encryption, 'tls' also accepted
// 		$mail->Port = 465;
// 		$mail->setFrom('info@isasbeautyschool.com', 'ISAS');
// 		$mail->addAddress("erp.isas@gmail.com"); 
// 		$mail->addCC("kiran@isassystems.com"); 
		
// 		///usr/local/bin/php -q /home/isasadmin007/isastest/faculty_login/dsr_mail.php?&send_mail=mail
// 		///bin/touch /home/isasadmin007/public_html/cron_test.txt >/dev/null 2>&1 && /bin/echo "Cron ran at: `date`" >> /home/isasadmin007/public_html/cron_test.txt
// 		$mail->Subject = 'PMS Report is Generated ISAS Pvt Ltd- '.date('Y-m-d H:i:s').'';

// 		$sendMessage=$GLOBALS['box_message_top'];
// 		$sendMessage.=$message;
// 		$sendMessage.=$GLOBALS['box_message_bottom'];
		
// 		$mail->WordWrap = 3000;
// 		$mail->isHTML(true);
// 		$mail->Body = $sendMessage;
		 
// 	    $mail->Send();
// 		echo "Email Sent Successfully.";
// 	} catch (phpmailerException $e) {
// 	  echo $e->errorMessage(); 
// 	} catch (Exception $e) {
// 	  echo $e->getMessage(); 
// 	}	
//============================================================================
// =============================================== student Reiw Report============================================================

// $sel_cm="select distinct(cm_id) from site_setting where 1 and type='A'";
// $ptr_cm=mysql_query($sel_cm);
// while($data_cm=mysql_fetch_array($ptr_cm))
// {
//     $sel_staff="select * from student_batch_feedback where 1 ".$date." ".$data_cm['cm_id']." order by batch_id ASC ";
//     $ptr_staff=mysql_query( $sel_staff);
//     $no_of_records=mysql_num_rows( $ptr_staff);
//     $tot_std= $no_of_records*100;
//     $i=1;
//     $teaching_method=0;
//     $monitoring_class=0;
//     $faculty_behaviour=0;
//     $class_attention=0;
//     $phone_submission=0;
//     $management_approach=0;
//     while($data_staff=mysql_fetch_array($ptr_staff))
//     {
//         $cm_ids=$data_staff['cm_id'];

      
//         $teaching_method+=$data_staff['teaching_method'];
    
       
//         $monitoring_class+=$data_staff['monitoring_class'];
    
       
//         $faculty_behaviour+=$data_staff['faculty_behaviour'];
    
        
//         $class_attention+=$data_staff['class_attention'];
    
        
//         $phone_submission+=$data_staff['phone_submission'];
    
        
//         $management_approach+=$data_staff['management_approach'];
    
//     }
//     $tot_teaching_method=($teaching_method/$tot_std)*100;
//     $tot_monitoring_class=($monitoring_class/$tot_std)*100;
//     $tot_faculty_behaviour=($faculty_behaviour/$tot_std)*100;
//     $tot_class_attention=($class_attention/$tot_std)*100;
//     $tot_phone_submission=($phone_submission/$tot_std)*100;
//     $tot_management_approach=($management_approach/$tot_std)*100;

//     $sel_branch="select branch_name from site_setting where cm_id='".$data_cm['cm_id']."' and type='A'";
//     $ptr_branch=mysql_query($sel_branch);
//     $data_branch=mysql_fetch_array($ptr_branch);

//     echo '<br>Date - '.$date;
//     echo '<br>Branch Name - '.$data_branch['branch_name'];
//     echo '<br>Teaching Method - '.$tot_teaching_method;
//     echo '<br>Monitoring Class - '.$tot_monitoring_class;
//     echo '<br>Faculty Behaviour - '.$tot_faculty_behaviour;
//     echo '<br>Class Attention - '.$tot_class_attention;
//     echo '<br>Phone Submission - '.$tot_phone_submission;
//     echo '<br>Management Approach - '.$tot_management_approach;
   

//     // Email send Code 
// }
  
?>