Fairoj : Contribute changes are done

This commit is contained in:
venbatechnologies@gmail.com 2019-09-30 18:54:23 +05:30
parent 25a064598f
commit f5f2a9668d
25 changed files with 777 additions and 52 deletions

View File

@ -7331,6 +7331,11 @@
"resolved": "https://registry.npmjs.org/ngx-color-picker/-/ngx-color-picker-7.5.0.tgz",
"integrity": "sha512-bTW16A3IitWUNGc3kZtE+N1r3FpmUj7uJTG80eym2nQLvsROkMntalKJDo1SQVQhh9Nh4N9C88UezdMg8fjR5Q=="
},
"ngx-cookie-service": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/ngx-cookie-service/-/ngx-cookie-service-2.2.0.tgz",
"integrity": "sha512-2kaC1itlEMxiMAPJ320hOpcwU9vhvjbKQCZ1Go6bGhYjJtqG7eYvhNP7mM9IhFz1/afG2tBryJPySWmFUGhRpA=="
},
"ngx-perfect-scrollbar": {
"version": "5.0.0-7",
"resolved": "https://registry.npmjs.org/ngx-perfect-scrollbar/-/ngx-perfect-scrollbar-5.0.0-7.tgz",

View File

@ -48,6 +48,7 @@
"ng2-tree": "^2.0.0-alpha.10",
"ng2-validation": "^4.2.0",
"ngx-color-picker": "^7.0.2",
"ngx-cookie-service": "^2.2.0",
"ngx-perfect-scrollbar": "5.0.0-7",
"ngx-slick-carousel": "^0.4.6",
"perfect-scrollbar": "^1.4.0",

View File

@ -1,17 +1,25 @@
import { Component } from '@angular/core';
import { TranslateService} from '@ngx-translate/core';
import { CookieService } from 'ngx-cookie-service';
@Component({
selector: 'app-root',
template: '<router-outlet></router-outlet>'
})
export class AppComponent {
constructor(translate: TranslateService) {
constructor(translate: TranslateService,private cookieService:CookieService) {
translate.addLangs(['en', 'fr']);
translate.setDefaultLang('en');
const browserLang: string = translate.getBrowserLang();
translate.use(browserLang.match(/en|fr/) ? browserLang : 'en');
console.log("app component")
var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var dateTime = date+'T'+time;
console.log(dateTime)
this.cookieService.set('Tn_Schools_user_in',dateTime);
// this.cookieService.set('Tn_Schools_user_in',date.toString(),-1,'/','csr')
}
}

View File

@ -51,6 +51,12 @@ import { AuthGuardService } from './shared/guards/auth-guard.service';
import { MatTableDataSource, MatTableModule } from '@angular/material';
import { SchoolDetailsService } from './shared/school-details.service';
// import { AddEventModule } from './add-event.module';
import {HashLocationStrategy,LocationStrategy} from '@angular/common';
import {CookieService} from 'ngx-cookie-service'
import { LoginComponent } from './components/login/login.component';
import { RegisterComponent } from './components/register/register.component';
import { ReqListComponent } from './components/req-list/req-list.component';
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
@ -75,7 +81,11 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
ProjectsComponent,
PaymentComponent,
PaymentConfirmationComponent,
MyAccountComponent
MyAccountComponent,
LoginComponent,
RegisterComponent,
ReqListComponent,
// ProjectListComponent
],
imports: [
@ -115,6 +125,8 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
],
providers: [
TranslateService,
CookieService,
{provide: LocationStrategy, useClass: HashLocationStrategy},
{
provide: PERFECT_SCROLLBAR_CONFIG,
useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG
@ -122,7 +134,8 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
provide:HTTP_INTERCEPTORS,
useClass: TokenInterceptorService,
multi: true
},AuthGuardService,SchoolDetailsService,
},AuthGuardService,
SchoolDetailsService,
],
entryComponents: [],
bootstrap: [AppComponent]

View File

