<?php
include 'include/db.php';
include 'include/connect.php';
$id = $_POST['id'];

if(!empty($id)){

                $data['wholesale_name'] = $_POST['name'];
                
		$rs = $db->update('tbpayment',$data,'payment_id',$id);
           if($rs){
            echo "0";
           } else {
            echo "00";
           }

     } else {

      if($_POST['name'] != "0") {
           
      $rs = $db->insert('tbpayment',array(
       'payment_iv' => $_POST['payment_iv'],
       'payment_date' => $_POST['payment_date'],
       'payment_pic' => $_POST['image_field2'],
       'payment_type' => $_POST['payment_type'],
       'payment_bank' => $_POST['payment_bank'],
       'payment_ref' => $_POST['payment_ref'],
       'payment_total' => $_POST['payment_total']
            ));

           if($rs){
            echo "2";
           } else {
            echo "0";
           }
         } else {
            echo "3";
        }
}
?>

