32
32
public function executeStafftypes(sfWebRequest $request)
34
34
$this->ag_staff_types = Doctrine_Core::getTable('agStaffResourceType')
38
38
$this->staffTypeForm = new PluginagStaffTypeForm();
40
40
if ($request->isMethod(sfRequest::POST)) {
41
41
$this->staffTypeForm->bind($request->getParameter($this->staffTypeForm->getName()),
42
$request->getFiles($this->staffTypeForm->getName()));
42
$request->getFiles($this->staffTypeForm->getName()));
43
43
if ($this->staffTypeForm->isValid()) {
44
44
$this->staffTypeForm->save();
80
80
/** @todo take into consideration app_display */
81
81
$staffStatusOptions = agDoctrineQuery::create()
82
->select('s.staff_resource_status, s.staff_resource_status')
83
->from('agStaffResourceStatus s')
84
->execute(array(), 'key_value_pair');
82
->select('s.staff_resource_status, s.staff_resource_status')
83
->from('agStaffResourceStatus s')
84
->execute(array(), 'key_value_pair');
85
85
//the above query returns an array of keys matching their values.
86
86
//ideally the above should exist in a global param,
87
87
//so the database is not queried all the time
88
88
$staffStatusOptions['all'] = 'all';
89
89
if ($request->getParameter('status') && in_array($request->getParameter('status'),
90
$staffStatusOptions)) {
90
$staffStatusOptions)) {
91
91
$this->status = $request->getParameter('status');
93
93
$this->statusWidget = new sfForm();
114
114
// $staffArray = apc_fetch('staffArray');
117
$staffArray = agListHelper::getStaffList(null, $this->status, $this->sort, $this->order, $this->limit);
117
$staffArray = agListHelper::getStaffList(null, $this->status, $this->sort, $this->order,
118
119
// apc_store('staffArray', $staffArray);
119
120
// } this will not work currently on update, there needs to be a hook/callback
235
236
$this->forward404Unless(
236
237
$this->agStaff = Doctrine::getTable('AgStaff')->find($request->getParameter('id')),
237
sprintf('Object ag_staff does not exist (%s).',
238
$request->getParameter('id'))
238
sprintf('Object ag_staff does not exist (%s).',
239
$request->getParameter('id'))
241
242
$this->ag_person_name_types = Doctrine::getTable('agPersonNameType')
244
245
$this->ag_phone_contact_types = Doctrine::getTable('agPhoneContactType')
247
248
$this->ag_email_contact_types = Doctrine::getTable('agEmailContactType')
250
251
$this->ag_language_formats = Doctrine::getTable('agLanguageFormat')
253
254
$this->ag_address_contact_types = Doctrine::getTable('agAddressContactType')
258
259
//$this->agStaff = $this->pager->getResults()->getFirst();
309
310
$this->forward404unless($request->isXmlHttpRequest());
310
311
if ($request->hasParameter('staffResourceId')) {
311
312
$staffResource = agDoctrineQuery::create()
312
->delete('agStaffResource sr')
313
->where('id = ?', $request->getParameter('staffResourceId'))
313
->delete('agStaffResource sr')
314
->where('id = ?', $request->getParameter('staffResourceId'))
349
350
$this->forward404Unless(
350
351
$ag_staff = Doctrine::getTable('AgStaff')->find($request->getParameter('id')),
351
sprintf('Object ag_staff does not exist (%s).',
352
$request->getParameter('id'))
352
sprintf('Object ag_staff does not exist (%s).',
353
$request->getParameter('id'))
355
356
$ag_person = $ag_staff->getAgPerson();
373
374
$this->forward404Unless(
374
375
$ag_staff = Doctrine::getTable('AgStaff')->find($request->getParameter('id')),
375
sprintf('Object ag_staff does not exist (%s).',
376
$request->getParameter('id'))
376
sprintf('Object ag_staff does not exist (%s).',
377
$request->getParameter('id'))
379
380
$ag_person = $ag_staff->getAgPerson();
407
408
$this->forward404Unless(
408
409
$ag_staff = Doctrine::getTable('AgStaff')->find($request->getParameter('id')),
409
sprintf('Object ag_staff does not exist (%s).',
410
$request->getParameter('id'))
410
sprintf('Object ag_staff does not exist (%s).',
411
$request->getParameter('id'))
413
414
$ag_person = $ag_staff->getAgPerson();
476
477
$ag_staff = $form->save();
477
478
$refAgStaff = $ag_staff->getAgStaff();
478
479
$staffObj = agDoctrineQuery::create()
480
->where('s.person_id=?', $ag_staff->id)
481
->where('s.person_id=?', $ag_staff->id)
482
483
LuceneRecord::updateLuceneRecord($staffObj);
484
485
//$staff_id = $ag_staff->getAgStaff()->getFirst()->getId();
485
486
//not an object? first it's a collection, now not an object if i just get one
487
488
$staff_id = Doctrine::getTable('agStaff')->createQuery('a')
490
->where('a.person_id = ?', $ag_staff->id)
491
->where('a.person_id = ?', $ag_staff->id)
493
494
//get id of STAFF person from the saved, extended agpersonform.
494
495
// Check if the Save and Create Another button was used to submit. If it was, redirect to staff/new.
512
513
// Free up some memory by getting rid of the agFacilityExporter object.
513
514
unset($staffExporter);
514
515
$this->getResponse()->setHttpHeader('Content-Type', 'application/vnd.ms-excel');
515
$this->getResponse()->setHttpHeader('Content-Disposition', 'attachment;filename="' . $exportResponse['fileName'] . '"');
516
$this->getResponse()->setHttpHeader('Content-Disposition',
517
'attachment;filename="' . $exportResponse['fileName'] . '"');
517
519
$exportFile = file_get_contents($exportResponse['filePath']);
526
528
//TODO: put this in the global actions file?
527
529
public function executeCancelimport(sfWebRequest $request)
529
$abortFlagId = 'aborted';//implode('_', array('abort', $this->moduleName, 'import'));
531
$abortFlagId = 'aborted'; //implode('_', array('abort', $this->moduleName, 'import'));
530
532
//$this->getContext()->set($abortFlagId, TRUE);
532
533
//TODO: get import data directory root info from global param
533
534
$importDataRoot = sfConfig::get('sf_upload_dir');
534
535
$importDir = $importDataRoot . DIRECTORY_SEPARATOR . $this->moduleName;
551
552
public function executeImport(sfWebRequest $request)
553
// $this->timer = time();
554
// $this->timer = time();
555
556
$uploadedFile = $_FILES['import'];
557
$importPath = sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . $uploadedFile['name'];
558
if (!move_uploaded_file($uploadedFile['tmp_name'], $importPath)) {
559
return sfView::ERROR;
558
print("<pre>" . print_r($_FILES, true) . "</pre>");
560
$this->importPath = sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . $uploadedFile['name'];
562
print("<pre>Move {$uploadedFile['tmp_name']} to " . $this->importPath . "</pre>");
563
if (!move_uploaded_file($uploadedFile['tmp_name'], $this->importPath)) {
564
print("<pre>Failed to move {$uploadedFile['tmp_name']} to ".$this->importPath."</pre>");
565
//return sfView::ERROR;
562
$this->importPath = $importPath;
565
569
// fires event so listener will process the file (see ProjectConfiguration.class.php)
566
// $this->dispatcher->notify(new sfEvent($this, 'import.staff_file_ready'));
570
//$this->dispatcher->notify(new sfEvent($this, 'import.staff_file_ready'));
567
571
// TODO: eventually use this ^^^ to replace this vvv.
569
573
$this->importer = agStaffImportNormalization::getInstance(NULL, agEventHandler::EVENT_DEBUG);
570
575
$this->importer->processXlsImportFile($this->importPath);
574
579
$left = $this->importer->processBatch();
577
582
$this->importer->concludeImport();
579
584
// removes the file from the server
580
unlink($this->importPath);
583
// $this->dispatcher->notify(new sfEvent($this, 'import.start'));
585
//unlink($this->importPath);
587
//$this->dispatcher->notify(new sfEvent($this, 'import.start'));
585
588
//unset($this->importer);
586
// $this->timer = (time() - $this->timer);
589
//$this->timer = (time() - $this->timer);