PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/1.1.4/system/application/controllers/retentionSchedule.php

http://records-authority.googlecode.com/
PHP | 387 lines | 200 code | 29 blank | 158 comment | 23 complexity | 2e15a0446f1e3e39eb0cbb42da2cf090 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * Copyright 2008 University of Denver--Penrose Library--University Records Management Program
  4. * Author fernando.reyes@du.edu
  5. *
  6. * This file is part of Records Authority.
  7. *
  8. * Records Authority is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * Records Authority is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with Records Authority. If not, see <http://www.gnu.org/licenses/>.
  20. **/
  21. class RetentionSchedule extends Controller {
  22. public function __construct() {
  23. parent::Controller();
  24. // admin user must be loggedin
  25. $this->load->model('SessionManager');
  26. $this->SessionManager->isAdminLoggedIn();
  27. $this->load->model('UpkeepModel');
  28. $this->load->model('LookUpTablesModel');
  29. $this->load->model('JsModel');
  30. }
  31. /**
  32. * renders retention schedule view
  33. *
  34. * @return void
  35. */
  36. public function view() {
  37. $siteUrl = site_url();
  38. //$data['dispositions'] = $this->RetentionScheduleModel->getDispositions();
  39. $data['divisions'] = $this->LookUpTablesModel->createRsDivisionDropDown();
  40. // js
  41. $data['unitScript'] = $this->JsModel->departmentWidgetJs($siteUrl);
  42. $data['unitRadioButtonScript'] = $this->JsModel->departmentRadioButtonWidgetJs($siteUrl);
  43. $data['unitRadioButtonCheckScript'] = $this->JsModel->officeOfPrimaryResponsibilitydepartmentCheckWidgetJs($siteUrl);
  44. //$data['dispositionScript'] = $this->JsModel->dispositionWidgetJs($siteUrl);
  45. $data['assocUnitsScript'] = $this->JsModel->associatedUnitWidgetJs($siteUrl);
  46. $data['checkAllScript'] = $this->JsModel->associatedUnitCheckAllWidgetJs($siteUrl);
  47. $data['uncheckAllScript'] = $this->JsModel->associatedUnitUnCheckAllWidgetJs($siteUrl);
  48. $data['checkDeptScript'] = $this->JsModel->associatedUnitDeptCheck($siteUrl);
  49. $data['uncheckDeptScript'] = $this->JsModel->associatedUnitDeptUnCheck($siteUrl);
  50. // when form is triggered from record type form
  51. if ($this->uri->segment(3)) {
  52. $recordInformationID = $this->uri->segment(3);
  53. $data['recordInformation'] = $this->RetentionScheduleModel->getRecordInformation($recordInformationID);
  54. } else {
  55. $data['recordCategories'] = $this->LookUpTablesModel->getRecordCategories();
  56. }
  57. $this->load->view('admin/forms/retentionSchedule/addRetentionScheduleForm', $data);
  58. }
  59. /**
  60. * saves retention schedule
  61. *
  62. * @return void
  63. */
  64. public function save() {
  65. if (isset($_POST['retentionPeriod'])) {
  66. $retentionScheduleID = $this->RetentionScheduleModel->saveRetentionSchedule($_POST);
  67. // go into edit mode immediately after save
  68. $this->edit($retentionScheduleID);
  69. }
  70. }
  71. /**
  72. * updates retention schedule
  73. *
  74. * @return void
  75. */
  76. public function update() {
  77. if (isset($_POST['retentionScheduleID'])) {
  78. $retentionScheduleID = $_POST['retentionScheduleID'];
  79. $this->RetentionScheduleModel->updateRetentionSchedule($_POST);
  80. $this->edit($retentionScheduleID);
  81. }
  82. }
  83. /**
  84. * pulls retention schedule record into edit mode
  85. *
  86. * @param $retentionScheduleID
  87. * @return void
  88. */
  89. public function edit($retentionScheduleID="") {
  90. $siteUrl = site_url();
  91. //$data['dispositions'] = $this->RetentionScheduleModel->getDispositions();
  92. $data['divisions'] = $this->LookUpTablesModel->createDivisionDropDown();
  93. $data['recordCategories'] = $this->LookUpTablesModel->getRecordCategories();
  94. //js
  95. $data['unitScript'] = $this->JsModel->departmentWidgetJs($siteUrl);
  96. $data['unitRadioButtonScript'] = $this->JsModel->departmentRadioButtonWidgetJs($siteUrl);
  97. $data['unitRadioButtonCheckScript'] = $this->JsModel->officeOfPrimaryResponsibilitydepartmentCheckWidgetJs($siteUrl);
  98. //$data['dispositionScript'] = $this->JsModel->dispositionWidgetJs($siteUrl);
  99. $data['assocUnitsScript'] = $this->JsModel->associatedUnitWidgetJs($siteUrl);
  100. $data['checkAllScript'] = $this->JsModel->associatedUnitCheckAllWidgetJs($siteUrl);
  101. $data['uncheckAllScript'] = $this->JsModel->associatedUnitUnCheckAllWidgetJs($siteUrl);
  102. $data['checkDeptScript'] = $this->JsModel->associatedUnitDeptCheck($siteUrl);
  103. $data['uncheckDeptScript'] = $this->JsModel->associatedUnitDeptUnCheck($siteUrl);
  104. if (isset($_POST['retentionScheduleID'])) {
  105. $retentionScheduleID = $_POST['retentionScheduleID'];
  106. }
  107. if ($retentionScheduleID !== "") {
  108. $retentionScheduleResults = $this->RetentionScheduleModel->editRetentionSchedule($retentionScheduleID);
  109. // get divisionID out of array to get associated departments
  110. $divisionID = $retentionScheduleResults['divisionID'];
  111. $data['retentionSchedule'] = $retentionScheduleResults;
  112. $data['oprDepartments'] = $this->LookUpTablesModel->setDepartments($divisionID);
  113. $this->load->view('admin/forms/retentionSchedule/editRetentionScheduleForm', $data);
  114. }
  115. }
  116. /**
  117. * updates office of primary responsibility
  118. *
  119. * @param $_POST
  120. * @return void
  121. */
  122. public function updateOfficeOfPrimaryResponsibility() {
  123. if (isset($_POST['departmentID'])) {
  124. $this->RetentionScheduleModel->updateOfficeOfPrimaryResponsibility($_POST);
  125. }
  126. }
  127. /**
  128. * retrieves checked associated units
  129. *
  130. * @param $_POST
  131. * @return $checkedAssociatedUnits
  132. */
  133. public function editCheckAllAssociatedUnits() {
  134. $checkedAssociatedUnits = $this->LookUpTablesModel->editCheckAllAssociatedUnits($_POST);
  135. echo $checkedAssociatedUnits;
  136. }
  137. /**
  138. * retrieves unchecked associated units
  139. *
  140. * @param $_POST
  141. * @return $unCheckedAssociatedUnits
  142. */
  143. public function editUnCheckAllAssociatedUnits() {
  144. $unCheckedAssociatedUnits = $this->LookUpTablesModel->editUnCheckAllAssociatedUnits($_POST);
  145. echo $unCheckedAssociatedUnits;
  146. }
  147. /** not used **
  148. * gets disposition details
  149. *
  150. * @param $dispositionID
  151. * @return $dispositionDetails
  152. */
  153. public function getDispositionDetails() {
  154. $dispositionID = $_POST['dispositionID'];
  155. $dispositionDetails = $this->RetentionScheduleModel->getDispositionDetails($dispositionID);
  156. if (is_array($dispositionDetails)) {
  157. foreach ($dispositionDetails as $details) {
  158. echo $details;
  159. }
  160. } else {
  161. echo $dispositionDetails;
  162. }
  163. }
  164. /**
  165. * gets associated units
  166. *
  167. * @param $_POST
  168. * @return $associatedUnits
  169. */
  170. public function getAssociatedUnits() {
  171. $associatedUnits = $this->LookUpTablesModel->getAssociatedUnits($_POST);
  172. echo $associatedUnits;
  173. }
  174. /**
  175. * gets checked associated units
  176. *
  177. * @param $_POST
  178. * @return $checkedAssociatedUnits
  179. */
  180. public function check_associatedUnits() {
  181. $checkedAssociatedUnits = $this->LookUpTablesModel->check_associatedUnits($_POST);
  182. echo $checkedAssociatedUnits;
  183. }
  184. /**
  185. * gets unchecked associated units
  186. *
  187. * @param $_POST
  188. * @return $uncheckedAssociatedUnits
  189. */
  190. public function uncheck_associatedUnits() {
  191. $unCheckedAssociatedUnits = $this->LookUpTablesModel->uncheck_associatedUnits($_POST);
  192. echo $unCheckedAssociatedUnits;
  193. }
  194. /**
  195. * provides auto suggest functionality for primary authorities
  196. *
  197. * @param $_POST
  198. * @return $uncheckedAssociatedUnits
  199. */
  200. public function autoSuggest_primaryAuthorities() {
  201. $primaryAuthority = $_POST['q'];
  202. $primaryAuthorities = $this->UpkeepModel->autoSuggest_primaryAuthorities($primaryAuthority);
  203. if (is_array($primaryAuthorities)) {
  204. foreach ($primaryAuthorities as $results) {
  205. echo $results . "\n";
  206. }
  207. } else {
  208. echo $primaryAuthorities; // displays "no results found"
  209. }
  210. }
  211. /**
  212. * provides auto suggest functionality for primary authorities
  213. *
  214. * @param $_POST
  215. * @return $uncheckedAssociatedUnits
  216. */
  217. public function autoSuggest_primaryAuthorityRetentions() {
  218. $primaryAuthorityRetention = $_POST['q'];
  219. $primaryAuthorityRetentions = $this->UpkeepModel->autoSuggest_primaryAuthorityRetentions($primaryAuthorityRetention);
  220. if (is_array($primaryAuthorityRetentions)) {
  221. foreach ($primaryAuthorityRetentions as $results) {
  222. echo $results . "\n";
  223. }
  224. } else {
  225. echo $primaryAuthorityRetentions;
  226. }
  227. }
  228. /**
  229. * provides auto suggest functionality for primary authorities
  230. *
  231. * @param $_POST
  232. * @return $uncheckedAssociatedUnits
  233. */
  234. public function autoSuggest_relatedAuthorities() {
  235. $relatedAuthority = $_POST['q'];
  236. $relatedAuthorities = $this->UpkeepModel->autoSuggest_relatedAuthorities($relatedAuthority);
  237. if (is_array($relatedAuthorities)) {
  238. foreach ($relatedAuthorities as $results) {
  239. echo $results . "\n";
  240. }
  241. } else {
  242. echo $relatedAuthorities;
  243. }
  244. }
  245. /**
  246. * provides auto suggest functionality for retention periods
  247. *
  248. * @param $retentionPeriod
  249. * @return $results / $retentionPeriods
  250. */
  251. public function autoSuggest_retentionPeriods() {
  252. $retentionPeriod = $_POST['q'];
  253. $retentionPeriods = $this->UpkeepModel->autoSuggest_retentionPeriods($retentionPeriod);
  254. if (is_array($retentionPeriods)) {
  255. foreach ($retentionPeriods as $results) {
  256. echo $results . "\n";
  257. }
  258. } else {
  259. echo $retentionPeriods; // displays "no results found"
  260. }
  261. }
  262. /**
  263. * provides auto suggest functionality for related authority retentions
  264. *
  265. * @param $relatedAuthorityRetention
  266. * @return $results / $relatedAuthorityRetentions
  267. */
  268. public function autoSuggest_relatedAuthorityRetention() {
  269. $relatedAuthorityRetention = $_POST['q'];
  270. $relatedAuthorityRetentions = $this->UpkeepModel->autoSuggest_relatedAuthorityRetention($relatedAuthorityRetention);
  271. if (is_array($relatedAuthorityRetentions)) {
  272. foreach ($relatedAuthorityRetentions as $results) {
  273. echo $results . "\n";
  274. }
  275. } else {
  276. echo $relatedAuthorityRetentions;
  277. }
  278. }
  279. /**
  280. * provides auto suggest functionality for record names
  281. *
  282. * @param $relatedAuthorityRetention
  283. * @return $results / $relatedAuthorityRetentions
  284. */
  285. public function autoSuggest_recordName() {
  286. $recordName = $_POST['q'];
  287. $recordNames = $this->UpkeepModel->autoSuggest_recordName($recordName);
  288. if (is_array($recordNames)) {
  289. foreach ($recordNames as $results) {
  290. echo $results . "\n";
  291. }
  292. } else {
  293. echo $recordNames;
  294. }
  295. }
  296. /**
  297. * provides auto suggest functionality for record codes
  298. *
  299. * @param $relatedAuthorityRetention
  300. * @return $results / $relatedAuthorityRetentions
  301. */
  302. public function autoSuggest_recordCode() {
  303. $recordCode = $_POST['q'];
  304. $recordCodes = $this->UpkeepModel->autoSuggest_recordCode($recordCode);
  305. if (is_array($recordCodes)) {
  306. foreach ($recordCodes as $results) {
  307. echo $results . "\n";
  308. }
  309. } else {
  310. echo $recordCodes;
  311. }
  312. }
  313. /**
  314. * indexes retention schedules
  315. *
  316. * @access public
  317. * @return void
  318. */
  319. public function indexRetentionSchedules() {
  320. $this->RetentionScheduleModel->indexRs();
  321. }
  322. /**
  323. * deletes record type
  324. *
  325. * @access public
  326. * @return void
  327. */
  328. public function delete() {
  329. $retentionScheduleID = $this->uri->segment(3);
  330. $this->RetentionScheduleModel->deleteRetentionSchedule($retentionScheduleID);
  331. $data['recordUpdated'] = "Record Deleted.";
  332. $this->load->view('admin/displays/success', $data);
  333. }
  334. /**
  335. * restores retention rchedule
  336. *
  337. * @access public
  338. * @return void
  339. */
  340. public function restore(){
  341. $retentionScheduleID = $this->uri->segment(3);
  342. $this->RetentionScheduleModel->restoreRetentionSchedule($retentionScheduleID);
  343. $data['recordUpdated'] = "Record Restored.";
  344. $this->load->view('admin/displays/success', $data);
  345. }
  346. /**
  347. * deletes retention schedule from deleted table
  348. *
  349. * @access public
  350. * @return void
  351. */
  352. public function permanentDelete() {
  353. $retentionScheduleID = $this->uri->segment(3);
  354. $this->RetentionScheduleModel->permanentDeleteRetentionSchedule($retentionScheduleID);
  355. $data['recordUpdated'] = "Record Deleted.";
  356. $this->load->view('admin/displays/success', $data);
  357. }
  358. }