Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
- Ajout d'une option sur le parametrage des "attributs" de produit po…
Browse files Browse the repository at this point in the history
…ur definir l'affichage de celui-ci sur WooCommerce

- Correction de la page "A propos"
  • Loading branch information
kkhelifa-opendsi committed Oct 6, 2023
1 parent e6ef531 commit f89fea9
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 19 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ChangeLog

## 4.1.62.0
- Ajout d'une option sur le parametrage des "attributs" de produit pour definir l'affichage de celui-ci sur WooCommerce
- Correction de la page "A propos"

## 4.1.61.0
- Ajout d'un champ dans la liste des factures pour afficher le delta entre le total TTC et le total HT plus total TVA
- Ajout d'un script pour corriger les factures en recreant les lignes de celles-ci (et modifie le prix des lignes existantes de la commande lié, ne creer pas les nouvelle lignes manquantes)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.61
4.1.62
35 changes: 32 additions & 3 deletions admin/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,35 @@
$langs->load("ecommerce@ecommerceng");
$langs->load("opendsi@ecommerceng");

if (!$user->admin) accessforbidden();
if (!$user->admin && !$user->rights->ecommerceng->site) accessforbidden();

$id = GETPOST('id', 'int');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'aZ09');

$object = new eCommerceSite($db);
if (empty($action) && !($id > 0) && strlen($id) == 0) {
$sites = $object->listSites();
if (!empty($sites)) {
$id = array_values($sites)[0]['id'];
}
}
if ($id > 0) {
$result = $object->fetch($id);
if ($result < 0) {
accessforbidden($object->errorsToString());
} elseif ($result == 0) {
$langs->load('errors');
accessforbidden($langs->trans('ErrorRecordNotFound'));
}
}

/**
* Actions
*/
$error = 0;

include dol_buildpath('/ecommerceng/admin/actions_selectsite.inc.php');


