396 $this->action = $action;
397 $this->record = &$record;
398 $this->EditMode = $editing;
399 $this->break_line_format =
'<tr><th class="ph" colspan="2">%s</th></tr>'.
"\n";
400 $this->table_line_format =
'<tr><th class="prompt">%s</th><td class="entry">%s<span class="help">%s</span></td></tr>'.
"\n";
471 if ( !is_array($extra_attributes) && $extra_attributes !=
'' ) {
472 list( $k, $v ) = explode(
'=', $extra_attributes );
473 $extra_attributes = array( $k => $v );
475 $extra_attributes[
'action'] = $this->action;
476 if ( !isset($extra_attributes[
'method']) ) $extra_attributes[
'method'] =
'post';
477 if ( strtolower($extra_attributes[
'method']) !=
'get' )
478 if ( !isset($extra_attributes[
'enctype']) ) $extra_attributes[
'enctype'] =
'multipart/form-data';
479 if ( !isset($extra_attributes[
'name']) ) $extra_attributes[
'name'] =
'form';
480 if ( !isset($extra_attributes[
'class']) ) $extra_attributes[
'class'] =
'formdata';
481 if ( !isset($extra_attributes[
'id']) ) $extra_attributes[
'id'] = $extra_attributes[
'name'];
484 reset( $extra_attributes );
485 $attribute_values =
"";
486 foreach( $extra_attributes as $k => $v ) {
487 $attribute_values .=
" $k=\"".htmlspecialchars($v).
"\"";
489 return "<form$attribute_values>\n";
563 function DataEntryField( $format, $ftype=
'', $base_fname=
'', $attributes=
'', $prefix=
'' )
567 if ( ($base_fname ==
'' || $ftype ==
'') ) {
571 $fname = $prefix . $base_fname;
573 dbg_error_log(
"DataEntry",
":DataEntryField: fmt='%s', fname='%s', fvalue='%s'", $format, $fname, (isset($this->record->{$fname})?$this->record->{$fname}:
'value not set') );
574 if ( !$this->EditMode ) {
576 if ( !isset($this->record->{$fname}) && substr($fname,0,4) ==
'xxxx' && isset($this->record->{substr($fname,4)}) )
577 $fname = substr($fname,4);
578 if ( !isset($this->record->{$fname}) )
return '';
580 if ($ftype ==
"date" || $ftype ==
"timestamp")
581 return sprintf($format, $session->FormattedDate($this->record->{$fname}) );
582 dbg_error_log(
"DataEntry",
":DataEntryField: fmt='%s', fname='%s', fvalue='%s'", $format, $fname, (isset($this->record->{$fname})?$this->record->{$fname}:
'value not set') );
583 return sprintf($format, $this->record->{$fname} );
588 if ( preg_match(
"/^(.+)\[(.+)\]$/", $fname, $parts) ) {
591 @dbg_error_log(
"DataEntry",
":DataEntryField: fname=%s, p1=%s, p2=%s, POSTVAL=%s, \$this->record->{'%s'}['%s']=%s",
592 $fname, $p1, $p2, $_POST[$p1][$p2], $p1, $p2, $this->record->{
"$p1"}[
"$p2"] );
594 if ( isset($_POST[$p1]) ) {
595 if ( isset($_POST[$p1][$p2]) ) {
596 $currval = $_POST[$p1][$p2];
599 else if ( isset($this->record) && is_object($this->record)
600 && isset($this->record->{
"$p1"}[
"$p2"])
602 $currval = $this->record->{
"$p1"}[
"$p2"];
606 if ( isset($_POST[$fname]) ) {
607 $currval = $_POST[$fname];
609 else if ( isset($this->record) && is_object($this->record) && isset($this->record->{
"$base_fname"}) ) {
610 $currval = $this->record->{
"$base_fname"};
612 else if ( isset($this->record) && is_object($this->record) && isset($this->record->{
"$fname"}) ) {
613 $currval = $this->record->{
"$fname"};
616 if ( $ftype ==
"date" ) $currval = $session->FormattedDate($currval);
617 else if ( $ftype ==
"timestamp" ) $currval = $session->FormattedDate($currval, $ftype);
620 $field =
new EntryField( $ftype, $fname, $this->_ParseAttributes($ftype,$attributes), $currval );
621 return $field->Render();
631 $field =
new EntryField(
'submit', $fname, $this->_ParseAttributes(
'submit', $attributes), $fvalue );
632 return $field->Render();
639 function DataEntryLine( $prompt, $field_format, $ftype=
'', $fname=
'', $attributes=
'', $prefix =
'' )
641 $attributes = $this->_ParseAttributes( $ftype, $attributes );
642 return sprintf( $this->table_line_format, $prompt,
643 $this->DataEntryField( $field_format, $ftype, $fname, $attributes, $prefix ),
644 $attributes[
'_help'] );
652 function MultiEntryLine( $prompt_options, $prompt_name, $default_prompt, $format, $ftype=
'', $fname=
'', $attributes=
'', $prefix=
'' )
655 $prompt =
"<select name=\"$prompt_name\">";
657 reset($prompt_options);
658 foreach( $prompt_options as $k => $v ) {
659 $selected = ( ( $k == $default_prompt ) ?
' selected="selected"' :
'' );
660 $nextrow =
"<option value=\"$k\"$selected>$v</option>";
661 if ( preg_match(
'/&/', $nextrow) ) $nextrow = preg_replace(
'/&/',
'&', $nextrow);
664 $prompt .=
"</select>";
666 return $this->DataEntryLine( $prompt, $format, $ftype, $fname, $attributes, $prefix );