コード例 #1
0
 /**
  * @param  Marriage $marriage 
  * @return boolean|Marriage Marriage used as boolean. If it matches the conditions.      
  */
 public function isSatisfiedBy($marriage)
 {
     $marriages = $marriage->getMarriages();
     foreach ($marriages as $marriageEvent) {
         // if both of these are not true (it is before the start OR after the end)
         if ($marriageEvent->occurredOn < $start || $mariageEvent->occurredOn > $end) {
             return false;
         }
     }
     return $marriage;
 }
コード例 #2
0
ファイル: Marriage.class.php プロジェクト: alcf/chms
 /**
  * Given this marriage record, this will update the "linked" marriage record with the same stats and details.
  * Only does anything if this marriage record has a MarriedToPerson object (otherwise, this does nothing).
  * 
  * This will CREATE the Linked Marriage record if none yet exists.
  * 
  */
 public function UpdateLinkedMarriage()
 {
     if (!$this->MarriedToPersonId) {
         return;
     }
     $objLinkedMarriage = $this->LinkedMarriage;
     if (!$objLinkedMarriage) {
         $objLinkedMarriage = new Marriage();
         $objLinkedMarriage->LinkedMarriage = $this;
         $objLinkedMarriage->Person = $this->MarriedToPerson;
         $objLinkedMarriage->MarriedToPerson = $this->Person;
     }
     $objLinkedMarriage->DateStart = $this->DateStart;
     $objLinkedMarriage->DateEnd = $this->DateEnd;
     $objLinkedMarriage->MarriageStatusTypeId = $this->intMarriageStatusTypeId;
     $objLinkedMarriage->Save();
     if (!$this->intLinkedMarriageId) {
         $this->intLinkedMarriageId = $objLinkedMarriage->Id;
         $this->Save();
     }
 }
