'Default', 'basePath' => dirname(__FILE__) )); class ct_accession_pending_mail { var $mysqlconfig; var $mysqldb; var $data_grid; var $from; function ct_accession_pending_mail() { $this->from="ctinfo@metropolisindia.com"; $this->mysqlconfig = new Zend_Config( array( 'database' => array( 'adapter' => 'Pdo_Mysql', 'params' => array( 'host' => 'localhost', 'dbname' => 'intranet', '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 get_coordinator_users($id) // { // // // $sql="Select b.email from ct_accession_manual_details a,ct_Protocol_Study_Master b,ct_protocol_details c where c.name=b.id and a.project_name=c.protocol_id and a.id='$id';"; // $rec= $this->fetchAll($sql); // $tomail=$rec[0]['email']; // // //array_push($this->to,$tomail); // array_push($this->to,"laxmi.bhor@metropolisindia.com"); // //// echo $this->to; //// exit; // return $this->to; // } function send_mail($subject,$from,$to,$cc,$htmlbody) { $config = array('auth' => 'login', 'username' => 'ctinfo@metropolisindia.com', 'password' => 'Cti@#2017', 'ssl' => 'tls', 'port'=> 587 ); $tr = new Zend_Mail_Transport_Smtp('gateway.metropolisindia.com' , $config); //$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) { 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 coordinator_pending_mail() { $htmlbody.="Dear All,
Following Samples are pending for registration, which were received till date.

"; $sql="Select distinct e.email from accessioning a inner join ct_accession_manual_details b on a.accession_num=b.accession_num inner join pan_ctlocations c on c.id=a.location inner join ct_protocol_details d on b.project_name=d.protocol_id inner join ct_Protocol_Study_Master e on e.id=d.name where b.sample_status=0 and e.id=d.name;"; $rec= $this->fetchAll($sql); foreach($rec as $k=>$row) { $email=$row['email']; $to=array(); $cc=array(); $rowbody=""; $sql1="Select e.email,e.name,b.*,a.dispatch_datetime,c.location from accessioning a inner join ct_accession_manual_details b on a.accession_num=b.accession_num inner join pan_ctlocations c on c.id=a.location inner join ct_protocol_details d on b.project_name=d.protocol_id inner join ct_Protocol_Study_Master e on e.id=d.name where b.sample_status=0 and e.id=d.name and e.email='$email' ;"; $rec= $this->fetchAll($sql1); //var_dump($sql1); foreach($rec as $k=>$row) { $accession_num=$row['accession_num']; $dispatch_datetime=$row['dispatch_datetime']; $location=$row['location']; $udate=$row['udate']; $investigator=$row['investigator']; $subject_details=$row['subject_details']; $subject_contact_no=$row['subject_contact_no']; $age=$row['age']; $gender=$row['gender']; $project_name=$row['name']; $trf_received=$row['trf_received']; $payment_received=$row['payment_received']; $test_name=$row['test_name']; $collection_date_time=$row['collection_date_time']; $toemail=$row['email']; $rowbody.=""; } array_push($to,$email); array_push($cc,"it.support@metropolisindia.com"); //array_push($cc,"ajit.dixit@metropolisindia.com"); //array_push($cc,"pooja.narke@metropolisindia.com"); array_push($cc,"mhlct@metropolisindia.com"); array_push($cc,"vijaya.sonawane@metropolisindia.com"); array_push($cc,"dnyandev.phadtare@metropolisindia.com"); array_push($cc,"ctinfo@metropolisindia.com"); //var_dump($to); $tailbody="
Accession_num Dispatch datetime Location Collection date_time Subject Details Gender Age/DOB Project Name Subject contact no Doctor Name Trf Received Test name Payment received Remark Sample status
$accession_num $dispatch_datetime $location $collection_date_time $subject_details $gender $age $project_name $subject_contact_no $investigator $trf_received $test_name $payment_received $remark Pending



Please feel free to revert on below mentioned numbers in case of any query or information required.
Regards,
CT Accession Team
022-50560708"; $subject="Cumulative Data of Samples Pending"; //array_push($cc,"it.support@metropolisindia.com"); // array_push($cc,"aquil.faruqui@metropolisindia.com"); $this->send_mail($subject,$this->from,$to,$cc,$htmlbody.$rowbody.$tailbody); } } } $lm=new ct_accession_pending_mail(); $lm->coordinator_pending_mail(); echo "End Ok...!"; ?>