document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. private function editEventForm($function = \'addnew\', $eventID = null, $courseID = null){
  2.    
  3.         $path = $this -> moduleBaseUrl . "&sdms_section=eventoverview";
  4.         $smarty = $this -> getSmartyVar();
  5.        
  6.         $currencySymbols = $this -> getCurrencySymbols();
  7.         $currencySymbolsJS = json_encode($currencySymbols);
  8.         $symbolString = "<script type=\'text/javascript\'> var currencySymbols = " . $currencySymbolsJS . "</script>";
  9.         $smarty -> assign("T_JS_SYMBOLS_OBJ", $symbolString);
  10.        
  11.         if($function == \'edit\'){
  12.        
  13.             $path = $path . "&func=edit&ref=$eventID";
  14.             $editflag = 1;
  15.             $tag = _SDMS_EDITEVENT;
  16.             $subtag = _SDMS_UPDATEEVENT;
  17.            
  18.             $getEvent = eF_getTableData(\'sdms_actevent\',\'activitykey, eventreference, maximumnumber, eventstatus, organiser, owner, branch, trainer, eventtitle, scope, programmeaims, programmeobj, programmeprog, ts_start, ts_end, ts_close, coursefee, currency, extratrainers\',"id=\'$eventID\'");
  19.             $arrEvent = $getEvent[0];
  20.            
  21.             $getSession = eF_getTableData(\'sdms_actsessi\',\'venuekey, roomkey\',"eventkey=\'$eventID\'");
  22.             $arrSession = $getSession[0];
  23.             $courseID = $arrEvent[\'activitykey\'];
  24.             $eventRef = $arrEvent[\'eventreference\'];
  25.             $eventTitle = $arrEvent[\'eventtitle\'];
  26.             $maxDel = $arrEvent[\'maximumnumber\'];
  27.             $status = $arrEvent[\'eventstatus\'];
  28.             $start_ts = $arrEvent[\'ts_start\'];
  29.             $end_ts = $arrEvent[\'ts_end\'];
  30.             $close_ts = $arrEvent[\'ts_close\'];
  31.             $objectives = $arrEvent[\'programmeobj\'];
  32.             $scope = $arrEvent[\'scope\'];
  33.             $aims = $arrEvent[\'programmeaims\'];
  34.             $programme = $arrEvent[\'programmeprog\'];
  35.             $venue = $arrSession[\'venuekey\'];
  36.             $venueRoom = $arrSession[\'roomkey\'];
  37.             $orgValue = $arrEvent[\'organiser\'];
  38.             $courseFee = $arrEvent[\'coursefee\'];
  39.             $trainerValue = $arrEvent[\'trainer\'];
  40.             $currency = $arrEvent[\'currency\'];
  41.             $currencySymbol = $currencySymbols[$currency];
  42.             $owner = $arrEvent[\'owner\'];
  43.             $branch = $arrEvent[\'branch\'];
  44.             $extratrainers = explode(",",$arrEvent["extratrainers"]);
  45.             $formatFee = number_format(($courseFee / 100), 2, ".", ",");
  46.             $explodeFee = explode(".", $formatFee);
  47.             $feeValue1 = $explodeFee[0];
  48.             $feeValue2 = $explodeFee[1];
  49.            
  50.             $startDate = date("d/m/Y", $start_ts);
  51.             $startTimeH = date("H", $start_ts);
  52.             $startTimeM = date("i", $start_ts);
  53.             $endDate = date("d/m/Y", $end_ts);
  54.             $endTimeH = date("H", $end_ts);
  55.             $endTimeM = date("i", $end_ts);
  56.             $closeDate = ($close_ts == 0) ? "" : date("d/m/Y", $close_ts);
  57.  
  58.            
  59.             $activity = $this -> getCourseDetails($courseID);
  60.        
  61.         }elseif($function == \'addnew\' && $courseID != null){
  62.        
  63.             $path = $path . "&func=addnew&ref=$courseID";
  64.             $editflag = null;
  65.             $tag = _SDMS_NEWEVENT;
  66.             $subtag = _SDMS_SUBMITEVENT;
  67.            
  68.             $activity = $this -> getCourseDetails($courseID);
  69.             $getActEventCount = eF_getTableData(\'sdms_actevent\',\'id\',"activitykey=\'$courseID\'");
  70.             $eventNum = count($getActEventCount);
  71.            
  72.             $eventRef = $eventNum + 1;
  73.             $eventTitle = $activity[\'title\'];
  74.             $maxDel = $activity[\'delegates\'];
  75.             $scope = $activity[\'scope\'];
  76.             $orgValue = $activity[\'organiser\'];
  77.             $trainerValue = null;
  78.             $status = \'schd\';
  79.             $venue = null;
  80.             $venueRoom = null;
  81.             $courseFee = $activity[\'fee\'];
  82.             $defStartTS = $activity[\'defStartTS\'];
  83.             $defEndTS = $activity[\'defEndTS\'];
  84.             $currency = $activity[\'defcurrency\'];
  85.             $currencySymbol = $currencySymbols[$currency];
  86.             $scope = $activity[\'scope\'];
  87.             $owner = 0;
  88.             $branch = 0;
  89.            
  90.             $formatFee = number_format(($courseFee / 100), 2, ".", ",");
  91.             $explodeFee = explode(".", $formatFee);
  92.             $feeValue1 = $explodeFee[0];
  93.             $feeValue2 = $explodeFee[1];
  94.            
  95.             $startDate = $endDate = $closeDate = date("d/m/Y");
  96.            
  97.             $startTimeH = date("H", $defStartTS);
  98.             $startTimeM = date("i", $defStartTS);
  99.  
  100.             $endTimeH = date("H", $defEndTS);
  101.             $endTimeM = date("i", $defEndTS);
  102.  
  103.        
  104.         }else{
  105.        
  106.             $t_conf = "Call to undefined function - $function - in editEventForm() .";
  107.             $outcome = "failure";
  108.             $this -> setMessageVar($t_conf, $outcome);
  109.        
  110.         }
  111.        
  112.         $statusDropDown = $this -> buildCodesDropDown("STATUS", $status);
  113.         $venues = $this -> buildVenueDropDown($venue);
  114.         $venueRooms = $this -> buildVenueRoomsDropDown($venue, $venueRoom);
  115.         $organiser = $this -> buildOrganisersDropDown($orgValue);
  116.         $trainer = $this -> buildTrainersDropDown($trainerValue);
  117.         $currencies = $this -> buildCurrenciesDropDown();
  118.         $ownersDropDown = $this -> getSupervisorsDropDown();
  119.         $branchDropDown = $this -> getBranchDropDown();
  120.         //new multi-trainer stuff
  121.         $form2 = new HTML_QuickForm("addMultipleTrainers", "POST", $path, "", null, true);
  122.         $trainerQuery = eF_getTableData("users", "*", "istrainer = \'1\'");
  123.         $trainerArray = array();
  124.         $trainerNameArray = array();
  125.         $z=0;
  126.         foreach($trainerQuery as $trainerData){
  127.             $trainerArray[$z]["Name"] = $trainerData["name"];
  128.             $trainerArray[$z]["Surname"] = $trainerData["surname"];
  129.             $trainerArray[$z]["Login"] = $trainerData["login"];
  130.             $trainerGroup = eF_getTableData("users_to_groups", "*", "users_LOGIN = \'".$trainerArray[$z]["Login"]."\'");
  131.             $groupData = eF_getTableData("groups", "*", "id = \'".$trainerGroup[0]["groups_ID"]."\'");
  132.             $trainerArray[$z]["Group"] = $groupData[0]["name"];
  133.             if($trainerArray[$z]["Group"] == ""){
  134.                 $trainerArray[$z]["Group"] = "No Branch";
  135.             }
  136.             $z++;
  137.         }
  138.         $z=0;
  139.         foreach($trainerArray as $multiTrainer){
  140.             $form2 -> addElement(\'checkbox\', \'trainers[]\', $multiTrainer["Login"], "", "");
  141.             $form2 -> addElement(\'radio\', \'maintrainer[]\', $multiTrainer["Group"], "", $multiTrainer["Login"]);
  142.             $trainerNameArray[$z] = $multiTrainer["Name"]." ".$multiTrainer["Surname"]." (".$multiTrainer["Login"].")";
  143.             $z++;
  144.         }
  145.         $form2 -> addElement(\'submit\', \'submit\', _SDMS_FORMTRAINERSBUTTON, \'class="flatButton"\');
  146. /*     
  147.         $form2 -> addElement(\'select\', \'MainTrainer\', _SDMS_FORMMAINTRAINER.\': \', $trainer, \'style="width:250px; margin:5px 0 5px 0;"\');
  148.         $multiselect = $form2 -> addElement(\'select\', \'trainers\', _SDMS_FORMTRAINERS.\': \', $trainer, \'style="dith:250px; margin:5px 0 5px 0;"\');
  149.         $multiselect -> setMultiple(true);
  150. */
  151.         if($form2 -> isSubmitted() && $form2 -> validate()){
  152.             $values2 = $form2 -> exportValues();
  153.             //isSubmitted doesn\'t like our foreach addElements, so we grab the post.
  154.             foreach($_POST as $key=>$value){
  155.                 $values2[$key] = $value;
  156.             }
  157.             $trainer = $values2["maintrainer"][0];
  158.             for($z=0; $z<=sizeof($values2["trainers"]); $z++){
  159.                 if($trainer == $values2["trainers"][$z]){
  160.                     unset($values2["trainers"][$z]);
  161.                 }
  162.             }
  163.             $extratrainers = implode(",", $values2["trainers"]);
  164.             $trainerClashCheckNew = $this -> trainerClashCheck($trainer, $start_ts, $end_ts, $eventID);
  165.             $multiTrainerClashCheckNew = array();
  166.             foreach($values2["trainers"] as $xTrainer){
  167.                 $multiTrainerClashCheckNew[] = $this -> multiTrainerClashCheck($xTrainer, $start_ts, $end_ts, $eventID);
  168.             }
  169.             $eventDataNew = array(  \'trainer\' => $trainer,
  170.                                     \'extratrainers\' => $extratrainers,
  171.                                     \'eventstatus\' => strtoupper($status)
  172.                                 );
  173.             if($trainerClashCheckNew[0] > 0){                  
  174.                 $eventDataNew[\'eventstatus\'] = "PROP"; 
  175.             }
  176.             foreach($multiTrainerClashCheckNew as $multiCheck){
  177.                 if($multiCheck[0]>0){
  178.                     $eventDataNew["eventstatus"] = "PROP";
  179.                 }
  180.             }
  181.             $queryNew = eF_updateTableData(\'sdms_actevent\', $eventDataNew, "id=\'".$eventID."\'");
  182.             $t_conf = "Trainers Added to: ".$eventTitle;
  183.             $outcome = "success";
  184.             if($trainerClashCheckNew[0] > 0){
  185.                     $t_conf = _SDMS_TRAINERCLASH;
  186.                     $outcome = "failure";
  187.             }
  188.             foreach($multiTrainerClashCheckNew as $multiCheck){
  189.                 if($multiCheck[0]>0){
  190.                     $t_conf = "One or more trainers have prior commitments on this date and time, event status set to Proposed.";
  191.                     $outcome = "failure";
  192.                 }
  193.             }
  194.             $path = $this -> moduleBaseUrl . "&sdms_section=eventoverview&func=edit&ref=$eventID";
  195.             eF_redirect($path.\'&message=\'.$t_conf.\'&message_type=\'.$outcome);  
  196.         }
  197.         $renderer2 = prepareFormRenderer($form2);
  198.         $form2 = $renderer2 -> toArray();
  199.         //forcing checkbox value change as html_quickform only allows 1 or 0
  200.         for($x=0; $x<=sizeof($form2); $x++){
  201.             if($form2["trainers"][$x]["type"] == "checkbox"){
  202.                 $form2["trainers"][$x]["value"] = $form2["trainers"][$x]["label"];
  203.                 $form2["trainers"][$x]["label"] = $trainerNameArray[$x];
  204.                 $flagMainVar = "flagMain(\'".$form2["trainers"][$x]["value"]."\')";
  205.                 $form2["trainers"][$x]["html"] = str_replace(\'value="1"\', \'value="\'.$form2["trainers"][$x]["value"].\'" onchange="\'.$flagMainVar.\'"\', $form2["trainers"][$x]["html"]);
  206.                 $form2["maintrainer"][$x]["html"] = str_replace(\'value="\'.$form2["maintrainer"][$x]["value"].\'"\', \'value="\'.$form2["maintrainer"][$x]["value"].\'" onchange="flagTrainer()"\', $form2["maintrainer"][$x]["html"]);
  207.                 if($trainerValue != "0"){
  208.                     if($form2["trainers"][$x]["value"] == $trainerValue){
  209.                         $form2["maintrainer"][$x]["html"] = str_replace(\'name="maintrainer[]"\', \'name="maintrainer[]" checked="checked"\', $form2["maintrainer"][$x]["html"]);
  210.                         $form2["trainers"][$x]["html"] = str_replace(\'name="trainers[]"\', \'name="trainers[]" checked="checked"\', $form2["trainers"][$x]["html"]);
  211.                     }
  212.                     if(in_array($form2["trainers"][$x]["value"], $extratrainers)){
  213.                         $form2["trainers"][$x]["html"] = str_replace(\'name="trainers[]"\', \'name="trainers[]" checked="checked"\', $form2["trainers"][$x]["html"]);
  214.                     }
  215.                 }
  216.                 else{
  217.                     if($form2["trainers"][$x]["value"] == $values2["maintrainer"][0]){
  218.                         $form2["maintrainer"][$x]["html"] = str_replace(\'name="maintrainer[]"\', \'name="maintrainer[]" checked="checked"\', $form2["maintrainer"][$x]["html"]);
  219.                         $form2["trainers"][$x]["html"] = str_replace(\'name="trainers[]"\', \'name="trainers[]" checked="checked"\', $form2["trainers"][$x]["html"]);
  220.                     }
  221.                     if(in_array($form2["trainers"][$x]["value"], $values2["trainers"])){
  222.                         $form2["trainers"][$x]["html"] = str_replace(\'name="trainers[]"\', \'name="trainers[]" checked="checked"\', $form2["trainers"][$x]["html"]);
  223.                     }
  224.                 }
  225.             }
  226.         }
  227.         $smarty -> assign("T_MULTITRAINER", $form2);
  228.         $activityTitle = $activity[\'title\'];
  229.         $activityLink = "<a class=\'editLink\' href=\'" . $this -> moduleBaseUrl . "&sdms_section=courses&func=edit&ref=$courseID&def_tab=ecc_evsch\'>$activityTitle</a>";
  230.         $datePickerJS = "<script type=\\"text/javascript\\">
  231.                             window.onload = function(){
  232.                                 new JsDatePick({
  233.                                     useMode:2,
  234.                                     target:\\"datepicker\\",
  235.                                     dateFormat:\\"%d/%m/%Y\\"
  236.                                 });
  237.                                
  238.                                 new JsDatePick({
  239.                                     useMode:2,
  240.                                     target:\\"endDateNew\\",
  241.                                     dateFormat:\\"%d/%m/%Y\\"
  242.                                 });
  243.                                
  244.                                 new JsDatePick({
  245.                                     useMode:2,
  246.                                     target:\\"closeDateNew\\",
  247.                                     dateFormat:\\"%d/%m/%Y\\"
  248.                                 });
  249.                             };
  250.                             function showHide(divID){
  251.                                     if(document.getElementById(divID).style.display == \'block\'){
  252.                                         document.getElementById(divID).style.display = \'none\';
  253.                                     }
  254.                                     else{
  255.                                         document.getElementById(divID).style.display = \'block\';
  256.                                     }
  257.                                 }
  258.                         </script>";
  259.         $smarty -> assign("T_DATEPICKER_JS", $datePickerJS);
  260.         //new defines
  261.         $smarty -> assign("T_LABELMULTIPLETRAINER", _SDMS_LABELMULTITRAINER);
  262.         $smarty -> assign("T_LABELMULTIPLETRAINERS", _SDMS_LABELMULTIPLETRAINERS);
  263.         $smarty -> assign("T_LABELTRAINER", _SDMS_LABELTRAINER);
  264.         $smarty -> assign("T_LABELTRAINERNAME", _SDMS_LABELTRAINERNAME);
  265.        
  266.         $jsVenueRoomArray = $this -> buildVenueRoomsJSArray();
  267.         $smarty -> assign(\'T_VENUEROOM_JS_ARRAY\', $jsVenueRoomArray);
  268.        
  269.         $smarty -> assign(\'T_ACTIVITY_LINK\', $activityLink);
  270.         $smarty -> assign(\'T_COURSETAB_LABEL\', $tag);
  271.         $smarty -> assign(\'T_EDITCOUSE_FLAG\', $editflag);
  272.         $smarty -> assign("T_CURRENCY_SYMBOL", $currencySymbol);
  273.        
  274.         $form = new HTML_QuickForm("editEventDetails", "POST", $path, "", null,true);
  275.        
  276.         $form -> addElement(\'text\', \'startDateNew\', _SDMS_START .\': \', \'size="12" maxlength="10" id="datepicker" onchange="updateEndCloseDate(this);" value="\'.$startDate.\'"\');
  277.         $form -> addElement(\'text\', \'endDate_New\', _SDMS_END .\': \', "size=\\"12\\" maxlength=\\"10\\" id=\\"endDateNew\\" value=\\"$endDate\\"");
  278.         $form -> addElement(\'text\', \'closeDate_New\', _SDMS_CLOSE .\': \', \'size="12" maxlength="10" id="closeDateNew" value="\'.$closeDate.\'"\');
  279.         $form -> addElement(\'text\', \'eventReference\', _SDMS_REFERENCE .\': \', array(\'size\' => 10, \'maxlength\' => 10, \'value\' => $eventRef, \'onblur\' => "this.value=this.value.toUpperCase()"));
  280.         $form -> addElement(\'text\', \'eventTitle\', _SDMS_TITLE .\': \', array(\'size\' => 100, \'maxlength\' => 100, \'value\' => $eventTitle));
  281.         $form -> addElement(\'select\', \'status\', _SDMS_STATUSLABEL .": ", $statusDropDown, \'style = "width:250px;margin:5px 0 5px 0;"\');
  282.         $form -> addElement(\'select\', \'organiser\', _SDMS_ORGANISER .": ", $organiser, \'style = "width:250px;margin:5px 0 5px 0;"\');
  283.         $form -> addElement(\'text\', \'startTime_h\', null, array(\'size\' => 2, \'maxlength\' => 2, \'value\' => "$startTimeH"));
  284.         $form -> addElement(\'text\', \'startTime_m\', null, array(\'size\' => 2, \'maxlength\' => 2, \'value\' => "$startTimeM"));
  285.         $form -> addElement(\'text\', \'endTime_h\', null, array(\'size\' => 2, \'maxlength\' => 2, \'value\' => "$endTimeH"));
  286.         $form -> addElement(\'text\', \'endTime_m\', null, array(\'size\' => 2, \'maxlength\' => 2, \'value\' => "$endTimeM"));
  287.         $form -> addElement(\'text\', \'maxDel\', _SDMS_MAXDELEGATES .": ", array(\'size\' => 2, \'maxlength\' => 2, \'value\' => $maxDel));
  288.         //$form -> addElement(\'select\', \'provider\', "Provider", $provider);
  289.         $trainerSelect = $form -> addElement(\'select\', \'trainer\', _SDMS_TRAINER .": ", $trainer, \'style = "width:250px;margin:5px 0 5px 0;"\');
  290.         if(isset($values2["maintrainer"][0]) && $values2["maintrainer"][0] != "0"){
  291.             $trainerSelectValue = $values2["maintrainer"][0];
  292.             $trainerSelect -> setSelected($trainerSelectValue);
  293.         }
  294.         if(isset($extratrainers)){
  295.             foreach($extratrainers as $extraTrainer){
  296.                 if($extraTrainer != ""){
  297.                     $form -> addElement(\'text\', \'extratrainer[]\', \'extratrainer\', \'value="\'.$extraTrainer.\'"\');
  298.                     $extraCount++;
  299.                 }
  300.             }
  301.         }
  302.         if(isset($values2["trainers"])){
  303.             foreach($values2["trainers"] as $extraTrainer){
  304.                 if($extraTrainer != $values2["maintrainer"][0]){               
  305.                     if($trainerSelectValue == "" && $trainerValue == "0"){
  306.                         //Original code here no longer needed.             
  307.                     }
  308.                     elseif($extratrainers[0] != ""){
  309.                         if(!in_array($extraTrainer, $extratrainers)){
  310.                             $form -> addElement(\'text\', \'extratrainer[]\', \'extratrainer\', \'value="\'.$extraTrainer.\'"\');
  311.                             $extraCount++;
  312.                         }
  313.                     }
  314.                     else{
  315.                         $form -> addElement(\'text\', \'extratrainer[]\', \'extratrainer\', \'value="\'.$extraTrainer.\'"\');
  316.                         $extraCount++;
  317.                     }
  318.                 }
  319.             }
  320.         }
  321.         if($extraCount == ""){
  322.             $extraCount = 0;
  323.         }
  324.         $smarty -> assign("T_EXTRATRAINERCOUNT", $extraCount);
  325.         $form -> addElement(\'text\', \'courseFee1\', _SDMS_COURSEFEE .": ", array(\'size\' => 3, \'maxlength\' => 3, \'value\' => $feeValue1));
  326.         $form -> addElement(\'text\', \'courseFee2\', \'\', array(\'size\' => 2, \'maxlength\' => 2, \'value\' => $feeValue2));
  327.         $form -> addElement(\'select\', \'currency\', _SDMS_CURRENCY .": ", $currencies, \'style = "width:250px;margin:5px 0 5px 0;" onChange = "updateCurrencySymbol(this);"\');
  328.         $form -> addElement(\'select\', \'venue\', _SDMS_VENUE .": ", $venues, \'onChange = "venueRoomChange(this);" style = "width:250px;margin:5px 0 5px 0;"\');
  329.         $form -> addElement(\'select\', \'venueRoom\', _SDMS_ROOM . ": ", $venueRooms, \'id = "venueRoom" style = "width:250px;margin:5px 0 5px 0;"\');
  330.         $form -> addElement(\'select\', \'owner\', _SDMS_OWNER .": ", $ownersDropDown, \'id = "eventOwner" style = "width:250px;margin:5px 0 5px 0;"\');
  331.         $form -> addElement(\'select\', \'branch\', _SDMS_AVAILABILITY . ": ", $branchDropDown, \'id = "availibility" style = "width:250px;margin:5px 0 5px 0;"\');
  332.         $form -> addElement(\'textarea\', \'scope\', _SDMS_SCOPE .": ", array(\'rows\' => 10, \'cols\' => 90)) -> setValue($scope);
  333.         $form -> addElement(\'textarea\', \'objectives\', _SDMS_OBJECTIVES .": ", array(\'rows\' => 10, \'cols\' => 90)) -> setValue($objectives);
  334.         $form -> addElement(\'textarea\', \'progAims\', _SDMS_AIMS .": ", array(\'rows\' => 10, \'cols\' => 90)) -> setValue($aims);
  335.         $form -> addElement(\'textarea\', \'programme\', _SDMS_PROGRAMME .": ", array(\'rows\' => 10, \'cols\' => 90)) -> setValue($programme);
  336.         $form -> addElement(\'submit\', \'submit_event\', $subtag, \'class = "flatButton"\');
  337.        
  338.         $defaultValues[\'owner\'] = array($owner);
  339.         $defaultValues[\'branch\'] = array($branch);
  340.         $defaultValues[\'currency\'] = array($currency);
  341.         $form -> setDefaults($defaultValues);
  342.        
  343.         if($form -> isSubmitted() && $form -> validate()){
  344.            
  345.             $values = $form -> exportValues();
  346.             $feeValue1 = $values[\'courseFee1\'];
  347.             $feeValue2 = $values[\'courseFee2\'];
  348.             $courseFee = "$feeValue1"."$feeValue2";
  349.             $roomValue = ($values[\'venueRoom\'] != null) ? $values[\'venueRoom\'] : $_POST[\'venueRoom\'];
  350.             $roomValue = ($roomValue == null) ? 0 : $roomValue;
  351.             $trainer = $values[\'trainer\'];
  352.             if(isset($_POST["extratrainer"])){
  353.                 $extratrainers = implode(",", $_POST["extratrainer"]);
  354.             }
  355.             else{
  356.                 $extratrainers = "";
  357.             }
  358.             list($startDay, $startMonth, $startYear) = explode("/", $values[\'startDateNew\']);
  359.             list($endDay, $endMonth, $endYear) = explode("/", $values[\'endDate_New\']);
  360.             list($closeDay, $closeMonth, $closeYear) = explode("/", $values[\'closeDate_New\']);
  361.            
  362.             $start_ts = mktime($values[\'startTime_h\'], $values[\'startTime_m\'], 0, $startMonth, $startDay, $startYear);
  363.             $end_ts = mktime($values[\'endTime_h\'], $values[\'endTime_m\'], 0, $endMonth, $endDay, $endYear);
  364.             $close_hour = ($closeDay == $startDay && $closeMonth == $startMonth && $closeYear == $startYear) ? $values[\'startTime_h\'] : 23;
  365.             $close_min = ($closeDay == $startDay && $closeMonth == $startMonth && $closeYear == $startYear) ? ($values[\'startTime_m\'] - 1) : 59;
  366.            
  367.             $close_ts = mktime($close_hour, $close_min, 59, $closeMonth, $closeDay, $closeYear);
  368.             $edit_ts = date("U");
  369.            
  370.             $eventData = array( \'activitykey\' => $courseID,
  371.                                 \'eventreference\' => $values[\'eventReference\'],
  372.                                 \'maximumnumber\' => $values[\'maxDel\'],
  373.                                 \'eventstatus\' => strtoupper($values[\'status\']),
  374.                                 \'organiser\' => $values[\'organiser\'],
  375.                                 \'owner\' => $values[\'owner\'],
  376.                                 \'branch\' => $values[\'branch\'],
  377.                                 \'trainer\' => $trainer,
  378.                                 \'scope\' => $values[\'scope\'],
  379.                                 \'eventtitle\' => $values[\'eventTitle\'],
  380.                                 \'programmeaims\' => $values[\'progAims\'],
  381.                                 \'programmeobj\' => $values[\'objectives\'],
  382.                                 \'programmeprog\' => $values[\'programme\'],
  383.                                 \'ts_start\' => $start_ts,
  384.                                 \'ts_end\' => $end_ts,
  385.                                 \'ts_close\' => $close_ts,
  386.                                 \'coursefee\' => $courseFee,
  387.                                 \'currency\' => $values[\'currency\'],
  388.                                 \'ts_changed\' => $edit_ts,
  389.                                 \'extratrainers\' => $extratrainers
  390.                             );         
  391.             $sessionData = array(   \'venuekey\' => $values[\'venue\'],
  392.                                     \'roomkey\' => $roomValue
  393.                                 ); 
  394.             $checkReference = $this -> checkEventReference($eventData[\'eventreference\'], $courseID, $eventID);
  395.             $venueRoomClashCheck = $this -> venueRoomClashCheck($roomValue, $start_ts, $end_ts, $eventID);
  396.             $trainerClashCheck = $this -> trainerClashCheck($trainer, $start_ts, $end_ts, $eventID);
  397.             $multiTrainerClashCheck = array();
  398.             if(isset($_POST["extratrainer"])){
  399.                 foreach($_POST["extratrainer"] as $xTrainer){
  400.                     $multiTrainerClashCheck[] = $this -> multiTrainerClashCheck($xTrainer, $start_ts, $end_ts, $eventID);
  401.                 }
  402.             }
  403.             if($trainerClashCheck[0] > 0){                 
  404.                 $eventData[\'eventstatus\'] = "PROP";
  405.             }
  406.             foreach($multiTrainerClashCheck as $multiCheck){
  407.                 if($multiCheck[0]>0){
  408.                     $eventData["eventstatus"] = "PROP";
  409.                 }
  410.             }
  411.             if(strlen($eventData[\'eventreference\']) < 1){
  412.            
  413.                 $t_conf = _SDMS_REFERENCEMISSING;
  414.                 $outcome = "failure";
  415.                
  416.             }elseif(strlen($eventData[\'eventtitle\']) <= 1){
  417.            
  418.                 $t_conf = _SDMS_TITLEMISSING;
  419.                 $outcome = "failure";
  420.                
  421.             }elseif($eventData[\'eventstatus\'] == \'0\'){
  422.            
  423.                 $t_conf = _SDMS_NOSTATUSSELECTED;
  424.            
  425.             }elseif($checkReference === true){
  426.            
  427.                 $t_conf = _SDMS_DUPLICATEREFERENCE;
  428.                 $outcome = "failure";
  429.                
  430.             }elseif($end_ts < $start_ts){
  431.            
  432.                 $t_conf = _SDMS_ENDBEFORESTART;
  433.                 $outcome = "failure";
  434.            
  435.             }elseif($start_ts < $close_ts){
  436.            
  437.                 $t_conf = _SDMS_CLOSEAFTERSTART;
  438.                 $outcome = "failure";
  439.            
  440.             }else{
  441.            
  442.                 if($function == \'edit\'){
  443.                    
  444.                     $temp = eF_getTableData(\'sdms_actevent\',\'eventstatus\',"id=\'".$eventID."\'");
  445.                     $temp = $temp[0][\'eventstatus\'];
  446.                    
  447.                     $eventSession = eF_getTableData(\'sdms_actsessi\',\'id\',"eventkey=\'" . $eventID . "\'");
  448.                    
  449.                     $query = eF_updateTableData(\'sdms_actevent\', $eventData, "id=\'".$eventID."\'");
  450.                    
  451.                     if(count($eventSession) > 0){
  452.                    
  453.                         eF_updateTableData(\'sdms_actsessi\', $sessionData, "eventkey=\'".$eventID."\'");
  454.                    
  455.                     }else{
  456.                        
  457.                         $sessionData[\'activitykey\'] = $courseID;
  458.                         $sessionData[\'eventkey\'] = $eventID;
  459.                         $query = eF_insertTableData(\'sdms_actsessi\', $sessionData);
  460.                    
  461.                     }
  462.  
  463.                     $t_conf = _SDMS_EVENTUPDATED . ": $eventTitle";
  464.                     $outcome = "success";
  465.                    
  466.                     if($temp != $eventData[\'eventstatus\']){
  467.                        
  468.                         $eventCode = ($eventData[\'eventstatus\'] == "CANC" || $eventData[\'eventstatus\'] == "CLOS" || $eventData[\'eventstatus\'] == "DELE" || $eventData[\'eventstatus\'] == "REDN") ? \'ESCC\' : \'ESIU\';
  469.                         $this -> emailEventHandler($eventCode, null, $eventID);
  470.                        
  471.                     }
  472.                    
  473.                     unset($temp);
  474.                    
  475.                 }elseif($function == \'addnew\'){
  476.                    
  477.            
  478.                     $eventID = eF_insertTableData(\'sdms_actevent\', $eventData);
  479.                
  480.                     $sessionData[\'activitykey\'] = $courseID;
  481.                     $sessionData[\'eventkey\'] = $eventID;
  482.                     $query = eF_insertTableData(\'sdms_actsessi\', $sessionData);
  483.                    
  484.                     ($trainerClashCheck[0] <= 0) ? $this -> addCalendarEvent($eventID, $eventData[\'trainer\']) : \'\';
  485.                     $this -> addCalendarEvent($eventID, $eventData[\'organiser\']);
  486.                    
  487.                     $t_conf = _SDMS_EVENTCREATED . ": $eventTitle";
  488.                     $outcome = "success";
  489.                    
  490.                 }
  491.                
  492.                 if($sessionData[\'venuekey\'] != 0 && $sessionData[\'roomkey\'] != 0){
  493.                
  494.                     $updateRoomResources = $this -> assignRoomResourceToEvent($sessionData[\'roomkey\'], $eventID);
  495.                
  496.                 }
  497.                
  498.                 if($venueRoomClashCheck[0] > 0){
  499.                        
  500.                     $t_conf = _SDMS_VENUEROOMCLASH;
  501.                     $outcome = "failure";
  502.                    
  503.                 }
  504.                
  505.                 if($trainerClashCheck[0] > 0){
  506.                    
  507.                     $t_conf = _SDMS_TRAINERCLASH;
  508.                     $outcome = "failure";
  509.                    
  510.                 }
  511.                 foreach($multiTrainerClashCheck as $multiCheck){
  512.                     if($multiCheck[0]>0){
  513.                         $t_conf = "One or more trainers have prior commitments on this date and time, event status set to Proposed.";
  514.                         $outcome = "failure";
  515.                     }
  516.                 }
  517.            
  518.                 $path = $this -> moduleBaseUrl . "&sdms_section=eventoverview&func=edit&ref=$eventID";
  519.                 eF_redirect($path.\'&message=\'.$t_conf.\'&message_type=\'.$outcome);
  520.                
  521.             }
  522.            
  523.             $this -> setMessageVar($t_conf, $outcome);
  524.            
  525.         }
  526.        
  527.         $renderer = prepareFormRenderer($form);
  528.         $form = $renderer -> toArray();
  529.         for($x=0; $x<=sizeof($form); $x++){
  530.             if($form["extratrainer"][$x]["type"] == "text"){
  531.                 $form["extratrainer"][$x]["html"] = str_replace(\'name="extratrainer[]"\', \'name="extratrainer[]" readonly="readonly" style="background-color:#DCDCDC;" \', $form["extratrainer"][$x]["html"]);
  532.             }
  533.         }
  534.         return $form;
  535.     }
');