3

I had created a dropdown list with fields lab,pharmacy and food.When

1.I select the lab it has to send the mail for those islab checkbox is true.

2.when I select the pharmacy it has to send the mail for those ispharmacy checkbox is true and in the same way for food.

I have tried for islab but I could not add for rest of them. Please help me.

mail.phtml

   <?php
   $connectionresource = Mage::getSingleton('core/resource');
   $readconnection = $connectionresource->getConnection('core_read');  
     $allrecord = $readconnection->select()->from(array('serviceprovider'=>'mg_serviceprovider'))->where('serviceprovider.islab=?', '1' 
 );
       $alldata =$readconnection->fetchAll($allrecord);
     foreach($alldata as $data)
     {
          sendMailserviceAction($data['email'],$data['name']);
     }

     function sendMailserviceAction($email,$pname){
 //Mage::getModel('sales/order')->load(24999);
 $cemail=$_POST['email'];
 $bloodgroup=$_POST['bloodgroup'];
 $unitsrequired=$_POST['unitsrequired'];
 $requireddate=$_POST['requiredby'];
 $rcity=$_POST['rcity'];
 $city=$_POST['city'];
 $hospital=$_POST['hospital'];
 //$location=$_POST['location'];

 $name=$_POST['name'];
 $mobile=$_POST['mobile'];
 $yourbloodgroup=$_POST['yourbloodgroup'];

 $html=
'Hi,
<p>
<p><h2>Requisition Details:</h2> </p>
<p>Bloodgroup: '.$bloodgroup.'</p>
 <p>Units Required:'.$unitsrequired.'</p>
 <p>Required By:'. $requireddate.'</p>
 <p>City: '.$rcity.'</p>
 <p>Hospital:'.$hospital.'</p>

 <p><h2>Seeker Details:</h2></p>

 <p>Name: '.$name.'</p>
 <p>Email : '.$cemail.'</p>
 <p>Mobile Number: '.$mobile.'</p>
 <p>City: '.$city.'</p>
 <p>YourBloodgroup:'.$yourbloodgroup.'</p>'

;

 $mail = Mage::getModel('core/email');
  $mail->setToName($pname);
 $mail->setToEmail($email);
 $mail->setBody($html);
 $mail->setSubject('Blood Donor');
 $mail->setFromEmail('admin@labwise.in');
 $mail->setFromName("Labwise");
//$mail->addBcc("admin@labwise.in");
$mail->setType('html');// YOu can use Html or text as Mail format

   try {
  $mail->send();
  //Mage::getSingleton('core/session')->addSuccess('Your Order is successfully Completed');
  //Mage::app()->getResponse()->setRedirect(Mage::getBaseUrl());
//return '<h2>Your Order has been submitted. Thank you for using labwise.   </h2>';
  //$this->_redirect('');
  }
 catch (Exception $e) {
  //Mage::getSingleton('core/session')->addError('Unable to send.');
   //Mage::app()->getResponse()->setRedirect(Mage::getBaseUrl());
 // return '</h2>Unable to submit.</h2>'; 
 //$this->_redirect('');
 }
 }
 echo sendMailserviceAction();

 ?>
  • this is database column name islab? – Qaisar Satti Nov 18 '15 at 4:37
  • yes islab is column name in mg_serviceprovider table – Mouni Nov 18 '15 at 4:47
  • what are value for islab in database? – Qaisar Satti Nov 18 '15 at 4:47
  • islab is checkbox – Mouni Nov 18 '15 at 4:49
  • checkbox have value what are the value of it check the database? – Qaisar Satti Nov 18 '15 at 4:51
3

use this query for or condition..

 $connectionresource = Mage::getSingleton('core/resource');
       $readconnection = $connectionresource->getConnection('core_read');  
       $query="SELECT *
      FROM mg_serviceprovider  where islab='1' or ispharmacy='1'";
  $alldata =$readconnection->fetchAll($query);

         foreach($alldata as $data)
         {
              sendMailserviceAction($data['email'],$data['name']);
         }
| improve this answer | |
  • if islab=1 and ispharmacy=0 it has to send the email for islab provider.Does it works for this condition also. – Mouni Nov 18 '15 at 5:14
  • yes is it using the or condition 1 condition is true it will work – Qaisar Satti Nov 18 '15 at 5:16
  • Ok.When I select the pharmacy from dropdown list it shows an another field upload button and I need to send the attached file to these providers also.How can I send these attachement – Mouni Nov 18 '15 at 5:17
  • ask another question for that with the form that have file name of file. i will answer briefly. – Qaisar Satti Nov 18 '15 at 5:21
  • this code is working or not? and for attachment this will answer ur requirement magento.stackexchange.com/questions/9652/… – Qaisar Satti Nov 18 '15 at 5:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.