<?php
class Fileservice extends CI_Controller
{
/**
*
*/
public function __construct()
{
/*call CodeIgniter's default Constructor*/
parent::__construct();
/*load Model*/
$this->load->model('Fileservice_model');
}
public function index()
{
$data = array();
$data['page_title'] = 'Records';
$data['records'] = $this->Fileservice_model->getRecords();
$data['main_content'] = $this->load->view('admin/customers/recievedfiles', $data, TRUE);
$this->load->view('admin/index', $data);
}
public function recievedfiles()
{
$data = array();
$data['page_title'] = 'recievedfiles';
$data['records'] = $this->Fileservice_model->getRecords();
$data['main_content'] = $this->load->view('admin/customers/recievedfiles', $data, true);
$this->load->view('admin/index', $data);
}
public function sendfile()
{
$data = array();
$data['page_title'] = 'sendfile';
$data['records'] = $this->Fileservice_model->getRecords();
$data['main_content'] = $this->load->view('admin/customers/sendfile', $data, true);
$this->load->view('admin/index', $data);
}
public function viewfile()
{
$data = array();
$data['page_title'] = 'viewfile';
$data['viewfile'] = $this->Fileservice_model->getRecords();
$data['main_content'] = $this->load->view('admin/customers/viewfile', $data, true);
$this->load->view('admin/index', $data);
}
public function record($record_id){
$data = array();
$data['page_title'] = 'Record';
$data['record'] = $this->Fileservice_model->getRecordById($record_id);
if( !$data['record']){
$this->session->set_flashdata('error', "record not found");
redirect(site_url('admin/fileservice'));
}
$data['main_content'] = $this->load->view('admin/customers/viewfile', $data, TRUE);
$this->load->view('admin/index', $data);
}
public function deleterecord($record_id){
$this->Fileservice_model->deleteRecordById($record_id);
$this->session->set_flashdata('success', "record deleted");
redirect(site_url('admin/fileservice/recievedfiles'));
}
public function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = '*';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('sendfile'))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('sendfile', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
}
redirect(site_url('admin/fileservice/recievedfiles'));
}
/*Insert*/
public function savedata()
{
/*Check submit button */
$data['ticket_id'] = $this->input->post('ticket_id');
$data['vmake'] = $this->input->post('vmake');
$data['vmodel'] = $this->input->post('vmodel');
$data['vengine'] = $this->input->post('vengine');
$data['vfuel'] = $this->input->post('vfuel');
$data['ebrand'] = $this->input->post('ebrand');
$data['etype'] = $this->input->post('etype');
$data['esw'] = $this->input->post('esw');
$data['ehw'] = $this->input->post('ehw');
$data['esolutions'] = $this->input->post('esolutions');
$data['etuning'] = $this->input->post('etuning');
$data['etool'] = $this->input->post('etool');
$data['emessage'] = $this->input->post('emessage');
$data['efile'] = $this->input->post('efile');
$data['efilemod'] = $this->input->post('efilemod');
$data['status'] = $this->input->post('status');
$data['date_created'] = date('Y-m-d H:i:s');
$response = $this->Fileservice_model->saveRecord($data);
if ($response) {
$this->session->set_flashdata('success', "Records Saved Successfully . ID :" . $response);
} else {
$this->session->set_flashdata('error', "Error occurred");
}
redirect(site_url('admin/fileservice/recievedfiles'));
}