NEW shipment signed status update (#30928)
* Added event message * Added CommonSignedObject trait. Updated LibStatut method. Removed unnecessary properties. * Added SHIPPING_MODIFY notification * Refactored to use setSignedStatus method * Updated PHPDoc. Removed unnecessary properties. Added contributor details. * Added signed status to shipping list * Added signed status to fetch method * Fixed type * Added signed status to notification message * Updated EN localization * Fixed static property * Added event message localization * Updated EN localization * Updated PHPDoc * Added signed status for use in tooltip --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
f89245b354
commit
72aec91064
9 changed files with 73 additions and 47 deletions
|
|
@ -909,30 +909,8 @@ if ($action == "importSignature") {
|
|||
// We should just create an image file with the signature.
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->begin();
|
||||
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "expedition";
|
||||
$sql .= " SET signed_status = " . ((int) $object::STATUS_SIGNED) ;
|
||||
$sql .= " WHERE rowid = " . ((int) $object->id);
|
||||
|
||||
dol_syslog(__FILE__, LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
} else {
|
||||
$num = $db->affected_rows($resql);
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
$response = "success";
|
||||
setEventMessages("ExpeditionSigned", null, 'warnings');
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
$user = new User($db);
|
||||
$object->setSignedStatus($user, Expedition::$SIGNED_STATUSES['STATUS_SIGNED_RECEIVER_ONLINE'], 0, 'SHIPPING_MODIFY');
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
|
|
|
|||
|
|
@ -123,6 +123,9 @@ trait CommonSignedObject
|
|||
*/
|
||||
public function setSignedStatusCommon(User $user, int $status, int $notrigger = 0, string $triggercode = ''): int
|
||||
{
|
||||
global $langs;
|
||||
$langs->loadLangs(array('commercial'));
|
||||
|
||||
$error = 0;
|
||||
|
||||
if ($this instanceof CommonObject) {
|
||||
|
|
@ -149,6 +152,7 @@ trait CommonSignedObject
|
|||
if (!$error) {
|
||||
$this->signed_status = $status;
|
||||
$this->db->commit();
|
||||
setEventMessages($langs->transnoentitiesnoconv('DocumentSigned'), null, 'warnings');
|
||||
return 1;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ class Notify
|
|||
'ORDER_SUPPLIER_APPROVE',
|
||||
'ORDER_SUPPLIER_SUBMIT',
|
||||
'ORDER_SUPPLIER_REFUSE',
|
||||
'SHIPPING_MODIFY',
|
||||
'SHIPPING_VALIDATE',
|
||||
'EXPENSE_REPORT_VALIDATE',
|
||||
'EXPENSE_REPORT_APPROVE',
|
||||
|
|
@ -869,6 +870,13 @@ class Notify
|
|||
$mesg .= $outputlangs->transnoentitiesnoconv("EMailTextSupplierOrderRefusedBy", $link, $user->getFullName($outputlangs));
|
||||
$mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n";
|
||||
break;
|
||||
case 'SHIPPING_MODIFY':
|
||||
$link = '<a href="'.$urlwithroot.'/expedition/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
|
||||
$context_info = array_key_exists('signature', $object->context) ? $object->getLibSignedStatus() : '';
|
||||
$dir_output = $conf->expedition->dir_output."/sending/".get_exdir(0, 0, 0, 1, $object, 'shipment');
|
||||
$object_type = 'shipping';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpeditionModified", $link, $context_info);
|
||||
break;
|
||||
case 'SHIPPING_VALIDATE':
|
||||
$link = '<a href="'.$urlwithroot.'/expedition/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
|
||||
$dir_output = $conf->expedition->dir_output."/sending/".get_exdir(0, 0, 0, 1, $object, 'shipment');
|
||||
|
|
@ -1174,6 +1182,13 @@ class Notify
|
|||
$mesg .= $langs->transnoentitiesnoconv("EMailTextSupplierOrderRefusedBy", $link, $user->getFullName($langs));
|
||||
$mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
|
||||
break;
|
||||
case 'SHIPPING_MODIFY':
|
||||
$link = '<a href="'.$urlwithroot.'/expedition/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
|
||||
$context_info = array_key_exists('signature', $object->context) ? $object->getLibSignedStatus() : '';
|
||||
$dir_output = $conf->expedition->dir_output."/sending/".get_exdir(0, 0, 0, 1, $object, 'shipment');
|
||||
$object_type = 'order_supplier';
|
||||
$mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionModified", $link, $context_info);
|
||||
break;
|
||||
case 'SHIPPING_VALIDATE':
|
||||
$link = '<a href="'.$urlwithroot.'/expedition/card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
|
||||
$dir_output = $conf->expedition->dir_output."/sending/".get_exdir(0, 0, 0, 1, $object, 'shipment');
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '')
|
|||
|
||||
$sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,";
|
||||
$sql .= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_elementdet, ed.fk_entrepot as warehouse_id,";
|
||||
$sql .= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition, e.billed, e.fk_statut as status,";
|
||||
$sql .= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition, e.billed, e.fk_statut as status, e.signed_status,";
|
||||
$sql .= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,';
|
||||
$sql .= ' p.description as product_desc';
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed,";
|
||||
|
|
@ -304,6 +304,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '')
|
|||
$expedition->billed = $objp->billed;
|
||||
$expedition->statut = $objp->status;
|
||||
$expedition->status = $objp->status;
|
||||
$expedition->signed_status = $objp->signed_status;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2020 Lenin Rivas <lenin@leninrivas.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -45,14 +46,18 @@ if (isModEnabled('order')) {
|
|||
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
}
|
||||
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionlinebatch.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonsignedobject.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage shipments
|
||||
* @property int $signed_status
|
||||
* @static array<int> $SIGNED_STATUSES
|
||||
*/
|
||||
class Expedition extends CommonObject
|
||||
{
|
||||
use CommonIncoterm;
|
||||
use CommonSignedObject;
|
||||
|
||||
/**
|
||||
* @var string ID to identify managed object
|
||||
|
|
@ -219,11 +224,6 @@ class Expedition extends CommonObject
|
|||
public $multicurrency_total_tva;
|
||||
public $multicurrency_total_ttc;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $signed_status = 0;
|
||||
|
||||
/**
|
||||
* Draft status
|
||||
*/
|
||||
|
|
@ -259,19 +259,6 @@ class Expedition extends CommonObject
|
|||
*/
|
||||
const STATUS_SHIPMENT_IN_PROGRESS = 3;
|
||||
|
||||
|
||||
/**
|
||||
* No signature
|
||||
*/
|
||||
const STATUS_NO_SIGNATURE = 0;
|
||||
|
||||
/**
|
||||
* Signed status
|
||||
*/
|
||||
const STATUS_SIGNED = 1;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
|
@ -402,6 +389,7 @@ class Expedition extends CommonObject
|
|||
$sql .= ", note_public";
|
||||
$sql .= ", model_pdf";
|
||||
$sql .= ", fk_incoterms, location_incoterms";
|
||||
$sql .= ", signed_status";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= "'(PROV)'";
|
||||
$sql .= ", ".((int) $conf->entity);
|
||||
|
|
@ -427,6 +415,7 @@ class Expedition extends CommonObject
|
|||
$sql .= ", ".(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null");
|
||||
$sql .= ", ".(int) $this->fk_incoterms;
|
||||
$sql .= ", '".$this->db->escape($this->location_incoterms)."'";
|
||||
$sql .= ", ".($this->signed_status);
|
||||
$sql .= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
|
|
@ -608,7 +597,7 @@ class Expedition extends CommonObject
|
|||
return -1;
|
||||
}
|
||||
|
||||
$sql = "SELECT e.rowid, e.entity, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.fk_user_author, e.fk_statut, e.fk_projet as fk_project, e.billed";
|
||||
$sql = "SELECT e.rowid, e.entity, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.fk_user_author, e.fk_statut, e.signed_status, e.fk_projet as fk_project, e.billed";
|
||||
$sql .= ", e.date_valid";
|
||||
$sql .= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height";
|
||||
$sql .= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery";
|
||||
|
|
@ -648,6 +637,7 @@ class Expedition extends CommonObject
|
|||
$this->ref_ext = $obj->ref_ext;
|
||||
$this->status = $obj->fk_statut;
|
||||
$this->statut = $this->status; // Deprecated
|
||||
$this->signed_status = $obj->signed_status;
|
||||
$this->user_author_id = $obj->fk_user_author;
|
||||
$this->fk_user_author = $obj->fk_user_author;
|
||||
$this->date_creation = $this->db->jdate($obj->date_creation);
|
||||
|
|
@ -1997,7 +1987,11 @@ class Expedition extends CommonObject
|
|||
$statusType = 'status9';
|
||||
}
|
||||
|
||||
return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
|
||||
$signed_label = ' (' . $this->getLibSignedStatus() . ')';
|
||||
$status_label = $this->signed_status ? $labelStatus . $signed_label : $labelStatus;
|
||||
$status_label_short = $this->signed_status ? $labelStatusShort . $signed_label : $labelStatusShort;
|
||||
|
||||
return dolGetStatus($status_label, $status_label_short, '', $statusType, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
|
||||
* Copyright (C) 2024 Vincent Maury <vmaury@timgroup.fr>
|
||||
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -96,6 +97,7 @@ $pageprev = $page - 1;
|
|||
$pagenext = $page + 1;
|
||||
|
||||
$search_status = GETPOST('search_status', 'intcomma');
|
||||
$search_signed_status = GETPOST('search_signed_status', 'alpha');
|
||||
|
||||
$diroutputmassaction = $conf->expedition->dir_output.'/sending/temp/massgeneration/'.$user->id;
|
||||
|
||||
|
|
@ -139,6 +141,7 @@ $arrayfields = array(
|
|||
'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),
|
||||
'e.signed_status' =>array('label' => 'Signed status', 'checked' => 0, 'position' => 1001),
|
||||
'l.ref' => array('label' => $langs->trans("DeliveryRef"), 'checked' => 1, 'position' => 1010, 'enabled' => (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') ? 1 : 0)),
|
||||
'l.date_delivery' => array('label' => $langs->trans("DateReceived"), 'position' => 1020, 'checked' => 1, 'enabled' => (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') ? 1 : 0)),
|
||||
'e.billed' => array('label' => $langs->trans("Billed"), 'checked' => 1, 'position' => 1100, 'enabled' => 'getDolGlobalString("WORKFLOW_BILL_ON_SHIPMENT") !== "0"'),
|
||||
|
|
@ -206,6 +209,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
|
|||
$search_datereceipt_start = '';
|
||||
$search_datereceipt_end = '';
|
||||
$search_status = '';
|
||||
$search_signed_status = '';
|
||||
$toselect = array();
|
||||
$search_array_options = array();
|
||||
$search_categ_cus = 0;
|
||||
|
|
@ -574,6 +578,9 @@ if (empty($reshook)) {
|
|||
if ($search_status != '') {
|
||||
$param .= '&search_status='.urlencode($search_status);
|
||||
}
|
||||
if ($search_signed_status != '' && $search_signed_status >= 0) {
|
||||
$param .= '&search_signed_status='.urlencode($search_signed_status);
|
||||
}
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
|
|
@ -650,7 +657,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.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_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,";
|
||||
|
|
@ -714,6 +721,9 @@ if ($socid) {
|
|||
if ($search_status != '' && $search_status >= 0) {
|
||||
$sql .= " AND e.fk_statut = ".((int) $search_status);
|
||||
}
|
||||
if ($search_signed_status != '' && $search_signed_status >= 0) {
|
||||
$sql .= ' AND e.signed_status = '.urlencode($search_signed_status);
|
||||
}
|
||||
if ($search_ref_customer != '') {
|
||||
$sql .= natural_search('e.ref_customer', $search_ref_customer);
|
||||
}
|
||||
|
|
@ -979,6 +989,9 @@ if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
|
|||
if ($search_status != '') {
|
||||
$param .= '&search_status='.urlencode($search_status);
|
||||
}
|
||||
if ($search_signed_status != '' && $search_signed_status >= 0) {
|
||||
$param .= '&search_signed_status='.urlencode($search_signed_status);
|
||||
}
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
|
|
@ -1288,6 +1301,13 @@ if (!empty($arrayfields['e.fk_statut']['checked'])) {
|
|||
print $form->selectarray('search_status', array('0' => $langs->trans('StatusSendingDraftShort'), '1' => $langs->trans('StatusSendingValidatedShort'), '2' => $langs->trans('StatusSendingProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
|
||||
print '</td>';
|
||||
}
|
||||
// Signed status
|
||||
if (!empty($arrayfields['e.signed_status']['checked'])) {
|
||||
print '<td class="liste_titre center">';
|
||||
$list_signed_status = $object->getSignedStatusLocalisedArray();
|
||||
print $form->selectarray('search_signed_status', $list_signed_status, $search_signed_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status');
|
||||
print '</td>';
|
||||
}
|
||||
// Status billed
|
||||
if (!empty($arrayfields['e.billed']['checked'])) {
|
||||
print '<td class="liste_titre maxwidthonsmartphone center">';
|
||||
|
|
@ -1395,6 +1415,10 @@ if (!empty($arrayfields['e.fk_statut']['checked'])) {
|
|||
print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
if (!empty($arrayfields['e.signed_status']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.signed_status']['label'], $_SERVER["PHP_SELF"], "e.signed_status", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
if (!empty($arrayfields['e.billed']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
$totalarray['nbfield']++;
|
||||
|
|
@ -1658,6 +1682,13 @@ while ($i < $imaxinloop) {
|
|||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
// Signed Status
|
||||
if (!empty($arrayfields['e.signed_status']['checked'])) {
|
||||
print '<td class="center">'.$object->getLibSignedStatus(5).'</td>';
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
// Billed
|
||||
if (!empty($arrayfields['e.billed']['checked'])) {
|
||||
print '<td class="center">'.yn($obj->billed).'</td>';
|
||||
|
|
|
|||
|
|
@ -101,3 +101,4 @@ SignedReceiver=Signed by third party
|
|||
SignedReceiverOnline=Signed by third party online
|
||||
SignedAll=Signed by all parties
|
||||
SignStatus=Signature status
|
||||
DocumentSigned=Document signed
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ Notify_FICHINTER_MODIFY=Intervention modified
|
|||
Notify_FICHINTER_CLOSE=Intervention closed
|
||||
Notify_FICHINTER_ADD_CONTACT=Added contact to Intervention
|
||||
Notify_FICHINTER_SENTBYMAIL=Intervention sent by mail
|
||||
Notify_SHIPPING_MODIFY=Shipping modified
|
||||
Notify_SHIPPING_VALIDATE=Shipping validated
|
||||
Notify_SHIPPING_SENTBYMAIL=Shipping sent by mail
|
||||
Notify_MEMBER_VALIDATE=Member validated
|
||||
|
|
@ -229,6 +230,7 @@ EMailTextSupplierOrderCanceledBy=Purchase order %s has been canceled by %s.
|
|||
EMailTextSupplierOrderValidatedBy=Purchase order %s has been recorded by %s.
|
||||
EMailTextSupplierOrderSubmittedBy=Purchase order %s has been submitted by %s.
|
||||
EMailTextSupplierOrderRefusedBy=Purchase order %s has been refused by %s.
|
||||
EMailTextExpeditionModified=Shipping %s has been validated. %s
|
||||
EMailTextExpeditionValidated=Shipping %s has been validated.
|
||||
EMailTextExpenseReportValidated=Expense report %s has been validated.
|
||||
EMailTextExpenseReportApproved=Expense report %s has been approved.
|
||||
|
|
|
|||
|
|
@ -835,7 +835,7 @@ if ($action == "dosign" && empty($cancel)) {
|
|||
print '<input type="submit" class="butAction small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignFichinter").'">';
|
||||
}
|
||||
} elseif ($source == 'expedition') {
|
||||
if ($message == 'signed' || $object->signed_status == Expedition::STATUS_SIGNED) {
|
||||
if ($message == 'signed' || $object->signed_status == Expedition::$SIGNED_STATUSES['STATUS_SIGNED_SENDER']) {
|
||||
print '<span class="ok">'.$langs->trans("ExpeditionSigned").'</span>';
|
||||
} else {
|
||||
print '<input type="submit" class="butAction small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignExpedition").'">';
|
||||
|
|
|
|||
Loading…
Reference in a new issue