Skip to content

Commit

Permalink
lipiec14
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamRomek committed Jul 14, 2020
1 parent 25e8824 commit 076466f
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 94 deletions.
19 changes: 12 additions & 7 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ legend {
width: 100%;
}
div#content{width:100%;
background-color:#F9B254;
background-color: #ACF2A2;
margin-top: 400px;
}

p{background-color: blanchedalmond;}

label .lab {
float: left;
Expand All @@ -62,14 +62,15 @@ input [type="text"]{
#indeksT{width: 150px; }
#nazwaT{width:450px;}
#jm{width: 100px;}
#ilosc{width: 100px; padding-left:2em;}
#ilosc{width: 70px; }
#cena{width: 100px;}
#vat{width: 100px;}
#vat{width: 50px;}
#pkwiu{width: 100px;}
#cena_brutto{width: 100px;}
#kodKT{width: 150px;}
#kodKT{width: 250px; text-align: right;}
#stan_mag{width:100px; }
#data_zak{width: 60px;}
#marza{width: 50px;}

input[type=text]:focus {
background-color: #ADD8E6;
Expand All @@ -80,9 +81,9 @@ input[type=text]:focus {
.btn{
float: right;
background-color: #F9965C;
margin-top: 5px;
margin: 10px 10px;
}
#button{background-color: #B8ABAB; margin-top: 5px; }
#button{background-color: #B8ABAB; margin: 10px 10px; border-radius: 8px; }

.ui-autocomplete { height: 350px; overflow-y: scroll; overflow-x: hidden;}
.ui-autocomplete-input{font-size: 18px;}
Expand All @@ -95,3 +96,7 @@ input[type=text]:focus {
#id_f{width: 150px;}
#indeksD{width: 150px;}
#nazwa1{width: 150px;}

table, th, td {
border-collapse: collapse;
border:1px solid black;}
1 change: 0 additions & 1 deletion db/connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

echo "Połączone z bazą zoonet_alaska na serwerze NAZWA.PL <br />";

?>
87 changes: 29 additions & 58 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,70 +39,24 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Baza Sklepu ZooNet</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

<style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;margin:0px auto;width: 600px;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:0.3em;
overflow:hidden;padding:5px 5px;word-break:normal;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:1em;
font-weight:normal;overflow:hidden;padding:5px 5px;word-break:normal;width: auto;}
.tg .tg-0lax{text-align:left;vertical-align:top;background-color: #BFBFBF;font-family:Arial, sans-serif;font-size:0.5em;}
</style>
<link type="text/css" href="css/style.css" rel="stylesheet" >
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

</head>
<body>
<nav><div id="top">Dostawcy:<a href="dostawcy.php">Powrót do dostawców</a></div>
<div id="top">Faktura:<a href="KoniecFaktury.php">Koniec faktury</a></div></nav>
<div id="top">Faktura:<a href="KoniecFaktury.php">Koniec faktury</a></div>
</nav>

<header><h3>Wprowadzanie towaru - wyszukiwanie po indeksie, nazwie towaru lub kodach kreskowych</h3></header>
<div id="pojemnik">
<!--
<table class="tg">

<thead>
<tr>
<th class="tg-0lax">Lp</th>
<th class="tg-0lax">Indeks:</th>
<th class="tg-0lax">Nazwa towaru</th>
<th class="tg-0lax">Jm</th>
<th class="tg-0lax">Ilość</th>
<th class="tg-0lax">Cena netto zakupu</th>
<th class="tg-0lax">VAT</th>
<th class="tg-0lax">PKWiU</th>
<th class="tg-0lax">Cena brutto sprzedaży</th>
<th class="tg-0lax">Kod kreskowy</th>
<th class="tg-0lax">Data zakupów</th>
</tr>
</thead>
<tbody>
<form>
<tr>
<td class="tg-0lax"></td>
<td class="tg-0lax"><input id="indeks" type="text" name="indeks" /></td>
<td class="tg-0lax"><input id="nazwa" type="text" name="nazwa" /></td>
<td class="tg-0lax"><input id="jm" type="text" name="jm" /></td>
<td class="tg-0lax"><input id="ilosc" type="text" name="ilosc" /></td>
<td class="tg-0lax"><input id="cena" type="text" name="cena" /> </td>
<td class="tg-0lax"><input id="vat" type="text" name="vat" /></td>
<td class="tg-0lax"><input id="pkwiu" type="text" name="pkwiu" /></td>
<td class="tg-0lax"><input id="cena_brutto" type="text" name="cena_brutto" /></td>
<td class="tg-0lax"><input id="kodK" type="text" name="kodK" /></td>
<td class="tg-0lax"><input id="data_zak" type="text" name="data_zak" /></td>


</tr>
<input class="btn" type="reset" value="Wyczyść rekord" ></form>
</form>
</table> -->


<div id="form">
<form action="index.php?go=zapiszTowar" method="post" enctype="multipart/form-data">


<div id="faktura">
<div id="faktura">
<fieldset>
<legend>Faktura i dostawca</legend>
<label class="lab" for="nr_faktury">Nr faktury</label>
Expand Down Expand Up @@ -137,11 +91,11 @@
<input id="jm" type="text" name="jm" value="szt" >

<label for="ilosc">Ilość</label>&nbsp;&nbsp;
<input id="ilosc" type="text" name="ilosc" value="<?php echo($_GET['ilosc']) ?>" required ><br>
<input id="ilosc" type="text" name="ilosc" value="<?php echo($_GET['ilosc']) ?>" required >


<label class="lab">Cena netto wyliczana z brutto</label>
<input type="text" name="bruttoZb" size="10" onkeyup="licz_Z_brutto(this.form)"> VAT lub RABAT
<input type="text" name="bruttoZb" size="10" onkeyup="licz_Z_brutto(this.form)"><br> VAT lub RABAT
<input type="text" name="vatZb" size="5" onkeyup="licz_Z_brutto(this.form)">

<label class="lab">Cena netto</label>
Expand All @@ -153,10 +107,20 @@
<input id="pkwiu" type="text" name="pkwiu" value="<?php echo($_GET['pkwiu']) ?>" >

<label class="lab" for="vat">VAT</label>
<input id="vat" type="text" name="vat" value="<?php echo($_GET['vat']) ?>" required ><br>
<input id="vat" type="text" name="vat" value="<?php echo($_GET['vat']) ?>" required >

<label class="lab" for="kod_k">Kod kreskowy</label>
<input id="kodKT" type="text" name="kod_k" value="<?php echo($_GET['kod_k']) ?>" >
<?php
$cena_n = ($_GET['cena_z']);
$vat = ($_GET['vat']);
$cena_brutto = ($_GET['cena_brutto']);
$brutto =number_format((($cena_n*$vat/100)+$cena_n), 2, '.', '');
$razem = number_format(($cena_n * $ilosc), 2, '.', '');
$marza = number_format((( $cena_brutto / $brutto )*100-100), 2, '.', '');
?>
<label class="lab" for="marza">Marża</label>
<input id="marza" type="number" name="marza" onkeyup="marzaN(this.form)">

<label class="lab" for="cena_brutto">Cena sprzedaży brutto</label>
<input type="text" id="cena_brutto" name="cena_brutto" value="<?php echo($_GET['cena_brutto']) ?>" required >
Expand All @@ -183,7 +147,7 @@

</div>

<div id="content"><br><p>Tutaj ma się pokazywać faktura</p>
<div id="content">
<?php
// zmienna $go przekazana metoda GET
$go = $_GET['go'];
Expand Down Expand Up @@ -235,7 +199,7 @@
return false;
}
});
});
});

