29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/contract.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
34if (isModEnabled(
'project')) {
35 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
39$langs->loadLangs(array(
'contracts',
'companies'));
41$action =
GETPOST(
'action',
'aZ09');
42$confirm =
GETPOST(
'confirm',
'alpha');
43$socid =
GETPOST(
'socid',
'int');
49 $socid = $user->socid;
55$hookmanager->initHooks(array(
'contractcontactcard',
'globalcard'));
57$permissiontoadd = $user->hasRight(
'contrat',
'creer');
66$parameters = array(
'id'=>$id);
67$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
74 if ($action ==
'addcontact' && $user->hasRight(
'contrat',
'creer')) {
75 $result = $object->fetch($id);
77 if ($result > 0 && $id > 0) {
80 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
84 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
87 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
88 $langs->load(
"errors");
89 $msg = $langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType");
91 $mesg = $object->error;
99 if ($action ==
'swapstatut' && $user->hasRight(
'contrat',
'creer')) {
100 if ($object->fetch($id)) {
101 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
108 if ($action ==
'deletecontact' && $user->hasRight(
'contrat',
'creer')) {
110 $result = $object->delete_contact(
GETPOST(
"lineid",
'int'));
113 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
123$title = $langs->trans(
"Contract");
124$help_url =
'EN:Module_Contracts|FR:Module_Contrat';
128$form =
new Form($db);
130$contactstatic =
new Contact($db);
131$userstatic =
new User($db);
139if ($id > 0 || !empty($ref)) {
140 if ($object->fetch($id, $ref) > 0) {
141 $object->fetch_thirdparty();
147 print
dol_get_fiche_head($head, $hselected, $langs->trans(
"Contract"), -1,
'contract');
151 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
156 $morehtmlref .= $object->ref;
162 $morehtmlref .=
'<div class="refidno">';
164 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, 0,
'string',
'', 0, 1);
165 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, 0,
'string',
'',
null,
null,
'', 1,
'getFormatedCustomerRef');
167 $morehtmlref .=
'<br>';
168 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', 0, 1);
169 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'',
null,
null,
'', 1,
'getFormatedSupplierRef');
171 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
173 if (isModEnabled(
'project')) {
174 $langs->load(
"projects");
175 $morehtmlref .=
'<br>';
177 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
178 if ($action !=
'classify') {
179 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
181 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
183 if (!empty($object->fk_project)) {
185 $proj->fetch($object->fk_project);
186 $morehtmlref .= $proj->getNomUrl(1);
188 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
193 $morehtmlref .=
'</div>';
196 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'none', $morehtmlref);
199 print
'<div class="fichecenter">';
200 print
'<div class="underbanner clearboth"></div>';
202 print
'<table class="border tableforfield" width="100%">';
206 print
'<tr><td class="titlefield">'.$langs->trans(
'Discount').
'</td><td colspan="3">';
207 if ($object->thirdparty->remise_percent) {
208 print $langs->trans(
"CompanyHasRelativeDiscount", $object->thirdparty->remise_percent);
210 print $langs->trans(
"CompanyHasNoRelativeDiscount");
212 $absolute_discount = $object->thirdparty->getAvailableDiscounts();
214 if ($absolute_discount) {
215 print $langs->trans(
"CompanyHasAbsoluteDiscount",
price($absolute_discount), $langs->trans(
"Currency".$conf->currency));
217 print $langs->trans(
"CompanyHasNoAbsoluteDiscount");
224 print
'<td class="titlefield">';
225 print $form->editfieldkey(
"Date",
'date_contrat', $object->date_contrat, $object, 0);
227 print $form->editfieldval(
"Date",
'date_contrat', $object->date_contrat, $object, 0,
'datehourpicker');
240 include DOL_DOCUMENT_ROOT.
'/core/tpl/contacts.tpl.php';
242 print
"ErrorRecordNotFound";
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage contracts.
Class to manage projects.
Class to manage Dolibarr users.
contract_prepare_head(Contrat $object)
Prepare array with list of tabs.
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.
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.
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.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
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.