Date Formatting In dalelotts/angular-bootstrap-date-ranger directive - datetime-format

I am using Dalelotts angular bootstrap date range picker
Which gives the date and time in the format as Thu Mar 09 2017 06:30:00 GMT+0530 (India Standard Time) .But I need the date format to be in 2017-03-09 06:30:00.How can I make this.Please help me,Thanks in advance.
Date range picker html code
<div class="dropdown form-group">
<label>Start Date</label>
<a class="dropdown-toggle" id="dropdownStart" role="button" data-toggle="dropdown" data-target="#"
href="#">
<div class="input-group date">
<input type="text" class="form-control" data-ng-model="dateRangeStart">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<datetimepicker data-ng-model="dateRangeStart"
data-datetimepicker-config="{ dropdownSelector: '#dropdownStart', renderOn: 'end-date-changed' }"
data-on-set-time="startDateOnSetTime()"
data-before-render="startDateBeforeRender($dates)"></datetimepicker>
</ul>
</div>
<div class="dropdown form-group">
<label>End Date</label>
<a class="dropdown-toggle" id="dropdownEnd" role="button" data-toggle="dropdown" data-target="#"
href="#">
<div class="input-group date">
<input type="text" class="form-control" data-ng-model="dateRangeEnd">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<datetimepicker data-ng-model="dateRangeEnd"
data-datetimepicker-config="{ dropdownSelector: '#dropdownEnd', renderOn: 'start-date-changed' }"
data-on-set-time="endDateOnSetTime()"
data-before-render="endDateBeforeRender($view, $dates, $leftDate, $upDate, $rightDate)"></datetimepicker>
</ul>
</div>
In my controller
$scope.endDateBeforeRender = endDateBeforeRender
$scope.endDateOnSetTime = endDateOnSetTime
$scope.startDateBeforeRender = startDateBeforeRender
$scope.startDateOnSetTime = startDateOnSetTime
function startDateOnSetTime () {
$scope.$broadcast('start-date-changed');
}
function endDateOnSetTime () {
$scope.$broadcast('end-date-changed');
}
function startDateBeforeRender ($dates) {
if ($scope.dateRangeEnd) {
var activeDate = moment($scope.dateRangeEnd);
$dates.filter(function (date) {
return date.localDateValue() >= activeDate.valueOf()
}).forEach(function (date) {
date.selectable = false;
})
}
}
function endDateBeforeRender ($view, $dates) {
if ($scope.dateRangeStart) {
var activeDate = moment($scope.dateRangeStart).subtract(1, $view).add(1, 'minute');
$dates.filter(function (date) {
return date.localDateValue() <= activeDate.valueOf()
}).forEach(function (date) {
date.selectable = false;
})
}
}

Add data-date-time-input attribute into the input.
<input type="text" class="form-control" data-date-time-input="YYYY-MM-DD HH:ii:ss" data-ng-model="dateRangeStart">

Related

how to insert the current url of the page in the database

