Merge branch '23.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
6cd6acabfe
5 changed files with 46 additions and 29 deletions
|
|
@ -126,6 +126,12 @@ class DolibarrApi
|
|||
// Others will use 'alphanohtml'
|
||||
}
|
||||
|
||||
// In case of a field with unknown type (legacy code), we use its name to have a chance to sanitize it
|
||||
if (preg_match('/^fk_/i', $field)) {
|
||||
// We accept only integer
|
||||
return sanitizeVal($value, 'int');
|
||||
}
|
||||
|
||||
if (in_array($field, array('note', 'note_private', 'note_public', 'desc', 'description'))) {
|
||||
return sanitizeVal($value, 'restricthtml');
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1168,14 +1168,23 @@ if (empty($reshook)) {
|
|||
}
|
||||
|
||||
if (empty($error)) {
|
||||
// Set invoice as paid
|
||||
$result = $object->setPaid($user); // We can close the invoice. Even if we got an excess received, it is now into discounts.
|
||||
if ($result >= 0) {
|
||||
$object->fetch($object->id); // Reload properties
|
||||
// Set invoice as paid, unless it's a deposit converted to credit without any payment received
|
||||
// (option DEPOSIT_AS_CREDIT_AVAILABLE_EVEN_UNPAID allows creating the discount/credit even if the deposit
|
||||
// has not been paid yet; in that case we must NOT mark it as paid since no payment was actually received)
|
||||
$skipSetPaid = ($object->type == Facture::TYPE_DEPOSIT && getDolGlobalInt('DEPOSIT_AS_CREDIT_AVAILABLE_EVEN_UNPAID') && price2num($object->getSommePaiement(), 'MT') == 0);
|
||||
|
||||
if ($skipSetPaid) {
|
||||
$object->fetch($object->id); // Reload properties
|
||||
$db->commit();
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$db->rollback();
|
||||
$result = $object->setPaid($user); // We can close the invoice. Even if we got an excess received, it is now into discounts.
|
||||
if ($result >= 0) {
|
||||
$object->fetch($object->id); // Reload properties
|
||||
$db->commit();
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setEventMessages($discount->error, $discount->errors, 'errors');
|
||||
|
|
|
|||
|
|
@ -486,13 +486,13 @@ class Expedition extends CommonObject
|
|||
$sql .= ", ".($this->date_delivery > 0 ? "'".$this->db->idate($this->date_delivery)."'" : "null");
|
||||
$sql .= ", ".($this->socid > 0 ? ((int) $this->socid) : "null");
|
||||
$sql .= ", ".($this->fk_project > 0 ? ((int) $this->fk_project) : "null");
|
||||
$sql .= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null");
|
||||
$sql .= ", ".($this->fk_delivery_address > 0 ? ((int) $this->fk_delivery_address) : "null");
|
||||
$sql .= ", ".($this->shipping_method_id > 0 ? ((int) $this->shipping_method_id) : "null");
|
||||
$sql .= ", '".$this->db->escape($this->tracking_number)."'";
|
||||
$sql .= ", ".(is_numeric($this->weight) ? $this->weight : 'NULL');
|
||||
$sql .= ", ".(is_numeric($this->sizeS) ? $this->sizeS : 'NULL'); // TODO Should use this->trueDepth
|
||||
$sql .= ", ".(is_numeric($this->sizeW) ? $this->sizeW : 'NULL'); // TODO Should use this->trueWidth
|
||||
$sql .= ", ".(is_numeric($this->sizeH) ? $this->sizeH : 'NULL'); // TODO Should use this->trueHeight
|
||||
$sql .= ", ".(is_numeric($this->weight) ? (float) $this->weight : 'NULL');
|
||||
$sql .= ", ".(is_numeric($this->sizeS) ? (float) $this->sizeS : 'NULL'); // TODO Should use this->trueDepth
|
||||
$sql .= ", ".(is_numeric($this->sizeW) ? (float) $this->sizeW : 'NULL'); // TODO Should use this->trueWidth
|
||||
$sql .= ", ".(is_numeric($this->sizeH) ? (float) $this->sizeH : 'NULL'); // TODO Should use this->trueHeight
|
||||
$sql .= ", ".($this->weight_units != '' ? (int) $this->weight_units : 'NULL');
|
||||
$sql .= ", ".($this->size_units != '' ? (int) $this->size_units : 'NULL');
|
||||
$sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null");
|
||||
|
|
@ -1397,6 +1397,7 @@ class Expedition extends CommonObject
|
|||
$this->line->element_type = $element_type;
|
||||
$this->line->fk_product = $fk_product;
|
||||
$this->line->description = $description;
|
||||
$this->line->desc = $description;
|
||||
$this->line->fk_parent = $fk_parent;
|
||||
$this->line->qty = (float) $qty;
|
||||
$this->line->fk_unit = $fk_unit;
|
||||
|
|
@ -1684,24 +1685,24 @@ class Expedition extends CommonObject
|
|||
$sql .= " ref = ".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").",";
|
||||
$sql .= " ref_ext = ".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").",";
|
||||
$sql .= " ref_customer = ".(isset($this->ref_customer) ? "'".$this->db->escape($this->ref_customer)."'" : "null").",";
|
||||
$sql .= " fk_soc = ".(isset($this->socid) ? $this->socid : "null").",";
|
||||
$sql .= " fk_soc = ".(isset($this->socid) ? ((int) $this->socid) : "null").",";
|
||||
$sql .= " date_creation = ".(dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').",";
|
||||
$sql .= " fk_user_author = ".(isset($this->fk_user_author) ? $this->fk_user_author : "null").",";
|
||||
$sql .= " fk_user_author = ".(isset($this->fk_user_author) ? ((int) $this->fk_user_author) : "null").",";
|
||||
$sql .= " date_valid = ".(dol_strlen($this->date_valid) != 0 ? "'".$this->db->idate($this->date_valid)."'" : 'null').",";
|
||||
$sql .= " fk_user_valid = ".(isset($this->fk_user_valid) ? $this->fk_user_valid : "null").",";
|
||||
$sql .= " fk_user_valid = ".(isset($this->fk_user_valid) ? ((int) $this->fk_user_valid) : "null").",";
|
||||
$sql .= " date_expedition = ".(dol_strlen($this->date_shipping) != 0 ? "'".$this->db->idate($this->date_shipping)."'" : 'null').",";
|
||||
$sql .= " date_delivery = ".(dol_strlen($this->date_delivery) != 0 ? "'".$this->db->idate($this->date_delivery)."'" : 'null').",";
|
||||
$sql .= " fk_address = ".(isset($this->fk_delivery_address) ? $this->fk_delivery_address : "null").",";
|
||||
$sql .= " fk_shipping_method = ".((isset($this->shipping_method_id) && $this->shipping_method_id > 0) ? $this->shipping_method_id : "null").",";
|
||||
$sql .= " fk_address = ".(isset($this->fk_delivery_address) ? ((int) $this->fk_delivery_address) : "null").",";
|
||||
$sql .= " fk_shipping_method = ".((isset($this->shipping_method_id) && $this->shipping_method_id > 0) ? ((int) $this->shipping_method_id) : "null").",";
|
||||
$sql .= " tracking_number = ".(isset($this->tracking_number) ? "'".$this->db->escape($this->tracking_number)."'" : "null").",";
|
||||
$sql .= " fk_statut = ".(isset($this->status) ? $this->status : "null").",";
|
||||
$sql .= " fk_projet = ".(isset($this->fk_project) ? $this->fk_project : "null").",";
|
||||
$sql .= " height = ".(($this->trueHeight != '') ? $this->trueHeight : "null").",";
|
||||
$sql .= " width = ".(($this->trueWidth != '') ? $this->trueWidth : "null").",";
|
||||
$sql .= " size_units = ".(isset($this->size_units) ? $this->size_units : "null").",";
|
||||
$sql .= " size = ".(($this->trueDepth != '') ? $this->trueDepth : "null").",";
|
||||
$sql .= " weight_units = ".(isset($this->weight_units) ? $this->weight_units : "null").",";
|
||||
$sql .= " weight = ".(($this->trueWeight != '') ? $this->trueWeight : "null").",";
|
||||
$sql .= " fk_statut = ".(isset($this->status) ? ((int) $this->status) : "null").",";
|
||||
$sql .= " fk_projet = ".(isset($this->fk_project) ? ((int) $this->fk_project) : "null").",";
|
||||
$sql .= " height = ".(($this->trueHeight != '') ? ((float) $this->trueHeight) : "null").",";
|
||||
$sql .= " width = ".(($this->trueWidth != '') ? ((float) $this->trueWidth) : "null").",";
|
||||
$sql .= " size_units = ".(isset($this->size_units) ? ((int) $this->size_units) : "null").",";
|
||||
$sql .= " size = ".(($this->trueDepth != '') ? ((float) $this->trueDepth) : "null").",";
|
||||
$sql .= " weight_units = ".(isset($this->weight_units) ? ((int) $this->weight_units) : "null").",";
|
||||
$sql .= " weight = ".(($this->trueWeight != '') ? ((float) $this->trueWeight) : "null").",";
|
||||
$sql .= " note_private = ".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").",";
|
||||
$sql .= " note_public = ".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").",";
|
||||
$sql .= " model_pdf = ".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").",";
|
||||
|
|
|
|||
|
|
@ -1509,8 +1509,9 @@ class Product extends CommonObject
|
|||
|
||||
if ($result >= 0) {
|
||||
// $this->oldcopy should have been set by the caller of update (here properties were already modified)
|
||||
if (is_null($this->oldcopy) || (is_object($this->oldcopy) && $this->oldcopy->isEmpty())) {
|
||||
$this->oldcopy = dol_clone($this, 1); // 1 to clone with methods to avoid fatal error with $this->oldcopy->hasbatch()
|
||||
// Note that this->oldcopy must be object and not stdClass, if not the method hasbatch() will not work.
|
||||
if (is_null($this->oldcopy) || (is_object($this->oldcopy) && empty($this->oldcopy->id))) {
|
||||
$this->oldcopy = dol_clone($this, 1); // 1 to clone with methods to avoid fatal error with $this->oldcopy->hasbatch()
|
||||
}
|
||||
// Test if batch management is activated on existing product
|
||||
// If yes, we create missing entries into product_batch
|
||||
|
|
@ -6919,9 +6920,9 @@ class Product extends CommonObject
|
|||
}
|
||||
|
||||
/**
|
||||
* Return if the object has a sell-by or eat-by date.
|
||||
* Return if the object has a batch management.
|
||||
*
|
||||
* @return boolean True if the object has a sell-by or eat-by date, false otherwise.
|
||||
* @return boolean True if the object has a batch management, false otherwise.
|
||||
*/
|
||||
public function hasbatch()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ if (empty($reshook)) {
|
|||
if (($action == 'update_price' || $action == 'update_level_price') && !$cancel && $permissiontoadd) {
|
||||
$error = 0;
|
||||
$pricestoupdate = array();
|
||||
$object->oldcopy = dol_clone($object, 2);
|
||||
$object->oldcopy = dol_clone($object, 1); // when calling ->update later we need to call method on ->oldcopy so we clone using param 1
|
||||
|
||||
$psq = GETPOSTINT('psqflag');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue