<?php require_once('includes/requirecompere.inc.php'); require_once('includes/requirepost.inc.php'); $action=TPOST('action'); $copyfrommemberinfo=TPOST('copyfrommemberinfo'); $plcinfo=array(); $plcinfo['plc_id']=TPOST('plc_id'); $plcinfo['mb_id_owner']=current_mb_id(); $plcinfo['plc_name']=TPOST('plc_name'); $plcinfo['plc_country']=TPOST('plc_country'); $plcinfo['plc_zipcode']=TPOST('plc_zipcode'); $plcinfo['plc_state']=TPOST('plc_state'); $plcinfo['plc_city']=TPOST('plc_city'); $plcinfo['plc_address']=TPOST('plc_address'); $plcinfo['plc_room']=TPOST('plc_room'); $plcinfo['plc_phone']=TPOST('plc_phone'); $plcinfo['plc_status']='VALID'; $clsrinfo['iscreateclassroom']=TPOST('iscreateclassroom'); $clsrinfo['clsr_name']=TPOST('clsr_name'); $clsrinfo['clsr_desc']=TPOST('clsr_desc'); $clsrinfo['seat_count']=TPOST('seat_count'); $DBConn->connect(); if ($copyfrommemberinfo) { $mb_id=current_mb_id(); $minfo=db_load_member_info($DBConn,$mb_id); $mphones=db_load_member_phones($DBConn,$mb_id); $plcinfo['plc_country']=$minfo['mb_country']; $plcinfo['plc_zipcode']=$minfo['mb_zipcode']; $plcinfo['plc_state']=$minfo['mb_state']; $plcinfo['plc_city']=$minfo['mb_city']; $plcinfo['plc_address']=$minfo['mb_address']; if ($mphones) $plcinfo['plc_phone']=$mphones[0]['mb_phone']; $errorareas=array(); } else { $DBConn->begin(true); $mb_id=current_mb_id(); $p_count=db_count_place($DBConn,$mb_id); $total_seat_count=db_count_seat($DBConn,$mb_id); $seat_limit=get_compere_limit($DBConn,$mb_id,'seat.count'); $classroom_seat_limit=get_compere_limit($DBConn,$mb_id,'classroom.seat.count'); $seat_max=min($seat_limit-$total_seat_count,$classroom_seat_limit); $errorareas=iif_array4(array( array(!$plcinfo['plc_name'],'ERROR-PLACENAME',array(0),array()), array(!$plcinfo['plc_country'],'ERROR-COUNTRY',array(0),array()), array(!$plcinfo['plc_zipcode'],'ERROR-ZIPCODE',array(0),array()), array(!$plcinfo['plc_state'],'ERROR-STATE',array(0),array()), array(!$plcinfo['plc_city'],'ERROR-CITY',array(0),array()), array(!$plcinfo['plc_address'],'ERROR-ADDRESS',array(0),array()), array(!$plcinfo['plc_phone'],'ERROR-PHONE',array(0),array()), array($action=="addnew" && !is_integer_in_range($clsrinfo['seat_count'],0,$seat_max),'ERROR-SEATCOUNT-INVALID',array(0),array()), array($action=="addnew" && $p_count>=get_compere_limit($DBConn,$mb_id,'place.count'),'ERROR-COUNT-LIMIT',array(0),array()) )); if ($clsrinfo['iscreateclassroom']) { $classroom_count=db_count_classroom($DBConn,$mb_id); $errorareas+=iif_array4(array( array($classroom_count>=get_compere_limit($DBConn,$mb_id,'classroom.count'),'ERROR-ROOM-COUNT-LIMIT',array(0),array()), array(!$clsrinfo['clsr_name'],'ERROR-ROOM-NAME-INVALID',array(0),array()), array(!$clsrinfo['clsr_desc'],'ERROR-ROOM-DESC-INVALID',array(0),array()) )); } } $dataset+=prepare_wizard_dataset(); if ($copyfrommemberinfo || count_true_entries($errorareas)) { $_SESSION['reserv.inputcache.data']=$plcinfo+$clsrinfo; $_SESSION['reserv.inputcache.domain']='place'; $_SESSION['reserv.inputcache.errorareas']=$errorareas; if ($action=="addnew") redirect("qx-cmd-place.addnew-op-revise".$dataset['WIZARD-PARAM-DBLHYP'].".html"); if ($action=="modify") redirect("qx-cmd-place.modify-plc_id-".$plcinfo['plc_id']."-op-revise".$dataset['WIZARD-PARAM-DBLHYP'].".html"); } else { purge_array_by_key_prefix($_SESSION,'reserv.inputcache'); if ($action=="addnew") { $plc_id=db_insert_place($DBConn,$plcinfo); if ($clsrinfo['seat_count']) db_add_seats_at_place($DBConn,$plc_id,$clsrinfo['seat_count']); if ($clsrinfo['iscreateclassroom']) { $clsrinfo['mb_id_owner']=$mb_id; $clsrinfo['clsr_status']='VALID'; $clsr_id=db_insert_classroom($DBConn,$clsrinfo); $seats=db_load_seats_at_place($DBConn,$plc_id); $st_ids=array_projection($seats,'st_id'); db_add_seats_to_classroom($DBConn,$clsr_id,$st_ids); $cs_id=wizard_get_data('cs_id',"publishcourse"); if ($cs_id) db_add_classroom_to_course($DBConn,$cs_id,$clsr_id); } } if ($action=="modify") db_update_place($DBConn,$plcinfo); redirect("qx-cmd-place.manage.html",array("publishcourse"=>"qx-cmd-course.assign.classroom-cs_id-".wizard_get_data('cs_id')."-wizard-publishcourse.html")); member_refresh_login($DBConn); } $DBConn->commit(); ?>