Forums

Help with querying database

ramakunga 20 Nov, 2015
Hi Everyone
If possible I would like some input on how complete the workflow for a leave application form I have created for our Intranet. Here is what I have done so far

• Created the form with inputs as required
• Created actions that email the details of the leave application back to the user and also forwards to a supervisor (dynamic email send to address based on inputs)
• Data is saved to a database within Joomla using Chronoforms create table.

The next step is to have the supervisor approve the leave request via another form. My idea is to use a field set that display’s all user requests if the status is awaiting approval. The supervisor should be able to press an approve or deny button that updates the record and notifies the user and our HR Dept.

The area I am having trouble with is getting the data to display in the fieldset. So far I have

• Created a DB Read action in the on-load section before the render form action
o Enabled = Yes
o Table Name is correct
o Multi Read=Yes
o Enable Model ID= No
o Fields entered
o Order selected
o No conditions entered ( but I want it to display only records where status= Awaiting Approval)

• In designer I have container as type fieldset
• Custom code module entered
<table>
  <thead>
    <tr>
      <th>ID</th>
      <th>Name</th>
      <th>Leave Start Date</th>
      <th>Leave Finish Date</th>
      <th>Type of Leave</th>
    </tr>
  </thead>
  <tbody>
<?php
//Not sure what to put as PHP Query
?>
  </tbody>
</table>


Any help would be greatly appreciated
GreyHead 20 Nov, 2015
Hi ramakunga,

I would do it something like this. First add a Model ID to the DB Read to let you access the data more easily.

<?php
$leave = array();
foreach ( $form->data['model_id'] as $v ) {
  $leave[] = "<tr><td>{$v['aaa']}</td><td>{$v['bbb']}</td><td>{$v['ccc']}</td><td>{$v['ddd']}</td></tr>";
}
$leave = implode("\n", $leave);
?>

<table>
  <thead>
    <tr>
      <th>ID</th>
      <th>Name</th>
      <th>Leave Start Date</th>
      <th>Leave Finish Date</th>
      <th>Type of Leave</th>
    </tr>
  </thead>
  <tbody>
<?php echo $leave; ?>
  </tbody>
</table>

Replace the model_id and aaa, bbb, . . . with the values from your table.

There are other ways you might do this - ChronoConnectivity is more capable for creating listings.

Also you could email the Admin a link that will let them access the specific entry that needs to be approved.

Bob
ramakunga 22 Nov, 2015
Answer
Thanks for the info Bob,

I took your advice and installed Chrono Connectivity, this acheived what i was looking to do and more

thanks for the heads up
This topic is locked and no more replies can be posted.