This commit is contained in:
2018-01-31 11:10:17 +01:00
parent f3bf0c9f80
commit 05c165c9ed
27 changed files with 724 additions and 265 deletions
@@ -49,7 +49,9 @@ class OffersController extends MY_Controller {
$offerID = Offer::saveOffer( $offerID, $offer );
$this->json( ['success' => TRUE, 'offerID' => $offerID] );
$createProject = $this->checkCreateproject( $offerID );
$this->json( ['success' => TRUE, 'offerID' => $offerID, 'createProject' => $createProject] );
}
public function archiveOffer( $offerID, $status )
@@ -68,4 +70,14 @@ class OffersController extends MY_Controller {
$this->json( ['result' => TRUE] );
}
private function checkCreateproject( $offerID )
{
$offer = Offer::find( $offerID );
if ( is_int( $offer->project_id ) ) return FALSE;
if ( is_null( $offer->accepteddate ) ) return FALSE;
return TRUE;
}
}
@@ -41,6 +41,14 @@ class ProjectsController extends MY_Controller {
$this->json( $project );
}
public function getAvailableEmployees( $projectID )
{
$availableEmployees =
Projectemployee::getAvailableEmployees( $projectID );
$this->json( $availableEmployees );
}
public function addProject()
{
$projectID = Project::createProject();
@@ -48,6 +56,30 @@ class ProjectsController extends MY_Controller {
$this->json( $projectID );
}
public function creatProjectFromOffer( $offerID )
{
$offer = Offer::find( $offerID );
$offernumber = $offer->offernumber;
$projectnumber = 'P' . substr( $offernumber, 1 );
$data = [
'projectnumber' => $projectnumber,
'projectleader_id' => $offer->offerleader_id,
'startdate' => $offer->accepteddate,
'customer_id' => $offer->customer_id
];
$project = Project::create( $data );
Offer::whereId( $offerID )->update( ['project_id' => $project->id] );
Projectemployee::create( ['project_id' => $project->id, 'user_id' => $offer->offerleader_id] );
$this->json( ['success' => TRUE, 'projectnumber' => $projectnumber] );
}
public function addProjectEmployee( $projectID )
{
Projectemployee::createProjectEmployee( $projectID );
@@ -94,6 +126,29 @@ class ProjectsController extends MY_Controller {
$this->json( ['success' => TRUE] );
}
public function saveInvoice()
{
$invoiceValidation = new InvoiceValidation();
if ( ! $invoiceValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $invoiceValidation->getErrorMessages()] );
$invoice = $this->input->post();
$invoiceID = $invoice['id'];
unset( $invoice['id'] );
$invoice['invoicedate'] = date2mysql( $invoice['invoicedate'] );
$invoice['forecastdate'] = date2mysql( $invoice['forecastdate'] );
$invoice['invoiceamount'] = str_replace( ',', '.', $invoice['invoiceamount'] );
$invoice['forecastamount'] = str_replace( ',', '.', $invoice['forecastamount'] );
$invoiceID = Invoice::saveInvoice( $invoiceID, $invoice );
$this->json( ['success' => TRUE, 'invoiceID' => $invoiceID] );
}
public function savePayment()
{
$paymentValidation = new PaymentValidation();
@@ -108,10 +163,31 @@ class ProjectsController extends MY_Controller {
unset( $payment['id'] );
$payment['paymentdate'] = date2mysql( $payment['paymentdate'] );
$payment['paymentamount'] = str_replace( ',', '.', $payment['paymentamount'] );
$paymentID = Payment::savePayment( $paymentID, $payment );
$this->json( ['success' => TRUE, 'paymentID'=> $paymentID ] );
$this->json( ['success' => TRUE, 'paymentID' => $paymentID] );
}
public function saveProjectcost()
{
$projectcostValidation = new ProjectcostValidation();
if ( ! $projectcostValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $projectcostValidation->getErrorMessages()] );
$projectcost = $this->input->post();
$projectcostID = $projectcost['id'];
unset( $projectcost['id'] );
$projectcost['date'] = date2mysql( $projectcost['date'] );
$projectcostID = Projectcost::saveProjectcost( $projectcostID, $projectcost );
$this->json( ['success' => TRUE, 'projectcostID' => $projectcostID] );
}
public function saveProjecthour()
@@ -131,7 +207,7 @@ class ProjectsController extends MY_Controller {
$paymentID = Projecthour::saveProjecthour( $projecthourID, $projecthour );
$this->json( ['success' => TRUE, 'projecthourID'=> $paymentID ] );
$this->json( ['success' => TRUE, 'projecthourID' => $paymentID] );
}
public function archiveProject( $projectID, $status )
@@ -0,0 +1,44 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 10/07/16
* Time: 13:35
*/
require_once( APPPATH . 'libraries/validation/inputValidations/BaseValidation.php' );
class InvoiceValidation extends BaseValidation {
protected $validationFields = [
'project_id' => [
'validations' => 'required|integer',
'fieldname' => 'project'
],
'invoicedate' => [
'validations' => 'date',
'fieldname' => 'factuurdatum'
],
'forecastdate' => [
'validations' => 'date',
'fieldname' => 'prognosedatum'
],
'invoiceamount' => [
'validations' => 'number',
'fieldname' => 'factuurbedrag'
],
'forecastamount' => [
'validations' => 'number',
'fieldname' => 'prognosebedrag'
]
];
public function __construct()
{
parent::__construct();
$this->ci =& get_instance();
}
}
@@ -13,9 +13,9 @@ class PaymentValidation extends BaseValidation {
protected $validationFields = [
'offer_id' => [
'invoice_id' => [
'validations' => 'required|integer',
'fieldname' => 'offerte'
'fieldname' => 'factuur'
],
'paymentdate' => [
'validations' => 'date',
@@ -0,0 +1,40 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 10/07/16
* Time: 13:35
*/
require_once( APPPATH . 'libraries/validation/inputValidations/BaseValidation.php' );
class ProjectcostValidation extends BaseValidation {
protected $validationFields = [
'project_id' => [
'validations' => 'required|integer',
'fieldname' => 'project'
],
'external_id' => [
'validations' => 'required|integer',
'fieldname' => 'externe'
],
'date' => [
'validations' => 'date',
'fieldname' => 'datum'
],
'costs' => [
'validations' => 'number',
'fieldname' => 'kosten'
]
];
public function __construct()
{
parent::__construct();
$this->ci =& get_instance();
}
}
@@ -32,5 +32,12 @@ class ProjectemployeeValidation extends BaseValidation {
parent::__construct();
$this->ci =& get_instance();
$this->handleSpecificValidations();
}
protected function handleSpecificValidations()
{
}
}
+17
View File
@@ -22,4 +22,21 @@ class Invoice extends BaseModel {
{
return $this->belongsTo( 'Vat' );
}
public static function saveInvoice( $invoiceID, $invoice )
{
$invoice = (array) $invoice;
if ( $invoiceID == 0 )
{
$invoice = Invoice::create( $invoice );
$invoiceID = $invoice['id'];
}
else
{
Invoice::whereId( $invoiceID )->update( $invoice );
}
return $invoiceID;
}
}
+4 -2
View File
@@ -52,13 +52,15 @@ class Offer extends BaseModel {
if ( $offerID == 0 )
{
$offer = Offer::create( $offer );
$offerID = $offer['id'];
}
else
{
$offer = Offer::whereId( $offerID )->update( $offer );
Offer::whereId( $offerID )->update( $offer );
}
return $offer['id'];
return $offerID;
}
public static function removeOffer( $offerID )
@@ -18,4 +18,21 @@ class Projectcost extends BaseModel {
return $this->belongsTo( 'External' );
}
public static function saveProjectcost( $projectID, $project )
{
$project = (array) $project;
if ( $projectID == 0 )
{
$project = Self::create( $project );
$projectID = $project['id'];
}
else
{
Self::whereId( $projectID )->update( $project );
}
return $projectID;
}
}
@@ -23,6 +23,19 @@ class Projectemployee extends BaseModel {
return $this->hasMany( 'Projecthour' );
}
public static function getAvailableEmployees( $projectID )
{
$currentEmployees = Self::whereProjectId( $projectID )
->lists( 'user_id' );
$availableEmployees = User::selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" )
->whereNotIn( 'id', $currentEmployees )
->whereArchive( 'F' )
->get();
return $availableEmployees;
}
public static function createProjectEmployee( $projectID )
{
$projectemployee = Projectemployee::create( [
+2 -4
View File
@@ -54,7 +54,6 @@
<i class="icon fa-plus-square greenish pointer" data-bind="click:addUser"></i>
</div>
</div>
<!-- ko if : ! hasProject() -->
<div class="form-group row">
<label class="col-xl-3 form-control-label">
klant
@@ -67,7 +66,6 @@
optionsText:'name',
value:customer_id,
optionsCaption:'selecteer klant',
disable:hasProject,
event:{change:getCustomerProjects}"></select>
</div>
<small class="invalid-feedback"
@@ -92,7 +90,6 @@
value:project_id"></select>
</div>
</div>
<!-- /ko -->
<div class="form-group row">
</div>
@@ -184,7 +181,8 @@
placeholder="acceptatie datum"
class="form-control"
readonly
data-bind="datepicker:{dateFormat: 'dd-mm-yy' }, value:accepteddate, disable:rejectdate()">
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
value:accepteddate, disable:rejectdate()">
</div>
</div>
<div class="col-xl-1">
+3 -2
View File
@@ -13,7 +13,7 @@
<th class="table-cyanish-header">
datum
</th>
<th class="table-cyanish-header">
<th class="table-cyanish-header align-right">
uren
</th>
<th class="table-cyanish-header" width="40px">
@@ -23,7 +23,8 @@
<tbody data-bind="foreach:projecthours">
<tr>
<td>
<span data-bind="text:fullname, visible:! inEdit()"></span>
<span data-bind="text:dbo.helpers.findArrayElement('id', 'fullname', projectemployee_id(), $root.projectEmployees()),
visible:! inEdit()"></span>
<select class="form-control form-control-sm"
data-bind="options:$root.projectEmployees,
optionsText:'fullname',
@@ -14,13 +14,16 @@
<th class="table-cyanish-header">
factuurdatum
</th>
<th class="table-cyanish-header">
<th class="table-cyanish-header align-right">
bedrag (excl)
</th>
<th class="table-cyanish-header">
<th class="table-cyanish-header align-right">
bedrag (incl)
</th>
<th class="table-cyanish-header">
<th class="table-cyanish-header align-right">
openstaand
</th>
<th class="table-cyanish-header align-right">
prognose(excl)
</th>
<th class="table-cyanish-header">
@@ -67,10 +70,14 @@
data-bind="textInput:invoiceamount, visible:inEdit,
event:{change:$root.saveInvoice,keyup:$root.validateNumber.bind($data, 'invoiceamount')}"/>
</td>
<td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:inclBtw"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:outstanding"></span>
</td>
<td class="align-right">
<span data-bind=" visible: ! inEdit()">
<i class="icon fa-euro"></i>
@@ -125,6 +132,7 @@
</th>
<th class="table-cyanish-header-light">
</th>
<th width="50%">&nbsp;</th>
</thead>
<tbody data-bind="foreach:payments">
<tr>
@@ -147,26 +155,30 @@
class="form-control form-control-sm align-right"
paceholder="bedrag"
data-bind="textInput:paymentamount, visible:inEdit,
event:{change:$root.saveInvoice,
event:{change:$root.savePayment,
keyup:$root.validateNumber.bind($data, 'paymentamount')}"/>
</td>
<td>
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editPayment"></i>
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editPayment.bind($data, $parents[0])"></i>
<i class="icon fa-trash redish pointer" title="verwijder"
data-bind="click:$root.removePayment"></i>
</td>
</tr>
</tbody>
<tfoot>
<td colspan="4">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:$root.newPayment">
<td></td>
<td colspan="3">
<a href="#" data-bind="click:$root.newPayment">
nieuwe betaling
</button>
</a>
</td>
</tfoot>
</table>
</td>
</tr>
<tr>
<th colspan="10" class="table-cyanish-header"></th>
</tr>
</tbody>
<tfoot>
<tr>
@@ -26,7 +26,8 @@
<tbody data-bind="foreach:projectcosts">
<tr>
<td>
<span data-bind="text:contactperson, visible:! inEdit()"></span>
<span data-bind="text:dbo.helpers.findArrayElement('id', 'contactperson', external_id(), $root.externals()),
visible:! inEdit()"></span>
<select class="form-control form-control-sm"
data-bind="options:$root.externals,
optionsText:'contactperson',
@@ -68,7 +69,7 @@
event:{change:$root.saveProjectcosts,keyup:$root.validateNumber.bind($data, 'costs')}"/>
</td>
<td>
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editProjecthour"></i>
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editProjectcosts"></i>
<i class="icon fa-trash redish pointer" title="verwijder"
data-bind="click:$root.removeProjecthour"></i>
</td>
@@ -0,0 +1,87 @@
<div class="row" form-inline>
<div class="col-md-3">
<div class="form-group row">
<label class="col-md-3 col-form-label">klant</label>
<div class="col-md-9">
<select class="form-control form-control-sm"
data-bind="options:customers,
optionsText:'name',
optionsValue: 'id',
value:customerID,
disable:offers().length > 0,
optionsCaption:'selecteer klant',
event:{change:saveProject},
css:{'is-invalid': ! customerID()}"></select>
<small class="invalid-feedback"
data-bind="style:{display: ! customerID() ? 'block' : 'none'}">
selecteer een klant
</small>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group row">
<label class="col-md-5 col-form-label">projectleider</label>
<div class="col-md-7">
<select class="form-control form-control-sm"
data-bind="options:users,
optionsText:'fullname',
optionsValue:'id',
value:projectleaderID,
optionsCaption:'projectleider',
event:{change:saveProject}">
</select>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group row">
<label class="col-md-5 col-form-label">begin project</label>
<div class="col-md-7">
<div class="input-group input-group-icon">
<span class="input-group-addon">
<i class="icon fa-calendar"></i>
</span>
<input type="text"
placeholder="start project"
class="form-control form-control-sm"
readonly
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
value:startdate,
event:{change:saveProject}">
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group row">
<label class="col-md-5 col-form-label">eind project</label>
<div class="col-md-7">
<div class="input-group input-group-icon">
<span class="input-group-addon">
<i class="icon fa-calendar"></i>
</span>
<input type="text"
placeholder="eind project"
class="form-control form-control-sm"
readonly
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
value:enddate,
event:{change:saveProject}">
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="graph-holder">
<canvas id="hours-vs-budget" height="300"></canvas>
</div>
</div>
<div class="col-md-4">
<div class="graph-holder">
<canvas id="invoice-vs-payed" height="300"></canvas>
</div>
</div>
</div>
@@ -16,12 +16,6 @@
<th class="table-cyanish-header">
budget
</th>
<th class="table-cyanish-header">
start
</th>
<th class="table-cyanish-header">
eind
</th>
<th class="table-cyanish-header" width="40px">
&nbsp;&nbsp;
</th>
@@ -29,7 +23,8 @@
<tbody data-bind="foreach:projectEmployees">
<tr>
<td>
<span data-bind="text:fullname, visible: ! inEdit()"></span>
<span data-bind="text:dbo.helpers.findArrayElement('id', 'fullname', employeeID(), $root.users()),
visible: ! inEdit()"></span>
<select class="form-control form-control-sm"
data-bind="
options:$root.users,
@@ -59,23 +54,6 @@
data-bind="textInput:budget, visible:inEdit,
event:{change:$root.saveProjectemployee,keyup:$root.validateNumber.bind($data, 'budget')}"/>
</td>
<td>
<span data-bind="text:startdate, visible: ! inEdit()"></span>
<input type="text"
class="form-control form-control-sm"
placeholder="start"
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
value:startdate, visible:inEdit,
event:{change:$root.saveProjectemployee}"/>
</td>
<td>
<span data-bind="visible: ! inEdit()"></span>
<input type="text"
class="form-control form-control-sm"
placeholder=""
data-bind="visible:inEdit,
event:{change:$root.saveProjectemployee}"/>
</td>
<td>
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editProjectemployee"></i>
<i class="icon fa-trash redish pointer" title="verwijder"
@@ -37,19 +37,19 @@
<td>
<span data-bind="text:other_revenue"></span>
</td>
<td>
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editOffer"></i>
<i class="icon fa-trash redish pointer" title="verwijder"
data-bind="click:$root.removeOffer"></i>
</td>
<!-- <td>-->
<!-- <i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editOffer"></i>-->
<!-- <i class="icon fa-trash redish pointer" title="verwijder"-->
<!-- data-bind="click:$root.removeOffer"></i>-->
<!-- </td>-->
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="5">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newOffer">
nieuwe offerte
</button>
<!-- <button class="btn btn-primary btn-round btn-sm" data-bind="click:newOffer">-->
<!-- nieuwe offerte-->
<!-- </button>-->
</td>
</tr>
</tfoot>
+4 -78
View File
@@ -43,93 +43,19 @@
</ul>
<div class="tab-content">
<div class="tab-pane animation-slide-top active" id="dashboard">
<div class="row" form-inline>
<div class="col-md-3">
<div class="form-group row">
<label class="col-md-3 col-form-label">klant</label>
<div class="col-md-9">
<select class="form-control form-control-sm"
data-bind="options:customers,
optionsText:'name',
optionsValue: 'id',
value:customerID,
disable:offers().length > 0,
optionsCaption:'selecteer klant',
event:{change:saveProject},
css:{'is-invalid': ! customerID()}"></select>
<small class="invalid-feedback"
data-bind="style:{display: ! customerID() ? 'block' : 'none'}">
selecteer een klant
</small>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group row">
<label class="col-md-5 col-form-label">projectleider</label>
<div class="col-md-7">
<select class="form-control form-control-sm"
data-bind="options:users,
optionsText:'fullname',
optionsValue:'id',
value:projectleaderID,
optionsCaption:'projectleider',
event:{change:saveProject}">
</select>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group row">
<label class="col-md-5 col-form-label">begin project</label>
<div class="col-md-7">
<div class="input-group input-group-icon">
<span class="input-group-addon">
<i class="icon fa-calendar"></i>
</span>
<input type="text"
placeholder="start project"
class="form-control form-control-sm"
readonly
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
value:startdate,
event:{change:saveProject}">
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group row">
<label class="col-md-5 col-form-label">eind project</label>
<div class="col-md-7">
<div class="input-group input-group-icon">
<span class="input-group-addon">
<i class="icon fa-calendar"></i>
</span>
<input type="text"
placeholder="eind project"
class="form-control form-control-sm"
readonly
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
value:enddate,
event:{change:saveProject}">
</div>
</div>
</div>
</div>
</div>
<?php $this->load->view('modals/partials/_projectdashboard'); ?>
</div>
<div class="tab-pane animation-slide-top" id="financial">
<div class="row" data-bind="fadeVisible:customerID()">
<div class="col-md-7">
<div class="col-md-6">
<?php $this->load->view( 'modals/partials/_projectoffers' ); ?>
</div>
<div class="col-md-5">
<div class="col-md-6">
<?php $this->load->view( 'modals/partials/_projectcosts' ); ?>
</div>
</div>
<div class="row">
<div class="col-md-9">
<div class="col-md-12">
<?php $this->load->view( 'modals/partials/_invoices' ); ?>
</div>
</div>
+22 -19
View File
@@ -1,4 +1,3 @@
<!-- Core -->
<!--<script src="js/vendor/babel-external-helpers/babel-external-helpers.js"></script>-->
<script src="js/vendor/jquery/jquery.js"></script>
@@ -11,8 +10,7 @@
<script src="js/vendor/froala/js/froala_editor.min.js"></script>
<script src="js/vendor/froala/js/plugins/knockout-froala.js"></script>
<script src="js/vendor/Chart.js"></script>
<!--<script src="js/vendor/mousewheel/jquery.mousewheel.js"></script>-->
@@ -58,28 +56,28 @@
<!-- DBOIS -->
<script src="js/lib/main.js?version=<?=$this->version?>"></script>
<script src="js/lib/modules/specials/tellmeModule.js?version=<?=$this->version?>"></script>
<script src="js/lib/main.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modules/specials/tellmeModule.js?version=<?= $this->version ?>"></script>
<!-- ***********MODULES************* -->
<script src="js/lib/modules/menuModule.js?version=<?=$this->version?>"></script>
<script src="js/lib/modules/beheer/usersModule.js?version=<?=$this->version?>"></script>
<script src="js/lib/modules/beheer/customersModule.js?version=<?=$this->version?>"></script>
<script src="js/lib/modules/beheer/externalsModule.js?version=<?=$this->version?>"></script>
<script src="js/lib/modules/projects/offersModule.js?version=<?=$this->version?>"></script>
<script src="js/lib/modules/projects/projectsModule.js?version=<?=$this->version?>"></script>
<script src="js/lib/modules/menuModule.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modules/beheer/usersModule.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modules/beheer/customersModule.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modules/beheer/externalsModule.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modules/projects/offersModule.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modules/projects/projectsModule.js?version=<?= $this->version ?>"></script>
<!-- ***********MODALS************* -->
<script src="js/lib/modals/userModal.js?version=<?=$this->version?>"></script>
<script src="js/lib/modals/customerModal.js?version=<?=$this->version?>"></script>
<script src="js/lib/modals/externalModal.js?version=<?=$this->version?>"></script>
<script src="js/lib/modals/offerModal.js?version=<?=$this->version?>"></script>
<script src="js/lib/modals/projectModal.js?version=<?=$this->version?>"></script>
<script src="js/lib/modals/commentModal.js?version=<?=$this->version?>"></script>
<script src="js/lib/modals/userModal.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modals/customerModal.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modals/externalModal.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modals/offerModal.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modals/projectModal.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modals/commentModal.js?version=<?= $this->version ?>"></script>
<!-- ***********MODALS************* -->
<script src="js/lib/services/offersService.js?version=<?=$this->version?>"></script>
<script src="js/lib/services/offersService.js?version=<?= $this->version ?>"></script>
<!-- ***********DATASERVICES************* -->
@@ -93,4 +91,9 @@
<script src="js/lib/dataservices/documentsDataservice.js"></script>
<script src="js/lib/dataservices/projectsDataservice.js"></script>
<script src="js/lib/dataservices/vatDataservice.js"></script>
<script src="js/lib/helpers.js"></script>
<script src="js/lib/services/chartService.js"></script>
<script src="js/lib/helpers.js"></script>
+12 -1
View File
@@ -229,10 +229,21 @@
.project-page-header > h3{
color:#fff;
margin-top:10px;
margin-left:30px;
margin-left:20px;
}
.project-page > .container{
background-color: #fff;
}
.graph-holder{
padding:10px 10px;
background-color: #4c4c4c;
background-image: -webkit-gradient(radial, 50% 50%,0,50% 50%,200, from(rgb(22, 20, 17)), to(rgb(76, 76, 76)));
background-image: -webkit-radial-gradient(50% 50%, rgb(76, 76, 76), rgb(22, 20, 17));
background-image: -moz-radial-gradient(50% 50%, rgb(76, 76, 76), rgb(22, 20, 17));
background-image: -o-radial-gradient(50% 50%, rgb(76, 76, 76), rgb(22, 20, 17));
background-image: -ms-radial-gradient(50% 50%, rgb(76, 76, 76), rgb(22, 20, 17));
background-image: radial-gradient(50% 50%, rgb(76, 76, 76), rgb(22, 20, 17));
border-radius: 15px;
}
@@ -22,7 +22,14 @@ dbo.projectDataService = {
},
getpayMents: function ( projectID, callback ) {
$.getJSON( 'index.php/projects/projectsController/getP ayments/' + projectID )
$.getJSON( 'index.php/projects/projectsController/getPayments/' + projectID )
.done( function ( data ) {
callback( data );
} );
},
getAvailableEmployees: function ( projectID, callback ) {
$.getJSON( 'index.php/projects/projectsController/getAvailableEmployees/' + projectID )
.done( function ( data ) {
callback( data );
} );
@@ -40,6 +47,13 @@ dbo.projectDataService = {
} );
},
createProject: function ( offerID, callback ) {
$.getJSON( 'index.php/projects/projectsController/creatProjectFromOffer/' + offerID )
.done( function ( data ) {
callback( data );
} );
},
addProjectemployee: function ( projectID, callback ) {
$.get( 'index.php/projects/projectsController/addProjectemployee/' + projectID, function () {
callback();
@@ -57,6 +71,13 @@ dbo.projectDataService = {
$.post( 'index.php/projects/projectsController/saveProjectemployee', submitDATA );
},
saveInvoice: function ( submitDATA, callback ) {
$.post( 'index.php/projects/projectsController/saveInvoice', submitDATA )
.done( function ( data ) {
callback( data );
} );
},
savePayment: function ( submitDATA, callback ) {
$.post( 'index.php/projects/projectsController/savePayment', submitDATA )
.done( function ( data ) {
@@ -71,6 +92,13 @@ dbo.projectDataService = {
} );
},
saveProjectcost: function ( submitDATA, callback ) {
$.post( 'index.php/projects/projectsController/saveProjectcost', submitDATA )
.done( function ( data ) {
callback( data );
} );
},
archiveProject: function ( userID, status, callback ) {
$.get( 'index.php/projects/projectsController/archiveProject/' + userID + '/' + status )
.done( function () {
+6 -3
View File
@@ -52,14 +52,17 @@ dbo.helpers = {
},
findArrayElement: function ( toFind, element, value, array ) {
console.log( array );
// console.log( toFind );
// console.log( element );
// console.log( value );
// console.log( array );
if ( !Array.isArray( array ) ) return null;
console.log( value );
var foundValue = null
$.each( array, function ( i, p ) {
if ( p[toFind] == value ) foundValue = p[element];
} );
console.log( foundValue );
// console.log( foundValue );
return foundValue;
},
+42 -23
View File
@@ -62,32 +62,51 @@ $( function () {
}
dbo.offerDataService.saveOffer( submitDATA, function ( data ) {
if ( data.success ) {
if ( data.createProject ) {
tellMe( {
title : 'offer aangemaakt',
message : 'de offer is succesvol opgeslagen',
modalClass: 'modal-success'
}, function () {
vm.hideOfferModal();
if ( typeof(vm.callback) == 'function' ) vm.callback();
title : 'project aanmaken',
message : 'De offerte is goedgekeurt maar nog niet gekoppeld aan een project, wilt u een project aanmaken?',
notify : true,
noText : 'Nee, maak geen project aan',
yesText : 'Ja, maak een project aan',
modalClass: 'modal-warning'
}, function ( response ) {
if ( response ) {
dbo.projectDataService.createProject( data.offerID, function ( data ) {
if ( data.success ) {
tellMe( {
title : 'project aangemaakt',
message : 'er is een project aangemaakt met nummer: ' + data.projectnumber,
modalClass: 'modal-success'
}, function(){
vm.hideOfferModal();
} );
} else {
tellMe( {
title : 'fout project aanmaken',
message : 'helaas kon het project niet aangemaakt worden',
modalClass: 'modal-danger'
} );
}
} );
}
} )
} else if ( !data.success ) {
var errorMessage = '<ul>';
$.each( data.messages, function ( i, p ) {
if ( p[0] ) {
errorMessage += '<li>' + i + ': ' + p[0] + '</li>';
}
} );
return;
errorMessage += '</ul>';
tellMe( {
title : 'fout opslaan offerte',
message : errorMessage,
modalClass: 'modal-danger'
} );
}else{
vm.hideOfferModal();
}
var errorMessage = '<ul>';
$.each( data.messages, function ( i, p ) {
if ( p[0] ) {
errorMessage += '<li>' + i + ': ' + p[0] + '</li>';
}
} );
errorMessage += '</ul>';
tellMe( {
title : 'fout aanmaken offer',
message : errorMessage,
modalClass: 'modal-danger'
} );
} );
},
+150 -83
View File
@@ -9,28 +9,29 @@ $( function () {
var timeout;
dbo.editProjectModal = {
offers : ko.observableArray( [] ),
projectEmployees: ko.observableArray( [] ),
customers : ko.observableArray( [] ),
users : ko.observableArray( [] ),
invoices : ko.observableArray( [] ),
projecthours : ko.observableArray( [] ),
offerFiles : ko.observableArray( [] ),
offerComments : ko.observableArray( [] ),
projectFiles : ko.observableArray( [] ),
projectComments : ko.observableArray( [] ),
externals : ko.observableArray( [] ),
projectcosts : ko.observableArray( [] ),
vats : ko.observableArray( [] ),
showProject : ko.observable( false ),
projectID : null,
callback : null,
customerID : ko.observable( null ),
projectleaderID : ko.observable(),
archive : ko.observable( false ),
startdate : ko.observable( null ),
enddate : ko.observable( null ),
busy : false,
offers : ko.observableArray( [] ),
projectEmployees : ko.observableArray( [] ),
customers : ko.observableArray( [] ),
users : ko.observableArray( [] ),
invoices : ko.observableArray( [] ),
projecthours : ko.observableArray( [] ),
offerFiles : ko.observableArray( [] ),
offerComments : ko.observableArray( [] ),
projectFiles : ko.observableArray( [] ),
projectComments : ko.observableArray( [] ),
externals : ko.observableArray( [] ),
projectcosts : ko.observableArray( [] ),
vats : ko.observableArray( [] ),
availableEmployees: ko.observableArray( [] ),
showProject : ko.observable( false ),
projectID : null,
callback : null,
customerID : ko.observable( null ),
projectleaderID : ko.observable(),
archive : ko.observable( false ),
startdate : ko.observable( null ),
enddate : ko.observable( null ),
busy : false,
init: function () {
var vm = dbo.editProjectModal;
@@ -40,9 +41,13 @@ $( function () {
dbo.userDataService.getAllUsers( 'F', function ( data ) {
vm.users( data );
dbo.externalDataService.getAllExternals( 'F', function ( data ) {
vm.externals( data );
dbo.vatDataService.getVats( 'F', function ( data ) {
vm.vats( data )
vm.refreshProject();
vm.vats( data );
vm.refreshAvailableEmployees( function () {
vm.refreshProject();
} );
} );
} );
} );
@@ -50,11 +55,11 @@ $( function () {
},
togglePayments: function () {
this.showPayment( !this.showPayment() );
this.showPayments( !this.showPayments() );
var showPayments = sessionStorage.showPayments || [];
if ( this.showPayment() ) {
if ( this.showPayments() ) {
showPayments.push( this.id );
} else {
var index = showPayments.indexOf( this.id );
@@ -76,10 +81,22 @@ $( function () {
} );
},
editPayment: function () {
editInvoice: function () {
var self = this;
var vm = dbo.editProjectModal;
$.each( vm.payments(), function ( i, p ) {
$.each( vm.invoices(), function ( i, p ) {
if ( p.id == self.id ) {
p.inEdit( !p.inEdit() );
} else {
p.inEdit( false );
}
} );
},
editPayment: function ( parent ) {
var self = this;
$.each( parent.payments(), function ( i, p ) {
console.log( p.invoice_id(), ' ', parent.id );
if ( p.id == self.id ) {
p.inEdit( !p.inEdit() );
} else {
@@ -100,6 +117,18 @@ $( function () {
} );
},
editProjectcosts: function () {
var self = this;
var vm = dbo.editProjectModal;
$.each( vm.projectcosts(), function ( i, p ) {
if ( p.id == self.id ) {
p.inEdit( !p.inEdit() );
} else {
p.inEdit( false );
}
} );
},
newOffer: function () {
var vm = dbo.editProjectModal;
var service = dbo.offersService;
@@ -129,16 +158,17 @@ $( function () {
newPayment: function () {
var vm = dbo.editProjectModal;
var self = this;
console.log( self );
var payment = {
id : 0,
offernumber : '',
invoice_id : self.id,
paymentdate : null,
paymentamount: 0,
inEdit : true
};
vm.payments.push( new vm.Payment( payment ) );
self.payments.push( new vm.Payment( payment ) );
},
newProjecthour: function () {
@@ -241,25 +271,44 @@ $( function () {
}
timeout = setTimeout( function () {
var submitDATA = {
id : self.id,
user_id : self.employeeID(),
tarif : self.tarif() ? self.tarif().toString().replace( ',', '.' ) : 0,
budget : self.budget() ? self.budget().toString().replace( ',', '.' ) : 0,
startdate: self.startdate()
id : self.id,
user_id: self.employeeID(),
tarif : self.tarif() ? self.tarif().toString().replace( ',', '.' ) : 0,
budget : self.budget() ? self.budget().toString().replace( ',', '.' ) : 0
}
dbo.projectDataService.saveProjectemployee( submitDATA );
dbo.projectDataService.saveProjectemployee( submitDATA, function () {
vm.refreshAvailableEmployees();
} );
}, 400 );
},
saveInvoice: function () {
var self = this;
var submitDATA = {
id : self.id,
project_id : self.project_id(),
invoicenumber : self.invoicenumber(),
invoicedate : self.invoicedate(),
invoiceamount : self.invoiceamount(),
forecastamount: self.forecastamount(),
forecastdate : self.forecastdate(),
vat_id : self.vat_id()
};
dbo.projectDataService.saveInvoice( submitDATA, function ( data ) {
if ( data.success ) self.id = data.invoiceID;
} );
},
savePayment: function () {
var self = this;
if ( !self.offer_id() ) return;
var submitDATA = {
id : self.id,
offer_id : self.offer_id(),
invoice_id : self.invoice_id(),
paymentdate : self.paymentdate(),
paymentamount: self.paymentamount()
};
@@ -287,6 +336,24 @@ $( function () {
} );
},
saveProjectcosts: function () {
var vm = dbo.editProjectModal;
var self = this;
var submitDATA = {
id : self.id,
project_id : vm.projectID,
external_id: self.external_id(),
description: self.description(),
date : self.date(),
costs : self.costs()
};
dbo.projectDataService.saveProjectcost( submitDATA, function ( data ) {
if ( data.success ) self.id = data.projectcostID;
} );
},
removeProjectemployee: function () {
var vm = dbo.editProjectModal;
var self = this;
@@ -303,13 +370,7 @@ $( function () {
if ( response ) {
dbo.projectDataService.removeProjectemployee( self.id, function ( data ) {
if ( data.result ) {
tellMe( {
title : 'projectmedewerker verwijderd',
message : 'de projectmedewerker is succesvol verwijderd',
modalClass: 'modal-success'
}, function () {
vm.refreshProject();
} );
vm.refreshProject();
} else {
tellMe( {
title : 'fout bij verwijderen projectmedewerker',
@@ -338,13 +399,7 @@ $( function () {
if ( response ) {
dbo.offerDataService.removeOffer( self.id, function ( data ) {
if ( data.result ) {
tellMe( {
title : 'offerte verwijderd',
message : 'de offerte is succesvol verwijderd',
modalClass: 'modal-success'
}, function () {
vm.refreshProject();
} );
vm.refreshProject();
} else {
tellMe( {
title : 'fout bij verwijderen offerte',
@@ -373,13 +428,7 @@ $( function () {
if ( response ) {
dbo.projectDataService.removePayment( self.id, function ( data ) {
if ( data.result ) {
tellMe( {
title : 'betaling verwijderd',
message : 'de betaling is succesvol verwijderd',
modalClass: 'modal-success'
}, function () {
vm.refreshProject();
} );
vm.refreshProject();
} else {
tellMe( {
title : 'fout bij verwijderen betaling',
@@ -408,13 +457,7 @@ $( function () {
if ( response ) {
dbo.projectDataService.removeProjecthour( self.id, function ( data ) {
if ( data.result ) {
tellMe( {
title : 'projectuur verwijderd',
message : 'de projectuur is succesvol verwijderd',
modalClass: 'modal-success'
}, function () {
vm.refreshProject();
} );
vm.refreshProject();
} else {
tellMe( {
title : 'fout bij verwijderen projectuur',
@@ -436,7 +479,17 @@ $( function () {
},
validateNumber: function ( field ) {
this[field]( dbo.helpers.validateNumber( this[field](), false ) );
this[field]( dbo.helpers.validateNumber( this[field](), true ) );
},
refreshAvailableEmployees: function ( callback ) {
var vm = dbo.editProjectModal;
dbo.projectDataService.getAvailableEmployees( vm.projectID, function ( data ) {
vm.availableEmployees( data );
if ( typeof(callback) == 'function' ) callback();
} );
},
refreshProject: function () {
@@ -479,6 +532,9 @@ $( function () {
} );
vm.busy = false;
dbo.charts.drawHoursVsBudget(340, 230, 'hours-vs-budget');
dbo.charts.drawInvoicesVsPayed(36000, 24000, 11000, 'invoice-vs-payed');
} );
},
@@ -490,12 +546,11 @@ $( function () {
self.fullname = ko.observable( data.user ? data.user.fullname : '#NB' );
self.tarif = ko.observable( data.tarif ? data.tarif.toString().replace( '.', ',' ) : 0 );
self.budget = ko.observable( data.budget ? data.budget.toString().replace( '.', ',' ) : 0 );
self.startdate = ko.observable( dbo.helpers.mysql2date( data.startdate ) );
self.inEdit = ko.observable( sessionStorage.editEmployee == data.id );
},
Projecthour: function ( data, fullname ) {
var inEdit = sessionStorage.editPayment == data.id;
var inEdit = sessionStorage.Projecthour == data.id;
if ( !inEdit ) inEdit = data.inEdit || false;
this.id = data.id;
@@ -526,33 +581,43 @@ $( function () {
self.project_id = ko.observable( data.project_id );
self.invoicenumber = ko.observable( data.invoicenumber );
self.invoicedate = ko.observable( dbo.helpers.mysql2date( data.invoicedate ) );
self.invoiceamount = ko.observable( data.invoiceamount.toFixed(2) );
self.forecastamount = ko.observable( data.forecastamount.toFixed(2) );
self.invoiceamount = ko.observable( data.invoiceamount.toFixed( 2 ) );
self.forecastamount = ko.observable( data.forecastamount.toFixed( 2 ) );
self.forecastdate = ko.observable( dbo.helpers.mysql2date( data.forecastdate ) );
self.vat_id = ko.observable( data.vat_id );
self.inEdit = ko.observable( inEdit );
self.inclBtw = ko.pureComputed( function () {
if ( !self.vat_id() ) return self.invoiceamount();
return (Number( self.invoiceamount() ) + (self.invoiceamount() *
(dbo.helpers.findArrayElement( 'id', 'vatrate', self.vat_id(), this.vats() ) / 100))).toFixed( 2 );
}, dbo.editProjectModal );
self.showPayments = ko.observable( data.showPayments || false );
self.inclBtw = ko.pureComputed(function(){
if( ! self.vat_id() ) return self.invoiceamount();
return (Number(self.invoiceamount()) + (self.invoiceamount() *
(dbo.helpers.findArrayElement('id', 'vatrate', self.vat_id(), this.vats()) /100))).toFixed(2);
}, dbo.editProjectModal)
if ( sessionStorage.showPayment == data.id ) self.showPayments( true );
self.payments = ko.observableArray( [] );
$.each( data.payments, function ( i, p ) {
self.payments.push( new vm.Payment( p, self.invoicenumber ) );
} );
self.outstanding = ko.pureComputed( function () {
var payed = 0
$.each( self.payments(), function ( i, p ) {
payed += Number( p.paymentamount() );
} );
return (self.inclBtw() - payed).toFixed( 2 );
} );
},
Payment: function ( data, invoicenumber = '' ) {
Payment: function ( data ) {
var inEdit = sessionStorage.editPayment == data.id;
if ( !inEdit ) inEdit = data.inEdit || false;
this.id = data.id;
this.invoicenumber = ko.observable( invoicenumber );
this.invoice_id = ko.observable( data.invoice_id );
this.paymentdate = ko.observable( dbo.helpers.mysql2date( data.paymentdate ) );
this.paymentamount = ko.observable( data.paymentamount );
this.inEdit = ko.observable( inEdit );
@@ -560,4 +625,6 @@ $( function () {
};
ko.applyBindings( dbo.editProjectModal, document.getElementById( 'project-modal' ) );
} );
} );
+81
View File
@@ -0,0 +1,81 @@
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 30/01/2018
* Time: 16:03
*/
dbo.charts = {
drawHoursVsBudget : function(hours, budget, element){
var ctx = document.getElementById( element ).getContext( '2d' );
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["uren", "budget"],
datasets: [{
data: [hours, budget],
backgroundColor: [
'#f3a921', '#f2770c'
]
}]
},
options: {
maintainAspectRatio: false,
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
},
legend:{
display : false,
},
title: {
display: true,
text: 'Uren vs budget',
fontSize:16,
fontColor: '#b2b2b2'
}
}
});
},
drawInvoicesVsPayed : function(offer, invoice, payed, element){
var ctx = document.getElementById( element ).getContext( '2d' );
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["offerte", "facturen", "betaald"],
datasets: [{
data: [offer, invoice, payed],
backgroundColor: [
'#f3a921', '#f2770c', '#72221a'
]
}]
},
options: {
maintainAspectRatio: false,
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
},
legend:{
display : false,
},
title: {
display: true,
text: 'offerte vs facuren vs betalingen',
fontSize:16,
fontColor: '#b2b2b2'
}
}
});
}
}
+1 -1
View File
@@ -13,7 +13,7 @@ dbo.offersService = {
newOffer: function (projectID=false, customerID=false) {
var service = dbo.offersService;
dbo.editOfferModal.newEditOffer( false, projectID, customerID, function () {
dbo.editOfferModal.newEditOffer( false, projectID, customerID, true, function () {
service.refreshOffers();
} );
},
+16
View File
File diff suppressed because one or more lines are too long