Removalls and offers revenues

This commit is contained in:
2018-06-10 17:31:05 +02:00
parent 8fe98e6ccb
commit c539d03fb6
20 changed files with 449 additions and 158 deletions
@@ -63,7 +63,7 @@ class OffersController extends MY_Controller {
{
$removeOffer = new RemoveOffer( $offerID );
if ( $removeOffer->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
if ( $removeOffer->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] );
Offer::removeOffer( $offerID );
@@ -256,28 +256,39 @@ class ProjectsController extends MY_Controller {
Project::whereId( $projectID )->update( ['archive' => $status] );
}
public function removeProject( $projectID )
{
$removeProject = new RemoveProject( $projectID );
if ( $removeProject->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
Project::removeProject( $projectID );
$this->json( ['result' => TRUE] );
}
public function removeProjectemployee( $projectemployeeID )
{
$removeProjectemployee = new RemoveProjectemployee( $projectemployeeID );
if ( $removeProjectemployee->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
if ( $removeProjectemployee->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] );
Projectemployee::removeProjectemployee( $projectemployeeID );
$this->json( ['result' => TRUE] );
}
public function removeInvoice( $invoiceID )
{
$removeInvoice = new RemoveInvoice( $invoiceID );
if ( $removeInvoice->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] );
Invoice::whereId( $invoiceID )->delete();
return $this->json( ['result' => TRUE] );
}
public function removeIncomingInvoice( $invoiceID )
{
// $removeInvoice = new RemoveInvoice( $invoiceID );
//
// if ( $removeInvoice->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] );
Projectcost::whereId( $invoiceID )->delete();
return $this->json( ['result' => TRUE] );
}
public function removePayment( $paymentID )
{
$removePayment = new RemovePayment( $paymentID );
@@ -322,4 +333,15 @@ class ProjectsController extends MY_Controller {
$this->json( ['result' => TRUE] );
}
public function removeProject( $projectID )
{
$removeProject = new RemoveProject( $projectID );
if ( $removeProject->getRemoveAllowed() === FALSE ) return $this->json( ['result' => FALSE] );
Project::removeProject( $projectID );
$this->json( ['result' => TRUE] );
}
}
@@ -0,0 +1,53 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 10/06/2018
* Time: 17:06
*/
class RemoveInvoice {
private $invoiceID;
private $payments;
private $removeAllowed;
public function __construct( $invoiceID )
{
$this->setInvoiceID( $invoiceID );
$this->handle();
}
public function getRemoveAllowed()
{
return $this->removeAllowed;
}
private function setInvoiceID( $invoiceID )
{
$this->invoiceID = $invoiceID;
}
private function handle()
{
$this->setPayment();
$this->setRemoveAllowed();
}
private function setPayment()
{
$payments = Payment::whereInvoiceId( $this->invoiceID );
$this->payments = $payments->count() == 0 ? TRUE : FALSE;
}
private function setRemoveAllowed()
{
if ( $this->payments === FALSE ) return $this->removeAllowed = FALSE;
$this->removeAllowed = TRUE;
}
}
@@ -0,0 +1,46 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 10/06/2018
* Time: 15:56
*/
class RemoveInvoices {
private $invoiceID;
private $payments;
private $removeAllowed;
public function __construct( $invoiceID )
{
$this->setInvoiceID($invoiceID);
$this->handle();
}
private function setInvoiceID( $invoiceID )
{
$this->invoiceID = $invoiceID;
}
private function handle()
{
$this->setPayments();
$this->setRemoveAllowed();
}
private function setPayments()
{
$payments = Payment::whereInvoiceId($this->invoiceID);
$this->payments = $payments->count() == 0 ? TRUE : FALSE;
}
private function setRemoveAllowed()
{
$this->removeAllowed = $this->payments;
}
}
@@ -0,0 +1,52 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 10/06/2018
* Time: 16:28
*/
class RemoveOffer {
private $offerID;
private $project;
private $removeAllowed;
public function __construct($offerID)
{
$this->setOfferID($offerID);
$this->handle();
}
public function getRemoveAllowed()
{
return $this->removeAllowed;
}
private function setOfferID( $offerID )
{
$this->offerID = $offerID;
}
private function handle()
{
$this->setProject();
$this->setRemoveAllowed();
}
private function setProject()
{
$offer = Offer::Find($this->offerID);
$this->project = is_null($offer->project_id) ? TRUE : FALSE;
}
private function setRemoveAllowed()
{
if( $this->project === FALSE ) return $this->removeAllowed = FALSE;
$this->removeAllowed = TRUE;
}
}
@@ -0,0 +1,97 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 10/06/2018
* Time: 15:53
*/
class RemoveProject {
private $projectID;
private $forecast;
private $invoices;
private $projectemployees;
private $reservations;
private $removeAllowed;
private $projectcosts;
public function __construct( $projectID )
{
$this->setProjectID( $projectID );
$this->handle();
}
public function getRemoveAllowed()
{
return $this->removeAllowed;
}
private function setProjectID( $projectID )
{
$this->projectID = $projectID;
}
private function handle()
{
$this->setForecast();
$this->setInvoices();
$this->setProjectemployees();
$this->setReservations();
$this->setRemoveAllowed();
$this->setProjectCosts();
}
private function setForecast()
{
$forecast = Forecast::whereProjectId( $this->projectID );
$this->forecast = $forecast->count() == 0 ? TRUE : FALSE;
}
private function setInvoices()
{
$invoices = Invoice::whereProjectId( $this->projectID );
$this->invoices = $invoices->count() == 0 ? TRUE : FALSE;
}
private function setProjectemployees( )
{
$setProjectemployees = Projectemployee::whereProjectId($this->projectID);
$this->projectemployees = $setProjectemployees->count() == 0 ? TRUE : FALSE;
}
private function setReservations( )
{
$reservations = Reservation::whereProjectId($this->projectID);
$this->reservations = $reservations->count() == 0 ? TRUE : FALSE;
}
private function setProjectcosts( )
{
$projectcosts = Projectcost::whereProjectId($this->projectID);
$this->projectcosts = $projectcosts->count() == 0 ? TRUE : FALSE;
}
private function setRemoveAllowed()
{
if( $this->forecast === false ) return $this->removeAllowed = FALSE;
if( $this->invoices === false ) return $this->removeAllowed = FALSE;
if( $this->projectemployees === false ) return $this->removeAllowed = FALSE;
if( $this->reservations === false ) return $this->removeAllowed = FALSE;
if( $this->projectcosts === false ) return $this->removeAllowed = FALSE;
$this->removeAllowed = TRUE;
}
}
@@ -0,0 +1,53 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 27/12/2017
* Time: 17:45
*/
class RemoveProjectemployee {
private $projectemployeeID;
private $removeAllowed;
private $projecthours;
public function __construct( $projectemployeeID )
{
$this->setProjectemployeeID( $projectemployeeID );
$this->handle();
}
public function getRemoveAllowed()
{
return $this->removeAllowed;
}
private function setProjectemployeeID( $projectemployeeID )
{
$this->projectemployeeID = $projectemployeeID;
}
private function handle()
{
$this->setProjectHours();
$this->setRemoveAllowed();
}
private function setProjecthours()
{
$projecthours = Projecthour::whereProjectemployeeId($this->projectemployeeID);
$this->projecthours = $projecthours->count() == 0 ?TRUE : FALSE;
}
private function setRemoveAllowed()
{
if( $this->projecthours === false ) return $this->removeAllowed = FALSE;
$this->removeAllowed = TRUE;
}
}
@@ -1,43 +0,0 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 27/12/2017
* Time: 17:45
*/
class RemoveProject {
private $projectID;
private $allowDelete = TRUE;
public function __construct( $projectID )
{
$this->setProjectID( $projectID );
$this->handle();
}
public function getAllowDelete()
{
return $this->allowDelete;
}
private function setProjectID( $projectID )
{
$this->projectID = $projectID;
}
private function handle()
{
$this->checkForOffers();
}
private function checkForOffers()
{
$offers = Offer::whereProjectId($this->projectID);
if( $offers->count() > 0 ) $this->allowDelete = FALSE;
}
}
@@ -1,36 +0,0 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 27/12/2017
* Time: 17:45
*/
class RemoveProjectemployee {
private $projectemployeeID;
private $allowDelete = TRUE;
public function __construct( $projectemployeeID )
{
$this->setProjectemployeeID( $projectemployeeID );
$this->handle();
}
public function getAllowDelete()
{
return $this->allowDelete;
}
private function setProjectemployeeID( $projectemployeeID )
{
$this->projectemployeeID = $projectemployeeID;
}
private function handle()
{
}
}
@@ -1,36 +0,0 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 27/12/2017
* Time: 17:45
*/
class RemoveOffer {
private $offerID;
private $allowDelete = TRUE;
public function __construct( $userID )
{
$this->setOfferID( $userID );
$this->handle();
}
public function getAllowDelete()
{
return $this->allowDelete;
}
private function setOfferID( $customerID )
{
$this->offerID = $customerID;
}
private function handle()
{
}
}
+2
View File
@@ -80,6 +80,8 @@ class Project extends BaseModel {
public static function removeProject( $projectID )
{
Offer::whereProjectId( $projectID )->update( ['project_id' => NULL] );
Project::whereId( $projectID )->delete();
}
@@ -14,7 +14,7 @@ class Qinvoiceoverview {
$sql = "
SELECT PRJ.id, PRJ.projectnumber,
PRJ.projectname,
(own_revenue + other_revenue ) AS revenues,
(own_revenue + other_revenue + OFF.costs ) AS revenues,
CUS.name AS customername,
SUM(IF( YEAR(invoicedate) = {$year}, invoiceamount* ((100 + VTS.vatrate)/100), 0)) AS currentyear,
SUM(IF( YEAR(invoicedate) != {$year}, invoiceamount * ((100 + VTS.vatrate)/100), 0)) AS otheryear,
@@ -27,7 +27,7 @@ class Invoices_model extends MY_Model {
public function getOutstandingPerProject( $projectID )
{
$this->sql = "
SELECT (own_revenue + other_revenue) AS totalrevenue,
SELECT (own_revenue + other_revenue + OFF.costs) AS totalrevenue,
ROUND(SUM(INV.invoiceamount * ((100 + vatrate) / 100)), 0) AS totalinvoiced,
(
SELECT SUM(paymentamount) PAYMENTAMOUNT
@@ -94,7 +94,7 @@
<td>
<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>
data-bind="click:$root.removeProjectcosts"></i>
</td>
</tr>
</tbody>
@@ -117,6 +117,13 @@
</h4>
</div>
<div class="divider"></div>
<label class="col-md-6 col-form-label">kosten(excl.btw)</label>
<div class="col-md-6">
<h4 class="form-control-label">
<i class="icon fa-euro"> </i><span class="euro-amount" data-bind="text:costs"></span>
</h4>
</div>
<div class="divider"></div>
<label class="col-md-6 col-form-label">Totaal omzet(excl.btw)</label>
<div class="col-md-6">
<h4><i class="icon fa-euro"> </i><span class="euro-amount" data-bind="text:totalRevenues"></span></h4>