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


PHP CRM_Utils_Date::currentDBDate方法代码示例

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


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

示例1: create

 /**
  * Create a new HRJobContractRevision based on array-data
  *
  * @param array $params key-value pairs
  * @return CRM_HRJob_DAO_HRJobContractRevision|NULL
  *
  */
 public static function create($params)
 {
     global $user;
     $params['editor_uid'] = $user->uid;
     $className = 'CRM_Hrjobcontract_DAO_HRJobContractRevision';
     $entityName = 'HRJobContractRevision';
     $hook = empty($params['id']) ? 'create' : 'edit';
     $now = CRM_Utils_Date::currentDBDate();
     if ($hook === 'create') {
         $params['created_date'] = $now;
         $params['deleted'] = 0;
     } else {
         $params['modified_date'] = $now;
     }
     CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
     $instance = new $className();
     $instance->copyValues($params);
     $instance->save();
     CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
     return $instance;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:28,代码来源:HRJobContractRevision.php

示例2: addActivityForSelection

 /**
  * @param int $participantId
  * @param $activityType
  *
  * @throws CRM_Core_Exception
  */
 public static function addActivityForSelection($participantId, $activityType)
 {
     $eventId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantId, 'event_id');
     $contactId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantId, 'contact_id');
     $date = CRM_Utils_Date::currentDBDate();
     $event = CRM_Event_BAO_Event::getEvents(0, $eventId);
     $eventTitle = $event[$eventId];
     $subject = "Registration selections changed for {$eventTitle}";
     $targetCid = $contactId;
     $srcRecId = $participantId;
     // activity params
     $activityParams = array('source_contact_id' => $targetCid, 'source_record_id' => $srcRecId, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'subject' => $subject, 'activity_date_time' => $date, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'), 'skipRecentView' => TRUE);
     // create activity with target contacts
     $session = CRM_Core_Session::singleton();
     $id = $session->get('userID');
     if ($id) {
         $activityParams['source_contact_id'] = $id;
         $activityParams['target_contact_id'][] = $targetCid;
     }
     CRM_Activity_BAO_Activity::create($activityParams);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:27,代码来源:Participant.php

示例3: needsRunning

 /**
  * @return bool
  */
 public function needsRunning()
 {
     /************************************
      * begin com.klangsoft.flexiblejobs *
      ************************************/
     // check if the job has a specificly scheduled date/time
     $key = 'job_' . $this->id;
     $ts = CRM_Core_BAO_Setting::getItem('com.klangsoft.flexiblejobs', $key);
     if (!is_null($ts)) {
         if ($ts < time()) {
             CRM_Core_BAO_Setting::setItem(NULL, 'com.klangsoft.flexiblejobs', $key);
             return TRUE;
         } else {
             return FALSE;
         }
     }
     /**********************************
      * end com.klangsoft.flexiblejobs *
      **********************************/
     // run if it was never run
     if (empty($this->last_run)) {
         return TRUE;
     }
     // run_frequency check
     switch ($this->run_frequency) {
         case 'Always':
             return TRUE;
             /************************************
              * begin com.klangsoft.flexiblejobs *
              ************************************/
         /************************************
          * begin com.klangsoft.flexiblejobs *
          ************************************/
         case 'Yearly':
             $offset = '+1 year';
             break;
         case 'Quarter':
             $offset = '+3 months';
             break;
         case 'Monthly':
             $offset = '+1 month';
             break;
         case 'Weekly':
             $offset = '+1 week';
             break;
         case 'Daily':
             $offset = '+1 day';
             break;
         case 'Hourly':
             $offset = '+1 hour';
             break;
     }
     $now = strtotime(CRM_Utils_Date::currentDBDate());
     $lastTime = strtotime($this->last_run);
     $nextTime = strtotime($offset, $lastTime);
     return $now >= $nextTime;
     /**********************************
      * end com.klangsoft.flexiblejobs *
      **********************************/
 }
开发者ID:konadave,项目名称:com.klangsoft.flexiblejobs,代码行数:63,代码来源:ScheduledJob.php

示例4: testCreateContactCustomFldDateTime

 /**
  * CRM-15792 - create/update datetime field for contact.
  */
 public function testCreateContactCustomFldDateTime()
 {
     $customGroup = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'datetime_test_group'));
     $dateTime = CRM_Utils_Date::currentDBDate();
     //check date custom field is saved along with time when time_format is set
     $params = array('first_name' => 'abc3', 'last_name' => 'xyz3', 'contact_type' => 'Individual', 'email' => 'man3@yahoo.com', 'api.CustomField.create' => array('custom_group_id' => $customGroup['id'], 'name' => 'test_datetime', 'label' => 'Demo Date', 'html_type' => 'Select Date', 'data_type' => 'Date', 'time_format' => 2, 'weight' => 4, 'is_required' => 1, 'is_searchable' => 0, 'is_active' => 1));
     $result = $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__);
     $customFldId = $result['values'][$result['id']]['api.CustomField.create']['id'];
     $this->assertNotNull($result['id']);
     $this->assertNotNull($customFldId);
     $params = array('id' => $result['id'], "custom_{$customFldId}" => $dateTime, 'api.CustomValue.get' => 1);
     $result = $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__);
     $this->assertNotNull($result['id']);
     $customFldDate = date("YmdHis", strtotime($result['values'][$result['id']]['api.CustomValue.get']['values'][0]['latest']));
     $this->assertNotNull($customFldDate);
     $this->assertEquals($dateTime, $customFldDate);
     $customValueId = $result['values'][$result['id']]['api.CustomValue.get']['values'][0]['id'];
     $dateTime = date('Ymd');
     //date custom field should not contain time part when time_format is null
     $params = array('id' => $result['id'], 'api.CustomField.create' => array('id' => $customFldId, 'html_type' => 'Select Date', 'data_type' => 'Date', 'time_format' => ''), 'api.CustomValue.create' => array('id' => $customValueId, 'entity_id' => $result['id'], "custom_{$customFldId}" => $dateTime), 'api.CustomValue.get' => 1);
     $result = $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__);
     $this->assertNotNull($result['id']);
     $customFldDate = date("Ymd", strtotime($result['values'][$result['id']]['api.CustomValue.get']['values'][0]['latest']));
     $customFldTime = date("His", strtotime($result['values'][$result['id']]['api.CustomValue.get']['values'][0]['latest']));
     $this->assertNotNull($customFldDate);
     $this->assertEquals($dateTime, $customFldDate);
     $this->assertEquals(00, $customFldTime);
     $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:32,代码来源:ContactTest.php

