//  @import com.hedgehoglab.application.controller.BaseController;

function ContactsImportController(scope) {
	BaseHelper.call(this,scope);
	var _this=this;
    scope.import_view.subscribe_to('import_complete', function(event) {
		var options={type:"notification",message:""};
		
		if(event.error!=null){
			// console.warn(event.error);
			options.message=event.message;
			options.type="error";
		}else{
			// console.warn(event);
			options.message=event.message;
		}
		scope.message_service.show_message(options);
		scope.search_view.raise_event("on_search_term_changed", {term:''});
    });

	scope.import_view.subscribe_to('import_clicked', function(event) {
		scope.licence_service.can_add_contacts(function(can_add_contacts,check){
			if(can_add_contacts){
				scope.import_view.show();
			}else{
				var message = _this.resource_string("feedback.contacts.index.importlicencefail");
			    scope.message_service.show_message({
			        message: message,
			        type: "info"
			    });
			}
		});
	});
	
    scope.import_view.subscribe_to('form_submission', function(event) {
        //event.form.submit();
    });

	//	Ask the licence service if we have a valid licence
	// scope.licence_service.is_valid_licence(function(licence_valid){
	// 	scope.import_view.disable_actions(!licence_valid);
	// });
};