Fixing style errors.
This commit is contained in:
parent
84d8ca4b33
commit
458c1e2174
@ -375,132 +375,132 @@ if ($action == 'confirm_generateinvoice')
|
|||||||
|
|
||||||
if (!$error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
if ($generateinvoicemode=='onelineperuser') {
|
if ($generateinvoicemode=='onelineperuser') {
|
||||||
$arrayoftasks = array();
|
$arrayoftasks = array();
|
||||||
foreach ($toselect as $key => $value)
|
foreach ($toselect as $key => $value)
|
||||||
{
|
{
|
||||||
// Get userid, timepent
|
// Get userid, timepent
|
||||||
$object->fetchTimeSpent($value);
|
$object->fetchTimeSpent($value);
|
||||||
$arrayoftasks[$object->timespent_fk_user]['timespent'] += $object->timespent_duration;
|
$arrayoftasks[$object->timespent_fk_user]['timespent'] += $object->timespent_duration;
|
||||||
$arrayoftasks[$object->timespent_fk_user]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
|
$arrayoftasks[$object->timespent_fk_user]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($arrayoftasks as $userid => $value)
|
|
||||||
{
|
|
||||||
$fuser->fetch($userid);
|
|
||||||
//$pu_ht = $value['timespent'] * $fuser->thm;
|
|
||||||
$username = $fuser->getFullName($langs);
|
|
||||||
|
|
||||||
// Define qty per hour
|
|
||||||
$qtyhour = round($value['timespent'] / 3600, 2);
|
|
||||||
$qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
|
|
||||||
|
|
||||||
// If no unit price known
|
|
||||||
if (empty($pu_ht))
|
|
||||||
{
|
|
||||||
$pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add lines
|
foreach ($arrayoftasks as $userid => $value)
|
||||||
$lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
|
|
||||||
|
|
||||||
// Update lineid into line of timespent
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id;
|
|
||||||
$sql .= ' WHERE rowid in ('.join(',', $toselect).') AND fk_user = '.$userid;
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if (!$result)
|
|
||||||
{
|
{
|
||||||
$error++;
|
$fuser->fetch($userid);
|
||||||
setEventMessages($db->lasterror(), null, 'errors');
|
//$pu_ht = $value['timespent'] * $fuser->thm;
|
||||||
break;
|
$username = $fuser->getFullName($langs);
|
||||||
|
|
||||||
|
// Define qty per hour
|
||||||
|
$qtyhour = round($value['timespent'] / 3600, 2);
|
||||||
|
$qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
|
||||||
|
|
||||||
|
// If no unit price known
|
||||||
|
if (empty($pu_ht))
|
||||||
|
{
|
||||||
|
$pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add lines
|
||||||
|
$lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
|
||||||
|
|
||||||
|
// Update lineid into line of timespent
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id;
|
||||||
|
$sql .= ' WHERE rowid in ('.join(',', $toselect).') AND fk_user = '.$userid;
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if (!$result)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
setEventMessages($db->lasterror(), null, 'errors');
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
elseif ($generateinvoicemode=='onelineperperiod') {
|
||||||
elseif ($generateinvoicemode=='onelineperperiod') {
|
$arrayoftasks = array();
|
||||||
$arrayoftasks = array();
|
foreach ($toselect as $key => $value)
|
||||||
foreach ($toselect as $key => $value)
|
{
|
||||||
{
|
// Get userid, timepent
|
||||||
// Get userid, timepent
|
$object->fetchTimeSpent($value);
|
||||||
$object->fetchTimeSpent($value);
|
$arrayoftasks[$object->timespent_id]['timespent'] = $object->timespent_duration;
|
||||||
$arrayoftasks[$object->timespent_id]['timespent'] = $object->timespent_duration;
|
$arrayoftasks[$object->timespent_id]['totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
|
||||||
$arrayoftasks[$object->timespent_id]['totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm;
|
$arrayoftasks[$object->timespent_id]['note'] = $object->timespent_note;
|
||||||
$arrayoftasks[$object->timespent_id]['note'] = $object->timespent_note;
|
$arrayoftasks[$object->timespent_id]['user'] = $object->timespent_fk_user;
|
||||||
$arrayoftasks[$object->timespent_id]['user'] = $object->timespent_fk_user;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($arrayoftasks as $timespent_id => $value)
|
|
||||||
{
|
|
||||||
$userid = $value['user'];
|
|
||||||
$fuser->fetch($userid);
|
|
||||||
//$pu_ht = $value['timespent'] * $fuser->thm;
|
|
||||||
$username = $fuser->getFullName($langs);
|
|
||||||
|
|
||||||
// Define qty per hour
|
|
||||||
$qtyhour = round($value['timespent'] / 3600, 2);
|
|
||||||
$qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
|
|
||||||
|
|
||||||
// If no unit price known
|
|
||||||
if (empty($pu_ht))
|
|
||||||
{
|
|
||||||
$pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add lines
|
foreach ($arrayoftasks as $timespent_id => $value)
|
||||||
$lineid = $tmpinvoice->addline($value['note'], $pu_ht, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
|
|
||||||
|
|
||||||
// Update lineid into line of timespent
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id;
|
|
||||||
$sql .= ' WHERE rowid in ('.join(',', $toselect).') AND fk_user = '.$userid;
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if (!$result)
|
|
||||||
{
|
{
|
||||||
$error++;
|
$userid = $value['user'];
|
||||||
setEventMessages($db->lasterror(), null, 'errors');
|
$fuser->fetch($userid);
|
||||||
break;
|
//$pu_ht = $value['timespent'] * $fuser->thm;
|
||||||
|
$username = $fuser->getFullName($langs);
|
||||||
|
|
||||||
|
// Define qty per hour
|
||||||
|
$qtyhour = round($value['timespent'] / 3600, 2);
|
||||||
|
$qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
|
||||||
|
|
||||||
|
// If no unit price known
|
||||||
|
if (empty($pu_ht))
|
||||||
|
{
|
||||||
|
$pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add lines
|
||||||
|
$lineid = $tmpinvoice->addline($value['note'], $pu_ht, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
|
||||||
|
|
||||||
|
// Update lineid into line of timespent
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id;
|
||||||
|
$sql .= ' WHERE rowid in ('.join(',', $toselect).') AND fk_user = '.$userid;
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if (!$result)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
setEventMessages($db->lasterror(), null, 'errors');
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
elseif ($generateinvoicemode=='onelinepertask') {
|
||||||
elseif ($generateinvoicemode=='onelinepertask') {
|
$arrayoftasks = array();
|
||||||
$arrayoftasks = array();
|
foreach ($toselect as $key => $value)
|
||||||
foreach ($toselect as $key => $value)
|
{
|
||||||
{
|
// Get userid, timepent
|
||||||
// Get userid, timepent
|
$object->fetchTimeSpent($value);
|
||||||
$object->fetchTimeSpent($value);
|
// $object->id is the task id
|
||||||
// $object->id is the task id
|
$arrayoftasks[$object->id]['timespent'] += $object->timespent_duration;
|
||||||
$arrayoftasks[$object->id]['timespent'] += $object->timespent_duration;
|
$arrayoftasks[$object->id]['totalvaluetodivideby3600'] += $object->timespent_duration * $object->timespent_thm;
|
||||||
$arrayoftasks[$object->id]['totalvaluetodivideby3600'] += $object->timespent_duration * $object->timespent_thm;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($arrayoftasks as $task_id => $value)
|
|
||||||
{
|
|
||||||
$ftask = new Task($db);
|
|
||||||
$ftask->fetch($task_id);
|
|
||||||
// Define qty per hour
|
|
||||||
$qtyhour = round($value['timespent'] / 3600, 2);
|
|
||||||
$qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
|
|
||||||
|
|
||||||
// If no unit price known
|
|
||||||
if (empty($pu_ht))
|
|
||||||
{
|
|
||||||
$pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add lines
|
foreach ($arrayoftasks as $task_id => $value)
|
||||||
$lineName = $ftask->ref.' - '.$ftask->label;
|
|
||||||
$lineid = $tmpinvoice->addline($lineName, $pu_ht, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
|
|
||||||
|
|
||||||
// Update lineid into line of timespent
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id;
|
|
||||||
$sql .= ' WHERE rowid in ('.join(',', $toselect).')';
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if (!$result)
|
|
||||||
{
|
{
|
||||||
$error++;
|
$ftask = new Task($db);
|
||||||
setEventMessages($db->lasterror(), null, 'errors');
|
$ftask->fetch($task_id);
|
||||||
break;
|
// Define qty per hour
|
||||||
|
$qtyhour = round($value['timespent'] / 3600, 2);
|
||||||
|
$qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
|
||||||
|
|
||||||
|
// If no unit price known
|
||||||
|
if (empty($pu_ht))
|
||||||
|
{
|
||||||
|
$pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add lines
|
||||||
|
$lineName = $ftask->ref.' - '.$ftask->label;
|
||||||
|
$lineid = $tmpinvoice->addline($lineName, $pu_ht, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
|
||||||
|
|
||||||
|
// Update lineid into line of timespent
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id;
|
||||||
|
$sql .= ' WHERE rowid in ('.join(',', $toselect).')';
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if (!$result)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
setEventMessages($db->lasterror(), null, 'errors');
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user