Commit 3d36883a by Yaremko95

admin functionality is implemented

shopping cart using sessions, ajax, javascript
parent a426da3d
No preview for this file type
......@@ -58,7 +58,7 @@ $autoload['packages'] = array();
|
| $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array('database', 'session', 'form_validation');
$autoload['libraries'] = array('database', 'session', 'form_validation', 'upload', 'cart');
/*
| -------------------------------------------------------------------
......@@ -79,7 +79,7 @@ $autoload['libraries'] = array('database', 'session', 'form_validation');
| $autoload['drivers'] = array('cache' => 'cch');
|
*/
$autoload['drivers'] = array();
$autoload['drivers'] = array('session');
/*
| -------------------------------------------------------------------
......
......@@ -23,7 +23,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = 'http://localhost/webapp/ci';
$config['base_url'] = 'https://wbt-2-ty.appspot.com';
/*
|--------------------------------------------------------------------------
......@@ -324,7 +324,7 @@ $config['cache_query_string'] = FALSE;
| https://codeigniter.com/user_guide/libraries/encryption.html
|
*/
$config['encryption_key'] = '';
$config['encryption_key'] = 'femEDWTX$AQ@6HggkKn8RWGf!*ufK?KC';
/*
|--------------------------------------------------------------------------
......@@ -382,7 +382,7 @@ $config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_time_to_update'] = 7200;
$config['sess_regenerate_destroy'] = FALSE;
/*
......@@ -432,7 +432,7 @@ $config['standardize_newlines'] = FALSE;
| for backwards compatibility purposes!
|
*/
$config['global_xss_filtering'] = FALSE;
$config['global_xss_filtering'] = true;
/*
|--------------------------------------------------------------------------
......@@ -448,7 +448,7 @@ $config['global_xss_filtering'] = FALSE;
| 'csrf_regenerate' = Regenerate token on every submission
| 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks
*/
$config['csrf_protection'] = FALSE;
$config['csrf_protection'] = true;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
......
......@@ -75,9 +75,9 @@ $query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'hostname' => '104.199.82.156',
'username' => 'tetiana',
'password' => 'yaremko_tetiana',
'database' => 'mydb',
'dbdriver' => 'mysqli',
'dbprefix' => '',
......
<?php
class Admin extends CI_Controller
{
class Admin extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function index () {
$name = $this->session->userdata('name');
$this->load->view('admin/aside');
$this->load->view('admin/admin_home');
}
public function index () {
public function add_product() {
$this->form_validation->set_rules("artist", "Atist", "required");
$this->form_validation->set_rules("title", "Title", "required");
$this->form_validation->set_rules("genre", "Genre", "required");
$this->form_validation->set_rules("quantity", "Quantity", "required");
$this->form_validation->set_rules("price", "Price", "required");
$this->form_validation->set_rules("description", "Description", "required");
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = 2048;
$file_name="image".time();
$config['file_name']=$file_name;
$this->upload->initialize($config);
$field_name = "image";
if ($this->form_validation->run() == TRUE) {
if(!$this->upload->do_upload($field_name)) {
$file_error = $this->upload->display_errors();
$this->session->set_flashdata("file_error", "<div class=\"alert alert-danger alert-dismissible fade show\" role=\"alert\">
'$file_error' <button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\">
<span aria-hidden=\"true\">&times;</span></button></div>");
} else {
$this->load->model('Admin_model', 'admin');
$this->admin->add_product();
$this->session->set_flashdata("message", "<div class=\"alert alert-success alert-dismissible fade show\" role=\"alert\">
Product has been added to the database<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\">
<span aria-hidden=\"true\">&times;</span></button></div>");
redirect('admin/product_inventory');
}
}
$this->load->view('admin/aside');
$this->load->view('admin/add_product');
}
public function product_inventory() {
$this->load->model('Admin_model', 'admin');
$data=$this->admin->get_data();
$this->load->view('admin/aside');
$this->load->view('admin/product_inventory', array('data'=>$data));
}
$name = $this->session->userdata('name');
public function update_item($item_id) {
$this->load->model('Admin_model', 'admin');
$data=$this->admin->get_product($item_id);
$this->form_validation->set_rules("artist", "Atist", "required");
$this->form_validation->set_rules("title", "Title", "required");
$this->form_validation->set_rules("genre", "Genre", "required");
$this->form_validation->set_rules("quantity", "Quantity", "required");
$this->form_validation->set_rules("price", "Price", "required");
$this->form_validation->set_rules("description", "Description", "required");
$this->form_validation->set_rules("status", "Status", "required");
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = 2048;
$file_name="image".time();
$config['file_name']=$file_name;
$this->upload->initialize($config);
$field_name = "image";
if ($this->form_validation->run() == TRUE) {
if(!$this->upload->do_upload($field_name)) {
$file_error = $this->upload->display_errors();
$this->session->set_flashdata("file_error", "<div class=\"alert alert-danger alert-dismissible fade show\" role=\"alert\">
'$file_error' <button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\">
<span aria-hidden=\"true\">&times;</span></button></div>");
} else {
$this->load->model('Admin_model', 'admin');
$this->admin->update_product($item_id);
redirect('admin/product_inventory');
}
}
$this->load->view('admin/aside');
$this->load->view('admin/update_item', array('data'=>$data));
}
public function delete_item($item_id) {
$this->load->model('Admin_model', 'admin');
$this->admin->delete_product($item_id);
redirect('admin/product_inventory');
}
......@@ -30,4 +119,9 @@ class Admin extends CI_Controller
}
}
......@@ -31,6 +31,7 @@ class Auth extends CI_Controller
$this->form_validation->set_rules("password", "Password", "trim|required");
if ($this->form_validation->run() == true) {
$this->load->model('auth_model', 'auth');
$this->load->model('Cart_model', 'cmodel');
$status = $this->auth->validate();
if ($status == ERR_INVALID_EMAIL) {
$this->session->set_flashdata("error", "Email is not valid");
......@@ -43,6 +44,12 @@ class Auth extends CI_Controller
$this->session->set_userdata("role_id", $user_role);
$this->session->set_userdata($this->auth->get_data());
$this->session->set_userdata("logged_in", true);
$data=$this->cmodel->getAllFromCart();
$this->cmodel->set_user_cart($this->session->userdata('email'), $data);
if($user_role==1) {
redirect("admin/index");
}
......
......@@ -13,9 +13,11 @@ class User extends CI_Controller
public function user_profile() {
if($this->session->userdata("role_id")=='1') {
redirect('admin/index');
};
if(isset($_POST['update'])) {
$this->form_validation->set_rules('new_email', 'Email', 'required|valid_email',
array('required' => 'Please, enter new email in order to update', 'valid_email' => 'Email not valid'));
$this->form_validation->set_rules('new_name', 'Name', 'required',
......
......@@ -15,29 +15,13 @@ class Home extends CI_Controller {
public function products()
{
$this->load->view('templates/header');
$this->load->view('templates/home_t');
/*if($_SESSION['user_logged']==true) {
$this->load->model('Admin_model', 'admin');
$data=$this->admin->get_data();
//redirect("home/products");
$this->load->view('templates/header');
$this->load->view('templates/home_t', array('data'=>$data));
$this->load->view('templates/header');
$this->load->view('templates/home_t');
}
else
{
redirect("auth/login");
}
*/
/*if ($this->session->userdata("logged_in")) {
$this->load->view('templates/header');
$this->load->view('templates/home_t');
}
else {
redirect("auth/login");
}*/
}
......
......@@ -8,17 +8,33 @@
$allowAll['auth']['login']=true;
$allowAll['auth']['register']=true;
$allowAll['auth']['forgotPassword']=true;
$allowAll['home']['products']=true;
$allowAll['common']['unauthorized']=true;
$allowAll['auth']['logout']=true;
$allowAll['auth']['resetpassword']=true;
$allowAll['auth']['resetPassword']=true;
$allowAll['auth']['changePassword']=true;
$allowAll['auth']['verify'] =true;
$allowAll['home']['products']=true;
$allowAll['cart']['add_to_cart']=true;
$allowAll['cart']['show_cart']=true;
$allowAll['cart']['load_cart']=true;
$allowAll['cart']['delete_product_from_cart']=true;
$allowAll['cart']['increase_qty']=true;
$allowAll['cart']['decrease_qty']=true;
$allowAll['common']['unauthorized']=true;
$allowOnly['1']['admin']['index']=true;
$allowOnly['1']['admin']['add_product']=true;
$allowOnly['1']['admin']['update_item']=true;
$allowOnly['1']['admin']['product_inventory']=true;
$allowOnly['1']['admin']['delete_item']=true;
$allowOnly['2']['user']['user_profile']=true;
$allowOnly['2']['auth']['resetPassword']=true;
$allowOnly['2']['auth']['changePassword']=true;
$allowOnly['2']['cart']['user_cart']=true;
//$allowOnly['2']['home']['products']=true;
......@@ -115,4 +115,7 @@ class Auth_model extends CI_Model {
}
}
}
}
<html>
<head>
</head>
<body>
<h1>Admin page</h1>
</body>
</html>
<html>
<head>
<title>retro record</title>
<link rel="stylesheet" href="<?php echo base_url(); ?>asset/css/stylee.css" type="text/css">
<link rel="stylesheet" href="<?php echo base_url(); ?>asset/css/home.css" type="text/css">
<link rel="stylesheet" href="<?php echo base_url(); ?>asset/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class="container">
<div class="header-wrapper">
<header class="header-section" >
<div class="container-fluid" id="header-top">
<div class="inner-header">
<div class="header-top">
<div class="logo">
<a href="<?php echo base_url(); ?>index.php/home/products"><img src="<?= asset_url('img/logo.png')?>" alt=""></a>
</div>
<div class="header-right">
<div class="menu-right">
<div class="cart-profile">
<div class="toggle-account active-btn">
<a href="<?php echo base_url(); ?>index.php/user/user_profile" >
<img src="<?= asset_url('img/icons/man.png')?>" alt="">
<i class="fa fa-user-circle-o"></i>
</a>
<!--
<ul class="active-nav" style="display: block;">
<li class="profile">
<a href="/profile.html" title="Profile">
Profile
</a>
<a href="#">
<img src="<?= asset_url('img/icons/bag.png')?>" alt="">
<span>2</span>
</li>
<li class="orders">
<a href="/orders.html" title="Order History">
Order History
</a>
</li>
<li class="logout">
<form method="post" action="/">
<button type="submit" title="Log Out" name="logout">
Log Out
</button>
</form>
</li>
</ul> -->
</div>
<div class="cart-box" style="margin-left: 10px;">
<a class="cart-link" href="#" >
<i class="fa fa-shopping-cart" ></i>
<span class="badge"></span>
</a>
</div>
<div id="mini-cart" class="cart-overlay" >
<div id="cart" class="cart">
<button type="button" class="close position-absolute top-0 right-0" aria-label="Close" style="float: left;">
<span aria-hidden="true">&times;</span>
</button>
<div style="display: flex; justify-content: space-between"> <span></span><a href="<?php echo base_url(); ?>index.php/cart/user_cart">View Basket &raquo;</a></div>
<div class="products-center" style="width: 100%">
<div id="detail-cart" class="mini-cart-item">
</div>
</div>
</div>
</div>
</div>
<div class="user-access">
<a href="<?php echo base_url(); ?>index.php/auth/register">Register</a>
<a href="<?php echo base_url(); ?>index.php/auth/login" class="in">Log in</a>
<a href="<?php echo base_url(); ?>index.php/auth/logout" class="out">Log Out</a>
</div>
<nav class="main-menu mobile-menu">
<ul>
<li><a href="">About</a></li>
<li><a href="">Contact</a></li>
</ul>
</nav>
<div class="about-menu">
<a href="">About</a>
</div>
<div class="contact-menu">
<a href="">Contact</a>
</div>
</div>
</div>
<div class="container">
<nav>
<ul id="navigation" class="navigation">
<li id="cat_johnnycashreissues" class="cat_level_0">
<li >
<a href="">Metal</a>
</li>
<li id="cat_preorders" class="cat_level_0">
<li >
<a href="">Pop</a>
</li>
<li id="cat_newreleases" class="cat_level_0">
<li>
<a href="">Soundtracks</a>
</li>
<li id="cat_sovexclusives" class="cat_level_0">
<li>
<a href="/">Jazz & Classical</a>
</li>
<li id="cat_colouredvinyl" class="cat_level_0">
<li>
<a href="/">Soul & RNB</a>
</li>
<li id="cat_limitededition" class="cat_level_0">
<li>
<a href="">Hip Hop & Rap</a>
</li>
<li id="cat_merchandise" class="cat_level_0">
<li >
<a href="">Compilations</a>
</li>
<li id="cat_genres" class="cat_level_0">
......@@ -69,20 +115,27 @@
<li id="cat_sale" class="cat_level_0">
<a class="parent-cat parent-cat-0" href="">Ska + Reggae</a>
</ul>
</nav>
</div>
</header>
<!-- Header Info Begin -->
</div>
</div>
<script type="text/javascript">
baseUrl = '<?php echo base_url(); ?>';
</script>
<!-- <script src="--><?php //echo base_url(); ?><!--asset/js/scrypt.js"></script>-->
<!-- Header Info Begin -->
<script src="<?php echo base_url(); ?>asset/js/jquery-3.3.1.min.js"></script>
<script src="<?php echo base_url(); ?>asset/js/bootstrap.min.js"></script>
<script src="<?php echo base_url(); ?>asset/js/jquery.js"></script>
<script src="<?php echo base_url(); ?>asset/js/jquery-ui.js"></script>
</body>
</html>
......
......@@ -41,6 +41,18 @@ h2 {
border-bottom: 1px solid #ddd;
margin-bottom: 1em;
}
.add-product-table {
width: 80%;
clear: both;
padding: 0 0 1em;
margin-right: 1.5em;
border-bottom: 1px solid #ddd;
margin-bottom: 1em;
}
.add-product-table td{
display: block;
}
.message-box {
float: right;
width: 30%;
......@@ -105,6 +117,33 @@ label {
cursor: text;
}
.add-product-table input, select {
width: 100%;
max-width: 25em;
font-size: 1em;
line-height: 1.6;
padding: .1em .2em;
border: 1px solid #ccc;
background: #fdfcfc;
margin: .1em 0;
color: #444;
background-clip: padding-box;
text-rendering: auto;
letter-spacing: normal;
word-spacing: normal;
text-transform: none;
text-indent: 0px;
text-shadow: none;
display: inline-block;
text-align: start;
cursor: text;
}
.add-product-table select {
height: 110%;
}
.add-product-table textarea {
}
.delivery-details input {
width: 100%;
max-width: 25em;
......
......@@ -164,49 +164,8 @@ header.sticky {
.navigation li{display:inline-block;list-style:none;margin:0;padding:0;}
.navigation li a{display:block;margin:0; max-width:auto;padding:.5em 1em;list-style:none;color:inherit;font-weight:inherit;cursor:pointer}
.navigation li a:hover{color:#666}
.header-info li{
color: black;
}
.homepage-ctas{padding:1em 0 .5em;position:relative; margin-top: 195px;}
.homepage-ctas .card{transition:opacity .3s;vertical-align:top;text-align:center;position:relative;display:inline-block;width:33%; background: black;padding:.5em 0}
.homepage-ctas .card:hover{opacity: .6}
.homepage-ctas .card::after{content:"";height:1.5em;width:2px;position:absolute;top:50%;margin-top:-.75em;bottom:0;right:0;background:#ffffff}
.homepage-ctas .card:last-child::after{display:none}
.homepage-ctas h4{text-transform:uppercase;font-size:1.25em;margin:0; }
.homepage-ctas p{position:relative;margin:0; color:#ffffff;line-height:1.25}
.homepage-ctas::after,.homepage-ctas::before{content:"";height:100%;width:100vw;position:absolute;left:50%;right:50%;top:0;margin-left:-50vw;margin-right:-50vw}
.homepage-ctas::before{background:#0e0e0e}.homepage-ctas::after{height:1px;top:auto;bottom:0;background:#000000}
.header-info {
margin-top: 195px;
background: black;
overflow: hidden;
padding: 30px 45px;
}
.header-info .header-item {
overflow: hidden;
}
.header-info .header-item img {
display: inline-block;
margin-right: 13px;
}
.header-info .header-item p {
display: inline-block;
line-height: 1;
font-size: 20px;
color: yellow;
font-weight: 500;
margin-bottom: 0;
position: relative;
top: 3px;
}
.carousel {
margin: 10px auto;
padding: 10px 300px;
......
......@@ -101,6 +101,7 @@ header img{
.auth-section {
padding: 60px 0px;
display: flex;
......
INSERT INTO 'users'(u_id, email, password, name, surname, country, city, street, zip, building) VALUES (1, 'email@gmail.com', 'pass', 'name', 'surname', 'country', 'city', 'street', 'zip', 'building');
INSERT INTO 'users'(u_id, email, password, name, surname, country, city, street, zip, building) VALUES (2, 'email2@gmail.com', 'pass2', 'name2', 'surname2', 'country2', 'city2', 'street2', 'zip2', 'building2');
INSERT INTO 'users'(u_id, email, password, name, surname, country, city, street, zip, building) VALUES (3, 'email3@gmail.com', 'pass3', 'name3', 'surname3', 'country3', 'city3', 'street3', 'zip3', 'building3');
INSERT INTO 'users'(u_id, email, password, name, surname, country, city, street, zip, building) VALUES (4, 'email4@gmail.com', 'pass4', 'name4', 'surname4', 'country4', 'city4', 'street4', 'zip4', 'building4');
INSERT INTO `user_role` (`id`, `role`) VALUES (NULL, 'administrator'), (NULL, 'member');
INSERT INTO 'product'(id, artist, title, genre, description, price, q_ty) VALUES (1, 'artist', 'title', 'genre', 'description', 100, 5);
INSERT INTO 'product'(id, artist, title, genre, description, price, q_ty) VALUES (2, 'artist2', 'title2', 'genre2', 'description2', 100, 5);
INSERT INTO 'product'(id, artist, title, genre, description, price, q_ty) VALUES (3, 'artist3', 'title3', 'genre3', 'description3', 100, 5);
INSERT INTO 'product'(id, artist, title, genre, description, price, q_ty) VALUES (4, 'artist4', 'title4', 'genre4', 'description4', 100, 5);
INSERT INTO 'cart'(id, user_id) VALUES (1,1);
INSERT INTO 'cart'(id, user_id) VALUES (2,2);
INSERT INTO 'cart'(id, user_id) VALUES (3,3);
INSERT INTO 'cart'(id, user_id) VALUES (4,4);
INSERT INTO 'prod_in_cart'(prod_q_ty, c_id, p_id) VALUES (5,1,1);
INSERT INTO 'prod_in_cart'(prod_q_ty, c_id, p_id) VALUES (5,2,2);
INSERT INTO 'prod_in_cart'(prod_q_ty, c_id, p_id) VALUES (5,3,3);
INSERT INTO 'prod_in_cart'(prod_q_ty, c_id, p_id) VALUES (5,4,4);
INSERT INTO 'status'(id_status, status) VALUES (1, 'succesful');
INSERT INTO 'status'(id_status, status) VALUES (2, 'processing');
INSERT INTO 'status'(id_status, status) VALUES (3, 'canceled');
INSERT INTO 'transaction'(id, id_user, id_status) VALUES (1, 1, 1);
INSERT INTO 'transaction'(id, id_user, id_status) VALUES (2, 1, 1);
INSERT INTO 'transaction'(id, id_user, id_status) VALUES (3, 1, 1);
INSERT INTO 'transaction'(id, id_user, id_status) VALUES (4, 1, 1);
INSERT INTO 'trans_products'(id_trans, id_prod, num_of_pr, price) VALUES (1, 1, 5, 120);
INSERT INTO 'trans_products'(id_trans, id_prod, num_of_pr, price) VALUES (2, 1, 5, 120);
INSERT INTO 'trans_products'(id_trans, id_prod, num_of_pr, price) VALUES (3, 1, 5, 120);
INSERT INTO 'trans_products'(id_trans, id_prod, num_of_pr, price) VALUES (4, 1, 5, 120);
https://app.moqups.com/unsaved/2585a64b/edit/page/a2ce38a45
\ No newline at end of file
No preview for this file type
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment