Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions htdocs/core/class/notify.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,7 @@ class Notify
'ACTION_CREATE',
'CONTRACT_MODIFY',
'STOCKTRANSFER_CREATE',
'STOCKTRANSFER_MODIFY',
'STOCKTRANSFER_VALIDATE',
'STOCKTRANSFER_UNVALIDATE',
'STOCKTRANSFER_CLOSE',
'STOCKTRANSFER_DESTOCK',
'STOCKTRANSFER_DESTOCK_CANCEL',
'STOCKTRANSFER_ADDSTOCK',
'STOCKTRANSFER_ADDSTOCK_CANCEL'
'STOCKTRANSFER_MODIFY'
);

/**
Expand Down Expand Up @@ -943,6 +936,30 @@ public function send($notifcode, $object, $filename_list = array(), $mimetype_li
$object_type = 'contract';
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextContractModified", $link, $context_info);
break;
case 'STOCKTRANSFER_CREATE':
$link = '<a href="'.$urlwithroot.'/product/stock/stocktransfer/stocktransfer_card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
$dir_output = $conf->stocktransfer->dir_output."/stocktransfer/".dol_sanitizeFileName($newref);
$object_type = 'stocktransfer';
$mesg = $outputlangs->transnoentitiesnoconv('Notify_STOCKTRANSFER_CREATE')." ".$link;
break;
case 'STOCKTRANSFER_MODIFY':
$link = '<a href="'.$urlwithroot.'/product/stock/stocktransfer/stocktransfer_card.php?id='.$object->id.'&entity='.$object->entity.'">'.$newref.'</a>';
$dir_output = $conf->stocktransfer->dir_output."/stocktransfer/".dol_sanitizeFileName($newref);
$object_type = 'stocktransfer';
$template = 'STOCKTRANSFER_MODIFY_TEMPLATE';
$eventKey = 'Notify_STOCKTRANSFER_MODIFY';
if (!empty($object->context['stocktransfer_event'])) {
$eventKeyCandidate = 'Notify_STOCKTRANSFER_MODIFY_'.strtoupper($object->context['stocktransfer_event']);
$templateCandidate = 'STOCKTRANSFER_MODIFY_'.strtoupper($object->context['stocktransfer_event']).'_TEMPLATE';
if (!empty(getDolGlobalString($templateCandidate))) {
$template = $templateCandidate;
}
if ($outputlangs->transnoentities($eventKeyCandidate) != $eventKeyCandidate) {
$eventKey = $eventKeyCandidate;
}
}
$mesg = $outputlangs->transnoentitiesnoconv($eventKey)." ".$link;
break;
default:
$object_type = $object->element;
$dir_output = $conf->$object_type->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object, $object_type);
Expand All @@ -955,7 +972,9 @@ public function send($notifcode, $object, $filename_list = array(), $mimetype_li
$formmail = new FormMail($this->db);
$arraydefaultmessage = null;

$template = $notifcode.'_TEMPLATE';
if (empty($template)) {
$template = $notifcode.'_TEMPLATE';
}
$labeltouse = getDolGlobalString($template);
if (!empty($labeltouse)) {
$arraydefaultmessage = $formmail->getEMailTemplate($this->db, $object_type, $user, $outputlangs, 0, 1, $labeltouse);
Expand Down
7 changes: 0 additions & 7 deletions htdocs/install/mysql/data/llx_c_action_trigger.sql
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,6 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_CANCEL','MO canceled','Executed when a MO is canceled','mrp',663);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('STOCKTRANSFER_CREATE','Stock transfer created','Executed when a stock transfer is created','stocktransfer',670);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('STOCKTRANSFER_MODIFY','Stock transfer modified','Executed when a stock transfer is modified','stocktransfer',671);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('STOCKTRANSFER_VALIDATE','Stock transfer validated','Executed when a stock transfer is validated','stocktransfer',672);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('STOCKTRANSFER_UNVALIDATE','Stock transfer back to draft','Executed when a stock transfer is set back to draft','stocktransfer',673);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('STOCKTRANSFER_DESTOCK','Stock transfer source stock decremented','Executed when source warehouses stock is decremented for a stock transfer','stocktransfer',674);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('STOCKTRANSFER_DESTOCK_CANCEL','Stock transfer source stock decrement canceled','Executed when source warehouses stock decrement is canceled for a stock transfer','stocktransfer',675);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('STOCKTRANSFER_CLOSE','Stock transfer closed','Executed when a stock transfer is closed after destination stock increment','stocktransfer',676);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('STOCKTRANSFER_ADDSTOCK','Stock transfer destination stock incremented','Executed when destination warehouses stock is incremented for a stock transfer','stocktransfer',677);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('STOCKTRANSFER_ADDSTOCK_CANCEL','Stock transfer destination stock increment canceled','Executed when destination warehouses stock increment is canceled for a stock transfer','stocktransfer',678);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTACT_CREATE','Contact address created','Executed when a contact is created','contact',50);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTACT_MODIFY','Contact address update','Executed when a contact is updated','contact',51);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTACT_SENTBYMAIL','Mails sent from third party card','Executed when you send email from contact address record','contact',52);
Expand Down
7 changes: 0 additions & 7 deletions htdocs/install/mysql/migration/23.0.0-24.0.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,6 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private,

INSERT IGNORE INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('STOCKTRANSFER_CREATE','Stock transfer created','Executed when a stock transfer is created','stocktransfer',670);
INSERT IGNORE INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('STOCKTRANSFER_MODIFY','Stock transfer modified','Executed when a stock transfer is modified','stocktransfer',671);
INSERT IGNORE INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('STOCKTRANSFER_VALIDATE','Stock transfer validated','Executed when a stock transfer is validated','stocktransfer',672);
INSERT IGNORE INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('STOCKTRANSFER_UNVALIDATE','Stock transfer back to draft','Executed when a stock transfer is set back to draft','stocktransfer',673);
INSERT IGNORE INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('STOCKTRANSFER_DESTOCK','Stock transfer source stock decremented','Executed when source warehouses stock is decremented for a stock transfer','stocktransfer',674);
INSERT IGNORE INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('STOCKTRANSFER_DESTOCK_CANCEL','Stock transfer source stock decrement canceled','Executed when source warehouses stock decrement is canceled for a stock transfer','stocktransfer',675);
INSERT IGNORE INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('STOCKTRANSFER_CLOSE','Stock transfer closed','Executed when a stock transfer is closed after destination stock increment','stocktransfer',676);
INSERT IGNORE INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('STOCKTRANSFER_ADDSTOCK','Stock transfer destination stock incremented','Executed when destination warehouses stock is incremented for a stock transfer','stocktransfer',677);
INSERT IGNORE INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('STOCKTRANSFER_ADDSTOCK_CANCEL','Stock transfer destination stock increment canceled','Executed when destination warehouses stock increment is canceled for a stock transfer','stocktransfer',678);

ALTER TABLE llx_c_ticket_category ADD COLUMN fk_ticket_type integer NULL;
-- end of migration
15 changes: 8 additions & 7 deletions htdocs/langs/en_US/other.lang
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,11 @@ SendPrompt=Send
ConfirmAiAction=Are you sure you want to %1$s using the %2$s tool?

Notify_STOCKTRANSFER_CREATE=Stock transfer created
Notify_STOCKTRANSFER_VALIDATE=Stock transfer validated
Notify_STOCKTRANSFER_UNVALIDATE=Stock transfer set back to draft
Notify_STOCKTRANSFER_DESTOCK=Source stock decreased for stock transfer
Notify_STOCKTRANSFER_DESTOCK_CANCEL=Source stock decrease cancelled for stock transfer
Notify_STOCKTRANSFER_CLOSE=Stock transfer closed
Notify_STOCKTRANSFER_ADDSTOCK=Destination stock increased for stock transfer
Notify_STOCKTRANSFER_ADDSTOCK_CANCEL=Destination stock increase cancelled for stock transfer
Notify_STOCKTRANSFER_MODIFY=Stock transfer modified
Notify_STOCKTRANSFER_MODIFY_ADDSTOCK_CANCEL=Destination stock increase cancelled for stock transfer
Notify_STOCKTRANSFER_MODIFY_ADDSTOCK=Destination stock increased for stock transfer
Notify_STOCKTRANSFER_MODIFY_CLOSE=Stock transfer closed
Notify_STOCKTRANSFER_MODIFY_DESTOCK_CANCEL=Source stock decrease cancelled for stock transfer
Notify_STOCKTRANSFER_MODIFY_DESTOCK=Source stock decreased for stock transfer
Notify_STOCKTRANSFER_MODIFY_UNVALIDATE=Stock transfer set back to draft
Notify_STOCKTRANSFER_MODIFY_VALIDATE=Stock transfer validated
17 changes: 14 additions & 3 deletions htdocs/product/stock/stocktransfer/class/stocktransfer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,11 @@ public function validate($user, $notrigger = 0)
}

if (!$error && !$notrigger) {
if (empty($this->context['stocktransfer_event'])) {
$this->context['stocktransfer_event'] = 'validate';
}
// Call trigger
$result = $this->call_trigger('STOCKTRANSFER_VALIDATE', $user);
$result = $this->call_trigger('STOCKTRANSFER_MODIFY', $user);
if ($result < 0) {
$error++;
}
Expand Down Expand Up @@ -718,7 +721,11 @@ public function setDraft($user, $notrigger = 0)
return 0;
}

return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'STOCKTRANSFER_UNVALIDATE');
if (empty($this->context['stocktransfer_event'])) {
$this->context['stocktransfer_event'] = 'unvalidate';
}

return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'STOCKTRANSFER_MODIFY');
}

/**
Expand All @@ -735,7 +742,11 @@ public function cancel($user, $notrigger = 0)
return 0;
}

return $this->setStatusCommon($user, self::STATUS_CLOSED, $notrigger, 'STOCKTRANSFER_CLOSE');
if (empty($this->context['stocktransfer_event'])) {
$this->context['stocktransfer_event'] = 'close';
}

return $this->setStatusCommon($user, self::STATUS_CLOSED, $notrigger, 'STOCKTRANSFER_MODIFY');
}

/**
Expand Down
37 changes: 12 additions & 25 deletions htdocs/product/stock/stocktransfer/stocktransfer_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@

$triggermodname = 'STOCKTRANSFER_MODIFY'; // Name of trigger action code to execute when we modify record

if ($action == 'confirm_validate' && $confirm == 'yes') {
$object->context['stocktransfer_event'] = 'validate';
} elseif ($action == 'confirm_setdraft' && $confirm == 'yes') {
$object->context['stocktransfer_event'] = 'unvalidate';
} elseif ($action == 'confirm_close' && $confirm == 'yes') {
$object->context['stocktransfer_event'] = 'close';
}

// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';

Expand Down Expand Up @@ -309,12 +317,8 @@
$object->setStatut($object::STATUS_TRANSFERED, $id);
$object->status = $object::STATUS_TRANSFERED;
$object->date_reelle_depart = dol_now();
$object->context['stocktransfer_event'] = 'destock';
$object->update($user);
$result = $object->call_trigger('STOCKTRANSFER_DESTOCK', $user);
if ($result < 0) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
setEventMessage('StockStransferDecremented');
}
}
Expand All @@ -341,12 +345,8 @@
$object->setStatut($object::STATUS_VALIDATED, $id);
$object->status = $object::STATUS_VALIDATED;
$object->date_reelle_depart = null;
$object->context['stocktransfer_event'] = 'destock_cancel';
$object->update($user);
$result = $object->call_trigger('STOCKTRANSFER_DESTOCK_CANCEL', $user);
if ($result < 0) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
setEventMessage('StockStransferDecrementedCancel', 'warnings');
}
}
Expand All @@ -373,17 +373,8 @@
$object->setStatut($object::STATUS_CLOSED, $id);
$object->status = $object::STATUS_CLOSED;
$object->date_reelle_arrivee = dol_now();
$object->context['stocktransfer_event'] = 'addstock';
$object->update($user);
$result = $object->call_trigger('STOCKTRANSFER_CLOSE', $user);
if ($result < 0) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
$result = $object->call_trigger('STOCKTRANSFER_ADDSTOCK', $user);
if ($result < 0) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
setEventMessage('StockStransferIncrementedShort');
}
}
Expand All @@ -410,12 +401,8 @@
$object->setStatut($object::STATUS_TRANSFERED, $id);
$object->status = $object::STATUS_TRANSFERED;
$object->date_reelle_arrivee = null;
$object->context['stocktransfer_event'] = 'addstock_cancel';
$object->update($user);
$result = $object->call_trigger('STOCKTRANSFER_ADDSTOCK_CANCEL', $user);
if ($result < 0) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
setEventMessage('StockStransferIncrementedShortCancel', 'warnings');
}
}
Expand Down
Loading