Когда я отправляю свою форму, успешно вставляя все данные в таблицу, а также получая сообщение об ошибке в консоли, как показано ниже: Есть ли проблемы в коде ?, Я нашел необычную дату в ошибке, дата показывает '1970-01-01. Но я выбрал сегодняшнюю дату, но по ошибке она показывает только «1970-01-01»;
A Database Error Occurred
Error Number: 1048
Column 'purchase_shopId' cannot be null
INSERT INTO `stock_purchase_history` (`purchase_shopId`, `purchase_productID`, `purchase_quantity`, `purchase_costPrice`, `purchase_TotalRate`, `purchase_tax`, `purchase_taxEmp`, `purchase_sellingPrice`, `purchase_employeeSellingPrice`, `purchase_supplierName`, `purchase_invoice`, `purchase_PurchaseDate`) VALUES (NULL, NULL, NULL, NULL, 0, NULL, NULL, 0, 0, NULL, NULL, '1970-01-01')
Filename: C:/xampp/htdocs/stock/system/database/DB_driver.php
Line Number: 691
мой код запроса
public function insertPurchaseData()
{
$shopId = $this->input->post('shopId');
$productID = $this->input->post('productID');
$quantity = $this->input->post('quantity');
$costPrice = $this->input->post('costPrice');
$PurchaseTotalRate = $quantity*$costPrice;
$taxNormal = $this->input->post('taxNormal');
$taxEmp = $this->input->post('taxEmp');
$supplierName = $this->input->post('supplierName');
$invoice = $this->input->post('invoice');
$PurchaseDate = date('Y-m-d', strtotime($this->input->post('PurchaseDate')));
// normal Selling price
$sellingPrice=($costPrice*$taxNormal)/100+$costPrice ;
// emp selling price
$employeeSellingPrice=($costPrice*$taxEmp)/100+$costPrice;
$purchaseData =array(
'purchase_shopId' => $shopId,
'purchase_productID' => $productID,
'purchase_quantity' =>$quantity,
'purchase_costPrice' =>$costPrice,
'purchase_TotalRate' =>$PurchaseTotalRate,
'purchase_tax' =>$taxNormal,
'purchase_taxEmp' =>$taxEmp,
'purchase_sellingPrice' =>$sellingPrice,
'purchase_employeeSellingPrice'=>$employeeSellingPrice,
'purchase_supplierName' =>$supplierName,
'purchase_invoice' =>$invoice,
'purchase_PurchaseDate' =>$PurchaseDate
);
$this->db->insert('stock_purchase_history',$purchaseData);
}
см. Ниже код ajax
if(result == '1234567')
{
$.ajax({
type: "POST",
url: "<?php echo site_url('Con_purchase/add_purchase_for_shop')?>",
dataType: "JSON",
data: {
shopId: shopId,
productID: productID,
quantity: quantity,
costPrice : costPrice ,
taxNormal : taxNormal ,
taxEmp : taxEmp ,
supplierName : supplierName,
invoice : invoice ,
PurchaseDate : PurchaseDate
},
success: function(data)
{ if (data == '1') {
var btn = $(this).closest("tr")
var name = inputData.find("button").prop('disabled', false).css(
"background-color", "green");
} else {
var btn = $(this).closest("tr")
var name = inputData.find("button").prop('disabled', true).css(
"background-color", "#2d7bf4");
}
}
});
return false;
}
my db введите описание изображения здесь