<a id="new_osaa_today_button" href="<?php echo url('/today/articles/new'); ?>">Create New OSAAtoday Article</a>
<a href="<?php echo url('/today'); ?>"><img src="<?php echo asset('/images/logos/OSAAtoday.png'); ?>" alt="" title="" style="margin-top: 1em;" /></a>

<h2>News Author Profile Information</h2>
<div class="columns">
    <div class="third">        

        <div class="label">First Name:</div><?php echo (!Helpers::strIsEmpty(Auth::user()->first_name)) ? Auth::user()->first_name : '- -'; ?><br />
        <div class="label">Middle Name:</div><?php echo (!Helpers::strIsEmpty(Auth::user()->middle_name)) ? Auth::user()->middle_name : '- -'; ?><br />
        <div class="label">Last Name:</div><?php echo (!Helpers::strIsEmpty(Auth::user()->last_name)) ? Auth::user()->last_name : '- -'; ?><br />

        <br />

        <div class="label">Login E-Mail:</div><?php echo Auth::user()->email; ?><br />

        <br />
        
        <div class="label">User ID:</div><?php echo Auth::user()->id; ?><br />
        <div class="label">User Created:</div><?php echo date('n/j/Y g:ia', strtotime(Auth::user()->created_at)); ?><br />
        <div class="label">Last Updated:</div><?php echo date('n/j/Y g:ia', strtotime(Auth::user()->updated_at)); ?><br />

        <br />

        <div class="label">Author ID:</div><?php echo $info['author']->id; ?><br />
        <div class="label">Author Created:</div><?php echo date('n/j/Y g:ia', strtotime($info['author']->created_at)); ?><br />
        <div class="label">Last Updated:</div><?php echo date('n/j/Y g:ia', strtotime($info['author']->updated_at)); ?>

    </div>

    <div class="third">

        <div class="label">Display Name:</div><?php echo $info['author']->getName(); ?><br />
        <div class="label">Display E-Mail:</div><?php echo Form::text('display_email', $info['author']->getEmail(false), array('data-type' => 'STRING', 'data-autosave-news' => 'email', 'style' => 'font-size: 9pt;')); ?><br />


        <br />

        <div class="label">Facebook:</div><?php echo Form::text('facebook_handle', $info['author']->facebook_handle, array('data-type' => 'STRING', 'data-autosave-news' => 'facebook_handle', 'style' => 'font-size: 9pt;')); ?><br />        
        <div class="label">Twitter:</div><?php echo Form::text('twitter_handle', $info['author']->twitter_handle, array('data-type' => 'STRING', 'data-autosave-news' => 'twitter_handle', 'style' => 'font-size: 9pt;')); ?><br />
        <div class="label">Instagram:</div><?php echo Form::text('instagram_handle', $info['author']->instagram_handle, array('data-type' => 'STRING', 'data-autosave-news' => 'instagram_handle', 'style' => 'font-size: 9pt;')); ?><br />        

        <br />

        <div class="label">Outlet:</div><?php echo Form::text('author_outlet', $info['author']->outlet, array('data-type' => 'STRING', 'data-autosave-news' => 'outlet', 'style' => 'font-size: 9pt;')); ?><br />
        <div class="label">Title:</div><?php echo Form::text('author_title', $info['author']->title, array('data-type' => 'STRING', 'data-autosave-news' => 'title', 'style' => 'font-size: 9pt;')); ?><br />

        <br />

        <div class="label">Is Publisher?:</div><?php echo ($info['author']->is_publisher) ? 'Yes' : 'No'; ?>


    </div>

    <div class="third">        

        <?php if (Helpers::strIsEmpty($info['author']->photo_path)): ?>                
            <img id="news_author_photo" src="" alt="" title="" style="float: left; margin: 0 20px 0.5em 0; width: 64px; height: 80px; background-color: #999999; outline: 1px solid #000000;" />
        <?php else: ?>
            <img id="news_author_photo" src="<?php echo asset($info['author']->photo_path); ?>?t=<?php echo time(); ?>" alt="" title="" style="float: left; margin: 0 20px 0.5em 0; width: 64px; height: 80px; outline: 1px solid #000000;" />
        <?php endif; ?>

        <b>Display Photo</b><br />
        <?php if (Helpers::strIsEmpty($info['author']->photo_path)): ?>                
            <span name="news_author_photo_preview_text" class="small gray note" style="">No author photo uploaded.  Use the buttons below to upload an image to be used as your author photo.</span>
        <?php else: ?>
            <span name="news_author_photo_preview_text" class="small gray note" style="">Your photo is uploaded.  You can replace the image using the buttons below.</span>
        <?php endif; ?>

        <br class="clear" /><br />

        <?php echo Form::open(array('url'    => url('/today/authors') . '/' . $info['author']->id . '/upload-photo',
                        'files'  => true,
                        'id'     => 'edit-news-author',
                        'name'   => 'edit-news-author',
                        'method' => 'post')); ?>
            <?php echo Form::hidden('author_id', $info['author']->id); ?>            
            <?php echo Form::file('news_author_photo_upload_field', array('name' => 'news_author_photo_upload_field', 'id' => 'news_author_photo_upload_field')); ?>        
        <?php echo Form::close(); ?>

        <br class="clear" />

        <a href="#" data-action="upload_news_author_photo">Upload Photo</a>
        <a href="#" data-action="delete_news_author_photo">Delete Photo</a>

        <br /><br />
        
        <ul style="font-size: 9pt;">
            <li>Max file size: less than 4 MB</li>
            <li>Image file extensions: .jpg, .jpeg., .gif, or .png</li>            
            <li>Dimensions: 64px (W) x 80px (H)</li>            
        </ul>
    </div>
