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\Shipping;
|
||||
|
||||
/* 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;
|
||||
@@ -148,7 +148,7 @@ class _EasyPostRate implements \IPS\nexus\Shipping\Rate
|
||||
return \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,
|
||||
@@ -159,7 +159,7 @@ class _EasyPostRate implements \IPS\nexus\Shipping\Rate
|
||||
),
|
||||
'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,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Shipping;
|
||||
|
||||
/* 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;
|
||||
@@ -104,11 +104,11 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
$weightMatrix->columns = array(
|
||||
'w_rate_min'=> function( $key, $value, $data )
|
||||
{
|
||||
return new \IPS\nexus\Form\Weight( $key, ( is_numeric( $value ) ) ? new \IPS\nexus\Shipping\Weight( $value ) : $value, FALSE, array( 'unlimitedLang' => 's_any_value' ) );
|
||||
return new \IPS\nexus\Form\Weight( $key, ( \is_numeric( $value ) ) ? new \IPS\nexus\Shipping\Weight( $value ) : $value, FALSE, array( 'unlimitedLang' => 's_any_value' ) );
|
||||
},
|
||||
'w_rate_max'=> function( $key, $value, $data )
|
||||
{
|
||||
return new \IPS\nexus\Form\Weight( $key, ( is_numeric( $value ) ) ? new \IPS\nexus\Shipping\Weight( $value ) : $value, FALSE, array( 'unlimitedLang' => 's_any_value' ) );
|
||||
return new \IPS\nexus\Form\Weight( $key, ( \is_numeric( $value ) ) ? new \IPS\nexus\Shipping\Weight( $value ) : $value, FALSE, array( 'unlimitedLang' => 's_any_value' ) );
|
||||
},
|
||||
'w_rate_price'=> function( $key, $value, $data )
|
||||
{
|
||||
@@ -293,7 +293,7 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
{
|
||||
$price[ $money->currency ] = $money->amount;
|
||||
}
|
||||
if ( !count( $price ) )
|
||||
if ( !\count( $price ) )
|
||||
{
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
{
|
||||
@@ -379,7 +379,7 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
|
||||
if ( isset( $locations[ $destination->country ] ) )
|
||||
{
|
||||
if ( $locations[ $destination->country ] !== '*' and !in_array( $destination->region, $locations[ $destination->country ] ) )
|
||||
if ( $locations[ $destination->country ] !== '*' and !\in_array( $destination->region, $locations[ $destination->country ] ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -396,12 +396,12 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
foreach ( $rates as $rate )
|
||||
{
|
||||
$min = $rate['min'];
|
||||
if ( is_array( $min ) )
|
||||
if ( \is_array( $min ) )
|
||||
{
|
||||
$min = $min[ $currency ];
|
||||
}
|
||||
$max = $rate['max'];
|
||||
if ( is_array( $max ) )
|
||||
if ( \is_array( $max ) )
|
||||
{
|
||||
$max = $max[ $currency ];
|
||||
}
|
||||
@@ -488,12 +488,12 @@ class _FlatRate extends \IPS\Node\Model implements \IPS\nexus\Shipping\Rate
|
||||
foreach ( $rates as $rate )
|
||||
{
|
||||
$min = $rate['min'];
|
||||
if ( is_array( $min ) )
|
||||
if ( \is_array( $min ) )
|
||||
{
|
||||
$min = $min[ $currency ];
|
||||
}
|
||||
$max = $rate['max'];
|
||||
if ( is_array( $max ) )
|
||||
if ( \is_array( $max ) )
|
||||
{
|
||||
$max = $max[ $currency ];
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Shipping;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Shipping;
|
||||
|
||||
/* 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;
|
||||
@@ -42,6 +42,98 @@ class _Order extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
public static $databasePrefix = 'o_';
|
||||
|
||||
/**
|
||||
* Get table of shipping orders
|
||||
*
|
||||
* @param \IPS\Http\Url $url URL that the table will eb shown on
|
||||
* @return \IPS\Helpers\Table\Db
|
||||
*/
|
||||
public static function table( \IPS\Http\Url $url )
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'nexus_ship_orders', $url );
|
||||
$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', 'nexus' )->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', 'nexus' )->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' ) );
|
||||
};
|
||||
|
||||
/* Return */
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Default Values
|
||||
*
|
||||
@@ -66,7 +158,7 @@ class _Order extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Set invoice
|
||||
*
|
||||
* @param \IPS\nexus\Invoice
|
||||
* @param \IPS\nexus\Invoice $invoice Invoice to associate with order
|
||||
* @return void
|
||||
*/
|
||||
public function set_invoice( \IPS\nexus\Invoice $invoice )
|
||||
@@ -115,7 +207,7 @@ class _Order extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Set method
|
||||
*
|
||||
* @param \IPS\nexus\Shipping\FlatRate
|
||||
* @param \IPS\nexus\Shipping\FlatRate $method Flatrate method to use
|
||||
* @return void
|
||||
*/
|
||||
public function set_method( \IPS\nexus\Shipping\FlatRate $method )
|
||||
@@ -325,7 +417,7 @@ class _Order extends \IPS\Patterns\ActiveRecord
|
||||
$return['cancel'] = array(
|
||||
'title' => 'cancel',
|
||||
'icon' => 'times',
|
||||
'link' => $url->setQueryString( 'do', 'cancel' ),
|
||||
'link' => $url->setQueryString( 'do', 'cancel' )->csrf(),
|
||||
'data' => array( 'confirm' => '' )
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Shipping;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Shipping;
|
||||
|
||||
/* 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;
|
||||
@@ -61,7 +61,7 @@ class _Weight
|
||||
/**
|
||||
* Contructor
|
||||
*
|
||||
* @param float $weight Weight
|
||||
* @param float $amount Weight
|
||||
* @param string $unit Unit
|
||||
* @return void
|
||||
*/
|
||||
@@ -73,7 +73,7 @@ class _Weight
|
||||
/**
|
||||
* Get as float
|
||||
*
|
||||
* @param $unit Unit
|
||||
* @param string $unit Unit
|
||||
* @return float
|
||||
*/
|
||||
public function float( $unit='kg' )
|
||||
|
||||
Reference in new issue
Block a user