university logo added

This commit is contained in:
venbatechnologies@gmail.com 2018-05-22 11:31:48 +05:30
parent 7b6373f81b
commit 76219d28a2
11 changed files with 461 additions and 49 deletions

View File

@ -64,22 +64,44 @@ class University_Controller extends REST_Controller {
//update university details
public function updateUniversityDetail_post() {
//s print_r($_FILES);
$imagename='';
$size='';
$imageSource='';
if(!empty($_FILES))
{
$imagename = $_FILES['idProof']['name'];
$size = $_FILES['idProof']['size'];
$imageSource = $_FILES['idProof']['tmp_name'];
}
// echo $imagename;
// echo $size;
// echo $imageSource;
// die();
$reqData = $this->post('data');
$data = json_decode($reqData, true);
$req['UpdatedBy'] = $this->post('updatedBy');
$date = date('Y-m-d H:i:s');
$req['UpdatedOn'] = $date;
$req['UniversityName']= $reqData['UniversityName'];
$req['UniversityShortName']= $reqData['UniversityShortName'];
$req['MobileNumber']= $reqData['MobileNumber'];
$req['EmailID']= $reqData['EmailID'];
$req['Address']= $reqData['Address'];
$req['IsActive']= $reqData['IsActive'];
$req['UniversityName']= $data['UniversityName'];
$req['UniversityShortName']= $data['UniversityShortName'];
$req['MobileNumber']= $data['MobileNumber'];
$req['EmailID']= $data['EmailID'];
$req['Address']= $data['Address'];
$req['IsActive']= $data['IsActive'];
$req['BranchCode'] = $this->post('branchCode');
$req['ID']= $reqData['ID'];
$req['ID']= $data['ID'];
$updateFor = $reqData['UniversityID'];
$updateFor = $data['UniversityID'];
$updateUniversityDetail = $this->university_model->update_university_details($updateFor, $req);// Check if the employee exist
$updateUniversityDetail = $this->university_model->update_university_details($updateFor, $req,$imagename,$imageSource,$size);// Check if the employee exist
if ($updateUniversityDetail)
{
$updateUniversityDetail['status'] = REST_Controller::HTTP_OK;
@ -124,20 +146,37 @@ class University_Controller extends REST_Controller {
// insert university details
public function insertUniversity_post() {
// echo "sdg";
$imagename = $_FILES['idProof']['name'];
$size = $_FILES['idProof']['size'];
$imageSource = $_FILES['idProof']['tmp_name'];
// echo $imagename;
// echo $size;
// echo $imageSource;
$reqData = $this->post('data');
$temp = json_decode($reqData, true);
//print_r($reqData);
//die();
$req['CreatedBy'] = $this->post('createdBy');
$date = date('Y-m-d H:i:s');
$req['CreatedOn'] = $date;
$req['UniversityName']= $reqData['UniversityName'];
$req['UniversityShortName']= $reqData['UniversityShortName'];
$req['MobileNumber']= $reqData['MobileNumber'];
$req['EmailID']= $reqData['EmailID'];
$req['Address']= $reqData['Address'];
$req['IsActive']= $reqData['switchsetting'];
$req['UniversityID']= $reqData['UniversityID'];
$req['UniversityName']= $temp['UniversityName'];
$req['UniversityShortName']= $temp['UniversityShortName'];
$req['MobileNumber']= $temp['MobileNumber'];
$req['EmailID']= $temp['EmailID'];
$req['Address']= $temp['Address'];
$req['IsActive']= $temp['switchsetting'];
$req['UniversityID']= $temp['UniversityID'];
$req['BranchCode']= $this->post('branchCode');
$insertUniv = $this->university_model->insert_Univ($req);// Check if the employee exist
$insertUniv = $this->university_model->insert_Univ($req,$imagename,$imageSource,$size);// Check if the employee exist
if ($insertUniv)
{
$insertUniv['status'] = REST_Controller::HTTP_OK;

View File

@ -34,10 +34,35 @@ class University_model extends CI_Model
$results['message'] = 'No record found';
}
return $results;
print_r($results);
}
// update univesity details
public function update_university_details($updateFor, $Arr) {
public function update_university_details($updateFor, $Arr,$imageName, $imageSource, $imageSize) {
if($imageSource == '')
{
//echo "if";
$imageNameDb = 'default.jpeg';
// $Arr['ProfilePicPath'] = "university/".$imageNameDb;
}
else
{
//echo "else";
$target = "../images/university/";
$getUploadStatus = $this->upload_image($imageSource, $imageSize, $target);
$imageNameDb = $getUploadStatus['status'] == true ? $getUploadStatus['imageName'] : $getUploadStatus['imageName'] = 'default.jpeg';
// echo $imageNameDb;
$Arr['ProfilePicPath'] = "university/".$imageNameDb;
}
// print_r($Arr);
// die();
$this->db->where('UniversityID', $updateFor);
$this->db->where('BranchCode', $Arr['BranchCode']);
$this->db->where('ID', $Arr['ID']);
@ -47,7 +72,7 @@ class University_model extends CI_Model
$result['message'] = "Successfully University details Updated";
} else {
$result['updateUniversityStatus'] = false;
$result['message'] = "Successfully University details Updated";
$result['message'] = "University details not Updated";
}
return $result;
}
@ -69,7 +94,35 @@ class University_model extends CI_Model
}
// add university details
public function insert_Univ($arr) {
public function insert_Univ($arr,$imageName, $imageSource, $imageSize) {
// echo $imageName;
// echo $imageSource;
// echo $imageSize;
if($imageSource == '')
{
//echo "if";
$imageNameDb = 'default.jpeg';
$arr['ProfilePicPath'] = "university/".$imageNameDb;
}
else
{
//echo "else";
$target = "../images/university/";
$getUploadStatus = $this->upload_image($imageSource, $imageSize, $target);
$imageNameDb = $getUploadStatus['status'] == true ? $getUploadStatus['imageName'] : $getUploadStatus['imageName'] = 'default.jpeg';
// echo $imageNameDb;
$arr['ProfilePicPath'] = "university/".$imageNameDb;
}
// // echo $imageName;
// // echo $imageSource;
// // echo $imageSize;
// echo $imageSource;
//die();
$this->db->select('*');
$this->db->from(UNIVERSITY);
$this->db->where('UniversityID', $arr['UniversityID']);
@ -81,7 +134,7 @@ class University_model extends CI_Model
$this->db->insert(UNIVERSITY, $arr);
if ($this->db->affected_rows() == '1') {
$result['addUniv'] = true;
$result['message'] = "Successfully University details added";
$result['message'] = "Successfully University details added";
} else {
$result['addUniv'] = false;
$result['message'] = "Something went wrong.please try again";
@ -382,4 +435,30 @@ class University_model extends CI_Model
return $result;
}
// image upload in taget path
public function upload_image( $imageSource, $size, $target ) {
//echo "fn";
$key2 = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 12);
$new_regNo = "Dri_" . $key2 . "." . 'jpeg';
$targetPlace = $target . $new_regNo;
// echo $imageSource;
// exit();
if(!move_uploaded_file($imageSource , $targetPlace))
{//echo "if";
return $result['status'] = false;
$result['imageName'] = $new_regNo;
}
else
{
// echo "else";
$result['status'] = true;
$result['imageName'] = $new_regNo;
return $result;
}
}
}

View File

@ -12,6 +12,7 @@ app.controller('universityCtrl', ["$scope", "toaster", "$filter", "ngTableParams
// get local cliend details
var localDetail = JSON.parse(localStorage.getItem('localObj'));
var localDetails = ipCookie('cookiechk');
//alert(JSON.stringify(localDetail));
$scope.myModel = {
'UniversityID': '',
@ -21,6 +22,9 @@ app.controller('universityCtrl', ["$scope", "toaster", "$filter", "ngTableParams
'EmailID': '',
'Address': '',
'switchsetting': true,
};
@ -63,7 +67,7 @@ app.controller('universityCtrl', ["$scope", "toaster", "$filter", "ngTableParams
if (response.data.univList) {
$scope.loader = false;
$scope.emptyUniversity = true;
$scope.data = response.data.university_details;
$scope.univ = response.data.university_details;
} else {
$scope.loader = false;
$scope.emptyUniversity = false;
@ -95,6 +99,56 @@ app.controller('universityCtrl', ["$scope", "toaster", "$filter", "ngTableParams
});
}
//-------------------------------------------------------------->
// getting for image to show
//-------------------------------------------------------------->
$scope.stepsModel = [];
$scope.imageUpload = function (event) {
var files = event.target.files; //FileList object
for (var i = 0; i < files.length; i++) {
var file = files[i];
var reader = new FileReader();
reader.onload = $scope.imageIsLoaded;
reader.readAsDataURL(file);
}
}
$scope.imageIsLoaded = function (e) {
$scope.$apply(function () {
// $scope.stepsModel.push(e.target.result);
$scope.stepsModel[0] = e.target.result;
});
}
//an array of files selected
$scope.filesimage = [];
//listen for the file selected event
$scope.$on("fileSelected", function (event, args) {
$scope.$apply(function () {
//add the file object to the scope's files collection
$scope.filesimage[0] = args.file;
// console.log($scope.filesimage);
});
});
// reset image
$scope.resetImage = function () {
$scope.filesimage.length = 0;
$scope.stepsModel.length = 0;
}
//------------------image functions over ---------->
$scope.setEditId = function (id) {
// alert(id);
$scope.editId = id;
@ -106,6 +160,7 @@ app.controller('universityCtrl', ["$scope", "toaster", "$filter", "ngTableParams
}
$scope.updateUniversityDetails = function (form, p) {
//alert()
var firstError = null;
if (form.$invalid) {
var field = null, firstError = null;
@ -123,6 +178,14 @@ app.controller('universityCtrl', ["$scope", "toaster", "$filter", "ngTableParams
// swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error");
} else {
p.IsActive = p.IsActive === true ? 1 : 0;
var idProof = $scope.filesimage[0];
if(idProof === undefined)
{
//alert('if')
// alert(JSON.stringify(p))
var req = {
method: 'POST',
url: apiPoint.url + 'updateUniversityDetail/',
@ -130,7 +193,7 @@ app.controller('universityCtrl', ["$scope", "toaster", "$filter", "ngTableParams
'Content-Type': 'application/json'
},
data: {
data: p,
data: JSON.stringify(p),
updatedBy: localDetails.localUserID,
branchCode: localDetails.localBranchID
}
@ -145,6 +208,36 @@ app.controller('universityCtrl', ["$scope", "toaster", "$filter", "ngTableParams
swal(" ", "Something went wrong, please try again.", "error");
}
});
}
else
{
//alert('else')
var formData = new FormData();
var idProof = $scope.filesimage[0];
//alert(idProof)
formData.append("data", JSON.stringify(p));
formData.append("updatedBy", localDetails.localUserID);
formData.append("branchCode", localDetails.localBranchID);
formData.append('idProof', idProof);
$http.post(apiPoint.url + 'updateUniversityDetail/', formData, {
transformRequest: angular.identity,
headers: { 'Content-Type': undefined, 'Process-Data': false },
}).success(function (data) {
if (data.updateUniversityStatus == true) {
swal("Success!", data.message, "success");
$state.go($state.current, {}, { reload: true });
} else {
// $scope.ldloading1[loading.replace('-', '_')] = false;
swal("Failed!", data.message, "error");
}
});
}
}
}
@ -168,32 +261,62 @@ app.controller('universityCtrl', ["$scope", "toaster", "$filter", "ngTableParams
// swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error");
} else {
$scope.myModel.switchsetting = $scope.myModel.switchsetting === true ? 1 : 0;
var req = {
method: 'POST',
url: apiPoint.url + 'insertUniversity/',
headers: {
'Content-Type': 'application/json'
},
data: {
data: $scope.myModel,
branchCode: localDetails.localBranchID,
createdBy: localDetails.localUserID,
}
};
$http(req).then(function (response) {
if (response.data.addUniv == true) {
swal("", "University details added successfully.", "success");
$state.go($state.current, {}, { reload: true });
}
else if(response.data.addUniv == false){
swal("","This University Id is already exist!", "error");
}
else {
// $scope.ldloading1[loading.replace('-', '_')] = false;
swal("","Something went wrong, please try again.", "error");
}
});
var idProof = $scope.filesimage[0];
var formData = new FormData();
//var idProof = $scope.filesimage[0];
//alert(idProof);
// var req = {
// method: 'POST',
// url: apiPoint.url + 'insertUniversity/',
// headers: {
// 'Content-Type': 'application/json'
// },
// data: {
// data: $scope.myModel,
// branchCode: localDetails.localBranchID,
// createdBy: localDetails.localUserID,
// }
// };
formData.append("data", JSON.stringify($scope.myModel));
formData.append("branchCode", localDetails.localBranchID);
formData.append("createdBy", localDetails.localUserID);
formData.append('idProof', idProof);
$http.post(apiPoint.url + 'insertUniversity/', formData, {
transformRequest: angular.identity,
headers: { 'Content-Type': undefined, 'Process-Data': false },
}).success(function (data) {
if (data.addUniv == true) {
// swal("Success!", data.message, "success");
// $state.go($state.current, {}, { reload: true });
swal("Success!", data.message, "success");
$state.go($state.current, {}, { reload: true });
} else {
// $scope.ldloading1[loading.replace('-', '_')] = false;
swal("Failed!", data.message, "error");
}
});
// $http(req).then(function (response) {
// if (response.data.addUniv == true) {
// swal("", "University details added successfully.", "success");
// $state.go($state.current, {}, { reload: true });
// }
// else if(response.data.addUniv == false){
// swal("","This University Id is already exist!", "error");
// }
// else {
// // $scope.ldloading1[loading.replace('-', '_')] = false;
// swal("","Something went wrong, please try again.", "error");
// }
// });
}
},
reset: function (form) {
@ -212,3 +335,22 @@ app.controller('universityCtrl', ["$scope", "toaster", "$filter", "ngTableParams
}
}]);
// file upload directive
app.directive('fileUpload', function () {
return {
scope: true, //create a new scope
link: function (scope, el, attrs) {
el.bind('change', function (event) {
var files = event.target.files;
//iterate files since 'multiple' may be specified on the element
for (var i = 0; i < files.length; i++) {
//emit event upward
scope.$emit("fileSelected", { file: files[i] });
}
});
}
};
});

View File

@ -88,7 +88,94 @@
</div>
</div>
</div>
<div class="col-md-4">
<img class="thumb prof" ng-src="images/{{p.ProfilePicPath}}" />
<style>
.thumb {
width: 130px;
height: 140px;
margin: 18px;
float: left;
}
.prof {
border: 2px solid #2C3543;
}
.uploader {
clear: both;
}
</style>
</div>
</div>
<div class="file-upload">
<div class="row">
<div class="col-md-6">
<h5>Update Profile Picture</h5>
<div class=" margin-bottom-5">
</div>
<input type="file" accept="image/*" ng-init="resetImage()" file-upload onchange="angular.element(this).scope().imageUpload(event)" />
</div>
<div class="col-md-6">
<div class="form-group">
<div class="user-image">
</div>
<!--<input type="file" file-model="idProof"
accept="image/*" onchange="angular.element(this).scope().imageUpload(event)"/>-->
<div>
<div ng-repeat="step in stepsModel">
<!--<a class="close-thin"></a>-->
<img class="thumb" ng-src="{{step}}" />
<div class="col-md-12">
<div class="pull-right">
<button class="btn btn-success btn-o btn-sm margin-right-15" type="button" ng-click="resetImage()">Reset
</button>
</div>
</div>
</div>
</div>
<style>
.thumb {
width: 130px;
height: 140px;
margin: 18px;
float: left;
}
.uploader {
clear: both;
}
</style>
</div>
</div>
</div>
</div>
<!--<pre>{{ p | json}}</pre>-->
<div class="row">
<div class="col-md-12">

View File

@ -61,7 +61,7 @@
</th>
</tr>
</thead>
<tbody dir-paginate="p in data|orderBy:sortKey:reverse|filter:search:strict|itemsPerPage:10">
<tbody dir-paginate="p in univ|orderBy:sortKey:reverse|filter:search:strict|itemsPerPage:10">
<tr>
<td>{{p.UniversityID}}</td>
<td>{{p.UniversityShortName}}</td>
@ -178,6 +178,71 @@
<span class="error text-small block" ng-if="Form.Address.$dirty && Form.Address.$invalid">Address is required</span>
</div>
</div>
<div class="col-md-3">
<form name="Form" id="form1" novalidate ng-submit="form.submit(Form,myModel)" method="post">
<div class="file-upload">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<div class="user-image">
<h5>University Logo</h5>
<div class=" margin-bottom-5">
</div>
</div>
<div>
<div ng-repeat="step in stepsModel">
<img class="thumb" ng-src="{{step}}" />
<div class="col-md-12">
<div class="pull-right">
<button class="btn btn-success btn-o btn-sm margin-right-15" type="button" ng-click="resetImage()">Reset
</button>
</div>
</div>
</div>
</div>
<input type="file" accept="image/*" file-upload onchange="angular.element(this).scope().imageUpload(event)" />
<style>
.thumb {
width: 130px;
height: 140px;
margin: 18px;
float: left;
}
.uploader {
clear: both;
}
</style>
</div>
</div>
</div>
</div>
</form>
</div>
<div class="row">
<div class="col-md-4">
<label>

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB