<?php

//insert transfers and return the success transfer ids
//function insert_transfers($branch_id, $depot_id, $transfers) {
//    global $db;
//    $succ_ids = array();
//    if (!empty($transfers)) {
//        //start transaction
//        $warehouseDepot = new WarehouseDepot;
//        //start transaction
//        foreach ($transfers as $trnsfr_id => $trnsfr_row) {
//            $trnsfr_row['app_request_id'] = $trnsfr_row['Request_ID'];
//            $trnsfr_row['app_user_id'] = $trnsfr_row['Logged_ID'];
//            $trnsfr_row['request_prefix'] = $trnsfr_row['serial_prefix'];
//            $trnsfr_row['is_confirmed'] = 1;
//            $trnsfr_row['is_data_collector'] = 0;
//            //insert transfer and set is_main_transfer = 1 to don't transfer to server again
//            $trnsfr_row['is_main_transfer'] = 1;
//            $trnsfr_row[0] = $trnsfr_row['Logged_ID'];
//            $check_request = $db->query_execute('select Request_ID from tbl_stock_request where app_request_id = ? and app_user_id = ?', array($trnsfr_row['app_request_id'], $trnsfr_row['app_user_id']));
//            if ($db->query_result_count($check_request) == 0) {
//                $insert = $warehouseDepot->setdata($trnsfr_row)->createRequest();
//                if (!empty($insert) && is_numeric($insert[0]))
//                    $succ_ids[] = $trnsfr_id;
//            } else
//                $succ_ids[] = $trnsfr_id;
//        }
//    }
//    return $succ_ids;
//}

//insert transfers and return the success transfer ids
//function insert_customer_contacts($branch_id, $customer_contacts) {
//    global $db;
//    $succ_ids = array();
//    if (!empty($customer_contacts)) {
//        //start transaction
//        $customer = new Customer;
//        //start transaction
//        $db->query_execute('TRUNCATE tbl_customer_supplier_contacts;');
//        foreach ($customer_contacts as $cust_id => $cust_row) {
//            $insert = $customer->setdata($cust_row)->insertCustomerContacts($cust_row, $cust_id);
//            if (empty($insert))
//                $succ_ids[] = $cust_id;
//        }
//    }
//    return $succ_ids;
//}
