From 0ab377440d49c4839e83f63de72b2bcbfc2fb66c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 12 Sep 2016 20:16:39 +0200 Subject: [PATCH] Complete param of setValueFrom --- htdocs/barcode/codeinit.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/compta/deplacement/card.php | 4 ++-- htdocs/compta/facture.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/compta/facture/fiche-rec.php | 2 +- htdocs/compta/paiement/cheque/card.php | 2 +- htdocs/contrat/card.php | 8 ++++---- htdocs/core/class/commonobject.class.php | 3 ++- htdocs/fourn/commande/card.php | 3 +-- htdocs/product/card.php | 4 ++-- htdocs/societe/soc.php | 4 ++-- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index d47e5aaecd3..ebe121301b7 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -143,7 +143,7 @@ if ($action == 'initbarcodeproducts') $nextvalue=$modBarCodeProduct->getNextValue($productstatic,''); //print 'Set value '.$nextvalue.' to product '.$productstatic->id." ".$productstatic->ref." ".$productstatic->type."<br>\n"; - $result=$productstatic->setValueFrom('barcode', $nextvalue); + $result=$productstatic->setValueFrom('barcode', $nextvalue, '', '', 'date', '', $user, 'PRODUCT_MODIFY'); $nbtry++; if ($result > 0) $nbok++; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index def950305d6..00eac5dce6f 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1231,7 +1231,7 @@ if (empty($reshook)) if ($action == 'set_thirdparty' && $user->rights->commande->creer) { $object->fetch($id); - $object->setValueFrom('fk_soc', $socid); + $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY'); header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); exit(); diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 934c970accf..bf3e311c313 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -213,13 +213,13 @@ else if ($action == 'setdated' && $user->rights->deplacement->creer) { $dated=dol_mktime(GETPOST('datedhour','int'), GETPOST('datedmin','int'), GETPOST('datedsec','int'), GETPOST('datedmonth','int'), GETPOST('datedday','int'), GETPOST('datedyear','int')); $object->fetch($id); - $result=$object->setValueFrom('dated',$dated,'','','date'); + $result=$object->setValueFrom('dated', $dated, '', '', 'date', '', $user, 'DEPLACEMENT_MODIFY'); if ($result < 0) dol_print_error($db, $object->error); } else if ($action == 'setkm' && $user->rights->deplacement->creer) { $object->fetch($id); - $result=$object->setValueFrom('km',GETPOST('km','int')); + $result=$object->setValueFrom('km', GETPOST('km','int'), '', null, 'text', '', $user, 'DEPLACEMENT_MODIFY'); if ($result < 0) dol_print_error($db, $object->error); } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index be92266b152..b2d8e47fa9e 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -254,7 +254,7 @@ if (empty($reshook)) else if ($action == 'set_thirdparty' && $user->rights->facture->creer) { $object->fetch($id); - $object->setValueFrom('fk_soc', $socid); + $object->setValueFrom('fk_soc', $socid, '', null, 'int', '', $user, 'BILL_MODIFY'); header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); exit(); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 17d4c9635a8..a0cd4de90e8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -319,7 +319,7 @@ class Facture extends CommonInvoice dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); if (empty($_facrec->date_when)) $_facrec->date_when = $now; $next_date = $_facrec->getNextDate(); // Calculate next date - $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date'); + $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date', '', $user, ''); //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. $result = $_facrec->setNextDate($next_date,1); } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index b6b9ca87ac5..1dc9198051f 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -270,7 +270,7 @@ elseif ($action == 'classin' && $user->rights->facture->creer) // Set bank account elseif ($action == 'setref' && $user->rights->facture->creer) { - $result=$object->setValueFrom('titre', GETPOST('ref', 'alpha')); + $result=$object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY'); if ($result > 0) { $object->titre = GETPOST('ref', 'alpha'); diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 0ffaf49b955..b7e7af581de 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -95,7 +95,7 @@ if ($action == 'setrefext' && $user->rights->banque->cheque) { $ref_ext = GETPOST('ref_ext'); - $result=$object->setValueFrom('ref_ext', $ref_ext); + $result=$object->setValueFrom('ref_ext', $ref_ext, '', null, 'text', '', $user, 'CHECKDEPOSIT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index c5222151625..d034ff21fc1 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -796,7 +796,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - $result = $object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); + $result = $object->setValueFrom('ref_supplier', GETPOST('ref_supplier','alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'editref_supplier'; @@ -821,7 +821,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - $result = $object->setValueFrom('ref_customer',GETPOST('ref_customer','alpha')); + $result = $object->setValueFrom('ref_customer', GETPOST('ref_customer','alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'editref_customer'; @@ -845,7 +845,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - $result = $object->setValueFrom('ref',GETPOST('ref','alpha')); + $result = $object->setValueFrom('ref', GETPOST('ref','alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'editref'; @@ -869,7 +869,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } $datacontrat=dol_mktime(GETPOST('date_contrathour'), GETPOST('date_contratmin'), 0, GETPOST('date_contratmonth'), GETPOST('date_contratday'), GETPOST('date_contratyear')); - $result = $object->setValueFrom('date_contrat',$datacontrat,'',null,'date'); + $result = $object->setValueFrom('date_contrat', $datacontrat, '', null, 'date', '', $user, 'CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'editdate_contrat'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 62c3264d17b..4e4f027ae12 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1216,7 +1216,7 @@ abstract class CommonObject /** * Setter generic. Update a specific field into database. - * Warning: Trigger is run only if param trigkey is provided + * Warning: Trigger is run only if param trigkey is provided. * * @param string $field Field to update * @param mixed $value New value @@ -1246,6 +1246,7 @@ abstract class CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; + else if ($format == 'int') $sql.= $field." = ".$this->db->escape($value); else if ($format == 'date') $sql.= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); if (is_object($user)) $sql.=", fk_user_modif = ".$user->id; $sql.= " WHERE ".$id_field." = ".$id; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 38f1fbc036e..3c710461b06 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -140,9 +140,8 @@ if (empty($reshook)) if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer) { - $result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); + $result=$object->setValueFrom('ref_supplier', GETPOST('ref_supplier','alpha'), '', null, 'text', '', $user, 'ORDER_SUPPLIER_MODIFY'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); - else $object->ref_supplier = GETPOST('ref_supplier','alpha'); // The setValueFrom does not set new property of object } // Set incoterm diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 13820f620d3..cfcf253eb31 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -135,7 +135,7 @@ if (empty($reshook)) // Type if ($action == 'setfk_product_type' && $user->rights->produit->creer) { - $result = $object->setValueFrom('fk_product_type', GETPOST('fk_product_type')); + $result = $object->setValueFrom('fk_product_type', GETPOST('fk_product_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -169,7 +169,7 @@ if (empty($reshook)) // Barcode type if ($action == 'setfk_barcode_type' && $createbarcode) { - $result = $object->setValueFrom('fk_barcode_type', GETPOST('fk_barcode_type')); + $result = $object->setValueFrom('fk_barcode_type', GETPOST('fk_barcode_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 9317614343c..675544566e8 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -228,14 +228,14 @@ if (empty($reshook)) //obtidre selected del combobox $value=GETPOST('lt1'); $object->fetch($socid); - $res=$object->setValueFrom('localtax1_value', $value); + $res=$object->setValueFrom('localtax1_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); } if($action=='set_localtax2') { //obtidre selected del combobox $value=GETPOST('lt2'); $object->fetch($socid); - $res=$object->setValueFrom('localtax2_value', $value); + $res=$object->setValueFrom('localtax2_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); } // Add new or update third party -- GitLab