Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions modules/bank/view/tabbankaccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,32 @@ function generate_kontoliste($conf) {
printf("var data = %s", json_encode($_lib['form3']->accountplan_number_menu3($conf)));

echo "
color = '';
text = 'Velg konto';
if (selected == 0) {
color = '';
value_found = true;
text = 'Velg konto';
} else {
color = 'red';
value_found = false;
text = 'Konto finnes ikke: ' + selected;;
}

for(var i = 0; i < data.length; i++) {
if(data[i][0] == selected) {
color = data[i][1];
text = data[i][2];
value_found = true;
break;
}
}
// if value is not found, uncheck the auto checkbox
if (!value_found) {
auto_checkbox_id_array = name.split('.');
auto_checkbox_id_array[1] = 'AutoResultAccount';
auto_checkbox_id = auto_checkbox_id_array.join('.');
auto_checkbox = document.getElementById(auto_checkbox_id);
auto_checkbox.checked = false;
}

/* setter inn valgt element */
/* 0: value, 2: color, 3: text */
Expand Down
15 changes: 12 additions & 3 deletions modules/journal/view/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,16 @@
?>

<? print exchange::getCurrenciesInJS(); ?>

<?
$messages = $_lib['message']->get();
if (!$voucher_input->new && $messages) {
?>
<div class="warning">
<?= $messages ?>
</div>
<?
}
?>
<form class="voucher" name="find_customer" action="<? print $MY_SELF ?>" method="post">
Kunde/Org-nummer
<? print $_lib['form3']->hidden(array('name' => 'type' , 'value' => $voucher_input->type)) ?>
Expand Down Expand Up @@ -431,7 +440,7 @@
?>
</td>

<td><input class="voucher" type="text" size="20" maxlength="25" tabindex="<? if($rowCount>1) { print ''; } else { print $tabindex++; } ?>" accesskey="F" name="voucher.DueDate" value="<? if ($voucherHead->DueDate != "") print $voucherHead->DueDate; ?>" <? if(!$period_open) print "disabled='disabled'"; ?>></td>
<td><input class="voucher" type="text" size="20" maxlength="25" tabindex="<? if($rowCount>1) { print ''; } else { print $tabindex++; } ?>" onchange="enableOrDisable(validDate(this.value), 'save_button_<?= $voucherHead->VoucherID ?>');" accesskey="F" name="voucher.DueDate" value="<? if ($voucherHead->DueDate != "") print $voucherHead->DueDate; ?>" <? if(!$period_open) print "disabled='disabled'"; ?>></td>

<td><input class="voucher" type="text" size="20" maxlength="25" tabindex="<? if($rowCount>1) { print ''; } else { print $tabindex++; } ?>" accesskey="R" name="voucher.InvoiceID" value="<? print $voucher_input->InvoiceID ?>" <? if(!$period_open) print "disabled='disabled'"; ?>></td>
<td><input class="voucher match_checkbox" type="checkbox" name="voucher.matched_by" value="invoice" onclick="changeMatchBy(this);" <? if ($voucherHead->matched_by == 'invoice') print 'checked' ?> <? if(!$period_open) print "disabled='disabled'"; ?>></td>
Expand Down Expand Up @@ -647,7 +656,7 @@
}
?>
</td>
<td><input class="voucher" type="text" size="20" tabindex="<? print $tabindex++; ?>" name="voucher.DueDate" accesskey="F" value="<? if ($voucherHead->DueDate != "") print $voucherHead->DueDate; else print $voucher_input->DueDate; ?>" <? if(!$period_open) print "disabled='disabled'"; ?>></td>
<td><input class="voucher" type="text" size="20" tabindex="<? print $tabindex++; ?>" name="voucher.DueDate" onchange="enableOrDisable(validDate(this.value), 'save_button_<?= $voucher->VoucherID ?>');" accesskey="F" value="<? if ($voucherHead->DueDate != "") print $voucherHead->DueDate; else print $voucher_input->DueDate; ?>" <? if(!$period_open) print "disabled='disabled'"; ?>></td>

