<?php
/**
 * YAWIK
 *
 * @filesource
 * @copyright https://yawik.org/COPYRIGHT.php
 * @license   MIT
 */
/**
 * render a linkedin profile
 */
 ?>
<div class="panel panel-default">
<div class="panel-heading"><?php echo $this->translate('personal information'); ?></div>
<div class="panel-body">
<div class="pull-left">
<?php if (null !== $this->{'picture-url'}): ?><img class="yk-portrait" src="<?php echo $this->{'picture-url'};?>"/><?php endif ?>

</div>
<div>
<b><?php echo $this->{'first-name'};?> <?php echo $this->{'last-name'};?></b>
<br/><?php echo $this->location['name'];?>
<br/>
<?php


if(isset($this->birth_date['day'])):
  $date=DateTime::createFromFormat('Y-m-d', $this->birth_date['year'] . '-' .
                                            $this->birth_date['month'] . '-'.
                                            $this->birth_date['day']);
  echo $this->translate('Birthday').': ';
  echo $this->DateFormat($date,'short','none');
elseif(isset($this->birth_date['month'])):
  echo $this->translate("Year of birth");
  echo $this->birth_date['month'].'/';
  echo $this->birth_date['year'];
elseif(isset($this->birth_date['year'])):
  echo $this->translate("Year of birth").':';
  echo $this->birth_date['year'];
endif;
?>

<br/><i class="yk-icon yk-icon-linkedin"></i> <?php echo $this->link($this->{'public-profile-url'}); ?>
</div>
</div>
</div>

<?php if(isset($this->educations)):?>
<div class="panel panel-default">
<div class="panel-heading"><?php echo $this->translate("education")?></div>
<table class="table table-bordered table-condensed">
<tr>
<th><?php echo $this->translate("Date")?></th>
<th><?php echo $this->translate("School or university")?></th>
<th><?php echo $this->translate("Degree")?></th>
</tr>
<?php foreach($this->educations as $edu):?>
<tr>
 <td>
    <?php if (isset($edu['start-date'])):
        $date=DateTime::createFromFormat('Y-m-d', $edu['start-date']['year'] . '-' .
                                            $edu['start-date']['month'] . '-'.
                                            $edu['start-date']['day']);
        echo $this->dateFormat($date, 'short', 'none');
    endif;?>
    <?php if (isset($edu['end-date'])):?> - <?php
        $date=DateTime::createFromFormat('Y-m-d', $edu['end-date']['year'] . '-' .
                                            $edu['end-date']['month'] . '-'.
                                            $edu['end-date']['day']);
        echo $this->dateFormat($date, 'short', 'none');
    endif;?>
 </td>
 <td>
   <?php echo isset($edu['school-name'])?$edu['school-name']:'';?>
 </td>
 <td>
   <?php echo isset($edu['degree'])?$edu['degree']:'';?>
 </td>
</tr>
<?php endforeach;?>
</table>
</div>
<?php endif;?>

<?php if(isset($this->positions)):?>
<div class="panel panel-default">
<div class="panel-heading"><?php echo $this->translate("work experience");?></div>
<table class="table table-bordered table-condensed">
<tr>
<th><?php echo $this->translate("Date")?></th>
<th><?php echo $this->translate("Employer")?></th>
<th><?php echo $this->translate("Position")?></th>
<th><?php echo $this->translate("Description")?></th>
</tr>
<?php foreach($this->positions as $work_experience):?>
<?php if(isset($work_experience['id'])):?>
<tr>
 <td>
 <?php if (isset($work_experience['start-date'])):
        $date=DateTime::createFromFormat('Y-m-d', $work_experience['start-date']['year'] . '-' .
                                            $work_experience['start-date']['month'] . '-'.
                                            $work_experience['start-date']['day']);
        echo $this->dateFormat($date, 'short', 'none');
    endif;?>
    <?php if (isset($work_experience['end-date'])):?> - <?php
        $date=DateTime::createFromFormat('Y-m-d', $work_experience['end-date']['year'] . '-' .
                                            $work_experience['end-date']['month'] . '-'.
                                            $work_experience['end-date']['day']);
        echo $this->dateFormat($date, 'short', 'none');
    endif;?>
 </td>
 <td>
   <?php echo isset($work_experience['company'])?$work_experience['company']:'';?>
 </td>
 <td>
   <?php echo isset($work_experience['title'])?$work_experience['title']:'';?>
 </td>
 <td>
 <?php echo isset($work_experience['summary'])?$work_experience['summary']:'';?>
 </td>
</tr>
<?php endif;?>
<?php endforeach;?>
</table>
</div>
<?php endif;?>

