?> <table class='linedDataTable' style='width:100%'> <tr> <th><?php echo _("General Subject"); ?> </th> <th><?php echo _("Detailed Subject"); ?> </th> <th style='width:20px;'> </th> </tr> <?php foreach ($generalSubjectArray as $ug) { $generalSubject = new GeneralSubject(new NamedArguments(array('primaryKey' => $ug['generalSubjectID']))); echo "<tr>"; echo "<td>" . $generalSubject->shortName . "</td>"; echo "<td>"; foreach ($generalSubject->getDetailedSubjects() as $detailedSubjects) { echo $detailedSubjects->shortName . "<br />"; } echo "</td>"; echo "<td><a href='ajax_forms.php?action=getGeneralDetailSubjectForm&generalSubjectID=" . $generalSubject->generalSubjectID . "&height=400&width=305&modal=true' class='thickbox'><img src='images/edit.gif' alt='" . _("edit") . "' title='" . _("edit") . "'></a></td>"; echo "</tr>"; } ?> </table> <?php } else { echo _("(none found)") . "<br />";
<?php if (isset($_GET['generalSubjectID'])) { $generalSubjectID = $_GET['generalSubjectID']; } else { $generalSubjectID = ''; } $generalSubject = new GeneralSubject(new NamedArguments(array('primaryKey' => $generalSubjectID))); //get all users for output in drop down $allDetailedSubjectArray = array(); $detailedSubjectObj = new DetailedSubject(); $allDetailedSubjectArray = $detailedSubjectObj->allAsArray(); //get Detail Subjects already set up for this General subject in case it's an edit $dsSubjectArray = $generalSubject->getDetailedSubjects(); ?> <div id='div_detailedSubjectForm'> <form id='detailedSubjectForm'> <input type='hidden' name='editgeneralSubjectID' id='editgeneralSubjectID' value='<?php echo $generalSubjectID; ?> '> <div class='formTitle' style='width:280px; margin-bottom:5px;position:relative;'><span class='headerText'><?php echo _("Add / Edit Subject Relationships"); ?> </span></div> <span class='smallDarkRedText' id='span_errors'></span> <table class='noBorder' style='width:100%;'> <tr style='vertical-align:top;'>
<?php $generalSubjectID = $_POST['generalSubjectID']; if ($generalSubjectID != '') { $generalSubject = new GeneralSubject(new NamedArguments(array('primaryKey' => $generalSubjectID))); } else { $generalSubject = new GeneralSubject(); } // Update the General Subject if needed $generalSubject->shortName = str_replace("'", "''", $_POST['shortName']); try { $generalSubject->save(); $generalSubjectID = $generalSubject->primaryKey; $detailSubjectArray = array(); $detailSubjectArray = explode(':::', $_POST['detailSubjectsList']); $detailSubjectIDs = "(-1"; // Update the GeneralDetailSubject Links foreach ($detailSubjectArray as $key => $value) { if ($value) { $generalDetailSubjectLink = new GeneralDetailSubjectLink(); $generalDetailSubjectLink->detailedSubjectID = $value; $generalDetailSubjectLink->generalSubjectID = $generalSubjectID; // Add any Detail Subject Links that are new if ($generalDetailSubjectLink->duplicateCheck() == 0) { // Add the new link try { $generalDetailSubjectLink->save(); } catch (Exception $e) { echo $e->getMessage(); } }
</tr> <tr> <td class='searchRow'><label for='searchGeneralSubjectID'><b>General Subject</b></label> <br /> <select name='search[generalSubjectID]' id='searchGeneralSubjectID' style='width:150px'> <option value=''>All</option> <?php if ($search['generalSubjectID'] == "none") { echo "<option value='none' selected>(none)</option>"; } else { echo "<option value='none'>(none)</option>"; } $display = array(); $generalSubject = new GeneralSubject(); foreach ($generalSubject->allAsArray() as $display) { if ($search['generalSubjectID'] == $display['generalSubjectID']) { echo "<option value='" . $display['generalSubjectID'] . "' selected>" . $display['shortName'] . "</option>"; } else { echo "<option value='" . $display['generalSubjectID'] . "'>" . $display['shortName'] . "</option>"; } } ?> </select> </td> </tr> <tr> <td class='searchRow'><label for='searchDetailedSubjectID'><b>Detailed Subject</b></label> <br />
$generalSubjectID = null; if ($subject['column'] === "") { continue; } if ($subject['delimiter'] !== "") { $subjectArray = array_map('trim', explode($subject['delimiter'], $data[intval($subject['column']) - 1])); } else { $subjectArray = array(trim($data[intval($subject['column']) - 1])); } foreach ($subjectArray as $currentSubject) { $index = searchForShortName($currentSubject, $generalSubjectArray); if ($index !== null) { $generalSubjectID = $generalSubjectArray[$index]['generalSubjectID']; } else { if ($index === null && $currentSubject != '') { $generalSubjectObj = new GeneralSubject(); $generalSubjectObj->shortName = $currentSubject; $generalSubjectObj->save(); $generalSubjectID = $generalSubjectObj->primaryKey; $generalSubjectArray = $generalSubjectObj->allAsArray(); $generalSubjectInserted++; } } if ($generalSubjectID !== null) { $generalDetailSubjectLinkObj = new GeneralDetailSubjectLink(); $generalDetailID = $generalDetailSubjectLinkObj->getGeneralDetailID($generalSubjectID, -1); if ($generalDetailID !== -1) { array_push($generalDetailSubjectLinkIDArray, $generalDetailID); } } }