parent
010f297a5a
commit
c5ec5b216f
@ -48,6 +48,11 @@ class Controller_api_driver_documents extends Crunchbutton_Controller_RestAccoun
|
||||
if( !$docStatus->id_driver_document_status ){
|
||||
$docStatus->id_admin = $id_admin;
|
||||
$docStatus->id_driver_document = $id_driver_document;
|
||||
} else {
|
||||
$oldFile = Crunchbutton_Driver_Document_Status::path() . $docStatus->file;
|
||||
if( file_exists( $oldFile ) ){
|
||||
@unlink( $oldFile );
|
||||
}
|
||||
}
|
||||
// todo: delete old doc
|
||||
$docStatus->datetime = date('Y-m-d H:i:s');
|
||||
|
||||
@ -163,11 +163,14 @@ class Crunchbutton_Admin extends Cana_Table {
|
||||
}
|
||||
|
||||
public function communitiesHeDeliveriesFor(){
|
||||
|
||||
$deliveryFor = [];
|
||||
$communities = Crunchbutton_Community::q( 'SELECT * FROM community ORDER BY name ASC' );
|
||||
foreach( $communities as $community ){
|
||||
if( $community->driverDeliveryHere( $this->id_admin ) ){
|
||||
$deliveryFor[] = $community;
|
||||
if( $this->id_admin ){
|
||||
$communities = Crunchbutton_Community::q( 'SELECT * FROM community ORDER BY name ASC' );
|
||||
foreach( $communities as $community ){
|
||||
if( $community->driverDeliveryHere( $this->id_admin ) ){
|
||||
$deliveryFor[] = $community;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $deliveryFor;
|
||||
|
||||
@ -81,7 +81,7 @@
|
||||
<li>
|
||||
<label for="driverDocument">
|
||||
<div class="label">Select the file type:</div>
|
||||
<select name="driverDocument" ng-model="doc_uploaded" ng-options="opt.id_driver_document as opt.name for opt in documents"></select>
|
||||
<select name="driverDocument" ng-model="doc_uploaded" ng-change="setDocument( this.doc_uploaded )" ng-options="opt.id_driver_document as opt.name for opt in documents"></select>
|
||||
</label>
|
||||
</li>
|
||||
<li ng-show="uploader.progress">
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
<div class="top-pad"></div>
|
||||
|
||||
<div class="content-padding" ng-show="ready">
|
||||
<div class="content">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -114,6 +114,11 @@ NGApp.config(['$routeProvider', '$locationProvider', function($routeProvider, $l
|
||||
controller: 'DriversOnboardingFormCtrl',
|
||||
templateUrl: 'assets/view/drivers-onboarding-form.html'
|
||||
})
|
||||
.when('/setup/:phone', {
|
||||
action: 'drivers-setup',
|
||||
controller: 'DriversOnboardingSetupCtrl',
|
||||
templateUrl: 'assets/view/drivers-onboarding-setup.html'
|
||||
})
|
||||
.otherwise({
|
||||
action: 'home',
|
||||
controller: 'DefaultCtrl',
|
||||
@ -265,10 +270,18 @@ NGApp.controller('AppController', function ($scope, $route, $http, $routeParams,
|
||||
/* todo: check user's permission too */
|
||||
NGApp.run( function ( $rootScope, $location, MainNavigationService ) {
|
||||
$rootScope.$on( '$routeChangeStart', function ( event, next, current ) {
|
||||
if ( $location.url() != '/login' && !$rootScope.account.isLoggedIn() ) {
|
||||
MainNavigationService.link( '/login' );
|
||||
if( !$rootScope.account.isLoggedIn() ){
|
||||
var isAllowed = false;
|
||||
angular.forEach( [ '/login', '/setup' ], function( allowed ){
|
||||
if( $location.url().indexOf( allowed ) >= 0 ){
|
||||
isAllowed = true;
|
||||
}
|
||||
} );
|
||||
if( !isAllowed ) {
|
||||
MainNavigationService.link( '/login' );
|
||||
}
|
||||
}
|
||||
if ( $location.url() == '/login' && $rootScope.account.isLoggedIn() ) {
|
||||
if( $location.url() == '/login' && $rootScope.account.isLoggedIn() ) {
|
||||
MainNavigationService.link( '/' );
|
||||
}
|
||||
});
|
||||
|
||||
@ -256,7 +256,6 @@ NGApp.controller( 'DriversOnboardingFormCtrl', function ( $scope, $fileUploader,
|
||||
// Upload control stuff
|
||||
$scope.doc_uploaded = 0;
|
||||
|
||||
|
||||
var uploader = $scope.uploader = $fileUploader.create({
|
||||
scope: $scope,
|
||||
url: '/api/driver/documents/upload/',
|
||||
@ -264,16 +263,20 @@ NGApp.controller( 'DriversOnboardingFormCtrl', function ( $scope, $fileUploader,
|
||||
} );
|
||||
|
||||
uploader.bind( 'success', function( event, xhr, item, response ) {
|
||||
$scope.$apply();
|
||||
if( response.success ){
|
||||
var doc = { id_admin : $scope.driver.id_admin, id_driver_document : $scope.doc_uploaded, file : response.success };
|
||||
DriverOnboardingService.docs.save( doc, function(){
|
||||
docs();
|
||||
$scope.flash.setMessage( 'File saved!' );
|
||||
DriverOnboardingService.docs.save( doc, function( json ){
|
||||
if( json.success ){
|
||||
docs();
|
||||
$scope.flash.setMessage( 'File saved!' );
|
||||
} else {
|
||||
$scope.flash.setMessage( 'File not saved: ' + json.error );
|
||||
}
|
||||
} );
|
||||
$scope.doc_uploaded = 0;
|
||||
uploader.clearQueue();
|
||||
} else {
|
||||
App.alert( 'Upload error: ' + response.error );
|
||||
$scope.flash.setMessage( 'File not saved: ' + json.error );
|
||||
}
|
||||
});
|
||||
|
||||
@ -282,3 +285,7 @@ NGApp.controller( 'DriversOnboardingFormCtrl', function ( $scope, $fileUploader,
|
||||
});
|
||||
|
||||
} );
|
||||
|
||||
NGApp.controller('DriversOnboardingSetupCtrl', function($scope) {
|
||||
console.log('setup');
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user