Example #1
0
		        <?php    	
				$contexts = array();
				$members =  $task->getMembers();
				if(count($members)>0){
					foreach ($members as $member){
						$dim = $member->getDimension();
						if($dim->getIsManageable()){
							if ($dim->getCode() == "customer_project"){
								$obj_type = ObjectTypes::findById($member->getObjectTypeId());
								if ($obj_type instanceof ObjectType) {
								echo lang($dim->getCode()). ": ";
								echo $contexts[$dim->getCode()][$obj_type->getName()][]= '<span style="'.get_workspace_css_properties($member->getMemberColor()).'">'. $member->getName() .'</span>';
							}
							}else{
								echo lang($dim->getCode()). ": ";
								echo $contexts[$dim->getCode()][]= '<span style="'.get_workspace_css_properties($member->getMemberColor()).'">'. $member->getName() .'</span>';
							}
						}
					}
				}
				?>
                <!-- CONTEXTS -->
            </b></p>
<?php } // if ?>

<?php if ($task->getAssignedTo() instanceof Contact) { ?>
<p><b><?php echo lang('assigned to') ?>:</b>&nbsp;<?php echo clean($task->getAssignedToName()) ?></p>
<?php } // if ?>


<?php if ($task->getMilestone() instanceof ProjectMilestone) { ?>
 private static function buildContextObjectForNotification($object)
 {
     $contexts = array();
     $members = $object->getMembers();
     if (count($members) > 0) {
         foreach ($members as $member) {
             $dim = $member->getDimension();
             if ($dim->getIsManageable()) {
                 /* @var $member Member */
                 $parent_members = $member->getAllParentMembersInHierarchy();
                 $parents_str = '';
                 foreach ($parent_members as $pm) {
                     /* @var $pm Member */
                     if (!$pm instanceof Member) {
                         continue;
                     }
                     $parents_str .= '<span style="' . get_workspace_css_properties($pm->getMemberColor()) . '">' . $pm->getName() . '</span>';
                 }
                 if ($dim->getCode() == "customer_project" || $dim->getCode() == "customers") {
                     $obj_type = ObjectTypes::findById($member->getObjectTypeId());
                     if ($obj_type instanceof ObjectType) {
                         $contexts[$dim->getCode()][$obj_type->getName()][] = $parents_str . '<span style="' . get_workspace_css_properties($member->getMemberColor()) . '">' . $member->getName() . '</span>';
                     }
                 } else {
                     $contexts[$dim->getCode()][] = $parents_str . '<span style="' . get_workspace_css_properties($member->getMemberColor()) . '">' . $member->getName() . '</span>';
                 }
             }
         }
     }
     return $contexts;
 }
        echo $name3;
        ?>
<br><?php 
    }
    ?>
			<br><br>
			<?php 
}
?>
	<br><br>
	
	<?php 
echo lang('workspace');
?>
: <span style='<?php 
echo get_workspace_css_properties($workspace_color);
?>
'>
	<?php 
echo $workspaces;
?>
</span><br><br>
	<br><br>
	<div style="color: #818283; font-style: italic; border-top: 2px solid #818283; padding-top: 2px; font-family: Verdana, Arial, sans-serif; font-size: 12px;">
	<?php 
echo lang('system notification email');
?>
<br>
	<a href="<?php 
