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')) { ...@@ -5,7 +5,7 @@ if (!defined('W2P_BASE_DIR')) {
$del = w2PgetParam($_POST, 'del', 0); $del = w2PgetParam($_POST, 'del', 0);
$stat = w2PgetParam($_POST,'stat', -1); $stat = w2PgetParam($_POST,'stat', -1);
$tag = w2PgetParam($_POST, 'tag', -1); $tag = w2PgetParam($_POST, 'tag', null);
$obj = new CInvoice(); $obj = new CInvoice();
if (!$obj->bind( $_POST )) { if (!$obj->bind( $_POST )) {
...@@ -13,6 +13,8 @@ if (!$obj->bind( $_POST )) { ...@@ -13,6 +13,8 @@ if (!$obj->bind( $_POST )) {
$AppUI->redirect(); $AppUI->redirect();
} }
$obj->task_invoice = $_POST["task_invoice"]; $obj->task_invoice = $_POST["task_invoice"];
//$obj->invoice_tag = $_POST["invoice_tag"];
//$obj->$invoice_status = $_POST['$invoice_status'];
$AppUI->setMsg( 'Invoice' ); $AppUI->setMsg( 'Invoice' );
$msg = "m=invoice"; $msg = "m=invoice";
...@@ -23,21 +25,8 @@ if ($del) { ...@@ -23,21 +25,8 @@ if ($del) {
$AppUI->setMsg( "Invoice deleted", UI_MSG_ALERT ); $AppUI->setMsg( "Invoice deleted", UI_MSG_ALERT );
} }
$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;
} 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 { } else {
$isNotNew = ($obj->task_invoice != 0);
while(list($key,$value)=each($_POST)) { while(list($key,$value)=each($_POST)) {
$tmparr=split("_",$key); $tmparr=split("_",$key);
if ($tmparr[0] == "num") { if ($tmparr[0] == "num") {
...@@ -49,7 +38,20 @@ if ($del) { ...@@ -49,7 +38,20 @@ 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 ); $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;
} }
......
...@@ -17,7 +17,7 @@ class CInvoice extends w2p_Core_BaseObject { ...@@ -17,7 +17,7 @@ class CInvoice extends w2p_Core_BaseObject {
public $invoice_creator = null; public $invoice_creator = null;
// table 'invoice_task_queue' // table 'invoice_task_queue'
public $invoice_task_queue_id = null; public $task_queue_id = null;
public $task_invoice = null; public $task_invoice = null;
public $task_log_id = null; public $task_log_id = null;
public $task_amount = null; public $task_amount = null;
...@@ -91,7 +91,7 @@ class CInvoice extends w2p_Core_BaseObject { ...@@ -91,7 +91,7 @@ class CInvoice extends w2p_Core_BaseObject {
$this->clearErrors(); $this->clearErrors();
$q = $this->_getQuery(); $q = $this->_getQuery();
$q->setDelete('invoice_task_queue'); $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()) { if (!$q->exec()) {
$this->_error['delete-invoice'] = db_error(); $this->_error['delete-invoice'] = db_error();
return false; 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