<?php session_start(); ?>
<?php ERROR_REPORTING(0); ?>

<?php

if (!empty($_POST["luna_sel_prez"]))
{
	$_SESSION["luna_sel"]=substr($_POST["luna_sel"],0,2);
}

if (isset($_POST["aplic"]) and isset($_POST["unit"]))
{
	$_SESSION["aplic"]=$_POST["aplic"];
	$_SESSION["unit"]=$_POST["unit"];
}

$luna_sel = $_SESSION["luna_sel"];

include 'conectare.php';

	$connection=mysql_connect("$host","$username","$password") or die("Nu aveti acces la server");
	$baza="apponlin_".$_SESSION["aplic"]."_".$_SESSION["unit"];
	$db=mysql_select_db($baza,$connection) or die("Nu puteti selecta Baza de date ".$baza);	

mysql_query("SET NAMES 'utf8'");
	
// include and create object
	include("inc/jqgrid_dist.php");

	$col = array();
	$col["title"] = "Id"; // caption of column
	$col["name"] = "id";
	$col["width"] = "1";
	$col["editable"] = false;  // this column is not editable
	$col["align"] = "right";
	$col["search"] = false; // this column is not searchable
	$col["hidden"] = true; // hide column by default
	$cols[] = $col;	

	$col = array();
	$col["title"] = "Codgrp"; // caption of column
	$col["name"] = "codgrp";
	$col["width"] = "2";
	$col["editable"] = false;  // this column is not editable
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$col["hidden"] = false; // hide column by default
	$cols[] = $col;	

	$col = array();
	$col["title"] = "Luna"; // caption of column
	$col["name"] = "luna";
	$col["width"] = "1";
	$col["editable"] = false;  // this column is not editable
	$col["align"] = "center";
	$col["search"] = false; // this column is not searchable
	$col["hidden"] = true; // hide column by default
	$cols[] = $col;	
	
	$col = array();
	$col["title"] = "Grupa";
	$col["name"] = "dengrp";
	$col["width"] = "5";
	$col["editable"] = false; // this column is editable
	$col["align"] = "left";
	$col["search"] = true; // this column is searchable
	$cols[] = $col;

	$wluna=substr($_POST["luna_sel"],0,2);
	$wanc=date('Y');
	$wz=date('N',strtotime("01-".$wluna."-".$wanc));
	$ws="LMMJVSDLMMJVSDLMMJVSDLMMJVSDLMMJVSDLMMJVSDLMMJVSDLMMJVSD";
	$wlit=substr($ws,$wz-1,1);
	
	$wlit1 = $wlit;
	$col = array();
	$col["title"] = $wlit."01";
	$col["name"] = "z_01";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
