[Vtigercrm-commits] [vtiger-commits] r10194 - in /vtigercrm/branches/5.0.3: data/CRMEntity.php include/utils/CommonUtils.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Fri Feb 16 10:43:58 EST 2007


Author: saraj
Date: Fri Feb 16 08:43:53 2007
New Revision: 10194

Log:
mail to group is not working in trouble tickets. Fixes #2803

Modified:
    vtigercrm/branches/5.0.3/data/CRMEntity.php
    vtigercrm/branches/5.0.3/include/utils/CommonUtils.php

Modified: vtigercrm/branches/5.0.3/data/CRMEntity.php
==============================================================================
--- vtigercrm/branches/5.0.3/data/CRMEntity.php (original)
+++ vtigercrm/branches/5.0.3/data/CRMEntity.php Fri Feb 16 08:43:53 2007
@@ -72,6 +72,9 @@
 	
 	//Calling the Module specific save code
 	$this->save_module($module);
+
+	$assigntype=$_REQUEST['assigntype'];
+          $this->whomToSendMail($module,$this ->mode,$assigntype);
 	
 	$this->db->completeTransaction();
         $this->db->println("TRANS saveentity ends");
@@ -546,6 +549,34 @@
 	  }
 
   }
+
+function whomToSendMail($module,$insertion_mode,$assigntype)
+{
+ global $adb;
+       if($insertion_mode!="edit")
+       {
+               if($assigntype=='U')
+               {
+                       if($module == 'Events' || $module == 'Calendar')
+                       {
+                               $moduleObj=new Activity();
+                       }else
+                       {
+                               $moduleObj=new $module();
+                       }
+                       sendNotificationToOwner($module,$moduleObj);
+               }
+               elseif($assigntype=='T')
+               {
+                       $groupname=$_REQUEST['assigned_group_name'];
+                       $resultqry=$adb->query("select groupid from vtiger_groups where groupname='".$groupname."'");
+                       $groupid=$adb->query_result($resultqry,0,"groupid");
+                       sendNotificationToGroups($groupid,$this->id,$module);
+               }
+       }
+}
+
+
 	/** Function to delete a record in the specifed table 
   	  * @param $table_name -- table name:: Type varchar
 	  * The function will delete a record .The id is obtained from the class variable $this->id and the columnname got from $this->tab_name_index[$table_name]

Modified: vtigercrm/branches/5.0.3/include/utils/CommonUtils.php
==============================================================================
--- vtigercrm/branches/5.0.3/include/utils/CommonUtils.php (original)
+++ vtigercrm/branches/5.0.3/include/utils/CommonUtils.php Fri Feb 16 08:43:53 2007
@@ -2044,35 +2044,67 @@
 			      		     );
 	}	
 	
-	$description = 'Dear '.$ownername.',<br><br>';
-
-	if($focus->mode == 'edit')
-	{
-		$subject = 'Regarding '.$mod_name.' updation - '.$objectname;
-		$description .= 'The '.$mod_name.' has been updated.';
-	}
-	else
-	{
-		$subject = 'Regarding '.$mod_name.' assignment - '.$objectname;
-		$description .= 'The '.$mod_name.' has been assigned to you.';
-	}
-	$description .= '<br>The '.$mod_name.' details are:<br><br>';
-	$description .= $mod_name.' Id : '.$focus->id.'<br>';
-
-	foreach($object_column_fields as $fieldname => $fieldlabel)
-	{
-		//Get the translated string
-		$temp_label = isset($app_strings[$fieldlabel])?$app_strings[$fieldlabel]:(isset($mod_strings[$fieldlabel])?$mod_strings[$fieldlabel]:$fieldlabel);
-
-		$description .= $temp_label.' : <b>'.$focus->column_fields[$fieldname].'</b><br>';
-	}
-
-	$description .= '<br><br>Thank You <br>';
-	$status = send_mail($module,$ownermailid,$current_user->user_name,'',$subject,$description);
-
-	$log->debug("Exiting sendNotificationToOwner method ...");
-	return $status;
-}
+	if($module == "Accounts" || $module == "Potentials" || $module == "Contacts")
+	{
+		$description = 'Dear '.$ownername.',<br><br>';
+
+		if($focus->mode == 'edit')
+		{
+			$subject = 'Regarding '.$mod_name.' updation - '.$objectname;
+			$description .= 'The '.$mod_name.' has been updated.';
+		}
+		else
+		{
+			$subject = 'Regarding '.$mod_name.' assignment - '.$objectname;
+			$description .= 'The '.$mod_name.' has been assigned to you.';
+		}
+		$description .= '<br>The '.$mod_name.' details are:<br><br>';
+		$description .= $mod_name.' Id : '.$focus->id.'<br>';
+		foreach($object_column_fields as $fieldname => $fieldlabel)
+		{
+			//Get the translated string
+			$temp_label = isset($app_strings[$fieldlabel])?$app_strings[$fieldlabel]:(isset($mod_strings[$fieldlabel])?$mod_strings[$fieldlabel]:$fieldlabel);
+
+			$description .= $temp_label.' : <b>'.$focus->column_fields[$fieldname].'</b><br>';
+		}
+
+		$description .= '<br><br>Thank You <br>';
+		$status = send_mail($module,$ownermailid,$current_user->user_name,'',$subject,$description);
+
+		$log->debug("Exiting sendNotificationToOwner method ...");
+		return $status;
+	}
+}
+
+//Function to send notification to the users of a group
+function sendNotificationToGroups($groupid,$crmid,$module)
+{
+       global $adb;
+       $returnEntity=Array();
+       $returnEntity=getEntityName($module,Array($crmid));
+       $mycrmid=$groupid;
+       require_once('include/utils/GetGroupUsers.php');
+       $getGroupObj=new GetGroupUsers();
+       $getGroupObj->getAllUsersInGroup($mycrmid);
+       $userIds=$getGroupObj->group_users;
+        $groupqry="select email1,id,user_name from vtiger_users where id in(".implode(',',$userIds).")";
+       $groupqry_res=$adb->query($groupqry);
+       for($z=0;$z < $adb->num_rows($groupqry_res);$z++)
+       {
+               //handle the mail send to vtiger_users
+               $emailadd = $adb->query_result($groupqry_res,$z,'email1');
+               $curr_userid = $adb->query_result($groupqry_res,$z,'id');
+               $tosender=$adb->query_result($groupqry_res,$z,'user_name');
+               $pmodule = 'Users';
+               $description = "Dear $tosender,<br>$returnEntity[$crmid] has been created for $module.<br><br>Thanks,<br>vTiger Team.";
+               require_once('modules/Emails/mail.php');
+               $mail_status = send_mail('Emails',$emailadd,$current_user->user_name,'','Record created-vTiger Team',$description,'','','all',$focus->id);
+               $all_to_emailids []= $emailadd;
+                $mail_status_str .= $emailadd."=".$mail_status."&&&";
+        }
+}
+
+
 function getUserslist()
 {
 	global $log,$current_user,$module,$adb,$assigned_user_id;





More information about the vtigercrm-commits mailing list