2
0
forked from Wavyzz/dolibarr

Complete work on dol_banner on contracts

This commit is contained in:
Laurent Destailleur
2016-12-04 13:30:17 +01:00
parent 211436b436
commit 788cbf9a01
10 changed files with 97 additions and 92 deletions

View File

@@ -999,6 +999,7 @@ llxHeader('',$langs->trans("Contract"),"");
$form = new Form($db);
$formfile = new FormFile($db);
if (! empty($conf->projet->enabled)) $formproject = new FormProjets($db);
$objectlignestatic=new ContratLigne($db);
@@ -1086,34 +1087,36 @@ if ($action == 'create')
print '<table class="border" width="100%">';
// Ref
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td>';
if (! empty($modCodeContract->code_auto)) {
$tmpcode=$langs->trans("Draft");
} else {
$tmpcode='<input name="ref" size="20" maxlength="128" value="'.dol_escape_htmltag(GETPOST('ref')?GETPOST('ref'):$tmpcode).'">';
$tmpcode='<input name="ref" class="maxwidth100" maxlength="128" value="'.dol_escape_htmltag(GETPOST('ref')?GETPOST('ref'):$tmpcode).'">';
}
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$tmpcode.'</td></tr>';
print $tmpcode;
print '</td></tr>';
// Ref customer
print '<tr><td>'.$langs->trans('RefCustomer').'</td>';
print '<td colspan="2"><input type="text" size="5" name="ref_customer" id="ref_customer" value="'.GETPOST('ref_customer','alpha').'"></td></tr>';
print '<td><input type="text" class="maxwidth150" name="ref_customer" id="ref_customer" value="'.dol_escape_htmltag(GETPOST('ref_customer','alpha')).'"></td></tr>';
// Ref supplier
print '<tr><td>'.$langs->trans('RefSupplier').'</td>';
print '<td colspan="2"><input type="text" size="5" name="ref_supplier" id="ref_supplier" value="'.GETPOST('ref_supplier','alpha').'"></td></tr>';
print '<td><input type="text" class="maxwidth150" name="ref_supplier" id="ref_supplier" value="'.dol_escape_htmltag(GETPOST('ref_supplier','alpha')).'"></td></tr>';
// Thirdparty
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('ThirdParty').'</td>';
if ($socid>0)
{
print '<td colspan="2">';
print '<td>';
print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
print '</td>';
}
else
{
print '<td colspan="2">';
print '<td>';
print $form->select_company('','socid','','SelectThirdParty',1);
print '</td>';
}
@@ -1122,7 +1125,7 @@ if ($action == 'create')
if($socid>0)
{
// Ligne info remises tiers
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="2">';
print '<tr><td>'.$langs->trans('Discounts').'</td><td>';
if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_percent);
else print $langs->trans("CompanyHasNoRelativeDiscount");
print '. ';
@@ -1158,11 +1161,9 @@ if ($action == 'create')
}
print '<tr><td>'.$langs->trans("NotePublic").'</td><td valign="top">';
$doleditor=new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%');
print $doleditor->Create(1);
print '</td></tr>';
if (empty($user->societe_id))
{
@@ -1293,47 +1294,75 @@ else
print $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneContract'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
print '<table class="border" width="100%">';
// Contract card
$linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref du contrat
$morehtmlref='';
if (! empty($modCodeContract->code_auto)) {
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
print "</td></tr>";
$morehtmlref.=$object->ref;
} else {
print '<tr>';
print '<td class="titlefieldcreate">';
print $form->editfieldkey("Ref",'ref',$object->ref,$object,$user->rights->contrat->creer);
print '</td><td>';
print $form->editfieldval("Ref",'ref',$object->ref,$object,$user->rights->contrat->creer);
print '</td>';
print '</tr>';
$morehtmlref.=$form->editfieldkey("",'ref',$object->ref,$object,$user->rights->contrat->creer,'string','',0,3);
$morehtmlref.=$form->editfieldval("",'ref',$object->ref,$object,$user->rights->contrat->creer,'string','',0,2);
}
print '<tr>';
print '<td>';
print $form->editfieldkey("RefCustomer",'ref_customer',$object->ref_customer,$object,$user->rights->contrat->creer);
print '</td><td>';
print $form->editfieldval("RefCustomer",'ref_customer',$object->ref_customer,$object,$user->rights->contrat->creer);
print '</td>';
print '</tr>';
$morehtmlref.='<div class="refidno">';
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1);
// Ref supplier
$morehtmlref.='<br>';
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->contrat->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
print '<tr>';
print '<td>';
print $form->editfieldkey("RefSupplier",'ref_supplier',$object->ref_supplier,$object,$user->rights->contrat->creer);
print '</td><td>';
print $form->editfieldval("RefSupplier",'ref_supplier',$object->ref_supplier,$object,$user->rights->contrat->creer);
print '</td>';
print '</tr>';
// Customer
print "<tr><td>".$langs->trans("Customer")."</td>";
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Ligne info remises tiers
print '<tr><td>'.$langs->trans('Discount').'</td><td colspan="3">';
print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">';
if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent);
else print $langs->trans("CompanyHasNoRelativeDiscount");
$absolute_discount=$object->thirdparty->getAvailableDiscounts();
@@ -1343,44 +1372,15 @@ else
print '.';
print '</td></tr>';
// Statut contrat
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
if ($object->statut==0) print $object->getLibStatut(2);
else print $object->getLibStatut(4);
print "</td></tr>";
// Date
print '<tr>';
print '<td>';
print '<td class="titlefield">';
print $form->editfieldkey("Date",'date_contrat',$object->date_contrat,$object,$user->rights->contrat->creer);
print '</td><td>';
print $form->editfieldval("Date",'date_contrat',$object->date_contrat,$object,$user->rights->contrat->creer,'datehourpicker');
print '</td>';
print '</tr>';
/* print '<tr><td>'.$langs->trans("Date").'</td>';
print '<td colspan="3">'.dol_print_date($object->date_contrat,"dayhour")."</td></tr>\n";*/
// Projet
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans("Project");
print '</td>';
if ($action != "classify" && $user->rights->projet->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->trans("SetProject")).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == "classify")
{
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, "projectid", 1, 0, 1);
}
else
{
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, "none", 0, 0);
}
print "</td></tr>";
}
// Other attributes
$cols = 3;
@@ -1388,12 +1388,14 @@ else
print "</table>";
print '</div>';
if (! empty($object->brouillon) && $user->rights->contrat->creer)
{
print '</form>';
}
echo '<br>';
//echo '<br>';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
@@ -1457,8 +1459,8 @@ else
print '<tr class="liste_titre'.($cursorline?' liste_titre_add':'').'">';
print '<td>'.$langs->trans("ServiceNb",$cursorline).'</td>';
print '<td width="50" align="center">'.$langs->trans("VAT").'</td>';
print '<td width="50" align="right">'.$langs->trans("PriceUHT").'</td>';
print '<td width="80" align="center">'.$langs->trans("VAT").'</td>';
print '<td width="80" align="right">'.$langs->trans("PriceUHT").'</td>';
print '<td width="30" align="center">'.$langs->trans("Qty").'</td>';
if ($conf->global->PRODUCT_USE_UNITS) print '<td width="30" align="left">'.$langs->trans("Unit").'</td>';
print '<td width="50" align="right">'.$langs->trans("ReductionShort").'</td>';
@@ -1927,8 +1929,6 @@ else
<input type="hidden" name="id" value="'.$object->id.'">
';
print '<br>';
print '<div class="div-table-responsive">';
print '<table id="tablelines" class="noborder noshadow" width="100%">'; // Array with (n*2)+1 lines

