Index: cprs/trunk/CPRS-Chart/Orders/fOtherSchedule.pas
===================================================================
--- cprs/trunk/CPRS-Chart/Orders/fOtherSchedule.pas	(revision 456)
+++ cprs/trunk/CPRS-Chart/Orders/fOtherSchedule.pas	(revision 829)
@@ -5,5 +5,6 @@
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
-  Dialogs, ComCtrls, StdCtrls, ExtCtrls, Buttons, fAutoSz, rMisc;
+  Dialogs, ComCtrls, StdCtrls, ExtCtrls, Buttons, fAutoSz, rMisc, ORCtrls, rODMeds,
+  VA508AccessibilityManager, VAUtils;
 
 const
@@ -29,5 +30,4 @@
     btn0k1: TButton;
     btnCancel: TButton;
-    txtSchedule: TEdit;
     Label1: TLabel;
     btnReset: TButton;
@@ -37,4 +37,9 @@
     btnAdd: TButton;
     Button1: TButton;
+    GroupBox3: TGroupBox;
+    NSScboSchedule: TORComboBox;
+    btnSchAdd: TButton;
+    btnSchRemove: TButton;
+    txtSchedule: TEdit;
     procedure FormCreate(Sender: TObject);
     procedure btnCancelClick(Sender: TObject);
@@ -58,7 +63,11 @@
       Shift: TShiftState);
     procedure Button1Click(Sender: TObject);
+    procedure btnSchAddClick(Sender: TObject);
+    procedure btnSchRemoveClick(Sender: TObject);
+    procedure FormDestroy(Sender: TObject);
   private
     FDaySchedule: array [1..7] of string;
     FTimeSchedule: TStringList;
+    FSchedule: String;
     FOtherSchedule: String;
     FFromCheckBox: boolean;
@@ -67,5 +76,8 @@
     procedure SetDaySchedule(Sender: TObject);
     procedure SetTimeSchedule;
+    procedure SetScheduleSelection;
     procedure UpdateOnFreeTextInput;
+    procedure EnabledTime(TF: boolean);
+    procedure EnabledSch(TF: boolean);
     function CheckDay(ADayStr: string): string;
     
@@ -75,4 +87,7 @@
 function ShowOtherSchedule(var ASchedule: string): boolean;
 
+var
+   frmOtherSchedule: TfrmOtherSchedule;
+
 implementation
 
@@ -80,10 +95,14 @@
 {$R *.dfm}
 
-function ShowOtherSchedule(var ASchedule: string): boolean;
-var
-  frmOtherSchedule: TfrmOtherSchedule;
+function ShowOtherSchedule(var ASchedule: string):
+
+boolean;
+var
+
+  AdminTime, SchType: string;
 begin
   Result := False;
   try
+   ASchedule := '';
    frmOtherSchedule := TfrmOtherSchedule.Create(Application);
    ResizeFormToFont(TForm(frmOtherSchedule));
@@ -92,8 +111,21 @@
    begin
      ASchedule := UpperCase(frmOtherSchedule.FOtherSchedule);
+     if frmOtherSchedule.GroupBox3.Enabled = True then
+       begin
+         AdminTime := Piece(frmOtherSchedule.NSScboSchedule.Items.Strings[frmOtherSchedule.NSScboSchedule.itemindex],U,4);
+         schType := Piece(frmOtherSchedule.NSScboSchedule.Items.Strings[frmOtherSchedule.NSScboSchedule.itemindex],U,3);
+         ASchedule := ASchedule + U + AdminTime + U + schType;
+         //if (schType = 'P') or (schType = 'OC') then ASchedule := ASchedule + U + '1'
+         //else ASchedule := ASchedule + U + '0';
+       end
+     else if frmOtherSchedule.GroupBox2.Enabled = true then
+       begin
+         AdminTime := Piece(ASchedule,'@',2);
+         ASchedule := ASchedule + U + AdminTime + U + 'C';
+       end;
      Result := True;
    end;
   except
-   ShowMessage('Error happen when building other schedule');
+   ShowMsg('Error happen when building other schedule');
   end;
 end;
