[CS-Project-svn_notify] SF.net SVN: cs-project: [717] trunk
Brought to you by:
crazedsanity
From: <cra...@us...> - 2007-12-27 16:35:51
|
Revision: 717 http://cs-project.svn.sourceforge.net/cs-project/?rev=717&view=rev Author: crazedsanity Date: 2007-12-27 08:35:48 -0800 (Thu, 27 Dec 2007) Log Message: ----------- Reverse r697 to re-add invoices. SVN COMMAND::: merge -r697:696 https://cs-project.svn.sourceforge.net/svnroot/cs-project/trunk Modified Paths: -------------- trunk/lib/invoice.class.php trunk/lib/invoiceItem.class.php trunk/public_html/.htaccess Added Paths: ----------- trunk/docs/sql/upgrades/upgradeTo1.1.0-BETA16.sql trunk/includes/test.inc trunk/lib/invoiceTransaction.class.php trunk/public_html/test trunk/public_html/test.php trunk/templates/test/ Copied: trunk/docs/sql/upgrades/upgradeTo1.1.0-BETA16.sql (from rev 696, trunk/docs/sql/upgrades/upgradeTo1.1.0-BETA16.sql) =================================================================== --- trunk/docs/sql/upgrades/upgradeTo1.1.0-BETA16.sql (rev 0) +++ trunk/docs/sql/upgrades/upgradeTo1.1.0-BETA16.sql 2007-12-27 16:35:48 UTC (rev 717) @@ -0,0 +1,59 @@ +-- +-- SVN INFORMATION::: +-- +-- SVN Signature::::::::: $Id$ +-- Last Committted Date:: $Date$ +-- Last Committed Path::: $HeadURL$ +-- + + +CREATE TABLE invoice_status_table ( + invoice_status_id integer NOT NULL PRIMARY KEY, + name text NOT NULL UNIQUE, + description text NOT NULL UNIQUE, + is_updateable boolean NOT NULL DEFAULT FALSE +); + +-- NOTE: by setting the invoice_status_id, we ensure they always get set properly, and new ones can't be readily inserted without specifying that too. +INSERT INTO invoice_status_table (invoice_status_id, name, description, is_updateable) VALUES (-1, 'W/0', 'Write Off', FALSE); +INSERT INTO invoice_status_table (invoice_status_id, name, description, is_updateable) VALUES (0, 'New', 'Open, pending changes', TRUE); +INSERT INTO invoice_status_table (invoice_status_id, name, description, is_updateable) VALUES (1, 'OK', 'Completed', FALSE); + +CREATE TABLE invoice_table ( + invoice_id integer NOT NULL PRIMARY KEY, + poc text, + company text, + address1 text, + address2 text, + phone text, + fax text, + city text, + state text, + zip text, + invoice_status_id integer NOT NULL DEFAULT 0 REFERENCES invoice_status_table(invoice_status_id), + creator_contact_id integer NOT NULL REFERENCES contact_table(contact_id), + billing_contact_id integer NOT NULL REFERENCES contact_table(contact_id), + is_proforma boolean NOT NULL DEFAULT FALSE, + date_created date NOT NULL DEFAULT CURRENT_DATE +); + + +CREATE TABLE invoice_item_table ( + invoice_item_id integer NOT NULL PRIMARY KEY, + invoice_id integer NOT NULL REFERENCES invoice_table(invoice_id), + description text NOT NULL, + unit_price decimal(10,2), + quantity integer NOT NULL DEFAULT 1 +); + + + +CREATE TABLE invoice_transaction_table ( + invoice_transaction_id integer NOT NULL PRIMARY KEY, + invoice_id integer NOT NULL REFERENCES invoice_table(invoice_id), + auth_string text NOT NULL, + number text NOT NULL, + date_created date NOT NULL DEFAULT CURRENT_DATE +); + + Property changes on: trunk/docs/sql/upgrades/upgradeTo1.1.0-BETA16.sql ___________________________________________________________________ Name: svn:keywords + Id HeadURL Date Revision Author Name: svn:eol-style + native Copied: trunk/includes/test.inc (from rev 696, trunk/includes/test.inc) =================================================================== --- trunk/includes/test.inc (rev 0) +++ trunk/includes/test.inc 2007-12-27 16:35:48 UTC (rev 717) @@ -0,0 +1,79 @@ +<?php +/* + * Created on Dec 13, 2007 + * + * SVN INFORMATION::: + * ------------------ + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + + */ + + +$invoiceData = array( + 'invoice_id' => '10015', + 'poc' => 'Johnny Jackson', + 'company' => 'Llama Soft, Inc.', + 'address1' => '1555 North Georgia Ave.', + 'address2' => 'Suite 1411', + 'phone' => '(701) 555-3389 ext. 1911', + 'fax' => '(701) 555-9193', + 'city' => 'St. Louis', + 'state' => 'Missouri', + 'zip' => '55454' +); + +$invoiceItemData = array( + 91 => array( + 'invoice_item_id' => 91, + 'invoice_id' => 10015, + 'description' => 'Contract Downpayment', + 'unit_price' => 3000, + 'quantity' => 1 + ), + 93 => array( + 'invoice_item_id' => 93, + 'invoice_id' => 10015, + 'description' => 'Remote Software Development', + 'unit_price' => 75, + 'quantity' => 40 + ), + 94 => array( + 'invoice_item_id' => 94, + 'invoice_id' => 10015, + 'description' => 'Remote Software Development (overtime hours)', + 'unit_price' => 112.5, + 'quantity' => 12 + ) +); + + +$gf = new cs_globalFunctions; +$gf->debugPrintOpt = 1; + +$gf->debug_print("Here is the main invoice data::: ". $gf->debug_print($invoiceData,0)); + +$blockRows = $page->rip_all_block_rows(); + +if(!count($blockRows)) { + $gf->debug_print("Here's what I could find for block rows (should be more than just an empty array)::: ". $gf->debug_print($page->get_block_row_defs('content'),0)); + throw new exception("You forgot to give me valid block rows for parsing invoice items!"); +} +else { + $gf->debug_print("Here's the items that will be parsed into the rows::: ". $gf->debug_print($invoiceItemData,0)); + foreach($invoiceData as $index=>$value) { + $page->add_template_var($index, $value); + } + + //I have no idea how this will work when I don't know what the name of the block row is. + $tmplRow = array_pop($blockRows); + $allParsedRows = ""; + + foreach($invoiceItemData as $itemId=>$subData) { + $allParsedRows .= $page->gfObj->mini_parser($tmplRow, $subData, '{', '}'); + } +} + +?> Property changes on: trunk/includes/test.inc ___________________________________________________________________ Name: svn:eol + native Name: svn:keywords + Id HeadURL Date Revision Author Name: svn:eol-style + native Modified: trunk/lib/invoice.class.php =================================================================== --- trunk/lib/invoice.class.php 2007-12-27 00:07:36 UTC (rev 716) +++ trunk/lib/invoice.class.php 2007-12-27 16:35:48 UTC (rev 717) @@ -1,5 +1,8 @@ <?php /* + * This class was built to handle creation, searching, and updates of invoices. + * For searches involving items on the invoice, use invoiceItem{}. + * invoices is handled by * * SVN INFORMATION::: * ------------------ @@ -18,20 +21,95 @@ protected $gfObj; protected $logsObj; + private $invoiceId = NULL; + private $creatorContactId = NULL; + private $billingContactId = NULL; + + //set some internal things that should NEVER be changed after initialization. + const mainTable = 'invoice_table'; + const mainTableSeq = 'invoice_table_invoice_id_seq'; + + const itemTable = 'invoice_item_table'; + const itemTableSeq = 'invoice_item_table_invoice_item_id_seq'; + + const transTable = 'invoice_transaction_table'; + const transTableSeq = 'invoice_transaction_table_invoice_transaction_id_seq'; + //========================================================================= public function __construct(cs_phpDB $db) { $this->db = $db; $this->gfObj = new cs_globalFunctions; $this->gfObj->debugPrintOpt = DEBUGPRINTOPT; - $this->logsObj = new logsClass($this->db, 'Authentication Token'); + $this->logsObj = new logsClass($this->db, 'Invoice'); }//end __construct() //========================================================================= //========================================================================= + /** + * Method to handle creating the main invoice record. + */ + public function create_invoice(array $invoiceData, $isProforma=FALSE) { + $cleanFields = array( + 'poc','company', 'address1', 'address2', 'phone', 'fax', 'city', + 'state', 'zip' + ); + + $insertArr = array(); + foreach($invoiceData as $name=>$value) { + $insertArr[$name] = $this->gfObj->cleanString($value, 'sql'); + } + + if($isProforma === TRUE) { + $insertArr['is_proforma'] = 't'; + } + + $insertString = $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); + + $sql = "INSERT INTO ". $this->mainTable .' '. $insertString; + + if($this->run_sql($sql)) { + //pull the new invoice id. + $retval = $this->get_inserted_invoice_id(); + } + else { + throw new exception(__METHOD__ .': failed to insert new invoice: '. $this->lastError ."<BR>\nSQL::: ". $sql); + } + + return($retval); + + }//end create_invoice() + //========================================================================= + + + + //========================================================================= + /** + * Add a line item to the invoice; should be an instance of invoiceItem{}. + */ public function add_item(invoiceItem $item) { }//end add_item() //========================================================================= + + + + //========================================================================= + /** + * Retrieve the invoice_id that was last inserted. + */ + private function get_inserted_invoice_id() { + $sql = "SELECT currval('". $this->mainTableSeq ."'::text)"; + if($this->run_sql($sql)) { + $data = $this->db->farray(); + $retval = $data[0]; + } + else { + throw new exception(__METHOD__ .": failed to retrieve last invoice_id: ". $this->lastError); + } + + return($retval); + }//end get_inserted_invoice_id() + //========================================================================= } ?> Modified: trunk/lib/invoiceItem.class.php =================================================================== --- trunk/lib/invoiceItem.class.php 2007-12-27 00:07:36 UTC (rev 716) +++ trunk/lib/invoiceItem.class.php 2007-12-27 16:35:48 UTC (rev 717) @@ -14,7 +14,7 @@ //TODO: log everything! -class invoiceItem extends dbAbstract { +class invoiceItem extends invoice { protected $gfObj; protected $logsObj; @@ -24,7 +24,7 @@ $this->db = $db; $this->gfObj = new cs_globalFunctions; $this->gfObj->debugPrintOpt = DEBUGPRINTOPT; - $this->logsObj = new logsClass($this->db, 'Authentication Token'); + $this->logsObj = new logsClass($this->db, 'Invoice Item'); }//end __construct() //========================================================================= Copied: trunk/lib/invoiceTransaction.class.php (from rev 696, trunk/lib/invoiceTransaction.class.php) =================================================================== --- trunk/lib/invoiceTransaction.class.php (rev 0) +++ trunk/lib/invoiceTransaction.class.php 2007-12-27 16:35:48 UTC (rev 717) @@ -0,0 +1,30 @@ +<?php +/* + * + * SVN INFORMATION::: + * ------------------ + * SVN Signature::::::: $Id$ + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + * + */ + +//TODO: log everything! + +class invoiceTransaction extends invoice { + + protected $gfObj; + protected $logsObj; + + //========================================================================= + public function __construct(cs_phpDB $db) { + $this->db = $db; + $this->gfObj = new cs_globalFunctions; + $this->gfObj->debugPrintOpt = DEBUGPRINTOPT; + $this->logsObj = new logsClass($this->db, 'Invoice Transaction'); + }//end __construct() + //========================================================================= +} +?> Property changes on: trunk/lib/invoiceTransaction.class.php ___________________________________________________________________ Name: svn:keywords + Id HeadURL Date Revision Author Name: svn:eol-style + native Modified: trunk/public_html/.htaccess =================================================================== --- trunk/public_html/.htaccess 2007-12-27 00:07:36 UTC (rev 716) +++ trunk/public_html/.htaccess 2007-12-27 16:35:48 UTC (rev 717) @@ -17,4 +17,7 @@ </files> <files help> ForceType application/x-httpd-php +</files> +<files test> + ForceType application/x-httpd-php </files> \ No newline at end of file Copied: trunk/public_html/test (from rev 696, trunk/public_html/test) =================================================================== --- trunk/public_html/test (rev 0) +++ trunk/public_html/test 2007-12-27 16:35:48 UTC (rev 717) @@ -0,0 +1,20 @@ +<?php +/* + * Created on Mar 10, 2006 + * by + * Dan Falconer + */ + + +require_once(dirname(__FILE__) ."/../lib/site_config.php"); + +$db = new cs_phpDB; +$db->connect(get_config_db_params()); +$session = new Session($db); + +$GLOBALS['DEBUGPRINTOPT'] = DEBUGPRINTOPT; + +$contentObj = new contentSystem(); +$contentObj->handle_session($session); +$contentObj->finish(); +?> Property changes on: trunk/public_html/test ___________________________________________________________________ Name: svn:eol + native Name: svn:executable + * Name: svn:eol-style + native Copied: trunk/public_html/test.php (from rev 696, trunk/public_html/test.php) =================================================================== --- trunk/public_html/test.php (rev 0) +++ trunk/public_html/test.php 2007-12-27 16:35:48 UTC (rev 717) @@ -0,0 +1 @@ +link test \ No newline at end of file Property changes on: trunk/public_html/test.php ___________________________________________________________________ Name: svn:special + * Copied: trunk/templates/test (from rev 696, trunk/templates/test) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |