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

if(!empty($id)){

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

     } else {

      if($_POST['name'] != "0") {
           
      $rs = $db->insert('tbdoc',array(
       'doc_iv' => $_POST['doc_iv'],
       'doc_text' => $_POST['doc_text'],
       'doc_file' => $_POST['series_field'],
       'doc_date' => $_POST['doc_date'],
       'doc_ref' => $_POST['doc_ref'],
       'doc_type' => $_POST['doc_type'],
            ));

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

