<?php
	/**
	 * phpGroupWare - sms: A SMS Gateway
	 *
	 * @author Sigurd Nes <sigurdne@online.no>
	 * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc. http://www.fsf.org/
	 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
	 * @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/
	 * @package sms
	 * @subpackage sms
	 * @version $Id: config_VASK 18297 2007-10-03 13:34:09Z sigurdne $
	 */
	/**
	 * Description
	 * @package sms
	 * Config values for SMS-command "ST" - (Strøing) "sanding the ice" in Norwegian - as example - as it is configured at BBB 
	 */
	//$agreement = array(48089,48329);
	$agreement = array(86850);

	$limit = array
		(
		48089 => ' AND id > 0 AND id < 131',
		48329 => ' AND id > 0 AND id < 43',
		86850 => '',
	);

	if (isset($param[0]) && $param[0])
	{
		$location_code = implode('', $param);

		foreach ($agreement as $candidate)
		{
			$sql = "SELECT count(id) as found from fm_s_agreement_detail WHERE agreement_id = $candidate AND location_code ilike '" . $location_code . "%'";
			$this->db->query($sql, __LINE__, __FILE__);
			$this->db->next_record();
			if ($this->db->f('found'))
			{
				$agreement_id = $candidate;
				break;
			}
		}
	}

	$id_field = 'location_code';
	$target_field = 'kvittering';
	$location_id = $GLOBALS['phpgw']->locations->get_id('property', '.s_agreement.detail');

	if ($agreement_id && isset($param[0]) && $param[0])
	{
		$location_code = implode('', $param);
		$filter = "WHERE agreement_id = $agreement_id AND location_code ilike '" . $location_code . "%'" . $limit[$agreement_id];
	}

	$this->db->query("SELECT id FROM phpgw_cust_attribute WHERE column_name = '$target_field' AND location_id = $location_id", __LINE__, __FILE__);
	$this->db->next_record();
	$attrib_id = $this->db->f('id');
	$receipt = utf8_encode('Strøing: ');
