28require 
'../main.inc.php';
 
   29require_once DOL_DOCUMENT_ROOT.
'/core/lib/contract.lib.php';
 
   30require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
 
   31require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
 
   32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
 
   33if (isModEnabled(
'project')) {
 
   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');     
 
   64if ($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;
 
   89if ($action == 
'swapstatut' && $user->hasRight(
'contrat', 
'creer')) {
 
   90  if ($object->fetch($id)) {
 
   91    $result = $object->swapContactStatus(
GETPOST(
'ligne', 
'int'));
 
   98if ($action == 
'deletecontact' && $user->hasRight(
'contrat', 
'creer')) {
 
  100  $result = $object->delete_contact(
GETPOST(
"lineid", 
'int'));
 
  103    header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
 
  113llxHeader(
'', $langs->trans(
"Contract"), 
"");
 
  115$form = 
new Form($db);
 
  117$contactstatic = 
new Contact($db);
 
  118$userstatic = 
new User($db);
 
  126if ($id > 0 || !empty($ref)) {
 
  127  if ($object->fetch($id, $ref) > 0) {
 
  128    $object->fetch_thirdparty();
 
  134    print 
dol_get_fiche_head($head, $hselected, $langs->trans(
"Contract"), -1, 
'contract');
 
  138    $linkback = 
'<a href="'.DOL_URL_ROOT.
'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ? 
'&socid='.$socid : 
'').
'">'.$langs->trans(
"BackToList").
'</a>';
 
  143      $morehtmlref .= $object->ref;
 
  149    $morehtmlref .= 
'<div class="refidno">';
 
  151    $morehtmlref .= $form->editfieldkey(
"RefCustomer", 
'ref_customer', $object->ref_customer, $object, 0, 
'string', 
'', 0, 1);
 
  152    $morehtmlref .= $form->editfieldval(
"RefCustomer", 
'ref_customer', $object->ref_customer, $object, 0, 
'string', 
'', 
null, 
null, 
'', 1, 
'getFormatedCustomerRef');
 
  154    $morehtmlref .= 
'<br>';
 
  155    $morehtmlref .= $form->editfieldkey(
"RefSupplier", 
'ref_supplier', $object->ref_supplier, $object, 0, 
'string', 
'', 0, 1);
 
  156    $morehtmlref .= $form->editfieldval(
"RefSupplier", 
'ref_supplier', $object->ref_supplier, $object, 0, 
'string', 
'', 
null, 
null, 
'', 1, 
'getFormatedSupplierRef');
 
  158    $morehtmlref .= 
'<br>'.$object->thirdparty->getNomUrl(1);
 
  160    if (isModEnabled(
'project')) {
 
  161      $langs->load(
"projects");
 
  162      $morehtmlref .= 
'<br>';
 
  164        $morehtmlref .= 
img_picto($langs->trans(
"Project"), 
'project', 
'class="pictofixedwidth"');
 
  165        if ($action != 
'classify') {
 
  166          $morehtmlref .= 
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
 
  168        $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action == 
'classify' ? 
'projectid' : 
'none'), 0, 0, 0, 1, 
'', 
'maxwidth300');
 
  170        if (!empty($object->fk_project)) {
 
  172          $proj->fetch($object->fk_project);
 
  173          $morehtmlref .= $proj->getNomUrl(1);
 
  175            $morehtmlref .= 
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
 
  180    $morehtmlref .= 
'</div>';
 
  183    dol_banner_tab($object, 
'ref', $linkback, 1, 
'ref', 
'none', $morehtmlref);
 
  186    print 
'<div class="fichecenter">';
 
  187    print 
'<div class="underbanner clearboth"></div>';
 
  189    print 
'<table class="border tableforfield" width="100%">';
 
  193    print 
'<tr><td class="titlefield">'.$langs->trans(
'Discount').
'</td><td colspan="3">';
 
  194    if ($object->thirdparty->remise_percent) {
 
  195      print $langs->trans(
"CompanyHasRelativeDiscount", $object->thirdparty->remise_percent);
 
  197      print $langs->trans(
"CompanyHasNoRelativeDiscount");
 
  199    $absolute_discount = $object->thirdparty->getAvailableDiscounts();
 
  201    if ($absolute_discount) {
 
  202      print $langs->trans(
"CompanyHasAbsoluteDiscount", 
price($absolute_discount), $langs->trans(
"Currency".$conf->currency));
 
  204      print $langs->trans(
"CompanyHasNoAbsoluteDiscount");
 
  211    print 
'<td class="titlefield">';
 
  212    print $form->editfieldkey(
"Date", 
'date_contrat', $object->date_contrat, $object, 0);
 
  214    print $form->editfieldval(
"Date", 
'date_contrat', $object->date_contrat, $object, 0, 
'datehourpicker');
 
  227    include DOL_DOCUMENT_ROOT.
'/core/tpl/contacts.tpl.php';
 
  229    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.