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


PHP Project::findFirst方法代码示例

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


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

示例1: updateAction

 public function updateAction()
 {
     $oper = $this->request->getPost('oper', 'string');
     if ($oper == 'edit') {
         $id = $this->request->getPost('id', 'int');
         $project = Project::findFirst($id);
         $project->username = $this->request->getPost('begintime', 'string');
         $project->password = $this->request->getPost('endtime', 'string');
         $project->name = $this->request->getPost('name', 'string');
         $project->description = $this->request->getPost('description', 'string');
         if (!$project->save()) {
             foreach ($project->getMessages() as $message) {
                 echo $message;
             }
         }
     }
     if ($oper == 'del') {
         $id = $this->request->getPost('id', 'int');
         $manager = Project::findFirst($id);
         if (!$manager->delete()) {
             foreach ($manager->getMessages() as $message) {
                 echo $message;
             }
         }
     }
 }
开发者ID:Brucewyh,项目名称:Questionnaire,代码行数:26,代码来源:AdminController.php

示例2: delproject

 /**
  * @usage 删除项目, 删除project
  * 由于数据库中采取使用外键级联与project相关的所有信息
  */
 public static function delproject($project_id)
 {
     try {
         $manager = new TxManager();
         $transaction = $manager->get();
         $project_info = Project::findFirst($project_id);
         $project_info->setTransaction($transaction);
         if ($project_info->delete() == false) {
             $transaction->rollback("数据删除失败-" . print_r($project_info, true));
         }
         $transaction->commit();
         return true;
     } catch (TxFailed $e) {
         throw new Exception($e->getMessage());
     }
 }
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:20,代码来源:AdminDB.php

示例3: LoadExaminee

 /**
  * 被试人员导入
  * TODO: 后面超过4条的部分
  */
 public function LoadExaminee($filename, $project_id, $db)
 {
     PHPExcel_Settings::setCacheStorageMethod(PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip);
     $project = Project::findFirst($project_id);
     $last_number = 1;
     $db->begin();
     if (is_readable($filename)) {
         try {
             $objexcel = PHPExcel_IOFactory::load($filename);
             $sheet = $objexcel->getSheet(0);
             $higestrow = $sheet->getHighestRow();
             $last_number = $project->last_examinee_id;
             $i = 3;
             while ($i <= $higestrow) {
                 $k = $sheet->getCell("C" . $i)->getValue();
                 if (is_null($k) || $k == "") {
                     break;
                 }
                 $this->readline_examinee($sheet, $project_id, $last_number, $i);
                 $i++;
                 $last_number++;
             }
         } catch (Exception $ex) {
             $errors['Exception'] = $ex->getMessage();
             $db->rollback();
             $objexcel->disconnectWorksheets();
             unlink($filename);
             return $errors;
         }
     }
     $project->last_examinee_id = $last_number;
     $project->save();
     $db->commit();
     $objexcel->disconnectWorksheets();
     unlink($filename);
     return 0;
 }
开发者ID:Brucewyh,项目名称:Questionnaire,代码行数:41,代码来源:ExcelLoader.php

示例4: getdetailAction

 public function getdetailAction()
 {
     $this->view->disable();
     $manager = $this->session->get('Manager');
     if (empty($manager)) {
         $this->dataReturn(array('error' => '用户信息失效,请重新登录!'));
         return;
     }
     $project_id = $manager->project_id;
     $project = Project::findFirst($project_id);
     if (!isset($project->id)) {
         $this->dataReturn(array('error' => '项目不存在,请联系管理员'));
         return;
     }
     $ans_array = array();
     $ans_array['project_name'] = $project->name;
     $ans_array['begintime'] = $project->begintime;
     $ans_array['endtime'] = $project->endtime;
     $ans_array['state'] = $project->state == 2 ? true : false;
     $ans_array['inquery'] = false;
     $ans_array['exam'] = false;
     if ($project->state == 1) {
         $inquery = InqueryQuestion::findFirst(array('project_id=?1', 'bind' => array(1 => $project_id)));
         if (isset($inquery->project_id)) {
             $ans_array['inquery'] = true;
         } else {
             $ans_array['exam'] = true;
         }
     }
     if ($project->state == 2) {
         $ans_array['inquery'] = true;
         $ans_array['exam'] = true;
     }
     //项目详情只显示被试
     $examinees = Examinee::find(array('project_id=?1 AND type = 0', 'bind' => array(1 => $project_id)));
     //获取该项目下答题的总人数
     $ans_array['exam_count'] = count($examinees);
     $examinee_com = 0;
     $examinee_coms = array();
     $examinee_not_coms = array();
     foreach ($examinees as $examinee) {
         if ($examinee->state > 0) {
             $examinee_com++;
             $examinee_coms[$examinee_com - 1] = $examinee->id;
         } else {
             $examinee_not_coms[] = $examinee->id;
         }
     }
     //答题完成人数
     $ans_array['exam_finish'] = $examinee_com;
     $interview_com = 0;
     for ($i = 0; $i < $examinee_com; $i++) {
         $interview = Interview::findFirst(array("examinee_id =:id:", 'bind' => array('id' => $examinee_coms[$i])));
         //判定条件
         if (!empty($interview->advantage) && !empty($interview->disadvantage) && !empty($interview->remark)) {
             $interview_com++;
         }
     }
     $ans_array['interview_finish'] = $interview_com;
     $this->dataReturn(array('success' => $ans_array));
     return;
 }
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:62,代码来源:PmController.php

