現在、オープン ソースの PHP POS を変更しています。警告を表示する代わりにコードを修正し、在庫数が 0 のアイテムを表示して、数量が 0 の場合は結果を表示しないようにしたいと考えています。
メッセージを通常のメッセージからjavascriptポップアップに変更することはできますが、それでもアイテムを表示しないことを好みます。このシステムを使用している私のスタッフは常にポップアップを無視し、月末にはかなりの数の否定的な項目が表示され、チェックして変更するのに頭が痛いからです。したがって、私はここで私に助言し、支援する専門家の助けを求めています. 私は高低を調べて、それが1つであると思われるコードの束をなんとか取得しました。私が間違っている場合は、私を修正してください。
コード:
function add_item($item_id,$quantity=1,$discount=0,$price=null,$description=null,$serialnumber=null)
{
//make sure item exists
if(!$this->CI->Item->exists($item_id))
{
//try to get item id given an item_number
$item_id = $this->CI->Item->get_item_id($item_id);
if(!$item_id)
return false;
}
//Alain Serialization and Description
//Get all items in the cart so far...
$items = $this->get_cart();
//We need to loop through all items in the cart.
//If the item is already there, get it's key($updatekey).
//We also need to get the next key that we are going to use in case we need to add the
//item to the cart. Since items can be deleted, we can't use a count. we use the highest key + 1.
$maxkey=0; //Highest key so far
$itemalreadyinsale=FALSE; //We did not find the item yet.
$insertkey=0; //Key to use for new entry.
$updatekey=0; //Key to use to update(quantity)
foreach ($items as $item)
{
//We primed the loop so maxkey is 0 the first time.
//Also, we have stored the key in the element itself so we can compare.
if($maxkey <= $item['line'])
{
$maxkey = $item['line'];
}
if($item['item_id']==$item_id)
{
$itemalreadyinsale=TRUE;
$updatekey=$item['line'];
}
}
$insertkey=$maxkey+1;
//array/cart records are identified by $insertkey and item_id is just another field.
$item = array(($insertkey)=>
array(
'item_id'=>$item_id,
'line'=>$insertkey,
'name'=>$this->CI->Item->get_info($item_id)->name,
'item_number'=>$this->CI->Item->get_info($item_id)->item_number,
'description'=>$description!=null ? $description: $this->CI->Item->get_info($item_id)->description,
'serialnumber'=>$serialnumber!=null ? $serialnumber: '',
'allow_alt_description'=>$this->CI->Item->get_info($item_id)->allow_alt_description,
'is_serialized'=>$this->CI->Item->get_info($item_id)->is_serialized,
'quantity'=>$quantity,
'discount'=>$discount,
'price'=>$price!=null ? $price: $this->CI->Item->get_info($item_id)->unit_price
)
);
//Item already exists and is not serialized, add to quantity
if($itemalreadyinsale && ($this->CI->Item->get_info($item_id)->is_serialized ==0) )
{
$items[$updatekey]['quantity']+=$quantity;
}
else
{
//add to existing array
$items+=$item;
}
$this->set_cart($items);
return true;
}
function out_of_stock($item_id)
{
//make sure item exists
if(!$this->CI->Item->exists($item_id))
{
//try to get item id given an item_number
$item_id = $this->CI->Item->get_item_id($item_id);
if(!$item_id)
return false;
}
$item = $this->CI->Item->get_info($item_id);
$quanity_added = $this->get_quantity_already_added($item_id);
if ($item->quantity - $quanity_added < 0)
{
return true;
}
return false;
}
前もって感謝します!ジェフ