<?php
$DEBUG = 1;
$pageTitle = "$config->appName > New entry";
$newdn = ",$dn";
$encdn = rawurlencode($dn); // used when building urls with the dn
include_once( './page.header.php' );
// TEMP DEBUG
html::form( $PHP_SELF, "post", 'name="frm"' );
html::hidden( "A", "" );
echo '<div align=center><table style="width:300px; border: 1px solid gray;">';
echo '<caption>', $pageTitle, "</caption>\n";
if( $statusMsg ) {
FormLine( " ", $statusMsg );
}
$jsCode = ' onBlur="fillFromDn(this.value);" ';
FormLine(
"Distinguished Name",
new TextInput( "newdn", utf8_decode($newdn), $tbL . $jsCode )
);
// fields for new values
//FormStart( "New attributes" );
FormLine(
"",
"Enter new attributes below</i>"
);
for ($i = 0; $i < $config->newEntryAttributesCount; $i++) {
FormLine(
new TextInput( "newattrname[$i]", $newattrname[$i], $tbS ),
new TextInput( "newattrval[$i]", $newattrval[$i], $tbL )
);
}
/*
FormLine(
new TextInput( "newattrname[$i]", $newattrname[$i], $tbS ),
new FileInput( "newattrvalbin[$i]", $newattrvalbin[$i], $tbL )
);
*/
// create button bar elements
$wAdd = new Button( "Add", "formAction(this.form, 'entry.add' )", "add", $btM );
$wBack = new Button( "Cancel", "history.go(-1)", $btM );
// display buttons bar
echo "<tr><td colspan=2><table>";
RowN(
array(
$wAdd,
$wBack
)
);
echo "</table></td></tr>\n";
echo "</table></div>\n</form>\n";
// JS invoqued by form buttons
?>
<script language="javascript">
<!--
function fillFromDn( val )
{
// var objName,objValue;
objName = document.frm.elements['newattrname[0]'];
objValue = document.frm.elements['newattrval[0]'];
if( objName.value == '' ) {
posComma = val.indexOf(",");
posEqual = val.indexOf("=");
// nothing good to copy
if( ( posComma < 1 ) || ( posComma < posEqual) ) {
alert( "soucis !" );
return;
}
objName.value = val.substr( 0, posEqual );
objValue.value = val.substr( posEqual+1, posComma - posEqual - 1 );
}
}
function formAction( formObj, actionStr )
{
document.frm.A.value = actionStr;
document.frm.submit();
}
function Loadfile( url )
{
window.location = url;
}
// -->
</script>
<?php
include("./page.footer.php");
?>