[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 ini_set("include_path", "../:."); 3 4 require ('send_mail.php'); 5 require_once ('config.php'); 6 require_once ('include/utils/utils.php'); 7 8 // Email Setup 9 $emailresult = $adb->query("SELECT email1 from vtiger_users"); 10 $emailid = $adb->fetch_array($emailresult); 11 $emailaddress = $emailid[0]; 12 $mailserveresult = $adb->query("SELECT server,server_username,server_password FROM vtiger_systems"); 13 $mailrow = $adb->fetch_array($mailserveresult); 14 $mailserver = $mailrow[0]; 15 16 $mailuname = $mailrow[1]; 17 $mailpwd = $mailrow[1]; 18 // End Email Setup 19 20 21 //query the vtiger_notificationscheduler vtiger_table and get data for those notifications which are active 22 $sql = "select active from vtiger_notificationscheduler where schedulednotificationid=1"; 23 $result = $adb->query($sql); 24 25 $activevalue = $adb->fetch_array($result); 26 27 if($activevalue[0] == 1) 28 { 29 //Delayed Tasks Notification 30 31 //get all those activities where the status is not completed even after the passing of 24 hours 32 $today = date("Ymd"); 33 $result = $adb->query("select (vtiger_activity.date_start +1) from vtiger_activity where vtiger_activity.status <> 'Completed' and ".$today." > (vtiger_activity.date_start+1)",$db); 34 35 " > (vtiger_activity.date_start+1)"; 36 while ($myrow = $adb->fetch_array($result)) 37 { 38 $status=$myrow[0]; 39 if($status != 'Completed') 40 { 41 sendmail($emailaddress,$emailaddress,"Task Not completed","Dear Admin,<br><br> Please note that there are certain tasks in the system which have not been completed even after 24hours of their existence<br> Thank You<br>HelpDesk Team<br>",$mailserver,$mailuname,$mailpwd,""); 42 } 43 } 44 } 45 46 //Big Deal Alert 47 $sql = "select active from vtiger_notificationscheduler where schedulednotificationid=2"; 48 $result = $adb->query($sql); 49 50 $activevalue = $adb->fetch_array($result); 51 if($activevalue[0] == 1) 52 { 53 $result = $adb->query("SELECT sales_stage,amount FROM vtiger_potential",$db); 54 while ($myrow = $adb->fetch_array($result)) 55 { 56 $amount=$myrow[1]; 57 $stage = $myrow[0]; 58 if($stage == 'Closed Won' && $amount > 10000) 59 { 60 61 sendmail($emailaddress,$emailaddress,"Big Deal Closed Successfully!","Dear Team,<br>Congratulations!Time to Party! <br>We closed a deal worth more than 10000!!!!<br> Time to hit the dance floor!<br>",$mailserver,$mailuname,$mailpwd,""); 62 } 63 } 64 65 } 66 67 //Pending tickets 68 $sql = "select active from vtiger_notificationscheduler where schedulednotificationid=3"; 69 $result = $adb->query($sql); 70 71 $activevalue = $adb->fetch_array($result); 72 if($activevalue[0] == 1) 73 { 74 $result = $adb->query("SELECT vtiger_troubletickets.status,ticketid FROM vtiger_troubletickets INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_troubletickets.ticketid WHERE vtiger_crmentity.deleted='0' AND vtiger_troubletickets.status <> 'Completed' AND vtiger_troubletickets.status <> 'Closed' ",$db); 75 76 while ($myrow = $adb->fetch_array($result)) 77 { 78 $status=$myrow[0]; 79 $ticketid = $myrow[1]; 80 if($status != "Completed" || $status != "Closed") 81 { 82 sendmail($emailaddress,$emailaddress,"Pending Ticket notification","Dear Admin,<br> This is to bring to your kind attention that ticket number ".$ticketid ." is yet to be closed<br> Thank You,<br> HelpDesk Team<br>",$mailserver,$mailuname,$mailpwd,""); 83 } 84 } 85 86 87 } 88 89 //Too many tickets related to a particular vtiger_account/company causing concern 90 $sql = "select active from vtiger_notificationscheduler where schedulednotificationid=4"; 91 $result = $adb->query($sql); 92 93 $activevalue = $adb->fetch_array($result); 94 if($activevalue[0] == 1) 95 { 96 97 $result = $adb->query("SELECT status,vtiger_troubletickets.ticketid FROM vtiger_troubletickets where status <> 'Completed' AND status <> 'Closed'",$db); 98 while ($myrow = $adb->fetch_array($result)) 99 { 100 $status=$myrow[0]; 101 $ticketid = $myrow[1]; 102 sendmail($emailaddress,$emailaddress,"Too many pending tickets","Dear Admin,<br> This is to bring to your notice that there are too many tickets pending. Kindly take the necessary action required for addressing the same<br><br> Thanks and Regards,<br> HelpDesk Team<br>",$mailserver,$mailuname,$mailpwd,""); 103 } 104 105 } 106 107 //Support Starting 108 $sql = "select active from vtiger_notificationscheduler where schedulednotificationid=5"; 109 $result = $adb->query($sql); 110 111 $activevalue = $adb->fetch_array($result); 112 if($activevalue[0] == 1) 113 { 114 $result = $adb->query("SELECT productname FROM vtiger_products where start_date like '".date('Y-m-d')."%'",$db); 115 while ($myrow = $adb->fetch_array($result)) 116 { 117 $productname=$myrow[0]; 118 sendmail($emailaddress,$emailaddress,"Support starting","Hello! Support Starts for ".$productname ."\n Congratulations! Your support starts from today",$mailserver,$mailuname,$mailpwd,""); 119 } 120 121 } 122 123 //Support ending 124 $sql = "select active from vtiger_notificationscheduler where schedulednotificationid=6"; 125 $result = $adb->query($sql); 126 127 $activevalue = $adb->fetch_array($result); 128 if($activevalue[0] == 1) 129 { 130 131 $result = $adb->query("SELECT productname from vtiger_products where expiry_date like '".date('Y-m-d')."%'",$db); 132 while ($myrow = $adb->fetch_array($result)) 133 { 134 $productname=$myrow[0]; 135 sendmail($emailaddress,$emailaddress,"Support Ending","Dear Admin,<br> This is to inform you that the support for ".$productname ."\n ends shortly. Kindly renew your support please<br>Regards,<br>HelpDesk Team<br>",$mailserver,$mailuname,$mailpwd,""); 136 } 137 138 } 139 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |