dolibarr  9.0.0
objectline_view.tpl.php
1 <?php
2 /* Copyright (C) 2010-2013 Regis Houssin <regis.houssin@inodbox.com>
3  * Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
5  * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
6  * Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
7  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
8  * Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * Need to have following variables defined:
24  * $object (invoice, order, ...)
25  * $conf
26  * $langs
27  * $dateSelector
28  * $forceall (0 by default, 1 for supplier invoices/orders)
29  * $element (used to test $user->rights->$element->creer)
30  * $permtoedit (used to replace test $user->rights->$element->creer)
31  * $senderissupplier (0 by default, 1 for supplier invoices/orders)
32  * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
33  * $usemargins (0 to disable all margins columns, 1 to show according to margin setup)
34  * $object_rights->creer initialized from = $object->getRights()
35  * $disableedit, $disablemove, $disableremove
36  *
37  * $type, $text, $description, $line
38  */
39 
40 // Protection to avoid direct call of template
41 if (empty($object) || ! is_object($object))
42 {
43  print "Error, template page can't be called as URL";
44  exit;
45 }
46 
47 
48 global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax;
49 
50 $usemargins=0;
51 if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1;
52 
53 if (empty($dateSelector)) $dateSelector=0;
54 if (empty($forceall)) $forceall=0;
55 if (empty($senderissupplier)) $senderissupplier=0;
56 if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
57 if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0;
58 
59 // add html5 elements
60 $domData = ' data-element="'.$line->element.'"';
61 $domData .= ' data-id="'.$line->id.'"';
62 $domData .= ' data-qty="'.$line->qty.'"';
63 $domData .= ' data-product_type="'.$line->product_type.'"';
64 
65 
66 ?>
67 <?php $coldisplay=0; ?>
68 <!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->
69 <tr id="row-<?php echo $line->id?>" class="drag drop oddeven" <?php echo $domData; ?> >
70  <?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
71  <td class="linecolnum" align="center"><?php $coldisplay++; ?><?php echo ($i+1); ?></td>
72  <?php } ?>
73  <td class="linecoldescription minwidth300imp"><?php $coldisplay++; ?><div id="line_<?php echo $line->id; ?>"></div>
74  <?php
75  if (($line->info_bits & 2) == 2) {
76  ?>
77  <a href="<?php echo DOL_URL_ROOT.'/comm/remx.php?id='.$this->socid; ?>">
78  <?php
79  $txt='';
80  print img_object($langs->trans("ShowReduc"),'reduc').' ';
81  if ($line->description == '(DEPOSIT)') $txt=$langs->trans("Deposit");
82  elseif ($line->description == '(EXCESS RECEIVED)') $txt=$langs->trans("ExcessReceived");
83  elseif ($line->description == '(EXCESS PAID)') $txt=$langs->trans("ExcessPaid");
84  //else $txt=$langs->trans("Discount");
85  print $txt;
86  ?>
87  </a>
88  <?php
89  if ($line->description)
90  {
91  if ($line->description == '(CREDIT_NOTE)' && $line->fk_remise_except > 0)
92  {
93  $discount=new DiscountAbsolute($this->db);
94  $discount->fetch($line->fk_remise_except);
95  echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0));
96  }
97  elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0)
98  {
99  $discount=new DiscountAbsolute($this->db);
100  $discount->fetch($line->fk_remise_except);
101  echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0));
102  // Add date of deposit
103  if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE))
104  echo ' ('.dol_print_date($discount->datec).')';
105  }
106  elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0)
107  {
108  $discount=new DiscountAbsolute($this->db);
109  $discount->fetch($line->fk_remise_except);
110  echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessReceived",$discount->getNomUrl(0));
111  }
112  elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0)
113  {
114  $discount=new DiscountAbsolute($this->db);
115  $discount->fetch($line->fk_remise_except);
116  echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessPaid",$discount->getNomUrl(0));
117  }
118  else
119  {
120  echo ($txt?' - ':'').dol_htmlentitiesbr($line->description);
121  }
122  }
123  }
124  else
125  {
126  $format = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE?'dayhour':'day';
127 
128  if ($line->fk_product > 0)
129  {
130  echo $form->textwithtooltip($text,$description,3,'','',$i,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):''));
131  }
132  else
133  {
134  if ($type==1) $text = img_object($langs->trans('Service'),'service');
135  else $text = img_object($langs->trans('Product'),'product');
136 
137  if (! empty($line->label)) {
138  $text.= ' <strong>'.$line->label.'</strong>';
139  echo $form->textwithtooltip($text,dol_htmlentitiesbr($line->description),3,'','',$i,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):''));
140  } else {
141  if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow');
142  echo $text.' '.dol_htmlentitiesbr($line->description);
143  }
144  }
145 
146  // Show date range
147  if ($line->element == 'facturedetrec') {
148  if ($line->date_start_fill || $line->date_end_fill) echo '<br><div class="clearboth nowraponall">';
149  if ($line->date_start_fill) echo $langs->trans('AutoFillDateFromShort').': '.yn($line->date_start_fill);
150  if ($line->date_start_fill && $line->date_end_fill) echo ' - ';
151  if ($line->date_end_fill) echo $langs->trans('AutoFillDateToShort').': '.yn($line->date_end_fill);
152  if ($line->date_start_fill || $line->date_end_fill) echo '</div>';
153  }
154  else {
155  if ($line->date_start || $line->date_end) echo '<br><div class="clearboth nowraponall">'.get_date_range($line->date_start, $line->date_end, $format).'</div>';
156  //echo get_date_range($line->date_start, $line->date_end, $format);
157  }
158 
159  // Add description in form
160  if ($line->fk_product > 0 && ! empty($conf->global->PRODUIT_DESC_IN_FORM))
161  {
162  print (! empty($line->description) && $line->description!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->description):'';
163  }
164  }
165 
166  if (! empty($conf->accounting->enabled) && $line->fk_accounting_account > 0)
167  {
168  $accountingaccount=new AccountingAccount($this->db);
169  $accountingaccount->fetch($line->fk_accounting_account);
170  echo '<div class="clearboth"></div><br><span class="opacitymedium">' . $langs->trans('AccountingAffectation') . ' : </span>' . $accountingaccount->getNomUrl(0,1,1);
171  }
172 
173  ?>
174  </td>
175  <?php
176  if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines
177  {
178  ?>
179  <td class="linecolrefsupplier"><?php
180  echo ($line->ref_fourn?$line->ref_fourn:$line->ref_supplier);
181  ?></td>
182  <?php
183  }
184  // VAT Rate
185  ?>
186  <td align="right" class="linecolvat nowrap"><?php $coldisplay++; ?><?php
187  $positiverates='';
188  if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx);
189  if (price2num($line->total_localtax1)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx);
190  if (price2num($line->total_localtax2)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx);
191  if (empty($positiverates)) $positiverates='0';
192  echo vatrate($positiverates.($line->vat_src_code?' ('.$line->vat_src_code.')':''), '%', $line->info_bits);
193  //echo vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits);
194  ?></td>
195 
196  <td align="right" class="linecoluht nowrap"><?php $coldisplay++; ?><?php echo price($line->subprice); ?></td>
197 
198  <?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?>
199  <td align="right" class="linecoluht_currency nowrap"><?php $coldisplay++; ?><?php echo price($line->multicurrency_subprice); ?></td>
200  <?php } ?>
201 
202  <?php if ($inputalsopricewithtax) { ?>
203  <td align="right" class="linecoluttc nowrap"><?php $coldisplay++; ?><?php echo (isset($line->pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?></td>
204  <?php } ?>
205 
206  <td align="right" class="linecolqty nowrap"><?php $coldisplay++; ?>
207  <?php if ((($line->info_bits & 2) != 2) && $line->special_code != 3) {
208  // I comment this because it shows info even when not required
209  // for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated
210  // must also not be output for most entities (proposal, intervention, ...)
211  //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
212  echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price
213  } else echo '&nbsp;'; ?>
214  </td>
215 
216  <?php
217  if($conf->global->PRODUCT_USE_UNITS)
218  {
219  print '<td align="left" class="linecoluseunit nowrap">';
220  $label = $line->getLabelOfUnit('short');
221  if ($label !== '') {
222  print $langs->trans($label);
223  }
224  print '</td>';
225  }
226  ?>
227 
228  <?php if (!empty($line->remise_percent) && $line->special_code != 3) { ?>
229  <td class="linecoldiscount" align="right"><?php
230  $coldisplay++;
231  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
232  echo dol_print_reduction($line->remise_percent,$langs);
233  ?></td>
234  <?php } else { ?>
235  <td class="linecoldiscount"><?php $coldisplay++; ?>&nbsp;</td>
236  <?php }
237 
238  if ($this->situation_cycle_ref) {
239  $coldisplay++;
240  print '<td align="right" class="linecolcycleref nowrap">' . $line->situation_percent . '%</td>';
241  }
242 
243  if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
244  {
245  $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
246  ?>
247 
248  <?php if (!empty($user->rights->margins->creer)) { ?>
249  <td align="right" class="linecolmargin1 nowrap margininfos"><?php $coldisplay++; ?><?php echo price($line->pa_ht); ?></td>
250  <?php } ?>
251  <?php if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?>
252  <td align="right" class="linecolmargin2 nowrap margininfos"><?php $coldisplay++; ?><?php echo (($line->pa_ht == 0)?'n/a':price($line->marge_tx, null, null, null, null, $rounding).'%'); ?></td>
253  <?php }
254  if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?>
255  <td align="right" class="linecolmargin2 nowrap margininfos"><?php $coldisplay++; ?><?php echo price($line->marque_tx, null, null, null, null, $rounding).'%'; ?></td>
256  <?php }
257  }
258  ?>
259 
260  <?php if ($line->special_code == 3) { ?>
261  <td align="right" class="linecoloption nowrap"><?php $coldisplay++; ?><?php echo $langs->trans('Option'); ?></td>
262  <?php } else { ?>
263  <td align="right" class="linecolht nowrap"><?php $coldisplay++; ?><?php echo price($line->total_ht); ?></td>
264  <?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?>
265  <td align="right" class="linecolutotalht_currency nowrap"><?php $coldisplay++; ?><?php echo price($line->multicurrency_total_ht); ?></td>
266  <?php } ?>
267  <?php } ?>
268  <?php if ($outputalsopricetotalwithtax) { ?>
269  <td align="right" class="linecolht nowrap"><?php $coldisplay++; ?><?php echo price($line->total_ttc); ?></td>
270  <?php } ?>
271 
272 
273  <?php
274  if ($this->statut == 0 && ($object_rights->creer) && $action != 'selectlines' ) { ?>
275  <td class="linecoledit" align="center"><?php $coldisplay++; ?>
276  <?php if (($line->info_bits & 2) == 2 || ! empty($disableedit)) { ?>
277  <?php } else { ?>
278  <a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'#line_'.$line->id; ?>">
279  <?php echo img_edit(); ?>
280  </a>
281  <?php } ?>
282  </td>
283 
284  <td class="linecoldelete" align="center"><?php $coldisplay++; ?>
285  <?php
286  if (($line->fk_prev_id == null ) && empty($disableremove)) { //La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation
287  print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&amp;action=ask_deleteline&amp;lineid=' . $line->id . '">';
288  print img_delete();
289  print '</a>';
290  }
291  ?>
292  </td>
293 
294  <?php
295  if ($num > 1 && $conf->browser->layout != 'phone' && ($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disablemove)) { ?>
296  <td align="center" class="linecolmove tdlineupdown"><?php $coldisplay++; ?>
297  <?php if ($i > 0) { ?>
298  <a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=up&amp;rowid='.$line->id; ?>">
299  <?php echo img_up('default',0,'imgupforline'); ?>
300  </a>
301  <?php } ?>
302  <?php if ($i < $num-1) { ?>
303  <a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=down&amp;rowid='.$line->id; ?>">
304  <?php echo img_down('default',0,'imgdownforline'); ?>
305  </a>
306  <?php } ?>
307  </td>
308  <?php } else { ?>
309  <td align="center"<?php echo (($conf->browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown"':' class="linecolmove"'); ?>><?php $coldisplay++; ?></td>
310  <?php } ?>
311 <?php } else { ?>
312  <td colspan="3"><?php $coldisplay=$coldisplay+3; ?></td>
313 <?php } ?>
314  <?php if($action == 'selectlines'){ ?>
315  <td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
316  <?php } ?>
317 
318 </tr>
319 
320 <?php
321 //Line extrafield
322 if (!empty($extrafieldsline))
323 {
324  print $line->showOptionals($extrafieldsline, 'view', array('style'=>'class="drag drop oddeven"','colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
325 }
326 ?>
327 
328 <!-- END PHP TEMPLATE objectline_view.tpl.php -->
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
print
Draft customers invoices.
Definition: index.php:91
</td >< td class="liste_titre" align="right"></td ></tr >< tr class="liste_titre">< input type="checkbox" onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< tr class="oddeven">< td >< input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td >< td >< input type="checkbox" class="check" name="choose'.$i.'"></td >< td class="nowrap"></td >< td >< input type="hidden" name="desc' . $i . '" value="' . dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:573
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
dol_print_reduction($reduction, $langs)
Returns formated reduction.
img_edit($titlealt='default', $float=0, $other='class="pictoedit"')
Show logo editer/modifier fiche.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:103
img_delete($titlealt='default', $other='class="pictodelete"')
Show delete logo.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
type
Definition: viewcat.php:284
if(GETPOST('cancel', 'alpha')) if(! GETPOST( 'confirmmassaction', 'alpha') &&$massaction !='presend' &&$massaction !='confirm_presend')
Draft customers invoices.
Definition: list.php:156
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
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...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
Class to manage absolute discounts.
Class to manage accounting accounts.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)