<?php

function function_sendmail_new_potential( $entity ) {
  require_once 'modules/Emails/mail.php';
    global $adb;
    global $site_URL;
    global $crmdetailviewurl;
    $data = $entity->data;
    $user = $entity->user;
    $time_zone = $user->time_zone;
    extract($data);
    //echo json_encode($data);
    //die();
    
    $id_ = explode("x", $id)[1];
    $assigned_user_id = explode("x", $assigned_user_id)[1];

    $query = $adb->pquery("SELECT * FROM vtiger_users WHERE id = '$assigned_user_id' ", array());
    $first_name = $adb->query_result($query, 0, 'first_name');
    $last_name = $adb->query_result($query, 0, 'last_name');
    $email1 = $adb->query_result($query, 0, 'email1');
    
    $url = $site_URL . "index.php?module=Potentials&view=Detail&record=$id_";
$mensaje = <<<EOT
<!DOCTYPE html>
<html>
<head>
  <title>Notificacion VTIGER </title>
</head>
<body>
<p>
<h2>Se ha creado una Oportunidad Nro $potential_no : $potentialname </h2>
<br>
Ver: <a href='$url'> $potential_no - $potentialname</a>
</body>
</html>
EOT;
    //$principal_email = "hcumbicus@creantis.com"; //local
    $principal_email = "fiorella.berio@fursysperu.com.pe"; //server

  //echo strpos($subject, 'test');
  //echo $mensaje;
  //echo $principal_email;
  //die();
  send_mail('Potentials', $principal_email, 'CRM Fursys', 'vtiger-admin@fursys.com.pe',"CRM Fursys",$mensaje, $cc='', $bcc='', $atc="",$eid="",$logo='',$ug='');
}