forked from Wavyzz/dolibarr
Complete param of setValueFrom
This commit is contained in:
@@ -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++;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user