0

Here is what I am trying to accomplish:

I have a form, reschedule requests.

I have gotten it to autofill the logged in user and email using the site's global variables. In other database tables, I have info on who they're scheduled with, and their scheduled time. I need to pull this info into my form in two select lists.

The first select list would autofill with the person they're scheduled with (or more than one person if they have multiple appointments) and then when they choose the person, the second select list should fill with the currently scheduled appointments they have with that person.

I was initially using BreezingForms for Joomla to do this, however, I'd like to make this into a plain html/php/js form instead, because the database queries and tables would be simpler to handle. However, someone else wrote the pieces and scripts for the BreezingForms part, and I don't know how to convert it to some regular queries that will work without BreezingForms. right now, they appear to call some specific global breezingforms functions in addition to regular php and mysql stuff.

anyhow, once I can get that form to autofill and submit to the database with the additional filled-in info, then I need a separate html table to populate, and have form actions performed on it.

the new html table would have a list of each submission of the previous form (which I know how to make the query to do this, I think) but it also needs two additional actions performed on it. The first, would be an approve/deny button for each row in the table. when the submission is either approved or denied, different things need to happen. if approved, then a date/time field needs to appear so that it can be rescheduled to a new time. this would submit to a different database table, to create a new appointment. if denied, it would just state "denied" and possibly "change to approve?" and would not give a new field to schedule with.

as you can see, the approve/deny part needs to happen in a separate action than the submit new schedule time part, as it might be approved immediately, however a new time might not be scheduled for a few days.

If anyone can help with even a part of this, I would be very appreciative.

Parts I need help with:

Create a select list on a form that gets it's values from a database table.
Create a second select list that populates based on the values of the first select list, also from a database table.

Submit the form to a new database table.

-----

Create an html table with the values from the new database table, and two additional columns.
One column would have approve and deny buttons. the other would have a greyed-out date/time field/picker/thingy. On clicking approve, the approve/deny column would submit the approval to a third database table, lose the buttons and simply say "approved" and the date/time fields would be available in the second column.
on clicking deny, the approve/deny column would submit the denial to the third database table, and change to "denied" but still have a button to update later to "approve" the date/time field would remain unavailable.
---------

when a date/time field is submitted on the second column, new appointment information would be entered in the appointment table in the database, and the field would disappear to be replaced with the newly scheduled date and time.

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by grayceworks
0

i dont think you should expect people to write it for you
make an efffort first and approach for help

0

i dont think you should expect people to write it for you
make an efffort first and approach for help

I've got large parts of it already written, as I think I stated. I've been working on this for 3 weeks on my own already. I just can't quite get it to all work nicely together, and I'm not a programmer by any means. Happy to post what I have so far, but it's hundreds and hundreds of lines of code.

And I was working with another person, but they've disappeared suddenly. :(

Specifically, I have the form, with two blank select lists. I have parts of a query for those, but dont' know the exact commands to get it to populate the lists.

I have the html table written, with placeholder fields in the two additional columns, and again, partial queries, but not working. It pulls the submissions from the other form into the table, but the two new columns don't work.

Edited by grayceworks: n/a

0

I've got large parts of it already written, as I think I stated. I've been working on this for 3 weeks on my own already. I just can't quite get it to all work nicely together, and I'm not a programmer by any means. Happy to post what I have so far, but it's hundreds and hundreds of lines of code.

And I was working with another person, but they've disappeared suddenly. :(

Specifically, I have the form, with two blank select lists. I have parts of a query for those, but dont' know the exact commands to get it to populate the lists.

I have the html table written, with placeholder fields in the two additional columns, and again, partial queries, but not working. It pulls the submissions from the other form into the table, but the two new columns don't work.

Form code so far, along with images, are attached. Hmm. Most of the code anyhow. A lot of the code from the pictured table is in a joomla module. I'll get that copied to a text file if needed.

