Ejemplo n.º 1
0
    public function renderCRTypeDashboard()
    {
        $model = new Order ( 'search' );
        $model->unsetAttributes();  // clear any default values
        $model->splsearch = Helper::CONST_Tomorrow;
        $model->hdnactionname = Helper::CONST_indexactionid;

        $timeslotmodel = new Persontimeslot;
        $timeslotmodel->unsetAttributes();
        $timeslotmodel->slotdate = $model->splsearch;

        if ( isset( $_GET['Order'] ) )
        {
            $model->attributes = $_GET['Order'];
            $timeslotmodel->slotdate = $model->splsearch;
        }
        $options = $this->prepareOrderGridOptions($model->hdnactionname, 
                Helper::CONST_grid_Height_200);
        $this->render( $this->getView('index','index'),
                        array(
                            'model' => $model,
                            'origin' => $model->hdnactionname,
                            'options'=> $options,
                            'fromdb' => true,
                            'timeslotmodel' => $timeslotmodel,
                            )
                    );
    }
Ejemplo n.º 2
0
 public function addOrUpdatePersonTimeSlots($personId, $slotdate, $slotvalue)
 {
     if(empty($slotdate)) return false;
     $t1 = '';
     $t2 = '';
     $this->splitCT($slotdate, $t1, $t2);
     $slot = $this->getSlotfromCT($t1);
     $rtn = $slot !== null;
     if(!$rtn) return $rtn;
     
     $criteria=new CDbCriteria();
     $criteria->addCondition('person_id =' . $personId);
     $criteria->addCondition('DATE(slotdate) >= DATE("'. $t1 .'")');
     $result = Persontimeslot::model()->findAll($criteria);
     //$slotdatestr = $slotdate->format('Y-m-d');
     //Yii::app()->controller->getMysqlFormattedDatetime($slotdate)
     if(count($result) > 0)
     {
         $rec= $result[0];
     }
     else if($slotvalue > 0)
     {
         $rec = new Persontimeslot;
     }
     else
     {
         return true;//no work. meaningless.
     }
     $oldvalue = (is_null($rec->$slot))?0:$rec->$slot;
     $newvalue = $oldvalue + $slotvalue;
     if($newvalue <= 0) $newvalue = null;
     $attributes = array('person_id' => $personId
                         ,'slotdate' => $t1
                         ,"$slot" => $newvalue
                         );
     $rec->attributes = $attributes;
     $rtn = $rec->save();
     return $rtn;
 }
Ejemplo n.º 3
0
 private function addOrUpdatePersonTimeSlots($personId, $slotdate, $slotvalue){
     $slot = $this->getSlotfromCT($slotdate);
     if($slot === null){
         return;
     }
     $slotdatestr = $slotdate->format('Y-m-d');
     $conditions = array('person_id=? AND DATE(slotdate)=?', $personId, $slotdatestr);
     $result = \Persontimeslot::find('all', array('conditions' => $conditions));
     $rec===null;
     if(count($result) > 0){
         $rec = $result[0];
         //$rec = \Persontimeslot::find($result[0]->id);
     }
     if($rec===null){
         $attributes = array('person_id' => $personId
                             ,'slotdate' => $slotdate);
         $rec = \Persontimeslot::create($attributes);
     }
     $oldvalue = (is_null($rec->$slot))?0:$rec->$slot;
     $newvalue = $oldvalue + $slotvalue;
     if($newvalue <= 0) $newvalue = null;
     $attributes = array($slot => $newvalue);
     $rec->update_attributes($attributes);
 }
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model=Persontimeslot::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}