Clean code to avoid confusion

This commit is contained in:
Laurent Destailleur 2018-03-15 14:25:09 +01:00
parent 7c62f22408
commit 620ceb54e3
4 changed files with 129 additions and 115 deletions

View File

@ -278,29 +278,38 @@ if ($object->id > 0)
print '</tr>'; print '</tr>';
} }
// This fields are used to know VAT to include in an invoice when the thirdparty is making a sale, so when it is a supplier.
// We don't need them into customer profile.
// Except for spain and localtax where localtax depends on buyer and not seller
// VAT is used // VAT is used
/*
print '<tr>'; print '<tr>';
print '<td class="nowrap">'.$langs->trans('VATIsUsed').'</td>'; print '<td class="nowrap">';
print $form->textwithpicto($langs->trans('VATIsUsed'),$langs->trans('VATIsUsedWhenSelling'));
print '</td>';
print '<td>'; print '<td>';
print yn($object->tva_assuj); print yn($object->tva_assuj);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
*/
// Local Taxes if ($mysoc->country_code == 'ES')
// TODO Move this on same record than VATIsUsed
if ($mysoc->localtax1_assuj=="1")
{ {
print '<tr><td class="nowrap">'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>'; // Local Taxes
print yn($object->localtax1_assuj); if ($mysoc->localtax1_assuj=="1")
print '</td></tr>'; {
print '<tr><td class="nowrap">'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
print yn($object->localtax1_assuj);
print '</td></tr>';
}
if ($mysoc->localtax1_assuj=="1")
{
print '<tr><td class="nowrap">'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
print yn($object->localtax2_assuj);
print '</td></tr>';
}
} }
if ($mysoc->localtax1_assuj=="1")
{
print '<tr><td class="nowrap">'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
print yn($object->localtax2_assuj);
print '</td></tr>';
}
// TVA Intra // TVA Intra
print '<tr><td class="nowrap">'.$langs->trans('VATIntra').'</td><td>'; print '<tr><td class="nowrap">'.$langs->trans('VATIntra').'</td><td>';

View File

@ -194,7 +194,9 @@ if ($object->id > 0)
// Assujetti a TVA ou pas // Assujetti a TVA ou pas
print '<tr>'; print '<tr>';
print '<td class="titlefield">'.$langs->trans('VATIsUsed').'</td><td>'; print '<td class="titlefield">';
print $form->textwithpicto($langs->trans('VATIsUsed'),$langs->trans('VATIsUsedWhenSelling'));
print '</td><td>';
print yn($object->tva_assuj); print yn($object->tva_assuj);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -290,7 +292,7 @@ if ($object->id > 0)
//else print $langs->trans("DiscountNone"); //else print $langs->trans("DiscountNone");
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr class="nowrap">'; print '<tr class="nowrap">';
print '<td>'; print '<td>';
print $form->editfieldkey("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer); print $form->editfieldkey("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer);

View File

@ -77,6 +77,7 @@ Web=Web
Poste= Position Poste= Position
DefaultLang=Language by default DefaultLang=Language by default
VATIsUsed=Sales tax is used VATIsUsed=Sales tax is used
VATIsUsedWhenSelling=This define if this thirdparty includes a sale tax or not when it makes an invoice to its own customers
VATIsNotUsed=Sales tax is not used VATIsNotUsed=Sales tax is not used
CopyAddressFromSoc=Fill address with third party address CopyAddressFromSoc=Fill address with third party address
ThirdpartyNotCustomerNotSupplierSoNoRef=Thirdparty neither customer nor supplier, no available refering objects ThirdpartyNotCustomerNotSupplierSoNoRef=Thirdparty neither customer nor supplier, no available refering objects

View File

