New function to format small and short dates

This commit is contained in:
Manuel Cillero 2017-09-17 08:14:59 +02:00
parent e2d79c1bb4
commit ce5f89b38f
18 changed files with 119 additions and 118 deletions

View file

@ -5,35 +5,43 @@
* (creating invoices based on other SuiteDesk nodes)
*/
function storminvoice_auto_add($node, $invoice = NULL) {
$type = $node->type;
switch ($node->type) {
case 'stormorganization':
$type = 'organization';
$invoice_nid = stormorganization_storminvoice_auto_add($node, $invoice);
break;
case 'stormproject':
$type = 'project';
$invoice_nid = stormproject_storminvoice_auto_add($node, $invoice);
break;
case 'stormtask':
$type = 'task';
$invoice_nid = stormtask_storminvoice_auto_add($node, $invoice);
break;
case 'stormticket':
$type = 'ticket';
$invoice_nid = stormticket_storminvoice_auto_add($node, $invoice);
break;
case 'stormtimetracking':
$type = 'timetracking';
$invoice_nid = stormtimetracking_storminvoice_auto_add($node, $invoice);
break;
case 'stormexpense':
$type = 'expense';
$invoice_nid = stormexpense_storminvoice_auto_add($node, $invoice);
break;
default:
drupal_set_message(t('This type of node cannot be automatically added to an invoice'), 'error');
drupal_set_message(t('This type of content cannot be automatically added to an invoice.'), 'error');
// watchdog - add link to record error in more detail?
drupal_goto('node/'. $node->nid);
}
if ($invoice) {
drupal_set_message(t('The @type has been added to the selected invoice.', array('@type' => $node->type)));
drupal_set_message(t('The @type has been added to the selected invoice.', array('@type' => t($type))));
}
else {
drupal_set_message(t('This invoice was created automatically from the selected @type.', array('@type' => $node->type)));
drupal_set_message(t('This invoice was created automatically from the selected @type.', array('@type' => t($type))));
}
drupal_goto('node/'. $invoice_nid);
}
@ -42,7 +50,7 @@ function storminvoice_auto_add_select() {
$form['node'] = array(
'#title' => t('Node'),
'#type' => 'hidden',
'#value' => arg(4),
'#value' => arg(3),
);
$form['invoice'] = array(
@ -54,7 +62,7 @@ function storminvoice_auto_add_select() {
// THIS CODE LOADS OPTIONS INTO THE INVOICE SELECTOR
// Load the node object, but don't know how to handle it yet because it could be a node of several types.
$node = node_load(arg(4));
$node = node_load(arg(3));
/* This function does not know the type of node that is being billed for. To avoid recording all relationships between the SuiteDesk nodes,
* we simply check for the existance of a parent node (perhaps project, task, ticket etc). Organization will always be set.
* The invoices we show in the list are those that match these parents or where these attributes are not set.