示例5: updateAction

 public function updateAction()
 {
     $this->view->disable();
     $oper = $this->request->getPost('oper', 'string');
     if ($oper == 'edit') {
         //edit
         //修改之前应该判断数据库中是否已经存在记录 -- 目前在前端进行判定2015-9-12
         $id = $this->request->getPost('id', 'int');
         $project = Project::findFirst($id);
         $project->name = $this->request->getPost('name', 'string');
         #项目开始时间不可变更
         $project->begintime = $this->request->getPost('begintime', 'string');
         $project->endtime = $this->request->getPost('endtime', 'string');
         $project->description = $this->request->getPost('description', 'string');
         $manager = Manager::findFirst(array('project_id=?0', 'bind' => array($id)));
         $manager->name = $this->request->getPost('manager_name', 'string');
         $manager->username = $this->request->getPost('manager_username', 'string');
         $manager->password = $this->request->getPost('manager_password', 'string');
         #时间检查
         if (strtotime($project->begintime) >= strtotime($project->endtime)) {
             $this->dataReturn(array('error' => '项目结束时间与开始时间冲突'));
             return;
         }
         try {
             AdminDB::updateManager($manager);
             AdminDB::updateProject($project);
         } catch (Exception $e) {
             $this->dataReturn(array('error' => '项目信息更新失败'));
             return;
         }
         $this->dataReturn(array('flag' => true));
         return;
     } else {
         if ($oper == 'del') {
             //del
             //需要添加判断是否能被删除 --目前还未添加相应的判定
             $id = $this->request->getPost('id', 'int');
             $project_info = Project::findFirst($id);
             if (!isset($project_info->id)) {
                 $this->dataReturn(array('error' => '项目编号不存在'));
                 return;
             } else {
                 #判断项目状态,如果不是项目的初始状态则禁止删除
                 if ($project_info->state != 0) {
                     $this->dataReturn(array('error' => '项目经理已配置了项目,不能被删除'));
                     return;
                 } else {
                     try {
                         AdminDB::delproject($id);
                     } catch (Exception $e) {
                         $this->dataReturn(array('error' => '项目删除失败'));
                         return;
                     }
                     $this->dataReturn(array('flag' => true));
                     return;
                 }
             }
         } else {
             //
         }
     }
 }
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:62,代码来源:AdminController.php

