Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+96 -4
View File
@@ -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' => '' )
);
}