Attachments
<?php
/**
* @package   Project Fork - Custom Section E
* @copyright Copyright (C) 2010 Antoine Thompson and grayCeworks small business solutions. All rights reserved.
* @license   Commercial - http://www.athomptech.com
**/
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
<div id="theme_cpanel_top"><?php $theme->loadPanels('custom_e_panel_top'); ?></div>
<div id="theme_cpanel_main"><?php $theme->loadPanels('custom_e_main'); ?></div>
<div><?php $theme->loadPanels('custom_e_main1'); ?></div><?php
//$confirm_link = $pf_core->link("section=custom_e&confirm=1");?>
<link href="http://ps2.testsitebuilding.com/administrator/components/com_projectfork/sections/custom_e/output/form.css" rel="stylesheet" type="text/css" /><style type="text/css">    .form-label{        width:150px !important;    }    .form-label-left{        width:150px !important;    }    .form-line{        padding:10px;    }    .form-label-right{        width:150px !important;    }    .form-all{        width:690px;        color:Black !important;        font-family:Verdana;        font-size:12px;    }</style><form class="form-form" action="#" method="post" name="makeuprequestform" id="10392645047" accept-charset="utf-8">    <input type="hidden" name="formID" value="10392645047" />    <div class="form-all">        <ul class="form-section">            <li id="cid_1" class="form-input-wide">                <div class="form-header-group">                    <h2 id="header_1" class="form-header">                        Makeup Class Request                    </h2>                </div>            </li>            <li class="form-line" id="id_3">                <div id="cid_3" class="form-input-wide">                    <div id="text_3" class="form-html">                        <p>                            Please fill in the following information regarding your Makeup Request. Your request will be reviewed by your instructor. If your request is approved, you will be notified, and you will have 90 days to complete the makeup lesson.                        </p>                    </div>                </div>            </li>            <li class="form-line" id="id_4">                <label class="form-label-left" id="label_4" for="vname"> Person Requesting </label>                <div id="cid_4" class="form-input">                    <input type="text" class="form-textbox" id="vname" name="vname" size="20" value="<?php global $my; echo $my->name;?>" />                </div>            </li>            <li class="form-line" id="id_6">                <label class="form-label-left" id="label_6" for="vemail"> Email </label>                <div id="cid_6" class="form-input">                    <input type="text" class="form-textbox" id="vemail" name="vemail" size="20" value="<?php global $my; echo $my->email;?>" />                </div>            </li>            <li class="form-line" id="id_7">                <label class="form-label-left" id="label_7" for="paddress"> Class With </label>                <div id="cid_7" class="form-input">                    <select class="form-dropdown" style="width:150px" id="paddress" name="paddress">                        <option>  </option>                        <option value="None Available"> None Available </option>                    </select>                </div>            </li>            <li class="form-line" id="id_8">                <label class="form-label-left" id="label_8" for="tasks"> Pick the class to reschedule: </label>                <div id="cid_8" class="form-input">                    <select class="form-dropdown" style="width:150px" id="tasks" name="tasks">                        <option>  </option>                        <option value="value1"> value1 </option>                    </select>                </div>            </li>            <li class="form-line" id="id_9">                <label class="form-label-left" id="label_9" for="issue_description"> Reason for the request: </label>                <div id="cid_9" class="form-input">                    <textarea id="issue_description" class="form-textarea" name="issue_description" cols="40" rows="6"></textarea>                </div>            </li>            <li class="form-line" id="id_2">                <div id="cid_2" class="form-input-wide">                    <div style="margin-left:156px" class="form-buttons-wrapper">                        <input id="submitmakeup" type="submit" class="form-submit-button" value="Submit Request" />                                              </div>                </div>            </li>        </ul>    </div>    <input type="hidden" class="form-hidden" value="Makeup Request Form" id="formsub" name="formsub" />    <input type="hidden" class="form-hidden" value="0" id="uid" name="uid" />    <input type="hidden" class="form-hidden" value="" id="taskcomment" name="taskcomment" />    <input type="hidden" class="form-hidden" value="0" id="tasktime" name="tasktime" />    <input type="hidden" class="form-hidden" value="null" id="commentid" name="commentid" />    <input type="hidden" class="form-hidden" value="tasks" id="commentscope" name="commentscope" /></form><?php//make this submit to the database in a brand new table. I created the table jos_pf_makeuprequestform with the appropriate fields//make this email a copy to admin. ?>
<div><?php $theme->loadPanels('custom_e_main2'); ?></div>
<div id="theme_cpanel_bottom"><?php $theme->loadPanels('custom_e_bottom'); ?></div>
<?php

