reports added

This commit is contained in:
gandhimathi 2018-04-03 17:19:48 +05:30
parent 62c45b3ba9
commit 308bc7cc07
14 changed files with 999 additions and 1 deletions

View File

@ -251,3 +251,8 @@ $route['updateSessionScheduleDetails'] = 'SessionSchedule_Controller/updateSessi
// halltickets
$route['getCourseSubjectDetails'] = 'HallTickets_Controller/getCourseSubjectDetails';
//Reports
$route['reportstatus'] = 'Report/status';
$route['reportbatchlist'] = 'Report/batch';
$route['reportmstatus'] = 'Report/mstatus';

View File

@ -0,0 +1,117 @@
<?php
/**
* Created by Visual Studio Code.
* User: Surendiran
* Date: 12/05/17
* Time: 01:05 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 Report extends REST_Controller {
function __construct()
{
// Construct the parent class
parent::__construct();
// load the model
$this->load->model('Reports_model', 'report_model');
}
public function status_post()
{
$bat = $this->post('bname');
$br = $this->post('brname');
$u = $this->post('univ');
$getStatus = $this->report_model->status($bat,$br,$u);
//print_r($getStatus);
if ($getStatus)
{
$getStatus['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getStatus, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else
{
// Set the response and exit
$this->response([
'message' => 'No records found!',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
}
}
public function mstatus_post()
{
$bat = $this->post('bname');
$br = $this->post('brname');
$u = $this->post('univ');
$getStatus = $this->report_model->mstatus($bat,$br,$u);
//print_r($getStatus);
if ($getStatus)
{
$getStatus['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getStatus, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else
{
// Set the response and exit
$this->response([
'message' => 'No records found!',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
}
}
public function batch_post()
{
$getStatus = $this->report_model->batch();
//print_r($getStatus);
if ($getStatus)
{
$getStatus['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getStatus, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else
{
// Set the response and exit
$this->response([
'message' => 'No records found!',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
}
}
}

View File

@ -0,0 +1,175 @@
<?php
/**
* Date: 11/9/17
* Time: 5:28 PM
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Reports_model extends CI_Model
{
public function status($bat=null,$br=null,$u=null){
$sql = "select @s:=@s+1 sl,sms.sid as ssid,std.name as name,std.father as father,br.bname as bname,ifnull(b.batch,'-') as batch,std.phone as phone,sms.cid as scid,sfp.bdate as bdate,sms.date as sdate,list.status as status,u.uname as uname,cm.course as course,sms.sem as sem,sfs.batch as fbatch,sfs.cid as fcid,cfd.syear as syear,sum(sfs.cf) as crsfee,sum(sfs.stf) as stf,sum(sfs.others) as others,(sum(sfs.cf) + sum(sfs.stf) + sum(sfs.others)) as total,ifnull(sfp.bamount,0) as bamount,(sum(sfs.cf) + (sum(sfs.stf) + sum(sfs.others)) - ifnull(sfp.bamount,0)) as balance
from (SELECT @s:= 0) AS s,
(SELECT StudentID as sid,CourseID as cid,ListCode as lcode,BranchCode as branch,SDate as date,Sem as sem FROM T_StudyMaterialStatus
group by sid,sem) as sms
left join
(SELECT FeesID as fid,BatchCode as batch,StudentID as sid,CourseID as cid,FeesType as ftype,sum(CourseFees) as cf,Sum(STFOrWR) as stf,sum(Others) as others FROM T_Students_Fees_Status
group by sid,batch) as sfs on sfs.sid=sms.sid
left join
(SELECT StudentID as sid,FeesId as fid,BillDate as bdate,sum(BillAmount) as bamount
FROM T_Students_Fees_PaidDetails
group by sid,fid,bdate) as sfp on sfp.sid=sfs.sid and sfp.fid=sfs.fid
left join
(SELECT ID as cid,CourseID as ccid,FeesType as ftype,Sem_Year as syear FROM T_Course_Fees_Details) as cfd
on cfd.cid=sms.cid
left join
(SELECT CourseID as cid,UniversityID as uid,CourseName as course FROM T_CourseMaster) as cm
on cm.cid=sfs.cid
left join
(SELECT UniversityID as uid,UniversityName as uname FROM T_UniversityMaster) as u
on u.uid=cm.uid
left join
(SELECT ListCode as lcode,ListName as status FROM T_PickListDetails) as list
on list.lcode=sms.lcode
left join
(SELECT StudentID as sid,MobileNumber as phone,FirstName as name,Fathername as father FROM T_StudentDetails) as std on std.sid=sms.sid
left join
(SELECT BatchCode as bcode,BatchName as batch FROM T_BatchMaster) as b on b.bcode=sfs.batch
left join
(SELECT BranchCode as brcode,BranchName as bname FROM T_BranchMaster) as br on br.brcode=sms.branch
where std.name != 'null'
";
if ($br!= ''){
$sql.=" and sms.branch = '".$br."'";
}
if ($bat!= ''){
$sql.=" and b.bcode = '".$bat."'";
}
if ($u!= ''){
$sql.=" and u.uid = '".$u."'";
}
$sql.=" group by ssid,sem,fbatch";
$sql.=" order by sl";
$leadDet=$this->db->query($sql);
$statusDetails = $leadDet->result();
if (count($statusDetails) > 0) {
$results['statusList'] = true;
$results['statusr'] = $statusDetails;
} else {
$results['statusList'] = false;
$results['message'] = 'No record found';
}
return $results;
}
public function batch(){
$sql = "SELECT BatchCode as batch,BatchName as bname FROM T_BatchMaster
group by batch;";
$b=$this->db->query($sql);
$batch = $b->result();
if (count($batch) > 0) {
$results['batchlist'] = true;
$results['batch'] = $batch;
} else {
$results['batchlist'] = false;
$results['message'] = 'No record found';
}
$sql = "SELECT BranchCode as brcode,BranchName as bname FROM T_BranchMaster";
$b=$this->db->query($sql);
$batch = $b->result();
if (count($batch) > 0) {
$results['branchlist'] = true;
$results['branch'] = $batch;
} else {
$results['branchlist'] = false;
$results['message'] = 'No record found';
}
$sql = "SELECT UniversityID as uid,UniversityName as uname FROM T_UniversityMaster";
$b=$this->db->query($sql);
$batch = $b->result();
if (count($batch) > 0) {
$results['univlist'] = true;
$results['univ'] = $batch;
} else {
$results['univlist'] = false;
$results['message'] = 'No record found';
}
return $results;
}
public function mstatus($bat=null,$br=null,$u=null){
$sql = "select @s:=@s+1 sl,sms.sid as ssid,std.name as name,std.father as father,br.bname as bname,ifnull(b.batch,'-') as batch,std.phone as phone,sms.cid as scid,sfp.bdate as bdate,list.status as status,u.uname as uname,cm.course as course,sms.sem as sem,sms.cdate as cdate,sfs.batch as fbatch,sfs.cid as fcid,cfd.syear as syear,sum(sfs.cf) as crsfee,sum(sfs.stf) as stf,sum(sfs.others) as others,(sum(sfs.cf) + sum(sfs.stf) + sum(sfs.others)) as total,ifnull(sfp.bamount,0) as bamount,(sum(sfs.cf) + (sum(sfs.stf) + sum(sfs.others)) - ifnull(sfp.bamount,0)) as balance
from
(SELECT StudentID as sid,CourseID as cid,BranchCode as branch,CDate as cdate,ListCode as lcode,Comments as cmts,Sem as sem FROM T_CertificationStatus) as sms
left join
(SELECT FeesID as fid,BatchCode as batch,StudentID as sid,CourseID as cid,FeesType as ftype,sum(CourseFees) as cf,Sum(STFOrWR) as stf,sum(Others) as others FROM T_Students_Fees_Status
group by sid,batch) as sfs on sfs.sid=sms.sid
left join
(SELECT StudentID as sid,FeesId as fid,BillDate as bdate,sum(BillAmount) as bamount
FROM T_Students_Fees_PaidDetails, (SELECT @s:= 0) AS s
group by sid,fid,bdate) as sfp on sfp.sid=sfs.sid and sfp.fid=sfs.fid
left join
(SELECT ID as cid,CourseID as ccid,FeesType as ftype,Sem_Year as syear FROM T_Course_Fees_Details) as cfd
on cfd.cid=sms.cid
left join
(SELECT CourseID as cid,UniversityID as uid,CourseName as course FROM T_CourseMaster) as cm
on cm.cid=sfs.cid
left join
(SELECT UniversityID as uid,UniversityName as uname FROM T_UniversityMaster) as u
on u.uid=cm.uid
left join
(SELECT ListCode as lcode,ListName as status FROM T_PickListDetails) as list
on list.lcode=sms.lcode
left join
(SELECT StudentID as sid,MobileNumber as phone,FirstName as name,Fathername as father FROM T_StudentDetails) as std on std.sid=sms.sid
left join
(SELECT BatchCode as bcode,BatchName as batch FROM T_BatchMaster) as b on b.bcode=sfs.batch
left join
(SELECT BranchCode as brcode,BranchName as bname FROM T_BranchMaster) as br on br.brcode=sms.branch
where std.name != 'null'
";
if ($br!= ''){
$sql.=" and sms.branch = '".$br."'";
}
if ($bat!= ''){
$sql.=" and b.bcode = '".$bat."'";
}
if ($u!= ''){
$sql.=" and u.uid = '".$u."'";
}
$sql.=" group by ssid,sem,fbatch";
$sql.=" order by sl";
$leadDet=$this->db->query($sql);
$mstatusDetails = $leadDet->result();
if (count($mstatusDetails) > 0) {
$results['statusList'] = true;
$results['mstatusr'] = $mstatusDetails;
} else {
$results['statusList'] = false;
$results['mmessage'] = 'No record found';
}
return $results;
}
}

View File

@ -75,6 +75,12 @@
"SESSIONMASTER":"SESSION DETAILS",
"SESSIONSCHEDULE": "SESSION SCHEDULE",
"HALLTICKET": "GENERATE HALLTICKET"
},
"report": {
"TITLE": "REPORTS",
"studmatstatus": "STUDY MATERIAL STATUS ",
"mstatus": "MARK CARD STATUS "
},
"student": {
"MAIN": "STUDENTS",

View File

@ -176,7 +176,9 @@ app.constant('JS_REQUIRES', {
//*** Filters
'htmlToPlaintext': 'assets/js/filters/htmlToPlaintext.js'
'htmlToPlaintext': 'assets/js/filters/htmlToPlaintext.js',
// reports
'reportCtrl':'assets/js/controllers/reportCtrl.js'
},
//*** angularJS Modules
modules: [{

View File

@ -570,6 +570,25 @@ app.config(['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$com
}).state('error.500', {
url: '/500',
templateUrl: "assets/views/utility_500.html",
}).state('app.reports', {
url: '/reports',
template: '<div ui-view class="fade-in-up"></div>',
title: 'Reports',
ncyBreadcrumb: {
label: 'Reports'
}
}).state('app.reports.studymaterial', {
url: '/reportCtrl',
templateUrl: "assets/views/report_studymaterialstatus.html",
resolve: loadSequence('ui.select','reportCtrl','ngTable', 'ladda', 'angular-ladda'),
title: 'Study Material Status Report',
}).state('app.reports.markcard', {
url: '/reportCtrl',
templateUrl: "assets/views/report_markcardstatus.html",
resolve: loadSequence('ui.select','reportCtrl','ngTable', 'ladda', 'angular-ladda'),
title: 'Mark Card Status Report',
});
// $locationProvider.html5Mode(true);

View File

@ -0,0 +1,100 @@
'use strict';
/*** controller for Wizard Form example***/
app.controller('reportCtrl', ["$scope", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', '$window',
function ($scope, apiPoint, $http, SweetAlert, $state, md5, ipCookie, $window) {
$scope.batch = {
"name": "",
"brname": "",
"univ": "",
};
$scope.batch = function () {
var bat = {
method: 'POST',
url: apiPoint.url + 'reportbatchlist/',
headers: {
'Content-Type': 'application/json'
}
};
$http(bat).then(function (response) {
if (response.data) {
$scope.batch = response.data.batch;
$scope.branch = response.data.branch;
$scope.univ = response.data.univ;
console.log($scope.branch);
} else {
}
});
}
$scope.onSubmit = function() {
//alert($scope.batch.name);
$scope.statusr = '';
$scope.message = '';
var sta = {
method: 'POST',
url: apiPoint.url + 'reportstatus/',
headers: {
'Content-Type': 'application/json'
},
data: {
bname : $scope.batch.name,
brname : $scope.batch.brname,
univ : $scope.batch.univ
}
};
$http(sta).then(function (response) {
if (response.data.statusList == true) {
$scope.statusr = response.data.statusr;
} else {
$scope.message = response.data.message;
}
});
}
$scope.mSubmit = function() {
//alert($scope.batch.name);
$scope.statusr = '';
$scope.message = '';
var msta = {
method: 'POST',
url: apiPoint.url + 'reportmstatus/',
headers: {
'Content-Type': 'application/json'
},
data: {
bname : $scope.batch.name,
brname : $scope.batch.brname,
univ : $scope.batch.univ
}
};
$http(msta).then(function (response) {
if (response.data.statusList == true) {
$scope.mstatusr = response.data.mstatusr;
} else {
$scope.mmessage = response.data.message;
}
});
}
}]);

