Merge pull request #4220 from bafbes/patch-11

NEW Can change customer on orders when hidden option COMMANDE_CHANGE_THIRDPARTY is on
This commit is contained in:
Laurent Destailleur 2016-02-15 01:14:08 +01:00
commit fdea892e3b
3 changed files with 48 additions and 18 deletions

View File

@ -1178,7 +1178,16 @@ if (empty($reshook))
$action = 'edit_extras';
}
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
if ($action == 'set_thirdparty' && $user->rights->commande->creer)
{
$object->fetch($id);
$object->setValueFrom('fk_soc', $socid);
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
exit();
}
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
/*
@ -1926,8 +1935,19 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</tr>';
// Third party
print '<tr><td>' . $langs->trans('Company') . '</td>';
print '<td colspan="3">' . $soc->getNomUrl(1) . '</td>';
print '<tr><td>';
print '<table class="nobordernopadding" width="100%">';
print '<tr><td>' . $langs->trans('Company') . '</td>';
print '</td><td colspan="5">';
if (! empty($conf->global->COMMANDE_CHANGE_THIRDPARTY) && $action != 'editthirdparty' && $object->brouillon && $user->rights->commande->creer)
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editthirdparty&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetLinkToThirdParty'), 1) . '</a></td>';
print '</tr></table>';
print '</td><td colspan="5">';
if ($action == 'editthirdparty') {
$form->form_thirdparty($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, 'socid','client>0');
} else {
print ' &nbsp;' . $soc->getNomUrl(1, 'compta');
}
print '</tr>';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {

View File

@ -1001,26 +1001,30 @@ abstract class CommonObject
{
global $conf;
if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) return 0;
if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id))
return 0;
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
$idtofetch=isset($this->socid)?$this->socid:(isset($this->fk_soc)?$this->fk_soc:$this->fk_thirdparty);
if ($force_thirdparty_id) $idtofetch=$force_thirdparty_id;
$idtofetch = isset($this->socid) ? $this->socid : (isset($this->fk_soc) ? $this->fk_soc : $this->fk_thirdparty);
if ($force_thirdparty_id)
$idtofetch = $force_thirdparty_id;
$thirdparty = new Societe($this->db);
$result=$thirdparty->fetch($idtofetch);
$this->client = $thirdparty; // deprecated
$this->thirdparty = $thirdparty;
if ($idtofetch) {
$thirdparty = new Societe($this->db);
$result = $thirdparty->fetch($idtofetch);
$this->client = $thirdparty; // deprecated
$this->thirdparty = $thirdparty;
// Use first price level if level not defined for third party
if (! empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->thirdparty->price_level))
{
$this->client->price_level=1; // deprecated
$this->thirdparty->price_level=1;
}
// Use first price level if level not defined for third party
if (!empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->thirdparty->price_level)) {
$this->client->price_level = 1; // deprecated
$this->thirdparty->price_level = 1;
}
return $result;
return $result;
} else
return -1;
}

View File

@ -81,6 +81,12 @@ if (! empty($_GET['conf']))
$conffile = 'conf/'.$confname.'.php';
}
*/
if (!empty($_GET['conf'])) {
setcookie('dolconf', $_GET['conf']);
$conffile = 'conf/' . $_GET['conf'] . '.php';
} else {
$conffile = 'conf/' . (!empty($_COOKIE['dolconf']) ? $_COOKIE['dolconf'] : 'conf') . '.php';
}
// Include configuration
$result=@include_once $conffile; // Keep @ because with some error reporting this break the redirect