This commit is contained in:
2017-12-31 10:13:05 +01:00
parent 8ce71a444b
commit 57092eea2b
3 changed files with 71 additions and 100 deletions
@@ -6,7 +6,7 @@
* Time: 10:11
*/
class customersController extends MY_Controller {
class externalsControllerController extends MY_Controller {
public function __construct()
{
@@ -1,99 +0,0 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 25/12/2017
* Time: 10:11
*/
class usersController extends MY_Controller {
public function __construct()
{
parent::__construct();
$models = [];
$libraries = [];
$this->load->model( $models );
$this->load->library( $libraries );
}
public function index()
{
}
public function getAllUsers( $archive = 'F' )
{
$users = User::getAllUsers( $archive );
$this->json( $users );
}
public function saveUser()
{
$userValidation = new UserValidation();
if ( ! $userValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $userValidation->getErrorMessages()] );
$user = $this->input->post();
$userID = $user['id'];
unset( $user['id'] );
if ( $userID == 0 ) $user = $this->newUser( $user );
$user['role'] = empty( $user['role'] ) ? NULL : $user['role'];
$userID = User::saveUser( $userID, $user );
$this->json( ['success' => TRUE, 'userID' => $userID] );
}
public function archiveUser( $userID, $status )
{
User::whereId( $userID )->update( ['archive' => $status] );
}
public function removeUser( $userID )
{
$removeUser = new RemoveUser( $userID );
if ( $removeUser->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
User::removeUser( $userID );
$this->json( ['result' => TRUE] );
}
private function newUser( $user )
{
$userCreation = new UserCreation( $user );
$user = $userCreation->getUser();
$password = $userCreation->getPassword();
$this->sendWelcomeEmail( $user, $password );
return $user;
}
private function sendWelcomeEmail( $user, $password )
{
$this->load->library( 'email' );
$html = $this->load->view( 'emails/welcome_email', [
'password' => $password, 'user' => $user], TRUE );
$this->email->from( 'noreply@debeleidsonderzoekers.nl', 'DBOIS' );
$this->email->to( $user['email'] );
$this->email->subject( 'Wachtwoord DBOIS' );
$this->email->message( $html );
$this->email->send();
}
}
@@ -0,0 +1,70 @@
<div class="container">
<div class="row">
<div class="col-xl-8">
<table class="table table-sm">
<thead>
<tr>
<th class="table-tealish-header">contact</th>
<th class="table-tealish-header">naam</th>
<th class="table-tealish-header">adres</th>
<th class="table-tealish-header">plaats</th>
<th class="table-tealish-header">email</th>
<th class="table-tealish-header">tarief</th>
<th class="table-tealish-header">&nbsp;</th>
</tr>
</thead>
<tbody data-bind="foreach:customers">
<tr>
<td><span data-bind="text:contactperson"</td>
<td><span data-bind="text:name"></span></td>
<td><span data-bind="text:address"></span></td>
<td><span data-bind="text:postcode + ' ' + place"></span></td>
<td><span data-bind="text:email"></span></td>
<td><span data-bind="text:rate"></span></td>
<td>
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editCustomer"></i>
<!-- ko if:archive == 'F' -->
<i class="icon fa-archive pointer" title="archiveer"
data-bind="click:$root.archiveCustomer"></i>
<!-- /ko -->
<!-- ko if:archive != 'F' -->
<i class="icon fa-minus-circle redish pointer" title="archiveer"
data-bind="click:$root.archiveCustomer"></i>
<!-- /ko -->
<i class="icon fa-trash redish pointer" title="verwijder"
data-bind="click:$root.removeCustomer"></i>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4" class="">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newCustomer">
nieuwe opdrachtgever
</button>
</td>
<td colspan="2" class="">
<div class="row form-horizontal">
<label class="col-md-4 form-control-label">archief</label>
<div class="col-md-8">
<div class="onoffswitch" data-bind="click:toggleArchive">
<input type="checkbox"
name="onoffswitch"
class="onoffswitch-checkbox"
data-bind="checked:archive"
id="myonoffswitch">
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</div>
</div>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>