// can't delete it there are productions or issues if (work_order_has_productions($selected_id) || work_order_has_issues($selected_id) || work_order_has_payments($selected_id)) { display_error(_("This work order cannot be deleted because it has already been processed.")); $cancel_delete = true; } if ($cancel_delete == false) { //ie not cancelled the delete as a result of above tests // delete the actual work order delete_work_order($selected_id); meta_forward($_SERVER['PHP_SELF'], "DeletedID={$selected_id}"); } } //------------------------------------------------------------------------------------- if (isset($_POST['close'])) { // update the closed flag in the work order close_work_order($selected_id); meta_forward($_SERVER['PHP_SELF'], "ClosedID={$selected_id}"); } //------------------------------------------------------------------------------------- if (get_post('_type_update')) { $Ajax->activate('_page_body'); } //------------------------------------------------------------------------------------- start_form(); start_table(TABLESTYLE2); $existing_comments = ""; $dec = 0; if (isset($selected_id)) { $myrow = get_work_order($selected_id); if (strlen($myrow[0]) == 0) { echo _("The order number sent is not valid.");
} // Close without invoice if (isset($VAR["closewithoutinvoice"])) { if (!close_work_order_no_invoice($db, $VAR)) { force_page('workorder', "view&wo_id={$wo_id}&error_msg=Failed to Close Work Order.&page_title=Work Order ID {$wo_id}"); } else { $q = "SELECT CUSTOMER_ID FROM " . PRFX . "TABLE_WORK_ORDER WHERE WORK_ORDER_ID=" . $db->qstr($wo_id); if (!($rs = $db->execute($q))) { force_page('core', 'error&error_msg=MySQL Error: ' . $db->ErrorMsg() . '&menu=1&type=database'); exit; } force_page('workorder', "main&page_title=Work Orders"); } } // Close with invoice if (isset($VAR["closewithinvoice"])) { if (!close_work_order($db, $VAR)) { force_page('workorder', "view&wo_id={$wo_id}&error_msg=Failed to Close Work Order.&page_title=Work Order ID {$wo_id}"); } else { $q = "SELECT CUSTOMER_ID FROM " . PRFX . "TABLE_WORK_ORDER WHERE WORK_ORDER_ID=" . $db->qstr($wo_id); if (!($rs = $db->execute($q))) { force_page('core', 'error&error_msg=MySQL Error: ' . $db->ErrorMsg() . '&menu=1&type=database'); exit; } $customer_id = $rs->fields['CUSTOMER_ID']; force_page('invoice', 'new&wo_id=' . $wo_id . '&customer_id=' . $customer_id . '&page_title=Create Invoice for Work Order# wo_id=' . $wo_id); } } else { $smarty->assign('wo_id', $VAR['wo_id']); $smarty->display('workorder' . SEP . 'close.tpl'); }