<?php require_once('includes/requirecompere.inc.php'); require_once('includes/requirepost.inc.php'); $clsr_id=0+TPOST('clsr_id'); $plc_id=0+TPOST('plc_id'); $mb_id=current_mb_id(); $st_ids=TPOST('st_ids'); if (!$st_ids) $st_ids=array(); $DBConn->connect(); $classroom=db_load_classroom($DBConn,$clsr_id); $place=db_load_place($DBConn,$plc_id); if ($classroom['mb_id_owner']!=$mb_id || $place['mb_id_owner']!=$mb_id) { $DBConn->rollback(); redirect("./"); return; } $DBConn->begin(true); $cur_seat_count=db_count_classroom_seats($DBConn,$clsr_id); $seat_count_addable=get_compere_limit($DBConn,$mb_id,'classroom.seat.count')-$cur_seat_count; $seats=db_load_unassigned_seats_at_place($DBConn,$plc_id); $seatids=array_projection($seats,'st_id'); $okids=array_intersect($st_ids,$seatids); if ($seat_count_addable>0) { while (sizeof($okids)>$seat_count_addable) array_pop($okids); db_add_seats_to_classroom($DBConn,$clsr_id,$okids); } $DBConn->commit(); redirect("qx-cmd-classroom.seats-clsr_id-".$clsr_id.".html"); ?>