Merge pull request #19832 from aspangaro/15a14
NEW Create contract from invoice
This commit is contained in:
commit
d41f3f1797
@ -130,6 +130,7 @@ $usercanread = $user->rights->facture->lire;
|
||||
$usercancreate = $user->rights->facture->creer;
|
||||
$usercanissuepayment = $user->rights->facture->paiement;
|
||||
$usercandelete = $user->rights->facture->supprimer;
|
||||
$usercancreatecontract = $user->rights->contrat->creer;
|
||||
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate)));
|
||||
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->send)));
|
||||
$usercanreopen = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->reopen)));
|
||||
@ -5378,6 +5379,17 @@ if ($action == 'create') {
|
||||
}
|
||||
}
|
||||
|
||||
// Create contract
|
||||
if (!empty($conf->global->CONTRACT_CREATE_FROM_INVOICE)) {
|
||||
if ($conf->contrat->enabled && $object->statut == Facture::STATUS_VALIDATED) {
|
||||
$langs->load("contracts");
|
||||
|
||||
if ($usercancreatecontract) {
|
||||
print '<a class="butAction" href="' . DOL_URL_ROOT . '/contrat/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans('AddContract') . '</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate
|
||||
if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (!empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) {
|
||||
if ($usercanvalidate) {
|
||||
|
||||
@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
if (!empty($conf->propal->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
}
|
||||
@ -248,6 +249,10 @@ if (empty($reshook)) {
|
||||
if ($element == 'propal') {
|
||||
$element = 'comm/propal'; $subelement = 'propal';
|
||||
}
|
||||
if ($element == 'invoice' || $element == 'facture') {
|
||||
$element = 'compta/facture';
|
||||
$subelement = 'facture';
|
||||
}
|
||||
|
||||
$object->origin = $origin;
|
||||
$object->origin_id = $originid;
|
||||
@ -1040,6 +1045,10 @@ if ($action == 'create') {
|
||||
if ($element == 'propal') {
|
||||
$element = 'comm/propal'; $subelement = 'propal';
|
||||
}
|
||||
if ($element == 'invoice' || $element == 'facture') {
|
||||
$element = 'compta/facture';
|
||||
$subelement = 'facture';
|
||||
}
|
||||
|
||||
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user