mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW Can go back to draft on shipment when stock change not on validate
This commit is contained in:
parent
8ba802ed5d
commit
90bca8b4d7
|
|
@ -9982,7 +9982,7 @@ abstract class CommonObject
|
|||
$this->db->begin();
|
||||
|
||||
$statusfield = 'status';
|
||||
if ($this->element == 'don' || $this->element == 'donation') {
|
||||
if (in_array($this->element, array('don', 'donation', 'shipping'))) {
|
||||
$statusfield = 'fk_statut';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5087,21 +5087,21 @@ class Form
|
|||
* print '});'."\n";
|
||||
* print '</script>'."\n";
|
||||
*
|
||||
* @param string $page Url of page to call if confirmation is OK. Can contains parameters (param 'action' and 'confirm' will be reformated)
|
||||
* @param string $title Title
|
||||
* @param string $question Question
|
||||
* @param string $action Action
|
||||
* @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>'autofocus' or 'style=...'))
|
||||
* 'type' can be 'text', 'password', 'checkbox', 'radio', 'date', 'datetime', 'select', 'multiselect', 'morecss',
|
||||
* 'other', 'onecolumn' or 'hidden'...
|
||||
* @param int|string $selectedchoice '' or 'no', or 'yes' or '1', 1, '0' or 0
|
||||
* @param int|string $useajax 0=No, 1=Yes use Ajax to show the popup, 2=Yes and also submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx
|
||||
* @param int|string $height Force height of box (0 = auto)
|
||||
* @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones.
|
||||
* @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a <form> section.
|
||||
* @param string $labelbuttonyes Label for Yes
|
||||
* @param string $labelbuttonno Label for No
|
||||
* @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form
|
||||
* @param string $page Url of page to call if confirmation is OK. Can contains parameters (param 'action' and 'confirm' will be reformated)
|
||||
* @param string $title Title
|
||||
* @param string $question Question
|
||||
* @param string $action Action
|
||||
* @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>'autofocus' or 'style=...'))
|
||||
* 'type' can be 'text', 'password', 'checkbox', 'radio', 'date', 'datetime', 'select', 'multiselect', 'morecss',
|
||||
* 'other', 'onecolumn' or 'hidden'...
|
||||
* @param int|string $selectedchoice '' or 'no', or 'yes' or '1', 1, '0' or 0
|
||||
* @param int|string $useajax 0=No, 1=Yes use Ajax to show the popup, 2=Yes and also submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx
|
||||
* @param int|string $height Force height of box (0 = auto)
|
||||
* @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones.
|
||||
* @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a <form> section.
|
||||
* @param string $labelbuttonyes Label for Yes
|
||||
* @param string $labelbuttonno Label for No
|
||||
* @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form
|
||||
*/
|
||||
public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0, $labelbuttonyes = 'Yes', $labelbuttonno = 'No')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -157,6 +157,14 @@ if (empty($reshook)) {
|
|||
$upload_dir = $conf->expedition->dir_output.'/sending';
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
|
||||
// Back to draft
|
||||
if ($action == 'setdraft' && $user->rights->expedition->creer) {
|
||||
$object->fetch($id);
|
||||
$result = $object->setDraft($user, 0);
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
// Reopen
|
||||
if ($action == 'reopen' && $user->rights->expedition->creer) {
|
||||
$object->fetch($id);
|
||||
|
|
@ -1740,9 +1748,9 @@ if ($action == 'create') {
|
|||
|
||||
$text = $langs->trans("ConfirmValidateSending", $numref);
|
||||
if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT')) {
|
||||
$text .= ' '.$langs->trans("StockMovementWillBeRecorded").'.';
|
||||
$text .= '<br>'.$langs->trans("StockMovementWillBeRecorded").'.';
|
||||
} elseif (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) {
|
||||
$text .= ' '.$langs->trans("StockMovementNotYetRecorded").'.';
|
||||
$text .= '<br>'.$langs->trans("StockMovementNotYetRecorded").'.';
|
||||
}
|
||||
|
||||
if (isModEnabled('notification')) {
|
||||
|
|
@ -1752,7 +1760,7 @@ if ($action == 'create') {
|
|||
$text .= $notify->confirmMessage('SHIPPING_VALIDATE', $object->socid, $object);
|
||||
}
|
||||
|
||||
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('ValidateSending'), $text, 'confirm_valid', '', 0, 1);
|
||||
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('ValidateSending'), $text, 'confirm_valid', '', 0, 1, 250);
|
||||
}
|
||||
// Confirm cancelation
|
||||
if ($action == 'cancel') {
|
||||
|
|
@ -2540,13 +2548,20 @@ if ($action == 'create') {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO add alternative status
|
||||
// 0=draft, 1=validated, 2=billed, we miss a status "delivered" (only available on order)
|
||||
if ($object->statut == Expedition::STATUS_CLOSED && $user->rights->expedition->creer) {
|
||||
if (isModEnabled('facture') && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ?
|
||||
print dolGetButtonAction('', $langs->trans('ClassifyUnbilled'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, '');
|
||||
} else {
|
||||
print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, '');
|
||||
// 0=draft, 1=validated/delivered, 2=closed/delivered
|
||||
// If WORKFLOW_BILL_ON_SHIPMENT: 0=draft, 1=validated, 2=billed (no status delivered)
|
||||
if ($object->statut == Expedition::STATUS_VALIDATED && !getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT')) {
|
||||
if ($user->hasRight('expedition', 'creer')) {
|
||||
print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?action=setdraft&token='.newToken().'&id='.$object->id, '');
|
||||
}
|
||||
}
|
||||
if ($object->statut == Expedition::STATUS_CLOSED) {
|
||||
if ($user->hasRight('expedition', 'creer')) {
|
||||
if (isModEnabled('facture') && !empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ?
|
||||
print dolGetButtonAction('', $langs->trans('ClassifyUnbilled'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, '');
|
||||
} else {
|
||||
print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2318,6 +2318,23 @@ class Expedition extends CommonObject
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set draft status
|
||||
*
|
||||
* @param User $user Object user that modify
|
||||
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function setDraft($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->statut <= self::STATUS_DRAFT) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'SHIPMENT_UNVALIDATE');
|
||||
}
|
||||
|
||||
/**
|
||||
* Classify the shipping as validated/opened
|
||||
*
|
||||
|
|
@ -2338,7 +2355,7 @@ class Expedition extends CommonObject
|
|||
|
||||
$oldbilled = $this->billed;
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1';
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut = 1';
|
||||
$sql .= " WHERE rowid = ".((int) $this->id).' AND fk_statut > 0';
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user