if (ModelState.IsValid)
{
ip.patientname = fc["patientname"];
ip.patientmail = fc["patientmail"];
ip.patientcountry = fc["patientcountry"];
ip.patientquery = fc["patientquery"];
ip.SecurityCode = fc["SecurityCode"];
string url = Request.Url.AbsoluteUri;
dblayer.Add_data_pharma(ip);
TempData["msg"] = "Inserted";
}
else
{
TempData["msg"] = "Not Inserted";
}
ModelState.Clear();
return Redirect(Request.UrlReferrer.PathAndQuery);
}
string url = Request.Url.AbsoluteUri;
I want to know how to insert url name in the database using Request.Url.AbsoluteUri or any method.
public void Add_data_pharma(insert_askpharma_mar212019 ip)
{
SqlCommand com = new SqlCommand("insert_askpharma", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("#pharmaid", ip.pharmaid);
com.Parameters.AddWithValue("#patientname", ip.patientname);
com.Parameters.AddWithValue("#patientmail", ip.patientmail);
com.Parameters.AddWithValue("#patientcountry", ip.patientcountry);
com.Parameters.AddWithValue("#patientquery", ip.patientquery);
com.Parameters.AddWithValue("#SecurityCode", ip.SecurityCode);
com.Parameters.AddWithValue("#urlname", string.Empty);
com.Parameters.AddWithValue("#ipaddress", string.Empty);
con.Open();
com.ExecuteNonQuery();
con.Close();
}
I want to insewrt the current page url in the database using mvc
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-6">
<h3 style="color:#669900">Personal Information</h3>
#using (Html.BeginForm("AskOurPharmacist", "Basic", FormMethod.Post, new { #id = "kycFormTab5" }))
{
<div class="form-group">
<label for="email">Name*</label>
<input type="text" class="form-control" id="patientname" name="patientname">
</div>
<div class="form-group">
<label for="pwd">Phone*</label>
<input type="text" class="form-control" id="" name="">
</div>
<div class="form-group">
<label for="email">Email*</label>
<input type="email" class="form-control" id="patientmail" name="patientmail">
</div>
<div class="form-group">
<input type="hidden" class="form-control" id="patientcountry" name="patientcountry">
</div>
<div class="form-group">
<input type="hidden" class="form-control" id="patientquery" name="patientquery">
</div>
<div class="form-group">
<input type="hidden" class="form-control" id="SecurityCode" name="SecurityCode">
</div>
<div class="form-group">
<input type="hidden" class="form-control" id="urlname" name="urlname">
</div>
<button type="submit" class="btn btn-success">Email me When in Stock</button>
}
</div>
<div class="col-sm-6">
<div class="rbox">
<h4 class=" text-center"><strong>Why shop with Us?</strong></h4>
<ul class="list-unstyled">
<li><i class="fa fa-heart"> </i>Trusted for Quality and Price</li>
<li><i class="fa fa-heart"> </i>80-90% Savings - Lowest Prices</li>
<li><i class="fa fa-heart"> </i>Free Shipping WorldWide*</li>
<li><i class="fa fa-heart"> </i>360° Round View of Products</li>
<li><i class="fa fa-heart"> </i>No Hidden Cost</li>
<li><i class="fa fa-heart"> </i>Saving Rewards, Referral Discounts</li>
<li><i class="fa fa-heart"> </i>Quality-Assured Medications</li>
<li class="text-right">*T&C Apply</li>
</ul>
</div>
</div>
</div>
</div>
This is my view ,in one mehod i have inserted two forms in this form only i want to insert the url in the database all are in the same table
this is my database
you must have a column(if not add 1 with name url) in database let say url which also will be available(if not add a property with the name url) in Model class ip. You method dblayer.Add_data_pharma(ip) will do the rest.
ip.url = Request.Url.AbsoluteUri;

How to move angularjs html filter into controller?

I would like to move the filter out of the HTML and inside a controller. Any suggestions on how the function would look?
<div class="dropdown">
<button class="btn btn-small btn-primary" type="button" data-toggle="dropdown">Filter
<span class="caret"></span></button>
<ul class="dropdown-menu dropdown-outer">
<div class="dropdown-inner">
<div class="inner-addon right-addon dropdown-padding">
<i ng-click="filteredItem.name = ''" class="glyph glyphicon glyphicon-remove-circle"></i>
<input class="form-control" data-keepOpenOnClick type="text" ng-trim="true" ng-model="filteredItem.name" placeholder="Filter by File Name"/>
</div>
<div class="inner-addon right-addon dropdown-padding">
<i ng-click="filteredItem.prettyName = ''" class="glyph glyphicon glyphicon-remove-circle"></i>
<input class="form-control" data-keepOpenOnClick type="text" ng-trim="true" ng-model="filteredItem.prettyName" placeholder="Filter by Name"/>
</div>
<div class="inner-addon right-addon dropdown-padding">
<i ng-click="filteredItem.type = ''" class="glyph glyphicon glyphicon-remove-circle"></i>
<input class="form-control" data-keepOpenOnClick type="text" ng-trim="true" ng-model="filteredItem.type" placeholder="Filter by Type" typeahead="type.pretty_name for type in widgetType" required />
</div>
<div class="dropdown-padding">
<button ng-click="resetfilteredItem()" class="btn btn-small btn-primary" type="button" data-toggle="dropdown">Reset
</div>
</div>
</ul>
</div>
<div class="list-group" ng-repeat="filter in filteredItems = (ideas | filter: (!!filteredItem.name || !!filteredItem.prettyName || !!filteredItem.type || undefined) && filteredItem)">
<div class="list-group-item widgets-group-item" ng-mouseover="showname=true" ng-mouseleave="showname=false" dnd-draggable="dragToWidgetConfig(widget)" dnd-effect-allowed="copy">
{{filter.prettyName}}
</div>
</div>
I was able to find a solution. Simply adding this scope to the controller
$scope.filteredItems = {};
and updating the HTML solve my problem.
<div class="list-group" ng-repeat="item in filteredItems = (items | filter: filteredItems)">
</div>

Date Range Picker in angular-ui-datepicker

I want to implement Date Range Picker in angularjs by using angular-ui-datepickerbut I can't find the resource or good example for this so can anyone suggest me for date range picker or normal select From Date to select To date example also helpful for me so please suggest me!
I know this type of question I cant ask on this website but I m stuck so I ask
and i try many example but nothing work properly
Here is my code snippet that i try already:
Html Code:
<div class="row form-group" style="margin-left: 15px;" ng-if="table.custompicker">
<div class="crm-form-container">
<div class="col-sm-4">
<div class="input-group">
<span class="input-group-addon" uib-tooltip="From Date" uib-tooltip-trigger="focus" uib-tooltip-placement="top"><i class="fa fa-hand-o-right" aria-hidden="true"></i></span>
<input id="datepicker_update" class="form-control" type="text" uib-datepicker-popup="{{table.format}}"
ng-model="AvailableDate" ng-value="table.price_list.date_update"
is-open="table.dt_picker[3]" min-date="dpick.minDate" max-date="'2019-12-22'"
datepicker-options="table.dateOptions3" date-disabled="table.disabled(date, mode)"
close-text="Close" placeholder="From Date" name="select_date" ng-change="ChangeExpiryMinDate(AvailableDate)" datepicker-mode="'day'" required=""/>
<span class="input-group-btn">
<button class="btn btn-info" type="button" ng-click="table.open_dt_picker(3)">
<em class="fa fa-calendar"></em>
</button>
</span>
</div>
<span class="text-danger" ng-show="table.validateInput('select_date', 'required')">{{'revalidationmsg.REQUIREDMSG'|translate}}</span>
</div>
<div class="col-sm-4">
<div class="input-group">
<span class="input-group-addon" uib-tooltip="From Date" uib-tooltip-trigger="focus" uib-tooltip-placement="top"><i class="fa fa-hand-o-right" aria-hidden="true"></i></span>
<input id="datepicker_update" class="form-control" type="text" uib-datepicker-popup="{{table.format}}"
ng-model="ExpireDate" ng-value="table.price_list.date_update"
is-open="table.dt_picker[4]" min-date="dpick.minDate" max-date="'2019-12-22'"
datepicker-options="table.dateOptions4" date-disabled="table.disabled(date, mode)"
close-text="Close" placeholder="To Date" name="select_date" datepicker-mode="'day'" required=""/>
<span class="input-group-btn">
<button class="btn btn-info" type="button" ng-click="table.open_dt_picker(4)">
<em class="fa fa-calendar"></em>
</button>
</span>
</div>
<span class="text-danger" ng-show="table.validateInput('select_date', 'required')">{{'revalidationmsg.REQUIREDMSG'|translate}}</span>
</div>
<div class="col-sm-4">
<button class="btn btn-success btn-xs" type="button" value="SAVE" ng-click="table.generateReport(table.select)" uib-tooltip="" uib-tooltip-trigger="focus" uib-tooltip-placement="top">Generate Report</button>
<button class="btn btn-default btn-xs" type="button" ng-click="" uib-tooltip="" uib-tooltip-trigger="focus" uib-tooltip-placement="top">Cancel</button>
</div>
</div>
</div>
And Here is JS :
vm.dt_picker = [];
vm.dt = [];
vm.open_dt_picker = function (index) {
vm.dt_picker[index] = true;
};
$scope.dateOptions3 = {
formatYear: 'yy',
startingDay: 1,
showWeeks: false,
minMode: 'week',
//minDate: today,
//maxDate: new Date(2030, 5, 22)
};
$scope.dateOptions4 = {
formatYear: 'yy',
startingDay: 1,
showWeeks: false,
minMode: 'week',
//minDate: today,
//maxDate: new Date(2030, 5, 22)
};
vm.formats = ['dd-MMMM-yyyy', 'yyyy-MM-dd', 'yyyy', 'shortDate', 'MM-yyyy'];
vm.format = vm.formats[1];
vm.opencustompicker = function () {
vm.custompicker = true;
};
Your Html Code like
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<label>Start Date</label>
<div class="input-group" >
<input ng-readonly="true" type="text" class="form-control " id="startdate" name="startdate" uib-datepicker-popup="MM/dd/yyyy"
ng-model="fromDate" is-open="startDateStatus"
show-button-bar="true" data-ng-click="toggleStartDate($event)"
placeholder="Select From Date"
datepicker-options="options"
close-text="Close" />
<span class="input-group-addon add-on link_cursor" data-ng-click="toggleStartDate($event)">
<i class="glyphicon glyphicon-calendar"></i>
</span>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<label>End Date</label>
<div class="input-group">
<input ng-readonly="true" type="text" class="form-control " id="enddate" name="enddate" uib-datepicker-popup="MM/dd/yyyy"
ng-model="toDate" is-open="endDateStatus"
show-button-bar="true" data-ng-click="toggleEndDate($event)"
placeholder="Select To Date"
datepicker-options="options2"
close-text="Close" />
<span class="input-group-addon add-on link_cursor" data-ng-click="toggleEndDate($event)">
<i class="glyphicon glyphicon-calendar"></i>
</span>
</div>
</div>
And Your Js Code like
//toggle start date popup
function toggleStartDate($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.startDateStatus = true;
}
//toggle end date popup
function toggleEndDate($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.endDateStatus = true;
}

How to require at least 1 checkbox with checklist-model for AngularJS Form Validation?

I have small form with 2 date input and one checklist which are all checkboxes. I couldn't figure it out how to require any of one checkbox in list for the form validation. If I add ng-required for an checkbox it repeats for all the check boxes. Can anyone know about this how to require the checkbox as required form element. but I don't want to choose all the element for making form valid. So if only one of the form field which are the checkboxes has been selected form must be valid otherwise invalid.
angular.module('frmApp', [
'ui.bootstrap', 'angularMoment'
])
.controller('Frm Controller', [
'$scope',
function($scope) {
$scope.invDets = $stateParams.details;
$scope.allowanceObj = {};
$scope.finCompWithLogo = [];
$scope.validUntil = new Date();
$scope.recentDate = new Date();
// Disable weekend selection
$scope.disabled = function(date, mode) {
return (mode === 'day' && (date.getDay() === 0 || date.getDay() === 6));
};
$scope.openedPayment = false;
$scope.openedAllowance = false;
$scope.openPayment = function($event, elementOpened) {
$scope.paymentDueDate = new Date();
/*$scope.openedPayment = !$scope.openedPayment;*/
$event.preventDefault();
$event.stopPropagation();
$scope[elementOpened] = !$scope[elementOpened];
};
$scope.openAllowance = function($event, elementOpened) {
$scope.allowanceDueDate = new Date();
/*$scope.openedAllowance = !$scope.openedAllowance;*/
$event.preventDefault();
$event.stopPropagation();
$scope[elementOpened] = !$scope[elementOpened];
};
$scope.dateOptions = {
'year-format': "'yy'",
'starting-day': 1,
'minDate': new Date()
};
$scope.doSomething = function (frm) {
$http.post('/someUrl', frm, config).then(successCallback, errorCallback); alert('Done something!!');
}
}
]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div>
<form name="frm1" novalidate>
<div class="row">
<div class="allowance-required-field">
<div class="box">
<div class="icon"> <i class="fa fa-calendar"></i> </div>
<div class="field-title">Payment</div>
<div class="input-group">
<input type="text" class="form-control" uib-datepicker-popup="dd-MM-yyyy" ng-click="openPayment($event, 'openedPayment')" ng-model="frm1.PaymentDueDate" show-weeks="false" is-open="openedPayment" datepicker-options="dateOptions" ng-required="true"
/>
<span class="input-group-btn">
<button class="btn btn-default" ng-click="openPayment($event, 'openedPayment')"><i class="fa fa-calendar"></i></button>
</span>
</div>
</div>
</div>
<div class="allowance-required-field">
<div class="box">
<div class="icon"> <i class="fa fa-calendar"></i> </div>
<div class="field-title">Delay</div>
<div class="input-group">
<input type="text" class="form-control" uib-datepicker-popup="dd-MM-yyyy" ng-click="openAllowance($event, 'openedAllowance')" ng-model="frm1.AllowanceDueDate" show-weeks="false" is-open="openedAllowance" min-date="recentDate" max-date="frm1.PaymentDueDate"
datepicker-options="dateOptions" ng-required="true" />
<span class="input-group-btn">
<button class="btn btn-default" ng-click="openAllowance($event, 'openedAllowance')"><i class="fa fa-calendar"></i></button>
</span>
</div>
</div>
</div>
<div class="pick-factoring-companies">
<div class="box">
<h2 class="text-center"> Choose One or More </h2>
<div class="text-center">
Select All
Deselect All
</div>
<ul ng-required="true">
<li ng-repeat="cmp in finCompWithLogo">
<div ng-if="cmp" class="finance-company">
<input id="{{'company-'+$index}}" type="checkbox" class="pick-faktoring" checklist-model="frm1.AllowanceCompanies" checklist-value="cmp.Identifier" ng-change="addCompany(cmp.Identifier)">
<label for="{{'company-'+$index}}">
<div class="img"> <img data-toggle="tooltip" data-placement="bottom" src="data:image/{{cmp.Logo[0].Type}};base64,{{cmp.Logo[0].Data}}" title="{{cmp.CompanyName}}"> </div>
<div class="title"> {{cmp.CompanyName}} </div>
</label>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="text-center">
Send
</div>
</form>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</div>
Mark the checkboxes as ng-required if the list is empty.
<label ng-repeat="role in roles">
<input ng-required="user.roles.length == 0"
type="checkbox"
checklist-model="user.roles"
checklist-value="role.id">
{{role.text}}
</label>
You can use checklist-change to set the validity or checklist-before-change to enable/disable selection.
Here's an example: http://jsfiddle.net/beradrian/nbwcbejw/
If you go for checklist-change and $setValidity then you should set this initially.
SOLVED! I have tried solves my problem.
<input id="{{'company-'+$index}}" type="checkbox" ng-model="cmp.Selected" ng-click="pushCompanyToArray(cmp)"
ng-required="frm1.AllowanceCompanies.length == 0"
ng-value="cmp.ID" ng-checked="all || cmp.Selected"/>
this solves my question. For anyone who couldn't find the solution this ng-required solved my problem.

UI bootstrap date picker with ng-repeate is not working

I am using angular directive for date picker from UI bootstrap. I also use ng-repeat to add multiple rows. I have added date picker code in ng-repeat. I have displayed these date pickers in bootstrap modal. Also ng-repeat is work fine. But if I add multiple row and click on single calendar icon then all calendar popups of all date picker are shown. I don't know why should this happened. I use is-open="$parent.opened1" to perform click on calendar button. If I use only is-open="opened1" then calendar popoup will open only once (means: can not open after selecting any date). And if I use is-open="$parent.opened1" then after adding multiple rows all calendar popup is open.
Here is my code-
<div class="modal fade bs-example-modal-lg preventiveCarePop" id="preventiveProcess" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<form role="myForm" name="myForm">
<div class="modal-dialog" style="width: 35%;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 style="margin: 0px;">
Preventive Care: <span ng-bind="patientObj.firstName"></span>
<span ng-bind="patientObj.lastName"></span><small
class="newSmall"><span> ({{patientObj.gender}}, <i
class="fa fa-mobile fa-lg"></i>:
{{patientObj.contact.mobileNumber}})
</span></small>
</h4>
</div>
<input type="hidden" ng-model="currentReminder" />
<div class="modal-body">
<div id="divActivites" name="divActivites">
<div class="form-group">
<div class="box-placeholder" ng-repeat="preventive in preventive.preventiveDetailsList">
<div class="form-group">
<div class="row">
<div class="col-lg-4">
<label for="exampleInputEmail1">Start Date<span
style="color: red;">*</span></label>
<p class="input-group">
<input type="text" class="form-control"
datepicker-popup="dd-MM-yyyy"
ng-model="preventive.startOnDate"
is-open="$parent.opened2"
id="dos-{{$index}}"
datepicker-options="dateOptions" close-text="Close"
placeholder="Select Date" required />
<span class="input-group-btn">
<button type="button" class="btn popUpCal"
ng-click="open($event,'opened2')">
<i class="fa fa-calendar"></i>
</button>
</span>
</p>
</div>
<div class="col-lg-4">
<label for="exampleInputEmail1">End Date<span
style="color: red;">*</span></label>
<p class="input-group">
<input type="text" class="form-control"
datepicker-popup="dd-MM-yyyy"
ng-model="preventive.endOnDate"
id="doe-{{$index}}"
is-open="$parent.opened1"
datepicker-options="dateOptions" close-text="Close"
placeholder="Select Date" required />
<span class="input-group-btn">
<button type="button" class="btn popUpCal"
ng-click="open($event,'opened1')" >
<i class="fa fa-calendar"></i>
</button>
</span>
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<button type="submit" class="btn btn-default" ng-click="addDummyPreventive(preventive.preventiveDetailsList,currCaseSheetObjForAddPrv.speciality,preventive.preventiveDetailsList.length)" style="float: right" title="Add new preventive"><i class="fa fa-plus-circle fa-lg"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
Here is my controller
$scope.open = function($event,opened) {
$event.preventDefault();
$event.stopPropagation();
$scope[opened] = true;
};
$scope.dateOptions = {
formatYear: 'yy',
startingDay: 1
};
I don't know what I use to work all fine.
Please share your idea's.
Thanks in advance.
Please see this demo and comments inside code can be helpful.
Html:
<div class="row" ng-repeat="dt in dates">
<div class="col-md-6">
<p class="input-group">
<input type="text" class="form-control" datepicker-popup="{{format}}" ng-model="dt.date" is-open="dt.opened" datepicker-options="dateOptions" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open($event,dt)"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
</p>
</div>
</div>
JS:
$scope.open = function($event, dt) {
$event.preventDefault();
$event.stopPropagation();
dt.opened = true;
};

Resources