View File

@ -319,6 +319,32 @@
</div>
</a>
</li>
<li ng-class="{'active open':$state.includes('app.reports')}">
<a href="javascript:void(0)">
<div class="item-content">
<div class="item-media">
<i class="ti-bar-chart"></i>
</div>
<div class="item-inner">
<span class="title" translate="sidebar.nav.report.TITLE"> REPORTS </span><i class="icon-arrow"></i>
</div>
</div>
</a>
<ul class="sub-menu">
<li ui-sref-active="active">
<a ui-sref="app.reports.studymaterial" ng-click="checkSuperAdmin()">
<span class="title" translate="sidebar.nav.report.studmatstatus">Study Material Status</span>
</a>
</li>
<li ui-sref-active="active">
<a ui-sref="app.reports.markcard" ng-click="checkSuperAdmin()">
<span class="title" translate="sidebar.nav.report.mstatus">Mark Card Status</span>
</a>
</li>
</ul>
</li>
<li ng-class="{'active open':$state.includes('app.myprofile')}">
<a ui-sref="app.myprofile" ng-click="checkSuperAdmin()">
<div class="item-content">

View File

@ -0,0 +1,146 @@
<section id="page-title">
<div class="row">
<div class="col-sm-8">
<h1 class="mainTitle">Mark Card Status Report</h1>
</div>
<!-- <div ncy-breadcrumb></div> -->
</div>
</section>
<style>
/* .sort-icon {
font-size: 9px;
margin-left: 5px;
}
th {
cursor: pointer;
} */
</style>
<script type="text/javascript" src="bower_components/ng-table-excel-export/ng-table-excel-export.min.js">
</script>
<div class="container-fluid container-fullw bg-white">
<div ng-controller="reportCtrl" ng-init="batch()">
<form name="Form" id="form" novalidate ng-submit="mSubmit()" method="post">
<fieldset>
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-3">
<label for="form-field-select-2">
Branch
</label>
<select ui-select2 class="form-control" tabindex="2" class="cs-select cs-skin-elastic" name="batch" ng-model="batch.brname">
<option value="" selected>Select Branch</option>
<option ng-repeat="br in branch" value="{{br.brcode}}"> {{br.bname}}</option>
</select>
</div>
<div class="col-md-3">
<label for="form-field-select-2">
University
</label>
<select ui-select2 class="form-control" tabindex="2" class="cs-select cs-skin-elastic" name="batch" ng-model="batch.univ">
<option value="" selected>Select University</option>
<option ng-repeat="u in univ" value="{{u.uid}}"> {{u.uname}}</option>
</select>
</div>
<div class="col-md-3">
<label for="form-field-select-2">
Batch
</label>
<select ui-select2 class="form-control" tabindex="2" class="cs-select cs-skin-elastic" name="batch" ng-model="batch.name">
<option value="" selected>Select Batch</option>
<option ng-repeat="b in batch" value="{{b.batch}}"> {{b.bname}}</option>
</select>
</div>
<!-- <div class="col-md-3">
<label for="form-field-select-2">
Batch
</label>
<select class="form-control" tabindex="3" class="cs-select cs-skin-elastic" name="batch" ng-model="searchData.Batch" ng-change="getValueChange()">
<option value="" selected>Select Batch</option>
<option ng-repeat="itemBatch in batchData" value="{{itemBatch.BatchCode}}">{{itemBatch.BatchName}}</option>
</select>
</div> -->
<div class="col-md-2" style="padding-top: 2.3%;">
<div class="pull-right">
<button type="submit" class="btn btn-success btn-o" tabindex="8">
Submit
</button>
</div>
</div>
</div>
</div>
</div>
</fieldset>
</form>
<!-- <pre>{{statusr | json}}</pre> -->
<div style="text-align: right;">
<a download="Mark_Card_status({{batch.name}}).xls" href="#" onclick="return ngTableExcelExport.excel(this, 'datatable', 'Study Material Status');">
<button class="btn btn-success btn-o" ng-click="Export()" tabindex="8">Export to Excel</button>
</a>
</div>
<div class="table-responsive">
<table id="datatable" class="table table-hover">
<thead>
<tr>
<th>SL.No</th>
<th>Intial Payment Paid Date</th>
<th>Student ID</th>
<th>Student Name</th>
<th>Father Name</th>
<th>Course</th>
<th>Sem/Year</th>
<th>Phone No</th>
<th>University</th>
<th>Balance Fee</th>
<th>Mark Card Status</th>
<th>Date</th>
</tr>
</thead>
<tbody dir-paginate="p in mstatusr|filter:search:strict|itemsPerPage:10">
<tr>
<td>{{p.sl}}</td>
<td>{{p.bdate}}</td>
<td>{{p.ssid}}</td>
<td>{{p.name}}</td>
<td>{{p.father}}</td>
<td>{{p.course}}</td>
<td>{{p.syear}}({{p.sem}})</td>
<td>{{p.phone}}</td>
<td>{{p.univ}}</td>
<td>{{p.balance}}</td>
<td>{{p.status}}</td>
<td>{{p.cdate}}</td>
</tr>
</tbody>
</table>
<h3 style="text-align:center;">{{message}}</h3>
</div>
<dir-pagination-controls direction-links="true" boundary-links="true">
</dir-pagination-controls>
</div>
</div>

