Index: pro-violet-viettel/www/deploy/20150304/assets/js/manager.js
===================================================================
--- pro-violet-viettel/www/deploy/20150304/assets/js/manager.js	(revision 880)
+++ pro-violet-viettel/www/deploy/20150304/assets/js/manager.js	(revision 881)
@@ -23,5 +23,5 @@
                                 if (o.navigationbar == undefined)
                                     o.navigationbar = null;
-                                
+
                                 if (o.oTree == undefined)
                                     o.oTree = null;
@@ -60,7 +60,7 @@
                                     act: null
                                 };
-                                
+
                                 var aryPath = [];
-                                
+
                                 if (o.homeNode == undefined)
                                     o.homeNode = null;
@@ -208,7 +208,7 @@
                                         manager: oContainer
                                     });
-                                    
+
                                     self.setHomeNode();
-                                    
+
                                     self.refreshStatusBar();
                                 };
@@ -322,10 +322,10 @@
                                         });
                                     });
-                                    
+
                                     $(document).on({
                                 	    ajaxStart: function() { $("body").addClass("loading"); },
-                                	    ajaxStop: function() { $("body").removeClass("loading"); }    
+                                	    ajaxStop: function() { $("body").removeClass("loading"); }
                                 	});
-                                    
+
                                     sendCommand({
                                         postdata: null,
@@ -357,6 +357,5 @@
                                 }
 
-                                var searchItemsByParent = function (parentID,
-                                        type) {
+                                var searchItemsByParent = function (parentID, type) {
                                     var data = {};
                                     var aryItem = [];
@@ -415,5 +414,5 @@
 
                                 }
-                                
+
                                 var btnDownloadClick = function () {
                                     var items = o.oGrid.getHighLightItem();
@@ -439,8 +438,8 @@
                                     self.redirectPost(url, {
                                               data: JSON.stringify(items)
-                                          }); 
-        
-
-                                   
+                                          });
+
+
+
                                 }
 
@@ -600,9 +599,9 @@
                                     return bootbox.dialog(promptOptions);
                                 }
-                                
+
                                 var uploadDone = function (result) {
 
                                 }
-                                
+
                                 var btnPreviewClick = function () {
                                     var items = o.oGrid.getHighLightItem();
@@ -707,5 +706,5 @@
                                     var content = "KhÃŽng há» trá»£ xem trÆ°á»c loáº¡i tá»p nÃ y, vui lÃ²ng táº£i xuá»ng vÃ  xem trÃªn mÃ¡y";
                                      bootbox.alert(content);
-                                    
+
                                 }
 
@@ -791,5 +790,5 @@
 
                                                             }
