Jump to content

Help to return usre tasks listing from Query


danjapro

Recommended Posts

 

Here is my code, All I am trying to do it eco and print out all the task or a limit# of tasks that is assigned to the user page being viewed:

 

However, in return it just prints out this html tag for every user:

<div class="pf_info">'.PFformat::Lang('PFL_NO_TASKS').'</div>

This states that theya re no task found assigned to that user, what am I missing here..some of the users should show tasks listed......

 

<?php


$id = (int) JRequest::GetVar('id');

if($id) {
    // Load objects
    $db     = PFdatabase::GetInstance();
    //$user   = PFuser::GetInstance();
$user =& JFactory::getUser();
    $config = PFconfig::GetInstance();
    
    // Load config params
    
    // Load tasks
$query = "SELECT t.*, u.name, p.title project_name, p.id pid, m.title ms_title FROM #__pf_tasks AS t"
	. "\n LEFT JOIN jos_pf_task_users AS tu ON tu.task_id = t.id"
	. "\n LEFT JOIN jos_users AS u ON u.id = tu.user_id"
	. "\n LEFT JOIN jos_pf_projects AS p ON p.id = t.project"
	. "\n LEFT JOIN jos_pf_milestones AS m ON m.id = t.milestone"
	. "\n WHERE p.id = $id"
	. "\n AND tu.user_id = $id"
	. "\n GROUP BY t.id"
	. "\n ORDER BY t.cdate ASC"
           . "\n LIMIT $limit";
    	   $db->setQuery($query);
    	   //$rows = $db->loadObjectList();
echo $rows;

    $rows = array();
    
    if($user->id) {
        $html = '
        <table class="pf_table adminlist" width="100%" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th align="center">#</th>
                    <th width="50%">'.PFformat::Lang('TITLE').'</th>
                    <th width="25%">'.PFformat::Lang('ASSIGNED_TO').'</th>
                    <th width="10%">'.PFformat::Lang('PRIORITY').'</th>
                    <th width="10%">'.PFformat::Lang('DEADLINE').'</th>
                    <th width="5%">'.PFformat::Lang('PROGRESS').'</th>
                </tr>
            </thead>
            <tbody>';
            
        $k = 0;
        foreach ($rows AS $i => $row)
        {
            JFilterOutput::objectHTMLSafe($row);
     	    $p_edit_s = "";
       	    $p_edit_e = "";
       	    $t_edit_s = "";
       	    $t_edit_e = "";
          	  
    		  
    		$deadline = PFformat::Lang('NOT_SET');
    		if($row->edate) $deadline = PFformat::ToDate($row->edate);
    		  
    		if($tlink == 1) {
    		    $t_edit_s = "<a href='".PFformat::Link("section=tasks&task=display_details&id=".$row->id)."'>";
    		  	$t_edit_e = "</a>";
    		}
          	
          	$html .= '
          	<tr class="pf_row'.$k.' row'.$k.' sectiontableentry'.($k+1).'">
          	    <td>'.($i + 1).'</td>
     	        <td>'.$t_edit_s.$row->title.$t_edit_e.'</td>
     	        <td>'.$row->name.'</td>
     	        <td>'.$priority.'</td>
     	        <td>'.$deadline.'</td>
     	        <td>'.$row->progress.'%</td>
          	</tr>';
          	$k = 1 - $k;
        }
        
        if(!count($rows)) {
            $html .= '
      	    <tr class="pf_row0">
      	        <td colspan="7" align="center" style="text-align:center"><div class="pf_info">'.PFformat::Lang('PFL_NO_TASKS').'</div></td>
  	        </tr>';
        }
        
        $html .= '</tbody></table>';

        echo $html;
        unset($html, $rows);
    }
}
?>

  :confused:

I have here is my sql update and still no results.

 

    // Load tasks
$query = "SELECT t.*, u.name, p.title project_name, p.id pid, m.title ms_title FROM #__pf_tasks AS t"
	. "\n LEFT JOIN jos_pf_task_users AS tu ON tu.task_id = t.id"
	. "\n LEFT JOIN jos_users AS u ON u.id = tu.user_id"
	. "\n LEFT JOIN jos_pf_projects AS p ON p.id = t.project"
	. "\n LEFT JOIN jos_pf_milestones AS m ON m.id = t.milestone"
	. "\n WHERE p.id = $id"
	//. "\n AND tu.user_id = $userid"
	. "\n GROUP BY t.id"
	. "\n ORDER BY t.cdate ASC"
           . "\n LIMIT $limit";
    	   $db->setQuery($query);
    	   $rows = $db->loadObjectList();
echo $rows;

I can't see issue anywhere....SQL help

So, let me get this straight, because I'm not sure you understood my question.  You typed that query into the database console, and it returned the rows you expected.  If that is the case, then you will have to look into your db class to see where the error is.  Perhaps your database class has an error/de-bug function.  I would run that to see if there is an error.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.