89 lines
2.1 KiB
PHP
89 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* AgileBill - Open Billing Software
|
|
*
|
|
* This body of work is free software; you can redistribute it and/or
|
|
* modify it under the terms of the Open AgileBill License
|
|
* License as published at http://www.agileco.com/agilebill/license1-4.txt
|
|
*
|
|
* Originally authored by Tony Landis, AgileBill LLC
|
|
*
|
|
* Recent modifications by Deon George
|
|
*
|
|
* @author Deon George <deonATleenooksDOTnet>
|
|
* @copyright 2009 Deon George
|
|
* @link http://osb.leenooks.net
|
|
*
|
|
* @link http://www.agileco.com/
|
|
* @copyright 2004-2008 Agileco, LLC.
|
|
* @license http://www.agileco.com/agilebill/license1-4.txt
|
|
* @author Tony Landis <tony@agileco.com>
|
|
* @package AgileBill
|
|
* @subpackage List
|
|
*/
|
|
|
|
/**
|
|
* The main AgileBill Menu List Multiple Method
|
|
*
|
|
* @package AgileBill
|
|
* @subpackage List
|
|
* @todo $id seems rendundant
|
|
*/
|
|
|
|
function list_menu_multi($default,$name,$table,$field,$id,$max,$class) {
|
|
global $C_translate;
|
|
|
|
if (! isset($default))
|
|
$default = array('');
|
|
elseif (gettype($default) == 'array') {}
|
|
elseif (gettype($default) == 'string')
|
|
$default = unserialize($default);
|
|
else
|
|
$default = array('');
|
|
|
|
$db = &DB();
|
|
$result = $db->Execute(sqlSelect($db,$table,sprintf('id,%s',$field),'',$field));
|
|
if ($result === false) {
|
|
global $C_debug;
|
|
|
|
$C_debug->error(__FILE__,__METHOD__, $db->ErrorMsg());
|
|
return;
|
|
}
|
|
|
|
if ($result->RecordCount() > $max && $result->RecordCount() != 0)
|
|
$size = $max;
|
|
else
|
|
$size = $result->RecordCount();
|
|
|
|
$return = sprintf('<select id="%s" name="%s[]" size="%s" multiple="multiple">',$name,$name,$size);
|
|
|
|
$i = 0;
|
|
while (! $result->EOF) {
|
|
$return .= sprintf('<option value="%s"',$result->fields['id']);
|
|
|
|
for ($ii=0; $ii<count($default); $ii++) {
|
|
if ($default[$ii] == $result->fields['id']) {
|
|
$return .= ' selected="selected"';
|
|
|
|
$ii = count($default);
|
|
}
|
|
}
|
|
|
|
$return .= sprintf('>%s</option>',$result->fields[$field]);
|
|
$result->MoveNext();
|
|
|
|
$i++;
|
|
}
|
|
|
|
$return .= '</select>';
|
|
|
|
if ($i==0) {
|
|
$return = $C_translate->translate('lists_none_defined');
|
|
if ($name)
|
|
$return .= sprintf('<input type="hidden" name="%s" value=""/>',$name);
|
|
}
|
|
|
|
echo $return;
|
|
}
|
|
?>
|