//	$col["editoptions"] = array("value"=>' : ;'.$wvar1.':'.$wvar2); 
//	$col["editoptions"] = array("value"=>$wvar2); 	
	$col["editoptions"] = array("value"=>' : ;P:P');

	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz,1);
	$wlit2 = $wlit;
	$col = array();
	$col["title"] = $wlit."02";
	$col["name"] = "z_02";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P');  	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+1,1);
	$wlit3 = $wlit;
	$col = array();
	$col["title"] = $wlit."03";
	$col["name"] = "z_03";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+2,1);
	$wlit4 = $wlit;
	$col = array();
	$col["title"] = $wlit."04";
	$col["name"] = "z_04";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+3,1);
	$wlit5 = $wlit;
	$col = array();
	$col["title"] = $wlit."05";
	$col["name"] = "z_05";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+4,1);
	$wlit6 = $wlit;
	$col = array();
	$col["title"] = $wlit."06";
	$col["name"] = "z_06";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+5,1);
	$wlit7 = $wlit;
	$col = array();
	$col["title"] = $wlit."07";
	$col["name"] = "z_07";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+6,1);
	$wlit8 = $wlit;
	$col = array();
	$col["title"] = $wlit."08";
	$col["name"] = "z_08";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+7,1);
	$wlit9 = $wlit;
	$col = array();
	$col["title"] = $wlit."09";
	$col["name"] = "z_09";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+8,1);
	$wlit10 = $wlit;
	$col = array();
	$col["title"] = $wlit."10";
	$col["name"] = "z_10";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+9,1);
	$wlit11 = $wlit;
	$col = array();
	$col["title"] = $wlit."11";
	$col["name"] = "z_11";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+10,1);
	$wlit12 = $wlit;
	$col = array();
	$col["title"] = $wlit."12";
	$col["name"] = "z_12";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+11,1);
	$wlit13 = $wlit;
	$col = array();
	$col["title"] = $wlit."13";
	$col["name"] = "z_13";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+12,1);
	$wlit14 = $wlit;
	$col = array();
	$col["title"] = $wlit."14";
	$col["name"] = "z_14";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;	

	$wlit=substr($ws,$wz+13,1);
	$wlit15 = $wlit;
	$col = array();
	$col["title"] = $wlit."15";
	$col["name"] = "z_15";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+14,1);
	$wlit16 = $wlit;
	$col = array();
	$col["title"] = $wlit."16";
	$col["name"] = "z_16";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+15,1);
	$wlit17 = $wlit;
	$col = array();
	$col["title"] = $wlit."17";
	$col["name"] = "z_17";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+16,1);
	$wlit18 = $wlit;
	$col = array();
	$col["title"] = $wlit."18";
	$col["name"] = "z_18";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+17,1);
	$wlit19 = $wlit;
	$col = array();
	$col["title"] = $wlit."19";
	$col["name"] = "z_19";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+18,1);
	$wlit20 = $wlit;
	$col = array();
	$col["title"] = $wlit."20";
	$col["name"] = "z_20";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+19,1);
	$wlit21 = $wlit;
	$col = array();
	$col["title"] = $wlit."21";
	$col["name"] = "z_21";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+20,1);
	$wlit22 = $wlit;
	$col = array();
	$col["title"] = $wlit."22";
	$col["name"] = "z_22";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+21,1);
	$wlit23 = $wlit;
	$col = array();
	$col["title"] = $wlit."23";
	$col["name"] = "z_23";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+22,1);
	$wlit24 = $wlit;
	$col = array();
	$col["title"] = $wlit."24";
	$col["name"] = "z_24";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+23,1);
	$wlit25 = $wlit;
	$col = array();
	$col["title"] = $wlit."25";
	$col["name"] = "z_25";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+24,1);
	$wlit26 = $wlit;
	$col = array();
	$col["title"] = $wlit."26";
	$col["name"] = "z_26";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;	

	$wlit=substr($ws,$wz+25,1);
	$wlit27 = $wlit;
	$col = array();
	$col["title"] = $wlit."27";
	$col["name"] = "z_27";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+26,1);
	$wlit28 = $wlit;
	$col = array();
	$col["title"] = $wlit."28";
	$col["name"] = "z_28";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
	$cols[] = $col;

	$wlit=substr($ws,$wz+27,1);
	$wlit29 = $wlit;
	$col = array();
	$col["title"] = $wlit."29";
	$col["name"] = "z_29";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
$wanc=date('Y');
if (substr($_SESSION["luna_sel"],0,2)=="02" and $wanc<>"2016" and $wanc<>"2020" and $wanc<>"2024" and $wanc<>"2028" and $wanc<>"2032")
{
  	$col["hidden"] = true;
}
else
{
	$col["hidden"] = false;
}
	$cols[] = $col;

	$wlit=substr($ws,$wz+28,1);
	$wlit30 = $wlit;
	$col = array();
	$col["title"] = $wlit."30";
	$col["name"] = "z_30";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
if (substr($_SESSION["luna_sel"],0,2)=="02")
{
  	$col["hidden"] = true;
}
else
{
	$col["hidden"] = false;
}
	$cols[] = $col;

	
	$wlit=substr($ws,$wz+29,1);
	$wlit31 = $wlit;
	$col = array();
	$col["title"] = $wlit."31";
	$col["name"] = "z_31";
	$col["width"] = "1";
	$col["editable"] = true; // this column is not editable
	$col["edittype"] = "select";
	$col["editoptions"] = array("value"=>' : ;P:P'); 	
	$col["align"] = "center";
	$col["search"] = true; // this column is not searchable