echo ROOT_URL;
?>
Example #4
0
	function workEstimate(ProjectTask $task) {
		tpl_assign('task_assigned', $task);
		
		if(!($task->getAssignedTo() instanceof Contact)) {
			return true; // not assigned to user
		}
		if (!is_valid_email($task->getAssignedTo()->getEmailAddress())) {
			return true;
		}

		$locale = $task->getAssignedTo()->getLocale();
		Localization::instance()->loadSettings($locale, ROOT . '/language');
                
                tpl_assign('title', $task->getObjectName());
                tpl_assign('by', $task->getAssignedBy()->getObjectName());
                tpl_assign('asigned', $task->getAssignedTo()->getObjectName());
                $text = "";
                if(config_option("wysiwyg_tasks")){
                    $text = purify_html(nl2br($task->getDescription()));
                }else{
                    $text = escape_html_whitespace($task->getDescription());
                }
                tpl_assign('description', $text);//descripction
                tpl_assign('description_title', lang("new task work estimate to you desc", $task->getObjectName(),$task->getAssignedBy()->getObjectName()));//description_title
                
                //priority
                if ($task->getPriority()) {
                    if ($task->getPriority() >= ProjectTasks::PRIORITY_URGENT) {
                            $priorityColor = "#FF0000";
                            $priority = lang('urgent priority');
                    }else if ($task->getPriority() >= ProjectTasks::PRIORITY_HIGH) {
                            $priorityColor = "#FF9088";
                            $priority = lang('high priority');
                    } else if ($task->getPriority() <= ProjectTasks::PRIORITY_LOW) {
                            $priorityColor = "white";
                            $priority = lang('low priority');
                    }else{
                            $priorityColor = "#DAE3F0";
                            $priority = lang('normal priority');
                    }
                    tpl_assign('priority', array($priority,$priorityColor));
		}
		
		//context		
		$contexts = array();
		$members = $task->getMembers();
		if(count($members)>0){
			foreach ($members as $member){
				$dim = $member->getDimension();
				if($dim->getIsManageable()){
					if ($dim->getCode() == "customer_project"){
						$obj_type = ObjectTypes::findById($member->getObjectTypeId());
						if ($obj_type instanceof ObjectType) {
							$contexts[$dim->getCode()][$obj_type->getName()][]= '<span style="'.get_workspace_css_properties($member->getMemberColor()).'">'. $member->getName() .'</span>';
						}
					}else{
						$contexts[$dim->getCode()][]= '<span style="'.get_workspace_css_properties($member->getMemberColor()).'">'. $member->getName() .'</span>';
					}
				}
			}
		}
                tpl_assign('contexts', $contexts);//workspaces
                
                //start date, due date or start
                if ($task->getStartDate() instanceof DateTimeValue) {
			$date = Localization::instance()->formatDescriptiveDate($task->getStartDate(), $task->getAssignedTo()->getTimezone());
			$time = Localization::instance()->formatTime($task->getStartDate(), $task->getAssignedTo()->getTimezone());
                        if($time > 0)
                        $date .= " " . $time;
                        tpl_assign('start_date', $date);//start_date
		}
                
		if ($task->getDueDate() instanceof DateTimeValue) {
			$date = Localization::instance()->formatDescriptiveDate($task->getDueDate(), $task->getAssignedTo()->getTimezone());
			$time = Localization::instance()->formatTime($task->getDueDate(), $task->getAssignedTo()->getTimezone());
                        if($time > 0)
                        $date .= " " . $time;
                        tpl_assign('due_date', $date);//due_date
		}

		$attachments = array();
		try {
			$content = FileRepository::getBackend()->getFileContent(owner_company()->getPictureFile());
			if ($content) {
				$file_path = ROOT . "/tmp/logo_empresa.png";
				$handle = fopen($file_path, 'wb');
				if ($handle) {
					fwrite($handle, $content);
					fclose($handle);
					$attachments['logo'] = array(
						'cid' => gen_id() . substr($task->getAssignedBy()->getEmailAddress(), strpos($task->getAssignedBy()->getEmailAddress(), '@')),
						'path' => $file_path,
						'type' => 'image/png',
						'disposition' => 'inline',
						'name' => 'logo_empresa.png',
					);
				}
			}
		} catch (FileNotInRepositoryError $e) {
			unset($attachments['logo']);
		}
		tpl_assign('attachments', $attachments);// attachments
		
                //ALL SUBSCRIBERS
                if($task->getSubscribers()){
                    $subscribers = $task->getSubscribers();
                    $string_subscriber = '';
                    $total_s = count($subscribers);
                    $c = 0;
                    foreach ($subscribers as $subscriber){
                        $c++;
                        if($c == $total_s && $total_s > 1){
                            $string_subscriber .= lang('and');
                        }else if($c > 1){
                            $string_subscriber .= ", ";
                        }

                        $string_subscriber .= $subscriber->getFirstName();
                        if($subscriber->getSurname() != "")
                            $string_subscriber .=" " . $subscriber->getSurname();

                    }
                    tpl_assign('subscribers', $string_subscriber);// subscribers
                }
		
		if($task->getAssignedById() == $task->getAssignedToContactId()){
			$emails[] = array(
                            "to" => array(self::prepareEmailAddress($task->getAssignedBy()->getEmailAddress(), $task->getAssignedBy()->getObjectName())),
                            "from" => self::prepareEmailAddress($task->getUpdatedBy()->getEmailAddress(), $task->getUpdatedByDisplayName()),
                            "subject" => lang('work estimate title'),
                            "body" => tpl_fetch(get_template_path('work_estimate', 'notifier')),
                            "attachments" => $attachments
                        ); 
		}else{
			$emails[] = array(
                            "to" => array(self::prepareEmailAddress($task->getAssignedBy()->getEmailAddress(), $task->getAssignedBy()->getObjectName())),
                            "from" => self::prepareEmailAddress($task->getUpdatedBy()->getEmailAddress(), $task->getUpdatedByDisplayName()),
                            "subject" => lang('work estimate title'),
                            "body" => tpl_fetch(get_template_path('work_estimate', 'notifier')),
                            "attachments" => $attachments
                        );
			$emails[] = array(
                            "to" => array(self::prepareEmailAddress($task->getAssignedTo()->getEmailAddress(), $task->getAssignedTo()->getObjectName())),
                            "from" => self::prepareEmailAddress($task->getUpdatedBy()->getEmailAddress(), $task->getUpdatedByDisplayName()),
                            "subject" => lang('work estimate title'),
                            "body" => tpl_fetch(get_template_path('work_estimate', 'notifier')),
                            "attachments" => $attachments
			);
		}
		self::queueEmails($emails);
		
		$locale = logged_user() instanceof Contact ? logged_user()->getLocale() : DEFAULT_LOCALIZATION;
		Localization::instance()->loadSettings($locale, ROOT . '/language');
	}
