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


PHP CRM_Core_DAO::setFieldValue方法代码示例

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


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

示例1: civicrm_api3_generic_setValue

/**
 * params must contain at least id=xx & {one of the fields from getfields}=value
 */
function civicrm_api3_generic_setValue($apiRequest)
{
    $entity = $apiRequest['entity'];
    $params = $apiRequest['params'];
    // we can't use _spec, doesn't work with generic
    civicrm_api3_verify_mandatory($params, NULL, array('id', 'field', 'value'));
    $id = $params['id'];
    if (!is_numeric($id)) {
        return civicrm_api3_create_error(ts('Please enter a number'), array('error_code' => 'NaN', 'field' => "id"));
    }
    $field = CRM_Utils_String::munge($params['field']);
    $value = $params['value'];
    $fields = civicrm_api($entity, 'getFields', array("version" => 3, "sequential"));
    // getfields error, shouldn't happen.
    if ($fields['is_error']) {
        return $fields;
    }
    $fields = $fields['values'];
    if (!array_key_exists($field, $fields)) {
        return civicrm_api3_create_error("Param 'field' ({$field}) is invalid. must be an existing field", array("error_code" => "invalid_field", "fields" => array_keys($fields)));
    }
    $def = $fields[$field];
    if (array_key_exists('required', $def) && empty($value)) {
        return civicrm_api3_create_error(ts("This can't be empty, please provide a value"), array("error_code" => "required", "field" => $field));
    }
    switch ($def['type']) {
        case 1:
            //int
            if (!is_numeric($value)) {
                return civicrm_api3_create_error("Param '{$field}' must be a number", array('error_code' => 'NaN'));
            }
        case 2:
            //string
            require_once "CRM/Utils/Rule.php";
            if (!CRM_Utils_Rule::xssString($value)) {
                return civicrm_api3_create_error(ts('Illegal characters in input (potential scripting attack)'), array('error_code' => 'XSS'));
            }
            if (array_key_exists('maxlength', $def)) {
                $value = substr($value, 0, $def['maxlength']);
            }
            break;
        case 16:
            //boolean
            $value = (bool) $value;
            break;
        case 4:
            //date
        //date
        default:
            return civicrm_api3_create_error("Param '{$field}' is of a type not managed yet. Join the API team and help us implement it", array('error_code' => 'NOT_IMPLEMENTED'));
    }
    if (CRM_Core_DAO::setFieldValue(_civicrm_api3_get_DAO($entity), $id, $field, $value)) {
        $entity = array('id' => $id, $field => $value);
        CRM_Utils_Hook::post('edit', $entity, $id, $entity);
        return civicrm_api3_create_success($entity);
    } else {
        return civicrm_api3_create_error("error assigning {$field}={$value} for {$entity} (id={$id})");
    }
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:62,代码来源:Setvalue.php

示例2: batchSave

 /**
  * Save record.
  */
 public function batchSave()
 {
     // save the entered information in 'data' column
     $batchId = CRM_Utils_Type::escape($_POST['batch_id'], 'Positive');
     unset($_POST['qfKey']);
     CRM_Core_DAO::setFieldValue('CRM_Batch_DAO_Batch', $batchId, 'data', json_encode(array('values' => $_POST)));
     CRM_Utils_System::civiExit();
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:11,代码来源:AJAX.php

示例3: setIsActive

 /**
  * Update the is_active flag in the db.
  *
  * @param int $id
  *   Id of the database record.
  * @param bool $is_active
  *   Value we want to set the is_active field.
  *
  * @return Object
  *   DAO object on success, null otherwise
  */
 public static function setIsActive($id, $is_active)
 {
     if (!$is_active) {
         $dao = new CRM_Contribute_DAO_PremiumsProduct();
         $dao->product_id = $id;
         $dao->delete();
     }
     return CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Product', $id, 'is_active', $is_active);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:20,代码来源:ManagePremiums.php

示例4: postProcess

 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Mailing_BAO_Mailing::del($this->_mailingId);
     } elseif ($this->_action & CRM_Core_Action::DISABLE) {
         CRM_Mailing_BAO_MailingJob::cancel($this->_mailingId);
     } elseif ($this->_action & CRM_Core_Action::RENEW) {
         //set is_archived to 1
         CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingId, 'is_archived', TRUE);
     }
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:11,代码来源:Browse.php

示例5: postProcess

 /**
  * Form submission of new/edit api is processed.
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     //get the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     if (!empty($this->_contactId)) {
         CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'api_key', $params['api_key']);
     }
     if (!empty($params['api_key'])) {
         CRM_Core_Session::setStatus("This API key has been updated.");
     } else {
         CRM_Core_Session::setStatus("This API key has been deleted.");
     }
 }
开发者ID:Beltline,项目名称:com.cividesk.apikey,代码行数:20,代码来源:APIKey.php

示例6: groupAdd

 /**
  * @param int $groupID
  * @param $group
  */
 public static function groupAdd($groupID, $group)
 {
     $ogID = CRM_Bridge_OG_Utils::ogID($groupID, FALSE);
     $node = new StdClass();
     if ($ogID) {
         $node->nid = $ogID;
     }
     global $user;
     $node->uid = $user->uid;
     $node->title = $group->title;
     $node->type = 'og';
     $node->status = 1;
     // set the og values
     $node->og_description = $group->description;
     $node->og_selective = OF_OPEN;
     $node->og_register = 0;
     $node->og_directory = 1;
     node_save($node);
     // also change the source field of the group
     CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Group', $groupID, 'source', CRM_Bridge_OG_Utils::ogSyncName($node->nid));
 }
开发者ID:kidaa30,项目名称:yes,代码行数:25,代码来源:CiviCRM.php

示例7: renewMembership

 /**
  * @param int $contactID
  * @param int $membershipTypeID
  * @param bool $is_test
  * @param $changeToday
  * @param int $modifiedID
  * @param $customFieldsFormatted
  * @param $numRenewTerms
  * @param int $membershipID
  * @param $pending
  * @param int $contributionRecurID
  * @param $membershipSource
  * @param $isPayLater
  * @param int $campaignId
  * @param array $formDates
  *
  * @throws CRM_Core_Exception
  * @return array
  */
 public static function renewMembership($contactID, $membershipTypeID, $is_test, $changeToday, $modifiedID, $customFieldsFormatted, $numRenewTerms, $membershipID, $pending, $contributionRecurID, $membershipSource, $isPayLater, $campaignId, $formDates = array())
 {
     $renewalMode = $updateStatusId = FALSE;
     $allStatus = CRM_Member_PseudoConstant::membershipStatus();
     $format = '%Y%m%d';
     $statusFormat = '%Y-%m-%d';
     $membershipTypeDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipTypeID);
     $dates = array();
     // CRM-7297 - allow membership type to be be changed during renewal so long as the parent org of new membershipType
     // is the same as the parent org of an existing membership of the contact
     $currentMembership = CRM_Member_BAO_Membership::getContactMembership($contactID, $membershipTypeID, $is_test, $membershipID, TRUE);
     if ($currentMembership) {
         $activityType = 'Membership Renewal';
         $renewalMode = TRUE;
         // Do NOT do anything.
         //1. membership with status : PENDING/CANCELLED (CRM-2395)
         //2. Paylater/IPN renew. CRM-4556.
         if ($pending || in_array($currentMembership['status_id'], array(array_search('Pending', $allStatus), array_search('Cancelled', CRM_Member_PseudoConstant::membershipStatus(NULL, " name = 'Cancelled' ", 'name', FALSE, TRUE))))) {
             $membership = new CRM_Member_DAO_Membership();
             $membership->id = $currentMembership['id'];
             $membership->find(TRUE);
             // CRM-8141 create a membership_log entry so that we will know the membership_type_id to change to when payment completed
             $format = '%Y%m%d';
             // note that we are logging the requested new membership_type_id that may be different than current membership_type_id
             // it will be used when payment is received to update the membership_type_id to what was paid for
             $logParams = array('membership_id' => $membership->id, 'status_id' => $membership->status_id, 'start_date' => CRM_Utils_Date::customFormat($membership->start_date, $format), 'end_date' => CRM_Utils_Date::customFormat($membership->end_date, $format), 'modified_date' => CRM_Utils_Date::customFormat(date('Ymd'), $format), 'membership_type_id' => $membershipTypeID, 'max_related' => !empty($membershipTypeDetails['max_related']) ? $membershipTypeDetails['max_related'] : NULL);
             $session = CRM_Core_Session::singleton();
             // If we have an authenticated session, set modified_id to that user's contact_id, else set to membership.contact_id
             if ($session->get('userID')) {
                 $logParams['modified_id'] = $session->get('userID');
             } else {
                 $logParams['modified_id'] = $membership->contact_id;
             }
             CRM_Member_BAO_MembershipLog::add($logParams);
             if ($contributionRecurID) {
                 CRM_Core_DAO::setFieldValue('CRM_Member_DAO_Membership', $membership->id, 'contribution_recur_id', $contributionRecurID);
             }
             return array($membership, $renewalMode, $dates);
         }
         // Check and fix the membership if it is STALE
         self::fixMembershipStatusBeforeRenew($currentMembership, $changeToday);
         // Now Renew the membership
         if (!$currentMembership['is_current_member']) {
             // membership is not CURRENT
             // CRM-7297 Membership Upsell - calculate dates based on new membership type
             $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($currentMembership['id'], $changeToday, $membershipTypeID, $numRenewTerms);
             $currentMembership['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
             foreach (array('start_date', 'end_date') as $dateType) {
                 $currentMembership[$dateType] = CRM_Utils_Array::value($dateType, $formDates);
                 if (empty($currentMembership[$dateType])) {
                     $currentMembership[$dateType] = CRM_Utils_Array::value($dateType, $dates);
                 }
             }
             $currentMembership['is_test'] = $is_test;
             if (!empty($membershipSource)) {
                 $currentMembership['source'] = $membershipSource;
             } else {
                 $currentMembership['source'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $currentMembership['id'], 'source');
             }
             if (!empty($currentMembership['id'])) {
                 $ids['membership'] = $currentMembership['id'];
             }
             $memParams = $currentMembership;
             $memParams['membership_type_id'] = $membershipTypeID;
             //set the log start date.
             $memParams['log_start_date'] = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);
         } else {
             // CURRENT Membership
             $membership = new CRM_Member_DAO_Membership();
             $membership->id = $currentMembership['id'];
             $membership->find(TRUE);
             // CRM-7297 Membership Upsell - calculate dates based on new membership type
             $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, $changeToday, $membershipTypeID, $numRenewTerms);
             // Insert renewed dates for CURRENT membership
             $memParams = array();
             $memParams['join_date'] = CRM_Utils_Date::isoToMysql($membership->join_date);
             $memParams['start_date'] = CRM_Utils_Date::isoToMysql($membership->start_date);
             $memParams['end_date'] = CRM_Utils_Array::value('end_date', $formDates);
             if (empty($memParams['end_date'])) {
                 $memParams['end_date'] = CRM_Utils_Array::value('end_date', $dates);
             }
//.........这里部分代码省略.........
开发者ID:konadave,项目名称:civicrm-core,代码行数:101,代码来源:Membership.php

示例8: updateMembershipStatus

 /**
  * Update membership status to deceased.
  * function return the status message for updated membership.
  *
  * @param array $deceasedParams
  *   having contact id and deceased value.
  *
  * @return null|string
  *   $updateMembershipMsg string  status message for updated membership.
  */
 public function updateMembershipStatus($deceasedParams)
 {
     $updateMembershipMsg = NULL;
     $contactId = CRM_Utils_Array::value('contact_id', $deceasedParams);
     $deceasedDate = CRM_Utils_Array::value('deceased_date', $deceasedParams);
     // process to set membership status to deceased for both active/inactive membership
     if ($contactId && $this->_contactType == 'Individual' && !empty($deceasedParams['is_deceased'])) {
         $session = CRM_Core_Session::singleton();
         $userId = $session->get('userID');
         if (!$userId) {
             $userId = $contactId;
         }
         // get deceased status id
         $allStatus = CRM_Member_PseudoConstant::membershipStatus();
         $deceasedStatusId = array_search('Deceased', $allStatus);
         if (!$deceasedStatusId) {
             return $updateMembershipMsg;
         }
         $today = time();
         if ($deceasedDate && strtotime($deceasedDate) > $today) {
             return $updateMembershipMsg;
         }
         // get non deceased membership
         $dao = new CRM_Member_DAO_Membership();
         $dao->contact_id = $contactId;
         $dao->whereAdd("status_id != {$deceasedStatusId}");
         $dao->find();
         $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
         $allStatus = CRM_Member_PseudoConstant::membershipStatus();
         $memCount = 0;
         while ($dao->fetch()) {
             // update status to deceased (for both active/inactive membership )
             CRM_Core_DAO::setFieldValue('CRM_Member_DAO_Membership', $dao->id, 'status_id', $deceasedStatusId);
             // add membership log
             $membershipLog = array('membership_id' => $dao->id, 'status_id' => $deceasedStatusId, 'start_date' => CRM_Utils_Date::isoToMysql($dao->start_date), 'end_date' => CRM_Utils_Date::isoToMysql($dao->end_date), 'modified_id' => $userId, 'modified_date' => date('Ymd'), 'membership_type_id' => $dao->membership_type_id, 'max_related' => $dao->max_related);
             CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
             //create activity when membership status is changed
             $activityParam = array('subject' => "Status changed from {$allStatus[$dao->status_id]} to {$allStatus[$deceasedStatusId]}", 'source_contact_id' => $userId, 'target_contact_id' => $dao->contact_id, 'source_record_id' => $dao->id, 'activity_type_id' => array_search('Change Membership Status', $activityTypes), 'status_id' => 2, 'version' => 3, 'priority_id' => 2, 'activity_date_time' => date('Y-m-d H:i:s'), 'is_auto' => 0, 'is_current_revision' => 1, 'is_deleted' => 0);
             $activityResult = civicrm_api('activity', 'create', $activityParam);
             $memCount++;
         }
         // set status msg
         if ($memCount) {
             $updateMembershipMsg = ts("%1 Current membership(s) for this contact have been set to 'Deceased' status.", array(1 => $memCount));
         }
     }
     return $updateMembershipMsg;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:58,代码来源:Contact.php

示例9: setDisable

 /**
  * Enable / Disable the campaign page
  *
  * @param int $id
  *   Campaign page id.
  *
  * @param $is_active
  * @return null
  */
 public static function setDisable($id, $is_active)
 {
     return CRM_Core_DAO::setFieldValue('CRM_PCP_DAO_PCP', $id, 'is_active', $is_active);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:13,代码来源:PCP.php

示例10: setIsActive

 /**
  * Update the is_active flag in the db.
  *
  * @param int $id
  *   Id of the database record.
  * @param bool $is_active
  *   Value we want to set the is_active field.
  *
  * @return Object
  *   DAO object on success, null otherwise
  */
 public static function setIsActive($id, $is_active)
 {
     return CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Component', $id, 'is_active', $is_active);
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:15,代码来源:Component.php

示例11: updateParticipantStatus

 /**
  * Function for update primary and additional participant status.
  *
  * @param int $participantID
  *   Primary participant's id.
  * @param int $oldStatusID
  * @param int $newStatusID
  * @param bool $updatePrimaryStatus
  *
  * @return bool|NULL
  */
 public static function updateParticipantStatus($participantID, $oldStatusID, $newStatusID = NULL, $updatePrimaryStatus = FALSE)
 {
     if (!$participantID || !$oldStatusID) {
         return NULL;
     }
     if (!$newStatusID) {
         $newStatusID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantID, 'status_id');
     } elseif ($updatePrimaryStatus) {
         CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Participant', $participantID, 'status_id', $newStatusID);
     }
     $cascadeAdditionalIds = self::getValidAdditionalIds($participantID, $oldStatusID, $newStatusID);
     if (!empty($cascadeAdditionalIds)) {
         $cascadeAdditionalIds = implode(',', $cascadeAdditionalIds);
         $query = "UPDATE civicrm_participant cp SET cp.status_id = %1 WHERE  cp.id IN ({$cascadeAdditionalIds})";
         $params = array(1 => array($newStatusID, 'Integer'));
         $dao = CRM_Core_DAO::executeQuery($query, $params);
         return TRUE;
     }
     return FALSE;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:31,代码来源:Participant.php

示例12: setIsActive

 /**
  * update the is_active flag in the db
  *
  * @param int      $id        id of the database record
  * @param boolean  $is_active value we want to set the is_active field
  *
  * @return Object             DAO object on sucess, null otherwise
  * @static
  */
 static function setIsActive($id, $is_active)
 {
     return CRM_Core_DAO::setFieldValue('CRM_ACL_DAO_EntityRole', $id, 'is_active', $is_active);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:13,代码来源:EntityRole.php

示例13: generateChecksum

 /**
  * Generate a checksum for a $entityId of type $entityType
  *
  * @param int $entityId
  * @param int $ts
  *   Timestamp that checksum was generated.
  * @param int $live
  *   Life of this checksum in hours/ 'inf' for infinite.
  * @param string $hash
  *   Contact hash, if sent, prevents a query in inner loop.
  *
  * @param string $entityType
  * @param null $hashSize
  *
  * @return array
  *   ( $cs, $ts, $live )
  */
 public static function generateChecksum($entityId, $ts = NULL, $live = NULL, $hash = NULL, $entityType = 'contact', $hashSize = NULL)
 {
     // return a warning message if we dont get a entityId
     // this typically happens when we do a message preview
     // or an anon mailing view - CRM-8298
     if (!$entityId) {
         return 'invalidChecksum';
     }
     if (!$hash) {
         if ($entityType == 'contact') {
             $hash = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $entityId, 'hash');
         } elseif ($entityType == 'mailing') {
             $hash = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $entityId, 'hash');
         }
     }
     if (!$hash) {
         $hash = md5(uniqid(rand(), TRUE));
         if ($hashSize) {
             $hash = substr($hash, 0, $hashSize);
         }
         if ($entityType == 'contact') {
             CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Contact', $entityId, 'hash', $hash);
         } elseif ($entityType == 'mailing') {
             CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Mailing', $entityId, 'hash', $hash);
         }
     }
     if (!$ts) {
         $ts = time();
     }
     if (!$live) {
         $days = Civi::settings()->get('checksum_timeout');
         $live = 24 * $days;
     }
     $cs = md5("{$hash}_{$entityId}_{$ts}_{$live}");
     return "{$cs}_{$ts}_{$live}";
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:53,代码来源:Utils.php

示例14: run

 /** 
  * run this page (figure out the action needed and perform it). 
  * 
  * @return void 
  */
 function run($newArgs)
 {
     $this->preProcess();
     if (isset($_GET['runJobs']) || CRM_Utils_Array::value('2', $newArgs) == 'queue') {
         require_once 'CRM/Mailing/BAO/Job.php';
         $config =& CRM_Core_Config::singleton();
         CRM_Mailing_BAO_Job::runJobs_pre($config->mailerJobSize);
         CRM_Mailing_BAO_Job::runJobs();
         CRM_Mailing_BAO_Job::runJobs_post();
     }
     $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
     if ($this->_sortByCharacter == 1 || !empty($_POST)) {
         $this->_sortByCharacter = '';
         $this->set('sortByCharacter', '');
     }
     if (CRM_Utils_Array::value(3, $newArgs) == 'unscheduled') {
         $this->_unscheduled = true;
     }
     $this->set('unscheduled', $this->_unscheduled);
     if (CRM_Utils_Array::value(3, $newArgs) == 'archived') {
         $this->_archived = true;
     }
     $this->set('archived', $this->_archived);
     if (CRM_Utils_Array::value(3, $newArgs) == 'scheduled') {
         $this->_scheduled = true;
     }
     $this->set('scheduled', $this->_scheduled);
     $this->_createdId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false, 0);
     if ($this->_createdId) {
         $this->set('createdId', $this->_createdId);
     }
     $session = CRM_Core_Session::singleton();
     $context = $session->readUserContext();
     if ($this->_action & CRM_Core_Action::DISABLE) {
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', $this)) {
             require_once 'CRM/Mailing/BAO/Job.php';
             CRM_Mailing_BAO_Job::cancel($this->_mailingId);
             CRM_Utils_System::redirect($context);
         } else {
             $controller = new CRM_Core_Controller_Simple('CRM_Mailing_Form_Browse', ts('Cancel Mailing'), $this->_action);
             $controller->setEmbedded(true);
             $controller->run();
         }
     } else {
         if ($this->_action & CRM_Core_Action::DELETE) {
             if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', $this)) {
                 // check for action permissions.
                 if (!CRM_Core_Permission::checkActionPermission('CiviMail', $this->_action)) {
                     CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
                 }
                 require_once 'CRM/Mailing/BAO/Mailing.php';
                 CRM_Mailing_BAO_Mailing::del($this->_mailingId);
                 CRM_Utils_System::redirect($context);
             } else {
                 $controller = new CRM_Core_Controller_Simple('CRM_Mailing_Form_Browse', ts('Delete Mailing'), $this->_action);
                 $controller->setEmbedded(true);
                 $controller->run();
             }
         } else {
             if ($this->_action & CRM_Core_Action::RENEW) {
                 //archive this mailing, CRM-3752.
                 if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', $this)) {
                     //set is_archived to 1
                     CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingId, 'is_archived', true);
                     CRM_Utils_System::redirect($context);
                 } else {
                     $controller = new CRM_Core_Controller_Simple('CRM_Mailing_Form_Browse', ts('Archive Mailing'), $this->_action);
                     $controller->setEmbedded(true);
                     $controller->run();
                 }
             }
         }
     }
     $selector = new CRM_Mailing_Selector_Browse();
     $selector->setParent($this);
     $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $this->get(CRM_Utils_Sort::SORT_ID) . $this->get(CRM_Utils_Sort::SORT_DIRECTION), CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TEMPLATE);
     $controller->setEmbedded(true);
     $controller->run();
     //hack to display results as per search
     $rows = $controller->getRows($controller);
     $this->assign('rows', $rows);
     $urlParams = 'reset=1';
     $urlString = 'civicrm/mailing/browse';
     if (CRM_Utils_Array::value(3, $newArgs) == 'unscheduled') {
         $urlString .= '/unscheduled';
         $urlParams .= '&scheduled=false';
         $this->assign('unscheduled', true);
         CRM_Utils_System::setTitle(ts('Draft and Unscheduled Mailings'));
     } else {
         if (CRM_Utils_Array::value(3, $newArgs) == 'archived') {
             $urlString .= '/archived';
             $this->assign('archived', true);
             CRM_Utils_System::setTitle(ts('Archived Mailings'));
         } else {
             if (CRM_Utils_Array::value(3, $newArgs) == 'scheduled') {
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Browse.php

示例15: adjustPledgePayment

 /**
  * @param int $pledgeID
  * @param $actualAmount
  * @param $pledgeScheduledAmount
  * @param int $paymentContributionId
  * @param int $pPaymentId
  * @param int $paymentStatusID
  */
 public static function adjustPledgePayment($pledgeID, $actualAmount, $pledgeScheduledAmount, $paymentContributionId = NULL, $pPaymentId = NULL, $paymentStatusID = NULL)
 {
     $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     if ($paymentStatusID == array_search('Cancelled', $allStatus) || $paymentStatusID == array_search('Refunded', $allStatus)) {
         $query = "\nSELECT civicrm_pledge_payment.id id\nFROM  civicrm_pledge_payment\nWHERE civicrm_pledge_payment.contribution_id = {$paymentContributionId}\n";
         $paymentsAffected = CRM_Core_DAO::executeQuery($query);
         $paymentIDs = array();
         while ($paymentsAffected->fetch()) {
             $paymentIDs[] = $paymentsAffected->id;
         }
         // Reset the affected values by the amount paid more than the scheduled amount
         foreach ($paymentIDs as $key => $value) {
             $payment = new CRM_Pledge_DAO_PledgePayment();
             $payment->id = $value;
             if ($payment->find(TRUE)) {
                 $payment->contribution_id = 'null';
                 $payment->status_id = array_search('Pending', $allStatus);
                 $payment->scheduled_date = NULL;
                 $payment->reminder_date = NULL;
                 $payment->scheduled_amount = $pledgeScheduledAmount;
                 $payment->actual_amount = 'null';
                 $payment->save();
             }
         }
         // Cancel the initial paid amount
         CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', reset($paymentIDs), 'status_id', $paymentStatusID, 'id');
         CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', reset($paymentIDs), 'actual_amount', $actualAmount, 'id');
         // Add new payment after the last payment for the pledge
         $allPayments = self::getPledgePayments($pledgeID);
         $lastPayment = array_pop($allPayments);
         $pledgeFrequencyUnit = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $pledgeID, 'frequency_unit', 'id');
         $pledgeFrequencyInterval = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $pledgeID, 'frequency_interval', 'id');
         $pledgeScheduledDate = $lastPayment['scheduled_date'];
         $scheduled_date = CRM_Utils_Date::processDate($pledgeScheduledDate);
         $date['year'] = (int) substr($scheduled_date, 0, 4);
         $date['month'] = (int) substr($scheduled_date, 4, 2);
         $date['day'] = (int) substr($scheduled_date, 6, 2);
         $newDate = date('YmdHis', mktime(0, 0, 0, $date['month'], $date['day'], $date['year']));
         $ScheduledDate = CRM_Utils_Date::format(CRM_Utils_Date::intervalAdd($pledgeFrequencyUnit, $pledgeFrequencyInterval, $newDate));
         $pledgeParams = array('status_id' => array_search('Pending', $allStatus), 'pledge_id' => $pledgeID, 'scheduled_amount' => $pledgeScheduledAmount, 'scheduled_date' => $ScheduledDate);
         $payment = self::add($pledgeParams);
     } else {
         $oldestPayment = self::getOldestPledgePayment($pledgeID);
         if (!$paymentContributionId) {
             // means we are editing payment scheduled payment, so get the second pending to update.
             $oldestPayment = self::getOldestPledgePayment($pledgeID, 2);
             if ($oldestPayment['count'] != 1 && $oldestPayment['id'] == $pPaymentId) {
                 $oldestPayment = self::getOldestPledgePayment($pledgeID);
             }
         }
         if ($oldestPayment) {
             // not the last scheduled payment and the actual amount is less than the expected , add it to oldest pending.
             if ($actualAmount != $pledgeScheduledAmount && ($actualAmount < $pledgeScheduledAmount || $actualAmount - $pledgeScheduledAmount < $oldestPayment['amount'])) {
                 $oldScheduledAmount = $oldestPayment['amount'];
                 $newScheduledAmount = $oldScheduledAmount + ($pledgeScheduledAmount - $actualAmount);
                 // store new amount in oldest pending payment record.
                 CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $oldestPayment['id'], 'scheduled_amount', $newScheduledAmount);
                 if (CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $oldestPayment['id'], 'contribution_id', 'id')) {
                     CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $oldestPayment['id'], 'contribution_id', $paymentContributionId);
                 }
             } elseif ($actualAmount > $pledgeScheduledAmount && $actualAmount - $pledgeScheduledAmount >= $oldestPayment['amount']) {
                 // here the actual amount is greater than expected and also greater than the next installment amount, so update the next installment as complete and again add it to next subsequent pending payment
                 // set the actual amount of the next pending to '0', set contribution Id to current contribution Id and status as completed
                 $paymentId = array($oldestPayment['id']);
                 self::updatePledgePayments($pledgeID, array_search('Completed', $allStatus), $paymentId, 0, $paymentContributionId);
                 CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $oldestPayment['id'], 'scheduled_amount', 0, 'id');
                 $oldestPayment = self::getOldestPledgePayment($pledgeID);
                 if (!$paymentContributionId) {
                     // means we are editing payment scheduled payment.
                     $oldestPaymentAmount = self::getOldestPledgePayment($pledgeID, 2);
                 }
                 $newActualAmount = $actualAmount - $pledgeScheduledAmount;
                 $newPledgeScheduledAmount = $oldestPayment['amount'];
                 if (!$paymentContributionId) {
                     $newActualAmount = $actualAmount - $pledgeScheduledAmount;
                     $newPledgeScheduledAmount = $oldestPaymentAmount['amount'];
                     // means we are editing payment scheduled payment, so update scheduled amount.
                     CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $oldestPaymentAmount['id'], 'scheduled_amount', $newActualAmount);
                 }
                 if ($newActualAmount > 0) {
                     self::adjustPledgePayment($pledgeID, $newActualAmount, $newPledgeScheduledAmount, $paymentContributionId);
                 }
             }
         }
     }
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:94,代码来源:PledgePayment.php


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