Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function userCheck(){
- $result = json_encode($this->array_filter_recursive($legs), JSON_PRETTY_PRINT);
- $this->load->view('tree/drag-drop', array('builder'=>$result));
- }
- public function array_filter_recursive($arr, $cb = null) {
- if (empty($cb)) {
- $cb = function ($el) {
- return $el;
- };
- }
- $result = array();
- foreach($arr as $key => $val) {
- if (is_array($val)) $val = $this->array_filter_recursive($val, $cb);
- if ($cb($val)) $result[$key] = $val;
- }
- return $result;
- }
- $(function() {
- var datascource = {
- 'name': '<?= $account[0]->first_name.' '.$account[0]->last_name ?>',
- 'title': '<?= $account[0]->gcn_id ?>',
- 'children':<?= $builder?>
- };
- var oc = $('#chart-container').orgchart({
- 'data' : datascource,
- 'nodeContent': 'title',
- 'draggable': true,
- 'dropCriteria': function($draggedNode, $dragZone, $dropZone) {
- if($draggedNode.find('.content').text().indexOf('manager') > -1 && $dropZone.find('.content').text().indexOf('engineer') > -1) {
- return false;
- }
- return true;
- }
- });
- oc.$chart.on('nodedropped.orgchart', function(event) {
- console.log('draggedNode:' + event.draggedNode.children('.title').text()
- + ', dragZone:' + event.dragZone.children('.title').text()
- + ', dropZone:' + event.dropZone.children('.title').text()
- );
- }); });
Add Comment
Please, Sign In to add comment