@ -2177,111 +2177,113 @@ else
} }
//if ($j % 2 == 1) print '<td colspan="2"></td></tr>'; //if ($j % 2 == 1) print '<td colspan="2"></td></tr>';
// VAT is used
print '<tr><td>'; // This fields are used to know VAT to include in an invoice when the thirdparty is making a sale, so when it is a supplier.
print $langs->trans('VATIsUsed'); // We don't need them into customer profile.
print '</td><td>'; // Except for spain and localtax where localtax depends on buyer and not seller
print yn($object->tva_assuj);
print '</td>'; if ($object->fournisseur)
print '</tr>'; {
// VAT is used
print '<tr><td>';
print $form->textwithpicto($langs->trans('VATIsUsed'),$langs->trans('VATIsUsedWhenSelling'));
print '</td><td>';
print yn($object->tva_assuj);
print '</td>';
print '</tr>';
}
// Local Taxes // Local Taxes
//TODO: Place into a function to control showing by country or study better option if ($object->fournisseur || $mysoc->country_code=='ES')
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") {
{ if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td>'; {
print yn($object->localtax1_assuj); print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td>';
print '</td></tr><tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>'; print yn($object->localtax1_assuj);
print yn($object->localtax2_assuj); print '</td></tr><tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
print '</td></tr>'; print yn($object->localtax2_assuj);
print '</td></tr>';
if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1))) if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1)))
{ {
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">'; print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
print '<input type="hidden" name="action" value="set_localtax1">'; print '<input type="hidden" name="action" value="set_localtax1">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr><td>'.$langs->transcountry("TypeLocaltax1", $mysoc->country_code).' <a href="'.$_SERVER["PHP_SELF"].'?action=editRE&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>'; print '<tr><td>'.$langs->transcountry("TypeLocaltax1", $mysoc->country_code).' <a href="'.$_SERVER["PHP_SELF"].'?action=editRE&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
if($action == 'editRE') if($action == 'editRE')
{ {
print '<td align="left">'; print '<td align="left">';
$formcompany->select_localtax(1,$object->localtax1_value, "lt1"); $formcompany->select_localtax(1,$object->localtax1_value, "lt1");
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
} }
else else
{ {
print '<td>'.$object->localtax1_value.'</td>'; print '<td>'.$object->localtax1_value.'</td>';
} }
print '</tr></form>'; print '</tr></form>';
} }
if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2))) if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2)))
{ {
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">'; print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
print '<input type="hidden" name="action" value="set_localtax2">'; print '<input type="hidden" name="action" value="set_localtax2">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr><td>'.$langs->transcountry("TypeLocaltax2", $mysoc->country_code).'<a href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>'; print '<tr><td>'.$langs->transcountry("TypeLocaltax2", $mysoc->country_code).'<a href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
if($action == 'editIRPF'){ if($action == 'editIRPF'){
print '<td align="left">'; print '<td align="left">';
$formcompany->select_localtax(2,$object->localtax2_value, "lt2"); $formcompany->select_localtax(2,$object->localtax2_value, "lt2");
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
}else{ }else{
print '<td>'.$object->localtax2_value.'</td>'; print '<td>'.$object->localtax2_value.'</td>';
} }
print '</tr></form>'; print '</tr></form>';
} }
} }
elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1") elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1")
{ {
print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td>'; print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td>';
print yn($object->localtax1_assuj); print yn($object->localtax1_assuj);
print '</td></tr>'; print '</td></tr>';
if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1))) if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1)))
{ {
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">'; print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
print '<input type="hidden" name="action" value="set_localtax1">'; print '<input type="hidden" name="action" value="set_localtax1">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr><td> '.$langs->transcountry("TypeLocaltax1", $mysoc->country_code).'<a href="'.$_SERVER["PHP_SELF"].'?action=editRE&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>'; print '<tr><td> '.$langs->transcountry("TypeLocaltax1", $mysoc->country_code).'<a href="'.$_SERVER["PHP_SELF"].'?action=editRE&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
if($action == 'editRE'){ if($action == 'editRE'){
print '<td align="left">'; print '<td align="left">';
$formcompany->select_localtax(1,$object->localtax1_value, "lt1"); $formcompany->select_localtax(1,$object->localtax1_value, "lt1");
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
}else{ }else{
print '<td>'.$object->localtax1_value.'</td>'; print '<td>'.$object->localtax1_value.'</td>';
} }
print '</tr></form>'; print '</tr></form>';
} }
} }
elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1")
{ {
print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>'; print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
print yn($object->localtax2_assuj); print yn($object->localtax2_assuj);
print '</td></tr>'; print '</td></tr>';
if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2))) if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2)))
{ {
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">'; print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
print '<input type="hidden" name="action" value="set_localtax2">'; print '<input type="hidden" name="action" value="set_localtax2">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr><td> '.$langs->transcountry("TypeLocaltax2", $mysoc->country_code).' <a href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>'; print '<tr><td> '.$langs->transcountry("TypeLocaltax2", $mysoc->country_code).' <a href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</td>';
if($action == 'editIRPF'){ if($action == 'editIRPF'){
print '<td align="left">'; print '<td align="left">';
$formcompany->select_localtax(2,$object->localtax2_value, "lt2"); $formcompany->select_localtax(2,$object->localtax2_value, "lt2");
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
}else{ }else{
print '<td>'.$object->localtax2_value.'</td>'; print '<td>'.$object->localtax2_value.'</td>';
} }
print '</tr></form>'; print '</tr></form>';
} }
} }
/* }
if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && $object->fournisseur==1)
{
print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td colspan="3">';
print yn($object->localtax2_assuj);
print '</td><tr>';
}
*/
// VAT Code // VAT Code
print '<tr>'; print '<tr>';