27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/contract.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
32 if (!empty($conf->projet->enabled)) {
33 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
37 $langs->loadLangs(array(
'contracts',
'companies'));
39 $action =
GETPOST(
'action',
'aZ09');
40 $confirm =
GETPOST(
'confirm',
'alpha');
41 $socid =
GETPOST(
'socid',
'int');
46 if ($user->socid) $socid = $user->socid;
52 $hookmanager->initHooks(array(
'contractcard',
'globalcard'));
59 if ($action ==
'addcontact' && $user->rights->contrat->creer)
61 $result = $object->fetch($id);
63 if ($result > 0 && $id > 0)
67 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
72 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
75 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
76 $langs->load(
"errors");
77 $msg = $langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType");
79 $mesg = $object->error;
87 if ($action ==
'swapstatut' && $user->rights->contrat->creer)
89 if ($object->fetch($id))
91 $result = $object->swapContactStatus(
GETPOST(
'ligne'));
98 if ($action ==
'deletecontact' && $user->rights->contrat->creer)
101 $result = $object->delete_contact($_GET[
"lineid"]);
105 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
115 llxHeader(
'', $langs->trans(
"Contract"),
"");
117 $form =
new Form($db);
119 $contactstatic =
new Contact($db);
120 $userstatic =
new User($db);
128 if ($id > 0 || !empty($ref))
130 if ($object->fetch($id, $ref) > 0)
132 $object->fetch_thirdparty();
142 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
147 $morehtmlref .= $object->ref;
153 $morehtmlref .=
'<div class="refidno">';
155 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, 0,
'string',
'', 0, 1);
156 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, 0,
'string',
'', null, null,
'', 1,
'getFormatedCustomerRef');
158 $morehtmlref .=
'<br>';
159 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', 0, 1);
160 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', null, null,
'', 1,
'getFormatedSupplierRef');
162 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
164 if (!empty($conf->projet->enabled)) {
165 $langs->load(
"projects");
166 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
167 if ($user->rights->contrat->creer) {
168 if ($action !=
'classify') {
170 $morehtmlref .=
' : ';
172 if ($action ==
'classify') {
174 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
175 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
176 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
177 $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
178 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
179 $morehtmlref .=
'</form>';
181 $morehtmlref .= $form->form_project(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->thirdparty->id, $object->fk_project,
'none', 0, 0, 0, 1);
184 if (!empty($object->fk_project)) {
186 $proj->fetch($object->fk_project);
187 $morehtmlref .=
'<a href="'.DOL_URL_ROOT.
'/projet/card.php?id='.$object->fk_project.
'" title="'.$langs->trans(
'ShowProject').
'">';
188 $morehtmlref .= $proj->ref;
189 $morehtmlref .=
'</a>';
195 $morehtmlref .=
'</div>';
198 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'none', $morehtmlref);
201 print '<div class="fichecenter">';
202 print '<div class="underbanner clearboth"></div>';
204 print '<table class="border tableforfield" width="100%">';
208 print '<tr><td class="titlefield">'.$langs->trans(
'Discount').
'</td><td colspan="3">';
209 if ($object->thirdparty->remise_percent) {
210 print $langs->trans(
"CompanyHasRelativeDiscount", $object->thirdparty->remise_percent);
212 print $langs->trans(
"CompanyHasNoRelativeDiscount");
214 $absolute_discount = $object->thirdparty->getAvailableDiscounts();
216 if ($absolute_discount)
print $langs->trans(
"CompanyHasAbsoluteDiscount",
price($absolute_discount), $langs->trans(
"Currency".$conf->currency));
217 else print $langs->trans(
"CompanyHasNoAbsoluteDiscount");
223 print '<td class="titlefield">';
224 print $form->editfieldkey(
"Date",
'date_contrat', $object->date_contrat, $object, 0);
226 print $form->editfieldval(
"Date",
'date_contrat', $object->date_contrat, $object, 0,
'datehourpicker');
239 include DOL_DOCUMENT_ROOT.
'/core/tpl/contacts.tpl.php';
241 print "ErrorRecordNotFound";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage Dolibarr users.
Class to manage contracts.
contract_prepare_head(Contrat $object)
Prepare array with list of tabs.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage projects.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.