//before form -- autofill makeup form fields based on logged in user

function ff_setSelectList($name, $value) {

    global $ff_processor;

    for ($r = 0; $r < $ff_processor->rowcount; $r++) {

        $row =& $ff_processor->rows[$r];

        if ($row->name==$name)

            $row->data2 = $value;

        unset($row);

    } // for

} // ff_setSelectList

// load the standard FacileForms library
$this->execPieceByName('ff_InitLib');

$user = &JFactory::getUser();

if ( isset( $user ) && ! $user->guest )
{
    global $database;

    $query = "SELECT * FROM #__users WHERE id = "
                . (int) $user->id;
    $database->setQuery( $query );

    $obj = null;
    $userInfo = $database->loadObject( $obj );
    
    ff_setValue('uid',(int) $user->id);


    if ( isset( $userInfo ) )
    {
        if ( isset( $userInfo->name ) )
        {
            ff_setValue('vname',
                $userInfo->name); 
        }
        if ( isset( $userInfo->email ) )
        {
            ff_setValue('vemail', 
                $userInfo->email); 
        }

       
        // Etc...
    }
    
	if($userInfo->usertype == "Registered"){
		//Find List of Teachers
		$query = "SELECT t.author AS id, u.name FROM #__pf_tasks AS t"
					 . "\n LEFT JOIN #__pf_task_users AS tu ON tu.task_id = t.id"
					 . "\n LEFT JOIN #__users AS u ON u.id = t.author"
					 . "\n WHERE tu.user_id = '".(int) $user->id."'"
                     . "\n GROUP BY t.author";
					 
		$StuTeach = "Teacher";
	}else{
		//Find List of Students
		$query = "SELECT tu.user_id AS id, u.name FROM #__pf_task_users AS tu"
					 . "\n LEFT JOIN #__pf_tasks AS t ON t.id = tu.task_id"
					 . "\n LEFT JOIN #__users AS u ON u.id = tu.user_id"
					 . "\n WHERE t.author = '".(int) $user->id."'"
					 . "\n GROUP BY tu.user_id";
		$StuTeach = "Student";
	}
	
	$database->setQuery( $query );
	$usernames = $database->loadObjectList( );
	if(!is_array($usernames)) {$usernames = array();}
	
	
	$listdata = "0;Choose A ".$StuTeach.";0\n";
	
	$projectList='';	
				foreach ($usernames AS $username)
				{
					$htmlProject = htmlspecialchars($username->name);
					$projectList .= $username->id.",";
					$listdata .= "0;{$htmlProject};{$username->id}\n";
					//$listdata .="{$htmlProject}";
				}
			
	//ff_setValue('paddress', $listdata);
	ff_setSelectList('paddress', $listdata);

      //Get All Tasks Information
    $projectList = substr_replace($projectList,'',-1);

    //Filter Results
	//$filter .= "\n AND t.assigned= '".(int) $user->id."'";
	//$filter .= "\n AND t.progress < 100";
	//$filter .= "\n AND t.progress = 100";

  
    $query = "SELECT t.id, t.title, t.project FROM #__pf_tasks AS t LEFT JOIN  #__pf_task_users AS tu ON tu.task_id = t.id WHERE t.project IN($projectList)"
	   . "\n AND tu.user_id = '".(int) $user->id."'"
	   . "\n AND t.progress < 100"
	   . "\n GROUP BY t.id";
			$listdata_tasks = '';
			$database->setQuery( $query );
			$tasks = $database->loadObjectList();
			if(!is_array($tasks)) { $tasks = array(); }    
			foreach ($tasks AS $task)
			{
				$htmlProject = htmlspecialchars($task->title);
				$listdata_tasks .= "0;{$htmlProject};{$task->id}\n";
			}
		
            
            
           // ff_setSelectList('tasks', $listdata_tasks);
          
    
}
//onchange when user selects a name from the class with: list
function changetasklist(intStart){
    var fTypes = document.getElementById('ff_elem501'); //this isnt a ff element anymore this is a input name paddress
    var fItems = document.getElementById('ff_elem453'); //this isnt a ff element anymore this is a form input name tasks
    var a = arItems;
    var b, c, d, intItem, intType


    if ( intStart > 0 ) {
        for ( b = 0; b < a.length; b++ ) {
            if ( a[b][1] == intStart )
                intType = a[b][0];
        }

        for ( c = 0; c < fTypes.length; c++ ) {
            if ( fTypes.options[ c ].value == intType )
                fTypes.selectedIndex = c;
        }
    }

    if ( intType == null )
        intType = fTypes.options[ fTypes.selectedIndex ].value;

    fItems.options.length = 0;

    for ( d = 0; d < a.length; d++ ) {
        if ( a[d][0] == intType )
            fItems.options[ fItems.options.length ] = new Option( a[d][2], a[d][1] );

        if ( a[d][1] == intStart )
            fItems.selectedIndex = fItems.options.length - 1;
    }
}

