From 0c83bf477988362fedafb5849393722b045ed26c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Oct 2010 00:12:54 +0000 Subject: [PATCH] Work on module paypal --- .../modules/DolibarrModules.class.php | 12 +- htdocs/includes/modules/modPaybox.class.php | 2 +- htdocs/includes/modules/modPaypal.class.php | 226 ++++++++++++++++++ htdocs/install/inc.php | 20 ++ htdocs/install/upgrade2.php | 8 + htdocs/langs/en_US/paypal.lang | 4 + htdocs/langs/fr_FR/paypal.lang | 4 + htdocs/master.inc.php | 2 +- htdocs/paybox/admin/paybox.php | 48 ++-- htdocs/paypal/admin/paypal.php | 191 +++++++++++++++ htdocs/paypal/{images => img}/.cvsignore | 0 htdocs/paypal/{images => img}/paypal.png | Bin 12 files changed, 486 insertions(+), 31 deletions(-) create mode 100644 htdocs/includes/modules/modPaypal.class.php create mode 100644 htdocs/langs/en_US/paypal.lang create mode 100644 htdocs/langs/fr_FR/paypal.lang create mode 100644 htdocs/paypal/admin/paypal.php rename htdocs/paypal/{images => img}/.cvsignore (100%) rename htdocs/paypal/{images => img}/paypal.png (100%) diff --git a/htdocs/includes/modules/DolibarrModules.class.php b/htdocs/includes/modules/DolibarrModules.class.php index fb594b29066..120961170ee 100644 --- a/htdocs/includes/modules/DolibarrModules.class.php +++ b/htdocs/includes/modules/DolibarrModules.class.php @@ -477,16 +477,18 @@ class DolibarrModules /** - * \brief Create tables and keys required by module - * Files module.sql and module.key.sql with create table and create keys - * commands must be stored in directory reldir='/module/sql/' - * This function is called by this->init. - * \return int <=0 if KO, >0 if OK + * Create tables and keys required by module. + * Files module.sql and module.key.sql with create table and create keys + * commands must be stored in directory reldir='/module/sql/' + * This function is called by this->init. + * @return int <=0 if KO, >0 if OK */ function _load_tables($reldir) { global $db,$conf; + $error=0; + include_once(DOL_DOCUMENT_ROOT ."/lib/admin.lib.php"); $ok = 1; diff --git a/htdocs/includes/modules/modPaybox.class.php b/htdocs/includes/modules/modPaybox.class.php index 37216b9ddb2..a9f5e82ac6b 100644 --- a/htdocs/includes/modules/modPaybox.class.php +++ b/htdocs/includes/modules/modPaybox.class.php @@ -45,7 +45,7 @@ class modPayBox extends DolibarrModules // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 10000; + $this->numero = 50000; // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'paybox'; diff --git a/htdocs/includes/modules/modPaypal.class.php b/htdocs/includes/modules/modPaypal.class.php new file mode 100644 index 00000000000..c43c6fd9f90 --- /dev/null +++ b/htdocs/includes/modules/modPaypal.class.php @@ -0,0 +1,226 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** \defgroup paybox Module paypal + * \brief Add integration with Paypal online payment system. + */ + +/** + * \file htdocs/includes/modules/modPaypal.class.php + * \ingroup mymodule + * \brief Description and activation file for module Paypal + * \version $Id$ + */ +include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php"); + + +/** \class modPaypal + * \brief Description and activation class for module Paypal + */ +class modPaypal extends DolibarrModules +{ + /** + * \brief Constructor. Define names, constants, directories, boxes, permissions + * \param DB Database handler + */ + function modPaypal($DB) + { + $this->db = $DB; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 50200; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'paypal'; + + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "other"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i','',get_class($this)); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "Module to offer an online payment page by credit card with PayPal"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'development'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Where to store the module in setup page (0=common,1=interface,2=other) + $this->special = 1; + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png' + $this->picto=DOL_URL_ROOT.'/paypal/img/paypal.png'; + + // Data directories to create when module is enabled. + $this->dirs = array('/paypal/temp'); + + // Relative path to module style sheet if exists. Example: '/mymodule/mycss.css'. + $this->style_sheet = ''; + + // Config pages. Put here list of php page names stored in admmin directory used to setup module. + $this->config_page_url = array("paypal.php@paypal"); + + // Dependencies + $this->depends = array(); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->phpmin = array(4,1); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(3,0,-2); // Minimum version of Dolibarr required by module + $this->langfiles = array("paybox"); + + // Constants + $this->const = array(); // List of particular constants to add when module is enabled + //Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0), + // 1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) ); + + // New pages on tabs + $this->tabs = array(); + + + // Boxes + $this->boxes = array(); // List of boxes + $r=0; + + // Add here list of php file(s) stored in includes/boxes that contains class to show a box. + // Example: + //$this->boxes[$r][1] = "myboxa.php"; + //$r++; + //$this->boxes[$r][1] = "myboxb.php"; + //$r++; + + + // Permissions + $this->rights = array(); // Permission array used by this module + $r=0; + + // Add here list of permission defined by an id, a label, a boolean and two constant strings. + // Example: + // $this->rights[$r][0] = 2000; // Permission id (must not be already used) + // $this->rights[$r][1] = 'Permision label'; // Permission label + // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + // $r++; + + + // Main menu entries + $this->menus = array(); // List of menus to add + $r=0; + + // Add here entries to declare new menus + // Example to declare the Top Menu entry: + // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu + // 'type'=>'top', // This is a Top menu entry + // 'titre'=>'MyModule top menu', + // 'mainmenu'=>'mymodule', + // 'leftmenu'=>'1', // Use 1 if you also want to add left menu entries using this descriptor. Use 0 if left menu entries are defined in a file pre.inc.php (old school). + // 'url'=>'/mymodule/pagetop.php', + // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + // + // Example to declare a Left Menu entry: + // $this->menu[$r]=array( 'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) + // 'type'=>'left', // This is a Left menu entry + // 'titre'=>'MyModule left menu 1', + // 'mainmenu'=>'mymodule', + // 'url'=>'/mymodule/pagelevel1.php', + // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + // + // Example to declare another Left Menu entry: + // $this->menu[$r]=array( 'fk_menu'=>'r=1', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) + // 'type'=>'left', // This is a Left menu entry + // 'titre'=>'MyModule left menu 2', + // 'mainmenu'=>'mymodule', + // 'url'=>'/mymodule/pagelevel2.php', + // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + + + // Exports + $r=1; + + // Example: + // $this->export_code[$r]=$this->rights_class.'_'.$r; + // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + // $this->export_permission[$r]=array(array("facture","facture","export")); + // $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'); + // $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'); + // $this->export_alias_array[$r]=array('s.rowid'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.cp'=>'soc_zip','s.ville'=>'soc_ville','s.fk_pays'=>'soc_pays','s.tel'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','s.code_compta'=>'soc_customer_accountancy','s.code_compta_fournisseur'=>'soc_supplier_accountancy','f.rowid'=>"invoiceid",'f.facnumber'=>"ref",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice",'f.total'=>"totalht",'f.total_ttc'=>"totalttc",'f.tva'=>"totalvat",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid','fd.description'=>"linedescription",'fd.price'=>"lineprice",'fd.total_ht'=>"linetotalht",'fd.total_tva'=>"linetotaltva",'fd.total_ttc'=>"linetotalttc",'fd.tva_tx'=>"linevatrate",'fd.qty'=>"lineqty",'fd.date_start'=>"linedatestart",'fd.date_end'=>"linedateend",'fd.fk_product'=>'productid','p.ref'=>'productref'); + // $this->export_sql_start[$r]='SELECT DISTINCT '; + // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; + // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; + // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; + // $r++; + } + + /** + * \brief Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories. + * \return int 1 if OK, 0 if KO + */ + function init() + { + $sql = array(); + + $result=$this->load_tables(); + + return $this->_init($sql); + } + + /** + * \brief Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted. + * \return int 1 if OK, 0 if KO + */ + function remove() + { + $sql = array(); + + return $this->_remove($sql); + } + + + /** + * \brief Create tables and keys required by module + * Files mymodule.sql and mymodule.key.sql with create table and create keys + * commands must be stored in directory /mymodule/sql/ + * This function is called by this->init. + * \return int <=0 if KO, >0 if OK + */ + function load_tables() + { + return $this->_load_tables('/paybox/sql/'); + } +} + +?> diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 9f335166a0c..bf17d4ff35c 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -120,6 +120,14 @@ if (! isset($dolibarr_main_db_prefix) || ! $dolibarr_main_db_prefix) $dolibarr_m define('MAIN_DB_PREFIX',(isset($dolibarr_main_db_prefix)?$dolibarr_main_db_prefix:'')); define('DOL_DATA_ROOT',(isset($dolibarr_main_data_root)?$dolibarr_main_data_root:'')); +define('DOL_CLASS_PATH', 'class/'); // Filsystem path to class dir +define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root)?$dolibarr_main_url_root:'')); // URL relative root +$uri=preg_replace('/^http(s?):\/\//i','',constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http* +$suburi = strstr ($uri, '/'); // $suburi contains url without domain +if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now '' +define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...) + + if (empty($conf->file->character_set_client)) $conf->file->character_set_client="UTF-8"; if (empty($conf->db->character_set)) $conf->db->character_set='utf8'; if (empty($conf->db->dolibarr_main_db_collation)) $conf->db->dolibarr_main_db_collation='utf8_general_ci'; @@ -127,6 +135,18 @@ if (empty($conf->db->dolibarr_main_db_encryption)) $conf->db->dolibarr_main_db_ if (empty($conf->db->dolibarr_main_db_cryptkey)) $conf->db->dolibarr_main_db_cryptkey=''; if (empty($conf->db->user)) $conf->db->user=''; +// Define array of document root directories +$conf->file->dol_document_root=array(DOL_DOCUMENT_ROOT); +if (! empty($dolibarr_main_document_root_alt)) +{ + // dolibarr_main_document_root_alt contains several directories + $values=preg_split('/[;,]/',$dolibarr_main_document_root_alt); + foreach($values as $value) + { + $conf->file->dol_document_root[]=$value; + } +} + // Security check if (preg_match('/install.lock/i',$_SERVER["SCRIPT_FILENAME"])) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 4d58fe78fff..82fde12199a 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -3262,6 +3262,14 @@ function migrate_reload_modules($db,$langs,$conf) //$mod->remove('noboxes'); // We need to remove because a permission id has been removed $mod->init(); } + if (! empty($conf->global->MAIN_MODULE_PAYBOX)) // Permission has changed into 3.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Paybox"); + require_once(DOL_DOCUMENT_ROOT.'/includes/modules/modPaybox.class.php'); + $mod=new modPaybox($db); + $mod->remove('noboxes'); // We need to remove because id of module has changed + $mod->init(); + } } diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang new file mode 100644 index 00000000000..3851ec9b1b1 --- /dev/null +++ b/htdocs/langs/en_US/paypal.lang @@ -0,0 +1,4 @@ +# Dolibarr language file - en_US - paypal +CHARSET=UTF-8 +PaypalSetup=PayPal module setup +PaypalDesc=This module offer pages to allow payment on PayPal by customers. This can be used for a free payment or for a payment on a particular Dolibarr object (invoice, order, ...) \ No newline at end of file diff --git a/htdocs/langs/fr_FR/paypal.lang b/htdocs/langs/fr_FR/paypal.lang new file mode 100644 index 00000000000..6d51fa7938c --- /dev/null +++ b/htdocs/langs/fr_FR/paypal.lang @@ -0,0 +1,4 @@ +# Dolibarr language file - fr_FR - paypal +CHARSET=UTF-8 +PaypalSetup=Configuration module PayPal +PaypalDesc=Ce module permet d'offrir une page de paiement via le prestataire Paypal pour réaliser un paiement quelconque ou un paiement par rapport à un objet Dolibarr (factures, commande...) diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index a17b55e7ead..5dc3931eff4 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -110,7 +110,7 @@ if ($dolibarr_main_url_root == 'auto' && ! empty($_SERVER["SCRIPT_URL"]) && ! em $dolibarr_main_url_root=str_replace($_SERVER["SCRIPT_URL"],'',$_SERVER["SCRIPT_URI"]); } define('DOL_MAIN_URL_ROOT', $dolibarr_main_url_root); // URL relative root -$uri=preg_replace('/^http(s?):\/\//i','',$dolibarr_main_url_root); // $uri contains url without http* +$uri=preg_replace('/^http(s?):\/\//i','',constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http* $suburi = strstr ($uri, '/'); // $suburi contains url without domain if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now '' define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...) diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php index 8b8029754d2..921b24d5497 100644 --- a/htdocs/paybox/admin/paybox.php +++ b/htdocs/paybox/admin/paybox.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Laurent Destailleur + * Copyright (C) 2005-2010 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -91,29 +91,6 @@ print ''.$langs->trans("Parameter").''; print ''.$langs->trans("Value").''; print "\n"; -/* -$var=!$var; -print ''; -print $langs->trans("PAYBOX_IBS_DEVISE").''; -print ''; -print '
'.$langs->trans("Example").': 978 (EUR)'; -print ''; -*/ - -$var=!$var; -print ''; -print $langs->trans("PAYBOX_CSS_URL").''; -print ''; -print '
'.$langs->trans("Example").': http://mysite/mycss.css'; -print ''; - -$var=!$var; -print ''; -print $langs->trans("PAYBOX_CREDITOR").''; -print ''; -print '
'.$langs->trans("Example").': '.$mysoc->nom; -print ''; - /* $var=!$var; print ''; @@ -151,6 +128,29 @@ print 'trans("Test").')'; print ''; +/* +$var=!$var; +print ''; +print $langs->trans("PAYBOX_IBS_DEVISE").''; +print ''; +print '
'.$langs->trans("Example").': 978 (EUR)'; +print ''; +*/ + +$var=!$var; +print ''; +print $langs->trans("PAYBOX_CREDITOR").''; +print ''; +print '
'.$langs->trans("Example").': '.$mysoc->nom; +print ''; + +$var=!$var; +print ''; +print $langs->trans("PAYBOX_CSS_URL").''; +print ''; +print '
'.$langs->trans("Example").': http://mysite/mycss.css'; +print ''; + print ''; print ''; diff --git a/htdocs/paypal/admin/paypal.php b/htdocs/paypal/admin/paypal.php new file mode 100644 index 00000000000..05d61adf1b1 --- /dev/null +++ b/htdocs/paypal/admin/paypal.php @@ -0,0 +1,191 @@ + + * Copyright (C) 2005-2010 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** \file htdocs/paypal/admin/paypal.php + * \ingroup paypal + * \brief Page to setup paypal module + * \version $Id$ + */ + +require("../../main.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); + +$servicename='PayPal'; + +$langs->load("admin"); +$langs->load("paypal"); +$langs->load("paybox"); + +if (!$user->admin) + accessforbidden(); + + +if ($_POST["action"] == 'setvalue' && $user->admin) +{ + //$result=dolibarr_set_const($db, "PAYPAL_IBS_DEVISE",$_POST["PAYPAL_IBS_DEVISE"],'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "PAYPAL_CSS_URL",$_POST["PAYPAL_CSS_URL"],'chaine',0,'',$conf->entity); +/* $result=dolibarr_set_const($db, "PAYPAL_CREDITOR",$_POST["PAYPAL_CREDITOR"],'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "PAYPAL_CGI_URL_V1",$_POST["PAYPAL_CGI_URL_V1"],'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "PAYPAL_CGI_URL_V2",$_POST["PAYPAL_CGI_URL_V2"],'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "PAYPAL_IBS_SITE",$_POST["PAYPAL_IBS_SITE"],'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "PAYPAL_IBS_RANG",$_POST["PAYPAL_IBS_RANG"],'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "PAYPAL_PBX_IDENTIFIANT",$_POST["PAYPAL_PBX_IDENTIFIANT"],'chaine',0,'',$conf->entity); +*/ + $result=dolibarr_set_const($db, "PAYPAL_API_SANDBOX",$_POST["PAYPAL_API_SANDBOX"],'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "PAYPAL_API_INTEGRAL",$_POST["PAYPAL_API_INTEGRAL"],'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "PAYPAL_API_USER",$_POST["PAYPAL_API_USER"],'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "PAYPAL_API_PASSWORD",$_POST["PAYPAL_API_PASSWORD"],'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, "PAYPAL_API_SIGNATURE",$_POST["PAYPAL_API_SIGNATURE"],'chaine',0,'',$conf->entity); + + if ($result >= 0) + { + $mesg='
'.$langs->trans("SetupSaved").'
'; + } + else + { + dol_print_error($db); + } +} + + +/* + * View + */ + +$form=new Form($db); + +$IBS_SITE="1999888"; # Site test +if (empty($conf->global->PAYPAL_IBS_SITE)) $conf->global->PAYPAL_IBS_SITE=$IBS_SITE; +$IBS_RANG="99"; # Rang test +if (empty($conf->global->PAYPAL_IBS_RANG)) $conf->global->PAYPAL_IBS_RANG=$IBS_RANG; +$IBS_DEVISE="978"; # Euro +if (empty($conf->global->PAYPAL_IBS_DEVISE)) $conf->global->PAYPAL_IBS_DEVISE=$IBS_DEVISE; + +llxHeader(); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("PaypalSetup"),$linkback,'setup'); + +print $langs->trans("PaypalDesc")."
\n"; + + +if ($mesg) print '
'.$mesg; + +print '
'; +print '
'; +print ''; +print ''; + +$var=true; + +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + +$var=!$var; +print ''; + + +print ''; +print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; +print ''.$langs->trans("PAYPAL_API_USER").''; +print ''; +print '
'.$langs->trans("Example").': paypal_api1.mywebsite.com'; +print '
'; +print ''.$langs->trans("PAYPAL_API_PASSWORD").''; +print ''; +print '
'; +print ''.$langs->trans("PAYPAL_API_SIGNATURE").''; +print ''; +print '
'.$langs->trans("Example").': ASsqXEmw4KzmX-CPChWSVDNCNfd.A3YNR7uz-VncXXAERFDFDFDF'; +print '
'; +print ''.$langs->trans("PAYPAL_API_INTEGRAL_OR_PAYPALONLY").''; +print $form->selectyesno("PAYPAL_API_INTEGRAL_OR_PAYPALONLY",$conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY); +print '
'; +print ''.$langs->trans("PAYPAL_API_EXPRESS").''; +print $form->selectyesno("PAYPAL_API_EXPRESS",$conf->global->PAYPAL_API_EXPRESS); +print '
'; +print $langs->trans("PAYPAL_API_SANDBOX").''; +print $form->selectyesno("PAYPAL_API_SANDBOX",$conf->global->PAYPAL_API_SANDBOX); +print '
'; +print $langs->trans("PAYPAL_CSS_URL").''; +print ''; +print '
'.$langs->trans("Example").': http://mysite/mycss.css'; +print '
'; + +print '

'; + +print ''.$langs->trans("FollowingUrlAreAvailableToMakePayments").':
'; +// Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr' +$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root); +print '
'; +print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount",$servicename).':
'; +print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/newpayment.php?amount=9.99&tag=your_free_tag'."
\n"; +print '
'; +if ($conf->commande->enabled) +{ + print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':
'; + print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/newpayment.php?amount=order&ref=order_ref'."
\n"; + print '
'; +} +if ($conf->facture->enabled) +{ + print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice",$servicename).':
'; + print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/newpayment.php?amount=invoice&ref=invoice_ref'."
\n"; +// print $langs->trans("SetupPaypalToHavePaymentCreatedAutomatically",$langs->transnoentitiesnoconv("FeatureNotYetAvailable"))."
\n"; + print '
'; +} +if ($conf->contrat->enabled) +{ + print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine",$servicename).':
'; + print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/newpayment.php?amount=contractline&ref=contractline_ref'."
\n"; + print '
'; +} +if ($conf->adherent->enabled) +{ + print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription",$servicename).':
'; + print ''.$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/newpayment.php?amount=membersubscription&ref=member_ref'."
\n"; + print '
'; +} +print $langs->trans("YouCanAddTagOnUrl"); + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/paypal/images/.cvsignore b/htdocs/paypal/img/.cvsignore similarity index 100% rename from htdocs/paypal/images/.cvsignore rename to htdocs/paypal/img/.cvsignore diff --git a/htdocs/paypal/images/paypal.png b/htdocs/paypal/img/paypal.png similarity index 100% rename from htdocs/paypal/images/paypal.png rename to htdocs/paypal/img/paypal.png