<?php require_once('includes/requirecompere.inc.php'); require_once('includes/requirepost.inc.php'); $cs_ids=TPOST('cs_id_checked'); $ta_id=0+TPOST('ta_id'); $action_addnew=TPOST('addnew'); $action_modify=TPOST('modify'); $since=array( 'year'=>TPOST('since_year'), 'month'=>TPOST('since_month'), 'day'=>TPOST('since_day'), 'hour'=>TPOST('since_hour'), 'minute'=>TPOST('since_minute'), 'second'=>'00' ); $expire=array( 'year'=>TPOST('expire_year'), 'month'=>TPOST('expire_month'), 'day'=>TPOST('expire_day'), 'hour'=>TPOST('expire_hour'), 'minute'=>TPOST('expire_minute'), 'second'=>'00' ); $mb_id=current_mb_id(); $timezone_bias_seconds=get_user_time_zone()*60; $tainfo=array( 'cs_ids'=>$cs_ids, 'ta_id'=>$ta_id, 'mb_id'=>$mb_id, 'ta_begin'=>combine_datetime($since,$timezone_bias_seconds,false), 'ta_end'=>combine_datetime($expire,$timezone_bias_seconds,false), 'ta_status'=>TPOST('ta_status') ); $DBConn->connect(); $DBConn->begin(true); $ta_count=db_count_timeavail($DBConn,$mb_id); $errorareas=iif_array4(array( array(!$tainfo['ta_begin'],'ERROR-TIMESINCE-INVALID',array(0)), array(!$tainfo['ta_end'],'ERROR-TIMEEXPIRE-INVALID',array(0)), array($tainfo['ta_begin']>=$tainfo['ta_end'],'ERROR-TIMEEXPIRE-INVALID',array(0)), array(seconds_to_datetime()>=$tainfo['ta_end'],'ERROR-TIMEEXPIRE-INVALID',array(0)), array(datetime_to_seconds($tainfo['ta_end'])-datetime_to_seconds($tainfo['ta_begin'])>$Config->TimeIntervalHoursMax*3600,'ERROR-TIMEEXPIRE-INVALID',array(0)), array($action_addnew && $ta_count>=get_compere_limit($DBConn,$mb_id,'timeavail.count'),'ERROR-COUNT-LIMIT',array(0)) )); if (count_true_entries($errorareas)>0) { $_SESSION['reserv.inputcache.data']=$tainfo; $_SESSION['reserv.inputcache.domain']='timeavail'; $_SESSION['reserv.inputcache.okas']=null; $_SESSION['reserv.inputcache.errorareas']=$errorareas; if ($action_addnew) redirect("qx-cmd-timeavail.addnew-op-revise.html",array("publishcourse"=>"qx-cmd-timeavail.addnew-op-revise-wizard-publishcourse.html")); if ($action_modify) redirect("qx-cmd-timeavail.modify-op-revise-ta_id-".$ta_id.".html"); } else { purge_array_by_key_prefix($_SESSION,'reserv.inputcache.'); if ($action_addnew) { $ta_id=db_insert_timeavail($DBConn,$tainfo); db_save_timeavail_course($DBConn,$ta_id,$mb_id,$cs_ids); } else if ($action_modify && $tainfo['ta_id']) { db_update_timeavail($DBConn,$tainfo); db_save_timeavail_course($DBConn,$ta_id,$mb_id,$cs_ids); } redirect("qx-cmd-timeavail.modify-op-saved-ta_id-".$ta_id.".html",array("publishcourse"=>"qx-cmd-course.publishwizard.done-cs_id-".wizard_get_data("cs_id").".html")); } $DBConn->commit(); ?>