Codeigniter 컨트롤러에 있는 함수를 리스트로 만드는 방법
조회수 1720회
아래 소스 코드는 Typist 라는 이름의 컨트롤러 입니다. receiptList 함수 를 index 함수로 가져와 리스트로 만든다음, 미처리 영수증 리스트가 있다면, 첫번째 인덱스를 수정하고 싶습니다. 어떻게 해야할지 감이 잘 안옵니다.ㅠㅠ
Below is the source code controller named Typist. I want to bring the receiptList() function. After, I want make a list.
My ultimate goal is First, Get receiptList() to make a list. Second, If there is a list, Modify the first index.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Typist extends CI_Controller
{
public function Typist()
{
parent::__construct();
$this->load->model('Cms_mdl','mdl_cms');
$this->load->model('Company_mdl','mdl_company');
$this->load->model('Manage_receipt_mdl','mdl_file');
$this->load->model('Expense_mdl','mdl_expense');
}
public function index()
{
// 미처리 영수증 리스트 가져오기 Get unprocessed receipt list
// 미처리 영수증 리스트가 있으면 If there are unprocessed receipt list
// 첫번째 인덱스를 수정하도록 하기
$this->load->view('typist/header');
$this->load->view('typist/typing');
$this->load->view('footer');
}
public function receiptList()
{
$title = '지출비용목록';
if(@$_GET['unattended'] == 'true')
{
$title = '미처리 영수증';
}
$this->load->view('header', array('title' => $title));
$_GET['company_id'] = $this->session->userdata('company_id');
$view['users'] = $this->mdl_company->getAllUserList($this->session->userdata('company_id'));
$view['cars'] = $this->mdl_company->getAllCarList($this->session->userdata('company_id'));
$view['countExpense'] = $this->getExpenseCount()['count'];
if($view['countExpense'] <= @$_GET['page']*@$_GET['count'])
{
$_GET['page'] = 0;
}
$view['expenses'] = $this->getExpenseList()['expense_list'];
$this->load->view('receiptList_view',$view);
$this->load->view('footer');
}
public function getExpenseCount()
{
$response = array();
$result = null;
$data = $_GET;
if(!isset($_GET['company_id']))
{
$data = $_POST;
}
$result = $this->mdl_expense->getCount(@$data['company_id'], @$data['userid'], @$data['carid'], @$data['expense_type'], @$data['to'], @$data['from'], @$data['order'], @$data['order_type'], @$data['unattended']);
$response['status'] = '200';
$response['message'] = "success";
$response['count'] = $result;
if(debug_backtrace()[1]['function'] == "call_user_func_array")
{
echo json_encode($response,JSON_UNESCAPED_UNICODE);
}
return $response;
}
public function getExpenseList()
{
$response = array();
$result = null;
$data = $_GET;
if(!isset($_GET['company_id']))
{
$data = $_POST;
}
$result = $this->mdl_expense->getList(@$data['company_id'], @$data['userid'], @$data['carid'], @$data['expense_type'], @$data['to'], @$data['from'], @$data['order'], @$data['order_type'], @$data['page'], @$data['count'], @$data['unattended']);
if($result != null)
{
$response['status'] = '200';
$response['message'] = '성공';
$response['expense_list'] = $result;
$response['count'] = $this->mdl_expense->getCount(@$data['company_id'], @$data['userid'], @$data['carid'], @$data['expense_type'], @$data['to'], @$data['from'], @$data['order'], @$data['order_type'], @$data['unattended']);
}
else
{
$response['status'] = '200';
$response['message'] = '데이터가 존재하지 않습니다.';
$response['expense_list'] = array();
$response['count'] = $this->mdl_expense->getCount(@$data['company_id'], @$data['userid'], @$data['carid'], @$data['expense_type'], @$data['to'], @$data['from'], @$data['order'], @$data['order_type'], @$data['unattended']);
}
if(debug_backtrace()[1]['function'] == "call_user_func_array")
{
echo json_encode($response,JSON_UNESCAPED_UNICODE);
}
return $response;
}
public function requestUpdateExpense()
{
$id = $_POST['id'];
$this->updateExpense();
redirect("/Typist?id=".$id,'refresh');
}
public function updateExpense()
{
$response = array();
$result = null;
$id = $_POST['id'];
unset($_POST['id']);
$data = array();
foreach ($_POST as $key => $value)
{
$data[$key] = $value;
}
if($_FILES['uploader']['name'] != '')
{
$image_name = explode(".", $_FILES['uploader']['name']);
$adminImg = $this->Common->singleImageUpload('uploader', 'receipt', $image_name[1], '2', '');
if($adminImg['upload']=='True')
{
$data['picture_url'] = $adminImg['data']['file_name'];
}
else
{
$imgFalse = 1;
}
unset($data['uploader']);
unset($data['picture_name']);
}
else if(isset($_POST['picture']))
{
$data['picture_url'] = date('Ymdhis').".".$_POST['picture_type'];
$image = base64_decode($_POST['picture']);
file_put_contents("images/receipt/".$data['picture_url'], $image);
unset($data['picture']);
unset($data['picture_type']);
}
else
{
unset($data['picture_name']);
}
$this->mdl_expense->update($id, $data);
$response['status'] = '200';
$response['message'] = '업데이트 완료.';
if(debug_backtrace()[1]['function'] == "call_user_func_array")
{
echo json_encode($response,JSON_UNESCAPED_UNICODE);
}
return $response;
}
}
?>
-
(•́ ✖ •̀)
알 수 없는 사용자
댓글 입력