当前位置: 首页>>代码示例>>PHP>>正文


PHP Employee::validate方法代码示例

本文整理汇总了PHP中Employee::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Employee::validate方法的具体用法?PHP Employee::validate怎么用?PHP Employee::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Employee的用法示例。


在下文中一共展示了Employee::validate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doValidate

 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aRole !== null) {
             if (!$this->aRole->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aRole->getValidationFailures());
             }
         }
         if ($this->aEmployee !== null) {
             if (!$this->aEmployee->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aEmployee->getValidationFailures());
             }
         }
         if (($retval = UserPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
开发者ID:lejacome,项目名称:hospital-mgt,代码行数:37,代码来源:BaseUser.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Employee();
     $user = new RbacUser();
     $disabled = "";
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (Yii::app()->user->checkAccess('employee.create')) {
         if (isset($_POST['Employee'])) {
             $model->attributes = $_POST['Employee'];
             $user->attributes = $_POST['RbacUser'];
             //$location_id = $_POST['Employee']['location'];
             if ($_POST['Employee']['year'] !== "" || $_POST['Employee']['month'] !== "" || $_POST['Employee']['day'] !== "") {
                 $dob = $_POST['Employee']['year'] . '-' . $_POST['Employee']['month'] . '-' . $_POST['Employee']['day'];
                 $model->dob = $dob;
             }
             // validate BOTH $a and $b
             $valid = $model->validate();
             $valid = $user->validate() && $valid;
             if ($valid) {
                 $transaction = $model->dbConnection->beginTransaction();
                 try {
                     if ($model->save()) {
                         $user->employee_id = $model->id;
                         if ($user->save()) {
                             $assignitems = array('items', 'sales', 'employees', 'customers', 'suppliers', 'store', 'receivings', 'reports', 'invoices', 'payments');
                             foreach ($assignitems as $assignitem) {
                                 if (!empty($_POST['RbacUser'][$assignitem])) {
                                     foreach ($_POST['RbacUser'][$assignitem] as $itemId) {
                                         $authassigment = new Authassignment();
                                         $authassigment->userid = $user->id;
                                         $authassigment->itemname = $itemId;
                                         if (!$authassigment->save()) {
                                             $transaction->rollback();
                                             print_r($authassigment->errors);
                                         }
                                     }
                                 }
                             }
                             $transaction->commit();
                             Yii::app()->user->setFlash('success', '<strong>Well done!</strong> successfully saved.');
                             //$this->redirect(array('view', 'id' => $model->id));
                             $this->redirect(array('admin'));
                         } else {
                             Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few things up and try submitting again.');
                         }
                     }
                 } catch (Exception $e) {
                     $transaction->rollback();
                     Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few things up and try submitting again.' . $e);
                 }
             }
         }
     } else {
         throw new CHttpException(403, 'You are not authorized to perform this action');
     }
     $this->render('create', array('model' => $model, 'user' => $user, 'disabled' => $disabled));
 }
开发者ID:noonnightcoder,项目名称:bakou-pos-apsara,代码行数:62,代码来源:EmployeeController.php

示例3: Employee

<?php

require_once '../config/config.php';
require_once '../controller/autoload.php';
require_once '../model/dropdownValues.php';
$emp_obj = new Employee($_POST);
if (isset($_POST['submit'])) {
    $validate = $emp_obj->validate();
    if ($validate['errorFlag'] == true) {
        $displayErrors = implode('<br>', $validate['errorMessage']);
        echo $displayErrors;
    } else {
        $emp_obj->addEmployee();
    }
}
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Register</title>
             <script type = "text/javascript" src = "../../js/Validate.js"></script>
            <link rel = "stylesheet" type = "text/css" 
            href = "../../css/register.css"/>
            <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>  
            <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>  
            <script>  $(document).ready(function() { $("#datepicker").datepicker({  maxDate: new Date("31/12/1997"),minDate: new Date("31/12/1965"),defaultDate: new Date("12/11/1985"),dateFormat: "yy/mm/dd" });});  </script>
            <h1 align = "right">Employee Details</h1>
    </head>
    <body>
        <form method = "POST" action = "">
            <table align = "right" cellpadding = "10" class = "table">
开发者ID:sathish-narayanan,项目名称:lamp,代码行数:31,代码来源:Register.php

示例4: doValidate

 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aPatient !== null) {
             if (!$this->aPatient->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aPatient->getValidationFailures());
             }
         }
         if ($this->aEmployeeRelatedByDoctorId !== null) {
             if (!$this->aEmployeeRelatedByDoctorId->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aEmployeeRelatedByDoctorId->getValidationFailures());
             }
         }
         if ($this->aWardBed !== null) {
             if (!$this->aWardBed->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aWardBed->getValidationFailures());
             }
         }
         if ($this->aEmployeeRelatedByWardDocId !== null) {
             if (!$this->aEmployeeRelatedByWardDocId->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aEmployeeRelatedByWardDocId->getValidationFailures());
             }
         }
         if (($retval = VisitPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         if ($this->collLabReports !== null) {
             foreach ($this->collLabReports as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collVisitMedicines !== null) {
             foreach ($this->collVisitMedicines as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
开发者ID:lejacome,项目名称:hospital-mgt,代码行数:61,代码来源:BaseVisit.php

示例5: ImportEmployee

 static function ImportEmployee()
 {
     // Делаем запись в таблицу отчетов импорта
     $logreport = new Logreport();
     $logreport->logreport_date = date('Y-m-d');
     $logreport->save();
     self::$logreport_id = $logreport->logreport_id;
     // Идем по файлам импорта из 1С (сотрудники.txt - Сотрудники)
     foreach (['сотрудники.txt'] as $filename) {
         self::$filename = mb_convert_encoding('imp/' . $filename, 'Windows-1251', 'UTF-8');
         if (file_exists(self::$filename)) {
             ini_set('max_execution_time', 1000);
             // 1000 seconds
             ini_set('memory_limit', 1073741824);
             // 1Gbyte Max Memory
             // Определяем показатели импорта
             self::$logreport_errors = 0;
             // Не загружено записей из-за ошибок
             self::$logreport_additions = 0;
             // Записей добавлено
             self::$logreport_amount = 0;
             // Всего записей
             $i = 0;
             $handle = @fopen(self::$filename, "r");
             if ($handle) {
                 while (($subject = fgets($handle, 4096)) !== false) {
                     $i++;
                     $pattern = '/^(.+?)\\|(Поликлиника №\\s?[1,2,3] )?(.+?)\\|(.+?)\\|/ui';
                     preg_match($pattern, $subject, $matches);
                     if ($matches[0] !== NULL) {
                         $pattern = '/(^Поликлиника №)\\s?([1,2,3])\\s?$/ui';
                         $matches[2] = preg_replace($pattern, 'Взрослая $1$2', mb_strtolower($matches[2], 'UTF-8'));
                         if ($matches[3] === 'Поликлиника профилактических осмотров') {
                             $matches[2] = $matches[3];
                         }
                         $pattern = '/^(.+) БУ "Нижневартовская городская поликлиника"$/ui';
                         $matches[3] = preg_replace($pattern, '$1', $matches[3]);
                         $employee_fio = $matches[1];
                         $location = self::AssignLocationForEmployeeImport($matches[3], $matches[2]);
                         $id_dolzh = self::AssignDolzh($matches[4]);
                         // На случай если Здание у сотрудника не определено
                         $buildsql = $location->id_build === null ? 'id_build IS NULL' : 'id_build = :id_build';
                         // Находим сотрудника в базе, если не находим создаем новую запись
                         $Employee = Employee::model()->Find('employee_fio LIKE :employee_fio and id_dolzh = :id_dolzh and id_podraz = :id_podraz and ' . $buildsql, array_merge([':employee_fio' => $employee_fio, ':id_dolzh' => $id_dolzh, ':id_podraz' => $location->id_podraz], $location->id_build === null ? [] : [':id_build' => $location->id_build]));
                         if ($Employee === null) {
                             $Employee = new Employee();
                             $Employee->attributes = ['employee_fio' => $employee_fio, 'id_dolzh' => $id_dolzh, 'id_podraz' => $location->id_podraz, 'id_build' => $location->id_build];
                             $Employeelog = new Employeelog();
                             $Employeelog->id_logreport = self::$logreport_id;
                             $Employeelog->employeelog_type = 1;
                             $Employeelog->employeelog_filename = mb_convert_encoding(self::$filename, 'UTF-8', 'Windows-1251');
                             $Employeelog->employeelog_rownum = $i;
                             $Employeelog->employeelog_message = 'Запись добавлена.';
                             $Employee->scenario = 'import1c';
                             if ($Employee->validate()) {
                                 self::$logreport_additions++;
                                 $Employee->save(false);
                             } else {
                                 $Employeelog->employeelog_type = 3;
                                 $Employeelog->employeelog_message = 'Ошибка при добавлении записи: ';
                                 foreach ($Employee->getErrors() as $fields) {
                                     $Employeelog->employeelog_message .= implode(' ', $fields) . ' ';
                                 }
                                 self::$logreport_errors++;
                             }
                             $Employeelog->employee_fio = $Employee->employee_fio;
                             $Employeelog->dolzh_name = Dolzh::model()->findbyPk($Employee->id_dolzh)->dolzh_name;
                             $Employeelog->podraz_name = Podraz::model()->findbyPk($Employee->id_podraz)->podraz_name;
                             if ($Employee->id_build !== null) {
                                 $Employeelog->build_name = Build::model()->findbyPk($Employee->id_build)->build_name;
                             }
                             $Employeelog->save(false);
                         }
                     } elseif (trim($subject) !== '') {
                         $Employeelog = new Employeelog();
                         $Employeelog->id_logreport = self::$logreport_id;
                         $Employeelog->employeelog_type = 3;
                         $Employeelog->employeelog_filename = mb_convert_encoding(self::$filename, 'UTF-8', 'Windows-1251');
                         $Employeelog->employeelog_rownum = $i;
                         $Employeelog->employeelog_message = 'Ошибка при добавлении записи: Не пройдено регулярное выражение /^(.+?)\\|(Поликлиника №\\s?[1,2,3] )?(.+?)\\|(.+?)\\|/ui';
                         $Employeelog->save(false);
                         self::$logreport_errors++;
                     }
                 }
                 fclose($handle);
             }
             $logreport->logreport_additions += self::$logreport_additions;
             $logreport->logreport_errors += self::$logreport_errors;
             $logreport->logreport_amount = $i;
             $logreport->save();
         }
     }
     echo '<BR>Подразделения:<BR>';
     ARData::Data(Podraz::model(), Podraz::model()->Test())->PrintData();
     echo '<BR>Должности:<BR>';
     ARData::Data(Dolzh::model(), Dolzh::model()->Test())->PrintData();
     echo '<BR>Сотрудники:<BR>';
     ARData::Data(Employee::model(), Employee::model()->Test())->PrintData();
     echo '<BR>Лог:<BR>';
     ARData::Data(Employeelog::model(), Employeelog::model()->Test())->PrintData();
//.........这里部分代码省略.........
开发者ID:vovancho,项目名称:baseportal,代码行数:101,代码来源:FregatImport.php


注:本文中的Employee::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。