Skip to content

Commit

Permalink
Merge pull request #1566 from ThisisMS11/mohit_fusion_1
Browse files Browse the repository at this point in the history
PS_1 Changes
  • Loading branch information
prajjwalkapoor authored Apr 25, 2024
2 parents 1807e62 + 0c41891 commit 97baf89
Show file tree
Hide file tree
Showing 18 changed files with 581 additions and 304 deletions.
1 change: 1 addition & 0 deletions FusionIIIT/applications/ps1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class IndentFile(models.Model):
purpose=models.CharField(max_length=250,blank=False )
specification=models.CharField(max_length=250)
item_type=models.CharField(max_length=250)
item_subtype = models.CharField(max_length=250,blank=False,default='computers')
nature=models.BooleanField(default = False)
indigenous= models.BooleanField(default = False)
replaced =models.BooleanField(default = False)
Expand Down
3 changes: 2 additions & 1 deletion FusionIIIT/applications/ps1/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
url(r'^outboxview/$', views.outboxview, name='outboxview'),


url(r'^update_stock_item_inUse/$', views.updateStockItemInUse, name='outboxview'),
url(r'^update_stock_item_inUse/$', views.updateStockItemInUse, name='stockItemInUse'),
url(r'^item_detail/(?P<id>\d+)/$', views.item_detail, name='item_detail'),

# BASE API
url(r'^api/',include('applications.ps1.api.urls')),
Expand Down
116 changes: 101 additions & 15 deletions FusionIIIT/applications/ps1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import json

from django.db.models import Q,Count
from datetime import datetime
from datetime import datetime

dept_admin_to_dept = {
"deptadmin_cse": "CSE",
Expand All @@ -29,9 +31,11 @@
"deptadmin_design": "Design",
"deptadmin_liberalarts": "Liberal Arts",
"deptadmin_ns": "Natural Science",
"Admin IWD":"IWD",
"Compounder":"Health Center"
}

dept_admin_design = ["deptadmin_cse", "deptadmin_ece", "deptadmin_me","deptadmin_sm", "deptadmin_design", "deptadmin_liberalarts","deptadmin_ns" ]
dept_admin_design = ["deptadmin_cse", "deptadmin_ece", "deptadmin_me","deptadmin_sm", "deptadmin_design", "deptadmin_liberalarts","deptadmin_ns" ,"Admin IWD","Compounder"]


@login_required(login_url = "/accounts/login/")
Expand Down Expand Up @@ -118,6 +122,8 @@ def create_proposal(request):
purpose=request.POST.get('purpose')
specification=request.POST.get('specification')
item_type=request.POST.get('item_type')
item_subtype=request.POST.get('item_subtype')

nature=request.POST.get('nature')
indigenous=request.POST.get('indigenous')
replaced =request.POST.get('replaced')
Expand Down Expand Up @@ -150,6 +156,7 @@ def create_proposal(request):
purpose=purpose,
specification=specification,
item_type=item_type,
item_subtype=item_subtype,
nature=nature,
indigenous=indigenous,
replaced = replaced ,
Expand Down Expand Up @@ -191,6 +198,8 @@ def create_proposal(request):
purpose=request.POST.get('purpose')
specification=request.POST.get('specification')
item_type=request.POST.get('item_type')
item_subtype=request.POST.get('item_subtype')

nature=request.POST.get('nature')
indigenous=request.POST.get('indigenous')
replaced =request.POST.get('replaced')
Expand Down Expand Up @@ -249,6 +258,7 @@ def create_proposal(request):
purpose=purpose,
specification=specification,
item_type=item_type,
item_subtype=item_subtype,
nature=nature,
indigenous=indigenous,
replaced = replaced ,
Expand Down Expand Up @@ -1104,11 +1114,12 @@ def current_stock_view(request):
StockEntryId__item_id__item_type=type
)

grouped_items = StockItems.values('StockEntryId__item_id__item_type', 'department').annotate(total_quantity=Count('id'))
grouped_items = StockItems.values('StockEntryId__item_id__item_type','StockEntryId__item_id__item_subtype', 'department').annotate(total_quantity=Count('id'))

