<?php require_once('../auth/auth.php');
if (isset($_POST['newunit'])) {
    $newunit = $_POST['newunit'];
    $unit_name=    $_POST['unit_name'];
    $unit_symble= $_POST['symble'];
    $unit_convart= $_POST['unit_convart'];


    if ($newunit=='0') {
    mysqli_query($conn,"INSERT INTO pro_unit( `coid`, `unit_name`, `unit_symble`, `unit_convart`) 
                VALUES ('$coid','$unit_name','$unit_symble','$unit_convart')")or die(mysqli_error($conn));
    } else if($newunit >0){
    mysqli_query($conn,"UPDATE pro_unit SET unit_name='$unit_name',unit_convart='$unit_convart',unit_symble='$unit_symble' WHERE puid='$newunit'");
    }
}       
?>

<?php 
if (isset($_POST['newbatch'])) {
    $newbatch=    $_POST['newbatch'];
    $mate_code=    $_POST['mate_code'];
    $batch_no= $_POST['batch_no'];
    $note= $_POST['note'];
    $start_date= $_POST['start_date'];
    $expiry_date= $_POST['expiry_date'];


    if ($newbatch=='0') {
    mysqli_query($conn,"INSERT INTO batch_no(`coid`, `bid`, `brid`, `mate_code`, `batch_no`, `note`, `start_date`, `expiry_date`, `active`) 
            VALUES ('$coid','$bid','$brid','$mate_code','$batch_no','$note','$start_date','$expiry_date','1')")or die(mysqli_error($conn));
    } else if($newbatch >0){
    mysqli_query($conn,"UPDATE batch_no SET mate_code='$mate_code',batch_no='$batch_no',note='$note',start_date='$start_date',expiry_date='$expiry_date' WHERE batid='$newbatch'");
    }



}       
?>