- Created 'dla-kandydata.php' template for candidates with job offers and registration options. - Developed 'dla-pracodawcy.php' template for employers detailing how Globelus works and registration for new employers. - Implemented 'advert-apply.php' for job applications, including form validation and file upload for CVs. - Added 'new-password.php' for users to set a new password with validation for password strength and matching.
679 lines
30 KiB
PHP
679 lines
30 KiB
PHP
<? global $lang, $globelus_settings; ?>
|
|
<div id="user-panel">
|
|
<?= \Tpl::view( 'globelus/firms/_partials/menu', [
|
|
'active' => 'ogloszenia'
|
|
] );?>
|
|
</div>
|
|
<div class="mini-box fluid">
|
|
<div class="title">
|
|
<?= ucfirst($lang['dodaj-ogloszenie']); ?>
|
|
<span class="pull-right text-danger small">
|
|
Posiadasz <?= (int)$this->user_points; ?> pkt. <a href="/panel-pracodawcy/zakup-punktow">Doładuj konto.</a>
|
|
</span>
|
|
</div>
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="content profil">
|
|
<form id="advert-add" method="POST" action="/globelusFirms/advert_save/" enctype="multipart/form-data">
|
|
<input type="hidden" name="id" value="<?= $this->advert['id']; ?>">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="title" class="col-12 col-sm-4"><?= ucfirst($lang['tytul-ogloszenia']); ?>:</label>
|
|
<div class="col-12 col-sm-8">
|
|
<input type="text" required id="title" name="title" class="form-control" value="<?= htmlspecialchars($this->advert['title']); ?>">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="category" class="col-12 col-sm-4"><?= ucfirst($lang['branza']); ?>:</label>
|
|
<div class="col-12 col-sm-8">
|
|
<select name="category" id="category" required class="form-control">
|
|
<option value="">--- <?= $lang['wybierz']; ?> ---</option>
|
|
<?
|
|
$categories = \front\factory\GlobelusAdverts::categories();
|
|
if (is_array($categories)) : foreach ($categories as $category) : ?>
|
|
<option value="<?= $category['id']; ?>" <? if ($category['id'] == $this->advert['category_id']) : ?>selected="selected" <? endif; ?>><?= $category['name']; ?></option>
|
|
<? endforeach;
|
|
endif;
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="position" class="col-12 col-sm-4">Stanowisko:</label>
|
|
<div class="col-12 col-sm-8">
|
|
<select name="position" id="position" required class="form-control">
|
|
<option value="">--- <?= $lang['wybierz']; ?> ---</option>
|
|
<? if ( is_array( $this -> positions ) ): foreach ( $this -> positions as $position ):?>
|
|
<option value="<?= $position['id']; ?>" <? if ( $position['id'] == $this -> advert['id_position'] ):?>selected="selected" <? endif; ?>><?= htmlspecialchars( $position['name'] );?></option>
|
|
<? endforeach; endif;?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<hr />
|
|
<div class="step-title"><?= ucfirst($lang['miejsce-zatrudnienia']); ?></div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="country" class="col-12 col-sm-4"><?= ucfirst($lang['kraj']); ?>:</label>
|
|
<div class="col-12 col-sm-8">
|
|
<select name="country" id="country" required class="form-control">
|
|
<option value="">--- <?= $lang['wybierz']; ?> ---</option>
|
|
<?
|
|
$countries = \front\factory\Globelus::countries();
|
|
if (is_array($countries)) : foreach ($countries as $country) :
|
|
if ($country['name'] != '- dowolny -') : ?>
|
|
<option value="<?= $country['id']; ?>" <? if ($country['id'] == $this->advert['country_id']) : ?>selected="selected" <? endif; ?>><?= $country['name']; ?></option>
|
|
<? endif;
|
|
endforeach;
|
|
endif;
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row voivodeship">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="region" class="col-12 col-sm-4"><?= ucfirst($lang['region']); ?>/<?= ucfirst($lang['wojewodztwo']); ?>:</label>
|
|
<div class="col-12 col-sm-8">
|
|
<select name="id_voivodeship" id="id_voivodeship" class="form-control">
|
|
<option value="">--- wybierz województwo ---</option>
|
|
<? foreach ($this->voivodeships as $voivodeship) : ?>
|
|
<option value="<?= $voivodeship['id']; ?>" <? if ($voivodeship['id'] == $this->advert['id_voivodeship']) : ?>selected="selected" <? endif; ?>><?= $voivodeship['name']; ?></option>
|
|
<? endforeach; ?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="city" class="col-12 col-sm-4"><?= ucfirst($lang['miasto']); ?>:</label>
|
|
<div class="col-12 col-sm-8">
|
|
<input type="text" class="form-control" required name="city" value="<?= htmlspecialchars($this->advert['city']); ?>">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<hr />
|
|
<div class="step-title"><?= ucfirst(\S::lang('dodatkowe-informacje')); ?></div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="region" class="col-12 col-sm-4"><?= ucfirst(\S::lang('proponowane-wynagrodzenie')); ?>:</label>
|
|
<div class="col-12 col-sm-8">
|
|
<input type="text" class="form-control number" name="salary" value="<?= htmlspecialchars($this->advert['salary']); ?>" required="required">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="work_type" class="col-12 col-sm-4"><?= ucfirst(\S::lang('rodzaj-pracy')); ?>:</label>
|
|
<div class="col-12 col-sm-8">
|
|
<select name="work_type" class="form-control" required="required">
|
|
<option value="0">--- <?= $lang['wybierz']; ?> ---</option>
|
|
<?
|
|
$types = \front\factory\Globelus::work_types();
|
|
if (is_array($types)) : foreach ($types as $key => $val) : ?>
|
|
<option value="<?= $key; ?>" <? if ($key == $this->advert['work_type']) : ?>selected="selected" <? endif; ?>><?= $val; ?></option>
|
|
<? endforeach;
|
|
endif;
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="without_language" class="col-12 col-sm-4"><?= ucfirst(\S::lang('oferta-dla-osob-bez-znajomosc-jezyka')); ?>:</label>
|
|
<div class="col-12 col-sm-8 pt7">
|
|
<input type="radio" name="without_language" value="0" class="checkbox" <? if (!$this->advert['without_language']) : ?>checked="checked" <? endif; ?> />nie
|
|
<input type="radio" name="without_language" value="1" class="checkbox" <? if ($this->advert['without_language']) : ?>checked="checked" <? endif; ?> />tak
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="without_experience" class="col-12 col-sm-4"><?= ucfirst(\S::lang('oferta-dla-osob-bez-doswiadczenia')); ?>:</label>
|
|
<div class="col-12 col-sm-8 pt7">
|
|
<input type="radio" name="without_experience" value="0" class="checkbox" <? if (!$this->advert['without_experience']) : ?>checked="checked" <? endif; ?> />nie
|
|
<input type="radio" name="without_experience" value="1" class="checkbox" <? if ($this->advert['without_experience']) : ?>checked="checked" <? endif; ?> />tak
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="for_couples" class="col-12 col-sm-4"><?= ucfirst(\S::lang('oferta-dla-par')); ?>:</label>
|
|
<div class="col-12 col-sm-8 pt7">
|
|
<input type="radio" name="for_couples" value="0" class="checkbox" <? if (!$this->advert['for_couples']) : ?>checked="checked" <? endif; ?> />nie
|
|
<input type="radio" name="for_couples" value="1" class="checkbox" <? if ($this->advert['for_couples']) : ?>checked="checked" <? endif; ?> />tak
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="from_now" class="col-12 col-sm-4">Pomoc z zakwaterowaniem?:</label>
|
|
<div class="col-12 col-sm-8 pt7">
|
|
<input type="radio" name="accommodation" value="0" class="checkbox accommodation" <? if (!$this->advert['accommodation']) : ?>checked="checked" <? endif; ?> />nie
|
|
<input type="radio" name="accommodation" value="1" class="checkbox accommodation" <? if ($this->advert['accommodation']) : ?>checked="checked" <? endif; ?> />tak
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="accommodation_cost" class="col-12 col-sm-4">Jaki koszt dla pracownika?:</label>
|
|
<div class="col-12 col-sm-8 pt7">
|
|
<input type="text" class="form-control" name="accommodation_cost" id="accommodation_cost" value="<?= htmlspecialchars($this->advert['accommodation_cost']); ?>" <? if ($this->advert['travel_refund']) : ?>required="required" <? endif; ?>>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="overtime" class="col-12 col-sm-4">Gwarancja godzin:</label>
|
|
<div class="col-12 col-sm-8 pt7">
|
|
<input type="radio" name="overtime" value="0" class="checkbox overtime" <? if (!$this->advert['overtime']) : ?>checked="checked" <? endif; ?> />nie
|
|
<input type="radio" name="overtime" value="1" class="checkbox overtime" <? if ($this->advert['overtime']) : ?>checked="checked" <? endif; ?> />tak
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="overtime_quantity" class="col-12 col-sm-4">Ile godzin gwarantuje pracodawca?:</label>
|
|
<div class="col-12 col-sm-8 pt7">
|
|
<input type="text" class="form-control" id="overtime_quantity" name="overtime_quantity" value="<?= htmlspecialchars($this->advert['overtime_quantity']); ?>" <? if ($this->advert['overtime']) : ?>required="required" <? endif; ?>>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="travel_refund" class="col-12 col-sm-4">Pracodawca refunduje przejazd/przelot:</label>
|
|
<div class="col-12 col-sm-8 pt7">
|
|
<input type="radio" name="travel_refund" value="0" class="checkbox" <? if (!$this->advert['travel_refund']) : ?>checked="checked" <? endif; ?> />nie
|
|
<input type="radio" name="travel_refund" value="1" class="checkbox" <? if ($this->advert['travel_refund']) : ?>checked="checked" <? endif; ?> />tak
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="outside_ue" class="col-12 col-sm-4">Praca dla obywateli spoza UE:</label>
|
|
<div class="col-12 col-sm-8 pt7">
|
|
<input type="radio" name="outside_ue" value="0" class="checkbox" <? if (!$this->advert['outside_ue']) : ?>checked="checked" <? endif; ?> />nie
|
|
<input type="radio" name="outside_ue" value="1" class="checkbox" <? if ($this->advert['outside_ue']) : ?>checked="checked" <? endif; ?> />tak
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="without_driving_license" class="col-12 col-sm-4">Oferta bez prawa jazdy:</label>
|
|
<div class="col-12 col-sm-8 pt7">
|
|
<input type="radio" name="without_driving_license" value="0" class="checkbox" <? if (!$this->advert['without_driving_license']) : ?>checked="checked" <? endif; ?> />nie
|
|
<input type="radio" name="without_driving_license" value="1" class="checkbox" <? if ($this->advert['without_driving_license']) : ?>checked="checked" <? endif; ?> />tak
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<hr />
|
|
<div class="step-title">
|
|
Zdjęcie nad ogłoszeniem
|
|
<br>
|
|
<span>
|
|
<small>
|
|
<strong>Uwaga! Jest to grafika dodatkowa, NIE logo, jeśli chcesz, aby ta grafika była widoczna jednocześnie we wszystkich Twoich ogłoszeniach dodaj ją w Profilu Pracodawcy. Zalecany rozmiar 730px x 200px.</strong>
|
|
</small>
|
|
</span>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12 col-md-6">
|
|
<div class="form-group row">
|
|
<label form="advert-img-top" class="col-12 col-sm-4">Zdjęcie (max. 1mb):</label>
|
|
<div class="col-12 col-sm-8 pt10">
|
|
<input type="file" id="advert-img-top" name="advert-img-top">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-12 col-md-6">
|
|
<div class="advert-img-top">
|
|
<? if ( file_exists(\front\factory\GlobelusFirms::advert_add_img_top_url($this->advert['id']))) :?>
|
|
<img src="/advert_add_img_top/<?= $this->advert['id']; ?>/<?= \S::get_token(); ?>" style="max-width: 200px;">
|
|
<a class="btn btn-danger advert-img-top_delete" href="#">Usuń zdjęcie</a>
|
|
<? elseif ( file_exists(\front\factory\GlobelusFirms::img_top_url( $this -> user['id'] ) ) ):?>
|
|
<img src="/img_header/<?= $this-> user['id'];?>/<?= \S::get_token();?>" style="max-width: 200px;">
|
|
<? endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</hr>
|
|
<hr>
|
|
<div class="step-title">
|
|
Zdjęcie pod ogłoszeniem
|
|
<br>
|
|
<span>
|
|
<small>
|
|
<strong>Uwaga! Jest to grafika dodatkowa, NIE logo, jeśli chcesz, aby ta grafika była widoczna jednocześnie we wszystkich Twoich ogłoszeniach dodaj ją w Profilu Pracodawcy. Zalecany rozmiar 730px x 200px.</strong>
|
|
</small>
|
|
</span>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12 col-md-6">
|
|
<div class="form-group row">
|
|
<label form="advert-img-bottom" class="col-12 col-sm-4">Zdjęcie (max. 1mb):</label>
|
|
<div class="col-12 col-sm-8 pt10">
|
|
<input type="file" id="advert-img-bottom" name="advert-img-bottom">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-12 col-md-6">
|
|
<div class="advert-img-bottom">
|
|
<? if (file_exists(\front\factory\GlobelusFirms::advert_add_img_bottom_url($this->advert['id']))) :?>
|
|
<img src="/advert_add_img_bottom/<?= $this->advert['id']; ?>/<?= \S::get_token(); ?>" style="max-width: 200px;">
|
|
<a class="btn btn-danger advert-img-bottom_delete" href="#">Usuń zdjęcie</a>
|
|
<? elseif (file_exists(\front\factory\GlobelusFirms::img_bottom_url($this->user['id']))) :?>
|
|
<img src="/img_bottom/<?= $this->user['id']; ?>/<?= \S::get_token(); ?>" style="max-width: 200px;">
|
|
<? endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</hr>
|
|
<hr>
|
|
<div class="step-title"><?= ucfirst($lang['tresc-ogloszenia-opis-wymagania']); ?></div>
|
|
<div class="subtitle warrning"><?= ucfirst($lang['tresc-ogloszenia-ostrzezenie']); ?></div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<textarea name="text" id="text"><?= $this->advert['text']; ?></textarea>
|
|
<p class="hidden editor-error">Proszę uzupełnić treść ogłoszenia.</p>
|
|
</div>
|
|
</div>
|
|
<div class="row mt-3">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="application_link" class="col-12 col-sm-4">Link do własnego formularza aplikacji:</label>
|
|
<div class="col-12 col-sm-8">
|
|
<input type="text" class="form-control" name="aplication_link" value="<?= htmlspecialchars($this->advert['aplication_link']);?>">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<hr />
|
|
<div class="step-title">Osoba rekrutująca na stanowisko</div>
|
|
<div class="row">
|
|
<div class="col-12 col-md-6">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="contact_person" class="col-12 col-sm-4"><?= ucfirst($lang['osoba-do-kontaktu']); ?>:</label>
|
|
<div class="col-12 col-sm-8">
|
|
<input type="text" class="form-control" name="contact_person" value="<?= $this->advert['id'] ? htmlspecialchars($this->advert['contact_person']) : htmlspecialchars($this->user['contact_person_1']); ?>">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="email" class="col-12 col-sm-4"><?= ucfirst($lang['email']); ?>:</label>
|
|
<div class="col-12 col-sm-8">
|
|
<input type="text" class="form-control" name="email" value="<?= $this->advert['id'] ? htmlspecialchars($this->advert['email']) : htmlspecialchars($this->user['email_1']); ?>">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="form-group row">
|
|
<label form="phone" class="col-12 col-sm-4"><?= ucfirst($lang['telefon']); ?>:</label>
|
|
<div class="col-12 col-sm-8">
|
|
<input type="text" class="form-control" name="phone" value="<?= $this->advert['id'] ? htmlspecialchars($this->advert['phone']) : htmlspecialchars($this->user['phone_1']); ?>">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12 col-md-6">
|
|
<div class="form-group row">
|
|
<div class="col-12 mt20">
|
|
<a href="/panel-pracodawcy/ogloszenia" class="btn btn-danger mr15"><?= ucfirst($lang['anuluj']); ?></a>
|
|
<input type="submit" value="<?= ucfirst($lang['zapisz']); ?>" class="btn btn-success">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<link class="footer" rel="stylesheet" type="text/css" href="/plugins/summernote/summernote-lite.css">
|
|
<link class="footer" rel="stylesheet" type="text/css" href="/plugins/selectize/css/selectize.bootstrap3.css">
|
|
<script class="footer" type="text/javascript" src="/plugins/popper.js"></script>
|
|
<script class="footer" type="text/javascript" src="/plugins/summernote/summernote-lite.js"></script>
|
|
<script class="footer" type="text/javascript" src="/plugins/summernote/lang/summernote-pl-PL.js"></script>
|
|
<script class="footer" type="text/javascript" src="/plugins/selectize/js/selectize.js"></script>
|
|
<script class="footer" type="text/javascript">
|
|
$(function() {
|
|
|
|
$( '#category' ).selectize({
|
|
maxItems: 1
|
|
});
|
|
|
|
$( '#country' ).selectize({
|
|
maxItems: 1
|
|
});
|
|
|
|
$( '#position' ).selectize({
|
|
maxItems: 1
|
|
});
|
|
|
|
$('body').on('change', '#country', function() {
|
|
if ($(this).val() == '1')
|
|
$('.row.voivodeship').show();
|
|
else
|
|
$('.row.voivodeship').hide();
|
|
});
|
|
|
|
$('#country').trigger("change");
|
|
|
|
$('.accommodation').on('ifChecked', function(event) {
|
|
if ($(this).attr("value") == "0")
|
|
$("#accommodation_cost").removeAttr('required');
|
|
|
|
if ($(this).attr("value") == "1")
|
|
$("#accommodation_cost").attr('required', 'required');
|
|
});
|
|
|
|
$('.overtime').on('ifChecked', function(event) {
|
|
if ($(this).attr("value") == "0")
|
|
$("#overtime_quantity").removeAttr('required');
|
|
|
|
if ($(this).attr("value") == "1")
|
|
$("#overtime_quantity").attr('required', 'required');
|
|
});
|
|
|
|
$('body').on('submit', '#advert-add', function(e) {
|
|
e.preventDefault();
|
|
if (document.activeElement) {
|
|
document.activeElement.blur();
|
|
}
|
|
|
|
var text = $('#text').summernote('code');
|
|
text = text.replace(/(<([^>]+)>)/ig, '');
|
|
text = text.replace(/ /g, '');
|
|
|
|
if ($.trim(text) === '') {
|
|
$('#text').parent('.col-12').children('.note-editor').addClass('error');
|
|
$('#text').parent('.col-12').children('.editor-error').removeClass('hidden');
|
|
$('html, body').animate({
|
|
scrollTop: $('#text').parent('.col-12').children('.note-editor').offset().top - 100
|
|
}, 100);
|
|
return;
|
|
} else {
|
|
$('#text').parent('.col-12').children('.note-editor').removeClass('error');
|
|
$('#text').parent('.col-12').children('.editor-error').addClass('hidden');
|
|
}
|
|
|
|
var work_type = $('select[name="work_type"]').val();
|
|
if (work_type == 0) {
|
|
$('select[name="work_type"]').addClass('error').focus();
|
|
return;
|
|
} else {
|
|
$('select[name="work_type"]').removeClass('error');
|
|
}
|
|
|
|
const headerInput = $('#advert-img-top')[0];
|
|
const bottomInput = $('#advert-img-bottom')[0];
|
|
const imageChecks = [];
|
|
|
|
if (headerInput && headerInput.files && headerInput.files.length) {
|
|
imageChecks.push(getImageSize(headerInput.files[0]).then(size => {
|
|
if (!isValidRatio(size)) {
|
|
throw new Error('header');
|
|
}
|
|
}));
|
|
}
|
|
|
|
if (bottomInput && bottomInput.files && bottomInput.files.length) {
|
|
imageChecks.push(getImageSize(bottomInput.files[0]).then(size => {
|
|
if (!isValidRatio(size)) {
|
|
throw new Error('bottom');
|
|
}
|
|
}));
|
|
}
|
|
|
|
Promise.allSettled(imageChecks).then(results => {
|
|
const rejected = results.find(r => r.status === 'rejected');
|
|
if (rejected) {
|
|
let scrollTarget;
|
|
let label;
|
|
|
|
if (rejected.reason.message === 'header') {
|
|
scrollTarget = $('#advert-img-top');
|
|
label = 'górny';
|
|
} else if (rejected.reason.message === 'bottom') {
|
|
scrollTarget = $('#advert-img-bottom');
|
|
label = 'dolny';
|
|
}
|
|
|
|
if (scrollTarget && scrollTarget.length) {
|
|
$('html, body').animate({
|
|
scrollTop: scrollTarget.offset().top - 100
|
|
}, 200);
|
|
}
|
|
|
|
showAlert(`Obrazek ${label} ma nieprawidłowe proporcje. Dozwolony zakres to 2.66:1 do 8:1.`);
|
|
return;
|
|
}
|
|
|
|
e.target.submit();
|
|
});
|
|
|
|
function isValidRatio({ width, height }) {
|
|
const ratio = width / height;
|
|
return ratio >= 2.6667 && ratio <= 8.0;
|
|
}
|
|
|
|
function getImageSize(file) {
|
|
return new Promise((resolve, reject) => {
|
|
const img = new Image();
|
|
img.onload = function () {
|
|
resolve({ width: this.naturalWidth, height: this.naturalHeight });
|
|
};
|
|
img.onerror = () => reject(new Error('invalid-image'));
|
|
|
|
const reader = new FileReader();
|
|
reader.onload = function (e) {
|
|
img.src = e.target.result;
|
|
};
|
|
reader.readAsDataURL(file);
|
|
});
|
|
}
|
|
|
|
function showAlert(message) {
|
|
$.alert({
|
|
title: 'Błąd',
|
|
icon: 'fa fa-exclamation',
|
|
content: message,
|
|
type: 'blue',
|
|
closeIcon: true,
|
|
closeIconClass: 'fa fa-close',
|
|
typeAnimated: true,
|
|
animation: 'opacity',
|
|
autoClose: 'confirm|10000',
|
|
columnClass: 'large',
|
|
theme: 'modern',
|
|
buttons: {
|
|
confirm: {
|
|
text: 'Zamknij',
|
|
btnClass: 'btn-blue',
|
|
keys: ['enter'],
|
|
action: function () {}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
$('#text').summernote({
|
|
height: 200,
|
|
lang: 'pl-PL',
|
|
toolbar: [
|
|
['style', ['bold', 'italic', 'underline', 'clear']],
|
|
['font', ['strikethrough', 'superscript', 'subscript']],
|
|
['fontsize', ['fontsize']],
|
|
['height', ['height']],
|
|
['color', ['color']],
|
|
['para', ['ul', 'ol', 'paragraph']],
|
|
['table', ['table']]
|
|
]
|
|
});
|
|
});
|
|
|
|
|
|
/*usuwanie zdjecia top */
|
|
$( function()
|
|
{
|
|
$( 'body' ).on( click_event, '.advert-img-top_delete', function()
|
|
{
|
|
$.alert(
|
|
{
|
|
title: '<?= ucfirst( $lang['potwierdz'] );?>',
|
|
icon: 'fa fa-exclamation',
|
|
content: 'Czy napewno chcesz usunąć zdjęcie górne?',
|
|
closeIcon: true,
|
|
closeIconClass: 'fa fa-close',
|
|
typeAnimated: true,
|
|
animation: 'opacity',
|
|
columnClass: 'large',
|
|
theme: 'modern',
|
|
buttons:
|
|
{
|
|
cancel:
|
|
{
|
|
text: '<?= $lang['anuluj'];?>',
|
|
action: function() {}
|
|
},
|
|
confirm:
|
|
{
|
|
text: '<?= $lang['zatwierdz'];?>',
|
|
btnClass: 'btn-blue',
|
|
keys: ['enter'],
|
|
action: function()
|
|
{
|
|
$.ajax(
|
|
{
|
|
type: 'POST',
|
|
url: '/globelusFirms/delete_advert_img_top/',
|
|
data:
|
|
{
|
|
id: <?= (int)$this -> advert['id'];?>
|
|
},
|
|
beforeSend: function() {},
|
|
success: function( response )
|
|
{
|
|
var data = jQuery.parseJSON( response );
|
|
if ( data.result == 'ok' ) {
|
|
const img_header = document.querySelector(".advert-img-top");
|
|
img_header.classList.add("img-hide");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
/*usuwanie zdjecia bottom */
|
|
$( function()
|
|
{
|
|
$( 'body' ).on( click_event, '.advert-img-bottom_delete', function()
|
|
{
|
|
$.alert(
|
|
{
|
|
title: '<?= ucfirst( $lang['potwierdz'] );?>',
|
|
icon: 'fa fa-exclamation',
|
|
content: 'Czy napewno chcesz usunąć zdjęcie dolne?',
|
|
closeIcon: true,
|
|
closeIconClass: 'fa fa-close',
|
|
typeAnimated: true,
|
|
animation: 'opacity',
|
|
columnClass: 'large',
|
|
theme: 'modern',
|
|
buttons:
|
|
{
|
|
cancel:
|
|
{
|
|
text: '<?= $lang['anuluj'];?>',
|
|
action: function() {}
|
|
},
|
|
confirm:
|
|
{
|
|
text: '<?= $lang['zatwierdz'];?>',
|
|
btnClass: 'btn-blue',
|
|
keys: ['enter'],
|
|
action: function()
|
|
{
|
|
$.ajax(
|
|
{
|
|
type: 'POST',
|
|
url: '/globelusFirms/delete_advert_img_bottom/',
|
|
data:
|
|
{
|
|
id: <?= (int)$this -> advert['id'];?>
|
|
},
|
|
beforeSend: function() {},
|
|
success: function( response )
|
|
{
|
|
var data = jQuery.parseJSON( response );
|
|
if ( data.result == 'ok' ) {
|
|
const img_header = document.querySelector(".advert-img-bottom");
|
|
img_header.classList.add("img-hide");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|