$(function() {
$("#indeksT").autocomplete({
Expand Down Expand Up @@ -323,11 +287,18 @@
}
});
});
$(document).ready(function () {
document.getElementById('button').style.visibility= "<?php print $button; ?>";
$(document).ready(function () {
var btn = document.getElementById('button').style.visibility= "<?php print $button; ?>";

if (button == btn.hidden) {
document.getElementsByTagName('p').style.color="green";
} else {
"cosik nie wyszło";
}

})

</script>
</script>
<script src="script/funkcje.js" ></script>
</body>
</html>
98 changes: 98 additions & 0 deletions page/pokazFakture.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php
//Utworzenie połączenia

include_once 'db/connect.php';

$sn1 = $_SESSION['nr_faktury'];
$sn2 = $_SESSION['data_zak'];
//$sn3 = $_POST['data2'];



//Instrukcja SQL wybierajÄ…ca rekordy

$stmt = $mysqli->prepare("SELECT t.nazwa, t.id_towar, t.indeks, t.vat, t.pkwiu, t.jm, t.cena_brutto, thf.ilosc, thf.cena_n_z, f.nr_faktury, f.data_zak, d.stan_mag, k.kod_kreskowy
FROM towar t
LEFT JOIN (faktura f, faktura_has_towar thf, dane_towaru d, kod_ean k)
ON (t.id_towar=thf.id_towar AND f.id_faktura=thf.id_faktura AND t.id_towar=d.id_towar AND t.id_towar=k.id_towar)
WHERE f.nr_faktury like '%$sn1%' AND f.data_zak >= '$sn2' ORDER BY t.indeks DESC ");


$stmt->bind_param("sss", $sn1, $sn2);
$stmt->bind_result( $nazwa, $id_towar, $indeks, $vat, $pkwiu, $jm, $cena_brutto, $ilosc, $cena_n_z, $nr_faktury,$data_zak,$stan_mag,$kod_kreskowy);
$stmt->execute();




//formatowanie wyniku
echo "<br /><table >";
echo "<tr>
<th>LP</th>
<th>Id towaru</th>
<th>Nazwa towaru</th>
<th>Indeks towaru</th>
<th>Miara</th>
<th>Ilość</th>
<th>Cena Zakupu</th>
<th>VAT</th>
<th>Brutto</th>
<th>PKWiU</th>
<th>Nr faktury</th>
<th>Data zakupu</th>
<th>Razem ilość</th>
<th>Kod kreskowy</th>
<th>Wartość netto</th>
<th>Cena sprzedaży brutto</th>
<th>Marża</th>
</tr>";

//formatowanie wyniku wierszami długo szukałem błędu w warunkach for() i doszedłem że ma być ...$stmt->fech() bez żadnych dodatków
//również w <td> należało od razu wpisywać zmienne
for($lp = 1; $stmt->fetch(); ++$lp) {

$brutto =number_format((($cena_n_z*$vat/100)+$cena_n_z), 2, '.', '');
$razem = number_format(($cena_n_z * $ilosc), 2, '.', '');
$marza = number_format((( $cena_brutto / $brutto )*100-100), 2, '.', '');

echo "<tr>
<td>$lp</td>
<td>$id_towar</td>
<td>$nazwa</td>
<td>$indeks</td>
<td>$jm</td>
<td>$ilosc</td>
<td>$cena_n_z</td>
<td>$vat</td>
<td bgcolor='#ADD8E6'><font color='#FF0000'><strong> $brutto</strong></font></td>
<td>$pkwiu</td>
<td>$nr_faktury</td>
<td>$data_zak</td>
<td>$stan_mag</td>
<td>$kod_kreskowy</td>
<td>$razem</td>
<td>$cena_brutto</td>
<td>$marza</td>
</tr>";


$wy[] = $razem; //Zmienna $wy jako tablica do której dopisujemy wartości z kolumny Wartość netto, zmienna $razem
$tab = array_sum($wy); // Funkcją array_sum dodajemy wszystkie wystąpienia w kolumnie Wartość netto
}

echo "</table>";
echo 'Nr faktury: ', $nr_faktury,"<br />";
echo "<div align='center'><strong>Razem netto = $tab</strong></div>";


$thread_id = $mysqli->thread_id;
$stmt->free_result();
$stmt->close();

$mysqli->close();
echo "<br /> Wróć do zapisów <a href='index.php'>Powrót</a>";
?>
10 changes: 3 additions & 7 deletions page/zapiszTowar.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
if ($indeks && $nazwa)
{

echo "<br /> Spróbuj ponownie <a href='index.php'>tutaj</a>";
echo "<table border=1>
echo "<table border=0.1>
<tr>
<th>Nr Faktury</th>
<th>Data zakupu</th>
Expand Down Expand Up @@ -72,8 +71,6 @@
}
}

echo "<br />Indeks dostawcy:".$indeks_dost."<br />";
echo " Nazwa dostawcy; ". $nazwa_dost."<br />";

/***************************** wpiszemy dostawców *******************************/
$stmt = $mysqli->prepare("SELECT id_dostawcy, indeks, nazwa1 FROM dostawcy WHERE nazwa1 = ? ");
Expand Down Expand Up @@ -106,7 +103,6 @@

if($nr_faktury == $col1)
{
printf("<br />Jest taka faktura : %s ", $col1 );

} else
{
Expand Down Expand Up @@ -249,9 +245,9 @@

?>
<div id="form">
<form action="index.php" method="post" enctype="multipart/form-data">
<form action="index.php?go=pokazFakture" method="post" enctype="multipart/form-data">
<div id="buttonTow">
<button id="btnTow">Wróć do dostawy </button>
<button id="btnTow">Pokaż fakturę </button>
</div>

</div>
18 changes: 0 additions & 18 deletions script/script.js

This file was deleted.

5 changes: 2 additions & 3 deletions search2.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@

// Create database connection
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);

$db -> query("SET NAMES 'utf8'");
// Check connection
if ($db->connect_error) {
die("Connection failed: " . $db->connect_error);
}

// Get search term
$searchTerm = $_GET['term'];

$searchTerm = $db -> real_escape_string($_GET['term']);
// Fetch matched data from the database
$query = $db->query("SELECT id_dostawcy,indeks, nazwa1 FROM dostawcy WHERE nazwa1 LIKE '%".$searchTerm."%' ORDER BY nazwa1 ASC");

Expand Down

0 comments on commit 076466f

Please sign in to comment.