grouped_items_list = [
{
'item_type': item['StockEntryId__item_id__item_type'],
'item_subtype': item['StockEntryId__item_id__item_subtype'],
'department': DepartmentInfo.objects.get(id=department),
'total_quantity': item['total_quantity']
}
Expand All @@ -1118,6 +1129,7 @@ def current_stock_view(request):

firstStock=StockItems.first()

print(grouped_items_list)


return render(request,'ps1/current_stock_view.html',{'stocks':grouped_items_list,'first_stock':firstStock,
Expand All @@ -1135,9 +1147,11 @@ def current_stock_view(request):
print(dept_admin_to_dept[request.session['currentDesignationSelected']]);
deptId = DepartmentInfo.objects.values('id', 'name').get(name=dept_admin_to_dept[request.session['currentDesignationSelected']])



departments=[deptId]

StockItems = StockItem.objects.filter(department=deptId)
StockItems = StockItem.objects.filter(department=deptId['id'])

elif request.session['currentDesignationSelected'] == "ps_admin":
departments=DepartmentInfo.objects.values('id','name').all()
Expand All @@ -1147,11 +1161,12 @@ def current_stock_view(request):
return redirect('/dashboard')


grouped_items = StockItems.values('StockEntryId__item_id__item_type','department').annotate(total_quantity=Count('id'))
grouped_items = StockItems.values('StockEntryId__item_id__item_type','StockEntryId__item_id__item_subtype','department').annotate(total_quantity=Count('id'))

grouped_items_list = [
{
'item_type': item['StockEntryId__item_id__item_type'],
'item_subtype': item['StockEntryId__item_id__item_subtype'],
'department': DepartmentInfo.objects.values('id','name').get(id=item['department']),
'departmentId': item['department'],
'total_quantity': item['total_quantity']
Expand All @@ -1170,14 +1185,19 @@ def stock_item_view(request):
if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]:
return redirect('/dashboard')

if request.method=="GET":
return HttpResponseRedirect('../current_stock_view')

if request.method=="POST":
departmentId = request.POST.get('departmentId')
type = request.POST.get('item_type')
subtype = request.POST.get('item_subtype')

# StockEntryId__item_id__file_info_grade
StockItems = StockItem.objects.filter(
department=departmentId,
StockEntryId__item_id__item_type=type
StockEntryId__item_id__item_type=type,
StockEntryId__item_id__item_subtype=subtype
)

return render(request,'ps1/stock_item_view.html',{'stocks':StockItems})
Expand Down Expand Up @@ -1339,16 +1359,57 @@ def generate_report(request):

if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]:
return redirect('/dashboard')


des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first()
department = request.user.extrainfo.department.name
if request.method =='GET':
if request.session['currentDesignationSelected'] in dept_admin_design:

if request.session['currentDesignationSelected'] in dept_admin_design:
sto=StockEntry.objects.filter(item_id__file_info__uploader__department__name=dept_admin_to_dept[request.session['currentDesignationSelected']])
else:
sto=StockEntry.objects.all()
deptId = DepartmentInfo.objects.values('id', 'name').get(name=dept_admin_to_dept[request.session['currentDesignationSelected']])
departments=[deptId]

elif request.session['currentDesignationSelected'] == "ps_admin":
departments=DepartmentInfo.objects.values('id','name').all()

return render(request,'ps1/generate_report_filter.html',{'departments':departments})


if request.method=="POST":


departments = request.POST.getlist('departments')
start_date = request.POST.get('start_date');
finish_date = request.POST.get('finish_date');



start_date = datetime.strptime(start_date, '%Y-%m-%d').date()
finish_date = datetime.strptime(finish_date, '%Y-%m-%d').date()

if(departments[0]=='all'):
StockItems = StockItem.objects.filter(StockEntryId__recieved_date__range=(start_date, finish_date))
else :
StockItems = StockItem.objects.filter(department__in=departments, StockEntryId__recieved_date__range=(start_date, finish_date))


return render(request,'ps1/generate_report.html',{'sto':sto})
grouped_items = StockItems.values('StockEntryId__item_id__item_type','StockEntryId__item_id__item_subtype','department').annotate(total_quantity=Count('id'))

grouped_items_list = [
{
'item_type': item['StockEntryId__item_id__item_type'],
'item_subtype': item['StockEntryId__item_id__item_subtype'],
'department': DepartmentInfo.objects.values('id','name').get(id=item['department']),
'departmentId': item['department'],
'total_quantity': item['total_quantity'],
'StockItems': StockItem.objects.filter(
department=item['department'],
StockEntryId__item_id__item_type=item['StockEntryId__item_id__item_type']
)
}
for item in grouped_items
]


return render(request,'ps1/generate_report.html',{'departments':departments,'stocks':grouped_items_list})


@login_required(login_url = "/accounts/login")
Expand Down Expand Up @@ -1447,7 +1508,7 @@ def perform_transfer(request):
dest_location=dest_location
)

messages.success(request,'Stock Transfer Done Successfully.!')
messages.success(request,'Stock Transfer Done Successfully.!')
# if the quantity required for this indent file is fulfilled we should mark this indentfile as done.
if(moreStocksRequired<=0):
myIndent.purchased=True
Expand All @@ -1458,7 +1519,7 @@ def perform_transfer(request):

department = request.user.extrainfo.department.name

return HttpResponseRedirect('../view_transfer')
return JsonResponse({'success':True})

# This is to get the list of all the available stock items for transfer.
@login_required(login_url = "/accounts/login")
Expand Down Expand Up @@ -1537,8 +1598,14 @@ def outboxview(request):

@login_required(login_url="/accounts/login")
def updateStockItemInUse(request):
print("updatestockiteminuse");

if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]:
return redirect('/dashboard')

if request.method=="GET":
return redirect('../current_stock_view')


if request.method == "POST":

Expand All @@ -1557,4 +1624,23 @@ def updateStockItemInUse(request):
stock_item.inUse = checked
stock_item.save()

return redirect('/purchase-and-store/current_stock_view')
return JsonResponse({'success': True})

# return HttpResponseRedirect('../current_stock_view')


@login_required(login_url="/accounts/login")
def item_detail(request, id):
if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]:
return redirect('/dashboard')

