Ejemplo n.º 1
0
int shutdown_approvals()
{
   if (spv_approve_dialog_up)
      if (approval_data_changed())
      {
         XMapRaised (XtDisplay(spv_create_shell),
            XtWindow(spv_create_shell));
         post_dialog (spv_approve_dialog, XmDIALOG_ERROR,
            "Unsaved Approval Information");
         return (FAILURE);
      }

   if (deny_dialog_up)
      if (denial_data_changed())
      {
         XMapRaised (XtDisplay(spv_create_shell),
            XtWindow(spv_create_shell));
         post_dialog (deny_dialog, XmDIALOG_ERROR,
            "Unsaved Approval Information");
         return (FAILURE);
      }

   close_approval_windows();
   return(SUCCESS);

} /* end shutdown_approvals */
Ejemplo n.º 2
0
int shutdown_cmf_external_id()
{

  if (ci_idterminate_dialog && XtIsManaged(ci_idterminate_dialog))
  {
    XMapRaised(XtDisplay(ci_idterminate_shell),
               XtWindow(ci_idterminate_shell));
    post_dialog(ci_idterminate_shell, XmDIALOG_ERROR, 
                 "Unsaved Provisioning Information");
    return(FAILURE);
  }
  
  if (ci_iddetail_form && XtIsManaged(ci_iddetail_form))
  {
    XMapRaised(XtDisplay(ci_iddetail_shell),
               XtWindow(ci_iddetail_shell));
    post_dialog(ci_iddetail_shell, XmDIALOG_ERROR, 
                 "Unsaved Provisioning Information");
    return(FAILURE);
  }
  
  close_cmf_external_id_windows();
  return(SUCCESS);

} /* end shutdown_cmf_external_id */
Ejemplo n.º 3
0
int shutdown_corridors()
{
  if (coradd_form && XtIsManaged(coradd_form))
  {
    XMapRaised(XtDisplay(coradd_shell),
               XtWindow(coradd_shell));
    post_dialog(coradd_shell, XmDIALOG_ERROR, 
                 "Unsaved Provisioning Information");
    return(FAILURE);
  }
  
  if (coricb_form && XtIsManaged(coricb_form))
  {
    XMapRaised(XtDisplay(coricb_shell),
               XtWindow(coricb_shell));
    post_dialog(coricb_shell, XmDIALOG_ERROR, 
                 "Unsaved Provisioning Information");
    return(FAILURE);
  }
  
  if (corrate_form && XtIsManaged(corrate_form))
  {
    XMapRaised(XtDisplay(corrate_shell),
               XtWindow(corrate_shell));
    post_dialog(corrate_shell, XmDIALOG_ERROR, 
                 "Unsaved Provisioning Information");
    return(FAILURE);
  }
  
  if (corter_bb && XtIsManaged(corter_bb))
  {
    XMapRaised(XtDisplay(corter_shell),
               XtWindow(corter_shell));
    post_dialog(corter_shell, XmDIALOG_ERROR, 
                 "Unsaved Provisioning Information");
    return(FAILURE);
  }
  
  if (corsel_form && XtIsManaged(corsel_form))
  {
    XMapRaised(XtDisplay(corselect_shell),
               XtWindow(corselect_shell));
    post_dialog(corselect_shell, XmDIALOG_ERROR, 
                 "Unsaved Provisioning Information");
    return(FAILURE);
  }
  
  close_corridors_windows();
  return(SUCCESS);

} /* end shutdown_corridors */
Ejemplo n.º 4
0
void display_manual_history_screen(Widget w, XtPointer *client_data,
XmListCallbackStruct *call_data)
{
   int *position_list;
   int num_selected;

   show_busy_cursor (cc_manual_hold_shell, True);

   if (cc_manual_hist_shell == NULL)
   {
      create_cc_manual_hist_shell (cc_manual_hold_shell);
      set_editable_off(cc_hist_account_id_txt);
      set_editable_off(cc_hist_amount_txt);
      set_editable_off(cc_hist_bill_ref_no_txt);
   }

   if (XmListGetSelectedPos (cc_manual_hold_list, &position_list,&num_selected))
   {
      selected_manual_hold = position_list[0];
      if(refresh_manual_history_screen() == FAILURE)
      {
        show_busy_cursor (cc_manual_hold_shell, False);
	return;
      }
      XtManageChild (cc_manual_hist_form);
      XtPopup (cc_manual_hist_shell, XtGrabNone);
      cc_manual_hist_shell_up = True;
   }
   else post_dialog(cc_manual_hold_shell,XmDIALOG_ERROR,
     "Please select an item.");

   show_busy_cursor (cc_manual_hold_shell, False);

} /* end display_manual_history_screen */
void
emf_terminate_external_id_cb(Widget w,
                   XtPointer client_data,
                   XmPushButtonCallbackStruct *call_data)
{
int *sellist = NULL;
int selcount;
int is_selected;

  if (emf_idterminate_shell == NULL) 
  {
    create_emf_idterminate_shell(emf_idinfo_shell);
  }

  is_selected = XmListGetSelectedPos(emf_external_list,&sellist,&selcount);

  if ((!is_selected) || (selcount = 0))
  {
    post_dialog (emf_idinfo_shell,XmDIALOG_ERROR,"Select an item for termination");
    return;
  }

  emf_external_id = sellist[0] - 1;
  free (sellist);

  XtManageChild(emf_idterminate_dialog);
  XtPopup(emf_idterminate_shell,XtGrabNone);
}
Ejemplo n.º 6
0
void 
RoamInterruptibleCmd::execute()
{
    char *name_str;
    
    name_str = (char *) name();

    _done  = FALSE;  // Initialize flag

    // Let the derived class post the dialog.
    // Updates happen when derived classes call update() or 
    // updateMessage().

    post_dialog();
    
    // Call the Cmd execute function to handle the Undo, and other
    // general mechanisms supported by Cmd. 
    // execute() calls doit() of derived class.
    
    Cmd::execute();  

    // If the task was completed in a single call,
    // don't bother to set up a work procedure. Just
    // give derived classes a chance to cleanup and
    // call the application's callback function

    // If it was interrupted, the interruptCallback would have been
    // called already and the dialog would have been unposted...

    // We need to focus on only two cases here:  what if the task was
    // was completed in one call without interruptions (unpost dialog 
    // and call callback indicating task completed), and what if the 
    // task was not completed in one call (install a workProc...)
    // 

    // if it done but not interrupted, it was genuinely done.
    if (_done && !_interrupted)
      {
	  unpost_dialog();  // derived classes implement this
	  cleanup();
	  
	  if ( _callback )  // the FALSE is to say it was not interrupted.
	      ( *_callback )( this, FALSE, _clientData );
      }

    // If the task is not done and it was not interrupted and there is
    // a callback to install, install a work procedure to continue the 
    // task as soon as possible.  Call the callback via the work proc
    // after completion.
    // 
    
    else if ((!_done && !_interrupted && _callback)) 
      {
	  
	  _wpId = XtAppAddWorkProc ( theApplication->appContext(), 
				  &RoamInterruptibleCmd::workProcCallback,
 				  (XtPointer) this );
      }
}
Ejemplo n.º 7
0
int shutdown_packages()
{

   if (emfp_shell_up)
      if (emfp_data_changed())
      {
         XMapRaised (XtDisplay(emf_products_shell), XtWindow(emf_products_shell));
         post_dialog (emf_products_shell, XmDIALOG_ERROR, 
            "Unsaved Provisioning Information");
         return(FAILURE);
      }

   if (emfpm_shell_up)
      if (emfpm_data_changed())
      {
         XMapRaised (XtDisplay(emfp_modify_shell), XtWindow(emfp_modify_shell));
         post_dialog (emfp_modify_shell, XmDIALOG_ERROR, 
            "Unsaved Provisioning Information");
         return(FAILURE);
      }

   if (pp_provision_form && XtIsManaged(pp_provision_form))
      {
         XMapRaised (XtDisplay(pp_provision_shell), XtWindow(pp_provision_shell));
         post_dialog (pp_provision_shell, XmDIALOG_ERROR, 
            "Unsaved Provisioning Information");
         return(FAILURE);
      }

   if (pp_secondary_form && XtIsManaged(pp_secondary_form))
      {
         XMapRaised (XtDisplay(pp_secondary_shell), XtWindow(pp_secondary_shell));
         post_dialog (pp_secondary_shell, XmDIALOG_ERROR, 
            "Unsaved Provisioning Information");
         return(FAILURE);
      }

   close_packages_windows();
   return(SUCCESS);
}
Ejemplo n.º 8
0
/*=== cor_filter_cb =========================================================
 * Called when the user hits 'Filter' -OR- 'Sort'.
 */
