<?php

if (!empty($_POST)) {
    $found = CalificationData::getByBA($_POST["block_id"], $_POST["alumn_id"]);
    if ($found == null && $_POST["val"] != "") {
        $assis = new CalificationData();
        $assis->alumn_id = $_POST["alumn_id"];
        $assis->block_id = $_POST["block_id"];
        $assis->val = $_POST["val"];
        $assis->add();
    } else {
        if ($found = !null && $_POST["val"] != "") {
            $found = CalificationData::getByBA($_POST["block_id"], $_POST["alumn_id"]);
            $found->val = $_POST["val"];
            $found->update();
        } else {
            if ($_POST["val"] == "") {
                //$found = CalificationData::getByBA($_POST["alumn_id"],$_POST["block_id"]);
                //$found->del();
            }
        }
    }
}
$section1 = $word->AddSection();
$section1->addText("CALIFICACIONES - " . strtoupper($team->name), array("size" => 22, "bold" => true, "align" => "right"));
$styleTable = array('borderSize' => 6, 'borderColor' => '888888', 'cellMargin' => 40);
$styleFirstRow = array('borderBottomColor' => '0000FF', 'bgColor' => 'AAAAAA');
$table1 = $section1->addTable("table1");
$table1->addRow();
$table1->addCell()->addText("Nombre Completo");
foreach ($blocks as $block) {
    $table1->addCell()->addText($block->name);
}
foreach ($alumns as $al) {
    $alumn = $al->getAlumn();
    $table1->addRow();
    $table1->addCell(5000)->addText($alumn->name . " " . $alumn->lastname);
    foreach ($blocks as $block) {
        $val = CalificationData::getByBA($block->id, $alumn->id);
        $v = "";
        if ($val != null) {
            $v = $val->val;
        }
        $table1->addCell()->addText($v);
    }
}
$word->addTableStyle('table1', $styleTable, $styleFirstRow);
/// datos bancarios
$section1->addText("");
$section1->addText("");
$section1->addText("");
$section1->addText("Generado por Xoolar Lite v1.0");
$filename = "califications-" . time() . ".docx";
#$word->setReadDataOnly(true);
		<?php 
$alumns = AlumnTeamData::getAllByTeamId($_GET["team_id"]);
if (count($alumns) > 0) {
    // si hay usuarios
    ?>

			<table class="table table-bordered table-hover">
			<thead>
			<th>Nombre</th>
			<th>
			</th>
			</thead>
			<?php 
    foreach ($alumns as $al) {
        $alumn = $al->getAlumn();
        $val = CalificationData::getByBA($_GET["block_id"], $alumn->id);
        ?>
				<tr>
				<td style="width:250px;"><?php 
        echo $alumn->name . " " . $alumn->lastname;
        ?>
</td>
				<td >
				<form id="form-<?php 
        echo $al->id;
        ?>
">
				<input type="hidden" name="alumn_id" value="<?php 
        echo $alumn->id;
        ?>
">