:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ASSOCIATION MODULE V1.0 FOR OSC 2.2MS2
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Autor: oscdev@bluewin.ch
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
######### A L L G E M E I N E H I N W E I S E ###########
Dieses Modul wurde für osCommerce Version 2.2-MS2 erstellt
und getestet.
WICHTIG: - Vor der Installtion ein Backup der Datenbank und
des Shops durchführen.
Alle benötigten Files (auch diejenigen, die geändert werden
müssen) liegen bei.
###### I N S T A L L A T I O N S A N L E I T U N G ########
-----------------------------------------------------------
1) Änderungen an der Datenbank
-----------------------------------------------------------
Das beiliegende File /sql/association.sql ausführen.
Das Skript erstellt die folgenden Tabellen:
- associations
- associations_account
- associations_account_detail
- associations_account_payment
- associations_info
-----------------------------------------------------------
-----------------------------------------------------------
2) ADMIN: Konstanten für Datenbanktabellen erfassen
-----------------------------------------------------------
In der Datei admin/includes/database_tables.php folgendes
eintragen:
define('TABLE_ASSOCIATIONS', 'associations');
define('TABLE_ASSOCIATIONS_INFO', 'associations_info');
define('TABLE_ASSOCIATIONS_ACCOUNT', 'associations_account');
define('TABLE_ASSOCIATIONS_ACCOUNT_DETAIL', 'associations_account_detail');
define('TABLE_ASSOCIATIONS_ACCOUNT_PAYMENT', 'associations_account_payment');
-----------------------------------------------------------
3) ADMIN: Konstanten für Filenames erfassen
-----------------------------------------------------------
In der Datei admin/includes/filenames.php folgendes
eintragen:
define('FILENAME_ASSOCIATIONS', 'associations.php');
define('FILENAME_ASSOCIATIONS_ACCOUNT', 'associations_account.php') ;
define('FILENAME_ASSOCIATIONS_PAYMENT', 'associations_payment.php') ;
-----------------------------------------------------------
4) ADMIN: Konstanten für Ordner (Bilder) erfassen
-----------------------------------------------------------
In der Datei admin/includes/configure.php folgendes
eintragen:
define('DIR_WS_CATALOG_IMAGES_ASC', DIR_WS_CATALOG_IMAGES . 'associations/');
Unter "shop/images/" ein neues Verzeichnis "associations" erstellen
-----------------------------------------------------------
4) ADMIN: Benötigte Dateien
-----------------------------------------------------------
Die Dateien
- /admin/associations.php
- /admin/associations_account.php
- /admin/associations_payment.php
in das Verzeichnis admin/ kopieren
-----------------------------------------------------------
5) ADMIN: Sprachfiles
-----------------------------------------------------------
Die Dateien
- /admin/includes/languages/french/associations.php
- /admin/includes/languages/french/associations_account.php
- /admin/includes/languages/french/associations_payment.php
in das Verzeichnis admin/includes/languages/french/ kopieren
In der Datei /admin/includes/languages/french.php folgende
Zeilen einfügen:
define('BOX_HEADING_ASSOCIATIONS', 'Associations') ;
define('BOX_ASSOCIATIONS_ASSOCIATIONS', 'Associations');
define('BOX_ASSOCIATIONS_ACCOUNT', 'Compte');
define('BOX_ASSOCIATIONS_PAYMENT', 'Paiement');
-----------------------------------------------------------
6) ADMIN: neue Funktionen einfügen
-----------------------------------------------------------
In der Datei admin/includes/functions/general.php den
Inhalt der Datei admin/includes/functions/general.php
(siehe beiliegendes File) von Zeile 767 bis Zeile 889
einfügen. (start and ende sind markiert)
-----------------------------------------------------------
7) ADMIN: Menu auf Startseite ändern
-----------------------------------------------------------
In der Datei admin/index.php den Inhalt der Datei
admin/index.php (siehe beiliegendes File) von Zeile 48
bis Zeile 54 einfügen:
array('title' => BOX_HEADING_ASSOCIATIONS,
'image' => 'customers.gif',
'href' => tep_href_link(FILENAME_ASSOCIATIONS, 'selected_box=associations'),
'children' => array(array('title' => BOX_ASSOCIATIONS_ASSOCIATIONS, 'link' => tep_href_link(FILENAME_ASSOCIATIONS, 'selected_box=associations')),
array('title' => BOX_ASSOCIATIONS_ACCOUNT, 'link' => tep_href_link(FILENAME_ASSOCIATIONS_ACCOUNT, 'selected_box=associations')),
array('title' => BOX_ASSOCIATIONS_PAYMENT, 'link' => tep_href_link(FILENAME_ASSOCIATIONS_PAYMENT, 'selected_box=associations')))),
-----------------------------------------------------------
8) ADMIN: Association box
-----------------------------------------------------------
Die beiliegende Datei
- admin/includes/boxes/associations.php
in das Verzeichnis admin/includes/boxes/ kopieren.
-----------------------------------------------------------
9) ADMIN: Association box einfügen
-----------------------------------------------------------
In der Datei /admin/includes/column_left.php folgendes
einfügen:
require(DIR_WS_BOXES . 'associations.php');
-----------------------------------------------------------
10) ADMIN: Falls bestellungen gelöscht werden, den Konto
stand der Associations updaten
-----------------------------------------------------------
In der Datein /admin/orders.php innerhalb des
case 'deleteconfirm'-Blocks folgende Zeile einfügen
(ca. Zeile 80):
case 'deleteconfirm':
$oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
tep_remove_order($oID, $HTTP_POST_VARS['restock']);
//start modif: update association account
tep_remove_asc_transaction($oID) ;
//end modif
tep_redirect(tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action'))));
break;
-----------------------------------------------------------
11) SHOP: Konstanten für Datenbanktabellen erfassen
-----------------------------------------------------------
In der Datei ROOT_SHOP/includes/database_tables.php folgendes
eintragen:
define('TABLE_ASSOCIATIONS', 'associations');
define('TABLE_ASSOCIATIONS_INFO', 'associations_info');
define('TABLE_ASSOCIATIONS_ACCOUNT', 'associations_account');
define('TABLE_ASSOCIATIONS_ACCOUNT_DETAIL', 'associations_account_detail');
define('TABLE_ASSOCIATIONS_ACCOUNT_PAYMENT', 'associations_account_payment');
-----------------------------------------------------------
12) SHOP: neue Funktionen einfügen
-----------------------------------------------------------
In der Datei shop/includes/functions/general.php den
Inhalt der Datei shop/includes/functions/general.php
(siehe beiliegendes File) von Zeile 86 bis Zeile 116
einfügen. (start and ende sind markiert):
function tep_get_asc_base_amount($ord_id) {
$asc_query = tep_db_query("select sum(final_price) as base_amount from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$ord_id . "'");
$asc = tep_db_fetch_array($asc_query);
return $asc['base_amount'];
}
function tep_get_asc_percentage($asc_id) {
$asc_query = tep_db_query("select asc_percentage from " . TABLE_ASSOCIATIONS . " where asc_id = '" . (int)$asc_id . "'");
$asc = tep_db_fetch_array($asc_query);
return $asc['asc_percentage'];
}
function tep_get_asc_amount_total($asc_id) {
$asc_query = tep_db_query("select asc_amount_total from " . TABLE_ASSOCIATIONS_ACCOUNT . " where asc_id = '" . (int)$asc_id . "'");
$asc = tep_db_fetch_array($asc_query);
return $asc['asc_amount_total'];
}
function tep_get_asc_amount_balance($asc_id) {
$asc_query = tep_db_query("select asc_amount_balance from " . TABLE_ASSOCIATIONS_ACCOUNT . " where asc_id = '" . (int)$asc_id . "'");
$asc = tep_db_fetch_array($asc_query);
return $asc['asc_amount_balance'];
}
function tep_update_asc_account($asc_id, $amountToDebit){
$asc_query = tep_db_query("update " . TABLE_ASSOCIATIONS_ACCOUNT . " SET asc_amount_total = asc_amount_total + " . $amountToDebit . ", asc_amount_balance = asc_amount_balance + " . $amountToDebit . " where asc_id = '" . (int)$asc_id . "'");
}
-----------------------------------------------------------
12) SHOP: Sprachfiles anpassen
-----------------------------------------------------------
In der Datei /includes/languages/french/checkout_payment.php
folgende Zeilen einfügen:
define('HEADING_ASSOCIATION_TITLE', 'Choisissez l\'association');
define('TEXT_INTRO_ASSOCIATION', 'Faire profiter l\'association suivante d\'un pourcentage de mon achat:') ;
-----------------------------------------------------------
13) SHOP: Selectbox der Associations anzeigen
-----------------------------------------------------------
In der Datei /shop/checkout_payment.php ab ca. Zeile 329
folgendes einfügen (siehe auch beiliegendes File
"shop/checkout_payment.php"):
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><b><?php echo HEADING_ASSOCIATION_TITLE; ?></b></td>
</tr>
</table></td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
<tr class="infoBoxContents">
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><?php echo TEXT_INTRO_ASSOCIATION ?></td>
</tr>
<tr>
<td align="center">
<?php
$associations_query = tep_db_query("select pa.asc_id, pd.asc_name from " . TABLE_ASSOCIATIONS . " pa, " . TABLE_ASSOCIATIONS_INFO . " pd where pa.asc_id = pd.asc_id and pa.asc_status = 1 and pd.language_id = '" . (int)$languages_id . "'") ;
echo '<select name="associations">' ;
while ($associations = tep_db_fetch_array($associations_query)) {
echo '<option value="' . $associations['asc_id'] . '"' ;
echo '>' . $associations['asc_name'] . '</option>' ;
}//end while
echo '</select>' . "\n";
echo '</td>' . "\n";
echo '</tr>' . "\n";
?>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<?php
/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
?>
-----------------------------------------------------------
13) SHOP: Ausgewählte Association in Session speichern:
-----------------------------------------------------------
In der Datei /shop/checkout_confirmation.php folgende Zeile
eintragen (ab ca. Zeile 48) (siehe auch beiliegendes File):
if (!tep_session_is_registered('associations')) tep_session_register('associations');
if (isset($HTTP_POST_VARS['associations']))
$associations = $HTTP_POST_VARS['associations'];
-----------------------------------------------------------
14) SHOP: Association-Konto nach Bestellung updaten
-----------------------------------------------------------
In der Datei /shop/checkout_process.php folgende Zeile
eintragen (ab ca. Zeile 254) (siehe auch beiliegendes File):
$amountToDebit = (tep_get_asc_base_amount($insert_id) / 100) * tep_get_asc_percentage($associations) ;
//1. insert account detail
$sql_data_array = array('asc_id' => $associations,
'asc_ord_id' => $insert_id,
'asc_date_purchased' => 'now()',
'asc_amount' => $amountToDebit,
'asc_order_total_amount' => tep_get_asc_base_amount($insert_id)) ;
tep_db_perform(TABLE_ASSOCIATIONS_ACCOUNT_DETAIL, $sql_data_array);
//3. Re-Balance account
tep_update_asc_account($associations, $amountToDebit) ;
Und am Schluss (ca. Zeile 328) noch folgende Zeile einfügen,
um die Session-Variable zu löschen:
tep_session_unregister('associations');
###################### E N D E #########################