function support_pm_user_week in Support Ticketing System 7
Same name and namespace in other branches
- 6 support_pm/support_pm.module \support_pm_user_week()
Page callback.
1 string reference to 'support_pm_user_week'
- support_pm_menu in support_pm/
support_pm.module - Implements hook_menu(). TODO: Include date in 'view' and 'edit' tabs
File
- support_pm/
support_pm.module, line 630 - Support Project Management. @author Jeremy Andrews <jeremy@tag1consulting.com> @package Support
Code
function support_pm_user_week($form, &$form_state, $user) {
$week = isset($_GET['week']) ? (int) $_GET['week'] : time();
$dates = _support_pm_dates($week);
drupal_add_js(array(
'support_pm' => array(
'unload_warning' => variable_get('support_pm_unload_warning', TRUE),
'elapsed' => 0,
),
), 'setting');
drupal_add_js(drupal_get_path('module', 'support_pm') . '/support_pm.js');
$clients = _support_available_clients($user);
$clients['totals'] = '<strong>' . t('Totals') . '</strong>';
foreach ($clients as $clid => $name) {
$form['client'][$clid] = array(
'#markup' => $name,
);
foreach ($dates as $date => $day) {
$hours = db_query('SELECT hours FROM {support_plan} WHERE clid = :client AND uid = :uid AND day = :day', array(
':client' => $clid,
':uid' => $user->uid,
':day' => $date,
))
->fetchField();
$form['textfields'][$clid]["{$clid}:{$date}"] = array(
'#type' => 'textfield',
'#size' => '2',
'#default_value' => $hours ? $hours : 0,
'#disabled' => $clid == 'totals' ? TRUE : FALSE,
);
}
$form['textfields'][$clid]["{$clid}:totals"] = array(
'#type' => 'textfield',
'#size' => '2',
'#disabled' => TRUE,
'#default_value' => 0,
);
if ($clid != 'totals') {
$comment = db_query('SELECT comment FROM {support_plan} WHERE clid = :client AND uid = :uid AND day = :day', array(
':client' => $clid,
':uid' => $user->uid,
':day' => _support_pm_first_day($week),
))
->fetchField();
$form['textfields'][$clid]["{$clid}:comment"] = array(
'#type' => 'textfield',
'#size' => '20',
'#disabled' => FALSE,
'#default_value' => $comment,
);
}
}
$form['uid'] = array(
'#type' => 'hidden',
'#value' => $user->uid,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save plan'),
);
return $form;
}