</div>

<br class="clear" /><br />

<?php if ($info['author']->is_publisher): ?>

    <h2>Articles Waiting to Be Published</h2>

    <?php
        $articles = array();

        $articles = newsarticle::where('is_retired', '=', 0)
                               ->where(function($query)
                                 {
                                     $query->whereNull('published_at')
                                           ->orWhere('published_at', '>=', date('Y-m-d H:i:s', time()));
                                 })
                               ->whereNotNull('submitted_at')
                               ->orderBy('submitted_at', 'DESC')
                               ->get();
    ?>

    <?php if (count($articles) > 0): ?>

        <table class="bia_table">

            <thead>
                <tr>
                    <th></th>
                    <th>Author</th>
                    <th>Publisher</th>
                    <th>Title</th>
                    <th>Submitted At</th> 
                    <th>Published At</th>                  
                    <th></th>
                </tr>
            </thead>

            <tbody>

                <?php foreach ($articles as $article): ?>

                    <tr data-article-id="<?php echo $article->id; ?>" data-color-rows="1">
                        <td>
                            <?php if (is_null($article->submitted_at)): ?>
                                <img src="<?php echo asset('/images/icons/never_started_16px.png'); ?>" alt="" title="Not Submitted" style="width: 1em; height: 1em; vertical-align: middle;" />
                            <?php elseif (is_null($article->published_at)): ?>
                                <img src="<?php echo asset('/images/icons/pending_16px.png'); ?>" alt="" title="Not Published" style="width: 1em; height: 1em; vertical-align: middle;" />
                            <?php elseif (strtotime($article->published_at) >= time()): ?>
                                <img src="<?php echo asset('/images/icons/ajax_loader2.gif'); ?>" alt="" title="Deferred Publish" style="width: 1em; height: 1em; vertical-align: middle;" />
                            <?php else: ?>
                                <img src="<?php echo asset('/images/icons/finished_16px.png'); ?>" alt="" title="Published" style="width: 1em; height: 1em; vertical-align: middle;" />
                            <?php endif; ?>
                        </td>
                        <td><?php echo $article->getAuthorName(); ?></td>
                        <td><?php echo $article->getPublisherName(); ?></td>
                        <td><?php echo $article->title; ?></td>
                        <td><?php echo date('n/j/y g:ia', strtotime($article->submitted_at)); ?></td>
                        <td>
                            <?php if (!is_null($article->published_at)): ?>
                                <?php echo date('n/j/y g:ia', strtotime($article->published_at)); ?>
                            <?php else: ?>
                                - -
                            <?php endif; ?> 
                        </td>
                        <td><a href="<?php echo url('/today/articles/' . $article->id . '/edit'); ?>" target="_blank">Open</a></td>
                    </tr>

                <?php endforeach; ?>

            </tbody>

        </table>                                       

    <?php else: ?>
        There are no OSAAtoday articles waiting to be published.<br />
    <?php endif; ?>


    <br class="clear" />
<?php endif; ?>

<h2>Your Articles</h2>

<?php
    $articles = array();

    $articles = newsarticle::where('is_retired', '=', 0)
                           ->where('author', '=', $info['author']->id)                               
                           ->orderBy('created_at', 'DESC')
                           ->get();
?>

<?php if (count($articles) > 0): ?>

    <table class="bia_table">

        <thead>
            <tr>
                <th></th>
                <th>Status</th>                
                <th>Publisher</th>
                <th>Title</th>                
                <th></th>
            </tr>
        </thead>

        <tbody>

            <?php foreach ($articles as $article): ?>

                <tr data-article-id="<?php echo $article->id; ?>" data-color-rows="1">
                    <td>
                        <?php if (is_null($article->submitted_at)): ?>
                            <img src="<?php echo asset('/images/icons/never_started_16px.png'); ?>" alt="" title="Not Submitted" style="width: 1em; height: 1em; vertical-align: middle;" />
                        <?php elseif (is_null($article->published_at)): ?>
                            <img src="<?php echo asset('/images/icons/pending_16px.png'); ?>" alt="" title="Not Published" style="width: 1em; height: 1em; vertical-align: middle;" />
                        <?php else: ?>
                            <img src="<?php echo asset('/images/icons/finished_16px.png'); ?>" alt="" title="Not Published" style="width: 1em; height: 1em; vertical-align: middle;" />
                        <?php endif; ?>
                    </td>
                    <td>
                        <?php if (is_null($article->submitted_at)): ?>
                            Not Submitted
                        <?php elseif (is_null($article->published_at)): ?>
                            Submitted <?php echo date('n/j/y g:ia', strtotime($article->submitted_at)); ?>
                        <?php else: ?>
                            Published <?php echo date('n/j/y g:ia', strtotime($article->published_at)); ?>
                        <?php endif; ?>
                    </td>                    
                    <td><?php echo $article->getPublisherName(); ?></td>
                    <td><?php echo $article->title; ?></td>                    
                    <td><a href="<?php echo url('/today/articles/' . $article->id . '/edit'); ?>" target="_blank">Open</a></td>
                </tr>

            <?php endforeach; ?>

        </tbody>

    </table>                                       

<?php else: ?>
    You have not authored any OSAAtoday articles.<br />
<?php endif; ?>


<br class="clear" />
