dolibarr  7.0.0-beta
objectline_view.tpl.php
1 <?php
2 /* Copyright (C) 2010-2013 Regis Houssin <regis.houssin@capnetworks.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 ?>
60 <?php $coldisplay=0; ?>
61 <!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->
62 <tr <?php echo 'id="row-'.$line->id.'" '.$bcdd[$var]; ?>>
63  <?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
64  <td class="linecolnum" align="center"><?php $coldisplay++; ?><?php echo ($i+1); ?></td>
65  <?php } ?>
66  <td class="linecoldescription minwidth300imp"><?php $coldisplay++; ?><div id="line_<?php echo $line->id; ?>"></div>
67  <?php
68  if (($line->info_bits & 2) == 2) {
69  ?>
70  <a href="<?php echo DOL_URL_ROOT.'/comm/remx.php?id='.$this->socid; ?>">
71  <?php
72  $txt='';
73  print img_object($langs->trans("ShowReduc"),'reduc').' ';
74  if ($line->description == '(DEPOSIT)') $txt=$langs->trans("Deposit");
75  elseif ($line->description == '(EXCESS RECEIVED)') $txt=$langs->trans("ExcessReceived");
76  //else $txt=$langs->trans("Discount");
77  print $txt;
78  ?>
79  </a>
80  <?php
81  if ($line->description)
82  {
83  if ($line->description == '(CREDIT_NOTE)' && $line->fk_remise_except > 0)
84  {
85  $discount=new DiscountAbsolute($this->db);
86  $discount->fetch($line->fk_remise_except);
87  echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0));
88  }
89  elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0)
90  {
91  $discount=new DiscountAbsolute($this->db);
92  $discount->fetch($line->fk_remise_except);
93  echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0));
94  // Add date of deposit
95  if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE))
96  echo ' ('.dol_print_date($discount->datec).')';
97  }
98  elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0)
99  {
100  $discount=new DiscountAbsolute($this->db);
101  $discount->fetch($line->fk_remise_except);
102  echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessReceived",$discount->getNomUrl(0));
103  }
104  else
105  {
106  echo ($txt?' - ':'').dol_htmlentitiesbr($line->description);
107  }
108  }
109  }
110  else
111  {
112  $format = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE?'dayhour':'day';
113 
114  if ($line->fk_product > 0)
115  {
116  echo $form->textwithtooltip($text,$description,3,'','',$i,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):''));
117 
118  // Show range
119  echo get_date_range($line->date_start, $line->date_end, $format);
120 
121  // Add description in form
122  if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
123  {
124  print (! empty($line->description) && $line->description!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->description):'';
125  }
126 
127  }
128  else
129  {
130 
131  if ($type==1) $text = img_object($langs->trans('Service'),'service');
132  else $text = img_object($langs->trans('Product'),'product');
133 
134  if (! empty($line->label)) {
135  $text.= ' <strong>'.$line->label.'</strong>';
136  echo $form->textwithtooltip($text,dol_htmlentitiesbr($line->description),3,'','',$i,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):''));
137  } else {
138  if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow');
139  echo $text.' '.dol_htmlentitiesbr($line->description);
140  }
141 
142  // Show range
143  echo get_date_range($line->date_start,$line->date_end, $format);
144  }
145  }
146  ?>
147  </td>
148  <?php
149  if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines
150  {
151  ?>
152  <td class="linecolrefsupplier"><?php
153  echo ($line->ref_fourn?$line->ref_fourn:$line->ref_supplier);
154  ?></td>
155  <?php
156  }
157  // VAT Rate
158  ?>
159  <td align="right" class="linecolvat nowrap"><?php $coldisplay++; ?><?php
160  $positiverates='';
161  if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx);
162  if (price2num($line->total_localtax1)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx);
163  if (price2num($line->total_localtax2)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx);
164  if (empty($positiverates)) $positiverates='0';
165  echo vatrate($positiverates.($line->vat_src_code?' ('.$line->vat_src_code.')':''), '%', $line->info_bits);
166  //echo vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits);
167  ?></td>
168 
169  <td align="right" class="linecoluht nowrap"><?php $coldisplay++; ?><?php echo price($line->subprice); ?></td>
170 
171  <?php if (!empty($conf->multicurrency->enabled)) { ?>
172  <td align="right" class="linecoluht_currency nowrap"><?php $coldisplay++; ?><?php echo price($line->multicurrency_subprice); ?></td>
173  <?php } ?>
174 
175  <?php if ($inputalsopricewithtax) { ?>
176  <td align="right" class="linecoluttc nowrap"><?php $coldisplay++; ?><?php echo (isset($line->pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?></td>
177  <?php } ?>
178 
179  <td align="right" class="linecolqty nowrap"><?php $coldisplay++; ?>
180  <?php if ((($line->info_bits & 2) != 2) && $line->special_code != 3) {
181  // I comment this because it shows info even when not required
182  // 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
183  // must also not be output for most entities (proposal, intervention, ...)
184  //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
185  echo $line->qty;
186  } else echo '&nbsp;'; ?>
187  </td>
188 
189  <?php
190  if($conf->global->PRODUCT_USE_UNITS)
191  {
192  print '<td align="left" class="linecoluseunit nowrap">';
193  $label = $line->getLabelOfUnit('short');
194  if ($label !== '') {
195  print $langs->trans($label);
196  }
197  print '</td>';
198  }
199  ?>
200 
201  <?php if (!empty($line->remise_percent) && $line->special_code != 3) { ?>
202  <td class="linecoldiscount" align="right"><?php
203  $coldisplay++;
204  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
205  echo dol_print_reduction($line->remise_percent,$langs);
206  ?></td>
207  <?php } else { ?>
208  <td class="linecoldiscount"><?php $coldisplay++; ?>&nbsp;</td>
209  <?php }
210 
211  if ($this->situation_cycle_ref) {
212  $coldisplay++;
213  print '<td align="right" class="linecolcycleref nowrap">' . $line->situation_percent . '%</td>';
214  }
215 
216  if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
217  {
218  $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
219  ?>
220 
221  <?php if (!empty($user->rights->margins->creer)) { ?>
222  <td align="right" class="linecolmargin1 nowrap margininfos"><?php $coldisplay++; ?><?php echo price($line->pa_ht); ?></td>
223  <?php } ?>
224  <?php if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?>
225  <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>
226  <?php }
227  if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?>
228  <td align="right" class="linecolmargin2 nowrap margininfos"><?php $coldisplay++; ?><?php echo price($line->marque_tx, null, null, null, null, $rounding).'%'; ?></td>
229  <?php }
230  }
231  ?>
232 
233  <?php if ($line->special_code == 3) { ?>
234  <td align="right" class="linecoloption nowrap"><?php $coldisplay++; ?><?php echo $langs->trans('Option'); ?></td>
235  <?php } else { ?>
236  <td align="right" class="liencolht nowrap"><?php $coldisplay++; ?><?php echo price($line->total_ht); ?></td>
237  <?php if (!empty($conf->multicurrency->enabled)) { ?>
238  <td align="right" class="linecolutotalht_currency nowrap"><?php $coldisplay++; ?><?php echo price($line->multicurrency_total_ht); ?></td>
239  <?php } ?>
240  <?php } ?>
241  <?php if ($outputalsopricetotalwithtax) { ?>
242  <td align="right" class="liencolht nowrap"><?php $coldisplay++; ?><?php echo price($line->total_ttc); ?></td>
243  <?php } ?>
244 
245 
246  <?php
247  if ($this->statut == 0 && ($object_rights->creer)) { ?>
248  <td class="linecoledit" align="center"><?php $coldisplay++; ?>
249  <?php if (($line->info_bits & 2) == 2 || ! empty($disableedit)) { ?>
250  <?php } else { ?>
251  <a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'#line_'.$line->id; ?>">
252  <?php echo img_edit(); ?>
253  </a>
254  <?php } ?>
255  </td>
256 
257  <td class="linecoldelete" align="center"><?php $coldisplay++; ?>
258  <?php
259  if (($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disableremove)) {
260  print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&amp;action=ask_deleteline&amp;lineid=' . $line->id . '">';
261  print img_delete();
262  print '</a>';
263  }
264  ?>
265  </td>
266 
267  <?php
268  if ($num > 1 && empty($conf->browser->phone) && ($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disablemove)) { ?>
269  <td align="center" class="linecolmove tdlineupdown"><?php $coldisplay++; ?>
270  <?php if ($i > 0) { ?>
271  <a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=up&amp;rowid='.$line->id; ?>">
272  <?php echo img_up('default',0,'imgupforline'); ?>
273  </a>
274  <?php } ?>
275  <?php if ($i < $num-1) { ?>
276  <a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=down&amp;rowid='.$line->id; ?>">
277  <?php echo img_down('default',0,'imgdownforline'); ?>
278  </a>
279  <?php } ?>
280  </td>
281  <?php } else { ?>
282  <td align="center"<?php echo ((empty($conf->browser->phone) && empty($disablemove)) ?' class="linecolmove tdlineupdown"':' class="linecolmove"'); ?>><?php $coldisplay++; ?></td>
283  <?php } ?>
284 <?php } else { ?>
285  <td colspan="3"><?php $coldisplay=$coldisplay+3; ?></td>
286 <?php } ?>
287 
288 <?php
289 //Line extrafield
290 if (!empty($extrafieldsline))
291 {
292  print $line->showOptionals($extrafieldsline,'view',array('style'=>$bcdd[$var],'colspan'=>$coldisplay));
293 }
294 ?>
295 
296 </tr>
297 <!-- END PHP TEMPLATE objectline_view.tpl.php -->
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
dol_print_reduction($reduction, $langs)
Returns formated reduction.
</td >< tdclass="liste_titre"align="right"></td ></tr >< trclass="liste_titre">< inputtype="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< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="'.$i.'"'.$disabled.'></td >< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"></td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:554
if(GETPOST('cancel','alpha')) if(!GETPOST('confirmmassaction','alpha')&&$massaction!= 'presend'&&$massaction!= 'confirm_presend')
Draft customers invoices.
Definition: list.php:147
if(empty($reshook)) $form
View.
Definition: perms.php:103
get_date_range($date_start, $date_end, $format= '', $outputlangs='', $withparenthesis=1)
Format output for start and end date.
img_down($titlealt= 'default', $selected=0, $moreclass='')
Show down arrow logo.
img_up($titlealt= 'default', $selected=0, $moreclass='')
Show top arrow logo.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_delete($titlealt= 'default', $other= 'class="pictodelete"')
Show delete logo.
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).
print
Draft customers invoices.
Definition: index.php:91
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.
img_edit($titlealt= 'default', $float=0, $other= 'class="pictoedit"')
Show logo editer/modifier fiche.
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is '...