/**
  * editTable ajax
  */
 private function ajaxeditTable()
 {
     if (!$this->hasACL('edit_course')) {
         $this->doNoAccessError();
     }
     $training_id = $this->_getParam('id');
     $do = $this->_getParam('edittable');
     if (!$training_id) {
         // user is adding a new session (which does not have an id yet)
         $this->sendData(array('0' => 0));
         return;
     }
     $action = $this->_getParam('a');
     $row_id = $this->_getParam('row_id');
     if ($do == 'trainer') {
         // update trainer table
         require_once 'models/table/Training.php';
         if ($action == 'add') {
             $days = $this->_getParam('days');
             $result = TrainingToTrainer::addTrainerToTraining($row_id, $training_id, $days);
             $sendRay['insert'] = $result;
             if ($result == -1) {
                 $sendRay['error'] = t('This') . ' ' . t('trainer') . ' ' . t('is already in this training session.');
             }
             $this->sendData($sendRay);
         } elseif ($action == 'del') {
             $tableObj = new TrainingToTrainer();
             $result = $tableObj->delete("id={$row_id}", true);
             $this->sendData(array('delete' => $result));
         } else {
             // update a row?
             $days = $this->_getParam('duration_days');
             if ($days) {
                 $tableObj = new TrainingToTrainer();
                 $result = $tableObj->update(array("duration_days" => $days), "id={$row_id}");
                 $sendRay['update'] = $result;
                 if (!$result) {
                     $sendRay['error'] = t('Could not update this record.');
                 }
                 $this->sendData($sendRay);
             }
         }
     } else {
         if ($do == 'persons') {
             // update person table
             require_once 'models/table/PersonToTraining.php';
             $tableObj = new PersonToTraining();
             if ($action == 'add') {
                 $result = $tableObj->addPersonToTraining($row_id, $training_id);
                 $sendRay['insert'] = $result;
                 if ($result == -1) {
                     $sendRay['error'] = t('This') . ' ' . t('participant') . ' ' . t('is already in this training session.');
                 }
                 $this->sendData($sendRay);
             } elseif ($action == 'del') {
                 $result = $tableObj->delete("id={$row_id}", true);
                 $this->sendData(array('delete' => $result));
             } else {
                 // update a row?
                 $days = $this->getSanParam('duration_days');
                 if ($days !== "") {
                     $tableObj = new PersonToTraining();
                     $result = $tableObj->update(array("duration_days" => $days), "id={$row_id}");
                     $sendRay['update'] = $result;
                     if (!$result) {
                         $sendRay['error'] = t('Could not update this record.');
                     }
                     $this->sendData($sendRay);
                 }
                 $award_id = $this->getSanParam('award_phrase');
                 if ($award_id !== "") {
                     $tableObj = new PersonToTraining();
                     $result = $tableObj->update(array("award_id" => $award_id), "id={$row_id}");
                     $sendRay['update'] = $result;
                     if (!$result) {
                         $sendRay['error'] = t('Could not update this record.');
                     }
                     $this->sendData($sendRay);
                 }
                 $viewing_loc_option_id = $this->getSanParam('location_phrase');
                 if ($viewing_loc_option_id !== "") {
                     $tableObj = new PersonToTraining();
                     $result = $tableObj->update(array("viewing_location_option_id" => $viewing_loc_option_id), "id={$row_id}");
                     $sendRay['update'] = $result;
                     if (!$result) {
                         $sendRay['error'] = t('Could not update this record.');
                     }
                     $this->sendData($sendRay);
                 }
                 $budget_code_option_id = $this->getSanParam('budget_code_phrase');
                 if ($budget_code_option_id !== "") {
                     $tableObj = new PersonToTraining();
                     $result = $tableObj->update(array("budget_code_option_id" => $budget_code_option_id), "id={$row_id}");
                     $sendRay['update'] = $result;
                     if (!$result) {
                         $sendRay['error'] = t('Could not update this record.');
                     }
                     $this->sendData($sendRay);
                 }
             }
         }
     }
     // update "modified_by" field in training table
     $tableObj = new Training();
     $tableObj->update(array(), "id = {$training_id}");
 }