-                                                        }, 
+                                                        },
                                                         fail: function (e, data) {
                                                             // Something has
@@ -932,13 +931,15 @@
 
                                     var items = [];
+                                    var aryDupplicated = [];
+                                    var messageText = '';
 
                                     var destination = self.getTreeCurrentNode();
-                                    if (oClipBoard.act != 'copy') {
-                                        /*$(oClipBoard.items).each(
+                                    /*if (oClipBoard.act != 'copy') {
+                                        $(oClipBoard.items).each(
                                                 function (index) {
                                                     var node = new Object;
                                                     if (this.type == 'directory')
                                                         buildTreeFromParent(this.id, node);
-                                                    	
+
                                                     else {
                                                         node.id = this.id;
@@ -947,10 +948,31 @@
 
                                                     items[index] = node;
-                                                });*/
-                                    	
-                                    } else {
+                                                });
+
+                                    } else {*/
+                                    	var destinationChildDirs = searchItemsByParent(destination, 'directory');
+                                    	var destinationChildFiles = searchItemsByParent(destination, 'file');
+
                                         items = oClipBoard.items;
-                                    }
-                                    
+
+                                        for (var i = 0; i < items.length; i++) {
+                                        	if (items[i].type == 'directory' ) {
+                                        		for (var d = 0; d < destinationChildDirs.length; d++) {
+                                        			if (destinationChildDirs[d].name == items[i].name) {
+                                        				aryDupplicated.push(items[i]);
+                                        			}
+                                        		}
+                                        	}
+
+                                        	if (items[i].type == 'file' ) {
+	                                    		for (var f = 0; f < destinationChildFiles.length; f++) {
+	                                    			if (destinationChildFiles[f].name == items[i].name) {
+	                                    				aryDupplicated.push(items[i]);
+	                                    			}
+	                                    		}
+                                        	}
+                                        }
+                                    //}
+
                                     for (var i = 0; i < items.length; i++) {
                                         if (items[i].type == 'directory') {
@@ -960,42 +982,77 @@
                                     }
 
+                                    if (aryDupplicated.length > 0) {
+                                    	if (aryDupplicated.length > 1){
+	                                    	messageText = 'CÃ¡c thÆ° má»¥c (files) ';
+	                                    	for (var m = 0; m < aryDupplicated.length; m++) {
+	                                    		messageText += '<strong>' + aryDupplicated[m].name  + '</strong>, ';
+	                                    	}
+                                    	}
+                                    	else {
+                                    		var type = aryDupplicated[0].type;
+	                                    	messageText = type == 'directory' ? 'ThÆ° má»¥c <strong>' + aryDupplicated[0].name + '</strong>' : 'File <strong>' + aryDupplicated[0].name + '</strong>';
+                                    	}
+
+                                    	messageText += ' ÄÃ£ tá»n táº¡i, báº¡n cÃ³ muá»n ghi ÄÃš lÃªn khÃŽng?';
+
+                                        var confirmOptions = {
+                                                message: messageText,
+                                                buttons: {
+                                                    confirm: {
+                                                        label: "Ghi ÄÃš"
+                                                    },
+                                                    cancel: {
+                                                        label: "Há»§y bá»"
+                                                    }
+                                                },
+                                                callback: function (result) {
+                                                	console.log(result);
+                                                }
+                                        }
+
+                                        bootbox.confirm(confirmOptions);
+                                    }
+                                }
+
+                                var pasteComplete = function (items, destination) {
+                                	if (items.length == 0 || destination == null) return false;
                                     var postdata = {
-                                        act: oClipBoard.act,
-                                        destination: destination,
-                                        data: JSON.stringify(items)
-                                    };
-                                    var script = oClipBoard.act;
-
-                                    sendCommand({
-                                        postdata: postdata,
-                                        script: script,
-                                        callbackSuccess: function (parseData) {
-                                            if (oClipBoard.act == 'copy') {
-                                                $(parseData.DIRECTORIES).each(
-                                                        function (index) {
-                                                            o.data.DIRECTORIES[$(o.data.DIRECTORIES).length] = this;
-                                                        });
-
-                                                $(parseData.FILES).each(
-                                                        function (index) {
-                                                            o.data.FILES[$(o.data.FILES).length] = this;
-                                                        });
-
-                                                o.data.DIRECTORIES.sort(function (a, b) {
-                                                    return a.parentID - b.parentID;
-                                                });
-
-                                                o.oTree.setData(o.data.DIRECTORIES);
-                                                o.oGrid.setData(o.data);
-                                                o.oTree.createCopyNode(parseData.DIRECTORIES);
-                                                o.oGrid.reloadGrid();
-                                            } else if (oClipBoard.act == 'move') {
-
+                                            act: oClipBoard.act,
+                                            destination: destination,
+                                            data: JSON.stringify(items)
+                                        };
+                                        var script = oClipBoard.act;
+
+                                        sendCommand({
+                                            postdata: postdata,
+                                            script: script,
+                                            callbackSuccess: function (parseData) {
+                                                if (oClipBoard.act == 'copy') {
+                                                    $(parseData.DIRECTORIES).each(
+                                                            function (index) {
+                                                                o.data.DIRECTORIES[$(o.data.DIRECTORIES).length] = this;
+                                                            });
+
+                                                    $(parseData.FILES).each(
+                                                            function (index) {
+                                                                o.data.FILES[$(o.data.FILES).length] = this;
+                                                            });
+
+                                                    o.data.DIRECTORIES.sort(function (a, b) {
+                                                        return a.parentID - b.parentID;
+                                                    });
+
+                                                    o.oTree.setData(o.data.DIRECTORIES);
+                                                    o.oGrid.setData(o.data);
+                                                    o.oTree.createCopyNode(parseData.DIRECTORIES);
+                                                    o.oGrid.reloadGrid();
+                                                } else if (oClipBoard.act == 'move') {
+
+                                                }
+
+                                                oClipBoard.act == '';
+                                                oClipBoard.items = null;
                                             }
-
-                                            oClipBoard.act == '';
-                                            oClipBoard.items = null;
-                                        }
-                                    });
+                                        });
                                 }
 
