Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stock and Supplier Notes as on Customer
02-16-2018, 12:51 AM (This post was last modified: 02-16-2018 08:06 AM by VortecCPI.)
Post: #1
Stock and Supplier Notes as on Customer
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'] . '&amp;SupplierID=' $myrow['supplierid'] . '">' _('Edit') . '</a></td>
                    <td><a href="AddSupplierNotes.php?Id=' 
$myrow['noteid'] . '&amp;SupplierID=' $myrow['supplierid'] . '&amp;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')


Attached File(s)
.php  AddSupplierNotes.php (Size: 7.56 KB / Downloads: 0)

https://www.linkedin.com/in/eclipsepaulbecker
Visit this user's website Find all posts by this user
Quote this message in a reply
02-16-2018, 01:57 AM (This post was last modified: 02-16-2018 04:13 AM by VortecCPI.)
Post: #2
RE: Supplier Notes as on Customer
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?

https://www.linkedin.com/in/eclipsepaulbecker
Visit this user's website Find all posts by this user
Quote this message in a reply
02-16-2018, 04:07 AM (This post was last modified: 03-14-2018 12:23 AM by VortecCPI.)
Post: #3
RE: Supplier Notes as on Customer
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...


Attached File(s)
.php  AddObjectNotes.php (Size: 8.9 KB / Downloads: 0)

https://www.linkedin.com/in/eclipsepaulbecker
Visit this user's website Find all posts by this user
Quote this message in a reply
02-16-2018, 08:04 AM (This post was last modified: 02-16-2018 08:05 AM by VortecCPI.)
Post: #4
RE: Stock and Supplier Notes as on Customer
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'] . '&amp;StockID=' $myrow['stockid'] . '">' _('Edit') . '</a></td>
                    <td><a href="AddStockNotes.php?Id=' 
$myrow['noteid'] . '&amp;StockID=' $myrow['stockid'] . '&amp;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>';
            }
        }



Attached File(s)
.php  AddStockNotes.php (Size: 7.39 KB / Downloads: 0)

https://www.linkedin.com/in/eclipsepaulbecker
Visit this user's website Find all posts by this user
Quote this message in a reply
03-13-2018, 11:57 PM (This post was last modified: 03-14-2018 12:09 AM by afcouling.)
Post: #5
RE: Supplier Notes as on Customer
(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.

https://www.linkedin.com/in/andrewcouling
Find all posts by this user
Quote this message in a reply
03-14-2018, 12:19 AM (This post was last modified: 03-14-2018 12:25 AM by VortecCPI.)
Post: #6
RE: Stock and Supplier Notes as on Customer
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...

https://www.linkedin.com/in/eclipsepaulbecker
Visit this user's website Find all posts by this user
Quote this message in a reply
03-14-2018, 12:28 AM
Post: #7
RE: Stock and Supplier Notes as on Customer
While we are throwing ideas out, how about a generic contact object, that can be linked to a notes object?

Tim
Visit this user's website Find all posts by this user
Quote this message in a reply
03-14-2018, 12:30 AM (This post was last modified: 03-14-2018 12:32 AM by VortecCPI.)
Post: #8
RE: Stock and Supplier Notes as on Customer
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...

https://www.linkedin.com/in/eclipsepaulbecker
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)