Example #1
0
<?php

require 'database/model.php';
$obj = ORM::getInstance();
$order_id = $_POST['order_id'];
//first delete from table orders
$obj->setTable('orders');
$no_row_afected = $obj->delete(array('id' => $order_id));
if ($no_row_afected > 0) {
    $obj->setTable('order_product');
    $no_product_afected = $obj->delete(array('order_id' => $order_id));
}
echo $no_row_afected;
echo $no_product_afected;
Example #2
0
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
  </head>
  <?php 
session_start();
if (isset($_SESSION['userName'])) {
    header("Location: ../layout/collapsed-sidebar.php");
}
require '../../ormProject.php';
require '../../validation.php';
$connection = ORM::getInstance();
$connection->setTable('user');
if ($_POST) {
    $validation = new Validation();
    $rules = array('Email' => 'email|required', 'Password' => 'required');
    if ($validation->validate($_POST, $rules) == true) {
        $Email = $_POST['Email'];
        $Password = $_POST['Password'];
        $data = array('password' => md5($Password), 'email' => $Email);
        $result = $connection->selectRow("*", $data);
        if ($result) {
            // session_start();
            $_SESSION['userId'] = $result['userId'];
            $_SESSION['userName'] = $result['userName'];
            $id = $result['userId'];
            $_SESSION['admin'] = $result['admin'];
<?php

require 'database/model.php';
//get or=der_id from the request
$order_id = $_POST['order_id'];
//echo $order_id;
/**
 * select query from table order_product  to get all products
 */
$obj_order = ORM::getInstance();
$obj_order->setTable('order_product');
$result = $obj_order->select(array('order_id' => $order_id));
$info = "";
//get all information in string to gend back to javascript
//getting the relation between order and product from table order_product
//then get from this relation the product_id to get information about each prosuct in the order
while ($order = $result->fetch_assoc()) {
    $obj_product = ORM::getInstance();
    $obj_product->setTable('products');
    $result_pro = $obj_product->select(array('id' => $order['product_id']));
    $result_product = $result_pro->fetch_assoc();
    $info .= $result_product['name'] . ";" . $result_product['pic'] . ";" . $order['amount'] . ";" . $order['total_price'] . ",";
}
echo $info;
Example #4
0
            </div>

            <div class="row panel-body">
                <div class="col-md-6">

                    <div class="panel panel-heading">

                        <h2> User: </h2>
                    </div>

                    <select class=" form-control" id="user_name">
                        <?php 
/**
 * get all users name
 */
$obj_users = ORM::getInstance();
$obj_users->setTable('users');
$all_users = $obj_users->select(array('is_admin' => 0));
if ($all_users->num_rows > 0) {
    while ($user = $all_users->fetch_assoc()) {
        ?>
                                <option value="<?php 
        echo $user['name'];
        ?>
"> <?php 
        echo $user['name'];
        ?>
 
                                    <?php 
    }
} else {
Example #5
0
<?php

include_once "ORM.php";
$db = ORM::getInstance();
$db->setTable('Book');
//
if ($_POST['flag'] == '1') {
    $upfile = "./images/bookimages/" . $_FILES['bookPicture']['name'];
    $image_name = $_FILES['bookPicture']['name'];
    $image_path = "./images/bookimages/" . $image_name;
    $image_error = "";
    if ($_FILES['bookPicture']['type'] != 'image/png') {
        $image_error = '* image is not png';
    }
    if (is_uploaded_file($_FILES['bookPicture']['tmp_name'])) {
        if (!move_uploaded_file($_FILES['bookPicture']['tmp_name'], $upfile)) {
            $image_error = '* Could not move image to destination directory';
        }
    }
    //
    $mysqli = $db->insert(array('bookName' => $_POST['bookName'], 'bookAuther' => $_POST['bookAuther'], 'bookDescription' => $_POST['bookDescription'], 'bookBody' => $_POST['bookBody'], 'bookPicture' => $image_name, 'categoryId' => $_POST['category']));
    header("Location: ./index.php");
} elseif ($_POST['flag'] == '2') {
    //$imgname=$db->select('categoryPicture',array('product_id'=>$_POST['id']));
    $mysqli = $db->delete(array('id' => $_POST['id']));
    // unlink('images/categoryimages/'.trim($imgname));
    echo '{"id":"add"}';
} elseif ($_POST['flag'] == '3') {
    $mysqli = $db->select('*', array('id' => $_POST['id']));
    echo json_encode(mysqli_fetch_assoc($mysqli));
} else {
Example #6
0
<?php

require 'database/model.php';
/**
 * update the statues of order acording to it`s id 
 */
$order_id = $_POST['order_id'];
$status = $_POST['status'];
$obj_order = ORM::getInstance();
$obj_order->setTable('orders');
$result = $obj_order->update(array('id' => $order_id), array('status' => $status));
echo $result;
Example #7
0
$status = "processing";
/**
 * insert order into database
 */
$obj_order = ORM::getInstance();
$obj_order->setTable('orders');
$result = $obj_order->insert(array("user_id" => $user_id, "status" => $status, "order_price" => $order_price, "room_id" => $order_room));
/**
 * select the last order to get order_id
 */
$obj_order_id = ORM::getInstance();
$obj_order_id->setTable('orders');
$last_order = $obj_order_id->select_last_row(array("user_id" => $user_id));
$order_id = $last_order['id'];
/**
 *  insert into table order_product all products of the order
 */
$notes = $_POST['notes'];
$products_array = $_POST['array'];
//getting all products separated by comma
$products = explode(",", $products_array);
//getting information obout each product and insert it into order_product table
for ($i = 0; $i < count($products) - 1; $i++) {
    $product = explode(":", $products[$i]);
    $obj_order_product = ORM::getInstance();
    $obj_order_product->setTable('order_product');
    $product_id = $product[0];
    $product_amount = $product[1];
    $product_price = $product[2];
    $obj_order_product->insert(array("order_id" => $order_id, "product_id" => $product_id, "amount" => $product_amount, "total_price" => $product_price, "notes" => $notes));
}
Example #8
0
">
                                        <?php 
            ?>
                                        <div class="row">
                                            <?php 
            echo "Amount: " . $current_product['amount'];
            ?>
                                        </div>
                                        <div class="row">
                                            <?php 
            echo " totalPrice: " . $current_product['total_price'];
            ?>
                                        </div>
                                        <?php 
            //get the name of product and all it`s info
            $obj_product_info = ORM::getInstance();
            $obj_product_info->setTable('products');
            $product_info_array = $obj_product_info->select(array('id' => $current_product['product_id']));
            $product_info = $product_info_array->fetch_assoc();
            ?>
                                        <div class="row">
                                            <?php 
            echo " Name: " . $product_info['name'];
            ?>
                                        </div>
                                        <div class="row">
                                            <img src="<?php 
            echo "images/products/" . $product_info['pic'];
            ?>
" class="img-responsive img-circle"  width="120px" height="120px">
                                        </div>
Example #9
0
    $obj_order_product->setTable('order_product');
    $product_id = $product[0];
    $product_amount = $product[1];
    $product_price = $product[2];
    $obj_order_product->insert(array("order_id" => $order_id, "product_id" => $product_id, "amount" => $product_amount, "total_price" => $product_price, "notes" => $notes));
}
/**
 * select all user information
 */
$obj_user = ORM::getInstance();
$obj_user->setTable('users');
$user_info = $obj_user->select(array("id" => $user_id));
$user = $user_info->fetch_assoc();
/**
 * select all order_products info
 */
$order_product = ORM::getInstance();
$order_product->setTable('order_product');
$order_info = $order_product->select(array("order_id" => $order_id));
$products_count = $order_info->num_rows;
$string_info = $last_order['id'] . ";" . $last_order['datetime'] . ";" . $user['name'] . ";" . $user['ext'] . ";" . $last_order['room_id'] . ";";
//$i=0;
while ($order = $order_info->fetch_assoc()) {
    $order_product_info_obj = ORM::getInstance();
    $order_product_info_obj->setTable('products');
    $order_product_info = $order_product_info_obj->select(array("id" => $order['product_id']));
    $product = $order_product_info->fetch_assoc();
    $string_info .= $product['name'] . "/" . $product['pic'] . "/" . $order['amount'] . "/" . $order['total_price'] . "%";
}
$string_info .= ";" . $last_order['order_price'];
echo $string_info;