require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader = new Zend_Application_Module_Autoloader(array( 'namespace' => 'Default', 'basePath' => dirname(__FILE__) )); class camp_ipca_mails { var $mysqlconfig; var $mysqldb; var $data_grid; var $from; function camp_ipca_mails() { $this->from="it.support@metropolisindia.com"; $this->mysqlconfig = new Zend_Config( array( 'database' => array( 'adapter' => 'Pdo_Mysql', 'params' => array( 'host' => 'localhost', 'dbname' => 'ctcamps', 'username' => 'root', 'password' => 'metropolisitteam', ) ) ) ); $this->mysqldb = Zend_Db::factory($this->mysqlconfig->database); $this->mysqldb->setFetchMode(Zend_Db::FETCH_ASSOC); } function fetchAll($sql) { //var_dump($sql); $rec=$this->mysqldb->fetchAll($sql); return $rec; } function execute($sql) { // var_dump($sql); $this->mysqldb->query($sql); } function get_asm_users($hq_id) { $validator = new Zend_Validate_EmailAddress(); $sql1="SELECT DISTINCT email_id_of_me FROM masters_ipca WHERE hq_id='hq_id'"; $me_rec=$this->fetchAll($sql1); foreach($me_rec as $k=>$email) { if ($validator->isValid(trim($email['email_id_of_me']))) { array_push($this->to,$email['email_id_of_me']); } } $sql="SELECT DISTINCT email_id_of_asm FROM masters_ipca WHERE hq_id='$hq_id'"; $asm_rec=$this->fetchAll($sql); foreach($asm_rec as $k=>$email) { if ($validator->isValid(trim($email['email_id_of_asm']))) { array_push($this->to,$email['email_id_of_asm']); } } return $this->to; // echo $this->to; // exit; } function get_sister_users($hq_id) { $validator = new Zend_Validate_EmailAddress(); $sql="SELECT a.email_id from users a inner join ipcasister_headquarters b on (a.uid=b.uid) WHERE b.headquarters='$hq_id'"; $lab_users=$this->fetchAll($sql); foreach($lab_users as $k=>$email) { if ($validator->isValid(trim($email['email_id']))) { array_push($this->to,$email['email_id']); } } // echo $this->to; // exit; return $this->to; } function get_head_users() { $validator = new Zend_Validate_EmailAddress(); $sql="SELECT email_id FROM sponcerer_heads WHERE SPON_ID='7' and uid not in ('4','54','2')"; $mum_users=$this->fetchAll($sql); foreach($mum_users as $k=>$email) { if ($validator->isValid(trim($email['email_id']))) { array_push($this->cc,$email['email_id']); } } return $this->cc; // echo $this->cc; // exit; } function send_mail($subject,$from,$to,$cc,$htmlbody,$textbody) { $config = array('auth' => 'login', 'username' => 'it.support@metropolisindia.com', 'password' => 'ItDvlp@2015', 'ssl' => 'tls'); $tr = new Zend_Mail_Transport_Smtp('192.168.23.66' , $config); Zend_Mail::setDefaultTransport($tr); $mail = new Zend_Mail(); $mail->setFrom((string)$from); foreach ($to as &$value) { $mail->addTo((string)$value); } if (isset($cc)) { foreach ($cc as &$value) { $mail->addCc((string)$value); } } $mail->setSubject((string)$subject); // $mail->setBodyText((string)$textbody); $mail->setBodyHtml((string)$htmlbody); try { $mail->send($tr); } catch (Exception $e) { array_push($to,"aquil.faruqui@metropolisindia.com"); foreach ($to as &$value) { $mail->addTo((string)$value); } $subject="Mail Not Sent Due to Incorrect Email"; $mail->send($tr); echo 'Caught exception: ', $e->getMessage(), "\n"; } } function adddetails() { $details="
Kindly revert on the below mentioned numbers incase of any queries or clarifications
"; $details.="Ms. Swati Shinde
Deputy Manager - Clinical Research
02230840738 / 02233143266
Ms. Kamakshi Desai
Deputy Manager - Clinical Research
02230840740 / 02233143288
Ms. Mugdha Hule
Deputy Manager - Clinical Research
02230840739 / 02233143277";
$details.="
Mr. Siddhesh Chavan
Team Lead
02230840737 / 02233143255
Ms. Sayli Rane
Deputy Manager - Clinical Research
02230840737 / 02233143255
This Is An Auto Generated Email. Kindly Do Not Reply
"; //var_dump($bodyhtml);exit; return $details; } function prepare_table_hqwise($phlebo, $reason) { $bodyhtml="Dear All,
Please note the following IPCA camps are Scheduled for Tomorrow.
"; $bodyhtml.="| ZONE | REGION | HEAD QUARTERS | DOCTOR NAME | CAMP DATE & TIME | INTIMATION DATE & TIME | INTIMATION DAYS | CAMP ADDRESS | "; if($phlebo==1){$bodyhtml.="PHLEBOTOMIST NAME & NUMBER | ";} if($reason==1){$bodyhtml.="STATUS | ";} // AND REASON FOR CHANGE IN SCHEDULE $bodyhtml.="TOTAL PATIENTS | ME NAME & NUMBER | ASM NAME & NUMBER |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| $zone | $region | $headquarters | $doctor_name | $camp_date | $intimation_date | $intimation_days | $venue_address | "; if($phlebo==1){$bodyhtml.="$phle | ";} if($reason==1){$bodyhtml.="$comments | ";} $bodyhtml.="$no_of_patients | $pa | $asm |
Dear All,
//Please note the following IPCA camps are Scheduled for Tomorrow.
"; $campdtls.=$this->prepare_table_hqwise(1,1); $details.=$this->adddetails(); $bodyhtml.=$campdtls; $bodyhtml.=$details; $this->get_head_users(); array_push($this->to,"supratimgupta@lupinpharma.com","spratimgupta@gmail.com"); // array_push($this->cc,"himanshu.bhatia@metropolisindia.com"); array_push($this->cc,"sayli.rane@metropolisindia.com","siddhesh.chavan@metropolisindia.com"); // array_push($this->cc,"it.support@metropolisindia.com"); $this->send_mail($subject,$this->from,$this->to,$this->cc,$bodyhtml,$textbody); } } $lm=new camp_ipca_mails(); $lm->camp_ipca_cumulative(); //echo "End Ok...!"; ?> //