<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright © 2002 - 2010 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Personnel List Mods
| Original author : eduran
| Update v7 Author : AvaLoN
| Upgrade: Smokeman
| Email: admin@fusiontr.com
| Web: http://www.fusiontr.com
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "../../maincore.php";
require_once THEMES."templates/header.php";

if (!defined("IN_FUSION")) { die("Access Denied"); }

include INFUSIONS."personnel_list/infusion_db.php";
require_once INCLUDES."bbcode_include.php";

if (file_exists(INFUSIONS."personnel_list/locale/".$settings['locale'].".php")) {
	include INFUSIONS."personnel_list/locale/".$settings['locale'].".php";
} else {
	include INFUSIONS."personnel_list/locale/Danish.php";
}

add_to_title(" - Personnel List");

	if (isset($_GET['action']) && $_GET['action'] == "refresh") {
	$i = 1;
	$result = dbquery("SELECT * FROM ".DB_PERSONNEL." ORDER BY personnel_order");
	while ($data = dbarray($result)){
		$result2 = dbquery("UPDATE ".DB_PERSONNEL." SET personnel_order='$i' WHERE personnel_id='".$data['personnel_id']."'");
		$i++;
	}
	redirect(FUSION_SELF.$aidlink);
	}
opentable($locale['pe300']);
$result = dbquery("SELECT * FROM ".DB_PERSONNEL."");
$rows = dbrows($result);
if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; }
if ($rows != 0){
	if (iADMIN) {echo "<center>[<a href='".INFUSIONS."personnel_list/personnel_list.php".$aidlink."&new_personnel=1'>".$locale['pe200']."</a>] |
                [<a href='".FUSION_SELF.$aidlink."&action=refresh'>".$locale['pe305']."</a>]</center><br />";}
	tablebreak();
	$i = 1; 
	$result = dbquery("SELECT * FROM ".DB_PERSONNEL." ORDER BY personnel_order LIMIT ".$_GET['rowstart'].",10");
	$numrows = dbrows($result);
	while ($data = dbarray($result)){
		echo "<table align='center' cellpadding='0' cellspacing='1' width='80%' class='tbl-border'>
              <tr>
                  <td class='tbl2' colspan='2'>
                    <table cellpadding='0' cellspacing='0' width='100%'>
                    <tr>";
                    	$result2 = dbquery("SELECT * FROM ".DB_USERS." WHERE user_id='".$data['personnel_userid']."'");
                      while ($data2 = dbarray($result2)){
                        echo "<td class='small'><b><span class='comment-name'><a href='".BASEDIR."profile.php?lookup=".$data['personnel_userid']."'>".$data['personnel_name']."</a></span></b> | <b>".$data['personnel_branch']."</b> | <a href='".BASEDIR."messages.php?msg_send=".$data['personnel_userid']."'><b>".$locale['pe213']."</b></a><br /><b>".$locale['pe214']."</b> ".showdate("%d. %B %Y %H:%M", $data2['user_lastvisit'])."</td>";
                        }
                        echo "<td class='small' align='right'>";
                          if ($data['personnel_tlf'])
                          {echo "<img src='".INFUSIONS."personnel_list/images/tlf.png' style='border:0px;' title=\"header=[".$data['personnel_name']."] body=[<b>".$locale['pe210']."<br /><font color='#ff0000'>".$data['personnel_tlf']."</font></b>] delay=[0] fade=[off]\" alt='' border='0' />";}
                          if ($data['personnel_mobil'])
                          {echo "&nbsp;<img src='".INFUSIONS."personnel_list/images/mobil.png' style='border:0px;' title=\"header=[".$data['personnel_name']."] body=[<b>".$locale['pe211']."<br /><font color='#ff0000'>".$data['personnel_mobil']."</font></b>] delay=[0] fade=[off]\" alt='' border='0' />";}
                          if ($data['personnel_email'])
                          {echo "&nbsp;<a href='mailto:".$data['personnel_email']."'title=\"header=[".$data['personnel_name']."] body=[<b>Email:<br /><font color='#ff0000'>".$data['personnel_email']."</font></b>] delay=[0] fade=[off]\"><img src='".INFUSIONS."personnel_list/images/email.png' alt='' border='0' /></a>";}
                          if ($data['personnel_web'])
                          {echo "&nbsp;<a href='http://".$data['personnel_web']."' target='_blank' title=\"header=[".$data['personnel_name']."] body=[<b>Hjemmeside:<br /><font color='#ff0000'>".$data['personnel_web']."</font></b>] delay=[0] fade=[off]\"><img src='".INFUSIONS."personnel_list/images/web.png' alt='' border='0' /></a>";}
           echo "</td>
		            </tr>
                </table>
              </td>
              </tr>
              <tr>
                  <td class='tbl1' valign='top' width='".$locale['pe306']."' height='".$locale['pe307']."'>";
                    if ($data['personnel_photo']) {
                      echo "<img width='".$locale['pe306']."' height='".$locale['pe307']."' src='".IMAGES."personnels/".$data['personnel_photo']."'/>";
                    }
           echo "<div style='padding-top:8px;'><a href='http://*a?*' target='_blank'><img width='".$locale['pe306a']."' height='".$locale['pe307a']."' src='".INFUSIONS."personnel_list/images/logo.png' border='0' alt='' /></a></div>
		  </td>
                  <td class='tbl1' valign='top' width='100%'>
                    <table cellpadding='0' cellspacing='0' width='100%'>
                    <tr>
                       <td class='small'>".nl2br(parseubb(parsesmileys($data['personnel_autobiography'])))."</td>
                    </tr>
                    </table>
                  </td>
              </tr>";
   if (iADMIN) {
        echo "<tr>
                  <td class='tbl2' colspan='2' width='100%'>
                    <table cellpadding='0' cellspacing='0' width='100%'>
                    <tr>
                       <td align='right' class='small'>".$locale['pe201']."&nbsp;".$data['personnel_order']."&nbsp;";
                  echo" 
                       </td>
                    </tr>
                    </table>
                  </td>
              </tr>";
           }
      echo "</table>\n";
      if ($i != $numrows) echo "<br />\n";
		  $i++;
	}
} else {
	       echo "<center><br />\n".$locale['pe308']."<br /><br />\n";
         if (iADMIN) {
         echo "[ <a href='".INFUSIONS."personnel_list/personnel_list.php".$aidlink."&new_personnel=1'>".$locale['pe200']."</a> ] <br /><br />\n";
            }
          echo "</center>\n";
       }
closetable();

if ($rows != 0) echo "<div align='center' style='margin-top:5px;'>\n".makePageNav($_GET['rowstart'],10,$rows,3,FUSION_SELF."?")."\n</div>\n";

echo "<script>
function DeleteMessage()
{
	return confirm(\"".$locale['pe309']."\");
}
</script>\n";


require_once THEMES."templates/footer.php";
?>