'Default', 'basePath' => dirname(__FILE__) )); class camp_roche_cronpopupmails { var $mysqlconfig; var $mysqldb; var $data_grid; var $from; function camp_roche_cronpopupmails() { $this->from="it.support@metropoliscustomers.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 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) { //var_dump($to); //var_dump($cc); // 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 sister_users($headquarters,$campid) { var_dump($headquarters.$campid); if($campid==0) { $sql="SELECT a.email_id from users a inner join rochesister_hq_id b on (a.uid=b.uid) WHERE b.hq_id='$headquarters'"; } else { $sql="SELECT a.email_id from users a inner join rochesister_hq_id b on (a.uid=b.uid) inner join roche_camps c on (b.hq_id=c.headquarters) where c.camp_id='$campid' "; } $rec=$this->fetchAll($sql); $validator = new Zend_Validate_EmailAddress(); foreach($rec as $k=>$email) { if ($validator->isValid(trim($email['email_id']))) { array_push($this->to,$email['email_id']); var_dump($this->to); } } } function camp_roche_intimation() { $this->to=array(); $this->cc=array(); // $to=$this->getFTM($camp_id); $sql="SELECT c.zone, c.region, c.headquarters, a.headquarters as hid, a.doctor_name, a.camp_type, a.camp_id, date_format(a.camp_date,'%d-%M-%Y %h:%i %p') as camp_date, date_format(a.camp_intimation,'%d-%M-%Y %h:%i %p') as intimation_date, DATEDIFF(a.camp_date,a.camp_intimation) as intimation_days, CONCAT(a.venue_address,' Pincode: ',a.pincode) as venue_address, a.no_of_patients, CONCAT(a.phlebotomist_name,'-',a.phlebotomist_number) as phle, CONCAT(a.me_name,'-',a.contact_no_of_me) as pa, CONCAT(a.name_of_asm,'-',a.contact_no_of_asm) as abn FROM roche_camps a INNER JOIN masters_roche b ON (a.headquarters=b.hq_id) INNER JOIN roche_headquarters c ON (b.headquarters=c.headquarters) WHERE a.freeze=1 AND a.pfreeze=0 and date_format(camp_date,'%Y-%m-%d') = CURDATE() + INTERVAL 1 DAY"; $this->data_grid=$this->fetchAll($sql); if(count($this->data_grid)>0) { $zone=$this->data_grid[0]['zone']; $hq_id=$this->data_grid[0]['hid']; var_dump($hq_id); $subject="Reminder for Phlebotomist details"; $bodyhtml="

Dear Team,

Gentle Reminder

Kindly consider this as a gentle reminder to fill the Phlebotomist details for below mentioned Roche Hepatitis camp on the following link:
http://support.metropolisindia.com/Camps/Roche .

"; $bodyhtml.=""; foreach($this->data_grid as $k=>$rdata) { $zone=$rdata['zone']; $region=$rdata['region']; $headquarters=$rdata['headquarters']; $doctor_name=$rdata['doctor_name']; $camp_date=$rdata['camp_date']; $camp_type=$rdata['camp_type']; $intimation_date=$rdata['intimation_date']; $intimation_days=$rdata['intimation_days']; $venue_address=$rdata['venue_address']; $phlebotomist_name=$rdata['phlebotomist_name']; $phlebotomist_number=$rdata['phlebotomist_number']; $contact_no_of_ram=$rdata['contact_no_of_ram']; $name_of_asm=$rdata['name_of_asm']; $contact_no_of_asm=$rdata['contact_no_of_asm']; $email_id_of_asm=$rdata['email_id_of_asm']; $me_name=$rdata['me_name']; $hq_id=$rdata['hid']; $campid=$rdata['campid']; $contact_no_of_me=$rdata['contact_no_of_me']; $email_id_of_me=$rdata['email_id_of_me']; $bodyhtml.=""; $bodyhtml.="
ZONE REGION HEADQUARTERS DOCTOR NAME CAMP TYPE CAMP DATE & TIME VENUE ADDRESS
$zone $region $headquarters $doctor_name $camp_type $camp_date $venue_address
"; $bodyhtml.="

Please feel free to revert on below mentioned numbers in case of any query or information required.

"; $format.="

Ms. Kamakshi _Project lead
02230840740 / 02233143288

Mr. Suhas Shinde _Project Co-ordinator
02230840740 / 02233143288

Ms. Urmila Kadam _ Project Co-ordinator
02230840740 / 02233143288

This is Auto Generated Email. Kindly Do Not reply

"; // // $bodyhtml.=$format; $this->sister_users($hq_id,$campid); array_push($this->cc,"roche@metropolisiSndia.com"); array_push($this->cc,"aquil.faruqui@metropolisindia.com"); array_push($this->cc,"it.support@metropolisindia.com"); // array_push($this->cc,"himanshu.bhatia@metropolisindia.com"); $this->send_mail($subject,$this->from,$this->to,$this->cc,$bodyhtml,$textbody); } } } } $lm=new camp_roche_cronpopupmails(); $lm->camp_roche_intimation(); echo "End Ok...!"; ?>