void
cor_filter_cb(Widget    w,
              XtPointer client_data,
              XtPointer call_data)
{
  char *tmp;
  char  plan[CORRIDOR_TEXT_LEN];
  char  point_origin[POINT_ORIGIN_LEN];
  char  point_target[POINT_TARGET_LEN];
  int   corridor_plan_id;
  int   found;
  int   i;

  tmp = XmTextGetString(cor_filter_plan_txt);
  strcpy(plan, tmp);
  XtFree(tmp);

  if (strlen(plan))
  {
    found = FALSE;
    for (i = 0; i < gnum_corplans; i++)
      if (strcmp(plan, gcorplans[i].description) == 0)
      {
        corridor_plan_id = gcorplans[i].db_code;
        found = TRUE;
      }
    if (! found)
    {
      post_dialog(cor_shell, XmDIALOG_ERROR,
                  "Invalid Corridor Plan.");
      XmProcessTraversal(cor_filter_plan_txt, XmTRAVERSE_CURRENT);
      return;
    }
  }
  else
    corridor_plan_id = 0;

  tmp = XmTextGetString(cor_filter_origin_txt);
  strcpy(point_origin, tmp);
  XtFree(tmp);
  tmp = XmTextGetString(cor_filter_target_txt);
  strcpy(point_target, tmp);
  XtFree(tmp);
  
  populate_corridor_list(corridor_plan_id,
                         point_origin,
                         point_target,
                         cor_sort_order);
}
Ejemplo n.º 9
0
int shutdown_adjustments()
{
   if (adjust_shell_up)
      if (adj_data_changed())
      {
         XMapRaised (XtDisplay(adjust_shell), XtWindow(adjust_shell));
         post_dialog (adjust_shell, XmDIALOG_ERROR,
            "Unsaved Adjustment Information");
         return(FAILURE);
      }

   close_adj_windows();
   return(SUCCESS);

} /* end shutdown_adjustments */
Ejemplo n.º 10
0
int shutdown_nrc()
{
   if (nrc1_shell_up)
      if (nrc_data_changed())
      {
         XMapRaised (XtDisplay(nrc_shell), XtWindow(nrc_shell));
         post_dialog (nrc1_shell, XmDIALOG_ERROR,
            "Unsaved Non Recurring Charges Information");
         return(FAILURE);
      }

   close_nrc_windows();
   return(SUCCESS);

} /* end shutdown_nrc */
Ejemplo n.º 11
0
int shutdown_contracts()
{
   if (ci_contractlist_shell_up)
      if (contract_data_changed()){
         XMapRaised (XtDisplay(ci_contractlist_shell), 
                     XtWindow (ci_contractlist_shell) );
         post_dialog (ci_contractlist_shell, XmDIALOG_ERROR,
                                 "Unsaved Customer Contract Information");
         return(FAILURE);
      }

   close_contract_window(NULL, NULL, NULL);
   return(SUCCESS);

} /* end of shutdown_contracts */
Ejemplo n.º 12
0
int shutdown_unit_credits()
{
   if (ci_ucrlist_shell_up)
      if (ucr_data_changed()){
         XMapRaised (XtDisplay(ci_ucrlist_shell), 
                     XtWindow (ci_ucrlist_shell) );
         post_dialog (ci_ucrlist_shell, XmDIALOG_ERROR,
                                 "Unsaved Unit Credits Information");
         return(FAILURE);
      }

   close_ucr_window(NULL, NULL, NULL);
   return(SUCCESS);

} /* end of shutdown_unit_credits */
Ejemplo n.º 13
0
int shutdown_notes()
{
   if (notes_create_shell_up)
      if (notes_create_data_changed())
      {
         XMapRaised (XtDisplay(notes_shell), XtWindow(notes_shell));
         post_dialog (notes_create_shell, XmDIALOG_ERROR,
            "Unsaved Notes Information");
         return(FAILURE);
      }

   close_notes_windows();
   return(SUCCESS);

} /* end shutdown_notes */
Ejemplo n.º 14
0
int shutdown_equipment()
{

   if (emf_shell_up)
      if (emf_data_changed())
      {
         XMapRaised (XtDisplay(emf_shell), XtWindow(emf_shell));
         post_dialog (emf_shell, XmDIALOG_ERROR, 
            "Unsaved Subscriber Information");
         return(FAILURE);
      }

   close_equipment_windows();
   return(SUCCESS);

} /* end shutdown_equipment */
Ejemplo n.º 15
0
void
emf_modify_external_id_cb(Widget w,
                   XtPointer client_data,
                   XmPushButtonCallbackStruct *call_data)
{
EXTERNAL_ID_DATA_TYPE modify_order;
int *sellist = NULL;
int selcount;
int is_selected;

  memset (&modify_order,0,sizeof(EXTERNAL_ID_DATA_TYPE));

  if (emf_iddetail_shell == NULL) 
  {
    create_emf_iddetail_shell(emf_idinfo_shell);
    XtAddEventHandler(emf_iddetail_start_txt,KeyPressMask,False,
       check_date,NULL);
    XtAddEventHandler(emf_iddetail_end_txt,KeyPressMask,False,
       check_date,NULL);
  }

  is_selected = XmListGetSelectedPos(emf_external_list,&sellist,&selcount);

  if ((!is_selected) || (selcount = 0))
  {
    post_dialog (emf_idinfo_shell,XmDIALOG_ERROR,"Select an item for modification");
    return;
  }
    
  emf_external_id = sellist[0] - 1;
  free (sellist);

  display_emf_external_id_data_on_screen (active_external_ids[emf_external_id]);

/* initialize struct for confirming cancel */
  memset (&emf_old_external_id,0,sizeof(emf_old_external_id));
  get_emf_external_id_data_from_screen (&emf_old_external_id);

  set_editable_off(emf_iddetail_id_txt);

  emfx_modify_flag = TRUE;

  emfx_shell_up = TRUE;

  XtManageChild (emf_iddetail_form);
  XtPopup (emf_iddetail_shell,XtGrabNone);
}
Ejemplo n.º 16
0
int shutdown_financials()
{
   if (gCBrefundwin_up)
      if (refund_data_changed())
      {
         XMapRaised (XtDisplay(gCBmain), XtWindow(gCBmain));
         post_dialog (gCBrefundwin, XmDIALOG_ERROR,
            "Unsaved Refund Information");
         return(FAILURE);
      }

   /* No need to check deposit_insert_shell and deposit_return_shell
   ** because they are full application modal
   */

   close_financial_system();
   return(SUCCESS);

} /* end shutdown_financials */
Ejemplo n.º 17
0
void cc_credit_process_btn_cb(Widget w, XtPointer *client_data,
XmPushButtonCallbackStruct *call_data)
{
   int *position_list;
   int num_selected;

   show_busy_cursor (cc_credit_hold_shell, True);

   if (XmListGetSelectedPos (cc_credit_list, &position_list, &num_selected))
   {
      process_credit_holds(position_list, num_selected); 
      refresh_credit_hold_screen();

      free (position_list);
   }
   else post_dialog(cc_credit_hold_shell, XmDIALOG_ERROR,
      "Please select one or more items to process.");

   show_busy_cursor (cc_credit_hold_shell, False);

} /* end cc_credit_process_btn_cb */
Ejemplo n.º 18
0
void setup_detail_screen(Widget w, XtPointer *client_data,
XmPushButtonCallbackStruct *call_data)
{
   int *position_list;
   int num_selected;

   show_busy_cursor (cc_manual_hold_shell, True);

   if (XmListGetSelectedPos (cc_manual_hold_list, &position_list,&num_selected))
   {
      selected_manual_hold = position_list[0];
      free (position_list);
      cc_change_type = (int)client_data;
      display_manual_detail_screen ();
   }
   else post_dialog(cc_manual_hold_shell,XmDIALOG_ERROR,
      "Please select an item to change.");

   show_busy_cursor (cc_manual_hold_shell, False);

} /* end setup_detail_screen */
Ejemplo n.º 19
0
int bld_geocode(Widget parent, Widget parent_form, Widget county_field,
                char *in_city,char *in_state,char *in_zip,
                char *in_county, char **out_county, char **out_geo,
                int input_geocode_type, int country_code, int franchise_code)
{
    int found_match;

    char display_string[300];
    char temp_string[100];
    char **counties = NULL;
    char **geocodes = NULL;
    int num_geos = 0;
    char *temp_geo = NULL;
    char *temp_county = NULL;
    int i;
    int county_len;
    int found_county;
    int j;
    int status;

    found_match = 0;
    found_county = 0;

    found_match = find_geocode (country_code,franchise_code,in_city,in_state,in_zip,&counties,&geocodes,&num_geos);

    if ((found_match) && (num_geos > 1))
    {

        /* first compare in_county to see if it matches one */

        county_len = strlen (in_county);
        for(j=county_len - 1; j > 0; j--)
        {
            if(in_county[j] == ' ')
            {
                in_county[j] = '\0';
            }
            else
            {
                break;
            }
        }

        for(i=0; i<strlen(in_county); i++)
        {
            in_county[i] = toupper(in_county[i]);
        }

        for (i=0; i<num_geos; i++)
        {
            /* remove trailing spaces */
            for(j=(strlen(counties[i]) - 1); j > 0; j--)
            {
                if(counties[i][j] == ' ')
                {
                    counties[i][j] = '\0';
                }
                else
                {
                    break;
                }
            }
            if (strcmp(in_county,counties[i]) == 0)
            {
                /* found exact match */
                temp_county = (char *)malloc((strlen(counties[i])+1) * sizeof(char));
                temp_geo = (char *)malloc((strlen(geocodes[i])+1) * sizeof(char));
                strcpy (temp_county,counties[i]);
                strcpy (temp_geo,geocodes[i]);

                found_county = TRUE;
                *out_county = temp_county;
                *out_geo = temp_geo;
                status = SUCCESS;
            }
        }

        if (!found_county)
        {
            strcpy (display_string,"Valid Counties are:\n");

            for(i=0; i<num_geos; i++)
            {
                sprintf(temp_string," %15.15s\n",counties[i]);
                strcat(display_string,temp_string);
            }

            show_window(parent,parent_form);

            XmProcessTraversal (county_field,XmTRAVERSE_CURRENT);

            post_dialog (parent,XmDIALOG_ERROR,display_string);
            status = FAILURE;
        }
    }
    else if (found_match)
    {
        temp_county = (char *)malloc((strlen(counties[0])+1) * sizeof(char));
        temp_geo = (char *)malloc((strlen(geocodes[0])+1) * sizeof(char));
        strcpy (temp_county,counties[0]);
        strcpy (temp_geo,geocodes[0]);

        *out_county = temp_county;
        *out_geo = temp_geo;
        status = SUCCESS;
    }
    else
    {   /* no match, based on parameters from system params, this may be an error */

        temp_county = (char *)malloc(2 * sizeof(char));
        temp_geo = (char *)malloc(2 * sizeof(char));
        strcpy (temp_county,"");
        strcpy (temp_geo,"");

        *out_county = temp_county;
        *out_geo = temp_geo;

        if (input_geocode_type == NO_GEOCODE_IS_IGNORED)
        {
            status = SUCCESS;
        }
        else if (input_geocode_type == NO_GEOCODE_IS_WARNING)
        {
            post_dialog (parent,XmDIALOG_ERROR,"Unable to calculate GEOCODE");
            status = SUCCESS;
        }
        else if (input_geocode_type == NO_GEOCODE_IS_ERROR)
        {
            post_dialog (parent,XmDIALOG_ERROR,"Unable to calculate GEOCODE.\nCorrect Address Information and try again.");
            status = FAILURE;
        }
    }

    /* free individual elements of counties and geocodes malloced in find_geocode */
    for (i=0; i < num_geos; i++)
    {
        if (counties[i] != NULL) free (counties[i]);
        if (geocodes[i] != NULL) free (geocodes[i]);
    }

    /* free arrays of counties and geocodes malloced in find_geocode */
    if (counties != NULL) free (counties);
    if (geocodes != NULL) free (geocodes);


    return (status);

}
Ejemplo n.º 20
0
void
emf_detail_verify_cb(Widget w,
                   XtPointer client_data,
                   XmPushButtonCallbackStruct *call_data)
{
EXTERNAL_ID_DATA_TYPE modify_order;
int status;
RETCODE ret_code;
int valid_date_found;
char *valid_date = NULL;
ARBOR_EXTERNAL_ID_MAP old_id_map;
ARBOR_EXTERNAL_ID_MAP new_id_map;

  valid_date_found = validate_date (emf_iddetail_start_txt,&valid_date);
  if (!valid_date_found)
  {
    return;
  }

  free (valid_date);

  valid_date_found = validate_date (emf_iddetail_end_txt,&valid_date);
  if (!valid_date_found)
  {
    return;
  }

  free (valid_date);

  memset (&modify_order,0,sizeof(EXTERNAL_ID_DATA_TYPE));
  get_emf_external_id_data_from_screen (&modify_order);

  if (strcmp(modify_order.external_id,"") == 0)
  {
     post_dialog (emf_iddetail_shell,XmDIALOG_ERROR, "External Id is a required field");
     XmProcessTraversal(emf_iddetail_id_txt, XmTRAVERSE_CURRENT);
     return;
  }
  if (strcmp(modify_order.active_dt,"") == 0)
  {
     post_dialog (emf_iddetail_shell,XmDIALOG_ERROR, "Start Date is a required field");
     XmProcessTraversal(emf_iddetail_start_txt, XmTRAVERSE_CURRENT);
     return;
  }
  if (strcmp(modify_order.inactive_dt,"") != 0)
  {
      if (date_cmp (modify_order.active_dt, modify_order.inactive_dt, &status) > 0)
      {
         post_dialog (emf_iddetail_shell,XmDIALOG_ERROR,"End Date must be after Start Date.");
         XmProcessTraversal(emf_iddetail_end_txt, XmTRAVERSE_CURRENT);
         return;
      }
  }
  
  if (modify_order.external_id_type == 0)
  {
     post_dialog (emf_iddetail_shell,XmDIALOG_ERROR, "Source is a required field");
     XmProcessTraversal(emf_iddetail_source_txt, XmTRAVERSE_CURRENT);
     return;
  }
/* save external id to db */

  if (emfx_modify_flag)
  {

    /* UPDATE the existing CIEM entry */
    old_id_map.account_no       = emf_active_account_no;
    old_id_map.external_id_type =
      active_external_ids[emf_external_id].external_id_type;
    strcpy(old_id_map.active_date,
           active_external_ids[emf_external_id].full_active_dt);
  
    new_id_map.account_no       = emf_active_account_no;
    new_id_map.subscr_no        = emf_active_subscr_no;
    new_id_map.subscr_no_resets = emf_active_subscr_no_resets;
    strcpy(new_id_map.external_id,
           active_external_ids[emf_external_id].external_id);
    new_id_map.external_id_type =
      modify_order.external_id_type;
    strcpy(new_id_map.active_date,
           modify_order.active_dt);
    strcpy(new_id_map.inactive_date, modify_order.inactive_dt);
    new_id_map.server_id = gserver_id;

    ret_code = update_equip_external_id(dbcatalog,
                                        dbproc1,
                                        &old_id_map,
                                        &new_id_map);

  }
  else
  {
    /* INSERT a new CIEM entry */

    new_id_map.account_no          = emf_active_account_no;
    new_id_map.subscr_no           = emf_active_subscr_no;
    new_id_map.subscr_no_resets    = emf_active_subscr_no_resets;
    strcpy(new_id_map.external_id,   modify_order.external_id);
    new_id_map.external_id_type    = modify_order.external_id_type;
    strcpy(new_id_map.active_date,   modify_order.active_dt);
    strcpy(new_id_map.inactive_date, modify_order.inactive_dt);
    new_id_map.server_id           = gserver_id;

    ret_code = insert_equip_external_id(dbcatalog,
                                       dbproc1,
                                       &new_id_map);

  }

  if (ret_code == SUCCESS)
  {
    populate_emf_external_id_scrolled_list();

    XtUnmanageChild (emf_iddetail_form);
    XtPopdown (emf_iddetail_shell);
  }
}
Ejemplo n.º 21
0
void pp_get_pkg_picked(Widget w, XtPointer *client_data, XmListCallbackStruct *call_data)
{
int selection;
int component_id;
char component_desc[81];
int max_allowed;
int min_reqd;
int comp_level;
int status;
int ret_code;
char *start_date = NULL;
int valid_date_found = 0;

  selection = call_data->item_position - 1;
  gprov_new_package = pp_elig_pkgs[selection].db_code;

  XmTextSetString (ppp_packageid_txt, pp_elig_pkgs[selection].description);

  valid_date_found = validate_date (ppp_start_date_txt,&start_date);
  if (!valid_date_found)
  {
    return;
  }

  if (strcmp(start_date,"") == 0)
  {
    post_dialog (pp_provision_shell,XmDIALOG_ERROR,"Start Date cannot be blank.");
    return;
  }

  XtUnmanageChild (pp_poplist_form);
  XtPopdown (pp_poplist_shell);

  /* now got get the components for this package */

  num_pp_avail_components = 0;

  show_busy_cursor(pp_provision_shell, TRUE);

  XmListDeleteAllItems (ppp_prov_list);
  XmListDeselectAllItems (ppp_prov_list);

  dbfcmd(dbproc1, "exec pp_select_avail_components @pkg_id = %d,",gprov_new_package);
  dbfcmd(dbproc1, " @lang_code = %d, ", gGUIlanguage);
  dbfcmd(dbproc1, " @input_date = '%s' ", start_date);

  if(safe_dbexec(dbproc1,"SELECT_ELIGIBLE_COMPONENTS", "select_eligible_comps")) 
    return;

  while ((status = safe_dbresults (dbproc1, "SELECT_ELIGIBLE_COMPONENTS", "select_eligible_comps")) != NO_MORE_RESULTS)
  {
    if (status == FAIL) return;

    dbbind (dbproc1, 1, INTBIND, 0, &component_id);
    dbbind (dbproc1, 2, NTBSTRINGBIND, 0, component_desc);
    dbbind (dbproc1, 3, INTBIND, 0, &min_reqd);
    dbbind (dbproc1, 4, INTBIND, 0, &max_allowed);
    dbbind (dbproc1, 5, INTBIND, 0, &comp_level);

    while ((ret_code = dbnextrow(dbproc1)) != NO_MORE_ROWS)
    {
      if(ret_code == FAIL) return;

      /* process results */

      num_pp_avail_components++;
      pp_avail_components = (COMPONENT_PROV_TYPE *) realloc (pp_avail_components, num_pp_avail_components * sizeof(COMPONENT_PROV_TYPE));

      pp_avail_components[num_pp_avail_components - 1].comp_id = component_id;
      pp_avail_components[num_pp_avail_components - 1].level_code = comp_level;
      pp_avail_components[num_pp_avail_components - 1].min_reqd = min_reqd;
      pp_avail_components[num_pp_avail_components - 1].max_allowed = max_allowed;
      strcpy (pp_avail_components[num_pp_avail_components - 1].comp_text,component_desc);

    }
  }

  pp_build_prov_comp_list();
  pp_display_avail_components(); 

  show_busy_cursor(pp_provision_shell, FALSE);
}
Ejemplo n.º 22
0
// CONSTRUCTOR
GPViewPageNode::GPViewPageNode(Widget Toplevel, DPC_page* Page, int Xpos, int Ypos, int Width, int Height) {

    const char *separator = "#------------------------------------------------\n";
    const char *new_section = "\n\n";
    const char *ncells_s;

    page = Page;
    toplevel = Toplevel;
    device = NOT_SET;
    #ifdef DEBUG
    save_tmp_files = true;
    #endif

    if ((ncells_s = Page->getAttribute("hcells")) != NULL) {
        n_hcells = atoi(ncells_s);
        if ((n_hcells < 0)||(n_hcells > 10)) {
        post_dialog( toplevel, XmDIALOG_ERROR,
            "Value for hcells attribute is out of range.\n"
            "Valid range for hcells is 1 .. 10.\n"
            "Ignoring hcells value.\n" );
            n_hcells = 1;
        }
    } else {
        n_hcells = 1;
    }

    if ((ncells_s = Page->getAttribute("vcells")) != NULL) {
        n_vcells = atoi(ncells_s);
        if ((n_vcells < 0)||(n_vcells > 10)) {
        post_dialog( toplevel, XmDIALOG_ERROR,
            "Value for vcells attribute is out of range.\n"
            "Valid range for vcells is 1 .. 10.\n"
            "Ignoring vcells value.\n");
            n_vcells = 1;
        }
    } else {
        n_vcells = 1;
    }


    //! Build the page part of the template.
    textbuf.print("%s", separator);
    textbuf.print("# (generated for GNUPLOT Version <GNUPLOT_VERSION>)\n");
    textbuf.print("# To execute, run the following command:\n");
    textbuf.print("# %% gnuplot -persist file_name [ENTER]\n");
    textbuf.print("#\n");
    textbuf.print("# Template:\n");
    textbuf.print("%s", separator);
    textbuf.print("set title \"<PAGE_TITLE>\"\n");

    //! Terminal spec line
    textbuf.print("%s", new_section);
    textbuf.print("%s", separator);
    textbuf.print("#  Set the output device\n");
    textbuf.print("%s", separator);
    if ( GnuplotVersion() >= 4.2 ) {
        textbuf.print("set term <TERM_TYPE> <CANVAS_SIZE> <TERM_OPTIONS>\n");
    } else if ( GnuplotVersion() >= 4.0 ) {
        textbuf.print("set term <TERM_TYPE> <TERM_OPTIONS>\n");
    } else {
        textbuf.print("set term <TERM_TYPE>\n");
    }

    //! Page size for whole page
    textbuf.print("%s", new_section);
    textbuf.print("%s", separator);
    textbuf.print("#  Set \"page\" size for whole plot\n");
    textbuf.print("%s", separator);
    textbuf.print("set size 1.0,1.0\n");
    textbuf.print("set origin 0.0,0.0\n");

    //! Default option for all plots
    textbuf.print("%s", new_section);
    textbuf.print("%s", separator);
    textbuf.print("#  Set default options for all plots\n");
    textbuf.print("%s", separator);
    textbuf.print("<PAGE_GRID_SPEC> <PAGE_GRID_COLOR_SPEC>\n");
    textbuf.print("set nolabel\n");
    if ( GnuplotVersion() >= 4.0 ) {
        textbuf.print("set mouse\n");
        textbuf.print("set style data <STYLE_DATA_SPEC>\n");
        textbuf.print("set style function <STYLE_FUNC_SPEC>\n");
    }

    /*!
     * OPTIONAL PAGE SETTINGS
     */
    if ( GnuplotVersion() >= 4.0 ) {
        textbuf.print("<PAGE_X_AXIS_SCALING_SPEC>");
        textbuf.print("<PAGE_Y_AXIS_SCALING_SPEC>");
    }
    textbuf.print("<PAGE_Y_AXIS_FORMAT_SPEC>");
    textbuf.print("<PAGE_FOREGROUND_SPEC>");
    textbuf.print("<PAGE_BACKGROUND_SPEC>");
    textbuf.print("<PAGE_KEY_SPEC>"); // key is the legend

    //! Linestyles
    char version_line_style[32] ;
    textbuf.print("%s", new_section);
    textbuf.print("%s", separator);
    textbuf.print("#  Set linestyles\n");
    textbuf.print("#  color scheme may differ if \"-xrm\" option was used\n");
    textbuf.print("%s", separator);
    textbuf.print("line_type_1  = <LINE_TYPE_1>\n");
    textbuf.print("line_type_2  = <LINE_TYPE_2>\n");
    textbuf.print("line_type_3  = <LINE_TYPE_3>\n");
    textbuf.print("line_type_4  = <LINE_TYPE_4>\n");
    textbuf.print("line_type_5  = <LINE_TYPE_5>\n");
    textbuf.print("line_type_6  = <LINE_TYPE_6>\n");
    textbuf.print("line_type_7  = <LINE_TYPE_7>\n");
    textbuf.print("line_type_8  = <LINE_TYPE_8>\n");
    textbuf.print("line_type_9  = <LINE_TYPE_9>\n");
    textbuf.print("line_type_10 = <LINE_TYPE_10>\n");
    textbuf.print("line_type_11 = <LINE_TYPE_11>\n");
    textbuf.print("line_type_12 = <LINE_TYPE_12>\n");
    textbuf.print("line_type_13 = <LINE_TYPE_13>\n");

    textbuf.print("\n");
    textbuf.print("point_shape_1  = <POINT_SHAPE_1>\n");
    textbuf.print("point_shape_2  = <POINT_SHAPE_2>\n");
    textbuf.print("point_shape_3  = <POINT_SHAPE_3>\n");
    textbuf.print("point_shape_4  = <POINT_SHAPE_4>\n");
    textbuf.print("point_shape_5  = <POINT_SHAPE_5>\n");
    textbuf.print("point_shape_6  = <POINT_SHAPE_6>\n");
    textbuf.print("point_shape_7  = <POINT_SHAPE_7>\n");
    textbuf.print("point_shape_8  = <POINT_SHAPE_8>\n");
    textbuf.print("point_shape_9  = <POINT_SHAPE_9>\n");
    textbuf.print("point_shape_10 = <POINT_SHAPE_10>\n");
    textbuf.print("point_shape_11 = <POINT_SHAPE_11>\n");
    textbuf.print("point_shape_12 = <POINT_SHAPE_12>\n");
    textbuf.print("point_shape_13 = <POINT_SHAPE_13>\n");

    //!Map Symbol Style pulldown menu to internal gnuplot shape indexes
    textbuf.print("\n");
    textbuf.print("None          = -1\n");
    textbuf.print("Square        = 4\n");
    textbuf.print("Circle        = 6\n");
    textbuf.print("Star          = 3\n");
    textbuf.print("XX            = 2\n");
    textbuf.print("Triangle      = 8\n");
    textbuf.print("Solid_Square  = 5\n");
    textbuf.print("Solid_Circle  = 7\n");
    textbuf.print("Thick_Square  = 5\n");

    //! Define a numerical value for the Symbol Size pulldown menu
    textbuf.print("\n");
    textbuf.print("Tiny   = 0.4\n");
    textbuf.print("Small  = 0.8\n");
    textbuf.print("Medium = 1.4\n");
    textbuf.print("Large  = 3.0\n");

    textbuf.print("\n");
    if ( GnuplotVersion() >= 4.0 ) {
            strcpy(version_line_style, "style line") ;
    } else {
            strcpy(version_line_style, "linestyle") ;
    }
    textbuf.print("set %s  1  <LINE_SPEC_1>  <LINE_COLOR_1>\n", version_line_style);
    textbuf.print("set %s  2  <LINE_SPEC_2>  <LINE_COLOR_2>\n", version_line_style);
    textbuf.print("set %s  3  <LINE_SPEC_3>  <LINE_COLOR_3>\n", version_line_style);
    textbuf.print("set %s  4  <LINE_SPEC_4>  <LINE_COLOR_4>\n", version_line_style);
    textbuf.print("set %s  5  <LINE_SPEC_5>  <LINE_COLOR_5>\n", version_line_style);
    textbuf.print("set %s  6  <LINE_SPEC_6>  <LINE_COLOR_6>\n", version_line_style);
    textbuf.print("set %s  7  <LINE_SPEC_7>  <LINE_COLOR_7>\n", version_line_style);
    textbuf.print("set %s  8  <LINE_SPEC_8>  <LINE_COLOR_8>\n", version_line_style);
    textbuf.print("set %s  9  <LINE_SPEC_9>  <LINE_COLOR_9>\n", version_line_style);
    textbuf.print("set %s 10  <LINE_SPEC_10>  <LINE_COLOR_10>\n", version_line_style);
    textbuf.print("set %s 11  <LINE_SPEC_11>  <LINE_COLOR_11>\n", version_line_style);
    textbuf.print("set %s 12  <LINE_SPEC_12>  <LINE_COLOR_12>\n", version_line_style);
    textbuf.print("set %s 13  <LINE_SPEC_13>  <LINE_COLOR_13>\n", version_line_style);

    //! Y Axes alignment command
    textbuf.print("%s", new_section);
    textbuf.print("%s", separator);
    textbuf.print("#  Force y-axes to align\n");
    textbuf.print("%s", separator);
    textbuf.print("set lmargin 7\n");

    //! Titles for whole page
    textbuf.print("%s", new_section);
    textbuf.print("%s", separator);
    textbuf.print("# Add title(s) for the whole page\n");
    textbuf.print("%s", separator);


    //! Page Title
    textbuf.print("set label <LABEL_1_TAG> \\\n");
    textbuf.print("    \"<LABEL_1_NAME>\" \\\n");
    textbuf.print("    at screen <LABEL_1_XPOS>,\\\n");
    textbuf.print("       screen <LABEL_1_YPOS>,\\\n");
    textbuf.print("       screen 0.0 <LABEL_1_JUST> \\\n");
    textbuf.print("       <PAGE_TEXT_COLOR_SPEC> \\\n");
    textbuf.print("       font <LABEL_1_FONT>\n\n");

    textbuf.print("set label <LABEL_2_TAG> \\\n");
    textbuf.print("    \"<LABEL_2_NAME>\" \\\n");
    textbuf.print("    at screen <LABEL_2_XPOS>,\\\n");
    textbuf.print("       screen <LABEL_2_YPOS>,\\\n");
    textbuf.print("       screen 0.0 <LABEL_2_JUST> \\\n");
    textbuf.print("       <PAGE_TEXT_COLOR_SPEC> \\\n");
    textbuf.print("       font <LABEL_2_FONT>\n\n");

    //! Another title with Simname/Runname
    textbuf.print("%s", new_section);
    textbuf.print("%s", separator);
    textbuf.print("# Add label(s) for the sim and run names\n");
    textbuf.print("%s", separator);

    textbuf.print("set label <LABEL_3_TAG> \\\n");
    textbuf.print("    \"<LABEL_3_NAME>\" \\\n");
    textbuf.print("    at screen <LABEL_3_XPOS>, \\\n");
    textbuf.print("       screen <LABEL_3_YPOS>, \\\n");
    textbuf.print("       screen 0.0 <LABEL_3_JUST> \\\n");
    textbuf.print("       <PAGE_TEXT_COLOR_SPEC> \\\n");
    textbuf.print("       font <LABEL_3_FONT>\n\n");

    //! Date (i.e., 4/2/2009)
    textbuf.print("set label <LABEL_4_TAG> \\\n");
    textbuf.print("    \"<LABEL_4_NAME>\" \\\n");
    textbuf.print("    at screen <LABEL_4_XPOS>, \\\n");
    textbuf.print("       screen <LABEL_4_YPOS>, \\\n");
    textbuf.print("       screen 0.0 <LABEL_4_JUST> \\\n");
    textbuf.print("       <PAGE_TEXT_COLOR_SPEC> \\\n");
    textbuf.print("       font <LABEL_4_FONT>\n\n");

    //! Multiplot command
    textbuf.print("%s", new_section);
    textbuf.print("%s", separator);
    textbuf.print("# Multiplot mode\n");
    textbuf.print("%s", separator);
    textbuf.print("set multiplot\n");

    //! Plot sections
    textbuf.print("%s", new_section);
    textbuf.print("%s", separator);
    textbuf.print("# Set defs for plot sizes and locations\n");
    textbuf.print("%s", separator);
    textbuf.print("plot_width  = <PLOT_WIDTH>\n");
    textbuf.print("plot_height = <PLOT_HEIGHT>\n");
    textbuf.print("plot_title_xpos = <PLOT_TITLE_XPOS>\n");
    textbuf.print("plot_title_ypos = <PLOT_TITLE_YPOS>\n");

    textbuf.print("\n");
    textbuf.print("x_axis_label_xpos = <X_AXIS_LABEL_XPOS_DECL>\n");
    textbuf.print("x_axis_label_ypos = <X_AXIS_LABEL_YPOS_DECL>\n");
    textbuf.print("y_axis_label_xpos = <Y_AXIS_LABEL_XPOS_DECL>\n");
    textbuf.print("y_axis_label_ypos = <Y_AXIS_LABEL_YPOS_DECL>\n");

    // -----------------
    instance_count ++;
}
Ejemplo n.º 23
0
void pp_assoc_cb(Widget w, XtPointer *client_data, XmListCallbackStruct *call_data)
{
int selection, number_selection;
char *str;
int num_associations, temp_num;
char *text, TempString[10];
int  StringLength, n, Selected, is_selected, total_start;
XmString *strlist;
int *sellist = NULL;
int selcount, i;
char display_string [200];
char trunc_external_id[49];
char trunc_comp_text[81];

/*  see if item is highlighted */

  is_selected = XmListGetSelectedPos(ppp_prov_list,&sellist,&selcount);

  if ((!is_selected) || (selcount = 0))
  {
    post_dialog (pp_provision_shell,XmDIALOG_ERROR,"Select a component to be associated");
    return;
  }
  else
  {
     XtVaGetValues (ppp_prov_list,
                    XmNitems, &strlist,
                    NULL);
     Selected = sellist[0] - 1;
     XmStringGetLtoR (strlist[Selected], XmFONTLIST_DEFAULT_TAG, &text); 
  }   

  /* Locate the exact item to be provisioned */
  for (i = 0; i <= num_pp_prov_components; i++)
  {
     strcpy (trunc_comp_text, pp_prov_components[i].comp_text);
     if (strlen(trunc_comp_text) > 40) trunc_comp_text[40] = '\0';

     strcpy (trunc_external_id, pp_prov_components[i].external_id);
     if (strlen(trunc_external_id) > 20) trunc_external_id[20] = '\0';

     sprintf (display_string, "%-10d %-40s %-20s", 
                   pp_prov_components[i].comp_id,  
                   trunc_comp_text, trunc_external_id);

     if(pp_prov_components[i].is_reqd)
     {
        strcat (display_string,"    Y    ");
     }
     else
     {
        strcat (display_string,"    N    ");
     }
 
     /* Compare the string to the value of the selected string in the listbox */
     if (strncmp (text, display_string, 70) == 0) 
     {
        gassoc_selection = i;
        break;
     } 
  }

  free (sellist);

  if ( pp_prov_components[gassoc_selection].level_code == EMF_LEVEL)
  {
     display_emf_level_selection(w);
  }
  else
  {  
     display_cmf_level_selection(w);
  }
}
Ejemplo n.º 24
0
void pp_picked_assoc_type_cb(Widget w, XtPointer *client_data, XmListCallbackStruct *call_data)
{
int selection, number_selection;
char *str;
int num_associations, temp_num;
char *text, TempString[10];
int  StringLength, n, Selected, is_selected, total_start;
XmString *strlist;
int *sellist = NULL;
int selcount, i;
char display_string [200];
char trunc_external_id[49];
char trunc_comp_text[81];

  number_selection = call_data->item_position - 1;

  XtUnmanageChild (pp_assoc_poplist_form);
  XtPopdown (pp_assoc_poplist_shell);

  /* read the amount of duplicates to be made */
  str = XmTextGetString (ppp_num_associations_txt);
  num_associations = atoi (str);
  if (num_associations == 0) 
  {
     post_dialog (pp_provision_shell, XmDIALOG_ERROR, "Please enter a valid number (1 - 999999) in the associations field.");
     XmTextSetString (ppp_num_associations_txt, "1");
     XtFree (str);
     return;
  }
  else
  {
     is_selected = XmListGetSelectedPos(ppp_prov_list,&sellist,&selcount);
     if (is_selected) 
     {
        XtVaGetValues (ppp_prov_list,
                       XmNitems, &strlist,
                       NULL);
        Selected = sellist[0] - 1;
        XmStringGetLtoR (strlist[Selected], XmFONTLIST_DEFAULT_TAG, &text); 
        StringLength = strlen(text);
        total_start = 0;
        for (n=StringLength-1; n > 0; n--)
        {
           if (text[n] == ' ')
           {
              total_start = n + 1;
              break;
           }      
        }
        if (total_start > 0) 
        {
           for (n=0; total_start + n < StringLength; n++)
           {
               TempString[n] = text[total_start+n];
           }
        }
        TempString[n] = '\0';
        temp_num = atoi (TempString);
        if (temp_num < num_associations)
        { 
           num_associations = temp_num;
           XmTextSetString (ppp_num_associations_txt, TempString);
        }
        
    }
  }

  XtFree (str);


  /* Repeat the association for the total number of associations specified */
  for (n=0; n < num_associations; n++)
  {
     /* Get the selection position of the package to be associated */
     selection = -1;

     /* Locate the exact item to be associated */
     for (i = 0; i <= num_pp_prov_components; i++)
     {
        strcpy (trunc_comp_text, pp_prov_components[i].comp_text);
        if (strlen(trunc_comp_text) > 40) trunc_comp_text[40] = '\0';

        strcpy (trunc_external_id, pp_prov_components[i].external_id);
        if (strlen(trunc_external_id) > 20) trunc_external_id[20] = '\0';

        sprintf (display_string, "%-10d %-40s %-20s", 
                      pp_prov_components[i].comp_id,  
                      trunc_comp_text, trunc_external_id);

        if(pp_prov_components[i].is_reqd)
        {
           strcat (display_string,"    Y    ");
        }
        else
        {
           strcat (display_string,"    N    ");
        }
 
        /* Compare the string to the value of the selected string in the listbox */
        if (strncmp (text, display_string, 70) == 0) 
        {
           selection = i;
           break;
        } 
     }

     if (selection != i)
     {
        printf ("No matching record could be found in the list.  Aborting...");
        pp_display_avail_components();
        return;
     }
   
     /* if this is a emf level component, write what the subscr_no and subscr_no_resets */
     if (pp_prov_components[selection].level_code == EMF_LEVEL)
     {
       pp_prov_components[selection].assigned_to = pp_elig_emfs[number_selection].subscr_no;
       pp_prov_components[selection].subscr_no_resets = pp_elig_emfs[number_selection].subscr_no_resets;
       strcpy(pp_prov_components[selection].external_id,pp_elig_emfs[number_selection].external_id);
     }
     else /* write the account number */
     {
       pp_prov_components[selection].assigned_to =  pp_elig_cmfs[number_selection].account_no;
       pp_prov_components[selection].subscr_no_resets = 0;
       strcpy(pp_prov_components[selection].external_id,pp_elig_cmfs[number_selection].external_id);
     }

  }

  /* refresh the list of components */
  pp_display_avail_components(); 
}
Ejemplo n.º 25
0
void pp_duplicate_prov_row(Widget w, XtPointer *client_data, XmListCallbackStruct *call_data)
{
int *sellist = NULL;
char *text;
int  Selected;
XmString *strlist;
int selcount;
int count;
int is_selected;
int selection;
int comp_id;
int i;
int max_allowed;
int num_there;
int comp_id_avail;
int num_duplicates;
char *str;

char display_string [200];
char trunc_external_id[49];
char trunc_comp_text[81];

  /* read the amount of duplcates to be made */
  str = XmTextGetString (ppp_num_duplications_txt);
  num_duplicates = atoi (str);
  if (num_duplicates == 0) 
  {
     post_dialog (pp_provision_shell, XmDIALOG_ERROR, "Please enter a valid number (1 - 999999) in the duplicates field.");
     XmTextSetString (ppp_num_duplications_txt, "1");
     XtFree (str);
     return;
  }
  XtFree (str);

  /* get row that is selected, only optional rows can be duplicated */
  is_selected = XmListGetSelectedPos(ppp_prov_list,&sellist,&selcount);

  selection = -1;

  if ((!is_selected) || (selcount = 0))
  {
    post_dialog (pp_provision_shell,XmDIALOG_ERROR,"Select a component to be duplicated.");
    return;
  }
  else
  {
     /* Get the value of the selected string in the listbox */
     XtVaGetValues (ppp_prov_list,
                    XmNitems, &strlist,
                    NULL);
     Selected = sellist[0] - 1;
     XmStringGetLtoR (strlist[Selected], XmFONTLIST_DEFAULT_TAG, &text);
  }

  /* Locate the exact item to be duplicated */
  for (i = 0; i < num_pp_prov_components; i++)
  {
    strcpy (trunc_comp_text, pp_prov_components[i].comp_text);
    if (strlen(trunc_comp_text) > 40) trunc_comp_text[40] = '\0';

    strcpy (trunc_external_id, pp_prov_components[i].external_id);
    if (strlen(trunc_external_id) > 20) trunc_external_id[20] = '\0';

    sprintf (display_string, "%-10d %-40s %-20s", 
                    pp_prov_components[i].comp_id,  
                    trunc_comp_text, trunc_external_id);

    if(pp_prov_components[i].is_reqd)
    {
       strcat (display_string,"    Y    ");
    }
    else
    {
      strcat (display_string,"    N    ");
    }
 
    /* Compre the string to the value of the selected string in the listbox */
    if (strncmp (text, display_string, 70) == 0) 
    {
       selection = Selected;
       break;
    } 
  }

  if (selection != Selected)
  {
     printf ("No matching record could be found in the list.  Aborting...");
     return;
  }
 
  /* Repeat the duplication of information for the amount of times that the user specified */
  for (count = 0; count < num_duplicates; count++)
  {

     if (pp_prov_components[selection].is_reqd) 
     {
        post_dialog (pp_provision_shell, XmDIALOG_ERROR, "Only Optional rows can be duplicated");
        return; 
     }
  
     /* now see if row can be duplicated */
  
     comp_id = pp_prov_components[selection].comp_id;
  
     num_there = 0;
  
     for (i = 0; i < num_pp_prov_components; i++)
     {
       if (pp_prov_components[i].comp_id == comp_id)
       {
         num_there++;
       }
     }

     /* find selection in pp_avail_components list */
     max_allowed = 0;

     for (i = 0; i < num_pp_avail_components; i++)
     {
       if (pp_avail_components[i].comp_id == comp_id)
       {
         max_allowed = pp_avail_components[i].max_allowed;
         comp_id_avail = i;
         break;
       } 
     }
   
     if (num_there == max_allowed)
     {
         post_dialog(pp_provision_shell, XmDIALOG_ERROR, "Maximum Number of Components has been provisioned");
         count = num_duplicates + 1; /* Ensure breaking out of loop */
     }
     else
     {

        /* if here, we can add one more row to  pp_prov_components */
        num_pp_prov_components++;
        pp_prov_components = (COMPONENT_PROV_ASGN_TYPE *) realloc (pp_prov_components, num_pp_prov_components * sizeof(COMPONENT_PROV_ASGN_TYPE));

        pp_prov_components[num_pp_prov_components - 1].comp_id = comp_id;
        strcpy (pp_prov_components[num_pp_prov_components - 1].comp_text, pp_avail_components[comp_id_avail].comp_text);
        pp_prov_components[num_pp_prov_components - 1].is_reqd = 0;
        pp_prov_components[num_pp_prov_components - 1].level_code =
        pp_avail_components[comp_id_avail].level_code;

#ifdef IMPLEMENT_DONT_RETAIN_ASSOCIATION
        /* Don't retain the association */
        pp_prov_components[num_pp_prov_components - 1].assigned_to = 0;
        strcpy (pp_prov_components[num_pp_prov_components - 1].external_id,
                "");
#else
        /* Retain the association */
        pp_prov_components[num_pp_prov_components - 1].assigned_to =
                               pp_prov_components[selection].assigned_to;
        strcpy (pp_prov_components[num_pp_prov_components - 1].external_id,
                pp_prov_components[selection].external_id);
        pp_prov_components[num_pp_prov_components - 1].subscr_no_resets = pp_prov_components[selection].subscr_no_resets;
#endif
     }

   }  /* end of the loop that does the duplication of information */      

/* now go redisplay the list */
   pp_display_avail_components(); 

} /* enf of duplicate */
Ejemplo n.º 26
0
void pp_display_prov_pkg_cb(Widget w, XtPointer *call_data, XmAnyCallbackStruct *client_data)
{
int package_id;
char package_desc[100];
int i;
int status;
int ret_code;
XmString temp;
int valid_date_found = 0;
char *start_date = NULL;

  if (pp_poplist_shell == NULL)
  {
     create_pp_poplist_shell(pp_provision_shell);
  }

  valid_date_found = validate_date (ppp_start_date_txt,&start_date);
  if (!valid_date_found)
  {
    return;
  }

  if (strcmp(start_date,"") == 0)
  {
    post_dialog (pp_provision_shell,XmDIALOG_ERROR,"Start Date cannot be blank.");
    return;
  }

  num_pp_elig_pkgs = 0;

  XmListDeselectAllItems (pp_poplist);
  XmListDeleteAllItems (pp_poplist);

  dbfcmd(dbproc1, "exec pp_select_eligible_pkgs @account_no = %d,",gaccount_no);
  dbfcmd(dbproc1, " @lang_code = %d, ", gGUIlanguage);
  dbfcmd(dbproc1, " @input_date = '%s' ", start_date);

  if(safe_dbexec(dbproc1,"SELECT_ELIGIBLE_PKGS", "select_eligible_pkgs")) 
    return;

  while ((status = safe_dbresults (dbproc1, "SELECT_ELIGIBLE_PKGS", "select_eligible_pkgs")) != NO_MORE_RESULTS)
  {
    if (status == FAIL) return;

    dbbind (dbproc1, 1, INTBIND, 0, &package_id);
    dbbind (dbproc1, 2, NTBSTRINGBIND, 0, package_desc);

    while ((ret_code = dbnextrow(dbproc1)) != NO_MORE_ROWS)
    {
      if(ret_code == FAIL) return;

      /* process results */

      num_pp_elig_pkgs++;
      pp_elig_pkgs = (DB_POPLIST_TYPE *) realloc (pp_elig_pkgs, num_pp_elig_pkgs * sizeof(DB_POPLIST_TYPE));

      pp_elig_pkgs[num_pp_elig_pkgs - 1].db_code = package_id;
      strcpy (pp_elig_pkgs[num_pp_elig_pkgs - 1].description,package_desc);

    }
  }

  for (i = 0; i < num_pp_elig_pkgs; i++)
  {
    temp = XmStringCreateSimple (pp_elig_pkgs[i].description);
    XmListAddItem (pp_poplist, temp, 0);
    XmStringFree (temp);
  }

 position_poplist (w,pp_poplist_shell);

  XtManageChild (pp_poplist_form);
  XtPopup (pp_poplist_shell, XtGrabNone);

}
Ejemplo n.º 27
0
void pp_provision_new_pkg(Widget w, XtPointer *client_data, XmPushButtonCallbackStruct *call_data)
{

int i;
int pkg_inst_id;
int pkg_inst_id_serv;
int comp_inst_id;
int comp_inst_id_serv;
int status;
char *start_date = NULL;
int valid_date_found;
int prov_status;
int csr_picked_one;

/* first write the package to the table as inactive, then add inactive coponent*/
/*then add each piece of component */

  if (gprov_new_package == 0)
  {
    post_dialog (pp_provision_shell, XmDIALOG_ERROR, "A package has not been selected");
    return;
  }

  if (num_pp_prov_components == 0) return;

  /* see if each comp was assigned to account or equip */
  for (i = 0; i < num_pp_prov_components; i++) 
  {
     if ((pp_prov_components[i].is_reqd) && ( pp_prov_components[i].assigned_to == 0))
      {
         post_dialog (pp_provision_shell, XmDIALOG_ERROR, "Not all required components have been associated");
         return;
      }
  }

  /* see if at least one  comp was assigned to account or equip */
  csr_picked_one = 0;
  for (i = 0; i < num_pp_prov_components; i++) 
  {
     if (pp_prov_components[i].assigned_to != 0)
      {
         csr_picked_one = 1;
         break;
      }
  }

  if (csr_picked_one == 0)
  {
         post_dialog (pp_provision_shell, XmDIALOG_ERROR, "There is nothing to SAVE");
         return;
  }

  valid_date_found = validate_date (ppp_start_date_txt,&start_date);
  if (!valid_date_found)
  {
    return;
  }

  if (strcmp(start_date,"") == 0)
  {
    post_dialog (pp_provision_shell,XmDIALOG_ERROR,"Start Date cannot be blank.");
    return;
  }

  show_busy_cursor (pp_provision_shell,TRUE);

  prov_status = pp_add_inactive_pkg (gprov_new_package, &pkg_inst_id, &pkg_inst_id_serv, start_date);

  if (prov_status != SUCCESS)
  {
     show_busy_cursor (pp_provision_shell,FALSE);
     return;
  }

  for (i = 0; i < num_pp_prov_components; i++)
  { /* if this component is optional and not assigned, skip over it */
     if ((!pp_prov_components[i].is_reqd) && 
         ( pp_prov_components[i].assigned_to == 0))
     {
      ;
     }
     else
     {
       prov_status = pp_add_component (pp_prov_components[i].comp_id, 
                                       gprov_new_package, 
                                       pkg_inst_id, 
                                       pkg_inst_id_serv, 
                                       pp_prov_components[i].level_code, 
                                       pp_prov_components[i].assigned_to, 
                                       pp_prov_components[i].subscr_no_resets,
                                       &comp_inst_id, 
                                       &comp_inst_id_serv, 
                                       start_date,0);

       if (prov_status != SUCCESS)
       {
           pp_delete_package(pkg_inst_id, pkg_inst_id_serv);
           show_busy_cursor (pp_provision_shell,FALSE);
           return;
       }

       prov_status = pp_add_component_pieces(pp_prov_components[i].comp_id,
                                             gprov_new_package,
                                             pkg_inst_id,
                                             pkg_inst_id_serv,
                                             comp_inst_id,
                                             comp_inst_id_serv, 
                                             pp_prov_components[i].level_code,
                                             pp_prov_components[i].assigned_to,
                                             pp_prov_components[i].subscr_no_resets, 
                                             start_date);
       
       if (prov_status != SUCCESS)
       {
           pp_delete_package(pkg_inst_id, pkg_inst_id_serv);
           show_busy_cursor (pp_provision_shell,FALSE);
           return;
       }

    }
  }

  status = pp_mark_pkg_active( gprov_new_package, pkg_inst_id, pkg_inst_id_serv);

  if (status != SUCCESS)
  {
     pp_delete_package(pkg_inst_id, pkg_inst_id_serv);
     show_busy_cursor (pp_provision_shell,FALSE);
     return;
  }

  show_busy_cursor (pp_provision_shell,FALSE);
  
  /* take down window and update main shell using filter criteria */
  XtUnmanageChild (pp_provision_form);
  XtPopdown (pp_provision_shell);

  product_pkgs_filter_cb(NULL,NULL,NULL);

}
Ejemplo n.º 28
0
int
get_overlap_periods_db(int seqnum)
{
   DAY_STRUCT *affected_days_2 = NULL;
   DAY_STRUCT *overlap_days = NULL;
   int from_date;
   int to_date;
   int active_dt;
   int inactive_dt;
   char *dummy = NULL;
   int ret_code,status;
   int year,month,dayofweek,dayofmonth;
   int priority_1;
   int priority_2;
   char starthhmm_1[8];
   char endhhmm_1[8];
   char rate_period_1[2];
   char starthhmm_2[8];
   char endhhmm_2[8];
   char point_class_target_1[12];
   char point_class_origin_1[12];
   tiny jurisdiction_1;
   short bill_class_1;  
   short provider_class_1;
   short type_id_usg_1;
   short rate_class_1; 
   short equip_type_code_1; 
   short equip_class_code_1;
   short class_of_service_code_1; 
   short element_id_1;
   char point_class_target_2[12];
   char point_class_origin_2[12];
   tiny jurisdiction_2;
   short bill_class_2;  
   short provider_class_2;
   short type_id_usg_2;
   short rate_class_2; 
   short equip_type_code_2; 
   short equip_class_code_2;
   short class_of_service_code_2; 
   short element_id_2;
   int  i,j,count_2;
   int  overlap_count = 0;
   XmStringTable str_list;
   char *items[1000];
   int seqnum_db;
   RATE_PERIODS_STRUCT rp_struct;
   int found, discount_factor;

      if(!validate_date(ro_from_date_text, &dummy))
      {
	return(FAILURE);
      }
      if(!strlen(dummy))
      {
	  post_dialog((Widget)ro_shell,XmDIALOG_MESSAGE,
		     "Invalid Date");
	  XmProcessTraversal(ro_from_date_text, XmTRAVERSE_CURRENT);
	  return(FAILURE);
      }

      status = get_seconds(&from_date, dummy);
      if (status == FAILURE)
         return(FALSE);
      free(dummy);

      if(!validate_date(ro_to_date_text, &dummy))
      {
	return(FAILURE);
      }
      if(!strlen(dummy))
      {
	  post_dialog((Widget)ro_shell,XmDIALOG_MESSAGE,
		     "Invalid Date");
	  XmProcessTraversal(ro_to_date_text, XmTRAVERSE_CURRENT);
	  return(FAILURE);
      }

      status = get_seconds(&to_date, dummy);
      if (status == FAILURE)
         return(FALSE);
      free(dummy);

      /* get affected days and priority by the selected row */
      get_affected_days_db(seqnum, 
			   &affected_days, 
			   &affected_days_count,
			   starthhmm_1,
			   endhhmm_1,
			   &priority_1,
			   rate_period_1,
			   point_class_target_1,
			   point_class_origin_1,
			   &jurisdiction_1,
			   &bill_class_1,
			   &provider_class_1,
			   &type_id_usg_1,&rate_class_1,&equip_type_code_1,
                           &equip_class_code_1,&class_of_service_code_1,
                           &element_id_1);

      /* get all rows from RATE_PERIODS table to see the
      ** overlapping days 
      */
      memset((char *) &rp_struct, 0, sizeof(RATE_PERIODS_STRUCT));
      dbcmd(dbproc1, " select seqnum,rate_period,discount_factor,");
      dbcmd(dbproc1, " starthhmm,endhhmm,year,month,dayofmonth,");
      dbcmd(dbproc1, " dayofweek,");
      dbcmd(dbproc1," active_dt,");
      dbcmd(dbproc1," inactive_dt,");
      dbcmd(dbproc1, " priority,point_class_target, ");
      dbcmd(dbproc1, " point_class_origin,jurisdiction, ");
      dbcmd(dbproc1, " bill_class,provider_class, type_id_usg, ");
      dbcmd(dbproc1, " rate_class,equip_type_code, equip_class_code, ");
      dbcmd(dbproc1, " class_of_service_code,element_id ");
      dbcmd(dbproc1, " from RATE_PERIODS ");
      dbfcmd(dbproc1, " where seqnum != %d ",seqnum);

      if(safe_dbselect(dbproc1, "RATE_PERIODS", "get_overlap_periods_db"))
        return(FAILURE);

      dbbind(dbproc1,1,INTBIND,0,&seqnum_db); 
      dbbind(dbproc1,2,NTBSTRINGBIND,256,
		      rp_struct.rate_period);
      dbbind(dbproc1,3,INTBIND,0, &discount_factor);
      dbbind(dbproc1,4,NTBSTRINGBIND,256, starthhmm_2);
      dbbind(dbproc1,5,NTBSTRINGBIND,256, endhhmm_2);
      dbbind(dbproc1,6,NTBSTRINGBIND,256,
		      rp_struct.year);
      dbbind(dbproc1,7,NTBSTRINGBIND,256,
		      rp_struct.month);
      dbbind(dbproc1,8,NTBSTRINGBIND,256,
		      rp_struct.dayofmonth);
      dbbind(dbproc1,9,NTBSTRINGBIND,256,
		     rp_struct.dayofweek);
      dbbind(dbproc1,10,ARB_TYPE_DATELONG,0,
		     &(rp_struct.arb_active_dt));
      dbbind(dbproc1,11,ARB_TYPE_DATELONG,0,
		     &(rp_struct.arb_inactive_dt));
      dbbind(dbproc1,12,INTBIND,0,
		     &priority_2);
      dbbind(dbproc1,13,NTBSTRINGBIND,256,
		     point_class_target_2);
      dbbind(dbproc1,14,NTBSTRINGBIND,256,
		     point_class_origin_2);
      dbbind(dbproc1,15,TINYBIND,0,
		     &jurisdiction_2);
      dbbind(dbproc1,16,SMALLBIND,0,
		     &bill_class_2);
      dbbind(dbproc1,17,SMALLBIND,0,
		     &provider_class_2);
      dbbind(dbproc1,18,SMALLBIND,0,
		     &type_id_usg_2);
      dbbind(dbproc1,19,SMALLBIND,0,
		     &rate_class_2);
      dbbind(dbproc1,20,SMALLBIND,0,
		     &equip_type_code_2);
      dbbind(dbproc1,21,SMALLBIND,0,
		     &equip_class_code_2);
      dbbind(dbproc1,22,SMALLBIND,0,
		     &class_of_service_code_2);
      dbbind(dbproc1,23,SMALLBIND,0,
		     &element_id_2);

      while((ret_code = dbnextrow(dbproc1)) == REG_ROW)
      {
        Arbdate_to_date_time(&(rp_struct.arb_active_dt),
          rp_struct.active_dt, NULL);
        Arbdate_to_date_time(&(rp_struct.arb_inactive_dt),
          rp_struct.inactive_dt, NULL);
        get_seconds_arbdate(&active_dt, &(rp_struct.arb_active_dt));
        get_seconds_arbdate(&inactive_dt, &(rp_struct.arb_inactive_dt));

        /* If the priority are not the same, it's not overlapping */
        if(priority_1 != priority_2)
  	  continue;
        if(jurisdiction_1 != jurisdiction_2 && 
          jurisdiction_1 != 0 && jurisdiction_2 != 0)
	  continue;
        if(bill_class_1 != bill_class_2 &&
          bill_class_1 != 0 && bill_class_2 != 0)
	  continue;
        if(type_id_usg_1 != type_id_usg_2 &&
          type_id_usg_1 != 0 && type_id_usg_2 != 0)
  	  continue;
        if(provider_class_1 != provider_class_2 &&
           provider_class_1 != 0 && provider_class_2 != 0)
          continue;
        if(strcmp(point_class_target_1,point_class_target_2) != 0 &&
          atoi(point_class_target_1) != 0 && atoi(point_class_target_2) != 0)
          continue;
        if(strcmp(point_class_origin_1,point_class_origin_2) != 0 &&
          atoi(point_class_origin_1) != 0 && atoi(point_class_origin_2) != 0)
          continue;
        if(rate_class_1 != rate_class_2 &&
           rate_class_1 != 0 && rate_class_2 != 0)
          continue;
        if(equip_type_code_1 != equip_type_code_2 &&
           equip_type_code_1 != 0 && equip_type_code_2 != 0)
          continue;
        if(equip_class_code_1 != equip_class_code_2 &&
           equip_class_code_1 != 0 && equip_class_code_2 != 0)
          continue;
        if(class_of_service_code_1 != class_of_service_code_2 &&
           class_of_service_code_1 != 0 && class_of_service_code_2 != 0)
          continue;
        if(element_id_1 != element_id_2 &&
           element_id_1 != 0 && element_id_2 != 0)
          continue;
        if(strcmp(starthhmm_1,endhhmm_2) >= 0 ||
          strcmp(starthhmm_2,endhhmm_1) >= 0)
          continue;

        from_date = (from_date > active_dt)?from_date:active_dt;
        if(inactive_dt != 0)
          to_date = (inactive_dt > to_date)?to_date:inactive_dt;
        year = atoi(rp_struct.year);
        month = atoi(rp_struct.month);
        dayofmonth = atoi(rp_struct.dayofmonth);
        dayofweek = atoi(rp_struct.dayofweek);
        calculate_affected_days(year,month,dayofmonth,dayofweek,
				    from_date,to_date, 
				    &affected_days_2, &count_2);
        found = 0;
        for(i = 0; i < affected_days_count && !found; i++)
        {
          for(j = 0; j < count_2 && !found; j++)
          {
    	    if(strcmp(affected_days[i].day_string,
			  affected_days_2[j].day_string) == 0)
	    {
	      overlap_count++;
	      ro_overlap_seqnum_array = 
	        (int *)realloc(ro_overlap_seqnum_array,
	        (overlap_count) * sizeof(int));
	      ro_overlap_seqnum_array[overlap_count-1] = seqnum_db;
	      sprintf(rp_struct.seqnum, "%d", seqnum_db);

	      sprintf(rp_struct.discount_factor,"%.3f",
		       discount_factor/1000.0);

	      strncpy(rp_struct.starthhmm,starthhmm_2,2);
		       rp_struct.starthhmm[2] = '\0';
	      strcat(rp_struct.starthhmm,":");
	      strcat(rp_struct.starthhmm,&starthhmm_2[2]);

	      strncpy(rp_struct.endhhmm,endhhmm_2,2);
		       rp_struct.endhhmm[2] = '\0';
	      strcat(rp_struct.endhhmm,":");
	      strcat(rp_struct.endhhmm,&endhhmm_2[2]);

              format_overlap_period(scratch, &rp_struct);
              items[overlap_count-1] = (char *)malloc(strlen(scratch) + 1);
	      strcpy(items[overlap_count-1], scratch);
	      found = 1;
	    }
          }
        }
        free(affected_days_2);
      }

      if(check_dbresults(dbproc1, ret_code,
	"RATE_PERIODS",
	"get_overlap_periods_db"))
        return(FAILURE);

      XmTextSetString(ro_overlap_days_text,"");

      if (overlap_count > 0) 
      {
        str_list = (XmStringTable)XtMalloc(overlap_count * sizeof (XmString*));
        for (i = 0; i < overlap_count; i++)
	{
	  str_list[i] = XmStringCreateSimple(items[i]);
	  free(items[i]);
	}

        XtVaSetValues(ro_overlap_summlist, 
	     XmNitemCount, overlap_count, 
	     XmNitems, str_list, NULL);

       for (i = 0; i < overlap_count; i++)
          XmStringFree(str_list[i]);
       XtFree((char *)str_list);
     } /* we should get a list first then manage the poplist, need a fix */
     else if (overlap_count == 0) 
     {
          XtVaSetValues(ro_overlap_summlist, 
	     XmNitemCount, 0, 
	     XmNitems, NULL, NULL);
          XmTextSetString(ro_overlap_days_text,"No overlapping in the overlapping range");
     }

     return (SUCCESS);
}
Ejemplo n.º 29
0
int
get_affected_days_db(int seqnum, 
		     DAY_STRUCT **affected_days, 
		     int *count,
		     char *starthhmm,
		     char *endhhmm,
		     int *priority,
		     char *rate_period,
		     char *point_class_target,
		     char *point_class_origin,
		     tiny *jurisdiction,
		     short *bill_class,
		     short *provider_class,
		     short *type_id_usg,
                     short *rate_class,
                     short *equip_type_code,
                     short *equip_class_code,
                     short *class_of_service_code,
                     short *element_id)
{
   int from_date;
   int to_date;
   int active_dt;
   int inactive_dt;
   Arb_date arb_active_dt;
   Arb_date arb_inactive_dt;
   char *dummy = NULL;
   int ret_code,status;
   int year,month,dayofweek,dayofmonth;

      if(!validate_date(ro_from_date_text, &dummy))
      {
	return(FAILURE);
      }
      if(!strlen(dummy))
      {
	post_dialog((Widget)ro_shell,XmDIALOG_MESSAGE,
	     "Invalid Date");
	XmProcessTraversal(ro_from_date_text, XmTRAVERSE_CURRENT);
	return(FAILURE);
      }

      status = get_seconds(&from_date, dummy);
      if (status == FAILURE)
         return(FALSE);
      free(dummy);

      if(!validate_date(ro_to_date_text, &dummy))
      {
	return(FAILURE);
      }
      if(!strlen(dummy))
      {
	post_dialog((Widget)ro_shell,XmDIALOG_MESSAGE,
	     "Invalid Date");
	XmProcessTraversal(ro_from_date_text, XmTRAVERSE_CURRENT);
	return(FAILURE);
      }

      status = get_seconds(&to_date, dummy);
      if (status == FAILURE)
         return(FALSE);
      free(dummy);

      dbcmd(dbproc1, " select year, month, dayofmonth,");
      dbcmd(dbproc1, " dayofweek, starthhmm, endhhmm, ");
      dbcmd(dbproc1, " priority, ");
      dbcmd(dbproc1, " active_dt, ");
      dbcmd(dbproc1, " inactive_dt, ");
      dbcmd(dbproc1, " rate_period,point_class_target, ");
      dbcmd(dbproc1, " point_class_origin,jurisdiction, ");
      dbcmd(dbproc1, " bill_class,provider_class,type_id_usg,rate_class, ");
      dbcmd(dbproc1, " equip_type_code,equip_class_code, ");
      dbcmd(dbproc1, " class_of_service_code,element_id ");
      dbcmd(dbproc1, " from RATE_PERIODS ");
      dbfcmd(dbproc1, " where seqnum = %d ",seqnum);

      if(safe_dbselect(dbproc1, "RATE_PERIODS", "get_affected_days_db"))
	return(FAILURE);

      dbbind(dbproc1,1,INTBIND,0,&year);
      dbbind(dbproc1,2,INTBIND,0,&month);
      dbbind(dbproc1,3,INTBIND,0,&dayofmonth);
      dbbind(dbproc1,4,INTBIND,0,&dayofweek);
      dbbind(dbproc1,5,NTBSTRINGBIND,256,starthhmm);
      dbbind(dbproc1,6,NTBSTRINGBIND,256,endhhmm);
      dbbind(dbproc1,7,INTBIND,0,priority);
      dbbind(dbproc1,8,ARB_TYPE_DATELONG,0,&arb_active_dt);
      dbbind(dbproc1,9,ARB_TYPE_DATELONG,0,&arb_inactive_dt);
      dbbind(dbproc1,10,NTBSTRINGBIND,256,rate_period);
      dbbind(dbproc1,11,NTBSTRINGBIND,256,point_class_target);
      dbbind(dbproc1,12,NTBSTRINGBIND,256,point_class_origin);
      dbbind(dbproc1,13,TINYBIND,0,jurisdiction);
      dbbind(dbproc1,14,SMALLBIND,0,bill_class);
      dbbind(dbproc1,15,SMALLBIND,0,provider_class);
      dbbind(dbproc1,16,SMALLBIND,0,type_id_usg);
      dbbind(dbproc1,17,SMALLBIND,0,rate_class);
      dbbind(dbproc1,18,SMALLBIND,0,equip_type_code);
      dbbind(dbproc1,19,SMALLBIND,0,equip_class_code);
      dbbind(dbproc1,20,SMALLBIND,0,class_of_service_code);
      dbbind(dbproc1,21,SMALLBIND,0,element_id);

      while((ret_code = dbnextrow(dbproc1)) == REG_ROW)
      {
        get_seconds_arbdate(&active_dt, &arb_active_dt);
        get_seconds_arbdate(&inactive_dt, &arb_inactive_dt);
        from_date = (from_date > active_dt)?from_date:active_dt;
        if(inactive_dt != 0)
          to_date = (inactive_dt > to_date)?to_date:inactive_dt;
        calculate_affected_days(year,month,dayofmonth,dayofweek,
			    from_date,to_date, 
			    affected_days, count);
      }

      if(check_dbresults(dbproc1, ret_code,
	"RATE_PERIODS",
        "get_affected_days_db"))
	return(FAILURE);

      return (SUCCESS);
}
Ejemplo n.º 30
0
int
update_rate_usage_or_db(RATE_USAGE_OVERRIDES_STRUCT *rate_usage_or_entered, 
		     RATE_USAGE_BANDS_OVERRIDES_STRUCT *rate_usage_or_bands_entered,
		     int num_of_bands_entered,
		     int seqnum)
{
    int ret_code;
    char   fixed_charge_amt[19];
    int    i,unit_rate, add_fixed_amt;


    /* convert money string to money field in proper implied decimal place */

    money_str_to_arb_numeric(fixed_charge_amt,
       rate_usage_or_entered->fixed_charge_amt,
       (short)atoi(rate_usage_or_entered->currency_code));

    if(rate_str_to_int_new(&unit_rate,
       rate_usage_or_entered->add_unit_rate,
       (short)atoi(rate_usage_or_entered->currency_code),
       (short)atoi(rate_usage_or_entered->add_implied_decimal)) == FAILURE)
    {
      sprintf(scratch, "Add. Unit Rate: %s would cause an integer overflow",
        rate_usage_or_entered->add_unit_rate);
      post_dialog(rate_usage_or_shell,XmDIALOG_MESSAGE,
               scratch);
      return FAILURE;
    }

    if(rate_str_to_int_new(&add_fixed_amt,
       rate_usage_or_entered->add_fixed_amt,
       (short)atoi(rate_usage_or_entered->currency_code),
       (short)atoi(rate_usage_or_entered->add_implied_decimal)) == FAILURE)
    {
      sprintf(scratch, "Add. Fixed Amt: %s would cause an integer overflow",
        rate_usage_or_entered->add_fixed_amt);
      post_dialog(rate_usage_or_shell,XmDIALOG_MESSAGE,
               scratch);
      return FAILURE;
    }

    dbcancel(dbproc1);
    if(begin_tran(dbproc1,"UPDATE_RATE_USAGE_OVERRIDES") == FAILURE)
	    return(FAILURE);

    dbcmd(dbproc1," update RATE_USAGE_OVERRIDES ");
    dbfcmd(dbproc1," set corridor_plan_id = %d, ", 
      atoi(rate_usage_or_entered->corridor_plan_id));
    dbfcmd(dbproc1," rate_class = %d, ", 
      atoi(rate_usage_or_entered->rate_class));
    dbfcmd(dbproc1," jurisdiction = %d, ", 
      atoi(rate_usage_or_entered->jurisdiction));
    dbfcmd(dbproc1," rate_units_type = %d, ", 
      atoi(rate_usage_or_entered->rate_units_type));
    dbfcmd(dbproc1," type_id_usg = %d, ", 
      atoi(rate_usage_or_entered->type_id_usg));
    dbfcmd(dbproc1," distance_band_id = %d, ", 
      atoi(rate_usage_or_entered->distance_band_id));
    dbfcmd(dbproc1," bill_class = %d, ", 
      atoi(rate_usage_or_entered->bill_class));
    dbfcmd(dbproc1," element_id = %d, ", 
      atoi(rate_usage_or_entered->element_id));
    dbfcmd(dbproc1," equip_type_code = %d, ", 
      atoi(rate_usage_or_entered->equip_type));
    dbfcmd(dbproc1," equip_class_code = %d, ", 
      atoi(rate_usage_or_entered->equip_class));
    dbfcmd(dbproc1," class_of_service_code = %d, ", 
      atoi(rate_usage_or_entered->equip_class_of_service));
    dbfcmd(dbproc1," units_indicator = %d, ", 
      atoi(rate_usage_or_entered->units_indicator));
    dbfcmd(dbproc1," provider_class = %d, ", 
      atoi(rate_usage_or_entered->provider_class));
    dbfcmd(dbproc1," rate_period = '%s', ", 
      rate_usage_or_entered->rate_period);
    dbfcmd(dbproc1," currency_code = %d, ", 
      atoi(rate_usage_or_entered->currency_code));
    dbfcmd(dbproc1," fixed_charge_amt = %s, ", fixed_charge_amt);
    dbfcmd(dbproc1," incremental_bands = %s, ", 
      rate_usage_or_entered->incremental_bands);
    dbfcmd(dbproc1," add_unit_rate = %d, ", unit_rate);
    dbfcmd(dbproc1," add_fixed_amt = %d, ", add_fixed_amt);
    dbfcmd(dbproc1," add_implied_decimal = %d, ",
      atoi(rate_usage_or_entered->add_implied_decimal));
    dbfcmd(dbproc1," chg_dt = %s, ", arb_server_getdate());
    dbfcmd(dbproc1," chg_who = %s, ", arb_server_username());

    date_time_to_Arbdate(rate_usage_or_entered->active_dt,
      rate_usage_or_entered->active_time,
      &(rate_usage_or_entered->arb_active_dt));
    dbfcmd(dbproc1," active_dt = %t, ",
      &(rate_usage_or_entered->arb_active_dt));

    date_time_to_Arbdate(rate_usage_or_entered->inactive_dt,
      rate_usage_or_entered->inactive_time,
      &(rate_usage_or_entered->arb_inactive_dt));
    if(Arbdate_is_null(&(rate_usage_or_entered->arb_inactive_dt)))
      dbcmd(dbproc1," inactive_dt = NULL ");
    else
      dbfcmd(dbproc1," inactive_dt = %t ",
        &(rate_usage_or_entered->arb_inactive_dt));

    dbfcmd(dbproc1," where seqnum = %d ",seqnum);

    if(safe_dbupdate(dbproc1, "RATE_USAGE_OVERRIDES",
			       "update_rate_usage_or_db"))
    {
      (void)rollback_tran(dbproc1, "update_rate_usage_or_db");
       dbcancel(dbproc1);
      return(FAILURE);
    }

    dbcmd(dbproc1," delete RATE_USAGE_BANDS_OVERRIDES ");
    dbfcmd(dbproc1," where seqnum = %d ",seqnum);

    if(safe_dbupdate(dbproc1, "RATE_USAGE_OVERRIDES",
			       "update_rate_usage_or_db"))
    {
      (void)rollback_tran(dbproc1, "update_rate_usage_or_db");
       dbcancel(dbproc1);
      return(FAILURE);
    }
    
    for(i = 0; i < num_of_bands_entered; i++)
    {
      if(rate_str_to_int_new(&unit_rate,
         rate_usage_or_bands_entered[i].unit_rate,
         (short)atoi(rate_usage_or_entered->currency_code),
         (short)atoi(rate_usage_or_entered->add_implied_decimal)) == FAILURE)
      {
        (void)rollback_tran(dbproc1, "rate_usage_or_save_db");
        dbcancel(dbproc1);

        sprintf(scratch,
          "Band %d Unit Rate: %s would cause an integer overflow",
          i+1,
          rate_usage_or_bands_entered[i].unit_rate);
        post_dialog(rate_usage_or_shell,XmDIALOG_MESSAGE,
                  scratch);
        return FAILURE;
      }

      dbcmd(dbproc1,"insert into RATE_USAGE_BANDS_OVERRIDES(seqnum,rateband,");
      dbcmd(dbproc1,"num_units,unit_rate)");
      dbfcmd(dbproc1,"values(%d,%d,%s,%d)",
      seqnum, i + 1, rate_usage_or_bands_entered[i].num_units,unit_rate);

    
      if(safe_dbupdate(dbproc1, "RATE_USAGE_OVERRIDES",
			       "update_rate_usage_or_db"))
      {
        (void)rollback_tran(dbproc1, "update_rate_usage_or_db");
         dbcancel(dbproc1);
        return(FAILURE);
      }
    }

   			          /* ************************ */
    (void)commit_tran(dbproc1);   /* ** COMMIT TRANSACTION ** */
				  /* ************************ */

    /* SUCCESS */
    return(SUCCESS);
}