function support_pm_user_week_submit in Support Ticketing System 7
Same name and namespace in other branches
- 6 support_pm/support_pm.module \support_pm_user_week_submit()
Save user's week plan.
File
- support_pm/
support_pm.module, line 678 - Support Project Management. @author Jeremy Andrews <jeremy@tag1consulting.com> @package Support
Code
function support_pm_user_week_submit($form, &$form_state) {
$week = isset($_GET['week']) ? _support_pm_first_day((int) $_GET['week']) : _support_pm_first_day(time());
$dates = _support_pm_dates($week);
$dates['totals'] = t('Totals');
$user = user_load($form_state['values']['uid']);
$clients = _support_available_clients($user);
foreach ($form_state['values'] as $key => $value) {
$key = explode(':', $key);
// Skip values that aren't part of the matrix.
if (count($key) != 2) {
continue;
}
$clid = $key[0];
$day = $key[1];
if (!empty($day)) {
if (isset($clients[$clid]) && $day != 'totals') {
if ($day == 'comment') {
db_merge('support_plan')
->key(array(
'clid' => $clid,
'uid' => $user->uid,
'day' => $week,
))
->fields(array(
'comment' => $value,
))
->execute();
}
else {
db_merge('support_plan')
->key(array(
'clid' => $clid,
'uid' => $user->uid,
'day' => $day,
))
->fields(array(
'hours' => $value,
))
->execute();
}
}
}
}
drupal_goto("user/{$user->uid}/support_pm", array(
'query' => array(
'week' => $week,
),
));
}