Merge pull request #9502 from frederic34/contractHookFormConfirm

NEW add hook formconfirm to contractcard
This commit is contained in:
Laurent Destailleur 2018-09-15 17:31:56 +02:00 committed by GitHub
commit edb3671cf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 73 additions and 79 deletions

View File

@ -1319,7 +1319,9 @@ else
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$result=$object->fetch_lines(); // This also init $this->nbofserviceswait, $this->nbofservicesopened, $this->nbofservicesexpired=, $this->nbofservicesclosed $result=$object->fetch_lines(); // This also init $this->nbofserviceswait, $this->nbofservicesopened, $this->nbofservicesexpired=, $this->nbofservicesclosed
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) {
dol_print_error($db,$object->error);
}
$nbofservices=count($object->lines); $nbofservices=count($object->lines);
@ -1335,53 +1337,51 @@ else
$head = contract_prepare_head($object); $head = contract_prepare_head($object);
$hselected = 0; $hselected = 0;
$formconfirm = '';
dol_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); dol_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract');
/* if ($action == 'delete') {
* Confirmation de la suppression du contrat //Confirmation de la suppression du contrat
*/ $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("DeleteAContract"),$langs->trans("ConfirmDeleteAContract"),"confirm_delete",'',0,1);
if ($action == 'delete') } elseif ($action == 'valid') {
{ //Confirmation de la validation
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("DeleteAContract"),$langs->trans("ConfirmDeleteAContract"),"confirm_delete",'',0,1);
}
/*
* Confirmation de la validation
*/
if ($action == 'valid')
{
$ref = substr($object->ref, 1, 4); $ref = substr($object->ref, 1, 4);
if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) {
{
$numref = $object->getNextNumRef($object->thirdparty); $numref = $object->getNextNumRef($object->thirdparty);
} } else {
else
{
$numref = $object->ref; $numref = $object->ref;
} }
$text = $langs->trans('ConfirmValidateContract',$numref);
$text=$langs->trans('ConfirmValidateContract',$numref); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ValidateAContract"),$text,"confirm_valid",'',0,1);
} elseif ($action == 'close') {
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ValidateAContract"),$text,"confirm_valid",'',0,1); // Confirmation de la fermeture
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("CloseAContract"),$langs->trans("ConfirmCloseContract"),"confirm_close",'',0,1);
} elseif ($action == 'activate') {
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ActivateAllOnContract"),$langs->trans("ConfirmActivateAllOnContract"),"confirm_activate",'',0,1);
} elseif ($action == 'clone') {
// Clone confirmation
$formquestion = array(array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)')));
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneContract'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
} }
/*
* Confirmation de la fermeture
*/
if ($action == 'close')
{
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("CloseAContract"),$langs->trans("ConfirmCloseContract"),"confirm_close",'',0,1);
// Call Hook formConfirm
$parameters = array(
'id' => $id,
//'lineid' => $lineid,
);
// Note that $action and $object may have been modified by hook
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action);
if (empty($reshook)) {
$formconfirm .= $hookmanager->resPrint;
} elseif ($reshook > 0) {
$formconfirm = $hookmanager->resPrint;
} }
if ($action == 'activate')
{
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ActivateAllOnContract"),$langs->trans("ConfirmActivateAllOnContract"),"confirm_activate",'',0,1);
} // Print form confirm
print $formconfirm;
/* /*
* Contrat * Contrat
@ -1393,12 +1393,6 @@ else
print '<input type="hidden" name="action" value="setremise">'; print '<input type="hidden" name="action" value="setremise">';
} }
// Clone confirmation
if ($action == 'clone') {
$formquestion = array(array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)')));
print $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneContract'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
// Contract card // Contract card
$linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
@ -1516,7 +1510,7 @@ else
} }
$colorb='666666'; $colorb = '666666';
$arrayothercontracts=$object->getListOfContracts('others'); $arrayothercontracts=$object->getListOfContracts('others');

View File

@ -164,15 +164,14 @@ if ($id > 0 || ! empty($ref))
// Thirdparty // Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project // Project
if (! empty($conf->projet->enabled)) if (! empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' '; $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->contrat->creer) if ($user->rights->contrat->creer) {
{ if ($action != 'classify') {
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : '; $morehtmlref.=' : ';
}
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
@ -210,9 +209,12 @@ if ($id > 0 || ! empty($ref))
// Ligne info remises tiers // Ligne info remises tiers
print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">'; print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">';
if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent); if ($object->thirdparty->remise_percent) {
else print $langs->trans("CompanyHasNoRelativeDiscount"); print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent);
$absolute_discount=$object->thirdparty->getAvailableDiscounts(); } else {
print $langs->trans("CompanyHasNoRelativeDiscount");
}
$absolute_discount = $object->thirdparty->getAvailableDiscounts();
print '. '; print '. ';
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency)); if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency));
else print $langs->trans("CompanyHasNoAbsoluteDiscount"); else print $langs->trans("CompanyHasNoAbsoluteDiscount");
@ -239,9 +241,7 @@ if ($id > 0 || ! empty($ref))
// Contacts lines // Contacts lines
include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php';
} } else {
else
{
print "ErrorRecordNotFound"; print "ErrorRecordNotFound";
} }
} }