/**
     * @param Bring_WC_Order_Adapter $order
     * @return string
     */
    static function render_errors($order)
    {
        $errors = $order->get_booking_errors();
        ?>
    <div class="bring-info-box">
      <div>
        <?php 
        $status = Bring_Booking_Common_View::get_booking_status_info($order);
        echo Bring_Booking_Common_View::create_status_icon($status);
        ?>
        <h3><?php 
        echo $status['text'];
        ?>
</h3>
      </div>

      <div class="bring-booking-errors">
        <div><?php 
        _e('Previous booking request failed with the following errors:', 'bring-fraktguiden');
        ?>
</div>
        <ul>
          <?php 
        foreach ($errors as $error) {
            ?>
            <li><?php 
            echo $error;
            ?>
</li>
          <?php 
        }
        ?>
        </ul>
        <div><?php 
        _e('Press Start to try again', 'bring-fraktguiden');
        ?>
</div>
      </div>
    </div>
    <?php 
    }
    /**
     *
     */
    static function add_bulk_admin_footer()
    {
        global $post_type;
        if ($post_type == 'shop_order') {
            ?>
      <script type="text/template" id="tmpl-bring-modal-bulk">
        <div class="wc-backbone-modal">
          <div class="wc-backbone-modal-content">
            <section class="wc-backbone-modal-main" role="main">
              <header class="wc-backbone-modal-header">
                <h1 class="bgf-modal-header"><?php 
            echo __('Bring Booking', 'bring-fraktguiden');
            ?>
</h1>
                <button
                    class="modal-close modal-close-link dashicons dashicons-no-alt">
                  <span class="screen-reader-text">Close modal panel</span>
                </button>
              </header>
              <article>
                <div class="bring-form-field" style="margin-top:0">
                  <?php 
            echo __('This will only book orders that has not been booked.', 'bring-fraktguiden');
            ?>
                </div>
                <div class="bring-form-field">
                  <label><?php 
            echo __('Selected orders', 'bring-fraktguiden');
            ?>
                    :</label>
                  <span class="bring-modal-selected-orders-list"></span>
                </div>
                <div class="bring-form-field">
                  <label><?php 
            echo __('MyBring Customer', 'bring-fraktguiden');
            ?>
                    :</label>
                  <?php 
            Bring_Booking_Common_View::render_customer_selector('_bring-modal-customer-selector');
            ?>
                </div>
                <div class="bring-form-field">
                  <label><?php 
            echo __('Shipping Date', 'bring-fraktguiden');
            ?>
                    :</label>
                  <?php 
            Bring_Booking_Common_View::render_shipping_date_time('_bring-modal-shipping-date');
            ?>
                </div>
              </article>
              <footer>
                <div class="inner">
                  <button id="btn-ok"
                          class="button button-primary button-large"><?php 
            echo Bring_Booking_Common_View::booking_label(true);
            ?>
</button>
                </div>
              </footer>
            </section>
          </div>
        </div>
        <div class="wc-backbone-modal-backdrop modal-close"></div>
      </script>

      <script type="text/javascript">
        (function () {
          var $ = jQuery;

          $( document ).ready( function () {

            // Add bulk booking to action selector
            $( '<option>' ).val( 'bring_bulk_book' ).text( '<?php 
            echo Bring_Booking_Common_View::booking_label(true);
            ?>
' ).appendTo( "select[name='action']" );
            $( '<option>' ).val( 'bring_bulk_book' ).text( '<?php 
            echo Bring_Booking_Common_View::booking_label(true);
            ?>
' ).appendTo( "select[name='action2']" );

            // Add bulk print to action selector
            $( '<option>' ).val( 'bring_print_labels' ).text( '<?php 
            _e('Bring - Print labels', 'bring-fraktguiden');
            ?>
' ).appendTo( "select[name='action']" );
            $( '<option>' ).val( 'bring_print_labels' ).text( '<?php 
            _e('Bring - Print labels', 'bring-fraktguiden');
            ?>
' ).appendTo( "select[name='action2']" );

            //@todo: does this need to be global?
            var modal = $( {} );

            var form = $( 'form#posts-filter' );

            // Add input for form filter submit from modal.
            var customer_number = $( '<input type="hidden" name="_bring-customer-number" value="">' );
            var shipping_date = $( '<input type="hidden" name="_bring-shipping-date" value="">' );
            var shipping_date_hour = $( '<input type="hidden" name="_bring-shipping-date-hour" value="">' );
            var shipping_date_minutes = $( '<input type="hidden" name="_bring-shipping-date-minutes" value="">' );

            form.append( customer_number );
            form.append( shipping_date );
            form.append( shipping_date_hour );
            form.append( shipping_date_minutes );

            function get_checked_order_ids() {
              var result = [];
              $( '#the-list' ).find( 'input[type=checkbox]:checked' ).each( function ( i, elem ) {
                result.push( elem.value );
              } );
              return result;
            }


            function show_bulk_book_dialog() {
              // Open dialog.
              modal.WCBackboneModal( {
                template: 'bring-modal-bulk'
              } );

              // Initialize data picker.
              $( "[name=_bring-modal-shipping-date]" ).datepicker( {
                minDate: 0,
                dateFormat: 'yy-mm-dd'
              } );

              // Disable dialog submit button if no orders are checked.
              var order_ids = get_checked_order_ids();
              if ( order_ids.length == 0 ) {
                $( '#btn-ok' ).attr( 'disabled', 'true' );
              }
              else {
                $( '#btn-ok' ).removeAttr( 'disabled' );
              }

              // Print order ids in dialog.
              $( '.bring-modal-selected-orders-list' ).text( order_ids.join( ' - ' ) );
            }


            $( '#doaction' ).click( function ( evt ) {
              if ( $( "select[name='action']" ).val() == 'bring_bulk_book' ) {
                show_bulk_book_dialog();
                evt.preventDefault();
              }

              if ( $( "select[name='action']" ).val() == 'bring_print_labels' ) {
                var url = '<?php 
            echo Bring_Booking_Labels::create_download_url('');
            ?>
';

                url = url + get_checked_order_ids().join(',');

                window.open(url);
                evt.preventDefault();
              }
            } );


            $( '#doaction2' ).click( function ( evt ) {
              if ( $( "select[name='action2']" ).val() == 'bring_bulk_book' ) {
                show_bulk_book_dialog();
                evt.preventDefault();
              }

              if ( $( "select[name='action']" ).val() == 'bring_print_labels' ) {
                evt.preventDefault();
              }
            } );

            $( document.body ).on( 'wc_backbone_modal_response', function ( e ) {
              customer_number.val( $( '[name=_bring-modal-customer-selector]' ).val() );
              shipping_date.val( $( '[name=_bring-modal-shipping-date]' ).val() );
              shipping_date_hour.val( $( '[name=_bring-modal-shipping-date-hour]' ).val() );
              shipping_date_minutes.val( $( '[name=_bring-modal-shipping-date-minutes]' ).val() );
              form.submit();
            } );

          } );
        })();
      </script>
      <?php 
        }
    }