芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/www/breadwinnerv2/application/controllers/Tools.php
load->model('tools_model', 'tools'); $this->load->library("Aauth"); if (!$this->aauth->is_loggedin()) { redirect('/user/', 'refresh'); } if ($this->aauth->get_user()->roleid < 4) { exit('
Sorry! You have insufficient permissions to access this section
'); } } //todo section public function todo() { $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'ToDo List'; $data['totalt'] = $this->tools->task_count_all(); $this->load->view('fixed/header', $head); $this->load->view('todo/index', $data); $this->load->view('fixed/footer'); } public function addtask() { $this->load->model('employee_model', 'employee'); $head['usernm'] = $this->aauth->get_user()->username; $data['emp'] = $this->employee->list_employee(); $head['title'] = 'Add Task'; $this->load->view('fixed/header', $head); $this->load->view('todo/addtask', $data); $this->load->view('fixed/footer'); } public function edittask() { if ($this->input->post()) { $id = $this->input->post('id'); $name = $this->input->post('name'); $status = $this->input->post('status'); $priority = $this->input->post('priority'); $stdate = $this->input->post('staskdate'); $tdate = $this->input->post('taskdate'); $employee = $this->input->post('employee'); $content = $this->input->post('content'); $stdate = datefordatabase($stdate); $tdate = datefordatabase($tdate); if ($this->tools->edittask($id, $name, $status, $priority, $stdate, $tdate, $employee, $content)) { echo json_encode(array('status' => 'Success', 'message' => $this->lang->line('UPDATED'))); } else { echo json_encode(array('status' => 'Error', 'message' => $this->lang->line('ERROR'))); } } else { $this->load->model('employee_model', 'employee'); $head['usernm'] = $this->aauth->get_user()->username; $data['emp'] = $this->employee->list_employee(); $head['title'] = 'Edit Task'; $id = $this->input->get('id'); $data['task'] = $this->tools->viewtask($id); $this->load->view('fixed/header', $head); $this->load->view('todo/edittask', $data); $this->load->view('fixed/footer'); } } public function save_addtask() { $name = $this->input->post('name'); $status = $this->input->post('status'); $priority = $this->input->post('priority'); $stdate = $this->input->post('staskdate'); $tdate = $this->input->post('taskdate'); $employee = $this->input->post('employee'); $content = $this->input->post('content'); $assign = $this->aauth->get_user()->id; $stdate = datefordatabase($stdate); $tdate = datefordatabase($tdate); if ($this->tools->addtask($name, $status, $priority, $stdate, $tdate, $employee, $assign, $content)) { echo json_encode(array('status' => 'Success', 'message' => $this->lang->line('New Task Added'))); } else { echo json_encode(array('status' => 'Error', 'message' => $this->lang->line('ERROR'))); } } public function set_task() { $id = $this->input->post('tid'); $stat = $this->input->post('stat'); $this->tools->settask($id, $stat); echo json_encode(array('status' => 'Success', 'message' => $this->lang->line('UPDATED'), 'pstatus' => 'Success')); } public function view_task() { $id = $this->input->post('tid'); $task = $this->tools->viewtask($id); echo json_encode(array('name' => $task['name'], 'description' => $task['description'], 'employee' => $task['emp'], 'assign' => $task['assign'], 'priority' => $task['priority'])); } public function task_stats() { $this->tools->task_stats(); } public function delete_i() { $id = $this->input->post('deleteid'); if ($this->tools->deletetask($id)) { echo json_encode(array('status' => 'Success', 'message' => $this->lang->line('DELETED'))); } else { echo json_encode(array('status' => 'Error', 'message' => $this->lang->line('ERROR'))); } } public function todo_load_list() { $cday = $this->input->get('cday'); $list = $this->tools->task_datatables($cday); $data = array(); $no = $this->input->post('start'); foreach ($list as $task) { $no++; $name = '
' . $task->name . '
'; if ($task->status == 'Done') { $name = '
' . $task->name . '
'; } $row = array(); $row[] = $no; $row[] = '
SET
' . $name; $row[] = dateformat($task->duedate); $row[] = dateformat($task->start); $row[] = '
' . $this->lang->line($task->status) . '
'; $row[] = '
'; $data[] = $row; } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->tools->task_count_all($cday), "recordsFiltered" => $this->tools->task_count_filtered($cday), "data" => $data, ); echo json_encode($output); } //set goals public function setgoals() { if ($this->input->post('income')) { $income = $this->input->post('income'); $expense = $this->input->post('expense'); $sales = $this->input->post('sales'); $netincome = $this->input->post('netincome'); if ($this->tools->setgoals($income, $expense, $sales, $netincome)) { echo json_encode(array('status' => 'Success', 'message' => $this->lang->line('UPDATED'))); } else { echo json_encode(array('status' => 'Error', 'message' => $this->lang->line('ERROR'))); } } else { $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'Set Goals'; $data['goals'] = $this->tools->goals(1); $this->load->view('fixed/header', $head); $this->load->view('goals/index', $data); $this->load->view('fixed/footer'); } } //notes public function notes() { $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'Notes'; $this->load->view('fixed/header', $head); $this->load->view('notes/index'); $this->load->view('fixed/footer'); } public function notes_load_list() { $list = $this->tools->notes_datatables(); $data = array(); $no = $this->input->post('start'); foreach ($list as $note) { $row = array(); $no++; $row[] = $no; $row[] = $note->title; $row[] = dateformat($note->cdate); $row[] = '
' . $this->lang->line('View') . '
'; $data[] = $row; } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->tools->notes_count_all(), "recordsFiltered" => $this->tools->notes_count_filtered(), "data" => $data, ); echo json_encode($output); } public function addnote() { if ($this->input->post('title')) { $title = $this->input->post('title'); $content = $this->input->post('content'); if ($this->tools->addnote($title, $content)) { echo json_encode(array('status' => 'Success', 'message' => $this->lang->line('ADDED'))); } else { echo json_encode(array('status' => 'Error', 'message' => $this->lang->line('ERROR'))); } } else { $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'Add Note'; $this->load->view('fixed/header', $head); $this->load->view('notes/addnote'); $this->load->view('fixed/footer'); } } public function editnote() { if ($this->input->post('title')) { $id = $this->input->post('id'); $title = $this->input->post('title'); $content = $this->input->post('content'); if ($this->tools->editnote($id, $title, $content)) { echo json_encode(array('status' => 'Success', 'message' => $this->lang->line('UPDATED'))); } else { echo json_encode(array('status' => 'Error', 'message' => $this->lang->line('ERROR'))); } } else { $id = $this->input->get('id'); $data['note'] = $this->tools->note_v($id); $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'Edit'; $this->load->view('fixed/header', $head); $this->load->view('notes/editnote', $data); $this->load->view('fixed/footer'); } } public function delete_note() { $id = $this->input->post('deleteid'); if ($this->tools->deletenote($id)) { echo json_encode(array('status' => 'Success', 'message' => $this->lang->line('DELETED'))); } else { echo json_encode(array('status' => 'Error', 'message' => $this->lang->line('ERROR'))); } } //documents public function documents() { $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'Documents'; $this->load->view('fixed/header', $head); $this->load->view('notes/documents'); $this->load->view('fixed/footer'); } public function document_load_list() { $list = $this->tools->document_datatables(); $data = array(); $no = $this->input->post('start'); foreach ($list as $document) { $row = array(); $no++; $row[] = $no; $row[] = $document->title; $row[] = dateformat($document->cdate); $row[] = '
' . $this->lang->line('View') . '
'; $data[] = $row; } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->tools->document_count_all(), "recordsFiltered" => $this->tools->document_count_filtered(), "data" => $data, ); echo json_encode($output); } public function adddocument() { $this->load->helper(array('form')); $data['response'] = 3; $head['usernm'] = $this->aauth->get_user()->username; $head['title'] = 'Add Document'; $this->load->view('fixed/header', $head); if ($this->input->post('title')) { $title = $this->input->post('title'); $config['upload_path'] = './userfiles/documents'; $config['allowed_types'] = 'docx|docs|txt|pdf|xls'; $config['max_size'] = 3000; $this->load->library('upload', $config); if (!$this->upload->do_upload('userfile')) { $data['response'] = 0; $data['responsetext'] = 'File Upload Error'; } else { $data['response'] = 1; $data['responsetext'] = 'Document Uploaded Successfully.'; $filename = $this->upload->data()['file_name']; $this->tools->adddocument($title, $filename); } $this->load->view('notes/adddocument', $data); } else { $this->load->view('notes/adddocument', $data); } $this->load->view('fixed/footer'); } public function delete_document() { $id = $this->input->post('deleteid'); if ($this->tools->deletedocument($id)) { echo json_encode(array('status' => 'Success', 'message' => $this->lang->line('DELETED'))); } else { echo json_encode(array('status' => 'Error', 'message' => $this->lang->line('ERROR'))); } } public function pendingtasks() { $tasks = $this->tools->pending_tasks(); $tlist = ''; $tc = 0; foreach ($tasks as $row) { $tlist .= '
' . $row['name'] . '
Due date is ' . dateformat($row['duedate']) . '.
Start
' . dateformat($row['start']) . '
'; $tc++; } echo json_encode(array('tasks' => $tlist, 'tcount' => $tc)); } }