Category: C++ Windows Mobile
Posted by: Alph
When using webERP, if you have created some customers, but they do not appear when you go to place a Sales Order. Even if you enter the exact customer code in

" Enter text in the customer name: OR Enter text extract in the customer code: "

This is probably because you need to set the following flag on the customer branch records:

Disable transactions on this branch: set to Enabled

The SQL has a select from custbranch and part of the where clause is 'AND custbranch.disabletrans=0'.

Category: Web ERP
Posted by: Alph
Setting up multiple companies in webERP is surprisingly simple. Thanks to the forum and mostly to the Multiple Company section in the Wiki.

This is for an installation on a local PC running Windows:

Copy the existing 'weberp' folder (Apache....\htdocs\webERP\companies\weberp) to a new folder under the companies folder. I did this and named the folder ABC. This folder should have sub-directories EDI_Incoming_Orders, EDI_Sent, part_pics, reports. A new logo can be placed in the ABC folder (logo.jpg)

To create a database for ABC company, get the MySQL script weberp-new.sql and copy it to a different folder (I just copied mine to the ABC folder - it's not that important where it's located, but you may as well keep it handy). Open the script with Notepad and do a find and replace (Ctrl-H) and replace 'weberp' with 'ABC' (don't use quotes). I'd suggest replacing each word using Replace so you can see what you are replacing. You could do 'Replace All' and it wouldn't hurt too much. The only bit you don't really want to replace is

INSERT INTO `www_users` VALUES ('demo','weberp','Demonstration user',''

because this will set the 'demo' password to 'ABC' if you replace that 'weberp', for example

INSERT INTO `www_users` VALUES ('demo','ABC','Demonstration user',''

IF you do this, it will just mean when you first log on to the ABC company, you will need to use the user 'demo' and password 'ABC'.

Also you don't really need to replace the 'weberp' in '' which is used in the script, but it won't hurt.

Now run this script. I use EMS MySQL Manager Lite:
Tools->SQL Script
Execute Script from File button
locate your script
run..... DB will be created

If you want the user to be able to choose the company from the drop-down when logging on, set the following line in Config.php

$AllowCompanySelectionBox = true;

otherwise make it 'false' and then it will be necessary for the user to enter the company name.

If you want the new company to be the default, then in Config.php change

$DefaultCompany = 'weberp';
$DefaultCompany = 'ABC';

When logging on to ABC for the first time, use 'demo' and then set up a new user as usual. Then set company configuration such as the company name etc.

That's it!

For more information or further help: contact me.

Category: Web ERP
Posted by: Alph
Here are some notes on the installation of Web ERP version 3.04 on a local machine (ie not on a hosted web site or LAN). Windows XP was the operating system. SSL was not used here.

Download the Web-ERP zip file from I downloaded ""

If you haven't got Apache and/or PHP installed already, download them from and Download the windows installer MSI versions. I downloaded


Install Apache first by running the msi and follow the defaults. If you want to install into different directories you can. The server name can be localhost. I chose the option to use port 8080 and manually start Apache - you don't have to. Once Apache is installed, test it by going to http://localhost:8080. You should see "It Works!".

Now install PHP by running the MSI and follow the defaults. I installed into C:/PHP

Make the following additions to httpd.conf (in the Apache folder "conf")

make sure DocumentRoot is set to the "htdocs" folder of your Apache installation. Mine was set as
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"

within the tags "", add ScriptAlias reference:
ScriptAlias /php/ "C:/PHP/"

<Directory "C:/PHP">
AllowOverride None
Options None
Order allow,deny
Allow from all

within "<IfModule mime_module>" tags, add:
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi.exe"

Test the PHP by creating a simple .php file called "phpinfo.php" in your Apache htdocs folder with the contents:
<?PHP phpinfo(); ?>

Test by visiting http://localhost:8080/phpinfo.php, you should see a purple coloured screen displaying PHP Info.

Install MySQL V4.1. I actually already had MySQL installed. There is plenty of info on the web on how to install MySQL on Windows XP.

Unzip the and move the extracted folder webERP so that it is a sub-directory of htdocs.

Create a MySQL user weberp@localhost and supply a password. Use:

grant all privileges on *.* to weberp@localhost identified by 'your_password' with grant option;

Create the database tables by applying the script \htdocs\webERP\sql\mysql\weberp-new.sql. To do this I used EMS SQL Manager Lite which is a very handy and free MySQL utility. This can be easily found on the net, try Simply use Tools->SQL Script, paste in script weberp-new.sql and "Execute script". I created the tables using the user "root" and the admininstration password for "root".

Modify config.php
make sure $dbType = 'mysql'; is uncommented
set $dbuser = 'weberp';
$dbpassword = 'your password';

You also need to install the MySQL extensions for PHP. To do this, download the additional zip file and PECL zip files from the PHP download site.

Adjust PHP.ini (mine is located in C:/Windows) as follows:

extension_dir = C:\PHP\extensions
uncomment extension=php_mysql.dll
create directory C:\php\extensions"
copy php_mysqli.dll and php_mysql.dll to C:\php\extensions
copy libmysql.dll to c:/PHP

Now visit http://localhost:8080/webERP and webERP should be running successfully.

log in using the name 'demo'
password 'weberp'

Good luck!

For more information or further help: contact me.

Category: C++ Windows Mobile
Posted by: Alph
Here is a simple piece of code that can be used to move files from one location to another on Windows CE. This code utilises SHFileOperation and shows how to set up the SHFILEOPSTRUCT structure to achieve the move. The flags are set so the whole operation is silent and doesn't show any dialogs.

BOOL YourClass::MoveFile(CString source, CString destination)


// add required string terminators

// set up File Operation structure
ZeroMemory(&SHFileOp, sizeof(SHFILEOPSTRUCT));
SHFileOp.hwnd = NULL;
SHFileOp.wFunc = FO_MOVE;
SHFileOp.pFrom = source;
SHFileOp.pTo = destination;

if(SHFileOperation(&SHFileOp) != 0){

AfxMessageBox(L"File Move Failed");
return false;

return true;

The various flags can be obtained from the Visual C++ / .NET documentation, or from MSDN.

An example usage is:

return( MoveFile(_T("\\Temp\\*.exe"), _T("\\Application\\")) );

This will move all executable files in the Temp directory into the Application directory.
Category: C++ Windows Mobile
Posted by: Alph
I must have wasted nearly two days trying to write some code to do a simple FTP file transfer from a remote server to my device. I initially hunted around on the internet and finally found an example class using sockets that would do most of the work, but it wasn't really complete and when transferring a binary executable the file always arrived corrupted. It had something to do with the byte order or character set or something, but after struggling for a while to work it out without success, I searched for something else.

Then I realised I could use WinInet functions FTPGetFile() etc. This turned out to be a lot easier with a lot less code and the file transferred flawlessly. I developed a prototype on a Symbol PDT8800 and it worked fine. Then I applied the same code on a Symbol MC1000 (the device I actually needed the code to work on) but every time the FTPGetFile would hang, taking a few minutes before responding with anything - and no file transfer. This had me baffled for a while, and I thought that it was perhaps related to a bug I'd read about with FTPGetFile here - but that was only supposed to be applicable to Pocket PC 2002 SDK, whereas the MC1000 uses Windows CE 4.2. So I tried all sorts of things, like using InternetOpenFile, InternetReadFile and InternetWriteFile, but even these were hanging.

Finally by chance I stumbled on some sample code and noticed that the code had set the INTERNET_FLAG_PASSIVE flag during the InternetConnect command. I thought I might as well give that a try and like magic everything started to work. So that's all it was - that Passive FTP Mode flag..

What is passive FTP Mode?

Here is the code I used. Hope it saves someone the hassle I faced.

// Set URL, username and password appropriately
CString m_URL=_T("");
CString m_Username=_T("your_username");
CString m_PasswordL=_T("your_password");
CString m_Filename_Remote = _T("your_remote_filename");
CString m_Filename_Local = _T("your_local_filename");

HINTERNET hInternetConnect;

HINTERNET hOpen = InternetOpen (L"YourApp",

if ( !hOpen )
AfxMessageBox(L"Failed to open WinInet");


hInternetConnect =

if( hInternetConnect ){

if(FtpGetFile(hInternetConnect, m_Filename_Remote, m_Filename_Local, 0, 0, FTP_TRANSFER_TYPE_BINARY, 0)){

AfxMessageBox(L"Get File Failed");
return false;

AfxMessageBox(L"Internet Connect failed");
return false;


Note that you should obviously set the appropriate URL and username and password. And you should use the appropriate INTERNET_OPEN_TYPE.. with InternetOpen (ie use a Proxy if needed)