/**
	 * Returns an unsaved copy of the milestone. Copies everything except open/closed state,
	 * anything that needs the task to have an id (like tags, properties, tasks),
	 * administrative info like who created the milestone and when, etc.
	 *
	 * @param ProjectMilestone $milestone
	 * @return ProjectMilestone
	 */
	function createMilestoneCopy(ProjectMilestone $milestone) {
		$new = new ProjectMilestone();
		$new->setObjectName($milestone->getObjectName());
		$new->setDescription($milestone->getDescription());
		$new->setIsUrgent($milestone->setIsUrgent());
		$new->setDueDate($milestone->getDueDate());
		return $new;
	}
 function quick_add_milestone()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     ajx_current("empty");
     $milestone = new ProjectMilestone();
     $milestone_data = array_var($_POST, 'milestone');
     $project = active_or_personal_project();
     if (!ProjectMilestone::canAdd(logged_user(), $project)) {
         flash_error(lang('no access permissions'));
         return;
     }
     // if
     if (is_array($milestone_data)) {
         try {
             $milestone->setFromAttributes($milestone_data);
             $now = DateTimeValueLib::now();
             $milestone->setDueDate(DateTimeValueLib::make(0, 0, 0, array_var($milestone_data, 'due_date_month', $now->getMonth()), array_var($milestone_data, 'due_date_day', $now->getDay()), array_var($milestone_data, 'due_date_year', $now->getYear())));
             // Set assigned to
             $assigned_to = explode(':', array_var($milestone_data, 'assigned_to', ''));
             $milestone->setAssignedToCompanyId(array_var($assigned_to, 0, 0));
             $milestone->setAssignedToUserId(array_var($assigned_to, 1, 0));
             $milestone->setIsPrivate(false);
             // Not used, but defined as not null.
             $urgent = array_var($milestone_data, 'is_urgent') == 'checked';
             $milestone->setIsUrgent($urgent);
             DB::beginWork();
             $milestone->save();
             $milestone->setProject($project);
             ApplicationLogs::createLog($milestone, $milestone->getWorkspaces(), ApplicationLogs::ACTION_ADD);
             DB::commit();
             ajx_extra_data(array("milestone" => $this->milestone_item($milestone)));
             flash_success(lang('success add milestone', $milestone->getName()));
         } catch (Exception $e) {
             DB::rollback();
             flash_error($e->getMessage());
         }
         // try
     }
     // if
 }
 /**
  * Returns an unsaved copy of the milestone. Copies everything except open/closed state,
  * anything that needs the task to have an id (like tags, properties, tasks),
  * administrative info like who created the milestone and when, etc.
  *
  * @param ProjectMilestone $milestone
  * @return ProjectMilestone
  */
 function createMilestoneCopy(ProjectMilestone $milestone)
 {
     $new = new ProjectMilestone();
     $new->setName($milestone->getName());
     $new->setDescription($milestone->getDescription());
     $new->setIsPrivate($milestone->getIsPrivate());
     $new->setIsUrgent($milestone->setIsUrgent());
     $new->setAssignedToCompanyId($milestone->getAssignedToCompanyId());
     $new->setAssignedToUserId($milestone->getAssignedToUserId());
     $new->setDueDate($milestone->getDueDate());
     return $new;
 }