Commit 5b7411cb authored by Jean-Paul Saman's avatar Jean-Paul Saman

Fix creating new invoices

parent 7b6c779a
......@@ -5,7 +5,7 @@ if (!defined('W2P_BASE_DIR')) {
$del = w2PgetParam($_POST, 'del', 0);
$stat = w2PgetParam($_POST,'stat', -1);
$tag = w2PgetParam($_POST, 'tag', -1);
$tag = w2PgetParam($_POST, 'tag', null);
$obj = new CInvoice();
if (!$obj->bind( $_POST )) {
......@@ -13,6 +13,8 @@ if (!$obj->bind( $_POST )) {
$AppUI->redirect();
}
$obj->task_invoice = $_POST["task_invoice"];
//$obj->invoice_tag = $_POST["invoice_tag"];
//$obj->$invoice_status = $_POST['$invoice_status'];
$AppUI->setMsg( 'Invoice' );
$msg = "m=invoice";
......@@ -23,21 +25,8 @@ if ($del) {
$AppUI->setMsg( "Invoice deleted", UI_MSG_ALERT );
}
$msg = "m=invoice&a=addedit&invoice_id=".$obj->task_invoice."&project_id=".$obj->invoice_project;
} else if ($stat != -1 && $obj->task_invoice != 0) {
if (!$obj->change_status($stat)) {
$AppUI->setMsg( 'Invoice status change failed', UI_MSG_ERROR );
} else {
$AppUI->setMsg( "Invoice status updated", UI_MSG_ALERT );
}
$msg = "m=invoice&a=addedit&invoice_id=".$obj->task_invoice."&project_id=".$obj->invoice_project;
} else if ($tag != '' && $obj->task_invoice != 0) {
if (!$obj->change_invoice_tag($tag)) {
$AppUI->setMsg( "Invoice tag change failed", UI_MSG_ERROR );
} else {
$AppUI->setMsg( "Invoice tag updated ". $tag, UI_MSG_ALERT );
}
$msg = "m=invoice&a=addedit&invoice_id=".$obj->task_invoice."&project_id=".$obj->invoice_project;
} else {
$isNotNew = ($obj->task_invoice != 0);
while(list($key,$value)=each($_POST)) {
$tmparr=split("_",$key);
if ($tmparr[0] == "num") {
......@@ -49,9 +38,22 @@ if ($del) {
}
}
}
$isNotNew = $obj->task_queue_id;
if ($stat != -1) {
if (!$obj->change_status($stat)) {
$AppUI->setMsg( 'Invoice status change failed', UI_MSG_ERROR );
} else {
$AppUI->setMsg( "Invoice status updated", UI_MSG_ALERT );
}
}
if ($tag) {
if (!$obj->change_invoice_tag($tag)) {
$AppUI->setMsg( "Invoice tag change failed", UI_MSG_ERROR );
} else {
$AppUI->setMsg( "Invoice tag updated", UI_MSG_ALERT );
}
}
$AppUI->setMsg( $isNotNew ? 'Invoice updated' : 'Invoice inserted', UI_MSG_OK );
$msg = "m=invoice&a=addedit&invoice_id=".$obj->task_invoice."&project_id=".$obj->invoice_project;
$msg = "m=invoice&a=addedit&invoice_id=".$obj->task_invoice."&project_id=".$obj->invoice_project;
}
$AppUI->redirect($msg);
?>
......@@ -17,7 +17,7 @@ class CInvoice extends w2p_Core_BaseObject {
public $invoice_creator = null;
// table 'invoice_task_queue'
public $invoice_task_queue_id = null;
public $task_queue_id = null;
public $task_invoice = null;
public $task_log_id = null;
public $task_amount = null;
......@@ -91,7 +91,7 @@ class CInvoice extends w2p_Core_BaseObject {
$this->clearErrors();
$q = $this->_getQuery();
$q->setDelete('invoice_task_queue');
$q->addWhere('task_queue_id = ' . $this->_task_queue_id);
$q->addWhere('task_queue_id = ' . $this->task_queue_id);
if (!$q->exec()) {
$this->_error['delete-invoice'] = db_error();
return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment