%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/pn/wp-content/themes/intosai/templates/logedin/
Upload File :
Create Path :
Current File : //var/www/pn/wp-content/themes/intosai/templates/logedin/my_projects.php

<?php
    //Get the user data (the role/s)
    $user_info = get_userdata($userID);
    $userRoll = implode(', ', $user_info->roles);
?>

<section class="content_section my_projects">
    <div class="wrapper">


        <a href="/my-projects/add-project/" class="create_project_btn btn trans-bg blue blue-border blue-hover-o">
            <i class="fa fa-plus"></i> Add New Project
        </a>
     	<?php
			$inputString = '';
			if($_POST['project-search']){
                    $inputString = $_POST['project-search'];
            }
		?>
		
        <div class="box-search-publish-project">
			
            <div class="search-project">
				
                <form action="<?php echo get_page_link(get_the_ID());?>" method="post">
					
                    <input type="text" name="project-search" id="search-project-input" placeholder="Project search" value="<?php echo $inputString; ?>">
					<?php if($_POST['project-search']){ ?>
                    <button type="button" class="clear-input-search clear-whole-form" style="display:block !important;"><span></span><span></span></button>
					
					<?php } else { ?>
					<button type="button" class="clear-input-search"><span></span><span></span></button>
					<?php } ?>
                </form>
            </div>
			
            <div class="list-result"></div>   
        </div>     
        
        <div class="centered_title">
            <h1><?php the_title(); ?>
			
			<?php if($_POST['project-search']){ ?>
			(Search results for: <?php echo $_POST['project-search']; ?>)
			<?php } ?>
			</h1>
			
			
			
        </div>

        <div class="project_list published">

            <div class="pl_title">
                <h2>Published Projects</h2>
            </div>
            <div class="pl_headings">
                <div class="id">ID</div>
                <div class="name">Name</div>
                <div class="created">Created</div>
                <div class="edited">Last Edited</div>
                <div class="status">Status</div>
                <div class="controlls">Controlls</div>
            </div>
            <?php
                $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
                
                //Checks if the user has one role of administrator 
                // var_dump(strpos($userRoll, "administrator"));
                // if (strpos($userRoll, "administrator") !== false) {
                    //Displays all the projects if the user is administrator
                    // $publishedArgs = array(
                    //     'post_type'         =>      'project',
                    //     'post_status'       =>      'publish',
                    //     'posts_per_page'    =>      -1,
                    //     'order'             =>      'ASC',
                    //     'orderby'           =>      'ID'
                    // );
                // } else {
                    //Displays only the projects who are assigned to the user
                    // $publishedArgs = array(
                    //     'post_type'         =>      'project',
                    //     'author'            =>      $userID,
                    //     'post_status'       =>      'publish',
                    //     'posts_per_page'    =>      -1,
                    //     'order'             =>      'ASC',
                    //     'orderby'           =>      'ID'
                    // );
                    
                    // if($_GET["dev"] == "true"){
                        $publishedArgs = array(
                            'post_type'         =>      'project',
                            // 'author'            =>      $userID,
                            'post_status'       =>      'publish',
                            'posts_per_page'    =>      50,
                            'paged'             =>      $paged,
                            'order'             =>      'ASC',
                            'orderby'           =>      'ID',
                            'search_prod_title' =>      $_POST['project-search']
                        );
                    // }else{
                    //     $publishedArgs = array(
                    //         'post_type'         =>      'project',
                    //         'author'            =>      $userID,
                    //         'post_status'       =>      'publish',
                    //         'posts_per_page'    =>      -1,
                    //         'order'             =>      'ASC',
                    //         'orderby'           =>      'ID'
                    //     );
                    // }
                // }

            ?>

    
            <?php 
                add_filter( 'posts_where', 'title_filter', 10, 2 );
                $publishedProjects = new WP_Query($publishedArgs); 
                remove_filter( 'posts_where', 'title_filter', 10, 2 );
                $iterProd = 0;
                //var_dump($publishedProjects);
            ?>
            <?php if($publishedProjects->have_posts()) : ?>
            <?php while($publishedProjects->have_posts()) : $publishedProjects->the_post(); ?>
        
                <?php
                    $revisionCreated = '';
                    $lastEdited = get_the_modified_date('d-m-Y  H:i');
                    $projectID = get_the_ID();
                    //echo $lastEdited;
                    /*----- SE IF THERE ARE ANY REVISIONS -----*/
                    $revisionArgs = array(
                        'post_type'         =>      'project_revisions',
                        'author'            =>      $userID,
                        'post_status'       =>      'pending',
                        'posts_per_page'    =>      1,
                        'order'             =>      'DESC',
                        'orderby'           =>      'ID',
                        'meta_query' => array(
                            array(
                                'key'     => 'revision_for_id',
                                'value'   => $projectID,
                                'compare' => 'LIKE',
                            ),
                        ),
                    );
                    $revisionProjects = new WP_Query($revisionArgs);
                    //var_dump($revisionProjects);
                    while($revisionProjects->have_posts()) : $revisionProjects->the_post();

                        $revisionCreated = get_the_date('d-m-Y  H:i');
                        //var_dump($revisionCreated);
                        //the_id(); echo ' '.$revisionCreated;

                    endwhile;
                    wp_reset_postdata();
                    /*----- END REVISION CHECK -----*/
                ?>          
                <div class="row">
                    <div class="id">
                        <div class="id_holder">
                            #<?= $projectID; ?>
                        </div>
                    </div>

                    <div class="name">
                        <?= get_the_title($projectID); ?>
                    </div>

                    <div class="created">
                        <?= get_the_date('d-m-Y  H:i', $projectID); ?>
                    </div>

                    <div class="edited">
                        <?php
                            //echo $revisionCreated.'<br />';
                            //echo $lastEdited.'<br />';
                            if($revisionCreated == '') :
                                echo $lastEdited;
                            elseif($lastEdited < $revisionCreated) :
                                echo $revisionCreated;
                            elseif($lastEdited > $revisionCreated) :
                                echo $lastEdited;
                            elseif($lastEdited = $revisionCreated) :
                                echo $lastEdited;
                            endif;
                        ?>
                    </div>

                    <div class="status">
                        <?php
                            if($revisionCreated == '') :
                                echo '<span class="published">Published</span>';
                            elseif($lastEdited < $revisionCreated) :
                                echo '<span class="pending">Update pending</span>';
                            elseif($lastEdited > $revisionCreated) :
                                echo '<span class="published">Published</span>';
                            elseif($lastEdited = $revisionCreated) :
                                echo '<span class="published">Published</span>';
                            endif;
                        ?>
                    </div>
                    <div class="controlls">

                        <a href="/my-projects/edit-project?id=<?= $projectID; ?>">
                            <div class="controll_holder edit">
                                <i class="fa fa-pencil"></i>

                                <div class="tooltip">
                                    Edit this project
                                </div>
                            </div>
                        </a>

                    </div>
                </div>
                <?php $iterProd++; ?>
            <?php endwhile; ?>
            <?php wp_reset_postdata(); ?>
            <?php else : ?>

                <div class="no-projects">
                    You have no published projects as of yet.
                </div>

            <?php endif; ?>
            
            <?php 
            
            // if($_GET["dev"] == "true"){
                // var_dump($_POST['project-search']);
                if($_POST['project-search']){
                    $count = $iterProd;
                }else{
                    $count = wp_count_posts('project')->publish;
                }
                // var_dump($count);
                $total = ceil($count/50);

                $big = 999999999; // уникальное число

                $paginate_links = paginate_links( array(
                    'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
                    'format'  => '?paged=%#%',
                    'current' => max( 1, get_query_var('paged') ),
                    'total'   => $total,
                    'prev_text' => '&laquo;',
                    'next_text' => '&raquo;'
                ) );

                if($total > 1){
                    echo '<nav class="pagination">'.$paginate_links.'</nav>';
                }
                
            // }
            ?>
            
        </div>

        <div class="project_list drafts">

            <div class="pl_title">
                <h2>Project drafts</h2>
            </div>
            <div class="pl_headings">
                <div class="id">ID</div>
                <div class="name">Name</div>
                <div class="created">Created</div>
                <div class="edited">Last Edited</div>
                <div class="status">Status</div>
                <div class="controlls">Controlls</div>
            </div>

            <?php
                //Checks if the user has one role of administrator 
                // if (strpos($userRoll, "administrator") !== false) {
                    //Displays all the project drafts if the user is administrator
                     $publishedArgs = array(
                        'post_type'         =>      'project',
                        // 'author'            =>      $userID,
                        'post_status'       =>      'pending',
                        'posts_per_page'    =>      -1,
                        'order'             =>      'ASC',
                        'orderby'           =>      'ID'
                    );
                // } else {
                    //Displays only the project drafts who are assigned to the user
                    $publishedArgs = array(
                        'post_type'         =>      'project',
                        'author'            =>      $userID,
                        'post_status'       =>      'pending',
                        'posts_per_page'    =>      -1,
                        'order'             =>      'ASC',
                        'orderby'           =>      'ID'
                    );
                // }
            ?>

            <?php $publishedProjects = new WP_Query($publishedArgs); ?>
            <?php if($publishedProjects->have_posts()) : ?>
            <?php while($publishedProjects->have_posts()) : $publishedProjects->the_post(); ?>

                <div class="row">
                    <div class="id">
                        <div class="id_holder">
                            #<?php the_ID(); ?>
                        </div>
                    </div>

                    <div class="name">
                        <?php the_title(); ?>
                    </div>

                    <div class="created">
                        <?//= get_the_date('d-m-Y'); ?>
                        <?= the_field('draft_creation'); ?>
                    </div>

                    <div class="edited">
                        <?= get_the_modified_date('d-m-Y H:i'); ?>
                    </div>

                    <div class="status">
                        <?php
                            $pStatus = get_post_status();
                            $ppStatus = get_field('publish_status');

                            if($pStatus == 'pending' && $ppStatus == 'draft') :
                                echo '<span class="draft">Draft</span>';
                            elseif($pStatus == 'pending' && $ppStatus == 'publish') :
                                echo '<span class="pending">Pending publication</span>';
                            endif;
                        ?>
                    </div>
                    <div class="controlls">

                        <a href="/my-projects/edit-project?id=<?= get_the_ID(); ?>">
                            <div class="controll_holder edit">
                                <i class="fa fa-pencil"></i>

                                <div class="tooltip">
                                    Edit this project
                                </div>
                            </div>
                        </a>

                    </div>
                </div>

            <?php endwhile; ?>
            <?php wp_reset_postdata(); ?>
            <?php else : ?>

                <div class="no-projects">
                    You have no project drafts as of yet.
                </div>

            <?php endif; ?>
        </div>

    </div>
</section>

Zerion Mini Shell 1.0