Uniformize code

This commit is contained in:
Laurent Destailleur 2016-10-30 10:13:55 +01:00
parent aec0e79653
commit f95acb24ff
3 changed files with 63 additions and 52 deletions

View File

@ -29,6 +29,10 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
$langs->load("orders"); $langs->load("orders");
$langs->load("sendings"); $langs->load("sendings");
@ -165,11 +169,10 @@ 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->supplier_proposal->creer) { if (0) { // Do not change on shipment
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> : ';
} }
@ -185,17 +188,20 @@ if ($id > 0 || ! empty($ref))
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
} else { } else {
if (! empty($object->fk_project)) { // We don't have project on shipment, so we will use the project or source object instead
// TODO Add project on shipment
$morehtmlref .= ' : ';
if (! empty($objectsrc->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($objectsrc->fk_project);
$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; $morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $objectsrc->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref .= $proj->ref; $morehtmlref .= $proj->ref;
$morehtmlref .= '</a>'; $morehtmlref .= '</a>';
} else { } else {
$morehtmlref .= ''; $morehtmlref .= '';
} }
} }
}*/ }
$morehtmlref.='</div>'; $morehtmlref.='</div>';

View File

@ -27,6 +27,10 @@
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
$langs->load("sendings"); $langs->load("sendings");
$langs->load("companies"); $langs->load("companies");
@ -110,37 +114,39 @@ 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 (0) { // Do not change on shipment
if ($user->rights->supplier_proposal->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> : '; }
} 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 . '">'; $morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">'; $morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
$morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
$morehtmlref .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">'; $morehtmlref .= '</form>';
$morehtmlref .= '</form>'; } else {
} else { $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); }
} } else {
} else { // We don't have project on shipment, so we will use the project or source object instead
if (! empty($object->fk_project)) { // TODO Add project on shipment
$proj = new Project($db); $morehtmlref .= ' : ';
$proj->fetch($object->fk_project); if (! empty($objectsrc->fk_project)) {
$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; $proj = new Project($db);
$morehtmlref .= $proj->ref; $proj->fetch($objectsrc->fk_project);
$morehtmlref .= '</a>'; $morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $objectsrc->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
} else { $morehtmlref .= $proj->ref;
$morehtmlref .= ''; $morehtmlref .= '</a>';
} } else {
} $morehtmlref .= '';
}*/ }
}
}
$morehtmlref.='</div>'; $morehtmlref.='</div>';

View File

@ -40,7 +40,11 @@ if (! empty($conf->expedition_bon->enabled))
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
if (! empty($conf->stock->enabled)) if (! empty($conf->stock->enabled))
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
$langs->load("sendings"); $langs->load("sendings");
$langs->load("bills"); $langs->load("bills");
@ -312,13 +316,8 @@ else
{ {
if ($object->id > 0) if ($object->id > 0)
{ {
// Origin of a 'livraison' (delivery) is ALWAYS 'expedition' (shipment). // Origin of a 'livraison' (delivery receipt) is ALWAYS 'expedition' (shipment).
// However, origin of shipment in future may differs (commande, proposal, ...) // However, origin of shipment in future may differs (commande, proposal, ...)
// TODO REGIS:
// Je ne suis pas d'accord, beaucoup entreprises n'utilisent pas les bons d'expéditions car ces derniers sont gérés par le transporteur,
// donc les bons de livraisons peuvent avoir une origine différente de 'expedition'
// les bons de livraisons et d'expéditions devraient être considérés comme des objets à part entière, voir des modules différents comme une propal ou autres.
$expedition=new Expedition($db); $expedition=new Expedition($db);
$result = $expedition->fetch($object->origin_id); $result = $expedition->fetch($object->origin_id);
$typeobject = $expedition->origin; // example: commande $typeobject = $expedition->origin; // example: commande
@ -369,17 +368,17 @@ else
* Livraison * Livraison
*/ */
if ($typeobject == 'commande' && $expedition->$typeobject->id && ! empty($conf->commande->enabled)) if ($typeobject == 'commande' && $expedition->origin_id > 0 && ! empty($conf->commande->enabled))
{ {
$objectsrc=new Commande($db); $objectsrc=new Commande($db);
$objectsrc->fetch($expedition->$typeobject->id); $objectsrc->fetch($expedition->origin_id);
} }
if ($typeobject == 'propal' && $expedition->$typeobject->id && ! empty($conf->propal->enabled)) if ($typeobject == 'propal' && $expedition->origin_id > 0 && ! empty($conf->propal->enabled))
{ {
$objectsrc=new Propal($db); $objectsrc=new Propal($db);
$objectsrc->fetch($expedition->$typeobject->id); $objectsrc->fetch($expedition->origin_id);
} }
// Shipment card // Shipment card
$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php">'.$langs->trans("BackToList").'</a>';
@ -411,10 +410,10 @@ else
} }
} else { } else {
$morehtmlref .= ' : '; $morehtmlref .= ' : ';
if (! empty($expeditionsrc->fk_project)) { if (! empty($objectsrc->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($expeditionsrc->fk_project); $proj->fetch($objectsrc->fk_project);
$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $expeditionsrc->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; $morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $objectsrc->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref .= $proj->ref; $morehtmlref .= $proj->ref;
$morehtmlref .= '</a>'; $morehtmlref .= '</a>';
} else { } else {