Skip to content

Instantly share code, notes, and snippets.

@nourhanhamdy
Last active October 12, 2015 16:10
Show Gist options
  • Save nourhanhamdy/bfbb2e669fd9f1a413ee to your computer and use it in GitHub Desktop.
Save nourhanhamdy/bfbb2e669fd9f1a413ee to your computer and use it in GitHub Desktop.
<?php
require'DataBasePos.php';
class Adminstration
{
public $Admin_Name;
public $Admin_Pass;
function View_Reports()
{
$Manger_Stock_Obj = new ManagerStock();
$Manger_Stock_Obj->Make_report_Expire();
$Manger_Stock_Obj->Make_report_Quantity();
}
function Offer_Item()
{
if($_POST)
{
$Item_Name = $_POST["item_name"];
$Item_offer = $_POST["offer_offer"];
}
$DB_obj = new DataBasePos();
$DB_obj ->insert_offer_for_item($Item_Name,$Item_offer);
}
function Offer_Order()
{
}
function Add_New_Item()
{
if($_POST)
{
$item_name = $_POST["item_name"];
$item_price = $_POST["item_price"];
$item_offer = $_POST["item_offer"];
$item_expire_date = $_POST["item_expire_date"];
$item_desc = $_POST["item_desc"];
$DataBasePos_Obj = new DataBasePos();
$DataBasePos_Obj->Add_Item($item_name,$item_price,$item_offer,$item_expire_date,$item_desc);
}
}
function Add_Employee()
{
if($_POST)
{
$cashair_id = $_POST["cashair_id"];
$cashair_name = $_POST["cashair_name"];
$csh_order_no = $_POST["csh_order_no"];
$DataBasePos_Obj = new DataBasePos();
$DataBasePos_Obj->Add_cashair($cashair_id,$cashair_name,$csh_order_no);
}
}
function Delete_Employee()
{
}
function Create_Purshase_Order()
{
if($_POST)
{
$stock_id = $_POST["stock_id"];
$item_id = $_POST["item_id"];
$sup_stkItem_id = $_POST["sup_stkItem_id"];
$item_quantity = $_POST["item_quantity"];
$DataBasePos_Obj = new DataBasePos();
$DataBasePos_Obj->Create_Purshase_from_Supplier($stk_item_id,$stock_id,$item_id,$sup_stkItem_id,$item_quantity);
}
}
function Add_Manager_Stock()
{
if($_POST)
{
$mang_id = $_POST["mang_id"];
$mang_name = $_POST["mang_name"];
$mang_branch = $_POST["mang_branch"];
$mang_type = $_POST["mang_type"];
$DataBasePos_Obj = new DataBasePos();
$DataBasePos_Obj->Add_Manager($mang_id,$mang_name,$mang_branch,$mang_type);
}
}
function Add_Supplier_of_stock()
{
if($_POST)
{
$supp_name = $_POST["supp_name"];
$supp_address = $_POST["supp_address"];
$supp_mng_id = $_POST["supp_mng_id"];
$DataBasePos_Obj = new DataBasePos();
$rslt= $DataBasePos_Obj->Add_Supplier($supp_name,$supp_address,$supp_mng_id);
}
}
}
$admin_Obj = new Adminstration();
$admin_Obj->Offer_Item();
$admin_Obj = new Adminstration();
$admin_Obj->Add_Employee();
$admin_Obj = new Adminstration();
$admin_Obj->Add_Manager_Stock();
$admin_Obj = new Adminstration();
$admin_Obj->Create_Purshase_Order();
$admin_Obj = new Adminstration();
$admin_Obj->Add_New_Item();
$admin_Obj = new Adminstration();
$admin_Obj->Add_Supplier_of_stock();
?>
<?php
class DataBasePos
{
function check_Customer_Product($order_payment,$order_Name,$Product_Name,$Prodct_Quantity)
{
$connect = mysqli_connect("localhost","root","","pos_system");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql_select = "SELECT item_price , item_no FROM item where item_name ='".$Product_Name."' and item_quantity = '".$Prodct_Quantity."'";
$result = $connect->query($sql_select);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
// echo "id: " . $row["item_no"]. " - Name: " . $row["item_name"]. "quantity " . $row["item_quantity"]. "<br>";
$item_No = $row["item_no"];
echo "item_price : " . $row["item_price"]."item_no : " . $row["item_no"]. "<br>" ;
$res= mysqli_query($connect," INSERT INTO `order`(`order_payment_type`,`order_name`) VALUES ($order_payment,'$order_Name')");
echo $order_Name;
$DB_obj = new DataBasePos();
$DB_obj->Insert_into_item_order($order_Name,$item_No);
}
}
}
///////////////////////////////////////////////////////////////////////////////////
function Insert_into_item_order($order_Name,$item_No)
{
$connect = mysqli_connect("localhost","root","","pos_system");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql_select = "SELECT order_no FROM `order` WHERE `order_name` = '".$order_Name."' ";
$result = mysqli_query($connect,$sql_select);
if($result)
{
echo "yes";
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
// echo "id: " . $row["item_no"]. " - Name: " . $row["item_name"]. "quantity " . $row["item_quantity"]. "<br>";
$Order_no_finish = $row["order_no"];
echo "order_no : " . $row["order_no"]. "<br>" ;
$res= mysqli_query($connect," INSERT INTO `order_item`(`oi_item_no`,`oi_order_no`) VALUES ('$item_No','$Order_no_finish')");
}
}
}
else
{
echo "nononon";
}
}
//////////////////////////////////////////////////////////////////////////////////////////////
function Check_Register_Customer($customer_name,$customer_Phone,$customer_adress)
{
$connect = mysqli_connect("localhost","root","","pos_system");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql_select_customer = "SELECT cust_id FROM customer where cust_phone ='".$customer_Phone."'";
$result = $connect->query($sql_select_customer);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
// echo "id: " . $row["item_no"]. " - Name: " . $row["item_name"]. "quantity " . $row["item_quantity"]. "<br>";
echo "cust_id : " . $row["cust_id"]."<br>" ;
}
}
else
{
echo $customer_name,$customer_Phone,$customer_adress;
$res_customer= mysqli_query($connect," INSERT INTO `customer`(`cust_name`,`cust_phone`,`cust_addres`) VALUES ('$customer_name','$customer_Phone','$customer_adress')");
if($res_customer)
{
echo "yes";
}
else {
echo "None";
}
echo "insert this user";
}
}
/////////////////////////////////////////////////////////add item///////////////////////////////////////////////////
function Add_Item($item_name,$item_price,$item_offer,$item_expire_date,$item_desc)
{
$connect = mysqli_connect("localhost","root","","pos_system");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$admin_add_item= mysqli_query($connect,"INSERT INTO `item` (`item_name`,`item_price`,`item_offer`,`item_expire_date`,`item_desc`)
VALUES ('$item_name','$item_price','$item_offer','$item_expire_date','$item_desc')");
}
///////////////////////////////////////////////////////add cashair////////////////////////////////////////////////
function Add_cashair($cashair_id,$cashair_name,$csh_order_no)
{
$connect = mysqli_connect("localhost","root","","pos_system");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$admin_add_cashair= mysqli_query($connect," INSERT INTO `cashair` (`cashair_id`, `cashair_name`, `csh_order_no`)
VALUES ('$cashair_id','$cashair_name','$csh_order_no')");
if ($admin_add_cashair)
{
echo"added";
}
else
{
echo " no add";
}
}
////////////////////////////////////////////////////add_manager_stock////////////////////////////////////////////////////////
function Add_Manager($mang_id,$mang_name,$mang_branch,$mang_type)
{
$connect = mysqli_connect("localhost","root","","pos_system");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$admin_add_manager= mysqli_query($connect," INSERT INTO `manager` (`mang_id`, `mang_name`, `mang_branch`, `mang_type`)
VALUES ('$mang_id','$mang_name','$mang_branch','$mang_type')");
if ($admin_add_manager)
{
echo"added";
}
else
{
echo " no add";
}
}
/////////////////////////////////////////////////////add supplier/////////////////////////////////////////////////////
function Add_Supplier($supp_name,$supp_address,$supp_mng_id)
{
$connect = mysqli_connect("localhost","root","","pos_system");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$admin_add_supplier= mysqli_query($connect," INSERT INTO `supplier`(`supp_name` ,`supp_address`,`supp_mng_id`)
VALUES ('$supp_name','$supp_address','$supp_mng_id')");
}
//////////////////////////////////////////////////Purshase order/////////////////////////////////////////////////////////
function Create_Purshase_from_Supplier($stk_item_id,$stock_id,$item_id,$sup_stkItem_id,$item_quantity)
{
$connect = mysqli_connect("localhost","root","","pos_system");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$admin_Purshase_from_Supplier= mysqli_query($connect," INSERT INTO `stock_item` (`stk_item_id`,`stock_id`,`item_id`,`sup_stkItem_id`,`item_quantity`)
VALUES ('$stk_item_id','$stock_id','$item_id','$sup_stkItem_id','$item_quantity')");
if ($admin_Purshase_from_Supplier)
{
echo"added";
}
else
{
echo " no add";
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
function insert_offer_for_item($Item_Name,$Item_offer)
{
echo $Item_Name,$Item_offer;
$connect = mysqli_connect("localhost","root","","pos_system");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$res_offer= mysqli_query($connect,"UPDATE `item` SET `item_offer`= '".$Item_offer."' WHERE `item_name`='".$Item_Name."'");
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment