<?php
define("_VALID_PHP", true);
require_once("../../init.php");
$page = basename($_SERVER["PHP_SELF"]);
$heder = "Import Artikala";
$mali = " > za forma za naručivanje";
$korisnik = $user->username;
$lokal = $user->fname;
$level = $user->userlevel;
$prezime = $user->lname;
$koje = $user->name;
echo $koje;
$ip = $_SERVER['REMOTE_ADDR']; 
$kome = $user->sendto;
$id_user = $user->uid;
$dept = $user->todept;
echo $id_user;
$gdeje = "(".$dept.")";
//echo $gdeje;
$firma = $user->country;
//load the database configuration file
include 'dbConfig.php';

if(!empty($_GET['status'])){
    switch($_GET['status']){
        case 'succ':
            $statusMsgClass = 'alert-success';
            $statusMsg = 'Members data has been inserted successfully.';
            break;
        case 'err':
            $statusMsgClass = 'alert-danger';
            $statusMsg = 'Some problem occurred, please try again.';
            break;
        case 'invalid_file':
            $statusMsgClass = 'alert-danger';
            $statusMsg = 'Please upload a valid CSV file.';
            break;
        default:
            $statusMsgClass = '';
            $statusMsg = '';
    }
}
?>
  <style type="text/css">
    .panel-heading a{float: right;}
    #importFrm{margin-bottom: 20px;display: none;}
    #importFrm input[type=file] {display: inline;}
  </style>
<h3 class="page-title">
<?php echo $heder;?><small><?php echo $mali;?></small>
</h3>
<div class="page-bar">
	<ul class="page-breadcrumb">
		<li>
			<i class="fa fa-home"></i>
			<a href="index.html">Home</a>
			<i class="fa fa-angle-right"></i>
		</li>
		<li>
			<a href="#"><?php echo $page;?></a>
		</li>
	</ul>
</div>
<!-- END PAGE HEADER-->
<!-- BEGIN PAGE CONTENT-->
<div class="row">
  <div class="col-md-12">
    <h2>Učitaj CSV fajl sa artiklima za trebovanje</h2>
    <?php if(!empty($statusMsg)){
        echo '<div class="alert '.$statusMsgClass.'">'.$statusMsg.'</div>';
    } ?>
    <div class="panel panel-default">
        <div class="panel-heading">
            Artikli
            <a href="javascript:void(0);" onclick="$('#importFrm').slideToggle();">Učitaj artikle</a>
        </div>
        <div class="panel-body">
            <form action="pages/importData.php" method="post" enctype="multipart/form-data" id="importFrm">
                <input type="file" name="file" id="csvfile"/>
                <input type="submit" class="btn btn-primary" name="importSubmit" id="importSubmit"value="IMPORT">
            </form>
            <table class="table table-bordered">
                <thead>
                    <tr>
                      <th>Naziv</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    //get rows query
                    $query = $db->query("SELECT * FROM products ORDER BY name ASC");
                    if($query->num_rows > 0){ 
                        while($row = $query->fetch_assoc()){
                        ?>
                    <tr>
                      <td><?php echo $row['name']; ?></td>
                      
                    </tr>
                    <?php } }else{ ?>
                    <tr><td colspan="1">Nema artikala u bazi...</td></tr>
                    <?php } ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
</div>


