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


PHP Family::populate方法代码示例

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


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

示例1: processView

    function processView()
    {
        $GLOBALS['system']->includeDBClass('family');
        $GLOBALS['system']->includeDBClass('person');
        $GLOBALS['system']->includeDBClass('person_group');
        $GLOBALS['system']->includeDBClass('congregation');
        $GLOBALS['system']->includeDBClass('person_note');
        if (!empty($_REQUEST['done'])) {
            $this->_stage = 'done';
        } else {
            if (!empty($_POST['confirm_import'])) {
                ini_set('memory_limit', '256M');
                ini_set('max_execution_time', 60 * 10);
                ini_set('zlib.output_compression', 'Off');
                // read from session and create
                $GLOBALS['system']->doTransaction('BEGIN');
                $group = $GLOBALS['system']->getDBObject('person_group', $_SESSION['import']['groupid']);
                $this->_captureErrors();
                $done = 0;
                ?>
			<h1 style="position: absolute; text-align: center; top: 40%; color: #ccc; width: 100%">Importing...</h1>
			<div style="border: 1px solid; width: 50%; height: 30px; top: 50%; left: 25%; position: absolute"><div id="progress" style="background: blue; height: 30px; width: 2%; overflow: visible; line-height: 30px; text-align: center; color: white" /></div>
			<p style="text-align: center; color: #888">If this indicator stops making progress, your import may still be running in the background.<br />You should <a href="<?php 
                echo build_url(array('view' => 'persons__list_all'));
                ?>
">check your system for the imported persons</a> before running the import again.</p>
			<?php 
                foreach ($_SESSION['import']['families'] as $familydata) {
                    $members = $familydata['members'];
                    unset($familydata['members']);
                    $family = new Family();
                    $family->populate(0, $familydata);
                    if ($family->create()) {
                        foreach ($members as $persondata) {
                            $notetext = null;
                            if (!empty($persondata['note'])) {
                                $notetext = $persondata['note'];
                                unset($persondata['note']);
                            }
                            $person = new Person();
                            $person->populate(0, $persondata);
                            $person->setValue('familyid', $family->id);
                            if ($person->create()) {
                                $group->addMember($person->id);
                                if ($notetext) {
                                    $note = new Person_Note();
                                    $note->setValue('subject', 'Import note');
                                    $note->setvalue('details', $notetext);
                                    $note->setValue('personid', $person->id);
                                    $note->create();
                                    unset($note);
                                }
                                unset($person);
                            }
                        }
                        $done++;
                        if ($done % 20 == 0) {
                            ?>
<script>var d = document.getElementById('progress'); d.innerHTML = 'Importing family <?php 
                            echo $done . ' of ' . $_SESSION['import']['total_families'];
                            ?>
'; d.style.width = '<?php 
                            echo (int) ($done / $_SESSION['import']['total_families'] * 100);
                            ?>
%'</script><?php 
                            echo str_repeat('    ', 1024 * 4);
                        }
                        flush();
                        unset($family);
                    }
                }
                if ($errors = $this->_getErrors()) {
                    $msg = 'Errors during import - import aborted. <ul><li>' . implode('</li></li>', $errors) . '</li></ul>';
                    add_message($msg, 'failure', true);
                    $GLOBALS['system']->doTransaction('ROLLBACK');
                } else {
                    add_message('Import complete', 'success');
                    $GLOBALS['system']->doTransaction('COMMIT');
                }
                ?>
<script>document.location = '<?php 
                echo build_url(array());
                ?>
&done=1';</script>
			<?php 
                exit;
            } else {
                if (!empty($_FILES['import'])) {
                    if (empty($_REQUEST['groupid'])) {
                        add_message("You must choose a group first", 'error');
                        $this->stage = 'begin';
                        return;
                    }
                    if (empty($_FILES['import']) || empty($_FILES['import']['tmp_name'])) {
                        add_message("You must upload a file", 'error');
                        return;
                    }
                    $this->_dummy_family = new Family();
                    $this->_dummy_person = new Person();
                    // read the csv and save to session
//.........这里部分代码省略.........
开发者ID:howardgrigg,项目名称:jethro-pmm,代码行数:101,代码来源:view_10_admin__7_import.class.php

示例2: run

    function run()
    {
        //Handle special IE contype request
        if (isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] == 'contype') {
            header('Content-Type: application/pdf');
            exit;
        }
        $env = new Envelope_List();
        $GLOBALS['system']->includeDBClass('family');
        if (!empty($_REQUEST['familyid'])) {
            $family =& $GLOBALS['system']->getDBObject('family', (int) $_REQUEST['familyid']);
            $env->addAddress($family->getAdultMemberNames() . "\n" . $family->getPostalAddress());
        }
        if (!empty($_REQUEST['personid'])) {
            if (is_array($_REQUEST['personid'])) {
                $families = Family::getFamilyDataByMemberIDs($_REQUEST['personid']);
                $addressee = array_get($_REQUEST, 'addressee', 'persons');
                $dummy = new Family();
                foreach ($families as $id => $family) {
                    if (empty($family['address_street'])) {
                        continue;
                    }
                    $dummy->populate($id, $family);
                    if ($addressee == 'family') {
                        $to = $family['family_name'] . " Family";
                    } else {
                        if ($addressee == 'adults') {
                            $to = $dummy->getAdultMemberNames();
                        } else {
                            if (count(explode(',', $family['selected_lastnames'])) == 1) {
                                $to = $family['selected_firstnames'] . ' ' . $family['selected_lastnames'];
                            } else {
                                $firstnames = explode(',', $family['selected_firstnames']);
                                $lastnames = explode(',', $family['selected_lastnames']);
                                $common_name = TRUE;
                                foreach ($lastnames as $lastname) {
                                    if ($lastname != reset($lastnames)) {
                                        $common_name = FALSE;
                                    }
                                }
                                if ($common_name) {
                                    $final = array_pop($firstnames);
                                    $to = implode(', ', $firstnames) . ' and ' . $final . ' ' . reset($lastnames);
                                } else {
                                    $tos = array();
                                    foreach ($firstnames as $i => $firstname) {
                                        $tos[] = $firstname . ' ' . $lastnames[$i];
                                    }
                                    $final = array_pop($tos);
                                    $to = implode(', ', $tos) . ' and ' . $final;
                                }
                            }
                        }
                    }
                    $env->addAddress($to . "\n" . $dummy->getPostalAddress());
                }
            } else {
                $person =& $GLOBALS['system']->getDBObject('person', (int) $_REQUEST['personid']);
                $family =& $GLOBALS['system']->getDBObject('family', $person->getValue('familyid'));
                $env->addAddress($person->toString() . "\n" . $family->getPostalAddress());
            }
        }
        if (empty($env->pages)) {
            ?>
			<script>
			alert("No addresses were found for the specified families");
			window.close();
			</script>
			<?php 
        } else {
            $env->output();
        }
    }
开发者ID:howardgrigg,项目名称:jethro-pmm,代码行数:73,代码来源:call_envelopes.class.php


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