<? global $lang;?>
<div class="fast_contact_box">
  <h3>Dołącz do grona naszych zadowolonych klientów</h3>
  <form action="">
    <div class="_row-1">
      <div class="_col-1">
        <div class="form_group">
          <label for="form_names">Imię i nazwisko</label>
          <input type="text" name="name_surname" id="form_names" placeholder="Imię i nazwisko">
        </div>

        <div class="form_group">
          <label for="form_email">E-mail*</label>
          <input type="email" name="email" id="form_email" placeholder="E-mail" require>
        </div>

        <div class="form_group">
          <label for="form_phone">Numer telefonu*</label>
          <input type="text" name="phone" id="form_phone" placeholder="Numer telefonu" require>
        </div>

        <div class="form_group">
          <label for="form_service">Usługa</label>
          <select name="service" id="form_service">
            <option value="" disabled <?= \S::get("from") ? '' : 'selected'; ?>>Wybierz usługę</option>
            <option value="strona www">strona www</option>
            <option value="sklep internetowy">skep internetowy</option>
            <option value="facebook ADS">facebook ADS</option>
            <option value="google ADS" <?= \S::get("from") === 'google-ads' ? 'selected' : ''; ?>>google ADS</option>
            <option value="pozycjonowanie">pozycjonowanie</option>
            <option value="obsługa istniejącej strony">obsługa istniejącej strony</option>
            <option value="inne">inne</option>
          </select>
        </div>

        <div class="form_group">
          <label for="form_budget">Budżet (zł)</label>
          <input type="text" name="budget" id="form_budget" required>
        </div>
      </div>
      <div class="_col-2">
        <div class="form_group">
          <label for="form_topic">Temat*</label>
          <input type="tel" name="topic" id="form_topic" placeholder="Temat" require value="Zapytanie ze strony <?= preg_replace( '#^(http(s)?://)?w{3}\.#', '$1', $_SERVER['SERVER_NAME'] );?>">
        </div>

        <div class="form_group">
          <label for="form_message">Wiadomość*</label>
          <textarea name="message" id="form_message" cols="30" rows="10" placeholder="Treść Twojej wiadomości" require></textarea>
        </div>

        <div class="form_group_2">
          <input type="checkbox" name="form_check" id="form_check" require>
          <label for="form_check">Administratorem danych osobowych jest Project-Pro. Dane wpisane w
            formularzu
            kontaktowym będą przetwarzane w celu udzielenia odpowiedzi na przesłane zapytanie.</label>
        </div>
      </div>
    </div>
    <div class="_row-2">
      <p class="btn-2">Wyślij zapytanie</p>
    </div>
  </form>
</div>
<script class="footer">
  $( function()
  {
    $( 'body' ).on( click_event, '.fast_contact_box .btn-2', function()
    {
      var form_names = $.trim( $( '.fast_contact_box #form_names' ).val() );
      var form_email = $.trim( $( '.fast_contact_box #form_email' ).val() );
      var form_phone = $.trim( $( '.fast_contact_box #form_phone' ).val() );
      var form_service = $.trim( $( '.fast_contact_box #form_service' ).val() );
      var form_budget = $.trim( $( '.fast_contact_box #form_budget' ).val() );
      var form_topic = $.trim( $( '.fast_contact_box #form_topic' ).val() );
      var form_message = $.trim( $( '.fast_contact_box #form_message' ).val() );

      var form_messaform_checkge = $.trim( $( '.fast_contact_box #form_check' ).val() );

      if ( form_email === '' || form_phone === '' || form_message === ''  ) {
        $.alert({
          title: '<?= ucfirst( $lang['blad'] );?>',
          content: 'Proszę uzupełnić wymagane dane: email, numer telefonu i treść wiadomości.',
          type: 'orange',
          closeIcon: true,
          closeIconClass: 'fa fa-close',
          typeAnimated: true,
          animation: 'opacity',
          autoClose: 'confirm|10000',
          boxWidth: '650px',
          useBootstrap: false,
          theme: 'modern',
          buttons: {
            confirm: {
              text: '<?= $lang['zamknij'];?>',
              btnClass: 'btn-blue',
              keys: ['enter'],
              action: function() {}
            }
          }
        });
        return false;
      }

      if ( !$( '.fast_contact_box #form_check' ).is( ':checked' ) ) {
        $.alert({
          title: '<?= ucfirst( $lang['blad'] );?>',
          content: '<?= $lang['prosze-zaznaczyc-zgode'];?>',
          type: 'orange',
          closeIcon: true,
          closeIconClass: 'fa fa-close',
          typeAnimated: true,
          animation: 'opacity',
          autoClose: 'confirm|10000',
          boxWidth: '650px',
          useBootstrap: false,
          theme: 'modern',
          buttons: {
            confirm: {
              text: '<?= $lang['zamknij'];?>',
              btnClass: 'btn-blue',
              keys: ['enter'],
              action: function() {}
            }
          }
        });
        return false;
      }

      $.ajax({
        type: 'POST',
        cache: false,
        url: '/',
        data: {
          a: 'send_contact_form',
          form_names:  form_names,
          form_email: form_email,
          form_phone: form_phone,
          form_service: form_service,
          form_budget: form_budget,
          form_topic: form_topic,
          form_message: form_message
        },
        beforeSend: function() {
          alert1 = $.alert({
            title: '<?= ucfirst( $lang['informacja'] );?>',
            content: '<?= $lang['prosze-czekac'];?>',
            type: 'blue',
            closeIcon: true,
            closeIconClass: 'fa fa-close',
            typeAnimated: true,
            animation: 'opacity',
            autoClose: 'confirm|60000',
            boxWidth: '650px',
            useBootstrap: false,
            theme: 'modern',
            buttons: {
              confirm: {
                text: '<?= $lang['zamknij'];?>',
                btnClass: 'btn-blue',
                keys: ['enter'],
                action: function() {}
              }
            }
          });
        },
        success: function( data ) {
          response = jQuery.parseJSON( data );

          if ( response.status === 'ok' )
            var msg = '<?= $lang['wiadomosc-zostala-wyslana'];?>';
          else
            var msg = '<?= $lang['wiadomosc-niezostala-wyslana'];?>';

          alert1.close();

          $( '.fast_contact_box input[type="text"], .fast_contact_box input[type="email"],.fast_contact_box textarea' ).val( '' );

          $.alert({
            title: '<?= ucfirst( $lang['informacja'] );?>',
            content: msg,
            type: 'blue',
            closeIcon: true,
            closeIconClass: 'fa fa-close',
            typeAnimated: true,
            animation: 'opacity',
            autoClose: 'confirm|10000',
            boxWidth: '650px',
            useBootstrap: false,
            theme: 'modern',
            buttons: {
              confirm: {
                text: '<?= $lang['zamknij'];?>',
                btnClass: 'btn-blue',
                keys: ['enter'],
                action: function() {}
              }
            }
          });
        }
      });
    });
  });
</script>