Commit 6e9d85cc32f8b33abf413b18f2f4fa0066fcbd12
1 parent
f763fe3e
refactored, tidied and added confirmation page for removing document field from document type
(fixes #2639) git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2313 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
119 additions
and
390 deletions
presentation/lookAndFeel/knowledgeTree/administration/doctypemanagement/editDocTypeFieldsBL.php
| ... | ... | @@ -23,174 +23,51 @@ if (checkSession()) { |
| 23 | 23 | require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); |
| 24 | 24 | require_once("$default->fileSystemRoot/presentation/Html.inc"); |
| 25 | 25 | |
| 26 | - | |
| 27 | - $oPatternCustom = & new PatternCustom(); | |
| 28 | - | |
| 29 | - // if a new DocType has been added | |
| 30 | - // coming from manual edit page | |
| 31 | - if (isset($fUpdate)) { | |
| 32 | - | |
| 33 | - //$oDocType = DocumentType::get($fDocTypeID); | |
| 34 | - //$oDocType->setName($fDocTypeName); | |
| 35 | - | |
| 36 | - // store type specific field id's in an array | |
| 37 | - $aGenericDocFields = DocumentField::getGenericFields(); | |
| 38 | - $aSpecificDocFields = DocumentTypeFieldLink::getSpecificFields($fDocTypeID); | |
| 39 | - | |
| 40 | - echo "<li><pre>" . arrayToString($aSpecificDocFields ) . "</pre></li></ul>"; | |
| 41 | - | |
| 42 | - /** | |
| 43 | - if ($oDocType->update()) { | |
| 44 | - // if successfull print out success message | |
| 45 | - $oPatternCustom->setHtml(getEditPageSuccess()); | |
| 46 | - | |
| 47 | - } else { | |
| 48 | - // if fail print out fail message | |
| 49 | - $oPatternCustom->setHtml(getEditPageFail()); | |
| 50 | - } | |
| 51 | - **/ | |
| 52 | - } else if (isset($fDocTypeSelected)){ | |
| 53 | - // post back on DocType select from manual edit page | |
| 54 | - // store type generic field id's in an array | |
| 55 | - $aGenericFields = DocumentField::getGenericFields(); | |
| 56 | - | |
| 57 | - // get all specific fields | |
| 58 | - $aAllSpecificFields = DocumentField::getAllSpecificFields(); | |
| 59 | - | |
| 60 | - | |
| 61 | - // store type specific field id's and names in an array for specifc doctype | |
| 62 | - $aSpecificFields = DocumentTypeFieldLink::getSpecificFields($fDocTypeID); | |
| 63 | - | |
| 64 | - | |
| 65 | - $oPatternCustom->setHtml(getDetailsPage($fDocTypeID, $aGenericFields, $aSpecificFields, $aAllSpecificFields)); | |
| 66 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fShowDetails=1"); | |
| 67 | - | |
| 68 | - | |
| 69 | - }else if(isset($fAdd)) | |
| 70 | - { | |
| 71 | - if($fIsMandatory == 1){ | |
| 72 | - $iMandatory = 1; | |
| 73 | - }else{ | |
| 74 | - $iMandatory = 0; | |
| 26 | + $oPatternCustom = & new PatternCustom(); | |
| 27 | + if ($fDocTypeID) { | |
| 28 | + if ($fDocFieldID) { | |
| 29 | + $oDocTypeFieldLink = DocumentTypeFieldLink::getByFieldAndTypeIDs($fDocTypeID, $fDocFieldID); | |
| 30 | + if (isset($fRemove)) { | |
| 31 | + if ($fConfirm) { | |
| 32 | + $oDocTypeFieldLink = DocumentTypeFieldLink::getByFieldAndTypeIDs($fDocTypeID, $fDocFieldID); | |
| 33 | + if ($oDocTypeFieldLink->delete()) { | |
| 34 | + // success | |
| 35 | + $oPatternCustom->setHtml(getSuccessPage("Document field successfully deleted.", $fDocTypeID)); | |
| 36 | + } else { | |
| 37 | + // failure | |
| 38 | + $oPatternCustom->setHtml(getSuccessPage("Error deleting document field.", $fDocTypeID)); | |
| 39 | + } | |
| 40 | + } else { | |
| 41 | + // ask for confirmation | |
| 42 | + $oPatternCustom->setHtml(getDeleteConfirmationPage($fDocTypeID, $fDocFieldID)); | |
| 43 | + } | |
| 44 | + } else if(isset($fUpdateMandatory)) { | |
| 45 | + if ($fConfirm) { | |
| 46 | + if (isset($fIsMandatory)) { | |
| 47 | + $oDocTypeFieldLink->setIsMandatory(true); | |
| 48 | + } else { | |
| 49 | + $oDocTypeFieldLink->setIsMandatory(false); | |
| 50 | + } | |
| 51 | + $default->log->info("dfl=" . arrayToString($oDocTypeFieldLink)); | |
| 52 | + $oDocTypeFieldLink->update(); | |
| 53 | + $oPatternCustom->setHtml(getDetailsPage($fDocTypeID)); | |
| 54 | + } else { | |
| 55 | + // display edit form | |
| 56 | + $oPatternCustom->setHtml(getEditDocumentFieldLinkPage($oDocTypeFieldLink)); | |
| 57 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fUpdateMandatory=1"); | |
| 58 | + } | |
| 75 | 59 | } |
| 76 | - | |
| 77 | - $oDocTypeField = new DocumentTypeFieldLink($fDocTypeID, $fDocFieldTypeID, $iMandatory); | |
| 78 | - | |
| 79 | - $oDocTypeField->create(); | |
| 80 | - | |
| 81 | - | |
| 82 | - // post back on DocType select from manual edit page | |
| 83 | - // store type generic field id's in an array | |
| 84 | - //$oDocFieldType = new DocumentTypeFieldLink( | |
| 85 | - $aGenericFields = DocumentField::getGenericFields(); | |
| 86 | - | |
| 87 | - // get all specific fields | |
| 88 | - $aAllSpecificFields = DocumentField::getAllSpecificFields(); | |
| 89 | - | |
| 90 | - | |
| 91 | - // store type specific field id's and names in an array for specifc doctype | |
| 92 | - $aSpecificFields = DocumentTypeFieldLink::getSpecificFields($fDocTypeID); | |
| 93 | - | |
| 94 | - $oPatternCustom->setHtml(getDetailsPage($fDocTypeID, $aGenericFields, $aSpecificFields, $aAllSpecificFields)); | |
| 95 | - | |
| 96 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fDocTypeSelected=1"); | |
| 97 | - //$oPatternCustom->setHtml(getEditPageSuccess()); | |
| 98 | - | |
| 99 | - | |
| 100 | - }else if(isset($fRemove)){ | |
| 101 | - | |
| 102 | - $fFieldID = $fRemove; | |
| 103 | - | |
| 104 | - // does'nt matter wot ismandatory is..not checking for it when deleting | |
| 105 | - $iMandatory = 0; | |
| 106 | - //create new object | |
| 107 | - $oDocTypeField = new DocumentTypeFieldLink($fDocTypeID, $fFieldID, $iMandatory); | |
| 108 | - | |
| 109 | - //delete it by first getting hte corresponding id | |
| 110 | - $oDocTypeField ->setDocTypeFieldID($fDocTypeID, $fFieldID); | |
| 111 | - $oDocTypeField->delete(); | |
| 112 | - | |
| 113 | - // post back on DocType select from manual edit page | |
| 114 | - // store type generic field id's in an array | |
| 115 | - //$oDocFieldType = new DocumentTypeFieldLink( | |
| 116 | - $aGenericFields = DocumentField::getGenericFields(); | |
| 117 | - | |
| 118 | - // get all specific fields | |
| 119 | - $aAllSpecificFields = DocumentField::getAllSpecificFields(); | |
| 120 | - | |
| 121 | - | |
| 122 | - // store type specific field id's and names in an array for specifc doctype | |
| 123 | - $aSpecificFields = DocumentTypeFieldLink::getSpecificFields($fDocTypeID); | |
| 124 | - | |
| 125 | - $oPatternCustom->setHtml(getDetailsPage($fDocTypeID, $aGenericFields, $aSpecificFields, $aAllSpecificFields)); | |
| 126 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fDocTypeSelected=1"); | |
| 127 | - | |
| 128 | - }else if(isset($fEdit)){ | |
| 129 | - $fFieldID = $fEdit; | |
| 130 | - | |
| 131 | - $iMandatory = 0; | |
| 132 | - | |
| 133 | - $oDocTypeField = new DocumentTypeFieldLink($fDocTypeID, $fFieldID, $iMandatory); | |
| 134 | - | |
| 135 | - //delete it by first getting hte corresponding id | |
| 136 | - $oDocTypeField ->setDocTypeFieldID($fDocTypeID, $fFieldID); | |
| 137 | - | |
| 138 | - $iDocTypeFieldID = $oDocTypeField->getID(); | |
| 139 | - | |
| 140 | - $oPatternCustom->setHtml(getMandatoryPage($fFieldID,$iDocTypeFieldID)); | |
| 141 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fUpdateMandatory=1"); | |
| 142 | - | |
| 143 | - | |
| 144 | - } else if(isset($fUpdateMandatory)){ | |
| 145 | - | |
| 146 | - $oDocTypeField = new DocumentTypeFieldLink($fDocTypeID, $fFieldID, $fMandatory); | |
| 147 | - | |
| 148 | - //delete it by first getting hte corresponding id | |
| 149 | - $oDocTypeField->setDocTypeFieldID($fDocTypeID, $fFieldID); | |
| 150 | - | |
| 151 | - if(isset($fIsMandatory)){ | |
| 152 | - $oDocTypeField->setIsMandatory(true); | |
| 153 | - }else{ | |
| 154 | - $oDocTypeField->setIsMandatory(false); | |
| 60 | + } else { | |
| 61 | + $oPatternCustom->setHtml(getDetailsPage($fDocTypeID)); | |
| 62 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fUpdateMandatory=1"); | |
| 155 | 63 | } |
| 156 | - | |
| 157 | - $oDocTypeField->update(); | |
| 158 | - | |
| 159 | - | |
| 160 | - | |
| 161 | - // post back on DocType select from manual edit page | |
| 162 | - // store type generic field id's in an array | |
| 163 | - //$oDocFieldType = new DocumentTypeFieldLink( | |
| 164 | - $aGenericFields = DocumentField::getGenericFields(); | |
| 165 | - | |
| 166 | - // get all specific fields | |
| 167 | - $aAllSpecificFields = DocumentField::getAllSpecificFields(); | |
| 168 | - | |
| 169 | - | |
| 170 | - // store type specific field id's and names in an array for specifc doctype | |
| 171 | - $aSpecificFields = DocumentTypeFieldLink::getSpecificFields($fDocTypeID); | |
| 172 | - | |
| 173 | - $oPatternCustom->setHtml(getDetailsPage($fDocTypeID, $aGenericFields, $aSpecificFields, $aAllSpecificFields)); | |
| 174 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fDocTypeSelected=1"); | |
| 175 | - | |
| 176 | - | |
| 177 | - | |
| 178 | - | |
| 179 | - }else { | |
| 180 | - // if nothing happens...just reload edit page | |
| 181 | - $oPatternCustom->setHtml(getEditPage(null)); | |
| 182 | - $main->setFormAction($_SERVER["PHP_SELF"] ."?fDocTypeSelected=1"); | |
| 183 | - | |
| 184 | - | |
| 64 | + } else { | |
| 65 | + // no document type selected to edit | |
| 66 | + // FIXME | |
| 185 | 67 | } |
| 186 | 68 | |
| 187 | - | |
| 188 | - | |
| 189 | - | |
| 190 | - | |
| 191 | - | |
| 192 | 69 | //render the page |
| 193 | 70 | $main->setCentralPayload($oPatternCustom); |
| 194 | 71 | $main->render(); |
| 195 | 72 | } |
| 196 | 73 | -?> |
| 74 | +?> | |
| 197 | 75 | \ No newline at end of file | ... | ... |
presentation/lookAndFeel/knowledgeTree/administration/doctypemanagement/editDocTypeFieldsUI.inc
| ... | ... | @@ -9,287 +9,139 @@ |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | // if its the manual edit page..then display normally |
| 12 | -function getEditPage($iDocTypeID) { | |
| 12 | +function getDetailsPage($iDocTypeID) { | |
| 13 | 13 | global $default; |
| 14 | 14 | $oDocType = null; |
| 15 | 15 | if (isset($iDocTypeID)) { |
| 16 | 16 | $oDocType = DocumentType::get($iDocTypeID); |
| 17 | - | |
| 18 | - } | |
| 19 | - | |
| 20 | - $sToRender .= renderHeading("Edit Document Type"); | |
| 21 | - $sToRender .= "<table>\n"; | |
| 22 | - $sToRender .= "<tr></tr>\n"; | |
| 23 | - $sToRender .= "<tr>\n"; | |
| 24 | - $sToRender .= "<td>Document Type Name: </td><td>" . getDocTypeDisplay($oDocType) . "</td>\n"; | |
| 25 | - $sToRender .= "</tr>\n"; | |
| 26 | - $sToRender .= "<tr>\n"; | |
| 27 | - $sToRender .= "</tr>\n"; | |
| 28 | - $sToRender .= "<tr>\n"; | |
| 29 | - $sToRender .= "</tr>\n"; | |
| 30 | - $sToRender .= "<tr>\n"; | |
| 31 | - $sToRender .= "</tr>\n"; | |
| 32 | - $sToRender .= "<tr>\n"; | |
| 33 | - $sToRender .= "</tr>\n"; | |
| 34 | - $sToRender .= "<tr>\n"; | |
| 35 | - $sToRender .= "</tr>\n"; | |
| 36 | - $sToRender .= "<tr>\n"; | |
| 37 | - $sToRender .= "</tr>\n"; | |
| 38 | - $sToRender .= "<tr>\n"; | |
| 39 | - $sToRender .= "<td></td>" . getUpdateButton($oDocType); | |
| 40 | - $sToRender .= getCancelButton($oDocType); | |
| 41 | - $sToRender .= "</tr>\n"; | |
| 42 | - $sToRender .= "</table>\n"; | |
| 43 | - | |
| 44 | - | |
| 45 | - return $sToRender; | |
| 46 | -} | |
| 47 | - | |
| 48 | -// if its the manual edit page..then display normally | |
| 49 | -function getDetailsPage($iDocTypeID,$aGeneric,$aSpecific, $aAllSpecific) { | |
| 50 | - global $default; | |
| 51 | - $oDocType = null; | |
| 52 | - if (isset($iDocTypeID)) { | |
| 53 | - $oDocType = DocumentType::get($iDocTypeID); | |
| 54 | - | |
| 55 | 17 | } |
| 56 | 18 | |
| 57 | 19 | $sToRender .= renderHeading("Edit Document Type"); |
| 58 | 20 | |
| 59 | 21 | $sToRender .= "<table border=0 width=100%>\n"; |
| 60 | - $sToRender .= "<tr><td><br></br></td><td><td></td><td></td><td></td>" . getCancelButton($oDocType) . "</td></tr>\n"; | |
| 61 | - $sToRender .= "<tr>\n"; | |
| 62 | - $sToRender .= "<td>Document Type Name: </td><td><input type=hidden name=\"fDocTypeID\" value=\"" . $iDocTypeID . "\">" . getDocTypeDisplay($oDocType) . "</td>\n"; | |
| 63 | - $sToRender .= "</tr>\n"; | |
| 64 | - $sToRender .= "<tr></tr>\n"; | |
| 65 | - $sToRender .= "<tr></tr>\n"; | |
| 66 | - $sToRender .= "<tr>\n"; | |
| 67 | - $sToRender .= "<td>Current Generic Fields: </td><td>" . getGenericFieldsList($aGeneric) . "</td>\n"; | |
| 68 | - $sToRender .= "</tr>\n"; | |
| 69 | - $sToRender .= "<tr></tr>\n"; | |
| 70 | - $sToRender .= "<tr></tr>\n"; | |
| 22 | + | |
| 71 | 23 | $sToRender .= "<tr>\n"; |
| 72 | - $sToRender .= "<td>Current Type Specific Fields: </td>"; | |
| 73 | - $sToRender .= "</td></tr>" . getSpecificFieldsList($aSpecific, $iDocTypeID) . "</td>\n"; | |
| 74 | - $sToRender .= "<td></td><td colspan=3>"; | |
| 75 | - $sToRender .= "<hr><a href=\"$default->rootUrl/control.php?action=addDocTypeFieldsLink&fDocTypeID=$iDocTypeID\" ><img border=0 src =\"$default->graphicsUrl/widgets/add.gif\" /><a>"; | |
| 76 | - $sToRender .= " Add new Type Specific Field "; | |
| 77 | - $sToRender .= "</td>"; | |
| 24 | + $sToRender .= "<td width=\"45%\">Document Type Name: </td><td>" . $oDocType->getName() . "</td>\n"; | |
| 78 | 25 | $sToRender .= "</tr>\n"; |
| 26 | + $sToRender .= "<tr><input type=hidden name=\"fDocTypeID\" value=\"" . $iDocTypeID . "\"></tr>\n"; | |
| 79 | 27 | $sToRender .= "<tr></tr>\n"; |
| 80 | - $sToRender .= "<tr><td><br></br></td></tr>\n"; | |
| 81 | - $sToRender .= "<tr></tr>\n"; | |
| 82 | - $sToRender .= "<tr>\n"; | |
| 83 | - /*if(count($aAllSpecific) > 0) { | |
| 84 | - $sToRender .= "<td>Add New Type Specific Field: </td><td>" . addSpecificFieldsList($aAllSpecific) ; | |
| 85 | - $sToRender .= "</td></tr><td></td><td>Mandatory: <input type=\"checkbox\" name=\"fIsMandatory\" value=\"1\" CHECKED></td><td>" . getAddSpecificFieldButton() . "</td>\n"; | |
| 86 | - }*/ | |
| 87 | - $sToRender .= "</tr>\n"; | |
| 88 | - $sToRender .= "<tr><td><br></br></td></tr>\n"; | |
| 28 | + $sToRender .= "<tr><td valign=\"top\">Generic Document Fields: </td><td>" . getGenericFieldsList() . "</td></tr>\n"; | |
| 89 | 29 | $sToRender .= "<tr></tr>\n"; |
| 90 | - $sToRender .= "<tr>\n"; | |
| 91 | - //$sToRender .= "<td></td>" . getUpdateButton($oDocType); | |
| 92 | - $sToRender .= "</tr>\n"; | |
| 30 | + $sToRender .= "<tr><td valign=\"top\">Document Type Specific Fields: </td>"; | |
| 31 | + $sToRender .= "<td>" . getDocumentTypeFieldsList($iDocTypeID) . "</td></tr>\n"; | |
| 32 | + $sToRender .= "<tr><td >" . generateControllerLink("addDocTypeFieldsLink", "fDocTypeID=$iDocTypeID", "Add new Type Specific Field <img border=0 src=\"$default->graphicsUrl/widgets/add.gif\"/>"); | |
| 33 | + $sToRender .= generateControllerLink("listDocTypes", "", "<img border=0 src=\"$default->graphicsUrl/widgets/back.gif\"/>"). "</td></tr>\n"; | |
| 93 | 34 | $sToRender .= "</table>\n"; |
| 94 | 35 | |
| 95 | - | |
| 96 | 36 | return $sToRender; |
| 97 | 37 | } |
| 98 | 38 | |
| 99 | -// if its the manual edit page..then display normally | |
| 100 | -function getMandatoryPage($iDocFieldID,$iDocTypeFieldID) { | |
| 101 | - global $default; | |
| 102 | - $oDocField = null; | |
| 103 | - | |
| 104 | - if (isset($iDocFieldID)) { | |
| 105 | - $oDocField = DocumentField::get($iDocFieldID); | |
| 106 | - | |
| 107 | - } | |
| 39 | +function getDeleteConfirmationPage($iDocTypeID, $iDocFieldID) { | |
| 40 | + global $default; | |
| 108 | 41 | |
| 109 | - if (isset($iDocTypeFieldID)) { | |
| 110 | - $oDocTypeField = DocumentTypeFieldLink::get($iDocTypeFieldID); | |
| 111 | - | |
| 112 | - } | |
| 113 | - | |
| 114 | - $sToRender .= "<input type=\"hidden\" height=0 name=\"fDocTypeID\" value=\"" . $oDocTypeField->iDocumentTypeID . "\">\n" ; | |
| 115 | - $sToRender .= "<input type=\"hidden\" height=0 name=\"fFieldID\" value=\"" . $oDocTypeField->iFieldID . "\">\n" . | |
| 116 | - //$sToRender .= renderHeading("Edit Mandatory settings"); | |
| 117 | - $sToRender .= "<br></br>\n"; | |
| 118 | - | |
| 119 | - $sToRender .= "<b>Change Mandatory Setting:</b>\n"; | |
| 120 | - $sToRender .= "<table>\n"; | |
| 121 | - $sToRender .= "<br></br>\n"; | |
| 122 | - $sToRender .= "<tr></tr>\n"; | |
| 123 | - $sToRender .= "<tr>\n"; | |
| 124 | - $sToRender .= "<td>Document Field Name: </td><td>" . $oDocField->getName() . "</td>\n"; | |
| 125 | - $sToRender .= "</tr>\n"; | |
| 126 | - $sToRender .= "<tr>\n"; | |
| 127 | - $sToRender .= "</tr>\n"; | |
| 128 | - $sToRender .= "<tr>\n"; | |
| 129 | - if($oDocTypeField->getIsMandatory() == 1) { | |
| 130 | - $sToRender .= "<td>Is Mandatory: </td><td><input type=\"checkbox\" name=\"fIsMandatory\" value=\"1\" CHECKED></td><td>\n"; | |
| 131 | - } else { | |
| 132 | - $sToRender .= "<td>Is Mandatory: </td><td><input type=\"checkbox\" name=\"fIsMandatory\" value=\"0\" ></td><td>\n"; | |
| 133 | - } | |
| 134 | - | |
| 135 | - $sToRender .= "</tr>\n"; | |
| 136 | - $sToRender .= "<tr>\n"; | |
| 137 | - $sToRender .= "</tr>\n"; | |
| 138 | - $sToRender .= "<tr>\n"; | |
| 139 | - $sToRender .= "</tr>\n"; | |
| 140 | - $sToRender .= "<tr>\n"; | |
| 141 | - $sToRender .= "</tr>\n"; | |
| 142 | - $sToRender .= "<tr>\n"; | |
| 143 | - $sToRender .= "</tr>\n"; | |
| 144 | - $sToRender .= "<tr>\n"; | |
| 145 | - $sToRender .= "<td></td>" . getDocTypeFieldUpdateButton() ; | |
| 146 | - $sToRender .= "</tr>\n"; | |
| 147 | - | |
| 42 | + $oDocType = DocumentType::get($iDocTypeID); | |
| 43 | + $oDocField = DocumentField::get($iDocFieldID); | |
| 44 | + | |
| 45 | + $sToRender .= renderHeading("Edit Document Type - Delete Document Field Link"); | |
| 46 | + $sToRender .= "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">\n"; | |
| 47 | + $sToRender .= "<tr><td>Are you sure you want to remove field '" . $oDocField->getName(). "' from document type '" . $oDocType->getName() ."'?</td></tr>\n"; | |
| 48 | + $sToRender .= "<tr/><tr/>\n"; | |
| 49 | + $sToRender .= "<tr><td>Click 'Remove' to remove the link, or 'Cancel' to abort.</td></tr>\n"; | |
| 50 | + $sToRender .= "<tr/><tr/>\n"; | |
| 51 | + $sToRender .= "<td align=\"right\">" . generateControllerLink("editDocTypeFields", "fConfirm=1&fRemove=1&fDocFieldID=$iDocFieldID&fDocTypeID=$iDocTypeID", "<img src =\"$default->graphicsUrl/widgets/remove.gif\" border = \"0\" />"); | |
| 52 | + $sToRender .= generateControllerLink("editDocTypeFields", "fDocTypeID=$iDocTypeID", "<img src =\"$default->graphicsUrl/widgets/cancel.gif\" border = \"0\" />") . "</td>\n"; | |
| 148 | 53 | $sToRender .= "</table>\n"; |
| 149 | - | |
| 150 | - | |
| 151 | 54 | return $sToRender; |
| 152 | 55 | } |
| 153 | 56 | |
| 154 | -// if edition is successful print otu success page | |
| 155 | -function getEditPageSuccess() { | |
| 57 | +function getEditDocumentFieldLinkPage($oDocTypeFieldLink) { | |
| 156 | 58 | global $default; |
| 157 | 59 | |
| 158 | - $sToRender .= renderHeading("Edit Document Type"); | |
| 60 | + $oDocField = DocumentField::get($oDocTypeFieldLink->getFieldID()); | |
| 61 | + | |
| 62 | + $sToRender .= renderHeading("Edit Document Type - Update Document Field Link Mandatory Setting"); | |
| 159 | 63 | $sToRender .= "<table>\n"; |
| 160 | - $sToRender .= "<tr><td><b>Success!</b></td></tr>\n"; | |
| 161 | - $sToRender .= "<tr><td>The Document Type was successfully modified</td></tr>\n"; | |
| 162 | - $sToRender .= "<tr></tr>\n"; | |
| 163 | - $sToRender .= "<tr></tr>\n"; | |
| 64 | + $sToRender .= "<input type=\"hidden\" name=\"fConfirm\" value=\"1\">\n"; | |
| 65 | + $sToRender .= "<input type=\"hidden\" name=\"fDocTypeID\" value=\"" . $oDocTypeFieldLink->getDocumentTypeID() . "\">\n"; | |
| 66 | + $sToRender .= "<input type=\"hidden\" name=\"fDocFieldID\" value=\"" . $oDocTypeFieldLink->getFieldID() . "\">\n"; | |
| 164 | 67 | $sToRender .= "<tr>\n"; |
| 165 | - $sToRender .= "<td></td><td align = right><a href=\"$default->rootUrl/control.php?action=listDocTypes\"><img src =\"$default->graphicsUrl/widgets/back.gif\" border = \"0\" /></a></td>\n"; | |
| 68 | + $sToRender .= "<td>Document Field Name: </td><td>" . $oDocField->getName() . "</td>\n"; | |
| 69 | + $sToRender .= "</tr>\n"; | |
| 70 | + $sToRender .= "<tr/>\n"; | |
| 71 | + $sToRender .= "<tr>\n"; | |
| 72 | + $sToRender .= "<td>Mandatory: </td><td><input type=\"checkbox\" name=\"fIsMandatory\" value=\"1\" " . ($oDocTypeFieldLink->getIsMandatory() ? "CHECKED" : "") . "></td>\n"; | |
| 166 | 73 | $sToRender .= "</tr>\n"; |
| 74 | + $sToRender .= "<tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/update.gif\"/>"; | |
| 75 | + $sToRender .= generateControllerLink("editDocTypeFields", "fDocTypeID=" . $oDocTypeFieldLink->getDocumentTypeID(), "<img src =\"$default->graphicsUrl/widgets/cancel.gif\" border = \"0\" />") . "</td></tr>\n"; | |
| 167 | 76 | $sToRender .= "</table>\n"; |
| 168 | - | |
| 169 | 77 | return $sToRender; |
| 170 | 78 | } |
| 171 | 79 | |
| 172 | -// gets the page if editing fails | |
| 173 | -function getEditPageFail() { | |
| 174 | - global $default; | |
| 175 | 80 | |
| 81 | +function getStatusPage($sHeading, $sText = "", $iDocTypeID) { | |
| 82 | + global $default; | |
| 83 | + | |
| 176 | 84 | $sToRender .= renderHeading("Edit Document Type"); |
| 177 | - $sToRender .= "<table>\n"; | |
| 178 | - $sToRender .= "<tr><td><b>Failure!</b></td></tr>\n"; | |
| 179 | - $sToRender .= "<tr><td>Document Type modification Failed!</td></tr>\n"; | |
| 180 | - $sToRender .= "<tr></tr>\n"; | |
| 181 | - $sToRender .= "<tr></tr>\n"; | |
| 85 | + $sToRender .= "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">\n"; | |
| 182 | 86 | $sToRender .= "<tr>\n"; |
| 183 | - $sToRender .= "<td></td><td align = right><a href=\"$default->rootUrl/control.php?action=listDocTypes\"><img src =\"$default->graphicsUrl/widgets/back.gif\" border = \"0\" /></a></td>\n"; | |
| 87 | + $sToRender .= "<td><b>$sHeading</b></td>\n"; | |
| 184 | 88 | $sToRender .= "</tr>\n"; |
| 89 | + $sToRender .= "<tr/><tr/>\n"; | |
| 90 | + $sToRender .= "<tr><td>$sText</td></tr>\n"; | |
| 91 | + $sToRender .= "<tr/><tr/>\n"; | |
| 92 | + $sToRender .= "<td align=\"right\">" . generateControllerLink("editDocTypeFields", "fDocTypeID=$iDocTypeID", "<img src =\"$default->graphicsUrl/widgets/back.gif\" border = \"0\" />") . "</td>\n"; | |
| 185 | 93 | $sToRender .= "</table>\n"; |
| 186 | - | |
| 187 | 94 | return $sToRender; |
| 188 | 95 | } |
| 189 | 96 | |
| 190 | -// show the list box when no DocType selected | |
| 191 | -// then shows a text box with the DocType's name | |
| 192 | -function getDocTypeDisplay($oDocType) { | |
| 193 | - global $default; | |
| 194 | - if (!isset($oDocType)) { | |
| 195 | - $oPatternListBox = & new PatternListBox($default->owl_document_types_table, "name", "id", "fDocTypeID"); | |
| 196 | - // only restrict doc type editing for non sys admins | |
| 197 | - if (!Permission::userIsSystemAdministrator()) { | |
| 198 | - $oPatternListBox->setFromClause("LEFT OUTER JOIN $default->owl_documents_table D on ST.id=D.document_type_id"); | |
| 199 | - $oPatternListBox->setWhereClause("ISNULL(D.id)"); | |
| 200 | - } | |
| 201 | - $oPatternListBox->setPostBackOnChange(true); | |
| 202 | - return $oPatternListBox->render(); | |
| 203 | - } else { | |
| 204 | - return $oDocType->getName(); | |
| 205 | - } | |
| 206 | - | |
| 207 | -} | |
| 208 | - | |
| 209 | -function getGenericFieldsList($aGeneric) { | |
| 210 | - global $default; | |
| 211 | - | |
| 212 | - $sList = "</tr><tr><td></td><td>"; | |
| 213 | - for($i = 0; $i < count($aGeneric);$i++) { | |
| 214 | - $sList .= "<li>" . $aGeneric[$i]["name"]. "</li>\n"; | |
| 215 | - } | |
| 216 | - $sList .= "</td></tr>"; | |
| 217 | - return $sList; | |
| 97 | +// if addition is successful print otu success page | |
| 98 | +function getSuccessPage($sMessage, $iDocTypeID) { | |
| 99 | + return getStatusPage("Success!", $sMessage, $iDocTypeID); | |
| 218 | 100 | } |
| 219 | 101 | |
| 220 | -function getSpecificFieldsList1($aSpecific) { | |
| 221 | - global $default; | |
| 222 | - $sList .= "<select name=fEdit>"; | |
| 223 | - for($i = 0; $i < count($aSpecific);$i++) { | |
| 224 | - $oDocField = DocumentField::get($aSpecific[$i]); | |
| 225 | - $sList .= "<tr><td></td><td><li>" . $oDocField->getName() . "</li></td><td>" . getEditSpecificFieldButton($aSpecific[$i]) ." ". getRemoveSpecificFieldButton($aSpecific[$i]) . "</td></tr>\n"; | |
| 226 | - } | |
| 227 | - return $sList; | |
| 228 | -} | |
| 229 | - | |
| 230 | -function getSpecificFieldsList($aSpecific, $iDocTypeID = null) { | |
| 231 | - global $default; | |
| 232 | - for($i = 0; $i < count($aSpecific);$i++) { | |
| 233 | - $oDocField = DocumentField::get($aSpecific[$i]); | |
| 234 | - $sList .= "<tr><td></td><td><li>" . $oDocField->getName() . "</li></td><td>" . getEditSpecificFieldButton($aSpecific[$i],$iDocTypeID) ." ". getRemoveSpecificFieldButton($aSpecific[$i], $iDocTypeID) . "</td></tr>\n"; | |
| 235 | - } | |
| 236 | - return $sList; | |
| 102 | +// gets the page if editing fails | |
| 103 | +function getFailurePage($sMessage, $iDocTypeID) { | |
| 104 | + return getStatusPage("Failure!", $sMessage, $iDocTypeID); | |
| 237 | 105 | } |
| 238 | 106 | |
| 239 | -// show Group details on confirm deletion page | |
| 240 | -function addSpecificFieldsList($aAllSpecific) { | |
| 107 | +function getGenericFieldsList() { | |
| 241 | 108 | global $default; |
| 242 | - | |
| 243 | - $sDocFieldType = "<Select Name=\"fDocFieldTypeID\">"; | |
| 244 | - for ($i=0;$i < count($aAllSpecific);$i++) { | |
| 245 | - $Options .= "<OPTION value= \"". $aAllSpecific[$i]["id"] . "\">". $aAllSpecific[$i]["name"] ."</OPTION>\n"; | |
| 109 | + $aGenericDocumentFields = DocumentField::getList("is_generic=1"); | |
| 110 | + for($i = 0; $i < count($aGenericDocumentFields); $i++) { | |
| 111 | + $sToRender .= "<li>" . $aGenericDocumentFields[$i]->getName() . "</li>\n"; | |
| 246 | 112 | } |
| 247 | - $sDocFieldType .= $Options . "</SELECT>"; | |
| 248 | - | |
| 249 | - return $sDocFieldType; | |
| 113 | + return $sToRender; | |
| 250 | 114 | } |
| 251 | 115 | |
| 252 | -// gets the updatebutton when a DocType is selected | |
| 253 | -function getUpdateButton($oDocType) { | |
| 254 | - global $default; | |
| 255 | - if (!isset($oDocType)) { | |
| 256 | - return "Please select a Document Type: "; | |
| 257 | - } else { | |
| 258 | - return "<td align = right><input ONCLICK=\" setActionAndSubmit('" . $_SERVER["PHP_SELF"] ."?fUpdate=1')\" type=\"image\" src =\"$default->graphicsUrl/widgets/update.gif\" value=\"submit\" /></td>\n"; | |
| 116 | +function getDocumentTypeFieldsList($iDocTypeID) { | |
| 117 | + global $default; | |
| 118 | + $aDocumentTypeFields = DocumentTypeFieldLink::getDocumentTypeFields($iDocTypeID); | |
| 119 | + $sToRender .= "<table border=0>"; | |
| 120 | + for($i = 0; $i < count($aDocumentTypeFields); $i++) { | |
| 121 | + $oDocField = $aDocumentTypeFields[$i]; | |
| 122 | + if ($oDocField) { | |
| 123 | + $oDocumentTypeFieldLink = DocumentTypeFieldLink::getByFieldAndTypeIDs($iDocTypeID, $oDocField->getID()); | |
| 124 | + $sToRender .= "<tr>"; | |
| 125 | + $sToRender .= "<td>" . $oDocField->getName() . "</td>"; | |
| 126 | + $sToRender .= "<td><img src=\"$default->graphicsUrl/widgets/" . ($oDocumentTypeFieldLink->getIsMandatory() ? "checked" : "unchecked") . ".gif\"/></td>"; | |
| 127 | + $sToRender .= "<td>" . getEditSpecificFieldButton($oDocField->getID(), $iDocTypeID) . "</td>"; | |
| 128 | + $sToRender .= "<td>" . getRemoveSpecificFieldButton($oDocField->getID(), $iDocTypeID) . "</td>"; | |
| 129 | + $sToRender .= "</tr>"; | |
| 130 | + } else { | |
| 131 | + // FIXME: what about broken links? | |
| 132 | + } | |
| 259 | 133 | } |
| 134 | + $sToRender .= "</table>\n"; | |
| 135 | + return $sToRender; | |
| 260 | 136 | } |
| 261 | 137 | |
| 262 | -// gets the updatebutton when a DocType is selected | |
| 263 | -function getDocTypeFieldUpdateButton() { | |
| 264 | - global $default; | |
| 265 | - return "<td align = right><input ONCLICK=\" setActionAndSubmit('" . $_SERVER["PHP_SELF"] ."?fUpdateMandatory=1')\" type=\"image\" src =\"$default->graphicsUrl/widgets/update.gif\" value=\"submit\" /></td>\n"; | |
| 266 | -} | |
| 267 | - | |
| 268 | -function getRemoveSpecificFieldButton($iNumber, $iDocTypeID=null) { | |
| 269 | - global $default; | |
| 270 | - //Return "<input ONCLICK=\" setActionAndSubmit('" . $_SERVER["PHP_SELF"] ."?fRemove=$iNumber')\" align = \"absmiddle\" type=\"image\" src =\"$default->graphicsUrl/widgets/remove.gif\" value=\"remove\" />\n"; | |
| 271 | - return "<a href=\"" . $_SERVER["PHP_SELF"] . "?fRemove=" . $iNumber . "&fDocTypeID=" . $iDocTypeID . "\"> <img border=0 src =\"$default->graphicsUrl/widgets/remove.gif\" value=\"edit\" /></a>\n"; | |
| 272 | -} | |
| 273 | - | |
| 274 | -function getEditSpecificFieldButton($iNumber, $iDocTypeID=null) { | |
| 275 | - global $default; | |
| 276 | - //return "<input ONCLICK=\" setActionAndSubmit('" . $_SERVER["PHP_SELF"] ."?fEdit=$iNumber')\" align = \"absmiddle\" type=\"image\" src =\"$default->graphicsUrl/widgets/edit.gif\" value=\"edit\" />\n"; | |
| 277 | - return "<a href=\"" . $_SERVER["PHP_SELF"] . "?fEdit=" . $iNumber . "&fDocTypeID=" . $iDocTypeID . "\"> <img border=0 src =\"$default->graphicsUrl/widgets/edit.gif\" value=\"edit\" /></a>\n"; | |
| 278 | -} | |
| 279 | - | |
| 280 | -function getAddSpecificFieldButton() { | |
| 138 | +function getEditSpecificFieldButton($iDocFieldID, $iDocTypeID) { | |
| 281 | 139 | global $default; |
| 282 | - return "<input ONCLICK=\" setActionAndSubmit('" . $_SERVER["PHP_SELF"] ."?fAdd=1')\" align = \"absmiddle\" type=\"image\" src =\"$default->graphicsUrl/widgets/add.gif\" value=\"add\" />\n"; | |
| 140 | + return generateControllerLink("editDocTypeFields", "fUpdateMandatory=1&fDocFieldID=$iDocFieldID&fDocTypeID=$iDocTypeID", "<img border=0 src =\"$default->graphicsUrl/widgets/edit.gif\" value=\"edit\" />"); | |
| 283 | 141 | } |
| 284 | 142 | |
| 285 | -// gets the cancel button when a DocType is selected | |
| 286 | -function getCancelButton($oDocType) { | |
| 143 | +function getRemoveSpecificFieldButton($iDocFieldID, $iDocTypeID) { | |
| 287 | 144 | global $default; |
| 288 | - if (!isset($oDocType)) { | |
| 289 | - return "<td align = right><a href=\"$default->rootUrl/control.php?action=doctypeManagement\"><img src =\"$default->graphicsUrl/widgets/cancel.gif\" value=\"cancel\" border = \"0\"/></a></td>\n"; | |
| 290 | - } | |
| 291 | - else { | |
| 292 | - return "<td align = right><a href=\"$default->rootUrl/control.php?action=listDocTypes\"><img src =\"$default->graphicsUrl/widgets/back.gif\" border = \"0\" /></a></td>\n"; | |
| 293 | - } | |
| 145 | + return generateControllerLink("editDocTypeFields", "fRemove=1&fDocFieldID=$iDocFieldID&fDocTypeID=$iDocTypeID", "<img border=0 src =\"$default->graphicsUrl/widgets/remove.gif\" value=\"remove\" />"); | |
| 294 | 146 | } |
| 295 | 147 | ?> |
| 296 | 148 | \ No newline at end of file | ... | ... |