<?php


function createStaff($conn_rjllearning_specific,$institution_id,$branch_id,$name,$email,$phone,$address,$group_id,$date_of_joining,$print_bank_details,$account_holder_name,$account_name,$account_no,$ifsc_code,$branch_address,$account_type,$username)
{
    
    $sql = "Select name from staff_details where institution_id = ? AND branch_id = ? AND (name = ? OR email = ? OR phone = ?) ";
    $fetch_category = $conn_rjllearning_specific->prepare($sql);
    $fetch_category->execute(array($institution_id,$branch_id,$name,$email,$phone));
    if (count($fetch_category->fetchAll()) > 0) {
            errorreturn('Staff detail already exists');
    }
    
     $sql = "Insert into  staff_details(institution_id,branch_id,name,email,phone,address,group_id,date_of_joining,print_bank_details,account_holder_name,account_name,account_no,ifsc_code,branch_address,account_type,added_by,date_created,time_created,status) 
     values (?, ?, ?, ? ,? ,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
     $insert_ledger = $conn_rjllearning_specific->prepare($sql);
     $insert_ledger->execute(array($institution_id,$branch_id,$name,$email,$phone,$address,$group_id,$date_of_joining,$print_bank_details,$account_holder_name,$account_name,$account_no,$ifsc_code,$branch_address,$account_type,$username, date('Y-m-d'),time(),1));
     $staff_id = $conn_rjllearning_specific->lastInsertId();
     
     return $staff_id;
    
}