これはたくさんあるかもしれませんが、うまくいけば、私はすべてを正しく伝えることができます。
このタイムトラッカーを購入しました:http://codecanyon.net/item/the-simple-clientproject-tracker/48930
私がやろうとしているのは、すべてのクライアントとそれに関連するプロジェクトをすべて1つのページに一覧表示することです。構築されたため、サイドバーで個別のリストとしてのみ個別に表示できます。または、クライアントをクリックすると、その個別のクライアントのプロジェクトが表示されます。ただし、すべてのプロジェクトのすべてのクライアントを含むマスターリストの方が優れています。これは、私が1つのページで達成しようとしていることです。
相互に通信するテーブルが3つあるようです[project、clients、project_clients]
プロジェクト列:[project_id、name、unique_id]
クライアント列:[client_id、name]
Project_clients列:[project_id、client_id]
既存の機能は次のとおりです。
/*
This returns the list of clients that are created with a link to view a list of their projects
*/
function getClientList(){
global $db,$secret;
$return = '';
$return = '<ul class="client_list">';
$query = "SELECT * FROM clients";
$res = $db->query($query,'assoc');
if(!empty($res)){
foreach($res as $row):
$return .= '<li><a href="client.php?client='.$row['client_id'].'" class="clientname" title="This client has '.tot_projects($row['client_id']).' projects associated to them">'.stripslashes($row['name']).'</a></li>';
endforeach;
}else{
$return .= '<li>No Clients Yet</li>';
}
$return .= '</ul>';
return $return;
}
-
/*
This will grab the each time a track was created and display it
@param MD5 $unique_id
*/
function getClientProjectTable($client_id){
global $db;
$clientLog = '';
//Get project_id
$query = "SELECT client_id FROM clients WHERE client_id = ".$db->prep($client_id);
$res = $db->query($query,'assoc');
$query = "SELECT project_id FROM project_clients WHERE client_id =".$db->prep($res[0]['client_id'])." ";
$resT = $db->query($query,'assoc');
//set vars
$thead = '<table id="timeLog" colspacing="0" colpadding="0" border="0">';
$thead .= '<thead><tr><th>Name</th><th>Hours</th><th></th></tr>
<tbody>';
$count_row = 0;
$alt = '';
$date = '';
$prevDate = '';
if($resT != false){
foreach($resT as $row):
$alt = ($count_row%2 == 0) ?'odd': '';
//Grab each track and process how much time has passed for it
$query = "SELECT name,unique_id FROM project WHERE project_id = ".$db->prep($row['project_id']);
$resProject = $db->query($query,'assoc');
$actions = '<a href="invoicebook.php?project_id='.urlencode($resProject[0]['unique_id']).'"><img src="images/invoice.png" alt="Invoice" style="vertical-align:middle;"/></a>';
//setup any actions to the row
$actions .= '<form name="projectDeleteAssign" action="process.php" method="post" style="display:inline; margin:0;" onsubmit="return confirmClientDelete();">
<input type="hidden" name="hiddenProjectID" value="'.$row['project_id'].'" />
<input type="hidden" name="hiddenClientID" value="'.$res[0]['client_id'].'" />
<input type="hidden" name="confirmDeleted" value="true" />
<input type="submit" name="action" class="delete" value="Delete Assignment" />
</form>';
//Check and see if you should check time based on if track has ended or is still running
$clientLog .= '<tr class="'.$alt.'"><td><a href="index.php?track='.urlencode($resProject[0]['unique_id']).'">'.stripslashes($resProject[0]['name']).'</a></td><td>'.tot_time($resProject[0]['unique_id'],'hours').'</td><td>'.$actions.'</td></tr>';
$count_row++;
endforeach;
}else{
$clientLog .= '<tr><td colspan="3">No Projects added to this client yet.</td></tr>';
}
$tfoot = '</tbody></table>';
return $thead.$clientLog.$tfoot;
}
-
/*
This returns the list of projects that are created with a link to view a detail view of each
*/
function getProjectList(){
global $db,$secret;
$return = '';
$return = '<ul>';
$query = "SELECT * FROM project";
$res = $db->query($query,'assoc');
if(!empty($res)){
foreach($res as $row):
$u_id = md5(utf8_encode($row['project_id'].$secret));
$return .= '<li><a href="index.php?track='.$u_id.'" class="'.bResult($row['startStop_track'],'timeStart','time').'">'.stripslashes($row['name']).'</a></li>';
endforeach;
}else{
$return .= '<li>No Projects Yet</li>';
}
$return .= '</ul>';
return $return;
}
-
/**
*
* This will return the total number of projects
*/
function tot_projects($client = null){
global $db;
if($client){
$query = "SELECT count(p.project_id) FROM project p INNER JOIN project_clients pc ON pc.project_id = p.project_id WHERE client_id = ".$db->prep($client);
}else{
$query = "SELECT count(project_id) FROM project";
}
$res = $db->query($query,'row');
return $res[0][0];
}
何か案は?