View File

@@ -45,6 +45,7 @@ class Contrat extends CommonObject
public $table_element_line='contratdet';
public $fk_element='fk_contrat';
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
public $picto='contract';
/**
* {@inheritdoc}

View File

@@ -3301,7 +3301,7 @@ abstract class CommonObject
}
// VAT
print '<td class="linecolvat" align="right" width="50">'.$langs->trans('VAT').'</td>';
print '<td class="linecolvat" align="right" width="80">'.$langs->trans('VAT').'</td>';
// Price HT
print '<td class="linecoluht" align="right" width="80">'.$langs->trans('PriceUHT').'</td>';

View File

@@ -78,9 +78,9 @@ class Form
* @param object $object Object
* @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field.
* @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...)
* @param string $moreparam More param to add on a href URL*
* @param string $moreparam More param to add on a href URL.
* @param int $fieldrequired 1 if we want to show field as mandatory using the "fieldrequired" CSS.
* @param int $notabletag 1=Do not output table tags but output a ':', 2=Do not output table tags and no ':'
* @param int $notabletag 1=Do not output table tags but output a ':', 2=Do not output table tags and no ':', 3=Do not output table tags but output a ' '
* @return string HTML edit field
*/
function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata='string', $moreparam='', $fieldrequired=0, $notabletag=0)
@@ -119,6 +119,7 @@ class Form
if (empty($notabletag) && GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='<td align="right">';
if ($htmlname && GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='<a href="'.$_SERVER["PHP_SELF"].'?action=edit'.$htmlname.'&amp;id='.$object->id.$moreparam.'">'.img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)).'</a>';
if (! empty($notabletag) && $notabletag == 1) $ret.=' : ';
if (! empty($notabletag) && $notabletag == 3) $ret.=' ';
if (empty($notabletag) && GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='</td>';
if (empty($notabletag) && GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='</tr></table>';
}

View File

@@ -1061,9 +1061,10 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
$morehtmlstatus.=$tmptxt;
}
elseif ($object->element == 'facturerec')
elseif ($object->element == 'contrat')
{
$morehtmlstatus.='<!-- No status for recurring invoice -->';
if ($object->statut==0) $morehtmlstatus.=$object->getLibStatut(2);
else $morehtmlstatus.=$object->getLibStatut(4);
}
else { // Generic case
$tmptxt=$object->getLibStatut(6);

View File

@@ -107,7 +107,7 @@ if ($nolinesbefore) {
<?php
}
?>
<tr class="pair nodrag nodrop nohoverpair<?php echo $nolinesbefore?'':' liste_titre_add'; ?>">
<tr class="pair nodrag nodrop nohoverpair<?php echo ($nolinesbefore || $object->element=='contrat')?'':' liste_titre_add'; ?>">
<?php
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$coldisplay=2; }

