28 if (!$res && file_exists(
"../main.inc.php")) $res = @include
"../main.inc.php";
29 if (!$res && file_exists(
"../../main.inc.php")) $res = @include
"../../main.inc.php";
30 if (!$res && file_exists(
"../../../main.inc.php")) $res = @include
"../../../main.inc.php";
31 if (!$res) die(
"Include of main fails");
32 require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
40 $langs->loadLangs(array(
'facture',
'orders',
'sendings',
'companies',
'stocks'));
44 $lineid =
GETPOST(
'lineid',
'int');
45 $action =
GETPOST(
'action',
'alpha');
48 if ($user->socid) $socid = $user->socid;
50 $result =
restrictedArea($user,
'stocktransfer', $id,
'',
'stocktransfer');
55 if ($id > 0 || !empty($ref)) {
56 $ret = $object->fetch($id, $ref);
58 $langs->load(
"errors");
67 $object->fetch_thirdparty();
69 header(
'Location: '.
dol_buildpath(
'/stocktransfer/stocktransfer_list.php', 1));
78 if ($action ==
'addcontact' && $user->rights->stocktransfer->stocktransfer->write) {
79 if ($object->id > 0) {
81 $result = $object->add_contact($contactid, !empty($_POST[
"typecontact"]) ? $_POST[
"typecontact"] : $_POST[
"type"], $_POST[
"source"]);
85 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
88 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
89 $langs->load(
"errors");
90 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
95 } elseif ($action ==
'swapstatut' && $user->rights->stocktransfer->stocktransfer->write) {
96 if ($object->id > 0) {
97 $result = $object->swapContactStatus(
GETPOST(
'ligne'));
99 } elseif ($action ==
'deletecontact' && $user->rights->stocktransfer->stocktransfer->write) {
100 $result = $object->delete_contact($lineid);
103 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
121 llxHeader(
'', $langs->trans(
'ModuleStockTransferName'),
'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos');
127 if ($object->id > 0) {
129 print
dol_get_fiche_head($head,
'contact', $langs->trans(
"StockTransfer"), -1,
'stock');
134 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/propal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
137 $morehtmlref =
'<div class="refidno">';
139 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'', 0, 1);
140 $morehtmlref .=
$form->editfieldval(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'',
null,
null,
'', 1);
142 if (!empty($object->thirdparty)) {
143 $morehtmlref .=
'<br>' . $langs->trans(
'ThirdParty') .
' : ' . $object->thirdparty->getNomUrl(1,
'customer');
146 if (!empty($conf->project->enabled)) {
147 $langs->load(
"projects");
148 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
149 if ($user->rights->stocktransfer->stocktransfer->write) {
150 if ($action !=
'classify') {
152 $morehtmlref .=
' : ';
154 if ($action ==
'classify') {
156 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
157 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
158 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
159 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
160 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
161 $morehtmlref .=
'</form>';
163 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
166 if (!empty($object->fk_project)) {
168 $proj->fetch($object->fk_project);
169 $morehtmlref .=
'<a href="'.DOL_URL_ROOT.
'/projet/card.php?id='.$object->fk_project.
'" title="'.$langs->trans(
'ShowProject').
'">';
170 $morehtmlref .= $proj->ref;
171 $morehtmlref .=
'</a>';
177 $morehtmlref .=
'</div>';
179 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'',
'', 1);
183 $user->rights->stocktransfer->write = $user->rights->stocktransfer->stocktransfer->write;
185 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/core/tpl'));
186 foreach ($dirtpls as $reldir) {