File: /home/barbeatleanalyti/public_html/manage.beatleanalytics.com/site/template/addattendant.php
<link rel="stylesheet" href="theme/black/css/croppie.css" />
<script>
$(document).ready(function(){
$("#FromDate").datepicker({format:'dd-mm-yyyy'});
$("#ToDate").datepicker({format:'dd-mm-yyyy'});
});
function validateDate(){
var D1 = document.getElementById("ToDate");
var D2 = document.getElementById("FromDate");
if(D1.value.trim() == ""){
D1.style.border = "1px solid red";
return false;
}
if(D2.value.trim() == ""){
D2.style.border = "1px solid red";
return false;
}
}
</script>
<?php
// Declare new object
$objAttendant = object;
// Assing object
$objAttendant = $objDB->objController;
// Assign all variable's value
$pg = $objAttendant->pg;
$acn = $objAttendant->acn;
$v = $objAttendant->v;
$State = $objAttendant->State;
$ReligionName = $objAttendant->ReligionName;
$sort = $objAttendant->sort;
$ReligionID = $objAttendant->ReligionID;
$field = $objAttendant->field;
$error = $objAttendant->error;
$msg = $objAttendant->msg;
$perpage = $objAttendant->perpage;
$start = $objAttendant->start;
$limit = $objAttendant->limit;
$SearchValue = $objAttendant->SearchValue;
$s = $objAttendant->s;
$CustomerID = $objAttendant->CustomerID;
$SurveyID = $objAttendant->SurveyID;
$TokenID = $objAttendant->TokenID;
$UserID = $objAttendant->UserID;
$OrgID = $objAttendant->OrgID;
$BranchID = $objAttendant->BranchID;
$IndustryID = $objAttendant->IndustryID;
$FromDate = $objAttendant->FromDate;
$ToDate = $objAttendant->ToDate;
//$profileimage = $objAttendant->profileimage;
$rsAttendentInfo = $objAttendant->FetchAttendentData("All");
$ProfileImage = $objAttendant->FetchWebProfileImage();
//$ProfileImage = $objProfile->FetchUserProfilePhoto();
if($ProfileImage != ""){
if(!fopen(UPLOAD_WEBPROFILEIMAGE.$ProfileImage,"r")){
$ProfileImage = _IMAGEPATH_.'/noimage_responsive.png';
}else {
$ProfileImage = UPLOAD_WEBPROFILEIMAGE.$ProfileImage;
$completepoint = $completepoint + 10;
}
}
else
$ProfileImage = _IMAGEPATH_.'/noimage_responsive.png';
?>
<div class="content-wrapper cust_hight">
<?php if( strtolower($v)=='add'|| strtolower($v)=='edit'){
if( strtolower($v)=='edit'){
if(!empty($UserID)) {
$_SESSION['AtteInfo']['UserID'] = $UserID;
?>
<section class="content customer-profile attendant_manage">
<div class="row">
<div class="col-md-12">
<div class="box box-primary " style="border:none; border-top:2px solid #3c8dbc;">
<div class="box-header" style="padding: 40px 0;">
<center><h2><img src="theme/black/images/Attendant-0005.png" alt="Smiley face" style="width: 54px;margin: 0 21px 0 0px;"> Add Attendant</h2></center>
<br>
<div class="col-md-4">
<div class="profile-pic-top">
<ul class="img-list1">
<li style="width:100%; height:auto;" id="attendentUserImage_">
<img id="attendentUserImage" src="<?php echo $ProfileImage ;?>" class="img-responsive" alt="User Image">
<a href="#popup_upload_attendent" class="chang_img"" data-toggle="modal" data-target="#popup_upload_attendent">
<span class="text-content1 cust-chang-img" style=" width: 100%; height: 418px;border-radius: 0px;
"><span><strong>Choose Image </strong></span></span>
</a>
</li>
</ul>
</div>
<style>
img#attendentUserImage { width: 79%; margin: 0 auto; border: 4px solid #d7d7d7; padding: 6px;}
a.chang_img { width: 80%; height: 417px; position: absolute; position: absolute;top: 50%; left: 50%; transform: translate(-50%,-50%); -ms-transform: translate(-50%,-50%);}
</style>
</div>
<div class="box-body col-md-6">
<form name="editfrmSettings" id="editfrmSettings" method="post" action="manage.php?pg=addattendant&acn=updateAttendentData" enctype="multipart/form-data" >
<input type="hidden" name="profilename" id="profilename">
<div class="form-group">
<label for="name" class="col-sm-3 control-label">Full Name</label>
<div class="col-sm-9">
<input type="text" name="name" class="form-control" id="name" placeholder="Name" value="<?php echo $rsAttendentInfo[0]['db_username'];?>">
</div>
</div>
<div class="form-group">
<label for="user-name" class="col-sm-3 control-label">User Name</label>
<div class="col-sm-9">
<input type="text" name="username" class="form-control" id="user-name" placeholder="User Name" value="<?php echo $rsAttendentInfo[0]['db_userLoginName'];?>">
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-3 control-label">Email</label>
<div class="col-sm-9">
<input type="email" name="email" class="form-control" id="email" placeholder="Email" value="<?php echo $rsAttendentInfo[0]['db_email'];?>">
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-3 control-label">Confirm Email</label>
<div class="col-sm-9">
<input type="email" class="form-control" id="c_email" placeholder="Confirm Email" value="<?php echo $rsAttendentInfo[0]['db_email'];?>">
<p id="email_error" style="color: red;"></p>
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-3 control-label">Mobile Number</label>
<div class="col-sm-9">
<input type="number_format" name="contact_number" class="form-control" id="number" placeholder="Mobile Number" value="<?php echo $rsAttendentInfo[0]['db_phone'];?>">
</div>
</div>
<div class="form-group">
<label for="organization-name" class="col-sm-3 control-label">Organization Name</label>
<div class="col-sm-9">
<input type="hidden" name="user_orgid" value="<?php echo $uInfo___[0]['OrgID']?>">
<input type="text" name="user_org" class="form-control" id="organization" placeholder="Organization Name" value="<?php echo $objAttendant->FetchOrganizationName($uInfo___[0]['OrgID']);?>" disabled>
</div>
</div>
<div class="form-group">
<label for="branch-name" class="col-sm-3 control-label">Branch Name </label>
<div class="col-sm-9">
<!-- <input type="text" class="form-control" id="branch" placeholder="User Name" value="<?php echo $objAttendant->FetchBranchName($uInfo___[0]['BranchID']);?>"> -->
<select name="user_branch" id="user_branch" required="required" onChange="changebranch(this.value);">
<option value="0" selected>Select Branch</option>
<?php
$branches = $objAttendant->fetchBranches();
//echo(count($branches));
//echo $_SESSION['OtherInfo']['OrgID'];
/*echo "<pre>";
print_r($branches);die();*/
for($i = 0; $i < count($branches); $i++){ ?>
<option value="<?php echo $branches[$i]['branchId'];?>" <?php if($branches[$i]['branchId'] == $rsAttendentInfo[0]['BranchID']) echo 'selected';?>><?php echo $branches[$i]['db_branchName'];?></option>
<?php } ?>
</select>
</div>
</div>
<script type="text/javascript">
$(function(){
changebranch(<?php echo $rsAttendentInfo[0]['BranchID'];?>);
});
var selectInd = false;
function changebranch(value) {
document.getElementById("user_ind").options.length = 1;
if (value.length == 0) document.getElementById("user_ind").innerHTML = "<option></option>";
else {
var catOptions = "";
jQuery.ajax({
type: "GET",
url: "runajax.php?acn=getIndustries&bid="+value,
cache: false,
success: function(result){
//document.getElementById("user_ind").innerHTML= '';
document.getElementById("user_ind").innerHTML= result;
if(selectInd == false){
document.getElementById("user_ind").value = "<?php echo $rsAttendentInfo[0]['IndustryID'];?>";
}
selectInd = true;
}
});
}
}
</script>
<div class="form-group">
<label for="Industry" class="col-sm-3 control-label">Industry Name</label>
<div class="col-sm-9">
<select name="user_ind" id="user_ind" required="required">
<option value="0" selected>Select Industry</option>
</select>
</div>
</div>
<br>
<!-- <button type="submit" onclick="javascript: return validateFrom();" bclass="btn btn-block btn-info" style="width: 120px;float: right;">Submit</button> -->
<script type="text/javascript">
function validateFrom(){
var name = document.getElementById('name');
var username = document.getElementById('user-name');
var email = document.getElementById('email');
var c_email = document.getElementById('c_email');
var contact_number = document.getElementById('number');
var user_branch = document.getElementById('user_branch');
var user_ind = document.getElementById('user_ind');
var error = 0;
if(username.value.trim() == ""){
username.style.border = "1px solid red";
error = 1;
}else{
username.style.border = "1px solid #ccc";
}
if(name.value.trim() == ""){
name.style.border = "1px solid red";
error = 1;
}else{
name.style.border = "1px solid #ccc";
}
if(contact_number.value.trim() == ""){
contact_number.style.border = "1px solid red";
error = 1;
}else{
contact_number.border = "1px solid #ccc";
}
if(contact_number.value.length != 10){
contact_number.style.border = "1px solid red";
error = 1;
}else{
contact_number.style.border = "1px solid #ccc";
}
if(c_email.value.trim() == ""){
c_email.style.border = "1px solid red";
error = 1;
}else{
c_email.style.border = "1px solid #ccc";
}
if(email.value.trim() == ""){
email.style.border = "1px solid red";
error = 1;
}else{
email.style.border = "1px solid #ccc";
}
if(email.value != c_email.value){
document.getElementById('email_error').innerHTML="Email not matched";
error = 1;
}else{
document.getElementById('email_error').innerHTML = "";
}
if(ValidateEmail(email) == false){
email.style.border = "1px solid red";
error = 1;
}else{
email.style.border = "1px solid #ccc";
}
if(user_branch.options[user_branch.selectedIndex].value == 0){
user_branch.style.border = "1px solid red";
error = 1;
}else{
user_branch.style.border = "1px solid #ccc";
}
if(user_ind.options[user_ind.selectedIndex].value == 0){
user_ind.style.border = "1px solid red";
error = 1;
}else{
user_ind.style.border = "1px solid #ccc";
}
if(error == 1)
return false;
document.getElementById('editfrmSettings').submit();
}
function ValidateEmail(mail)
{
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail.value.trim()))
{
return true;
}
//alert("You have entered an invalid email address!")
return false;
}
</script>
</form>
<button type="submit" onclick="javascript: return validateFrom();" bclass="btn btn-block btn-info" style="width: 120px;float: right;">Submit</button>
</div>
<div class="col-md-2"></div>
</div>
</div>
</div>
</div>
</section>
<?php } } ?>
<div class="col-md-12">
<?php
// Error or success message display
$objDB->NotificaitonForResult($msg,$error)
?>
</div>
<?php } else if($v=='list'){ ?>
<?php
// Error or success message display
$objDB->NotificaitonForResult($msg,$error)
?>
<section class="content customer-profile attendant_manage">
<div class="row">
<div class="col-md-12">
<div class="box box-primary " style="border:none; border-top:2px solid #3c8dbc;">
<div class="box-header" style="padding:40px 0;">
<center><h2><img src="theme/black/images/Attendant-0005.png" alt="Smiley face" style="width: 90px;margin: 0 21px 0 0px;"> Add Attendant</h2></center>
<br><br>
<div class="col-md-4">
<div class="profile-pic-top">
<ul class="img-list1">
<li style="width:100%; height:auto;" id="attendentUserImage_">
<img id="attendentUserImage" src="<?php echo $ProfileImage ;?>" class="img-responsive" alt="User Image">
<a href="#popup_upload_attendent" class="chang_img"" data-toggle="modal" data-target="#popup_upload_attendent">
<span class="text-content1 cust-chang-img" style=" width: 100%; height: 418px;border-radius: 0px;
"><span><strong>Change Image </strong></span></span>
</a>
</li>
</ul>
</div>
<style>
img#attendentUserImage { width: 79%; margin: 0 auto; border: 4px solid #d7d7d7; padding: 6px;}
a.chang_img { width: 80%; height: 417px; position: absolute; position: absolute;top: 50%; left: 50%; transform: translate(-50%,-50%); -ms-transform: translate(-50%,-50%);}
</style>
</div>
<div class="box-body col-md-6">
<form name="frmSettings" id="frmSettings" method="post" action="manage.php?pg=addattendant&acn=setAttendentData" enctype="multipart/form-data" >
<input type="hidden" name="profilename" id="profilename">
<div class="form-group">
<label for="name" class="col-sm-3 control-label">Full Name</label>
<div class="col-sm-9">
<input type="text" name="name" class="form-control" id="name" placeholder="Name">
</div>
</div>
<div class="form-group">
<label for="user-name" class="col-sm-3 control-label">User Name</label>
<div class="col-sm-9">
<input type="text" name="username" class="form-control" id="user-name" placeholder="User Name">
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-3 control-label">Email</label>
<div class="col-sm-9">
<input type="email" name="email" class="form-control" id="email" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-3 control-label">Confirm Email</label>
<div class="col-sm-9">
<input type="email" class="form-control" id="c_email" placeholder="Confirm Email">
<p id="email_error" style="color: red;"></p>
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-3 control-label">Mobile Number</label>
<div class="col-sm-9">
<input type="number_format" name="contact_number" class="form-control" id="number" placeholder="Mobile Number">
</div>
</div>
<div class="form-group">
<label for="organization-name" class="col-sm-3 control-label">Organization Name</label>
<div class="col-sm-9">
<input type="hidden" name="user_orgid" value="<?php echo $uInfo___[0]['OrgID']?>">
<input type="text" name="user_org" class="form-control" id="organization" placeholder="Organization Name" value="<?php echo $objAttendant->FetchOrganizationName($uInfo___[0]['OrgID']);?>" disabled>
</div>
</div>
<div class="form-group">
<label for="branch-name" class="col-sm-3 control-label">Branch Name </label>
<div class="col-sm-9">
<!-- <input type="text" class="form-control" id="branch" placeholder="User Name" value="<?php echo $objAttendant->FetchBranchName($uInfo___[0]['BranchID']);?>"> -->
<select name="user_branch" id="user_branch" required="required" onChange="changebranch(this.value);">
<option value="0" selected>Select Branch</option>
<?php
$branches = $objAttendant->fetchBranches();
//echo(count($branches));
//echo $_SESSION['OtherInfo']['OrgID'];
/*echo "<pre>";
print_r($branches);die();*/
for($i = 0; $i < count($branches); $i++){ ?>
<option value="<?php echo $branches[$i]['branchId'];?>"><?php echo $branches[$i]['db_branchName'];?></option>
<?php } ?>
</select>
</div>
</div>
<script type="text/javascript">
function changebranch(value) {
document.getElementById("user_ind").options.length = 1;
if (value.length == 0) document.getElementById("user_ind").innerHTML = "<option></option>";
else {
var catOptions = "";
jQuery.ajax({
type: "GET",
url: "runajax.php?acn=getIndustries&bid="+value,
cache: false,
success: function(result){
//document.getElementById("user_ind").innerHTML= '';
document.getElementById("user_ind").innerHTML= result;
}
});
}
}
</script>
<div class="form-group">
<label for="Industry" class="col-sm-3 control-label">Industry Name</label>
<div class="col-sm-9">
<select name="user_ind" id="user_ind" required="required">
<option value="0" selected>Select Industry</option>
</select>
</div>
</div>
<br>
<!-- <button type="submit" onclick="javascript: return validateFrom();" bclass="btn btn-block btn-info" style="width: 120px;float: right;">Submit</button> -->
<script type="text/javascript">
function validateFrom(){
var name = document.getElementById('name');
var username = document.getElementById('user-name');
var email = document.getElementById('email');
var c_email = document.getElementById('c_email');
var contact_number = document.getElementById('number');
var user_branch = document.getElementById('user_branch');
var user_ind = document.getElementById('user_ind');
var error = 0;
if(username.value.trim() == ""){
username.style.border = "1px solid red";
error = 1;
}else{
username.style.border = "1px solid #ccc";
}
if(name.value.trim() == ""){
name.style.border = "1px solid red";
error = 1;
}else{
name.style.border = "1px solid #ccc";
}
if(contact_number.value.trim() == ""){
contact_number.style.border = "1px solid red";
error = 1;
}else{
contact_number.border = "1px solid #ccc";
}
if(contact_number.value.length != 10){
contact_number.style.border = "1px solid red";
error = 1;
}else{
contact_number.style.border = "1px solid #ccc";
}
if(c_email.value.trim() == ""){
c_email.style.border = "1px solid red";
error = 1;
}else{
c_email.style.border = "1px solid #ccc";
}
if(email.value.trim() == ""){
email.style.border = "1px solid red";
error = 1;
}else{
email.style.border = "1px solid #ccc";
}
if(email.value != c_email.value){
document.getElementById('email_error').innerHTML="Email not matched";
error = 1;
}else{
document.getElementById('email_error').innerHTML = "";
}
if(ValidateEmail(email) == false){
email.style.border = "1px solid red";
error = 1;
}else{
email.style.border = "1px solid #ccc";
}
if(user_branch.options[user_branch.selectedIndex].value == 0){
user_branch.style.border = "1px solid red";
error = 1;
}else{
user_branch.style.border = "1px solid #ccc";
}
if(user_ind.options[user_ind.selectedIndex].value == 0){
user_ind.style.border = "1px solid red";
error = 1;
}else{
user_ind.style.border = "1px solid #ccc";
}
if(error == 1)
return false;
document.getElementById('frmSettings').submit();
}
function ValidateEmail(mail)
{
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail.value.trim()))
{
return true;
}
//alert("You have entered an invalid email address!")
return false;
}
</script>
</form>
<button type="submit" onclick="javascript: return validateFrom();" bclass="btn btn-block btn-info" style="width: 120px;float: right;">Submit</button>
</div>
<div class="col-md-2"></div>
</div>
</div>
</div>
<?php } ?>
<div class="modal fade" id="popup_upload_attendent" >
<div class="modal-dialog modal-lg" style="width: 913px;">
<div class="modal-content">
<div class="modal-header text-center bg-green cust">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
<h4 class="modal-title text-bold">Upload Attendent Image</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-8 text-center">
<div id="image_demo" style="width:350px; margin-top:30px"></div>
<input type="file" name="upload_image" id="upload_image" accept="image/x-png,image/jpeg,image/jpg"/>
</div>
<div class="col-md-4" style="padding-top:30px;">
<button class="btn btn-success crop_image">Crop & Upload Image</button>
</div>
</div>
</div>
<div class="col-md-12 form-group">
<span class="text-red"><strong>Note:</strong> File must be .jpg, .jpeg, .png, formate. </span>
</div>
<div class="modal-footer">
<button href="#close" title="Close" type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
<!--<input type="button" onclick="javascript: document.getElementById('frmuploadprofile').submit();" class="btn btn-primary form-group" style="margin-bottom:5px;" name="imageupload" value="Upload Now"/> -->
<?php if($WebProfileImage != ""){ ?>
<input type="button" onclick="javascript: document.getElementById('frmremoveprofileimage').submit();" class="btn choos-file form-group" style="margin-bottom:5px;" name="removeprofile" value="Remove Profile Image"/>
<?php }?>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<script src="theme/black/js/croppie.js"></script>
<script>
$(document).ready(function(){
$image_crop = $('#image_demo').croppie({
enableExif: true,
viewport: {
width:200,
height:200,
type:'square' //circle
},
boundary:{
width:300,
height:300
}
});
$('#upload_image').on('change', function(){
var reader = new FileReader();
reader.onload = function (event) {
$image_crop.croppie('bind', {
url: event.target.result
}).then(function(){
console.log('jQuery bind complete');
});
}
reader.readAsDataURL(this.files[0]);
//$('#uploadimageModal').modal('show');
});
$('.crop_image').click(function(event){
$image_crop.croppie('result', {
type: 'canvas',
size: 'viewport'
}).then(function(response){
$.ajax({
url:"runajax.php",
type: "POST",
data:{method:'uplodedAttendentProfileImage',"image": response},
success:function(data)
{
//alert("<?php echo SERVER_ROOT.UPLOAD_WEBPROFILEIMAGE?>"+$.trim(data));
$('#attendentUserImage_').children('img').attr('src',"<?php echo SERVER_ROOT.UPLOAD_WEBPROFILEIMAGE?>"+$.trim(data));
$('#profilename').val($.trim(data));
$('#popup_upload_attendent').modal('hide');
//$('#uploaded_image').html(data);
}
});
})
});
$('.cr-image').attr("src","<?php echo $ProfileImage; ?>");
});
</script>
<style>
#croppic_att{
background-image:url(<?php echo $ProfileImage; ?>) !important;
}
.slimScrollDiv{ height:100% !important;}
.menu{ height:100% !important;}
</style>