views/doctorshedule    code

<?php echo $html->css('calendar.css'); ?>
<?php echo $javascript->link('prototype', false); ?>
<div id="contentarea">
<div id="container">
<div id="containertitle">Doctor Schedule</div>
<div id="formarea">
<div class='form'>
<?php echo $form->create('Doctorschedule', array('action' =>
'addnew'));?>
<table border=0 width="800" bgcolor="#FFFFFF">
<tr height='5'><td colspan="2" class='errDiv'><?php  echo $errValDS;  ?
></td></tr>

<tr><td align="right" width="50%"><label for="Department"
class="formnormaltext">Department :</label></td><td width="50%">

<?php echo $form->select('department_id',$departments,null,array('id'
=> 'departmentId'),null,null,false); ?></td></tr>

<tr><td align="right"><label for="Doctor"
class="formnormaltext">Doctor :</label></td><td>
<?php
if(!isset($abc))
{
$abc='';
}
?>

<?php echo $form->select('doctor_id',$doctrs,array('default'=>
$abc),array('id' => 'doctor_id')); ?>

</td></tr>
<tr height='5'><td colspan="2"></td></tr>
<tr><td colspan="2" align="center">
<div id="test">

<?php

if(!isset($year))
{
$year='';
$month='';
$data='';
$base_url='';
$dat='';
$abc='';
}
if(!isset($abc))
{
$data='';
$base_url='';
$dat='';
$abc='';
}
//echo $abc;
echo $calendar->calendar($year, $month,$data, $base_url='',$dat,
$abc); ?>

</div>



</td></tr>
</table>
<?php

//echo $calendar->calendar($year, $month, $data, $base_url);

echo $ajax->observeField('doctor_id',array
('url'=>'calendar','update'=>'test'));
echo $ajax->observeField('departmentId',array
('url'=>'update_doctor_select','update'=>'doctor_id'));

?>

</div>
</div>
</div>

***************************************************************************************************************
controller

class DoctorschedulesController extends AppController {
var $name = 'Doctorschedules';
var $paginate = array('limit' => 20, 'page' => 1, 'order' =>array
('Doctorschedule.scheduled_date'=>'asc'));

 function beforeRender(){
if($this->RequestHandler->isAjax())
{
Configure::write('debug',0);
//prevent useless warnings for Ajax
}
}
function index($prev = null,$prev_month = null,$did= null)
{
        //$this->Session->read('errValDS');
$this->set('errValDS',$this->Session->read('errValDS'));
$this->Session->write('errValDS','');

if(isset($did))
{

$view_base_url = $this->webroot. 'doctorschedules';
$year=$prev;
$month=$prev_month;
$docid=$did;
//echo "doc id=".$docid;
$this->set('year', $year);
$this->set('month',$month);
$this->set('abc',$docid);
$data = null;
$dat = null;
                if(!$year || !$month)
                        {
                                $year = date('Y');
                                $month = date('M');


                                $month_num = date('n');
                                $item = null;
                        }

                $month_num =date("m", strtotime($month));
                $flag=1;

                if($flag == 0) { // if no date set, then use the default values
                                $year = date('Y');
                                $month = date('M');
                                $month_name = date('F');
                                $month_num = date('m');
                }

                $fields = array('id', 'doctor_id', 'DAY(scheduled_date) AS
event_day','doctor_status');

                $var = $this->Doctorschedule->findAll('MONTH
(Doctorschedule.scheduled_date) = ' . $month_num .' AND
Doctorschedule.doctor_id='.$docid.' AND YEAR
(Doctorschedule.scheduled_date) = ' . $year, $fields,
'Doctorschedule.scheduled_date ASC');

        $flg=0;
        //print_r($var);
        foreach($var as $v)
        {

                                if(isset($v[0]['event_day'])) {
                                $day = $v[0]['event_day'];
                                $flg=1;
                                $stats = $v['Doctorschedule']['doctor_status'];

                                }


                                //echo $flag;
                                if($flg==1)
                                {

                                if(isset($data[$day]))
                                        {

                                        $sql = "select name from doctors where 
id='".$v['Doctorschedule']
['doctor_id']."'";

                                        $val  
=$this->Doctorschedule->Doctor->query($sql);

                                        $name=$val[0]['doctors']['name'];


                                                //$data[$day] .= '<br /><a 
href="' . $view_base_url . '/view/' .
$v['Event']['id'] . '">' . $v['Event']['doctor_id'] . '</a>';

                                        //      $data[$day] .= '<br /><a 
href="' . $view_base_url . '/view/' .
$v['Event']['id'] . '">' . $name . '</a>';
                                        //$data[$day] .= '<br /><a href="' . 
$view_base_url . '/edit/' .
$v['Doctorschedule']['id'] . '">' . $name . '</a>';
                                        $data[$day] .= '<a href="' . 
$view_base_url . '/edit/' . $v
['Doctorschedule']['id'] . '">';
                                        $dat[$day]=$stats;


                                        }
                                else
                                        {

                                                $sql = "select name from 
doctors where id='".$v['Doctorschedule']
['doctor_id']."'";

                                                $val  
=$this->Doctorschedule->Doctor->query($sql);

                                                
$name=$val[0]['doctors']['name'];



                                                //$data[$day] = '<a href="' . 
$view_base_url . '/view/' . $v
['Event']['id'] . '">' . $name . '</a>';
                                        //      $data[$day] = '<br /><a href="' 
. $view_base_url . '/edit/' .
$v['Doctorschedule']['id'] . '">' . $name . '</a>';
                                                $data[$day] = '<a href="' . 
$view_base_url . '/edit/' . $v
['Doctorschedule']['id'] . '">';
                                                                                
//      $data[$day] .= '<br /><a href="' . $view_base_url . '/
view/' . $v['Event']['id'] . '">' . $val . '</a>';

                                                $dat[$day]=$stats;


          }
}
}
$this->set('data', $data);
$this->set('dat', $dat);
//print_r($dat);


//========================================
}


$this->checkSession();
                $user = $this->Session->read('User');
                $this->set('user',$user);
                $departments = $this->Doctorschedule->Doctor->Department->find
('list');
                $this->set('departments', $departments);
                $doctrs = $this->Doctorschedule->Doctor->find('list',array
('conditions'=>array('status
not'=>'DELETED','work_status'=>'Working')));

                $this->set('doctrs', $doctrs);

//============================== index end
}
}
************************************************************************************
model

<?php
class Doctorschedule extends AppModel {
var $name = 'Doctorschedule';

        var $validate = array(
        'doctor_id' => array(
        'rule' => 'notEmpty',
        'message' => 'Doctor cannot be empty'
        )
        );

  var $belongsTo = array('Doctor' =>
                           array('className'  => 'Doctor',
                                 'conditions' => '',
                                 'order'      => '',
                                 'foreignKey' => 'doctor_id'
                           )
                     );
/*var $hasMany = array('Patient' =>
                         array('className'     => 'Patient',
                               'conditions'    => 'Comment.moderated =
1',
                               'order'         => 'Comment.created
DESC',
                               'limit'         => '',
                               'foreignKey'    => 'patient_id',
                               'dependent'     => true,
                               'exclusive'     => false,
                               'finderQuery'   => ''
                                                        )
                                        );*/

function getMaxToken($dt,$doctor)
{
        $sqlT = "select max_token from doctorschedules where
scheduled_date='$dt' and doctor_id='$doctor'";
        $tokenMax = $this->query($sqlT);
        echo $tokenMaxVal = $tokenMax[0][0]['max_token'];

}


}
?>
******************************************************************

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to