Aller à : navigation, rechercher

Add document collection

Add a collection on your maarch V3

To add a document collection you need to know the type. There are two collections we will refer to: the invoice collection and the file collection. These two collections have different logic on their scripts, their tables in the database as well as on their XML schema. So it is vital to know the type of collection you want to add before starting.

Adding a new collection on Maarch V3

To add a new collection you first need to create the table corresponding to your collection then add the collection on the config.xml file and create the php files before adding the collection to the language file and finally add it to the research index. So let’s see how it works step by step in five easy steps.

Step 1: Create a table for your collection on your database

A collection must have a table named res_collection_name and a view res_view_collection_name.

Step 2: Add the collection on config.xml

 …\xampp\htdocs\Maarch_v3\apps\maarch_sample\xml\config.xml

The two collections that were already created will appear as follow:

The file collection:

<COLLECTION>
<id>coll_1</id>
<label>_DOCUMENTS</label>
<table>res_x</table>
<view>res_view</view>
<index_file>index.xml</index_file>
<script_add>index_documents.php</script_add>
<script_search>search_with_folder.php</script_search>
<script_search_result>list_results_documents.php</script_search_result>
<script_details>details_documents.php</script_details>
</COLLECTION>
</pre>
The invoice collection:
<pre>
<COLLECTION>
<id>coll_2</id>
<label>_INVOICES</label>
<table>res_invoices</table>
<view>res_view_invoices</view>
<index_file>index2.xml</index_file>
<script_add>index_invoices.php</script_add>
<script_search>search_without_folder.php</script_search>
<script_search_result>list_results_invoices.php</script_search_result>
<script_details>details_invoices.php</script_details>
</COLLECTION>

You will realise that for the file collection we did not choose to put a name. So for the table name we chose res_x and the view res_view. As for the invoice it is clearly res_invoice and the view res_view_invoice.

So for a new collection it has to be:

<COLLECTION>
<id>coll_3</id>
<label>_new_collection_name</label>
<table>res_new_collection_name</table>
<view>res_view_ new_collection_name </</view>
<index_file>index3.xml</index_file>
<script_add>index_ new_collection_name.php </.php</script_add>
<script_search>search_without_folder.php</script_search>
<script_search_result>list_results_new_collection_name</.php</script_search_result>
<script_details>details_ new_collection_name.php </.php</script_details>
</COLLECTION>

Step 3: Add the php files (index and details)

There are two php files to be added index_new_collection_name.php and details_new_collection_name.php. You can edit the files of one the previous collection that correspond to the type of collection you want to add.

Step 4: Add the collection on the language file

You will now modify the following file:

  …\xampp\htdocs\Maarch_v3\apps\maarch_sample\en.php

You will find on comment the label:

//COLLECTIONS
<pre>
define('_MAILS', 'Mails');
define('_DOCUMENTS', 'Real States Files');
define('_INVOICES', 'Invoice');
define('_NEW_COLLECTION', 'New_collection_name');
define('_CHOOSE_COLLECTION', 'Choose a collection');
</pre>
You will also need to define the indexing searching from the language file:
<pre>
define('_MODIFY_RESOURCE', 'Document index modification right');
define('_DELETE_RESOURCE', 'Document deletion right');
define('_INDEX_FILE', 'Document indexing right');
define('_INDEX_FILE_DOC', 'New document indexing right');
define('_INDEX_FILE_INV', 'New invoice indexing right');
define('_INDEX_FILE__(the first letters of the collection name in capital)', 'New
new_collection_name indexing right');
</pre>

Step 5: Indexing the new collection for research

You will first need to create a service. To do so open the following file:

 …\xampp\htdocs\Maarch_v3\modules\indexing_searching\xml\services.xml

The collection service has two tags. The first one is as follow for the invoice collection:

<pre>
<SERVICE>
<id>select_doctype2</id>
<name>_SELECT_DOCTYPE2</name>
<comment>_SELECT_DOCTYPE</comment>
<servicepage>select_type2.php</servicepage>
<servicetype>use</servicetype>
<enabled>true</enabled>
<WHEREAMIUSED>
<page>index_invoices.php</page>
<nature>frame</nature>
<width>400</width>
<height>80</height>
<scrolling>no</scrolling>
<border>0</border>
</WHEREAMIUSED>
</SERVICE>
</pre>

So our new collection’s first service tag has to be something like:

<pre>
<SERVICE>
<id>select_doctype2</id>
<name>_SELECT_DOCTYPE2</name>
<comment>_SELECT_DOCTYPE</comment>
<servicepage>select_type3.php</servicepage>
<servicetype>use</servicetype>
<enabled>true</enabled>
<WHEREAMIUSED>
<page>index_new_collection_name.php</page>
<nature>frame</nature>
<width>400</width>
<height>80</height>
<scrolling>no</scrolling>
<border>0</border>
</WHEREAMIUSED>
</SERVICE>
</pre>

Then there is the second tag that contains the subs <WHEREAMIUSED> and <PROCESSINBACKGROUND>.

For the invoice collection the second tag is as:

<pre>
<SERVICE>
<id>index_file2</id>
<name>_INDEX_FILE_INV</name>
<comment>_INDEX_FILE</comment>
<servicepage>res_type2.php</servicepage>
<servicetype>use</servicetype>
<enabled>true</enabled>
<WHEREAMIUSED>
<page>index_invoices.php</page>
<nature>frame</nature>
<width>515</width>
<height>350</height>
<scrolling>auto</scrolling>
<border>0</border>
</WHEREAMIUSED>
<PROCESSINBACKGROUND>
<page>file_index2.php</page>
<preprocess>res_type2_result_preprocess.php</preprocess>
<processorder>1</processorder>
</PROCESSINBACKGROUND>
</SERVICE>
</pre>

So the new collection’s one should be more like:

<pre>
<SERVICE>
<id>index_file3</id>
<name>_INDEX_FILE_(the first letters of the collection name in capitals)</name>
<comment>_INDEX_FILE</comment>
<servicepage>res_type3.php</servicepage>
<servicetype>use</servicetype>
<enabled>true</enabled>
<WHEREAMIUSED>
<page>index_new_collection_name.php</page>
<nature>frame</nature>
<width>515</width>
<height>350</height>
<scrolling>auto</scrolling>
<border>0</border>
</WHEREAMIUSED>
<PROCESSINBACKGROUND>
<page>file_index3.php</page>
<preprocess>res_type3_result_preprocess.php</preprocess>
<processorder>1</processorder>
</PROCESSINBACKGROUND>
</SERVICE>
</pre>