$offering->save();
     // redirect to contract in EditView; signal that temporary version should not be versioned by setting isLinked
     return header("Location: index.php?action=EditView&module=oqc_Contract&record={$contract->id}&isLinked=true");
 } else {
     $contract = new oqc_Contract();
     if ($contract->retrieve($previousContractId)) {
         if ($contract->deleted == 1) {
             //2.0 Contract is in deleted state because user pushed cancel instead of save; just redirect to it
             //$GLOBALS['log']->fatal("CreateContract:going branch 2");
             return header("Location: index.php?action=EditView&module=oqc_Contract&record={$contract->id}&isLinked=true");
         }
         if ($contract->version != $offering->version) {
             //$GLOBALS['log']->error("CreateContract:going branch 3");
             $oldsvnumber = $contract->svnumber;
             $newContract = new oqc_Contract();
             $newContract->loadFromRow($offering->fetched_row);
             unset($newContract->id);
             $newContract->document_id = '';
             $newContract->abbreviation = '';
             global $timedate;
             if (empty($newContract->startdate)) {
                 $newContract->startdate = date($timedate->get_date_format());
             }
             $newContract->svnumber = $oldsvnumber;
             // keep the same svnumber of contract and set the same version as quote
             $newContract->version = intval($offering->version);
             $newContract->deleted = 1;
             $newContract->is_latest = 0;
             $newContract->offeringid = $id;
             $newContract->previousrevision = $contract->id;
             $newContract->nextrevisions = '';