Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\modules\admin\payments;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -23,6 +23,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _shipping extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
@@ -41,87 +46,6 @@ class _shipping extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'nexus_ship_orders', \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=shipping' ) );
|
||||
$table->sortBy = $table->sortBy ?: 'o_date';
|
||||
|
||||
/* Format Columns */
|
||||
$table->include = array( 'o_status', 'o_method', 'o_invoice', 'o_date' );
|
||||
$table->parsers = array(
|
||||
'o_status' => function( $val )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('shiporders')->status( $val );
|
||||
},
|
||||
'o_method' => function( $val, $row )
|
||||
{
|
||||
if ( $row['o_api_service'] )
|
||||
{
|
||||
return $row['o_api_service'];
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Shipping\FlatRate::load( $val )->_title;
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'o_invoice' => function( $val )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('invoices')->link( \IPS\nexus\Invoice::load( $val ) );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'o_date' => function( $val )
|
||||
{
|
||||
return (string) \IPS\DateTime::ts( $val );
|
||||
}
|
||||
);
|
||||
|
||||
/* Filters */
|
||||
$table->filters = array(
|
||||
'sstatus_pend' => array( 'o_status=?', 'pend' ),
|
||||
);
|
||||
|
||||
/* Search */
|
||||
$methods = array();
|
||||
foreach( \IPS\nexus\Shipping\FlatRate::roots() as $method )
|
||||
{
|
||||
$methods[ $method->id ] = $method->_title;
|
||||
}
|
||||
$table->advancedSearch = array(
|
||||
'o_status' => array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => array(
|
||||
\IPS\nexus\Shipping\Order::STATUS_SHIPPED => 'sstatus_done',
|
||||
\IPS\nexus\Shipping\Order::STATUS_PENDING => 'sstatus_pend',
|
||||
\IPS\nexus\Shipping\Order::STATUS_CANCELED => 'sstatus_canc',
|
||||
), 'multiple' => TRUE ) ),
|
||||
'o_method' => array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => $methods, 'multiple' => TRUE ) ),
|
||||
'o_date' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
'o_shipped_date'=> \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
'o_tracknumber' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
);
|
||||
$table->quickSearch = 'o_tracknumber';
|
||||
|
||||
/* Buttons */
|
||||
$table->rowButtons = function( $row )
|
||||
{
|
||||
return array_merge( array(
|
||||
'view' => array(
|
||||
'icon' => 'search',
|
||||
'title' => 'shipment_view',
|
||||
'link' => \IPS\Http\Url::internal( "app=nexus&module=payments&controller=shipping&do=view&id={$row['o_id']}" )
|
||||
)
|
||||
), \IPS\nexus\Shipping\Order::constructFromData( $row )->buttons( 't' ) );
|
||||
};
|
||||
|
||||
/* Settings Button */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'shipmethods_manage' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['settings'] = array(
|
||||
@@ -133,7 +57,7 @@ class _shipping extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('shipping');
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
\IPS\Output::i()->output = (string) \IPS\nexus\Shipping\Order::table( \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=shipping' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -421,7 +345,7 @@ class _shipping extends \IPS\Dispatcher\Controller
|
||||
$easyPost = \IPS\Http\Url::external( 'https://api.easypost.com/v2/shipments' )->request()->login( \IPS\Settings::i()->easypost_api_key, '' )->post( array( 'shipment' => array(
|
||||
'to_address' => array(
|
||||
'street1' => array_shift( $toAddress['addressLines'] ),
|
||||
'street2' => count( $toAddress['addressLines'] ) ? implode( ', ', $toAddress['addressLines'] ) : NULL,
|
||||
'street2' => \count( $toAddress['addressLines'] ) ? implode( ', ', $toAddress['addressLines'] ) : NULL,
|
||||
'city' => $toAddress['city'],
|
||||
'state' => $toAddress['region'],
|
||||
'zip' => $toAddress['postalCode'],
|
||||
@@ -432,7 +356,7 @@ class _shipping extends \IPS\Dispatcher\Controller
|
||||
),
|
||||
'from_address' => array(
|
||||
'street1' => array_shift( $fromAddress->addressLines ),
|
||||
'street2' => count( $fromAddress->addressLines ) ? implode( ', ', $fromAddress->addressLines ) : NULL,
|
||||
'street2' => \count( $fromAddress->addressLines ) ? implode( ', ', $fromAddress->addressLines ) : NULL,
|
||||
'city' => $fromAddress->city,
|
||||
'state' => $fromAddress->region,
|
||||
'zip' => $fromAddress->postalCode,
|
||||
@@ -445,7 +369,7 @@ class _shipping extends \IPS\Dispatcher\Controller
|
||||
'customs_info' => $customsInfo
|
||||
) ) )->decodeJson();
|
||||
|
||||
if ( !count( $easyPost['rates'] ) )
|
||||
if ( !\count( $easyPost['rates'] ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'err_no_easypost', '1X193/6', 403, '' );
|
||||
}
|
||||
@@ -570,7 +494,7 @@ class _shipping extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* How much did the customer pay for shipping? */
|
||||
$invoiceSummary = $shipment->invoice->summary();
|
||||
$otherShipments = count( $shipment->invoice->shipments() ) - 1;
|
||||
$otherShipments = \count( $shipment->invoice->shipments() ) - 1;
|
||||
$message = $otherShipments ? \IPS\Member::loggedIn()->language()->addToStack( 'shipment_cost_others', FALSE, array( 'sprintf' => array( $invoiceSummary['shippingTotal'], $shipment->invoice->id, $otherShipments ) ) ) : \IPS\Member::loggedIn()->language()->addToStack( 'shipment_cost_noothers', FALSE, array( 'sprintf' => array( $invoiceSummary['shippingTotal'] ) ) );
|
||||
\IPS\Member::loggedIn()->language()->words['easypost_rate_desc'] = $message;
|
||||
|
||||
@@ -587,6 +511,7 @@ class _shipping extends \IPS\Dispatcher\Controller
|
||||
public function cancel()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'shiporders_edit' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Load */
|
||||
try
|
||||
@@ -675,7 +600,7 @@ class _shipping extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'shipping.css', 'nexus' ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->blankTemplate( $output ), 200, 'text/html', \IPS\Output::i()->httpHeaders );
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->blankTemplate( $output ), 200, 'text/html' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user