if (substr($_SESSION["luna_sel"],0,2)=="02" or substr($_SESSION["luna_sel"],0,2)=="04" or substr($_SESSION["luna_sel"],0,2)=="06" or substr($_SESSION["luna_sel"],0,2)=="09" or substr($_SESSION["luna_sel"],0,2)=="11")
{
  	$col["hidden"] = true;
}
else
{
	$col["hidden"] = false;
}
	$cols[] = $col;

	$col = array();
	$col["title"] = "Total P";
	$col["name"] = "z_tot";
	$col["width"] = "1";
	$col["align"] = "center"; // this column is not editable
	$col["hidden"] = false;
	$cols[] = $col;
	
	$col = array();
	$col["title"] = "  ";
	$col["width"] = "1";
	$col["align"] = "CENTER"; // this column is not editable
	$col["hidden"] = false;
	$col["search"] = false; 
	$cols[] = $col;	
	
	$g = new jqgrid();

// set few params
// $grid["url"] = ""; // your paramterized URL -- defaults to REQUEST_URI
	$grid["rowNum"] = 30;
	$grid["sortname"] = 'codgrp'; // by default sort grid by this field
	$grid["sortorder"] = "asc"; // ASC or DESC
	$grid["caption"] = "Prezenta"; // caption of grid
	$grid["autowidth"] = true; // expand grid to screen width
	$grid["height"] = "70%";
	$grid["multiselect"] = false; // allow you to multi-select through checkboxes	
//	$grid["altRows"] = true; // Set a zebra-striped grid, boolean
//	$grid["altclass"] = "myAltRowClass"; 
	
//$grid["add_options"] = array('width'=>'450',    
                            //"closeAfterEdit"=>true, // close dialog after add/edit
                          //  "top"=>"250", // absolute top position of dialog
                            //"left"=>"400" // absolute left position of dialog
                          //  );

//	$grid["edit_options"] = array('width'=>'200',    
                           // "closeAfterEdit"=>true, // close dialog after add/edit
                           // "top"=>"140", // absolute top position of dialog
                           // "left"=>"550" // absolute left position of dialog
                           // );
//	$grid["delete_options"] = array('width'=>'450',    
//                            "closeAfterEdit"=>true, // close dialog after add/edit
//                            "top"=>"250", // absolute top position of dialog
//                            "left"=>"400" // absolute left position of dialog
//                            );
						
//	$grid["export"] = array("format"=>"xlsx", "filename"=>"my-file", "sheetname"=>"test"); // only in Premium Version

	$g->set_options($grid);

	$g->set_actions(array(	
						"add"=>false, // allow/disallow add
						"edit"=>false, // allow/disallow edit
						"delete"=>false, // allow/disallow delete
						"rowactions"=>false, // show/hide row wise edit/del/save option
//						"export"=>true, // show/hide export to excel option
						"autofilter" => true, // show/hide autofilter for search
						"search" => "advance" // show single/multi field search condition (e.g. simple or advance)
					) 
				);
							
// you can provide custom SQL query to display data

	$g->select_command = "select * from prezenta_grp_man";
					
// set database table for CRUD operations
	$g->table = "prezenta_grp_man";
	
	$g->set_columns($cols);			
			
// render grid
	$out = $g->render("list1");

	$themes = array("redmond","smoothness","start","dot-luv","excite-bike","flick","ui-darkness","cupertino","dark-hive","ui-lightness");
	$i = rand(0,8);


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
		<link rel="stylesheet" type="text/css" media="screen" href="js/themes/start/jquery-ui.custom.css"></link>		
		<link rel="stylesheet" type="text/css" media="screen" href="js/jqgrid/css/ui.jqgrid.css"></link>	
		<link rel="stylesheet" type="text/css" href="A21_stiluri1.css"> 
	
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	
	<script src="js/jquery.min.js" type="text/javascript"></script>
	<script src="js/jqgrid/js/i18n/grid.locale-ro.js" type="text/javascript"></script>
	<script src="js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>	
	<script src="js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>

<TITLE>Prezenta grupe</TITLE>