@@ -1021,9 +1078,9 @@
                                 	var childDirs = [];
                                 	var childFiles = [];
-                                	
+
                                 	for(var i = 0; i < o.data.DIRECTORIES.length; i++) {
                                 		aryDirs[i] = o.data.DIRECTORIES[i];
                                 	}
-                                	
+
                                 	for (var i = 0; i < aryDirs.length; i++) {
                                 		if (aryDirs[i].parentID == parentID) {
@@ -1034,17 +1091,17 @@
                                 		}
                                 	}
-                                	
+
                                 	return branch;
                                 }
-                                
+
                                 this.searchParents = function (objDir) {
                                 	var parentID = objDir.parentID;
-                                	var aryDirs = [];                                	
-                                	
+                                	var aryDirs = [];
+
                                 	aryDirs[0] = o.homeNode;
                                 	for(var i = 1; i <= o.data.DIRECTORIES.length; i++) {
                                 		aryDirs[i] = o.data.DIRECTORIES[i - 1];
                                 	}
-                                	
+
                                 	for (var i = 0; i < aryDirs.length; i++) {
                                 		if (aryDirs[i].id == parentID) {
@@ -1054,5 +1111,5 @@
                                 	}
                                 }
-                                
+
                                 this.deleteItem = function (item) {
 
@@ -1191,5 +1248,5 @@
                                 }
 
-                                
+
                                 this.getTreeCurrentNode = function () {
                                     return treeCurrentNode;
@@ -1315,9 +1372,9 @@
                                     $(statusbar).html(message);
                                 }
-                                
+
                                 this.refreshNavigator = function () {
                                 	var navigatorBar = $('DIV#' + o.navigationbar + ' > UL.breadcrumb');
                                 	$(navigatorBar).find('LI').remove();
-                                	
+
                                 	var nodeID = self.getTreeCurrentNode();
                                 	if (nodeID != 0) {
@@ -1330,24 +1387,24 @@
                                 		aryPath.push(o.homeNode);
                                 	}
-                                	
+
                                 	for(var idx = 0; idx < aryPath.length; idx++) {
                                 		var i = $('<i></i>',{'class':'ace-icon icon-folder-close home-icon'});
                                 		var a = $('<a></a>',{text: aryPath[idx].name});
                                 		var li = $('<li></li>');
-                                		if (aryPath[idx].id == 0) 
+                                		if (aryPath[idx].id == 0)
                                 			$(li).append(i, a);
-                                		else 
+                                		else
                                 			$(li).append(a);
-                                		
+
                                 		$(navigatorBar).append(li);
                                 	}
-                                	
+
                                 	aryPath.splice(0,aryPath.length);
                                 }
-                                
+
                                 this.redirectPost = function (location, args) {
                                     var form = '';
                                     $.each(args, function (key, value) {
-                                       
+
                                         form += "<input type='hidden' name='"
                                                 + key + "' value='" + value
@@ -1386,5 +1443,5 @@
                                     }
                                 }
-                                
+
                                 this.setHomeNode = function () {
                                 	o.homeNode = {id:0, name:o.oTree.getRootName(), parentID:-1};
