Go to the documentation of this file.
28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/contract.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
38 $langs->loadLangs(array(
'contracts',
'companies'));
40 $action =
GETPOST(
'action',
'aZ09');
41 $confirm =
GETPOST(
'confirm',
'alpha');
42 $socid =
GETPOST(
'socid',
'int');
48 $socid = $user->socid;
55 $hookmanager->initHooks(array(
'contractcard',
'globalcard'));
57 $permissiontoadd = $user->hasRight(
'contrat',
'creer');
64 if ($action ==
'addcontact' && $user->hasRight(
'contrat',
'creer')) {
65 $result = $object->fetch($id);
67 if ($result > 0 && $id > 0) {
70 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
74 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
77 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
78 $langs->load(
"errors");
79 $msg = $langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType");
81 $mesg = $object->error;
89 if ($action ==
'swapstatut' && $user->hasRight(
'contrat',
'creer')) {
90 if ($object->fetch($id)) {
91 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
98 if ($action ==
'deletecontact' && $user->hasRight(
'contrat',
'creer')) {
100 $result = $object->delete_contact(
GETPOST(
"lineid",
'int'));
103 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
113 $title = $langs->trans(
"Contract");
114 $help_url =
'EN:Module_Contracts|FR:Module_Contrat';
120 $contactstatic =
new Contact($db);
121 $userstatic =
new User($db);
129 if ($id > 0 || !empty($ref)) {
130 if ($object->fetch($id, $ref) > 0) {
131 $object->fetch_thirdparty();
137 print
dol_get_fiche_head($head, $hselected, $langs->trans(
"Contract"), -1,
'contract');
141 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
146 $morehtmlref .= $object->ref;
152 $morehtmlref .=
'<div class="refidno">';
154 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, 0,
'string',
'', 0, 1);
155 $morehtmlref .=
$form->editfieldval(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, 0,
'string',
'',
null,
null,
'', 1,
'getFormatedCustomerRef');
157 $morehtmlref .=
'<br>';
158 $morehtmlref .=
$form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', 0, 1);
159 $morehtmlref .=
$form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'',
null,
null,
'', 1,
'getFormatedSupplierRef');
161 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
164 $langs->load(
"projects");
165 $morehtmlref .=
'<br>';
167 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
168 if ($action !=
'classify') {
169 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
171 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
173 if (!empty($object->fk_project)) {
175 $proj->fetch($object->fk_project);
176 $morehtmlref .= $proj->getNomUrl(1);
178 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
183 $morehtmlref .=
'</div>';
186 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'none', $morehtmlref);
189 print
'<div class="fichecenter">';
190 print
'<div class="underbanner clearboth"></div>';
192 print
'<table class="border tableforfield" width="100%">';
196 print
'<tr><td class="titlefield">'.$langs->trans(
'Discount').
'</td><td colspan="3">';
197 if ($object->thirdparty->remise_percent) {
198 print $langs->trans(
"CompanyHasRelativeDiscount", $object->thirdparty->remise_percent);
200 print $langs->trans(
"CompanyHasNoRelativeDiscount");
202 $absolute_discount = $object->thirdparty->getAvailableDiscounts();
204 if ($absolute_discount) {
205 print $langs->trans(
"CompanyHasAbsoluteDiscount",
price($absolute_discount), $langs->trans(
"Currency".$conf->currency));
207 print $langs->trans(
"CompanyHasNoAbsoluteDiscount");
214 print
'<td class="titlefield">';
215 print
$form->editfieldkey(
"Date",
'date_contrat', $object->date_contrat, $object, 0);
217 print
$form->editfieldval(
"Date",
'date_contrat', $object->date_contrat, $object, 0,
'datehourpicker');
230 include DOL_DOCUMENT_ROOT.
'/core/tpl/contacts.tpl.php';
232 print
"ErrorRecordNotFound";
Class to manage projects.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
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.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
restrictedArea(User $user, $features, $object=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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
isModEnabled($module)
Is Dolibarr module enabled.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
Class to manage contracts.
Class to manage Dolibarr users.
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.