<?php

function B_INVENTORY_DATE($COMMAND) {
global $thiss,$MENU_INIT,$ARG1,$ARG1_VAL,$result,$SQL_USER,$SQL_DATABASE,$INTERFACE_ADDR,$SQL_USER_PASS,$CURRENT_MENU;

 if($MENU_INIT==B_INVENTORY_DATE) {
 //$inventory->TELBOXES=test;
 require("icon/superedit-inventory.frm");

  $zapSQL="select T_TELBOX_NAME from TELBOXES where T_TELBOX_BUILDING_IN='".$_SESSION[BUILDINGS_COLUMN][EDITRECORD][S_ADDRESS_STREET]."' and A_ADM_COMPANY like '".$_SESSION[ADM_COMPANY]."%';"  ;
  $conn=mysql_pconnect($INTERFACE_ADDR,$SQL_USER,$SQL_USER_PASS);
  mysql_select_db($SQL_DATABASE) or die("ERROR podczas wyboru bazy R50!");
  $result = mysql_query($zapSQL,$conn) or die("Blad zapytania2!\n$zapSQL");
  $num_rows = mysql_num_rows($result); 
  if($num_rows > 0 ) {
   echo "<table  border=1 cellspacing=0 cellpadding=0 bordercolor=blue width=100%>";
    while ($h=mysql_fetch_row($result)) {
     BUILDING_SHOW_INVENTORY(T_TELBOX_NAME,$h[0]);
     if(!$TEMP_B_INVENTORY_DATE) { $TEMP_B_INVENTORY_DATE="and ( T_TELBOX_ADDRESS not like '$h[0]' "; 
      } else { $TEMP_B_INVENTORY_DATE=$TEMP_B_INVENTORY_DATE . " or T_TELBOX_ADDRESS not like '$h[0]'"; 
      }
    }
   echo "</table>";
    $TEMP_B_INVENTORY_DATE=$TEMP_B_INVENTORY_DATE . " )";
   }



    $zapSQL="select S_ADDRESS_STREET, A_STATUS from USERS2 where A_ADM_COMPANY like '".$_SESSION[ADM_COMPANY]."' $TEMP_B_INVENTORY_DATE and S_ADDRESS_STREET like '".$_SESSION[BUILDINGS_COLUMN][EDITRECORD][S_ADDRESS_STREET]."%' and T_NETWORK_SERVER='".$_SESSION[BUILDINGS_COLUMN][EDITRECORD][T_NETWORK_SERVER]."'";
    $result = mysql_query($zapSQL,$conn) or die("Blad zapytania2!\n$zapSQL");
    $num_rows = mysql_num_rows($result); 
    if($num_rows > 0) { echo "<b>UWAGA!</b> Podejrzani, nie przyporzadkowani do szafek abonenci:(<b>$num_rows</b>): ";   
     while ($h=mysql_fetch_row($result)) {
      echo "(<b>$h[0]</b> $h[1] [............] )  ";
     }
    }


  echo "<table width=100% border=1><tr><td>Odebral:<br>Data:.............................<br>Podpis:..........................<br></td><td>Wykonal:<br>Data:........................<br>Podpis:........................<br></td></tr></table>";




 } else if($COMMAND==VERIFY) {
 } else if($_SESSION[CURRENT_MENU]==$thiss->DETECT_EDIT_FUNCTION) {  
  GETFORMITEM($_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][B_INVENTORY_DATE],$_SESSION[$thiss->DETECT_TABLE_COLUMN][TYPE][B_INVENTORY_DATE],B_INVENTORY_DATE); 
  echo "(".$_SESSION[$thiss->DETECT_TABLE_COLUMN][EDITRECORD][B_INVENTORY_DATE].") ";
  echo "&nbsp; <a href='$PHP_SELF?MENU_INIT=B_INVENTORY_DATE' target='blank'><img src=icon/print.gif border=0 alt=DRUKUJ_INWENTARYZACJE></a> ";
 }
} //EOF function B_INVENTORY_DATE