<td><input class="voucher" type="text" size="20" maxlength="25" tabindex="<? print $tabindex++; ?>" name="voucher.InvoiceID" accesskey="R" value="<? print $voucher->InvoiceID ?>" <? if(!$period_open) print "disabled='disabled'"; ?>></td>
<td><input class="voucher match_checkbox" type="checkbox" name="voucher.matched_by" value="invoice" onclick="changeMatchBy(this);" <? if ($voucher->matched_by == 'invoice') print 'checked' ?> <? if(!$period_open) print "disabled='disabled'"; ?>></td>
Expand Down
12 changes: 12 additions & 0 deletions modules/journal/view/record.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<?

// recieves date as string 'YYYY-MM-DD' and returns bool if date is valid
function validDate($date) {
$d = DateTime::createFromFormat('Y-m-d', $date);
return $d && $d->format('Y-m-d') === $date;
}

$db_table = "voucher";

/*$VoucherType = $_REQUEST['VoucherType'];
Expand All @@ -11,6 +18,11 @@ $voucher_input = new framework_logic_voucherinput($_REQUEST);
$voucher_input->KID = trim($voucher_input->KID);
$voucher_input->InvoiceID = trim($voucher_input->InvoiceID);

if ((!empty($_REQUEST['voucher_VoucherDate']) && !validDate($_REQUEST['voucher_VoucherDate']))) {
$voucher_input->VoucherDate = '';
$_lib['message']->add("Ugyldig fakturadato " . $_REQUEST['voucher_VoucherDate'] . "!");
}

// if the valuta(either currency_id or exchange_rate) has changed for the voucher we are saving, then we update foreign currency for the whole journal
global $_lib;
$result = $_lib['db']->db_query('SELECT * FROM voucher WHERE JournalID = ' . $voucher_input->JournalID . ' LIMIT 1');
Expand Down
6 changes: 3 additions & 3 deletions modules/voucher/model/vouchergui.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ function update_journal_button_line($voucher, $VoucherPeriod, $JournalID, $Vouch
$html .= $_lib['form3']->button(array('url' => "$MY_SELF&amp;voucher.VoucherPeriod=$voucher->VoucherPeriod&amp;voucher.VoucherDate=$voucher->VoucherDate&amp;voucher.JournalID=$JournalID&amp;voucher.VoucherID=$voucher->VoucherID&amp;VoucherType=$VoucherType&amp;type=$type&amp;action_voucher_delete=1&amp;view_mvalines=$view_mvalines&amp;view_linedetails=$view_linedetails", 'name'=>'<img src="/lib/icons/trash.gif">', 'confirm' => 'Vil du virkelig slette linjen?'));
}
if($button == 'update') {
$html .= '<input type="submit" name="action_voucher_update" value="Lagre" class="green" tabindex="' . $tabindex++ . '" accesskey="S" >';
$html .= '<input type="submit" id="save_button_' . $voucher->VoucherID . '" name="action_voucher_update" value="Lagre" class="green" tabindex="' . $tabindex++ . '" accesskey="S" >';
}
}
}
Expand Down Expand Up @@ -293,7 +293,7 @@ function update_journal_button_head($voucherHead, $VoucherPeriod, $VoucherType,
if($new)
{
if($button = 'update') {
$html .= '<input type="submit" name="action_voucher_new" value="Lagre" class="green" tabindex="';
$html .= '<input type="submit" id="save_button_' . $voucherHead->VoucherID . '" name="action_voucher_new" value="Lagre" class="green" tabindex="';
if($rowCount>1) {
$html .= '';
} else {
Expand All @@ -308,7 +308,7 @@ function update_journal_button_head($voucherHead, $VoucherPeriod, $VoucherType,
$html .= $_lib['form3']->button(array('url' => "$MY_SELF&amp;voucher.VoucherPeriod=$VoucherPeriod&amp;voucher.VoucherDate=$voucherHead->VoucherDate&amp;voucher.JournalID=$JournalID&amp;VoucherType=$VoucherType&amp;type=$type&amp;action_voucher_head_delete=1", 'name'=>'<img src="/lib/icons/trash.gif">', 'confirm' => 'Vil du virkelig slette bilaget?'));
}
if($button == 'update') {
$html .= '<input type="submit" name="action_voucher_head_update" value="Lagre" class="green" tabindex="';
$html .= '<input type="submit" id="save_button_' . $voucherHead->VoucherID . '" name="action_voucher_head_update" value="Lagre" class="green" tabindex="';
if($rowCount>1) {
$html .= '';
} else {
Expand Down