<?php
require_once('helper.php'); 

if(!session_id()){
	session_start();
}

class db_function extends helper
{ 

	public function set_section_185($company_detail_id,$company,$type_company,$lending,$prevailing,$financ_year,$cut_off,$borrow_date,$maker,$checker,$banks,$nbfc,$financ_inst,$indian_comp,$llp,$foreign,$total){ 
		$response = array();

    	if($company_detail_id != '')
		{
			$query = "update gbca_company_detail_master set sch_enroll_no=?, sch_updated_date=CONVERT_TZ(NOW(), @@session.time_zone, '+5:30'), sch_updated_by=?, sch_status=? where sch_id=?";

			if($stmt_query = $this->conn->prepare($query))
			{
				$stmt_query->bind_param("sisi", $sch_enroll_no, $created_updated_by, $sch_status, $sch_id);
				if($stmt_query->execute())
				{
					$response['n'] = 1;
					$response['msg'] = "Admitted Successfully";
				}
				else
				{
					$response['n'] = 0;
					$response['msg'] = $this->conn->error;
				}
			}
			else
			{
				$response['n'] = 0;
				$response['msg'] = $this->conn->error;
			} 
		}
  else
  {

	$query = "INSERT INTO gbca_company_detail_master (section_id,
	company_detail_name,
	company_type_name,
	company_detail_lending_operation,
	company_detail_interest_charge,
	company_detail_financial_year,
	company_detail_cutofff_date,
	company_detail_preparation_date,
	company_detail_maker_name,
	company_detail_checker_name,
	company_detail_borrow_from_banks,
	company_detail_borrow_from_nbfc,
	company_detail_borrow_from_other_institude,
	company_detail_borrow_from_indian_company,
	company_detail_borrow_from_llp,
	company_detail_borrow_from_foreign_company,
	company_detail_total_borrowing,
	company_details_added_date,
	company_detail_status) VALUES ('1',?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,CONVERT_TZ(NOW(),@@session.time_zone,'+5:30'),'1')";

			
           if($stmt_query = $this->conn->prepare($query)){
			$stmt_query->bind_param("sssssssssiiiiiii",$company,$type_company,$lending,$prevailing,$financ_year,$cut_off,$borrow_date,$maker,$checker,$banks,$nbfc,$financ_inst,$indian_comp,$llp,$foreign,$total);

				if($stmt_query->execute()){
					$response['n'] = 1;
					$response['msg'] = "Record Added Successfully";
					$response['id']=$this->conn->insert_id;
				}
				else{
					$response['n'] = 0;
					$response['msg'] = $this->conn->error;
				}
			}
			else
			{
				$response['n'] = 0;
				$response['msg'] = $this->conn->error;
			}
		 
		}
     return $response;
   }
}

$obj_dba_func = new db_function();
?>