//begin submit code: adds form results to task comments
        global $ff_processor;

$commentData = '<p>Thank you!<br />The Class Makeup Request dated '.$ff_processor->submitted.' has been successfully submitted. <br />
<br />
You will be notified if your request is approved. If your request is approved, your instructor will schedule a new time for your class.</p>
<p><b>The following information was sent:</b><br>';

//Set out Task ID
$id      = "'".$this->maildata[3][4]."'";

//Change Project and Tasks Titles
$this->maildata[2][4]= getPFTitle($this->maildata[2][4],'project');
$this->maildata[3][4]= getPFTitle($this->maildata[3][4],'task');


foreach ($this->maildata as $data) {

     	$commentData.=  $data[_FF_DATA_TITLE]. '&nbsp;'.$data[_FF_DATA_VALUE].'<br /><br />';
}

$commentData.='

Form Title: '.$ff_processor->formrow->title.'<br />'
.'Submitted At: '.$ff_processor->submitted.'<br />
</p>

<p>';

if ($this->record_id != ''){
	$commentData.='Record saved to database with ID: '.$this->record_id.'<br />';
}
$commentData.='</p>';

//GET PF TITLE INFORMATION -----------------------------------------
function getPFTitle($qid,$type){
	global $database;
	
	if($type=="project"){
		$query = "SELECT title FROM #__pf_projects WHERE id =".$qid;
		$database->setQuery( $query );
		$Title = $database->loadResult( );
		return $Title;
	}else{
		$query = "SELECT title FROM #__pf_tasks WHERE id =".$qid;
		$database->setQuery( $query );
		$Title = $database->loadResult( );
		return $Title;
	}
}

$title   = "'".$ff_processor->formrow->title."'";
$content = "'".$commentData."'";
$author  = "'".$this->maildata[6][4]."'";
$now     = time();

    global $database;
	    	$query = "INSERT INTO #__pf_comments VALUES(NULL, $title, $content, 'tasks', $id, $author, $now)";
			$database->setQuery( $query );
			$projects = $database->loadObjectList( );

//Add Makeup Value to PF
            $query = "INSERT INTO #__pf_makeups VALUES(NULL, $author, '0', $id, '0', '0', '0')";
			$database->setQuery( $query );
			$projects = $database->loadObjectList( );


//end submit code: redirects to a page
global $ff_processor;
echo '<div style="background:#eef4d8;font-weight:bold;height:135px;vertical-align:middle;"><img src="images/stories/processing.gif" alt="Processing" style="float:left;vertical-align:middle;margin-right:15px;height:50px;width:50px"/><br style="line-height:0px;"/><h2>Thank you for letting us know about the Makeup Request! </h2><p>We will review it and add it to the comments for the class.<br/><a href="index.php?option=com_projectfork&section=tasks&Itemid=222">Click HERE to return to your class list.</a></p><br style="line-height:16px;"/></div><br style="line-height:15px;"/>';

 
ff_redirectPage('index.php?option=com_projectfork&section=tasks&workspace='.ff_getSubmit('paddress').'&Itemid=222' );

?>
formrequest.jpg 52.89 KB
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.