示例#1
0
function entrySetReady($entry)
{
    global $invoice_sendto, $systemurl, $login;
    if (!count($entry)) {
        echo __('No entry found.');
        return FALSE;
    }
    /*
     * Set new status
     * Set new rev_num, time of edit, etc
     */
    $rev_num = $entry['rev_num'] + 1;
    mysql_query("UPDATE `entry` SET `invoice_status` = '2', `user_last_edit` = '" . $login['user_id'] . "', `time_last_edit` = '" . time() . "', `rev_num` = '{$rev_num}' WHERE `entry_id` = '" . $entry['entry_id'] . "' LIMIT 1 ;");
    $log_data = array();
    if (!newEntryLog($entry['entry_id'], 'edit', 'invoice_readyfor', $rev_num, $log_data)) {
        echo __('Can\'t log the changes for the entry.');
        echo '<br><br>';
        return FALSE;
    }
    if (isset($invoice_sendto) && is_array($invoice_sendto)) {
        $entry_summary = 'Bookingid: ' . $entry['entry_id'] . chr(10);
        $area = getArea($entry['area_id']);
        if (count($area)) {
            foreach ($invoice_sendto as $email) {
                emailSendDirect($email, 'Booking klar til fakturering - ' . $area['area_name'] . ', ' . date('d.m.Y', $entry['time_start']) . ' (' . $entry['entry_id'] . ')', 'Hei' . chr(10) . chr(10) . $login['user_name'] . ' har satt en ny booking, fra ' . $area['area_name'] . ', klar til fakturering. Bookingen var fra ' . date('d.m.Y', $entry['time_start']) . '.' . chr(10) . chr(10) . 'Gå inn på følgende adresse for å få tilsendt fakturagrunnlagene:' . chr(10) . $systemurl . '/invoice_tobemade_ready.php' . chr(10) . 'Hvis det er flere fakturaer som er klar til fakturering, så kan samtlige hentes ut på likt.' . chr(10) . chr(10) . 'Oppsummert booking:' . chr(10) . 'Bookingid: ' . $entry['entry_id'] . chr(10) . 'Tittel: ' . html_entity_decode($entry['entry_name']) . chr(10) . 'Anlegg: ' . $area['area_name'] . chr(10) . 'Sum eks mva: kr ' . smarty_modifier_commify($entry['eks_mva_tot'], 2, ',', ' ') . chr(10) . ' + MVA kr ' . smarty_modifier_commify($entry['faktura_belop_sum_mva'], 2, ',', ' ') . chr(10) . 'Sum ink. mva: kr ' . smarty_modifier_commify($entry['faktura_belop_sum'], 2, ',', ' ') . chr(10) . chr(10) . 'Mvh. Bookingsystemet');
            }
        }
    }
    return TRUE;
}
 file_put_contents($invoice_location . $pdffile, $dompdf->output());
 // Update invoiced
 mysql_query("UPDATE `invoiced` SET `pdf_name` = '" . $pdffile . "' WHERE `invoiced_id` = '" . $invoiced_id . "' LIMIT 1 ;");
 // Send PDF in emails
 $subject = 'Fakturagrunnlag - ' . date('d.m.Y', $from) . ' til ' . date('d.m.Y', $to);
 $message_plain = 'Følgende ' . count($entries) . ' booking' . $er . ' (FROM_AREA) er med i vedlagt PDF-fil med fakturagrunnlag:' . chr(10) . chr(10);
 $areas_inpdf = array();
 foreach ($entries as $entry) {
     $message_plain .= '- (' . $entry['entry_id'] . ') ' . html_entity_decode($entry['entry_name']) . chr(10);
     $area = getArea($entry['area_id']);
     if (count($area)) {
         $message_plain .= '   ' . $area['area_name'] . chr(10);
         $areas_inpdf[$area['area_id']] = $area['area_name'];
     }
     $message_plain .= '   Sum eks mva: kr ' . smarty_modifier_commify($entry['eks_mva_tot'], 2, ',', ' ') . ' + MVA kr ' . smarty_modifier_commify($entry['faktura_belop_sum_mva'], 2, ',', ' ') . chr(10);
     $message_plain .= '   Sum ink. mva: kr ' . smarty_modifier_commify($entry['faktura_belop_sum'], 2, ',', ' ') . chr(10) . chr(10);
 }
 $message_plain .= chr(10) . 'Mvh. Bookingsystemet';
 if (count($areas_inpdf)) {
     $message_plain = str_replace('FROM_AREA', 'fra ' . implode(', ', $areas_inpdf), $message_plain);
 } else {
     $message_plain = str_replace(' (FROM_AREA)', '', $message_plain);
 }
 foreach ($invoice_sendto as $email) {
     emailSendInvoicePDF($email, $invoice_location . $pdffile, $message_plain, $subject);
     mysql_query("INSERT INTO `invoiced_emails` (`email_addr` , `invoiced_id`) VALUES ('" . $email . "', '" . $invoiced_id . "');");
 }
 mysql_query("UPDATE `invoiced` SET `emailed_time` = '" . time() . "', `emailed` = '1' WHERE `invoiced_id` = '" . $invoiced_id . "' LIMIT 1 ;");
 // Redirect back
 header('Location: ' . $redirect_forward . '?highlight=' . $invoiced_id);
 exit;
        }
        echo '<div class="area_products" id="area_products' . $R_prod['area_id'] . '">';
        if ($R_prod['area_id'] != 0) {
            echo iconHTML('house') . ' Produkter for <b>' . $area2[$R_prod['area_id']] . '</b>';
        } else {
            echo iconHTML('chart_organisation') . ' Produkter for <b>Alle anlegg</b>';
        }
        $last_area_id = $R_prod['area_id'];
        $open = true;
        echo '<table class="prettytable" style="margin: 5px; width: 650px;">' . '<tr>' . '<th style="width: 350px;">Produkt</th>' . '<th style="width: 100px;">Pris u/MVA</th>' . '<th style="width: 100px;">MVA</th>' . '<th style="width: 100px;">Pris m/MVA</th>' . '<th style="width: 40px;">&nbsp;</th>' . '</tr>';
    }
    echo '<tr id="product' . $R_prod['product_id'] . '">' . '<td ' . 'style="font-size: 1.1em; vertical-align: middle;"' . 'onclick="addFromProducts (this, \'' . $R_prod['product_name'] . '\', \'' . $R_prod['product_price'] . '\', \'' . $R_prod['product_tax'] . '\'); ' . '$(\'#products\').dialog(\'close\');"' . '>' . $R_prod['product_name'];
    if ($R_prod['product_desc'] != '') {
        echo '<br /><span style="font-size: 0.8em;"><i>' . $R_prod['product_desc'] . '</i></span>';
    }
    echo '</td>' . '<td class="rightalign" style="font-size: 1.1em; vertical-align: middle;">' . smarty_modifier_commify($R_prod['product_price'], 2, ",", "&nbsp;") . '</td>' . '<td class="rightalign" style="font-size: 1.1em; vertical-align: middle;">' . $R_prod['product_tax'] . ' %' . '</td>' . '<td class="rightalign" style="font-size: 1.1em; vertical-align: middle;">' . smarty_modifier_commify(round($R_prod['product_price'] * (100 + $R_prod['product_tax']) / 100, 2), 2, ",", "&nbsp;") . '</td>' . '<td style="text-align: center;">' . '<input type="button" style="width: 25px;" value="+" ' . 'onclick="addFromProducts (this, \'' . $R_prod['product_name'] . '\', \'' . $R_prod['product_price'] . '\', \'' . $R_prod['product_tax'] . '\'); ' . 'return false;">' . '</td>' . '</tr>';
}
if ($open) {
    echo '</table></div>';
}
echo '</div>';
echo '<script type="text/javascript">
$(\'#products\').dialog({ 
	modal: true,
	autoOpen: false,
	minHeight: 200,
	height: 400,
	minWidth: 700,
	width: 800,
//	show: \'blind\',
	open: function(event, ui) {
示例#4
0
function invoicelist_payed($Q)
{
    //$Q = mysql_query($SQL);
    if (!mysql_num_rows($Q)) {
        echo '<i>Ingen fakturaer er registert som betalt.</i>';
    } else {
        echo '<font color="red">' . mysql_num_rows($Q) . '</font> fakturaer funnet';
        echo '<br>' . chr(10) . chr(10);
        echo '<table style="border-collapse: collapse;">' . chr(10);
        echo ' <tr>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b class="hiddenprint">Vis mer</b><b class="print">Fakturaid</b></td>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>Fakturadato</b></td>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>Betalt</b></td>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>Beløp</b></td>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>Kunde</b></td>' . chr(10);
        echo '  <td style="border: 1px solid black;">&nbsp;</td>' . chr(10);
        echo ' </tr>' . chr(10);
        while ($R = mysql_fetch_assoc($Q)) {
            $invoice = new invoice($R['invoice_id']);
            $invoice->get();
            echo ' <tr>' . chr(10);
            // invoice_id
            echo '  <td style="border: 1px solid black;">';
            echo '<a href="invoice_view.php?invoice_id=' . $invoice->invoice_id . '" class="hiddenprint">' . iconHTML('coins') . ' Faktura ' . $invoice->invoice_id . '</a>';
            echo '<b class="print">' . $invoice->invoice_id . '</b>';
            echo '</td>' . chr(10);
            // time
            echo '  <td style="border: 1px solid black;">';
            echo $invoice->invoice_time2['year'] . '-' . $invoice->invoice_time2['month'] . '-' . $invoice->invoice_time2['day'];
            echo '</td>' . chr(10);
            // time_payed
            echo '  <td style="border: 1px solid black;">';
            echo nl2br($invoice->invoice_payment_time);
            echo '</td>' . chr(10);
            // sum
            echo '  <td style="border: 1px solid black;">kr&nbsp;' . smarty_modifier_commify($invoice->invoice_payed_amount, 2, ",", " ") . '</td>' . chr(10);
            // Customer
            echo '  <td style="border: 1px solid black;">';
            if ($invoice->invoice_to_customer_name != '') {
                echo '<a href="customer.php?customer_id=' . $invoice->invoice_to_customer_id . '">' . $invoice->invoice_to_customer_name . '</a>';
            } else {
                echo $invoice->invoice_to_line1;
            }
            echo '</td>' . chr(10);
            // Options
            echo '  <td style="border: 1px solid black;">';
            echo nl2br($invoice->invoice_payment_comment);
            echo '</td>' . chr(10);
            echo ' </tr>' . chr(10);
        }
        echo '</table>';
    }
}
示例#5
0
function entrylist_invoice_tobemade($SQL, $tamed_booking, $area_spesific = false)
{
    $Q = mysql_query($SQL . ' order by `time_start`');
    if (!$tamed_booking || !mysql_num_rows($Q)) {
        echo __('No entries found.');
    } else {
        echo '<font color="red">' . mysql_num_rows($Q) . '</font> ' . __('entries found.');
        echo '<br>' . chr(10) . chr(10);
        echo '<table style="border-collapse: collapse;">' . chr(10);
        echo ' <tr>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>Arrangementsdato</b></td>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>' . __('Name') . '</b></td>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>' . __('Area') . '</b></td>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>Sum</b></td>' . chr(10);
        echo '  <td style="border: 1px solid black;"><b>&nbsp;</b></td>' . chr(10);
        echo ' </tr>' . chr(10);
        while ($R = mysql_fetch_assoc($Q)) {
            $entry = getEntry($R['entry_id']);
            echo ' <tr>' . chr(10);
            // Starts
            echo '  <td style="border: 1px solid black;">';
            echo '<a href="day.php?year=' . date('Y', $entry['time_start']) . '&amp;month=' . date('m', $entry['time_start']) . '&amp;day=' . date('d', $entry['time_start']) . '&amp;area=' . $entry['area_id'] . '">' . date('d', $entry['time_start']) . '</a>-';
            echo '<a href="month.php?year=' . date('Y', $entry['time_start']) . '&amp;month=' . date('m', $entry['time_start']) . '&amp;day=' . date('d', $entry['time_start']) . '&amp;area=' . $entry['area_id'] . '">' . __(date('m', $entry['time_start'])) . '</a>-';
            echo date('Y', $entry['time_start']);
            echo '</td>' . chr(10);
            // Name
            echo '  <td style="border: 1px solid black;"><a href="entry.php?entry_id=' . $entry['entry_id'] . '">' . $entry['entry_name'] . '</a>';
            $checkInvoice = checkInvoicedata($entry);
            if (count($checkInvoice[0])) {
                echo '<br /><br /><b>Feil med fakturagrunnlag:</b><br />';
                echo '<div class="error"><ul style="padding-left: 20px; margin: 0px;">';
                foreach ($checkInvoice[0] as $error) {
                    echo '<li>' . $error . '</li>';
                }
                echo '</ul></div>';
            }
            if (count($checkInvoice[1])) {
                if (!count($checkInvoice[0])) {
                    echo '<br /><br />';
                }
                echo '<b>Advarsler p&aring; fakturagrunnlag:</b><br />';
                echo '<div class="notice"><ul style="padding-left: 20px; margin: 0px;">';
                foreach ($checkInvoice[1] as $warnings) {
                    echo '<li>' . $warnings . '</li>';
                }
                echo '</ul></div>';
            }
            echo '</td>' . chr(10);
            // Area
            echo '  <td style="border: 1px solid black;">';
            $area = getArea($entry['area_id']);
            if (count($area)) {
                echo $area['area_name'];
            }
            echo '</td>' . chr(10);
            // Invoice
            echo '  <td style="border: 1px solid black; text-align: right;">kr&nbsp;' . smarty_modifier_commify($entry['faktura_belop_sum'], 2, ",", "&nbsp;") . '</td>' . chr(10);
            // Set ready
            echo '  <td style="border: 1px solid black;">';
            echo '<a href="invoice_setready.php?entry_id=' . $entry['entry_id'];
            if ($area_spesific) {
                echo '&amp;return=invoice_tobemade_area';
            } else {
                echo '&amp;return=invoice_tobemade';
            }
            echo '">' . 'Sett&nbsp;faktureringsklar&nbsp;';
            if (count($checkInvoice[0])) {
                // Errors
                echo iconHTML('arrow_right_red');
            } elseif (count($checkInvoice[1])) {
                // Warnings
                echo iconHTML('arrow_right_yellow');
            } else {
                // None
                echo iconHTML('arrow_right');
            }
            echo '</a>';
            echo '</td>' . chr(10);
            echo ' </tr>' . chr(10);
        }
        echo '</table>';
    }
}