Advertisement
Guest User

Untitled

a guest
Mar 1st, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.15 KB | None | 0 0
  1. <?php
  2.  
  3. // form validation greater than example http://stackoverflow.com/questions/1996197/codeigniter-validation-how-to-limit-numerical-value
  4. require_once("MY_Ezbuild.php");
  5.  
  6. if (!defined('BASEPATH'))
  7. exit('No direct script access allowed');
  8.  
  9. class Destination extends MY_Ezbuild {
  10.  
  11. function __construct() {
  12. parent::__construct();
  13.  
  14. //$this->load->database();
  15. $this->load->helper('url');
  16. /* ------------------ */
  17. $this->load->library('grocery_CRUD');
  18. $this->delimiter = "- ";
  19. $this->lu_delimiter = " - ";
  20. $this->form_validation->set_message('required', '* required');
  21. $this->session->set_userdata('language', 'EN');
  22. $this->lan = $this->session->userdata('language');
  23. $this->lan = "NL";
  24. }
  25.  
  26. private function _subject_from_meta($language, $table) {
  27. $default_subject = ucfirst($table->name);
  28. $default_subject = str_replace("_", " ", $default_subject);
  29. $sql = "select `name` from `m_table_subject` `mts`
  30. where `mts`.`language` = ? and `mts`.`m_tableID` = ?";
  31.  
  32. $query = $this->defaultdb->query($sql, Array($language, $table->m_tableID));
  33. foreach ($query->result() as $row) {
  34. $subject = $row->name;
  35. }
  36. if (!isset($subject)) {
  37. $subject = $default_subject;
  38. }
  39. return ($subject);
  40. }
  41.  
  42. private function _create_hyperlinks($sql, $primary_key, $table, $fields) {
  43. $query = $this->defaultdb->query($sql, array($primary_key));
  44. $str = "";
  45. $keyfield_hyper = $table . "ID";
  46. foreach ($query->result() as $row) {
  47. $url = site_url("$table/index/read/" . $row->$keyfield_hyper);
  48. $hyper = "";
  49. foreach ($fields as $field) {
  50. if (isset($row->$field)) {
  51. if ($hyper != "") {
  52. $hyper .= " - " . $row->$field;
  53. } else {
  54. $hyper .= $row->$field;
  55. }
  56. }
  57. }
  58. if ($hyper != "") {
  59. $str .= "<a href='" . $url . "'>" . $hyper . "</a><br/>";
  60. }
  61. }
  62. $str = $this->rtrim($str, "<br/>");
  63. return $str;
  64. }
  65.  
  66. private function _get_table_subject($tableID) {
  67. if (is_numeric($tableID)) {
  68. $table = $this->_findtablebyID($tableID);
  69. } else {
  70. $table = $this->_findtable($tableID);
  71. }
  72. $subject = "";
  73. if (isset($table)) {
  74. if ($this->lan == "NL") {
  75. $subject = $this->_subject_from_meta("NL", $table);
  76. } else if ($this->lan == "EN") {
  77. $subject = $this->_subject_from_meta("EN", $table);
  78. } else if ($this->lan == "FR") {
  79. $subject = $this->_subject_from_meta("FR", $table);
  80. } else if ($this->lan == "DE") {
  81. $subject = $this->_subject_from_meta("DE", $table);
  82. }
  83. }
  84. return ($subject);
  85. }
  86.  
  87. private function _lookup_fields($tableID, $prefix) {
  88. $sql = "select `name` from m_field where m_tableID = $tableID and lookup_sequence <> 0 and is_AIfield = 0 order by lookup_sequence";
  89. $string = "";
  90. $query = $this->defaultdb->query($sql, array($tableID));
  91. foreach ($query->result() as $row) {
  92. $string .= $prefix . "." . $row->name . ",";
  93. }
  94. if ($string == "") {
  95. $sql = "select `name` from m_field where m_tableID = ? and (`name` = 'name' or `mysql_type` like 'varchar%')";
  96. $query = $this->defaultdb->query($sql, array($tableID));
  97. foreach ($query->result() as $row) {
  98. if ($row->name == "name") { // preference for name field
  99. $string = $prefix . "." . $row->name . ",";
  100. break;
  101. } else {
  102. $string = $prefix . "." . $row->name . ",";
  103. }
  104. }
  105. }
  106. if ($string != "") {
  107. $string = $this->rtrim($string, ",");
  108. } else {
  109. $this->log("No lookup fields found tableID = $tableID");
  110. }
  111. return ($string);
  112. }
  113.  
  114. function _init_stack($table1ID, $table2ID) {
  115. $this->joinstack = array();
  116. $sql = "select mr.m_relationID, mr.table1ID, mr.table2ID, mr.cardinality "
  117. . " from m_relation mr where (mr.table1ID = ?) or (mr.table2ID = ?)";
  118. $query = $this->defaultdb->query($sql, array($table1ID, $table1ID));
  119. // what tables are linked to $table1ID
  120. $finished = false;
  121. foreach ($query->result() as $row) {
  122. if ((($row->table2ID == $table2ID) && ($row->table1ID == $table1ID)) ||
  123. (($row->table2ID == $table1ID) && ($row->table1ID == $table2ID))) {
  124. $entry = new stdClass();
  125. $entry->table1ID = $table1ID;
  126. $entry->table2ID = $table2ID;
  127. $entry->valid = true;
  128. $finished = true;
  129. } else {
  130. $entry = new stdClass();
  131. $entry->table1ID = $row->table1ID;
  132. $entry->table2ID = $row->table2ID;
  133. $entry->valid = false;
  134. }
  135. array_push($this->joinstack, $entry);
  136. }
  137. return ($finished);
  138. }
  139.  
  140. function _add_2_stack($table1ID, $table2ID) {
  141. $found = false;
  142. foreach ($this->joinstack as $entry) {
  143. if (( ($entry->table1ID == $table1ID ) && ($entry->table2ID == $table2ID ) ) ||
  144. ( ($entry->table2ID == $table1ID ) && ($entry->table1ID == $table2ID ) )) {
  145. $found = true;
  146. }
  147. }
  148. if (!$found) {
  149. $entry = new stdClass();
  150. $entry->table1ID = $table1ID;
  151. $entry->table2ID = $table2ID;
  152. $entry->valid = false;
  153. array_push($this->joinstack, $entry);
  154. return true;
  155. } else {
  156. return false;
  157. }
  158. }
  159.  
  160. function _topstack() {
  161. $count = count($this->joinstack);
  162. if ($count > 0) {
  163. return ( $this->joinstack[$count - 1]);
  164. }
  165. }
  166.  
  167. /*
  168. * Recursive routine to create the joins
  169. */
  170.  
  171. function _process_stack() {
  172. $top_stack = $this->_topstack();
  173. if (isset($top_stack)) {
  174. $sql = "select mr.m_relationID, mr.table1ID, mr.table2ID, mr.cardinality "
  175. . " from m_relation mr where (mr.table1ID = ?) or (mr.table2ID = ?)";
  176. $debug = str_replace("?", $top_stack->table2ID, $sql);
  177. $query = $this->defaultdb->query($sql, array($top_stack->table2ID, $top_stack->table2ID));
  178. $ladd = false;
  179. $finished = false;
  180. foreach ($query->result() as $row) {
  181. if (($row->table1ID == $this->endtable->m_tableID) || ($row->table2ID == $this->endtable->m_tableID)) {
  182. $finished = true;
  183. $top_stack->valid = true;
  184. if ($row->table1ID == $top_stack->table2ID) {
  185. $ladd = $this->_add_2_stack($row->table2ID, $top_stack->table2ID);
  186. } else if ($row->table2ID == $top_stack->table2ID) {
  187. $ladd = $this->_add_2_stack($row->table1ID, $top_stack->table2ID);
  188. }
  189. if ($ladd) {
  190. $top_stack = $this->_topstack();
  191. $top_stack->valid = true;
  192. }
  193. break;
  194. } else if ($row->table1ID == $top_stack->table2ID) {
  195. $ladd = $this->_add_2_stack($row->table1ID, $row->table2ID);
  196. }
  197. }
  198. if ($finished) {
  199. return (true);
  200. } else {
  201. if (!$ladd) {
  202. array_pop($this->joinstack);
  203. }
  204. $finished = $this->_process_stack();
  205. if ($finished) {
  206. return (true);
  207. }
  208. }
  209. } else {
  210. return (true);
  211. }
  212. }
  213.  
  214. /*
  215. * Process the stack and build the join
  216. */
  217.  
  218. function _makejoin() {
  219. $size = count($this->joinstack);
  220. $sqljoin = "";
  221. $stop = false;
  222. $couple_table_info = null;
  223. $couple_table = null;
  224. while (!$stop) {
  225. $top_stack = $this->_topstack();
  226. if (isset($top_stack)) {
  227. if ($this->endtable->m_tableID == $top_stack->table1ID) {
  228. $couple_table = $top_stack->table2ID;
  229. } else if ($this->endtable->m_tableID == $top_stack->table2ID) {
  230. $couple_table = $top_stack->table1ID;
  231. } else if ($couple_table == $top_stack->table1ID) {
  232. $couple_table = $top_stack->table2ID;
  233. } else if ($couple_table == $top_stack->table2ID) {
  234. $couple_table = $top_stack->table1ID;
  235. } else {
  236. $couple_table = $top_stack->table1ID;
  237. }
  238. $couple_table_prev = $couple_table_info;
  239. $couple_table_info = $this->_findtablebyID($couple_table);
  240. if ($sqljoin == "") {
  241. $sqljoin .= " inner join " . $couple_table_info->name . " on " . $couple_table_info->name . "." .
  242. $this->endtable->name . "ID = " . $this->endtable->name . "." . $this->endtable->name . "ID";
  243. } else if (isset($couple_table_prev)) {
  244. $sqljoin .= " inner join " . $couple_table_info->name . " on " . $couple_table_info->name . "." .
  245. $couple_table_info->name . "ID = " . $couple_table_prev->name . "." . $couple_table_info->name . "ID";
  246. }
  247. array_pop($this->joinstack);
  248. $stop = ($couple_table == $this->begintable->m_tableID);
  249. } else {
  250. $stop = true; // stack is empty
  251. }
  252. }
  253. if ($sqljoin != "") {
  254. $fields = $this->_lookup_fields($this->endtable->m_tableID, $this->endtable->name);
  255. if ($fields != "") {
  256. $fields = $this->endtable->name . "." . $this->endtable->name . "ID," . $fields;
  257. $sqljoin = "select distinct $fields from " . $this->endtable->name . $sqljoin .
  258. " and " . $this->begintable->name . "." . $this->begintable->name . "ID = ?";
  259. }
  260. }
  261. return ($sqljoin);
  262. }
  263.  
  264. function _create_join_extra($source_table, $lookup_table, $couple_table, $keyfield) {
  265. $table1 = $this->_findtable($source_table);
  266. $table2 = $this->_findtable($lookup_table);
  267. $ct = $this->_findtablebyID($couple_table);
  268. $this->begintable = $table1;
  269. $this->endtable = $table2;
  270. $this->keyfield = $keyfield;
  271. $sqljoin = "";
  272. $sqljoin .= " left outer join " . $ct->name . " on " . $ct->name . "." . $source_table . "ID =" . $source_table . "." . $source_table . "ID";
  273. $sqljoin .= " left outer join " . $lookup_table . " on " . $ct->name . "." . $lookup_table . "ID =" . $lookup_table . "." . $lookup_table . "ID";
  274. if ($sqljoin != "") {
  275. $fields = $this->_lookup_fields($this->endtable->m_tableID, $this->endtable->name);
  276. if ($fields != "") {
  277. $fields = $this->endtable->name . "." . $this->endtable->name . "ID," . $fields;
  278. $sqljoin = "select distinct $fields from " . $table1->name . $sqljoin .
  279. " and " . $this->begintable->name . "." . $this->begintable->name . "ID = ?";
  280. }
  281. }
  282. return ($sqljoin);
  283. }
  284.  
  285. function _create_join_extra_old(
  286. $source_table, $lookup_table, $keyfield) {
  287. $table1 = $this->_findtable($source_table);
  288. $table2 = $this->_findtable($lookup_table);
  289. $this->begintable = $table1;
  290. $this->endtable = $table2;
  291. $this->keyfield = $keyfield;
  292.  
  293. $finished = $this->_init_stack($table1->m_tableID, $table2->m_tableID);
  294. if (!$finished) {
  295. $finished = $this->_process_stack();
  296. if ($finished) {
  297. $sql = $this->_makejoin();
  298. }
  299. } else {
  300. $sql = $this->_makejoin(); // simple join
  301. }
  302. return ($sql);
  303. }
  304.  
  305. private function _create_join($source_table, $field_name, $lookup_table, $lookup_tableID) {
  306. if ($lookup_tableID != -1) {
  307. $table1 = $this->rtrim($field_name, "ID"); // scrum_master
  308. $table1ID = $this->_findtable($table1);
  309. if (isset($table1ID)) {
  310. $sql = "select cardinality from m_relation where (table1ID = ? and table2ID = ?) or (table1ID = ? and table2ID = ?) ";
  311. $fields = $this->_lookup_fields($lookup_tableID, $lookup_table);
  312. $query = $this->defaultdb->query($sql, array($table1ID, $lookup_tableID, $lookup_tableID, $table1ID));
  313. foreach ($query->result() as $row) {
  314. $sql_join = " inner join $table1 on $table1.$field_name = $source_table.$field_name
  315. inner join $lookup_table on $lookup_table.$lookup_table" . "ID" . " = $table1.$lookup_table" . "ID" .
  316. " and $source_table.$field_name = ?";
  317. $sql = "select distinct $fields from $source_table $sql_join";
  318. $this->cb_lines[] = "//$sql";
  319. return ($sql);
  320. }
  321. } else {
  322. return;
  323. }
  324. } else {
  325. // so a directlink must be an ID field of a table
  326. $table1 = $this->rtrim($field_name, "ID"); // scrum_master
  327. $table1ID = $this->_findtable($table1);
  328. $fields = $this->_lookup_fields($table1ID);
  329. $sql_join = " inner join $table1 on $table1.$field_name = $source_table.$fieldname
  330. inner join $lookup_table on $lookup_table.$field_name" . "ID" . " = $source_table.$lookup_table" . "ID" .
  331. " and $source_table.$fieldname = ?";
  332. $sql = "select distinct $fields from $source_table $sql_join";
  333. $this->cb_lines[] = "//$sql";
  334. return ($sql);
  335. }
  336. }
  337.  
  338. public function _generate_output($output = null) {
  339. $this->load->view('standard_view.php', $output);
  340. }
  341.  
  342. public function index() {
  343. $crud = new grocery_CRUD();
  344.  
  345. $crud->set_theme('datatables');
  346. if ($this->lan == "NL") {
  347. $subject = "bestemming";
  348. } else if ($this->lan == "EN") {
  349. $subject = "Destination";
  350. } else if ($this->lan == "FR") {
  351. $subject = "Destination";
  352. } else if ($this->lan == "DE") {
  353. $subject = "Destination";
  354. }
  355. $crud->set_subject($subject);
  356. $crud->set_table('destination');
  357. $crud->columns('name', 'cluster', 'segment', 'class', 'premium_building', 'premium_inventory_goods', 'premium_company_risk', 'checked', 'updated', 'CEA_codeID', 'destination_codeID');
  358. $crud->callback_column('CEA_codeID', array($this, '_callback_destination_CEA_codeID'));
  359. $crud->callback_column('destination_codeID', array($this, '_callback_destination_destination_codeID'));
  360. $crud->callback_before_update(array($this, '_update_record'));
  361.  
  362. $crud->fields('name', 'cluster', 'segment', 'class', 'premium_building', 'premium_inventory_goods', 'premium_company_risk', 'checked', 'updated', 'CEA_codeID', 'destination_codeID');
  363. if ($this->lan == "NL") {
  364. $crud->display_as('destinationID', 'Destination');
  365. $crud->display_as('name', 'Bestemming');
  366. $crud->display_as('cluster', 'Cluster');
  367. $crud->display_as('segment', 'Segment');
  368. $crud->display_as('class', 'Klasse');
  369. $crud->display_as('premium_building', 'Premie gebouw');
  370. $crud->display_as('premium_inventory_goods', 'Premie inventaris goederen');
  371. $crud->display_as('premium_company_risk', 'Premie bedrijfsschade');
  372. $crud->display_as('checked', 'Gecontroleerd');
  373. $crud->display_as('updated', 'Datum wijziging');
  374. $crud->display_as('CEA_codeID', 'CEA code');
  375. $crud->display_as('destination_codeID', 'Destination code');
  376. } else if ($this->lan == "EN") {
  377. $crud->display_as('destinationID', 'Destination');
  378. $crud->display_as('name', 'Name');
  379. $crud->display_as('cluster', 'Cluster');
  380. $crud->display_as('segment', 'Segment');
  381. $crud->display_as('class', 'Class');
  382. $crud->display_as('premium_building', 'Premium building');
  383. $crud->display_as('premium_inventory_goods', 'Premium inventory goods');
  384. $crud->display_as('premium_company_risk', 'Premium company risk');
  385. $crud->display_as('checked', 'Checked');
  386. $crud->display_as('updated', 'Updated');
  387. $crud->display_as('CEA_codeID', 'CEA code');
  388. $crud->display_as('destination_codeID', 'Destination code');
  389. } else if ($this->lan == "FR") {
  390. $crud->display_as('destinationID', 'Destination');
  391. $crud->display_as('name', 'Name');
  392. $crud->display_as('cluster', 'Cluster');
  393. $crud->display_as('segment', 'Segment');
  394. $crud->display_as('class', 'Class');
  395. $crud->display_as('premium_building', 'Premium building');
  396. $crud->display_as('premium_inventory_goods', 'Premium inventory goods');
  397. $crud->display_as('premium_company_risk', 'Premium company risk');
  398. $crud->display_as('checked', 'Checked');
  399. $crud->display_as('updated', 'Updated');
  400. $crud->display_as('CEA_codeID', 'CEA code');
  401. $crud->display_as('destination_codeID', 'Destination code');
  402. } else if ($this->lan == "DE") {
  403. $crud->display_as('destinationID', 'Destination');
  404. $crud->display_as('name', 'Name');
  405. $crud->display_as('cluster', 'Cluster');
  406. $crud->display_as('segment', 'Segment');
  407. $crud->display_as('class', 'Class');
  408. $crud->display_as('premium_building', 'Premium building');
  409. $crud->display_as('premium_inventory_goods', 'Premium inventory goods');
  410. $crud->display_as('premium_company_risk', 'Premium company risk');
  411. $crud->display_as('checked', 'Checked');
  412. $crud->display_as('updated', 'Updated');
  413. $crud->display_as('CEA_codeID', 'CEA code');
  414. $crud->display_as('destination_codeID', 'Destination code');
  415. }
  416. if ($this->lan == "NL") {
  417. ;
  418. } else if ($this->lan == "EN") {
  419. ;
  420. } else if ($this->lan == "FR") {
  421. ;
  422. } else if ($this->lan == "DE") {
  423. ;
  424. }
  425. if ($this->lan == "NL") {
  426. ;
  427. } else if ($this->lan == "EN") {
  428. ;
  429. } else if ($this->lan == "FR") {
  430. ;
  431. } else if ($this->lan == "DE") {
  432. ;
  433. }
  434. if ($this->lan == "NL") {
  435. ;
  436. } else if ($this->lan == "EN") {
  437. ;
  438. } else if ($this->lan == "FR") {
  439. ;
  440. } else if ($this->lan == "DE") {
  441. ;
  442. }
  443. /* so only 1 item can be filled in */
  444. $sql = 'SELECT CEA_code.CEA_codeID,CEA_code.CEA_code FROM `CEA_code`';
  445. $query = $this->db->query($sql);
  446. $choose = array();
  447. foreach ($query->result() as $row) {
  448. $lu_value = '';
  449. foreach (get_object_vars($row) as $column => $value) {
  450. $lu_value .= $value . $this->lu_delimiter;
  451. }
  452. $lu_value = rtrim($lu_value, $this->lu_delimiter);
  453. $entry = $lu_value;
  454. $choose[$row->CEA_codeID] = $entry;
  455. }
  456. $crud->field_type('CEA_codeID', 'dropdown', $choose);
  457. /* so only 1 item can be filled in */
  458. $sql = 'SELECT destination_code.destination_codeID,destination_code.destination_code FROM `destination_code`';
  459. $query = $this->db->query($sql);
  460. $choose = array();
  461. foreach ($query->result() as $row) {
  462. $lu_value = '';
  463. foreach (get_object_vars($row) as $column => $value) {
  464. $lu_value .= $value . $this->lu_delimiter;
  465. }
  466. $lu_value = rtrim($lu_value, $this->lu_delimiter);
  467. $entry = $lu_value;
  468. $choose[$row->destination_codeID] = $entry;
  469. }
  470. $crud->field_type('destination_codeID', 'dropdown', $choose);
  471. if ($this->lan == "NL") {
  472. $crud->field_type('checked', 'enum', array('Nee', 'Ja'));
  473. } else if ($this->lan == "EN") {
  474. ;
  475. } else if ($this->lan == "FR") {
  476. ;
  477. } else if ($this->lan == "DE") {
  478. ;
  479. }
  480. $crud->field_type('name', 'string');
  481. $crud->field_type('cluster', 'string');
  482. $crud->field_type('segment', 'string');
  483. $crud->field_type('class', 'string');
  484. $crud->field_type('premium_building', 'string');
  485. $crud->field_type('premium_inventory_goods', 'string');
  486. $crud->field_type('premium_company_risk', 'string');
  487.  
  488. $crud->required_fields('updated');
  489. $output = $crud->render();
  490. $state = $crud->getState();
  491. $state_info = $crud->getStateInfo();
  492. if (($state == "edit") || ($state == "read")) {
  493. $primary_key = $state_info->primary_key;
  494. $sql = 'select CEA_code.CEA_codeID,CEA_code.CEA_code from destination left outer join _Z_REL_CEA_code_destination on _Z_REL_CEA_code_destination.destinationID = destination.destinationID inner join CEA_code on _Z_REL_CEA_code_destination.CEA_codeID = CEA_code.CEA_codeID and destination.destinationID = ?';
  495. $CEA_codeID = null;
  496. $query = $this->defaultdb->query($sql, array($primary_key));
  497. foreach ($query->result() as $row) {
  498. $CEA_codeID = $row->CEA_codeID;
  499. }
  500. $primary_key = $state_info->primary_key;
  501. $sql = 'select destination_code.destination_codeID,destination_code.destination_code from destination left outer join _Z_REL_destination_code_destination on _Z_REL_destination_code_destination.destinationID = destination.destinationID inner join destination_code on _Z_REL_destination_code_destination.destination_codeID = destination_code.destination_codeID and destination.destinationID = ?';
  502. $destination_codeID = null;
  503. $query = $this->defaultdb->query($sql, array($primary_key));
  504. foreach ($query->result() as $row) {
  505. $destination_codeID = $row->destination_codeID;
  506. }
  507. $view_arr = array(
  508. 'CEA_codeID' => $CEA_codeID,
  509. 'destination_codeID' => $destination_codeID,
  510. 'output' => $output
  511. );
  512. $this->load->view('destination.php', $view_arr);
  513. } else {
  514. $view_arr = array(
  515. 'output' => $output
  516. );
  517. $this->load->view('destination.php', $view_arr);
  518. }
  519. }
  520.  
  521. function _update_record($post_array, $primary_key) {
  522. $this->log("cb update");
  523. foreach ($post_array as $post) {
  524. echo ($post);
  525. }
  526. }
  527.  
  528. public function _callback_destination_CEA_codeID($value, $row) {
  529. $field = 'destinationID';
  530. $keyfield = $row->$field;
  531. $speed = 'destination_CEA_code';
  532. if (isset($this->$speed)) {
  533. $sql = $this->$speed;
  534. } else {
  535. $sql = $this->_create_join_extra('destination', 'CEA_code', 2, $keyfield);
  536. $this->$speed = $sql;
  537. }
  538. if ((isset($sql) && ($sql != ""))) {
  539. $query = $this->defaultdb->query($sql, array($keyfield));
  540. $hyperlinks = '';
  541. $hyper_text = '';
  542. foreach ($query->result() as $row) {
  543. $hyperlink = null;
  544. foreach ($row as $key => $value) {
  545. if ((!$this->endswith($key, 'ID')) && (isset($value))) {
  546. $hyper_text .= $value . $this->delimiter;
  547. } else if (isset($value)) {
  548. $hyperlink = $value;
  549. }
  550. }
  551. if (isset($hyperlink)) {
  552. $hyper_text = $this->rtrim($hyper_text, $this->delimiter);
  553. $hyperlinks .= '<a href="' . site_url('CEA_code/index/read/' . $hyperlink) . '">' . $hyper_text . '</a>, ';
  554. }
  555. }
  556. if ($hyperlinks != '') {
  557. $hyperlinks = $this->rtrim($hyperlinks, ', ');
  558. return $hyperlinks;
  559. }
  560. }
  561. }
  562.  
  563. public function _callback_destination_destination_codeID($value, $row) {
  564. $field = 'destinationID';
  565. $keyfield = $row->$field;
  566. $speed = 'destination_destination_code';
  567. if (isset($this->$speed)) {
  568. $sql = $this->$speed;
  569. } else {
  570. $sql = $this->_create_join_extra('destination', 'destination_code', 3, $keyfield);
  571. $this->$speed = $sql;
  572. }
  573. if ((isset($sql) && ($sql != ""))) {
  574. $query = $this->defaultdb->query($sql, array($keyfield));
  575. $hyperlinks = '';
  576. $hyper_text = '';
  577. foreach ($query->result() as $row) {
  578. $hyperlink = null;
  579. foreach ($row as $key => $value) {
  580. if ((!$this->endswith($key, 'ID')) && (isset($value))) {
  581. $hyper_text .= $value . $this->delimiter;
  582. } else if (isset($value)) {
  583. $hyperlink = $value;
  584. }
  585. }
  586. if (isset($hyperlink)) {
  587. $hyper_text = $this->rtrim($hyper_text, $this->delimiter);
  588. $hyperlinks .= '<a href="' . site_url('destination_code/index/read/' . $hyperlink) . '">' . $hyper_text . '</a>, ';
  589. }
  590. }
  591. if ($hyperlinks != '') {
  592. $hyperlinks = $this->rtrim($hyperlinks, ', ');
  593. return $hyperlinks;
  594. }
  595. }
  596. }
  597.  
  598. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement