<?php
/*=======================================================================
 *
 * courier_msggroup_list.php
 *
 * Autor: Marc Vollmann
 *
 =======================================================================*/

include_once ("../include/mcglobal.inc.php");
include_once ("../include/auth.inc.php");
include_once ('../include/email/htmlMimeMail.php');


$triggerOut = "";

if ($hq_id != "" && is_numeric($hq_id)) :

   $sqlquery = "SELECT msggrp.msggrp_name, cr.cr_eid, usr.usr_name, usr.usr_firstname, cmp.cmp_id"
             . "  FROM messagegroup AS msggrp, courier AS cr, user AS usr, company AS cmp"
             . "  WHERE msggrp.hq_id = '" . $hq_id . "'          AND"
             . "        cr.cr_msggrp LIKE CONCAT('%,',msggrp.msggrp_id,',%') AND"
             . "        cr.hq_id = '" . $hq_id . "' AND"
             . "        cr.usr_id = usr.usr_id      AND"
             . "        cr.cmp_id = cmp.cmp_id      AND"
             . "        cmp.cmp_authenticated = '1' AND"
             . "        cmp.cmp_visible = '1'"
             . "  ORDER BY msggrp.msggrp_name, cr.cr_eid";

   $result = $db->query($sqlquery);   
   if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());

   $rowColor = "AAAAAA";
   $tableRows = "";
   while ($row = $result->fetch_assoc()):
         $tableRows .= "<tr>\n";
         $tableRows .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\">" . $row["msggrp_name"] . "</td>\n";
         $tableRows .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\"><a href=\"../admin/courier_special.php?companyId=" . $row["cmp_id"] . "\" target=\"_blank\">" . $row["cr_eid"] . "</a>&nbsp;&nbsp;&nbsp;</td>\n";
         $tableRows .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\">" . $row["usr_name"] . "</td>\n";
         $tableRows .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\">" . $row["usr_firstname"] . "</td>\n";
         $tableRows .= "</tr>\n";
   endwhile;
   $result->free();
                    
   $triggerOut .= "<table>\n";
   $triggerOut .= "<tr>\n";
   $triggerOut .= "<td class=\"f12bp1_blue\">" . getLngt("ÜBERSICHT ZUORDNUNGEN TRANSPORTEURE <=> NACHRICHTENGRUPPEN") . "</td>";
   $triggerOut .= "</tr>\n";
   $triggerOut .= "</table>\n";
   $triggerOut .= "<br><br>";

   $triggerOut .= "<table>\n";
   $triggerOut .= "<tr>\n";
   $triggerOut .= "<td style=\"text-align:center;\">" . getLngt("Nachrichtengruppe") . "&nbsp;&nbsp;&nbsp;</td>\n";
   $triggerOut .= "<td style=\"text-align:center;\">" . getLngt("EID") . "&nbsp;&nbsp;&nbsp;</td>\n";
   $triggerOut .= "<td style=\"text-align:center;\">" . getLngt("Nachname") . "&nbsp;&nbsp;&nbsp;</td>\n";
   $triggerOut .= "<td style=\"text-align:center;\">" . getLngt("Vorname") . "&nbsp;&nbsp;&nbsp;</td>\n";
   $triggerOut .= "</tr>\n";

   $triggerOut .= $tableRows;

   $triggerOut .= "</table>\n";      

endif;
?>

  <html>
  
  <head>
  <link rel="stylesheet" type="text/css" href="../css/phoenix.css">
  </head>
  	
  <body class="menu_bgcol" >
  
  <center>
  	
  <br><br><br>
  
  <b><?php echo $triggerOut ?></b>
  
  </center>
  
  </body>	
  	
  </html>

