Go to the documentation of this file.
25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
27 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
30 $langs->loadLangs(array(
'companies',
'orders',
'bills'));
36 if ($user->socid > 0) {
37 $socid = $user->socid;
40 $backtopage =
GETPOST(
'backtopage',
'alpha');
41 $cancel =
GETPOST(
'cancel',
'aplha');
42 $action =
GETPOST(
'action',
'aZ09');
45 if ($user->socid > 0) {
48 $result =
restrictedArea($user,
'societe', $id,
'&societe',
'',
'fk_soc',
'rowid', 0);
56 if (!empty($backtopage)) {
57 header(
"Location: ".$backtopage);
64 if ($action ==
'setremise') {
68 $discount_type =
GETPOST(
'discount_type',
'int');
70 if (!empty($discount_type)) {
77 if (!empty($backtopage)) {
78 header(
"Location: ".$backtopage);
81 header(
"Location: remise.php?id=".
GETPOST(
"id",
'int'));
107 $object->fetch($socid);
111 $isCustomer = ($object->client == 1 || $object->client == 3);
112 $isSupplier = $object->fournisseur == 1;
114 print
'<form method="POST" action="remise.php?id='.$object->id.
'">';
115 print
'<input type="hidden" name="token" value="'.newToken().
'">';
116 print
'<input type="hidden" name="action" value="setremise">';
117 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
119 print
dol_get_fiche_head($head,
'relativediscount', $langs->trans(
"ThirdParty"), -1,
'company');
121 dol_banner_tab($object,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'nom');
123 print
'<div class="fichecenter">';
125 print
'<div class="underbanner clearboth"></div>';
127 if (!$isCustomer && !$isSupplier) {
128 print
'<p class="opacitymedium">'.$langs->trans(
'ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').
'</p>';
140 print
'<table class="border centpercent">';
144 print
'<tr><td class="titlefield">';
145 print $langs->trans(
"CustomerRelativeDiscount").
'</td><td>'.
price2num($object->remise_percent).
"%</td></tr>";
150 print
'<tr><td class="titlefield">';
151 print $langs->trans(
"SupplierRelativeDiscount").
'</td><td>'.
price2num($object->remise_supplier_percent).
"%</td></tr>";
159 print
'<div class="underbanner clearboth"></div>';
171 print
'<table class="border centpercent">';
173 if ($isCustomer || $isSupplier) {
175 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
'DiscountType').
'</td><td>';
177 print
'<input type="radio" name="discount_type" id="discount_type_0" '.(GETPOSTISSET(
'discount_type') ? (
GETPOST(
'discount_type',
'int') == 0 ?
' checked' :
'') :
' checked').
' value="0"> <label for="discount_type_0">'.$langs->trans(
'Customer').
'</label>';
180 print
' <input type="radio" name="discount_type" id="discount_type_1"'.(GETPOSTISSET(
'discount_type') ? (
GETPOST(
'discount_type',
'int') ?
' checked' :
'') : ($isCustomer ?
'' :
' checked')).
' value="1"> <label for="discount_type_1">'.$langs->trans(
'Supplier').
'</label>';
186 print
'<tr><td class="titlefield fieldrequired">';
187 print $langs->trans(
"NewValue").
'</td><td><input type="text" size="5" name="remise" value="'.
dol_escape_htmltag(
GETPOST(
"remise")).
'">%</td></tr>';
190 print
'<tr><td class="fieldrequired">';
191 print $langs->trans(
"NoteReason").
'</td><td><input type="text" size="60" name="note" value="'.
dol_escape_htmltag(
GETPOST(
"note",
"alphanohtml")).
'"></td></tr>';
199 print
$form->buttonsSaveCancel(
"Modify");
207 print
'<div class="fichecenter">';
208 print
'<div class="fichehalfleft">';
215 $sql =
"SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,";
216 $sql .=
" u.login, u.rowid as user_id";
217 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise as rc, ".MAIN_DB_PREFIX.
"user as u";
218 $sql .=
" WHERE rc.fk_soc = ".((int) $object->id);
219 $sql .=
" AND rc.entity IN (".getEntity(
'discount').
")";
220 $sql .=
" AND u.rowid = rc.fk_user_author";
221 $sql .=
" ORDER BY rc.datec DESC";
223 $resql = $db->query($sql);
225 print
'<table class="noborder centpercent">';
227 print
'<tr class="liste_titre">';
228 print
'<td width="160">'.$langs->trans(
"Date").
'</td>';
229 print
'<td width="160" align="center">'.$langs->trans(
"CustomerRelativeDiscountShort").
'</td>';
230 print
'<td class="left">'.$langs->trans(
"NoteReason").
'</td>';
231 print
'<td class="center">'.$langs->trans(
"User").
'</td>';
233 $num = $db->num_rows(
$resql);
237 $obj = $db->fetch_object(
$resql);
238 print
'<tr class="oddeven">';
239 print
'<td>'.dol_print_date($db->jdate($obj->dc),
"dayhour").
'</td>';
240 print
'<td class="center">'.price2num($obj->remise_percent).
'%</td>';
241 print
'<td class="left">'.$obj->note.
'</td>';
242 print
'<td align="center"><a href="'.DOL_URL_ROOT.
'/user/card.php?id='.$obj->user_id.
'">'.
img_object($langs->trans(
"ShowUser"),
'user').
' '.$obj->login.
'</a></td>';
247 print
'<tr><td colspan="8" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
259 print
'<div class="fichehalfright">';
266 $sql =
"SELECT rc.rowid, rc.remise_supplier as remise_percent, rc.note, rc.datec as dc,";
267 $sql .=
" u.login, u.rowid as user_id";
268 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_supplier as rc, ".MAIN_DB_PREFIX.
"user as u";
269 $sql .=
" WHERE rc.fk_soc = ".((int) $object->id);
270 $sql .=
" AND rc.entity IN (".getEntity(
'discount').
")";
271 $sql .=
" AND u.rowid = rc.fk_user_author";
272 $sql .=
" ORDER BY rc.datec DESC";
274 $resql = $db->query($sql);
276 print
'<table class="noborder centpercent">';
278 print
'<tr class="liste_titre">';
279 print
'<td width="160">'.$langs->trans(
"Date").
'</td>';
280 print
'<td width="160" align="center">'.$langs->trans(
"CustomerRelativeDiscountShort").
'</td>';
281 print
'<td class="left">'.$langs->trans(
"NoteReason").
'</td>';
282 print
'<td class="center">'.$langs->trans(
"User").
'</td>';
284 $num = $db->num_rows(
$resql);
288 $obj = $db->fetch_object(
$resql);
289 print
'<tr class="oddeven">';
290 print
'<td>'.dol_print_date($db->jdate($obj->dc),
"dayhour").
'</td>';
291 print
'<td class="center">'.price2num($obj->remise_percent).
'%</td>';
292 print
'<td class="left">'.$obj->note.
'</td>';
293 print
'<td align="center"><a href="'.DOL_URL_ROOT.
'/user/card.php?id='.$obj->user_id.
'">'.
img_object($langs->trans(
"ShowUser"),
'user').
' '.$obj->login.
'</a></td>';
298 print
'<tr><td colspan="8" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
Class to manage third parties objects (customers, suppliers, prospects...)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
restrictedArea($user, $features, $objectid=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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.