View File

@ -0,0 +1,146 @@
<section id="page-title">
<div class="row">
<div class="col-sm-8">
<h1 class="mainTitle">Study Material Status Report</h1>
</div>
<!-- <div ncy-breadcrumb></div> -->
</div>
</section>
<style>
/* .sort-icon {
font-size: 9px;
margin-left: 5px;
}
th {
cursor: pointer;
} */
</style>
<script type="text/javascript" src="bower_components/ng-table-excel-export/ng-table-excel-export.min.js">
</script>
<div class="container-fluid container-fullw bg-white">
<div ng-controller="reportCtrl" ng-init="batch()">
<form name="Form" id="form" novalidate ng-submit="onSubmit()" method="post">
<fieldset>
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-3">
<label for="form-field-select-2">
Branch
</label>
<select ui-select2 class="form-control" tabindex="2" class="cs-select cs-skin-elastic" name="batch" ng-model="batch.brname">
<option value="" selected>Select Branch</option>
<option ng-repeat="br in branch" value="{{br.brcode}}"> {{br.bname}}</option>
</select>
</div>
<div class="col-md-3">
<label for="form-field-select-2">
University
</label>
<select ui-select2 class="form-control" tabindex="2" class="cs-select cs-skin-elastic" name="batch" ng-model="batch.univ">
<option value="" selected>Select University</option>
<option ng-repeat="u in univ" value="{{u.uid}}"> {{u.uname}}</option>
</select>
</div>
<div class="col-md-3">
<label for="form-field-select-2">
Batch
</label>
<select ui-select2 class="form-control" tabindex="2" class="cs-select cs-skin-elastic" name="batch" ng-model="batch.name">
<option value="" selected>Select Batch</option>
<option ng-repeat="b in batch" value="{{b.batch}}"> {{b.bname}}</option>
</select>
</div>
<!-- <div class="col-md-3">
<label for="form-field-select-2">
Batch
</label>
<select class="form-control" tabindex="3" class="cs-select cs-skin-elastic" name="batch" ng-model="searchData.Batch" ng-change="getValueChange()">
<option value="" selected>Select Batch</option>
<option ng-repeat="itemBatch in batchData" value="{{itemBatch.BatchCode}}">{{itemBatch.BatchName}}</option>
</select>
</div> -->
<div class="col-md-2" style="padding-top: 2.3%;">
<div class="pull-right">
<button type="submit" class="btn btn-success btn-o" tabindex="8">
Submit
</button>
</div>
</div>
</div>
</div>
</div>
</fieldset>
</form>
<!-- <pre>{{statusr | json}}</pre> -->
<div style="text-align: right;">
<a download="Study_material_status({{batch.name}}).xls" href="#" onclick="return ngTableExcelExport.excel(this, 'datatable', 'Study Material Status');">
<button class="btn btn-success btn-o" ng-click="Export()" tabindex="8">Export to Excel</button>
</a>
</div>
<div class="table-responsive">
<table id="datatable" class="table table-hover">
<thead>
<tr>
<th>SL.No</th>
<th>Intial Payment Paid Date</th>
<th>Student ID</th>
<th>Student Name</th>
<th>Father Name</th>
<th>Course</th>
<th>Sem/Year</th>
<th>Phone No</th>
<th>University</th>
<th>Balance Fee</th>
<th>Study Material Status</th>
<th>Date</th>
</tr>
</thead>
<tbody dir-paginate="p in statusr|filter:search:strict|itemsPerPage:10">
<tr>
<td>{{p.sl}}</td>
<td>{{p.bdate}}</td>
<td>{{p.ssid}}</td>
<td>{{p.name}}</td>
<td>{{p.father}}</td>
<td>{{p.course}}</td>
<td>{{p.syear}}({{p.sem}})</td>
<td>{{p.phone}}</td>
<td>{{p.univ}}</td>
<td>{{p.balance}}</td>
<td>{{p.status}}</td>
<td>{{p.date}}</td>
</tr>
</tbody>
</table>
<h3 style="text-align:center;">{{message}}</h3>
</div>
<dir-pagination-controls direction-links="true" boundary-links="true">
</dir-pagination-controls>
</div>
</div>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,210 @@
/**
* ngTableExcelExport 1.0.0
* JavaScript export to Excel or CSV from HTML tables automatically in the browser and also compatible with all browsers.
*
* @author: Murugavel Ramachandran (blsrm@yahoo.com)
* @url: https://github.com/blsrm/ngTableExcelExport
*
*/
/*jslint browser: true, bitwise: true, vars: true, white: true */
/*global define, exports, module */
(function (global) {
'use strict';
var ngTableExcelExport = (function() {
function b64toBlob(b64Data, contentType, sliceSize) {
// function taken from http://stackoverflow.com/a/16245768/2591950
// author Jeremy Banks http://stackoverflow.com/users/1114/jeremy-banks
contentType = contentType || '';
sliceSize = sliceSize || 512;
var byteCharacters = window.atob(b64Data);
var byteArrays = [];
var offset;
for (offset = 0; offset < byteCharacters.length; offset += sliceSize) {
var slice = byteCharacters.slice(offset, offset + sliceSize);
var byteNumbers = new Array(slice.length);
var i;
for (i = 0; i < slice.length; i = i + 1) {
byteNumbers[i] = slice.charCodeAt(i);
}
var byteArray = new window.Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
var blob = new window.Blob(byteArrays, {
type: contentType
});
return blob;
}
var version = "1.5.0";
var uri = {excel: 'data:application/vnd.ms-excel;base64,', csv: 'data:application/csv;base64,'};
var template = {excel: '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=ProgId content=Excel.Sheet> <meta name=Generator content="Microsoft Excel 11"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table border="1">{table}</table></body></html>'};
var csvDelimiter = ",";
var csvNewLine = "\r\n";
var base64 = function(s) {
return window.btoa(window.unescape(encodeURIComponent(s)));
};
var format = function(s, c) {
return s.replace(new RegExp("{(\\w+)}", "g"), function(m, p) {
return c[p];
});
};
var get = function(element) {
if (!element.nodeType) {
return document.getElementById(element);
}
return element;
};
var fixCSVField = function(value) {
var fixedValue = value;
var addQuotes = (value.indexOf(csvDelimiter) !== -1) || (value.indexOf('\r') !== -1) || (value.indexOf('\n') !== -1);
var replaceDoubleQuotes = (value.indexOf('"') !== -1);
if (replaceDoubleQuotes) {
fixedValue = fixedValue.replace(/"/g, '""');
}
if (addQuotes || replaceDoubleQuotes) {
fixedValue = '"' + fixedValue + '"';
}
return fixedValue;
};
var tableToCSV = function(table) {
var data = "SEP="+csvDelimiter+csvNewLine;
var i, j, row, col;
var columnStart = 0;
for (i = 0; i < table.rows.length; i=i+1) {
row = table.rows[i];
var rowData = '';
//Checking ng table style for filters
if(row.className.indexOf('ng-table-filters') !== -1) {
continue;
}
//remove first column having check box in angular JS, in future will provide option from UI to control
if(table.rows[0].cells[0].textContent.trim() === '') {
columnStart = 1;
}else {
columnStart = 0;
}
for (j = columnStart; j < row.cells.length; j=j+1) {
col = row.cells[j];
rowData = rowData + fixCSVField(col.textContent.trim()) + (j ? csvDelimiter : ' ');
}
rowData = rowData.slice(0, rowData.length - 1); //remove last semicolon
data += rowData + csvNewLine;
}
return data;
};
var tableToHTML = function(table) {
var data = "";
var i, j, row, col;
var columnStart = 5;
for (i = 0; i < table.rows.length; i=i+1) {
row = table.rows[i];
var rowData = '';
//Checking ng table style for filters
if(row.className.indexOf('ng-table-filters') !== -1) {
continue;
}
//remove first column having check box in angular JS, in future will provide option from UI to control
if(table.rows[0].cells[0].textContent.trim() === '') {
columnStart = 1;
}else {
columnStart = 0;
}
for (j = columnStart; j < row.cells.length; j=j+1) {
col = row.cells[j];
if (i === 0) {
rowData += '<th>' + col.textContent.trim() + '</th>';
} else {
rowData += '<td>' + col.textContent.trim() + '</td>';
}
}
data += '<tr>' + rowData + '</tr>';
}
// return data;
};
function createDownloadLink(anchor, base64data, exporttype, filename) {
var blob;
if (window.navigator.msSaveBlob) {
blob = b64toBlob(base64data, exporttype);
window.navigator.msSaveBlob(blob, filename);
return false;
} else if(window.URL.createObjectURL) {
blob = b64toBlob(base64data, exporttype);
var blobUrl = window.URL.createObjectURL(blob, exporttype, filename);
anchor.href = blobUrl;
} else {
var hrefvalue = "data:" + exporttype + ";base64," + base64data;
anchor.download = filename;
anchor.href = hrefvalue;
}
// Return true to allow the link to work
return true;
}
var ee = {
/** @export */
excel: function(anchor, table, name) {
table = get(table);
var htmlTableData = tableToHTML(table);
var ctx = {worksheet: name || 'Worksheet', table: htmlTableData};
var b64 = base64(format(template.excel, ctx));
return createDownloadLink(anchor, b64, 'application/vnd.ms-excel',name+'.xls');
},
/** @export */
csv: function(anchor, table, name, delimiter, newLine) {
if (delimiter !== undefined && delimiter) {
csvDelimiter = delimiter;
}
if (newLine !== undefined && newLine) {
csvNewLine = newLine;
}
table = get(table);
var csvData = tableToCSV(table);
var b64 = base64(csvData);
return createDownloadLink(anchor,b64,'application/csv',name+'.csv');
}
};
return ee;
}());
// AMD support
if (typeof define === 'function' && define.amd) {
define(function () { return ngTableExcelExport; });
// CommonJS and Node.js module support.
} else if (typeof exports !== 'undefined') {
// Support Node.js specific `module.exports` (which can be a function)
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = ngTableExcelExport;
}
// But always support CommonJS module 1.1.1 spec (`exports` cannot be a function)
exports.ngTableExcelExport = ngTableExcelExport;
} else {
global.ngTableExcelExport = ngTableExcelExport;
}
})(this);

View File

@ -0,0 +1,15 @@
/**
* ngTableExcelExport 1.0.0
* JavaScript export to Excel or CSV from HTML tables automatically in the browser and also compatible with all browsers.
*
* @author: Murugavel Ramachandran (blsrm@yahoo.com)
* @url: https://github.com/blsrm/ngTableExcelExport
*
*/
/*jslint browser: true, bitwise: true, vars: true, white: true */
/*global define, exports, module */
(function(m){var g=function(){function g(h,a,e){a=a||"";e=e||512;h=window.atob(h);var c=[],b;for(b=0;b<h.length;b+=e){var f=h.slice(b,b+e),k=Array(f.length),d;for(d=0;d<f.length;d+=1)k[d]=f.charCodeAt(d);f=new window.Uint8Array(k);c.push(f)}return new window.Blob(c,{type:a})}function q(h,a,e,c){if(window.navigator.msSaveBlob)return a=g(a,e),window.navigator.msSaveBlob(a,c),!1;window.URL.createObjectURL?(a=g(a,e),e=window.URL.createObjectURL(a,e,c),h.href=e):(h.download=c,h.href="data:"+e+";base64,"+
a);return!0}var n=",",p="\r\n",m=function(h,a){return h.replace(RegExp("{(\\w+)}","g"),function(e,c){return a[c]})};return{excel:function(h,a,e){a=a.nodeType?a:document.getElementById(a);var c="",b,f,k,d;for(b=0;b<a.rows.length;b+=1){k=a.rows[b];var l="";if(-1===k.className.indexOf("ng-table-filters")){for(f=""===a.rows[0].cells[0].textContent.trim()?1:0;f<k.cells.length;f+=1)d=k.cells[f],l=0===b?l+("<th>"+d.textContent.trim()+"</th>"):l+("<td>"+d.textContent.trim()+"</td>");c+="<tr>"+l+"</tr>"}}a=
window.btoa(window.unescape(encodeURIComponent(m('<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=ProgId content=Excel.Sheet> <meta name=Generator content="Microsoft Excel 11"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\x3c!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--\x3e</head><body><table border="1">{table}</table></body></html>',
{worksheet:e||"Worksheet",table:c}))));return q(h,a,"application/vnd.ms-excel",e+".xls")},csv:function(h,a,e,c,b){void 0!==c&&c&&(n=c);void 0!==b&&b&&(p=b);a=a.nodeType?a:document.getElementById(a);c="SEP="+n+p;var f,k,d;for(b=0;b<a.rows.length;b+=1){k=a.rows[b];var l="";if(-1===k.className.indexOf("ng-table-filters")){for(f=""===a.rows[0].cells[0].textContent.trim()?1:0;f<k.cells.length;f+=1){d=k.cells[f];var g=d.textContent.trim();d=g;var m=-1!==g.indexOf(n)||-1!==g.indexOf("\r")||-1!==g.indexOf("\n");
(g=-1!==g.indexOf('"'))&&(d=d.replace(/"/g,'""'));if(m||g)d='"'+d+'"';l=l+d+(f?n:" ")}l=l.slice(0,l.length-1);c+=l+p}}a=window.btoa(window.unescape(encodeURIComponent(c)));return q(h,a,"application/csv",e+".csv")}}}();"function"===typeof define&&define.amd?define(function(){return g}):"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=g),exports.ngTableExcelExport=g):m.ngTableExcelExport=g})(this);

View File

@ -0,0 +1,15 @@
/**
* ngTableExcelExport 1.0.0
* JavaScript export to Excel or CSV from HTML tables automatically in the browser and also compatible with all browsers.
*
* @author: Murugavel Ramachandran (blsrm@yahoo.com)
* @url: https://github.com/blsrm/ngTableExcelExport
*
*/
/*jslint browser: true, bitwise: true, vars: true, white: true */
/*global define, exports, module */
(function(m){var g=function(){function g(h,a,e){a=a||"";e=e||512;h=window.atob(h);var c=[],b;for(b=0;b<h.length;b+=e){var f=h.slice(b,b+e),k=Array(f.length),d;for(d=0;d<f.length;d+=1)k[d]=f.charCodeAt(d);f=new window.Uint8Array(k);c.push(f)}return new window.Blob(c,{type:a})}function q(h,a,e,c){if(window.navigator.msSaveBlob)return a=g(a,e),window.navigator.msSaveBlob(a,c),!1;window.URL.createObjectURL?(a=g(a,e),e=window.URL.createObjectURL(a,e,c),h.href=e):(h.download=c,h.href="data:"+e+";base64,"+
a);return!0}var n=",",p="\r\n",m=function(h,a){return h.replace(RegExp("{(\\w+)}","g"),function(e,c){return a[c]})};return{excel:function(h,a,e){a=a.nodeType?a:document.getElementById(a);var c="",b,f,k,d;for(b=0;b<a.rows.length;b+=1){k=a.rows[b];var l="";if(-1===k.className.indexOf("ng-table-filters")){for(f=""===a.rows[0].cells[0].textContent.trim()?1:0;f<k.cells.length;f+=1)d=k.cells[f],l=0===b?l+("<th>"+d.textContent.trim()+"</th>"):l+("<td>"+d.textContent.trim()+"</td>");c+="<tr>"+l+"</tr>"}}a=
window.btoa(window.unescape(encodeURIComponent(m('<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=ProgId content=Excel.Sheet> <meta name=Generator content="Microsoft Excel 11"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\x3c!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--\x3e</head><body><table border="1">{table}</table></body></html>',
{worksheet:e||"Worksheet",table:c}))));return q(h,a,"application/vnd.ms-excel",e+".xls")},csv:function(h,a,e,c,b){void 0!==c&&c&&(n=c);void 0!==b&&b&&(p=b);a=a.nodeType?a:document.getElementById(a);c="SEP="+n+p;var f,k,d;for(b=0;b<a.rows.length;b+=1){k=a.rows[b];var l="";if(-1===k.className.indexOf("ng-table-filters")){for(f=""===a.rows[0].cells[0].textContent.trim()?1:0;f<k.cells.length;f+=1){d=k.cells[f];var g=d.textContent.trim();d=g;var m=-1!==g.indexOf(n)||-1!==g.indexOf("\r")||-1!==g.indexOf("\n");
(g=-1!==g.indexOf('"'))&&(d=d.replace(/"/g,'""'));if(m||g)d='"'+d+'"';l=l+d+(f?n:" ")}l=l.slice(0,l.length-1);c+=l+p}}a=window.btoa(window.unescape(encodeURIComponent(c)));return q(h,a,"application/csv",e+".csv")}}}();"function"===typeof define&&define.amd?define(function(){return g}):"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=g),exports.ngTableExcelExport=g):m.ngTableExcelExport=g})(this);