objectline_view.tpl.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. // Protection to avoid direct call of template
  40. if (empty($object) || ! is_object($object))
  41. {
  42. print "Error, template page can't be called as URL";
  43. exit;
  44. }
  45. global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax;
  46. $usemargins=0;
  47. if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1;
  48. if (empty($dateSelector)) $dateSelector=0;
  49. if (empty($forceall)) $forceall=0;
  50. if (empty($senderissupplier)) $senderissupplier=0;
  51. if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
  52. if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0;
  53. // add html5 elements
  54. $domData = ' data-element="'.$line->element.'"';
  55. $domData .= ' data-id="'.$line->id.'"';
  56. $domData .= ' data-qty="'.$line->qty.'"';
  57. $domData .= ' data-product_type="'.$line->product_type.'"';
  58. ?>
  59. <?php $coldisplay=0; ?>
  60. <!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->
  61. <tr <?php echo 'id="row-'.$line->id.'" '.$bcdd[$var]; echo $domData; ?> >
  62. <?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
  63. <td class="linecolnum" align="center"><?php $coldisplay++; ?><?php echo ($i+1); ?></td>
  64. <?php } ?>
  65. <td class="linecoldescription minwidth300imp"><?php $coldisplay++; ?><div id="line_<?php echo $line->id; ?>"></div>
  66. <?php
  67. if (($line->info_bits & 2) == 2) {
  68. ?>
  69. <a href="<?php echo DOL_URL_ROOT.'/comm/remx.php?id='.$this->socid; ?>">
  70. <?php
  71. $txt='';
  72. print img_object($langs->trans("ShowReduc"),'reduc').' ';
  73. if ($line->description == '(DEPOSIT)') $txt=$langs->trans("Deposit");
  74. elseif ($line->description == '(EXCESS RECEIVED)') $txt=$langs->trans("ExcessReceived");
  75. elseif ($line->description == '(EXCESS PAID)') $txt=$langs->trans("ExcessPaid");
  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. elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0)
  105. {
  106. $discount=new DiscountAbsolute($this->db);
  107. $discount->fetch($line->fk_remise_except);
  108. echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessPaid",$discount->getNomUrl(0));
  109. }
  110. else
  111. {
  112. echo ($txt?' - ':'').dol_htmlentitiesbr($line->description);
  113. }
  114. }
  115. }
  116. else
  117. {
  118. $format = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE?'dayhour':'day';
  119. if ($line->fk_product > 0)
  120. {
  121. echo $form->textwithtooltip($text,$description,3,'','',$i,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):''));
  122. }
  123. else
  124. {
  125. if ($type==1) $text = img_object($langs->trans('Service'),'service');
  126. else $text = img_object($langs->trans('Product'),'product');
  127. if (! empty($line->label)) {
  128. $text.= ' <strong>'.$line->label.'</strong>';
  129. echo $form->textwithtooltip($text,dol_htmlentitiesbr($line->description),3,'','',$i,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):''));
  130. } else {
  131. if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow');
  132. echo $text.' '.dol_htmlentitiesbr($line->description);
  133. }
  134. }
  135. // Show date range
  136. if ($line->element == 'facturedetrec') {
  137. if ($line->date_start_fill || $line->date_end_fill) echo '<br><div class="clearboth nowraponall">';
  138. if ($line->date_start_fill) echo $langs->trans('AutoFillDateFromShort').': '.yn($line->date_start_fill);
  139. if ($line->date_start_fill && $line->date_end_fill) echo ' - ';
  140. if ($line->date_end_fill) echo $langs->trans('AutoFillDateToShort').': '.yn($line->date_end_fill);
  141. if ($line->date_start_fill || $line->date_end_fill) echo '</div>';
  142. }
  143. else {
  144. if ($line->date_start || $line->date_end) echo '<br><div class="clearboth nowraponall">'.get_date_range($line->date_start, $line->date_end, $format).'</div>';
  145. //echo get_date_range($line->date_start, $line->date_end, $format);
  146. }
  147. // Add description in form
  148. if ($line->fk_product > 0 && ! empty($conf->global->PRODUIT_DESC_IN_FORM))
  149. {
  150. print (! empty($line->description) && $line->description!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->description):'';
  151. }
  152. }
  153. if (! empty($conf->accounting->enabled) && $line->fk_accounting_account > 0)
  154. {
  155. $accountingaccount=new AccountingAccount($this->db);
  156. $accountingaccount->fetch($line->fk_accounting_account);
  157. echo '<div class="clearboth"></div><br><span class="opacitymedium">' . $langs->trans('AccountingAffectation') . ' : </span>' . $accountingaccount->getNomUrl(0,1,1);
  158. }
  159. ?>
  160. </td>
  161. <?php
  162. if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines
  163. {
  164. ?>
  165. <td class="linecolrefsupplier"><?php
  166. echo ($line->ref_fourn?$line->ref_fourn:$line->ref_supplier);
  167. ?></td>
  168. <?php
  169. }
  170. // VAT Rate
  171. ?>
  172. <td align="right" class="linecolvat nowrap"><?php $coldisplay++; ?><?php
  173. $positiverates='';
  174. if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx);
  175. if (price2num($line->total_localtax1)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx);
  176. if (price2num($line->total_localtax2)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx);
  177. if (empty($positiverates)) $positiverates='0';
  178. echo vatrate($positiverates.($line->vat_src_code?' ('.$line->vat_src_code.')':''), '%', $line->info_bits);
  179. //echo vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits);
  180. ?></td>
  181. <td align="right" class="linecoluht nowrap"><?php $coldisplay++; ?><?php echo price($line->subprice); ?></td>
  182. <?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?>
  183. <td align="right" class="linecoluht_currency nowrap"><?php $coldisplay++; ?><?php echo price($line->multicurrency_subprice); ?></td>
  184. <?php } ?>
  185. <?php if ($inputalsopricewithtax) { ?>
  186. <td align="right" class="linecoluttc nowrap"><?php $coldisplay++; ?><?php echo (isset($line->pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?></td>
  187. <?php } ?>
  188. <td align="right" class="linecolqty nowrap"><?php $coldisplay++; ?>
  189. <?php if ((($line->info_bits & 2) != 2) && $line->special_code != 3) {
  190. // I comment this because it shows info even when not required
  191. // 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
  192. // must also not be output for most entities (proposal, intervention, ...)
  193. //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
  194. 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
  195. } else echo '&nbsp;'; ?>
  196. </td>
  197. <?php
  198. if($conf->global->PRODUCT_USE_UNITS)
  199. {
  200. print '<td align="left" class="linecoluseunit nowrap">';
  201. $label = $line->getLabelOfUnit('short');
  202. if ($label !== '') {
  203. print $langs->trans($label);
  204. }
  205. print '</td>';
  206. }
  207. ?>
  208. <?php if (!empty($line->remise_percent) && $line->special_code != 3) { ?>
  209. <td class="linecoldiscount" align="right"><?php
  210. $coldisplay++;
  211. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  212. echo dol_print_reduction($line->remise_percent,$langs);
  213. ?></td>
  214. <?php } else { ?>
  215. <td class="linecoldiscount"><?php $coldisplay++; ?>&nbsp;</td>
  216. <?php }
  217. if ($this->situation_cycle_ref) {
  218. $coldisplay++;
  219. print '<td align="right" class="linecolcycleref nowrap">' . $line->situation_percent . '%</td>';
  220. }
  221. if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
  222. {
  223. $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
  224. ?>
  225. <?php if (!empty($user->rights->margins->creer)) { ?>
  226. <td align="right" class="linecolmargin1 nowrap margininfos"><?php $coldisplay++; ?><?php echo price($line->pa_ht); ?></td>
  227. <?php } ?>
  228. <?php if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?>
  229. <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>
  230. <?php }
  231. if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?>
  232. <td align="right" class="linecolmargin2 nowrap margininfos"><?php $coldisplay++; ?><?php echo price($line->marque_tx, null, null, null, null, $rounding).'%'; ?></td>
  233. <?php }
  234. }
  235. ?>
  236. <?php if ($line->special_code == 3) { ?>
  237. <td align="right" class="linecoloption nowrap"><?php $coldisplay++; ?><?php echo $langs->trans('Option'); ?></td>
  238. <?php } else { ?>
  239. <td align="right" class="linecolht nowrap"><?php $coldisplay++; ?><?php echo price($line->total_ht); ?></td>
  240. <?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?>
  241. <td align="right" class="linecolutotalht_currency nowrap"><?php $coldisplay++; ?><?php echo price($line->multicurrency_total_ht); ?></td>
  242. <?php } ?>
  243. <?php } ?>
  244. <?php if ($outputalsopricetotalwithtax) { ?>
  245. <td align="right" class="linecolht nowrap"><?php $coldisplay++; ?><?php echo price($line->total_ttc); ?></td>
  246. <?php } ?>
  247. <?php
  248. if ($this->statut == 0 && ($object_rights->creer) && $action != 'selectlines' ) { ?>
  249. <td class="linecoledit" align="center"><?php $coldisplay++; ?>
  250. <?php if (($line->info_bits & 2) == 2 || ! empty($disableedit)) { ?>
  251. <?php } else { ?>
  252. <a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'#line_'.$line->id; ?>">
  253. <?php echo img_edit(); ?>
  254. </a>
  255. <?php } ?>
  256. </td>
  257. <td class="linecoldelete" align="center"><?php $coldisplay++; ?>
  258. <?php
  259. 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
  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. <?php
  267. if ($num > 1 && empty($conf->browser->phone) && ($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disablemove)) { ?>
  268. <td align="center" class="linecolmove tdlineupdown"><?php $coldisplay++; ?>
  269. <?php if ($i > 0) { ?>
  270. <a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=up&amp;rowid='.$line->id; ?>">
  271. <?php echo img_up('default',0,'imgupforline'); ?>
  272. </a>
  273. <?php } ?>
  274. <?php if ($i < $num-1) { ?>
  275. <a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=down&amp;rowid='.$line->id; ?>">
  276. <?php echo img_down('default',0,'imgdownforline'); ?>
  277. </a>
  278. <?php } ?>
  279. </td>
  280. <?php } else { ?>
  281. <td align="center"<?php echo ((empty($conf->browser->phone) && empty($disablemove)) ?' class="linecolmove tdlineupdown"':' class="linecolmove"'); ?>><?php $coldisplay++; ?></td>
  282. <?php } ?>
  283. <?php } else { ?>
  284. <td colspan="3"><?php $coldisplay=$coldisplay+3; ?></td>
  285. <?php } ?>
  286. <?php if($action == 'selectlines'){ ?>
  287. <td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
  288. <?php } ?>
  289. </tr>
  290. <?php
  291. //Line extrafield
  292. if (!empty($extrafieldsline))
  293. {
  294. print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcdd[$var],'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
  295. }
  296. ?>
  297. <!-- END PHP TEMPLATE objectline_view.tpl.php -->