--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.7 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2016 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+/**
+ * This class generates form components for closing an account period.
+ */
+class CRM_Contribute_Form_CloseAccPeriod extends CRM_Core_Form {
+
+ /**
+ * Set default values.
+ *
+ * @return array
+ */
+ public function setDefaultValues() {
+ $defaults = $period = array();
+ $period = Civi::settings()->get('closing_date');
+ if (empty($period)) {
+ $prior = CRM_Contribute_PseudoConstant::checkContributeSettings('prior_financial_period');
+ }
+ else {
+ $defaults['closing_date'] = $period;
+ return $defaults;
+ }
+ if (!empty($prior)) {
+ $period = array(
+ 'M' => date('n', strtotime($prior)),
+ 'd' => date('j', strtotime($prior)),
+ );
+ if ($period['M'] == 1) {
+ $period['M'] = 12;
+ }
+ else {
+ $period['M']--;
+ }
+ $defaults['closing_date'] = $period;
+ }
+ else {
+ $defaults['closing_date'] = array(
+ 'M' => date('n', strtotime("-1 month")),
+ 'd' => date('j'),
+ );
+ }
+ return $defaults;
+ }
+
+ /**
+ * Build the form object.
+ */
+ public function buildQuickForm() {
+ $this->add('date', 'closing_date', ts('Accounting Period to Close'), CRM_Core_SelectValues::date(NULL, 'M d'), TRUE);
+ $confirmClose = ts('Are you sure you want to close accounting period?');
+ $this->addButtons(array(
+ array(
+ 'type' => 'cancel',
+ 'name' => ts('Cancel'),
+ ),
+ array(
+ 'type' => 'upload',
+ 'name' => ts('Close Accounting Period'),
+ 'js' => array('onclick' => 'return confirm(\'' . $confirmClose . '\');'),
+ ),
+ )
+ );
+ }
+
+ /**
+ * Global form rule.
+ *
+ * @param array $fields
+ * The input form values.
+ * @param array $files
+ * The uploaded files if any.
+ * @param $self
+ *
+ */
+ public static function formRule($fields, $files, $self) {
+ }
+
+ /**
+ * Process the form submission.
+ */
+ public function postProcess() {
+ // store the submitted values in an array
+ $params = $this->controller->exportValues($this->_name);
+ // Create activity
+ $activityType = CRM_Core_OptionGroup::getValue('activity_type',
+ 'Close Accounting Period',
+ 'name'
+ );
+ $activityParams = array(
+ 'source_contact_id' => CRM_Core_Session::singleton()->get('userID'),
+ 'assignee_contact_id' => CRM_Core_Session::singleton()->get('userID'),
+ 'activity_type_id' => $activityType,
+ 'subject' => ts('Close Accounting Period'),
+ 'status_id' => CRM_Core_OptionGroup::getValue('activity_status',
+ 'Completed',
+ 'name'
+ ),
+ 'activity_date_time' => date('YmdHis'),
+ );
+ CRM_Activity_BAO_Activity::create($activityParams);
+ // Set Prior Financial Period
+ $priorFinPeriod = $params['closing_date']['M'] . '/' . $params['closing_date']['d'] . '/' . date('Y');
+ Civi::settings()->set('prior_financial_period', date('m/d/Y', strtotime($priorFinPeriod)));
+ // Set closing date
+ Civi::settings()->set('closing_date', $params['closing_date']);
+ CRM_Core_Session::setStatus(ts("Accounting Period has been closed successfully!"), ts('Success'), 'success');
+ }
+
+}
<weight>630</weight>
<component>CiviContribute</component>
</item>
+ <item>
+ <path>civicrm/admin/contribute/closeaccperiod</path>
+ <title>Close Accounting Period</title>
+ <page_callback>CRM_Contribute_Form_CloseAccPeriod</page_callback>
+ <access_arguments>access CiviContribute,administer CiviCRM,administer Accounting</access_arguments>
+ <page_type>1</page_type>
+ <weight>640</weight>
+ <component>CiviContribute</component>
+ </item>
</menu>
-- CRM-17118 extend civicrm_address postal_code to accept full data strings from paypal etc.
ALTER TABLE civicrm_address CHANGE `postal_code` `postal_code` varchar(64) ;
+-- CRM-16189
+SELECT @contributionNavId := id, @domainID := domain_id FROM civicrm_navigation WHERE name = 'Contributions';
+SELECT @navMaxWeight := MAX(ROUND(weight))+1 from civicrm_navigation WHERE parent_id = @contributionNavId;
+
+UPDATE civicrm_navigation SET has_separator = 1 WHERE name = 'Manage Price Sets' AND parent_id = @contributionNavId;
+
+INSERT INTO civicrm_navigation
+ (domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight)
+VALUES
+ (@domainID, 'civicrm/admin/contribute/closeaccperiod?reset=1', '{ts escape="sql" skip="true"}Close Accounting Period{/ts}', 'Close Accounting Period', 'access CiviContribute,administer CiviCRM,administer Accounting', 'AND', @contributionNavId, '1', NULL, @navMaxWeight);
--- /dev/null
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.7 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2016 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+*}
+
+<table class="form-layout-compressed">
+ <tr>
+ <td class="label">{$form.closing_date.label}</td>
+ <td class="content">{$form.closing_date.html}</td>
+ </tr>
+</table>
+
+<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
\ No newline at end of file
( @domainID, 'civicrm/admin/pcp?reset=1&page_type=contribute', '{ts escape="sql" skip="true"}Personal Campaign Pages{/ts}', 'Personal Campaign Pages', 'access CiviContribute,administer CiviCRM', 'AND', @contributionlastID, '1', NULL, 11 ),
( @domainID, 'civicrm/admin/contribute/managePremiums?reset=1', '{ts escape="sql" skip="true"}Premiums (Thank-you Gifts){/ts}', 'Premiums', 'access CiviContribute,administer CiviCRM', 'AND', @contributionlastID, '1', 1, 12 ),
( @domainID, 'civicrm/admin/price?reset=1&action=add', '{ts escape="sql" skip="true"}New Price Set{/ts}', 'New Price Set', 'access CiviContribute,administer CiviCRM', 'AND', @contributionlastID, '1', NULL, 13 ),
- ( @domainID, 'civicrm/admin/price?reset=1', '{ts escape="sql" skip="true"}Manage Price Sets{/ts}', 'Manage Price Sets', 'access CiviContribute,administer CiviCRM', 'AND', @contributionlastID, '1', NULL, 14 ),
+ ( @domainID, 'civicrm/admin/price?reset=1', '{ts escape="sql" skip="true"}Manage Price Sets{/ts}', 'Manage Price Sets', 'access CiviContribute,administer CiviCRM', 'AND', @contributionlastID, '1', 1, 14 ),
+ ( @domainID, 'civicrm/admin/contribute/closeaccperiod?reset=1', '{ts escape="sql" skip="true"}Close Accounting Period{/ts}', 'Close Accounting Period', 'access CiviContribute,administer CiviCRM,administer Accounting', 'AND', @contributionlastID, '1', NULL, 15 ),
( @domainID, 'civicrm/financial/batch?reset=1&action=add', '{ts escape="sql" skip="true"}New Batch{/ts}', 'New Batch', 'create manual batch', 'AND', @financialTransactionID, '1', NULL, 1 ),
( @domainID, 'civicrm/financial/financialbatches?reset=1&batchStatus=1', '{ts escape="sql" skip="true"}Open Batches{/ts}', 'Open Batches', 'view own manual batches,view all manual batches', 'OR', @financialTransactionID, '1', NULL, 2 ),