Niedermayer.ca
Published on Niedermayer.ca (https://niedermayer.ca)

Home > User Management System (UMS) -- Detailed System Design > Procedure Model > CGI Procedures

CGI Procedures

user/validate.cgi

Procedure Model

Type:    (  )Web Page              ( X )CGI Script           (  )Shared Library      (  )System API

Name: user/validate.cgi

Assigned to:

Reference:

Description

This script takes the information from the user/apply.html form, verifies that all required data is present before attempting to create a new user request.

Implementation Skills

PERL, CGI, SQL

Parameter List

Membership_Class
User_FirstName
User_LastName
User_Initial
User_Salutation
User_Organization
User_Title
User_StreetAddress1
User_StreetAddress2
User_City
User_Province
User_Country
User_PostalCode
User_HomePhone
User_WorkPhone
User_Age
User_InitialPassword
Member_UserName (the requested username by the prospective member)
Upgrade_toPPP (check box: True=”1”)
Upgrade_toDB (check box: True=”1”)
Upgrade_toVirtualDomain (check box: True=”1”)
Upgrade_toSSL (check box: True=”1”)
Upgrade_toListserver (check box: True=”1”)
Upgrade_toAliases (user enters a number)
Upgrade_Quota1 (check box: True=”5”)
Upgrade_Quota2 (check box: True=”5”)
Upgrade_Quota3 (check box: True=”5”)
 

Called By:

user/apply.html

Can Call:

lib/uname_generate.pl
lib/uname_test.pl
lib/pw_check.pl

Function Description

  1. The script verifies that the user has supplied all required values. The procedure model for the user/apply.html page lists these requirements. They include: Membership_Class, User_FirstName, User_LastName, User_Salutation , User_StreetAddress1, User_City, User_Province, User_Country, User_PostalCode, User_Age, User_InitialPassword.
  2. If Membership_Class is “Institution” or “Individual”, the following additional fields must also be gathered: Member_UserName, Upgrade_toPPP, Upgrade_toDB, Upgrade_toVirtualDomain, Upgrade_toSSL, Upgrade_toListserver, Upgrade_toAliases, Upgrade_Quota1, Upgrade_Quota2, Upgrade_Quota3.
  3. If Membership_Class is “Institution” User_Organization, and User_Title are also required fields.
  4. If Membership_Class is “Registered”, then the library function “uname_generate.pl” is called to return the next sequential userid. Otherwise, the “uname_test.pl” is called to verify that the value supplied in the Member_UserName field is unique and valid. If uname_generate.pl or uname_test.pl returns an error, the script returns with error condition 1 below.
  5. The value of User_InitialPassword is tested with a call to “pwcheck.pl”. If the test fails, the script returns with error condition 1 below.
  6. The values from the form are inserted as a new record in the Database User table. In addition, the following additional fields are populated as follows:
    User_IsActive = “Pending”
    User_Since = current timestamp
    User_IsMember = “Y” if Membership_Class is “Individual” or “Institution”, otherwise User_Is_Member = “N”
    User_EnteredBy = Web Server’s ‘REMOTE_USER’ value
    Retrieve the value of User_Number from the new record
  7. If Membership_Class is ‘Registered’, proceed to step 14 below.
  8. If Membership_Class is not “Registered”, insert a new record in the Member table with the following values:
    User_Number = the User_Number of the just created User record in the User table
    Member_Type = ‘Inst’ or ‘Ind” depending on whether Membership_Class is ‘Institution’ or ‘Individual’ respectively
    Member_UserName = User_UserName
    Member_Since = User_Member_Since
    Member_EnteredBy = the Web Server’s REMOTE_USER value
  9. If Membership_Class is not ‘Registered’ and any of Upgrade_toPPP, Upgrade_toDB, Upgrade_toVirtualDomain, Upgrade_toSSL, Upgrade_toListserver, Upgrade_toAliases, Upgrade_Quota1, Upgrade_Quota2, Upgrade_Quota3 are True or not equal to ‘0’, create a new record in the Upgrade_Request table inserting these values into the record.
  10. Unless Membership_Class is ‘Registered’, insert a new record into the Invoice table with the following values:
    Invoice_Date is the current Timestamp
    Invoice_Medium = ‘Web’
    Invoice_EnteredBy = REMOTE_USER
    and retrieve the Invoice_Number of this new record
  11. Insert a new record in the Invoice_Item table with the current Invoice_Number and User_Number. If Membership_Class is ‘Institution’ then the Item_Description should say ‘Institutional Annual Membership’ and the Item_Amount is the value of the Sys_Inst_Mem_Price. Otherwise, the Item_Description should say ‘Individual Annual Membership’ and the Item_Amount is the value of the Sys_Ind_Mem_Price.
  12. For each of the upgrade options listed in step 9 above where the option is not 0 or is “False”, insert a new record in the Invoice_Item table with an appropriate description and the value of the option field multiplied by the corresponding value from the System Defaults table.
  13. Calculate the total cost of the Invoice by taking the sum of all Invoice_Item records for this particular Invoice_Number and put this value in the Invoice_Amount field for the corresponding Invoice.
  14. Display the User Acceptance agreement based on the contents of the accept.tmpl page created by the web designers. Users will be instructed to print out this form and send it with any required documentation to the office.
  15. If Membership_Class is not Registered, append the Invoice information to the User Acceptance agreement created above using the format supplied in the invoice.tmpl file.

 

Possible Exit Conditions and Return Values

  1. The user supplied Member_UserName is not valid or not unique. An error message informing the user of the nature of the problem is displayed on the returned HTML page and the form in the user/apply.html page is recreated and repopulated with the current values. The user is invited to pick a different UserName and resubmit the form.
  2. The user supplied Initial_Password is not valid or not sufficiently hard. An error message informing the user of the specific failure of the password is displayed on the returned HTML page and the form in the user/apply.html page is recreated and repopulated with the current values. The user is invited to pick a different InitialPassword and resubmit the form.

Sign Off by:

Project Manager & Membership Committee or Board Designate

 

  • Log in [1] to post comments

user/login.cgi

Procedure Model

Type:    (  )Web Page              ( X )CGI Script           (  )Shared Library      (  )System API

Name: user/login.cgi

Assigned to:

Reference:

Description

This script creates a form to which the user enters their username and password, validates the information against the system records and if the user is authenticated, sets up a set of credentials for the user’s current session.

Implementation Skills

PERL, CGI, SQL

Parameter List

QueryString contains the URL (without the host portion) to which the user is redirected upon a successful authentication

 

Called By:

user/upgrade.html
user/myacct.html

Can Call:

lib/Login.pm
user/upgrade.cgi
user/myacct.cgi
user/index.html

Function Description

  1. The login.cgi script queries the user for a username and password combination. For users, the default access_level is “0”.[1]
  2. The username is then sent to the auth_user command. If the user is successfully validated according to the auth_user command, the Login.pm’s constructor method is called and a Login object is returned. This Login object is used to create a new cookie called Login with the value “<username>:<access_level>:<session_token> and a 1 hour expiry period. This cookie is returned to the user’s browser.
  3. If successful, the user is redirected to the URL constructed from the relative path and filename contained within the QueryString variable. Otherwise, the user is returned to the login.cgi page again with the appropriate error message displayed. The user is also given a link to go to the user/index.html page.

Possible Exit Conditions and Return Values

  1. A successful return from the auth_user command will redirect the user to the URL constructed from the relative path and filename passed through the QueryString variable (this value is relative in that it is missing the host and domain portion of a fully formed URL).
  2. An unsuccessful return from the auth_user command should return the user to another invocation of the login.cgi script and display the relevant error message.
  3. The user is always given the option of going to the user/index.html page or to the GPFN main page.

Sign Off by:

Project Manager

 



[1] The Access_Level value is included so that access texture can be incorporated in the future when different users and different volunteers can be given different levels of access to the system.

 

  • Log in [2] to post comments

user/upgrade.cgi

Procedure Model

Type:    (  )Web Page              ( X )CGI Script           (  )Shared Library      (  )System API

Name: user/upgrade.cgi

Assigned to:

Reference:

Description

This script shows the user the available system upgrades available to them. If the user selects any upgrades, an entry is added to the upgrade table so that the upgrades can be processed and applied to the users account.

Implementation Skills

PERL, CGI, SQL, Javascript

Parameter List

 

Called By:

user/index.html

Can Call:

lib/Login.pm
lib/uname_test.pl
vol/invoice.tmpl

Function Description

  1. The script calls the Login.pm module’s getLogin method to see if a valid set of user credentials exist for this user. If getLogin returns a NULL value, the user is redirected to the user/index.html page.
  2. If the getLogin returns a session credential, the Login.pm module’s getUserName method is called to determine the username of the session’s owner.
  3. The list of available upgrades for the user is determined and displayed to the user using the following logic:
  4. If the User record associated with the UserName has no corresponding entry in the Member table, then the Upgrade_User-Ind and Upgrade_User-Inst radio button is displayed. Only one of these options can be selected by the user. Javascript should be used to ensure that the user cannot select any other upgrade option unless one of these radio buttons is selected.
  5. If the Upgrade_User-Ind or Upgrade_User-Inst radio button is selected, ask the user to enter a textfield of between 4 and 16 characters for the Upgrade_Username field.
  6. If a corresponding entry in the Member table exists for this user, and the Member_Type is “Individual”, a checkbox for Upgrade_ind-Inst is displayed.
  7. If the corresponding entry in the Services table for this User_Number does not have a value for Service_PPP_Access, or Service_PPP_Access = 0, then a checkbox for Upgrade_toPPP is shown.
  8. If the corresponding entry in the Member_Type is “Institution” or the checkbox “Upgrade_Ind-Inst” or the radio button “Upgrade_User-Inst” is selected above, and the corresponding entry in the Services table for this User_Number does not have a positive integer value in the Service_WebSite field, then display a checkbox for Upgrade_toWebSite and by default set it to “checked.”
  9. If there is a corresponding entry in the Member table for this User_Number, display the following checkboxes:
    Upgrade_toVirtualDomain
    Upgrade_toDB
    Upgrade_toListserver
    and collect the following information in a text field for each of these checked options:
    Upgrade_VirtualDomainName
    Upgrade_DBName
    Upgrade_ListserverName
  10. If there is a corresponding entry in the Services table for Service_WebSite, or for Service_VirtualDomain, or the checkboxes for Upgrade_toVirtualDomain or Upgrade_toWebSite are selected above, display a checkbox for Upgrade_toSSL.
  11. If the corresponding entry in the Member_Type is “Institution” or the checkbox “Upgrade_Ind-Inst” or the radio button “Upgrade_User-Inst” is selected above, then display a checkbox for Upgrade_toAliases include two text fields for “Upgrade_AliasExtAddress” and “Upgrade_Alias_GPFNAddress”
  12. If there is a corresponding Member record for this User_Number, display three text fields with the current values for Service_Quota1, Service_Quota2, and Service_Quota3 for the corresponding Service table entry for this user. The labels for these fields should be constructed with meaningful labels from the Sys_Quota1_Mnt, Sys_Quota2_Mnt, and Sys_Quota3_Mnt fields.
  13. If there is no corresponding Member record for this User_Number and the Upgrade_User-Ind or Upgrade_User-Inst checkboxes are checked above, then display the default quotas from the Sys_Incl_Quota1, Sys_Incl_Quota2, and Sys_Incl_Quota3 fields as text fields.
  14. If a Username is requested in step 5 above, test this Username against the uname_test.pl library function.
  15. Collect the information and store all values in the respective fields of a new Upgrade_Request record.
  1. Insert a new record into the Invoice table with the following values:
    Invoice_Date is the current Timestamp
    Invoice_Medium = ‘Web’
    Invoice_EnteredBy = REMOTE_USER
    and retrieve the Invoice_Number of this new record
  2. For each of the upgrade options selected above where the option is not 0 or False, insert a new record in the Invoice_Item table with an appropriate description and the value of the option field multiplied by the corresponding value from the System Defaults table.
  3. Calculate the total cost of the Invoice by taking the sum of all Invoice_Item records for this particular Invoice_Number and put this value in the Invoice_Amount field for the corresponding Invoice.
  4. Display the Invoice information using the format supplied in the invoice.tmpl file. Direct the user to print this invoice and reference it when sending in their cheque.

Possible Exit Conditions and Return Values

  1. If getLogin returns a NULL value, the user is redirected to the user/index.html page.
  2. Otherwise, the user is supplied with an invoice of the total cost of their upgrades

Sign Off by:

Project Manager

 

  • Log in [3] to post comments

vol/listapps.cgi

Procedure Model

Type:    (  )Web Page              ( X )CGI Script           (  )Shared Library      (  )System API

Name: vol/listapps.cgi

Assigned to:

Reference:

Description

This script lists the applications for accounts currently in a pending state and asks a volunteer to approve or delete the application

Implementation Skills

PERL, CGI, SQL

Parameter List

 

Called By:

vol/index.html

vol/listapps.cgi

Can Call:

add_ppp()
add_db(dbname)
add_quota(mnt_point, Mb)
add_ssl(virtual_domain_name)
add_listserver(list_name)
vol/index.html
/index.html

Function Description

If the volunteer has selected the Delete button from a previous invocation of the form:

  1. Get the User_Number from the hidden field, then delete the User table record for this User, any Member table record for this user, any Upgrade_Request table record for this user where the Upgrade_ApprovedBy field is NULL, any Invoice table record where the Invoice_Number was in the Upgrade_Request record just deleted, and any Invoice_Item where the Invoice_Number is the Invoice_Number of the Invoice table record just deleted.

If the volunteer has selected the Approve button from a previous invocation of the form, perform the following steps:

  1. Call the sys/add_account configuration command, passing it the username (User_UserName), password (User_InitialPassword), and if there is a Member table record with this User_Number, the Member_Type value for this User_Number (one of "Institution" or "Individual"). If there is no corresponding Member table record for this User_Number, then it will pass the value of "User" as the value of the Member_Type parameter.
  2. If the Upgrade_toPPP is True, then call the add_ppp configuration command to add this user to the radiusd server.
  3. If the Upgrade_toDB is True, then call the add_db command with the name from the Upgrade_DBName value and the Username of the user making the request passed as parameters.
  4. If the Upgrade_Quota1 is greater than 0, then call the add_quota command with the parameters Sys_Quota1_Mnt, the value of the Upgrade_Quota1 multiplied by 1024, and the user’s Username who is making the request. Repeat this step for Quota2 and Quota3.
  5. If Upgrade_toVirtualDomain is True, then call add_virtualdomain with the name from the Upgrade_VirtualDomainName and the user’s Username and Groupname passed as parameters. The Groupname should be set to “users”, the default UNIX user group for new users.
  6. If Upgrade_toSSL is True, then call add_ssl with the value of the Service_VirtualDomainName (if one exists) or the value of the Upgrade_VirtualDomainName field.
  7. If Upgrade_toAliases is True, then verify that the Upgrade_AliasGPFNAddress is not a UserName assigned to another user by checking whether it exists in the User or Member tables and that it is not an existing Alias for another user by checking whether it exists in the E-mail Alias table. If the alias is not assigned, then call the add_alias command with the values from the Upgrade_AliasExtAddress and Upgrade_AliasGPFNAddress as parameters.
  8. If Upgrade_toListserver is True, then call the add_listserver command with the name from the Upgrade_ListserverName and the user’s Username as parameters.
  9. Update the User table record, the Upgrade table record, the Member table record and the Services table record by inserting the value of the REMOTE_USER variable into the User_EnteredBy, Upgrade_ApprovedBy, Services_EnteredBy, and Member_EnteredBy fields. Set the User_IsActive field to “Active” from “Pending”. Set the User_ExpiryDate to December 31 of the current calendar year. Set the User_Status_Msg to “User account approved: <timestamp>” where timestamp is the current date.
  10. If the User is a member, then ensure that a record in the Services table exists for this user, even if that record contains only the default values for each field (i.e. the member has not upgraded to any additional services).
  11. Create a new receipt table record with the value of the Invoice_Number matching this User_Number, the User_Number, the current timestamp as the Receipt_Date, and the values from the CGI form for the values of Receipt_Amount, and Receipt_Payment_Type and REMOTE_USER as the Receipt_Entered_By.

For all invocations of the script including the first:

  1. Select all records in the User table where the User_IsActive field = “Pending”
  2. For each record found in step 1, list the following information in a formatted table for each record. Each table should contain an HTML form with a hidden field containing the User_Number.
  3. Display the User_FirstName, User_LastName, User_Initial, User_Salutation, User_Organization (if exists), User_Title (if exists), User_StreetAddress1, User_StreetAddress2 (if exists), User_City, User_Province, User_Country, User_PostalCode, User_HomePhone (if exists), User_WorkPhone (if exists), and User_Age. If any of the required fields listed in the specifications for user/apply.html are left blank, a warning message should be displayed to the volunteer.
  4. In addition to the above fields, if a record exists in the Member table with this same User_Number perform the following additional steps:
  • Check if there is a record in the Upgrade table for this User_Number where Upgrade_ApprovedBy is NULL. If there is, display a series of checkboxes and textfields listing the following fields from that table:
    Upgrade_toPPP (checkbox)
    Upgrade_toDB (checkbox) and show Upgrade_DBName (textfield) if Upgrade_toDB is True
    Upgrade_Quota1 (textfield)
    Upgrade_Quota2 (textfield)
    Upgrade_Quota3 (textfield)
    Upgrade_toVirtualDomain (checkbox) and show Upgrade_VirtualDomainName (textfield) if Upgrade_toVirtualDomain is True
    Upgrade_toSSL (checkbox)
    Upgrade_toAliases (textfield) and show Upgrade_AliasExtAddress (textfield) and Upgrade_AliasGPFNAddress(textfield if Upgrade_toAliases is an integer > 0
    Upgrade_toListserver (checkbox) and Upgrade_ListserverName (textfield) if Upgrade_toListserver is True
  • Get the Invoice table record with this User_Number and display the Invoice_Date and Invoice_Amount.
  • Display a textfield named Receipt_Amount and a radio button array named Receipt_Payment_Type with values “Cash”, “Cheque”, “In-Kind”, “Visa”, or “MasterCard”.
  1. Display a “Approve” Submit Button and a “Delete” Submit Button for each Form.

Possible Exit Conditions and Return Values

  1. If there are no pending applications, the list should be empty and volunteers can click a link to return to vol/index.html or the GPFN home page.
  2. Any application from the list can be left it is current pending state, deleted from the system, or approved.

Sign Off by:

Project Manager

 

  • Log in [4] to post comments

vol/listupgrades.cgi

Procedure Model

Type:    (  )Web Page              ( X )CGI Script           (  )Shared Library      (  )System API

Name: vol/listupgrades.cgi

Assigned to:

Reference:

Description

This script lists the upgrades for existing accounts where an unapproved Upgrade_Request table record exists.

Implementation Skills

PERL, CGI, SQL

Parameter List

 

Called By:

vol/index.html

vol/listupgrades.cgi

Can Call:

lib/add_alias
lib/change_username
Prototype-User (non-login account profile)
Prototype-Ind (non-login account profile)
Prototype-Inst (non-login account profile)
add_ppp()
add_db(dbname)
add_quota(mnt_point, Mb)
add_ssl(virtual_domain_name)
add_listserver(list_name)
vol/index.html
/index.html

Function Description

If the volunteer has selected the Delete button from a previous invocation of the form:

  1. Get the User_Number from the hidden field, then delete the corresponding Upgrade_Request record, and update the corresponding User table User_Status_Msg with the string “Upgrade request declined on <date> by <REMOTE_USER> because: <Delete_Reason>.” where the appropriate values are inserted into the variables. Delete the corresponding record in the Invoice table and Invoice_Item table for this Upgrade_Request.

If the volunteer has selected the Approve button:

  1. If Upgrade_User-Ind or Upgrade_User-Inst fields are True and no Member table record exists for this User_Number: insert a new record in the Member Table, setting the User_Number to User_Number, Member_Since to today’s date, Member_EnteredBy to REMOTE_USER, Member_UserName to the value of UserName supplied from the form, and the Value of Member_Type to “Institution” in the case of a Upgrade_User-Inst request or “Individual” for a Upgrade_User-Ind request. Call the add_alias command with parameters User_UserName as the old address and Member_UserName as the new address to map to. Call the change_username command to rename the user’s home directory and alter the appropriate entries in the /etc/password and /etc/shadow files. Call the edquota command with parameter “Prototype-Ind” or “Prototype-Inst” depending on the value of the Member_Type field.
  2. If there is a corresponding record in the Member table for this User_Name:
  • If the Upgrade_toPPP is True, then call the add_ppp configuration command to add this user to the radiusd server.
  • If the Upgrade_toDB is True, then call the add_db command with the name from the Upgrade_DBName value and the Username of the user making the request passed as parameters.
  • If the Upgrade_Quota1 is greater than 0, then call the add_quota command with the parameters Sys_Quota1_Mnt, the value of the Upgrade_Quota1 multiplied by 1024, and the user’s Username who is making the request. Repeat this step for Quota2 and Quota3.
  • If Upgrade_toVirtualDomain is True, then call add_virtualdomain with the name from the Upgrade_VirtualDomainName and the user’s Username and Groupname passed as parameters. The Groupname should be set to “users”, the default UNIX user group for new users.
  • If Upgrade_toSSL is True, then call add_ssl with the value of the Service_VirtualDomainName (if one exists) or the value of the Upgrade_VirtualDomainName field.
  • If Upgrade_toAliases is True, then verify that the Upgrade_AliasGPFNAddress is not a UserName assigned to another user by checking whether it exists in the User or Member tables and that it is not an existing Alias for another user by checking whether it exists in the E-mail Alias table. If the alias is not assigned, then call the add_alias command with the values from the Upgrade_AliasExtAddress and Upgrade_AliasGPFNAddress as parameters.
  • If Upgrade_toListserver is True, then call the add_listserver command with the name from the Upgrade_ListserverName and the user’s Username as parameters.
  • Update the Upgrade table record and the Services table record by inserting the value of the REMOTE_USER variable into the User_EnteredBy, Upgrade_ApprovedBy and Services_EnteredBy fields.
  • Create a new receipt table record with the value of the Invoice_Number matching this User_Number, the User_Number, the current timestamp as the Receipt_Date, and the values from the CGI form for the values of Receipt_Amount, and Receipt_Payment_Type and REMOTE_USER as the Receipt_Entered_By

For all invocations of the script including the first:

  1. Select all records in the Upgrade_Request table where the matching record in the User table with the same User_Number does not have User_IsActive = “Pending”
  2. For each record found in step 1, list the following information in a formatted table for each record.
  3. Each table listed in step 2 should contain an HTML form with a hidden field containing the User_Number.
  4. Display the User_FirstName, User_LastName, User_Initial, User_Salutation, User_Organization (if exists), User_Title (if exists), User_StreetAddress1, User_StreetAddress2 (if exists), User_City, User_Province, User_Country, User_PostalCode, User_HomePhone (if exists), and User_WorkPhone (if exists).
  5. In addition to the above fields, display the following additional values:
    Upgrade_User-Ind or Upgrade_User-Inst (as a radio button)
    Upgrade_toPPP (checkbox)
    Upgrade_toDB (checkbox) and show Upgrade_DBName (textfield) if Upgrade_toDB is True
    Upgrade_Quota1 (textfield)
    Upgrade_Quota2 (textfield)
    Upgrade_Quota3 (textfield)
    Upgrade_toVirtualDomain (checkbox) and show Upgrade_VirtualDomainName (textfield) if Upgrade_toVirtualDomain is True
    Upgrade_toSSL (checkbox)
    Upgrade_toAliases (textfield) and show Upgrade_AliasExtAddress (textfield) and Upgrade_AliasGPFNAddress(textfield if Upgrade_toAliases is an integer > 0
    Upgrade_toListserver (checkbox) and Upgrade_ListserverName (textfield) if Upgrade_toListserver is True
  6. Get the Invoice table record with this User_Number and display the Invoice_Date and Invoice_Amount.
  7. Display a textfield named Receipt_Amount and a radio button array named Receipt_Payment_Type with values “Cash”, “Cheque”, “In-Kind”, “Visa”, or “MasterCard”.
  8. Get the Invoice table record with this User_Number and display the Invoice_Date and Invoice_Amount.
  9. Display a textfield named Receipt_Amount and a radio button array named Receipt_Payment_Type with values “Cash”, “Cheque”, “In-Kind”, “Visa”, or “MasterCard”.
  10. Display a textfield named “Delete_Reason”.
  11. Display a “Approve” Submit Button and a “Delete” Submit Button for each Form.

Possible Exit Conditions and Return Values

  1. If there are no pending applications, the list should be empty and volunteers can click a link to return to vol/index.html or the GPFN home page.
  2. Any application from the list can be left it is current pending state, deleted from the system, or approved.

Sign Off by:

Project Manager

 

  • Log in [5] to post comments

vol/geninvoice.cgi

Procedure Model

Type:    (  )Web Page              (X)CGI Script             (  )Shared Library      (  )System API

Name: vol/geninvoices.cgi

Assigned to:

Reference:

Description

This script taking parameters from the form on invoice.html generates invoices or statements for one or all system users

Implementation Skills

PERL, CGI, SQL

Parameter List

Invoice_Count
User_UserName
Type_Switch
Medium_Switch

Called By:

vol/invoices.html
vol/geninvoices.cgi

Can Call:

vol/index.html
 

Function Description

Depending on the values of the Type_Switch and Invoice_Count parameters, create a temporary directory named after the current process_id in which to store the following generated invoices or statements. Only one of the following six steps will be used for each invocation of this script:

  1. If Type_Switch = ‘NewInvoice’ and Invoice_Count = ‘all’, first ensure that the Sys_Last_Annual_Cycle is no more than 16 months after the current date[1]. If this test is successful, then get a list of all records in the User table where User_IsActive = ‘Active’ and User_Expiry_Date is less than the Sys_Last_Annual_Cycle. For each of these User records, create a new Invoice record, inserting the User_Number as the foreign key, the current date as the Invoice_Date, the Invoiced_Medium as the value of the Medium_Switch field, and the Invocie_EnteredBy as the value of REMOTE_USER.
  • If the User IsMember field = 0, create a new invoice for this user. This Invoice should have a single Invoice_Item with Item_Amount = Sys_Reg_User_Price and Item_Description = “Renewal of Free Internet Account”.[2]
  • If the User_Is_Member field= 1, denoting that the user is a member, then determine if the User is an Individual or Instutional member by querying the Member table for this user and create a new Invoice record with an Invoice_Item with Item_Description of either “Institutional Membership Renewal” or “Individual Membership Renewal” and an Item_Amount of either “Sys_Ind_Mem_Price” or “Sys_Inst_Mem_Price” respectively.
  • If the User_Is_Member field = 1 and the user has a corresponding record in the Services table, for each service listed in the Service Table, multiply any non-zero value by the respective Price in the System_Defaults table and create a new Invoice_Item record with this product in the Item_Amount field and the Service Description in the Item_Description field, and update the Invoice_Number and User_Number.
  • Once the Membership and all Services have been invoices for a user, obtain the sum of all Invoice_Item entries for this Invoice_Number and put this value in the Invoice_Amount field
  • Increment the sys_Last_Annual_Cycle by 1 year to be December 31 of the end of the current billing cycle.
  1. If Type_Switch = ‘NewInvoice’ and Invoice_Count = ‘1’, get the User_UserName value from the CGI script and query the User table to get the corresponding User_Number for this UserName. For this User_Number, create a new Invoice record, inserting the User_Number as the foreign key, the current date as the Invoice_Date, the Invoiced_Medium as the value of the Medium_Switch field, and the Invocie_EnteredBy as the value of REMOTE_USER.
  • If the User IsMember field = 0, create a new invoice for this user. This Invoice should have a single Invoice_Item with Item_Amount = Sys_Reg_User_Price and Item_Description = “Renewal of Free Internet Account”.
  • If the User_Is_Member field= 1, denoting that the user is a member, then determine if the User is an Individual or Instutional member by querying the Member table for this user and create a new Invoice record with an Invoice_Item with Item_Description of either “Institutional Membership Renewal” or “Individual Membership Renewal” and an Item_Amount of either “Sys_Ind_Mem_Price” or “Sys_Inst_Mem_Price” respectively.
  • For each service listed in the Service Table, multiply any non-zero value by the respective Price in the System_Defaults table and create a new Invoice_Item record with this product in the Item_Amount field and the Service Description in the Item_Description field, and update the Invoice_Number and User_Number. Once all Services have been invoices for the user, obtain the sum of all Invoice_Item entries for this Invoice_Number and put this value in the Invoice_Amount field.
  • Once the Membership and all Services have been invoices for the user, obtain the sum of all Invoice_Item entries for this Invoice_Number and put this value in the Invoice_Amount field.
  1. If Type_Switch = ‘ExistingInvoice’ and Invoice_Count = ‘all’, get a list of all invoices from the Invoice_Table where there is no corresponding Receipt table entry and where ‘User_IsActive = ‘Active’.
  2. If Type_Switch = ‘ExistingInvoice’ and Invoice_Count = ‘1’, get the User_UserName value from the CGI script and query the User table to get the corresponding User_Number for this UserName. Get a list of all invoices from the Invoice_Table where there is no corresponding Receipt table entry and where the Invoice table User_Number is the current User_Number.
  3. If Type_Switch = ‘Statement’ and Invoice_Count = ‘all’, get a list of all Invoices and Receipts for each User where User_IsActive = ‘Active’. Format each statement using the stmt.tmpl template file such that all invoice and receipt entries are combined and then sorted in an oldest-date-first list.
  4. If Type_Switch = ‘Statement’ and Invoice_Count = ‘1’, get a list of all Invoices and Receipts for the User_Number corresponding to the User_UserName value. Format the statement using the stmt.tmpl template file such that all invoice and receipt entries are combined and then sorted in a oldest-date-first list.

Regardless of which of the above six steps was selected, get the value of the Medium_Switch parameter:

  1. If the Medium_Switch = ‘E-mail’ format each file in the temporary directory created above as an e-mail message and send the statement or invoice via e-mail to <User_UserName>@gpfn.ca. Delete each temporary file after it is sent.
  2. If the Medium_Switch = ‘Screen’, format each file in the temporary directory created above as an HTML table, formatting it according to the invoice.tmpl or statement.tmpl file and then zipping it and then inserting a link in the returned page so the volunteer can download the file using a HTTP transport. Delete each temporary file after it is incorporated into the new HTML page.

Delete the temporary directory created above.

Possible Exit Conditions and Return Values

The script should always return successfully

Sign Off by:

Membership Committee or board designate



[1] We don’t mind invoices going out in September for the coming year, but let’s make sure that we don’t have two volunteers thinking this way or we’ll be billing people for two years down the road.

[2] This requirement is intended to allow the Free-Net to query existing registered users to determine if they still want their free e-mail and dial-up account. The invoice should have some information for the user to either print the invoice, sign it and send it in, or else e-mail a confirmation that they want to keep their account.

 

  • Log in [6] to post comments

vol/receipts.cgi

Procedure Model

Type:    (  )Web Page              (X)CGI Script             (  )Shared Library      (  )System API

Name: vol/receipts.cgi

Assigned to:

Reference:

Description

This script gets a list of all unpaid invoices and displays them to the volunteer so that the volunteer can apply receipts against them.

Implementation Skills

PERL, CGI, SQL

Parameter List

 

Called By:

vol/index.html
vol/receipts.cgi

Can Call:

vol/index.html
 

Function Description

If the script has been called by a previous invocation of this same script as determined by the value of the Submit button being “Apply Receipt”:

  1. Create a new Receipt record with the values of the Invoice_Number hidden field, the User_Number for this invoice, the Receipt_Date being the current date, the Receipt_Amount being the amount entered from the CGI form, the Receipt_Payment_Type being the value entered from the CGI form, and the Receipt_EnteredBy field being set to REMOTE_USER.
  2. If the sum of a Receipt_Amounts in the Receipt table where the Invoice_Number corresponds to the Invoice_Number passed through the CGI form is equal to or greater than the value of the Invoice record’s Invoice_Amount for this Invoice_Number, then set the User_Expiry_Date one year past its current date. (i.e. the Invoice has been paid in full).

For all invocations through this script, even the first, perform the following steps:

  1. Get a list of all Invoices from the Invoice table where the User_IsActive = ‘Active’ of the corresponding User_Number and where the sum of all Receipt_Amounts in the Receipt table with this Invoice_Number is less than the Invoice_Amount (i.e. the invoice has not been fully paid).
  2. Display a table to the volunteer. For each Invoice returned in step 1, create a row in a table that contains a form. Set the Invoice_Number as a hidden field within each form.
  3. Each row will also include: the User’s first and last name, the User’s username, and the value of the User_Since, User_Expiry_Date, and the value of the corresponding Member_Type field in the corresponding Member table. Also display the Invoice_Date, the Invoiced_Medium, the Invoice_Amount, and the sum of any Receipt_Amounts already applied against the Invoice. Present a textfield with the default value set to the difference of the Invoice_Amount less the sum of all Receipt_Amounts applied against this Invoice. Display a radio button array with the values “Cash”, “Cheque”, “In-Kind”, “Visa”, and “MasterCard”. Each row will also include a submit button with the name “Apply Receipt”

Possible Exit Conditions and Return Values

The script should always return successfully. If no outstanding invoices exist, an empty list should be presented. Volunteers can always click on a link to take them to the vol/index.html or GPFN main page.

Sign Off by:

Membership Committee or board designate

 

  • Log in [7] to post comments

Source URL:https://niedermayer.ca/node/188

Links
[1] https://niedermayer.ca/user/login?destination=node/188%23comment-form [2] https://niedermayer.ca/user/login?destination=node/189%23comment-form [3] https://niedermayer.ca/user/login?destination=node/190%23comment-form [4] https://niedermayer.ca/user/login?destination=node/191%23comment-form [5] https://niedermayer.ca/user/login?destination=node/192%23comment-form [6] https://niedermayer.ca/user/login?destination=node/193%23comment-form [7] https://niedermayer.ca/user/login?destination=node/194%23comment-form