@ -9,6 +9,8 @@ import { PaymentComponent } from './components/payment/payment.component';
import { PaymentConfirmationComponent } from './components/payment-confirmation/payment-confirmation.component';
import { MyAccountComponent } from './components/my-account/my-account.component';
import { AuthGuardService } from './shared/guards/auth-guard.service';
import { LoginComponent } from './components/login/login.component';
import { RegisterComponent } from './components/register/register.component';
export const AppRoutes: Routes = [{
path: '',
redirectTo: 'home',
@ -31,17 +33,29 @@ export const AppRoutes: Routes = [{
component:ProjectsComponent
},
{
canActivate:[AuthGuardService],
path : 'payment',
component:PaymentComponent
},
{
canActivate:[AuthGuardService],
path : 'paymentconfirmation',
component:PaymentConfirmationComponent
},
{
path : 'my-account',
component:MyAccountComponent
}
},
{
path:'login',
component:LoginComponent
},
{
path:'register',
component:RegisterComponent
}
]
},
{

View File

@ -66,7 +66,7 @@
<!-- School Column -->
<ng-container matColumnDef="School">
<th style="width: 25% !important;text-align: center !important;" mat-header-cell *matHeaderCellDef mat-sort-header>School</th>
<td style="width: 25% !important;" mat-cell *matCellDef="let row"> <a [routerLink]="'/home/project-detail'">{{row.school_name}}</a>, {{row.block_name}} Block, {{row.district_name}} District.</td>
<td style="width: 25% !important;" mat-cell *matCellDef="let row"> <a (click)="goToProjectDet(row)">{{row.school_name}}</a>, {{row.block_name}} Block, {{row.district_name}} District.</td>
</ng-container>
<!-- Quantity Column -->
@ -78,7 +78,7 @@
<!-- Sponsor Column -->
<ng-container matColumnDef="Sponsor Qty">
<th style="width: 10% !important;" mat-header-cell *matHeaderCellDef mat-sort-header> Sponsor Qty </th>
<td style="width: 10% !important;" mat-cell *matCellDef="let row;let i = index"> <input step="1" min="0" max="" title="Qty" class="text" size="2" type="number" (change)="somethingChanged($event.target.value,i,row.cost_per_unit,row.mat_id)" style="width: 100% !important;text-align: center;"> </td>
<td style="width: 10% !important;" mat-cell *matCellDef="let row;let i = index"> <input step="1" min="1" max="" title="Qty" [(ngModel)]="sponsor_qty[i]" class="text" size="2" type="number" (change)="somethingChanged($event.target.value,i,row.cost_per_unit,row.mat_id,row)" style="width: 100% !important;text-align: center;"> </td>
</ng-container>
<!-- price Column -->
@ -112,8 +112,8 @@
<mat-paginator [pageSize]="pageSize" [pageSizeOptions]="[5, 10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
<div class="pt-1 pr-1" style="text-align: right;">
<button mat-raised-button color="primary" (click)="finalSave(1)" class="mr-1 mb-1">I'd like to Contribute in kind</button>
<button (click)="finalSave(2)" mat-raised-button style="background-color:rgb(69, 189, 189);color:white" >I'd like to Contribute in Cash</button>
<button mat-raised-button color="primary" (click)="finalSave(2)" class="mr-1 mb-1">I'd like to Contribute in kind</button>
<button (click)="finalSave(1)" mat-raised-button style="background-color:rgb(69, 189, 189);color:white" >I'd like to Contribute in Cash</button>
</div>
</div>
<!--*********************-->
@ -147,11 +147,11 @@
<div fxLayout fxLayout="row" fxLayout.xs="column" fxLayoutGap.xs="0">
<div class="pl-3" fxFlex="100%" fxFlex.xs="100" fxFlex.sm="100" fxFlex.md="40" fxFlex.lg="100" fxFlex.xl="100">
<mat-form-field appearance="outline" style="width: 70%;text-align: center;">
<input matInput type="number" placeholder="Amount">
<input matInput type="number" placeholder="Amount" [(ngModel)]="general_devlop_amt">
</mat-form-field>
</div>
</div>
<mat-radio-button name="group1" class="pb-1">State School Development Fund</mat-radio-button>
<mat-radio-button name="group1" class="pb-1" checked>State School Development Fund</mat-radio-button>
<!--<mat-radio-button name="group1">District School Development Fund</mat-radio-button>
<mat-form-field style="width: 100%" class="pl-1">
<mat-select placeholder="Select District" >
@ -176,9 +176,9 @@
</mat-select>
</mat-form-field> -->
<mat-form-field dividerColor="warn" class="ml-xs mr-xs" style="width: 100%;">
<textarea matInput placeholder="Remarks" value="Some Text ..."></textarea>
<textarea matInput placeholder="Remarks" [(ngModel)]="gen_dev_fund_remarks"></textarea>
</mat-form-field>
<button [routerLink]="['../payment']" class="mat-green" mat-raised-button>Proceed for Payment</button>
<button class="mat-green" mat-raised-button style="color:white" (click)="storeData_session()">Proceed for Payment</button>
</div>
</mat-card-content>
</mat-card>

View File

@ -19,7 +19,7 @@ export class ContributeComponent implements OnInit {
dataLength :number;
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
@ViewChild(MatSort, {static: true}) sort: MatSort;
pageSize = 5;
pageSize = 10;
Contribute: FormGroup;
material_category: any = [];
district: any = [];
@ -28,10 +28,13 @@ export class ContributeComponent implements OnInit {
Total: any = [];
grandTotal: any = [];
finalData: any = [];
constructor(public restApi:ApiService,public fb:FormBuilder,public router:Router) {
sponsor_qty:any=[]
gen_dev_fund_remarks:string
general_devlop_amt:string='';
whole_contribute_list: any=[];
constructor(public restApi:ApiService,public fb:FormBuilder,public router:Router,private apiService:ApiService) {
// Create 100 users
}
// ngOnInit() {
@ -49,7 +52,9 @@ export class ContributeComponent implements OnInit {
}
}
ngOnInit() {
sessionStorage.removeItem('contribute-selected-list')
sessionStorage.removeItem('contribute-params');
sessionStorage.removeItem('contribute_final_total')
this.initForm();
this.getSchoolReqList();
this.getSchoolReqList2();
@ -79,6 +84,18 @@ export class ContributeComponent implements OnInit {
{
this.dataLength = schDet.records.length;
this.dataSource.data = schDet.records;
console.log("data",this.dataSource)
let store:any
store=sessionStorage.getItem('contribute')
store=JSON.parse(store)
console.log(store)
if(store.records){
if(store.records.contributions){
let indexes = Object.keys(store.records.contributions)
console.log(indexes)
// this.sponsor_qty[]
}
}
// console.log(this.material_category);
// this.dataSource.data = schDet.records.map((val, i)=>{
@ -89,15 +106,38 @@ export class ContributeComponent implements OnInit {
}
})
}
somethingChanged(e,i,item,mat_id){
somethingChanged(e,i,item,mat_id,curr_data){
console.log(curr_data.school_req_id)
// console.log(e,i,item);
this.Total[i] = e*item;
let data = {'qty': e
,'amount' : item
,'req_id': mat_id}
this.finalData[i] = data;
let data = {
'id':'',
'cont_id':'',
'qty': e,
'amount' : item,
'req_id': curr_data.school_req_id,
'school_id':curr_data.school_id,
'dist_id':curr_data.district_id
}
curr_data.amount=e*item
curr_data.sponsor_qty=e
if(this.finalData.length > 0){
this.finalData=this.finalData.filter(val=>val.req_id != curr_data.school_req_id)
this.whole_contribute_list=this.whole_contribute_list.filter(val=>val.school_req_id != curr_data.school_req_id)
this.finalData.push(data);
this.whole_contribute_list.push(curr_data)
}
else{
this.finalData=[data]
this.whole_contribute_list=[curr_data]
}
// console.log(this.Total);
this.grandTotal = this.Total.reduce((acc, value) => acc + value, 0);
this.whole_contribute_list.grandTotal=this.grandTotal
}
@ -162,21 +202,89 @@ export class ContributeComponent implements OnInit {
finalSave(flag)
{
let data = {'records':
{
'id':'',
'user_id':'',
"cont_type":flag,
"cont_towards":"",
"amount":this.grandTotal,
"payment_mode":"",
"payment_ref":"",
"contributions":this.finalData
}};
if(!this.apiService.isToken()){
this.router.navigate(['payment'])
return
}
if(this.grandTotal ==''){
alert("Please Fill the amount");
return
}
let data = {'records':
{
'id':'',
'user_id':'',
"cont_type":flag, //1-funds 2-materials
"cont_towards":"", //1-State Fund not needed here
"amount":this.grandTotal,
"payment_mode":"offline",
"payment_ref":"",
"contributions":this.finalData,
}};
console.log(data);
console.log("whole cont",this.whole_contribute_list);
this.apiService.csrContribute(data).subscribe(result=>{
if(result['dataStatus']){
data.records.id=result['records']
// if(flag == 1){
sessionStorage.setItem('contribute-selected-list',JSON.stringify(this.whole_contribute_list))
sessionStorage.setItem('contribute-params',JSON.stringify(data))
sessionStorage.setItem('contribute_final_total',this.grandTotal)
this.router.navigate(['payment'])
// }
}
else{
console.log("something went wrong")
}
},err=>{
console.log("Error")
})
}
storeData_session(){
sessionStorage.removeItem('contribute-selected-list')
if(!this.apiService.isToken()){
this.router.navigate(['payment'])
return
}
if(this.general_devlop_amt ==''){
alert("Please Fill the amount");
return
}
let data = {'records':
{
'id':'',
'user_id':'',
"cont_type":1, //1-funds 2-materials
"cont_towards":"1", //1-State Fund
"amount":this.general_devlop_amt,
"payment_mode":"offline",
"payment_ref":"",
"gen_dev_fund_remarks":this.gen_dev_fund_remarks,
"contributions":[]
}};
console.log(data);
sessionStorage.setItem('contribute',JSON.stringify(data))
this.apiService.csrContribute(data).subscribe(result=>{
if(result['dataStatus']){
data.records.id=result['records']
sessionStorage.setItem('contribute-params',JSON.stringify(data))
sessionStorage.setItem('contribute_final_total',this.general_devlop_amt)
this.router.navigate(['payment'])
}
else{
}
})
}
goToProjectDet(curr_array){
this.router.navigate(['home','project-detail',{schoolreqid:curr_array.school_id}])
}
}

View File

@ -0,0 +1,33 @@
<div class="relative">
<div class="">
<div fxLayout="row" fxLayoutAlign="center start" >
<div fxLayout="column" fxFlex.xl="100" fxFlex.lg="100" fxFlex.md="100" fxFlex.sm="100" fxFlex.xs="90">
<mat-card class="login-session">
<div>
<div class="close_icon" (click)="closeDialog()">
<mat-icon >close</mat-icon>
</div>
<h2 class="base-border">Login Form</h2>
<p>Enter Your Login Details</p>
<form [formGroup]="loginForm">
<div fxLayout="column" fxLayoutAlign="start stretch">
<mat-form-field style="width: 100%">
<input matInput placeholder="E-Mail" type="text" name="email" required formControlName="email">
</mat-form-field>
<mat-form-field style="width: 100%" class="mb-1">
<input matInput placeholder="Password" type="password" name="password" required formControlName="password">
</mat-form-field>
<button class="mat-green" mat-raised-button (click)="csrUserLogin()">SIGN IN</button>
<p class="mat-text-warn mb-0">Forgot password?</p>
<p class="mb-0">Don't have an account? <a (click)="registerDialog()" class="mat-text-primary">Register Here</a></p>
</div>
<!-- <div>
<p>Sign in using</p> <a href="#" class="shared-icon mr-1 mat-blue"><i class="fa fa-facebook fa-lg mr-1"></i> Facebook</a><a href="#" class="shared-icon mat-red"><i class="fa fa-google fa-lg mr-1"></i>Google</a>
</div> -->
</form>
</div>
</mat-card>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,12 @@
.close_icon{
// float: right;
text-align: right;
color: gray;
margin: 0px;
padding: 0px;
}
.close_icon:hover {
transition: transform 1.5s;
// color: blue;
cursor: pointer;
}

View File

@ -0,0 +1,116 @@
import { Component, OnInit ,ViewEncapsulation } from '@angular/core';
import {Router, NavigationEnd} from "@angular/router";
import { FormControl, FormBuilder } from '@angular/forms';
import { environment } from 'environments/environment';
import { ApiService } from 'app/shared/api.service';
import { Location } from "@angular/common";
import { MatDialog } from '@angular/material';
import { RegisterComponent } from '../register/register.component';
@Component({
selector: 'ms-login-session',
templateUrl:'./login-component.html',
styleUrls: ['./login-component.scss'],
encapsulation: ViewEncapsulation.None,
})
export class LoginComponent {
email: string;
password: string;
loginForm: any;
previousUrl: string;
constructor(public restApi:ApiService,public fb:FormBuilder,public router:Router,
private location:Location,private matDialog:MatDialog) {
// console.log(this.router.events);
}
ngOnInit() {
console.log("d",sessionStorage.getItem('contribute'))
// this.getSchoolReqList();
this.initForm();
// console.log(this.router.events);
// this.router.events.filter(e => e instanceof NavigationEnd).pairwise().subscribe((e) => {
// console.log('NAVIGATION PREVIOUS => ',e);
// });
this.previousUrl = this.restApi.getPreviousUrl();
}
initForm()
{
this.loginForm = this.fb.group(
{
email: new FormControl(''),
password: new FormControl(''),
})
}
csrUserLogin()
{
// console.log(this.loginForm.value);return false;
let url = `${environment.apiUrl}${'csrUserLogin'}`;
let data = this.loginForm.value;
this.restApi.post(url,data).subscribe(schDet=>
{
// this.load.loadedDismiss();
// console.log(schDet);return false;
if(schDet.dataStatus==true)
{
// this.setTokenData(schDet.records);
this.restApi.setToken(schDet.token);
if(this.router.url==this.previousUrl)
{
// this.router.navigate(['/home']);
// this.matDialog.closeAll()
this.matDialog.closeAll()
}else{
// this.router.navigate([this.previousUrl]);
// this.location.back();
this.matDialog.closeAll()
}
// this.router.navigate(['/home']);
// window.localStorage.setItem('token','abcd');
}else
{
// this.toast.apptoast(res.message,'danger');
window.localStorage.clear();
alert(schDet.msg);
return false;
}
})
}
// setTokenData(records: any) {
// throw new Error("Method not implemented.");
// }
// login() {
// this.router.navigate(['/']);
// }
closeDialog(){
this.matDialog.closeAll();
}
registerDialog(){
this.closeDialog()
this.matDialog.open(RegisterComponent,{
"height":"600px",
"width":"550px",
panelClass: 'custom-modalbox'
})
}
}

View File

@ -23,25 +23,77 @@
</mat-card-content>
</mat-card> -->
<div *ngIf="isCardShow">
<mat-card>
<mat-card-header>
<mat-card-title>
Review
</mat-card-title>
</mat-card-header>
<mat-card-content>
<app-req-list></app-req-list>
</mat-card-content>
</mat-card>
</div>
<mat-card>
<mat-card-title><h5 class="mt-0">Choose a Payment Option</h5></mat-card-title>
<hr>
<div class="mt-2" fxLayout="row wrap" fxLayoutAlign="center">
<div class="mt-2" fxLayout="row wrap" fxLayoutAlign="center" *ngIf="contribute_type != '2'">
<div fxLayoutAlign="center" fxFlex.sm="40.33" fxFlex.xs="100" fxFlex.sm="40.33" fxFlex.md="40.33" fxFlex.lg="40.33" fxFlex.xl="40.33" class="m-gap p-gap">
<mat-card class="p-1" style="background: linear-gradient(58deg,#009688,#673ab7);color: #fff;">
<mat-card-content>
<h3><strong><span class="amount"><span class="currency-symbol">&#8377;&nbsp;</span>70,000</span></strong></h3>
<h3><strong><span class="amount"><span class="currency-symbol">&#8377;&nbsp;</span>{{grand_tot_value}}</span></strong></h3><br/>
<mat-radio-group aria-label="Payment Mode" [(ngModel)]="payment_mode">
<mat-radio-button value="online" disabled>Online</mat-radio-button>&nbsp;
<mat-radio-button value="offline">Offline</mat-radio-button>
</mat-radio-group>
</mat-card-content>
</mat-card>
</div>
</div>
<div *ngIf="contribute_type == '2'">
<mat-card>
<mat-card-header>
<mat-card-title></mat-card-title>
</mat-card-header>
<form [formGroup]="contributeKind">
<div fxLayout="row" fxLayoutAlign="center center" fxLayoutGap.lg="0" >
<div fxFlex="80" fxFlex.xs="100" fxFlex.sm="100" >
<!-- <mat-form-field appearance="outline" >
<input matInput placeholder = "Delivery Point" type="text" formControlName="delivery_point">
</mat-form-field>&nbsp;&nbsp;&nbsp; -->
<mat-form-field appearance="outline">
<input matInput [matDatepicker]="picker" placeholder="Delivery date" formControlName="do_delivery">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>&nbsp;&nbsp;&nbsp;<br/>
<mat-form-field appearance="outline" >
<input matInput placeholder = "Delivery Point" type="text" formControlName="delivery_point">
</mat-form-field>&nbsp;&nbsp;&nbsp;<br/>
<mat-form-field appearance="outline">
<textarea matInput placeholder="Remarks" type="text" formControlName="remarks"></textarea>
</mat-form-field>
</div>
</div>
</form>
</mat-card>
</div>
<ul>
<li><span>Government of Tamil Nadu accepts online voluntary contributions using Net Banking or VISA-Debit/Credit Cards in Indian Rupees (INR) from Individuals, Organizations, Trusts,Companies and Institutions etc.</span></li>
<li *ngIf="payment_mode == 'online'"><span>Government of Tamil Nadu accepts online voluntary contributions using Net Banking or VISA-Debit/Credit Cards in Indian Rupees (INR) from Individuals, Organizations, Trusts,Companies and Institutions etc.</span></li>
<li><span>All contributions towards Tamil Nadu State Parent Teacher Association (TNPTA) are exempt from Income Tax under section 80 (G).</span></li>
<li><span>The PAN Number of Tamil Nadu State Tamil Nadu Parent Teacher Association (TNPTA) is AACAT2920R.</span></li>
</ul>
<!-- <mat-tab-group class="p-2">
<mat-tab>
<ng-template mat-tab-label>Credit/Debit Cards</ng-template>
@ -99,6 +151,6 @@
</mat-tab>
</mat-tab-group> -->
<div class="pt-1" style="text-align: right;">
<button [routerLink]="['../paymentconfirmation']" mat-raised-button color="primary" class="mr-1 mb-1">Proceed for Payment</button>
<button mat-raised-button color="primary" class="mr-1 mb-1" (click)="proceed_for_payment()"> {{payment_mode === 'online' ? 'Proceed for Payment' : 'Confirm'}}</button>
</div>
</mat-card>

View File

@ -177,4 +177,10 @@ $product-bg-color-hover: rgba(103, 58, 183, 0.7);
}
}
}
.amount{
text-align: center;
float: inline-start;
align-content: center;
color: black;
}
}

