السلام عليكم
انا عندي مشكلة عملت فورم لطلب موعد للمريض مع دكتور معين بهذه الصورة
Patient's Name
Appointment Date
Appointment Time
Mobile Number
Best Time to Call Back
Alternate Time
Alternate Date
Choose Doctor (قائمة باسماء الدكاترة من sql data base)
انا ابغا كل ما ختار اسم دكتور معين يترسل اطلب الموعد على ايميله و كل دكتور له ايميل
بس هنا عندي بيرسل كل الطلبات لايملي واحد
كيف اقدر احدد في الكود انو لكل دكتور يترسل الطلب لايميله هو فقط
هذا الكود
<?php
defined('_JEXEC') or die();
jimport( 'joomla.application.component.model' );
class AppointmentModelAppointment extends JModel
{
function getDoctorName($id)
{
$query = 'SELECT firstname,lastname FROM #__doctor WHERE id='.$id;
$this->_db->setQuery( $query );
$rows = $this->_db->loadObjectList();
$FullName=$rows[0]->firstname." ".$rows[0]->lastname;
return $FullName;
}
function getDoctor3()
{
$query = 'SELECT id AS value,CONCAT(firstname,lastname) as text FROM #__doctor ORDER by firstname';
$doctors[] = JHTML::_('select.option', '0', JText::_( 'Select Prefrence' ));
$this->_db->setQuery($query);
$doctors = array_merge($doctors, $this->_db->loadObjectList());
$lists = JHTML::_('select.genericlist', $doctors,'prefrence', ' class="inputbox" style="width:150px;" size="1"', 'value', 'text','');
return $lists;
}
function store()
{
global $mainframe;
$row =& $this->getTable();
$data = JRequest::get( 'post' );
// Bind the form fields to the appointment table
if (!$row->bind($data))
{
$this->setError($this->_db->getErrorMsg());
return false;
}
// Make sure the appointment record is valid
if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Store the web link table to the database
if (!$row->store()) {
$this->setError( $row->getErrorMsg() );
return false;
}
$this->sendmail($data);
$mainframe->redirect("index2.php?option=com_content&view=article&id=110&Itemid=144");
return true;
}
function sendmail($post)
{
global $mainframe;
$mailfrom = $mainframe->getCfg( 'mailfrom' );
$fromname = $mainframe->getCfg( 'fromname' );
$email ="rasha.alcattan@almashfa.com";
$subject="New Appointment";
$message='<table width="100%" border="0">
<tr>
<td><b>'.JText::_("Patient's Name").'</b></td>
<td>'.$post['patientname'].'</td>
</tr>
<tr>
<td><b>'.JText::_("Appointment Date").'</b></td>
<td>'.$post['appointmentdate'].'</td>
</tr>
<tr>
<td><b>'.JText::_("Appointment Time").'</b></td>
<td>'.$post['appointmenttime'].'</td>
</tr>
<tr>
<td><b>'.JText::_("Mobile Number").'</b></td>
<td>'.$post['mobile'].'</td>
</tr>
<tr>
<td><b>'.JText::_("Best Time to Call Back").'</b></td>
<td>'.$post['callbacktime'].'</td>
</tr>
<tr>
<td><b>'.JText::_("Alternate Date").'</b></td>
<td>'.$post['alternatedate'].'</td>
</tr>
<tr>
<td><b>'.JText::_("Alternate Time").'</b></td>
<td>'.$post['preferredtime1'].'</td>
</tr>
<tr>
<td><b>'.JText::_("Prefrence").'</b></td>
<td>'.$this->getDoctorName($post['prefrence']).'</td>
</tr>
</table>';
JUtility::sendMail($mailfrom, $fromname, $email, $subject, $message,$mode=1);
}
}
