- $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;
+ if (isset($_GET['NewQuoteToSalesOrder']))
+ {
+ $trans_no = $_GET['NewQuoteToSalesOrder'];
+ $doc = new Cart(ST_SALESQUOTE, $trans_no);
+ $doc->trans_no = 0;
+ $doc->trans_type = ST_SALESORDER;
+ $doc->reference = $Refs->get_next($doc->trans_type);
+ $doc->document_date = $doc->due_date = new_doc_date();
+ $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;