FILE: vtigercrm_director/modules/Invoice/CreatePDF.php

On line 153 you want to replace this:

$product_name[$i] = $associated_products[$i]['productName'.$i]

with this:

$product_name[$i] = $associated_products[$i]['productName'.$i]."\n-".$associated_products[$i]['comment'.$i];

Source: How to change the PDF layout

set all of the check boxes to:

<input type=”checkbox” name=”checkbox[]” value=”<?php echo $id ?>” />

That $id will be used to refer to the records to be updated.

To process the form data you use $_POST['checkbox'][$i], for example:

for ($i = 0; $i < count($_POST['checkbox']); ++$i) {
echo “item id: ” . $_POST['checkbox'][$i];
}

Add Foreign Key in phpMyAdmin

Posted by Ivan Guan under Uncategorized

The following steps are required for you to be able to add foreign keys using phpadmin (in xampp).

1. Select any table and go to operations tab, if InnoDB is listed under storage engine drop down menu then jump to step 5.
2. So InnoDB is disabled in mysql engine, edit the \xampp\mysql\bi\my.cnf file and remove the hashes that are required to enable InnoDB (its self explanatory).
3. Add a line in the above file, default_storage_engine=InnoDB (This makes InnoDB the default storage engine).
4. Restart mysql from the xampp control panel or from MS services.
5. Make sure, both PARENT and CHILD tables are of storage type InnoDB.
6. REFERENCED key (in parent) should be primary and REFERENCING key (in child) should be index.
7. In the CHILD table’s structure view, click on the link ‘relations view’ (it lies above ‘add fields’).
8. In the row corresponding to the REFERENCING key, select the REFERENCED key from the second column drop box.
9. Click go .. you’ll see that the required query is executed.

Example page: inline edit (no JS knowledge needed) [source ] | Inline example: Please edit me!

how you can make it work (5 easy steps for integration)

  • Download this Javascript file: InstantEdit 2.0 JS
  • Create a update file that handles the input. For example this PHP:  Update File
  • In your page add the javascript: <script type=”text/javascript” src=”instantedit.js”></script>
  • Set fixed vars (like hidden elements in a field post). These will be posted with the editable field so you can identify a user/session.
    <script type=”text/javascript”> setVarsForm(”pageID=profileEdit&userID=11″); </script>
  • Last step: in your HTML for any editable field add a SPAN arround it:
    <span id=”userName” class=”editText”>John Doe</span>
    Note: id is the fieldname (?userName=John Doe&), and should be unique!

how it works

A small piece of javascript reads al SPAN tags, checks if it has class=“editText” and a id=. If that is true, it adds a onclick function. That onclick function will create a textfield or input (depending on the size of the editable text). Someone has the ability to edit the field. When the text field is blurred, it will read the contents, and starts a XMLHttpRequest and ‘sends’ the content + fieldname + any set vars to an update file. That file will update your database, and reply with the newly set text and the textfield will dissapear again.

IE? FF?

This script works in internet explorer, netscape and firefox. Any other platforms haven’t been tested. That’s kinda up to you.

Update: HACKS

If you want to force a textarea over a textfield (for example to edit a piece of HTML) use class=“editText” offsetHeight=“10”.

If you want to PUSH an ID to your script I use: id=“edit_userID_$userID”. In your update script, strip the text, and keep the $userID. Et voila.

Source: http://www.yvoschaap.com/index.php/weblog/ajax_inline_instant_update_text_20/

Planning For Your Migration

It is very important to plan ahead when migrating a database application to MySQL, as you will want a solid strategy in place before you begin your conversion. In your planning, you will need to consider changes to your data such as modification of data types, as well as modification of the actual data that may be required. You will also want to look at the changes that will need to be made to your client application(s) including such things as cursor use, functions, stored procedures, and internal data types. You will also want to take a look at your current maintenance strategies and make any modifications necessary to continue maintenance under MySQL. Finally, you will want to look at the strengths and weaknesses of MySQL, SQL Server and/or Access and ensure that you will be using MySQL to its fullest.

Data Types

While SQL Server and MySQL have a fair amount of overlap as far as data types go, there are still some differences to be accounted for. Make sure to spend some time looking at the various data types you use in your tables and plan to migrate those tables to the MySQL data types that best match. Be careful when planning this: you want to match data types by capacity and not necessarily by name. For example: a MySQL VARCHAR can hold up to 255 characters, whereas a SQL Server VARCHAR can hold up to 4000 characters. In this case you would need to use a MySQL TEXT column type instead of VARCHAR.

