/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { parent::buildQuickForm(); if ($this->_action & CRM_Core_Action::UPDATE) { $bookingStatus = CRM_Booking_BAO_Booking::buildOptions('status_id', 'create'); if ($this->_values['status_id'] == $this->_cancelStatusId) { $this->assign('cancel_status_id', $this->_cancelStatusId); $this->add('hidden', 'booking_status', $this->_values['status_id']); } else { unset($bookingStatus[$this->_cancelStatusId]); //remove cancelled option $this->add('select', 'booking_status', ts('Booking status'), array('' => ts('- select -')) + $bookingStatus, TRUE, array()); } } $this->addFormRule(array('CRM_Booking_Form_Booking_Update', 'formRule'), $this); }
function buildQuickForm() { parent::buildQuickForm(); $this->addEntityRef("primary_contact_id", ts('Primary contact'), array('create' => TRUE), TRUE); $this->addEntityRef("secondary_contact_id", ts('Secondary contact'), array('create' => TRUE)); $this->add('text', 'po_no', ts('Purchase order number')); $bookingStatus = CRM_Booking_BAO_Booking::buildOptions('status_id', 'create'); $result = civicrm_api3('OptionValue', 'get', array('option_group_name' => CRM_Booking_Utils_Constants::OPTION_BOOKING_STATUS, 'name' => CRM_Booking_Utils_Constants::OPTION_VALUE_CANCELLED)); $this->_cancelStatusId = CRM_Utils_Array::value('value', CRM_Utils_Array::value($result['id'], $result['values'])); unset($bookingStatus[$this->_cancelStatusId]); $this->add('select', 'booking_status', ts('Booking status'), array('' => ts('- select -')) + $bookingStatus, TRUE, array()); $this->add('text', 'title', ts('Title'), array('size' => 80, 'maxlength' => 255), TRUE); $this->addDate('event_start_date', ts('Date booking made'), TRUE, array('formatType' => 'activityDateTime')); $this->add('textarea', 'description', ts('Description')); $this->add('textarea', 'note', ts('Note')); $this->add('text', 'enp', ts('Estimate number of participants')); $this->add('text', 'fnp', ts('Final number of participants')); $this->addElement('hidden', "resources"); $buttons = array(array('type' => 'back', 'name' => ts('<< Back')), array('type' => 'submit', 'name' => ts('Complete and Save'))); $this->addButtons($buttons); $this->addFormRule(array('CRM_Booking_Form_Booking_Info', 'formRule'), $this); }
/** * Process that send e-mails * * @return void * @access public */ static function sendMail($contactID, &$values, $isTest = FALSE, $returnMessageText = FALSE) { //TODO:: check if from email address is entered $config = CRM_Booking_BAO_BookingConfig::getConfig(); $template = CRM_Core_Smarty::singleton(); list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID); //send email only when email is present if ($email) { $bookingId = $values['booking_id']; //get latest booking status $params = array('id' => $bookingId); $bookingLatest = civicrm_api3('Booking', 'get', $params); $bookingStatusValueItems = CRM_Booking_BAO_Booking::buildOptions('status_id', 'create'); //get booking status option values $bookingLatestStatus = $bookingStatusValueItems[$bookingLatest['values'][$bookingId]['status_id']]; //get booking detail $bookingDetail = CRM_Booking_BAO_Booking::getBookingDetails($values['booking_id']); $slots = CRM_Utils_Array::value('slots', $bookingDetail); $subSlots = CRM_Utils_Array::value('sub_slots', $bookingDetail); $adhocCharges = CRM_Utils_Array::value('adhoc_charges', $bookingDetail); $cancellationCharges = CRM_Utils_Array::value('cancellation_charges', $bookingDetail); //get contacts associating with booking $contactIds = array(); $contactIds['primary_contact'] = CRM_Utils_Array::value('primary_contact_id', $values); $contactIds['secondary_contact'] = CRM_Utils_Array::value('secondary_contact_id', $values); $contactsDetail = array(); foreach (array_filter($contactIds) as $k => $contactIdItem) { //get contact detail $contactDetail = array(); $params = array('contact_id' => $contactIdItem); $contactDetailResult = civicrm_api3('Contact', 'get', $params); $contactValues = CRM_Utils_Array::value($contactDetailResult['id'], $contactDetailResult['values']); foreach ($contactValues as $key => $contactItem) { $contactDetail[$key] = $contactItem; } $contactsDetail[$k] = $contactDetail; } //get Price elements(Subtotal, Discount, Total) $booking_amount = CRM_Booking_BAO_Booking::getBookingAmount($values['booking_id']); //get date booking made $dateBookingMade = new DateTime($values['booking_date']); $tplParams = array('email' => $email, 'today_date' => date('d.m.Y'), 'receipt_header_message' => $values['receipt_header_message'], 'receipt_footer_message' => $values['receipt_footer_message'], 'booking_id' => $bookingId, 'booking_title' => $values['booking_title'], 'booking_status' => $bookingLatestStatus, 'booking_date_made' => $values['booking_date'], 'booking_start_date' => $values['booking_start_date'], 'booking_end_date' => $values['booking_end_date'], 'booking_event_day' => $dateBookingMade->format('l'), 'booking_subtotal' => number_format($booking_amount['total_amount'] + $booking_amount['discount_amount'], 2, '.', ''), 'booking_total' => number_format($booking_amount['total_amount'], 2, '.', ''), 'booking_discount' => number_format($booking_amount['discount_amount'], 2, '.', ''), 'participants_estimate' => $values['participants_estimate'], 'participants_actual' => $values['participants_actual'], 'contacts' => $contactsDetail, 'slots' => $slots, 'sub_slots' => $subSlots, 'adhoc_charges' => $adhocCharges, 'cancellation_charges' => $cancellationCharges); $sendTemplateParams = array('groupName' => 'msg_tpl_workflow_booking', 'valueName' => 'booking_offline_receipt', 'contactId' => $contactID, 'isTest' => $isTest, 'tplParams' => $tplParams, 'PDFFilename' => 'bookingReceipt.pdf'); //get include payment check box //if(CRM_Utils_Array::value('include_payment_info', $values)){ if (CRM_Utils_Array::value('contribution', $bookingDetail)) { //get contribution record $contribution = array(); $contributionResult = CRM_Utils_Array::value('contribution', $bookingDetail); foreach ($contributionResult as $kx => $ctbItem) { $contribution = $ctbItem; } $sendTemplateParams['tplParams']['contribution'] = $contribution; //calculate Amount outstanding $sendTemplateParams['tplParams']['amount_outstanding'] = number_format($booking_amount['total_amount'] - $contribution['total_amount'], 2, '.', ''); } //TODO:: add line item tpl params if ($lineItem = CRM_Utils_Array::value('lineItem', $values)) { $sendTemplateParams['tplParams']['lineItem'] = $lineItem; } $sendTemplateParams['from'] = $values['from_email_address']; $sendTemplateParams['toName'] = $displayName; $sendTemplateParams['toEmail'] = $email; //$sendTemplateParams['autoSubmitted'] = TRUE; $cc = CRM_Utils_Array::value('cc_email_address', $config); if ($cc) { $sendTemplateParams['cc'] = $cc; } $bcc = CRM_Utils_Array::value('bcc_email_address', $config); if ($bcc) { $sendTemplateParams['bcc'] = $bcc; } list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); if ($sent && CRM_Utils_Array::value('log_confirmation_email', $config)) { //check log_email_confirmaiton $session =& CRM_Core_Session::singleton(); $userId = $session->get('userID'); // which is contact id of the user //create activity for sending email $params = array('option_group_name' => 'activity_type', 'name' => CRM_Booking_Utils_Constants::ACTIVITY_TYPE_SEND_EMAIL); $optionValue = civicrm_api3('OptionValue', 'get', $params); $activityTypeId = $optionValue['values'][$optionValue['id']]['value']; $params = array('source_contact_id' => $userId, 'activity_type_id' => $activityTypeId, 'subject' => ts('Send Booking Confirmation Email'), 'activity_date_time' => date('YmdHis'), 'target_contact_id' => $contactID, 'details' => $message, 'status_id' => 2, 'priority_id' => 2); $result = civicrm_api3('Activity', 'create', $params); } if ($returnMessageText) { return array('subject' => $subject, 'body' => $message, 'to' => $displayName, 'html' => $html); } } }
static function buildSearchForm(&$form) { $form->add('text', 'booking_po_no', ts('Purchase Order Number')); $resourceTypes = CRM_Booking_BAO_Resource::getResourceTypes(); $resources = array(); foreach ($resourceTypes as $value) { $resources[$value['id']] = $value['label']; } $form->add('select', 'booking_resource_id', ts('Resource Type'), array('' => ts('- select -')) + $resources, FALSE, array()); $form->add('text', 'booking_id', ts('Booking ID')); $form->add('text', 'booking_title', ts('Booking Title')); CRM_Core_Form_Date::buildDateRange($form, 'booking_event_date', 1, '_low', '_high', ts('From'), FALSE); CRM_Core_Form_Date::buildDateRange($form, 'booking_start_date', 1, '_low', '_high', ts('From'), FALSE); CRM_Core_Form_Date::buildDateRange($form, 'booking_end_date', 1, '_low', '_high', ts('From'), FALSE); $bookingStatus = CRM_Booking_BAO_Booking::buildOptions('status_id', 'create'); foreach ($bookingStatus as $id => $name) { $form->_bookingStatus =& $form->addElement('checkbox', "booking_status_id[{$id}]", NULL, $name); } $paymentStatus = CRM_Contribute_PseudoConstant::contributionStatus(); foreach ($paymentStatus as $id => $name) { $form->_paymentStatus = $form->addElement('checkbox', "booking_payment_status_id[{$id}]", NULL, $name); } }