Beispiel #1
0
 public function getRegisterCLBalance(&$rsltObject, $loginid, $roleid)
 {
     $rsltObject->cl_balance = 0;
     //SELECT op_balance FROM registers WHERE DATE(created_at) = DATE(NOW()) ORDER BY id ASC LIMIT 1 
     $criteria=new CDbCriteria;
     $criteria->order = 'id DESC';
     $criteria->limit = '1';
     if(!empty($date))
     {
         $condition = " DATE(created_at) = DATE('". $date . "')";
     }
     else
     {
         $condition = "DATE(created_at) = DATE(NOW())";
     }
     $criteria->addCondition($condition);
     $condition = "login_id = " . $loginid;
     $condition .= " AND role_id = " . $roleid;
     $criteria->addCondition($condition);
     $result = Register::model()->findAll($criteria);
     foreach($result as $row)
     {
         $rsltObject->cl_balance = $row->cl_balance;                
         break;
     }
 }
 public function getDefaultObject($rolename)
 {
     $model = new Person;
     $rolename = (!empty($rolename)?$rolename:'');
     $model->role_id = Role::model()->getRoleId( $rolename , true );
     $model->rolename = $rolename;
     $model->enablelogin = false;
     $model->register_id = Register::model()->getDefaultRegisterId();
     $this->setrelationalModels($model);
     $this->setPeopleConfigs($model);
     return $model;
 }
/**
* 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=Register::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
 public function setRegister($record)
 {
     if(strtolower($record->role->role) 
                                 === strtolower(Helper::CONST_Sales))
     {
         $loginid = $record->login->id;
         $roleid = $record->role->id;
         $criteria=new CDbCriteria;
         $criteria->addCondition('login_id = :loginid AND role_id=:roleid
                 AND DATE(salesdate) = DATE(NOW())
                 AND open_time IS NOT NULL
                 AND close_time IS NULL');
         $criteria->params = array(':loginid' => $loginid, ':roleid' => $roleid, );
         $result = Register::model()->findAll($criteria);
         if(empty($result))
         {
             $result = null;
             $register = new Register;
             $register->login_id = $loginid;
             $register->role_id = $roleid;
             $register->salesdate = date(Yii::app()->controller->datetimemysqlformatYMD);
             $register->op_balance = null;
             $rtn = $register->save();
             if($rtn)
             {
                 $result = $register;
             }
         }
         else
         {
             $result = $result[0];
         }
         $this->setState('register',$result);
     }
     else
     {
         $this->setState('register',null);
     }
 }