Drupal, in a content type display some text depending on the value of a date field - drupal-7

I have a problem that puzzled me for quite a long time with the display of certain text depending on the value of a pair of date fields.
I have created a content type that includes two fields, a start date and an end date. I have also a third field titled "status" and I would like to make it display the values "in preparation", "in progress", "completed" depending on the value of the start/end dates.
Could you please guide me on how to do that?
I am using Drupal 7.

You can use template_preprocess_field and alter your field based on $vars['element']['#field_name'].
Also there is an $vars['element']['#object'] object that holds the original entity.

Related

Set Value to a Report Textbox from a Query

I made a query that only shows me a single field and a single record from another query, how can I put that value in a textbox in a report?
The record I want to set is a date that I insert with a MsgBox.
I read that there are ways to just put in the Control Source "=[table]![field]" but I get the Name? error, another way I read but did not understand it is defining a recordset. I can't put the value to the textbox despite trying the ways I've read in other posts.
One simple way is with DLookup() domain aggregate function expression in textbox. If field name has space or punctuation/special characters or is a reserved word, [ ] delimiters will be required. Usually table/query name does not but can't hurt.
=DLookup("[fieldname]","[tableORquery name]")

Printing records with condition Crystal reports

I am using stored procedure in mssql as backend, vb.net as frontend (just info).
There are a lot of records in the database and I am printing in crystal reports.
Now I want to filter the records from crystal report and not by adding a new parameter to procedure or changing database structure or else.
For now,Say there are columns : Name , Amount.
I want to put filter in amount like only display records whose amount above 100 or something. So other records with less than 100 should not be displayed.
This filter will be passed by the user so it'll be random.
I can't find a proper answer on internet. Might be a duplicate question, if so please post the link of the question if it is duplicated.!
Thanx anyways...!
In general the idea is to:
Create the parameter (user choose what will be the input/value) - link
Set filters, what values should be displayed in regards to parameter - link
On right side there is a DataExplorer window, where You need to add a Parameter (define his name, what question will be shown to user and what type the param will be / what values can be set inside).
Once done, You can jump to Data tab of a report, click Interactive Filter and specify which column must fit what condition with what value = Parameter (that one user will enter in Report).
Example: I will create AmountParam, with message "What should be the minimum amount?". Type will be set to Integer. Going to Report->Data->Interactive Filter, choose Amount as a Column, AmountParam as a Parameter and set condition Greater then (>).

MS ACCESS Report - Using CODE to change a value in a field from an OPTION Group to a different value

I have a report in ACCESS that Is based on a query of a table populated by a form with an Option group. ( to try to explain this better - Table is inspector qualifications, the query pulls all of the qualifications for the inspector, the qualifications are selected via option group on a form that populates the fields of the inspector qualification table.) Of course, the choices are stored as numeric values, "1, 2, 3 or 4" in the table, but 4 actually designates a N/A or NONE. Since everything is already built out this way, I am trying to write a code that will run when the report is generated (or opened,) that will take the "4" value entered (if the field equals that) and change it to a Null value /blank in the report - not in the query or table. I still want this report to generate everything else as is - show all records - just change the value if that particular option is the one shown in that field for that particular record.
Anyone know of a good way to do this? Any help would be GREATLY appreciated!!!!
You would just place an 'IIF' in the query that tests for the value you want to change, then either changes it to something else, or retains the original value. The below will test field 'Nbr1' for the presence of a 4, and if found, change it to 'N/A', otherwise it stays the same.
Note! You will need to change the control source in the report to reflect the name you provide (i.e. 'MyChange') because you can't keep the original name.
SELECT Table1.ID, Table1.EMPID, Table1.TestResult,
IIf([Nbr1]=4,"N/A",[Nbr1]) AS MyChange, Table1.Nbr2
FROM Table1;

FileMaker Pro 13: How to get a summary variable to display an accurate total

I am working on a database of records that includes a step that only needs to be performed for some of the records (about a fourth of them). To keep track of which records needs the extra step, I created a boolean field with 0 for "doesn't need the step" and 1 for "needs the extra step" (these are assigned before importing the information into the database). There is also an option for the user to click a button and change the boolean from 0 to 1 (in case the record needs the extra step in the future).
The database also has a report feature that shows the total number of records that needs this extra step. I need this field to display the current total number of these records, so I have tried setting up a summary variable called Total PLQA that is defined to give the "Total of" and then the boolean variable (PLQA Bool). Somehow, I got the total to work once, but it seems that the reporting variable "Total PLQA" does not update when new records are added to the database or when users change the boolean value. Somehow, I need to get the variable to update whenever the report script is run and I can't figure out how to get it to work.
I have tried setting up a summary variable called Total PLQA that is
defined to give the "Total of"
That would be a summary field, not a variable.
it seems that the reporting variable "Total PLQA" does not update when
new records are added to the database or when users change the boolean
value.
A summary field always displays the summary value for the current found set (unless you place it in a sub-summary part, where it will display the sub-summary value for each sorted group).
Make sure your report layout is based on the same table where the summary field is defined, and that the summary field's instance placed on the layout is coming from the same table occurrence.
Note also that:
After import, only the imported/updated records will be found;
If you modify the Boolean field, you must commit the record before you will see the summary field reflect the change.

Custom label text in cakephp

I want to get two field values from a database table and combine them together and use that as the display text in the label. Also I want to make another field value in the table as the label id.
The AgeCat table stores the different age categories. The table definition is
age_cat_id ---> primary key
range_start
range_end
e.g:
age_cat_id=>1
range_start=>18
range_end=>24
What I want is to have the label text set as '"range_start" to "range_end"'
e.g: '18 to 24'
and the label id to be the age_cat_id.
What is the proper way to format the label text to display as above? I have retrieved all the records of the AgeCat table, and stored them in a string array ($agecats) using find(all). I'm having trouble retrieving values from that array and then format it according to above way and set as the label text. Please suggest if there is a better way to do this.
The purpose of this is to display each record in the AgeCat table following the format of 'range_start to range_end' but having their value set as the corresponding age_cat_id.
E.g: 18 to 24 is displayed using some form element but the value should be 1. It's like having a drop down list with custom strings, but each linked to a unique value. So once an option is selected, the value is passed, not the string.
If the label is not good enough, what form element is suitable for this?
Virtual fields:cakephp documentation.
public $virtualFields = array(
'cat_date' => 'CONCAT(AgeCat.range_start, " to ", AgeCat.range_end)'
);
P.S.: according to Cakephp conventions the primary key should be named id.
Edit: take a look there: form helper
echo $this->Form->select('id', $cat_date)
In the controller something like this:
$cat_date=$this->Model->find('list',array('fields'=>array('id','cat_name')));
with $cat_date an array containing the desired values in the select.

Resources