コード例 #3
0
if ($_POST["idBoyfriend"] !== '0') {
    $boyfriend = PersonManager::getSinglePerson('id', $_POST["idBoyfriend"]);
}
$girlfriend = new Person();
if ($_POST["idGirlfriend"] !== '0') {
    $girlfriend = PersonManager::getSinglePerson('id', $_POST["idGirlfriend"]);
}
$boyfriend->setId($_POST["idBoyfriend"]);
$boyfriend->setNames($_POST["boyfriendName"]);
$boyfriend->setLastname1($_POST["lastname1Boyfriend"]);
$boyfriend->setLastname2($_POST["lastname2Boyfriend"]);
$girlfriend->setId($_POST["idGirlfriend"]);
$girlfriend->setNames($_POST["girlfriendName"]);
$girlfriend->setLastname1($_POST["lastname1Girlfriend"]);
$girlfriend->setLastname2($_POST["lastname2Girlfriend"]);
$marriage = new Marriage();
$marriage->setId($_POST["idMarriage"]);
$celb = DatabaseManager::singleDateToDatabaseDate($_POST["celebrationDate"]);
$marriage->setCelebrationDate($celb);
$marriage->setIdChurchProcess($churchProcess->getId());
$marriage->setIdChurchMarriage($churchMarriage->getId());
$marriage->setIdRector($_POST["rectorId"]);
if ($boyfriend->getId() === '0') {
    PersonManager::addPerson($boyfriend, 'true');
    $boyfriend = PersonManager::getSinglePerson('id', PersonManager::getLastID());
} else {
    PersonManager::updatePerson($boyfriend);
}
if ($girlfriend->getId() === '0') {
    PersonManager::addPerson($girlfriend, 'true');
    $girlfriend = PersonManager::getSinglePerson('id', PersonManager::getLastID());
コード例 #4
0
ファイル: Person.php プロジェクト: victorfcm/VuFind-Plus
 function saveMarriages()
 {
     if (isset($this->personId)) {
         $marriage = new Marriage();
         $marriage->query("DELETE FROM marriage WHERE personId = {$this->personId}");
         if (is_array($this->marriages)) {
             foreach ($this->marriages as $marriageData) {
                 $marriageData->personId = $this->personId;
                 $marriageData->insert();
             }
         }
     }
 }
コード例 #5
0
ファイル: datagen.cli.php プロジェクト: alcf/chms
 /**
  * Generates a single Individual record
  * @param boolean $blnMaleFlag
  * @param boolean $blnAdultFlag whether this Individual should be a child or an adult
  * @param string $strLastName optional last name
  * @return Person
  */
 protected static function GenerateIndividual($blnMaleFlag, $blnAdultFlag, $strLastName = null)
 {
     $objPerson = new Person();
     $objPerson->Gender = $blnMaleFlag ? 'M' : 'F';
     // Generate the name
     $objPerson->FirstName = $blnMaleFlag ? QDataGen::GenerateMaleFirstName() : QDataGen::GenerateFemaleFirstName();
     switch (rand(1, 10)) {
         case 1:
         case 2:
         case 3:
             $objPerson->MiddleName = chr(rand(ord('A'), ord('Z'))) . '.';
             break;
         case 4:
         case 5:
             $objPerson->MiddleName = $blnMaleFlag ? QDataGen::GenerateMaleFirstName() : QDataGen::GenerateFemaleFirstName();
             break;
     }
     $objPerson->LastName = $strLastName ? $strLastName : QDataGen::GenerateLastName();
     $objPerson->CanEmailFlag = rand(0, 1);
     $objPerson->CanMailFlag = rand(0, 1);
     $objPerson->CanPhoneFlag = rand(0, 1);
     if (!rand(0, 10)) {
         $objPerson->Nickname = $blnMaleFlag ? QDataGen::GenerateMaleFirstName() : QDataGen::GenerateFemaleFirstName();
     }
     if (!rand(0, 5) && !$blnMaleFlag) {
         $objPerson->PriorLastNames = QDataGen::GenerateLastName();
     }
     if (!rand(0, 10)) {
         $objPerson->MailingLabel = QString::FirstCharacter($objPerson->FirstName) . '. ' . $objPerson->LastName;
     }
     if (!rand(0, 10)) {
         $arrTitleArray = $blnMaleFlag ? array('Mr.', 'Dr.', 'Sir') : array('Ms.', 'Miss', 'Mrs.', 'Dr.', 'Lady');
         $objPerson->Title = QDataGen::GenerateFromArray($arrTitleArray);
     }
     if (!rand(0, 10)) {
         $arrSuffixArray = array('Sr.', 'Jr.', 'III', 'PhD', 'MD');
         $objPerson->Suffix = QDataGen::GenerateFromArray($arrSuffixArray);
     }
     // Date of Birth
     if ($blnAdultFlag) {
         if (rand(0, 1)) {
             $objPerson->DateOfBirth = QDataGen::GenerateDateTime(self::$LifeStartDate, self::$OldestChildBirthDate);
         }
     } else {
         $objPerson->DateOfBirth = QDataGen::GenerateDateTime(self::$OldestChildBirthDate, QDateTime::Now());
     }
     if ($objPerson->DateOfBirth) {
         $objPerson->DobGuessedFlag = !rand(0, 12);
         $objPerson->DobYearApproximateFlag = !rand(0, 12);
     }
     // Refresh Membership and Marital Statuses
     $objPerson->RefreshMembershipStatusTypeId(false);
     $objPerson->RefreshMaritalStatusTypeId(false);
     $objPerson->RefreshAge(false);
     // Setup Deceased Information
     $objPerson->DeceasedFlag = !rand(0, 200);
     if ($objPerson->DeceasedFlag && rand(0, 1)) {
         $objPerson->DateDeceased = QDataGen::GenerateDateTime(self::$LifeStartDate, QDateTime::Now());
     }
     $objPerson->Save();
     $objPerson->RefreshNameItemAssociations();
     // Head Shots
     $objHeadShotArray = array();
     $intHeadShotCount = rand(0, 3);
     for ($i = 0; $i < $intHeadShotCount; $i++) {
         $objHeadShotArray[] = $objPerson->SaveHeadShot(self::GetRandomHeadShot($objPerson->Gender == 'M'), QDataGen::GenerateDateTime(self::$SystemStartDate, QDateTime::Now()));
     }
     if (count($objHeadShotArray)) {
         $objPerson->SetCurrentHeadShot(QDataGen::GenerateFromArray($objHeadShotArray));
     }
     // Membership
     $intMembershipCount = 0;
     if ($blnAdultFlag) {
         if (!rand(0, 2)) {
             $intMembershipCount = rand(1, 3);
         }
     } else {
         if (!rand(0, 10)) {
             $intMembershipCount = rand(1, 2);
         }
     }
     if ($intMembershipCount) {
         $dttEarliestPossible = new QDateTime($objPerson->DateOfBirth ? $objPerson->DateOfBirth : self::$SystemStartDate);
         self::GenerateMembershipsForIndividual($objPerson, $dttEarliestPossible, $intMembershipCount);
     }
     // Past or non-defined marriage
     if ($blnAdultFlag && !rand(0, 10)) {
         $objMarriage = new Marriage();
         $objMarriage->Person = $objPerson;
         $objMarriage->MarriageStatusTypeId = QDataGen::GenerateFromArray(array_keys(MarriageStatusType::$NameArray));
         if (rand(0, 1)) {
             $dttStart = QDateTime::Now();
             $dttStart = QDataGen::GenerateDateTime(self::$LifeStartDate, $dttStart);
             $dttStart = QDataGen::GenerateDateTime(self::$LifeStartDate, $dttStart);
             $dttStart = QDataGen::GenerateDateTime(self::$LifeStartDate, $dttStart);
             $dttStart = QDataGen::GenerateDateTime(self::$LifeStartDate, $dttStart);
             $dttStart = QDataGen::GenerateDateTime(self::$LifeStartDate, $dttStart);
             $objMarriage->DateStart = $dttStart;
             switch ($objMarriage->MarriageStatusTypeId) {
                 case MarriageStatusType::Divorced:
                 case MarriageStatusType::Widowed:
                     $objMarriage->DateEnd = QDataGen::GenerateDateTime($dttStart, QDateTime::Now());
                     break;
             }
         }
         $objMarriage->Save();
         $objPerson->RefreshMaritalStatusTypeId();
     }
     // Comments
     $intCount = rand(0, 12);
     for ($intIndex = 0; $intIndex < $intCount; $intIndex++) {
         $dttPostDate = self::GenerateDateTime(self::$SystemStartDate, QDateTime::Now());
         $objLogin = self::GenerateFromArray(self::$UserArray);
         $objCommentCategory = self::GenerateFromArray(self::$CommentCategoryArray);
         $intCommentPrivacyTypeId = self::GenerateFromArray(array_keys(CommentPrivacyType::$NameArray));
         $strComment = self::GenerateContent(rand(1, 2), 5, 20);
         $dttActionDate = rand(0, 10) ? null : self::GenerateDateTime(self::$SystemStartDate, QDateTime::Now());
         $objPerson->SaveComment($objLogin, $strComment, $intCommentPrivacyTypeId, $objCommentCategory->Id, $dttPostDate, $dttActionDate);
     }
     // Addresses and Phone
     self::GenerateAddressesAndPhonesForPerson($objPerson);
     // Attributes
     self::GenerateAttributesForPerson($objPerson);
     return $objPerson;
 }
コード例 #6
0
 /**
  * This will save this object's Marriage instance,
  * updating only the fields which have had a control created for it.
  */
 public function SaveMarriage()
 {
     try {
         // Update any fields for controls that have been created
         if ($this->lstLinkedMarriage) {
             $this->objMarriage->LinkedMarriageId = $this->lstLinkedMarriage->SelectedValue;
         }
         if ($this->lstPerson) {
             $this->objMarriage->PersonId = $this->lstPerson->SelectedValue;
         }
         if ($this->lstMarriedToPerson) {
             $this->objMarriage->MarriedToPersonId = $this->lstMarriedToPerson->SelectedValue;
         }
         if ($this->lstMarriageStatusType) {
             $this->objMarriage->MarriageStatusTypeId = $this->lstMarriageStatusType->SelectedValue;
         }
         if ($this->calDateStart) {
             $this->objMarriage->DateStart = $this->calDateStart->DateTime;
         }
         if ($this->calDateEnd) {
             $this->objMarriage->DateEnd = $this->calDateEnd->DateTime;
         }
         // Update any UniqueReverseReferences (if any) for controls that have been created for it
         if ($this->lstMarriageAsLinked) {
             $this->objMarriage->MarriageAsLinked = Marriage::Load($this->lstMarriageAsLinked->SelectedValue);
         }
         // Save the Marriage object
         $this->objMarriage->Save();
         // Finally, update any ManyToManyReferences (if any)
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
コード例 #7
0
ファイル: Person.class.php プロジェクト: alcf/chms
 /**
  * Creates a new Marriage record and refreshes the marrital status for both this person and the spouse
  * @param integer $intMarriageStatusTypeId (defaults to "Married")
  * @param Person $objSpouse the spouse
  * @param QDateTime $dttStartDate the start date of the marriage
  * @param QDateTime $dttEndDate the end date of the marriage
  * @return Marriage
  */
 public function CreateMarriageWith(Person $objSpouse = null, QDateTime $dttStartDate = null, QDateTime $dttEndDate = null, $intMarriageStatusTypeId = MarriageStatusType::Married)
 {
     $objMarriage = new Marriage();
     $objMarriage->Person = $this;
     $objMarriage->MarriedToPerson = $objSpouse;
     $objMarriage->MarriageStatusTypeId = $intMarriageStatusTypeId;
     $objMarriage->DateStart = $dttStartDate;
     $objMarriage->DateEnd = $dttEndDate;
     $objMarriage->Save();
     // Updated Link record (if applicable)
     if ($objSpouse) {
         $objMarriage->UpdateLinkedMarriage();
     }
     // Refresh Stats
     $this->RefreshMaritalStatusTypeId();
     if ($objSpouse) {
         $objSpouse->RefreshMaritalStatusTypeId();
     }
     return $objMarriage;
 }
コード例 #8
0
ファイル: PersonGen.class.php プロジェクト: alcf/chms
    /**
     * Deletes all associated MarriagesAsMarriedTo
     * @return void
     */
    public function DeleteAllMarriagesAsMarriedTo()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateMarriageAsMarriedTo on this unsaved Person.');
        }
        // Get the Database Object for this Class
        $objDatabase = Person::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (Marriage::LoadArrayByMarriedToPersonId($this->intId) as $objMarriage) {
                $objMarriage->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`marriage`
				WHERE
					`married_to_person_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
コード例 #9
0
ファイル: Marriages.php プロジェクト: bryandease/VuFind-Plus
 function getObjectStructure()
 {
     return Marriage::getObjectStructure();
 }
コード例 #10
0
 /**
  * @param  Marriage $marriage 
  */
 public function isSatisfiedBy($marriage)
 {
     // {backwards} if valid (invalid=false), else not valid (invalid = true)
     return !$marriage->isValid();
 }
コード例 #11
0
ファイル: FamilyTree.php プロジェクト: ramoncarlos/angkan
 public function save()
 {
     $db = mysqli_connect(DBHOST, DBUSERNAME, DBPASSWORD);
     if (!$db) {
         print "\nUnable to save, cannot connect to the DB\n";
     }
     $rc = mysqli_selectdb(DBNAME);
     for ($i = 1; $i < Person::$theCount; $i++) {
         $person = Person::getById($i);
         $cameFromUnionId = 0;
         if ($person->cameFromUnion) {
             $cameFromUnionId = $person->cameFromUnion->id;
         }
         $sql = "INSERT INTO person (personId,name,realName,gender,dateOfBirth,dateOfDeath,cameFromUnionId,ordinal,suppress) VALUES (";
         $sql .= $person->id . ", '" . $person->name . "', '" . $person->realName . "', '" . $person->gender . "', '" . $person->dateOfBirth . "', '" . $person->dateOfDeath . "', " . $cameFromUnionId . ", " . $person->ordinal . ", " . $person->suppress . " ) ";
         $sql .= " ON DUPLICATE KEY UPDATE name='" . $person->name . "', cameFromUnionId= " . $cameFromUnionId;
         $rc = mysqli_query($sql);
         if (!$rc) {
             print "\n>>> error = " . mysqli_error() . " sql= " . $sql;
         }
         // save attributes
         foreach ($person->attribs as $attrName => $attrValue) {
             if (is_array($attrValue)) {
                 $tmp = join(",", $attrValue);
                 $attrValue = $tmp;
             }
             $sql = "INSERT INTO personattr (personId, attrName, attrValue ) VALUES (";
             $sql .= $person->id . ", '" . $attrName . "', '" . addslashes($attrValue) . "' );";
             $rc = mysqli_query($sql);
             if (!$rc) {
                 print "\n>>> error = " . mysqli_error() . " sql= " . $sql;
             }
         }
     }
     // save marriages
     for ($i = 1; $i < Marriage::$theCount; $i++) {
         $marriage = Marriage::getById($i);
         $sql = "INSERT INTO marriage (marriageId, personId1, personId2, suppress) VALUES ( ";
         $sql .= $marriage->id . ', ' . $marriage->personId1 . ', ' . $marriage->personId2 . ', ' . $marriage->suppress . ') ';
         $sql .= " ON DUPLICATE KEY UPDATE personId1 = " . $marriage->personId1 . ", personId2 = " . $marriage->personId2 . ", suppress=" . $marriage->suppress;
         $rc = mysqli_query($sql);
         if (!$rc) {
             print "\n>>> error = " . mysqli_error() . " sql=" . $sql;
         }
     }
     mysqli_close();
 }
コード例 #12
0
$numberPage = intval($_GET["page"]);
$sortType = $_GET["sort"];
$simpleKeyword = $_GET["keyword"];
$kid = $_GET["kid"];
if ($sortType == NULL || $sortType == '') {
    $sortType = 'id';
}
if ($numberPage === NULL || $numberPage < 0) {
    echo "<script src='../JS/functions.js'></script><script>nextPage('set', '0')</script>";
}
//Getting all registries
if ($simpleKeyword !== NULL) {
    $marriageRegistries = MarriageManager::simpleSearchMarriage($simpleKeyword, $sortType, $numberPage);
} else {
    if ($kid !== NULL) {
        $marriageSearch = new Marriage();
        $kcelebration = DatabaseManager::singleDateToDatabaseDate($_GET["kcelebration"]);
        $knameb = $_GET["knameb"];
        $klastname1b = $_GET["klastname1b"];
        $klastname2b = $_GET["klastname2b"];
        $knameg = $_GET["knameg"];
        $klastname1g = $_GET["klastname1g"];
        $klastname2g = $_GET["klastname2g"];
        $kchurchc = $_GET["kchurch"];
        $kbook = $_GET["kbook"];
        $knumber = $_GET["knumber"];
        $kpape = $_GET["kpape"];
        $marriageSearch->setId($kid);
        $marriageSearch->setCelebrationDate($kcelebration);
        $posibleNames[0] = PersonManager::searchPersonsByNames($knameb, $klastname1b, $klastname2b, false);
        $posibleNames[1] = PersonManager::searchPersonsByNames($knameg, $klastname1g, $klastname2g, false);
コード例 #13
0
 /**
  * Main utility method to aid with data binding.  It is used by the default BindAllRows() databinder but
  * could and should be used by any custom databind methods that would be used for instances of this
  * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. 
  *
  * If a paginator is set on this DataBinder, it will use it.  If not, then no pagination will be used.
  * It will also perform any sorting (if applicable).
  *
  * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself
  * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query		 
  * @return void
  */
 public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null)
 {
     // Setup input parameters to default values if none passed in
     if (!$objCondition) {
         $objCondition = QQ::All();
     }
     $objClauses = $objOptionalClauses ? $objOptionalClauses : array();
     // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = Marriage::QueryCount($objCondition, $objClauses);
     }
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be a Query result from Marriage, given the clauses above
     $this->DataSource = Marriage::QueryArray($objCondition, $objClauses);
 }
コード例 #14
0
 protected function SetupPanel()
 {
     // Get and Validate the Marriage Object
     $this->objMarriage = Marriage::Load($this->strUrlHashArgument);
     if (!$this->objMarriage) {
         // Trying to create a NEW marriage
         // Let's make sure this person doesn't have a current marriage
         $this->objPerson->RefreshMaritalStatusTypeId();
         switch ($this->objPerson->MaritalStatusTypeId) {
             case MaritalStatusType::Married:
             case MaritalStatusType::Separated:
                 return $this->ReturnTo('#general/view_marriage');
         }
         $this->objMarriage = new Marriage();
         $this->objMarriage->Person = $this->objPerson;
         $this->blnEditMode = false;
         $this->btnSave->Text = 'Create';
     } else {
         // Ensure the Membership object belongs to the person
         if ($this->objMarriage->PersonId != $this->objPerson->Id) {
             return $this->ReturnTo('#general/view_marriage');
         }
         $this->blnEditMode = true;
         $this->btnSave->Text = 'Update';
         $this->btnDelete = new QLinkButton($this);
         $this->btnDelete->Text = 'Delete';
         $this->btnDelete->CssClass = 'delete';
         $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to permenantly DELETE this record?  (This should only be done if this record is a mistake/error.)'));
         $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
         $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction());
     }
     // Create Controls
     $this->dtxDateStart = new QDateTimeTextBox($this);
     $this->dtxDateStart->Name = 'Marriage Started';
     $this->dtxDateStart->Text = $this->objMarriage->DateStart ? $this->objMarriage->DateStart->__toString() : null;
     $this->calDateStart = new QCalendar($this, $this->dtxDateStart);
     $this->dtxDateEnd = new QDateTimeTextBox($this);
     $this->dtxDateEnd->Name = 'Marriage Ended';
     $this->dtxDateEnd->Text = $this->objMarriage->DateEnd ? $this->objMarriage->DateEnd->__toString() : null;
     $this->calDateEnd = new QCalendar($this, $this->dtxDateEnd);
     $this->dtxDateStart->RemoveAllActions(QClickEvent::EventName);
     $this->dtxDateEnd->RemoveAllActions(QClickEvent::EventName);
     $this->lstStatus = new QListBox($this);
     $this->lstStatus->Name = 'Status';
     if (!$this->objMarriage->MarriageStatusTypeId) {
         $this->lstStatus->AddItem('- Select One -', null);
     }
     $this->lstStatus->Required = true;
     foreach (MarriageStatusType::$NameArray as $intId => $strName) {
         $this->lstStatus->AddItem($strName, $intId, $intId == $this->objMarriage->MarriageStatusTypeId);
     }
     // Create "Married To" Controls
     if ($this->objMarriage->MarriedToPerson) {
         $this->lblMarriedTo = new QLabel($this);
         $this->lblMarriedTo->Name = 'Married To';
         $this->lblMarriedTo->HtmlEntities = false;
         $this->lblMarriedTo->Text = $this->objMarriage->MarriedToPerson->LinkHtml;
     } else {
         $this->pnlMarriedTo = new SelectPersonPanel($this);
         $this->pnlMarriedTo->Name = 'Married To';
         $this->pnlMarriedTo->AllowCreate = true;
         switch ($this->objPerson->Gender) {
             case 'M':
                 $this->pnlMarriedTo->ForceAsMaleFlag = false;
             case 'F':
                 $this->pnlMarriedTo->ForceAsMaleFlag = true;
             default:
                 $this->pnlMarriedTo->ForceAsMaleFlag = null;
         }
     }
 }
コード例 #15
0
ファイル: AllInOne.php プロジェクト: aretecode/Marriage
 /**
  * A new invite aggregate root is created and added to the repository.
  */
 protected function handleCreateMarriageCommand(CreateMarriageCommand $command)
 {
     $marriage = Marriage::createMarriage($command->marriageId, $command->partnerIds, $command->occurredOn);
     $this->repository->save($marriage);
 }
コード例 #16
0
 /**
  * @param  Marriage $marriage 
  */
 public function isSatisfiedBy($marriage)
 {
     // if (count $partners) more than 3 (true), else (false)
     return count($marriage->getPartners()) > 3;
 }
コード例 #17
0
ファイル: MarriageGen.class.php プロジェクト: alcf/chms
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objLinkedMarriage) {
         $objObject->objLinkedMarriage = Marriage::GetSoapObjectFromObject($objObject->objLinkedMarriage, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intLinkedMarriageId = null;
         }
     }
     if ($objObject->objPerson) {
         $objObject->objPerson = Person::GetSoapObjectFromObject($objObject->objPerson, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intPersonId = null;
         }
     }
     if ($objObject->objMarriedToPerson) {
         $objObject->objMarriedToPerson = Person::GetSoapObjectFromObject($objObject->objMarriedToPerson, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intMarriedToPersonId = null;
         }
     }
     if ($objObject->dttDateStart) {
         $objObject->dttDateStart = $objObject->dttDateStart->__toString(QDateTime::FormatSoap);
     }
     if ($objObject->dttDateEnd) {
         $objObject->dttDateEnd = $objObject->dttDateEnd->__toString(QDateTime::FormatSoap);
     }
     return $objObject;
 }
コード例 #18
0
 /**
  * Search one marriage by one similar name
  * 
  * @author Jonathan Sandoval <*****@*****.**>
  * @param  Marriage        $marriage    Pseudo-marriage with the data to search
  * @param  string         $operator     To search with 'or' or 'and'
  * @param  string         $order        The type of sort of the Marriage
  * @param  integer        $begin        The number of page to display the registry
  * @return Array[Marriage] $marriages   Marriage objects with the similar name or null
  */
 static function advancedSearchMarriage($marriage = null, $operator = 'AND', $order = 'id', $begin = 0)
 {
     if ($marriage === null) {
         return null;
     }
     $tableMarriage = DatabaseManager::getNameTable('TABLE_MARRIAGE');
     $tablePerson = DatabaseManager::getNameTable('TABLE_PERSON');
     $tableChurch = DatabaseManager::getNameTable('TABLE_CHURCH');
     $celebrationDate = $marriage->getCelebrationDate();
     $queryBoy = "(";
     $posibleBoy = $marriage->getIdBoyfriend();
     $queryGirl = "(";
     $posibleGirl = $marriage->getIdGirlfriend();
     $queryChurch = "(";
     $posibleChurch = $marriage->getIdChurchMarriage();
     if ($posibleBoy !== NULL) {
         for ($i = 0; $i < sizeof($posibleBoy) - 1; $i++) {
             $queryBoy = $queryBoy . $posibleBoy[$i]->getId() . ",";
         }
         $queryBoy = $queryBoy . $posibleBoy[sizeof($posibleBoy) - 1]->getId() . ")";
         $queryBoy = "((b.id IN " . $queryBoy . ") OR b.id IS NULL)";
     }
     if ($posibleGirl !== NULL) {
         for ($i = 0; $i < sizeof($posibleGirl) - 1; $i++) {
             $queryGirl = $queryGirl . $posibleGirl[$i]->getId() . ",";
         }
         $queryGirl = $queryGirl . $posibleGirl[sizeof($posibleGirl) - 1]->getId() . ")";
         $queryGirl = "((g.id IN " . $queryGirl . ") OR g.id IS NULL)";
     }
     if ($posibleChurch !== NULL) {
         for ($i = 0; $i < sizeof($posibleChurch) - 1; $i++) {
             $queryChurch = $queryChurch . $posibleChurch[$i]->getId() . ",";
         }
         $queryChurch = $queryChurch . $posibleChurch[sizeof($posibleChurch) - 1]->getId() . ")";
         $queryChurch = "(c.id IN " . $queryChurch . ")";
     }
     if ($marriage->getId() == 0) {
         $id = '';
     } else {
         $id = $marriage->getId();
     }
     if ($marriage->getIdBookRegistry() == 0) {
         $idBookRegistry = '';
     } else {
         $idBookRegistry = $marriage->getIdBookRegistry()->getId();
     }
     $query = "SELECT m.* \r\n                        FROM {$tableMarriage} AS m \r\n                        LEFT JOIN {$tablePerson} AS b ON m.idBoyfriend = b.id\r\n                        LEFT JOIN {$tablePerson} AS g ON m.idGirlfriend = g.id\r\n                        JOIN {$tableChurch} AS c  ON m.idChurchMarriage = c.id\r\n                        WHERE m.id               LIKE '%{$id}%'               {$operator}\r\n                              m.marriageDate     LIKE '%{$celebrationDate}%'  {$operator} ";
     //Join the Query with the posibiitation query
     if ($queryBoy != '(') {
         $query = $query . $queryBoy . " " . $operator . " ";
     } else {
         $query = $query . "(b.id IN ())" . $operator . " ";
     }
     if ($queryGirl != '(') {
         $query = $query . $queryGirl . " " . $operator . " ";
     } else {
         $query = $query . "(g.id IN ())" . $operator . " ";
     }
     if ($queryChurch != '(') {
         $query = $query . $queryChurch . " " . $operator . " ";
     } else {
         $query = $query . "(c.id IN ())" . $operator . " ";
     }
     if ($idBookRegistry !== NULL) {
         $query = $query . "m.idMarriageRegistry LIKE '%{$idBookRegistry}%'";
     } else {
         $query = $query . "m.idMarriageRegistry LIKE '%%'";
     }
     if ($order == 'nameBoy') {
         $query = $query . " ORDER BY b.lastname1";
     } else {
         if ($order == 'nameGirl') {
             $query = $query . " ORDER BY g.lastname1";
         } else {
             if ($order == 'nameChurch') {
                 $query = $query . " ORDER BY c.name";
             } else {
                 $query = $query . " ORDER BY m.id DESC";
             }
         }
     }
     $query = $query . " LIMIT " . strval($begin * 10) . ", 11 ";
     $arrayMarriages = DatabaseManager::multiFetchAssoc($query);
     $marriages = array();
     if ($arrayMarriages !== NULL) {
         $i = 0;
         foreach ($arrayMarriages as $marriage) {
             if ($i == 10) {
                 continue;
             }
             $marriages[] = self::ArrayToMarriage($marriage);
             $i++;
         }
         return $marriages;
     } else {
         return null;
     }
 }