<?php
global $wpdb, $current_user;
$wpttarUserRole = $this->WPTTARGetCurrentUserCall();
if (isset($_REQUEST['projectID']) && !empty($_REQUEST['projectID']) && isset($_REQUEST['developerID']) && !empty($_REQUEST['developerID'])) {
    $developerID = $_REQUEST['developerID'];
    $projectID = $_REQUEST['projectID'];
} else {
    $developerID = $current_user->ID;
    $projectID = $_REQUEST['projectID'];
}
$wpttarProjectComments = $this->WPTTARGetResultsByMultipleFields($this->WpttarProjectsLogTable,'projectID','developerID',$projectID,$developerID,'getResults'); 
$WpttarEmployeeFirstName = get_user_meta($developerID, 'first_name', true);
$WpttarEmployeeLastName = get_user_meta($developerID, 'last_name', true);
?>
<!-- BEGIN PAGE HEADER-->
<!-- END PAGE HEADER-->
<div class="preloader">  <span class="preloader-custom-gif"></span></div>
<input type="hidden" id="current-role-member" value="<?php echo esc_attr($wpttarUserRole); ?>">
<div style="padding-left: 0px; padding-right:20px; padding-top:0px;" class="col-md-12">
    <h3 class="page-title"><?php _e('Projects Comments', 'wpttar'); ?></h3>
    <div class="page-bar">
        <ul class="page-breadcrumb">
             <li><a href="?page=wpttar-projects"><i class="fa fa-home"></i><?php _e('Home', 'wpttar'); ?><i class="fa fa-angle-right"></i></a></li>
            
            <?php if (isset($_REQUEST['action']) && $_REQUEST['action'] = 'Userpage') { ?>
            <li><a href="?page=wpttar-developer-projects-details&developerID=<?php
            if (isset($developerID)) : echo esc_attr($developerID);
            endif;
            ?>">
         <?php } else { ?>
                    <li><a href="?page=wpttar-project-view&projectID=<?php echo esc_attr($projectID); ?>">
                     <?php } ?>
                <?php _e('Project Details', 'wpttar'); ?><i class="fa fa-angle-right"></i></a></li>
            
            <li><?php _e('Projects Comments', 'wpttar'); ?></li>        
        </ul>
    </div>
    <div class="row">
        <div class="col-md-12">
            <?php if (isset($_REQUEST['action']) && $_REQUEST['action'] = 'Userpage') { ?>
                <a class="btn green " href="?page=wpttar-developer-projects-details&developerID=<?php echo esc_attr($developerID); ?>" ><i class="fa fa-arrow-left"></i><?php _e('Back', 'wpttar'); ?> </a>
            <?php } else { ?>
                <a class="btn green " href="?page=wpttar-project-view&projectID=<?php echo esc_attr($projectID); ?>" ><i class="fa fa-arrow-left"></i><?php _e('Back', 'wpttar'); ?> </a>    
            <?php } ?>
            <div class="portlet box blue calendar">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-list"></i>
                        <?php _e(' List of', 'wpttar'); ?>
                        <?php
                        if (isset($WpttarEmployeeFirstName)) : echo esc_html($WpttarEmployeeFirstName . ' ');
                        endif;
                        if (isset($WpttarEmployeeLastName)) : echo esc_html($WpttarEmployeeLastName);
                        endif;
                        ?>
                        <?php _e(' Comments', 'wpttar'); ?>
                    </div>
                </div>
                <div class="portlet-body">
                    <table class="table table-striped table-bordered table-hover" id="wpttarDataTable">
                        <thead>
                            <tr>
                                <th><?php _e('S.No', 'wpttar'); ?></th>
                                <th><?php _e('Project Name', 'wpttar'); ?></th>
                                <th><?php _e('Comments', 'wpttar'); ?></th>
                                <th><?php _e('Date', 'wpttar'); ?></th>
                                <th><?php _e('Action', 'wpttar'); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $i = 1;
                            if (!empty($wpttarProjectComments)) {
                                foreach ($wpttarProjectComments as $wpttarProjectComment) {
                                    $wpttarProjectResults = $this->WPTTARGetTableDataByID($projectID, $this->WpttarProjectsTable, 'id');
                                    ?>
                                    <tr id="row">
                                        <td><?php echo esc_html($i); ?></td>
                                        <td ><?php
                                            if (isset($wpttarProjectResults->projectName)) : echo esc_html($wpttarProjectResults->projectName);
                                            endif;
                                            ?></td>
                                        <td id="datacomment-<?php
                                            if (isset($wpttarProjectComment->id)) : echo esc_html($wpttarProjectComment->id);
                                            endif;
                                            ?>"><?php
                                            if (isset($wpttarProjectComment->userComment)) : echo esc_html($wpttarProjectComment->userComment);
                                            endif;
                                            ?></td>
                                        <td><?php
                                            if (isset($wpttarProjectComment->updateDate)) : echo esc_html(date('d M Y', strtotime($wpttarProjectComment->updateDate)));
                                            endif;
                                            ?></td>
                                        <td><a class="blue color" href="#editcomment" onclick="wpttarEditCommentArea('<?php echo esc_js($wpttarProjectComment->id); ?>','<?php echo esc_js($wpttarProjectResults->projectName); ?>','<?php echo esc_js(date('d M Y', strtotime($wpttarProjectComment->updateDate))); ?>','<?php echo esc_js($wpttarProjectComment->userComment); ?>')" data-toggle="modal"><i class="fa fa-edit"></i></a></td>
                                    </tr>
                                    <?php
                                    $i++;
                                }
                            }
                            ?>
                        </tbody>
                    </table>                   
                </div>
            </div>
        </div>
    </div>
</div>

<div id="editcomment" class="modal fade" tabindex="-1" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-close"></i></button>
                <h4 class="modal-title"><strong><?php _e('Edit Comment', 'wpttar'); ?></strong></h4>
            </div>
            <div class="modal-body">
                <div class="alert alert-success display-hide" id="editcomment_success"><i class='fa fa-check-square' aria-hidden='true'></i>
                    <button class="close" data-close="alert"></button>
                </div>
                <div class="alert alert-danger display-hide" id="editcomment_error">
                    <button class="close" data-close="alert"></button>
                </div>
                <div class="portlet-body form">
                    <!-- BEGIN FORM-->
                    <form action="#" method="post" class="form-horizontal">
                        <div class="form-body">
                            <div class="form-group">
                                <div class="col-md-5">
                                    <input class="form-control form-control-inline input-medium" readonly id="projectname"  type="text"/>
                                </div>
                                <div class="col-md-5">
                                    <input class="form-control form-control-inline input-medium" readonly id="projectdate"  type="text"/>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <div class="col-md-10">
                                    <textarea class="form-control form-control-inline" placeholder="<?php _e('Enter your comment', 'wpttar'); ?>" id="projectcomment" name="editcomment"></textarea>
                                </div>
                            </div>
                           
                        </div>
                        <div class="modal-footer">
                            <button type="button"  class=" btn blue editcommentarea"> <i class="fa fa-edit"></i><?php _e('Edit', 'wpttar'); ?></button>
                            <button type="button" data-dismiss="modal" aria-hidden="true" class="btn default wpttar-comment-close"><i class="fa fa-times"></i><?php _e('Cancel', 'wpttar'); ?></button>
                        </div>
                    </form>
                    <!-- END FORM-->
                </div>
            </div>
        </div></div></div>
<!-- END PAGE CONTENT-->
<div class="user-timer-load-in-div"></div>