\'' . date('Y-m-d H:i:s') . '\', 0, 1 ) '; if (database_void_query($sql) > 0) { $inquiry_id = mysql_insert_id(); if ($params['inquiry_type'] == '0') { $where_clause = 'l.id IN (SELECT listing_id FROM ' . TABLE_LISTINGS_CATEGORIES . ' lc WHERE category_id = ' . (int) $params['inquiry_category'] . ') AND '; $where_clause .= 'l.listing_location_id = ' . (int) $params['visitor_locations'] . ' AND '; $where_clause .= 'l.listing_sub_location_id = ' . (int) $params['visitor_sub_locations']; } else { $where_clause = 'l.id = ' . (int) $params['listing_id']; } $sql_insert = ''; $arr_customers = Listings::GetCustomerInfoByListing($where_clause); for ($i = 0; $i < $arr_customers[1]; $i++) { $send_email = true; // save inquires history (for standard inquires only) if ($params['inquiry_type'] == '0') { if ($arr_customers[0][$i]['inquiries_allowed'] == '-1' || $arr_customers[0][$i]['inquiries_sent'] < $arr_customers[0][$i]['inquiries_allowed']) { $sql_insert .= $sql_insert == '' ? 'INSERT INTO ' . TABLE_INQUIRIES_HISTORY . '(inquiry_id, customer_id, listing_id, date_added) VALUES ' : ','; $sql_insert .= '(' . (int) $inquiry_id . ', ' . (int) $arr_customers[0][$i]['customer_id'] . ', ' . (int) $params['listing_id'] . ', \'' . date('Y-m-d H:i:s') . '\')'; } else { $send_email = false; } } if ($send_email) { send_email($arr_customers[0][$i]['email'], $objSettings->GetParameter('admin_email'), 'inquiry_new', array('{FIRST NAME}' => $arr_customers[0][$i]['first_name'], '{LAST NAME}' => $arr_customers[0][$i]['last_name'], '{WEB SITE}' => $_SERVER['SERVER_NAME'], '{BASE URL}' => APPHP_BASE)); } }