function cloneCProgram($lCProgSourceID, $lCProgDestID)
 {
     //---------------------------------------------------------------------
     //
     //---------------------------------------------------------------------
     $cdest = new muser_fields_create();
     $ccpSource = new mcprograms();
     $ccpDest = new mcprograms();
     $ccpSource->loadClientProgramsViaCPID($lCProgSourceID);
     $cpSource =& $ccpSource->cprogs[0];
     $ccpDest->loadClientProgramsViaCPID($lCProgDestID);
     $cpDest =& $ccpDest->cprogs[0];
     $lETableSrcID = $cpSource->lEnrollmentTableID;
     $lATableSrcID = $cpSource->lAttendanceTableID;
     $lETableDestID = $cpDest->lEnrollmentTableID;
     $lATableDestID = $cpDest->lAttendanceTableID;
     // clone the enrollment table
     $attr = new stdClass();
     $attr->lSrcTableID = $lETableSrcID;
     $attr->lDestTableID = $lETableDestID;
     $this->cloneUTable($attr);
     // clone the attendance table; first remove the new
     // activity DDL field (it will be cloned appropriately)
     $cdest->loadSingleField($cpDest->lActivityFieldID);
     $cdest->strENPTableName = $cpDest->strAttendanceTable;
     $cdest->removeField();
     $attr->lSrcTableID = $lATableSrcID;
     $attr->lDestTableID = $lATableDestID;
     $this->cloneUTable($attr);
     //--------------------------------------------------
     // now identify the new activity ddl, and set
     // that field name in the parent Client Program
     // record
     //--------------------------------------------------
     // this is a bit kludgy - the activity field will be
     // the first ddl field in the attendance table
     //--------------------------------------------------
     $sqlStr = "SELECT pff_lKeyID\n         FROM uf_fields\n         WHERE pff_lTableID={$lATableDestID}\n            AND pff_enumFieldType='DDL'\n         ORDER BY pff_lKeyID\n         LIMIT 0,1;";
     $query = $this->db->query($sqlStr);
     if ($query->num_rows() != 1) {
         screamForHelp($lATableDestID . ': Attendance table clone failure: unable to detect the activity DDL in cloned table<br>error on line  <b> -- ' . __LINE__ . ' --</b>,<br>file ' . __FILE__ . ',<br>function ' . __FUNCTION__);
     }
     $row = $query->row();
     $lActivityFieldID = (int) $row->pff_lKeyID;
     $sqlStr = "UPDATE cprograms\n         SET cp_lActivityFieldID={$lActivityFieldID}\n         WHERE cp_lKeyID={$lCProgDestID};";
     $query = $this->db->query($sqlStr);
 }