CasperSecurity
<?php
session_start();
include '../../../../web/connection/connection.php';
include '../../../../web/connection/con.php';
include '../../../../web/connection/functions/encryption.php';
//$quotation_no = '12';
$quotation_no = $_POST['quotation_nos'];
$quotation_date = $_POST['production_date'];
$customer_id = $_POST['customer_id'];
// $quotation_item_id = $_POST['quotation_item_id'];
$product_service = $_REQUEST['product_service'];
$quantity = $_REQUEST['quantity'];
$rate = $_REQUEST['rata'];
$dis_rate = $_REQUEST['discount_rate'];
$amount = $quantity * $rate;
$amounty = number_format((float)$amount,2,'.','');
$discountamt =$amount*$dis_rate/100;
$discountamty = number_format((float)$discountamt,2,'.','');
$netamountt = $amount - $discountamt;
$netamount = number_format((float) $netamountt,2,'.','');
$db_handle = new DBController();
$business_sector = $db_handle-> runQuery("SELECT * FROM (business_sector
INNER JOIN client ON business_sector.business_sector_id = client.business_sector_id)
");
foreach($business_sector as $vbs) {
$business_sector = $vbs['business_sector'];
}
if($business_sector == 'Service Provider'){
$service_id = $product_service;
}else{
$product_id = $product_service;
}
$date = date("Y-m-d");
$active = 'yes';
$userId = $_SESSION['USER_ID'];
if(!empty($quantity)){
$db_handle = new DBController();
$qut_nomrow = $db_handle-> numRows("SELECT * FROM quotation WHERE quotation_date = '$quotation_date' AND customer_id = '$customer_id'");
if($qut_nomrow == '0'){
$db_handle = new DBController();
$newInsert = $db_handle->tableinsert("INSERT INTO quotation(quotation_no,quotation_date,customer_id,created_on,created_by,is_active)
VALUES ('$quotation_no','$quotation_date','$customer_id','$date','$userId','$active')");
$db_handle = new DBController();
$newInsert2 = $db_handle->tableinsert("INSERT INTO quotation_item(quotation_id,product_id,service_id,quantity,rate,discount_rate,discount_amount,amount,net_amount)
VALUES ('$newInsert','$product_id','$service_id','$quantity','$rate','$dis_rate','$discountamty','$amounty','$netamount')");
}else{
$db_handle = new DBController();
$quts = $db_handle-> runQuery("SELECT * FROM quotation ORDER BY quotation_id DESC LIMIT 1");
$db_handle = new DBController();
foreach($quts as $qut){
$newInsert = $qut['quotation_id'];
}
$db_handle = new DBController();
$newInsert2 = $db_handle->tableinsert("INSERT INTO quotation_item(quotation_id,product_id,service_id,quantity,rate,discount_rate,discount_amount,amount,net_amount)
VALUES ('$newInsert','$product_id','$service_id','$quantity','$rate','$dis_rate','$discountamty','$amounty','$netamount')");
}
$quotation_datez =amebi_crypt($quotation_date,e);
$customer_idz =amebi_crypt($customer_id,e);
$quotation_idz =amebi_crypt($newInsert,e);
$quotation_noz =amebi_crypt($quotation_no,e);
//$quotation_item_idz =amebi_crypt($quotation_item_id,e);
if($newInsert2 == TRUE){
//$_SESSION['ERROR_MSG'] = "Success";
// $_SESSION['MSG_ALRT'] = "TRUE";
header('location:../../../../web/home/modules/sales/quotation/quotation.php?quotation_date='.$quotation_datez.'&customer_id='.$customer_idz.'&qua_id='.$quotation_idz.'&qua_no='.$quotation_noz);
}else{
//$_SESSION['ERROR_MSG'] = "Unsuccess";
//$_SESSION['MSG_ALRT'] = "FALSE";
header('location:../../../../web/home/modules/sales/quotation/quotation.php?quotation_date='.$quotation_datez.'&customer_id='.$customer_idz.'&qua_id='.$quotation_idz.'&qua_no='.$quotation_noz);
}
}
?>