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

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

/*
getLanguage(__FILE__);
$deactivateMenuStatic = "1";
$pageTitel = getLngt("Vorort-Prüfungen");
include_once ("../admin/menu.php");
include_once ("../include/html.inc.php");
include_once ("../include/inc_filters.inc.php");
include_once ("../include/inc_vehicle.inc.php");
include_once ("../include/inc_group.inc.php");
getCurrentScript(__FILE__);
*/

// Check for authentication access and granted rights
// $usrAccessArray["hq"] = "1";
// authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
// authCheckEmployeeRights($emp_id, "1", "1");

// $currentDate = getDateTime("1");
// $currentDateTime = getDateTime("6");


if (true) :
   $rowColor = "AAAAAA";

   // "Vorort-Prüfung Kundenberichte", Kategorie = mtfc_id = 102
   $sqlquery = "SELECT cmp.cmp_id, cmp.cmp_comp, cmp.cmp_comp2, cmp.cmp_comp4, cs.cs_eid, crvh.crvh_id, crvh.crvh_sid, crvh.crvh_service"
             . "  FROM customervehicle AS csvh, customer AS cs, company AS cmp, couriervehicle AS crvh"
             . " WHERE csvh.cs_id = cs.cs_id AND"
             . "       cs.cmp_id = cmp.cmp_id AND"
             . "       csvh.crvh_id = crvh.crvh_id"
             . " ORDER BY cs.cs_eid, crvh.crvh_sid";

   $result = $db->query($sqlquery);   
   if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
   $tableRows = "";
   while ($row = $result->fetch_assoc()):
         $srvArr = array();
         $srv = $row["crvh_service"];
         if (((int)$srv & 1) == 1) :
            $srvArr[] = "Lieferung";
         endif;
         if (((int)$srv & 6) == 6) :
            $srvArr[] = "Kran";
         endif;
         $srvTxt = implode(",", $srvArr);

         $tableRows .= "<tr>\n";
         $tableRows .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\"><a href=\"../admin/customer_special.php?companyId=" . $row["cmp_id"] . "\" target=\"_blank\">" . $row["cmp_comp"] . "</a>&nbsp;&nbsp;&nbsp;</td>\n";
         $tableRows .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\"><a href=\"../admin/customer_special.php?companyId=" . $row["cmp_id"] . "\" target=\"_blank\">" . $row["cmp_comp2"] . "</a>&nbsp;&nbsp;&nbsp;</td>\n";
         $tableRows .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\"><a href=\"../admin/customer_special.php?companyId=" . $row["cmp_id"] . "\" target=\"_blank\">" . $row["cmp_comp4"] . "</a>&nbsp;&nbsp;&nbsp;</td>\n";
         $tableRows .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\"><a href=\"../admin/customer_special.php?companyId=" . $row["cmp_id"] . "\" target=\"_blank\">" . $row["cs_eid"] . "</a>&nbsp;&nbsp;&nbsp;</td>\n";
         $tableRows .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\"><a href=\"../admin/courier_vehicle.php?f_crvh_id=" . $row["crvh_id"] . "\" target=\"_blank\">" . $row["crvh_sid"] . "</a>&nbsp;&nbsp;&nbsp;</td>\n";
         $tableRows .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\">" . $srvTxt . "</td>\n";
         $tableRows .= "</tr>\n";
   endwhile;
   $result->free();
                    
   $triggerOut .= "<table>\n";
   $triggerOut .= "<tr>\n";
   $triggerOut .= "<td class=\"f12bp1_blue\">" . getLngt("ÜBERSICHT KUNDEN-FAHRZEUG-BEZIEHUNGEN") . "</td>";
   $triggerOut .= "</tr>\n";
   $triggerOut .= "</table>\n";
   $triggerOut .= "<br><br>";

   $triggerOut .= "<table>\n";
   $triggerOut .= "<tr>\n";
   $triggerOut .= "<td style=\"text-align:center;\">" . getLngt("Systemkunde") . "&nbsp;&nbsp;&nbsp;</td>\n";
   $triggerOut .= "<td style=\"text-align:center;\">" . "" . "&nbsp;&nbsp;&nbsp;</td>\n";
   $triggerOut .= "<td style=\"text-align:center;\">" . "" . "&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("SID") . "&nbsp;&nbsp;&nbsp;</td>\n";
   $triggerOut .= "<td style=\"text-align:center;\">" . getLngt("Service") . "&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>

