first commit
0
.gitignore
vendored
Normal file
25
.htaccess
Normal file
@@ -0,0 +1,25 @@
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
Options +FollowSymlinks
|
||||
Options -Indexes
|
||||
|
||||
RewriteCond %{HTTP_HOST} ^bilety\.brzezovka\.pl$
|
||||
RewriteRule ^$ /tickets/main_view/ [L,R=301]
|
||||
|
||||
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
|
||||
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
|
||||
RewriteCond %{SERVER_PORT} !=443
|
||||
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]
|
||||
|
||||
RewriteCond %{REQUEST_URI} !^(.*)/libraries/(.*) [NC]
|
||||
RewriteCond %{REQUEST_URI} !^(.*)/layout/(.*) [NC]
|
||||
RewriteCond %{REQUEST_URI} !^(.*)/resources/(.*) [NC]
|
||||
RewriteCond %{REQUEST_URI} !^(.*)/images/(.*) [NC]
|
||||
RewriteCond %{REQUEST_URI} !^(.*)/orders/(.*) [NC]
|
||||
RewriteCond %{REQUEST_URI} !^(.*)/posters_images/(.*) [NC]
|
||||
RewriteCond %{REQUEST_URI} !^(.*)/domain_tester_images/(.*) [NC]
|
||||
RewriteRule ^([^/]*)/([^/]*)/(.*)$ index.php?module=$1&action=$2&$3 [L]
|
||||
|
||||
#RewriteRule $ index.php?module=tickets&action=main_view [L]
|
||||
RewriteRule ^logowanie$ index.php?module=users&action=login_form [L]
|
||||
RewriteRule ^finances/tags.json$ index.php?module=finances&action=tags_json [L]
|
||||
17
.vscode/ftp-kr.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"host": "brzezovka.pl",
|
||||
"username": "jacek@brzezovka.pl",
|
||||
"password": "nKc36zNdv3fhh5qSRJu5",
|
||||
"remotePath": "/public_html/tickets/",
|
||||
"protocol": "ftp",
|
||||
"port": 0,
|
||||
"fileNameEncoding": "utf8",
|
||||
"autoUpload": true,
|
||||
"autoDelete": false,
|
||||
"autoDownload": false,
|
||||
"ignoreRemoteModification": true,
|
||||
"ignore": [
|
||||
".git",
|
||||
"/.vscode"
|
||||
]
|
||||
}
|
||||
94
.vscode/ftp-kr.sync.cache.json
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"ftp://brzezovka.pl@www@bilety.brzezovka.pl": {
|
||||
"public_html": {
|
||||
".gitignore": {
|
||||
"type": "-",
|
||||
"size": 0,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
".htaccess": {
|
||||
"type": "-",
|
||||
"size": 1031,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"ajax.php": {
|
||||
"type": "-",
|
||||
"size": 1208,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"api.php": {
|
||||
"type": "-",
|
||||
"size": 10554,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"autoload": {},
|
||||
"config.php": {
|
||||
"type": "-",
|
||||
"size": 4002,
|
||||
"lmtime": 0,
|
||||
"modified": true
|
||||
},
|
||||
"cron.php": {
|
||||
"type": "-",
|
||||
"size": 2636,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"custom.php": {
|
||||
"type": "-",
|
||||
"size": 2433,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"index.php": {
|
||||
"type": "-",
|
||||
"size": 1624,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"layout": {},
|
||||
"libraries": {},
|
||||
"orders": {},
|
||||
"templates": {
|
||||
"site": {
|
||||
"layout-cron.php": {
|
||||
"type": "-",
|
||||
"size": 2512,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"layout-logged.php": {
|
||||
"type": "-",
|
||||
"size": 5833,
|
||||
"lmtime": 1713172556038,
|
||||
"modified": false
|
||||
},
|
||||
"layout-unlogged.php": {
|
||||
"type": "-",
|
||||
"size": 4356,
|
||||
"lmtime": 1713172558543,
|
||||
"modified": false
|
||||
},
|
||||
"regulamin.php": {
|
||||
"type": "-",
|
||||
"size": 9529,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"test.txt": {
|
||||
"type": "-",
|
||||
"size": 348,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"upload": {}
|
||||
}
|
||||
},
|
||||
"$version": 1
|
||||
}
|
||||
14
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"liveSassCompile.settings.formats": [
|
||||
{
|
||||
"format": "compressed",
|
||||
"extensionName": ".css",
|
||||
"savePath": "~/../style-css/",
|
||||
"savePathSegmentKeys": null,
|
||||
"savePathReplaceSegmentsWith": null
|
||||
}
|
||||
],
|
||||
"liveSassCompile.settings.generateMap": true,
|
||||
"liveSassCompile.settings.autoprefix": "defaults",
|
||||
"liveSassCompile.settings.watchOnLaunch": true
|
||||
}
|
||||
12
.vscode/sftp.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "brzezovka.pl",
|
||||
"host": "brzezovka.pl",
|
||||
"protocol": "ftp",
|
||||
"port": 21,
|
||||
"username": "jacek@brzezovka.pl",
|
||||
"password": "nKc36zNdv3fhh5qSRJu5",
|
||||
"remotePath": "/public_html/tickets/",
|
||||
"uploadOnSave": false,
|
||||
"useTempFile": false,
|
||||
"openSsh": false
|
||||
}
|
||||
45
ajax.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
error_reporting( E_ALL ^ E_NOTICE ^ E_STRICT ^ E_WARNING ^ E_DEPRECATED );
|
||||
function __autoload_my_classes( $classname )
|
||||
{
|
||||
$q = explode( '\\' , $classname );
|
||||
$c = array_pop( $q );
|
||||
$f = 'autoload/' . implode( '/' , $q ) . '/class.' . $c . '.php';
|
||||
|
||||
if ( file_exists( $f ) )
|
||||
require_once( $f );
|
||||
}
|
||||
spl_autoload_register( '__autoload_my_classes' );
|
||||
date_default_timezone_set( 'Europe/Warsaw' );
|
||||
|
||||
require_once 'config.php';
|
||||
require_once 'libraries/medoo/medoo.php';
|
||||
require_once 'libraries/grid/config.php';
|
||||
|
||||
session_start();
|
||||
|
||||
if ( !isset( $_SESSION['check'] ) )
|
||||
{
|
||||
session_regenerate_id();
|
||||
$_SESSION['check'] = true;
|
||||
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
if ( $_SESSION['ip'] !== $_SERVER['REMOTE_ADDR'] )
|
||||
{
|
||||
session_destroy();
|
||||
header( 'Location: /' );
|
||||
exit;
|
||||
}
|
||||
|
||||
$mdb = new medoo( [
|
||||
'database_type' => 'mysql',
|
||||
'database_name' => $database['name'],
|
||||
'server' => $database['host'],
|
||||
'username' => $database['user'],
|
||||
'password' => $database['password'],
|
||||
'charset' => 'utf8'
|
||||
] );
|
||||
|
||||
$user = \S::get_session( 'user' );
|
||||
?>
|
||||
288
api.php
Normal file
@@ -0,0 +1,288 @@
|
||||
<?php
|
||||
error_reporting( E_ALL ^ E_NOTICE ^ E_STRICT ^ E_WARNING ^ E_DEPRECATED );
|
||||
|
||||
function __autoload_my_classes( $classname )
|
||||
{
|
||||
$q = explode( '\\', $classname );
|
||||
$c = array_pop( $q );
|
||||
$f = 'autoload/' . implode( '/', $q ) . '/class.' . $c . '.php';
|
||||
|
||||
if ( file_exists( $f ) )
|
||||
require_once( $f );
|
||||
}
|
||||
spl_autoload_register( '__autoload_my_classes' );
|
||||
date_default_timezone_set( 'Europe/Warsaw' );
|
||||
|
||||
require_once 'config.php';
|
||||
require_once 'libraries/medoo/medoo.php';
|
||||
require_once 'libraries/grid/config.php';
|
||||
require_once 'libraries/phpmailer/class.phpmailer.php';
|
||||
require_once 'libraries/phpmailer/class.smtp.php';
|
||||
require_once 'libraries/rb.php';
|
||||
|
||||
session_start();
|
||||
|
||||
$mdb = new medoo( [
|
||||
'database_type' => 'mysql',
|
||||
'database_name' => $database['name'],
|
||||
'server' => $database['host'],
|
||||
'username' => $database['user'],
|
||||
'password' => $database['password'],
|
||||
'charset' => 'utf8'
|
||||
] );
|
||||
|
||||
\R::setup( 'mysql:host=' . $database['host'] . ';dbname=' . $database['name'], $database['user'], $database['password'] );
|
||||
\R::ext( 'xdispense', function( $type )
|
||||
{
|
||||
return R::getRedBean() -> dispense( $type );
|
||||
} );
|
||||
|
||||
/* usuwanie lock_id z domain_tester */
|
||||
\R::exec( 'UPDATE domain_tester SET lock_id = null, lock_date = null WHERE lock_id IS NOT NULL AND DATE_ADD( lock_date, INTERVAL 5 MINUTE ) <= \'' . date( 'Y-m-d H:i:s' ) . '\'' );
|
||||
$mdb -> query( 'UPDATE domain_tester SET url_status_date = NULL WHERE url_status_date <= \'' . date( 'Y-m-d H:i:s', strtotime( '-3 days', strtotime( date( 'Y-m-d H:i:s' ) ) ) ) . '\'' );
|
||||
|
||||
|
||||
/* zapisywanie domen do rejestracji */
|
||||
if ( \S::get( 'action' ) == 'domain_register_save' )
|
||||
{
|
||||
$result = explode( '|', \S::get( 'result' ) );
|
||||
|
||||
$domain = \R::load( 'domain_tester', \S::get( 'domain_id' ) );
|
||||
|
||||
if ( \S::get( 'result' ) == 'free' )
|
||||
{
|
||||
$domain -> free_to_register = 1;
|
||||
$domain -> ostatnia_modyfikacja = date( 'Y-m-d' );
|
||||
$domain -> koniec_okres_rozliczeniowego = date( 'Y-m-d' );
|
||||
$domain -> register_date = date( 'Y-m-d' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$domain -> ostatnia_modyfikacja = $result[3];
|
||||
$domain -> koniec_okres_rozliczeniowego = $result[5];
|
||||
$domain -> register_date = $result[1];
|
||||
}
|
||||
\R::store( $domain );
|
||||
|
||||
echo json_encode( ['result' => 'ok'] );
|
||||
exit;
|
||||
}
|
||||
|
||||
/* sprawdzanie domen do rejestracji */
|
||||
if ( \S::get( 'action' ) == 'domain_register_check' )
|
||||
{
|
||||
$domain = \R::findOne( 'domain_tester', 'majestic_status = 1 AND cf >= 10 AND tf >= 10 AND url_status = 0 AND register_date IS NULL ORDER BY date_add ASC' );
|
||||
if ( $domain )
|
||||
{
|
||||
$result['id'] = $domain -> id;
|
||||
$result['url'] = $domain -> url;
|
||||
$result['domains_left'] = \R::count( 'domain_tester', 'majestic_status = 1 AND cf >= 10 AND tf >= 10 AND url_status = 0 AND register_date IS NULL ' );
|
||||
$result['result'] = 'ok';
|
||||
|
||||
echo json_encode( $result );
|
||||
}
|
||||
else
|
||||
echo json_encode( ['result' => 'bad'] );
|
||||
}
|
||||
|
||||
/* zapisywanie parametrów majestic */
|
||||
if ( \S::get( 'action' ) == 'domain_majestic_save' )
|
||||
{
|
||||
$results = json_decode( \S::get( 'result' ), true );
|
||||
|
||||
$domain = \R::load( 'domain_tester', \S::get( 'domain_id' ) );
|
||||
$domain -> feb = $results['ExtBackLinks'];
|
||||
$domain -> cf = $results['CitationFlow'];
|
||||
$domain -> tf = $results['TrustFlow'];
|
||||
$domain -> rd = $results['RefDomains'];
|
||||
$domain -> majestic_status = 1;
|
||||
\R::store( $domain );
|
||||
|
||||
echo json_encode( ['result' => 'ok'] );
|
||||
}
|
||||
|
||||
/* pobieranie parametrów majetic */
|
||||
if ( \S::get( 'action' ) == 'domain_majestic_check' )
|
||||
{
|
||||
$domain = \R::findOne( 'domain_tester', 'opr IS NOT NULL AND opr >= 3 AND majestic_status = 0 AND url_status = 0 AND url_status_date IS NOT NULL ORDER BY date_add ASC' );
|
||||
if ( $domain )
|
||||
{
|
||||
$result['id'] = $domain -> id;
|
||||
$result['url'] = $domain -> url;
|
||||
$result['domains_left'] = \R::count( 'domain_tester', 'opr IS NOT NULL AND opr >= 3 AND majestic_status = 0 AND url_status = 0 AND url_status_date IS NOT NULL' );
|
||||
$result['result'] = 'ok';
|
||||
|
||||
echo json_encode( $result );
|
||||
}
|
||||
else
|
||||
echo json_encode( ['result' => 'bad'] );
|
||||
}
|
||||
|
||||
if ( \S::get( 'action' ) == 'semstorm_traffic_domain_tester_save' )
|
||||
{
|
||||
$results = json_decode( \S::get( 'result' ), true );
|
||||
|
||||
foreach ( $results['results'][\S::get( 'url' )] as $key => $val )
|
||||
{
|
||||
if ( $key <= 3 )
|
||||
$top3 += $val;
|
||||
|
||||
if ( $key > 3 and $key <= 10 )
|
||||
$top10 += $val;
|
||||
|
||||
if ( $key > 10 )
|
||||
$top50 += $val;
|
||||
}
|
||||
|
||||
$domain = \R::load( 'domain_tester', \S::get( 'domain_id' ) );
|
||||
$domain -> semstorm_status = 1;
|
||||
$domain -> sem_traffic = $results['results'][\S::get( 'url' )]['traffic'];
|
||||
$domain -> semstorm_date = date( 'Y-m-d H:i:s' );
|
||||
\R::store( $domain );
|
||||
|
||||
echo json_encode( ['result' => 'ok'] );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( \S::get( 'action' ) == 'domain_test_url_check' )
|
||||
{
|
||||
$pdo = R::getPDO();
|
||||
|
||||
$lock_id = md5( time() . rand( 0, 9999999999 ) );
|
||||
|
||||
\R::exec( 'UPDATE '
|
||||
. 'domain_tester SET lock_id = ' . $pdo -> quote( $lock_id ) . ', lock_date = ' . $pdo -> quote( date( 'Y-m-d H:i:s' ) ) . ' '
|
||||
. 'WHERE '
|
||||
. 'lock_id IS NULL '
|
||||
. 'AND '
|
||||
. '( '
|
||||
. 'url_status IS NULL '
|
||||
. 'OR '
|
||||
. '( '
|
||||
. 'url_status = 0 '
|
||||
. 'AND '
|
||||
. '( url_status_date IS NULL OR url_status_date <= ' . $pdo -> quote( date( 'Y-m-d H:i:s', strtotime( '-3 days', strtotime( date( 'Y-m-d H:i:s' ) ) ) ) ) . ' ) '
|
||||
. ') '
|
||||
. ') '
|
||||
. 'ORDER BY date_add DESC LIMIT 1'
|
||||
);
|
||||
|
||||
$domain = \R::findOne( 'domain_tester', 'lock_id = ?', [$lock_id] );
|
||||
if ( $domain )
|
||||
{
|
||||
$result['lock_id'] = $lock_id;
|
||||
$result['id'] = $domain -> id;
|
||||
$result['url'] = $domain -> url;
|
||||
$result['domains_left'] = \R::count( 'domain_tester', 'url_status IS NULL OR ( url_status = 0 AND ( url_status_date IS NULL OR url_status_date <= ' . $pdo -> quote( date( 'Y-m-d H:i:s', strtotime( '-3 days', strtotime( date( 'Y-m-d H:i:s' ) ) ) ) ) . ' ) )' );
|
||||
$result['result'] = 'ok';
|
||||
|
||||
echo json_encode( $result );
|
||||
}
|
||||
else
|
||||
echo json_encode( ['result' => 'bad'] );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( \S::get( 'action' ) == 'domain_test_url_save' )
|
||||
{
|
||||
$domain = \R::load( 'domain_tester', \S::get( 'domain_id' ) );
|
||||
$domain -> url_status = \S::get( 'result' );
|
||||
$domain -> url_status_date = date( 'Y-m-d H:i:s' );
|
||||
$domain -> lock_id = null;
|
||||
$domain -> lock_date = null;
|
||||
\R::store( $domain );
|
||||
|
||||
echo json_encode( ['result' => 'ok'] );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( \S::get( 'action' ) == 'ceidg_firm_save' )
|
||||
{
|
||||
$ceidg = \R::findOne( 'ceidg', 'hash = ?', [\S::get( 'hash' )] );
|
||||
if ( !$ceidg )
|
||||
{
|
||||
$ceidg = \R::xdispense( 'ceidg' );
|
||||
$ceidg -> hash = \S::get( 'hash' );
|
||||
}
|
||||
|
||||
$ceidg -> imie_nazwisko = \S::get( 'dp_imie' ) . ' ' . \S::get( 'dp_nazwisko' );
|
||||
$ceidg -> nip = \S::get( 'dp_nip' );
|
||||
$ceidg -> regon = \S::get( 'dp_regon' );
|
||||
$ceidg -> firma = \S::get( 'dp_firma' );
|
||||
$ceidg -> email = strtolower( \S::get( 'dk_email' ) );
|
||||
$ceidg -> www = \S::get( 'dk_www' );
|
||||
$ceidg -> telefon = \S::get( 'dk_telefon' );
|
||||
$ceidg -> faks = \S::get( 'dk_faks' );
|
||||
|
||||
$ceidg -> ad1_terc = \S::get( 'da_ad1_terc' );
|
||||
$ceidg -> ad1_simc = \S::get( 'da_ad1_simc' );
|
||||
$ceidg -> ad1_ulic = \S::get( 'da_ad1_ulic' );
|
||||
|
||||
$ceidg -> ad1_miejscowosc = \S::get( 'da_ad1_miejscowosc' );
|
||||
$ceidg -> ad1_ulica = \S::get( 'da_ad1_ulica' );
|
||||
$ceidg -> ad1_budynek = \S::get( 'da_ad1_budynek' );
|
||||
$ceidg -> ad1_lokal = \S::get( 'da_ad1_lokal' );
|
||||
$ceidg -> ad1_kod_pocztowy = \S::get( 'da_ad1_kod_pocztowy' );
|
||||
$ceidg -> ad1_poczta = \S::get( 'da_ad1_poczta' );
|
||||
$ceidg -> ad1_gmina = \S::get( 'da_ad1_gmina' );
|
||||
$ceidg -> ad1_powiat = \S::get( 'da_ad1_powiat' );
|
||||
$ceidg -> ad1_wojewodztwo = mb_strtolower( \S::get( 'da_ad1_wojewodztwo' ), 'UTF-8' );
|
||||
|
||||
$ceidg -> ad2_terc = \S::get( 'da_ad2_terc' );
|
||||
$ceidg -> ad2_simc = \S::get( 'da_ad2_simc' );
|
||||
$ceidg -> ad2_ulic = \S::get( 'da_ad2_ulic' );
|
||||
|
||||
$ceidg -> ad2_miejscowosc = \S::get( 'da_ad2_miejscowosc' );
|
||||
$ceidg -> ad2_ulica = \S::get( 'da_ad2_ulica' );
|
||||
$ceidg -> ad2_budynek = \S::get( 'da_ad2_budynek' );
|
||||
$ceidg -> ad2_lokal = \S::get( 'da_ad2_lokal' );
|
||||
$ceidg -> ad2_kod_pocztowy = \S::get( 'da_ad2_kod_pocztowy' );
|
||||
$ceidg -> ad2_poczta = \S::get( 'da_ad2_poczta' );
|
||||
$ceidg -> ad2_gmina = \S::get( 'da_ad2_gmina' );
|
||||
$ceidg -> ad2_powiat = \S::get( 'da_ad2_powiat' );
|
||||
$ceidg -> ad2_wojewodztwo = mb_strtolower( \S::get( 'da_ad2_wojewodztwo' ), 'UTF-8' );
|
||||
|
||||
$ceidg -> obywatelstwo = \S::get( 'da_obywatelstwo' );
|
||||
|
||||
$ceidg -> rozpoczecie_dzialalnosci = \S::get( 'dd_rozpoczecie_dzialalnosci' );
|
||||
$ceidg -> zawieszenie_dzialalnosci = \S::get( 'dd_zawieszenie_dzialalnosci' ) ? \S::get( 'dd_zawieszenie_dzialalnosci' ) : null;
|
||||
$ceidg -> wznowienie_dzialalnosci = \S::get( 'dd_wznowienie_dzialalnosci' ) ? \S::get( 'dd_wznowienie_dzialalnosci' ) : null;
|
||||
$ceidg -> zaprzestanie_dzialalnosci = \S::get( 'dd_zaprzestanie_dzialalnosci' ) ? \S::get( 'dd_zaprzestanie_dzialalnosci' ) : null;
|
||||
$ceidg -> data_wykreslenia = \S::get( 'dd_wykreslenie_dzialalnosci' ) ? \S::get( 'dd_wykreslenie_dzialalnosci' ) : null;
|
||||
$ceidg -> wspolnosc_majatkowa = \S::get( 'dd_wspolnosc_majatkowa' );
|
||||
$ceidg -> status = mb_strtolower( \S::get( 'dd_status' ), 'UTF-8' );
|
||||
$ceidg -> pkd = \S::get( 'dd_pkd' );
|
||||
|
||||
$ceidg -> spolki_cywilne = \S::get( 'spolki_cywilne' );
|
||||
$ceidg -> zakazy = \S::get( 'zakazy' );
|
||||
$ceidg -> postepowanie_naprawcze = \S::get( 'postepowanie_naprawcze' );
|
||||
$ceidg -> pelnomocnicy = \S::get( 'pelnomocnicy' );
|
||||
|
||||
\R::store( $ceidg );
|
||||
|
||||
echo 'ok';
|
||||
exit;
|
||||
}
|
||||
|
||||
/* ceidg generowanie excela i wysyłanie go mailem */
|
||||
if ( \S::get( 'action' ) == 'firm_list_for_email' )
|
||||
{
|
||||
$response = \Cron::ceidg_send_excel();
|
||||
if ( $response['status'] == 'ok' )
|
||||
echo 'ok';
|
||||
else
|
||||
echo 'bad';
|
||||
exit;
|
||||
}
|
||||
|
||||
// if ( \S::get( 'action' ) == 'nowe' )
|
||||
// {
|
||||
// $results = $mdb -> select( 'ceidg', '*', [ 'AND' => [ 'status' => 'Aktywny', 'OR' => [ 'pkd[~]' => '6831', 'pkd[~]' => '6820' ] ], 'LIMIT' => [ 200001, 100000 ] ] );
|
||||
|
||||
// $fp = fopen( 'ceidg.csv', 'w');
|
||||
// fputs( $fp, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ) );
|
||||
// foreach ( $results as $row )
|
||||
// fputcsv( $fp, $row, ';' );
|
||||
|
||||
// fclose( $fp );
|
||||
// }
|
||||
9
autoload/.htaccess
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
RewriteRule ^index\.php$ - [L]
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule . /index.php [L]
|
||||
</IfModule>
|
||||
536
autoload/class.Cron.php
Normal file
@@ -0,0 +1,536 @@
|
||||
<?php
|
||||
|
||||
class Cron
|
||||
{
|
||||
static public function ceidg_send_excel()
|
||||
{
|
||||
global $mdb;
|
||||
$results = $mdb -> select( 'ceidg', '*', [ 'AND' => [
|
||||
'date_add[>=]' => date( 'Y-m-d', strtotime( '-7 days', time() ) ),
|
||||
'date_add[<]' => date( 'Y-m-d' ),
|
||||
'status' => 'Aktywny',
|
||||
'telefon[!]' => ''
|
||||
]
|
||||
], [
|
||||
'ORDERY' => [ 'date_add' => 'ASC' ]
|
||||
] );
|
||||
|
||||
$title = "CEIDG";
|
||||
$xls = new \Excel($title);
|
||||
$xls -> home();
|
||||
$xls -> label( 'Data dodania' );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( 'Data rozpoczęcia działalności' ) );
|
||||
$xls -> right();
|
||||
$xls -> label( 'Firma' );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( 'Imię i nazwisko' ) );
|
||||
$xls -> right();
|
||||
$xls -> label( 'NIP' );
|
||||
$xls -> right();
|
||||
$xls -> label( 'Regon' );
|
||||
$xls -> right();
|
||||
$xls -> label( 'Telefon' );
|
||||
$xls -> right();
|
||||
$xls -> label( 'Email' );
|
||||
$xls -> right();
|
||||
$xls -> label( 'www' );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( 'Województwo' ) );
|
||||
$xls -> right();
|
||||
$xls -> label( 'kod pocztowy' );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( 'Miejscowość' ) );
|
||||
$xls -> right();
|
||||
$xls -> label( 'Ulica' );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( 'Województwo' ) . ' - kor.' );
|
||||
$xls -> right();
|
||||
$xls -> label( 'kod pocztowy - kor.' );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( 'Miejscowość' ) . ' - kor.' );
|
||||
$xls -> right();
|
||||
$xls -> label( 'Ulica - kor.' );
|
||||
$xls -> right();
|
||||
$xls -> down();
|
||||
|
||||
foreach ( $results as $row )
|
||||
{
|
||||
$xls -> home();
|
||||
$xls -> label( date( 'Y-m-d', strtotime( $row['date_add'] ) ) );
|
||||
$xls -> right();
|
||||
$xls -> label( date( 'Y-m-d', strtotime( $row['rozpoczecie_dzialalnosci'] ) ) );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( $row['firma'] ) );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( $row['imie_nazwisko'] ) );
|
||||
$xls -> right();
|
||||
$xls -> label( $row['nip'] );
|
||||
$xls -> right();
|
||||
$xls -> label( $row['regon'] );
|
||||
$xls -> right();
|
||||
$xls -> label( $row['telefon'] );
|
||||
$xls -> right();
|
||||
$xls -> label( $row['email'] );
|
||||
$xls -> right();
|
||||
$xls -> label( $row['www'] );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( $row['ad1_wojewodztwo'] ) );
|
||||
$xls -> right();
|
||||
$xls -> label( $row['ad1_kod_pocztowy'] );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( $row['ad1_miejscowosc'] ) );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( $row['ad1_ulica'] ) );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( $row['ad2_wojewodztwo'] ) );
|
||||
$xls -> right();
|
||||
$xls -> label( $row['ad2_kod_pocztowy'] );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( $row['ad2_miejscowosc'] ) );
|
||||
$xls -> right();
|
||||
$xls -> label( \S::no_pl_excel( $row['ad2_ulica'] ) );
|
||||
$xls -> down();
|
||||
};
|
||||
$xls -> send_to_file('ceidg.xls');
|
||||
|
||||
\S::send_email( 'biuro@project-pro.pl', 'CEIDG - baza firm od ' . date( 'Y-m-d', strtotime( '-7 days', time() ) ) . ' do ' . date( 'Y-m-d', strtotime( '-1 days', time() ) ), 'CEIDG - baza firm', 'ceidg.xls' );
|
||||
// \S::send_email( 'andrzej.noga81@gmail.com', 'CEIDG - baza firm od ' . date( 'Y-m-d', strtotime( '-7 days', time() ) ) . ' do ' . date( 'Y-m-d', strtotime( '-1 days', time() ) ), 'CEIDG - baza firm', 'ceidg.xls' );
|
||||
// \S::send_email( '4axel@poczta.fm', 'CEIDG - baza firm od ' . date( 'Y-m-d', strtotime( '-7 days', time() ) ) . ' do ' . date( 'Y-m-d', strtotime( '-1 days', time() ) ), 'CEIDG - baza firm', 'ceidg.xls' );
|
||||
|
||||
unlink( 'ceidg.xls' );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function ceidg_download()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( $results = $mdb -> get( 'ceidg_urls', '*', ['date_update[!]' => date( 'Y-m-d' )] ) )
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt( $curl, CURLOPT_HEADER, true );
|
||||
curl_setopt( $curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" );
|
||||
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $curl, CURLOPT_VERBOSE, true );
|
||||
curl_setopt( $curl, CURLOPT_URL, str_replace( '[DATA]', date( "Y-m-d", strtotime( '-1 day', time() ) ), $results['url'] ) );
|
||||
curl_setopt( $curl, CURLOPT_TIMEOUT, 60 );
|
||||
curl_setopt( $curl, CURLOPT_MAXREDIRS, 60 );
|
||||
curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, true );
|
||||
$newUpdate = curl_exec( $curl );
|
||||
print_r( curl_error( $curl ) );
|
||||
curl_close( $curl );
|
||||
|
||||
$dlHandler = fopen( 'ceidg.zip', 'w' );
|
||||
if ( !fwrite( $dlHandler, $newUpdate ) )
|
||||
{
|
||||
exit();
|
||||
}
|
||||
fclose( $dlHandler );
|
||||
|
||||
ob_start();
|
||||
@system( 'unzip ceidg.zip' );
|
||||
ob_clean();
|
||||
|
||||
$mdb -> update( 'ceidg_urls', ['date_update' => date( 'Y-m-d' )], ['id' => $results['id']] );
|
||||
|
||||
unlink( 'ceidg.zip' );
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Pobieram xml do CEIDG: ' . $results['name']
|
||||
];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function ceidg_import()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$xml = false;
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_dolnoslaskie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_dolnoslaskie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_kujawsko-pomorskie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_kujawsko-pomorskie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_lubelskie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_lubelskie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_lubuskie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_lubuskie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_lódzkie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_lódzkie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_malopolskie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_malopolskie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_mazowieckie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_mazowieckie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_opolskie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_opolskie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_podkarpackie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_podkarpackie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_podlaskie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_podlaskie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_pomorskie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_pomorskie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_slaskie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_slaskie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_swietokrzyskie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_swietokrzyskie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_warminsko-mazurskie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_warminsko-mazurskie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_wielkopolskie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_wielkopolskie.xml';
|
||||
|
||||
if ( file_exists( utf8_decode( 'dzien_ExtendedAddress_zachodniopomorskie.xml' ) ) )
|
||||
$xml = 'dzien_ExtendedAddress_zachodniopomorskie.xml';
|
||||
|
||||
if ( $xml )
|
||||
{
|
||||
$reader = new XMLReader();
|
||||
$reader -> open( $xml );
|
||||
$reader -> read() && $reader -> read();
|
||||
|
||||
while ( $reader -> next( 'InformacjaOWpisie' ) )
|
||||
{
|
||||
$node = new SimpleXMLElement( $reader -> readOuterXML() );
|
||||
if ( !$mdb -> count( 'ceidg', ['hash' => (string)$node -> IdentyfikatorWpisu] ) )
|
||||
{
|
||||
$mdb -> insert( 'ceidg', [
|
||||
'hash' => (string)$node -> IdentyfikatorWpisu,
|
||||
'imie_nazwisko' => (string)$node -> DanePodstawowe -> Imie . ' ' . (string)$node -> DanePodstawowe -> Nazwisko,
|
||||
'nip' => (string)$node -> DanePodstawowe -> NIP,
|
||||
'regon' => (string)$node -> DanePodstawowe -> REGON,
|
||||
'firma' => (string)$node -> DanePodstawowe -> Firma,
|
||||
'email' => !empty( $node -> DaneKontaktowe -> AdresPocztyElektronicznej ) ? (string)$node -> DaneKontaktowe -> AdresPocztyElektronicznej : null,
|
||||
'www' => !empty( $node -> DaneKontaktowe -> AdresStronyInternetowej ) ? (string)$node -> DaneKontaktowe -> AdresStronyInternetowej : null,
|
||||
'telefon' => !empty( $node -> DaneKontaktowe -> Telefon ) ? (string)$node -> DaneKontaktowe -> Telefon : null,
|
||||
'faks' => !empty( $node -> DaneKontaktowe -> Faks ) ? (string)$node -> DaneKontaktowe -> Faks : null,
|
||||
'ad1_terc' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> TERC,
|
||||
'ad1_simc' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> SIMC,
|
||||
'ad1_ulic' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> ULIC,
|
||||
'ad1_miejscowosc' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> Miejscowosc,
|
||||
'ad1_terc' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> TERC,
|
||||
'ad1_kod_pocztowy' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> KodPocztowy,
|
||||
'ad1_poczta' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> Poczta,
|
||||
'ad1_gmina' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> Gmina,
|
||||
'ad1_powiat' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> Powiat,
|
||||
'ad1_wojewodztwo' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> Wojewodztwo,
|
||||
'ad2_terc' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> TERC,
|
||||
'ad2_simc' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> SIMC,
|
||||
'ad2_ulic' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> ULIC,
|
||||
'ad2_miejscowosc' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Miejscowosc,
|
||||
'ad2_ulica' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Ulica . ' ' . (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Budynek . ' ' . ( $node -> DaneAdresowe -> AdresDoDoreczen -> Budynek != '' ? ' lok. ' . (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Budynek : '' ),
|
||||
'ad2_kod_pocztowy' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> KodPocztowy,
|
||||
'ad2_poczta' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Poczta,
|
||||
'ad2_gmina' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Gmina,
|
||||
'ad2_powiat' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Powiat,
|
||||
'ad2_wojewodztwo' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Wojewodztwo,
|
||||
'obywatelstwo' => (string)$node -> DaneAdresowe -> PrzedsiebiorcaPosiadaObywatelstwaPanstw,
|
||||
'rozpoczecie_dzialalnosci' => (string)$node -> DaneDodatkowe -> DataRozpoczeciaWykonywaniaDzialalnosciGospodarczej,
|
||||
'zaprzestanie_dzialalnosci' => !empty( $node -> DaneDodatkowe -> DataZaprzestaniaWykonywaniaDzialalnosciGospodarczej ) ? (string)$node -> DaneDodatkowe -> DataZaprzestaniaWykonywaniaDzialalnosciGospodarczej : null,
|
||||
'data_wykreslenia' => !empty( $node -> DaneDodatkowe -> DataWykresleniaWpisuZRejestru ) ? (string)$node -> DaneDodatkowe -> DataWykresleniaWpisuZRejestru : null,
|
||||
'wspolnosc_majatkowa' => !empty( $node -> DaneDodatkowe -> MalzenskaWspolnoscMajatkowa ) ? (string)$node -> DaneDodatkowe -> MalzenskaWspolnoscMajatkowa : null,
|
||||
'status' => !empty( $node -> DaneDodatkowe -> Status ) ? (string)$node -> DaneDodatkowe -> Status : null,
|
||||
'pkd' => !empty( $node -> DaneDodatkowe -> KodyPKD ) ? (string)$node -> DaneDodatkowe -> KodyPKD : null,
|
||||
'spolki_cywilne' => !empty( $node -> SpolkiCywilneKtorychWspolnikiemJestPrzedsiebiorca ) ? json_encode( $node -> SpolkiCywilneKtorychWspolnikiemJestPrzedsiebiorca ) : null,
|
||||
'zakazy' => !empty( $node -> Zakazy ) ? json_encode( $node -> Zakazy ) : null,
|
||||
'postepowanie_naprawcze' => !empty( $node -> InformacjeDotyczaceUpadlosciPostepowaniaNaprawczego ) ? json_encode( $node -> InformacjeDotyczaceUpadlosciPostepowaniaNaprawczego ) : null
|
||||
] );
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mdb -> update( 'ceidg', [
|
||||
'imie_nazwisko' => (string)$node -> DanePodstawowe -> Imie . ' ' . (string)$node -> DanePodstawowe -> Nazwisko,
|
||||
'nip' => (string)$node -> DanePodstawowe -> NIP,
|
||||
'regon' => (string)$node -> DanePodstawowe -> REGON,
|
||||
'firma' => (string)$node -> DanePodstawowe -> Firma,
|
||||
'email' => !empty( $node -> DaneKontaktowe -> AdresPocztyElektronicznej ) ? (string)$node -> DaneKontaktowe -> AdresPocztyElektronicznej : null,
|
||||
'www' => !empty( $node -> DaneKontaktowe -> AdresStronyInternetowej ) ? (string)$node -> DaneKontaktowe -> AdresStronyInternetowej : null,
|
||||
'telefon' => !empty( $node -> DaneKontaktowe -> Telefon ) ? (string)$node -> DaneKontaktowe -> Telefon : null,
|
||||
'faks' => !empty( $node -> DaneKontaktowe -> Faks ) ? (string)$node -> DaneKontaktowe -> Faks : null,
|
||||
'ad1_terc' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> TERC,
|
||||
'ad1_simc' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> SIMC,
|
||||
'ad1_ulic' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> ULIC,
|
||||
'ad1_miejscowosc' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> Miejscowosc,
|
||||
'ad1_terc' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> TERC,
|
||||
'ad1_kod_pocztowy' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> KodPocztowy,
|
||||
'ad1_poczta' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> Poczta,
|
||||
'ad1_gmina' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> Gmina,
|
||||
'ad1_powiat' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> Powiat,
|
||||
'ad1_wojewodztwo' => (string)$node -> DaneAdresowe -> AdresGlownegoMiejscaWykonywaniaDzialalnosci -> Wojewodztwo,
|
||||
'ad2_terc' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> TERC,
|
||||
'ad2_simc' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> SIMC,
|
||||
'ad2_ulic' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> ULIC,
|
||||
'ad2_miejscowosc' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Miejscowosc,
|
||||
'ad2_ulica' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Ulica . ' ' . (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Budynek . ' ' . ( $node -> DaneAdresowe -> AdresDoDoreczen -> Budynek != '' ? ' lok. ' . (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Budynek : '' ),
|
||||
'ad2_kod_pocztowy' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> KodPocztowy,
|
||||
'ad2_poczta' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Poczta,
|
||||
'ad2_gmina' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Gmina,
|
||||
'ad2_powiat' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Powiat,
|
||||
'ad2_wojewodztwo' => (string)$node -> DaneAdresowe -> AdresDoDoreczen -> Wojewodztwo,
|
||||
'obywatelstwo' => (string)$node -> DaneAdresowe -> PrzedsiebiorcaPosiadaObywatelstwaPanstw,
|
||||
'rozpoczecie_dzialalnosci' => (string)$node -> DaneDodatkowe -> DataRozpoczeciaWykonywaniaDzialalnosciGospodarczej,
|
||||
'zaprzestanie_dzialalnosci' => !empty( $node -> DaneDodatkowe -> DataZaprzestaniaWykonywaniaDzialalnosciGospodarczej ) ? (string)$node -> DaneDodatkowe -> DataZaprzestaniaWykonywaniaDzialalnosciGospodarczej : null,
|
||||
'data_wykreslenia' => !empty( $node -> DaneDodatkowe -> DataWykresleniaWpisuZRejestru ) ? (string)$node -> DaneDodatkowe -> DataWykresleniaWpisuZRejestru : null,
|
||||
'wspolnosc_majatkowa' => !empty( $node -> DaneDodatkowe -> MalzenskaWspolnoscMajatkowa ) ? (string)$node -> DaneDodatkowe -> MalzenskaWspolnoscMajatkowa : null,
|
||||
'status' => !empty( $node -> DaneDodatkowe -> Status ) ? (string)$node -> DaneDodatkowe -> Status : null,
|
||||
'pkd' => !empty( $node -> DaneDodatkowe -> KodyPKD ) ? (string)$node -> DaneDodatkowe -> KodyPKD : null,
|
||||
'spolki_cywilne' => !empty( $node -> SpolkiCywilneKtorychWspolnikiemJestPrzedsiebiorca ) ? json_encode( $node -> SpolkiCywilneKtorychWspolnikiemJestPrzedsiebiorca ) : null,
|
||||
'zakazy' => !empty( $node -> Zakazy ) ? json_encode( $node -> Zakazy ) : null,
|
||||
'postepowanie_naprawcze' => !empty( $node -> InformacjeDotyczaceUpadlosciPostepowaniaNaprawczego ) ? json_encode( $node -> InformacjeDotyczaceUpadlosciPostepowaniaNaprawczego ) : null
|
||||
], [
|
||||
'hash' => (string)$node -> IdentyfikatorWpisu
|
||||
] );
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_dolnoslaskie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_dolnoslaskie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_kujawsko-pomorskie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_kujawsko-pomorskie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_lubelskie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_lubelskie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_lubuskie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_lubuskie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_lódzkie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_lódzkie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_malopolskie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_malopolskie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_mazowieckie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_mazowieckie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_opolskie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_opolskie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_podkarpackie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_podkarpackie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_podlaskie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_podlaskie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_pomorskie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_pomorskie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_slaskie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_slaskie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_swietokrzyskie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_swietokrzyskie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_warminsko-mazurskie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_warminsko-mazurskie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_wielkopolskie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_wielkopolskie.xml' ) );
|
||||
|
||||
if ( $xml == 'dzien_ExtendedAddress_zachodniopomorskie.xml' )
|
||||
unlink( utf8_decode( 'dzien_ExtendedAddress_zachodniopomorskie.xml' ) );
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Importuję firmy do CEIDG. Zaimportowano ' . (int)$i . ' firm. Zaktualizowano ' . (int)$j . ' firm.'
|
||||
];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function recursive_tasks()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 't.*, '
|
||||
. '( SELECT COUNT(0) FROM tasks WHERE parent_id = t.id ) AS quantity '
|
||||
. 'FROM '
|
||||
. 'tasks AS t '
|
||||
. 'WHERE '
|
||||
. 'recursively = 1 AND date_end IS NOT NULL AND date_end < \'' . date( 'Y-m-d', strtotime( '+1 months', time() ) ) . '\' '
|
||||
. 'HAVING quantity = 0' ) -> fetchAll();
|
||||
if ( is_array( $results ) and count( $results ) )
|
||||
foreach ( $results as $row )
|
||||
{
|
||||
if ( $row['date_end_month_day'] == null )
|
||||
{
|
||||
$mdb -> update( 'tasks', ['date_end_month_day' => date( 'j', strtotime( $row['date_end'] ) )], ['id' => $row['id']] );
|
||||
$row['date_end_month_day'] = date( 'j', strtotime( $row['date_end'] ) );
|
||||
}
|
||||
|
||||
if ( $row['date_start_month_day'] == null )
|
||||
{
|
||||
$mdb -> update( 'tasks', ['date_start_month_day' => date( 'j', strtotime( $row['date_start'] ) )], ['id' => $row['id']] );
|
||||
$row['date_start_month_day'] = date( 'j', strtotime( $row['date_start'] ) );
|
||||
}
|
||||
|
||||
/* powtarzanie co x dni */
|
||||
if ( $row['period'] == 1 )
|
||||
{
|
||||
$new_date_end = date( 'Y-m-d', strtotime( '+' . $row['frequency'] . ' days', strtotime( $row['date_end'] ) ) );
|
||||
|
||||
if ( $row['date_start'] )
|
||||
$new_date_start = date( 'Y-m-d', strtotime( '+' . $row['frequency'] . ' days', strtotime( $row['date_start'] ) ) );
|
||||
}
|
||||
|
||||
/* powtarzanie do x miesięcy */
|
||||
if ( $row['period'] == 2 )
|
||||
{
|
||||
$new_date_end = date( 'Y-m', strtotime( '+' . $row['frequency'] . ' months', strtotime( date( 'Y-m', strtotime( $row['date_end'] ) ) ) ) );
|
||||
$max_days = date( 't', strtotime( $new_date_end ) );
|
||||
|
||||
if ( $max_days <= $row['date_end_month_day'] )
|
||||
$new_date_end = date( 'Y-m-d', strtotime( $new_date_end . '-' . $max_days ) );
|
||||
else
|
||||
$new_date_end = date( 'Y-m-d', strtotime( $new_date_end . '-' . $row['date_end_month_day'] ) );
|
||||
|
||||
if ( $row['date_start'] )
|
||||
{
|
||||
$new_date_start = date( 'Y-m', strtotime( '+' . $row['frequency'] . ' months', strtotime( date( 'Y-m', strtotime( $row['date_start'] ) ) ) ) );
|
||||
$max_days = date( 't', strtotime( $new_date_start ) );
|
||||
|
||||
if ( $max_days <= $row['date_start_month_day'] )
|
||||
$new_date_start = date( 'Y-m-d', strtotime( $new_date_start . '-' . $max_days ) );
|
||||
else
|
||||
$new_date_start = date( 'Y-m-d', strtotime( $new_date_start . '-' . $row['date_start_month_day'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* powtarzanie co x lat */
|
||||
if ( $row['period'] == 3 )
|
||||
{
|
||||
$new_date_end = date( 'Y-m', strtotime( '+' . $row['frequency'] . ' years', strtotime( date( 'Y-m', strtotime( $row['date_end'] ) ) ) ) );
|
||||
$max_days = date( 't', strtotime( $new_date_end ) );
|
||||
|
||||
if ( $max_days <= $row['date_end_month_day'] )
|
||||
$new_date_end = date( 'Y-m-d', strtotime( $new_date_end . '-' . $max_days ) );
|
||||
else
|
||||
$new_date_end = date( 'Y-m-d', strtotime( $new_date_end . '-' . $row['date_end_month_day'] ) );
|
||||
|
||||
if ( $row['date_start'] )
|
||||
{
|
||||
$new_date_start = date( 'Y-m', strtotime( '+' . $row['frequency'] . ' years', strtotime( date( 'Y-m', strtotime( $row['date_start'] ) ) ) ) );
|
||||
$max_days = date( 't', strtotime( $new_date_start ) );
|
||||
|
||||
if ( $max_days <= $row['date_start_month_day'] )
|
||||
$new_date_start = date( 'Y-m-d', strtotime( $new_date_start . '-' . $max_days ) );
|
||||
else
|
||||
$new_date_start = date( 'Y-m-d', strtotime( $new_date_start . '-' . $row['date_start_month_day'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
$task_users = $mdb -> select( 'task_user', 'user_id', ['task_id' => $row['id']] );
|
||||
|
||||
\factory\Projects::task_save(
|
||||
null, $row['id'], $row['created_by'], $row['name'], $row['text'], $new_date_start, $new_date_end, $row['project_id'], $row['client'], $row['reminders'] ? 'on' : 'off',
|
||||
$row['reminders_interval'], $row['recursively'] ? 'on' : 'off', $row['frequency'], $row['period'], $row['gantt'] ? 'on' : 'off', $row['on_top'] ? 'on' : 'off', $task_users, $row['date_end_month_day'],
|
||||
$row['date_start_month_day']
|
||||
);
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Dodawanie rekursywnych zadań'
|
||||
];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function tasks_emails()
|
||||
{
|
||||
global $mdb, $setttings;
|
||||
|
||||
include_once 'libraries/phpmailer/class.phpmailer.php';
|
||||
include_once 'libraries/phpmailer/class.smtp.php';
|
||||
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 't.* '
|
||||
. 'FROM '
|
||||
. 'tasks AS t '
|
||||
. 'WHERE '
|
||||
. 'reminders = 1 AND reminders_send = 0 AND status = 0 AND deleted = 0' ) -> fetchAll();
|
||||
if ( is_array( $results ) and!empty( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$days_counter = explode( ',', $row['reminders_interval'] );
|
||||
rsort( $days_counter );
|
||||
|
||||
if ( is_array( $days_counter ) and!empty( $days_counter ) ) foreach ( $days_counter as $dc )
|
||||
{
|
||||
if ( !$mdb -> count( 'tasks_reminders', ['AND' => ['task_id' => $row['id'], 'day_counter' => $dc]] ) )
|
||||
{
|
||||
$send = false;
|
||||
$date_tmp = date( 'Y-m-d', strtotime( '+' . $dc . 'days', strtotime( date( 'Y-m-d' ) ) ) );
|
||||
if ( $date_tmp >= $row['date_end'] )
|
||||
{
|
||||
if ( !$mdb -> count( 'tasks_reminders', ['AND' => ['task_id' => $row['id'], 'day_counter' => $dc]] ) )
|
||||
{
|
||||
$users = $mdb -> select( 'task_user', 'user_id', ['task_id' => $row['id']] );
|
||||
|
||||
if ( is_array( $users ) and count( $users ) )
|
||||
{
|
||||
foreach ( $users as $user )
|
||||
{
|
||||
$user_email = $mdb -> get( 'users', 'email', ['id' => $user] );
|
||||
|
||||
date( 'Y-m-d', strtotime( $row['date_end'] ) ) == date( 'Y-m-d' ) ? $date = 'dzisiaj' : $date = date( 'Y-m-d', strtotime( $row['date_end'] ) );
|
||||
|
||||
|
||||
$subject = 'crmPRO - ' . $row['name'];
|
||||
$text = '<p>Witaj.</p>' .
|
||||
'<p>Otrzymałeś ten email z powodu ustawionego przypomnienia. Poniżej znajdziesz jego treść.</p>' .
|
||||
'<p>---------------------------------------------------------------------------------------</p>' .
|
||||
'<p><b>' . $row['name'] . '</b> (termin zadania: <b>' . $date . ')</b></p>' .
|
||||
'<p>' . $row['text'] . '</p>';
|
||||
|
||||
if ( \S::send_email( $user_email, $subject, $text ) );
|
||||
$send = true;
|
||||
}
|
||||
|
||||
if ( $send )
|
||||
{
|
||||
$mdb -> insert( 'tasks_reminders', ['task_id' => $row['id'], 'day_counter' => $dc] );
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Wiadomość została wysłana na adres: ' . $user_email
|
||||
];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mdb -> insert( 'tasks_reminders', ['task_id' => $row['id'], 'day_counter' => $dc] );
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Wiadomość nie wysłana z powodu braku odbiorców.'
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $days_counter ) == $mdb -> count( 'tasks_reminders', ['task_id' => $row['id']] ) )
|
||||
$mdb -> update( 'tasks', ['reminders_send' => 1], ['id' => $row['id']] );
|
||||
}
|
||||
return ['status' => 'empty'];
|
||||
}
|
||||
}
|
||||
58
autoload/class.DbModel.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
class DbModel
|
||||
{
|
||||
public $data;
|
||||
public $table;
|
||||
public $table_key = 'id';
|
||||
|
||||
public function __construct( $id )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( $id )
|
||||
{
|
||||
$result = $mdb -> get( $this -> table, '*', [ $this -> table_key => $id ] );
|
||||
if ( is_array( $result ) ) foreach ( $result as $key => $val )
|
||||
$this -> $key = $val;
|
||||
}
|
||||
}
|
||||
|
||||
public function __get( $variable )
|
||||
{
|
||||
if ( array_key_exists( $variable, $this -> data ) )
|
||||
return $this -> data[$variable];
|
||||
}
|
||||
|
||||
public function __set( $variable, $value )
|
||||
{
|
||||
$this -> data[$variable] = $value;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( $this -> __get( $this -> table_key ) )
|
||||
{
|
||||
$table_id_param = $this -> table_key;
|
||||
$table_id_value = $this -> __get( $this -> table_key );
|
||||
$data_tmp = $this -> data;
|
||||
unset( $data_tmp[ $table_id_param ] );
|
||||
|
||||
return $mdb -> update( $this -> table, $data_tmp, [ $table_id_param => $table_id_value ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$mdb -> insert( $this -> table, $this -> data );
|
||||
$this -> __set( $this -> table_key, $mdb -> id() );
|
||||
}
|
||||
return $this -> __get( $this -> table_key );
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> delete( $this -> table, [ $this -> table_key => $this -> __get( $this -> table_key ) ] );
|
||||
}
|
||||
|
||||
}
|
||||
167
autoload/class.Excel.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Simple excel writer class with no external dependencies, drop it in and have fun
|
||||
* @author Matt Nowack
|
||||
* @link https://gist.github.com/ihumanable/929039/edit
|
||||
* @license Unlicensed
|
||||
* @version 1.0
|
||||
*/
|
||||
class Excel {
|
||||
private $col;
|
||||
private $row;
|
||||
private $data;
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* Safely encode a string for use as a filename
|
||||
* @param string $title The title to use for the file
|
||||
* @return string The file safe title
|
||||
*/
|
||||
static function filename($title) {
|
||||
$result = strtolower(trim($title));
|
||||
$result = str_replace("'", '', $result);
|
||||
$result = preg_replace('#[^a-z0-9_]+#', '-', $result);
|
||||
$result = preg_replace('#\-{2,}#', '-', $result);
|
||||
return preg_replace('#(^\-+|\-+$)#D', '', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a new Excel Spreadsheet object
|
||||
* @return Excel The Spreadsheet
|
||||
*/
|
||||
function __construct($title) {
|
||||
$this->title = $title;
|
||||
$this->col = 0;
|
||||
$this->row = 0;
|
||||
$this->data = '';
|
||||
$this->bofMarker();
|
||||
}
|
||||
|
||||
/**
|
||||
* Transmits the proper headers to cause a download to occur and to identify the file properly
|
||||
* @return nothing
|
||||
*/
|
||||
function headers() {
|
||||
header("Content-Type: application/force-download");
|
||||
header("Content-Type: application/octet-stream");
|
||||
header("Content-Type: application/download");
|
||||
header("Content-Disposition: attachment;filename=" . Excel::filename($this->title) . ".xls ");
|
||||
header("Content-Transfer-Encoding: binary ");
|
||||
}
|
||||
|
||||
function send_to_file( $loc )
|
||||
{
|
||||
$this->eofMarker();
|
||||
file_put_contents($loc, $this->data);
|
||||
}
|
||||
|
||||
function send() {
|
||||
$this->eofMarker();
|
||||
$this->headers();
|
||||
echo $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the Excel Beginning of File marker
|
||||
* @see pack()
|
||||
* @return nothing
|
||||
*/
|
||||
private function bofMarker() {
|
||||
$this->data .= pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the Excel End of File marker
|
||||
* @see pack()
|
||||
* @return nothing
|
||||
*/
|
||||
private function eofMarker() {
|
||||
$this->data .= pack("ss", 0x0A, 0x00);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves internal cursor left by the amount specified
|
||||
* @param optional integer $amount The amount to move left by, defaults to 1
|
||||
* @return integer The current column after the move
|
||||
*/
|
||||
function left($amount = 1) {
|
||||
$this->col -= $amount;
|
||||
if($this->col < 0) {
|
||||
$this->col = 0;
|
||||
}
|
||||
return $this->col;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves internal cursor right by the amount specified
|
||||
* @param optional integer $amount The amount to move right by, defaults to 1
|
||||
* @return integer The current column after the move
|
||||
*/
|
||||
function right($amount = 1) {
|
||||
$this->col += $amount;
|
||||
return $this->col;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves internal cursor up by amount
|
||||
* @param optional integer $amount The amount to move up by, defaults to 1
|
||||
* @return integer The current row after the move
|
||||
*/
|
||||
function up($amount = 1) {
|
||||
$this->row -= $amount;
|
||||
if($this->row < 0) {
|
||||
$this->row = 0;
|
||||
}
|
||||
return $this->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves internal cursor down by amount
|
||||
* @param optional integer $amount The amount to move down by, defaults to 1
|
||||
* @return integer The current row after the move
|
||||
*/
|
||||
function down($amount = 1) {
|
||||
$this->row += $amount;
|
||||
return $this->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves internal cursor to the top of the page, row = 0
|
||||
* @return nothing
|
||||
*/
|
||||
function top() {
|
||||
$this->row = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves internal cursor all the way left, col = 0
|
||||
* @return nothing
|
||||
*/
|
||||
function home() {
|
||||
$this->col = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a number to the Excel Spreadsheet
|
||||
* @see pack()
|
||||
* @param integer $value The value to write out
|
||||
* @return nothing
|
||||
*/
|
||||
function number($value) {
|
||||
$this->data .= pack("sssss", 0x203, 14, $this->row, $this->col, 0x0);
|
||||
$this->data .= pack("d", $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a string (or label) to the Excel Spreadsheet
|
||||
* @see pack()
|
||||
* @param string $value The value to write out
|
||||
* @return nothing
|
||||
*/
|
||||
function label($value) {
|
||||
$length = strlen($value);
|
||||
$this->data .= pack("ssssss", 0x204, 8 + $length, $this->row, $this->col, 0x0, $length);
|
||||
$this->data .= $value;
|
||||
}
|
||||
}
|
||||
93
autoload/class.Html.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
class Html
|
||||
{
|
||||
public static function form_text( array $params = [] )
|
||||
{
|
||||
$tpl = new Tpl;
|
||||
$tpl -> params = $params;
|
||||
return $tpl -> render( 'html/form-text' );
|
||||
}
|
||||
|
||||
public static function input_switch( array $params = [] )
|
||||
{
|
||||
$tpl = new Tpl;
|
||||
$tpl -> params = $params;
|
||||
return $tpl -> render( 'html/input-switch' );
|
||||
}
|
||||
|
||||
public static function select( array $params = [] )
|
||||
{
|
||||
$tpl = new Tpl;
|
||||
$tpl -> params = $params;
|
||||
return $tpl -> render( 'html/select' );
|
||||
}
|
||||
|
||||
public static function textarea( array $params = [] )
|
||||
{
|
||||
$defaults = [
|
||||
'rows' => 4,
|
||||
];
|
||||
|
||||
$params = array_merge( $defaults, $params );
|
||||
|
||||
$tpl = new Tpl;
|
||||
$tpl -> params = $params;
|
||||
return $tpl -> render( 'html/textarea' );
|
||||
}
|
||||
|
||||
public static function input_icon( array $params = [] )
|
||||
{
|
||||
$defaults = [
|
||||
'type' => 'text',
|
||||
];
|
||||
|
||||
$params = array_merge( $defaults, $params );
|
||||
|
||||
$tpl = new Tpl;
|
||||
$tpl -> params = $params;
|
||||
return $tpl -> render( 'html/input-icon' );
|
||||
}
|
||||
|
||||
public static function input( array $params = [] )
|
||||
{
|
||||
$defaults = [
|
||||
'type' => 'text',
|
||||
];
|
||||
|
||||
$params = array_merge( $defaults, $params );
|
||||
|
||||
$tpl = new Tpl;
|
||||
$tpl -> params = $params;
|
||||
return $tpl -> render( 'html/input' );
|
||||
}
|
||||
|
||||
public static function button( array $params = [] )
|
||||
{
|
||||
$defaults = [
|
||||
'class' => 'btn-sm btn-info',
|
||||
];
|
||||
|
||||
$params = array_merge( $defaults, $params );
|
||||
|
||||
$tpl = new Tpl;
|
||||
$tpl -> params = $params;
|
||||
return $tpl -> render( 'html/button' );
|
||||
}
|
||||
|
||||
public static function panel( array $params = [] )
|
||||
{
|
||||
$defaults = [
|
||||
'title' => 'panel-title',
|
||||
'class' => 'panel-primary',
|
||||
'content' => 'panel-content'
|
||||
];
|
||||
|
||||
$params = array_merge( $defaults, $params );
|
||||
|
||||
$tpl = new Tpl;
|
||||
$tpl -> params = $params;
|
||||
return $tpl -> render( 'html/panel' );
|
||||
}
|
||||
|
||||
}
|
||||
250
autoload/class.S.php
Normal file
@@ -0,0 +1,250 @@
|
||||
<?php
|
||||
class S
|
||||
{
|
||||
public static function array_unique_multi( $array, $key )
|
||||
{
|
||||
$temp_array = [];
|
||||
foreach ($array as &$v) {
|
||||
if (!isset($temp_array[$v[$key]]))
|
||||
$temp_array[$v[$key]] =& $v;
|
||||
}
|
||||
$array = array_values($temp_array);
|
||||
return $array;
|
||||
|
||||
}
|
||||
|
||||
public function number_display( $value )
|
||||
{
|
||||
return number_format( $value, 2, ',', ' ' ) . ' zł';
|
||||
}
|
||||
|
||||
public static function prepar_request( $query )
|
||||
{
|
||||
if ( is_array( $query ) && !empty( $query ) )
|
||||
{
|
||||
foreach ( $query as $key => $value )
|
||||
$query[$key] = urlencode( $key ) . '=' . urlencode( $value );
|
||||
return implode( '&', $query );
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function seo( $val, $delete_rhombs = false )
|
||||
{
|
||||
$array_rep1 = array( '*', '_', ' ', '+', '"', "'", '?', '-', ',', '!', '~', '<', '>', '@', '#', '$', '%', '^', '&', '*' . '(', ')' . '-', '=', '\\', '|', '[', ']', ':', '(', ')' );
|
||||
$array_rep2 = array( '-', '-', '-', '-', '', '', '', '-', '-', '', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '', '-', '-', '-', '-', '-', '-', '-', '-' );
|
||||
|
||||
$val = self::noPl( $val );
|
||||
$val = str_replace( $array_rep1, $array_rep2, $val );
|
||||
$val = strtolower( $val );
|
||||
$val = preg_replace( '/(-){2,}/', '-', $val );
|
||||
if ( $delete_rhombs )
|
||||
$val = str_replace( '/', '', $val );
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
static public function no_pl_excel( $val )
|
||||
{
|
||||
$table = Array(
|
||||
"\xc4\x85" => "a", "\xc4\x84" => "A", "\xc4\x87" => "c", "\xc4\x86" => "C",
|
||||
"\xc4\x99" => "e", "\xc4\x98" => "E", "\xc5\x82" => "l", "\xc5\x81" => "L",
|
||||
"\xc3\xb3" => "o", "\xc3\x93" => "O", "\xc5\x9b" => "s", "\xc5\x9a" => "S",
|
||||
"\xc5\xbc" => "z", "\xc5\xbb" => "Z", "\xc5\xba" => "z", "\xc5\xb9" => "Z",
|
||||
"\xc5\x84" => "n", "\xc5\x83" => "N"
|
||||
);
|
||||
|
||||
$val = strtr( $val, $table );
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
public static function noPL( $val )
|
||||
{
|
||||
$table = array(
|
||||
"А" => "a", "Б" => "b", "В" => "v", "Г" => "g", "Д" => "d",
|
||||
"Е" => "e", "Ё" => "yo", "Ж" => "zh", "З" => "z", "И" => "i",
|
||||
"Й" => "j", "К" => "k", "Л" => "l", "М" => "m", "Н" => "n",
|
||||
"О" => "o", "П" => "p", "Р" => "r", "С" => "s", "Т" => "t",
|
||||
"У" => "u", "Ф" => "f", "Х" => "kh", "Ц" => "ts", "Ч" => "ch",
|
||||
"Ш" => "sh", "Щ" => "sch", "Ъ" => "", "Ы" => "y", "Ь" => "",
|
||||
"Э" => "e", "Ю" => "yu", "Я" => "ya", "а" => "a", "б" => "b",
|
||||
"в" => "v", "г" => "g", "д" => "d", "е" => "e", "ё" => "yo",
|
||||
"ж" => "zh", "з" => "z", "и" => "i", "й" => "j", "к" => "k",
|
||||
"л" => "l", "м" => "m", "н" => "n", "о" => "o", "п" => "p",
|
||||
"р" => "r", "с" => "s", "т" => "t", "у" => "u", "ф" => "f",
|
||||
"х" => "kh", "ц" => "ts", "ч" => "ch", "ш" => "sh", "щ" => "sch",
|
||||
"ъ" => "", "ы" => "y", "ь" => "", "э" => "e", "ю" => "yu",
|
||||
"я" => "ya", " " => "-", "." => "", "," => "",
|
||||
":" => "", ";" => "", "—" => "", "–" => "-"
|
||||
);
|
||||
|
||||
$val = strtr( $val, $table );
|
||||
|
||||
$val = iconv( 'UTF-8', 'ASCII//TRANSLIT', $val );
|
||||
|
||||
$table = Array(
|
||||
"\xc4\x85" => "a", "\xc4\x84" => "A", "\xc4\x87" => "c", "\xc4\x86" => "C",
|
||||
"\xc4\x99" => "e", "\xc4\x98" => "E", "\xc5\x82" => "l", "\xc5\x81" => "L",
|
||||
"\xc3\xb3" => "o", "\xc3\x93" => "O", "\xc5\x9b" => "s", "\xc5\x9a" => "S",
|
||||
"\xc5\xbc" => "z", "\xc5\xbb" => "Z", "\xc5\xba" => "z", "\xc5\xb9" => "Z",
|
||||
"\xc5\x84" => "n", "\xc5\x83" => "N"
|
||||
);
|
||||
|
||||
$val = strtr( $val, $table );
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
public static function alert( $text )
|
||||
{
|
||||
\S::set_session( 'alert', $text );
|
||||
}
|
||||
|
||||
public static function hash( $qtd )
|
||||
{
|
||||
$Caracteres = 'ABCDEFGHIJKLMOPQRSTUVXWYZ0123456789';
|
||||
$QuantidadeCaracteres = strlen($Caracteres);
|
||||
$QuantidadeCaracteres--;
|
||||
|
||||
$Hash =NULL;
|
||||
for ( $x = 1; $x <= $qtd; $x++ )
|
||||
{
|
||||
$Posicao = rand( 0, $QuantidadeCaracteres );
|
||||
$Hash .= substr( $Caracteres, $Posicao, 1 );
|
||||
}
|
||||
|
||||
return $Hash;
|
||||
}
|
||||
|
||||
public static function sort_array_of_array( &$array, $subfield, $type = SORT_ASC )
|
||||
{
|
||||
$sortarray = array();
|
||||
foreach ( $array as $key => $row )
|
||||
$sortarray[$key] = $row[$subfield];
|
||||
|
||||
array_multisort( $sortarray, $type, $array );
|
||||
}
|
||||
|
||||
public static function json_to_array( $json )
|
||||
{
|
||||
$values_tmp = json_decode( $json, true );
|
||||
|
||||
if ( is_array( $values_tmp ) ) foreach ( $values_tmp as $val )
|
||||
{
|
||||
if ( isset( $values[ $val['name'] ] ) )
|
||||
{
|
||||
if ( is_array( $values[ $val['name'] ] ) )
|
||||
$values[ $val['name'] ][] = $val['value'];
|
||||
else
|
||||
$values[ $val['name'] ] = array( $values[ $val['name'] ], $val['value'] );
|
||||
}
|
||||
else
|
||||
$values[ $val['name'] ] = $val['value'];
|
||||
}
|
||||
return $values;
|
||||
}
|
||||
|
||||
public static function get_session( $var )
|
||||
{
|
||||
return $_SESSION[ $var ];
|
||||
}
|
||||
|
||||
public static function del_session( $var ) {
|
||||
unset( $_SESSION[ $var ] );
|
||||
}
|
||||
|
||||
public static function set_session( $var, $val )
|
||||
{
|
||||
$_SESSION[ $var ] = $val;
|
||||
}
|
||||
|
||||
public static function get( $var )
|
||||
{
|
||||
if ( isset( $_POST[ $var ] ) )
|
||||
{
|
||||
if ( is_string( $_POST[ $var ] ) )
|
||||
return $_POST[ $var ];
|
||||
else
|
||||
return $_POST[ $var ];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isset( $_GET[ $var ] ) )
|
||||
{
|
||||
if ( is_string( $_GET[ $var ] ) )
|
||||
return $_GET[ $var ];
|
||||
else
|
||||
return $_GET[ $var ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function pre( $data , $type = '' )
|
||||
{
|
||||
$data = str_replace( 'Array
|
||||
(' , '' , $data );
|
||||
$data = str_replace( ')' , '' , $data );
|
||||
|
||||
echo '<pre';
|
||||
if ( $type == 'error' )
|
||||
echo ' style="color: #cc0000;" ';
|
||||
else if ( $type == 'info' )
|
||||
echo ' style="color: #2c539e;" ';
|
||||
else
|
||||
echo ' style="color: #8fc400;" ';
|
||||
echo '>' . print_r( $data , true ) . '</pre>';
|
||||
}
|
||||
|
||||
public static function email_check( $email )
|
||||
{
|
||||
return filter_var( $email, FILTER_VALIDATE_EMAIL );
|
||||
}
|
||||
|
||||
public static function send_email( $email, $subject, $text, $file = '' )
|
||||
{
|
||||
global $settings;
|
||||
|
||||
$mail = new PHPMailer;
|
||||
$mail -> IsSMTP();
|
||||
$mail -> SMTPAuth = true;
|
||||
$mail -> Host = $settings['email_host'];
|
||||
$mail -> Port = $settings['email_port'];
|
||||
$mail -> Username = $settings['email_login'];
|
||||
$mail -> Password = $settings['email_password'];
|
||||
$mail -> CharSet = "UTF-8";
|
||||
$mail -> SMTPOptions = array(
|
||||
'ssl' => array(
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'allow_self_signed' => true
|
||||
)
|
||||
);
|
||||
$mail -> From = 'bilety@brzezovka.pl';
|
||||
$mail -> FromName = 'KOMPLEKS TURYSTYCZNY BRZEZÓVKA';
|
||||
$mail -> addAddress( $email, $email );
|
||||
$mail -> addBCC( 'bilety@brzezovka.pl' );
|
||||
$mail -> addReplyTo( 'bilety@brzezovka.pl', 'KOMPLEKS TURYSTYCZNY BRZEZÓVKA' );
|
||||
$mail -> isHTML( true );
|
||||
|
||||
$mail -> Subject = $subject;
|
||||
$mail -> Body = $text;
|
||||
|
||||
if ( is_array( $file ) )
|
||||
{
|
||||
foreach ( $file as $file_tmp )
|
||||
{
|
||||
if ( file_exists( $file_tmp ) )
|
||||
$mail -> AddAttachment( $file_tmp );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( file_exists( $file ) )
|
||||
$mail -> AddAttachment( $file );
|
||||
}
|
||||
|
||||
return $mail -> send();
|
||||
}
|
||||
}
|
||||
73
autoload/class.Tpl.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
class Tpl
|
||||
{
|
||||
protected $dir = 'templates/';
|
||||
protected $vars = array();
|
||||
|
||||
function __construct( $dir = null )
|
||||
{
|
||||
if ( $dir !== null )
|
||||
$this -> dir = $dir;
|
||||
}
|
||||
|
||||
public static function view( $file, $values = '' )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
if ( is_array( $values ) ) foreach ( $values as $key => $val )
|
||||
$tpl -> $key = $val;
|
||||
return $tpl -> render( $file );
|
||||
}
|
||||
|
||||
public function secureHTML( $val )
|
||||
{
|
||||
$out = stripslashes( $val );
|
||||
$out = str_replace( "'", "'", $out );
|
||||
$out = str_replace( '"', """, $out );
|
||||
$out = str_replace( "<", "<", $out );
|
||||
$out = str_replace( ">", ">", $out );
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function render( $file )
|
||||
{
|
||||
if ( file_exists( 'templates_user/' . $file . '.php' ) )
|
||||
{
|
||||
ob_start();
|
||||
include 'templates_user/' . $file . '.php';
|
||||
$out = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $out;
|
||||
}
|
||||
else if ( file_exists( 'templates/' . $file . '.php' ) )
|
||||
{
|
||||
ob_start();
|
||||
include 'templates/' . $file . '.php';
|
||||
$out = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $out;
|
||||
}
|
||||
else if ( file_exists( $file . '.php' ) )
|
||||
{
|
||||
ob_start();
|
||||
include $file . '.php';
|
||||
$out = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $out;
|
||||
}
|
||||
else
|
||||
return '<div class="alert alert-danger" role="alert">Nie znaleziono pliku widoku: <b>' . $this -> dir . $file . '.php</b>';
|
||||
}
|
||||
|
||||
public function __set( $name, $value )
|
||||
{
|
||||
$this -> vars[ $name ] = $value;
|
||||
}
|
||||
|
||||
public function __get( $name )
|
||||
{
|
||||
return $this -> vars[ $name ];
|
||||
}
|
||||
}
|
||||
9
autoload/controls/.htaccess
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
RewriteRule ^index\.php$ - [L]
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule . /index.php [L]
|
||||
</IfModule>
|
||||
205
autoload/controls/class.Apanel.php
Normal file
@@ -0,0 +1,205 @@
|
||||
<?
|
||||
|
||||
namespace controls;
|
||||
|
||||
class Apanel
|
||||
{
|
||||
static public function login_view()
|
||||
{
|
||||
if (\S::get_session('user'))
|
||||
{
|
||||
header('Location: /apanel/main_view/');
|
||||
}
|
||||
else
|
||||
{
|
||||
return \Tpl::view('admin-panel/login');
|
||||
}
|
||||
}
|
||||
|
||||
static public function main_view()
|
||||
{
|
||||
global $mdb;
|
||||
$ordersArr = $mdb->query('SELECT id, name, surname, email, order_price, date_added, payment_status, used_ticket FROM orders')->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
|
||||
return \Tpl::view('admin-panel/main-view', [
|
||||
'orders' => $ordersArr
|
||||
]);
|
||||
}
|
||||
|
||||
static public function order_data()
|
||||
{
|
||||
global $mdb;
|
||||
$clientId = $_GET['id'];
|
||||
$orderTickets = $mdb->query('SELECT * FROM order_tickets WHERE order_id =' . $clientId)->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$orderInfo = $mdb->select('orders', '*', ['id' => $clientId]);
|
||||
|
||||
\S::del_session('user_orders');
|
||||
\S::set_session('user_orders', $orderTickets);
|
||||
|
||||
return \Tpl::view('admin-panel/order-data', [
|
||||
'order_tickets' => $orderTickets,
|
||||
'order_info' => $orderInfo,
|
||||
]);
|
||||
}
|
||||
|
||||
static public function login_check()
|
||||
{
|
||||
global $settings;
|
||||
$writingPassword = trim($_POST['admin_password']);
|
||||
|
||||
if ($writingPassword == $settings['admin-password'])
|
||||
{
|
||||
\S::set_session('user', true);
|
||||
header('Location: /scanner/scanner_view/');
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Location: /apanel/login_view/');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function unlogin()
|
||||
{
|
||||
\S::del_session("user");
|
||||
header('Location: /apanel/login_view/');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
//* Increment ticket
|
||||
static public function ticket_inc()
|
||||
{
|
||||
$basket = \S::get_session('user_orders');
|
||||
|
||||
$ticket_id = \S::get('ticket_id');
|
||||
|
||||
if ($basket[$ticket_id])
|
||||
{
|
||||
$basket[$ticket_id]['quantity']++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$basket[$ticket_id]['quantity'] = 1;
|
||||
}
|
||||
|
||||
|
||||
$basket = \factory\Apanel::recalculate_ticket_protection( $basket );
|
||||
$basket = \factory\Apanel::check_delivery( $basket );
|
||||
|
||||
\S::set_session( 'user_orders', $basket );
|
||||
|
||||
echo json_encode([
|
||||
'basket_form' => \Tpl::view('admin-panel/order-data-table', [
|
||||
'order_tickets' => $basket
|
||||
]),
|
||||
'order_summ' => \Tpl::view('admin-panel/order-summary', [
|
||||
'order_tickets' => $basket
|
||||
]),
|
||||
]);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
//* Decrement ticket
|
||||
static public function ticket_dec()
|
||||
{
|
||||
$basket = \S::get_session('user_orders');
|
||||
|
||||
$ticket_id = \S::get('ticket_id');
|
||||
|
||||
$basket[$ticket_id]['quantity']--;
|
||||
|
||||
if ( $basket[$ticket_id]['quantity'] == 0 )
|
||||
{
|
||||
unset($basket[$ticket_id]);
|
||||
}
|
||||
|
||||
$basket = \factory\Apanel::recalculate_ticket_protection( $basket );
|
||||
$basket = \factory\Apanel::check_delivery( $basket );
|
||||
|
||||
\S::set_session('user_orders', $basket);
|
||||
|
||||
echo json_encode([
|
||||
'basket_form' => \Tpl::view('admin-panel/order-data-table', [
|
||||
'order_tickets' => $basket
|
||||
]),
|
||||
'order_summ' => \Tpl::view('admin-panel/order-summary', [
|
||||
'order_tickets' => $basket
|
||||
]),
|
||||
]);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
//* Remove ticket
|
||||
static public function ticket_rem()
|
||||
{
|
||||
$basket = \S::get_session('user_orders');
|
||||
|
||||
$ticket_id = \S::get('ticket_id');
|
||||
|
||||
unset($basket[$ticket_id]);
|
||||
|
||||
$basket = \factory\Apanel::recalculate_ticket_protection( $basket );
|
||||
$basket = \factory\Apanel::check_delivery( $basket );
|
||||
|
||||
\S::set_session('user_orders', $basket);
|
||||
|
||||
echo json_encode([
|
||||
'basket_form' => \Tpl::view('admin-panel/order-data-table', [
|
||||
'order_tickets' => $basket
|
||||
]),
|
||||
'order_summ' => \Tpl::view('admin-panel/order-summary', [
|
||||
'order_tickets' => $basket
|
||||
]),
|
||||
]);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
//* Save new tickets list
|
||||
static public function ticket_save()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$order_id = \S::get('order_id');
|
||||
$payment_status = \S::get( 'payment_status' );
|
||||
$basket = \S::get_session('user_orders');
|
||||
$order_price = 0;
|
||||
|
||||
$mdb -> delete('order_tickets',['order_id' => $order_id]);
|
||||
|
||||
foreach ($basket as $key => $value)
|
||||
{
|
||||
$order_price += $value['price'] * $value['quantity'];
|
||||
//* Zapisywanie do DB bilety
|
||||
$mdb->insert('order_tickets', [
|
||||
'order_id' => $order_id,
|
||||
'product_id' => $value['product_id'],
|
||||
'name' => $value['name'],
|
||||
'quantity' => $value['quantity'],
|
||||
'price' => trim($value['price']),
|
||||
'date_visit' => $value['date_visit'],
|
||||
'date_added' => $value['date_added']
|
||||
]);
|
||||
}
|
||||
$mdb->update('orders', ['order_price' => $order_price, 'payment_status' => $payment_status ], ['id' => $order_id]);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function order_delete()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$order_id = \S::get('order_id');
|
||||
|
||||
$mdb->delete('order_tickets', ['order_id' => $order_id]);
|
||||
$mdb->delete('orders', ['id' => $order_id]);
|
||||
|
||||
header( 'Location: /apanel/main_view/' );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
9
autoload/controls/class.Cron.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace controls;
|
||||
class Cron
|
||||
{
|
||||
public static function main_view()
|
||||
{
|
||||
return \view\Cron::main_view();
|
||||
}
|
||||
}
|
||||
89
autoload/controls/class.Scanner.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
namespace controls;
|
||||
|
||||
class Scanner
|
||||
{
|
||||
static public function scanner_view()
|
||||
{
|
||||
if ( !\S::get_session('user') )
|
||||
return \Tpl::view('admin-panel/login');
|
||||
|
||||
return \Tpl::view( 'tickets/scanner-view');
|
||||
}
|
||||
|
||||
static public function scanner_get_data() {
|
||||
$ticketHash = \S::get( 'scannerData' );
|
||||
$ticketData = \factory\Tickets::get_order_details_by_hash( $ticketHash );
|
||||
|
||||
$dateNow = date('Y-m-d');
|
||||
$datePay = date("Y-m-d", strtotime($ticketData['payment_date']));
|
||||
$dateInterval = abs(strtotime($dateNow) - strtotime($datePay));
|
||||
$dateInterval = round($dateInterval / 86400, 1);
|
||||
|
||||
if ($ticketData) {
|
||||
$message = '</br>';
|
||||
$message .= '<strong><p style="font-size: 25px; margin-bottom: 0;">Status płatności: </p></strong>';
|
||||
$message .= '<strong><p style="font-size: 25px;">';
|
||||
$message .= $ticketData['payment_status'] ? '<span class="c_green">Zapłacono</span>' : '<span class="c_red">Nie zapłacono</span>';
|
||||
$message .= '</p></strong>';
|
||||
$message .= '<hr>';
|
||||
$message .= '<strong><p style="font-size: 25px; margin-bottom: 0;">Status biletu: </p></strong>';
|
||||
$message .= '<strong><p style="font-size: 25px; margin-bottom: 0;"';
|
||||
if($dateInterval > 30 and !$ticketData['used_ticket']){
|
||||
$message .= '<span class="c_red">Bilet nieważny</span>';
|
||||
} else {
|
||||
$message .= $ticketData['used_ticket'] ? '<span class="c_red">Wykorzystany</span>' : '<span class="c_green">Nie wykorzystany</span>';
|
||||
}
|
||||
$message .= '</p></strong>';
|
||||
if($ticketData['used_ticket']){
|
||||
$message .= '<p style="font-size: 20px;">' . $ticketData['used_ticket_date'] . '</p>';
|
||||
}
|
||||
|
||||
$message .= '<hr>';
|
||||
$message .= '<strong><p>Bilety: </p></strong>';
|
||||
$message .= '<ul>';
|
||||
foreach ($ticketData['tickets'] as $value){
|
||||
$message .= '<li>' . $value['name'] . ' (x ' . $value["quantity"] . ')</li>';
|
||||
}
|
||||
$message .= '</ul>';
|
||||
$message .= '<p>Cena: <strong>' . $ticketData['order_price'] . '</strong></p>';
|
||||
$message .= '<hr>';
|
||||
$message .= '<strong><p>Dane klienta:</p></strong>';
|
||||
$message .= '<input type="hidden" id="order-id" value="' . $ticketData['id'] . '">';
|
||||
$message .= '<p>Imie: <strong>' . $ticketData['name'] . '</strong></p>';
|
||||
$message .= '<p>Nazwisko: <strong>' . $ticketData['surname'] . '</strong></p>';
|
||||
$message .= '<p>Email: <strong>' . $ticketData['email'] . '</strong></p>';
|
||||
$message .= '<p>Kod pocztowy: <strong>' . $ticketData['zip_code'] . '</strong></p>';
|
||||
$message .= '<p>Miasto: <strong>' . $ticketData['city'] . '</strong></p>';
|
||||
$message .= '<hr>';
|
||||
if($dateInterval < 30){
|
||||
if (\S::get_session('user')){
|
||||
if(!$ticketData['used_ticket']){
|
||||
$message .= '<button class="btn-t1" id="btn-used" style="margin: 30px auto; display: block;">Oznacz jako wykorzystany</button>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = '</br>';
|
||||
$message .= '<strong><p style="font-size: 30px; text-align: center;">Nie poprawny kod QR</p></strong>';
|
||||
}
|
||||
echo json_encode($message);
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function use_ticket() {
|
||||
global $mdb;
|
||||
|
||||
$order_id = \S::get('order_id');
|
||||
$date = date('Y-m-d H:i:s');
|
||||
$mdb->update('orders', ['used_ticket' => 1, 'used_ticket_date' => $date], ['id' => $order_id]);
|
||||
|
||||
echo json_encode([
|
||||
'useStatus' => true
|
||||
]);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
23
autoload/controls/class.Site.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace controls;
|
||||
class Site
|
||||
{
|
||||
public static function route()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$class = '\controls\\';
|
||||
|
||||
$results = explode( '_', \S::get( 'module' ) );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
$class .= ucfirst( $row );
|
||||
|
||||
$action = \S::get( 'action' );
|
||||
|
||||
if ( class_exists( $class ) and method_exists( new $class, $action ) )
|
||||
{
|
||||
if ( \controls\Users::permissions( $user['id'], \S::get( 'module' ) ) )
|
||||
return call_user_func_array( array( $class, $action ), array() );
|
||||
}
|
||||
}
|
||||
}
|
||||
625
autoload/controls/class.Tickets.php
Normal file
@@ -0,0 +1,625 @@
|
||||
<?
|
||||
|
||||
namespace controls;
|
||||
|
||||
class Tickets
|
||||
{
|
||||
static public function main_view()
|
||||
{
|
||||
global $settings;
|
||||
|
||||
if ( !$settings['tickets']['enable_sell'] )
|
||||
return \Tpl::view( 'tickets/disabled-sell' );
|
||||
|
||||
return \Tpl::view('tickets/main-view', [
|
||||
'cart' => \S::get_session('basket'),
|
||||
'settings' => $settings
|
||||
]);
|
||||
}
|
||||
|
||||
static public function ticket_add()
|
||||
{
|
||||
global $settings;
|
||||
|
||||
|
||||
$selected_date = \S::get( 'date' ) ? \S::get( 'date' ) : null;
|
||||
$diffDays = \S::get('diffdays') ?? 0;
|
||||
|
||||
if ( $selected_date )
|
||||
{
|
||||
$selected = new \DateTime($selected_date);
|
||||
$today = new \DateTime(date('Y-m-d') . ' 00:00:00');
|
||||
$diffDays = $selected->diff($today)->days;
|
||||
}
|
||||
|
||||
$basket = \S::get_session('basket');
|
||||
$ticket_id = \S::get('ticket_id');
|
||||
|
||||
if ( $basket[$ticket_id][$diffDays] )
|
||||
{
|
||||
$basket[$ticket_id][$diffDays]['quantity']++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($diffDays == 0) {
|
||||
$addon = $settings['tickets'][$ticket_id]['dynamic_prices']['day0'] ?? 0;
|
||||
} elseif ($diffDays <= 2) {
|
||||
$addon = $settings['tickets'][$ticket_id]['dynamic_prices']['day1_2'] ?? 0;
|
||||
} elseif ($diffDays <= 7) {
|
||||
$addon = $settings['tickets'][$ticket_id]['dynamic_prices']['day3_7'] ?? 0;
|
||||
} else {
|
||||
$addon = 0;
|
||||
}
|
||||
|
||||
$basket[$ticket_id][$diffDays]['ticket_id'] = $ticket_id;
|
||||
$basket[$ticket_id][$diffDays]['ticket_price'] = $settings['tickets'][$ticket_id]['price'] + $addon;
|
||||
$basket[$ticket_id][$diffDays]['product_id'] = $settings['tickets'][$ticket_id]['product_id'];
|
||||
$basket[$ticket_id][$diffDays]['quantity'] = 1;
|
||||
$basket[$ticket_id][$diffDays]['date'] = $selected_date;
|
||||
}
|
||||
|
||||
if ( strpos( $ticket_id, "gift" ) !== false )
|
||||
{
|
||||
$basket['gift-price'][0]['quantity'] = 1;
|
||||
$basket['gift-price'][0]['ticket_price'] = $settings['tickets']['gift-price']['price'];
|
||||
$basket['gift-price'][0]['product_id'] = $settings['tickets']['gift-price']['product_id'];
|
||||
$basket['gift-price'][0]['ticket_id'] = 'gift-price';
|
||||
}
|
||||
|
||||
$basket = \factory\Tickets::recalculate_ticket_protection( $basket );
|
||||
|
||||
\S::set_session( 'basket', $basket );
|
||||
|
||||
if (\S::get('basket_step_1'))
|
||||
echo json_encode([
|
||||
'basket_form' => \Tpl::view('tickets/basket-form', [
|
||||
'cart' => $basket,
|
||||
'settings' => $settings
|
||||
]),
|
||||
'basket_summary' => \Tpl::view('tickets/basket-summary', [
|
||||
'cart' => $basket,
|
||||
'settings' => $settings
|
||||
])
|
||||
]);
|
||||
else
|
||||
echo json_encode(['shopping_cart' => \Tpl::view('tickets/shopping-cart', [
|
||||
'cart' => $basket,
|
||||
'settings' => $settings
|
||||
])]);
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function ticket_subtract()
|
||||
{
|
||||
global $settings;
|
||||
|
||||
$basket = \S::get_session('basket');
|
||||
$ticket_id = \S::get('ticket_id');
|
||||
$diffdays = \S::get('diffdays');
|
||||
|
||||
if ($basket[$ticket_id][$diffdays]['quantity'] > 0)
|
||||
{
|
||||
$basket[$ticket_id][$diffdays]['quantity']--;
|
||||
|
||||
if ($basket[$ticket_id][$diffdays]['quantity'] == 0)
|
||||
{
|
||||
unset($basket[$ticket_id][$diffdays]);
|
||||
if (empty($basket[$ticket_id])) {
|
||||
unset($basket[$ticket_id]);
|
||||
}
|
||||
|
||||
$giftKeys = array_filter(array_keys($basket), function ($key) {
|
||||
return strpos($key, "gift") !== false && $key != "gift-price";
|
||||
});
|
||||
if (empty($giftKeys)) {
|
||||
unset($basket['gift-price']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$basket = \factory\Tickets::recalculate_ticket_protection( $basket );
|
||||
|
||||
\S::set_session( 'basket', $basket );
|
||||
|
||||
if (\S::get('basket_step_1'))
|
||||
echo json_encode([
|
||||
'basket_form' => \Tpl::view('tickets/basket-form', [
|
||||
'cart' => $basket,
|
||||
'settings' => $settings
|
||||
]),
|
||||
'basket_summary' => \Tpl::view('tickets/basket-summary', [
|
||||
'cart' => $basket,
|
||||
'settings' => $settings
|
||||
]),
|
||||
'cart_count' => count($basket)
|
||||
]);
|
||||
|
||||
else
|
||||
echo json_encode([
|
||||
'shopping_cart' => \Tpl::view('tickets/shopping-cart', [
|
||||
'cart' => $basket,
|
||||
'settings' => $settings
|
||||
]),
|
||||
'cart_count' => count($basket)
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function ticket_remove()
|
||||
{
|
||||
global $settings;
|
||||
|
||||
$basket = \S::get_session('basket');
|
||||
$ticket_id = \S::get('ticket_id');
|
||||
$diffdays = \S::get('diffdays');
|
||||
|
||||
unset($basket[$ticket_id]);
|
||||
|
||||
$giftKeys = array_filter(array_keys($basket), function ($key) {
|
||||
return strpos($key, "gift") !== false && $key != "gift-price";
|
||||
});
|
||||
|
||||
if (empty($giftKeys)) {
|
||||
unset($basket['gift-price']);
|
||||
}
|
||||
|
||||
$basket = \factory\Tickets::recalculate_ticket_protection( $basket );
|
||||
|
||||
\S::set_session('basket', $basket);
|
||||
|
||||
if (\S::get('basket_step_1'))
|
||||
echo json_encode([
|
||||
'basket_form' => \Tpl::view('tickets/basket-form', [
|
||||
'cart' => $basket,
|
||||
'settings' => $settings
|
||||
]),
|
||||
'basket_summary' => \Tpl::view('tickets/basket-summary', [
|
||||
'cart' => $basket,
|
||||
'settings' => $settings
|
||||
]),
|
||||
'cart_count' => count($basket)
|
||||
]);
|
||||
else
|
||||
echo json_encode([
|
||||
'shopping_cart' => \Tpl::view('tickets/shopping-cart', [
|
||||
'cart' => $basket,
|
||||
'settings' => $settings
|
||||
]),
|
||||
'cart_count' => count($basket)
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Strona koszyka
|
||||
static public function basket_view()
|
||||
{
|
||||
global $settings;
|
||||
|
||||
if ( \S::get( 'ticket_protection' ) == 'true' ) {
|
||||
\S::set_session( 'ticket_protection', true );
|
||||
\factory\Tickets::add_ticket_protection();
|
||||
header( 'Location: /tickets/basket_view/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( \S::get( 'ticket_protection' ) == 'false' ) {
|
||||
\S::set_session( 'ticket_protection', false );
|
||||
\factory\Tickets::remove_ticket_protection();
|
||||
header( 'Location: /tickets/basket_view/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
return \Tpl::view('tickets/basket-view', [
|
||||
'cart' => \S::get_session('basket'),
|
||||
'settings' => $settings
|
||||
]);
|
||||
}
|
||||
|
||||
// Przetwarzanie formularza
|
||||
static public function basketFormHandler()
|
||||
{
|
||||
global $settings, $mdb;
|
||||
|
||||
$basket = \S::get_session('basket');
|
||||
$date = date('Y-m-d H:i:s');
|
||||
|
||||
$finalPrice = 0;
|
||||
foreach ( ( $basket ) as $data => $value )
|
||||
{
|
||||
foreach ( $value as $key => $val )
|
||||
{
|
||||
$price = $val['ticket_price'];
|
||||
$quantity = $val['quantity'];
|
||||
|
||||
$finalPrice += $price * $quantity;
|
||||
}
|
||||
}
|
||||
|
||||
$hash = md5(trim($_POST['email']) . trim($_POST['city']) . trim(date("Y-m-d H:i:s")));
|
||||
|
||||
//* Zapisywanie do DB klienta
|
||||
$mdb->insert('orders', [
|
||||
'name' => trim($_POST['name']),
|
||||
'surname' => trim($_POST['surname']),
|
||||
'email' => trim($_POST['email']),
|
||||
'zip_code' => trim($_POST['zip_code']),
|
||||
'city' => trim($_POST['city']),
|
||||
'street' => trim($_POST['street']),
|
||||
'order_price' => trim($finalPrice),
|
||||
'date_added' => $date,
|
||||
'hash' => $hash,
|
||||
'vat' => trim($_POST['vat'] == 'on' ? '1' : '0'),
|
||||
'company_name' => trim($_POST['company_name']),
|
||||
'nip' => trim($_POST['nip']),
|
||||
'gift_address' => trim($_POST['gift_address'])
|
||||
] );
|
||||
|
||||
//* Id klienta
|
||||
$last_id = $mdb->id();
|
||||
|
||||
if ( $last_id )
|
||||
{
|
||||
foreach ( ( $basket ) as $data => $value )
|
||||
{
|
||||
foreach ( $value as $key => $val )
|
||||
{
|
||||
$price = $val['ticket_price'];
|
||||
$quantity = $val['quantity'];
|
||||
|
||||
$finalPrice += $price * $quantity;
|
||||
}
|
||||
}
|
||||
foreach ( ( $basket ) as $data => $value )
|
||||
{
|
||||
foreach ( $value as $key => $val )
|
||||
{
|
||||
if ( $val['date'] ) {
|
||||
$dateFormatted = new \DateTime( $val['date'] );
|
||||
$dateFormatted = $dateFormatted->format('Y-m-d');
|
||||
} else
|
||||
$dateFormatted = null;
|
||||
|
||||
// Zapisywanie do DB bilety
|
||||
$mdb -> insert( 'order_tickets', [
|
||||
'order_id' => $last_id,
|
||||
'product_id' => $val['product_id'],
|
||||
'name' => trim( $settings['tickets'][$val['ticket_id']]['name'] ),
|
||||
'quantity' => trim( $val["quantity"]),
|
||||
'price' => trim( $val['ticket_price']),
|
||||
'date_visit' => $dateFormatted,
|
||||
'date_added' => $date
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
//QR CODE
|
||||
$dir = 'orders/' . $hash[0] . '/' . $hash[1] . '/';
|
||||
|
||||
if (!file_exists($dir . $hash . '.png'))
|
||||
{
|
||||
if (!is_dir($dir))
|
||||
mkdir($dir, 0755, true);
|
||||
|
||||
\QRcode::png($hash, $dir . $hash . '.png', QR_ECLEVEL_H, 4);
|
||||
}
|
||||
|
||||
\S::del_session('basket');
|
||||
header('Location: /tickets/przelewy24/order=' . $hash);
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Location: /tickets/main_view/');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
//* Strona końcowego zamówienia
|
||||
static public function przelewy24()
|
||||
{
|
||||
global $settings, $mdb;
|
||||
|
||||
$hash = \S::get('order');
|
||||
$order = \factory\Tickets::get_order_details_by_hash(\S::get('order'));
|
||||
|
||||
$subject = "brzezovka.pl - zamówienie biletów";
|
||||
$message = '<div style="width:100%; max-width: 600px; margin: 0 auto;">';
|
||||
$message .= '<div style="text-align: center;"><img src="https://bilety.brzezovka.pl/layout/images/logo.png" alt="" style="width: 300px;"></div><hr>';
|
||||
$message .= '<h2>Potwierdzenie Zamówienia</h2>';
|
||||
$message .= '<span>Witamy,</span><br/>';
|
||||
$message .= '<span>potwierdzamy realizację Zamówienia numer: ' . $order['id'] . '</span><br/><br/>';
|
||||
$message .= '<table style="width:100%;">';
|
||||
$message .= '<thead style="text-align: left;">';
|
||||
$message .= '<tr>';
|
||||
$message .= '<th>Dane zamówienia</th>';
|
||||
$message .= '<th>Dane zamawiającego</th>';
|
||||
$message .= '</tr>';
|
||||
$message .= '</thead>';
|
||||
$message .= '<tbody>';
|
||||
$message .= '<tr>';
|
||||
$message .= '<td>Cena: ' . $order['order_price'] . 'zł</td>';
|
||||
$message .= '<td>' . $order['name'] . ' ' . $order['surname'] . '</td>';
|
||||
$message .= '</tr>';
|
||||
$message .= '<tr>';
|
||||
$message .= '<td>Data: ' . $order['date_added'] . '</td>';
|
||||
$message .= '<td>' . $order['city'] . ' ' . $order['zip_code'] . '</td>';
|
||||
$message .= '</tr>';
|
||||
$message .= '<tr>';
|
||||
$message .= '<td></td>';
|
||||
$message .= '<td>' . $order['email'] . '</td>';
|
||||
$message .= '</tr>';
|
||||
$message .= '</tbody>';
|
||||
$message .= '</table>';
|
||||
$message .= '<br/><hr>';
|
||||
$message .= '<h3>Lista biletów</h3>';
|
||||
$message .= '<table style="width:100%;">';
|
||||
$message .= '<thead style="text-align: left;">';
|
||||
$message .= '<tr> <th>Bilet</th> <th>Termin wizyty</th> <th>Cena</th> <th>Ilość</th> <th>Razem</th> </tr>';
|
||||
$message .= '</thead>';
|
||||
$message .= '<tbody>';
|
||||
foreach ($order['tickets'] as $value)
|
||||
{
|
||||
$message .= '<tr>';
|
||||
$message .= '<td>' . $value['name'] . '</td>';
|
||||
$message .= '<td>' . $value['date_visit'] . '</td>';
|
||||
$message .= '<td>' . $value['price'] . '</td>';
|
||||
$message .= '<td>' . $value["quantity"] . '</td>';
|
||||
$message .= '<td>' . $value['price']*$value["quantity"] . 'zł</td>';
|
||||
$message .= '</tr>';
|
||||
}
|
||||
$message .= '</tbody>';
|
||||
$message .= '</table>';
|
||||
$message .= '<br/><hr>';
|
||||
|
||||
if (!empty($order['gift_address'])) {
|
||||
$message .= '<h3>Dane do wysyłki biletu prezentowego</h3>';
|
||||
$message .= '<p>' . $order['gift_address'] . '</p>';
|
||||
}
|
||||
|
||||
$message .= '<br/><hr>';
|
||||
|
||||
//QR CODE
|
||||
$dir = 'orders/' . $hash[0] . '/' . $hash[1] . '/';
|
||||
|
||||
if ( !file_exists($dir . $hash . '.png' ) )
|
||||
{
|
||||
if (!is_dir($dir))
|
||||
mkdir($dir, 0755, true);
|
||||
|
||||
\QRcode::png( $hash, $dir . $hash . '.png', QR_ECLEVEL_H, 4 );
|
||||
}
|
||||
|
||||
$qr_path = 'https://bilety.brzezovka.pl/' . $dir . $hash . '.png';
|
||||
$message .= '<h3>QR kod</h3>';
|
||||
$message .= '<img src="' . $qr_path . '" alt="QR kod" style="width: 200px; height: 200px;"/>';
|
||||
$message .= '<br/><hr>';
|
||||
|
||||
$message .= '<a style="display: inline-block; color: #000; border: none; text-decoration: none; margin-top:20px; background-color: #a4e653; font-weight: 800; border-radius: 10px; padding: 10px 30px;" href="https://bilety.brzezovka.pl/tickets/order_confirm/order=' . $order['hash'] . '">Link do szczegółów zamówienia</a>';
|
||||
$message .= '</div>';
|
||||
|
||||
\S::send_email( $order['email'], $subject, $message );
|
||||
|
||||
$przelewy24_hash = md5(time());
|
||||
$mdb->update('orders', ['payment_hash' => $przelewy24_hash], ['id' => $order['id']]);
|
||||
|
||||
return \Tpl::view('tickets/przelewy24', [
|
||||
'settings' => $settings,
|
||||
'hash' => \S::get('order'),
|
||||
'order' => $order,
|
||||
'przelewy24_hash' => $przelewy24_hash
|
||||
]);
|
||||
}
|
||||
|
||||
//* Akceptowanie zmian w DB. Jeżeli płatność jest ok
|
||||
static public function przelewy24_response()
|
||||
{
|
||||
global $settings, $mdb;
|
||||
|
||||
$crc_key = '';
|
||||
|
||||
if($settings['p24']['sandbox']) {
|
||||
$crc_key = $settings['p24']['sandbox_crc_key'];
|
||||
} else {
|
||||
$crc_key = $settings['p24']['crc_key'];
|
||||
}
|
||||
|
||||
$post = [
|
||||
'p24_merchant_id' => \S::get('p24_merchant_id'),
|
||||
'p24_pos_id' => \S::get('p24_pos_id'),
|
||||
'p24_session_id' => \S::get('p24_session_id'),
|
||||
'p24_amount' => \S::get('p24_amount'),
|
||||
'p24_currency' => \S::get('p24_currency'),
|
||||
'p24_order_id' => \S::get('p24_order_id'),
|
||||
'p24_sign' => md5(\S::get('p24_session_id') . '|' . \S::get('p24_order_id') . '|' . \S::get('p24_amount') . '|' . \S::get('p24_currency') . '|' . $crc_key)
|
||||
];
|
||||
|
||||
$ch = curl_init();
|
||||
if ($settings['p24']['sandbox'])
|
||||
{
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://sandbox.przelewy24.pl/trnVerify');
|
||||
}
|
||||
else
|
||||
{
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://secure.przelewy24.pl/trnVerify');
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
|
||||
curl_exec($ch);
|
||||
|
||||
$order = \factory\Tickets::get_order_details_by_przelewy24_hash(\S::get('p24_session_id'));
|
||||
if ( !$order )
|
||||
return false;
|
||||
|
||||
$mdb->update('orders', ['payment_status' => 1], ['id' => $order['id']]);
|
||||
$mdb->update('orders', ['payment_date' => date('Y-m-d H:i:s')], ['id' => $order['id']]);
|
||||
|
||||
//* Wystawienie faktury
|
||||
if ($order['invoice_status'] == 0)
|
||||
{
|
||||
if($order['vat'] == 0){
|
||||
$api = array();
|
||||
$api["api_id"] = "9fa7772af97ab35b6d8a1cd05ac9e1b5";
|
||||
$api["api_zadanie"] = "1";
|
||||
$api["dokument_rodzaj"] = "20";
|
||||
$api["dokument_dostep"] = "1";
|
||||
$api["dokument_miejsce"] = "Brzezovka sklep internetowy";
|
||||
$api["produkt_stawka_vat"] = "8";
|
||||
|
||||
$api["nabywca_imie"] = $order['name'];
|
||||
$api["nabywca_nazwisko"] = $order['surname'];
|
||||
$api["nabywca_email"] = $order['email'];
|
||||
|
||||
if($order['city']){
|
||||
$api["nabywca_miasto"] = $order['city'];
|
||||
}
|
||||
if($order['zip_code']){
|
||||
$api["nabywca_kod"] = $order['zip_code'];
|
||||
}
|
||||
if($order['street']){
|
||||
$api["nabywca_ulica"] = $order['street'];
|
||||
}
|
||||
|
||||
foreach ($order['tickets'] as $key => $value)
|
||||
{
|
||||
$key += 1;
|
||||
$api["produkt_nazwa_$key"] = $value['name'];
|
||||
$api["produkt_ilosc_$key"] = $value['quantity'];
|
||||
$api["produkt_jm_$key"] = "2";
|
||||
$api["produkt_stawka_vat_$key"] = "23";
|
||||
$api["produkt_wartosc_brutto_$key"] = $value['price'] * $value['quantity'];
|
||||
}
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, "https://www.fakturowo.pl/api");
|
||||
curl_setopt($curl, CURLOPT_POST, 1);
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 300);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $api);
|
||||
$result = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
$result = explode("\n", $result);
|
||||
if ($result[0] == 1)
|
||||
{
|
||||
$subject = "brzezovka.pl - zamówienie biletów 'paragon'";
|
||||
$message = '<div style="width:100%; max-width: 600px; margin: 0 auto;">';
|
||||
$message .= '<div style="text-align: center;"><img src="https://bilety.brzezovka.pl/layout/images/logo.png" alt="" style="width:100%; max-width: 100px;"></div><hr>';
|
||||
$message .= '<h2>Paragon z Potwierdzeniem Zamówienia</h2>';
|
||||
$message .= '<span>Link do pobrania:</span><br/>';
|
||||
$message .= '<a href="' . $result[2] . '">' . $result[2] . '</a>';
|
||||
$message .= '</div>';
|
||||
|
||||
\S::send_email( $order['email'], $subject, $message );
|
||||
|
||||
$mdb->update('orders', ['invoice_status' => 1], ['id' => $order['id']]);
|
||||
$mdb->update('orders', ['invoice_url' => $result[2]], ['id' => $order['id']]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "ERROR: " . $result[1];
|
||||
}
|
||||
}
|
||||
elseif ($order['vat'] == 1)
|
||||
{
|
||||
$api = array();
|
||||
$api["api_id"] = "9fa7772af97ab35b6d8a1cd05ac9e1b5";
|
||||
$api["api_zadanie"] = "1";
|
||||
$api["dokument_rodzaj"] = "0";
|
||||
$api["dokument_dostep"] = "1";
|
||||
$api["dokument_miejsce"] = "Brzezovka sklep internetowy";
|
||||
$api["produkt_stawka_vat"] = "8";
|
||||
|
||||
$api["nabywca_imie"] = $order['name'];
|
||||
$api["nabywca_nazwisko"] = $order['surname'];
|
||||
$api["nabywca_email"] = $order['email'];
|
||||
|
||||
$api["nabywca_miasto"] = $order['city'];
|
||||
$api["nabywca_kod"] = $order['zip_code'];
|
||||
$api["nabywca_ulica"] = $order['street'];
|
||||
|
||||
$api["nabywca_nazwa"] = $order['company_name'];
|
||||
$api["nabywca_nip"] = $order['nip'];
|
||||
|
||||
foreach ($order['tickets'] as $key => $value)
|
||||
{
|
||||
$key += 1;
|
||||
$api["produkt_nazwa_$key"] = $value['name'];
|
||||
$api["produkt_ilosc_$key"] = $value['quantity'];
|
||||
$api["produkt_jm_$key"] = "2";
|
||||
$api["produkt_stawka_vat_$key"] = "23";
|
||||
$api["produkt_wartosc_brutto_$key"] = $value['price'] * $value['quantity'];
|
||||
}
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, "https://www.fakturowo.pl/api");
|
||||
curl_setopt($curl, CURLOPT_POST, 1);
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 300);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $api);
|
||||
$result = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
$result = explode("\n", $result);
|
||||
if ($result[0] == 1)
|
||||
{
|
||||
$subject = "brzezovka.pl - zamówienie biletów 'faktura'";
|
||||
$message = '<div style="width:100%; max-width: 600px; margin: 0 auto;">';
|
||||
$message .= '<div style="text-align: center;"><img src="https://bilety.brzezovka.pl/layout/images/logo.png" alt="" style="width:100%; max-width: 100px;"></div><hr>';
|
||||
$message .= '<h2>Faktura z Potwierdzeniem Zamówienia</h2>';
|
||||
$message .= '<span>Link do pobrania:</span><br/>';
|
||||
$message .= '<a href="' . $result[2] . '">' . $result[2] . '</a>';
|
||||
$message .= '</div>';
|
||||
|
||||
\S::send_email( $order['email'], $subject, $message );
|
||||
|
||||
$mdb->update('orders', ['invoice_status' => 1], ['id' => $order['id']]);
|
||||
$mdb->update('orders', ['invoice_url' => $result[2]], ['id' => $order['id']]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "ERROR: " . $result[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
//* Końcowa strona z informacją o zamówieniu
|
||||
static public function order_confirm()
|
||||
{
|
||||
global $mdb;
|
||||
$order = \factory\Tickets::get_order_details_by_hash(\S::get('order'));
|
||||
|
||||
if ( $order['payment_status'] and !$order['informed_user'] )
|
||||
{
|
||||
if ($order['payment_status'])
|
||||
{
|
||||
$order_successful = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$order_fail = true;
|
||||
}
|
||||
|
||||
$mdb->update('orders', ['informed_user' => 1], ['id' => $order['id']]);
|
||||
}
|
||||
|
||||
return \Tpl::view( 'tickets/order-confirm', [
|
||||
'order' => $order,
|
||||
'order_successful' => $order_successful,
|
||||
'order_fail' => $order_fail
|
||||
]);
|
||||
}
|
||||
|
||||
//* Regulamin
|
||||
static public function regulamin()
|
||||
{
|
||||
return \Tpl::view('site/regulamin');
|
||||
}
|
||||
|
||||
static public function regulamin_biletow_prezentowych()
|
||||
{
|
||||
return \Tpl::view('site/regulamin-for-gifts');
|
||||
}
|
||||
}
|
||||
131
autoload/controls/class.Users.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
namespace controls;
|
||||
|
||||
class Users
|
||||
{
|
||||
|
||||
public static function permissions( $user_id, $module = '', $action = '' )
|
||||
{
|
||||
// Pyziak Jacek
|
||||
$permissions[ 1 ][ 'projects' ] = true;
|
||||
$permissions[ 1 ][ 'finances' ] = true;
|
||||
$permissions[ 1 ][ 'ceidg' ] = true;
|
||||
$permissions[ 1 ][ 'domain_tester' ] = true;
|
||||
$permissions[ 1 ][ 'wiki' ] = true;
|
||||
$permissions[ 1 ][ 'crm' ] = true;
|
||||
// Pyziak Grzegorz
|
||||
$permissions[ 3 ][ 'projects' ] = true;
|
||||
$permissions[ 3 ][ 'finances' ] = true;
|
||||
$permissions[ 3 ][ 'ceidg' ] = true;
|
||||
$permissions[ 3 ][ 'domain_tester' ] = true;
|
||||
$permissions[ 3 ][ 'wiki' ] = true;
|
||||
$permissions[ 3 ][ 'crm' ] = true;
|
||||
// Łukasz Szydełko
|
||||
$permissions[ 4 ][ 'projects' ] = false;
|
||||
$permissions[ 4 ][ 'finances' ] = false;
|
||||
$permissions[ 4 ][ 'ceidg' ] = true;
|
||||
$permissions[ 4 ][ 'domain_tester' ] = true;
|
||||
$permissions[ 4 ][ 'wiki' ] = false;
|
||||
$permissions[ 4 ][ 'crm' ] = false;
|
||||
// Roman Pyrih
|
||||
$permissions[ 5 ][ 'projects' ] = true;
|
||||
$permissions[ 5 ][ 'finances' ] = false;
|
||||
$permissions[ 5 ][ 'ceidg' ] = false;
|
||||
$permissions[ 5 ][ 'domain_tester' ] = false;
|
||||
$permissions[ 5 ][ 'wiki' ] = true;
|
||||
$permissions[ 5 ][ 'crm' ] = false;
|
||||
// Marian Uryc
|
||||
$permissions[ 7 ][ 'projects' ] = true;
|
||||
$permissions[ 7 ][ 'finances' ] = false;
|
||||
$permissions[ 7 ][ 'ceidg' ] = false;
|
||||
$permissions[ 7 ][ 'domain_tester' ] = false;
|
||||
$permissions[ 7 ][ 'wiki' ] = true;
|
||||
$permissions[ 7 ][ 'crm' ] = false;
|
||||
|
||||
if ( $action and isset( $permissions[ $user_id ][ $module ][ $action ] ) )
|
||||
{
|
||||
return $permissions[ $user_id ][ $module ][ $action ];
|
||||
}
|
||||
|
||||
if ( isset( $permissions[ $user_id ][ $module ] ) )
|
||||
{
|
||||
return $permissions[ $user_id ][ $module ];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function logout()
|
||||
{
|
||||
$domain = preg_replace( '#^(http(s)?://)?w{3}\.#', '$1', $_SERVER['SERVER_NAME'] );
|
||||
$cookie_name = str_replace( '.', '-', $domain );
|
||||
|
||||
setcookie( $cookie_name, "", strtotime( "-1 year" ), "/", $domain );
|
||||
session_destroy();
|
||||
header( 'Location: /' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function settings_save()
|
||||
{
|
||||
global $mdb, $user;
|
||||
|
||||
if ( \factory\Users::settings_save( $user[ 'id' ], \S::get( 'pushover_api' ), \S::get( 'pushover_user' ) ) )
|
||||
{
|
||||
$user = $mdb -> get( 'users', '*', [ 'id' => $user[ 'id' ] ] );
|
||||
\S::set_session( 'user', $user );
|
||||
\S::alert( 'Ustawienia zostały zapisane.' );
|
||||
}
|
||||
header( 'Location: /users/settings/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function settings()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ( !$user )
|
||||
{
|
||||
return \Tpl::view( 'users/login-form' );
|
||||
}
|
||||
|
||||
return \view\Users::settings(
|
||||
$user
|
||||
);
|
||||
}
|
||||
|
||||
public static function login()
|
||||
{
|
||||
if ( $user = \factory\Users::login(
|
||||
\S::get( 'email' ),
|
||||
md5( \S::get( 'password' ) )
|
||||
) )
|
||||
{
|
||||
// zapamiętaj logowanie
|
||||
if ( \S::get( 'remember' ) )
|
||||
{
|
||||
$domain = preg_replace( '#^(http(s)?://)?w{3}\.#', '$1', $_SERVER['SERVER_NAME'] );
|
||||
$cookie_name = str_replace( '.', '-', $domain );
|
||||
|
||||
$value = [ 'email' => \S::get( 'email' ), 'hash' => md5( \S::get( 'password' ) ) ];
|
||||
$value = json_encode( $value );
|
||||
|
||||
setcookie( $cookie_name, $value, strtotime( "+1 year" ), "/", $domain );
|
||||
}
|
||||
|
||||
\S::set_session( 'user', $user );
|
||||
echo json_encode( [ 'result' => 'true', 'msg' => 'Właśnie zostałeś zalogowany. Za chwilę nastąpi przekierowanie.', 'default_project' => $user[ 'default_project' ] ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode( [ 'result' => 'false', 'msg' => 'Podany login i hasło są nieprawidłowe.' ] );
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function login_form()
|
||||
{
|
||||
return \Tpl::view( 'users/login-form' );
|
||||
}
|
||||
|
||||
}
|
||||
9
autoload/factory/.htaccess
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
RewriteRule ^index\.php$ - [L]
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule . /index.php [L]
|
||||
</IfModule>
|
||||
63
autoload/factory/class.Apanel.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?
|
||||
namespace factory;
|
||||
class Apanel {
|
||||
static public function check_delivery( $basket )
|
||||
{
|
||||
$add_delivery = false;
|
||||
|
||||
foreach ( $basket as $key => $val )
|
||||
{
|
||||
if ( strpos( $val['name'], 'Bilet prezentowy' ) !== false )
|
||||
{
|
||||
$add_delivery = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$add_delivery )
|
||||
{
|
||||
foreach ( $basket as $key => $val )
|
||||
{
|
||||
if ( $val['product_id'] == 999999 )
|
||||
{
|
||||
unset( $basket[$key] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $basket;
|
||||
}
|
||||
|
||||
static public function recalculate_ticket_protection( $basket ) {
|
||||
|
||||
if ( !\S::get_session( 'ticket_protection' ) )
|
||||
return $basket;
|
||||
|
||||
$quantity = 0;
|
||||
|
||||
foreach ( $basket as $key => $val ) {
|
||||
if( $val['product_id'] != 0 and $val['product_id'] != 999999 ) {
|
||||
$quantity += $val['quantity'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $quantity > 0 )
|
||||
{
|
||||
foreach ( $basket as $key => $val ) {
|
||||
if ( $val['product_id'] == 0 ) {
|
||||
unset( $basket[$key] );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ( $basket as $key => $val ) {
|
||||
if ( $val['product_id'] == 0 ) {
|
||||
unset( $basket[$key] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $basket;
|
||||
}
|
||||
}
|
||||
530
autoload/factory/class.Cron.php
Normal file
@@ -0,0 +1,530 @@
|
||||
<?php
|
||||
namespace factory;
|
||||
class Cron
|
||||
{
|
||||
public static function remove_points_history()
|
||||
{
|
||||
global $mdb;
|
||||
if ( $results = $mdb -> delete( 'users_points_history', [ 'date[<]' => date( 'Y-m-d H:i:s', strtotime( '-30 days', time() ) ) ] ) )
|
||||
{
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Usuwam historię punktów.'
|
||||
];
|
||||
}
|
||||
return [ 'status' => 'bad' ];
|
||||
}
|
||||
|
||||
public static function update_points()
|
||||
{
|
||||
global $mdb;
|
||||
if ( $mdb -> update( 'users', [ 'points[+]' => 100, 'points_update' => date( 'Y-m-d' ) ], [ 'OR' => [ 'points_update[!]' => date( 'Y-m-d' ), 'points_update' => null ] ] ) )
|
||||
{
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Dodaję punkty.'
|
||||
];
|
||||
}
|
||||
return [ 'status' => 'bad' ];
|
||||
}
|
||||
|
||||
public static function send_push()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$sent_mail = false;
|
||||
|
||||
/* powiadomienia natychmiastowe */
|
||||
$users = $mdb -> query( 'SELECT '
|
||||
. 'id, email, pushover_api, pushover_user '
|
||||
. 'FROM '
|
||||
. 'users '
|
||||
. 'WHERE '
|
||||
. 'id IN ('
|
||||
. 'SELECT user_id FROM posters WHERE id IN ( '
|
||||
. 'SELECT poster_id FROM posters_history WHERE send_pushover = 0 AND pushover_settings = 1 GROUP BY poster_id ) ) '
|
||||
. 'AND '
|
||||
. 'pushover_api IS NOT NULL '
|
||||
. 'AND '
|
||||
. 'pushover_user IS NOT NULL' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $users ) and count( $users ) )
|
||||
{
|
||||
foreach ( $users as $user )
|
||||
{
|
||||
$posters = $mdb -> query( 'SELECT '
|
||||
. 'pr.id, url, title, price, comment '
|
||||
. 'FROM '
|
||||
. 'posters_history AS pr '
|
||||
. 'INNER JOIN posters AS p ON p.id = pr.poster_id '
|
||||
. 'WHERE '
|
||||
. 'send_pushover = 0 '
|
||||
. 'AND '
|
||||
. 'pushover_settings = 1 '
|
||||
. 'AND '
|
||||
. 'user_id = ' . $user['id'] . ' LIMIT 1' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $posters ) and count( $posters ) )
|
||||
{
|
||||
foreach ( $posters as $poster )
|
||||
{
|
||||
$posters_id[] = $poster['id'];
|
||||
$auctions[] = $poster;
|
||||
}
|
||||
|
||||
\factory\Posters::send_push( $user['email'], $auctions, $user['pushover_api'], $user['pushover_user'] );
|
||||
$mdb -> query( 'UPDATE posters_history SET send_pushover = 1 WHERE id IN ( ' . implode( ',', $posters_id ) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Wysyłam powiadomienia push o znalezionych ogłoszeniach.'
|
||||
];
|
||||
}
|
||||
|
||||
/* powiadomienia zbiorcze co godzinę */
|
||||
$users = $mdb -> query( 'SELECT '
|
||||
. 'id, email, pushover_api, pushover_user '
|
||||
. 'FROM '
|
||||
. 'users '
|
||||
. 'WHERE '
|
||||
. 'id IN ('
|
||||
. 'SELECT user_id FROM posters WHERE id IN ( '
|
||||
. 'SELECT poster_id FROM posters_history AS pr WHERE send_pushover = 0 AND pushover_settings = 2 AND DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) = \'' . date( 'Y-m-d H', strtotime( '-1 hours', time() ) ) . '\' GROUP BY poster_id ) ) '
|
||||
. 'AND '
|
||||
. 'pushover_api IS NOT NULL '
|
||||
. 'AND '
|
||||
. 'pushover_user IS NOT NULL' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $users ) and count( $users ) )
|
||||
{
|
||||
foreach ( $users as $user )
|
||||
{
|
||||
$posters = $mdb -> query( 'SELECT '
|
||||
. 'pr.id, url, title, price, comment '
|
||||
. 'FROM '
|
||||
. 'posters_history AS pr '
|
||||
. 'INNER JOIN posters AS p ON p.id = pr.poster_id '
|
||||
. 'WHERE '
|
||||
. 'send_pushover = 0 '
|
||||
. 'AND '
|
||||
. 'pushover_settings = 2 '
|
||||
. 'AND '
|
||||
. 'DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) = \'' . date( 'Y-m-d H', strtotime( '-1 hours', time() ) ) . '\' '
|
||||
. 'AND '
|
||||
. 'user_id = ' . $user['id'] . ' LIMIT 1' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $posters ) and count( $posters ) )
|
||||
{
|
||||
foreach ( $posters as $poster )
|
||||
{
|
||||
$posters_id[] = $poster['id'];
|
||||
$auctions[] = $poster;
|
||||
}
|
||||
|
||||
\factory\Posters::send_push( $user['email'], $auctions, $user['pushover_api'], $user['pushover_user'] );
|
||||
$mdb -> query( 'UPDATE posters_history SET send_pushover = 1 WHERE id IN ( ' . implode( ',', $posters_id ) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Wysyłam powiadomienia push o znalezionych ogłoszeniach.'
|
||||
];
|
||||
}
|
||||
|
||||
if ( date( 'Y-m-d H:i:s' ) > date( 'Y-m-d 08:00:00' ) )
|
||||
{
|
||||
/* powiadomienia zbiorcze dwa razy dziennie - o godzinie 8 */
|
||||
$users = $mdb -> query( 'SELECT '
|
||||
. 'id, email, pushover_api, pushover_user '
|
||||
. 'FROM '
|
||||
. 'users '
|
||||
. 'WHERE '
|
||||
. 'id IN ('
|
||||
. 'SELECT user_id FROM posters WHERE id IN ( '
|
||||
. 'SELECT poster_id FROM posters_history AS pr WHERE send_pushover = 0 AND pushover_settings = 3 AND DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) < \'' . date( 'Y-m-d 08' ) . '\' GROUP BY poster_id ) ) '
|
||||
. 'AND '
|
||||
. 'pushover_api IS NOT NULL '
|
||||
. 'AND '
|
||||
. 'pushover_user IS NOT NULL' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $users ) and count( $users ) )
|
||||
{
|
||||
foreach ( $users as $user )
|
||||
{
|
||||
$posters = $mdb -> query( 'SELECT '
|
||||
. 'pr.id, url, title, price, comment '
|
||||
. 'FROM '
|
||||
. 'posters_history AS pr '
|
||||
. 'INNER JOIN posters AS p ON p.id = pr.poster_id '
|
||||
. 'WHERE '
|
||||
. 'send_pushover = 0 '
|
||||
. 'AND '
|
||||
. 'pushover_settings = 3 '
|
||||
. 'AND '
|
||||
. 'DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) < \'' . date( 'Y-m-d 08' ) . '\' '
|
||||
. 'AND '
|
||||
. 'user_id = ' . $user['id'] . ' LIMIT 1' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $posters ) and count( $posters ) )
|
||||
{
|
||||
foreach ( $posters as $poster )
|
||||
{
|
||||
$posters_id[] = $poster['id'];
|
||||
$auctions[] = $poster;
|
||||
}
|
||||
|
||||
\factory\Posters::send_push( $user['email'], $auctions, $user['pushover_api'], $user['pushover_user'] );
|
||||
$mdb -> query( 'UPDATE posters_history SET send_pushover = 1 WHERE id IN ( ' . implode( ',', $posters_id ) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Wysyłam powiadomienia push o znalezionych ogłoszeniach.'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if ( date( 'Y-m-d H:i:s' ) > date( 'Y-m-d 20:00:00' ) )
|
||||
{
|
||||
/* powiadomienia zbiorcze dwa razy dziennie - o godzinie 20 */
|
||||
$users = $mdb -> query( 'SELECT '
|
||||
. 'id, email, pushover_api, pushover_user '
|
||||
. 'FROM '
|
||||
. 'users '
|
||||
. 'WHERE '
|
||||
. 'id IN ('
|
||||
. 'SELECT user_id FROM posters WHERE id IN ( '
|
||||
. 'SELECT poster_id FROM posters_history AS pr WHERE send_pushover = 0 AND pushover_settings = 3 AND DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) < \'' . date( 'Y-m-d 20' ) . '\' GROUP BY poster_id ) ) '
|
||||
. 'AND '
|
||||
. 'pushover_api IS NOT NULL '
|
||||
. 'AND '
|
||||
. 'pushover_user IS NOT NULL' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $users ) and count( $users ) )
|
||||
{
|
||||
foreach ( $users as $user )
|
||||
{
|
||||
$posters = $mdb -> query( 'SELECT '
|
||||
. 'pr.id, url, title, price, comment '
|
||||
. 'FROM '
|
||||
. 'posters_history AS pr '
|
||||
. 'INNER JOIN posters AS p ON p.id = pr.poster_id '
|
||||
. 'WHERE '
|
||||
. 'send_pushover = 0 '
|
||||
. 'AND '
|
||||
. 'pushover_settings = 3 '
|
||||
. 'AND '
|
||||
. 'DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) < \'' . date( 'Y-m-d 20' ) . '\' '
|
||||
. 'AND '
|
||||
. 'user_id = ' . $user['id'] . ' LIMIT 1' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $posters ) and count( $posters ) )
|
||||
{
|
||||
foreach ( $posters as $poster )
|
||||
{
|
||||
$posters_id[] = $poster['id'];
|
||||
$auctions[] = $poster;
|
||||
}
|
||||
|
||||
\factory\Posters::send_push( $user['email'], $auctions, $user['pushover_api'], $user['pushover_user'] );
|
||||
$mdb -> query( 'UPDATE posters_history SET send_pushover = 1 WHERE id IN ( ' . implode( ',', $posters_id ) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Wysyłam powiadomienia push o znalezionych ogłoszeniach.'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if ( date( 'Y-m-d H:i:s' ) > date( 'Y-m-d 20:00:00' ) )
|
||||
{
|
||||
/* powiadomienia zbiorcze raz dziennie - o godzinie 20 */
|
||||
$users = $mdb -> query( 'SELECT '
|
||||
. 'id, email, pushover_api, pushover_user '
|
||||
. 'FROM '
|
||||
. 'users '
|
||||
. 'WHERE '
|
||||
. 'id IN ('
|
||||
. 'SELECT user_id FROM posters WHERE id IN ( '
|
||||
. 'SELECT poster_id FROM posters_history AS pr WHERE send_pushover = 0 AND pushover_settings = 4 AND DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) < \'' . date( 'Y-m-d 20' ) . '\' GROUP BY poster_id ) ) '
|
||||
. 'AND '
|
||||
. 'pushover_api IS NOT NULL '
|
||||
. 'AND '
|
||||
. 'pushover_user IS NOT NULL' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $users ) and count( $users ) )
|
||||
{
|
||||
foreach ( $users as $user )
|
||||
{
|
||||
$posters = $mdb -> query( 'SELECT '
|
||||
. 'pr.id, url, title, price, comment '
|
||||
. 'FROM '
|
||||
. 'posters_history AS pr '
|
||||
. 'INNER JOIN posters AS p ON p.id = pr.poster_id '
|
||||
. 'WHERE '
|
||||
. 'send_pushover = 0 '
|
||||
. 'AND '
|
||||
. 'pushover_settings = 4 '
|
||||
. 'AND '
|
||||
. 'DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) < \'' . date( 'Y-m-d 20' ) . '\' '
|
||||
. 'AND '
|
||||
. 'user_id = ' . $user['id'] . ' LIMIT 1' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $posters ) and count( $posters ) )
|
||||
{
|
||||
foreach ( $posters as $poster )
|
||||
{
|
||||
$posters_id[] = $poster['id'];
|
||||
$auctions[] = $poster;
|
||||
}
|
||||
|
||||
\factory\Posters::send_push( $user['email'], $auctions, $user['pushover_api'], $user['pushover_user'] );
|
||||
$mdb -> query( 'UPDATE posters_history SET send_pushover = 1 WHERE id IN ( ' . implode( ',', $posters_id ) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Wysyłam powiadomienia push o znalezionych ogłoszeniach.'
|
||||
];
|
||||
}
|
||||
}
|
||||
return [ 'status' => 'bad' ];
|
||||
}
|
||||
|
||||
public static function send_emails()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$sent_mail = false;
|
||||
|
||||
/* powiadomienia natychmiastowe */
|
||||
$users = $mdb -> query( 'SELECT '
|
||||
. 'id, email '
|
||||
. 'FROM '
|
||||
. 'users '
|
||||
. 'WHERE '
|
||||
. 'id IN ('
|
||||
. 'SELECT user_id FROM posters WHERE id IN ( '
|
||||
. 'SELECT poster_id FROM posters_history WHERE send_email = 0 AND mail_settings = 1 GROUP BY poster_id ) )' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $users ) and count( $users ) )
|
||||
{
|
||||
foreach ( $users as $user )
|
||||
{
|
||||
$posters = $mdb -> query( 'SELECT '
|
||||
. 'pr.id, url, title, price, comment, mail_settings '
|
||||
. 'FROM '
|
||||
. 'posters_history AS pr '
|
||||
. 'INNER JOIN posters AS p ON p.id = pr.poster_id '
|
||||
. 'WHERE '
|
||||
. 'send_email = 0 '
|
||||
. 'AND '
|
||||
. 'mail_settings = 1 '
|
||||
. 'AND '
|
||||
. 'user_id = ' . $user['id'] ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $posters ) and count( $posters ) )
|
||||
{
|
||||
foreach ( $posters as $poster )
|
||||
{
|
||||
$posters_id[] = $poster['id'];
|
||||
$auctions[] = $poster;
|
||||
}
|
||||
|
||||
\factory\Posters::send_emails( $user['email'], $auctions );
|
||||
$mdb -> query( 'UPDATE posters_history SET send_email = 1 WHERE id IN ( ' . implode( ',', $posters_id ) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Wysyłam powiadomienia mailowe o znalezionych ogłoszeniach.'
|
||||
];
|
||||
}
|
||||
|
||||
/* powiadomienia zbiorcze co godzinę */
|
||||
$users = $mdb -> query( 'SELECT '
|
||||
. 'id, email '
|
||||
. 'FROM '
|
||||
. 'users '
|
||||
. 'WHERE '
|
||||
. 'id IN ('
|
||||
. 'SELECT user_id FROM posters WHERE id IN ( '
|
||||
. 'SELECT poster_id FROM posters_history AS pr WHERE send_email = 0 AND mail_settings = 2 AND DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) = \'' . date( 'Y-m-d H', strtotime( '-1 hours', time() ) ) . '\' GROUP BY poster_id ) )' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $users ) and count( $users ) )
|
||||
{
|
||||
foreach ( $users as $user )
|
||||
{
|
||||
$posters = $mdb -> query( 'SELECT '
|
||||
. 'pr.id, url, title, price, comment, mail_settings '
|
||||
. 'FROM '
|
||||
. 'posters_history AS pr '
|
||||
. 'INNER JOIN posters AS p ON p.id = pr.poster_id '
|
||||
. 'WHERE '
|
||||
. 'send_email = 0 '
|
||||
. 'AND '
|
||||
. 'mail_settings = 2 '
|
||||
. 'AND '
|
||||
. 'DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) = \'' . date( 'Y-m-d H', strtotime( '-1 hours', time() ) ) . '\' '
|
||||
. 'AND '
|
||||
. 'user_id = ' . $user['id'] ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $posters ) and count( $posters ) )
|
||||
{
|
||||
foreach ( $posters as $poster )
|
||||
{
|
||||
$posters_id[] = $poster['id'];
|
||||
$auctions[] = $poster;
|
||||
}
|
||||
|
||||
\factory\Posters::send_emails( $user['email'], $auctions, ' | mail zbiorczy co 1h' );
|
||||
$mdb -> query( 'UPDATE posters_history SET send_email = 1 WHERE id IN ( ' . implode( ',', $posters_id ) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Wysyłam powiadomienia mailowe o znalezionych ogłoszeniach.'
|
||||
];
|
||||
}
|
||||
|
||||
if ( date( 'Y-m-d H:i:s' ) > date( 'Y-m-d 08:00:00' ) )
|
||||
{
|
||||
/* powiadomienia zbiorcze dwa razy dziennie - o godzinie 8 */
|
||||
$users = $mdb -> query( 'SELECT '
|
||||
. 'id, email '
|
||||
. 'FROM '
|
||||
. 'users '
|
||||
. 'WHERE '
|
||||
. 'id IN ('
|
||||
. 'SELECT user_id FROM posters WHERE id IN ( '
|
||||
. 'SELECT poster_id FROM posters_history AS pr WHERE send_email = 0 AND mail_settings = 3 AND DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) < \'' . date( 'Y-m-d 08' ) . '\' GROUP BY poster_id ) )' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $users ) and count( $users ) )
|
||||
{
|
||||
foreach ( $users as $user )
|
||||
{
|
||||
$posters = $mdb -> query( 'SELECT '
|
||||
. 'pr.id, url, title, price, comment, mail_settings '
|
||||
. 'FROM '
|
||||
. 'posters_history AS pr '
|
||||
. 'INNER JOIN posters AS p ON p.id = pr.poster_id '
|
||||
. 'WHERE '
|
||||
. 'send_email = 0 '
|
||||
. 'AND '
|
||||
. 'mail_settings = 3 '
|
||||
. 'AND '
|
||||
. 'DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) < \'' . date( 'Y-m-d 08' ) . '\' '
|
||||
. 'AND '
|
||||
. 'user_id = ' . $user['id'] ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $posters ) and count( $posters ) )
|
||||
{
|
||||
foreach ( $posters as $poster )
|
||||
{
|
||||
$posters_id[] = $poster['id'];
|
||||
$auctions[] = $poster;
|
||||
}
|
||||
|
||||
\factory\Posters::send_emails( $user['email'], $auctions, ' | mail zbiorczy 2 razy dziennie (08:00)' );
|
||||
$mdb -> query( 'UPDATE posters_history SET send_email = 1 WHERE id IN ( ' . implode( ',', $posters_id ) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Wysyłam powiadomienia mailowe o znalezionych ogłoszeniach.'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if ( date( 'Y-m-d H:i:s' ) > date( 'Y-m-d 20:00:00' ) )
|
||||
{
|
||||
/* powiadomienia zbiorcze dwa razy dziennie - o godzinie 20 */
|
||||
$users = $mdb -> query( 'SELECT '
|
||||
. 'id, email '
|
||||
. 'FROM '
|
||||
. 'users '
|
||||
. 'WHERE '
|
||||
. 'id IN ('
|
||||
. 'SELECT user_id FROM posters WHERE id IN ( '
|
||||
. 'SELECT poster_id FROM posters_history AS pr WHERE send_email = 0 AND mail_settings = 3 AND DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) < \'' . date( 'Y-m-d 20' ) . '\' GROUP BY poster_id ) )' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $users ) and count( $users ) )
|
||||
{
|
||||
foreach ( $users as $user )
|
||||
{
|
||||
$posters = $mdb -> query( 'SELECT '
|
||||
. 'pr.id, url, title, price, comment, mail_settings '
|
||||
. 'FROM '
|
||||
. 'posters_history AS pr '
|
||||
. 'INNER JOIN posters AS p ON p.id = pr.poster_id '
|
||||
. 'WHERE '
|
||||
. 'send_email = 0 '
|
||||
. 'AND '
|
||||
. 'mail_settings = 3 '
|
||||
. 'AND '
|
||||
. 'DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) < \'' . date( 'Y-m-d 20' ) . '\' '
|
||||
. 'AND '
|
||||
. 'user_id = ' . $user['id'] ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $posters ) and count( $posters ) )
|
||||
{
|
||||
foreach ( $posters as $poster )
|
||||
{
|
||||
$posters_id[] = $poster['id'];
|
||||
$auctions[] = $poster;
|
||||
}
|
||||
|
||||
\factory\Posters::send_emails( $user['email'], $auctions, ' | mail zbiorczy 2 razy dziennie (20:00)' );
|
||||
$mdb -> query( 'UPDATE posters_history SET send_email = 1 WHERE id IN ( ' . implode( ',', $posters_id ) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Wysyłam powiadomienia mailowe o znalezionych ogłoszeniach.'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if ( date( 'Y-m-d H:i:s' ) > date( 'Y-m-d 20:00:00' ) )
|
||||
{
|
||||
/* powiadomienia zbiorcze raz dziennie - o godzinie 20 */
|
||||
$users = $mdb -> query( 'SELECT '
|
||||
. 'id, email '
|
||||
. 'FROM '
|
||||
. 'users '
|
||||
. 'WHERE '
|
||||
. 'id IN ('
|
||||
. 'SELECT user_id FROM posters WHERE id IN ( '
|
||||
. 'SELECT poster_id FROM posters_history AS pr WHERE send_email = 0 AND mail_settings = 4 AND DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) < \'' . date( 'Y-m-d 20' ) . '\' GROUP BY poster_id ) )' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $users ) and count( $users ) )
|
||||
{
|
||||
foreach ( $users as $user )
|
||||
{
|
||||
$posters = $mdb -> query( 'SELECT '
|
||||
. 'pr.id, url, title, price, comment, mail_settings '
|
||||
. 'FROM '
|
||||
. 'posters_history AS pr '
|
||||
. 'INNER JOIN posters AS p ON p.id = pr.poster_id '
|
||||
. 'WHERE '
|
||||
. 'send_email = 0 '
|
||||
. 'AND '
|
||||
. 'mail_settings = 4 '
|
||||
. 'AND '
|
||||
. 'DATE_FORMAT( pr.date, \'%Y-%m-%d %H\' ) < \'' . date( 'Y-m-d 20' ) . '\' '
|
||||
. 'AND '
|
||||
. 'user_id = ' . $user['id'] ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $posters ) and count( $posters ) )
|
||||
{
|
||||
foreach ( $posters as $poster )
|
||||
{
|
||||
$posters_id[] = $poster['id'];
|
||||
$auctions[] = $poster;
|
||||
}
|
||||
|
||||
\factory\Posters::send_emails( $user['email'], $auctions, ' | mail zbiorczy raz dziennie (20:00)' );
|
||||
$mdb -> query( 'UPDATE posters_history SET send_email = 1 WHERE id IN ( ' . implode( ',', $posters_id ) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Wysyłam powiadomienia mailowe o znalezionych ogłoszeniach.'
|
||||
];
|
||||
}
|
||||
}
|
||||
return [ 'status' => 'bad' ];
|
||||
}
|
||||
}
|
||||
113
autoload/factory/class.Tickets.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?
|
||||
namespace factory;
|
||||
class Tickets {
|
||||
|
||||
static public function recalculate_ticket_protection( $basket ) {
|
||||
global $settings;
|
||||
|
||||
if ( !\S::get_session( 'ticket_protection' ) )
|
||||
return $basket;
|
||||
|
||||
$quantity = 0;
|
||||
|
||||
foreach ( $basket as $key => $val ) {
|
||||
foreach ( $val as $key2 => $val2 ) {
|
||||
if ( $key != 'gift-price' and $key != 'ticket-protection' ) {
|
||||
$quantity += $val2['quantity'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $quantity > 0 ) {
|
||||
$basket['ticket-protection'][0] = [
|
||||
'name' => 'Ochrona kupującego',
|
||||
'ticket_price' => $settings['tickets']['ticket-protection']['price'],
|
||||
'quantity' => $quantity,
|
||||
'product_id' => 0,
|
||||
'ticket_id' => 'ticket-protection',
|
||||
];
|
||||
} else {
|
||||
unset( $basket['ticket-protection'] );
|
||||
}
|
||||
|
||||
return $basket;
|
||||
}
|
||||
|
||||
static public function remove_ticket_protection() {
|
||||
global $settings;
|
||||
|
||||
$basket = \S::get_session( 'basket' );
|
||||
|
||||
if ( isset( $basket['ticket-protection'] ) ) {
|
||||
unset( $basket['ticket-protection'] );
|
||||
}
|
||||
|
||||
\S::set_session( 'basket', $basket );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function add_ticket_protection() {
|
||||
global $settings;
|
||||
|
||||
$basket = \S::get_session( 'basket' );
|
||||
$quantity = 0;
|
||||
|
||||
foreach ( $basket as $key => $val ) {
|
||||
|
||||
foreach ( $val as $key2 => $val2 ) {
|
||||
|
||||
if ( $key != 'gift-price' and $key != 'ticket-protection' ) {
|
||||
|
||||
$quantity += $val2['quantity'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$basket['ticket-protection'][0] = [
|
||||
'name' => 'Ochrona kupującego',
|
||||
'ticket_price' => $settings['tickets']['ticket-protection']['price'],
|
||||
'quantity' => $quantity,
|
||||
'product_id' => 0,
|
||||
'ticket_id' => 'ticket-protection',
|
||||
];
|
||||
|
||||
\S::set_session( 'basket', $basket );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function get_order_details_by_hash( $hash )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$order = $mdb -> get( 'orders', '*', [ 'hash' => $hash]);
|
||||
if ( $order )
|
||||
{
|
||||
$order['tickets'] = $mdb -> select( 'order_tickets', '*', [ 'order_id' => $order['id']]);
|
||||
}
|
||||
|
||||
if ( $order ){
|
||||
return $order;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static public function get_order_details_by_przelewy24_hash( $hash )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$order = $mdb -> get( 'orders', '*', [ 'payment_hash' => $hash]);
|
||||
if ( $order )
|
||||
{
|
||||
$order['tickets'] = $mdb -> select( 'order_tickets', '*', [ 'order_id' => $order['id']]);
|
||||
}
|
||||
|
||||
if ( $order ){
|
||||
return $order;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
64
autoload/factory/class.Users.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace factory;
|
||||
class Users
|
||||
{
|
||||
static public function user_details( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'users', '*', [ 'id' => $user_id ] );
|
||||
}
|
||||
|
||||
public static function get_default_project( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'users', 'default_project', [ 'id' => $user_id ] );
|
||||
}
|
||||
|
||||
public static function get_user_email( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'users', 'email', [ 'id' => $user_id ] );
|
||||
}
|
||||
|
||||
public static function user_name( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$user = $mdb -> get( 'users', '*', [ 'id' => $user_id ] );
|
||||
|
||||
return $user['name'] . ' ' . $user['surname'];
|
||||
}
|
||||
|
||||
public static function users_list()
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> select( 'users', '*' );
|
||||
}
|
||||
|
||||
public static function settings_save( $user_id, $pushover_api, $pushover_user )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> update( 'users', [
|
||||
'pushover_api' => $pushover_api,
|
||||
'pushover_user' => $pushover_user
|
||||
], [
|
||||
'id' => $user_id
|
||||
] );
|
||||
}
|
||||
|
||||
public static function login( $email, $password )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$result = $mdb -> get( 'users', '*', [ 'email' => strtolower( $email ) ] );
|
||||
if ( $result === false )
|
||||
return false;
|
||||
else
|
||||
{
|
||||
if ( $password == $result['password'] )
|
||||
return $result;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
autoload/view/.htaccess
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
RewriteRule ^index\.php$ - [L]
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule . /index.php [L]
|
||||
</IfModule>
|
||||
11
autoload/view/class.Cron.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace view;
|
||||
|
||||
class Cron
|
||||
{
|
||||
public static function main_view()
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
return $tpl -> render( 'cron/main-view' );
|
||||
}
|
||||
}
|
||||
36
autoload/view/class.Site.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace view;
|
||||
class Site
|
||||
{
|
||||
public static function show()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$class = '\controls\\';
|
||||
|
||||
$results = explode( '_', \S::get( 'module' ) );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
$class .= ucfirst( $row );
|
||||
|
||||
$action = \S::get( 'action' );
|
||||
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> content = \controls\Site::route();
|
||||
|
||||
if ( ( $class == '\controls\Apanel' && $action != 'login_view' ) && !$user )
|
||||
{
|
||||
header( 'Location: /apanel/login_view/' );
|
||||
exit;
|
||||
// return $tpl -> render( 'site/layout-unlogged' );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $alert = \S::get_session( 'alert' ) )
|
||||
{
|
||||
$tpl -> alert = $alert;
|
||||
unset( $_SESSION['alert'] );
|
||||
}
|
||||
return $tpl -> render( 'site/layout-logged' );
|
||||
}
|
||||
}
|
||||
}
|
||||
18
autoload/view/class.Users.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace view;
|
||||
class Users
|
||||
{
|
||||
public static function points_history( $user )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> user = $user;
|
||||
return $tpl -> render( 'users/points-history' );
|
||||
}
|
||||
|
||||
public static function settings( $user )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> user = $user;
|
||||
return $tpl -> render( 'users/settings' );
|
||||
}
|
||||
}
|
||||
232
config.php
Normal file
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
if ( $_GET['debug'] == 'lower_price_ticket' )
|
||||
$_SESSION['lower_price_ticket'] = true;
|
||||
|
||||
$database['name'] = 'srv81099_brzez_ticket';
|
||||
$database['host'] = 'localhost';
|
||||
$database['user'] = 'srv81099_brzez_ticket';
|
||||
$database['password'] = 'jvVtWNrvWr7c4HhepYDu';
|
||||
|
||||
$settings['email_host'] = 'h53.seohost.pl';
|
||||
$settings['email_port'] = 25;
|
||||
$settings['email_login'] = 'bilety@brzezovka.pl';
|
||||
$settings['email_password'] = 'biletyonline';
|
||||
|
||||
$settings['tickets']['enable_sell'] = true;
|
||||
|
||||
// $settings['tickets']['price_0day'][indywidua] = 5;
|
||||
// $settings['tickets']['price_0day'][rodzinn1] = 5;
|
||||
// $settings['tickets']['price_0day'][rodzinny2] = 5;
|
||||
//TODO: Bilet ulgowy - do 140 cm wzrostu
|
||||
if ( $_SESSION['lower_price_ticket'] )
|
||||
$settings['tickets']['plac-zabaw-ulgowy']['price'] = 1;
|
||||
else
|
||||
$settings['tickets']['plac-zabaw-ulgowy']['price'] = 45;
|
||||
|
||||
$settings['tickets']['plac-zabaw-ulgowy']['price_promo'] = 36;
|
||||
$settings['tickets']['plac-zabaw-ulgowy']['dynamic_prices'] = [
|
||||
'day0' => 5,
|
||||
'day1_2' => 3,
|
||||
'day3_7' => 1,
|
||||
];
|
||||
$settings['tickets']['plac-zabaw-ulgowy']['name'] = 'Park rozrywki i dinozaurów - ulgowy';
|
||||
$settings['tickets']['plac-zabaw-ulgowy']['color'] = "orange";
|
||||
$settings['tickets']['plac-zabaw-ulgowy']['product_id'] = 1;
|
||||
|
||||
|
||||
$settings['tickets']['park-wodny-ulgowy']['price']= 35;
|
||||
$settings['tickets']['park-wodny-ulgowy']['price_promo']= 28;
|
||||
$settings['tickets']['park-wodny-ulgowy']['dynamic_prices'] = [
|
||||
'day0' => 5,
|
||||
'day1_2' => 3,
|
||||
'day3_7' => 1,
|
||||
];
|
||||
$settings['tickets']['park-wodny-ulgowy']['name']= 'Park wodny - ulgowy';
|
||||
$settings['tickets']['park-wodny-ulgowy']['color']= 'blue';
|
||||
$settings['tickets']['park-wodny-ulgowy']['product_id'] = 2;
|
||||
$settings['tickets']['park-wodny-ulgowy']['alert'] = "strefa wodna czynna od 28.06.2025";
|
||||
|
||||
|
||||
$settings['tickets']['gift-plac-zabaw-ulgowy']['price'] = 45;
|
||||
// $settings['tickets']['gift-plac-zabaw-ulgowy']['price_promo'] = 999;
|
||||
$settings['tickets']['gift-plac-zabaw-ulgowy']['dynamic_prices'] = [
|
||||
'day0' => 5,
|
||||
'day1_2' => 3,
|
||||
'day3_7' => 1,
|
||||
];
|
||||
$settings['tickets']['gift-plac-zabaw-ulgowy']['name'] = 'Bilet prezentowy Park Rozrywki i Dinozaurów - ulgowy';
|
||||
$settings['tickets']['gift-plac-zabaw-ulgowy']['color'] = "orange";
|
||||
$settings['tickets']['gift-plac-zabaw-ulgowy']['product_id'] = 10;
|
||||
|
||||
$settings['bilety-ulgowe'] = array(
|
||||
'plac-zabaw-ulgowy',
|
||||
'gift-plac-zabaw-ulgowy',
|
||||
// 'park-historyczny-ulgowy',
|
||||
'park-wodny-ulgowy'
|
||||
);
|
||||
|
||||
//TODO: Bilet normalny - od 140 cm wzrostu
|
||||
$settings['tickets']['plac-zabaw-normalny']['price'] = 52;
|
||||
$settings['tickets']['plac-zabaw-normalny']['price_promo'] = 41.60;
|
||||
$settings['tickets']['plac-zabaw-normalny']['dynamic_prices'] = [
|
||||
'day0' => 5,
|
||||
'day1_2' => 3,
|
||||
'day3_7' => 1,
|
||||
];
|
||||
$settings['tickets']['plac-zabaw-normalny']['name'] = "Park rozrywki i dinozaurów - normalny";
|
||||
$settings['tickets']['plac-zabaw-normalny']['color'] = "orange";
|
||||
$settings['tickets']['plac-zabaw-normalny']['product_id'] = 3;
|
||||
|
||||
|
||||
$settings['tickets']['park-wodny-normalny']['price'] = 40;
|
||||
$settings['tickets']['park-wodny-normalny']['price_promo'] = 32;
|
||||
$settings['tickets']['park-wodny-normalny']['dynamic_prices'] = [
|
||||
'day0' => 5,
|
||||
'day1_2' => 3,
|
||||
'day3_7' => 1,
|
||||
];
|
||||
$settings['tickets']['park-wodny-normalny']['name'] = "Park wodny - normalny";
|
||||
$settings['tickets']['park-wodny-normalny']['color'] = "blue";
|
||||
$settings['tickets']['park-wodny-normalny']['product_id'] = 4;
|
||||
$settings['tickets']['park-wodny-normalny']['alert'] = "strefa wodna czynna od 28.06.2025";
|
||||
|
||||
|
||||
$settings['tickets']['gift-plac-zabaw-normalny']['price'] = 52;
|
||||
// $settings['tickets']['plac-zabaw-normalny']['price_promo'] = 999;
|
||||
$settings['tickets']['gift-plac-zabaw-normalny']['dynamic_prices'] = [
|
||||
'day0' => 5,
|
||||
'day1_2' => 3,
|
||||
'day3_7' => 1,
|
||||
];
|
||||
$settings['tickets']['gift-plac-zabaw-normalny']['name'] = "Bilet prezentowy Park Rozrywki i Dinozaurów - normalny";
|
||||
$settings['tickets']['gift-plac-zabaw-normalny']['color'] = "orange";
|
||||
$settings['tickets']['gift-plac-zabaw-normalny']['product_id'] = 9;
|
||||
|
||||
$settings['bilety-normalne'] = array(
|
||||
'plac-zabaw-normalny',
|
||||
// 'park-historyczny-normalny',
|
||||
'gift-plac-zabaw-normalny',
|
||||
'park-wodny-normalny',
|
||||
);
|
||||
|
||||
|
||||
//TODO: Bilety All Open - bilety do wszystkich parków
|
||||
$settings['tickets']['bilet-all-open-ulgowy']['price']= 75;
|
||||
$settings['tickets']['bilet-all-open-ulgowy']['price_promo']= 60;
|
||||
$settings['tickets']['bilet-all-open-ulgowy']['dynamic_prices'] = [
|
||||
'day0' => 5,
|
||||
'day1_2' => 3,
|
||||
'day3_7' => 1,
|
||||
];
|
||||
$settings['tickets']['bilet-all-open-ulgowy']['name']= 'All Open - ulgowy';
|
||||
$settings['tickets']['bilet-all-open-ulgowy']['color']= 'green';
|
||||
$settings['tickets']['bilet-all-open-ulgowy']['product_id'] = 5;
|
||||
|
||||
|
||||
$settings['tickets']['bilet-all-open-normalny']['price']= 85;
|
||||
$settings['tickets']['bilet-all-open-normalny']['price_promo']= 68.80;
|
||||
$settings['tickets']['bilet-all-open-normalny']['dynamic_prices'] = [
|
||||
'day0' => 5,
|
||||
'day1_2' => 3,
|
||||
'day3_7' => 1,
|
||||
];
|
||||
$settings['tickets']['bilet-all-open-normalny']['name']= 'All Open - normalny';
|
||||
$settings['tickets']['bilet-all-open-normalny']['color']= 'green';
|
||||
$settings['tickets']['bilet-all-open-normalny']['product_id'] = 6;
|
||||
|
||||
|
||||
$settings['tickets']['gift-bilet-all-open-ulgowy']['price']= 75;
|
||||
// $settings['tickets']['gift-bilet-all-open-ulgowy']['price_promo']= 999;
|
||||
$settings['tickets']['gift-bilet-all-open-ulgowy']['dynamic_prices'] = [
|
||||
'day0' => 5,
|
||||
'day1_2' => 3,
|
||||
'day3_7' => 1,
|
||||
];
|
||||
$settings['tickets']['gift-bilet-all-open-ulgowy']['name']= 'Bilet prezentowy All Open - ulgowy';
|
||||
$settings['tickets']['gift-bilet-all-open-ulgowy']['color']= 'green';
|
||||
$settings['tickets']['gift-bilet-all-open-ulgowy']['product_id'] = 5;
|
||||
|
||||
|
||||
$settings['tickets']['gift-bilet-all-open-normalny']['price']= 85;
|
||||
// $settings['tickets']['gift-bilet-all-open-normalny']['price_promo']= 999;
|
||||
$settings['tickets']['gift-bilet-all-open-normalny']['dynamic_prices'] = [
|
||||
'day0' => 5,
|
||||
'day1_2' => 3,
|
||||
'day3_7' => 1,
|
||||
];
|
||||
$settings['tickets']['gift-bilet-all-open-normalny']['name']= 'Bilet prezentowy All Open - normalny';
|
||||
$settings['tickets']['gift-bilet-all-open-normalny']['color']= 'green';
|
||||
$settings['tickets']['gift-bilet-all-open-normalny']['product_id'] = 11;
|
||||
|
||||
$settings['bilety-all-open'] = array(
|
||||
'bilet-all-open-ulgowy',
|
||||
'bilet-all-open-normalny',
|
||||
'gift-bilet-all-open-ulgowy',
|
||||
'gift-bilet-all-open-normalny',
|
||||
|
||||
);
|
||||
|
||||
//TODO: Bilety rodzinne - bilety dla rodzin
|
||||
$settings['tickets']['bilet-rodzina-2+1']['price']= 220;
|
||||
$settings['tickets']['bilet-rodzina-2+1']['price_promo']= 176;
|
||||
$settings['tickets']['bilet-rodzina-2+1']['dynamic_prices'] = [
|
||||
'day0' => 15,
|
||||
'day1_2' => 9,
|
||||
'day3_7' => 1,
|
||||
];
|
||||
$settings['tickets']['bilet-rodzina-2+1']['name']= 'Rodzina 2+1';
|
||||
$settings['tickets']['bilet-rodzina-2+1']['color']= 'violet';
|
||||
$settings['tickets']['bilet-rodzina-2+1']['product_id'] = 7;
|
||||
|
||||
|
||||
$settings['tickets']['bilet-rodzina-2+2']['price']= 280;
|
||||
$settings['tickets']['bilet-rodzina-2+2']['price_promo']= 224;
|
||||
$settings['tickets']['bilet-rodzina-2+2']['dynamic_prices'] = [
|
||||
'day0' => 20,
|
||||
'day1_2' => 12,
|
||||
'day3_7' => 1,
|
||||
];
|
||||
$settings['tickets']['bilet-rodzina-2+2']['name']= 'Rodzina 2+2';
|
||||
$settings['tickets']['bilet-rodzina-2+2']['color']= 'violet';
|
||||
$settings['tickets']['bilet-rodzina-2+2']['product_id'] = 8;
|
||||
|
||||
$settings['bilety-rodzinne'] = array(
|
||||
'bilet-rodzina-2+1',
|
||||
'bilet-rodzina-2+2'
|
||||
);
|
||||
|
||||
$settings['tickets']['gift-price']['price']= 15;
|
||||
$settings['tickets']['gift-price']['name']= 'Koszt przesyłki';
|
||||
$settings['tickets']['gift-price']['product_id'] = 999999;
|
||||
|
||||
$settings['gift-price-delivery'] = array(
|
||||
'gift-price'
|
||||
);
|
||||
|
||||
//TODO: Karnet imienny - na cały sezon
|
||||
$settings['tickets']['karnet-imienny-na-caly-sezon']['price']= 250;
|
||||
// $settings['tickets']['karnet-imienny-na-caly-sezon']['price_promo']= 176;
|
||||
$settings['tickets']['karnet-imienny-na-caly-sezon']['dynamic_prices'] = [
|
||||
'day0' => 0,
|
||||
'day1_2' => 0,
|
||||
'day3_7' => 0,
|
||||
];
|
||||
$settings['tickets']['karnet-imienny-na-caly-sezon']['name']= 'Karnet imienny na cały sezon';
|
||||
$settings['tickets']['karnet-imienny-na-caly-sezon']['color']= 'violet';
|
||||
$settings['tickets']['karnet-imienny-na-caly-sezon']['product_id'] = 12;
|
||||
|
||||
$settings['karnety'] = array(
|
||||
'karnet-imienny-na-caly-sezon'
|
||||
);
|
||||
|
||||
$settings['tickets']['ticket-protection']['price'] = 5;
|
||||
$settings['tickets']['ticket-protection']['name'] = 'Ochrona kupującego';
|
||||
$settings['tickets']['ticket-protection']['product_id'] = 0;
|
||||
|
||||
$settings['p24']['merchant_id'] = '227658';
|
||||
$settings['p24']['pos_id'] = '227658';
|
||||
$settings['p24']['crc_key'] = '6f83d724c84e9bae';
|
||||
$settings['p24']['sandbox_crc_key'] = 'a48ba2394a52373a';
|
||||
$settings['p24']['sandbox'] = false;
|
||||
|
||||
$settings['admin-password'] = 'Admin2022!';
|
||||
116
cron.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
error_reporting( E_ALL ^ E_NOTICE ^ E_STRICT ^ E_WARNING ^ E_DEPRECATED );
|
||||
|
||||
function __autoload_my_classes( $classname )
|
||||
{
|
||||
$q = explode( '\\', $classname );
|
||||
$c = array_pop( $q );
|
||||
$f = 'autoload/' . implode( '/', $q ) . '/class.' . $c . '.php';
|
||||
|
||||
if ( file_exists( $f ) )
|
||||
require_once( $f );
|
||||
}
|
||||
spl_autoload_register( '__autoload_my_classes' );
|
||||
date_default_timezone_set( 'Europe/Warsaw' );
|
||||
|
||||
require_once 'config.php';
|
||||
require_once 'libraries/medoo/medoo.php';
|
||||
require_once 'libraries/grid/config.php';
|
||||
require_once 'libraries/rb.php';
|
||||
|
||||
session_start();
|
||||
|
||||
if ( !isset( $_SESSION['check'] ) )
|
||||
{
|
||||
session_regenerate_id();
|
||||
$_SESSION['check'] = true;
|
||||
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
if ( $_SESSION['ip'] !== $_SERVER['REMOTE_ADDR'] )
|
||||
{
|
||||
session_destroy();
|
||||
header( 'Location: /' );
|
||||
exit;
|
||||
}
|
||||
|
||||
$mdb = new medoo( [
|
||||
'database_type' => 'mysql',
|
||||
'database_name' => $database['name'],
|
||||
'server' => $database['host'],
|
||||
'username' => $database['user'],
|
||||
'password' => $database['password'],
|
||||
'charset' => 'utf8'
|
||||
] );
|
||||
|
||||
\R::setup( 'mysql:host=' . $database['host'] . ';dbname=' . $database['name'],
|
||||
$database['user'], $database['password'] );
|
||||
\R::ext( 'xdispense',
|
||||
function( $type )
|
||||
{
|
||||
return R::getRedBean() -> dispense( $type );
|
||||
} );
|
||||
|
||||
/* wysyłanie przypomnnień do zadań */
|
||||
$response = \Cron::tasks_emails();
|
||||
if ( $response['status'] == 'ok' )
|
||||
{
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
/* dodawanie zadań rekursywnych */
|
||||
$response = \Cron::recursive_tasks();
|
||||
if ( $response['status'] == 'ok' )
|
||||
{
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( date( 'G' ) >= 12 )
|
||||
{
|
||||
/* import do ceidg */
|
||||
$response = \Cron::ceidg_download();
|
||||
if ( $response['status'] == 'ok' )
|
||||
{
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* import do ceidg */
|
||||
$response = \Cron::ceidg_import();
|
||||
if ( $response['status'] == 'ok' )
|
||||
{
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
/* przeniesienie starych firm do innej tabeli */
|
||||
if ( $ceidg = \R::findOne( 'ceidg', 'data_wykreslenia IS NOT NULL AND data_wykreslenia < ?', [date( 'Y-m-d', strtotime( '-1 years', time() ) )] ) )
|
||||
{
|
||||
$ceidg_old = \R::xdispense( 'ceidg_old' );
|
||||
|
||||
$properties = $ceidg -> getProperties();
|
||||
foreach ( $properties as $key => $val )
|
||||
{
|
||||
if ( $key != 'id' )
|
||||
$ceidg_old[$key] = $val;
|
||||
}
|
||||
|
||||
\R::store( $ceidg_old );
|
||||
|
||||
\R::trash( $ceidg );
|
||||
|
||||
echo json_encode( [
|
||||
'status' => 'ok',
|
||||
'msg' => 'Przenoszę starą firmę ' . $ceidg -> firma
|
||||
] );
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
echo json_encode( ['status' => 'empty'] );
|
||||
|
||||
//echo '<hr/>' . ( microtime( true ) - $_SERVER["REQUEST_TIME_FLOAT"] );
|
||||
?>
|
||||
75
custom.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
include 'libraries/medoo/medoo.php';
|
||||
|
||||
$mdb = new medoo( [
|
||||
'database_type' => 'mysql',
|
||||
'database_name' => 'martins_bilety',
|
||||
'server' => 'localhost',
|
||||
'username' => 'martins_bilety',
|
||||
'password' => 'fnT1G)-cOJA6x[-v',
|
||||
'charset' => 'utf8'
|
||||
] );
|
||||
|
||||
// $results = $mdb->select('orders', '*', ['payment_status' => 1]);
|
||||
// $results = $mdb->select('orders', '*', [
|
||||
// 'AND' => [
|
||||
// 'payment_status' => 1,
|
||||
// 'id' => 171
|
||||
// ]
|
||||
// ]);
|
||||
|
||||
// foreach ( $results as $order ) {
|
||||
// $order['tickets'] = $mdb -> select( 'order_tickets', '*', [ 'order_id' => $order['id'] ] );
|
||||
|
||||
// $api = array();
|
||||
// $api["api_id"] = "9fa7772af97ab35b6d8a1cd05ac9e1b5";
|
||||
// $api["api_zadanie"] = "1";
|
||||
// $api["dokument_rodzaj"] = "20";
|
||||
// $api["dokument_dostep"] = "1";
|
||||
// $api["dokument_miejsce"] = "Brzezovka sklep internetowy";
|
||||
// $api["dokument_data_w"] = date("d-m-Y", strtotime($order['date_added']));
|
||||
// $api["dokument_data_s"] = date("d-m-Y", strtotime($order['payment_date']));
|
||||
|
||||
// $api["nabywca_imie"] = $order['name'];
|
||||
// $api["nabywca_nazwisko"] = $order['surname'];
|
||||
// $api["nabywca_email"] = $order['email'];
|
||||
|
||||
// if($order['city']){
|
||||
// $api["nabywca_miasto"] = $order['city'];
|
||||
// }
|
||||
// if($order['zip_code']){
|
||||
// $api["nabywca_kod"] = $order['zip_code'];
|
||||
// }
|
||||
// if($order['street']){
|
||||
// $api["nabywca_ulica"] = $order['street'];
|
||||
// }
|
||||
|
||||
// foreach ($order['tickets'] as $key => $value)
|
||||
// {
|
||||
// $key += 1;
|
||||
// $api["produkt_nazwa_$key"] = $value['name'];
|
||||
// $api["produkt_ilosc_$key"] = $value['quantity'];
|
||||
// $api["produkt_jm_$key"] = "2";
|
||||
// $api["produkt_stawka_vat_$key"] = "23";
|
||||
// $api["produkt_wartosc_brutto_$key"] = $value['price'] * $value['quantity'];
|
||||
// }
|
||||
|
||||
// $curl = curl_init();
|
||||
// curl_setopt($curl, CURLOPT_URL, "https://www.fakturowo.pl/api");
|
||||
// curl_setopt($curl, CURLOPT_POST, 1);
|
||||
// curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 300);
|
||||
// curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
// curl_setopt($curl, CURLOPT_POSTFIELDS, $api);
|
||||
// $result = curl_exec($curl);
|
||||
// curl_close($curl);
|
||||
|
||||
// $result = explode("\n", $result);
|
||||
|
||||
// if($result[0] == 1) {
|
||||
// $mdb -> update( 'orders', ['invoice_url' => $result[2]], ['id' => $order['id']] );
|
||||
// }
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($result);
|
||||
// echo '<br/>---<br/></pre>';
|
||||
// }
|
||||
52
index.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
session_start();
|
||||
error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT ^ E_WARNING ^ E_DEPRECATED);
|
||||
function __autoload_my_classes($classname)
|
||||
{
|
||||
$q = explode('\\', $classname);
|
||||
$c = array_pop($q);
|
||||
$f = 'autoload/' . implode('/', $q) . '/class.' . $c . '.php';
|
||||
|
||||
if (file_exists($f)) {
|
||||
require_once($f);
|
||||
}
|
||||
}
|
||||
spl_autoload_register('__autoload_my_classes');
|
||||
date_default_timezone_set('Europe/Warsaw');
|
||||
|
||||
require_once 'config.php';
|
||||
require_once 'libraries/medoo/medoo.php';
|
||||
require_once 'libraries/grid/config.php';
|
||||
require_once 'libraries/phpmailer/class.phpmailer.php';
|
||||
require_once 'libraries/phpmailer/class.smtp.php';
|
||||
require_once 'libraries/rb.php';
|
||||
require_once "libraries/phpqrcode/qrlib.php";
|
||||
|
||||
|
||||
if (!isset($_SESSION['check'])) {
|
||||
session_regenerate_id();
|
||||
$_SESSION['check'] = true;
|
||||
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
if ($_SESSION['ip'] !== $_SERVER['REMOTE_ADDR']) {
|
||||
session_destroy();
|
||||
header('Location: /');
|
||||
exit;
|
||||
}
|
||||
|
||||
\R::setup('mysql:host=' . $database['host'] . ';dbname=' . $database['name'], $database['user'], $database['password']);
|
||||
\R::ext('xdispense', function ($type) {
|
||||
return R::getRedBean() -> dispense($type);
|
||||
});
|
||||
|
||||
$mdb = new medoo([
|
||||
'database_type' => 'mysql',
|
||||
'database_name' => $database['name'],
|
||||
'server' => $database['host'],
|
||||
'username' => $database['user'],
|
||||
'password' => $database['password'],
|
||||
'charset' => 'utf8'
|
||||
]);
|
||||
$user = \S::get_session('user');
|
||||
echo \view\Site::show();
|
||||
BIN
layout/images/bg-unlogged.jpg
Normal file
|
After Width: | Height: | Size: 71 KiB |
BIN
layout/images/logo-white.png
Normal file
|
After Width: | Height: | Size: 8.5 KiB |
BIN
layout/images/logo.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
layout/images/no-image.jpg
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
1
layout/style-css/style.css
Normal file
1
layout/style-css/style.css.map
Normal file
145
layout/style-scss/_mixins.scss
Normal file
@@ -0,0 +1,145 @@
|
||||
$breakpoints: (
|
||||
xs: 576px,
|
||||
sm: 768px,
|
||||
md: 992px,
|
||||
lg: 1200px,
|
||||
);
|
||||
@mixin respond-above($breakpoint) {
|
||||
@if map-has-key($breakpoints, $breakpoint) {
|
||||
$breakpoint-value: map-get($breakpoints, $breakpoint);
|
||||
@media (min-width: $breakpoint-value) {
|
||||
@content;
|
||||
}
|
||||
} @else {
|
||||
@warn 'Invalid breakpoint: #{$breakpoint}.';
|
||||
}
|
||||
}
|
||||
@mixin respond-below($breakpoint) {
|
||||
@if map-has-key($breakpoints, $breakpoint) {
|
||||
$breakpoint-value: map-get($breakpoints, $breakpoint);
|
||||
@media (max-width: ($breakpoint-value - 1)) {
|
||||
@content;
|
||||
}
|
||||
} @else {
|
||||
@warn 'Invalid breakpoint: #{$breakpoint}.';
|
||||
}
|
||||
}
|
||||
@mixin respond-between($lower, $upper) {
|
||||
@if map-has-key($breakpoints, $lower) and map-has-key($breakpoints, $upper) {
|
||||
$lower-breakpoint: map-get($breakpoints, $lower);
|
||||
$upper-breakpoint: map-get($breakpoints, $upper);
|
||||
@media (min-width: $lower-breakpoint) and (max-width: ($upper-breakpoint - 1)) {
|
||||
@content;
|
||||
}
|
||||
} @else {
|
||||
@if (map-has-key($breakpoints, $lower) == false) {
|
||||
@warn 'Your lower breakpoint was invalid: #{$lower}.';
|
||||
}
|
||||
@if (map-has-key($breakpoints, $upper) == false) {
|
||||
@warn 'Your upper breakpoint was invalid: #{$upper}.';
|
||||
}
|
||||
}
|
||||
}
|
||||
@mixin border-radius($px: 0) {
|
||||
-webkit-border-radius: $px;
|
||||
-moz-border-radius: $px;
|
||||
border-radius: $px;
|
||||
}
|
||||
@mixin box-shadow($value) {
|
||||
-webkit-box-shadow: $value;
|
||||
-moz-box-shadow: $value;
|
||||
box-shadow: $value;
|
||||
}
|
||||
@mixin transition($element: all, $time: 0.5s, $option: ease) {
|
||||
-webkit-transition: $element $time $option !important;
|
||||
transition: $element $time $option !important;
|
||||
}
|
||||
@mixin opacity($value) {
|
||||
$IEValue: $value * 100;
|
||||
opacity: $value;
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + $IEValue +
|
||||
")";
|
||||
filter: alpha(opacity=$IEValue);
|
||||
}
|
||||
@mixin flexbox() {
|
||||
display: -webkit-box;
|
||||
display: -moz-box;
|
||||
display: -ms-flexbox;
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
}
|
||||
@mixin flex($values) {
|
||||
-webkit-box-flex: $values;
|
||||
-moz-box-flex: $values;
|
||||
-webkit-flex: $values;
|
||||
-ms-flex: $values;
|
||||
flex: $values;
|
||||
}
|
||||
@mixin flex-direction($direction) {
|
||||
-webkit-flex-direction: $direction;
|
||||
-moz-flex-direction: $direction;
|
||||
-ms-flex-direction: $direction;
|
||||
flex-direction: $direction;
|
||||
}
|
||||
@mixin flex-wrap($wrap) {
|
||||
-webkit-flex-wrap: $wrap;
|
||||
-moz-flex-wrap: $wrap;
|
||||
-ms-flex-wrap: $wrap;
|
||||
flex-wrap: $wrap;
|
||||
}
|
||||
@mixin flex-flow($flow) {
|
||||
-webkit-flex-flow: $flow;
|
||||
-moz-flex-flow: $flow;
|
||||
-ms-flex-flow: $flow;
|
||||
flex-flow: $flow;
|
||||
}
|
||||
@mixin order($val) {
|
||||
-webkit-box-ordinal-group: $val;
|
||||
-moz-box-ordinal-group: $val;
|
||||
-ms-flex-order: $val;
|
||||
-webkit-order: $val;
|
||||
order: $val;
|
||||
}
|
||||
@mixin flex-grow($grow) {
|
||||
-webkit-flex-grow: $grow;
|
||||
-moz-flex-grow: $grow;
|
||||
-ms-flex-grow: $grow;
|
||||
flex-grow: $grow;
|
||||
}
|
||||
@mixin flex-shrink($shrink) {
|
||||
-webkit-flex-shrink: $shrink;
|
||||
-moz-flex-shrink: $shrink;
|
||||
-ms-flex-shrink: $shrink;
|
||||
flex-shrink: $shrink;
|
||||
}
|
||||
@mixin flex-basis($width) {
|
||||
-webkit-flex-basis: $width;
|
||||
-moz-flex-basis: $width;
|
||||
-ms-flex-basis: $width;
|
||||
flex-basis: $width;
|
||||
}
|
||||
@mixin justify-content($justify) {
|
||||
-webkit-justify-content: $justify;
|
||||
-moz-justify-content: $justify;
|
||||
-ms-justify-content: $justify;
|
||||
justify-content: $justify;
|
||||
-ms-flex-pack: $justify;
|
||||
}
|
||||
@mixin align-content($align) {
|
||||
-webkit-align-content: $align;
|
||||
-moz-align-content: $align;
|
||||
-ms-align-content: $align;
|
||||
align-content: $align;
|
||||
}
|
||||
@mixin align-items($align) {
|
||||
-webkit-align-items: $align;
|
||||
-moz-align-items: $align;
|
||||
-ms-align-items: $align;
|
||||
align-items: $align;
|
||||
}
|
||||
@mixin align-self($align) {
|
||||
-webkit-align-self: $align;
|
||||
-moz-align-self: $align;
|
||||
-ms-align-self: $align;
|
||||
align-self: $align;
|
||||
}
|
||||
218
layout/style-scss/_stuff.scss
Normal file
@@ -0,0 +1,218 @@
|
||||
.clearfix {
|
||||
&:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
}
|
||||
|
||||
.clear {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
a {
|
||||
@include transition();
|
||||
}
|
||||
|
||||
.btn {
|
||||
@include transition();
|
||||
@include border-radius(3px);
|
||||
padding: 0 15px 0 0 !important;
|
||||
border: 0;
|
||||
line-height: 28px !important;
|
||||
font-size: 14px;
|
||||
|
||||
&:focus {
|
||||
@include box-shadow(none);
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
i {
|
||||
@include transition();
|
||||
@include border-radius(3px 0 0 3px);
|
||||
display: block;
|
||||
float: left;
|
||||
height: 28px;
|
||||
width: 28px;
|
||||
text-align: center;
|
||||
line-height: 28px;
|
||||
margin-right: 15px;
|
||||
|
||||
@include respond-below(xs) {
|
||||
margin-right: 7px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
@extend .btn;
|
||||
background: #5aba47;
|
||||
color: #FFF !important;
|
||||
border: 0 !important;
|
||||
|
||||
i {
|
||||
background: #379126;
|
||||
}
|
||||
|
||||
&:hover,
|
||||
&.acive,
|
||||
&:focus {
|
||||
background: #379126;
|
||||
|
||||
i {
|
||||
background: #257315;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
@extend .btn;
|
||||
background: $cBlueLight !important;
|
||||
border: 0 !important;
|
||||
color: #FFF;
|
||||
|
||||
i {
|
||||
background: #1394ce;
|
||||
}
|
||||
|
||||
&:hover,
|
||||
&.active,
|
||||
&.focus {
|
||||
background: #03a9f4 !important;
|
||||
color: #FFF;
|
||||
|
||||
i {
|
||||
background: #1394ce;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.btn-dark {
|
||||
@extend .btn;
|
||||
background: #bcbcbc;
|
||||
color: #FFF;
|
||||
|
||||
i {
|
||||
background: #646474;
|
||||
}
|
||||
|
||||
&:hover,
|
||||
&.active,
|
||||
&:focus {
|
||||
background: #646474;
|
||||
color: #FFF;
|
||||
|
||||
i {
|
||||
background: #333333;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
@extend .btn;
|
||||
background: #f75b50;
|
||||
color: #FFF;
|
||||
|
||||
i {
|
||||
background: #d24d44;
|
||||
}
|
||||
|
||||
&:hover,
|
||||
&.acive,
|
||||
&:focus {
|
||||
background: #f52d1f;
|
||||
|
||||
i {
|
||||
background: #d0261a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.form-control {
|
||||
@include border-radius(0);
|
||||
}
|
||||
|
||||
#g-form-container {
|
||||
@include box-shadow(0 13px 25px -2px rgba(0, 0, 0, 0.2));
|
||||
background: #FFF;
|
||||
padding: 15px 25px 25px;
|
||||
border: 1px solid #f1f1f1;
|
||||
|
||||
.col-form-label {
|
||||
font-size: 14px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
input,
|
||||
textarea,
|
||||
select {
|
||||
font-size: 14px;
|
||||
|
||||
&.error {
|
||||
border: 1px solid $cRed;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
@include box-shadow(none);
|
||||
}
|
||||
}
|
||||
|
||||
.input-group-addon {
|
||||
@include border-radius(0);
|
||||
text-align: center;
|
||||
line-height: 38px;
|
||||
font-size: 13px;
|
||||
padding: 0;
|
||||
width: 38px;
|
||||
background: $cBlueLight;
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
.switch {
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.alert {
|
||||
background: $cOrange;
|
||||
color: #FFF;
|
||||
border: 0;
|
||||
font-size: 13px;
|
||||
|
||||
&.login {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.hidden-xs {
|
||||
@include respond-below(xs) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.text-system {
|
||||
color: $cGreen;
|
||||
}
|
||||
|
||||
/* autocomplete tagsinput*/
|
||||
.label-info {
|
||||
background-color: #5bc0de;
|
||||
display: inline-block;
|
||||
padding: 7px 10px;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
.vertical-middle {
|
||||
@include flexbox;
|
||||
@include align-items(center);
|
||||
}
|
||||
1197
layout/style-scss/style.scss
Normal file
3924
libraries/phpmailer/class.phpmailer.php
Normal file
BIN
orders/0/0/00b1870ea2c27f95cc6b8a79326da988.png
Normal file
|
After Width: | Height: | Size: 403 B |
BIN
orders/0/0/00d4731f73ef366a5d283f9df3e4e0b4.png
Normal file
|
After Width: | Height: | Size: 405 B |
BIN
orders/0/5/0580a39afc949bd0d79909541f92dd8d.png
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
orders/0/5/05ecd06d96092f2494eb595657e9c170.png
Normal file
|
After Width: | Height: | Size: 417 B |
BIN
orders/0/6/06bf895aefe73d96c220d34320c9b1ef.png
Normal file
|
After Width: | Height: | Size: 405 B |
BIN
orders/1/e/1e8eb6de16750a2d4f28917b72f9620c.png
Normal file
|
After Width: | Height: | Size: 404 B |
BIN
orders/2/8/283cbf8d8596f8785e3e55380ea64b3d.png
Normal file
|
After Width: | Height: | Size: 412 B |
BIN
orders/4/1/41b35697ac95919c204ef94c9fd76c18.png
Normal file
|
After Width: | Height: | Size: 417 B |
BIN
orders/4/2/42aa0f44351b9f3b73119b1a0b763a91.png
Normal file
|
After Width: | Height: | Size: 402 B |
BIN
orders/5/9/59ef7bc8f464fa6d61a1bc302e63e87a.png
Normal file
|
After Width: | Height: | Size: 404 B |
BIN
orders/6/4/64e4bf90e8be9cf16ad3c9e2e48db531.png
Normal file
|
After Width: | Height: | Size: 405 B |
BIN
orders/6/9/69120abe28ce1d3a172995ebf19e46b5.png
Normal file
|
After Width: | Height: | Size: 405 B |
BIN
orders/6/a/6a39da4002c99904a23f8bdffbb9f3f2.png
Normal file
|
After Width: | Height: | Size: 400 B |
BIN
orders/8/b/8b47c74db03fa468b98146c65f72e4e3.png
Normal file
|
After Width: | Height: | Size: 405 B |
BIN
orders/8/e/8e1151ddfee0b552ca05362ccb93bec4.png
Normal file
|
After Width: | Height: | Size: 407 B |
BIN
orders/9/2/9224cac8a1f7a2f1867209adcb220bca.png
Normal file
|
After Width: | Height: | Size: 405 B |
BIN
orders/9/6/9625c1861d2ea16f1920425c8638f47d.png
Normal file
|
After Width: | Height: | Size: 399 B |
BIN
orders/9/c/9ca99956c4b729c57d38c8fa97873637.png
Normal file
|
After Width: | Height: | Size: 400 B |
BIN
orders/9/c/9cbdf84e6675393a64f3d4ba9b7f2d89.png
Normal file
|
After Width: | Height: | Size: 415 B |
BIN
orders/9/e/9e82b8e722defb1cfd205b3fbca56415.png
Normal file
|
After Width: | Height: | Size: 420 B |
BIN
orders/a/0/a0ac567a7f2cb51e2c1af414b12d187c.png
Normal file
|
After Width: | Height: | Size: 408 B |
BIN
orders/a/2/a253ca142247a543d4a82184823049c2.png
Normal file
|
After Width: | Height: | Size: 398 B |
BIN
orders/a/3/a3125a56567a69f81df9c62977ac036b.png
Normal file
|
After Width: | Height: | Size: 410 B |
BIN
orders/a/a/aa5429ca1504fffa73dc51e3ee5ccabb.png
Normal file
|
After Width: | Height: | Size: 396 B |
BIN
orders/a/b/ab385735da32754cac3771a18d65e8f1.png
Normal file
|
After Width: | Height: | Size: 399 B |
BIN
orders/a/b/abe354b0babc452399f3b0bf75ef5b6b.png
Normal file
|
After Width: | Height: | Size: 411 B |
BIN
orders/a/f/af1ef99320b2de9e6d7dd505fa4c5a4c.png
Normal file
|
After Width: | Height: | Size: 407 B |
BIN
orders/c/9/c9b7cc8d33c11126a111d75dfcaf1729.png
Normal file
|
After Width: | Height: | Size: 407 B |
BIN
orders/c/e/ce51c7fb9cafdfeaeef6ac1cfe75c1a9.png
Normal file
|
After Width: | Height: | Size: 402 B |
BIN
orders/c/f/cf5298d35e6475ee5d46cc1640d133de.png
Normal file
|
After Width: | Height: | Size: 461 B |
BIN
orders/d/0/d0dddabcb18d55a9a5c344b04927e3c5.png
Normal file
|
After Width: | Height: | Size: 416 B |
BIN
orders/d/1/d1531cd384f68413ab192f52ac69aaa6.png
Normal file
|
After Width: | Height: | Size: 405 B |
BIN
orders/e/6/e618cfa6867950a525a03931d5ba88bb.png
Normal file
|
After Width: | Height: | Size: 407 B |
BIN
orders/e/c/ec2d2cefab8e72d4bf6b2aa49bbe3ba5.png
Normal file
|
After Width: | Height: | Size: 409 B |
BIN
orders/f/0/f03e85d9404a42a19b690571bbc76b45.png
Normal file
|
After Width: | Height: | Size: 406 B |
BIN
orders/f/7/f7c805a2a17162f5cacc8ec025148af5.png
Normal file
|
After Width: | Height: | Size: 404 B |
BIN
orders/f/d/fd0ea2de49177201f8c9836f8efcace6.png
Normal file
|
After Width: | Height: | Size: 410 B |
BIN
orders/f/e/fe30725247fc0715a4db2175162d4482.png
Normal file
|
After Width: | Height: | Size: 414 B |
2
robots.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow: /
|
||||
11
templates/admin-panel/login.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<div class="alogin-page">
|
||||
<div class="panel-login container">
|
||||
<form action="/apanel/login_check/" method="POST">
|
||||
<div class="form-group">
|
||||
<input type="password" name="admin_password" id="password" class="form-control" placeholder="Hasło">
|
||||
|
||||
</div>
|
||||
<button type="submit" class="btn-t1">zaloguj się</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
55
templates/admin-panel/main-view.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
$orderArr = $this->orders;
|
||||
?>
|
||||
<div id="tickets-orders">
|
||||
<div class="container">
|
||||
<div class="tickets-orders">
|
||||
<h1>Lista zamówień</h1>
|
||||
<div class="orders-list">
|
||||
<div style="overflow-x:auto;">
|
||||
<table class="table table-striped" id="myTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">id</th>
|
||||
<th scope="col">Imię</th>
|
||||
<th scope="col">Nazwisko</th>
|
||||
<th scope="col">Email</th>
|
||||
<th scope="col">Cena</th>
|
||||
<th scope="col">Status płatności</th>
|
||||
<th scope="col">Status biletu</th>
|
||||
<th scope="col">Data zakupu</th>
|
||||
<th>Edytuj</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? foreach ($orderArr as $key => $value) : ?>
|
||||
<tr>
|
||||
<td scope="row"><?= $value['id']; ?></td>
|
||||
<td><?= $value['name']; ?></td>
|
||||
<td><?= $value['surname']; ?></td>
|
||||
<td><?= $value['email']; ?></td>
|
||||
<td><?= $value['order_price']; ?></td>
|
||||
<td><?= $value['payment_status'] == 1 ? 'Zapłacono': 'Nie zapłacono'; ?></td>
|
||||
<td><?= $value['used_ticket'] == 1 ? 'Wykorzystany': 'Nie wykorzystany'; ?></td>
|
||||
<td><?= $value['date_added']; ?></td>
|
||||
<td class="edit-btn"><a href="/apanel/order_data/id=<?= $value['id']; ?>"><i
|
||||
class="fa-regular fa-pen-to-square"></i></a></td>
|
||||
</tr>
|
||||
<? endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var table = $('#myTable').DataTable({
|
||||
"pagingType": "simple",
|
||||
order: [
|
||||
[0, 'desc']
|
||||
],
|
||||
});
|
||||
});
|
||||
</script>
|
||||
49
templates/admin-panel/order-data-table.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
$orderData = $this->order_tickets;
|
||||
?>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h3>BILETY</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>TERMIN</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>CENA</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>WARTOŚĆ</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>ZMIENIĆ ILOŚĆ</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>USUŃ</h3>
|
||||
</th>
|
||||
</tr>
|
||||
<?php foreach ($orderData as $key => $value) : ?>
|
||||
<tr>
|
||||
<td><?= $value['name']; ?> ( x <?= $value["quantity"]; ?>)</td>
|
||||
<td><?= $value['date_visit'] ? date('d/m/Y', strtotime($value['date_visit'])) : ''; ?></td>
|
||||
<td><?= $value['price']; ?> zł</td>
|
||||
<td><?= $value['price'] * $value["quantity"]; ?> zł</td>
|
||||
<td>
|
||||
<? if ( $value['product_id'] != 0 and $value['product_id'] != 999999 ) : ?>
|
||||
<button class="btn_t1 add" ticket_id="<?= $key; ?>">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
</button>
|
||||
<button class="btn_t1 subtract" ticket_id="<?= $key; ?>">
|
||||
<i class="fa-solid fa-minus"></i>
|
||||
</button>
|
||||
<? endif;?>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn_t1 delete" ticket_id="<?= $key; ?>">
|
||||
<i class="fa-solid fa-trash-can"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
346
templates/admin-panel/order-data.php
Normal file
@@ -0,0 +1,346 @@
|
||||
<?php
|
||||
$ticketsData = $this->order_tickets;
|
||||
$orderInfo = $this->order_info;
|
||||
?>
|
||||
|
||||
<div id="order-data">
|
||||
<div class="order-data">
|
||||
<div class="container">
|
||||
<div class="mini-nav-menu">
|
||||
<a href="/apanel/main_view/" class="btn-t1">Lista zamówień</a>
|
||||
</div>
|
||||
<div class="box_01">
|
||||
<input type="hidden" name="order_id" id="order_id" value="<?= $ticketsData[0]['order_id'] ?>">
|
||||
<div class="box-tickets-list">
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h3>BILETY</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>TERMIN</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>CENA</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>WARTOŚĆ</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>ZMIENIĆ ILOŚĆ</h3>
|
||||
</th>
|
||||
<th>
|
||||
<h3>USUŃ</h3>
|
||||
</th>
|
||||
</tr>
|
||||
<?php foreach ($ticketsData as $key => $value) : ?>
|
||||
<? $ticketsPrice += $value['price'] * $value['quantity'];?>
|
||||
<tr>
|
||||
<td><?= $value['name']; ?> ( x <?= $value["quantity"]; ?>)</td>
|
||||
<td><?= $value['date_visit'] ? date('d/m/Y', strtotime($value['date_visit'])) : ''; ?></td>
|
||||
<td><?= $value['price']; ?> zł</td>
|
||||
<td><?= $value['price'] * $value["quantity"]; ?> zł</td>
|
||||
<td>
|
||||
<? if ( $value['product_id'] != 0 and $value['product_id'] != 999999 ) : ?>
|
||||
<button class="btn_t1 add" ticket_id="<?= $key; ?>">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
</button>
|
||||
<button class="btn_t1 subtract" ticket_id="<?= $key; ?>">
|
||||
<i class="fa-solid fa-minus"></i>
|
||||
</button>
|
||||
<? endif;?>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn_t1 delete" ticket_id="<?= $key; ?>">
|
||||
<i class="fa-solid fa-trash-can"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_02">
|
||||
<div class="row">
|
||||
<div class="order-detale-info col-lg-8 col-md-8 col-xs-12">
|
||||
<div class="order-detale-info__wrapper">
|
||||
<h2>SZCZEGÓŁY</h2>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="name" class="col-lg-3 col-form-label">Status płatności</label>
|
||||
<div class="col-lg-9">
|
||||
<select name="payment_status" class="form-control">
|
||||
<option value="0" <?= $orderInfo[0]['payment_status'] == 0 ? 'selected' : ''; ?>>Nie zapłacono</option>
|
||||
<option value="1" <?= $orderInfo[0]['payment_status'] == 1 ? 'selected' : ''; ?>>Zapłacono</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="name" class="col-lg-3 col-form-label">Imię</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" class="form-control" id="name" name="name" value="<?= $orderInfo[0]['name']; ?>"
|
||||
disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="surname" class="col-lg-3 col-form-label">Nazwisko</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" class="form-control" id="surname" name="surname"
|
||||
value="<?= $orderInfo[0]['surname']; ?>" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="email" class="col-lg-3 col-form-label">Email</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="email" class="form-control" id="email" name="email" value="<?= $orderInfo[0]['email']; ?>"
|
||||
disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="zip_code" class="col-lg-3 col-form-label">Kod pocztowy</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" class="form-control" id="zip_code" name="zip_code"
|
||||
value="<?= $orderInfo[0]['zip_code']; ?>" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="city" class="col-lg-3 col-form-label">Miejscowość</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" class="form-control" id="city" name="city" value="<?= $orderInfo[0]['city']; ?>"
|
||||
disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="street" class="col-lg-3 col-form-label">Ulica</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" class="form-control" id="street" name="street" value="<?= $orderInfo[0]['street']; ?>"
|
||||
disabled>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<? if(!empty($orderInfo[0]['gift_address'])) : ?>
|
||||
<div class="form-group row mb-lg-2" id="gift_address_box">
|
||||
<label for="gift_address" class="col-lg-3 col-form-label">Dane do wysyłki biletu prezentowego</label>
|
||||
<div class="col-lg-9">
|
||||
<textarea rows="5" type="text" class="form-control" id="gift_address" name="gift_address" disabled><?= $orderInfo[0]['gift_address']; ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<? endif; ?>
|
||||
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="date-added-ticket" class="col-lg-3 col-form-label">Data dodanie</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" class="form-control" id="date-added-ticket" name="date-added-ticket"
|
||||
value="<?= $orderInfo[0]['date_added']; ?>" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="date-pay-ticket" class="col-lg-3 col-form-label">Data płatności</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" class="form-control" id="date-pay-ticket" name="date-pay-ticket"
|
||||
value="<?= $orderInfo[0]['payment_date']; ?>" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="pay-status" class="col-lg-3 col-form-label">Status płatności</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" class="form-control" id="pay-status" name="pay-status"
|
||||
value="<?= $orderInfo[0]['payment_status'] ? 'Zapłacono' : 'Nie zapłacono'; ?>" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="ticket-status" class="col-lg-3 col-form-label">Status biletu</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" class="form-control" id="ticket-status" name="ticket-status"
|
||||
value="<?= $orderInfo[0]['used_ticket'] ? 'Wykorzystany' : 'Nie wykorzystany'; ?>" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<? if($orderInfo[0]['used_ticket_date']) : ?>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="ticket-use-date" class="col-lg-3 col-form-label">Data wykorzystania</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" class="form-control" id="ticket-use-date" name="ticket-use-date"
|
||||
value="<?= $orderInfo[0]['used_ticket_date']; ?>" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<? endif; ?>
|
||||
<!-- <pre>
|
||||
<?= var_dump($orderInfo[0]['vat']); ?>
|
||||
</pre> -->
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="date-pay-ticket" class="col-lg-3 col-form-label"><?= $orderInfo[0]['vat'] ? "Faktura" : 'Paragon'; ?></label>
|
||||
<div class="col-lg-9">
|
||||
<a href="<?= $orderInfo[0]['invoice_url']; ?>"><?= $orderInfo[0]['invoice_url']; ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($orderInfo[0]['vat']) : ?>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="company_name" class="col-lg-3 col-form-label">Nazwa firmy</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" class="form-control" id="company_name" name="company_name" disabled value="<?= $orderInfo[0]['company_name']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-lg-2">
|
||||
<label for="nip" class="col-lg-3 col-form-label">NIP</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" class="form-control" id="nip" name="nip" disabled value="<?= $orderInfo[0]['nip']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="order-summary col-lg-4 col-md-4 col-xs-12">
|
||||
<div class="order-summary__wrapper">
|
||||
<h2>Suma:</h2>
|
||||
<p id="order-general-price"><?= $ticketsPrice; ?> zł</p>
|
||||
<hr>
|
||||
<div class="flex flex-buttons-group">
|
||||
<button class="btn-t1 btn-save-new-list">Zapisz</button>
|
||||
<a href="#" class="btn btn-danger btn-delete-order" data-id="<?= $orderInfo[0]['id']; ?>">Usuń zamówienie</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
// add
|
||||
$('body').on('click', '.add', function() {
|
||||
var ticket_id = $(this).attr('ticket_id');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/apanel/ticket_inc/',
|
||||
data: {
|
||||
ticket_id: ticket_id,
|
||||
},
|
||||
success: function(data) {
|
||||
response = jQuery.parseJSON(data);
|
||||
$('.box_01 .box-tickets-list').html(response.basket_form);
|
||||
$('.box_02 .order-summary').html(response.order_summ);
|
||||
$('.btn-save-new-list').attr('disabled', false)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// subtract
|
||||
$('body').on('click', '.subtract', function() {
|
||||
var ticket_id = $(this).attr('ticket_id');
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/apanel/ticket_dec/',
|
||||
data: {
|
||||
ticket_id: ticket_id,
|
||||
},
|
||||
success: function(data) {
|
||||
response = jQuery.parseJSON(data);
|
||||
$('.box_01 .box-tickets-list').html(response.basket_form);
|
||||
$('.box_02 .order-summary').html(response.order_summ);
|
||||
$('.btn-save-new-list').attr('disabled', false)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//remove
|
||||
$('body').on('click', '.delete', function() {
|
||||
var ticket_id = $(this).attr('ticket_id');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/apanel/ticket_rem/',
|
||||
data: {
|
||||
ticket_id: ticket_id,
|
||||
},
|
||||
success: function(data) {
|
||||
response = jQuery.parseJSON(data);
|
||||
$('.box_01 .box-tickets-list').html(response.basket_form);
|
||||
$('.box_02 .order-summary').html(response.order_summ);
|
||||
$('.btn-save-new-list').attr('disabled', false)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.btn-delete-order', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
var order_id = $(this).attr( 'data-id' );
|
||||
$.alert({
|
||||
title: 'Pytanie',
|
||||
content: 'Na pewno chcesz usunąć wybrane zamówienie?',
|
||||
type: 'orange',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-times',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
columnClass: 'col-12 col-lg-10',
|
||||
theme: 'modern',
|
||||
icon: 'fa fa-question',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Tak',
|
||||
btnClass: 'btn-success',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
document.location.href = '/apanel/order_delete/order_id=' + order_id;
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: 'Nie',
|
||||
btnClass: 'btn-dark',
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
|
||||
//save
|
||||
$('body').on('click', '.btn-save-new-list', function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/apanel/ticket_save/',
|
||||
data: {
|
||||
order_id: $('#order_id').val(),
|
||||
payment_status: $('select[name="payment_status"]').val()
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('.btn-save-new-list').attr('disabled', true)
|
||||
},
|
||||
complete: function(data) {
|
||||
$.alert({
|
||||
icon: 'fa-regular fa-face-smile-beam',
|
||||
title: 'Zmiany zapisano',
|
||||
content: '',
|
||||
typeAnimated: true,
|
||||
animation: 'scale',
|
||||
closeAnimation: 'scale',
|
||||
autoClose: 'confirm|10000',
|
||||
bgOpacity: '0.5',
|
||||
type: 'green',
|
||||
theme: 'modern',
|
||||
columnClass: 'col-md-6 col-md-offset-3',
|
||||
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Zamknij',
|
||||
btnClass: 'btn-green btn-alert',
|
||||
keys: ['enter'],
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
</script>
|
||||
16
templates/admin-panel/order-summary.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<div class="order-summary__wrapper">
|
||||
<h2>Suma:</h2>
|
||||
<?php
|
||||
$finalPrice = 0;
|
||||
foreach (($this->order_tickets) as $data => $value)
|
||||
{
|
||||
$finalPrice += $value['price'] * $value['quantity'];
|
||||
}
|
||||
?>
|
||||
<p id="order-general-price"><?= $finalPrice; ?> zł</p>
|
||||
<hr>
|
||||
<div class="flex flex-buttons-group">
|
||||
<button class="btn-t1 btn-save-new-list">Zapisz</button>
|
||||
<a href="#" class="btn btn-danger btn-delete-order" data-id="<?= $this -> order_id; ?>">Usuń zamówienie</a>
|
||||
</div>
|
||||
</div>
|
||||
10
templates/components/spinner.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<div class="lds-roller">
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
</div>
|
||||
97
templates/cron/main-view.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'cron';
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Cron';
|
||||
$grid -> default_buttons = false;
|
||||
$grid -> external_code = '<div class="countdown callback"></div><div id="cron-container"></div>';
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
<script type="text/javascript" src="/libraries/countdown/jquery.countdown.js"></script>
|
||||
<script type="text/javascript">
|
||||
var delay = 1;
|
||||
$( document ).ready( function()
|
||||
{
|
||||
$( '#content_wrapper' ).css( 'margin', '0px' );
|
||||
|
||||
$( '.countdown.callback' ).countdown(
|
||||
{
|
||||
date: +(new Date) + 1000,
|
||||
render: function(data)
|
||||
{
|
||||
$( this.el ).text( this.leadingZeros( data.sec, 2 ) + " sek" );
|
||||
},
|
||||
onEnd: function()
|
||||
{
|
||||
$( this.el ).addClass( 'ended' );
|
||||
cron();
|
||||
}
|
||||
}).stop();
|
||||
});
|
||||
|
||||
function cron()
|
||||
{
|
||||
$( '.msg:gt(48)' ).remove();
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/cron.php',
|
||||
timeout: ( 30 * 1000 ),
|
||||
data:
|
||||
{
|
||||
cron: 'true'
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
jQuery( '#cron-container' ).css( 'opacity', '0.8' );
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
response = jQuery.parseJSON( data );
|
||||
|
||||
jQuery( '#cron-container' ).css( 'opacity', '1' );
|
||||
|
||||
if ( response.status === 'empty' )
|
||||
{
|
||||
delay++;
|
||||
if ( delay > 60 )
|
||||
delay = 60;
|
||||
|
||||
$( '.countdown.callback' ).removeClass('ended').data('countdown').update( +( new Date ) + delay * 1000 ).start();
|
||||
if ( typeof value === "undefined" )
|
||||
$( '#cron-container' ).prepend( '<div class="msg">W tej chwili nie ma nic do wykonania.</div>' );
|
||||
else
|
||||
$( '#cron-container' ).prepend( '<div class="msg">' + response.msg + '</div>' );
|
||||
}
|
||||
else
|
||||
{
|
||||
delay = 1;
|
||||
$( '#cron-container' ).prepend( '<div class="msg">' + response.msg + '</div>' );
|
||||
$( '.countdown.callback' ).removeClass('ended').data('countdown').update( +( new Date ) + 1 ).start();
|
||||
}
|
||||
},
|
||||
error: function(data)
|
||||
{
|
||||
delay++;
|
||||
if ( delay > 120 )
|
||||
delay = 120;
|
||||
|
||||
$( '#cron-container' ).prepend( '<div class="msg">Błąd podczas połączenia.</div>' );
|
||||
$( '.countdown.callback' ).removeClass('ended').data('countdown').update( +( new Date ) + delay * 1000 ).start();
|
||||
},
|
||||
statusCode:
|
||||
{
|
||||
500: function() {
|
||||
|
||||
delay++;
|
||||
if ( delay > 120 )
|
||||
delay = 120;
|
||||
|
||||
$( '#cron-container' ).prepend( '<div class="msg">Błąd podczas połączenia.</div>' );
|
||||
$( '.countdown.callback' ).removeClass('ended').data('countdown').update( +( new Date ) + delay * 1000 ).start();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
37
templates/html/button.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?
|
||||
if ( $this -> params['type'] == 'submit' )
|
||||
$out .= '<button ';
|
||||
else
|
||||
$out = '<a ';
|
||||
$out .= 'class="btn ' . $this -> params['class'] . '" ';
|
||||
|
||||
if ( $this -> params['style'] )
|
||||
$out .= 'style="' . $this -> params['style'] . '" ';
|
||||
|
||||
if ( $this -> params['js'] )
|
||||
$out .= 'onclick="' . htmlspecialchars( $this -> params['js'] ) . '" ';
|
||||
|
||||
if ( $this -> params['url'] )
|
||||
$out .= 'href="' . htmlspecialchars( $this -> params['url'] ) . '" ';
|
||||
|
||||
if ( $this -> params['id'] )
|
||||
$out .= 'id="' . $this -> params['id'] . '" ';
|
||||
|
||||
if ( $this -> params['title'] )
|
||||
$out .= 'title="' . htmlspecialchars( $this -> params['title'] ) . '" ';
|
||||
|
||||
if ( $this -> params['type'] == 'submit' )
|
||||
$out .= 'type="submit" ';
|
||||
|
||||
$out .= '>';
|
||||
if ( $this -> params['icon'] )
|
||||
$out .= '<i class="fa ' . $this -> params['icon'] . ' mr5"></i>';
|
||||
|
||||
$out .= $this -> params['text'];
|
||||
|
||||
if ( $this -> params['type'] == 'submit' )
|
||||
$out .= '</button';
|
||||
else
|
||||
$out .= '</a>';
|
||||
|
||||
echo $out;
|
||||
8
templates/html/form-text.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<div class="form-group">
|
||||
<label class="col-lg-4 control-label"><?= $this -> params['label'];?>:</label>
|
||||
<div class="col-lg-8">
|
||||
<p class="form-control-static" id="<?= $this -> params['id'];?>">
|
||||
<?= $this -> params['text'];?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
71
templates/html/input-icon.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?
|
||||
if ( $this -> params['label'] )
|
||||
{
|
||||
$out .= '<div class="form-group row">';
|
||||
$out .= '<label class="';
|
||||
if ( !$this -> params['inline'] )
|
||||
$out .= 'col-md-12 text-left ';
|
||||
else
|
||||
$out .= 'col-md-3 ';
|
||||
$out .= 'col-form-label">' . $this -> params['label'] . ':</label>';
|
||||
$out .= '<div class="';
|
||||
if ( !$this -> params['inline'] )
|
||||
$out .= 'col-md-12';
|
||||
else
|
||||
$out .= 'col-md-9';
|
||||
$out .= '">';
|
||||
}
|
||||
$out .= '<div class="input-group">';
|
||||
$out .= '<input ';
|
||||
$out .= 'type="' . $this -> params['type'] . '" ';
|
||||
|
||||
if ( $this -> params['id'] )
|
||||
$out .= 'id="' . $this -> params['id'] . '" ';
|
||||
else
|
||||
$out .= 'id="' . $this -> params['name'] . '" ';
|
||||
|
||||
if ( $this -> params['class'] or $this -> params['label'] )
|
||||
{
|
||||
if ( $this -> params['label'] )
|
||||
$out .= 'class="' . $this -> params['class'] . ' form-control" ';
|
||||
else if ( $this -> params['class'] )
|
||||
$out .= 'class="' . $this -> params['class'] . '" ';
|
||||
}
|
||||
|
||||
$out .= 'name="' . $this -> params['name'] . '" ';
|
||||
$out .= 'value="' . $this -> secureHTML( $this -> params['value'] ) . '" ';
|
||||
|
||||
if ( $this -> params['style'] )
|
||||
$out .= 'style="' . $this -> params['style'] . '" ';
|
||||
|
||||
if ( $this -> params['readonly'] )
|
||||
$out .= 'readonly="readonly" ';
|
||||
|
||||
if ( $this -> params['required'] )
|
||||
$out .= 'required ';
|
||||
|
||||
if ( $this -> params['autocomplete'] == 'off' )
|
||||
$out .= 'autocomplete="off" ';
|
||||
|
||||
$out .= ' />';
|
||||
|
||||
$out .= '<span class="input-group-addon ';
|
||||
if ( $this -> params['icon_js'] )
|
||||
$out .= 'pointer ';
|
||||
$out .= '"';
|
||||
|
||||
if ( $this -> params['icon_js'] )
|
||||
$out .= 'onclick="' . htmlspecialchars( $this -> params['icon_js'] ) . '" ';
|
||||
|
||||
$out .= '>';
|
||||
$out .= $this -> params['icon_content'];
|
||||
$out .= '</span>';
|
||||
$out .= '</div>';
|
||||
|
||||
if ( $this -> params['label'] )
|
||||
{
|
||||
$out .= '</div>';
|
||||
$out .= '</div>';
|
||||
}
|
||||
|
||||
echo $out;
|
||||
36
templates/html/input-switch.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?
|
||||
if ( $this -> params['label'] )
|
||||
{
|
||||
$out .= '<div class="form-group row">';
|
||||
$out .= '<label class="col-md-3 col-form-label">' . $this -> params['label'] . ':</label>';
|
||||
$out .= '<div class="col-md-9">';
|
||||
}
|
||||
|
||||
$out .= '<div class="switch switch-primary round switch-inline">';
|
||||
$out .= '<input ';
|
||||
|
||||
if ( $this -> params['id'] )
|
||||
$out .= 'id="' . $this -> params['id'] . '" ';
|
||||
else
|
||||
$out .= 'id="' . $this -> params['name'] . '" ';
|
||||
$out .= 'name="' . $this -> params['name'] . '" type="checkbox"';
|
||||
|
||||
if ( $this -> params['checked'] )
|
||||
$out .= 'checked="checked" ';
|
||||
|
||||
$out .= '>';
|
||||
$out .= '<label for="';
|
||||
if ( $this -> params['id'] )
|
||||
$out .= $this -> params['id'];
|
||||
else
|
||||
$out .= $this -> params['name'];
|
||||
$out .= '"></label>';
|
||||
$out .= '</div>';
|
||||
|
||||
if ( $this -> params['label'] )
|
||||
{
|
||||
$out .= '</div>';
|
||||
$out .= '</div>';
|
||||
}
|
||||
|
||||
echo $out;
|
||||
59
templates/html/input.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?
|
||||
if ( $this -> params['label'] )
|
||||
{
|
||||
$out .= '<div class="form-group row">';
|
||||
$out .= '<label class="';
|
||||
if ( !$this -> params['inline'] )
|
||||
$out .= 'col-md-12 text-left ';
|
||||
else
|
||||
$out .= 'col-md-3 ';
|
||||
$out .= 'col-form-label">' . $this -> params['label'] . ':</label>';
|
||||
$out .= '<div class="';
|
||||
if ( !$this -> params['inline'] )
|
||||
$out .= 'col-md-12';
|
||||
else
|
||||
$out .= 'col-md-9';
|
||||
$out .= '">';
|
||||
}
|
||||
|
||||
$out .= '<input ';
|
||||
$out .= 'type="' . $this -> params['type'] . '" ';
|
||||
|
||||
if ( $this -> params['id'] )
|
||||
$out .= 'id="' . $this -> params['id'] . '" ';
|
||||
|
||||
if ( $this -> params['class'] or $this -> params['label'] )
|
||||
{
|
||||
if ( $this -> params['label'] )
|
||||
$out .= 'class="' . $this -> params['class'] . ' form-control" ';
|
||||
else if ( $this -> params['class'] )
|
||||
$out .= 'class="' . $this -> params['class'] . '" ';
|
||||
}
|
||||
|
||||
$out .= 'name="' . $this -> params['name'] . '" ';
|
||||
$out .= 'value="' . $this -> secureHTML( $this -> params['value'] ) . '" ';
|
||||
|
||||
if ( $this -> params['style'] )
|
||||
$out .= 'style="' . $this -> params['style'] . '" ';
|
||||
|
||||
if ( $this -> params['readonly'] )
|
||||
$out .= 'readonly="readonly" ';
|
||||
|
||||
if ( $this -> params['required'] )
|
||||
$out .= 'required ';
|
||||
|
||||
if ( $this -> params['autocomplete'] == 'off' )
|
||||
$out .= 'autocomplete="off" ';
|
||||
|
||||
if ( $this -> params['placeholder'] )
|
||||
$out .= 'placeholder="' . $this -> params['placeholder'] . '" ';
|
||||
|
||||
$out .= ' />';
|
||||
|
||||
if ( $this -> params['label'] )
|
||||
{
|
||||
$out .= '</div>';
|
||||
$out .= '</div>';
|
||||
}
|
||||
|
||||
echo $out;
|
||||
8
templates/html/panel.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<div class="panel <?= $this -> params['class'];?>">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title"><?= $this -> params['title'];?></span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<?= $this -> params['content'];?>
|
||||
</div>
|
||||
</div>
|
||||
56
templates/html/select.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?
|
||||
if ( $this -> params['label'] )
|
||||
{
|
||||
$out .= '<div class="form-group row';
|
||||
if ( $this -> params['inline'] )
|
||||
$out .= 'pl10 pr10';
|
||||
$out .= '">';
|
||||
$out .= '<label class="';
|
||||
if ( !$this -> params['inline'] )
|
||||
$out .= 'col-md-3 ';
|
||||
if ( $this -> params['inline'] )
|
||||
$out .= 'mb5 ';
|
||||
$out .= 'col-form-label">' . $this -> params['label'] . ':</label>';
|
||||
$out .= '<div class="';
|
||||
if ( !$this -> params['inline'] )
|
||||
$out .= 'col-md-9';
|
||||
$out .= '">';
|
||||
}
|
||||
|
||||
$out .= '<select ';
|
||||
|
||||
if ( $this -> params['id'] )
|
||||
$out .= 'id="' . $this -> params['id'] . '" ';
|
||||
|
||||
if ( $this -> params['class'] or $this -> params['label'] )
|
||||
{
|
||||
if ( $this -> params['label'] )
|
||||
$out .= 'class="' . $this -> params['class'] . ' form-control" ';
|
||||
else if ( $this -> params['class'] )
|
||||
$out .= 'class="' . $this -> params['class'] . '" ';
|
||||
}
|
||||
|
||||
$out .= 'name="' . $this -> params['name'] . '" ';
|
||||
|
||||
if ( $this -> params['style'] )
|
||||
$out .= 'style="' . $this -> params['style'] . '" ';
|
||||
|
||||
$out .= '>';
|
||||
|
||||
if ( $this -> params['empty'] )
|
||||
$out .= '<option value="">--- ' . mb_strtolower( $this -> params['label'], 'UTF-8' ) . ' ---</option>';
|
||||
|
||||
if ( is_array( $this -> params['values'] ) ) foreach ( $this -> params['values'] as $key => $val )
|
||||
{
|
||||
$out .= '<option value="' . $key . '"'; if ( $key == $this -> params['value'] ) $out .= 'selected="selected"'; $out .='>' . $val . '</option>';
|
||||
}
|
||||
|
||||
$out .= '</select>';
|
||||
|
||||
if ( $this -> params['label'] )
|
||||
{
|
||||
$out .= '</div>';
|
||||
$out .= '</div>';
|
||||
}
|
||||
|
||||
echo $out;
|
||||
49
templates/html/textarea.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?
|
||||
if ( $this -> params['label'] )
|
||||
{
|
||||
$out .= '<div class="form-group row';
|
||||
if ( $this -> params['inline'] )
|
||||
$out .= 'pl10 pr10';
|
||||
$out .= '">';
|
||||
$out .= '<label class="';
|
||||
if ( !$this -> params['inline'] )
|
||||
$out .= 'col-md-3 ';
|
||||
if ( $this -> params['inline'] )
|
||||
$out .= 'mb5 ';
|
||||
$out .= 'col-form-label">' . $this -> params['label'] . ':</label>';
|
||||
$out .= '<div class="';
|
||||
if ( !$this -> params['inline'] )
|
||||
$out .= 'col-md-9';
|
||||
$out .= '">';
|
||||
}
|
||||
|
||||
$out .= '<textarea ';
|
||||
|
||||
if ( $this -> params['id'] )
|
||||
$out .= 'id="' . $this -> params['id'] . '" ';
|
||||
|
||||
if ( $this -> params['class'] or $this -> params['label'] )
|
||||
{
|
||||
if ( $this -> params['label'] )
|
||||
$out .= 'class="' . $this -> params['class'] . ' form-control" ';
|
||||
else if ( $this -> params['class'] )
|
||||
$out .= 'class="' . $this -> params['class'] . '" ';
|
||||
}
|
||||
|
||||
$out .= 'name="' . $this -> params['name'] . '" ';
|
||||
|
||||
if ( $this -> params['style'] )
|
||||
$out .= 'style="' . $this -> params['style'] . '" ';
|
||||
|
||||
if ( $this -> params['placeholder'] )
|
||||
$out .= 'placeholder="' . $this -> params['placeholder'] . '" ';
|
||||
|
||||
$out .= ' rows="' . $this -> params['rows'] . '">' . $this -> secureHTML( $this -> params['value'] ) . '</textarea>';
|
||||
|
||||
if ( $this -> params['label'] )
|
||||
{
|
||||
$out .= '</div>';
|
||||
$out .= '</div>';
|
||||
}
|
||||
|
||||
echo $out;
|
||||
63
templates/site/layout-cron.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>crmPro</title>
|
||||
<meta name="keywords" content="">
|
||||
<meta name="description" content="">
|
||||
<meta name="robots" content="all">
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i&subset=latin-ext"
|
||||
rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/bootstrap-4.1.3/css/bootstrap.css">
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/font-awesome-6.1.1/css/all.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/icheck-1.0.2/skins/square/aero.css">
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/jquery-confirm/jquery-confirm.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/datepicker/css/datepicker.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/layout/style-css/style.css">
|
||||
<script type="text/javascript" src="/libraries/jquery/jquery-3.6.0.min.js"></script>
|
||||
<script type="text/javascript" src="/libraries/bootstrap-4.1.3/js/bootstrap.js"></script>
|
||||
<script type="text/javascript" src="/libraries/icheck-1.0.2/icheck.min.js"></script>
|
||||
<script type="text/javascript" src="/libraries/jquery-confirm/jquery-confirm.min.js"></script>
|
||||
<script type="text/javascript" src="/libraries/datepicker/js/datepicker.min.js"></script>
|
||||
<script type="text/javascript" src="/libraries/datepicker/js/i18n/datepicker.pl.js"></script>
|
||||
<script type="text/javascript" src="/libraries/functions.js"></script>
|
||||
</head>
|
||||
|
||||
<body class="logged">
|
||||
<div id="top">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12 col-sm-6">
|
||||
<a href="/" id="logo">search<span>Pro</span></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main-menu">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#">Kontakt</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div class="container-fluid">
|
||||
<? if ( $this -> alert ):?>
|
||||
<div class="alert"><?= $this -> alert;?></div>
|
||||
<? endif;?>
|
||||
<?= $this -> content;?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||