/** * Created by Pensare Software. * User: Theo Weijmer * Date: 17/01/2018 * Time: 09:53 */ dbo.documentService = { tableName: 'OFFER', removeFile: function (that) { var vm = dbo.offersService.vm; tellMe( { title : 'verwijderen document', message : 'weet u zeker dat u hjet document wilt verwijderen, dit kan niet ongedaan worden gemaakt', notify : true, noText : 'nee verwijder het document niet', yesText : 'ja verwijder het document', modalClass: 'modal-warning' }, function ( response ) { console.log( response ); if ( response ) { dbo.documentsDataService.removeDocument( self.id, function ( data ) { if ( data.result ) { tellMe( { title : 'document verwijderd', message : 'het document is succesvol verwijderd', modalClass: 'modal-success' }, function () { vm.refreshDocuments(); } ); } else { tellMe( { title : 'fout bij verwijderen document', message : 'het document kan niet worden verwijderd', modalClass: 'modal-danger' } ); } } ); } } ); }, addDocument: function ( data, evt ) { var vm = dbo.offersModel; uploadFile( evt.target.files[0], vm.selectedRowID(), vm.tableName, function () { vm.refreshDocuments(); } ); }, refreshDocuments: function () { var vm = dbo.offersModel; dbo.documentsDataService.getdocuments( vm.selectedRowID(), vm.tableName, function ( data ) { vm.documents.removeAll(); $.each( data, function ( i, p ) { vm.documents.push( new vm.Document( p ) ); } ) } ) }, downloadDocument: function () { window.open( 'index.php/projects/documentscontroller/downloaddocument/' + this.id ); }, Document: function ( data ) { this.id = data.id; this.originalname = data.originalname; this.uploaddate = data.uploaddate; this.fullname = data.user.fullname; } }