86 lines
2.5 KiB
PHP
86 lines
2.5 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: kms
|
|
* Date: 11/13/17
|
|
* Time: 7:40 PM
|
|
*/
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
|
|
/** @noinspection PhpIncludeInspection */
|
|
require_once APPPATH . '/libraries/REST_Controller.php';
|
|
|
|
/**
|
|
* This is an example of a few basic user interaction methods you could use
|
|
* all done with a hardcoded array
|
|
*
|
|
* @package CodeIgniter
|
|
* @subpackage Rest Server
|
|
* @category Controller
|
|
* @author
|
|
* @license MIT
|
|
* @link
|
|
*/
|
|
class Branch_Controller extends REST_Controller {
|
|
|
|
function __construct()
|
|
{
|
|
// Construct the parent class
|
|
parent::__construct();
|
|
// Configure limits on our controller methods
|
|
// Ensure you have created the 'limits' table and enabled 'limits' within application/config/rest.php
|
|
$this->methods['getBranchDetails_post']['limit'] = 500; // 50 requests per hour per user/key
|
|
$this->methods['uploadFiles_post']['limit'] = 500; // 50 requests per hour per user/key
|
|
|
|
// load the model
|
|
$this->load->model('Branch_model', 'branch_model');
|
|
}
|
|
/*
|
|
* get branch details
|
|
* created by kms
|
|
* */
|
|
public function getBranchDetails_get()
|
|
{
|
|
$token = '';
|
|
$tokens = AUTHORIZATION::validateToken($token);
|
|
print_r($tokens);die;
|
|
$requestedBy = $this->post('requestedBy');
|
|
$getBranch = $this->branch_model->getBranch($requestedBy);
|
|
if ($getBranch['branchStatus'])
|
|
{
|
|
// Set the response and exit
|
|
$this->response($getBranch);
|
|
}
|
|
else
|
|
{
|
|
// Set the response and exit
|
|
$this->response([
|
|
'message' => 'No records found!',
|
|
'branchStatus' => false
|
|
]);
|
|
}
|
|
}
|
|
// upload file details
|
|
public function uploadFiles_post()
|
|
{
|
|
$req['doc_name'] = $_FILES['fileKey']['name'];
|
|
$req['doc_size'] = $_FILES['fileKey']['size'];
|
|
$req['doc_source'] = $_FILES['fileKey']['tmp_name'];
|
|
$uploadDetails=$this->branch_model->uploadFiles($req);
|
|
if ($uploadDetails['uploadStatus'])
|
|
{
|
|
// Set the response and exit
|
|
$this->response($uploadDetails);
|
|
}
|
|
else
|
|
{
|
|
// Set the response and exit
|
|
$this->response([
|
|
'message' => 'Upload Faild!',
|
|
'uploadStatus' => false
|
|
]);
|
|
}
|
|
}
|
|
} |