dolibarr  7.0.0-beta
remx.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
30 
31 $langs->load("orders");
32 $langs->load("bills");
33 $langs->load("companies");
34 
35 $id=GETPOST('id','int');
36 
37 $action=GETPOST('action','alpha');
38 $backtopage=GETPOST('backtopage','alpha');
39 
40 // Security check
41 $socid = GETPOST('id','int')?GETPOST('id','int'):GETPOST('socid','int');
42 if ($user->societe_id > 0)
43 {
44  $socid = $user->societe_id;
45 }
46 
47 
48 /*
49  * Actions
50  */
51 
52 if (GETPOST('cancel','alpha') && ! empty($backtopage))
53 {
54  header("Location: ".$backtopage);
55  exit;
56 }
57 
58 if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
59 {
60  //if ($user->rights->societe->creer)
61  //if ($user->rights->facture->creer)
62 
63  $amount_ttc_1=GETPOST('amount_ttc_1');
64  $amount_ttc_2=GETPOST('amount_ttc_2');
65 
66  $error=0;
67  $remid=GETPOST("remid")?GETPOST("remid"):0;
68  $discount=new DiscountAbsolute($db);
69  $res=$discount->fetch($remid);
70  if (! $res > 0)
71  {
72  $error++;
73  setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors');
74  }
75  if (! $error && price2num($amount_ttc_1+$amount_ttc_2) != $discount->amount_ttc)
76  {
77  $error++;
78  setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors');
79  }
80  if (! $error && $discount->fk_facture_line)
81  {
82  $error++;
83  setEventMessages($langs->trans("ErrorCantSplitAUsedDiscount"), null, 'errors');
84  }
85  if (! $error)
86  {
87  $newdiscount1=new DiscountAbsolute($db);
88  $newdiscount2=new DiscountAbsolute($db);
89  $newdiscount1->fk_facture_source=$discount->fk_facture_source;
90  $newdiscount2->fk_facture_source=$discount->fk_facture_source;
91  $newdiscount1->fk_facture=$discount->fk_facture;
92  $newdiscount2->fk_facture=$discount->fk_facture;
93  $newdiscount1->fk_facture_line=$discount->fk_facture_line;
94  $newdiscount2->fk_facture_line=$discount->fk_facture_line;
95  if ($discount->description == '(CREDIT_NOTE)' || $discount->description == '(DEPOSIT)')
96  {
97  $newdiscount1->description=$discount->description;
98  $newdiscount2->description=$discount->description;
99  }
100  else
101  {
102  $newdiscount1->description=$discount->description.' (1)';
103  $newdiscount2->description=$discount->description.' (2)';
104  }
105  $newdiscount1->fk_user=$discount->fk_user;
106  $newdiscount2->fk_user=$discount->fk_user;
107  $newdiscount1->fk_soc=$discount->fk_soc;
108  $newdiscount2->fk_soc=$discount->fk_soc;
109  $newdiscount1->datec=$discount->datec;
110  $newdiscount2->datec=$discount->datec;
111  $newdiscount1->tva_tx=$discount->tva_tx;
112  $newdiscount2->tva_tx=$discount->tva_tx;
113  $newdiscount1->amount_ttc=$_POST["amount_ttc_1"];
114  $newdiscount2->amount_ttc=price2num($discount->amount_ttc-$newdiscount1->amount_ttc);
115  $newdiscount1->amount_ht=price2num($newdiscount1->amount_ttc/(1+$newdiscount1->tva_tx/100),'MT');
116  $newdiscount2->amount_ht=price2num($newdiscount2->amount_ttc/(1+$newdiscount2->tva_tx/100),'MT');
117  $newdiscount1->amount_tva=price2num($newdiscount1->amount_ttc-$newdiscount1->amount_ht);
118  $newdiscount2->amount_tva=price2num($newdiscount2->amount_ttc-$newdiscount2->amount_ht);
119 
120  $db->begin();
121  $discount->fk_facture_source=0; // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_facture_source
122  $res=$discount->delete($user);
123  $newid1=$newdiscount1->create($user);
124  $newid2=$newdiscount2->create($user);
125  if ($res > 0 && $newid1 > 0 && $newid2 > 0)
126  {
127  $db->commit();
128  header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id.($backtopage?'&backtopage='.urlencode($backtopage):'')); // To avoid pb whith back
129  exit;
130  }
131  else
132  {
133  $db->rollback();
134  }
135  }
136 }
137 
138 if ($action == 'setremise' && $user->rights->societe->creer)
139 {
140  //if ($user->rights->societe->creer)
141  //if ($user->rights->facture->creer)
142 
143  $amount_ht=GETPOST('amount_ht');
144  $desc=GETPOST('desc','alpha');
145  $tva_tx=GETPOST('tva_tx','alpha');
146 
147  if (price2num($amount_ht) > 0)
148  {
149  $error=0;
150  if (empty($desc))
151  {
152  setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("ReasonDiscount")), null, 'errors');
153  $error++;
154  }
155 
156  if (! $error)
157  {
158  $soc = new Societe($db);
159  $soc->fetch($id);
160  $discountid=$soc->set_remise_except($amount_ht,$user,$desc,$tva_tx);
161 
162  if ($discountid > 0)
163  {
164  if (! empty($backtopage))
165  {
166  header("Location: ".$backtopage.'&discountid='.$discountid);
167  exit;
168  }
169  else
170  {
171  header("Location: remx.php?id=".$id);
172  exit;
173  }
174  }
175  else
176  {
177  $error++;
178  setEventMessages($soc->error, $soc->errors, 'errors');
179  }
180  }
181  }
182  else
183  {
184  setEventMessages($langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")), null, 'errors');
185  }
186 }
187 
188 if (GETPOST('action','aZ09') == 'confirm_remove' && GETPOST("confirm")=='yes')
189 {
190  //if ($user->rights->societe->creer)
191  //if ($user->rights->facture->creer)
192 
193  $db->begin();
194 
195  $discount = new DiscountAbsolute($db);
196  $result=$discount->fetch(GETPOST("remid"));
197  $result=$discount->delete($user);
198  if ($result > 0)
199  {
200  $db->commit();
201  header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back
202  exit;
203  }
204  else
205  {
206  setEventMessages($discount->error, $discount->errors, 'errors');
207  $db->rollback();
208  }
209 }
210 
211 
212 /*
213  * View
214  */
215 
216 $form=new Form($db);
217 $facturestatic=new Facture($db);
218 
219 llxHeader('',$langs->trans("GlobalDiscount"));
220 
221 if ($socid > 0)
222 {
223  // On recupere les donnees societes par l'objet
224  $object = new Societe($db);
225  $object->fetch($socid);
226 
227  /*
228  * Display tabs
229  */
230  $head = societe_prepare_head($object);
231 
232 
233  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
234  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
235  print '<input type="hidden" name="action" value="setremise">';
236  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
237 
238  dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"), 0, 'company');
239 
240  dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
241 
242  print '<div class="fichecenter">';
243 
244  print '<div class="underbanner clearboth"></div>';
245  print '<table class="border centpercent">';
246 
247  // Calcul avoirs en cours
248  $remise_all=$remise_user=0;
249  $sql = "SELECT SUM(rc.amount_ht) as amount, rc.fk_user";
250  $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
251  $sql.= " WHERE rc.fk_soc = " . $object->id;
252  $sql.= " AND rc.entity = " . $conf->entity;
253  $sql.= " AND (fk_facture_line IS NULL AND fk_facture IS NULL)";
254  $sql.= " GROUP BY rc.fk_user";
255  $resql=$db->query($sql);
256  if ($resql)
257  {
258  $obj = $db->fetch_object($resql);
259  $remise_all+=$obj->amount;
260  if ($obj->fk_user == $user->id) $remise_user+=$obj->amount;
261  }
262  else
263  {
264  dol_print_error($db);
265  }
266 
267  print '<tr><td class="titlefield">'.$langs->trans("CustomerAbsoluteDiscountAllUsers").'</td>';
268  print '<td>'.$remise_all.'&nbsp;'.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'</td></tr>';
269 
270  if (! empty($user->fk_soc)) // No need to show this for external users
271  {
272  print '<tr><td>'.$langs->trans("CustomerAbsoluteDiscountMy").'</td>';
273  print '<td>'.$remise_user.'&nbsp;'.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'</td></tr>';
274  }
275  print '</table>';
276 
277  print '</div>';
278 
279  if ($user->rights->societe->creer)
280  {
281  print '<br>';
282 
283  print load_fiche_titre($langs->trans("NewGlobalDiscount"),'','');
284 
285  print '<div class="underbanner clearboth"></div>';
286  print '<table class="border" width="100%">';
287  print '<tr><td class="titlefield fieldrequired">'.$langs->trans("AmountHT").'</td>';
288  print '<td><input type="text" size="5" name="amount_ht" value="'.price2num(GETPOST("amount_ht")).'">';
289  print '<span class="hideonsmartphone">&nbsp;'.$langs->trans("Currency".$conf->currency).'</span></td></tr>';
290  print '<tr><td>'.$langs->trans("VAT").'</td>';
291  print '<td>';
292  print $form->load_tva('tva_tx',GETPOST('tva_tx'),$mysoc,$object);
293  print '</td></tr>';
294  print '<tr><td class="fieldrequired" >'.$langs->trans("NoteReason").'</td>';
295  print '<td><input type="text" class="quatrevingtpercent" name="desc" value="'.GETPOST('desc','none').'"></td></tr>';
296 
297  print "</table>";
298  }
299 
300  dol_fiche_end();
301 
302  if ($user->rights->societe->creer)
303  {
304  print '<div class="center">';
305  print '<input type="submit" class="button" name="submit" value="'.$langs->trans("AddGlobalDiscount").'">';
306  if (! empty($backtopage))
307  {
308  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
309  print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
310  }
311  print '</div>';
312  }
313 
314  print '</form>';
315 
316 
317  print '<br>';
318 
319  if ($_GET['action'] == 'remove')
320  {
321  print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.GETPOST('remid'), $langs->trans('RemoveDiscount'), $langs->trans('ConfirmRemoveDiscount'), 'confirm_remove', '', 0, 1);
322  }
323 
324  /*
325  * Liste remises fixes restant en cours (= liees a aucune facture ni ligne de facture)
326  */
327  $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
328  $sql.= " rc.datec as dc, rc.description,";
329  $sql.= " rc.fk_facture_source,";
330  $sql.= " u.login, u.rowid as user_id,";
331  $sql.= " fa.facnumber as ref, fa.type as type";
332  $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."societe_remise_except as rc";
333  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
334  $sql.= " WHERE rc.fk_soc = " . $object->id;
335  $sql.= " AND rc.entity = " . $conf->entity;
336  $sql.= " AND u.rowid = rc.fk_user";
337  $sql.= " AND (rc.fk_facture_line IS NULL AND rc.fk_facture IS NULL)";
338  $sql.= " ORDER BY rc.datec DESC";
339 
340  $resql=$db->query($sql);
341  if ($resql)
342  {
343  print load_fiche_titre($langs->trans("DiscountStillRemaining"));
344  print '<table width="100%" class="noborder">';
345  print '<tr class="liste_titre">';
346  print '<td class="widthdate">'.$langs->trans("Date").'</td>'; // Need 120+ for format with AM/PM
347  print '<td>'.$langs->trans("ReasonDiscount").'</td>';
348  print '<td width="150" class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
349  print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>';
350  print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>';
351  print '<td width="120" align="right">'.$langs->trans("AmountTTC").'</td>';
352  print '<td width="100" align="center">'.$langs->trans("DiscountOfferedBy").'</td>';
353  print '<td width="50">&nbsp;</td>';
354  print '</tr>';
355 
356  $showconfirminfo=array();
357 
358  $i = 0;
359  $num = $db->num_rows($resql);
360  if ($num > 0)
361  {
362  while ($i < $num)
363  {
364  $obj = $db->fetch_object($resql);
365 
366  print '<tr class="oddeven">';
367  print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>';
368  if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
369  {
370  print '<td class="nowrap">';
371  $facturestatic->id=$obj->fk_facture_source;
372  $facturestatic->ref=$obj->ref;
373  $facturestatic->type=$obj->type;
374  print preg_replace('/\(CREDIT_NOTE\)/',$langs->trans("CreditNote"),$obj->description).' '.$facturestatic->getNomURl(1);
375  print '</td>';
376  }
377  elseif (preg_match('/\(DEPOSIT\)/',$obj->description))
378  {
379  print '<td class="nowrap">';
380  $facturestatic->id=$obj->fk_facture_source;
381  $facturestatic->ref=$obj->ref;
382  $facturestatic->type=$obj->type;
383  print preg_replace('/\(DEPOSIT\)/',$langs->trans("InvoiceDeposit"),$obj->description).' '.$facturestatic->getNomURl(1);
384  print '</td>';
385  }
386  elseif (preg_match('/\(EXCESS RECEIVED\)/',$obj->description))
387  {
388  print '<td class="nowrap">';
389  $facturestatic->id=$obj->fk_facture_source;
390  $facturestatic->ref=$obj->ref;
391  $facturestatic->type=$obj->type;
392  print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("ExcessReceived"),$obj->description).' '.$facturestatic->getNomURl(1);
393  print '</td>';
394  }
395  else
396  {
397  print '<td>';
398  print $obj->description;
399  print '</td>';
400  }
401  print '<td class="nowrap">'.$langs->trans("NotConsumed").'</td>';
402  print '<td align="right">'.price($obj->amount_ht).'</td>';
403  print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
404  print '<td align="right">'.price($obj->amount_ttc).'</td>';
405  print '<td align="center">';
406  print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a>';
407  print '</td>';
408  if ($user->rights->societe->creer || $user->rights->facture->creer)
409  {
410  print '<td class="nowrap">';
411  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=split&remid='.$obj->rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_split($langs->trans("SplitDiscount")).'</a>';
412  print ' &nbsp; ';
413  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=remove&remid='.$obj->rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_delete($langs->trans("RemoveDiscount")).'</a>';
414  print '</td>';
415  }
416  else print '<td>&nbsp;</td>';
417  print '</tr>';
418 
419  if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid)
420  {
421  $showconfirminfo['rowid']=$obj->rowid;
422  $showconfirminfo['amount_ttc']=$obj->amount_ttc;
423  }
424  $i++;
425  }
426  }
427  else
428  {
429  print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
430  }
431  $db->free($resql);
432  print "</table>";
433 
434  if (count($showconfirminfo))
435  {
436  $amount1=price2num($showconfirminfo['amount_ttc']/2,'MT');
437  $amount2=($showconfirminfo['amount_ttc']-$amount1);
438  $formquestion=array(
439  'text' => $langs->trans('TypeAmountOfEachNewDiscount'),
440  array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'),
441  array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5')
442  );
443  $langs->load("dict");
444  print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage?'&backtopage='.urlencode($backtopage):''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount',price($showconfirminfo['amount_ttc']),$langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0);
445  }
446  }
447  else
448  {
449  dol_print_error($db);
450  }
451 
452  print '<br>';
453 
454  /*
455  * List discount consumed (=liees a une ligne de facture ou facture)
456  */
457 
458  // Remises liees a lignes de factures
459  $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
460  $sql.= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,";
461  $sql.= " rc.fk_facture_source,";
462  $sql.= " u.login, u.rowid as user_id,";
463  $sql.= " f.rowid, f.facnumber,";
464  $sql.= " fa.facnumber as ref, fa.type as type";
465  $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
466  $sql.= " , ".MAIN_DB_PREFIX."user as u";
467  $sql.= " , ".MAIN_DB_PREFIX."facturedet as fc";
468  $sql.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
469  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
470  $sql.= " WHERE rc.fk_soc =". $object->id;
471  $sql.= " AND rc.fk_facture_line = fc.rowid";
472  $sql.= " AND fc.fk_facture = f.rowid";
473  $sql.= " AND rc.fk_user = u.rowid";
474  $sql.= " ORDER BY dc DESC";
475  //$sql.= " UNION ";
476  // Remises liees a factures
477  $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
478  $sql2.= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,";
479  $sql2.= " rc.fk_facture_source,";
480  $sql2.= " u.login, u.rowid as user_id,";
481  $sql2.= " f.rowid, f.facnumber,";
482  $sql2.= " fa.facnumber as ref, fa.type as type";
483  $sql2.= " FROM ".MAIN_DB_PREFIX."facture as f";
484  $sql2.= " , ".MAIN_DB_PREFIX."user as u";
485  $sql2.= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
486  $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
487  $sql2.= " WHERE rc.fk_soc =". $object->id;
488  $sql2.= " AND rc.fk_facture = f.rowid";
489  $sql2.= " AND rc.fk_user = u.rowid";
490 
491  $sql2.= " ORDER BY dc DESC";
492 
493  $resql=$db->query($sql);
494  $resql2=null;
495  if ($resql) $resql2=$db->query($sql2);
496  if ($resql2)
497  {
498  print load_fiche_titre($langs->trans("DiscountAlreadyCounted"));
499  print '<table class="noborder" width="100%">';
500  print '<tr class="liste_titre">';
501  print '<td class="widthdate">'.$langs->trans("Date").'</td>'; // Need 120+ for format with AM/PM
502  print '<td>'.$langs->trans("ReasonDiscount").'</td>';
503  print '<td width="150" class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
504  print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>';
505  print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>';
506  print '<td width="120" align="right">'.$langs->trans("AmountTTC").'</td>';
507  print '<td width="100" align="center">'.$langs->trans("Author").'</td>';
508  print '<td width="50">&nbsp;</td>';
509  print '</tr>';
510 
511  $tab_sqlobj=array();
512  $tab_sqlobjOrder=array();
513  $num = $db->num_rows($resql);
514  if ($num > 0)
515  {
516  for ($i = 0;$i < $num; $i++)
517  {
518  $sqlobj = $db->fetch_object($resql);
519  $tab_sqlobj[] = $sqlobj;
520  $tab_sqlobjOrder[]=$db->jdate($sqlobj->dc);
521  }
522  }
523  $db->free($resql);
524 
525  $num = $db->num_rows($resql2);
526  for ($i = 0;$i < $num;$i++)
527  {
528  $sqlobj = $db->fetch_object($resql2);
529  $tab_sqlobj[] = $sqlobj;
530  $tab_sqlobjOrder[]= $db->jdate($sqlobj->dc);
531  }
532  $db->free($resql2);
533  array_multisort($tab_sqlobjOrder,SORT_DESC,$tab_sqlobj);
534 
535  $num = count($tab_sqlobj);
536  if ($num > 0)
537  {
538  $i = 0 ;
539  while ($i < $num )
540  {
541  $obj = array_shift($tab_sqlobj);
542  print '<tr class="oddeven">';
543  print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>';
544  if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
545  {
546  print '<td class="nowrap">';
547  $facturestatic->id=$obj->fk_facture_source;
548  $facturestatic->ref=$obj->ref;
549  $facturestatic->type=$obj->type;
550  print preg_replace('/\(CREDIT_NOTE\)/',$langs->trans("CreditNote"),$obj->description).' '.$facturestatic->getNomURl(1);
551  print '</td>';
552  }
553  elseif (preg_match('/\(DEPOSIT\)/',$obj->description))
554  {
555  print '<td class="nowrap">';
556  $facturestatic->id=$obj->fk_facture_source;
557  $facturestatic->ref=$obj->ref;
558  $facturestatic->type=$obj->type;
559  print preg_replace('/\(DEPOSIT\)/',$langs->trans("InvoiceDeposit"),$obj->description).' '.$facturestatic->getNomURl(1);
560  print '</td>';
561  }
562  elseif (preg_match('/\(EXCESS RECEIVED\)/',$obj->description))
563  {
564  print '<td class="nowrap">';
565  $facturestatic->id=$obj->fk_facture_source;
566  $facturestatic->ref=$obj->ref;
567  $facturestatic->type=$obj->type;
568  print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("Invoice"),$obj->description).' '.$facturestatic->getNomURl(1);
569  print '</td>';
570  }
571  else
572  {
573  print '<td>';
574  print $obj->description;
575  print '</td>';
576  }
577  print '<td align="left" class="nowrap"><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.'</a></td>';
578  print '<td align="right">'.price($obj->amount_ht).'</td>';
579  print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
580  print '<td align="right">'.price($obj->amount_ttc).'</td>';
581  print '<td align="center">';
582  print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a>';
583  print '</td>';
584  print '<td>&nbsp;</td>';
585  print '</tr>';
586  $i++;
587  }
588  }
589  else
590  {
591  print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
592  }
593 
594  print "</table>";
595  }
596  else
597  {
598  dol_print_error($db);
599  }
600 
601 }
602 
603 llxFooter();
604 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
if(GETPOST('cancel','alpha')) if(!GETPOST('confirmmassaction','alpha')&&$massaction!= 'presend'&&$massaction!= 'confirm_presend')
Draft customers invoices.
Definition: list.php:147
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_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
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.
Definition: company.lib.php:40
img_delete($titlealt= 'default', $other= 'class="pictodelete"')
Show delete logo.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->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)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
Class to manage absolute discounts.
Class to manage invoices.
img_split($titlealt= 'default', $other= 'class="pictosplit"')
Show split logo.
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is '...