function create_recurrent_invoices($customer_id, $branch_id, $order_no, $tmpl_no, $date, $from, $to)
{
    global $Refs;
    $doc = new Cart(ST_SALESORDER, array($order_no));
    get_customer_details_to_order($doc, $customer_id, $branch_id);
    $doc->trans_type = ST_SALESORDER;
    $doc->trans_no = 0;
    $doc->document_date = $date;
    $doc->due_date = get_invoice_duedate($doc->payment, $doc->document_date);
    $doc->reference = $Refs->get_next($doc->trans_type);
    if ($doc->Comments != "") {
        $doc->Comments .= "\n";
    }
    $doc->Comments .= sprintf(_("Recurrent Invoice covers period %s - %s."), $from, add_days($to, -1));
    foreach ($doc->line_items as $line_no => $item) {
        $line =& $doc->line_items[$line_no];
        $line->price = get_price($line->stock_id, $doc->customer_currency, $doc->sales_type, $doc->price_factor, $doc->document_date);
    }
    $cart = $doc;
    $cart->trans_type = ST_SALESINVOICE;
    $cart->reference = $Refs->get_next($cart->trans_type);
    $invno = $cart->write(1);
    if ($invno == -1) {
        display_error(_("The entered reference is already in use."));
        display_footer_exit();
    }
    update_last_sent_recurrent_invoice($tmpl_no, $to);
    return $invno;
}
shippers_list_cells(null, 'ship_via', $_POST['ship_via']);
// set this up here cuz it's used to calc qoh
if (!isset($_POST['DispatchDate']) || !is_date($_POST['DispatchDate'])) {
    $_POST['DispatchDate'] = new_doc_date();
    if (!is_date_in_fiscalyear($_POST['DispatchDate'])) {
        $_POST['DispatchDate'] = end_fiscalyear();
    }
}
date_cells(_("Date"), 'DispatchDate', '', $_SESSION['Items']->trans_no == 0, 0, 0, 0, "class='tableheader2'");
end_row();
end_table();
echo "</td><td>";
// outer table
start_table(TABLESTYLE, "width=90%");
if (!isset($_POST['due_date']) || !is_date($_POST['due_date'])) {
    $_POST['due_date'] = get_invoice_duedate($_SESSION['Items']->payment, $_POST['DispatchDate']);
}
text_cells(_("Delivery #"), 'custom_num', '', null, "class='tableheader2'");
//moodlearning
customer_credit_row($_SESSION['Items']->customer_id, $_SESSION['Items']->credit, "class='tableheader2'");
// 2010-09-03 Joe Hunt
$dim = get_company_pref('use_dimension');
if ($dim > 0) {
    start_row();
    label_cell(_("Dimension") . ":", "class='tableheader2'");
    dimensions_list_cells(null, 'dimension_id', null, true, ' ', false, 1, false);
    end_row();
} else {
    hidden('dimension_id', 0);
}
if ($dim > 1) {
function create_cart($type, $trans_no)
{
    global $Refs;
    if (!$_SESSION['SysPrefs']->db_ok) {
        // create_cart is called before page() where the check is done
        return;
    }
    processing_start();
    if (isset($_GET['NewQuoteToSalesOrder'])) {
        $trans_no = $_GET['NewQuoteToSalesOrder'];
        $doc = new Cart(ST_SALESQUOTE, $trans_no, true);
        $doc->Comments = _("Sales Quotation") . " # " . $trans_no;
        $_SESSION['Items'] = $doc;
    } elseif ($type != ST_SALESORDER && $type != ST_SALESQUOTE && $trans_no != 0) {
        // this is template
        $doc = new Cart(ST_SALESORDER, array($trans_no));
        $doc->trans_type = $type;
        $doc->trans_no = 0;
        $doc->document_date = new_doc_date();
        if ($type == ST_SALESINVOICE) {
            $doc->due_date = get_invoice_duedate($doc->payment, $doc->document_date);
            $doc->pos = get_sales_point(user_pos());
        } else {
            $doc->due_date = $doc->document_date;
        }
        $doc->reference = $Refs->get_next($doc->trans_type);
        //$doc->Comments='';
        foreach ($doc->line_items as $line_no => $line) {
            $doc->line_items[$line_no]->qty_done = 0;
        }
        $_SESSION['Items'] = $doc;
    } else {
        $_SESSION['Items'] = new Cart($type, array($trans_no));
    }
    copy_from_cart();
}
Beispiel #4
0
function create_cart($type, $trans_no)
{
    processing_start();
    $doc_type = $type;
    if ($type != 30 && $trans_no != 0) {
        // this is template
        $doc_type = 30;
        $doc = new Cart(30, array($trans_no));
        $doc->trans_type = $type;
        $doc->trans_no = 0;
        if ($type == 10) {
            $doc->due_date = get_invoice_duedate($doc->customer_id, $doc->document_date);
        } else {
            $doc->due_date = $doc->document_date = Today();
        }
        $doc->reference = references::get_next($doc->trans_type);
        $doc->Comments = '';
        foreach ($doc->line_items as $line_no => $line) {
            $doc->line_items[$line_no]->qty_done = 0;
        }
        $_SESSION['Items'] = $doc;
    } else {
        $_SESSION['Items'] = new Cart($type, array($trans_no));
    }
    copy_from_cart();
}
Beispiel #5
0
shippers_list_cells(null, 'ship_via', $_POST['ship_via']);
// set this up here cuz it's used to calc qoh
if (!isset($_POST['DispatchDate']) || !is_date($_POST['DispatchDate'])) {
    $_POST['DispatchDate'] = Today();
    if (!is_date_in_fiscalyear($_POST['DispatchDate'])) {
        $_POST['DispatchDate'] = end_fiscalyear();
    }
}
date_cells(tr("Date"), 'DispatchDate', $_POST['DispatchDate'], 0, 0, 0, "class='tableheader2'");
end_row();
end_table();
echo "</td><td>";
// outer table
start_table("{$table_style} width=90%");
if (!isset($_POST['due_date']) || !is_date($_POST['due_date'])) {
    $_POST['due_date'] = get_invoice_duedate($_SESSION['Items']->customer_id, $_POST['DispatchDate']);
}
date_row(tr("Invoice Dead-line"), 'due_date', $_POST['due_date'], 0, 0, 0, "class='tableheader2'");
end_table();
echo "</td></tr>";
end_table(1);
// outer table
display_heading(tr("Delivery Items"));
start_table("{$table_style} width=80%");
$th = array(tr("Item Code"), tr("Item Description"), tr("Date"), tr("Description"), tr("Ordered"), tr("Units"), tr("Delivered"), tr("This Delivery"), tr("Price"), tr("Tax Type"), tr("Discount"), tr("Total"));
table_header($th);
$k = 0;
$has_marked = false;
$show_qoh = true;
foreach ($_SESSION['Items']->line_items as $line => $ln_itm) {
    if ($ln_itm->quantity == $ln_itm->qty_done) {