本文整理匯總了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;
}
}
}
}
示例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());
}
}
示例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;
}
示例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;
}
示例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 {
//
}
}
}
示例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;
}
}
}
示例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;
}
示例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());
}
}
示例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);
//.........這裏部分代碼省略.........