23 * [uur] => Array * ( * [0] => 3-1 * [1] => 3-2 * [2] => 4-3 * [3] => 4-4 * ) * * [lokalen] => Array * ( * [0] => COM2 * ) * * [text] => test * [sort] => HARD * ) */ $week = mdb2_single_assoc($db, "SELECT * FROM $roosterdb.weken WHERE week_id = %i", $_POST['week_id']); if (!is_array($week)) error_system("week id niet gevonden"); if (!isset($_POST['lokalen']) || !is_array($_POST['lokalen']) || count($_POST['lokalen']) == 0) error_user("geen lokaal aangevinkt", "vink minstens 1 lokaal aan", "blok.php?week_id=".$_POST['week_id']); if (!isset($_POST['uur']) || !is_array($_POST['uur']) || count($_POST['uur']) == 0) error_user("geen lokaal aangevinkt", "vink minstens 1 lokaal aan", "blok.php?week_id=".$_POST['week_id']); if (!isset($_POST['soort']) || ($_POST['soort'] != 'HARD' && $_POST['soort'] != 'SOFT')) error_system("impossible: soort must be set and be equal to HARD or SOFT"); mdb2_exec($db, "INSERT INTO blokgroups ( text_roostermaker, week_id, soort ) VALUES ( '%q', %i, '%q' )", htmlenc($_POST['text']), $_POST['week_id'], $_POST['soort']); $blokgroup_id = mdb2_single_val($db, $last_insert_id); foreach ($_POST['lokalen'] as $lokaal) { $entity_id = mdb2_single_val($db, "SELECT entity_id FROM $roosterdb.entities WHERE entity_name = '%q'", $lokaal); if (!$entity_id) error_system("lokaal niet gevonden: ".$lokaal); mdb2_exec($db, "INSERT INTO entblok ( entity_id, blokgroup_id ) VALUES ( %i, %i )", $entity_id, $blokgroup_id); } foreach ($_POST['uur'] as $daguur) { echo($daguur."\n"); if (!preg_match('/(\d+)-(\d+)/', $daguur, $matches)) error_system("imposible uur format"); $dag = $matches[1]; $uur = $matches[2]; echo("daguur=$daguur dag=$dag uur=$uur\n"); mdb2_exec($db, "INSERT INTO uurblok ( dag, uur, blokgroup_id ) VALUES ( %i, %i, %i )", $dag, $uur, $blokgroup_id); } if (isset($_POST['blokgroup_id'])) mdb2_exec($db, "UPDATE blokgroups SET timestamp_delete = NOW() WHERE blokgroup_id = %i AND week_id = %i", $_POST['blokgroup_id'], $_POST['week_id']); header('Location: '.$location.'admin.php?week_id='.$_POST['week_id']); ?>