View File

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { FormBuilder } from '@angular/forms';
import { FormBuilder, FormGroup } from '@angular/forms';
import { ApiService } from 'app/shared/api.service';
@Component({
@ -42,13 +42,44 @@ export class PaymentComponent implements OnInit {
value: 'milk-8',
viewValue: 'Milk'
}];
constructor(public restApi:ApiService,public fb:FormBuilder,public router:Router) {
isCardShow:boolean = false
grand_tot_value: string;
contribute_type: any;
contributeKind: FormGroup;
contribute_params: any;
payment_mode:any='offline';
constructor(public restApi:ApiService,public fb:FormBuilder,public router:Router,private apiService:ApiService) {
this.isToken();
}
ngOnInit() {
// window.localStorage.clear();
let values= sessionStorage.getItem('contribute-selected-list')
console.log(values)
if(values){
this.isCardShow=true
}
let grand_total=sessionStorage.getItem('contribute_final_total')
console.log(grand_total)
if(grand_total){
this.grand_tot_value=grand_total
}
this.contribute_params=sessionStorage.getItem('contribute-params')
this.contribute_params=JSON.parse(this.contribute_params)
// console.log("parm",contribute_params[''].records)
this.contribute_type= this.contribute_params.records.cont_type
console.log("ty",this.contribute_type)
if(this.contribute_type == '2'){
this.contributeKind=this.fb.group({
delivery_point:[''],
do_delivery:[''],
remarks:['']
})
}
// }
}
isToken(){
// console.log(this.restApi.isToken());
@ -60,5 +91,24 @@ export class PaymentComponent implements OnInit {
}
}
proceed_for_payment(){
let params=this.contribute_params
if(this.contribute_type == '2'){
params.records.mat_delivery_point=this.contributeKind.value.delivery_point
params.records.mat_delivery_date=this.contributeKind.value.do_delivery
params.records.gen_dev_fund_remarks=this.contributeKind.value.remarks
}
params.records.payment_mode=this.payment_mode
this.apiService.csrContribute(params).subscribe(result=>{
if(result['dataStatus']){
this.router.navigate(['/'],{replaceUrl:true})
}
else{
console.log("something went wrong")
}
},err=>{
console.log("Error")
})
}
}

View File

@ -0,0 +1,61 @@
<div class="relative">
<div class="">
<div fxLayout="row" fxLayoutAlign="center start" >
<div fxLayout="column" fxFlex.xl="100" fxFlex.lg="200" fxFlex.md="100" fxFlex.sm="100" fxFlex.xs="90">
<mat-card class="login-session">
<div class="close_icon" (click)="closeDialog()">
<mat-icon >close</mat-icon>
</div>
<p class="mb-0" style="text-align: right;">Already Registered ? <a [routerLink]="['/login']" class="mat-text-primary">Login Here</a></p>
<div>
<h2 class="base-border">Register as a new user</h2>
<p>We would need some of your information to facilitate your contributions and keep you updated on the progress of the projects or new projects</p>
<form [formGroup]="go_reg">
<div fxLayout="column" fxLayoutAlign="start stretch">
<mat-form-field style="width: 100%">
<input matInput placeholder="Name" type="text" name="name" formControlName="name" required>
</mat-form-field>
<mat-form-field style="width: 100%">
<input matInput placeholder="E Mail" type="email" name="email" formControlName="email" required>
</mat-form-field>
<mat-form-field style="width: 100%">
<input matInput placeholder="Phone Number" type="number" name="mobile" formControlName="mobile" required>
</mat-form-field>
<mat-form-field style="width: 100%">
<input matInput placeholder="Password" type="password" name="password" formControlName="password" required>
</mat-form-field>
<!-- <div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" style="width: 25%;">
<input matInput placeholder="Phone OTP" type="number" name="pOTP" formControlName="pOTP" required>
</mat-form-field>
<mat-form-field dividerColor="accent" class="ml-xs mr-xs" style="width: 25%;">
<input matInput placeholder="Email OTP" type="emailOTP" name="emailOTP" formControlName="emailOTP" required>
</mat-form-field>
<button class="mat-green" mat-raised-button>Verify</button>
</div> -->
</div>
<hr>
<div fxLayout="column" fxLayoutAlign="start stretch" formGroupName="org_info">
<mat-form-field style="width: 100%">
<input matInput placeholder="Organisation Name" type="text" name="orgname" formControlName="orgname" required>
</mat-form-field>
<mat-form-field style="width: 100%;">
<textarea matInput placeholder="Register Address" name="org_address" formControlName="org_address" required></textarea>
</mat-form-field>
<mat-form-field style="width: 100%">
<input matInput placeholder="Pan of the Organisation" type="number" name="org_pan" formControlName="org_pan" required>
</mat-form-field>
<button class="mat-red" mat-raised-button (click)="csrUserRegistration()">Register</button>
</div>
<!-- <div>
<p>Sign Up Using</p> <a href="#" class="shared-icon mr-1 mat-blue"><i class="fa fa-facebook fa-lg mr-1"></i> Facebook</a><a href="#" class="shared-icon mat-red"><i class="fa fa-google fa-lg mr-1"></i>Google</a>
</div> -->
</form>
</div>
</mat-card>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,15 @@
.register-account {
background-color: #fff;
}
.close_icon{
// float: right;
text-align: right;
color: gray;
margin: 0px;
padding: 0px;
}
.close_icon:hover {
transition: transform 1.5s;
// color: blue;
cursor: pointer;
}

View File

@ -0,0 +1,70 @@
import { Component, OnInit,ViewEncapsulation } from '@angular/core';
import {Router} from "@angular/router";
import { environment } from '../../../environments/environment';
import { ApiService } from '../../shared/api.service';
import { FormBuilder, FormControl } from '@angular/forms';
import { MatDialog } from '@angular/material';
@Component({
selector: 'ms-register-session',
templateUrl:'./register-component.html',
styleUrls: ['./register-component.scss'],
encapsulation: ViewEncapsulation.None,
})
export class RegisterComponent {
name: string;
email: string;
password: string;
passwordConfirm: string;
go_reg: any;
constructor(public restApi:ApiService,public fb:FormBuilder,public router:Router,private matDialog:MatDialog) { }
ngOnInit() {
// this.getSchoolReqList();
this.initForm();
}
initForm()
{
this.go_reg = this.fb.group(
{
id: new FormControl(''),
name: new FormControl(''),
email: new FormControl(''),
mobile: new FormControl(''),
password: new FormControl(''),
org_info: this.fb.group({
orgname: new FormControl(''),
org_address: new FormControl(''),
org_pan: new FormControl('')
}),
"created_by":"1",
"updated_by":"1"
})
}
csrUserRegistration()
{
// console.log(this.go_reg.value);return false;
let url = `${environment.apiUrl}${'csrUserRegistration'}`;
let data = this.go_reg.value;
this.restApi.post(url,data).subscribe(schDet=>
{
this.router.navigate(['/authentication/login']);
})
}
register() {
this.router.navigate(['/']);
}
closeDialog(){
this.matDialog.closeAll();
}
}

View File

@ -0,0 +1,62 @@
<table mat-table [dataSource]="dataSource" matSort>
<!-- Requirement Column -->
<ng-container matColumnDef="Requirement">
<th style="width: 15% !important;" mat-header-cell *matHeaderCellDef mat-sort-header>Requirement</th>
<td style="width: 15% !important;" mat-cell *matCellDef="let row" class="product-thumbnail"><img src="{{row.img_url}}" onerror="this.onerror=null;this.src='https://upload.wikimedia.org/wikipedia/commons/thumb/1/15/No_image_available_600_x_450.svg/600px-No_image_available_600_x_450.svg.png';" alt="School Img" width="70"></td>
</ng-container>
<!-- Item Need Column -->
<ng-container matColumnDef="Item Need">
<th style="width: 15% !important;" mat-header-cell *matHeaderCellDef mat-sort-header>Item Need</th>
<td style="width: 15% !important;" mat-cell *matCellDef="let row" class="product-thumbnail"> {{row.material_name}} </td>
</ng-container>
<!-- School Column -->
<ng-container matColumnDef="School">
<th style="width: 25% !important;text-align: center !important;" mat-header-cell *matHeaderCellDef mat-sort-header>School</th>
<td style="width: 25% !important;" mat-cell *matCellDef="let row"> <a [routerLink]="'/home/project-detail'">{{row.school_name}}</a>, {{row.block_name}} Block, {{row.district_name}} District.</td>
</ng-container>
<!-- Quantity Column -->
<ng-container matColumnDef="Required Qty">
<th style="width: 10% !important;" mat-header-cell *matHeaderCellDef mat-sort-header> Required Qty </th>
<td style="width: 10% !important;" mat-cell *matCellDef="let row"> {{row.qty}}</td>
</ng-container>
<!-- Sponsor Column -->
<ng-container matColumnDef="Sponsor Qty">
<th style="width: 10% !important;" mat-header-cell *matHeaderCellDef mat-sort-header> Sponsor Qty </th>
<td style="width: 10% !important;" mat-cell *matCellDef="let row;let i = index"> {{row.sponsor_qty}} </td>
</ng-container>
<!-- price Column -->
<ng-container matColumnDef="Cost Per Unit">
<th style="width: 15% !important;" mat-header-cell *matHeaderCellDef mat-sort-header> Cost Per Unit (in RS) </th>
<td style="width: 15% !important;" mat-cell *matCellDef="let row;"> {{row.cost_per_unit === null ? 0 : row.cost_per_unit}} </td>
<!-- <td mat-footer-cell *matFooterCellDef> Total </td> -->
</ng-container>
<!-- Total Column -->
<ng-container matColumnDef="Amount">
<th style="width: 20% !important;" mat-header-cell *matHeaderCellDef mat-sort-header> Amount (in RS) </th>
<td style="width: 20% !important;" mat-cell *matCellDef="let row ;let i=index">{{row.amount}} </td>
<!-- <td mat-footer-cell *matFooterCellDef> {{somethingChanged()}} </td> -->
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
<!-- <tr mat-footer-row *matFooterRowDef="tableColumns"></tr> -->
</table>
<!-- <div class="clearfix order-total" style="padding-bottom: 0px !important;">
<div class="calculated-shipping" style="text-align: -webkit-right !important;">
<table class="table-responsive" cellspacing="0" style="width: 50% !important;">
<tr class="order-total" style="text-align: right;">
<td style="font-weight: bold;">Total</td>
<td> <strong><span class="amount"><span class="currency-symbol">&#8377;</span>{{grandTotal}}</span></strong></td>
</tr>
</table>
</div>
</div> -->
<!-- <mat-paginator [pageSize]="pageSize" [pageSizeOptions]="[5, 10, 25, 50, 100]" showFirstLastButtons></mat-paginator> -->

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ReqListComponent } from './req-list.component';
describe('ReqListComponent', () => {
let component: ReqListComponent;
let fixture: ComponentFixture<ReqListComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ReqListComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ReqListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,30 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatTableDataSource, MatPaginator, MatSort } from '@angular/material';
@Component({
selector: 'app-req-list',
templateUrl: './req-list.component.html',
styleUrls: ['./req-list.component.scss']
})
export class ReqListComponent implements OnInit {
dataSource:any = new MatTableDataSource();
dataLength :number;
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
@ViewChild(MatSort, {static: true}) sort: MatSort;
pageSize = 10;
displayedColumns: string[] = ['Requirement', 'Item Need', 'School', 'Required Qty', 'Sponsor Qty', 'Cost Per Unit', 'Amount'];
constructor() {
}
ngOnInit() {
let list_req= sessionStorage.getItem('contribute-selected-list')
list_req=JSON.parse(list_req)
console.log(list_req);
if(list_req.length > 0){
this.dataLength = list_req.length;
this.dataSource.data = list_req;
}
}
}

View File

@ -8,6 +8,7 @@ export const DashboardRoutes: Routes = [{
component: DashboardComponent
},{
path:'project-detail',
data:{some_data:'some value'},
component:ProjectDetailComponent
}];

View File

@ -3,6 +3,8 @@ import {Router, NavigationEnd} from "@angular/router";
import { FormControl, FormBuilder } from '@angular/forms';
import { environment } from 'environments/environment';
import { ApiService } from 'app/shared/api.service';
import { Location } from "@angular/common";
import { MatDialog } from '@angular/material';
@Component({
selector: 'ms-login-session',
@ -17,13 +19,14 @@ export class LoginComponent {
loginForm: any;
previousUrl: string;
constructor(public restApi:ApiService,public fb:FormBuilder,public router:Router) {
constructor(public restApi:ApiService,public fb:FormBuilder,public router:Router,private location:Location,private matDialog:MatDialog) {
// console.log(this.router.events);
}
ngOnInit() {
console.log("d",sessionStorage.getItem('contribute'))
// this.getSchoolReqList();
this.initForm();
// console.log(this.router.events);
@ -63,9 +66,12 @@ this.previousUrl = this.restApi.getPreviousUrl();
this.restApi.setToken(schDet.token);
if(this.router.url==this.previousUrl)
{
this.router.navigate(['/home']);
this.router.navigate(['/home']);
// this.matDialog.closeAll()
}else{
this.router.navigate([this.previousUrl]);
// this.router.navigate([this.previousUrl]);
// this.location.back();
this.matDialog.closeAll()
}
// this.router.navigate(['/home']);

View File

@ -4,7 +4,7 @@ import { environment } from '../../environments/environment';
import { Observable,from,of, BehaviorSubject } from 'rxjs';
import { delay } from 'rxjs/internal/operators';
import { delay, catchError } from 'rxjs/internal/operators';
import 'rxjs/Rx';
import 'rxjs/add/operator/toPromise';
@ -78,10 +78,11 @@ export class ApiService {
let token = {};
if(t){
token['raw'] = t;
token['header'] = JSON.parse(window.atob(t.split('.')[0]));
token['payload'] = JSON.parse(window.atob(t.split('.')[1]));
}
return (token);
}
@ -128,9 +129,23 @@ export class ApiService {
isToken()
{
this.Token()
return this.expToken.value;
}
//API FOR CONTRIBUTE PAGE
csrContribute(DATA){
let token_decode=this.jwtDecode(localStorage.getItem('token'))
if(token_decode){
DATA.records.user_id=token_decode['payload'].username
}
console.log("dd",token_decode)
return this.http.post(apiUrl+'csrContribute',DATA).pipe
()
}
getIndividualSchoolReqData(req_id){
return this.http.get(apiUrl+'getIndividualSchoolReqData/'+req_id)
}
}

View File

@ -2,21 +2,38 @@ import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanActivateChild } from '@angular/router';
import { Router } from '@angular/router';
import { ApiService } from '../api.service';
import { MatDialog, MatDialogConfig } from '@angular/material';
import { AuthLayoutComponent } from 'app/layouts/auth/auth-layout.component';
import { LoginComponent } from '../../components/login/login.component';
@Injectable({
providedIn: 'root'
})
export class AuthGuardService implements CanActivate{
constructor(public router:Router,public api:ApiService) {
constructor(public router:Router,public api:ApiService,private matDialog:MatDialog) {
}
canActivate(): boolean {
return this.api.isToken();
console.log("can activate",this.api.isToken())
if(this.api.isToken()){
return this.api.isToken();
}
else{
const dialogConfig = new MatDialogConfig();
dialogConfig.disableClose = true;
dialogConfig.autoFocus = true;
this.matDialog.open(LoginComponent,{
height: '450px',
width: '400px',
panelClass: 'custom-modalbox'
})
// this.router.navigate(['/authentication'])
return false
}
}
}

View File

@ -44,4 +44,9 @@ Author: TrendSetter Themes
@import "scss/core";
@import "scss/material";
@import "scss/utilities/utilities";
.custom-modalbox {
mat-dialog-container {
padding: 0;
}
}