Diversen nav mail Peter
This commit is contained in:
@@ -44,4 +44,17 @@ class vatController extends MY_Controller {
|
||||
$vatrate = $this->input->post( 'vatrate' );
|
||||
Vat::whereId( $vatID )->update( ['vatrate' => $vatrate] );
|
||||
}
|
||||
|
||||
public function removeVat( $vatID )
|
||||
{
|
||||
$removeVat = new RemoveVat($vatID);
|
||||
|
||||
$allowRemove = $removeVat->getRemoveAllowed();
|
||||
|
||||
if( $allowRemove === FALSE ) return $this->json( ['result'=>FALSE]);
|
||||
|
||||
Vat::whereId($vatID)->delete();
|
||||
|
||||
$this->json( ['result'=>TRUE]);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class MY_Controller extends CI_Controller {
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->version = '0.02.00';
|
||||
$this->version = '0.02.01';
|
||||
|
||||
$this->load->library( 'beheer/session/RetrieveUserSession' );
|
||||
|
||||
@@ -25,11 +25,25 @@ class MY_Controller extends CI_Controller {
|
||||
|
||||
private function handle()
|
||||
{
|
||||
$this->setSecureSite();
|
||||
|
||||
$this->retrieveusersession->handle();
|
||||
|
||||
$this->user = $this->User_model->get( USERID );
|
||||
}
|
||||
|
||||
public function setSecureSite()
|
||||
{
|
||||
if ( getenv( 'ENVIRONMENT' ) != 'production' ) return;
|
||||
|
||||
if ( ! isset( $_SERVER["HTTPS"] ) || $_SERVER["HTTPS"] != "on" )
|
||||
{
|
||||
header( "Location: " . getenv( 'APP_URL' ) );
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function clean_input( $post )
|
||||
{
|
||||
$value = $this->input->input_stream( $post, TRUE );
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/06/2018
|
||||
* Time: 17:06
|
||||
*/
|
||||
|
||||
class RemoveVat {
|
||||
|
||||
private $vatID;
|
||||
private $projects;
|
||||
private $invoices;
|
||||
private $removeAllowed;
|
||||
|
||||
public function __construct( $vatID )
|
||||
{
|
||||
$this->setVatID( $vatID );
|
||||
|
||||
$this->handle();
|
||||
}
|
||||
|
||||
public function getRemoveAllowed()
|
||||
{
|
||||
return $this->removeAllowed;
|
||||
}
|
||||
|
||||
private function setVatID( $vatID )
|
||||
{
|
||||
$this->vatID = $vatID;
|
||||
}
|
||||
|
||||
private function handle()
|
||||
{
|
||||
$this->setProject();
|
||||
|
||||
$this->setInvoices();
|
||||
|
||||
$this->setRemoveAllowed();
|
||||
}
|
||||
|
||||
private function setProject()
|
||||
{
|
||||
$projects = Project::whereVatId( $this->vatID );
|
||||
|
||||
$this->projects = $projects->count() == 0 ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
private function setInvoices()
|
||||
{
|
||||
$invoices = Invoice::whereVatId( $this->vatID );
|
||||
|
||||
$this->invoices = $invoices->count() == 0 ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
private function setRemoveAllowed()
|
||||
{
|
||||
if ( $this->projects === FALSE ) return $this->removeAllowed = FALSE;
|
||||
|
||||
if ( $this->invoices === FALSE ) return $this->removeAllowed = FALSE;
|
||||
|
||||
$this->removeAllowed = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,16 +12,20 @@
|
||||
<tr>
|
||||
<td>
|
||||
<div class="percentage-sign-holder">
|
||||
<!-- ko if:inEdit() -->
|
||||
<input type="text"
|
||||
class="form-control percentage-input"
|
||||
data-bind="textInput:vatrate,
|
||||
event:{keyup:$root.validateNumber.bind($data, 'vatrate')}">
|
||||
<span class="percentage-sign">%</span>
|
||||
<!-- /ko -->
|
||||
<!-- ko if: !inEdit() -->
|
||||
<span data-bind="text:vatrate"></span>%
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
</td>
|
||||
<td width="60px">
|
||||
<i class="icon fa-edit" data-bind="click:$root.toggleEdit"></i>
|
||||
<i class="icon fa-trash redish" data-bind="$root.removeVat"></i>
|
||||
<i class="icon fa-edit pointer" data-bind="click:$root.toggleEdit"></i>
|
||||
<i class="icon fa-trash redish pointer" data-bind="click:$root.removeVat"></i>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user