示例5: postProcess

 /**
  * Process the form submission.
  */
 public function postProcess()
 {
     CRM_Utils_System::flushCache('CRM_Core_DAO_Job');
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_BAO_Job::del($this->_id);
         CRM_Core_Session::setStatus("", ts('Scheduled Job Deleted.'), "success");
         return;
     }
     $values = $this->controller->exportValues($this->_name);
     $domainID = CRM_Core_Config::domainID();
     $dao = new CRM_Core_DAO_Job();
     $dao->id = $this->_id;
     $dao->domain_id = $domainID;
     $dao->run_frequency = $values['run_frequency'];
     $dao->parameters = $values['parameters'];
     $dao->name = $values['name'];
     $dao->api_entity = $values['api_entity'];
     $dao->api_action = $values['api_action'];
     $dao->description = $values['description'];
     $dao->is_active = CRM_Utils_Array::value('is_active', $values, 0);
     // CRM-17686
     $ts = strtotime($values['scheduled_run_date']);
     // if a date/time is supplied and not in the past, then set the next scheduled run...
     if ($ts > time()) {
         $dao->scheduled_run_date = CRM_Utils_Date::currentDBDate($ts);
         // warn about monthly/quarterly scheduling, if applicable
         if ($dao->run_frequency == 'Monthly' || $dao->run_frequency == 'Quarter') {
             $info = getdate($ts);
             if ($info['mday'] > 28) {
                 CRM_Core_Session::setStatus(ts('Relative month values are calculated based on the length of month(s) that they pass through.
           The result will land on the same day of the month except for days 29-31 when the target month contains fewer days than the previous month.
           For example, if a job is scheduled to run on August 31st, the following invocation will occur on October 1st, and then the 1st of every month thereafter.
           To avoid this issue, please schedule Monthly and Quarterly jobs to run within the first 28 days of the month.'), ts('Warning'), 'info', array('expires' => 0));
             }
         }
     } elseif ($dao->id) {
         $job = new CRM_Core_ScheduledJob(array('id' => $dao->id));
         $job->clearScheduledRunDate();
     }
     $dao->save();
     // CRM-11143 - Give warning message if update_greetings is Enabled (is_active) since it generally should not be run automatically via execute action or runjobs url.
     if ($values['api_action'] == 'update_greeting' && CRM_Utils_Array::value('is_active', $values) == 1) {
         // pass "wiki" as 6th param to docURL2 if you are linking to a page in wiki.civicrm.org
         $docLink = CRM_Utils_System::docURL2("Managing Scheduled Jobs", NULL, NULL, NULL, NULL, "wiki");
         $msg = ts('The update greeting job can be very resource intensive and is typically not necessary to run on a regular basis. If you do choose to enable the job, we recommend you do not run it with the force=1 option, which would rebuild greetings on all records. Leaving that option absent, or setting it to force=0, will only rebuild greetings for contacts that do not currently have a value stored. %1', array(1 => $docLink));
         CRM_Core_Session::setStatus($msg, ts('Warning: Update Greeting job enabled'), 'alert');
     }
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:51,代码来源:Job.php

示例6: needsRunning

 /**
  * @return bool
  */
 public function needsRunning()
 {
     // CRM-17686
     // check if the job has a specific scheduled date/time
     if (!empty($this->scheduled_run_date)) {
         if (strtotime($this->scheduled_run_date) <= time()) {
             $this->clearScheduledRunDate();
             return TRUE;
         } else {
             return FALSE;
         }
     }
     // run if it was never run
     if (empty($this->last_run)) {
         return TRUE;
     }
     // run_frequency check
     switch ($this->run_frequency) {
         case 'Always':
             return TRUE;
             // CRM-17669
         // CRM-17669
         case 'Yearly':
             $offset = '+1 year';
             break;
         case 'Quarter':
             $offset = '+3 months';
             break;
         case 'Monthly':
             $offset = '+1 month';
             break;
         case 'Weekly':
             $offset = '+1 week';
             break;
         case 'Daily':
             $offset = '+1 day';
             break;
         case 'Hourly':
             $offset = '+1 hour';
             break;
     }
     $now = strtotime(CRM_Utils_Date::currentDBDate());
     $lastTime = strtotime($this->last_run);
     $nextTime = strtotime($offset, $lastTime);
     return $now >= $nextTime;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:49,代码来源:ScheduledJob.php

示例7: buildQuickForm

 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->_showFeeBlock) {
         return CRM_Event_Form_EventFees::buildQuickForm($this);
     }
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     //need to assign custom data type to the template
     $this->assign('customDataType', 'Participant');
     $this->applyFilter('__ALL__', 'trim');
     if ($this->_action & CRM_Core_Action::DELETE) {
         if ($this->_single) {
             $additionalParticipant = count(CRM_Event_BAO_Event::buildCustomProfile($this->_id, NULL, $this->_contactId, FALSE, TRUE)) - 1;
             if ($additionalParticipant) {
                 $deleteParticipants = array(1 => ts('Delete this participant record along with associated participant record(s).'), 2 => ts('Delete only this participant record.'));
                 $this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '<br />');
                 $this->setDefaults(array('delete_participant' => 1));
                 $this->assign('additionalParticipant', $additionalParticipant);
             }
         }
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     if ($this->_single) {
         $urlPath = 'civicrm/contact/view/participant';
         $urlParams = "reset=1&cid={$this->_contactId}&context=participant";
         if ($this->_context == 'standalone') {
             CRM_Contact_Form_NewContact::buildQuickForm($this);
             $urlParams = 'reset=1&context=standalone';
             $urlPath = 'civicrm/participant/add';
         }
         if ($this->_id) {
             $urlParams .= "&action=update&id={$this->_id}";
         } else {
             $urlParams .= "&action=add";
         }
         if ($this->_mode) {
             $urlParams .= "&mode={$this->_mode}";
         }
         $url = CRM_Utils_System::url($urlPath, $urlParams, FALSE, NULL, FALSE);
     } else {
         $currentPath = CRM_Utils_System::currentPath();
         $url = CRM_Utils_System::url($currentPath, '_qf_Participant_display=true', FALSE, NULL, FALSE);
     }
     $this->assign('refreshURL', $url);
     $this->add('hidden', 'past_event');
     $events = array();
     if ($this->_eID) {
         $eventEndDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eID, 'end_date');
     }
     $this->assign('past', 0);
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $events = CRM_Event_BAO_Event::getEvents(1, FALSE, FALSE);
     } elseif ($this->getElementValue('past_event') || isset($eventEndDate) && CRM_Utils_Date::currentDBDate() > CRM_Utils_Date::processDate($eventEndDate)) {
         $pastval = $this->getElementValue('past_event');
         $events = CRM_Event_BAO_Event::getEvents($pastval);
         $this->assign('past', $pastval);
     } else {
         $events = CRM_Event_BAO_Event::getEvents();
     }
     if ($this->_mode) {
         //unset the event which are not monetary when credit card
         //event registration is used
         foreach ($events as $key => $val) {
             $isPaid = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $key, 'is_monetary');
             if (!$isPaid) {
                 unset($events[$key]);
             }
         }
         $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE);
     }
     // build array(event -> eventType) mapper
     $query = "\nSELECT     civicrm_event.id as id, civicrm_event.event_type_id as event_type_id\nFROM       civicrm_event\nWHERE      civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0";
     $dao = CRM_Core_DAO::executeQuery($query);
     $eventAndTypeMapping = array();
     while ($dao->fetch()) {
         $eventAndTypeMapping[$dao->id] = $dao->event_type_id;
     }
     $eventAndTypeMapping = json_encode($eventAndTypeMapping);
     // building of mapping ends --
     //inherit the campaign from event.
     $eventCampaigns = array();
     $allEventIds = array_keys($events);
     if (!empty($allEventIds)) {
         CRM_Core_PseudoConstant::populate($eventCampaigns, 'CRM_Event_DAO_Event', TRUE, 'campaign_id');
     }
     $eventCampaigns = json_encode($eventCampaigns);
     $element = $this->add('select', 'event_id', ts('Event'), array('' => ts('- select -')) + $events, TRUE, array('onchange' => "buildFeeBlock( this.value ); CRM.buildCustomData( 'Participant', this.value, {$this->_eventNameCustomDataTypeID} ); buildParticipantRole( this.value ); buildEventTypeCustomData( this.value, {$this->_eventTypeCustomDataTypeID}, '{$eventAndTypeMapping}' ); loadCampaign( this.value, {$eventCampaigns} );", 'class' => 'huge'));
     // CRM-6111
     // note that embedding JS within PHP files is quite awful, IMO
     // but we do the same for the onChange element and this form is complex
     // and i did not want to break it late in the 3.2 cycle
     $preloadJSSnippet = NULL;