@@ -105,4 +137,5 @@
   nssMsg: string;
 begin
+  frmOtherSchedule := nil;
   FFromCheckBox := False;
   FFromEditBox := False;
@@ -111,4 +144,5 @@
    FDaySchedule[i] := '';
   FTimeSchedule := TStringlist.Create;
+  FSchedule := '';
   FOtherSchedule := '';
   nssMsg := GetSiteMessage;
@@ -116,9 +150,22 @@
     nssMsg := NSS_TXT;
   memMessage.Lines.Add(nssMsg);
+  LoadDOWSchedules(NSScboSchedule.Items);
+  if ScreenReaderActive = false then txtSchedule.TabStop := false;
+
+end;
+
+procedure TfrmOtherSchedule.FormDestroy(Sender: TObject);
+begin
+  inherited;
+    //FDaySchedule
+    FTimeSchedule.Free;
+    frmOtherSchedule := nil;
+    //FSchedule: String;
+    //FOtherSchedule: String;
 end;
 
 procedure TfrmOtherSchedule.btnCancelClick(Sender: TObject);
 begin
-  modalResult := mrCancel;
+  frmOtherSchedule.Release;
 end;
 
@@ -128,12 +175,17 @@
     (cbo6.Checked = false) and (cbo7.Checked = false) then
     begin
-      ShowMessage('A day of week must be selected!');
+      ShowMsg('A day of week must be selected!');
       Exit;
     end;
-  if not IsValidSchStr(FOtherSchedule) then
-  begin
-    ShowMessage('The schedule you entered is invalid!');
+  if Pos('@', self.txtSchedule.Text) = 0 then
+    begin
+      ShowMsg('An Administation Time or a schedule needs to be selected');
+      exit;
+    end;
+(*  if not IsValidSchStr(FOtherSchedule) then
+  begin
+    Show508Message('The schedule you entered is invalid!');
     Exit;
-  end;
+  end;  *)
   modalResult := mrOK;
 end;
@@ -142,5 +194,5 @@
 var
   i : integer;
-  TimePart, DayPart: string;
+  TimePart, DayPart, Schedule: string;
 begin
   with (Sender as TCheckBox) do
@@ -152,5 +204,5 @@
         FDaySchedule[TCheckBox(Sender).Tag] := '';
     except
-      ShowMessage('Error happened when building day schedule.');
+      ShowMsg('Error happened when building day schedule.');
       Exit;
     end;
@@ -159,9 +211,14 @@
   TimePart := '';
   DayPart := '';
-  for i := 0 to FTimeSchedule.Count - 1 do
-  begin
-    if i = 0 then TimePart := TimePart + FTimeSchedule[i]
-    else TimePart := TimePart + '-' + FTimeSchedule[i];
-  end;
+  schedule := '';
+  if Self.GroupBox2.Enabled = True then
+    begin
+        for i := 0 to FTimeSchedule.Count - 1 do
+          begin
+            if i = 0 then TimePart := TimePart + FTimeSchedule[i]
+            else TimePart := TimePart + '-' + FTimeSchedule[i];
+          end;
+    end;
+  if (self.GroupBox3.Enabled = True) and (FSchedule <> '') then schedule := FSchedule;
   for i := Low(FDaySchedule) to High(FDaySchedule) do
   begin
@@ -179,5 +236,39 @@
       FOtherSchedule := TimePart;
   end
+  else if Length(schedule) > 0 then
+    begin
+      if length(DayPart) > 0 then
+      FOtherSchedule := DayPart + '@' + Schedule
+    else if Length(DayPart) = 0 then
+      FOtherSchedule := Schedule;
+    end
   else FOtherSchedule := DayPart;
