foreach ( $orderStatusArray as $orderStatus ) { $id = $orderStatus->attribute( 'id' ); if ( $http->hasPostVariable( "orderstatus_name_" . $id ) ) { $orderStatus->setAttribute( 'name', $http->postVariable( "orderstatus_name_" . $id ) ); } // Only check the checkbox value if the has_input variable is set if ( $http->hasPostVariable( "orderstatus_active_has_input_" . $id ) ) { $orderStatus->setAttribute( 'is_active', $http->hasPostVariable( "orderstatus_active_" . $id ) ? 1: 0 ); } $orderStatus->sync(); } eZOrderStatus::flush(); } if ( $http->hasPostVariable( "AddOrderStatusButton" ) ) { $orderStatus = eZOrderStatus::create(); $orderStatus->storeCustom(); $messages[] = array( 'description' => ezpI18n::tr( 'kernel/shop', 'New order status was successfully added.' ) ); } if ( $http->hasPostVariable( "SaveOrderStatusButton" ) ) { $messages[] = array( 'description' => ezpI18n::tr( 'kernel/shop', 'Changes to order status were successfully stored.' ) ); } if ( $http->hasPostVariable( "RemoveOrderStatusButton" ) )
function storeCustom() { if ($this->StatusID) { eZOrderStatus::flush(); $this->store(); } else { // Lock the table while we find the highest number $db = eZDB::instance(); $db->lock('ezorder_status'); $rows = $db->arrayQuery("SELECT max( status_id ) as status_id FROM ezorder_status"); $statusID = $rows[0]['status_id']; // If the max ID is below the custom one we set as the first // custom ID, if not we increase it by one. if ($statusID < eZOrderStatus::CUSTOM) { $statusID = eZOrderStatus::CUSTOM; } else { ++$statusID; } $this->StatusID = $statusID; $this->store(); $db->unlock(); eZOrderStatus::flush(); } }