<?php
/**********************************************************************
***********************************************************************/

//function get_batch_i_owe_you_details($batch_no, $iou_id = 0)
//{  
//	$sql= "SELECT 
//                ou.project_id, ou.employee_code,  ou.type, ou.tran_date, ou.batch_no, ou.id iou_id,
//                oud.task_id,oud.amount,oud.id, oud.comments,
//                pt.description as task_description,
//                CONCAT(em.employee_code,' - ', em.initials,' ',em.last_name,'(',em.first_name,')') employee,
//                st.value_name type_name,
//                pm.description project_description 
//            FROM " .TB_PREF."employee_master em, "
//                .TB_PREF."i_owe_you ou, "
//                .TB_PREF."i_owe_you_details oud, "
//                .TB_PREF."list_values st, "
//                .TB_PREF."projects_master pm, "
//                .TB_PREF."project_tasks pt  
//            WHERE ou.employee_code=em.employee_code AND 
//                    ou.id = oud.iou_id AND 
//                    ou.type = st.id AND st.list_code = 'PETTY_CASH_TYPES' AND 
//                    ou.project_id = pm.project_id AND 
//                    oud.task_id = pt.task_id AND 
//                    ou.approval_status = ".db_escape(AS_APPROVED);
//                    
//    if($batch_no > 0  && $iou_id > 0){
//        $sql .= " AND (ou.batch_no = ".db_escape($batch_no)." OR ou.id = ".db_escape($iou_id).")";
//    }
//    elseif($iou_id > 0){
//        $sql .= " AND (ou.id = ".db_escape($iou_id).")";
//    }
//    else{
//        $sql .= " AND (ou.batch_no = ".db_escape($batch_no).")";
//    }
//    
//    $sql .= " ORDER BY ou.id, tran_date";
//        
//	return db_query($sql,"Could not get_batch_i_owe_yous");	
//}

//
//
//
//function close_i_owe_you_for_payments($id)
//{
//	$sql = "UPDATE ".TB_PREF."i_owe_you  
//            SET closed_for_payments = 1   
//            WHERE id = ".$id." AND batch_complete = 0 ";
//        
//    db_query($sql,"Could not close_i_owe_you_for_payments");        
//}
//
//function complete_i_owe_you($id)
//{
//	$sql = "UPDATE ".TB_PREF."i_owe_you  
//            SET closed_for_payments = 1, 
//                batch_complete = 1    
//            WHERE id = ".$id." AND batch_complete = 0 ";
//        
//    db_query($sql,"Could not complete_i_owe_you"); 
//    
//    return db_num_affected_rows();
//}
//
//function get_i_owe_you_details_new($iou_id, $project_id)
//{
//    $sql = "SELECT pt.task_id, pt.project_id, pt.description, pt.budget, pt.budget_used, pt.budget_allocated, 
//                    oud.id, oud.iou_id, oud.amount, oud.required_date, oud.comments, oud.row_state  
//            FROM ".TB_PREF."project_tasks pt 
//                    LEFT JOIN ".TB_PREF."i_owe_you_details oud ON 
//                            pt.task_id = oud.task_id AND 
//                            oud.iou_id = ".db_escape($iou_id)." 
//                    LEFT JOIN ".TB_PREF."i_owe_you ou ON oud.iou_id = ou.id AND 
//                            ou.project_id = pt.project_id AND 
//                            ou.id = ".db_escape($iou_id)." 
//            WHERE pt.project_id = ".db_escape($project_id)." 
//            ORDER BY pt.task_id";
//    
//    return db_query($sql,"Could not release_i_owe_you_payment");
//}

//function get_i_owe_you_details($iou_id)
//{
//    $sql = "SELECT oud.*  
//            FROM ".TB_PREF."i_owe_you_details oud 
//            WHERE oud.iou_id = ".db_escape($iou_id);
//    
//    return db_query($sql,"Could not get_i_owe_you_details");
//}

//function add_to_petty_cash_float($tran_type, $type_no, $float_id, $amount, $tran_date)
//{
//    $sql = "SELECT balance FROM ".TB_PREF."petty_cash_float_trans WHERE float_id = ". db_escape($float_id)." ORDER BY id DESC LIMIT 1";
//    $bq = db_query($sql,"Could not add_to_petty_cash_float");
//    $b = db_fetch($bq);
//    
//    $balance = $b['balance'] + $amount;
//    
//    $created_on = date('Y-m-d H:i:s');
//    
//    $sql = "INSERT INTO ".TB_PREF."petty_cash_float_trans(
//                    float_id, tran_type, type_no, 
//                    amount, balance, 
//                    tran_date, created_on) 
//            VALUES (".db_escape($float_id).", ".db_escape($tran_type).", ".db_escape($type_no).", "
//                    .db_escape($amount). ", ".db_escape($balance).", "
//                    .db_escape(date2sql($tran_date)).", ".db_escape($created_on).")";
//    
//    db_query($sql,"Could not add_to_petty_cash_float");
//}


?>