161 lines
5.5 KiB
Plaintext
161 lines
5.5 KiB
Plaintext
@using EnVisage.Code.HtmlHelpers
|
|
@using Microsoft.AspNet.Identity
|
|
@using EnVisage.Code
|
|
@model EnVisage.Models.CompanyModel
|
|
|
|
@{
|
|
ViewBag.Title = "Company hierarchy";
|
|
}
|
|
|
|
@section scripts
|
|
{
|
|
<script type="text/javascript">
|
|
var ctr = 0;
|
|
init.push(function () {
|
|
$('#companies').dataTable({
|
|
"bProcessing": true,
|
|
"bServerSide": true,
|
|
"bAutoWidth": false,
|
|
"sAjaxSource": document.URL,
|
|
"sServerMethod": "POST",
|
|
"aoColumns": [
|
|
{ "mDataProp": "Name" },
|
|
{ "mDataProp": "ProjectsCount" },
|
|
{
|
|
"mData": function (data, type, full) {
|
|
if (data.Clients.length > 0) {
|
|
var res = "";
|
|
for (var i = 0; i < data.Clients.length; i++) {
|
|
res += data.Clients[i] + ", ";
|
|
}
|
|
return res.substr(0, res.length - 2);
|
|
}
|
|
else {
|
|
return "";
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"mData": function (data, type, full) {
|
|
if (data.Views.length > 0) {
|
|
var res = "";
|
|
for (var i = 0; i < data.Views.length; i++) {
|
|
res += data.Views[i] + ", ";
|
|
}
|
|
return res.substr(0, res.length - 2);
|
|
}
|
|
else {
|
|
return "";
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"mData": function (data, type, full) {
|
|
@if (SecurityManager.CheckSecurityObjectPermission(Areas.Company, AccessLevel.Write))
|
|
{
|
|
<text>
|
|
ctr++;
|
|
return ('<a id="btnEdit' + ctr + '" onclick="return CheckLock(this.id, \'Company\', \'_rplcmnt_\')" data-toggle="popover" data-placement="left" ' + 'class="btn btn-sm btn-primary popover-warning popover-dark" href="@Url.Action("Edit", "Company", new {@id = "_rplcmnt_"})"><i class="fa fa-edit"></i> Edit</a> ' +
|
|
'<a id="btnDelete' + ctr + '" onclick="return CheckLock(this.id, \'Company\', \'_rplcmnt_\')" data-toggle="popover" data-placement="left" ' + (data.ProjectsCount > 0 ? 'class="btn btn-sm btn-danger popover-warning popover-dark disabled" href="javascript:void(0);"' : 'class="btn btn-sm btn-danger popover-warning popover-dark" href="@Url.Action("Delete", "Company", new {@id = "_rplcmnt_"})"') + ' ><i class="fa fa-trash-o"></i> Delete</a>')
|
|
.replace(/_rplcmnt_/g, data.Id);
|
|
</text>
|
|
}
|
|
else
|
|
{
|
|
<text>
|
|
return "";
|
|
</text>
|
|
}
|
|
}
|
|
}],
|
|
});
|
|
@if (SecurityManager.CheckSecurityObjectPermission(Areas.Company, AccessLevel.Write))
|
|
{
|
|
<text>
|
|
$('#companies_wrapper .table-caption').html('<a class="btn btn-primary" href="#" onclick="loadAddCompanyModal()"><i class="fa fa-plus"></i> Add Company</a>');
|
|
</text>
|
|
}
|
|
$('#companies_wrapper .dataTables_filter input').attr('placeholder', 'Search...');
|
|
$('#companies_wrapper .dataTables_processing').addClass("table-caption");
|
|
$('#companies_wrapper .dataTables_processing').html('<span class="h3"><img class="valign-middle" src="../Content/images/loadFA.gif"/></span>');
|
|
});
|
|
|
|
function loadAddCompanyModal() {
|
|
$('.divForCreate').load('@Url.Action("AddEditCompany", "Company")', function () {
|
|
$(".innerForm input").removeData("validator");
|
|
$(".innerForm input").removeData("unobtrusiveValidation");
|
|
$.validator.unobtrusive.parseDynamicContent('.innerForm');
|
|
$('#btnsave').click(function () {
|
|
if ($(this).parents('form').valid())
|
|
blockUI();
|
|
});
|
|
$('#modalAddCompany').modal('show');
|
|
});
|
|
}
|
|
</script>
|
|
}
|
|
|
|
<div class="panel form-horizontal">
|
|
<div class="panel-heading">
|
|
<span class="panel-title">Parent Company</span>
|
|
</div>
|
|
<div class="panel-body">
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.Name, new { @class = "col-sm-2 control-label" })
|
|
<div class="col-sm-10 radio">
|
|
@Html.DisplayFor(model => model.Name)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.ProjectsCount, new { @class = "col-sm-2 control-label" })
|
|
<div class="col-sm-10 radio">
|
|
@Html.DisplayFor(model => model.ProjectsCount)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.CompaniesCount, new { @class = "col-sm-2 control-label" })
|
|
<div class="col-sm-10 radio">
|
|
@Html.DisplayFor(model => model.CompaniesCount)
|
|
</div>
|
|
</div>
|
|
@if (SecurityManager.CheckSecurityObjectPermission(Areas.Company, AccessLevel.Write))
|
|
{
|
|
<div class="form-group" style="margin-bottom: 0;">
|
|
<div class="col-sm-offset-2 col-sm-10">
|
|
<a id="btnEdit" onclick="return CheckLock(this.id, 'Company', '@Model.Id')" data-toggle="popover" data-placement="left" class="btn btn-primary popover-warning popover-dark" href="@Url.Action("EditParent", "Company", new { id = Model.Id })"><i class="fa fa-edit"></i> Edit</a>
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="table-light table-responsive">
|
|
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="companies">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
Name
|
|
</th>
|
|
<th>
|
|
Number of Projects
|
|
</th>
|
|
<th>
|
|
Clients
|
|
</th>
|
|
<th>
|
|
Views
|
|
</th>
|
|
<th>
|
|
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
</div>
|
|
|
|
<div id="modalAddCompany" class="modal fade" tabindex="-1" role="dialog" style="display: none;" data-backdrop="static">
|
|
<div class="modal-dialog divForCreate">
|
|
|
|
</div> <!-- / .modal-dialog -->
|
|
</div> <!-- / .modal -->
|