Commit ede692eb authored by jaapjansma's avatar jaapjansma
Browse files

update

parent c1a78e7e
Version 1.0.4
-------------
* Added edit expense link to the data processor
* Added documentation
Version 1.0.3
-------------
......
......@@ -46,7 +46,7 @@ class CRM_Expenses_Form_Search extends CRM_Core_Form {
$this->add('text', 'description_val', E::ts('Description'), array('class' => 'huge'));
$this->add('select', "description_op", E::ts('Operator:'), $textOperators, true, [
'style' => 'min-width: 50px;',
'class' => 'crm-select2 medium',
'class' => 'crm-select2 medium search_op',
'multiple' => FALSE,
'placeholder' => E::ts('- select -'),
]);
......@@ -54,7 +54,7 @@ class CRM_Expenses_Form_Search extends CRM_Core_Form {
$this->addEntityRef('contact_id_val', E::ts('Contact'), ['create' => false, 'multiple' => true], false, array('class' => 'huge'));
$this->add('select', "contact_id_op", E::ts('Operator:'), $entityRefOperators, true, [
'style' => 'min-width: 50px;',
'class' => 'crm-select2 medium',
'class' => 'crm-select2 medium search_op',
'multiple' => FALSE,
'placeholder' => E::ts('- select -'),
]);
......@@ -62,7 +62,7 @@ class CRM_Expenses_Form_Search extends CRM_Core_Form {
$this->addEntityRef('assignee_contact_id_val', E::ts('Assignee'), ['create' => false, 'multiple' => true], false, array('class' => 'huge'));
$this->add('select', "assignee_contact_id_op", E::ts('Operator:'), $entityRefOperators, true, [
'style' => 'min-width: 50px;',
'class' => 'crm-select2 medium',
'class' => 'crm-select2 medium search_op',
'multiple' => FALSE,
'placeholder' => E::ts('- select -'),
]);
......@@ -70,7 +70,7 @@ class CRM_Expenses_Form_Search extends CRM_Core_Form {
$this->addEntityRef('case_id_val', E::ts('Case'), ['create' => false, 'multiple' => true], false, array('class' => 'huge'));
$this->add('select', "case_id_op", E::ts('Operator:'), $entityRefOperators, true, [
'style' => 'min-width: 50px;',
'class' => 'crm-select2 medium',
'class' => 'crm-select2 medium search_op',
'multiple' => FALSE,
'placeholder' => E::ts('- select -'),
]);
......@@ -79,7 +79,7 @@ class CRM_Expenses_Form_Search extends CRM_Core_Form {
$this->add('select', 'status_id_val', E::ts('Status'), $statuses, FALSE, ['class' => 'huge crm-select2', 'multiple' => true]);
$this->add('select', "status_id_op", E::ts('Operator:'), $selectOperators, true, [
'style' => 'min-width: 50px;',
'class' => 'crm-select2 medium',
'class' => 'crm-select2 medium search_op',
'multiple' => FALSE,
'placeholder' => E::ts('- select -'),
]);
......
......@@ -179,7 +179,7 @@ class CRM_Expenses_Utils_Search {
if ($from && $to) {
$from = substr($from, 0, 4). '-'.substr($from, 4, 2).'-'.substr($from, 6, 2);
$to = substr($to, 0, 4). '-'.substr($to, 4, 2).'-'.substr($to, 6, 2);
return "(DATE(`{$tableName}`.`{$fieldName}`) >= DATE ('{$from}') AND (DATE(`{$tableName}`.`{$fieldName}`) <= DATE ('{$to}'))";
return "(DATE(`{$tableName}`.`{$fieldName}`) >= DATE ('{$from}')) AND (DATE(`{$tableName}`.`{$fieldName}`) <= DATE ('{$to}'))";
} elseif ($from) {
$from = substr($from, 0, 4). '-'.substr($from, 4, 2).'-'.substr($from, 6, 2);
return "(DATE(`{$tableName}`.`{$fieldName}`) >= DATE ('{$from}'))";
......@@ -243,8 +243,10 @@ class CRM_Expenses_Utils_Search {
break;
case 'current_user':
$op = '=';
$requiresValue = false;
$requiresValue = true;
$value = CRM_Core_Session::getLoggedInContactID();
$escapedValue = CRM_Core_Session::getLoggedInContactID();
$doEscape = false;
break;
}
if ($requiresValue && !empty($value)) {
......
......@@ -29,6 +29,11 @@ class Expenses implements CompilerPassInterface {
'Civi\DataProcessor\Source\Expenses\ExpenseLineSource',
E::ts('Expense Line'),
]);
$factoryDefinition->addMethodCall('addOutputHandler', [
'edit_expense',
'Civi\DataProcessor\FieldOutputHandler\Expenses\EditExpenseLineFieldOutputHandler',
E::ts('Edit Expense Link'),
]);
}
if ($container->hasDefinition('action_provider')) {
......
<?php
/**
* @author Jaap Jansma <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
namespace Civi\DataProcessor\FieldOutputHandler\Expenses;
use Civi\DataProcessor\FieldOutputHandler\AbstractSimpleFieldOutputHandler;
use Civi\DataProcessor\FieldOutputHandler\HTMLFieldOutput;
use CRM_Expenses_ExtensionUtil as E;
class EditExpenseLineFieldOutputHandler extends AbstractSimpleFieldOutputHandler {
/**
* Returns the formatted value
*
* @param $rawRecord
* @param $formattedRecord
*
* @return \Civi\DataProcessor\FieldOutputHandler\FieldOutput
*/
public function formatField($rawRecord, $formattedRecord) {
$id = $rawRecord[$this->inputFieldSpec->alias];
$url = \CRM_Utils_System::url('civicrm/expense/form', ['id' => $id, 'action' => 'update']);
$link = '<a href="'.$url.'"><i class="crm-i fa-pencil">&nbsp;</i>'.E::ts("Edit Expense").'</a>';
$formattedValue = new HTMLFieldOutput($url);
$formattedValue->formattedValue = $url;
$formattedValue->setHtmlOutput($link);
return $formattedValue;
}
/**
* Returns the label of the field for selecting a field.
*
* This could be override in a child class.
*
* @return string
*/
protected function getFieldTitle() {
return E::ts('Expense ID Field');
}
}
......@@ -7,6 +7,12 @@ An expense exist of one or more line(s) and you can add attachments to an expens
You can even add your own custom fields to an expense or an expense line.
![Screenshot](images/screenshot.png)
![Screenshot](docs/images/screenshot1.png)
# Documentation
Documentation is available at [docs/introduction.md](docs/introduction.md)
# License
The extension is licensed under [AGPL-3.0](LICENSE.txt).
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment