<script type="text/javascript" src="/libraries/framework/vendor/plugins/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/libraries/framework/vendor/plugins/ckeditor/adapters/jquery.js"></script>
<?
global $db;
$carrier_accounts[''] = '--- wybierz konto przewoźnika ---';
foreach ( $this -> apilo_carrier_account_list as $carrier_account )
{
  $carrier_accounts[ $carrier_account['id'] ] = $carrier_account['name'];
}
// sellasist_shipments_methods
$sellasist_shipments_methods[''] = '--- wybierz metodę wysyłki ---';
foreach ( $this -> sellasist_shipments_methods as $sellasist_shipments_method )
{
  $sellasist_shipments_methods[ $sellasist_shipments_method['id'] ] = $sellasist_shipments_method['title'];
}
ob_start();
?>
  <div id="settings-tabs">
    <ul class="resp-tabs-list settings-tabs">
      <li><i class="fa fa-file"></i>Ogólne</li>
      <li><i class="fa fa-wrench"></i>Powiązane metody płatności</li>
    </ul>
    <div class="resp-tabs-container settings-tabs">
      <div>
        <?= \Html::input(
                    array(
                      'label'         => 'Nazwa',
                      'class'         => 'require',
                      'name'          => 'name',
                      'id'            => 'name',
                      'readonly'      => true,
                      'value'         => $this -> transport_details['name']
                    )
                );?>
        <?= \Html::input(
                    array(
                      'label'         => 'Nazwa widoczna',
                      'name'          => 'name_visible',
                      'id'            => 'name_visible',
                      'value'         => $this -> transport_details['name_visible']
                    )
                );?>
        <?= \Html::input(
                    array(
                      'label'         => 'Opis',
                      'name'          => 'description',
                      'id'            => 'description',
                      'value'         => $this -> transport_details['description']
                    )
                );?>
        <?= \Html::input(
                    array(
                      'label'         => 'Koszt (PLN)',
                      'class'         => 'number-format require',
                      'name'          => 'cost',
                      'id'            => 'cost',
                      'value'         => $this -> transport_details['cost']
                    )
                );?>
        <?= \Html::input(
                    array(
                      'label'         => 'Maks. WP',
                      'class'         => 'number-format require',
                      'name'          => 'max_wp',
                      'id'            => 'max_wp',
                      'value'         => $this -> transport_details['max_wp']
                    )
                );?>
        <?= \Html::input_switch( [
          'label' => 'Domyślna forma dostawy',
          'name' => 'default',
          'checked' => $this -> transport_details['default'] == 1 ? true : false
        ] );?>
        <?= \Html::input_switch(
          array(
            'label'   => 'Aktywny',
            'name'    => 'status',
            'checked' => $this -> transport_details['status'] == 1 ? true : false
          )
        );?>
        <?= \Html::input_switch( [
          'label' => 'Darmowa dostawa',
          'name' => 'delivery_free',
          'checked' => $this -> transport_details['delivery_free'] == 1 ? true : false
        ] );?>
        <?= \Html::select( [
          'label' => 'Kurier z Apilo',
          'name' => 'apilo_carrier_account_id',
          'id' => 'apilo_carrier_account_id',
          'values'  => $carrier_accounts,
          'value' => $this -> transport_details['apilo_carrier_account_id']
        ] );?>
        <!-- sellasist_shipments_methods -->
        <?= \Html::select( [
          'label' => 'Metoda wysyłki z Sellasist',
          'name' => 'sellasist_shipment_method_id',
          'id' => 'sellasist_shipment_method_id',
          'values'  => $sellasist_shipments_methods,
          'value' => $this -> transport_details['sellasist_shipment_method_id']
        ] );?>
      </div>
      <div>
        <? if ( is_array( $this -> payments_list ) ): foreach ( $this -> payments_list as $payment_method ):?>
          <div class="form-group">
            <div class="col-lg-12">
              <div class="list">
                <input type="checkbox" class="g-checkbox" name="payment_methods[]" value="<?= $payment_method['id'];?>" <? if ( in_array( $payment_method['id'], $this -> transport_details['payment_methods'] ) ):?>checked="checked"<? endif;?> />
                <span class="bold <? if ( !$payment_method['status'] ):?>text-muted<? endif;?>"><?= $payment_method['name'];?></span>
              </div>
            </div>
          </div>
        <? endforeach; endif;?>
      </div>
    </div>
  </div>
<?
$out = ob_get_clean();

$grid = new \gridEdit;
$grid -> id               = 'transport-edit';
$grid -> gdb_opt          = $gdb;
$grid -> include_plugins  = true;
$grid -> title            = 'Edycja rodzaju transportu';
$grid -> fields           = [
                              [
                                'db' => 'id',
                                'type' => 'hidden',
                                'value' => $this -> transport_details['id']
                              ]
                            ];
$grid -> actions          = [
                              'save' => [ 'url' => '/admin/shop_transport/transport_save/', 'back_url' => '/admin/shop_transport/view_list/' ],
                              'cancel' => [ 'url' => '/admin/shop_transport/view_list/' ]
                            ];
$grid -> external_code    = $out;
$grid -> persist_edit     = true;
$grid -> id_param         = 'id';

echo $grid -> draw();
?>
<script type="text/javascript">
  $( function()
  {
    disable_menu();

    $( '#settings-tabs' ).easyResponsiveTabs({
      width: 'auto',
      fit: true,
      tabidentify: 'settings-tabs',
      type: 'vertical'
    });
  });
</script>