Driver Settlement - #3232
This commit is contained in:
parent
90f49a44b9
commit
170f318daf
@ -4,30 +4,12 @@ class Controller_Api_Settlement extends Crunchbutton_Controller_RestAccount {
|
||||
|
||||
public function init() {
|
||||
|
||||
$this->resultsPerPage = 20;
|
||||
|
||||
// $this->_driverPayments();
|
||||
// exit;
|
||||
|
||||
// $this->_driverDoPayment();
|
||||
// exit;
|
||||
|
||||
// $this->_driverBegin();
|
||||
// exit;
|
||||
|
||||
// $set = new Settlement;
|
||||
|
||||
// echo json_encode( $set->driversProcessOrders( [ $set->orderExtractVariables( Order::o( c::getPagePiece( 2 ) ) ) ] ) );exit();;
|
||||
|
||||
// $set->scheduleDriverPayment( [], Crunchbutton_Payment::PAY_TYPE_PAYMENT );
|
||||
// $set->scheduleDriverPayment( [], Crunchbutton_Payment::PAY_TYPE_REIMBURSEMENT );
|
||||
|
||||
// exit;
|
||||
|
||||
if( !c::admin()->permission()->check( ['global', 'settlement' ] ) ){
|
||||
$this->_error();
|
||||
}
|
||||
|
||||
$this->resultsPerPage = 20;
|
||||
|
||||
switch ($this->method()) {
|
||||
case 'get':
|
||||
switch ( c::getPagePiece( 2 ) ) {
|
||||
@ -127,6 +109,12 @@ class Controller_Api_Settlement extends Crunchbutton_Controller_RestAccount {
|
||||
case 'payment':
|
||||
$this->_driverPayment();
|
||||
break;
|
||||
case 'view-summary':
|
||||
$this->_driverViewSummary();
|
||||
break;
|
||||
case 'send-summary':
|
||||
$this->_driverSendSummary();
|
||||
break;
|
||||
default:
|
||||
$this->_error();
|
||||
break;
|
||||
@ -339,9 +327,9 @@ class Controller_Api_Settlement extends Crunchbutton_Controller_RestAccount {
|
||||
}
|
||||
|
||||
private function _restaurantSendSummary(){
|
||||
$id_payment_schedule = c::getPagePiece( 4 );
|
||||
$id_payment = c::getPagePiece( 4 );
|
||||
$settlement = new Settlement;
|
||||
if( $settlement->sendRestaurantPaymentNotification( $id_payment_schedule ) ){
|
||||
if( $settlement->sendRestaurantPaymentNotification( $id_payment ) ){
|
||||
echo json_encode( [ 'success' => true ] );
|
||||
} else {
|
||||
echo json_encode( [ 'error' => true ] );
|
||||
@ -600,6 +588,25 @@ class Controller_Api_Settlement extends Crunchbutton_Controller_RestAccount {
|
||||
}
|
||||
}
|
||||
|
||||
private function _driverSendSummary(){
|
||||
$id_payment = c::getPagePiece( 4 );
|
||||
$settlement = new Settlement;
|
||||
if( $settlement->sendDriverPaymentNotification( $id_payment ) ){
|
||||
echo json_encode( [ 'success' => true ] );
|
||||
} else {
|
||||
echo json_encode( [ 'error' => true ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function _driverViewSummary(){
|
||||
$id_payment = c::getPagePiece( 4 );
|
||||
$settlement = new Crunchbutton_Settlement;
|
||||
$summary = $settlement->driverSummaryByIdPayment( $id_payment );
|
||||
$mail = new Crunchbutton_Email_Payment_Summary( [ 'summary' => $summary ] );
|
||||
echo $mail->message();
|
||||
}
|
||||
|
||||
private function _range(){
|
||||
$now = new DateTime( 'now', new DateTimeZone( c::config()->timezone ) );
|
||||
$range = [ 'end' => $now->format( 'Y,m,d' ) ];
|
||||
|
||||
@ -16,8 +16,11 @@ class Crunchbutton_Email_Payment_Summary extends Crunchbutton_Email {
|
||||
$this->view()->subject = $params[ 'summary' ]['notes'];
|
||||
$this->view()->email = $params[ 'summary' ]['summary_email'];
|
||||
|
||||
$params['messageHtml'] = $this->view()->render( 'payment/summary',[ 'display' => true, 'set' => [ 'summary' => $params['summary'] ] ] );
|
||||
|
||||
if( $params[ 'summary' ][ 'type' ] == Cockpit_Payment_Schedule::TYPE_DRIVER ){
|
||||
$params['messageHtml'] = $this->view()->render( 'payment/summary-driver',[ 'display' => true, 'set' => [ 'summary' => $params['summary'] ] ] );
|
||||
} else {
|
||||
$params['messageHtml'] = $this->view()->render( 'payment/summary-restaurant',[ 'display' => true, 'set' => [ 'summary' => $params['summary'] ] ] );
|
||||
}
|
||||
parent::__construct($params);
|
||||
}
|
||||
}
|
||||
|
||||
@ -483,7 +483,7 @@ class Crunchbutton_Settlement extends Cana_Model {
|
||||
$schedule->date = date( 'Y-m-d H:i:s' );
|
||||
$schedule->amount = max( $payment_data[ 'total_due' ], 0 );
|
||||
$schedule->adjustment = $adjustment;
|
||||
$schedule->pay_type = Cockpit_Payment_Schedule::PAYMENT_TYPE_PAYMENT;
|
||||
$schedule->pay_type = Cockpit_Payment_Schedule::PAY_TYPE_PAYMENT;
|
||||
$schedule->type = Cockpit_Payment_Schedule::TYPE_RESTAURANT;
|
||||
$schedule->status = Cockpit_Payment_Schedule::STATUS_SCHEDULED;
|
||||
$schedule->note = $notes;
|
||||
@ -632,6 +632,7 @@ class Crunchbutton_Settlement extends Cana_Model {
|
||||
$summary[ 'summary_email' ] = $schedule->restaurant()->payment_type()->summary_email;
|
||||
$summary[ 'summary_fax' ] = $schedule->restaurant()->payment_type()->summary_fax;
|
||||
$summary[ 'payment_method' ] = $schedule->restaurant()->payment_type()->payment_method;
|
||||
$summary[ 'type' ] = Cockpit_Payment_Schedule::TYPE_RESTAURANT;
|
||||
$payment = $schedule->payment();
|
||||
if( $payment->id_payment ){
|
||||
$summary[ 'balanced_id' ] = $payment->balanced_id;
|
||||
@ -972,7 +973,7 @@ class Crunchbutton_Settlement extends Cana_Model {
|
||||
$payment_order_transaction->save();
|
||||
}
|
||||
|
||||
// $this->sendDriverPaymentNotification( $payment->id_payment );
|
||||
$this->sendDriverPaymentNotification( $payment->id_payment );
|
||||
return true;
|
||||
} else {
|
||||
$message = 'Driver Payment error! Driver: ' . $schedule->driver()->name;
|
||||
@ -1022,11 +1023,10 @@ class Crunchbutton_Settlement extends Cana_Model {
|
||||
$settlement = new Settlement;
|
||||
$summary = $schedule->exports();
|
||||
$summary[ 'driver' ] = $schedule->driver()->name;
|
||||
$summary[ 'summary_method' ] = $schedule->driver()->payment_type()->summary_method;
|
||||
$summary[ 'summary_email' ] = $schedule->driver()->payment_type()->summary_email;
|
||||
$summary[ 'summary_fax' ] = $schedule->driver()->payment_type()->summary_fax;
|
||||
$summary[ 'driver' ] = $schedule->driver()->name;
|
||||
$summary[ 'payment_method' ] = $schedule->driver()->payment_type()->payment_method;
|
||||
$summary[ 'type' ] = Cockpit_Payment_Schedule::TYPE_DRIVER;
|
||||
$payment = $schedule->payment();
|
||||
if( $payment->id_payment ){
|
||||
$summary[ 'balanced_id' ] = $payment->balanced_id;
|
||||
@ -1055,6 +1055,8 @@ class Crunchbutton_Settlement extends Cana_Model {
|
||||
'total' => $variables[ 'final_price_plus_delivery_markup' ],
|
||||
'date' => $variables[ 'short_date' ],
|
||||
'tip' => $variables[ 'tip' ],
|
||||
'restaurant' => $variables[ 'restaurant' ],
|
||||
'delivery_fee' => $variables[ 'delivery_fee' ],
|
||||
'pay_type' => $type,
|
||||
'total_reimburse' => $pay_info[ 0 ][ 'total_reimburse' ],
|
||||
'total_payment' => $pay_info[ 0 ][ 'total_payment' ]
|
||||
@ -1133,6 +1135,33 @@ class Crunchbutton_Settlement extends Cana_Model {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function sendDriverPaymentNotification( $id_payment ){
|
||||
|
||||
$summary = $this->driverSummaryByIdPayment( $id_payment );
|
||||
|
||||
if( !$summary ){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->log( 'sendDriverPaymentNotification', $summary );
|
||||
|
||||
$env = c::getEnv();
|
||||
|
||||
$mail = ( $env == 'live' ? $summary[ 'summary_email' ] : Crunchbutton_Settlement::TEST_SUMMARY_EMAIL );
|
||||
$fax = ( $env == 'live' ? $summary[ 'summary_fax' ] : Crunchbutton_Settlement::TEST_SUMMARY_FAX );
|
||||
|
||||
$mail = new Crunchbutton_Email_Payment_Summary( [ 'summary' => $summary ] );
|
||||
|
||||
if ( $mail->send() ) {
|
||||
$payment = Crunchbutton_Payment::o( $id_payment );
|
||||
$payment->summary_sent_date = date('Y-m-d H:i:s');
|
||||
$payment->save();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function log( $method, $message ){
|
||||
Log::debug( [ 'method' => $method, 'id_admin' => c::user()->id_admin, 'message' => $message, 'env' => c::getEnv(), 'type' => 'settlement' ] );
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@
|
||||
<table class="tb-grid tb-zebra">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="7" class="title">Orders</td>
|
||||
<td colspan="8" class="title">Orders</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<thead ng-if="!result.orders">
|
||||
@ -146,16 +146,22 @@
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</td>
|
||||
</thead>
|
||||
<thead ng-if="result.orders">
|
||||
<tr>
|
||||
<td>#</td>
|
||||
<td class="td-medium">Curstomer name</td>
|
||||
<td>Curstomer name</td>
|
||||
<td>Restaurant</td>
|
||||
<td>Date</td>
|
||||
<td>Total</td>
|
||||
<td>Tip</td>
|
||||
<td>Type</td>
|
||||
<td>
|
||||
<span ng-if="pay_type_payment">Tip</span>
|
||||
</td>
|
||||
<td>
|
||||
<span ng-if="pay_type_payment">Delivery Fee</span>
|
||||
</td>
|
||||
<td ng-if="pay_type_reimbursement">Reimbursement</td>
|
||||
<td ng-if="pay_type_payment">Payment</td>
|
||||
</tr>
|
||||
@ -164,10 +170,11 @@
|
||||
<tr ng-repeat="order in result.orders.included">
|
||||
<td>{{order.id_order}}</td>
|
||||
<td>{{order.name}}</td>
|
||||
<td>{{order.restaurant}}</td>
|
||||
<td>{{order.date}}</td>
|
||||
<td>$ {{order.tip | formatPrice}}</td>
|
||||
<td>$ {{order.total | formatPrice}}</td>
|
||||
<td>{{order.pay_type}}</td>
|
||||
<td><span ng-if="pay_type_payment">$ {{order.delivery_fee | formatPrice}}</span></td>
|
||||
<td><span ng-if="pay_type_payment">$ {{order.tip | formatPrice}}</span></td>
|
||||
<td ng-if="pay_type_reimbursement">$ {{order.total_reimburse | formatPrice}}</td>
|
||||
<td ng-if="pay_type_payment">$ {{order.total_payment | formatPrice}}</td>
|
||||
</tr>
|
||||
@ -181,8 +188,10 @@
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="transparent">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>Tips by Card</td>
|
||||
<td>$ {{result.calcs.tip | formatPrice}}</td>
|
||||
@ -191,16 +200,8 @@
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="transparent">
|
||||
<td></td>
|
||||
<td>Visa/Mastercard/Amex Charges</td>
|
||||
<td>$ {{result.calcs.credit_charge | formatPrice}}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="transparent" ng-if="result.adjustment">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>Adjustment</td>
|
||||
<td>$ {{result.adjustment | formatPrice}}</td>
|
||||
@ -210,6 +211,7 @@
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="transparent" ng-if="pay_type_reimbursement">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><strong>Total Reimburse</strong></td>
|
||||
<td><strong>$ {{result.calcs.total_reimburse | formatPrice}}</strong></td>
|
||||
@ -219,6 +221,27 @@
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="transparent" ng-if="pay_type_payment">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>Total Delivery Fee</td>
|
||||
<td>$ {{result.calcs.delivery_fee | formatPrice}}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="transparent" ng-if="pay_type_payment">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><strong>Markup</strong></td>
|
||||
<td><strong>$ {{result.calcs.markup | formatPrice}}</strong></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="transparent" ng-if="pay_type_payment">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><strong>Total Payment</strong></td>
|
||||
<td><strong>$ {{result.calcs.total_payment | formatPrice}}</strong></td>
|
||||
@ -227,15 +250,7 @@
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="transparent">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="transparent"><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
126
include/views/mail/crunchbutton/payment/summary-driver.phtml
Normal file
126
include/views/mail/crunchbutton/payment/summary-driver.phtml
Normal file
@ -0,0 +1,126 @@
|
||||
<div class="xhatch separator-big"></div>
|
||||
|
||||
<table width="100%" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td style="border: 0; padding: 5px;">
|
||||
<h1>Crunchbutton</h1>
|
||||
</td>
|
||||
<td style="border: 0; padding: 5px; text-align: right;">
|
||||
<span class="order-num">Payment #<?php echo $summary[ 'id_payment' ]; ?></span><br />
|
||||
<?php echo $summary[ 'driver' ]; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="xhatch separator-small"></div>
|
||||
|
||||
<table width="100%" celpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td>
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td style="font-size:22px;" class="text-size-mid"><strong><?php echo $summary[ 'driver' ]; ?></strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php if( $summary[ 'note' ] ) { ?>
|
||||
<table class="notes" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top"><img src="<?=$this->helper('ImageBase64')->output(c::config()->dirs->www.'/assets/images/mprinter/note.png')?>" class="icon-note"></td>
|
||||
<td style="margin: 0; padding: 22px 0 0 0;" valign="top"><div class="arrow-left"></div></td>
|
||||
<td style="width: 100%; padding-right: 0; "><table style="width: 100%"><tr><td class="notes-content"><?=nl2br( $summary[ 'note' ] )?></td></tr></table></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php } ?>
|
||||
|
||||
<div class="xhatch separator-small"></div>
|
||||
|
||||
<table width="100%" celpadding="0" cellspacing="0" class="detail">
|
||||
<thead style="font-weight:bold">
|
||||
<tr>
|
||||
<td colspan="7" class="topitem" style="font-size:18px;">Orders</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<thead style="font-weight:bold">
|
||||
<tr>
|
||||
<td style="width:215px;" class="topitem">Customer</td>
|
||||
<td style="width:215px;" class="topitem">Restaurant</td>
|
||||
<td style="width:215px;" class="topitem">Date</td>
|
||||
<td class="topitem">Type</td>
|
||||
<?php if( $summary[ 'pay_type' ] == Cockpit_Payment_Schedule::PAY_TYPE_PAYMENT ) { ?>
|
||||
<td style="width:155px;" class="topitem">Tip</td>
|
||||
<td style="width:155px;" class="topitem">Delivery Fee</td>
|
||||
<td style="width:155px;" class="topitem">Payment</td>
|
||||
<?php } ?>
|
||||
<?php if( $summary[ 'pay_type' ] == Cockpit_Payment_Schedule::PAY_TYPE_REIMBURSEMENT ) { ?>
|
||||
<td class="topitem">Reimbursement</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php foreach( $summary[ 'orders' ][ 'included' ] as $order ) { ?>
|
||||
<tr>
|
||||
<td class="fooditem"><?php echo $order[ 'name' ]; ?></td>
|
||||
<td class="fooditem"><?php echo $order[ 'restaurant' ]; ?></td>
|
||||
<td class="fooditem"><?php echo $order[ 'date' ]; ?></td>
|
||||
<td class="fooditem"><?php echo $order[ 'pay_type' ]; ?></td>
|
||||
<?php if( $summary[ 'pay_type' ] == Cockpit_Payment_Schedule::PAY_TYPE_PAYMENT ) { ?>
|
||||
<td class="fooditem">
|
||||
<?php if( $order[ 'tip' ] && $order[ 'pay_type' ] == 'Card' ) { ?>
|
||||
$<?php echo number_format( $order[ 'tip' ], 2 ); ?>
|
||||
<?php } else { ?>
|
||||
-
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="fooditem">$<?php echo number_format( $order[ 'delivery_fee' ], 2 ); ?></td>
|
||||
<td class="fooditem">$<?php echo number_format( $order[ 'total_payment' ], 2 ); ?></td>
|
||||
<?php } else { ?>
|
||||
<td class="fooditem">$<?php echo number_format( $order[ 'total_reimburse' ], 2 ); ?></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td colspan="7"> </td>
|
||||
</tr>
|
||||
<?php if( $summary[ 'pay_type' ] == Cockpit_Payment_Schedule::PAY_TYPE_PAYMENT ) { ?>
|
||||
<tr class="class">
|
||||
<td colspan="6" style="text-align:right">Tips by Card</td>
|
||||
<td>$<?php echo number_format( $summary[ 'calcs' ][ 'tip' ], 2 ); ?></td>
|
||||
</tr>
|
||||
<tr class="class">
|
||||
<td colspan="6" style="text-align:right">Total Delivery Fee</td>
|
||||
<td>$<?php echo number_format( $summary[ 'calcs' ][ 'delivery_fee' ], 2 ); ?></td>
|
||||
</tr>
|
||||
<tr class="class">
|
||||
<td colspan="6" style="text-align:right"><strong>Markup</strong></td>
|
||||
<td><strong>$<?php echo number_format( $summary[ 'calcs' ][ 'markup' ], 2 ); ?></strong></td>
|
||||
</tr>
|
||||
<tr class="class">
|
||||
<td colspan="6" style="text-align:right"><strong>Total Payment</strong></td>
|
||||
<td><strong>$<?php echo number_format( $summary[ 'calcs' ][ 'total_payment' ], 2 ); ?></strong></td>
|
||||
</tr>
|
||||
<?php } else { ?>
|
||||
<tr class="class">
|
||||
<td colspan="6" style="text-align:right"><strong>Total Reimbursement</strong></td>
|
||||
<td><strong>$<?php echo number_format( $summary[ 'calcs' ][ 'total_reimburse' ], 2 ); ?></strong></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
<br/><br/>
|
||||
<table cellpadding="0" cellspacing="0" style="width: 100%; margin-top: 20px;">
|
||||
<tr>
|
||||
<td style="text-align: left;" class="text-size-small">
|
||||
<?php if( $summary[ 'payment_method' ] == 'deposit' ) { ?>
|
||||
Payment has been deposited into your bank account
|
||||
<?php } else { ?>
|
||||
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td style="text-align: right;" class="text-size-small">Crunchbutton support: call or text <?=c::config()->phone->restaurant?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="xhatch separator-big" style="text-align:right!important;"></div>
|
||||
@ -26,12 +26,12 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php if( $summary[ 'notes' ] ) { ?>
|
||||
<?php if( $summary[ 'note' ] ) { ?>
|
||||
<table class="notes" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top"><img src="<?=$this->helper('ImageBase64')->output(c::config()->dirs->www.'/assets/images/mprinter/note.png')?>" class="icon-note"></td>
|
||||
<td style="margin: 0; padding: 22px 0 0 0;" valign="top"><div class="arrow-left"></div></td>
|
||||
<td style="width: 100%; padding-right: 0; "><table style="width: 100%"><tr><td class="notes-content"><?=nl2br( $summary[ 'notes' ] )?></td></tr></table></td>
|
||||
<td style="width: 100%; padding-right: 0; "><table style="width: 100%"><tr><td class="notes-content"><?=nl2br( $summary[ 'note' ] )?></td></tr></table></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php } ?>
|
||||
@ -132,7 +132,7 @@
|
||||
<tr>
|
||||
<td style="text-align: left;" class="text-size-small">
|
||||
<?php if( $summary[ 'payment_method' ] == 'deposit' ) { ?>
|
||||
Payment has been deposited into your back account
|
||||
Payment has been deposited into your bank account
|
||||
<?php } else { ?>
|
||||
|
||||
<?php } ?>
|
||||
@ -123,7 +123,7 @@ NGApp.config(['$routeProvider', '$locationProvider', function($routeProvider, $l
|
||||
.when('/settlement/restaurants/summary/:id', {
|
||||
action: 'settlement',
|
||||
controller: 'SettlementRestaurantsSummaryCtrl',
|
||||
templateUrl: 'assets/view/settlement-restaurants-summary.html'
|
||||
templateUrl: 'assets/view/settlement-summary.html'
|
||||
})
|
||||
.when('/settlement/restaurants/payments', {
|
||||
action: 'settlement',
|
||||
@ -158,7 +158,7 @@ NGApp.config(['$routeProvider', '$locationProvider', function($routeProvider, $l
|
||||
.when('/settlement/drivers/summary/:id', {
|
||||
action: 'settlement',
|
||||
controller: 'SettlementDriversSummaryCtrl',
|
||||
templateUrl: 'assets/view/settlement-drivers-summary.html'
|
||||
templateUrl: 'assets/view/settlement-summary.html'
|
||||
})
|
||||
/* Driver shifts */
|
||||
.when('/drivers/orders', {
|
||||
|
||||
@ -415,7 +415,7 @@ NGApp.controller( 'SettlementDriversCtrl', function ( $scope, $filter, Settlemen
|
||||
if( json.start && json.end ){
|
||||
$scope.range = { 'start' : new Date( json.start ), 'end' : new Date( json.end ) };
|
||||
$scope.ready = true;
|
||||
setTimeout( function() { $scope.begin() }, 100 );
|
||||
// setTimeout( function() { $scope.begin() }, 100 );
|
||||
}
|
||||
} );
|
||||
}
|
||||
@ -767,3 +767,25 @@ NGApp.controller( 'SettlementDriversPaymentCtrl', function ( $scope, $routeParam
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
NGApp.controller( 'SettlementDriversSummaryCtrl', function ( $scope, $routeParams, SettlementService ) {
|
||||
|
||||
$scope.ready = false;
|
||||
|
||||
var load = function(){
|
||||
SettlementService.drivers.view_summary( function( data ){
|
||||
$scope.summary = data;
|
||||
$scope.ready = true;
|
||||
} );
|
||||
}
|
||||
|
||||
$scope.payment = function(){
|
||||
$scope.navigation.link( '/settlement/drivers/payment/' + $routeParams.id );
|
||||
}
|
||||
|
||||
// Just run if the user is loggedin
|
||||
if( $scope.account.isLoggedIn() ){
|
||||
load();
|
||||
}
|
||||
|
||||
});
|
||||
@ -34,6 +34,7 @@ NGApp.factory( 'SettlementService', function( $resource, $http, $routeParams ) {
|
||||
'scheduled' : { 'method': 'POST', params : { action: 'scheduled' } },
|
||||
'scheduled_payment' : { 'method': 'POST', params : { action: 'scheduled' } },
|
||||
'do_payment' : { 'method': 'POST', params : { action: 'do-payment' } },
|
||||
'send_summary' : { 'method': 'POST', params : { action: 'send-summary' } },
|
||||
'payment' : { 'method': 'POST', params : { action: 'payment' } },
|
||||
'payments' : { 'method': 'POST', params : { action: 'payments' } },
|
||||
'begin' : { 'method': 'POST', params : { action: 'begin' } }
|
||||
@ -90,12 +91,12 @@ NGApp.factory( 'SettlementService', function( $resource, $http, $routeParams ) {
|
||||
service.restaurants.view_summary = function( callback ){
|
||||
var url = App.service + 'settlement/restaurants/view-summary/' + $routeParams.id;
|
||||
$http( { method: 'POST', url: url } ).
|
||||
success( function( data, status, headers, config ) {
|
||||
callback( data );
|
||||
}).
|
||||
error( function(data, status, headers, config ) {
|
||||
callback( false );
|
||||
} );
|
||||
success( function( data, status, headers, config ) {
|
||||
callback( data );
|
||||
}).
|
||||
error( function(data, status, headers, config ) {
|
||||
callback( false );
|
||||
} );
|
||||
}
|
||||
|
||||
service.restaurants.payments = function( params, callback ){
|
||||
@ -182,6 +183,23 @@ NGApp.factory( 'SettlementService', function( $resource, $http, $routeParams ) {
|
||||
} );
|
||||
}
|
||||
|
||||
service.drivers.send_summary = function( callback ){
|
||||
settlement.drivers.send_summary( { 'id_payment_schedule' : $routeParams.id }, function( json ){
|
||||
callback( json );
|
||||
} );
|
||||
}
|
||||
|
||||
service.drivers.view_summary = function( callback ){
|
||||
var url = App.service + 'settlement/drivers/view-summary/' + $routeParams.id;
|
||||
$http( { method: 'POST', url: url } ).
|
||||
success( function( data, status, headers, config ) {
|
||||
callback( data );
|
||||
}).
|
||||
error( function(data, status, headers, config ) {
|
||||
callback( false );
|
||||
} );
|
||||
}
|
||||
|
||||
service.pay_types = function(){
|
||||
var tips = [];
|
||||
tips.push( { type: 0, label: 'All' } );
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user