upload
This commit is contained in:
@@ -21,9 +21,9 @@ class DocumentsController extends MY_Controller {
|
|||||||
$this->load->library( $libraries );
|
$this->load->library( $libraries );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDocuments( $foreignID, $tablename )
|
public function getDocuments( $foreignID )
|
||||||
{
|
{
|
||||||
$documents = Document::getDocuments( $foreignID, $tablename );
|
$documents = Document::getDocuments( $foreignID );
|
||||||
|
|
||||||
$this->json( $documents );
|
$this->json( $documents );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Document extends BaseModel {
|
|||||||
return $this->belongsTo( 'User' );
|
return $this->belongsTo( 'User' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDocuments( $foreignID, $tablename )
|
public static function getDocuments( $foreignID)
|
||||||
{
|
{
|
||||||
$documents = Document::orderBy( 'uploaddate', 'desc' )
|
$documents = Document::orderBy( 'uploaddate', 'desc' )
|
||||||
->with( [
|
->with( [
|
||||||
@@ -23,7 +23,6 @@ class Document extends BaseModel {
|
|||||||
$q->selectRaw( "CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname, id" );
|
$q->selectRaw( "CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname, id" );
|
||||||
}] )
|
}] )
|
||||||
->whereForeignId( $foreignID )
|
->whereForeignId( $foreignID )
|
||||||
->whereForeignTable( $tablename )
|
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return $documents;
|
return $documents;
|
||||||
|
|||||||
@@ -1,43 +1,50 @@
|
|||||||
<div class="panel panel-bordered panel-primary panel-line">
|
<div class="col-md-6">
|
||||||
<div class="panel-heading panel-heading-project">
|
<table class="table table-condensed">
|
||||||
<h3 class="">
|
<thead>
|
||||||
bestanden
|
<tr>
|
||||||
</h3>
|
<th>door</th>
|
||||||
|
<th>datum</th>
|
||||||
|
<th>bestandsnaam</th>
|
||||||
|
<th> </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr data-bind="foreach:documents">
|
||||||
|
<td>
|
||||||
|
<span data-bind="text:fullname"></span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span data-bind="text:uploaddate"></span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span data-bind="text:originalname"></span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<i class="icon fa-download pointer" data-bind="click:$root.downloadDocument"></i>
|
||||||
|
<i class="icon fa-trash redish pointer" data-bind="click:$root.removeFile"></i>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tr></tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
<div class="upload-btn-wrapper" data-bind="">
|
||||||
|
<button class="upload-btn">voeg bestand toe</button>
|
||||||
|
<input type="file" name="userfile" data-bind="event:{change:addDocument}" id="fileinput"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body panel-body-project">
|
</div>
|
||||||
<table class="table table-sm">
|
<div class="col-md-6">
|
||||||
<thead>
|
<hr/>
|
||||||
<tr>
|
<!-- <button data-bind="click:addComment" class="upload-btn">-->
|
||||||
<td colspan="2" class="table-cyanish-header">
|
<!-- voeg commentaar toe-->
|
||||||
offerte bestanden
|
<!-- </button>-->
|
||||||
</td>
|
<!-- ko foreach: comments -->
|
||||||
</tr>
|
<div data-bind="click:$root.editComment" class="pointer">
|
||||||
</thead>
|
<span class="badge badge-info" style="width:100%; text-align:left;">
|
||||||
<tbody data-bind="foreach:projectFiles">
|
<span data-bind="text:fullname"></span> |
|
||||||
<td>
|
<span data-bind="text:comment_date"></span>
|
||||||
|
</span>
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editPayment"></i>
|
|
||||||
<i class="icon fa-trash redish pointer" title="verwijder"
|
|
||||||
data-bind="click:$root.removePayment"></i>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th colspan="2" class="table-cyanish-header">
|
|
||||||
project bestanden
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div data-bind="html:comment,click:$root.editComment" class="comment-text pointer"></div>
|
||||||
|
<!-- /ko -->
|
||||||
</div>
|
</div>
|
||||||
@@ -8,6 +8,7 @@ $this->load->view('modals/project_modal');
|
|||||||
$this->load->view('modals/comment_modal');
|
$this->load->view('modals/comment_modal');
|
||||||
|
|
||||||
$this->load->view('specials/tellme_modal');
|
$this->load->view('specials/tellme_modal');
|
||||||
|
$this->load->view('specials/upload_modal');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<div class="modal fade modal-primary" tabindex="-1" role="dialog" id="upload-bestand">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||||
|
<h4 class="upload file">Uploaden bestand</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="upload-btn-wrapper">
|
||||||
|
<button class="upload-btn">Kies bestand</button>
|
||||||
|
<input type="file" name="myfile" id="file-chooser" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">sluit</button>
|
||||||
|
<button type="button" class="btn btn-primary">uploaden</button>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div><!-- /.modal -->
|
||||||
@@ -317,3 +317,27 @@ th.focus-green{
|
|||||||
color:#666;
|
color:#666;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.upload-btn-wrapper {
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-btn {
|
||||||
|
border: 2px solid gray;
|
||||||
|
color: gray;
|
||||||
|
background-color: white;
|
||||||
|
padding: 8px 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-btn-wrapper input[type=file] {
|
||||||
|
font-size: 100px;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
dbo.documentsDataService = {
|
dbo.documentsDataService = {
|
||||||
|
|
||||||
getdocuments: function ( foreignID, tablename, callback ) {
|
getdocuments: function ( foreignID, callback ) {
|
||||||
$.getJSON( 'index.php/projects/documentsController/getDocuments/' + foreignID + '/' + tablename )
|
$.getJSON( 'index.php/projects/documentsController/getDocuments/' + foreignID )
|
||||||
.done( function ( data ) {
|
.done( function ( data ) {
|
||||||
callback( data );
|
callback( data );
|
||||||
} );
|
} );
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ $( function () {
|
|||||||
$('body').delay(500).fadeIn(1500);
|
$('body').delay(500).fadeIn(1500);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
function uploadFile( file, foreignID, tablename, callback ) {
|
function uploadFile( file, foreignID, callback ) {
|
||||||
var url = 'index.php/utils/fileUpload/upload/' + foreignID + '/' + tablename;
|
var url = 'index.php/utils/fileUpload/upload/' + foreignID;
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
var fd = new FormData();
|
var fd = new FormData();
|
||||||
xhr.open( "POST", url, true );
|
xhr.open( "POST", url, true );
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ $( function () {
|
|||||||
outstanding : ko.observable(),
|
outstanding : ko.observable(),
|
||||||
toForecast : ko.observable(),
|
toForecast : ko.observable(),
|
||||||
totalForecast : ko.observable(),
|
totalForecast : ko.observable(),
|
||||||
|
documents : ko.observableArray( [] ),
|
||||||
|
comments : ko.observableArray( [] ),
|
||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
var vm = dbo.editProjectModal;
|
var vm = dbo.editProjectModal;
|
||||||
@@ -747,6 +749,8 @@ $( function () {
|
|||||||
vm.reservations.push( new vm.Reservation( p ) );
|
vm.reservations.push( new vm.Reservation( p ) );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
vm.refreshDocuments();
|
||||||
|
|
||||||
vm.busy = false;
|
vm.busy = false;
|
||||||
|
|
||||||
dbo.charts.drawHoursVsBudget( 340, 230, 'hours-vs-budget' );
|
dbo.charts.drawHoursVsBudget( 340, 230, 'hours-vs-budget' );
|
||||||
@@ -879,7 +883,73 @@ $( function () {
|
|||||||
this.reservationamount = ko.observable( data.reservationamount );
|
this.reservationamount = ko.observable( data.reservationamount );
|
||||||
this.payed = ko.observable( data.payed );
|
this.payed = ko.observable( data.payed );
|
||||||
this.inEdit = ko.observable( data.inEdit || false );
|
this.inEdit = ko.observable( data.inEdit || false );
|
||||||
|
},
|
||||||
|
|
||||||
|
addDocument: function ( data, evt ) {
|
||||||
|
var vm = dbo.editProjectModal;
|
||||||
|
uploadFile( evt.target.files[0], vm.projectID, function () {
|
||||||
|
vm.refreshDocuments();
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
|
addComment: function () {
|
||||||
|
var vm = dbo.editProjectModal;
|
||||||
|
dbo.commentsDataService.addComment( vm.selectedRowID(), vm.tableName, function ( commentID ) {
|
||||||
|
dbo.commentModel.showComment( commentID, function () {
|
||||||
|
vm.refreshComments();
|
||||||
|
} )
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
|
editComment: function () {
|
||||||
|
var vm = dbo.editProjectModal;
|
||||||
|
dbo.commentModel.showComment( this.id, function () {
|
||||||
|
vm.refreshComments();
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
|
downloadDocument: function () {
|
||||||
|
window.open( 'index.php/projects/documentscontroller/downloaddocument/' + this.id );
|
||||||
|
},
|
||||||
|
|
||||||
|
refreshComments: function () {
|
||||||
|
var vm = dbo.editProjectModal;
|
||||||
|
|
||||||
|
dbo.commentsDataService.getComments( vm.selectedRowID(), vm.tableName, function ( data ) {
|
||||||
|
vm.comments.removeAll();
|
||||||
|
console.log( data );
|
||||||
|
$.each( data, function ( i, p ) {
|
||||||
|
vm.comments.push( new vm.Comment( p ) );
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
|
refreshDocuments: function () {
|
||||||
|
var vm = dbo.editProjectModal;
|
||||||
|
|
||||||
|
dbo.documentsDataService.getdocuments( vm.projectID, function ( data ) {
|
||||||
|
vm.documents.removeAll();
|
||||||
|
|
||||||
|
$.each( data, function ( i, p ) {
|
||||||
|
vm.documents.push( new vm.Document( p ) );
|
||||||
|
} )
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
|
Comment: function ( data ) {
|
||||||
|
this.id = data.id;
|
||||||
|
this.comment_date = data.comment_date;
|
||||||
|
this.fullname = data.user.fullname;
|
||||||
|
this.comment = ko.observable( data.comment );
|
||||||
|
},
|
||||||
|
|
||||||
|
Document: function ( data ) {
|
||||||
|
this.id = data.id;
|
||||||
|
this.originalname = data.originalname;
|
||||||
|
this.uploaddate = data.uploaddate;
|
||||||
|
this.fullname = data.user.fullname;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dbo.editProjectModal.totalHours = ko.pureComputed( function () {
|
dbo.editProjectModal.totalHours = ko.pureComputed( function () {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ dbo.documentService = {
|
|||||||
|
|
||||||
tableName: 'OFFER',
|
tableName: 'OFFER',
|
||||||
|
|
||||||
|
|
||||||
removeFile: function (that) {
|
removeFile: function (that) {
|
||||||
var vm = dbo.offersService.vm;
|
var vm = dbo.offersService.vm;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user