Exemple #1
0
void CExtIdDetail::OnKillfocusEndDateEdit() 
{
	UpdateData(TRUE);
	int valid = ABP_FAILURE;

	valid = validate_date( m_eEndDate, "End Date" ); 

	// check to see if from time < to time
	if( valid == ABP_SUCCESS )
	{
		COleDateTime	CheckStartTime;
		COleDateTime	CheckEndTime;
		CString			sStartDate;
		CString			sEndDate;

		m_eStartDate.GetWindowText(sStartDate);
		m_eEndDate.GetWindowText(sEndDate);

		if( !sStartDate.IsEmpty() && !sEndDate.IsEmpty() )
		{
			// parse the date string.....
			CheckStartTime.ParseDateTime( sStartDate, VAR_DATEVALUEONLY, LANG_USER_DEFAULT );
			CheckEndTime.ParseDateTime( sEndDate, VAR_DATEVALUEONLY, LANG_USER_DEFAULT );

			if( CheckStartTime > CheckEndTime )
			{
				Beep( 400, 100 );
				CGuiMsg::GuiMessage( GUIMSG_END_DATE_AFTER_START_DATE );
				m_eEndDate.SetWindowText("");
				UpdateData(FALSE);
			}
		}
	}

}
Exemple #2
0
// after focus moves...validate date for the ToDate CString var
void CNotesDlg::OnKillfocusNoteDateToTxt() 
{
   UpdateData(TRUE);

   int valid = ABP_FAILURE;

   valid = validate_date( m_sDateTo, "ToDate" );

   // check to see if from time < to time
   if( valid == ABP_SUCCESS )
   {
      COleDateTime CheckFromTime;
      COleDateTime CheckToTime;

      if( !m_sDateFrom.IsEmpty() && !m_sDateTo.IsEmpty() )
	  {
	     // parse the date string.....
	     CheckFromTime.ParseDateTime( m_sDateFrom, VAR_DATEVALUEONLY, LCID_ENGLISH );
	     CheckToTime.ParseDateTime( m_sDateTo, VAR_DATEVALUEONLY, LCID_ENGLISH );

	     if( CheckFromTime > CheckToTime )
	     {
		    Beep( 400, 100 );
	        CGuiMsg::GuiMessage( GUIMSG_DATE_TO_BEFORE_FROM_DATE );
	        m_sDateTo.Empty();
			UpdateData(FALSE);
	     }
	  }
   }
}
Exemple #3
0
/*
 * Dive trip directory, name is 'nn-alphabetic[~hex]'
 */
static int dive_trip_directory(const char *root, const char *name)
{
	int yyyy = -1, mm = -1, dd = -1;

	if (sscanf(root, "%d/%d", &yyyy, &mm) != 2)
		return GIT_WALK_SKIP;
	dd = atoi(name);
	if (!validate_date(yyyy, mm, dd))
		return GIT_WALK_SKIP;
	finish_active_trip();
	active_trip = create_new_trip(yyyy, mm, dd);
	return GIT_WALK_OK;
}
Exemple #4
0
int parse_date(const char *str, struct tm *tim) {
	char *end;
	/* day */
	tim->tm_mday = strtol(str, &end, 10);
	if(end != str && *end) {
		str = end + 1;
		/* month */
		tim->tm_mon = strtol(str, &end, 10);
		if(end != str && *end) {
			str = end + 1;
			/* year */
			tim->tm_year = strtol(str, &end, 10);
			if(end != str) {
				tim->tm_mon--;
				tim->tm_year -= 1900;

				return validate_date(tim);
			}
		}
	}
	return 0;
}
Exemple #5
0
/*
 * Dive directory, name is [[yyyy-]mm-]nn-ddd-hh:mm:ss[~hex],
 * and 'timeoff' points to what should be the time part of
 * the name (the first digit of the hour).
 *
 * The root path will be of the form yyyy/mm[/tripdir],
 */
