<?php

$delete_id = $link->hrefquery();
$get_inventory = $db->get_all('inventory');
if($delete_id['0']=='delete_id'){
	$delete_inventory =$db->delete('inventory',array('id'=>$delete_id['1']));
	if($delete_inventory){
		$session->redirect('view_inventory',Admin);
	}
}
if(isset($_POST['installment_submit'])){
	$inventory_id = $_POST['inventory_id'];
	$installment_amount = $_POST['add_installment'];
	$installment_date = $_POST['installment_date'];
	$get_amount_date = $db->get_row('inventory',array('id'=>$inventory_id),array('payment_amount','payment_date'));
	
	
	if($get_amount_date['payment_amount']=="" || $get_amount_date['payment_amount']=="N;" || $get_amount_date['payment_date']=="" || $get_amount_date['payment_date']=="N;"){
		$installment_amount = serialize(array($installment_amount));
		$installment_date=serialize(array($installment_date));
	}else{
		$un_amount = unserialize($get_amount_date['payment_amount']);
		$installment_amount = array_push($un_amount, $installment_amount);
		$installment_amount = serialize($un_amount);
		$un_date = unserialize($get_amount_date['payment_date']);
		$installment_date = array_push($un_date, $installment_date);
		$installment_date = serialize($un_date);
	}
	
	
	$db->update('inventory',array('payment_amount'=>$installment_amount,'payment_date'=>$installment_date),array('id'=>$inventory_id));


}
?>
