0

次の表が表示されます

Task No.    Person            Company           Project Task               Date Tracked Total Time  Comments
14.1    vaish, arpit          ABC-TecHolding    Relaunch Websitnalysis     2013-02-12   19:21:03    
14.2    vaish, arpit          Sugarion          New Opensource Server      2013-02-12   19:21:03    
14.6    vaish, arpit          Sugarion          New Opensource Server      2013-02-12   19:21:03    
5.26    Projectmanager, Paul  ABC-Tec Holding   Relaunch Website           2010-03-13   03:40:16    
5.27    Projectmanager, Paul  ABC-Tec Holding   Relaunch Website           2010-03-12   03:40:16    
5.27    Projectmanager, Paul  ABC-Tec Holding   Relaunch Website           2010-03-13   03:40:16    
8.2     Worker, Willi         Customers ACME    Hosting Data transfer      2010-03-13   00:21:18    
14.2    Worker, Willi         Sugarion          New Opensource Server      2013-02-06   00:21:18    fyhbvghjukjjkhhlhh uuiuijujj jookljh

これは私のforeachループです

foreach($result123 as $key=>$task) {
            $time=$this->addtime($task['name'],$range['start'],$range['end']); //to calculate total time per user in time range

            $diff       = $task['estimated']+$task['tracked'];
            $diffSign   = $diff > 0 ? '-' : '+';

            $table->addRow(array(
                'number'    => $task['tasknumber'].' '.$task['id_project'] ,
                'person'=> $task['name'],
                'customer'      => $task['company'],
                'project'       => $task['project'],
                'task'      => $task['task'],
                'date'      => $task['date_tracked'],
                'tracked'   => $task['workload_tracked'],
                'Total_Time'        => $time,
                'comment'=>$task['comment']
            ));

        }

列の合計時間は、1 人あたりの追跡時間の合計を示します。合計時間を Person ごとに 1 回だけ表示し、行ごとに何度も表示しないようにしたいと考えています。前もって感謝します。

4

2 に答える 2

0
$name = '';

foreach($result123 as $key=>$task) {


if ($name == $task['name']) {
$time = '';
}
elseif ($name != $task['name']) {
$time=$this->addtime($task['name'],$range['start'],$range['end']); 
$name = $task['name'];
}


$diff= $task['estimated']+$task['tracked'];
$diffSign= $diff > 0 ? '-' : '+';

$table->addRow(array(
'number'    => $task['tasknumber'].' '.$task['id_project'] ,
'person'=> $task['name'],
'customer'      => $task['company'],
'project'       => $task['project'],
'task'      => $task['task'],
'date'      => $task['date_tracked'],
'tracked'   => $task['workload_tracked'],
'Total_Time'        => $time,
'comment'=>$task['comment']
));

}

それでいいと思います。

于 2013-02-12T06:46:57.170 に答える
0

それが私がそれを行う方法です(疑似コード):

  • 「チェック済み」の人の配列を設定する
  • Foreach レコード:
  • 「チェック済み」配列に人はいますか?
  • はいの場合は、続けてください。
  • いいえの場合、合計を表示し、「チェック済み」の人に人を追加します。

そしてPHPで:(私がそれを正しければ)

  $checked = array();

  foreach($result123 as $key=>&$task) {
        $time=$this->addtime($task['name'],$range['start'],$range['end']); //to calculate total time per user in time range

        $diff       = $task['estimated']+$task['tracked'];
        $diffSign   = $diff > 0 ? '-' : '+';

        if (in_array($task['name'],$checked) $time =0;
        else {
              $checked[] = $task['name'];
        }

        $table->addRow(array(
            'number'    => $task['tasknumber'].' '.$task['id_project'] ,
            'person'=> $task['name'],
            'customer'      => $task['company'],
            'project'       => $task['project'],
            'task'      => $task['task'],
            'date'      => $task['date_tracked'],
            'tracked'   => $task['workload_tracked'],
            'Total_Time'        => $time,
            'comment'=>$task['comment']
        ));

    }
于 2013-02-12T06:40:57.813 に答える