Debug module variant
This commit is contained in:
parent
0b470bef80
commit
2c07886360
@ -46,10 +46,10 @@ if ($_POST) {
|
|||||||
|
|
||||||
if ($action == 'edit') {
|
if ($action == 'edit') {
|
||||||
|
|
||||||
$object->label = $label;
|
|
||||||
$object->ref = $ref;
|
$object->ref = $ref;
|
||||||
|
$object->label = $label;
|
||||||
|
|
||||||
if ($object->update() < 1) {
|
if ($object->update($user) < 1) {
|
||||||
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
||||||
} else {
|
} else {
|
||||||
setEventMessage($langs->trans('RecordSaved'));
|
setEventMessage($langs->trans('RecordSaved'));
|
||||||
@ -61,12 +61,26 @@ if ($_POST) {
|
|||||||
if ($objectval->fetch($valueid) > 0) {
|
if ($objectval->fetch($valueid) > 0) {
|
||||||
|
|
||||||
$objectval->ref = $ref;
|
$objectval->ref = $ref;
|
||||||
$objectval->value = GETPOST('value');
|
$objectval->value = GETPOST('value','alpha');
|
||||||
|
|
||||||
if ($objectval->update() > 0) {
|
if (empty($objectval->ref))
|
||||||
setEventMessage($langs->trans('RecordSaved'));
|
{
|
||||||
} else {
|
$error++;
|
||||||
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
|
||||||
|
}
|
||||||
|
if (empty($objectval->value))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
if ($objectval->update($user) > 0) {
|
||||||
|
setEventMessage($langs->trans('RecordSaved'));
|
||||||
|
} else {
|
||||||
|
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -149,12 +149,14 @@ class ProductAttribute
|
|||||||
/**
|
/**
|
||||||
* Updates a product attribute
|
* Updates a product attribute
|
||||||
*
|
*
|
||||||
* @return int <0 KO, >0 OK
|
* @param User $user Object user
|
||||||
|
* @return int <0 KO, >0 OK
|
||||||
*/
|
*/
|
||||||
public function update()
|
public function update(User $user)
|
||||||
{
|
{
|
||||||
//Ref must be uppercase
|
//Ref must be uppercase
|
||||||
$this->ref = strtoupper($this->ref);
|
$this->ref = trim(strtoupper($this->ref));
|
||||||
|
$this->label = trim($this->label);
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product_attribute SET ref = '".$this->db->escape($this->ref)."', label = '".$this->db->escape($this->label)."', rang = ".(int) $this->rang." WHERE rowid = ".(int) $this->id;
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product_attribute SET ref = '".$this->db->escape($this->ref)."', label = '".$this->db->escape($this->label)."', rang = ".(int) $this->rang." WHERE rowid = ".(int) $this->id;
|
||||||
|
|
||||||
|
|||||||
@ -168,12 +168,14 @@ class ProductAttributeValue
|
|||||||
/**
|
/**
|
||||||
* Updates a product attribute value
|
* Updates a product attribute value
|
||||||
*
|
*
|
||||||
* @return int
|
* @param User $user Object user
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function update()
|
public function update(User $user)
|
||||||
{
|
{
|
||||||
//Ref must be uppercase
|
//Ref must be uppercase
|
||||||
$this->ref = strtoupper($this->ref);
|
$this->ref = trim(strtoupper($this->ref));
|
||||||
|
$this->value = trim($this->value);
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product_attribute_value
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product_attribute_value
|
||||||
SET fk_product_attribute = '".(int) $this->fk_product_attribute."', ref = '".$this->db->escape($this->ref)."',
|
SET fk_product_attribute = '".(int) $this->fk_product_attribute."', ref = '".$this->db->escape($this->ref)."',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user