static int dive_directory(const char *root, const char *name, int timeoff)
{
	int yyyy = -1, mm = -1, dd = -1;
	int h, m, s;
	int mday_off, month_off, year_off;
	struct tm tm;

	/* Skip the '-' before the time */
	mday_off = timeoff;
	if (!mday_off || name[--mday_off] != '-')
		return GIT_WALK_SKIP;
	/* Skip the day name */
	while (mday_off > 0 && name[--mday_off] != '-')
		/* nothing */;

	mday_off = mday_off - 2;
	month_off = mday_off - 3;
	year_off = month_off - 5;
	if (mday_off < 0)
		return GIT_WALK_SKIP;

	/* Get the time of day */
	if (sscanf(name+timeoff, "%d:%d:%d", &h, &m, &s) != 3)
		return GIT_WALK_SKIP;
	if (!validate_time(h, m, s))
		return GIT_WALK_SKIP;

	/*
	 * Using the "git_tree_walk()" interface is simple, but
	 * it kind of sucks as an interface because there is
	 * no sane way to pass the hierarchy to the callbacks.
	 * The "payload" is a fixed one-time thing: we'd like
	 * the "current trip" to be passed down to the dives
	 * that get parsed under that trip, but we can't.
	 *
	 * So "active_trip" is not the trip that is in the hierarchy
	 * _above_ us, it's just the trip that was _before_ us. But
	 * if a dive is not in a trip at all, we can't tell.
	 *
	 * We could just do a better walker that passes the
	 * return value around, but we hack around this by
	 * instead looking at the one hierarchical piece of
	 * data we have: the pathname to the current entry.
	 *
	 * This is pretty hacky. The magic '8' is the length
	 * of a pathname of the form 'yyyy/mm/'.
	 */
	if (strlen(root) == 8)
		finish_active_trip();

	/*
	 * Get the date. The day of the month is in the dive directory
	 * name, the year and month might be in the path leading up
	 * to it.
	 */
	dd = atoi(name + mday_off);
	if (year_off < 0) {
		if (sscanf(root, "%d/%d", &yyyy, &mm) != 2)
			return GIT_WALK_SKIP;
	} else
		yyyy = atoi(name + year_off);
	if (month_off >= 0)
		mm = atoi(name + month_off);

	if (!validate_date(yyyy, mm, dd))
		return GIT_WALK_SKIP;

	/* Ok, close enough. We've gotten sufficient information */
	memset(&tm, 0, sizeof(tm));
	tm.tm_hour = h;
	tm.tm_min = m;
	tm.tm_sec = s;
	tm.tm_year = yyyy - 1900;
	tm.tm_mon = mm-1;
	tm.tm_mday = dd;

	finish_active_dive();
	active_dive = create_new_dive(utc_mktime(&tm));
	return GIT_WALK_OK;
}
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);
  }
}
Exemple #7
0
// after focus moves...validate date for the FromDate CString var
void CNotesDlg::OnKillfocusNoteDateFromTxt(){ UpdateData(TRUE); validate_date( m_sDateFrom, "FromDate" ); }
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);
}
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);
}
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);

}
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);

}
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);
}
Exemple #13
0
void CExtIdDetail::OnKillfocusStartDateEdit() 
{
	UpdateData(TRUE);
	validate_date( m_eStartDate, "Start Date" ); 
}
Exemple #14
0
void
filter_notes()
{
   char external_subscr_no[EXTERNAL_ID_LEN];
   char note_type[20];
   char from_date[DATE_LEN];
   char to_date[DATE_LEN];
   char user_id[CHG_WHO_LEN];
   char *str;
   char *check_to_date = NULL;
   char *check_from_date = NULL;
   int  status;

   status = validate_date (notes_filter_from_txt,&check_from_date);
   if(check_from_date != NULL)
     free (check_from_date);

   if (!status)
   {
     return;
   }

   status = validate_date (notes_filter_to_txt,&check_to_date);

   if(check_to_date != NULL)
     free (check_to_date);

   if (!status)
   {
     return;
   }

   memset (filter_str, '\0', sizeof(filter_str));

   str = XmTextGetString(notes_filter_type_txt);
   sprintf(note_type, "%s", str);
   if(str != NULL)
     XtFree (str);

   status = validate_filter_note_type_entry(note_type);
   if (status != SUCCESS)
   {
     return;
   }

   str = XmTextGetString(notes_filter_equip_txt);
   sprintf(external_subscr_no, "%s", str);
   if(str != NULL)
     XtFree (str);

   status = validate_note_subscr_no_entry(external_subscr_no,
                                          notes_shell,
                                          notes_filter_equip_txt);
   if (status != SUCCESS)
   {
     return;
   }

   str = XmTextGetString(notes_filter_from_txt);
   sprintf(from_date, "%s", str);
   if(str != NULL)
     XtFree (str);

   str = XmTextGetString(notes_filter_to_txt);
   sprintf(to_date, "%s", str);
   if(str != NULL)
     XtFree (str);

   str = XmTextGetString(notes_filter_user_txt);
   sprintf(user_id, "%s", str);
   if(str != NULL)
     XtFree (str);

   /* filter_str will always start with "and" since there is already a 
    * where clause in get_notes for the account_no.
    */
   if (strlen(external_subscr_no) > 0)
     {
       char   *tmp_str;
       tmp_str = convert_to_db_string(external_subscr_no);
       sprintf (filter_str, " and equip_external_id = '%s' ",
		tmp_str);
      
       free(tmp_str);
     }

   if (strlen(note_type) > 0)
      sprintf (filter_str, "%s and note_code = '%s'", filter_str, note_type); 
   if (strlen(user_id) > 0)
      sprintf (filter_str, "%s and chg_who = '%s'", filter_str, user_id);

   /* If both dates are entered, get notes between and including those dates
    * independent of the order, ie (from < to) OR (to < from).
    * If only the from date is entered, get all notes from that date forward.
    * If only the to date is entered, get all notes up to and including that
    * date.
    */
   if ((strlen(from_date) > 0) && (strlen(to_date) > 0))
   {
      /* from date < to_date */
      sprintf (filter_str, "%s and ((chg_date between '%s' and '%s 23:59:59')",
         filter_str, from_date, to_date);

      /* to_date < from_date */
      sprintf (filter_str, "%s or (chg_date between '%s 23:59:59' and '%s'))",
         filter_str, from_date, to_date);
   }
   else if (strlen(from_date) > 0)
      sprintf (filter_str, "%s and chg_date >= '%s'", filter_str, from_date);
   else if (strlen(to_date) > 0)
      sprintf (filter_str, "%s and chg_date <= '%s 23:59:59'",
         filter_str, to_date);

   get_notes();
}