2
0
forked from Wavyzz/dolibarr

NEW: use Expedition::$date_shipping property in card and list (#31701)

* NEW: use Expedition::$date_shipping property in card and list

* FIX: translation

* FIX: PHPStan rebutal

* FIX: not a great idea to copy and not edit comment

* FIX: on create, expected delivery date should precede sending date

* Update card.php

* Update list.php

* Update list.php

* Update list.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Noé Cendrier
2024-11-14 13:23:22 +01:00
committed by GitHub
parent 1d1c381e98
commit ed6bf372cd
7 changed files with 97 additions and 9 deletions

View File

@@ -120,6 +120,8 @@ $hookmanager->initHooks(array('expeditioncard', 'globalcard'));
$date_delivery = dol_mktime(GETPOSTINT('date_deliveryhour'), GETPOSTINT('date_deliverymin'), 0, GETPOSTINT('date_deliverymonth'), GETPOSTINT('date_deliveryday'), GETPOSTINT('date_deliveryyear'));
$date_shipping = dol_mktime(GETPOSTINT('date_shippinghour'), GETPOSTINT('date_shippingmin'), 0, GETPOSTINT('date_shippingmonth'), GETPOSTINT('date_shippingday'), GETPOSTINT('date_shippingyear'));
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
$object->fetch_thirdparty();
@@ -266,6 +268,7 @@ if (empty($reshook)) {
$object->ref_customer = GETPOST('ref_customer', 'alpha');
$object->model_pdf = GETPOST('model');
$object->date_delivery = $date_delivery; // Date delivery planned
$object->date_shipping = $date_shipping; // Sending date
$object->fk_delivery_address = $objectsrc->fk_delivery_address;
$object->shipping_method_id = GETPOSTINT('shipping_method_id');
$object->tracking_number = GETPOST('tracking_number', 'alpha');
@@ -1037,6 +1040,15 @@ if ($action == 'create') {
print "</td>\n";
print '</tr>';
// Date sending
print '<tr><td>'.$langs->trans("DateShipping").'</td>';
print '<td colspan="3">';
print img_picto('', 'action', 'class="pictofixedwidth"');
$date_shipping = ($date_shipping ? $date_shipping : $object->date_shipping); // $date_shipping comes from GETPOST
print $form->selectDate($date_shipping ? $date_shipping : -1, 'date_shipping', 1, 1, 1);
print "</td>\n";
print '</tr>';
// Note Public
print '<tr><td>'.$langs->trans("NotePublic").'</td>';
print '<td colspan="3">';
@@ -2018,7 +2030,6 @@ if ($action == 'create') {
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('DateDeliveryPlanned');
print '</td>';
if ($action != 'editdate_livraison') {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'</a></td>';
}
@@ -2037,6 +2048,29 @@ if ($action == 'create') {
print '</td>';
print '</tr>';
// Delivery sending date
print '<tr><td height="10">';
print '<table class="nobordernopadding centpercent"><tr><td>';
print $langs->trans('DateShipping');
print '</td>';
if ($action != 'editdate_shipping') {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_shipping&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetShippingDate'), 1).'</a></td>';
}
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 '<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="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
print $object->date_shipping ? dol_print_date($object->date_shipping, 'dayhour') : '&nbsp;';
}
print '</td>';
print '</tr>';
// Weight
print '<tr><td>';
print $form->editfieldkey("Weight", 'trueWeight', $object->trueWeight, $object, $user->hasRight('expedition', 'creer'));

View File

@@ -1206,6 +1206,9 @@ class Expedition extends CommonObject
if (isset($this->model_pdf)) {
$this->model_pdf = trim($this->model_pdf);
}
if (!empty($this->date_expedition)) {
$this->date_shipping = $this->date_expedition;
}
// Check parameters
// Put here code to add control on parameters values
@@ -1220,7 +1223,7 @@ class Expedition extends CommonObject
$sql .= " fk_user_author = ".(isset($this->fk_user_author) ? $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 .= " date_expedition = ".(dol_strlen($this->date_expedition) != 0 ? "'".$this->db->idate($this->date_expedition)."'" : '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").",";

View File

@@ -77,6 +77,8 @@ $search_state = GETPOST("search_state", 'alpha');
$search_country = GETPOST("search_country", 'aZ09');
$search_type_thirdparty = GETPOST("search_type_thirdparty", 'intcomma');
$search_billed = GETPOST("search_billed", 'intcomma');
$search_dateshipping_start = dol_mktime(0, 0, 0, GETPOSTINT('search_dateshipping_startmonth'), GETPOSTINT('search_dateshipping_startday'), GETPOSTINT('search_dateshipping_startyear'));
$search_dateshipping_end = dol_mktime(23, 59, 59, GETPOSTINT('search_dateshipping_endmonth'), GETPOSTINT('search_dateshipping_endday'), GETPOSTINT('search_dateshipping_endyear'));
$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datedelivery_startmonth'), GETPOSTINT('search_datedelivery_startday'), GETPOSTINT('search_datedelivery_startyear'));
$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOSTINT('search_datedelivery_endmonth'), GETPOSTINT('search_datedelivery_endday'), GETPOSTINT('search_datedelivery_endyear'));
$search_datereceipt_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datereceipt_startmonth'), GETPOSTINT('search_datereceipt_startday'), GETPOSTINT('search_datereceipt_startyear'));
@@ -144,9 +146,10 @@ $arrayfields = array(
'country.code_iso' => array('label' => $langs->trans("Country"), 'checked' => 0, 'position' => 7),
'typent.code' => array('label' => $langs->trans("ThirdPartyType"), 'checked' => $checkedtypetiers, 'position' => 8),
'e.date_delivery' => array('label' => $langs->trans("DateDeliveryPlanned"), 'checked' => 1, 'position' => 9),
'e.fk_shipping_method' => array('label' => $langs->trans('SendingMethod'), 'checked' => 1, 'position' => 10),
'e.tracking_number' => array('label' => $langs->trans("TrackingNumber"), 'checked' => 1, 'position' => 11),
'e.weight' => array('label' => $langs->trans("Weight"), 'checked' => 0, 'position' => 12),
'e.date_expedition' => array('label' => $langs->trans("DateShipping"), 'checked' => 1, 'position' => 10),
'e.fk_shipping_method' => array('label' => $langs->trans('SendingMethod'), 'checked' => 1, 'position' => 11),
'e.tracking_number' => array('label' => $langs->trans("TrackingNumber"), 'checked' => 1, 'position' => 12),
'e.weight' => array('label' => $langs->trans("Weight"), 'checked' => 0, 'position' => 13),
'e.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500),
'e.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 500),
'e.fk_statut' => array('label' => $langs->trans("Status"), 'checked' => 1, 'position' => 1000),
@@ -213,6 +216,8 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_shipping_method_ids = [];
$search_type_thirdparty = '';
$search_billed = '';
$search_dateshipping_start = '';
$search_dateshipping_end = '';
$search_datedelivery_start = '';
$search_datedelivery_end = '';
$search_datereceipt_start = '';
@@ -567,6 +572,12 @@ if (empty($reshook)) {
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
$param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
}
if ($search_dateshipping_start) {
$param .= '&search_dateshipping_startday='.urlencode(dol_print_date($search_dateshipping_start, '%d')).'&search_dateshipping_startmonth='.urlencode(dol_print_date($search_dateshipping_start, '%m')).'&search_dateshipping_startyear='.urlencode(dol_print_date($search_dateshipping_start, '%Y'));
}
if ($search_dateshipping_end) {
$param .= '&search_dateshipping_endday='.urlencode(dol_print_date($search_dateshipping_end, '%d')).'&search_dateshipping_endmonth='.urlencode(dol_print_date($search_dateshipping_end, '%m')).'&search_dateshipping_endyear='.urlencode(dol_print_date($search_dateshipping_end, '%Y'));
}
if ($search_datedelivery_start) {
$param .= '&search_datedelivery_startday='.urlencode(dol_print_date($search_datedelivery_start, '%d')).'&search_datedelivery_startmonth='.urlencode(dol_print_date($search_datedelivery_start, '%m')).'&search_datedelivery_startyear='.urlencode(dol_print_date($search_datedelivery_start, '%Y'));
}
@@ -667,7 +678,7 @@ $sql = 'SELECT';
if ($search_all || $search_user > 0) {
$sql = 'SELECT DISTINCT';
}
$sql .= " e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.weight, e.weight_units, e.date_delivery as delivery_date, e.fk_statut, e.signed_status, e.billed, e.tracking_number, e.fk_shipping_method,";
$sql .= " e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.weight, e.weight_units, e.date_expedition, e.date_delivery as delivery_date, e.fk_statut, e.signed_status, e.billed, e.tracking_number, e.fk_shipping_method,";
if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) {
// Link for delivery fields ref and date. Does not duplicate the line because we should always have only 1 link or 0 per shipment
$sql .= " l.date_delivery as date_reception,";
@@ -771,6 +782,12 @@ if ($search_company) {
if ($search_ref_exp) {
$sql .= natural_search('e.ref', $search_ref_exp);
}
if ($search_dateshipping_start) {
$sql .= " AND e.date_expedition >= '".$db->idate($search_dateshipping_start)."'";
}
if ($search_dateshipping_end) {
$sql .= " AND e.date_expedition <= '".$db->idate($search_dateshipping_end)."'";
}
if ($search_datedelivery_start) {
$sql .= " AND e.date_delivery >= '".$db->idate($search_datedelivery_start)."'";
}
@@ -978,6 +995,12 @@ if ($search_zip) {
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
$param .= '&search_type_thirdparty='.urlencode((string) ($search_type_thirdparty));
}
if ($search_dateshipping_start) {
$param .= '&search_dateshipping_startday='.urlencode(dol_print_date($search_dateshipping_start, '%d')).'&search_dateshipping_startmonth='.urlencode(dol_print_date($search_dateshipping_start, '%m')).'&search_dateshipping_startyear='.urlencode(dol_print_date($search_dateshipping_start, '%Y'));
}
if ($search_dateshipping_end) {
$param .= '&search_dateshipping_endday='.urlencode(dol_print_date($search_dateshipping_end, '%d')).'&search_dateshipping_endmonth='.urlencode(dol_print_date($search_dateshipping_end, '%m')).'&search_dateshipping_endyear='.urlencode(dol_print_date($search_dateshipping_end, '%Y'));
}
if ($search_datedelivery_start) {
$param .= '&search_datedelivery_startday='.urlencode(dol_print_date($search_datedelivery_start, '%d')).'&search_datedelivery_startmonth='.urlencode(dol_print_date($search_datedelivery_start, '%m')).'&search_datedelivery_startyear='.urlencode(dol_print_date($search_datedelivery_start, '%Y'));
}
@@ -1248,6 +1271,17 @@ if (!empty($arrayfields['e.date_delivery']['checked'])) {
print '</div>';
print '</td>';
}
// Date shipping
if (!empty($arrayfields['e.date_expedition']['checked'])) {
print '<td class="liste_titre center">';
print '<div class="nowrapfordate">';
print $form->selectDate($search_dateshipping_start ? $search_dateshipping_start : -1, 'search_dateshipping_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '<div class="nowrapfordate">';
print $form->selectDate($search_dateshipping_end ? $search_dateshipping_end : -1, 'search_dateshipping_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
print '</div>';
print '</td>';
}
if (!empty($arrayfields['e.fk_shipping_method']['checked'])) {
// Delivery method
print '<td class="liste_titre center">';
@@ -1268,7 +1302,7 @@ if (!empty($arrayfields['l.ref']['checked'])) {
print '</td>';
}
if (!empty($arrayfields['l.date_delivery']['checked'])) {
// Date received
// Date reception
print '<td class="liste_titre center">';
print '<div class="nowrapfordate">';
print $form->selectDate($search_datereceipt_start ? $search_datereceipt_start : -1, 'search_datereceipt_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
@@ -1385,6 +1419,10 @@ if (!empty($arrayfields['e.date_delivery']['checked'])) {
print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['e.date_expedition']['checked'])) {
print_liste_field_titre($arrayfields['e.date_expedition']['label'], $_SERVER["PHP_SELF"], "e.date_expedition", "", $param, '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
}
if (!empty($arrayfields['e.fk_shipping_method']['checked'])) {
print_liste_field_titre($arrayfields['e.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "e.fk_shipping_method", "", $param, '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
@@ -1602,6 +1640,15 @@ while ($i < $imaxinloop) {
$totalarray['nbfield']++;
}
}
// Date shipping
if (!empty($arrayfields['e.date_expedition']['checked'])) {
print '<td class="center nowraponall">';
print dol_print_date($db->jdate($obj->date_expedition), "dayhour");
print "</td>\n";
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['e.fk_shipping_method']['checked'])) {
// Get code using getLabelFromKey
$code = $langs->getLabelFromKey($db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');

View File

@@ -6,7 +6,8 @@ DeliveryOrder=Delivery receipt
DeliveryDate=Delivery date
CreateDeliveryOrder=Generate delivery receipt
DeliveryStateSaved=Delivery state saved
SetDeliveryDate=Set shipping date
SetDeliveryDate=Set estimated delivery date
SetShippingDate=Set shipping date
ValidateDeliveryReceipt=Validate delivery receipt
ValidateDeliveryReceiptConfirm=Are you sure you want to validate this delivery receipt?
DeleteDeliveryReceipt=Delete delivery receipt

View File

@@ -44,6 +44,7 @@ ConfirmCancelSending=Are you sure you want to cancel this shipment?
DocumentModelMerou=Merou A5 model
WarningNoQtyLeftToSend=Warning, no products waiting to be shipped.
StatsOnShipmentsOnlyValidated=Statistics are only for validated shipments. Date used is the date of validation of shipment (planned delivery date is not always known)
DateShipping=Sending date
DateDeliveryPlanned=Planned date of delivery
RefDeliveryReceipt=Ref delivery receipt
StatusReceipt=Status delivery receipt

View File

@@ -6,7 +6,8 @@ DeliveryOrder=Bon de réception
DeliveryDate=Date de livraison
CreateDeliveryOrder=Générer bon de réception
DeliveryStateSaved=Le statut de livraison est enregistré
SetDeliveryDate=Définir la date d'expédition
SetDeliveryDate=Définir la date prévue de livraison
SetShippingDate=Définir la date d'expédition
ValidateDeliveryReceipt=Valider le bon de livraison
ValidateDeliveryReceiptConfirm=Êtes-vous sûr de vouloir valider ce bon de livraison ?
DeleteDeliveryReceipt=Supprimer le bon de livraison

View File

@@ -44,6 +44,7 @@ ConfirmCancelSending=Êtes-vous sûr de vouloir annuler cette expédition ?
DocumentModelMerou=Modèle Merou A5
WarningNoQtyLeftToSend=Alerte, aucun produit en attente d'expédition.
StatsOnShipmentsOnlyValidated=Les statistiques ne prennent en compte que les envois validés. La date utilisée est celle qui est la date de validation de l'envoi (la date de réception prévue n'est pas nécessairement connue)
DateShipping=Date dexpédition
DateDeliveryPlanned=Date prévue de livraison
RefDeliveryReceipt=Ref bon de réception
StatusReceipt=Status du bon de réception