require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader = new Zend_Application_Module_Autoloader(array( 'namespace' => 'Default', 'basePath' => dirname(__FILE__) )); class abbott_mails { var $mysqlconfig; var $mysqldb; var $data_grid; var $from; function abbott_mails() { $this->from="abbott.tsh@metropolisindia.com"; $this->mysqlconfig = new Zend_Config( array( 'database' => array( 'adapter' => 'Pdo_Mysql', 'params' => array( 'host' => 'localhost', 'dbname' => 'abbott', '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 getFTM($camp_id) { $validator = new Zend_Validate_EmailAddress(); $sql="SELECT DISTINCT email_id_of_ftm FROM abbott_camps WHERE camp_id='$camp_id';"; $me_rec=$this->fetchAll($sql); foreach($me_rec as $k=>$email) { if ($validator->isValid(trim($email['email_id_of_ftm']))) { array_push($this->to,$email['email_id_of_ftm']); } } $sql="SELECT DISTINCT email_id_of_ram FROM abbott_camps WHERE camp_id='$camp_id';"; $asm_rec=$this->fetchAll($sql); foreach($asm_rec as $k=>$email) { if ($validator->isValid(trim($email['email_id_of_ram']))) { array_push($this->to,$email['email_id_of_ram']); } } return $this->to; } function getZone($zone) { $validator = new Zend_Validate_EmailAddress(); // $sql="SELECT email_id FROM users_zone a,users b WHERE a.uid=b.uid and zone='$zone';"; $sql="SELECT email_id FROM sponcerer_heads where zone='$zone';"; // echo $sql; $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']); } } array_push($this->cc,"aquil.faruqui@metropolisindia.com"); array_push($this->cc,"mugdha.hule@metropolisindia.com"); array_push($this->cc,"it.support@metropolisindia.com"); // array_push($this->cc,"sneha.anaokar@metropolisindia.com"); // array_push($this->cc,"nicole.mendonca@metropolisindia.com"); return $this->cc; } // function getLab($data_grid) // { // $validator = new Zend_Validate_EmailAddress(); // foreach($data_grid as $k=>$rdata) // { // $hq_id=$rdata['hq_id']; // $sql="SELECT a.uid,b.email_id FROM users_hq_id a, users b WHERE a.uid=b.uid and a.hq_id='$hq_id';"; // $hq_id_users=$this->fetchAll($sql); // foreach($hq_id_users as $k=>$email) // { // if ($validator->isValid(trim($email['email_id']))) // { // array_push($this->to,$email['email_id']); // } // } // } // } 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,"mugdha.hule@metropolisindia.com"); //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 preparetable() { $table="
| Zone | HeadQuarters | Doctor Name | Doctor Degree | Clinic Programme Date | Sample pick up Time | Venue Address |
|---|---|---|---|---|---|---|
| $zone | $headquarters | $doctor_name | $doctor_degree | $camp_date | $sample_picup_time | $venue_address |
In case of any query kindly revert on the below mentioned numbers:
"; if($zone=='WEST'){$format="Ms. Swati Shinde
Deputy Manager - Clinical Research
02230840738/ 02233143266
Ms. Sayli Rane
Deputy Manager - Clinical Research
02230840737 /02233143255
Ms. Kamakshi Desai
Deputy Manager - Clinical Research
02230840740 /02233143288
Ms. Mugdha Hule
Deputy Manager - Clinical Research
02230840739 /02233143277
This Is An Auto Generated Email. Kindly Do Not reply
"; $table.=$format; return $table; } function preparetable_logistic() { $table="| Zone | HeadQuarters | Doctor Name | Doctor Degree | Clinic Programme Date | Sample pick up Time | Venue Address |
|---|---|---|---|---|---|---|
| $zone | $headquarters | $doctor_name | $doctor_degree | $camp_date | $sample_picup_time | $venue_address |
Dear Abbott Team,
We have received intimation for the following Abbott Clinic programme.
"; $new_body=$this->preparetable(); $bodyhtml.=$new_body; // array_push($this->cc,"sneha.anaokar@metropolisindia.com"); } $this->send_mail($subject,$this->from,$this->to,$this->cc,$bodyhtml,$textbody); } } function camp_logistic_abbott() { $sql="SELECT DISTINCT b.zone, b.hq as headquarters FROM abbott_camps a INNER JOIN hq_mast b ON (a.headquarters=b.hq_id) WHERE a.freeze=1 and a.l_freeze=1 AND a.camp_intimation_mail=0 and date(a.camp_date)= ADDDATE(CURDATE(),INTERVAL 1 DAY) ORDER BY b.hq ; "; $rec=$this->fetchAll($sql); foreach($rec as $k=>$row) { $this->to=array(); $this->cc=array(); $camp_id=$row['camp_id']; $zone=$row['zone']; $headquarters=$row['headquarters']; // $to=$this->getFTM($camp_id); $sql="SELECT DISTINCT a.camp_id, b.zone, b.hq as headquarters, a.logistic_name, a.logistic_number, date_format(a.camp_date,'%d-%M-%Y') as camp_date, a.sample_picup_time, a.venue_address, concat(c.doc_fname,' ',c.doc_lname) as doctor_name, c.qualification as doctor_degree, c.doc_mob_no as doctor_contact_number FROM abbott_camps a INNER JOIN hq_mast b ON (a.headquarters=b.hq_id) left join doctor_master c on a.doc_code=c.doc_code WHERE a.freeze=1 AND a.camp_phlebo_mail=0 AND b.zone='$zone' and date(a.camp_date)= ADDDATE(CURDATE(),INTERVAL 1 DAY) ORDER BY b.hq"; $this->data_grid=$this->fetchAll($sql); if(count($this->data_grid)>0) { $zone=$this->data_grid[0]['zone']; $logistic_name=$this->data_grid[0]['logistic_name']; $logistic_number=$this->data_grid[0]['logistic_number']; $tommorow = mktime(date("H"), date("i"), date("s"), date("m"), date("d")+1, date("Y")); $date = date("d-m-Y", $tommorow ); // echo $tommorow; // echo $date; $to=$this->getFTM($camp_id); $cc=$this->getZone($zone); $subject="Logistic Personnel Details for ".$date; $bodyhtml="Dear FTM / RAM,
Please find below the scheduled Thyroid clinic programmes for ".$date."
"; $new_body=$this->preparetable_logistic(); $bodyhtml.=$new_body; $format="The logistic personnel contact details are as follows;
"; $format.="| Logistic Personnel Name : | ".$logistic_name." |
| Number : | ".$logistic_number." |
In case of any query kindly revert on the below mentioned numbers:
"; if($zone=='WEST'){$format.="Ms. Swati Shinde
Deputy Manager - Clinical Research
02230840738 / 02233143266
Ms. Sayli Rane
Deputy Manager - Clinical Research
02230840737 / 02233143255
Ms. Kamakshi Desai
Deputy Manager - Clinical Research
02230840740 / 02233143288
Ms. Mugdha Hule
Deputy Manager - Clinical Research
02230840739 / 02233143277
This Is An Auto Generated Email. Kindly Do Not reply
"; $bodyhtml.=$format; // array_push($this->to,"sneha.anaokar@metropolisindia.com"); // array_push($this->cc,"sneha.anaokar@metropolisindia.com"); } $this->send_mail($subject,$this->from,$this->to,$this->cc,$bodyhtml,$textbody); } } function camp_logistic_reminder() { $sql="SELECT DISTINCT b.zone, b.hq as headquarters FROM abbott_camps a INNER JOIN hq_mast b ON (a.headquarters=b.hq_id) WHERE a.freeze=1 and a.l_freeze=1 AND a.camp_intimation_mail=0 and date(a.camp_date)= ADDDATE(CURDATE(),INTERVAL 1 DAY) ORDER BY b.hq "; $rec=$this->fetchAll($sql); foreach($rec as $k=>$row) { $this->to=array(); $this->cc=array(); $camp_id=$row['camp_id']; $zone=$row['zone']; $headquarters=$row['headquarters']; // $to=$this->getFTM($camp_id); $sql="SELECT DISTINCT a.camp_id, b.zone, b.hq as headquarters, d.logistic_name, d.logistic_number, date_format(a.camp_date,'%d-%M-%Y') as camp_date, a.sample_picup_time, a.venue_address, concat(c.doc_fname,' ',c.doc_lname) as doctor_name, c.qualification as doctor_degree, c.doc_mob_no as doctor_contact_number FROM abbott_camps a INNER JOIN hq_mast b ON (a.headquarters=b.hq_id) left join doctor_master c on a.doc_code=c.doc_code left join abbott_logistic d on a.logistic_id=d.logistic_id WHERE a.freeze=1 AND a.camp_phlebo_mail=0 AND b.zone='$zone' and date(a.camp_date)= ADDDATE(CURDATE(),INTERVAL 1 DAY) ORDER BY b.hq"; $this->data_grid=$this->fetchAll($sql); if(count($this->data_grid)>0) { $zone=$this->data_grid[0]['zone']; $cc=$this->getZone($zone); $tommorow = mktime(date("H"), date("i"), date("s"), date("m"), date("d")+1, date("Y")); $date = date("d-m-Y", $tommorow ); $subject="Sample Pick up Reminder - ".$zone; $bodyhtml="Dear Team,
The following Pick ups are scheduled for tomorrow ".$date.".
"; $new_body=$this->preparetable(); $bodyhtml.=$new_body; // array_push($this->to,"sneha.anaokar@metropolisindia.com"); } $this->send_mail($subject,$this->from,$this->to,$this->cc,$bodyhtml,$textbody); } } } $lm=new abbott_mails(); //$lm->camp_abbott_intimation(); $lm->camp_logistic_reminder(); $lm->camp_logistic_abbott(); echo "End Ok...!"; ?>