Skip to content

Commit

Permalink
FIX: shipping date was not editable in view mode
Browse files Browse the repository at this point in the history
  • Loading branch information
altairis-noe committed Nov 20, 2024
1 parent 12ec583 commit 56b181e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
14 changes: 11 additions & 3 deletions htdocs/expedition/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,14 @@
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setdate_shipping' && $user->hasRight('expedition', 'creer')) {
$dateshipping = dol_mktime(GETPOSTINT('ship_hour'), GETPOSTINT('ship_min'), 0, GETPOSTINT('ship_month'), GETPOSTINT('ship_day'), GETPOSTINT('ship_year'));

$object->fetch($id);
$result = $object->setShippingDate($user, $dateshipping);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif (in_array($action, array('settracking_number', 'settracking_url', 'settrueWeight', 'settrueWidth', 'settrueHeight', 'settrueDepth', 'setshipping_method_id')) && $user->hasRight('expedition', 'creer')) {
// Action update
$error = 0;
Expand Down Expand Up @@ -2061,10 +2069,10 @@
print '</tr></table>';
print '</td><td colspan="2">';
if ($action == 'editdate_shipping') {
print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<form name="setdate_shipping" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setdate_livraison">';
print $form->selectDate($object->date_shipping ? $object->date_shipping : -1, 'liv_', 1, 1, 0, "setdate_shipping", 1, 0);
print '<input type="hidden" name="action" value="setdate_shipping">';
print $form->selectDate($object->date_shipping ? $object->date_shipping : -1, 'ship_', 1, 1, 0, "setdate_shipping", 1, 0);
print '<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
Expand Down
28 changes: 28 additions & 0 deletions htdocs/expedition/class/expedition.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,34 @@ public function setDeliveryDate($user, $delivery_date)
}
}

/**
* Set the shipping date
*
* @param User $user Object user that modify
* @param integer $shipping_date Date of shipping
* @return int Return integer <0 if KO, >0 if OK
*/
public function setShippingDate($user, $shipping_date)
{
if ($user->hasRight('expedition', 'creer')) {
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition";
$sql .= " SET date_expedition = ".($shipping_date ? "'".$this->db->idate($shipping_date)."'" : 'null');
$sql .= " WHERE rowid = ".((int) $this->id);

dol_syslog(get_class($this)."::setShippingDate", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$this->date_shipping = $shipping_date;
return 1;
} else {
$this->error = $this->db->error();
return -1;
}
} else {
return -2;
}
}

// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Fetch deliveries method and return an array. Load array this->meths(rowid=>label).
Expand Down

0 comments on commit 56b181e

Please sign in to comment.