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->project->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');
47 $socid = $user->socid;
54 $hookmanager->initHooks(array(
'contractcard',
'globalcard'));
61 if ($action ==
'addcontact' && $user->rights->contrat->creer) {
62 $result = $object->fetch($id);
64 if ($result > 0 && $id > 0) {
67 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
71 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
74 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
75 $langs->load(
"errors");
76 $msg = $langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType");
78 $mesg = $object->error;
86 if ($action ==
'swapstatut' && $user->rights->contrat->creer) {
87 if ($object->fetch($id)) {
88 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
95 if ($action ==
'deletecontact' && $user->rights->contrat->creer) {
97 $result = $object->delete_contact(
GETPOST(
"lineid",
'int'));
100 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
110 llxHeader(
'', $langs->trans(
"Contract"),
"");
114 $contactstatic =
new Contact($db);
115 $userstatic =
new User($db);
123 if ($id > 0 || !empty($ref)) {
124 if ($object->fetch($id, $ref) > 0) {
125 $object->fetch_thirdparty();
131 print
dol_get_fiche_head($head, $hselected, $langs->trans(
"Contract"), -1,
'contract');
135 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
140 $morehtmlref .= $object->ref;
146 $morehtmlref .=
'<div class="refidno">';
148 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, 0,
'string',
'', 0, 1);
149 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, 0,
'string',
'', null, null,
'', 1,
'getFormatedCustomerRef');
151 $morehtmlref .=
'<br>';
152 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', 0, 1);
153 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', null, null,
'', 1,
'getFormatedSupplierRef');
155 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
157 if (!empty($conf->project->enabled)) {
158 $langs->load(
"projects");
159 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
160 if ($user->rights->contrat->creer) {
161 if ($action !=
'classify') {
163 $morehtmlref .=
' : ';
165 if ($action ==
'classify') {
167 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
168 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
169 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
170 $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
171 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
172 $morehtmlref .=
'</form>';
174 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->thirdparty->id, $object->fk_project,
'none', 0, 0, 0, 1);
177 if (!empty($object->fk_project)) {
179 $proj->fetch($object->fk_project);
180 $morehtmlref .=
' : '.$proj->getNomUrl(1);
182 $morehtmlref .=
' - '.$proj->title;
189 $morehtmlref .=
'</div>';
192 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'none', $morehtmlref);
195 print
'<div class="fichecenter">';
196 print
'<div class="underbanner clearboth"></div>';
198 print
'<table class="border tableforfield" width="100%">';
202 print
'<tr><td class="titlefield">'.$langs->trans(
'Discount').
'</td><td colspan="3">';
203 if ($object->thirdparty->remise_percent) {
204 print $langs->trans(
"CompanyHasRelativeDiscount", $object->thirdparty->remise_percent);
206 print $langs->trans(
"CompanyHasNoRelativeDiscount");
208 $absolute_discount = $object->thirdparty->getAvailableDiscounts();
210 if ($absolute_discount) {
211 print $langs->trans(
"CompanyHasAbsoluteDiscount",
price($absolute_discount), $langs->trans(
"Currency".$conf->currency));
213 print $langs->trans(
"CompanyHasNoAbsoluteDiscount");
220 print
'<td class="titlefield">';
221 print $form->editfieldkey(
"Date",
'date_contrat', $object->date_contrat, $object, 0);
223 print $form->editfieldval(
"Date",
'date_contrat', $object->date_contrat, $object, 0,
'datehourpicker');
236 include DOL_DOCUMENT_ROOT.
'/core/tpl/contacts.tpl.php';
238 print
"ErrorRecordNotFound";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Class to manage Dolibarr users.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
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, $mode=0)
Check permissions of a user to show a page and an object.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
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.