Skip to content

Commit

Permalink
Merge pull request #35 from Eoxia/1.2.0
Browse files Browse the repository at this point in the history
1.2.0
  • Loading branch information
nicolas-eoxia authored Sep 6, 2021
2 parents 184ad8c + 0b293f9 commit 6aac200
Show file tree
Hide file tree
Showing 38 changed files with 1,605 additions and 89 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.idea
.tx
.editorconfig
test
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

14 changes: 0 additions & 14 deletions .idea/deployment.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

15 changes: 0 additions & 15 deletions .idea/webServers.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .tx/config

This file was deleted.

22 changes: 21 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# CHANGELOG WPSHOP FOR <a href="https://www.dolibarr.org">DOLIBARR ERP CRM</a>

## 0.1.0
# 1.2.0
- Création d'un Utilisateur API avec affectation des droits limité pour préserver une sécurité optimale.
- Rajout de fichier index pour éviter de naviguer librement dans les fichiers du module.
- Rajout du flux de création automatique sur les propositions commerciales, commande, facture et paiements.
- Rajout de traduction.
- Réalisation d'une page personnaliser de paiment en ligne.
- Création et configuration des traductions d'un produit. (description,titre)
- Synchronisation avec les informations du plugins de traductions WPML sur Wordpress.
- Création d'un post relatif à la traduction du produit Dolibarr sur Wordpress.

#1.1.1
Modifications DOL_DOCUMENT_ROOT en include_once
WPshop ID sur les produits unique

#1.1.0
Rajout des la synchronisation direct des médias
Corrections de nombreux bugs

## 1.0.0
Initial version



45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
# DoliWPshop
# DoliWPshop pour [DOLIBARR ERP CRM](https://www.dolibarr.org)

Module for Dolibarr ERP/CRM to connect WPshop Plugin from WordPress.
Module pour Dolibarr ERP/CRM connecté le plugin WPshop de WordPress.

## Fonctionnalités

- Connecter le plugin WPshop de WordPress et l'ERP/CRM Dolibarr.
-Synchronisation des produits, tiers et médias.
- Utilisation du service de paiement en ligne Dolibarr.
- Récupération des documents et images lié au produits.
- Flux de création automatique sur les propositions commerciales, commande, facture et paiements.

Retrouver d'autre module développée par [EOXIA](https://www.eoxia.com/) sur [Dolistore.com](https://www.dolistore.com).

## Traduction

La traduction de ce module peut être définie manuellement en éditant les fichiers dans le dossier *langs*.

## Installation

### Méthode 1 :

- Depuis le menu "Déployer/Installer un module externe" de Dolibarr :
- Glisser l'archive ZIP 'module_doliwpshop-x.x.x' et cliquer sur "ENVOYER"
- Activer le module dans la liste des Modules/Applications installés

### Méthode 2 :

- Dans le dossier "dolibarr/htdocs/custom" copier la ligne suivante :
```
git clone https://github.com/Eoxia/doliwpshop.git
```

## Licenses

Ce module est publié sous licence AGPLv3.

### Documentation

Le wiki de ce module est accessible sur la page suivante :
https://wiki.dolibarr.org/index.php/Module_DoliWPshop

La documentation de ce module est accessible sur la page suivante :
https://wpshop.fr/documentation/
77 changes: 74 additions & 3 deletions admin/doliwpshop.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,77 @@
if (! $user->admin) accessforbidden();

// Parameters
$action = GETPOST('action', 'alpha');
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$value = GETPOST('value', 'alpha');

$arrayofparameters = array(
'WPSHOP_URL_WORDPRESS' => array('css'=> 'minwidth500', 'enabled' => 1),
'WPSHOP_TOKEN' => array('css'=> 'minwidth500', 'enabled'=> 1)
'WPSHOP_URL_WORDPRESS' => array('css'=> 'minwidth500', 'enabled' => 1),
'WPSHOP_TOKEN' => array('css'=> 'minwidth500', 'enabled'=> 1),
);

$userapi = new User($db);
$userapi->fetch($conf->global->DOLIWPSHOP_USERAPI_SET,'', '',0,$conf->entity);
$userapi->getrights();
//Rights invoices
$userapi->rights->facture->lire ? 1 : $userapi->addrights(11);
$userapi->rights->facture->creer ? 1 : $userapi->addrights(12);
$userapi->rights->facture->paiment ? 1 : $userapi->addrights(16);
//Rights propals
$userapi->rights->propale->lire ? 1 : $userapi->addrights(21);
$userapi->rights->propale->creer ? 1 : $userapi->addrights(22);
$userapi->rights->propale->cloturer ? 1 : $userapi->addrights(26);
//Rights products
$userapi->rights->produit->lire ? 1 : $userapi->addrights(31);
$userapi->rights->produit->creer ? 1 : $userapi->addrights(32);
//Rights orders
$userapi->rights->commande->lire ? 1 : $userapi->addrights(81);
$userapi->rights->commande->creer ? 1 : $userapi->addrights(82);
//Rights tiers
$userapi->rights->societe->lire ? 1 : $userapi->addrights(121);
$userapi->rights->societe->creer ? 1 : $userapi->addrights(122);
$userapi->rights->societe->supprimer ? 1 : $userapi->addrights(125);
$userapi->rights->societe->exporter ? 1 : $userapi->addrights(126);
$userapi->rights->societe->client->voir ? 1 : $userapi->addrights(262);
$userapi->rights->societe->contact->lire ? 1 : $userapi->addrights(281);
//Rights tags
$userapi->rights->categorie->lire ? 1 : $userapi->addrights(241);
$userapi->rights->categorie->creer ? 1 : $userapi->addrights(242);
//Rights services
$userapi->rights->service->lire ? 1 : $userapi->addrights(531);
$userapi->rights->service->creer ? 1 : $userapi->addrights(532);
//Rights stocks
$userapi->rights->stock->lire ? 1 : $userapi->addrights(1001);
//Rights events
$userapi->rights->agenda->myactions->read ? 1 : $userapi->addrights(2401);
$userapi->rights->propale->myactions->create ? 1 : $userapi->addrights(2402);
$userapi->rights->propale->myactions->delete ? 1 : $userapi->addrights(2403);

