Stock and Supplier Notes as on Customer - VortecCPI - 02-16-2018
I realize we can integrate webERP with WIKIs but it sure would be nice if we had an area for each Stock and Supplier where we could enter data in a memo area. It would be the same as "Add a note on this customer".
Many of my customers enter bits of data into these areas in their ERP systems.
Well... That was pretty easy...
Can somebody please check my work to be sure it meets webERP standards?
Code: CREATE TABLE `suppnotes` (
`noteid` tinyint(4) NOT NULL AUTO_INCREMENT,
`supplierid` varchar(10) NOT NULL DEFAULT '0',
`href` varchar(100) NOT NULL,
`note` text NOT NULL,
`date` date NOT NULL DEFAULT '0000-00-00',
`priority` varchar(20) NOT NULL,
PRIMARY KEY (`noteid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Of course we also need to:
Add area to bottom of Supplier page:
PHP Code: // Supplier Notes $SQL = "SELECT noteid, supplierid, href, note, date, priority FROM suppnotes WHERE supplierid='" . $_SESSION['SupplierID'] . "' ORDER BY date DESC"; $result = DB_query($SQL); if(DB_num_rows($result) <> 0) { echo '<br /><div class="centre"><img src="' . $RootPath . '/css/' . $Theme . '/images/note_add.png" title="' . _('Supplier Notes') . '" alt="" />' . ' ' . _('Supplier Notes') . '</div><br />'; echo '<table style="width: 45%;">'; echo '<tr> <th class="ascending">' . _('Date') . '</th> <th>' . _('Note') . '</th> <th>' . _('Hyperlink') . '</th> <th class="ascending">' . _('Priority') . '</th> <th>' . _('Edit') . '</th> <th>' . _('Delete') . '</th> <th> <a href="AddSupplierNotes.php?SupplierID=', urlencode($_SESSION['SupplierID']), '">' . ' ' . _('Add New Note') . '</a> </th> </tr>'; $k = 0;// row colour counter while ($myrow = DB_fetch_array($result)) { if($k == 1) { echo '<tr class="OddTableRows">'; $k = 0; }// $k == 1 else { echo '<tr class="EvenTableRows">'; $k = 1; } echo '<td>' . ConvertSQLDate($myrow['date']) . '</td> <td>' . $myrow['note'] . '</td> <td><a href="' . $myrow['href'] . '">' . $myrow['href'] . '</a></td> <td>' . $myrow['priority'] . '</td> <td><a href="AddSupplierNotes.php?Id=' . $myrow['noteid'] . '&SupplierID=' . $myrow['supplierid'] . '">' . _('Edit') . '</a></td> <td><a href="AddSupplierNotes.php?Id=' . $myrow['noteid'] . '&SupplierID=' . $myrow['supplierid'] . '&delete=1">' . _('Delete') . '</a></td> </tr>'; }// END WHILE LIST LOOP echo '</table>'; }// end if there are supplier notes to display
Add entry to scripts table
Add line of code in SelectSupplier.php
PHP Code: <br /><a href="' . $RootPath . '/AddSupplierNotes.php?SupplierID=' . $_SESSION['SupplierID'] . '">' . _('Add a note on this supplier') . '</a>
Add applicable entries to messages.mo
_('Supplier Notes')
_('Notes for Supplier')
_('Are you sure you wish to delete this supplier note?')
_('Review all notes for this Supplier')
RE: Supplier Notes as on Customer - VortecCPI - 02-16-2018
Also...
Why do we limit the note length to 200 characters?
Why do we use the term "contact" throughout these scripts?
This could also be useful for Stock items as well.
Perhaps the code can be abstracted to work for all contexts? Put them all into one table as well?
RE: Supplier Notes as on Customer - VortecCPI - 02-16-2018
Okay... Here is my crack at an abstracted Object Notes script to manage notes for Customers, Suppliers, and Stock...
Code: CREATE TABLE `objectnotes` (
`noteid` tinyint(4) NOT NULL AUTO_INCREMENT,
`parentid` varchar(10) NOT NULL DEFAULT '0',
`parenttype` varchar(8) NOT NULL,
`href` varchar(100) NOT NULL,
`note` text NOT NULL,
`date` date NOT NULL DEFAULT '0000-00-00',
`priority` varchar(20) NOT NULL,
PRIMARY KEY (`noteid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I am SURE one of you PHP geniuses can do a lot more to tidy this up and make it a lot better...
Obviously we need to concatenate "&SupplierType=XXX" to the end of the calling hyperlinks...
Now we have just one script to maintain and just one table to maintain.
Not too sure if this goes well with security schema though...
With a script like this we could potentially attach notes to any object in the system.
I was inspired by how it is done with TUTOS, which is VERY OO in nature...
http://www.tutos.org/homepage/index.html
We could leave custnotes as is and add this just for Stock and Supplier.
Would be better for upgrades to leave custnotes alone...
It seems to me like we could easily abstract Contacts the same way...
RE: Stock and Supplier Notes as on Customer - VortecCPI - 02-16-2018
Here is one for Stock Notes...
Code: CREATE TABLE `stocknotes` (
`noteid` tinyint(4) NOT NULL AUTO_INCREMENT,
`stockid` varchar(10) NOT NULL DEFAULT '0',
`href` varchar(100) NOT NULL,
`note` text NOT NULL,
`date` date NOT NULL DEFAULT '0000-00-00',
`priority` varchar(20) NOT NULL,
PRIMARY KEY (`noteid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
PHP Code: echo '<a href="' . $RootPath . '/AddStockNotes.php?StockID=' . urlencode($StockID) . '">' . _('Add a note on this stock') . '</a><br />';
PHP Code: if ($StockID != '') { // Stock Notes $SQL = "SELECT noteid, stockid, href, note, date, priority FROM stocknotes WHERE stockid='" . $StockID . "' ORDER BY date DESC"; $result = DB_query($SQL); if(DB_num_rows($result) <> 0) { echo '<br /><div class="centre"><img src="' . $RootPath . '/css/' . $Theme . '/images/note_add.png" title="' . _('Stock Notes') . '" alt="" />' . ' ' . _('Stock Notes') . '</div><br />'; echo '<table style="width: 45%;">'; echo '<tr> <th class="ascending">' . _('Date') . '</th> <th>' . _('Note') . '</th> <th>' . _('Hyperlink') . '</th> <th class="ascending">' . _('Priority') . '</th> <th>' . _('Edit') . '</th> <th>' . _('Delete') . '</th> <th> <a href="AddStockNotes.php?StockID=', urlencode($StockID), '">' . ' ' . _('Add New Note') . '</a> </th> </tr>'; $k = 0;// row colour counter while ($myrow = DB_fetch_array($result)) { if($k == 1) { echo '<tr class="OddTableRows">'; $k = 0; }// $k == 1 else { echo '<tr class="EvenTableRows">'; $k = 1; } echo '<td>' . ConvertSQLDate($myrow['date']) . '</td> <td>' . $myrow['note'] . '</td> <td><a href="' . $myrow['href'] . '">' . $myrow['href'] . '</a></td> <td>' . $myrow['priority'] . '</td> <td><a href="AddStockNotes.php?Id=' . $myrow['noteid'] . '&StockID=' . $myrow['stockid'] . '">' . _('Edit') . '</a></td> <td><a href="AddStockNotes.php?Id=' . $myrow['noteid'] . '&StockID=' . $myrow['stockid'] . '&delete=1">' . _('Delete') . '</a></td> </tr>'; }// END WHILE LIST LOOP echo '</table>'; }// end if there are stock notes to display else { if($StockID != '') { echo '<br /><div class="centre"><img src="' . $RootPath . '/css/' . $Theme . '/images/note_add.png" title="' . _('Stock Notes') . '" alt="" /><a href="AddStockNotes.php?StockID=', urlencode($StockID), '">' . ' ' . _('Add New Note for this Stock') . '</a></div>'; } } }
RE: Supplier Notes as on Customer - afcouling - 03-13-2018
(02-16-2018, 04:07 AM)VortecCPI Wrote: Okay... Here is my crack at an abstracted Object Notes script to manage notes for Customers, Suppliers, and Stock...
Code: CREATE TABLE `objectnotes` (
`noteid` tinyint(4) NOT NULL AUTO_INCREMENT,
`parentid` varchar(10) NOT NULL DEFAULT '0',
`parenttype` varchar(8) NOT NULL,
`href` varchar(100) NOT NULL,
`note` text NOT NULL,
`date` date NOT NULL DEFAULT '0000-00-00',
`priority` varchar(20) NOT NULL,
PRIMARY KEY (`noteid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I am SURE one of you PHP geniuses can do a lot more to tidy this up and make it a lot better...
Obviously we need to concatenate "&SupplierType=XXX" to the end of the calling hyperlinks...
Now we have just one script to maintain and just one table to maintain.
Not too sure if this goes well with security schema though...
With a script like this we could potentially attach notes to any object in the system.
I was inspired by how it is done with TUTOS, which is VERY OO in nature...
We could leave custnotes as is and add this just for Stock and Supplier.
Would be better for upgrades to leave custnotes alone...
It seems to me like we could easily abstract Contacts the same way...
I like the idea of a generic 'object notes' table.
If we go down this route, I'd recommend sticking customer, supplier, and item notes in there, rather than leaving custnotes as is, for the sake of keeping things tidy.
From an upgrade perspective, would it not be better to alter the existing custnotes table to match the 'objectnotes' structure above?
Do you see any benefit in being able to add formatting to a note, with a WYSIWYG HTML editor?
Andy.
RE: Stock and Supplier Notes as on Customer - VortecCPI - 03-14-2018
I am also in favor of an abstracted and generic Notes object.
ALTERing the custnotes table seems the best route and would be quite easy.
In our case formatted text is not necessary but it may be needed or required by others...
Also... Perhaps we can add the note handling code to MiscFunctions.php to keep things easy to extend and maintain...
RE: Stock and Supplier Notes as on Customer - TimSchofield - 03-14-2018
While we are throwing ideas out, how about a generic contact object, that can be linked to a notes object?
Tim
RE: Stock and Supplier Notes as on Customer - VortecCPI - 03-14-2018
Also... Perhaps we should add "Author" (i.e., USERID) to the Note object?
(03-14-2018, 12:28 AM)falkoner Wrote: While we are throwing ideas out, how about a generic contact object, that can be linked to a notes object?
Tim
Yes. I also like that idea as well.
Some sort of file attachment might also be a nice touch...
|