stock_transfers = StockTransfer.objects.filter(stockItem=id).order_by('dateTime')
stock_item = StockItem.objects.filter(id=id).first();
# Do something with the stock_transfers

context = {
'transfers': stock_transfers,
'item': stock_item
}

return render(request, 'ps1/stock_item_details.html', context)
5 changes: 5 additions & 0 deletions FusionIIIT/templates/ps1/composeIndent.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ <h3>
</select>
</div>

<div class="field">
<label>Item Subtype*</label>
<input type="text" name="item_subtype">
</div>


<div class="field">
<label>Budgetary Head</label>
Expand Down
2 changes: 1 addition & 1 deletion FusionIIIT/templates/ps1/createdindent.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<div class="ui two item menu">
<a class="item"><b>Quantity :-</b><b class="meta" style="text-indent: 1em; color: #1B1C1D;">{{indent.quantity}}</b></a>

<a class="item"><b>Present Stock :</b><b class="meta" style="text-indent: 1em; color: #1B1C1D;">{{indent.present_stock}}</b></a>
<a class="item"><b>SubType </b><b class="meta" style="text-indent: 1em; color: #1B1C1D;">{{indent.item_subtype}}</b></a>
</div>

<div class="ui two item menu">
Expand Down
12 changes: 10 additions & 2 deletions FusionIIIT/templates/ps1/current_stock_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ <h3>
<thead>
<tr>
<th>Item Type</th>
<!-- <th>Item SubType</th> -->
<th>department/Section</th>
<th>Quantity</th>

Expand All @@ -45,6 +46,7 @@ <h3>
<tr>

<td> {{s.item_type}} </td>
<!-- <td> {{s.item_subtype}} </td> -->
<td> {{s.department}} </td>
<td>{{s.total_quantity}}</td>
</tr>
Expand All @@ -56,7 +58,7 @@ <h3>

<!-- for displaying the stocks -->
<div class="ui divider"></div>
<div class="table-container" style="overflow-x: scroll;">
<div class="table-container" style="overflow-x: scroll;max-height: 300px; overflow-y: scroll;">


<table class="ui very basic celled sortable table">
Expand All @@ -81,7 +83,13 @@ <h3>
<td>{{s.location}}</td>
<td>{{s.isTransferred}}</td>
<td>{{s.StockEntryId.vendor}}</td>
<td>{{s.StockEntryId.bill}}</td>
<td>
{% if s.StockEntryId.bill %}
<a href="{{ s.StockEntryId.bill.url }}" download>{{ s.StockEntryId.bill }}</a>
{% else %}
No bill available
{% endif %}
</td>

</tr>
{% endif %}
Expand Down
3 changes: 3 additions & 0 deletions FusionIIIT/templates/ps1/current_stock_view_filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ <h3>
<thead>
<tr>
<th>Item Type</th>
<th>Item Subtype</th>
<th>department/section</th>
<th>Quantity</th>
<th>View Stocks</th>
Expand All @@ -94,12 +95,14 @@ <h3>
<tr>

<td> {{s.item_type}} </td>
<td> {{s.item_subtype}} </td>
<td> {{s.department.name}} </td>
<td>{{s.total_quantity}}</td>

<td>
<form action="/purchase-and-store/stock_item_view/" method="POST" >{% csrf_token %}
<input hidden name = 'item_type' value="{{ s.item_type}}">
<input hidden name = 'item_subtype' value="{{ s.item_subtype}}">
<input hidden name = 'departmentId' value="{{ s.departmentId}}">
<button class="ui primary button" >View Stocks</button>
</form>
Expand Down
2 changes: 1 addition & 1 deletion FusionIIIT/templates/ps1/forwardedIndent.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<div class="ui two item menu">
<a class="item"><b>Quantity :-</b><b class="meta" style="text-indent: 1em; color: #1B1C1D;">{{indent.quantity}}</b></a>

<a class="item"><b>Present Stock :</b><b class="meta" style="text-indent: 1em; color: #1B1C1D;">{{indent.present_stock}}</b></a>
<a class="item"><b>SubType :</b><b class="meta" style="text-indent: 1em; color: #1B1C1D;">{{indent.item_subtype}}</b></a>
</div>

<div class="ui two item menu">
Expand Down
2 changes: 1 addition & 1 deletion FusionIIIT/templates/ps1/forwardindent.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<div class="ui two item menu">
<a class="item"><b>Quantity :-</b><b class="meta" style="text-indent: 1em; color: #1B1C1D;">{{indent.quantity}}</b></a>

<a class="item"><b>Present Stock :</b><b class="meta" style="text-indent: 1em; color: #1B1C1D;">{{indent.present_stock}}</b></a>
<a class="item"><b>SubType :</b><b class="meta" style="text-indent: 1em; color: #1B1C1D;">{{indent.item_subtype}}</b></a>
</div>

<div class="ui two item menu">
Expand Down
Loading

0 comments on commit 97baf89

Please sign in to comment.