+  txtSchedule.Text := FOtherSchedule;
+end;
+
+
+procedure TfrmOtherSchedule.SetScheduleSelection;
+var
+  i: integer;
+  DayPart: string;
+begin
+  DayPart := '';
+  for i := Low(FDaySchedule) to High(FDaySchedule) do
+  begin
+    if Length(FDaySchedule[i])>0 then
+    begin
+      if DayPart = '' then DayPart := FDaySchedule[i]
+      else DayPart := DayPart + '-' + FDaySchedule[i];
+    end;
+  end;
+  if Length(DayPart) > 0 then
+  begin
+    if FSchedule <> '' then
+      FOtherSchedule := DayPart + '@' + FSchedule
+    else
+      FOtherSchedule := DayPart;
+  end
+  else FOtherSchedule := FSchedule;
+  //if Length(APRN) > 0 then FOtherSchedule := FOtherSchedule;
   txtSchedule.Text := FOtherSchedule;
 end;
@@ -278,4 +369,5 @@
   hour, min: string;
 begin
+  if FSchedule <> '' then Exit;
   if lstHour.ItemIndex < 0 then exit;
   hour := lstHour.Items[lstHour.ItemIndex];
@@ -298,4 +390,5 @@
   FTimeSchedule.Sort;
   SetTimeSchedule;
+  if FTimeSchedule.Count > 0 then EnabledSch(False);
 end;
 
@@ -313,4 +406,5 @@
   lstHour.ItemIndex := -1;
   lstMinute.ItemIndex := -1;
+  NSScboSchedule.ItemIndex := -1;
   for i := low(FDaySchedule) to high(FDaySchedule) do
     FDaySchedule[i] := '';
@@ -318,4 +412,33 @@
   FOtherSchedule := '';
   txtSchedule.Text := '';
+  FSchedule := '';
+  EnabledTime(True);
+  EnabledSch(True);
+end;
+
+procedure TfrmOtherSchedule.btnSchAddClick(Sender: TObject);
+begin
+  inherited;
+  if self.NSScboSchedule.ItemIndex < 0 then Exit;
+  if FSchedule <> '' then
+    begin
+      infoBox('A Day-of-week schedule can only contain one schedule','Warning',MB_OK);
+      Exit;
+    end;
+  FSchedule := self.NSScboSchedule.Text;
+  SetScheduleSelection;
+  Self.NSScboSchedule.Enabled := False;
+  EnabledTime(False);
+end;
+
+procedure TfrmOtherSchedule.btnSchRemoveClick(Sender: TObject);
+begin
+  inherited;
+  if (FSchedule = '') or (self.NSScboSchedule.ItemIndex < 0) then exit;
+  if self.NSScboSchedule.Text <> FSchedule then exit;
+  Fschedule := '';
+  SetScheduleSelection;
+  self.NSScboSchedule.Enabled := True;
+  EnabledTime(True);
 end;
 
@@ -346,4 +469,5 @@
   SetTimeSchedule;
   FFromCheckBox := False;
+  if FTimeSchedule.Count = 0 then EnabledSch(True);
 end;
 
@@ -370,4 +494,5 @@
     Action := caFree;
   end;
+  //frmOtherSchedule := nil;
 end;
 
@@ -523,4 +648,29 @@
 end;
 
+procedure TfrmOtherSchedule.EnabledSch(TF: boolean);
+begin
+   self.GroupBox3.Enabled := TF;
+   self.NSScboSchedule.Enabled := TF;
+   self.btnSchAdd.Enabled := TF;
+   self.btnSchRemove.Enabled := TF;
+//   if TF = False then self.NSScboSchedule.Color := cl3DLight
+//   else self.NSScboSchedule.Color := clWindow;
+   if TF = False then self.NSScboSchedule.ItemIndex := -1;
+end;
+
+procedure TfrmOtherSchedule.EnabledTime(TF: boolean);
+begin
+  self.GroupBox2.Enabled := TF;
+  self.lstHour.Enabled := TF;
+  self.lstMinute.Enabled := TF;
+  self.btnAdd.Enabled := TF;
+  self.btnRemove.Enabled := TF;
+  if TF = False then
+    begin
+      self.lstHour.ItemIndex := -1;
+      self.lstMinute.ItemIndex := -1;
+    end;
+end;
+
 procedure TfrmOtherSchedule.lstMinuteMouseUp(Sender: TObject;
   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
