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


PHP Build::model方法代码示例

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


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

示例1: 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


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