/*
* Actions
*/
if ((float) DOL_VERSION >= 6) {
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
}

if (($action == 'update' && !GETPOST("cancel", 'alpha')) || ($action == 'updateedit'))
{
$WPSHOP_URL_WORDPRESS = GETPOST('WPSHOP_URL_WORDPRESS','alpha');
$data_archive_on_deletion = GETPOST('data_archive_on_deletion','alpha');

$link = '<a href="'.$WPSHOP_URL_WORDPRESS.'">'.$langs->trans("PaymentMessage").'</a>';

dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_OK", $link, 'integer', 0, '', $conf->entity);

dolibarr_set_const($db, "WPSHOP_DATA_ARCHIVE_ON_DELETION", $data_archive_on_deletion, 'integer', 0, '', $conf->entity);

if ($action != 'updateedit' && !$error)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
}

// @todo: Statut en status
$connected = WPshopAPI::get('/wp-json/wpshop/v2/statut');

Expand Down Expand Up @@ -86,6 +142,12 @@
print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip'));
print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '"></td></tr>';
}

print '<tr><td>'.$langs->trans("DataArchiveOnDeletion").'</td><td>';
print '<input type="checkbox" id="data_archive_on_deletion" name="data_archive_on_deletion" '.($conf->global->WPSHOP_DATA_ARCHIVE_ON_DELETION ? ' checked=""' : '').'';
print '</td></tr>';


print '</table>';

print '<br><div class="center">';
Expand Down Expand Up @@ -113,6 +175,15 @@
echo $langs->trans("FailureWordPress");
}
print '</td></tr>';

print '<tr><td>'.$langs->trans("DataArchiveOnDeletion").'</td><td>';
print '<input type="checkbox" id="data_archive_on_deletion" name="data_archive_on_deletion" '.($conf->global->WPSHOP_DATA_ARCHIVE_ON_DELETION ? ' checked=""' : '').' disabled>';
print '</td></tr>';

print '<tr><td>'.$langs->trans("ActivateTranslateLink").'</td><td>';
print '<a href="'.DOL_MAIN_URL_ROOT.'/admin/ihm.php?mainmenu=home" target="_blank">'.DOL_MAIN_URL_ROOT.'/admin/ihm.php?mainmenu=home</a>';
print '</td></tr>';

print '</table>';

print '<div class="tabsAction">';
Expand Down
2 changes: 2 additions & 0 deletions admin/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
// Silence is golden.
128 changes: 128 additions & 0 deletions admin/product_lang_extrafields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?php
/* Copyright (C) 2021 EOXIA <[email protected]>
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/

/**
* \file htdocs/custom/doliwpshop/admin/product_lang_extrafields.php
* \ingroup doliwpshop
* \brief Page to setup extra fields of traduction
*/

// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
// Try main.inc.php using relative path
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");

require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';

// Load translation files required by the page
$langs->loadLangs(array('companies', 'admin', 'products'));

$extrafields = new ExtraFields($db);
$form = new Form($db);

// List of supported format
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}

$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'product_lang'; //Must be the $element of the class that manage extrafield

if (!$user->admin) {
accessforbidden();
}


/*
* Actions
*/

require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';



/*
* View
*/

$title = $langs->trans('ProductLangsExtraFields');
$textobject = $langs->trans("ProductsAndServices");
if (empty($conf->product->enabled)) {
$title = $langs->trans('ServiceSetup');
$textobject = $langs->trans('Services');
} elseif (empty($conf->service->enabled)) {
$title = $langs->trans('ProductSetup');
$textobject = $langs->trans('Products');
}

$help_url = '';
llxHeader('', $title, $help_url);


$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($title, $linkback, 'title_setup');


$head = product_admin_prepare_head();

print dol_get_fiche_head($head, 'productLangAttributes', $textobject, -1, 'product');

require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';

print dol_get_fiche_end();


// Buttons
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
}


// Creation of an optional field
if ($action == 'create') {
print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));

require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}

// Edition of an optional field
if ($action == 'edit' && !empty($attrname)) {
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));

require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}

// End of page
llxFooter();
$db->close();
Loading

0 comments on commit 6aac200

Please sign in to comment.