Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5533 from marcosgdf/prod-attr
Feature Request: NEW Added product attributes feature
- Loading branch information
Showing
44 changed files
with
4,042 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> | ||
* | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
require '../../main.inc.php'; | ||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; | ||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; | ||
|
||
$langs->load("admin"); | ||
$langs->load("products"); | ||
|
||
// Security check | ||
if (! $user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) | ||
accessforbidden(); | ||
|
||
if ($_POST) { | ||
|
||
$value = GETPOST('PRODUIT_ATTRIBUTES_HIDECHILD'); | ||
|
||
if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_HIDECHILD', $value, 'chaine', 0, '', $conf->entity)) { | ||
setEventMessage($langs->trans('RecordSaved')); | ||
} else { | ||
setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); | ||
} | ||
|
||
} | ||
|
||
$title = $langs->trans('ModuleSetup').' '.$langs->trans('ProductAttributes'); | ||
llxHeader('', $title); | ||
|
||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; | ||
print load_fiche_titre($title,$linkback,'title_setup'); | ||
|
||
dol_fiche_head(array(), 'general', $tab, 0, 'product'); | ||
|
||
print '<form method="post">'; | ||
print '<table class="noborder" width="100%">'; | ||
print '<tr class="liste_titre">'; | ||
print '<td>'.$langs->trans("Parameters").'</td>'."\n"; | ||
print '<td align="right" width="60">'.$langs->trans("Value").'</td>'."\n"; | ||
print '<td width="80"> </td></tr>'."\n"; | ||
print '<tr><td>'.$langs->trans('HideProductCombinations').'</td><td>'; | ||
print $form->selectyesno("PRODUIT_ATTRIBUTES_HIDECHILD",$conf->global->PRODUIT_ATTRIBUTES_HIDECHILD,1).'</td></tr>'; | ||
print '</table>'; | ||
print '<br><div style="text-align: center"><input type="submit" value="'.$langs->trans('Save').'" class="button"></div>'; | ||
print '</form>'; | ||
|
||
llxFooter(); | ||
|
||
$db->close(); | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> | ||
* | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
define('NOTOKENRENEWAL','1'); | ||
define('NOREQUIREMENU','1'); | ||
define('NOREQUIREHTML','1'); | ||
define('NOREQUIREAJAX','1'); | ||
define('NOREQUIRESOC','1'); | ||
|
||
require '../../main.inc.php'; | ||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; | ||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination.class.php'; | ||
|
||
header('Content-Type: application/json'); | ||
|
||
$id = GETPOST('id'); | ||
|
||
if (!$id) { | ||
print json_encode(array( | ||
'error' => 'ID not set' | ||
)); | ||
die; | ||
} | ||
|
||
$product = new Product($db); | ||
|
||
if ($product->fetch($id) < 0) { | ||
print json_encode(array( | ||
'error' => 'Product not found' | ||
)); | ||
} | ||
|
||
$prodcomb = new ProductCombination($db); | ||
|
||
echo json_encode($prodcomb->getUniqueAttributesAndValuesByFkProductParent($product->id)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> | ||
* | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
define('NOTOKENRENEWAL','1'); | ||
define('NOREQUIREMENU','1'); | ||
define('NOREQUIREHTML','1'); | ||
define('NOREQUIREAJAX','1'); | ||
define('NOREQUIRESOC','1'); | ||
|
||
require '../../main.inc.php'; | ||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; | ||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttribute.class.php'; | ||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttributeValue.class.php'; | ||
|
||
header('Content-Type: application/json'); | ||
|
||
$id = GETPOST('id'); | ||
|
||
if (!$id) { | ||
print json_encode(array( | ||
'error' => 'ID not set' | ||
)); | ||
die; | ||
} | ||
|
||
$prodattr = new ProductAttribute($db); | ||
|
||
if ($prodattr->fetch($id) < 0) { | ||
print json_encode(array( | ||
'error' => 'Attribute not found' | ||
)); | ||
die; | ||
} | ||
|
||
$prodattrval = new ProductAttributeValue($db); | ||
|
||
$res = $prodattrval->fetchAllByProductAttribute($id); | ||
|
||
if ($res == -1) { | ||
print json_encode(array( | ||
'error' => 'Internal error' | ||
)); | ||
die; | ||
} | ||
|
||
print json_encode($res); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> | ||
* | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disable token renewal | ||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); | ||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); | ||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); | ||
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); | ||
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); | ||
if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); // Disable "main.inc.php" hooks | ||
|
||
require '../../main.inc.php'; | ||
|
||
/* | ||
* View | ||
*/ | ||
|
||
top_httphead(); | ||
|
||
// Registering the location of boxes | ||
if (isset($_POST['roworder'])) { | ||
$roworder=GETPOST('roworder','alpha',2); | ||
|
||
dol_syslog("AjaxOrderAttribute roworder=".$roworder, LOG_DEBUG); | ||
|
||
$rowordertab = explode(',', $roworder); | ||
|
||
foreach ($rowordertab as $value) { | ||
if (!empty($value)) { | ||
$newrowordertab[] = $value; | ||
} | ||
} | ||
|
||
require DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttribute.class.php'; | ||
|
||
ProductAttribute::bulkUpdateOrder($db, $newrowordertab); | ||
} | ||
|
Oops, something went wrong.