/** * Load an object from its id and create a new one in database * * @param int $fromid of object to clone * @return int id of clone */ function createFromClone($fromid) { global $user, $langs; $error = 0; $object = new Lead($this->db); $this->db->begin(); // Load source object $object->fetch($fromid); $object->ref = $object->getNextNumRef(); $object->ref_int = $this->ref_int; // Create clone $result = $object->create($user); // Other options if ($result < 0) { $this->error = $object->error; $error++; } if (!$error) { } // End if (!$error) { $this->db->commit(); return $object->id; } else { $this->db->rollback(); return -1; } }