<?php require_once('includes/requirecompere.inc.php'); require_once('includes/requirepost.inc.php'); $lctr_id=TPOST('lctr_id'); $mb_id_owner=current_mb_id(); $addparticipant=TPOST('addparticipant'); $DBConn->connect(); $csowner_qualified=db_is_compere_qualified($DBConn,$mb_id_owner); $lecture=db_load_lecture_by_id($DBConn,$lctr_id); $course=db_load_course_by_id($DBConn,$lecture['cs_id']); if (!$lecture || $course['mb_id_owner']!=$mb_id_owner) { redirect("./"); return; } if ($addparticipant && $csowner_qualified) { $mb_id_adds=TPOST('mb_id_adds'); if (!$mb_id_adds) $mb_id_adds=array(); $plc_clsr_id=TPOST('plc_clsr_id'); list($plc_id,$clsr_id)=explode(',',$plc_clsr_id); if (sizeof($mb_id_adds)>0 && ctype_digit((string)$plc_id) && ctype_digit((string)$clsr_id)) { $DBConn->begin(true); $sizes=db_load_lecture_size_by_place_classroom($DBConn,$lctr_id,$plc_id,$clsr_id); $st_ids=db_pick_seat_available_for_lecture($DBConn,$lctr_id,$plc_id,$clsr_id,sizeof($mb_id_adds)); if (!$sizes || min($sizes[0]['clsr_size'],$course['cs_member_max'])-$sizes[0]['lctr_size']<sizeof($mb_id_adds)) { $DBConn->rollback(); redirect("qx-cmd-course.lecture.detail-op-fail.overbooking-lctr_id-".$lctr_id.".html"); } else { for ($i=0;$i<sizeof($st_ids);$i++) { $rsv_id=db_insert_reservation($DBConn,$lctr_id,$st_ids[$i],$mb_id_adds[$i],$mb_id_owner); } if ($course['cs_autoconfirm']=='YES' || $course['cs_autoconfirm']=='ALLBUTONE' && db_count_reservations_of_lecture($DBConn,$lctr_id,false,true)>0) { for ($i=0;$i<sizeof($st_ids);$i++) db_confirm_reservation($DBConn,$lctr_id,$st_ids[$i],$mb_id_adds[$i]); } $DBConn->commit(); redirect("qx-cmd-course.lecture.detail-op-reserve.ok-lctr_id-".$lctr_id.".html"); } } else redirect("qx-cmd-course.lecture.detail-lctr_id-".$lctr_id.".html"); } else redirect("qx-cmd-course.lecture.detail-lctr_id-".$lctr_id.".html"); ?>