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'));
38 $socid = $user->socid;
41 $backtopage =
GETPOST(
'backtopage',
'alpha');
48 if (
GETPOST(
'cancel',
'alpha') && !empty($backtopage))
50 header(
"Location: ".$backtopage);
54 if (
GETPOST(
'action',
'aZ09') ==
'setremise')
59 $discount_type =
GETPOST(
'discount_type',
'int');
61 if (!empty($discount_type)) {
69 if (!empty($backtopage))
71 header(
"Location: ".$backtopage);
74 header(
"Location: remise.php?id=".$_GET[
"id"]);
87 $form =
new Form($db);
101 $object->fetch($socid);
105 $isCustomer = ($object->client == 1 || $object->client == 3);
106 $isSupplier = $object->fournisseur == 1;
108 print '<form method="POST" action="remise.php?id='.$object->id.
'">';
109 print '<input type="hidden" name="token" value="'.newToken().
'">';
110 print '<input type="hidden" name="action" value="setremise">';
111 print '<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
115 dol_banner_tab($object,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'nom');
117 print '<div class="fichecenter">';
119 print '<div class="underbanner clearboth"></div>';
121 if (!$isCustomer && !$isSupplier) {
122 print '<p class="opacitymedium">'.$langs->trans(
'ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').
'</p>';
134 print '<table class="border centpercent">';
138 print '<tr><td class="titlefield">';
139 print $langs->trans(
"CustomerRelativeDiscount").
'</td><td>'.
price2num($object->remise_percent).
"%</td></tr>";
144 print '<tr><td class="titlefield">';
145 print $langs->trans(
"SupplierRelativeDiscount").
'</td><td>'.
price2num($object->remise_supplier_percent).
"%</td></tr>";
153 print '<div class="underbanner clearboth"></div>';
165 print
'<table class="border centpercent">';
167 if ($isCustomer || $isSupplier)
170 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
'DiscountType').
'</td><td>';
172 print
'<input type="radio" name="discount_type" id="discount_type_0" checked value="0"/> <label for="discount_type_0">'.$langs->trans(
'Customer').
'</label>';
175 print
' <input type="radio" name="discount_type" id="discount_type_1"'.($isCustomer ?
'' :
' checked').
' value="1"/> <label for="discount_type_1">'.$langs->trans(
'Supplier').
'</label>';
181 print
'<tr><td class="titlefield fieldrequired">';
182 print $langs->trans(
"NewValue").
'</td><td><input type="text" size="5" name="remise" value="'.
dol_escape_htmltag(
GETPOST(
"remise")).
'">%</td></tr>';
185 print
'<tr><td class="fieldrequired">';
186 print $langs->trans(
"NoteReason").
'</td><td><input type="text" size="60" name="note" value="'.
dol_escape_htmltag(
GETPOST(
"note",
"alphanohtml")).
'"></td></tr>';
194 print
'<div class="center">';
195 print
'<input type="submit" class="button" value="'.$langs->trans(
"Modify").
'">';
196 if (!empty($backtopage))
198 print
' ';
199 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
209 print
'<div class="fichecenter">';
210 print
'<div class="fichehalfleft">';
217 $sql =
"SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,";
218 $sql .=
" u.login, u.rowid as user_id";
219 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise as rc, ".MAIN_DB_PREFIX.
"user as u";
220 $sql .=
" WHERE rc.fk_soc = ".$object->id;
221 $sql .=
" AND rc.entity IN (".getEntity(
'discount').
")";
222 $sql .=
" AND u.rowid = rc.fk_user_author";
223 $sql .=
" ORDER BY rc.datec DESC";
225 $resql = $db->query($sql);
228 print
'<table class="noborder centpercent">';
230 print
'<tr class="liste_titre">';
231 print
'<td width="160">'.$langs->trans(
"Date").
'</td>';
232 print
'<td width="160" align="center">'.$langs->trans(
"CustomerRelativeDiscountShort").
'</td>';
233 print
'<td class="left">'.$langs->trans(
"NoteReason").
'</td>';
234 print
'<td class="center">'.$langs->trans(
"User").
'</td>';
236 $num = $db->num_rows(
$resql);
242 $obj = $db->fetch_object(
$resql);
243 print
'<tr class="oddeven">';
244 print
'<td>'.dol_print_date($db->jdate($obj->dc),
"dayhour").
'</td>';
245 print
'<td class="center">'.price2num($obj->remise_percent).
'%</td>';
246 print
'<td class="left">'.$obj->note.
'</td>';
247 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>';
252 print
'<tr><td colspan="8" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
264 print
'<div class="fichehalfright">';
265 print
'<div class="ficheaddleft">';
272 $sql =
"SELECT rc.rowid, rc.remise_supplier as remise_percent, rc.note, rc.datec as dc,";
273 $sql .=
" u.login, u.rowid as user_id";
274 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_supplier as rc, ".MAIN_DB_PREFIX.
"user as u";
275 $sql .=
" WHERE rc.fk_soc = ".$object->id;
276 $sql .=
" AND rc.entity IN (".getEntity(
'discount').
")";
277 $sql .=
" AND u.rowid = rc.fk_user_author";
278 $sql .=
" ORDER BY rc.datec DESC";
280 $resql = $db->query($sql);
283 print
'<table class="noborder centpercent">';
285 print
'<tr class="liste_titre">';
286 print
'<td width="160">'.$langs->trans(
"Date").
'</td>';
287 print
'<td width="160" align="center">'.$langs->trans(
"CustomerRelativeDiscountShort").
'</td>';
288 print
'<td class="left">'.$langs->trans(
"NoteReason").
'</td>';
289 print
'<td class="center">'.$langs->trans(
"User").
'</td>';
291 $num = $db->num_rows(
$resql);
297 $obj = $db->fetch_object(
$resql);
298 print
'<tr class="oddeven">';
299 print
'<td>'.dol_print_date($db->jdate($obj->dc),
"dayhour").
'</td>';
300 print
'<td class="center">'.price2num($obj->remise_percent).
'%</td>';
301 print
'<td class="left">'.$obj->note.
'</td>';
302 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>';
307 print
'<tr><td colspan="8" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>';
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= '')
Set event messages in dol_events session object.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
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.
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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...