//.........这里部分代码省略.........
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:Participant.php

示例8: needsRunning

 /**
  * @return bool
  */
 public function needsRunning()
 {
     // run if it was never run
     if (empty($this->last_run)) {
         return TRUE;
     }
     // run_frequency check
     switch ($this->run_frequency) {
         case 'Always':
             return TRUE;
         case 'Hourly':
             $format = 'YmdH';
             break;
         case 'Daily':
             $format = 'Ymd';
             break;
         case 'Mondays':
             $now = CRM_Utils_Date::currentDBDate();
             $dayAgo = strtotime('-1 day', strtotime($now));
             $lastRun = strtotime($this->last_run);
             $nowDayOfWeek = date('l', strtotime($now));
             return $lastRun < $dayAgo && $nowDayOfWeek == 'Monday';
         case '1stOfMth':
             $now = CRM_Utils_Date::currentDBDate();
             $dayAgo = strtotime('-1 day', strtotime($now));
             $lastRun = strtotime($this->last_run);
             $nowDayOfMonth = date('j', strtotime($now));
             return $lastRun < $dayAgo && $nowDayOfMonth == '1';
         case '1stOfQtr':
             $now = CRM_Utils_Date::currentDBDate();
             $dayAgo = strtotime('-1 day', strtotime($now));
             $lastRun = strtotime($this->last_run);
             $nowDayOfMonth = date('j', strtotime($now));
             $nowMonth = date('n', strtotime($now));
             $qtrMonths = array('1', '4', '7', '10');
             return $lastRun < $dayAgo && $nowDayOfMonth == '13' && in_array($nowMonth, $qtrMonths);
     }
     $now = CRM_Utils_Date::currentDBDate();
     $lastTime = date($format, strtotime($this->last_run));
     $thisTime = date($format, strtotime($now));
     return $lastTime != $thisTime;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:45,代码来源:ScheduledJob.php

示例9: needsRunning

 /**
  * @return bool
  */
 public function needsRunning()
 {
     // run if it was never run
     if (empty($this->last_run)) {
         return TRUE;
     }
     // run_frequency check
     switch ($this->run_frequency) {
         case 'Always':
             return TRUE;
         case 'Hourly':
             $format = 'YmdH';
             break;
         case 'Daily':
             $format = 'Ymd';
             break;
     }
     $now = CRM_Utils_Date::currentDBDate();
     $lastTime = date($format, strtotime($this->last_run));
     $thisTime = date($format, strtotime($now));
     return $lastTime != $thisTime;
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:25,代码来源:ScheduledJob.php

示例10: needsRunning

 /**
  * @return bool
  */
 public function needsRunning()
 {
     // run if it was never run
     if (empty($this->last_run)) {
         return TRUE;
     }
     // run_frequency check
     switch ($this->run_frequency) {
         case 'Always':
             return TRUE;
         case 'Hourly':
             $now = CRM_Utils_Date::currentDBDate();
             $hourAgo = strtotime('-1 hour', strtotime($now));
             $lastRun = strtotime($this->last_run);
             if ($lastRun < $hourAgo) {
                 return TRUE;
             }
         case 'Daily':
             $now = CRM_Utils_Date::currentDBDate();
             $dayAgo = strtotime('-1 day', strtotime($now));
             $lastRun = strtotime($this->last_run);
             if ($lastRun < $dayAgo) {
                 return TRUE;
             }
     }
     return FALSE;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:30,代码来源:ScheduledJob.php

示例11: handlePaymentNotification

 public function handlePaymentNotification()
 {
     $errors = array("101" => "Tarjeta caducada", "102" => "Tarjeta en excepción transitoria o bajo sospecha de fraude", "106" => "Intentos de PIN excedidos", "125" => "Tarjeta no efectiva", "129" => "Código de seguridad (CVV2/CVC2) incorrecto", "180" => "Tarjeta ajena al servicio", "184" => "Error en la autenticación del titular", "190" => "Denegación del emisor sin especificar motivo", "191" => "Fecha de caducidad errónea", "202" => "Tarjeta en excepción transitoria o bajo sospecha de fraude con retirada de tarjeta", "904" => "Comercio no registrado en FUC", "909" => "Error de sistema", "913" => "Pedido repetido", "944" => "Sesión Incorrecta", "950" => "Operación de devolución no permitida", "912" => "Emisor no disponible", "9912" => "Emisor no disponible", "9064" => "Número de posiciones de la tarjeta incorrecto", "9078" => "Tipo de operación no permitida para esa tarjeta", "9093" => "Tarjeta no existente", "9094" => "Rechazo servidores internacionales", "9104" => "Comercio con “titular seguro” y titular sin clave de compra segura", "9218" => "El comercio no permite op. seguras por entrada /operaciones", "9253" => "Tarjeta no cumple el check-digit", "9256" => "El comercio no puede realizar preautorizaciones", "9257" => "Esta tarjeta no permite operativa de preautorizaciones", "9261" => "Operación detenida por superar el control de restricciones en la entrada al SIS", "9915" => "A petición del usuario se ha cancelado el pago", "9929" => "Anulación de autorización en diferido realizada por el comercio", "9997" => "Se está procesando otra transacción en SIS con la misma tarjeta", "9998" => "Operación en proceso de solicitud de datos de tarjeta", "9999" => "Operación que ha sido redirigida al emisor a autenticar");
     $module = self::retrieve('md', 'String', 'GET', false);
     $qfKey = self::retrieve('qfKey', 'String', 'GET', false);
     $miObj = new RedsysAPI();
     $response = array();
     $response["version"] = $_POST["Ds_SignatureVersion"];
     $response["parameters"] = $_POST["Ds_MerchantParameters"];
     $response["signature"] = $_POST["Ds_Signature"];
     $decodecResponseJson = $miObj->decodeMerchantParameters($response["parameters"]);
     $decodecResponse = json_decode($decodecResponseJson);
     $firma = $miObj->createMerchantSignatureNotif($this->_paymentProcessor["password"], $response["parameters"]);
     // Validations
     if ($decodecResponse->Ds_MerchantCode != $this->_paymentProcessor["user_name"]) {
         CRM_Core_Error::debug_log_message("Redsys Response param Ds_MerchantCode incorrect");
         return false;
     }
     // Contribution exists and is valid
     $contribution = new CRM_Contribute_BAO_Contribution();
     $contribution->id = self::trimAmount($decodecResponse->Ds_Order);
     if (!$contribution->find(TRUE)) {
         CRM_Core_Error::debug_log_message("Could not find contribution record: {$contribution->id} in IPN request: " . print_r($params, TRUE));
         echo "Failure: Could not find contribution record for {$contribution->id}<p>";
         return FALSE;
     }
     if ($firma === $response["signature"]) {
         switch ($module) {
             case 'contribute':
                 if ($decodecResponse->Ds_Response == self::REDSYS_RESPONSE_CODE_ACCEPTED) {
                     $query = "UPDATE civicrm_contribution SET trxn_id='" . $decodecResponse->Ds_AuthorisationCode . "', contribution_status_id=1 where id='" . self::trimAmount($decodecResponse->Ds_Order) . "'";
                     CRM_Core_DAO::executeQuery($query);
                 } else {
                     $error = self::trimAmount($decodecResponse->Ds_Response);
                     if (array_key_exists($error, $errors)) {
                         $error = $errors[$error];
                     }
                     $cancel_date = CRM_Utils_Date::currentDBDate();
                     $query = "UPDATE civicrm_contribution SET contribution_status_id=3, cancel_reason = '" . $error . "' , cancel_date = '" . $cancel_date . "' where id='" . self::trimAmount($decodecResponse->Ds_Order) . "'";
                     CRM_Core_DAO::executeQuery($query);
                 }
                 break;
             case 'event':
                 if ($decodecResponse->Ds_Response == self::REDSYS_RESPONSE_CODE_ACCEPTED) {
                     $query = "UPDATE civicrm_contribution SET trxn_id='" . $decodecResponse->Ds_AuthorisationCode . "', contribution_status_id=1 where id='" . self::trimAmount($decodecResponse->Ds_Order) . "'";
                     CRM_Core_DAO::executeQuery($query);
                 } else {
                     $error = self::trimAmount($decodecResponse->Ds_Response);
                     if (array_key_exists($error, $errors)) {
                         $error = $errors[$error];
                     }
                     $cancel_date = CRM_Utils_Date::currentDBDate();
                     $query = "UPDATE civicrm_contribution SET contribution_status_id=3, cancel_reason = '" . $error . "' , cancel_date = '" . $cancel_date . "' where id='" . self::trimAmount($decodecResponse->Ds_Order) . "'";
                     CRM_Core_DAO::executeQuery($query);
                 }
                 break;
             default:
                 require_once 'CRM/Core/Error.php';
                 CRM_Core_Error::debug_log_message("Could not get module name from request url");
         }
     }
 }
开发者ID:javivf,项目名称:civicrm-redsys,代码行数:62,代码来源:Redsys.php

示例12: createBatch

 static function createBatch(array $batchDetails)
 {
     //check mandatory $params
     foreach (array('banking_date', 'banking_account', 'batch_status', 'exclude_from_posting', 'payment_instrument_id') as $param) {
         if (!isset($batchDetails[$param])) {
             throw new InvalidArgumentException("No param[{$param}]");
         }
     }
     // PS Commented out this way of creating the batch
     // Replaced with using the batch description and tidying
     //$batch_sql = "SELECT max(id) as max_id FROM civicrm_batch";
     //$batch_dao = CRM_Core_DAO::executeQuery($batch_sql);
     //$batch_dao->fetch();
     //$nextId = $batch_dao->max_id + 1;
     $session =& CRM_Core_Session::singleton();
     //$nextId = CRM_Utils_String::titleToVar($batchDetails['description']);
     if (!isset($batchDetails['batch_title'])) {
         $batchDetails['batch_title'] = 'Contrib Batch ' . CRM_Utils_Date::currentDBDate();
     }
     $batchParams = array('title' => $batchDetails['batch_title'], 'description' => $batchDetails['description'], 'created_id' => $session->get('userID'), 'created_date' => CRM_Utils_Date::currentDBDate(), 'type_id' => 1, 'status_id' => 2);
     // Create the batch
     require_once 'CRM/Batch/BAO/Batch.php';
     $createdBatch =& CRM_Batch_BAO_Batch::create($batchParams);
     $batchDetails['batch_id'] = $createdBatch->id;
     require_once 'CRM/Utils/Date.php';
     $batchDetails['banking_date'] = CRM_Utils_Date::processDate($batchDetails['banking_date']);
     //        require_once 'CRM/Finance/BAO/BatchType.php';
     $expectedPostingDate = CRM_Finance_BAO_BatchType::getBatchTypeExpectedPostingDate();
     //matusz: copied from CRM_Batch_Page_AJAX::getContributionTypeForCampaign()
     //$batchDetails['contribution_type_id']
     $campaignId = null;
     if (!empty($batchDetails['campaign_id'])) {
         $campaignId = $batchDetails['campaign_id'];
     }
     /*       
            $contributionTypeId = null;
            if($campaignId !== null) {
                $select_dao = CRM_Core_DAO::executeQuery("SELECT * FROM ".CIVICRM_MTL_CAMPAIGN_FUND_CODE." WHERE campaign_id = %0", array(
                    array($campaignId, 'Int')
                ));
                if (!$select_dao->fetch()){
                    throw new Exception("No contribution_type_id found by using campaign id '$campaignId'");
                }
     
                $batchDetails['contribution_type_id'] = $select_dao->contribution_type_id;
            }
     */
     if (empty($batchDetails['contribution_type_id'])) {
         $batchDetails['contribution_type_id'] = 0;
     }
     $batchDetails['exclude_from_posting'] = empty($batchDetails['exclude_from_posting']) ? 0 : 1;
     $sqlParams = array(array($batchDetails['payment_instrument_id'], 'Int'), array($expectedPostingDate, 'Timestamp'), array($batchDetails['exclude_from_posting'], 'Boolean'), array($batchDetails['banking_date'], 'Timestamp'), array($batchDetails['banking_account'], 'Int'), array($batchDetails['contribution_type_id'], 'Int'), array((string) $batchDetails['batch_title'], 'String'));
     $batchDetailsSql = " UPDATE civicrm_batch SET ";
     $batchDetailsSql .= "    payment_instrument_id = %0 ";
     $batchDetailsSql .= " ,  expected_posting_date = %1 ";
     $batchDetailsSql .= " ,  exclude_from_posting = %2 ";
     $batchDetailsSql .= " ,  banking_date  = %3 ";
     $batchDetailsSql .= " ,  banking_account = %4 ";
     $batchDetailsSql .= " ,  contribution_type_id = %5 ";
     $batchDetailsSql .= " ,  title = %6 ";
     $parameterIndex = 6;
     if ($campaignId !== null) {
         $parameterIndex = $parameterIndex + 1;
         $batchDetailsSql .= ", campaign_id = %{$parameterIndex} ";
         $sqlParams[] = array($campaignId, 'Int');
     }
     /*        
             if(isset($batchDetails['expected_entries'])) {
                 $parameterIndex = $parameterIndex + 1;            
                 $batchDetailsSql .= ", expected_entries = %$parameterIndex ";
                 $sqlParams[] = array($batchDetails['expected_entries'], 'Int');
             }
             
             if(isset($batchDetails['expected_value'])) {
                 $parameterIndex = $parameterIndex + 1;            
                 $batchDetailsSql .= ", expected_value = %$parameterIndex ";
                 $sqlParams[] = array($batchDetails['expected_value'], 'Money');
             }
     */
     if (isset($batchDetails['entity_type'])) {
         $parameterIndex = $parameterIndex + 1;
         $batchDetailsSql .= ", entity_type = %{$parameterIndex} ";
         $sqlParams[] = array($batchDetails['entity_type'], 'String');
     }
     $parameterIndex = $parameterIndex + 1;
     $batchDetailsSql .= " WHERE id = %{$parameterIndex} ";
     $sqlParams[] = array($batchDetails['batch_id'], 'Int');
     CRM_Core_DAO::executeQuery($batchDetailsSql, $sqlParams);
     return $batchDetails;
 }
开发者ID:hoegrammer,项目名称:uk.co.vedaconsulting.module.justgivingImports,代码行数:90,代码来源:Batch.php


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