-
Notifications
You must be signed in to change notification settings - Fork 0
/
load.php
92 lines (73 loc) · 2.72 KB
/
load.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
session_start();
include_once('funkcje.php');
include_once 'head.html';
include_once 'nav.html';
echo '<div class="container theme-showcase" role="main">';
echo '<div class="jumbotron">';
include_once('funkcje.php');
if (!isset($_SESSION['kod'])) {
} else {
$kod = $_SESSION['kod'];
echo '<h3>Przetwarzanie</h3>';
loadProduct($kod); //Załadowanie produktu do bazy
if (!isset($_SESSION['pgs'])) {
//Obliczenia stron i offsetu ostatniej z nich
$opinie = countReviews($kod);
$offset = 0;
$strony = ceil($opinie / 10);
$_SESSION['pgs'] = $strony;
$_SESSION['pgsCount'] = 0;
echo ' <div class="alert alert-warning" role="alert">
<strong>Praca w toku!</strong> Dodawanie produktu do bazy.
</div>';
loadProduct($kod);
header('refresh: 1;');
} elseif ($_SESSION['pgsCount'] < $_SESSION['pgs']) {
echo ' <div class="alert alert-warning" role="alert">
<strong>Praca w toku!</strong> Dodawanie opinii do bazy.<br>';
$opinie = countReviews($kod);
$offset = substr($opinie, -1, 1);
print_r("Strona " . $_SESSION['pgsCount'] . " z " . $_SESSION['pgs'] . "</div>");
loadOpinions($kod, $_SESSION['pgsCount'], $offset);
header('refresh: 0.2;');
$_SESSION['pgsCount'] ++;
} else {
print_r("Strona " . $_SESSION['pgsCount'] . " z " . $_SESSION['pgs'] . "<br>");
$opinie = countReviews($kod);
$offset = substr($opinie, -1, 1);
loadOpinions($kod, $_SESSION['pgsCount'], $offset - 1);
echo '<div class="alert alert-success" role="alert">
<strong>Zakończono!</strong>Produkt wraz z opiniami został zapisany w bazie.
</div>';
unset($_SESSION['kod']);
unset($_SESSION['pgs']);
unset($_SESSION['pgsCount']);
$_SESSION = array();
}
}
if (isset($_SESSION['pgs'])) {
$max = $_SESSION['pgs'];
$current = $_SESSION['pgsCount'];
} else {
$current = 100;
$max = 100;
$percentage = ($current / $max) * 100;
}
if ($max != 0) {
$percentage = ($current / $max) * 100;
} else {
$current = 100;
$max = 100;
$percentage = ($current / $max) * 100;
}
echo '<div class="progress">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="' . $current . '" aria-valuemin="0" aria-valuemax="' . $max . '" style="width: ' . $percentage . '%"><span class="sr-only">40% Complete (success)</span></div>
</div>';
// print_r('Autor:'.$tab[2]['nick'].'<br>');
// print_r($tab);
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/