26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
28require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
31$langs->loadLangs(array(
'companies',
'orders',
'bills'));
37if ($user->socid > 0) {
38 $socid = $user->socid;
41$backtopage =
GETPOST(
'backtopage',
'alpha');
42$cancel =
GETPOST(
'cancel',
'alpha');
43$action =
GETPOST(
'action',
'aZ09');
46if ($user->socid > 0) {
49$result =
restrictedArea($user,
'societe', $id,
'&societe',
'',
'fk_soc',
'rowid', 0);
57 if (!empty($backtopage)) {
58 header(
"Location: ".$backtopage);
65if ($action ==
'setremise' && $user->hasRight(
'societe',
'lire')) {
71 if (!empty($discount_type)) {
78 if (!empty($backtopage)) {
79 header(
"Location: ".$backtopage);
82 header(
"Location: remise.php?id=".
GETPOSTINT(
"id"));
112$isSupplier =
$object->fournisseur == 1;
114print
'<form method="POST" action="remise.php?id='.$object->id.
'">';
115print
'<input type="hidden" name="token" value="'.newToken().
'">';
116print
'<input type="hidden" name="action" value="setremise">';
117print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
119print
dol_get_fiche_head($head,
'relativediscount', $langs->trans(
"ThirdParty"), -1,
'company');
121dol_banner_tab($object,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'nom');
123print
'<div class="fichecenter">';
125print
'<div class="underbanner clearboth"></div>';
127if (!$isCustomer && !$isSupplier) {
128 print
'<p class="opacitymedium">'.$langs->trans(
'ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').
'</p>';
140print
'<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>";
159print
'<div class="underbanner clearboth"></div>';
171print
'<table class="border centpercent marginbottomonly">';
173if ($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') ? (
GETPOSTINT(
'discount_type') == 0 ?
' checked' :
'') :
' checked').
' value="0"> <label for="discount_type_0">'.$langs->trans(
'Customer').
'</label>';
179 if ($isCustomer && $isSupplier) {
183 print
' <input type="radio" name="discount_type" id="discount_type_1"'.(GETPOSTISSET(
'discount_type') ? (
GETPOSTINT(
'discount_type') ?
' checked' :
'') : ($isCustomer ?
'' :
' checked')).
' value="1"> <label for="discount_type_1">'.$langs->trans(
'Supplier').
'</label>';
189print
'<tr><td class="titlefield fieldrequired">';
190print $langs->trans(
"NewValue").
'</td><td><input type="text" size="5" name="remise" value="'.
dol_escape_htmltag(
GETPOST(
"remise")).
'">%</td></tr>';
193print
'<tr><td class="fieldrequired">';
194print $langs->trans(
"NoteReason").
'</td><td><input type="text" size="60" name="note" value="'.
dol_escape_htmltag(
GETPOST(
"note",
"alphanohtml")).
'"></td></tr>';
200print $form->buttonsSaveCancel(
"Modify");
212 print
'<div class="fichecenter">';
213 print
'<div class="fichehalfleft">';
220 $sql =
"SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,";
221 $sql .=
" u.login, u.rowid as user_id";
222 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise as rc, ".MAIN_DB_PREFIX.
"user as u";
223 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
224 $sql .=
" AND rc.entity IN (".getEntity(
'discount').
")";
225 $sql .=
" AND u.rowid = rc.fk_user_author";
226 $sql .=
" ORDER BY rc.datec DESC";
228 $resql = $db->query($sql);
230 print
'<table class="noborder centpercent">';
231 print
'<tr class="liste_titre">';
232 print
'<td width="160">'.$langs->trans(
"Date").
'</td>';
233 print
'<td width="160" align="center">'.$langs->trans(
"CustomerRelativeDiscountShort").
'</td>';
234 print
'<td class="left">'.$langs->trans(
"NoteReason").
'</td>';
235 print
'<td class="center">'.$langs->trans(
"User").
'</td>';
237 $num = $db->num_rows($resql);
241 $obj = $db->fetch_object($resql);
242 print
'<tr class="oddeven">';
243 print
'<td>'.dol_print_date($db->jdate($obj->dc),
"dayhour").
'</td>';
244 print
'<td class="center">'.price2num($obj->remise_percent).
'%</td>';
245 print
'<td class="left">'.$obj->note.
'</td>';
246 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>';
251 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
263 print
'<div class="fichehalfright">';
270 $sql =
"SELECT rc.rowid, rc.remise_supplier as remise_percent, rc.note, rc.datec as dc,";
271 $sql .=
" u.login, u.rowid as user_id";
272 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_supplier as rc, ".MAIN_DB_PREFIX.
"user as u";
273 $sql .=
" WHERE rc.fk_soc = ".((int)
$object->id);
274 $sql .=
" AND rc.entity IN (".getEntity(
'discount').
")";
275 $sql .=
" AND u.rowid = rc.fk_user_author";
276 $sql .=
" ORDER BY rc.datec DESC";
278 $resql = $db->query($sql);
280 print
'<table class="noborder centpercent">';
281 print
'<tr class="liste_titre">';
282 print
'<td width="160">'.$langs->trans(
"Date").
'</td>';
283 print
'<td width="160" align="center">'.$langs->trans(
"CustomerRelativeDiscountShort").
'</td>';
284 print
'<td class="left">'.$langs->trans(
"NoteReason").
'</td>';
285 print
'<td class="center">'.$langs->trans(
"User").
'</td>';
287 $num = $db->num_rows($resql);
291 $obj = $db->fetch_object($resql);
292 print
'<tr class="oddeven">';
293 print
'<td>'.dol_print_date($db->jdate($obj->dc),
"dayhour").
'</td>';
294 print
'<td class="center">'.price2num($obj->remise_percent).
'%</td>';
295 print
'<td class="left">'.$obj->note.
'</td>';
296 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>';
301 print
'<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage third parties objects (customers, suppliers, prospects...)
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.