View File

@@ -243,3 +243,6 @@ ALTER TABLE llx_expensereport ADD UNIQUE INDEX idx_expensereport_uk_ref (ref, en
UPDATE llx_projet_task SET ref = NULL WHERE ref = '';
ALTER TABLE llx_projet_task ADD UNIQUE INDEX uk_projet_task_ref (ref, entity);
ALTER TABLE llx_contrat ADD COLUMN fk_user_modif integer;

View File

@@ -38,6 +38,7 @@ create table llx_contrat
fk_commercial_signature integer, -- obsolete
fk_commercial_suivi integer, -- obsolete
fk_user_author integer NOT NULL default 0,
fk_user_modif integer,
fk_user_mise_en_service integer,
fk_user_cloture integer,
note_private text,

View File

@@ -231,7 +231,7 @@ SpaceX=Space X
SpaceY=Space Y
FontSize=Font size
Content=Content
NoticePeriod=Notice
NoticePeriod=Notice period
NewByMonth=New by month
Emails=E-mails
EMailsSetup=E-mails setup

View File

@@ -674,14 +674,12 @@ elseif ($object->id > 0)
}
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="comefromclone" value="'.$comefromclone.'">';
$head=project_prepare_head($object);
dol_fiche_head($head, 'project', $langs->trans("Project"),0,($object->public?'projectpub':'project'));