dolibarr  9.0.0
orderstoinvoice.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
5  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2012 Andreu Bisquerra Gaya <jove@bisquerra.com>
7  * Copyright (C) 2012 David Rodriguez Martinez <davidrm146@gmail.com>
8  * Copyright (C) 2012-2017 Juanjo Menent <jmenent@2byte.es>
9  * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
10  * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
11  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <http://www.gnu.org/licenses/>.
25  */
26 
32 require '../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
34 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
35 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
36 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
39 require_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_invoice/modules_facturefournisseur.php';
40 if (! empty($conf->projet->enabled)) {
41  require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
42 }
43 
44 // Load translation files required by the page
45 $langs->loadLangs(array("orders", "companies", "deliveries"));
46 
47 if (! $user->rights->fournisseur->facture->creer)
49 
50 $id = (GETPOST('id') ? GETPOST('id', 'int') : GETPOST("facid")); // For backward compatibility
51 $ref = GETPOST('ref', 'alpha');
52 $action = GETPOST('action', 'alpha');
53 $confirm = GETPOST('confirm', 'alpha');
54 $sref = GETPOST('sref');
55 $sref_client = GETPOST('sref_client');
56 $sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
57 $socid = GETPOST('socid', 'int');
58 $selected = GETPOST('orders_to_invoice');
59 $sortfield = GETPOST("sortfield", 'alpha');
60 $sortorder = GETPOST("sortorder", 'alpha');
61 $viewstatut = GETPOST('viewstatut');
62 
63 if (! $sortfield)
64  $sortfield = 'c.rowid';
65 if (! $sortorder)
66  $sortorder = 'DESC';
67 
68 $now = dol_now();
69 $date_start = dol_mktime(0, 0, 0, $_REQUEST["date_startmonth"], $_REQUEST["date_startday"], $_REQUEST["date_startyear"]); // Date for local PHP server
70 $date_end = dol_mktime(23, 59, 59, $_REQUEST["date_endmonth"], $_REQUEST["date_endday"], $_REQUEST["date_endyear"]);
71 $date_starty = dol_mktime(0, 0, 0, $_REQUEST["date_start_delymonth"], $_REQUEST["date_start_delyday"], $_REQUEST["date_start_delyyear"]); // Date for local PHP server
72 $date_endy = dol_mktime(23, 59, 59, $_REQUEST["date_end_delymonth"], $_REQUEST["date_end_delyday"], $_REQUEST["date_end_delyyear"]);
73 
74 $extrafields = new ExtraFields($db);
75 
76 // fetch optionals attributes and labels
77 $extralabels=$extrafields->fetch_name_optionals_label('facture_fourn');
78 
79 if ($action == 'create')
80 {
81  if (! is_array($selected))
82  {
83  $error++;
84  setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors');
85  } else {
86  $origin = GETPOST('origin');
87  $originid = GETPOST('originid');
88  }
89 }
90 
91 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
92 include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
93 $hookmanager = new HookManager($db);
94 $hookmanager->initHooks(array('orderstoinvoicesupplier'));
95 
96 
97 /*
98  * Actions
99  */
100 
101 if (($action == 'create' || $action == 'add') && ! $error) {
102 
103  require_once DOL_DOCUMENT_ROOT . '/core/lib/fourn.lib.php';
104  if (! empty($conf->projet->enabled))
105  require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
106 
107  // Load translation files required by the page
108  $langs->loadLangs(array("bills", "main", "products"));
109 
110  if (isset($_GET['orders_to_invoice'])) {
111  $orders_id = GETPOST('orders_to_invoice','',1);
112  $n = count($orders_id);
113  $i = 0;
114 
115  $originid = $orders_id[0];
116  $_GET['originid'] = $orders_id[0];
117  }
118  if (isset($_POST['orders_to_invoice'])) {
119  $orders_id = GETPOST('orders_to_invoice','',2);
120  $nn = count($orders_id);
121  $ii = 0;
122 
123  $originid = $orders_id[0];
124  $_POST['originid'] = $orders_id[0];
125  }
126 
127  $projectid = GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : 0;
128  $lineid = GETPOST('lineid', 'int');
129  $userid = GETPOST('userid', 'int');
130  $search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref') : GETPOST('search_ref');
131 
132  // Security check
133  if ($user->societe_id)
134  $socid = $user->societe_id;
135  $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
136 
137  $usehm = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE;
138  $object = new FactureFournisseur($db);
139 
140  // Insert new invoice in database
141  if ($action == 'add' && $user->rights->fournisseur->facture->creer) {
142  $object->socid = GETPOST('socid');
143  $db->begin();
144  $error = 0;
145 
146  // Standard or deposit or proforma invoice
147  $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
148  if (empty($datefacture)) {
149  $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y"));
150  }
151  if (! $error) {
152  $object->ref = GETPOST('ref');
153  $object->ref_supplier = GETPOST('ref_supplier');
154  $object->socid = GETPOST('socid','int');
155  $object->libelle = GETPOST('libelle');
156  $object->date = $datefacture;
157  $object->date_echeance = $datedue;
158  $object->note_public = GETPOST('note_public','none');
159  $object->note_private = GETPOST('note_private','none');
160  $object->cond_reglement_id = GETPOST('cond_reglement_id');
161  $object->mode_reglement_id = GETPOST('mode_reglement_id');
162  $projectid = GETPOST('projectid');
163  if ($projectid > 0)
164  $object->fk_project = $projectid;
165 
166  // Auto calculation of date due if not filled by user
167  if (empty($object->date_echeance))
168  $object->date_echeance = $object->calculate_date_lim_reglement();
169 
170  $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
171  if ($ret < 0) $error++;
172 
173  if ($_POST['origin'] && $_POST['originid']) {
174  $linked_orders_ids=array();
175  foreach ( $orders_id as $origin => $origin_id ) {
176  $origin_id = (! empty($origin_id) ? $origin_id : $orders_id[$ii]);
177  $linked_orders_ids[]=$origin_id;
178  }
179  $object->linked_objects = array(GETPOST('origin')=>$linked_orders_ids);
180  $id = $object->create($user);
181 
182  if ($id > 0) {
183  while ( $ii < $nn ) {
184  $objectsrc = new CommandeFournisseur($db);
185  dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines");
186  $result = $objectsrc->fetch($orders_id[$ii]);
187  if ($result > 0) {
188  $lines = $objectsrc->lines;
189  if (empty($lines) && method_exists($objectsrc, 'fetch_lines')) {
190  $objectsrc->fetch_lines();
191  $lines = $objectsrc->lines;
192  }
193  $fk_parent_line = 0;
194  $num = count($lines);
195  for($i = 0; $i < $num; $i ++) {
196  $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
197 
198  $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
199  $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
200 
201  // Dates
202  // TODO mutualiser
203  $date_start = $lines[$i]->date_debut_prevue;
204  if ($lines[$i]->date_debut_reel)
205  $date_start = $lines[$i]->date_debut_reel;
206  if ($lines[$i]->date_start)
207  $date_start = $lines[$i]->date_start;
208  $date_end = $lines[$i]->date_fin_prevue;
209  if ($lines[$i]->date_fin_reel)
210  $date_end = $lines[$i]->date_fin_reel;
211  if ($lines[$i]->date_end)
212  $date_end = $lines[$i]->date_end;
213 
214  // Reset fk_parent_line for no child products and special product
215  if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
216  $fk_parent_line = 0;
217  }
218  // FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example.
219  $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->qty, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, 'HT', $product_type, -1, false, 0, $lines[$i]->fk_unit);
220 
221  if ($result > 0) {
222  $lineid = $result;
223  } else {
224  $lineid = 0;
225  $error ++;
226  break;
227  }
228  // Defined the new fk_parent_line
229  if ($result > 0 && $lines[$i]->product_type == 9) {
230  $fk_parent_line = $result;
231  }
232  }
233  } else {
234  $mesgs[] = $objectsrc->error;
235  $error ++;
236  }
237  $ii ++;
238  }
239  } else {
240  $mesgs[] = $object->error;
241  $error ++;
242  }
243  }
244  }
245 
246  // End of object creation, we show it
247  if ($id > 0 && ! $error) {
248 
249  foreach($orders_id as $fk_supplier_order) {
250  $supplier_order = new CommandeFournisseur($db);
251  if ($supplier_order->fetch($fk_supplier_order)>0 && $supplier_order->statut == 5)
252  {
253  if ($supplier_order->classifyBilled($user) < 0)
254  {
255  $db->rollback();
256  $action = 'create';
257  $_GET["origin"] = $_POST["origin"];
258  $_GET["originid"] = $_POST["originid"];
259  $mesgs[] = '<div class="error">' . $object->error . '</div>';
260 
261  $error++;
262  break;
263  }
264  }
265  }
266 
267  if(!$error) {
268  $db->commit();
269  header('Location: ' . DOL_URL_ROOT . '/fourn/facture/card.php?facid=' . $id);
270  exit();
271  }
272  } else {
273  $db->rollback();
274  $action = 'create';
275  $_GET["origin"] = $_POST["origin"];
276  $_GET["originid"] = $_POST["originid"];
277  $mesgs[] = '<div class="error">' . $object->error . '</div>';
278  }
279  }
280 }
281 
282 /*
283  * View
284  */
285 
286 $html = new Form($db);
287 $htmlother = new FormOther($db);
288 $formfile = new FormFile($db);
289 $companystatic = new Societe($db);
290 
291 // Mode creation
292 if ($action == 'create' && !$error) {
293 
294  llxHeader();
295  print load_fiche_titre($langs->trans('NewBill'));
296 
297  $soc = new Societe($db);
298  if ($socid)
299  $res = $soc->fetch($socid);
300  if ($res) {
301  $cond_reglement_id = $soc->cond_reglement_id;
302  $mode_reglement_id = $soc->mode_reglement_id;
303  }
304  $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? - 1 : '';
305 
306  print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
307  print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
308  print '<input type="hidden" name="action" value="add">';
309  print '<input type="hidden" name="socid" value="' . $soc->id . '">' . "\n";
310  print '<input name="facnumber" type="hidden" value="provisoire">';
311  print '<input name="ref_client" type="hidden" value="' . $ref_client . '">';
312  print '<input name="ref_int" type="hidden" value="' . $ref_int . '">';
313  print '<input type="hidden" name="origin" value="' . GETPOST('origin') . '">';
314  print '<input type="hidden" name="originid" value="' . GETPOST('originid') . '">';
315  print '<table class="border" width="100%">';
316 
317  // Ref
318  print '<tr><td class="fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans('Draft') . '</td></tr>';
319 
320  // Ref supplier
321  print '<tr><td class="fieldrequired">' . $langs->trans('RefSupplier') . '</td><td><input name="ref_supplier" value="' . dol_escape_htmltag(isset($_POST['ref_supplier']) ? GETPOST('ref_supplier','alpha', 2) : '') . '" type="text"></td>';
322  print '</tr>';
323 
324  // Third party
325  print '<tr><td class="fieldrequired">' . $langs->trans('Customer') . '</td><td colspan="2">';
326  print $soc->getNomUrl(1);
327  print '<input type="hidden" name="socid" value="' . $soc->id . '">';
328  print '</td>';
329  print '</tr>' . "\n";
330 
331  // Date invoice
332  print '<tr><td class="fieldrequired">' . $langs->trans('Date') . '</td><td colspan="2">';
333  print $html->selectDate('', '', '', '', '', "add", 1, 1);
334  print '</td></tr>';
335  // Payment term
336  print '<tr><td class="nowrap">' . $langs->trans('PaymentConditionsShort') . '</td><td colspan="2">';
337  $html->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id');
338  print '</td></tr>';
339  // Payment mode
340  print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
341  $html->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id');
342  print '</td></tr>';
343  // Project
344  if (! empty($conf->projet->enabled)) {
345  $formproject = new FormProjets($db);
346 
347  $langs->load('projects');
348  print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">';
349  $formproject->select_projects($soc->id, $projectid, 'projectid');
350  print '</td></tr>';
351  }
352 
353  $objectsrc = new CommandeFournisseur($db);
354  $listoforders = array ();
355  foreach ( $selected as $sel ) {
356  $result = $objectsrc->fetch($sel);
357  if ($result > 0) {
358  $listoforders[] = $objectsrc->ref;
359  }
360  }
361 
362  // Other attributes
363  $parameters = array (
364  'objectsrc' => $objectsrc,
365  'idsrc' => $listoforders,
366  'colspan' => ' colspan="2"',
367  'cols'=>2
368  );
369  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
370  print $hookmanager->resPrint;
371 
372  if (empty($reshook))
373  {
374  $object=new FactureFournisseur($db);
375  print $object->showOptionals($extrafields,'edit');
376  }
377 
378  // Modele PDF
379  print '<tr><td>' . $langs->trans('Model') . '</td>';
380  print '<td>';
382  print $html->selectarray('model', $liste, $conf->global->INVOICE_SUPPLIER_ADDON_PDF);
383  print "</td></tr>";
384 
385  // Public note
386  print '<tr>';
387  print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
388  print '<td valign="top" colspan="2">';
389  print '<textarea name="note_public" wrap="soft" class="quatrevingtpercent" rows="' . ROWS_3 . '">';
390 
391  print $langs->trans("Orders") . ": " . implode(', ', $listoforders);
392 
393  print '</textarea></td></tr>';
394  // Private note
395  if (empty($user->societe_id)) {
396  print '<tr>';
397  print '<td class="border" valign="top">' . $langs->trans('NotePrivate') . '</td>';
398  print '<td valign="top" colspan="2">';
399  print '<textarea name="note" wrap="soft" cols="70" rows="' . ROWS_3 . '">';
400 
401  print '</textarea></td></tr>';
402  }
403 
404  print '</table>';
405 
406  while ( $i < $n ) {
407  print '<input type="hidden" name="orders_to_invoice[]" value="' . $orders_id[$i] . '">';
408 
409  $i ++;
410  }
411 
412  // Button "Create Draft"
413  print '<br><div class="center"><input type="submit" class="button" name="bouton" value="' . $langs->trans('CreateDraft') . '" /></div>';
414  print "</form>\n";
415 
416  print '</td></tr>';
417  print "</table>\n";
418 }
419 
420 // Mode liste
421 if (($action != 'create' && $action != 'add') && !$error) {
422  llxHeader();
423  ?>
424  <script type="text/javascript">
425  jQuery(document).ready(function() {
426  jQuery("#checkall").click(function() {
427  jQuery(".checkformerge").prop('checked', true);
428  });
429  jQuery("#checknone").click(function() {
430  jQuery(".checkformerge").prop('checked', false);
431  });
432  });
433  </script>
434 <?php
435 
436  $sql = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
437  $sql .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
438  $sql .= ' FROM ' . MAIN_DB_PREFIX . 'societe as s';
439  $sql .= ', ' . MAIN_DB_PREFIX . 'commande_fournisseur as c';
440  if (! $user->rights->societe->client->voir && ! $socid)
441  $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
442  $sql .= ' WHERE c.entity = ' . $conf->entity;
443  $sql .= ' AND c.fk_soc = s.rowid';
444 
445  // Show orders with status validated, shipping started and delivered (well any order we can bill)
446  $sql .= " AND c.fk_statut IN (5)";
447  $sql .= " AND c.billed = 0";
448 
449  // Find order that are not already invoiced
450  //No need due to the billed status
451  //$sql .= " AND c.rowid NOT IN (SELECT fk_source FROM " . MAIN_DB_PREFIX . "element_element WHERE targettype='invoice_supplier')";
452 
453  if ($socid)
454  $sql .= ' AND s.rowid = ' . $socid;
455  if (! $user->rights->societe->client->voir && ! $socid)
456  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;
457  if ($sref) {
458  $sql .= natural_search("c.ref", $sref);
459  }
460  if ($sall) {
461  $sql .= natural_search(array("c.ref","c.note"), $sall);
462  }
463 
464  // Date filter
465  if ($date_start && $date_end)
466  $sql .= " AND c.date_commande >= '" . $db->idate($date_start) . "' AND c.date_commande <= '" . $db->idate($date_end) . "'";
467  if ($date_starty && $date_endy)
468  $sql .= " AND c.date_livraison >= '" . $db->idate($date_starty) . "' AND c.date_livraison <= '" . $db->idate($date_endy) . "'";
469 
470  if (! empty($sref_client)) {
471  $sql .= natural_search('c.ref_supplier', $sref_client);
472  }
473  $sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder;
474  dol_syslog('fourn/commande/ordertoinvoice.php sql=' . $sql);
475  $resql = $db->query($sql);
476 
477  if ($resql) {
478  if ($socid) {
479  $soc = new Societe($db);
480  $soc->fetch($socid);
481  }
482  $title = $langs->trans('ListOfSupplierOrders');
483  $title .= ' - ' . $langs->trans('StatusOrderReceivedAllShort');
484  $num = $db->num_rows($resql);
485  print load_fiche_titre($title);
486  $i = 0;
487  $period = $html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0) . ' - ' . $html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0);
488  $periodely = $html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0) . ' - ' . $html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0);
489 
490  if (! empty($socid)) {
491  // Company
492  $companystatic->id = $socid;
493  $companystatic->nom = $soc->nom;
494  print '<h3>' . $companystatic->getNomUrl(1, 'customer') . '</h3>';
495  }
496 
497  print '<form name="orders2invoice" method="GET" action="orderstoinvoice.php">';
498  print '<input type="hidden" name="socid" value="' . $socid . '">';
499  print '<table class="noborder" width="100%">';
500  print '<tr class="liste_titre">';
501  print_liste_field_titre('Ref', 'orderstoinvoice.php', 'c.ref', '', '&amp;socid=' . $socid, '', $sortfield, $sortorder);
502  print_liste_field_titre('RefSupplier', 'orderstoinvoice.php', 'c.ref_supplier', '', '&amp;socid=' . $socid, '', $sortfield, $sortorder);
503  print_liste_field_titre('OrderDate', 'orderstoinvoice.php', 'c.date_commande', '', '&amp;socid=' . $socid, 'align="center"', $sortfield, $sortorder);
504  print_liste_field_titre('DeliveryDate', 'orderstoinvoice.php', 'c.date_livraison', '', '&amp;socid=' . $socid, 'align="center"', $sortfield, $sortorder);
505  print_liste_field_titre('Status', '', '', '', '', 'align="right"');
506  print_liste_field_titre('GenerateBill', '', '', '', '', 'align="center"');
507  print "</tr>\n";
508 
509  // Lignes des champs de filtre
510  print '<tr class="liste_titre">';
511  print '<td class="liste_titre">';
512  // REF
513  print '<input class="flat" size="10" type="text" name="sref" value="' . $sref . '">';
514  print '</td>';
515  // print '<td class="liste_titre">';
516  print '<td class="liste_titre" align="left">';
517  print '<input class="flat" type="text" size="10" name="sref_client" value="' . $sref_client . '">';
518  print '</td>';
519 
520  // DATE ORDER
521  print '<td class="liste_titre" align="center">';
522  print $period;
523  print '</td>';
524 
525  // DATE DELIVERY
526  print '<td class="liste_titre" align="center">';
527  print $periodely;
528  print '</td>';
529 
530  // SEARCH BUTTON
531  print '<td align="right" class="liste_titre">';
532  print '<input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
533  print '</td>';
534 
535  // ALL/NONE
536  print '<td class="liste_titre" align="center">';
537  if ($conf->use_javascript_ajax)
538  print '<a href="#" id="checkall">' . $langs->trans("All") . '</a> / <a href="#" id="checknone">' . $langs->trans("None") . '</a>';
539  print '</td>';
540 
541  print '</td></tr>';
542 
543  $generic_commande = new CommandeFournisseur($db);
544 
545  while ($i < $num) {
546  $objp = $db->fetch_object($resql);
547 
548  print '<tr class="oddeven">';
549  print '<td class="nowrap">';
550 
551  $generic_commande->id = $objp->rowid;
552  $generic_commande->ref = $objp->ref;
553 
554  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
555  print '<td class="nobordernopadding nowrap">';
556  print $generic_commande->getNomUrl(1, $objp->fk_statut);
557  print '</td>';
558 
559  print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
560  $filename = dol_sanitizeFileName($objp->ref);
561  $filedir = $conf->fournisseur->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref);
562  $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objp->rowid;
563  print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
564  print '</td></tr></table>';
565  print '</td>';
566 
567  print '<td>' . $objp->ref_supplier . '</td>';
568 
569  // Order date
570  print '<td align="center" nowrap>';
571  print dol_print_date($db->jdate($objp->date_commande), 'day');
572  print '</td>';
573 
574  // Delivery date
575  print '<td align="center" nowrap>';
576  print dol_print_date($db->jdate($objp->date_livraison), 'day');
577  print '</td>';
578 
579  // Statut
580  print '<td align="right" class="nowrap">' . $generic_commande->LibStatut($objp->fk_statut, 5) . '</td>';
581 
582  // Checkbox
583  print '<td class="center">';
584  print '<input class="flat checkformerge" type="checkbox" name="orders_to_invoice[]" value="' . $objp->rowid . '">';
585  print '</td>';
586 
587  print '</tr>';
588 
589  $total = $total + $objp->price;
590  $subtotal = $subtotal + $objp->price;
591  $i ++;
592  }
593  print '</table>';
594 
595  /*
596  * Boutons actions
597  */
598  print '<div class="center">';
599  print '<div class="right">';
600  print '<input type="hidden" name="socid" value="' . $socid . '">';
601  print '<input type="hidden" name="action" value="create">';
602  print '<input type="hidden" name="origin" value="order_supplier"><br>';
603  // print '<a class="butAction" href="index.php">'.$langs->trans("GoBack").'</a>';
604  print '<input type="submit" class="butAction" value="' . $langs->trans("GenerateBill") . '">';
605  print '</div>';
606  print '</div>';
607 
608  print '</form>';
609 
610  $db->free($resql);
611  } else {
612  print dol_print_error($db);
613  }
614 }
615 
616 dol_htmloutput_mesg($mesg, $mesgs);
617 
618 // End of page
619 llxFooter();
620 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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:1053
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
Class to manage suppliers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage standard extra fields.
Class to manage hooks.
Class to manage generation of HTML components Only common components must be here.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
type
Definition: viewcat.php:284
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage building of HTML components.
Classe permettant la generation de composants html autre Only common components are here...
llxHeader()
Empty header.
Definition: wrapper.php:44
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='gmt')
Return date for now.
Class to manage predefined suppliers products.
Class to offer components to list and upload files.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation models.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).