A
admin author
Use Case:
User selects "Request", Muli-selection with static selections
- Paint, Punch, Clean, Trashout, Other, etc.
System generates a single record per selection
If Other is included in the selection then the "Description" field is required I could not find a way to make that the "Description" field required if other was selected from "Request, therefor, I split out the Request into two fields making "Other" it's own option as described below: If there is an easier way to achieve the Use Case, I'm all in for help there. Otherwise, I need help for the below.
--------------- Two list fields as check boxes.
- Request, multiple selection
- Other Request, single selection (Other)
What I am trying to do is: if "Request" is completed -> explode (create multiple records and not include description field) ORif "Other" is completed -> explode (create single record with Request Type = "Other" include description field) OR
if "Request" AND"Other" are completed ->explode (create multiple records where "Other" sets Request Type as "Other" and includes description field) Here is what is happening:
If "Request" is selected with Clean, and Paint options selected AND NOT "Other", it is creating 3 records.
1 Clean record
1 Paint record
1 Clean,Paint record
It should just create 1 Clean and 1 Paint record If "Other" is selected (only option is "Other") AND NOT "Request"
Nothing is created If "Request" is completed with Clean and Trash out options selected AND"Other" is selected it is creating 3 work orders which is working properly.
1 Clean
1 Trash out
1 Other My code is pasted below and I appreciate any help! if ($values["request"])
{
$arr = explode(",",$values["request"]);
// This is the name of the multi check box or
// list select field, its value becomes $arr
for ($i=0;$i<count($arr);$i++)
{
$strInsert = "insert into workorders (request,
prop_name,
status,
priority,
unit_no,
unit_size,
unit_type,
no_baths,
notes,
regional_mgr,
property_mgr,
maint_sup,
file,
propid,
prop_initials,
regional_mgrid,
property_mgrid,
maint_supid,
created_by,
created_date
) values ('".$arr[$i]."',
'".$values["prop_name"]."',
'".$values["status"]."',
'".$values["priority"]."',
'".$values["unit_no"]."',
'".$values["unit_size"]."',
'".$values["unit_type"]."',
'".$values["no_baths"]."',
'".$values["notes"]."',
'".$values["regional_mgr"]."',
'".$values["property_mgr"]."',
'".$values["maint_sup"]."',
'".$values["file"]."',
'".$values["propid"]."',
'".$values["prop_initials"]."',
'".$values["regional_mgrid"]."',
'".$values["property_mgrid"]."',
'".$values["maint_supid"]."',
'".$values["created_by"]."',
'".$values["created_date"]."')"; // add more fields from the add page to be inserted into database
db_exec($strInsert);
} if ($values["other"])
{
$arr = explode(",",$values["other"]);
// This is the name of the multi check box or
// list select field, its value becomes $arr
for ($i=0;$i<count($arr);$i++)
{
$strInsert = "insert into workorders (other,
prop_name,
status,
priority,
description,
request,
unit_no,
unit_size,
unit_type,
no_baths,
notes,
regional_mgr,
property_mgr,
maint_sup,
file,
propid,
prop_initials,
regional_mgrid,
property_mgrid,
maint_supid,
created_by,
created_date
) values ('".$arr[$i]."',
'".$values["prop_name"]."',
'".$values["status"]."',
'".$values["priority"]."',
'".$values["description"]."',
'".$values["other"]."',
'".$values["unit_no"]."',
'".$values["unit_size"]."',
'".$values["unit_type"]."',
'".$values["no_baths"]."',
'".$values["notes"]."',
'".$values["regional_mgr"]."',
'".$values["property_mgr"]."',
'".$values["maint_sup"]."',
'".$values["file"]."',
'".$values["propid"]."',
'".$values["prop_initials"]."',
'".$values["regional_mgrid"]."',
'".$values["property_mgrid"]."',
'".$values["maint_supid"]."',
'".$values["created_by"]."',
'".$values["created_date"]."')"; // add more fields from the add page to be inserted into database
db_exec($strInsert);
}
header("Location: http://pmsindy.com/pmsi/requests_regional_list.php");
// Exit and Redirect to the list page after updating database
exit();
} return true;
}
|
|