Diversen nav opmerkingen

This commit is contained in:
2018-05-06 20:39:59 +02:00
parent a3d200c38b
commit c7846f9a80
16 changed files with 126 additions and 82 deletions
@@ -38,4 +38,10 @@ class vatController extends MY_Controller {
{
Vat::create( [] );
}
public function saveVat( $vatID )
{
$vatrate = $this->input->post( 'vatrate' );
Vat::whereId( $vatID )->update( ['vatrate' => $vatrate] );
}
}
@@ -41,8 +41,6 @@ class ProjectsController extends MY_Controller {
$project->invoiceDetails =
$this->Invoices_model->getOutstandingPerProject( $project->id );
$project->vatrate = Vat::getCurrentVat();
$this->json( $project );
}
+4 -5
View File
@@ -23,7 +23,7 @@ class FileUpload extends MY_Controller {
$this->load->library( $libraries );
}
public function upload( $foreignID, $tablename )
public function upload( $foreignID )
{
$config['upload_path'] = MYROOTPATH . 'documents/temp';
$config['allowed_types'] = '*';
@@ -43,7 +43,7 @@ class FileUpload extends MY_Controller {
$this->setStoragename();
$this->persistDocument( $data['upload_data'], $foreignID, $tablename );
$this->persistDocument( $data['upload_data'], $foreignID );
$this->renameDocument( $data['upload_data']['full_path'] );
}
@@ -55,15 +55,14 @@ class FileUpload extends MY_Controller {
$this->storagename = sha1( random_string( 'alnum', 16 ) );
}
private function persistDocument( $data, $foreignID, $tablename )
private function persistDocument( $data, $foreignID )
{
$file = [
'storagename' => $this->storagename,
'originalname' => $data['file_name'],
'user_id' => USERID,
'uploaddate' => date( 'Y-m-d H:i:s' ),
'foreign_id' => $foreignID,
'foreign_table' => $tablename
'foreign_id' => $foreignID
];
Document::create( $file );
+1 -1
View File
@@ -16,7 +16,7 @@ class MY_Controller extends CI_Controller {
{
parent::__construct();
$this->version = '0.10.AA';
$this->version = '0.02.00';
$this->load->library( 'beheer/session/RetrieveUserSession' );
+6
View File
@@ -41,6 +41,11 @@ class Project extends BaseModel {
return $this->hasMany( 'Reservation' );
}
public function vat()
{
return $this->belongsTo('Vat');
}
public function projectleader()
{
return $this->belongsTo( 'User', 'projectleader_id' );
@@ -112,6 +117,7 @@ class Project extends BaseModel {
->with( 'projectcosts.external' )
->with( 'invoices.payments' )
->with( 'invoices.vat' )
->with( 'vat' )
->with( 'customer' );
return $project;
@@ -14,7 +14,12 @@ class ReservationTotals {
$sql = "SELECT Q5.project_id AS projectID, external_id AS externalID,
costs, reservation, payed, (reservation - payed) AS saldo,
(costs - payed) AS saldoToPay, PRJ.projectnumber, EXT.contactperson,
ROUND(( (other_revenue * (100 + (SELECT vatrate from vats where active='T' LIMIT 1))) / 100 ), 0) other_revenue
ROUND(( (other_revenue * (100 + (
SELECT vatrate
FROM vats VTS
JOIN projects P
ON VTS.id = P.vat_id
WHERE P.id = PRJ.id LIMIT 1))) / 100 ), 0) other_revenue
FROM (
SELECT COALESCE(reservation, 0) AS reservation, costs, payed, Q2.external_id, Q2.project_id
FROM (
@@ -75,6 +75,17 @@
</div>
</div>
<div class="divider"></div>
<label class="col-md-4 col-form-label">BTW percentage</label>
<div class="col-md-3">
<select class="form-control form-control-sm"
data-bind="options:vats,
optionsText:'vatrate',
optionsValue:'id',
value:vat_id,
event:{change:$root.saveProject},
optionsCaption:'selecteer btw ...'"></select>
</div>
<div class="divider"></div>
<label class="col-md-4 col-form-label">te besteden uren</label>
<div class="col-md-8">
<h4><span data-bind="text:(totalBudget() - totalHours())"></span></h4>
@@ -7,16 +7,16 @@
<div class="panel-body panel-body-project">
<table class="table table-sm">
<thead>
<th class="table-cyanish-header">
<th class="table-cyanish-header" width="40%">
naam
</th>
<th class="table-cyanish-header align-right">
<th class="table-cyanish-header align-right" width="20%">
tarief
</th>
<th class="table-cyanish-header align-right">
<th class="table-cyanish-header align-right" width="25%">
budget
</th>
<th class="table-cyanish-header" width="40px">
<th class="table-cyanish-header" width="15%">
&nbsp;&nbsp;
</th>
</thead>
@@ -1,4 +1,4 @@
<div class="col-md-6">
<div class="col-md-8">
<table class="table table-condensed">
<thead>
<tr>
@@ -8,8 +8,8 @@
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<tr data-bind="foreach:documents">
<tbody data-bind="foreach:documents">
<tr>
<td>
<span data-bind="text:fullname"></span>
</td>
@@ -25,6 +25,7 @@
</td>
</tr>
</tbody>
<tfoot>
<tr></tr>
</tfoot>
</table>
@@ -32,19 +33,5 @@
<button class="upload-btn">voeg bestand toe</button>
<input type="file" name="userfile" data-bind="event:{change:addDocument}" id="fileinput"/>
</div>
</div>
<div class="col-md-6">
<hr/>
<!-- <button data-bind="click:addComment" class="upload-btn">-->
<!-- voeg commentaar toe-->
<!-- </button>-->
<!-- ko foreach: comments -->
<div data-bind="click:$root.editComment" class="pointer">
<span class="badge badge-info" style="width:100%; text-align:left;">
<span data-bind="text:fullname"></span> |
<span data-bind="text:comment_date"></span>
</span>
</div>
<div data-bind="html:comment,click:$root.editComment" class="comment-text pointer"></div>
<!-- /ko -->
</div>
+1 -4
View File
@@ -45,6 +45,7 @@
sluit
</button>
</div>
<div id="project-scroller">
<div class="tab-pane animation-slide-top"
id="dashboard"
data-bind="visible:activeTab()=='DASHBOARD'">
@@ -72,12 +73,8 @@
id="files"
data-bind="visible:activeTab()=='FILES'">
<div class="row" data-bind="fadeVisible:customerID()">
<div class="col-md-4">
<?php $this->load->view( 'modals/partials/_projectfiles' ); ?>
</div>
<div class="col-md-4">
<?php $this->load->view( 'modals/partials/_projectcomments' ); ?>
</div>
</div>
</div>
</div>
+8 -3
View File
@@ -1,6 +1,6 @@
<div class="VAT">
<div class="row">
<div class="col-md-4">
<div class="col-md-2">
<table class="table table-condensed">
<thead>
<tr>
@@ -11,10 +11,15 @@
<tbody data-bind="foreach:vats">
<tr>
<td>
<input type="text" data-bind="text:vatrate" />
<div class="percentage-sign-holder">
<input type="text"
class="form-control percentage-input"
data-bind="textInput:vatrate,
event:{keyup:$root.validateNumber.bind($data, 'vatrate')}">
<span class="percentage-sign">&#x25;</span>
</div>
</td>
<td width="60px">
<i class="icon fa-sellsy"></i>
<i class="icon fa-edit" data-bind="click:$root.toggleEdit"></i>
<i class="icon fa-trash redish" data-bind="$root.removeVat"></i>
</td>
+5 -1
View File
@@ -215,7 +215,7 @@ th.focus-green{
}
.percentage-sign {
position: absolute;
right: 15px;
right: 12px;
z-index: 10;
top: 7px;
}
@@ -382,3 +382,7 @@ th.focus-green{
color: red;
}
#project-scroller {
overflow: auto;
}
@@ -19,6 +19,10 @@ dbo.vatDataService = {
.done( function () {
callback();
} );
},
saveVat: function ( vatID, vatrate ) {
$.post( 'index.php/beheer/vatController/saveVat/' + vatID, {vatrate: vatrate} );
}
}
+15 -4
View File
@@ -34,6 +34,7 @@ $( function () {
archive : ko.observable( false ),
startdate : ko.observable( null ),
enddate : ko.observable( null ),
vat_id : ko.observable(),
projectname : ko.observable(),
busy : false,
ownRevenue : ko.observable(),
@@ -58,6 +59,10 @@ $( function () {
init: function () {
var vm = dbo.editProjectModal;
vm.busy = true;
$( "#project-scroller" ).height( $( window ).height() - 100 );
dbo.customerDataService.getAllCustomers( 'F', function ( data ) {
vm.customers( data );
dbo.userDataService.getAllUsers( 'F', function ( data ) {
@@ -71,6 +76,8 @@ $( function () {
vm.refreshProject();
vm.activeTab( 'DASHBOARD' );
vm.busy = false;
} );
} );
} );
@@ -287,6 +294,7 @@ $( function () {
vm.callback = callback;
dbo.projectDataService.addProject( function ( data ) {
console.log( data );
vm.projectID = data;
vm.showProject( true );
@@ -365,11 +373,13 @@ $( function () {
projectleader_id: vm.projectleaderID(),
projectname : vm.projectname(),
startdate : vm.startdate(),
enddate : vm.enddate()
enddate : vm.enddate(),
vat_id : vm.vat_id()
}
dbo.projectDataService.saveProject( vm.projectID, submitDATA, function ( data ) {
vm.projectID = data;
vm.refreshProject();
// vm.projectID = data.projectID;
} );
},
@@ -725,7 +735,7 @@ $( function () {
vm.busy = true;
dbo.projectDataService.getProject( vm.projectID, function ( data ) {
var totalRevenuesIncl = Math.round( (data.invoiceDetails.totalrevenue * (data.vatrate + 100)) / 100 );
var totalRevenuesIncl = Math.round( (data.invoiceDetails.totalrevenue * (Number( data.vat.vatrate ) + 100)) / 100 );
vm.id = data.id
vm.projectleaderID( data.projectleader_id );
@@ -734,6 +744,7 @@ $( function () {
vm.enddate( dbo.helpers.mysql2date( data.enddate ) );
vm.projectnumber( data.projectnumber );
vm.projectname( data.projectname );
vm.vat_id( data.vat_id );
vm.totalRevenues( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalrevenue ) ) ) );
vm.totalRevenuesIncl( dbo.helpers.numberWithPoints( totalRevenuesIncl ) );
vm.totalInvoiced( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalinvoiced ) ) ) );
@@ -978,7 +989,7 @@ $( function () {
refreshDocuments: function () {
var vm = dbo.editProjectModal;
console.log( vm.projectID );
dbo.documentsDataService.getdocuments( vm.projectID, function ( data ) {
vm.documents.removeAll();
+16 -2
View File
@@ -7,6 +7,7 @@
dbo.vatInit = function () {
var timeout;
if ( dbo.vatModel !== undefined ) {
@@ -35,7 +36,7 @@ dbo.vatInit = function () {
vm.vats.removeAll();
_.each( data, function ( p ) {
vm.vats( new vm.Vat( p ) );
vm.vats.push( new vm.Vat( p ) );
} )
} );
},
@@ -44,9 +45,22 @@ dbo.vatInit = function () {
this.inEdit( !this.inEdit() );
},
validateNumber: function ( field ) {
var self = this;
self[field]( dbo.helpers.validateNumber( self[field](), true ) );
if ( timeout ) {
clearTimeout( timeout );
timeout = null;
}
timeout = setTimeout( function () {
dbo.vatDataService.saveVat( self.id, self.vatrate() );
}, 700 );
},
Vat: function ( data, inEdit = false ) {
this.id = data.id;
this.vatrate = ko.observable( data.vatrate );
this.vatrate = ko.observable( data.vatrate || 0 );
this.inEdit = ko.observable( inEdit );
},
@@ -96,17 +96,14 @@ dbo.reservationsInit = function () {
self.payed = dbo.helpers.numberWithPoints( data.payed );
self.saldo = dbo.helpers.numberWithPoints( data.saldo );
self.saldoToPay = dbo.helpers.numberWithPoints( data.saldoToPay );
}
}
}
dbo.reservationsModel.init();
ko.applyBindings(
dbo.reservationsModel, document.getElementById( "RESERVATIONS" ) );
ko.applyBindings( dbo.reservationsModel, document.getElementById( "RESERVATIONS" ) );
}
}