- Timestamp:
- 22/11/07 05:59:55 (4 years ago)
- File:
-
- 1 edited
-
roster/trunk/roster.module (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
roster/trunk/roster.module
r120 r121 21 21 'type' => MENU_LOCAL_TASK 22 22 ); 23 $items[] = array( 24 'path' => 'node/'.arg(1).'/csv', 25 'title' => t('csv export'), 26 'callback' => 'roster_csv', 27 'access' => user_access('assign booths'), 28 'type' => MENU_LOCAL_TASK 29 ); 23 30 } 24 31 } … … 165 172 $form['submit'] = array ( 166 173 '#type' => 'submit', 167 '#value' => t(' Go'),174 '#value' => t('Save'), 168 175 ); 169 176 … … 182 189 $form['person'] = array( 183 190 '#type' => 'select', 184 '#title' => t(' '),191 '#title' => t('Working'), 185 192 '#options' => $users, 186 193 ); 187 194 $form['notes'] = array( 188 195 '#type' => 'textfield', 189 '#title' => t(' notes')196 '#title' => t('Notes') 190 197 ); 191 198 $form['bid'] = array( … … 199 206 $form['save'] = array( 200 207 '#type' => 'submit', 201 '#value' => t(' save')208 '#value' => t('Save') 202 209 ); 203 210 $form['aid'] = array( … … 207 214 if ($selected != NULL){ 208 215 $form['aid']['#value'] = $selected->aid; 209 $form['notes']['# value'] = $selected->notes;216 $form['notes']['#default_value'] = $selected->notes; 210 217 $form['person']['#default_value'] = $selected->person; 211 218 } … … 248 255 249 256 // Format roster table for display 250 $table = "<table ><tr><th>Booth</th><th>Morning</th><th>Afternoon</th></tr>";257 $table = "<table border='1px'><tr><th>Booth</th><th>Morning</th><th>Afternoon</th></tr>"; 251 258 foreach ($booths as $booth){ 252 $table .= "<tr><td>".l($booth->name,'node/'.arg(1).'/booth/'.$booth->bid)."</td>"; 253 $people = ($roster[$booth->bid] != NULL)?$roster[$booth->bid][0]:NULL; 259 $table .= "<tr><td>".l($booth->name,'node/'.arg(1).'/booth/'.$booth->bid). 260 "<br/>".$booth->last_votes.'/'.$booth->last_votes_total."</td>"; 261 262 $people = ($roster[$booth->bid] != NULL && $roster[$booth->bid][0] != NULL)?$roster[$booth->bid][0]:array(); 254 263 $table .= "<td>"; 255 264 foreach ($people as $person) 256 drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, $person, $booth->bid, 0);265 $table .= drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, $person, $booth->bid, 0); 257 266 // A new one too 258 drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, NULL, $booth->bid, 0);267 $table .= drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, NULL, $booth->bid, 0); 259 268 $table .= "</td>"; 260 $people = ($roster[$booth->bid] != NULL)?$roster[$booth->bid][1]:NULL; 269 270 $people = ($roster[$booth->bid] != NULL && $roster[$booth->bid][1] != NULL)?$roster[$booth->bid][1]:array(); 261 271 $table .= "<td>"; 262 272 foreach ($people as $person) 263 drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, $person, $booth->bid, 1)273 $table .= drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, $person, $booth->bid, 1); 264 274 // A new one too 265 drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, NULL, $booth->bid, 1)275 $table .= drupal_get_form('roster_assignment_form'.$rosterFormId++, $users, NULL, $booth->bid, 1); 266 276 $table .= "</td>"; 267 277 $table .= "</tr>"; … … 276 286 $node->content['body'] = NULL; 277 287 return $node; 288 } 289 290 function roster_csv($node, $teaser = FALSE, $page = FALSE) { 291 if (!user_access('assign booths')) 292 return FALSE; 293 $node = node_load(arg(1)); 294 // Get roster data 295 $booths = roster_get_booths($node->nid); 296 $roster = roster_get_roster($node->nid); 297 $_users = roster_get_group_members($node->group_id); 298 $users = array(''=>'None'); 299 foreach ($_users[0] as $contact){ 300 $users[$contact['contact_id']] = $contact['sort_name']; 301 } 302 drupal_set_header('Content-Type: text/csv; charset=utf-8'); 303 drupal_set_header('Content-Disposition: attachment; filename="roster.csv";'); 304 305 print '"Booth","Morning shift","Afternoon shift"'."\n"; 306 foreach ($booths as $booth){ 307 $morn = $roster[$booth->bid][0]; 308 $after = $roster[$booth->bid][1]; 309 print '"'.$booth->name.' '.$booth->last_votes.'/'.$booth->last_votes_total.'","'; 310 $once = false; 311 foreach ($morn as $p){ 312 if ($once)print ' & '; 313 print $users[$p->person].'('.$p->notes.')'; 314 $once = true; 315 } 316 print '","'; 317 $once = false; 318 foreach ($after as $p){ 319 if ($once)print ' & '; 320 print $users[$p->person].'('.$p->notes.')'; 321 $once = true; 322 } 323 print "\"\n"; 324 } 278 325 } 279 326 … … 322 369 $sort = array('sort_name' => 'ASC'); 323 370 324 $contacts =& crm_contact_search( $params, $return_properties, $sort );371 $contacts =& crm_contact_search( $params, $return_properties, $sort , 0, 200); 325 372 if (!$contacts) return false; 326 373 return $contacts;
Note: See TracChangeset
for help on using the changeset viewer.