Example #5
0
<div style="font-family: Verdana, Arial, sans-serif; font-size: 12px;">
	<a href="<?php 
echo str_replace('&amp;', '&', $task_assigned->getViewUrl());
?>
" style="font-size: 18px;"><?php 
echo lang('task assigned', $task_assigned->getTitle());
?>
</a><br><br>
	
	<?php 
echo lang('workspace');
?>
: <span style="<?php 
echo get_workspace_css_properties($task_assigned->getProject()->getColor());
?>
">
	<?php 
echo $task_assigned->getProject()->getName();
?>
</span><br><br>
	
	<?php 
if ($task_assigned->getMilestone() instanceof Milestone) {
    echo lang('milestone') . ': ' . $task_assigned->getMilestone()->getName();
    ?>
		<br><br>
	<?php 
}
?>
	
	<?php 
Example #6
0
 function workEstimate(ProjectTask $task)
 {
     tpl_assign('task_assigned', $task);
     if (!$task->getAssignedTo() instanceof Contact) {
         return true;
         // not assigned to user
     }
     if (!is_valid_email($task->getAssignedTo()->getEmailAddress())) {
         return true;
     }
     $locale = $task->getAssignedTo()->getLocale();
     Localization::instance()->loadSettings($locale, ROOT . '/language');
     tpl_assign('title', $task->getObjectName());
     tpl_assign('by', $task->getAssignedBy()->getObjectName());
     tpl_assign('asigned', $task->getAssignedTo()->getObjectName());
     $text = "";
     if (config_option("wysiwyg_tasks")) {
         $text = purify_html(nl2br($task->getDescription()));
     } else {
         $text = escape_html_whitespace($task->getDescription());
     }
     tpl_assign('description', $text);
     //descripction
     tpl_assign('description_title', lang("new task work estimate to you desc", $task->getObjectName(), $task->getCreatedBy()->getObjectName()));
     //description_title
     //priority
     if ($task->getPriority()) {
         if ($task->getPriority() >= ProjectTasks::PRIORITY_URGENT) {
             $priorityColor = "#FF0000";
             $priority = lang('urgent priority');
         } else {
             if ($task->getPriority() >= ProjectTasks::PRIORITY_HIGH) {
                 $priorityColor = "#FF9088";
                 $priority = lang('high priority');
             } else {
                 if ($task->getPriority() <= ProjectTasks::PRIORITY_LOW) {
                     $priorityColor = "white";
                     $priority = lang('low priority');
                 } else {
                     $priorityColor = "#DAE3F0";
                     $priority = lang('normal priority');
                 }
             }
         }
         tpl_assign('priority', array($priority, $priorityColor));
     }
     //context
     $contexts = array();
     if ($task->getMembersToDisplayPath()) {
         $members = $task->getMembersToDisplayPath();
         foreach ($members as $key => $member) {
             $dim = Dimensions::getDimensionById($key);
             if ($dim->getCode() == "customer_project") {
                 foreach ($members[$key] as $member) {
                     $obj_type = ObjectTypes::findById($member['ot']);
                     $contexts[$dim->getCode()][$obj_type->getName()][] = '<span style="' . get_workspace_css_properties($member['c']) . '">' . $member['name'] . '</span>';
                 }
             } else {
                 foreach ($members[$key] as $member) {
                     $contexts[$dim->getCode()][] = '<span style="' . get_workspace_css_properties($member['c']) . '">' . $member['name'] . '</span>';
                 }
             }
         }
     }
     tpl_assign('contexts', $contexts);
     //workspaces
     //start date, due date or start
     if ($task->getStartDate() instanceof DateTimeValue) {
         $date = Localization::instance()->formatDescriptiveDate($task->getStartDate(), $task->getAssignedTo()->getTimezone());
         $time = Localization::instance()->formatTime($task->getStartDate(), $task->getAssignedTo()->getTimezone());
         if ($time > 0) {
             $date .= " " . $time;
         }
         tpl_assign('start_date', $date);
         //start_date
     }
     if ($task->getDueDate() instanceof DateTimeValue) {
         $date = Localization::instance()->formatDescriptiveDate($task->getDueDate(), $task->getAssignedTo()->getTimezone());
         $time = Localization::instance()->formatTime($task->getDueDate(), $task->getAssignedTo()->getTimezone());
         if ($time > 0) {
             $date .= " " . $time;
         }
         tpl_assign('due_date', $date);
         //due_date
     }
     $attachments = array();
     try {
         $content = FileRepository::getBackend()->getFileContent(owner_company()->getPictureFile());
         $file_path = ROOT . "/upload/logo_empresa.png";
         $handle = fopen($file_path, 'wb');
         fwrite($handle, $content);
         fclose($handle);
         if ($content != "") {
             $attachments['logo'] = array('cid' => gen_id() . substr($task->getAssignedBy()->getEmailAddress(), strpos($task->getAssignedBy()->getEmailAddress(), '@')), 'path' => $file_path, 'type' => 'image/png', 'disposition' => 'inline', 'name' => 'logo_empresa.png');
             tpl_assign('attachments', $attachments);
             // attachments
         }
     } catch (FileNotInRepositoryError $e) {
         // If no logo is set, don't interrupt notifications.
     }
     tpl_assign('attachments', $attachments);
     // attachments
     self::queueEmail(array(self::prepareEmailAddress($task->getCreatedBy()->getEmailAddress(), $task->getCreatedBy()->getObjectName())), self::prepareEmailAddress($task->getUpdatedBy()->getEmailAddress(), $task->getUpdatedByDisplayName()), lang('work estimate title'), tpl_fetch(get_template_path('work_estimate', 'notifier')), 'text/html', '8bit', $attachments);
     // send
     $locale = logged_user() instanceof Contact ? logged_user()->getLocale() : DEFAULT_LOCALIZATION;
     Localization::instance()->loadSettings($locale, ROOT . '/language');
 }
 /**
  * Send event notification to the list of users ($people)
  *
  * @param ProjectEvent $event Event
  * @param array $people
  * @return boolean
  * @throws NotifierConnectionError
  */
 static function notifEvent(ProjectEvent $object, $people, $notification, $sender)
 {
     if (!is_array($people) || !count($people) || !$sender instanceof User) {
         return;
         // nothing here...
     }
     // if
     $uid = $object->getUniqueObjectId();
     $name = $object->getObjectName();
     $type = $object->getObjectTypeName();
     $typename = lang($object->getObjectTypeName());
     $description = lang("{$notification} notification event desc", $object->getObjectName(), $sender->getDisplayName());
     $properties = array();
     $second_properties = array();
     $second_properties['unique id'] = $uid;
     //$properties['view event'] = str_replace('&amp;', '&', $object->getViewUrl());
     tpl_assign('object', $object);
     tpl_assign('description', $description);
     tpl_assign('properties', $properties);
     $emails = array();
     foreach ($people as $user) {
         if ($user->getId() != $sender->getId()) {
             // send notification on user's locale and with user info
             $locale = $user->getLocale();
             Localization::instance()->loadSettings($locale, ROOT . '/language');
             $workspaces = $object->getUserWorkspaces($user);
             $ws = "";
             foreach ($workspaces as $w) {
                 if ($ws) {
                     $ws .= ", ";
                 }
                 $css = get_workspace_css_properties($w->getColor());
                 $ws .= "<span style=\"{$css}\">" . $w->getPath() . "</span>";
             }
             $properties['workspace'] = $ws;
             $properties['date'] = Localization::instance()->formatDescriptiveDate($object->getStart(), $user->getTimezone());
             if ($object->getTypeId() != 2) {
                 $properties['meeting_time'] = Localization::instance()->formatTime($object->getStart(), $user->getTimezone());
             }
             $properties['accept or reject invitation help, click on one of the links below'] = '';
             //	$properties['accept invitation'] = get_url('event', 'change_invitation_state', array('at' => 1, 'e' => $object->getId(), 'u' => $user->getId()));
             //	$properties['reject invitation'] = get_url('event', 'change_invitation_state', array('at' => 2, 'e' => $object->getId(), 'u' => $user->getId()));
             $links = array(array('img' => get_image_url("/16x16/complete.png"), 'text' => lang('accept invitation'), 'url' => get_url('event', 'change_invitation_state', array('at' => 1, 'e' => $object->getId(), 'u' => $user->getId()))), array('img' => get_image_url("/16x16/del.png"), 'text' => lang('reject invitation'), 'url' => get_url('event', 'change_invitation_state', array('at' => 2, 'e' => $object->getId(), 'u' => $user->getId()))));
             tpl_assign('links', $links);
             tpl_assign('properties', $properties);
             tpl_assign('second_properties', $second_properties);
             $from = self::prepareEmailAddress($sender->getEmail(), $sender->getDisplayName());
             $emails[] = array("to" => array(self::prepareEmailAddress($user->getEmail(), $user->getDisplayName())), "from" => self::prepareEmailAddress($sender->getEmail(), $sender->getDisplayName()), "subject" => $subject = lang("{$notification} notification {$type}", $name, $uid, $typename, $ws), "body" => tpl_fetch(get_template_path('general', 'notifier')));
         }
     }
     // foreach
     $locale = logged_user() instanceof User ? logged_user()->getLocale() : DEFAULT_LOCALIZATION;
     Localization::instance()->loadSettings($locale, ROOT . '/language');
     self::queueEmails($emails);
 }
<div style="font-family: Verdana, Arial, sans-serif; font-size: 12px;">
	<a href="<?php 
echo str_replace('&amp;', '&', $milestone_assigned->getViewUrl());
?>
" target="_blank" style="font-size: 18px;"><?php 
echo lang('milestone assigned', $milestone_assigned->getName());
?>
</a><br><br>

	<?php 
echo lang('workspace');
?>
: <span style="<?php 
echo get_workspace_css_properties($milestone_assigned->getProject()->getColor());
?>
">
	<?php 
echo $milestone_assigned->getProject()->getName();
?>
</span><br><br>

	<?php 
if (isset($date)) {
    echo "<br>";
    echo lang('date');
    ?>
: <?php 
    echo $date;
    echo "<br>";
}
?>