
<?php

require_once("ajax_preload.php");

if ($httpreferer){
  if ($ajax_db->getErrorCode()==1){
    die;
  }else{

  $dolgozo=$_REQUEST["dolgozo"];
  $datum = substr($_REQUEST["datum"],0,10);
  $content_forgnaplo="";

  if (@checkdate(substr($datum,5,2),substr($datum,8,2),substr($datum,0,4)) and (substr($datum,4,1)=="-" and substr($datum,7,1)=="-")){

//
    $datum_from=$datum.' 00:00:00';
    $datum_to=$datum.' 23:59:59';

    $query = getForgnaplo($ajax_db,$dolgozo,$datum_from,$datum_to);
    $dolgozok = getDolgozok($ajax_db);

    $lista='';

    if ($query){
      foreach ($query as &$value) {
	if ($value["storno"]==1){
	  $bgcolor='background-color: #808080;';
	  $stornozott='<img width="16" height="16" alt="" src="'.$config->getValue("media_path","").'/cross.png" />';
	}else{
	  $stornozott='<a href="javascript:void(0);" onclick="getHiddenAjaxData(\''.$config->getValue("AjaxData","").'/set_stornogepnaplo.php\',\'gepnaplo_id='.$value["id_pg_gepnaplo"].'\',\'hiddenajaxdata\',\''.$config->getValue("loading_gif","").'\',runFromStornoGepnaplo(\'hiddenajaxdata\'));"><img width="16" height="16" alt="" src="'.$config->getValue("media_path","").'/ikon_minusz.png"></a>		  		  ';
	}

	if ($value["statusz"]!=1){
	  $bgcolor='background-color: #FF0000;';
	}else{
	  $bgcolor='';
	}

	if ($value["from_dolgozo"]==$dolgozo){
	  $irany=$config->getValue("get_forgnaplo","kiad");
	  $nev=iconv_iso88592_utf8($dolgozok[$value["to_dolgozo"]]);
	}else{
	  $irany=$config->getValue("get_forgnaplo","vissza");
	  $nev=iconv_iso88592_utf8($dolgozok[$value["from_dolgozo"]]);
	  if ($nev=="null"){
	    $nev='-';
	  }
	}
	$statusz=iconv_iso88592_utf8($value["megnevezes"]);
	$lista.='<tr>
		 <td valign="top" align="left" class="function_table_in" colspan="5" style="'.$bgcolor.'">
		    <table border="0" >
		    <tr>
		      <td class="td_medium"  align="left" valign="middle" style="width: 16px; ">
		      '.$stornozott.'
		      </td>
		      <td class="td_title"  align="left" valign="middle" style="width: 100px; ">
		      '.$value["gepszam"].'
		      </td>
		      <td class="td_medium" align="left" valign="top" style="width: 100px; ">
		      '.$irany.'
		      </td>
		      <td class="td_medium" align="left" valign="top" style="width: 300px;">
		      '.$nev.'
		      </td>
		      <td class="td_medium" align="left" valign="top"  style="width: 110px;">
		      '.$statusz.'
		      </td>
		      <td class="td_medium" align="right" valign="top" >
		      '.substr($value["datum"],-8).'
		      </td>
		    </tr>
		    </table>
		</td>
		</tr>
		';
      }
    }else{
      $lista='<tr>
	      <td valign="top" align="left" class="function_table_in td_medium" colspan="5">
	      '.$config->getValue("get_forgnaplo","nincsnaplo").'
	      </td>
	      </tr>';
    }
    $content_forgnaplo='<table border="0"align="center" valign="top" width="100%">
				      <tr>					
					<td class="td_medium" align="right" valign="top" colspan="5">
					'.date("Y-m-d H:i:s").'
					</td>
				      </tr>
				      <tr>
					<td class="td_medium" align="left" valign="middle" style="width: 100px;">
					'.$config->getValue("get_forgnaplo","gepszam").'
					</td>
					<td class="td_medium" align="left" valign="top" style="width: 100px;">
					'.$config->getValue("get_forgnaplo","atadatvesz").'
					</td>
					<td class="td_medium" align="left" valign="top" style="width: 300px;">
					'.$config->getValue("get_forgnaplo","nev").'
					</td>
					<td class="td_medium" align="left" valign="top" style="width: 100px;">
					'.$config->getValue("get_forgnaplo","statusz").'
					</td>
					<td class="td_medium" align="left" valign="top" style="width: 70px;">
					'.$config->getValue("get_forgnaplo","ido").'
					</td>
				      </tr>
				      <tr>
				      </tr>
				      '.$lista.'
				     </table>';
//


  }else{
    $content_forgnaplo=$config->getValue("datumhiba","");
  }

    $dolgozo_query=getOneDolg($ajax_db,$dolgozo);

    $ajax_page->setTag("content_datum", $datum);
    $ajax_page->setTag("content_title", iconv_iso88592_utf8($dolgozo_query["nev"])." ".$config->getValue("get_forgnaplo","title"));
    $ajax_page->setTag("content_forgnaplo", $content_forgnaplo);
    $ajax_page->AppendTag("content", $ajax_page->getAppropriateTemplate($config->getValue("templates_path","")."/get_forgnaplo.tmpl.php"));
    
    $ajax_page->out();

  }
}
?>