Some data types do not have a direct correlation between SQL Server or Access and MySQL. One example would be the CURRENCY data type: MySQL does not (yet) have a CURRENCY data type, but creating a column with the definition DECIMAL(19,4) serves the same purpose. While MSSQL defaults to Unicode character types such as nCHAR and nVARCHAR, MySQL does not so tightly bind character sets to field types, instead allowing for one set of character types which can be bound to any number of character sets, including Unicode.

You can find the latest list of MySQL column types in the MySQL Reference Manual. You can use this table of mappings between Visual Basic datatypes and MySQL column types as a quick reference of the basic MySQL column types, their capacities, and their VB6 equivalents. MSDN also provides a list of SQL Server data types.

Data Modification

Sometimes you will need to modify the data itself when doing a data conversion. One example of this would be columns that hold date information. MySQL stores date information in a standard format of YYYY-MM-DD, while Microsoft databases are often in a MM-DD-YYYY format. It is very likely that your conversion tool will automatically take care of this, but if you are creating your own conversion tools you will need to keep this in mind. Both MSSQL and MySQL use single quote characters to wrap date information (i.e. '2000-12-13'), but Access uses hash marks to accomplish the same task (i.e. #23-11-2001#). If converting from Access to MySQL you will need to change your queries accordingly. Other data modifications might include schema changes to normalize your tables while performing data conversions. For more on database normalization, read the article “An Introduction to Database Normalization”.

Built-In Functions

Many of the built-in MySQL functions are the same as SQL Server built-in functions, though sometimes there are naming differences. One example is the MSSQL ISNULL() function. MySQL’s equivalent is the IFNULL() function, which uses the same syntax. Conversely, the ISNULL() function in Access uses a different syntax, and returns only a boolean instead of a substituted value. MySQL has more built-in functions than its Microsoft counterparts so there should be MySQL equivalents for any built-in functions your existing queries use.

Cursors

Typical Windows applications will use server-side dynamic or keyset cursors when accessing data through APIs such as ADO. The Connector/ODBC driver does not support keyset-driven cursors and server-side cursor support is very limited in any case. You will want to evaluate the cursor types and cursor locations used in your application to determine if changes need to be made. You may benefit from reading the article “CursorTypes, LockTypes, and CursorLocations”.

User Defined Functions

User Defined Functions (or UDFs) are not the same between SQL Server and MySQL. SQL Server functions are very similar to stored procedures, allowing you to encapsulate a series of queries into a callable function that can then be incorporated into a query. MySQL UDFs, on the other hand, are compiled C code that can be assigned to a function name and used in queries. One example would be using a C function that converts a color photo to black and white within a MySQL query to return images stored in color in BLOB columns as black and white images. Once your C code is compiled you can then incorporate it into the server and call it from a query.

MySQL does not currently offer an equivalent for the SQL Server style User Defined Functions, and the functionality of any UDFs present in your database will need to be converted to client-side application code.

Stored Procedures

MySQL has recently implemented stored procedures in version 5 of its database server. While MySQL is committed to following standard SQL conventions, this is no guarantee that a T-SQL will work in MySQL unchanged. If you will not be using MySQL 5, you will need to rewrite your stored procedures to use client-side code.

Maintenance Planning

In addition to planning your data and application conversions, you will also need to look at converting your database maintenance strategies and tools. Some major backup vendors do provide backup tools for MySQL, so you may want to check with your existing vendor to determine if they provide an equivalent tool for MySQL. Backup strategies for MySQL are very similar to those of SQL Server: regular full backups should be done, with log files backed up in the interval.

Migration Tools

There are a wide variety of tools available to help you migrate a SQL Server or Access database to MySQL. We’ll look at several different tools so you can choose the one that best suits your needs. The tools we will look at will include the following:

  • MSSQL2MYSQL
  • Microsoft DTS
  • SQLyog
  • Access Export
  • Text Import/Export

SQLYog and the Microsoft DTS wizard offer graphical interfaces that can be used with both MSSQL and Microsoft Access to import tables into MySQL. MSSQL2MYSQL is a script by Michael Kofler that can convert not only the table structure and data, but converts the index information as well. If you use Microsoft Access you may not have access to the above tools, but you can use the data export features of Access.

MSSQL2MYSQL

MSSQL2MYSQL is a creation of Michael Kofler, author of The Definitive Guide to MySQL by Apress. MSSQL2MYSQL is a Visual Basic script that can be executed using either a Microsoft Visual Basic 6 installation or an application that supports VBA such as Microsoft Word or Excel.

Details on usage can be found at the author’s web site, which also includes a listing of GUI front-ends that can be used to make MSSQL2MYSQL a bit more user-friendly for non-programmers.

To use MSSQL2MYSQL with VB6, simply copy the text located at http://www.kofler.cc/mysql/mssql2mysql.txt and paste it into the code section of a VB form. You will need to change the constants at the beginning of the code to match your SQL Server and MySQL installations, and you can then proceed to run the VB6 application and your conversion will take place. MSSQL2MYSQL does not provide any visual feedback on the progress of your conversion, and provides a simple messagebox upon completion.

A nice feature of MSSQL2MYSQL is the ability to dump all statements into a text file, which you can then review and edit before executing on the MySQL server.

Microsoft Data Transformation Services

Microsoft DTS is a data manipulation tool that is included with Microsoft SQL Server. DTS is excellent for moving data between various formats and systems such as databases, spreadsheets, and even HTML. The Microsoft Data Transformation Service can be very complex, but most of us will only ever need to use the Import/Export Wizard that is included with DTS.

Using DTS is fairly straightforward, you choose an ODBC data source to read data from, and then select an ODBC data source to convert the data to. You are then given a list of tables to convert, with an option of renaming the destination table and even performing basic transformations on the data before it is inserted into the target database. These transformations are performed using Visual Basic scripting. In addition, you are given control over the table creation statements to be used, allowing you to fine-tune the MySQL table definitions to add parameters such as table handler (InnoDB, BDB, etc) to the script that will be executed.

DTS also has the ability to perform scheduled data transformations, something that can be very useful when you are using MySQL for analysis of SQL Server data or when you just want the latest data available as you work on your application migration.

SQLyog

SQLyog is a third-party commercial tool available to help administrators manage MySQL in a GUI environment. SQLyog is provided by by webyog, a MySQL partner, and a thirty day trial of the tool is provided. SQLyog provides an ODBC import tool that is similar to DTS, offering a straightforward interface that is perhaps even simpler to use than DTS.

SQLyog is capable of scheduled imports of data, and can also be used to synchronize both data and schema between multiple MySQL servers.

Access Export

If you are a Microsoft Access user but do not have access to Microsoft DTS or SQLyog, you may want to use the export capability of Microsoft Access. Access can export its tables to a variety of formats, including ODBC. This allows you to export an Access table to MySQL by way of the Connector/ODBC ODBC driver provided by MySQL AB.

To export an Access table to MySQL, right-click on the table in question and choose the ‘Export’ option. After several steps your data will be exported to MySQL. The column-type choices made by Access may need to be modified, and you should be aware that Access will not export index information with the data, meaning that you will need to implement indexes on your tables after exporting them.

Text Import/Export

One final way to import data is to export the data from MSSQL/Access in a text format and import it directly into MySQL. When exporting, common formats such as tab-delimited or comma-delimited will work fine for later import into MySQL.

When taking this approach, you will need to manually create the MySQL tables, then import the data with the LOAD DATA command in the mysql command-line client. Additional information on the LOAD DATA command can be found in the “LOAD DATA INFILE syntax” section of the MySQL Reference Manual.

While perhaps the most labor-intensive and time-consuming, this approach gives you the highest level of control over table schema as you manually create the tables before importing data.

Source: http://dev.mysql.com/tech-resources/articles/migrating-from-microsoft.html

===

Additional Info regarding date format issue for text import

As MS Access Date format is dd/mm/yyyy 00:00:00 and MYSQL Date Format is yyyy-mm-dd

1. Changed the field definition for the date field to varchar
2. Imported normally
3. ran this query using substring_index

mm/dd/yyyy 00:00:00 ==> yyyy-mm-dd
update Customer set CreationDate=concat(
substring(substring_index(CreationDate,”/”,-1),1,4),”-”,
substring_index(CreationDate,”/”,1),”-”,
substring_index(substring_index(CreationDate,”/”,2),”/”,-1)
)

dd/mm/yyyy 00:00:00 ==> yyyy-mm-dd
update Customer set CreationDate=concat(
substring(substring_index(CreationDate,”/”,-1),1,4),”-”,
substring_index(substring_index(CreationDate,”/”,2),”/”,-1),”-”,
substring_index(CreationDate,”/”,1)
)

4. Then I changed the field definition back to Date

This article shows you how to switch the view of a subform from Datasheet view to Form view while the main form is open in Form view.

  1. Open the sample database Northwind.
  2. Open the Orders form in Design view.
  3. Add a command button to the main form. If the Command Button Wizard appears, click Cancel.
  4. Set the following properties for the command button:
       Name: cmdChangeView
       Caption: Change View
       OnClick: [Event Procedure]
  5. Set the OnClick property of the command button to the following event procedure:
    Private Sub cmdChangeView_Click()
        Me![Orders Subform].SetFocus
        DoCmd.RunCommand acCmdSubformDatasheet
    End Sub
  6. Close the Visual Basic Editor, and then open the Orders form in Form view.
  7. Click the Change View button to switch the subform from Datasheet view to Form view. Note that the button toggles the subform view. In other words, each time that you click the button, the subform changes either from Datasheet view to Form view, or vice versa.

Search with operators

Looking for a mail from your friend John? Use the Gmail search box and type from:john. Gmail will find all mails from John. If you can’t remember if the mail you are looking for was sent by John or Paul, type from:john OR paul.

If you have more than one friend called John, the search phrase looks like this: from:john-smith.

There are several operators of this kind:

  • from:
  • to:
  • cc:
  • bcc:
  • subject:
  • label:
  • filename:
  • has:attachment
  • in:anywhere
  • in:inbox
  • in:trash
  • in:spam
  • is:starred
  • is:unread
  • is:read
  • after:
  • before:

The two last operators relate to dates. If you want to find emails from a April 2007, the form is: after:2007/03/31 before:2004/05/01.

If you want to search for a label consisting of more than one word, use hyphens, like in the example with John Smith above: label:holiday-france.

To find mail from email addresses within a certain domain, you just enter the domain in the “From:” field.

You can also use standard Boolean operators (AND, OR, +, -, quotes and parentheses). For an introduction to Boolean search, see the Pandia Goalgetter search tutorial.

Use the Google Toolbar

If you have the Google Toolbar installed (and many Page Rank junkies do), recent editions have a Gmail button you can use to search your mail.

I want to keep a consistent data between my VTiger CRM & Outlook & Pocket PC. It turns out to be a very difficult task to do. I’ve tried a few methods to solve the problem below

Vtiger CRM returns  “Invalid return value from vTiger CRM”

At the beginning, I thought it was due to invalid name data as discussed in vtigercrm’s forum. The rule is

  • There can be only one word for “last name”, no space, no ‘, no -

However, after taking the painful steps to correct all my 900 contacts, I still get the same problem. Thus, I have to do it one by one. Trust me, you will never want to do that again. And guess what, I realised after sync about 450 contacts successfully, i got the same error message again.

Therefore, I suspected that there might be some limits set somewhere. Eventually, I discover this is because my shared server gives me 64M php memory limit! That’s how much 450 contacts used to sync!

Thus, I have to separate the contacts into two categories: business & personal. and sync them by two vtiger accounts. as a result, now I have two folders of contacts. and now it creates another problem.

Pocket PC can only sync with the default contact folder

This problem can be solved by Outlook 2002 Add-in: Pocket Contact Synchronizer 1.2 Here is an introduction of how to use PCS. However, here comes the next problem. That is

PCS is a one-way synchronization feature only.

That is if you update the Contact information on your Pocket PC and synchronize then you will need to move the Contact back to its sub folder manually. (I haven’t found a solution for this yet)

  • Outlook PCS does not modify any of the items that you place in the default contacts folder.
  • Outlook PCS also does not modify any of the actual items in the folders you specify to be synchronized.
  • Outlook PCS inserts the original folder name in the Categories field of the new items so you can sort or group by the items in Outlook. This lets you filter the items in Pocket Outlook once they are synchronized to your Pocket PC or Windows CE device.
  • You don?t need to run ActiveSync after running Outlook PCS — you can see if Outlook PCS worked correctly by checking your default contacts folder for new items synchronized from your specified folder(s). Each synchronized contact should also have the name of the original folder as a category for that item as well.

And it seems the birthday is not sync from the sub folder to the default folder

There is duplicated birthday reminder created by outlook 2003

(not solved yet)

How to count inode via ssh

Posted by Ivan Guan under Linux

If your provider allows you to ssh to your account, then once you are connected, all you have to do is type the following:

find . -printf “%i\n” | sort -u | wc -l

For more options you can visit http://www.olivetalks.com

Docx is the new file format of Word 2007 and this is the default format of Word 2007. This format cannot be opened in previous versions of Word unless you have the office compatibility pack installed. Incase you do not wish to install the compatibility pack, there are
online
converters
to do the job of converting to .doc format. Here is the list of top 3
online
converters.

1. Zamzar: Zamzar can
convert
variety of file formats and

Docx
is one of them. Select the file and format to be converted and enter your email id, the file will be converted and a link will be sent to your email ID for download.

2. Docx2Doc: As the name indicated, this service converts
docx
formats into doc files so that it can be viewed in
Word 2003 or lower. The major disadvantage with this service its that there is a one hour delay in downloading the converted files to reduce website bandwidth.

3. Docx Converter:  This is again a
good service
to
convert

Docx
file and the output file is in
html format so that it can be read in all systems. There is also a desktop widget for converting.

In case you just want to view a
docx
file, then there is a simpler way for this. Rename the extension of file from
.
docx
to .zip and then extract the contents.
Docx
is basically a set of xml files. When you unzip the file, you get a folder named Word and inside that you can see a file named
document.xml. To view the contents of the document, open document.xml.