<script language="JavaScript" type="text/javascript">

var w1;
function target_popup1(form) {
		w1=window.open('', 'win01', '');
		form.target = 'win01';
}

var w3;
function target_popup3(form) {
		w3=window.open('', 'win03','width=650,height=350,top=300,left=300,toolbar=no, location=no,status=no,menubar=no,scrollbars=no,resizable=no');
			form.target = 'win03';
}
</script>

</HEAD>
<BODY>

<?php
ob_start();
include 'javascripts.php';
include 'conectare.php';

	$wan2 = $_POST["an"]+1;

	echo "<CENTER>";
	echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
	echo "<tr>";
	echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
	echo "</tr>";
	echo "<TR BGCOLOR=\"#4EAEF2\">";
	echo "<TD colspan=\"11\" class=\"style1\" height=\"25\" align=\"center\">";
	echo "<B> ".$_POST["den_aplic"]."</B>";
	echo "</TD>";
	echo "</TR>";
	echo "<tr>";
	echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
	echo "</tr>";
	echo "<TR BGCOLOR=\"#A3D9FF\">";
	echo "<TD width=\"250\" class=\"style1\" colspan=\"2\" height=\"25\" align=\"left\"><B>Unitatea: &nbsp".$_POST["denunit"]."</B>";
	echo "</TD>";
	echo "<TD width=\"160\" class=\"style1\"  height=\"25\" align=\"left\"><B>An scolar: ".$_POST["an"]." - ".$wan2."</B>";
	echo "</TD>";
	echo "</td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
	echo "</tr>";
	echo "</table>";
	
	echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
	echo "<tr>";
	echo "<td colspan=\"20\" height=\"1px\"></td>";
	echo "</tr>";
	echo "</table>";
	
	$connection=mysql_connect("$host","$username","$password") or die("Nu aveti acces la server");
	$baza="apponlin_".$_POST["aplic"]."_".$_POST["unit"];
	$db=mysql_select_db($baza,$connection) or die("Nu puteti selecta Baza de date ".$baza);		
	
	echo "<FORM NAME=\"form\" ACTION=\"A21_copii.php\" METHOD=\"POST\" onsubmit=\"target_popup3(this)\">";
	include 'A21_param1.php';
	
	$wdenluna_sel=substr($_POST["luna_sel_prez"],3,strlen($_POST["luna_sel_prez"])-3);
	
	echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";				
	echo "<TR>";
	echo "<TD align=\"center\" class=\"td_print2\">";	
	echo "<B>PREZENTA PRESCOLARI PE GRUPE</B>";
	echo "<BR>";
	echo "</TD>";
	echo "</TR>";
	echo "</TABLE>";
	echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"50%\" border=0>";
	echo "<TR>";
	echo "<TD align=\"center\" class=\"td_print2\">";
	echo "<B>LUNA:&nbsp<U>".$wdenluna_sel."</U></B>";
	echo "<BR>";
	echo "</TD>";
	echo "</TR>";
	echo "</TABLE>";
	echo "</FORM>";
	
	
	echo "<FORM NAME=\"form\" ACTION=\"A21_copii.php\" METHOD=\"POST\">";
	include 'A21_param1.php';

	echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"30%\" align=\"right\" border=0>";	
	echo "<TR>";		
	echo "<TD colspan=\"1\" height=\"35\" align=\"right\">";
	echo "<input type=\"submit\" class=\"noPrint\" name=\"actiune\" value=\"INAPOI\">";
	echo "</TD>";
	echo "</TR>";
	echo "</TABLE>";
	echo "</FORM>";
	
	$wluna=substr($_POST["luna_sel_prez"],0,2);
	$wanc=date('Y');
	$wz=date('N',strtotime("01-".$wluna."-".$wanc));
	$ws="LMMJVSDLMMJVSDLMMJVSDLMMJVSDLMMJVSDLMMJVSDLMMJVSDLMMJVSD";
	
	$wlit1=substr($ws,$wz-1,1);
	$wlit2=substr($ws,$wz,1);	
	$wlit3=substr($ws,$wz+1,1);
	$wlit4=substr($ws,$wz+2,1);	
	$wlit5=substr($ws,$wz+3,1);		
	$wlit6=substr($ws,$wz+4,1);	
	$wlit7=substr($ws,$wz+5,1);		
	$wlit8=substr($ws,$wz+6,1);		
	$wlit9=substr($ws,$wz+7,1);		
	$wlit10=substr($ws,$wz+8,1);	
	$wlit11=substr($ws,$wz+9,1);		
	$wlit12=substr($ws,$wz+10,1);	
	$wlit13=substr($ws,$wz+11,1);	
	$wlit14=substr($ws,$wz+12,1);	
	$wlit15=substr($ws,$wz+13,1);	
	$wlit16=substr($ws,$wz+14,1);	
	$wlit17=substr($ws,$wz+15,1);	
	$wlit18=substr($ws,$wz+16,1);	
	$wlit19=substr($ws,$wz+17,1);	
	$wlit20=substr($ws,$wz+18,1);	
	$wlit21=substr($ws,$wz+19,1);	
	$wlit22=substr($ws,$wz+20,1);	
	$wlit23=substr($ws,$wz+21,1);	
	$wlit24=substr($ws,$wz+22,1);	
	$wlit25=substr($ws,$wz+23,1);	
	$wlit26=substr($ws,$wz+24,1);	
	$wlit27=substr($ws,$wz+25,1);	
	$wlit28=substr($ws,$wz+26,1);	
	$wlit29=substr($ws,$wz+27,1);	
	$wlit30=substr($ws,$wz+28,1);	
	$wlit31=substr($ws,$wz+29,1);	
	
	$z_tot = '';
	
	for ($i=1;$i<=31;$i++)
	{
		//$wz[$i]='p';
		$wz[$i]='';
	}
	
	$w_z_val01_tot = 0;
	$w_z_val02_tot = 0;
	$w_z_val03_tot = 0;
	$w_z_val04_tot = 0;
	$w_z_val05_tot = 0;
	$w_z_val06_tot = 0;
	$w_z_val07_tot = 0;
	$w_z_val08_tot = 0;
	$w_z_val09_tot = 0;
	$w_z_val10_tot = 0;
	$w_z_val11_tot = 0;
	$w_z_val12_tot = 0;

	$query0="DELETE FROM prezenta_grp_man";
	$result0=mysql_query($query0) or die("Interogare esuata: ".mysql_error());

	$query="SELECT codgrp,dengrp FROM grupe order by codgrp";
	$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());	
	
	while($row=mysql_fetch_array($result))
	{
		$codgrp_arr[] = $row["codgrp"];
		$dengrp_arr[] = $row["dengrp"];
	}
	
	$count_grp = count($codgrp_arr);
	
	for ($n=0;$n<$count_grp;$n++)
	{		
		$w_z_val01 = 0;
		$w_z_val02 = 0;
		$w_z_val03 = 0;
		$w_z_val04 = 0;
		$w_z_val05 = 0;
		$w_z_val06 = 0;
		$w_z_val07 = 0;
		$w_z_val08 = 0;
		$w_z_val09 = 0;
		$w_z_val10 = 0;
		$w_z_val11 = 0;
		$w_z_val12 = 0;
		$w_z_val13 = 0;
		$w_z_val14 = 0;
		$w_z_val15 = 0;	
		$w_z_val16 = 0;
		$w_z_val17 = 0;
		$w_z_val18 = 0;	
		$w_z_val19 = 0;
		$w_z_val20 = 0;
		$w_z_val21 = 0;
		$w_z_val22 = 0;
		$w_z_val23 = 0;
		$w_z_val24 = 0;
		$w_z_val25 = 0;	
		$w_z_val26 = 0;
		$w_z_val27 = 0;
		$w_z_val28 = 0;	
		$w_z_val29 = 0;	
		$w_z_val30 = 0;	
		$w_z_val31 = 0;			
		$w_z_val_tot = 0;

		$query1="SELECT * FROM prezenta WHERE luna=\"".$wluna."\" AND codgrp = \"".$codgrp_arr[$n]."\" order by codcopil";
		$result1=mysql_query($query1) or die("Interogare esuata: ".mysql_error());

		while($row1=mysql_fetch_array($result1))
		{
			$w_z_val01 = $w_z_val01.'_'.$row1["z_01"];
			$w_z_val02 = $w_z_val02.'_'.$row1["z_02"];
			$w_z_val03 = $w_z_val03.'_'.$row1["z_03"];
			$w_z_val04 = $w_z_val04.'_'.$row1["z_04"];
			$w_z_val05 = $w_z_val05.'_'.$row1["z_05"];
			$w_z_val06 = $w_z_val06.'_'.$row1["z_06"];
			$w_z_val07 = $w_z_val07.'_'.$row1["z_07"];
			$w_z_val08 = $w_z_val08.'_'.$row1["z_08"];
			$w_z_val09 = $w_z_val09.'_'.$row1["z_09"];
			$w_z_val10 = $w_z_val10.'_'.$row1["z_10"];
			$w_z_val11 = $w_z_val11.'_'.$row1["z_11"];
			$w_z_val12 = $w_z_val12.'_'.$row1["z_12"];
			$w_z_val13 = $w_z_val13.'_'.$row1["z_13"];
			$w_z_val14 = $w_z_val14.'_'.$row1["z_14"];
			$w_z_val15 = $w_z_val15.'_'.$row1["z_15"];
			$w_z_val16 = $w_z_val16.'_'.$row1["z_16"];
			$w_z_val17 = $w_z_val17.'_'.$row1["z_17"];
			$w_z_val18 = $w_z_val18.'_'.$row1["z_18"];
			$w_z_val19 = $w_z_val19.'_'.$row1["z_19"];
			$w_z_val20 = $w_z_val20.'_'.$row1["z_20"];
			$w_z_val21 = $w_z_val21.'_'.$row1["z_21"];
			$w_z_val22 = $w_z_val22.'_'.$row1["z_22"];
			$w_z_val23 = $w_z_val23.'_'.$row1["z_23"];
			$w_z_val24 = $w_z_val24.'_'.$row1["z_24"];
			$w_z_val25 = $w_z_val25.'_'.$row1["z_25"];
			$w_z_val26 = $w_z_val26.'_'.$row1["z_26"];
			$w_z_val27 = $w_z_val27.'_'.$row1["z_27"];
			$w_z_val28 = $w_z_val28.'_'.$row1["z_28"];
			$w_z_val29 = $w_z_val29.'_'.$row1["z_29"];	
			$w_z_val30 = $w_z_val30.'_'.$row1["z_30"];
			$w_z_val31 = $w_z_val31.'_'.$row1["z_31"];						
		}

		$w_z_val01_p = substr_count($w_z_val01,'P');
		$w_z_val02_p = substr_count($w_z_val02,'P');
		$w_z_val03_p = substr_count($w_z_val03,'P');
		$w_z_val04_p = substr_count($w_z_val04,'P');
		$w_z_val05_p = substr_count($w_z_val05,'P');
		$w_z_val06_p = substr_count($w_z_val06,'P');
		$w_z_val07_p = substr_count($w_z_val07,'P');
		$w_z_val08_p = substr_count($w_z_val08,'P');
		$w_z_val09_p = substr_count($w_z_val09,'P');
		$w_z_val10_p = substr_count($w_z_val10,'P');
		$w_z_val11_p = substr_count($w_z_val11,'P');
		$w_z_val12_p = substr_count($w_z_val12,'P');
		$w_z_val13_p = substr_count($w_z_val13,'P');
		$w_z_val14_p = substr_count($w_z_val14,'P');
		$w_z_val15_p = substr_count($w_z_val15,'P');
		$w_z_val16_p = substr_count($w_z_val16,'P');
		$w_z_val17_p = substr_count($w_z_val17,'P');
		$w_z_val18_p = substr_count($w_z_val18,'P');
		$w_z_val19_p = substr_count($w_z_val19,'P');
		$w_z_val20_p = substr_count($w_z_val20,'P');
		$w_z_val21_p = substr_count($w_z_val21,'P');
		$w_z_val22_p = substr_count($w_z_val22,'P');
		$w_z_val23_p = substr_count($w_z_val23,'P');
		$w_z_val24_p = substr_count($w_z_val24,'P');
		$w_z_val25_p = substr_count($w_z_val25,'P');
		$w_z_val26_p = substr_count($w_z_val26,'P');
		$w_z_val27_p = substr_count($w_z_val27,'P');
		$w_z_val28_p = substr_count($w_z_val28,'P');
		$w_z_val29_p = substr_count($w_z_val29,'P');
		$w_z_val30_p = substr_count($w_z_val30,'P');
		$w_z_val31_p = substr_count($w_z_val31,'P');
		
		
		$w_z_val_tot = $w_z_val01_p + $w_z_val02_p + $w_z_val03_p + $w_z_val04_p + $w_z_val05_p + $w_z_val06_p + $w_z_val07_p + $w_z_val08_p + $w_z_val09_p + $w_z_val10_p + $w_z_val11_p + $w_z_val12_p + $w_z_val13_p + $w_z_val14_p + $w_z_val15_p + $w_z_val16_p + $w_z_val17_p + $w_z_val18_p + $w_z_val19_p + $w_z_val20_p + $w_z_val21_p + $w_z_val22_p + $w_z_val23_p + $w_z_val24_p + $w_z_val25_p + $w_z_val26_p + $w_z_val27_p + $w_z_val28_p + $w_z_val29_p + $w_z_val30_p + $w_z_val31_p;		
		
		$query2="INSERT INTO prezenta_grp_man (codgrp, dengrp, luna, an, z_01, z_02, z_03, z_04, z_05, z_06, z_07, z_08, z_09, z_10, z_11, z_12, z_13, z_14, z_15, z_16, z_17,z_18,z_19,z_20,z_21,z_22,z_23,z_24,z_25,z_26,z_27,z_28,z_29,z_30,z_31,z_tot) ";
		$query2=$query2."VALUES (\"".$codgrp_arr[$n]."\",\"".$dengrp_arr[$n]."\",\"".$wluna."\",\"".$wanc."\",\"".$w_z_val01_p."\",\"".$w_z_val02_p."\",\"".$w_z_val03_p."\",\"".$w_z_val04_p."\",\"".$w_z_val05_p."\",\"".$w_z_val06_p."\",\"".$w_z_val07_p."\",\"".$w_z_val08_p."\",\"".$w_z_val09_p."\",\"".$w_z_val10_p."\",\"".$w_z_val11_p."\",\"".$w_z_val12_p."\",\"".$w_z_val13_p."\",\"".$w_z_val14_p."\",\"".$w_z_val15_p."\",\"".$w_z_val16_p."\",\"".$w_z_val17_p."\",\"".$w_z_val18_p."\",\"".$w_z_val19_p."\",\"".$w_z_val20_p."\",\"".$w_z_val21_p."\",\"".$w_z_val22_p."\",\"".$w_z_val23_p."\",\"".$w_z_val24_p."\",\"".$w_z_val25_p."\",\"".$w_z_val26_p."\",\"".$w_z_val27_p."\",\"".$w_z_val28_p."\",\"".$w_z_val29_p."\",\"".$w_z_val30_p."\",\"".$w_z_val31_p."\",\"".$w_z_val_tot."\")";
		$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());		
	}

	$query3="SELECT SUM(z_01) as z_01, SUM(z_02) as z_02, SUM(z_03) as z_03, SUM(z_04) as z_04, SUM(z_05) as z_05, SUM(z_06) as z_06, SUM(z_07) as z_07, SUM(z_08) as z_08, SUM(z_09) as z_09, SUM(z_10) as z_10, SUM(z_11) as z_11, SUM(z_12) as z_12, SUM(z_13) as z_13, SUM(z_14) as z_14, SUM(z_15) as z_15, SUM(z_16) as z_16, SUM(z_17) as z_17, SUM(z_18) as z_18, SUM(z_19) as z_19, SUM(z_20) as z_20, SUM(z_21) as z_21, SUM(z_22) as z_22, SUM(z_23) as z_23, SUM(z_24) as z_24, SUM(z_25) as z_25, SUM(z_26) as z_26, SUM(z_27) as z_27, SUM(z_28) as z_28, SUM(z_29) as z_29, SUM(z_30) as z_30, SUM(z_31) as z_31 FROM prezenta_grp_man order by codgrp";
	$result3=mysql_query($query3) or die("Interogare esuata: ".mysql_error());
	$row3=mysql_fetch_array($result3);
	
	$w_z_val_tot_grp = $row3["z_01"] + $row3["z_02"] + $row3["z_03"] + $row3["z_04"] + $row3["z_05"] + $row3["z_06"] + $row3["z_07"] + $row3["z_08"] + $row3["z_09"] + $row3["z_10"] + $row3["z_11"] + $row3["z_12"] + $row3["z_13"] + $row3["z_14"] + $row3["z_15"] + $row3["z_16"] + $row3["z_17"] + $row3["z_18"] + $row3["z_19"] + $row3["z_20"] + $row3["z_21"] + $row3["z_22"] + $row3["z_23"] + $row3["z_24"] + $row3["z_25"] + $row3["z_26"] + $row3["z_27"] + $row3["z_28"] + $row3["z_29"] + $row3["z_30"] + $row3["z_31"];
	
	$query4="INSERT INTO prezenta_grp_man (codgrp, dengrp, luna, an, z_01, z_02, z_03, z_04, z_05, z_06, z_07, z_08, z_09, z_10, z_11, z_12, z_13, z_14, z_15, z_16, z_17,z_18,z_19,z_20,z_21,z_22,z_23,z_24,z_25,z_26,z_27,z_28,z_29,z_30,z_31,z_tot) ";
	$query4=$query4."VALUES ('99','TOTAL',\"".$wluna."\",\"".$wanc."\",\"".$row3["z_01"]."\",\"".$row3["z_02"]."\",\"".$row3["z_03"]."\",\"".$row3["z_04"]."\",\"".$row3["z_05"]."\",\"".$row3["z_06"]."\",\"".$row3["z_07"]."\",\"".$row3["z_08"]."\",\"".$row3["z_09"]."\",\"".$row3["z_10"]."\",\"".$row3["z_11"]."\",\"".$row3["z_12"]."\",\"".$row3["z_13"]."\",\"".$row3["z_14"]."\",\"".$row3["z_15"]."\",\"".$row3["z_16"]."\",\"".$row3["z_17"]."\",\"".$row3["z_18"]."\",\"".$row3["z_19"]."\",\"".$row3["z_20"]."\",\"".$row3["z_21"]."\",\"".$row3["z_22"]."\",\"".$row3["z_23"]."\",\"".$row3["z_24"]."\",\"".$row3["z_25"]."\",\"".$row3["z_26"]."\",\"".$row3["z_27"]."\",\"".$row3["z_28"]."\",\"".$row3["z_29"]."\",\"".$row3["z_30"]."\",\"".$row3["z_31"]."\",\"".$w_z_val_tot_grp."\")";
	$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());		
		
	
/*
		$w_z_val01_tot = $w_z_val01_tot + $w_z_val01;
		$w_z_val02_tot = $w_z_val02_tot + $w_z_val02;
		$w_z_val03_tot = $w_z_val03_tot + $w_z_val03;
		$w_z_val04_tot = $w_z_val04_tot + $w_z_val04;
		$w_z_val05_tot = $w_z_val05_tot + $w_z_val05;
		$w_z_val06_tot = $w_z_val06_tot + $w_z_val06;
		$w_z_val07_tot = $w_z_val07_tot + $w_z_val07;
		$w_z_val08_tot = $w_z_val08_tot + $w_z_val08;
		$w_z_val09_tot = $w_z_val09_tot + $w_z_val09;
		$w_z_val10_tot = $w_z_val10_tot + $w_z_val10;	
		$w_z_val11_tot = $w_z_val11_tot + $w_z_val11;	
		$w_z_val12_tot = $w_z_val12_tot + $w_z_val12;	
*/
	
	echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
	echo "<TR>";		
	echo $out;
	echo "</TR>";
	echo "</TABLE>";

	mysql_close($connection);	
	
?>	