track which admin created new driver accounts, so we know who hired each driver #4092

This commit is contained in:
Pererinha 2015-01-22 13:58:33 -02:00
parent 7aa1952e30
commit e60d212e23
5 changed files with 29 additions and 2 deletions

View File

@ -0,0 +1,4 @@
ALTER TABLE `admin` ADD `id_admin_author` int(11) unsigned DEFAULT NULL;
ALTER TABLE `admin` ADD KEY `admin_ibfk_1` (`id_admin_author`);
ALTER TABLE `admin` ADD CONSTRAINT `admin_ibfk_1` FOREIGN KEY (`id_admin_author`) REFERENCES `admin` (`id_admin`) ON DELETE SET NULL ON UPDATE SET NULL;

View File

@ -32,6 +32,7 @@ class Controller_api_driver_list extends Crunchbutton_Controller_RestAccount {
$list = []; $list = [];
foreach( $drivers as $driver ){ foreach( $drivers as $driver ){
if( $count >= $start && $count < $end ){ if( $count >= $start && $count < $end ){
$data = $driver->exports( [ 'permissions', 'groups' ] ); $data = $driver->exports( [ 'permissions', 'groups' ] );
$data[ 'vehicle' ] = $driver->vehicle(); $data[ 'vehicle' ] = $driver->vehicle();

View File

@ -110,6 +110,13 @@ class Cockpit_Admin extends Crunchbutton_Admin {
$out['referral_admin_credit'] = floatval( $this->referral_admin_credit ); $out['referral_admin_credit'] = floatval( $this->referral_admin_credit );
$out['referral_customer_credit'] = floatval( $this->referral_customer_credit ); $out['referral_customer_credit'] = floatval( $this->referral_customer_credit );
$author = $this->author();
if( $author->id_admin ){
$out['author'] = $author->name;
} else {
$out['author'] = null;
}
if ($this->location()) { if ($this->location()) {
$out['location'] = $this->location()->exports(); $out['location'] = $this->location()->exports();
} }

View File

@ -914,10 +914,21 @@ class Crunchbutton_Admin extends Cana_Table {
return $driver_info; return $driver_info;
} }
public function author(){
if( !$this->_author && $this->id_admin_author ){
$this->_author = Admin::o( $this->id_admin_author );
}
return $this->_author;
}
public function save() { public function save() {
$this->phone = Phone::clean($this->phone); $this->phone = Phone::clean($this->phone);
$this->txt = Phone::clean($this->txt); $this->txt = Phone::clean($this->txt);
$this->testphone = Phone::clean($this->testphone); $this->testphone = Phone::clean($this->testphone);
// if it is a new record saves the author
if( !$this->id_admin && c::admin()->id_admin ){
$this->id_admin_author = c::admin()->id_admin;
}
return parent::save(); return parent::save();
} }

View File

@ -26,6 +26,7 @@
<th>Login</th> <th>Login</th>
<th>Vehicle</th> <th>Vehicle</th>
<th>Community</th> <th>Community</th>
<th>Created by</th>
<th></th> <th></th>
</tr> </tr>
<tr ng-repeat="driver in drivers" ng-attr-tabindex="{{$index+1}}" tab-select="/drivers/onboarding/{{driver.id_admin}}"> <tr ng-repeat="driver in drivers" ng-attr-tabindex="{{$index+1}}" tab-select="/drivers/onboarding/{{driver.id_admin}}">
@ -43,6 +44,9 @@
{{community}} {{community}}
</span> </span>
</td> </td>
<td>
{{driver.author}}
</td>
<td> <td>
<span ng-if="driver.sent_all_docs" class="sp-label sp-label-success"> <span ng-if="driver.sent_all_docs" class="sp-label sp-label-success">
Docs ok Docs ok