| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- define(['app'], function (app) {
- app.directive('uploadImgFile', function ($rootScope) {
- return {
- restrict: 'A',
- scope: true,
- link: function (scope, element, attr) {
- element.on('change', function (event) {
- var files = event.target.files;
- if ($rootScope.imageFormat.indexOf(files[0].type) != -1) {
- $rootScope.prodimage = files[0];
- } else {
- $rootScope.$apply(function () {
- $rootScope.modalShown = true;
- $rootScope.message = "Please select Image format only"
- angular.element("input[type='file']").val(null);
- })
- }
- })
- }
- }
- })
- function readURL(input) {
- var num = current_imageObject.attr('data-id');
- console.log(num)
- if (input.files && input.files[0]) {
- var reader = new FileReader();
- reader.onload = function (e) {
- $('#store_image_' + num)
- .attr('src', e.target.result)
- .width(119)
- .height(112);
- }
- reader.readAsDataURL(input.files[0]);
- }
- }
- app.directive('thumbUploadFile', function ($rootScope) {
- return {
- restrict: 'A',
- scope: true,
- link: function (scope, element, attr) {
- element.on('change', function (event) {
- var files = event.target.files;
- if ($rootScope.imageFormat.indexOf(files[0].type) != -1) {
- $rootScope.uploadthumbimage.push(files[0]);
- } else {
- $rootScope.$apply(function () {
- $rootScope.modalShown = true;
- $rootScope.message = "Please select CSV format only"
- angular.element("input[type='file']").val(null);
- })
- }
- })
- }
- }
- })
- app.directive('uploadingFileContent', function ($rootScope) {
- return {
- restrict: 'A',
- scope: true,
- link: function (scope, element, attr) {
- element.on('change', function (event) {
- var files = event.target.files;
- console.log(files[0])
- console.log($rootScope.file_Format.indexOf(files[0].type))
- if ($rootScope.filetype_format == 1) {
- } if ($rootScope.file_Format.indexOf(files[0].type) != -1) {
- $rootScope.uploadfile.push(files[0]);
- // console.log($rootScope.uploadfile.length)
- // console.log($rootScope.uploadfile.length)
- } else {
- $rootScope.$apply(function () {
- $rootScope.modalShown = true;
- $rootScope.message = "Please select excel file format only"
- angular.element("input[type='file']").val(null);
- })
- }
- })
- }
- }
- })
- app.service("UploadProdService", function ($http, $rootScope, $timeout) {
- var service = {}
- service.upload = upload;
- var returnfun;
- function upload(formData, scope) {
- console.log("File : ",formData);
- returnfun = scope
- $rootScope.loadingCont = true;
- var xhr;
- if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
- xhr = new XMLHttpRequest();
- } else {// code for IE6, IE5
- xhr = new ActiveXObject("Microsoft.XMLHTTP");
- }
- //this._scope['formLoad'] = false;
- xhr.upload.addEventListener("progress", uploadProgress, false)
- xhr.addEventListener("load", function (evt) {
- returnfun(evt.target.responseText);
- }, false)
- xhr.addEventListener("error", uploadFailed, false)
- xhr.addEventListener("abort", uploadCanceled, false)
- xhr.open("POST", "../services/excelupload.php")
- $rootScope.progressVisible = true
- xhr.send(formData);
- }
- function uploadProgress(evt) {
- $rootScope.$apply(function () {
- if (evt.lengthComputable) {
- } else {
- }
- })
- }
- function uploadComplete(evt) {
- }
- function uploadFailed(evt) {
- $rootScope.$apply(function () {
- $rootScope.loadingCont = false;
- })
- }
- function uploadCanceled(evt) {
- $rootScope.$apply(function () {
- $rootScope.loadingCont = false;
- })
- }
- return service;
- })
- app.controller('DSESalesCtrl', function ($scope, $rootScope, AppData, $location, UploadProdService) {
- //Every module Set Same Variable//
- $rootScope.menucont = true;
- $rootScope.pageLoadComp = false;
- $scope.formLoad = false;
- $scope.listFound = false;
- $scope.pageData = notificationData[$rootScope.selLanguage];
- $scope.formAction = "Add";
- $rootScope.sideselect = $scope.pageData.sidemenu[0];
- $scope.itemdetail = [];
- $scope.selectedIndex = null;
- $rootScope.cofirmWindow = false;
- $scope.submenu = $scope.pageData.sidemenu;
- $scope.tblheading = $rootScope.sideselect.headingText;
- $scope.url = "../senddata/log/";
- //$scope.pageurl = "../senddata/notification/";
- $scope.commonurl = "../senddata/common/";
- $scope.cat_error = '';
- $scope.topic_error = '';
- //filter data
- $scope.common_filter = [];
- $scope.zonearr = [];
- $scope.search_box = true;
- $rootScope.modalShown = false;
- $rootScope.cofirmWindow = false;
- //pagination
- $scope.viewby = '10';
- $scope.currentPage = 1;
- $scope.pageSize = 10;
- $scope.maxSize = 5;
- $scope.itemsPerPage = $scope.viewby;
- $scope.maxSize = 5;
- $scope.choice = {};
- $scope.choice.filelang = '';
- //Check Session//
- $scope.formData = {}
- $rootScope.formData = {}
- $scope.formData.ismenuload = "Yes";
- if ($rootScope.items == undefined || $rootScope.items == null) {
- $scope.formData.ismenuload = "No";
- }
- $scope.formData.funName = "checksession";
- $scope.formData.lang = $rootScope.selLanguage;
- // $scope.formData.start = 0;
- // $scope.formData.limit = 2;
- $rootScope.file_Format = ["csv","application/vnd.ms-excel" ];
- $rootScope.imageFormat = ["image/jpeg", "image/png"];
- $rootScope.pdfFormat = ["application/pdf"];
- $rootScope.fileFormat = ["video/mp4", "application/pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx"];
- $rootScope.docFormat = ["doc", "docx", "xls", "xlsx", "ppt", "pptx"];
- $rootScope.prodimage = '';
- $rootScope.uploadfile = [];
- $rootScope.uploadthumbimage = [];
- $scope.enableeditbox = false;
- $scope.cat_error = '';
- $scope.topic_error = '';
- AppData.sendData($scope.url, $scope.formData, function (res) {
- if (res.cont) {
- if ($rootScope.items == undefined || $rootScope.items == null) {
- $rootScope.items = res.item.control;
- }
- for (var i = 0; i < $rootScope.items.length; i++) {
- if ($location.path() == $rootScope.items[i].modulepath) {
- $rootScope.modulename = $rootScope.items[i].modulename;
- $scope.usercontrol = String($rootScope.items[i].permission).split("|");
- }
- }
- $scope.listFound = true;
- $scope.statusobj = res.item.status;
- $rootScope.username = res.item.username;
- } else {
- $location.path("/login");
- }
- })
- $scope.filesubmmit = function () {
- if ($scope.fieldValidationTopic()) {
-
- var formData = new FormData();
- if ($scope.formData.salesdate == '' || $scope.formData.salesdate == undefined) {
- $scope.startMonth = moment($scope.startingMonth).format("M");
- $scope.startYear = moment($scope.startingMonth).format("YYYY");
- $scope.monthpicker = moment().format("MMM YYYY")
- } else {
- $scope.monthpicker = moment($scope.formData.salesdate).format("MMM YYYY")
- $scope.startMonth = moment($scope.formData.salesdate).format("M");
- $scope.startYear = moment($scope.formData.salesdate).format("YYYY");
- }
-
- $scope.formData.salesdate=moment($scope.startingMonth).format("YYYY-MM-DD")
- console.log($scope.formData.salesdate)
- // $scope.formData.funName = "dsesalesdata";
-
- formData.append("funName", "dsesalesdata");
- formData.append("salesdate", $scope.formData.salesdate);
- if ($rootScope.uploadfile.length != 0) {
- formData.append("file", $rootScope.uploadfile[0]);
- // console.log($rootScope.uploadfile[0])
- }
-
- console.log(formData);
- UploadProdService.upload(formData, function (data) {
- //console.log(data)
- var response = JSON.parse(data)
- $scope.$apply(function () {
- $scope.formData = {}
- $rootScope.modalShown = true;
- $rootScope.message = response.mess;
- //$scope.filesubmmit();
-
- $scope.formLoad = false;
- $rootScope.loadingCont = false;
- $rootScope.pageLoadComp = true;
- })
- });
- }
- }
- $scope.fieldValidationTopic = function () {
- $scope.formData.salesdate = $("#salesdate").val();
- $scope.date_error = ($scope.formData.salesdate == '' || $scope.formData.salesdate == undefined) ? 'Please select the date' : '';
- $scope.topic_image_error = ($rootScope.uploadfile[0] == undefined || $rootScope.uploadfile[0] == '') ? 'Please choose the file' : '';
- return ($scope.date_error == '' && $scope.topic_image_error == '') ? true : false;
- }
- });
- });
|