示例6: loginAction

 public function loginAction()
 {
     $username = $this->request->getPost("username", "string");
     $password = $this->request->getPost("password", "string");
     if (!LoginConfig::IsOnlyNumber($username)) {
         $this->dataReturn(array('error' => '账号输入错误'));
         return;
     }
     if (!LoginConfig::IsOnlyNumberAndLetter($password)) {
         $this->dataReturn(array('error' => '密码输入错误'));
         return;
     }
     if (strlen($username) == 8) {
         $examinee = Examinee::checkLogin($username, $password);
         if ($examinee === 0) {
             $this->dataReturn(array('error' => '密码不正确'));
             return;
         }
         if ($examinee === -1) {
             $this->dataReturn(array('error' => '用户不存在'));
             return;
         }
         if ($examinee) {
             $project = Project::findFirst($examinee->project_id);
             $now = date('y-m-d h:i:s');
             if (strtotime($now) < strtotime($project->begintime)) {
                 $this->dataReturn(array('error' => '测评还未开启,请在测评开启后登录'));
                 return;
             }
             if (strtotime($now) > strtotime($project->endtime)) {
                 $this->dataReturn(array('error' => '测评已经结束,请在测评开启时间内登录'));
                 return;
             }
             if ($examinee->state > 0) {
                 $this->dataReturn(array('error' => '您已参加过测评,不能再次登录'));
                 return;
             }
             if ($project->state < 2) {
                 $this->dataReturn(array('error' => '本次测评配置还未完成,请待配置完成后登录'));
                 return;
             }
             $this->session->set('Examinee', $examinee);
             #添加绿色通道人员直接到个人信息编辑页
             if ($examinee->type == 1) {
                 $this->dataReturn(array('url' => '/examinee/editinfo'));
                 return;
             }
             if (LoginConfig::IsInqueryFinish($examinee->id)) {
                 $this->dataReturn(array('url' => '/examinee/editinfo'));
             } else {
                 $this->dataReturn(array('url' => '/examinee/inquery'));
             }
         }
     } else {
         if (strlen($username) == 7) {
             $manager = Manager::checkLogin($username, $password);
             if ($manager === 0) {
                 $this->dataReturn(array('error' => '密码不正确'));
                 return;
             }
             if ($manager === -1) {
                 $this->dataReturn(array('error' => '用户不存在'));
                 return;
             }
             if ($manager) {
                 if ($manager->role == 'L') {
                     $this->session->set('Manager', $manager);
                     $this->dataReturn(array('url' => '/leader/index'));
                 } else {
                     $this->dataReturn(array('error' => '请在后台登录入口登录<a href=\'/managerlogin\'>点击跳转</a>'));
                 }
             }
         } else {
             $this->dataReturn(array('error' => '用户不存在'));
             return;
         }
     }
 }
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:78,代码来源:IndexController.php

示例7: getProject

 public function getProject($project_id = null)
 {
     if ($project_id) {
         return Project::findFirst($project_id);
     } else {
         if ($this->project == null) {
             $this->project = $this->getProject($this->project_id);
         }
     }
     return $this->project;
 }
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:11,代码来源:SearchSource.php

示例8: insertInquery

 public static function insertInquery($data, $project_id)
 {
     try {
         self::delInquery($project_id);
         #插入新数据
         $manager = new TxManager();
         $transaction = $manager->get();
         foreach ($data as $value) {
             $inquery = new InqueryQuestion();
             $inquery->setTransaction($transaction);
             foreach ($value as $key => $svalue) {
                 $inquery->{$key} = $svalue;
             }
             $inquery->project_id = $project_id;
             if ($inquery->save() == false) {
                 $transaction->rollback('数据更新失败-3');
             }
         }
         $type = false;
         #更新项目状态
         $project = Project::findFirst(array("id=?1", 'bind' => array(1 => $project_id)));
         $project->setTransaction($transaction);
         $state = self::getProjectStateNext($project, $type);
         $project->state = $state;
         if ($project->save() == false) {
             $transaction->rollback("数据插入失败-4");
         }
         $transaction->commit();
         return true;
     } catch (TxFailed $e) {
         throw new Exception($e->getMessage());
     }
 }
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:33,代码来源:PmDB.php