/**
Expand All @@ -46,12 +74,13 @@

$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ECommerceSetup"),$linkback,'title_setup');
print "<br>\n";

include dol_buildpath('/ecommerceng/admin/tpl/selectsite.tpl.php');

$head=ecommercengConfigSitePrepareHead($object);

print dol_get_fiche_head($head, 'about', $langs->trans("Module107100Name"), 0, 'opendsi@ecommerceng');

print '<br>';

$modClass = new modECommerceNg($db);
$ECommerceNgVersion = !empty($modClass->getVersion()) ? $modClass->getVersion() : 'NC';
Expand Down
5 changes: 5 additions & 0 deletions admin/actions_extrafields.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

$activated_list = array();
$value_list = array();
$show_list = array();
foreach ($extra_fields_list[$table_element]['extra_fields'] as $key => $label) {
// default value
$activated = GETPOST("ef_dft_state_{$table_element}_{$key}", 'int') ? 1 : 0;
Expand All @@ -56,9 +57,13 @@
$value = $activated ? GETPOST("ef_att_value_{$table_element}_{$key}", 'alphanohtml') :
(!empty($object->parameters['extra_fields'][$table_element]['values']['att'][$key]) ? $object->parameters['extra_fields'][$table_element]['values']['att'][$key] : null);
if (isset($value)) $value_list['att'][$key] = $value;
$show = $activated ? GETPOST("ef_att_show_{$table_element}_{$key}", 'alphanohtml') :
(!empty($object->parameters['extra_fields'][$table_element]['show']['att'][$key]) ? $object->parameters['extra_fields'][$table_element]['show']['att'][$key] : null);
if (isset($show)) $show_list['att'][$key] = $show;
}
$object->parameters['extra_fields'][$table_element]['activated'] = $activated_list;
$object->parameters['extra_fields'][$table_element]['values'] = $value_list;
$object->parameters['extra_fields'][$table_element]['show'] = $show_list;

$result = $object->update($user);

Expand Down
18 changes: 12 additions & 6 deletions admin/tpl/extrafields.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@

$activated_info = $object->parameters['extra_fields'][$table_element]['activated'];
$values_info = $object->parameters['extra_fields'][$table_element]['values'];
$show_info = $object->parameters['extra_fields'][$table_element]['show'];
foreach ($info['extra_fields'] as $key => $label) {
if (!empty($extrafields->attributes[$table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$table_element]['langfile'][$key]);

Expand All @@ -83,6 +84,7 @@
if (!empty($info['default'])) {
$not_supported = in_array($extrafields->attributes[$table_element]['type'][$key], [ 'date', 'datetime' ]);

$target_class = 'ef_dft_' . $table_element . '_' . $key;
$default_value = '';
if (isset($extrafields->attributes[$table_element]['default'][$key])) $default_value = $extrafields->attributes[$table_element]['default'][$key];
$value = isset($values_info['dft'][$key]) ? $values_info['dft'][$key] : $default_value;
Expand All @@ -92,33 +94,37 @@
print $langs->trans('NotSupported');
} else {
// print $extrafields->showInputField($key, $value, ($activated ? '' : ' disabled'), '', 'ef_dft_value_' . $table_element . '_', '', 0, $table_element);
print '<input type="text" class="centpercent" id="ef_dft_value_' . $table_element . '_options_' . $key . '" name="ef_dft_value_' . $table_element . '_options_' . $key . '" value="' . dol_escape_htmltag($value) . '"' . ($activated ? '' : ' disabled') . ' />';
print '<input type="text" class="centpercent ' . $target_class . '" id="ef_dft_value_' . $table_element . '_options_' . $key . '" name="ef_dft_value_' . $table_element . '_options_' . $key . '" value="' . dol_escape_htmltag($value) . '"' . ($activated ? '' : ' disabled') . ' />';
}
print '</td>' . "\n";
print '<td class="center">' . "\n";
if (!$not_supported) {
print '<input type="checkbox" class="ef_state ef_dft_state_' . $table_element . '" name="ef_dft_state_' . $table_element . '_' . $key . '" value="1" data-target="ef_dft_value_' . $table_element . '_options_' . $key . '"' . ($activated ? ' checked' : '') . ' title="' . $langs->trans('Enabled') . '" />' . "\n";
print '<input type="checkbox" class="ef_state ef_dft_state_' . $table_element . '" name="ef_dft_state_' . $table_element . '_' . $key . '" value="1" data-target="' . $target_class . '"' . ($activated ? ' checked' : '') . ' title="' . $langs->trans('Enabled') . '" />' . "\n";
}
print '</td>';
}
if (!empty($info['metadata'])) {
$target_class = 'ef_mdt_' . $table_element . '_' . $key;
$value = isset($values_info['mdt'][$key]) ? $values_info['mdt'][$key] : $key;
$activated = !empty($activated_info['mdt'][$key]);
print '<td>' . "\n";
print '<input type="text" class="centpercent" id="ef_mdt_value_' . $table_element . '_' . $key . '" name="ef_mdt_value_' . $table_element . '_' . $key . '" value="' . dol_escape_htmltag($value) . '"' . ($activated ? '' : ' disabled') . ' />';
print '<input type="text" class="centpercent ' . $target_class . '" id="ef_mdt_value_' . $table_element . '_' . $key . '" name="ef_mdt_value_' . $table_element . '_' . $key . '" value="' . dol_escape_htmltag($value) . '"' . ($activated ? '' : ' disabled') . ' />';
print '</td>' . "\n";
print '<td class="center">' . "\n";
print '<input type="checkbox" class="ef_state ef_mdt_state_' . $table_element . '" name="ef_mdt_state_' . $table_element . '_' . $key . '" value="1" data-target="ef_mdt_value_' . $table_element . '_' . $key . '"' . ($activated ? ' checked' : '') . ' title="' . $langs->trans('Enabled') . '" />' . "\n";
print '<input type="checkbox" class="ef_state ef_mdt_state_' . $table_element . '" name="ef_mdt_state_' . $table_element . '_' . $key . '" value="1" data-target="' . $target_class . '"' . ($activated ? ' checked' : '') . ' title="' . $langs->trans('Enabled') . '" />' . "\n";
print '</td>';
}
if (!empty($info['attributes'])) {
$target_class = 'ef_att_' . $table_element . '_' . $key;
$value = isset($values_info['att'][$key]) ? $values_info['att'][$key] : (isset($remote_attributes_label[$label]) ? $remote_attributes_label[$label] : $key);
$show = isset($show_info['att'][$key]) ? $show_info['att'][$key] : 0;
$activated = !empty($activated_info['att'][$key]);
print '<td>' . "\n";
print $form->selectarray('ef_att_value_' . $table_element . '_' . $key, $info['attributes'], $value, 1, 0, 0, '', 0, 0, $activated ? 0 : 1, '', 'minwidth300');
print $form->selectarray('ef_att_value_' . $table_element . '_' . $key, $info['attributes'], $value, 1, 0, 0, '', 0, 0, $activated ? 0 : 1, '', 'minwidth300 ' . $target_class);
print $form->selectarray('ef_att_show_' . $table_element . '_' . $key, [ 1 => $langs->trans('Show'), 2 => $langs->trans('Hide') ], $show, 0, 0, 0, '', 0, 0, $activated ? 0 : 1, '', 'minwidth100 ' . $target_class);
print '</td>' . "\n";
print '<td class="center">' . "\n";
print '<input type="checkbox" class="ef_state ef_att_state_' . $table_element . '" name="ef_att_state_' . $table_element . '_' . $key . '" value="1" data-target="ef_att_value_' . $table_element . '_' . $key . '"' . ($activated ? ' checked' : '') . ' title="' . $langs->trans('Enabled') . '" />' . "\n";
print '<input type="checkbox" class="ef_state ef_att_state_' . $table_element . '" name="ef_att_state_' . $table_element . '_' . $key . '" value="1" data-target="' . $target_class . '"' . ($activated ? ' checked' : '') . ' title="' . $langs->trans('Enabled') . '" />' . "\n";
print '</td>';
}
print '</tr>' . "\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3181,8 +3181,9 @@ public function convertObjectIntoProductData($remote_id, $object)
// Synch extrafields <=> attributes
if (!empty($this->site->parameters['extra_fields']['product']['activated']['att'][$cr_key])) {
$data_key = $this->site->parameters['extra_fields']['product']['values']['att'][$cr_key];
$show_attr = $this->site->parameters['extra_fields']['product']['show']['att'][$cr_key];
if (!empty($data_key)) {
$variationData['attributes'][] = array('id' => $data_key, 'options' => !empty($value) ? explode(',', $value) : array());
$variationData['attributes'][] = array('id' => $data_key, 'visible' => $show_attr != 2, 'options' => !empty($value) ? explode(',', $value) : array());
}
}
}
Expand Down Expand Up @@ -3474,8 +3475,9 @@ public function convertObjectIntoProductData($remote_id, $object)
// Synch extrafields <=> attributes
if (!empty($this->site->parameters['extra_fields']['product']['activated']['att'][$cr_key])) {
$data_key = $this->site->parameters['extra_fields']['product']['values']['att'][$cr_key];
$show_attr = $this->site->parameters['extra_fields']['product']['show']['att'][$cr_key];
if (!empty($data_key)) {
$productData['attributes'][] = array('id' => $data_key, 'options' => !empty($value) ? explode(',', $value) : array());
$productData['attributes'][] = array('id' => $data_key, 'visible' => $show_attr != 2, 'options' => !empty($value) ? explode(',', $value) : array());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ jQuery(document).ready(function (){
var target = _this.attr('data-target');
var state = _this.is(':checked');

jQuery('#'+target).prop('disabled', !state);
jQuery('.'+target).prop('disabled', !state);
}
});
11 changes: 5 additions & 6 deletions lib/eCommerce.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ function ecommercengConfigSitePrepareHead($object)
$head[$h][2] = 'settings';
$h++;

$head[$h][0] = dol_buildpath("/ecommerceng/admin/about.php", 1);
$head[$h][1] = $langs->trans("About") . " / " . $langs->trans("Support");
$head[$h][2] = 'about';
$h++;


if ($object->id > 0) {
if (!empty($conf->societe->enabled)) {
$langs->load('companies');
Expand Down Expand Up @@ -90,6 +84,11 @@ function ecommercengConfigSitePrepareHead($object)

complete_head_from_modules($conf, $langs, null, $head, $h, 'ecommerceng_config_site', 'remove');

$head[$h][0] = dol_buildpath("/ecommerceng/admin/about.php", 1);
$head[$h][1] = $langs->trans("About") . " / " . $langs->trans("Support");
$head[$h][2] = 'about';
$h++;

return $head;
}

Expand Down

0 comments on commit f89fea9

Please sign in to comment.