Ejemplo n.º 1
0
	function addCustomLines($custom_lines){
		if(!is_array($custom_lines) || count($custom_lines) <= 0){
			return TRUE;
		}

		$lines = array();
		foreach($custom_lines as $new_line){
			if(!isset($new_line['item_code_id']) || $new_line['item_code_id'] <= 0 || !isset($new_line['quantity']) || !isset($new_line['description']) || !isset($new_line['price']))
				continue;
				
			if($new_line['quantity'] <= 0)
				continue;
			
			$il = new SI_InvoiceLine();
			$il->invoice_id = $this->id;
			$il->item_code_id = $new_line['item_code_id'];
			$il->quantity = $new_line['quantity'];
			$il->unit_price = floatval($new_line['price']);
			$il->description = $new_line['description'];
			$il->addTax();
			$lines[] = $il;
		}

		if(!$this->_lines)
			$this->_lines = array();
			
		foreach($lines as $line){
			if($line->add() === FALSE){
				$this->error = "SI_Invoice::addCustomLines(): Error adding line item: ".$line->getLastError();
				return FALSE;
			}
			$this->_lines[] = $line;
		}

		return TRUE;
	}
Ejemplo n.º 2
0
	function get($id = NULL){
		global $db_conn;

		if(!isset($id)){
			$id = $this->id;
		}

		if(!isset($id)){
			$this->error = "SI_InvoiceLine::get() : InvoiceLine id not set\n";
			return FALSE;
		}

		$InvoiceLine = SI_InvoiceLine::retrieveSet("WHERE id = $id", TRUE);
		if($InvoiceLine === FALSE){
			return FALSE;
		}

		if(isset($InvoiceLine[0])){
			$this->updateFromAssocArray($InvoiceLine[0]);
			if($this->_populateLinks() === FALSE)
				return FALSE;
			$this->stripSlashes();
		}else{
			$this->error = "SI_InvoiceLine::get() : No data retrieved from query\n";
			return FALSE;
		}
		return TRUE;
	}
Ejemplo n.º 3
0
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 */
require_once('includes/common.php');
require_once('includes/SI_Invoice.php');
require_once('includes/SI_InvoiceLine.php');
require_once('includes/SI_Company.php');
require_once('includes/SI_TaskActivity.php');
require_once('includes/SI_Payment.php');
require_once('includes/SI_ItemCode.php');

checkLogin('accounting');

$line = new SI_InvoiceLine();
$invoice = new SI_Invoice();
$company = new SI_Company();
$item_code = new SI_ItemCode();

if(!isset($_REQUEST['mode'])) $_REQUEST['mode'] = 'add';

// Clean up unit_price
if(!empty($_POST['unit_price'])){
	$_POST['unit_price'] = preg_replace('/[^0-9\.-]/','',$_POST['unit_price']);
}

// Prepare our variables
$line_added = false;
if($_REQUEST['mode'] == 'add_ta_link' || $_REQUEST['mode'] == 'add_sp_link' ||
   $_REQUEST['mode'] == 'add_ex_link' || $_REQUEST['mode'] == 'delete_link' ||