示例9: report

 public function report($project_id)
 {
     $data = new ProjectComData();
     $data->project_check($project_id);
     $chart = new WordChart();
     $project = Project::findFirst($project_id);
     //-----------------------------------
     \PhpOffice\PhpWord\Autoloader::register();
     $this->wordHandle = new \PhpOffice\PhpWord\PhpWord();
     // layout
     $sectionStyle = array('orientation' => 'portrait', 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.2), 'marginRight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.2), 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(2.2), 'marginBottom' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1.9), 'pageSizeW' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(21), 'pageSizeH' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(29.7), 'headerHeight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1), 'footerHeight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(0.8));
     //add section
     $section = $this->wordHandle->addSection($sectionStyle);
     $section->getStyle()->setPageNumberingStart(1);
     $header = $section->addHeader();
     $header = $header->createTextrun();
     $header->addImage('reportimage/logo_2.jpg', array('marginTop' => -1, 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToInch(1), 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(5.98), 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1.54), 'wrappingStyle' => 'square'));
     $header->addText($project->name . "总体分析报告", array('color' => 'red', 'size' => 11), array('lineHeight' => 1, 'alignment' => 'right'));
     $footer = $section->addFooter();
     $footer->addPreserveText('{PAGE}', array('size' => 10, 'color' => '000000'), array('alignment' => 'center', 'lineHeight' => 1));
     //cover part
     $paragraphStyle = array('alignment' => 'center', 'lineHeight' => 1.5);
     $defaultParagraphStyle = array('lineHeight' => 1.5);
     $captionFontStyle = array('name' => 'Microsoft YaHei', 'size' => 22, 'color' => 'red', 'bold' => true);
     $section->addTextBreak(6);
     $section->addText($project->name . "总体分析报告", $captionFontStyle, $paragraphStyle);
     $section->addPageBreak();
     //set title style---TOC
     $this->wordHandle->addTitleStyle(1, array('size' => 16, 'bold' => true), array('lineHeight' => 1.5));
     $this->wordHandle->addTitleStyle(2, array('size' => 15, 'bold' => true), array('lineHeight' => 1.5));
     $this->wordHandle->addTitleStyle(3, array('size' => 12, 'bold' => true), array('lineHeight' => 1.5));
     //catalog part
     $section->addText("目录", array('color' => 'blue', 'size' => 12), $paragraphStyle);
     $section->addTOC(array('size' => 12), \PhpOffice\PhpWord\Style\TOC::TABLEADER_LINE, 1, 3);
     $section->addPageBreak();
     $captionFontStyle2 = array('name' => 'Microsoft YaHei', 'size' => 18, 'color' => 'red', 'bold' => true);
     $section->addText($project->name . "总体分析报告", $captionFontStyle2, $paragraphStyle);
     //part1  项目背景
     $section->addTitle("一、项目背景", 1);
     //-------------------------------------------------------------------------
     $examinee = Examinee::find(array('project_id=?1 AND type = 0 ', 'bind' => array(1 => $project_id)));
     $examinee = $examinee->toArray();
     $examinee_num = count($examinee);
     //总人数
     $exam_date_start = explode(' ', $project->begintime)[0];
     //开始时间
     $exam_date_end = explode(' ', $project->endtime)[0];
     //结束时间
     $min_time = 0;
     $total_time = 0;
     $level_array = array(1 => 0, 2 => 0, 3 => 0, 4 => 0);
     foreach ($examinee as $examinee_record) {
         if ($min_time == 0 || $min_time > $examinee_record['exam_time']) {
             $min_time = $examinee_record['exam_time'];
         }
         $total_time += $examinee_record['exam_time'];
         $level = ReportData::getLevel($examinee_record['id']);
         $level_array[$level]++;
     }
     $min_time_str = null;
     foreach (array(3600 => '小时', 60 => '分', 1 => '秒') as $key => $value) {
         if ($min_time >= $key) {
             $min_time_str .= floor($min_time / $key) . $value;
             $min_time %= $key;
         }
     }
     //最短答题时间
     $average_time = $total_time / $examinee_num;
     $average_time_str = null;
     foreach (array(3600 => '小时', 60 => '分', 1 => '秒') as $key => $value) {
         if ($average_time >= $key) {
             $average_time_str .= floor($average_time / $key) . $value;
             $average_time %= $key;
         }
     }
     //平均答题时间
     $rate_1 = sprintf('%.2f', $level_array[1] / $examinee_num) * 100 . '%';
     //优秀率
     $rate_2 = sprintf('%.2f', $level_array[2] / $examinee_num) * 100 . '%';
     //良好率
     $rate_3 = sprintf('%.2f', $level_array[3] / $examinee_num) * 100 . '%';
     //中等率
     //	---------------------------------------------------------
     $section->addText("    为了充分开发中青年人才资源,了解中青年人才水平、培养有潜力人才及科技骨干、选拔一批经验丰富,德才兼备的中青年高技能人才,北京XXX集团(后简称“集团”),采用第三方北京技术交流培训中心(以下简称“中心”)自主研发26年,通过上下、左右、前后六维(简称“6+1”)测评技术,对集团" . $examinee_num . "名中青年人才进行了一次有针对性的测评。从" . $exam_date_start . "到" . $exam_date_end . ",在集团培训中心进行上机测试。规定测评时间为3小时,最短完成时间为" . $min_time_str . ",一般为" . $average_time_str . "左右。 ", $defaultParagraphStyle);
     $section->addText("    测评后进行专家(四位局级以上领导干部)与中青年人才一对一人均半小时的沟通(简称“面询”), 这是区别国内所有综合测评机构的独有特色。面询内容有三:一是根据测评结果按优劣势分析归纳与评价;二是双方互动理解与确认测评结果;三是现场解答每位人才提出的问题,并给予针对性、个性化的解决方案与建议。", $defaultParagraphStyle);
     $section->addText("    通过对" . $examinee_num . "位中青年人才综合统计分析,按优良中差排序结果为:全体优秀率达" . $rate_1 . ",良好" . $rate_2 . "。在测评和专家面询后,对全部人才进行了无记名的满意度调查,参加调查83人,回收有效问卷83份,有效率100%,满意度100%。(满意度调查报告详见附件1) ", $defaultParagraphStyle);
     $section->addTitle("1、测评目的", 2);
     $section->addTitle("第一、为中青年人才培训提供科学参考依据", 3);
     $section->addText("    在传统的人事管理信息系统中,人与人之间的差别只体现在性别、年龄、职务、工种、学历、职称、工作经历上,而却忽略了内隐素质能力上的差异。综合测评可以帮助集团领导了解中青年人才更多重要的信息,为个性化培养与培训提供科学、准确的依据。在对人才进行精准识别后,还进行了人岗匹配,针对岗位胜任程度和潜质提出了使用与培养的建议。通过本次测评,清晰了集团中青年人才职业心理、职业素质、智体结构、职业能力和发展潜质,为集团下一步的培训工作提供了科学、客观、准确的依据。", $defaultParagraphStyle);
     $section->addTitle("第二、为中青年人才提供自我认知和自我提升的工具", 3);
     $section->addText("    通过综合测评,帮助了这些人才全面、系统、客观、准确了解自我;通过结合岗位职责一对一面询,让这些人才更加明确自身优势与劣势;清晰哪些技能和素质需要进一步培训,在实际工作中扬长避短,促进自我职业生涯与集团战略的有机结合。", $defaultParagraphStyle);
     $section->addTitle("2、测评流程", 2);
     $section->addText("    综合测评分为五个阶段:", $defaultParagraphStyle);
     $section->addText("    一是测评前准备。这一阶段确定测试人才的人数、测评时间、测评内容、测评群体的总体情况;收集测评人才简历;编制测评总体需求量表。", $defaultParagraphStyle);
     $section->addText("    二是人机对话测评。通过“6+1”系统综合测评,人均获取近1000个定性与定量数据,经过数据处理与统计分析,为专家面询提供科学、准确、客观、真实的测评结果。", $defaultParagraphStyle);
     $section->addText("    三是专家面询。这一过程人均半小时,目的是让有较高领导岗位经历和复合学科背景的专家依据测评结果,与中青年人才一对一的互动沟通:首先,帮他们清晰自己的优劣势;其次,为他们排忧解惑;最后,为每位中青年人才梳理出与集团发展匹配的对策。", $defaultParagraphStyle);
     $section->addText("    四是撰写总体与个体报告。依据对“6+1”大数据分析结果撰写总体综合素质分析报告;整合个人测评结果和专家面询评价,撰写每位人才的综合测评分析报告。", $defaultParagraphStyle);
     $section->addText("    五是汇报与反馈。向集团领导汇报总体与个体测评结果,反馈无记名满意度调查报告等,针对集团发展战略和现代人力资源管理提出针对性的建议与对策。", $defaultParagraphStyle);
     $section->addTitle("3、技术路径", 2);
     $section->addText("    “中心”的综合测评系统始于1988年博士研究成果,经历了26年实践检验,其过程(1)测评地域:北京、上海、天津、广东、山西、湖南、湖北、陕西、内蒙、海南、浙江、山东、辽宁、河南等省市;(2)年龄:20~68岁;(3)学历:大专~博士后;(4)职称:初级~两院士;(5)职务:初、中级~政府副部长、部队中将(陆海空);(6)类型:跨国公司高管、各类企业高管与技术人才;(7)测评人数:3万多人;(8)测评数据:每人925个;(9)获得荣誉:7次获国家自然科学基金资助,2次获航空科学基金资助,4次获省部级科学技术进步二等奖和管理成果一等奖;在国内外核心刊物发表论文30多篇,专著一本;测评软件50多套;培养出3名博士、9名硕士;经调查,客户反映测评准确率高、效果明显,平均满意度达97.8%,受到被测评人才和用人单位的普遍欢迎和认可。", $defaultParagraphStyle);
//.........这里部分代码省略.........
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:101,代码来源:ProjectComExport.php


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