Example #1
0
 public static function newEntry($program, $user, $prior_year = false)
 {
     $entry = new Entry();
     $entry->year = $program->year;
     $entry->Top_Company__c = $program->id;
     $entry->Account__c = $user->accountId;
     $entry->Contact__c = $user->contactId;
     if ($prior_year) {
         $entry->Information_Only__c = 'true';
         $entry->cansave = 'true';
     }
     foreach ($program->questions as $q) {
         $resp = new Response();
         $resp->setQuestion($q);
         $entry->addResponse($resp);
     }
     $entry->save();
     return $entry;
 }