130 lines
4.6 KiB
PHP
Executable File

<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Formmapping extends MX_Controller {
function __construct() { parent::__construct();
$this->load->model('formbuilder/Formbuilder_model');
$this->load->model('Formmapping_model');
}
function index() {
$this->load->view('home/dashboard'); // just the header file
$this->load->view('namelist');
$this->load->view('home/footer'); // just the header file
}
function addMapping(){
$data['list']=$this->Formbuilder_model->get_list();
$data['heading']="Add Mapping";
//echo '<pre>'; print_r($data);die;
$this->load->view('home/dashboard'); // just the header file
$this->load->view('editname',$data);
$this->load->view('home/footer'); // just the header file
}
function editMapping(){
$id=$this->input->get('id');
$data['list']=$this->Formbuilder_model->get_list();
$data['mapping']=$this->Formmapping_model->get_mapping_data($id);
$data['heading']="Edit Mapping";
//echo '<pre>'; print_r($data);die;
$this->load->view('home/dashboard'); // just the header file
$this->load->view('editname',$data);
$this->load->view('home/footer'); // just the header file
}
function getTemplateId()
{
$formname=$this->input->post('name');
$output=$this->Formmapping_model->getFormDataByName($formname);
$templateArr=explode(',', $output->template_id);
print_r($templateArr);
}
function saveMapping(){
$post=$this->input->post();
if(isset($post['form_id'])){ $id=$post['form_id']; }
// echo $id;
// echo '<pre>'; print_r($post);die;
$data['form_name']=$post['form_name'];
$data['template_id']=implode(',',$post['template_id']) ;
if($id!=""){
$result=$this->Formmapping_model->updateMapping($data,$id);
}else{
$result=$this->Formmapping_model->saveMapping($data);
}
if($result['code']=='200'){
$this->session->set_flashdata('success_msg', $result['msg']);
}else{
$this->session->set_flashdata('failed_msg', $result['msg']);
}
redirect('formmapping');
}
function getFromData(){
$formid=$this->input->get('formid');
$output=$this->Formbuilder_model->getFormData($formid);
print_r($output);
}
public function getList()
{
$requestData = $_REQUEST;
$start = $requestData['start'];
$limit = $requestData['length'];
$orderColumn=$requestData['order'][0]['column'];
$orderType=$requestData['order'][0]['dir'];
$search = $this->input->post('search')['value'];
if (!empty($search)) {
$data['name'] = $this->Formmapping_model->getNameByLimitBySearch($limit, $start, $search,$orderColumn, $orderType);
} else {
$data['name'] = $this->Formmapping_model->getNameByLimit($limit, $start, $orderColumn, $orderType);
}
$listCount = sizeof($data['name']);
foreach ($data['name'] as $data) {
static $slno = 1;
$options1 = '<a class="btn btn-primary" title="' . lang('Edit') .'" href="'.base_url().'formmapping/editMapping/?id='. $data->id .'" ><i class="la la-edit"></i>' . lang('Edit') .' </a>';
// $options2 = '<a class="btn btn-primary" title="' . lang('Preview') .'" href="#" onclick="previewModal('. $data->id .');" ><i class="la la-edit"></i>' . lang('Preview') .' </a>';
$info[] = array(
$slno,
$data->form_name,
//$data->template_id,
$data->template_name,
//$switch,
$options1,
);
$slno++;
}
$csrf_name = $this->security->get_csrf_token_name();
$csrf_hash = $this->security->get_csrf_hash();
if ($listCount > 0) {
$output = array(
"draw" => intval($requestData['draw']),
"recordsTotal" => $this->Formmapping_model->total_list(),
"recordsFiltered" => $listCount,
"data" => $info
);
}
else {
$output = array(
// "draw" => 1,
"recordsTotal" => 0,
"recordsFiltered" => 0,
"data" => []
);
$output[$csrf_name] = $csrf_hash;
}
echo json_encode($output);
}
}
/* End of file accountant.php */
/* Location: ./application/modules/accountant/controllers/accountant.php */